From 4846dd5a2fdf80538d440e113f8cd7296b9c4d93 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 28 三月 2024 09:23:01 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js | 46 ++++++++++++++++++++++++++--------------------
1 files changed, 26 insertions(+), 20 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 aaa6a1e..459d919 100644
--- a/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
+++ b/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
@@ -3,12 +3,7 @@
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls'
import TWEEN from '@tweenjs/tween.js';
-const help = true;
-const debugCamera = {
- x: 200,
- y: 200,
- z: 200
-}
+const help = false;
export default class ShelfThree {
@@ -23,7 +18,7 @@
this.stats = this.initStats(container);
this.windowResize();
this.initRaycaster(container);
- // initLight(this.scene);
+ initLight(this.scene);
this.objects = [];
}
@@ -34,12 +29,13 @@
}
animate = () => {
- requestAnimationFrame(this.animate);
+ this.animationFrame = requestAnimationFrame(this.animate);
this.render();
TWEEN.update();
}
render = () => {
+ console.log(1);
this.renderer.shadowMap.enabled = true;
this.renderer.render(this.scene, this.camera);
this.stats.update();
@@ -64,8 +60,8 @@
}
initCamera = () => {
- const camera = new THREE.PerspectiveCamera(70, this.fullWidth / this.fullHeight, 1, 10000);
- camera.position.set(debugCamera.x, debugCamera.y, debugCamera.z);
+ const camera = new THREE.PerspectiveCamera(70, this.fullWidth / this.fullHeight, 1, 60000);
+ camera.position.set(200, 200, 200);
this.scene.add(camera);
return camera;
}
@@ -112,12 +108,12 @@
}
windowResize = () => {
- let that = this;
- window.addEventListener('resize', function () {
- that.camera.aspect = this.fullWidth / this.fullHeight;
- that.camera.updateProjectionMatrix();
- that.renderer.setSize(that.fullWidth, that.fullHeight);
- }, false);
+ this.resizeHandler = () => {
+ this.camera.aspect = this.fullWidth / this.fullHeight;
+ this.camera.updateProjectionMatrix();
+ this.renderer.setSize(this.fullWidth, this.fullHeight);
+ };
+ window.addEventListener('resize', this.resizeHandler, false);
}
initRaycaster = (container) => {
@@ -167,6 +163,13 @@
handleClick = () => {
}
+
+ destroy = () => {
+ cancelAnimationFrame(this.animationFrame);
+ window.removeEventListener('resize', this.resizeHandler);
+ this.renderer.dispose();
+ this.controls.dispose();
+ }
};
const initLight = (scene) => {
@@ -178,13 +181,16 @@
scene.add(ambientLight);
const spotLight = new THREE.SpotLight(0xffffff, 8);
- spotLight.position.set(0, 300, 0);
- spotLight.angle = Math.PI * 1;
- spotLight.decay = 0;
+ spotLight.position.set(0, 1000, 0);
+ spotLight.angle = Math.PI / 4; // 瑙掑害
+ spotLight.distance = 1500; // 璺濈
+ spotLight.decay = 0; // 鍏夎“
+ // 鍏夌収闃村奖鍙婂叾鐢熸晥鑼冨洿
spotLight.castShadow = true;
- spotLight.shadow.camera.near = 200;
+ spotLight.shadow.camera.near = 50;
spotLight.shadow.camera.far = 2000;
spotLight.shadow.bias = - 0.000222;
+ // 闃村奖鐗规晥楂樹綆鍊�
spotLight.shadow.mapSize.width = 1024;
spotLight.shadow.mapSize.height = 1024;
scene.add(spotLight);
--
Gitblit v1.9.1