Constructs a new MutableColorRgba instance.
A Float32Array containing the RGBA values [r, g, b, a]
Gets the update counter value. This counter is incremented whenever the vector is modified.
The current update count
Gets the alpha component.
The alpha value
Sets the alpha component.
The alpha value to set
Gets the blue component.
The blue value
Sets the blue component.
The blue value to set
Gets the number of bytes per component in the underlying typed array.
The byte size per component (4 for Float32Array, 8 for Float64Array)
Gets the class name for debugging and identification purposes.
The string 'MutableVector4'
Gets the green component.
The green value
Sets the green component.
The green value to set
Converts the vector to a GLSL vec4 string representation with float precision.
A GLSL-compatible vec4 string (e.g., "vec4(1.0, 2.0, 3.0, 4.0)")
Converts the vector to a GLSL ivec4 string representation with integer values.
A GLSL-compatible ivec4 string (e.g., "ivec4(1, 2, 3, 4)")
Gets the red component.
The red value
Sets the red component.
The red value to set
Gets the w component (equivalent to alpha component).
The w/alpha value
Sets the w component (equivalent to alpha component).
The value to set
Converts the vector to a WGSL vec4f string representation with float precision.
A WGSL-compatible vec4f string (e.g., "vec4f(1.0, 2.0, 3.0, 4.0)")
Converts the vector to a WGSL vec4i string representation with integer values.
A WGSL-compatible vec4i string (e.g., "vec4i(1, 2, 3, 4)")
Gets the x component (equivalent to red component).
The x/red value
Sets the x component (equivalent to red component).
The value to set
Gets the y component (equivalent to green component).
The y/green value
Sets the y component (equivalent to green component).
The value to set
Gets the z component (equivalent to blue component).
The z/blue value
Sets the z component (equivalent to blue component).
The value to set
StaticcompositionGets the composition type identifier for this vector type.
The CompositionType.Vec4 identifier
Adds another vector to this vector component-wise.
The vector to add
This vector instance for method chaining
Creates a deep copy of this MutableColorRgba instance.
A new MutableColorRgba instance with the same values
Copies components from another vector to this vector.
The source vector to copy from
This vector instance for method chaining
Divides this vector by a scalar value. If the value is zero, sets 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. If any component of the divisor is zero, sets the corresponding result to Infinity.
The vector to divide by
This vector instance for method chaining
Calculates the dot product between this vector and another vector. The dot product is the sum of the products of corresponding components.
The vector to calculate dot product with
The dot product of the two vectors
Checks if this vector is approximately equal to another vector within a specified tolerance.
The vector to compare with
The tolerance value for comparison (default: Number.EPSILON)
True if the vectors are approximately equal, false otherwise
Checks if this vector is strictly equal to another vector (exact component equality).
The vector to compare with
True if all components 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 distance from this vector to another vector.
The target vector to calculate distance to
The distance between the two vectors
Multiplies this vector by a scalar value.
The scalar value to multiply by
This vector instance for method chaining
Multiplies this vector by another vector component-wise.
The vector to multiply by
This vector instance for method chaining
Normalizes the vector to unit length. Modifies this vector in place.
This vector instance for method chaining
Normalizes only the x, y, z components (treating as 3D vector). The w component is divided by the same length factor.
This vector instance for method chaining
Sets all components to one.
This vector instance for method chaining
Gets the raw typed array containing the vector components.
The underlying typed array [x, y, z, w]
Sets the value at the specified index.
The index (0-3) to set
The value to set at the index
This vector instance for method chaining
Sets all four components of the vector.
The x component value
The y component value
The z component value
The w component value
This vector instance for method chaining
Subtracts another vector from this vector component-wise.
The vector to subtract
This vector instance for method chaining
Sets all components to zero.
This vector instance for method chaining
Static_addAdds two vectors component-wise and returns a new vector.
The left operand vector
The right operand vector
The typed array constructor to use for internal storage
A new vector containing the sum (l_vec + r_vec)
Static_divideDivides a vector by a scalar value and returns a new vector. If the divisor is zero, the result components will be set to Infinity and an error will be logged.
The vector to divide
The scalar value to divide by
The typed array constructor to use for internal storage
A new vector with each component divided by the scalar
Static_divideDivides the left vector by the right vector component-wise and returns a new vector. If any component of the right vector is zero, the corresponding result component will be set to Infinity.
The left operand vector (dividend)
The right operand vector (divisor)
The typed array constructor to use for internal storage
A new vector with component-wise division result
Static_dummyCreates a dummy vector with no components (empty array). This is used as a placeholder when a vector is needed but not yet initialized.
The typed array constructor to use for internal storage
A new dummy vector with empty components
Static_fromCreates a new vector from individual component values.
The X component value
The Y component value
The Z component value
The W component value
The typed array constructor to use for internal storage
A new vector instance with the specified component values
Static_fromCreates a new vector from an array by copying the first 4 values. If the array has fewer than 4 elements, the remaining components will be undefined.
Array containing numeric values (at least 4 elements recommended)
The typed array constructor to use for internal storage
A new vector instance with the first 4 values from the array
Static_fromCreates a new vector from a 4-element array by copying the values.
Array containing exactly 4 numeric values [x, y, z, w]
The typed array constructor to use for internal storage
A new vector instance with the copied values
Static_fromCreates a new Vector4 from a Vector3, setting the W component to 1. This is commonly used for converting 3D positions to homogeneous coordinates.
The source Vector3 to copy from
The typed array constructor to use for internal storage
A new Vector4 with (vec3.x, vec3.y, vec3.z, 1.0)
Static_fromCreates a new vector by copying values from another Vector4.
The source Vector4 to copy from
The typed array constructor to use for internal storage
A new vector instance with copied values from the source vector
Static_fromCreates a new Vector4 from a Vector2, setting Z to 0 and W to 1. This is commonly used for converting 2D positions to homogeneous coordinates.
The source Vector2 to copy from
The typed array constructor to use for internal storage
A new Vector4 with (vec2.x, vec2.y, 0.0, 1.0)
Static_multiplyMultiplies a vector by a scalar value and returns a new vector. This operation scales the vector while preserving its direction.
The vector to multiply
The scalar value to multiply by
The typed array constructor to use for internal storage
A new vector with each component multiplied by the scalar
Static_multiplyMultiplies two vectors component-wise and returns a new vector. This is also known as the Hadamard product or element-wise multiplication.
The left operand vector
The right operand vector
The typed array constructor to use for internal storage
A new vector with each component being the product of corresponding components
Static_normalizeCreates a normalized version of the given vector. A normalized vector has a length of 1 while maintaining its direction.
The vector to normalize
The typed array constructor to use for internal storage
A new normalized vector
Static_oneCreates a vector with all components set to 1 (1, 1, 1, 1).
The typed array constructor to use for internal storage
A new vector with all components set to 1
Static_subtractSubtracts the right vector from the left vector component-wise and returns a new vector.
The left operand vector (minuend)
The right operand vector (subtrahend)
The typed array constructor to use for internal storage
A new vector containing the difference (l_vec - r_vec)
Static_zeroCreates a zero vector (0, 0, 0, 0).
The typed array constructor to use for internal storage
A new zero vector
StaticaddAdds two vectors component-wise.
A new MutableColorRgba containing the sum
StaticaddAdds two vectors component-wise and stores the result in the output vector. This method modifies the output vector in-place for better performance.
The left operand vector
The right operand vector
The output vector to store the result (will be modified)
The modified output vector containing the sum
StaticdivideDivides a vector by a scalar value.
The vector to divide
The scalar value to divide by
A new MutableColorRgba containing the divided result
StaticdivideDivides a vector by a scalar value and stores the result in the output vector. If the divisor is zero, the result components will be set to Infinity and an error will be logged. This method modifies the output vector in-place for better performance.
The vector to divide
The scalar value to divide by
The output vector to store the result (will be modified)
The modified output vector with each component divided by the scalar
StaticdivideDivides the left vector by the right vector component-wise.
A new MutableColorRgba containing the component-wise quotient
StaticdivideDivides the left vector by the right vector component-wise and stores the result in the output vector. If any component of the right vector is zero, the corresponding result component will be set to Infinity. This method modifies the output vector in-place for better performance.
The left operand vector (dividend)
The right operand vector (divisor)
The output vector to store the result (will be modified)
The modified output vector with component-wise division result
StaticdotStaticdummyCreates a dummy MutableColorRgba instance.
A new MutableColorRgba instance for placeholder purposes
StaticfromCreates a new MutableVector4 from individual component values.
The x component
The y component
The z component
The w component
A new MutableVector4 instance
StaticfromCreates a new MutableVector4 from an array of numbers. Takes up to 4 elements from the array.
Array of numbers to copy from
A new MutableVector4 instance
StaticfromCreates a new MutableVector4 from a 4-element array.
Array of exactly 4 numbers [x, y, z, w]
A new MutableVector4 instance
StaticlengthStaticlengthCalculates the squared length (magnitude) of a vector. This is more efficient than length() when only comparing magnitudes.
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 MutableColorRgba containing the scaled result
StaticmultiplyMultiplies a vector by a scalar value and stores the result in the output vector. This method modifies the output vector in-place for better performance.
The vector to multiply
The scalar value to multiply by
The output vector to store the result (will be modified)
The modified output vector with each component multiplied by the scalar
StaticmultiplyMultiplies two vectors component-wise.
A new MutableColorRgba containing the component-wise product
StaticmultiplyMultiplies two vectors component-wise and stores the result in the output vector. This method modifies the output vector in-place for better performance.
The left operand vector
The right operand vector
The output vector to store the result (will be modified)
The modified output vector with component-wise multiplication result
StaticnormalizeCreates a normalized version of the given vector.
The vector to normalize
A new MutableColorRgba with normalized values
StaticoneCreates a new MutableColorRgba with all components set to one.
A new MutableColorRgba instance with values [1, 1, 1, 1]
StaticsubtractSubtracts the right vector from the left vector component-wise.
A new MutableColorRgba containing the difference
StaticsubtractSubtracts the right vector from the left vector component-wise and stores the result in the output vector. This method modifies the output vector in-place for better performance.
The left operand vector (minuend)
The right operand vector (subtrahend)
The output vector to store the result (will be modified)
The modified output vector containing the difference
StaticzeroCreates a new MutableColorRgba with all components set to zero.
A new MutableColorRgba instance with values [0, 0, 0, 0]
A mutable RGBA color class that extends MutableVector4. Represents a color with red, green, blue, and alpha components. This class provides both vector-like (x, y, z, w) and color-specific (r, g, b, a) accessors.