@2112-lab/central-plant 0.1.6 โ†’ 0.1.7

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.
@@ -0,0 +1,799 @@
1
+ import { createClass as _createClass, slicedToArray as _slicedToArray, createForOfIteratorHelper as _createForOfIteratorHelper, classCallCheck as _classCallCheck, objectSpread2 as _objectSpread2, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import * as THREE from 'three';
3
+
4
+ var SceneViewer = /*#__PURE__*/function () {
5
+ /**
6
+ * Initialize the SceneViewer
7
+ * @param {HTMLElement} container - DOM element to render the scene
8
+ * @param {Object} options - Configuration options
9
+ * @param {Object} centralPlant - CentralPlant instance for managers
10
+ */
11
+ function SceneViewer(container) {
12
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
13
+ var centralPlant = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
14
+ _classCallCheck(this, SceneViewer);
15
+ // Core properties
16
+ this.container = container;
17
+ this.centralPlant = centralPlant;
18
+ this.options = _objectSpread2({
19
+ enableAutoRotation: false,
20
+ enableShadows: true,
21
+ enableBloom: true,
22
+ enableSSAO: false,
23
+ antialias: true,
24
+ pixelRatio: Math.min(window.devicePixelRatio, 2)
25
+ }, options);
26
+
27
+ // Instance tracking for hot-reload handling
28
+ this.instanceId = Date.now() + Math.random();
29
+
30
+ // Core Three.js objects
31
+ this.scene = null;
32
+ this.camera = null;
33
+ this.renderer = null;
34
+ this.controls = null;
35
+ this.composer = null;
36
+ this.bloomPass = null;
37
+ this.ssaoPass = null;
38
+
39
+ // Utilities
40
+ this.textureLoader = null;
41
+ this.gltfLoader = null;
42
+ this.envMap = null;
43
+ this.performanceMonitor = null;
44
+ this.resizeObserver = null;
45
+
46
+ // Scene data
47
+ this.currentSceneData = null;
48
+
49
+ // State flags
50
+ this.isDestroyed = false;
51
+ this.isInitialized = false;
52
+
53
+ // Transform controls
54
+ this.transformManager = null;
55
+ this.selectedObjectForTransform = null;
56
+ this.transformMode = 'translate';
57
+ this.transformSpace = 'world';
58
+ this.transformHistory = [];
59
+ this.previousTransformValues = null;
60
+
61
+ // Manager instances (will be attached from centralPlant)
62
+ this.managers = {};
63
+
64
+ // Event system for communication with external systems
65
+ this.eventCallbacks = new Map();
66
+
67
+ // Drag and drop state
68
+ this.isDragOver = false;
69
+ this.dragDropManager = null;
70
+
71
+ // Scene helper utility
72
+ this.sceneHelper = null;
73
+
74
+ // Pathfinder version cache
75
+ this.pathfinderVersionInfo = null;
76
+
77
+ // Transform settings
78
+ this.shouldUpdatePaths = true;
79
+
80
+ // Initialize the scene viewer
81
+ this.init();
82
+ }
83
+
84
+ /**
85
+ * Initialize the Three.js scene and all components
86
+ */
87
+ return _createClass(SceneViewer, [{
88
+ key: "init",
89
+ value: (function () {
90
+ var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
91
+ var _t;
92
+ return _regenerator().w(function (_context) {
93
+ while (1) switch (_context.n) {
94
+ case 0:
95
+ _context.p = 0;
96
+ console.log('๐Ÿš€ Initializing SceneViewer...', {
97
+ instanceId: this.instanceId,
98
+ containerSize: {
99
+ width: this.container.clientWidth,
100
+ height: this.container.clientHeight
101
+ }
102
+ });
103
+
104
+ // Attach managers from centralPlant if available
105
+ if (this.centralPlant) {
106
+ this.attachManagers();
107
+ }
108
+
109
+ // Initialize Three.js components
110
+ this.initScene();
111
+ this.initCamera();
112
+ this.initRenderer();
113
+ this.initLights();
114
+ this.initControls();
115
+ this.initPostProcessing();
116
+ this.initEventListeners();
117
+
118
+ // Initialize managers that require scene to be ready
119
+ _context.n = 1;
120
+ return this.initializeSceneManagers();
121
+ case 1:
122
+ // Start the animation loop
123
+ this.animate();
124
+ this.isInitialized = true;
125
+ this.emit('initialized', {
126
+ sceneViewer: this
127
+ });
128
+ console.log('โœ… SceneViewer initialization completed');
129
+ _context.n = 3;
130
+ break;
131
+ case 2:
132
+ _context.p = 2;
133
+ _t = _context.v;
134
+ console.error('โŒ Error initializing SceneViewer:', _t);
135
+ this.emit('error', {
136
+ error: _t,
137
+ phase: 'initialization'
138
+ });
139
+ case 3:
140
+ return _context.a(2);
141
+ }
142
+ }, _callee, this, [[0, 2]]);
143
+ }));
144
+ function init() {
145
+ return _init.apply(this, arguments);
146
+ }
147
+ return init;
148
+ }()
149
+ /**
150
+ * Attach managers from centralPlant
151
+ */
152
+ )
153
+ }, {
154
+ key: "attachManagers",
155
+ value: function attachManagers() {
156
+ var _this = this;
157
+ if (!this.centralPlant) return;
158
+
159
+ // Get all managers from centralPlant
160
+ var managers = this.centralPlant.getAllManagers();
161
+
162
+ // Attach each manager to this instance
163
+ Object.entries(managers).forEach(function (_ref) {
164
+ var _ref2 = _slicedToArray(_ref, 2),
165
+ key = _ref2[0],
166
+ manager = _ref2[1];
167
+ _this[key] = manager;
168
+ _this.managers[key] = manager;
169
+ });
170
+
171
+ // Also attach utilities
172
+ var utilities = this.centralPlant.getAllUtilities();
173
+ Object.entries(utilities).forEach(function (_ref3) {
174
+ var _ref4 = _slicedToArray(_ref3, 2),
175
+ key = _ref4[0],
176
+ utility = _ref4[1];
177
+ _this[key] = utility;
178
+ });
179
+ console.log('๐Ÿ“ฆ Managers attached to SceneViewer:', Object.keys(managers));
180
+ }
181
+
182
+ /**
183
+ * Initialize Three.js scene
184
+ */
185
+ }, {
186
+ key: "initScene",
187
+ value: function initScene() {
188
+ this.scene = new THREE.Scene();
189
+ this.scene.name = 'MainScene';
190
+
191
+ // Set background
192
+ this.scene.background = new THREE.Color(0x87CEEB); // Sky blue
193
+
194
+ console.log('๐ŸŒ Scene initialized');
195
+ }
196
+
197
+ /**
198
+ * Initialize camera
199
+ */
200
+ }, {
201
+ key: "initCamera",
202
+ value: function initCamera() {
203
+ var aspect = this.container.clientWidth / this.container.clientHeight;
204
+ this.camera = new THREE.PerspectiveCamera(75, aspect, 0.1, 1000);
205
+ this.camera.position.set(5, 5, 5);
206
+ this.camera.lookAt(0, 0, 0);
207
+ console.log('๐Ÿ“ท Camera initialized');
208
+ }
209
+
210
+ /**
211
+ * Initialize renderer
212
+ */
213
+ }, {
214
+ key: "initRenderer",
215
+ value: function initRenderer() {
216
+ this.renderer = new THREE.WebGLRenderer({
217
+ antialias: this.options.antialias,
218
+ powerPreference: 'high-performance'
219
+ });
220
+ this.renderer.setSize(this.container.clientWidth, this.container.clientHeight);
221
+ this.renderer.setPixelRatio(this.options.pixelRatio);
222
+ this.renderer.shadowMap.enabled = this.options.enableShadows;
223
+ this.renderer.shadowMap.type = THREE.PCFSoftShadowMap;
224
+ this.renderer.outputColorSpace = THREE.SRGBColorSpace;
225
+ this.renderer.toneMapping = THREE.ACESFilmicToneMapping;
226
+ this.renderer.toneMappingExposure = 1;
227
+
228
+ // Append renderer to container
229
+ this.container.appendChild(this.renderer.domElement);
230
+ console.log('๐ŸŽจ Renderer initialized');
231
+ }
232
+
233
+ /**
234
+ * Initialize lighting
235
+ */
236
+ }, {
237
+ key: "initLights",
238
+ value: function initLights() {
239
+ // Ambient light
240
+ var ambientLight = new THREE.AmbientLight(0x404040, 0.4);
241
+ this.scene.add(ambientLight);
242
+
243
+ // Directional light
244
+ var directionalLight = new THREE.DirectionalLight(0xffffff, 1);
245
+ directionalLight.position.set(10, 10, 5);
246
+ directionalLight.castShadow = this.options.enableShadows;
247
+ if (this.options.enableShadows) {
248
+ directionalLight.shadow.mapSize.width = 2048;
249
+ directionalLight.shadow.mapSize.height = 2048;
250
+ directionalLight.shadow.camera.near = 0.5;
251
+ directionalLight.shadow.camera.far = 500;
252
+ }
253
+ this.scene.add(directionalLight);
254
+ console.log('๐Ÿ’ก Lights initialized');
255
+ }
256
+
257
+ /**
258
+ * Initialize controls (if available)
259
+ */
260
+ }, {
261
+ key: "initControls",
262
+ value: function initControls() {
263
+ // Controls will be initialized by the camera controls manager
264
+ // This is just a placeholder for the base setup
265
+ console.log('๐ŸŽฎ Controls setup ready');
266
+ }
267
+
268
+ /**
269
+ * Initialize post-processing effects
270
+ */
271
+ }, {
272
+ key: "initPostProcessing",
273
+ value: function initPostProcessing() {
274
+ // Post-processing will be handled by managers
275
+ // This is just a placeholder
276
+ console.log('โœจ Post-processing setup ready');
277
+ }
278
+
279
+ /**
280
+ * Initialize event listeners
281
+ */
282
+ }, {
283
+ key: "initEventListeners",
284
+ value: function initEventListeners() {
285
+ var _this2 = this;
286
+ // Resize observer
287
+ this.resizeObserver = new ResizeObserver(function (entries) {
288
+ var _iterator = _createForOfIteratorHelper(entries),
289
+ _step;
290
+ try {
291
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
292
+ var entry = _step.value;
293
+ _this2.handleResize();
294
+ }
295
+ } catch (err) {
296
+ _iterator.e(err);
297
+ } finally {
298
+ _iterator.f();
299
+ }
300
+ });
301
+ this.resizeObserver.observe(this.container);
302
+
303
+ // Mouse events for selection
304
+ this.container.addEventListener('click', this.handleClick.bind(this));
305
+ this.container.addEventListener('dblclick', this.handleDoubleClick.bind(this));
306
+
307
+ // Drag and drop events
308
+ this.container.addEventListener('dragover', this.handleDragOver.bind(this));
309
+ this.container.addEventListener('drop', this.handleDrop.bind(this));
310
+ this.container.addEventListener('dragenter', this.handleDragEnter.bind(this));
311
+ this.container.addEventListener('dragleave', this.handleDragLeave.bind(this));
312
+ console.log('๐Ÿ‘‚ Event listeners initialized');
313
+ }
314
+
315
+ /**
316
+ * Initialize scene managers that require the scene to be ready
317
+ */
318
+ }, {
319
+ key: "initializeSceneManagers",
320
+ value: (function () {
321
+ var _initializeSceneManagers = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
322
+ var _t2;
323
+ return _regenerator().w(function (_context2) {
324
+ while (1) switch (_context2.n) {
325
+ case 0:
326
+ _context2.p = 0;
327
+ if (!this.sceneInitializationManager) {
328
+ _context2.n = 1;
329
+ break;
330
+ }
331
+ _context2.n = 1;
332
+ return this.sceneInitializationManager.initializeScene();
333
+ case 1:
334
+ if (!this.environmentManager) {
335
+ _context2.n = 2;
336
+ break;
337
+ }
338
+ _context2.n = 2;
339
+ return this.environmentManager.initializeEnvironment();
340
+ case 2:
341
+ // Initialize other managers as needed
342
+ console.log('๐Ÿ—๏ธ Scene managers initialized');
343
+ _context2.n = 4;
344
+ break;
345
+ case 3:
346
+ _context2.p = 3;
347
+ _t2 = _context2.v;
348
+ console.error('โŒ Error initializing scene managers:', _t2);
349
+ case 4:
350
+ return _context2.a(2);
351
+ }
352
+ }, _callee2, this, [[0, 3]]);
353
+ }));
354
+ function initializeSceneManagers() {
355
+ return _initializeSceneManagers.apply(this, arguments);
356
+ }
357
+ return initializeSceneManagers;
358
+ }()
359
+ /**
360
+ * Main animation loop
361
+ */
362
+ )
363
+ }, {
364
+ key: "animate",
365
+ value: function animate() {
366
+ var _this3 = this;
367
+ if (this.isDestroyed) return;
368
+ requestAnimationFrame(function () {
369
+ return _this3.animate();
370
+ });
371
+ try {
372
+ // Update controls
373
+ if (this.controls && this.controls.update) {
374
+ this.controls.update();
375
+ }
376
+
377
+ // Update camera controls manager
378
+ if (this.cameraControlsManager) {
379
+ this.cameraControlsManager.update();
380
+ }
381
+
382
+ // Update animation manager
383
+ if (this.animationManager) {
384
+ this.animationManager.update();
385
+ }
386
+
387
+ // Update performance monitor
388
+ if (this.performanceMonitor) {
389
+ this.performanceMonitor.begin();
390
+ }
391
+
392
+ // Render the scene
393
+ if (this.composer) {
394
+ this.composer.render();
395
+ } else {
396
+ this.renderer.render(this.scene, this.camera);
397
+ }
398
+
399
+ // End performance monitoring
400
+ if (this.performanceMonitor) {
401
+ this.performanceMonitor.end();
402
+ }
403
+ } catch (error) {
404
+ console.error('โŒ Error in animation loop:', error);
405
+ }
406
+ }
407
+
408
+ /**
409
+ * Handle window/container resize
410
+ */
411
+ }, {
412
+ key: "handleResize",
413
+ value: function handleResize() {
414
+ if (!this.camera || !this.renderer) return;
415
+ var width = this.container.clientWidth;
416
+ var height = this.container.clientHeight;
417
+
418
+ // Update camera
419
+ this.camera.aspect = width / height;
420
+ this.camera.updateProjectionMatrix();
421
+
422
+ // Update renderer
423
+ this.renderer.setSize(width, height);
424
+
425
+ // Update composer if available
426
+ if (this.composer) {
427
+ this.composer.setSize(width, height);
428
+ }
429
+ this.emit('resize', {
430
+ width: width,
431
+ height: height
432
+ });
433
+ }
434
+
435
+ /**
436
+ * Handle click events
437
+ */
438
+ }, {
439
+ key: "handleClick",
440
+ value: function handleClick(event) {
441
+ if (!this.camera || !this.scene) return;
442
+ var rect = this.container.getBoundingClientRect();
443
+ var mouse = new THREE.Vector2();
444
+ mouse.x = (event.clientX - rect.left) / rect.width * 2 - 1;
445
+ mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
446
+ var raycaster = new THREE.Raycaster();
447
+ raycaster.setFromCamera(mouse, this.camera);
448
+ var intersects = raycaster.intersectObjects(this.scene.children, true);
449
+ if (intersects.length > 0) {
450
+ var object = intersects[0].object;
451
+ this.selectObject(object);
452
+ } else {
453
+ this.selectObject(null);
454
+ }
455
+ }
456
+
457
+ /**
458
+ * Handle double click events
459
+ */
460
+ }, {
461
+ key: "handleDoubleClick",
462
+ value: function handleDoubleClick(event) {
463
+ // Handle double click actions
464
+ this.emit('doubleClick', {
465
+ event: event
466
+ });
467
+ }
468
+
469
+ /**
470
+ * Handle drag over events
471
+ */
472
+ }, {
473
+ key: "handleDragOver",
474
+ value: function handleDragOver(event) {
475
+ event.preventDefault();
476
+ this.isDragOver = true;
477
+ this.emit('dragOver', {
478
+ event: event
479
+ });
480
+ }
481
+
482
+ /**
483
+ * Handle drop events
484
+ */
485
+ }, {
486
+ key: "handleDrop",
487
+ value: function handleDrop(event) {
488
+ event.preventDefault();
489
+ this.isDragOver = false;
490
+ try {
491
+ var dataTransfer = event.dataTransfer.getData('text/plain');
492
+ if (dataTransfer) {
493
+ var componentData = JSON.parse(dataTransfer);
494
+
495
+ // Calculate drop position
496
+ var rect = this.container.getBoundingClientRect();
497
+ var mouse = new THREE.Vector2();
498
+ mouse.x = (event.clientX - rect.left) / rect.width * 2 - 1;
499
+ mouse.y = -((event.clientY - rect.top) / rect.height) * 2 + 1;
500
+ var raycaster = new THREE.Raycaster();
501
+ raycaster.setFromCamera(mouse, this.camera);
502
+
503
+ // Cast ray to ground plane (y = 0)
504
+ var groundPlane = new THREE.Plane(new THREE.Vector3(0, 1, 0), 0);
505
+ var dropPosition = new THREE.Vector3();
506
+ raycaster.ray.intersectPlane(groundPlane, dropPosition);
507
+ this.emit('componentDropped', {
508
+ componentData: componentData,
509
+ position: dropPosition,
510
+ event: event
511
+ });
512
+ }
513
+ } catch (error) {
514
+ console.error('โŒ Error handling drop:', error);
515
+ this.emit('dropError', {
516
+ error: error,
517
+ event: event
518
+ });
519
+ }
520
+ }
521
+
522
+ /**
523
+ * Handle drag enter events
524
+ */
525
+ }, {
526
+ key: "handleDragEnter",
527
+ value: function handleDragEnter(event) {
528
+ event.preventDefault();
529
+ this.emit('dragEnter', {
530
+ event: event
531
+ });
532
+ }
533
+
534
+ /**
535
+ * Handle drag leave events
536
+ */
537
+ }, {
538
+ key: "handleDragLeave",
539
+ value: function handleDragLeave(event) {
540
+ this.isDragOver = false;
541
+ this.emit('dragLeave', {
542
+ event: event
543
+ });
544
+ }
545
+
546
+ /**
547
+ * Select an object in the scene
548
+ */
549
+ }, {
550
+ key: "selectObject",
551
+ value: function selectObject(object) {
552
+ // Clear previous selection
553
+ if (this.selectedObjectForTransform) {
554
+ // Remove selection indicators
555
+ this.clearObjectSelection(this.selectedObjectForTransform);
556
+ }
557
+ this.selectedObjectForTransform = object;
558
+ if (object) {
559
+ // Add selection indicators
560
+ this.highlightSelectedObject(object);
561
+
562
+ // Initialize transform controls if available
563
+ if (this.transformManager) {
564
+ this.transformManager.attachToObject(object);
565
+ }
566
+ } else {
567
+ // Clear transform controls
568
+ if (this.transformManager) {
569
+ this.transformManager.detach();
570
+ }
571
+ }
572
+ this.emit('objectSelected', {
573
+ object: object
574
+ });
575
+ }
576
+
577
+ /**
578
+ * Clear object selection visual indicators
579
+ */
580
+ }, {
581
+ key: "clearObjectSelection",
582
+ value: function clearObjectSelection(object) {
583
+ // Remove selection outline or other indicators
584
+ // This would depend on your specific selection visualization
585
+ }
586
+
587
+ /**
588
+ * Highlight selected object
589
+ */
590
+ }, {
591
+ key: "highlightSelectedObject",
592
+ value: function highlightSelectedObject(object) {
593
+ // Add selection outline or other indicators
594
+ // This would depend on your specific selection visualization
595
+ }
596
+
597
+ /**
598
+ * Load a scene from data
599
+ */
600
+ }, {
601
+ key: "loadScene",
602
+ value: (function () {
603
+ var _loadScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(sceneData) {
604
+ var _t3;
605
+ return _regenerator().w(function (_context3) {
606
+ while (1) switch (_context3.n) {
607
+ case 0:
608
+ _context3.p = 0;
609
+ this.currentSceneData = sceneData;
610
+ if (!this.componentManager) {
611
+ _context3.n = 1;
612
+ break;
613
+ }
614
+ _context3.n = 1;
615
+ return this.componentManager.loadSceneFromData(sceneData);
616
+ case 1:
617
+ this.emit('sceneLoaded', {
618
+ sceneData: sceneData
619
+ });
620
+ _context3.n = 3;
621
+ break;
622
+ case 2:
623
+ _context3.p = 2;
624
+ _t3 = _context3.v;
625
+ console.error('โŒ Error loading scene:', _t3);
626
+ this.emit('sceneLoadError', {
627
+ error: _t3,
628
+ sceneData: sceneData
629
+ });
630
+ case 3:
631
+ return _context3.a(2);
632
+ }
633
+ }, _callee3, this, [[0, 2]]);
634
+ }));
635
+ function loadScene(_x) {
636
+ return _loadScene.apply(this, arguments);
637
+ }
638
+ return loadScene;
639
+ }()
640
+ /**
641
+ * Add a component to the scene
642
+ */
643
+ )
644
+ }, {
645
+ key: "addComponentToScene",
646
+ value: function addComponentToScene(componentData) {
647
+ var position = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new THREE.Vector3();
648
+ try {
649
+ if (this.componentManager) {
650
+ return this.componentManager.addComponent(componentData, position);
651
+ }
652
+ return false;
653
+ } catch (error) {
654
+ console.error('โŒ Error adding component:', error);
655
+ return false;
656
+ }
657
+ }
658
+
659
+ /**
660
+ * Export scene data
661
+ */
662
+ }, {
663
+ key: "exportScene",
664
+ value: function exportScene() {
665
+ try {
666
+ if (this.sceneExportManager) {
667
+ return this.sceneExportManager.exportScene();
668
+ }
669
+ return null;
670
+ } catch (error) {
671
+ console.error('โŒ Error exporting scene:', error);
672
+ return null;
673
+ }
674
+ }
675
+
676
+ /**
677
+ * Toggle camera auto rotation
678
+ */
679
+ }, {
680
+ key: "toggleCameraRotation",
681
+ value: function toggleCameraRotation() {
682
+ if (this.cameraControlsManager) {
683
+ return this.cameraControlsManager.toggleCameraRotation();
684
+ }
685
+ return false;
686
+ }
687
+
688
+ /**
689
+ * Get selected transform data
690
+ */
691
+ }, {
692
+ key: "getSelectedTransform",
693
+ value: function getSelectedTransform() {
694
+ if (this.transformManager && this.selectedObjectForTransform) {
695
+ return this.transformManager.getTransformData(this.selectedObjectForTransform);
696
+ }
697
+ return null;
698
+ }
699
+
700
+ /**
701
+ * Event system methods
702
+ */
703
+ }, {
704
+ key: "on",
705
+ value: function on(eventName, callback) {
706
+ if (!this.eventCallbacks.has(eventName)) {
707
+ this.eventCallbacks.set(eventName, []);
708
+ }
709
+ this.eventCallbacks.get(eventName).push(callback);
710
+ }
711
+ }, {
712
+ key: "off",
713
+ value: function off(eventName, callback) {
714
+ if (this.eventCallbacks.has(eventName)) {
715
+ var callbacks = this.eventCallbacks.get(eventName);
716
+ var index = callbacks.indexOf(callback);
717
+ if (index > -1) {
718
+ callbacks.splice(index, 1);
719
+ }
720
+ }
721
+ }
722
+ }, {
723
+ key: "emit",
724
+ value: function emit(eventName) {
725
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
726
+ if (this.eventCallbacks.has(eventName)) {
727
+ this.eventCallbacks.get(eventName).forEach(function (callback) {
728
+ try {
729
+ callback(data);
730
+ } catch (error) {
731
+ console.error("\u274C Error in event callback for ".concat(eventName, ":"), error);
732
+ }
733
+ });
734
+ }
735
+ }
736
+
737
+ /**
738
+ * Dispose of the scene viewer and clean up resources
739
+ */
740
+ }, {
741
+ key: "dispose",
742
+ value: function dispose() {
743
+ console.log('๐Ÿงน Disposing SceneViewer...');
744
+ this.isDestroyed = true;
745
+ try {
746
+ // Clean up event listeners
747
+ this.eventCallbacks.clear();
748
+
749
+ // Clean up resize observer
750
+ if (this.resizeObserver) {
751
+ this.resizeObserver.disconnect();
752
+ this.resizeObserver = null;
753
+ }
754
+
755
+ // Clean up DOM event listeners
756
+ if (this.container) {
757
+ this.container.removeEventListener('click', this.handleClick);
758
+ this.container.removeEventListener('dblclick', this.handleDoubleClick);
759
+ this.container.removeEventListener('dragover', this.handleDragOver);
760
+ this.container.removeEventListener('drop', this.handleDrop);
761
+ this.container.removeEventListener('dragenter', this.handleDragEnter);
762
+ this.container.removeEventListener('dragleave', this.handleDragLeave);
763
+ }
764
+
765
+ // Dispose of managers using disposal manager
766
+ if (this.disposalManager) {
767
+ this.disposalManager.cleanupEventListeners();
768
+ this.disposalManager.cleanupPerformanceMonitoring();
769
+ this.disposalManager.cleanupControls();
770
+ this.disposalManager.cleanupScene();
771
+ this.disposalManager.cleanupRenderer();
772
+ }
773
+
774
+ // Remove renderer from DOM
775
+ if (this.renderer && this.renderer.domElement && this.container) {
776
+ this.container.removeChild(this.renderer.domElement);
777
+ }
778
+
779
+ // Dispose of renderer
780
+ if (this.renderer) {
781
+ this.renderer.dispose();
782
+ this.renderer = null;
783
+ }
784
+
785
+ // Clear references
786
+ this.scene = null;
787
+ this.camera = null;
788
+ this.controls = null;
789
+ this.currentSceneData = null;
790
+ this.selectedObjectForTransform = null;
791
+ console.log('โœ… SceneViewer disposed successfully');
792
+ } catch (error) {
793
+ console.error('โŒ Error during SceneViewer disposal:', error);
794
+ }
795
+ }
796
+ }]);
797
+ }();
798
+
799
+ export { SceneViewer, SceneViewer as default };