Skip to content

Documentation / base / ObservableVector3

Class: ObservableVector3 ​

Defined in: libs/base/src/math/vector.ts:1079

Observable 3 dimentional vector

Extends ​

Indexable ​

[index: number]: number

Constructors ​

Constructor ​

new ObservableVector3(x, y, z): ObservableVector3

Defined in: libs/base/src/math/vector.ts:604

Creates a new Vector3 initialized with values.

Parameters ​

x ​

number

The x component.

y ​

number

The y component.

z ​

number

The z component.

Returns ​

ObservableVector3

Inherited from ​

Vector3.constructor

Constructor ​

new ObservableVector3(elements): ObservableVector3

Defined in: libs/base/src/math/vector.ts:609

Creates a new Vector3 initialized with values in an array.

Parameters ​

elements ​

number[]

Array that contains the x, y, z values.

Returns ​

ObservableVector3

Inherited from ​

Vector3.constructor

Constructor ​

new ObservableVector3(array): ObservableVector3

Defined in: libs/base/src/math/vector.ts:614

Creates a new Vector3 initialized with values in a Float32Array.

Parameters ​

array ​

Float32Array<ArrayBuffer>

Float32Array object that contains the x, y, z values.

Returns ​

ObservableVector3

Inherited from ​

Vector3.constructor

Constructor ​

new ObservableVector3(buffer, offset): ObservableVector3

Defined in: libs/base/src/math/vector.ts:620

Creates a new Vector3 placed on a given ArrayBuffer object.

Parameters ​

buffer ​

ArrayBuffer

The array buffer object.

offset ​

number

The byte offset of the buffer where the vector placed at.

Returns ​

ObservableVector3

Inherited from ​

Vector3.constructor

Constructor ​

new ObservableVector3(): ObservableVector3

Defined in: libs/base/src/math/vector.ts:624

Creates a new Vector3 filled with zero values.

Returns ​

ObservableVector3

Inherited from ​

Vector3.constructor

Accessors ​

magnitude ​

Get Signature ​

get magnitude(): number

Defined in: libs/base/src/math/vector.ts:676

Get the length of the vector.

Returns ​

number

Inherited from ​

Vector3.magnitude


magnitudeSq ​

Get Signature ​

get magnitudeSq(): number

Defined in: libs/base/src/math/vector.ts:680

Get the squared length of the vector.

Returns ​

number

Inherited from ​

Vector3.magnitudeSq


callback ​

Get Signature ​

get callback(): () => void

Defined in: libs/base/src/math/vector.ts:1083

The callback function which will be executed when the value changed

Returns ​

() => void

Set Signature ​

set callback(cb): void

Defined in: libs/base/src/math/vector.ts:1086

Parameters ​
cb ​

() => void

Returns ​

void


x ​

Get Signature ​

get x(): number

Defined in: libs/base/src/math/vector.ts:1097

Get the x component value.

Returns ​

number

Set Signature ​

set x(val): void

Defined in: libs/base/src/math/vector.ts:1100

Get the x component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Vector3.x


y ​

Get Signature ​

get y(): number

Defined in: libs/base/src/math/vector.ts:1110

Get the y component value.

Returns ​

number

Set Signature ​

set y(val): void

Defined in: libs/base/src/math/vector.ts:1113

Get the y component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Vector3.y


z ​

Get Signature ​

get z(): number

Defined in: libs/base/src/math/vector.ts:1123

Get the z component value.

Returns ​

number

Set Signature ​

set z(val): void

Defined in: libs/base/src/math/vector.ts:1126

Get the z component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Vector3.z

Methods ​

equalsTo() ​

equalsTo(other, epsl?): boolean

Defined in: libs/base/src/math/vector.ts:32

Check if all data is close enough to another

Parameters ​

other ​

Float32Array<ArrayBuffer>

The data to be compared with.

epsl? ​

number

Returns ​

boolean

true if close enough, otherwise false.

Inherited from ​

Vector3.equalsTo


toString() ​

toString(): string

Defined in: libs/base/src/math/vector.ts:52

Convert this to string object.

Returns ​

string

Inherited from ​

Vector3.toString


isNaN() ​

isNaN(): boolean

Defined in: libs/base/src/math/vector.ts:61

Check the data for the presence of NaN.

Returns ​

boolean

true if NaN is present, otherwise false.

Inherited from ​

Vector3.isNaN


setRandom() ​

setRandom(minValue, maxValue): void

Defined in: libs/base/src/math/vector.ts:75

Generate random vector

Parameters ​

minValue ​

number

Minimum value of any component of the vector

maxValue ​

number

Maximum value of any component of the vector

Returns ​

void

Inherited from ​

Vector3.setRandom


clone() ​

clone(): Vector3

Defined in: libs/base/src/math/vector.ts:651

Creates a new Vector3 initialized with values from this vector.

Returns ​

Vector3

The new vector.

Inherited from ​

Vector3.clone


xy() ​

xy(): Vector2

Defined in: libs/base/src/math/vector.ts:687

Creates a new Vector2 initialized with x, y component of this vector.

Returns ​

Vector2

The new vector

Inherited from ​

Vector3.xy


setAndNormalize() ​

setAndNormalize(x, y, z): ObservableVector3

Defined in: libs/base/src/math/vector.ts:710

Set component values and then normalize the vector.

Parameters ​

x ​

number

The x component value.

y ​

number

The y component value.

z ​

number

The z component value.

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.setAndNormalize


subBy() ​

subBy(other): ObservableVector3

Defined in: libs/base/src/math/vector.ts:719

Subtract a vector from this vector.

Parameters ​

other ​

Vector3

The vector that will be subtract.

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.subBy


addBy() ​

addBy(other): ObservableVector3

Defined in: libs/base/src/math/vector.ts:728

Add a vector to this vector.

Parameters ​

other ​

Vector3

The vector that will be added.

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.addBy


combineBy() ​

combineBy(other, t0, t1): ObservableVector3

Defined in: libs/base/src/math/vector.ts:739

Combine a vector to this vector.

Parameters ​

other ​

Vector3

The vector that will be added.

t0 ​

number

Scale factor for this vector

t1 ​

number

Scale factor for other vector

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.combineBy


mulBy() ​

mulBy(other): ObservableVector3

Defined in: libs/base/src/math/vector.ts:748

Multiply this vector by a vector.

Parameters ​

other ​

Vector3

The vector that will be multiplied by.

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.mulBy


divBy() ​

divBy(other): ObservableVector3

Defined in: libs/base/src/math/vector.ts:757

Divide this vector by a vector.

Parameters ​

other ​

Vector3

The vector that will be divide by.

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.divBy


scaleBy() ​

scaleBy(f): ObservableVector3

Defined in: libs/base/src/math/vector.ts:766

Scale this vector by a scalar number.

Parameters ​

f ​

number

amount to scale this vector by.

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.scaleBy


inplaceNormalize() ​

inplaceNormalize(): ObservableVector3

Defined in: libs/base/src/math/vector.ts:774

Normalize this vector inplace.

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.inplaceNormalize


inplaceInverse() ​

inplaceInverse(): ObservableVector3

Defined in: libs/base/src/math/vector.ts:782

Inverse this vector inplace.

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.inplaceInverse


inplaceMin() ​

inplaceMin(other): ObservableVector3

Defined in: libs/base/src/math/vector.ts:791

Set the component values to the minimum of this vector and another vector.

Parameters ​

other ​

Vector3

The vector that to be compared with.

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.inplaceMin


inplaceMax() ​

inplaceMax(other): ObservableVector3

Defined in: libs/base/src/math/vector.ts:800

Set the component values to the maximum of this vector and another vector.

Parameters ​

other ​

Vector3

The vector that to be compared with.

Returns ​

ObservableVector3

self

Inherited from ​

Vector3.inplaceMax


zero() ​

static zero(): Vector3

Defined in: libs/base/src/math/vector.ts:808

Creates a new Vector3 initialized with zero values.

Returns ​

Vector3

The new vector

Inherited from ​

Vector3.zero


one() ​

static one(): Vector3

Defined in: libs/base/src/math/vector.ts:815

Creates a new Vector3 initialized with one.

Returns ​

Vector3

The new vector

Inherited from ​

Vector3.one


axisPX() ​

static axisPX(): Vector3

Defined in: libs/base/src/math/vector.ts:822

Creates a new Vector3 pointing in the positive direction of the X axis, i.e. vec3(1, 0, 0)

Returns ​

Vector3

The new vector

Inherited from ​

Vector3.axisPX


axisNX() ​

static axisNX(): Vector3

Defined in: libs/base/src/math/vector.ts:829

Creates a new Vector3 pointing in the negative direction of the X axis, i.e. vec3(-1, 0, 0)

Returns ​

Vector3

The new vector

Inherited from ​

Vector3.axisNX


axisPY() ​

static axisPY(): Vector3

Defined in: libs/base/src/math/vector.ts:836

Creates a new Vector3 pointing in the positive direction of the Y axis, i.e. vec3(0, 1, 0)

Returns ​

Vector3

The new vector

Inherited from ​

Vector3.axisPY


axisNY() ​

static axisNY(): Vector3

Defined in: libs/base/src/math/vector.ts:843

Creates a new Vector3 pointing in the negative direction of the Y axis, i.e. vec3(0, -1, 0)

Returns ​

Vector3

The new vector

Inherited from ​

Vector3.axisNY


axisPZ() ​

static axisPZ(): Vector3

Defined in: libs/base/src/math/vector.ts:850

Creates a new Vector3 pointing in the positive direction of the Z axis, i.e. vec3(0, 0, 1)

Returns ​

Vector3

The new vector

Inherited from ​

Vector3.axisPZ


axisNZ() ​

static axisNZ(): Vector3

Defined in: libs/base/src/math/vector.ts:857

Creates a new Vector2 pointing in the negative direction of the Z axis, i.e. vec3(0, 0, -1)

Returns ​

Vector3

The new vector

Inherited from ​

Vector3.axisNZ


distance() ​

static distance(v1, v2): number

Defined in: libs/base/src/math/vector.ts:866

Calculates the distance between two Vector3's.

Parameters ​

v1 ​

Vector3

The first vector.

v2 ​

Vector3

The second vector.

Returns ​

number

distance between v1 and v2

Inherited from ​

Vector3.distance


distanceSq() ​

static distanceSq(v1, v2): number

Defined in: libs/base/src/math/vector.ts:875

Calculates the squared distance between two Vector3's.

Parameters ​

v1 ​

Vector3

The first vector.

v2 ​

Vector3

The second vector.

Returns ​

number

squared distance between v1 and v2

Inherited from ​

Vector3.distanceSq


normalize() ​

static normalize(v, result?): Vector3

Defined in: libs/base/src/math/vector.ts:887

Normalize a Vector3

Parameters ​

v ​

Vector3

The input vector

result? ​

Vector3

The output vector (can be the same vector as v). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.normalize


inverse() ​

static inverse(v, result?): Vector3

Defined in: libs/base/src/math/vector.ts:900

Inverse a Vector3

Parameters ​

v ​

Vector3

The input vector

result? ​

Vector3

The output vector (can be the same vector as v). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.inverse


sub() ​

static sub(a, b, result?): Vector3

Defined in: libs/base/src/math/vector.ts:913

Subtract two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

result? ​

Vector3

The output vector (can be the same vector as a or b). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.sub


add() ​

static add(a, b, result?): Vector3

Defined in: libs/base/src/math/vector.ts:926

Add two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

result? ​

Vector3

The output vector (can be the same vector as a or b). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.add


combine() ​

static combine(a, b, t0, t1, result?): Vector3

Defined in: libs/base/src/math/vector.ts:941

Combine two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

t0 ​

number

Scale factor for the first operand

t1 ​

number

Scale factor for the second operand

result? ​

Vector3

The output vector (can be the same vector as a or b). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.combine


lerp() ​

static lerp(a, b, t, result?): Vector3

Defined in: libs/base/src/math/vector.ts:955

Linearly interpolate between two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

t ​

number

The interpolation factor. The result is equal to a when t = 0 and equal to b when t = 1.

result? ​

Vector3

The output vector (can be the same vector as a or b). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.lerp


mul() ​

static mul(a, b, result?): Vector3

Defined in: libs/base/src/math/vector.ts:968

Multiply two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

result? ​

Vector3

The output vector (can be the same vector as a or b). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.mul


div() ​

static div(a, b, result?): Vector3

Defined in: libs/base/src/math/vector.ts:981

Divide two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

result? ​

Vector3

The output vector (can be the same vector as a or b). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.div


scale() ​

static scale(a, b, result?): Vector3

Defined in: libs/base/src/math/vector.ts:994

Scale a Vector3 by a scalar number.

Parameters ​

a ​

Vector3

The vector to be scaled.

b ​

number

The scalar number.

result? ​

Vector3

The output vector (can be the same vector as a). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.scale


min() ​

static min(a, b, result?): Vector3

Defined in: libs/base/src/math/vector.ts:1007

Calculates the minimum of two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

result? ​

Vector3

The output vector (can be the same vector as a or b). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.min


max() ​

static max(a, b, result?): Vector3

Defined in: libs/base/src/math/vector.ts:1020

Calculates the maximum of two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

result? ​

Vector3

The output vector (can be the same vector as a or b). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.max


abs() ​

static abs(a, result?): Vector3

Defined in: libs/base/src/math/vector.ts:1032

Calculates the absolute values of a Vector3.

Parameters ​

a ​

Vector3

The input vector.

result? ​

Vector3

The output vector (can be the same vector as a or b). if not specified, a new vector will be created.

Returns ​

Vector3

The output vector

Inherited from ​

Vector3.abs


dot() ​

static dot(a, b): number

Defined in: libs/base/src/math/vector.ts:1044

Calculates the dot product of two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

Returns ​

number

dot product of a and b

Inherited from ​

Vector3.dot


cross() ​

static cross(a, b, result?): Vector3

Defined in: libs/base/src/math/vector.ts:1053

Calculates the cross product of two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

result? ​

Vector3

Returns ​

Vector3

the cross product of the two vectors.

Inherited from ​

Vector3.cross


angleBetween() ​

static angleBetween(a, b): number

Defined in: libs/base/src/math/vector.ts:1065

Calculates the angle between two Vector3's.

Parameters ​

a ​

Vector3

The first operand.

b ​

Vector3

The second operand.

Returns ​

number

the angle between the two vectors in radians

Inherited from ​

Vector3.angleBetween


setCallback() ​

setCallback(cb): ObservableVector3

Defined in: libs/base/src/math/vector.ts:1090

Set callback

Parameters ​

cb ​

() => void

Returns ​

ObservableVector3


setXYZ() ​

setXYZ(x, y, z): ObservableVector3

Defined in: libs/base/src/math/vector.ts:1136

Set component values.

Parameters ​

x ​

number

The x component value.

y ​

number

The y component value.

z ​

number

The z component value.

Returns ​

ObservableVector3

self

Overrides ​

Vector3.setXYZ


copyWithin() ​

copyWithin(target, start, end?): ObservableVector3

Defined in: libs/base/src/math/vector.ts:1149

Inherited from Float32Array.copyWithin

Parameters ​

target ​

number

start ​

number

end? ​

number

Returns ​

ObservableVector3

Overrides ​

Vector3.copyWithin


fill() ​

fill(value, start?, end?): ObservableVector3

Defined in: libs/base/src/math/vector.ts:1157

Inherited from Float32Array.fill

Parameters ​

value ​

number

start? ​

number

end? ​

number

Returns ​

ObservableVector3

Overrides ​

Vector3.fill


reverse() ​

reverse(): ObservableVector3

Defined in: libs/base/src/math/vector.ts:1165

Inherited from Float32Array.reverse

Returns ​

ObservableVector3

Overrides ​

Vector3.reverse


set() ​

set(array, offset?): void

Defined in: libs/base/src/math/vector.ts:1173

Inherited from Float32Array.set

Parameters ​

array ​

ArrayLike<number>

offset? ​

number

Returns ​

void

Overrides ​

Vector3.set


sort() ​

sort(compareFn?): ObservableVector3

Defined in: libs/base/src/math/vector.ts:1180

Inherited from Float32Array.sort

Parameters ​

compareFn? ​

(a, b) => number

Returns ​

ObservableVector3

Overrides ​

Vector3.sort

Released under the MIT License.