How to get the coordinate information of the model in View

how to get coordinate information in Viewer?

Jul.07,2022

do you need the coordinates of the component, or some other coordinate information? If it is a component, viewer loads geometric patches, not the design software has the so-called 'location' information.

viewer provides the transformation matrix information of the component, which can be obtained through the following code. If you just want to have a reference point, consider using the center of the box, which is also demonstrated in the following code:

var dbid = 1234;
var bounds = new THREE.Box3();
var box = new THREE.Box3();
var instanceTree = NOP_VIEWER.impl.model.getData().instanceTree;
var fragList = NOP_VIEWER.impl.model.getFragmentList();

instanceTree.enumNodeFragments(dbid, function (fragId) {
   console.log('fragId:' + fragId);

   //
   fragList.getWorldBounds(fragId, box)
   //
   bounds.union(box);
             
   //
   //
   //
   var fm = new THREE.Matrix4();
   fragList.getWorldMatrix(fragId,fm);
   console.log('frag matrix:' + JSON.stringify(fm));  
 }, true)
Menu