@2112-lab/central-plant 0.3.34 → 0.3.36
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 +632 -170
- package/dist/cjs/src/core/centralPlant.js +41 -17
- package/dist/cjs/src/core/centralPlantInternals.js +6 -2
- package/dist/cjs/src/core/sceneViewer.js +6 -24
- package/dist/cjs/src/managers/behaviors/IoBehaviorManager.js +510 -44
- package/dist/cjs/src/managers/cache/S3CacheService.js +2 -33
- package/dist/cjs/src/managers/cache/S3MetadataCacheService.js +0 -1
- package/dist/cjs/src/managers/components/componentDataManager.js +2 -6
- package/dist/cjs/src/managers/controls/transformControlsManager.js +32 -10
- package/dist/cjs/src/managers/scene/modelManager.js +11 -5
- package/dist/cjs/src/managers/scene/sceneExportManager.js +10 -3
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +11 -3
- package/dist/cjs/src/rendering/modelPreloader.js +1 -17
- package/dist/cjs/src/utils/ioDeviceUtils.js +0 -5
- package/dist/esm/src/core/centralPlant.js +41 -17
- package/dist/esm/src/core/centralPlantInternals.js +6 -2
- package/dist/esm/src/core/sceneViewer.js +6 -24
- package/dist/esm/src/managers/behaviors/IoBehaviorManager.js +511 -45
- package/dist/esm/src/managers/cache/S3CacheService.js +2 -33
- package/dist/esm/src/managers/cache/S3MetadataCacheService.js +0 -1
- package/dist/esm/src/managers/components/componentDataManager.js +2 -6
- package/dist/esm/src/managers/controls/transformControlsManager.js +32 -10
- package/dist/esm/src/managers/scene/modelManager.js +11 -5
- package/dist/esm/src/managers/scene/sceneExportManager.js +10 -3
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +11 -3
- package/dist/esm/src/rendering/modelPreloader.js +1 -17
- package/dist/esm/src/utils/ioDeviceUtils.js +0 -5
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
35
35
|
* Initialize the CentralPlant manager
|
|
36
36
|
*
|
|
37
37
|
* @constructor
|
|
38
|
-
* @version 0.3.
|
|
38
|
+
* @version 0.3.36
|
|
39
39
|
* @updated 2025-10-22
|
|
40
40
|
*
|
|
41
41
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -209,7 +209,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
209
209
|
key: "setImportedSceneData",
|
|
210
210
|
value: (function () {
|
|
211
211
|
var _setImportedSceneData = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee2(sceneData) {
|
|
212
|
-
var _this$importedSceneDa, _this$importedSceneDa2;
|
|
212
|
+
var _this$importedSceneDa, _this$importedSceneDa2, _this$importedSceneDa3, _this$sceneViewer;
|
|
213
|
+
var ioBehavMgr;
|
|
213
214
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context2) {
|
|
214
215
|
while (1) switch (_context2.n) {
|
|
215
216
|
case 0:
|
|
@@ -220,9 +221,21 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
220
221
|
console.log('📥 Imported scene data stored in CentralPlant:', {
|
|
221
222
|
connections: ((_this$importedSceneDa = this.importedSceneData.connections) === null || _this$importedSceneDa === void 0 ? void 0 : _this$importedSceneDa.length) || 0,
|
|
222
223
|
sceneObjects: ((_this$importedSceneDa2 = this.importedSceneData.scene) === null || _this$importedSceneDa2 === void 0 || (_this$importedSceneDa2 = _this$importedSceneDa2.children) === null || _this$importedSceneDa2 === void 0 ? void 0 : _this$importedSceneDa2.length) || 0,
|
|
224
|
+
behaviors: ((_this$importedSceneDa3 = this.importedSceneData.behaviors) === null || _this$importedSceneDa3 === void 0 ? void 0 : _this$importedSceneDa3.length) || 0,
|
|
223
225
|
timestamp: new Date().toISOString()
|
|
224
226
|
});
|
|
225
227
|
|
|
228
|
+
// Scene behaviors loaded
|
|
229
|
+
|
|
230
|
+
// Register behaviors with IoBehaviorManager
|
|
231
|
+
ioBehavMgr = (_this$sceneViewer = this.sceneViewer) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.managers) === null || _this$sceneViewer === void 0 ? void 0 : _this$sceneViewer.ioBehaviorManager;
|
|
232
|
+
if (ioBehavMgr) {
|
|
233
|
+
// Setting cross-component behaviors
|
|
234
|
+
ioBehavMgr.setCrossComponentBehaviors(this.importedSceneData.behaviors || []);
|
|
235
|
+
} else {
|
|
236
|
+
console.warn('[Behavior] ioBehaviorManager not available!');
|
|
237
|
+
}
|
|
238
|
+
|
|
226
239
|
// Reset component counter based on imported components to avoid ID conflicts
|
|
227
240
|
this.internals.resetComponentCounter();
|
|
228
241
|
case 2:
|
|
@@ -402,8 +415,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
402
415
|
}, {
|
|
403
416
|
key: "selectObject",
|
|
404
417
|
value: function selectObject(objectOrId) {
|
|
405
|
-
var _this$
|
|
406
|
-
if (!((_this$
|
|
418
|
+
var _this$sceneViewer2, _object;
|
|
419
|
+
if (!((_this$sceneViewer2 = this.sceneViewer) !== null && _this$sceneViewer2 !== void 0 && _this$sceneViewer2.transformManager)) {
|
|
407
420
|
console.warn('⚠️ Transform manager not initialized');
|
|
408
421
|
return false;
|
|
409
422
|
}
|
|
@@ -449,8 +462,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
449
462
|
}, {
|
|
450
463
|
key: "toggleObject",
|
|
451
464
|
value: function toggleObject(objectOrId) {
|
|
452
|
-
var _this$
|
|
453
|
-
if (!((_this$
|
|
465
|
+
var _this$sceneViewer3, _object2;
|
|
466
|
+
if (!((_this$sceneViewer3 = this.sceneViewer) !== null && _this$sceneViewer3 !== void 0 && _this$sceneViewer3.transformManager)) {
|
|
454
467
|
console.warn('⚠️ Transform manager not initialized');
|
|
455
468
|
return false;
|
|
456
469
|
}
|
|
@@ -486,8 +499,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
486
499
|
}, {
|
|
487
500
|
key: "deselectObject",
|
|
488
501
|
value: function deselectObject() {
|
|
489
|
-
var _this$
|
|
490
|
-
if (!((_this$
|
|
502
|
+
var _this$sceneViewer4;
|
|
503
|
+
if (!((_this$sceneViewer4 = this.sceneViewer) !== null && _this$sceneViewer4 !== void 0 && _this$sceneViewer4.transformManager)) {
|
|
491
504
|
console.warn('⚠️ Transform manager not initialized');
|
|
492
505
|
return false;
|
|
493
506
|
}
|
|
@@ -716,7 +729,6 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
716
729
|
|
|
717
730
|
// Enable drag functionality for the specific element
|
|
718
731
|
this.sceneViewer.managers.componentDragManager.enableElementDrag(element, componentId);
|
|
719
|
-
console.log("\u2705 enableDragDrop(): Enabled drag and drop for ".concat(componentId));
|
|
720
732
|
return true;
|
|
721
733
|
} catch (error) {
|
|
722
734
|
console.error('❌ enableDragDrop(): Error enabling drag and drop:', error);
|
|
@@ -752,7 +764,6 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
752
764
|
}
|
|
753
765
|
try {
|
|
754
766
|
this.sceneViewer.managers.componentDragManager.disableElementDrag(element);
|
|
755
|
-
console.log('✅ disableDragDrop(): Disabled drag and drop for element');
|
|
756
767
|
return true;
|
|
757
768
|
} catch (error) {
|
|
758
769
|
console.error('❌ disableDragDrop(): Error disabling drag and drop:', error);
|
|
@@ -786,7 +797,6 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
786
797
|
if (this.sceneViewer.managers.componentDragManager) {
|
|
787
798
|
this.sceneViewer.managers.componentDragManager.setEnabled(enabled);
|
|
788
799
|
}
|
|
789
|
-
console.log("\u2705 setDragDropEnabled(): Drag and drop ".concat(enabled ? 'enabled' : 'disabled'));
|
|
790
800
|
return true;
|
|
791
801
|
} catch (error) {
|
|
792
802
|
console.error('❌ setDragDropEnabled(): Error setting drag and drop state:', error);
|
|
@@ -1101,9 +1111,9 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1101
1111
|
}, {
|
|
1102
1112
|
key: "setIoDeviceState",
|
|
1103
1113
|
value: function setIoDeviceState(attachmentId, stateId, value, parentUuid) {
|
|
1104
|
-
var _this$
|
|
1114
|
+
var _this$sceneViewer5, _this$sceneViewer6, _this$sceneViewer7;
|
|
1105
1115
|
// 1. Persist via state adapter if one has been configured
|
|
1106
|
-
var stateAdapter = (_this$
|
|
1116
|
+
var stateAdapter = (_this$sceneViewer5 = this.sceneViewer) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.managers) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.componentTooltipManager) === null || _this$sceneViewer5 === void 0 ? void 0 : _this$sceneViewer5._stateAdapter;
|
|
1107
1117
|
if (stateAdapter !== null && stateAdapter !== void 0 && stateAdapter.setState) {
|
|
1108
1118
|
var scopedKey = parentUuid ? "".concat(parentUuid, "::").concat(attachmentId) : attachmentId;
|
|
1109
1119
|
try {
|
|
@@ -1114,10 +1124,19 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1114
1124
|
}
|
|
1115
1125
|
|
|
1116
1126
|
// 2. Apply io-behavior changes
|
|
1117
|
-
(_this$
|
|
1127
|
+
var ioBehavMgr = (_this$sceneViewer6 = this.sceneViewer) === null || _this$sceneViewer6 === void 0 || (_this$sceneViewer6 = _this$sceneViewer6.managers) === null || _this$sceneViewer6 === void 0 ? void 0 : _this$sceneViewer6.ioBehaviorManager;
|
|
1128
|
+
if (ioBehavMgr) {
|
|
1129
|
+
var _this$importedSceneDa4;
|
|
1130
|
+
ioBehavMgr.triggerState(attachmentId, stateId, value, parentUuid);
|
|
1131
|
+
|
|
1132
|
+
// Evaluate cross-component behaviors if they exist in the imported scene
|
|
1133
|
+
if ((_this$importedSceneDa4 = this.importedSceneData) !== null && _this$importedSceneDa4 !== void 0 && _this$importedSceneDa4.behaviors) {
|
|
1134
|
+
ioBehavMgr.triggerCrossComponentBehaviors(this.importedSceneData.behaviors, parentUuid, attachmentId, stateId, value);
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1118
1137
|
|
|
1119
1138
|
// 3. Emit event for host apps that don't use the state adapter (e.g. cp3d-viewer)
|
|
1120
|
-
(_this$
|
|
1139
|
+
(_this$sceneViewer7 = this.sceneViewer) === null || _this$sceneViewer7 === void 0 || _this$sceneViewer7.emit('io-device-state-changed', {
|
|
1121
1140
|
attachmentId: attachmentId,
|
|
1122
1141
|
stateId: stateId,
|
|
1123
1142
|
value: value,
|
|
@@ -1139,8 +1158,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1139
1158
|
}, {
|
|
1140
1159
|
key: "getSceneAttachments",
|
|
1141
1160
|
value: function getSceneAttachments() {
|
|
1142
|
-
var _this$
|
|
1143
|
-
var scene = (_this$
|
|
1161
|
+
var _this$sceneViewer8;
|
|
1162
|
+
var scene = (_this$sceneViewer8 = this.sceneViewer) === null || _this$sceneViewer8 === void 0 ? void 0 : _this$sceneViewer8.scene;
|
|
1144
1163
|
if (!scene) return [];
|
|
1145
1164
|
var results = [];
|
|
1146
1165
|
scene.traverse(function (obj) {
|
|
@@ -2767,7 +2786,12 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2767
2786
|
}, {
|
|
2768
2787
|
key: "clearScene",
|
|
2769
2788
|
value: function clearScene() {
|
|
2789
|
+
var _this$sceneViewer9;
|
|
2770
2790
|
this.importedSceneData = null;
|
|
2791
|
+
var ioBehavMgr = (_this$sceneViewer9 = this.sceneViewer) === null || _this$sceneViewer9 === void 0 || (_this$sceneViewer9 = _this$sceneViewer9.managers) === null || _this$sceneViewer9 === void 0 ? void 0 : _this$sceneViewer9.ioBehaviorManager;
|
|
2792
|
+
if (ioBehavMgr) {
|
|
2793
|
+
ioBehavMgr.setCrossComponentBehaviors([]);
|
|
2794
|
+
}
|
|
2771
2795
|
if (this.sceneViewer && this.sceneViewer.scene) {
|
|
2772
2796
|
this.sceneViewer.scene.clear();
|
|
2773
2797
|
}
|
|
@@ -236,12 +236,10 @@ var CentralPlantInternals = /*#__PURE__*/function () {
|
|
|
236
236
|
if (this.centralPlant.sceneViewer.$refs.container && this.centralPlant.sceneViewer.camera && this.centralPlant.sceneViewer.scene) {
|
|
237
237
|
this.centralPlant.managers.tooltipsManager = new sceneTooltipsManager.SceneTooltipsManager(this.centralPlant.sceneViewer.$refs.container, this.centralPlant.sceneViewer.camera, this.centralPlant.sceneViewer.scene);
|
|
238
238
|
this.centralPlant.sceneViewer.tooltipsManager = this.centralPlant.managers.tooltipsManager;
|
|
239
|
-
console.log('🔍 Tooltip manager initialized:', this.centralPlant.managers.tooltipsManager);
|
|
240
239
|
|
|
241
240
|
// Initialize the component tooltip manager (screen-space tooltip on selection)
|
|
242
241
|
this.centralPlant.managers.componentTooltipManager = new componentTooltipManager.ComponentTooltipManager(this.centralPlant.sceneViewer);
|
|
243
242
|
this.centralPlant.sceneViewer.componentTooltipManager = this.centralPlant.managers.componentTooltipManager;
|
|
244
|
-
console.log('🔍 Component tooltip manager initialized');
|
|
245
243
|
}
|
|
246
244
|
}
|
|
247
245
|
|
|
@@ -1174,6 +1172,12 @@ var CentralPlantInternals = /*#__PURE__*/function () {
|
|
|
1174
1172
|
for (var _i = 0, _Object$entries = Object.entries(componentData.attachedDevices); _i < _Object$entries.length; _i++) {
|
|
1175
1173
|
if (_loop()) continue;
|
|
1176
1174
|
}
|
|
1175
|
+
|
|
1176
|
+
// Register component-level behaviors (intra-component io-device linking)
|
|
1177
|
+
if (componentData.behaviors && componentData.behaviors.length > 0) {
|
|
1178
|
+
// Registering ${componentData.behaviors.length} component-level behavior(s)
|
|
1179
|
+
ioBehavMgr.registerComponentBehaviors(componentId, componentData.behaviors);
|
|
1180
|
+
}
|
|
1177
1181
|
}
|
|
1178
1182
|
}
|
|
1179
1183
|
|
|
@@ -434,28 +434,10 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
434
434
|
},
|
|
435
435
|
onIODeviceDrag: function onIODeviceDrag(ioDeviceObject, signedDelta, isStart, hitMesh) {
|
|
436
436
|
if (isStart) {
|
|
437
|
-
var
|
|
438
|
-
//
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
var parentUuid = null;
|
|
442
|
-
var obj = ioDeviceObject.parent;
|
|
443
|
-
while (obj) {
|
|
444
|
-
var _obj$userData;
|
|
445
|
-
if (((_obj$userData = obj.userData) === null || _obj$userData === void 0 ? void 0 : _obj$userData.objectType) === 'component') {
|
|
446
|
-
parentUuid = obj.userData.originalUuid || obj.uuid;
|
|
447
|
-
break;
|
|
448
|
-
}
|
|
449
|
-
obj = obj.parent;
|
|
450
|
-
}
|
|
451
|
-
var attachmentId = (_ioDeviceObject$userD = ioDeviceObject.userData) === null || _ioDeviceObject$userD === void 0 ? void 0 : _ioDeviceObject$userD.attachmentId;
|
|
452
|
-
// When animated meshes are available, outline ONLY them so their
|
|
453
|
-
// silhouette is isolated and the outline ring is visible around
|
|
454
|
-
// them specifically (not swallowed by the larger device body).
|
|
455
|
-
// Fall back to the whole device group when none are registered.
|
|
456
|
-
var animatedMeshes = attachmentId && parentUuid ? (_this4$managers$ioBeh = (_this4$managers = _this4.managers) === null || _this4$managers === void 0 || (_this4$managers = _this4$managers.ioBehaviorManager) === null || _this4$managers === void 0 ? void 0 : _this4$managers.getAnimatedMeshes(parentUuid, attachmentId)) !== null && _this4$managers$ioBeh !== void 0 ? _this4$managers$ioBeh : [] : [];
|
|
457
|
-
var targets = animatedMeshes.length > 0 ? animatedMeshes : [ioDeviceObject];
|
|
458
|
-
(_this4$managers2 = _this4.managers) === null || _this4$managers2 === void 0 || (_this4$managers2 = _this4$managers2.ioOutlineManager) === null || _this4$managers2 === void 0 || _this4$managers2.setTargets(targets);
|
|
437
|
+
var _this4$managers;
|
|
438
|
+
// Outline only the specific mesh that was clicked
|
|
439
|
+
var targets = hitMesh ? [hitMesh] : [ioDeviceObject];
|
|
440
|
+
(_this4$managers = _this4.managers) === null || _this4$managers === void 0 || (_this4$managers = _this4$managers.ioOutlineManager) === null || _this4$managers === void 0 || _this4$managers.setTargets(targets);
|
|
459
441
|
}
|
|
460
442
|
if (!_this4.componentTooltipManager) return;
|
|
461
443
|
if (isStart) {
|
|
@@ -465,8 +447,8 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
465
447
|
}
|
|
466
448
|
},
|
|
467
449
|
onIODeviceDragEnd: function onIODeviceDragEnd(ioDeviceObject) {
|
|
468
|
-
var _this4$
|
|
469
|
-
(_this4$
|
|
450
|
+
var _this4$managers2;
|
|
451
|
+
(_this4$managers2 = _this4.managers) === null || _this4$managers2 === void 0 || (_this4$managers2 = _this4$managers2.ioOutlineManager) === null || _this4$managers2 === void 0 || _this4$managers2.setTargets([]);
|
|
470
452
|
if (_this4.componentTooltipManager) {
|
|
471
453
|
_this4.componentTooltipManager.endIODeviceDrag();
|
|
472
454
|
}
|