@onerjs/smart-filters 8.25.2 → 8.25.3

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 (251) hide show
  1. package/dist/IDisposable.d.ts +10 -0
  2. package/dist/IDisposable.d.ts.map +1 -0
  3. package/dist/IDisposable.js +2 -0
  4. package/dist/IDisposable.js.map +1 -0
  5. package/dist/blockFoundation/aggregateBlock.d.ts +56 -0
  6. package/dist/blockFoundation/aggregateBlock.d.ts.map +1 -0
  7. package/dist/blockFoundation/aggregateBlock.js +130 -0
  8. package/dist/blockFoundation/aggregateBlock.js.map +1 -0
  9. package/dist/blockFoundation/baseBlock.d.ts +176 -0
  10. package/dist/blockFoundation/baseBlock.d.ts.map +1 -0
  11. package/dist/blockFoundation/baseBlock.js +276 -0
  12. package/dist/blockFoundation/baseBlock.js.map +1 -0
  13. package/dist/blockFoundation/customAggregateBlock.d.ts +38 -0
  14. package/dist/blockFoundation/customAggregateBlock.d.ts.map +1 -0
  15. package/dist/blockFoundation/customAggregateBlock.js +63 -0
  16. package/dist/blockFoundation/customAggregateBlock.js.map +1 -0
  17. package/dist/blockFoundation/customShaderBlock.d.ts +73 -0
  18. package/dist/blockFoundation/customShaderBlock.d.ts.map +1 -0
  19. package/dist/blockFoundation/customShaderBlock.js +232 -0
  20. package/dist/blockFoundation/customShaderBlock.js.map +1 -0
  21. package/dist/blockFoundation/disableableShaderBlock.d.ts +56 -0
  22. package/dist/blockFoundation/disableableShaderBlock.d.ts.map +1 -0
  23. package/dist/blockFoundation/disableableShaderBlock.js +68 -0
  24. package/dist/blockFoundation/disableableShaderBlock.js.map +1 -0
  25. package/dist/blockFoundation/index.d.ts +10 -0
  26. package/dist/blockFoundation/index.d.ts.map +1 -0
  27. package/dist/blockFoundation/index.js +8 -0
  28. package/dist/blockFoundation/index.js.map +1 -0
  29. package/dist/blockFoundation/inputBlock.d.ts +127 -0
  30. package/dist/blockFoundation/inputBlock.d.ts.map +1 -0
  31. package/dist/blockFoundation/inputBlock.deserializer.d.ts +12 -0
  32. package/dist/blockFoundation/inputBlock.deserializer.d.ts.map +1 -0
  33. package/dist/blockFoundation/inputBlock.deserializer.js +65 -0
  34. package/dist/blockFoundation/inputBlock.deserializer.js.map +1 -0
  35. package/dist/blockFoundation/inputBlock.js +89 -0
  36. package/dist/blockFoundation/inputBlock.js.map +1 -0
  37. package/dist/blockFoundation/inputBlock.serialization.types.d.ts +105 -0
  38. package/dist/blockFoundation/inputBlock.serialization.types.d.ts.map +1 -0
  39. package/dist/blockFoundation/inputBlock.serialization.types.js +2 -0
  40. package/dist/blockFoundation/inputBlock.serialization.types.js.map +1 -0
  41. package/dist/blockFoundation/inputBlock.serializer.d.ts +6 -0
  42. package/dist/blockFoundation/inputBlock.serializer.d.ts.map +1 -0
  43. package/dist/blockFoundation/inputBlock.serializer.js +130 -0
  44. package/dist/blockFoundation/inputBlock.serializer.js.map +1 -0
  45. package/dist/blockFoundation/outputBlock.d.ts +47 -0
  46. package/dist/blockFoundation/outputBlock.d.ts.map +1 -0
  47. package/dist/blockFoundation/outputBlock.js +123 -0
  48. package/dist/blockFoundation/outputBlock.js.map +1 -0
  49. package/dist/blockFoundation/shaderBlock.d.ts +64 -0
  50. package/dist/blockFoundation/shaderBlock.d.ts.map +1 -0
  51. package/dist/blockFoundation/shaderBlock.js +125 -0
  52. package/dist/blockFoundation/shaderBlock.js.map +1 -0
  53. package/dist/blockFoundation/textureOptions.d.ts +47 -0
  54. package/dist/blockFoundation/textureOptions.d.ts.map +1 -0
  55. package/dist/blockFoundation/textureOptions.js +37 -0
  56. package/dist/blockFoundation/textureOptions.js.map +1 -0
  57. package/dist/command/command.d.ts +48 -0
  58. package/dist/command/command.d.ts.map +1 -0
  59. package/dist/command/command.js +15 -0
  60. package/dist/command/command.js.map +1 -0
  61. package/dist/command/commandBuffer.d.ts +40 -0
  62. package/dist/command/commandBuffer.d.ts.map +1 -0
  63. package/dist/command/commandBuffer.js +58 -0
  64. package/dist/command/commandBuffer.js.map +1 -0
  65. package/dist/command/commandBufferDebugger.d.ts +7 -0
  66. package/dist/command/commandBufferDebugger.d.ts.map +1 -0
  67. package/dist/command/commandBufferDebugger.js +13 -0
  68. package/dist/command/commandBufferDebugger.js.map +1 -0
  69. package/dist/command/index.d.ts +6 -0
  70. package/dist/command/index.d.ts.map +1 -0
  71. package/dist/command/index.js +8 -0
  72. package/dist/command/index.js.map +1 -0
  73. package/dist/connection/connectionPoint.d.ts +110 -0
  74. package/dist/connection/connectionPoint.d.ts.map +1 -0
  75. package/dist/connection/connectionPoint.js +154 -0
  76. package/dist/connection/connectionPoint.js.map +1 -0
  77. package/dist/connection/connectionPointCompatibilityState.d.ts +20 -0
  78. package/dist/connection/connectionPointCompatibilityState.d.ts.map +1 -0
  79. package/dist/connection/connectionPointCompatibilityState.js +32 -0
  80. package/dist/connection/connectionPointCompatibilityState.js.map +1 -0
  81. package/dist/connection/connectionPointDirection.d.ts +10 -0
  82. package/dist/connection/connectionPointDirection.d.ts.map +1 -0
  83. package/dist/connection/connectionPointDirection.js +11 -0
  84. package/dist/connection/connectionPointDirection.js.map +1 -0
  85. package/dist/connection/connectionPointType.d.ts +29 -0
  86. package/dist/connection/connectionPointType.d.ts.map +1 -0
  87. package/dist/connection/connectionPointType.js +19 -0
  88. package/dist/connection/connectionPointType.js.map +1 -0
  89. package/dist/connection/connectionPointWithDefault.d.ts +23 -0
  90. package/dist/connection/connectionPointWithDefault.d.ts.map +1 -0
  91. package/dist/connection/connectionPointWithDefault.js +19 -0
  92. package/dist/connection/connectionPointWithDefault.js.map +1 -0
  93. package/dist/connection/index.d.ts +8 -0
  94. package/dist/connection/index.d.ts.map +1 -0
  95. package/dist/connection/index.js +7 -0
  96. package/dist/connection/index.js.map +1 -0
  97. package/dist/editorUtils/editableInPropertyPage.d.ts +80 -0
  98. package/dist/editorUtils/editableInPropertyPage.d.ts.map +1 -0
  99. package/dist/editorUtils/editableInPropertyPage.js +42 -0
  100. package/dist/editorUtils/editableInPropertyPage.js.map +1 -0
  101. package/dist/editorUtils/index.d.ts +3 -0
  102. package/dist/editorUtils/index.d.ts.map +1 -0
  103. package/dist/editorUtils/index.js +4 -0
  104. package/dist/editorUtils/index.js.map +1 -0
  105. package/dist/index.d.ts +13 -0
  106. package/dist/index.d.ts.map +1 -0
  107. package/dist/index.js +14 -0
  108. package/dist/index.js.map +1 -0
  109. package/dist/optimization/dependencyGraph.d.ts +31 -0
  110. package/dist/optimization/dependencyGraph.d.ts.map +1 -0
  111. package/dist/optimization/dependencyGraph.js +78 -0
  112. package/dist/optimization/dependencyGraph.js.map +1 -0
  113. package/dist/optimization/index.d.ts +2 -0
  114. package/dist/optimization/index.d.ts.map +1 -0
  115. package/dist/optimization/index.js +2 -0
  116. package/dist/optimization/index.js.map +1 -0
  117. package/dist/optimization/optimizedShaderBlock.d.ts +75 -0
  118. package/dist/optimization/optimizedShaderBlock.d.ts.map +1 -0
  119. package/dist/optimization/optimizedShaderBlock.js +105 -0
  120. package/dist/optimization/optimizedShaderBlock.js.map +1 -0
  121. package/dist/optimization/smartFilterOptimizer.d.ts +126 -0
  122. package/dist/optimization/smartFilterOptimizer.d.ts.map +1 -0
  123. package/dist/optimization/smartFilterOptimizer.js +666 -0
  124. package/dist/optimization/smartFilterOptimizer.js.map +1 -0
  125. package/dist/runtime/index.d.ts +8 -0
  126. package/dist/runtime/index.d.ts.map +1 -0
  127. package/dist/runtime/index.js +7 -0
  128. package/dist/runtime/index.js.map +1 -0
  129. package/dist/runtime/renderTargetGenerator.d.ts +43 -0
  130. package/dist/runtime/renderTargetGenerator.d.ts.map +1 -0
  131. package/dist/runtime/renderTargetGenerator.js +169 -0
  132. package/dist/runtime/renderTargetGenerator.js.map +1 -0
  133. package/dist/runtime/shaderRuntime.d.ts +103 -0
  134. package/dist/runtime/shaderRuntime.d.ts.map +1 -0
  135. package/dist/runtime/shaderRuntime.js +132 -0
  136. package/dist/runtime/shaderRuntime.js.map +1 -0
  137. package/dist/runtime/smartFilterRuntime.d.ts +69 -0
  138. package/dist/runtime/smartFilterRuntime.d.ts.map +1 -0
  139. package/dist/runtime/smartFilterRuntime.js +63 -0
  140. package/dist/runtime/smartFilterRuntime.js.map +1 -0
  141. package/dist/runtime/strongRef.d.ts +16 -0
  142. package/dist/runtime/strongRef.d.ts.map +1 -0
  143. package/dist/runtime/strongRef.js +9 -0
  144. package/dist/runtime/strongRef.js.map +1 -0
  145. package/dist/serialization/importCustomBlockDefinition.d.ts +15 -0
  146. package/dist/serialization/importCustomBlockDefinition.d.ts.map +1 -0
  147. package/dist/serialization/importCustomBlockDefinition.js +76 -0
  148. package/dist/serialization/importCustomBlockDefinition.js.map +1 -0
  149. package/dist/serialization/index.d.ts +9 -0
  150. package/dist/serialization/index.d.ts.map +1 -0
  151. package/dist/serialization/index.js +11 -0
  152. package/dist/serialization/index.js.map +1 -0
  153. package/dist/serialization/serializedBlockDefinition.d.ts +12 -0
  154. package/dist/serialization/serializedBlockDefinition.d.ts.map +1 -0
  155. package/dist/serialization/serializedBlockDefinition.js +2 -0
  156. package/dist/serialization/serializedBlockDefinition.js.map +1 -0
  157. package/dist/serialization/serializedShaderBlockDefinition.d.ts +7 -0
  158. package/dist/serialization/serializedShaderBlockDefinition.d.ts.map +1 -0
  159. package/dist/serialization/serializedShaderBlockDefinition.js +2 -0
  160. package/dist/serialization/serializedShaderBlockDefinition.js.map +1 -0
  161. package/dist/serialization/serializedSmartFilter.d.ts +6 -0
  162. package/dist/serialization/serializedSmartFilter.d.ts.map +1 -0
  163. package/dist/serialization/serializedSmartFilter.js +2 -0
  164. package/dist/serialization/serializedSmartFilter.js.map +1 -0
  165. package/dist/serialization/smartFilterDeserializer.d.ts +34 -0
  166. package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -0
  167. package/dist/serialization/smartFilterDeserializer.js +141 -0
  168. package/dist/serialization/smartFilterDeserializer.js.map +1 -0
  169. package/dist/serialization/smartFilterSerializer.d.ts +23 -0
  170. package/dist/serialization/smartFilterSerializer.d.ts.map +1 -0
  171. package/dist/serialization/smartFilterSerializer.js +95 -0
  172. package/dist/serialization/smartFilterSerializer.js.map +1 -0
  173. package/dist/serialization/v1/defaultBlockSerializer.d.ts +9 -0
  174. package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -0
  175. package/dist/serialization/v1/defaultBlockSerializer.js +19 -0
  176. package/dist/serialization/v1/defaultBlockSerializer.js.map +1 -0
  177. package/dist/serialization/v1/index.d.ts +4 -0
  178. package/dist/serialization/v1/index.d.ts.map +1 -0
  179. package/dist/serialization/v1/index.js +5 -0
  180. package/dist/serialization/v1/index.js.map +1 -0
  181. package/dist/serialization/v1/shaderBlockSerialization.types.d.ts +73 -0
  182. package/dist/serialization/v1/shaderBlockSerialization.types.d.ts.map +1 -0
  183. package/dist/serialization/v1/shaderBlockSerialization.types.js +7 -0
  184. package/dist/serialization/v1/shaderBlockSerialization.types.js.map +1 -0
  185. package/dist/serialization/v1/smartFilterSerialization.types.d.ts +98 -0
  186. package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -0
  187. package/dist/serialization/v1/smartFilterSerialization.types.js +2 -0
  188. package/dist/serialization/v1/smartFilterSerialization.types.js.map +1 -0
  189. package/dist/smartFilter.d.ts +118 -0
  190. package/dist/smartFilter.d.ts.map +1 -0
  191. package/dist/smartFilter.js +169 -0
  192. package/dist/smartFilter.js.map +1 -0
  193. package/dist/utils/buildTools/buildShaders.d.ts +9 -0
  194. package/dist/utils/buildTools/buildShaders.d.ts.map +1 -0
  195. package/dist/utils/buildTools/buildShaders.js +13 -0
  196. package/dist/utils/buildTools/buildShaders.js.map +1 -0
  197. package/dist/utils/buildTools/convertGlslIntoBlock.d.ts +9 -0
  198. package/dist/utils/buildTools/convertGlslIntoBlock.d.ts.map +1 -0
  199. package/dist/utils/buildTools/convertGlslIntoBlock.js +346 -0
  200. package/dist/utils/buildTools/convertGlslIntoBlock.js.map +1 -0
  201. package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts +26 -0
  202. package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts.map +1 -0
  203. package/dist/utils/buildTools/convertGlslIntoShaderProgram.js +141 -0
  204. package/dist/utils/buildTools/convertGlslIntoShaderProgram.js.map +1 -0
  205. package/dist/utils/buildTools/convertShaders.d.ts +16 -0
  206. package/dist/utils/buildTools/convertShaders.d.ts.map +1 -0
  207. package/dist/utils/buildTools/convertShaders.js +62 -0
  208. package/dist/utils/buildTools/convertShaders.js.map +1 -0
  209. package/dist/utils/buildTools/shaderCode.types.d.ts +51 -0
  210. package/dist/utils/buildTools/shaderCode.types.d.ts.map +1 -0
  211. package/dist/utils/buildTools/shaderCode.types.js +2 -0
  212. package/dist/utils/buildTools/shaderCode.types.js.map +1 -0
  213. package/dist/utils/buildTools/shaderConverter.d.ts +77 -0
  214. package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -0
  215. package/dist/utils/buildTools/shaderConverter.js +297 -0
  216. package/dist/utils/buildTools/shaderConverter.js.map +1 -0
  217. package/dist/utils/buildTools/watchShaders.d.ts +9 -0
  218. package/dist/utils/buildTools/watchShaders.d.ts.map +1 -0
  219. package/dist/utils/buildTools/watchShaders.js +39 -0
  220. package/dist/utils/buildTools/watchShaders.js.map +1 -0
  221. package/dist/utils/index.d.ts +4 -0
  222. package/dist/utils/index.d.ts.map +1 -0
  223. package/dist/utils/index.js +4 -0
  224. package/dist/utils/index.js.map +1 -0
  225. package/dist/utils/renderTargetUtils.d.ts +14 -0
  226. package/dist/utils/renderTargetUtils.d.ts.map +1 -0
  227. package/dist/utils/renderTargetUtils.js +23 -0
  228. package/dist/utils/renderTargetUtils.js.map +1 -0
  229. package/dist/utils/shaderCodeUtils.d.ts +91 -0
  230. package/dist/utils/shaderCodeUtils.d.ts.map +1 -0
  231. package/dist/utils/shaderCodeUtils.js +111 -0
  232. package/dist/utils/shaderCodeUtils.js.map +1 -0
  233. package/dist/utils/textureLoaders.d.ts +16 -0
  234. package/dist/utils/textureLoaders.d.ts.map +1 -0
  235. package/dist/utils/textureLoaders.js +22 -0
  236. package/dist/utils/textureLoaders.js.map +1 -0
  237. package/dist/utils/textureUtils.d.ts +13 -0
  238. package/dist/utils/textureUtils.d.ts.map +1 -0
  239. package/dist/utils/textureUtils.js +25 -0
  240. package/dist/utils/textureUtils.js.map +1 -0
  241. package/dist/utils/uniqueIdGenerator.d.ts +19 -0
  242. package/dist/utils/uniqueIdGenerator.d.ts.map +1 -0
  243. package/dist/utils/uniqueIdGenerator.js +27 -0
  244. package/dist/utils/uniqueIdGenerator.js.map +1 -0
  245. package/dist/version.d.ts +5 -0
  246. package/dist/version.d.ts.map +1 -0
  247. package/dist/version.js +5 -0
  248. package/dist/version.js.map +1 -0
  249. package/package.json +1 -1
  250. package/src/optimization/smartFilterOptimizer.ts +305 -158
  251. package/src/version.ts +1 -1
@@ -0,0 +1,9 @@
1
+ import type { SerializeBlockV1 } from "./smartFilterSerialization.types.js";
2
+ /**
3
+ * The default V1 block serializer which can be used for any block that relies only on ConnectionPoints
4
+ * and does not have any constructor parameters or class properties that need to be serialized.
5
+ * @param block - The block to serialize
6
+ * @returns The serialized block
7
+ */
8
+ export declare const DefaultBlockSerializer: SerializeBlockV1;
9
+ //# sourceMappingURL=defaultBlockSerializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultBlockSerializer.d.ts","sourceRoot":"","sources":["../../../src/serialization/v1/defaultBlockSerializer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAEhG;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,gBAUpC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { ShaderBlock } from "../../blockFoundation/shaderBlock.js";
2
+ /**
3
+ * The default V1 block serializer which can be used for any block that relies only on ConnectionPoints
4
+ * and does not have any constructor parameters or class properties that need to be serialized.
5
+ * @param block - The block to serialize
6
+ * @returns The serialized block
7
+ */
8
+ export const DefaultBlockSerializer = (block) => {
9
+ return {
10
+ name: block.name,
11
+ uniqueId: block.uniqueId,
12
+ blockType: block.blockType,
13
+ namespace: block.namespace,
14
+ comments: block.comments,
15
+ data: undefined,
16
+ outputTextureOptions: block instanceof ShaderBlock ? block.outputTextureOptions : undefined,
17
+ };
18
+ };
19
+ //# sourceMappingURL=defaultBlockSerializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultBlockSerializer.js","sourceRoot":"","sources":["../../../src/serialization/v1/defaultBlockSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAInE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAqB,CAAC,KAAgB,EAAsB,EAAE;IAC7F,OAAO;QACH,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,IAAI,EAAE,SAAS;QACf,oBAAoB,EAAE,KAAK,YAAY,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS;KAC9F,CAAC;AACN,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./defaultBlockSerializer.js";
2
+ export { DefaultBlockSerializer as defaultBlockSerializer } from "./defaultBlockSerializer.js";
3
+ export * from "./smartFilterSerialization.types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/serialization/v1/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAE5C,OAAO,EAAE,sBAAsB,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,cAAc,qCAAqC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from "./defaultBlockSerializer.js";
2
+ // Back compat for when camelCase was used
3
+ export { DefaultBlockSerializer as defaultBlockSerializer } from "./defaultBlockSerializer.js";
4
+ export * from "./smartFilterSerialization.types.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/serialization/v1/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,0CAA0C;AAC1C,OAAO,EAAE,sBAAsB,IAAI,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC/F,cAAc,qCAAqC,CAAC"}
@@ -0,0 +1,73 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Data Types Used For Block Serialization
4
+ * ----------------------------------------------------------------------------
5
+ */
6
+ import type { Nullable } from "@onerjs/core/types.js";
7
+ import type { AllConnectionPointTypes, ConnectionPointValue } from "../../connection/connectionPointType.js";
8
+ import type { ShaderProgram } from "../../utils/shaderCodeUtils.js";
9
+ /**
10
+ * The V1 definition of a serialized shader block. This block definition is loaded by a CustomShaderBlock and defines how a
11
+ * blockType works. This should not be confused with an ISerializedBockV1, which is a serialized instance of a block in a
12
+ * serialized SmartFilter graph. It is referenced by blockType in a serialized SmartFilter.
13
+ */
14
+ export type SerializedShaderBlockDefinitionV1 = {
15
+ /**
16
+ * Which type of serialized data this is.
17
+ */
18
+ format: "shaderBlockDefinition";
19
+ /**
20
+ * The version of the block definition format (format of the serialized data, not the version of the block definition itself).
21
+ */
22
+ formatVersion: 1;
23
+ /**
24
+ * The type used to refer to the block in serialized SmartFilters and in the editor UI.
25
+ * The application doing the deserialization will use this to instantiate the correct block definition.
26
+ * Block types are expected to be unique and their behavior should be semantically equivalent across implementations
27
+ * (their results must be similar enough that the differences are not perceivable).
28
+ */
29
+ blockType: string;
30
+ /**
31
+ * The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
32
+ * By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
33
+ */
34
+ namespace: Nullable<string>;
35
+ /**
36
+ * The shader program for the block.
37
+ */
38
+ shaderProgram: ShaderProgram;
39
+ /**
40
+ * The input connection points of the block.
41
+ */
42
+ inputConnectionPoints: SerializedInputConnectionPointV1[];
43
+ /**
44
+ * If true, the optimizer will not attempt to optimize this block.
45
+ */
46
+ disableOptimization: boolean;
47
+ };
48
+ /**
49
+ * Possible V1 auto bind values for input connection points.
50
+ */
51
+ export type InputAutoBindV1 = "outputResolution" | "outputAspectRatio";
52
+ /**
53
+ * A V1 input connection point of a serialized block definition.
54
+ */
55
+ export type SerializedInputConnectionPointV1<U extends AllConnectionPointTypes = AllConnectionPointTypes> = {
56
+ /**
57
+ * The name of the connection point.
58
+ */
59
+ name: string;
60
+ /**
61
+ * The type of the connection point.
62
+ */
63
+ type: U;
64
+ /**
65
+ * The optional default value of the connection point.
66
+ */
67
+ defaultValue?: ConnectionPointValue<U>;
68
+ /**
69
+ * If supplied, the input will be automatically bound to this value, instead of creating an input connection point.
70
+ */
71
+ autoBind?: InputAutoBindV1;
72
+ };
73
+ //# sourceMappingURL=shaderBlockSerialization.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shaderBlockSerialization.types.d.ts","sourceRoot":"","sources":["../../../src/serialization/v1/shaderBlockSerialization.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,8BAAsB;AAC9C,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC7G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,MAAM,iCAAiC,GAAG;IAC5C;;OAEG;IACH,MAAM,EAAE,uBAAuB,CAAC;IAEhC;;OAEG;IACH,aAAa,EAAE,CAAC,CAAC;IAEjB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IAE5B;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;OAEG;IACH,qBAAqB,EAAE,gCAAgC,EAAE,CAAC;IAE1D;;OAEG;IACH,mBAAmB,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAEvE;;GAEG;AACH,MAAM,MAAM,gCAAgC,CAAC,CAAC,SAAS,uBAAuB,GAAG,uBAAuB,IAAI;IACxG;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAEvC;;OAEG;IACH,QAAQ,CAAC,EAAE,eAAe,CAAC;CAC9B,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Data Types Used For Block Serialization
4
+ * ----------------------------------------------------------------------------
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=shaderBlockSerialization.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shaderBlockSerialization.types.js","sourceRoot":"","sources":["../../../src/serialization/v1/shaderBlockSerialization.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,98 @@
1
+ import type { Nullable } from "@onerjs/core/types.js";
2
+ import type { BaseBlock } from "../../blockFoundation/baseBlock.js";
3
+ import type { SmartFilter } from "../../smartFilter.js";
4
+ import type { ThinEngine } from "@onerjs/core/Engines/thinEngine.js";
5
+ import type { IEditorData } from "shared-ui-components/nodeGraphSystem/interfaces/nodeLocationInfo.js";
6
+ import type { SmartFilterDeserializer } from "../smartFilterDeserializer.js";
7
+ import type { OutputTextureOptions } from "../../blockFoundation/textureOptions.js";
8
+ /**
9
+ * ----------------------------------------------------------------------------
10
+ * Serialized Data Types
11
+ * ----------------------------------------------------------------------------
12
+ */
13
+ /**
14
+ * V1 Serialized Smart Filter
15
+ */
16
+ export type SerializedSmartFilterV1 = {
17
+ /** Which type of serialized data this is. */
18
+ format: "smartFilter";
19
+ /** The format version of the serialized data (not the version of the SmartFilter itself).*/
20
+ formatVersion: 1;
21
+ /** The SmartFilter name */
22
+ name: string;
23
+ /** The namespace of the SmartFilter */
24
+ namespace: Nullable<string>;
25
+ /** The SmartFilter comments */
26
+ comments: Nullable<string>;
27
+ /** The editor data for the SmartFilter */
28
+ editorData: Nullable<IEditorData>;
29
+ /** The serialized blocks */
30
+ blocks: ISerializedBlockV1[];
31
+ /** The serialized connections */
32
+ connections: ISerializedConnectionV1[];
33
+ };
34
+ /**
35
+ * V1 format of a block in a serialized Smart Filter.
36
+ * Not to be confused with a SerializedBlockDefinitionV1 which serializes the definition of a CustomShaderBlock.
37
+ */
38
+ export interface ISerializedBlockV1 {
39
+ /** The name of the block */
40
+ name: string;
41
+ /** The namespace of the block */
42
+ namespace: Nullable<string>;
43
+ /** The unique ID of the block - correlates with the ID in the editorData for block position, etc. */
44
+ uniqueId: number;
45
+ /** The blockType of the block - used to determine how to instantiate the block during deserialization */
46
+ blockType: string;
47
+ /** The comments for the block */
48
+ comments: Nullable<string>;
49
+ /** The OutputTextureOptions for serialized ShaderBlocks */
50
+ outputTextureOptions?: OutputTextureOptions;
51
+ /** Block specific serialized data */
52
+ data: any;
53
+ }
54
+ /**
55
+ * V1 Serialized Connection
56
+ */
57
+ export interface ISerializedConnectionV1 {
58
+ /** The uniqueId of the block that the connection is to */
59
+ outputBlock: number;
60
+ /** The name of the connectionPoint on the outputBlock */
61
+ outputConnectionPoint: string;
62
+ /** The uniqueId of the block that the connection is from */
63
+ inputBlock: number;
64
+ /** The name of the connectionPoint on the inputBlock */
65
+ inputConnectionPoint: string;
66
+ }
67
+ /**
68
+ * ----------------------------------------------------------------------------
69
+ * Serializer Types
70
+ * ----------------------------------------------------------------------------
71
+ */
72
+ /**
73
+ * A function that serializes a block to a V1 serialized block object
74
+ */
75
+ export type SerializeBlockV1 = (block: BaseBlock) => ISerializedBlockV1;
76
+ /**
77
+ * A V1 serializer for blocks in a SmartFilter
78
+ */
79
+ export interface IBlockSerializerV1 {
80
+ /** The blockType of the block that this serializer can serialize */
81
+ blockType: string;
82
+ /** The function that serializes the block in the Smart Filter */
83
+ serialize: SerializeBlockV1;
84
+ }
85
+ /**
86
+ * ----------------------------------------------------------------------------
87
+ * Deserializer Types
88
+ * ----------------------------------------------------------------------------
89
+ */
90
+ /**
91
+ * A function that deserializes a V1 block in a SmartFilter
92
+ */
93
+ export type DeserializeBlockV1 = (smartFilter: SmartFilter, serializedBlock: ISerializedBlockV1, engine: ThinEngine, smartFilterDeserializer: SmartFilterDeserializer) => Promise<BaseBlock>;
94
+ /**
95
+ * A function that optionally deserializes a block from a V1 serialized block object, returning null if it cannot
96
+ */
97
+ export type OptionalBlockDeserializerV1 = (smartFilter: SmartFilter, serializedBlock: ISerializedBlockV1, engine: ThinEngine) => Promise<Nullable<BaseBlock>>;
98
+ //# sourceMappingURL=smartFilterSerialization.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartFilterSerialization.types.d.ts","sourceRoot":"","sources":["../../../src/serialization/v1/smartFilterSerialization.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,8BAAsB;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,2CAAmC;AAC7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qEAAqE,CAAC;AACvG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAEpF;;;;GAIG;AAEH;;GAEG;AACH,MAA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;AAExE;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAElB,iEAAiE;IACjE,SAAS,EAAE,gBAAgB,CAAC;CAC/B;AAED;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC7B,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,kBAAkB,EACnC,MAAM,EAAE,UAAU,EAClB,uBAAuB,EAAE,uBAAuB,KAC/C,OAAO,CAAC,SAAS,CAAC,CAAC;AAExB;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,CAAC,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=smartFilterSerialization.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartFilterSerialization.types.js","sourceRoot":"","sources":["../../../src/serialization/v1/smartFilterSerialization.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,118 @@
1
+ import type { ThinEngine } from "@onerjs/core/Engines/thinEngine.js";
2
+ import type { Nullable } from "@onerjs/core/types.js";
3
+ import type { SmartFilterRuntime } from "./runtime/smartFilterRuntime.js";
4
+ import type { BaseBlock } from "./blockFoundation/baseBlock.js";
5
+ import type { ConnectionPointType } from "./connection/connectionPointType.js";
6
+ import type { ConnectionPoint } from "./connection/connectionPoint.js";
7
+ import { OutputBlock } from "./blockFoundation/outputBlock.js";
8
+ import { InternalSmartFilterRuntime } from "./runtime/smartFilterRuntime.js";
9
+ import { RenderTargetGenerator } from "./runtime/renderTargetGenerator.js";
10
+ import type { IEditorData } from "shared-ui-components/nodeGraphSystem/interfaces/nodeLocationInfo.js";
11
+ import type { IDisposable } from "./IDisposable.js";
12
+ /**
13
+ * Data passed to the initialize function of the blocks.
14
+ */
15
+ export type InitializationData = {
16
+ /**
17
+ * The current smart filter runtime the block is being initialized for.
18
+ */
19
+ readonly runtime: InternalSmartFilterRuntime;
20
+ /**
21
+ * The output block of the smart filter.
22
+ * This is used to determine if a block is linked to the output block so that we can prevent an
23
+ * extra render pass.
24
+ */
25
+ readonly outputBlock: OutputBlock;
26
+ /**
27
+ * The list of promises to wait for during the initialization step.
28
+ */
29
+ readonly initializationPromises: Promise<void>[];
30
+ /**
31
+ * Resources that need to be disposed when the runtime is disposed.
32
+ */
33
+ readonly disposableResources: IDisposable[];
34
+ };
35
+ /**
36
+ * The smart filter class is the main class of the smart filter module.
37
+ *
38
+ * It is responsible for managing a graph of smart filter blocks.
39
+ *
40
+ * It is also responsible for creating the runtime associated to the current state of the filter.
41
+ */
42
+ export declare class SmartFilter {
43
+ /**
44
+ * The friendly name of the smart filter.
45
+ */
46
+ readonly name: string;
47
+ /**
48
+ * The namespace of the smart filter.
49
+ */
50
+ readonly namespace: Nullable<string>;
51
+ /**
52
+ * The smart filter output (input connection point of the output block...).
53
+ *
54
+ * This is where the smart filter final block should be connected to in order to be visible on screen.
55
+ */
56
+ readonly output: ConnectionPoint<ConnectionPointType.Texture>;
57
+ /**
58
+ * The output block of the smart filter.
59
+ */
60
+ readonly outputBlock: OutputBlock;
61
+ /**
62
+ * User defined comments to describe the current smart filter.
63
+ */
64
+ comments: Nullable<string>;
65
+ /**
66
+ * Data used by the smart filter editor.
67
+ */
68
+ editorData: Nullable<IEditorData>;
69
+ private readonly _attachedBlocks;
70
+ /**
71
+ * Creates a new instance of a @see SmartFilter.
72
+ * @param name - The friendly name of the smart filter
73
+ * @param namespace - The namespace of the smart filter
74
+ */
75
+ constructor(name: string, namespace?: Nullable<string>);
76
+ /**
77
+ * @returns the list of blocks attached to the smart filter.
78
+ */
79
+ get attachedBlocks(): ReadonlyArray<BaseBlock>;
80
+ /**
81
+ * @returns The current class name of the smart filter.
82
+ */
83
+ getClassName(): string;
84
+ /**
85
+ * Registers a block to be part of this smart filter.
86
+ * @param block - The block to register on the smart filter
87
+ * @throws if the block is already registered on another smart filter
88
+ * @remarks This function will not register the block if it is already registered on the smart filter.
89
+ */
90
+ registerBlock(block: BaseBlock): void;
91
+ /**
92
+ * Removes the block from the smart filter.
93
+ * @param block - The block to remove from the smart filter
94
+ * @remarks This function will disconnect the block on removal.
95
+ * This Output block cannot be removed.
96
+ */
97
+ removeBlock(block: BaseBlock): void;
98
+ private _generateCommandsAndGatherInitPromises;
99
+ /**
100
+ * Create a new runtime for the current state of the smart filter.
101
+ * @param engine - The Babylon.js engine to use for the runtime
102
+ * @param renderTargetGenerator - The render target generator to use to generate the RTTs for the shader blocks. If not provided, a default one will be created.
103
+ * @returns the runtime that can be used to render the smart filter
104
+ */
105
+ createRuntimeAsync(engine: ThinEngine, renderTargetGenerator?: RenderTargetGenerator): Promise<SmartFilterRuntime>;
106
+ /**
107
+ * Resizes any intermediate textures according to the new size of the render target
108
+ * @param engine - The engine used to render the smart filter
109
+ */
110
+ resize(engine: ThinEngine): void;
111
+ /**
112
+ * @internal
113
+ * Merges all aggregate blocks into the smart filter graph, executes the passed-in work, then restores the aggregate blocks.
114
+ * @param work - The work to execute with the aggregate blocks merged
115
+ */
116
+ _workWithAggregateFreeGraph(work: () => void): void;
117
+ }
118
+ //# sourceMappingURL=smartFilter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartFilter.d.ts","sourceRoot":"","sources":["../src/smartFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,2CAAmC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,8BAAsB;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iCAAiC,CA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I,YAAY,IAAI,MAAM;IAI7B;;;;;OAKG;IACI,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAe5C;;;;;OAKG;IACI,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAc1C,OAAO,CAAC,sCAAsC;IAQ9C;;;;;OAKG;IACU,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,qBAAqB,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAsC/H;;;OAGG;IACI,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAevC;;;;OAIG;IACI,2BAA2B,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI;CAoB7D"}
@@ -0,0 +1,169 @@
1
+ import { OutputBlock } from "./blockFoundation/outputBlock.js";
2
+ import { InternalSmartFilterRuntime } from "./runtime/smartFilterRuntime.js";
3
+ import { RenderTargetGenerator } from "./runtime/renderTargetGenerator.js";
4
+ import { AggregateBlock } from "./blockFoundation/aggregateBlock.js";
5
+ import { ShaderBlock } from "./blockFoundation/shaderBlock.js";
6
+ import { GetBlockOutputTextureSize } from "./utils/textureUtils.js";
7
+ /**
8
+ * How long to wait for shader compilation and texture loading to complete before erroring out.
9
+ */
10
+ const InitializationTimeout = 10000;
11
+ /**
12
+ * The smart filter class is the main class of the smart filter module.
13
+ *
14
+ * It is responsible for managing a graph of smart filter blocks.
15
+ *
16
+ * It is also responsible for creating the runtime associated to the current state of the filter.
17
+ */
18
+ export class SmartFilter {
19
+ /**
20
+ * Creates a new instance of a @see SmartFilter.
21
+ * @param name - The friendly name of the smart filter
22
+ * @param namespace - The namespace of the smart filter
23
+ */
24
+ constructor(name, namespace = null) {
25
+ /**
26
+ * User defined comments to describe the current smart filter.
27
+ */
28
+ this.comments = null;
29
+ /**
30
+ * Data used by the smart filter editor.
31
+ */
32
+ this.editorData = null;
33
+ this.name = name;
34
+ this.namespace = namespace;
35
+ this._attachedBlocks = new Array();
36
+ this.outputBlock = new OutputBlock(this);
37
+ this.output = this.outputBlock.input;
38
+ }
39
+ /**
40
+ * @returns the list of blocks attached to the smart filter.
41
+ */
42
+ get attachedBlocks() {
43
+ return this._attachedBlocks;
44
+ }
45
+ /**
46
+ * @returns The current class name of the smart filter.
47
+ */
48
+ getClassName() {
49
+ return "SmartFilter";
50
+ }
51
+ /**
52
+ * Registers a block to be part of this smart filter.
53
+ * @param block - The block to register on the smart filter
54
+ * @throws if the block is already registered on another smart filter
55
+ * @remarks This function will not register the block if it is already registered on the smart filter.
56
+ */
57
+ registerBlock(block) {
58
+ // It is impossible to attach a block from another filter
59
+ if (block.smartFilter !== this) {
60
+ throw new Error("Block is not part of this smart filter");
61
+ }
62
+ // No need to attach a block several times
63
+ if (this._attachedBlocks.indexOf(block) !== -1) {
64
+ return;
65
+ }
66
+ // Add the block to the list of attached blocks
67
+ this._attachedBlocks.push(block);
68
+ }
69
+ /**
70
+ * Removes the block from the smart filter.
71
+ * @param block - The block to remove from the smart filter
72
+ * @remarks This function will disconnect the block on removal.
73
+ * This Output block cannot be removed.
74
+ */
75
+ removeBlock(block) {
76
+ const attachedBlockIndex = this._attachedBlocks.indexOf(block);
77
+ // The block can only be removed if it is not the output block
78
+ // and if it is attached to the smart filter
79
+ if (attachedBlockIndex > -1 && !block.isOutput) {
80
+ // Disconnects all the connections of the block
81
+ block.disconnect();
82
+ // Removes the block from the list of attached blocks
83
+ this._attachedBlocks.splice(attachedBlockIndex, 1);
84
+ }
85
+ }
86
+ _generateCommandsAndGatherInitPromises(initializationData) {
87
+ const outputBlock = this.outputBlock;
88
+ outputBlock.visit(initializationData, (block, initializationData) => {
89
+ block.generateCommandsAndGatherInitPromises(initializationData, outputBlock.input.connectedTo?.ownerBlock === block);
90
+ });
91
+ }
92
+ /**
93
+ * Create a new runtime for the current state of the smart filter.
94
+ * @param engine - The Babylon.js engine to use for the runtime
95
+ * @param renderTargetGenerator - The render target generator to use to generate the RTTs for the shader blocks. If not provided, a default one will be created.
96
+ * @returns the runtime that can be used to render the smart filter
97
+ */
98
+ async createRuntimeAsync(engine, renderTargetGenerator) {
99
+ const runtime = new InternalSmartFilterRuntime(engine);
100
+ const initializationData = {
101
+ runtime,
102
+ outputBlock: this.outputBlock,
103
+ initializationPromises: [],
104
+ disposableResources: [],
105
+ };
106
+ this._workWithAggregateFreeGraph(() => {
107
+ this.outputBlock.prepareForRuntime();
108
+ renderTargetGenerator = renderTargetGenerator ?? new RenderTargetGenerator(false);
109
+ renderTargetGenerator.setOutputTextures(this, initializationData);
110
+ this.outputBlock.propagateRuntimeData();
111
+ this._generateCommandsAndGatherInitPromises(initializationData);
112
+ });
113
+ // Wait for all the blocks to be initialized
114
+ if (initializationData.initializationPromises.length > 0) {
115
+ const timeoutPromise = new Promise((resolve) => setTimeout(resolve, InitializationTimeout, true));
116
+ // eslint-disable-next-line github/no-then
117
+ const initializationPromises = Promise.all(initializationData.initializationPromises).then(() => false);
118
+ const timedOut = await Promise.race([initializationPromises, timeoutPromise]);
119
+ if (timedOut) {
120
+ throw new Error("Initialization promises timed out");
121
+ }
122
+ }
123
+ // Register the resources to dispose when the runtime is disposed
124
+ initializationData.disposableResources.forEach((resource) => runtime.registerResource(resource));
125
+ return runtime;
126
+ }
127
+ /**
128
+ * Resizes any intermediate textures according to the new size of the render target
129
+ * @param engine - The engine used to render the smart filter
130
+ */
131
+ resize(engine) {
132
+ this._workWithAggregateFreeGraph(() => {
133
+ this.outputBlock.visit({}, (block) => {
134
+ if (!(block instanceof ShaderBlock)) {
135
+ return;
136
+ }
137
+ if (block.output.runtimeData?.value) {
138
+ const size = GetBlockOutputTextureSize(this, engine, block.outputTextureOptions);
139
+ block.output.runtimeData.value.resize(size);
140
+ }
141
+ });
142
+ });
143
+ }
144
+ /**
145
+ * @internal
146
+ * Merges all aggregate blocks into the smart filter graph, executes the passed-in work, then restores the aggregate blocks.
147
+ * @param work - The work to execute with the aggregate blocks merged
148
+ */
149
+ _workWithAggregateFreeGraph(work) {
150
+ const mergedAggregateBlocks = [];
151
+ // Merge all aggregate blocks
152
+ this.outputBlock.visit({}, (block, _extraData) => {
153
+ if (block instanceof AggregateBlock) {
154
+ block._mergeIntoSmartFilter(mergedAggregateBlocks);
155
+ }
156
+ });
157
+ try {
158
+ // Do the passed in work
159
+ work();
160
+ }
161
+ finally {
162
+ // Restore all aggregate blocks, even if work throws
163
+ for (const block of mergedAggregateBlocks) {
164
+ block._unmergeFromSmartFilter();
165
+ }
166
+ }
167
+ }
168
+ }
169
+ //# sourceMappingURL=smartFilter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smartFilter.js","sourceRoot":"","sources":["../src/smartFilter.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAGrE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAE/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AAEpE;;GAEG;AACH,MAAM,qBAAqB,GAAG,KAAK,CAAC;AA6BpC;;;;;;GAMG;AACH,MAAM,OAAO,WAAW;IAkCpB;;;;OAIG;IACH,YAAY,IAAY,EAAE,YAA8B,IAAI;QAhB5D;;WAEG;QACI,aAAQ,GAAqB,IAAI,CAAC;QAEzC;;WAEG;QACI,eAAU,GAA0B,IAAI,CAAC;QAS5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,IAAI,CAAC,eAAe,GAAG,IAAI,KAAK,EAAa,CAAC;QAC9C,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,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AE,CAAC;gBACxC,KAAK,CAAC,uBAAuB,EAAE,CAAC;YACpC,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Builds all .glsl files under <shaderPath>.
3
+ * @param shaderPath - The path to the shaders to watch
4
+ * @param smartFiltersCorePath - The path to import the Smart Filters core from
5
+ * @param babylonCorePath - The path to import the Babylon core from (optional)
6
+ * @example node buildShaders.js <shaderPath> @babylonjs/smart-filters
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=buildShaders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildShaders.d.ts","sourceRoot":"","sources":["../../../src/utils/buildTools/buildShaders.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Builds all .glsl files under <shaderPath>.
3
+ * @param shaderPath - The path to the shaders to watch
4
+ * @param smartFiltersCorePath - The path to import the Smart Filters core from
5
+ * @param babylonCorePath - The path to import the Babylon core from (optional)
6
+ * @example node buildShaders.js <shaderPath> @babylonjs/smart-filters
7
+ */
8
+ import { ConvertShaders } from "./convertShaders.js";
9
+ const ExternalArguments = process.argv.slice(2);
10
+ if (ExternalArguments.length >= 2 && ExternalArguments[0] && ExternalArguments[1]) {
11
+ ConvertShaders(ExternalArguments[0], ExternalArguments[1], ExternalArguments[2]);
12
+ }
13
+ //# sourceMappingURL=buildShaders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildShaders.js","sourceRoot":"","sources":["../../../src/utils/buildTools/buildShaders.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,MAAM,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAChD,IAAI,iBAAiB,CAAC,MAAM,IAAI,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChF,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Converts a single shader to a .ts file which exports a Smart Filter block
3
+ * @param fragmentShaderPath - The path to the fragment file for the shader
4
+ * @param smartFiltersCorePath - The path to import the Smart Filters core from
5
+ * @param babylonCorePath - The path to import the Babylon core from (optional)
6
+
7
+ */
8
+ export declare function ConvertGlslIntoBlock(fragmentShaderPath: string, smartFiltersCorePath: string, babylonCorePath?: string): void;
9
+ //# sourceMappingURL=convertGlslIntoBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertGlslIntoBlock.d.ts","sourceRoot":"","sources":["../../../src/utils/buildTools/convertGlslIntoBlock.ts"],"names":[],"mappings":"AAsJA;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAwK7H"}