简体   繁体   English

无法在 Autodesk Forge Viewer 中加载 SVF2 模型

[英]Cannot load SVF2 model in Autodesk Forge Viewer

I just tried out the SVF2 public beta but couldn't get the model to load in the Viewer.我刚刚尝试了 SVF2 公开测试版,但无法在查看器中加载模型。 I believe the model was translated successfully since the manifest returned has:我相信模型已成功翻译,因为返回的清单具有:

"name": "XXXX_ARC.nwd",
"progress": "complete",
"outputType": "svf2",
"status": "success"

However, when I tried to load the model in Viewer, it would fail on this line:但是,当我尝试在 Viewer 中加载模型时,它会在这一行失败:

theViewer.loadModel(svfURL, onItemLoadSuccess, onItemLoadFail);

The svfURL is something like this: svfURL 是这样的:

https://cdn.derivative.autodesk.com/modeldata/file/urn:adsk.fluent:fs.file:autodesk-360-translation-storage-prod/*MyURN*/output/otg_files/0/output/0/otg_model.json https://cdn.derivative.autodesk.com/modeldata/file/urn:adsk.fluent:fs.file:autodesk-360-translation-storage-prod/*MyURN*/output/otg_files/0/output/0/ otg_model.json

And the errors I got from Chrome browser: 403 GET errors .还有我从 Chrome 浏览器得到的错误403 GET errors Seems like I don't have privilege to access the model?好像我没有权限访问模型?

Is there some additional setting I need to do?我需要做一些额外的设置吗?

Additional Info:附加信息:
I have setup the Viewer environment as follows:我已按如下方式设置查看器环境:

var options = {
    env: 'MD20ProdUS',
    api: 'D3S',
    getAccessToken: getForgeToken
};

var documentId = 'urn:' + urn;

Autodesk.Viewing.Initializer(options, function onInitialized() {
    var htmlDiv = document.getElementById('forgeViewer');
    var config3d = {
      extensions: ['ToolbarExtension', 'HandleSelectionExtension', .....a few extensions ],
      loaderExtensions: { svf: "Autodesk.MemoryLimited" }
    };
    
    theViewer = new Autodesk.Viewing.GuiViewer3D(htmlDiv, config3d);
    var startedCode = theViewer.start();
    if (startedCode > 0) {
        console.error('Failed to create a Viewer: WebGL not supported.');
        return;
    }
    Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
});

I have also tried removing the config3d when creating the viewer but it still returned the same messages.我还尝试在创建查看器时删除config3d ,但它仍然返回相同的消息。 The code got into onDocumentLoadSuccess but failed at theViewer.loadModel(svfURL, onItemLoadSuccess, onItemLoadFail);代码进入onDocumentLoadSuccess但在theViewer.loadModel(svfURL, onItemLoadSuccess, onItemLoadFail); , jumping into onItemLoadFail . ,跳入onItemLoadFail

Because you mention mainly the viewer not loading the SVF2, I can suspect that maybe you have not specified the correct Viewer environment.因为您主要提到查看器未加载 SVF2,所以我怀疑您可能没有指定正确的查看器环境。

Here is some sample code, and pay attention to the options where you have to set env and API:下面是一些示例代码,请注意必须设置 env 和 API 的选项:

 var viewer; var options = { // These are the SVF2 viewing settings during public beta env: 'MD20ProdUS', // or MD20ProdEU (for EMEA) api: 'D3S', getAccessToken: getForgeToken }; var documentId = 'urn:' + getUrlParameter('urn'); // Run this when the page is loaded Autodesk.Viewing.Initializer(options, function onInitialized() { // Find the element where the 3d viewer will live. var htmlElement = document.getElementById('MyViewerDiv'); if (htmlElement) { // Create and start the viewer in that element viewer = new Autodesk.Viewing.GuiViewer3D(htmlElement); viewer.start(); // Load the document into the viewer. Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure); } });

I am facing the same problem.我面临同样的问题。

  1. Although the model has been converted to SVF2 format, my cloud credits are being used up .虽然模型已经转成SVF2格式,但是我的云积分正在用完。 An excerpt from the manifest:清单摘录:

     "name": "7085-33cc-9464.rvt", "progress": "complete", "outputType": "svf2", "status": "success"
  2. No matter with which settings, only the SVF format is loaded in the viewer.无论使用哪种设置,在查看器中都只加载 SVF 格式。 I don't get an error message from the viewer, everything works as before, except that SVF is still loaded and not SVF2.我没有从查看器收到错误消息,一切都像以前一样,除了 SVF 仍然加载而不是 SVF2。 Viewer init options:查看器初始化选项:

     const viewerEnv = await this.initialize({ //env: dbModel.env, env: "MD20ProdEU", api: "D3S", //accessToken: "", });

Not sure if this has been solved on a separate thread, but the issue was probably that acmSessionId was not set in the options for loadModel() - seehttps://forge.autodesk.com/blog/403-error-when-trying-view-svf2不知道这是否已经解决了在一个单独的线程,但问题是可能是acmSessionId没有在设置optionsloadModel() -见https://forge.autodesk.com/blog/403-error-when-trying -查看-svf2

function onDocumentLoadSuccess(doc) {
  let items = doc.getRoot().search({
    'type': 'geometry',
    'role': '3d'
  }, true)

  let url = doc.getViewablePath(items[0])

  viewer.loadModel(url, { acmSessionId: doc.getAcmSessionId(url) })
}

The best thing is to just use loadDocumentNode() instead of loadModel()最好的办法是只使用loadDocumentNode()而不是loadModel()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM