How Autodesk Forge viewer manages multiple scenes to select multiple elements

后端 未结 1 722
深忆病人
深忆病人 2021-01-23 12:00

I want to understand how Autodesk Forge viewer stores node elements in multiple THREE.Scene objects. There are several scenes:

viewer.impl.scene // The main scen         


        
相关标签:
1条回答
  • 2021-01-23 12:39

    Here are two methods that shows you how to access the bounding boxes of specific components based on their fragmentIds:

    //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;
     }
    

    You can find a comprehensive sample from the blog post below:

    Getting bounding boxes of each component in the viewer

    0 讨论(0)
提交回复
热议问题