@2112-lab/central-plant 0.3.28 → 0.3.30
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 +182 -77
- package/dist/cjs/src/core/centralPlant.js +3 -3
- package/dist/cjs/src/core/centralPlantInternals.js +7 -7
- package/dist/cjs/src/core/sceneViewer.js +6 -6
- package/dist/cjs/src/index.js +2 -2
- package/dist/cjs/src/managers/behaviors/IoBehaviorManager.js +672 -0
- package/dist/cjs/src/managers/controls/transformControlsManager.js +6 -2
- package/dist/cjs/src/managers/scene/componentTooltipManager.js +9 -9
- package/dist/cjs/src/managers/scene/modelManager.js +8 -8
- package/dist/esm/src/core/centralPlant.js +3 -3
- package/dist/esm/src/core/centralPlantInternals.js +7 -7
- package/dist/esm/src/core/sceneViewer.js +6 -6
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/managers/behaviors/IoBehaviorManager.js +648 -0
- package/dist/esm/src/managers/controls/transformControlsManager.js +6 -2
- package/dist/esm/src/managers/scene/componentTooltipManager.js +9 -9
- package/dist/esm/src/managers/scene/modelManager.js +8 -8
- package/package.json +1 -1
package/dist/bundle/index.js
CHANGED
|
@@ -4171,6 +4171,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
|
|
|
4171
4171
|
raycaster.setFromCamera(mouse, _this4.camera);
|
|
4172
4172
|
var allIntersects = raycaster.intersectObjects(_this4.scene.children, true);
|
|
4173
4173
|
var ioDeviceObject = null;
|
|
4174
|
+
var hitMesh = null;
|
|
4174
4175
|
var _iterator = _createForOfIteratorHelper(allIntersects),
|
|
4175
4176
|
_step;
|
|
4176
4177
|
try {
|
|
@@ -4185,7 +4186,10 @@ var TransformControlsManager = /*#__PURE__*/function () {
|
|
|
4185
4186
|
}
|
|
4186
4187
|
obj = obj.parent;
|
|
4187
4188
|
}
|
|
4188
|
-
if (ioDeviceObject)
|
|
4189
|
+
if (ioDeviceObject) {
|
|
4190
|
+
hitMesh = hit.object;
|
|
4191
|
+
break;
|
|
4192
|
+
}
|
|
4189
4193
|
}
|
|
4190
4194
|
} catch (err) {
|
|
4191
4195
|
_iterator.e(err);
|
|
@@ -4200,7 +4204,7 @@ var TransformControlsManager = /*#__PURE__*/function () {
|
|
|
4200
4204
|
_this4._ioDragStartY = event.clientY;
|
|
4201
4205
|
_this4._ioDragMoved = false;
|
|
4202
4206
|
if (_this4.orbitControls) _this4.orbitControls.enabled = false;
|
|
4203
|
-
_this4.callbacks.onIODeviceDrag(ioDeviceObject, 0, true);
|
|
4207
|
+
_this4.callbacks.onIODeviceDrag(ioDeviceObject, 0, true, hitMesh);
|
|
4204
4208
|
var onMove = function onMove(e) {
|
|
4205
4209
|
var dx = e.clientX - _this4._ioDragStartX;
|
|
4206
4210
|
var dy = e.clientY - _this4._ioDragStartY;
|
|
@@ -31309,7 +31313,7 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
31309
31313
|
key: "loadLibraryModel",
|
|
31310
31314
|
value: function () {
|
|
31311
31315
|
var _loadLibraryModel = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(targetMesh, jsonEntry, componentData) {
|
|
31312
|
-
var component, _jsonEntry$userData, _jsonEntry$userData2, _jsonEntry$userData3, originalProps, connectorChildren, gltfScene, libraryModel, _this$sceneViewer,
|
|
31316
|
+
var component, _jsonEntry$userData, _jsonEntry$userData2, _jsonEntry$userData3, originalProps, connectorChildren, gltfScene, libraryModel, _this$sceneViewer, ioBehavMgr, _loop, _i, _Object$entries, warmFn, _jsonEntry$userData4, _t;
|
|
31313
31317
|
return _regenerator().w(function (_context2) {
|
|
31314
31318
|
while (1) switch (_context2.n) {
|
|
31315
31319
|
case 0:
|
|
@@ -31352,22 +31356,22 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
31352
31356
|
_context2.n = 4;
|
|
31353
31357
|
return attachIODevicesToComponent(libraryModel, componentData, modelPreloader, originalProps.uuid);
|
|
31354
31358
|
case 4:
|
|
31355
|
-
// Register
|
|
31356
|
-
|
|
31357
|
-
if (!
|
|
31359
|
+
// Register behavior configs for each attached device
|
|
31360
|
+
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;
|
|
31361
|
+
if (!ioBehavMgr) {
|
|
31358
31362
|
_context2.n = 8;
|
|
31359
31363
|
break;
|
|
31360
31364
|
}
|
|
31361
31365
|
_loop = /*#__PURE__*/_regenerator().m(function _loop() {
|
|
31362
|
-
var _modelPreloader$compo, _deviceData$
|
|
31366
|
+
var _modelPreloader$compo, _deviceData$behaviorC;
|
|
31363
31367
|
var _Object$entries$_i, attachmentId, attachment, deviceData, deviceRoot;
|
|
31364
31368
|
return _regenerator().w(function (_context) {
|
|
31365
31369
|
while (1) switch (_context.n) {
|
|
31366
31370
|
case 0:
|
|
31367
31371
|
_Object$entries$_i = _slicedToArray(_Object$entries[_i], 2), attachmentId = _Object$entries$_i[0], attachment = _Object$entries$_i[1];
|
|
31368
31372
|
deviceData = (_modelPreloader$compo = modelPreloader.componentDictionary) === null || _modelPreloader$compo === void 0 ? void 0 : _modelPreloader$compo[attachment.deviceId];
|
|
31369
|
-
console.log("[ModelManager] attachment \"".concat(attachmentId, "\" \u2192 deviceId \"").concat(attachment.deviceId, "\" \u2192
|
|
31370
|
-
if (deviceData !== null && deviceData !== void 0 && deviceData.
|
|
31373
|
+
console.log("[ModelManager] attachment \"".concat(attachmentId, "\" \u2192 deviceId \"").concat(attachment.deviceId, "\" \u2192 behaviorConfig:"), (_deviceData$behaviorC = deviceData === null || deviceData === void 0 ? void 0 : deviceData.behaviorConfig) !== null && _deviceData$behaviorC !== void 0 ? _deviceData$behaviorC : 'NONE');
|
|
31374
|
+
if (deviceData !== null && deviceData !== void 0 && deviceData.behaviorConfig) {
|
|
31371
31375
|
_context.n = 1;
|
|
31372
31376
|
break;
|
|
31373
31377
|
}
|
|
@@ -31379,7 +31383,7 @@ var ModelManager = /*#__PURE__*/function () {
|
|
|
31379
31383
|
if (!deviceRoot && ((_obj$userData = obj.userData) === null || _obj$userData === void 0 ? void 0 : _obj$userData.attachmentId) === attachmentId) deviceRoot = obj;
|
|
31380
31384
|
});
|
|
31381
31385
|
if (deviceRoot) {
|
|
31382
|
-
|
|
31386
|
+
ioBehavMgr.loadBehaviors(attachmentId, deviceData.behaviorConfig, deviceRoot, originalProps.uuid);
|
|
31383
31387
|
}
|
|
31384
31388
|
case 2:
|
|
31385
31389
|
return _context.a(2);
|
|
@@ -36654,7 +36658,7 @@ var ComponentTooltipManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36654
36658
|
var currentVal = (_ref = storedVal !== null && storedVal !== void 0 ? storedVal : binaryState.defaultValue) !== null && _ref !== void 0 ? _ref : false;
|
|
36655
36659
|
var newVal = !Boolean(currentVal);
|
|
36656
36660
|
this._stateAdapter.setState(scopedAttachmentId, dpId, newVal);
|
|
36657
|
-
(_this$sceneViewer = this.sceneViewer) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.managers) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.
|
|
36661
|
+
(_this$sceneViewer = this.sceneViewer) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.managers) === null || _this$sceneViewer === void 0 || (_this$sceneViewer = _this$sceneViewer.ioBehaviorManager) === null || _this$sceneViewer === void 0 || _this$sceneViewer.triggerState(attachmentId, dpId, newVal, parentUuid);
|
|
36658
36662
|
console.log("\uD83D\uDD04 [IODevice] Toggled ".concat(scopedAttachmentId, ".").concat(dpId, ": ").concat(currentVal, " \u2192 ").concat(newVal));
|
|
36659
36663
|
}
|
|
36660
36664
|
|
|
@@ -36669,7 +36673,7 @@ var ComponentTooltipManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36669
36673
|
*/
|
|
36670
36674
|
}, {
|
|
36671
36675
|
key: "startIODeviceDrag",
|
|
36672
|
-
value: function startIODeviceDrag(ioDeviceObject) {
|
|
36676
|
+
value: function startIODeviceDrag(ioDeviceObject, hitMesh) {
|
|
36673
36677
|
var _this$sceneViewer2,
|
|
36674
36678
|
_this2 = this;
|
|
36675
36679
|
if (!ioDeviceObject || !this._stateAdapter) return;
|
|
@@ -36687,8 +36691,8 @@ var ComponentTooltipManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36687
36691
|
obj = obj.parent;
|
|
36688
36692
|
}
|
|
36689
36693
|
var scopedAttachmentId = this._getScopedAttachmentKey(attachmentId, parentUuid);
|
|
36690
|
-
var
|
|
36691
|
-
var dataPoints = ((
|
|
36694
|
+
var ioBehavMgr = (_this$sceneViewer2 = this.sceneViewer) === null || _this$sceneViewer2 === void 0 || (_this$sceneViewer2 = _this$sceneViewer2.managers) === null || _this$sceneViewer2 === void 0 ? void 0 : _this$sceneViewer2.ioBehaviorManager;
|
|
36695
|
+
var dataPoints = ((ioBehavMgr === null || ioBehavMgr === void 0 ? void 0 : ioBehavMgr.getAnimationDataPoints(parentUuid, attachmentId, hitMesh)) || []).concat((ud === null || ud === void 0 ? void 0 : ud.dataPoints) || [])
|
|
36692
36696
|
// deduplicate by id
|
|
36693
36697
|
.filter(function (dp, i, arr) {
|
|
36694
36698
|
return arr.findIndex(function (d) {
|
|
@@ -36817,7 +36821,7 @@ var ComponentTooltipManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36817
36821
|
dp = _ref2.dp;
|
|
36818
36822
|
var dpId = dp.id;
|
|
36819
36823
|
(_this$_stateAdapter = this._stateAdapter) === null || _this$_stateAdapter === void 0 || _this$_stateAdapter.setState(scopedAttachmentId, dpId, newVal);
|
|
36820
|
-
(_this$sceneViewer3 = this.sceneViewer) === null || _this$sceneViewer3 === void 0 || (_this$sceneViewer3 = _this$sceneViewer3.managers) === null || _this$sceneViewer3 === void 0 || (_this$sceneViewer3 = _this$sceneViewer3.
|
|
36824
|
+
(_this$sceneViewer3 = this.sceneViewer) === null || _this$sceneViewer3 === void 0 || (_this$sceneViewer3 = _this$sceneViewer3.managers) === null || _this$sceneViewer3 === void 0 || (_this$sceneViewer3 = _this$sceneViewer3.ioBehaviorManager) === null || _this$sceneViewer3 === void 0 || _this$sceneViewer3.triggerState(attachmentId, dpId, newVal, parentUuid);
|
|
36821
36825
|
}
|
|
36822
36826
|
|
|
36823
36827
|
/**
|
|
@@ -36942,11 +36946,11 @@ var ComponentTooltipManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
36942
36946
|
var _this3$sceneViewer$ma, _this3$sceneViewer;
|
|
36943
36947
|
var attachmentId = child.userData.attachmentId || '';
|
|
36944
36948
|
|
|
36945
|
-
// Use only data points from the animate window (
|
|
36949
|
+
// Use only data points from the animate window (behaviorConfig).
|
|
36946
36950
|
// The static ioConfig.states[] snapshot on userData is intentionally ignored.
|
|
36947
|
-
var dataPoints = (_this3$sceneViewer$ma = (_this3$sceneViewer = _this3.sceneViewer) === null || _this3$sceneViewer === void 0 || (_this3$sceneViewer = _this3$sceneViewer.managers) === null || _this3$sceneViewer === void 0 || (_this3$sceneViewer = _this3$sceneViewer.
|
|
36951
|
+
var dataPoints = (_this3$sceneViewer$ma = (_this3$sceneViewer = _this3.sceneViewer) === null || _this3$sceneViewer === void 0 || (_this3$sceneViewer = _this3$sceneViewer.managers) === null || _this3$sceneViewer === void 0 || (_this3$sceneViewer = _this3$sceneViewer.ioBehaviorManager) === null || _this3$sceneViewer === void 0 ? void 0 : _this3$sceneViewer.getAnimationDataPoints(parentUuid, attachmentId)) !== null && _this3$sceneViewer$ma !== void 0 ? _this3$sceneViewer$ma : [];
|
|
36948
36952
|
|
|
36949
|
-
// When data points come from
|
|
36953
|
+
// When data points come from behaviorConfig they already carry direction:'input'.
|
|
36950
36954
|
// Pass null so _buildDataPointRow uses the per-dp direction instead of the
|
|
36951
36955
|
// device-level ioDirection (which may be 'output' and would hide controls).
|
|
36952
36956
|
var deviceDirection = dataPoints.length > 0 ? null : child.userData.ioDirection || 'output';
|
|
@@ -37185,7 +37189,7 @@ var ComponentTooltipManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37185
37189
|
var _this5$_stateAdapter, _this5$selectedObject, _this5$sceneViewer;
|
|
37186
37190
|
(_this5$_stateAdapter = _this5._stateAdapter) === null || _this5$_stateAdapter === void 0 || _this5$_stateAdapter.setState(scopedAttachmentId, dpId, newVal);
|
|
37187
37191
|
var parentUuid = ((_this5$selectedObject = _this5.selectedObject) === null || _this5$selectedObject === void 0 ? void 0 : _this5$selectedObject.uuid) || null;
|
|
37188
|
-
(_this5$sceneViewer = _this5.sceneViewer) === null || _this5$sceneViewer === void 0 || (_this5$sceneViewer = _this5$sceneViewer.managers) === null || _this5$sceneViewer === void 0 || (_this5$sceneViewer = _this5$sceneViewer.
|
|
37192
|
+
(_this5$sceneViewer = _this5.sceneViewer) === null || _this5$sceneViewer === void 0 || (_this5$sceneViewer = _this5$sceneViewer.managers) === null || _this5$sceneViewer === void 0 || (_this5$sceneViewer = _this5$sceneViewer.ioBehaviorManager) === null || _this5$sceneViewer === void 0 || _this5$sceneViewer.triggerState(originalAttachmentId || scopedAttachmentId, dpId, newVal, parentUuid);
|
|
37189
37193
|
});
|
|
37190
37194
|
row.appendChild(ctrl);
|
|
37191
37195
|
this._stateElements.set(key, {
|
|
@@ -37357,11 +37361,11 @@ var ComponentTooltipManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37357
37361
|
}]);
|
|
37358
37362
|
}(BaseDisposable);
|
|
37359
37363
|
|
|
37360
|
-
var
|
|
37361
|
-
function
|
|
37364
|
+
var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
37365
|
+
function IoBehaviorManager(sceneViewer) {
|
|
37362
37366
|
var _this;
|
|
37363
|
-
_classCallCheck(this,
|
|
37364
|
-
_this = _callSuper(this,
|
|
37367
|
+
_classCallCheck(this, IoBehaviorManager);
|
|
37368
|
+
_this = _callSuper(this, IoBehaviorManager);
|
|
37365
37369
|
_this.sceneViewer = sceneViewer;
|
|
37366
37370
|
|
|
37367
37371
|
/**
|
|
@@ -37386,21 +37390,34 @@ var IoAnimationManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37386
37390
|
* so that mesh references are live.
|
|
37387
37391
|
*
|
|
37388
37392
|
* @param {string} attachmentId - The attachment key (e.g. 'attch-switch-01')
|
|
37389
|
-
* @param {Object|Array}
|
|
37390
|
-
* {
|
|
37393
|
+
* @param {Object|Array} behaviorConfig - Serialized config; either the full object
|
|
37394
|
+
* { behaviors: [...] } or a plain array of behavior entries.
|
|
37391
37395
|
* @param {THREE.Object3D} deviceModelRoot - The device's root Object3D as added to the scene
|
|
37392
37396
|
* @param {string} parentUuid - UUID of the host component Object3D
|
|
37393
37397
|
*/
|
|
37394
|
-
_inherits(
|
|
37395
|
-
return _createClass(
|
|
37396
|
-
key: "
|
|
37397
|
-
value: function
|
|
37398
|
-
var
|
|
37399
|
-
if (!
|
|
37400
|
-
var anims = Array.isArray(
|
|
37398
|
+
_inherits(IoBehaviorManager, _BaseDisposable);
|
|
37399
|
+
return _createClass(IoBehaviorManager, [{
|
|
37400
|
+
key: "loadBehaviors",
|
|
37401
|
+
value: function loadBehaviors(attachmentId, behaviorConfig, deviceModelRoot, parentUuid) {
|
|
37402
|
+
var _behaviorConfig$behav;
|
|
37403
|
+
if (!behaviorConfig || !deviceModelRoot) return;
|
|
37404
|
+
var anims = Array.isArray(behaviorConfig) ? behaviorConfig : (_behaviorConfig$behav = behaviorConfig.behaviors) !== null && _behaviorConfig$behav !== void 0 ? _behaviorConfig$behav : [];
|
|
37401
37405
|
if (!anims.length) return;
|
|
37402
37406
|
var key = this._key(parentUuid, attachmentId);
|
|
37403
37407
|
var entries = [];
|
|
37408
|
+
|
|
37409
|
+
// Capture the device root's world orientation once so each entry can
|
|
37410
|
+
// convert the configured axis from device-local space to world space.
|
|
37411
|
+
var deviceWorldQuat = new THREE__namespace.Quaternion();
|
|
37412
|
+
deviceModelRoot.getWorldQuaternion(deviceWorldQuat);
|
|
37413
|
+
|
|
37414
|
+
// Compute the model's native max dimension so rotAxisOffset values (stored
|
|
37415
|
+
// in dialog-viewer-world units, where the model is normalised to 1 unit)
|
|
37416
|
+
// can be scaled to runtime-world units. viewerMaxDim = 1 / ns_viewer.
|
|
37417
|
+
var _deviceBox = new THREE__namespace.Box3().setFromObject(deviceModelRoot);
|
|
37418
|
+
var _deviceSize = new THREE__namespace.Vector3();
|
|
37419
|
+
_deviceBox.getSize(_deviceSize);
|
|
37420
|
+
var viewerMaxDim = Math.max(_deviceSize.x, _deviceSize.y, _deviceSize.z) || 1;
|
|
37404
37421
|
var _iterator = _createForOfIteratorHelper(anims),
|
|
37405
37422
|
_step;
|
|
37406
37423
|
try {
|
|
@@ -37408,14 +37425,26 @@ var IoAnimationManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37408
37425
|
var anim = _step.value;
|
|
37409
37426
|
var mesh = this._resolveMesh(anim, deviceModelRoot);
|
|
37410
37427
|
if (!mesh) {
|
|
37411
|
-
console.warn("[
|
|
37428
|
+
console.warn("[IoBehaviorManager] Could not find mesh for animation \"".concat(anim.name || anim.stateVariable, "\" (uuid: ").concat(anim.meshUuid, ", name: \"").concat(anim.meshName, "\")"));
|
|
37412
37429
|
continue;
|
|
37413
37430
|
}
|
|
37431
|
+
var worldPos = new THREE__namespace.Vector3();
|
|
37432
|
+
mesh.getWorldPosition(worldPos);
|
|
37433
|
+
var worldQuat = new THREE__namespace.Quaternion();
|
|
37434
|
+
mesh.getWorldQuaternion(worldQuat);
|
|
37435
|
+
var box = new THREE__namespace.Box3().setFromObject(mesh);
|
|
37436
|
+
var worldCenter = new THREE__namespace.Vector3();
|
|
37437
|
+
if (!box.isEmpty()) box.getCenter(worldCenter);else worldCenter.copy(worldPos);
|
|
37414
37438
|
entries.push({
|
|
37415
37439
|
anim: anim,
|
|
37416
37440
|
mesh: mesh,
|
|
37417
37441
|
origPos: mesh.position.clone(),
|
|
37418
|
-
origRot: mesh.rotation.clone()
|
|
37442
|
+
origRot: mesh.rotation.clone(),
|
|
37443
|
+
origWorldPos: worldPos,
|
|
37444
|
+
origWorldQuat: worldQuat,
|
|
37445
|
+
origWorldCenter: worldCenter,
|
|
37446
|
+
deviceWorldQuat: deviceWorldQuat.clone(),
|
|
37447
|
+
viewerMaxDim: viewerMaxDim
|
|
37419
37448
|
});
|
|
37420
37449
|
}
|
|
37421
37450
|
} catch (err) {
|
|
@@ -37425,11 +37454,11 @@ var IoAnimationManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37425
37454
|
}
|
|
37426
37455
|
if (entries.length) {
|
|
37427
37456
|
this._entries.set(key, entries);
|
|
37428
|
-
console.log("[
|
|
37457
|
+
console.log("[IoBehaviorManager] Loaded ".concat(entries.length, " animation(s) for attachment \"").concat(attachmentId, "\" (parent: ").concat(parentUuid, ") \u2014 stateVariables: ").concat(entries.map(function (e) {
|
|
37429
37458
|
return e.anim.stateVariable;
|
|
37430
37459
|
}).join(', ')));
|
|
37431
37460
|
} else {
|
|
37432
|
-
console.warn("[
|
|
37461
|
+
console.warn("[IoBehaviorManager] No mesh entries resolved for attachment \"".concat(attachmentId, "\" \u2014 behaviorConfig had ").concat(anims.length, " entries but none matched a mesh"));
|
|
37433
37462
|
}
|
|
37434
37463
|
}
|
|
37435
37464
|
|
|
@@ -37489,13 +37518,26 @@ var IoAnimationManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37489
37518
|
}, {
|
|
37490
37519
|
key: "getAnimationDataPoints",
|
|
37491
37520
|
value: function getAnimationDataPoints(parentUuid, attachmentId) {
|
|
37521
|
+
var _this2 = this;
|
|
37522
|
+
var hitMesh = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
37492
37523
|
var key = this._key(parentUuid, attachmentId);
|
|
37493
37524
|
var entries = this._entries.get(key);
|
|
37494
37525
|
if (!(entries !== null && entries !== void 0 && entries.length)) return [];
|
|
37495
37526
|
|
|
37527
|
+
// When a specific mesh was clicked, filter to only animations whose target
|
|
37528
|
+
// mesh is the clicked mesh or an ancestor of it (e.g. the clicked primitive
|
|
37529
|
+
// is inside a group that is the animation target).
|
|
37530
|
+
var filtered = entries;
|
|
37531
|
+
if (hitMesh) {
|
|
37532
|
+
var matching = entries.filter(function (e) {
|
|
37533
|
+
return _this2._isMeshOrDescendant(hitMesh, e.mesh);
|
|
37534
|
+
});
|
|
37535
|
+
if (matching.length > 0) filtered = matching;
|
|
37536
|
+
}
|
|
37537
|
+
|
|
37496
37538
|
// Collapse multiple mesh entries that share the same stateVariable
|
|
37497
37539
|
var seen = new Map(); // stateVariable → anim
|
|
37498
|
-
var _iterator3 = _createForOfIteratorHelper(
|
|
37540
|
+
var _iterator3 = _createForOfIteratorHelper(filtered),
|
|
37499
37541
|
_step3;
|
|
37500
37542
|
try {
|
|
37501
37543
|
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
@@ -37623,7 +37665,7 @@ var IoAnimationManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37623
37665
|
key: "dispose",
|
|
37624
37666
|
value: function dispose() {
|
|
37625
37667
|
this._entries.clear();
|
|
37626
|
-
_superPropGet(
|
|
37668
|
+
_superPropGet(IoBehaviorManager, "dispose", this, 3)([]);
|
|
37627
37669
|
}
|
|
37628
37670
|
|
|
37629
37671
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -37635,6 +37677,22 @@ var IoAnimationManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37635
37677
|
return "".concat(parentUuid, "::").concat(attachmentId);
|
|
37636
37678
|
}
|
|
37637
37679
|
|
|
37680
|
+
/**
|
|
37681
|
+
* Returns true if `candidate` is `ancestor` or any descendant of `ancestor`.
|
|
37682
|
+
* @param {THREE.Object3D} candidate
|
|
37683
|
+
* @param {THREE.Object3D} ancestor
|
|
37684
|
+
*/
|
|
37685
|
+
}, {
|
|
37686
|
+
key: "_isMeshOrDescendant",
|
|
37687
|
+
value: function _isMeshOrDescendant(candidate, ancestor) {
|
|
37688
|
+
var obj = candidate;
|
|
37689
|
+
while (obj) {
|
|
37690
|
+
if (obj === ancestor) return true;
|
|
37691
|
+
obj = obj.parent;
|
|
37692
|
+
}
|
|
37693
|
+
return false;
|
|
37694
|
+
}
|
|
37695
|
+
|
|
37638
37696
|
/**
|
|
37639
37697
|
* Find the mesh inside `root` using UUID first, then name as fallback.
|
|
37640
37698
|
* GLTFLoader assigns fresh UUIDs on every load, so name is the reliable key.
|
|
@@ -37675,7 +37733,12 @@ var IoAnimationManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37675
37733
|
var anim = entry.anim,
|
|
37676
37734
|
mesh = entry.mesh,
|
|
37677
37735
|
origPos = entry.origPos,
|
|
37678
|
-
origRot = entry.origRot
|
|
37736
|
+
origRot = entry.origRot,
|
|
37737
|
+
origWorldPos = entry.origWorldPos,
|
|
37738
|
+
origWorldQuat = entry.origWorldQuat,
|
|
37739
|
+
origWorldCenter = entry.origWorldCenter,
|
|
37740
|
+
deviceWorldQuat = entry.deviceWorldQuat,
|
|
37741
|
+
viewerMaxDim = entry.viewerMaxDim;
|
|
37679
37742
|
var mapping = this._resolveMapping(anim, value);
|
|
37680
37743
|
if (!mapping) return;
|
|
37681
37744
|
var types = anim.transformTypes || [];
|
|
@@ -37687,7 +37750,7 @@ var IoAnimationManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37687
37750
|
if (type === 'translation') {
|
|
37688
37751
|
this._applyTranslation(mesh, origPos, mapping.transform);
|
|
37689
37752
|
} else if (type === 'rotation') {
|
|
37690
|
-
this._applyRotation(mesh, origPos, origRot, anim, mapping.rotationTransform);
|
|
37753
|
+
this._applyRotation(mesh, origPos, origRot, anim, mapping.rotationTransform, origWorldPos, origWorldQuat, origWorldCenter, deviceWorldQuat, viewerMaxDim);
|
|
37691
37754
|
} else if (type === 'color') {
|
|
37692
37755
|
this._applyColor(mesh, mapping.colorTransform);
|
|
37693
37756
|
}
|
|
@@ -37832,26 +37895,24 @@ var IoAnimationManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37832
37895
|
}
|
|
37833
37896
|
|
|
37834
37897
|
/**
|
|
37835
|
-
* Apply a rotation around an arbitrary pivot point
|
|
37836
|
-
*
|
|
37837
|
-
*
|
|
37838
|
-
*
|
|
37839
|
-
* pivot = rotAxisOffset
|
|
37840
|
-
* delta = origPos - pivot
|
|
37841
|
-
* newDelta = rotate(delta, angle, axis)
|
|
37842
|
-
* newPos = pivot + newDelta
|
|
37843
|
-
* newRot[axis] = origRot[axis] + angle
|
|
37898
|
+
* Apply a rotation around an arbitrary pivot point using world-space quaternion
|
|
37899
|
+
* math matching the ReconstructionViewer's setMeshPreviewRotationAxis approach.
|
|
37900
|
+
* This ensures the runtime axis/pivot matches what the user configured in the
|
|
37901
|
+
* animation dialog, regardless of the device's parent transform in the scene.
|
|
37844
37902
|
*
|
|
37845
37903
|
* @param {THREE.Object3D} mesh
|
|
37846
|
-
* @param {THREE.Vector3} origPos
|
|
37847
|
-
* @param {THREE.Euler} origRot
|
|
37904
|
+
* @param {THREE.Vector3} origPos - local position at load time (unused, kept for signature compat)
|
|
37905
|
+
* @param {THREE.Euler} origRot - local rotation at load time (unused)
|
|
37848
37906
|
* @param {Object} anim
|
|
37849
|
-
* @param {number} angleDeg
|
|
37907
|
+
* @param {number} angleDeg - Degrees
|
|
37908
|
+
* @param {THREE.Vector3} origWorldPos - world position at load time
|
|
37909
|
+
* @param {THREE.Quaternion} origWorldQuat - world quaternion at load time
|
|
37910
|
+
* @param {THREE.Vector3} origWorldCenter - world bounding-box center at load time
|
|
37850
37911
|
*/
|
|
37851
37912
|
}, {
|
|
37852
37913
|
key: "_applyRotation",
|
|
37853
|
-
value: function _applyRotation(mesh, origPos, origRot, anim, angleDeg) {
|
|
37854
|
-
var _anim$rotAxis, _anim$rotAxisOffset
|
|
37914
|
+
value: function _applyRotation(mesh, origPos, origRot, anim, angleDeg, origWorldPos, origWorldQuat, origWorldCenter, deviceWorldQuat, viewerMaxDim) {
|
|
37915
|
+
var _anim$rotAxis, _anim$rotAxisOffset;
|
|
37855
37916
|
var angle = THREE__namespace.MathUtils.degToRad(typeof angleDeg === 'number' ? angleDeg : 0);
|
|
37856
37917
|
var axis = ((_anim$rotAxis = anim.rotAxis) !== null && _anim$rotAxis !== void 0 ? _anim$rotAxis : 'x').toLowerCase();
|
|
37857
37918
|
var off = (_anim$rotAxisOffset = anim.rotAxisOffset) !== null && _anim$rotAxisOffset !== void 0 ? _anim$rotAxisOffset : {
|
|
@@ -37860,13 +37921,57 @@ var IoAnimationManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37860
37921
|
z: 0
|
|
37861
37922
|
};
|
|
37862
37923
|
|
|
37863
|
-
//
|
|
37864
|
-
var
|
|
37865
|
-
|
|
37866
|
-
|
|
37867
|
-
|
|
37868
|
-
|
|
37869
|
-
|
|
37924
|
+
// Local axis in the device's coordinate system
|
|
37925
|
+
var localAxisVec = new THREE__namespace.Vector3(axis === 'x' ? 1 : 0, axis === 'y' ? 1 : 0, axis === 'z' ? 1 : 0);
|
|
37926
|
+
if (origWorldPos && origWorldQuat && origWorldCenter) {
|
|
37927
|
+
// Transform the configured axis from device-local space into world space
|
|
37928
|
+
// so that 'X' means the device's local X, not the world X.
|
|
37929
|
+
var worldAxisVec = localAxisVec.clone().applyQuaternion(deviceWorldQuat || new THREE__namespace.Quaternion());
|
|
37930
|
+
|
|
37931
|
+
// rotAxisOffset is stored in dialog-viewer-world space where the model root
|
|
37932
|
+
// has been rotated Rot_Z(π) by default (ReconstructionViewer's else branch).
|
|
37933
|
+
// Translation uses the same convention and negates X/Y to compensate.
|
|
37934
|
+
// For rotation offset we apply the same compensation mathematically:
|
|
37935
|
+
// offset_runtime = deviceWorldQuat × Rot_Z(π) × offset_dialog × scale
|
|
37936
|
+
// This maps from dialog world space (post Z+180° flip) → model local → world.
|
|
37937
|
+
var scale = viewerMaxDim || 1;
|
|
37938
|
+
var rotZ180 = new THREE__namespace.Quaternion().setFromAxisAngle(new THREE__namespace.Vector3(0, 0, 1), Math.PI);
|
|
37939
|
+
var qCombined = (deviceWorldQuat || new THREE__namespace.Quaternion()).clone().multiply(rotZ180);
|
|
37940
|
+
var offWorld = new THREE__namespace.Vector3((off.x || 0) * scale, (off.y || 0) * scale, (off.z || 0) * scale).applyQuaternion(qCombined);
|
|
37941
|
+
var pivot = origWorldCenter.clone().add(offWorld);
|
|
37942
|
+
var deltaQuat = new THREE__namespace.Quaternion().setFromAxisAngle(worldAxisVec, angle);
|
|
37943
|
+
|
|
37944
|
+
// Rotate world position around pivot
|
|
37945
|
+
var offsetVec = origWorldPos.clone().sub(pivot);
|
|
37946
|
+
offsetVec.applyQuaternion(deltaQuat);
|
|
37947
|
+
var newWorldPos = pivot.clone().add(offsetVec);
|
|
37948
|
+
|
|
37949
|
+
// Compose world quaternion
|
|
37950
|
+
var newWorldQuat = deltaQuat.clone().multiply(origWorldQuat);
|
|
37951
|
+
|
|
37952
|
+
// Convert world position → parent local space
|
|
37953
|
+
if (mesh.parent) {
|
|
37954
|
+
mesh.parent.worldToLocal(newWorldPos);
|
|
37955
|
+
}
|
|
37956
|
+
mesh.position.copy(newWorldPos);
|
|
37957
|
+
|
|
37958
|
+
// Convert quaternion → parent local space
|
|
37959
|
+
if (mesh.parent) {
|
|
37960
|
+
var parentWorldQuat = new THREE__namespace.Quaternion();
|
|
37961
|
+
mesh.parent.getWorldQuaternion(parentWorldQuat);
|
|
37962
|
+
parentWorldQuat.invert();
|
|
37963
|
+
newWorldQuat.premultiply(parentWorldQuat);
|
|
37964
|
+
}
|
|
37965
|
+
mesh.quaternion.copy(newWorldQuat);
|
|
37966
|
+
} else {
|
|
37967
|
+
var _off$x, _off$y, _off$z;
|
|
37968
|
+
// Fallback for entries loaded without world data
|
|
37969
|
+
var _pivot = new THREE__namespace.Vector3((_off$x = off.x) !== null && _off$x !== void 0 ? _off$x : 0, (_off$y = off.y) !== null && _off$y !== void 0 ? _off$y : 0, (_off$z = off.z) !== null && _off$z !== void 0 ? _off$z : 0);
|
|
37970
|
+
var delta = origPos.clone().sub(_pivot);
|
|
37971
|
+
delta.applyAxisAngle(localAxisVec, angle);
|
|
37972
|
+
mesh.position.copy(_pivot).add(delta);
|
|
37973
|
+
mesh.rotation[axis] = origRot[axis] + angle;
|
|
37974
|
+
}
|
|
37870
37975
|
}
|
|
37871
37976
|
|
|
37872
37977
|
/**
|
|
@@ -38248,7 +38353,7 @@ var CentralPlantInternals = /*#__PURE__*/function () {
|
|
|
38248
38353
|
this.centralPlant.managers.cameraControlsManager = new CameraControlsManager(this.centralPlant.sceneViewer);
|
|
38249
38354
|
this.centralPlant.managers.componentDragManager = new ComponentDragManager(this.centralPlant.sceneViewer);
|
|
38250
38355
|
this.centralPlant.managers.viewport2DManager = new Viewport2DManager(this.centralPlant.sceneViewer);
|
|
38251
|
-
this.centralPlant.managers.
|
|
38356
|
+
this.centralPlant.managers.ioBehaviorManager = new IoBehaviorManager(this.centralPlant.sceneViewer);
|
|
38252
38357
|
this.centralPlant.managers.ioOutlineManager = new IoOutlineManager(this.centralPlant.sceneViewer);
|
|
38253
38358
|
|
|
38254
38359
|
// All managers are now stored in the managers collection and will be attached via attachToComponent()
|
|
@@ -39227,23 +39332,23 @@ var CentralPlantInternals = /*#__PURE__*/function () {
|
|
|
39227
39332
|
var _this$centralPlant$sc8;
|
|
39228
39333
|
attachIODevicesToComponent(componentModel, componentData, modelPreloader, componentId);
|
|
39229
39334
|
|
|
39230
|
-
// Register
|
|
39231
|
-
var
|
|
39232
|
-
if (
|
|
39335
|
+
// Register behavior configs so IoBehaviorManager can respond to state changes
|
|
39336
|
+
var ioBehavMgr = (_this$centralPlant$sc8 = this.centralPlant.sceneViewer) === null || _this$centralPlant$sc8 === void 0 || (_this$centralPlant$sc8 = _this$centralPlant$sc8.managers) === null || _this$centralPlant$sc8 === void 0 ? void 0 : _this$centralPlant$sc8.ioBehaviorManager;
|
|
39337
|
+
if (ioBehavMgr) {
|
|
39233
39338
|
var _loop = function _loop() {
|
|
39234
39339
|
var _modelPreloader$compo;
|
|
39235
39340
|
var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
|
|
39236
39341
|
attachmentId = _Object$entries$_i[0],
|
|
39237
39342
|
attachment = _Object$entries$_i[1];
|
|
39238
39343
|
var deviceData = (_modelPreloader$compo = modelPreloader.componentDictionary) === null || _modelPreloader$compo === void 0 ? void 0 : _modelPreloader$compo[attachment.deviceId];
|
|
39239
|
-
if (!(deviceData !== null && deviceData !== void 0 && deviceData.
|
|
39344
|
+
if (!(deviceData !== null && deviceData !== void 0 && deviceData.behaviorConfig)) return 1; // continue
|
|
39240
39345
|
var deviceRoot = null;
|
|
39241
39346
|
componentModel.traverse(function (obj) {
|
|
39242
39347
|
var _obj$userData2;
|
|
39243
39348
|
if (!deviceRoot && ((_obj$userData2 = obj.userData) === null || _obj$userData2 === void 0 ? void 0 : _obj$userData2.attachmentId) === attachmentId) deviceRoot = obj;
|
|
39244
39349
|
});
|
|
39245
39350
|
if (deviceRoot) {
|
|
39246
|
-
|
|
39351
|
+
ioBehavMgr.loadBehaviors(attachmentId, deviceData.behaviorConfig, deviceRoot, componentId);
|
|
39247
39352
|
}
|
|
39248
39353
|
};
|
|
39249
39354
|
for (var _i = 0, _Object$entries = Object.entries(componentData.attachedDevices); _i < _Object$entries.length; _i++) {
|
|
@@ -39550,7 +39655,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
39550
39655
|
* Initialize the CentralPlant manager
|
|
39551
39656
|
*
|
|
39552
39657
|
* @constructor
|
|
39553
|
-
* @version 0.3.
|
|
39658
|
+
* @version 0.3.30
|
|
39554
39659
|
* @updated 2025-10-22
|
|
39555
39660
|
*
|
|
39556
39661
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -40628,8 +40733,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
40628
40733
|
}
|
|
40629
40734
|
}
|
|
40630
40735
|
|
|
40631
|
-
// 2. Apply io-
|
|
40632
|
-
(_this$sceneViewer5 = this.sceneViewer) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.managers) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.
|
|
40736
|
+
// 2. Apply io-behavior changes
|
|
40737
|
+
(_this$sceneViewer5 = this.sceneViewer) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.managers) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.ioBehaviorManager) === null || _this$sceneViewer5 === void 0 || _this$sceneViewer5.triggerState(attachmentId, stateId, value, parentUuid);
|
|
40633
40738
|
|
|
40634
40739
|
// 3. Emit event for host apps that don't use the state adapter (e.g. cp3d-viewer)
|
|
40635
40740
|
(_this$sceneViewer6 = this.sceneViewer) === null || _this$sceneViewer6 === void 0 || _this$sceneViewer6.emit('io-device-state-changed', {
|
|
@@ -42460,7 +42565,7 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
42460
42565
|
this.centralPlant.attachToComponent();
|
|
42461
42566
|
|
|
42462
42567
|
// Sync our managers tracking object after attachment
|
|
42463
|
-
managerKeys = ['threeJSResourceManager', 'performanceMonitorManager', 'settingsManager', 'sceneExportManager', 'componentManager', 'sceneInitializationManager', 'environmentManager', 'keyboardControlsManager', 'pathfindingManager', 'pathFlowManager', '
|
|
42568
|
+
managerKeys = ['threeJSResourceManager', 'performanceMonitorManager', 'settingsManager', 'sceneExportManager', 'componentManager', 'sceneInitializationManager', 'environmentManager', 'keyboardControlsManager', 'pathfindingManager', 'pathFlowManager', 'ioBehaviorManager', 'ioOutlineManager', 'sceneOperationsManager', 'animationManager', 'cameraControlsManager', 'componentDragManager', 'tooltipsManager', 'componentTooltipManager']; // Populate our managers tracking object
|
|
42464
42569
|
managerKeys.forEach(function (key) {
|
|
42465
42570
|
if (_this2[key]) {
|
|
42466
42571
|
_this2.managers[key] = _this2[key];
|
|
@@ -42790,12 +42895,12 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
42790
42895
|
_this4.componentTooltipManager.toggleIODeviceBinaryState(ioDeviceObject);
|
|
42791
42896
|
}
|
|
42792
42897
|
},
|
|
42793
|
-
onIODeviceDrag: function onIODeviceDrag(ioDeviceObject, signedDelta, isStart) {
|
|
42898
|
+
onIODeviceDrag: function onIODeviceDrag(ioDeviceObject, signedDelta, isStart, hitMesh) {
|
|
42794
42899
|
if (isStart) {
|
|
42795
|
-
var _ioDeviceObject$userD, _this4$managers$
|
|
42900
|
+
var _ioDeviceObject$userD, _this4$managers$ioBeh, _this4$managers, _this4$managers2;
|
|
42796
42901
|
// Resolve parentUuid by walking up to the host component.
|
|
42797
42902
|
// Use userData.originalUuid (the custom componentId) because that
|
|
42798
|
-
// is what
|
|
42903
|
+
// is what IoBehaviorManager uses as the map key — NOT obj.uuid.
|
|
42799
42904
|
var parentUuid = null;
|
|
42800
42905
|
var obj = ioDeviceObject.parent;
|
|
42801
42906
|
while (obj) {
|
|
@@ -42811,13 +42916,13 @@ var sceneViewer = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
42811
42916
|
// silhouette is isolated and the outline ring is visible around
|
|
42812
42917
|
// them specifically (not swallowed by the larger device body).
|
|
42813
42918
|
// Fall back to the whole device group when none are registered.
|
|
42814
|
-
var animatedMeshes = attachmentId && parentUuid ? (_this4$managers$
|
|
42919
|
+
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 : [] : [];
|
|
42815
42920
|
var targets = animatedMeshes.length > 0 ? animatedMeshes : [ioDeviceObject];
|
|
42816
42921
|
(_this4$managers2 = _this4.managers) === null || _this4$managers2 === void 0 || (_this4$managers2 = _this4$managers2.ioOutlineManager) === null || _this4$managers2 === void 0 || _this4$managers2.setTargets(targets);
|
|
42817
42922
|
}
|
|
42818
42923
|
if (!_this4.componentTooltipManager) return;
|
|
42819
42924
|
if (isStart) {
|
|
42820
|
-
_this4.componentTooltipManager.startIODeviceDrag(ioDeviceObject);
|
|
42925
|
+
_this4.componentTooltipManager.startIODeviceDrag(ioDeviceObject, hitMesh);
|
|
42821
42926
|
} else {
|
|
42822
42927
|
_this4.componentTooltipManager.updateIODeviceDrag(signedDelta);
|
|
42823
42928
|
}
|
|
@@ -48190,7 +48295,7 @@ exports.ComponentTooltipManager = ComponentTooltipManager;
|
|
|
48190
48295
|
exports.EnvironmentManager = EnvironmentManager;
|
|
48191
48296
|
exports.FLOW_ATTRIBUTE_KEYS = FLOW_ATTRIBUTE_KEYS;
|
|
48192
48297
|
exports.GLOBAL_CACHE_NAME = GLOBAL_CACHE_NAME;
|
|
48193
|
-
exports.
|
|
48298
|
+
exports.IoBehaviorManager = IoBehaviorManager;
|
|
48194
48299
|
exports.KeyboardControlsManager = KeyboardControlsManager;
|
|
48195
48300
|
exports.ModelManager = ModelManager;
|
|
48196
48301
|
exports.OperationHistoryManager = OperationHistoryManager;
|
|
@@ -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.30
|
|
39
39
|
* @updated 2025-10-22
|
|
40
40
|
*
|
|
41
41
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -1113,8 +1113,8 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
1113
1113
|
}
|
|
1114
1114
|
}
|
|
1115
1115
|
|
|
1116
|
-
// 2. Apply io-
|
|
1117
|
-
(_this$sceneViewer5 = this.sceneViewer) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.managers) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.
|
|
1116
|
+
// 2. Apply io-behavior changes
|
|
1117
|
+
(_this$sceneViewer5 = this.sceneViewer) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.managers) === null || _this$sceneViewer5 === void 0 || (_this$sceneViewer5 = _this$sceneViewer5.ioBehaviorManager) === null || _this$sceneViewer5 === void 0 || _this$sceneViewer5.triggerState(attachmentId, stateId, value, parentUuid);
|
|
1118
1118
|
|
|
1119
1119
|
// 3. Emit event for host apps that don't use the state adapter (e.g. cp3d-viewer)
|
|
1120
1120
|
(_this$sceneViewer6 = this.sceneViewer) === null || _this$sceneViewer6 === void 0 || _this$sceneViewer6.emit('io-device-state-changed', {
|
|
@@ -26,7 +26,7 @@ var componentDragManager = require('../managers/controls/componentDragManager.js
|
|
|
26
26
|
var sceneTooltipsManager = require('../managers/scene/sceneTooltipsManager.js');
|
|
27
27
|
var componentTooltipManager = require('../managers/scene/componentTooltipManager.js');
|
|
28
28
|
var viewport2DManager = require('../managers/scene/viewport2DManager.js');
|
|
29
|
-
var
|
|
29
|
+
var IoBehaviorManager = require('../managers/behaviors/IoBehaviorManager.js');
|
|
30
30
|
var IoOutlineManager = require('../managers/behaviors/IoOutlineManager.js');
|
|
31
31
|
var nameUtils = require('../utils/nameUtils.js');
|
|
32
32
|
var ioDeviceUtils = require('../utils/ioDeviceUtils.js');
|
|
@@ -173,7 +173,7 @@ var CentralPlantInternals = /*#__PURE__*/function () {
|
|
|
173
173
|
this.centralPlant.managers.cameraControlsManager = new cameraControlsManager.CameraControlsManager(this.centralPlant.sceneViewer);
|
|
174
174
|
this.centralPlant.managers.componentDragManager = new componentDragManager.ComponentDragManager(this.centralPlant.sceneViewer);
|
|
175
175
|
this.centralPlant.managers.viewport2DManager = new viewport2DManager.Viewport2DManager(this.centralPlant.sceneViewer);
|
|
176
|
-
this.centralPlant.managers.
|
|
176
|
+
this.centralPlant.managers.ioBehaviorManager = new IoBehaviorManager.IoBehaviorManager(this.centralPlant.sceneViewer);
|
|
177
177
|
this.centralPlant.managers.ioOutlineManager = new IoOutlineManager.IoOutlineManager(this.centralPlant.sceneViewer);
|
|
178
178
|
|
|
179
179
|
// All managers are now stored in the managers collection and will be attached via attachToComponent()
|
|
@@ -1152,23 +1152,23 @@ var CentralPlantInternals = /*#__PURE__*/function () {
|
|
|
1152
1152
|
var _this$centralPlant$sc8;
|
|
1153
1153
|
ioDeviceUtils.attachIODevicesToComponent(componentModel, componentData, modelPreloader, componentId);
|
|
1154
1154
|
|
|
1155
|
-
// Register
|
|
1156
|
-
var
|
|
1157
|
-
if (
|
|
1155
|
+
// Register behavior configs so IoBehaviorManager can respond to state changes
|
|
1156
|
+
var ioBehavMgr = (_this$centralPlant$sc8 = this.centralPlant.sceneViewer) === null || _this$centralPlant$sc8 === void 0 || (_this$centralPlant$sc8 = _this$centralPlant$sc8.managers) === null || _this$centralPlant$sc8 === void 0 ? void 0 : _this$centralPlant$sc8.ioBehaviorManager;
|
|
1157
|
+
if (ioBehavMgr) {
|
|
1158
1158
|
var _loop = function _loop() {
|
|
1159
1159
|
var _modelPreloader$compo;
|
|
1160
1160
|
var _Object$entries$_i = _rollupPluginBabelHelpers.slicedToArray(_Object$entries[_i], 2),
|
|
1161
1161
|
attachmentId = _Object$entries$_i[0],
|
|
1162
1162
|
attachment = _Object$entries$_i[1];
|
|
1163
1163
|
var deviceData = (_modelPreloader$compo = modelPreloader.componentDictionary) === null || _modelPreloader$compo === void 0 ? void 0 : _modelPreloader$compo[attachment.deviceId];
|
|
1164
|
-
if (!(deviceData !== null && deviceData !== void 0 && deviceData.
|
|
1164
|
+
if (!(deviceData !== null && deviceData !== void 0 && deviceData.behaviorConfig)) return 1; // continue
|
|
1165
1165
|
var deviceRoot = null;
|
|
1166
1166
|
componentModel.traverse(function (obj) {
|
|
1167
1167
|
var _obj$userData2;
|
|
1168
1168
|
if (!deviceRoot && ((_obj$userData2 = obj.userData) === null || _obj$userData2 === void 0 ? void 0 : _obj$userData2.attachmentId) === attachmentId) deviceRoot = obj;
|
|
1169
1169
|
});
|
|
1170
1170
|
if (deviceRoot) {
|
|
1171
|
-
|
|
1171
|
+
ioBehavMgr.loadBehaviors(attachmentId, deviceData.behaviorConfig, deviceRoot, componentId);
|
|
1172
1172
|
}
|
|
1173
1173
|
};
|
|
1174
1174
|
for (var _i = 0, _Object$entries = Object.entries(componentData.attachedDevices); _i < _Object$entries.length; _i++) {
|