From 2ade0a881a00bf7ebc6cd6067f52d3a268508111 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 28 三月 2024 14:12:49 +0800
Subject: [PATCH] #
---
zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js | 31 +++++++++++++++++++++++++++++--
zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx | 28 +++++++++++++++++++---------
2 files changed, 48 insertions(+), 11 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 c7a6fd8..fc082f0 100644
--- a/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
+++ b/zy-asrs-flow/src/pages/map/drawer/shelf/shelfThree.js
@@ -167,8 +167,35 @@
destroy = () => {
cancelAnimationFrame(this.animationFrame);
window.removeEventListener('resize', this.resizeHandler);
- this.renderer.dispose();
- this.controls.dispose();
+ if (this.scene) {
+ while (this.scene.children.length > 0) {
+ this.removeEntity(this.scene.children[0]);
+ }
+ this.scene = null;
+ }
+ if (this.renderer) {
+ this.renderer.dispose();
+ this.renderer.forceContextLoss();
+ this.renderer.context = null;
+ this.renderer.domElement = null;
+ this.renderer = null;
+ }
+ if (this.controls) {
+ this.controls.dispose();
+ this.controls = null;
+ }
+ this.camera = null;
+ this.objects = [];
+ while (this.dom?.firstChild) {
+ this.dom.removeChild(this.dom.firstChild);
+ }
+ }
+
+ removeEntity = (object) => {
+ if (object.material) object.material.dispose();
+ if (object.geometry) object.geometry.dispose();
+ if (object.texture) object.texture.dispose();
+ this.scene.remove(object);
}
};
diff --git a/zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx b/zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx
index 4afd377..93b021f 100644
--- a/zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx
+++ b/zy-asrs-flow/src/pages/map/drawer/shelf/view.jsx
@@ -23,20 +23,30 @@
const intl = useIntl();
const { styles } = useStyles();
const refContainer = useRef();
- const [loading, setLoading] = React.useState(true);
+ const [loading, setLoading] = React.useState(false);
+
+ const startThree = () => {
+ shelfThree = new ShelfThree(refContainer.current);
+ shelfThree.startup();
+ }
+
+ const endThree = () => {
+ if (shelfThree) {
+ shelfThree.destroy();
+ shelfThree = null;
+ }
+ }
useEffect(() => {
- console.log(props);
+ setLoading(true);
+ endThree();
setTimeout(() => {
setLoading(false);
- shelfThree = new ShelfThree(refContainer.current);
- shelfThree.startup();
- }, 1000)
+ startThree();
+ }, 300)
- return () => {
- shelfThree?.destroy();
- }
- }, [props]);
+ return endThree;
+ }, [props.data.uuid]);
return (
<>
--
Gitblit v1.9.1