rhodonite
    Preparing search index...

    Class AnimatedVector3

    An animated 3D vector that interpolates values based on animation tracks.

    This class extends Vector3 to provide animation capabilities, allowing the vector to change its values over time based on animation samplers. It supports blending between two animation tracks and can operate in looped or non-looped modes.

    const samplers = new Map();
    const animatedVector = new AnimatedVector3(samplers, "track1");
    animatedVector.setTime(1.5);
    console.log(animatedVector.x, animatedVector.y, animatedVector.z);

    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 blending ratio between 0 and 1

    • set blendingRatio(value: number): void

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

      Parameters

      • value: number

        A value between 0 and 1, where 0 means only the first track is used and 1 means only the second track is used

      Returns void

    • get bytesPerComponent(): number

      Gets the number of bytes per component.

      Returns number

      The number of bytes per component (4 for Float32Array, 8 for Float64Array)

    • get glslStrAsFloat(): string

      Gets the GLSL representation of this vector as a float vec3.

      Returns string

      A string representation suitable for GLSL shaders

    • get glslStrAsInt(): string

      Gets the GLSL representation of this vector as an integer ivec3.

      Returns string

      A string representation suitable for GLSL shaders with integer components

    • 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 w(): number

      Gets the W component of the vector (always returns 1 for homogeneous coordinates).

      Returns number

      Always returns 1

    • get wgslStrAsFloat(): string

      Gets the WGSL representation of this vector as a float vec3f.

      Returns string

      A string representation suitable for WGSL shaders

    • get wgslStrAsInt(): string

      Gets the WGSL representation of this vector as an integer vec3i.

      Returns string

      A string representation suitable for WGSL shaders with integer components

    • 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 x(): number

      Gets the X component of the vector.

      This getter automatically triggers an update to ensure the value reflects the current animation state.

      Returns number

      The current X component value

    • get y(): number

      Gets the Y component of the vector.

      This getter automatically triggers an update to ensure the value reflects the current animation state.

      Returns number

      The current Y component value

    • get z(): number

      Gets the Z component of the vector.

      This getter automatically triggers an update to ensure the value reflects the current animation state.

      Returns number

      The current Z component value

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

      Gets the composition type for this vector class.

      Returns CompositionTypeClass<"VEC3">

      The composition type (Vec3)

    Methods

    • Gets the component at the specified index.

      Parameters

      • i: number

        The index (0 for x, 1 for y, 2 for z)

      Returns number

      The component value at the specified index

    • Removes an animation sampler for the specified track.

      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 the specified 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 from the input data of the specified animation track.

      Parameters

      • trackName: string

        The name of the animation track

      Returns number

      The maximum input time value

      When the specified animation track is not found

    • Gets the minimum start time from the input data of the specified animation track.

      Parameters

      • trackName: string

        The name of the animation track

      Returns number

      The minimum input time value

      When the specified animation track is not found

    • Returns the vector components as a regular JavaScript array.

      Returns number[]

      An array containing the x, y, and z components

    • 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: IVector3

        The vector to compare with

      • delta: number = Number.EPSILON

        The tolerance for comparison (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

    • Sets or updates an animation sampler for the specified 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

    • Sets the vector values from a Float32Array and triggers an update.

      Parameters

      • array: Float32Array

        A Float32Array containing the new x, y, z values

      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

    • Sets the current animation time and triggers an update.

      When a specific time is set, the vector will use this time instead of the global animation time for interpolation calculations.

      Parameters

      • time: number

        The time value in seconds

      Returns void

    • Updates the vector values based on the current animation state.

      This method interpolates values from the active animation tracks using the current time. If two tracks are active, it blends them according to the blending ratio. The method handles looping and caches results to avoid unnecessary recalculations.

      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

    • Creates a vector from individual x, y, z components.

      Parameters

      • x: number

        The x component

      • y: number

        The y component

      • z: number

        The z component

      Returns Vector3

      A new Vector3 instance

    • 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: IVector3

        The vector to calculate squared length for

      Returns number

      The squared length of the vector