Class AbstractVectorAbstract

Abstract base class for vector implementations. Provides common functionality and defines the interface that all vector classes must implement. This class handles basic vector operations and serves as a foundation for specific vector types.

Hierarchy (view full)

Implements

Constructors

Properties

_v: TypedArray = ...

Internal typed array storage for vector components

Accessors

  • get glslStrAsInt(): string
  • Gets the GLSL string representation of the vector as integer values.

    Returns string

    GLSL-formatted string for integer values

    Error - Must be implemented by subclasses

  • get wgslStrAsInt(): string
  • Gets the WGSL string representation of the vector as integer values.

    Returns string

    WGSL-formatted string for integer values

    Error - Must be implemented by subclasses

Methods

  • Gets the component value at the specified index.

    Parameters

    • i: number

      The index of the component to retrieve

    Returns number

    The component value at the given index

  • Calculates the dot product between this vector and another vector.

    Parameters

    • vec: IVector

      The vector to calculate dot product with

    Returns number

    The dot product result

    Error - Must be implemented by subclasses

  • Checks if this vector is a dummy (empty) vector. A dummy vector has no components and is typically used as a placeholder.

    Returns boolean

    True if the vector is dummy, false otherwise

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

    Parameters

    • vec: IVector

      The vector to compare against

    • Optionaldelta: number

      Optional tolerance value for comparison

    Returns boolean

    True if vectors are approximately equal, false otherwise

    Error - Must be implemented by subclasses

  • Checks if this vector is strictly equal to another vector (exact equality).

    Parameters

    • vec: IVector

      The vector to compare against

    Returns boolean

    True if vectors are exactly equal, false otherwise

    Error - Must be implemented by subclasses

  • 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 length() when only relative comparisons are needed.

    Returns number

    The squared length of the vector

    Error - Must be implemented by subclasses

  • Calculates the distance from this vector to another vector.

    Parameters

    Returns number

    The distance between the vectors

    Error - Must be implemented by subclasses

  • Converts the vector to an approximate string representation. Useful for debugging when exact precision is not required.

    Returns string

    Approximate string representation of the vector

    Error - Must be implemented by subclasses

  • 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