【问题标题】:How Autodesk Forge viewer manages multiple scenes to select multiple elementsAutodesk Forge 查看器如何管理多个场景以选择多个元素
【发布时间】:2017-05-06 00:28:54
【问题描述】:

我想了解 Autodesk Forge 查看器如何将节点元素存储在多个 THREE.Scene 对象中。有几个场景:

viewer.impl.scene // The main scene
viewer.impl.overlayScenes // Three overlay scenes: selection, pivot and roll

每当在 Forge 查看器中选择一个元素时,它的 THREE.Mesh 对象都会添加到 viewer.impl.overlayScenes.selection.scene.children。但是它的边​​界几何总是为零,不像原始的THREE.Mesh对象在执行geometry.computeBoundaryBox()之后会有边界

由于 Forge 元素的零边界,我不能使用 THREE.Raycaster 来投射覆盖元素以在鼠标选择时获取它们的 dbId。我如何选择内部 dbId,因为它将获得外部 dbId? Forge 查看器不允许在单击外部对象时选择内部对象。如何在另一个元素中选择一个元素?

主要场景也有空的孩子。所有元素都在哪里?它们如何在屏幕上呈现?

如果要了解 Forge 查看器数据结构以获得完整的 API 控制,则需要更好的文档。 Autodesk Forge查看器的viewer3D.js和wgs.js我必须自学。

【问题讨论】:

    标签: autodesk-forge autodesk-viewer


    【解决方案1】:

    这里有两种方法向您展示如何根据它们的 fragmentId 访问特定组件的边界框:

    //returns bounding box as it appears in the viewer
    // (transformations could be applied)
    function getModifiedWorldBoundingBox(fragIds, fragList) {
    
      var fragbBox = new THREE.Box3();
      var nodebBox = new THREE.Box3();
    
      fragIds.forEach(function(fragId) {
    
        fragList.getWorldBounds(fragId, fragbBox);
        nodebBox.union(fragbBox);
      });
    
      return nodebBox;
     }
    
     // Returns bounding box as loaded in the file
     // (no explosion nor transformation)
    function getOriginalWorldBoundingBox(fragIds, fragList) {
    
      var fragBoundingBox = new THREE.Box3();
      var nodeBoundingBox = new THREE.Box3();
    
      var fragmentBoxes = fragList.boxes;
    
      fragIds.forEach(function(fragId) {
        var boffset = fragId * 6;
        fragBoundingBox.min.x = fragmentBoxes[boffset];
        fragBoundingBox.min.y = fragmentBoxes[boffset+1];
        fragBoundingBox.min.z = fragmentBoxes[boffset+2];
        fragBoundingBox.max.x = fragmentBoxes[boffset+3];
        fragBoundingBox.max.y = fragmentBoxes[boffset+4];
        fragBoundingBox.max.z = fragmentBoxes[boffset+5];
        nodeBoundingBox.union(fragBoundingBox);
      });
    
      return nodeBoundingBox;
     }
    

    您可以从下面的博客文章中找到一个全面的示例:

    Getting bounding boxes of each component in the viewer

    【讨论】:

    • fragList.getWorldBounds(fragId, fragbBox) 很棒。您是否找到另一种计算片段边界球的方法?感谢您的支持。
    • “还有现场演示。” - 不幸的是,该链接不再有效...
    猜你喜欢
    • 2023-03-06
    • 2020-02-10
    • 2021-11-12
    • 1970-01-01
    • 2017-03-01
    • 2021-11-05
    • 2019-07-19
    • 2019-11-23
    • 2017-05-07
    相关资源
    最近更新 更多