轴线对齐边界框,以获取乐趣和利润。
var aabb = require ( 'aabb-3d' )
var bounding_box = aabb ( [ 0 , 0 , 0 ] , [ 12 , 12 , 12 ] ) // x, y, z == 0; width, height, depth == 12
, other = aabb ( [ 10 , 10 , 10 ] , [ 2 , 2 , 2 ] )
bounding_box . intersects ( other ) // true
bounding_box . translate ( [ 2 , 2 , 2 ] ) // moves the bounding box
bounding_box . expand ( other ) // returns a new aabb that surrounds both bboxes
返回新的AABB。
返回:
x0/y1/z1---x1/y1/z1
depth-> / /|
/ / |
x0/y1/z0 -- x1/y1/z0
| | |
| | <-- height
| | /
| | /
x0/y0/z0 ----- x1/y0/z0
^
|
width
移动盒子。返回自己。
如果两个边界框相交(或根本触摸),则返回true。
返回一个新的aabb
代表两个AABB的共享区域。如果盒子不相交,则返回null
。
返回围绕两个AABB的新aabb
。
麻省理工学院