Reputation: 4648
Not sure if this is a bug or an issue with script loading order. Using ES5 but in an ES6 capable browser. v6 works. Discovered this while upgrading to v7.
The line in "ChooseViewerItem" (a wrapper function to allow me to change viewables) - calls
viewer.loadDocumentNode(document, viewable).then(onItemLoadSuccess, onItemLoadFail);
What am I missing?
Uncaught TypeError: avDocument.getViewableUrn is not a function
loadDocumentNode Viewer3D.js:1738
ChooseViewerItem a9dcd494-cecb-4391-a14e-834f7c7d8172:1280
onDocumentLoadSuccess a9dcd494-cecb-4391-a14e-834f7c7d8172:1298
onSuccess Document.js:174
onSuccessWrapped Xhr.js:565
onLoad Xhr.js:669
_rawGet Xhr.js:707
rawGet Xhr.js:573
pendGo index.js:54
go index.js:13
rawGet Xhr.js:557
getManifest Xhr.js:855
doLoad Document.js:227
load Document.js:231
launchViewer a9dcd494-cecb-4391-a14e-834f7c7d8172:1272
promise callback*Initializer envinit.js:629
launchViewer a9dcd494-cecb-4391-a14e-834f7c7d8172:1261
<anonymous> a9dcd494-cecb-4391-a14e-834f7c7d8172:922
Angular 18
jQuery 13
Viewer3D.js:1738
Upvotes: 0
Views: 283
Reputation: 9942
The Document class is bundled with all the other basic classes in the viewer3D.js file so there should be no problems with loading order.
I'd suggest checking if the object you are passing into the loadDocumentNode
method is actually an instance of Document
.
Here's how models/viewables are typically loaded with Forge Viewer v7.*:
async function loadModelViewable(viewer, urn, guid = null) {
function onDocumentLoadSuccess(doc) {
if (guid) {
viewer.loadDocumentNode(doc, doc.getRoot().findByGuid(guid));
} else {
viewer.loadDocumentNode(doc, doc.getRoot().getDefaultGeometry());
}
}
function onDocumentLoadFailure(code, message) {
console.error(message);
}
Autodesk.Viewing.Document.load('urn:' + urn, onDocumentLoadSuccess, onDocumentLoadFailure);
}
Upvotes: 1