function initBimCfg(that) { if (!that.bimCfg) { that.bimCfg = {} } if (!that.hideParts) { that.hideParts = []; } let config = that.$tryToJson(that.selProject?.bimConfig, {}) that.bimCfg.background = config.background || '' that.bimCfg.showGis = config.showGis || false that.bimCfg.clientApi = config.clientApi || false } function initLoadModel(that, api) { let fnInit = () => { if (api.m_model.size > 0) { setTimeout(() => { initModelPosition(that, api) }, 1000) } else { setTimeout(fnInit, 1000); } } fnInit(); } function initModelPosition(that, api) { that.models.forEach(modelInfo => { if (modelInfo) { let modelId = modelInfo.lightweightName let cfg = that.$tryToJson(modelInfo.bimConfig, {}); let x = cfg?.x || 0; let y = cfg?.y || 0; let z = cfg?.z || 0; let rotateZ = cfg?.rotateZ || 0; let rotateX = cfg?.rotateX || 0; let rotateY = cfg?.rotateY || 0; if (x * 1 + y * 1 + z * 1 != 0) { console.log(x, y, z) api.Model.moveToPosition([x, y, z], 0, modelId) } if (rotateZ * 1 != 0) { if (!this.me.bimCfg.clientApi) { api.Model.rotate(rotateX, rotateY, rotateZ, modelId) } } if (cfg && cfg.hideParts) { cfg.hideParts.forEach(it => { that.hideParts.push(it); }) } setTimeout(() => { api.Model.location(modelId); setTimeout(() => { that.resetScene(); }, 1000); }, 1000); } initHideParts(that, api) }); } function initHideParts(that, api) { let hideCnt = 0; let hideFn = () => { hideCnt++; if (hideCnt > 30) { return; } setTimeout(() => { let featureIds = (that.hideParts || []).map(it => it.featureId); if (featureIds.length > 0) { api.Feature.setVisible(featureIds.join("#"), false); } hideFn(); }, 100) }; hideFn(); } function resetScene(that, api) { that.selectedViewpoint = null; that.selectedRoam = null; api.Camera.stopImmersiveRoam(); api.Model.location(api.m_model.keys().toArray()[0]); if (!that.isClient()) { api.Plugin.deleteMiniMap(); } if (that.viewPoint) { if (that.viewPoint.world) { if (!that.isClient()) { api.Camera.setViewPort(that.viewPoint); } } } } export default { initBimCfg, initLoadModel, initModelPosition, initHideParts, resetScene }