Skip to content
On this page

Class: Vector4

WebSG.Vector4

A 4-dimensional vector.

Indexable

▪ [index: number]: number

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new Vector4()

Constructs a new vector.

Defined in

websg.d.ts:2095

new Vector4(x, y, z, w)

Constructs a new vector with the given components.

Parameters

NameTypeDescription
xnumberThe x component of the vector.
ynumberThe y component of the vector.
znumberThe z component of the vector.
wnumberThe w component of the vector.

Defined in

websg.d.ts:2103

new Vector4(array)

Constructs and sets the initial components of the vector from a numeric array-like object.

Parameters

NameType
arrayArrayLike<number>

Defined in

websg.d.ts:2107

Properties

bottom

bottom: number

Alias for z

Defined in

websg.d.ts:2087


left

left: number

Alias for w

Defined in

websg.d.ts:2091


length

Readonly length: number

Returns the number of components in this vector.

Defined in

websg.d.ts:2187


right: number

Alias for y

Defined in

websg.d.ts:2083


top

top: number

Alias for x

Defined in

websg.d.ts:2079


w

w: number

The w component of the vector.

Defined in

websg.d.ts:2075


x

x: number

The x component of the vector.

Defined in

websg.d.ts:2063


y

y: number

The y component of the vector.

Defined in

websg.d.ts:2067


z

z: number

The z component of the vector.

Defined in

websg.d.ts:2071

Methods

add

add(vector): Vector4

Adds a vector to this vector.

Parameters

NameTypeDescription
vectorArrayLike<number>The vector to add.

Returns

Vector4

Defined in

websg.d.ts:2122


addScaledVector

addScaledVector(vector, scale): Vector4

Adds a scaled vector to this vector.

Parameters

NameTypeDescription
vectorArrayLike<number>The vector to add.
scalenumberThe scale to apply to the vector.

Returns

Vector4

Defined in

websg.d.ts:2134


addVectors

addVectors(a, b): Vector4

Adds two vectors together and stores the result in this vector.

Parameters

NameTypeDescription
aArrayLike<number>The first vector.
bArrayLike<number>The second vector.

Returns

Vector4

Defined in

websg.d.ts:2128


divide

divide(vector): Vector4

Divides this vector by another vector.

Parameters

NameTypeDescription
vectorArrayLike<number>The vector to divide by.

Returns

Vector4

Defined in

websg.d.ts:2172


divideScalar

divideScalar(scalar): Vector4

Divides this vector by a scalar value.

Parameters

NameTypeDescription
scalarnumberThe scalar to divide by.

Returns

Vector4

Defined in

websg.d.ts:2183


divideVectors

divideVectors(a, b): Vector4

Divides two vectors and stores the result in this vector.

Parameters

NameTypeDescription
aArrayLike<number>The first vector.
bArrayLike<number>The second vector.

Returns

Vector4

Defined in

websg.d.ts:2178


multiply

multiply(vector): Vector4

Multiplies this vector by another vector.

Parameters

NameTypeDescription
vectorArrayLike<number>The vector to multiply.

Returns

Vector4

Defined in

websg.d.ts:2156


multiplyScalar

multiplyScalar(scalar): Vector4

Multiplies this vector by a scalar value.

Parameters

NameTypeDescription
scalarnumberThe scalar to multiply by.

Returns

Vector4

Defined in

websg.d.ts:2167


multiplyVectors

multiplyVectors(a, b): Vector4

Multiplies two vectors together and stores the result in this vector.

Parameters

NameTypeDescription
aArrayLike<number>The first vector.
bArrayLike<number>The second vector.

Returns

Vector4

Defined in

websg.d.ts:2162


set

set(value): Vector4

Sets the components of the vector.

Parameters

NameTypeDescription
valueArrayLike<number>The x,y,z,w components of the vector.

Returns

Vector4

Defined in

websg.d.ts:2112


setScalar

setScalar(value): Vector4

Sets the components of the vector to a scalar value.

Parameters

NameTypeDescription
valuenumberThe value to set the components to.

Returns

Vector4

Defined in

websg.d.ts:2117


subtract

subtract(vector): Vector4

Subtracts a vector from this vector.

Parameters

NameTypeDescription
vectorArrayLike<number>The vector to subtract.

Returns

Vector4

Defined in

websg.d.ts:2139


subtractScaledVector

subtractScaledVector(vector, scale): Vector4

Subtracts a scaled vector from this vector.

Parameters

NameTypeDescription
vectorArrayLike<number>The vector to subtract.
scalenumberThe scale to apply to the vector.

Returns

Vector4

Defined in

websg.d.ts:2151


subtractVectors

subtractVectors(a, b): Vector4

Subtracts two vectors and stores the result in this vector.

Parameters

NameTypeDescription
aArrayLike<number>The first vector.
bArrayLike<number>The second vector.

Returns

Vector4

Defined in

websg.d.ts:2145