使用外部按钮控制Autodesk-Forge查看器 [英] Controlling the autodesk-forge viewer with external buttons

查看:141
本文介绍了使用外部按钮控制Autodesk-Forge查看器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在向公司内部网站添加伪造,我们可以在其中查看已制造或正在制造的所有机器.该网站的工作方式如下:用户选择一个机器号,然后将弹出有关该机器的所有信息.这包括机器内的工作站,以及每个工作站内的所有单个零件.我的任务是将autodesk-forge添加到网站.目前,我已经成功地使用欧特克锻浏览器,以便每当机器被拾取,用户可以按下一个按钮,整个机器的型号会弹出来看待.下一步是使查看器由网站上的外部按钮控制.我们希望它可以这样工作:

Currently I am adding forge to an internal company website where we can view all of the machines we have built or are building. The website works like this: The user selects a machine number and all the information about the machine will pop up. This includes stations within the machine, as well as all the individual parts within each station. My task was to add autodesk-forge to the website. Currently I have successfully used the autodesk-forge viewer so that whenever a machine is picked, the user can press a button, and the model of the entire machine will pop up to be viewed. The next step is to have the viewer be controlled by external buttons on the website. We want it to work as such:

  1. 用户选择一台机器.之后,将弹出所有信息,例如工作站以及机器中每个工作站内的零件的信息(完成).

  1. A machine is picked by the user. After this all the information such as stations, and parts within each station in the machine will pop up (this is completed).

用户单击视图模型"按钮,该按钮将使用伪造查看器使机器在网站上弹出(这已由我完成).

The user clicks a "view model" button which will use the forge viewer to make the machine pop up on the website (This has been completed by me).

一旦带有模型的伪造查看器出现在屏幕上,我们希望该查看器能够由站点上已经存在的外部按钮控制.

Once the forge viewer with the model is on the screen, we want the viewer to be able to be controlled by external buttons already on the site.

例如,如果有一台名称为MC-000的机器,并且在该机器中有一个名为ST010的工位,则该工位内有很多零件,例如齿轮.当用户正在查看机器MC-000时,我们希望能够单击一个已经完成的外部按钮(例如ST010),并且查看器将自动放大并突出显示机器中的该电台.我们也希望机器内的零件也一样.拾取机器后,其站点以及站点内的零件已经在我们的网站上打印了出来.现在,我们希望能够单击桩号或零件,并让查看器自动放大该零件号或桩号.我在此处找到了类似的代码示例.在此示例中,查看器的各个部分由不在查看器内的按钮控制.例如,单击引擎"按钮时,查看器将自动放大引擎.这个示例的问题在于,所有位置都被硬编码到代码中,这意味着引擎的位置已经在代码中.我无法做到这一点,因为我们有许多不同的机器,其中有成千上万个零件,因此我不可能将它们全部硬编码.使用autodesk-forge viewer可能会发生这种情况.任何帮助或指导将不胜感激.干杯!

For example, if there is a machine with name MC-000, and in that machine there is a station named ST010, within that station there are many parts, for example a gear. When the machine MC-000 is being viewed by the user, we want to be able to click an external button which is already made (for example ST010) and the viewer will automatically zoom in and highlight that station within the machine. We also want the same for parts within the machine. When a machine is picked, its stations, as well as the parts within the stations are already printed out within our website. We now want to be able to click the stations, or parts and have the viewer automatically zoom into that part# or station#. I have found a similar code sample here. In this example, parts of the viewer are controlled by buttons not within the viewer. For example, when the 'engine' button is clicked, the viewer will automatically zoom into the engine. The problem with this example, is that all of the positions are hard-coded into the code, meaning that the position of the engine is already within the code. I cannot do this as we have many different machines with thousands of parts, so it would be impossible for me to hard-code them all in. Is something like this possible to do with autodesk-forge viewer. Any help or guidance would be greatly appreciated. Cheers!

编辑**

任何有关如何更改查看器放大位置的指导都将受到赞赏,并会有所帮助.当前,我有一些方法可以从GET:urn/metadata/:guid http请求中获取dbid和外部objectId.再次感谢!

Any guidance at all on how I can change where the viewer zooms into would be much appreciated and would help a lot. Currently, I have methods go get both the dbid, and the external objectId from the GET :urn/metadata/:guid http request. Thanks again!

推荐答案

似乎您确实具有指定的引擎dbid,并且可以通过某种方式将查看器功能与外部代码链接.查看器的默认doubleclick行为是选择鼠标指针与之碰撞的项目.然后,相机会放大(或缩小)该项目以使其适合视图.

It seems you do have the specified engine dbid and you have a way to link viewer functions with your outside code. The default doubleclick behaviour of the viewer is to select the item the mousepointer collides with. The camera then zooms in (or out) to that item to fit it into the view.

您可以使用:

选择

还有

fitToView

实现模拟交互.

例如在打字稿中:

// Your dbid is for example 1234
this.viewer.select(1234);
this.viewer.fitToView([1234]);

这篇关于使用外部按钮控制Autodesk-Forge查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆