For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /math/classes/Vector3Utils.md.

Class: Vector3Utils

Utilities operating on Vector3 objects. All methods are static and do not modify the input objects.

操作 Vector3 对象的工具类。所有方法都是静态的,并且不会修改输入对象。

Constructors

Constructor

new Vector3Utils(): Vector3Utils

Returns

Vector3Utils

Methods

add()

static add(v1, v2): Vector3

add

Add two vectors to produce a new vector

将两个向量相加生成一个新的向量。

Parameters

v1

Vector3

v2

Vector3

Returns

Vector3


ceil()

static ceil(v): Vector3

ceil

Ceil the components of a vector to produce a new vector

对向量的各个分量向上取整,生成一个新的向量。

Parameters

v

Vector3

Returns

Vector3


clamp()

static clamp(v, limits?): Vector3

clamp

Clamps the components of a vector to limits to produce a new vector

将向量的各个分量钳制在一定范围内,生成一个新的向量。

Parameters

v

Vector3

limits?
max?

any

min?

any

Returns

Vector3


cross()

static cross(a, b): Vector3

cross

Calculate the cross product of two vectors. Returns a new vector.

计算两个向量的叉积。返回一个新的向量。

Parameters

a

Vector3

b

Vector3

Returns

Vector3


distance()

static distance(a, b): number

distance

Calculate the distance between two vectors

计算两个向量之间的距离。

Parameters

a

Vector3

b

Vector3

Returns

number


dot()

static dot(a, b): number

dot

Calculate the dot product of two vectors

计算两个向量的点积。

Parameters

a

Vector3

b

Vector3

Returns

number


equals()

static equals(v1, v2): boolean

equals

Check the equality of two vectors

检查两个向量是否相等。

Parameters

v1

Vector3

v2

Vector3

Returns

boolean


floor()

static floor(v): Vector3

floor

Floor the components of a vector to produce a new vector

对向量的各个分量向下取整,生成一个新的向量。

Parameters

v

Vector3

Returns

Vector3


fromString()

static fromString(str, delimiter?): any

fromString

Vector3Utils.toString 产生的字符串表示中解析出 Vector3。若任一数值不是数字或格式无效,则返回 undefined。

Gets a Vector3 from the string representation produced by Vector3Utils.toString. If any numeric value is not a number or the format is invalid, undefined is returned.

Parameters

str

string

The string to parse

delimiter?

string

The delimiter used to separate the components. Defaults to the same as the default for Vector3Utils.toString

Returns

any


lerp()

static lerp(a, b, t): Vector3

lerp

Constructs a new vector using linear interpolation on each component from two vectors.

根据两个向量的每个分量进行线性插值,构建一个新的向量。

Parameters

a

Vector3

b

Vector3

t

number

Returns

Vector3


magnitude()

static magnitude(v): number

magnitude

The magnitude of a vector

返回向量的模长。

Parameters

v

Vector3

Returns

number


max()

static max(a, b): Vector3

max

Max the components of two vectors to produce a new vector

取两个向量各分量中的较大值,生成一个新的向量。

Parameters

a

Vector3

b

Vector3

Returns

Vector3


min()

static min(a, b): Vector3

min

Min the components of two vectors to produce a new vector

取两个向量各分量中的较小值,生成一个新的向量。

Parameters

a

Vector3

b

Vector3

Returns

Vector3


multiply()

static multiply(a, b): Vector3

multiply

对两个向量进行逐元素相乘。 不要与 Vector3Utils.dot 点积或 Vector3Utils.cross 叉积混淆。

Element-wise multiplication of two vectors together. Not to be confused with Vector3Utils.dot product or Vector3Utils.cross product

Parameters

a

Vector3

b

Vector3

Returns

Vector3


normalize()

static normalize(v): Vector3

normalize

Takes a vector 3 and normalizes it to a unit vector

将一个三维向量归一化为单位向量。

Parameters

v

Vector3

Returns

Vector3


rotateX()

static rotateX(v, a): Vector3

rotateX

沿 x 轴逆时针(左手法则)旋转该向量。

Rotates the vector around the x axis counterclockwise (left hand rule)

Parameters

v

Vector3

a

number

Angle in radians

Returns

Vector3


rotateY()

static rotateY(v, a): Vector3

rotateY

沿 y 轴逆时针(左手法则)旋转该向量。

Rotates the vector around the y axis counterclockwise (left hand rule)

Parameters

v

Vector3

a

number

Angle in radians

Returns

Vector3


rotateZ()

static rotateZ(v, a): Vector3

rotateZ

沿 z 轴逆时针(左手法则)旋转该向量。

Rotates the vector around the z axis counterclockwise (left hand rule)

Parameters

v

Vector3

a

number

Angle in radians

Returns

Vector3


scale()

static scale(v1, scale): Vector3

scale

Multiple all entries in a vector by a single scalar value producing a new vector

使用单一标量值乘以向量中的所有元素,生成一个新的向量。

Parameters

v1

Vector3

scale

number

Returns

Vector3


slerp()

static slerp(a, b, t): Vector3

slerp

Constructs a new vector using spherical linear interpolation on each component from two vectors.

根据两个向量的每个分量进行球面线性插值,构建一个新的向量。

Parameters

a

Vector3

b

Vector3

t

number

Returns

Vector3


subtract()

static subtract(v1, v2): Vector3

subtract

Subtract two vectors to produce a new vector (v1-v2)

将两个向量相减生成一个新的向量 (v1-v2)。

Parameters

v1

Vector3

v2

Vector3

Returns

Vector3


toString()

static toString(v, options?): string

toString

Create a string representation of a vector3

以指定的格式返回向量的字符串表示。

Parameters

v

Vector3

options?
decimals?

number

delimiter?

string

Returns

string