Search code examples
autodesk-forgeautodesk-viewer

Problem launching Forge Viewer locally instead of through Design Automation/OSS


I’m starting by telling the viewer to launch with the document specified as the bubble.json file:

Helpers.launchViewer('viewerDiv', 'urn:' +  '/resources/41bbc339-294e-4eb1-b5ee-f4f303df46bbviewable/bubble.json');//this.props.modelPath);





function launchViewer(div, urn) {
    getToken.accessToken.then((token) => {
        var options = {
            'document': urn,
            'env': 'Local',
          };

          Autodesk.Viewing.Initializer(options, () => {
            viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById(div));
            viewer.start(options.document, options);
            Autodesk.Viewing.Document.load(urn, options, onDocumentLoadSuccess, onDocumentLoadFailure);
            viewer.loadExtension('Autodesk.ModelStructure');
          });
    });
}

I then get the following errors:

Xhr.js:940 POST http://localhost:3000/oss-ext/v2/acmsessions 404 (Not Found)

Otg.js:198 Uncaught TypeError: Cannot read property 'manifest' of null at Otg.js:198 at Function. (Otg.js:143) at l (Xhr.js:564) at XMLHttpRequest.u (Xhr.js:668)

I wonder if maybe when I'm returning the files from my server if there's information I'm not including that's needed, or if I'm doing something else incorrecty. Thanks!

EDIT: I've also tried loading the result.svf instead of the bubble and get the following error:

Error while processing SVF: {"url":"/derivativeservice/v2/derivatives/urn%3Aresources%2F0d3f37ff-d195-451b-9a3c-35402f326f4dviewable%2Foutput%2F1%2Fresult.svf","exception":"SyntaxError: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL","stack":"Error: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL\n at Object.g._rawGet (blob:http://localhost:3000/a2115ade-285d-4398-8b8b-ae7704e9cc25:1:60485)\n at blob:http://localhost:3000/a2115ade-285d-4398-8b8b-ae7704e9cc25:1:59206\n at n ...


Solution

  • I solved the problem myself - the Autodesk documentation specifies that 'urn:' has to come before the urn when loading a document. Loading the document locally, the relative file path should be used without the 'urn:' affix.