Preparing search index...

    3-component floating-point vector used for 3D positions, directions, and RGB color values.

    Index

    Constructors

    • Constructs a vec3 with the given x, y, z components.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns vec3

    Properties

    b: number

    Blue channel component, equivalent to z.

    g: number

    Green channel component, equivalent to y.

    length: number

    The Euclidean length of this vector.

    lengthSquared: number

    The squared Euclidean length of this vector.

    r: number

    Red channel component, equivalent to x.

    x: number

    X component of this vector.

    y: number

    Y component of this vector.

    z: number

    Z component of this vector.

    Methods

    • Returns a new vec3 that is the sum of this vector and the given vector.

      Parameters

      Returns vec3

    • Adds the given vector to this vector in place.

      Parameters

      Returns void

    • Returns the angle in radians between this vector and the given vector.

      Parameters

      Returns number

    • Static vec3 pointing in the negative Z direction (0, 0, -1).

      Returns vec3

    • Returns a new vec3 with its length clamped to the given maximum length.

      Parameters

      • length: number

      Returns vec3

    • Clamps the length of this vector to the given maximum length in place.

      Parameters

      • length: number

      Returns void

    • Returns a new vec3 with the same component values as this vector.

      Returns vec3

    • Copies the component values from the given vector into this vector.

      Parameters

      Returns void

    • Returns the cross product of this vector and the given vector.

      Parameters

      Returns vec3

    • Computes the cross product of this vector and the given vector, storing the result in this vector.

      Parameters

      Returns void

    • Returns the Euclidean distance between this vector and the given vector.

      Parameters

      Returns number

    • Returns the squared Euclidean distance between this vector and the given vector.

      Parameters

      Returns number

    • Returns a new vec3 that is this vector divided component-wise by the given vector.

      Parameters

      Returns vec3

    • Divides this vector component-wise by the given vector in place.

      Parameters

      Returns void

    • Returns the dot product of this vector and the given vector.

      Parameters

      Returns number

    • Static vec3 pointing in the negative Y direction (0, -1, 0).

      Returns vec3

    • Returns true if this vector's components are equal to the given vector's components.

      Parameters

      Returns boolean

    • Sets all components of this vector to the given value.

      Parameters

      • scalar: number

      Returns void

    • Static vec3 pointing in the positive Z direction (0, 0, 1).

      Returns vec3

    • Static vec3 pointing in the negative X direction (-1, 0, 0).

      Returns vec3

    • Returns a new vec3 linearly interpolated between two vectors by factor t.

      Parameters

      Returns vec3

    • Linearly interpolates this vector toward the given target vector by factor t, in place.

      Parameters

      • target: vec3
      • t: number

      Returns void

    • Returns a new vec3 with the component-wise maximum of two vectors.

      Parameters

      Returns vec3

    • Returns a new vec3 with the component-wise minimum of two vectors.

      Parameters

      Returns vec3

    • Returns a new vec3 moved from this vector toward the target by at most maxDelta distance.

      Parameters

      • target: vec3
      • step: number

      Returns vec3

    • Moves this vector toward the target by at most maxDelta distance, in place.

      Parameters

      • point: vec3
      • magnitude: number

      Returns void

    • Returns a new vec3 that is this vector multiplied component-wise by the given vector.

      Parameters

      Returns vec3

    • Multiplies this vector component-wise by the given vector in place.

      Parameters

      Returns void

    • Returns a new vec3 with the same direction as this vector but with length 1.

      Returns vec3

    • Normalizes this vector to unit length in place.

      Returns void

    • Static vec3 with all components set to 1.

      Returns vec3

    • Returns an orthonormalized version of the given vector relative to a reference vector.

      Parameters

      Returns void

    • Returns the projection of this vector onto the given vector.

      Parameters

      Returns vec3

    • Projects this vector onto the given vector in place.

      Parameters

      Returns void

    • Returns the projection of this vector onto the plane defined by the given normal.

      Parameters

      Returns vec3

    • Projects this vector onto the plane defined by the given normal, in place.

      Parameters

      Returns void

    • Returns a new vec3 with a random unit direction.

      Returns vec3

    • Returns the reflection of this vector off a surface with the given normal.

      Parameters

      Returns vec3

    • Reflects this vector off a surface with the given normal, in place.

      Parameters

      Returns void

    • Static vec3 pointing in the positive X direction (1, 0, 0).

      Returns vec3

    • Returns a new vec3 rotated from this vector toward the target, by at most maxAngle radians.

      Parameters

      • target: vec3
      • step: number

      Returns vec3

    • Rotates this vector toward the target by at most maxAngle radians, in place.

      Parameters

      • target: vec3
      • step: number

      Returns void

    • Returns a new vec3 that is this vector multiplied by the given scalar.

      Parameters

      Returns vec3

    • Multiplies this vector by the given scalar in place.

      Parameters

      Returns void

    • Sets this vector to a random unit vector in place.

      Returns void

    • Sets the r, g, b components of this vector.

      Parameters

      • Optionalr: number
      • Optionalg: number
      • Optionalb: number

      Returns void

    • Sets the x, y, z components of this vector.

      Parameters

      • Optionalx: number
      • Optionaly: number
      • Optionalz: number

      Returns void

    • Returns a new vec3 spherically interpolated between two vectors by factor t.

      Parameters

      Returns vec3

    • Spherically interpolates this vector toward the given target vector by factor t, in place.

      Parameters

      • target: vec3
      • t: number

      Returns void

    • Returns a new vec3 that is this vector minus the given vector.

      Parameters

      Returns vec3

    • Subtracts the given vector from this vector in place.

      Parameters

      Returns void

    • Returns a string representation of this vector's components.

      Returns string

    • Returns a new vec3 with all components multiplied by the given scalar.

      Parameters

      • scale: number

      Returns vec3

    • Multiplies all components of this vector by the given scalar in place.

      Parameters

      • scale: number

      Returns void

    • Static vec3 pointing in the positive Y direction (0, 1, 0).

      Returns vec3

    • Static vec3 with all components set to 0.

      Returns vec3