rhodonite
    Preparing search index...

    Class MutableVector2_<T>Internal

    Base class for mutable 2D vectors with generic typed array support. Provides mutable operations for vector manipulation that modify the vector in place.

    Type Parameters

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    _v: TypedArray = ...

    Internal typed array storage for vector components

    Accessors

    • get bytesPerComponent(): number

      Gets the number of bytes per component in the underlying typed array.

      Returns number

      The number of bytes per element

    • get className(): string

      Gets the class name of this vector instance.

      Returns string

      The constructor name of the class

    • get glslStrAsFloat(): string

      Converts the vector to a GLSL vec2 string representation with float precision.

      Returns string

      GLSL-compatible vec2 string

    • 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 wgslStrAsFloat(): string

      Converts the vector to a WGSL vec2f string representation with float precision.

      Returns string

      WGSL-compatible vec2f string

    • 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 compositionType(): CompositionTypeClass<"VEC2">

      Gets the composition type of this vector.

      Returns CompositionTypeClass<"VEC2">

      The composition type (Vec2)

    Methods

    • Gets the component at the specified index.

      Parameters

      • i: number

        The index (0 for x, 1 for y)

      Returns number

      The component value at the specified index

    • Divides this vector by a scalar value (modifies this vector in place). If the divisor is zero, sets components to Infinity and logs an error.

      Parameters

      • value: number

        The scalar value to divide by

      Returns MutableVector2_<T>

      This vector instance for method chaining

    • Checks if this vector is approximately equal to another vector within a tolerance.

      Parameters

      • vec: IVector2

        The vector to compare with

      • delta: number = Number.EPSILON

        The tolerance value (default: Number.EPSILON)

      Returns boolean

      True if vectors are approximately equal, false otherwise

    • Checks if the internal storage shares the same ArrayBuffer as the provided one. Useful for determining if vectors share underlying memory.

      Parameters

      • arrayBuffer: ArrayBuffer

        The ArrayBuffer to compare against

      Returns boolean

      True if the same ArrayBuffer is used, false otherwise

    • Calculates the squared length of the vector. This is more efficient than calculating the actual length when only comparison is needed.

      Returns number

      The squared length of the vector

    • Gets the component value at the specified index. Alias for the at() method for convenience.

      Parameters

      • i: number

        The index of the component to retrieve

      Returns number

      The component value at the given index

    • 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