rhodonite
    Preparing search index...

    Class MutableVector2

    Mutable 2D vector class with 32-bit float components. Provides efficient vector operations that modify the vector in place, implementing both IMutableVector and IMutableVector2 interfaces.

    const vec = MutableVector2.zero();
    vec.setComponents(3, 4);
    vec.normalize(); // vec is now (0.6, 0.8)

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    _v: TypedArray = ...

    Internal typed array storage for vector components

    Accessors

    • get glslStrAsInt(): string

      Converts the vector to a GLSL ivec2 string representation with integer precision.

      Returns string

      GLSL-compatible ivec2 string

    • get glslStrAsUint(): string

      Gets the GLSL string representation of the vector as unsigned integer values.

      Returns string

      GLSL-formatted string for unsigned integer values with 'u' suffix

      Error - Must be implemented by subclasses

    • get w(): number

      Gets the w component of the vector (always 1 for homogeneous coordinates).

      Returns number

      Always returns 1

    • get wgslStrAsInt(): string

      Converts the vector to a WGSL vec2i string representation with integer precision.

      Returns string

      WGSL-compatible vec2i string

    • get wgslStrAsUint(): string

      Gets the WGSL string representation of the vector as unsigned integer values.

      Returns string

      WGSL-formatted string for unsigned integer values with 'u' suffix

      Error - Must be implemented by subclasses

    • get z(): number

      Gets the z component of the vector (always 0 for 2D vectors).

      Returns number

      Always returns 0

    • get compositionType(): CompositionTypeClass<"VEC2">

      Gets the composition type of this vector.

      Returns CompositionTypeClass<"VEC2">

      The composition type (Vec2)

    Methods

    • Calculates the squared length of a vector (static version). This is more efficient than calculating the actual length when only comparison is needed.

      Parameters

      • vec: IVector2

        The vector to calculate squared length for

      Returns number

      The squared length of the vector