autodesk-forge在a360查看器中添加对象的超链接

时间:2018-04-15 15:34:22

标签: hyperlink autodesk-forge

需要找到在a360查看器中向组件的组件添加超链接的方法,以便在使用移动设备单击或触摸时,将导航到网页以获取更多信息。实现它需要Forge API,但找不到这种解决方案的任何具体示例。我认为这可以从属性表中完成,但我希望直接导航来触摸/单击对象。

1 个答案:

答案 0 :(得分:0)

您可以订阅对象选择事件并通过例如对象做出反应。打开一个给定的URL:



    viewer.addEventListener(
        Autodesk.Viewing.SELECTION_CHANGED_EVENT,
        function (event) {
            // Get id of first selected item
            var dbId = event.dbIdArray[0];
            if (dbId) {
                // Maybe get the properties of the selected object
                viewer.getProperties(dbId, function (props) {
                   // Depending on the properties you could open a website
                   
                   // Just printing to the console the external id of 
                   // the selected component as an example
                   console.log(props.externalId);
                });
            }
        }
    );




如果您搜索" Autodesk.Viewing.SELECTION_CHANGED_EVENT"您也可以使用此活动找到一些文章和样本,例如https://forge.autodesk.com/blog/selection-override