Static
_setForcefully sets the internal values of a mathematical object to match another object's values. This method directly modifies the internal array representation for performance. Performs equality check to avoid unnecessary operations.
Target object to modify
Source object or value to copy from
True if values were changed, false if they were already equal
Static
addStatic
arrayConverts a 4-element array to a Quaternion instance.
Array of 4 numbers representing quaternion components [x, y, z, w]
Quaternion instance created from the array elements
Static
arrayConverts an array of numbers to the appropriate Vector type based on array length.
Array of numbers to convert
Vector2, Vector3, or Vector4 instance based on array length, or the original element if not an array
Static
arrayConverts an array of numbers to the appropriate Vector or Matrix type based on array length. Supports conversion to Matrix44, Matrix33, Vector4, Vector3, or Vector2.
Array of numbers to convert
Matrix44, Matrix33, Vector4, Vector3, or Vector2 instance based on array length, or the original element if not an array
Static
cloneStatic
componentDetermines the number of components in a vector instance or array.
Vector instance or array to analyze
Number of components (2 for Vector2, 3 for Vector3, 4 for Vector4/Quaternion, array length for arrays, 0 for unsupported types)
Static
divideDivides various mathematical types by a scalar number. Supports numbers, vectors, quaternions, and arrays.
Mathematical object to divide
Scalar divisor
Result of the scalar division, type depends on input type
Static
getGets the immutable value class constructor for a given composition type.
The composition type enum value
Constructor function for the corresponding immutable math class, or undefined if not supported
Static
getGets the mutable value class constructor for a given composition type.
The composition type enum value
Constructor function for the corresponding mutable math class, or undefined if not supported
Static
initInitializes a mutable mathematical object from a value using a provided Float32Array as storage. This method efficiently reuses memory by using the provided array as the backing store.
Value to initialize from (can be various mathematical types)
Float32Array to use as backing storage
Mutable mathematical object using the provided array as storage
Static
initInitializes a mathematical object of the same type as the input with a scalar value. For vectors and arrays, all components are set to the scalar value. For quaternions, creates an identity quaternion.
Object used to determine the target type
Scalar value to initialize with
New instance of the same type as objForDetectType initialized with val
Static
isStatic
makeCreates a sub-array with the specified number of components from the beginning of the input array.
Source array to extract elements from
Number of components to extract (1-4)
Sub-array with the specified number of elements, or single element if componentN is 1
Static
multiplyMultiplies various mathematical types by a scalar number. Supports numbers, vectors, quaternions, and arrays.
Mathematical object to multiply
Scalar multiplier
Result of the scalar multiplication, type depends on input type
Static
packPacks a normalized 4D vector into a 2D vector using a grid-based encoding scheme. Input values must be in the range [-1, 1] and are converted to [0, 1] internally.
X component of the 4D vector (must be in range [-1, 1])
Y component of the 4D vector (must be in range [-1, 1])
Z component of the 4D vector (must be in range [-1, 1])
W component of the 4D vector (must be in range [-1, 1])
Grid resolution for encoding (determines precision)
Array of 2 values representing the packed vector
Static
subtractPerforms subtraction operation on various mathematical types. Supports numbers, vectors, quaternions, and arrays.
Left-hand side operand (minuend)
Right-hand side operand (subtrahend)
Result of the subtraction operation, type depends on input types
Static
unUnprojects a window coordinate to world space using the inverse projection-view matrix. Converts 2D screen coordinates with depth to 3D world coordinates.
X coordinate in window space
Y coordinate in window space
Z coordinate (depth) in window space
Inverse of the projection-view matrix
Viewport parameters [x, y, width, height]
Output vector to store the result
The unprojected 3D world position
Static
vectorConverts vector instances to arrays of their component values.
Vector2, Vector3, Vector4, or Quaternion instance
Array representation of the vector components, or the original element if not a vector
Utility class providing various mathematical operations and conversions for vector, matrix, and quaternion types. This class contains static methods for converting between different mathematical representations, performing arithmetic operations, and manipulating mathematical objects.