唐润平:传感器添加功能
This commit is contained in:
@@ -1,10 +1,55 @@
|
||||
function addEquipment(targetPoint, EquType) {
|
||||
const equMesh = this.equMap.get("equ_fan").clone();
|
||||
console.log(equMesh);
|
||||
this.scene.add(equMesh);
|
||||
/**
|
||||
*
|
||||
* @param {Mesh} targetPoint
|
||||
* @param {String} equType "fan" "sensors"
|
||||
*/
|
||||
function addEquipment(targetPoint, formInfo) {
|
||||
if (targetPoint.hasDevice) {
|
||||
alert("已添加设备");
|
||||
return;
|
||||
}
|
||||
switch (formInfo.equipmentType) {
|
||||
case "fan":
|
||||
handleFanEqu.call(this, targetPoint);
|
||||
break;
|
||||
case "sensors":
|
||||
handleOtherEqu.call(this, targetPoint);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
targetPoint.hasDevice = true;
|
||||
console.log("添加信息", targetPoint, formInfo);
|
||||
}
|
||||
// 其他传感器
|
||||
function handleOtherEqu(targetPoint, speed = 0) {
|
||||
const equMesh = this.equMap.get("equ_sensors").clone();
|
||||
const worldP = targetPoint.getWorldPosition(new this.THREE.Vector3());
|
||||
equMesh.position.copy(worldP);
|
||||
if (/tr$/.test(targetPoint.name)) {
|
||||
equMesh.rotation.z = -(3 * Math.PI) / 4;
|
||||
} else if (/tl$/.test(targetPoint.name)) {
|
||||
equMesh.rotation.z = -Math.PI / 4;
|
||||
} else if (/trc$/.test(targetPoint.name)) {
|
||||
} else if (/br$/.test(targetPoint.name)) {
|
||||
equMesh.rotation.z = -Math.PI / 2;
|
||||
equMesh.translateX(-1);
|
||||
} else if (/bl$/.test(targetPoint.name)) {
|
||||
equMesh.rotation.z = Math.PI / 2;
|
||||
equMesh.translateX(1);
|
||||
}
|
||||
this.scene.add(equMesh);
|
||||
targetPoint.visible = false;
|
||||
}
|
||||
|
||||
// 风机
|
||||
function handleFanEqu(targetPoint, speed = 0) {
|
||||
const equMesh = this.equMap.get("equ_fan").clone();
|
||||
const worldP = targetPoint.getWorldPosition(new this.THREE.Vector3());
|
||||
equMesh.position.copy(worldP);
|
||||
equMesh.translateY(-0.6);
|
||||
this.scene.add(equMesh);
|
||||
targetPoint.visible = false;
|
||||
}
|
||||
// 处理设备添加位置
|
||||
function handleOtherEqu() {}
|
||||
function handleFanEqu() {}
|
||||
function removeEquipment(targetPoint) {}
|
||||
export { addEquipment, removeEquipment };
|
||||
|
||||
Reference in New Issue
Block a user