Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace vec3

Index

Functions

add

  • add(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3): vec3
  • Adds two vec3's

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns vec3

    out

angle

  • angle(a: ReadonlyVec3, b: ReadonlyVec3): number
  • Get the angle between two 3D vectors

    Parameters

    • a: ReadonlyVec3

      The first operand

    • b: ReadonlyVec3

      The second operand

    Returns number

    The angle in radians

bezier

  • bezier(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3, c: ReadonlyVec3, d: ReadonlyVec3, t: number): vec3
  • Performs a bezier interpolation with two control points

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    • c: ReadonlyVec3

      the third operand

    • d: ReadonlyVec3

      the fourth operand

    • t: number

      interpolation amount, in the range [0-1], between the two inputs

    Returns vec3

    out

ceil

  • ceil(out: vec3, a: ReadonlyVec3): vec3
  • Math.ceil the components of a vec3

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      vector to ceil

    Returns vec3

    out

clone

  • clone(a: ReadonlyVec3): vec3
  • Creates a new vec3 initialized with values from an existing vector

    Parameters

    • a: ReadonlyVec3

      vector to clone

    Returns vec3

    a new 3D vector

copy

  • copy(out: vec3, a: ReadonlyVec3): vec3
  • Copy the values from one vec3 to another

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the source vector

    Returns vec3

    out

create

  • Creates a new, empty vec3

    Returns vec3

    a new 3D vector

cross

  • cross(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3): vec3
  • Computes the cross product of two vec3's

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns vec3

    out

dist

  • dist(a: ReadonlyVec3, b: ReadonlyVec3): number
  • Calculates the euclidian distance between two vec3's

    Parameters

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns number

    distance between a and b

distance

  • distance(a: ReadonlyVec3, b: ReadonlyVec3): number
  • Calculates the euclidian distance between two vec3's

    Parameters

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns number

    distance between a and b

div

  • div(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3): vec3
  • Divides two vec3's

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns vec3

    out

divide

  • divide(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3): vec3
  • Divides two vec3's

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns vec3

    out

dot

  • dot(a: ReadonlyVec3, b: ReadonlyVec3): number
  • Calculates the dot product of two vec3's

    Parameters

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns number

    dot product of a and b

equals

  • equals(a: ReadonlyVec3, b: ReadonlyVec3): boolean
  • Returns whether or not the vectors have approximately the same elements in the same position.

    Parameters

    • a: ReadonlyVec3

      The first vector.

    • b: ReadonlyVec3

      The second vector.

    Returns boolean

    True if the vectors are equal, false otherwise.

exactEquals

  • exactEquals(a: ReadonlyVec3, b: ReadonlyVec3): boolean
  • Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)

    Parameters

    • a: ReadonlyVec3

      The first vector.

    • b: ReadonlyVec3

      The second vector.

    Returns boolean

    True if the vectors are equal, false otherwise.

floor

  • floor(out: vec3, a: ReadonlyVec3): vec3
  • Math.floor the components of a vec3

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      vector to floor

    Returns vec3

    out

forEach

  • forEach(a: any, stride: any, offset: any, count: any, fn: any, arg: any): any
  • Parameters

    • a: any
    • stride: any
    • offset: any
    • count: any
    • fn: any
    • arg: any

    Returns any

fromValues

  • fromValues(x: number, y: number, z: number): vec3
  • Creates a new vec3 initialized with the given values

    Parameters

    • x: number

      X component

    • y: number

      Y component

    • z: number

      Z component

    Returns vec3

    a new 3D vector

hermite

  • hermite(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3, c: ReadonlyVec3, d: ReadonlyVec3, t: number): vec3
  • Performs a hermite interpolation with two control points

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    • c: ReadonlyVec3

      the third operand

    • d: ReadonlyVec3

      the fourth operand

    • t: number

      interpolation amount, in the range [0-1], between the two inputs

    Returns vec3

    out

inverse

  • inverse(out: vec3, a: ReadonlyVec3): vec3
  • Returns the inverse of the components of a vec3

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      vector to invert

    Returns vec3

    out

len

  • len(a: ReadonlyVec3): number
  • Calculates the length of a vec3

    Parameters

    • a: ReadonlyVec3

      vector to calculate length of

    Returns number

    length of a

length

  • length(a: ReadonlyVec3): number
  • Calculates the length of a vec3

    Parameters

    • a: ReadonlyVec3

      vector to calculate length of

    Returns number

    length of a

lerp

  • lerp(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3, t: number): vec3
  • Performs a linear interpolation between two vec3's

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    • t: number

      interpolation amount, in the range [0-1], between the two inputs

    Returns vec3

    out

max

  • max(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3): vec3
  • Returns the maximum of two vec3's

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns vec3

    out

min

  • min(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3): vec3
  • Returns the minimum of two vec3's

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns vec3

    out

mul

  • mul(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3): vec3
  • Multiplies two vec3's

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns vec3

    out

multiply

  • multiply(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3): vec3
  • Multiplies two vec3's

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns vec3

    out

negate

  • negate(out: vec3, a: ReadonlyVec3): vec3
  • Negates the components of a vec3

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      vector to negate

    Returns vec3

    out

normalize

  • normalize(out: vec3, a: ReadonlyVec3): vec3
  • Normalize a vec3

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      vector to normalize

    Returns vec3

    out

random

  • random(out: vec3, scale?: number): vec3
  • Generates a random vector with the given scale

    Parameters

    • out: vec3

      the receiving vector

    • Optional scale: number

    Returns vec3

    out

rotateX

  • rotateX(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3, rad: number): vec3
  • Rotate a 3D vector around the x-axis

    Parameters

    • out: vec3

      The receiving vec3

    • a: ReadonlyVec3

      The vec3 point to rotate

    • b: ReadonlyVec3

      The origin of the rotation

    • rad: number

      The angle of rotation in radians

    Returns vec3

    out

rotateY

  • rotateY(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3, rad: number): vec3
  • Rotate a 3D vector around the y-axis

    Parameters

    • out: vec3

      The receiving vec3

    • a: ReadonlyVec3

      The vec3 point to rotate

    • b: ReadonlyVec3

      The origin of the rotation

    • rad: number

      The angle of rotation in radians

    Returns vec3

    out

rotateZ

  • rotateZ(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3, rad: number): vec3
  • Rotate a 3D vector around the z-axis

    Parameters

    • out: vec3

      The receiving vec3

    • a: ReadonlyVec3

      The vec3 point to rotate

    • b: ReadonlyVec3

      The origin of the rotation

    • rad: number

      The angle of rotation in radians

    Returns vec3

    out

round

  • round(out: vec3, a: ReadonlyVec3): vec3
  • Math.round the components of a vec3

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      vector to round

    Returns vec3

    out

scale

  • scale(out: vec3, a: ReadonlyVec3, b: number): vec3
  • Scales a vec3 by a scalar number

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the vector to scale

    • b: number

      amount to scale the vector by

    Returns vec3

    out

scaleAndAdd

  • scaleAndAdd(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3, scale: number): vec3
  • Adds two vec3's after scaling the second operand by a scalar value

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    • scale: number

      the amount to scale b by before adding

    Returns vec3

    out

set

  • set(out: vec3, x: number, y: number, z: number): vec3
  • Set the components of a vec3 to the given values

    Parameters

    • out: vec3

      the receiving vector

    • x: number

      X component

    • y: number

      Y component

    • z: number

      Z component

    Returns vec3

    out

sqrDist

  • sqrDist(a: ReadonlyVec3, b: ReadonlyVec3): number
  • Calculates the squared euclidian distance between two vec3's

    Parameters

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns number

    squared distance between a and b

sqrLen

  • sqrLen(a: ReadonlyVec3): number
  • Calculates the squared length of a vec3

    Parameters

    • a: ReadonlyVec3

      vector to calculate squared length of

    Returns number

    squared length of a

squaredDistance

  • squaredDistance(a: ReadonlyVec3, b: ReadonlyVec3): number
  • Calculates the squared euclidian distance between two vec3's

    Parameters

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns number

    squared distance between a and b

squaredLength

  • squaredLength(a: ReadonlyVec3): number
  • Calculates the squared length of a vec3

    Parameters

    • a: ReadonlyVec3

      vector to calculate squared length of

    Returns number

    squared length of a

str

  • str(a: ReadonlyVec3): string
  • Returns a string representation of a vector

    Parameters

    • a: ReadonlyVec3

      vector to represent as a string

    Returns string

    string representation of the vector

sub

  • sub(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3): vec3
  • Subtracts vector b from vector a

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns vec3

    out

subtract

  • subtract(out: vec3, a: ReadonlyVec3, b: ReadonlyVec3): vec3
  • Subtracts vector b from vector a

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the first operand

    • b: ReadonlyVec3

      the second operand

    Returns vec3

    out

transformMat3

  • transformMat3(out: vec3, a: ReadonlyVec3, m: ReadonlyMat3): vec3
  • Transforms the vec3 with a mat3.

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the vector to transform

    • m: ReadonlyMat3

      the 3x3 matrix to transform with

    Returns vec3

    out

transformMat4

  • transformMat4(out: vec3, a: ReadonlyVec3, m: ReadonlyMat4): vec3
  • Transforms the vec3 with a mat4. 4th vector component is implicitly '1'

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the vector to transform

    • m: ReadonlyMat4

      matrix to transform with

    Returns vec3

    out

transformQuat

  • transformQuat(out: vec3, a: ReadonlyVec3, q: ReadonlyQuat): vec3
  • Transforms the vec3 with a quat Can also be used for dual quaternions. (Multiply it with the real part)

    Parameters

    • out: vec3

      the receiving vector

    • a: ReadonlyVec3

      the vector to transform

    • q: ReadonlyQuat

      quaternion to transform with

    Returns vec3

    out

zero

  • Set the components of a vec3 to zero

    Parameters

    • out: vec3

      the receiving vector

    Returns vec3

    out