From 736973883280e9a6059c5da2f2e67d5a6aecdcef Mon Sep 17 00:00:00 2001
From: zhang <zc857179121@qq.com>
Date: 星期五, 29 八月 2025 15:03:22 +0800
Subject: [PATCH] 1

---
 zy-acs-flow/src/map/insight/agv/AgvThree.js |  106 ++++++++--------------------------------------------
 1 files changed, 17 insertions(+), 89 deletions(-)

diff --git a/zy-acs-flow/src/map/insight/agv/AgvThree.js b/zy-acs-flow/src/map/insight/agv/AgvThree.js
index 1a15c01..b4671bd 100644
--- a/zy-acs-flow/src/map/insight/agv/AgvThree.js
+++ b/zy-acs-flow/src/map/insight/agv/AgvThree.js
@@ -2,11 +2,6 @@
 import Stats from 'three/addons/libs/stats.module.js';
 import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls';
 import TWEEN from '@tweenjs/tween.js';
-import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer';
-import { RenderPass } from 'three/examples/jsm/postprocessing/RenderPass';
-import { OutlinePass } from 'three/examples/jsm/postprocessing/OutlinePass';
-import { ShaderPass } from 'three/examples/jsm/postprocessing/ShaderPass';
-import { FXAAShader } from 'three/examples/jsm/shaders/FXAAShader';
 import { FBXLoader } from 'three/examples/jsm/loaders/FBXLoader';
 
 const help = false;
@@ -24,9 +19,7 @@
         this.renderer = this.initRenderer();
         this.controls = this.initControls();
         this.stats = this.initStats();
-        this.composer = this.initComposer();
         this.initLight();
-        this.initRaycaster();
         this.windowResize();
 
         this.animate();
@@ -39,7 +32,7 @@
     }
 
     render = () => {
-        this.composer.render();
+        this.renderer.render(this.scene, this.camera);
         this.stats.update();
         this.controls.update();
     }
@@ -59,7 +52,7 @@
 
     initScene = () => {
         const scene = new THREE.Scene();
-        scene.background = new THREE.Color(0x7a7a7a);
+        scene.background = new THREE.Color(0x323232);
         scene.fog = new THREE.Fog(scene.background, 1, 5000);
         if (help) {
             scene.add(new THREE.AxesHelper(1000));
@@ -78,32 +71,10 @@
         renderer.setClearAlpha(0);
         renderer.shadowMap.enabled = true;
         renderer.toneMapping = THREE.ACESFilmicToneMapping;
-        renderer.setPixelRatio(window.devicePixelRatio);
+        renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
         renderer.setSize(this.getFullWidth(), this.getFullHeight());
         this.dom?.appendChild(renderer.domElement);
         return renderer;
-    }
-
-    initComposer = () => {
-        const composer = new EffectComposer(this.renderer);
-        const renderPass = new RenderPass(this.scene, this.camera);
-        composer.addPass(renderPass);
-
-        const pixelRatio = this.renderer.getPixelRatio();
-        const newWidth = Math.floor(this.getFullWidth() * pixelRatio) || 1;
-        const newHeight = Math.floor(this.getFullHeight() * pixelRatio) || 1;
-        composer.setSize(newWidth, newHeight);
-
-        const effectFXAA = new ShaderPass(FXAAShader);
-        effectFXAA.uniforms['resolution'].value.set(1 / newWidth, 1 / newHeight);
-        composer.addPass(effectFXAA);
-
-        this.outlinePass = new OutlinePass(new THREE.Vector2(this.getFullWidth(), this.getFullHeight()), this.scene, this.camera);
-        this.outlinePass.visibleEdgeColor.set('#ffffff');
-        this.outlinePass.edgeStrength = 10;
-        composer.addPass(this.outlinePass);
-
-        return composer;
     }
 
     initControls = () => {
@@ -150,52 +121,10 @@
         this.scene.add(dirLight1);
     }
 
-    initRaycaster = () => {
-        this.raycaster = new THREE.Raycaster();
-        this.mouse = new THREE.Vector2();
-        this.handleClickEvent = (event) => {
-            let x, y;
-            if (event.changedTouches) {
-                x = event.changedTouches[0].pageX;
-                y = event.changedTouches[0].pageY;
-            } else {
-                x = event.clientX;
-                y = event.clientY;
-            }
-            let rect = this.dom.getBoundingClientRect();
-            this.mouse.x = ((x - rect.left) / rect.width) * 2 - 1;
-            this.mouse.y = -((y - rect.top) / rect.height) * 2 + 1;
-            event.preventDefault();
-            this.raycaster.setFromCamera(this.mouse, this.camera);
-            let intersects = this.raycaster.intersectObjects(this.objects, true);
-            if (intersects.length === 0) {
-                return;
-            }
-            let objName = intersects[0].object.name;
-            this.objects.forEach(obj => {
-                if (obj.name === objName) {
-                    this.outlinePass.selectedObjects = [obj];
-                }
-            });
-            if (objName && this.handleClick) {
-                this.handleClick(objName, x, y);
-            }
-        }
-        this.dom?.addEventListener("click", this.handleClickEvent, false);
-    }
 
     generateMesh = (fn) => {
         const loader = new FBXLoader();
         fn(loader, this.addObject);
-    }
-
-    setNewSelectedMesh = (objName) => {
-        for (const obj of this.objects) {
-            if (obj.name === objName) {
-                this.outlinePass.selectedObjects = [obj];
-                break;
-            }
-        }
     }
 
     rePerspective = (maxHeight, normalHeight) => {
@@ -214,7 +143,6 @@
             this.camera.aspect = this.getFullWidth() / this.getFullHeight();
             this.camera.updateProjectionMatrix();
             this.renderer.setSize(this.getFullWidth(), this.getFullHeight());
-            this.composer.setSize(this.getFullWidth(), this.getFullHeight());
         };
         window.addEventListener('resize', this.resizeHandler, false);
     }
@@ -231,28 +159,28 @@
         if (this.renderer) {
             this.renderer.dispose();
             this.renderer.forceContextLoss();
-            this.renderer.context = null;
-            this.renderer.domElement = null;
-            this.renderer = null;
-        }
-        if (this.composer) {
-            this.composer.passes.forEach(pass => {
-                if (pass.dispose) {
-                    pass.dispose();
+            if (this.dom && this.renderer.domElement && this.dom.contains(this.renderer.domElement)) {
+                try {
+                    this.dom.removeChild(this.renderer.domElement);
+                } catch (error) {
+                    console.warn('Failed to remove renderer.domElement:', error);
                 }
-            });
-            this.composer = null;
+            }
+            this.renderer = null;
         }
         if (this.controls) {
             this.controls.dispose();
             this.controls = null;
         }
-        this.dom?.removeEventListener("click", this.handleClickEvent);
+        if (this.stats && this.stats.domElement && this.dom.contains(this.stats.domElement)) {
+            try {
+                this.dom.removeChild(this.stats.domElement);
+            } catch (error) {
+                console.warn('Failed to remove stats.domElement:', error);
+            }
+        }
         this.camera = null;
         this.objects = [];
-        while (this.dom?.firstChild) {
-            this.dom.removeChild(this.dom.firstChild);
-        }
     }
 
     removeEntity = (object) => {

--
Gitblit v1.9.1