类 BlockVolume实验性

BlockVolume 是一个简单的接口,表示在世界方块位置中具有给定大小(三维方块)的矩形区域。 注意,这些并不等同于“最小值”和“最大值”,因为向量的各个分量顺序并不固定。 此外,这些向量位置不能与 BlockLocation 互换使用。 若需要将此体积表示为 BlockLocation 的范围,可以使用 getBoundingBox 工具函数。 此体积类会保持初始设置的角索引顺序。例如,当你在编辑器中分配每个角并移动角的位置时 (可能会颠倒边界的最小值/最大值关系),原本选择的左上角可能会变成右下角。 手动编辑这些体积时,需要在编辑时保持角的标识 - BlockVolume 的工具函数会处理这一点。

需要注意的是,这里测量的是方块的大小(起点到终点)。 一个普通的 AABB (0,0,0) 到 (0,0,0) 传统上大小为 (0,0,0)。 但因为我们测量的是方块,BlockVolume 的大小或跨度实际上为 (1,1,1)。

A BlockVolume is a simple interface to an object which represents a 3D rectangle of a given size (in blocks) at a world block location. Note that these are not analogous to "min" and "max" values, in that the vector components are not guaranteed to be in any order. In addition, these vector positions are not interchangeable with BlockLocation. If you want to get this volume represented as range of of BlockLocations, you can use the getBoundingBox utility function. This volume class will maintain the ordering of the corner indexes as initially set. imagine that each corner is assigned in Editor - as you move the corner around (potentially inverting the min/max relationship of the bounds) - what you had originally selected as the top/left corner would traditionally become the bottom/right. When manually editing these kinds of volumes, you need to maintain the identity of the corner as you edit - the BlockVolume utility functions do this.

Important to note that this measures block sizes (to/from) - a normal AABB (0,0,0) to (0,0,0) would traditionally be of size (0,0,0) However, because we're measuring blocks - the size or span of a BlockVolume would actually be (1,1,1)

层级 (查看层级一览)

构造函数

属性

from: Vector3

表示一个三维矩形中某个角的世界方块位置。

A world block location that represents a corner in a 3D rectangle

无法在只读模式下修改此属性,详见 WorldBeforeEvents

表示一个三维矩形中与另一角相对的世界方块位置。

A world block location that represents the opposite corner in a 3D rectangle

无法在只读模式下修改此属性,详见 WorldBeforeEvents

方法

  • 实验性

    参数

    • pos: Vector3

      要测试的世界方块位置。

      The world block location to test

    返回 boolean

    若位置在内部或距离超过 0 个方块,函数将返回 false。 若位置直接接触到 BlockVolume 的外表面,函数将返回 true。

    If the location is either inside or more than 0 blocks away, the function will return false. If the location is directly contacting the outer surface of the BlockVolume, the function will return true.

    检测给定位置是否直接与 BlockVolume 的外表面相邻。

    Check to see if the given location is directly adjacent to the outer surface of a BlockVolume.

    无法在只读模式下调用此函数,详见 WorldBeforeEvents

  • 实验性

    参数

    • other: BlockVolume

      要测试的体积。

      The volume to test

    返回 boolean

    若两个方块体积的外表面在任何点相接触并直接相邻,返回 true。

    If the outer faces of both block volumes touch and are directly adjacent at any point, return true.

    检测两个方块体积是否直接相邻并且两个面接触。

    Check to see if a two block volumes are directly adjacent and two faces touch.

    无法在只读模式下调用此函数,详见 WorldBeforeEvents

  • 实验性

    返回 BoundingBox

    返回一个 BoundingBox 对象,表示该体积经过验证的最小和最大坐标。

    Return a BoundingBox object which represents the validated min and max coordinates of the volume

    无法在只读模式下调用此函数,详见 WorldBeforeEvents

    此函数可能会抛出错误。

    This function can throw errors.

  • 实验性

    返回 number

    返回 BlockVolume 的容量(体积)(宽高)。

    Return the capacity (volume) of the BlockVolume (WDH)

    无法在只读模式下调用此函数,详见 WorldBeforeEvents

  • 实验性

    返回 Vector3

    获取体积的最大角位置(保证 >= 最小值)。

    Get the largest corner position of the volume (guaranteed to be >= min)

    无法在只读模式下调用此函数,详见 WorldBeforeEvents

    此函数可能会抛出错误。

    This function can throw errors.

  • 实验性

    返回 Vector3

    获取体积的最小角位置(保证 <= 最大值)。

    Get the smallest corner position of the volume (guaranteed to be <= max)

    无法在只读模式下调用此函数,详见 WorldBeforeEvents

    此函数可能会抛出错误。

    This function can throw errors.

  • 实验性

    返回 Vector3

    获取一个 Vector3 对象,其中每个分量表示沿该轴的方块数量。

    Get a Vector3 object where each component represents the number of blocks along that axis

    无法在只读模式下调用此函数,详见 WorldBeforeEvents

  • 实验性

    参数

    返回 boolean

    检查给定的世界方块位置是否在 BlockVolume 内。

    Check to see if a given world block location is inside a BlockVolume

    无法在只读模式下调用此函数,详见 WorldBeforeEvents

  • 实验性

    参数

    • delta: Vector3

      移动的方块数量。

      Amount of blocks to move by

    返回 void

    按指定的量移动 BlockVolume。

    Move a BlockVolume by a specified amount

    无法在只读模式下调用此函数,详见 WorldBeforeEvents