唐润平:风机旋转

This commit is contained in:
trp
2023-12-16 16:00:04 +08:00
parent 9ff76d31db
commit 236ed18fd5
6 changed files with 80885 additions and 7 deletions

View File

@@ -65,7 +65,11 @@ function handleOtherEqu(targetPoint, EqeName) {
}
// 风机
function handleFanEqu(targetPoint, speed = 0) {
function handleFanEqu(targetPoint, speed = Math.random().toFixed(1) * 1000) {
// 由于风机比较多,每个风机转速不一直,保存在一个数中遍历
if (!this.fanSpinArray) {
this.fanSpinArray = [];
}
const equMesh = this.equMap.get("equ_fan").clone();
const worldP = targetPoint.getWorldPosition(new this.THREE.Vector3());
equMesh.position.copy(worldP);
@@ -78,7 +82,21 @@ function handleFanEqu(targetPoint, speed = 0) {
targetPoint.info = {
id: equMesh.id, //模型在场景id
};
// 定义风机旋转
const fanLeaf = equMesh.getObjectByName("fan_leafs");
const fanSpin = new this.TWEEN.Tween({ rotation: 0 });
fanSpin.to({ rotation: 2 * Math.PI }, speed);
fanSpin.repeat(Infinity);
fanSpin.start();
fanSpin.onUpdate((obj) => {
fanLeaf.rotation.z = obj.rotation;
});
this.fanSpinArray.push(fanSpin);
}
// 删除传感器
function removeEquipment(targetPoint) {
if (!targetPoint.hasDevice) return;
const mesh = this.scene.getObjectById(targetPoint.info.id);