aabb(英文全称:Axis-Aligned Bounding Box)是一个三维空间中的立方体,它的六个面都与X,Y,Z轴平行。aabb常常用于快速碰撞检测、物体选择以及物体剔除等计算。在Yuka js库的MeshGeometry中,aabb的计算方法如下:
updateAABB(): void
此方法用于更新当前MeshGeometry对象的aabb。
getAABB(): Box3
此方法用于获取当前MeshGeometry对象的aabb。
aabb: Box3
此属性表示当前MeshGeometry对象的aabb。
import { MeshGeometry } from 'yuka';
const meshGeometry = new MeshGeometry();
meshGeometry.updateVertices( [
-1, -1, 1,
1, -1, 1,
1, 1, 1,
-1, 1, 1
] );
meshGeometry.updateIndices( [
0, 1, 2,
2, 3, 0
] );
meshGeometry.updateAABB();
console.log( meshGeometry.getAABB() );
aabb是一个三维空间中的立方体,常常用于快速碰撞检测、物体选择以及物体剔除等计算中。在Yuka js库的MeshGeometry中,aabb可以使用updateAABB方法进行更新,或者使用getAABB方法获取当前MeshGeometry对象的aabb。在进行场景渲染时,可以使用aabb进行剔除提高渲染效率。