我刚刚试用了SVF2公共Beta,但无法在Viewer中加载模型。我相信该模型已成功转换,因为返回的清单有:
"name": "XXXX_ARC.nwd",
"progress": "complete",
"outputType": "svf2",
"status": "success"
但是,当我尝试在Viewer中加载模型时,此行将失败:
theViewer.loadModel(svfURL, onItemLoadSuccess, onItemLoadFail);
svfURL是这样的:
以及我从Chrome浏览器中得到的错误: 403 GET errors。好像我没有访问模型的权限?
我还需要做一些其他设置吗?
其他信息:
我已经按照以下步骤设置了Viewer环境:
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
。
答案 0 :(得分:0)
由于您主要提到查看器未加载SVF2,所以我怀疑您可能未指定正确的查看器环境。
这是一些示例代码,请注意必须设置环境和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 :(得分:0)
我正面临着同样的问题。
尽管该模型已转换为SVF2格式,但我的云积分已用完。 清单摘录:
"name": "7085-33cc-9464.rvt",
"progress": "complete",
"outputType": "svf2",
"status": "success"
无论使用哪种设置,查看器中都只会加载SVF格式。 我没有从查看器中收到错误消息,除SVF仍在加载而不是SVF2之外,其他所有内容都像以前一样工作。 查看器初始化选项:
const viewerEnv = await this.initialize({
//env: dbModel.env,
env: "MD20ProdEU",
api: "D3S",
//accessToken: "",
});
答案 2 :(得分:0)
不确定这是否已在单独的线程上解决,但问题可能是 acmSessionId
未在 options
的 loadModel()
中设置 - 参见 https://forge.autodesk.com/blog/403-error-when-trying-view-svf2< /p>
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()