Search code examples
autodesk-forgeautodesk-viewer

Understanding the difference between a Viewer and a ViewingApplication


This question is related to my previous question (How to implement a Forge Autodesk model-aggregating viewer? ). My current viewer is based on the http://learnforge.autodesk.io/#/ tutorial, and there's a part of the code I don't understand :

var options = {
  env: 'AutodeskProduction',
  getAccessToken: getForgeToken
};
var documentId = 'urn:' + urn;
console.log(documentId)
Autodesk.Viewing.Initializer(options, function onInitialized() {
  viewerApp = new Autodesk.Viewing.ViewingApplication('forgeViewer');
  viewerApp.registerViewer(viewerApp.k3D, Autodesk.Viewing.Private.GuiViewer3D);
  viewerApp.loadDocument(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});

The previous code, as far as I understood, initialize the viewer. However I don't figure out what kind of object viewerApp is. Indeed :


Solution

  • I'd recommend to refrain from using ViewingApplication as it's being deprecated (albeit ployfill available for legacy support) in the upcoming Viewer v7.* (GTA next week).

    Go with Autodesk.Viewing.Private.GuiViewer3D or Autodesk.Viewing.Private.Viewer3D and see here on how to initialize and load a model.

    And see here for doc on AAutodesk.Viewing.Document.load (equivalent to loadDocument).