rhodonite
    Preparing search index...

    Class AnimatedScalar

    A scalar value that can be animated using animation samplers. This class extends Scalar and implements both IScalar and IAnimatedValue interfaces. It supports blending between two animation tracks and can be configured to loop.

    Hierarchy (View Summary)

    Implements

    Index
    • Creates a new AnimatedScalar instance.

      Parameters

      • animationSamplers: AnimationSamplers

        A map of animation track names to their corresponding samplers

      • activeAnimationTrackName: string

        The name of the initially active animation track

      Returns AnimatedScalar

      If the specified animation track is not found in the samplers

    _v: TypedArray = ...

    Internal typed array storage for vector components

    isLoop: boolean = true

    Whether the animation should loop when it reaches the end.

    • 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 animation tracks.

      Parameters

      • value: number

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

      Returns void

    • get bytesPerComponent(): number

      Gets the number of bytes per component in the underlying typed array.

      Returns number

      The number of bytes per element

    • get className(): string

      Gets the class name for debugging and reflection purposes.

      Returns string

      The string "Scalar"

    • get glslStrAsFloat(): string

      Gets the scalar value as a GLSL-compatible float string.

      Returns string

      The scalar value formatted as a GLSL float literal

    • get glslStrAsInt(): string

      Gets the scalar value as a GLSL-compatible integer string.

      Returns string

      The scalar value formatted as a GLSL integer literal

    • get glslStrAsUint(): string

      Gets the scalar value as a GLSL-compatible unsigned integer string.

      Returns string

      The scalar value formatted as a GLSL unsigned integer literal with 'u' suffix

    • get raw(): TypedArray

      Gets the raw typed array containing the scalar value.

      Returns TypedArray

      The underlying typed array

    • get wgslStrAsFloat(): string

      Gets the scalar value as a WGSL-compatible float string.

      Returns string

      The scalar value formatted as a WGSL float literal

    • get wgslStrAsInt(): string

      Gets the scalar value as a WGSL-compatible integer string.

      Returns string

      The scalar value formatted as a WGSL integer literal

    • get wgslStrAsUint(): string

      Gets the scalar value as a WGSL-compatible unsigned integer string.

      Returns string

      The scalar value formatted as a WGSL unsigned integer literal with 'u' suffix

    • get x(): number

      Gets the current scalar value, updating the animation if necessary.

      Returns number

      The current scalar value

    • get compositionType(): CompositionTypeEnum

      Gets the composition type for scalar values.

      Returns CompositionTypeEnum

      The scalar composition type

    • Gets the component value at the specified index.

      Parameters

      • i: number

        The index of the component to retrieve

      Returns number

      The component value at the given index

    • Creates a deep copy of this scalar.

      Returns Scalar

      A new Scalar instance with the same value

    • Deletes an animation sampler for the specified track name.

      Parameters

      • trackName: string

        The name of the animation track to delete

      Returns void

    • Calculates the dot product between this vector and another vector.

      Parameters

      Returns number

      The dot product result

      Error - Must be implemented by subclasses

    • Converts the vector to a flat array of numbers.

      Returns number[]

      Array containing all vector components

      Error - Must be implemented by subclasses

    • Gets an array of all available animation track names.

      Returns string[]

      An array containing all animation track names

    • Gets the animation sampler for the specified track name.

      Parameters

      • trackName: string

        The name of the animation track

      Returns AnimationSampler

      The animation sampler for the specified track

      If the specified animation track is not found

    • Number of actual interpolations performed. Intended for tests and benchmarks.

      Returns number

    • Gets the track name of the sampler that is actually bound as the first animation. This can differ from the requested active track when that track has no sampler.

      Returns string

      The track name of the currently evaluated first sampler

    • Gets the name of the first active animation track.

      Returns string

      The name of the first active animation track

    • Gets the maximum end time from the input keyframes of the specified animation track.

      Parameters

      • trackName: string

        The name of the animation track

      Returns number

      The maximum end time of the animation track

      If the specified animation track is not found

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

      Parameters

      • trackName: string

        The name of the animation track

      Returns number

      The minimum start time of the animation track

      If the specified animation track is not found

    • Returns the scalar value as an array of numbers.

      Returns number[]

      An array containing the scalar value

    • Gets the track name of the sampler that is actually bound as the second animation. This can differ from the requested active track when that track has no sampler.

      Returns string | undefined

      The track name of the currently evaluated second sampler, or undefined if none is bound

    • Gets the name of the second active animation track.

      Returns string | undefined

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

    • Gets the scalar value as a number.

      Returns number

      The scalar value

    • Gets the internal value array without allocating a copy. Do not mutate the returned array.

      Returns TypedArray

    • Gets the scalar value wrapped in an array.

      Returns number[]

      An array containing the scalar value

    • Drops the memoized interpolation result. Call this after mutating sampler data directly.

      Returns void

    • Checks if this vector is a dummy (empty) vector. A dummy vector has no components and is typically used as a placeholder.

      Returns boolean

      True if the vector is dummy, false otherwise

    • Performs approximate equality comparison with another scalar within a tolerance.

      Parameters

      • scalar: Scalar_<Float32ArrayConstructor>

        The scalar to compare with

      • delta: number = Number.EPSILON

        The tolerance for comparison (default: Number.EPSILON)

      Returns boolean

      True if the scalars are equal within the specified tolerance

    • Performs strict equality comparison with another scalar. Uses exact floating-point comparison without tolerance.

      Parameters

      • scalar: Scalar_<Float32ArrayConstructor>

        The scalar to compare with

      Returns boolean

      True if the scalars are exactly 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

    • Calculates the length (magnitude) of the vector.

      Returns number

      The length of the vector

      Error - Must be implemented by subclasses

    • Calculates the squared length of the vector. This is more efficient than length() when only relative comparisons are needed.

      Returns number

      The squared length of the vector

      Error - Must be implemented by subclasses

    • Calculates the distance from this vector to another vector.

      Parameters

      Returns number

      The distance between the vectors

      Error - Must be implemented by subclasses

    • Sets or updates an animation sampler for the specified track name.

      Parameters

      • animationTrackName: string

        The name of the animation track

      • animationSampler: AnimationSampler

        The animation sampler to associate with the track

      Returns void

    • Sets the first active animation track by name.

      Parameters

      • animationTrackName: string

        The name of the animation track to set as the first active track

      Returns void

    • Sets the internal Float32Array and triggers an update.

      Parameters

      • array: Float32Array

        The new Float32Array to set

      Returns void

    • Sets the second active animation track by name for blending purposes.

      Parameters

      • animationTrackName: string

        The name of the animation track to set as the second active track

      Returns void

    • Sets a specific time for animation playback.

      Parameters

      • time: number

        The time value to set for animation sampling

      Returns void

    • Sets the time and blending ratio and evaluates the value at most once.

      Parameters

      • time: number
      • blendingRatio: number

      Returns void

    • Converts the scalar to a string representation.

      Returns string

      A string representation of the scalar in the format "(value)"

    • Converts the vector to an approximate string representation. Useful for debugging when exact precision is not required.

      Returns string

      Approximate string representation of the vector

      Error - Must be implemented by subclasses

    • Updates the animated scalar value based on the current time and active animation tracks. This method interpolates between keyframes and handles blending between two tracks if configured. The update is skipped if the time hasn't changed since the last update.

      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 dummy (uninitialized) scalar instance.

      Returns Scalar

      A new dummy Scalar instance

    • Creates a new scalar from a numeric value.

      Parameters

      • value: number

        The numeric value to create the scalar from

      Returns Scalar

      A new Scalar instance

    • Creates a scalar with value one.

      Returns Scalar

      A new Scalar instance with value 1

    • Creates a scalar with value zero.

      Returns Scalar

      A new Scalar instance with value 0