@2112-lab/central-plant 0.3.45 → 0.3.47
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 +635 -337
- package/dist/cjs/src/core/centralPlant.js +342 -218
- package/dist/cjs/src/core/centralPlantInternals.js +2 -0
- package/dist/cjs/src/core/sceneViewer.js +0 -1
- package/dist/cjs/src/managers/behaviors/IoBehaviorManager.js +1 -2
- package/dist/cjs/src/managers/components/componentDataManager.js +0 -1
- package/dist/cjs/src/managers/controls/componentDragManager.js +4 -8
- package/dist/cjs/src/managers/pathfinding/pathfindingManager.js +55 -1
- package/dist/cjs/src/managers/scene/collisionManager.js +142 -0
- package/dist/cjs/src/managers/scene/componentTooltipManager.js +2 -3
- package/dist/cjs/src/managers/scene/sceneExportManager.js +32 -11
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +17 -33
- package/dist/cjs/src/utils/behaviorDispatch.js +11 -42
- package/dist/cjs/src/utils/boundingBoxUtils.js +54 -8
- package/dist/cjs/src/utils/ioDeviceUtils.js +3 -9
- package/dist/esm/src/core/centralPlant.js +342 -218
- package/dist/esm/src/core/centralPlantInternals.js +2 -0
- package/dist/esm/src/core/sceneViewer.js +0 -1
- package/dist/esm/src/managers/behaviors/IoBehaviorManager.js +1 -2
- package/dist/esm/src/managers/components/componentDataManager.js +0 -1
- package/dist/esm/src/managers/controls/componentDragManager.js +4 -8
- package/dist/esm/src/managers/pathfinding/pathfindingManager.js +56 -2
- package/dist/esm/src/managers/scene/collisionManager.js +118 -0
- package/dist/esm/src/managers/scene/componentTooltipManager.js +2 -3
- package/dist/esm/src/managers/scene/sceneExportManager.js +33 -12
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +17 -33
- package/dist/esm/src/utils/behaviorDispatch.js +11 -42
- package/dist/esm/src/utils/boundingBoxUtils.js +55 -10
- package/dist/esm/src/utils/ioDeviceUtils.js +3 -9
- package/dist/index.d.ts +0 -6
- package/package.json +1 -1
|
@@ -211,6 +211,51 @@ function computeIODeviceBoundingBoxes(componentObject) {
|
|
|
211
211
|
return results;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Computes individual world-space bounding boxes for each connector child
|
|
216
|
+
* of a component.
|
|
217
|
+
*
|
|
218
|
+
* @param {THREE.Object3D} componentObject - The component's Three.js object
|
|
219
|
+
* @returns {Array<{uuid: string, userData: Object, worldBoundingBox: {min: number[], max: number[]}}>}
|
|
220
|
+
* Array of connector bounding box descriptors ready for injection into scene data
|
|
221
|
+
*/
|
|
222
|
+
function computeConnectorBoundingBoxes(componentObject) {
|
|
223
|
+
var results = [];
|
|
224
|
+
var _iterator2 = _rollupPluginBabelHelpers.createForOfIteratorHelper(componentObject.children),
|
|
225
|
+
_step2;
|
|
226
|
+
try {
|
|
227
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
228
|
+
var _child$userData2;
|
|
229
|
+
var child = _step2.value;
|
|
230
|
+
if (((_child$userData2 = child.userData) === null || _child$userData2 === void 0 ? void 0 : _child$userData2.objectType) !== 'connector') continue;
|
|
231
|
+
var bbox = new THREE__namespace.Box3().setFromObject(child);
|
|
232
|
+
|
|
233
|
+
// Fallback if mesh is too small or empty (sometimes connectors are just points)
|
|
234
|
+
if (bbox.isEmpty() || bbox.getSize(new THREE__namespace.Vector3()).length() < 0.01) {
|
|
235
|
+
var worldPos = new THREE__namespace.Vector3();
|
|
236
|
+
child.getWorldPosition(worldPos);
|
|
237
|
+
var size = 0.1;
|
|
238
|
+
bbox.setFromCenterAndSize(worldPos, new THREE__namespace.Vector3(size, size, size));
|
|
239
|
+
}
|
|
240
|
+
results.push({
|
|
241
|
+
uuid: child.uuid,
|
|
242
|
+
userData: _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, child.userData), {}, {
|
|
243
|
+
objectType: 'connector'
|
|
244
|
+
}),
|
|
245
|
+
worldBoundingBox: {
|
|
246
|
+
min: [bbox.min.x, bbox.min.y, bbox.min.z],
|
|
247
|
+
max: [bbox.max.x, bbox.max.y, bbox.max.z]
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
} catch (err) {
|
|
252
|
+
_iterator2.e(err);
|
|
253
|
+
} finally {
|
|
254
|
+
_iterator2.f();
|
|
255
|
+
}
|
|
256
|
+
return results;
|
|
257
|
+
}
|
|
258
|
+
|
|
214
259
|
/**
|
|
215
260
|
* Creates bounding box helpers for a selected object. For smart components
|
|
216
261
|
* (components with io-device children), this produces:
|
|
@@ -269,8 +314,8 @@ function createSelectionBoxHelpers(object) {
|
|
|
269
314
|
|
|
270
315
|
// Check if this object has io-device children (smart component)
|
|
271
316
|
var hasIODevices = (_object$children = object.children) === null || _object$children === void 0 ? void 0 : _object$children.some(function (child) {
|
|
272
|
-
var _child$
|
|
273
|
-
return ((_child$
|
|
317
|
+
var _child$userData3;
|
|
318
|
+
return ((_child$userData3 = child.userData) === null || _child$userData3 === void 0 ? void 0 : _child$userData3.objectType) === 'io-device';
|
|
274
319
|
});
|
|
275
320
|
if (hasIODevices) {
|
|
276
321
|
// 1. Create filtered helper for the component body
|
|
@@ -307,11 +352,11 @@ function createSelectionBoxHelpers(object) {
|
|
|
307
352
|
* @param {THREE.Scene} scene - The scene (for finding objects by uuid)
|
|
308
353
|
*/
|
|
309
354
|
function updateSelectionBoxHelpers(helpers, selectedObjects, scene) {
|
|
310
|
-
var
|
|
311
|
-
|
|
355
|
+
var _iterator3 = _rollupPluginBabelHelpers.createForOfIteratorHelper(helpers),
|
|
356
|
+
_step3;
|
|
312
357
|
try {
|
|
313
358
|
var _loop = function _loop() {
|
|
314
|
-
var helper =
|
|
359
|
+
var helper = _step3.value;
|
|
315
360
|
var _helper$userData = helper.userData,
|
|
316
361
|
sourceObjectUuid = _helper$userData.sourceObjectUuid,
|
|
317
362
|
isFiltered = _helper$userData.isFiltered,
|
|
@@ -342,16 +387,17 @@ function updateSelectionBoxHelpers(helpers, selectedObjects, scene) {
|
|
|
342
387
|
helper.update();
|
|
343
388
|
}
|
|
344
389
|
};
|
|
345
|
-
for (
|
|
390
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
346
391
|
if (_loop()) continue;
|
|
347
392
|
}
|
|
348
393
|
} catch (err) {
|
|
349
|
-
|
|
394
|
+
_iterator3.e(err);
|
|
350
395
|
} finally {
|
|
351
|
-
|
|
396
|
+
_iterator3.f();
|
|
352
397
|
}
|
|
353
398
|
}
|
|
354
399
|
|
|
400
|
+
exports.computeConnectorBoundingBoxes = computeConnectorBoundingBoxes;
|
|
355
401
|
exports.computeFilteredBoundingBox = computeFilteredBoundingBox;
|
|
356
402
|
exports.computeFilteredBoundingBoxCached = computeFilteredBoundingBoxCached;
|
|
357
403
|
exports.computeIODeviceBoundingBoxes = computeIODeviceBoundingBoxes;
|
|
@@ -27,7 +27,7 @@ function attachIODevicesToComponent(_x, _x2, _x3, _x4) {
|
|
|
27
27
|
}
|
|
28
28
|
function _attachIODevicesToComponent() {
|
|
29
29
|
_attachIODevicesToComponent = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee(componentModel, componentData, modelPreloader, parentComponentId) {
|
|
30
|
-
var attachedDevices, _i, _Object$entries, _Object$entries$_i, attachmentId, attachment, _modelPreloader$compo,
|
|
30
|
+
var attachedDevices, _i, _Object$entries, _Object$entries$_i, attachmentId, attachment, _modelPreloader$compo, _attachment$attachmen, _attachment$attachmen2, deviceData, cachedDevice, _modelPreloader$loadi, deviceModel, pos, rot, deg2rad, _t, _t2;
|
|
31
31
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context) {
|
|
32
32
|
while (1) switch (_context.n) {
|
|
33
33
|
case 0:
|
|
@@ -105,20 +105,14 @@ function _attachIODevicesToComponent() {
|
|
|
105
105
|
// Name the device model
|
|
106
106
|
deviceModel.name = "".concat(attachment.attachmentLabel || 'IO Device', " (").concat(attachmentId, ")");
|
|
107
107
|
|
|
108
|
-
// Set user data for identification
|
|
109
|
-
// component tooltip can render state displays without an extra lookup.
|
|
108
|
+
// Set user data for identification
|
|
110
109
|
deviceModel.userData = {
|
|
111
110
|
objectType: 'io-device',
|
|
112
111
|
deviceId: attachment.deviceId,
|
|
113
112
|
attachmentId: attachmentId,
|
|
114
113
|
attachmentLabel: attachment.attachmentLabel,
|
|
115
114
|
parentComponentId: parentComponentId,
|
|
116
|
-
deviceName: deviceData.name || ''
|
|
117
|
-
// Snapshot of the device's data point definitions (stateType, stateConfig, direction, etc.)
|
|
118
|
-
// ioConfig can use either 'states' (preferred) or legacy 'dataPoints' as the array key
|
|
119
|
-
dataPoints: ((_deviceData$ioConfig = deviceData.ioConfig) === null || _deviceData$ioConfig === void 0 ? void 0 : _deviceData$ioConfig.states) || ((_deviceData$ioConfig2 = deviceData.ioConfig) === null || _deviceData$ioConfig2 === void 0 ? void 0 : _deviceData$ioConfig2.dataPoints) || [],
|
|
120
|
-
// Device-level I/O direction: 'input' means the user can write state via the tooltip
|
|
121
|
-
ioDirection: ((_deviceData$ioConfig3 = deviceData.ioConfig) === null || _deviceData$ioConfig3 === void 0 ? void 0 : _deviceData$ioConfig3.direction) || 'output'
|
|
115
|
+
deviceName: deviceData.name || ''
|
|
122
116
|
};
|
|
123
117
|
|
|
124
118
|
// Position at the attachment point
|