Box3Bounds3 / GameBounds3 三维区域空间
这是一个服务端API
该API仅在服务端脚本使用
构造函数¶
新建一个区域
属性 | 类型 | 说明 |
---|---|---|
lo | 区域的低处顶点 | |
hi | 区域的高处顶点 |
属性 | 类型 | 说明 |
---|---|---|
lo | 区域的低处顶点 | |
hi | 区域的高处顶点 |
关于lo
与hi
参数的说明
在编写代码的时候,要保证lo
的每个值是比hi
小的(lo.x < hi.x && lo.y < hi.y && lo.z < hi.z
),否则会发生匪夷所思的问题
如果不能保证,可以使用
警告
TypeError: Cannot read property 'toString' of undefined
常用¶
属性¶
属性 | 类型 | 说明 |
---|---|---|
lo | 区域的低处顶点 | |
hi | 区域的高处顶点 |
属性 | 类型 | 说明 |
---|---|---|
lo | 区域的低处顶点 | |
hi | 区域的高处顶点 |
方法¶
intersect (b:Box3Bounds3 ):Box3Bounds3 intersect (b:GameBounds3 ):GameBounds3 - 计算与此包围盒相交的部分
示例
contains (b:Box3Vector3 ):boolean contains (b:GameVector3 ):boolean - 判断一个三维向量是否在这个空间区域里,包括边界
示例
containsBounds (b:Box3Vector3 ):boolean containsBounds (b:GameVector3 ):boolean - 检测一个空间区域是否完全在空间区域里(边界也算)
示例
new Box3Bounds3(new Box3Vector3(0, 0, 0), new Box3Vector3(5, 5, 5)).containsBounds(new Box3Bounds3(new Box3Vector3(2, 2, 2), new Box3Vector3(7, 7, 7))) //<~ false new Box3Bounds3(new Box3Vector3(2, 2, 2), new Box3Vector3(7, 7, 7)).containsBounds(new Box3Bounds3(new Box3Vector3(0, 0, 0), new Box3Vector3(5, 5, 5))) //<~ false new Box3Bounds3(new Box3Vector3(0, 0, 0), new Box3Vector3(7, 7, 7)).containsBounds(new Box3Bounds3(new Box3Vector3(2, 2, 2), new Box3Vector3(5, 5, 5))) // <~ true new Box3Bounds3(new Box3Vector3(0, 0, 0), new Box3Vector3(7, 7, 7)).containsBounds(new Box3Bounds3(new Box3Vector3(2, 2, 0), new Box3Vector3(5, 7, 5))) // <~ true
new GameBounds3(new GameVector3(0, 0, 0), new GameVector3(5, 5, 5)).containsBounds(new GameBounds3(new GameVector3(2, 2, 2), new GameVector3(7, 7, 7))) //<~ false new GameBounds3(new GameVector3(2, 2, 2), new GameVector3(7, 7, 7)).containsBounds(new GameBounds3(new GameVector3(0, 0, 0), new GameVector3(5, 5, 5))) //<~ false new GameBounds3(new GameVector3(0, 0, 0), new GameVector3(7, 7, 7)).containsBounds(new GameBounds3(new GameVector3(2, 2, 2), new GameVector3(5, 5, 5))) // <~ true new GameBounds3(new GameVector3(0, 0, 0), new GameVector3(7, 7, 7)).containsBounds(new GameBounds3(new GameVector3(2, 2, 0), new GameVector3(5, 7, 5))) // <~ true
intersects (b:Box3Bounds3 ):boolean intersects (b:GameBounds3 ):boolean - 判断一个空间区域是否与这个空间区域相交(挨着不算)
示例
new Box3Bounds3(new Box3Vector3(0, 0, 0), new Box3Vector3(5, 5, 5)).intersects(new Box3Bounds3(new Box3Vector3(2, 2, 2), new Box3Vector3(7, 7, 7))) //<~ true new Box3Bounds3(new Box3Vector3(0, 0, 0), new Box3Vector3(5, 5, 5)).intersects(new Box3Bounds3(new Box3Vector3(5, 5, 5), new Box3Vector3(7, 7, 7))) //<~ false new Box3Bounds3(new Box3Vector3(0, 0, 0), new Box3Vector3(5, 5, 5)).intersects(new Box3Bounds3(new Box3Vector3(4.99999, 4.99999, 4.99999), new Box3Vector3(7, 7, 7))) //<~ true
new GameBounds3(new GameVector3(0, 0, 0), new GameVector3(5, 5, 5)).intersects(new GameBounds3(new GameVector3(2, 2, 2), new GameVector3(7, 7, 7))) //<~ true new GameBounds3(new GameVector3(0, 0, 0), new GameVector3(5, 5, 5)).intersects(new GameBounds3(new GameVector3(5, 5, 5), new GameVector3(7, 7, 7))) //<~ false new GameBounds3(new GameVector3(0, 0, 0), new GameVector3(5, 5, 5)).intersects(new GameBounds3(new GameVector3(4.99999, 4.99999, 4.99999), new GameVector3(7, 7, 7))) //<~ true
set (lox: , loy: , loz: , hix: , hiy: , hiz: ):Box3Bounds3 set (lox: , loy: , loz: , hix: , hiy: , hiz: ):GameBounds3 - 设置这个空间区域
copy (b:Box3Bounds3 ):Box3Bounds3 copy (b:GameBounds3 ):GameBounds3 - 把一个空间区域的值复制到这个空间区域上
toString ():string - 将这个空间区域转换成字符串
fromPoints (points: ...Box3Vector3 ):Box3Bounds3 fromPoints (points: ...GameVector3 ):GameBounds3 - 根据坐标点生成一个空间区域,使每个点都在这个空间区域内