[英]forge Viewer - How can we add CAMERA_CHANGE_EVENT for svg markups?
How can we add listener CMERA_CHANGE_EVENT for markups drawn on a viewer?我们如何为在查看器上绘制的标记添加侦听器 CMERA_CHANGE_EVENT? If we create a label against a dbid, we can store its coordinates and can apply worldToClient on coordinates to get new coordinates.
如果我们针对 dbid 创建一个标签,我们可以存储它的坐标,并且可以在坐标上应用 worldToClient 以获得新坐标。 But how this work for svg markups?
但是这对于 svg 标记是如何工作的呢?
In my application, two ways user can associate rfi information.在我的应用程序中,用户可以通过两种方式关联 rfi 信息。 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.
1. 只需单击模型对象/dbid,我将让用户通过文本框添加一些文本信息,并将其附加为带有所选对象/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从技术上讲,为了完成这项工作,我使用函数 getObjPosition 来获取 dbid 的坐标并将其存储在标签控件中,我在相机更改事件期间提取这些值并使用以下函数 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.希望我的问题现在清楚了。
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. CAMERA_CHANGE_EVENT
适用于整个场景,无论何时发生导航,因此无法将其绑定到任何特定对象,这样做也没什么意义。
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.如果您尝试将 SVG 标记移动到导航后新的相应坐标,只需在导航前存储它们的原始世界位置(使用
clientToWorld
),然后使用worldToClient
获取导航后的新坐标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.