Interface IVector

Base interface for immutable vector types. Provides common read-only operations for vector mathematics.

interface IVector {
    _v: TypedArray;
    bytesPerComponent: number;
    className: string;
    glslStrAsFloat: string;
    glslStrAsInt: string;
    wgslStrAsFloat: string;
    wgslStrAsInt: string;
    x: number;
    at(i: number): number;
    dot(vec: IVector): number;
    flattenAsArray(): number[];
    isDummy(): boolean;
    isEqual(vec: IVector, delta?: number): boolean;
    isStrictEqual(vec: IVector): boolean;
    isTheSourceSame(arrayBuffer: ArrayBuffer): boolean;
    length(): number;
    lengthSquared(): number;
    lengthTo(vec: IVector): number;
    toString(): string;
    toStringApproximately(): string;
    v(i: number): number;
}

Hierarchy (view full)

Implemented by

Properties

The underlying typed array containing vector components

bytesPerComponent: number

Number of bytes per component in the underlying array

className: string

The class name identifier

glslStrAsFloat: string

GLSL string representation for float type

glslStrAsInt: string

GLSL string representation for integer type

wgslStrAsFloat: string

WGSL string representation for float type

wgslStrAsInt: string

WGSL string representation for integer type

x: number

The x component of the vector

Methods

  • Gets the component value at the specified index.

    Parameters

    • i: number

      The component index

    Returns number

    The component value

  • Converts the vector to a flat array of numbers.

    Returns number[]

    Array containing all vector components

  • Checks if this is a dummy/placeholder vector.

    Returns boolean

    True if this is a dummy vector

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

    Parameters

    • vec: IVector

      The vector to compare with

    • Optionaldelta: number

      Optional tolerance value (default: small epsilon)

    Returns boolean

    True if vectors are approximately equal

  • Checks if this vector is strictly equal to another vector.

    Parameters

    • vec: IVector

      The vector to compare with

    Returns boolean

    True if vectors are exactly equal

  • Checks if this vector shares the same source array buffer.

    Parameters

    • arrayBuffer: ArrayBuffer

      The array buffer to check

    Returns boolean

    True if using the same source buffer

  • Calculates the squared length of the vector (faster than length).

    Returns number

    The squared vector length

  • Calculates the distance to another vector.

    Parameters

    Returns number

    The distance between vectors

  • Returns a string representation of the vector.

    Returns string

    String representation of the vector

  • Returns an approximate string representation of the vector with rounded values.

    Returns string

    Approximate string representation

  • Gets the component value at the specified index (alias for at).

    Parameters

    • i: number

      The component index

    Returns number

    The component value