在本地而不是通过 Design 启动 Forge Viewer 时出现问题 Automation/OSS

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

我首先告诉查看器使用指定为 bubble.json 文件的文档启动:

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');
          });
    });
}

然后我收到以下错误:

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)

我想知道当我从我的服务器返回文件时是否有我没有包含的所需信息,或者我是否做错了其他事情。谢谢!

编辑: 我还尝试加载 result.svf 而不是气泡并收到以下错误:

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 ...

我自己解决了这个问题 - Autodesk 文档指定加载文档时 'urn:' 必须位于骨灰盒之前。本地加载文档,相对文件路径不带'urn:'后缀。

  1. 您不需要在离线查看器中添加 urn 前缀
  2. 查看器仅支持 http/https url 作为文档
  3. 参考 0.svf 文件进行渲染

有关更多信息,请查看此