@2112-lab/central-plant 0.1.0

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 (54) hide show
  1. package/README.md +0 -0
  2. package/dist/bundle/index.js +14259 -0
  3. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +353 -0
  4. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1292 -0
  5. package/dist/cjs/node_modules/three/examples/jsm/controls/TransformControls.js +1543 -0
  6. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4374 -0
  7. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +465 -0
  8. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +117 -0
  9. package/dist/cjs/src/ConnectionManager.js +114 -0
  10. package/dist/cjs/src/Pathfinder.js +88 -0
  11. package/dist/cjs/src/animationManager.js +121 -0
  12. package/dist/cjs/src/componentManager.js +151 -0
  13. package/dist/cjs/src/debugLogger.js +176 -0
  14. package/dist/cjs/src/disposalManager.js +185 -0
  15. package/dist/cjs/src/environmentManager.js +1015 -0
  16. package/dist/cjs/src/hotReloadManager.js +252 -0
  17. package/dist/cjs/src/index.js +126 -0
  18. package/dist/cjs/src/keyboardControlsManager.js +206 -0
  19. package/dist/cjs/src/modelPreloader.js +360 -0
  20. package/dist/cjs/src/nameUtils.js +106 -0
  21. package/dist/cjs/src/pathfindingManager.js +321 -0
  22. package/dist/cjs/src/performanceMonitor.js +718 -0
  23. package/dist/cjs/src/sceneExportManager.js +292 -0
  24. package/dist/cjs/src/sceneInitializationManager.js +540 -0
  25. package/dist/cjs/src/sceneOperationsManager.js +560 -0
  26. package/dist/cjs/src/textureConfig.js +195 -0
  27. package/dist/cjs/src/transformControlsManager.js +851 -0
  28. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +328 -0
  29. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1287 -0
  30. package/dist/esm/node_modules/three/examples/jsm/controls/TransformControls.js +1537 -0
  31. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4370 -0
  32. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +461 -0
  33. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +113 -0
  34. package/dist/esm/src/ConnectionManager.js +110 -0
  35. package/dist/esm/src/Pathfinder.js +84 -0
  36. package/dist/esm/src/animationManager.js +112 -0
  37. package/dist/esm/src/componentManager.js +123 -0
  38. package/dist/esm/src/debugLogger.js +167 -0
  39. package/dist/esm/src/disposalManager.js +155 -0
  40. package/dist/esm/src/environmentManager.js +989 -0
  41. package/dist/esm/src/hotReloadManager.js +244 -0
  42. package/dist/esm/src/index.js +117 -0
  43. package/dist/esm/src/keyboardControlsManager.js +196 -0
  44. package/dist/esm/src/modelPreloader.js +337 -0
  45. package/dist/esm/src/nameUtils.js +99 -0
  46. package/dist/esm/src/pathfindingManager.js +295 -0
  47. package/dist/esm/src/performanceMonitor.js +712 -0
  48. package/dist/esm/src/sceneExportManager.js +286 -0
  49. package/dist/esm/src/sceneInitializationManager.js +513 -0
  50. package/dist/esm/src/sceneOperationsManager.js +536 -0
  51. package/dist/esm/src/textureConfig.js +168 -0
  52. package/dist/esm/src/transformControlsManager.js +827 -0
  53. package/dist/index.d.ts +259 -0
  54. package/package.json +53 -0
@@ -0,0 +1,851 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ /**
26
+ * Transform Controls Manager for Three.js
27
+ * Provides modular object transformation capabilities with position, rotation, and scale controls
28
+ */
29
+
30
+ var THREE;
31
+ var TransformControls;
32
+
33
+ /**
34
+ * Dynamically import ThreeJS and TransformControls when in browser environment
35
+ */
36
+ function importDependencies() {
37
+ return _importDependencies.apply(this, arguments);
38
+ }
39
+ /**
40
+ * Class for managing object transform controls in a 3D scene
41
+ */
42
+ function _importDependencies() {
43
+ _importDependencies = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee2() {
44
+ var transformModule, customModule, _t2;
45
+ return _rollupPluginBabelHelpers.regenerator().w(function (_context2) {
46
+ while (1) switch (_context2.n) {
47
+ case 0:
48
+ if (!(typeof window !== 'undefined')) {
49
+ _context2.n = 9;
50
+ break;
51
+ }
52
+ _context2.p = 1;
53
+ _context2.n = 2;
54
+ return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('three')); });
55
+ case 2:
56
+ THREE = _context2.v;
57
+ _context2.p = 3;
58
+ _context2.n = 4;
59
+ return Promise.resolve().then(function () { return require('../node_modules/three/examples/jsm/controls/TransformControls.js'); });
60
+ case 4:
61
+ transformModule = _context2.v;
62
+ TransformControls = transformModule.TransformControls;
63
+ _context2.n = 7;
64
+ break;
65
+ case 5:
66
+ _context2.p = 5;
67
+ _context2.v;
68
+ console.log('Using fallback path for TransformControls');
69
+ // Fallback to the custom plugin path if available
70
+ if (!(typeof window.__transformControlsCustomPath === 'string')) {
71
+ _context2.n = 7;
72
+ break;
73
+ }
74
+ _context2.n = 6;
75
+ return (function (t) { return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(t)); }); })(window.__transformControlsCustomPath);
76
+ case 6:
77
+ customModule = _context2.v;
78
+ TransformControls = customModule.TransformControls;
79
+ case 7:
80
+ _context2.n = 9;
81
+ break;
82
+ case 8:
83
+ _context2.p = 8;
84
+ _t2 = _context2.v;
85
+ console.error('Failed to load Transform Controls dependencies:', _t2);
86
+ throw new Error('TransformControlsManager: Required dependencies could not be loaded');
87
+ case 9:
88
+ return _context2.a(2);
89
+ }
90
+ }, _callee2, null, [[3, 5], [1, 8]]);
91
+ }));
92
+ return _importDependencies.apply(this, arguments);
93
+ }
94
+ var TransformControlsManager = /*#__PURE__*/function () {
95
+ /**
96
+ * Create a TransformControlsManager
97
+ * @param {THREE.Scene} scene - The Three.js scene
98
+ * @param {THREE.Camera} camera - The Three.js camera
99
+ * @param {THREE.WebGLRenderer} renderer - The Three.js renderer
100
+ * @param {THREE.OrbitControls} orbitControls - Optional orbit controls for camera
101
+ */
102
+ function TransformControlsManager(scene, camera, renderer) {
103
+ var _this = this;
104
+ var orbitControls = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
105
+ _rollupPluginBabelHelpers.classCallCheck(this, TransformControlsManager);
106
+ this.scene = scene;
107
+ this.camera = camera;
108
+ this.renderer = renderer;
109
+ this.orbitControls = orbitControls;
110
+
111
+ // Transform control instance
112
+ this.transformControls = null;
113
+
114
+ // Bounding box helper for visual feedback
115
+ this.boundingBoxHelper = null;
116
+
117
+ // Cache for object bounding boxes to improve performance
118
+ this.boundingBoxCache = new WeakMap();
119
+
120
+ // Currently selected object
121
+ this.selectedObject = null;
122
+
123
+ // Transform mode: 'translate', 'rotate', 'scale'
124
+ this.currentMode = 'translate';
125
+
126
+ // Transform space: 'world' or 'local'
127
+ this.currentSpace = 'world';
128
+
129
+ // Flag to force controls to stay invisible (used during scene loading)
130
+ this.forceInvisible = false;
131
+
132
+ // Event handlers storage
133
+ this.eventHandlers = {
134
+ keydown: null,
135
+ pointerdown: null,
136
+ pointerup: null,
137
+ transformStart: null,
138
+ transformEnd: null,
139
+ transforming: null
140
+ };
141
+
142
+ // Transform state tracking
143
+ this.transformState = {
144
+ isTransforming: false,
145
+ initialTransform: null,
146
+ currentTransform: null
147
+ };
148
+
149
+ // Configuration options
150
+ this.config = {
151
+ size: 1,
152
+ enabled: true,
153
+ showX: true,
154
+ showY: true,
155
+ showZ: true,
156
+ snap: null,
157
+ // Snap value for transformations
158
+ translationSnap: null,
159
+ rotationSnap: null,
160
+ scaleSnap: null,
161
+ showBoundingBox: true,
162
+ // Show bounding box on selection
163
+ boundingBoxColor: 0x00ff00,
164
+ // Green bounding box by default
165
+ useBoundingBoxSelection: true // Use bounding box-based selection instead of mesh selection
166
+ };
167
+
168
+ // Callbacks for external event handling
169
+ this.callbacks = {
170
+ onObjectSelect: null,
171
+ onTransformStart: null,
172
+ onTransform: null,
173
+ onTransformEnd: null,
174
+ onModeChange: null
175
+ };
176
+
177
+ // Initialize asynchronously if needed
178
+ if (typeof window !== 'undefined') {
179
+ importDependencies().then(function () {
180
+ return _this.init();
181
+ });
182
+ }
183
+ }
184
+
185
+ /**
186
+ * Initialize the transform controls
187
+ */
188
+ return _rollupPluginBabelHelpers.createClass(TransformControlsManager, [{
189
+ key: "init",
190
+ value: (function () {
191
+ var _init = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee() {
192
+ return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
193
+ while (1) switch (_context.n) {
194
+ case 0:
195
+ if (!(typeof window !== 'undefined' && !THREE)) {
196
+ _context.n = 1;
197
+ break;
198
+ }
199
+ _context.n = 1;
200
+ return importDependencies();
201
+ case 1:
202
+ this.createTransformControls();
203
+ this.setupEventListeners();
204
+ this.setupKeyboardControls();
205
+ case 2:
206
+ return _context.a(2);
207
+ }
208
+ }, _callee, this);
209
+ }));
210
+ function init() {
211
+ return _init.apply(this, arguments);
212
+ }
213
+ return init;
214
+ }()
215
+ /**
216
+ * Register event callbacks
217
+ * @param {Object} callbacks - Object containing callback functions
218
+ */
219
+ )
220
+ }, {
221
+ key: "on",
222
+ value: function on(callbacks) {
223
+ if (callbacks.onObjectSelect) {
224
+ this.callbacks.onObjectSelect = callbacks.onObjectSelect;
225
+ }
226
+ if (callbacks.onTransformStart) {
227
+ this.callbacks.onTransformStart = callbacks.onTransformStart;
228
+ }
229
+ if (callbacks.onTransform) {
230
+ this.callbacks.onTransform = callbacks.onTransform;
231
+ }
232
+ if (callbacks.onTransformEnd) {
233
+ this.callbacks.onTransformEnd = callbacks.onTransformEnd;
234
+ }
235
+ if (callbacks.onModeChange) {
236
+ this.callbacks.onModeChange = callbacks.onModeChange;
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Create transform controls and add to scene
242
+ */
243
+ }, {
244
+ key: "createTransformControls",
245
+ value: function createTransformControls() {
246
+ // Ensure THREE and TransformControls are available
247
+ if (!THREE || !TransformControls) {
248
+ console.warn('TransformControls cannot be created - THREE.js not loaded');
249
+ return;
250
+ }
251
+
252
+ // Create transform controls if they don't exist
253
+ if (!this.transformControls) {
254
+ this.transformControls = new TransformControls(this.camera, this.renderer.domElement);
255
+ this.transformControls.size = this.config.size;
256
+ this.transformControls.enabled = this.config.enabled;
257
+ this.transformControls.visible = this.config.enabled && !this.forceInvisible;
258
+
259
+ // Set initial mode
260
+ this.transformControls.setMode(this.currentMode);
261
+ this.transformControls.setSpace(this.currentSpace);
262
+
263
+ // Mark with userData for easy identification
264
+ this.transformControls.userData = {
265
+ isTransformControls: true
266
+ };
267
+
268
+ // Add to scene
269
+ this.scene.add(this.transformControls);
270
+ console.log('✅ Transform controls created and added to scene');
271
+ }
272
+ }
273
+
274
+ /**
275
+ * Set up event listeners for transform controls
276
+ */
277
+ }, {
278
+ key: "setupEventListeners",
279
+ value: function setupEventListeners() {
280
+ var _this2 = this;
281
+ if (!this.transformControls) return;
282
+
283
+ // Clean up any existing listeners to avoid duplicates
284
+ this.removeEventListeners();
285
+
286
+ // Event handler for transform start
287
+ this.eventHandlers.transformStart = function (event) {
288
+ _this2.transformState.isTransforming = true;
289
+ if (_this2.selectedObject) {
290
+ // Store initial transform for history/undo purposes
291
+ _this2.transformState.initialTransform = _this2.captureObjectTransform(_this2.selectedObject);
292
+
293
+ // Notify via callback if registered
294
+ if (_this2.callbacks.onTransformStart) {
295
+ _this2.callbacks.onTransformStart(_this2.selectedObject, _this2.transformState.initialTransform);
296
+ }
297
+ }
298
+ };
299
+
300
+ // Event handler for transform changes
301
+ this.eventHandlers.transforming = function (event) {
302
+ if (_this2.selectedObject && _this2.transformState.isTransforming) {
303
+ // Capture current transform
304
+ _this2.transformState.currentTransform = _this2.captureObjectTransform(_this2.selectedObject);
305
+
306
+ // Notify via callback if registered
307
+ if (_this2.callbacks.onTransform) {
308
+ _this2.callbacks.onTransform(_this2.selectedObject, _this2.transformState.currentTransform, _this2.transformState.initialTransform);
309
+ }
310
+
311
+ // Update bounding box if shown
312
+ _this2.updateBoundingBox();
313
+ }
314
+ };
315
+
316
+ // Event handler for transform end
317
+ this.eventHandlers.transformEnd = function (event) {
318
+ if (_this2.selectedObject) {
319
+ // Capture final transform
320
+ var finalTransform = _this2.captureObjectTransform(_this2.selectedObject);
321
+
322
+ // Notify via callback if registered
323
+ if (_this2.callbacks.onTransformEnd) {
324
+ _this2.callbacks.onTransformEnd(_this2.selectedObject, finalTransform, _this2.transformState.initialTransform);
325
+ }
326
+ }
327
+ _this2.transformState.isTransforming = false;
328
+ };
329
+
330
+ // Attach event listeners to transform controls
331
+ this.transformControls.addEventListener('mouseDown', this.eventHandlers.transformStart);
332
+ this.transformControls.addEventListener('objectChange', this.eventHandlers.transforming);
333
+ this.transformControls.addEventListener('mouseUp', this.eventHandlers.transformEnd);
334
+
335
+ // Disable orbit controls during transform (if orbit controls provided)
336
+ if (this.orbitControls) {
337
+ this.transformControls.addEventListener('dragging-changed', function (event) {
338
+ _this2.orbitControls.enabled = !event.value;
339
+ });
340
+ }
341
+ }
342
+
343
+ /**
344
+ * Set up keyboard controls for transform operations
345
+ */
346
+ }, {
347
+ key: "setupKeyboardControls",
348
+ value: function setupKeyboardControls() {
349
+ var _this3 = this;
350
+ // Skip if not in browser environment
351
+ if (typeof window === 'undefined' || typeof document === 'undefined') {
352
+ return;
353
+ }
354
+
355
+ // Clean up any existing listeners first
356
+ if (this.eventHandlers.keydown) {
357
+ document.removeEventListener('keydown', this.eventHandlers.keydown);
358
+ }
359
+
360
+ // Keydown handler for keyboard shortcuts
361
+ this.eventHandlers.keydown = function (event) {
362
+ if (!_this3.config.enabled || !_this3.selectedObject) return;
363
+ switch (event.key.toLowerCase()) {
364
+ case 'g':
365
+ // Translate mode (grab)
366
+ _this3.setMode('translate');
367
+ break;
368
+ case 'r':
369
+ // Rotate mode
370
+ _this3.setMode('rotate');
371
+ break;
372
+ case 's':
373
+ // Scale mode
374
+ _this3.setMode('scale');
375
+ break;
376
+ case ' ':
377
+ // Toggle visibility
378
+ _this3.toggleVisibility();
379
+ break;
380
+ case 'escape':
381
+ // Deselect object
382
+ _this3.deselectObject();
383
+ break;
384
+ case 'x':
385
+ // X-axis constraint
386
+ if (event.shiftKey) {
387
+ // Shift + X to toggle X controls
388
+ _this3.config.showX = !_this3.config.showX;
389
+ _this3.updateAxisVisibility();
390
+ } else {
391
+ _this3.transformControls.showX = true;
392
+ _this3.transformControls.showY = false;
393
+ _this3.transformControls.showZ = false;
394
+ }
395
+ break;
396
+ case 'y':
397
+ // Y-axis constraint
398
+ if (event.shiftKey) {
399
+ // Shift + Y to toggle Y controls
400
+ _this3.config.showY = !_this3.config.showY;
401
+ _this3.updateAxisVisibility();
402
+ } else {
403
+ _this3.transformControls.showX = false;
404
+ _this3.transformControls.showY = true;
405
+ _this3.transformControls.showZ = false;
406
+ }
407
+ break;
408
+ case 'z':
409
+ // Z-axis constraint
410
+ if (event.shiftKey) {
411
+ // Shift + Z to toggle Z controls
412
+ _this3.config.showZ = !_this3.config.showZ;
413
+ _this3.updateAxisVisibility();
414
+ } else {
415
+ _this3.transformControls.showX = false;
416
+ _this3.transformControls.showY = false;
417
+ _this3.transformControls.showZ = true;
418
+ }
419
+ break;
420
+ case 'q':
421
+ // Toggle world/local space
422
+ _this3.toggleSpace();
423
+ break;
424
+ }
425
+ };
426
+
427
+ // Add keyboard event listener
428
+ document.addEventListener('keydown', this.eventHandlers.keydown);
429
+ }
430
+
431
+ /**
432
+ * Remove all event listeners
433
+ */
434
+ }, {
435
+ key: "removeEventListeners",
436
+ value: function removeEventListeners() {
437
+ if (this.transformControls) {
438
+ // Remove transform control event listeners
439
+ this.transformControls.removeEventListener('mouseDown', this.eventHandlers.transformStart);
440
+ this.transformControls.removeEventListener('objectChange', this.eventHandlers.transforming);
441
+ this.transformControls.removeEventListener('mouseUp', this.eventHandlers.transformEnd);
442
+ }
443
+
444
+ // Remove document event listeners if in browser
445
+ if (typeof document !== 'undefined') {
446
+ if (this.eventHandlers.keydown) {
447
+ document.removeEventListener('keydown', this.eventHandlers.keydown);
448
+ }
449
+ }
450
+ }
451
+
452
+ /**
453
+ * Select an object for transformation
454
+ * @param {THREE.Object3D} object - The object to transform
455
+ */
456
+ }, {
457
+ key: "selectObject",
458
+ value: function selectObject(object) {
459
+ if (!this.config.enabled || !this.transformControls || !object) return;
460
+
461
+ // Deselect current object if any
462
+ this.deselectObject();
463
+
464
+ // Set new selected object
465
+ this.selectedObject = object;
466
+ this.transformControls.attach(object);
467
+
468
+ // Show bounding box if enabled
469
+ if (this.config.showBoundingBox) {
470
+ this.showBoundingBox(object);
471
+ }
472
+
473
+ // Notify via callback if registered
474
+ if (this.callbacks.onObjectSelect) {
475
+ this.callbacks.onObjectSelect(object, true);
476
+ }
477
+
478
+ // Make controls visible if not forced invisible
479
+ if (!this.forceInvisible) {
480
+ this.transformControls.visible = true;
481
+ }
482
+ return object;
483
+ }
484
+
485
+ /**
486
+ * Deselect the currently selected object
487
+ */
488
+ }, {
489
+ key: "deselectObject",
490
+ value: function deselectObject() {
491
+ if (this.selectedObject) {
492
+ // Detach from transform controls
493
+ if (this.transformControls) {
494
+ this.transformControls.detach();
495
+ }
496
+
497
+ // Hide bounding box
498
+ this.hideBoundingBox();
499
+
500
+ // Notify via callback if registered
501
+ if (this.callbacks.onObjectSelect) {
502
+ this.callbacks.onObjectSelect(this.selectedObject, false);
503
+ }
504
+
505
+ // Clear selection
506
+ var previousSelection = this.selectedObject;
507
+ this.selectedObject = null;
508
+
509
+ // Ensure transform controls are removed from scene
510
+ this.ensureSceneAttachment(false);
511
+ return previousSelection;
512
+ }
513
+ return null;
514
+ }
515
+
516
+ /**
517
+ * Set transformation mode
518
+ * @param {string} mode - The transform mode ('translate', 'rotate', or 'scale')
519
+ */
520
+ }, {
521
+ key: "setMode",
522
+ value: function setMode(mode) {
523
+ if (!this.transformControls) return;
524
+ if (['translate', 'rotate', 'scale'].includes(mode)) {
525
+ this.currentMode = mode;
526
+ this.transformControls.setMode(mode);
527
+
528
+ // Update snap values based on mode
529
+ switch (mode) {
530
+ case 'translate':
531
+ this.transformControls.setTranslationSnap(this.config.translationSnap);
532
+ break;
533
+ case 'rotate':
534
+ this.transformControls.setRotationSnap(this.config.rotationSnap);
535
+ break;
536
+ case 'scale':
537
+ this.transformControls.setScaleSnap(this.config.scaleSnap);
538
+ break;
539
+ }
540
+
541
+ // Notify via callback if registered
542
+ if (this.callbacks.onModeChange) {
543
+ this.callbacks.onModeChange(mode);
544
+ }
545
+ }
546
+ }
547
+
548
+ /**
549
+ * Toggle coordinate space between world and local
550
+ */
551
+ }, {
552
+ key: "toggleSpace",
553
+ value: function toggleSpace() {
554
+ if (!this.transformControls) return;
555
+ this.currentSpace = this.currentSpace === 'world' ? 'local' : 'world';
556
+ this.transformControls.setSpace(this.currentSpace);
557
+ }
558
+
559
+ /**
560
+ * Toggle visibility of transform controls
561
+ */
562
+ }, {
563
+ key: "toggleVisibility",
564
+ value: function toggleVisibility() {
565
+ if (!this.transformControls) return;
566
+ if (!this.forceInvisible) {
567
+ this.transformControls.visible = !this.transformControls.visible;
568
+ }
569
+ }
570
+
571
+ /**
572
+ * Set enabled state of transform controls
573
+ * @param {boolean} enabled - Whether transform controls should be enabled
574
+ */
575
+ }, {
576
+ key: "setEnabled",
577
+ value: function setEnabled(enabled) {
578
+ this.config.enabled = enabled;
579
+ if (this.transformControls) {
580
+ this.transformControls.enabled = enabled;
581
+ if (!enabled) {
582
+ this.deselectObject();
583
+ this.transformControls.visible = false;
584
+ } else if (this.selectedObject && !this.forceInvisible) {
585
+ this.transformControls.visible = true;
586
+ }
587
+ }
588
+ }
589
+
590
+ /**
591
+ * Update axis visibility based on config
592
+ */
593
+ }, {
594
+ key: "updateAxisVisibility",
595
+ value: function updateAxisVisibility() {
596
+ if (!this.transformControls) return;
597
+ this.transformControls.showX = this.config.showX;
598
+ this.transformControls.showY = this.config.showY;
599
+ this.transformControls.showZ = this.config.showZ;
600
+ }
601
+
602
+ /**
603
+ * Show bounding box for an object
604
+ * @param {THREE.Object3D} object - The object to show bounding box for
605
+ */
606
+ }, {
607
+ key: "showBoundingBox",
608
+ value: function showBoundingBox(object) {
609
+ if (!object || !THREE) return;
610
+ this.hideBoundingBox();
611
+
612
+ // Get bounding box (from cache or compute it)
613
+ var boundingBox = this.boundingBoxCache.get(object);
614
+ if (!boundingBox) {
615
+ boundingBox = new THREE.Box3().setFromObject(object);
616
+ this.boundingBoxCache.set(object, boundingBox);
617
+ }
618
+
619
+ // Create helper if needed
620
+ if (!this.boundingBoxHelper) {
621
+ this.boundingBoxHelper = new THREE.Box3Helper(boundingBox, this.config.boundingBoxColor);
622
+ this.scene.add(this.boundingBoxHelper);
623
+ } else {
624
+ this.boundingBoxHelper.box = boundingBox;
625
+ }
626
+
627
+ // Store bounding box in object userData for easy access
628
+ object.userData.worldBoundingBox = boundingBox;
629
+ }
630
+
631
+ /**
632
+ * Hide bounding box helper
633
+ */
634
+ }, {
635
+ key: "hideBoundingBox",
636
+ value: function hideBoundingBox() {
637
+ if (this.boundingBoxHelper) {
638
+ this.scene.remove(this.boundingBoxHelper);
639
+ this.boundingBoxHelper = null;
640
+ }
641
+ }
642
+
643
+ /**
644
+ * Update bounding box for selected object
645
+ */
646
+ }, {
647
+ key: "updateBoundingBox",
648
+ value: function updateBoundingBox() {
649
+ if (this.selectedObject && this.config.showBoundingBox) {
650
+ // Update bounding box to reflect current transform
651
+ var boundingBox = new THREE.Box3().setFromObject(this.selectedObject);
652
+
653
+ // Update cache
654
+ this.boundingBoxCache.set(this.selectedObject, boundingBox);
655
+
656
+ // Update helper if exists
657
+ if (this.boundingBoxHelper) {
658
+ this.boundingBoxHelper.box = boundingBox;
659
+ }
660
+
661
+ // Update userData
662
+ this.selectedObject.userData.worldBoundingBox = boundingBox;
663
+ }
664
+ }
665
+
666
+ /**
667
+ * Capture object transformation data
668
+ * @param {THREE.Object3D} object - The object to capture transform from
669
+ * @returns {Object} Object containing position, rotation and scale data
670
+ */
671
+ }, {
672
+ key: "captureObjectTransform",
673
+ value: function captureObjectTransform(object) {
674
+ if (!object) return null;
675
+ return {
676
+ position: {
677
+ x: object.position.x,
678
+ y: object.position.y,
679
+ z: object.position.z
680
+ },
681
+ rotation: {
682
+ x: object.rotation.x,
683
+ y: object.rotation.y,
684
+ z: object.rotation.z
685
+ },
686
+ scale: {
687
+ x: object.scale.x,
688
+ y: object.scale.y,
689
+ z: object.scale.z
690
+ }
691
+ };
692
+ }
693
+
694
+ /**
695
+ * Set snap values for transformations
696
+ * @param {Object} options - Snap options
697
+ * @param {number} options.translation - Translation snap value
698
+ * @param {number} options.rotation - Rotation snap value in degrees
699
+ * @param {number} options.scale - Scale snap value
700
+ */
701
+ }, {
702
+ key: "setSnapValues",
703
+ value: function setSnapValues() {
704
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
705
+ if (!this.transformControls) return;
706
+ if (options.translation !== undefined) {
707
+ this.config.translationSnap = options.translation;
708
+ if (this.currentMode === 'translate') {
709
+ this.transformControls.setTranslationSnap(options.translation);
710
+ }
711
+ }
712
+ if (options.rotation !== undefined) {
713
+ // Convert degrees to radians for rotation snap
714
+ var rotationSnapRadians = options.rotation * (Math.PI / 180);
715
+ this.config.rotationSnap = rotationSnapRadians;
716
+ if (this.currentMode === 'rotate') {
717
+ this.transformControls.setRotationSnap(rotationSnapRadians);
718
+ }
719
+ }
720
+ if (options.scale !== undefined) {
721
+ this.config.scaleSnap = options.scale;
722
+ if (this.currentMode === 'scale') {
723
+ this.transformControls.setScaleSnap(options.scale);
724
+ }
725
+ }
726
+ }
727
+
728
+ /**
729
+ * Set size of transform controls
730
+ * @param {number} size - The size factor for transform controls
731
+ */
732
+ }, {
733
+ key: "setSize",
734
+ value: function setSize(size) {
735
+ this.config.size = size;
736
+ if (this.transformControls) {
737
+ this.transformControls.size = size;
738
+ }
739
+ }
740
+
741
+ /**
742
+ * Clean up resources and remove event listeners
743
+ */
744
+ }, {
745
+ key: "dispose",
746
+ value: function dispose() {
747
+ this.removeEventListeners();
748
+ this.hideBoundingBox();
749
+ if (this.transformControls) {
750
+ this.transformControls.detach();
751
+ this.scene.remove(this.transformControls);
752
+ this.transformControls = null;
753
+ }
754
+
755
+ // Clear references
756
+ this.selectedObject = null;
757
+ this.boundingBoxCache = new WeakMap();
758
+ console.log('🧹 TransformControlsManager disposed');
759
+ }
760
+
761
+ /**
762
+ * Ensures transform controls are properly attached to the scene
763
+ * @param {boolean} allowVisible - Whether to allow controls to be visible when reattached
764
+ * @returns {boolean} - True if controls were reattached, false if already attached
765
+ */
766
+ }, {
767
+ key: "ensureSceneAttachment",
768
+ value: function ensureSceneAttachment() {
769
+ var allowVisible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
770
+ if (!this.transformControls || !this.scene) return false;
771
+
772
+ // Check if the controls are already in the scene
773
+ var isInScene = this.scene.children.includes(this.transformControls);
774
+ if (!isInScene) {
775
+ // Reattach to scene
776
+ this.scene.add(this.transformControls);
777
+
778
+ // Set visibility based on allowVisible parameter and forceInvisible flag
779
+ this.transformControls.visible = allowVisible && !this.forceInvisible && this.config.enabled;
780
+ return true; // Controls were reattached
781
+ }
782
+ return false; // Already properly attached
783
+ }
784
+
785
+ /**
786
+ * Get current transform data for the selected object
787
+ * @returns {Object|null} Object containing position, rotation, scale, and world coordinates
788
+ */
789
+ }, {
790
+ key: "getTransformData",
791
+ value: function getTransformData() {
792
+ if (!this.selectedObject) return null;
793
+ var worldPosition = new THREE.Vector3();
794
+ this.selectedObject.getWorldPosition(worldPosition);
795
+ var worldQuaternion = new THREE.Quaternion();
796
+ this.selectedObject.getWorldQuaternion(worldQuaternion);
797
+ var worldEuler = new THREE.Euler().setFromQuaternion(worldQuaternion);
798
+ var worldScale = new THREE.Vector3();
799
+ this.selectedObject.getWorldScale(worldScale);
800
+ return {
801
+ uuid: this.selectedObject.uuid,
802
+ position: {
803
+ x: this.selectedObject.position.x,
804
+ y: this.selectedObject.position.y,
805
+ z: this.selectedObject.position.z
806
+ },
807
+ rotation: {
808
+ x: this.selectedObject.rotation.x,
809
+ y: this.selectedObject.rotation.y,
810
+ z: this.selectedObject.rotation.z
811
+ },
812
+ scale: {
813
+ x: this.selectedObject.scale.x,
814
+ y: this.selectedObject.scale.y,
815
+ z: this.selectedObject.scale.z
816
+ },
817
+ worldPosition: {
818
+ x: worldPosition.x,
819
+ y: worldPosition.y,
820
+ z: worldPosition.z
821
+ },
822
+ worldRotation: {
823
+ x: worldEuler.x,
824
+ y: worldEuler.y,
825
+ z: worldEuler.z
826
+ },
827
+ worldScale: {
828
+ x: worldScale.x,
829
+ y: worldScale.y,
830
+ z: worldScale.z
831
+ }
832
+ };
833
+ }
834
+ }]);
835
+ }();
836
+
837
+ /**
838
+ * Factory function to get TransformControlsManager instance
839
+ * @param {THREE.Scene} scene - The Three.js scene
840
+ * @param {THREE.Camera} camera - The Three.js camera
841
+ * @param {THREE.WebGLRenderer} renderer - The Three.js renderer
842
+ * @param {THREE.OrbitControls} orbitControls - Optional orbit controls for camera
843
+ * @returns {TransformControlsManager} TransformControlsManager instance
844
+ */
845
+ function getTransformControlsManager(scene, camera, renderer, orbitControls) {
846
+ return new TransformControlsManager(scene, camera, renderer, orbitControls);
847
+ }
848
+
849
+ exports.TransformControlsManager = TransformControlsManager;
850
+ exports["default"] = TransformControlsManager;
851
+ exports.getTransformControlsManager = getTransformControlsManager;