# Namespace: vec3
# Table of contents
# Type aliases
# Functions
- add
- angle
- bezier
- ceil
- clone
- copy
- create
- cross
- distance
- divide
- dot
- equals
- exactEquals
- floor
- forEach
- fromValues
- hermite
- inverse
- length
- lerp
- max
- min
- multiply
- negate
- normalize
- random
- rotateX
- rotateY
- rotateZ
- round
- scale
- scaleAndAdd
- set
- squaredDistance
- squaredLength
- str
- subtract
- transformMat3
- transformMat4
- transformQuat
# Type aliases
# valueType
Ƭ valueType: vec3type
# Functions
# add
▸ add(out
: vec3type, a
: vec3type, b
: vec3type): vec3type
Adds two vec3's
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
Returns: vec3type
out
# angle
▸ angle(a
: vec3type, b
: vec3type): number
Get the angle between two 3D vectors
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | The first operand |
b | vec3type | The second operand |
Returns: number
The angle in radians
# bezier
▸ bezier(out
: vec3type, a
: vec3type, b
: vec3type, c
: vec3type, d
: vec3type, t
: number): vec3type
Performs a bezier interpolation with two control points
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
c | vec3type | the third operand |
d | vec3type | the fourth operand |
t | number | interpolation amount between the two inputs |
Returns: vec3type
out
# ceil
▸ ceil(out
: vec3type, a
: vec3type): vec3type
Math.ceil the components of a vec3
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | vector to ceil |
Returns: vec3type
out
# clone
▸ clone(a
: vec3type): vec3type
Creates a new vec3 initialized with values from an existing vector
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | vector to clone |
Returns: vec3type
a new 3D vector
# copy
▸ copy(out
: vec3type, a
: vec3type): vec3type
Copy the values from one vec3 to another
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the source vector |
Returns: vec3type
out
# create
▸ create(): vec3type
Creates a new, empty vec3
Returns: vec3type
a new 3D vector
# cross
▸ cross(out
: vec3type, a
: vec3type, b
: vec3type): vec3type
Computes the cross product of two vec3's
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
Returns: vec3type
out
# distance
▸ distance(a
: vec3type, b
: vec3type): number
Calculates the euclidian distance between two vec3's
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | the first operand |
b | vec3type | the second operand |
Returns: number
distance between a and b
# divide
▸ divide(out
: vec3type, a
: vec3type, b
: vec3type): vec3type
Divides two vec3's
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
Returns: vec3type
out
# dot
▸ dot(a
: vec3type, b
: vec3type): number
Calculates the dot product of two vec3's
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | the first operand |
b | vec3type | the second operand |
Returns: number
dot product of a and b
# equals
▸ equals(a
: vec3type, b
: vec3type): boolean
Returns whether or not the vectors have approximately the same elements in the same position.
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | The first vector. |
b | vec3type | The second vector. |
Returns: boolean
True if the vectors are equal, false otherwise.
# exactEquals
▸ exactEquals(a
: vec3type, b
: vec3type): boolean
Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | The first vector. |
b | vec3type | The second vector. |
Returns: boolean
True if the vectors are equal, false otherwise.
# floor
▸ floor(out
: vec3type, a
: vec3type): vec3type
Math.floor the components of a vec3
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | vector to floor |
Returns: vec3type
out
# forEach
▸ forEach(a
: vec3type, stride
: number, offset
: number, count
: number, fn
: (out
: vec3type, vec
: vec3type, arg
: any) => void, arg?
: any): any
Perform some operation over an array of vec3s.
function
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | the array of vectors to iterate over |
stride | number | Number of elements between the start of each vec3. If 0 assumes tightly packed |
offset | number | Number of elements to skip at the beginning of the array |
count | number | Number of vec3s to iterate over. If 0 iterates over entire array |
fn | (out : vec3type, vec : vec3type, arg : any) => void | Function to call for each vector in the array |
arg? | any | - |
Returns: any
a
# fromValues
▸ fromValues(x
: number, y
: number, z
: number): vec3type
Creates a new vec3 initialized with the given values
# Parameters
Name | Type | Description |
---|---|---|
x | number | X component |
y | number | Y component |
z | number | Z component |
Returns: vec3type
a new 3D vector
# hermite
▸ hermite(out
: vec3type, a
: vec3type, b
: vec3type, c
: vec3type, d
: vec3type, t
: number): vec3type
Performs a hermite interpolation with two control points
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
c | vec3type | the third operand |
d | vec3type | the fourth operand |
t | number | interpolation amount between the two inputs |
Returns: vec3type
out
# inverse
▸ inverse(out
: vec3type, a
: vec3type): vec3type
Returns the inverse of the components of a vec3
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | vector to invert |
Returns: vec3type
out
# length
▸ length(a
: vec3type): number
Calculates the length of a vec3
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | vector to calculate length of |
Returns: number
length of a
# lerp
▸ lerp(out
: vec3type, a
: vec3type, b
: vec3type, t
: number): vec3type
Performs a linear interpolation between two vec3's
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
t | number | interpolation amount between the two inputs |
Returns: vec3type
out
# max
▸ max(out
: vec3type, a
: vec3type, b
: vec3type): vec3type
Returns the maximum of two vec3's
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
Returns: vec3type
out
# min
▸ min(out
: vec3type, a
: vec3type, b
: vec3type): vec3type
Returns the minimum of two vec3's
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
Returns: vec3type
out
# multiply
▸ multiply(out
: vec3type, a
: vec3type, b
: vec3type): vec3type
Multiplies two vec3's
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
Returns: vec3type
out
# negate
▸ negate(out
: vec3type, a
: vec3type): vec3type
Negates the components of a vec3
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | vector to negate |
Returns: vec3type
out
# normalize
▸ normalize(out
: vec3type, a
: vec3type): vec3type
Normalize a vec3
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | vector to normalize |
Returns: vec3type
out
# random
▸ random(out
: vec3type, s?
: number): vec3type
Generates a random vector with the given scale
# Parameters
Name | Type | Default value | Description |
---|---|---|---|
out | vec3type | - | the receiving vector |
s | number | 1.0 | - |
Returns: vec3type
out
# rotateX
▸ rotateX(out
: vec3type, a
: vec3type, b
: vec3type, c
: number): vec3type
Rotate a 3D vector around the x-axis
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | The receiving vec3 |
a | vec3type | The vec3 point to rotate |
b | vec3type | The origin of the rotation |
c | number | The angle of rotation |
Returns: vec3type
out
# rotateY
▸ rotateY(out
: vec3type, a
: vec3type, b
: vec3type, c
: number): vec3type
Rotate a 3D vector around the y-axis
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | The receiving vec3 |
a | vec3type | The vec3 point to rotate |
b | vec3type | The origin of the rotation |
c | number | The angle of rotation |
Returns: vec3type
out
# rotateZ
▸ rotateZ(out
: vec3type, a
: vec3type, b
: vec3type, c
: number): vec3type
Rotate a 3D vector around the z-axis
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | The receiving vec3 |
a | vec3type | The vec3 point to rotate |
b | vec3type | The origin of the rotation |
c | number | The angle of rotation |
Returns: vec3type
out
# round
▸ round(out
: vec3type, a
: vec3type): vec3type
Math.round the components of a vec3
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | vector to round |
Returns: vec3type
out
# scale
▸ scale(out
: vec3type, a
: vec3type, b
: number): vec3type
Scales a vec3 by a scalar number
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the vector to scale |
b | number | amount to scale the vector by |
Returns: vec3type
out
# scaleAndAdd
▸ scaleAndAdd(out
: vec3type, a
: vec3type, b
: vec3type, s
: number): vec3type
Adds two vec3's after scaling the second operand by a scalar value
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
s | number | the amount to scale b by before adding |
Returns: vec3type
out
# set
▸ set(out
: vec3type, x
: number, y
: number, z
: number): vec3type
Set the components of a vec3 to the given values
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
x | number | X component |
y | number | Y component |
z | number | Z component |
Returns: vec3type
out
# squaredDistance
▸ squaredDistance(a
: vec3type, b
: vec3type): number
Calculates the squared euclidian distance between two vec3's
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | the first operand |
b | vec3type | the second operand |
Returns: number
squared distance between a and b
# squaredLength
▸ squaredLength(a
: vec3type): number
Calculates the squared length of a vec3
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | vector to calculate squared length of |
Returns: number
squared length of a
# str
▸ str(a
: vec3type): string
Returns a string representation of a vector
# Parameters
Name | Type | Description |
---|---|---|
a | vec3type | vector to represent as a string |
Returns: string
string representation of the vector
# subtract
▸ subtract(out
: vec3type, a
: vec3type, b
: vec3type): vec3type
Subtracts vector b from vector a
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the first operand |
b | vec3type | the second operand |
Returns: vec3type
out
# transformMat3
▸ transformMat3(out
: vec3type, a
: vec3type, m
: mat4type): vec3type
Transforms the vec3 with a mat3.
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the vector to transform |
m | mat4type | the 3x3 matrix to transform with |
Returns: vec3type
out
# transformMat4
▸ transformMat4(out
: vec3type, a
: vec3type, m
: mat4type): vec3type
Transforms the vec3 with a mat4. 4th vector component is implicitly '1'
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the vector to transform |
m | mat4type | matrix to transform with |
Returns: vec3type
out
# transformQuat
▸ transformQuat(out
: vec3type, a
: vec3type, q
: quattype): vec3type
Transforms the vec3 with a quat
# Parameters
Name | Type | Description |
---|---|---|
out | vec3type | the receiving vector |
a | vec3type | the vector to transform |
q | quattype | quaternion to transform with |
Returns: vec3type
out