@2112-lab/central-plant 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/bundle/index.js +33146 -1
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +432 -1
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -1
  4. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1853 -1
  5. package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3537 -1
  6. package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +305 -1
  7. package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +542 -1
  8. package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +218 -1
  9. package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +683 -1
  10. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4811 -1
  11. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +480 -1
  12. package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +309 -1
  13. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +120 -1
  14. package/dist/cjs/src/analysis/analysis.js +560 -1
  15. package/dist/cjs/src/analysis/testing.js +958 -1
  16. package/dist/cjs/src/core/centralPlant.js +1149 -1
  17. package/dist/cjs/src/core/debugLogger.js +175 -1
  18. package/dist/cjs/src/core/mathUtils.js +574 -1
  19. package/dist/cjs/src/core/nameUtils.js +93 -1
  20. package/dist/cjs/src/data/export.js +716 -1
  21. package/dist/cjs/src/data/import.js +380 -1
  22. package/dist/cjs/src/data/numerics.js +522 -1
  23. package/dist/cjs/src/helpers/sceneHelper.js +572 -1
  24. package/dist/cjs/src/index.js +69 -1
  25. package/dist/cjs/src/managers/components/animationManager.js +123 -1
  26. package/dist/cjs/src/managers/components/componentManager.js +332 -1
  27. package/dist/cjs/src/managers/components/pathfindingManager.js +1441 -1
  28. package/dist/cjs/src/managers/controls/TransformControls.js +1063 -1
  29. package/dist/cjs/src/managers/controls/cameraControlsManager.js +79 -1
  30. package/dist/cjs/src/managers/controls/dragDropManager.js +1026 -1
  31. package/dist/cjs/src/managers/controls/keyboardControlsManager.js +395 -1
  32. package/dist/cjs/src/managers/controls/transformControlsManager.js +1807 -1
  33. package/dist/cjs/src/managers/environment/environmentManager.js +714 -1
  34. package/dist/cjs/src/managers/environment/textureConfig.js +229 -1
  35. package/dist/cjs/src/managers/scene/sceneExportManager.js +264 -1
  36. package/dist/cjs/src/managers/scene/sceneInitializationManager.js +346 -1
  37. package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1509 -1
  38. package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +661 -1
  39. package/dist/cjs/src/managers/system/disposalManager.js +444 -1
  40. package/dist/cjs/src/managers/system/hotReloadManager.js +291 -1
  41. package/dist/cjs/src/managers/system/performanceMonitor.js +863 -1
  42. package/dist/cjs/src/rendering/modelPreloader.js +369 -1
  43. package/dist/cjs/src/rendering/rendering2D.js +631 -1
  44. package/dist/cjs/src/rendering/rendering3D.js +685 -1
  45. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +396 -1
  46. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -1
  47. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1849 -1
  48. package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3533 -1
  49. package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +301 -1
  50. package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +538 -1
  51. package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +214 -1
  52. package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +679 -1
  53. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4807 -1
  54. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +476 -1
  55. package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +304 -1
  56. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +116 -1
  57. package/dist/esm/src/analysis/analysis.js +536 -1
  58. package/dist/esm/src/analysis/testing.js +954 -1
  59. package/dist/esm/src/core/centralPlant.js +1144 -1
  60. package/dist/esm/src/core/debugLogger.js +167 -1
  61. package/dist/esm/src/core/mathUtils.js +570 -1
  62. package/dist/esm/src/core/nameUtils.js +87 -1
  63. package/dist/esm/src/data/export.js +712 -1
  64. package/dist/esm/src/data/import.js +356 -1
  65. package/dist/esm/src/data/numerics.js +518 -1
  66. package/dist/esm/src/helpers/sceneHelper.js +547 -1
  67. package/dist/esm/src/index.js +35 -1
  68. package/dist/esm/src/managers/components/animationManager.js +119 -1
  69. package/dist/esm/src/managers/components/componentManager.js +328 -1
  70. package/dist/esm/src/managers/components/pathfindingManager.js +1417 -1
  71. package/dist/esm/src/managers/controls/TransformControls.js +1057 -1
  72. package/dist/esm/src/managers/controls/cameraControlsManager.js +75 -1
  73. package/dist/esm/src/managers/controls/dragDropManager.js +1002 -1
  74. package/dist/esm/src/managers/controls/keyboardControlsManager.js +371 -1
  75. package/dist/esm/src/managers/controls/transformControlsManager.js +1782 -1
  76. package/dist/esm/src/managers/environment/environmentManager.js +690 -1
  77. package/dist/esm/src/managers/environment/textureConfig.js +202 -1
  78. package/dist/esm/src/managers/scene/sceneExportManager.js +260 -1
  79. package/dist/esm/src/managers/scene/sceneInitializationManager.js +322 -1
  80. package/dist/esm/src/managers/scene/sceneOperationsManager.js +1485 -1
  81. package/dist/esm/src/managers/scene/sceneTooltipsManager.js +637 -1
  82. package/dist/esm/src/managers/system/disposalManager.js +440 -1
  83. package/dist/esm/src/managers/system/hotReloadManager.js +287 -1
  84. package/dist/esm/src/managers/system/performanceMonitor.js +858 -1
  85. package/dist/esm/src/rendering/modelPreloader.js +364 -1
  86. package/dist/esm/src/rendering/rendering2D.js +627 -1
  87. package/dist/esm/src/rendering/rendering3D.js +661 -1
  88. package/package.json +1 -1
@@ -1 +1,440 @@
1
- import{createClass as t,slicedToArray as n,typeof as i,classCallCheck as e,asyncToGenerator as s,regenerator as l}from"../../../_virtual/_rollupPluginBabelHelpers.js";var a=function(){return t(function t(n){e(this,t),this.sceneViewer=n,this.isDev="development"===process.env.NODE_ENV},[{key:"enhancedDisposal",value:(u=s(l().m(function t(){return l().w(function(t){for(;;)switch(t.n){case 0:return this.isDev,this.forceStopOperations(),t.n=1,this.enhancedSceneCleanup();case 1:this.enhancedRendererCleanup(),this.sceneViewer.hotReloadManager&&this.sceneViewer.hotReloadManager.clearPendingOperations(),this.isDev&&this.sceneViewer.hotReloadManager&&this.sceneViewer.hotReloadManager.forceGarbageCollectionHint();case 2:return t.a(2)}},t,this)})),function(){return u.apply(this,arguments)})},{key:"forceStopOperations",value:function(){this.sceneViewer.isDestroyed=!0,this.sceneViewer.isLoading=!1,this.sceneViewer.currentTransition=null,this.sceneViewer.animationId&&(cancelAnimationFrame(this.sceneViewer.animationId),this.sceneViewer.animationId=null),this.isDev}},{key:"enhancedSceneCleanup",value:(a=s(l().m(function t(){var n,i=this;return l().w(function(t){for(;;)switch(t.n){case 0:if(n={textures:0,materials:0,geometries:0,objects:0},this.sceneViewer.scene){for(this.sceneViewer.scene.traverse(function(t){t.material&&(Array.isArray(t.material)?t.material.forEach(function(t){n.textures+=i.disposeMaterialTextures(t),t.dispose(),n.materials++}):(n.textures+=i.disposeMaterialTextures(t.material),t.material.dispose(),n.materials++)),t.geometry&&(t.geometry.dispose(),n.geometries++),n.objects++});this.sceneViewer.scene.children.length>0;)this.sceneViewer.scene.remove(this.sceneViewer.scene.children[0]);this.isDev}case 1:return t.a(2)}},t,this)})),function(){return a.apply(this,arguments)})},{key:"disposeMaterialTextures",value:function(t){var n=0;return["map","normalMap","roughnessMap","metalnessMap","envMap","lightMap","bumpMap","specularMap"].forEach(function(i){t[i]&&(t[i].dispose(),n++)}),n}},{key:"enhancedRendererCleanup",value:function(){if(this.sceneViewer.renderer){var t=this.sceneViewer.renderer.getContext();if(t&&"function"==typeof t.getExtension){var n=t.getExtension("WEBGL_lose_context");n&&n.loseContext()}this.sceneViewer.renderer.dispose(),this.sceneViewer.renderer.forceContextLoss(),this.sceneViewer.renderer=null,this.isDev}}},{key:"cleanupScene",value:function(){var t=this;if(this.sceneViewer.scene){var n=[];this.sceneViewer.scene.traverse(function(t){n.push(t)});for(var i=function(){var i=n[e];i.geometry&&i.geometry.dispose(),i.material&&(Array.isArray(i.material)?i.material.forEach(function(n){return t.disposeMaterial(n)}):t.disposeMaterial(i.material));["map","lightMap","bumpMap","normalMap","specularMap","envMap"].forEach(function(t){i[t]&&i[t].dispose()}),i.parent&&i.parent.remove(i)},e=n.length-1;e>=0;e--)i();this.sceneViewer.scene.environment&&(this.sceneViewer.scene.environment.dispose(),this.sceneViewer.scene.environment=null),this.sceneViewer.scene.background&&this.sceneViewer.scene.background.dispose&&(this.sceneViewer.scene.background.dispose(),this.sceneViewer.scene.background=null),this.sceneViewer.scene.clear(),this.sceneViewer.scene=null}}},{key:"disposeMaterial",value:function(t){for(var e=0,s=Object.entries(t);e<s.length;e++){var l=n(s[e],2);l[0];var a=l[1];a&&"object"===i(a)&&"function"==typeof a.dispose&&a.dispose()}t.dispose()}},{key:"cleanupRenderer",value:function(){this.sceneViewer.renderer&&(this.sceneViewer.renderer.domElement&&this.sceneViewer.renderer.domElement.parentNode&&this.sceneViewer.renderer.domElement.parentNode.removeChild(this.sceneViewer.renderer.domElement),this.sceneViewer.renderer.dispose(),this.sceneViewer.renderer.forceContextLoss(),this.sceneViewer.renderer=null)}},{key:"cleanupControls",value:function(){this.sceneViewer.controls&&(this.sceneViewer.controls.dispose(),this.sceneViewer.controls=null)}},{key:"cleanupEventListeners",value:function(){this.sceneViewer.handleResize&&(window.removeEventListener("resize",this.sceneViewer.handleResize),this.sceneViewer.handleResize=null),this.sceneViewer.resizeObserver&&(this.sceneViewer.resizeObserver.disconnect(),this.sceneViewer.resizeObserver=null),this.sceneViewer.handleKeyDown&&(window.removeEventListener("keydown",this.sceneViewer.handleKeyDown),this.sceneViewer.handleKeyDown=null),window._performanceKeyHandler&&(window.removeEventListener("keydown",window._performanceKeyHandler),delete window._performanceKeyHandler)}},{key:"cleanupPerformanceMonitoring",value:function(){if(this.sceneViewer.performanceMonitor){try{this.sceneViewer.performanceMonitor.stop()}catch(t){}this.sceneViewer.performanceMonitor=null}if(this.sceneViewer.performanceUI){try{"function"==typeof this.sceneViewer.performanceUI.dispose?this.sceneViewer.performanceUI.dispose():this.sceneViewer.performanceUI.hide()}catch(t){}this.sceneViewer.performanceUI=null}try{var t=document.querySelectorAll("#performance-monitor-ui");t.length>0&&t.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})}catch(t){}}},{key:"cleanupGlobalReferences",value:function(){var t=this.parent;if(t){if(t.tooltipsManager)try{t.tooltipsManager.dispose()}catch(t){}finally{t.tooltipsManager=null}t.hotReloadManager=null,t.sceneExportManager=null,t.componentManager=null,t.sceneInitializationManager=null,t.environmentManager=null,t.keyboardControlsManager=null,t.pathfindingManager=null,t.sceneOperationsManager=null,t.animationManager=null,t.cameraControlsManager=null,t.disposalManager=null}}},{key:"cleanupNuxtEventListeners",value:function(){window.$nuxt&&window.$nuxt.$off&&(window.$nuxt.$off("loadNewScene"),window.$nuxt.$off("createNewScene"))}}]);var a,u}();export{a as DisposalManager};
1
+ import { createClass as _createClass, slicedToArray as _slicedToArray, typeof as _typeof, classCallCheck as _classCallCheck, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+
3
+ /**
4
+ * Disposal Manager Class
5
+ * Handles comprehensive cleanup and disposal of Three.js resources
6
+ */
7
+ var DisposalManager = /*#__PURE__*/function () {
8
+ function DisposalManager(sceneViewer) {
9
+ _classCallCheck(this, DisposalManager);
10
+ this.sceneViewer = sceneViewer;
11
+ this.isDev = process.env.NODE_ENV === 'development';
12
+ }
13
+
14
+ /**
15
+ * Enhanced disposal system with hot-reload support
16
+ */
17
+ return _createClass(DisposalManager, [{
18
+ key: "enhancedDisposal",
19
+ value: (function () {
20
+ var _enhancedDisposal = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
21
+ var _window$_sceneViewerI, _window$_sceneViewerI2;
22
+ return _regenerator().w(function (_context) {
23
+ while (1) switch (_context.n) {
24
+ case 0:
25
+ if (this.isDev) {
26
+ console.log('🔄 [Hot-Reload] Starting enhanced disposal...', {
27
+ timestamp: Date.now(),
28
+ instanceId: this.sceneViewer.instanceId,
29
+ totalInstances: ((_window$_sceneViewerI = window._sceneViewerInstances) === null || _window$_sceneViewerI === void 0 ? void 0 : _window$_sceneViewerI.size) || 0
30
+ });
31
+ }
32
+
33
+ // Immediately stop all operations
34
+ this.forceStopOperations();
35
+
36
+ // Enhanced scene cleanup
37
+ _context.n = 1;
38
+ return this.enhancedSceneCleanup();
39
+ case 1:
40
+ // Enhanced renderer cleanup
41
+ this.enhancedRendererCleanup();
42
+
43
+ // Clear any pending operations (delegate to hot reload manager)
44
+ if (this.sceneViewer.hotReloadManager) {
45
+ this.sceneViewer.hotReloadManager.clearPendingOperations();
46
+ }
47
+
48
+ // Development garbage collection hint
49
+ if (this.isDev) {
50
+ if (this.sceneViewer.hotReloadManager) {
51
+ this.sceneViewer.hotReloadManager.forceGarbageCollectionHint();
52
+ }
53
+ console.log('✅ [Hot-Reload] Enhanced disposal completed', {
54
+ timestamp: Date.now(),
55
+ instanceId: this.sceneViewer.instanceId,
56
+ remainingInstances: ((_window$_sceneViewerI2 = window._sceneViewerInstances) === null || _window$_sceneViewerI2 === void 0 ? void 0 : _window$_sceneViewerI2.size) || 0
57
+ });
58
+ }
59
+ case 2:
60
+ return _context.a(2);
61
+ }
62
+ }, _callee, this);
63
+ }));
64
+ function enhancedDisposal() {
65
+ return _enhancedDisposal.apply(this, arguments);
66
+ }
67
+ return enhancedDisposal;
68
+ }()
69
+ /**
70
+ * Force stop all ongoing operations immediately
71
+ */
72
+ )
73
+ }, {
74
+ key: "forceStopOperations",
75
+ value: function forceStopOperations() {
76
+ this.sceneViewer.isDestroyed = true;
77
+ this.sceneViewer.isLoading = false;
78
+ this.sceneViewer.currentTransition = null;
79
+
80
+ // Stop any ongoing animations
81
+ if (this.sceneViewer.animationId) {
82
+ cancelAnimationFrame(this.sceneViewer.animationId);
83
+ this.sceneViewer.animationId = null;
84
+ }
85
+ if (this.isDev) {
86
+ console.log('🛑 [Hot-Reload] Forced stop of all operations');
87
+ }
88
+ }
89
+
90
+ /**
91
+ * Enhanced scene cleanup with better memory leak prevention
92
+ */
93
+ }, {
94
+ key: "enhancedSceneCleanup",
95
+ value: (function () {
96
+ var _enhancedSceneCleanup = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
97
+ var _this = this;
98
+ var disposedCount;
99
+ return _regenerator().w(function (_context2) {
100
+ while (1) switch (_context2.n) {
101
+ case 0:
102
+ disposedCount = {
103
+ textures: 0,
104
+ materials: 0,
105
+ geometries: 0,
106
+ objects: 0
107
+ };
108
+ if (this.sceneViewer.scene) {
109
+ // Dispose in proper order: textures → materials → geometries → objects
110
+ this.sceneViewer.scene.traverse(function (child) {
111
+ if (child.material) {
112
+ if (Array.isArray(child.material)) {
113
+ child.material.forEach(function (material) {
114
+ disposedCount.textures += _this.disposeMaterialTextures(material);
115
+ material.dispose();
116
+ disposedCount.materials++;
117
+ });
118
+ } else {
119
+ disposedCount.textures += _this.disposeMaterialTextures(child.material);
120
+ child.material.dispose();
121
+ disposedCount.materials++;
122
+ }
123
+ }
124
+ if (child.geometry) {
125
+ child.geometry.dispose();
126
+ disposedCount.geometries++;
127
+ }
128
+ disposedCount.objects++;
129
+ });
130
+
131
+ // Clear scene
132
+ while (this.sceneViewer.scene.children.length > 0) {
133
+ this.sceneViewer.scene.remove(this.sceneViewer.scene.children[0]);
134
+ }
135
+ if (this.isDev) {
136
+ console.log('🧹 [Hot-Reload] Enhanced scene cleanup completed:', disposedCount);
137
+ }
138
+ }
139
+ case 1:
140
+ return _context2.a(2);
141
+ }
142
+ }, _callee2, this);
143
+ }));
144
+ function enhancedSceneCleanup() {
145
+ return _enhancedSceneCleanup.apply(this, arguments);
146
+ }
147
+ return enhancedSceneCleanup;
148
+ }()
149
+ /**
150
+ * Dispose material textures and return count
151
+ */
152
+ )
153
+ }, {
154
+ key: "disposeMaterialTextures",
155
+ value: function disposeMaterialTextures(material) {
156
+ var textureCount = 0;
157
+ var textureProperties = ['map', 'normalMap', 'roughnessMap', 'metalnessMap', 'envMap', 'lightMap', 'bumpMap', 'specularMap'];
158
+ textureProperties.forEach(function (prop) {
159
+ if (material[prop]) {
160
+ material[prop].dispose();
161
+ textureCount++;
162
+ }
163
+ });
164
+ return textureCount;
165
+ }
166
+
167
+ /**
168
+ * Enhanced renderer cleanup with WebGL state clearing
169
+ */
170
+ }, {
171
+ key: "enhancedRendererCleanup",
172
+ value: function enhancedRendererCleanup() {
173
+ if (this.sceneViewer.renderer) {
174
+ // Clear WebGL state
175
+ var gl = this.sceneViewer.renderer.getContext();
176
+ if (gl && typeof gl.getExtension === 'function') {
177
+ // Force WebGL context loss to free memory
178
+ var loseContext = gl.getExtension('WEBGL_lose_context');
179
+ if (loseContext) {
180
+ loseContext.loseContext();
181
+ }
182
+ }
183
+
184
+ // Standard renderer disposal
185
+ this.sceneViewer.renderer.dispose();
186
+ this.sceneViewer.renderer.forceContextLoss();
187
+ this.sceneViewer.renderer = null;
188
+ if (this.isDev) {
189
+ console.log('🎮 [Hot-Reload] Enhanced renderer cleanup with WebGL state clearing');
190
+ }
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Clean up scene objects with material and geometry disposal
196
+ */
197
+ }, {
198
+ key: "cleanupScene",
199
+ value: function cleanupScene() {
200
+ var _this2 = this;
201
+ if (!this.sceneViewer.scene) return;
202
+ console.log('🗑️ Disposing scene objects...');
203
+
204
+ // Collect all objects to dispose
205
+ var objectsToDispose = [];
206
+ this.sceneViewer.scene.traverse(function (object) {
207
+ objectsToDispose.push(object);
208
+ });
209
+
210
+ // Dispose objects in reverse order (children first)
211
+ var _loop = function _loop() {
212
+ var object = objectsToDispose[i];
213
+
214
+ // Dispose geometry
215
+ if (object.geometry) {
216
+ object.geometry.dispose();
217
+ }
218
+
219
+ // Dispose materials
220
+ if (object.material) {
221
+ if (Array.isArray(object.material)) {
222
+ object.material.forEach(function (material) {
223
+ return _this2.disposeMaterial(material);
224
+ });
225
+ } else {
226
+ _this2.disposeMaterial(object.material);
227
+ }
228
+ }
229
+
230
+ // Dispose textures on lights and other objects
231
+ var textureProperties = ['map', 'lightMap', 'bumpMap', 'normalMap', 'specularMap', 'envMap'];
232
+ textureProperties.forEach(function (prop) {
233
+ if (object[prop]) object[prop].dispose();
234
+ });
235
+
236
+ // Remove from parent
237
+ if (object.parent) {
238
+ object.parent.remove(object);
239
+ }
240
+ };
241
+ for (var i = objectsToDispose.length - 1; i >= 0; i--) {
242
+ _loop();
243
+ }
244
+
245
+ // Dispose scene environment and background
246
+ if (this.sceneViewer.scene.environment) {
247
+ this.sceneViewer.scene.environment.dispose();
248
+ this.sceneViewer.scene.environment = null;
249
+ }
250
+ if (this.sceneViewer.scene.background && this.sceneViewer.scene.background.dispose) {
251
+ this.sceneViewer.scene.background.dispose();
252
+ this.sceneViewer.scene.background = null;
253
+ }
254
+
255
+ // Clear scene
256
+ this.sceneViewer.scene.clear();
257
+ this.sceneViewer.scene = null;
258
+ }
259
+
260
+ /**
261
+ * Dispose a material and its textures
262
+ */
263
+ }, {
264
+ key: "disposeMaterial",
265
+ value: function disposeMaterial(material) {
266
+ // Dispose all texture properties
267
+ for (var _i = 0, _Object$entries = Object.entries(material); _i < _Object$entries.length; _i++) {
268
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2);
269
+ _Object$entries$_i[0];
270
+ var value = _Object$entries$_i[1];
271
+ if (value && _typeof(value) === 'object' && typeof value.dispose === 'function') {
272
+ value.dispose();
273
+ }
274
+ }
275
+ material.dispose();
276
+ }
277
+
278
+ /**
279
+ * Clean up renderer resources
280
+ */
281
+ }, {
282
+ key: "cleanupRenderer",
283
+ value: function cleanupRenderer() {
284
+ if (this.sceneViewer.renderer) {
285
+ // Remove renderer DOM element
286
+ if (this.sceneViewer.renderer.domElement && this.sceneViewer.renderer.domElement.parentNode) {
287
+ this.sceneViewer.renderer.domElement.parentNode.removeChild(this.sceneViewer.renderer.domElement);
288
+ }
289
+
290
+ // Dispose renderer resources
291
+ this.sceneViewer.renderer.dispose();
292
+ this.sceneViewer.renderer.forceContextLoss();
293
+ this.sceneViewer.renderer = null;
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Clean up controls
299
+ */
300
+ }, {
301
+ key: "cleanupControls",
302
+ value: function cleanupControls() {
303
+ if (this.sceneViewer.controls) {
304
+ this.sceneViewer.controls.dispose();
305
+ this.sceneViewer.controls = null;
306
+ }
307
+ }
308
+
309
+ /**
310
+ * Clean up event listeners
311
+ */
312
+ }, {
313
+ key: "cleanupEventListeners",
314
+ value: function cleanupEventListeners() {
315
+ if (this.sceneViewer.handleResize) {
316
+ window.removeEventListener('resize', this.sceneViewer.handleResize);
317
+ this.sceneViewer.handleResize = null;
318
+ }
319
+ if (this.sceneViewer.resizeObserver) {
320
+ this.sceneViewer.resizeObserver.disconnect();
321
+ this.sceneViewer.resizeObserver = null;
322
+ }
323
+ if (this.sceneViewer.handleKeyDown) {
324
+ window.removeEventListener('keydown', this.sceneViewer.handleKeyDown);
325
+ this.sceneViewer.handleKeyDown = null;
326
+ }
327
+ if (window._performanceKeyHandler) {
328
+ window.removeEventListener('keydown', window._performanceKeyHandler);
329
+ delete window._performanceKeyHandler;
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Clean up performance monitoring
335
+ */
336
+ }, {
337
+ key: "cleanupPerformanceMonitoring",
338
+ value: function cleanupPerformanceMonitoring() {
339
+ console.log('🧹 Cleaning up performance monitoring...');
340
+ if (this.sceneViewer.performanceMonitor) {
341
+ try {
342
+ this.sceneViewer.performanceMonitor.stop();
343
+ } catch (error) {
344
+ console.warn('⚠️ Error stopping performance monitor:', error);
345
+ }
346
+ this.sceneViewer.performanceMonitor = null;
347
+ }
348
+ if (this.sceneViewer.performanceUI) {
349
+ try {
350
+ // Use dispose() method for proper cleanup instead of hide()
351
+ if (typeof this.sceneViewer.performanceUI.dispose === 'function') {
352
+ this.sceneViewer.performanceUI.dispose();
353
+ } else {
354
+ // Fallback to hide() if dispose() doesn't exist
355
+ console.warn('⚠️ PerformanceUI dispose() method not available, falling back to hide()');
356
+ this.sceneViewer.performanceUI.hide();
357
+ }
358
+ } catch (error) {
359
+ console.warn('⚠️ Error disposing performance UI:', error);
360
+ }
361
+ this.sceneViewer.performanceUI = null;
362
+ }
363
+
364
+ // Additional cleanup: remove any stray performance monitor elements
365
+ try {
366
+ var strayElements = document.querySelectorAll('#performance-monitor-ui');
367
+ if (strayElements.length > 0) {
368
+ console.log("\uD83E\uDDF9 Found ".concat(strayElements.length, " stray performance monitor elements, removing..."));
369
+ strayElements.forEach(function (element) {
370
+ if (element.parentNode) {
371
+ element.parentNode.removeChild(element);
372
+ }
373
+ });
374
+ }
375
+ } catch (error) {
376
+ console.warn('⚠️ Error cleaning up stray performance monitor elements:', error);
377
+ }
378
+ console.log('✅ Performance monitoring cleanup completed');
379
+ }
380
+ /**
381
+ * Clean up global references
382
+ */
383
+ }, {
384
+ key: "cleanupGlobalReferences",
385
+ value: function cleanupGlobalReferences() {
386
+ console.log('🧹 Cleaning up global references...');
387
+ var parent = this.parent;
388
+
389
+ // Check if parent exists before proceeding
390
+ if (!parent) {
391
+ console.warn('⚠️ Parent not available for global references cleanup');
392
+ return;
393
+ }
394
+
395
+ // Clean up tooltips manager with extra safety
396
+ if (parent.tooltipsManager) {
397
+ try {
398
+ console.log('🧹 Disposing tooltipsManager...');
399
+ parent.tooltipsManager.dispose();
400
+ } catch (e) {
401
+ console.error('Error disposing tooltipsManager:', e);
402
+ } finally {
403
+ // Always null the reference even if dispose fails
404
+ parent.tooltipsManager = null;
405
+ console.log('✅ tooltipsManager nullified');
406
+ }
407
+ }
408
+
409
+ // Clean up other managers - now safe since we checked parent exists
410
+ parent.hotReloadManager = null;
411
+ parent.sceneExportManager = null;
412
+ parent.componentManager = null;
413
+ parent.sceneInitializationManager = null;
414
+ parent.environmentManager = null;
415
+ parent.keyboardControlsManager = null;
416
+ parent.pathfindingManager = null;
417
+ parent.sceneOperationsManager = null;
418
+ parent.animationManager = null;
419
+ parent.cameraControlsManager = null;
420
+
421
+ // Set disposal manager to null last
422
+ parent.disposalManager = null;
423
+ console.log('✅ Global references cleaned up');
424
+ }
425
+
426
+ /**
427
+ * Clean up Nuxt event listeners
428
+ */
429
+ }, {
430
+ key: "cleanupNuxtEventListeners",
431
+ value: function cleanupNuxtEventListeners() {
432
+ if (window.$nuxt && window.$nuxt.$off) {
433
+ window.$nuxt.$off('loadNewScene');
434
+ window.$nuxt.$off('createNewScene');
435
+ }
436
+ }
437
+ }]);
438
+ }();
439
+
440
+ export { DisposalManager };