唐润平: 传感器添加删除、标签文字设置、双击进入视角、双击空白回退视角
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import EquipmentTag from "../utils/EquipmentTag";
|
||||
/**
|
||||
*
|
||||
* @param {Mesh} targetPoint
|
||||
@@ -13,33 +14,53 @@ function addEquipment(targetPoint, formInfo) {
|
||||
handleFanEqu.call(this, targetPoint);
|
||||
break;
|
||||
case "sensors":
|
||||
handleOtherEqu.call(this, targetPoint);
|
||||
case "sensors_2":
|
||||
handleOtherEqu.call(this, targetPoint, formInfo.equipmentType);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
targetPoint.hasDevice = true;
|
||||
console.log("添加信息", targetPoint, formInfo);
|
||||
// 标识设备信息
|
||||
}
|
||||
// 其他传感器
|
||||
function handleOtherEqu(targetPoint, speed = 0) {
|
||||
function handleOtherEqu(targetPoint, EqeName) {
|
||||
const equMesh = this.equMap.get("equ_sensors").clone();
|
||||
const worldP = targetPoint.getWorldPosition(new this.THREE.Vector3());
|
||||
equMesh.position.copy(worldP);
|
||||
|
||||
//设备添加标签
|
||||
const tag = EquipmentTag(EqeName === "sensors" ? "风压传感器" : "普通传感器");
|
||||
equMesh.getObjectByName("tag").material = tag;
|
||||
if (/tr$/.test(targetPoint.name)) {
|
||||
equMesh.rotation.z = -(3 * Math.PI) / 4;
|
||||
targetPoint.scale.set(0.03, 0.03, 0.03);
|
||||
equMesh.getObjectByName("tag").rotation.z += Math.PI; ///注意在原来的基础上加
|
||||
} else if (/tl$/.test(targetPoint.name)) {
|
||||
equMesh.rotation.z = -Math.PI / 4;
|
||||
} else if (/trc$/.test(targetPoint.name)) {
|
||||
equMesh.rotation.z = -(5 * Math.PI) / 4;
|
||||
targetPoint.scale.set(0.03, 0.03, 0.03);
|
||||
} else if (/tc$/.test(targetPoint.name)) {
|
||||
equMesh.rotation.z = Math.PI;
|
||||
targetPoint.scale.set(0.03, 0.03, 0.03);
|
||||
} else if (/br$/.test(targetPoint.name)) {
|
||||
equMesh.rotation.z = -Math.PI / 2;
|
||||
equMesh.translateX(-1);
|
||||
equMesh.getObjectByName("tag").rotation.z += Math.PI; ///注意在原来的基础上加
|
||||
targetPoint.scale.set(0.03, 0.03, 0.075);
|
||||
} else if (/bl$/.test(targetPoint.name)) {
|
||||
equMesh.rotation.z = Math.PI / 2;
|
||||
equMesh.translateX(1);
|
||||
|
||||
targetPoint.scale.set(0.03, 0.03, 0.075);
|
||||
}
|
||||
|
||||
this.scene.add(equMesh);
|
||||
targetPoint.visible = false;
|
||||
|
||||
// 保存该设备id,后期直接从附附着点进行删除
|
||||
targetPoint.info = {
|
||||
id: equMesh.id,
|
||||
};
|
||||
}
|
||||
|
||||
// 风机
|
||||
@@ -50,6 +71,19 @@ function handleFanEqu(targetPoint, speed = 0) {
|
||||
equMesh.translateY(-0.6);
|
||||
this.scene.add(equMesh);
|
||||
targetPoint.visible = false;
|
||||
// 放大附着点方便选中风机的范围
|
||||
targetPoint.scale.set(0.06, 0.06, 0.06);
|
||||
// 保存该设备id,后期直接从附附着点进行删除
|
||||
targetPoint.info = {
|
||||
id: equMesh.id, //模型在场景id
|
||||
};
|
||||
}
|
||||
function removeEquipment(targetPoint) {
|
||||
if (!targetPoint.hasDevice) return;
|
||||
const mesh = this.scene.getObjectById(targetPoint.info.id);
|
||||
this.scene.remove(mesh);
|
||||
targetPoint.visible = true;
|
||||
targetPoint.hasDevice = false;
|
||||
targetPoint.scale.set(0.01, 0.01, 0.01);
|
||||
}
|
||||
function removeEquipment(targetPoint) {}
|
||||
export { addEquipment, removeEquipment };
|
||||
|
||||
Reference in New Issue
Block a user