唐润平:风机旋转
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user