Constructor
new L3D.Vector3()
Vector3() // [0, 0, 0]
Vector3(1) // [1, 1, 1]
Vector3(1, 2, 3) // [1, 2, 3]
Vector3([1, 2, 3]) // [1, 2, 3]
Vector3(Vector3) // Copy the vector
arguments... |
* | Variable arguments |
Extends
- Float32Array
Properties
Get the axis that has the greatest absolute value.
True if the vector is all zeros.
The x component.
The y component.
The z component.
Vector3(0, 0, 1)
Vector3(0, -1, 0)
Vector3(0, 0, -1)
Vector3(-1, 0, 0)
Vector3(1, 1, 1)
Vector3(1, 0, 0)
Vector3(0, 1, 0)
Vector3(1, 0, 0)
Vector3(0, 1, 0)
Slightly offset from true Y, to reduce potential singularity error aligning Y to (0, -1, 0) with Matrix4.setAlignToVector.
Vector3(0, 0, 1)
Vector3(0, 0, 0)
Methods
abs() → Vector3
Make each component its absolute value, [abs(x), abs(y), abs(z)]
- Vector3
Returns self.
add(b) → Vector3
Add a vector to this, this + b.
b |
Vector3 |
- Vector3
Returns self.
clone() → Vector3
Create a copy of this vector.
divide(b) → Vector3
Divide a vector to this, this / b.
b |
Vector3 |
- Vector3
Returns self.
getLength() → number
Returns the length of the vector.
- number
getLengthSquared() → number
Returns the squared length of the vector.
- number
map() → number|Vector2|Vector3
Map this vector to a new vector.
map(1) // Returns a number with the y value of this vector.
map(0, 2) // Returns a Vector2 as [x, z].
map(2, 1, 0) // Returns a Vector3 with as [z, y, x].
arguments... |
number | The variable component indices to map. |
multiply(b) → Vector3
Multiply a vector with this, this * b.
b |
Vector3 |
- Vector3
Returns self.
negate() → Vector3
Negate the vector, as [-x, -y, -z].
- Vector3
Returns self.
normalize() → Vector3
Normalize the vector.
- Vector3
Returns self.
remap(xi, yi, zi) → Vector3
Remap the channels of this vector.
remap(1, 2, 0) // returns [y, z, x]
xi |
number | The index of the channel to set x to. |
yi |
number | The index of the channel to set y to. |
zi |
number | The index of the channel to set z to. |
scale(s) → Vector3
Scale the vector by a number, this * s.
s |
number |
setFrom(x, y, z) → Vector3
Set the components of this vector.
x |
number | Array | |
y |
number | |
z |
number |
- Vector3
Returns this vector.
setZero() → Vector3
Set all components to 0.
- Vector3
Returns this vector.
subtract(b) → Vector3
Subtract a vector from this, this - b.
b |
Vector3 |
- Vector3
Returns self.
sum() → number
Returns the sum of the components, x + y + z.
- number
toArray() → Array
Convert the vector to an Array.
- Array
toString() → String
Get the string representation of the vector.
- String
static abs(a, out) → Vector3
Return the absoluate value of a vector.
a |
Vector3 | |
out |
Vector3 | Optional storage for the output. |
static add(a, b, out) → Vector3
Add two vectors.
a |
Vector3 | |
b |
Vector3 | |
out |
Vector3 | Optional storage for the output. |
static cross(a, b, out) → Vector3
Calculate the cross product of two vectors.
a |
Vector3 | |
b |
Vector3 | |
out |
Vector3 | Optional storage for the output. |
static distance(a, b) → number
Calculate the distance between two points.
a |
Vector3 | |
b |
Vector3 |
- number
static distanceSquared(a, b) → number
Calculate the squared distance between two points.
a |
Vector3 | |
b |
Vector3 |
- number
static divide(a, b, out) → Vector3
Divide two vectors.
a |
Vector3 | |
b |
Vector3 | |
out |
Vector3 |
static dot(a, b) → number
Calculate the dot product of two vectors.
a |
Vector3 | |
b |
Vector3 |
- number
static length(a) → number
Calculate the length of a vector.
a |
Vector3 |
- number
static lengthSquared(a) → number
Calculate the squared lenth of a vector.
a |
Vector3 |
- number
static lerp(a, b, t, out) → Vector3
Linear interpolate between two vectors.
a |
Vector3 | |
b |
Vector3 | |
t |
number | Interpolator between 0 and 1. |
out |
Vector3 | Optional storage for the output. |
static max(a, b, out) → Vector3
Each component will be the maximum of either a or b.
a |
Vector3 | |
b |
Vector3 | |
out |
Vector3 | Optional storage for the output. |
static min(a, b, out) → Vector3
Each component will be the minimum of either a or b.
a |
Vector3 | |
b |
Vector3 | |
out |
Vector3 | Optional storage for the output. |
static multiply(a, b, out) → Vector3
Multiply two vectors
a |
Vector3 | |
b |
Vector3 | |
out |
Vector3 |
static negated(a, out) → Vector3
Return the negated value of a vector.
a |
Vector3 | |
out |
Vector3 | Optional storage for the output. |
static normalize(a, out) → Vector3
Return the normalized version of the vector.
a |
Vector3 | |
out |
Vector3 | Optional storage for the output. |
static project(a, b, out) → Vector3
Project a onto b.
a |
Vector3 | |
b |
Vector3 | |
out |
Vector3 |
static reflect(direction, normal, out) → Vector3
Reflect the direction vector against the normal.
direction |
Vector3 | |
normal |
Vector3 | |
out |
Vector3 |
static refract(incident, normal, eta, out) → Vector3
Calculate the refraction vector against the surface normal, from IOR k1 to IOR k2.
incident |
Vector3 | Specifies the incident vector |
normal |
Vector3 | Specifies the normal vector |
eta |
number | Specifies the ratio of indices of refraction |
out |
Vector3 | Optional output storage |
static scale(a, s, out) → Vector3
Scale a vector by a number.
a |
Vector3 | |
s |
number | |
out |
Vector3 |
static scaleAndAdd(a, b, s, out) → Vector3
Scale and add two numbers, as out = a + b * s.
a |
Vector3 | |
b |
Vector3 | |
s |
number | |
out |
Vector3 |
static subtract(a, b, out) → Vector3
Subtract two vectors
a |
Vector3 | |
b |
Vector3 | |
out |
Vector3 |