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



我刚刚试用了SVF2公测版,但无法在Viewer中加载模型。我相信模型已经成功翻译,因为返回的清单有:

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

然而,当我试图在Viewer中加载模型时,它会在以下行失败:

theViewer.loadModel(svfURL, onItemLoadSuccess, onItemLoadFail);

svfURL是这样的:

https://cdn.derivative.autodesk.com/modeldata/file/urn:adsk.fluent:fs.file:autodesk-360翻译存储产品/*MyURN*/output/otg_files/0/output/0/otg_model.json

我从Chrome浏览器中得到的错误:403 GET错误。我好像没有访问模型的权限?

我需要做一些额外的设置吗?

其他信息:
我已按如下方式设置查看器环境:

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

我还尝试在创建查看器时删除config3d,但它仍然返回相同的消息。代码进入onDocumentLoadSuccess,但在theViewer.loadModel(svfURL, onItemLoadSuccess, onItemLoadFail);失败,跳到onItemLoadFail

因为您主要提到查看器没有加载SVF2,我可以怀疑您可能没有指定正确的查看器环境。

下面是一些示例代码,请注意必须设置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);
}
});

我也面临同样的问题。

  1. 尽管模型已转换为SVF2格式,但我的云信用额度正在耗尽。清单摘录:

    "name": "7085-33cc-9464.rvt",
    "progress": "complete",
    "outputType": "svf2",
    "status": "success"
    
  2. 无论使用哪种设置,查看器中都只加载SVF格式。我没有从查看器收到错误消息,一切都像以前一样工作,只是SVF仍然加载,而不是SVF2。查看器初始化选项:

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

不确定是否在单独的线程上解决了这个问题,但问题可能是loadModel()options中没有设置acmSessionId-请参阅https://forge.autodesk.com/blog/403-error-when-trying-view-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) })
}

最好的方法是只使用loadDocumentNode()而不是loadModel()

最新更新