From d62c5c0eb2e28b7bf27d23de84a609b5a2e415e4 Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 17 十月 2024 18:48:00 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js b/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
index 5c2913e..fde4550 100644
--- a/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
+++ b/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
@@ -50,11 +50,11 @@
}
getFullWidth = () => {
- return this.dom.offsetWidth;
+ return this.dom?.offsetWidth;
}
getFullHeight = () => {
- return this.dom.offsetHeight;
+ return this.dom?.offsetHeight;
}
addObject = (object) => {
@@ -90,7 +90,7 @@
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(this.getFullWidth(), this.getFullHeight());
- this.dom.appendChild(renderer.domElement);
+ this.dom?.appendChild(renderer.domElement);
return renderer;
}
@@ -136,7 +136,7 @@
initStats = () => {
const stats = new Stats();
- this.dom.appendChild(stats.dom);
+ this.dom?.appendChild(stats.dom);
if (!help) {
stats.domElement.style.display = 'none';
}
@@ -183,7 +183,7 @@
this.handleClick(objName, x, y);
}
}
- this.dom.addEventListener("click", this.handleClickEvent, false);
+ this.dom?.addEventListener("click", this.handleClickEvent, false);
}
generateMesh = (fn) => {
@@ -200,9 +200,15 @@
}
}
- rePerspective = (maxHeight) => {
- this.camera.position.set(-maxHeight * 0.8, maxHeight * 0.8, maxHeight * 0.8);
- this.controls.target = new THREE.Vector3(0, maxHeight * 0.55, 0);
+ rePerspective = (maxHeight, normalHeight) => {
+ const height = Math.max(maxHeight, normalHeight)
+ const cameraPosScale = 0.7;
+ this.camera.position.set(
+ -height * cameraPosScale,
+ height * cameraPosScale,
+ height * cameraPosScale
+ );
+ this.controls.target = new THREE.Vector3(0, maxHeight * 0.53, 0);
}
destroy = () => {
@@ -233,7 +239,7 @@
this.controls.dispose();
this.controls = null;
}
- this.dom.removeEventListener("click", this.handleClickEvent);
+ this.dom?.removeEventListener("click", this.handleClickEvent);
this.camera = null;
this.objects = [];
while (this.dom?.firstChild) {
--
Gitblit v1.9.1