Constructor
new Vector3($x, $y, $z)
- Description:
- Creates a new three-dimensional vector.
- Source:
Examples
// without chaining
const vector = new Vector3(3, 2, 1);
vector.add(new Vector3(1, 0, -1));
// with chaining
const vector = new Vector3(3, 2, 1).add(new Vector3(1, 0, -1));
Parameters:
Name | Type | Description |
---|---|---|
$x |
number | The x component of the vector to create. |
$y |
number | The y component of the vector to create. |
$z |
number | The z component of the vector to create. |
Members
x :number
- Description:
- Gets the x component.
- Source:
Gets the x component.
Type:
- number
y :number
- Description:
- Gets the y component.
- Source:
Gets the y component.
Type:
- number
z :number
- Description:
- Gets the z component.
- Source:
Gets the z component.
Type:
- number
Methods
add($vector) → {this}
- Description:
- Adds the given vector.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
$vector |
Vector3 | The vector to add. |
Returns:
- Type
- this
clone() → {Vector3}
- Description:
- Clones the vector.
- Source:
Returns:
- Type
- Vector3
equal($vector) → {boolean}
- Description:
- Checks the equality with the given vector.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
$vector |
Vector3 | The vector to check with. |
Returns:
- Type
- boolean
length() → {number}
- Description:
- Gets the length of the vector.
- Source:
Returns:
- Type
- number
multiply($vector) → {this}
- Description:
- Multiplies with the given vector.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
$vector |
Vector3 | The vector to multiply with. |
Returns:
- Type
- this
negate() → {this}
- Description:
- Negates the vector.
- Source:
Returns:
- Type
- this
normalize() → {this}
- Description:
- Normalizes the vector.
- Source:
Returns:
- Type
- this
rotate($quaternion) → {this}
- Description:
- Rotates the vector.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
$quaternion |
Quaternion | The rotation to apply. |
Returns:
- Type
- this
scale($factor) → {this}
- Description:
- Scales the vector by the given scalar factor.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
$factor |
number | The scalar factor to multiply with. |
Returns:
- Type
- this
subtract($vector) → {this}
- Description:
- Subtracts the given vector.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
$vector |
Vector3 | The vector to subtract. |
Returns:
- Type
- this
(static) from($vector) → {Vector3}
- Description:
- Creates a new vector from the given vector.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
$vector |
Vector3 | The given vector. |
Returns:
- Type
- Vector3