【问题标题】:How to retrieve a bounding box's meshes in three js?如何在三个js中检索边界框的网格?
【发布时间】:2018-01-13 11:42:24
【问题描述】:

我实际上正在努力在 three.js 上实现一些遮挡剔除,我想知道是否有办法从 THREE.Box3 中检索此边界框内的所有相应网格?
three.js 中的边界框是否跟踪它包含的网格?
谢谢你们 。

【问题讨论】:

    标签: three.js bounding-box occlusion-culling


    【解决方案1】:

    以相反的顺序回答你的问题:

    不,Box3 没有“环境感” 如果您想保留 Box3 包含的网格列表,您需要在创建 Box3 时构建该列表,并维护它作为你的场景和Box3 改变。

    但是,您可以通过检查 bounding box intersections 来获取所有这些网格。一个主要的警告是,这些盒子必须被翻译成它们的世界变换。这会降低交点的准确性,因为边界框会扩展以包含变换后的部分,同时保持世界对齐。

    myMesh.geometry.computeBoundingBox(); // computes a LOCAL bounding box
    var tmpBox = new THREE.Box3().copy(myMesh.boundingBox);
    tmpBox.applyMatrix4(myMesh.matrixWorld); // converts tmpBox into a WORLD bounding box
    console.log("Boxes intersect:", someOtherWorldBox.intersectsBox(tmpBox)); // true/false
    

    【讨论】:

      猜你喜欢
      • 2022-10-18
      • 2021-05-27
      • 2018-10-04
      • 2013-02-04
      • 2018-10-07
      • 2018-02-10
      • 2019-10-06
      • 2017-08-02
      • 1970-01-01
      相关资源
      最近更新 更多