@babylonjs/core 7.52.2 → 7.53.0

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 (211) hide show
  1. package/AudioV2/abstractAudio/abstractAudioBus.d.ts +11 -0
  2. package/AudioV2/abstractAudio/abstractAudioBus.js +10 -0
  3. package/AudioV2/abstractAudio/abstractAudioBus.js.map +1 -1
  4. package/AudioV2/abstractAudio/abstractSound.d.ts +10 -3
  5. package/AudioV2/abstractAudio/abstractSound.js +10 -0
  6. package/AudioV2/abstractAudio/abstractSound.js.map +1 -1
  7. package/AudioV2/abstractAudio/audioBus.d.ts +4 -4
  8. package/AudioV2/abstractAudio/audioBus.js.map +1 -1
  9. package/AudioV2/abstractAudio/mainAudioBus.d.ts +2 -2
  10. package/AudioV2/abstractAudio/mainAudioBus.js.map +1 -1
  11. package/AudioV2/abstractAudio/staticSound.d.ts +5 -5
  12. package/AudioV2/abstractAudio/staticSound.js +3 -3
  13. package/AudioV2/abstractAudio/staticSound.js.map +1 -1
  14. package/AudioV2/abstractAudio/streamingSound.d.ts +1 -1
  15. package/AudioV2/abstractAudio/streamingSound.js +1 -1
  16. package/AudioV2/abstractAudio/streamingSound.js.map +1 -1
  17. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.d.ts +30 -9
  18. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js +52 -26
  19. package/AudioV2/abstractAudio/subNodes/abstractAudioSubGraph.js.map +1 -1
  20. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.d.ts +24 -0
  21. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.js +30 -0
  22. package/AudioV2/abstractAudio/subNodes/audioAnalyzerSubNode.js.map +1 -0
  23. package/AudioV2/abstractAudio/subNodes/audioSubNode.d.ts +1 -0
  24. package/AudioV2/abstractAudio/subNodes/audioSubNode.js +1 -0
  25. package/AudioV2/abstractAudio/subNodes/audioSubNode.js.map +1 -1
  26. package/AudioV2/abstractAudio/subNodes/stereoAudioSubNode.js.map +1 -1
  27. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.d.ts +86 -0
  28. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.js +29 -0
  29. package/AudioV2/abstractAudio/subProperties/abstractAudioAnalyzer.js.map +1 -0
  30. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.d.ts +35 -0
  31. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js +96 -0
  32. package/AudioV2/abstractAudio/subProperties/audioAnalyzer.js.map +1 -0
  33. package/AudioV2/abstractAudio/subProperties/index.d.ts +1 -0
  34. package/AudioV2/abstractAudio/subProperties/index.js +1 -0
  35. package/AudioV2/abstractAudio/subProperties/index.js.map +1 -1
  36. package/AudioV2/abstractAudio/subProperties/spatialAudio.js +10 -5
  37. package/AudioV2/abstractAudio/subProperties/spatialAudio.js.map +1 -1
  38. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.d.ts +37 -0
  39. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js +85 -0
  40. package/AudioV2/webAudio/subNodes/webAudioAnalyzerSubNode.js.map +1 -0
  41. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.d.ts +5 -3
  42. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js +25 -2
  43. package/AudioV2/webAudio/subNodes/webAudioBaseSubGraph.js.map +1 -1
  44. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.d.ts +2 -1
  45. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js +33 -18
  46. package/AudioV2/webAudio/subNodes/webAudioBusAndSoundSubGraph.js.map +1 -1
  47. package/Engines/WebGPU/webgpuTextureManager.d.ts +0 -1
  48. package/Engines/WebGPU/webgpuTextureManager.js +2 -57
  49. package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
  50. package/Engines/abstractEngine.d.ts +6 -0
  51. package/Engines/abstractEngine.js +3 -3
  52. package/Engines/abstractEngine.js.map +1 -1
  53. package/Engines/engine.common.js +4 -0
  54. package/Engines/engine.common.js.map +1 -1
  55. package/Engines/nativeEngine.d.ts +1 -0
  56. package/Engines/nativeEngine.js +3 -0
  57. package/Engines/nativeEngine.js.map +1 -1
  58. package/Engines/nullEngine.d.ts +1 -0
  59. package/Engines/nullEngine.js +1 -0
  60. package/Engines/nullEngine.js.map +1 -1
  61. package/Engines/thinEngine.d.ts +1 -0
  62. package/Engines/thinEngine.js +7 -4
  63. package/Engines/thinEngine.js.map +1 -1
  64. package/Engines/webgpuEngine.d.ts +2 -1
  65. package/Engines/webgpuEngine.js +12 -9
  66. package/Engines/webgpuEngine.js.map +1 -1
  67. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.d.ts +3 -12
  68. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js +16 -36
  69. package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.js.map +1 -1
  70. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.d.ts +5 -1
  71. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +17 -4
  72. package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
  73. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.d.ts +48 -0
  74. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js +54 -0
  75. package/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.js.map +1 -0
  76. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.d.ts +3 -11
  77. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js +5 -14
  78. package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
  79. package/FlowGraph/Blocks/Data/index.d.ts +1 -0
  80. package/FlowGraph/Blocks/Data/index.js +1 -0
  81. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  82. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +1 -0
  83. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +19 -13
  84. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  85. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +3 -5
  86. package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
  87. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js +1 -1
  88. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.js.map +1 -1
  89. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js +2 -4
  90. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSetDelayBlock.js.map +1 -1
  91. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +1 -1
  92. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
  93. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +1 -2
  94. package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
  95. package/FlowGraph/Blocks/flowGraphBlockFactory.js +2 -0
  96. package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
  97. package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +2 -1
  98. package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
  99. package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
  100. package/FlowGraph/CustomTypes/flowGraphInteger.d.ts +1 -0
  101. package/FlowGraph/CustomTypes/flowGraphInteger.js +3 -0
  102. package/FlowGraph/CustomTypes/flowGraphInteger.js.map +1 -1
  103. package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +2 -0
  104. package/FlowGraph/CustomTypes/flowGraphMatrix.js +6 -0
  105. package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
  106. package/FlowGraph/flowGraphExecutionBlock.d.ts +1 -0
  107. package/FlowGraph/flowGraphExecutionBlock.js +4 -0
  108. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  109. package/FlowGraph/utils.d.ts +2 -1
  110. package/FlowGraph/utils.js +7 -2
  111. package/FlowGraph/utils.js.map +1 -1
  112. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js +2 -2
  113. package/FrameGraph/Node/Blocks/PostProcesses/bloomPostProcessBlock.js.map +1 -1
  114. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +2 -2
  115. package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js.map +1 -1
  116. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.d.ts +126 -0
  117. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +497 -0
  118. package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -0
  119. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
  120. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +30 -4
  121. package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
  122. package/FrameGraph/Node/Blocks/index.d.ts +1 -0
  123. package/FrameGraph/Node/Blocks/index.js +1 -0
  124. package/FrameGraph/Node/Blocks/index.js.map +1 -1
  125. package/FrameGraph/Node/nodeRenderGraph.js +1 -1
  126. package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
  127. package/FrameGraph/Tasks/PostProcesses/bloomTask.d.ts +2 -3
  128. package/FrameGraph/Tasks/PostProcesses/bloomTask.js +3 -4
  129. package/FrameGraph/Tasks/PostProcesses/bloomTask.js.map +1 -1
  130. package/FrameGraph/Tasks/PostProcesses/blurTask.js +2 -2
  131. package/FrameGraph/Tasks/PostProcesses/blurTask.js.map +1 -1
  132. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.d.ts +2 -3
  133. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js +4 -5
  134. package/FrameGraph/Tasks/PostProcesses/depthOfFieldTask.js.map +1 -1
  135. package/FrameGraph/Tasks/PostProcesses/postProcessTask.d.ts +6 -0
  136. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js +14 -0
  137. package/FrameGraph/Tasks/PostProcesses/postProcessTask.js.map +1 -1
  138. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.d.ts +11 -0
  139. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js +18 -0
  140. package/FrameGraph/Tasks/PostProcesses/ssrBlurTask.js.map +1 -0
  141. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.d.ts +76 -0
  142. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js +170 -0
  143. package/FrameGraph/Tasks/PostProcesses/ssrRenderingPipelineTask.js.map +1 -0
  144. package/FrameGraph/Tasks/PostProcesses/ssrTask.d.ts +16 -0
  145. package/FrameGraph/Tasks/PostProcesses/ssrTask.js +45 -0
  146. package/FrameGraph/Tasks/PostProcesses/ssrTask.js.map +1 -0
  147. package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +10 -0
  148. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +29 -0
  149. package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
  150. package/FrameGraph/frameGraph.d.ts +7 -3
  151. package/FrameGraph/frameGraph.js +10 -4
  152. package/FrameGraph/frameGraph.js.map +1 -1
  153. package/FrameGraph/frameGraphTextureManager.d.ts +2 -1
  154. package/FrameGraph/frameGraphTextureManager.js +4 -3
  155. package/FrameGraph/frameGraphTextureManager.js.map +1 -1
  156. package/FrameGraph/index.d.ts +1 -0
  157. package/FrameGraph/index.js +1 -0
  158. package/FrameGraph/index.js.map +1 -1
  159. package/Materials/Node/nodeMaterial.js +3 -0
  160. package/Materials/Node/nodeMaterial.js.map +1 -1
  161. package/Materials/PBR/pbrBaseMaterial.js +1 -1
  162. package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
  163. package/Materials/effectRenderer.js +1 -1
  164. package/Materials/effectRenderer.js.map +1 -1
  165. package/Materials/material.js +5 -3
  166. package/Materials/material.js.map +1 -1
  167. package/Materials/materialHelper.geometryrendering.d.ts +7 -5
  168. package/Materials/materialHelper.geometryrendering.js +8 -3
  169. package/Materials/materialHelper.geometryrendering.js.map +1 -1
  170. package/Materials/standardMaterial.js +1 -1
  171. package/Materials/standardMaterial.js.map +1 -1
  172. package/Meshes/Builders/shapeBuilder.d.ts +2 -0
  173. package/Meshes/Builders/shapeBuilder.js +7 -4
  174. package/Meshes/Builders/shapeBuilder.js.map +1 -1
  175. package/Meshes/geometry.js +4 -0
  176. package/Meshes/geometry.js.map +1 -1
  177. package/Particles/particleSystemComponent.d.ts +2 -1
  178. package/Particles/particleSystemComponent.js +2 -2
  179. package/Particles/particleSystemComponent.js.map +1 -1
  180. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.d.ts +23 -30
  181. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +226 -411
  182. package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
  183. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.d.ts +222 -0
  184. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js +373 -0
  185. package/PostProcesses/RenderPipeline/Pipelines/thinSSRRenderingPipeline.js.map +1 -0
  186. package/PostProcesses/postProcess.d.ts +5 -0
  187. package/PostProcesses/postProcess.js +10 -2
  188. package/PostProcesses/postProcess.js.map +1 -1
  189. package/PostProcesses/thinDepthOfFieldEffect.d.ts +4 -4
  190. package/PostProcesses/thinDepthOfFieldEffect.js.map +1 -1
  191. package/PostProcesses/thinSSRBlurCombinerPostProcess.d.ts +41 -0
  192. package/PostProcesses/thinSSRBlurCombinerPostProcess.js +185 -0
  193. package/PostProcesses/thinSSRBlurCombinerPostProcess.js.map +1 -0
  194. package/PostProcesses/thinSSRBlurPostProcess.d.ts +18 -0
  195. package/PostProcesses/thinSSRBlurPostProcess.js +47 -0
  196. package/PostProcesses/thinSSRBlurPostProcess.js.map +1 -0
  197. package/PostProcesses/thinSSRPostProcess.d.ts +94 -0
  198. package/PostProcesses/thinSSRPostProcess.js +416 -0
  199. package/PostProcesses/thinSSRPostProcess.js.map +1 -0
  200. package/Rendering/IBLShadows/iblShadowsRenderPipeline.d.ts +2 -0
  201. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -0
  202. package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
  203. package/Rendering/iblCdfGenerator.js +1 -1
  204. package/Rendering/iblCdfGenerator.js.map +1 -1
  205. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
  206. package/Shaders/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
  207. package/ShadersWGSL/geometry.fragment.js +1 -1
  208. package/ShadersWGSL/geometry.fragment.js.map +1 -1
  209. package/ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js +13 -2
  210. package/ShadersWGSL/screenSpaceReflection2BlurCombiner.fragment.js.map +1 -1
  211. package/package.json +1 -1
@@ -1,6 +1,5 @@
1
1
  import type { FlowGraphAssetType } from "../../../flowGraphAssetsContext.js";
2
2
  import type { IFlowGraphBlockConfiguration } from "../../../flowGraphBlock.js";
3
- import { FlowGraphBlock } from "../../../flowGraphBlock.js";
4
3
  import type { FlowGraphContext } from "../../../flowGraphContext.js";
5
4
  import type { FlowGraphDataConnection } from "../../../flowGraphDataConnection.js";
6
5
  import { FlowGraphPathConverterComponent } from "../../../flowGraphPathConverterComponent.js";
@@ -8,6 +7,7 @@ import type { IObjectAccessor } from "../../../typeDefinitions.js";
8
7
  import type { IPathToObjectConverter } from "../../../../ObjectModel/objectModelInterfaces.js";
9
8
  import type { Animation } from "../../../../Animations/animation.js";
10
9
  import type { EasingFunction } from "../../../../Animations/easing.js";
10
+ import { FlowGraphCachedOperationBlock } from "../flowGraphCachedOperationBlock";
11
11
  /**
12
12
  * Configuration for the JSON pointer parser block.
13
13
  */
@@ -30,7 +30,7 @@ export interface IFlowGraphJsonPointerParserBlockConfiguration extends IFlowGrap
30
30
  * The output is an object and a property name.
31
31
  * Optionally, the block can also output the value of the property. This is configurable.
32
32
  */
33
- export declare class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphBlock {
33
+ export declare class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphCachedOperationBlock<P> {
34
34
  /**
35
35
  * the configuration of the block
36
36
  */
@@ -43,11 +43,6 @@ export declare class FlowGraphJsonPointerParserBlock<P extends any, O extends Fl
43
43
  * Output connection: The property name.
44
44
  */
45
45
  readonly propertyName: FlowGraphDataConnection<string>;
46
- /**
47
- * Output connection: The value of the property.
48
- * Note that per default this is not outputted. It can be enabled by setting the outputValue property to true.
49
- */
50
- readonly value: FlowGraphDataConnection<P>;
51
46
  /**
52
47
  * Output connection: A function that can be used to update the value of the property.
53
48
  */
@@ -60,10 +55,6 @@ export declare class FlowGraphJsonPointerParserBlock<P extends any, O extends Fl
60
55
  * Output connection: A function that can be used to get the interpolation animation property info.
61
56
  */
62
57
  readonly generateAnimationsFunction: FlowGraphDataConnection<() => (keys: any[], fps: number, easingFunction?: EasingFunction) => Animation[]>;
63
- /**
64
- * Output connection: Whether the value is valid.
65
- */
66
- readonly isValid: FlowGraphDataConnection<boolean>;
67
58
  /**
68
59
  * The component with the templated inputs for the provided path.
69
60
  */
@@ -73,7 +64,7 @@ export declare class FlowGraphJsonPointerParserBlock<P extends any, O extends Fl
73
64
  * the configuration of the block
74
65
  */
75
66
  config: IFlowGraphJsonPointerParserBlockConfiguration);
76
- _updateOutputs(context: FlowGraphContext): void;
67
+ _doOperation(context: FlowGraphContext): P;
77
68
  private _setPropertyValue;
78
69
  private _getPropertyValue;
79
70
  private _getInterpolationAnimationPropertyInfo;
@@ -1,63 +1,43 @@
1
- import { FlowGraphBlock } from "../../../flowGraphBlock.js";
2
1
  import { FlowGraphPathConverterComponent } from "../../../flowGraphPathConverterComponent.js";
3
2
  import { RichTypeAny } from "../../../flowGraphRichTypes.js";
4
3
  import { RegisterClass } from "../../../../Misc/typeStore.js";
5
4
  import { Color3, Color4 } from "../../../../Maths/math.color.js";
5
+ import { FlowGraphCachedOperationBlock } from "../flowGraphCachedOperationBlock.js";
6
6
  /**
7
7
  * This block will take a JSON pointer and parse it to get the value from the JSON object.
8
8
  * The output is an object and a property name.
9
9
  * Optionally, the block can also output the value of the property. This is configurable.
10
10
  */
11
- export class FlowGraphJsonPointerParserBlock extends FlowGraphBlock {
11
+ export class FlowGraphJsonPointerParserBlock extends FlowGraphCachedOperationBlock {
12
12
  constructor(
13
13
  /**
14
14
  * the configuration of the block
15
15
  */
16
16
  config) {
17
- super(config);
17
+ super(RichTypeAny, config);
18
18
  this.config = config;
19
19
  this.object = this.registerDataOutput("object", RichTypeAny);
20
20
  this.propertyName = this.registerDataOutput("propertyName", RichTypeAny);
21
- this.isValid = this.registerDataOutput("isValid", RichTypeAny);
22
- if (config.outputValue) {
23
- this.value = this.registerDataOutput("value", RichTypeAny);
24
- }
25
21
  this.setterFunction = this.registerDataOutput("setFunction", RichTypeAny, this._setPropertyValue.bind(this));
26
22
  this.getterFunction = this.registerDataOutput("getFunction", RichTypeAny, this._getPropertyValue.bind(this));
27
23
  this.generateAnimationsFunction = this.registerDataOutput("generateAnimationsFunction", RichTypeAny, this._getInterpolationAnimationPropertyInfo.bind(this));
28
24
  this.templateComponent = new FlowGraphPathConverterComponent(config.jsonPointer, this);
29
25
  }
30
- _updateOutputs(context) {
31
- try {
32
- const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
33
- const value = accessorContainer.info.get(accessorContainer.object);
34
- const object = accessorContainer.info.getTarget?.(accessorContainer.object);
35
- const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object);
36
- if (!object) {
37
- this.isValid.setValue(false, context);
38
- return;
39
- }
40
- else {
41
- this.object.setValue(object, context);
42
- if (propertyName) {
43
- this.propertyName.setValue(propertyName, context);
44
- }
45
- this.isValid.setValue(true, context);
46
- }
47
- if (this.config.outputValue) {
48
- if (value === undefined) {
49
- this.isValid.setValue(false, context);
50
- }
51
- else {
52
- this.value.setValue(value, context);
53
- this.isValid.setValue(true, context);
54
- }
55
- }
26
+ _doOperation(context) {
27
+ const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
28
+ const value = accessorContainer.info.get(accessorContainer.object);
29
+ const object = accessorContainer.info.getTarget?.(accessorContainer.object);
30
+ const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object);
31
+ if (!object) {
32
+ throw new Error("Object is undefined");
56
33
  }
57
- catch (e) {
58
- this.isValid.setValue(false, context);
59
- return;
34
+ else {
35
+ this.object.setValue(object, context);
36
+ if (propertyName) {
37
+ this.propertyName.setValue(propertyName, context);
38
+ }
60
39
  }
40
+ return value;
61
41
  }
62
42
  _setPropertyValue(_target, _propertyName, value, context) {
63
43
  const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphJsonPointerParserBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,mCAAsC;AAG/D,OAAO,EAAE,+BAA+B,EAAE,oDAAuD;AACjG,OAAO,EAAE,WAAW,EAAE,uCAA0C;AAIhE,OAAO,EAAE,aAAa,EAAE,sCAA4B;AAIpD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,wCAA8B;AAqBvD;;;;GAIG;AACH,MAAM,OAAO,+BAA6E,SAAQ,cAAc;IA0C5G;IACI;;OAEG;IACa,MAAqD;QAErE,KAAK,CAAC,MAAM,CAAC,CAAC;QAFE,WAAM,GAAN,MAAM,CAA+C;QA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CAAC;YAEH,OAAO,UAAU,CAAC;QACtB,CAAC,CAAC;IACN,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,qFAA6C;IACjD,CAAC;CACJ;AAED,SAAS,OAAO,CAAC,KAAU,EAAE,aAAqB;IAC9C,IAAI,KAAK,CAAC,YAAY,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,OAAO,KAAmC,CAAC;IAC/C,CAAC;IACD,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;SAAM,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,aAAa,gFAAwC,+BAA+B,CAAC,CAAC","sourcesContent":["import type { FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport { FlowGraphBlock } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { FlowGraphPathConverterComponent } from \"core/FlowGraph/flowGraphPathConverterComponent\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { IObjectAccessor } from \"core/FlowGraph/typeDefinitions\";\nimport type { IPathToObjectConverter } from \"core/ObjectModel/objectModelInterfaces\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport type { Animation } from \"core/Animations/animation\";\nimport type { EasingFunction } from \"core/Animations/easing\";\nimport type { Vector4 } from \"core/Maths/math.vector\";\nimport { Color3, Color4 } from \"core/Maths/math.color\";\n\n/**\n * Configuration for the JSON pointer parser block.\n */\nexport interface IFlowGraphJsonPointerParserBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The JSON pointer to parse.\n */\n jsonPointer: string;\n /**\n * The path converter to use to convert the path to an object accessor.\n */\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\n\n /**\n * Whether to output the value of the property.\n */\n outputValue?: boolean;\n}\n\n/**\n * This block will take a JSON pointer and parse it to get the value from the JSON object.\n * The output is an object and a property name.\n * Optionally, the block can also output the value of the property. This is configurable.\n */\nexport class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphBlock {\n /**\n * Output connection: The object that contains the property.\n */\n public readonly object: FlowGraphDataConnection<O>;\n\n /**\n * Output connection: The property name.\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Output connection: The value of the property.\n * Note that per default this is not outputted. It can be enabled by setting the outputValue property to true.\n */\n public readonly value: FlowGraphDataConnection<P>;\n\n /**\n * Output connection: A function that can be used to update the value of the property.\n */\n public readonly setterFunction: FlowGraphDataConnection<(target: O, propertyName: string, value: P, context: FlowGraphContext) => void>;\n\n /**\n * Output connection: A function that can be used to get the value of the property.\n */\n public readonly getterFunction: FlowGraphDataConnection<(target: O, propertyName: string, context: FlowGraphContext) => P | undefined>;\n\n /**\n * Output connection: A function that can be used to get the interpolation animation property info.\n */\n public readonly generateAnimationsFunction: FlowGraphDataConnection<() => (keys: any[], fps: number, easingFunction?: EasingFunction) => Animation[]>;\n\n /**\n * Output connection: Whether the value is valid.\n */\n public readonly isValid: FlowGraphDataConnection<boolean>;\n\n /**\n * The component with the templated inputs for the provided path.\n */\n public readonly templateComponent: FlowGraphPathConverterComponent;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphJsonPointerParserBlockConfiguration\n ) {\n super(config);\n this.object = this.registerDataOutput(\"object\", RichTypeAny);\n this.propertyName = this.registerDataOutput(\"propertyName\", RichTypeAny);\n this.isValid = this.registerDataOutput(\"isValid\", RichTypeAny);\n if (config.outputValue) {\n this.value = this.registerDataOutput(\"value\", RichTypeAny);\n }\n this.setterFunction = this.registerDataOutput(\"setFunction\", RichTypeAny, this._setPropertyValue.bind(this));\n this.getterFunction = this.registerDataOutput(\"getFunction\", RichTypeAny, this._getPropertyValue.bind(this));\n this.generateAnimationsFunction = this.registerDataOutput(\"generateAnimationsFunction\", RichTypeAny, this._getInterpolationAnimationPropertyInfo.bind(this));\n this.templateComponent = new FlowGraphPathConverterComponent(config.jsonPointer, this);\n }\n\n public override _updateOutputs(context: FlowGraphContext) {\n try {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const value = accessorContainer.info.get(accessorContainer.object);\n const object = accessorContainer.info.getTarget?.(accessorContainer.object);\n const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object);\n if (!object) {\n this.isValid.setValue(false, context);\n return;\n } else {\n this.object.setValue(object, context);\n if (propertyName) {\n this.propertyName.setValue(propertyName, context);\n }\n this.isValid.setValue(true, context);\n }\n if (this.config.outputValue) {\n if (value === undefined) {\n this.isValid.setValue(false, context);\n } else {\n this.value.setValue(value, context);\n this.isValid.setValue(true, context);\n }\n }\n } catch (e) {\n this.isValid.setValue(false, context);\n return;\n }\n }\n\n private _setPropertyValue(_target: O, _propertyName: string, value: P, context: FlowGraphContext): void {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n value = ToColor(value as Vector4, type) as unknown as P;\n }\n accessorContainer.info.set?.(value, accessorContainer.object);\n }\n\n private _getPropertyValue(_target: O, _propertyName: string, context: FlowGraphContext): P | undefined {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n return accessorContainer.info.get(accessorContainer.object);\n }\n\n private _getInterpolationAnimationPropertyInfo(\n _target: O,\n _propertyName: string,\n context: FlowGraphContext\n ): (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation[] {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n return (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => {\n const animations: Animation[] = [];\n // make sure keys are of the right type (in case of float3 color/vector)\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n keys = keys.map((key) => {\n return {\n frame: key.frame,\n value: ToColor(key.value, type),\n };\n });\n }\n accessorContainer.info.interpolation?.forEach((info, index) => {\n const name = accessorContainer.info.getPropertyName?.[index](accessorContainer.object) || \"Animation-interpolation-\" + index;\n // generate the keys based on interpolation info\n let newKeys: any[] = keys;\n if (animationType !== info.type) {\n // convert the keys to the right type\n newKeys = keys.map((key) => {\n return {\n frame: key.frame,\n value: info.getValue(undefined, key.value.asArray ? key.value.asArray() : [key.value], 0, 1),\n };\n });\n }\n const animationData = info.buildAnimations(accessorContainer.object, name, 60, newKeys);\n animationData.forEach((animation) => {\n if (easingFunction) {\n animation.babylonAnimation.setEasingFunction(easingFunction);\n }\n animations.push(animation.babylonAnimation);\n });\n });\n\n return animations;\n };\n }\n\n /**\n * Gets the class name of this block\n * @returns the class name\n */\n public override getClassName(): string {\n return FlowGraphBlockNames.JsonPointerParser;\n }\n}\n\nfunction ToColor(value: any, expectedValue: string) {\n if (value.getClassName().startsWith(\"Color\")) {\n return value as unknown as Color3 | Color4;\n }\n if (expectedValue === \"Color3\") {\n return new Color3(value.x, value.y, value.z);\n } else if (expectedValue === \"Color4\") {\n return new Color4(value.x, value.y, value.z, value.w);\n }\n return value;\n}\n\nRegisterClass(FlowGraphBlockNames.JsonPointerParser, FlowGraphJsonPointerParserBlock);\n"]}
1
+ {"version":3,"file":"flowGraphJsonPointerParserBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserB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C;IACjD,CAAC;SAAM,IAAI,aAAa,KAAK,QAAQ,EAAE,CAAC;QACpC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,aAAa,gFAAwC,+BAA+B,CAAC,CAAC","sourcesContent":["import type { FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { FlowGraphPathConverterComponent } from \"core/FlowGraph/flowGraphPathConverterComponent\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { IObjectAccessor } from \"core/FlowGraph/typeDefinitions\";\nimport type { IPathToObjectConverter } from \"core/ObjectModel/objectModelInterfaces\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport type { Animation } from \"core/Animations/animation\";\nimport type { EasingFunction } from \"core/Animations/easing\";\nimport type { Vector4 } from \"core/Maths/math.vector\";\nimport { Color3, Color4 } from \"core/Maths/math.color\";\nimport { FlowGraphCachedOperationBlock } from \"../flowGraphCachedOperationBlock\";\n\n/**\n * Configuration for the JSON pointer parser block.\n */\nexport interface IFlowGraphJsonPointerParserBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The JSON pointer to parse.\n */\n jsonPointer: string;\n /**\n * The path converter to use to convert the path to an object accessor.\n */\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\n\n /**\n * Whether to output the value of the property.\n */\n outputValue?: boolean;\n}\n\n/**\n * This block will take a JSON pointer and parse it to get the value from the JSON object.\n * The output is an object and a property name.\n * Optionally, the block can also output the value of the property. This is configurable.\n */\nexport class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphCachedOperationBlock<P> {\n /**\n * Output connection: The object that contains the property.\n */\n public readonly object: FlowGraphDataConnection<O>;\n\n /**\n * Output connection: The property name.\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Output connection: A function that can be used to update the value of the property.\n */\n public readonly setterFunction: FlowGraphDataConnection<(target: O, propertyName: string, value: P, context: FlowGraphContext) => void>;\n\n /**\n * Output connection: A function that can be used to get the value of the property.\n */\n public readonly getterFunction: FlowGraphDataConnection<(target: O, propertyName: string, context: FlowGraphContext) => P | undefined>;\n\n /**\n * Output connection: A function that can be used to get the interpolation animation property info.\n */\n public readonly generateAnimationsFunction: FlowGraphDataConnection<() => (keys: any[], fps: number, easingFunction?: EasingFunction) => Animation[]>;\n\n /**\n * The component with the templated inputs for the provided path.\n */\n public readonly templateComponent: FlowGraphPathConverterComponent;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphJsonPointerParserBlockConfiguration\n ) {\n super(RichTypeAny, config);\n this.object = this.registerDataOutput(\"object\", RichTypeAny);\n this.propertyName = this.registerDataOutput(\"propertyName\", RichTypeAny);\n this.setterFunction = this.registerDataOutput(\"setFunction\", RichTypeAny, this._setPropertyValue.bind(this));\n this.getterFunction = this.registerDataOutput(\"getFunction\", RichTypeAny, this._getPropertyValue.bind(this));\n this.generateAnimationsFunction = this.registerDataOutput(\"generateAnimationsFunction\", RichTypeAny, this._getInterpolationAnimationPropertyInfo.bind(this));\n this.templateComponent = new FlowGraphPathConverterComponent(config.jsonPointer, this);\n }\n\n public override _doOperation(context: FlowGraphContext): P {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const value = accessorContainer.info.get(accessorContainer.object) as P;\n const object = accessorContainer.info.getTarget?.(accessorContainer.object);\n const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object);\n if (!object) {\n throw new Error(\"Object is undefined\");\n } else {\n this.object.setValue(object, context);\n if (propertyName) {\n this.propertyName.setValue(propertyName, context);\n }\n }\n return value;\n }\n\n private _setPropertyValue(_target: O, _propertyName: string, value: P, context: FlowGraphContext): void {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n value = ToColor(value as Vector4, type) as unknown as P;\n }\n accessorContainer.info.set?.(value, accessorContainer.object);\n }\n\n private _getPropertyValue(_target: O, _propertyName: string, context: FlowGraphContext): P | undefined {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n return accessorContainer.info.get(accessorContainer.object);\n }\n\n private _getInterpolationAnimationPropertyInfo(\n _target: O,\n _propertyName: string,\n context: FlowGraphContext\n ): (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation[] {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n return (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => {\n const animations: Animation[] = [];\n // make sure keys are of the right type (in case of float3 color/vector)\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n keys = keys.map((key) => {\n return {\n frame: key.frame,\n value: ToColor(key.value, type),\n };\n });\n }\n accessorContainer.info.interpolation?.forEach((info, index) => {\n const name = accessorContainer.info.getPropertyName?.[index](accessorContainer.object) || \"Animation-interpolation-\" + index;\n // generate the keys based on interpolation info\n let newKeys: any[] = keys;\n if (animationType !== info.type) {\n // convert the keys to the right type\n newKeys = keys.map((key) => {\n return {\n frame: key.frame,\n value: info.getValue(undefined, key.value.asArray ? key.value.asArray() : [key.value], 0, 1),\n };\n });\n }\n const animationData = info.buildAnimations(accessorContainer.object, name, 60, newKeys);\n animationData.forEach((animation) => {\n if (easingFunction) {\n animation.babylonAnimation.setEasingFunction(easingFunction);\n }\n animations.push(animation.babylonAnimation);\n });\n });\n\n return animations;\n };\n }\n\n /**\n * Gets the class name of this block\n * @returns the class name\n */\n public override getClassName(): string {\n return FlowGraphBlockNames.JsonPointerParser;\n }\n}\n\nfunction ToColor(value: any, expectedValue: string) {\n if (value.getClassName().startsWith(\"Color\")) {\n return value as unknown as Color3 | Color4;\n }\n if (expectedValue === \"Color3\") {\n return new Color3(value.x, value.y, value.z);\n } else if (expectedValue === \"Color4\") {\n return new Color4(value.x, value.y, value.z, value.w);\n }\n return value;\n}\n\nRegisterClass(FlowGraphBlockNames.JsonPointerParser, FlowGraphJsonPointerParserBlock);\n"]}
@@ -11,12 +11,16 @@ export declare abstract class FlowGraphCachedOperationBlock<OutputT> extends Flo
11
11
  * The output of the operation
12
12
  */
13
13
  readonly value: FlowGraphDataConnection<OutputT>;
14
+ /**
15
+ * Output connection: Whether the value is valid.
16
+ */
17
+ readonly isValid: FlowGraphDataConnection<boolean>;
14
18
  constructor(outputRichType: RichType<OutputT>, config?: IFlowGraphBlockConfiguration);
15
19
  /**
16
20
  * @internal
17
21
  * Operation to realize
18
22
  * @param context the graph context
19
23
  */
20
- abstract _doOperation(context: FlowGraphContext): OutputT;
24
+ abstract _doOperation(context: FlowGraphContext): OutputT | undefined;
21
25
  _updateOutputs(context: FlowGraphContext): void;
22
26
  }
@@ -1,4 +1,5 @@
1
1
  import { FlowGraphBlock } from "../../flowGraphBlock.js";
2
+ import { RichTypeBoolean } from "../../flowGraphRichTypes.js";
2
3
  const cacheName = "cachedOperationValue";
3
4
  const cacheExecIdName = "cachedExecutionId";
4
5
  /**
@@ -8,18 +9,30 @@ export class FlowGraphCachedOperationBlock extends FlowGraphBlock {
8
9
  constructor(outputRichType, config) {
9
10
  super(config);
10
11
  this.value = this.registerDataOutput("value", outputRichType);
12
+ this.isValid = this.registerDataOutput("isValid", RichTypeBoolean);
11
13
  }
12
14
  _updateOutputs(context) {
13
15
  const cachedExecutionId = context._getExecutionVariable(this, cacheExecIdName, -1);
14
16
  const cachedValue = context._getExecutionVariable(this, cacheName, null);
15
17
  if (cachedValue !== undefined && cachedValue !== null && cachedExecutionId === context.executionId) {
18
+ this.isValid.setValue(true, context);
16
19
  this.value.setValue(cachedValue, context);
17
20
  }
18
21
  else {
19
- const calculatedValue = this._doOperation(context);
20
- context._setExecutionVariable(this, cacheName, calculatedValue);
21
- context._setExecutionVariable(this, cacheExecIdName, context.executionId);
22
- this.value.setValue(calculatedValue, context);
22
+ try {
23
+ const calculatedValue = this._doOperation(context);
24
+ if (calculatedValue === undefined || calculatedValue === null) {
25
+ this.isValid.setValue(false, context);
26
+ return;
27
+ }
28
+ context._setExecutionVariable(this, cacheName, calculatedValue);
29
+ context._setExecutionVariable(this, cacheExecIdName, context.executionId);
30
+ this.value.setValue(calculatedValue, context);
31
+ this.isValid.setValue(true, context);
32
+ }
33
+ catch (e) {
34
+ this.isValid.setValue(false, context);
35
+ }
23
36
  }
24
37
  }
25
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphCachedOperationBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,MAAM,SAAS,GAAG,sBAAsB,CAAC;AACzC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAE5C;;GAEG;AACH,MAAM,OAAgB,6BAAuC,SAAQ,cAAc;IAM/E,YAAY,cAAiC,EAAE,MAAqC;QAChF,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;IAClE,CAAC;IASe,cAAc,CAAC,OAAyB;QACpD,MAAM,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC;QACnF,MAAM,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAoB,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QAC5F,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,IAAI,iBAAiB,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC;YACjG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACJ,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;YACnD,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;YAChE,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1E,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAClD,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { FlowGraphBlock } from \"../../flowGraphBlock\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport type { RichType } from \"../../flowGraphRichTypes\";\r\n\r\nconst cacheName = \"cachedOperationValue\";\r\nconst cacheExecIdName = \"cachedExecutionId\";\r\n\r\n/**\r\n * A block that will cache the result of an operation and deliver it as an output.\r\n */\r\nexport abstract class FlowGraphCachedOperationBlock<OutputT> extends FlowGraphBlock {\r\n /**\r\n * The output of the operation\r\n */\r\n public readonly value: FlowGraphDataConnection<OutputT>;\r\n\r\n constructor(outputRichType: RichType<OutputT>, config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n\r\n this.value = this.registerDataOutput(\"value\", outputRichType);\r\n }\r\n\r\n /**\r\n * @internal\r\n * Operation to realize\r\n * @param context the graph context\r\n */\r\n public abstract _doOperation(context: FlowGraphContext): OutputT;\r\n\r\n public override _updateOutputs(context: FlowGraphContext) {\r\n const cachedExecutionId = context._getExecutionVariable(this, cacheExecIdName, -1);\r\n const cachedValue = context._getExecutionVariable<Nullable<OutputT>>(this, cacheName, null);\r\n if (cachedValue !== undefined && cachedValue !== null && cachedExecutionId === context.executionId) {\r\n this.value.setValue(cachedValue, context);\r\n } else {\r\n const calculatedValue = this._doOperation(context);\r\n context._setExecutionVariable(this, cacheName, calculatedValue);\r\n context._setExecutionVariable(this, cacheExecIdName, context.executionId);\r\n this.value.setValue(calculatedValue, context);\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"flowGraphCachedOperationBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,MAAM,SAAS,GAAG,sBAAsB,CAAC;AACzC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAE5C;;GAEG;AACH,MAAM,OAAgB,6BAAuC,SAAQ,cAAc;IAW/E,YAAY,cAAiC,EAAE,MAAqC;QAChF,KAAK,CAAC,MAAM,CAAC,CAAC;QAEd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC9D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IACvE,CAAC;IASe,cAAc,CAAC,OAAyB;QACpD,MAAM,iBAAiB,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,CAAC;QACnF,MAAM,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAoB,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;QAC5F,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,IAAI,IAAI,iBAAiB,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC;YACjG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACrC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC9C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC;gBACD,MAAM,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gBACnD,IAAI,eAAe,KAAK,SAAS,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;oBAC5D,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;oBACtC,OAAO;gBACX,CAAC;gBACD,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;gBAChE,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC;gBAC1E,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;gBAC9C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAC1C,CAAC;QACL,CAAC;IACL,CAAC;CACJ","sourcesContent":["import type { Nullable } from \"../../../types\";\r\nimport type { IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\nimport { FlowGraphBlock } from \"../../flowGraphBlock\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport type { RichType } from \"../../flowGraphRichTypes\";\r\nimport { RichTypeBoolean } from \"../../flowGraphRichTypes\";\r\n\r\nconst cacheName = \"cachedOperationValue\";\r\nconst cacheExecIdName = \"cachedExecutionId\";\r\n\r\n/**\r\n * A block that will cache the result of an operation and deliver it as an output.\r\n */\r\nexport abstract class FlowGraphCachedOperationBlock<OutputT> extends FlowGraphBlock {\r\n /**\r\n * The output of the operation\r\n */\r\n public readonly value: FlowGraphDataConnection<OutputT>;\r\n\r\n /**\r\n * Output connection: Whether the value is valid.\r\n */\r\n public readonly isValid: FlowGraphDataConnection<boolean>;\r\n\r\n constructor(outputRichType: RichType<OutputT>, config?: IFlowGraphBlockConfiguration) {\r\n super(config);\r\n\r\n this.value = this.registerDataOutput(\"value\", outputRichType);\r\n this.isValid = this.registerDataOutput(\"isValid\", RichTypeBoolean);\r\n }\r\n\r\n /**\r\n * @internal\r\n * Operation to realize\r\n * @param context the graph context\r\n */\r\n public abstract _doOperation(context: FlowGraphContext): OutputT | undefined;\r\n\r\n public override _updateOutputs(context: FlowGraphContext) {\r\n const cachedExecutionId = context._getExecutionVariable(this, cacheExecIdName, -1);\r\n const cachedValue = context._getExecutionVariable<Nullable<OutputT>>(this, cacheName, null);\r\n if (cachedValue !== undefined && cachedValue !== null && cachedExecutionId === context.executionId) {\r\n this.isValid.setValue(true, context);\r\n this.value.setValue(cachedValue, context);\r\n } else {\r\n try {\r\n const calculatedValue = this._doOperation(context);\r\n if (calculatedValue === undefined || calculatedValue === null) {\r\n this.isValid.setValue(false, context);\r\n return;\r\n }\r\n context._setExecutionVariable(this, cacheName, calculatedValue);\r\n context._setExecutionVariable(this, cacheExecIdName, context.executionId);\r\n this.value.setValue(calculatedValue, context);\r\n this.isValid.setValue(true, context);\r\n } catch (e) {\r\n this.isValid.setValue(false, context);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -0,0 +1,48 @@
1
+ import { FlowGraphBlock, type IFlowGraphBlockConfiguration } from "../../flowGraphBlock.js";
2
+ import type { FlowGraphContext } from "../../flowGraphContext.js";
3
+ import type { FlowGraphDataConnection } from "../../flowGraphDataConnection.js";
4
+ import type { FlowGraphNumber } from "../../utils.js";
5
+ export interface IFlowGraphDataSwitchBlockConfiguration<T> extends IFlowGraphBlockConfiguration {
6
+ /**
7
+ * The possible values for the selection.
8
+ *
9
+ */
10
+ cases: FlowGraphNumber[];
11
+ /**
12
+ * If true, the cases will be treated as integers, meaning 1.1, 1.0, 0.1e1 and 1 will a single case - "1".
13
+ * This is the default behavior in glTF interactivity.
14
+ */
15
+ treatCasesAsIntegers?: boolean;
16
+ }
17
+ /**
18
+ * This block conditionally outputs one of its inputs, based on a condition and a list of cases.
19
+ *
20
+ * This of it as a passive (data) version of the switch statement in programming languages.
21
+ */
22
+ export declare class FlowGraphDataSwitchBlock<T> extends FlowGraphBlock {
23
+ /**
24
+ * the configuration of the block
25
+ */
26
+ config: IFlowGraphDataSwitchBlockConfiguration<T>;
27
+ /**
28
+ * Current selection value.
29
+ */
30
+ readonly case: FlowGraphDataConnection<FlowGraphNumber>;
31
+ /**
32
+ * Input: default value to output if no case is matched.
33
+ */
34
+ readonly default: FlowGraphDataConnection<T>;
35
+ /**
36
+ * Output: the value that is output based on the selection.
37
+ */
38
+ readonly value: FlowGraphDataConnection<T | undefined>;
39
+ private _inputCases;
40
+ constructor(
41
+ /**
42
+ * the configuration of the block
43
+ */
44
+ config: IFlowGraphDataSwitchBlockConfiguration<T>);
45
+ _updateOutputs(context: FlowGraphContext): void;
46
+ private _getOutputValueForCase;
47
+ getClassName(): string;
48
+ }
@@ -0,0 +1,54 @@
1
+ import { FlowGraphBlock } from "../../flowGraphBlock.js";
2
+ import { RichTypeAny } from "../../flowGraphRichTypes.js";
3
+ import { getNumericValue, isNumeric } from "../../utils.js";
4
+ import { RegisterClass } from "../../../Misc/typeStore.js";
5
+ /**
6
+ * This block conditionally outputs one of its inputs, based on a condition and a list of cases.
7
+ *
8
+ * This of it as a passive (data) version of the switch statement in programming languages.
9
+ */
10
+ export class FlowGraphDataSwitchBlock extends FlowGraphBlock {
11
+ constructor(
12
+ /**
13
+ * the configuration of the block
14
+ */
15
+ config) {
16
+ super(config);
17
+ this.config = config;
18
+ this._inputCases = new Map();
19
+ this.case = this.registerDataInput("case", RichTypeAny, NaN);
20
+ this.default = this.registerDataInput("default", RichTypeAny);
21
+ this.value = this.registerDataOutput("value", RichTypeAny);
22
+ // iterate the set not using for of
23
+ (this.config.cases || []).forEach((caseValue) => {
24
+ // if treat as integers, make sure not to set it again if it exists
25
+ caseValue = getNumericValue(caseValue);
26
+ if (this.config.treatCasesAsIntegers) {
27
+ caseValue = caseValue | 0;
28
+ if (this._inputCases.has(caseValue)) {
29
+ return;
30
+ }
31
+ }
32
+ this._inputCases.set(caseValue, this.registerDataInput(`in_${caseValue}`, RichTypeAny));
33
+ });
34
+ }
35
+ _updateOutputs(context) {
36
+ const selectionValue = this.case.getValue(context);
37
+ let outputValue;
38
+ if (isNumeric(selectionValue)) {
39
+ outputValue = this._getOutputValueForCase(getNumericValue(selectionValue), context);
40
+ }
41
+ else {
42
+ outputValue = this.default.getValue(context);
43
+ }
44
+ this.value.setValue(outputValue, context);
45
+ }
46
+ _getOutputValueForCase(caseValue, context) {
47
+ return this._inputCases.get(caseValue)?.getValue(context);
48
+ }
49
+ getClassName() {
50
+ return "FlowGraphDataSwitchBlock" /* FlowGraphBlockNames.DataSwitch */;
51
+ }
52
+ }
53
+ RegisterClass("FlowGraphDataSwitchBlock" /* FlowGraphBlockNames.DataSwitch */, FlowGraphDataSwitchBlock);
54
+ //# sourceMappingURL=flowGraphDataSwitchBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flowGraphDataSwitchBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Data/flowGraphDataSwitchBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAqC,gCAAsC;AAGlG,OAAO,EAAE,WAAW,EAAE,oCAA0C;AAEhE,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,uBAA6B;AAElE,OAAO,EAAE,aAAa,EAAE,mCAA4B;AAepD;;;;GAIG;AACH,M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AC,eAAe,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC;QACxF,CAAC;aAAM,CAAC;YACJ,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAEO,sBAAsB,CAAC,SAAiB,EAAE,OAAyB;QACvE,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9D,CAAC;IAEe,YAAY;QACxB,uEAAsC;IAC1C,CAAC;CACJ;AACD,aAAa,kEAAiC,wBAAwB,CAAC,CAAC","sourcesContent":["import { FlowGraphBlock, type IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\nimport type { FlowGraphNumber } from \"core/FlowGraph/utils\";\nimport { getNumericValue, isNumeric } from \"core/FlowGraph/utils\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\n\nexport interface IFlowGraphDataSwitchBlockConfiguration<T> extends IFlowGraphBlockConfiguration {\n /**\n * The possible values for the selection.\n *\n */\n cases: FlowGraphNumber[];\n\n /**\n * If true, the cases will be treated as integers, meaning 1.1, 1.0, 0.1e1 and 1 will a single case - \"1\".\n * This is the default behavior in glTF interactivity.\n */\n treatCasesAsIntegers?: boolean;\n}\n/**\n * This block conditionally outputs one of its inputs, based on a condition and a list of cases.\n *\n * This of it as a passive (data) version of the switch statement in programming languages.\n */\nexport class FlowGraphDataSwitchBlock<T> extends FlowGraphBlock {\n /**\n * Current selection value.\n */\n public readonly case: FlowGraphDataConnection<FlowGraphNumber>;\n\n /**\n * Input: default value to output if no case is matched.\n */\n public readonly default: FlowGraphDataConnection<T>;\n\n /**\n * Output: the value that is output based on the selection.\n */\n public readonly value: FlowGraphDataConnection<T | undefined>;\n\n private _inputCases: Map<number, FlowGraphDataConnection<T>> = new Map();\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphDataSwitchBlockConfiguration<T>\n ) {\n super(config);\n\n this.case = this.registerDataInput(\"case\", RichTypeAny, NaN);\n this.default = this.registerDataInput(\"default\", RichTypeAny);\n this.value = this.registerDataOutput(\"value\", RichTypeAny);\n\n // iterate the set not using for of\n (this.config.cases || []).forEach((caseValue) => {\n // if treat as integers, make sure not to set it again if it exists\n caseValue = getNumericValue(caseValue);\n if (this.config.treatCasesAsIntegers) {\n caseValue = caseValue | 0;\n if (this._inputCases.has(caseValue)) {\n return;\n }\n }\n this._inputCases.set(caseValue, this.registerDataInput(`in_${caseValue}`, RichTypeAny));\n });\n }\n\n public override _updateOutputs(context: FlowGraphContext): void {\n const selectionValue = this.case.getValue(context);\n let outputValue: T | undefined;\n if (isNumeric(selectionValue)) {\n outputValue = this._getOutputValueForCase(getNumericValue(selectionValue), context);\n } else {\n outputValue = this.default.getValue(context);\n }\n\n this.value.setValue(outputValue, context);\n }\n\n private _getOutputValueForCase(caseValue: number, context: FlowGraphContext): T | undefined {\n return this._inputCases.get(caseValue)?.getValue(context);\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.DataSwitch;\n }\n}\nRegisterClass(FlowGraphBlockNames.DataSwitch, FlowGraphDataSwitchBlock);\n"]}
@@ -1,8 +1,8 @@
1
1
  import type { AssetType, FlowGraphAssetType } from "../../flowGraphAssetsContext.js";
2
2
  import type { IFlowGraphBlockConfiguration } from "../../flowGraphBlock.js";
3
- import { FlowGraphBlock } from "../../flowGraphBlock.js";
4
3
  import type { FlowGraphContext } from "../../flowGraphContext.js";
5
4
  import type { FlowGraphDataConnection } from "../../flowGraphDataConnection.js";
5
+ import { FlowGraphCachedOperationBlock } from "./flowGraphCachedOperationBlock";
6
6
  export interface IFlowGraphGetPropertyBlockConfiguration<O extends FlowGraphAssetType> extends IFlowGraphBlockConfiguration {
7
7
  /**
8
8
  * The name of the property that will be set
@@ -25,15 +25,11 @@ export interface IFlowGraphGetPropertyBlockConfiguration<O extends FlowGraphAsse
25
25
  *
26
26
  * Note that it is recommended to input the object on which you are working on (i.e. a material) rather than providing a mesh as object and then getting the material from it.
27
27
  */
28
- export declare class FlowGraphGetPropertyBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphBlock {
28
+ export declare class FlowGraphGetPropertyBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphCachedOperationBlock<P> {
29
29
  /**
30
30
  * the configuration of the block
31
31
  */
32
32
  config: IFlowGraphGetPropertyBlockConfiguration<O>;
33
- /**
34
- * Output connection: The value of the property.
35
- */
36
- readonly value: FlowGraphDataConnection<P>;
37
33
  /**
38
34
  * Input connection: The asset from which the property will be retrieved
39
35
  */
@@ -42,10 +38,6 @@ export declare class FlowGraphGetPropertyBlock<P extends any, O extends FlowGrap
42
38
  * Input connection: The name of the property that will be set
43
39
  */
44
40
  readonly propertyName: FlowGraphDataConnection<string>;
45
- /**
46
- * Output connection: Whether the value is valid.
47
- */
48
- readonly isValid: FlowGraphDataConnection<boolean>;
49
41
  /**
50
42
  * Input connection: A function that can be used to get the value of the property.
51
43
  * This will be used if defined, instead of the default get function.
@@ -56,7 +48,7 @@ export declare class FlowGraphGetPropertyBlock<P extends any, O extends FlowGrap
56
48
  * the configuration of the block
57
49
  */
58
50
  config: IFlowGraphGetPropertyBlockConfiguration<O>);
59
- _updateOutputs(context: FlowGraphContext): void;
51
+ _doOperation(context: FlowGraphContext): P | undefined;
60
52
  private _getPropertyValue;
61
53
  getClassName(): string;
62
54
  }
@@ -1,6 +1,6 @@
1
- import { FlowGraphBlock } from "../../flowGraphBlock.js";
2
1
  import { RichTypeAny } from "../../flowGraphRichTypes.js";
3
2
  import { RegisterClass } from "../../../Misc/typeStore.js";
3
+ import { FlowGraphCachedOperationBlock } from "./flowGraphCachedOperationBlock.js";
4
4
  /**
5
5
  * This block will deliver a property of an asset, based on the property name and an input asset.
6
6
  * The property name can include dots ("."), which will be interpreted as a path to the property.
@@ -9,21 +9,19 @@ import { RegisterClass } from "../../../Misc/typeStore.js";
9
9
  *
10
10
  * Note that it is recommended to input the object on which you are working on (i.e. a material) rather than providing a mesh as object and then getting the material from it.
11
11
  */
12
- export class FlowGraphGetPropertyBlock extends FlowGraphBlock {
12
+ export class FlowGraphGetPropertyBlock extends FlowGraphCachedOperationBlock {
13
13
  constructor(
14
14
  /**
15
15
  * the configuration of the block
16
16
  */
17
17
  config) {
18
- super(config);
18
+ super(RichTypeAny, config);
19
19
  this.config = config;
20
20
  this.object = this.registerDataInput("object", RichTypeAny, config.object);
21
21
  this.propertyName = this.registerDataInput("propertyName", RichTypeAny, config.propertyName);
22
- this.value = this.registerDataOutput("value", RichTypeAny);
23
- this.isValid = this.registerDataOutput("isValid", RichTypeAny, false);
24
22
  this.customGetFunction = this.registerDataInput("customGetFunction", RichTypeAny);
25
23
  }
26
- _updateOutputs(context) {
24
+ _doOperation(context) {
27
25
  const getter = this.customGetFunction.getValue(context);
28
26
  let value;
29
27
  if (getter) {
@@ -34,14 +32,7 @@ export class FlowGraphGetPropertyBlock extends FlowGraphBlock {
34
32
  const propertyName = this.propertyName.getValue(context);
35
33
  value = target && propertyName ? this._getPropertyValue(target, propertyName) : undefined;
36
34
  }
37
- if (value === undefined) {
38
- this.value.resetToDefaultValue(context);
39
- this.isValid.setValue(false, context);
40
- }
41
- else {
42
- this.value.setValue(value, context);
43
- this.isValid.setValue(true, context);
44
- }
35
+ return value;
45
36
  }
46
37
  _getPropertyValue(target, propertyName) {
47
38
  const path = propertyName.split(".");
@@ -1 +1 @@
1
- {"version":3,"file":"flowGraphGetPropertyBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Data/flow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AO,CAAC,CAAC;YAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YACzD,KAAK,GAAG,MAAM,IAAI,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAC9F,CAAC;QACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;YACxC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YACpC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;IACL,CAAC;IAEO,iBAAiB,CAAC,MAAoB,EAAE,YAAoB;QAChE,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,KAAK,GAAQ,MAAM,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE,CAAC;YACtB,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;YACpB,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACtB,OAAO;YACX,CAAC;QACL,CAAC;QACD,OAAO,KAAU,CAAC;IACtB,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 { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport { FlowGraphBlock } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\n\nexport interface IFlowGraphGetPropertyBlockConfiguration<O extends FlowGraphAssetType> extends IFlowGraphBlockConfiguration {\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 object?: AssetType<O>;\n\n /**\n * If true, the block will reset the output to the default value when the target asset is undefined.\n */\n resetToDefaultWhenUndefined?: boolean;\n}\n\n/**\n * This block will deliver a property of an asset, based on the property name and an input asset.\n * The property name can include dots (\".\"), which will be interpreted as a path to the property.\n *\n * For example, with an input of a mesh asset, the property name \"position.x\" will deliver 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) rather than providing a mesh as object and then getting the material from it.\n */\nexport class FlowGraphGetPropertyBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphBlock {\n /**\n * Output connection: The value of the property.\n */\n public readonly value: FlowGraphDataConnection<P>;\n\n /**\n * Input connection: The 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 * Output connection: Whether the value is valid.\n */\n public readonly isValid: FlowGraphDataConnection<boolean>;\n\n /**\n * Input connection: A function that can be used to get the value of the property.\n * This will be used if defined, instead of the default get function.\n */\n public readonly customGetFunction: FlowGraphDataConnection<(target: AssetType<O>, propertyName: string, context: FlowGraphContext) => P | undefined>;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphGetPropertyBlockConfiguration<O>\n ) {\n super(config);\n this.object = this.registerDataInput(\"object\", RichTypeAny, config.object);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeAny, config.propertyName);\n this.value = this.registerDataOutput(\"value\", RichTypeAny);\n this.isValid = this.registerDataOutput(\"isValid\", RichTypeAny, false);\n this.customGetFunction = this.registerDataInput(\"customGetFunction\", RichTypeAny);\n }\n\n public override _updateOutputs(context: FlowGraphContext): void {\n const getter = this.customGetFunction.getValue(context);\n let value;\n if (getter) {\n value = getter(this.object.getValue(context), this.propertyName.getValue(context), context);\n } else {\n const target = this.object.getValue(context);\n const propertyName = this.propertyName.getValue(context);\n value = target && propertyName ? this._getPropertyValue(target, propertyName) : undefined;\n }\n if (value === undefined) {\n this.value.resetToDefaultValue(context);\n this.isValid.setValue(false, context);\n } else {\n this.value.setValue(value, context);\n this.isValid.setValue(true, context);\n }\n }\n\n private _getPropertyValue(target: AssetType<O>, propertyName: string): P | undefined {\n const path = propertyName.split(\".\");\n let value: any = target;\n for (const prop of path) {\n value = value[prop];\n if (value === undefined) {\n return;\n }\n }\n return value as P;\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.GetProperty;\n }\n}\n\nRegisterClass(FlowGraphBlockNames.GetProperty, FlowGraphGetPropertyBlock);\n"]}
1
+ {"version":3,"file":"flowGraphGetPropertyBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,oCAA0C;AAChE,OAAO,EAAE,aAAa,EAAE,mCAA4B;AAEpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAmBhF;;;;;;;GAOG;AACH,MAAM,OAAO,yBAAuE,SAAQ,6BAAgC;IAiBxH;IACI;;OAEG;IACa,MAAkD;QAElE,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAFX,WAAM,GAAN,MAAM,CAA4C;QAGlE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3E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AC;IACtB,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 { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport type { FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport type { FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\nimport { FlowGraphCachedOperationBlock } from \"./flowGraphCachedOperationBlock\";\n\nexport interface IFlowGraphGetPropertyBlockConfiguration<O extends FlowGraphAssetType> extends IFlowGraphBlockConfiguration {\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 object?: AssetType<O>;\n\n /**\n * If true, the block will reset the output to the default value when the target asset is undefined.\n */\n resetToDefaultWhenUndefined?: boolean;\n}\n\n/**\n * This block will deliver a property of an asset, based on the property name and an input asset.\n * The property name can include dots (\".\"), which will be interpreted as a path to the property.\n *\n * For example, with an input of a mesh asset, the property name \"position.x\" will deliver 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) rather than providing a mesh as object and then getting the material from it.\n */\nexport class FlowGraphGetPropertyBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphCachedOperationBlock<P> {\n /**\n * Input connection: The 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 get the value of the property.\n * This will be used if defined, instead of the default get function.\n */\n public readonly customGetFunction: FlowGraphDataConnection<(target: AssetType<O>, propertyName: string, context: FlowGraphContext) => P | undefined>;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphGetPropertyBlockConfiguration<O>\n ) {\n super(RichTypeAny, config);\n this.object = this.registerDataInput(\"object\", RichTypeAny, config.object);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeAny, config.propertyName);\n this.customGetFunction = this.registerDataInput(\"customGetFunction\", RichTypeAny);\n }\n\n public override _doOperation(context: FlowGraphContext): P | undefined {\n const getter = this.customGetFunction.getValue(context);\n let value;\n if (getter) {\n value = getter(this.object.getValue(context), this.propertyName.getValue(context), context);\n } else {\n const target = this.object.getValue(context);\n const propertyName = this.propertyName.getValue(context);\n value = target && propertyName ? this._getPropertyValue(target, propertyName) : undefined;\n }\n return value;\n }\n\n private _getPropertyValue(target: AssetType<O>, propertyName: string): P | undefined {\n const path = propertyName.split(\".\");\n let value: any = target;\n for (const prop of path) {\n value = value[prop];\n if (value === undefined) {\n return;\n }\n }\n return value as P;\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.GetProperty;\n }\n}\n\nRegisterClass(FlowGraphBlockNames.GetProperty, FlowGraphGetPropertyBlock);\n"]}
@@ -6,6 +6,7 @@ export * from "./flowGraphGetPropertyBlock";
6
6
  export * from "../Execution/flowGraphSetPropertyBlock";
7
7
  export * from "./flowGraphConstantBlock";
8
8
  export * from "./flowGraphGetAssetBlock";
9
+ export * from "./flowGraphDataSwitchBlock";
9
10
  export * from "./Math/index";
10
11
  export * from "./Transformers/index";
11
12
  export * from "./Utils/index";
@@ -6,6 +6,7 @@ export * from "./flowGraphGetPropertyBlock.js";
6
6
  export * from "../Execution/flowGraphSetPropertyBlock.js";
7
7
  export * from "./flowGraphConstantBlock.js";
8
8
  export * from "./flowGraphGetAssetBlock.js";
9
+ export * from "./flowGraphDataSwitchBlock.js";
9
10
  // eslint-disable-next-line import/no-internal-modules
10
11
  export * from "./Math/index.js";
11
12
  // eslint-disable-next-line import/no-internal-modules
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Data/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,sDAAsD;AACtD,cAAc,cAAc,CAAC;AAC7B,sDAAsD;AACtD,cAAc,sBAAsB,CAAC;AACrC,sDAAsD;AACtD,cAAc,eAAe,CAAC","sourcesContent":["export * from \"./flowGraphConditionalDataBlock\";\r\nexport * from \"./flowGraphGetVariableBlock\";\r\nexport * from \"../Execution/flowGraphSetVariableBlock\";\r\nexport * from \"./flowGraphTransformCoordinatesSystemBlock\";\r\nexport * from \"./flowGraphGetPropertyBlock\";\r\nexport * from \"../Execution/flowGraphSetPropertyBlock\";\r\nexport * from \"./flowGraphConstantBlock\";\r\nexport * from \"./flowGraphGetAssetBlock\";\r\n// eslint-disable-next-line import/no-internal-modules\r\nexport * from \"./Math/index\";\r\n// eslint-disable-next-line import/no-internal-modules\r\nexport * from \"./Transformers/index\";\r\n// eslint-disable-next-line import/no-internal-modules\r\nexport * from \"./Utils/index\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Data/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,sDAAsD;AACtD,cAAc,cAAc,CAAC;AAC7B,sDAAsD;AACtD,cAAc,sBAAsB,CAAC;AACrC,sDAAsD;AACtD,cAAc,eAAe,CAAC","sourcesContent":["export * from \"./flowGraphConditionalDataBlock\";\r\nexport * from \"./flowGraphGetVariableBlock\";\r\nexport * from \"../Execution/flowGraphSetVariableBlock\";\r\nexport * from \"./flowGraphTransformCoordinatesSystemBlock\";\r\nexport * from \"./flowGraphGetPropertyBlock\";\r\nexport * from \"../Execution/flowGraphSetPropertyBlock\";\r\nexport * from \"./flowGraphConstantBlock\";\r\nexport * from \"./flowGraphGetAssetBlock\";\r\nexport * from \"./flowGraphDataSwitchBlock\";\r\n// eslint-disable-next-line import/no-internal-modules\r\nexport * from \"./Math/index\";\r\n// eslint-disable-next-line import/no-internal-modules\r\nexport * from \"./Transformers/index\";\r\n// eslint-disable-next-line import/no-internal-modules\r\nexport * from \"./Utils/index\";\r\n"]}
@@ -64,6 +64,7 @@ export declare class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecution
64
64
  * @param context
65
65
  */
66
66
  _preparePendingTasks(context: FlowGraphContext): void;
67
+ protected _reportError(context: FlowGraphContext, error: string | Error): void;
67
68
  /**
68
69
  * @internal
69
70
  */