@2112-lab/central-plant 0.1.18 โ 0.1.19
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.
package/dist/bundle/index.js
CHANGED
|
@@ -26485,6 +26485,1238 @@ var CentralPlant = /*#__PURE__*/function () {
|
|
|
26485
26485
|
}]);
|
|
26486
26486
|
}();
|
|
26487
26487
|
|
|
26488
|
+
var SceneViewerEnhanced = /*#__PURE__*/function () {
|
|
26489
|
+
function SceneViewerEnhanced(container) {
|
|
26490
|
+
var centralPlant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
26491
|
+
_classCallCheck(this, SceneViewerEnhanced);
|
|
26492
|
+
// Container element where the scene will be rendered
|
|
26493
|
+
this.container = container;
|
|
26494
|
+
this.centralPlant = centralPlant;
|
|
26495
|
+
|
|
26496
|
+
// Create Vue-like $refs object to maintain compatibility with managers
|
|
26497
|
+
this.$refs = {
|
|
26498
|
+
container: container
|
|
26499
|
+
};
|
|
26500
|
+
|
|
26501
|
+
// Scene components
|
|
26502
|
+
this.scene = null;
|
|
26503
|
+
this.camera = null;
|
|
26504
|
+
this.renderer = null;
|
|
26505
|
+
this.controls = null;
|
|
26506
|
+
this.currentSceneData = null;
|
|
26507
|
+
|
|
26508
|
+
// Flag to stop animation loop during cleanup
|
|
26509
|
+
this.isDestroyed = false;
|
|
26510
|
+
|
|
26511
|
+
// Transform controls
|
|
26512
|
+
this.transformManager = null;
|
|
26513
|
+
this.selectedObjectForTransform = null;
|
|
26514
|
+
this.transformMode = 'translate';
|
|
26515
|
+
this.transformHistory = [];
|
|
26516
|
+
this.previousTransformValues = null;
|
|
26517
|
+
|
|
26518
|
+
// Manager instances
|
|
26519
|
+
this.disposalManager = null;
|
|
26520
|
+
this.sceneExportManager = null;
|
|
26521
|
+
this.componentManager = null;
|
|
26522
|
+
this.sceneInitializationManager = null;
|
|
26523
|
+
this.environmentManager = null;
|
|
26524
|
+
this.keyboardControlsManager = null;
|
|
26525
|
+
this.pathfindingManager = null;
|
|
26526
|
+
this.sceneOperationsManager = null;
|
|
26527
|
+
this.animationManager = null;
|
|
26528
|
+
this.cameraControlsManager = null;
|
|
26529
|
+
this.tooltipsManager = null;
|
|
26530
|
+
|
|
26531
|
+
// Scene helper utility
|
|
26532
|
+
this.sceneHelper = null;
|
|
26533
|
+
|
|
26534
|
+
// Transform settings
|
|
26535
|
+
this.shouldUpdatePaths = true;
|
|
26536
|
+
|
|
26537
|
+
// Event callbacks
|
|
26538
|
+
this.callbacks = {
|
|
26539
|
+
onSceneDataUpdated: null,
|
|
26540
|
+
onObjectSelected: null,
|
|
26541
|
+
onTransformUpdate: null,
|
|
26542
|
+
onTransformModeChanged: null,
|
|
26543
|
+
onSceneChanged: null
|
|
26544
|
+
};
|
|
26545
|
+
}
|
|
26546
|
+
|
|
26547
|
+
/**
|
|
26548
|
+
* Initialize the scene viewer
|
|
26549
|
+
*/
|
|
26550
|
+
return _createClass(SceneViewerEnhanced, [{
|
|
26551
|
+
key: "init",
|
|
26552
|
+
value: (function () {
|
|
26553
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
26554
|
+
var _t;
|
|
26555
|
+
return _regenerator().w(function (_context) {
|
|
26556
|
+
while (1) switch (_context.n) {
|
|
26557
|
+
case 0:
|
|
26558
|
+
_context.p = 0;
|
|
26559
|
+
if (this.centralPlant) {
|
|
26560
|
+
_context.n = 1;
|
|
26561
|
+
break;
|
|
26562
|
+
}
|
|
26563
|
+
console.error('โ CentralPlant not provided');
|
|
26564
|
+
return _context.a(2, false);
|
|
26565
|
+
case 1:
|
|
26566
|
+
// Set this scene viewer instance on the managers collection
|
|
26567
|
+
this.centralPlant.setSceneViewer(this);
|
|
26568
|
+
|
|
26569
|
+
// Attach all managers and utilities to this component instance
|
|
26570
|
+
this.centralPlant.attachToComponent();
|
|
26571
|
+
_context.n = 2;
|
|
26572
|
+
return this.initializeScene();
|
|
26573
|
+
case 2:
|
|
26574
|
+
return _context.a(2, true);
|
|
26575
|
+
case 3:
|
|
26576
|
+
_context.p = 3;
|
|
26577
|
+
_t = _context.v;
|
|
26578
|
+
console.error('Error during scene viewer initialization:', _t);
|
|
26579
|
+
return _context.a(2, false);
|
|
26580
|
+
}
|
|
26581
|
+
}, _callee, this, [[0, 3]]);
|
|
26582
|
+
}));
|
|
26583
|
+
function init() {
|
|
26584
|
+
return _init.apply(this, arguments);
|
|
26585
|
+
}
|
|
26586
|
+
return init;
|
|
26587
|
+
}()
|
|
26588
|
+
/**
|
|
26589
|
+
* Initialize scene components and managers
|
|
26590
|
+
*/
|
|
26591
|
+
)
|
|
26592
|
+
}, {
|
|
26593
|
+
key: "initializeScene",
|
|
26594
|
+
value: (function () {
|
|
26595
|
+
var _initializeScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
26596
|
+
var _this = this;
|
|
26597
|
+
return _regenerator().w(function (_context2) {
|
|
26598
|
+
while (1) switch (_context2.n) {
|
|
26599
|
+
case 0:
|
|
26600
|
+
_context2.n = 1;
|
|
26601
|
+
return this.sceneInitializationManager.initialize();
|
|
26602
|
+
case 1:
|
|
26603
|
+
_context2.n = 2;
|
|
26604
|
+
return this.environmentManager.initializeEnvironment();
|
|
26605
|
+
case 2:
|
|
26606
|
+
// Setup keyboard controls and resize handlers
|
|
26607
|
+
this.keyboardControlsManager.setupKeyboardControls();
|
|
26608
|
+
this.keyboardControlsManager.setupResizeHandler();
|
|
26609
|
+
|
|
26610
|
+
// Initialize managers that need scene components (tooltip)
|
|
26611
|
+
if (this.centralPlant) {
|
|
26612
|
+
this.centralPlant.initializePostSceneManagers();
|
|
26613
|
+
}
|
|
26614
|
+
|
|
26615
|
+
// Handle window resize to update tooltip renderer size
|
|
26616
|
+
window.addEventListener('resize', function () {
|
|
26617
|
+
if (_this.tooltipsManager) {
|
|
26618
|
+
_this.tooltipsManager.resize();
|
|
26619
|
+
}
|
|
26620
|
+
});
|
|
26621
|
+
|
|
26622
|
+
// Configure auto-rotation (initialize state from controls)
|
|
26623
|
+
if (this.controls && this.cameraControlsManager) {
|
|
26624
|
+
this.cameraControlsManager.isAutoRotating();
|
|
26625
|
+
}
|
|
26626
|
+
|
|
26627
|
+
// Load and setup scene
|
|
26628
|
+
_context2.n = 3;
|
|
26629
|
+
return this.loadScene();
|
|
26630
|
+
case 3:
|
|
26631
|
+
// Start animation loop
|
|
26632
|
+
this.animationManager.startAnimation();
|
|
26633
|
+
|
|
26634
|
+
// Set up event listeners for scene loading
|
|
26635
|
+
this.sceneOperationsManager.setupEventListeners();
|
|
26636
|
+
|
|
26637
|
+
// Initialize transform controls AFTER all other initialization is complete
|
|
26638
|
+
// This ensures that createTransformControls is available via attachToComponent
|
|
26639
|
+
this.initTransformControls();
|
|
26640
|
+
|
|
26641
|
+
// Use transform manager's object selection instead of our own
|
|
26642
|
+
if (this.transformManager) {
|
|
26643
|
+
this.transformManager.setupObjectSelection(function (obj) {
|
|
26644
|
+
return _this.isSelectableObject(obj);
|
|
26645
|
+
});
|
|
26646
|
+
}
|
|
26647
|
+
console.log('๐ Transform controls will be enabled after scene loading');
|
|
26648
|
+
case 4:
|
|
26649
|
+
return _context2.a(2);
|
|
26650
|
+
}
|
|
26651
|
+
}, _callee2, this);
|
|
26652
|
+
}));
|
|
26653
|
+
function initializeScene() {
|
|
26654
|
+
return _initializeScene.apply(this, arguments);
|
|
26655
|
+
}
|
|
26656
|
+
return initializeScene;
|
|
26657
|
+
}()
|
|
26658
|
+
/**
|
|
26659
|
+
* Add event listener for scene viewer events
|
|
26660
|
+
*/
|
|
26661
|
+
)
|
|
26662
|
+
}, {
|
|
26663
|
+
key: "on",
|
|
26664
|
+
value: function on(eventName, callback) {
|
|
26665
|
+
if (this.callbacks.hasOwnProperty("on".concat(eventName.charAt(0).toUpperCase() + eventName.slice(1)))) {
|
|
26666
|
+
this.callbacks["on".concat(eventName.charAt(0).toUpperCase() + eventName.slice(1))] = callback;
|
|
26667
|
+
}
|
|
26668
|
+
}
|
|
26669
|
+
|
|
26670
|
+
/**
|
|
26671
|
+
* Emit event to registered callbacks (Vue-compatible method)
|
|
26672
|
+
*/
|
|
26673
|
+
}, {
|
|
26674
|
+
key: "$emit",
|
|
26675
|
+
value: function $emit(eventName, data) {
|
|
26676
|
+
this.emit(eventName, data);
|
|
26677
|
+
}
|
|
26678
|
+
|
|
26679
|
+
/**
|
|
26680
|
+
* Emit event to registered callbacks
|
|
26681
|
+
*/
|
|
26682
|
+
}, {
|
|
26683
|
+
key: "emit",
|
|
26684
|
+
value: function emit(eventName, data) {
|
|
26685
|
+
var callbackName = "on".concat(eventName.charAt(0).toUpperCase() + eventName.slice(1).replace(/-([a-z])/g, function (g) {
|
|
26686
|
+
return g[1].toUpperCase();
|
|
26687
|
+
}));
|
|
26688
|
+
if (this.callbacks[callbackName] && typeof this.callbacks[callbackName] === 'function') {
|
|
26689
|
+
this.callbacks[callbackName](data);
|
|
26690
|
+
}
|
|
26691
|
+
}
|
|
26692
|
+
|
|
26693
|
+
/**
|
|
26694
|
+
* Load scene data
|
|
26695
|
+
*/
|
|
26696
|
+
}, {
|
|
26697
|
+
key: "loadSceneData",
|
|
26698
|
+
value: (function () {
|
|
26699
|
+
var _loadSceneData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(data) {
|
|
26700
|
+
var isImported,
|
|
26701
|
+
_args3 = arguments;
|
|
26702
|
+
return _regenerator().w(function (_context3) {
|
|
26703
|
+
while (1) switch (_context3.n) {
|
|
26704
|
+
case 0:
|
|
26705
|
+
isImported = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : true;
|
|
26706
|
+
if (!this.sceneOperationsManager) {
|
|
26707
|
+
_context3.n = 2;
|
|
26708
|
+
break;
|
|
26709
|
+
}
|
|
26710
|
+
_context3.n = 1;
|
|
26711
|
+
return this.sceneOperationsManager.loadSceneData(data, isImported);
|
|
26712
|
+
case 1:
|
|
26713
|
+
// Update scene helper with new scene data
|
|
26714
|
+
if (this.sceneHelper) {
|
|
26715
|
+
this.sceneHelper.updateSceneData(data);
|
|
26716
|
+
}
|
|
26717
|
+
case 2:
|
|
26718
|
+
return _context3.a(2);
|
|
26719
|
+
}
|
|
26720
|
+
}, _callee3, this);
|
|
26721
|
+
}));
|
|
26722
|
+
function loadSceneData(_x) {
|
|
26723
|
+
return _loadSceneData.apply(this, arguments);
|
|
26724
|
+
}
|
|
26725
|
+
return loadSceneData;
|
|
26726
|
+
}()
|
|
26727
|
+
/**
|
|
26728
|
+
* Load default scene
|
|
26729
|
+
*/
|
|
26730
|
+
)
|
|
26731
|
+
}, {
|
|
26732
|
+
key: "loadScene",
|
|
26733
|
+
value: (function () {
|
|
26734
|
+
var _loadScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
26735
|
+
return _regenerator().w(function (_context4) {
|
|
26736
|
+
while (1) switch (_context4.n) {
|
|
26737
|
+
case 0:
|
|
26738
|
+
if (!this.sceneOperationsManager) {
|
|
26739
|
+
_context4.n = 2;
|
|
26740
|
+
break;
|
|
26741
|
+
}
|
|
26742
|
+
_context4.n = 1;
|
|
26743
|
+
return this.sceneOperationsManager.loadScene();
|
|
26744
|
+
case 1:
|
|
26745
|
+
_context4.n = 3;
|
|
26746
|
+
break;
|
|
26747
|
+
case 2:
|
|
26748
|
+
console.error('โ SceneOperationsManager not available for loadScene');
|
|
26749
|
+
case 3:
|
|
26750
|
+
return _context4.a(2);
|
|
26751
|
+
}
|
|
26752
|
+
}, _callee4, this);
|
|
26753
|
+
}));
|
|
26754
|
+
function loadScene() {
|
|
26755
|
+
return _loadScene.apply(this, arguments);
|
|
26756
|
+
}
|
|
26757
|
+
return loadScene;
|
|
26758
|
+
}()
|
|
26759
|
+
/**
|
|
26760
|
+
* Clear scene objects while preserving base environment
|
|
26761
|
+
*/
|
|
26762
|
+
)
|
|
26763
|
+
}, {
|
|
26764
|
+
key: "clearSceneObjects",
|
|
26765
|
+
value: function clearSceneObjects() {
|
|
26766
|
+
if (this.sceneOperationsManager) {
|
|
26767
|
+
this.sceneOperationsManager.clearSceneObjects();
|
|
26768
|
+
}
|
|
26769
|
+
}
|
|
26770
|
+
|
|
26771
|
+
/**
|
|
26772
|
+
* Create empty scene with just the base environment
|
|
26773
|
+
*/
|
|
26774
|
+
}, {
|
|
26775
|
+
key: "createEmptyScene",
|
|
26776
|
+
value: function createEmptyScene() {
|
|
26777
|
+
if (this.sceneOperationsManager) {
|
|
26778
|
+
this.sceneOperationsManager.createEmptyScene();
|
|
26779
|
+
}
|
|
26780
|
+
}
|
|
26781
|
+
|
|
26782
|
+
/**
|
|
26783
|
+
* Load scene from imported JSON data
|
|
26784
|
+
*/
|
|
26785
|
+
}, {
|
|
26786
|
+
key: "loadSceneFromData",
|
|
26787
|
+
value: (function () {
|
|
26788
|
+
var _loadSceneFromData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(data) {
|
|
26789
|
+
return _regenerator().w(function (_context5) {
|
|
26790
|
+
while (1) switch (_context5.n) {
|
|
26791
|
+
case 0:
|
|
26792
|
+
if (!this.sceneOperationsManager) {
|
|
26793
|
+
_context5.n = 1;
|
|
26794
|
+
break;
|
|
26795
|
+
}
|
|
26796
|
+
_context5.n = 1;
|
|
26797
|
+
return this.sceneOperationsManager.loadSceneFromData(data);
|
|
26798
|
+
case 1:
|
|
26799
|
+
return _context5.a(2);
|
|
26800
|
+
}
|
|
26801
|
+
}, _callee5, this);
|
|
26802
|
+
}));
|
|
26803
|
+
function loadSceneFromData(_x2) {
|
|
26804
|
+
return _loadSceneFromData.apply(this, arguments);
|
|
26805
|
+
}
|
|
26806
|
+
return loadSceneFromData;
|
|
26807
|
+
}()
|
|
26808
|
+
/**
|
|
26809
|
+
* Clear the model cache to free up memory
|
|
26810
|
+
*/
|
|
26811
|
+
)
|
|
26812
|
+
}, {
|
|
26813
|
+
key: "clearModelCache",
|
|
26814
|
+
value: function clearModelCache() {
|
|
26815
|
+
if (this.sceneOperationsManager) {
|
|
26816
|
+
this.sceneOperationsManager.clearModelCache();
|
|
26817
|
+
}
|
|
26818
|
+
}
|
|
26819
|
+
|
|
26820
|
+
/**
|
|
26821
|
+
* Initialize transform controls
|
|
26822
|
+
*/
|
|
26823
|
+
}, {
|
|
26824
|
+
key: "initTransformControls",
|
|
26825
|
+
value: function initTransformControls() {
|
|
26826
|
+
if (!this.scene || !this.camera || !this.renderer) {
|
|
26827
|
+
console.warn('โ ๏ธ Cannot initialize transform controls: missing scene components');
|
|
26828
|
+
return;
|
|
26829
|
+
}
|
|
26830
|
+
|
|
26831
|
+
// Clean up existing transform manager if it exists
|
|
26832
|
+
if (this.transformManager) {
|
|
26833
|
+
console.log('๐ง Cleaning up existing transform manager before reinitializing');
|
|
26834
|
+
this.transformManager.dispose();
|
|
26835
|
+
}
|
|
26836
|
+
|
|
26837
|
+
// Create new transform controls manager using utility from centralPlant
|
|
26838
|
+
this.transformManager = this.createTransformControls(this.scene, this.camera, this.renderer, this.controls // OrbitControls instance
|
|
26839
|
+
);
|
|
26840
|
+
|
|
26841
|
+
// Register event callbacks
|
|
26842
|
+
this.transformManager.on({
|
|
26843
|
+
onObjectSelect: this.onObjectSelect.bind(this),
|
|
26844
|
+
onTransformStart: this.onTransformStart.bind(this),
|
|
26845
|
+
onTransform: this.onTransform.bind(this),
|
|
26846
|
+
onTransformEnd: this.onTransformEnd.bind(this),
|
|
26847
|
+
onModeChange: this.onModeChange.bind(this),
|
|
26848
|
+
onObjectRemoved: this.onObjectRemoved.bind(this)
|
|
26849
|
+
});
|
|
26850
|
+
|
|
26851
|
+
// Set up reasonable defaults
|
|
26852
|
+
this.transformManager.setSnap({
|
|
26853
|
+
translation: 0.5,
|
|
26854
|
+
rotation: Math.PI / 2,
|
|
26855
|
+
// 90 degrees
|
|
26856
|
+
scale: 0.05
|
|
26857
|
+
});
|
|
26858
|
+
|
|
26859
|
+
// Set transform controls size to 50% of default
|
|
26860
|
+
this.transformManager.setSize(0.5);
|
|
26861
|
+
|
|
26862
|
+
// Hide multi-axis plane helpers by default (only allow single-axis translation)
|
|
26863
|
+
this.transformManager.setShowPlanes(false);
|
|
26864
|
+
|
|
26865
|
+
// Set transform controls to invisible by default
|
|
26866
|
+
if (this.transformManager.transformControls) {
|
|
26867
|
+
this.transformManager.transformControls.visible = false;
|
|
26868
|
+
this.transformManager.setEnabled(false);
|
|
26869
|
+
}
|
|
26870
|
+
|
|
26871
|
+
// Check that transform controls are properly in scene
|
|
26872
|
+
var isInScene = this.scene.children.includes(this.transformManager.transformControls);
|
|
26873
|
+
console.log('๐ง Transform controls initialized and in scene:', isInScene ? 'YES' : 'NO');
|
|
26874
|
+
}
|
|
26875
|
+
|
|
26876
|
+
/**
|
|
26877
|
+
* Transform control event handlers
|
|
26878
|
+
*/
|
|
26879
|
+
}, {
|
|
26880
|
+
key: "onObjectSelect",
|
|
26881
|
+
value: function onObjectSelect(object) {
|
|
26882
|
+
this.selectedObjectForTransform = object;
|
|
26883
|
+
|
|
26884
|
+
// If object is null, it means we clicked away
|
|
26885
|
+
if (!object) {
|
|
26886
|
+
// Clear tooltip when clicking away from objects
|
|
26887
|
+
if (this.tooltipsManager) {
|
|
26888
|
+
this.tooltipsManager.handleSceneClick();
|
|
26889
|
+
}
|
|
26890
|
+
|
|
26891
|
+
// Hide transform controls when clicking away
|
|
26892
|
+
if (this.transformManager && this.transformManager.transformControls) {
|
|
26893
|
+
this.transformManager.transformControls.enabled = false;
|
|
26894
|
+
this.transformManager.transformControls.visible = false;
|
|
26895
|
+
}
|
|
26896
|
+
this.emit('object-selected-for-transform', null);
|
|
26897
|
+
return;
|
|
26898
|
+
}
|
|
26899
|
+
|
|
26900
|
+
// Object is selected, show transform controls
|
|
26901
|
+
if (this.transformManager && this.transformManager.transformControls) {
|
|
26902
|
+
this.transformManager.transformControls.enabled = true;
|
|
26903
|
+
this.transformManager.transformControls.visible = true;
|
|
26904
|
+
}
|
|
26905
|
+
|
|
26906
|
+
// Show tooltip if the object has component data
|
|
26907
|
+
if (this.tooltipsManager && object && object.userData) {
|
|
26908
|
+
// Make sure component exists in userData
|
|
26909
|
+
if (!object.userData.component) {
|
|
26910
|
+
object.userData.component = {};
|
|
26911
|
+
}
|
|
26912
|
+
|
|
26913
|
+
// Make sure attributes exists in component
|
|
26914
|
+
if (!object.userData.component.attributes && object.userData.componentType) {
|
|
26915
|
+
// Create default attributes based on component type
|
|
26916
|
+
object.userData.component.attributes = {
|
|
26917
|
+
'info': {
|
|
26918
|
+
key: 'Type',
|
|
26919
|
+
value: object.userData.componentType || 'component',
|
|
26920
|
+
min: 0,
|
|
26921
|
+
max: 100,
|
|
26922
|
+
step: 1
|
|
26923
|
+
}
|
|
26924
|
+
};
|
|
26925
|
+
}
|
|
26926
|
+
|
|
26927
|
+
// Determine the best tooltip corner position based on the object's position in the scene
|
|
26928
|
+
var cornerPosition = this.determineTooltipPosition(object);
|
|
26929
|
+
|
|
26930
|
+
// Now set the selected mesh for tooltip display with the appropriate corner position
|
|
26931
|
+
this.tooltipsManager.setSelectedMesh(object, cornerPosition);
|
|
26932
|
+
} else if (this.tooltipsManager) {
|
|
26933
|
+
// Clear tooltip if no valid userData
|
|
26934
|
+
this.tooltipsManager.clearTooltip();
|
|
26935
|
+
}
|
|
26936
|
+
|
|
26937
|
+
// Emit event
|
|
26938
|
+
this.emit('object-selected-for-transform', object);
|
|
26939
|
+
}
|
|
26940
|
+
}, {
|
|
26941
|
+
key: "onTransformStart",
|
|
26942
|
+
value: function onTransformStart(object, mode) {
|
|
26943
|
+
console.log("\uD83D\uDD27 Started ".concat(mode, " transformation on ").concat(object.uuid));
|
|
26944
|
+
|
|
26945
|
+
// Store the current transform mode for history tracking
|
|
26946
|
+
this.transformMode = mode;
|
|
26947
|
+
|
|
26948
|
+
// Store previous transform values for history tracking
|
|
26949
|
+
this.previousTransformValues = {
|
|
26950
|
+
position: object.position.clone(),
|
|
26951
|
+
rotation: object.rotation.clone(),
|
|
26952
|
+
scale: object.scale.clone()
|
|
26953
|
+
};
|
|
26954
|
+
}
|
|
26955
|
+
}, {
|
|
26956
|
+
key: "onTransform",
|
|
26957
|
+
value: function onTransform(object, mode) {
|
|
26958
|
+
// Real-time transform feedback with both local and world coordinates
|
|
26959
|
+
var transform = this.transformManager.getTransformData();
|
|
26960
|
+
|
|
26961
|
+
// Update tooltip position if it exists
|
|
26962
|
+
if (this.tooltipsManager && object === this.tooltipsManager.selectedMesh) {
|
|
26963
|
+
// Determine the best tooltip position dynamically as the object moves
|
|
26964
|
+
var cornerPosition = this.determineTooltipPosition(object);
|
|
26965
|
+
this.tooltipsManager.updateTooltip(cornerPosition);
|
|
26966
|
+
}
|
|
26967
|
+
this.emit('transform-update', transform);
|
|
26968
|
+
}
|
|
26969
|
+
}, {
|
|
26970
|
+
key: "onTransformEnd",
|
|
26971
|
+
value: function onTransformEnd(object) {
|
|
26972
|
+
console.log('onTransformEnd started:', object);
|
|
26973
|
+
|
|
26974
|
+
// Check if the transformed object is a pipe segment and handle connector-based transformation
|
|
26975
|
+
if (object && object.userData && object.userData.isPipeSegment) {
|
|
26976
|
+
var segmentInfo = {
|
|
26977
|
+
segmentId: object.userData.segmentId,
|
|
26978
|
+
segmentIndex: object.userData.segmentIndex,
|
|
26979
|
+
pathFrom: object.userData.pathFrom,
|
|
26980
|
+
pathTo: object.userData.pathTo,
|
|
26981
|
+
pathIndex: object.userData.pathIndex,
|
|
26982
|
+
length: object.userData.length,
|
|
26983
|
+
name: object.name
|
|
26984
|
+
};
|
|
26985
|
+
console.log('๐ง Pipe segment transformation completed:', segmentInfo);
|
|
26986
|
+
console.log('๐ Pipe segment position after transform:', {
|
|
26987
|
+
x: object.position.x.toFixed(3),
|
|
26988
|
+
y: object.position.y.toFixed(3),
|
|
26989
|
+
z: object.position.z.toFixed(3)
|
|
26990
|
+
});
|
|
26991
|
+
|
|
26992
|
+
// Handle manual segment transformation with connector generation
|
|
26993
|
+
if (this.pathfindingManager && this.currentSceneData) {
|
|
26994
|
+
this.pathfindingManager.handleManualSegmentTransformation(object, this.currentSceneData);
|
|
26995
|
+
} else {
|
|
26996
|
+
console.warn('โ ๏ธ PathfindingManager or CurrentSceneData not available');
|
|
26997
|
+
}
|
|
26998
|
+
} else {
|
|
26999
|
+
console.warn('๐ Object is not a pipe segment');
|
|
27000
|
+
}
|
|
27001
|
+
|
|
27002
|
+
// Check if component is underground and move to surface if needed
|
|
27003
|
+
var checkUnderground = this.getCheckUndergroundSetting();
|
|
27004
|
+
if (checkUnderground && object.position.y < 0) {
|
|
27005
|
+
console.log("\uD83D\uDD27 Component was underground (y=".concat(object.position.y.toFixed(3), "), moving to surface"));
|
|
27006
|
+
object.position.y = 0;
|
|
27007
|
+
|
|
27008
|
+
// Update the transform controls to reflect the new position
|
|
27009
|
+
if (this.transformManager && this.transformManager.transformControls) {
|
|
27010
|
+
this.transformManager.transformControls.object = object;
|
|
27011
|
+
}
|
|
27012
|
+
console.log("\u2705 Component moved to surface (y=".concat(object.position.y.toFixed(3), ")"));
|
|
27013
|
+
}
|
|
27014
|
+
object.updateMatrix();
|
|
27015
|
+
var worldBoundingBox = new THREE__namespace.Box3().setFromObject(object);
|
|
27016
|
+
if (object.userData.associatedJsonObject) {
|
|
27017
|
+
// Update jsonData.userData.worldBoundingBox as array of numbers
|
|
27018
|
+
object.userData.associatedJsonObject.userData.worldBoundingBox.min = worldBoundingBox.min.toArray();
|
|
27019
|
+
object.userData.associatedJsonObject.userData.worldBoundingBox.max = worldBoundingBox.max.toArray();
|
|
27020
|
+
}
|
|
27021
|
+
|
|
27022
|
+
// Record the transform operation in CentralPlant's transform history
|
|
27023
|
+
if (this.centralPlant && this.previousTransformValues) {
|
|
27024
|
+
var currentTransformValues = {
|
|
27025
|
+
position: object.position.clone(),
|
|
27026
|
+
rotation: object.rotation.clone(),
|
|
27027
|
+
scale: object.scale.clone()
|
|
27028
|
+
};
|
|
27029
|
+
this.centralPlant.recordTransform({
|
|
27030
|
+
type: this.transformMode || 'translate',
|
|
27031
|
+
object: object,
|
|
27032
|
+
values: currentTransformValues,
|
|
27033
|
+
previousValues: this.previousTransformValues
|
|
27034
|
+
});
|
|
27035
|
+
|
|
27036
|
+
// Clear previous values after recording
|
|
27037
|
+
this.previousTransformValues = null;
|
|
27038
|
+
}
|
|
27039
|
+
|
|
27040
|
+
// Delegate the complex update logic to SceneOperationsManager
|
|
27041
|
+
if (this.sceneOperationsManager) {
|
|
27042
|
+
this.sceneOperationsManager.updateSceneDataAfterTransform(object, this.currentSceneData);
|
|
27043
|
+
}
|
|
27044
|
+
if (this.shouldUpdatePaths) {
|
|
27045
|
+
this.updatePaths();
|
|
27046
|
+
}
|
|
27047
|
+
if (typeof window !== 'undefined') {
|
|
27048
|
+
// Also dispatch a general scene initialization complete event
|
|
27049
|
+
console.log('๐ก Dispatching sceneUpdateComplete event');
|
|
27050
|
+
var sceneCompleteEvent = new CustomEvent('sceneUpdateComplete', {
|
|
27051
|
+
detail: {
|
|
27052
|
+
timestamp: Date.now()
|
|
27053
|
+
}
|
|
27054
|
+
});
|
|
27055
|
+
window.dispatchEvent(sceneCompleteEvent);
|
|
27056
|
+
}
|
|
27057
|
+
}
|
|
27058
|
+
}, {
|
|
27059
|
+
key: "onModeChange",
|
|
27060
|
+
value: function onModeChange(newMode, oldMode) {
|
|
27061
|
+
this.transformMode = newMode;
|
|
27062
|
+
console.log("\uD83D\uDD04 Transform mode: ".concat(oldMode, " \u2192 ").concat(newMode));
|
|
27063
|
+
|
|
27064
|
+
// Emit event
|
|
27065
|
+
this.emit('transform-mode-changed', newMode);
|
|
27066
|
+
}
|
|
27067
|
+
}, {
|
|
27068
|
+
key: "onObjectRemoved",
|
|
27069
|
+
value: function onObjectRemoved(object) {
|
|
27070
|
+
console.log('๐๏ธ Object removed:', object.uuid);
|
|
27071
|
+
this.onGatewayConnectionsRevert(object);
|
|
27072
|
+
}
|
|
27073
|
+
|
|
27074
|
+
/**
|
|
27075
|
+
* Update pathfinding with new connections
|
|
27076
|
+
*/
|
|
27077
|
+
}, {
|
|
27078
|
+
key: "updatePathfindingWithConnections",
|
|
27079
|
+
value: (function () {
|
|
27080
|
+
var _updatePathfindingWithConnections = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(newConnections) {
|
|
27081
|
+
var success;
|
|
27082
|
+
return _regenerator().w(function (_context6) {
|
|
27083
|
+
while (1) switch (_context6.n) {
|
|
27084
|
+
case 0:
|
|
27085
|
+
if (!this.pathfindingManager) {
|
|
27086
|
+
_context6.n = 2;
|
|
27087
|
+
break;
|
|
27088
|
+
}
|
|
27089
|
+
_context6.n = 1;
|
|
27090
|
+
return this.pathfindingManager.updatePathfindingWithConnections(newConnections);
|
|
27091
|
+
case 1:
|
|
27092
|
+
success = _context6.v;
|
|
27093
|
+
if (success) {
|
|
27094
|
+
// Emit event to notify about the scene data change
|
|
27095
|
+
this.emit('scene-data-updated', {
|
|
27096
|
+
action: 'connections-update',
|
|
27097
|
+
connections: newConnections,
|
|
27098
|
+
sceneData: this.currentSceneData
|
|
27099
|
+
});
|
|
27100
|
+
}
|
|
27101
|
+
return _context6.a(2, success);
|
|
27102
|
+
case 2:
|
|
27103
|
+
return _context6.a(2, false);
|
|
27104
|
+
}
|
|
27105
|
+
}, _callee6, this);
|
|
27106
|
+
}));
|
|
27107
|
+
function updatePathfindingWithConnections(_x3) {
|
|
27108
|
+
return _updatePathfindingWithConnections.apply(this, arguments);
|
|
27109
|
+
}
|
|
27110
|
+
return updatePathfindingWithConnections;
|
|
27111
|
+
}())
|
|
27112
|
+
}, {
|
|
27113
|
+
key: "getPathColor",
|
|
27114
|
+
value: function getPathColor(index) {
|
|
27115
|
+
return this.pathfindingManager ? this.pathfindingManager.getPathColor(index) : '#468e49';
|
|
27116
|
+
}
|
|
27117
|
+
}, {
|
|
27118
|
+
key: "updatePaths",
|
|
27119
|
+
value: function updatePaths() {
|
|
27120
|
+
console.log("updatePaths started");
|
|
27121
|
+
// Delegate pathfinding update to PathfindingManager
|
|
27122
|
+
if (this.pathfindingManager) {
|
|
27123
|
+
this.pathfindingManager.updatePathfindingAfterTransform(this.currentSceneData);
|
|
27124
|
+
}
|
|
27125
|
+
}
|
|
27126
|
+
|
|
27127
|
+
/**
|
|
27128
|
+
* Remove all paths
|
|
27129
|
+
*/
|
|
27130
|
+
}, {
|
|
27131
|
+
key: "removeAllPaths",
|
|
27132
|
+
value: function removeAllPaths() {
|
|
27133
|
+
if (this.pathfindingManager) {
|
|
27134
|
+
this.pathfindingManager.removeAllPaths();
|
|
27135
|
+
}
|
|
27136
|
+
}
|
|
27137
|
+
|
|
27138
|
+
/**
|
|
27139
|
+
* Recompute world bounding boxes
|
|
27140
|
+
*/
|
|
27141
|
+
}, {
|
|
27142
|
+
key: "recomputeWorldBoundingBoxes",
|
|
27143
|
+
value: function recomputeWorldBoundingBoxes(currentSceneData) {
|
|
27144
|
+
if (this.pathfindingManager) {
|
|
27145
|
+
this.pathfindingManager.recomputeWorldBoundingBoxes(currentSceneData);
|
|
27146
|
+
}
|
|
27147
|
+
}
|
|
27148
|
+
|
|
27149
|
+
/**
|
|
27150
|
+
* Gateway removal callback handlers
|
|
27151
|
+
*/
|
|
27152
|
+
}, {
|
|
27153
|
+
key: "onGatewayConnectionsRevert",
|
|
27154
|
+
value: function onGatewayConnectionsRevert(gatewayInfo) {
|
|
27155
|
+
console.log('๐ Reverting gateway connections in SceneViewer:', gatewayInfo);
|
|
27156
|
+
|
|
27157
|
+
// Revert connections that were modified when the gateway was declared
|
|
27158
|
+
if (this.currentSceneData && this.currentSceneData.connections && gatewayInfo.connections) {
|
|
27159
|
+
var currentConnections = this.currentSceneData.connections;
|
|
27160
|
+
|
|
27161
|
+
// Revert removed connections (add them back)
|
|
27162
|
+
if (gatewayInfo.connections.removed && Array.isArray(gatewayInfo.connections.removed)) {
|
|
27163
|
+
console.log('๐ Adding back removed connections:', gatewayInfo.connections.removed);
|
|
27164
|
+
gatewayInfo.connections.removed.forEach(function (removedConn) {
|
|
27165
|
+
// Check if connection already exists to avoid duplicates
|
|
27166
|
+
var alreadyExists = currentConnections.some(function (conn) {
|
|
27167
|
+
return conn.from === removedConn.from && conn.to === removedConn.to || conn.from === removedConn.to && conn.to === removedConn.from;
|
|
27168
|
+
});
|
|
27169
|
+
if (!alreadyExists) {
|
|
27170
|
+
currentConnections.push(removedConn);
|
|
27171
|
+
console.log("\uD83D\uDD04 Added back connection: ".concat(removedConn.from, " \u2192 ").concat(removedConn.to));
|
|
27172
|
+
}
|
|
27173
|
+
});
|
|
27174
|
+
}
|
|
27175
|
+
|
|
27176
|
+
// Revert added connections (remove them)
|
|
27177
|
+
if (gatewayInfo.connections.added && Array.isArray(gatewayInfo.connections.added)) {
|
|
27178
|
+
console.log('๐ Removing added connections:', gatewayInfo.connections.added);
|
|
27179
|
+
this.currentSceneData.connections = currentConnections.filter(function (connection) {
|
|
27180
|
+
var shouldRemove = gatewayInfo.connections.added.some(function (addedConn) {
|
|
27181
|
+
return addedConn.from === connection.from && addedConn.to === connection.to || addedConn.from === connection.to && addedConn.to === connection.from;
|
|
27182
|
+
});
|
|
27183
|
+
if (shouldRemove) {
|
|
27184
|
+
console.log("\uD83D\uDD04 Removed connection: ".concat(connection.from, " \u2192 ").concat(connection.to));
|
|
27185
|
+
}
|
|
27186
|
+
return !shouldRemove;
|
|
27187
|
+
});
|
|
27188
|
+
}
|
|
27189
|
+
console.log('โ
Gateway connections reverted. Total connections:', this.currentSceneData.connections.length);
|
|
27190
|
+
}
|
|
27191
|
+
console.log('Executing pathfinding to regenerate gateway:', gatewayInfo.uuid);
|
|
27192
|
+
|
|
27193
|
+
// Remove the gateway from scene data so it can be regenerated
|
|
27194
|
+
this.currentSceneData.scene.object.children = this.currentSceneData.scene.object.children.filter(function (child) {
|
|
27195
|
+
return child.uuid !== gatewayInfo.uuid;
|
|
27196
|
+
});
|
|
27197
|
+
console.log('๐๏ธ Removed gateway from scene data for regeneration', this.currentSceneData);
|
|
27198
|
+
|
|
27199
|
+
// Recalculate bounding boxes
|
|
27200
|
+
this.recomputeWorldBoundingBoxes(this.currentSceneData);
|
|
27201
|
+
|
|
27202
|
+
// Execute pathfinding with updated scene data
|
|
27203
|
+
this.pathfindingManager.updatePathfindingAfterTransform(this.currentSceneData).then(function () {
|
|
27204
|
+
console.log('โ
Pathfinding completed - gateway regenerated automatically');
|
|
27205
|
+
}).catch(function (error) {
|
|
27206
|
+
console.error('โ Error during pathfinding execution:', error);
|
|
27207
|
+
});
|
|
27208
|
+
}
|
|
27209
|
+
|
|
27210
|
+
/**
|
|
27211
|
+
* Check if object is selectable for transformation
|
|
27212
|
+
*/
|
|
27213
|
+
}, {
|
|
27214
|
+
key: "isSelectableObject",
|
|
27215
|
+
value: function isSelectableObject(object) {
|
|
27216
|
+
var _object$userData, _object$userData2;
|
|
27217
|
+
if (object.type == "TransformControlsPlane") {
|
|
27218
|
+
object = object.object;
|
|
27219
|
+
}
|
|
27220
|
+
|
|
27221
|
+
// Allow pipe segments and junctions to be selected
|
|
27222
|
+
var isPipeSegment = ((_object$userData = object.userData) === null || _object$userData === void 0 ? void 0 : _object$userData.isPipeSegment) === true;
|
|
27223
|
+
var isPipeJunction = ((_object$userData2 = object.userData) === null || _object$userData2 === void 0 ? void 0 : _object$userData2.isPipeJunction) === true;
|
|
27224
|
+
if (isPipeSegment) {
|
|
27225
|
+
return true;
|
|
27226
|
+
}
|
|
27227
|
+
|
|
27228
|
+
// Exclude regular polyline parent objects (pipe paths) from selection
|
|
27229
|
+
if (object.name && object.name.toLowerCase().includes("polyline") && !isPipeSegment && !isPipeJunction) {
|
|
27230
|
+
return false;
|
|
27231
|
+
}
|
|
27232
|
+
|
|
27233
|
+
// Check for different component types using userData.componentType
|
|
27234
|
+
var isGLBModel = object.userData && object.userData.componentType === 'component';
|
|
27235
|
+
var isConnector = object.userData && object.userData.componentType === 'connector';
|
|
27236
|
+
var isGateway = object.userData && object.userData.componentType === 'gateway';
|
|
27237
|
+
var canTransform = (object.isMesh || object.isObject3D) && (isGLBModel || isConnector || isGateway) && object.visible;
|
|
27238
|
+
return canTransform;
|
|
27239
|
+
}
|
|
27240
|
+
|
|
27241
|
+
/**
|
|
27242
|
+
* Select object for transformation
|
|
27243
|
+
*/
|
|
27244
|
+
}, {
|
|
27245
|
+
key: "selectObjectForTransform",
|
|
27246
|
+
value: function selectObjectForTransform(object) {
|
|
27247
|
+
// Safety check: ensure object is valid before selecting
|
|
27248
|
+
if (!object || !object.parent) {
|
|
27249
|
+
console.warn('โ ๏ธ Cannot select invalid object for transform');
|
|
27250
|
+
return;
|
|
27251
|
+
}
|
|
27252
|
+
if (this.transformManager) {
|
|
27253
|
+
this.transformManager.selectObject(object);
|
|
27254
|
+
}
|
|
27255
|
+
}
|
|
27256
|
+
|
|
27257
|
+
/**
|
|
27258
|
+
* Deselect currently selected object
|
|
27259
|
+
*/
|
|
27260
|
+
}, {
|
|
27261
|
+
key: "deselectObject",
|
|
27262
|
+
value: function deselectObject() {
|
|
27263
|
+
if (this.transformManager) {
|
|
27264
|
+
this.transformManager.deselectObject();
|
|
27265
|
+
}
|
|
27266
|
+
this.selectedObjectForTransform = null;
|
|
27267
|
+
}
|
|
27268
|
+
|
|
27269
|
+
/**
|
|
27270
|
+
* Public API method to select an object in the scene
|
|
27271
|
+
*/
|
|
27272
|
+
}, {
|
|
27273
|
+
key: "selectObject",
|
|
27274
|
+
value: function selectObject(object) {
|
|
27275
|
+
if (!object || !object.uuid) {
|
|
27276
|
+
console.warn('โ ๏ธ Cannot select invalid object');
|
|
27277
|
+
return false;
|
|
27278
|
+
}
|
|
27279
|
+
|
|
27280
|
+
// Select the object for transformation
|
|
27281
|
+
this.selectObjectForTransform(object);
|
|
27282
|
+
|
|
27283
|
+
// Emit event
|
|
27284
|
+
this.emit('object-selected-for-transform', object);
|
|
27285
|
+
return true;
|
|
27286
|
+
}
|
|
27287
|
+
|
|
27288
|
+
/**
|
|
27289
|
+
* Get currently selected object transform data
|
|
27290
|
+
*/
|
|
27291
|
+
}, {
|
|
27292
|
+
key: "getSelectedTransform",
|
|
27293
|
+
value: function getSelectedTransform() {
|
|
27294
|
+
var _this$transformManage;
|
|
27295
|
+
return ((_this$transformManage = this.transformManager) === null || _this$transformManage === void 0 ? void 0 : _this$transformManage.getTransformData()) || null;
|
|
27296
|
+
}
|
|
27297
|
+
|
|
27298
|
+
/**
|
|
27299
|
+
* Component management methods
|
|
27300
|
+
*/
|
|
27301
|
+
}, {
|
|
27302
|
+
key: "addComponentToScene",
|
|
27303
|
+
value: (function () {
|
|
27304
|
+
var _addComponentToScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(componentData) {
|
|
27305
|
+
var result, _t2;
|
|
27306
|
+
return _regenerator().w(function (_context7) {
|
|
27307
|
+
while (1) switch (_context7.n) {
|
|
27308
|
+
case 0:
|
|
27309
|
+
if (!this.componentManager) {
|
|
27310
|
+
_context7.n = 2;
|
|
27311
|
+
break;
|
|
27312
|
+
}
|
|
27313
|
+
_context7.n = 1;
|
|
27314
|
+
return this.componentManager.addComponentToScene(componentData);
|
|
27315
|
+
case 1:
|
|
27316
|
+
_t2 = _context7.v;
|
|
27317
|
+
_context7.n = 3;
|
|
27318
|
+
break;
|
|
27319
|
+
case 2:
|
|
27320
|
+
_t2 = false;
|
|
27321
|
+
case 3:
|
|
27322
|
+
result = _t2;
|
|
27323
|
+
if (result) {
|
|
27324
|
+
this.emit('scene-changed', {
|
|
27325
|
+
action: 'add',
|
|
27326
|
+
data: componentData
|
|
27327
|
+
});
|
|
27328
|
+
}
|
|
27329
|
+
return _context7.a(2, result);
|
|
27330
|
+
}
|
|
27331
|
+
}, _callee7, this);
|
|
27332
|
+
}));
|
|
27333
|
+
function addComponentToScene(_x4) {
|
|
27334
|
+
return _addComponentToScene.apply(this, arguments);
|
|
27335
|
+
}
|
|
27336
|
+
return addComponentToScene;
|
|
27337
|
+
}())
|
|
27338
|
+
}, {
|
|
27339
|
+
key: "removeComponentFromScene",
|
|
27340
|
+
value: function removeComponentFromScene(componentUuid) {
|
|
27341
|
+
var result = this.componentManager ? this.componentManager.removeComponentFromScene(componentUuid) : false;
|
|
27342
|
+
if (result) {
|
|
27343
|
+
this.emit('scene-changed', {
|
|
27344
|
+
action: 'remove',
|
|
27345
|
+
uuid: componentUuid
|
|
27346
|
+
});
|
|
27347
|
+
}
|
|
27348
|
+
return result;
|
|
27349
|
+
}
|
|
27350
|
+
}, {
|
|
27351
|
+
key: "getSceneComponents",
|
|
27352
|
+
value: function getSceneComponents() {
|
|
27353
|
+
return this.componentManager ? this.componentManager.getSceneComponents() : [];
|
|
27354
|
+
}
|
|
27355
|
+
}, {
|
|
27356
|
+
key: "updateComponent",
|
|
27357
|
+
value: function updateComponent(componentUuid, updates) {
|
|
27358
|
+
return this.componentManager ? this.componentManager.updateComponent(componentUuid, updates) : false;
|
|
27359
|
+
}
|
|
27360
|
+
|
|
27361
|
+
/**
|
|
27362
|
+
* Export scene data
|
|
27363
|
+
*/
|
|
27364
|
+
}, {
|
|
27365
|
+
key: "exportSceneData",
|
|
27366
|
+
value: function exportSceneData() {
|
|
27367
|
+
return this.sceneExportManager ? this.sceneExportManager.exportSceneData() : null;
|
|
27368
|
+
}
|
|
27369
|
+
}, {
|
|
27370
|
+
key: "downloadSceneExport",
|
|
27371
|
+
value: function downloadSceneExport() {
|
|
27372
|
+
var filename = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
|
|
27373
|
+
return this.sceneExportManager ? this.sceneExportManager.downloadSceneExport(filename) : false;
|
|
27374
|
+
}
|
|
27375
|
+
|
|
27376
|
+
/**
|
|
27377
|
+
* Tooltip management methods
|
|
27378
|
+
*/
|
|
27379
|
+
}, {
|
|
27380
|
+
key: "updateTooltipForObject",
|
|
27381
|
+
value: function updateTooltipForObject(object, cornerPosition) {
|
|
27382
|
+
if (this.tooltipsManager && object) {
|
|
27383
|
+
// If no specific corner position provided, determine the best one
|
|
27384
|
+
if (!cornerPosition) {
|
|
27385
|
+
cornerPosition = this.determineTooltipPosition(object);
|
|
27386
|
+
}
|
|
27387
|
+
|
|
27388
|
+
// Update the tooltip for the specified object with the corner position
|
|
27389
|
+
this.tooltipsManager.setSelectedMesh(object, cornerPosition);
|
|
27390
|
+
}
|
|
27391
|
+
}
|
|
27392
|
+
}, {
|
|
27393
|
+
key: "clearAllTooltips",
|
|
27394
|
+
value: function clearAllTooltips() {
|
|
27395
|
+
if (this.tooltipsManager) {
|
|
27396
|
+
this.tooltipsManager.clearTooltip();
|
|
27397
|
+
}
|
|
27398
|
+
}
|
|
27399
|
+
|
|
27400
|
+
/**
|
|
27401
|
+
* Helper method to determine the best tooltip position based on the object's position in the scene
|
|
27402
|
+
*/
|
|
27403
|
+
}, {
|
|
27404
|
+
key: "determineTooltipPosition",
|
|
27405
|
+
value: function determineTooltipPosition(object) {
|
|
27406
|
+
if (!object || !this.camera || !this.scene) {
|
|
27407
|
+
return 'top-right'; // Default position
|
|
27408
|
+
}
|
|
27409
|
+
|
|
27410
|
+
// Get the object's world position
|
|
27411
|
+
var objPosition = new THREE__namespace.Vector3();
|
|
27412
|
+
object.getWorldPosition(objPosition);
|
|
27413
|
+
|
|
27414
|
+
// Project the object's position to screen space
|
|
27415
|
+
var screenPosition = objPosition.clone();
|
|
27416
|
+
screenPosition.project(this.camera);
|
|
27417
|
+
|
|
27418
|
+
// Convert to normalized device coordinates (-1 to +1)
|
|
27419
|
+
var x = screenPosition.x;
|
|
27420
|
+
var y = screenPosition.y;
|
|
27421
|
+
|
|
27422
|
+
// Determine the best position based on the screen quadrant
|
|
27423
|
+
if (x > 0 && y > 0) {
|
|
27424
|
+
// Top-right quadrant - place tooltip at top-left
|
|
27425
|
+
return 'top-left';
|
|
27426
|
+
} else if (x <= 0 && y > 0) {
|
|
27427
|
+
// Top-left quadrant - place tooltip at top-right
|
|
27428
|
+
return 'top-right';
|
|
27429
|
+
} else if (x > 0 && y <= 0) {
|
|
27430
|
+
// Bottom-right quadrant - place tooltip at top-left
|
|
27431
|
+
return 'top-left';
|
|
27432
|
+
} else {
|
|
27433
|
+
// Bottom-left quadrant - place tooltip at top-right
|
|
27434
|
+
return 'top-right';
|
|
27435
|
+
}
|
|
27436
|
+
}
|
|
27437
|
+
|
|
27438
|
+
/**
|
|
27439
|
+
* Helper method to get the checkUnderground setting from localStorage
|
|
27440
|
+
*/
|
|
27441
|
+
}, {
|
|
27442
|
+
key: "getCheckUndergroundSetting",
|
|
27443
|
+
value: function getCheckUndergroundSetting() {
|
|
27444
|
+
try {
|
|
27445
|
+
if (typeof window !== 'undefined' && window.localStorage) {
|
|
27446
|
+
var savedSettings = localStorage.getItem('sceneConfigurations');
|
|
27447
|
+
if (savedSettings) {
|
|
27448
|
+
var parsed = JSON.parse(savedSettings);
|
|
27449
|
+
// Default to true if not explicitly set to false
|
|
27450
|
+
return parsed.checkUnderground !== false;
|
|
27451
|
+
}
|
|
27452
|
+
}
|
|
27453
|
+
} catch (error) {
|
|
27454
|
+
console.warn('โ ๏ธ Error reading checkUnderground setting from localStorage:', error);
|
|
27455
|
+
}
|
|
27456
|
+
|
|
27457
|
+
// Default to true if localStorage is not available or has errors
|
|
27458
|
+
return true;
|
|
27459
|
+
}
|
|
27460
|
+
|
|
27461
|
+
/**
|
|
27462
|
+
* Toggle shouldUpdatePaths setting
|
|
27463
|
+
*/
|
|
27464
|
+
}, {
|
|
27465
|
+
key: "toggleshouldUpdatePaths",
|
|
27466
|
+
value: function toggleshouldUpdatePaths() {
|
|
27467
|
+
this.shouldUpdatePaths = !this.shouldUpdatePaths;
|
|
27468
|
+
console.log("\uD83D\uDD04 shouldUpdatePaths ".concat(this.shouldUpdatePaths ? 'enabled' : 'disabled'));
|
|
27469
|
+
|
|
27470
|
+
// Also log current state for clarity
|
|
27471
|
+
if (this.shouldUpdatePaths) {
|
|
27472
|
+
console.log('โ
Path recalculation will occur after component transforms');
|
|
27473
|
+
this.updatePaths();
|
|
27474
|
+
} else {
|
|
27475
|
+
console.log('โ ๏ธ Path recalculation disabled - manual scene reload may be needed');
|
|
27476
|
+
}
|
|
27477
|
+
return this.shouldUpdatePaths;
|
|
27478
|
+
}
|
|
27479
|
+
|
|
27480
|
+
/**
|
|
27481
|
+
* Transform controls management
|
|
27482
|
+
*/
|
|
27483
|
+
}, {
|
|
27484
|
+
key: "disableTransformControls",
|
|
27485
|
+
value: function disableTransformControls() {
|
|
27486
|
+
console.log('๐ง Manually disabling transform controls');
|
|
27487
|
+
if (!this.transformManager) {
|
|
27488
|
+
console.warn('โ ๏ธ No transform manager found to disable');
|
|
27489
|
+
return false;
|
|
27490
|
+
}
|
|
27491
|
+
|
|
27492
|
+
// Deselect any selected object
|
|
27493
|
+
if (this.transformManager.selectedObject) {
|
|
27494
|
+
this.transformManager.deselectObject();
|
|
27495
|
+
}
|
|
27496
|
+
|
|
27497
|
+
// Disable controls and set visibility to false
|
|
27498
|
+
if (this.transformManager.transformControls) {
|
|
27499
|
+
this.transformManager.setEnabled(false);
|
|
27500
|
+
this.transformManager.transformControls.visible = false;
|
|
27501
|
+
console.log('โ
Transform controls disabled');
|
|
27502
|
+
return true;
|
|
27503
|
+
}
|
|
27504
|
+
console.warn('โ ๏ธ Transform controls not found in manager');
|
|
27505
|
+
return false;
|
|
27506
|
+
}
|
|
27507
|
+
}, {
|
|
27508
|
+
key: "enableTransformControls",
|
|
27509
|
+
value: function enableTransformControls() {
|
|
27510
|
+
console.log('๐ง Manually enabling transform controls');
|
|
27511
|
+
if (!this.transformManager) {
|
|
27512
|
+
console.warn('โ ๏ธ No transform manager found to enable');
|
|
27513
|
+
return false;
|
|
27514
|
+
}
|
|
27515
|
+
|
|
27516
|
+
// Check if we should enable transform controls
|
|
27517
|
+
// Only enable if we have actual objects in the scene (not an empty scene)
|
|
27518
|
+
var hasNonBaseObjects = false;
|
|
27519
|
+
this.scene.traverse(function (child) {
|
|
27520
|
+
var _child$userData, _child$userData2, _child$userData3, _child$geometry;
|
|
27521
|
+
if (child.isMesh && !((_child$userData = child.userData) !== null && _child$userData !== void 0 && _child$userData.isBaseGround) && !((_child$userData2 = child.userData) !== null && _child$userData2 !== void 0 && _child$userData2.isBrickWall) && !((_child$userData3 = child.userData) !== null && _child$userData3 !== void 0 && _child$userData3.isBaseGrid) && ((_child$geometry = child.geometry) === null || _child$geometry === void 0 ? void 0 : _child$geometry.type) !== 'PlaneGeometry') {
|
|
27522
|
+
hasNonBaseObjects = true;
|
|
27523
|
+
}
|
|
27524
|
+
});
|
|
27525
|
+
|
|
27526
|
+
// Don't enable controls for empty scenes
|
|
27527
|
+
if (!hasNonBaseObjects) {
|
|
27528
|
+
console.log('๐ง No objects to transform in scene, keeping transform controls disabled');
|
|
27529
|
+
return false;
|
|
27530
|
+
}
|
|
27531
|
+
|
|
27532
|
+
// Enable controls and set visibility to true
|
|
27533
|
+
if (this.transformManager.transformControls) {
|
|
27534
|
+
// Reset the force invisible flag to allow controls to become visible
|
|
27535
|
+
this.transformManager.forceInvisible = false;
|
|
27536
|
+
this.transformManager.setEnabled(true);
|
|
27537
|
+
this.transformManager.transformControls.visible = true;
|
|
27538
|
+
console.log('โ
Transform controls enabled');
|
|
27539
|
+
return true;
|
|
27540
|
+
}
|
|
27541
|
+
console.warn('โ ๏ธ Transform controls not found in manager');
|
|
27542
|
+
return false;
|
|
27543
|
+
}
|
|
27544
|
+
}, {
|
|
27545
|
+
key: "keepTransformControlsInactive",
|
|
27546
|
+
value: function keepTransformControlsInactive() {
|
|
27547
|
+
if (this.transformManager && this.transformManager.transformControls) {
|
|
27548
|
+
console.log('๐ Ensuring transform controls remain inactive after scene load');
|
|
27549
|
+
this.transformManager.setEnabled(false);
|
|
27550
|
+
this.transformManager.transformControls.visible = false;
|
|
27551
|
+
|
|
27552
|
+
// Set force invisible flag to prevent any selection from making controls visible
|
|
27553
|
+
this.transformManager.forceInvisible = true;
|
|
27554
|
+
|
|
27555
|
+
// Deselect any selected object to ensure clean state
|
|
27556
|
+
if (this.transformManager.selectedObject) {
|
|
27557
|
+
this.transformManager.deselectObject();
|
|
27558
|
+
}
|
|
27559
|
+
}
|
|
27560
|
+
}
|
|
27561
|
+
}, {
|
|
27562
|
+
key: "setMultiAxisTranslation",
|
|
27563
|
+
value: function setMultiAxisTranslation(enabled) {
|
|
27564
|
+
if (!this.transformManager) {
|
|
27565
|
+
console.warn('โ ๏ธ No transform manager found');
|
|
27566
|
+
return false;
|
|
27567
|
+
}
|
|
27568
|
+
return this.transformManager.setShowPlanes(enabled);
|
|
27569
|
+
}
|
|
27570
|
+
}, {
|
|
27571
|
+
key: "ensureTransformControlsAttached",
|
|
27572
|
+
value: function ensureTransformControlsAttached() {
|
|
27573
|
+
var allowVisible = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
27574
|
+
// Check if transform manager exists
|
|
27575
|
+
if (!this.transformManager) {
|
|
27576
|
+
console.log('๐ง No transform manager found, initializing transform controls...');
|
|
27577
|
+
this.initTransformControls();
|
|
27578
|
+
return;
|
|
27579
|
+
}
|
|
27580
|
+
|
|
27581
|
+
// Check if transform controls exist in the manager
|
|
27582
|
+
if (!this.transformManager.transformControls) {
|
|
27583
|
+
console.log('๐ง Transform controls not found in manager, reinitializing...');
|
|
27584
|
+
this.transformManager.createTransformControls();
|
|
27585
|
+
this.transformManager.setupEventListeners();
|
|
27586
|
+
console.log('โ
Transform controls recreated in manager');
|
|
27587
|
+
return;
|
|
27588
|
+
}
|
|
27589
|
+
|
|
27590
|
+
// Use the TransformControlsManager's built-in method for reattachment
|
|
27591
|
+
var wasReattached = this.transformManager.ensureSceneAttachment(allowVisible);
|
|
27592
|
+
if (wasReattached) {
|
|
27593
|
+
console.log('๐ง Transform controls were reattached after scene operation');
|
|
27594
|
+
|
|
27595
|
+
// Override visibility based on allowVisible parameter
|
|
27596
|
+
if (!allowVisible && this.transformManager.transformControls) {
|
|
27597
|
+
this.transformManager.transformControls.visible = false;
|
|
27598
|
+
console.log('๐ง Forcing transform controls to be invisible during load');
|
|
27599
|
+
}
|
|
27600
|
+
} else {
|
|
27601
|
+
console.log('โ Transform controls are properly attached');
|
|
27602
|
+
|
|
27603
|
+
// Still ensure visibility is set correctly even if not reattached
|
|
27604
|
+
if (!allowVisible && this.transformManager.transformControls) {
|
|
27605
|
+
this.transformManager.transformControls.visible = false;
|
|
27606
|
+
console.log('๐ง Ensuring transform controls remain invisible during load');
|
|
27607
|
+
}
|
|
27608
|
+
}
|
|
27609
|
+
}
|
|
27610
|
+
|
|
27611
|
+
/**
|
|
27612
|
+
* Clean up transform controls
|
|
27613
|
+
*/
|
|
27614
|
+
}, {
|
|
27615
|
+
key: "cleanupTransformControls",
|
|
27616
|
+
value: function cleanupTransformControls() {
|
|
27617
|
+
console.log('๐งน Cleaning up transform controls...');
|
|
27618
|
+
if (this.transformManager) {
|
|
27619
|
+
// First deselect any object
|
|
27620
|
+
if (this.transformManager.selectedObject) {
|
|
27621
|
+
this.transformManager.deselectObject();
|
|
27622
|
+
}
|
|
27623
|
+
|
|
27624
|
+
// Explicitly disable transform controls
|
|
27625
|
+
if (this.transformManager.transformControls) {
|
|
27626
|
+
console.log('๐ง Disabling transform controls before disposal');
|
|
27627
|
+
this.transformManager.setEnabled(false);
|
|
27628
|
+
this.transformManager.transformControls.visible = false;
|
|
27629
|
+
}
|
|
27630
|
+
|
|
27631
|
+
// Now dispose of the transform controls
|
|
27632
|
+
this.transformManager.dispose();
|
|
27633
|
+
this.transformManager = null;
|
|
27634
|
+
}
|
|
27635
|
+
this.selectedObjectForTransform = null;
|
|
27636
|
+
this.transformHistory = [];
|
|
27637
|
+
console.log('โ
Transform controls cleanup completed');
|
|
27638
|
+
}
|
|
27639
|
+
|
|
27640
|
+
/**
|
|
27641
|
+
* Manual cleanup method that can be called externally
|
|
27642
|
+
*/
|
|
27643
|
+
}, {
|
|
27644
|
+
key: "destroy",
|
|
27645
|
+
value: function destroy() {
|
|
27646
|
+
console.log('๐ง Manual cleanup requested');
|
|
27647
|
+
this.dispose();
|
|
27648
|
+
}
|
|
27649
|
+
|
|
27650
|
+
/**
|
|
27651
|
+
* Utility method to check if scene is properly disposed
|
|
27652
|
+
*/
|
|
27653
|
+
}, {
|
|
27654
|
+
key: "isDisposed",
|
|
27655
|
+
value: function isDisposed() {
|
|
27656
|
+
return this.isDestroyed || !this.scene || !this.renderer || !this.camera;
|
|
27657
|
+
}
|
|
27658
|
+
|
|
27659
|
+
/**
|
|
27660
|
+
* Comprehensive cleanup and disposal
|
|
27661
|
+
*/
|
|
27662
|
+
}, {
|
|
27663
|
+
key: "dispose",
|
|
27664
|
+
value: function dispose() {
|
|
27665
|
+
console.log('Starting comprehensive scene cleanup...');
|
|
27666
|
+
|
|
27667
|
+
// Stop animation loop by setting a flag
|
|
27668
|
+
this.isDestroyed = true;
|
|
27669
|
+
try {
|
|
27670
|
+
// Use disposal manager for comprehensive cleanup
|
|
27671
|
+
if (this.disposalManager) {
|
|
27672
|
+
try {
|
|
27673
|
+
this.disposalManager.cleanupEventListeners();
|
|
27674
|
+
this.disposalManager.cleanupControls();
|
|
27675
|
+
this.disposalManager.cleanupGlobalReferences();
|
|
27676
|
+
} catch (e) {
|
|
27677
|
+
console.error('Error during disposal manager cleanup:', e);
|
|
27678
|
+
}
|
|
27679
|
+
}
|
|
27680
|
+
|
|
27681
|
+
// Clean up transform controls
|
|
27682
|
+
try {
|
|
27683
|
+
this.cleanupTransformControls();
|
|
27684
|
+
} catch (e) {
|
|
27685
|
+
console.error('Error cleaning up transform controls:', e);
|
|
27686
|
+
}
|
|
27687
|
+
|
|
27688
|
+
// Clean up tooltip manager
|
|
27689
|
+
if (this.tooltipsManager) {
|
|
27690
|
+
try {
|
|
27691
|
+
console.log('Disposing tooltip manager...');
|
|
27692
|
+
this.tooltipsManager.dispose();
|
|
27693
|
+
} catch (e) {
|
|
27694
|
+
console.error('Error disposing tooltip manager:', e);
|
|
27695
|
+
} finally {
|
|
27696
|
+
// Ensure reference is always nullified even if disposal fails
|
|
27697
|
+
this.tooltipsManager = null;
|
|
27698
|
+
}
|
|
27699
|
+
}
|
|
27700
|
+
|
|
27701
|
+
// Dispose of scene objects and materials
|
|
27702
|
+
if (this.disposalManager) {
|
|
27703
|
+
try {
|
|
27704
|
+
this.disposalManager.cleanupScene();
|
|
27705
|
+
this.disposalManager.cleanupRenderer();
|
|
27706
|
+
} catch (e) {
|
|
27707
|
+
console.error('Error during scene and renderer cleanup:', e);
|
|
27708
|
+
} finally {
|
|
27709
|
+
this.disposalManager = null;
|
|
27710
|
+
}
|
|
27711
|
+
}
|
|
27712
|
+
console.log('Scene cleanup completed');
|
|
27713
|
+
} catch (e) {
|
|
27714
|
+
console.error('Unexpected error during scene cleanup:', e);
|
|
27715
|
+
}
|
|
27716
|
+
}
|
|
27717
|
+
}]);
|
|
27718
|
+
}();
|
|
27719
|
+
|
|
26488
27720
|
var _MathUtils;
|
|
26489
27721
|
/**
|
|
26490
27722
|
* MathUtils
|
|
@@ -36941,6 +38173,7 @@ exports.SceneInitializationManager = SceneInitializationManager;
|
|
|
36941
38173
|
exports.SceneOperationsManager = SceneOperationsManager;
|
|
36942
38174
|
exports.SceneTooltipsManager = SceneTooltipsManager;
|
|
36943
38175
|
exports.SceneViewer = SceneViewer;
|
|
38176
|
+
exports.SceneViewerEnhanced = SceneViewerEnhanced;
|
|
36944
38177
|
exports.Testing = testing;
|
|
36945
38178
|
exports.createTransformControls = createTransformControls;
|
|
36946
38179
|
exports.findObjectByHardcodedUuid = findObjectByHardcodedUuid;
|