如何将自定义菜单添加到Autodesk Forge Viewer? [英] How to add custom menu to Autodesk Forge Viewer?

查看:228
本文介绍了如何将自定义菜单添加到Autodesk Forge Viewer?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好 我在这里使用查看器示例"表单: https://forge.autodesk.com/zh-CN/docs/viewer/v5/tutorials/basic-viewer/ (步骤1) 现在我需要:

Helo I'm using Viewer Example form here: https://forge.autodesk.com/en/docs/viewer/v5/tutorials/basic-viewer/ (Step 1) and now I need:

1. add custom menu on right click
2. get info's for clicked object, like Area, Volume, Length (if 3D) or length if 2D.

请问该怎么做?

我尝试从中复制整个类MyContextMenu扩展..."代码 https://forge.autodesk.com/blog/customize-viewer-context-菜单 但这不起作用.

I try to copy whole "class MyContextMenu extends ... " code from https://forge.autodesk.com/blog/customize-viewer-context-menu but it does not worked.

谢谢.

推荐答案

下面是一个向上下文菜单添加自定义菜单项的简单示例:

Here's a simple example of adding custom menu items to the context menu: http://jsfiddle.net/s47vy5u3/2. You'll just need to include your Forge app's access token and some viewable URN. The menu customization code itself looks like this:

function customizeMenu() {
    const viewer = NOP_VIEWER;
    viewer.registerContextMenuCallback('MyCustomMenuItems', function(menu, status) {
    menu.push({
      title: 'My custom menu item',
      target: () => {
        // Add your menu item's code here
      }
    });
  });
}

这篇关于如何将自定义菜单添加到Autodesk Forge Viewer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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