webGl旋转问题解决
parent
1073c8a188
commit
cff600a3b7
|
@ -17,7 +17,7 @@
|
|||
|
||||
<script>
|
||||
import {
|
||||
getModelFeatureInfos,updateBimModel
|
||||
getModelFeatureInfos, updateBimModel
|
||||
} from "@/api/bim/bimModel";
|
||||
export default {
|
||||
props: {
|
||||
|
@ -33,32 +33,36 @@ export default {
|
|||
hideEl: 0,
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
hideParts(val){
|
||||
this.me.hideParts=val;
|
||||
watch: {
|
||||
hideParts(val) {
|
||||
this.me.hideParts = val;
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
doSaveHide(){
|
||||
isClient() {
|
||||
return this.me.bimCfg.clientApi;
|
||||
},
|
||||
doSaveHide() {
|
||||
this.$modal.confirm("确定保存吗?").then(() => {
|
||||
let obj={};
|
||||
this.hideParts.forEach(it=>{
|
||||
let modelId=it.modelId;
|
||||
if(!obj[modelId]){
|
||||
obj[modelId]=[];
|
||||
let obj = {};
|
||||
this.hideParts.forEach(it => {
|
||||
let modelId = it.modelId;
|
||||
if (!obj[modelId]) {
|
||||
obj[modelId] = [];
|
||||
}
|
||||
obj[modelId].push({
|
||||
featureId:it.featureId,
|
||||
externalId:it.externalId,
|
||||
modelId:it.modelId,
|
||||
info:it.info
|
||||
featureId: it.featureId,
|
||||
externalId: it.externalId,
|
||||
modelId: it.modelId,
|
||||
info: it.info
|
||||
});
|
||||
})
|
||||
for(let modelId in obj){
|
||||
let modelInfo=this.me.models.find(it=>it.modelId==modelId);
|
||||
if(modelInfo){
|
||||
modelInfo.bimCfg.hideParts=obj[modelId];
|
||||
modelInfo.bimConfig=JSON.stringify(modelInfo.bimCfg);
|
||||
for (let modelId in obj) {
|
||||
let modelInfo = this.me.models.find(it => it.modelId == modelId);
|
||||
if (modelInfo) {
|
||||
modelInfo.bimCfg.hideParts = obj[modelId];
|
||||
modelInfo.bimConfig = JSON.stringify(modelInfo.bimCfg);
|
||||
updateBimModel(modelInfo).then(res => {
|
||||
this.$message.success("保存成功");
|
||||
});
|
||||
|
@ -80,7 +84,8 @@ export default {
|
|||
},
|
||||
doHideFeatures(hideParts) {
|
||||
let that = this;
|
||||
this.hideParts=hideParts||[];
|
||||
this.hideParts = hideParts || [];
|
||||
if (!this.isClient()) {
|
||||
api.Public.clearHandler();
|
||||
api.Feature.getByEvent(false);
|
||||
api.Feature.getByEvent(true, async (n) => {
|
||||
|
@ -95,6 +100,24 @@ export default {
|
|||
that.hideEl++;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
api.Public.pickupCoordinate(false);
|
||||
api.Public.event("LEFT_CLICK", (t) => {
|
||||
api.Feature.GetFeatureByEvent(t.position, async n => {
|
||||
if (n && n["id"]) {
|
||||
let featureId = n.id;
|
||||
let datas = await that.getServerFeatureInfos(that, [featureId]);
|
||||
datas.forEach(it => {
|
||||
that.hideParts.push(it);
|
||||
});
|
||||
//that.hideParts.push(featureId);
|
||||
api.Feature.setVisible(featureId, false);
|
||||
that.hideEl++;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
async getServerFeatureInfos(that, ids) {
|
||||
if (ids.length == 0) {
|
||||
|
@ -128,6 +151,7 @@ export default {
|
|||
.hide-features {
|
||||
padding: 0px 0px 20px;
|
||||
height: 80vh;
|
||||
|
||||
.sel-list {
|
||||
padding: 0px 10px 10px;
|
||||
height: 100%;
|
||||
|
|
|
@ -185,10 +185,17 @@ export default {
|
|||
},
|
||||
addModel(modelId, cb) {
|
||||
let url = `${window.config.modelUrl}/Tools/output/model/${modelId}/root.glt`;
|
||||
let modelInfo = this.projectMessage.find(m => m.modelId == modelId);
|
||||
let direction = null;
|
||||
if (this.me.bimCfg.clientApi) {
|
||||
url = `/bimdata/Tools/output/model/${modelId}/root.glt`;
|
||||
if (modelInfo) {
|
||||
direction = modelInfo.bimCfg.direction;
|
||||
}
|
||||
}
|
||||
console.log("加载模型:" + url);
|
||||
|
||||
|
||||
api.Model.add(
|
||||
url,
|
||||
modelId,
|
||||
|
@ -197,7 +204,7 @@ export default {
|
|||
},
|
||||
() => {
|
||||
console.log("加载模型成功");
|
||||
let modelInfo = this.projectMessage.find(m => m.modelId == modelId);
|
||||
|
||||
if (modelInfo) {
|
||||
let cfg = modelInfo.bimCfg;
|
||||
let x = cfg?.x || 0;
|
||||
|
@ -208,9 +215,9 @@ export default {
|
|||
api.Model.moveToPosition([x, y, 0], 0, modelId)
|
||||
}
|
||||
if (rotateZ * 1 != 0) {
|
||||
if(this.me.bimCfg.clientApi){
|
||||
if (this.me.bimCfg.clientApi) {
|
||||
|
||||
}else{
|
||||
} else {
|
||||
api.Model.rotate(0, 0, rotateZ, modelId)
|
||||
}
|
||||
}
|
||||
|
@ -249,6 +256,7 @@ export default {
|
|||
setTimeout(() => {
|
||||
let featureIds = (this.me.hideParts || []).map(it => it.featureId);
|
||||
if (featureIds.length > 0) {
|
||||
console.log("隐藏", featureIds.join("#"));
|
||||
api.Feature.setVisible(featureIds.join("#"), false);
|
||||
}
|
||||
hideFn();
|
||||
|
@ -256,8 +264,7 @@ export default {
|
|||
};
|
||||
hideFn();
|
||||
}, 1000);
|
||||
}
|
||||
);
|
||||
}, direction);
|
||||
},
|
||||
onCheckTree(checkNode, event) {
|
||||
let checked = event.checkedNodes.includes(checkNode);
|
||||
|
|
|
@ -21,25 +21,37 @@
|
|||
</el-form-item>
|
||||
<div class="button-group">
|
||||
<el-button type="primary" @click="updatePosition">更新位置</el-button>
|
||||
|
||||
</div>
|
||||
<template v-if="isClient">
|
||||
<template v-if="clientEditMode">
|
||||
<el-button type="primary" @click="doSaveEditData">保存</el-button>
|
||||
<el-button @click="doCancelEditMode">取消编辑旋转模式</el-button>
|
||||
</template>
|
||||
<el-button v-else type="primary" @click="updateRotate">更新旋转角度</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="nav-title">旋转</div>
|
||||
<el-form-item label="绕X轴">
|
||||
<el-slider v-model="form.rotateX" :min="-180" :max="180"></el-slider>
|
||||
<el-input-number v-model="form.rotateX" placeholder="请输入旋转角度" :min="-180" :max="180"></el-input-number>
|
||||
<el-input-number v-model="form.rotateX" placeholder="请输入旋转角度" :min="-180"
|
||||
:max="180"></el-input-number>
|
||||
</el-form-item>
|
||||
<el-form-item label="绕Y轴">
|
||||
<el-slider v-model="form.rotateY" :min="-180" :max="180"></el-slider>
|
||||
<el-input-number v-model="form.rotateY" placeholder="请输入旋转角度" :min="-180" :max="180"></el-input-number>
|
||||
<el-input-number v-model="form.rotateY" placeholder="请输入旋转角度" :min="-180"
|
||||
:max="180"></el-input-number>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="绕Z轴">
|
||||
<el-slider v-model="form.rotateZ" :min="-180" :max="180"></el-slider>
|
||||
<el-input-number v-model="form.rotateZ" placeholder="请输入旋转角度" :min="-180" :max="180"></el-input-number>
|
||||
<el-input-number v-model="form.rotateZ" placeholder="请输入旋转角度" :min="-180"
|
||||
:max="180"></el-input-number>
|
||||
</el-form-item>
|
||||
<div class="button-group">
|
||||
<el-button type="primary" @click="updateRotate">更新旋转角度</el-button>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<div class="footer-btn">
|
||||
<el-button @click="resetRotate">清除模型偏移和旋转</el-button>
|
||||
<el-button type="primary" @click="onSubmit">保存</el-button>
|
||||
|
@ -64,7 +76,7 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
isClient:false,
|
||||
isClient: false,
|
||||
modelId: null,
|
||||
movePoint: null,
|
||||
form: {
|
||||
|
@ -77,7 +89,7 @@ export default {
|
|||
|
||||
},
|
||||
saveData: {
|
||||
type:'',
|
||||
type: '',
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0,
|
||||
|
@ -86,10 +98,28 @@ export default {
|
|||
rotateZ: 0,
|
||||
|
||||
},
|
||||
movePoint: null
|
||||
movePoint: null,
|
||||
clientEditMode: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
doSaveEditData() {
|
||||
this.clientEditMode = false;
|
||||
api.Edit.setEditMode("")
|
||||
api.Edit.save(d => {
|
||||
let m = d.model.find(it => it.id == this.modelId);
|
||||
this.saveData.direction = {
|
||||
flyto: true,
|
||||
matrix: m.matrix,
|
||||
rotate: m.rotate,
|
||||
transform: m.transform
|
||||
}
|
||||
});
|
||||
},
|
||||
doCancelEditMode() {
|
||||
this.clientEditMode = false;
|
||||
api.Edit.setEditMode("")
|
||||
},
|
||||
doModelMove() {
|
||||
ElMessage.info("左键单击选择移动位置,右键单击结束操作!");
|
||||
if (this.me.bimCfg.clientApi) {
|
||||
|
@ -107,6 +137,8 @@ export default {
|
|||
this.$modal.confirm("确定保存吗?").then(() => {
|
||||
let model = this.me.models.find(model => model.modelId == this.modelId);
|
||||
if (model) {
|
||||
this.saveData.hideParts = model.bimCfg?.hideParts || [];
|
||||
this.saveData.direction = this.saveData.direction || model.bimCfg?.direction;
|
||||
model.bimConfig = JSON.stringify(this.saveData);
|
||||
model.bimCfg = this.saveData;
|
||||
updateBimModel(model).then(res => {
|
||||
|
@ -119,8 +151,8 @@ export default {
|
|||
},
|
||||
initData(modelId) {
|
||||
this.modelId = modelId;
|
||||
this.saveData.type=this.me.bimCfg.clientApi?'api':'sapi'
|
||||
this.isClient=this.me.bimCfg.clientApi
|
||||
this.saveData.type = this.me.bimCfg.clientApi ? 'api' : 'sapi'
|
||||
this.isClient = this.me.bimCfg.clientApi
|
||||
let modelInfo = this.me.models.find(m => m.modelId == modelId);
|
||||
if (modelInfo) {
|
||||
let cfg = modelInfo.bimCfg;
|
||||
|
@ -166,10 +198,10 @@ export default {
|
|||
},
|
||||
|
||||
updateRotate() {
|
||||
if(this.isClient){
|
||||
api.Model.ClearModelRotation(this.modelId);
|
||||
api.Model.rotateForEdit(this.modelId,this.form.rotateX, this.form.rotateY, this.form.rotateZ)
|
||||
}else{
|
||||
if (this.isClient) {
|
||||
api.Edit.setEditMode("Rotate")
|
||||
this.clientEditMode = true;
|
||||
} else {
|
||||
api.Model.rotateForEdit(this.form.rotateX, this.form.rotateY, this.form.rotateZ, this.modelId)
|
||||
}
|
||||
this.saveData.rotateZ = this.form.rotateZ;
|
||||
|
|
Loading…
Reference in New Issue