new Vector3(x, y, z)math3d.js:75Create a 3D vector
xnumber optional, default 0ynumber optional, default 0znumber optional, default 0
const a = vec3(1, 2, 3);
const b = a.add(vec3(0, 1, 0)).normalize();3D Vector object, right handed with Y up
new Vector3(x, y, z)math3d.js:75Create a 3D vector
x number optional, default 0y number optional, default 0z number optional, default 0const a = vec3(1, 2, 3);
const b = a.add(vec3(0, 1, 0)).normalize();x : numbermath3d.js:85X axis location
y : numbermath3d.js:87Y axis location
z : numbermath3d.js:89Z axis location
abs() → Vector3math3d.js:242Returns a new vector with the absolute value of each component
clampLength(length) → Vector3math3d.js:169Returns a new vector clamped to the length passed in
length number optional, default 1copy() → Vector3math3d.js:106Returns a new vector that is a copy of this
cross(v) → Vector3math3d.js:183Returns a vector at right angles to both this and the one passed in
v Vector3distance(v) → numbermath3d.js:150Returns the distance from this vector to the vector passed in
v Vector3distanceSquared(v) → numbermath3d.js:155Returns the distance squared from this vector to the vector passed in
v Vector3divide(v) → Vector3math3d.js:126Returns a copy of this vector divided by the vector passed in
v Vector3dot(v) → numbermath3d.js:178Returns the dot product of this vector and the vector passed in
v Vector3floor() → Vector3math3d.js:246Returns a new vector with each component floored
isValid() → booleanmath3d.js:273Checks if this is a valid vector
length() → numbermath3d.js:135Returns the length of this vector
lengthSquared() → numbermath3d.js:139Returns the length of this vector squared
lerp(v, percent) → Vector3math3d.js:195Returns a new vector interpolated between this and the vector passed in, percent is clamped to 0-1
v Vector3percent numbernormalize(length) → Vector3math3d.js:160Returns a new vector in the same direction with the length passed in, zero stays zero
length number optional, default 1reflect(normal, restitution) → Vector3math3d.js:145Returns a copy of this vector reflected by a surface normal
normal Vector3Surface normal, should be normalized
restitution number optional, default 1How much to bounce, 1 is a perfect bounce, 0 slides along the surface
rotate(axis, angle) → Vector3math3d.js:205Returns a new vector turned around an axis, counter clockwise when the axis points at you
axis Vector3Unit length
angle numberRadians
rotateX(angle) → Vector3math3d.js:216Returns a new vector turned around the X axis, the way a positive pitch in rotation3D turns things
angle numberRadians
rotateY(angle) → Vector3math3d.js:225Returns a new vector turned around the Y axis, the way a positive yaw in rotation3D turns things
angle numberRadians
rotateZ(angle) → Vector3math3d.js:234Returns a new vector turned around the Z axis, the way a positive roll in rotation3D turns things
angle numberRadians
round() → Vector3math3d.js:250Returns a new vector with each component rounded
set(x, y, z) → Vector3math3d.js:97Sets values of this vector and returns self
x number optional, default 0y number optional, default 0z number optional, default 0setFrom(v) → Vector3math3d.js:102Copies the values of another vector into this one and returns self
v Vector3snap(grid) → Vector3math3d.js:255Returns a new vector snapped down to a grid, grid is the number of steps per unit like Vector2.snap
grid numberSnap steps per unit, 2 snaps to halves
toString(digits) → stringmath3d.js:278Returns a string representation of this vector for debugging
digits number optional, default 3Number of digits to display
transform(matrix) → Vector3math3d.js:264Returns this point transformed by a matrix, translation included
matrix Matrix4transformDirection(matrix) → Vector3math3d.js:269Returns this direction transformed by a matrix, rotation and scale only
matrix Matrix4