Reputation: 8574
The Autodesk Viewer can load some extensions on the 'new Autodesk.Vieweing.Viewer3D' constructor, but what are the available options? The code below came 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);
}
);
}
Upvotes: 1
Views: 376
Reputation: 2659
The simple answer to this question about loading viewer extensions is to provide an object like this one:
{
extensions: [
'Autodesk.IoTTool', 'Autodesk.FirstPerson'
]
}
and the viewer will call Viewer3D.loadExtension (name, this.config) for you during initialization. The name can be either Autodesk extensions, or your own extensions like shown on this example. See the IoTTool extension which is local vs the FirstPerson extension which is coming from the Autodesk server.
However, this config object can do a lot more. For example:
{
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
}
The Viewer3D.kDefaultCanvasConfig defaults are:
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
}
Upvotes: 2