Completely unload and reload forge viewer

非 Y 不嫁゛ 提交于 2019-12-01 08:54:47

问题


I'm using the Forge Viewer on an Angular 5 application.

Is there a way to completely unload the viewer so it can later be reloaded?

I have the following code to unload the viewer:

if (this.viewer && this.viewer.running) {
  this.viewer.tearDown();
  this.viewer.finish();
  this.viewer = null;
}

And I also have the code to load the viewer every time the user enters the page.

Currently, when a user navigates to a different page on the application, that code gets executed, but when the user comes back to the page that contains the viewer, it shows a grey box where the viewer should be.

Here's a github repo that reproduces the issue: https://github.com/theivanaguilar/forge-viewer-reload

Am I missing something here?


回答1:


The static method Autodesk.Viewing.Initializer can only be called once the subsequent times it will not return. All other viewer methods need to be invoked every time your component loads. So you need to refactor your code a bit.

My app is using React and I save a boolean in the appState to avoid calling that Initializer twice if it has been initialized already.

Hope that helps



来源:https://stackoverflow.com/questions/47548653/completely-unload-and-reload-forge-viewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!