Class: Vector3Builder
Vector3 wrapper class which can be used as a Vector3 for APIs on @minecraft/server which require a Vector, but also contain additional helper methods. This is an alternative to using the core Vector 3 utility methods directly, for those who prefer a more object-oriented approach. This version of the class is mutable and changes state inline.
For an immutable version of the build, use ImmutableVector3Builder.
用于 @minecraft/server 中需要用到三维向量的 API 的 Vector3 包装类,同时也包含额外的帮助方法。 这是对直接使用核心 Vector 3 实用方法的一种替代,适用于偏好面向对象方法的人。 此类的该版本是可变的,并且在内联中会更改状态。
若要使用构建的不可变版本,请使用 ImmutableVector3Builder。
Implements
unknown
Constructors
Constructor
new Vector3Builder(
vecStr,delim?,arg2?):Vector3Builder
Parameters
vecStr
string
delim?
string
arg2?
undefined
Returns
Vector3Builder
Constructor
new Vector3Builder(
vec,arg?,arg2?):Vector3Builder
Parameters
vec
Vector3
arg?
undefined
arg2?
undefined
Returns
Vector3Builder
Constructor
new Vector3Builder(
x,y,z):Vector3Builder
Parameters
x
number
y
number
z
number
Returns
Vector3Builder
Properties
x
x:
number
y
y:
number
z
z:
number
Methods
add()
add(
v):this
add
Adds the vector v to this, returning itself.
将向量 v 加到当前向量上,返回自身。
Parameters
v
Vector3
Returns
this
assign()
assign(
vec):this
Assigns the values of the passed in vector to this vector. Returns itself.
将传入向量的值赋给此向量。返回自身。
Parameters
vec
Vector3
Returns
this
ceil()
ceil():
this
ceil
Ceil the components of a vector to produce a new vector
对向量的各个分量向上取整,生成新的向量。
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
cross()
cross(
vec):this
cross
Computes the cross product of this and the passed in vector, returning itself.
计算此向量与传入向量的叉积,返回自身。
Parameters
vec
Vector3
Returns
this
distance()
distance(
vec):number
distance
Calculate the distance between two vectors
计算两个向量之间的距离。
Parameters
vec
Vector3
Returns
number
dot()
dot(
vec):number
dot
Computes the dot product of this and the passed in vector.
计算此向量与传入向量的点积。
Parameters
vec
Vector3
Returns
number
equals()
equals(
v):boolean
equals
Check the equality of two vectors
检查两个向量是否相等。
Parameters
v
Vector3
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
Vector3
t
number
Returns
this
magnitude()
magnitude():
number
magnitude
The magnitude of the vector
返回向量的模长。
Returns
number
max()
max(
vec):this
max
Max the components of two vectors to produce a new vector
取两个向量各分量中的较大值,生成新的向量。
Parameters
vec
Vector3
Returns
this
min()
min(
vec):this
min
Min the components of two vectors to produce a new vector
取两个向量各分量中的较小值,生成新的向量。
Parameters
vec
Vector3
Returns
this
multiply()
multiply(
vec):this
multiply
对两个向量进行逐元素相乘。 不要与 Vector3Builder.dot 点积或 Vector3Builder.cross 叉积混淆。
Element-wise multiplication of two vectors together. Not to be confused with Vector3Builder.dot product or Vector3Builder.cross product
Parameters
vec
Vector3
Returns
this
normalize()
normalize():
this
normalize
Normalizes this vector, returning itself.
归一化此向量,返回自身。
Returns
this
rotateX()
rotateX(
a):this
rotateX
沿 x 轴逆时针(左手法则)旋转该向量。
Rotates the vector around the x axis counterclockwise (left hand rule)
Parameters
a
number
Angle in radians
Returns
this
rotateY()
rotateY(
a):this
rotateY
沿 y 轴逆时针(左手法则)旋转该向量。
Rotates the vector around the y axis counterclockwise (left hand rule)
Parameters
a
number
Angle in radians
Returns
this
rotateZ()
rotateZ(
a):this
rotateZ
沿 z 轴逆时针(左手法则)旋转该向量。
Rotates the vector around the z axis counterclockwise (left hand rule)
Parameters
a
number
Angle in radians
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
Vector3
t
number
Returns
this
subtract()
subtract(
v):this
subtract
Subtracts the vector v from this, returning itself.
从此向量减去向量 v ,返回自身。
Parameters
v
Vector3
Returns
this
toString()
toString(
options?):string
toString
Create a string representation of a vector
以指定的格式返回向量的字符串表示。
Parameters
options?
decimals?
number
delimiter?
string
Returns
string
