|
@@ -6,6 +6,7 @@ import { getTextCanvas, renderVideo } from '/@/utils/threejs/util';
|
|
|
import gsap from 'gsap';
|
|
|
import { Mesh } from 'three';
|
|
|
import { resolve } from 'path';
|
|
|
+import Matching from '@zxcvbn-ts/core/dist/Matching';
|
|
|
|
|
|
class mainWindRect {
|
|
|
model;
|
|
@@ -36,6 +37,9 @@ class mainWindRect {
|
|
|
backSmoke; // 后面风流对象
|
|
|
player1; // 视频播放器
|
|
|
playerStartClickTime1 = new Date().getTime();
|
|
|
+ frontWindowGroup;
|
|
|
+ backWindowGroup;
|
|
|
+ windowAngle = 0;
|
|
|
|
|
|
constructor(model, playerVal1) {
|
|
|
this.model = model;
|
|
@@ -491,6 +495,92 @@ class mainWindRect {
|
|
|
this.group?.add(this.backSmoke.points);
|
|
|
// this.backSmoke.points.position.set(47.07, -8.48, -1.83);
|
|
|
}
|
|
|
+
|
|
|
+ /** 初始化电机 */
|
|
|
+ async initMotor() {
|
|
|
+ // 前电机
|
|
|
+ const motorGltf1 = await this.model.setModel('dj1');
|
|
|
+ this.motorGroup1 = motorGltf1.scene as THREE.Group;
|
|
|
+ this.motorGroup1?.position.set(0, 0, 0);
|
|
|
+ this.motorGroup1.visible = false;
|
|
|
+ this.motorGroup1.traverse((item) => {
|
|
|
+ if (item.name === 'fan_blade003') {
|
|
|
+ // @ts-ignore
|
|
|
+ this.gearBack.gear1 = item as THREE.Group;
|
|
|
+ } else if (item.name === 'fan_blade005') {
|
|
|
+ // @ts-ignore
|
|
|
+ this.gearBack.gear2 = item as THREE.Group;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.group?.add(this.motorGroup1);
|
|
|
+
|
|
|
+ // 后电机
|
|
|
+ const motorGltf2 = await this.model.setModel('dj2');
|
|
|
+ this.motorGroup2 = motorGltf2.scene as THREE.Group;
|
|
|
+ this.motorGroup2?.position.set(0, 0, 0);
|
|
|
+ this.motorGroup2.visible = false;
|
|
|
+ this.motorGroup2.traverse((item) => {
|
|
|
+ if (item.name === 'fan_blade007') {
|
|
|
+ // @ts-ignore
|
|
|
+ this.gearFront.gear1 = item as THREE.Group;
|
|
|
+ } else if (item.name === 'fan_blade006') {
|
|
|
+ // @ts-ignore
|
|
|
+ this.gearFront.gear2 = item as THREE.Group;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.group?.add(this.motorGroup2);
|
|
|
+ }
|
|
|
+
|
|
|
+ openOrCloseWindow(flag) {
|
|
|
+ const _this = this;
|
|
|
+ let endAngle = 0;
|
|
|
+ if (flag == 'openWindow') {
|
|
|
+ // 打开风窗
|
|
|
+ endAngle = 1;
|
|
|
+ } else {
|
|
|
+ // 关闭风窗
|
|
|
+ endAngle = 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ gsap.to(this, {
|
|
|
+ windowAngle: endAngle,
|
|
|
+ duration: Math.abs(endAngle - this.windowAngle) * 10,
|
|
|
+ ease: 'none',
|
|
|
+ onUpdate: function () {
|
|
|
+ _this.frontWindowGroup.children.forEach((mesh) => {
|
|
|
+ mesh.rotation.z = _this.windowAngle;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 初始化风窗 */
|
|
|
+ initWindow() {
|
|
|
+ if (!this.group) return;
|
|
|
+ this.frontWindowGroup = new THREE.Group();
|
|
|
+ this.frontWindowGroup.name = 'frontWindowGroup';
|
|
|
+
|
|
|
+ this.backWindowGroup = new THREE.Group();
|
|
|
+ this.backWindowGroup.name = 'backWindowGroup';
|
|
|
+ if (this.group && this.group?.children.length > 0) {
|
|
|
+ for (let i = this.group?.children.length - 1; i >= 0; i--) {
|
|
|
+ const obj = this.group?.children[i];
|
|
|
+ if (obj.type === 'Mesh' && obj.name && obj.name.startsWith('TC')) {
|
|
|
+ const mesh = obj.clone();
|
|
|
+ if (obj.name.startsWith('TC1')) {
|
|
|
+ this.backWindowGroup.add(mesh);
|
|
|
+ } else if (obj.name.startsWith('TC2')) {
|
|
|
+ this.frontWindowGroup.add(mesh);
|
|
|
+ }
|
|
|
+ obj.removeFromParent();
|
|
|
+ this.group?.remove(obj);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.group?.add(this.backWindowGroup);
|
|
|
+ this.group?.add(this.frontWindowGroup);
|
|
|
+ }
|
|
|
+
|
|
|
mountedThree() {
|
|
|
return new Promise(async (resolve) => {
|
|
|
this.model.setModel(this.modelName).then(async (gltf) => {
|
|
@@ -503,39 +593,11 @@ class mainWindRect {
|
|
|
this.setSmokePosition();
|
|
|
// this.startSmoke();
|
|
|
// this.initSmoke();
|
|
|
- // 前电机
|
|
|
- const motorGltf1 = await this.model.setModel('dj1');
|
|
|
- this.motorGroup1 = motorGltf1.scene as THREE.Group;
|
|
|
- this.motorGroup1?.position.set(0, 0, 0);
|
|
|
- this.motorGroup1.visible = false;
|
|
|
- this.motorGroup1.traverse((item) => {
|
|
|
- if (item.name === 'fan_blade003') {
|
|
|
- // @ts-ignore
|
|
|
- this.gearBack.gear1 = item as THREE.Group;
|
|
|
- } else if (item.name === 'fan_blade005') {
|
|
|
- // @ts-ignore
|
|
|
- this.gearBack.gear2 = item as THREE.Group;
|
|
|
- }
|
|
|
- });
|
|
|
- this.group?.add(this.motorGroup1);
|
|
|
- // 后电机
|
|
|
- const motorGltf2 = await this.model.setModel('dj2');
|
|
|
- this.motorGroup2 = motorGltf2.scene as THREE.Group;
|
|
|
- this.motorGroup2?.position.set(0, 0, 0);
|
|
|
- this.motorGroup2.visible = false;
|
|
|
- this.motorGroup2.traverse((item) => {
|
|
|
- if (item.name === 'fan_blade007') {
|
|
|
- // @ts-ignore
|
|
|
- this.gearFront.gear1 = item as THREE.Group;
|
|
|
- } else if (item.name === 'fan_blade006') {
|
|
|
- // @ts-ignore
|
|
|
- this.gearFront.gear2 = item as THREE.Group;
|
|
|
- }
|
|
|
- });
|
|
|
- this.group?.add(this.motorGroup2);
|
|
|
|
|
|
+ await this.initMotor();
|
|
|
resolve(null);
|
|
|
-
|
|
|
+ this.initWindow();
|
|
|
+ this.openOrCloseWindow('openWindow');
|
|
|
setTimeout(async () => {
|
|
|
const videoPlayer1 = document.getElementById('main-player1')?.getElementsByClassName('vjs-tech')[0];
|
|
|
if (videoPlayer1) {
|