唐润平:风机旋转
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
import { saveState, resetState } from "./viewBack";
|
||||
import addFunction from "./addEvent";
|
||||
import { addEquipment, removeEquipment } from "./editEquipment";
|
||||
import { Group } from "three/examples/jsm/libs/tween.module";
|
||||
export default class Demo {
|
||||
// 摄像机看向位置
|
||||
origin = null;
|
||||
@@ -101,6 +102,10 @@ export default class Demo {
|
||||
if (this.dblIntoTween) {
|
||||
this.dblIntoTween.update();
|
||||
}
|
||||
// 风机叶片旋转动画
|
||||
if (this.fanSpinArray && this.fanSpinArray.length) {
|
||||
this.fanSpinArray.forEach((element) => element.update());
|
||||
}
|
||||
}
|
||||
|
||||
// 添加世界坐标系
|
||||
@@ -357,14 +362,35 @@ export default class Demo {
|
||||
* @param {Map} meshes gltf加载过后的模型Map
|
||||
*/
|
||||
initDevicesModel(equMap) {
|
||||
// 把风机叶片做为一个组,方便后期旋转
|
||||
const group = new this.THREE.Group();
|
||||
group.name = "fanLeaf";
|
||||
// 初始化风机
|
||||
|
||||
this.equMap = equMap;
|
||||
|
||||
// 初始化风机颜色
|
||||
this.equMap.get("equ_fan").traverse((v) => {
|
||||
v.material = new this.THREE.MeshBasicMaterial();
|
||||
v.material.color = new this.THREE.Color("#191a05");
|
||||
// v.material = new this.THREE.MeshBasicMaterial();
|
||||
// v.material.color = new this.THREE.Color("#191a05");
|
||||
if (/^leaf/.test(v.name) || /^roller/.test(v.name)) {
|
||||
group.add(v.clone());
|
||||
v.visible = false;
|
||||
// console.log(v);
|
||||
}
|
||||
});
|
||||
const axesHelper = new this.THREE.AxesHelper(100);
|
||||
// 改变叶子旋转中心
|
||||
let x = 0,
|
||||
y = -0.2,
|
||||
z = 0;
|
||||
const wrapper = new this.THREE.Object3D();
|
||||
wrapper.position.set(x, y, z);
|
||||
wrapper.add(group);
|
||||
group.position.set(-x, -y, -z);
|
||||
// wrapper.add(axesHelper);
|
||||
wrapper.rotation.z = Math.PI / 4;
|
||||
wrapper.name = "fan_leafs";
|
||||
this.equMap.get("equ_fan").add(wrapper);
|
||||
|
||||
// 初其他传感器机颜色
|
||||
this.equMap.get("equ_sensors").scale.set(0.1, 0.1, 0.1);
|
||||
|
||||
Reference in New Issue
Block a user