Class Vector3_<T>Internal

Generic base class for 3D vectors with floating-point components. This class provides immutable 3D vector operations and serves as the foundation for both 32-bit and 64-bit precision vector implementations.

Type Parameters

Hierarchy (view full)

Implements

Constructors

Properties

_v: TypedArray = ...

Internal typed array storage for vector components

Accessors

  • get bytesPerComponent(): number
  • Gets the number of bytes per component.

    Returns number

    The number of bytes per component (4 for Float32Array, 8 for Float64Array)

  • get glslStrAsFloat(): string
  • Gets the GLSL representation of this vector as a float vec3.

    Returns string

    A string representation suitable for GLSL shaders

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

    Returns string

    A string representation suitable for GLSL shaders with integer components

  • get w(): number
  • Gets the W component of the vector (always returns 1 for homogeneous coordinates).

    Returns number

    Always returns 1

  • get wgslStrAsFloat(): string
  • Gets the WGSL representation of this vector as a float vec3f.

    Returns string

    A string representation suitable for WGSL shaders

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

    Returns string

    A string representation suitable for WGSL shaders with integer components

  • get compositionType(): CompositionTypeClass<"VEC3">
  • Gets the composition type for this vector class.

    Returns CompositionTypeClass<"VEC3">

    The composition type (Vec3)

Methods

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

    Parameters

    • vec: IVector3

      The vector to compare with

    • delta: number = Number.EPSILON

      The tolerance for comparison (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

  • 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 angle between two vectors in radians.

    Parameters

    Returns number

    The angle between the vectors in radians

    Error if either vector has zero length

  • Calculates the dot product of two vectors (static version).

    Parameters

    Returns number

    The dot product of the two vectors

  • Calculates the distance between two vectors.

    Parameters

    Returns number

    The distance between the two vectors

  • 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: IVector3

      The vector to calculate squared length for

    Returns number

    The squared length of the vector