@2112-lab/central-plant 0.3.44 → 0.3.46
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 +557 -349
- package/dist/cjs/src/core/centralPlant.js +352 -241
- package/dist/cjs/src/core/centralPlantInternals.js +2 -0
- package/dist/cjs/src/index.js +0 -1
- package/dist/cjs/src/managers/behaviors/IoBehaviorManager.js +62 -7
- package/dist/cjs/src/managers/controls/componentDragManager.js +2 -1
- package/dist/cjs/src/managers/scene/collisionManager.js +143 -0
- package/dist/cjs/src/managers/scene/sceneExportManager.js +2 -0
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +10 -46
- package/dist/cjs/src/utils/animationTransformUtils.js +8 -1
- package/dist/cjs/src/utils/demoSceneUtils.js +1 -51
- package/dist/esm/src/core/centralPlant.js +352 -241
- package/dist/esm/src/core/centralPlantInternals.js +2 -0
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/managers/behaviors/IoBehaviorManager.js +62 -7
- package/dist/esm/src/managers/controls/componentDragManager.js +2 -1
- package/dist/esm/src/managers/scene/collisionManager.js +119 -0
- package/dist/esm/src/managers/scene/sceneExportManager.js +2 -0
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +10 -46
- package/dist/esm/src/utils/animationTransformUtils.js +8 -1
- package/dist/esm/src/utils/demoSceneUtils.js +2 -51
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ import { KeyboardControlsManager } from '../managers/controls/keyboardControlsMa
|
|
|
17
17
|
import { PathfindingManager } from '../managers/pathfinding/pathfindingManager.js';
|
|
18
18
|
import { PathFlowManager } from '../managers/pathfinding/PathFlowManager.js';
|
|
19
19
|
import { SceneOperationsManager } from '../managers/scene/sceneOperationsManager.js';
|
|
20
|
+
import { CollisionManager } from '../managers/scene/collisionManager.js';
|
|
20
21
|
import { AnimationManager } from '../managers/scene/animationManager.js';
|
|
21
22
|
import { CameraControlsManager } from '../managers/controls/cameraControlsManager.js';
|
|
22
23
|
import { ComponentDragManager } from '../managers/controls/componentDragManager.js';
|
|
@@ -145,6 +146,7 @@ var CentralPlantInternals = /*#__PURE__*/function () {
|
|
|
145
146
|
this.centralPlant.managers.keyboardControlsManager = new KeyboardControlsManager(this.centralPlant.sceneViewer);
|
|
146
147
|
this.centralPlant.managers.pathfindingManager = new PathfindingManager(this.centralPlant.sceneViewer);
|
|
147
148
|
this.centralPlant.managers.pathFlowManager = new PathFlowManager(this.centralPlant.sceneViewer);
|
|
149
|
+
this.centralPlant.managers.collisionManager = new CollisionManager(this.centralPlant.sceneViewer);
|
|
148
150
|
this.centralPlant.managers.sceneOperationsManager = new SceneOperationsManager(this.centralPlant.sceneViewer);
|
|
149
151
|
this.centralPlant.managers.animationManager = new AnimationManager(this.centralPlant.sceneViewer);
|
|
150
152
|
this.centralPlant.managers.cameraControlsManager = new CameraControlsManager(this.centralPlant.sceneViewer);
|
package/dist/esm/src/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export { buildCrossBehavior, buildIntraBehavior, normalizeBehavior, parseCrossBe
|
|
|
14
14
|
export { registerBehaviorsForComponent, reloadBehaviorsForDeviceAsset } from './utils/behaviorRegistration.js';
|
|
15
15
|
export { applyDefaultIoDeviceStates, getIoBehaviorManager, getScopedAttachmentKey, resolveDataPoints } from './utils/behaviorDispatch.js';
|
|
16
16
|
export { applyCrossComponentBehaviors, loadCrossComponentBehaviors, refreshSceneIntraBehaviors, reregisterSceneBehaviors, scanSceneIoEndpoints } from './utils/behaviorSceneUtils.js';
|
|
17
|
-
export { collectSceneLibraryIds,
|
|
17
|
+
export { collectSceneLibraryIds, getComponentDictionary } from './utils/demoSceneUtils.js';
|
|
18
18
|
export { applyModelRootTranslation, applyModelRootTranslationFromWorldBase, modelOffsetToWorldDelta } from './utils/animationTransformUtils.js';
|
|
19
19
|
export { ComponentManager } from './managers/components/componentManager.js';
|
|
20
20
|
export { AnimationManager } from './managers/scene/animationManager.js';
|
|
@@ -28,6 +28,13 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
28
28
|
/** @type {Map<string, Object[]>} cache key → data point definitions */
|
|
29
29
|
_this._dataPointsCache = new Map();
|
|
30
30
|
|
|
31
|
+
// Listen for object transformations to invalidate world-pose caches
|
|
32
|
+
if (_this.sceneViewer && typeof _this.sceneViewer.on === 'function') {
|
|
33
|
+
_this.sceneViewer.on('objectTransformed', function () {
|
|
34
|
+
return _this.invalidateCaches();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
31
38
|
/**
|
|
32
39
|
* Injected by the host application to read and write I/O device state.
|
|
33
40
|
* Set via configure(). Shape:
|
|
@@ -89,6 +96,13 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
89
96
|
console.warn("[IoBehaviorManager] Could not find mesh for animation \"".concat(anim.name || anim.stateVariable, "\" (uuid: ").concat(anim.meshUuid, ", name: \"").concat(anim.meshName, "\")"));
|
|
90
97
|
continue;
|
|
91
98
|
}
|
|
99
|
+
|
|
100
|
+
// Ensure world matrix is fresh before capturing rest world pose
|
|
101
|
+
if (typeof mesh.updateWorldMatrix === 'function') {
|
|
102
|
+
mesh.updateWorldMatrix(true, false);
|
|
103
|
+
} else {
|
|
104
|
+
mesh.updateMatrixWorld(true);
|
|
105
|
+
}
|
|
92
106
|
var worldPos = new THREE.Vector3();
|
|
93
107
|
mesh.getWorldPosition(worldPos);
|
|
94
108
|
var worldQuat = new THREE.Quaternion();
|
|
@@ -679,6 +693,40 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
679
693
|
this._attachmentParentMap.clear();
|
|
680
694
|
this._dataPointsCache.clear();
|
|
681
695
|
}
|
|
696
|
+
|
|
697
|
+
/**
|
|
698
|
+
* Invalidate world-space pose caches for all registered entries.
|
|
699
|
+
* Call this when components are moved or rotated to ensure behaviors
|
|
700
|
+
* recalculate their world-space rest pose.
|
|
701
|
+
*/
|
|
702
|
+
}, {
|
|
703
|
+
key: "invalidateCaches",
|
|
704
|
+
value: function invalidateCaches() {
|
|
705
|
+
var _iterator9 = _createForOfIteratorHelper(this._entries.values()),
|
|
706
|
+
_step9;
|
|
707
|
+
try {
|
|
708
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
709
|
+
var entryList = _step9.value;
|
|
710
|
+
var _iterator0 = _createForOfIteratorHelper(entryList),
|
|
711
|
+
_step0;
|
|
712
|
+
try {
|
|
713
|
+
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
714
|
+
var entry = _step0.value;
|
|
715
|
+
delete entry._restWorldCache;
|
|
716
|
+
}
|
|
717
|
+
} catch (err) {
|
|
718
|
+
_iterator0.e(err);
|
|
719
|
+
} finally {
|
|
720
|
+
_iterator0.f();
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
} catch (err) {
|
|
724
|
+
_iterator9.e(err);
|
|
725
|
+
} finally {
|
|
726
|
+
_iterator9.f();
|
|
727
|
+
}
|
|
728
|
+
this._dataPointsCache.clear();
|
|
729
|
+
}
|
|
682
730
|
}, {
|
|
683
731
|
key: "dispose",
|
|
684
732
|
value: function dispose() {
|
|
@@ -757,11 +805,11 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
757
805
|
var mapping = this._resolveMapping(anim, value);
|
|
758
806
|
if (!mapping) return;
|
|
759
807
|
var types = anim.transformTypes || [];
|
|
760
|
-
var
|
|
761
|
-
|
|
808
|
+
var _iterator1 = _createForOfIteratorHelper(types),
|
|
809
|
+
_step1;
|
|
762
810
|
try {
|
|
763
|
-
for (
|
|
764
|
-
var type =
|
|
811
|
+
for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
|
|
812
|
+
var type = _step1.value;
|
|
765
813
|
if (type === 'translation') {
|
|
766
814
|
this._applyTranslation(entry, mapping.transform);
|
|
767
815
|
} else if (type === 'rotation') {
|
|
@@ -771,9 +819,9 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
771
819
|
}
|
|
772
820
|
}
|
|
773
821
|
} catch (err) {
|
|
774
|
-
|
|
822
|
+
_iterator1.e(err);
|
|
775
823
|
} finally {
|
|
776
|
-
|
|
824
|
+
_iterator1.f();
|
|
777
825
|
}
|
|
778
826
|
}
|
|
779
827
|
|
|
@@ -933,7 +981,14 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
933
981
|
var savedQuat = mesh.quaternion.clone();
|
|
934
982
|
mesh.position.copy(origPos);
|
|
935
983
|
mesh.rotation.copy(origRot);
|
|
936
|
-
|
|
984
|
+
|
|
985
|
+
// Ensure all ancestors are updated so getWorldPosition is accurate
|
|
986
|
+
// even if a parent component was recently moved.
|
|
987
|
+
if (typeof mesh.updateWorldMatrix === 'function') {
|
|
988
|
+
mesh.updateWorldMatrix(true, false);
|
|
989
|
+
} else {
|
|
990
|
+
mesh.updateMatrixWorld(true);
|
|
991
|
+
}
|
|
937
992
|
var origWorldPos = new THREE.Vector3();
|
|
938
993
|
mesh.getWorldPosition(origWorldPos);
|
|
939
994
|
var origWorldQuat = new THREE.Quaternion();
|
|
@@ -643,6 +643,7 @@ var ComponentDragManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
643
643
|
// Find intersection with ground plane
|
|
644
644
|
var intersection = this.raycaster.ray.intersectPlane(this.dropPlane, this.dropIntersection);
|
|
645
645
|
if (intersection) {
|
|
646
|
+
var _this$sceneViewer$col;
|
|
646
647
|
// Apply 0.5 unit transform snapping to intersection point
|
|
647
648
|
var snappedPosition = this._applyTransformSnap(intersection);
|
|
648
649
|
this.dragData.previewObject.position.copy(snappedPosition);
|
|
@@ -650,7 +651,7 @@ var ComponentDragManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
650
651
|
|
|
651
652
|
// Check for overlap and update color accordingly
|
|
652
653
|
var wasOverlapping = this.dragData.isOverlapping;
|
|
653
|
-
this.dragData.isOverlapping = this.
|
|
654
|
+
this.dragData.isOverlapping = !!((_this$sceneViewer$col = this.sceneViewer.collisionManager) !== null && _this$sceneViewer$col !== void 0 && _this$sceneViewer$col.checkCollision(this.dragData.previewObject));
|
|
654
655
|
|
|
655
656
|
// Update color if overlap state changed
|
|
656
657
|
if (wasOverlapping !== this.dragData.isOverlapping) {
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { createClass as _createClass, createForOfIteratorHelper as _createForOfIteratorHelper, classCallCheck as _classCallCheck } from '../../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
+
import * as THREE from 'three';
|
|
3
|
+
|
|
4
|
+
var CollisionManager = /*#__PURE__*/function () {
|
|
5
|
+
/**
|
|
6
|
+
* @param {Object} sceneViewer - The scene viewer instance
|
|
7
|
+
*/
|
|
8
|
+
function CollisionManager(sceneViewer) {
|
|
9
|
+
_classCallCheck(this, CollisionManager);
|
|
10
|
+
this.sceneViewer = sceneViewer;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Check if a given object overlaps with any other relevant objects in the scene.
|
|
15
|
+
* @param {THREE.Object3D} object - The object to check for collisions
|
|
16
|
+
* @param {Array<string>} excludeTypes - Object types to exclude from checking (e.g. ['ground'])
|
|
17
|
+
* @returns {Object|null} Collision info {object, objectType} if collision detected, null otherwise
|
|
18
|
+
*/
|
|
19
|
+
return _createClass(CollisionManager, [{
|
|
20
|
+
key: "checkCollision",
|
|
21
|
+
value: function checkCollision(object) {
|
|
22
|
+
var _this$sceneViewer,
|
|
23
|
+
_this = this;
|
|
24
|
+
var excludeTypes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['isBaseGround', 'isBaseGrid', 'isBrickWall'];
|
|
25
|
+
if (!((_this$sceneViewer = this.sceneViewer) !== null && _this$sceneViewer !== void 0 && _this$sceneViewer.scene) || !object) return null;
|
|
26
|
+
|
|
27
|
+
// Compute high-quality bounding box for the object being checked
|
|
28
|
+
// We use setFromObject here because the target object just moved
|
|
29
|
+
var objectBBox = new THREE.Box3().setFromObject(object);
|
|
30
|
+
|
|
31
|
+
// Narrow down potential colliders
|
|
32
|
+
var collisionDetected = null;
|
|
33
|
+
|
|
34
|
+
// Optimization: Only check the root-level CP objects to avoid O(N^2) complexity with meshes
|
|
35
|
+
this.sceneViewer.scene.traverse(function (child) {
|
|
36
|
+
var _child$userData, _child$userData2, _child$userData3, _child$userData4, _child$userData5;
|
|
37
|
+
if (collisionDetected) return; // Short circuit
|
|
38
|
+
|
|
39
|
+
// Skip the object itself and its descendants
|
|
40
|
+
if (child === object || _this._isDescendantOf(object, child)) return;
|
|
41
|
+
|
|
42
|
+
// Filter by CP object types at the root level (skip internal meshes during traverse)
|
|
43
|
+
var isCPRootObject = ((_child$userData = child.userData) === null || _child$userData === void 0 ? void 0 : _child$userData.objectType) === 'component' || ((_child$userData2 = child.userData) === null || _child$userData2 === void 0 ? void 0 : _child$userData2.objectType) === 'segment' || ((_child$userData3 = child.userData) === null || _child$userData3 === void 0 ? void 0 : _child$userData3.objectType) === 'gateway' || ((_child$userData4 = child.userData) === null || _child$userData4 === void 0 ? void 0 : _child$userData4.objectType) === 'connector' || ((_child$userData5 = child.userData) === null || _child$userData5 === void 0 ? void 0 : _child$userData5.ioConfig); // IO Device
|
|
44
|
+
|
|
45
|
+
if (isCPRootObject && !_this._shouldExclude(child, excludeTypes)) {
|
|
46
|
+
// Use cached worldBoundingBox if available, otherwise compute it (and cache it)
|
|
47
|
+
var childBBox;
|
|
48
|
+
if (child.userData.worldBoundingBox && !child.userData.isMoving) {
|
|
49
|
+
var _min$x, _min$y, _min$z, _max$x, _max$y, _max$z;
|
|
50
|
+
// Use stored worldBoundingBox (handles array or Box3 format)
|
|
51
|
+
var min = child.userData.worldBoundingBox.min;
|
|
52
|
+
var max = child.userData.worldBoundingBox.max;
|
|
53
|
+
childBBox = new THREE.Box3(new THREE.Vector3((_min$x = min.x) !== null && _min$x !== void 0 ? _min$x : min[0], (_min$y = min.y) !== null && _min$y !== void 0 ? _min$y : min[1], (_min$z = min.z) !== null && _min$z !== void 0 ? _min$z : min[2]), new THREE.Vector3((_max$x = max.x) !== null && _max$x !== void 0 ? _max$x : max[0], (_max$y = max.y) !== null && _max$y !== void 0 ? _max$y : max[1], (_max$z = max.z) !== null && _max$z !== void 0 ? _max$z : max[2]));
|
|
54
|
+
} else {
|
|
55
|
+
// Fallback to high-quality computation for moving objects or first-time checks
|
|
56
|
+
childBBox = new THREE.Box3().setFromObject(child);
|
|
57
|
+
|
|
58
|
+
// Cache the result for next time (non-moving objects)
|
|
59
|
+
if (!child.userData.isMoving) {
|
|
60
|
+
child.userData.worldBoundingBox = {
|
|
61
|
+
min: [childBBox.min.x, childBBox.min.y, childBBox.min.z],
|
|
62
|
+
max: [childBBox.max.x, childBBox.max.y, childBBox.max.z]
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (objectBBox.intersectsBox(childBBox)) {
|
|
67
|
+
collisionDetected = {
|
|
68
|
+
object: child,
|
|
69
|
+
objectType: child.userData.objectType,
|
|
70
|
+
uuid: child.uuid,
|
|
71
|
+
name: child.name || child.userData.libraryId || child.uuid
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return collisionDetected;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Helper to check if a node is a descendant of a specific parent
|
|
81
|
+
* @private
|
|
82
|
+
*/
|
|
83
|
+
}, {
|
|
84
|
+
key: "_isDescendantOf",
|
|
85
|
+
value: function _isDescendantOf(parent, child) {
|
|
86
|
+
var node = child.parent;
|
|
87
|
+
while (node !== null) {
|
|
88
|
+
if (node === parent) return true;
|
|
89
|
+
node = node.parent;
|
|
90
|
+
}
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Helper to determine if an object should be excluded from collision checking
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
}, {
|
|
99
|
+
key: "_shouldExclude",
|
|
100
|
+
value: function _shouldExclude(object, excludeTypes) {
|
|
101
|
+
if (object.userData.isPreview) return true;
|
|
102
|
+
var _iterator = _createForOfIteratorHelper(excludeTypes),
|
|
103
|
+
_step;
|
|
104
|
+
try {
|
|
105
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
106
|
+
var type = _step.value;
|
|
107
|
+
if (object.userData[type]) return true;
|
|
108
|
+
}
|
|
109
|
+
} catch (err) {
|
|
110
|
+
_iterator.e(err);
|
|
111
|
+
} finally {
|
|
112
|
+
_iterator.f();
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
}]);
|
|
117
|
+
}();
|
|
118
|
+
|
|
119
|
+
export { CollisionManager };
|
|
@@ -145,6 +145,8 @@ var SceneExportManager = /*#__PURE__*/function () {
|
|
|
145
145
|
// Internal tracking - not needed in export
|
|
146
146
|
'initialPosition',
|
|
147
147
|
// Internal tracking - not needed in export
|
|
148
|
+
'attachedDevices',
|
|
149
|
+
// Stored in smart component dictionary, not scene JSON
|
|
148
150
|
// Exclude internal segment tracking properties
|
|
149
151
|
'segmentId',
|
|
150
152
|
// Internal tracking
|
|
@@ -1309,55 +1309,20 @@ var SceneOperationsManager = /*#__PURE__*/function () {
|
|
|
1309
1309
|
y: componentModel.scale.y,
|
|
1310
1310
|
z: componentModel.scale.z
|
|
1311
1311
|
},
|
|
1312
|
-
userData: _objectSpread2(_objectSpread2({},
|
|
1312
|
+
userData: _objectSpread2(_objectSpread2({}, function () {
|
|
1313
|
+
var ud = _objectSpread2({}, componentModel.userData);
|
|
1314
|
+
delete ud.attachedDevices; // Instance data belongs in dictionary, not scene JSON
|
|
1315
|
+
delete ud.isDeclared; // Runtime flag
|
|
1316
|
+
delete ud.originalUuid; // Runtime tracking
|
|
1317
|
+
return ud;
|
|
1318
|
+
}()), {}, {
|
|
1313
1319
|
worldBoundingBox: {
|
|
1314
1320
|
min: boundingBox.min.toArray(),
|
|
1315
1321
|
max: boundingBox.max.toArray()
|
|
1316
1322
|
}
|
|
1317
|
-
})
|
|
1318
|
-
children: []
|
|
1323
|
+
})
|
|
1319
1324
|
};
|
|
1320
1325
|
|
|
1321
|
-
// Process children (connectors, etc.) if they exist
|
|
1322
|
-
if (componentModel.children && componentModel.children.length > 0) {
|
|
1323
|
-
componentModel.children.forEach(function (child) {
|
|
1324
|
-
var _child$userData0, _child$userData1;
|
|
1325
|
-
var childType = ((_child$userData0 = child.userData) === null || _child$userData0 === void 0 ? void 0 : _child$userData0.objectType) || ((_child$userData1 = child.userData) === null || _child$userData1 === void 0 ? void 0 : _child$userData1.objectType);
|
|
1326
|
-
if (childType === 'connector') {
|
|
1327
|
-
var _child$geometry;
|
|
1328
|
-
var childBoundingBox = new THREE.Box3().setFromObject(child);
|
|
1329
|
-
var childSceneData = {
|
|
1330
|
-
uuid: child.uuid,
|
|
1331
|
-
name: child.name,
|
|
1332
|
-
type: child.type,
|
|
1333
|
-
position: {
|
|
1334
|
-
x: child.position.x,
|
|
1335
|
-
y: child.position.y,
|
|
1336
|
-
z: child.position.z
|
|
1337
|
-
},
|
|
1338
|
-
rotation: {
|
|
1339
|
-
x: THREE.MathUtils.radToDeg(child.rotation.x),
|
|
1340
|
-
y: THREE.MathUtils.radToDeg(child.rotation.y),
|
|
1341
|
-
z: THREE.MathUtils.radToDeg(child.rotation.z)
|
|
1342
|
-
},
|
|
1343
|
-
scale: {
|
|
1344
|
-
x: child.scale.x,
|
|
1345
|
-
y: child.scale.y,
|
|
1346
|
-
z: child.scale.z
|
|
1347
|
-
},
|
|
1348
|
-
userData: _objectSpread2(_objectSpread2({}, child.userData), {}, {
|
|
1349
|
-
worldBoundingBox: {
|
|
1350
|
-
min: childBoundingBox.min.toArray(),
|
|
1351
|
-
max: childBoundingBox.max.toArray()
|
|
1352
|
-
}
|
|
1353
|
-
}),
|
|
1354
|
-
geometry: ((_child$geometry = child.geometry) === null || _child$geometry === void 0 ? void 0 : _child$geometry.uuid) || 'CONNECTOR-GEO'
|
|
1355
|
-
};
|
|
1356
|
-
componentSceneData.children.push(childSceneData);
|
|
1357
|
-
}
|
|
1358
|
-
});
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
1326
|
// Add the component to the scene data
|
|
1362
1327
|
if (!currentSceneData.scene.children) {
|
|
1363
1328
|
currentSceneData.scene.children = [];
|
|
@@ -1366,7 +1331,6 @@ var SceneOperationsManager = /*#__PURE__*/function () {
|
|
|
1366
1331
|
console.log('✅ addComponentToSceneData: Component added to scene data successfully', {
|
|
1367
1332
|
componentId: componentModel.uuid,
|
|
1368
1333
|
libraryId: (_componentModel$userD = componentModel.userData) === null || _componentModel$userD === void 0 ? void 0 : _componentModel$userD.libraryId,
|
|
1369
|
-
childrenCount: componentSceneData.children.length,
|
|
1370
1334
|
totalSceneChildren: currentSceneData.scene.children.length
|
|
1371
1335
|
});
|
|
1372
1336
|
return true;
|
|
@@ -1407,8 +1371,8 @@ var SceneOperationsManager = /*#__PURE__*/function () {
|
|
|
1407
1371
|
if (segment.children && segment.children.length > 0) {
|
|
1408
1372
|
var childrenToRemove = _toConsumableArray(segment.children);
|
|
1409
1373
|
childrenToRemove.forEach(function (child) {
|
|
1410
|
-
var _child$
|
|
1411
|
-
if ((_child$
|
|
1374
|
+
var _child$userData0;
|
|
1375
|
+
if ((_child$userData0 = child.userData) !== null && _child$userData0 !== void 0 && _child$userData0.isPipeElbow) {
|
|
1412
1376
|
console.log("\uD83D\uDDD1\uFE0F Removing elbow child from segment before manualization: ".concat(child.uuid));
|
|
1413
1377
|
segment.remove(child);
|
|
1414
1378
|
if (child.geometry) child.geometry.dispose();
|
|
@@ -32,7 +32,14 @@ function modelOffsetToWorldDelta(modelRoot, offset, customQuat) {
|
|
|
32
32
|
function applyModelRootTranslation(mesh, modelRoot, origLocalPos, modelOffset, customQuat) {
|
|
33
33
|
if (!mesh || !modelRoot || !origLocalPos) return;
|
|
34
34
|
mesh.position.copy(origLocalPos);
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
// Ensure all ancestors are updated so getWorldPosition is accurate
|
|
37
|
+
// even if a parent component was recently moved.
|
|
38
|
+
if (typeof mesh.updateWorldMatrix === 'function') {
|
|
39
|
+
mesh.updateWorldMatrix(true, false);
|
|
40
|
+
} else {
|
|
41
|
+
mesh.updateMatrixWorld(true);
|
|
42
|
+
}
|
|
36
43
|
var origWorldPos = new THREE.Vector3();
|
|
37
44
|
mesh.getWorldPosition(origWorldPos);
|
|
38
45
|
var newWorldPos = origWorldPos.add(modelOffsetToWorldDelta(modelRoot, modelOffset, customQuat));
|
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { typeof as _typeof, objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
|
-
|
|
3
|
-
var _excluded = ["componentDefinitions"];
|
|
4
1
|
/**
|
|
5
|
-
* Helpers for portable demo scene JSON
|
|
2
|
+
* Helpers for portable demo scene JSON.
|
|
6
3
|
*/
|
|
7
4
|
|
|
8
|
-
function cloneDefinition(def) {
|
|
9
|
-
if (!def || _typeof(def) !== 'object') return null;
|
|
10
|
-
try {
|
|
11
|
-
return JSON.parse(JSON.stringify(def));
|
|
12
|
-
} catch (_unused) {
|
|
13
|
-
return _objectSpread2({}, def);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
5
|
/**
|
|
18
6
|
* Collect unique library IDs referenced by scene nodes.
|
|
19
7
|
* @param {Object} sceneData
|
|
@@ -35,43 +23,6 @@ function collectSceneLibraryIds(sceneData) {
|
|
|
35
23
|
return Array.from(ids);
|
|
36
24
|
}
|
|
37
25
|
|
|
38
|
-
/**
|
|
39
|
-
* Embed component/device definitions required by a scene into the JSON payload.
|
|
40
|
-
* @param {Object} sceneData
|
|
41
|
-
* @param {Record<string, Object>} componentDictionary
|
|
42
|
-
* @returns {Object}
|
|
43
|
-
*/
|
|
44
|
-
function embedComponentDefinitions(sceneData) {
|
|
45
|
-
var componentDictionary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
46
|
-
if (!sceneData || _typeof(sceneData) !== 'object') return sceneData;
|
|
47
|
-
var libraryIds = collectSceneLibraryIds(sceneData);
|
|
48
|
-
var componentDefinitions = {};
|
|
49
|
-
var deviceIds = new Set();
|
|
50
|
-
libraryIds.forEach(function (libraryId) {
|
|
51
|
-
var def = componentDictionary[libraryId];
|
|
52
|
-
if (!def) return;
|
|
53
|
-
componentDefinitions[libraryId] = cloneDefinition(def);
|
|
54
|
-
var attachedDevices = def.attachedDevices;
|
|
55
|
-
if (!attachedDevices || _typeof(attachedDevices) !== 'object') return;
|
|
56
|
-
Object.values(attachedDevices).forEach(function (att) {
|
|
57
|
-
if (att !== null && att !== void 0 && att.deviceId) deviceIds.add(att.deviceId);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
deviceIds.forEach(function (deviceId) {
|
|
61
|
-
if (componentDefinitions[deviceId]) return;
|
|
62
|
-
var deviceDef = componentDictionary[deviceId];
|
|
63
|
-
if (deviceDef) componentDefinitions[deviceId] = cloneDefinition(deviceDef);
|
|
64
|
-
});
|
|
65
|
-
if (!Object.keys(componentDefinitions).length) {
|
|
66
|
-
sceneData.componentDefinitions;
|
|
67
|
-
var rest = _objectWithoutProperties(sceneData, _excluded);
|
|
68
|
-
return rest;
|
|
69
|
-
}
|
|
70
|
-
return _objectSpread2(_objectSpread2({}, sceneData), {}, {
|
|
71
|
-
componentDefinitions: componentDefinitions
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
26
|
/**
|
|
76
27
|
* Resolve the live component dictionary from a CentralPlant instance.
|
|
77
28
|
* @param {Object} centralPlant
|
|
@@ -82,4 +33,4 @@ function getComponentDictionary(centralPlant) {
|
|
|
82
33
|
return (centralPlant === null || centralPlant === void 0 || (_centralPlant$getUtil = centralPlant.getUtility) === null || _centralPlant$getUtil === void 0 || (_centralPlant$getUtil = _centralPlant$getUtil.call(centralPlant, 'modelPreloader')) === null || _centralPlant$getUtil === void 0 ? void 0 : _centralPlant$getUtil.componentDictionary) || (centralPlant === null || centralPlant === void 0 || (_centralPlant$manager = centralPlant.managers) === null || _centralPlant$manager === void 0 || (_centralPlant$manager = _centralPlant$manager.componentDataManager) === null || _centralPlant$manager === void 0 ? void 0 : _centralPlant$manager.componentDictionary) || {};
|
|
83
34
|
}
|
|
84
35
|
|
|
85
|
-
export { collectSceneLibraryIds,
|
|
36
|
+
export { collectSceneLibraryIds, getComponentDictionary };
|