大屏BIM漫游客户端渲染

dev_xd
lj7788@126.com 2025-08-19 18:01:44 +08:00
parent fca1934db0
commit aef62e391c
13 changed files with 180 additions and 134 deletions

View File

@ -146,7 +146,7 @@ const ganttStyle = {
},
};
function initEngine(that) {
if (that.isClient()) {
if (that.clientShow()) {
apiTools.loadEngine(that, "bim4DContainer", 'bim4DApi',
() => {
initLoadModel(that);
@ -206,7 +206,7 @@ function addModel(that, modelId, cb) {
let url = `${window.config.modelUrl}/Tools/output/model/${modelId}/root.glt`;
let direction = null;
let modelInfo = that.models.find(m => m.modelId == modelId);
if (that.isClient()) {
if (that.clientShow()) {
url = `/bimdata/Tools/output/model/${modelId}/root.glt`;
if (modelInfo) {
direction = modelInfo.bimCfg.direction;
@ -224,7 +224,7 @@ function addModel(that, modelId, cb) {
setTimeout(() => {
if (that.viewPoint) {
if (that.viewPoint.world) {
if (!that.isClient()) {
if (!that.clientShow()) {
api.Camera.setViewPort(that.viewPoint);
}
}

View File

@ -164,14 +164,20 @@ function addModel(api, bimCfg, modelId, cb, models) {
let rotateX = cfg?.rotateX || 0;
let rotateY = cfg?.rotateY || 0;
if (x * 1 + y * 1 + z * 1 != 0) {
if(bimCfg.showGis){
api.Model.moveToPosition([x*1, y*1, z*1], 0, modelId)
}
}
if (rotateZ * 1 != 0) {
if (this.me.bimCfg.clientApi) {
} else {
if(bimCfg.showGis){
api.Model.rotate(rotateX, rotateY, rotateZ, modelId)
}
}
}
if (cfg && cfg.hideParts) {
cfg.hideParts.forEach(it => {
@ -262,13 +268,18 @@ function initModelPosition(that, api) {
let rotateY = cfg?.rotateY || 0;
if (x * 1 + y * 1 + z * 1 != 0) {
console.log(x, y, z)
if(that.bimCfg.showGis){
api.Model.moveToPosition([x, y, z], 0, modelId)
}
}
if (rotateZ * 1 != 0) {
if (!this.me.bimCfg.clientApi) {
if(that.bimCfg.showGis){
api.Model.rotate(rotateX, rotateY, rotateZ, modelId)
}
}
}
if (cfg && cfg.hideParts) {
cfg.hideParts.forEach(it => {
that.hideParts.push(it);
@ -307,7 +318,17 @@ function initHideParts(that, api) {
function resetScene(that, api) {
that.selectedViewpoint = null;
that.selectedRoam = null;
try{
if(that.isClient){
api.Camera.IRPlayCancle()
api.Camera.stopViewPortRoam()
}else{
api.Camera.stopViewPortRoam()
api.Camera.stopImmersiveRoam();
}
}catch(e){
}
api.Model.location(api.m_model.keys().toArray()[0]);
if (!that.bimCfg.clientApi) {
api.Plugin.deleteMiniMap();
@ -317,6 +338,11 @@ function resetScene(that, api) {
if (!that.bimCfg.clientApi) {
api.Camera.setViewPort(that.viewPoint);
}
}else{
if(that.bimCfg.clientApi){
let pt=that.viewPoint;
api.Camera.SetCamera(pt.position, pt.heading, pt.pitch)
}
}
}
}

View File

@ -202,7 +202,7 @@ function clearEvent(that) {
let api = bimBriefingApi;
if (api) {
actorShow(that);
if (!that.isClient()) {
if (!that.clientShow()) {
api.Feature.getByEvent(false);
api.Model.clearBoundsBox();

View File

@ -152,8 +152,8 @@ export default {
window.D4App = this;
},
methods: {
isClient() {
return this.bimCfg.clientApi;
clientShow() {
return this.bimCfg?.clientApi || false;
},
doSaveSetting() {
if (isNaN(parseInt(this.playTime))) {

View File

@ -270,8 +270,8 @@ export default {
this.initEngine();
},
methods: {
isClient() {
return this.bimCfg.clientApi;
clientShow() {
return this.bimCfg?.clientApi || false;
},
clearAllHide() {
this.$confirm("确定要显示所有构件吗?", "提示", {
@ -516,7 +516,7 @@ export default {
this.attributeInformation = "";
bimTools.initBimCfg(this);
setTimeout(() => {
if (this.isClient()) {
if (this.clientShow()) {
apiTools.loadEngine(this, "bimBriefingContainer", 'bimBriefingApi', this.initLoadModel)
} else {
sapiTools.loadEngine(this, "bimBriefingContainer", 'bimBriefingApi', this.initLoadModel)
@ -631,7 +631,7 @@ export default {
let url = `${window.config.modelUrl}/Tools/output/model/${modelId}/root.glt`;
let direction = null;
let modelInfo = this.models.find(m => m.modelId == modelId);
if (this.isClient()) {
if (this.clientShow()) {
url = `/bimdata/Tools/output/model/${modelId}/root.glt`;
if (modelInfo) {
direction = modelInfo.bimCfg.direction;
@ -648,7 +648,7 @@ export default {
console.log("加载模型成功");
setTimeout(() => {
if (this.viewPoint) {
if (!this.isClient()) {
if (!this.clientShow()) {
api.Camera.setViewPort(this.viewPoint);
}
} else {

View File

@ -853,60 +853,16 @@ export default {
this.loadDevicePosition();
setTimeout(() => {
bimTools.setDefaultViewPoint(window.bimMgrApi, this.bimCfg, this.viewPoint)
this.hideParts=hideParts;
bimTools.hideParts(window.bimMgrApi, hideParts);
this.modelLoadSuccess = true;
this.resetScene();
}, 1000);
});
// this.models.forEach((item) => {
// this.addModel(item.lightweightName);
// });
//bimTools.initLoadModel(this, bimMgrApi)
}
});
},
// addModel(modelId, cb) {
// let url = `${window.config.modelUrl}/Tools/output/model/${modelId}/root.glt`;
// let direction = null;
// let modelInfo = this.models.find(m => m.modelId == modelId);
// if (this.isClient) {
// url = `/bimdata/Tools/output/model/${modelId}/root.glt`;
// if (modelInfo) {
// direction = modelInfo.bimCfg.direction;
// }
// }
// let api = bimMgrApi;
// console.log(modelId, url);
// api.Model.add(
// url,
// modelId,
// () => { },
// () => {
// cb && cb();
// console.log("");
// this.loadDevicePosition();
// setTimeout(() => {
// if (this.isClient) {
// } else {
// if (this.viewPoint) {
// api.Camera.setViewPort(this.viewPoint);
// } else {
// api.Camera.getViewPort((p) => {
// this.viewPoint = p;
// });
// }
// }
// this.modelLoadSuccess = true;
// api.Model.location(modelId)
// }, 1000);
// }, direction
// );
// },
changeMode(mode) {
if (!this.modelLoadSuccess) {
this.$message.error("模型加载中,请稍后");
@ -922,6 +878,7 @@ export default {
api.Model.original(it.lightweightName);
api.Model.setAlpha(it.lightweightName, 1);
});
bimTools.hideParts(api, this.hideParts);
this.resetScene();
} else {
this.$api.planSchedule.findPlanProgress(this.selProject.id).then((d) => {
@ -957,7 +914,6 @@ export default {
});
}
});
//console.log("====>",beforeData,afterData,processData,standData);
if (allData.length > 0) {
allData = allData.map((item) => item.featureId);
this.models.forEach((model) => {

View File

@ -121,6 +121,7 @@ export default {
selectedRoam: null,
modelLoaded: false,
isPlay: false,
isClient: false,
};
},
mounted() {
@ -144,8 +145,8 @@ export default {
this.initEngine();
},
methods: {
isClient() {
return this.bimCfg.clientApi;
clientShow() {
return this.bimCfg?.clientApi || false;
},
loadNode(node, resolve) {
let that = this;
@ -191,7 +192,6 @@ export default {
}
},
getTreeChildren(node, resolve) {
let that = this;
let data = node.data;
this.$api.bim.getModelTree(data.modelId, data.glid).then((d) => {
let tmps = (d.data || []).map((it) => {
@ -217,18 +217,50 @@ export default {
return o;
},
playIRPause(data) {
let api = bimRoadmApi;
data.play = 2;
this.isPlay = false;
if (data.roamingType == 2) {//
api.Camera.pauseViewPortRoam(false)
return;
}
if (this.isClient) {
bimRoadmApi.Camera.PlayIRPause();
} else {
bimRoadmApi.Camera.pauseImmersiveRoam(false);
}
},
playClient(data) {
let api = bimRoadmApi;
api.Camera.startViewPortRoam(JSON.parse(data.points), 0, data.time * 1000, (res) => {
this.isRoamingHistory = false
data.play = 0
this.$message.info('漫游结束!')
this.resetScene()
})
},
playContinue(data) {
let api = bimRoadmApi;
data.play = 1;
this.isPlay = true;
if (data.roamingType == 2) {//
if (this.isClient) {
this.playClient(data)
} else {
api.Camera.pauseViewPortRoam(true)
}
return;
}
if (this.isClient) {
bimRoadmApi.Camera.PlayIRContinue();
} else {
bimRoadmApi.Camera.pauseImmersiveRoam(true);
}
},
playCancle(data) {
this.isPlay = false;
let api = bimRoadmApi;
if (data) {
data.play = 0;
this.selectedRoam = null;
@ -237,8 +269,36 @@ export default {
this.roamingList.find((x) => x.play === 1).play = 0;
}
}
bimRoadmApi.Camera.cancelPlayImmersiveRoam();
if (data && data.roamingType == 2) {//
if (this.isClient) {
api.Camera.IRPlayCancle()
} else {
api.Camera.stopViewPortRoam()
}
this.resetScene();
return;
}
if (this.isClient) {
bimRoadmApi.Camera.IRPlayCancle()
} else {
bimRoadmApi.Camera.cancelPlayImmersiveRoam();
}
this.resetScene();
},
doPlayCustomView(data) {
//
let api = bimRoadmApi;
if (this.isClient) {
this.playClient(data)
return;
}
api.Camera.startViewPortRoam(JSON.parse(data.points), data.time, (res) => {
this.isRoamingHistory = false
data.play = 0
this.$message.info('漫游结束!')
this.resetScene()
})
},
startRoaming(data) {
if (!this.modelLoaded) {
@ -246,14 +306,31 @@ export default {
return;
}
let api = bimRoadmApi;
this.playCancle();
this.playCancle(data);
if (this.roamingList.findIndex((x) => x.play === 1) > -1) {
this.roamingList.find((x) => x.play === 1).play = 0;
}
data.play = 1;
if (data.roamingType == 2) {
this.doPlayCustomView(data);
return;
}
let record = typeof data.points === "string" ? JSON.parse(data.points) : data.points;
if (this.isClient) {
this.selectedRoam = data;
this.isPlay = true;
api.Camera.PlayIRCamera({
records: data.points,
complete: () => {
this.selectedRoam = null;
data.play = 0;
this.isPlay = false;
}
})
return;
}
api.Camera.setImmersiveRoamConfig({
roamingMode: data.roamingMode,
moveRate: data.moveRate,
@ -294,6 +371,7 @@ export default {
it.visible = true;
api.Model.setVisible(it.modelId, true);
api.Model.original(it.modelId);
bimTools.hideParts(window.bimRoadmApi, this.hideParts);
});
} else {
that.models.forEach((it) => {
@ -305,6 +383,7 @@ export default {
if (checked) {
api.Model.setVisible(node.modelId, true);
api.Model.original(node.modelId);
bimTools.hideParts(window.bimRoadmApi, this.hideParts);
this.models.find((mm) => mm.modelId == node.modelId).visible = true;
} else {
api.Model.setVisible(node.modelId, false);
@ -340,6 +419,7 @@ export default {
this.setFeatueVisible(tmps, true);
}
}
bimTools.hideParts(window.bimRoadmApi, this.hideParts);
}
},
setFeatueVisible(featureIds, show) {
@ -376,18 +456,18 @@ export default {
if (!this.selProject) {
return;
}
bimTools.initBimCfg(this);
this.elId++;
this.activeMenu = 0;
bimTools.initBimCfg(this);
setTimeout(() => {
if (this.isClient()) {
apiTools.loadEngine(this, "bimRoamingContainer", 'bimRoadmApi', this.initLoadModel)
} else {
sapiTools.loadEngine(this, "bimRoamingContainer", 'bimRoadmApi', this.initLoadModel)
}
bimTools.initEngine("bimRoadmApi", "bimRoamingContainer", this.bimCfg, this.initLoadModel);
}, 10);
},
initLoadModel() {
if (this.selProject == null) {
return;
}
this.$api.bim.getDefaultViewPoint(this.selProject.id, 1).then((d) => {
let pt = "";
if (d.data && d.data.length > 0) {
@ -417,18 +497,24 @@ export default {
if (this.models.length == 0) {
this.$modal.error("暂无模型,请先关联模型");
} else {
bimTools.addModelList(window.bimRoadmApi, this.bimCfg, this.models, (hideParts) => {
setTimeout(() => {
bimTools.setDefaultViewPoint(window.bimRoadmApi, this.bimCfg, this.viewPoint)
this.hideParts = hideParts;
bimTools.hideParts(window.bimRoadmApi, hideParts);
this.modelLoaded = true;
this.resetScene();
}, 1000);
});
this.models.forEach((item) => {
item.modelId = item.lightweightName;
item.gis = JSON.parse(item.gisJson);
this.addModel(item.lightweightName);
setTimeout(() => {
this.$refs.tree.setChecked(item.lightweightName, true, true);
}, 3000);
});
this.treeKey++;
bimTools.initLoadModel(this, bimRoadmApi)
}
});
this.init();
@ -453,7 +539,6 @@ export default {
loadRoaming() {
this.$api.bim
.roamingGet({
roamingType: 1,
projectId: this.selProject.id,
pageSize: 100,
pageNum: 1,
@ -463,7 +548,7 @@ export default {
list.forEach((item) => {
item.play = 0;
});
this.roamingList = list;
this.roamingList = list.filter(x => (x.roamingMode == (this.isClient ? "Client" : 0) && x.roamingType == 2) || x.roamingType == 1);
this.roamingLoading = false;
});
},
@ -474,8 +559,14 @@ export default {
}
this.playCancle();
this.selectedViewpoint = item;
let pt = JSON.parse(item.viewPosition)
if (item.viewPosition != null) {
bimRoadmApi.Camera.setViewPort(JSON.parse(item.viewPosition));
if (this.isClient) {
bimRoadmApi.Camera.SetCamera(pt.position, pt.heading, pt.pitch)
} else {
bimRoadmApi.Camera.setViewPort(pt);
}
}
},
loadModelTree() {
@ -532,51 +623,13 @@ export default {
};
node.children = makeTree(objs.filter((item) => item.level == 0));
node.children.forEach((item) => {
//this.treeExpendedKeys.push(item.key)
this.treeExpendedKeys.push(item.key)
});
this.treeKey++;
});
},
addModel(modelId, cb) {
let url = `${window.config.modelUrl}/Tools/output/model/${modelId}/root.glt`;
console.log(modelId, url);
let direction = null;
let modelInfo = this.models.find(m => m.modelId == modelId);
if (this.isClient()) {
url = `/bimdata/Tools/output/model/${modelId}/root.glt`;
if (modelInfo) {
direction = modelInfo.bimCfg.direction;
}
}
let api = bimRoadmApi;
api.Model.add(
url,
modelId,
() => { },
() => {
cb && cb();
console.log("加载模型成功");
setTimeout(() => {
if (this.viewPoint) {
if (this.viewPoint.world) {
if (!this.isClient()) {
api.Camera.setViewPort(this.viewPoint);
}
}
} else {
api.Camera.getViewPort((p) => {
this.viewPoint = p;
});
}
this.modelLoaded = true;
}, 1000);
}, direction
);
},
resetScene() {
bimTools.resetScene(this,bimRoadmApi)
bimTools.resetScene(this, bimRoadmApi)
},
},
};

View File

@ -7,7 +7,7 @@ function resolve(dir) {
module.exports = defineConfig({
transpileDependencies: true,
publicPath: process.env.NODE_ENV==='production'? "./":"./xdbs",
publicPath: process.env.NODE_ENV==='production'? "./":"/xdbs",
productionSourceMap: false,
devServer: {
host: "0.0.0.0",

View File

@ -275,7 +275,7 @@ export default {
ElMessage.success('漫游结束')
that.isRoaming = true
api.Camera.stopViewPortRoam()
this.resetScane()
this.resetScene()
},
//
SaveRoam() {
@ -307,7 +307,7 @@ export default {
time: 10,
name: '',
}
this.resetScane()
this.resetScene()
this.$refs.ruleForm.resetFields()
} else {
ElMessage.error('保存失败!')
@ -330,11 +330,15 @@ export default {
this.isRoamingHistory = false
data.play = 0
ElMessage.info('漫游结束!')
this.resetScane()
this.resetScene()
})
},
resetScane() {
resetScene() {
try{
api.Camera.stopViewPortRoam()
}catch(e){
}
api.Model.location(api.m_model.keys().toArray()[0])
},
//
@ -356,7 +360,7 @@ export default {
this.isRoamingHistory = false
data.play = 0
ElMessage.info('漫游结束!')
this.resetScane()
this.resetScene()
})
},
//
@ -368,7 +372,7 @@ export default {
api.Camera.IRPlayCancle()
}
api.Camera.stopViewPortRoam()
this.resetScane()
this.resetScene()
}
},
//

View File

@ -190,6 +190,7 @@ export default {
bimTools.setDefaultViewPoint(window.api, this.me.bimCfg, this.me.viewPoint)
bimTools.hideParts(window.api, hideParts);
cb && cb();
this.me.resetScene();
this.$emit("change");
}, 1000);
});

View File

@ -336,7 +336,7 @@ export default {
title: [],
remark: "",
};
that.resetScane();
that.resetScene();
that.$refs.form.resetFields();
that.visible = false;
that.getList();
@ -348,7 +348,7 @@ export default {
});
});
},
resetScane() {
resetScene() {
api.Camera.stopViewPortRoam();
api.Model.location(api.m_model.keys().toArray()[0]);
},

View File

@ -163,15 +163,20 @@ function addModel(api, bimCfg, modelId, cb, models) {
let rotateX = cfg?.rotateX || 0;
let rotateY = cfg?.rotateY || 0;
if (x * 1 + y * 1 + z * 1 != 0) {
if(bimCfg.showGis){
api.Model.moveToPosition([x*1, y*1, z*1], 0, modelId)
}
}
if (rotateZ * 1 != 0) {
if (this.me.bimCfg.clientApi) {
} else {
if(bimCfg.showGis){
api.Model.rotate(rotateX, rotateY, rotateZ, modelId)
}
}
}
if (cfg && cfg.hideParts) {
cfg.hideParts.forEach(it => {
hideParts.push(it);

View File

@ -419,6 +419,7 @@ export default {
setTimeout(() => {
BimTools.setDefaultViewPoint(window.sandSettingApi, this.bimCfg, this.viewPoint)
BimTools.hideParts(window.sandSettingApi, hideParts);
this.resetScene();
}, 1000);
});