分压阀添加墙壁完成
This commit is contained in:
@@ -33,10 +33,15 @@ function addEquipment(targetPoint, formInfo) {
|
||||
this.clearTagsObj();
|
||||
}
|
||||
|
||||
//判断墙是否已经存在,如果存在的话,就不管,添加则无效嘛(就是说只能添加一面墙,如果存在一面墙,则不管了)
|
||||
let hasWall = false
|
||||
let wallHang = 0;
|
||||
|
||||
// function handleValveEqu(targetPoint, equipmentInfo) {
|
||||
|
||||
// }
|
||||
// let allline = new Array();
|
||||
let allline = new Array();
|
||||
let Allhang = new Array();
|
||||
// 其他传感器
|
||||
function handleOtherEqu(targetPoint, equipmentInfo) {
|
||||
const equMesh = this.equMap.get("equ_sensors").clone();
|
||||
@@ -67,7 +72,75 @@ function handleOtherEqu(targetPoint, equipmentInfo) {
|
||||
targetPoint.scale.set(0.03, 0.06, 0.05);
|
||||
this.scene.add(equMesh);
|
||||
targetPoint.visible = false;
|
||||
targetPoint.hasWall = true;
|
||||
// targetPoint.hasWall = true;
|
||||
allline.push(targetPoint.name)
|
||||
if (hasWall == false) {
|
||||
let findWallHang = new Array;
|
||||
// console.log(targetPoint.name);
|
||||
console.log(allline);
|
||||
Allhang = allline.map(function (str) {
|
||||
return parseInt(str.match(/\d+/)[0], 10);
|
||||
})
|
||||
console.log(Allhang);
|
||||
//将取出来的所有行数字符串用一个新数组来保存,之后判断是不是存在同一行的(即相同的行数)
|
||||
for (let i = 0; i < Allhang.length; i++) {
|
||||
//判断是不是存在相同的行数,如果存在,则继续判断是不是存在左右的传感器
|
||||
findWallHang.push(Allhang[i - 1])
|
||||
if (findWallHang.includes(Allhang[i])) {
|
||||
console.log(allline[i - 1].slice(-1));
|
||||
console.log(allline[i].slice(-1));
|
||||
wallHang = Allhang[i];
|
||||
if ((allline[i - 1].slice(-1) == 'r' && allline[i].slice(-1) == 'l') || allline[i - 1].slice(-1) == 'l' && allline[i].slice(-1) == 'r') {
|
||||
console.log('进行添加操作');
|
||||
// 将这二个符合添加规则的锚点给设一个属性,这样方便之后我们进行删除操作
|
||||
// this.scene.getObjectByName(allline[i - 1]).hasWall = true
|
||||
// this.scene.getObjectByName(allline[i]).hasWall = true
|
||||
console.log(this.scene.getObjectByName(allline[i - 1]));
|
||||
console.log(this.scene.getObjectByName(allline[i]));
|
||||
//出现满足条件的风压阀了,这时候就设定为已经有墙了,不需要再添加了
|
||||
hasWall = true
|
||||
findWallHang = []
|
||||
//进行添加操作,因为数值问题,所以我们分开进行添加操作
|
||||
for (let line = Allhang[i]; line <= 20; line++) {
|
||||
if (line < 10) {
|
||||
let wall = 'wall_' + '0' + line
|
||||
console.log(wall);
|
||||
//把墙设为可见
|
||||
this.scene.getObjectByName(wall).visible = true
|
||||
let point = 'point_' + '00' + line + '_tc'
|
||||
// console.log(this.scene.getObjectByName(point));
|
||||
//把顶部的附着点设为隐藏!!!,然后设为不可选中
|
||||
this.scene.getObjectByName(point).visible = false
|
||||
this.scene.getObjectByName(point).layers.set(-2)
|
||||
//如果最中间一行有设备,我们则需要将设备进行隐藏!!!
|
||||
if (this.scene.getObjectByName(point).hasDevice == true) {
|
||||
let EquID = this.scene.getObjectByName(point).info.id
|
||||
this.scene.getObjectById(EquID).visible = false
|
||||
}
|
||||
} else if (line >= 10) {
|
||||
let wall = 'wall_' + line
|
||||
this.scene.getObjectByName(wall).visible = true
|
||||
let point = 'point_' + '0' + line + '_tc'
|
||||
this.scene.getObjectByName(point).visible = false
|
||||
this.scene.getObjectByName(point).layers.set(-2)
|
||||
if (this.scene.getObjectByName(point).hasDevice == true) {
|
||||
let EquID = this.scene.getObjectByName(point).info.id
|
||||
this.scene.getObjectById(EquID).visible = false
|
||||
}
|
||||
}
|
||||
//处理21行的设备和附着点
|
||||
let point = 'point_' + '0' + 21 + '_tc'
|
||||
this.scene.getObjectByName(point).visible = false
|
||||
this.scene.getObjectByName(point).layers.set(-2)
|
||||
if (this.scene.getObjectByName(point).hasDevice == true) {
|
||||
let EquID = this.scene.getObjectByName(point).info.id
|
||||
this.scene.getObjectById(EquID).visible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//处理风压阀的代码片段
|
||||
// let lineIndex = targetPoint.name.slice(7, 9);
|
||||
// if (allline.includes(Number(lineIndex))) {
|
||||
@@ -92,9 +165,11 @@ function handleOtherEqu(targetPoint, equipmentInfo) {
|
||||
...equipmentInfo,
|
||||
};
|
||||
//下面进行模拟分压阀的添加效果
|
||||
// 1.先取出当前点击添加设备锚点的行数
|
||||
// 2.再进行字符串拼接出墙的名字,使用scene.getObjectByName(墙名去获取)
|
||||
// 3.加上循环,固定到20结束就可以了,将点击的函数到20的函数的墙全部设为visable设为可见,还需要将中间的那行设备和附着点全部设为隐藏,且层级变低,无法选中
|
||||
// 1. 不能放在初始化的地方去写,我们最好放在同一行的地方去写,当用户每添加一个模型,就判断是不是该行已经添加过了多个模型了
|
||||
// 2.如果是的话,我们必须判断是不是左右同时添加的情况,如果是的话则则可以加一个墙
|
||||
|
||||
// 0. 首先需要定义一个变量,看墙是否已经添加了,如果已经添加的话,则直接跳出不管(因为只会有二个风压阀生成的墙)
|
||||
// 1. 每添加一个则将附着点保存到数组里面,然后对数组里面进行第一遍过滤,将相同行数的提取出来,如果存在左右的话,则进行墙的展示(里面套for循环将后面的墙全部打开,并且将该行上面的附着点全部隐藏,包括设备和层级!!!)
|
||||
}
|
||||
|
||||
// 风机
|
||||
@@ -137,43 +212,55 @@ function handleFanEqu(
|
||||
function removeEquipment(targetPoint) {
|
||||
//删除设备这里需要再进行处理,就是根据附着点(附着点一定保存了当前添加设备的信息了)判断是不是分压阀,然后继续一样的隐藏
|
||||
if (!targetPoint.hasDevice) return;
|
||||
// if (targetPoint.hasWall == true) {
|
||||
// let lineIndex = targetPoint.name.slice(7, 9);
|
||||
// for (let line = Number(lineIndex); line <= 20; line++) {
|
||||
// if (line < 10) {
|
||||
// let wall = "wall_" + "0" + line;
|
||||
// this.scene.getObjectByName(wall).visible = false;
|
||||
// let point = "point_" + "00" + line + "_tc";
|
||||
// console.log(this.scene.getObjectByName(point));
|
||||
// this.scene.getObjectByName(point).visible = true;
|
||||
// this.scene.getObjectByName(point).layers.set(0);
|
||||
// if (this.scene.getObjectByName(point).hasDevice == true) {
|
||||
// this.scene.getObjectByName(point).visible = false;
|
||||
// let EquID = this.scene.getObjectByName(point).info.id;
|
||||
// this.scene.getObjectById(EquID).visible = true;
|
||||
// }
|
||||
// } else if (line >= 10) {
|
||||
// let wall = "wall_" + line;
|
||||
// this.scene.getObjectByName(wall).visible = false;
|
||||
// let point = "point_" + "0" + line + "_tc";
|
||||
// this.scene.getObjectByName(point).visible = true;
|
||||
// this.scene.getObjectByName(point).layers.set(0);
|
||||
// if (this.scene.getObjectByName(point).hasDevice == true) {
|
||||
// this.scene.getObjectByName(point).visible = false;
|
||||
// let EquID = this.scene.getObjectByName(point).info.id;
|
||||
// this.scene.getObjectById(EquID).visible = true;
|
||||
// }
|
||||
// }
|
||||
// //处理21行的设备和附着点
|
||||
// let point = "point_" + "0" + 21 + "_tc";
|
||||
// this.scene.getObjectByName(point).visible = true;
|
||||
// this.scene.getObjectByName(point).layers.set(0);
|
||||
// if (this.scene.getObjectByName(point).hasDevice == true) {
|
||||
// let EquID = this.scene.getObjectByName(point).info.id;
|
||||
// this.scene.getObjectById(EquID).visible = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
//删除我们这里使用行数来判断,即是不是删除到了我们的那一行呢?
|
||||
//如果删除到了我们那行的话,我们必须将行的数组从中去掉已存在的数据,然后将附着点列表中也去除这个点,然后将墙设置为false来让下次使用
|
||||
|
||||
let lineIndex = targetPoint.name.slice(7, 9)
|
||||
deleteItem(allline, targetPoint.name)
|
||||
if (Number(lineIndex) == wallHang) {
|
||||
wallHang = 0;
|
||||
hasWall = false
|
||||
for (let line = Number(lineIndex); line <= 20; line++) {
|
||||
if (line < 10) {
|
||||
let wall = 'wall_' + '0' + line
|
||||
this.scene.getObjectByName(wall).visible = false
|
||||
let point = 'point_' + '00' + line + '_tc'
|
||||
console.log(this.scene.getObjectByName(point));
|
||||
this.scene.getObjectByName(point).visible = true
|
||||
this.scene.getObjectByName(point).layers.set(0)
|
||||
if (this.scene.getObjectByName(point).hasDevice == true) {
|
||||
this.scene.getObjectByName(point).visible = false
|
||||
let EquID = this.scene.getObjectByName(point).info.id
|
||||
this.scene.getObjectById(EquID).visible = true
|
||||
}
|
||||
} else if (line >= 10) {
|
||||
let wall = 'wall_' + line
|
||||
this.scene.getObjectByName(wall).visible = false
|
||||
let point = 'point_' + '0' + line + '_tc'
|
||||
this.scene.getObjectByName(point).visible = true
|
||||
this.scene.getObjectByName(point).layers.set(0)
|
||||
if (this.scene.getObjectByName(point).hasDevice == true) {
|
||||
this.scene.getObjectByName(point).visible = false
|
||||
let EquID = this.scene.getObjectByName(point).info.id
|
||||
this.scene.getObjectById(EquID).visible = true
|
||||
}
|
||||
}
|
||||
//处理21行的设备和附着点
|
||||
let point = 'point_' + '0' + 21 + '_tc'
|
||||
this.scene.getObjectByName(point).visible = true
|
||||
this.scene.getObjectByName(point).layers.set(0)
|
||||
if (this.scene.getObjectByName(point).hasDevice == true) {
|
||||
let EquID = this.scene.getObjectByName(point).info.id
|
||||
this.scene.getObjectById(EquID).visible = true
|
||||
}
|
||||
}
|
||||
}
|
||||
deleteItem(Allhang, Number(lineIndex))
|
||||
|
||||
|
||||
|
||||
console.log("测试是不是删除了");
|
||||
const mesh = this.scene.getObjectById(targetPoint.info.id);
|
||||
this.scene.remove(mesh);
|
||||
@@ -183,3 +270,12 @@ function removeEquipment(targetPoint) {
|
||||
delete targetPoint.info; // 清空设备信息
|
||||
}
|
||||
export { addEquipment, removeEquipment };
|
||||
|
||||
|
||||
function deleteItem(array, item) {
|
||||
let index = array.indexOf(item);
|
||||
if (index !== -1) {
|
||||
array.splice(index, 1);
|
||||
}
|
||||
return array
|
||||
}
|
||||
Reference in New Issue
Block a user