简体   繁体   中英

forge Viewer - Markup camera change issue

In my viewer, I have a markup plotted using cloud mode and during camera change event, am not able to map the associated label with the markup as it moves on. To make this work I store coordinates and while camera change event I use worldToClient to find the new coordinates, but this is not working

So problem is with finding original world coordinates. I tried multiple ways as below, but nothing seems to work for me. Much appreciate help on this. Just for an idea on this, am attaching screen-shots of model before and after camera change.

/*** option 1***/
worldCoord = markup.markups[0].generateBoundingBox().max;
/*** option 2***/
var coords = viewer.impl.clientToViewport(pos.x, pos.y);
worldCoord = coords.unproject(viewer.impl.camera)
/*** option 3***/
worldCoord = markup.markups[0].getClientPosition()
/*** option 4***/
worldCoord = viewer.clientToWorld(pos.x,pos.y,true);
/***option 5***/
worldCoord = markup.markups[0].getBoundingRect()

Finally I got it.

We can store layername info with your label and fetch it in your camera change event using below code.

position = markup.svgLayersMap[layerName].markups[0].getClientPosition()

hope this helps someone

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM