|
@@ -26,6 +26,11 @@ class Fm1 {
|
|
|
mixers: THREE.AnimationMixer | undefined;
|
|
|
appStore = useAppStore();
|
|
|
|
|
|
+ backDamperOpenMesh;
|
|
|
+ backDamperClosedMesh;
|
|
|
+ frontDamperOpenMesh;
|
|
|
+ frontDamperClosedMesh;
|
|
|
+
|
|
|
clipActionArr = {
|
|
|
frontDoor: null as unknown as THREE.AnimationAction,
|
|
|
backDoor: null as unknown as THREE.AnimationAction,
|
|
@@ -36,7 +41,7 @@ class Fm1 {
|
|
|
}
|
|
|
|
|
|
addLight() {
|
|
|
- const directionalLight = new THREE.DirectionalLight(0xffffff, 1.2);
|
|
|
+ const directionalLight = new THREE.DirectionalLight(0xffffff, 1.5);
|
|
|
directionalLight.position.set(344, 690, 344);
|
|
|
this.group?.add(directionalLight);
|
|
|
directionalLight.target = this.group as THREE.Object3D;
|
|
@@ -235,35 +240,35 @@ class Fm1 {
|
|
|
// 判断是否点击到视频
|
|
|
intersects.find((intersect) => {
|
|
|
const mesh = intersect.object;
|
|
|
- if (mesh.name === 'player1') {
|
|
|
- if (new Date().getTime() - this.playerStartClickTime1 < 400) {
|
|
|
- // 双击,视频放大
|
|
|
- if (this.player1) {
|
|
|
- this.player1.requestPictureInPicture();
|
|
|
- }
|
|
|
- }
|
|
|
- this.playerStartClickTime1 = new Date().getTime();
|
|
|
- return true;
|
|
|
- } else if (mesh.name === 'player2') {
|
|
|
- if (new Date().getTime() - this.playerStartClickTime2 < 400) {
|
|
|
- // 双击,视频放大
|
|
|
- if (this.player2) {
|
|
|
- this.player2.requestPictureInPicture();
|
|
|
- }
|
|
|
- }
|
|
|
- this.playerStartClickTime2 = new Date().getTime();
|
|
|
- return true;
|
|
|
- } else if (mesh.name.startsWith('hotPoint')) {
|
|
|
- if (this.deviceDetailCSS3D) {
|
|
|
- this.deviceDetailCSS3D.position.set(mesh.position.x + 0.035, mesh.position.y + 0.68, mesh.position.z + 0.02);
|
|
|
- console.log('[ deviceDetailCSS3D.position ] >', this.deviceDetailCSS3D.position);
|
|
|
- this.deviceDetailCSS3D.visible = true;
|
|
|
- return true;
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (this.deviceDetailCSS3D) this.deviceDetailCSS3D.visible = false;
|
|
|
- console.log('[ 点击事件 ] >');
|
|
|
- }
|
|
|
+ // if (mesh.name === 'player1') {
|
|
|
+ // if (new Date().getTime() - this.playerStartClickTime1 < 400) {
|
|
|
+ // // 双击,视频放大
|
|
|
+ // if (this.player1) {
|
|
|
+ // this.player1.requestPictureInPicture();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // this.playerStartClickTime1 = new Date().getTime();
|
|
|
+ // return true;
|
|
|
+ // } else if (mesh.name === 'player2') {
|
|
|
+ // if (new Date().getTime() - this.playerStartClickTime2 < 400) {
|
|
|
+ // // 双击,视频放大
|
|
|
+ // if (this.player2) {
|
|
|
+ // this.player2.requestPictureInPicture();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // this.playerStartClickTime2 = new Date().getTime();
|
|
|
+ // return true;
|
|
|
+ // } else if (mesh.name.startsWith('hotPoint')) {
|
|
|
+ // if (this.deviceDetailCSS3D) {
|
|
|
+ // this.deviceDetailCSS3D.position.set(mesh.position.x + 0.035, mesh.position.y + 0.68, mesh.position.z + 0.02);
|
|
|
+ // console.log('[ deviceDetailCSS3D.position ] >', this.deviceDetailCSS3D.position);
|
|
|
+ // this.deviceDetailCSS3D.visible = true;
|
|
|
+ // return true;
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // if (this.deviceDetailCSS3D) this.deviceDetailCSS3D.visible = false;
|
|
|
+ // console.log('[ 点击事件 ] >');
|
|
|
+ // }
|
|
|
return false;
|
|
|
});
|
|
|
}
|
|
@@ -323,6 +328,7 @@ class Fm1 {
|
|
|
|
|
|
// 播放动画
|
|
|
play(handlerState, timeScale = 0.01) {
|
|
|
+
|
|
|
let handler = () => {};
|
|
|
switch (handlerState) {
|
|
|
case 1: // 打开前门
|
|
@@ -334,6 +340,10 @@ class Fm1 {
|
|
|
// this.clipActionArr.frontDoor.clampWhenFinished = true;
|
|
|
this.clipActionArr.frontDoor.play();
|
|
|
this.fmClock.start();
|
|
|
+
|
|
|
+ // 显示打开前门文字
|
|
|
+ if (this.frontDamperOpenMesh) this.frontDamperOpenMesh.visible = true;
|
|
|
+ if (this.frontDamperClosedMesh) this.frontDamperClosedMesh.visible = false;
|
|
|
};
|
|
|
break;
|
|
|
case 2: // 关闭前门
|
|
@@ -345,6 +355,9 @@ class Fm1 {
|
|
|
// this.clipActionArr.frontDoor.clampWhenFinished = true;
|
|
|
this.clipActionArr.frontDoor.play();
|
|
|
this.fmClock.start();
|
|
|
+
|
|
|
+ if (this.frontDamperOpenMesh) this.frontDamperOpenMesh.visible = false;
|
|
|
+ if (this.frontDamperClosedMesh) this.frontDamperClosedMesh.visible = true;
|
|
|
};
|
|
|
break;
|
|
|
case 3: // 打开后门
|
|
@@ -356,6 +369,9 @@ class Fm1 {
|
|
|
// this.clipActionArr.backDoor.clampWhenFinished = true;
|
|
|
this.clipActionArr.backDoor.play();
|
|
|
this.fmClock.start();
|
|
|
+
|
|
|
+ if (this.backDamperOpenMesh) this.backDamperOpenMesh.visible = true;
|
|
|
+ if (this.backDamperClosedMesh) this.backDamperClosedMesh.visible = false;
|
|
|
};
|
|
|
break;
|
|
|
case 4: // 关闭后门
|
|
@@ -367,6 +383,9 @@ class Fm1 {
|
|
|
// this.clipActionArr.backDoor.clampWhenFinished = true;
|
|
|
this.clipActionArr.backDoor.play();
|
|
|
this.fmClock.start();
|
|
|
+
|
|
|
+ if (this.backDamperOpenMesh) this.backDamperOpenMesh.visible = false;
|
|
|
+ if (this.backDamperClosedMesh) this.backDamperClosedMesh.visible = true;
|
|
|
};
|
|
|
break;
|
|
|
// case 5: // 打开前后门
|
|
@@ -425,7 +444,7 @@ class Fm1 {
|
|
|
// }, 1000);
|
|
|
}
|
|
|
|
|
|
- async initCamera(dom1, dom2) {
|
|
|
+ async initCamera(dom1?, dom2?) {
|
|
|
const videoPlayer1 = dom1;
|
|
|
const videoPlayer2 = dom2;
|
|
|
this.player1 = dom1;
|
|
@@ -442,7 +461,7 @@ class Fm1 {
|
|
|
y: 40,
|
|
|
},
|
|
|
];
|
|
|
- const canvas = await getTextCanvas(560, 346, textArr, '');
|
|
|
+ const canvas = await getTextCanvas(320, 180, '', 'noSinge.png');
|
|
|
|
|
|
let textMaterial: THREE.MeshBasicMaterial | null = null;
|
|
|
if (canvas) {
|
|
@@ -462,58 +481,66 @@ class Fm1 {
|
|
|
textMap.dispose();
|
|
|
}
|
|
|
}
|
|
|
- if (!videoPlayer1) {
|
|
|
- const videoPlayer = this.group.getObjectByName('player1');
|
|
|
- if (videoPlayer) {
|
|
|
- this.model.clearMesh(videoPlayer);
|
|
|
- this.group.remove(videoPlayer);
|
|
|
- }
|
|
|
+ const player1 = this.group.getObjectByName('player1');
|
|
|
+ if (player1) {
|
|
|
+ this.model.clearMesh(player1);
|
|
|
+ this.group.remove(player1);
|
|
|
+ }
|
|
|
+ const noPlayer1 = this.group.getObjectByName('noPlayer1');
|
|
|
+ if (noPlayer1) {
|
|
|
+ this.model.clearMesh(noPlayer1);
|
|
|
+ this.group.remove(noPlayer1);
|
|
|
+ }
|
|
|
+ if (!videoPlayer1 && videoPlayer1 === null) {
|
|
|
if (monitorPlane && !this.group.getObjectByName('noPlayer1')) {
|
|
|
const planeMesh = monitorPlane.clone();
|
|
|
planeMesh.name = 'noPlayer1';
|
|
|
- planeMesh.scale.set(0.011, 0.008, 0.011);
|
|
|
- planeMesh.position.set(-4.23, -0.28, -0.39);
|
|
|
+ planeMesh.scale.set(0.0085, 0.0056, 0.012);
|
|
|
+ planeMesh.position.set(-4.23, 0.02, -0.39);
|
|
|
this.group?.add(planeMesh.clone());
|
|
|
}
|
|
|
- } else {
|
|
|
- const noPlayer1 = this.group.getObjectByName('noPlayer1');
|
|
|
- if (noPlayer1) {
|
|
|
- this.model.clearMesh(noPlayer1);
|
|
|
- this.group.remove(noPlayer1);
|
|
|
- }
|
|
|
- const mesh = renderVideo(this.group, videoPlayer1, 'player1');
|
|
|
- if (mesh) {
|
|
|
- mesh?.scale.set(-0.028, 0.0285, 1);
|
|
|
- mesh?.position.set(-4.262, 0.02, -0.4);
|
|
|
- mesh.rotation.y = -Math.PI;
|
|
|
- this.group.add(mesh);
|
|
|
+ } else if (videoPlayer1) {
|
|
|
+ try {
|
|
|
+ const mesh = renderVideo(this.group, videoPlayer1, 'player1');
|
|
|
+ if (mesh) {
|
|
|
+ mesh?.scale.set(-0.028, 0.0285, 1);
|
|
|
+ mesh?.position.set(-4.262, 0.02, -0.4);
|
|
|
+ mesh.rotation.y = -Math.PI;
|
|
|
+ this.group.add(mesh);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log('视频信号异常');
|
|
|
}
|
|
|
}
|
|
|
- if (!videoPlayer2) {
|
|
|
- const videoPlayer = this.group.getObjectByName('player2');
|
|
|
- if (videoPlayer) {
|
|
|
- this.model.clearMesh(videoPlayer);
|
|
|
- this.group.remove(videoPlayer);
|
|
|
- }
|
|
|
+ const player2 = this.group.getObjectByName('player2');
|
|
|
+ if (player2) {
|
|
|
+ this.model.clearMesh(player2);
|
|
|
+ this.group.remove(player2);
|
|
|
+ }
|
|
|
+ const noPlayer2 = this.group.getObjectByName('noPlayer2');
|
|
|
+ if (noPlayer2) {
|
|
|
+ this.model.clearMesh(noPlayer2);
|
|
|
+ this.group.remove(noPlayer2);
|
|
|
+ }
|
|
|
+ if (!videoPlayer2 && videoPlayer2 === null) {
|
|
|
if (monitorPlane && !this.group.getObjectByName('noPlayer2')) {
|
|
|
const planeMesh = monitorPlane.clone();
|
|
|
planeMesh.name = 'noPlayer2';
|
|
|
- planeMesh.scale.set(0.012, 0.009, 0.012);
|
|
|
- planeMesh.position.set(4.33, -0.33, -0.39);
|
|
|
+ planeMesh.scale.set(0.0085, 0.0056, 0.012);
|
|
|
+ planeMesh.position.set(4.29, 0.02, -0.41);
|
|
|
this.group?.add(planeMesh.clone());
|
|
|
}
|
|
|
- } else {
|
|
|
- const noPlayer2 = this.group.getObjectByName('noPlayer2');
|
|
|
- if (noPlayer2) {
|
|
|
- this.model.clearMesh(noPlayer2);
|
|
|
- this.group.remove(noPlayer2);
|
|
|
- }
|
|
|
- const mesh = renderVideo(this.group, videoPlayer2, 'player2');
|
|
|
- if (mesh) {
|
|
|
- mesh?.scale.set(-0.028, 0.0285, 1);
|
|
|
- mesh?.position.set(4.298, 0.02, -0.4);
|
|
|
- mesh.rotation.y = -Math.PI;
|
|
|
- this.group.add(mesh);
|
|
|
+ } else if (videoPlayer2) {
|
|
|
+ try {
|
|
|
+ const mesh = renderVideo(this.group, videoPlayer2, 'player2');
|
|
|
+ if (mesh) {
|
|
|
+ mesh?.scale.set(-0.028, 0.0285, 1);
|
|
|
+ mesh?.position.set(4.298, 0.02, -0.4);
|
|
|
+ mesh.rotation.y = -Math.PI;
|
|
|
+ this.group.add(mesh);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log('视频信号异常');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -530,7 +557,17 @@ class Fm1 {
|
|
|
this.addLight();
|
|
|
// this.deviceDetailCard();
|
|
|
this.model.animate();
|
|
|
- if (this.model.camera && this.model.camera.layers.mask == -1) this.model.camera.layers.toggle(1);
|
|
|
+
|
|
|
+ this.backDamperOpenMesh = this.group.getObjectByName('Dampler_open_1');
|
|
|
+ if (this.backDamperOpenMesh) this.backDamperOpenMesh.visible = false;
|
|
|
+ this.backDamperClosedMesh = this.group.getObjectByName('Damper_Closed_1');
|
|
|
+ if (this.backDamperClosedMesh) this.backDamperClosedMesh.visible = true;
|
|
|
+
|
|
|
+ this.frontDamperOpenMesh = this.group.getObjectByName('Damper_Open_2');
|
|
|
+ if (this.frontDamperOpenMesh) this.frontDamperOpenMesh.visible = false;
|
|
|
+ this.frontDamperClosedMesh = this.group.getObjectByName('Damper_Closed_2');
|
|
|
+ if (this.frontDamperClosedMesh) this.frontDamperClosedMesh.visible = true;
|
|
|
+
|
|
|
resolve(this.model);
|
|
|
});
|
|
|
});
|