Home Reference Source Repository
import Vector3 from 'dh3dlib/js/base/Vector3.js'
public class | source

Vector3

3 params vector class

Constructor Summary

Public Constructor
public

constructor(x: float, y: float, z: float)

constructor

Member Summary

Public Members
public

x: *

public

y: *

public

z: *

Method Summary

Public Methods
public

add(vec1: Vector3, vec2: Vector3): void

add 2 vectors.

public

clone(): *

public

cross(vec1: Vector3, vec2: Vector3): void

public

dot(vec: Vector3): float

public

get Float32Array format of vector value

public

length(): float

calc a length of vector

public

lerp(vec1: Vector3, vec2: Vector3, rate: float): void

public

mul(vec1: Vector3, rate: float): void

public

mulAdd(vec1: Vector3, vec2: Vector3, rate: float): void

public

normalize(src: Vector3): void

public

quaternionToEuler(quat: Vector4): void

public

rotate(vec: Vector3, matrix: Matrix): void

public

setValue(x: float | Vector3, y: float, z: float): void

set vector value

public

sub(vec1: Vector3, vec2: Vector3): void

public

transform(vec: Vector3, matrix: Matrix): void

Public Constructors

public constructor(x: float, y: float, z: float) source

constructor

Params:

NameTypeAttributeDescription
x float

X value, default is 0.0

y float

Y value, default is 0.0

z float

Z value, default is 0.0

Public Members

public x: * source

public y: * source

public z: * source

Public Methods

public add(vec1: Vector3, vec2: Vector3): void source

add 2 vectors. result is set to this matrix.

Params:

NameTypeAttributeDescription
vec1 Vector3
vec2 Vector3

Return:

void

public clone(): * source

Return:

*

public cross(vec1: Vector3, vec2: Vector3): void source

Params:

NameTypeAttributeDescription
vec1 Vector3
vec2 Vector3

Return:

void

public dot(vec: Vector3): float source

Params:

NameTypeAttributeDescription
vec Vector3

Return:

float

result of dot

public getWebGLFloatArray(): Float32Array source

get Float32Array format of vector value

Return:

Float32Array

vector value

public length(): float source

calc a length of vector

Return:

float

length of vector

public lerp(vec1: Vector3, vec2: Vector3, rate: float): void source

Params:

NameTypeAttributeDescription
vec1 Vector3
vec2 Vector3
rate float

Return:

void

public mul(vec1: Vector3, rate: float): void source

Params:

NameTypeAttributeDescription
vec1 Vector3
rate float

Return:

void

public mulAdd(vec1: Vector3, vec2: Vector3, rate: float): void source

Params:

NameTypeAttributeDescription
vec1 Vector3
vec2 Vector3
rate float

Return:

void

public normalize(src: Vector3): void source

Params:

NameTypeAttributeDescription
src Vector3

optional

Return:

void

public quaternionToEuler(quat: Vector4): void source

Params:

NameTypeAttributeDescription
quat Vector4

Return:

void

public rotate(vec: Vector3, matrix: Matrix): void source

Params:

NameTypeAttributeDescription
vec Vector3
matrix Matrix

Return:

void

public setValue(x: float | Vector3, y: float, z: float): void source

set vector value

Params:

NameTypeAttributeDescription
x float | Vector3

x value, or Vector3 object to copy. if first param is Vector3, second/third params are ignored.

y float

y value, default is 0.0

z float

z value, default is 0.0

Return:

void

Example:

var v1 = new Vector3(1.0, 2.0, 3.0)
var v2 = new Vector3()
var v2.setValue(v1)
// v2 is {x:1.0, y:2.0, z:3.0}

public sub(vec1: Vector3, vec2: Vector3): void source

Params:

NameTypeAttributeDescription
vec1 Vector3
vec2 Vector3

Return:

void

public transform(vec: Vector3, matrix: Matrix): void source

Params:

NameTypeAttributeDescription
vec Vector3
matrix Matrix

Return:

void