廖杰:预览模式当风机离线(不在online下)会显示红色

This commit is contained in:
Hcat
2024-02-28 21:23:57 +08:00
parent 5e24845abb
commit 70364c8e10
4 changed files with 45 additions and 6 deletions

View File

@@ -145,6 +145,7 @@ async function handleMounted() {
// ); // );
// 初始化设备模型 // 初始化设备模型
try { try {
//在这加载隧道 //在这加载隧道
const map = new Map(); const map = new Map();
map.set("equ_fan", await loadModel("/devicesModel/model2.obj")); map.set("equ_fan", await loadModel("/devicesModel/model2.obj"));
@@ -153,8 +154,9 @@ async function handleMounted() {
demo.initDevicesModel(map); demo.initDevicesModel(map);
// const equipmentList = await store.getEquipmentList(); // const equipmentList = await store.getEquipmentList();
modelList.value = await modelStore.initModelDataPreview(params.tunnelId); modelList.value = await modelStore.initModelDataPreview(params.tunnelId);
// console.log(modelList.value);
// console.log("init", params.tunnelId); // console.log("init", params.tunnelId);
demo.previewtunnelModeInit(toRaw(modelList.value)); demo.previewtunnelModeInit(toRaw(modelList.value), fanData);
demo.SignsInf(params.tunnelName, String(params.tunnelLen.value)) demo.SignsInf(params.tunnelName, String(params.tunnelLen.value))
// watch( // watch(
// () => params.tunnelId, // () => params.tunnelId,

View File

@@ -388,6 +388,7 @@ export default class Demo {
// 初始化风机颜色 // 初始化风机颜色
this.equMap.get("equ_fan").traverse((v) => { this.equMap.get("equ_fan").traverse((v) => {
v.material = new this.THREE.MeshBasicMaterial(); v.material = new this.THREE.MeshBasicMaterial();
// v.material.color = new this.THREE.Color(0xFF0000);
v.material.color = new this.THREE.Color(0xC0C0C0); v.material.color = new this.THREE.Color(0xC0C0C0);
if (/^leaf/.test(v.name) || /^roller/.test(v.name)) { if (/^leaf/.test(v.name) || /^roller/.test(v.name)) {
group.add(v.clone()); group.add(v.clone());
@@ -452,7 +453,7 @@ export default class Demo {
); );
} }
changeFanColor(fanData) { changeFanColor(fanData) {
console.log(this.scene.getObjectById(22)); console.log(this.scene.getObjectByName('fan'));
} }
/** /**
* *

View File

@@ -8,14 +8,14 @@ import EquipmentTag from "../utils/EquipmentTag";
//formInfo需要的信息这里包括了 //formInfo需要的信息这里包括了
//equipmentType //equipmentType
function addEquipment(targetPoint, formInfo) { function addEquipment(targetPoint, formInfo, fanData) {
if (targetPoint.hasDevice) { if (targetPoint.hasDevice) {
return; return;
} }
switch (formInfo.equipmentType) { switch (formInfo.equipmentType) {
case "frequency": case "frequency":
handleFanEqu.call(this, targetPoint, formInfo); handleFanEqu.call(this, targetPoint, formInfo, fanData);
break; break;
// 还没有风压阀的模型,所以先用其他设备传感器实现 // 还没有风压阀的模型,所以先用其他设备传感器实现
// case "valve": // case "valve":
@@ -177,6 +177,7 @@ function handleOtherEqu(targetPoint, equipmentInfo) {
function handleFanEqu( function handleFanEqu(
targetPoint, targetPoint,
equipmentInfo, equipmentInfo,
fanData,
speed = Math.random().toFixed(1) * 1000 speed = Math.random().toFixed(1) * 1000
) { ) {
// 由于风机比较多,每个风机转速不一直,保存在一个数中遍历 // 由于风机比较多,每个风机转速不一直,保存在一个数中遍历
@@ -196,6 +197,41 @@ function handleFanEqu(
id: equMesh.id, //模型在场景id id: equMesh.id, //模型在场景id
...equipmentInfo, ...equipmentInfo,
}; };
// console.log(targetPoint.info);
//风机颜色重新命名
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)
}
})
}
});
}
}
// console.log(fanData);
// 定义风机旋转 // 定义风机旋转
const fanLeaf = equMesh.getObjectByName("fan_leafs"); const fanLeaf = equMesh.getObjectByName("fan_leafs");

View File

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