I am using the Autodesk Forge Viewer v7.18.0 along with a custom extension that uses the new SceneBuilder to add 3d Geometries in the Viewer itself.
While using this, when the user switches from one file to another, basically loading a different SVF file, we remove all the fragments in the modelBuilder created by the SceneBuilder and then call the
Autodesk.Viewing.Document.load(fileUrn, onDocumentLoadSuccess, onDocumentLoadFailure)
and in the onDocumentLoadSuccess()
, we call the function
//The viewable is fetched from the file based on certain criteria
viewer.loadDocumentNode(doc, viewable, loadOptions)
This on the first load of a new file gives the following error and I am not sure how to fix that:
Uncaught TypeError: Cannot read property 'dispatchEvent' of null
at f.dispose (FragmentList.js:782)
at u.dtor (RenderModel.js:144)
at H.unloadModel (Viewer3DImpl.js:2763)
at H.unloadCurrentModel (Viewer3DImpl.js:2925)
at T.Z.tearDown (Viewer3D.js:800)
at T.tearDown (GuiViewer3D.js:180)
at T.Z.loadDocumentNode (Viewer3D.js:1713)
at onDocumentLoadSuccess (eval at <anonymous> (jquery.min.js:1), <anonymous>:142:12)
at Function.p (Document.js:146)
at l (Xhr.js:564)
The same error doesn't show up if the new file is loaded again and it works as expected.
Any help is highly appreciated.
As you can see in the stack trace, when a Model
/RenderModel
object is unloaded (when switching to another SVF), it will automatically dispose all its fragments, so you don't have to do that manually.
If you still get this error even without manually removing the fragments, it might be a bug in the SceneBuilder
extension. In that case please submit a bug report to forge (dot) help (at) autodesk (dot) com
.