Creates a new AnimatedVector2 instance.
A map of animation track names to their corresponding samplers
The name of the initial active animation track
Internal typed array storage for vector components
Whether the animation should loop when it reaches the end.
Gets the current blending ratio between animation tracks.
The current blending ratio
Sets the blending ratio between the first and second active animation tracks.
The blending ratio (0.0 = first track only, 1.0 = second track only)
Gets the number of bytes per component in the underlying typed array.
The number of bytes per component
Gets the class name.
The string "Vector2"
Converts the vector to a GLSL vec2 string representation with float precision.
GLSL-compatible vec2 string
Converts the vector to a GLSL ivec2 string representation with integer precision.
GLSL-compatible ivec2 string
Converts the vector to a WGSL vec2f string representation with float precision.
WGSL-compatible vec2f string
Converts the vector to a WGSL vec2i string representation with integer precision.
WGSL-compatible vec2i string
Gets the x component of the vector, updating the animation if necessary.
The x component value
Gets the y component of the vector, updating the animation if necessary.
The y component value
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.
The z component value
StaticcompositionGets the composition type of this vector.
The composition type (Vec2)
Gets the component at the specified index.
The index (0 for x, 1 for y)
The component value at the specified index
Removes an animation sampler from the available tracks.
The name of the animation track to remove
Calculates the dot product with another vector.
The vector to calculate dot product with
The dot product result
Converts the vector to a flat array representation.
Array containing [x, y] components
Gets all available animation track names.
An array containing all animation track names
Gets the animation sampler for a specific track.
The name of the animation track
The animation sampler for the specified track
Gets the name of the first (primary) active animation track.
The name of the first active animation track
Returns the current vector values as a regular JavaScript array.
An array containing the x and y components of the vector
Gets the name of the second (secondary) active animation track.
The name of the second active animation track, or undefined if not set
Checks if this vector is a dummy (empty) vector.
True if the vector has no components, false otherwise
Checks if this vector is approximately equal to another vector within a tolerance.
The vector to compare with
The tolerance value (default: Number.EPSILON)
True if vectors are approximately equal, false otherwise
Checks if this vector is strictly equal to another vector (exact comparison).
The vector to compare with
True if vectors 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.
The ArrayBuffer to compare against
True if the same ArrayBuffer is used, false otherwise
Calculates the length (magnitude) of the vector.
The length of the vector
Calculates the squared length of the vector. This is more efficient than calculating the actual length when only comparison is needed.
The squared length of the vector
Calculates the distance from this vector to another vector.
The target vector
The distance between the vectors
Adds or updates an animation sampler for a specific track.
The name of the animation track
The animation sampler to associate with the track
Sets the internal Float32Array and triggers an update.
The new Float32Array to use for the vector components
Sets a specific time for animation evaluation instead of using global time.
The time value to use for animation sampling
Converts the vector to a string representation.
String representation in the format "(x, y)"
Converts the vector to an approximate string representation with financial precision.
String representation with reduced decimal places
Updates the vector values based on the current time and active animation tracks. Handles looping, blending between tracks, and caching to avoid redundant calculations.
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.
Gets the component value at the specified index. Alias for the at() method for convenience.
The index of the component to retrieve
The component value at the given index
Static_Adds two vectors component-wise (static version).
The left vector operand
The right vector operand
The typed array constructor
A new vector containing the sum
Static_Divides a vector by a scalar value (static version).
The vector to divide
The scalar value to divide by
The typed array constructor
A new vector containing the divided result
Static_Divides the left vector by the right vector component-wise (static version).
The left vector operand (dividend)
The right vector operand (divisor)
The typed array constructor
A new vector containing the component-wise division result
Static_Creates a dummy vector with no components.
The typed array constructor
A new dummy vector
Static_Creates a vector from individual x and y components.
The x component
The y component
The typed array constructor
A new vector instance
Static_Creates a vector from an array, taking the first 2 elements.
The array containing components
The typed array constructor
A new vector instance
Static_Creates a vector from a 2-element array.
The array containing [x, y] components
The typed array constructor
A new vector instance
Static_Creates a vector by copying components from another IVector2.
The source vector
The typed array constructor
A new vector instance
Static_Creates a vector by copying the first 2 components from a 3D vector.
The source 3D vector
The typed array constructor
A new vector instance
Static_Creates a vector by copying the first 2 components from a 4D vector.
The source 4D vector
The typed array constructor
A new vector instance
Static_Creates a vector from another IVector2 by sharing the underlying array.
The source vector
The typed array constructor
A new vector instance
Static_Multiplies a vector by a scalar value (static version).
The vector to multiply
The scalar value to multiply by
The typed array constructor
A new vector containing the scaled result
Static_Multiplies two vectors component-wise (static version).
The left vector operand
The right vector operand
The typed array constructor
A new vector containing the component-wise product
Static_Normalizes a vector to unit length (static version).
The vector to normalize
The typed array constructor
A new normalized vector
Static_Creates a one vector (1, 1).
The typed array constructor
A new one vector
Static_Subtracts the right vector from the left vector component-wise (static version).
The left vector operand
The right vector operand
The typed array constructor
A new vector containing the difference
Static_Creates a zero vector (0, 0).
The typed array constructor
A new zero vector
StaticaddStaticaddAdds two vectors component-wise and stores the result in the output vector.
The left vector operand
The right vector operand
The output vector to store the result
The output vector containing the sum
StaticangleStaticdivideStaticdivideDivides a vector by a scalar value and stores the result in the output vector.
The vector to divide
The scalar value to divide by
The output vector to store the result
The output vector containing the divided result
StaticdivideStaticdivideDivides the left vector by the right vector component-wise and stores the result in the output vector.
The left vector operand (dividend)
The right vector operand (divisor)
The output vector to store the result
The output vector containing the component-wise division result
StaticdotStaticdummyStaticfromCreates a vector from individual x and y components.
The x component
The y component
A new Vector2 instance
StaticfromCreates a vector from an array, taking the first 2 elements.
The array containing components
A new Vector2 instance
StaticfromStaticfromStaticfromStaticlengthStaticlengthCalculates the squared length of a vector (static version). This is more efficient than calculating the actual length when only comparison is needed.
The vector to calculate squared length for
The squared length of the vector
StaticmultiplyStaticmultiplyMultiplies a vector by a scalar value and stores the result in the output vector.
The vector to multiply
The scalar value to multiply by
The output vector to store the result
The output vector containing the scaled result
StaticmultiplyStaticmultiplyMultiplies two vectors component-wise and stores the result in the output vector.
The left vector operand
The right vector operand
The output vector to store the result
The output vector containing the component-wise product
StaticnormalizeStaticoneStaticsubtractStaticsubtractSubtracts the right vector from the left vector component-wise and stores the result in the output vector.
The left vector operand
The right vector operand
The output vector to store the result
The output vector containing the difference
Staticzero
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.