Preparing search index...

    Four-component float vector used for XYZW coordinates and RGBA color values.

    Index

    Constructors

    • Constructs a vec4 with the given x, y, z, and w components.

      Parameters

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

      Returns vec4

    Properties

    a: number

    Alpha component of the vector, equivalent to w.

    b: number

    Blue component of the vector, equivalent to z.

    g: number

    Green component of the vector, equivalent to y.

    length: number

    Magnitude of the vector.

    lengthSquared: number

    Squared magnitude of the vector.

    r: number

    Red component of the vector, equivalent to x.

    w: number

    Fourth component of the vector.

    x: number

    First component of the vector.

    y: number

    Second component of the vector.

    z: number

    Third component of the vector.

    Methods

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

      Parameters

      Returns vec4

    • 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

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

      Parameters

      • length: number

      Returns vec4

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

      Parameters

      • length: number

      Returns void

    • Returns a new vec4 with the same component values.

      Returns vec4

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

      Parameters

      Returns void

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

      Parameters

      Returns number

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

      Parameters

      Returns number

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

      Parameters

      Returns vec4

    • 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

    • Returns true if this vector and the given vector have equal components.

      Parameters

      Returns boolean

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

      Parameters

      • scalar: number

      Returns void

    • Returns a new vec4 linearly interpolated between two vectors by the given factor.

      Parameters

      Returns vec4

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

      Parameters

      • target: vec4
      • t: number

      Returns void

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

      Parameters

      Returns vec4

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

      Parameters

      Returns vec4

    • Returns a new vec4 moved toward the target by at most the given max delta.

      Parameters

      • target: vec4
      • step: number

      Returns vec4

    • Moves this vector toward the target by at most the given max delta in place.

      Parameters

      • point: vec4
      • magnitude: number

      Returns void

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

      Parameters

      Returns vec4

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

      Parameters

      Returns void

    • Returns a new vec4 with unit length in the same direction.

      Returns vec4

    • Normalizes this vector to unit length in place.

      Returns void

    • Returns a vec4 with all components set to 1.

      Returns vec4

    • Returns a new vec4 projected onto the given vector.

      Parameters

      Returns vec4

    • Projects this vector onto the given vector in place.

      Parameters

      Returns void

    • Returns a new vec4 projected onto the plane defined by the given normal.

      Parameters

      Returns vec4

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

      Parameters

      Returns void

    • Returns a new vec4 reflected off the plane defined by the given normal.

      Parameters

      Returns vec4

    • Reflects this vector off the plane defined by the given normal in place.

      Parameters

      Returns void

    • Returns a new vec4 scaled by the given scalar.

      Parameters

      Returns vec4

    • Scales this vector by the given scalar in place.

      Parameters

      Returns void

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

      Parameters

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

      Returns void

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

      Parameters

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

      Returns void

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

      Parameters

      Returns vec4

    • Subtracts the given vector from this vector in place.

      Parameters

      Returns void

    • Returns a string representation of this vector.

      Returns string

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

      Parameters

      • scale: number

      Returns vec4

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

      Parameters

      • scale: number

      Returns void

    • Returns a vec4 with all components set to 0.

      Returns vec4