@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.
Files changed (132) hide show
  1. package/Bones/skeleton.d.ts +5 -0
  2. package/Bones/skeleton.js +35 -8
  3. package/Bones/skeleton.js.map +1 -1
  4. package/Collisions/collider.js +2 -2
  5. package/Collisions/collider.js.map +1 -1
  6. package/Culling/Helper/computeShaderBoundingHelper.js +8 -1
  7. package/Culling/Helper/computeShaderBoundingHelper.js.map +1 -1
  8. package/Culling/Helper/transformFeedbackBoundingHelper.js +1 -1
  9. package/Culling/Helper/transformFeedbackBoundingHelper.js.map +1 -1
  10. package/Engines/WebGPU/webgpuShaderProcessingContext.d.ts +1 -0
  11. package/Engines/WebGPU/webgpuShaderProcessingContext.js.map +1 -1
  12. package/Engines/WebGPU/webgpuShaderProcessor.d.ts +1 -1
  13. package/Engines/WebGPU/webgpuShaderProcessor.js +2 -2
  14. package/Engines/WebGPU/webgpuShaderProcessor.js.map +1 -1
  15. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js +20 -2
  16. package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
  17. package/Engines/abstractEngine.js +2 -2
  18. package/Engines/abstractEngine.js.map +1 -1
  19. package/Engines/engine.d.ts +2 -1
  20. package/Engines/engineCapabilities.d.ts +2 -0
  21. package/Engines/engineCapabilities.js.map +1 -1
  22. package/Engines/nullEngine.js +1 -0
  23. package/Engines/nullEngine.js.map +1 -1
  24. package/Engines/thinEngine.js +1 -0
  25. package/Engines/thinEngine.js.map +1 -1
  26. package/Engines/thinNativeEngine.js +1 -0
  27. package/Engines/thinNativeEngine.js.map +1 -1
  28. package/Engines/webgpuEngine.js +1 -0
  29. package/Engines/webgpuEngine.js.map +1 -1
  30. package/FlowGraph/Blocks/Data/flowGraphDebugBlock.d.ts +45 -0
  31. package/FlowGraph/Blocks/Data/flowGraphDebugBlock.js +98 -0
  32. package/FlowGraph/Blocks/Data/flowGraphDebugBlock.js.map +1 -0
  33. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +16 -0
  34. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +15 -2
  35. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
  36. package/FlowGraph/Blocks/Event/flowGraphPointerDownEventBlock.d.ts +64 -0
  37. package/FlowGraph/Blocks/Event/flowGraphPointerDownEventBlock.js +54 -0
  38. package/FlowGraph/Blocks/Event/flowGraphPointerDownEventBlock.js.map +1 -0
  39. package/FlowGraph/Blocks/Event/flowGraphPointerMoveEventBlock.d.ts +64 -0
  40. package/FlowGraph/Blocks/Event/flowGraphPointerMoveEventBlock.js +54 -0
  41. package/FlowGraph/Blocks/Event/flowGraphPointerMoveEventBlock.js.map +1 -0
  42. package/FlowGraph/Blocks/Event/flowGraphPointerUpEventBlock.d.ts +64 -0
  43. package/FlowGraph/Blocks/Event/flowGraphPointerUpEventBlock.js +54 -0
  44. package/FlowGraph/Blocks/Event/flowGraphPointerUpEventBlock.js.map +1 -0
  45. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +1 -0
  46. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +17 -1
  47. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  48. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.d.ts +1 -0
  49. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js +23 -3
  50. package/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.js.map +1 -1
  51. package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.js +2 -2
  52. package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.js.map +1 -1
  53. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +7 -1
  54. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  55. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.d.ts +4 -0
  56. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js +6 -2
  57. package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
  58. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +2 -2
  59. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  60. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +0 -4
  61. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
  62. package/FlowGraph/Blocks/flowGraphBlockFactory.js +16 -0
  63. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
  64. package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +2 -1
  65. package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
  66. package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
  67. package/FlowGraph/flowGraph.d.ts +63 -2
  68. package/FlowGraph/flowGraph.js +210 -19
  69. package/FlowGraph/flowGraph.js.map +1 -1
  70. package/FlowGraph/flowGraphContext.d.ts +73 -0
  71. package/FlowGraph/flowGraphContext.js +115 -0
  72. package/FlowGraph/flowGraphContext.js.map +1 -1
  73. package/FlowGraph/flowGraphExecutionBlock.d.ts +7 -0
  74. package/FlowGraph/flowGraphExecutionBlock.js +7 -0
  75. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  76. package/FlowGraph/flowGraphParser.js +1 -0
  77. package/FlowGraph/flowGraphParser.js.map +1 -1
  78. package/FlowGraph/flowGraphSceneEventCoordinator.d.ts +3 -0
  79. package/FlowGraph/flowGraphSceneEventCoordinator.js +13 -1
  80. package/FlowGraph/flowGraphSceneEventCoordinator.js.map +1 -1
  81. package/FlowGraph/flowGraphSignalConnection.d.ts +5 -0
  82. package/FlowGraph/flowGraphSignalConnection.js +12 -0
  83. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  84. package/FlowGraph/flowGraphValidator.d.ts +66 -0
  85. package/FlowGraph/flowGraphValidator.js +324 -0
  86. package/FlowGraph/flowGraphValidator.js.map +1 -0
  87. package/FlowGraph/index.d.ts +1 -0
  88. package/FlowGraph/index.js +1 -0
  89. package/FlowGraph/index.js.map +1 -1
  90. package/FlowGraph/serialization.js +10 -3
  91. package/FlowGraph/serialization.js.map +1 -1
  92. package/Layers/thinEffectLayer.js +1 -1
  93. package/Layers/thinEffectLayer.js.map +1 -1
  94. package/Layers/thinSelectionOutlineLayer.js +1 -1
  95. package/Layers/thinSelectionOutlineLayer.js.map +1 -1
  96. package/Lights/Shadows/shadowGenerator.js +1 -1
  97. package/Lights/Shadows/shadowGenerator.js.map +1 -1
  98. package/Materials/Node/Blocks/Vertex/bonesBlock.js +2 -2
  99. package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
  100. package/Materials/PBR/openpbrMaterial.js +1 -1
  101. package/Materials/PBR/openpbrMaterial.js.map +1 -1
  102. package/Materials/PBR/pbrBaseMaterial.js +1 -1
  103. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  104. package/Materials/materialHelper.functions.js +2 -2
  105. package/Materials/materialHelper.functions.js.map +1 -1
  106. package/Materials/materialHelper.geometryrendering.js +1 -1
  107. package/Materials/materialHelper.geometryrendering.js.map +1 -1
  108. package/Materials/standardMaterial.js +1 -1
  109. package/Materials/standardMaterial.js.map +1 -1
  110. package/Meshes/mesh.js +2 -2
  111. package/Meshes/mesh.js.map +1 -1
  112. package/Misc/bitArray.js +1 -1
  113. package/Misc/bitArray.js.map +1 -1
  114. package/Misc/tools.js +3 -3
  115. package/Misc/tools.js.map +1 -1
  116. package/Particles/thinParticleSystem.js +2 -2
  117. package/Particles/thinParticleSystem.js.map +1 -1
  118. package/PostProcesses/volumetricLightScatteringPostProcess.js +1 -1
  119. package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
  120. package/Rendering/depthRenderer.js +1 -1
  121. package/Rendering/depthRenderer.js.map +1 -1
  122. package/Rendering/geometryBufferRenderer.js +3 -3
  123. package/Rendering/geometryBufferRenderer.js.map +1 -1
  124. package/Rendering/outlineRenderer.js +1 -1
  125. package/Rendering/outlineRenderer.js.map +1 -1
  126. package/Shaders/ShadersInclude/bonesDeclaration.js +5 -7
  127. package/Shaders/ShadersInclude/bonesDeclaration.js.map +1 -1
  128. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js +3 -3
  129. package/ShadersWGSL/ShadersInclude/bonesDeclaration.js.map +1 -1
  130. package/ShadersWGSL/boundingInfo.compute.js +4 -3
  131. package/ShadersWGSL/boundingInfo.compute.js.map +1 -1
  132. package/package.json +1 -1
@@ -0,0 +1,54 @@
1
+ import { FlowGraphEventBlock } from "../../flowGraphEventBlock.js";
2
+ import { RegisterClass } from "../../../Misc/typeStore.js";
3
+ import { _IsDescendantOf } from "../../utils.js";
4
+ import { RichTypeAny, RichTypeNumber } from "../../flowGraphRichTypes.js";
5
+ /**
6
+ * A pointer up event block.
7
+ * This block fires when a pointer is released (mouse button up / touch end).
8
+ * Optionally filters to a specific mesh via the `targetMesh` input.
9
+ */
10
+ export class FlowGraphPointerUpEventBlock extends FlowGraphEventBlock {
11
+ /**
12
+ * Creates a new FlowGraphPointerUpEventBlock.
13
+ * @param config optional configuration
14
+ */
15
+ constructor(config) {
16
+ super(config);
17
+ /** @internal */
18
+ this.type = "PointerUp" /* FlowGraphEventType.PointerUp */;
19
+ this.targetMesh = this.registerDataInput("targetMesh", RichTypeAny, config?.targetMesh);
20
+ this.pointerId = this.registerDataOutput("pointerId", RichTypeNumber);
21
+ this.pickedMesh = this.registerDataOutput("pickedMesh", RichTypeAny);
22
+ this.pickedPoint = this.registerDataOutput("pickedPoint", RichTypeAny);
23
+ }
24
+ /** @internal */
25
+ _executeEvent(context, pointerInfo) {
26
+ const mesh = this.targetMesh.getValue(context);
27
+ const pickedMesh = pointerInfo.pickInfo?.pickedMesh;
28
+ // If a target mesh is set, only fire when that mesh (or a descendant) is picked.
29
+ if (mesh && !(pickedMesh === mesh || (pickedMesh && _IsDescendantOf(pickedMesh, mesh)))) {
30
+ return true;
31
+ }
32
+ this.pointerId.setValue(pointerInfo.event.pointerId, context);
33
+ this.pickedMesh.setValue(pickedMesh ?? null, context);
34
+ this.pickedPoint.setValue(pointerInfo.pickInfo?.pickedPoint ?? null, context);
35
+ this._execute(context);
36
+ return !this.config?.stopPropagation;
37
+ }
38
+ /** @internal */
39
+ _preparePendingTasks(_context) {
40
+ // no-op
41
+ }
42
+ /** @internal */
43
+ _cancelPendingTasks(_context) {
44
+ // no-op
45
+ }
46
+ /**
47
+ * @returns the class name of the block.
48
+ */
49
+ getClassName() {
50
+ return "FlowGraphPointerUpEventBlock" /* FlowGraphBlockNames.PointerUpEvent */;
51
+ }
52
+ }
53
+ RegisterClass("FlowGraphPointerUpEventBlock" /* FlowGraphBlockNames.PointerUpEvent */, FlowGraphPointerUpEventBlock);
54
+ //# sourceMappingURL=flowGraphPointerUpEventBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowGraphPointerUpEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphPointerUpEventBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,qCAA2C;AAIzE,OAAO,EAAE,aAAa,EAAE,mCAA4B;AACpD,OAAO,EAAE,eAAe,EAAE,uBAA6B;AAGvD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,oCAA0C;AAqBhF;;;;GAIG;AACH,MAAM,OAAO,4BAA6B,SAAQ,mBAAmB;IAyBjE;;;OAGG;IACH,YAAmB,MAAmD;QAClE,KAAK,CAAC,MAAM,CAAC,CAAC;QARlB,gBAAgB;QACS,SAAI,kDAAoD;QAQ7E,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACxF,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AC9C,CAAC;CACJ;AAED,aAAa,0EAAqC,4BAA4B,CAAC,CAAC","sourcesContent":["import type { AbstractMesh } from \"core/Meshes/abstractMesh\";\nimport { FlowGraphEventBlock } from \"core/FlowGraph/flowGraphEventBlock\";\nimport type { PointerInfo } from \"core/Events/pointerEvents\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { _IsDescendantOf } from \"core/FlowGraph/utils\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { RichTypeAny, RichTypeNumber } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { Vector3 } from \"core/Maths/math.vector\";\nimport { FlowGraphEventType } from \"core/FlowGraph/flowGraphEventType\";\nimport type { Nullable } from \"core/types\";\n\n/**\n * Configuration for the pointer up event block.\n */\nexport interface IFlowGraphPointerUpEventBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * Should this block stop propagation of the event to other listeners.\n */\n stopPropagation?: boolean;\n\n /**\n * Optional mesh to filter events to. If set, the block only fires when the pointer\n * is released over this mesh or a descendant of it. If not set, fires on any pointer up.\n */\n targetMesh?: AbstractMesh;\n}\n\n/**\n * A pointer up event block.\n * This block fires when a pointer is released (mouse button up / touch end).\n * Optionally filters to a specific mesh via the `targetMesh` input.\n */\nexport class FlowGraphPointerUpEventBlock extends FlowGraphEventBlock {\n /**\n * Optional input connection: restrict firing to this mesh (and its descendants).\n * Leave disconnected to fire on any pointer up.\n */\n public readonly targetMesh: FlowGraphDataConnection<AbstractMesh>;\n\n /**\n * Output connection: The id of the pointer that triggered the event.\n */\n public readonly pointerId: FlowGraphDataConnection<number>;\n\n /**\n * Output connection: The mesh that was picked (if any).\n */\n public readonly pickedMesh: FlowGraphDataConnection<Nullable<AbstractMesh>>;\n\n /**\n * Output connection: The world-space point that was picked (if any).\n */\n public readonly pickedPoint: FlowGraphDataConnection<Nullable<Vector3>>;\n\n /** @internal */\n public override readonly type: FlowGraphEventType = FlowGraphEventType.PointerUp;\n\n /**\n * Creates a new FlowGraphPointerUpEventBlock.\n * @param config optional configuration\n */\n public constructor(config?: IFlowGraphPointerUpEventBlockConfiguration) {\n super(config);\n this.targetMesh = this.registerDataInput(\"targetMesh\", RichTypeAny, config?.targetMesh);\n this.pointerId = this.registerDataOutput(\"pointerId\", RichTypeNumber);\n this.pickedMesh = this.registerDataOutput(\"pickedMesh\", RichTypeAny);\n this.pickedPoint = this.registerDataOutput(\"pickedPoint\", RichTypeAny);\n }\n\n /** @internal */\n public override _executeEvent(context: FlowGraphContext, pointerInfo: PointerInfo): boolean {\n const mesh = this.targetMesh.getValue(context);\n const pickedMesh = pointerInfo.pickInfo?.pickedMesh;\n\n // If a target mesh is set, only fire when that mesh (or a descendant) is picked.\n if (mesh && !(pickedMesh === mesh || (pickedMesh && _IsDescendantOf(pickedMesh, mesh)))) {\n return true;\n }\n\n this.pointerId.setValue((pointerInfo.event as PointerEvent).pointerId, context);\n this.pickedMesh.setValue(pickedMesh ?? null, context);\n this.pickedPoint.setValue(pointerInfo.pickInfo?.pickedPoint ?? null, context);\n this._execute(context);\n return !this.config?.stopPropagation;\n }\n\n /** @internal */\n public override _preparePendingTasks(_context: FlowGraphContext): void {\n // no-op\n }\n\n /** @internal */\n public override _cancelPendingTasks(_context: FlowGraphContext): void {\n // no-op\n }\n\n /**\n * @returns the class name of the block.\n */\n public override getClassName(): string {\n return FlowGraphBlockNames.PointerUpEvent;\n }\n}\n\nRegisterClass(FlowGraphBlockNames.PointerUpEvent, FlowGraphPointerUpEventBlock);\n"]}
@@ -40,6 +40,7 @@ export declare class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBloc
40
40
  _preparePendingTasks(context: FlowGraphContext): void;
41
41
  _cancelPendingTasks(context: FlowGraphContext): void;
42
42
  _executeEvent(_context: FlowGraphContext, _payload: any): boolean;
43
+ serialize(serializationObject?: any): void;
43
44
  /**
44
45
  * @returns class name of the block.
45
46
  */
@@ -1,5 +1,6 @@
1
1
  import { FlowGraphEventBlock } from "../../flowGraphEventBlock.js";
2
2
  import { Tools } from "../../../Misc/tools.js";
3
+ import { getRichTypeByFlowGraphType } from "../../flowGraphRichTypes.js";
3
4
  import { RegisterClass } from "../../../Misc/typeStore.js";
4
5
  import { FlowGraphCoordinator } from "../../flowGraphCoordinator.js";
5
6
  /**
@@ -18,7 +19,13 @@ export class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {
18
19
  this.initPriority = 1;
19
20
  // use event data to register data outputs
20
21
  for (const key in this.config.eventData) {
21
- this.registerDataOutput(key, this.config.eventData[key].type);
22
+ const entry = this.config.eventData[key];
23
+ // Handle deserialized config where type may be a string typeName, a plain object
24
+ // with a typeName property (from old JSON serialization), or a proper RichType instance.
25
+ const typeKey = typeof entry.type === "string" ? entry.type : entry.type?.typeName;
26
+ const richType = typeof entry.type?.serialize === "function" ? entry.type : getRichTypeByFlowGraphType(typeKey);
27
+ entry.type = richType;
28
+ this.registerDataOutput(key, richType);
22
29
  }
23
30
  }
24
31
  _preparePendingTasks(context) {
@@ -50,6 +57,15 @@ export class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {
50
57
  _executeEvent(_context, _payload) {
51
58
  return true;
52
59
  }
60
+ serialize(serializationObject = {}) {
61
+ super.serialize(serializationObject);
62
+ // Override the eventData in config to store typeName strings instead of RichType instances
63
+ const serializedEventData = {};
64
+ for (const key in this.config.eventData) {
65
+ serializedEventData[key] = { type: this.config.eventData[key].type.typeName };
66
+ }
67
+ serializationObject.config.eventData = serializedEventData;
68
+ }
53
69
  /**
54
70
  * @returns class name of the block.
55
71
  */
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphReceiveCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock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,IAAI,IAAI,EAAE,CAAC;gBACrB,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;YAC/D,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,EAAE,aAAa,CAAC,CAAC;IACzE,CAAC;IACe,mBAAmB,CAAC,OAAyB;QACzD,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACnG,IAAI,UAAU,EAAE,CAAC;YACb,MAAM,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAA4B,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC,CAAC;YAC7G,UAAU,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC;aAAM,CAAC;YACJ,KAAK,CAAC,IAAI,CAAC,kEAAkE,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACxG,CAAC;IACL,CAAC;IAEe,aAAa,CAAC,QAA0B,EAAE,QAAa;QACnE,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,uFAA8C;IAClD,CAAC;CACJ;AACD,aAAa,kFAAyC,gCAAgC,CAAC,CAAC","sourcesContent":["import type { Observer } from \"../../../Misc/observable\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { FlowGraphEventBlock } from \"../../flowGraphEventBlock\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Tools } from \"../../../Misc/tools\";\r\nimport type { RichType } from \"../../flowGraphRichTypes\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\r\nimport { FlowGraphCoordinator } from \"core/FlowGraph/flowGraphCoordinator\";\r\n/**\r\n * Parameters used to create a FlowGraphReceiveCustomEventBlock.\r\n */\r\nexport interface IFlowGraphReceiveCustomEventBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The id of the event to receive.\r\n * This event id is unique to the environment (not the context).\r\n */\r\n eventId: string;\r\n /**\r\n * The names of the data outputs for that event. Should be in the same order as the event data in\r\n * SendCustomEvent\r\n */\r\n eventData: { [key: string]: { type: RichType<any> } };\r\n}\r\n\r\n/**\r\n * A block that receives a custom event.\r\n * It saves the event data in the data outputs, based on the provided eventData in the configuration. For example, if the event data is\r\n * `{ x: { type: RichTypeNumber }, y: { type: RichTypeNumber } }`, the block will have two data outputs: x and y.\r\n */\r\nexport class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {\r\n public override initPriority: number = 1;\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphReceiveCustomEventBlockConfiguration\r\n ) {\r\n super(config);\r\n // use event data to register data outputs\r\n for (const key in this.config.eventData) {\r\n this.registerDataOutput(key, this.config.eventData[key].type);\r\n }\r\n }\r\n\r\n public override _preparePendingTasks(context: FlowGraphContext): void {\r\n const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);\r\n // check if we are not exceeding the max number of events\r\n if (observable && observable.hasObservers() && observable.observers.length > FlowGraphCoordinator.MaxEventsPerType) {\r\n this._reportError(context, `FlowGraphReceiveCustomEventBlock: Too many observers for event ${this.config.eventId}. Max is ${FlowGraphCoordinator.MaxEventsPerType}.`);\r\n return;\r\n }\r\n\r\n const eventObserver = observable.add((eventData: { [key: string]: any }) => {\r\n const keys = Object.keys(eventData);\r\n for (const key of keys) {\r\n this.getDataOutput(key)?.setValue(eventData[key], context);\r\n }\r\n this._execute(context);\r\n });\r\n context._setExecutionVariable(this, \"_eventObserver\", eventObserver);\r\n }\r\n public override _cancelPendingTasks(context: FlowGraphContext): void {\r\n const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);\r\n if (observable) {\r\n const eventObserver = context._getExecutionVariable<Nullable<Observer<any[]>>>(this, \"_eventObserver\", null);\r\n observable.remove(eventObserver);\r\n } else {\r\n Tools.Warn(`FlowGraphReceiveCustomEventBlock: Missing observable for event ${this.config.eventId}`);\r\n }\r\n }\r\n\r\n public override _executeEvent(_context: FlowGraphContext, _payload: any): boolean {\r\n return true;\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.ReceiveCustomEvent;\r\n }\r\n}\r\nRegisterClass(FlowGraphBlockNames.ReceiveCustomEvent, FlowGraphReceiveCustomEventBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphReceiveCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,sCAA4C;AAiB3E;;;;GAIG;AACH,MAAM,OAAO,gCAAiC,SAAQ,mBAAmB;IAGrE;IACI;;OAEG;IACa,MAAsD;QAEtE,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAAgD;QAN1D,iBAAY,GAAW,CAAC,CAAC;QASrC,0CAA0C;QAC1C,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACzC,iFAAi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port type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { FlowGraphEventBlock } from \"../../flowGraphEventBlock\";\r\nimport type { Nullable } from \"../../../types\";\r\nimport { Tools } from \"../../../Misc/tools\";\r\nimport type { RichType } from \"../../flowGraphRichTypes\";\r\nimport { getRichTypeByFlowGraphType } from \"../../flowGraphRichTypes\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\r\nimport { FlowGraphCoordinator } from \"core/FlowGraph/flowGraphCoordinator\";\r\n/**\r\n * Parameters used to create a FlowGraphReceiveCustomEventBlock.\r\n */\r\nexport interface IFlowGraphReceiveCustomEventBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The id of the event to receive.\r\n * This event id is unique to the environment (not the context).\r\n */\r\n eventId: string;\r\n /**\r\n * The names of the data outputs for that event. Should be in the same order as the event data in\r\n * SendCustomEvent\r\n */\r\n eventData: { [key: string]: { type: RichType<any> } };\r\n}\r\n\r\n/**\r\n * A block that receives a custom event.\r\n * It saves the event data in the data outputs, based on the provided eventData in the configuration. For example, if the event data is\r\n * `{ x: { type: RichTypeNumber }, y: { type: RichTypeNumber } }`, the block will have two data outputs: x and y.\r\n */\r\nexport class FlowGraphReceiveCustomEventBlock extends FlowGraphEventBlock {\r\n public override initPriority: number = 1;\r\n\r\n constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphReceiveCustomEventBlockConfiguration\r\n ) {\r\n super(config);\r\n // use event data to register data outputs\r\n for (const key in this.config.eventData) {\r\n const entry = this.config.eventData[key];\r\n // Handle deserialized config where type may be a string typeName, a plain object\r\n // with a typeName property (from old JSON serialization), or a proper RichType instance.\r\n const typeKey = typeof entry.type === \"string\" ? entry.type : entry.type?.typeName;\r\n const richType = typeof entry.type?.serialize === \"function\" ? entry.type : getRichTypeByFlowGraphType(typeKey);\r\n entry.type = richType;\r\n this.registerDataOutput(key, richType);\r\n }\r\n }\r\n\r\n public override _preparePendingTasks(context: FlowGraphContext): void {\r\n const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);\r\n // check if we are not exceeding the max number of events\r\n if (observable && observable.hasObservers() && observable.observers.length > FlowGraphCoordinator.MaxEventsPerType) {\r\n this._reportError(context, `FlowGraphReceiveCustomEventBlock: Too many observers for event ${this.config.eventId}. Max is ${FlowGraphCoordinator.MaxEventsPerType}.`);\r\n return;\r\n }\r\n\r\n const eventObserver = observable.add((eventData: { [key: string]: any }) => {\r\n const keys = Object.keys(eventData);\r\n for (const key of keys) {\r\n this.getDataOutput(key)?.setValue(eventData[key], context);\r\n }\r\n this._execute(context);\r\n });\r\n context._setExecutionVariable(this, \"_eventObserver\", eventObserver);\r\n }\r\n public override _cancelPendingTasks(context: FlowGraphContext): void {\r\n const observable = context.configuration.coordinator.getCustomEventObservable(this.config.eventId);\r\n if (observable) {\r\n const eventObserver = context._getExecutionVariable<Nullable<Observer<any[]>>>(this, \"_eventObserver\", null);\r\n observable.remove(eventObserver);\r\n } else {\r\n Tools.Warn(`FlowGraphReceiveCustomEventBlock: Missing observable for event ${this.config.eventId}`);\r\n }\r\n }\r\n\r\n public override _executeEvent(_context: FlowGraphContext, _payload: any): boolean {\r\n return true;\r\n }\r\n\r\n public override serialize(serializationObject: any = {}) {\r\n super.serialize(serializationObject);\r\n // Override the eventData in config to store typeName strings instead of RichType instances\r\n const serializedEventData: any = {};\r\n for (const key in this.config.eventData) {\r\n serializedEventData[key] = { type: this.config.eventData[key].type.typeName };\r\n }\r\n serializationObject.config.eventData = serializedEventData;\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.ReceiveCustomEvent;\r\n }\r\n}\r\nRegisterClass(FlowGraphBlockNames.ReceiveCustomEvent, FlowGraphReceiveCustomEventBlock);\r\n"]}
@@ -38,6 +38,7 @@ export declare class FlowGraphSendCustomEventBlock extends FlowGraphExecutionBlo
38
38
  */
39
39
  config: IFlowGraphSendCustomEventBlockConfiguration);
40
40
  _execute(context: FlowGraphContext): void;
41
+ serialize(serializationObject?: any): void;
41
42
  /**
42
43
  * @returns class name of the block.
43
44
  */
@@ -1,3 +1,4 @@
1
+ import { getRichTypeByFlowGraphType } from "../../flowGraphRichTypes.js";
1
2
  import { FlowGraphExecutionBlockWithOutSignal } from "../../flowGraphExecutionBlockWithOutSignal.js";
2
3
  import { RegisterClass } from "../../../Misc/typeStore.js";
3
4
  /**
@@ -15,7 +16,13 @@ export class FlowGraphSendCustomEventBlock extends FlowGraphExecutionBlockWithOu
15
16
  super(config);
16
17
  this.config = config;
17
18
  for (const key in this.config.eventData) {
18
- this.registerDataInput(key, this.config.eventData[key].type, this.config.eventData[key].value);
19
+ const entry = this.config.eventData[key];
20
+ // Handle deserialized config where type may be a string typeName, a plain object
21
+ // with a typeName property (from old JSON serialization), or a proper RichType instance.
22
+ const typeKey = typeof entry.type === "string" ? entry.type : entry.type?.typeName;
23
+ const richType = typeof entry.type?.serialize === "function" ? entry.type : getRichTypeByFlowGraphType(typeKey);
24
+ entry.type = richType;
25
+ this.registerDataInput(key, richType, entry.value);
19
26
  }
20
27
  }
21
28
  _execute(context) {
@@ -28,12 +35,25 @@ export class FlowGraphSendCustomEventBlock extends FlowGraphExecutionBlockWithOu
28
35
  context.configuration.coordinator.notifyCustomEvent(eventId, eventData);
29
36
  this.out._activateSignal(context);
30
37
  }
38
+ serialize(serializationObject = {}) {
39
+ super.serialize(serializationObject);
40
+ // Override the eventData in config to store typeName strings instead of RichType instances
41
+ const serializedEventData = {};
42
+ for (const key in this.config.eventData) {
43
+ const entry = this.config.eventData[key];
44
+ serializedEventData[key] = { type: entry.type.typeName };
45
+ if (entry.value !== undefined) {
46
+ serializedEventData[key].value = entry.value;
47
+ }
48
+ }
49
+ serializationObject.config.eventData = serializedEventData;
50
+ }
31
51
  /**
32
52
  * @returns class name of the block.
33
53
  */
34
54
  getClassName() {
35
- return "FlowGraphReceiveCustomEventBlock" /* FlowGraphBlockNames.ReceiveCustomEvent */;
55
+ return "FlowGraphSendCustomEventBlock" /* FlowGraphBlockNames.SendCustomEvent */;
36
56
  }
37
57
  }
38
- RegisterClass("FlowGraphReceiveCustomEventBlock" /* FlowGraphBlockNames.ReceiveCustomEvent */, FlowGraphSendCustomEventBlock);
58
+ RegisterClass("FlowGraphSendCustomEventBlock" /* FlowGraphBlockNames.SendCustomEvent */, FlowGraphSendCustomEventBlock);
39
59
  //# sourceMappingURL=flowGraphSendCustomEventBlock.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphSendCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oCAAoC,EAAE,MAAM,4CAA4C,CAAC;AAElG,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAkBxD;;;;;GAKG;AACH,MAAM,OAAO,6BAA8B,SAAQ,oCAAoC;IACnF;IACI;;OAEG;IACa,MAAmD;QAEnE,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAA6C;QAGnE,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,iBAAiB,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;QACnG,CAAC;IACL,CAAC;IAEM,QAAQ,CAAC,OAAyB;QACrC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;QACpC,sGAAsG;QACtG,MAAM,SAAS,GAAQ,EAAE,CAAC;QAC1B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACjC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClD,CAAC;QAED,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,iBAAiB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAExE,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,uFAA8C;IAClD,CAAC;CACJ;AACD,aAAa,kFAAyC,6BAA6B,CAAC,CAAC","sourcesContent":["import type { RichType } from \"core/FlowGraph/flowGraphRichTypes\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../flowGraphExecutionBlockWithOutSignal\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\r\n\r\n/**\r\n * Parameters used to create a FlowGraphSendCustomEventBlock.\r\n */\r\nexport interface IFlowGraphSendCustomEventBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The id of the event to send.\r\n * Note - in the glTF specs this is an index to the event array (i.e. - a number)\r\n */\r\n eventId: string;\r\n /**\r\n * The names of the data inputs for that event.\r\n */\r\n eventData: { [key: string]: { type: RichType<any>; value?: any } };\r\n}\r\n/**\r\n * A block that sends a custom event.\r\n * To receive this event you need to use the ReceiveCustomEvent block.\r\n * This block has no output, but does have inputs based on the eventData from the configuration.\r\n * @see FlowGraphReceiveCustomEventBlock\r\n */\r\nexport class FlowGraphSendCustomEventBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphSendCustomEventBlockConfiguration\r\n ) {\r\n super(config);\r\n for (const key in this.config.eventData) {\r\n this.registerDataInput(key, this.config.eventData[key].type, this.config.eventData[key].value);\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n const eventId = this.config.eventId;\r\n // eventData is a map with the key being the data input's name, and value being the data input's value\r\n const eventData: any = {};\r\n for (const port of this.dataInputs) {\r\n eventData[port.name] = port.getValue(context);\r\n }\r\n\r\n context.configuration.coordinator.notifyCustomEvent(eventId, eventData);\r\n\r\n this.out._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.ReceiveCustomEvent;\r\n }\r\n}\r\nRegisterClass(FlowGraphBlockNames.ReceiveCustomEvent, FlowGraphSendCustomEventBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphSendCustomEventBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphSendCustomEventBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,oCAA0C;AAC/E,OAAO,EAAE,oCAAoC,EAAE,MAAM,4CAA4C,CAAC;AAElG,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAkBxD;;;;;GAKG;AACH,MAAM,OAAO,6BAA8B,SAAQ,oCAAoC;IACnF;IACI;;OAEG;IACa,MAAmD;QAEnE,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAA6C;QAGnE,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;YACtC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACzC,iFAAiF;YACjF,yFAAyF;YACzF,MAAM,OAAO,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC;YACnF,MAAM,QAAQ,GAAG,O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KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;YACjD,CAAC;QACL,CAAC;QACD,mBAAmB,CAAC,MAAM,CAAC,SAAS,GAAG,mBAAmB,CAAC;IAC/D,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,iFAA2C;IAC/C,CAAC;CACJ;AACD,aAAa,4EAAsC,6BAA6B,CAAC,CAAC","sourcesContent":["import type { RichType } from \"core/FlowGraph/flowGraphRichTypes\";\r\nimport { getRichTypeByFlowGraphType } from \"core/FlowGraph/flowGraphRichTypes\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../flowGraphExecutionBlockWithOutSignal\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\r\n\r\n/**\r\n * Parameters used to create a FlowGraphSendCustomEventBlock.\r\n */\r\nexport interface IFlowGraphSendCustomEventBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * The id of the event to send.\r\n * Note - in the glTF specs this is an index to the event array (i.e. - a number)\r\n */\r\n eventId: string;\r\n /**\r\n * The names of the data inputs for that event.\r\n */\r\n eventData: { [key: string]: { type: RichType<any>; value?: any } };\r\n}\r\n/**\r\n * A block that sends a custom event.\r\n * To receive this event you need to use the ReceiveCustomEvent block.\r\n * This block has no output, but does have inputs based on the eventData from the configuration.\r\n * @see FlowGraphReceiveCustomEventBlock\r\n */\r\nexport class FlowGraphSendCustomEventBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config: IFlowGraphSendCustomEventBlockConfiguration\r\n ) {\r\n super(config);\r\n for (const key in this.config.eventData) {\r\n const entry = this.config.eventData[key];\r\n // Handle deserialized config where type may be a string typeName, a plain object\r\n // with a typeName property (from old JSON serialization), or a proper RichType instance.\r\n const typeKey = typeof entry.type === \"string\" ? entry.type : entry.type?.typeName;\r\n const richType = typeof entry.type?.serialize === \"function\" ? entry.type : getRichTypeByFlowGraphType(typeKey);\r\n entry.type = richType;\r\n this.registerDataInput(key, richType, entry.value);\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n const eventId = this.config.eventId;\r\n // eventData is a map with the key being the data input's name, and value being the data input's value\r\n const eventData: any = {};\r\n for (const port of this.dataInputs) {\r\n eventData[port.name] = port.getValue(context);\r\n }\r\n\r\n context.configuration.coordinator.notifyCustomEvent(eventId, eventData);\r\n\r\n this.out._activateSignal(context);\r\n }\r\n\r\n public override serialize(serializationObject: any = {}) {\r\n super.serialize(serializationObject);\r\n // Override the eventData in config to store typeName strings instead of RichType instances\r\n const serializedEventData: any = {};\r\n for (const key in this.config.eventData) {\r\n const entry = this.config.eventData[key];\r\n serializedEventData[key] = { type: entry.type.typeName };\r\n if (entry.value !== undefined) {\r\n serializedEventData[key].value = entry.value;\r\n }\r\n }\r\n serializationObject.config.eventData = serializedEventData;\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.SendCustomEvent;\r\n }\r\n}\r\nRegisterClass(FlowGraphBlockNames.SendCustomEvent, FlowGraphSendCustomEventBlock);\r\n"]}
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { FlowGraphBlock } from "../../../flowGraphBlock.js";
3
- import { getRichTypeByAnimationType, getRichTypeByFlowGraphType, RichTypeAny, RichTypeNumber } from "../../../flowGraphRichTypes.js";
3
+ import { getRichTypeByAnimationType, getRichTypeByFlowGraphType, RichTypeAny, RichTypeNumber, RichTypeString } from "../../../flowGraphRichTypes.js";
4
4
  import { Animation } from "../../../../Animations/animation.js";
5
5
  import { RegisterClass } from "../../../../Misc/typeStore.js";
6
6
  /**
@@ -37,7 +37,7 @@ export class FlowGraphInterpolationBlock extends FlowGraphBlock {
37
37
  this.endValue = this.keyFrames[numberOfKeyFrames].value;
38
38
  this.easingFunction = this.registerDataInput("easingFunction", RichTypeAny);
39
39
  this.animation = this.registerDataOutput("animation", RichTypeAny);
40
- this.propertyName = this.registerDataInput("propertyName", RichTypeAny, config?.propertyName);
40
+ this.propertyName = this.registerDataInput("propertyName", RichTypeString, config?.propertyName);
41
41
  this.customBuildAnimation = this.registerDataInput("customBuildAnimation", RichTypeAny);
42
42
  }
43
43
  _updateOutputs(context) {
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphInterpolationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,yCAA+B;AACnD,OAAO,EAAE,cAAc,EAAqC,mCAAsC;AAIlG,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,WAAW,EAAE,cAAc,EAAE,uCAA0C;AACxI,OAAO,EAAE,SAAS,EAAE,4CAAkC;AACtD,OAAO,EAAE,aAAa,EAAE,sCAA4B;AA+BpD;;;;;;;;;GASG;AACH,MAAM,OAAO,2BAA+B,SAAQ,cAAc;IA8C9D,YAAY,SAAoD,EAAE;QAC9D,KAAK,CAAC,MAAM,CAAC,CAAC;QAVlB;;;WAGG;QACa,cAAS,GAGnB,EAAE,CAAC;QAIL,MAAM,IAAI,GACN,OAAO,MAAM,EAAE,aAAa,KAAK,QAAQ;YACrC,CAAC,CAAC,0BAA0B,CAAC,MAAM,CAAC,aAAa,CAAC;YAClD,CAAC,CAAC,0BAA0B,CAAC,MAAM,EAAE,aAAa,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC;QAE7F,MAAM,iBAAiB,GAAG,MAAM,EAAE,cAAc,IAAI,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,IAAI,CAAC,iBAAiB,CAAC,YAAY,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;QACzE,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,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C,IAAI,EAAE,EAAE;gBACzC,MAAM,SAAS,GAAG,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;gBAC1F,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACxB,OAAO,SAAS,CAAC;YACrB,CAAC,CAAC,CAAC;YACH,OAAO,UAAU,CAAC;QACtB,CAAC;IACL,CAAC;IAEe,YAAY;QACxB,kFAA8C;IAClD,CAAC;CACJ;AAED,aAAa,6EAAyC,2BAA2B,CAAC,CAAC;AAEnF,UAAU","sourcesContent":["import type { EasingFunction } from \"core/Animations/easing\";\nimport { Constants } from \"core/Engines/constants\";\nimport { FlowGraphBlock, type IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport type { FlowGraphTypes } from \"core/FlowGraph/flowGraphRichTypes\";\nimport { getRichTypeByAnimationType, getRichTypeByFlowGraphType, RichTypeAny, RichTypeNumber } from \"core/FlowGraph/flowGraphRichTypes\";\nimport { Animation } from \"core/Animations/animation\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\n\n/**\n * Configuration for the interpolation block.\n */\nexport interface IFlowGraphInterpolationBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The number of keyframes to interpolate between.\n * Will default to 1 if not provided (i.e. from currentValue to a provided value in the time provided)\n */\n keyFramesCount?: number;\n\n /**\n * The duration of the interpolation.\n */\n duration?: number;\n\n /**\n * The name of the property that will be interpolated.\n */\n propertyName?: string | string[];\n\n /**\n * The type of the animation to create.\n * Default is ANIMATIONTYPE_FLOAT\n * This cannot be changed after construction, so make sure to pass the right value.\n */\n animationType?: number | FlowGraphTypes;\n}\n\n/**\n * This block is responsible for interpolating between two values.\n * The babylon concept used is Animation, and it is the output of this block.\n *\n * Note that values will be parsed when the in connection is triggered. until then changing the value will not trigger a new interpolation.\n *\n * Internally this block uses the Animation class.\n *\n * Note that if the interpolation is already running a signal will be sent to stop the animation group running it.\n */\nexport class FlowGraphInterpolationBlock<T> extends FlowGraphBlock {\n /**\n * Input connection: The value to interpolate from.\n * Optional. If not provided, the current value will be used.\n * Note that if provided, every time the animation is created this value will be used!\n */\n public readonly initialValue: FlowGraphDataConnection<T>;\n\n /**\n * Input connection: The value to interpolate to.\n * Optional. This can also be set using the KeyFrames input!\n * If provided it will be set to the last keyframe value.\n */\n public readonly endValue: FlowGraphDataConnection<T>;\n\n /**\n * output connection: The animation that will be created when in is triggered.\n */\n public readonly animation: FlowGraphDataConnection<Animation | Animation[]>;\n\n /**\n * Input connection: An optional easing function to use for the interpolation.\n */\n public readonly easingFunction: FlowGraphDataConnection<EasingFunction>;\n\n /**\n * Input connection: The name of the property that will be set\n */\n public readonly propertyName: FlowGraphDataConnection<string | string[]>;\n\n /**\n * If provided, this function will be used to create the animation object(s).\n */\n public readonly customBuildAnimation: FlowGraphDataConnection<\n (target: any, propertname: any, context: FlowGraphContext) => (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation | Animation[]\n >;\n\n /**\n * The keyframes to interpolate between.\n * Each keyframe has a duration input and a value input.\n */\n public readonly keyFrames: {\n duration: FlowGraphDataConnection<number>;\n value: FlowGraphDataConnection<T>;\n }[] = [];\n\n constructor(config: IFlowGraphInterpolationBlockConfiguration = {}) {\n super(config);\n const type =\n typeof config?.animationType === \"string\"\n ? getRichTypeByFlowGraphType(config.animationType)\n : getRichTypeByAnimationType(config?.animationType ?? Constants.ANIMATIONTYPE_FLOAT);\n\n const numberOfKeyFrames = config?.keyFramesCount ?? 1;\n const duration = this.registerDataInput(`duration_0`, RichTypeNumber, 0);\n const value = this.registerDataInput(`value_0`, type);\n this.keyFrames.push({ duration, value });\n for (let i = 1; i < numberOfKeyFrames + 1; i++) {\n const duration = this.registerDataInput(`duration_${i}`, RichTypeNumber, i === numberOfKeyFrames ? config.duration : undefined);\n const value = this.registerDataInput(`value_${i}`, type);\n this.keyFrames.push({ duration, value });\n }\n this.initialValue = this.keyFrames[0].value;\n this.endValue = this.keyFrames[numberOfKeyFrames].value;\n this.easingFunction = this.registerDataInput(\"easingFunction\", RichTypeAny);\n this.animation = this.registerDataOutput(\"animation\", RichTypeAny);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeAny, config?.propertyName);\n this.customBuildAnimation = this.registerDataInput(\"customBuildAnimation\", RichTypeAny);\n }\n\n public override _updateOutputs(context: FlowGraphContext): void {\n const interpolationAnimations = context._getGlobalContextVariable(\"interpolationAnimations\", []) as number[];\n const propertyName = this.propertyName.getValue(context);\n const easingFunction = this.easingFunction.getValue(context);\n const animation = this._createAnimation(context, propertyName, easingFunction);\n // If an old animation exists, it will be ignored here.\n // This is because if the animation is running and they both have the same target, the old will be stopped.\n // This doesn't happen here, it happens in the play animation block.\n this.animation.setValue(animation, context);\n // to make sure no 2 interpolations are running on the same target, we will mark the animation in the context\n if (Array.isArray(animation)) {\n for (const anim of animation) {\n interpolationAnimations.push(anim.uniqueId);\n }\n } else {\n interpolationAnimations.push(animation.uniqueId);\n }\n context._setGlobalContextVariable(\"interpolationAnimations\", interpolationAnimations);\n }\n\n private _createAnimation(context: FlowGraphContext, propertyName: string | string[], easingFunction: EasingFunction): Animation | Animation[] {\n const type = this.initialValue.richType;\n const keys: { frame: number; value: T }[] = [];\n // add initial value\n const currentValue = this.initialValue.getValue(context) || type.defaultValue;\n keys.push({ frame: 0, value: currentValue });\n const numberOfKeyFrames = this.config?.numberOfKeyFrames ?? 1;\n for (let i = 1; i < numberOfKeyFrames + 1; i++) {\n const duration = this.keyFrames[i].duration?.getValue(context);\n let value = this.keyFrames[i].value?.getValue(context);\n if (i === numberOfKeyFrames - 1) {\n value = value || type.defaultValue;\n }\n if (duration !== undefined && value) {\n // convert duration to frames, based on 60 fps\n keys.push({ frame: duration * 60, value });\n }\n }\n const customBuildAnimation = this.customBuildAnimation.getValue(context);\n if (customBuildAnimation) {\n return customBuildAnimation(null, null, context)(keys, 60, type.animationType, easingFunction);\n }\n if (typeof propertyName === \"string\") {\n const animation = Animation.CreateAnimation(propertyName, type.animationType, 60, easingFunction);\n animation.setKeys(keys);\n return [animation];\n } else {\n const animations = propertyName.map((name) => {\n const animation = Animation.CreateAnimation(name, type.animationType, 60, easingFunction);\n animation.setKeys(keys);\n return animation;\n });\n return animations;\n }\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.ValueInterpolation;\n }\n}\n\nRegisterClass(FlowGraphBlockNames.ValueInterpolation, FlowGraphInterpolationBlock);\n\n// #L54P2C\n"]}
1
+ {"version":3,"file":"flowGraphInterpolationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,yCAA+B;AACnD,OAAO,EAAE,cAAc,EAAqC,mCAAsC;AAIlG,OAAO,EAAE,0BAA0B,EAAE,0BAA0B,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,uCAA0C;AACxJ,OAAO,EAAE,SAAS,EAAE,4CAAkC;AACtD,OAAO,EAAE,aAAa,EAAE,sCAA4B;AA+BpD;;;;;;;;;GASG;AACH,MAAM,OAAO,2BAA+B,SAAQ,cAAc;IA8C9D,YAAY,SAAoD,EAAE;QAC9D,KAAK,CAAC,MAAM,CAAC,CAAC;QAVlB;;;WAGG;QACa,cAAS,GAGnB,EAAE,CAAC;QAIL,MAAM,IAAI,GACN,OAAO,MAAM,EAAE,aAAa,KAAK,QAAQ;YACrC,CAAC,CAAC,0BAA0B,CAAC,MAAM,CAAC,aAAa,CAAC;YAClD,CAAC,CAAC,0BAA0B,CAAC,MAAM,EAAE,aAAa,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC;QAE7F,MAAM,iBAAiB,GA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AAE,EAAE,EAAE,cAAc,CAAC,CAAC;YAClG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACJ,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACzC,MAAM,SAAS,GAAG,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;gBAC1F,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACxB,OAAO,SAAS,CAAC;YACrB,CAAC,CAAC,CAAC;YACH,OAAO,UAAU,CAAC;QACtB,CAAC;IACL,CAAC;IAEe,YAAY;QACxB,kFAA8C;IAClD,CAAC;CACJ;AAED,aAAa,6EAAyC,2BAA2B,CAAC,CAAC;AAEnF,UAAU","sourcesContent":["import type { EasingFunction } from \"core/Animations/easing\";\nimport { Constants } from \"core/Engines/constants\";\nimport { FlowGraphBlock, type IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport type { FlowGraphTypes } from \"core/FlowGraph/flowGraphRichTypes\";\nimport { getRichTypeByAnimationType, getRichTypeByFlowGraphType, RichTypeAny, RichTypeNumber, RichTypeString } from \"core/FlowGraph/flowGraphRichTypes\";\nimport { Animation } from \"core/Animations/animation\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\n\n/**\n * Configuration for the interpolation block.\n */\nexport interface IFlowGraphInterpolationBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The number of keyframes to interpolate between.\n * Will default to 1 if not provided (i.e. from currentValue to a provided value in the time provided)\n */\n keyFramesCount?: number;\n\n /**\n * The duration of the interpolation.\n */\n duration?: number;\n\n /**\n * The name of the property that will be interpolated.\n */\n propertyName?: string | string[];\n\n /**\n * The type of the animation to create.\n * Default is ANIMATIONTYPE_FLOAT\n * This cannot be changed after construction, so make sure to pass the right value.\n */\n animationType?: number | FlowGraphTypes;\n}\n\n/**\n * This block is responsible for interpolating between two values.\n * The babylon concept used is Animation, and it is the output of this block.\n *\n * Note that values will be parsed when the in connection is triggered. until then changing the value will not trigger a new interpolation.\n *\n * Internally this block uses the Animation class.\n *\n * Note that if the interpolation is already running a signal will be sent to stop the animation group running it.\n */\nexport class FlowGraphInterpolationBlock<T> extends FlowGraphBlock {\n /**\n * Input connection: The value to interpolate from.\n * Optional. If not provided, the current value will be used.\n * Note that if provided, every time the animation is created this value will be used!\n */\n public readonly initialValue: FlowGraphDataConnection<T>;\n\n /**\n * Input connection: The value to interpolate to.\n * Optional. This can also be set using the KeyFrames input!\n * If provided it will be set to the last keyframe value.\n */\n public readonly endValue: FlowGraphDataConnection<T>;\n\n /**\n * output connection: The animation that will be created when in is triggered.\n */\n public readonly animation: FlowGraphDataConnection<Animation | Animation[]>;\n\n /**\n * Input connection: An optional easing function to use for the interpolation.\n */\n public readonly easingFunction: FlowGraphDataConnection<EasingFunction>;\n\n /**\n * Input connection: The name of the property that will be set\n */\n public readonly propertyName: FlowGraphDataConnection<string | string[]>;\n\n /**\n * If provided, this function will be used to create the animation object(s).\n */\n public readonly customBuildAnimation: FlowGraphDataConnection<\n (target: any, propertname: any, context: FlowGraphContext) => (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation | Animation[]\n >;\n\n /**\n * The keyframes to interpolate between.\n * Each keyframe has a duration input and a value input.\n */\n public readonly keyFrames: {\n duration: FlowGraphDataConnection<number>;\n value: FlowGraphDataConnection<T>;\n }[] = [];\n\n constructor(config: IFlowGraphInterpolationBlockConfiguration = {}) {\n super(config);\n const type =\n typeof config?.animationType === \"string\"\n ? getRichTypeByFlowGraphType(config.animationType)\n : getRichTypeByAnimationType(config?.animationType ?? Constants.ANIMATIONTYPE_FLOAT);\n\n const numberOfKeyFrames = config?.keyFramesCount ?? 1;\n const duration = this.registerDataInput(`duration_0`, RichTypeNumber, 0);\n const value = this.registerDataInput(`value_0`, type);\n this.keyFrames.push({ duration, value });\n for (let i = 1; i < numberOfKeyFrames + 1; i++) {\n const duration = this.registerDataInput(`duration_${i}`, RichTypeNumber, i === numberOfKeyFrames ? config.duration : undefined);\n const value = this.registerDataInput(`value_${i}`, type);\n this.keyFrames.push({ duration, value });\n }\n this.initialValue = this.keyFrames[0].value;\n this.endValue = this.keyFrames[numberOfKeyFrames].value;\n this.easingFunction = this.registerDataInput(\"easingFunction\", RichTypeAny);\n this.animation = this.registerDataOutput(\"animation\", RichTypeAny);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeString, config?.propertyName);\n this.customBuildAnimation = this.registerDataInput(\"customBuildAnimation\", RichTypeAny);\n }\n\n public override _updateOutputs(context: FlowGraphContext): void {\n const interpolationAnimations = context._getGlobalContextVariable(\"interpolationAnimations\", []) as number[];\n const propertyName = this.propertyName.getValue(context);\n const easingFunction = this.easingFunction.getValue(context);\n const animation = this._createAnimation(context, propertyName, easingFunction);\n // If an old animation exists, it will be ignored here.\n // This is because if the animation is running and they both have the same target, the old will be stopped.\n // This doesn't happen here, it happens in the play animation block.\n this.animation.setValue(animation, context);\n // to make sure no 2 interpolations are running on the same target, we will mark the animation in the context\n if (Array.isArray(animation)) {\n for (const anim of animation) {\n interpolationAnimations.push(anim.uniqueId);\n }\n } else {\n interpolationAnimations.push(animation.uniqueId);\n }\n context._setGlobalContextVariable(\"interpolationAnimations\", interpolationAnimations);\n }\n\n private _createAnimation(context: FlowGraphContext, propertyName: string | string[], easingFunction: EasingFunction): Animation | Animation[] {\n const type = this.initialValue.richType;\n const keys: { frame: number; value: T }[] = [];\n // add initial value\n const currentValue = this.initialValue.getValue(context) || type.defaultValue;\n keys.push({ frame: 0, value: currentValue });\n const numberOfKeyFrames = this.config?.numberOfKeyFrames ?? 1;\n for (let i = 1; i < numberOfKeyFrames + 1; i++) {\n const duration = this.keyFrames[i].duration?.getValue(context);\n let value = this.keyFrames[i].value?.getValue(context);\n if (i === numberOfKeyFrames - 1) {\n value = value || type.defaultValue;\n }\n if (duration !== undefined && value) {\n // convert duration to frames, based on 60 fps\n keys.push({ frame: duration * 60, value });\n }\n }\n const customBuildAnimation = this.customBuildAnimation.getValue(context);\n if (customBuildAnimation) {\n return customBuildAnimation(null, null, context)(keys, 60, type.animationType, easingFunction);\n }\n if (typeof propertyName === \"string\") {\n const animation = Animation.CreateAnimation(propertyName, type.animationType, 60, easingFunction);\n animation.setKeys(keys);\n return [animation];\n } else {\n const animations = propertyName.map((name) => {\n const animation = Animation.CreateAnimation(name, type.animationType, 60, easingFunction);\n animation.setKeys(keys);\n return animation;\n });\n return animations;\n }\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.ValueInterpolation;\n }\n}\n\nRegisterClass(FlowGraphBlockNames.ValueInterpolation, FlowGraphInterpolationBlock);\n\n// #L54P2C\n"]}
@@ -136,7 +136,13 @@ export class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {
136
136
  _stopAnimationGroup(context, animationGroup) {
137
137
  // stop, while skipping the on AnimationEndObservable to avoid the "done" signal
138
138
  animationGroup.stop(true);
139
- animationGroup.dispose();
139
+ // Only dispose animation groups that were internally created by this block
140
+ // (i.e. built from individual animations). Scene-provided animation groups
141
+ // must not be disposed as that removes them from the scene catalog and
142
+ // breaks the editor dropdown / re-use on replay.
143
+ if (animationGroup.name.startsWith("flowGraphAnimationGroup-")) {
144
+ animationGroup.dispose();
145
+ }
140
146
  this._removeFromCurrentlyRunning(context, animationGroup);
141
147
  }
142
148
  _removeFromCurrentlyRunning(context, animationGroup) {
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphPlayAnimationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.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AE,EAAE,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,6EAAyC;IAC7C,CAAC;CACJ;AAED,aAAa,wEAAoC,2BAA2B,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport type { Animation } from \"core/Animations/animation\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\n\r\n/**\r\n * @experimental\r\n * A block that plays an animation on an animatable object.\r\n */\r\nexport class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * Input connection: The speed of the animation.\r\n */\r\n public readonly speed: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Should the animation loop?\r\n * Not in glTF specs, but useful for the engine.\r\n */\r\n public readonly loop: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Input connection: The starting frame of the animation.\r\n */\r\n public readonly from: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: The ending frame of the animation.\r\n */\r\n public readonly to: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current frame of the animation.\r\n */\r\n public readonly currentFrame: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current time of the animation.\r\n */\r\n public readonly currentTime: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The animatable that is currently running.\r\n */\r\n public readonly currentAnimationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: Will be initialized if no animation group was provided in the configuration.\r\n */\r\n public readonly animationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: If provided this animation will be used. Priority will be given to the animation group input.\r\n */\r\n public readonly animation: FlowGraphDataConnection<Animation | Animation[]>;\r\n\r\n /**\r\n * Input connection: The target object that will be animated. If animation group is provided this input will be ignored.\r\n */\r\n public readonly object: FlowGraphDataConnection<any>;\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config?: IFlowGraphBlockConfiguration\r\n ) {\r\n super(config, [\"animationLoop\", \"animationEnd\", \"animationGroupLoop\"]);\r\n\r\n this.speed = this.registerDataInput(\"speed\", RichTypeNumber);\r\n this.loop = this.registerDataInput(\"loop\", RichTypeBoolean);\r\n this.from = this.registerDataInput(\"from\", RichTypeNumber, 0);\r\n this.to = this.registerDataInput(\"to\", RichTypeNumber);\r\n\r\n this.currentFrame = this.registerDataOutput(\"currentFrame\", RichTypeNumber);\r\n this.currentTime = this.registerDataOutput(\"currentTime\", RichTypeNumber);\r\n\r\n this.currentAnimationGroup = this.registerDataOutput(\"currentAnimationGroup\", RichTypeAny);\r\n this.animationGroup = this.registerDataInput(\"animationGroup\", RichTypeAny, config?.animationGroup);\r\n this.animation = this.registerDataInput(\"animation\", RichTypeAny);\r\n this.object = this.registerDataInput(\"object\", RichTypeAny);\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param context\r\n */\r\n public override _preparePendingTasks(context: FlowGraphContext): void {\r\n const ag = this.animationGroup.getValue(context);\r\n const animation = this.animation.getValue(context);\r\n if (!ag && !animation) {\r\n return this._reportError(context, \"No animation or animation group provided\");\r\n } else {\r\n // if an animation group was already created, dispose it and create a new one\r\n const currentAnimationGroup = this.currentAnimationGroup.getValue(context);\r\n if (currentAnimationGroup && currentAnimationGroup !== ag) {\r\n currentAnimationGroup.dispose();\r\n }\r\n let animationGroupToUse = ag;\r\n // check which animation to use. If no animationGroup was defined and an animation was provided, use the animation\r\n if (animation && !animationGroupToUse) {\r\n const target = this.object.getValue(context);\r\n if (!target) {\r\n return this._reportError(context, \"No target object provided\");\r\n }\r\n const animationsArray = Array.isArray(animation) ? animation : [animation];\r\n const name = animationsArray[0].name;\r\n animationGroupToUse = new AnimationGroup(\"flowGraphAnimationGroup-\" + name + \"-\" + target.name, context.configuration.scene);\r\n let isInterpolation = false;\r\n const interpolationAnimations = context._getGlobalContextVariable(\"interpolationAnimations\", []) as number[];\r\n for (const anim of animationsArray) {\r\n animationGroupToUse.addTargetedAnimation(anim, target);\r\n if (interpolationAnimations.indexOf(anim.uniqueId) !== -1) {\r\n isInterpolation = true;\r\n }\r\n }\r\n\r\n if (isInterpolation) {\r\n this._checkInterpolationDuplications(context, animationsArray, target);\r\n }\r\n }\r\n // not accepting 0\r\n const speed = this.speed.getValue(context) || 1;\r\n const from = this.from.getValue(context) ?? 0;\r\n // not accepting 0\r\n const to = this.to.getValue(context) || animationGroupToUse.to;\r\n const loop = !isFinite(to) || this.loop.getValue(context);\r\n this.currentAnimationGroup.setValue(animationGroupToUse, context);\r\n\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n // check if it already running\r\n if (currentlyRunningAnimationGroups.indexOf(animationGroupToUse.uniqueId) !== -1) {\r\n animationGroupToUse.stop();\r\n }\r\n try {\r\n animationGroupToUse.start(loop, speed, from, to);\r\n animationGroupToUse.onAnimationGroupEndObservable.add(() => this._onAnimationGroupEnd(context));\r\n animationGroupToUse.onAnimationEndObservable.add(() => this._eventsSignalOutputs[\"animationEnd\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationLoopObservable.add(() => this._eventsSignalOutputs[\"animationLoop\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationGroupLoopObservable.add(() => this._eventsSignalOutputs[\"animationGroupLoop\"]._activateSignal(context));\r\n currentlyRunningAnimationGroups.push(animationGroupToUse.uniqueId);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n } catch (e) {\r\n this._reportError(context, e);\r\n }\r\n }\r\n }\r\n\r\n protected override _reportError(context: FlowGraphContext, error: string | Error): void {\r\n super._reportError(context, error);\r\n this.currentFrame.setValue(-1, context);\r\n this.currentTime.setValue(-1, context);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _executeOnTick(_context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(_context);\r\n if (ag) {\r\n this.currentFrame.setValue(ag.getCurrentFrame(), _context);\r\n this.currentTime.setValue(ag.animatables[0]?.elapsedTime ?? 0, _context);\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n this._startPendingTasks(context);\r\n }\r\n\r\n private _onAnimationGroupEnd(context: FlowGraphContext) {\r\n this._removeFromCurrentlyRunning(context, this.currentAnimationGroup.getValue(context));\r\n this._resetAfterCanceled(context);\r\n this.done._activateSignal(context);\r\n }\r\n\r\n /**\r\n * The idea behind this function is to check every running animation group and check if the targeted animations it uses are interpolation animations.\r\n * If they are, we want to see that they don't collide with the current interpolation animations that are starting to play.\r\n * If they do, we want to stop the already-running animation group.\r\n * @internal\r\n */\r\n private _checkInterpolationDuplications(context: FlowGraphContext, animation: Animation[], target: any) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n for (const uniqueId of currentlyRunningAnimationGroups) {\r\n const ag = context.assetsContext.animationGroups.find((ag) => ag.uniqueId === uniqueId);\r\n if (ag) {\r\n for (const anim of ag.targetedAnimations) {\r\n for (const animToCheck of animation) {\r\n if (anim.animation.targetProperty === animToCheck.targetProperty && anim.target === target) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _stopAnimationGroup(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n // stop, while skipping the on AnimationEndObservable to avoid the \"done\" signal\r\n animationGroup.stop(true);\r\n animationGroup.dispose();\r\n this._removeFromCurrentlyRunning(context, animationGroup);\r\n }\r\n\r\n private _removeFromCurrentlyRunning(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n const idx = currentlyRunningAnimationGroups.indexOf(animationGroup.uniqueId);\r\n if (idx !== -1) {\r\n currentlyRunningAnimationGroups.splice(idx, 1);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Stop any currently running animations.\r\n */\r\n public override _cancelPendingTasks(context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(context);\r\n if (ag) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.PlayAnimation;\r\n }\r\n}\r\n\r\nRegisterClass(FlowGraphBlockNames.PlayAnimation, FlowGraphPlayAnimationBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphPlayAnimationBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,cAAc,EAAE,iDAAuC;AAIhE;;;GAGG;AACH,MAAM,OAAO,2BAA4B,SAAQ,4BAA4B;IAiDzE;IACI;;OAEG;IACa,MAAqC;QAErD,KAAK,CAAC,MAAM,EAAE,CAAC,eAAe,EAAE,cAAc,EAAE,oBAAoB,CAAC,CAAC,CAAC;QAFvD,WAAM,GAAN,MAAM,CAA+B;QAIrD,IAAI,CAAC,KAAK,GAAG,IA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,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,2EAA2E;QAC3E,2EAA2E;QAC3E,uEAAuE;QACvE,iDAAiD;QACjD,IAAI,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE,CAAC;YAC7D,cAAc,CAAC,OAAO,EAAE,CAAC;QAC7B,CAAC;QACD,IAAI,CAAC,2BAA2B,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAC9D,CAAC;IAEO,2BAA2B,CAAC,OAAyB,EAAE,cAA8B;QACzF,MAAM,+BAA+B,GAAG,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,EAAE,CAAa,CAAC;QAC7H,MAAM,GAAG,GAAG,+BAA+B,CAAC,OAAO,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAC7E,IAAI,GAAG,KAAK,CAAC,CAAC,EAAE,CAAC;YACb,+BAA+B,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;YAC/C,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,+BAA+B,CAAC,CAAC;QAC1G,CAAC;IACL,CAAC;IAED;;;OAGG;IACa,mBAAmB,CAAC,OAAyB;QACzD,MAAM,EAAE,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACxD,IAAI,EAAE,EAAE,CAAC;YACL,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;IACL,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,6EAAyC;IAC7C,CAAC;CACJ;AAED,aAAa,wEAAoC,2BAA2B,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../../flowGraphDataConnection\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../../flowGraphBlock\";\r\nimport { AnimationGroup } from \"core/Animations/animationGroup\";\r\nimport type { Animation } from \"core/Animations/animation\";\r\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\r\n\r\n/**\r\n * @experimental\r\n * A block that plays an animation on an animatable object.\r\n */\r\nexport class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * Input connection: The speed of the animation.\r\n */\r\n public readonly speed: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: Should the animation loop?\r\n * Not in glTF specs, but useful for the engine.\r\n */\r\n public readonly loop: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Input connection: The starting frame of the animation.\r\n */\r\n public readonly from: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: The ending frame of the animation.\r\n */\r\n public readonly to: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current frame of the animation.\r\n */\r\n public readonly currentFrame: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The current time of the animation.\r\n */\r\n public readonly currentTime: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output connection: The animatable that is currently running.\r\n */\r\n public readonly currentAnimationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: Will be initialized if no animation group was provided in the configuration.\r\n */\r\n public readonly animationGroup: FlowGraphDataConnection<AnimationGroup>;\r\n\r\n /**\r\n * Input: If provided this animation will be used. Priority will be given to the animation group input.\r\n */\r\n public readonly animation: FlowGraphDataConnection<Animation | Animation[]>;\r\n\r\n /**\r\n * Input connection: The target object that will be animated. If animation group is provided this input will be ignored.\r\n */\r\n public readonly object: FlowGraphDataConnection<any>;\r\n\r\n public constructor(\r\n /**\r\n * the configuration of the block\r\n */\r\n public override config?: IFlowGraphBlockConfiguration\r\n ) {\r\n super(config, [\"animationLoop\", \"animationEnd\", \"animationGroupLoop\"]);\r\n\r\n this.speed = this.registerDataInput(\"speed\", RichTypeNumber);\r\n this.loop = this.registerDataInput(\"loop\", RichTypeBoolean);\r\n this.from = this.registerDataInput(\"from\", RichTypeNumber, 0);\r\n this.to = this.registerDataInput(\"to\", RichTypeNumber);\r\n\r\n this.currentFrame = this.registerDataOutput(\"currentFrame\", RichTypeNumber);\r\n this.currentTime = this.registerDataOutput(\"currentTime\", RichTypeNumber);\r\n\r\n this.currentAnimationGroup = this.registerDataOutput(\"currentAnimationGroup\", RichTypeAny);\r\n this.animationGroup = this.registerDataInput(\"animationGroup\", RichTypeAny, config?.animationGroup);\r\n this.animation = this.registerDataInput(\"animation\", RichTypeAny);\r\n this.object = this.registerDataInput(\"object\", RichTypeAny);\r\n }\r\n\r\n /**\r\n * @internal\r\n * @param context\r\n */\r\n public override _preparePendingTasks(context: FlowGraphContext): void {\r\n const ag = this.animationGroup.getValue(context);\r\n const animation = this.animation.getValue(context);\r\n if (!ag && !animation) {\r\n return this._reportError(context, \"No animation or animation group provided\");\r\n } else {\r\n // if an animation group was already created, dispose it and create a new one\r\n const currentAnimationGroup = this.currentAnimationGroup.getValue(context);\r\n if (currentAnimationGroup && currentAnimationGroup !== ag) {\r\n currentAnimationGroup.dispose();\r\n }\r\n let animationGroupToUse = ag;\r\n // check which animation to use. If no animationGroup was defined and an animation was provided, use the animation\r\n if (animation && !animationGroupToUse) {\r\n const target = this.object.getValue(context);\r\n if (!target) {\r\n return this._reportError(context, \"No target object provided\");\r\n }\r\n const animationsArray = Array.isArray(animation) ? animation : [animation];\r\n const name = animationsArray[0].name;\r\n animationGroupToUse = new AnimationGroup(\"flowGraphAnimationGroup-\" + name + \"-\" + target.name, context.configuration.scene);\r\n let isInterpolation = false;\r\n const interpolationAnimations = context._getGlobalContextVariable(\"interpolationAnimations\", []) as number[];\r\n for (const anim of animationsArray) {\r\n animationGroupToUse.addTargetedAnimation(anim, target);\r\n if (interpolationAnimations.indexOf(anim.uniqueId) !== -1) {\r\n isInterpolation = true;\r\n }\r\n }\r\n\r\n if (isInterpolation) {\r\n this._checkInterpolationDuplications(context, animationsArray, target);\r\n }\r\n }\r\n // not accepting 0\r\n const speed = this.speed.getValue(context) || 1;\r\n const from = this.from.getValue(context) ?? 0;\r\n // not accepting 0\r\n const to = this.to.getValue(context) || animationGroupToUse.to;\r\n const loop = !isFinite(to) || this.loop.getValue(context);\r\n this.currentAnimationGroup.setValue(animationGroupToUse, context);\r\n\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n // check if it already running\r\n if (currentlyRunningAnimationGroups.indexOf(animationGroupToUse.uniqueId) !== -1) {\r\n animationGroupToUse.stop();\r\n }\r\n try {\r\n animationGroupToUse.start(loop, speed, from, to);\r\n animationGroupToUse.onAnimationGroupEndObservable.add(() => this._onAnimationGroupEnd(context));\r\n animationGroupToUse.onAnimationEndObservable.add(() => this._eventsSignalOutputs[\"animationEnd\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationLoopObservable.add(() => this._eventsSignalOutputs[\"animationLoop\"]._activateSignal(context));\r\n animationGroupToUse.onAnimationGroupLoopObservable.add(() => this._eventsSignalOutputs[\"animationGroupLoop\"]._activateSignal(context));\r\n currentlyRunningAnimationGroups.push(animationGroupToUse.uniqueId);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n } catch (e) {\r\n this._reportError(context, e);\r\n }\r\n }\r\n }\r\n\r\n protected override _reportError(context: FlowGraphContext, error: string | Error): void {\r\n super._reportError(context, error);\r\n this.currentFrame.setValue(-1, context);\r\n this.currentTime.setValue(-1, context);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _executeOnTick(_context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(_context);\r\n if (ag) {\r\n this.currentFrame.setValue(ag.getCurrentFrame(), _context);\r\n this.currentTime.setValue(ag.animatables[0]?.elapsedTime ?? 0, _context);\r\n }\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n this._startPendingTasks(context);\r\n }\r\n\r\n private _onAnimationGroupEnd(context: FlowGraphContext) {\r\n this._removeFromCurrentlyRunning(context, this.currentAnimationGroup.getValue(context));\r\n this._resetAfterCanceled(context);\r\n this.done._activateSignal(context);\r\n }\r\n\r\n /**\r\n * The idea behind this function is to check every running animation group and check if the targeted animations it uses are interpolation animations.\r\n * If they are, we want to see that they don't collide with the current interpolation animations that are starting to play.\r\n * If they do, we want to stop the already-running animation group.\r\n * @internal\r\n */\r\n private _checkInterpolationDuplications(context: FlowGraphContext, animation: Animation[], target: any) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n for (const uniqueId of currentlyRunningAnimationGroups) {\r\n const ag = context.assetsContext.animationGroups.find((ag) => ag.uniqueId === uniqueId);\r\n if (ag) {\r\n for (const anim of ag.targetedAnimations) {\r\n for (const animToCheck of animation) {\r\n if (anim.animation.targetProperty === animToCheck.targetProperty && anim.target === target) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private _stopAnimationGroup(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n // stop, while skipping the on AnimationEndObservable to avoid the \"done\" signal\r\n animationGroup.stop(true);\r\n // Only dispose animation groups that were internally created by this block\r\n // (i.e. built from individual animations). Scene-provided animation groups\r\n // must not be disposed as that removes them from the scene catalog and\r\n // breaks the editor dropdown / re-use on replay.\r\n if (animationGroup.name.startsWith(\"flowGraphAnimationGroup-\")) {\r\n animationGroup.dispose();\r\n }\r\n this._removeFromCurrentlyRunning(context, animationGroup);\r\n }\r\n\r\n private _removeFromCurrentlyRunning(context: FlowGraphContext, animationGroup: AnimationGroup) {\r\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\r\n const idx = currentlyRunningAnimationGroups.indexOf(animationGroup.uniqueId);\r\n if (idx !== -1) {\r\n currentlyRunningAnimationGroups.splice(idx, 1);\r\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Stop any currently running animations.\r\n */\r\n public override _cancelPendingTasks(context: FlowGraphContext): void {\r\n const ag = this.currentAnimationGroup.getValue(context);\r\n if (ag) {\r\n this._stopAnimationGroup(context, ag);\r\n }\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.PlayAnimation;\r\n }\r\n}\r\n\r\nRegisterClass(FlowGraphBlockNames.PlayAnimation, FlowGraphPlayAnimationBlock);\r\n"]}
@@ -27,6 +27,10 @@ export declare class FlowGraphConsoleLogBlock extends FlowGraphExecutionBlockWit
27
27
  * Input connection: The log type.
28
28
  */
29
29
  readonly logType: FlowGraphDataConnection<"log" | "warn" | "error">;
30
+ /**
31
+ * Creates a new console log block.
32
+ * @param config optional configuration
33
+ */
30
34
  constructor(config?: IFlowGraphConsoleLogBlockConfiguration);
31
35
  /**
32
36
  * @internal
@@ -1,15 +1,19 @@
1
1
  import { FlowGraphExecutionBlockWithOutSignal } from "../../flowGraphExecutionBlockWithOutSignal.js";
2
- import { RichTypeAny } from "../../flowGraphRichTypes.js";
2
+ import { RichTypeAny, RichTypeString } from "../../flowGraphRichTypes.js";
3
3
  import { RegisterClass } from "../../../Misc/typeStore.js";
4
4
  import { Logger } from "../../../Misc/logger.js";
5
5
  /**
6
6
  * Block that logs a message to the console.
7
7
  */
8
8
  export class FlowGraphConsoleLogBlock extends FlowGraphExecutionBlockWithOutSignal {
9
+ /**
10
+ * Creates a new console log block.
11
+ * @param config optional configuration
12
+ */
9
13
  constructor(config) {
10
14
  super(config);
11
15
  this.message = this.registerDataInput("message", RichTypeAny);
12
- this.logType = this.registerDataInput("logType", RichTypeAny, "log");
16
+ this.logType = this.registerDataInput("logType", RichTypeString, "log");
13
17
  if (config?.messageTemplate) {
14
18
  const matches = this._getTemplateMatches(config.messageTemplate);
15
19
  for (const match of matches) {
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphConsoleLogBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oCAAoC,EAAE,MAAM,4CAA4C,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,gCAAyB;AAgB1C;;GAEG;AACH,MAAM,OAAO,wBAAyB,SAAQ,oCAAoC;IAY9E,YAAmB,MAA+C;QAC9D,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;QACrE,IAAI,MAAM,EAAE,eAAe,EAAE,CAAC;YAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;YACjE,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC1B,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;YAC/C,CAAC;QACL,CAAC;IACL,CAAC;IAED;;OAEG;IACI,QAAQ,CAAC,OAAyB;QACrC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,YAAY,GAAG,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,SAAS,KAAK,MAAM,EAAE,CAAC;YACvB,M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CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YAC7C,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3B,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ;AAED,aAAa,kEAAiC,wBAAwB,CAAC,CAAC","sourcesContent":["import type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../flowGraphExecutionBlockWithOutSignal\";\r\nimport { RichTypeAny } from \"../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\r\n\r\n/**\r\n * Configuration for the console log block.\r\n */\r\nexport interface IFlowGraphConsoleLogBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * An optional message template to use for the log message.\r\n * If provided, the template can hold placeholders for the message value.\r\n * For example, if the template is \"The message is: \\{data\\}\", a new data input called \"data\" will be created.\r\n * The value of the message input will be used to replace the placeholder in the template.\r\n */\r\n messageTemplate?: string;\r\n}\r\n\r\n/**\r\n * Block that logs a message to the console.\r\n */\r\nexport class FlowGraphConsoleLogBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * Input connection: The message to log.\r\n * Will be ignored if a message template is provided.\r\n */\r\n public readonly message: FlowGraphDataConnection<any>;\r\n\r\n /**\r\n * Input connection: The log type.\r\n */\r\n public readonly logType: FlowGraphDataConnection<\"log\" | \"warn\" | \"error\">;\r\n\r\n public constructor(config?: IFlowGraphConsoleLogBlockConfiguration) {\r\n super(config);\r\n this.message = this.registerDataInput(\"message\", RichTypeAny);\r\n this.logType = this.registerDataInput(\"logType\", RichTypeAny, \"log\");\r\n if (config?.messageTemplate) {\r\n const matches = this._getTemplateMatches(config.messageTemplate);\r\n for (const match of matches) {\r\n this.registerDataInput(match, RichTypeAny);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _execute(context: FlowGraphContext): void {\r\n const typeValue = this.logType.getValue(context);\r\n const messageValue = this._getMessageValue(context);\r\n if (typeValue === \"warn\") {\r\n Logger.Warn(messageValue);\r\n } else if (typeValue === \"error\") {\r\n Logger.Error(messageValue);\r\n } else {\r\n Logger.Log(messageValue);\r\n }\r\n // activate the output flow block\r\n this.out._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.ConsoleLog;\r\n }\r\n\r\n private _getMessageValue(context: FlowGraphContext): string {\r\n if (this.config?.messageTemplate) {\r\n let template: string = this.config.messageTemplate;\r\n const matches = this._getTemplateMatches(template);\r\n for (const match of matches) {\r\n const value = this.getDataInput(match)?.getValue(context);\r\n if (value !== undefined) {\r\n // replace all\r\n template = template.replace(new RegExp(`\\\\{${match}\\\\}`, \"g\"), value.toString());\r\n }\r\n }\r\n return template;\r\n } else {\r\n return this.message.getValue(context);\r\n }\r\n }\r\n\r\n private _getTemplateMatches(template: string): string[] {\r\n const regex = /\\{([^}]+)\\}/g;\r\n const matches: string[] = [];\r\n let match;\r\n while ((match = regex.exec(template)) !== null) {\r\n matches.push(match[1]);\r\n }\r\n return matches;\r\n }\r\n}\r\n\r\nRegisterClass(FlowGraphBlockNames.ConsoleLog, FlowGraphConsoleLogBlock);\r\n"]}
1
+ {"version":3,"file":"flowGraphConsoleLogBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oCAAoC,EAAE,MAAM,4CAA4C,CAAC;AAClG,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,0BAA0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from \"../../flowGraphDataConnection\";\r\nimport { FlowGraphExecutionBlockWithOutSignal } from \"../../flowGraphExecutionBlockWithOutSignal\";\r\nimport { RichTypeAny, RichTypeString } from \"../../flowGraphRichTypes\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\r\n\r\n/**\r\n * Configuration for the console log block.\r\n */\r\nexport interface IFlowGraphConsoleLogBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /**\r\n * An optional message template to use for the log message.\r\n * If provided, the template can hold placeholders for the message value.\r\n * For example, if the template is \"The message is: \\{data\\}\", a new data input called \"data\" will be created.\r\n * The value of the message input will be used to replace the placeholder in the template.\r\n */\r\n messageTemplate?: string;\r\n}\r\n\r\n/**\r\n * Block that logs a message to the console.\r\n */\r\nexport class FlowGraphConsoleLogBlock extends FlowGraphExecutionBlockWithOutSignal {\r\n /**\r\n * Input connection: The message to log.\r\n * Will be ignored if a message template is provided.\r\n */\r\n public readonly message: FlowGraphDataConnection<any>;\r\n\r\n /**\r\n * Input connection: The log type.\r\n */\r\n public readonly logType: FlowGraphDataConnection<\"log\" | \"warn\" | \"error\">;\r\n\r\n /**\r\n * Creates a new console log block.\r\n * @param config optional configuration\r\n */\r\n public constructor(config?: IFlowGraphConsoleLogBlockConfiguration) {\r\n super(config);\r\n this.message = this.registerDataInput(\"message\", RichTypeAny);\r\n this.logType = this.registerDataInput(\"logType\", RichTypeString, \"log\") as FlowGraphDataConnection<\"log\" | \"warn\" | \"error\">;\r\n if (config?.messageTemplate) {\r\n const matches = this._getTemplateMatches(config.messageTemplate);\r\n for (const match of matches) {\r\n this.registerDataInput(match, RichTypeAny);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _execute(context: FlowGraphContext): void {\r\n const typeValue = this.logType.getValue(context);\r\n const messageValue = this._getMessageValue(context);\r\n if (typeValue === \"warn\") {\r\n Logger.Warn(messageValue);\r\n } else if (typeValue === \"error\") {\r\n Logger.Error(messageValue);\r\n } else {\r\n Logger.Log(messageValue);\r\n }\r\n // activate the output flow block\r\n this.out._activateSignal(context);\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.ConsoleLog;\r\n }\r\n\r\n private _getMessageValue(context: FlowGraphContext): string {\r\n if (this.config?.messageTemplate) {\r\n let template: string = this.config.messageTemplate;\r\n const matches = this._getTemplateMatches(template);\r\n for (const match of matches) {\r\n const value = this.getDataInput(match)?.getValue(context);\r\n if (value !== undefined) {\r\n // replace all\r\n template = template.replace(new RegExp(`\\\\{${match}\\\\}`, \"g\"), value.toString());\r\n }\r\n }\r\n return template;\r\n } else {\r\n return this.message.getValue(context);\r\n }\r\n }\r\n\r\n private _getTemplateMatches(template: string): string[] {\r\n const regex = /\\{([^}]+)\\}/g;\r\n const matches: string[] = [];\r\n let match;\r\n while ((match = regex.exec(template)) !== null) {\r\n matches.push(match[1]);\r\n }\r\n return matches;\r\n }\r\n}\r\n\r\nRegisterClass(FlowGraphBlockNames.ConsoleLog, FlowGraphConsoleLogBlock);\r\n"]}
@@ -1,5 +1,5 @@
1
1
  import { FlowGraphExecutionBlockWithOutSignal } from "../../flowGraphExecutionBlockWithOutSignal.js";
2
- import { RichTypeAny } from "../../flowGraphRichTypes.js";
2
+ import { RichTypeAny, RichTypeString } from "../../flowGraphRichTypes.js";
3
3
  import { RegisterClass } from "../../../Misc/typeStore.js";
4
4
  /**
5
5
  * This block will set a property on a given target asset.
@@ -21,7 +21,7 @@ export class FlowGraphSetPropertyBlock extends FlowGraphExecutionBlockWithOutSig
21
21
  this.config = config;
22
22
  this.object = this.registerDataInput("object", RichTypeAny, config.target);
23
23
  this.value = this.registerDataInput("value", RichTypeAny);
24
- this.propertyName = this.registerDataInput("propertyName", RichTypeAny, config.propertyName);
24
+ this.propertyName = this.registerDataInput("propertyName", RichTypeString, config.propertyName);
25
25
  this.customSetFunction = this.registerDataInput("customSetFunction", RichTypeAny);
26
26
  }
27
27
  _execute(context, _callingSignal) {
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphSetPropertyBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oCAAoC,EAAE,sDAA4D;AAC3G,OAAO,EAAE,WAAW,EAAE,oCAA0C;AAEhE,OAAO,EAAE,aAAa,EAAE,mCAA4B;AAepD;;;;;;;;;GASG;AACH,MAAM,OAAO,yBAAuE,SAAQ,oCAAoC;IAsB5H;IACI;;OAEG;IACa,MAAkD;QAElE,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAA4C;QAGlE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3E,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QAC1D,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,WAAW,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;QAC7F,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;IACtF,CAAC;IACe,QAAQ,CAAC,OAAyB,EAAE,cAAyC;QACzF,IAAI,CAAC;YACD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC7C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC3C,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAA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AAG,+BAA+B,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;wBAChE,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC;4BACf,+BAA+B,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;4BACjD,OAAO,CAAC,yBAAyB,CAAC,iCAAiC,EAAE,+BAA+B,CAAC,CAAC;wBAC1G,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAEO,iBAAiB,CAAC,MAAoB,EAAE,YAAoB,EAAE,KAAQ;QAC1E,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,GAAG,GAAG,MAAa,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC1B,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACnB,CAAC;YACD,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACvC,CAAC;IAEe,YAAY;QACxB,yEAAuC;IAC3C,CAAC;CACJ;AAED,aAAa,oEAAkC,yBAAyB,CAAC,CAAC","sourcesContent":["import type { AssetType, FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"core/FlowGraph/flowGraphExecutionBlockWithOutSignal\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { FlowGraphSignalConnection } from \"core/FlowGraph/flowGraphSignalConnection\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\n\nexport interface IFlowGraphSetPropertyBlockConfiguration<O extends FlowGraphAssetType> {\n /**\n * The name of the property that will be set\n */\n propertyName?: string;\n\n /**\n * The target asset from which the property will be retrieved\n */\n target?: AssetType<O>;\n}\n\n/**\n * This block will set a property on a given target asset.\n * The property name can include dots (\".\"), which will be interpreted as a path to the property.\n * The target asset is an input and can be changed at any time.\n * The value of the property is an input and can be changed at any time.\n *\n * For example, with an input of a mesh asset, the property name \"position.x\" will set the x component of the position of the mesh.\n *\n * Note that it is recommended to input the object on which you are working on (i.e. a material) than providing a mesh and then getting the material from it.\n */\nexport class FlowGraphSetPropertyBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphExecutionBlockWithOutSignal {\n /**\n * Input connection: The value to set on the property.\n */\n public readonly value: FlowGraphDataConnection<P>;\n\n /**\n * Input connection: The target asset from which the property will be retrieved\n */\n public readonly object: FlowGraphDataConnection<AssetType<O>>;\n\n /**\n * Input connection: The name of the property that will be set\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Input connection: A function that can be used to set the value of the property.\n * If set it will be used instead of the default set function.\n */\n public readonly customSetFunction: FlowGraphDataConnection<(target: AssetType<O>, propertyName: string, value: P, context: FlowGraphContext) => void>;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphSetPropertyBlockConfiguration<O>\n ) {\n super(config);\n this.object = this.registerDataInput(\"object\", RichTypeAny, config.target);\n this.value = this.registerDataInput(\"value\", RichTypeAny);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeAny, config.propertyName);\n this.customSetFunction = this.registerDataInput(\"customSetFunction\", RichTypeAny);\n }\n public override _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\n try {\n const target = this.object.getValue(context);\n const value = this.value.getValue(context);\n const propertyName = this.propertyName.getValue(context);\n\n this._stopRunningAnimations(context, target, propertyName);\n\n const setFunction = this.customSetFunction.getValue(context);\n if (setFunction) {\n setFunction(target, propertyName, value, context);\n } else {\n this._setPropertyValue(target, propertyName, value);\n }\n } catch (e) {\n this._reportError(context, e);\n }\n this.out._activateSignal(context);\n }\n\n private _stopRunningAnimations(context: FlowGraphContext, target: any, propertyName: string) {\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\n for (const uniqueId of currentlyRunningAnimationGroups) {\n const animationGroup = context.assetsContext.animationGroups.find((animationGroup) => animationGroup.uniqueId === uniqueId);\n if (animationGroup) {\n for (const targetedAnimations of animationGroup.targetedAnimations) {\n if (targetedAnimations.target === target && targetedAnimations.animation.targetProperty === propertyName) {\n animationGroup.stop(true);\n animationGroup.dispose();\n\n const index = currentlyRunningAnimationGroups.indexOf(uniqueId);\n if (index !== -1) {\n currentlyRunningAnimationGroups.splice(index, 1);\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\n }\n }\n }\n }\n }\n }\n\n private _setPropertyValue(target: AssetType<O>, propertyName: string, value: P): void {\n const path = propertyName.split(\".\");\n let obj = target as any;\n for (let i = 0; i < path.length - 1; i++) {\n const prop = path[i];\n if (obj[prop] === undefined) {\n obj[prop] = {};\n }\n obj = obj[prop];\n }\n obj[path[path.length - 1]] = value;\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.SetProperty;\n }\n}\n\nRegisterClass(FlowGraphBlockNames.SetProperty, FlowGraphSetPropertyBlock);\n"]}
1
+ {"version":3,"file":"flowGraphSetPropertyBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oCAAoC,EAAE,sDAA4D;AAC3G,OAAO,EAAE,WAAW,EAAE,cAAc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AAoB,EAAE,YAAoB,EAAE,KAAQ;QAC1E,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,GAAG,GAAG,MAAa,CAAC;QACxB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACvC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC1B,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACnB,CAAC;YACD,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC;IACvC,CAAC;IAEe,YAAY;QACxB,yEAAuC;IAC3C,CAAC;CACJ;AAED,aAAa,oEAAkC,yBAAyB,CAAC,CAAC","sourcesContent":["import type { AssetType, FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { FlowGraphExecutionBlockWithOutSignal } from \"core/FlowGraph/flowGraphExecutionBlockWithOutSignal\";\nimport { RichTypeAny, RichTypeString } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { FlowGraphSignalConnection } from \"core/FlowGraph/flowGraphSignalConnection\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\n\nexport interface IFlowGraphSetPropertyBlockConfiguration<O extends FlowGraphAssetType> {\n /**\n * The name of the property that will be set\n */\n propertyName?: string;\n\n /**\n * The target asset from which the property will be retrieved\n */\n target?: AssetType<O>;\n}\n\n/**\n * This block will set a property on a given target asset.\n * The property name can include dots (\".\"), which will be interpreted as a path to the property.\n * The target asset is an input and can be changed at any time.\n * The value of the property is an input and can be changed at any time.\n *\n * For example, with an input of a mesh asset, the property name \"position.x\" will set the x component of the position of the mesh.\n *\n * Note that it is recommended to input the object on which you are working on (i.e. a material) than providing a mesh and then getting the material from it.\n */\nexport class FlowGraphSetPropertyBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphExecutionBlockWithOutSignal {\n /**\n * Input connection: The value to set on the property.\n */\n public readonly value: FlowGraphDataConnection<P>;\n\n /**\n * Input connection: The target asset from which the property will be retrieved\n */\n public readonly object: FlowGraphDataConnection<AssetType<O>>;\n\n /**\n * Input connection: The name of the property that will be set\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Input connection: A function that can be used to set the value of the property.\n * If set it will be used instead of the default set function.\n */\n public readonly customSetFunction: FlowGraphDataConnection<(target: AssetType<O>, propertyName: string, value: P, context: FlowGraphContext) => void>;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphSetPropertyBlockConfiguration<O>\n ) {\n super(config);\n this.object = this.registerDataInput(\"object\", RichTypeAny, config.target);\n this.value = this.registerDataInput(\"value\", RichTypeAny);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeString, config.propertyName);\n this.customSetFunction = this.registerDataInput(\"customSetFunction\", RichTypeAny);\n }\n public override _execute(context: FlowGraphContext, _callingSignal: FlowGraphSignalConnection): void {\n try {\n const target = this.object.getValue(context);\n const value = this.value.getValue(context);\n const propertyName = this.propertyName.getValue(context);\n\n this._stopRunningAnimations(context, target, propertyName);\n\n const setFunction = this.customSetFunction.getValue(context);\n if (setFunction) {\n setFunction(target, propertyName, value, context);\n } else {\n this._setPropertyValue(target, propertyName, value);\n }\n } catch (e) {\n this._reportError(context, e);\n }\n this.out._activateSignal(context);\n }\n\n private _stopRunningAnimations(context: FlowGraphContext, target: any, propertyName: string) {\n const currentlyRunningAnimationGroups = context._getGlobalContextVariable(\"currentlyRunningAnimationGroups\", []) as number[];\n for (const uniqueId of currentlyRunningAnimationGroups) {\n const animationGroup = context.assetsContext.animationGroups.find((animationGroup) => animationGroup.uniqueId === uniqueId);\n if (animationGroup) {\n for (const targetedAnimations of animationGroup.targetedAnimations) {\n if (targetedAnimations.target === target && targetedAnimations.animation.targetProperty === propertyName) {\n animationGroup.stop(true);\n animationGroup.dispose();\n\n const index = currentlyRunningAnimationGroups.indexOf(uniqueId);\n if (index !== -1) {\n currentlyRunningAnimationGroups.splice(index, 1);\n context._setGlobalContextVariable(\"currentlyRunningAnimationGroups\", currentlyRunningAnimationGroups);\n }\n }\n }\n }\n }\n }\n\n private _setPropertyValue(target: AssetType<O>, propertyName: string, value: P): void {\n const path = propertyName.split(\".\");\n let obj = target as any;\n for (let i = 0; i < path.length - 1; i++) {\n const prop = path[i];\n if (obj[prop] === undefined) {\n obj[prop] = {};\n }\n obj = obj[prop];\n }\n obj[path[path.length - 1]] = value;\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.SetProperty;\n }\n}\n\nRegisterClass(FlowGraphBlockNames.SetProperty, FlowGraphSetPropertyBlock);\n"]}
@@ -7,10 +7,6 @@ import { RichTypeAny } from "../../flowGraphRichTypes.js";
7
7
  export class FlowGraphSetVariableBlock extends FlowGraphExecutionBlockWithOutSignal {
8
8
  constructor(config) {
9
9
  super(config);
10
- // check if the variable is defined
11
- if (!config.variable && !config.variables) {
12
- throw new Error("FlowGraphSetVariableBlock: variable/variables is not defined");
13
- }
14
10
  // check if the variable is an array
15
11
  if (config.variables && config.variable) {
16
12
  throw new Error("FlowGraphSetVariableBlock: variable and variables are both defined");