Skip to content

Documentation / base / ObservableVector4

Class: ObservableVector4 ​

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

Observable 4 dimentional vector

Extends ​

Indexable ​

[index: number]: number

Constructors ​

Constructor ​

new ObservableVector4(x, y, z, w): ObservableVector4

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

Creates a new Vector4 initialized with values.

Parameters ​

x ​

number

The x component.

y ​

number

The y component.

z ​

number

The z component.

w ​

number

The w component.

Returns ​

ObservableVector4

Inherited from ​

Vector4.constructor

Constructor ​

new ObservableVector4(elements): ObservableVector4

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

Creates a new Vector4 initialized with values in an array.

Parameters ​

elements ​

number[]

Array that contains the x, y, z, w values.

Returns ​

ObservableVector4

Inherited from ​

Vector4.constructor

Constructor ​

new ObservableVector4(array): ObservableVector4

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

Creates a new Vector4 initialized with values in a Float32Array.

Parameters ​

array ​

Float32Array

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

Returns ​

ObservableVector4

Inherited from ​

Vector4.constructor

Constructor ​

new ObservableVector4(buffer, offset): ObservableVector4

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

Creates a new Vector4 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 ​

ObservableVector4

Inherited from ​

Vector4.constructor

Constructor ​

new ObservableVector4(): ObservableVector4

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

Creates a new Vector4 filled with zero values.

Returns ​

ObservableVector4

Inherited from ​

Vector4.constructor

Accessors ​

magnitude ​

Get Signature ​

get magnitude(): number

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

Get the length of the vector.

Returns ​

number

Inherited from ​

Vector4.magnitude


magnitudeSq ​

Get Signature ​

get magnitudeSq(): number

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

Get the squared length of the vector.

Returns ​

number

Inherited from ​

Vector4.magnitudeSq


callback ​

Get Signature ​

get callback(): () => void

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

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:1684

Parameters ​
cb ​

() => void

Returns ​

void


x ​

Get Signature ​

get x(): number

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

Get the x component value.

Returns ​

number

Set Signature ​

set x(val): void

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

Get the x component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Vector4.x


y ​

Get Signature ​

get y(): number

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

Get the y component value.

Returns ​

number

Set Signature ​

set y(val): void

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

Get the y component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Vector4.y


z ​

Get Signature ​

get z(): number

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

Get the z component value.

Returns ​

number

Set Signature ​

set z(val): void

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

Get the z component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Vector4.z


w ​

Get Signature ​

get w(): number

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

Get the w component value.

Returns ​

number

Set Signature ​

set w(val): void

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

Get the w component value.

Parameters ​
val ​

number

Returns ​

void

Overrides ​

Vector4.w

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 ​

Vector4.equalsTo


toString() ​

toString(): string

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

Convert this to string object.

Returns ​

string

Inherited from ​

Vector4.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 ​

Vector4.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 ​

Vector4.setRandom


clone() ​

clone(): Vector4

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

Creates a new Vector4 initialized with values from this vector.

Returns ​

Vector4

The new vector.

Inherited from ​

Vector4.clone


xy() ​

xy(): Vector2

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

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

Returns ​

Vector2

The new vector

Inherited from ​

Vector4.xy


xyz() ​

xyz(): Vector3

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

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

Returns ​

Vector3

The new vector

Inherited from ​

Vector4.xyz


setAndNormalize() ​

setAndNormalize(x, y, z, w): ObservableVector4

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

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.

w ​

number

The w component value.

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.setAndNormalize


subBy() ​

subBy(other): ObservableVector4

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

Subtract a vector from this vector.

Parameters ​

other ​

Vector4

The vector that will be subtract.

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.subBy


addBy() ​

addBy(other): ObservableVector4

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

Add a vector to this vector.

Parameters ​

other ​

Vector4

The vector that will be added.

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.addBy


combineBy() ​

combineBy(other, t0, t1): ObservableVector4

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

Combine a vector to this vector.

Parameters ​

other ​

Vector4

The vector that will be added.

t0 ​

number

Scale factor for this vector

t1 ​

number

Scale factor for other vector

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.combineBy


mulBy() ​

mulBy(other): ObservableVector4

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

Multiply this vector by a vector.

Parameters ​

other ​

Vector4

The vector that will be multiplied by.

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.mulBy


divBy() ​

divBy(other): ObservableVector4

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

Divide this vector by a vector.

Parameters ​

other ​

Vector4

The vector that will be divide by.

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.divBy


scaleBy() ​

scaleBy(f): ObservableVector4

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

Scale this vector by a scalar number.

Parameters ​

f ​

number

amount to scale this vector by.

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.scaleBy


inplaceNormalize() ​

inplaceNormalize(): ObservableVector4

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

Normalize this vector inplace.

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.inplaceNormalize


inplaceInverse() ​

inplaceInverse(): ObservableVector4

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

Inverse this vector inplace.

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.inplaceInverse


inplaceMin() ​

inplaceMin(other): ObservableVector4

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

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

Parameters ​

other ​

Vector4

The vector that to be compared with.

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.inplaceMin


inplaceMax() ​

inplaceMax(other): ObservableVector4

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

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

Parameters ​

other ​

Vector4

The vector that to be compared with.

Returns ​

ObservableVector4

self

Inherited from ​

Vector4.inplaceMax


zero() ​

static zero(): Vector4

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

Creates a new Vector4 initialized with zero values.

Returns ​

Vector4

The new vector

Inherited from ​

Vector4.zero


one() ​

static one(): Vector4

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

Creates a new Vector4 initialized with one.

Returns ​

Vector4

The new vector

Inherited from ​

Vector4.one


axisPX() ​

static axisPX(): Vector4

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

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

Returns ​

Vector4

The new vector

Inherited from ​

Vector4.axisPX


axisNX() ​

static axisNX(): Vector4

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

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

Returns ​

Vector4

The new vector

Inherited from ​

Vector4.axisNX


axisPY() ​

static axisPY(): Vector4

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

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

Returns ​

Vector4

The new vector

Inherited from ​

Vector4.axisPY


axisNY() ​

static axisNY(): Vector4

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

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

Returns ​

Vector4

The new vector

Inherited from ​

Vector4.axisNY


axisPZ() ​

static axisPZ(): Vector4

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

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

Returns ​

Vector4

The new vector

Inherited from ​

Vector4.axisPZ


axisNZ() ​

static axisNZ(): Vector4

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

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

Returns ​

Vector4

The new vector

Inherited from ​

Vector4.axisNZ


axisPW() ​

static axisPW(): Vector4

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

Creates a new Vector4 pointing in the positive direction of the W axis, i.e. vec4(0, 0, 0, 1)

Returns ​

Vector4

The new vector

Inherited from ​

Vector4.axisPW


axisNW() ​

static axisNW(): Vector4

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

Creates a new Vector4 pointing in the negative direction of the W axis, i.e. vec4(0, 0, 0, -1)

Returns ​

Vector4

The new vector

Inherited from ​

Vector4.axisNW


normalize() ​

static normalize(v, result?): Vector4

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

Normalize a Vector4

Parameters ​

v ​

Vector4

The input vector

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.normalize


inverse() ​

static inverse(v, result?): Vector4

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

Inverse a Vector4

Parameters ​

v ​

Vector4

The input vector

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.inverse


sub() ​

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

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

Subtract two Vector4's.

Parameters ​

a ​

Vector4

The first operand.

b ​

Vector4

The second operand.

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.sub


add() ​

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

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

Add two Vector4's.

Parameters ​

a ​

Vector4

The first operand.

b ​

Vector4

The second operand.

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.add


combine() ​

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

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

Combine two Vector4's.

Parameters ​

a ​

Vector4

The first operand.

b ​

Vector4

The second operand.

t0 ​

number

Scale factor for the first operand

t1 ​

number

Scale factor for the second operand

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.combine


lerp() ​

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

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

Linearly interpolate between two Vector4's.

Parameters ​

a ​

Vector4

The first operand.

b ​

Vector4

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? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.lerp


mul() ​

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

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

Multiply two Vector4's.

Parameters ​

a ​

Vector4

The first operand.

b ​

Vector4

The second operand.

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.mul


div() ​

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

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

Divide two Vector4's.

Parameters ​

a ​

Vector4

The first operand.

b ​

Vector4

The second operand.

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.div


scale() ​

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

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

Scale a Vector4 by a scalar number.

Parameters ​

a ​

Vector4

The vector to be scaled.

b ​

number

The scalar number.

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.scale


min() ​

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

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

Calculates the minimum of two Vector4's.

Parameters ​

a ​

Vector4

The first operand.

b ​

Vector4

The second operand.

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.min


max() ​

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

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

Calculates the maximum of two Vector4's.

Parameters ​

a ​

Vector4

The first operand.

b ​

Vector4

The second operand.

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.max


abs() ​

static abs(a, result?): Vector4

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

Calculates the absolute values of a Vector4.

Parameters ​

a ​

Vector4

The input vector.

result? ​

Vector4

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

Returns ​

Vector4

The output vector

Inherited from ​

Vector4.abs


dot() ​

static dot(a, b): number

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

Calculates the dot product of two Vector4's.

Parameters ​

a ​

Vector4

The first operand.

b ​

Vector4

The second operand.

Returns ​

number

dot product of a and b

Inherited from ​

Vector4.dot


setCallback() ​

setCallback(cb): ObservableVector4

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

Set callback

Parameters ​

cb ​

() => void

Returns ​

ObservableVector4


setXYZW() ​

setXYZW(x, y, z, w): ObservableVector4

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

Set component values.

Parameters ​

x ​

number

The x component value.

y ​

number

The y component value.

z ​

number

The z component value.

w ​

number

The w component value.

Returns ​

ObservableVector4

self

Overrides ​

Vector4.setXYZW


copyWithin() ​

copyWithin(target, start, end?): ObservableVector4

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

Inherited from Float32Array.copyWithin

Parameters ​

target ​

number

start ​

number

end? ​

number

Returns ​

ObservableVector4

Overrides ​

Vector4.copyWithin


fill() ​

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

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

Inherited from Float32Array.fill

Parameters ​

value ​

number

start? ​

number

end? ​

number

Returns ​

ObservableVector4

Overrides ​

Vector4.fill


reverse() ​

reverse(): ObservableVector4

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

Inherited from Float32Array.reverse

Returns ​

ObservableVector4

Overrides ​

Vector4.reverse


set() ​

set(array, offset?): void

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

Inherited from Float32Array.set

Parameters ​

array ​

ArrayLike<number>

offset? ​

number

Returns ​

void

Overrides ​

Vector4.set


sort() ​

sort(compareFn?): ObservableVector4

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

Inherited from Float32Array.sort

Parameters ​

compareFn? ​

(a, b) => number

Returns ​

ObservableVector4

Overrides ​

Vector4.sort

Released under the MIT License.