From a18933e1988d48aa3049bf5079fc07183d116da8 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期四, 28 三月 2024 16:46:47 +0800 Subject: [PATCH] # --- zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 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 02416bc..6436449 100644 --- a/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js +++ b/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js @@ -9,8 +9,6 @@ constructor(dom) { this.dom = dom; - this.fullWidth = dom.offsetWidth; - this.fullHeight = dom.offsetHeight; this.objects = []; } @@ -44,6 +42,14 @@ this.controls.autoRotateSpeed = 2; } + getFullWidth = () => { + return this.dom.offsetWidth; + } + + getFullHeight = () => { + return this.dom.offsetHeight; + } + addObject = (object) => { this.scene.add(object); this.objects.push(object); @@ -60,7 +66,7 @@ } initCamera = () => { - const camera = new THREE.PerspectiveCamera(70, this.fullWidth / this.fullHeight, 1, 60000); + const camera = new THREE.PerspectiveCamera(70, this.getFullWidth() / this.getFullHeight(), 1, 60000); camera.position.set(-300, 300, 300); this.scene.add(camera); return camera; @@ -75,7 +81,7 @@ // this.renderer.toneMapping = THREE.ReinhardToneMapping; renderer.toneMapping = THREE.ACESFilmicToneMapping; renderer.setPixelRatio(window.devicePixelRatio); - renderer.setSize(this.fullWidth, this.fullHeight); + renderer.setSize(this.getFullWidth(), this.getFullHeight()); this.dom.appendChild(renderer.domElement); return renderer; } @@ -109,9 +115,9 @@ windowResize = () => { this.resizeHandler = () => { - this.camera.aspect = this.fullWidth / this.fullHeight; + this.camera.aspect = this.getFullWidth() / this.getFullHeight(); this.camera.updateProjectionMatrix(); - this.renderer.setSize(this.fullWidth, this.fullHeight); + this.renderer.setSize(this.getFullWidth(), this.getFullHeight()); }; window.addEventListener('resize', this.resizeHandler, false); } -- Gitblit v1.9.1