为什么我收到错误“中止loadExtensionAsync”

时间:2019-09-04 13:23:47

标签: javascript autodesk-forge autodesk-viewer viewer

我相信初始化会在查看器中加载两个模型。为此,我创建了两个查看器,并为它们添加了初始化的html容器。这两个模型都有自己的工具栏。一切都很好,但是某些工具栏扩展未加载到查看器中。 我在6版本中使用此代码,并且一切正常,但是在7版本中,我得到此错误列表。 这是浏览器的控制台错误的图像。 enter image description here

This is stack trace error.
ExtensionManager.js:399 
Uncaught (in promise) Abort loadExtensionAsync('Autodesk.ViewCubeUi')
(anonymous) @   ExtensionManager.js:399
c.onload    @   load-dependency.js:51
load (async)        
o   @   load-dependency.js:53
(anonymous) @   ExtensionManager.js:394
loadExtensionAsync  @   ExtensionManager.js:393
loadExtension   @   ExtensionManager.js:238
(anonymous) @   GuiViewer3D.js:445
setTimeout (async)      
L.createUI  @   GuiViewer3D.js:430
(anonymous) @   GuiViewer3D.js:276
(anonymous) @   GuiViewer3D.js:288
setTimeout (async)      
(anonymous) @   GuiViewer3D.js:283
p   @   Viewer3D.js:1199
(anonymous) @   SvfLoader.js:251
i   @   WorkerCreator.js:182

这是我的代码,它初始化了两个查看器并加载了两个模型。

Autodesk.Viewing.Initializer(options, function (){
  var htmlDiv = document.getElementById('MyViewerDiv');
  var htmlDivSecond = document.getElementById('MySecondViewerDiv');

  viewer = new Autodesk.Viewing.GuiViewer3D(htmlDiv, config3d);
  viewerSecond = new Autodesk.Viewing.GuiViewer3D(htmlDivSecond, config3dSecond);

  var startedCode = viewer.start();
  if(startedCode > 0){
    console.error('Faild to create a Viewer: WebGl not supported.');
    return;
  }
  Autodesk.Viewing.Document.load(documentId,onDocumentLoadSuccess,onDocumentLoadFailure );
  console.log('Initialization ....');
  Autodesk.Viewing.Document.load(documentId1,onDocumentLoadSuccess1,onDocumentLoadFailure1 );
});

...

function onDocumentLoadSuccess(doc) {
   console.log(doc);
    var defaultModel = doc.getRoot().getDefaultGeometry();
    viewer.loadDocumentNode(doc, defaultModel);
    // Choose any of the avialble viewables
    var svfUrl = doc.getViewablePath();

    viewerSecond.start(svfUrl, onLoadModelSuccess, onLoadModelError);
}

非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

看起来工程学已迅速采取行动并解决了该问题-请参阅herehere,所有扩展都可以在双Viewer实例中正常加载:

enter image description here

const viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('MyViewerDiv'));
  const viewerSecond = new Autodesk.Viewing.GuiViewer3D(document.getElementById('MyViewerDiv2'));