检查Away3D中两个边界框之间的冲突



我需要在Away3D中做一些简单的碰撞检测。我找到了away3d.bounds.AxisAlignedBoundingBox类,但似乎只能检查边界框和Vector之间的冲突。

有什么方法可以检查两个边界框之间的碰撞吗?

如果您正在使用/can升级到4.4.x,查看Mesh.worldBounds,特别是wordBounds.重叠(someOtherWorldBounds).

示例(away3d设置被取消):

// setup objects and materials
cubeMaterial:ColorMaterial;
cube:Mesh;
sphereMaterial:ColorMaterial;
sphere:Mesh;
collideMaterial:ColorMaterial;
cubeMaterial = new ColorMaterial(0x3333FF);
cube = new Mesh(new CubeGeometry(), cubeMaterial);
cube.x = -100;
cube.showBounds = true;
sphereMaterial = new ColorMaterial(0xFF3333);
sphere = new Mesh(new SphereGeometry(), sphereMaterial);
sphere.x = 100;
sphere.showBounds = true;
collideMaterial = new ColorMaterial(0x33FF33);

在您的enterFrame处理程序中:

// process your object movement here
if (cube.worldBounds.overlaps(sphere.worldBounds) cube.material = collideMaterial;
else cube.material = cubeMaterial;
view.render();

相关内容

  • 没有找到相关文章

最新更新