@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createForOfIteratorHelper as _createForOfIteratorHelper, construct as _construct, toConsumableArray as _toConsumableArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
1
|
+
import { createForOfIteratorHelper as _createForOfIteratorHelper, objectSpread2 as _objectSpread2, construct as _construct, toConsumableArray as _toConsumableArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import * as THREE from 'three';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -187,6 +187,51 @@ function computeIODeviceBoundingBoxes(componentObject) {
|
|
|
187
187
|
return results;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Computes individual world-space bounding boxes for each connector child
|
|
192
|
+
* of a component.
|
|
193
|
+
*
|
|
194
|
+
* @param {THREE.Object3D} componentObject - The component's Three.js object
|
|
195
|
+
* @returns {Array<{uuid: string, userData: Object, worldBoundingBox: {min: number[], max: number[]}}>}
|
|
196
|
+
* Array of connector bounding box descriptors ready for injection into scene data
|
|
197
|
+
*/
|
|
198
|
+
function computeConnectorBoundingBoxes(componentObject) {
|
|
199
|
+
var results = [];
|
|
200
|
+
var _iterator2 = _createForOfIteratorHelper(componentObject.children),
|
|
201
|
+
_step2;
|
|
202
|
+
try {
|
|
203
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
204
|
+
var _child$userData2;
|
|
205
|
+
var child = _step2.value;
|
|
206
|
+
if (((_child$userData2 = child.userData) === null || _child$userData2 === void 0 ? void 0 : _child$userData2.objectType) !== 'connector') continue;
|
|
207
|
+
var bbox = new THREE.Box3().setFromObject(child);
|
|
208
|
+
|
|
209
|
+
// Fallback if mesh is too small or empty (sometimes connectors are just points)
|
|
210
|
+
if (bbox.isEmpty() || bbox.getSize(new THREE.Vector3()).length() < 0.01) {
|
|
211
|
+
var worldPos = new THREE.Vector3();
|
|
212
|
+
child.getWorldPosition(worldPos);
|
|
213
|
+
var size = 0.1;
|
|
214
|
+
bbox.setFromCenterAndSize(worldPos, new THREE.Vector3(size, size, size));
|
|
215
|
+
}
|
|
216
|
+
results.push({
|
|
217
|
+
uuid: child.uuid,
|
|
218
|
+
userData: _objectSpread2(_objectSpread2({}, child.userData), {}, {
|
|
219
|
+
objectType: 'connector'
|
|
220
|
+
}),
|
|
221
|
+
worldBoundingBox: {
|
|
222
|
+
min: [bbox.min.x, bbox.min.y, bbox.min.z],
|
|
223
|
+
max: [bbox.max.x, bbox.max.y, bbox.max.z]
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
} catch (err) {
|
|
228
|
+
_iterator2.e(err);
|
|
229
|
+
} finally {
|
|
230
|
+
_iterator2.f();
|
|
231
|
+
}
|
|
232
|
+
return results;
|
|
233
|
+
}
|
|
234
|
+
|
|
190
235
|
/**
|
|
191
236
|
* Creates bounding box helpers for a selected object. For smart components
|
|
192
237
|
* (components with io-device children), this produces:
|
|
@@ -245,8 +290,8 @@ function createSelectionBoxHelpers(object) {
|
|
|
245
290
|
|
|
246
291
|
// Check if this object has io-device children (smart component)
|
|
247
292
|
var hasIODevices = (_object$children = object.children) === null || _object$children === void 0 ? void 0 : _object$children.some(function (child) {
|
|
248
|
-
var _child$
|
|
249
|
-
return ((_child$
|
|
293
|
+
var _child$userData3;
|
|
294
|
+
return ((_child$userData3 = child.userData) === null || _child$userData3 === void 0 ? void 0 : _child$userData3.objectType) === 'io-device';
|
|
250
295
|
});
|
|
251
296
|
if (hasIODevices) {
|
|
252
297
|
// 1. Create filtered helper for the component body
|
|
@@ -283,11 +328,11 @@ function createSelectionBoxHelpers(object) {
|
|
|
283
328
|
* @param {THREE.Scene} scene - The scene (for finding objects by uuid)
|
|
284
329
|
*/
|
|
285
330
|
function updateSelectionBoxHelpers(helpers, selectedObjects, scene) {
|
|
286
|
-
var
|
|
287
|
-
|
|
331
|
+
var _iterator3 = _createForOfIteratorHelper(helpers),
|
|
332
|
+
_step3;
|
|
288
333
|
try {
|
|
289
334
|
var _loop = function _loop() {
|
|
290
|
-
var helper =
|
|
335
|
+
var helper = _step3.value;
|
|
291
336
|
var _helper$userData = helper.userData,
|
|
292
337
|
sourceObjectUuid = _helper$userData.sourceObjectUuid,
|
|
293
338
|
isFiltered = _helper$userData.isFiltered,
|
|
@@ -318,14 +363,14 @@ function updateSelectionBoxHelpers(helpers, selectedObjects, scene) {
|
|
|
318
363
|
helper.update();
|
|
319
364
|
}
|
|
320
365
|
};
|
|
321
|
-
for (
|
|
366
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
322
367
|
if (_loop()) continue;
|
|
323
368
|
}
|
|
324
369
|
} catch (err) {
|
|
325
|
-
|
|
370
|
+
_iterator3.e(err);
|
|
326
371
|
} finally {
|
|
327
|
-
|
|
372
|
+
_iterator3.f();
|
|
328
373
|
}
|
|
329
374
|
}
|
|
330
375
|
|
|
331
|
-
export { computeFilteredBoundingBox, computeFilteredBoundingBoxCached, computeIODeviceBoundingBoxes, createSelectionBoxHelpers, updateSelectionBoxHelpers };
|
|
376
|
+
export { computeConnectorBoundingBoxes, computeFilteredBoundingBox, computeFilteredBoundingBoxCached, computeIODeviceBoundingBoxes, createSelectionBoxHelpers, updateSelectionBoxHelpers };
|
|
@@ -23,7 +23,7 @@ function attachIODevicesToComponent(_x, _x2, _x3, _x4) {
|
|
|
23
23
|
}
|
|
24
24
|
function _attachIODevicesToComponent() {
|
|
25
25
|
_attachIODevicesToComponent = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(componentModel, componentData, modelPreloader, parentComponentId) {
|
|
26
|
-
var attachedDevices, _i, _Object$entries, _Object$entries$_i, attachmentId, attachment, _modelPreloader$compo,
|
|
26
|
+
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;
|
|
27
27
|
return _regenerator().w(function (_context) {
|
|
28
28
|
while (1) switch (_context.n) {
|
|
29
29
|
case 0:
|
|
@@ -101,20 +101,14 @@ function _attachIODevicesToComponent() {
|
|
|
101
101
|
// Name the device model
|
|
102
102
|
deviceModel.name = "".concat(attachment.attachmentLabel || 'IO Device', " (").concat(attachmentId, ")");
|
|
103
103
|
|
|
104
|
-
// Set user data for identification
|
|
105
|
-
// component tooltip can render state displays without an extra lookup.
|
|
104
|
+
// Set user data for identification
|
|
106
105
|
deviceModel.userData = {
|
|
107
106
|
objectType: 'io-device',
|
|
108
107
|
deviceId: attachment.deviceId,
|
|
109
108
|
attachmentId: attachmentId,
|
|
110
109
|
attachmentLabel: attachment.attachmentLabel,
|
|
111
110
|
parentComponentId: parentComponentId,
|
|
112
|
-
deviceName: deviceData.name || ''
|
|
113
|
-
// Snapshot of the device's data point definitions (stateType, stateConfig, direction, etc.)
|
|
114
|
-
// ioConfig can use either 'states' (preferred) or legacy 'dataPoints' as the array key
|
|
115
|
-
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) || [],
|
|
116
|
-
// Device-level I/O direction: 'input' means the user can write state via the tooltip
|
|
117
|
-
ioDirection: ((_deviceData$ioConfig3 = deviceData.ioConfig) === null || _deviceData$ioConfig3 === void 0 ? void 0 : _deviceData$ioConfig3.direction) || 'output'
|
|
111
|
+
deviceName: deviceData.name || ''
|
|
118
112
|
};
|
|
119
113
|
|
|
120
114
|
// Position at the attachment point
|
package/dist/index.d.ts
CHANGED
|
@@ -35,11 +35,6 @@ export interface IoDeviceState {
|
|
|
35
35
|
direction?: 'input' | 'output'
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export interface IoDeviceConfig {
|
|
39
|
-
direction: 'input' | 'output'
|
|
40
|
-
states: IoDeviceState[]
|
|
41
|
-
}
|
|
42
|
-
|
|
43
38
|
export interface BehaviorMapping {
|
|
44
39
|
stateValue: any
|
|
45
40
|
transform?: { x?: number; y?: number; z?: number }
|
|
@@ -91,7 +86,6 @@ export interface IoDeviceAsset {
|
|
|
91
86
|
uuid: string
|
|
92
87
|
name: string
|
|
93
88
|
assetType: 'I/O Device'
|
|
94
|
-
ioConfig: IoDeviceConfig
|
|
95
89
|
behaviorConfig?: BehaviorEntry[]
|
|
96
90
|
meshNameMap?: Record<string, string>
|
|
97
91
|
}
|