@2112-lab/central-plant 0.1.62 → 0.1.64
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 +932 -381
- package/dist/cjs/src/core/centralPlant.js +290 -147
- package/dist/cjs/src/managers/components/componentDataManager.js +283 -74
- package/dist/cjs/src/managers/controls/componentDragManager.js +259 -120
- package/dist/cjs/src/managers/controls/keyboardControlsManager.js +3 -0
- package/dist/cjs/src/rendering/modelPreloader.js +93 -36
- package/dist/esm/src/core/centralPlant.js +291 -148
- package/dist/esm/src/managers/components/componentDataManager.js +284 -75
- package/dist/esm/src/managers/controls/componentDragManager.js +260 -121
- package/dist/esm/src/managers/controls/keyboardControlsManager.js +3 -0
- package/dist/esm/src/rendering/modelPreloader.js +93 -36
- package/package.json +1 -1
package/dist/bundle/index.js
CHANGED
|
@@ -17751,6 +17751,7 @@ var ModelPreloader = /*#__PURE__*/function () {
|
|
|
17751
17751
|
this.preloadingPromise = null;
|
|
17752
17752
|
this.componentDictionary = null;
|
|
17753
17753
|
this.modelsBasePath = '/library/models/'; // Default local path
|
|
17754
|
+
this.urlResolver = null; // Optional function to resolve model URLs (for S3 authentication)
|
|
17754
17755
|
|
|
17755
17756
|
console.log('🚀 ModelPreloader initialized with GLB support');
|
|
17756
17757
|
}
|
|
@@ -17773,6 +17774,27 @@ var ModelPreloader = /*#__PURE__*/function () {
|
|
|
17773
17774
|
console.log("\uD83D\uDCC2 Models base path set to: ".concat(this.modelsBasePath));
|
|
17774
17775
|
}
|
|
17775
17776
|
|
|
17777
|
+
/**
|
|
17778
|
+
* Set a URL resolver function for model loading
|
|
17779
|
+
* @param {Function} resolverFn - Function that takes modelKey and returns Promise<string> URL
|
|
17780
|
+
* @example
|
|
17781
|
+
* // Sandbox can provide S3 signed URL resolver
|
|
17782
|
+
* modelPreloader.setUrlResolver(async (modelKey) => {
|
|
17783
|
+
* const url = await Storage.get(`models/${modelKey}`)
|
|
17784
|
+
* return url
|
|
17785
|
+
* })
|
|
17786
|
+
*/
|
|
17787
|
+
}, {
|
|
17788
|
+
key: "setUrlResolver",
|
|
17789
|
+
value: function setUrlResolver(resolverFn) {
|
|
17790
|
+
if (typeof resolverFn !== 'function') {
|
|
17791
|
+
console.warn('⚠️ urlResolver must be a function');
|
|
17792
|
+
return;
|
|
17793
|
+
}
|
|
17794
|
+
this.urlResolver = resolverFn;
|
|
17795
|
+
console.log('🔗 URL resolver set for model loading');
|
|
17796
|
+
}
|
|
17797
|
+
|
|
17776
17798
|
/**
|
|
17777
17799
|
* Preload all models from the component dictionary
|
|
17778
17800
|
* @param {Object} componentDictionary - The component dictionary object
|
|
@@ -17881,59 +17903,94 @@ var ModelPreloader = /*#__PURE__*/function () {
|
|
|
17881
17903
|
}, {
|
|
17882
17904
|
key: "preloadSingleModel",
|
|
17883
17905
|
value: (function () {
|
|
17884
|
-
var _preloadSingleModel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
17906
|
+
var _preloadSingleModel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(modelKey) {
|
|
17885
17907
|
var _this2 = this;
|
|
17886
17908
|
var loadPromise;
|
|
17887
|
-
return _regenerator().w(function (
|
|
17888
|
-
while (1) switch (
|
|
17909
|
+
return _regenerator().w(function (_context3) {
|
|
17910
|
+
while (1) switch (_context3.n) {
|
|
17889
17911
|
case 0:
|
|
17890
17912
|
if (!this.modelCache.has(modelKey)) {
|
|
17891
|
-
|
|
17913
|
+
_context3.n = 1;
|
|
17892
17914
|
break;
|
|
17893
17915
|
}
|
|
17894
17916
|
console.log("\uD83C\uDFAF Model ".concat(modelKey, " already cached, skipping"));
|
|
17895
|
-
return
|
|
17917
|
+
return _context3.a(2, this.modelCache.get(modelKey));
|
|
17896
17918
|
case 1:
|
|
17897
17919
|
if (!this.loadingPromises.has(modelKey)) {
|
|
17898
|
-
|
|
17920
|
+
_context3.n = 2;
|
|
17899
17921
|
break;
|
|
17900
17922
|
}
|
|
17901
17923
|
console.log("\u23F3 Model ".concat(modelKey, " already loading, waiting for completion"));
|
|
17902
|
-
return
|
|
17924
|
+
return _context3.a(2, this.loadingPromises.get(modelKey));
|
|
17903
17925
|
case 2:
|
|
17904
17926
|
console.log("\uD83D\uDD04 Starting preload of GLB model: ".concat(modelKey));
|
|
17905
|
-
loadPromise = new Promise(function (
|
|
17906
|
-
var
|
|
17907
|
-
|
|
17908
|
-
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17913
|
-
|
|
17914
|
-
|
|
17915
|
-
|
|
17916
|
-
|
|
17917
|
-
|
|
17918
|
-
|
|
17919
|
-
|
|
17920
|
-
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17927
|
+
loadPromise = new Promise(/*#__PURE__*/function () {
|
|
17928
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(resolve, reject) {
|
|
17929
|
+
var modelPath, _t;
|
|
17930
|
+
return _regenerator().w(function (_context2) {
|
|
17931
|
+
while (1) switch (_context2.n) {
|
|
17932
|
+
case 0:
|
|
17933
|
+
if (!_this2.urlResolver) {
|
|
17934
|
+
_context2.n = 5;
|
|
17935
|
+
break;
|
|
17936
|
+
}
|
|
17937
|
+
_context2.p = 1;
|
|
17938
|
+
_context2.n = 2;
|
|
17939
|
+
return _this2.urlResolver(modelKey);
|
|
17940
|
+
case 2:
|
|
17941
|
+
modelPath = _context2.v;
|
|
17942
|
+
console.log("\uD83D\uDD17 Resolved URL for ".concat(modelKey, ":"), modelPath.substring(0, 100) + '...');
|
|
17943
|
+
_context2.n = 4;
|
|
17944
|
+
break;
|
|
17945
|
+
case 3:
|
|
17946
|
+
_context2.p = 3;
|
|
17947
|
+
_t = _context2.v;
|
|
17948
|
+
console.error("\u274C Failed to resolve URL for ".concat(modelKey, ":"), _t);
|
|
17949
|
+
reject(_t);
|
|
17950
|
+
return _context2.a(2);
|
|
17951
|
+
case 4:
|
|
17952
|
+
_context2.n = 6;
|
|
17953
|
+
break;
|
|
17954
|
+
case 5:
|
|
17955
|
+
modelPath = "".concat(_this2.modelsBasePath).concat(modelKey);
|
|
17956
|
+
console.log("\uD83D\uDCC2 Loading from: ".concat(modelPath));
|
|
17957
|
+
case 6:
|
|
17958
|
+
// Load GLB model
|
|
17959
|
+
_this2.gltfLoader.load(modelPath, function (gltf) {
|
|
17960
|
+
console.log("\u2705 Successfully preloaded GLB model: ".concat(modelKey));
|
|
17961
|
+
// Cache the scene for future use
|
|
17962
|
+
_this2.modelCache.set(modelKey, gltf.scene);
|
|
17963
|
+
// Remove from loading promises
|
|
17964
|
+
_this2.loadingPromises.delete(modelKey);
|
|
17965
|
+
resolve(gltf.scene);
|
|
17966
|
+
}, function (progress) {
|
|
17967
|
+
// Optional: track loading progress
|
|
17968
|
+
if (progress.lengthComputable) {
|
|
17969
|
+
var percentage = progress.loaded / progress.total * 100;
|
|
17970
|
+
if (percentage % 25 === 0) {
|
|
17971
|
+
// Log every 25%
|
|
17972
|
+
console.log("\uD83D\uDCCA Loading GLB ".concat(modelKey, ": ").concat(percentage.toFixed(0), "%"));
|
|
17973
|
+
}
|
|
17974
|
+
}
|
|
17975
|
+
}, function (error) {
|
|
17976
|
+
console.error("\u274C Failed to preload GLB model ".concat(modelKey, ":"), error);
|
|
17977
|
+
// Remove from loading promises
|
|
17978
|
+
_this2.loadingPromises.delete(modelKey);
|
|
17979
|
+
reject(error);
|
|
17980
|
+
});
|
|
17981
|
+
case 7:
|
|
17982
|
+
return _context2.a(2);
|
|
17924
17983
|
}
|
|
17925
|
-
}
|
|
17926
|
-
}
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
|
|
17931
|
-
});
|
|
17932
|
-
}); // Cache the loading promise
|
|
17984
|
+
}, _callee2, null, [[1, 3]]);
|
|
17985
|
+
}));
|
|
17986
|
+
return function (_x3, _x4) {
|
|
17987
|
+
return _ref.apply(this, arguments);
|
|
17988
|
+
};
|
|
17989
|
+
}()); // Cache the loading promise
|
|
17933
17990
|
this.loadingPromises.set(modelKey, loadPromise);
|
|
17934
|
-
return
|
|
17991
|
+
return _context3.a(2, loadPromise);
|
|
17935
17992
|
}
|
|
17936
|
-
},
|
|
17993
|
+
}, _callee3, this);
|
|
17937
17994
|
}));
|
|
17938
17995
|
function preloadSingleModel(_x2) {
|
|
17939
17996
|
return _preloadSingleModel.apply(this, arguments);
|
|
@@ -18553,6 +18610,7 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
18553
18610
|
_this.lastCacheUpdate = 0;
|
|
18554
18611
|
_this.cacheTimeout = 5000; // 5 seconds cache timeout
|
|
18555
18612
|
_this.componentDictionary = null;
|
|
18613
|
+
_this.dictionaryLoadPromise = null; // Track dictionary loading state
|
|
18556
18614
|
|
|
18557
18615
|
// Register this manager with the sceneViewer if needed
|
|
18558
18616
|
if (_this.sceneViewer && _this.sceneViewer.managers) {
|
|
@@ -18560,66 +18618,145 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
18560
18618
|
}
|
|
18561
18619
|
|
|
18562
18620
|
// Load component dictionary
|
|
18563
|
-
_this._loadComponentDictionary();
|
|
18621
|
+
_this.dictionaryLoadPromise = _this._loadComponentDictionary();
|
|
18564
18622
|
return _this;
|
|
18565
18623
|
}
|
|
18566
18624
|
|
|
18567
18625
|
/**
|
|
18568
|
-
*
|
|
18569
|
-
* @
|
|
18570
|
-
* @param {string|string[]} options.category - Filter by category (single category or array of categories)
|
|
18571
|
-
* @param {string} options.name - Filter by component name (partial match, case-insensitive)
|
|
18572
|
-
* @returns {Array} Array of available component objects from the dictionary with metadata always included
|
|
18626
|
+
* Ensure dictionary is loaded before accessing it
|
|
18627
|
+
* @returns {Promise<boolean>} True if dictionary is loaded, false otherwise
|
|
18573
18628
|
*/
|
|
18574
18629
|
_inherits(ComponentDataManager, _BaseDisposable);
|
|
18575
18630
|
return _createClass(ComponentDataManager, [{
|
|
18576
|
-
key: "
|
|
18577
|
-
value: function
|
|
18578
|
-
var
|
|
18579
|
-
|
|
18580
|
-
|
|
18581
|
-
|
|
18582
|
-
|
|
18583
|
-
|
|
18584
|
-
|
|
18585
|
-
|
|
18586
|
-
|
|
18587
|
-
|
|
18588
|
-
|
|
18589
|
-
|
|
18590
|
-
|
|
18631
|
+
key: "ensureDictionaryLoaded",
|
|
18632
|
+
value: (function () {
|
|
18633
|
+
var _ensureDictionaryLoaded = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
18634
|
+
return _regenerator().w(function (_context) {
|
|
18635
|
+
while (1) switch (_context.n) {
|
|
18636
|
+
case 0:
|
|
18637
|
+
if (!this.componentDictionary) {
|
|
18638
|
+
_context.n = 1;
|
|
18639
|
+
break;
|
|
18640
|
+
}
|
|
18641
|
+
return _context.a(2, true);
|
|
18642
|
+
case 1:
|
|
18643
|
+
if (!this.dictionaryLoadPromise) {
|
|
18644
|
+
_context.n = 3;
|
|
18645
|
+
break;
|
|
18646
|
+
}
|
|
18647
|
+
_context.n = 2;
|
|
18648
|
+
return this.dictionaryLoadPromise;
|
|
18649
|
+
case 2:
|
|
18650
|
+
return _context.a(2, !!this.componentDictionary);
|
|
18651
|
+
case 3:
|
|
18652
|
+
return _context.a(2, false);
|
|
18653
|
+
}
|
|
18654
|
+
}, _callee, this);
|
|
18655
|
+
}));
|
|
18656
|
+
function ensureDictionaryLoaded() {
|
|
18657
|
+
return _ensureDictionaryLoaded.apply(this, arguments);
|
|
18591
18658
|
}
|
|
18592
|
-
|
|
18593
|
-
|
|
18594
|
-
|
|
18595
|
-
|
|
18596
|
-
|
|
18597
|
-
|
|
18598
|
-
|
|
18599
|
-
|
|
18600
|
-
|
|
18601
|
-
|
|
18602
|
-
|
|
18603
|
-
|
|
18604
|
-
|
|
18605
|
-
|
|
18606
|
-
|
|
18607
|
-
|
|
18608
|
-
|
|
18609
|
-
|
|
18610
|
-
|
|
18611
|
-
|
|
18612
|
-
|
|
18613
|
-
|
|
18614
|
-
|
|
18615
|
-
|
|
18659
|
+
return ensureDictionaryLoaded;
|
|
18660
|
+
}()
|
|
18661
|
+
/**
|
|
18662
|
+
* Get available components from the component dictionary
|
|
18663
|
+
* @param {Object} options - Configuration options
|
|
18664
|
+
* @param {string|string[]} options.category - Filter by category (single category or array of categories)
|
|
18665
|
+
* @param {string} options.name - Filter by component name (partial match, case-insensitive)
|
|
18666
|
+
* @returns {Promise<Array>} Array of available component objects from the dictionary with metadata always included
|
|
18667
|
+
*/
|
|
18668
|
+
)
|
|
18669
|
+
}, {
|
|
18670
|
+
key: "getDictionaryComponents",
|
|
18671
|
+
value: (function () {
|
|
18672
|
+
var _getDictionaryComponents = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
18673
|
+
var options,
|
|
18674
|
+
_options$category,
|
|
18675
|
+
category,
|
|
18676
|
+
_options$name,
|
|
18677
|
+
name,
|
|
18678
|
+
enhancedOptions,
|
|
18679
|
+
components,
|
|
18680
|
+
_i,
|
|
18681
|
+
_Object$entries,
|
|
18682
|
+
_Object$entries$_i,
|
|
18683
|
+
key,
|
|
18684
|
+
component,
|
|
18685
|
+
categoriesArray,
|
|
18686
|
+
formattedComponent,
|
|
18687
|
+
nameFilter,
|
|
18688
|
+
_args2 = arguments;
|
|
18689
|
+
return _regenerator().w(function (_context2) {
|
|
18690
|
+
while (1) switch (_context2.n) {
|
|
18691
|
+
case 0:
|
|
18692
|
+
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
18693
|
+
_context2.n = 1;
|
|
18694
|
+
return this.ensureDictionaryLoaded();
|
|
18695
|
+
case 1:
|
|
18696
|
+
_options$category = options.category, category = _options$category === void 0 ? null : _options$category, _options$name = options.name, name = _options$name === void 0 ? null : _options$name; // Always include metadata
|
|
18697
|
+
enhancedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
18698
|
+
includeMetadata: true
|
|
18699
|
+
});
|
|
18700
|
+
if (this.componentDictionary) {
|
|
18701
|
+
_context2.n = 2;
|
|
18702
|
+
break;
|
|
18703
|
+
}
|
|
18704
|
+
console.warn('⚠️ getDictionaryComponents(): Component dictionary not loaded');
|
|
18705
|
+
return _context2.a(2, []);
|
|
18706
|
+
case 2:
|
|
18707
|
+
components = []; // Process each component in the dictionary
|
|
18708
|
+
_i = 0, _Object$entries = Object.entries(this.componentDictionary);
|
|
18709
|
+
case 3:
|
|
18710
|
+
if (!(_i < _Object$entries.length)) {
|
|
18711
|
+
_context2.n = 8;
|
|
18712
|
+
break;
|
|
18713
|
+
}
|
|
18714
|
+
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), key = _Object$entries$_i[0], component = _Object$entries$_i[1];
|
|
18715
|
+
if (!(key === 'categories')) {
|
|
18716
|
+
_context2.n = 4;
|
|
18717
|
+
break;
|
|
18718
|
+
}
|
|
18719
|
+
return _context2.a(3, 7);
|
|
18720
|
+
case 4:
|
|
18721
|
+
if (!category) {
|
|
18722
|
+
_context2.n = 5;
|
|
18723
|
+
break;
|
|
18724
|
+
}
|
|
18725
|
+
categoriesArray = Array.isArray(category) ? category : [category];
|
|
18726
|
+
if (categoriesArray.includes(component.category)) {
|
|
18727
|
+
_context2.n = 5;
|
|
18728
|
+
break;
|
|
18729
|
+
}
|
|
18730
|
+
return _context2.a(3, 7);
|
|
18731
|
+
case 5:
|
|
18732
|
+
// Format the component data
|
|
18733
|
+
formattedComponent = this._formatDictionaryComponent(key, component, enhancedOptions); // Filter by name if specified (partial match, case-insensitive)
|
|
18734
|
+
if (!(name && typeof name === 'string' && name.trim().length > 0)) {
|
|
18735
|
+
_context2.n = 6;
|
|
18736
|
+
break;
|
|
18737
|
+
}
|
|
18738
|
+
nameFilter = name.toLowerCase().trim();
|
|
18739
|
+
if (!(!formattedComponent.name || !formattedComponent.name.toLowerCase().includes(nameFilter))) {
|
|
18740
|
+
_context2.n = 6;
|
|
18741
|
+
break;
|
|
18742
|
+
}
|
|
18743
|
+
return _context2.a(3, 7);
|
|
18744
|
+
case 6:
|
|
18745
|
+
components.push(formattedComponent);
|
|
18746
|
+
case 7:
|
|
18747
|
+
_i++;
|
|
18748
|
+
_context2.n = 3;
|
|
18749
|
+
break;
|
|
18750
|
+
case 8:
|
|
18751
|
+
return _context2.a(2, components);
|
|
18616
18752
|
}
|
|
18617
|
-
}
|
|
18618
|
-
|
|
18753
|
+
}, _callee2, this);
|
|
18754
|
+
}));
|
|
18755
|
+
function getDictionaryComponents() {
|
|
18756
|
+
return _getDictionaryComponents.apply(this, arguments);
|
|
18619
18757
|
}
|
|
18620
|
-
return
|
|
18621
|
-
}
|
|
18622
|
-
|
|
18758
|
+
return getDictionaryComponents;
|
|
18759
|
+
}()
|
|
18623
18760
|
/**
|
|
18624
18761
|
* Get scene hierarchy by directly traversing the scene
|
|
18625
18762
|
* @param {Object} options - Scene hierarchy options
|
|
@@ -18627,6 +18764,7 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
18627
18764
|
* @param {string} options.name - Filter by component name (partial match, case-insensitive)
|
|
18628
18765
|
* @returns {Array} Array of scene component objects with connectors and gateways
|
|
18629
18766
|
*/
|
|
18767
|
+
)
|
|
18630
18768
|
}, {
|
|
18631
18769
|
key: "getSceneHierarchy",
|
|
18632
18770
|
value: function getSceneHierarchy() {
|
|
@@ -18767,9 +18905,133 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
18767
18905
|
}];
|
|
18768
18906
|
}
|
|
18769
18907
|
|
|
18908
|
+
/**
|
|
18909
|
+
* Extend component dictionary with additional components (e.g., from S3)
|
|
18910
|
+
* @param {Object} additionalComponents - Object with component definitions to add
|
|
18911
|
+
* @returns {Promise<boolean>} True if components were added successfully
|
|
18912
|
+
*/
|
|
18913
|
+
}, {
|
|
18914
|
+
key: "extendComponentDictionary",
|
|
18915
|
+
value: (function () {
|
|
18916
|
+
var _extendComponentDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(additionalComponents) {
|
|
18917
|
+
var _this$sceneViewer, addedCount, modelPreloader, _t;
|
|
18918
|
+
return _regenerator().w(function (_context3) {
|
|
18919
|
+
while (1) switch (_context3.n) {
|
|
18920
|
+
case 0:
|
|
18921
|
+
if (!(!additionalComponents || _typeof(additionalComponents) !== 'object')) {
|
|
18922
|
+
_context3.n = 1;
|
|
18923
|
+
break;
|
|
18924
|
+
}
|
|
18925
|
+
console.warn('⚠️ extendComponentDictionary(): Invalid components object');
|
|
18926
|
+
return _context3.a(2, false);
|
|
18927
|
+
case 1:
|
|
18928
|
+
_context3.n = 2;
|
|
18929
|
+
return this.ensureDictionaryLoaded();
|
|
18930
|
+
case 2:
|
|
18931
|
+
if (this.componentDictionary) {
|
|
18932
|
+
_context3.n = 3;
|
|
18933
|
+
break;
|
|
18934
|
+
}
|
|
18935
|
+
console.warn('⚠️ extendComponentDictionary(): Component dictionary not loaded yet');
|
|
18936
|
+
return _context3.a(2, false);
|
|
18937
|
+
case 3:
|
|
18938
|
+
_context3.p = 3;
|
|
18939
|
+
// Merge additional components into dictionary
|
|
18940
|
+
addedCount = Object.keys(additionalComponents).length;
|
|
18941
|
+
Object.assign(this.componentDictionary, additionalComponents);
|
|
18942
|
+
|
|
18943
|
+
// Update ModelPreloader's dictionary reference
|
|
18944
|
+
// This ensures drag-and-drop can find S3 components
|
|
18945
|
+
modelPreloader = (_this$sceneViewer = this.sceneViewer) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.centralPlant) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.utilities) === null || _this$sceneViewer === void 0 ? void 0 : _this$sceneViewer.modelPreloader;
|
|
18946
|
+
if (modelPreloader) {
|
|
18947
|
+
modelPreloader.componentDictionary = this.componentDictionary;
|
|
18948
|
+
console.log("\uD83D\uDD04 Updated ModelPreloader's dictionary reference (".concat(Object.keys(this.componentDictionary).length, " total components)"));
|
|
18949
|
+
}
|
|
18950
|
+
|
|
18951
|
+
// Clear cache to force refresh
|
|
18952
|
+
this.clearCache();
|
|
18953
|
+
console.log("\u2705 extendComponentDictionary(): Added ".concat(addedCount, " components to dictionary"));
|
|
18954
|
+
return _context3.a(2, true);
|
|
18955
|
+
case 4:
|
|
18956
|
+
_context3.p = 4;
|
|
18957
|
+
_t = _context3.v;
|
|
18958
|
+
console.error('❌ extendComponentDictionary(): Error extending dictionary:', _t);
|
|
18959
|
+
return _context3.a(2, false);
|
|
18960
|
+
}
|
|
18961
|
+
}, _callee3, this, [[3, 4]]);
|
|
18962
|
+
}));
|
|
18963
|
+
function extendComponentDictionary(_x) {
|
|
18964
|
+
return _extendComponentDictionary.apply(this, arguments);
|
|
18965
|
+
}
|
|
18966
|
+
return extendComponentDictionary;
|
|
18967
|
+
}()
|
|
18968
|
+
/**
|
|
18969
|
+
* Remove S3 components from the component dictionary
|
|
18970
|
+
* @returns {Promise<boolean>} True if components were removed successfully
|
|
18971
|
+
*/
|
|
18972
|
+
)
|
|
18973
|
+
}, {
|
|
18974
|
+
key: "removeS3Components",
|
|
18975
|
+
value: (function () {
|
|
18976
|
+
var _removeS3Components = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
18977
|
+
var _this3 = this;
|
|
18978
|
+
var _this$sceneViewer2, keysToRemove, _i2, _Object$entries2, _Object$entries2$_i, key, component, modelPreloader, _t2;
|
|
18979
|
+
return _regenerator().w(function (_context4) {
|
|
18980
|
+
while (1) switch (_context4.n) {
|
|
18981
|
+
case 0:
|
|
18982
|
+
_context4.n = 1;
|
|
18983
|
+
return this.ensureDictionaryLoaded();
|
|
18984
|
+
case 1:
|
|
18985
|
+
if (this.componentDictionary) {
|
|
18986
|
+
_context4.n = 2;
|
|
18987
|
+
break;
|
|
18988
|
+
}
|
|
18989
|
+
console.warn('⚠️ removeS3Components(): Component dictionary not loaded yet');
|
|
18990
|
+
return _context4.a(2, false);
|
|
18991
|
+
case 2:
|
|
18992
|
+
_context4.p = 2;
|
|
18993
|
+
// Find and remove all S3 components
|
|
18994
|
+
keysToRemove = [];
|
|
18995
|
+
for (_i2 = 0, _Object$entries2 = Object.entries(this.componentDictionary); _i2 < _Object$entries2.length; _i2++) {
|
|
18996
|
+
_Object$entries2$_i = _slicedToArray(_Object$entries2[_i2], 2), key = _Object$entries2$_i[0], component = _Object$entries2$_i[1];
|
|
18997
|
+
if (component.isS3Component) {
|
|
18998
|
+
keysToRemove.push(key);
|
|
18999
|
+
}
|
|
19000
|
+
}
|
|
19001
|
+
|
|
19002
|
+
// Remove the S3 components
|
|
19003
|
+
keysToRemove.forEach(function (key) {
|
|
19004
|
+
delete _this3.componentDictionary[key];
|
|
19005
|
+
});
|
|
19006
|
+
|
|
19007
|
+
// Update ModelPreloader's dictionary reference
|
|
19008
|
+
modelPreloader = (_this$sceneViewer2 = this.sceneViewer) === null || _this$sceneViewer2 === void 0 || (_this$sceneViewer2 = _this$sceneViewer2.centralPlant) === null || _this$sceneViewer2 === void 0 || (_this$sceneViewer2 = _this$sceneViewer2.utilities) === null || _this$sceneViewer2 === void 0 ? void 0 : _this$sceneViewer2.modelPreloader;
|
|
19009
|
+
if (modelPreloader) {
|
|
19010
|
+
modelPreloader.componentDictionary = this.componentDictionary;
|
|
19011
|
+
console.log("\uD83D\uDD04 Updated ModelPreloader's dictionary reference (".concat(Object.keys(this.componentDictionary).length, " total components)"));
|
|
19012
|
+
}
|
|
19013
|
+
|
|
19014
|
+
// Clear cache to force refresh
|
|
19015
|
+
this.clearCache();
|
|
19016
|
+
console.log("\u2705 removeS3Components(): Removed ".concat(keysToRemove.length, " S3 components from dictionary"));
|
|
19017
|
+
return _context4.a(2, true);
|
|
19018
|
+
case 3:
|
|
19019
|
+
_context4.p = 3;
|
|
19020
|
+
_t2 = _context4.v;
|
|
19021
|
+
console.error('❌ removeS3Components(): Error removing S3 components:', _t2);
|
|
19022
|
+
return _context4.a(2, false);
|
|
19023
|
+
}
|
|
19024
|
+
}, _callee4, this, [[2, 3]]);
|
|
19025
|
+
}));
|
|
19026
|
+
function removeS3Components() {
|
|
19027
|
+
return _removeS3Components.apply(this, arguments);
|
|
19028
|
+
}
|
|
19029
|
+
return removeS3Components;
|
|
19030
|
+
}()
|
|
18770
19031
|
/**
|
|
18771
19032
|
* Clear the component cache
|
|
18772
19033
|
*/
|
|
19034
|
+
)
|
|
18773
19035
|
}, {
|
|
18774
19036
|
key: "clearCache",
|
|
18775
19037
|
value: function clearCache() {
|
|
@@ -18780,46 +19042,47 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
18780
19042
|
/**
|
|
18781
19043
|
* Load component dictionary from static file
|
|
18782
19044
|
* @private
|
|
19045
|
+
* @returns {Promise<void>} Promise that resolves when dictionary is loaded
|
|
18783
19046
|
*/
|
|
18784
19047
|
}, {
|
|
18785
19048
|
key: "_loadComponentDictionary",
|
|
18786
19049
|
value: (function () {
|
|
18787
|
-
var _loadComponentDictionary2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
18788
|
-
var response,
|
|
18789
|
-
return _regenerator().w(function (
|
|
18790
|
-
while (1) switch (
|
|
19050
|
+
var _loadComponentDictionary2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
|
|
19051
|
+
var response, _t3;
|
|
19052
|
+
return _regenerator().w(function (_context5) {
|
|
19053
|
+
while (1) switch (_context5.n) {
|
|
18791
19054
|
case 0:
|
|
18792
|
-
|
|
18793
|
-
|
|
19055
|
+
_context5.p = 0;
|
|
19056
|
+
_context5.n = 1;
|
|
18794
19057
|
return fetch('/library/component-dictionary.json');
|
|
18795
19058
|
case 1:
|
|
18796
|
-
response =
|
|
19059
|
+
response = _context5.v;
|
|
18797
19060
|
if (!response.ok) {
|
|
18798
|
-
|
|
19061
|
+
_context5.n = 3;
|
|
18799
19062
|
break;
|
|
18800
19063
|
}
|
|
18801
|
-
|
|
19064
|
+
_context5.n = 2;
|
|
18802
19065
|
return response.json();
|
|
18803
19066
|
case 2:
|
|
18804
|
-
this.componentDictionary =
|
|
19067
|
+
this.componentDictionary = _context5.v;
|
|
18805
19068
|
console.log('📚 ComponentDataManager: Component dictionary loaded successfully');
|
|
18806
|
-
|
|
19069
|
+
_context5.n = 4;
|
|
18807
19070
|
break;
|
|
18808
19071
|
case 3:
|
|
18809
19072
|
console.warn('⚠️ ComponentDataManager: Could not load component dictionary');
|
|
18810
19073
|
this.componentDictionary = null;
|
|
18811
19074
|
case 4:
|
|
18812
|
-
|
|
19075
|
+
_context5.n = 6;
|
|
18813
19076
|
break;
|
|
18814
19077
|
case 5:
|
|
18815
|
-
|
|
18816
|
-
|
|
18817
|
-
console.warn('⚠️ ComponentDataManager: Error loading component dictionary:',
|
|
19078
|
+
_context5.p = 5;
|
|
19079
|
+
_t3 = _context5.v;
|
|
19080
|
+
console.warn('⚠️ ComponentDataManager: Error loading component dictionary:', _t3);
|
|
18818
19081
|
this.componentDictionary = null;
|
|
18819
19082
|
case 6:
|
|
18820
|
-
return
|
|
19083
|
+
return _context5.a(2);
|
|
18821
19084
|
}
|
|
18822
|
-
},
|
|
19085
|
+
}, _callee5, this, [[0, 5]]);
|
|
18823
19086
|
}));
|
|
18824
19087
|
function _loadComponentDictionary() {
|
|
18825
19088
|
return _loadComponentDictionary2.apply(this, arguments);
|
|
@@ -18840,10 +19103,10 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
18840
19103
|
if (!this.componentDictionary) return 'unknown';
|
|
18841
19104
|
|
|
18842
19105
|
// Look for component in dictionary
|
|
18843
|
-
for (var
|
|
18844
|
-
var _Object$
|
|
18845
|
-
key = _Object$
|
|
18846
|
-
component = _Object$
|
|
19106
|
+
for (var _i3 = 0, _Object$entries3 = Object.entries(this.componentDictionary); _i3 < _Object$entries3.length; _i3++) {
|
|
19107
|
+
var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i3], 2),
|
|
19108
|
+
key = _Object$entries3$_i[0],
|
|
19109
|
+
component = _Object$entries3$_i[1];
|
|
18847
19110
|
if (key === 'categories') continue;
|
|
18848
19111
|
if (name && name.toLowerCase().includes(key.toLowerCase())) {
|
|
18849
19112
|
return component.category || 'unknown';
|
|
@@ -18869,7 +19132,7 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
18869
19132
|
}, {
|
|
18870
19133
|
key: "_traverseScene",
|
|
18871
19134
|
value: function _traverseScene(object) {
|
|
18872
|
-
var
|
|
19135
|
+
var _this4 = this;
|
|
18873
19136
|
var components = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
18874
19137
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
18875
19138
|
if (!object) return components;
|
|
@@ -18885,7 +19148,7 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
18885
19148
|
// Recursively traverse children
|
|
18886
19149
|
if (object.children && object.children.length > 0) {
|
|
18887
19150
|
object.children.forEach(function (child) {
|
|
18888
|
-
|
|
19151
|
+
_this4._traverseScene(child, components, options);
|
|
18889
19152
|
});
|
|
18890
19153
|
}
|
|
18891
19154
|
return components;
|
|
@@ -19054,7 +19317,10 @@ var ComponentDataManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
19054
19317
|
modelKey: component.modelKey,
|
|
19055
19318
|
modelType: component.modelType,
|
|
19056
19319
|
thumbnail: component.thumbnail,
|
|
19057
|
-
tags: component.tags || []
|
|
19320
|
+
tags: component.tags || [],
|
|
19321
|
+
// Preserve S3 metadata
|
|
19322
|
+
isS3Component: component.isS3Component,
|
|
19323
|
+
s3Path: component.s3Path
|
|
19058
19324
|
};
|
|
19059
19325
|
return _objectSpread2(_objectSpread2({}, baseData), {}, {
|
|
19060
19326
|
metadata: component.metadata || {},
|
|
@@ -24863,6 +25129,9 @@ var KeyboardControlsManager = /*#__PURE__*/function () {
|
|
|
24863
25129
|
key: "setupKeyboardControls",
|
|
24864
25130
|
value: function setupKeyboardControls() {
|
|
24865
25131
|
this.handleKeyDown = function (event) {
|
|
25132
|
+
// Guard against undefined event or key
|
|
25133
|
+
if (!event || !event.key) return;
|
|
25134
|
+
|
|
24866
25135
|
// Sample Ctrl+Z example
|
|
24867
25136
|
if (event.ctrlKey && (event.key.toLowerCase() === 'z' || event.code === 'KeyZ')) {
|
|
24868
25137
|
// method call here
|
|
@@ -30297,134 +30566,235 @@ var ComponentDragManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
30297
30566
|
* @param {string} componentId - Library ID of the component to drag
|
|
30298
30567
|
* @param {HTMLElement} sourceElement - The DOM element being dragged
|
|
30299
30568
|
* @param {MouseEvent|TouchEvent} event - The initiating event
|
|
30300
|
-
* @returns {boolean} True if drag started successfully
|
|
30569
|
+
* @returns {Promise<boolean>} True if drag started successfully
|
|
30301
30570
|
*/
|
|
30302
30571
|
}, {
|
|
30303
30572
|
key: "startComponentDrag",
|
|
30304
|
-
value: function
|
|
30305
|
-
var
|
|
30306
|
-
|
|
30307
|
-
|
|
30308
|
-
|
|
30309
|
-
|
|
30310
|
-
|
|
30311
|
-
|
|
30312
|
-
|
|
30313
|
-
|
|
30314
|
-
|
|
30315
|
-
|
|
30316
|
-
|
|
30317
|
-
|
|
30318
|
-
|
|
30319
|
-
|
|
30320
|
-
|
|
30321
|
-
|
|
30322
|
-
|
|
30323
|
-
|
|
30324
|
-
|
|
30325
|
-
|
|
30326
|
-
|
|
30327
|
-
|
|
30328
|
-
|
|
30329
|
-
|
|
30330
|
-
|
|
30331
|
-
|
|
30332
|
-
|
|
30333
|
-
|
|
30334
|
-
|
|
30335
|
-
|
|
30336
|
-
|
|
30337
|
-
|
|
30338
|
-
|
|
30339
|
-
|
|
30340
|
-
|
|
30341
|
-
|
|
30342
|
-
|
|
30343
|
-
|
|
30344
|
-
|
|
30345
|
-
|
|
30346
|
-
|
|
30347
|
-
|
|
30573
|
+
value: (function () {
|
|
30574
|
+
var _startComponentDrag = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(componentId, sourceElement, event) {
|
|
30575
|
+
var _this$sceneViewer$$re, _event$touches$, _event$touches$2;
|
|
30576
|
+
var canvases, perspectiveCanvas, clientX, clientY;
|
|
30577
|
+
return _regenerator().w(function (_context) {
|
|
30578
|
+
while (1) switch (_context.n) {
|
|
30579
|
+
case 0:
|
|
30580
|
+
if (!(!this.enabled || this.isDragging)) {
|
|
30581
|
+
_context.n = 1;
|
|
30582
|
+
break;
|
|
30583
|
+
}
|
|
30584
|
+
return _context.a(2, false);
|
|
30585
|
+
case 1:
|
|
30586
|
+
if (!(!this.sceneViewer || !this.sceneViewer.scene || !this.sceneViewer.camera)) {
|
|
30587
|
+
_context.n = 2;
|
|
30588
|
+
break;
|
|
30589
|
+
}
|
|
30590
|
+
console.warn('ComponentDragManager: Scene not ready for drag operations');
|
|
30591
|
+
return _context.a(2, false);
|
|
30592
|
+
case 2:
|
|
30593
|
+
console.log('🎯 Starting component drag:', componentId);
|
|
30594
|
+
this.isDragging = true;
|
|
30595
|
+
this.dragData.componentId = componentId;
|
|
30596
|
+
this.dragData.dragElement = sourceElement;
|
|
30597
|
+
|
|
30598
|
+
// Find the actual 3D canvas and use its parent as drop zone
|
|
30599
|
+
// The scene might be in QuadViewport, so we need to find the perspective canvas
|
|
30600
|
+
canvases = document.querySelectorAll('canvas');
|
|
30601
|
+
perspectiveCanvas = Array.from(canvases).find(function (canvas) {
|
|
30602
|
+
return canvas.parentElement && canvas.parentElement.classList.contains('perspective-container');
|
|
30603
|
+
});
|
|
30604
|
+
this.dragData.dropZone = perspectiveCanvas ? perspectiveCanvas.parentElement : (_this$sceneViewer$$re = this.sceneViewer.$refs) === null || _this$sceneViewer$$re === void 0 ? void 0 : _this$sceneViewer$$re.container;
|
|
30605
|
+
|
|
30606
|
+
// Store starting position
|
|
30607
|
+
clientX = event.clientX || event.touches && ((_event$touches$ = event.touches[0]) === null || _event$touches$ === void 0 ? void 0 : _event$touches$.clientX) || 0;
|
|
30608
|
+
clientY = event.clientY || event.touches && ((_event$touches$2 = event.touches[0]) === null || _event$touches$2 === void 0 ? void 0 : _event$touches$2.clientY) || 0;
|
|
30609
|
+
this.dragData.startPosition = {
|
|
30610
|
+
x: clientX,
|
|
30611
|
+
y: clientY
|
|
30612
|
+
};
|
|
30613
|
+
this.dragData.currentPosition = {
|
|
30614
|
+
x: clientX,
|
|
30615
|
+
y: clientY
|
|
30616
|
+
};
|
|
30348
30617
|
|
|
30349
|
-
|
|
30350
|
-
|
|
30351
|
-
|
|
30352
|
-
|
|
30618
|
+
// Create preview object (async to wait for loading models)
|
|
30619
|
+
_context.n = 3;
|
|
30620
|
+
return this._createPreviewObject(componentId);
|
|
30621
|
+
case 3:
|
|
30622
|
+
// Add global event listeners
|
|
30623
|
+
document.addEventListener('mousemove', this.handleGlobalMouseMove, false);
|
|
30624
|
+
document.addEventListener('mouseup', this.handleGlobalMouseUp, false);
|
|
30625
|
+
document.addEventListener('touchmove', this.handleGlobalMouseMove, false);
|
|
30626
|
+
document.addEventListener('touchend', this.handleGlobalMouseUp, false);
|
|
30627
|
+
|
|
30628
|
+
// Update mouse position and preview
|
|
30629
|
+
this._updateMousePosition(clientX, clientY);
|
|
30630
|
+
this._updatePreviewPosition();
|
|
30631
|
+
|
|
30632
|
+
// Add visual feedback to source element
|
|
30633
|
+
if (sourceElement) {
|
|
30634
|
+
sourceElement.style.opacity = '0.5';
|
|
30635
|
+
sourceElement.style.transform = 'scale(0.95)';
|
|
30636
|
+
}
|
|
30637
|
+
return _context.a(2, true);
|
|
30638
|
+
}
|
|
30639
|
+
}, _callee, this);
|
|
30640
|
+
}));
|
|
30641
|
+
function startComponentDrag(_x, _x2, _x3) {
|
|
30642
|
+
return _startComponentDrag.apply(this, arguments);
|
|
30353
30643
|
}
|
|
30354
|
-
return
|
|
30355
|
-
}
|
|
30356
|
-
|
|
30644
|
+
return startComponentDrag;
|
|
30645
|
+
}()
|
|
30357
30646
|
/**
|
|
30358
30647
|
* Create a preview object for the component being dragged
|
|
30359
30648
|
* @param {string} componentId - Library ID of the component
|
|
30360
30649
|
* @private
|
|
30361
30650
|
*/
|
|
30651
|
+
)
|
|
30362
30652
|
}, {
|
|
30363
30653
|
key: "_createPreviewObject",
|
|
30364
|
-
value: function
|
|
30365
|
-
var
|
|
30366
|
-
|
|
30367
|
-
|
|
30368
|
-
|
|
30369
|
-
|
|
30370
|
-
|
|
30371
|
-
|
|
30372
|
-
|
|
30373
|
-
|
|
30374
|
-
|
|
30375
|
-
|
|
30376
|
-
|
|
30377
|
-
|
|
30378
|
-
|
|
30379
|
-
|
|
30380
|
-
|
|
30381
|
-
|
|
30382
|
-
|
|
30383
|
-
|
|
30384
|
-
|
|
30385
|
-
|
|
30386
|
-
|
|
30387
|
-
|
|
30388
|
-
|
|
30389
|
-
|
|
30390
|
-
|
|
30391
|
-
|
|
30392
|
-
|
|
30393
|
-
|
|
30394
|
-
|
|
30395
|
-
|
|
30396
|
-
|
|
30397
|
-
|
|
30398
|
-
|
|
30399
|
-
|
|
30400
|
-
|
|
30401
|
-
|
|
30402
|
-
|
|
30403
|
-
|
|
30404
|
-
|
|
30405
|
-
|
|
30406
|
-
|
|
30407
|
-
|
|
30408
|
-
|
|
30409
|
-
|
|
30410
|
-
|
|
30411
|
-
|
|
30412
|
-
|
|
30413
|
-
|
|
30414
|
-
|
|
30415
|
-
|
|
30416
|
-
|
|
30417
|
-
|
|
30418
|
-
|
|
30419
|
-
|
|
30420
|
-
|
|
30421
|
-
|
|
30422
|
-
|
|
30423
|
-
|
|
30424
|
-
|
|
30425
|
-
|
|
30654
|
+
value: (function () {
|
|
30655
|
+
var _createPreviewObject2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(componentId) {
|
|
30656
|
+
var _this$sceneViewer$cen;
|
|
30657
|
+
var modelPreloader, componentData, cachedModel, geometry, material, _t, _t2;
|
|
30658
|
+
return _regenerator().w(function (_context2) {
|
|
30659
|
+
while (1) switch (_context2.n) {
|
|
30660
|
+
case 0:
|
|
30661
|
+
// Try to get the actual component model from modelPreloader
|
|
30662
|
+
modelPreloader = (_this$sceneViewer$cen = this.sceneViewer.centralPlant) === null || _this$sceneViewer$cen === void 0 || (_this$sceneViewer$cen = _this$sceneViewer$cen.utilities) === null || _this$sceneViewer$cen === void 0 ? void 0 : _this$sceneViewer$cen.modelPreloader; // DEBUG: Log what we're looking for
|
|
30663
|
+
console.log("\uD83D\uDD0D ComponentDragManager: Looking for component: \"".concat(componentId, "\""));
|
|
30664
|
+
console.log("\uD83D\uDD0D ModelPreloader available:", !!modelPreloader);
|
|
30665
|
+
console.log("\uD83D\uDD0D ComponentDictionary available:", !!(modelPreloader !== null && modelPreloader !== void 0 && modelPreloader.componentDictionary));
|
|
30666
|
+
if (!(modelPreloader && modelPreloader.componentDictionary)) {
|
|
30667
|
+
_context2.n = 13;
|
|
30668
|
+
break;
|
|
30669
|
+
}
|
|
30670
|
+
console.log("\uD83D\uDCDA Available dictionary keys:", Object.keys(modelPreloader.componentDictionary));
|
|
30671
|
+
componentData = modelPreloader.componentDictionary[componentId]; // DEBUG: Log lookup result
|
|
30672
|
+
if (!componentData) {
|
|
30673
|
+
console.error("\u274C Component \"".concat(componentId, "\" not found in ModelPreloader dictionary"));
|
|
30674
|
+
console.log("\uD83D\uDCCB Full dictionary:", modelPreloader.componentDictionary);
|
|
30675
|
+
} else {
|
|
30676
|
+
console.log("\u2705 Found component data for \"".concat(componentId, "\":"), {
|
|
30677
|
+
modelKey: componentData.modelKey,
|
|
30678
|
+
isS3Component: componentData.isS3Component,
|
|
30679
|
+
s3Path: componentData.s3Path
|
|
30680
|
+
});
|
|
30681
|
+
}
|
|
30682
|
+
if (!(componentData && componentData.modelKey)) {
|
|
30683
|
+
_context2.n = 11;
|
|
30684
|
+
break;
|
|
30685
|
+
}
|
|
30686
|
+
// Try to get cached model first
|
|
30687
|
+
cachedModel = modelPreloader.getCachedModelWithDimensions(componentData.modelKey, componentId); // If not cached but currently loading, wait for it
|
|
30688
|
+
if (!(!cachedModel && modelPreloader.loadingPromises && modelPreloader.loadingPromises.has(componentData.modelKey))) {
|
|
30689
|
+
_context2.n = 4;
|
|
30690
|
+
break;
|
|
30691
|
+
}
|
|
30692
|
+
console.log("\u23F3 Waiting for ".concat(componentData.modelKey, " to finish loading..."));
|
|
30693
|
+
_context2.p = 1;
|
|
30694
|
+
_context2.n = 2;
|
|
30695
|
+
return modelPreloader.loadingPromises.get(componentData.modelKey);
|
|
30696
|
+
case 2:
|
|
30697
|
+
cachedModel = modelPreloader.getCachedModelWithDimensions(componentData.modelKey, componentId);
|
|
30698
|
+
_context2.n = 4;
|
|
30699
|
+
break;
|
|
30700
|
+
case 3:
|
|
30701
|
+
_context2.p = 3;
|
|
30702
|
+
_t = _context2.v;
|
|
30703
|
+
console.warn("\u26A0\uFE0F Failed to wait for model ".concat(componentData.modelKey, ":"), _t);
|
|
30704
|
+
case 4:
|
|
30705
|
+
if (cachedModel) {
|
|
30706
|
+
_context2.n = 8;
|
|
30707
|
+
break;
|
|
30708
|
+
}
|
|
30709
|
+
console.log("\uD83D\uDD04 Model ".concat(componentData.modelKey, " not cached, attempting to load..."));
|
|
30710
|
+
_context2.p = 5;
|
|
30711
|
+
_context2.n = 6;
|
|
30712
|
+
return modelPreloader.preloadSingleModel(componentData.modelKey);
|
|
30713
|
+
case 6:
|
|
30714
|
+
cachedModel = modelPreloader.getCachedModelWithDimensions(componentData.modelKey, componentId);
|
|
30715
|
+
_context2.n = 8;
|
|
30716
|
+
break;
|
|
30717
|
+
case 7:
|
|
30718
|
+
_context2.p = 7;
|
|
30719
|
+
_t2 = _context2.v;
|
|
30720
|
+
console.warn("\u26A0\uFE0F Failed to preload model ".concat(componentData.modelKey, ":"), _t2);
|
|
30721
|
+
case 8:
|
|
30722
|
+
if (!cachedModel) {
|
|
30723
|
+
_context2.n = 9;
|
|
30724
|
+
break;
|
|
30725
|
+
}
|
|
30726
|
+
this.dragData.previewObject = cachedModel.clone();
|
|
30727
|
+
|
|
30728
|
+
// Clone materials to avoid affecting other objects
|
|
30729
|
+
this._cloneMaterials(this.dragData.previewObject);
|
|
30730
|
+
|
|
30731
|
+
// Store original colors BEFORE making transparent
|
|
30732
|
+
this._storeOriginalColors(this.dragData.previewObject);
|
|
30733
|
+
|
|
30734
|
+
// Make the preview semi-transparent
|
|
30735
|
+
this._setPreviewTransparency(this.dragData.previewObject, 0.5);
|
|
30736
|
+
this.dragData.previewObject.userData = {
|
|
30737
|
+
isPreview: true,
|
|
30738
|
+
componentId: componentId,
|
|
30739
|
+
originalOpacity: 1.0
|
|
30740
|
+
};
|
|
30741
|
+
|
|
30742
|
+
// Position off-screen initially
|
|
30743
|
+
this.dragData.previewObject.position.set(1000, 1000, 1000);
|
|
30744
|
+
this.sceneViewer.scene.add(this.dragData.previewObject);
|
|
30745
|
+
console.log("\u2705 Created ".concat(componentData.isS3Component ? 'S3' : 'static', " GLB preview object for: ").concat(componentId));
|
|
30746
|
+
return _context2.a(2);
|
|
30747
|
+
case 9:
|
|
30748
|
+
console.warn("\u26A0\uFE0F Failed to load model for ".concat(componentId, ", will use fallback"));
|
|
30749
|
+
case 10:
|
|
30750
|
+
_context2.n = 12;
|
|
30751
|
+
break;
|
|
30752
|
+
case 11:
|
|
30753
|
+
console.warn("\u26A0\uFE0F No modelKey found for component ".concat(componentId));
|
|
30754
|
+
case 12:
|
|
30755
|
+
_context2.n = 14;
|
|
30756
|
+
break;
|
|
30757
|
+
case 13:
|
|
30758
|
+
console.warn("\u26A0\uFE0F ModelPreloader or component dictionary not available");
|
|
30759
|
+
case 14:
|
|
30760
|
+
// Fallback: Create a simple preview mesh if model not available
|
|
30761
|
+
geometry = new THREE__namespace.BoxGeometry(1, 1, 1);
|
|
30762
|
+
material = new THREE__namespace.MeshPhysicalMaterial({
|
|
30763
|
+
color: 0x4CAF50,
|
|
30764
|
+
transparent: true,
|
|
30765
|
+
opacity: 0.5,
|
|
30766
|
+
wireframe: true
|
|
30767
|
+
});
|
|
30768
|
+
this.dragData.previewObject = new THREE__namespace.Mesh(geometry, material);
|
|
30769
|
+
this.dragData.previewObject.userData = {
|
|
30770
|
+
isPreview: true,
|
|
30771
|
+
componentId: componentId,
|
|
30772
|
+
originalOpacity: 0.7
|
|
30773
|
+
};
|
|
30774
|
+
|
|
30775
|
+
// Store original color for fallback mesh
|
|
30776
|
+
this.dragData.previewObject.material.userData.originalColor = 0x4CAF50;
|
|
30777
|
+
|
|
30778
|
+
// Position off-screen initially
|
|
30779
|
+
this.dragData.previewObject.position.set(1000, 1000, 1000);
|
|
30780
|
+
this.sceneViewer.scene.add(this.dragData.previewObject);
|
|
30781
|
+
console.log("\u26A0\uFE0F Created fallback wireframe preview for: ".concat(componentId));
|
|
30782
|
+
case 15:
|
|
30783
|
+
return _context2.a(2);
|
|
30784
|
+
}
|
|
30785
|
+
}, _callee2, this, [[5, 7], [1, 3]]);
|
|
30786
|
+
}));
|
|
30787
|
+
function _createPreviewObject(_x4) {
|
|
30788
|
+
return _createPreviewObject2.apply(this, arguments);
|
|
30789
|
+
}
|
|
30790
|
+
return _createPreviewObject;
|
|
30791
|
+
}()
|
|
30792
|
+
/**
|
|
30793
|
+
* Clone all materials in an object hierarchy to avoid shared material issues
|
|
30794
|
+
* @param {THREE.Object3D} object - The object to clone materials for
|
|
30426
30795
|
* @private
|
|
30427
30796
|
*/
|
|
30797
|
+
)
|
|
30428
30798
|
}, {
|
|
30429
30799
|
key: "_cloneMaterials",
|
|
30430
30800
|
value: function _cloneMaterials(object) {
|
|
@@ -30880,16 +31250,54 @@ var ComponentDragManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
30880
31250
|
value: function enableElementDrag(element, componentId) {
|
|
30881
31251
|
var _this3 = this;
|
|
30882
31252
|
if (!element || !componentId) return;
|
|
30883
|
-
var handleMouseDown = function
|
|
30884
|
-
|
|
30885
|
-
|
|
30886
|
-
|
|
30887
|
-
|
|
30888
|
-
|
|
30889
|
-
|
|
30890
|
-
|
|
30891
|
-
|
|
30892
|
-
|
|
31253
|
+
var handleMouseDown = /*#__PURE__*/function () {
|
|
31254
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(event) {
|
|
31255
|
+
return _regenerator().w(function (_context3) {
|
|
31256
|
+
while (1) switch (_context3.n) {
|
|
31257
|
+
case 0:
|
|
31258
|
+
if (!(event.button !== 0)) {
|
|
31259
|
+
_context3.n = 1;
|
|
31260
|
+
break;
|
|
31261
|
+
}
|
|
31262
|
+
return _context3.a(2);
|
|
31263
|
+
case 1:
|
|
31264
|
+
// Only left mouse button
|
|
31265
|
+
event.preventDefault();
|
|
31266
|
+
_context3.n = 2;
|
|
31267
|
+
return _this3.startComponentDrag(componentId, element, event);
|
|
31268
|
+
case 2:
|
|
31269
|
+
return _context3.a(2);
|
|
31270
|
+
}
|
|
31271
|
+
}, _callee3);
|
|
31272
|
+
}));
|
|
31273
|
+
return function handleMouseDown(_x5) {
|
|
31274
|
+
return _ref.apply(this, arguments);
|
|
31275
|
+
};
|
|
31276
|
+
}();
|
|
31277
|
+
var handleTouchStart = /*#__PURE__*/function () {
|
|
31278
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(event) {
|
|
31279
|
+
return _regenerator().w(function (_context4) {
|
|
31280
|
+
while (1) switch (_context4.n) {
|
|
31281
|
+
case 0:
|
|
31282
|
+
if (!(event.touches.length !== 1)) {
|
|
31283
|
+
_context4.n = 1;
|
|
31284
|
+
break;
|
|
31285
|
+
}
|
|
31286
|
+
return _context4.a(2);
|
|
31287
|
+
case 1:
|
|
31288
|
+
// Only single touch
|
|
31289
|
+
event.preventDefault();
|
|
31290
|
+
_context4.n = 2;
|
|
31291
|
+
return _this3.startComponentDrag(componentId, element, event);
|
|
31292
|
+
case 2:
|
|
31293
|
+
return _context4.a(2);
|
|
31294
|
+
}
|
|
31295
|
+
}, _callee4);
|
|
31296
|
+
}));
|
|
31297
|
+
return function handleTouchStart(_x6) {
|
|
31298
|
+
return _ref2.apply(this, arguments);
|
|
31299
|
+
};
|
|
31300
|
+
}();
|
|
30893
31301
|
element.addEventListener('mousedown', handleMouseDown, false);
|
|
30894
31302
|
element.addEventListener('touchstart', handleTouchStart, false);
|
|
30895
31303
|
|
|
@@ -34054,7 +34462,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
34054
34462
|
* Initialize the CentralPlant manager
|
|
34055
34463
|
*
|
|
34056
34464
|
* @constructor
|
|
34057
|
-
* @version 0.1.
|
|
34465
|
+
* @version 0.1.64
|
|
34058
34466
|
* @updated 2025-10-22
|
|
34059
34467
|
*
|
|
34060
34468
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -35077,48 +35485,70 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35077
35485
|
* @param {Object} [options={}] - Configuration options for component listing
|
|
35078
35486
|
* @param {string} [options.category] - Filter by category (e.g., 'pumps', 'chillers')
|
|
35079
35487
|
* @param {string} [options.name] - Filter by component name (partial match)
|
|
35080
|
-
* @returns {Array<Object
|
|
35488
|
+
* @returns {Promise<Array<Object>>} Array of component objects with detailed information
|
|
35081
35489
|
* @description Retrieves available component information from the library dictionary with flexible filtering options.
|
|
35082
35490
|
* Metadata is always included for complete component details.
|
|
35083
35491
|
* @example
|
|
35084
35492
|
* // Get all available components from dictionary
|
|
35085
|
-
* const availableComponents = centralPlant.getComponents();
|
|
35493
|
+
* const availableComponents = await centralPlant.getComponents();
|
|
35086
35494
|
* console.log(`${availableComponents.length} components available in library`);
|
|
35087
35495
|
*
|
|
35088
35496
|
* @example
|
|
35089
35497
|
* // Filter by category
|
|
35090
|
-
* const availablePumps = centralPlant.getComponents({ category: 'pumps' });
|
|
35498
|
+
* const availablePumps = await centralPlant.getComponents({ category: 'pumps' });
|
|
35091
35499
|
*
|
|
35092
35500
|
* @example
|
|
35093
35501
|
* // Filter by multiple categories
|
|
35094
|
-
* const availableEquipment = centralPlant.getComponents({ category: ['pumps', 'chillers'] });
|
|
35502
|
+
* const availableEquipment = await centralPlant.getComponents({ category: ['pumps', 'chillers'] });
|
|
35095
35503
|
*
|
|
35096
35504
|
* @example
|
|
35097
35505
|
* // Filter by name pattern
|
|
35098
|
-
* const towers = centralPlant.getComponents({ name: 'tower' });
|
|
35506
|
+
* const towers = await centralPlant.getComponents({ name: 'tower' });
|
|
35099
35507
|
*/
|
|
35100
35508
|
}, {
|
|
35101
35509
|
key: "getComponents",
|
|
35102
|
-
value: function
|
|
35103
|
-
var
|
|
35104
|
-
|
|
35105
|
-
|
|
35106
|
-
|
|
35107
|
-
|
|
35108
|
-
|
|
35109
|
-
|
|
35110
|
-
|
|
35111
|
-
|
|
35112
|
-
|
|
35113
|
-
|
|
35114
|
-
|
|
35115
|
-
|
|
35116
|
-
|
|
35117
|
-
|
|
35118
|
-
|
|
35510
|
+
value: (function () {
|
|
35511
|
+
var _getComponents = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
35512
|
+
var options,
|
|
35513
|
+
validation,
|
|
35514
|
+
enhancedOptions,
|
|
35515
|
+
_args2 = arguments,
|
|
35516
|
+
_t;
|
|
35517
|
+
return _regenerator().w(function (_context2) {
|
|
35518
|
+
while (1) switch (_context2.n) {
|
|
35519
|
+
case 0:
|
|
35520
|
+
options = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
|
35521
|
+
// Validate filter options using centralized validator
|
|
35522
|
+
validation = this.internals.validator.validateComponentFilter(options);
|
|
35523
|
+
if (validation.isValid) {
|
|
35524
|
+
_context2.n = 1;
|
|
35525
|
+
break;
|
|
35526
|
+
}
|
|
35527
|
+
console.warn('⚠️ getComponents(): Invalid filter options provided:', validation.message);
|
|
35528
|
+
return _context2.a(2, []);
|
|
35529
|
+
case 1:
|
|
35530
|
+
_context2.p = 1;
|
|
35531
|
+
// Always include metadata
|
|
35532
|
+
enhancedOptions = _objectSpread2(_objectSpread2({}, options), {}, {
|
|
35533
|
+
includeMetadata: true
|
|
35534
|
+
});
|
|
35535
|
+
_context2.n = 2;
|
|
35536
|
+
return this.managers.componentDataManager.getDictionaryComponents(enhancedOptions);
|
|
35537
|
+
case 2:
|
|
35538
|
+
return _context2.a(2, _context2.v);
|
|
35539
|
+
case 3:
|
|
35540
|
+
_context2.p = 3;
|
|
35541
|
+
_t = _context2.v;
|
|
35542
|
+
console.error('❌ getDictionaryComponents(): Error retrieving available components:', _t);
|
|
35543
|
+
return _context2.a(2, []);
|
|
35544
|
+
}
|
|
35545
|
+
}, _callee2, this, [[1, 3]]);
|
|
35546
|
+
}));
|
|
35547
|
+
function getComponents() {
|
|
35548
|
+
return _getComponents.apply(this, arguments);
|
|
35119
35549
|
}
|
|
35120
|
-
|
|
35121
|
-
|
|
35550
|
+
return getComponents;
|
|
35551
|
+
}()
|
|
35122
35552
|
/**
|
|
35123
35553
|
* Get scene hierarchy with components, connectors, and gateways
|
|
35124
35554
|
* @param {Object} [options={}] - Configuration options for scene hierarchy listing
|
|
@@ -35144,6 +35574,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35144
35574
|
* // Filter by name pattern
|
|
35145
35575
|
* const sceneTowers = centralPlant.getSceneHierarchy({ name: 'cooling' });
|
|
35146
35576
|
*/
|
|
35577
|
+
)
|
|
35147
35578
|
}, {
|
|
35148
35579
|
key: "getSceneHierarchy",
|
|
35149
35580
|
value: function getSceneHierarchy() {
|
|
@@ -35192,6 +35623,90 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35192
35623
|
}
|
|
35193
35624
|
}
|
|
35194
35625
|
|
|
35626
|
+
/**
|
|
35627
|
+
* Extend component dictionary with additional components (e.g., from S3)
|
|
35628
|
+
* @param {Object} additionalComponents - Object with component definitions to add
|
|
35629
|
+
* @returns {Promise<boolean>} True if components were added successfully, false otherwise
|
|
35630
|
+
* @description Allows sandbox to register additional components (like S3 components) into the
|
|
35631
|
+
* component dictionary at runtime. These components will then be available through getComponents()
|
|
35632
|
+
* and can be used with addComponent().
|
|
35633
|
+
* @example
|
|
35634
|
+
* // Register S3 components
|
|
35635
|
+
* const s3Components = {
|
|
35636
|
+
* 'custom-pump-1.0.0': {
|
|
35637
|
+
* modelKey: 'CUSTOM-PUMP.glb',
|
|
35638
|
+
* name: 'Custom Pump',
|
|
35639
|
+
* category: 'pumps',
|
|
35640
|
+
* // ... other component properties
|
|
35641
|
+
* }
|
|
35642
|
+
* }
|
|
35643
|
+
* const success = await centralPlant.extendComponentDictionary(s3Components)
|
|
35644
|
+
*/
|
|
35645
|
+
}, {
|
|
35646
|
+
key: "extendComponentDictionary",
|
|
35647
|
+
value: (function () {
|
|
35648
|
+
var _extendComponentDictionary = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(additionalComponents) {
|
|
35649
|
+
return _regenerator().w(function (_context3) {
|
|
35650
|
+
while (1) switch (_context3.n) {
|
|
35651
|
+
case 0:
|
|
35652
|
+
if (this.managers.componentDataManager) {
|
|
35653
|
+
_context3.n = 1;
|
|
35654
|
+
break;
|
|
35655
|
+
}
|
|
35656
|
+
console.warn('⚠️ extendComponentDictionary(): Component data manager not available');
|
|
35657
|
+
return _context3.a(2, false);
|
|
35658
|
+
case 1:
|
|
35659
|
+
_context3.n = 2;
|
|
35660
|
+
return this.managers.componentDataManager.extendComponentDictionary(additionalComponents);
|
|
35661
|
+
case 2:
|
|
35662
|
+
return _context3.a(2, _context3.v);
|
|
35663
|
+
}
|
|
35664
|
+
}, _callee3, this);
|
|
35665
|
+
}));
|
|
35666
|
+
function extendComponentDictionary(_x2) {
|
|
35667
|
+
return _extendComponentDictionary.apply(this, arguments);
|
|
35668
|
+
}
|
|
35669
|
+
return extendComponentDictionary;
|
|
35670
|
+
}()
|
|
35671
|
+
/**
|
|
35672
|
+
* Remove S3 components from component dictionary
|
|
35673
|
+
* @returns {Promise<boolean>} True if components were removed successfully, false otherwise
|
|
35674
|
+
* @description Removes all S3 components from the component dictionary, typically called when
|
|
35675
|
+
* user signs out or when S3 components need to be refreshed
|
|
35676
|
+
* @example
|
|
35677
|
+
* // Remove all S3 components from dictionary
|
|
35678
|
+
* const success = await centralPlant.removeS3Components();
|
|
35679
|
+
* if (success) {
|
|
35680
|
+
* console.log('S3 components removed');
|
|
35681
|
+
* }
|
|
35682
|
+
*/
|
|
35683
|
+
)
|
|
35684
|
+
}, {
|
|
35685
|
+
key: "removeS3Components",
|
|
35686
|
+
value: (function () {
|
|
35687
|
+
var _removeS3Components = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
35688
|
+
return _regenerator().w(function (_context4) {
|
|
35689
|
+
while (1) switch (_context4.n) {
|
|
35690
|
+
case 0:
|
|
35691
|
+
if (this.managers.componentDataManager) {
|
|
35692
|
+
_context4.n = 1;
|
|
35693
|
+
break;
|
|
35694
|
+
}
|
|
35695
|
+
console.warn('⚠️ removeS3Components(): Component data manager not available');
|
|
35696
|
+
return _context4.a(2, false);
|
|
35697
|
+
case 1:
|
|
35698
|
+
_context4.n = 2;
|
|
35699
|
+
return this.managers.componentDataManager.removeS3Components();
|
|
35700
|
+
case 2:
|
|
35701
|
+
return _context4.a(2, _context4.v);
|
|
35702
|
+
}
|
|
35703
|
+
}, _callee4, this);
|
|
35704
|
+
}));
|
|
35705
|
+
function removeS3Components() {
|
|
35706
|
+
return _removeS3Components.apply(this, arguments);
|
|
35707
|
+
}
|
|
35708
|
+
return removeS3Components;
|
|
35709
|
+
}()
|
|
35195
35710
|
/**
|
|
35196
35711
|
* Select an object (component, connector, or gateway) in the scene by its ID
|
|
35197
35712
|
* @param {string} objectId - The UUID or name of the object to select
|
|
@@ -35228,6 +35743,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35228
35743
|
* centralPlant.selectComponent(targetObject.uuid);
|
|
35229
35744
|
* }
|
|
35230
35745
|
*/
|
|
35746
|
+
)
|
|
35231
35747
|
}, {
|
|
35232
35748
|
key: "selectComponent",
|
|
35233
35749
|
value: function selectComponent(objectId) {
|
|
@@ -35388,51 +35904,51 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35388
35904
|
}, {
|
|
35389
35905
|
key: "initialize2DViewport",
|
|
35390
35906
|
value: function () {
|
|
35391
|
-
var _initialize2DViewport = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
35907
|
+
var _initialize2DViewport = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(container) {
|
|
35392
35908
|
var viewType,
|
|
35393
35909
|
instanceKey,
|
|
35394
35910
|
success,
|
|
35395
|
-
|
|
35396
|
-
|
|
35397
|
-
return _regenerator().w(function (
|
|
35398
|
-
while (1) switch (
|
|
35911
|
+
_args5 = arguments,
|
|
35912
|
+
_t2;
|
|
35913
|
+
return _regenerator().w(function (_context5) {
|
|
35914
|
+
while (1) switch (_context5.n) {
|
|
35399
35915
|
case 0:
|
|
35400
|
-
viewType =
|
|
35401
|
-
instanceKey =
|
|
35916
|
+
viewType = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : 'top';
|
|
35917
|
+
instanceKey = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : null;
|
|
35402
35918
|
if (container) {
|
|
35403
|
-
|
|
35919
|
+
_context5.n = 1;
|
|
35404
35920
|
break;
|
|
35405
35921
|
}
|
|
35406
35922
|
console.warn('⚠️ initialize2DViewport(): No container provided');
|
|
35407
|
-
return
|
|
35923
|
+
return _context5.a(2, false);
|
|
35408
35924
|
case 1:
|
|
35409
35925
|
if (this.managers.viewport2DManager) {
|
|
35410
|
-
|
|
35926
|
+
_context5.n = 2;
|
|
35411
35927
|
break;
|
|
35412
35928
|
}
|
|
35413
35929
|
console.warn('⚠️ initialize2DViewport(): Viewport2D manager not available');
|
|
35414
|
-
return
|
|
35930
|
+
return _context5.a(2, false);
|
|
35415
35931
|
case 2:
|
|
35416
|
-
|
|
35417
|
-
|
|
35932
|
+
_context5.p = 2;
|
|
35933
|
+
_context5.n = 3;
|
|
35418
35934
|
return this.managers.viewport2DManager.initialize(container, viewType, instanceKey);
|
|
35419
35935
|
case 3:
|
|
35420
|
-
success =
|
|
35936
|
+
success = _context5.v;
|
|
35421
35937
|
if (success) {
|
|
35422
35938
|
console.log("\u2705 2D viewport initialized successfully (".concat(viewType, " view, key: ").concat(instanceKey || viewType, ")"));
|
|
35423
35939
|
} else {
|
|
35424
35940
|
console.warn("\u26A0\uFE0F Failed to initialize 2D viewport (".concat(viewType, " view)"));
|
|
35425
35941
|
}
|
|
35426
|
-
return
|
|
35942
|
+
return _context5.a(2, success);
|
|
35427
35943
|
case 4:
|
|
35428
|
-
|
|
35429
|
-
|
|
35430
|
-
console.error('❌ initialize2DViewport(): Error initializing 2D viewport:',
|
|
35431
|
-
return
|
|
35944
|
+
_context5.p = 4;
|
|
35945
|
+
_t2 = _context5.v;
|
|
35946
|
+
console.error('❌ initialize2DViewport(): Error initializing 2D viewport:', _t2);
|
|
35947
|
+
return _context5.a(2, false);
|
|
35432
35948
|
}
|
|
35433
|
-
},
|
|
35949
|
+
}, _callee5, this, [[2, 4]]);
|
|
35434
35950
|
}));
|
|
35435
|
-
function initialize2DViewport(
|
|
35951
|
+
function initialize2DViewport(_x3) {
|
|
35436
35952
|
return _initialize2DViewport.apply(this, arguments);
|
|
35437
35953
|
}
|
|
35438
35954
|
return initialize2DViewport;
|
|
@@ -35525,6 +36041,41 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35525
36041
|
}
|
|
35526
36042
|
}
|
|
35527
36043
|
|
|
36044
|
+
/**
|
|
36045
|
+
* Set a URL resolver function for model loading (for S3 authentication)
|
|
36046
|
+
* @param {Function} resolverFn - Function that takes modelKey and returns Promise<string> URL
|
|
36047
|
+
* @returns {boolean} True if resolver was set successfully, false otherwise
|
|
36048
|
+
* @description Allows sandbox to provide a resolver function that handles S3 authentication
|
|
36049
|
+
* and generates signed URLs for model files. This keeps central-plant free of AWS dependencies.
|
|
36050
|
+
* @example
|
|
36051
|
+
* // In sandbox with AWS Amplify Storage
|
|
36052
|
+
* centralPlant.setModelUrlResolver(async (modelKey) => {
|
|
36053
|
+
* const signedUrl = await Storage.get(`models/${modelKey}`)
|
|
36054
|
+
* return signedUrl
|
|
36055
|
+
* })
|
|
36056
|
+
*/
|
|
36057
|
+
}, {
|
|
36058
|
+
key: "setModelUrlResolver",
|
|
36059
|
+
value: function setModelUrlResolver(resolverFn) {
|
|
36060
|
+
if (!resolverFn || typeof resolverFn !== 'function') {
|
|
36061
|
+
console.warn('⚠️ setModelUrlResolver(): Resolver function is required');
|
|
36062
|
+
return false;
|
|
36063
|
+
}
|
|
36064
|
+
try {
|
|
36065
|
+
var _modelPreloader = this.getUtility('modelPreloader');
|
|
36066
|
+
if (!_modelPreloader) {
|
|
36067
|
+
console.warn('⚠️ setModelUrlResolver(): Model preloader utility not available');
|
|
36068
|
+
return false;
|
|
36069
|
+
}
|
|
36070
|
+
_modelPreloader.setUrlResolver(resolverFn);
|
|
36071
|
+
console.log('✅ setModelUrlResolver(): URL resolver set successfully');
|
|
36072
|
+
return true;
|
|
36073
|
+
} catch (error) {
|
|
36074
|
+
console.error('❌ setModelUrlResolver(): Error setting resolver:', error);
|
|
36075
|
+
return false;
|
|
36076
|
+
}
|
|
36077
|
+
}
|
|
36078
|
+
|
|
35528
36079
|
/**
|
|
35529
36080
|
* Initialize model preloading from component dictionary
|
|
35530
36081
|
* @param {string} [basePath='/library/'] - Base path for both dictionary and models (can be local path or S3 URL)
|
|
@@ -35543,22 +36094,22 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35543
36094
|
}, {
|
|
35544
36095
|
key: "initializeModelPreloading",
|
|
35545
36096
|
value: (function () {
|
|
35546
|
-
var _initializeModelPreloading = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36097
|
+
var _initializeModelPreloading = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
35547
36098
|
var basePath,
|
|
35548
36099
|
normalizedBasePath,
|
|
35549
36100
|
dictionaryPath,
|
|
35550
36101
|
modelsBasePath,
|
|
35551
36102
|
response,
|
|
35552
36103
|
componentDictionary,
|
|
35553
|
-
|
|
36104
|
+
_modelPreloader2,
|
|
35554
36105
|
progress,
|
|
35555
|
-
|
|
35556
|
-
|
|
35557
|
-
return _regenerator().w(function (
|
|
35558
|
-
while (1) switch (
|
|
36106
|
+
_args6 = arguments,
|
|
36107
|
+
_t3;
|
|
36108
|
+
return _regenerator().w(function (_context6) {
|
|
36109
|
+
while (1) switch (_context6.n) {
|
|
35559
36110
|
case 0:
|
|
35560
|
-
basePath =
|
|
35561
|
-
|
|
36111
|
+
basePath = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : '/library/';
|
|
36112
|
+
_context6.p = 1;
|
|
35562
36113
|
// Ensure basePath ends with a slash
|
|
35563
36114
|
normalizedBasePath = basePath.endsWith('/') ? basePath : "".concat(basePath, "/");
|
|
35564
36115
|
dictionaryPath = "".concat(normalizedBasePath, "component-dictionary.json");
|
|
@@ -35569,39 +36120,39 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35569
36120
|
console.log("\uFFFD Models path: ".concat(modelsBasePath));
|
|
35570
36121
|
|
|
35571
36122
|
// Load the component dictionary
|
|
35572
|
-
|
|
36123
|
+
_context6.n = 2;
|
|
35573
36124
|
return fetch(dictionaryPath);
|
|
35574
36125
|
case 2:
|
|
35575
|
-
response =
|
|
36126
|
+
response = _context6.v;
|
|
35576
36127
|
if (response.ok) {
|
|
35577
|
-
|
|
36128
|
+
_context6.n = 3;
|
|
35578
36129
|
break;
|
|
35579
36130
|
}
|
|
35580
36131
|
throw new Error("Failed to load component dictionary: ".concat(response.status));
|
|
35581
36132
|
case 3:
|
|
35582
|
-
|
|
36133
|
+
_context6.n = 4;
|
|
35583
36134
|
return response.json();
|
|
35584
36135
|
case 4:
|
|
35585
|
-
componentDictionary =
|
|
36136
|
+
componentDictionary = _context6.v;
|
|
35586
36137
|
console.log('📚 Component dictionary loaded:', Object.keys(componentDictionary));
|
|
35587
36138
|
|
|
35588
36139
|
// Start preloading all models with the specified base path
|
|
35589
|
-
|
|
35590
|
-
|
|
35591
|
-
return
|
|
36140
|
+
_modelPreloader2 = this.getUtility('modelPreloader');
|
|
36141
|
+
_context6.n = 5;
|
|
36142
|
+
return _modelPreloader2.preloadAllModels(componentDictionary, modelsBasePath);
|
|
35592
36143
|
case 5:
|
|
35593
|
-
progress =
|
|
36144
|
+
progress = _context6.v;
|
|
35594
36145
|
console.log('🎉 Model preloading completed:', progress);
|
|
35595
|
-
return
|
|
36146
|
+
return _context6.a(2, progress);
|
|
35596
36147
|
case 6:
|
|
35597
|
-
|
|
35598
|
-
|
|
35599
|
-
console.error('❌ Failed to initialize model preloading:',
|
|
35600
|
-
throw
|
|
36148
|
+
_context6.p = 6;
|
|
36149
|
+
_t3 = _context6.v;
|
|
36150
|
+
console.error('❌ Failed to initialize model preloading:', _t3);
|
|
36151
|
+
throw _t3;
|
|
35601
36152
|
case 7:
|
|
35602
|
-
return
|
|
36153
|
+
return _context6.a(2);
|
|
35603
36154
|
}
|
|
35604
|
-
},
|
|
36155
|
+
}, _callee6, this, [[1, 6]]);
|
|
35605
36156
|
}));
|
|
35606
36157
|
function initializeModelPreloading() {
|
|
35607
36158
|
return _initializeModelPreloading.apply(this, arguments);
|
|
@@ -35618,57 +36169,57 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35618
36169
|
}, {
|
|
35619
36170
|
key: "importScene",
|
|
35620
36171
|
value: (function () {
|
|
35621
|
-
var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
35622
|
-
var validation,
|
|
35623
|
-
return _regenerator().w(function (
|
|
35624
|
-
while (1) switch (
|
|
36172
|
+
var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(jsonData) {
|
|
36173
|
+
var validation, _t4;
|
|
36174
|
+
return _regenerator().w(function (_context7) {
|
|
36175
|
+
while (1) switch (_context7.n) {
|
|
35625
36176
|
case 0:
|
|
35626
36177
|
if (jsonData) {
|
|
35627
|
-
|
|
36178
|
+
_context7.n = 1;
|
|
35628
36179
|
break;
|
|
35629
36180
|
}
|
|
35630
36181
|
console.error('❌ No JSON data provided for import');
|
|
35631
|
-
return
|
|
36182
|
+
return _context7.a(2, false);
|
|
35632
36183
|
case 1:
|
|
35633
|
-
|
|
36184
|
+
_context7.p = 1;
|
|
35634
36185
|
// Validate scene data structure
|
|
35635
36186
|
validation = this.internals.validateAndAnalyzeSceneData(jsonData);
|
|
35636
36187
|
if (validation.isValid) {
|
|
35637
|
-
|
|
36188
|
+
_context7.n = 2;
|
|
35638
36189
|
break;
|
|
35639
36190
|
}
|
|
35640
36191
|
console.error('❌ Invalid scene data format:', validation.message);
|
|
35641
|
-
return
|
|
36192
|
+
return _context7.a(2, false);
|
|
35642
36193
|
case 2:
|
|
35643
|
-
|
|
36194
|
+
_context7.n = 3;
|
|
35644
36195
|
return this.setImportedSceneData(jsonData);
|
|
35645
36196
|
case 3:
|
|
35646
36197
|
if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
|
|
35647
|
-
|
|
36198
|
+
_context7.n = 5;
|
|
35648
36199
|
break;
|
|
35649
36200
|
}
|
|
35650
|
-
|
|
36201
|
+
_context7.n = 4;
|
|
35651
36202
|
return this.sceneViewer.sceneOperationsManager.loadSceneFromData(jsonData);
|
|
35652
36203
|
case 4:
|
|
35653
36204
|
console.log('✅ Scene imported successfully');
|
|
35654
|
-
return
|
|
36205
|
+
return _context7.a(2, true);
|
|
35655
36206
|
case 5:
|
|
35656
36207
|
console.error('❌ SceneViewer not available for scene loading');
|
|
35657
|
-
return
|
|
36208
|
+
return _context7.a(2, false);
|
|
35658
36209
|
case 6:
|
|
35659
|
-
|
|
36210
|
+
_context7.n = 8;
|
|
35660
36211
|
break;
|
|
35661
36212
|
case 7:
|
|
35662
|
-
|
|
35663
|
-
|
|
35664
|
-
console.error('❌ Error importing scene:',
|
|
35665
|
-
return
|
|
36213
|
+
_context7.p = 7;
|
|
36214
|
+
_t4 = _context7.v;
|
|
36215
|
+
console.error('❌ Error importing scene:', _t4);
|
|
36216
|
+
return _context7.a(2, false);
|
|
35666
36217
|
case 8:
|
|
35667
|
-
return
|
|
36218
|
+
return _context7.a(2);
|
|
35668
36219
|
}
|
|
35669
|
-
},
|
|
36220
|
+
}, _callee7, this, [[1, 7]]);
|
|
35670
36221
|
}));
|
|
35671
|
-
function importScene(
|
|
36222
|
+
function importScene(_x4) {
|
|
35672
36223
|
return _importScene.apply(this, arguments);
|
|
35673
36224
|
}
|
|
35674
36225
|
return importScene;
|
|
@@ -35690,33 +36241,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35690
36241
|
}, {
|
|
35691
36242
|
key: "exportSceneJSON",
|
|
35692
36243
|
value: (function () {
|
|
35693
|
-
var _exportSceneJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36244
|
+
var _exportSceneJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
|
|
35694
36245
|
var filename,
|
|
35695
|
-
|
|
35696
|
-
|
|
35697
|
-
return _regenerator().w(function (
|
|
35698
|
-
while (1) switch (
|
|
36246
|
+
_args8 = arguments,
|
|
36247
|
+
_t5;
|
|
36248
|
+
return _regenerator().w(function (_context8) {
|
|
36249
|
+
while (1) switch (_context8.n) {
|
|
35699
36250
|
case 0:
|
|
35700
|
-
filename =
|
|
36251
|
+
filename = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : null;
|
|
35701
36252
|
if (this.managers.sceneExportManager) {
|
|
35702
|
-
|
|
36253
|
+
_context8.n = 1;
|
|
35703
36254
|
break;
|
|
35704
36255
|
}
|
|
35705
36256
|
console.error('❌ Scene export manager not available');
|
|
35706
|
-
return
|
|
36257
|
+
return _context8.a(2, false);
|
|
35707
36258
|
case 1:
|
|
35708
|
-
|
|
35709
|
-
|
|
36259
|
+
_context8.p = 1;
|
|
36260
|
+
_context8.n = 2;
|
|
35710
36261
|
return this.managers.sceneExportManager.downloadSceneJSON(filename);
|
|
35711
36262
|
case 2:
|
|
35712
|
-
return
|
|
36263
|
+
return _context8.a(2, _context8.v);
|
|
35713
36264
|
case 3:
|
|
35714
|
-
|
|
35715
|
-
|
|
35716
|
-
console.error('❌ Error exporting scene as JSON:',
|
|
35717
|
-
return
|
|
36265
|
+
_context8.p = 3;
|
|
36266
|
+
_t5 = _context8.v;
|
|
36267
|
+
console.error('❌ Error exporting scene as JSON:', _t5);
|
|
36268
|
+
return _context8.a(2, false);
|
|
35718
36269
|
}
|
|
35719
|
-
},
|
|
36270
|
+
}, _callee8, this, [[1, 3]]);
|
|
35720
36271
|
}));
|
|
35721
36272
|
function exportSceneJSON() {
|
|
35722
36273
|
return _exportSceneJSON.apply(this, arguments);
|
|
@@ -35741,33 +36292,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35741
36292
|
}, {
|
|
35742
36293
|
key: "exportSceneGLTF",
|
|
35743
36294
|
value: (function () {
|
|
35744
|
-
var _exportSceneGLTF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36295
|
+
var _exportSceneGLTF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
|
|
35745
36296
|
var filename,
|
|
35746
|
-
|
|
35747
|
-
|
|
35748
|
-
return _regenerator().w(function (
|
|
35749
|
-
while (1) switch (
|
|
36297
|
+
_args9 = arguments,
|
|
36298
|
+
_t6;
|
|
36299
|
+
return _regenerator().w(function (_context9) {
|
|
36300
|
+
while (1) switch (_context9.n) {
|
|
35750
36301
|
case 0:
|
|
35751
|
-
filename =
|
|
36302
|
+
filename = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : null;
|
|
35752
36303
|
if (this.managers.sceneExportManager) {
|
|
35753
|
-
|
|
36304
|
+
_context9.n = 1;
|
|
35754
36305
|
break;
|
|
35755
36306
|
}
|
|
35756
36307
|
console.error('❌ Scene export manager not available');
|
|
35757
|
-
return
|
|
36308
|
+
return _context9.a(2, false);
|
|
35758
36309
|
case 1:
|
|
35759
|
-
|
|
35760
|
-
|
|
36310
|
+
_context9.p = 1;
|
|
36311
|
+
_context9.n = 2;
|
|
35761
36312
|
return this.managers.sceneExportManager.exportSceneAsGLTF(filename, false);
|
|
35762
36313
|
case 2:
|
|
35763
|
-
return
|
|
36314
|
+
return _context9.a(2, _context9.v);
|
|
35764
36315
|
case 3:
|
|
35765
|
-
|
|
35766
|
-
|
|
35767
|
-
console.error('❌ Error exporting scene as GLTF:',
|
|
35768
|
-
return
|
|
36316
|
+
_context9.p = 3;
|
|
36317
|
+
_t6 = _context9.v;
|
|
36318
|
+
console.error('❌ Error exporting scene as GLTF:', _t6);
|
|
36319
|
+
return _context9.a(2, false);
|
|
35769
36320
|
}
|
|
35770
|
-
},
|
|
36321
|
+
}, _callee9, this, [[1, 3]]);
|
|
35771
36322
|
}));
|
|
35772
36323
|
function exportSceneGLTF() {
|
|
35773
36324
|
return _exportSceneGLTF.apply(this, arguments);
|
|
@@ -35793,33 +36344,33 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35793
36344
|
}, {
|
|
35794
36345
|
key: "exportSceneGLB",
|
|
35795
36346
|
value: (function () {
|
|
35796
|
-
var _exportSceneGLB = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
36347
|
+
var _exportSceneGLB = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
|
|
35797
36348
|
var filename,
|
|
35798
|
-
|
|
35799
|
-
|
|
35800
|
-
return _regenerator().w(function (
|
|
35801
|
-
while (1) switch (
|
|
36349
|
+
_args0 = arguments,
|
|
36350
|
+
_t7;
|
|
36351
|
+
return _regenerator().w(function (_context0) {
|
|
36352
|
+
while (1) switch (_context0.n) {
|
|
35802
36353
|
case 0:
|
|
35803
|
-
filename =
|
|
36354
|
+
filename = _args0.length > 0 && _args0[0] !== undefined ? _args0[0] : null;
|
|
35804
36355
|
if (this.managers.sceneExportManager) {
|
|
35805
|
-
|
|
36356
|
+
_context0.n = 1;
|
|
35806
36357
|
break;
|
|
35807
36358
|
}
|
|
35808
36359
|
console.error('❌ Scene export manager not available');
|
|
35809
|
-
return
|
|
36360
|
+
return _context0.a(2, false);
|
|
35810
36361
|
case 1:
|
|
35811
|
-
|
|
35812
|
-
|
|
36362
|
+
_context0.p = 1;
|
|
36363
|
+
_context0.n = 2;
|
|
35813
36364
|
return this.managers.sceneExportManager.exportSceneAsGLB(filename);
|
|
35814
36365
|
case 2:
|
|
35815
|
-
return
|
|
36366
|
+
return _context0.a(2, _context0.v);
|
|
35816
36367
|
case 3:
|
|
35817
|
-
|
|
35818
|
-
|
|
35819
|
-
console.error('❌ Error exporting scene as GLB:',
|
|
35820
|
-
return
|
|
36368
|
+
_context0.p = 3;
|
|
36369
|
+
_t7 = _context0.v;
|
|
36370
|
+
console.error('❌ Error exporting scene as GLB:', _t7);
|
|
36371
|
+
return _context0.a(2, false);
|
|
35821
36372
|
}
|
|
35822
|
-
},
|
|
36373
|
+
}, _callee0, this, [[1, 3]]);
|
|
35823
36374
|
}));
|
|
35824
36375
|
function exportSceneGLB() {
|
|
35825
36376
|
return _exportSceneGLB.apply(this, arguments);
|
|
@@ -35858,18 +36409,18 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35858
36409
|
}, {
|
|
35859
36410
|
key: "loadSceneFromData",
|
|
35860
36411
|
value: (function () {
|
|
35861
|
-
var _loadSceneFromData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
35862
|
-
return _regenerator().w(function (
|
|
35863
|
-
while (1) switch (
|
|
36412
|
+
var _loadSceneFromData = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(sceneData) {
|
|
36413
|
+
return _regenerator().w(function (_context1) {
|
|
36414
|
+
while (1) switch (_context1.n) {
|
|
35864
36415
|
case 0:
|
|
35865
|
-
|
|
36416
|
+
_context1.n = 1;
|
|
35866
36417
|
return this.setImportedSceneData(sceneData);
|
|
35867
36418
|
case 1:
|
|
35868
|
-
return
|
|
36419
|
+
return _context1.a(2, true);
|
|
35869
36420
|
}
|
|
35870
|
-
},
|
|
36421
|
+
}, _callee1, this);
|
|
35871
36422
|
}));
|
|
35872
|
-
function loadSceneFromData(
|
|
36423
|
+
function loadSceneFromData(_x5) {
|
|
35873
36424
|
return _loadSceneFromData.apply(this, arguments);
|
|
35874
36425
|
}
|
|
35875
36426
|
return loadSceneFromData;
|