1

Autodesk 查看器可以在“新 Autodesk.Vieweing.Viewer3D”构造函数上加载一些扩展,但有哪些可用选项?下面的代码来自本教程

function initialize() {
   var options = {
      'document' : 'urn:<<SOME URN HERE>>',
      'env':'AutodeskProduction',
      'getAccessToken': getToken,
      'refreshToken': getToken,
   };
   var viewerElement = document.getElementById('viewer');
   var viewer = new Autodesk.Viewing.Viewer3D(viewerElement, { /* Extensions here? */});
   Autodesk.Viewing.Initializer(
      options,
      function() {
         viewer.initialize();
         loadDocument(viewer, options.document);
      }
   );
}
4

1 回答 1

2

这个关于加载查看器扩展的问题的简单答案是提供一个像这样的对象:

{
    extensions: [
        'Autodesk.IoTTool', 'Autodesk.FirstPerson'
    ]
}

并且查看器将在初始化期间为您调用 Viewer3D.loadExtension (name, this.config)。该名称可以是 Autodesk 扩展,也可以是您自己的扩展,如本示例所示。查看本地的 IoTTool 扩展与来自 Autodesk 服务器的 FirstPerson 扩展。

然而,这个配置对象可以做更多的事情。例如:

{
    startOnInitialize: boolean, // (default true) the default behavior is to run the main loop immediately, unless startOnInitialize is provided and is to false.

    canvasConfig: { // (default Viewer3D.kDefaultCanvasConfig)
        disableSpinner: boolean,
        disableMouseWheel: boolean, // (default false) the name tells it
        disableTwoFingerSwipe: boolean, // (default false)

        COMMAND: {
            onObject: ACTIONS,
            offObject: ACTIONS
        },

        ...

        // COMMAND: click, clickAlt, clickCtrl, clickShift, clickCtrlShift
        // ACTIONS: selectOnly, selectToggle, deselectAll, isolate, showAll, setCOI, focus, hide

    },

    extensions: [], // will call this.loadExtension(extensions[i], this.config)

    onTriggerContextMenuCallback: <function callback>, // function (event) {}
    onTriggerSelectionChangedCallback: <function callback>, // function (event) {dbid}
    onTriggerDoubleTapCallback: <function callback>, // function (event) {}
    onTriggerSingleTapCallback: <function callback>, // function (event) {}

    viewableName: string, // the name appearing on the model dialog box

    screenModeDelegate: <class>, // to control fullscreen behaviour
}

Viewer3D.kDefaultCanvasConfig 默认值为:

Viewer3D.kDefaultCanvasConfig = {
    "click": {
        "onObject": ["selectOnly"],
        "offObject": ["deselectAll"]
    },
    "clickAlt": {
        "onObject": ["setCOI"],
        "offObject": ["setCOI"]
    },
    "clickCtrl": {
        "onObject": ["selectToggle"],
        "offObject": ["deselectAll"]
    },
    "clickShift": {
        "onObject": ["selectToggle"],
        "offObject": ["deselectAll"]
    },

    // Features that support disabling
    "disableSpinner": false,
    "disableMouseWheel": false,
    "disableTwoFingerSwipe": false
}
于 2016-05-04T17:50:42.703 回答