@2112-lab/central-plant 0.3.34 → 0.3.36
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 +632 -170
- package/dist/cjs/src/core/centralPlant.js +41 -17
- package/dist/cjs/src/core/centralPlantInternals.js +6 -2
- package/dist/cjs/src/core/sceneViewer.js +6 -24
- package/dist/cjs/src/managers/behaviors/IoBehaviorManager.js +510 -44
- package/dist/cjs/src/managers/cache/S3CacheService.js +2 -33
- package/dist/cjs/src/managers/cache/S3MetadataCacheService.js +0 -1
- package/dist/cjs/src/managers/components/componentDataManager.js +2 -6
- package/dist/cjs/src/managers/controls/transformControlsManager.js +32 -10
- package/dist/cjs/src/managers/scene/modelManager.js +11 -5
- package/dist/cjs/src/managers/scene/sceneExportManager.js +10 -3
- package/dist/cjs/src/managers/scene/sceneOperationsManager.js +11 -3
- package/dist/cjs/src/rendering/modelPreloader.js +1 -17
- package/dist/cjs/src/utils/ioDeviceUtils.js +0 -5
- package/dist/esm/src/core/centralPlant.js +41 -17
- package/dist/esm/src/core/centralPlantInternals.js +6 -2
- package/dist/esm/src/core/sceneViewer.js +6 -24
- package/dist/esm/src/managers/behaviors/IoBehaviorManager.js +511 -45
- package/dist/esm/src/managers/cache/S3CacheService.js +2 -33
- package/dist/esm/src/managers/cache/S3MetadataCacheService.js +0 -1
- package/dist/esm/src/managers/components/componentDataManager.js +2 -6
- package/dist/esm/src/managers/controls/transformControlsManager.js +32 -10
- package/dist/esm/src/managers/scene/modelManager.js +11 -5
- package/dist/esm/src/managers/scene/sceneExportManager.js +10 -3
- package/dist/esm/src/managers/scene/sceneOperationsManager.js +11 -3
- package/dist/esm/src/rendering/modelPreloader.js +1 -17
- package/dist/esm/src/utils/ioDeviceUtils.js +0 -5
- package/package.json +1 -1
|
@@ -42,6 +42,24 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
42
42
|
* }>
|
|
43
43
|
*/
|
|
44
44
|
_this._entries = new Map();
|
|
45
|
+
_this._crossComponentBehaviors = [];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Map: `${componentUuid}` → Array<{ id, input, outputs }>
|
|
49
|
+
* Component-level behaviors for intra-component io-device linking
|
|
50
|
+
*/
|
|
51
|
+
_this._componentBehaviors = new Map();
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Injected by the host application to read and write I/O device state.
|
|
55
|
+
* Set via configure(). Shape:
|
|
56
|
+
* {
|
|
57
|
+
* getState(attachmentId, dataPointId) -> value | null,
|
|
58
|
+
* setState(attachmentId, dataPointId, value) -> void
|
|
59
|
+
* }
|
|
60
|
+
* @type {{ getState: Function, setState: Function } | null}
|
|
61
|
+
*/
|
|
62
|
+
_this._stateAdapter = null;
|
|
45
63
|
return _this;
|
|
46
64
|
}
|
|
47
65
|
|
|
@@ -119,9 +137,7 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
119
137
|
}
|
|
120
138
|
if (entries.length) {
|
|
121
139
|
this._entries.set(key, entries);
|
|
122
|
-
|
|
123
|
-
return e.anim.stateVariable;
|
|
124
|
-
}).join(', ')));
|
|
140
|
+
// Loaded ${entries.length} animation(s) for attachment "${attachmentId}"
|
|
125
141
|
} else {
|
|
126
142
|
console.warn("[IoBehaviorManager] No mesh entries resolved for attachment \"".concat(attachmentId, "\" \u2014 behaviorConfig had ").concat(anims.length, " entries but none matched a mesh"));
|
|
127
143
|
}
|
|
@@ -139,29 +155,479 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
139
155
|
}, {
|
|
140
156
|
key: "triggerState",
|
|
141
157
|
value: function triggerState(attachmentId, dataPointId, value, parentUuid) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
158
|
+
// triggerState: ${attachmentId}.${dataPointId} = ${value}
|
|
159
|
+
|
|
160
|
+
if (parentUuid) {
|
|
161
|
+
var key = this._key(parentUuid, attachmentId);
|
|
162
|
+
var entries = this._entries.get(key);
|
|
163
|
+
if (entries) {
|
|
164
|
+
var _iterator2 = _rollupPluginBabelHelpers.createForOfIteratorHelper(entries),
|
|
165
|
+
_step2;
|
|
149
166
|
try {
|
|
150
|
-
for (
|
|
151
|
-
var entry =
|
|
167
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
168
|
+
var entry = _step2.value;
|
|
152
169
|
if (entry.anim.stateVariable !== dataPointId) continue;
|
|
153
170
|
this._applyAnimation(entry, value);
|
|
154
171
|
}
|
|
155
172
|
} catch (err) {
|
|
156
|
-
|
|
173
|
+
_iterator2.e(err);
|
|
157
174
|
} finally {
|
|
158
|
-
|
|
175
|
+
_iterator2.f();
|
|
159
176
|
}
|
|
160
177
|
}
|
|
178
|
+
} else {
|
|
179
|
+
// Fallback when parentUuid is not provided: match by attachmentId suffix or exact key match
|
|
180
|
+
var suffix = "::".concat(attachmentId);
|
|
181
|
+
var _iterator3 = _rollupPluginBabelHelpers.createForOfIteratorHelper(this._entries.entries()),
|
|
182
|
+
_step3;
|
|
183
|
+
try {
|
|
184
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
185
|
+
var _step3$value = _rollupPluginBabelHelpers.slicedToArray(_step3.value, 2),
|
|
186
|
+
_key2 = _step3$value[0],
|
|
187
|
+
_entries = _step3$value[1];
|
|
188
|
+
if (_key2 === attachmentId || _key2.endsWith(suffix)) {
|
|
189
|
+
var _iterator4 = _rollupPluginBabelHelpers.createForOfIteratorHelper(_entries),
|
|
190
|
+
_step4;
|
|
191
|
+
try {
|
|
192
|
+
for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
|
|
193
|
+
var _entry = _step4.value;
|
|
194
|
+
if (_entry.anim.stateVariable !== dataPointId) continue;
|
|
195
|
+
this._applyAnimation(_entry, value);
|
|
196
|
+
}
|
|
197
|
+
} catch (err) {
|
|
198
|
+
_iterator4.e(err);
|
|
199
|
+
} finally {
|
|
200
|
+
_iterator4.f();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
} catch (err) {
|
|
205
|
+
_iterator3.e(err);
|
|
206
|
+
} finally {
|
|
207
|
+
_iterator3.f();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Evaluate component-level behaviors (intra-component io-device linking)
|
|
212
|
+
if (parentUuid && this._componentBehaviors.has(parentUuid)) {
|
|
213
|
+
var componentBehaviors = this._componentBehaviors.get(parentUuid);
|
|
214
|
+
// Checking component-level behaviors (count: ${componentBehaviors.length})
|
|
215
|
+
this.triggerCrossComponentBehaviors(componentBehaviors, parentUuid, attachmentId, dataPointId, value);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Evaluate cross-component behaviors if any are registered
|
|
219
|
+
// Checking cross-component behaviors (count: ${this._crossComponentBehaviors?.length || 0})
|
|
220
|
+
if (this._crossComponentBehaviors && this._crossComponentBehaviors.length > 0) {
|
|
221
|
+
this.triggerCrossComponentBehaviors(this._crossComponentBehaviors, parentUuid, attachmentId, dataPointId, value);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Register the root-level cross-component behaviors from the scene.
|
|
227
|
+
* Normalizes shorthand syntax to full format.
|
|
228
|
+
*
|
|
229
|
+
* @param {Array} behaviors
|
|
230
|
+
*/
|
|
231
|
+
}, {
|
|
232
|
+
key: "setCrossComponentBehaviors",
|
|
233
|
+
value: function setCrossComponentBehaviors(behaviors) {
|
|
234
|
+
var _this2 = this;
|
|
235
|
+
this._crossComponentBehaviors = (behaviors || []).map(function (b) {
|
|
236
|
+
return _this2._normalizeBehavior(b);
|
|
237
|
+
});
|
|
238
|
+
// Loaded ${this._crossComponentBehaviors.length} cross-component behavior(s)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Register component-level behaviors (intra-component io-device linking).
|
|
243
|
+
* These behaviors are defined in the smart component's JSON and link devices within the same component instance.
|
|
244
|
+
*
|
|
245
|
+
* @param {string} componentUuid - The UUID of the component
|
|
246
|
+
* @param {Array} behaviors - Array of behaviors in shorthand format
|
|
247
|
+
*/
|
|
248
|
+
}, {
|
|
249
|
+
key: "registerComponentBehaviors",
|
|
250
|
+
value: function registerComponentBehaviors(componentUuid, behaviors) {
|
|
251
|
+
var _this3 = this;
|
|
252
|
+
if (!behaviors || behaviors.length === 0) return;
|
|
253
|
+
var normalized = behaviors.map(function (b) {
|
|
254
|
+
return _this3._normalizeBehavior(b);
|
|
255
|
+
});
|
|
256
|
+
this._componentBehaviors.set(componentUuid, normalized);
|
|
257
|
+
// Registered ${normalized.length} component-level behavior(s) for component ${componentUuid}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Normalize behavior from shorthand to full format.
|
|
262
|
+
* Supports:
|
|
263
|
+
* - input: "attachment.state" → { attachment, state }
|
|
264
|
+
* - outputs: ["attachment.state", ...] → converted to individual behaviors
|
|
265
|
+
*
|
|
266
|
+
* @param {Object} behavior - Raw behavior from scene JSON
|
|
267
|
+
* @returns {Object} Normalized behavior
|
|
268
|
+
*/
|
|
269
|
+
}, {
|
|
270
|
+
key: "_normalizeBehavior",
|
|
271
|
+
value: function _normalizeBehavior(behavior) {
|
|
272
|
+
var normalized = _rollupPluginBabelHelpers.objectSpread2({}, behavior);
|
|
273
|
+
|
|
274
|
+
// Parse shorthand input: "attachment.state"
|
|
275
|
+
if (typeof behavior.input === 'string') {
|
|
276
|
+
var _behavior$input$split = behavior.input.split('.'),
|
|
277
|
+
_behavior$input$split2 = _rollupPluginBabelHelpers.slicedToArray(_behavior$input$split, 2),
|
|
278
|
+
attachment = _behavior$input$split2[0],
|
|
279
|
+
state = _behavior$input$split2[1];
|
|
280
|
+
normalized.input = {
|
|
281
|
+
attachment: attachment,
|
|
282
|
+
state: state
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Parse shorthand output/outputs
|
|
287
|
+
if (behavior.outputs) {
|
|
288
|
+
// Multiple outputs - expand to array
|
|
289
|
+
normalized._outputs = behavior.outputs.map(function (out) {
|
|
290
|
+
if (typeof out === 'string') {
|
|
291
|
+
var _out$split = out.split('.'),
|
|
292
|
+
_out$split2 = _rollupPluginBabelHelpers.slicedToArray(_out$split, 2),
|
|
293
|
+
_attachment = _out$split2[0],
|
|
294
|
+
_state = _out$split2[1];
|
|
295
|
+
return {
|
|
296
|
+
attachment: _attachment,
|
|
297
|
+
state: _state
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
return out;
|
|
301
|
+
});
|
|
302
|
+
delete normalized.outputs;
|
|
303
|
+
} else if (typeof behavior.output === 'string') {
|
|
304
|
+
// Single output string
|
|
305
|
+
var _behavior$output$spli = behavior.output.split('.'),
|
|
306
|
+
_behavior$output$spli2 = _rollupPluginBabelHelpers.slicedToArray(_behavior$output$spli, 2),
|
|
307
|
+
_attachment2 = _behavior$output$spli2[0],
|
|
308
|
+
_state2 = _behavior$output$spli2[1];
|
|
309
|
+
normalized.output = {
|
|
310
|
+
attachment: _attachment2,
|
|
311
|
+
state: _state2
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
return normalized;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/**
|
|
318
|
+
* Find the parent component UUID for a given attachment ID.
|
|
319
|
+
* Searches the scene tree for the io-device with this attachment ID,
|
|
320
|
+
* then returns its parentComponentId.
|
|
321
|
+
*
|
|
322
|
+
* @param {string} attachmentId
|
|
323
|
+
* @returns {string|null} Component UUID or null if not found
|
|
324
|
+
*/
|
|
325
|
+
}, {
|
|
326
|
+
key: "_findComponentByAttachment",
|
|
327
|
+
value: function _findComponentByAttachment(attachmentId) {
|
|
328
|
+
var _this$sceneViewer;
|
|
329
|
+
if (!((_this$sceneViewer = this.sceneViewer) !== null && _this$sceneViewer !== void 0 && _this$sceneViewer.scene)) return null;
|
|
330
|
+
var scene = this.sceneViewer.scene;
|
|
331
|
+
var found = null;
|
|
332
|
+
scene.traverse(function (obj) {
|
|
333
|
+
var _obj$userData, _obj$userData2;
|
|
334
|
+
if (found) return;
|
|
335
|
+
// Find the io-device object with this attachmentId
|
|
336
|
+
if (((_obj$userData = obj.userData) === null || _obj$userData === void 0 ? void 0 : _obj$userData.objectType) === 'io-device' && ((_obj$userData2 = obj.userData) === null || _obj$userData2 === void 0 ? void 0 : _obj$userData2.attachmentId) === attachmentId) {
|
|
337
|
+
found = obj.userData.parentComponentId;
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
if (!found) {
|
|
341
|
+
console.warn("[Behavior] Could not find parent component for attachment \"".concat(attachmentId, "\""));
|
|
342
|
+
}
|
|
343
|
+
return found;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Inject a state adapter so cross-component behaviors can write I/O device state.
|
|
348
|
+
* Call this once after the host application's state store is ready.
|
|
349
|
+
*
|
|
350
|
+
* @param {{ getState: Function, setState: Function }} stateAdapter
|
|
351
|
+
* - getState(attachmentId, dataPointId) -> current value (any) | null
|
|
352
|
+
* - setState(attachmentId, dataPointId, value) -> void
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* // Sandbox (Vuex)
|
|
356
|
+
* ioBehaviorManager.configure({
|
|
357
|
+
* getState: (attId, dpId) =>
|
|
358
|
+
* store.getters['assetManagerStore/ioDeviceState'](attId)(dpId) ?? null,
|
|
359
|
+
* setState: (attId, dpId, value) =>
|
|
360
|
+
* store.dispatch('assetManagerStore/setIoDeviceState',
|
|
361
|
+
* { attachmentId: attId, dataPointId: dpId, value })
|
|
362
|
+
* })
|
|
363
|
+
*/
|
|
364
|
+
}, {
|
|
365
|
+
key: "configure",
|
|
366
|
+
value: function configure(stateAdapter) {
|
|
367
|
+
this._stateAdapter = stateAdapter || null;
|
|
368
|
+
// State adapter configured
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Evaluate and apply cross-component behaviors loaded from the scene JSON.
|
|
373
|
+
*
|
|
374
|
+
* @param {Array} behaviors - Root-level behaviors array from the scene JSON
|
|
375
|
+
* @param {string} triggerParentUuid - Parent component UUID of the triggering device
|
|
376
|
+
* @param {string} triggerAttachmentId - Attachment ID of the triggering device
|
|
377
|
+
* @param {string} triggerStateId - The state variable ID that changed
|
|
378
|
+
* @param {*} value - The new state value
|
|
379
|
+
*/
|
|
380
|
+
}, {
|
|
381
|
+
key: "triggerCrossComponentBehaviors",
|
|
382
|
+
value: function triggerCrossComponentBehaviors(behaviors, triggerParentUuid, triggerAttachmentId, triggerStateId, value) {
|
|
383
|
+
if (!behaviors || !Array.isArray(behaviors)) {
|
|
384
|
+
return;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
// Evaluating ${behaviors.length} behavior(s)
|
|
388
|
+
var _iterator5 = _rollupPluginBabelHelpers.createForOfIteratorHelper(behaviors),
|
|
389
|
+
_step5;
|
|
390
|
+
try {
|
|
391
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
392
|
+
var behavior = _step5.value;
|
|
393
|
+
var input = behavior.input,
|
|
394
|
+
output = behavior.output,
|
|
395
|
+
_outputs = behavior._outputs,
|
|
396
|
+
conditions = behavior.conditions;
|
|
397
|
+
if (!input || !output && !_outputs) {
|
|
398
|
+
console.warn('[Behavior] Skipping behavior - missing input or output(s):', behavior);
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// Auto-lookup component if not specified
|
|
403
|
+
var inputComponent = input.component || this._findComponentByAttachment(input.attachment);
|
|
404
|
+
console.log("[Behavior] Checking behavior \"".concat(behavior.id, "\":"), {
|
|
405
|
+
inputMatch: inputComponent === triggerParentUuid,
|
|
406
|
+
attachmentMatch: input.attachment === triggerAttachmentId,
|
|
407
|
+
stateMatch: input.state === triggerStateId,
|
|
408
|
+
expected: {
|
|
409
|
+
component: inputComponent,
|
|
410
|
+
attachment: input.attachment,
|
|
411
|
+
state: input.state
|
|
412
|
+
},
|
|
413
|
+
actual: {
|
|
414
|
+
component: triggerParentUuid,
|
|
415
|
+
attachment: triggerAttachmentId,
|
|
416
|
+
state: triggerStateId
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
// Verify that the input matches the triggering source
|
|
421
|
+
if (inputComponent === triggerParentUuid && input.attachment === triggerAttachmentId && input.state === triggerStateId) {
|
|
422
|
+
// Behavior "${behavior.id}" matched
|
|
423
|
+
|
|
424
|
+
// Collect all outputs (single or multiple)
|
|
425
|
+
var outputs = _outputs || (output ? [output] : []);
|
|
426
|
+
|
|
427
|
+
// Process each output
|
|
428
|
+
var _iterator6 = _rollupPluginBabelHelpers.createForOfIteratorHelper(outputs),
|
|
429
|
+
_step6;
|
|
430
|
+
try {
|
|
431
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
432
|
+
var out = _step6.value;
|
|
433
|
+
// NEW: State-to-state pass-through pattern
|
|
434
|
+
if (out.state) {
|
|
435
|
+
// Auto-lookup output component if not specified
|
|
436
|
+
var outputComponent = out.component || this._findComponentByAttachment(out.attachment);
|
|
437
|
+
|
|
438
|
+
// Direct state mapping without conditions
|
|
439
|
+
if (this._stateAdapter) {
|
|
440
|
+
// Dispatching state-to-state: ${out.attachment}.${out.state} = ${value}
|
|
441
|
+
this._stateAdapter.setState(out.attachment, out.state, value);
|
|
442
|
+
|
|
443
|
+
// Trigger animations on the output component
|
|
444
|
+
// triggerState(attachmentId, dataPointId, value, parentUuid)
|
|
445
|
+
if (outputComponent) {
|
|
446
|
+
// Triggering animations on output component
|
|
447
|
+
this.triggerState(out.attachment, out.state, value, outputComponent);
|
|
448
|
+
} else {
|
|
449
|
+
console.warn("[Behavior] Could not find component for attachment \"".concat(out.attachment, "\""));
|
|
450
|
+
}
|
|
451
|
+
} else {
|
|
452
|
+
console.warn('[Behavior] ✗ State adapter not configured for state-to-state behavior');
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
// LEGACY: Mesh-based pattern with conditions
|
|
456
|
+
else if (conditions && out.child) {
|
|
457
|
+
// Using legacy mesh-based pattern with conditions
|
|
458
|
+
// Evaluate conditions
|
|
459
|
+
var _iterator7 = _rollupPluginBabelHelpers.createForOfIteratorHelper(conditions),
|
|
460
|
+
_step7;
|
|
461
|
+
try {
|
|
462
|
+
for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
|
|
463
|
+
var condition = _step7.value;
|
|
464
|
+
if (this._evaluateCondition(condition.when, value)) {
|
|
465
|
+
// Apply actions to the target output component/attachment/child mesh
|
|
466
|
+
this._applyCrossComponentActions(out, condition.actions);
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
} catch (err) {
|
|
470
|
+
_iterator7.e(err);
|
|
471
|
+
} finally {
|
|
472
|
+
_iterator7.f();
|
|
473
|
+
}
|
|
474
|
+
} else {
|
|
475
|
+
console.warn('[Behavior] Output has neither state nor (child + conditions):', out);
|
|
476
|
+
}
|
|
477
|
+
} // end outputs loop
|
|
478
|
+
} catch (err) {
|
|
479
|
+
_iterator6.e(err);
|
|
480
|
+
} finally {
|
|
481
|
+
_iterator6.f();
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
} catch (err) {
|
|
486
|
+
_iterator5.e(err);
|
|
487
|
+
} finally {
|
|
488
|
+
_iterator5.f();
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
* Safely evaluate a condition expression.
|
|
494
|
+
*/
|
|
495
|
+
}, {
|
|
496
|
+
key: "_evaluateCondition",
|
|
497
|
+
value: function _evaluateCondition(whenExpr, value) {
|
|
498
|
+
try {
|
|
499
|
+
var fn = new Function('state', "return (".concat(whenExpr, ");"));
|
|
500
|
+
return fn({
|
|
501
|
+
value: value
|
|
502
|
+
});
|
|
503
|
+
} catch (err) {
|
|
504
|
+
console.warn("[IoBehaviorManager] Failed to evaluate condition: \"".concat(whenExpr, "\""), err);
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Resolve target output mesh and apply actions.
|
|
511
|
+
*/
|
|
512
|
+
}, {
|
|
513
|
+
key: "_applyCrossComponentActions",
|
|
514
|
+
value: function _applyCrossComponentActions(output, actions) {
|
|
515
|
+
var _this$sceneViewer2;
|
|
516
|
+
if (!actions || !Array.isArray(actions)) return;
|
|
517
|
+
|
|
518
|
+
// 1. Resolve output component
|
|
519
|
+
var scene = (_this$sceneViewer2 = this.sceneViewer) === null || _this$sceneViewer2 === void 0 ? void 0 : _this$sceneViewer2.scene;
|
|
520
|
+
if (!scene) return;
|
|
521
|
+
var componentModel = scene.getObjectByProperty('uuid', output.component) || scene.getObjectByProperty('name', output.component);
|
|
522
|
+
if (!componentModel) {
|
|
523
|
+
console.warn("[IoBehaviorManager] Output component \"".concat(output.component, "\" not found in scene"));
|
|
524
|
+
return;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
// 2. Resolve attachment model under the component
|
|
528
|
+
var deviceRoot = null;
|
|
529
|
+
componentModel.traverse(function (obj) {
|
|
530
|
+
var _obj$userData3;
|
|
531
|
+
if (!deviceRoot && ((_obj$userData3 = obj.userData) === null || _obj$userData3 === void 0 ? void 0 : _obj$userData3.attachmentId) === output.attachment) {
|
|
532
|
+
deviceRoot = obj;
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
if (!deviceRoot) {
|
|
536
|
+
console.warn("[IoBehaviorManager] Output attachment \"".concat(output.attachment, "\" not found on component \"").concat(output.component, "\""));
|
|
537
|
+
return;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
// 3. Resolve child mesh if specified
|
|
541
|
+
var targetObj = deviceRoot;
|
|
542
|
+
if (output.child) {
|
|
543
|
+
var foundChild = null;
|
|
544
|
+
deviceRoot.traverse(function (obj) {
|
|
545
|
+
if (!foundChild && obj.name === output.child) {
|
|
546
|
+
foundChild = obj;
|
|
547
|
+
}
|
|
548
|
+
});
|
|
549
|
+
if (foundChild) {
|
|
550
|
+
targetObj = foundChild;
|
|
551
|
+
} else {
|
|
552
|
+
console.warn("[IoBehaviorManager] Child \"".concat(output.child, "\" not found under attachment \"").concat(output.attachment, "\" on component \"").concat(output.component, "\""));
|
|
553
|
+
return;
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// 4. Apply actions to targetObj
|
|
558
|
+
var _iterator8 = _rollupPluginBabelHelpers.createForOfIteratorHelper(actions),
|
|
559
|
+
_step8;
|
|
560
|
+
try {
|
|
561
|
+
for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
|
|
562
|
+
var action = _step8.value;
|
|
563
|
+
this._applyCrossComponentAction(targetObj, action);
|
|
564
|
+
}
|
|
161
565
|
} catch (err) {
|
|
162
|
-
|
|
566
|
+
_iterator8.e(err);
|
|
163
567
|
} finally {
|
|
164
|
-
|
|
568
|
+
_iterator8.f();
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Apply a single action to the target mesh.
|
|
574
|
+
*/
|
|
575
|
+
}, {
|
|
576
|
+
key: "_applyCrossComponentAction",
|
|
577
|
+
value: function _applyCrossComponentAction(targetObj, action) {
|
|
578
|
+
var set = action.set,
|
|
579
|
+
value = action.value;
|
|
580
|
+
if (!set) return;
|
|
581
|
+
if (set.startsWith('material.')) {
|
|
582
|
+
var prop = set.slice(9);
|
|
583
|
+
targetObj.traverse(function (obj) {
|
|
584
|
+
if (!obj.isMesh || !obj.material) return;
|
|
585
|
+
if (!obj.userData._materialCloned) {
|
|
586
|
+
obj.material = obj.material.clone();
|
|
587
|
+
obj.userData._materialCloned = true;
|
|
588
|
+
}
|
|
589
|
+
try {
|
|
590
|
+
if (prop === 'color') {
|
|
591
|
+
obj.material.color.set(value);
|
|
592
|
+
} else {
|
|
593
|
+
if (prop in obj.material) {
|
|
594
|
+
if (obj.material[prop] && typeof obj.material[prop].set === 'function') {
|
|
595
|
+
obj.material[prop].set(value);
|
|
596
|
+
} else {
|
|
597
|
+
obj.material[prop] = value;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
} catch (err) {
|
|
602
|
+
console.warn("[IoBehaviorManager] Failed to set material property \"".concat(prop, "\""), err);
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
} else if (set === 'visible') {
|
|
606
|
+
targetObj.visible = !!value;
|
|
607
|
+
} else {
|
|
608
|
+
// General fallback path parsing (e.g. position.z)
|
|
609
|
+
var parts = set.split('.');
|
|
610
|
+
var current = targetObj;
|
|
611
|
+
for (var i = 0; i < parts.length - 1; i++) {
|
|
612
|
+
if (current && current[parts[i]]) {
|
|
613
|
+
current = current[parts[i]];
|
|
614
|
+
} else {
|
|
615
|
+
current = null;
|
|
616
|
+
break;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
if (current) {
|
|
620
|
+
var lastPart = parts[parts.length - 1];
|
|
621
|
+
try {
|
|
622
|
+
if (current[lastPart] && typeof current[lastPart].set === 'function') {
|
|
623
|
+
current[lastPart].set(value);
|
|
624
|
+
} else {
|
|
625
|
+
current[lastPart] = value;
|
|
626
|
+
}
|
|
627
|
+
} catch (err) {
|
|
628
|
+
console.warn("[IoBehaviorManager] Failed to set property \"".concat(set, "\""), err);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
165
631
|
}
|
|
166
632
|
}
|
|
167
633
|
|
|
@@ -191,7 +657,7 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
191
657
|
}, {
|
|
192
658
|
key: "getAnimationDataPoints",
|
|
193
659
|
value: function getAnimationDataPoints(parentUuid, attachmentId) {
|
|
194
|
-
var
|
|
660
|
+
var _this4 = this;
|
|
195
661
|
var hitMesh = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
196
662
|
var key = this._key(parentUuid, attachmentId);
|
|
197
663
|
var entries = this._entries.get(key);
|
|
@@ -203,35 +669,35 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
203
669
|
var filtered = entries;
|
|
204
670
|
if (hitMesh) {
|
|
205
671
|
var matching = entries.filter(function (e) {
|
|
206
|
-
return
|
|
672
|
+
return _this4._isMeshOrDescendant(hitMesh, e.mesh);
|
|
207
673
|
});
|
|
208
674
|
if (matching.length > 0) filtered = matching;
|
|
209
675
|
}
|
|
210
676
|
|
|
211
677
|
// Collapse multiple mesh entries that share the same stateVariable
|
|
212
678
|
var seen = new Map(); // stateVariable → anim
|
|
213
|
-
var
|
|
214
|
-
|
|
679
|
+
var _iterator9 = _rollupPluginBabelHelpers.createForOfIteratorHelper(filtered),
|
|
680
|
+
_step9;
|
|
215
681
|
try {
|
|
216
|
-
for (
|
|
217
|
-
var anim =
|
|
682
|
+
for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
|
|
683
|
+
var anim = _step9.value.anim;
|
|
218
684
|
if (!seen.has(anim.stateVariable)) {
|
|
219
685
|
seen.set(anim.stateVariable, anim);
|
|
220
686
|
}
|
|
221
687
|
}
|
|
222
688
|
} catch (err) {
|
|
223
|
-
|
|
689
|
+
_iterator9.e(err);
|
|
224
690
|
} finally {
|
|
225
|
-
|
|
691
|
+
_iterator9.f();
|
|
226
692
|
}
|
|
227
693
|
var dps = [];
|
|
228
|
-
var
|
|
229
|
-
|
|
694
|
+
var _iterator0 = _rollupPluginBabelHelpers.createForOfIteratorHelper(seen),
|
|
695
|
+
_step0;
|
|
230
696
|
try {
|
|
231
|
-
for (
|
|
232
|
-
var
|
|
233
|
-
stateVar =
|
|
234
|
-
_anim =
|
|
697
|
+
for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
|
|
698
|
+
var _step0$value = _rollupPluginBabelHelpers.slicedToArray(_step0.value, 2),
|
|
699
|
+
stateVar = _step0$value[0],
|
|
700
|
+
_anim = _step0$value[1];
|
|
235
701
|
// Normalise stateType from AnimateDevicesDialog variants
|
|
236
702
|
var stateType = void 0;
|
|
237
703
|
var raw = (_anim.stateType || '').toLowerCase();
|
|
@@ -282,9 +748,9 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
282
748
|
});
|
|
283
749
|
}
|
|
284
750
|
} catch (err) {
|
|
285
|
-
|
|
751
|
+
_iterator0.e(err);
|
|
286
752
|
} finally {
|
|
287
|
-
|
|
753
|
+
_iterator0.f();
|
|
288
754
|
}
|
|
289
755
|
return dps;
|
|
290
756
|
}
|
|
@@ -319,19 +785,19 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
319
785
|
key: "unloadForComponent",
|
|
320
786
|
value: function unloadForComponent(parentUuid) {
|
|
321
787
|
var prefix = "".concat(parentUuid, "::");
|
|
322
|
-
var
|
|
323
|
-
|
|
788
|
+
var _iterator1 = _rollupPluginBabelHelpers.createForOfIteratorHelper(this._entries.keys()),
|
|
789
|
+
_step1;
|
|
324
790
|
try {
|
|
325
|
-
for (
|
|
326
|
-
var key =
|
|
791
|
+
for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
|
|
792
|
+
var key = _step1.value;
|
|
327
793
|
if (key.startsWith(prefix)) {
|
|
328
794
|
this._entries.delete(key);
|
|
329
795
|
}
|
|
330
796
|
}
|
|
331
797
|
} catch (err) {
|
|
332
|
-
|
|
798
|
+
_iterator1.e(err);
|
|
333
799
|
} finally {
|
|
334
|
-
|
|
800
|
+
_iterator1.f();
|
|
335
801
|
}
|
|
336
802
|
}
|
|
337
803
|
}, {
|
|
@@ -415,11 +881,11 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
415
881
|
var mapping = this._resolveMapping(anim, value);
|
|
416
882
|
if (!mapping) return;
|
|
417
883
|
var types = anim.transformTypes || [];
|
|
418
|
-
var
|
|
419
|
-
|
|
884
|
+
var _iterator10 = _rollupPluginBabelHelpers.createForOfIteratorHelper(types),
|
|
885
|
+
_step10;
|
|
420
886
|
try {
|
|
421
|
-
for (
|
|
422
|
-
var type =
|
|
887
|
+
for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
|
|
888
|
+
var type = _step10.value;
|
|
423
889
|
if (type === 'translation') {
|
|
424
890
|
this._applyTranslation(mesh, origPos, mapping.transform);
|
|
425
891
|
} else if (type === 'rotation') {
|
|
@@ -429,9 +895,9 @@ var IoBehaviorManager = /*#__PURE__*/function (_BaseDisposable) {
|
|
|
429
895
|
}
|
|
430
896
|
}
|
|
431
897
|
} catch (err) {
|
|
432
|
-
|
|
898
|
+
_iterator10.e(err);
|
|
433
899
|
} finally {
|
|
434
|
-
|
|
900
|
+
_iterator10.f();
|
|
435
901
|
}
|
|
436
902
|
}
|
|
437
903
|
|