Autodesk Viewer的内置扩展

时间:2016-05-02 18:51:21

标签: webgl autodesk-viewer

Autodesk Viewer可以在'new Autodesk.Vieweing.Viewer3D'构造函数中加载一些扩展,但有哪些可用选项?以下代码来自from this tutorial

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);
      }
   );
}

1 个答案:

答案 0 :(得分:2)

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

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

并且查看器将在初始化期间为您调用Viewer3D.loadExtension(name,this.config)。该名称可以是Autodesk扩展程序,也可以是您自己的扩展名,如example所示。请参阅ItoTTool扩展,它是本地与第一个来自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
}