Methods
(static) add(outputVector, firstVector, secondVector) → {Vector3|Float32Array}
Adds two vectors.
Parameters:
| Name | Type | Description |
|---|---|---|
outputVector |
Vector3 | Float32Array | Output vector. |
firstVector |
Vector3 | Float32Array | First vector. |
secondVector |
Vector3 | Float32Array | Second vector. |
- Source:
Throws:
-
-
When any vector is invalid.
- Type
- TypeError
-
-
-
When `Float32Array` vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- Vector3 | Float32Array
(static) approxEquals(firstVector, secondVector, epsilonopt) → {boolean}
Compares two vectors with a tolerance.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
firstVector |
Vector3 | Float32Array | First vector. | ||
secondVector |
Vector3 | Float32Array | Second vector. | ||
epsilon |
number |
<optional> |
1e-6 | Tolerance. |
- Source:
Throws:
-
-
When vectors or epsilon are invalid.
- Type
- TypeError
-
-
-
When Float32Array vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- boolean
(static) clamp(outputVector, inputVector, min, max) → {Vector3|Float32Array}
Clamps vector components to the [min..max] range.
Parameters:
| Name | Type | Description |
|---|---|---|
outputVector |
Vector3 | Float32Array | Output vector. |
inputVector |
Vector3 | Float32Array | Input vector. |
min |
number | Minimum component value. |
max |
number | Maximum component value. |
- Source:
Throws:
-
-
When vectors or bounds are invalid.
- Type
- TypeError
-
-
-
When Float32Array vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- Vector3 | Float32Array
(static) cross(outputVector, firstVector, secondVector) → {Vector3|Float32Array}
Computes cross product.
Parameters:
| Name | Type | Description |
|---|---|---|
outputVector |
Vector3 | Float32Array | Output vector. |
firstVector |
Vector3 | Float32Array | First vector. |
secondVector |
Vector3 | Float32Array | Second vector. |
- Source:
Throws:
-
-
When vectors are invalid.
- Type
- TypeError
-
-
-
When `Float32Array` vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- Vector3 | Float32Array
(static) distance(firstVector, secondVector) → {number}
Computes distance between two vectors.
Parameters:
| Name | Type | Description |
|---|---|---|
firstVector |
Vector3 | Float32Array | First vector. |
secondVector |
Vector3 | Float32Array | Second vector. |
- Source:
Throws:
-
-
When vectors are invalid.
- Type
- TypeError
-
-
-
When `Float32Array` vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- number
(static) dot(firstVector, secondVector) → {number}
Computes dot product.
Parameters:
| Name | Type | Description |
|---|---|---|
firstVector |
Vector3 | Float32Array | First vector. |
secondVector |
Vector3 | Float32Array | Second vector. |
- Source:
Throws:
-
-
When vectors are invalid.
- Type
- TypeError
-
-
-
When `Float32Array` vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- number
(static) length(inputVector) → {number}
Computes vector length.
Parameters:
| Name | Type | Description |
|---|---|---|
inputVector |
Vector3 | Float32Array | Input vector. |
- Source:
Throws:
-
-
When vector is invalid.
- Type
- TypeError
-
-
-
When `Float32Array` vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- number
(static) lerp(outputVector, startVector, endVector, interpolationFactor) → {Vector3|Float32Array}
Linearly interpolates between vectors.
Parameters:
| Name | Type | Description |
|---|---|---|
outputVector |
Vector3 | Float32Array | Output vector. |
startVector |
Vector3 | Float32Array | Start vector. |
endVector |
Vector3 | Float32Array | End vector. |
interpolationFactor |
number | Interpolation factor in [0..1]. |
- Source:
Throws:
-
-
When vectors or interpolation factor are invalid.
- Type
- TypeError
-
-
-
When Float32Array vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- Vector3 | Float32Array
(static) normalize(outputVector, inputVector) → {Vector3|Float32Array}
Normalizes a vector.
Parameters:
| Name | Type | Description |
|---|---|---|
outputVector |
Vector3 | Float32Array | Output vector. |
inputVector |
Vector3 | Float32Array | Input vector. |
- Source:
Throws:
-
-
When vectors are invalid.
- Type
- TypeError
-
-
-
When `Float32Array` vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- Vector3 | Float32Array
(static) scale(outputVector, inputVector, scalar) → {Vector3|Float32Array}
Scales a vector by a scalar.
Parameters:
| Name | Type | Description |
|---|---|---|
outputVector |
Vector3 | Float32Array | Output vector. |
inputVector |
Vector3 | Float32Array | Input vector. |
scalar |
number | Scalar multiplier. |
- Source:
Throws:
-
-
When vectors or scalar are invalid.
- Type
- TypeError
-
-
-
When `Float32Array` vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- Vector3 | Float32Array
(static) sub(outputVector, firstVector, secondVector) → {Vector3|Float32Array}
Subtracts the second vector from the first vector.
Parameters:
| Name | Type | Description |
|---|---|---|
outputVector |
Vector3 | Float32Array | Output vector. |
firstVector |
Vector3 | Float32Array | First vector. |
secondVector |
Vector3 | Float32Array | Second vector. |
- Source:
Throws:
-
-
When any vector is invalid.
- Type
- TypeError
-
-
-
When `Float32Array` vectors are not `length 3`.
- Type
- RangeError
-
Returns:
- Type
- Vector3 | Float32Array