Class AnimatedQuaternion

An animated quaternion that can be driven by animation samplers. This class extends the base Quaternion class to provide animation capabilities, allowing quaternion values to be interpolated over time using animation tracks. Supports blending between multiple animation tracks and both local and global time management.

Hierarchy (view full)

Implements

Constructors

Properties

_v: Float32Array = ...

Internal typed array storage for quaternion components [x, y, z, w].

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): void
  • Sets the blending ratio between the first and second active animation tracks.

    Parameters

    • value: number

      Blending ratio (0.0 = first track only, 1.0 = second track only)

    Returns void

  • get compositionType(): CompositionTypeClass<"VEC4">
  • Gets the composition type for this quaternion class.

    Returns CompositionTypeClass<"VEC4">

    CompositionType.Vec4 indicating this is a 4-component vector

Methods

  • Deletes an animation sampler for the specified track.

    Parameters

    • trackName: string

      The animation track name to delete

    Returns void

  • Calculates the dot product between this quaternion and another quaternion. The dot product of two quaternions gives a scalar value that represents the cosine of half the angle between them when both quaternions are unit quaternions.

    Parameters

    • quat: IQuaternion

      The quaternion to compute the dot product with

    Returns number

    The dot product result

  • Gets all available animation track names.

    Returns string[]

    Array of all animation track names

  • Gets the animation sampler for the specified track.

    Parameters

    • trackName: string

      The animation track name

    Returns AnimationSampler

    The animation sampler for the track

    When the specified animation track is not found

  • Gets the name of the first active animation track.

    Returns string

    The first active animation track name

  • Gets the maximum end time for the specified animation track.

    Parameters

    • trackName: string

      The animation track name

    Returns number

    The end time of the animation track

    When the specified animation track is not found

  • Gets the minimum start time for the specified animation track.

    Parameters

    • trackName: string

      The animation track name

    Returns number

    The start time of the animation track

    When the specified animation track is not found

  • Returns the quaternion values as a number array.

    Returns number[]

    Array containing the x, y, z, w components of the quaternion

  • Gets the name of the second active animation track.

    Returns undefined | string

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

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

    Parameters

    • quat: IQuaternion

      The quaternion to compare with

    • delta: number = Number.EPSILON

      The tolerance value (default: Number.EPSILON)

    Returns boolean

    True if all components are within the tolerance, false otherwise

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

    Parameters

    • animationTrackName: string

      The animation track name

    • animationSampler: AnimationSampler

      The animation sampler to set

    Returns void

  • Sets the first active animation track.

    Parameters

    • animationTrackName: string

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

    Returns void

  • Sets the quaternion values from a Float32Array.

    Parameters

    • array: Float32Array

      Float32Array containing the quaternion components [x, y, z, w]

    Returns void

  • Sets the second active animation track for blending.

    Parameters

    • animationTrackName: string

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

    Returns void

  • Sets the local animation time for this quaternion. When set, this time will be used instead of the global animation time.

    Parameters

    • time: number

      The animation time in seconds

    Returns void

  • Updates the quaternion values based on the current animation time and active tracks. This method interpolates values from animation samplers and handles blending between tracks. If looping is enabled, the time will wrap around the animation duration.

    Returns void

  • Switches to using global animation time instead of local time. Resets the local time and triggers an update.

    Returns void

  • Clamps the rotation angle of a quaternion to a maximum value. If the quaternion's rotation angle exceeds thetaMax, it scales the rotation down.

    Parameters

    • quat: IQuaternion

      The quaternion to clamp

    • thetaMax: number

      The maximum allowed rotation angle in radians

    Returns IQuaternion

    A quaternion with rotation angle clamped to thetaMax

  • Performs linear interpolation (LERP) between two quaternions. Note: LERP does not maintain constant angular velocity like SLERP.

    Parameters

    • l_quat: IQuaternion

      The starting quaternion

    • r_quat: IQuaternion

      The ending quaternion

    • ratio: number

      The interpolation parameter (0.0 = l_quat, 1.0 = r_quat)

    Returns Quaternion

    The linearly interpolated quaternion

  • Performs spherical linear interpolation (SLERP) between two quaternions. SLERP provides smooth rotation interpolation that maintains constant angular velocity.

    Parameters

    • l_quat: IQuaternion

      The starting quaternion

    • r_quat: IQuaternion

      The ending quaternion

    • ratio: number

      The interpolation parameter (0.0 = l_quat, 1.0 = r_quat)

    Returns IQuaternion

    The interpolated quaternion