@2112-lab/central-plant 0.1.96 → 0.1.98
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 +89 -25
- package/dist/cjs/src/core/centralPlant.js +88 -24
- package/dist/cjs/src/managers/scene/sceneInitializationManager.js +1 -1
- package/dist/esm/src/core/centralPlant.js +88 -24
- package/dist/esm/src/managers/scene/sceneInitializationManager.js +1 -1
- package/package.json +1 -1
package/dist/bundle/index.js
CHANGED
|
@@ -24181,7 +24181,7 @@ var SceneInitializationManager = /*#__PURE__*/function () {
|
|
|
24181
24181
|
containerWidth = containerRect.width;
|
|
24182
24182
|
containerHeight = containerRect.height; // Create camera (Z-up coordinate system with flipped Y)
|
|
24183
24183
|
component.camera = new THREE__namespace.PerspectiveCamera(50, containerWidth / containerHeight, 0.01, 1000);
|
|
24184
|
-
component.camera.position.set(-8, -9,
|
|
24184
|
+
component.camera.position.set(-8, -9, 2); // Flipped Y direction
|
|
24185
24185
|
component.camera.up.set(0, 0, 1); // Set Z as up vector
|
|
24186
24186
|
|
|
24187
24187
|
// Create renderer
|
|
@@ -37233,7 +37233,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37233
37233
|
* Initialize the CentralPlant manager
|
|
37234
37234
|
*
|
|
37235
37235
|
* @constructor
|
|
37236
|
-
* @version 0.1.
|
|
37236
|
+
* @version 0.1.98
|
|
37237
37237
|
* @updated 2025-10-22
|
|
37238
37238
|
*
|
|
37239
37239
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -37275,6 +37275,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37275
37275
|
// Optional cache primer function (dependency injection)
|
|
37276
37276
|
_this.cachePrimer = null;
|
|
37277
37277
|
|
|
37278
|
+
// Optional resolver for fetching component definitions on demand (dependency injection)
|
|
37279
|
+
_this._componentDefinitionResolver = null;
|
|
37280
|
+
|
|
37278
37281
|
// Initialize utilities immediately (they don't need scene viewer)
|
|
37279
37282
|
_this.internals.initializeUtilities();
|
|
37280
37283
|
|
|
@@ -39477,6 +39480,36 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
39477
39480
|
}
|
|
39478
39481
|
}
|
|
39479
39482
|
|
|
39483
|
+
/**
|
|
39484
|
+
* Set a resolver function for fetching component definitions on demand.
|
|
39485
|
+
* When set, importScene() will automatically call this resolver for any
|
|
39486
|
+
* components referenced in the scene JSON that are not already in the
|
|
39487
|
+
* component dictionary. This keeps central-plant free of S3/AWS dependencies.
|
|
39488
|
+
* @param {Function} resolverFn - Function that takes an array of missing library IDs
|
|
39489
|
+
* and returns Promise<Object> keyed by UUID with component/device definitions.
|
|
39490
|
+
* @returns {boolean} True if resolver was set successfully
|
|
39491
|
+
* @example
|
|
39492
|
+
* centralPlant.setComponentDefinitionResolver(async (missingIds) => {
|
|
39493
|
+
* const registry = {}
|
|
39494
|
+
* await Promise.all(missingIds.map(async (id) => {
|
|
39495
|
+
* const res = await fetch(`https://my-bucket.s3.amazonaws.com/components/${id}/data.json`)
|
|
39496
|
+
* if (res.ok) registry[id] = await res.json()
|
|
39497
|
+
* }))
|
|
39498
|
+
* return registry
|
|
39499
|
+
* })
|
|
39500
|
+
*/
|
|
39501
|
+
}, {
|
|
39502
|
+
key: "setComponentDefinitionResolver",
|
|
39503
|
+
value: function setComponentDefinitionResolver(resolverFn) {
|
|
39504
|
+
if (!resolverFn || typeof resolverFn !== 'function') {
|
|
39505
|
+
console.warn('⚠️ setComponentDefinitionResolver(): Resolver function is required');
|
|
39506
|
+
return false;
|
|
39507
|
+
}
|
|
39508
|
+
this._componentDefinitionResolver = resolverFn;
|
|
39509
|
+
console.log('✅ setComponentDefinitionResolver(): Resolver set successfully');
|
|
39510
|
+
return true;
|
|
39511
|
+
}
|
|
39512
|
+
|
|
39480
39513
|
/**
|
|
39481
39514
|
* Initialize model preloading from component dictionary
|
|
39482
39515
|
* @param {string} [basePath='/library/'] - Base path for both dictionary and models (can be local path or S3 URL)
|
|
@@ -39571,7 +39604,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
39571
39604
|
key: "importScene",
|
|
39572
39605
|
value: (function () {
|
|
39573
39606
|
var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(jsonData) {
|
|
39574
|
-
var validation, _t4;
|
|
39607
|
+
var validation, missingIds, resolved, _t4, _t5;
|
|
39575
39608
|
return _regenerator().w(function (_context10) {
|
|
39576
39609
|
while (1) switch (_context10.n) {
|
|
39577
39610
|
case 0:
|
|
@@ -39592,33 +39625,64 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
39592
39625
|
console.error('❌ Invalid scene data format:', validation.message);
|
|
39593
39626
|
return _context10.a(2, false);
|
|
39594
39627
|
case 2:
|
|
39595
|
-
|
|
39596
|
-
|
|
39597
|
-
case 3:
|
|
39598
|
-
if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
|
|
39599
|
-
_context10.n = 5;
|
|
39628
|
+
if (!this._componentDefinitionResolver) {
|
|
39629
|
+
_context10.n = 8;
|
|
39600
39630
|
break;
|
|
39601
39631
|
}
|
|
39632
|
+
missingIds = this.getMissingLibraryIds(jsonData);
|
|
39633
|
+
if (!(missingIds.length > 0)) {
|
|
39634
|
+
_context10.n = 8;
|
|
39635
|
+
break;
|
|
39636
|
+
}
|
|
39637
|
+
_context10.p = 3;
|
|
39638
|
+
console.log("\uD83D\uDD0D importScene(): Resolving ".concat(missingIds.length, " missing component definition(s)..."));
|
|
39602
39639
|
_context10.n = 4;
|
|
39603
|
-
return this.
|
|
39640
|
+
return this._componentDefinitionResolver(missingIds);
|
|
39604
39641
|
case 4:
|
|
39605
|
-
|
|
39606
|
-
|
|
39642
|
+
resolved = _context10.v;
|
|
39643
|
+
if (!(resolved && _typeof(resolved) === 'object' && Object.keys(resolved).length > 0)) {
|
|
39644
|
+
_context10.n = 6;
|
|
39645
|
+
break;
|
|
39646
|
+
}
|
|
39647
|
+
_context10.n = 5;
|
|
39648
|
+
return this.extendComponentDictionary(resolved);
|
|
39607
39649
|
case 5:
|
|
39608
|
-
console.
|
|
39609
|
-
return _context10.a(2, false);
|
|
39650
|
+
console.log("\u2705 importScene(): Resolved ".concat(Object.keys(resolved).length, " component definition(s)"));
|
|
39610
39651
|
case 6:
|
|
39611
39652
|
_context10.n = 8;
|
|
39612
39653
|
break;
|
|
39613
39654
|
case 7:
|
|
39614
39655
|
_context10.p = 7;
|
|
39615
39656
|
_t4 = _context10.v;
|
|
39616
|
-
console.
|
|
39617
|
-
return _context10.a(2, false);
|
|
39657
|
+
console.warn('⚠️ importScene(): Component definition resolver failed, continuing with existing dictionary:', _t4);
|
|
39618
39658
|
case 8:
|
|
39659
|
+
_context10.n = 9;
|
|
39660
|
+
return this.setImportedSceneData(jsonData);
|
|
39661
|
+
case 9:
|
|
39662
|
+
if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
|
|
39663
|
+
_context10.n = 11;
|
|
39664
|
+
break;
|
|
39665
|
+
}
|
|
39666
|
+
_context10.n = 10;
|
|
39667
|
+
return this.sceneViewer.sceneOperationsManager.loadSceneFromData(jsonData);
|
|
39668
|
+
case 10:
|
|
39669
|
+
console.log('✅ Scene imported successfully');
|
|
39670
|
+
return _context10.a(2, true);
|
|
39671
|
+
case 11:
|
|
39672
|
+
console.error('❌ SceneViewer not available for scene loading');
|
|
39673
|
+
return _context10.a(2, false);
|
|
39674
|
+
case 12:
|
|
39675
|
+
_context10.n = 14;
|
|
39676
|
+
break;
|
|
39677
|
+
case 13:
|
|
39678
|
+
_context10.p = 13;
|
|
39679
|
+
_t5 = _context10.v;
|
|
39680
|
+
console.error('❌ Error importing scene:', _t5);
|
|
39681
|
+
return _context10.a(2, false);
|
|
39682
|
+
case 14:
|
|
39619
39683
|
return _context10.a(2);
|
|
39620
39684
|
}
|
|
39621
|
-
}, _callee10, this, [[
|
|
39685
|
+
}, _callee10, this, [[3, 7], [1, 13]]);
|
|
39622
39686
|
}));
|
|
39623
39687
|
function importScene(_x6) {
|
|
39624
39688
|
return _importScene.apply(this, arguments);
|
|
@@ -39645,7 +39709,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
39645
39709
|
var _exportSceneJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
39646
39710
|
var filename,
|
|
39647
39711
|
_args11 = arguments,
|
|
39648
|
-
|
|
39712
|
+
_t6;
|
|
39649
39713
|
return _regenerator().w(function (_context11) {
|
|
39650
39714
|
while (1) switch (_context11.n) {
|
|
39651
39715
|
case 0:
|
|
@@ -39664,8 +39728,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
39664
39728
|
return _context11.a(2, _context11.v);
|
|
39665
39729
|
case 3:
|
|
39666
39730
|
_context11.p = 3;
|
|
39667
|
-
|
|
39668
|
-
console.error('❌ Error exporting scene as JSON:',
|
|
39731
|
+
_t6 = _context11.v;
|
|
39732
|
+
console.error('❌ Error exporting scene as JSON:', _t6);
|
|
39669
39733
|
return _context11.a(2, false);
|
|
39670
39734
|
}
|
|
39671
39735
|
}, _callee11, this, [[1, 3]]);
|
|
@@ -39696,7 +39760,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
39696
39760
|
var _exportSceneGLTF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
39697
39761
|
var filename,
|
|
39698
39762
|
_args12 = arguments,
|
|
39699
|
-
|
|
39763
|
+
_t7;
|
|
39700
39764
|
return _regenerator().w(function (_context12) {
|
|
39701
39765
|
while (1) switch (_context12.n) {
|
|
39702
39766
|
case 0:
|
|
@@ -39715,8 +39779,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
39715
39779
|
return _context12.a(2, _context12.v);
|
|
39716
39780
|
case 3:
|
|
39717
39781
|
_context12.p = 3;
|
|
39718
|
-
|
|
39719
|
-
console.error('❌ Error exporting scene as GLTF:',
|
|
39782
|
+
_t7 = _context12.v;
|
|
39783
|
+
console.error('❌ Error exporting scene as GLTF:', _t7);
|
|
39720
39784
|
return _context12.a(2, false);
|
|
39721
39785
|
}
|
|
39722
39786
|
}, _callee12, this, [[1, 3]]);
|
|
@@ -39748,7 +39812,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
39748
39812
|
var _exportSceneGLB = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
39749
39813
|
var filename,
|
|
39750
39814
|
_args13 = arguments,
|
|
39751
|
-
|
|
39815
|
+
_t8;
|
|
39752
39816
|
return _regenerator().w(function (_context13) {
|
|
39753
39817
|
while (1) switch (_context13.n) {
|
|
39754
39818
|
case 0:
|
|
@@ -39767,8 +39831,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
39767
39831
|
return _context13.a(2, _context13.v);
|
|
39768
39832
|
case 3:
|
|
39769
39833
|
_context13.p = 3;
|
|
39770
|
-
|
|
39771
|
-
console.error('❌ Error exporting scene as GLB:',
|
|
39834
|
+
_t8 = _context13.v;
|
|
39835
|
+
console.error('❌ Error exporting scene as GLB:', _t8);
|
|
39772
39836
|
return _context13.a(2, false);
|
|
39773
39837
|
}
|
|
39774
39838
|
}, _callee13, this, [[1, 3]]);
|
|
@@ -19,7 +19,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
19
19
|
* Initialize the CentralPlant manager
|
|
20
20
|
*
|
|
21
21
|
* @constructor
|
|
22
|
-
* @version 0.1.
|
|
22
|
+
* @version 0.1.98
|
|
23
23
|
* @updated 2025-10-22
|
|
24
24
|
*
|
|
25
25
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -61,6 +61,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
61
61
|
// Optional cache primer function (dependency injection)
|
|
62
62
|
_this.cachePrimer = null;
|
|
63
63
|
|
|
64
|
+
// Optional resolver for fetching component definitions on demand (dependency injection)
|
|
65
|
+
_this._componentDefinitionResolver = null;
|
|
66
|
+
|
|
64
67
|
// Initialize utilities immediately (they don't need scene viewer)
|
|
65
68
|
_this.internals.initializeUtilities();
|
|
66
69
|
|
|
@@ -2263,6 +2266,36 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2263
2266
|
}
|
|
2264
2267
|
}
|
|
2265
2268
|
|
|
2269
|
+
/**
|
|
2270
|
+
* Set a resolver function for fetching component definitions on demand.
|
|
2271
|
+
* When set, importScene() will automatically call this resolver for any
|
|
2272
|
+
* components referenced in the scene JSON that are not already in the
|
|
2273
|
+
* component dictionary. This keeps central-plant free of S3/AWS dependencies.
|
|
2274
|
+
* @param {Function} resolverFn - Function that takes an array of missing library IDs
|
|
2275
|
+
* and returns Promise<Object> keyed by UUID with component/device definitions.
|
|
2276
|
+
* @returns {boolean} True if resolver was set successfully
|
|
2277
|
+
* @example
|
|
2278
|
+
* centralPlant.setComponentDefinitionResolver(async (missingIds) => {
|
|
2279
|
+
* const registry = {}
|
|
2280
|
+
* await Promise.all(missingIds.map(async (id) => {
|
|
2281
|
+
* const res = await fetch(`https://my-bucket.s3.amazonaws.com/components/${id}/data.json`)
|
|
2282
|
+
* if (res.ok) registry[id] = await res.json()
|
|
2283
|
+
* }))
|
|
2284
|
+
* return registry
|
|
2285
|
+
* })
|
|
2286
|
+
*/
|
|
2287
|
+
}, {
|
|
2288
|
+
key: "setComponentDefinitionResolver",
|
|
2289
|
+
value: function setComponentDefinitionResolver(resolverFn) {
|
|
2290
|
+
if (!resolverFn || typeof resolverFn !== 'function') {
|
|
2291
|
+
console.warn('⚠️ setComponentDefinitionResolver(): Resolver function is required');
|
|
2292
|
+
return false;
|
|
2293
|
+
}
|
|
2294
|
+
this._componentDefinitionResolver = resolverFn;
|
|
2295
|
+
console.log('✅ setComponentDefinitionResolver(): Resolver set successfully');
|
|
2296
|
+
return true;
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2266
2299
|
/**
|
|
2267
2300
|
* Initialize model preloading from component dictionary
|
|
2268
2301
|
* @param {string} [basePath='/library/'] - Base path for both dictionary and models (can be local path or S3 URL)
|
|
@@ -2357,7 +2390,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2357
2390
|
key: "importScene",
|
|
2358
2391
|
value: (function () {
|
|
2359
2392
|
var _importScene = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee10(jsonData) {
|
|
2360
|
-
var validation, _t4;
|
|
2393
|
+
var validation, missingIds, resolved, _t4, _t5;
|
|
2361
2394
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context10) {
|
|
2362
2395
|
while (1) switch (_context10.n) {
|
|
2363
2396
|
case 0:
|
|
@@ -2378,33 +2411,64 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2378
2411
|
console.error('❌ Invalid scene data format:', validation.message);
|
|
2379
2412
|
return _context10.a(2, false);
|
|
2380
2413
|
case 2:
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2414
|
+
if (!this._componentDefinitionResolver) {
|
|
2415
|
+
_context10.n = 8;
|
|
2416
|
+
break;
|
|
2417
|
+
}
|
|
2418
|
+
missingIds = this.getMissingLibraryIds(jsonData);
|
|
2419
|
+
if (!(missingIds.length > 0)) {
|
|
2420
|
+
_context10.n = 8;
|
|
2386
2421
|
break;
|
|
2387
2422
|
}
|
|
2423
|
+
_context10.p = 3;
|
|
2424
|
+
console.log("\uD83D\uDD0D importScene(): Resolving ".concat(missingIds.length, " missing component definition(s)..."));
|
|
2388
2425
|
_context10.n = 4;
|
|
2389
|
-
return this.
|
|
2426
|
+
return this._componentDefinitionResolver(missingIds);
|
|
2390
2427
|
case 4:
|
|
2391
|
-
|
|
2392
|
-
|
|
2428
|
+
resolved = _context10.v;
|
|
2429
|
+
if (!(resolved && _rollupPluginBabelHelpers["typeof"](resolved) === 'object' && Object.keys(resolved).length > 0)) {
|
|
2430
|
+
_context10.n = 6;
|
|
2431
|
+
break;
|
|
2432
|
+
}
|
|
2433
|
+
_context10.n = 5;
|
|
2434
|
+
return this.extendComponentDictionary(resolved);
|
|
2393
2435
|
case 5:
|
|
2394
|
-
console.
|
|
2395
|
-
return _context10.a(2, false);
|
|
2436
|
+
console.log("\u2705 importScene(): Resolved ".concat(Object.keys(resolved).length, " component definition(s)"));
|
|
2396
2437
|
case 6:
|
|
2397
2438
|
_context10.n = 8;
|
|
2398
2439
|
break;
|
|
2399
2440
|
case 7:
|
|
2400
2441
|
_context10.p = 7;
|
|
2401
2442
|
_t4 = _context10.v;
|
|
2402
|
-
console.
|
|
2403
|
-
return _context10.a(2, false);
|
|
2443
|
+
console.warn('⚠️ importScene(): Component definition resolver failed, continuing with existing dictionary:', _t4);
|
|
2404
2444
|
case 8:
|
|
2445
|
+
_context10.n = 9;
|
|
2446
|
+
return this.setImportedSceneData(jsonData);
|
|
2447
|
+
case 9:
|
|
2448
|
+
if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
|
|
2449
|
+
_context10.n = 11;
|
|
2450
|
+
break;
|
|
2451
|
+
}
|
|
2452
|
+
_context10.n = 10;
|
|
2453
|
+
return this.sceneViewer.sceneOperationsManager.loadSceneFromData(jsonData);
|
|
2454
|
+
case 10:
|
|
2455
|
+
console.log('✅ Scene imported successfully');
|
|
2456
|
+
return _context10.a(2, true);
|
|
2457
|
+
case 11:
|
|
2458
|
+
console.error('❌ SceneViewer not available for scene loading');
|
|
2459
|
+
return _context10.a(2, false);
|
|
2460
|
+
case 12:
|
|
2461
|
+
_context10.n = 14;
|
|
2462
|
+
break;
|
|
2463
|
+
case 13:
|
|
2464
|
+
_context10.p = 13;
|
|
2465
|
+
_t5 = _context10.v;
|
|
2466
|
+
console.error('❌ Error importing scene:', _t5);
|
|
2467
|
+
return _context10.a(2, false);
|
|
2468
|
+
case 14:
|
|
2405
2469
|
return _context10.a(2);
|
|
2406
2470
|
}
|
|
2407
|
-
}, _callee10, this, [[
|
|
2471
|
+
}, _callee10, this, [[3, 7], [1, 13]]);
|
|
2408
2472
|
}));
|
|
2409
2473
|
function importScene(_x6) {
|
|
2410
2474
|
return _importScene.apply(this, arguments);
|
|
@@ -2431,7 +2495,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2431
2495
|
var _exportSceneJSON = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee11() {
|
|
2432
2496
|
var filename,
|
|
2433
2497
|
_args11 = arguments,
|
|
2434
|
-
|
|
2498
|
+
_t6;
|
|
2435
2499
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context11) {
|
|
2436
2500
|
while (1) switch (_context11.n) {
|
|
2437
2501
|
case 0:
|
|
@@ -2450,8 +2514,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2450
2514
|
return _context11.a(2, _context11.v);
|
|
2451
2515
|
case 3:
|
|
2452
2516
|
_context11.p = 3;
|
|
2453
|
-
|
|
2454
|
-
console.error('❌ Error exporting scene as JSON:',
|
|
2517
|
+
_t6 = _context11.v;
|
|
2518
|
+
console.error('❌ Error exporting scene as JSON:', _t6);
|
|
2455
2519
|
return _context11.a(2, false);
|
|
2456
2520
|
}
|
|
2457
2521
|
}, _callee11, this, [[1, 3]]);
|
|
@@ -2482,7 +2546,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2482
2546
|
var _exportSceneGLTF = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee12() {
|
|
2483
2547
|
var filename,
|
|
2484
2548
|
_args12 = arguments,
|
|
2485
|
-
|
|
2549
|
+
_t7;
|
|
2486
2550
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context12) {
|
|
2487
2551
|
while (1) switch (_context12.n) {
|
|
2488
2552
|
case 0:
|
|
@@ -2501,8 +2565,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2501
2565
|
return _context12.a(2, _context12.v);
|
|
2502
2566
|
case 3:
|
|
2503
2567
|
_context12.p = 3;
|
|
2504
|
-
|
|
2505
|
-
console.error('❌ Error exporting scene as GLTF:',
|
|
2568
|
+
_t7 = _context12.v;
|
|
2569
|
+
console.error('❌ Error exporting scene as GLTF:', _t7);
|
|
2506
2570
|
return _context12.a(2, false);
|
|
2507
2571
|
}
|
|
2508
2572
|
}, _callee12, this, [[1, 3]]);
|
|
@@ -2534,7 +2598,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2534
2598
|
var _exportSceneGLB = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee13() {
|
|
2535
2599
|
var filename,
|
|
2536
2600
|
_args13 = arguments,
|
|
2537
|
-
|
|
2601
|
+
_t8;
|
|
2538
2602
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context13) {
|
|
2539
2603
|
while (1) switch (_context13.n) {
|
|
2540
2604
|
case 0:
|
|
@@ -2553,8 +2617,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2553
2617
|
return _context13.a(2, _context13.v);
|
|
2554
2618
|
case 3:
|
|
2555
2619
|
_context13.p = 3;
|
|
2556
|
-
|
|
2557
|
-
console.error('❌ Error exporting scene as GLB:',
|
|
2620
|
+
_t8 = _context13.v;
|
|
2621
|
+
console.error('❌ Error exporting scene as GLB:', _t8);
|
|
2558
2622
|
return _context13.a(2, false);
|
|
2559
2623
|
}
|
|
2560
2624
|
}, _callee13, this, [[1, 3]]);
|
|
@@ -54,7 +54,7 @@ var SceneInitializationManager = /*#__PURE__*/function () {
|
|
|
54
54
|
containerWidth = containerRect.width;
|
|
55
55
|
containerHeight = containerRect.height; // Create camera (Z-up coordinate system with flipped Y)
|
|
56
56
|
component.camera = new THREE__namespace.PerspectiveCamera(50, containerWidth / containerHeight, 0.01, 1000);
|
|
57
|
-
component.camera.position.set(-8, -9,
|
|
57
|
+
component.camera.position.set(-8, -9, 2); // Flipped Y direction
|
|
58
58
|
component.camera.up.set(0, 0, 1); // Set Z as up vector
|
|
59
59
|
|
|
60
60
|
// Create renderer
|
|
@@ -15,7 +15,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
15
15
|
* Initialize the CentralPlant manager
|
|
16
16
|
*
|
|
17
17
|
* @constructor
|
|
18
|
-
* @version 0.1.
|
|
18
|
+
* @version 0.1.98
|
|
19
19
|
* @updated 2025-10-22
|
|
20
20
|
*
|
|
21
21
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -57,6 +57,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
57
57
|
// Optional cache primer function (dependency injection)
|
|
58
58
|
_this.cachePrimer = null;
|
|
59
59
|
|
|
60
|
+
// Optional resolver for fetching component definitions on demand (dependency injection)
|
|
61
|
+
_this._componentDefinitionResolver = null;
|
|
62
|
+
|
|
60
63
|
// Initialize utilities immediately (they don't need scene viewer)
|
|
61
64
|
_this.internals.initializeUtilities();
|
|
62
65
|
|
|
@@ -2259,6 +2262,36 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2259
2262
|
}
|
|
2260
2263
|
}
|
|
2261
2264
|
|
|
2265
|
+
/**
|
|
2266
|
+
* Set a resolver function for fetching component definitions on demand.
|
|
2267
|
+
* When set, importScene() will automatically call this resolver for any
|
|
2268
|
+
* components referenced in the scene JSON that are not already in the
|
|
2269
|
+
* component dictionary. This keeps central-plant free of S3/AWS dependencies.
|
|
2270
|
+
* @param {Function} resolverFn - Function that takes an array of missing library IDs
|
|
2271
|
+
* and returns Promise<Object> keyed by UUID with component/device definitions.
|
|
2272
|
+
* @returns {boolean} True if resolver was set successfully
|
|
2273
|
+
* @example
|
|
2274
|
+
* centralPlant.setComponentDefinitionResolver(async (missingIds) => {
|
|
2275
|
+
* const registry = {}
|
|
2276
|
+
* await Promise.all(missingIds.map(async (id) => {
|
|
2277
|
+
* const res = await fetch(`https://my-bucket.s3.amazonaws.com/components/${id}/data.json`)
|
|
2278
|
+
* if (res.ok) registry[id] = await res.json()
|
|
2279
|
+
* }))
|
|
2280
|
+
* return registry
|
|
2281
|
+
* })
|
|
2282
|
+
*/
|
|
2283
|
+
}, {
|
|
2284
|
+
key: "setComponentDefinitionResolver",
|
|
2285
|
+
value: function setComponentDefinitionResolver(resolverFn) {
|
|
2286
|
+
if (!resolverFn || typeof resolverFn !== 'function') {
|
|
2287
|
+
console.warn('⚠️ setComponentDefinitionResolver(): Resolver function is required');
|
|
2288
|
+
return false;
|
|
2289
|
+
}
|
|
2290
|
+
this._componentDefinitionResolver = resolverFn;
|
|
2291
|
+
console.log('✅ setComponentDefinitionResolver(): Resolver set successfully');
|
|
2292
|
+
return true;
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2262
2295
|
/**
|
|
2263
2296
|
* Initialize model preloading from component dictionary
|
|
2264
2297
|
* @param {string} [basePath='/library/'] - Base path for both dictionary and models (can be local path or S3 URL)
|
|
@@ -2353,7 +2386,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2353
2386
|
key: "importScene",
|
|
2354
2387
|
value: (function () {
|
|
2355
2388
|
var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(jsonData) {
|
|
2356
|
-
var validation, _t4;
|
|
2389
|
+
var validation, missingIds, resolved, _t4, _t5;
|
|
2357
2390
|
return _regenerator().w(function (_context10) {
|
|
2358
2391
|
while (1) switch (_context10.n) {
|
|
2359
2392
|
case 0:
|
|
@@ -2374,33 +2407,64 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2374
2407
|
console.error('❌ Invalid scene data format:', validation.message);
|
|
2375
2408
|
return _context10.a(2, false);
|
|
2376
2409
|
case 2:
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2410
|
+
if (!this._componentDefinitionResolver) {
|
|
2411
|
+
_context10.n = 8;
|
|
2412
|
+
break;
|
|
2413
|
+
}
|
|
2414
|
+
missingIds = this.getMissingLibraryIds(jsonData);
|
|
2415
|
+
if (!(missingIds.length > 0)) {
|
|
2416
|
+
_context10.n = 8;
|
|
2382
2417
|
break;
|
|
2383
2418
|
}
|
|
2419
|
+
_context10.p = 3;
|
|
2420
|
+
console.log("\uD83D\uDD0D importScene(): Resolving ".concat(missingIds.length, " missing component definition(s)..."));
|
|
2384
2421
|
_context10.n = 4;
|
|
2385
|
-
return this.
|
|
2422
|
+
return this._componentDefinitionResolver(missingIds);
|
|
2386
2423
|
case 4:
|
|
2387
|
-
|
|
2388
|
-
|
|
2424
|
+
resolved = _context10.v;
|
|
2425
|
+
if (!(resolved && _typeof(resolved) === 'object' && Object.keys(resolved).length > 0)) {
|
|
2426
|
+
_context10.n = 6;
|
|
2427
|
+
break;
|
|
2428
|
+
}
|
|
2429
|
+
_context10.n = 5;
|
|
2430
|
+
return this.extendComponentDictionary(resolved);
|
|
2389
2431
|
case 5:
|
|
2390
|
-
console.
|
|
2391
|
-
return _context10.a(2, false);
|
|
2432
|
+
console.log("\u2705 importScene(): Resolved ".concat(Object.keys(resolved).length, " component definition(s)"));
|
|
2392
2433
|
case 6:
|
|
2393
2434
|
_context10.n = 8;
|
|
2394
2435
|
break;
|
|
2395
2436
|
case 7:
|
|
2396
2437
|
_context10.p = 7;
|
|
2397
2438
|
_t4 = _context10.v;
|
|
2398
|
-
console.
|
|
2399
|
-
return _context10.a(2, false);
|
|
2439
|
+
console.warn('⚠️ importScene(): Component definition resolver failed, continuing with existing dictionary:', _t4);
|
|
2400
2440
|
case 8:
|
|
2441
|
+
_context10.n = 9;
|
|
2442
|
+
return this.setImportedSceneData(jsonData);
|
|
2443
|
+
case 9:
|
|
2444
|
+
if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
|
|
2445
|
+
_context10.n = 11;
|
|
2446
|
+
break;
|
|
2447
|
+
}
|
|
2448
|
+
_context10.n = 10;
|
|
2449
|
+
return this.sceneViewer.sceneOperationsManager.loadSceneFromData(jsonData);
|
|
2450
|
+
case 10:
|
|
2451
|
+
console.log('✅ Scene imported successfully');
|
|
2452
|
+
return _context10.a(2, true);
|
|
2453
|
+
case 11:
|
|
2454
|
+
console.error('❌ SceneViewer not available for scene loading');
|
|
2455
|
+
return _context10.a(2, false);
|
|
2456
|
+
case 12:
|
|
2457
|
+
_context10.n = 14;
|
|
2458
|
+
break;
|
|
2459
|
+
case 13:
|
|
2460
|
+
_context10.p = 13;
|
|
2461
|
+
_t5 = _context10.v;
|
|
2462
|
+
console.error('❌ Error importing scene:', _t5);
|
|
2463
|
+
return _context10.a(2, false);
|
|
2464
|
+
case 14:
|
|
2401
2465
|
return _context10.a(2);
|
|
2402
2466
|
}
|
|
2403
|
-
}, _callee10, this, [[
|
|
2467
|
+
}, _callee10, this, [[3, 7], [1, 13]]);
|
|
2404
2468
|
}));
|
|
2405
2469
|
function importScene(_x6) {
|
|
2406
2470
|
return _importScene.apply(this, arguments);
|
|
@@ -2427,7 +2491,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2427
2491
|
var _exportSceneJSON = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
|
|
2428
2492
|
var filename,
|
|
2429
2493
|
_args11 = arguments,
|
|
2430
|
-
|
|
2494
|
+
_t6;
|
|
2431
2495
|
return _regenerator().w(function (_context11) {
|
|
2432
2496
|
while (1) switch (_context11.n) {
|
|
2433
2497
|
case 0:
|
|
@@ -2446,8 +2510,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2446
2510
|
return _context11.a(2, _context11.v);
|
|
2447
2511
|
case 3:
|
|
2448
2512
|
_context11.p = 3;
|
|
2449
|
-
|
|
2450
|
-
console.error('❌ Error exporting scene as JSON:',
|
|
2513
|
+
_t6 = _context11.v;
|
|
2514
|
+
console.error('❌ Error exporting scene as JSON:', _t6);
|
|
2451
2515
|
return _context11.a(2, false);
|
|
2452
2516
|
}
|
|
2453
2517
|
}, _callee11, this, [[1, 3]]);
|
|
@@ -2478,7 +2542,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2478
2542
|
var _exportSceneGLTF = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
|
|
2479
2543
|
var filename,
|
|
2480
2544
|
_args12 = arguments,
|
|
2481
|
-
|
|
2545
|
+
_t7;
|
|
2482
2546
|
return _regenerator().w(function (_context12) {
|
|
2483
2547
|
while (1) switch (_context12.n) {
|
|
2484
2548
|
case 0:
|
|
@@ -2497,8 +2561,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2497
2561
|
return _context12.a(2, _context12.v);
|
|
2498
2562
|
case 3:
|
|
2499
2563
|
_context12.p = 3;
|
|
2500
|
-
|
|
2501
|
-
console.error('❌ Error exporting scene as GLTF:',
|
|
2564
|
+
_t7 = _context12.v;
|
|
2565
|
+
console.error('❌ Error exporting scene as GLTF:', _t7);
|
|
2502
2566
|
return _context12.a(2, false);
|
|
2503
2567
|
}
|
|
2504
2568
|
}, _callee12, this, [[1, 3]]);
|
|
@@ -2530,7 +2594,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2530
2594
|
var _exportSceneGLB = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
|
|
2531
2595
|
var filename,
|
|
2532
2596
|
_args13 = arguments,
|
|
2533
|
-
|
|
2597
|
+
_t8;
|
|
2534
2598
|
return _regenerator().w(function (_context13) {
|
|
2535
2599
|
while (1) switch (_context13.n) {
|
|
2536
2600
|
case 0:
|
|
@@ -2549,8 +2613,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2549
2613
|
return _context13.a(2, _context13.v);
|
|
2550
2614
|
case 3:
|
|
2551
2615
|
_context13.p = 3;
|
|
2552
|
-
|
|
2553
|
-
console.error('❌ Error exporting scene as GLB:',
|
|
2616
|
+
_t8 = _context13.v;
|
|
2617
|
+
console.error('❌ Error exporting scene as GLB:', _t8);
|
|
2554
2618
|
return _context13.a(2, false);
|
|
2555
2619
|
}
|
|
2556
2620
|
}, _callee13, this, [[1, 3]]);
|
|
@@ -30,7 +30,7 @@ var SceneInitializationManager = /*#__PURE__*/function () {
|
|
|
30
30
|
containerWidth = containerRect.width;
|
|
31
31
|
containerHeight = containerRect.height; // Create camera (Z-up coordinate system with flipped Y)
|
|
32
32
|
component.camera = new THREE.PerspectiveCamera(50, containerWidth / containerHeight, 0.01, 1000);
|
|
33
|
-
component.camera.position.set(-8, -9,
|
|
33
|
+
component.camera.position.set(-8, -9, 2); // Flipped Y direction
|
|
34
34
|
component.camera.up.set(0, 0, 1); // Set Z as up vector
|
|
35
35
|
|
|
36
36
|
// Create renderer
|