Vector3
Vector3
Kind: global class
Author: Alex Goldring
Copyright: Alex Goldring 2015-2024
- Vector3
- new Vector3([x], [y], [z])
- instance
- .x :
number - .y :
number - .z :
number - .onChanged :
Signal.<number, number, number, number, number, number> .asArray- .isVector3 :
boolean - .readFromArray(array, offset)
- .writeToArray(array, offset)
- .set(x, y, z) ⇒
Vector3 - .setScalar(v)
- .setX(v) ⇒
Vector3 - .setY(v) ⇒
Vector3 - .setZ(v) ⇒
Vector3 - .setXY(x, y) ⇒
Vector3 - .setXZ(x, z) ⇒
Vector3 - .setYZ(y, z) ⇒
Vector3 - .addVectors(a, b)
- .add(other) ⇒
Vector3 - ._add(x, y, z) ⇒
Vector3 - .subVectors(a, b)
- .sub(other) ⇒
Vector3 - ._sub(x, y, z) ⇒
Vector3 - ._multiply(x, y, z) ⇒
Vector3 - .multiply(other) ⇒
Vector3 - .multiplyVectors(a, b)
- ._divide(x, y, z) ⇒
Vector3 - .divide(other) ⇒
Vector3 - .subScalar(val) ⇒
Vector3 - .addScalar(val) ⇒
Vector3 - .clone() ⇒
Vector3 - .multiplyScalar(val) ⇒
Vector3 - .isZero() ⇒
boolean - .cross(other) ⇒
Vector3 - .crossVectors(first, second)
- ._crossVectors(ax, ay, az, bx, by, bz)
- .abs() ⇒
Vector3 - .dot(v) ⇒
number - .length() ⇒
number - .lengthSqr() ⇒
number - .normalize()
- .isNormalized([squaredError]) ⇒
boolean - .copy(other) ⇒
Vector3 - .negate() ⇒
Vector3 - .distanceTo(other) ⇒
number - ._distanceTo(x, y, z) ⇒
number - .distanceSqrTo(other)
- ._distanceSqrTo(x, y, z) ⇒
number - .angleTo(other) ⇒
number - .applyQuaternion(q)
- .sign() ⇒
Vector3 - .lerp(other, fraction) ⇒
Vector3 - .lerpVectors(a, b, fraction)
- .slerpVectors(a, b, fraction)
.applyMatrix4_three(matrix4)- .applyMatrix4(m4)
- .applyDirectionMatrix4(m4)
.transformDirection_three(m).applyMatrix3_three(m) ⇒Vector3- .applyMatrix3(mat)
.threejs_setFromMatrixPosition(matrix4)- .setFromMatrixPosition(matrix4)
- .equals(other) ⇒
boolean - ._equals(x, y, z) ⇒
boolean - .roughlyEquals(other, [tolerance]) ⇒
boolean - ._roughlyEquals(x, y, z, [tolerance]) ⇒
boolean - .projectOntoVector3(other)
- ._projectVectors(x0, y0, z0, x1, y1, z1)
- .setFromSphericalCoords(radius, phi, theta)
- .process(processor, [thisArg]) ⇒
Vector3 - .fromJSON(json)
.toBinaryBuffer(buffer).fromBinaryBuffer(buffer).toBinaryBufferFloat32(buffer).fromBinaryBufferFloat32(buffer)
- .x :
- static
- .zero :
Vector3 - .one :
Vector3 - .minus_one :
Vector3 - .up :
Vector3 - .down :
Vector3 - .left :
Vector3 - .right :
Vector3 - .forward :
Vector3 - .back :
Vector3 - .typeName :
string - .dot(a, b) ⇒
number - .distance(a, b) ⇒
number - .fromArray(input, [offset]) ⇒
Vector3 - .fromScalar(value) ⇒
Vector3
- .zero :
new Vector3([x], [y], [z])
| Param | Type | Default |
|---|---|---|
| [x] | number | 0 |
| [y] | number | 0 |
| [z] | number | 0 |
vector3.x : number
Kind: instance property of Vector3
vector3.y : number
Kind: instance property of Vector3
vector3.z : number
Kind: instance property of Vector3
vector3.onChanged : Signal.<number, number, number, number, number, number>
Kind: instance property of Vector3
Read only: true
vector3.asArray
Deprecated
Kind: instance property of Vector3
vector3.isVector3 : boolean
Kind: instance property of Vector3
Read only: true
vector3.readFromArray(array, offset)
Kind: instance method of Vector3
| Param | Type | Default |
|---|---|---|
| array | Array.<number> | Float32Array | |
| offset | number | 0 |
vector3.writeToArray(array, offset)
Kind: instance method of Vector3
| Param | Type | Default |
|---|---|---|
| array | Array.<number> | Float32Array | |
| offset | number | 0 |
vector3.set(x, y, z) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x | Number |
| y | Number |
| z | Number |
vector3.setScalar(v)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| v | number |
vector3.setX(v) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| v | number |
vector3.setY(v) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| v | number |
vector3.setZ(v) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| v | number |
vector3.setXY(x, y) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x | number |
| y | number |
vector3.setXZ(x, z) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x | number |
| z | number |
vector3.setYZ(y, z) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| y | number |
| z | number |
vector3.addVectors(a, b)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| a | Vector3 |
| b | Vector3 |
vector3.add(other) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 |
vector3._add(x, y, z) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x | Number |
| y | Number |
| z | Number |
vector3.subVectors(a, b)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| a | Vector3 |
| b | Vector3 |
vector3.sub(other) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 |
vector3._sub(x, y, z) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x | Number |
| y | Number |
| z | Number |
vector3._multiply(x, y, z) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x | Number |
| y | Number |
| z | Number |
vector3.multiply(other) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 |
vector3.multiplyVectors(a, b)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| a | Vector3 |
| b | Vector3 |
vector3._divide(x, y, z) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x | number |
| y | number |
| z | number |
vector3.divide(other) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 |
vector3.subScalar(val) ⇒ Vector3
Subtract scalar value from each component of the vector
Kind: instance method of Vector3
| Param | Type |
|---|---|
| val | number |
vector3.addScalar(val) ⇒ Vector3
Add a scalar value to each component of the vector
Kind: instance method of Vector3
| Param | Type |
|---|---|
| val | number |
vector3.clone() ⇒ Vector3
Kind: instance method of Vector3
vector3.multiplyScalar(val) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| val | number |
vector3.isZero() ⇒ boolean
Kind: instance method of Vector3
vector3.cross(other) ⇒ Vector3
Compute cross-product of two vectors. Result is written to this vector.
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 |
vector3.crossVectors(first, second)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| first | Vector3 |
| second | Vector3 |
vector3._crossVectors(ax, ay, az, bx, by, bz)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| ax | number |
| ay | number |
| az | number |
| bx | number |
| by | number |
| bz | number |
vector3.abs() ⇒ Vector3
Sets all components of the vector to absolute value (positive)
Kind: instance method of Vector3
vector3.dot(v) ⇒ number
Kind: instance method of Vector3
| Param | Type |
|---|---|
| v | Vector3 |
vector3.length() ⇒ number
Computes length(magnitude) of the vector
Kind: instance method of Vector3
vector3.lengthSqr() ⇒ number
Computes squared length(magnitude) of the vector. Note: this operation is faster than computing length, because it doesn't involve computing square root
Kind: instance method of Vector3
vector3.normalize()
Normalizes the vector, preserving its direction, but making magnitude equal to 1
Kind: instance method of Vector3
vector3.isNormalized([squaredError]) ⇒ boolean
Kind: instance method of Vector3
| Param | Type | Default |
|---|---|---|
| [squaredError] | number | 0.00001 |
vector3.copy(other) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 | Object |
vector3.negate() ⇒ Vector3
Negates every component of the vector making it {-x, -y, -z}
Kind: instance method of Vector3
vector3.distanceTo(other) ⇒ number
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 |
vector3._distanceTo(x, y, z) ⇒ number
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x | number |
| y | number |
| z | number |
vector3.distanceSqrTo(other)
Squared distance between this vector and another. It is faster than computing real distance because no SQRT operation is needed.
Kind: instance method of Vector3
| Param | Type | Description |
|---|---|---|
| other | Vector3 | returns {number} |
vector3._distanceSqrTo(x, y, z) ⇒ number
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x | number |
| y | number |
| z | number |
vector3.angleTo(other) ⇒ number
Angle between two vectors (co-planar) in radians
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 |
vector3.applyQuaternion(q)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| q | Quaternion |
vector3.sign() ⇒ Vector3
Set components X,Y,Z to values 1,0 or -1 based on the sign of their original value.
Kind: instance method of Vector3
Example
new Vector(5,0,-10).sign().equals(new Vector(1,0,-1)); //true
vector3.lerp(other, fraction) ⇒ Vector3
Linear interpolation
Kind: instance method of Vector3
| Param | Type | Description |
|---|---|---|
| other | Vector3 | |
| fraction | Number | between 0 and 1 |
vector3.lerpVectors(a, b, fraction)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| a | Vector3 |
| b | Vector3 |
| fraction | number |
vector3.slerpVectors(a, b, fraction)
Spherical linear interpolation
Kind: instance method of Vector3
| Param | Type |
|---|---|
| a | Vector3 |
| b | Vector3 |
| fraction | number |
vector3.applyMatrix4_three(matrix4)
Deprecated
Kind: instance method of Vector3
| Param | Type |
|---|---|
| matrix4 | THREE.Matrix4 |
vector3.applyMatrix4(m4)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| m4 | ArrayLike.<number> | Array.<number> | Float32Array |
vector3.applyDirectionMatrix4(m4)
Assume current vector holds a direction, transform using a matrix to produce a new directional unit vector
Kind: instance method of Vector3
| Param | Type |
|---|---|
| m4 | ArrayLike.<number> | Array.<number> | Float32Array |
vector3.transformDirection_three(m)
Deprecated
Kind: instance method of Vector3
| Param | Type |
|---|---|
| m | THREE.Matrix4 |
vector3.applyMatrix3_three(m) ⇒ Vector3
Vector3Deprecated
Kind: instance method of Vector3
| Param | Type |
|---|---|
| m | THREE.Matrix3 |
vector3.applyMatrix3(mat)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| mat | Array.<number> | Float32Array |
vector3.threejs_setFromMatrixPosition(matrix4)
Deprecated
Kind: instance method of Vector3
| Param | Type |
|---|---|
| matrix4 | THREE.Matrix4 |
vector3.setFromMatrixPosition(matrix4)
Kind: instance method of Vector3
| Param | Type | Description |
|---|---|---|
| matrix4 | ArrayLike.<number> | Array.<number> | Float32Array | 4x4 transform matrix |
vector3.equals(other) ⇒ boolean
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 |
vector3._equals(x, y, z) ⇒ boolean
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x | number |
| y | number |
| z | number |
vector3.roughlyEquals(other, [tolerance]) ⇒ boolean
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 |
| [tolerance] | number |
vector3._roughlyEquals(x, y, z, [tolerance]) ⇒ boolean
Kind: instance method of Vector3
| Param | Type | Description |
|---|---|---|
| x | number | |
| y | number | |
| z | number | |
| [tolerance] | number | acceptable deviation |
vector3.projectOntoVector3(other)
Project this vector onto another
Kind: instance method of Vector3
| Param | Type |
|---|---|
| other | Vector3 |
vector3._projectVectors(x0, y0, z0, x1, y1, z1)
Project first vector onto second one
Kind: instance method of Vector3
| Param | Type |
|---|---|
| x0 | number |
| y0 | number |
| z0 | number |
| x1 | number |
| y1 | number |
| z1 | number |
vector3.setFromSphericalCoords(radius, phi, theta)
Convert spherical coordinates to cartesian
Kind: instance method of Vector3
| Param | Type | Description |
|---|---|---|
| radius | number | |
| phi | number | Also known as Azimuth |
| theta | number | Also known as Elevation |
vector3.process(processor, [thisArg]) ⇒ Vector3
Kind: instance method of Vector3
| Param | Type |
|---|---|
| processor | function |
| [thisArg] | * |
vector3.fromJSON(json)
Kind: instance method of Vector3
| Param | Type |
|---|---|
| json | Object | number |
vector3.toBinaryBuffer(buffer)
Deprecated
Kind: instance method of Vector3
| Param | Type |
|---|---|
| buffer | BinaryBuffer |
vector3.fromBinaryBuffer(buffer)
Deprecated
Kind: instance method of Vector3
| Param | Type |
|---|---|
| buffer | BinaryBuffer |
vector3.toBinaryBufferFloat32(buffer)
Deprecated
Kind: instance method of Vector3
| Param | Type |
|---|---|
| buffer | BinaryBuffer |
vector3.fromBinaryBufferFloat32(buffer)
Deprecated
Kind: instance method of Vector3
| Param | Type |
|---|---|
| buffer | BinaryBuffer |
Vector3.zero : Vector3
Kind: static property of Vector3
Read only: true
Vector3.one : Vector3
Useful for setting scale
Kind: static property of Vector3
Read only: true
Vector3.minus_one : Vector3
Useful for setting scale
Kind: static property of Vector3
Read only: true
Vector3.up : Vector3
Kind: static property of Vector3
Read only: true
Vector3.down : Vector3
Kind: static property of Vector3
Read only: true
Vector3.left : Vector3
Kind: static property of Vector3
Read only: true
Vector3.right : Vector3
Kind: static property of Vector3
Read only: true
Vector3.forward : Vector3
Kind: static property of Vector3
Read only: true
Vector3.back : Vector3
Kind: static property of Vector3
Read only: true
Vector3.typeName : string
Kind: static property of Vector3
Read only: true
Vector3.dot(a, b) ⇒ number
Dot product
Kind: static method of Vector3
| Param | Type |
|---|---|
| a | Vector3 | Vector4 |
| b | Vector3 | Vector4 |
Vector3.distance(a, b) ⇒ number
Kind: static method of Vector3
| Param | Type |
|---|---|
| a | Vector3 |
| b | Vector3 |
Vector3.fromArray(input, [offset]) ⇒ Vector3
Kind: static method of Vector3
| Param | Type | Default |
|---|---|---|
| input | Array.<number> | |
| [offset] | number | 0 |
Vector3.fromScalar(value) ⇒ Vector3
Kind: static method of Vector3
| Param | Type |
|---|---|
| value | number |