在模型浏览器中单击时,防止在Forge Viewer中缩放 [英] Prevent zoom in Forge viewer when clicking in Model Browser

查看:120
本文介绍了在模型浏览器中单击时,防止在Forge Viewer中缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

模型浏览器中的点击行为已从Forge Viewer的版本2更改为版本3.在v2中,单击将选择元素,然后双击将放大到选定的元素.在v3中,只需单击一下即可放大元素.有时这很好,但是禁用此行为通常会很好.今天有没有简单的方法可以做到这一点?如果没有,是否可以向查看器API添加disableZoomOnSelection函数?

There has been a change in the click behavior in the model browser from version 2 to version 3 of the Forge Viewer. In v2, a single click would select the elements and a double click would zoom to the selected elements. In v3, a single click will zoom to the elements. Sometimes this is great, but often it would be nice to disable this behavior. Is there an easy way to do this today? And if not, could it be possible to add a disableZoomOnSelection function to the viewer API?

我知道浏览器会注视显示和隐藏元素,但是很容易偶然地将这三者并入,并且观看者突然在没有用户意图的情况下放大.

I know that the eyes in the browser will take care of the show and hide elements, but it’s very easy to klick in the three by accident and suddenly the viewer zoom without the user intention.

问候爆炸

推荐答案

我为您挖掘了该代码,以查看我在那篇文章中公开的 ViewerModelStructurePanel 的实现:https://forge.autodesk.com/blog/supporting-multiple-models-new-modelstructurepanel"rel =" nofollow noreferrer>在新的ModelStructurePanel中支持多个模型

I dig that code for you looking at the implementation of the ViewerModelStructurePanel that I was exposing in that article: Supporting multiple models in the new ModelStructurePanel

树中发生的事件通过 options.docStructureConfig 对象映射到预定义的动作,因此解决方法是使用所需选项实例化新的 ViewerModelStructurePanel :

Events that occur in the tree are mapped to predefined actions through the options.docStructureConfig object, so the workaround is to instantiate a new ViewerModelStructurePanel with the desired options:

viewer.addEventListener(Autodesk.Viewing.OBJECT_TREE_CREATED_EVENT, () => {

    var options = {
      docStructureConfig: {
          // go with default, which is viewer.select(node)
          //  click: {
          //    onObject: ["toggleOverlayedSelection"]
          //},
          clickShift: {
            onObject: ["toggleMultipleOverlayedSelection"]
        },
          clickCtrl: {
          onObject: ["toggleMultipleOverlayedSelection"]
        }
      }
    }

    var customModelStructurePanel =
      new Autodesk.Viewing.Extensions.ViewerModelStructurePanel(
        viewer, 'Browser', options)

    viewer.setModelStructurePanel(customModelStructurePanel)
  })

但是,双击未链接到当前实现中的事件,因此,对于更强大的自定义,我建议您用本文中介绍的自定义替换整个实现,并实现所需的操作处理程序.我将其实现为嵌入式替换,因此在这种情况下,您只需要在查看器脚本之后将其包含到html中,而不必替换 OBJECT_TREE_CREATED_EVENT

The double-click however is not linked to an event in the current implementation, so for a more powerful customization I would recommend you replace the whole implementation by a custom one as exposed in the article and implement desired action handlers. I implemented it as drop-in replacement, so in that case you just need to include it to your html after the viewer script and don't have to replace the model browser in OBJECT_TREE_CREATED_EVENT

这篇关于在模型浏览器中单击时,防止在Forge Viewer中缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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