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 | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 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 010d3ed..fde4550 100644
--- a/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
+++ b/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
@@ -10,7 +10,7 @@
import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader'
import * as Utils from '../../utils'
-const help = true;
+const help = false;
export default class ShelfThree {
@@ -50,11 +50,11 @@
}
getFullWidth = () => {
- return this.dom.offsetWidth;
+ return this.dom?.offsetWidth;
}
getFullHeight = () => {
- return this.dom.offsetHeight;
+ return this.dom?.offsetHeight;
}
addObject = (object) => {
@@ -64,9 +64,6 @@
initScene = () => {
const scene = new THREE.Scene();
- // scene.background = new THREE.Color(0xf0f0f0);
- // scene.background = new THREE.Color(0x333333);
-
// scene.background = new THREE.Color(0xf8f8f8);
scene.background = new THREE.Color(0x7a7a7a);
scene.fog = new THREE.Fog(scene.background, 1, 5000);
@@ -93,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;
}
@@ -121,14 +118,14 @@
initControls = () => {
const controls = new OrbitControls(this.camera, this.renderer.domElement);
// controls.enableRotate = false; // 绂佺敤鏁翠綋鏃嬭浆鍔熻兘
- controls.enablePan = true; // 鍏佽骞崇Щ
+ controls.enablePan = false; // 鍏佽骞崇Щ
controls.enableDamping = true; // 寮�鍚樆灏�
controls.dampingFactor = 0.08; // 闃诲凹鍥犲瓙
controls.enableZoom = true; // 鍏佽缂╂斁
// controls.minDistance = 1; // 鏈�灏忕缉鏀捐窛绂�
// controls.maxDistance = 30; // 鏈�澶х缉鏀捐窛绂�
controls.minPolarAngle = 0; // 鏈�灏忎刊浠拌搴︼紙鍚戜笅鐪嬶級
- // controls.minPolarAngle = Math.PI / 2.1;
+ controls.minPolarAngle = Math.PI / 2.1;
controls.maxPolarAngle = Math.PI / 2.1; // 鏈�澶т刊浠拌搴︼紙鍚戜笂鐪嬶級
controls.rotateSpeed = 0.6; // 瑙嗚绉诲姩閫熷害鍑忔參
controls.autoRotate = true; // 鑷姩鏃嬭浆
@@ -139,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';
}
@@ -186,7 +183,7 @@
this.handleClick(objName, x, y);
}
}
- this.dom.addEventListener("click", this.handleClickEvent, false);
+ this.dom?.addEventListener("click", this.handleClickEvent, false);
}
generateMesh = (fn) => {
@@ -201,6 +198,17 @@
break;
}
}
+ }
+
+ 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 = () => {
@@ -231,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