@onerjs/core 8.44.7 → 8.44.9
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/Bones/skeleton.d.ts +5 -0
- package/Bones/skeleton.js +35 -8
- package/Bones/skeleton.js.map +1 -1
- package/Collisions/collider.js +2 -2
- package/Collisions/collider.js.map +1 -1
- package/Culling/Helper/computeShaderBoundingHelper.js +8 -1
- package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
- package/Culling/Helper/transformFeedbackBoundingHelper.js +1 -1
- package/Culling/Helper/transformFeedbackBoundingHelper.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessingContext.d.ts +1 -0
- package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessor.d.ts +1 -1
- package/Engines/WebGPU/webgpuShaderProcessor.js +2 -2
- package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +20 -2
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.d.ts +2 -1
- package/Engines/engineCapabilities.d.ts +2 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/nullEngine.js +1 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +1 -0
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/thinNativeEngine.js +1 -0
- package/Engines/thinNativeEngine.js.map +1 -1
- package/Engines/webgpuEngine.js +1 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphDebugBlock.d.ts +45 -0
- package/FlowGraph/Blocks/Data/flowGraphDebugBlock.js +98 -0
- package/FlowGraph/Blocks/Data/flowGraphDebugBlock.js.map +1 -0
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +16 -0
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +15 -2
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphPointerDownEventBlock.d.ts +64 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerDownEventBlock.js +54 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerDownEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerMoveEventBlock.d.ts +64 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerMoveEventBlock.js +54 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerMoveEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerUpEventBlock.d.ts +64 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerUpEventBlock.js +54 -0
- package/FlowGraph/Blocks/Event/flowGraphPointerUpEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +17 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js +23 -3
- package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.js +2 -2
- package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +7 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.d.ts +4 -0
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +6 -2
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +2 -2
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +0 -4
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +16 -0
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +2 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +63 -2
- package/FlowGraph/flowGraph.js +210 -19
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +73 -0
- package/FlowGraph/flowGraphContext.js +115 -0
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphExecutionBlock.d.ts +7 -0
- package/FlowGraph/flowGraphExecutionBlock.js +7 -0
- package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
- package/FlowGraph/flowGraphParser.js +1 -0
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/FlowGraph/flowGraphSceneEventCoordinator.d.ts +3 -0
- package/FlowGraph/flowGraphSceneEventCoordinator.js +13 -1
- package/FlowGraph/flowGraphSceneEventCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphSignalConnection.d.ts +5 -0
- package/FlowGraph/flowGraphSignalConnection.js +12 -0
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
- package/FlowGraph/flowGraphValidator.d.ts +66 -0
- package/FlowGraph/flowGraphValidator.js +324 -0
- package/FlowGraph/flowGraphValidator.js.map +1 -0
- package/FlowGraph/index.d.ts +1 -0
- package/FlowGraph/index.js +1 -0
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/serialization.js +10 -3
- package/FlowGraph/serialization.js.map +1 -1
- package/Layers/thinEffectLayer.js +1 -1
- package/Layers/thinEffectLayer.js.map +1 -1
- package/Layers/thinSelectionOutlineLayer.js +1 -1
- package/Layers/thinSelectionOutlineLayer.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +1 -1
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/bonesBlock.js +2 -2
- package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.js +1 -1
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +1 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/materialHelper.functions.js +2 -2
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.js +1 -1
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/standardMaterial.js +1 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/mesh.js +2 -2
- package/Meshes/mesh.js.map +1 -1
- package/Misc/bitArray.js +1 -1
- package/Misc/bitArray.js.map +1 -1
- package/Misc/tools.js +3 -3
- package/Misc/tools.js.map +1 -1
- package/Particles/thinParticleSystem.js +2 -2
- package/Particles/thinParticleSystem.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/Rendering/depthRenderer.js +1 -1
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.js +3 -3
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/outlineRenderer.js +1 -1
- package/Rendering/outlineRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/bonesDeclaration.js +5 -7
- package/Shaders/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +3 -3
- package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/ShadersWGSL/boundingInfo.compute.js +4 -3
- package/ShadersWGSL/boundingInfo.compute.js.map +1 -1
- package/package.json +1 -1
|
@@ -65,6 +65,36 @@ export class FlowGraphContext {
|
|
|
65
65
|
* Observable that is triggered when a node is executed.
|
|
66
66
|
*/
|
|
67
67
|
this.onNodeExecutedObservable = new Observable();
|
|
68
|
+
/**
|
|
69
|
+
* Observable triggered when a breakpoint is hit.
|
|
70
|
+
* Observers receive the pending activation (block, context, signal) that was paused.
|
|
71
|
+
*/
|
|
72
|
+
this.onBreakpointHitObservable = new Observable();
|
|
73
|
+
/**
|
|
74
|
+
* A predicate called before each execution block runs.
|
|
75
|
+
* If it returns true, execution is paused before the block and a
|
|
76
|
+
* pending activation is stored, which can be resumed via
|
|
77
|
+
* {@link continueExecution} or {@link stepExecution}.
|
|
78
|
+
*
|
|
79
|
+
* Set to `null` to disable breakpoint checking.
|
|
80
|
+
*/
|
|
81
|
+
this.breakpointPredicate = null;
|
|
82
|
+
/**
|
|
83
|
+
* The activation that is currently paused due to a breakpoint hit.
|
|
84
|
+
* `null` when execution is not paused on a breakpoint.
|
|
85
|
+
*/
|
|
86
|
+
this._pendingActivation = null;
|
|
87
|
+
/**
|
|
88
|
+
* When true, the next activation will pause regardless of the breakpoint predicate.
|
|
89
|
+
* Set by {@link stepExecution}.
|
|
90
|
+
*/
|
|
91
|
+
this._stepMode = false;
|
|
92
|
+
/**
|
|
93
|
+
* When set, the breakpoint check is skipped for this specific block uniqueId
|
|
94
|
+
* on the very next call to {@link _shouldBreak}. Used by continue/step to avoid
|
|
95
|
+
* immediately re-hitting the breakpoint on the block being resumed.
|
|
96
|
+
*/
|
|
97
|
+
this._skipBreakpointForBlockId = null;
|
|
68
98
|
/**
|
|
69
99
|
* Whether to treat data as right-handed.
|
|
70
100
|
* This is used when serializing data from a right-handed system, while running the context in a left-handed system, for example in glTF parsing.
|
|
@@ -394,6 +424,91 @@ export class FlowGraphContext {
|
|
|
394
424
|
get executionId() {
|
|
395
425
|
return this._executionId;
|
|
396
426
|
}
|
|
427
|
+
// ── Breakpoint API ─────────────────────────────────────────────────
|
|
428
|
+
/**
|
|
429
|
+
* Check whether the given block should break before executing.
|
|
430
|
+
* Called by the signal connection infrastructure.
|
|
431
|
+
* @internal
|
|
432
|
+
* @param block the block about to execute
|
|
433
|
+
* @param signal the signal that is triggering the execution
|
|
434
|
+
* @returns true if execution should be paused (breakpoint hit)
|
|
435
|
+
*/
|
|
436
|
+
_shouldBreak(block, signal) {
|
|
437
|
+
// If continue/step just resumed this specific block, let it through
|
|
438
|
+
if (this._skipBreakpointForBlockId === block.uniqueId) {
|
|
439
|
+
this._skipBreakpointForBlockId = null;
|
|
440
|
+
return false;
|
|
441
|
+
}
|
|
442
|
+
// If already paused on a breakpoint, silently block further execution
|
|
443
|
+
// without overwriting the pending activation or re-notifying observers.
|
|
444
|
+
if (this._pendingActivation) {
|
|
445
|
+
return true;
|
|
446
|
+
}
|
|
447
|
+
if (this._stepMode) {
|
|
448
|
+
this._stepMode = false;
|
|
449
|
+
this._pendingActivation = { block, context: this, signal };
|
|
450
|
+
this.onBreakpointHitObservable.notifyObservers(this._pendingActivation);
|
|
451
|
+
return true;
|
|
452
|
+
}
|
|
453
|
+
if (this.breakpointPredicate && this.breakpointPredicate(block)) {
|
|
454
|
+
this._pendingActivation = { block, context: this, signal };
|
|
455
|
+
this.onBreakpointHitObservable.notifyObservers(this._pendingActivation);
|
|
456
|
+
return true;
|
|
457
|
+
}
|
|
458
|
+
return false;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Returns the currently paused activation, or null if not paused.
|
|
462
|
+
*/
|
|
463
|
+
get pendingActivation() {
|
|
464
|
+
return this._pendingActivation;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Resume execution from a breakpoint hit.
|
|
468
|
+
* The paused block and all downstream blocks will execute normally until
|
|
469
|
+
* the next breakpoint (if any) is hit.
|
|
470
|
+
*/
|
|
471
|
+
continueExecution() {
|
|
472
|
+
const pending = this._pendingActivation;
|
|
473
|
+
if (!pending) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
this._pendingActivation = null;
|
|
477
|
+
// Tell _shouldBreak to skip the breakpoint for this block on re-entry
|
|
478
|
+
this._skipBreakpointForBlockId = pending.block.uniqueId;
|
|
479
|
+
pending.signal._activateSignal(this);
|
|
480
|
+
// Clear in case no re-entry happened (shouldn't linger)
|
|
481
|
+
this._skipBreakpointForBlockId = null;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Execute exactly the paused block and then pause again before the next
|
|
485
|
+
* execution block fires. If no activation is pending, this is a no-op.
|
|
486
|
+
*/
|
|
487
|
+
stepExecution() {
|
|
488
|
+
const pending = this._pendingActivation;
|
|
489
|
+
if (!pending) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
this._pendingActivation = null;
|
|
493
|
+
// Enable step mode so the very next input-signal activation will pause
|
|
494
|
+
this._stepMode = true;
|
|
495
|
+
// Tell _shouldBreak to skip the breakpoint for this block on re-entry
|
|
496
|
+
this._skipBreakpointForBlockId = pending.block.uniqueId;
|
|
497
|
+
pending.signal._activateSignal(this);
|
|
498
|
+
// If nothing further executed (end of chain), clear step mode
|
|
499
|
+
this._stepMode = false;
|
|
500
|
+
this._skipBreakpointForBlockId = null;
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* Discard any pending breakpoint activation without resuming.
|
|
504
|
+
* Used when stopping or resetting the graph.
|
|
505
|
+
* @internal
|
|
506
|
+
*/
|
|
507
|
+
_clearPendingActivation() {
|
|
508
|
+
this._pendingActivation = null;
|
|
509
|
+
this._stepMode = false;
|
|
510
|
+
this._skipBreakpointForBlockId = null;
|
|
511
|
+
}
|
|
397
512
|
/**
|
|
398
513
|
* Serializes a context
|
|
399
514
|
* @param serializationObject the object to write the values in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphContext.js","sourceRoot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I,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClE,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACrE,CAAC;QACN,CAAC;IACL,CAAC;IAED;;OAEG;IACI,YAAY;QACf,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ;AAjdU;IADN,SAAS,EAAE;kDACmB","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport { RandomGUID } from \"../Misc/guid\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraph } from \"./flowGraph\";\r\nimport { defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { AssetType, FlowGraphAssetType } from \"./flowGraphAssetsContext\";\r\nimport { GetFlowGraphAssetWithType } from \"./flowGraphAssetsContext\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { FlowGraphAction, FlowGraphLogger } from \"./flowGraphLogger\";\r\nimport type { IFlowGraphOnTickEventPayload } from \"./Blocks/Event/flowGraphSceneTickEventBlock\";\r\n\r\n/**\r\n * Construction parameters for the context.\r\n */\r\nexport interface IFlowGraphContextConfiguration {\r\n /**\r\n * The scene that the flow graph context belongs to.\r\n */\r\n readonly scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph context.\r\n */\r\n readonly coordinator: FlowGraphCoordinator;\r\n\r\n /**\r\n * The assets context used by the flow graph context.\r\n * If none is provided, a default one will be created.\r\n */\r\n readonly assetsContext?: IAssetContainer;\r\n}\r\n\r\n/**\r\n * Options for parsing a context.\r\n */\r\nexport interface IFlowGraphContextParseOptions {\r\n /**\r\n * A function that parses a value from a serialization object.\r\n * @param key the key of the value\r\n * @param serializationObject the object containing the value\r\n * @param assetsContainer the assets container\r\n * @param scene the current scene\r\n * @returns\r\n */\r\n readonly valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The graph that the context is being parsed in.\r\n */\r\n readonly graph: FlowGraph;\r\n}\r\n/**\r\n * The context represents the current state and execution of the flow graph.\r\n * It contains both user-defined variables, which are derived from\r\n * a more general variable definition, and execution variables that\r\n * are set by the blocks.\r\n */\r\nexport class FlowGraphContext {\r\n /**\r\n * A randomly generated GUID for each context.\r\n */\r\n @serialize()\r\n public uniqueId = RandomGUID();\r\n /**\r\n * These are the variables defined by a user.\r\n */\r\n private _userVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the blocks.\r\n */\r\n private _executionVariables: { [key: string]: any } = {};\r\n\r\n /**\r\n * A context-specific global variables, available to all blocks in the context.\r\n */\r\n private _globalContextVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the values for the data connection points\r\n */\r\n private _connectionValues: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the graph.\r\n */\r\n private readonly _configuration: IFlowGraphContextConfiguration;\r\n /**\r\n * These are blocks that have currently pending tasks/listeners that need to be cleaned up.\r\n */\r\n private _pendingBlocks: FlowGraphAsyncExecutionBlock[] = [];\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n private _executionId = 0;\r\n /**\r\n * Observable that is triggered when a node is executed.\r\n */\r\n public onNodeExecutedObservable: Observable<FlowGraphBlock> = new Observable<FlowGraphBlock>();\r\n\r\n /**\r\n * The assets context used by the flow graph context.\r\n * Note that it can be shared between flow graph contexts.\r\n */\r\n public assetsContext: IAssetContainer;\r\n\r\n /**\r\n * Whether to treat data as right-handed.\r\n * This is used when serializing data from a right-handed system, while running the context in a left-handed system, for example in glTF parsing.\r\n * Default is false.\r\n */\r\n public treatDataAsRightHanded = false;\r\n\r\n private _enableLogging = false;\r\n\r\n /**\r\n * The logger used by the context to log actions.\r\n */\r\n public logger: Nullable<FlowGraphLogger>;\r\n\r\n /**\r\n * Enable logging on this context\r\n */\r\n public get enableLogging() {\r\n return this._enableLogging;\r\n }\r\n\r\n public set enableLogging(value: boolean) {\r\n if (this._enableLogging === value) {\r\n return;\r\n }\r\n this._enableLogging = value;\r\n if (this._enableLogging) {\r\n this.logger = new FlowGraphLogger();\r\n this.logger.logToConsole = true;\r\n } else {\r\n this.logger = null;\r\n }\r\n }\r\n\r\n constructor(params: IFlowGraphContextConfiguration) {\r\n this._configuration = params;\r\n this.assetsContext = params.assetsContext ?? params.scene;\r\n }\r\n\r\n /**\r\n * Check if a user-defined variable is defined.\r\n * @param name the name of the variable\r\n * @returns true if the variable is defined\r\n */\r\n public hasVariable(name: string) {\r\n return name in this._userVariables;\r\n }\r\n\r\n /**\r\n * Set a user-defined variable.\r\n * @param name the name of the variable\r\n * @param value the value of the variable\r\n */\r\n public setVariable(name: string, value: any) {\r\n this._userVariables[name] = value;\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.ContextVariableSet,\r\n payload: {\r\n name,\r\n value,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Get an assets from the assets context based on its type and index in the array\r\n * @param type The type of the asset\r\n * @param index The index of the asset\r\n * @returns The asset or null if not found\r\n */\r\n public getAsset<T extends FlowGraphAssetType>(type: T, index: number): Nullable<AssetType<T>> {\r\n return GetFlowGraphAssetWithType(this.assetsContext, type, index);\r\n }\r\n\r\n /**\r\n * Get a user-defined variable.\r\n * @param name the name of the variable\r\n * @returns the value of the variable\r\n */\r\n public getVariable(name: string): any {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.ContextVariableGet,\r\n payload: {\r\n name,\r\n value: this._userVariables[name],\r\n },\r\n });\r\n return this._userVariables[name];\r\n }\r\n\r\n /**\r\n * Gets all user variables map\r\n */\r\n public get userVariables() {\r\n return this._userVariables;\r\n }\r\n\r\n /**\r\n * Get the scene that the context belongs to.\r\n * @returns the scene\r\n */\r\n public getScene() {\r\n return this._configuration.scene;\r\n }\r\n\r\n private _getUniqueIdPrefixedName(obj: FlowGraphBlock, name: string): string {\r\n return `${obj.uniqueId}_${name}`;\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param name name of the variable\r\n * @param defaultValue default value to return if the variable is not defined\r\n * @returns the variable value or the default value if the variable is not defined\r\n */\r\n public _getGlobalContextVariable<T>(name: string, defaultValue: T): T {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableGet,\r\n payload: {\r\n name,\r\n defaultValue,\r\n possibleValue: this._globalContextVariables[name],\r\n },\r\n });\r\n if (this._hasGlobalContextVariable(name)) {\r\n return this._globalContextVariables[name];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Set a global context variable\r\n * @internal\r\n * @param name the name of the variable\r\n * @param value the value of the variable\r\n */\r\n public _setGlobalContextVariable<T>(name: string, value: T) {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableSet,\r\n payload: { name, value },\r\n });\r\n this._globalContextVariables[name] = value;\r\n }\r\n\r\n /**\r\n * Delete a global context variable\r\n * @internal\r\n * @param name the name of the variable\r\n */\r\n public _deleteGlobalContextVariable(name: string) {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableDelete,\r\n payload: { name },\r\n });\r\n delete this._globalContextVariables[name];\r\n }\r\n\r\n /**\r\n * Check if a global context variable is defined\r\n * @internal\r\n * @param name the name of the variable\r\n * @returns true if the variable is defined\r\n */\r\n public _hasGlobalContextVariable(name: string) {\r\n return name in this._globalContextVariables;\r\n }\r\n\r\n /**\r\n * Set an internal execution variable\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public _setExecutionVariable(block: FlowGraphBlock, name: string, value: any) {\r\n this._executionVariables[this._getUniqueIdPrefixedName(block, name)] = value;\r\n }\r\n\r\n /**\r\n * Get an internal execution variable\r\n * @internal\r\n * @param name\r\n * @returns\r\n */\r\n public _getExecutionVariable<T>(block: FlowGraphBlock, name: string, defaultValue: T): T {\r\n if (this._hasExecutionVariable(block, name)) {\r\n return this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Delete an internal execution variable\r\n * @internal\r\n * @param block\r\n * @param name\r\n */\r\n public _deleteExecutionVariable(block: FlowGraphBlock, name: string) {\r\n delete this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n }\r\n\r\n /**\r\n * Check if an internal execution variable is defined\r\n * @internal\r\n * @param block\r\n * @param name\r\n * @returns\r\n */\r\n public _hasExecutionVariable(block: FlowGraphBlock, name: string) {\r\n return this._getUniqueIdPrefixedName(block, name) in this._executionVariables;\r\n }\r\n\r\n /**\r\n * Check if a connection value is defined\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _hasConnectionValue(connectionPoint: FlowGraphDataConnection<any>) {\r\n return connectionPoint.uniqueId in this._connectionValues;\r\n }\r\n\r\n /**\r\n * Set a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @param value\r\n */\r\n public _setConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>, value: T) {\r\n this._connectionValues[connectionPoint.uniqueId] = value;\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.SetConnectionValue,\r\n payload: {\r\n connectionPointId: connectionPoint.uniqueId,\r\n value,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Set a connection value by key\r\n * @internal\r\n * @param key the key of the connection value\r\n * @param value the value of the connection\r\n */\r\n public _setConnectionValueByKey<T>(key: string, value: T) {\r\n this._connectionValues[key] = value;\r\n }\r\n\r\n /**\r\n * Get a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _getConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>): T {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GetConnectionValue,\r\n payload: {\r\n connectionPointId: connectionPoint.uniqueId,\r\n value: this._connectionValues[connectionPoint.uniqueId],\r\n },\r\n });\r\n return this._connectionValues[connectionPoint.uniqueId];\r\n }\r\n\r\n /**\r\n * Get the configuration\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public get configuration() {\r\n return this._configuration;\r\n }\r\n\r\n /**\r\n * Check if there are any pending blocks in this context\r\n * @returns true if there are pending blocks\r\n */\r\n public get hasPendingBlocks() {\r\n return this._pendingBlocks.length > 0;\r\n }\r\n\r\n /**\r\n * Add a block to the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _addPendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n // check if block is already in the array\r\n if (this._pendingBlocks.includes(block)) {\r\n return;\r\n }\r\n this._pendingBlocks.push(block);\r\n // sort pending blocks by priority\r\n this._pendingBlocks.sort((a, b) => a.priority - b.priority);\r\n }\r\n\r\n /**\r\n * Remove a block from the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _removePendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n const index = this._pendingBlocks.indexOf(block);\r\n if (index !== -1) {\r\n this._pendingBlocks.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all pending blocks.\r\n * @internal\r\n */\r\n public _clearPendingBlocks() {\r\n for (const block of this._pendingBlocks) {\r\n block._cancelPendingTasks(this);\r\n }\r\n this._pendingBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Function that notifies the node executed observable\r\n * @param node\r\n */\r\n public _notifyExecuteNode(node: FlowGraphBlock) {\r\n this.onNodeExecutedObservable.notifyObservers(node);\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: node.getClassName(),\r\n uniqueId: node.uniqueId,\r\n action: FlowGraphAction.ExecuteBlock,\r\n });\r\n }\r\n\r\n public _notifyOnTick(framePayload: IFlowGraphOnTickEventPayload) {\r\n // set the values as global variables\r\n this._setGlobalContextVariable(\"timeSinceStart\", framePayload.timeSinceStart);\r\n this._setGlobalContextVariable(\"deltaTime\", framePayload.deltaTime);\r\n // iterate the pending blocks and run each one's onFrame function\r\n for (const block of this._pendingBlocks) {\r\n block._executeOnTick?.(this);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _increaseExecutionId() {\r\n this._executionId++;\r\n }\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n public get executionId() {\r\n return this._executionId;\r\n }\r\n\r\n /**\r\n * Serializes a context\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializationFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializationFunction: (key: string, value: any, serializationObject: any) => void = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject._userVariables = {};\r\n for (const key in this._userVariables) {\r\n valueSerializationFunction(key, this._userVariables[key], serializationObject._userVariables);\r\n }\r\n serializationObject._connectionValues = {};\r\n for (const key in this._connectionValues) {\r\n valueSerializationFunction(key, this._connectionValues[key], serializationObject._connectionValues);\r\n }\r\n // serialize assets context, if not scene\r\n if (this.assetsContext !== this.getScene()) {\r\n serializationObject._assetsContext = {\r\n meshes: this.assetsContext.meshes.map((m) => m.id),\r\n materials: this.assetsContext.materials.map((m) => m.id),\r\n textures: this.assetsContext.textures.map((m) => m.name),\r\n animations: this.assetsContext.animations.map((m) => m.name),\r\n lights: this.assetsContext.lights.map((m) => m.id),\r\n cameras: this.assetsContext.cameras.map((m) => m.id),\r\n sounds: this.assetsContext.sounds?.map((m) => m.name),\r\n skeletons: this.assetsContext.skeletons.map((m) => m.id),\r\n particleSystems: this.assetsContext.particleSystems.map((m) => m.name),\r\n geometries: this.assetsContext.geometries.map((m) => m.id),\r\n multiMaterials: this.assetsContext.multiMaterials.map((m) => m.id),\r\n transformNodes: this.assetsContext.transformNodes.map((m) => m.id),\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * @returns the class name of the object.\r\n */\r\n public getClassName() {\r\n return \"FlowGraphContext\";\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EAAmB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAsDrE;;;;;GAKG;AACH,MAAM,OAAO,gBAAgB;IAgGzB;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED,IAAW,aAAa,CAAC,KAAc;QACnC,IAAI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,aAAa,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClD,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpD,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;gBACrD,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxD,eAAe,EAAE,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;gBACtE,UAAU,EAAE,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC1D,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClE,cAAc,EAAE,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACrE,CAAC;QACN,CAAC;IACL,CAAC;IAED;;OAEG;IACI,YAAY;QACf,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ;AAjlBU;IADN,SAAS,EAAE;kDACmB","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport { RandomGUID } from \"../Misc/guid\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraph } from \"./flowGraph\";\r\nimport { defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { AssetType, FlowGraphAssetType } from \"./flowGraphAssetsContext\";\r\nimport { GetFlowGraphAssetWithType } from \"./flowGraphAssetsContext\";\r\nimport type { IAssetContainer } from \"core/IAssetContainer\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { FlowGraphAction, FlowGraphLogger } from \"./flowGraphLogger\";\r\nimport type { IFlowGraphOnTickEventPayload } from \"./Blocks/Event/flowGraphSceneTickEventBlock\";\r\nimport type { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\r\nimport type { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\r\n\r\n/**\r\n * Represents a pending signal activation that was paused by a breakpoint.\r\n */\r\nexport interface IFlowGraphPendingActivation {\r\n /** The block that was about to execute */\r\n readonly block: FlowGraphExecutionBlock;\r\n /** The context in which execution was paused */\r\n readonly context: FlowGraphContext;\r\n /** The signal connection that triggered the execution */\r\n readonly signal: FlowGraphSignalConnection;\r\n}\r\n/**\r\n * Construction parameters for the context.\r\n */\r\nexport interface IFlowGraphContextConfiguration {\r\n /**\r\n * The scene that the flow graph context belongs to.\r\n */\r\n readonly scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph context.\r\n */\r\n readonly coordinator: FlowGraphCoordinator;\r\n\r\n /**\r\n * The assets context used by the flow graph context.\r\n * If none is provided, a default one will be created.\r\n */\r\n readonly assetsContext?: IAssetContainer;\r\n}\r\n\r\n/**\r\n * Options for parsing a context.\r\n */\r\nexport interface IFlowGraphContextParseOptions {\r\n /**\r\n * A function that parses a value from a serialization object.\r\n * @param key the key of the value\r\n * @param serializationObject the object containing the value\r\n * @param assetsContainer the assets container\r\n * @param scene the current scene\r\n * @returns\r\n */\r\n readonly valueParseFunction?: (key: string, serializationObject: any, assetsContainer: IAssetContainer, scene: Scene) => any;\r\n /**\r\n * The graph that the context is being parsed in.\r\n */\r\n readonly graph: FlowGraph;\r\n}\r\n/**\r\n * The context represents the current state and execution of the flow graph.\r\n * It contains both user-defined variables, which are derived from\r\n * a more general variable definition, and execution variables that\r\n * are set by the blocks.\r\n */\r\nexport class FlowGraphContext {\r\n /**\r\n * A randomly generated GUID for each context.\r\n */\r\n @serialize()\r\n public uniqueId = RandomGUID();\r\n /**\r\n * These are the variables defined by a user.\r\n */\r\n private _userVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the blocks.\r\n */\r\n private _executionVariables: { [key: string]: any } = {};\r\n\r\n /**\r\n * A context-specific global variables, available to all blocks in the context.\r\n */\r\n private _globalContextVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the values for the data connection points\r\n */\r\n private _connectionValues: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the graph.\r\n */\r\n private readonly _configuration: IFlowGraphContextConfiguration;\r\n /**\r\n * These are blocks that have currently pending tasks/listeners that need to be cleaned up.\r\n */\r\n private _pendingBlocks: FlowGraphAsyncExecutionBlock[] = [];\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n private _executionId = 0;\r\n /**\r\n * Observable that is triggered when a node is executed.\r\n */\r\n public onNodeExecutedObservable: Observable<FlowGraphBlock> = new Observable<FlowGraphBlock>();\r\n\r\n /**\r\n * Observable triggered when a breakpoint is hit.\r\n * Observers receive the pending activation (block, context, signal) that was paused.\r\n */\r\n public onBreakpointHitObservable: Observable<IFlowGraphPendingActivation> = new Observable<IFlowGraphPendingActivation>();\r\n\r\n /**\r\n * A predicate called before each execution block runs.\r\n * If it returns true, execution is paused before the block and a\r\n * pending activation is stored, which can be resumed via\r\n * {@link continueExecution} or {@link stepExecution}.\r\n *\r\n * Set to `null` to disable breakpoint checking.\r\n */\r\n public breakpointPredicate: Nullable<(block: FlowGraphExecutionBlock) => boolean> = null;\r\n\r\n /**\r\n * The activation that is currently paused due to a breakpoint hit.\r\n * `null` when execution is not paused on a breakpoint.\r\n */\r\n private _pendingActivation: Nullable<IFlowGraphPendingActivation> = null;\r\n\r\n /**\r\n * When true, the next activation will pause regardless of the breakpoint predicate.\r\n * Set by {@link stepExecution}.\r\n */\r\n private _stepMode: boolean = false;\r\n\r\n /**\r\n * When set, the breakpoint check is skipped for this specific block uniqueId\r\n * on the very next call to {@link _shouldBreak}. Used by continue/step to avoid\r\n * immediately re-hitting the breakpoint on the block being resumed.\r\n */\r\n private _skipBreakpointForBlockId: Nullable<string> = null;\r\n\r\n /**\r\n * The assets context used by the flow graph context.\r\n * Note that it can be shared between flow graph contexts.\r\n */\r\n public assetsContext: IAssetContainer;\r\n\r\n /**\r\n * Whether to treat data as right-handed.\r\n * This is used when serializing data from a right-handed system, while running the context in a left-handed system, for example in glTF parsing.\r\n * Default is false.\r\n */\r\n public treatDataAsRightHanded = false;\r\n\r\n private _enableLogging = false;\r\n\r\n /**\r\n * The logger used by the context to log actions.\r\n */\r\n public logger: Nullable<FlowGraphLogger>;\r\n\r\n /**\r\n * Enable logging on this context\r\n */\r\n public get enableLogging() {\r\n return this._enableLogging;\r\n }\r\n\r\n public set enableLogging(value: boolean) {\r\n if (this._enableLogging === value) {\r\n return;\r\n }\r\n this._enableLogging = value;\r\n if (this._enableLogging) {\r\n this.logger = new FlowGraphLogger();\r\n this.logger.logToConsole = true;\r\n } else {\r\n this.logger = null;\r\n }\r\n }\r\n\r\n constructor(params: IFlowGraphContextConfiguration) {\r\n this._configuration = params;\r\n this.assetsContext = params.assetsContext ?? params.scene;\r\n }\r\n\r\n /**\r\n * Check if a user-defined variable is defined.\r\n * @param name the name of the variable\r\n * @returns true if the variable is defined\r\n */\r\n public hasVariable(name: string) {\r\n return name in this._userVariables;\r\n }\r\n\r\n /**\r\n * Set a user-defined variable.\r\n * @param name the name of the variable\r\n * @param value the value of the variable\r\n */\r\n public setVariable(name: string, value: any) {\r\n this._userVariables[name] = value;\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.ContextVariableSet,\r\n payload: {\r\n name,\r\n value,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Get an assets from the assets context based on its type and index in the array\r\n * @param type The type of the asset\r\n * @param index The index of the asset\r\n * @returns The asset or null if not found\r\n */\r\n public getAsset<T extends FlowGraphAssetType>(type: T, index: number): Nullable<AssetType<T>> {\r\n return GetFlowGraphAssetWithType(this.assetsContext, type, index);\r\n }\r\n\r\n /**\r\n * Get a user-defined variable.\r\n * @param name the name of the variable\r\n * @returns the value of the variable\r\n */\r\n public getVariable(name: string): any {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.ContextVariableGet,\r\n payload: {\r\n name,\r\n value: this._userVariables[name],\r\n },\r\n });\r\n return this._userVariables[name];\r\n }\r\n\r\n /**\r\n * Gets all user variables map\r\n */\r\n public get userVariables() {\r\n return this._userVariables;\r\n }\r\n\r\n /**\r\n * Get the scene that the context belongs to.\r\n * @returns the scene\r\n */\r\n public getScene() {\r\n return this._configuration.scene;\r\n }\r\n\r\n private _getUniqueIdPrefixedName(obj: FlowGraphBlock, name: string): string {\r\n return `${obj.uniqueId}_${name}`;\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param name name of the variable\r\n * @param defaultValue default value to return if the variable is not defined\r\n * @returns the variable value or the default value if the variable is not defined\r\n */\r\n public _getGlobalContextVariable<T>(name: string, defaultValue: T): T {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableGet,\r\n payload: {\r\n name,\r\n defaultValue,\r\n possibleValue: this._globalContextVariables[name],\r\n },\r\n });\r\n if (this._hasGlobalContextVariable(name)) {\r\n return this._globalContextVariables[name];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Set a global context variable\r\n * @internal\r\n * @param name the name of the variable\r\n * @param value the value of the variable\r\n */\r\n public _setGlobalContextVariable<T>(name: string, value: T) {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableSet,\r\n payload: { name, value },\r\n });\r\n this._globalContextVariables[name] = value;\r\n }\r\n\r\n /**\r\n * Delete a global context variable\r\n * @internal\r\n * @param name the name of the variable\r\n */\r\n public _deleteGlobalContextVariable(name: string) {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GlobalVariableDelete,\r\n payload: { name },\r\n });\r\n delete this._globalContextVariables[name];\r\n }\r\n\r\n /**\r\n * Check if a global context variable is defined\r\n * @internal\r\n * @param name the name of the variable\r\n * @returns true if the variable is defined\r\n */\r\n public _hasGlobalContextVariable(name: string) {\r\n return name in this._globalContextVariables;\r\n }\r\n\r\n /**\r\n * Set an internal execution variable\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public _setExecutionVariable(block: FlowGraphBlock, name: string, value: any) {\r\n this._executionVariables[this._getUniqueIdPrefixedName(block, name)] = value;\r\n }\r\n\r\n /**\r\n * Get an internal execution variable\r\n * @internal\r\n * @param name\r\n * @returns\r\n */\r\n public _getExecutionVariable<T>(block: FlowGraphBlock, name: string, defaultValue: T): T {\r\n if (this._hasExecutionVariable(block, name)) {\r\n return this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Delete an internal execution variable\r\n * @internal\r\n * @param block\r\n * @param name\r\n */\r\n public _deleteExecutionVariable(block: FlowGraphBlock, name: string) {\r\n delete this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n }\r\n\r\n /**\r\n * Check if an internal execution variable is defined\r\n * @internal\r\n * @param block\r\n * @param name\r\n * @returns\r\n */\r\n public _hasExecutionVariable(block: FlowGraphBlock, name: string) {\r\n return this._getUniqueIdPrefixedName(block, name) in this._executionVariables;\r\n }\r\n\r\n /**\r\n * Check if a connection value is defined\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _hasConnectionValue(connectionPoint: FlowGraphDataConnection<any>) {\r\n return connectionPoint.uniqueId in this._connectionValues;\r\n }\r\n\r\n /**\r\n * Set a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @param value\r\n */\r\n public _setConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>, value: T) {\r\n this._connectionValues[connectionPoint.uniqueId] = value;\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.SetConnectionValue,\r\n payload: {\r\n connectionPointId: connectionPoint.uniqueId,\r\n value,\r\n },\r\n });\r\n }\r\n\r\n /**\r\n * Set a connection value by key\r\n * @internal\r\n * @param key the key of the connection value\r\n * @param value the value of the connection\r\n */\r\n public _setConnectionValueByKey<T>(key: string, value: T) {\r\n this._connectionValues[key] = value;\r\n }\r\n\r\n /**\r\n * Get a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _getConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>): T {\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: this.getClassName(),\r\n uniqueId: this.uniqueId,\r\n action: FlowGraphAction.GetConnectionValue,\r\n payload: {\r\n connectionPointId: connectionPoint.uniqueId,\r\n value: this._connectionValues[connectionPoint.uniqueId],\r\n },\r\n });\r\n return this._connectionValues[connectionPoint.uniqueId];\r\n }\r\n\r\n /**\r\n * Get the configuration\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public get configuration() {\r\n return this._configuration;\r\n }\r\n\r\n /**\r\n * Check if there are any pending blocks in this context\r\n * @returns true if there are pending blocks\r\n */\r\n public get hasPendingBlocks() {\r\n return this._pendingBlocks.length > 0;\r\n }\r\n\r\n /**\r\n * Add a block to the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _addPendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n // check if block is already in the array\r\n if (this._pendingBlocks.includes(block)) {\r\n return;\r\n }\r\n this._pendingBlocks.push(block);\r\n // sort pending blocks by priority\r\n this._pendingBlocks.sort((a, b) => a.priority - b.priority);\r\n }\r\n\r\n /**\r\n * Remove a block from the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _removePendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n const index = this._pendingBlocks.indexOf(block);\r\n if (index !== -1) {\r\n this._pendingBlocks.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all pending blocks.\r\n * @internal\r\n */\r\n public _clearPendingBlocks() {\r\n for (const block of this._pendingBlocks) {\r\n block._cancelPendingTasks(this);\r\n }\r\n this._pendingBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Function that notifies the node executed observable\r\n * @param node\r\n */\r\n public _notifyExecuteNode(node: FlowGraphBlock) {\r\n this.onNodeExecutedObservable.notifyObservers(node);\r\n this.logger?.addLogItem({\r\n time: Date.now(),\r\n className: node.getClassName(),\r\n uniqueId: node.uniqueId,\r\n action: FlowGraphAction.ExecuteBlock,\r\n });\r\n }\r\n\r\n public _notifyOnTick(framePayload: IFlowGraphOnTickEventPayload) {\r\n // set the values as global variables\r\n this._setGlobalContextVariable(\"timeSinceStart\", framePayload.timeSinceStart);\r\n this._setGlobalContextVariable(\"deltaTime\", framePayload.deltaTime);\r\n // iterate the pending blocks and run each one's onFrame function\r\n for (const block of this._pendingBlocks) {\r\n block._executeOnTick?.(this);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _increaseExecutionId() {\r\n this._executionId++;\r\n }\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n public get executionId() {\r\n return this._executionId;\r\n }\r\n\r\n // ── Breakpoint API ─────────────────────────────────────────────────\r\n\r\n /**\r\n * Check whether the given block should break before executing.\r\n * Called by the signal connection infrastructure.\r\n * @internal\r\n * @param block the block about to execute\r\n * @param signal the signal that is triggering the execution\r\n * @returns true if execution should be paused (breakpoint hit)\r\n */\r\n public _shouldBreak(block: FlowGraphExecutionBlock, signal: FlowGraphSignalConnection): boolean {\r\n // If continue/step just resumed this specific block, let it through\r\n if (this._skipBreakpointForBlockId === block.uniqueId) {\r\n this._skipBreakpointForBlockId = null;\r\n return false;\r\n }\r\n\r\n // If already paused on a breakpoint, silently block further execution\r\n // without overwriting the pending activation or re-notifying observers.\r\n if (this._pendingActivation) {\r\n return true;\r\n }\r\n\r\n if (this._stepMode) {\r\n this._stepMode = false;\r\n this._pendingActivation = { block, context: this, signal };\r\n this.onBreakpointHitObservable.notifyObservers(this._pendingActivation);\r\n return true;\r\n }\r\n if (this.breakpointPredicate && this.breakpointPredicate(block)) {\r\n this._pendingActivation = { block, context: this, signal };\r\n this.onBreakpointHitObservable.notifyObservers(this._pendingActivation);\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Returns the currently paused activation, or null if not paused.\r\n */\r\n public get pendingActivation(): Nullable<IFlowGraphPendingActivation> {\r\n return this._pendingActivation;\r\n }\r\n\r\n /**\r\n * Resume execution from a breakpoint hit.\r\n * The paused block and all downstream blocks will execute normally until\r\n * the next breakpoint (if any) is hit.\r\n */\r\n public continueExecution(): void {\r\n const pending = this._pendingActivation;\r\n if (!pending) {\r\n return;\r\n }\r\n this._pendingActivation = null;\r\n // Tell _shouldBreak to skip the breakpoint for this block on re-entry\r\n this._skipBreakpointForBlockId = pending.block.uniqueId;\r\n pending.signal._activateSignal(this);\r\n // Clear in case no re-entry happened (shouldn't linger)\r\n this._skipBreakpointForBlockId = null;\r\n }\r\n\r\n /**\r\n * Execute exactly the paused block and then pause again before the next\r\n * execution block fires. If no activation is pending, this is a no-op.\r\n */\r\n public stepExecution(): void {\r\n const pending = this._pendingActivation;\r\n if (!pending) {\r\n return;\r\n }\r\n this._pendingActivation = null;\r\n // Enable step mode so the very next input-signal activation will pause\r\n this._stepMode = true;\r\n // Tell _shouldBreak to skip the breakpoint for this block on re-entry\r\n this._skipBreakpointForBlockId = pending.block.uniqueId;\r\n pending.signal._activateSignal(this);\r\n // If nothing further executed (end of chain), clear step mode\r\n this._stepMode = false;\r\n this._skipBreakpointForBlockId = null;\r\n }\r\n\r\n /**\r\n * Discard any pending breakpoint activation without resuming.\r\n * Used when stopping or resetting the graph.\r\n * @internal\r\n */\r\n public _clearPendingActivation(): void {\r\n this._pendingActivation = null;\r\n this._stepMode = false;\r\n this._skipBreakpointForBlockId = null;\r\n }\r\n\r\n /**\r\n * Serializes a context\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializationFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializationFunction: (key: string, value: any, serializationObject: any) => void = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject._userVariables = {};\r\n for (const key in this._userVariables) {\r\n valueSerializationFunction(key, this._userVariables[key], serializationObject._userVariables);\r\n }\r\n serializationObject._connectionValues = {};\r\n for (const key in this._connectionValues) {\r\n valueSerializationFunction(key, this._connectionValues[key], serializationObject._connectionValues);\r\n }\r\n // serialize assets context, if not scene\r\n if (this.assetsContext !== this.getScene()) {\r\n serializationObject._assetsContext = {\r\n meshes: this.assetsContext.meshes.map((m) => m.id),\r\n materials: this.assetsContext.materials.map((m) => m.id),\r\n textures: this.assetsContext.textures.map((m) => m.name),\r\n animations: this.assetsContext.animations.map((m) => m.name),\r\n lights: this.assetsContext.lights.map((m) => m.id),\r\n cameras: this.assetsContext.cameras.map((m) => m.id),\r\n sounds: this.assetsContext.sounds?.map((m) => m.name),\r\n skeletons: this.assetsContext.skeletons.map((m) => m.id),\r\n particleSystems: this.assetsContext.particleSystems.map((m) => m.name),\r\n geometries: this.assetsContext.geometries.map((m) => m.id),\r\n multiMaterials: this.assetsContext.multiMaterials.map((m) => m.id),\r\n transformNodes: this.assetsContext.transformNodes.map((m) => m.id),\r\n };\r\n }\r\n }\r\n\r\n /**\r\n * @returns the class name of the object.\r\n */\r\n public getClassName() {\r\n return \"FlowGraphContext\";\r\n }\r\n}\r\n"]}
|
|
@@ -28,6 +28,13 @@ export declare abstract class FlowGraphExecutionBlock extends FlowGraphBlock {
|
|
|
28
28
|
* Note that priority cannot be change AFTER the block was added as sorting happens when the block is added to the execution queue.
|
|
29
29
|
*/
|
|
30
30
|
readonly priority: number;
|
|
31
|
+
/**
|
|
32
|
+
* The last measured execution time in milliseconds.
|
|
33
|
+
* Updated by the signal connection when the block is executed.
|
|
34
|
+
* A value of -1 means no measurement has been taken yet.
|
|
35
|
+
* @internal
|
|
36
|
+
*/
|
|
37
|
+
_lastExecutionTime: number;
|
|
31
38
|
protected constructor(config?: IFlowGraphBlockConfiguration);
|
|
32
39
|
/**
|
|
33
40
|
* @internal
|
|
@@ -12,6 +12,13 @@ export class FlowGraphExecutionBlock extends FlowGraphBlock {
|
|
|
12
12
|
* Note that priority cannot be change AFTER the block was added as sorting happens when the block is added to the execution queue.
|
|
13
13
|
*/
|
|
14
14
|
this.priority = 0;
|
|
15
|
+
/**
|
|
16
|
+
* The last measured execution time in milliseconds.
|
|
17
|
+
* Updated by the signal connection when the block is executed.
|
|
18
|
+
* A value of -1 means no measurement has been taken yet.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
this._lastExecutionTime = -1;
|
|
15
22
|
this.signalInputs = [];
|
|
16
23
|
this.signalOutputs = [];
|
|
17
24
|
this.in = this._registerSignalInput("in");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphExecutionBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphExecutionBlock.ts"],"names":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YACrF,IAAI,YAAY,EAAE,CAAC;gBACf,YAAY,CAAC,WAAW,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;YACnE,CAAC;iBAAM,CAAC;gBACJ,MAAM,IAAI,KAAK,CAAC,yCAAyC,GAAG,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,YAAY,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC1J,CAAC;QACL,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,OAAO,yBAAyB,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import type { IFlowGraphBlockConfiguration } from \"./flowGraphBlock\";\r\nimport { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\r\n\r\n/**\r\n * A block that executes some action. Always has an input signal (which is not used by event blocks).\r\n * Can have one or more output signals.\r\n */\r\nexport abstract class FlowGraphExecutionBlock extends FlowGraphBlock {\r\n /**\r\n * Input connection: The input signal of the block.\r\n */\r\n public readonly in: FlowGraphSignalConnection;\r\n\r\n /**\r\n * An output connection that can be used to signal an error, if the block defines it.\r\n */\r\n public readonly error: FlowGraphSignalConnection;\r\n /**\r\n * Input connections that activate the block.\r\n */\r\n public signalInputs: FlowGraphSignalConnection[];\r\n /**\r\n * Output connections that can activate downstream blocks.\r\n */\r\n public signalOutputs: FlowGraphSignalConnection[];\r\n\r\n /**\r\n * The priority of the block. Higher priority blocks will be executed first.\r\n * Note that priority cannot be change AFTER the block was added as sorting happens when the block is added to the execution queue.\r\n */\r\n public readonly priority: number = 0;\r\n\r\n protected constructor(config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n this.signalInputs = [];\r\n this.signalOutputs = [];\r\n this.in = this._registerSignalInput(\"in\");\r\n this.error = this._registerSignalOutput(\"error\");\r\n }\r\n\r\n /**\r\n * @internal\r\n * Executes the flow graph execution block.\r\n */\r\n public abstract _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void;\r\n\r\n protected _registerSignalInput(name: string): FlowGraphSignalConnection {\r\n const input = new FlowGraphSignalConnection(name, FlowGraphConnectionType.Input, this);\r\n this.signalInputs.push(input);\r\n return input;\r\n }\r\n\r\n protected _registerSignalOutput(name: string): FlowGraphSignalConnection {\r\n const output = new FlowGraphSignalConnection(name, FlowGraphConnectionType.Output, this);\r\n this.signalOutputs.push(output);\r\n return output;\r\n }\r\n\r\n protected _unregisterSignalInput(name: string): void {\r\n const index = this.signalInputs.findIndex((input) => input.name === name);\r\n if (index !== -1) {\r\n this.signalInputs[index].dispose();\r\n this.signalInputs.splice(index, 1);\r\n }\r\n }\r\n\r\n protected _unregisterSignalOutput(name: string): void {\r\n const index = this.signalOutputs.findIndex((output) => output.name === name);\r\n if (index !== -1) {\r\n this.signalOutputs[index].dispose();\r\n this.signalOutputs.splice(index, 1);\r\n }\r\n }\r\n\r\n protected _reportError(context: FlowGraphContext, error: Error | string) {\r\n this.error.payload = typeof error === \"string\" ? new Error(error) : error;\r\n this.error._activateSignal(context);\r\n }\r\n\r\n /**\r\n * Given a name of a signal input, return that input if it exists\r\n * @param name the name of the input\r\n * @returns if the input exists, the input. Otherwise, undefined.\r\n */\r\n public getSignalInput(name: string): FlowGraphSignalConnection | undefined {\r\n return this.signalInputs.find((input) => input.name === name);\r\n }\r\n\r\n /**\r\n * Given a name of a signal output, return that input if it exists\r\n * @param name the name of the input\r\n * @returns if the input exists, the input. Otherwise, undefined.\r\n */\r\n public getSignalOutput(name: string): FlowGraphSignalConnection | undefined {\r\n return this.signalOutputs.find((output) => output.name === name);\r\n }\r\n\r\n /**\r\n * Serializes this block\r\n * @param serializationObject the object to serialize in\r\n */\r\n public override serialize(serializationObject: any = {}) {\r\n super.serialize(serializationObject);\r\n serializationObject.signalInputs = [];\r\n serializationObject.signalOutputs = [];\r\n for (const input of this.signalInputs) {\r\n const serializedInput: any = {};\r\n input.serialize(serializedInput);\r\n serializationObject.signalInputs.push(serializedInput);\r\n }\r\n for (const output of this.signalOutputs) {\r\n const serializedOutput: any = {};\r\n output.serialize(serializedOutput);\r\n serializationObject.signalOutputs.push(serializedOutput);\r\n }\r\n }\r\n\r\n /**\r\n * Deserializes from an object\r\n * @param serializationObject the object to deserialize from\r\n */\r\n public override deserialize(serializationObject: any) {\r\n for (let i = 0; i < serializationObject.signalInputs.length; i++) {\r\n const signalInput = this.getSignalInput(serializationObject.signalInputs[i].name);\r\n if (signalInput) {\r\n signalInput.deserialize(serializationObject.signalInputs[i]);\r\n } else {\r\n throw new Error(\"Could not find signal input with name \" + serializationObject.signalInputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n for (let i = 0; i < serializationObject.signalOutputs.length; i++) {\r\n const signalOutput = this.getSignalOutput(serializationObject.signalOutputs[i].name);\r\n if (signalOutput) {\r\n signalOutput.deserialize(serializationObject.signalOutputs[i]);\r\n } else {\r\n throw new Error(\"Could not find signal output with name \" + serializationObject.signalOutputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"FlowGraphExecutionBlock\";\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphExecutionBlock.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphExecutionBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE;;;GAGG;AACH,MAAM,OAAgB,uBAAwB,SAAQ,cAAc;IAiChE,YAAsB,MAAqC;QACvD,KAAK,CAAC,MAAM,CAAC,CAAC;QAflB;;;WAGG;QACa,aAAQ,GAAW,CAAC,CAAC;QAErC;;;;;WAKG;QACI,uBAAk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AG,mBAAmB,CAAC,SAAS,CAAC,CAAC;YAC1J,CAAC;QACL,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,OAAO,yBAAyB,CAAC;IACrC,CAAC;CACJ","sourcesContent":["import type { IFlowGraphBlockConfiguration } from \"./flowGraphBlock\";\r\nimport { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport { FlowGraphConnectionType } from \"./flowGraphConnection\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\r\n\r\n/**\r\n * A block that executes some action. Always has an input signal (which is not used by event blocks).\r\n * Can have one or more output signals.\r\n */\r\nexport abstract class FlowGraphExecutionBlock extends FlowGraphBlock {\r\n /**\r\n * Input connection: The input signal of the block.\r\n */\r\n public readonly in: FlowGraphSignalConnection;\r\n\r\n /**\r\n * An output connection that can be used to signal an error, if the block defines it.\r\n */\r\n public readonly error: FlowGraphSignalConnection;\r\n /**\r\n * Input connections that activate the block.\r\n */\r\n public signalInputs: FlowGraphSignalConnection[];\r\n /**\r\n * Output connections that can activate downstream blocks.\r\n */\r\n public signalOutputs: FlowGraphSignalConnection[];\r\n\r\n /**\r\n * The priority of the block. Higher priority blocks will be executed first.\r\n * Note that priority cannot be change AFTER the block was added as sorting happens when the block is added to the execution queue.\r\n */\r\n public readonly priority: number = 0;\r\n\r\n /**\r\n * The last measured execution time in milliseconds.\r\n * Updated by the signal connection when the block is executed.\r\n * A value of -1 means no measurement has been taken yet.\r\n * @internal\r\n */\r\n public _lastExecutionTime: number = -1;\r\n\r\n protected constructor(config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n this.signalInputs = [];\r\n this.signalOutputs = [];\r\n this.in = this._registerSignalInput(\"in\");\r\n this.error = this._registerSignalOutput(\"error\");\r\n }\r\n\r\n /**\r\n * @internal\r\n * Executes the flow graph execution block.\r\n */\r\n public abstract _execute(context: FlowGraphContext, callingSignal: FlowGraphSignalConnection): void;\r\n\r\n protected _registerSignalInput(name: string): FlowGraphSignalConnection {\r\n const input = new FlowGraphSignalConnection(name, FlowGraphConnectionType.Input, this);\r\n this.signalInputs.push(input);\r\n return input;\r\n }\r\n\r\n protected _registerSignalOutput(name: string): FlowGraphSignalConnection {\r\n const output = new FlowGraphSignalConnection(name, FlowGraphConnectionType.Output, this);\r\n this.signalOutputs.push(output);\r\n return output;\r\n }\r\n\r\n protected _unregisterSignalInput(name: string): void {\r\n const index = this.signalInputs.findIndex((input) => input.name === name);\r\n if (index !== -1) {\r\n this.signalInputs[index].dispose();\r\n this.signalInputs.splice(index, 1);\r\n }\r\n }\r\n\r\n protected _unregisterSignalOutput(name: string): void {\r\n const index = this.signalOutputs.findIndex((output) => output.name === name);\r\n if (index !== -1) {\r\n this.signalOutputs[index].dispose();\r\n this.signalOutputs.splice(index, 1);\r\n }\r\n }\r\n\r\n protected _reportError(context: FlowGraphContext, error: Error | string) {\r\n this.error.payload = typeof error === \"string\" ? new Error(error) : error;\r\n this.error._activateSignal(context);\r\n }\r\n\r\n /**\r\n * Given a name of a signal input, return that input if it exists\r\n * @param name the name of the input\r\n * @returns if the input exists, the input. Otherwise, undefined.\r\n */\r\n public getSignalInput(name: string): FlowGraphSignalConnection | undefined {\r\n return this.signalInputs.find((input) => input.name === name);\r\n }\r\n\r\n /**\r\n * Given a name of a signal output, return that input if it exists\r\n * @param name the name of the input\r\n * @returns if the input exists, the input. Otherwise, undefined.\r\n */\r\n public getSignalOutput(name: string): FlowGraphSignalConnection | undefined {\r\n return this.signalOutputs.find((output) => output.name === name);\r\n }\r\n\r\n /**\r\n * Serializes this block\r\n * @param serializationObject the object to serialize in\r\n */\r\n public override serialize(serializationObject: any = {}) {\r\n super.serialize(serializationObject);\r\n serializationObject.signalInputs = [];\r\n serializationObject.signalOutputs = [];\r\n for (const input of this.signalInputs) {\r\n const serializedInput: any = {};\r\n input.serialize(serializedInput);\r\n serializationObject.signalInputs.push(serializedInput);\r\n }\r\n for (const output of this.signalOutputs) {\r\n const serializedOutput: any = {};\r\n output.serialize(serializedOutput);\r\n serializationObject.signalOutputs.push(serializedOutput);\r\n }\r\n }\r\n\r\n /**\r\n * Deserializes from an object\r\n * @param serializationObject the object to deserialize from\r\n */\r\n public override deserialize(serializationObject: any) {\r\n for (let i = 0; i < serializationObject.signalInputs.length; i++) {\r\n const signalInput = this.getSignalInput(serializationObject.signalInputs[i].name);\r\n if (signalInput) {\r\n signalInput.deserialize(serializationObject.signalInputs[i]);\r\n } else {\r\n throw new Error(\"Could not find signal input with name \" + serializationObject.signalInputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n for (let i = 0; i < serializationObject.signalOutputs.length; i++) {\r\n const signalOutput = this.getSignalOutput(serializationObject.signalOutputs[i].name);\r\n if (signalOutput) {\r\n signalOutput.deserialize(serializationObject.signalOutputs[i]);\r\n } else {\r\n throw new Error(\"Could not find signal output with name \" + serializationObject.signalOutputs[i].name + \" in block \" + serializationObject.className);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"FlowGraphExecutionBlock\";\r\n }\r\n}\r\n"]}
|
|
@@ -95,6 +95,7 @@ export function ParseFlowGraph(serializationObject, options, resolvedClasses) {
|
|
|
95
95
|
const serializedBlock = serializationObject.allBlocks[i];
|
|
96
96
|
const block = ParseFlowGraphBlockWithClassType(serializedBlock, { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, assetsContainer: options.coordinator.config.scene, valueParseFunction }, resolvedClasses[i]);
|
|
97
97
|
blocks.push(block);
|
|
98
|
+
graph.addBlock(block);
|
|
98
99
|
if (block instanceof FlowGraphEventBlock) {
|
|
99
100
|
graph.addEventBlock(block);
|
|
100
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphParser.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gC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,IAAI,EAAE,mBAAmB,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC5G,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,mBAAwB,EAAE,UAA0B,EAAE,SAAyC;IACpI,MAAM,QAAQ,GAAG,aAAa,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC;IACtD,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACrK,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,mBAAwB;IAC3C,OAAO,IAAI,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import type { IAssetContainer } from \"core/IAssetContainer\";\nimport { blockFactory } from \"./Blocks/flowGraphBlockFactory\";\nimport type { FlowGraphBlockNames } from \"./Blocks/flowGraphBlockNames\";\nimport type { FlowGraph, IFlowGraphParseOptions } from \"./flowGraph\";\nimport type { FlowGraphBlock, IFlowGraphBlockParseOptions } from \"./flowGraphBlock\";\nimport type { FlowGraphContext, IFlowGraphContextParseOptions } from \"./flowGraphContext\";\nimport type { IFlowGraphCoordinatorParseOptions } from \"./flowGraphCoordinator\";\nimport { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\nimport { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\nimport type { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\nimport { defaultValueParseFunction, needsPathConverter } from \"./serialization\";\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphContext } from \"./typeDefinitions\";\nimport type { Node } from \"core/node\";\nimport { getRichTypeByFlowGraphType, RichType } from \"./flowGraphRichTypes\";\nimport type { FlowGraphConnection } from \"./flowGraphConnection\";\n\n/**\n * Given a list of blocks, find an output data connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetDataOutConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphDataConnection<any> {\n for (const block of blocks) {\n for (const dataOut of block.dataOutputs) {\n if (dataOut.uniqueId === uniqueId) {\n return dataOut;\n }\n }\n }\n throw new Error(\"Could not find data out connection with unique id \" + uniqueId);\n}\n\n/**\n * Given a list of blocks, find an input signal connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetSignalInConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphSignalConnection {\n for (const block of blocks) {\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalIn of block.signalInputs) {\n if (signalIn.uniqueId === uniqueId) {\n return signalIn;\n }\n }\n }\n }\n throw new Error(\"Could not find signal in connection with unique id \" + uniqueId);\n}\n\n/**\n * Parses a serialized coordinator.\n * @param serializedObject the object to parse\n * @param options the options to use when parsing\n * @returns the parsed coordinator\n */\nexport async function ParseCoordinatorAsync(serializedObject: any, options: IFlowGraphCoordinatorParseOptions) {\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n const coordinator = new FlowGraphCoordinator({ scene: options.scene });\n\n if (serializedObject.dispatchEventsSynchronously) {\n coordinator.dispatchEventsSynchronously = serializedObject.dispatchEventsSynchronously;\n }\n\n await options.scene.whenReadyAsync();\n // if custom default values are defined, set them in the global context\n if (serializedObject._defaultValues) {\n for (const key in serializedObject._defaultValues) {\n // key is the FlowGraphType, value is the default value\n const value = serializedObject._defaultValues[key];\n getRichTypeByFlowGraphType(key).defaultValue = value;\n }\n }\n // async-parse the flow graphs. This can be done in parallel\n await Promise.all(\n serializedObject._flowGraphs?.map(\n async (serializedGraph: any) => await ParseFlowGraphAsync(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter })\n )\n );\n return coordinator;\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @returns the parsed graph\n */\nexport async function ParseFlowGraphAsync(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions): Promise<FlowGraph> {\n // get all classes types needed for the blocks using the block factory\n const resolvedClasses = await Promise.all(\n serializationObject.allBlocks.map(async (serializedBlock) => {\n const classFactory = blockFactory(serializedBlock.className as FlowGraphBlockNames);\n return await classFactory();\n })\n );\n // async will be used when we start using the block async factory\n return ParseFlowGraph(serializationObject, options, resolvedClasses);\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @param resolvedClasses the resolved classes for the blocks\n * @returns the parsed graph\n */\nexport function ParseFlowGraph(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions, resolvedClasses: (typeof FlowGraphBlock)[]) {\n const graph = options.coordinator.createGraph();\n const blocks: FlowGraphBlock[] = [];\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n // Parse all blocks\n // for (const serializedBlock of serializationObject.allBlocks) {\n for (let i = 0; i < serializationObject.allBlocks.length; i++) {\n const serializedBlock = serializationObject.allBlocks[i];\n const block = ParseFlowGraphBlockWithClassType(\n serializedBlock,\n { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, assetsContainer: options.coordinator.config.scene, valueParseFunction },\n resolvedClasses[i]\n );\n blocks.push(block);\n if (block instanceof FlowGraphEventBlock) {\n graph.addEventBlock(block);\n }\n }\n // After parsing all blocks, connect them\n for (const block of blocks) {\n for (const dataIn of block.dataInputs) {\n for (const serializedConnection of dataIn.connectedPointIds) {\n const connection = GetDataOutConnectionByUniqueId(blocks, serializedConnection);\n dataIn.connectTo(connection);\n }\n }\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalOut of block.signalOutputs) {\n for (const serializedConnection of signalOut.connectedPointIds) {\n const connection = GetSignalInConnectionByUniqueId(blocks, serializedConnection);\n signalOut.connectTo(connection);\n }\n }\n }\n }\n for (const serializedContext of serializationObject.executionContexts) {\n ParseFlowGraphContext(serializedContext, { graph, valueParseFunction }, serializationObject.rightHanded);\n }\n return graph;\n}\n\n/**\n * Parses a context\n * @param serializationObject the object containing the context serialization values\n * @param options the options for parsing the context\n * @param rightHanded whether the serialized data is right handed\n * @returns\n */\nexport function ParseFlowGraphContext(serializationObject: ISerializedFlowGraphContext, options: IFlowGraphContextParseOptions, rightHanded?: boolean): FlowGraphContext {\n const result = options.graph.createContext();\n if (serializationObject.enableLogging) {\n result.enableLogging = true;\n }\n result.treatDataAsRightHanded = rightHanded || false;\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n result.uniqueId = serializationObject.uniqueId;\n const scene = result.getScene();\n // check if assets context is available\n if (serializationObject._assetsContext) {\n const ac = serializationObject._assetsContext;\n const assetsContext: IAssetContainer = {\n meshes: ac.meshes?.map((m: string) => scene.getMeshById(m)),\n lights: ac.lights?.map((l: string) => scene.getLightByName(l)),\n cameras: ac.cameras?.map((c: string) => scene.getCameraByName(c)),\n materials: ac.materials?.map((m: string) => scene.getMaterialById(m)),\n textures: ac.textures?.map((t: string) => scene.getTextureByName(t)),\n animations: ac.animations?.map((a: string) => scene.animations.find((anim) => anim.name === a)),\n skeletons: ac.skeletons?.map((s: string) => scene.getSkeletonByName(s)),\n particleSystems: ac.particleSystems?.map((ps: string) => scene.getParticleSystemById(ps)),\n animationGroups: ac.animationGroups?.map((ag: string) => scene.getAnimationGroupByName(ag)),\n transformNodes: ac.transformNodes?.map((tn: string) => scene.getTransformNodeById(tn)),\n rootNodes: [],\n multiMaterials: [],\n morphTargetManagers: [],\n geometries: [],\n actionManagers: [],\n environmentTexture: null,\n postProcesses: [],\n sounds: null,\n effectLayers: [],\n layers: [],\n reflectionProbes: [],\n lensFlareSystems: [],\n proceduralTextures: [],\n getNodes: function (): Array<Node> {\n throw new Error(\"Function not implemented.\");\n },\n };\n result.assetsContext = assetsContext;\n }\n for (const key in serializationObject._userVariables) {\n const value = valueParseFunction(key, serializationObject._userVariables, result.assetsContext, scene);\n result.userVariables[key] = value;\n }\n for (const key in serializationObject._connectionValues) {\n const value = valueParseFunction(key, serializationObject._connectionValues, result.assetsContext, scene);\n result._setConnectionValueByKey(key, value);\n }\n\n return result;\n}\n\n/**\n * Parses a block from a serialization object\n * This function is async due to the factory method that is used to create the block's class. If you load the class externally use ParseBlockWithClassType\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @returns the parsed block\n */\nexport async function ParseBlockAsync(serializationObject: ISerializedFlowGraphBlock, parseOptions: IFlowGraphBlockParseOptions): Promise<FlowGraphBlock> {\n const classFactory = blockFactory(serializationObject.className as FlowGraphBlockNames);\n const classType = await classFactory();\n return ParseFlowGraphBlockWithClassType(serializationObject, parseOptions, classType);\n}\n\n/**\n * Parses a block from a serialization object\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @param classType the class type of the block. This is used when the class is not loaded asynchronously\n * @returns the parsed block\n */\nexport function ParseFlowGraphBlockWithClassType(\n serializationObject: ISerializedFlowGraphBlock,\n parseOptions: IFlowGraphBlockParseOptions,\n classType: typeof FlowGraphBlock\n): FlowGraphBlock {\n const parsedConfig: any = {};\n const valueParseFunction = parseOptions.valueParseFunction ?? defaultValueParseFunction;\n if (serializationObject.config) {\n for (const key in serializationObject.config) {\n parsedConfig[key] = valueParseFunction(key, serializationObject.config, parseOptions.assetsContainer || parseOptions.scene, parseOptions.scene);\n }\n }\n if (needsPathConverter(serializationObject.className)) {\n if (!parseOptions.pathConverter) {\n throw new Error(\"Path converter is required for this block\");\n }\n parsedConfig.pathConverter = parseOptions.pathConverter;\n }\n const obj = new classType(parsedConfig);\n obj.uniqueId = serializationObject.uniqueId;\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\n const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);\n if (dataInput) {\n dataInput.deserialize(serializationObject.dataInputs[i]);\n } else {\n throw new Error(\"Could not find data input with name \" + serializationObject.dataInputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\n const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);\n if (dataOutput) {\n dataOutput.deserialize(serializationObject.dataOutputs[i]);\n } else {\n throw new Error(\"Could not find data output with name \" + serializationObject.dataOutputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n obj.metadata = serializationObject.metadata;\n obj.deserialize && obj.deserialize(serializationObject);\n return obj;\n}\n\n/**\n * Parses a connection from an object\n * @param serializationObject the object to parse from.\n * @param ownerBlock the block that owns the connection.\n * @param classType the class type of the connection.\n * @returns the parsed connection.\n */\nexport function ParseGraphConnectionWithClassType<BlockT extends FlowGraphBlock>(serializationObject: any = {}, ownerBlock: BlockT, classType: typeof FlowGraphConnection) {\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a data connection from a serialized object.\n * @param serializationObject the object to parse from\n * @param ownerBlock the block that owns the connection\n * @param classType the class type of the data connection\n * @returns the parsed connection\n */\nexport function ParseGraphDataConnection(serializationObject: any, ownerBlock: FlowGraphBlock, classType: typeof FlowGraphDataConnection): FlowGraphDataConnection<any> {\n const richType = ParseRichType(serializationObject.richType);\n const defaultValue = serializationObject.defaultValue;\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock, richType, defaultValue, !!serializationObject._optional);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a rich type from a serialization object.\n * @param serializationObject a serialization object\n * @returns the parsed rich type\n */\nfunction ParseRichType(serializationObject: any): RichType<any> {\n return new RichType(serializationObject.typeName, serializationObject.defaultValue);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphParser.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAM9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,OAAO,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAGhF,OAAO,EAAE,0BAA0B,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG5E;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAAC,MAAwB,EAAE,QAAgB;IACrF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,WAAW,EAAE,CAAC;YACtC,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;gBAChC,OAAO,OAAO,CAAC;YACnB,CAAC;QACL,CAAC;IACL,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oDAAoD,GAAG,QAAQ,CAAC,CAAC;AACrF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAAC,MAAwB,EAAE,QAAgB;IACtF,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACzB,IAAI,KAAK,YAAY,uBAAuB,EAAE,CAAC;YAC3C,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC;gBACxC,IAA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BAAmB,CAAC,SAAS,CAAC,CAAC;QACtJ,CAAC;IACL,CAAC;IACD,GAAG,CAAC,QAAQ,GAAG,mBAAmB,CAAC,QAAQ,CAAC;IAC5C,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IACxD,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iCAAiC,CAAgC,sBAA2B,EAAE,EAAE,UAAkB,EAAE,SAAqC;IACrK,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC,eAAe,EAAE,UAAU,CAAC,CAAC;IAC5G,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,mBAAwB,EAAE,UAA0B,EAAE,SAAyC;IACpI,MAAM,QAAQ,GAAG,aAAa,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAC;IACtD,MAAM,UAAU,GAAG,IAAI,SAAS,CAAC,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,CAAC,eAAe,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;IACrK,UAAU,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;IAC5C,OAAO,UAAU,CAAC;AACtB,CAAC;AAED;;;;GAIG;AACH,SAAS,aAAa,CAAC,mBAAwB;IAC3C,OAAO,IAAI,QAAQ,CAAC,mBAAmB,CAAC,QAAQ,EAAE,mBAAmB,CAAC,YAAY,CAAC,CAAC;AACxF,CAAC","sourcesContent":["import type { IAssetContainer } from \"core/IAssetContainer\";\nimport { blockFactory } from \"./Blocks/flowGraphBlockFactory\";\nimport type { FlowGraphBlockNames } from \"./Blocks/flowGraphBlockNames\";\nimport type { FlowGraph, IFlowGraphParseOptions } from \"./flowGraph\";\nimport type { FlowGraphBlock, IFlowGraphBlockParseOptions } from \"./flowGraphBlock\";\nimport type { FlowGraphContext, IFlowGraphContextParseOptions } from \"./flowGraphContext\";\nimport type { IFlowGraphCoordinatorParseOptions } from \"./flowGraphCoordinator\";\nimport { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\nimport { FlowGraphEventBlock } from \"./flowGraphEventBlock\";\nimport { FlowGraphExecutionBlock } from \"./flowGraphExecutionBlock\";\nimport type { FlowGraphSignalConnection } from \"./flowGraphSignalConnection\";\nimport { defaultValueParseFunction, needsPathConverter } from \"./serialization\";\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphContext } from \"./typeDefinitions\";\nimport type { Node } from \"core/node\";\nimport { getRichTypeByFlowGraphType, RichType } from \"./flowGraphRichTypes\";\nimport type { FlowGraphConnection } from \"./flowGraphConnection\";\n\n/**\n * Given a list of blocks, find an output data connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetDataOutConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphDataConnection<any> {\n for (const block of blocks) {\n for (const dataOut of block.dataOutputs) {\n if (dataOut.uniqueId === uniqueId) {\n return dataOut;\n }\n }\n }\n throw new Error(\"Could not find data out connection with unique id \" + uniqueId);\n}\n\n/**\n * Given a list of blocks, find an input signal connection that has a specific unique id\n * @param blocks a list of flow graph blocks\n * @param uniqueId the unique id of a connection\n * @returns the connection that has this unique id. throws an error if none was found\n */\nexport function GetSignalInConnectionByUniqueId(blocks: FlowGraphBlock[], uniqueId: string): FlowGraphSignalConnection {\n for (const block of blocks) {\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalIn of block.signalInputs) {\n if (signalIn.uniqueId === uniqueId) {\n return signalIn;\n }\n }\n }\n }\n throw new Error(\"Could not find signal in connection with unique id \" + uniqueId);\n}\n\n/**\n * Parses a serialized coordinator.\n * @param serializedObject the object to parse\n * @param options the options to use when parsing\n * @returns the parsed coordinator\n */\nexport async function ParseCoordinatorAsync(serializedObject: any, options: IFlowGraphCoordinatorParseOptions) {\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n const coordinator = new FlowGraphCoordinator({ scene: options.scene });\n\n if (serializedObject.dispatchEventsSynchronously) {\n coordinator.dispatchEventsSynchronously = serializedObject.dispatchEventsSynchronously;\n }\n\n await options.scene.whenReadyAsync();\n // if custom default values are defined, set them in the global context\n if (serializedObject._defaultValues) {\n for (const key in serializedObject._defaultValues) {\n // key is the FlowGraphType, value is the default value\n const value = serializedObject._defaultValues[key];\n getRichTypeByFlowGraphType(key).defaultValue = value;\n }\n }\n // async-parse the flow graphs. This can be done in parallel\n await Promise.all(\n serializedObject._flowGraphs?.map(\n async (serializedGraph: any) => await ParseFlowGraphAsync(serializedGraph, { coordinator, valueParseFunction, pathConverter: options.pathConverter })\n )\n );\n return coordinator;\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @returns the parsed graph\n */\nexport async function ParseFlowGraphAsync(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions): Promise<FlowGraph> {\n // get all classes types needed for the blocks using the block factory\n const resolvedClasses = await Promise.all(\n serializationObject.allBlocks.map(async (serializedBlock) => {\n const classFactory = blockFactory(serializedBlock.className as FlowGraphBlockNames);\n return await classFactory();\n })\n );\n // async will be used when we start using the block async factory\n return ParseFlowGraph(serializationObject, options, resolvedClasses);\n}\n\n/**\n * Parses a graph from a given serialization object\n * @param serializationObject the object where the values are written\n * @param options options for parsing the graph\n * @param resolvedClasses the resolved classes for the blocks\n * @returns the parsed graph\n */\nexport function ParseFlowGraph(serializationObject: ISerializedFlowGraph, options: IFlowGraphParseOptions, resolvedClasses: (typeof FlowGraphBlock)[]) {\n const graph = options.coordinator.createGraph();\n const blocks: FlowGraphBlock[] = [];\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n // Parse all blocks\n // for (const serializedBlock of serializationObject.allBlocks) {\n for (let i = 0; i < serializationObject.allBlocks.length; i++) {\n const serializedBlock = serializationObject.allBlocks[i];\n const block = ParseFlowGraphBlockWithClassType(\n serializedBlock,\n { scene: options.coordinator.config.scene, pathConverter: options.pathConverter, assetsContainer: options.coordinator.config.scene, valueParseFunction },\n resolvedClasses[i]\n );\n blocks.push(block);\n graph.addBlock(block);\n if (block instanceof FlowGraphEventBlock) {\n graph.addEventBlock(block);\n }\n }\n // After parsing all blocks, connect them\n for (const block of blocks) {\n for (const dataIn of block.dataInputs) {\n for (const serializedConnection of dataIn.connectedPointIds) {\n const connection = GetDataOutConnectionByUniqueId(blocks, serializedConnection);\n dataIn.connectTo(connection);\n }\n }\n if (block instanceof FlowGraphExecutionBlock) {\n for (const signalOut of block.signalOutputs) {\n for (const serializedConnection of signalOut.connectedPointIds) {\n const connection = GetSignalInConnectionByUniqueId(blocks, serializedConnection);\n signalOut.connectTo(connection);\n }\n }\n }\n }\n for (const serializedContext of serializationObject.executionContexts) {\n ParseFlowGraphContext(serializedContext, { graph, valueParseFunction }, serializationObject.rightHanded);\n }\n return graph;\n}\n\n/**\n * Parses a context\n * @param serializationObject the object containing the context serialization values\n * @param options the options for parsing the context\n * @param rightHanded whether the serialized data is right handed\n * @returns\n */\nexport function ParseFlowGraphContext(serializationObject: ISerializedFlowGraphContext, options: IFlowGraphContextParseOptions, rightHanded?: boolean): FlowGraphContext {\n const result = options.graph.createContext();\n if (serializationObject.enableLogging) {\n result.enableLogging = true;\n }\n result.treatDataAsRightHanded = rightHanded || false;\n const valueParseFunction = options.valueParseFunction ?? defaultValueParseFunction;\n result.uniqueId = serializationObject.uniqueId;\n const scene = result.getScene();\n // check if assets context is available\n if (serializationObject._assetsContext) {\n const ac = serializationObject._assetsContext;\n const assetsContext: IAssetContainer = {\n meshes: ac.meshes?.map((m: string) => scene.getMeshById(m)),\n lights: ac.lights?.map((l: string) => scene.getLightByName(l)),\n cameras: ac.cameras?.map((c: string) => scene.getCameraByName(c)),\n materials: ac.materials?.map((m: string) => scene.getMaterialById(m)),\n textures: ac.textures?.map((t: string) => scene.getTextureByName(t)),\n animations: ac.animations?.map((a: string) => scene.animations.find((anim) => anim.name === a)),\n skeletons: ac.skeletons?.map((s: string) => scene.getSkeletonByName(s)),\n particleSystems: ac.particleSystems?.map((ps: string) => scene.getParticleSystemById(ps)),\n animationGroups: ac.animationGroups?.map((ag: string) => scene.getAnimationGroupByName(ag)),\n transformNodes: ac.transformNodes?.map((tn: string) => scene.getTransformNodeById(tn)),\n rootNodes: [],\n multiMaterials: [],\n morphTargetManagers: [],\n geometries: [],\n actionManagers: [],\n environmentTexture: null,\n postProcesses: [],\n sounds: null,\n effectLayers: [],\n layers: [],\n reflectionProbes: [],\n lensFlareSystems: [],\n proceduralTextures: [],\n getNodes: function (): Array<Node> {\n throw new Error(\"Function not implemented.\");\n },\n };\n result.assetsContext = assetsContext;\n }\n for (const key in serializationObject._userVariables) {\n const value = valueParseFunction(key, serializationObject._userVariables, result.assetsContext, scene);\n result.userVariables[key] = value;\n }\n for (const key in serializationObject._connectionValues) {\n const value = valueParseFunction(key, serializationObject._connectionValues, result.assetsContext, scene);\n result._setConnectionValueByKey(key, value);\n }\n\n return result;\n}\n\n/**\n * Parses a block from a serialization object\n * This function is async due to the factory method that is used to create the block's class. If you load the class externally use ParseBlockWithClassType\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @returns the parsed block\n */\nexport async function ParseBlockAsync(serializationObject: ISerializedFlowGraphBlock, parseOptions: IFlowGraphBlockParseOptions): Promise<FlowGraphBlock> {\n const classFactory = blockFactory(serializationObject.className as FlowGraphBlockNames);\n const classType = await classFactory();\n return ParseFlowGraphBlockWithClassType(serializationObject, parseOptions, classType);\n}\n\n/**\n * Parses a block from a serialization object\n * @param serializationObject the object to parse from\n * @param parseOptions options for parsing the block\n * @param classType the class type of the block. This is used when the class is not loaded asynchronously\n * @returns the parsed block\n */\nexport function ParseFlowGraphBlockWithClassType(\n serializationObject: ISerializedFlowGraphBlock,\n parseOptions: IFlowGraphBlockParseOptions,\n classType: typeof FlowGraphBlock\n): FlowGraphBlock {\n const parsedConfig: any = {};\n const valueParseFunction = parseOptions.valueParseFunction ?? defaultValueParseFunction;\n if (serializationObject.config) {\n for (const key in serializationObject.config) {\n parsedConfig[key] = valueParseFunction(key, serializationObject.config, parseOptions.assetsContainer || parseOptions.scene, parseOptions.scene);\n }\n }\n if (needsPathConverter(serializationObject.className)) {\n if (!parseOptions.pathConverter) {\n throw new Error(\"Path converter is required for this block\");\n }\n parsedConfig.pathConverter = parseOptions.pathConverter;\n }\n const obj = new classType(parsedConfig);\n obj.uniqueId = serializationObject.uniqueId;\n for (let i = 0; i < serializationObject.dataInputs.length; i++) {\n const dataInput = obj.getDataInput(serializationObject.dataInputs[i].name);\n if (dataInput) {\n dataInput.deserialize(serializationObject.dataInputs[i]);\n } else {\n throw new Error(\"Could not find data input with name \" + serializationObject.dataInputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n for (let i = 0; i < serializationObject.dataOutputs.length; i++) {\n const dataOutput = obj.getDataOutput(serializationObject.dataOutputs[i].name);\n if (dataOutput) {\n dataOutput.deserialize(serializationObject.dataOutputs[i]);\n } else {\n throw new Error(\"Could not find data output with name \" + serializationObject.dataOutputs[i].name + \" in block \" + serializationObject.className);\n }\n }\n obj.metadata = serializationObject.metadata;\n obj.deserialize && obj.deserialize(serializationObject);\n return obj;\n}\n\n/**\n * Parses a connection from an object\n * @param serializationObject the object to parse from.\n * @param ownerBlock the block that owns the connection.\n * @param classType the class type of the connection.\n * @returns the parsed connection.\n */\nexport function ParseGraphConnectionWithClassType<BlockT extends FlowGraphBlock>(serializationObject: any = {}, ownerBlock: BlockT, classType: typeof FlowGraphConnection) {\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a data connection from a serialized object.\n * @param serializationObject the object to parse from\n * @param ownerBlock the block that owns the connection\n * @param classType the class type of the data connection\n * @returns the parsed connection\n */\nexport function ParseGraphDataConnection(serializationObject: any, ownerBlock: FlowGraphBlock, classType: typeof FlowGraphDataConnection): FlowGraphDataConnection<any> {\n const richType = ParseRichType(serializationObject.richType);\n const defaultValue = serializationObject.defaultValue;\n const connection = new classType(serializationObject.name, serializationObject._connectionType, ownerBlock, richType, defaultValue, !!serializationObject._optional);\n connection.deserialize(serializationObject);\n return connection;\n}\n\n/**\n * Parses a rich type from a serialization object.\n * @param serializationObject a serialization object\n * @returns the parsed rich type\n */\nfunction ParseRichType(serializationObject: any): RichType<any> {\n return new RichType(serializationObject.typeName, serializationObject.defaultValue);\n}\n"]}
|
|
@@ -37,6 +37,9 @@ export declare class FlowGraphSceneEventCoordinator {
|
|
|
37
37
|
private _sceneOnBeforeRenderObserver;
|
|
38
38
|
private _meshPickedObserver;
|
|
39
39
|
private _meshUnderPointerObserver;
|
|
40
|
+
private _pointerDownObserver;
|
|
41
|
+
private _pointerUpObserver;
|
|
42
|
+
private _pointerMoveObserver;
|
|
40
43
|
private _pointerUnderMeshState;
|
|
41
44
|
private _startingTime;
|
|
42
45
|
constructor(scene: Scene);
|
|
@@ -21,7 +21,7 @@ export class FlowGraphSceneEventCoordinator {
|
|
|
21
21
|
this._initialize();
|
|
22
22
|
}
|
|
23
23
|
_initialize() {
|
|
24
|
-
this._sceneReadyObserver = this._scene.onReadyObservable.
|
|
24
|
+
this._sceneReadyObserver = this._scene.onReadyObservable.addOnce(() => {
|
|
25
25
|
if (!this.sceneReadyTriggered) {
|
|
26
26
|
this.onEventTriggeredObservable.notifyObservers({ type: "SceneReady" /* FlowGraphEventType.SceneReady */ });
|
|
27
27
|
this.sceneReadyTriggered = true;
|
|
@@ -44,6 +44,15 @@ export class FlowGraphSceneEventCoordinator {
|
|
|
44
44
|
this._meshPickedObserver = this._scene.onPointerObservable.add((pointerInfo) => {
|
|
45
45
|
this.onEventTriggeredObservable.notifyObservers({ type: "MeshPick" /* FlowGraphEventType.MeshPick */, payload: pointerInfo });
|
|
46
46
|
}, PointerEventTypes.POINTERPICK); // should it be pointerdown?
|
|
47
|
+
this._pointerDownObserver = this._scene.onPointerObservable.add((pointerInfo) => {
|
|
48
|
+
this.onEventTriggeredObservable.notifyObservers({ type: "PointerDown" /* FlowGraphEventType.PointerDown */, payload: pointerInfo });
|
|
49
|
+
}, PointerEventTypes.POINTERDOWN);
|
|
50
|
+
this._pointerUpObserver = this._scene.onPointerObservable.add((pointerInfo) => {
|
|
51
|
+
this.onEventTriggeredObservable.notifyObservers({ type: "PointerUp" /* FlowGraphEventType.PointerUp */, payload: pointerInfo });
|
|
52
|
+
}, PointerEventTypes.POINTERUP);
|
|
53
|
+
this._pointerMoveObserver = this._scene.onPointerObservable.add((pointerInfo) => {
|
|
54
|
+
this.onEventTriggeredObservable.notifyObservers({ type: "PointerMove" /* FlowGraphEventType.PointerMove */, payload: pointerInfo });
|
|
55
|
+
}, PointerEventTypes.POINTERMOVE);
|
|
47
56
|
this._meshUnderPointerObserver = this._scene.onMeshUnderPointerUpdatedObservable.add((data) => {
|
|
48
57
|
// check if the data has changed. Check the state of the last change and see if it is a mesh or null.
|
|
49
58
|
// if it is a mesh and the previous state was null, trigger over event. If it is null and the previous state was a mesh, trigger out event.
|
|
@@ -71,6 +80,9 @@ export class FlowGraphSceneEventCoordinator {
|
|
|
71
80
|
this._sceneOnBeforeRenderObserver?.remove();
|
|
72
81
|
this._meshPickedObserver?.remove();
|
|
73
82
|
this._meshUnderPointerObserver?.remove();
|
|
83
|
+
this._pointerDownObserver?.remove();
|
|
84
|
+
this._pointerUpObserver?.remove();
|
|
85
|
+
this._pointerMoveObserver?.remove();
|
|
74
86
|
this.onEventTriggeredObservable.clear();
|
|
75
87
|
}
|
|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EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;YAC1I,CAAC;iBAAM,IAAI,aAAa,IAAI,IAAI,IAAI,aAAa,KAAK,IAAI,EAAE,CAAC;gBACzD,IAAI,CAAC,0BAA0B,CAAC,eAAe,CAAC,EAAE,IAAI,kDAA+B,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;gBAClJ,IAAI,CAAC,0BAA0B,CAAC,eAAe,CAAC,EAAE,IAAI,oDAAgC,EAAE,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,CAAC;YAChJ,CAAC;YACD,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;QAClD,CAAC,EAAE,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC;IAEM,OAAO;QACV,IAAI,CAAC,qBAAqB,EAAE,MAAM,EAAE,CAAC;QACrC,IAAI,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC;QACnC,IAAI,CAAC,4BAA4B,EAAE,MAAM,EAAE,CAAC;QAC5C,IAAI,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC;QACnC,IAAI,CAAC,yBAAyB,EAAE,MAAM,EAAE,CAAC;QACzC,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;CACJ","sourcesContent":["import type { PointerInfo } from \"core/Events/pointerEvents\";\nimport { PointerEventTypes } from \"core/Events/pointerEvents\";\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\nimport type { Observer } from \"core/Misc/observable\";\nimport { Observable } from \"core/Misc/observable\";\nimport type { Scene } from \"core/scene\";\nimport type { Nullable } from \"core/types\";\nimport { FlowGraphEventType } from \"./flowGraphEventType\";\n\n/**\n * the interface of the object the scene event coordinator will trigger.\n */\nexport interface IFlowGraphEventTrigger {\n /**\n * The type of the event\n */\n type: FlowGraphEventType;\n /**\n * The data of the event\n */\n payload?: any;\n}\n\n/**\n * This class is responsible for coordinating the events that are triggered in the scene.\n * It registers all observers needed to track certain events and triggers the blocks that are listening to them.\n * Abstracting the events from the class will allow us to easily change the events that are being listened to, and trigger them in any order.\n */\nexport class FlowGraphSceneEventCoordinator {\n /**\n * @internal\n */\n public readonly _scene: Scene;\n\n /**\n * register to this observable to get flow graph event notifications.\n */\n public onEventTriggeredObservable: Observable<IFlowGraphEventTrigger> = new Observable();\n\n /**\n * Was scene-ready already triggered?\n */\n public sceneReadyTriggered: boolean = false;\n\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\n private _sceneReadyObserver: Nullable<Observer<Scene>>;\n private _sceneOnBeforeRenderObserver: Nullable<Observer<Scene>>;\n private _meshPickedObserver: Nullable<Observer<PointerInfo>>;\n private _meshUnderPointerObserver: Nullable<Observer<{ mesh: Nullable<AbstractMesh>; pointerId: number }>>;\n private _pointerUnderMeshState: { [pointerId: number]: Nullable<AbstractMesh> } = {};\n\n private _startingTime: number = 0;\n\n constructor(scene: Scene) {\n this._scene = scene;\n this._initialize();\n }\n\n private _initialize() {\n this._sceneReadyObserver = this._scene.onReadyObservable.add(() => {\n if (!this.sceneReadyTriggered) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneReady });\n this.sceneReadyTriggered = true;\n }\n });\n\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneDispose });\n });\n this._sceneOnBeforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\n const deltaTime = this._scene.getEngine().getDeltaTime() / 1000; // set in seconds\n this.onEventTriggeredObservable.notifyObservers({\n type: FlowGraphEventType.SceneBeforeRender,\n payload: {\n timeSinceStart: this._startingTime,\n deltaTime,\n },\n });\n this._startingTime += deltaTime;\n });\n\n this._meshPickedObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.MeshPick, payload: pointerInfo });\n }, PointerEventTypes.POINTERPICK); // should it be pointerdown?\n\n this._meshUnderPointerObserver = this._scene.onMeshUnderPointerUpdatedObservable.add((data) => {\n // check if the data has changed. Check the state of the last change and see if it is a mesh or null.\n // if it is a mesh and the previous state was null, trigger over event. If it is null and the previous state was a mesh, trigger out event.\n // if it is a mesh and the previous state was a mesh, trigger out from the old mesh and over the new mesh\n // if it is null and the previous state was null, do nothing.\n const pointerId = data.pointerId;\n const mesh = data.mesh;\n const previousState = this._pointerUnderMeshState[pointerId];\n if (!previousState && mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOver, payload: { pointerId, mesh } });\n } else if (previousState && !mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOut, payload: { pointerId, mesh: previousState } });\n } else if (previousState && mesh && previousState !== mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOut, payload: { pointerId, mesh: previousState, over: mesh } });\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOver, payload: { pointerId, mesh, out: previousState } });\n }\n this._pointerUnderMeshState[pointerId] = mesh;\n }, PointerEventTypes.POINTERMOVE);\n }\n\n public dispose() {\n this._sceneDisposeObserver?.remove();\n this._sceneReadyObserver?.remove();\n this._sceneOnBeforeRenderObserver?.remove();\n this._meshPickedObserver?.remove();\n this._meshUnderPointerObserver?.remove();\n this.onEventTriggeredObservable.clear();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphSceneEventCoordinator.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphSceneEventCoordinator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mCAAkC;AAG9D,OAAO,EAAE,UAAU,EAAE,8BAA6B;AAmBlD;;;;GAIG;AACH,MAAM,OAAO,8BA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AAE,CAAC;QACnC,IAAI,CAAC,4BAA4B,EAAE,MAAM,EAAE,CAAC;QAC5C,IAAI,CAAC,mBAAmB,EAAE,MAAM,EAAE,CAAC;QACnC,IAAI,CAAC,yBAAyB,EAAE,MAAM,EAAE,CAAC;QACzC,IAAI,CAAC,oBAAoB,EAAE,MAAM,EAAE,CAAC;QACpC,IAAI,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;QAClC,IAAI,CAAC,oBAAoB,EAAE,MAAM,EAAE,CAAC;QACpC,IAAI,CAAC,0BAA0B,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;CACJ","sourcesContent":["import type { PointerInfo } from \"core/Events/pointerEvents\";\nimport { PointerEventTypes } from \"core/Events/pointerEvents\";\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\nimport type { Observer } from \"core/Misc/observable\";\nimport { Observable } from \"core/Misc/observable\";\nimport type { Scene } from \"core/scene\";\nimport type { Nullable } from \"core/types\";\nimport { FlowGraphEventType } from \"./flowGraphEventType\";\n\n/**\n * the interface of the object the scene event coordinator will trigger.\n */\nexport interface IFlowGraphEventTrigger {\n /**\n * The type of the event\n */\n type: FlowGraphEventType;\n /**\n * The data of the event\n */\n payload?: any;\n}\n\n/**\n * This class is responsible for coordinating the events that are triggered in the scene.\n * It registers all observers needed to track certain events and triggers the blocks that are listening to them.\n * Abstracting the events from the class will allow us to easily change the events that are being listened to, and trigger them in any order.\n */\nexport class FlowGraphSceneEventCoordinator {\n /**\n * @internal\n */\n public readonly _scene: Scene;\n\n /**\n * register to this observable to get flow graph event notifications.\n */\n public onEventTriggeredObservable: Observable<IFlowGraphEventTrigger> = new Observable();\n\n /**\n * Was scene-ready already triggered?\n */\n public sceneReadyTriggered: boolean = false;\n\n private _sceneDisposeObserver: Nullable<Observer<Scene>>;\n private _sceneReadyObserver: Nullable<Observer<Scene>>;\n private _sceneOnBeforeRenderObserver: Nullable<Observer<Scene>>;\n private _meshPickedObserver: Nullable<Observer<PointerInfo>>;\n private _meshUnderPointerObserver: Nullable<Observer<{ mesh: Nullable<AbstractMesh>; pointerId: number }>>;\n private _pointerDownObserver: Nullable<Observer<PointerInfo>>;\n private _pointerUpObserver: Nullable<Observer<PointerInfo>>;\n private _pointerMoveObserver: Nullable<Observer<PointerInfo>>;\n private _pointerUnderMeshState: { [pointerId: number]: Nullable<AbstractMesh> } = {};\n\n private _startingTime: number = 0;\n\n constructor(scene: Scene) {\n this._scene = scene;\n this._initialize();\n }\n\n private _initialize() {\n this._sceneReadyObserver = this._scene.onReadyObservable.addOnce(() => {\n if (!this.sceneReadyTriggered) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneReady });\n this.sceneReadyTriggered = true;\n }\n });\n\n this._sceneDisposeObserver = this._scene.onDisposeObservable.add(() => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.SceneDispose });\n });\n this._sceneOnBeforeRenderObserver = this._scene.onBeforeRenderObservable.add(() => {\n const deltaTime = this._scene.getEngine().getDeltaTime() / 1000; // set in seconds\n this.onEventTriggeredObservable.notifyObservers({\n type: FlowGraphEventType.SceneBeforeRender,\n payload: {\n timeSinceStart: this._startingTime,\n deltaTime,\n },\n });\n this._startingTime += deltaTime;\n });\n\n this._meshPickedObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.MeshPick, payload: pointerInfo });\n }, PointerEventTypes.POINTERPICK); // should it be pointerdown?\n\n this._pointerDownObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerDown, payload: pointerInfo });\n }, PointerEventTypes.POINTERDOWN);\n\n this._pointerUpObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerUp, payload: pointerInfo });\n }, PointerEventTypes.POINTERUP);\n\n this._pointerMoveObserver = this._scene.onPointerObservable.add((pointerInfo) => {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerMove, payload: pointerInfo });\n }, PointerEventTypes.POINTERMOVE);\n\n this._meshUnderPointerObserver = this._scene.onMeshUnderPointerUpdatedObservable.add((data) => {\n // check if the data has changed. Check the state of the last change and see if it is a mesh or null.\n // if it is a mesh and the previous state was null, trigger over event. If it is null and the previous state was a mesh, trigger out event.\n // if it is a mesh and the previous state was a mesh, trigger out from the old mesh and over the new mesh\n // if it is null and the previous state was null, do nothing.\n const pointerId = data.pointerId;\n const mesh = data.mesh;\n const previousState = this._pointerUnderMeshState[pointerId];\n if (!previousState && mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOver, payload: { pointerId, mesh } });\n } else if (previousState && !mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOut, payload: { pointerId, mesh: previousState } });\n } else if (previousState && mesh && previousState !== mesh) {\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOut, payload: { pointerId, mesh: previousState, over: mesh } });\n this.onEventTriggeredObservable.notifyObservers({ type: FlowGraphEventType.PointerOver, payload: { pointerId, mesh, out: previousState } });\n }\n this._pointerUnderMeshState[pointerId] = mesh;\n }, PointerEventTypes.POINTERMOVE);\n }\n\n public dispose() {\n this._sceneDisposeObserver?.remove();\n this._sceneReadyObserver?.remove();\n this._sceneOnBeforeRenderObserver?.remove();\n this._meshPickedObserver?.remove();\n this._meshUnderPointerObserver?.remove();\n this._pointerDownObserver?.remove();\n this._pointerUpObserver?.remove();\n this._pointerMoveObserver?.remove();\n this.onEventTriggeredObservable.clear();\n }\n}\n"]}
|
|
@@ -18,6 +18,11 @@ export declare class FlowGraphSignalConnection extends FlowGraphConnection<FlowG
|
|
|
18
18
|
priority: number;
|
|
19
19
|
_isSingularConnection(): boolean;
|
|
20
20
|
connectTo(point: FlowGraphSignalConnection): void;
|
|
21
|
+
/**
|
|
22
|
+
* Timestamp of the last activation (set on output signals when they fire).
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
_lastActivationTime: number;
|
|
21
26
|
/**
|
|
22
27
|
* @internal
|
|
23
28
|
*/
|