59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
export default function (devInfo) {
|
|
const dev = this.deviceList[devInfo.checkIndex].clone(); //克隆对应的moxin
|
|
const p = this.targetPoint.getWorldPosition(new this.THREE.Vector3());
|
|
dev.position.copy(p);
|
|
// console.log(this.targetPoint);
|
|
modelEffectProcess(dev, this.targetPoint)
|
|
this.scene.add(dev);
|
|
this.targetPoint.hasDevice = true; //标记还存在设备
|
|
// 附着点记录信息
|
|
this.targetPoint.info = {
|
|
meshId: dev.id,
|
|
name: devInfo.devName,
|
|
position: transformPosition(this.targetPoint.name, this.distance),
|
|
state: devInfo.devState,
|
|
};
|
|
// this.targetPoint.visible = false;
|
|
return this.targetPoint.info;
|
|
}
|
|
|
|
function modelEffectProcess(model, point) {
|
|
if (model.children[0].name == "camera") {
|
|
console.log(model);
|
|
console.log(point);
|
|
model.scale.set(0.1, 0.1, 0.1)
|
|
|
|
}
|
|
if (model.children[0].name == "fan") {
|
|
console.log(model);
|
|
console.log(point);
|
|
|
|
}
|
|
if (model.children[0].name == "sensors") {
|
|
console.log(model);
|
|
console.log(point);
|
|
|
|
model.scale.set(0.2, 0.2, 0.2)
|
|
}
|
|
}
|
|
|
|
function transformPosition(position, distance) {
|
|
return `${equal(position.charAt(position.lastIndexOf("_") + 1))}边隧道${equal(
|
|
position.charAt(position.lastIndexOf("_") + 2)
|
|
)}侧设备约${(Number(
|
|
position.substring(position.indexOf("_") + 1, position.lastIndexOf("_"))
|
|
) +
|
|
1) *
|
|
distance
|
|
}米处`;
|
|
}
|
|
|
|
function equal(str) {
|
|
switch (str) {
|
|
case "r":
|
|
return "右";
|
|
case "l":
|
|
return "左";
|
|
}
|
|
}
|