Reputation: 340
How can we add listener CMERA_CHANGE_EVENT for markups drawn on a viewer? If we create a label against a dbid, we can store its coordinates and can apply worldToClient on coordinates to get new coordinates. But how this work for svg markups?
In my application, two ways user can associate rfi information. 1. by simply clicking a model obkject/dbid, I will let user add some textual information through a textbox and attach it as a label with that selected object/dbid. this is working as label moves along with the selected object while camer rotation event.
Technically to get this done, am using function getObjPosition to get coordinates of dbid and store it in a label control and I pull those values during camera change event and updates current client coordinates using below function getClientCoordinates
function getObjPosition(dbId) {
const model = viewer.model;
const instanceTree = model.getData().instanceTree;
const fragList = model.getFragmentList();
let bounds = new THREE.Box3();
instanceTree.enumNodeFragments( dbId, ( fragId ) => {
let box = new THREE.Box3();
fragList.getWorldBounds( fragId, box );
bounds.union( box );
}, true );
const position = bounds.center();
return position;
}
function getClientCoordinates(positionCoordinates){
var screenpoint = viewer.worldToClient(
new THREE.Vector3(positionCoordinates.x,
positionCoordinates.y,
positionCoordinates.z,));
return screenpoint
}
Hope my question is clear now.
Upvotes: 0
Views: 517
Reputation: 5342
The CAMERA_CHANGE_EVENT
works for the entire scene and whenever navigation occurs so there's no way to bind this to any specific object and it makes little sense to do so either.
If you are trying to move SVG markups to their new corresponding coordinates post navigation simply store their original world positions (using clientToWorld
) before navigation and then use worldToClient
to get their new coords post navigation.
Upvotes: 1