我正在关注 Node.js 语言的“查看 BIM 360 和融合模型”教程
https://learnforge.autodesk.io/#/tutorials/viewhubmodels
我按照教程创建了一个文件夹结构,我的服务器也在监听。
现在我想在查看器中叠加多个模型,例如:Arch、structure & MEP, 如何添加代码以及在哪里?请帮忙 请参阅下面来自 Visual Studio 代码的文件夹的屏幕截图
答案 0 :(得分:0)
viewhubmodels 示例使用对象树中的选定版本在查看器上呈现特定的骨灰盒,因此您需要更改此默认逻辑。 要利用此示例实现多模型,请参阅 multi-model refresher 博文。
您可以通过单击实现示例中博客文章中描述的 addViewable 函数来聚合模型。
您可以通过更改 ForgeViewer.js 来实现它。更准确地说Initializer。
每当我们点击一个项目版本时,示例就会为 viewer 分配一个新值。我们可以更改此行为以在点击时聚合新模型,而不是通过以下代码更改当前 Initializer 来替换它们:
if(!!viewer){
addViewable(viewer, urn);
}
else{
viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('forgeViewer'), { extensions: ['Autodesk.DocumentBrowser'] });
viewer.start();
var documentId = 'urn:' + urn;
Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure);
}
addViewable 由前面提到的博客文章定义。
async function addViewable(viewer, urn, xform, offset) {
return new Promise(function (resolve, reject) {
function onDocumentLoadSuccess(doc) {
const viewable = doc.getRoot().getDefaultGeometry();
const options = {
preserveView: true,
keepCurrentModels: true
};
if (xform) {
options.placementTransform = xform;
}
if (offset) {
options.globalOffset = offset;
}
viewer.loadDocumentNode(doc, viewable, options)
.then(resolve)
.catch(reject);
}
function onDocumentLoadFailure(code) {
reject(`Could not load document (${code}).`);
}
Autodesk.Viewing.Document.load('urn:' + urn, onDocumentLoadSuccess, onDocumentLoadFailure);
});
}