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/Vector2Builder.md.

Class: Vector2Builder

Vector2 wrapper class which can be used as a Vector2 for APIs on @minecraft/server which require a Vector2.

用于 @minecraft/server 中需要用到 Vector2 的 API 的 Vector2 包装类。

Implements

  • unknown

Constructors

Constructor

new Vector2Builder(vecStr, delim?): Vector2Builder

Parameters

vecStr

string

delim?

string

Returns

Vector2Builder

Constructor

new Vector2Builder(vec, arg?): Vector2Builder

Parameters

vec

Vector2

arg?

undefined

Returns

Vector2Builder

Constructor

new Vector2Builder(x, y): Vector2Builder

Parameters

x

number

y

number

Returns

Vector2Builder

Properties

x

x: number


y

y: number

Methods

add()

add(v): this

add

将向量 v 加到本向量上,返回自身。

Adds the vector v to this, returning itself.

Parameters

v

Vector2

Returns

this


assign()

assign(vec): this

将传入向量的各分量值赋值给本向量,返回自身。

Assigns the values of the passed in vector to this vector. Returns itself.

Parameters

vec

Vector2

Returns

this


clamp()

clamp(limits): this

clamp

将向量的各分量限制在指定的上下限范围内,返回自身。

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

Parameters

limits
max?

any

min?

any

Returns

this


distance()

distance(vec): number

distance

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

Calculate the distance between two vectors

Parameters

vec

Vector2

Returns

number


dot()

dot(vec): number

dot

计算本向量与传入向量的点积。

Computes the dot product of this and the passed in vector.

Parameters

vec

Vector2

Returns

number


equals()

equals(v): boolean

equals

判断两个向量是否相等。

Check the equality of two vectors

Parameters

v

Vector2

Returns

boolean


floor()

floor(): this

floor

将向量的各分量向下取整,返回自身。

Floor the components of a vector to produce a new vector

Returns

this


lerp()

lerp(vec, t): this

lerp

使用两个向量各分量的线性插值构造一个新向量,返回自身。

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

Parameters

vec

Vector2

t

number

Returns

this


magnitude()

magnitude(): number

magnitude

向量的模长。

The magnitude of the vector

Returns

number


multiply()

multiply(vec): this

multiply

对两个向量进行逐分量相乘。 注意不要与 Vector2Builder.dot(点积)混淆。

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

Parameters

vec

Vector2

Returns

this


normalize()

normalize(): this

normalize

将本向量归一化,返回自身。

Normalizes this vector, returning itself.

Returns

this


scale()

scale(val): this

scale

将本向量按传入的数值进行缩放,返回自身。

Scales this by the passed in value, returning itself.

Parameters

val

number

Returns

this


slerp()

slerp(vec, t): this

slerp

使用两个向量各分量的球面线性插值构造一个新向量,返回自身。

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

Parameters

vec

Vector2

t

number

Returns

this


subtract()

subtract(v): this

subtract

从本向量中减去向量 v,返回自身。

Subtracts the vector v from this, returning itself.

Parameters

v

Vector2

Returns

this


toString()

toString(options?): string

Parameters

options?
decimals?

number

delimiter?

string

Returns

string