@2112-lab/central-plant 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bundle/index.js
CHANGED
|
@@ -37214,7 +37214,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37214
37214
|
* Initialize the CentralPlant manager
|
|
37215
37215
|
*
|
|
37216
37216
|
* @constructor
|
|
37217
|
-
* @version 0.2.
|
|
37217
|
+
* @version 0.2.4
|
|
37218
37218
|
* @updated 2025-10-22
|
|
37219
37219
|
*
|
|
37220
37220
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -38248,6 +38248,69 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
38248
38248
|
bm.triggerState(attachmentId, stateId, value, parentUuid);
|
|
38249
38249
|
}
|
|
38250
38250
|
|
|
38251
|
+
/**
|
|
38252
|
+
* Set the state of an I/O device instance in the Three.js scene.
|
|
38253
|
+
*
|
|
38254
|
+
* This is the primary public API for driving IO device state changes from
|
|
38255
|
+
* external code (real-time data feeds, AI agents, automated tests, etc.).
|
|
38256
|
+
* It performs three coordinated actions in order:
|
|
38257
|
+
* 1. Persists the new value through the state adapter (Vuex in sandbox,
|
|
38258
|
+
* or any custom adapter injected via componentTooltipManager.configure())
|
|
38259
|
+
* so that the host application's store stays consistent.
|
|
38260
|
+
* 2. Evaluates all behaviors whose input matches this (attachmentId, stateId)
|
|
38261
|
+
* pair and applies the resulting property changes to Three.js meshes.
|
|
38262
|
+
* 3. Emits an 'io-device-state-changed' event on the sceneViewer so that
|
|
38263
|
+
* host applications without a Vuex store (e.g. cp3d-viewer) can react.
|
|
38264
|
+
*
|
|
38265
|
+
* @param {string} attachmentId - The attachment ID of the IO device (matches
|
|
38266
|
+
* the `attachmentId` stored in the Three.js object's userData)
|
|
38267
|
+
* @param {string} stateId - The data-point / state ID on the device (e.g. 'power', 'level')
|
|
38268
|
+
* @param {*} value - The new state value (boolean, number, string, etc.)
|
|
38269
|
+
* @param {string} [parentUuid] - UUID of the parent component instance.
|
|
38270
|
+
* Required when multiple instances of the same smart component share the
|
|
38271
|
+
* same attachmentId — prevents cross-instance state bleed.
|
|
38272
|
+
* @returns {boolean} True if the behavior system was reached; false if unavailable.
|
|
38273
|
+
* @example
|
|
38274
|
+
* // Toggle a push-button on a specific pump instance
|
|
38275
|
+
* centralPlant.setIoDeviceState('pump-push-button-01', 'power', true, pumpUuid)
|
|
38276
|
+
*
|
|
38277
|
+
* // Drive an analog level sensor (no parentUuid needed when only one instance)
|
|
38278
|
+
* centralPlant.setIoDeviceState('chiller-level-sensor-01', 'level', 0.75)
|
|
38279
|
+
*/
|
|
38280
|
+
}, {
|
|
38281
|
+
key: "setIoDeviceState",
|
|
38282
|
+
value: function setIoDeviceState(attachmentId, stateId, value, parentUuid) {
|
|
38283
|
+
var _this$sceneViewer0, _this$sceneViewer1, _this$sceneViewer10;
|
|
38284
|
+
var bm = (_this$sceneViewer0 = this.sceneViewer) === null || _this$sceneViewer0 === void 0 || (_this$sceneViewer0 = _this$sceneViewer0.managers) === null || _this$sceneViewer0 === void 0 ? void 0 : _this$sceneViewer0.behaviorManager;
|
|
38285
|
+
if (!bm) {
|
|
38286
|
+
console.warn('⚠️ setIoDeviceState(): BehaviorManager not available');
|
|
38287
|
+
return false;
|
|
38288
|
+
}
|
|
38289
|
+
|
|
38290
|
+
// 1. Persist via state adapter if one has been configured
|
|
38291
|
+
var stateAdapter = (_this$sceneViewer1 = this.sceneViewer) === null || _this$sceneViewer1 === void 0 || (_this$sceneViewer1 = _this$sceneViewer1.managers) === null || _this$sceneViewer1 === void 0 || (_this$sceneViewer1 = _this$sceneViewer1.componentTooltipManager) === null || _this$sceneViewer1 === void 0 ? void 0 : _this$sceneViewer1._stateAdapter;
|
|
38292
|
+
if (stateAdapter !== null && stateAdapter !== void 0 && stateAdapter.setState) {
|
|
38293
|
+
var scopedKey = parentUuid ? "".concat(parentUuid, "::").concat(attachmentId) : attachmentId;
|
|
38294
|
+
try {
|
|
38295
|
+
stateAdapter.setState(scopedKey, stateId, value);
|
|
38296
|
+
} catch (err) {
|
|
38297
|
+
console.warn('⚠️ setIoDeviceState(): stateAdapter.setState() threw:', err);
|
|
38298
|
+
}
|
|
38299
|
+
}
|
|
38300
|
+
|
|
38301
|
+
// 2. Apply Three.js behavior changes
|
|
38302
|
+
bm.triggerState(attachmentId, stateId, value, parentUuid);
|
|
38303
|
+
|
|
38304
|
+
// 3. Emit event for host apps that don't use the state adapter (e.g. cp3d-viewer)
|
|
38305
|
+
(_this$sceneViewer10 = this.sceneViewer) === null || _this$sceneViewer10 === void 0 || _this$sceneViewer10.emit('io-device-state-changed', {
|
|
38306
|
+
attachmentId: attachmentId,
|
|
38307
|
+
stateId: stateId,
|
|
38308
|
+
value: value,
|
|
38309
|
+
parentUuid: parentUuid || null
|
|
38310
|
+
});
|
|
38311
|
+
return true;
|
|
38312
|
+
}
|
|
38313
|
+
|
|
38251
38314
|
/**
|
|
38252
38315
|
* Return all io-device attachments present in the current Three.js scene.
|
|
38253
38316
|
* Each entry carries the attachmentId, an optional label, and the parent
|
|
@@ -38261,8 +38324,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
38261
38324
|
}, {
|
|
38262
38325
|
key: "getSceneAttachments",
|
|
38263
38326
|
value: function getSceneAttachments() {
|
|
38264
|
-
var _this$
|
|
38265
|
-
var scene = (_this$
|
|
38327
|
+
var _this$sceneViewer11;
|
|
38328
|
+
var scene = (_this$sceneViewer11 = this.sceneViewer) === null || _this$sceneViewer11 === void 0 ? void 0 : _this$sceneViewer11.scene;
|
|
38266
38329
|
if (!scene) return [];
|
|
38267
38330
|
var results = [];
|
|
38268
38331
|
scene.traverse(function (obj) {
|
|
@@ -40261,8 +40324,10 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
40261
40324
|
// Update renderer size (updateStyle=true to sync canvas CSS)
|
|
40262
40325
|
this.renderer.setSize(width, height, true);
|
|
40263
40326
|
|
|
40264
|
-
//
|
|
40265
|
-
this.
|
|
40327
|
+
// Immediately re-render so the canvas is never composited blank
|
|
40328
|
+
if (this.scene) {
|
|
40329
|
+
this.renderer.render(this.scene, this.camera);
|
|
40330
|
+
}
|
|
40266
40331
|
|
|
40267
40332
|
// Update tooltips manager if available
|
|
40268
40333
|
if (this.tooltipsManager) {
|
|
@@ -19,7 +19,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
19
19
|
* Initialize the CentralPlant manager
|
|
20
20
|
*
|
|
21
21
|
* @constructor
|
|
22
|
-
* @version 0.2.
|
|
22
|
+
* @version 0.2.4
|
|
23
23
|
* @updated 2025-10-22
|
|
24
24
|
*
|
|
25
25
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -1053,6 +1053,69 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1053
1053
|
bm.triggerState(attachmentId, stateId, value, parentUuid);
|
|
1054
1054
|
}
|
|
1055
1055
|
|
|
1056
|
+
/**
|
|
1057
|
+
* Set the state of an I/O device instance in the Three.js scene.
|
|
1058
|
+
*
|
|
1059
|
+
* This is the primary public API for driving IO device state changes from
|
|
1060
|
+
* external code (real-time data feeds, AI agents, automated tests, etc.).
|
|
1061
|
+
* It performs three coordinated actions in order:
|
|
1062
|
+
* 1. Persists the new value through the state adapter (Vuex in sandbox,
|
|
1063
|
+
* or any custom adapter injected via componentTooltipManager.configure())
|
|
1064
|
+
* so that the host application's store stays consistent.
|
|
1065
|
+
* 2. Evaluates all behaviors whose input matches this (attachmentId, stateId)
|
|
1066
|
+
* pair and applies the resulting property changes to Three.js meshes.
|
|
1067
|
+
* 3. Emits an 'io-device-state-changed' event on the sceneViewer so that
|
|
1068
|
+
* host applications without a Vuex store (e.g. cp3d-viewer) can react.
|
|
1069
|
+
*
|
|
1070
|
+
* @param {string} attachmentId - The attachment ID of the IO device (matches
|
|
1071
|
+
* the `attachmentId` stored in the Three.js object's userData)
|
|
1072
|
+
* @param {string} stateId - The data-point / state ID on the device (e.g. 'power', 'level')
|
|
1073
|
+
* @param {*} value - The new state value (boolean, number, string, etc.)
|
|
1074
|
+
* @param {string} [parentUuid] - UUID of the parent component instance.
|
|
1075
|
+
* Required when multiple instances of the same smart component share the
|
|
1076
|
+
* same attachmentId — prevents cross-instance state bleed.
|
|
1077
|
+
* @returns {boolean} True if the behavior system was reached; false if unavailable.
|
|
1078
|
+
* @example
|
|
1079
|
+
* // Toggle a push-button on a specific pump instance
|
|
1080
|
+
* centralPlant.setIoDeviceState('pump-push-button-01', 'power', true, pumpUuid)
|
|
1081
|
+
*
|
|
1082
|
+
* // Drive an analog level sensor (no parentUuid needed when only one instance)
|
|
1083
|
+
* centralPlant.setIoDeviceState('chiller-level-sensor-01', 'level', 0.75)
|
|
1084
|
+
*/
|
|
1085
|
+
}, {
|
|
1086
|
+
key: "setIoDeviceState",
|
|
1087
|
+
value: function setIoDeviceState(attachmentId, stateId, value, parentUuid) {
|
|
1088
|
+
var _this$sceneViewer0, _this$sceneViewer1, _this$sceneViewer10;
|
|
1089
|
+
var bm = (_this$sceneViewer0 = this.sceneViewer) === null || _this$sceneViewer0 === void 0 || (_this$sceneViewer0 = _this$sceneViewer0.managers) === null || _this$sceneViewer0 === void 0 ? void 0 : _this$sceneViewer0.behaviorManager;
|
|
1090
|
+
if (!bm) {
|
|
1091
|
+
console.warn('⚠️ setIoDeviceState(): BehaviorManager not available');
|
|
1092
|
+
return false;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// 1. Persist via state adapter if one has been configured
|
|
1096
|
+
var stateAdapter = (_this$sceneViewer1 = this.sceneViewer) === null || _this$sceneViewer1 === void 0 || (_this$sceneViewer1 = _this$sceneViewer1.managers) === null || _this$sceneViewer1 === void 0 || (_this$sceneViewer1 = _this$sceneViewer1.componentTooltipManager) === null || _this$sceneViewer1 === void 0 ? void 0 : _this$sceneViewer1._stateAdapter;
|
|
1097
|
+
if (stateAdapter !== null && stateAdapter !== void 0 && stateAdapter.setState) {
|
|
1098
|
+
var scopedKey = parentUuid ? "".concat(parentUuid, "::").concat(attachmentId) : attachmentId;
|
|
1099
|
+
try {
|
|
1100
|
+
stateAdapter.setState(scopedKey, stateId, value);
|
|
1101
|
+
} catch (err) {
|
|
1102
|
+
console.warn('⚠️ setIoDeviceState(): stateAdapter.setState() threw:', err);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
// 2. Apply Three.js behavior changes
|
|
1107
|
+
bm.triggerState(attachmentId, stateId, value, parentUuid);
|
|
1108
|
+
|
|
1109
|
+
// 3. Emit event for host apps that don't use the state adapter (e.g. cp3d-viewer)
|
|
1110
|
+
(_this$sceneViewer10 = this.sceneViewer) === null || _this$sceneViewer10 === void 0 || _this$sceneViewer10.emit('io-device-state-changed', {
|
|
1111
|
+
attachmentId: attachmentId,
|
|
1112
|
+
stateId: stateId,
|
|
1113
|
+
value: value,
|
|
1114
|
+
parentUuid: parentUuid || null
|
|
1115
|
+
});
|
|
1116
|
+
return true;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1056
1119
|
/**
|
|
1057
1120
|
* Return all io-device attachments present in the current Three.js scene.
|
|
1058
1121
|
* Each entry carries the attachmentId, an optional label, and the parent
|
|
@@ -1066,8 +1129,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1066
1129
|
}, {
|
|
1067
1130
|
key: "getSceneAttachments",
|
|
1068
1131
|
value: function getSceneAttachments() {
|
|
1069
|
-
var _this$
|
|
1070
|
-
var scene = (_this$
|
|
1132
|
+
var _this$sceneViewer11;
|
|
1133
|
+
var scene = (_this$sceneViewer11 = this.sceneViewer) === null || _this$sceneViewer11 === void 0 ? void 0 : _this$sceneViewer11.scene;
|
|
1071
1134
|
if (!scene) return [];
|
|
1072
1135
|
var results = [];
|
|
1073
1136
|
scene.traverse(function (obj) {
|
|
@@ -296,8 +296,10 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
296
296
|
// Update renderer size (updateStyle=true to sync canvas CSS)
|
|
297
297
|
this.renderer.setSize(width, height, true);
|
|
298
298
|
|
|
299
|
-
//
|
|
300
|
-
this.
|
|
299
|
+
// Immediately re-render so the canvas is never composited blank
|
|
300
|
+
if (this.scene) {
|
|
301
|
+
this.renderer.render(this.scene, this.camera);
|
|
302
|
+
}
|
|
301
303
|
|
|
302
304
|
// Update tooltips manager if available
|
|
303
305
|
if (this.tooltipsManager) {
|
|
@@ -15,7 +15,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
15
15
|
* Initialize the CentralPlant manager
|
|
16
16
|
*
|
|
17
17
|
* @constructor
|
|
18
|
-
* @version 0.2.
|
|
18
|
+
* @version 0.2.4
|
|
19
19
|
* @updated 2025-10-22
|
|
20
20
|
*
|
|
21
21
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -1049,6 +1049,69 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1049
1049
|
bm.triggerState(attachmentId, stateId, value, parentUuid);
|
|
1050
1050
|
}
|
|
1051
1051
|
|
|
1052
|
+
/**
|
|
1053
|
+
* Set the state of an I/O device instance in the Three.js scene.
|
|
1054
|
+
*
|
|
1055
|
+
* This is the primary public API for driving IO device state changes from
|
|
1056
|
+
* external code (real-time data feeds, AI agents, automated tests, etc.).
|
|
1057
|
+
* It performs three coordinated actions in order:
|
|
1058
|
+
* 1. Persists the new value through the state adapter (Vuex in sandbox,
|
|
1059
|
+
* or any custom adapter injected via componentTooltipManager.configure())
|
|
1060
|
+
* so that the host application's store stays consistent.
|
|
1061
|
+
* 2. Evaluates all behaviors whose input matches this (attachmentId, stateId)
|
|
1062
|
+
* pair and applies the resulting property changes to Three.js meshes.
|
|
1063
|
+
* 3. Emits an 'io-device-state-changed' event on the sceneViewer so that
|
|
1064
|
+
* host applications without a Vuex store (e.g. cp3d-viewer) can react.
|
|
1065
|
+
*
|
|
1066
|
+
* @param {string} attachmentId - The attachment ID of the IO device (matches
|
|
1067
|
+
* the `attachmentId` stored in the Three.js object's userData)
|
|
1068
|
+
* @param {string} stateId - The data-point / state ID on the device (e.g. 'power', 'level')
|
|
1069
|
+
* @param {*} value - The new state value (boolean, number, string, etc.)
|
|
1070
|
+
* @param {string} [parentUuid] - UUID of the parent component instance.
|
|
1071
|
+
* Required when multiple instances of the same smart component share the
|
|
1072
|
+
* same attachmentId — prevents cross-instance state bleed.
|
|
1073
|
+
* @returns {boolean} True if the behavior system was reached; false if unavailable.
|
|
1074
|
+
* @example
|
|
1075
|
+
* // Toggle a push-button on a specific pump instance
|
|
1076
|
+
* centralPlant.setIoDeviceState('pump-push-button-01', 'power', true, pumpUuid)
|
|
1077
|
+
*
|
|
1078
|
+
* // Drive an analog level sensor (no parentUuid needed when only one instance)
|
|
1079
|
+
* centralPlant.setIoDeviceState('chiller-level-sensor-01', 'level', 0.75)
|
|
1080
|
+
*/
|
|
1081
|
+
}, {
|
|
1082
|
+
key: "setIoDeviceState",
|
|
1083
|
+
value: function setIoDeviceState(attachmentId, stateId, value, parentUuid) {
|
|
1084
|
+
var _this$sceneViewer0, _this$sceneViewer1, _this$sceneViewer10;
|
|
1085
|
+
var bm = (_this$sceneViewer0 = this.sceneViewer) === null || _this$sceneViewer0 === void 0 || (_this$sceneViewer0 = _this$sceneViewer0.managers) === null || _this$sceneViewer0 === void 0 ? void 0 : _this$sceneViewer0.behaviorManager;
|
|
1086
|
+
if (!bm) {
|
|
1087
|
+
console.warn('⚠️ setIoDeviceState(): BehaviorManager not available');
|
|
1088
|
+
return false;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
// 1. Persist via state adapter if one has been configured
|
|
1092
|
+
var stateAdapter = (_this$sceneViewer1 = this.sceneViewer) === null || _this$sceneViewer1 === void 0 || (_this$sceneViewer1 = _this$sceneViewer1.managers) === null || _this$sceneViewer1 === void 0 || (_this$sceneViewer1 = _this$sceneViewer1.componentTooltipManager) === null || _this$sceneViewer1 === void 0 ? void 0 : _this$sceneViewer1._stateAdapter;
|
|
1093
|
+
if (stateAdapter !== null && stateAdapter !== void 0 && stateAdapter.setState) {
|
|
1094
|
+
var scopedKey = parentUuid ? "".concat(parentUuid, "::").concat(attachmentId) : attachmentId;
|
|
1095
|
+
try {
|
|
1096
|
+
stateAdapter.setState(scopedKey, stateId, value);
|
|
1097
|
+
} catch (err) {
|
|
1098
|
+
console.warn('⚠️ setIoDeviceState(): stateAdapter.setState() threw:', err);
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
// 2. Apply Three.js behavior changes
|
|
1103
|
+
bm.triggerState(attachmentId, stateId, value, parentUuid);
|
|
1104
|
+
|
|
1105
|
+
// 3. Emit event for host apps that don't use the state adapter (e.g. cp3d-viewer)
|
|
1106
|
+
(_this$sceneViewer10 = this.sceneViewer) === null || _this$sceneViewer10 === void 0 || _this$sceneViewer10.emit('io-device-state-changed', {
|
|
1107
|
+
attachmentId: attachmentId,
|
|
1108
|
+
stateId: stateId,
|
|
1109
|
+
value: value,
|
|
1110
|
+
parentUuid: parentUuid || null
|
|
1111
|
+
});
|
|
1112
|
+
return true;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1052
1115
|
/**
|
|
1053
1116
|
* Return all io-device attachments present in the current Three.js scene.
|
|
1054
1117
|
* Each entry carries the attachmentId, an optional label, and the parent
|
|
@@ -1062,8 +1125,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1062
1125
|
}, {
|
|
1063
1126
|
key: "getSceneAttachments",
|
|
1064
1127
|
value: function getSceneAttachments() {
|
|
1065
|
-
var _this$
|
|
1066
|
-
var scene = (_this$
|
|
1128
|
+
var _this$sceneViewer11;
|
|
1129
|
+
var scene = (_this$sceneViewer11 = this.sceneViewer) === null || _this$sceneViewer11 === void 0 ? void 0 : _this$sceneViewer11.scene;
|
|
1067
1130
|
if (!scene) return [];
|
|
1068
1131
|
var results = [];
|
|
1069
1132
|
scene.traverse(function (obj) {
|
|
@@ -292,8 +292,10 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
292
292
|
// Update renderer size (updateStyle=true to sync canvas CSS)
|
|
293
293
|
this.renderer.setSize(width, height, true);
|
|
294
294
|
|
|
295
|
-
//
|
|
296
|
-
this.
|
|
295
|
+
// Immediately re-render so the canvas is never composited blank
|
|
296
|
+
if (this.scene) {
|
|
297
|
+
this.renderer.render(this.scene, this.camera);
|
|
298
|
+
}
|
|
297
299
|
|
|
298
300
|
// Update tooltips manager if available
|
|
299
301
|
if (this.tooltipsManager) {
|