xr-frame / Exports / Vector3

# Class: Vector3

# Table of contents

# Constructors

# Properties

# Accessors

# Methods

# Constructors

# constructor

new Vector3(raw?, offset?)

# Parameters

Name Type
raw? Float32Array
offset? number

# Properties

# ForwardLH

Static Readonly ForwardLH: Vector3

前方向,基于左手坐标系,不要对该对象进行修改

static

memberof Vector3


# ONE

Static Readonly ONE: Vector3

一向量,不要对该对象进行修改

readonly

static

memberof Vector3


# Phys3D

Static Optional Phys3D: typeof phys3D


# Up

Static Readonly Up: Vector3

上方向,不要对该对象进行修改

static

memberof Vector3


# ZERO

Static Readonly ZERO: Vector3

零向量,不要对该对象进行修改

readonly

static

memberof Vector3

# Accessors

# x

get x(): number

x值

memberof Vector3

# Returns

number

set x(val): void

x值

# Parameters

Name Type
val number

# Returns

void


# y

get y(): number

y值

memberof Vector3

# Returns

number

set y(val): void

y值

# Parameters

Name Type
val number

# Returns

void


# z

get z(): number

z值

memberof Vector3

# Returns

number

set z(val): void

z值

# Parameters

Name Type
val number

# Returns

void

# Methods

# abs

abs(): Vector3

# Returns

Vector3


# add

add(v, dst?): Vector3

向量加法

memberof Vector3

# Parameters

Name Type Description
v Vector3 目标向量
dst? Vector3 -

# Returns

Vector3

计算结果


# angleTo

angleTo(location, dst?): Vector3

获取到目标点的角度

memberof Vector3

# Parameters

Name Type Description
location Vector3 目标点
dst? Vector3 -

# Returns

Vector3

计算结果


# applyMatrix4

applyMatrix4(m): Vector3

create by janzen Multiplies this vector (with an implicit 1 in the 4th dimension) and m, and divides by perspective.

# Parameters

Name Type
m Matrix4

# Returns

Vector3


# applyMatrix4Raw

applyMatrix4Raw(m): Vector3

create by roamye Multiplies this vector (with an implicit 1 in the 4th dimension) and m, and divides by perspective.

# Parameters

Name Type
m Float32Array

# Returns

Vector3


# applyQuaternion

applyQuaternion(q): Vector3

# Parameters

Name Type
q Quaternion

# Returns

Vector3


# clone

clone(): Vector3

拷贝该向量

memberof Vector3

# Returns

Vector3

拷贝出来的对象


# cross

cross(v, dst?): Vector3

向量叉乘

memberof Vector3

# Parameters

Name Type Description
v Vector3 目标向量
dst? Vector3 -

# Returns

Vector3

计算结果


# distanceTo

distanceTo(p): number

获取到目标点的距离

memberof Vector3

# Parameters

Name Type Description
p Vector3 目标点

# Returns

number

计算结果


# dot

dot(v): number

向量点乘

memberof Vector3

# Parameters

Name Type Description
v Vector3 目标向量

# Returns

number

计算结果


# equal

equal(v): boolean

判断与目标向量的值是否相等

memberof Vector3

# Parameters

Name Type Description
v Vector3 目标向量

# Returns

boolean

是否相等,这里误差小于10^-6视为相等


# fromArray

fromArray(array, offset): Vector3

# Parameters

Name Type
array Float32Array
offset number

# Returns

Vector3


# fromPhysics

fromPhysics(v): Vector3

# Parameters

Name Type
v any

# Returns

Vector3


# get

get(i): number

# Parameters

Name Type
i number

# Returns

number


# isZero

isZero(): boolean

是否为零向量

memberof Vector3

# Returns

boolean


# length

length(): number

向量的模

memberof Vector3

# Returns

number

计算结果


# lerp

lerp(v, f, dst?): Vector3

在该向量与目标向量之间计算插值

memberof Vector3

# Parameters

Name Type Description
v Vector3 目标向量
f number 插值系数
dst? Vector3 -

# Returns

Vector3

计算结果


# negate

negate(): Vector3

取反

# Returns

Vector3


# normalize

normalize(dst?): Vector3

向量归一化

memberof Vector3

# Parameters

Name Type
dst? Vector3

# Returns

Vector3

计算结果


# print

print(): void

# Returns

void


# scale

scale(f, dst?): Vector3

向量缩放

memberof Vector3

# Parameters

Name Type Description
f number 缩放比
dst? Vector3 -

# Returns

Vector3

计算结果


# scaleXYZ

scaleXYZ(x, y, z, dst?): Vector3

向量缩放

memberof Vector3

# Parameters

Name Type Description
x number x缩放比
y number y缩放比
z number z缩放比
dst? Vector3 -

# Returns

Vector3

计算结果


# set

set(v): Vector3

拷贝目标向量的值到该向量

memberof Vector3

# Parameters

Name Type
v Vector3

# Returns

Vector3

自身


# setArray

setArray(value, offset?): Vector3

# Parameters

Name Type
value ArrayLike<number>
offset? number

# Returns

Vector3


# setFromArray

setFromArray(xyz): Vector3

# Parameters

Name Type
xyz number[]

# Returns

Vector3


# setFromMatrixColumn

setFromMatrixColumn(m, index): Vector3

# Parameters

Name Type
m Matrix4
index number

# Returns

Vector3


# setFromMatrixPosition

setFromMatrixPosition(worldMatrix): Vector3

create by janzen Sets this vector to the position elements of the transformation matrix

# Parameters

Name Type
worldMatrix Matrix4

# Returns

Vector3


# setFromMatrixScale

setFromMatrixScale(m): Vector3

# Parameters

Name Type
m Matrix4

# Returns

Vector3


# setValue

setValue(x, y, z): Vector3

设置向量的值

memberof Vector3

# Parameters

Name Type Description
x number x
y number y
z number z

# Returns

Vector3

自身


# sub

sub(v, dst?): Vector3

向量减法

memberof Vector3

# Parameters

Name Type Description
v Vector3 目标向量
dst? Vector3 -

# Returns

Vector3

计算结果


# toArray

toArray(): [number, number, number]

返回向量数据

memberof Vector3

# Returns

[number, number, number]

矩阵数据,以JSArray返回


# toPhysics

toPhysics(): any

created by shanexyzhou 生成物理引擎内的RawVec3f

# Returns

any


# transformDirection

transformDirection(m): Vector3

create by janzen Transforms the direction of this vector by a matrix (the upper left 3 x 3 subset of a m) and then normalizes the result.

# Parameters

Name Type
m Matrix4

# Returns

Vector3


# transformDirectionRaw

transformDirectionRaw(raw): Vector3

create by roamye Transforms the direction of this vector by a matrix (the upper left 3 x 3 subset of a m) and then normalizes the result.

# Parameters

Name Type
raw Float32Array

# Returns

Vector3


# clearPhysicsPool

Static clearPhysicsPool(): void

# Returns

void


# createFromArray

Static createFromArray(array): Vector3

使用一个数组创建 此操作会拷贝一份数组

static

memberof Vector3

# Parameters

Name Type Description
array number[] 数据源,长度必须为3,否则会抛出异常

# Returns

Vector3

创建出来的向量


# createFromNumber

Static createFromNumber(x, y, z): Vector3

使用数值创建 推荐使用这种方式代替new Vector3

static

memberof Vector3

# Parameters

Name Type Description
x number x
y number y
z number z

# Returns

Vector3

创建出来的向量


# createFromTypedArray

Static createFromTypedArray(array, offset?): Vector3

使用某个已有的typedArray创建 此操作不会拷贝数据,而是在原来的内存区域上操作

static

memberof Vector3

# Parameters

Name Type Default value Description
array Float32Array undefined 数据源
offset number 0 -

# Returns

Vector3


# fromPhysics

Static fromPhysics(v): Vector3

created by shanexyzhou 从物理引擎内的RawVec3f生成Vector3

# Parameters

Name Type
v any

# Returns

Vector3


# transformCoordinate

Static transformCoordinate(coordinate, transform, dst?): Vector3

# Parameters

Name Type
coordinate Vector3
transform Matrix4
dst? Vector3

# Returns

Vector3


# transformQuat

Static transformQuat(source, rotation, dst?): Vector3

使用四元数进行向量旋转

static

memberof Vector3

# Parameters

Name Type Description
source Vector3 源向量
rotation Quaternion 用于旋转的四元数
dst? Vector3 -

# Returns

Vector3

计算结果