廖杰:完成风机功能+预览模式路牌修复

This commit is contained in:
Hcat
2024-03-02 22:44:11 +08:00
parent 6c5de35283
commit eef5cf50d8
4 changed files with 92 additions and 73 deletions

View File

@@ -177,7 +177,7 @@ function handleOtherEqu(targetPoint, equipmentInfo) {
function handleFanEqu(
targetPoint,
equipmentInfo,
fanData = 1,
fanData,
speed = Math.random().toFixed(1) * 1000
) {
// 由于风机比较多,每个风机转速不一直,保存在一个数中遍历
@@ -197,61 +197,8 @@ function handleFanEqu(
id: equMesh.id, //模型在场景id
...equipmentInfo,
};
// console.log(targetPoint.info);
//风机颜色重新命名
if (fanData != 1) {
if (fanData.length == 2) {
let fan1 = fanData[0].equipmentType
let fan2 = fanData[1].equipmentType
if (targetPoint.info.typeKey == fan1) {
if (fanData[0].online == false) {
this.scene.traverse(function (child) {
if (child.id === 1005) {
child.traverse(function (obj) {
// console.log(obj);
// 判断子对象是否是物体,如果是,更改其颜色
if (obj.isMesh) {
obj.material.color.set(0xFF0000)
}
})
}
});
}
} else {
if (fanData[1].online == false) {
this.scene.traverse(function (child) {
if (child.id === 1005) {
child.traverse(function (obj) {
// console.log(obj);
// 判断子对象是否是物体,如果是,更改其颜色
if (obj.isMesh) {
obj.material.color.set(0xFF0000)
}
})
}
});
}
}
} else {
let fan1 = fanData[0].equipmentType
if (targetPoint.info.typeKey == fan1) {
if (fanData[0].online == false) {
this.scene.traverse(function (child) {
if (child.id === 1005) {
child.traverse(function (obj) {
// console.log(obj);
// 判断子对象是否是物体,如果是,更改其颜色
if (obj.isMesh) {
obj.material.color.set(0xFF0000)
}
})
}
});
}
}
}
}
// console.log(fanData);
//这里感觉情况改变风机的颜色
changeFanColor(fanData, targetPoint, this.scene)
// 定义风机旋转
@@ -336,4 +283,55 @@ function deleteItem(array, item) {
array.splice(index, 1);
}
return array
}
//这里是改变风机颜色的代码
function changeFanColor(fanData, targetPoint, scene) {
if (fanData !== undefined) {
//保证是预览模式才进行这里的操作(!=1
if (fanData.length > 0) {
//if保证存在风机即有长度再进行遍历
for (let i = 0; i < fanData.length; i++) {
//先做匹配操作
let fanType = fanData[i].equipmentType
//有符合条件的风机进来了
if (targetPoint.info.typeKey == fanType) {
//下面进行变色需要的逻辑判断了
if (fanData[i].breakdown == true) {
//故障状态,变红色
scene.traverse(function (child) {
if (child.id === targetPoint.info.id) {
child.traverse(function (obj) {
// console.log(obj);
// 判断子对象是否是物体,如果是,更改其颜色
if (obj.isMesh) {
obj.material.color.set(0xFF0000)
}
})
}
});
} else {
// 这里再判断是否运行
if (fanData[i].running == true) {
//运行状态,绿色 0x008000
scene.traverse(function (child) {
if (child.id === targetPoint.info.id) {
child.traverse(function (obj) {
// console.log(obj);
// 判断子对象是否是物体,如果是,更改其颜色
if (obj.isMesh) {
obj.material.color.set(0x008000)
}
})
}
});
} else {
//停止状态,不变色
break;
}
}
}
}
}
}
}

View File

@@ -1,5 +1,5 @@
export default function previewtunnelModeInit(equipmentList, fanData = 1) {
export default function previewtunnelModeInit(equipmentList, fanData) {
//初始化将墙壁隐藏起来
// for (let line = 1; line <= 20; line++) {
// if (line < 10) {
@@ -13,7 +13,7 @@ export default function previewtunnelModeInit(equipmentList, fanData = 1) {
// console.log(equipmentList);
equipmentList.forEach((item) => {
this.addEquipment(this.scene.getObjectByName(item.position), item, fanData = 1);
this.addEquipment(this.scene.getObjectByName(item.position), item, fanData);
});
//进行预览和编辑模式的一些操作
if (this.isedit == false) {