Creates a new MutableVector3 instance.
The typed array containing the vector components
Gets the alpha component (always 1 for RGB colors).
Always returns 1
Gets the blue color component.
The blue component value (0.0 to 1.0)
Sets the blue color component.
The blue component value (typically 0.0 to 1.0)
Gets the number of bytes per component in the underlying typed array.
The number of bytes per element (4 for Float32Array, 8 for Float64Array)
Gets the class name for debugging purposes.
The class name string
Gets the green color component.
The green component value (0.0 to 1.0)
Sets the green color component.
The green component value (typically 0.0 to 1.0)
Gets the GLSL representation of this vector as a float vec3.
A string representation suitable for GLSL shaders
Gets the GLSL representation of this vector as an integer ivec3.
A string representation suitable for GLSL shaders with integer components
Gets the red color component.
The red component value (0.0 to 1.0)
Sets the red color component.
The red component value (typically 0.0 to 1.0)
Gets the W component (always 1 for RGB colors).
Always returns 1
Gets the WGSL representation of this vector as a float vec3f.
A string representation suitable for WGSL shaders
Gets the WGSL representation of this vector as an integer vec3i.
A string representation suitable for WGSL shaders with integer components
Gets the X component (same as red component).
The X/red component value
Sets the X component (same as red component).
The value to set for X/red component
Gets the Y component (same as green component).
The Y/green component value
Sets the Y component (same as green component).
The value to set for Y/green component
Gets the Z component (same as blue component).
The Z/blue component value
Sets the Z component (same as blue component).
The value to set for Z/blue component
StaticcompositionGets the composition type for this vector class.
The composition type (Vec3)
Adds another vector to this vector. Performs component-wise addition and modifies this vector in place.
The vector to add
This vector instance for method chaining
Gets the component at the specified index.
The index (0 for x, 1 for y, 2 for z)
The component value at the specified index
Creates a deep copy of this MutableColorRgb instance.
A new MutableColorRgb instance with the same RGB values
Copies the components from another vector.
The vector to copy from
This vector instance for method chaining
Computes the cross product of this vector with another vector. Calculates the cross product and modifies this vector in place to store the result. The cross product produces a vector perpendicular to both input vectors.
The vector to compute cross product with
This vector instance for method chaining
Divides this vector by a scalar value. Scales all components by 1/value and modifies this vector in place. If value is 0, sets all components to Infinity and logs an error.
The scalar value to divide by
This vector instance for method chaining
Divides this vector by another vector component-wise. Performs element-wise division and modifies this vector in place. If any component of the divisor vector is 0, sets the corresponding component to Infinity.
The vector to divide by
This vector instance for method chaining
Calculates the dot product of this vector with another vector.
The vector to calculate dot product with
The dot product result
Converts the vector to a flat array.
An array containing the x, y, and z components
Checks if this vector is a dummy vector (empty).
True if the vector is dummy (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 for comparison (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
Multiplies this vector by a scalar value. Scales all components by the given value and modifies this vector in place.
The scalar value to multiply by
This vector instance for method chaining
Applies a quaternion rotation to this vector. Rotates this vector by the given quaternion and modifies it in place. Equivalent to: quat * vector3 * quat^(-1)
The quaternion representing the rotation
This vector instance for method chaining
Multiplies this vector by another vector component-wise. Performs element-wise multiplication and modifies this vector in place.
The vector to multiply by
This vector instance for method chaining
Normalizes this vector to unit length. Modifies the vector in place to have a magnitude of 1.
This vector instance for method chaining
Returns the raw typed array containing the vector components.
The underlying typed array
Sets the value at the specified index.
The index (0 for x, 1 for y, 2 for z)
The new value to set
This vector instance for method chaining
Sets all three components of the vector.
The x component value
The y component value
The z component value
This vector instance for method chaining
Subtracts another vector from this vector. Performs component-wise subtraction and modifies this vector in place.
The vector to subtract
This vector instance for method chaining
Converts the vector to a string representation.
A string representation of the vector in the format "(x, y, z)"
Converts the vector to an approximate string representation with limited decimal places.
A string representation with financial formatting
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 first vector
The second vector
The typed array constructor to use
A new vector containing the sum
Static_Calculates the cross product of two vectors (static version).
The first vector (left operand)
The second vector (right operand)
The typed array constructor to use
A new vector containing the cross product result
Static_Divides a vector by a scalar value (static version).
The vector to divide
The scalar value to divide by
The typed array constructor to use
A new vector containing the divided result
Static_Divides two vectors component-wise (static version).
The vector to divide
The vector to divide by
The typed array constructor to use
A new vector containing the component-wise division result
Static_Creates an empty dummy vector for placeholder purposes.
The typed array constructor to use
A new dummy vector
Protected Static_ProtectedCreates a new vector from three component values.
The x component
The y component
The z component
The typed array constructor
A new vector instance
Static_Creates a vector from an array (takes first 3 elements).
The array containing the components
The typed array constructor to use
A new vector
Static_Creates a vector from a 3-element array.
The array containing x, y, z components
The typed array constructor to use
A new vector
Static_Creates a vector by copying from another Vector3.
The source vector to copy from
The typed array constructor to use
A new vector
Static_Creates a Vector3 from a Vector4 (drops the w component).
The source Vector4 to copy from
The typed array constructor to use
A new vector
Static_Creates a Vector3 from a Vector2 (sets z component to 0).
The source Vector2 to copy from
The typed array constructor to use
A new vector
Static_Performs linear interpolation between two vectors (static version).
The start vector
The end vector
The interpolation ratio (0.0 to 1.0)
The typed array constructor to use
A new vector containing the interpolated result
Static_Multiplies a vector by a scalar value (static version).
The vector to multiply
The scalar value to multiply by
The typed array constructor to use
A new vector containing the scaled result
Static_Transforms a 3D vector by a 4x4 matrix, treating the vector as a point (w=1). The result is perspective-divided if the w component is not 1.
The vector to transform
The 4x4 transformation matrix
The typed array constructor to use
A new transformed vector
Static_Transforms a vector by a quaternion rotation (static version). This applies the quaternion rotation to the vector.
The quaternion to apply
The vector to transform
The typed array constructor to use
A new vector containing the transformed result
Static_Multiplies two vectors component-wise (static version).
The first vector
The second vector
The typed array constructor to use
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 to use
A new normalized vector
Static_Creates a vector with all components set to 1 (1, 1, 1).
The typed array constructor to use
A new vector with all components set to 1
Static_Subtracts the second vector from the first vector (static version).
The vector to subtract from
The vector to subtract
The typed array constructor to use
A new vector containing the difference
Static_Creates a zero vector (0, 0, 0).
The typed array constructor to use
A new zero vector
StaticaddAdds two vectors component-wise and returns the result as a MutableColorRgb.
A new MutableColorRgb with the sum of the input vectors
StaticaddAdds a scaled vector to another vector and stores the result in the output vector.
The vector to add to
The vector to add
The scale to apply to the second vector
The output vector to store the result
The output vector containing the sum
StaticaddAdds two vectors and stores the result in the output vector.
The first vector
The second vector
The output vector to store the result
The output vector containing the sum
StaticangleStaticcrossComputes the cross product of two vectors.
A new MutableColorRgb with the cross product result
StaticcrossCalculates the cross product of two vectors and stores the result in the output vector.
The first vector (left operand)
The second vector (right operand)
The output vector to store the result
The output vector containing the cross product result
StaticdivideDivides a vector by a scalar value.
The vector to divide
The scalar value to divide by
A new MutableColorRgb with the divided vector
StaticdivideDivides a vector by a scalar 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
StaticdivideDivides two vectors component-wise.
A new MutableColorRgb with the component-wise division
StaticdivideDivides two vectors component-wise and stores the result in the output vector.
The vector to divide
The vector to divide by
The output vector to store the result
The output vector containing the component-wise division result
StaticdotStaticdummyCreates a dummy MutableColorRgb instance for placeholder purposes.
A new MutableColorRgb instance for dummy use
StaticfromCreates a vector with all components set to the same value.
The value for all components
A new vector instance
StaticfromCreates a vector from three component values.
The x component
The y component
The z component
A new vector instance
StaticfromCreates a vector from an array, taking the first 3 elements.
The array containing at least 3 values
A new vector instance
StaticfromCreates a vector from a 3-element array.
The array containing x, y, z values
A new vector instance
StaticfromCreates a vector by copying from an existing Float32Array.
The Float32Array to copy from
A new vector instance with copied data
StaticfromCreates a vector by copying from another 3D vector.
The vector to copy from
A new vector instance
StaticfromCreates a 3D vector by copying from a 4D vector (ignoring w component).
The 4D vector to copy from
A new 3D vector instance
StaticfromCreates a vector from an existing Float32Array (shares the same buffer).
The Float32Array to use
A new vector instance
StaticlengthStaticlengthCalculates 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
StaticmultiplyMultiplies a vector by a scalar value.
The vector to multiply
The scalar value to multiply by
A new MutableColorRgb with the scaled vector
StaticmultiplyTransforms a 3D vector by a 4x4 matrix, treating the vector as a point (w=1). The result is perspective-divided if the w component is not 1.
The vector to transform
The 4x4 transformation matrix
The output vector to store the result
A new transformed vector
StaticmultiplyCreates a new vector by applying a quaternion rotation to a vector.
The quaternion representing the rotation
The vector to rotate
A new rotated vector
StaticmultiplyTransforms a vector by a quaternion rotation and stores the result in the output vector. This applies the quaternion rotation to the vector.
The quaternion to apply
The vector to transform
The output vector to store the result
The output vector containing the transformed result
StaticmultiplyMultiplies a vector by a scalar 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
StaticmultiplyMultiplies two vectors component-wise.
A new MutableColorRgb with the component-wise product
StaticmultiplyMultiplies two vectors component-wise and stores the result in the output vector.
The first vector
The second vector
The output vector to store the result
The output vector containing the component-wise product
StaticnormalizeCreates a normalized version of the given vector as a MutableColorRgb.
The vector to normalize
A new normalized MutableColorRgb instance
StaticnormalizeNormalizes a vector and stores the result in the output vector.
The vector to normalize
The output vector to store the result
The output vector containing the normalized result
StaticoneCreates a new MutableColorRgb with all components set to one (white).
A new MutableColorRgb instance with RGB values [1, 1, 1]
StaticrotateRotates a vector around the X-axis and stores the result in the output vector. Only the Y and Z components are affected by X-axis rotation.
The input vector to rotate
The rotation angle in radians
The output vector to store the result
StaticrotateRotates a vector around the Y-axis and stores the result in the output vector. Only the X and Z components are affected by Y-axis rotation.
The input vector to rotate
The rotation angle in radians
The output vector to store the result
StaticrotateRotates a vector around the Z-axis and stores the result in the output vector. Only the X and Y components are affected by Z-axis rotation.
The input vector to rotate
The rotation angle in radians
The output vector to store the result
StaticsubtractSubtracts the right vector from the left vector component-wise.
A new MutableColorRgb with the difference of the input vectors
StaticsubtractSubtracts two vectors and stores the result in the output vector.
The vector to subtract from
The vector to subtract
The output vector to store the result
The output vector containing the difference
StaticzeroCreates a new MutableColorRgb with all components set to zero (black).
A new MutableColorRgb instance with RGB values [0, 0, 0]
A mutable RGB color class that extends MutableVector3. Represents a color with red, green, and blue components, with alpha always set to 1. This class provides both vector-based operations and color-specific accessors.