Skip to content
On this page

Class: Vector3 ​

WebSG.Vector3

A 3-dimensional vector.

Indexable ​

▪ [index: number]: number

Table of contents ​

Constructors ​

Properties ​

Methods ​

Constructors ​

constructor ​

• new Vector3()

Defined in ​

websg.d.ts:1963

• new Vector3(x, y, z)

Constructs and sets the initial components of the vector.

Parameters ​

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

Defined in ​

websg.d.ts:1970

• new Vector3(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:1974

Properties ​

length ​

• Readonly length: number

Returns the number of components in this vector.

Defined in ​

websg.d.ts:2052


x ​

• x: number

The x component of the vector.

Defined in ​

websg.d.ts:1954


y ​

• y: number

The y component of the vector.

Defined in ​

websg.d.ts:1958


z ​

• z: number

The z component of the vector.

Defined in ​

websg.d.ts:1962

Methods ​

add ​

▸ add(vector): Vector3

Adds the given vector to this vector.

Parameters ​

NameTypeDescription
vectorArrayLike<number>The vector to add.

Returns ​

Vector3

Defined in ​

websg.d.ts:1989


addScaledVector ​

▸ addScaledVector(vector, scale): Vector3

Adds the given vector scaled by the given scalar to this vector.

Parameters ​

NameType
vectorArrayLike<number>
scalenumber

Returns ​

Vector3

Defined in ​

websg.d.ts:1999


addVectors ​

▸ addVectors(a, b): Vector3

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

Parameters ​

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

Returns ​

Vector3

Defined in ​

websg.d.ts:1995


divide ​

▸ divide(vector): Vector3

Divides this vector by the given vector.

Parameters ​

NameTypeDescription
vectorArrayLike<number>The vector to divide by.

Returns ​

Vector3

Defined in ​

websg.d.ts:2037


divideScalar ​

▸ divideScalar(scalar): Vector3

Divides this vector by the given scalar.

Parameters ​

NameTypeDescription
scalarnumberThe scalar to divide by.

Returns ​

Vector3

Defined in ​

websg.d.ts:2048


divideVectors ​

▸ divideVectors(a, b): Vector3

Divides the first vector by the second and stores the result in this vector.

Parameters ​

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

Returns ​

Vector3

Defined in ​

websg.d.ts:2043


multiply ​

▸ multiply(vector): Vector3

Multiplies this vector by the given vector.

Parameters ​

NameTypeDescription
vectorArrayLike<number>The vector to multiply by.

Returns ​

Vector3

Defined in ​

websg.d.ts:2021


multiplyScalar ​

▸ multiplyScalar(scalar): Vector3

Multiplies this vector by the given scalar.

Parameters ​

NameTypeDescription
scalarnumberThe scalar to multiply by.

Returns ​

Vector3

Defined in ​

websg.d.ts:2032


multiplyVectors ​

▸ multiplyVectors(a, b): Vector3

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

Parameters ​

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

Returns ​

Vector3

Defined in ​

websg.d.ts:2027


set ​

▸ set(value): Vector3

Sets the components of the vector.

Parameters ​

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

Returns ​

Vector3

Defined in ​

websg.d.ts:1979


setScalar ​

▸ setScalar(value): Vector3

Sets the components of the vector to the given scalar value.

Parameters ​

NameTypeDescription
valuenumberThe scalar value to set.

Returns ​

Vector3

Defined in ​

websg.d.ts:1984


subtract ​

▸ subtract(vector): Vector3

Subtracts the given vector from this vector.

Parameters ​

NameTypeDescription
vectorArrayLike<number>The vector to subtract.

Returns ​

Vector3

Defined in ​

websg.d.ts:2004


subtractScaledVector ​

▸ subtractScaledVector(vector, scale): Vector3

Subtracts the given vector scaled by the given scalar from this vector.

Parameters ​

NameTypeDescription
vectorArrayLike<number>The vector to subtract.
scalenumberThe scalar to scale the vector by before subtracting.

Returns ​

Vector3

Defined in ​

websg.d.ts:2016


subtractVectors ​

▸ subtractVectors(a, b): Vector3

Subtracts the second vector from the first and stores the result in this vector.

Parameters ​

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

Returns ​

Vector3

Defined in ​

websg.d.ts:2010