ObservableVector3d
class ObservableVector3d extends Vector3d
A Vector3d object that provide notification by executing the given callback when the vector is changed.
Constructor
new ObservableVector3d(x: number, y: number, z: number, settings: object) → {}
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number | 0 |
x value of the vector |
|
y | number | 0 |
y value of the vector |
|
z | number | 0 |
z value of the vector |
|
settings | object |
additional required parameters |
||
settings.onUpdate | Function |
the callback to be executed when the vector is changed |
||
settings.scope | object |
<optional> |
the value to use as this when calling onUpdate |
Summary
Methods from ObservableVector3d
Methods inherited from Vector3d
Public Properties
Public Methods
abs() → {ObservableVector3d}
Update this vector values to absolute values
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
add(v: Vector2d | Vector3d | ObservableVector2d | ObservableVector3d) → {ObservableVector3d}
Add the passed vector to this vector
Name | Type | Description |
---|---|---|
v | Vector2d | Vector3d | ObservableVector2d | ObservableVector3d |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
ceil() → {ObservableVector3d}
Ceil the vector values
Type | Description |
---|---|
ObservableVector3d |
new me.ObservableVector3d |
ceilSelf() → {ObservableVector3d}
Ceil this vector values
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
clamp(low: number, high: number) → {ObservableVector3d}
Clamp the vector value within the specified value range
Name | Type | Description |
---|---|---|
low | number | |
high | number |
Type | Description |
---|---|
ObservableVector3d |
new me.ObservableVector3d |
clampSelf(low: number, high: number) → {ObservableVector3d}
Clamp this vector value within the specified value range
Name | Type | Description |
---|---|---|
low | number | |
high | number |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
clone() → {ObservableVector3d}
return a clone copy of this vector
Type | Description |
---|---|
ObservableVector3d |
new me.ObservableVector3d |
copy(v: Vector2d | Vector3d | ObservableVector2d | ObservableVector3d) → {ObservableVector3d}
Copy the components of the given vector into this one
Name | Type | Description |
---|---|---|
v | Vector2d | Vector3d | ObservableVector2d | ObservableVector3d |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
cross(v: Vector3d | ObservableVector3d) → {ObservableVector3d}
calculate the cross product of this vector and the passed one
Name | Type | Description |
---|---|---|
v | Vector3d | ObservableVector3d |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
distance(v: Vector2d | Vector3d | ObservableVector2d | ObservableVector3d) → {number}
return the distance between this vector and the passed one
Name | Type | Description |
---|---|---|
v | Vector2d | Vector3d | ObservableVector2d | ObservableVector3d |
Type | Description |
---|---|
number |
div(n: number) → {ObservableVector3d}
Divide this vector values by the passed value
Name | Type | Description |
---|---|---|
n | number |
the value to divide the vector by |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
dot(v: Vector2d | Vector3d | ObservableVector2d | ObservableVector3d) → {number}
return the dot product of this vector and the passed one
Name | Type | Description |
---|---|---|
v | Vector2d | Vector3d | ObservableVector2d | ObservableVector3d |
Type | Description |
---|---|
number |
The dot product. |
equals(v: Vector2d | Vector3d | ObservableVector2d | ObservableVector3d) → {boolean}
return true if the two vectors are the same
Name | Type | Description |
---|---|---|
v | Vector2d | Vector3d | ObservableVector2d | ObservableVector3d |
Type | Description |
---|---|
boolean |
floor() → {ObservableVector3d}
Floor the vector values
Type | Description |
---|---|
ObservableVector3d |
new me.ObservableVector3d |
floorSelf() → {ObservableVector3d}
Floor this vector values
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
lerp(v: Vector3d | ObservableVector3d, alpha: number) → {ObservableVector3d}
Linearly interpolate between this vector and the given one.
Name | Type | Description |
---|---|---|
v | Vector3d | ObservableVector3d | |
alpha | number |
distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one). |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
maxV(v: Vector2d | Vector3d | ObservableVector2d | ObservableVector3d) → {ObservableVector3d}
Update this vector with the maximum value between this and the passed vector
Name | Type | Description |
---|---|---|
v | Vector2d | Vector3d | ObservableVector2d | ObservableVector3d |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
minV(v: Vector2d | Vector3d | ObservableVector2d | ObservableVector3d) → {ObservableVector3d}
Update this vector with the minimum value between this and the passed vector
Name | Type | Description |
---|---|---|
v | Vector2d | Vector3d | ObservableVector2d | ObservableVector3d |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
moveTowards(target: Vector2d | ObservableVector2d | Vector3d | ObservableVector3d, step: number) → {ObservableVector3d}
interpolate the position of this vector on the x and y axis towards the given one while ensure that the distance never exceeds the given step.
Name | Type | Description |
---|---|---|
target | Vector2d | ObservableVector2d | Vector3d | ObservableVector3d | |
step | number |
the maximum step per iteration (Negative values will push the vector away from the target) |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
negate() → {ObservableVector3d}
Negate the vector values
Type | Description |
---|---|
ObservableVector3d |
new me.ObservableVector3d |
negateSelf() → {ObservableVector3d}
Negate this vector values
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
perp() → {ObservableVector3d}
change this vector to be perpendicular to what it was before.
(Effectively rotates it 90 degrees in a clockwise direction)
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
rotate(angle: number, v: Vector2d | ObservableVector2d) → {ObservableVector3d}
Rotate this vector (counter-clockwise) by the specified angle (in radians).
Name | Type | Attributes | Description |
---|---|---|---|
angle | number |
The angle to rotate (in radians) |
|
v | Vector2d | ObservableVector2d |
<optional> |
an optional point to rotate around (on the same z axis) |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
scale(x: number, y: number, z: number) → {ObservableVector3d}
Multiply this vector values by the given scalar
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number | |||
y | number |
<optional> |
x | |
z | number |
<optional> |
1 |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
scaleV(v: Vector2d | Vector3d | ObservableVector2d | ObservableVector3d) → {ObservableVector3d}
Multiply this vector values by the passed vector
Name | Type | Description |
---|---|---|
v | Vector2d | Vector3d | ObservableVector2d | ObservableVector3d |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
setCallback(fn: Function, scope: Function) → {ObservableVector3d}
set the callback to be executed when the vector is changed
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
fn | Function |
callback |
||
scope | Function |
<optional> |
null |
scope |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
setMuted(x: number, y: number, z: number) → {ObservableVector3d}
set the vector value without triggering the callback
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
x | number |
x value of the vector |
||
y | number |
y value of the vector |
||
z | number |
<optional> |
0 |
z value of the vector |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
sub(v: Vector2d | Vector3d | ObservableVector2d | ObservableVector3d) → {ObservableVector3d}
Substract the passed vector to this vector
Name | Type | Description |
---|---|---|
v | Vector2d | Vector3d | ObservableVector2d | ObservableVector3d |
Type | Description |
---|---|
ObservableVector3d |
Reference to this object for method chaining |
toString() → {string}
convert the object to a string representation
Type | Description |
---|---|
string |
toVector3d() → {Vector3d}
return a me.Vector3d
copy of this me.ObservableVector3d
object
Type | Description |
---|---|
Vector3d |
new me.Vector3d |