@2112-lab/central-plant 0.3.44 → 0.3.45
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 +102 -102
- package/dist/cjs/src/core/centralPlant.js +27 -41
- package/dist/cjs/src/index.js +0 -1
- package/dist/cjs/src/managers/behaviors/IoBehaviorManager.js +62 -7
- 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 +27 -41
- package/dist/esm/src/index.js +1 -1
- package/dist/esm/src/managers/behaviors/IoBehaviorManager.js +62 -7
- package/dist/esm/src/utils/animationTransformUtils.js +8 -1
- package/dist/esm/src/utils/demoSceneUtils.js +2 -51
- package/package.json +1 -1
package/dist/bundle/index.js
CHANGED
|
@@ -27898,7 +27898,7 @@ var PathRenderingManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
27898
27898
|
}]);
|
|
27899
27899
|
}(BaseDisposable);
|
|
27900
27900
|
|
|
27901
|
-
var _excluded$
|
|
27901
|
+
var _excluded$1 = ["direction"];
|
|
27902
27902
|
var ConnectorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
27903
27903
|
function ConnectorManager(sceneViewer) {
|
|
27904
27904
|
var _this;
|
|
@@ -28043,7 +28043,7 @@ var ConnectorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
28043
28043
|
// Filter out 'direction' attribute - manual segment connectors don't need it
|
|
28044
28044
|
var _ref = connector.userData || {};
|
|
28045
28045
|
_ref.direction;
|
|
28046
|
-
var cleanedUserData = _objectWithoutProperties(_ref, _excluded$
|
|
28046
|
+
var cleanedUserData = _objectWithoutProperties(_ref, _excluded$1);
|
|
28047
28047
|
var sceneDataConnector = {
|
|
28048
28048
|
uuid: connector.uuid,
|
|
28049
28049
|
userData: _objectSpread2(_objectSpread2({}, cleanedUserData), {}, {
|
|
@@ -32810,7 +32810,7 @@ var SceneClearingUtility = /*#__PURE__*/function () {
|
|
|
32810
32810
|
}]);
|
|
32811
32811
|
}();
|
|
32812
32812
|
|
|
32813
|
-
var _excluded
|
|
32813
|
+
var _excluded = ["direction"],
|
|
32814
32814
|
_excluded2 = ["direction"];
|
|
32815
32815
|
var SceneOperationsManager = /*#__PURE__*/function () {
|
|
32816
32816
|
function SceneOperationsManager(sceneViewer) {
|
|
@@ -33399,7 +33399,7 @@ var SceneOperationsManager = /*#__PURE__*/function () {
|
|
|
33399
33399
|
// Initialize userData (filter out 'direction' - manual segment connectors don't need it)
|
|
33400
33400
|
var _ref = connectorData.userData || {};
|
|
33401
33401
|
_ref.direction;
|
|
33402
|
-
var _cleanedUserData = _objectWithoutProperties(_ref, _excluded
|
|
33402
|
+
var _cleanedUserData = _objectWithoutProperties(_ref, _excluded);
|
|
33403
33403
|
_connectorMesh.userData = _objectSpread2(_objectSpread2({}, _cleanedUserData), {}, {
|
|
33404
33404
|
originalUuid: connectorData.uuid,
|
|
33405
33405
|
objectType: 'segment-connector',
|
|
@@ -37881,7 +37881,14 @@ function modelOffsetToWorldDelta(modelRoot, offset, customQuat) {
|
|
|
37881
37881
|
function applyModelRootTranslation(mesh, modelRoot, origLocalPos, modelOffset, customQuat) {
|
|
37882
37882
|
if (!mesh || !modelRoot || !origLocalPos) return;
|
|
37883
37883
|
mesh.position.copy(origLocalPos);
|
|
37884
|
-
|
|
37884
|
+
|
|
37885
|
+
// Ensure all ancestors are updated so getWorldPosition is accurate
|
|
37886
|
+
// even if a parent component was recently moved.
|
|
37887
|
+
if (typeof mesh.updateWorldMatrix === 'function') {
|
|
37888
|
+
mesh.updateWorldMatrix(true, false);
|
|
37889
|
+
} else {
|
|
37890
|
+
mesh.updateMatrixWorld(true);
|
|
37891
|
+
}
|
|
37885
37892
|
var origWorldPos = new THREE__namespace.Vector3();
|
|
37886
37893
|
mesh.getWorldPosition(origWorldPos);
|
|
37887
37894
|
var newWorldPos = origWorldPos.add(modelOffsetToWorldDelta(modelRoot, modelOffset, customQuat));
|
|
@@ -37928,6 +37935,13 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37928
37935
|
/** @type {Map<string, Object[]>} cache key → data point definitions */
|
|
37929
37936
|
_this._dataPointsCache = new Map();
|
|
37930
37937
|
|
|
37938
|
+
// Listen for object transformations to invalidate world-pose caches
|
|
37939
|
+
if (_this.sceneViewer && typeof _this.sceneViewer.on === 'function') {
|
|
37940
|
+
_this.sceneViewer.on('objectTransformed', function () {
|
|
37941
|
+
return _this.invalidateCaches();
|
|
37942
|
+
});
|
|
37943
|
+
}
|
|
37944
|
+
|
|
37931
37945
|
/**
|
|
37932
37946
|
* Injected by the host application to read and write I/O device state.
|
|
37933
37947
|
* Set via configure(). Shape:
|
|
@@ -37989,6 +38003,13 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37989
38003
|
console.warn("[IoBehaviorManager] Could not find mesh for animation \"".concat(anim.name || anim.stateVariable, "\" (uuid: ").concat(anim.meshUuid, ", name: \"").concat(anim.meshName, "\")"));
|
|
37990
38004
|
continue;
|
|
37991
38005
|
}
|
|
38006
|
+
|
|
38007
|
+
// Ensure world matrix is fresh before capturing rest world pose
|
|
38008
|
+
if (typeof mesh.updateWorldMatrix === 'function') {
|
|
38009
|
+
mesh.updateWorldMatrix(true, false);
|
|
38010
|
+
} else {
|
|
38011
|
+
mesh.updateMatrixWorld(true);
|
|
38012
|
+
}
|
|
37992
38013
|
var worldPos = new THREE__namespace.Vector3();
|
|
37993
38014
|
mesh.getWorldPosition(worldPos);
|
|
37994
38015
|
var worldQuat = new THREE__namespace.Quaternion();
|
|
@@ -38579,6 +38600,40 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
38579
38600
|
this._attachmentParentMap.clear();
|
|
38580
38601
|
this._dataPointsCache.clear();
|
|
38581
38602
|
}
|
|
38603
|
+
|
|
38604
|
+
/**
|
|
38605
|
+
* Invalidate world-space pose caches for all registered entries.
|
|
38606
|
+
* Call this when components are moved or rotated to ensure behaviors
|
|
38607
|
+
* recalculate their world-space rest pose.
|
|
38608
|
+
*/
|
|
38609
|
+
}, {
|
|
38610
|
+
key: "invalidateCaches",
|
|
38611
|
+
value: function invalidateCaches() {
|
|
38612
|
+
var _iterator9 = _createForOfIteratorHelper(this._entries.values()),
|
|
38613
|
+
_step9;
|
|
38614
|
+
try {
|
|
38615
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
38616
|
+
var entryList = _step9.value;
|
|
38617
|
+
var _iterator0 = _createForOfIteratorHelper(entryList),
|
|
38618
|
+
_step0;
|
|
38619
|
+
try {
|
|
38620
|
+
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
38621
|
+
var entry = _step0.value;
|
|
38622
|
+
delete entry._restWorldCache;
|
|
38623
|
+
}
|
|
38624
|
+
} catch (err) {
|
|
38625
|
+
_iterator0.e(err);
|
|
38626
|
+
} finally {
|
|
38627
|
+
_iterator0.f();
|
|
38628
|
+
}
|
|
38629
|
+
}
|
|
38630
|
+
} catch (err) {
|
|
38631
|
+
_iterator9.e(err);
|
|
38632
|
+
} finally {
|
|
38633
|
+
_iterator9.f();
|
|
38634
|
+
}
|
|
38635
|
+
this._dataPointsCache.clear();
|
|
38636
|
+
}
|
|
38582
38637
|
}, {
|
|
38583
38638
|
key: "dispose",
|
|
38584
38639
|
value: function dispose() {
|
|
@@ -38657,11 +38712,11 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
38657
38712
|
var mapping = this._resolveMapping(anim, value);
|
|
38658
38713
|
if (!mapping) return;
|
|
38659
38714
|
var types = anim.transformTypes || [];
|
|
38660
|
-
var
|
|
38661
|
-
|
|
38715
|
+
var _iterator1 = _createForOfIteratorHelper(types),
|
|
38716
|
+
_step1;
|
|
38662
38717
|
try {
|
|
38663
|
-
for (
|
|
38664
|
-
var type =
|
|
38718
|
+
for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
|
|
38719
|
+
var type = _step1.value;
|
|
38665
38720
|
if (type === 'translation') {
|
|
38666
38721
|
this._applyTranslation(entry, mapping.transform);
|
|
38667
38722
|
} else if (type === 'rotation') {
|
|
@@ -38671,9 +38726,9 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
38671
38726
|
}
|
|
38672
38727
|
}
|
|
38673
38728
|
} catch (err) {
|
|
38674
|
-
|
|
38729
|
+
_iterator1.e(err);
|
|
38675
38730
|
} finally {
|
|
38676
|
-
|
|
38731
|
+
_iterator1.f();
|
|
38677
38732
|
}
|
|
38678
38733
|
}
|
|
38679
38734
|
|
|
@@ -38833,7 +38888,14 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
38833
38888
|
var savedQuat = mesh.quaternion.clone();
|
|
38834
38889
|
mesh.position.copy(origPos);
|
|
38835
38890
|
mesh.rotation.copy(origRot);
|
|
38836
|
-
|
|
38891
|
+
|
|
38892
|
+
// Ensure all ancestors are updated so getWorldPosition is accurate
|
|
38893
|
+
// even if a parent component was recently moved.
|
|
38894
|
+
if (typeof mesh.updateWorldMatrix === 'function') {
|
|
38895
|
+
mesh.updateWorldMatrix(true, false);
|
|
38896
|
+
} else {
|
|
38897
|
+
mesh.updateMatrixWorld(true);
|
|
38898
|
+
}
|
|
38837
38899
|
var origWorldPos = new THREE__namespace.Vector3();
|
|
38838
38900
|
mesh.getWorldPosition(origWorldPos);
|
|
38839
38901
|
var origWorldQuat = new THREE__namespace.Quaternion();
|
|
@@ -40774,7 +40836,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
40774
40836
|
* Initialize the CentralPlant manager
|
|
40775
40837
|
*
|
|
40776
40838
|
* @constructor
|
|
40777
|
-
* @version 0.3.
|
|
40839
|
+
* @version 0.3.45
|
|
40778
40840
|
* @updated 2025-10-22
|
|
40779
40841
|
*
|
|
40780
40842
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -43266,7 +43328,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
43266
43328
|
key: "importScene",
|
|
43267
43329
|
value: (function () {
|
|
43268
43330
|
var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(jsonData) {
|
|
43269
|
-
var validation,
|
|
43331
|
+
var validation, missingIds, resolved, _t4, _t5;
|
|
43270
43332
|
return _regenerator().w(function (_context10) {
|
|
43271
43333
|
while (1) switch (_context10.n) {
|
|
43272
43334
|
case 0:
|
|
@@ -43287,78 +43349,64 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
43287
43349
|
console.error('❌ Invalid scene data format:', validation.message);
|
|
43288
43350
|
return _context10.a(2, false);
|
|
43289
43351
|
case 2:
|
|
43290
|
-
if (!(jsonData.componentDefinitions && _typeof(jsonData.componentDefinitions) === 'object')) {
|
|
43291
|
-
_context10.n = 4;
|
|
43292
|
-
break;
|
|
43293
|
-
}
|
|
43294
|
-
embeddedCount = Object.keys(jsonData.componentDefinitions).length;
|
|
43295
|
-
if (!(embeddedCount > 0)) {
|
|
43296
|
-
_context10.n = 4;
|
|
43297
|
-
break;
|
|
43298
|
-
}
|
|
43299
|
-
_context10.n = 3;
|
|
43300
|
-
return this.extendComponentDictionary(jsonData.componentDefinitions);
|
|
43301
|
-
case 3:
|
|
43302
|
-
console.log("\uD83D\uDCE6 importScene(): Applied ".concat(embeddedCount, " embedded component definition(s)"));
|
|
43303
|
-
case 4:
|
|
43304
43352
|
if (!this._componentDefinitionResolver) {
|
|
43305
|
-
_context10.n =
|
|
43353
|
+
_context10.n = 8;
|
|
43306
43354
|
break;
|
|
43307
43355
|
}
|
|
43308
43356
|
missingIds = this.getMissingLibraryIds(jsonData);
|
|
43309
43357
|
if (!(missingIds.length > 0)) {
|
|
43310
|
-
_context10.n =
|
|
43358
|
+
_context10.n = 8;
|
|
43311
43359
|
break;
|
|
43312
43360
|
}
|
|
43313
|
-
_context10.p =
|
|
43361
|
+
_context10.p = 3;
|
|
43314
43362
|
console.log("\uD83D\uDD0D importScene(): Resolving ".concat(missingIds.length, " missing component definition(s)..."));
|
|
43315
|
-
_context10.n =
|
|
43363
|
+
_context10.n = 4;
|
|
43316
43364
|
return this._componentDefinitionResolver(missingIds);
|
|
43317
|
-
case
|
|
43365
|
+
case 4:
|
|
43318
43366
|
resolved = _context10.v;
|
|
43319
43367
|
if (!(resolved && _typeof(resolved) === 'object' && Object.keys(resolved).length > 0)) {
|
|
43320
|
-
_context10.n =
|
|
43368
|
+
_context10.n = 6;
|
|
43321
43369
|
break;
|
|
43322
43370
|
}
|
|
43323
|
-
_context10.n =
|
|
43371
|
+
_context10.n = 5;
|
|
43324
43372
|
return this.extendComponentDictionary(resolved);
|
|
43325
|
-
case
|
|
43373
|
+
case 5:
|
|
43326
43374
|
console.log("\u2705 importScene(): Resolved ".concat(Object.keys(resolved).length, " component definition(s)"));
|
|
43327
|
-
case
|
|
43328
|
-
_context10.n =
|
|
43375
|
+
case 6:
|
|
43376
|
+
_context10.n = 8;
|
|
43329
43377
|
break;
|
|
43330
|
-
case
|
|
43331
|
-
_context10.p =
|
|
43378
|
+
case 7:
|
|
43379
|
+
_context10.p = 7;
|
|
43332
43380
|
_t4 = _context10.v;
|
|
43333
43381
|
console.warn('⚠️ importScene(): Component definition resolver failed, continuing with existing dictionary:', _t4);
|
|
43334
|
-
case
|
|
43335
|
-
_context10.n =
|
|
43382
|
+
case 8:
|
|
43383
|
+
_context10.n = 9;
|
|
43336
43384
|
return this.setImportedSceneData(jsonData);
|
|
43337
|
-
case
|
|
43385
|
+
case 9:
|
|
43338
43386
|
if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
|
|
43339
|
-
_context10.n =
|
|
43387
|
+
_context10.n = 11;
|
|
43340
43388
|
break;
|
|
43341
43389
|
}
|
|
43342
|
-
_context10.n =
|
|
43390
|
+
_context10.n = 10;
|
|
43343
43391
|
return this.sceneViewer.sceneOperationsManager.loadSceneFromData(jsonData);
|
|
43344
|
-
case
|
|
43392
|
+
case 10:
|
|
43345
43393
|
console.log('✅ Scene imported successfully');
|
|
43346
43394
|
return _context10.a(2, true);
|
|
43347
|
-
case
|
|
43395
|
+
case 11:
|
|
43348
43396
|
console.error('❌ SceneViewer not available for scene loading');
|
|
43349
43397
|
return _context10.a(2, false);
|
|
43350
|
-
case
|
|
43351
|
-
_context10.n =
|
|
43398
|
+
case 12:
|
|
43399
|
+
_context10.n = 14;
|
|
43352
43400
|
break;
|
|
43353
|
-
case
|
|
43354
|
-
_context10.p =
|
|
43401
|
+
case 13:
|
|
43402
|
+
_context10.p = 13;
|
|
43355
43403
|
_t5 = _context10.v;
|
|
43356
43404
|
console.error('❌ Error importing scene:', _t5);
|
|
43357
43405
|
return _context10.a(2, false);
|
|
43358
|
-
case
|
|
43406
|
+
case 14:
|
|
43359
43407
|
return _context10.a(2);
|
|
43360
43408
|
}
|
|
43361
|
-
}, _callee10, this, [[
|
|
43409
|
+
}, _callee10, this, [[3, 7], [1, 13]]);
|
|
43362
43410
|
}));
|
|
43363
43411
|
function importScene(_x6) {
|
|
43364
43412
|
return _importScene.apply(this, arguments);
|
|
@@ -44996,20 +45044,10 @@ var SceneHierarchyManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
44996
45044
|
}]);
|
|
44997
45045
|
}(BaseDisposable);
|
|
44998
45046
|
|
|
44999
|
-
var _excluded = ["componentDefinitions"];
|
|
45000
45047
|
/**
|
|
45001
|
-
* Helpers for portable demo scene JSON
|
|
45048
|
+
* Helpers for portable demo scene JSON.
|
|
45002
45049
|
*/
|
|
45003
45050
|
|
|
45004
|
-
function cloneDefinition(def) {
|
|
45005
|
-
if (!def || _typeof(def) !== 'object') return null;
|
|
45006
|
-
try {
|
|
45007
|
-
return JSON.parse(JSON.stringify(def));
|
|
45008
|
-
} catch (_unused) {
|
|
45009
|
-
return _objectSpread2({}, def);
|
|
45010
|
-
}
|
|
45011
|
-
}
|
|
45012
|
-
|
|
45013
45051
|
/**
|
|
45014
45052
|
* Collect unique library IDs referenced by scene nodes.
|
|
45015
45053
|
* @param {Object} sceneData
|
|
@@ -45031,43 +45069,6 @@ function collectSceneLibraryIds(sceneData) {
|
|
|
45031
45069
|
return Array.from(ids);
|
|
45032
45070
|
}
|
|
45033
45071
|
|
|
45034
|
-
/**
|
|
45035
|
-
* Embed component/device definitions required by a scene into the JSON payload.
|
|
45036
|
-
* @param {Object} sceneData
|
|
45037
|
-
* @param {Record<string, Object>} componentDictionary
|
|
45038
|
-
* @returns {Object}
|
|
45039
|
-
*/
|
|
45040
|
-
function embedComponentDefinitions(sceneData) {
|
|
45041
|
-
var componentDictionary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
45042
|
-
if (!sceneData || _typeof(sceneData) !== 'object') return sceneData;
|
|
45043
|
-
var libraryIds = collectSceneLibraryIds(sceneData);
|
|
45044
|
-
var componentDefinitions = {};
|
|
45045
|
-
var deviceIds = new Set();
|
|
45046
|
-
libraryIds.forEach(function (libraryId) {
|
|
45047
|
-
var def = componentDictionary[libraryId];
|
|
45048
|
-
if (!def) return;
|
|
45049
|
-
componentDefinitions[libraryId] = cloneDefinition(def);
|
|
45050
|
-
var attachedDevices = def.attachedDevices;
|
|
45051
|
-
if (!attachedDevices || _typeof(attachedDevices) !== 'object') return;
|
|
45052
|
-
Object.values(attachedDevices).forEach(function (att) {
|
|
45053
|
-
if (att !== null && att !== void 0 && att.deviceId) deviceIds.add(att.deviceId);
|
|
45054
|
-
});
|
|
45055
|
-
});
|
|
45056
|
-
deviceIds.forEach(function (deviceId) {
|
|
45057
|
-
if (componentDefinitions[deviceId]) return;
|
|
45058
|
-
var deviceDef = componentDictionary[deviceId];
|
|
45059
|
-
if (deviceDef) componentDefinitions[deviceId] = cloneDefinition(deviceDef);
|
|
45060
|
-
});
|
|
45061
|
-
if (!Object.keys(componentDefinitions).length) {
|
|
45062
|
-
sceneData.componentDefinitions;
|
|
45063
|
-
var rest = _objectWithoutProperties(sceneData, _excluded);
|
|
45064
|
-
return rest;
|
|
45065
|
-
}
|
|
45066
|
-
return _objectSpread2(_objectSpread2({}, sceneData), {}, {
|
|
45067
|
-
componentDefinitions: componentDefinitions
|
|
45068
|
-
});
|
|
45069
|
-
}
|
|
45070
|
-
|
|
45071
45072
|
/**
|
|
45072
45073
|
* Resolve the live component dictionary from a CentralPlant instance.
|
|
45073
45074
|
* @param {Object} centralPlant
|
|
@@ -49561,7 +49562,6 @@ exports.clearS3Cache = clearS3Cache;
|
|
|
49561
49562
|
exports.collectSceneLibraryIds = collectSceneLibraryIds;
|
|
49562
49563
|
exports.createPathfindingRequest = createPathfindingRequest;
|
|
49563
49564
|
exports.createTransformControls = createTransformControls;
|
|
49564
|
-
exports.embedComponentDefinitions = embedComponentDefinitions;
|
|
49565
49565
|
exports.findObjectByHardcodedUuid = findObjectByHardcodedUuid;
|
|
49566
49566
|
exports.formatCacheExpiry = formatCacheExpiry;
|
|
49567
49567
|
exports.generateUniqueComponentId = generateUniqueComponentId;
|
|
@@ -37,7 +37,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
37
37
|
* Initialize the CentralPlant manager
|
|
38
38
|
*
|
|
39
39
|
* @constructor
|
|
40
|
-
* @version 0.3.
|
|
40
|
+
* @version 0.3.45
|
|
41
41
|
* @updated 2025-10-22
|
|
42
42
|
*
|
|
43
43
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -2529,7 +2529,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2529
2529
|
key: "importScene",
|
|
2530
2530
|
value: (function () {
|
|
2531
2531
|
var _importScene = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee10(jsonData) {
|
|
2532
|
-
var validation,
|
|
2532
|
+
var validation, missingIds, resolved, _t4, _t5;
|
|
2533
2533
|
return _rollupPluginBabelHelpers.regenerator().w(function (_context10) {
|
|
2534
2534
|
while (1) switch (_context10.n) {
|
|
2535
2535
|
case 0:
|
|
@@ -2550,78 +2550,64 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2550
2550
|
console.error('❌ Invalid scene data format:', validation.message);
|
|
2551
2551
|
return _context10.a(2, false);
|
|
2552
2552
|
case 2:
|
|
2553
|
-
if (!(jsonData.componentDefinitions && _rollupPluginBabelHelpers["typeof"](jsonData.componentDefinitions) === 'object')) {
|
|
2554
|
-
_context10.n = 4;
|
|
2555
|
-
break;
|
|
2556
|
-
}
|
|
2557
|
-
embeddedCount = Object.keys(jsonData.componentDefinitions).length;
|
|
2558
|
-
if (!(embeddedCount > 0)) {
|
|
2559
|
-
_context10.n = 4;
|
|
2560
|
-
break;
|
|
2561
|
-
}
|
|
2562
|
-
_context10.n = 3;
|
|
2563
|
-
return this.extendComponentDictionary(jsonData.componentDefinitions);
|
|
2564
|
-
case 3:
|
|
2565
|
-
console.log("\uD83D\uDCE6 importScene(): Applied ".concat(embeddedCount, " embedded component definition(s)"));
|
|
2566
|
-
case 4:
|
|
2567
2553
|
if (!this._componentDefinitionResolver) {
|
|
2568
|
-
_context10.n =
|
|
2554
|
+
_context10.n = 8;
|
|
2569
2555
|
break;
|
|
2570
2556
|
}
|
|
2571
2557
|
missingIds = this.getMissingLibraryIds(jsonData);
|
|
2572
2558
|
if (!(missingIds.length > 0)) {
|
|
2573
|
-
_context10.n =
|
|
2559
|
+
_context10.n = 8;
|
|
2574
2560
|
break;
|
|
2575
2561
|
}
|
|
2576
|
-
_context10.p =
|
|
2562
|
+
_context10.p = 3;
|
|
2577
2563
|
console.log("\uD83D\uDD0D importScene(): Resolving ".concat(missingIds.length, " missing component definition(s)..."));
|
|
2578
|
-
_context10.n =
|
|
2564
|
+
_context10.n = 4;
|
|
2579
2565
|
return this._componentDefinitionResolver(missingIds);
|
|
2580
|
-
case
|
|
2566
|
+
case 4:
|
|
2581
2567
|
resolved = _context10.v;
|
|
2582
2568
|
if (!(resolved && _rollupPluginBabelHelpers["typeof"](resolved) === 'object' && Object.keys(resolved).length > 0)) {
|
|
2583
|
-
_context10.n =
|
|
2569
|
+
_context10.n = 6;
|
|
2584
2570
|
break;
|
|
2585
2571
|
}
|
|
2586
|
-
_context10.n =
|
|
2572
|
+
_context10.n = 5;
|
|
2587
2573
|
return this.extendComponentDictionary(resolved);
|
|
2588
|
-
case
|
|
2574
|
+
case 5:
|
|
2589
2575
|
console.log("\u2705 importScene(): Resolved ".concat(Object.keys(resolved).length, " component definition(s)"));
|
|
2590
|
-
case
|
|
2591
|
-
_context10.n =
|
|
2576
|
+
case 6:
|
|
2577
|
+
_context10.n = 8;
|
|
2592
2578
|
break;
|
|
2593
|
-
case
|
|
2594
|
-
_context10.p =
|
|
2579
|
+
case 7:
|
|
2580
|
+
_context10.p = 7;
|
|
2595
2581
|
_t4 = _context10.v;
|
|
2596
2582
|
console.warn('⚠️ importScene(): Component definition resolver failed, continuing with existing dictionary:', _t4);
|
|
2597
|
-
case
|
|
2598
|
-
_context10.n =
|
|
2583
|
+
case 8:
|
|
2584
|
+
_context10.n = 9;
|
|
2599
2585
|
return this.setImportedSceneData(jsonData);
|
|
2600
|
-
case
|
|
2586
|
+
case 9:
|
|
2601
2587
|
if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
|
|
2602
|
-
_context10.n =
|
|
2588
|
+
_context10.n = 11;
|
|
2603
2589
|
break;
|
|
2604
2590
|
}
|
|
2605
|
-
_context10.n =
|
|
2591
|
+
_context10.n = 10;
|
|
2606
2592
|
return this.sceneViewer.sceneOperationsManager.loadSceneFromData(jsonData);
|
|
2607
|
-
case
|
|
2593
|
+
case 10:
|
|
2608
2594
|
console.log('✅ Scene imported successfully');
|
|
2609
2595
|
return _context10.a(2, true);
|
|
2610
|
-
case
|
|
2596
|
+
case 11:
|
|
2611
2597
|
console.error('❌ SceneViewer not available for scene loading');
|
|
2612
2598
|
return _context10.a(2, false);
|
|
2613
|
-
case
|
|
2614
|
-
_context10.n =
|
|
2599
|
+
case 12:
|
|
2600
|
+
_context10.n = 14;
|
|
2615
2601
|
break;
|
|
2616
|
-
case
|
|
2617
|
-
_context10.p =
|
|
2602
|
+
case 13:
|
|
2603
|
+
_context10.p = 13;
|
|
2618
2604
|
_t5 = _context10.v;
|
|
2619
2605
|
console.error('❌ Error importing scene:', _t5);
|
|
2620
2606
|
return _context10.a(2, false);
|
|
2621
|
-
case
|
|
2607
|
+
case 14:
|
|
2622
2608
|
return _context10.a(2);
|
|
2623
2609
|
}
|
|
2624
|
-
}, _callee10, this, [[
|
|
2610
|
+
}, _callee10, this, [[3, 7], [1, 13]]);
|
|
2625
2611
|
}));
|
|
2626
2612
|
function importScene(_x6) {
|
|
2627
2613
|
return _importScene.apply(this, arguments);
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -92,7 +92,6 @@ exports.refreshSceneIntraBehaviors = behaviorSceneUtils.refreshSceneIntraBehavio
|
|
|
92
92
|
exports.reregisterSceneBehaviors = behaviorSceneUtils.reregisterSceneBehaviors;
|
|
93
93
|
exports.scanSceneIoEndpoints = behaviorSceneUtils.scanSceneIoEndpoints;
|
|
94
94
|
exports.collectSceneLibraryIds = demoSceneUtils.collectSceneLibraryIds;
|
|
95
|
-
exports.embedComponentDefinitions = demoSceneUtils.embedComponentDefinitions;
|
|
96
95
|
exports.getComponentDictionary = demoSceneUtils.getComponentDictionary;
|
|
97
96
|
exports.applyModelRootTranslation = animationTransformUtils.applyModelRootTranslation;
|
|
98
97
|
exports.applyModelRootTranslationFromWorldBase = animationTransformUtils.applyModelRootTranslationFromWorldBase;
|
|
@@ -52,6 +52,13 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
52
52
|
/** @type {Map<string, Object[]>} cache key → data point definitions */
|
|
53
53
|
_this._dataPointsCache = new Map();
|
|
54
54
|
|
|
55
|
+
// Listen for object transformations to invalidate world-pose caches
|
|
56
|
+
if (_this.sceneViewer && typeof _this.sceneViewer.on === 'function') {
|
|
57
|
+
_this.sceneViewer.on('objectTransformed', function () {
|
|
58
|
+
return _this.invalidateCaches();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
55
62
|
/**
|
|
56
63
|
* Injected by the host application to read and write I/O device state.
|
|
57
64
|
* Set via configure(). Shape:
|
|
@@ -113,6 +120,13 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
113
120
|
console.warn("[IoBehaviorManager] Could not find mesh for animation \"".concat(anim.name || anim.stateVariable, "\" (uuid: ").concat(anim.meshUuid, ", name: \"").concat(anim.meshName, "\")"));
|
|
114
121
|
continue;
|
|
115
122
|
}
|
|
123
|
+
|
|
124
|
+
// Ensure world matrix is fresh before capturing rest world pose
|
|
125
|
+
if (typeof mesh.updateWorldMatrix === 'function') {
|
|
126
|
+
mesh.updateWorldMatrix(true, false);
|
|
127
|
+
} else {
|
|
128
|
+
mesh.updateMatrixWorld(true);
|
|
129
|
+
}
|
|
116
130
|
var worldPos = new THREE__namespace.Vector3();
|
|
117
131
|
mesh.getWorldPosition(worldPos);
|
|
118
132
|
var worldQuat = new THREE__namespace.Quaternion();
|
|
@@ -703,6 +717,40 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
703
717
|
this._attachmentParentMap.clear();
|
|
704
718
|
this._dataPointsCache.clear();
|
|
705
719
|
}
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Invalidate world-space pose caches for all registered entries.
|
|
723
|
+
* Call this when components are moved or rotated to ensure behaviors
|
|
724
|
+
* recalculate their world-space rest pose.
|
|
725
|
+
*/
|
|
726
|
+
}, {
|
|
727
|
+
key: "invalidateCaches",
|
|
728
|
+
value: function invalidateCaches() {
|
|
729
|
+
var _iterator9 = _rollupPluginBabelHelpers.createForOfIteratorHelper(this._entries.values()),
|
|
730
|
+
_step9;
|
|
731
|
+
try {
|
|
732
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
733
|
+
var entryList = _step9.value;
|
|
734
|
+
var _iterator0 = _rollupPluginBabelHelpers.createForOfIteratorHelper(entryList),
|
|
735
|
+
_step0;
|
|
736
|
+
try {
|
|
737
|
+
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
738
|
+
var entry = _step0.value;
|
|
739
|
+
delete entry._restWorldCache;
|
|
740
|
+
}
|
|
741
|
+
} catch (err) {
|
|
742
|
+
_iterator0.e(err);
|
|
743
|
+
} finally {
|
|
744
|
+
_iterator0.f();
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
} catch (err) {
|
|
748
|
+
_iterator9.e(err);
|
|
749
|
+
} finally {
|
|
750
|
+
_iterator9.f();
|
|
751
|
+
}
|
|
752
|
+
this._dataPointsCache.clear();
|
|
753
|
+
}
|
|
706
754
|
}, {
|
|
707
755
|
key: "dispose",
|
|
708
756
|
value: function dispose() {
|
|
@@ -781,11 +829,11 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
781
829
|
var mapping = this._resolveMapping(anim, value);
|
|
782
830
|
if (!mapping) return;
|
|
783
831
|
var types = anim.transformTypes || [];
|
|
784
|
-
var
|
|
785
|
-
|
|
832
|
+
var _iterator1 = _rollupPluginBabelHelpers.createForOfIteratorHelper(types),
|
|
833
|
+
_step1;
|
|
786
834
|
try {
|
|
787
|
-
for (
|
|
788
|
-
var type =
|
|
835
|
+
for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
|
|
836
|
+
var type = _step1.value;
|
|
789
837
|
if (type === 'translation') {
|
|
790
838
|
this._applyTranslation(entry, mapping.transform);
|
|
791
839
|
} else if (type === 'rotation') {
|
|
@@ -795,9 +843,9 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
795
843
|
}
|
|
796
844
|
}
|
|
797
845
|
} catch (err) {
|
|
798
|
-
|
|
846
|
+
_iterator1.e(err);
|
|
799
847
|
} finally {
|
|
800
|
-
|
|
848
|
+
_iterator1.f();
|
|
801
849
|
}
|
|
802
850
|
}
|
|
803
851
|
|
|
@@ -957,7 +1005,14 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
957
1005
|
var savedQuat = mesh.quaternion.clone();
|
|
958
1006
|
mesh.position.copy(origPos);
|
|
959
1007
|
mesh.rotation.copy(origRot);
|
|
960
|
-
|
|
1008
|
+
|
|
1009
|
+
// Ensure all ancestors are updated so getWorldPosition is accurate
|
|
1010
|
+
// even if a parent component was recently moved.
|
|
1011
|
+
if (typeof mesh.updateWorldMatrix === 'function') {
|
|
1012
|
+
mesh.updateWorldMatrix(true, false);
|
|
1013
|
+
} else {
|
|
1014
|
+
mesh.updateMatrixWorld(true);
|
|
1015
|
+
}
|
|
961
1016
|
var origWorldPos = new THREE__namespace.Vector3();
|
|
962
1017
|
mesh.getWorldPosition(origWorldPos);
|
|
963
1018
|
var origWorldQuat = new THREE__namespace.Quaternion();
|
|
@@ -56,7 +56,14 @@ function modelOffsetToWorldDelta(modelRoot, offset, customQuat) {
|
|
|
56
56
|
function applyModelRootTranslation(mesh, modelRoot, origLocalPos, modelOffset, customQuat) {
|
|
57
57
|
if (!mesh || !modelRoot || !origLocalPos) return;
|
|
58
58
|
mesh.position.copy(origLocalPos);
|
|
59
|
-
|
|
59
|
+
|
|
60
|
+
// Ensure all ancestors are updated so getWorldPosition is accurate
|
|
61
|
+
// even if a parent component was recently moved.
|
|
62
|
+
if (typeof mesh.updateWorldMatrix === 'function') {
|
|
63
|
+
mesh.updateWorldMatrix(true, false);
|
|
64
|
+
} else {
|
|
65
|
+
mesh.updateMatrixWorld(true);
|
|
66
|
+
}
|
|
60
67
|
var origWorldPos = new THREE__namespace.Vector3();
|
|
61
68
|
mesh.getWorldPosition(origWorldPos);
|
|
62
69
|
var newWorldPos = origWorldPos.add(modelOffsetToWorldDelta(modelRoot, modelOffset, customQuat));
|
|
@@ -2,22 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
|
|
6
|
-
|
|
7
|
-
var _excluded = ["componentDefinitions"];
|
|
8
5
|
/**
|
|
9
|
-
* Helpers for portable demo scene JSON
|
|
6
|
+
* Helpers for portable demo scene JSON.
|
|
10
7
|
*/
|
|
11
8
|
|
|
12
|
-
function cloneDefinition(def) {
|
|
13
|
-
if (!def || _rollupPluginBabelHelpers["typeof"](def) !== 'object') return null;
|
|
14
|
-
try {
|
|
15
|
-
return JSON.parse(JSON.stringify(def));
|
|
16
|
-
} catch (_unused) {
|
|
17
|
-
return _rollupPluginBabelHelpers.objectSpread2({}, def);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
9
|
/**
|
|
22
10
|
* Collect unique library IDs referenced by scene nodes.
|
|
23
11
|
* @param {Object} sceneData
|
|
@@ -39,43 +27,6 @@ function collectSceneLibraryIds(sceneData) {
|
|
|
39
27
|
return Array.from(ids);
|
|
40
28
|
}
|
|
41
29
|
|
|
42
|
-
/**
|
|
43
|
-
* Embed component/device definitions required by a scene into the JSON payload.
|
|
44
|
-
* @param {Object} sceneData
|
|
45
|
-
* @param {Record<string, Object>} componentDictionary
|
|
46
|
-
* @returns {Object}
|
|
47
|
-
*/
|
|
48
|
-
function embedComponentDefinitions(sceneData) {
|
|
49
|
-
var componentDictionary = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
50
|
-
if (!sceneData || _rollupPluginBabelHelpers["typeof"](sceneData) !== 'object') return sceneData;
|
|
51
|
-
var libraryIds = collectSceneLibraryIds(sceneData);
|
|
52
|
-
var componentDefinitions = {};
|
|
53
|
-
var deviceIds = new Set();
|
|
54
|
-
libraryIds.forEach(function (libraryId) {
|
|
55
|
-
var def = componentDictionary[libraryId];
|
|
56
|
-
if (!def) return;
|
|
57
|
-
componentDefinitions[libraryId] = cloneDefinition(def);
|
|
58
|
-
var attachedDevices = def.attachedDevices;
|
|
59
|
-
if (!attachedDevices || _rollupPluginBabelHelpers["typeof"](attachedDevices) !== 'object') return;
|
|
60
|
-
Object.values(attachedDevices).forEach(function (att) {
|
|
61
|
-
if (att !== null && att !== void 0 && att.deviceId) deviceIds.add(att.deviceId);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
deviceIds.forEach(function (deviceId) {
|
|
65
|
-
if (componentDefinitions[deviceId]) return;
|
|
66
|
-
var deviceDef = componentDictionary[deviceId];
|
|
67
|
-
if (deviceDef) componentDefinitions[deviceId] = cloneDefinition(deviceDef);
|
|
68
|
-
});
|
|
69
|
-
if (!Object.keys(componentDefinitions).length) {
|
|
70
|
-
sceneData.componentDefinitions;
|
|
71
|
-
var rest = _rollupPluginBabelHelpers.objectWithoutProperties(sceneData, _excluded);
|
|
72
|
-
return rest;
|
|
73
|
-
}
|
|
74
|
-
return _rollupPluginBabelHelpers.objectSpread2(_rollupPluginBabelHelpers.objectSpread2({}, sceneData), {}, {
|
|
75
|
-
componentDefinitions: componentDefinitions
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
30
|
/**
|
|
80
31
|
* Resolve the live component dictionary from a CentralPlant instance.
|
|
81
32
|
* @param {Object} centralPlant
|
|
@@ -87,5 +38,4 @@ function getComponentDictionary(centralPlant) {
|
|
|
87
38
|
}
|
|
88
39
|
|
|
89
40
|
exports.collectSceneLibraryIds = collectSceneLibraryIds;
|
|
90
|
-
exports.embedComponentDefinitions = embedComponentDefinitions;
|
|
91
41
|
exports.getComponentDictionary = getComponentDictionary;
|
|
@@ -33,7 +33,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
33
33
|
* Initialize the CentralPlant manager
|
|
34
34
|
*
|
|
35
35
|
* @constructor
|
|
36
|
-
* @version 0.3.
|
|
36
|
+
* @version 0.3.45
|
|
37
37
|
* @updated 2025-10-22
|
|
38
38
|
*
|
|
39
39
|
* @description Creates a new CentralPlant instance and initializes internal managers and utilities.
|
|
@@ -2525,7 +2525,7 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2525
2525
|
key: "importScene",
|
|
2526
2526
|
value: (function () {
|
|
2527
2527
|
var _importScene = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(jsonData) {
|
|
2528
|
-
var validation,
|
|
2528
|
+
var validation, missingIds, resolved, _t4, _t5;
|
|
2529
2529
|
return _regenerator().w(function (_context10) {
|
|
2530
2530
|
while (1) switch (_context10.n) {
|
|
2531
2531
|
case 0:
|
|
@@ -2546,78 +2546,64 @@ var CentralPlant = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
2546
2546
|
console.error('❌ Invalid scene data format:', validation.message);
|
|
2547
2547
|
return _context10.a(2, false);
|
|
2548
2548
|
case 2:
|
|
2549
|
-
if (!(jsonData.componentDefinitions && _typeof(jsonData.componentDefinitions) === 'object')) {
|
|
2550
|
-
_context10.n = 4;
|
|
2551
|
-
break;
|
|
2552
|
-
}
|
|
2553
|
-
embeddedCount = Object.keys(jsonData.componentDefinitions).length;
|
|
2554
|
-
if (!(embeddedCount > 0)) {
|
|
2555
|
-
_context10.n = 4;
|
|
2556
|
-
break;
|
|
2557
|
-
}
|
|
2558
|
-
_context10.n = 3;
|
|
2559
|
-
return this.extendComponentDictionary(jsonData.componentDefinitions);
|
|
2560
|
-
case 3:
|
|
2561
|
-
console.log("\uD83D\uDCE6 importScene(): Applied ".concat(embeddedCount, " embedded component definition(s)"));
|
|
2562
|
-
case 4:
|
|
2563
2549
|
if (!this._componentDefinitionResolver) {
|
|
2564
|
-
_context10.n =
|
|
2550
|
+
_context10.n = 8;
|
|
2565
2551
|
break;
|
|
2566
2552
|
}
|
|
2567
2553
|
missingIds = this.getMissingLibraryIds(jsonData);
|
|
2568
2554
|
if (!(missingIds.length > 0)) {
|
|
2569
|
-
_context10.n =
|
|
2555
|
+
_context10.n = 8;
|
|
2570
2556
|
break;
|
|
2571
2557
|
}
|
|
2572
|
-
_context10.p =
|
|
2558
|
+
_context10.p = 3;
|
|
2573
2559
|
console.log("\uD83D\uDD0D importScene(): Resolving ".concat(missingIds.length, " missing component definition(s)..."));
|
|
2574
|
-
_context10.n =
|
|
2560
|
+
_context10.n = 4;
|
|
2575
2561
|
return this._componentDefinitionResolver(missingIds);
|
|
2576
|
-
case
|
|
2562
|
+
case 4:
|
|
2577
2563
|
resolved = _context10.v;
|
|
2578
2564
|
if (!(resolved && _typeof(resolved) === 'object' && Object.keys(resolved).length > 0)) {
|
|
2579
|
-
_context10.n =
|
|
2565
|
+
_context10.n = 6;
|
|
2580
2566
|
break;
|
|
2581
2567
|
}
|
|
2582
|
-
_context10.n =
|
|
2568
|
+
_context10.n = 5;
|
|
2583
2569
|
return this.extendComponentDictionary(resolved);
|
|
2584
|
-
case
|
|
2570
|
+
case 5:
|
|
2585
2571
|
console.log("\u2705 importScene(): Resolved ".concat(Object.keys(resolved).length, " component definition(s)"));
|
|
2586
|
-
case
|
|
2587
|
-
_context10.n =
|
|
2572
|
+
case 6:
|
|
2573
|
+
_context10.n = 8;
|
|
2588
2574
|
break;
|
|
2589
|
-
case
|
|
2590
|
-
_context10.p =
|
|
2575
|
+
case 7:
|
|
2576
|
+
_context10.p = 7;
|
|
2591
2577
|
_t4 = _context10.v;
|
|
2592
2578
|
console.warn('⚠️ importScene(): Component definition resolver failed, continuing with existing dictionary:', _t4);
|
|
2593
|
-
case
|
|
2594
|
-
_context10.n =
|
|
2579
|
+
case 8:
|
|
2580
|
+
_context10.n = 9;
|
|
2595
2581
|
return this.setImportedSceneData(jsonData);
|
|
2596
|
-
case
|
|
2582
|
+
case 9:
|
|
2597
2583
|
if (!(this.sceneViewer && this.sceneViewer.sceneOperationsManager)) {
|
|
2598
|
-
_context10.n =
|
|
2584
|
+
_context10.n = 11;
|
|
2599
2585
|
break;
|
|
2600
2586
|
}
|
|
2601
|
-
_context10.n =
|
|
2587
|
+
_context10.n = 10;
|
|
2602
2588
|
return this.sceneViewer.sceneOperationsManager.loadSceneFromData(jsonData);
|
|
2603
|
-
case
|
|
2589
|
+
case 10:
|
|
2604
2590
|
console.log('✅ Scene imported successfully');
|
|
2605
2591
|
return _context10.a(2, true);
|
|
2606
|
-
case
|
|
2592
|
+
case 11:
|
|
2607
2593
|
console.error('❌ SceneViewer not available for scene loading');
|
|
2608
2594
|
return _context10.a(2, false);
|
|
2609
|
-
case
|
|
2610
|
-
_context10.n =
|
|
2595
|
+
case 12:
|
|
2596
|
+
_context10.n = 14;
|
|
2611
2597
|
break;
|
|
2612
|
-
case
|
|
2613
|
-
_context10.p =
|
|
2598
|
+
case 13:
|
|
2599
|
+
_context10.p = 13;
|
|
2614
2600
|
_t5 = _context10.v;
|
|
2615
2601
|
console.error('❌ Error importing scene:', _t5);
|
|
2616
2602
|
return _context10.a(2, false);
|
|
2617
|
-
case
|
|
2603
|
+
case 14:
|
|
2618
2604
|
return _context10.a(2);
|
|
2619
2605
|
}
|
|
2620
|
-
}, _callee10, this, [[
|
|
2606
|
+
}, _callee10, this, [[3, 7], [1, 13]]);
|
|
2621
2607
|
}));
|
|
2622
2608
|
function importScene(_x6) {
|
|
2623
2609
|
return _importScene.apply(this, arguments);
|
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();
|
|
@@ -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 };
|