Threepp.Vector3¶
3D vector class
Represents a three-dimensional vector. It can also be converted from an array [x, y, z] or a dictionary %[x:, y:, z:].
Members¶
Constructors¶
Properties¶
Methods¶
- set
- setScalar
- setX
- setY
- setZ
- copy
- add
- addScalar
- addVectors
- addScaledVector
- sub
- subScalar
- subVectors
- multiply
- multiplyScalar
- multiplyVectors
- applyAxisAngle
- applyEuler
- applyMatrix3
- applyMatrix4
- applyQuaternion
- project
- unproject
- transformDirection
- divide
- divideScalar
- min
- max
- clamp
- clampScalar
- clampLength
- floor
- ceil
- round
- negate
- dot
- lengthSq
- length
- manhattanLength
- normalize
- setLength
- lerp
- lerpVectors
- cross
- crossVectors
- reflect
- angleTo
- distanceTo
- distanceToSquared
- manhattanDistanceTo
- setFromMatrixPosition
- setFromMatrixScale
- equals
Vector3¶
Constructor
Arguments
| Arguments | Default | Description |
|---|---|---|
x |
0 |
X component. |
y |
0 |
Y component. |
z |
0 |
Z component. |
Description
Constructor
x¶
Property \ Access: r/w
Description
X component
y¶
Property \ Access: r/w
Description
Y component
z¶
Property \ Access: r/w
Description
Z component
set¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
x |
|
|
y |
|
|
z |
|
Description
Sets the values
setScalar¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
value |
|
Description
Sets all components to the same value
setX¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
value |
|
Description
Sets the X component
setY¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
value |
|
Description
Sets the Y component
setZ¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
value |
|
Description
Sets the Z component
copy¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Copies another vector
add¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Adds a vector
addScalar¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
s |
|
Description
Adds a scalar
addVectors¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
a |
|
|
b |
|
Description
Sets this vector to the sum of two vectors
addScaledVector¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
|
s |
|
Description
Adds a scaled vector
sub¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Subtracts a vector
subScalar¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
s |
|
Description
Subtracts a scalar
subVectors¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
a |
|
|
b |
|
Description
Sets this vector to the difference of two vectors
multiply¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Component-wise multiplication by a vector
multiplyScalar¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
s |
|
Description
Multiplies by a scalar
multiplyVectors¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
a |
|
|
b |
|
Description
Sets this vector to the component-wise product of two vectors
applyAxisAngle¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
axis |
|
|
angle |
|
Description
Rotates by an axis and an angle
applyEuler¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
euler |
|
Description
Rotates by Euler angles
applyMatrix3¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
m |
|
Description
Applies a 3x3 matrix
applyMatrix4¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
m |
|
Description
Applies a 4x4 matrix
applyQuaternion¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
q |
|
Description
Rotates by a quaternion
project¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
camera |
|
Description
Projects the vector with a camera
unproject¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
camera |
|
Description
Unprojects the vector
transformDirection¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
m |
|
Description
Transforms a direction vector
divide¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Component-wise division by a vector
divideScalar¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
s |
|
Description
Divides by a scalar
min¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Component-wise minimum
max¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Component-wise maximum
clamp¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
min |
|
|
max |
|
Description
Clamps each component
clampScalar¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
min |
|
|
max |
|
Description
Clamps to a scalar range
clampLength¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
min |
|
|
max |
|
Description
Clamps the length
floor¶
Method
Description
Rounds each component down
ceil¶
Method
Description
Rounds each component up
round¶
Method
Description
Rounds each component to the nearest integer
negate¶
Method
Description
Negates the vector
dot¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Dot product
lengthSq¶
Method
Description
Squared length
length¶
Method
Description
Length
manhattanLength¶
Method
Description
Manhattan length
normalize¶
Method
Description
Normalizes the vector
setLength¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
length |
|
Description
Sets the length
lerp¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
|
alpha |
|
Description
Linear interpolation
lerpVectors¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
a |
|
|
b |
|
|
alpha |
|
Description
Linear interpolation between two vectors
cross¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Cross product
crossVectors¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
a |
|
|
b |
|
Description
Cross product of two vectors
reflect¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
normal |
|
Description
Reflection
angleTo¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Angle to another vector
distanceTo¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Distance to another vector
distanceToSquared¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Squared distance
manhattanDistanceTo¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Manhattan distance
setFromMatrixPosition¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
m |
|
Description
Gets the translation component of a matrix
setFromMatrixScale¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
m |
|
Description
Gets the scale component of a matrix
equals¶
Method
Arguments
| Arguments | Default | Description |
|---|---|---|
v |
|
Description
Equality test