94 lines
2.6 KiB
JavaScript
94 lines
2.6 KiB
JavaScript
|
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 initBimGis(that, api) {
|
||
|
if (that.bimCfg.showGis) {
|
||
|
api.Public.setGisState(true);
|
||
|
api.Public.setTerrainState(false, "http://113.201.2.107:9304/layer.json", false)
|
||
|
api.Public.setGisState(true);
|
||
|
} else if (that.bimCfg.background) {
|
||
|
api.Public.setGisState(false, that.bimCfg.background);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
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;
|
||
|
if (x * 1 + y * 1 + z * 1 != 0) {
|
||
|
console.log("移动模型", modelId, x, y, z)
|
||
|
api.Model.moveToPosition([x, y, z], 0, modelId)
|
||
|
}
|
||
|
if (rotateZ * 1 != 0) {
|
||
|
api.Model.rotate(0, 0, 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();
|
||
|
}
|
||
|
|
||
|
export default {
|
||
|
initBimCfg,
|
||
|
initBimGis,
|
||
|
initLoadModel,
|
||
|
initModelPosition,
|
||
|
initHideParts
|
||
|
}
|