rhodonite
    Preparing search index...

    Class AnimatedVector2

    An animated 2D vector that can interpolate between animation keyframes over time. This class extends Vector2 and implements both IVector2 and IAnimatedValue interfaces, providing support for animation blending, looping, and time-based value updates.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    _v: TypedArray = ...

    Internal typed array storage for vector components

    isLoop: boolean = true

    Whether the animation should loop when it reaches the end.

    Accessors

    • get blendingRatio(): number

      Gets the current blending ratio between animation tracks.

      Returns number

      The current blending ratio

    • set blendingRatio(value: number): void

      Sets the blending ratio between the first and second active animation tracks.

      Parameters

      • value: number

        The blending ratio (0.0 = first track only, 1.0 = second track only)

      Returns void

    • get glslStrAsFloat(): string

      Converts the vector to a GLSL vec2 string representation with float precision.

      Returns string

      GLSL-compatible vec2 string

    • get glslStrAsInt(): string

      Converts the vector to a GLSL ivec2 string representation with integer precision.

      Returns string

      GLSL-compatible ivec2 string

    • get glslStrAsUint(): string

      Gets the GLSL string representation of the vector as unsigned integer values.

      Returns string

      GLSL-formatted string for unsigned integer values with 'u' suffix

      Error - Must be implemented by subclasses

    • get wgslStrAsFloat(): string

      Converts the vector to a WGSL vec2f string representation with float precision.

      Returns string

      WGSL-compatible vec2f string

    • get wgslStrAsInt(): string

      Converts the vector to a WGSL vec2i string representation with integer precision.

      Returns string

      WGSL-compatible vec2i string

    • get wgslStrAsUint(): string

      Gets the WGSL string representation of the vector as unsigned integer values.

      Returns string

      WGSL-formatted string for unsigned integer values with 'u' suffix

      Error - Must be implemented by subclasses

    • get z(): number

      Gets the z component of the vector, updating the animation if necessary. Note: This always returns the z component even though this is a 2D vector.

      Returns number

      The z component value

    • get compositionType(): CompositionTypeClass<"VEC2">

      Gets the composition type of this vector.

      Returns CompositionTypeClass<"VEC2">

      The composition type (Vec2)

    Methods

    • Gets the component at the specified index.

      Parameters

      • i: number

        The index (0 for x, 1 for y)

      Returns number

      The component value at the specified index

    • Removes an animation sampler from the available tracks.

      Parameters

      • trackName: string

        The name of the animation track to remove

      Returns void

    • Gets all available animation track names.

      Returns string[]

      An array containing all animation track names

    • Gets the animation sampler for a specific track.

      Parameters

      • trackName: string

        The name of the animation track

      Returns AnimationSampler

      The animation sampler for the specified track

      When the specified animation track is not found

    • Gets the name of the first (primary) active animation track.

      Returns string

      The name of the first active animation track

    • Gets the maximum end time for a specific animation track.

      Parameters

      • trackName: string

        The name of the animation track

      Returns number

      The maximum end time (last input value) of the specified track

      When the specified animation track is not found

    • Gets the minimum start time for a specific animation track.

      Parameters

      • trackName: string

        The name of the animation track

      Returns number

      The minimum start time (first input value) of the specified track

      When the specified animation track is not found

    • Returns the current vector values as a regular JavaScript array.

      Returns number[]

      An array containing the x and y components of the vector

    • Gets the name of the second (secondary) active animation track.

      Returns string | undefined

      The name of the second active animation track, or undefined if not set

    • Checks if this vector is approximately equal to another vector within a tolerance.

      Parameters

      • vec: IVector2

        The vector to compare with

      • delta: number = Number.EPSILON

        The tolerance value (default: Number.EPSILON)

      Returns boolean

      True if vectors are approximately equal, false otherwise

    • Checks if the internal storage shares the same ArrayBuffer as the provided one. Useful for determining if vectors share underlying memory.

      Parameters

      • arrayBuffer: ArrayBuffer

        The ArrayBuffer to compare against

      Returns boolean

      True if the same ArrayBuffer is used, false otherwise

    • Adds or updates an animation sampler for a specific track.

      Parameters

      • animationTrackName: string

        The name of the animation track

      • animationSampler: AnimationSampler

        The animation sampler to associate with the track

      Returns void

    • Sets the first (primary) active animation track.

      Parameters

      • animationTrackName: string

        The name of the animation track to set as primary

      Returns void

      When the specified animation track is not found (logged as info instead)

    • Sets the internal Float32Array and triggers an update.

      Parameters

      • array: Float32Array

        The new Float32Array to use for the vector components

      Returns void

    • Sets the second (secondary) active animation track for blending.

      Parameters

      • animationTrackName: string

        The name of the animation track to set as secondary

      Returns void

      When the specified animation track is not found (logged as info instead)

    • Sets a specific time for animation evaluation instead of using global time.

      Parameters

      • time: number

        The time value to use for animation sampling

      Returns void

    • Updates the vector values based on the current time and active animation tracks. Handles looping, blending between tracks, and caching to avoid redundant calculations.

      Returns void

    • Clears the specific time and uses the default time (0) for animation updates. When used with AnimationComponent, the time will be set via setTime() during animation processing.

      Returns void

    • Gets the component value at the specified index. Alias for the at() method for convenience.

      Parameters

      • i: number

        The index of the component to retrieve

      Returns number

      The component value at the given index

    • Calculates the squared length of a vector (static version). This is more efficient than calculating the actual length when only comparison is needed.

      Parameters

      • vec: IVector2

        The vector to calculate squared length for

      Returns number

      The squared length of the vector