Class: Vector4
WebSG.Vector4
A 4-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 Vector4()
Constructs a new vector.
Defined in
• new Vector4(x
, y
, z
, w
)
Constructs a new vector with the given components.
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. |
w | number | The w component of the vector. |
Defined in
• new Vector4(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
bottom
• bottom: number
Alias for z
Defined in
left
• left: number
Alias for w
Defined in
length
• Readonly
length: number
Returns the number of components in this vector.
Defined in
right
• right: number
Alias for y
Defined in
top
• top: number
Alias for x
Defined in
w
• w: number
The w component of the 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
): Vector4
Adds a vector to this vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to add. |
Returns
Defined in
addScaledVector
▸ addScaledVector(vector
, scale
): Vector4
Adds a scaled vector to this vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to add. |
scale | number | The scale to apply to the vector. |
Returns
Defined in
addVectors
▸ addVectors(a
, b
): Vector4
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
): Vector4
Divides this vector by another vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to divide by. |
Returns
Defined in
divideScalar
▸ divideScalar(scalar
): Vector4
Divides this vector by a scalar value.
Parameters
Name | Type | Description |
---|---|---|
scalar | number | The scalar to divide by. |
Returns
Defined in
divideVectors
▸ divideVectors(a
, b
): Vector4
Divides two vectors 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
): Vector4
Multiplies this vector by another vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to multiply. |
Returns
Defined in
multiplyScalar
▸ multiplyScalar(scalar
): Vector4
Multiplies this vector by a scalar value.
Parameters
Name | Type | Description |
---|---|---|
scalar | number | The scalar to multiply by. |
Returns
Defined in
multiplyVectors
▸ multiplyVectors(a
, b
): Vector4
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
): Vector4
Sets the components of the vector.
Parameters
Name | Type | Description |
---|---|---|
value | ArrayLike <number > | The x,y,z,w components of the vector. |
Returns
Defined in
setScalar
▸ setScalar(value
): Vector4
Sets the components of the vector to a scalar value.
Parameters
Name | Type | Description |
---|---|---|
value | number | The value to set the components to. |
Returns
Defined in
subtract
▸ subtract(vector
): Vector4
Subtracts a vector from this vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to subtract. |
Returns
Defined in
subtractScaledVector
▸ subtractScaledVector(vector
, scale
): Vector4
Subtracts a scaled vector from this vector.
Parameters
Name | Type | Description |
---|---|---|
vector | ArrayLike <number > | The vector to subtract. |
scale | number | The scale to apply to the vector. |
Returns
Defined in
subtractVectors
▸ subtractVectors(a
, b
): Vector4
Subtracts two vectors and stores the result in this vector.
Parameters
Name | Type | Description |
---|---|---|
a | ArrayLike <number > | The first vector. |
b | ArrayLike <number > | The second vector. |