Document.js:54 Uncaught TypeError: Cannot read properties of undefined (reading 'traverse') Autodesk Viewer + React

47 Views Asked by At

Since Sunday, February 18, I am experimenting in this project (react + Autodesk Viewer): Proyect: https://github.com/autodesk-platform-services/viewer-react-sample The following error:

Document.js:54 Uncaught TypeError: Cannot read properties of undefined (reading 'traverse') at new Document (Document.js:54:18) at Function.onSuccess (Document.js:172:29) at onSuccessWrapped (Xhr.js:609:40) at XMLHttpRequest.onLoad (Xhr.js:851:34)

Error Image

enter image description here

Before that date, I didn't have that, the problem didn't exist. I checked the updates and there was one on February 14 but I see no relation to the error. I tried different environments, browsers, computers, etc. Does anyone have any ideas? Updates: https://aps.autodesk.com/en/docs/viewer/v7/change_history/changelog_v7/

Install the proyect with dependencies ,but not run the models .

2

There are 2 best solutions below

0
Petr Broz On

This might be related to a recent change in the Viewer SDK. Before this change, it was possible to call Autodesk.Viewing.Initializer without specifying the env option, and the viewer would try to auto-detect the proper settings based on the URL of the website that's hosting it. After the change, the auto-detected settings might be different, so I'd recommend hard-coding the env property to be on the safe side. Please see this blog post for more details: https://aps.autodesk.com/blog/getting-404-resource-not-found-error-viewer.

0
Gustavo da Costa e Silva On

Making some tests into loadModel function I faced this error too, the solution for me was add the "urn:":

Autodesk.Viewing.Document.load(
   "urn:" + urn,
   onDocumentLoadSuccess,
   onDocumentLoadFailure
);