这个关于加载查看器扩展的问题的简单答案是提供一个像这样的对象:
{
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
}