# Namespace: vec4

# Table of contents

# Type aliases

# Functions

# Type aliases

# valueType

Ƭ valueType: vec4type

# Functions

# add

add(out: vec4type, a: vec4type, b: vec4type): vec4type

Adds two vec4's

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the first operand
b vec4type the second operand

Returns: vec4type

out


# ceil

ceil(out: vec4type, a: vec4type): vec4type

Math.ceil the components of a vec4

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type vector to ceil

Returns: vec4type

out


# clone

clone(a: vec4type): vec4type

Creates a new vec4 initialized with values from an existing vector

# Parameters
Name Type Description
a vec4type vector to clone

Returns: vec4type

a new 4D vector


# copy

copy(out: vec4type, a: vec4type): vec4type

Copy the values from one vec4 to another

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the source vector

Returns: vec4type

out


# create

create(): vec4type

Creates a new, empty vec4

Returns: vec4type

a new 4D vector


# distance

distance(a: vec4type, b: vec4type): number

Calculates the euclidian distance between two vec4's

# Parameters
Name Type Description
a vec4type the first operand
b vec4type the second operand

Returns: number

distance between a and b


# divide

divide(out: vec4type, a: vec4type, b: vec4type): vec4type

Divides two vec4's

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the first operand
b vec4type the second operand

Returns: vec4type

out


# dot

dot(a: vec4type, b: vec4type): number

Calculates the dot product of two vec4's

# Parameters
Name Type Description
a vec4type the first operand
b vec4type the second operand

Returns: number

dot product of a and b


# equals

equals(a: vec4type, b: vec4type): boolean

Returns whether or not the vectors have approximately the same elements in the same position.

# Parameters
Name Type Description
a vec4type The first vector.
b vec4type The second vector.

Returns: boolean

True if the vectors are equal, false otherwise.


# exactEquals

exactEquals(a: vec4type, b: vec4type): boolean

Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)

# Parameters
Name Type Description
a vec4type The first vector.
b vec4type The second vector.

Returns: boolean

True if the vectors are equal, false otherwise.


# floor

floor(out: vec4type, a: vec4type): vec4type

Math.floor the components of a vec4

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type vector to floor

Returns: vec4type

out


# forEach

forEach(a: vec4type, stride: number, offset: number, count: number, fn: (out: vec4type, vec: vec4type, arg: any) => void, arg?: any): any

Perform some operation over an array of vec4s.

function

# Parameters
Name Type Description
a vec4type the array of vectors to iterate over
stride number Number of elements between the start of each vec4. If 0 assumes tightly packed
offset number Number of elements to skip at the beginning of the array
count number Number of vec4s to iterate over. If 0 iterates over entire array
fn (out: vec4type, vec: vec4type, 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, w: number): vec4type

Creates a new vec4 initialized with the given values

# Parameters
Name Type Description
x number X component
y number Y component
z number Z component
w number W component

Returns: vec4type

a new 4D vector


# inverse

inverse(out: vec4type, a: vec4type): vec4type

Returns the inverse of the components of a vec4

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type vector to invert

Returns: vec4type

out


# length

length(a: vec4type): number

Calculates the length of a vec4

# Parameters
Name Type Description
a vec4type vector to calculate length of

Returns: number

length of a


# lerp

lerp(out: vec4type, a: vec4type, b: vec4type, t: number): vec4type

Performs a linear interpolation between two vec4's

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the first operand
b vec4type the second operand
t number interpolation amount between the two inputs

Returns: vec4type

out


# max

max(out: vec4type, a: vec4type, b: vec4type): vec4type

Returns the maximum of two vec4's

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the first operand
b vec4type the second operand

Returns: vec4type

out


# min

min(out: vec4type, a: vec4type, b: vec4type): vec4type

Returns the minimum of two vec4's

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the first operand
b vec4type the second operand

Returns: vec4type

out


# multiply

multiply(out: vec4type, a: vec4type, b: vec4type): vec4type

Multiplies two vec4's

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the first operand
b vec4type the second operand

Returns: vec4type

out


# negate

negate(out: vec4type, a: vec4type): vec4type

Negates the components of a vec4

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type vector to negate

Returns: vec4type

out


# normalize

normalize(out: vec4type, a: vec4type): vec4type

Normalize a vec4

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type vector to normalize

Returns: vec4type

out


# random

random(out: vec4type, s?: number): vec4type

Generates a random vector with the given scale

# Parameters
Name Type Default value Description
out vec4type - the receiving vector
s number 1.0 -

Returns: vec4type

out


# round

round(out: vec4type, a: vec4type): vec4type

Math.round the components of a vec4

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type vector to round

Returns: vec4type

out


# scale

scale(out: vec4type, a: vec4type, b: number): vec4type

Scales a vec4 by a scalar number

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the vector to scale
b number amount to scale the vector by

Returns: vec4type

out


# scaleAndAdd

scaleAndAdd(out: vec4type, a: vec4type, b: vec4type, s: number): vec4type

Adds two vec4's after scaling the second operand by a scalar value

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the first operand
b vec4type the second operand
s number the amount to scale b by before adding

Returns: vec4type

out


# set

set(out: vec4type, x: number, y: number, z: number, w: number): vec4type

Set the components of a vec4 to the given values

# Parameters
Name Type Description
out vec4type the receiving vector
x number X component
y number Y component
z number Z component
w number W component

Returns: vec4type

out


# squaredDistance

squaredDistance(a: vec4type, b: vec4type): number

Calculates the squared euclidian distance between two vec4's

# Parameters
Name Type Description
a vec4type the first operand
b vec4type the second operand

Returns: number

squared distance between a and b


# squaredLength

squaredLength(a: vec4type): number

Calculates the squared length of a vec4

# Parameters
Name Type Description
a vec4type vector to calculate squared length of

Returns: number

squared length of a


# str

str(a: vec4type): string

Returns a string representation of a vector

# Parameters
Name Type Description
a vec4type vector to represent as a string

Returns: string

string representation of the vector


# subtract

subtract(out: vec4type, a: vec4type, b: vec4type): vec4type

Subtracts vector b from vector a

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the first operand
b vec4type the second operand

Returns: vec4type

out


# transformMat4

transformMat4(out: vec4type, a: vec4type, m: mat4type): vec4type

Transforms the vec4 with a mat4.

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the vector to transform
m mat4type matrix to transform with

Returns: vec4type

out


# transformQuat

transformQuat(out: vec4type, a: vec4type, q: quattype): vec4type

Transforms the vec4 with a quat

# Parameters
Name Type Description
out vec4type the receiving vector
a vec4type the vector to transform
q quattype quaternion to transform with

Returns: vec4type

out