How do I get all the components in the viewpoint?

when I save a viewpoint, I want to get all the components within the visual range of the viewpoint, as long as they appear in the viewpoint. Is there any good way? Because it is the viewpoint, I want to customize the bounding box, but I don"t know how to judge the scope of the box.

May.14,2022

the truncated body can be obtained by the camera and determine whether it collides with the bounding box of the component, such as

.
var frustum = new THREE.Frustum();
var cameraViewProjectionMatrix = new THREE.Matrix4():
camera.matrixWorldInverse.getInverse( camera.matrixWorld );
cameraViewProjectionMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
frustum.setFromMatrix( cameraViewProjectionMatrix );

model.getInstanceTree().enumNodeChildren(rootid, (dbid) => {
  var box = getComponentBoundingBox(model,dbid);
  if (frustum.intersectsBox(box))
      dbidArrayToSelect.push(dbid)
});

Viewer.select(dbidArrayToSelect)

where getComponentBoundingBox can refer to https://github.com/Autodesk-F...

.
Menu