A Vector object for 3d positions.
Kind: global class
- Vector3
- new Vector3(x, y, z)
- instance
- .clone() ⇒
Vector3
- .set(x, y, z) ⇒
Vector3
- .copy() ⇒
Vector3
- .add(Other) ⇒
Vector3
- .sub(Other) ⇒
Vector3
- .div(Other) ⇒
Vector3
- .mul(Other) ⇒
Vector3
- .round() ⇒
Vector3
- .floor() ⇒
Vector3
- .ceil() ⇒
Vector3
- .normalized() ⇒
Vector3
- .addSelf(Other) ⇒
Vector3
- .subSelf(Other) ⇒
Vector3
- .divSelf(Other) ⇒
Vector3
- .mulSelf(Other) ⇒
Vector3
- .roundSelf() ⇒
Vector3
- .floorSelf() ⇒
Vector3
- .ceilSelf() ⇒
Vector3
- .normalizeSelf() ⇒
Vector3
- .equals(other) ⇒
Boolean
- .approximate(other, threshold) ⇒
Boolean
- .length() ⇒
Number
- .scaled() ⇒
Vector3
- .distanceTo(other) ⇒
Number
- .distanceToSquared(other) ⇒
Number
- .clamp(min, max) ⇒
Vector3
- .clampSelf(min, max) ⇒
Vector3
- .dot(other) ⇒
Number
- .minSelf(v) ⇒
Vector3
- .maxSelf(v) ⇒
Vector3
- .min(v) ⇒
Vector3
- .max(v) ⇒
Vector3
- .string()
- .toArray() ⇒
Array.<Number>
- .toDict(minimized) ⇒
*
- .clone() ⇒
- static
- .zeroReadonly
- .oneReadonly
- .halfReadonly
- .leftReadonly
- .rightReadonly
- .upReadonly
- .downReadonly
- .frontReadonly
- .backReadonly
- .zero() ⇒
Vector3
- .one() ⇒
Vector3
- .half() ⇒
Vector3
- .left() ⇒
Vector3
- .right() ⇒
Vector3
- .up() ⇒
Vector3
- .down() ⇒
Vector3
- .front() ⇒
Vector3
- .back() ⇒
Vector3
- .lerp(p1, p2, a) ⇒
Vector3
- .distance(p1, p2) ⇒
Number
- .crossVector(p1, p2) ⇒
Vector3
- .parse(str) ⇒
Vector3
- .fromArray(arr) ⇒
Vector3
- .fromDict(data) ⇒
Vector3
Create the Vector object.
Param | Type | Default | Description |
---|---|---|---|
x | number |
0 |
Vector X. |
y | number |
0 |
Vector Y. |
z | number |
0 |
Vector Z. |
vector3.clone() ⇒ Vector3
Clone the vector.
Kind: instance method of Vector3
Returns: Vector3
- cloned vector.
vector3.set(x, y, z) ⇒ Vector3
Set vector value.
Kind: instance method of Vector3
Returns: Vector3
- this.
Param | Type | Description |
---|---|---|
x | Number |
X component. |
y | Number |
Y component. |
z | Number |
Z component. |
vector3.copy() ⇒ Vector3
Copy values from other vector into self.
Kind: instance method of Vector3
Returns: Vector3
- this.
vector3.add(Other) ⇒ Vector3
Return a new vector of this + other.
Kind: instance method of Vector3
Returns: Vector3
- result vector.
Param | Type | Description |
---|---|---|
Other | Number | Vector3 |
Vector3 or number to add to all components. |
vector3.sub(Other) ⇒ Vector3
Return a new vector of this - other.
Kind: instance method of Vector3
Returns: Vector3
- result vector.
Param | Type | Description |
---|---|---|
Other | Number | Vector3 |
Vector3 or number to sub from all components. |
vector3.div(Other) ⇒ Vector3
Return a new vector of this / other.
Kind: instance method of Vector3
Returns: Vector3
- result vector.
Param | Type | Description |
---|---|---|
Other | Number | Vector3 |
Vector3 or number to divide by all components. |
vector3.mul(Other) ⇒ Vector3
Return a new vector of this * other.
Kind: instance method of Vector3
Returns: Vector3
- result vector.
Param | Type | Description |
---|---|---|
Other | Number | Vector3 |
Vector3 or number to multiply with all components. |
vector3.round() ⇒ Vector3
Return a round copy of this vector.
Kind: instance method of Vector3
Returns: Vector3
- result vector.
vector3.floor() ⇒ Vector3
Return a floored copy of this vector.
Kind: instance method of Vector3
Returns: Vector3
- result vector.
vector3.ceil() ⇒ Vector3
Return a ceiled copy of this vector.
Kind: instance method of Vector3
Returns: Vector3
- result vector.
vector3.normalized() ⇒ Vector3
Return a normalized copy of this vector.
Kind: instance method of Vector3
Returns: Vector3
- result vector.
vector3.addSelf(Other) ⇒ Vector3
Add other vector values to self.
Kind: instance method of Vector3
Returns: Vector3
- this.
Param | Type | Description |
---|---|---|
Other | Number | Vector3 |
Vector or number to add. |
vector3.subSelf(Other) ⇒ Vector3
Sub other vector values from self.
Kind: instance method of Vector3
Returns: Vector3
- this.
Param | Type | Description |
---|---|---|
Other | Number | Vector3 |
Vector or number to substract. |
vector3.divSelf(Other) ⇒ Vector3
Divide this vector by other vector values.
Kind: instance method of Vector3
Returns: Vector3
- this.
Param | Type | Description |
---|---|---|
Other | Number | Vector3 |
Vector or number to divide by. |
vector3.mulSelf(Other) ⇒ Vector3
Multiply this vector by other vector values.
Kind: instance method of Vector3
Returns: Vector3
- this.
Param | Type | Description |
---|---|---|
Other | Number | Vector3 |
Vector or number to multiply by. |
vector3.roundSelf() ⇒ Vector3
Round self.
Kind: instance method of Vector3
Returns: Vector3
- this.
vector3.floorSelf() ⇒ Vector3
Floor self.
Kind: instance method of Vector3
Returns: Vector3
- this.
vector3.ceilSelf() ⇒ Vector3
Ceil self.
Kind: instance method of Vector3
Returns: Vector3
- this.
vector3.normalizeSelf() ⇒ Vector3
Return a normalized copy of this vector.
Kind: instance method of Vector3
Returns: Vector3
- this.
Return if vector equals another vector.
Kind: instance method of Vector3
Returns: Boolean
- if vectors are equal.
Param | Type | Description |
---|---|---|
other | Vector3 |
Other vector to compare to. |
Return if vector approximately equals another vector.
Kind: instance method of Vector3
Returns: Boolean
- if vectors are equal.
Param | Type | Description |
---|---|---|
other | Vector3 |
Other vector to compare to. |
threshold | Number |
Distance threshold to consider as equal. Defaults to 1. |
Return vector length (aka magnitude).
Kind: instance method of Vector3
Returns: Number
- Vector length.
vector3.scaled() ⇒ Vector3
Return a copy of this vector multiplied by a factor.
Kind: instance method of Vector3
Returns: Vector3
- result vector.
Calculate distance between this vector and another vector.
Kind: instance method of Vector3
Returns: Number
- Distance between vectors.
Param | Type | Description |
---|---|---|
other | Vector3 |
Other vector. |
Calculate squared distance between this vector and another vector.
Kind: instance method of Vector3
Returns: Number
- Distance between vectors.
Param | Type | Description |
---|---|---|
other | Vector3 |
Other vector. |
vector3.clamp(min, max) ⇒ Vector3
Return a clone and clamp its values to be between min and max.
Kind: instance method of Vector3
Returns: Vector3
- Clamped vector.
Param | Type | Description |
---|---|---|
min | Vector3 |
Min vector. |
max | Vector3 |
Max vector. |
vector3.clampSelf(min, max) ⇒ Vector3
Clamp this vector values to be between min and max.
Kind: instance method of Vector3
Returns: Vector3
- Self.
Param | Type | Description |
---|---|---|
min | Vector3 |
Min vector. |
max | Vector3 |
Max vector. |
Calculate the dot product with another vector.
Kind: instance method of Vector3
Returns: Number
- Dot product value.
Param | Type | Description |
---|---|---|
other | Vector3 |
Vector to calculate dot with. |
vector3.minSelf(v) ⇒ Vector3
Set self values to be min values between self and a given vector.
Kind: instance method of Vector3
Returns: Vector3
- Self.
Param | Type | Description |
---|---|---|
v | Vector3 |
Vector to min with. |
vector3.maxSelf(v) ⇒ Vector3
Set self values to be max values between self and a given vector.
Kind: instance method of Vector3
Returns: Vector3
- Self.
Param | Type | Description |
---|---|---|
v | Vector3 |
Vector to max with. |
vector3.min(v) ⇒ Vector3
Create a clone vector that is the min result between self and a given vector.
Kind: instance method of Vector3
Returns: Vector3
- Result vector.
Param | Type | Description |
---|---|---|
v | Vector3 |
Vector to min with. |
vector3.max(v) ⇒ Vector3
Create a clone vector that is the max result between self and a given vector.
Kind: instance method of Vector3
Returns: Vector3
- Result vector.
Param | Type | Description |
---|---|---|
v | Vector3 |
Vector to max with. |
Convert to string.
Kind: instance method of Vector3
Convert to array of numbers.
Kind: instance method of Vector3
Returns: Array.<Number>
- Vector components as array.
Convert to dictionary.
Kind: instance method of Vector3
Returns: *
- Dictionary with {x,y,z}
Param | Type | Description |
---|---|---|
minimized | Boolean |
If true, will not include keys that their values are 0. You can use fromDict on minimized dicts. |
Vector with 0,0,0 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector3
Vector with 1,1,1 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector3
Vector with 0.5,0.5,0.5 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector3
Vector with -1,0,0 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector3
Vector with 1,0,0 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector3
Vector with 0,-1,0 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector3
Vector with 0,1,0 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector3
Vector with 0,0,1 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector3
Vector with 0,0,-1 values as a frozen shared object. Be careful not to try and change it.
Kind: static property of Vector3
Vector3.zero() ⇒ Vector3
Get vector with 0,0,0 values.
Kind: static method of Vector3
Returns: Vector3
- result vector.
Vector3.one() ⇒ Vector3
Get vector with 1,1,1 values.
Kind: static method of Vector3
Returns: Vector3
- result vector.
Vector3.half() ⇒ Vector3
Get vector with 0.5,0.5 values.
Kind: static method of Vector3
Returns: Vector3
- result vector.
Vector3.left() ⇒ Vector3
Get vector with -1,0,0 values.
Kind: static method of Vector3
Returns: Vector3
- result vector.
Vector3.right() ⇒ Vector3
Get vector with 1,0,0 values.
Kind: static method of Vector3
Returns: Vector3
- result vector.
Vector3.up() ⇒ Vector3
Get vector with 0,-1,0 values.
Kind: static method of Vector3
Returns: Vector3
- result vector.
Vector3.down() ⇒ Vector3
Get vector with 0,1,0 values.
Kind: static method of Vector3
Returns: Vector3
- result vector.
Vector3.front() ⇒ Vector3
Get vector with 0,0,1 values.
Kind: static method of Vector3
Returns: Vector3
- result vector.
Vector3.back() ⇒ Vector3
Get vector with 0,0,-1 values.
Kind: static method of Vector3
Returns: Vector3
- result vector.
Vector3.lerp(p1, p2, a) ⇒ Vector3
Lerp between two vectors.
Kind: static method of Vector3
Returns: Vector3
- result vector.
Param | Type | Description |
---|---|---|
p1 | Vector3 |
First vector. |
p2 | Vector3 |
Second vector. |
a | Number |
Lerp factor (0.0 - 1.0). |
Calculate distance between two vectors.
Kind: static method of Vector3
Returns: Number
- Distance between vectors.
Param | Type | Description |
---|---|---|
p1 | Vector3 |
First vector. |
p2 | Vector3 |
Second vector. |
Vector3.crossVector(p1, p2) ⇒ Vector3
Return cross product between two vectors.
Kind: static method of Vector3
Returns: Vector3
- Crossed vector.
Param | Type | Description |
---|---|---|
p1 | Vector3 |
First vector. |
p2 | Vector3 |
Second vector. |
Vector3.parse(str) ⇒ Vector3
Parse and return a vector object from string in the form of "x,y".
Kind: static method of Vector3
Returns: Vector3
- Parsed vector.
Param | Type | Description |
---|---|---|
str | String |
String to parse. |
Vector3.fromArray(arr) ⇒ Vector3
Create vector from array of numbers.
Kind: static method of Vector3
Returns: Vector3
- Vector instance.
Param | Type | Description |
---|---|---|
arr | Array.<Number> |
Array of numbers to create vector from. |
Vector3.fromDict(data) ⇒ Vector3
Create vector from a dictionary.
Kind: static method of Vector3
Returns: Vector3
- Newly created vector.
Param | Type | Description |
---|---|---|
data | * |
Dictionary with {x,y,z}. |