Class: Vector3
WebSG.Vector3
A 3-dimensional vector.
Indexable
▪ [index: number
]: number
Table of contents
Constructors
Properties
Methods
- add
- addScaledVector
- addVectors
- divide
- divideScalar
- divideVectors
- multiply
- multiplyScalar
- multiplyVectors
- set
- setScalar
- subtract
- subtractScaledVector
- subtractVectors
Constructors
constructor
• new Vector3()
Defined in
• new Vector3(x
, y
, z
)
Constructs and sets the initial components of the vector.
Parameters
Name | Type | Description |
---|---|---|
x | number | The x component of the vector. |
y | number | The y component of the vector. |
z | number | The z component of the vector. |
Defined in
• new Vector3(array
)
Constructs and sets the initial components of the vector from a numeric array-like object.
Parameters
Name | Type |
---|---|
array | ArrayLike <number > |
Defined in
Properties
length
• Readonly
length: number
Returns the number of components in this vector.
Defined in
x
• x: number
The x component of the vector.
Defined in
y
• y: number
The y component of the vector.
Defined in
z
• z: number
The z component of the vector.
Defined in
Methods
add
▸ add(vector
): Vector3
Adds the given vector to this vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to add. |
Returns
Defined in
addScaledVector
▸ addScaledVector(vector
, scale
): Vector3
Adds the given vector scaled by the given scalar to this vector.
Parameters
Name | Type |
---|---|
vector | ArrayLike <number > |
scale | number |
Returns
Defined in
addVectors
▸ addVectors(a
, b
): Vector3
Adds two vectors together and stores the result in this vector.
Parameters
Name | Type | Description |
---|---|---|
a | ArrayLike <number > | The first vector. |
b | ArrayLike <number > | The second vector. |
Returns
Defined in
divide
▸ divide(vector
): Vector3
Divides this vector by the given vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to divide by. |
Returns
Defined in
divideScalar
▸ divideScalar(scalar
): Vector3
Divides this vector by the given scalar.
Parameters
Name | Type | Description |
---|---|---|
scalar | number | The scalar to divide by. |
Returns
Defined in
divideVectors
▸ divideVectors(a
, b
): Vector3
Divides the first vector by the second and stores the result in this vector.
Parameters
Name | Type | Description |
---|---|---|
a | ArrayLike <number > | The first vector. |
b | ArrayLike <number > | The second vector. |
Returns
Defined in
multiply
▸ multiply(vector
): Vector3
Multiplies this vector by the given vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to multiply by. |
Returns
Defined in
multiplyScalar
▸ multiplyScalar(scalar
): Vector3
Multiplies this vector by the given scalar.
Parameters
Name | Type | Description |
---|---|---|
scalar | number | The scalar to multiply by. |
Returns
Defined in
multiplyVectors
▸ multiplyVectors(a
, b
): Vector3
Multiplies two vectors together and stores the result in this vector.
Parameters
Name | Type | Description |
---|---|---|
a | ArrayLike <number > | The first vector. |
b | ArrayLike <number > | The second vector. |
Returns
Defined in
set
▸ set(value
): Vector3
Sets the components of the vector.
Parameters
Name | Type | Description |
---|---|---|
value | ArrayLike <number > | The x,y,z components of the vector. |
Returns
Defined in
setScalar
▸ setScalar(value
): Vector3
Sets the components of the vector to the given scalar value.
Parameters
Name | Type | Description |
---|---|---|
value | number | The scalar value to set. |
Returns
Defined in
subtract
▸ subtract(vector
): Vector3
Subtracts the given vector from this vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to subtract. |
Returns
Defined in
subtractScaledVector
▸ subtractScaledVector(vector
, scale
): Vector3
Subtracts the given vector scaled by the given scalar from this vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to subtract. |
scale | number | The scalar to scale the vector by before subtracting. |
Returns
Defined in
subtractVectors
▸ subtractVectors(a
, b
): Vector3
Subtracts the second vector from the first and stores the result in this vector.
Parameters
Name | Type | Description |
---|---|---|
a | ArrayLike <number > | The first vector. |
b | ArrayLike <number > | The second vector. |