简体   繁体   English

伪造查看器 - 我们如何为 svg 标记添加 CAMERA_CHANGE_EVENT?

[英]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 }

  1. In this scenarion, I am giving user to draw cloud markup and associate a label for the tetual information user enter on selection of markup.在这个场景中,我让用户绘制云标记并为用户在选择标记时输入的 tetual 信息关联一个标签。 So to get coordinates am using below code所以要获得坐标我使用下面的代码
    var pos = markup.markups[0].getClientPosition(); var pos = markup.markups[0].getClientPosition(); and tag the label with this created markup.并使用此创建的标记标记标签。 It works.有用。 For camera change event, the markups itself lose its position, so not sure how I will attach to the model and apply coordinates for label.对于相机更改事件,标记本身会丢失其位置,因此不确定我将如何附加到模型并为标签应用坐标。 Here another worrying part is, how I should get all the drawn markups on the model during camera change event这里另一个令人担忧的部分是,我应该如何在相机更换事件期间获得模型上的所有绘制标记

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.

相关问题 Forge 查看器 - 如何在相机更改事件时将恢复的标记与写在其上的标签文本链接起来 - Forge viewer - How to link restored markups with their label text written on it while camera change event Forge Viewer - 标记 - 我们可以获得当前选择的 xy 坐标吗? - Forge Viewer - Markups - can we get xy coordinates of the current selection? Forge Viewer - 我们可以将模型对象与在查看器中绘制的标记相关联吗? - Forge Viewer - can we associate objects of model with markups which are drawn in viewer? Forge Viewer - 如何编辑旧标记? - Forge Viewer - how to edit old markups? 如何在 Autodesk Forge 查看器中将点击事件添加到图钉? - How can i add click event to pushpin in autodesk forge viewer? 如何从也包含MarkupsCore标记的Forge Viewer中导出.dwg文件? - How can I export a .dwg file from the Forge Viewer that also includes MarkupsCore markups? Forge Viewer Markups 最新版本 - Forge Viewer Markups latest version Forge Viewer - 标记层的概念是什么? - Forge Viewer - What is the concept of layer on markups? 添加标记时,Forge Viewer显示UI - Forge Viewer show UI while adding Markups 我们可以在伪造查看器中添加一次选择多个标记的功能吗 - Can we add functionality to select multiple markup at a time in forge viewer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM