@onerjs/smart-filters 8.25.1 → 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,89 @@
1
+ import { BaseBlock } from "./baseBlock.js";
2
+ import { CreateStrongRef } from "../runtime/strongRef.js";
3
+ import { ConnectionPointType } from "../connection/connectionPointType.js";
4
+ /**
5
+ * Type predicate to check if value is a strong ref or a direct value
6
+ * @param value - The value to check
7
+ * @returns true if the value is a strong ref, otherwise false
8
+ */
9
+ function IsRuntimeData(value) {
10
+ return value && value.value !== undefined;
11
+ }
12
+ /**
13
+ * Predicate to check if a block is a texture input block.
14
+ * @param block - The block to check
15
+ * @returns true if the block is a texture input block, otherwise false
16
+ */
17
+ export function IsTextureInputBlock(block) {
18
+ return block.type === ConnectionPointType.Texture;
19
+ }
20
+ /**
21
+ * Predicate to check if a block is a disableable block.
22
+ * @param block - The block to check
23
+ * @returns true if the block is a disableable block, otherwise false
24
+ */
25
+ export function IsDisableableShaderBlock(block) {
26
+ return block.disabled !== undefined;
27
+ }
28
+ /**
29
+ * This base class exists to provide a type that the serializer can use to represent
30
+ * any InputBlock without knowing the exact type it is.
31
+ */
32
+ export class InputBlockBase extends BaseBlock {
33
+ }
34
+ /**
35
+ * The class name of the block.
36
+ */
37
+ InputBlockBase.ClassName = "InputBlock";
38
+ /**
39
+ * This represents any inputs used in the graph.
40
+ *
41
+ * This is used to provide a way to connect the graph to the outside world.
42
+ *
43
+ * The value is dynamically set by the user.
44
+ */
45
+ export class InputBlock extends InputBlockBase {
46
+ /**
47
+ * Gets the current value of the input.
48
+ */
49
+ get runtimeValue() {
50
+ return this.output.runtimeData;
51
+ }
52
+ /**
53
+ * Sets the current value of the input.
54
+ */
55
+ set runtimeValue(value) {
56
+ this.output.runtimeData = value;
57
+ }
58
+ /**
59
+ * Creates a new InputBlock.
60
+ * @param smartFilter - The smart filter to add the block to
61
+ * @param name - The friendly name of the block
62
+ * @param type - The type of the input
63
+ * @param initialValue - The initial value of the input
64
+ * @remarks the initial value can either be a strong reference or a value
65
+ */
66
+ constructor(smartFilter, name, type, initialValue) {
67
+ super(smartFilter, name);
68
+ /**
69
+ * Data used by the Editor to store options required for instantiating the block in the Editor.
70
+ */
71
+ this.editorData = null;
72
+ /**
73
+ * Metadata the hosting app wants to track for this input. For example, a hint for what data to
74
+ * assign to this input, or hints about how to draw dynamic UI to allow users to control this value.
75
+ */
76
+ this.appMetadata = null;
77
+ this.type = type;
78
+ // Creates the output connection point
79
+ this.output = this._registerOutputWithDefault("output", type, IsRuntimeData(initialValue) ? initialValue : CreateStrongRef(initialValue));
80
+ // Creates a strong reference to the initial value in case a reference has not been provided
81
+ if (IsRuntimeData(initialValue)) {
82
+ this.runtimeValue = initialValue;
83
+ }
84
+ else {
85
+ this.runtimeValue = CreateStrongRef(initialValue);
86
+ }
87
+ }
88
+ }
89
+ //# sourceMappingURL=inputBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputBlock.js","sourceRoot":"","sources":["../../src/blockFoundation/inputBlock.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAA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a,CAAC,YAAY,CAAC,EAAE,CAAC;YAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACrC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,YAAY,CAAC,CAAC;QACtD,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,105 @@
1
+ import type { Nullable } from "@onerjs/core/types.js";
2
+ import type { ConnectionPointType } from "../connection/connectionPointType.js";
3
+ import type { IColor3Like, IColor4Like, IVector2Like } from "@onerjs/core/Maths/math.like.js";
4
+ /**
5
+ * Data that all serialized InputBlocks share
6
+ */
7
+ export type CommonInputBlockData = {
8
+ /**
9
+ * Metadata the hosting app wants to track for this input. For example, a hint for what data to
10
+ * assign to this input, or hints about how to draw dynamic UI to allow users to control this value.
11
+ */
12
+ appMetadata: unknown;
13
+ };
14
+ /**
15
+ * The data for an InputBlock for ConnectionPointType.Texture inputs
16
+ */
17
+ export type TextureInputBlockData = CommonInputBlockData & {
18
+ /** The type of the input block */
19
+ inputType: ConnectionPointType.Texture;
20
+ /** The URL, if available, of the texture */
21
+ url: Nullable<string>;
22
+ /**
23
+ * If supplied, gives a hint as to which type of texture the URL points to.
24
+ * Default is assumed to be "image"
25
+ */
26
+ urlTypeHint: Nullable<"image" | "video">;
27
+ /**
28
+ * Defines the anisotropic level to use, or default if null
29
+ */
30
+ anisotropicFilteringLevel: Nullable<number>;
31
+ /**
32
+ * Indicates if the Y axis should be flipped, or default if null
33
+ */
34
+ flipY: Nullable<boolean>;
35
+ /**
36
+ * The file extension to use, or default if null.
37
+ */
38
+ forcedExtension: Nullable<string>;
39
+ };
40
+ /**
41
+ * The data for an InputBlock for ConnectionPointType.Boolean inputs
42
+ */
43
+ export type BooleanInputBlockData = CommonInputBlockData & {
44
+ /** The type of the input block */
45
+ inputType: ConnectionPointType.Boolean;
46
+ /** The value of the input block */
47
+ value: boolean;
48
+ };
49
+ /**
50
+ * The data for an InputBlock for ConnectionPointType.Float inputs
51
+ */
52
+ export type FloatInputBlockData = CommonInputBlockData & {
53
+ /** The type of the input block */
54
+ inputType: ConnectionPointType.Float;
55
+ /** The value of the input block */
56
+ value: number;
57
+ /**
58
+ * If supplied, how this should be animated by the editor. Will not affect runtime behavior.
59
+ */
60
+ animationType: Nullable<"time">;
61
+ /**
62
+ * If supplied, the amount to change the value per millisecond when animating.
63
+ */
64
+ valueDeltaPerMs: Nullable<number>;
65
+ /**
66
+ * The minimum value of the float, used for slider control.
67
+ */
68
+ min: Nullable<number>;
69
+ /**
70
+ * The maximum value of the float, used for slider control.
71
+ */
72
+ max: Nullable<number>;
73
+ };
74
+ /**
75
+ * The data for an InputBlock for ConnectionPointType.Color3 inputs
76
+ */
77
+ export type Color3InputBlockData = CommonInputBlockData & {
78
+ /** The type of the input block */
79
+ inputType: ConnectionPointType.Color3;
80
+ /** The value of the input block */
81
+ value: IColor3Like;
82
+ };
83
+ /**
84
+ * The data for an InputBlock for ConnectionPointType.Color4 inputs
85
+ */
86
+ export type Color4InputBlockData = CommonInputBlockData & {
87
+ /** The type of the input block */
88
+ inputType: ConnectionPointType.Color4;
89
+ /** The value of the input block */
90
+ value: IColor4Like;
91
+ };
92
+ /**
93
+ * The data for an InputBlock for ConnectionPointType.Vector2 inputs
94
+ */
95
+ export type Vector2InputBlockData = CommonInputBlockData & {
96
+ /** The type of the input block */
97
+ inputType: ConnectionPointType.Vector2;
98
+ /** The value of the input block */
99
+ value: IVector2Like;
100
+ };
101
+ /**
102
+ * Type union of all possible InputBlock data types
103
+ */
104
+ export type SerializedInputBlockData = TextureInputBlockData | BooleanInputBlockData | FloatInputBlockData | Color3InputBlockData | Color4InputBlockData | Vector2InputBlockData;
105
+ //# sourceMappingURL=inputBlock.serialization.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputBlock.serialization.types.d.ts","sourceRoot":"","sources":["../../src/blockFoundation/inputBlock.serialization.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAA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B;;OAEG;IACH,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACzB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GAAG;IACtD,kCAAkC;IAClC,SAAS,EAAE,mBAAmB,CAAC,MAAM,CAAC;IAEtC,mCAAmC;IACnC,KAAK,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,oBAAoB,GAAG;IACtD,kCAAkC;IAClC,SAAS,EAAE,mBAAmB,CAAC,MAAM,CAAC;IAEtC,mCAAmC;IACnC,KAAK,EAAE,WAAW,CAAC;CACtB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GAAG;IACvD,kCAAkC;IAClC,SAAS,EAAE,mBAAmB,CAAC,OAAO,CAAC;IAEvC,mCAAmC;IACnC,KAAK,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG,qBAAqB,GAAG,qBAAqB,GAAG,mBAAmB,GAAG,oBAAoB,GAAG,oBAAoB,GAAG,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inputBlock.serialization.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputBlock.serialization.types.js","sourceRoot":"","sources":["../../src/blockFoundation/inputBlock.serialization.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import type { IBlockSerializerV1 } from "../serialization/v1/smartFilterSerialization.types.js";
2
+ /**
3
+ * The V1 serializer for an InputBlock
4
+ */
5
+ export declare const InputBlockSerializer: IBlockSerializerV1;
6
+ //# sourceMappingURL=inputBlock.serializer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputBlock.serializer.d.ts","sourceRoot":"","sources":["../../src/blockFoundation/inputBlock.serializer.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAuHhG;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,kBAelC,CAAC"}
@@ -0,0 +1,130 @@
1
+ import { InputBlockBase } from "./inputBlock.js";
2
+ import { ConnectionPointType } from "../connection/connectionPointType.js";
3
+ /**
4
+ * Determines which generic type of InputBlock we are trying to serialize and calls the appropriate function
5
+ * to serialize the specifics for that type of InputBlock
6
+ * @param inputBlock - The InputBlock to serialize
7
+ * @returns Serialized data for the InputBlock
8
+ */
9
+ function SerializeInputBlockData(inputBlock) {
10
+ switch (inputBlock.type) {
11
+ case ConnectionPointType.Texture:
12
+ return SerializeTextureInputBlock(inputBlock);
13
+ case ConnectionPointType.Boolean:
14
+ return SerializeBooleanInputBlock(inputBlock);
15
+ case ConnectionPointType.Float:
16
+ return SerializeFloatInputBlock(inputBlock);
17
+ case ConnectionPointType.Color3:
18
+ return SerializeColor3InputBlock(inputBlock);
19
+ case ConnectionPointType.Color4:
20
+ return SerializeColor4InputBlock(inputBlock);
21
+ case ConnectionPointType.Vector2:
22
+ return SerializeVector2InputBlock(inputBlock);
23
+ }
24
+ }
25
+ /**
26
+ * Generates the serialized data for a Texture InputBlock
27
+ * @param inputBlock - The Texture InputBlock to serialize
28
+ * @returns The serialized data for the InputBlock
29
+ */
30
+ function SerializeTextureInputBlock(inputBlock) {
31
+ const internalTexture = inputBlock.runtimeValue.value?.getInternalTexture();
32
+ const forcedExtension = internalTexture?._extension ?? null;
33
+ let url = internalTexture?.url ?? null;
34
+ if (url === "" || !url) {
35
+ url = inputBlock.editorData?.url ?? null;
36
+ }
37
+ return {
38
+ inputType: ConnectionPointType.Texture,
39
+ url,
40
+ urlTypeHint: inputBlock.editorData?.urlTypeHint ?? null,
41
+ flipY: internalTexture?.invertY ?? null,
42
+ anisotropicFilteringLevel: internalTexture?.anisotropicFilteringLevel ?? null,
43
+ forcedExtension: forcedExtension !== "" ? forcedExtension : null,
44
+ appMetadata: inputBlock.appMetadata,
45
+ };
46
+ }
47
+ /**
48
+ * Generates the serialized data for a Boolean InputBlock
49
+ * @param inputBlock - The Boolean InputBlock to serialize
50
+ * @returns The serialized data for the InputBlock
51
+ */
52
+ function SerializeBooleanInputBlock(inputBlock) {
53
+ return {
54
+ inputType: ConnectionPointType.Boolean,
55
+ value: inputBlock.runtimeValue.value,
56
+ appMetadata: inputBlock.appMetadata,
57
+ };
58
+ }
59
+ /**
60
+ * Generates the serialized data for a Float InputBlock
61
+ * @param inputBlock - The Float InputBlock to serialize
62
+ * @returns The serialized data for the InputBlock
63
+ */
64
+ function SerializeFloatInputBlock(inputBlock) {
65
+ return {
66
+ inputType: ConnectionPointType.Float,
67
+ value: inputBlock.runtimeValue.value,
68
+ animationType: inputBlock.editorData?.animationType ?? null,
69
+ valueDeltaPerMs: inputBlock.editorData?.valueDeltaPerMs ?? null,
70
+ min: inputBlock.editorData?.min ?? null,
71
+ max: inputBlock.editorData?.max ?? null,
72
+ appMetadata: inputBlock.appMetadata,
73
+ };
74
+ }
75
+ /**
76
+ * Generates the serialized data for a Color3 InputBlock
77
+ * @param inputBlock - The Color3 InputBlock to serialize
78
+ * @returns The serialized data for the InputBlock
79
+ */
80
+ function SerializeColor3InputBlock(inputBlock) {
81
+ return {
82
+ inputType: ConnectionPointType.Color3,
83
+ value: inputBlock.runtimeValue.value,
84
+ appMetadata: inputBlock.appMetadata,
85
+ };
86
+ }
87
+ /**
88
+ * Generates the serialized data for a Color4 InputBlock
89
+ * @param inputBlock - The Color4 InputBlock to serialize
90
+ * @returns The serialized data for the InputBlock
91
+ */
92
+ function SerializeColor4InputBlock(inputBlock) {
93
+ return {
94
+ inputType: ConnectionPointType.Color4,
95
+ value: inputBlock.runtimeValue.value,
96
+ appMetadata: inputBlock.appMetadata,
97
+ };
98
+ }
99
+ /**
100
+ * Generates the serialized data for a Vector2 InputBlock
101
+ * @param inputBlock - The Vector2 InputBlock to serialize
102
+ * @returns The serialized data for the InputBlock
103
+ */
104
+ function SerializeVector2InputBlock(inputBlock) {
105
+ return {
106
+ inputType: ConnectionPointType.Vector2,
107
+ value: inputBlock.runtimeValue.value,
108
+ appMetadata: inputBlock.appMetadata,
109
+ };
110
+ }
111
+ /**
112
+ * The V1 serializer for an InputBlock
113
+ */
114
+ export const InputBlockSerializer = {
115
+ blockType: InputBlockBase.ClassName,
116
+ serialize: (block) => {
117
+ if (block.blockType !== InputBlockBase.ClassName) {
118
+ throw new Error("Was asked to serialize an unrecognized block type");
119
+ }
120
+ return {
121
+ name: block.name,
122
+ uniqueId: block.uniqueId,
123
+ blockType: InputBlockBase.ClassName,
124
+ namespace: null,
125
+ comments: block.comments,
126
+ data: SerializeInputBlockData(block),
127
+ };
128
+ },
129
+ };
130
+ //# sourceMappingURL=inputBlock.serializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inputBlock.serializer.js","sourceRoot":"","sources":["../../src/blockFoundation/inputBlock.serializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAY3E;;;;;GAKG;AACH,SAAS,uBAAuB,CAAC,UAA0B;IACvD,QAAQ,UAAU,CAAC,IAAI,EAAE,CAAC;QACtB,KAAK,mBAAmB,CAAC,OAAO;YAC5B,OAAO,0BAA0B,CAAC,UAAqD,CAAC,CAAC;QAC7F,KAAK,mBAAmB,CAAC,OAAO;YAC5B,OAAO,0BAA0B,CAAC,UAAqD,CAAC,CAAC;QAC7F,KAAK,mBAAmB,CAAC,KAAK;YAC1B,OAAO,wBAAwB,CAAC,UAAmD,CAAC,CAAC;QACzF,KAAK,mBAAmB,CAAC,MAAM;YAC3B,OAAO,yBAAyB,CAAC,UAAoD,CAAC,CAAC;QAC3F,KAAK,mBAAmB,CAAC,MAAM;YAC3B,OAAO,yBAAyB,CAAC,UAAoD,CAAC,CAAC;QAC3F,KAAK,mBAAmB,CAAC,OAAO;YAC5B,OA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AAS,EAAE,IAAI;YACf,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,uBAAuB,CAAC,KAAkC,CAAC;SACpE,CAAC;IACN,CAAC;CACJ,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { InitializationData, SmartFilter } from "../smartFilter.js";
2
+ import { ConnectionPointType } from "../connection/connectionPointType.js";
3
+ import { BaseBlock } from "./baseBlock.js";
4
+ import type { Nullable } from "@onerjs/core/types.js";
5
+ import type { RenderTargetWrapper } from "@onerjs/core/Engines/renderTargetWrapper.js";
6
+ /**
7
+ * The output block of a smart filter.
8
+ *
9
+ * Only the smart filter will internally create and host the output block.
10
+ * It should not be exported through the main index.ts module.
11
+ */
12
+ export declare class OutputBlock extends BaseBlock {
13
+ /**
14
+ * The class name of the block.
15
+ */
16
+ static ClassName: string;
17
+ /**
18
+ * Input connection point of the output block.
19
+ * This takes a texture as input.
20
+ */
21
+ readonly input: import("../connection/connectionPoint.js").ConnectionPoint<ConnectionPointType.Texture>;
22
+ /**
23
+ * If supplied, the Smart Filter will render into this RenderTargetWrapper. Otherwise, it renders
24
+ * into the the canvas or WebGL context the ThinEngine is using for rendering.
25
+ */
26
+ renderTargetWrapper: Nullable<RenderTargetWrapper>;
27
+ /**
28
+ * Create a new output block.
29
+ * @param smartFilter - The smart filter this block belongs to
30
+ */
31
+ constructor(smartFilter: SmartFilter);
32
+ /**
33
+ * Prepares all blocks for runtime by traversing the graph.
34
+ */
35
+ prepareForRuntime(): void;
36
+ /**
37
+ * Propagates the runtime data for all graph blocks.
38
+ */
39
+ propagateRuntimeData(): void;
40
+ /**
41
+ * Generates the commands needed to execute the block at runtime and gathers promises for initialization work
42
+ * @param initializationData - The initialization data to use
43
+ * @param finalOutput - Defines if the block is the final output of the smart filter
44
+ */
45
+ generateCommandsAndGatherInitPromises(initializationData: InitializationData, finalOutput: boolean): void;
46
+ }
47
+ //# sourceMappingURL=outputBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputBlock.d.ts","sourceRoot":"","sources":["../../src/blockFoundation/outputBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,KAAK,EAAE,QAAQ,EAAE,8BAAsB;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,oDAA4C;AAsC/E;;;;;GAKG;AACH,qBAAa,WAAY,SAAQ,SAAS;IACtC;;OAEG;IACH,OAAuB,SAAS,SAAiB;IAEjD;;;OAGG;IACH,SAAgB,KAAK,0FAA6D;IAElF;;;OAGG;IACI,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB,CAAC,CAAQ;IAEjE;;;OAGG;gBACS,WAAW,EAAE,WAAW;IAIpC;;OAEG;IACa,iBAAiB,IAAI,IAAI;IAQzC;;OAEG;IACa,oBAAoB,IAAI,IAAI;IAS5C;;;;OAIG;IACa,qCAAqC,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI;CAe5H"}
@@ -0,0 +1,123 @@
1
+ import { ConnectionPointType } from "../connection/connectionPointType.js";
2
+ import { BaseBlock } from "./baseBlock.js";
3
+ import { ShaderBinding, ShaderRuntime } from "../runtime/shaderRuntime.js";
4
+ import { RegisterFinalRenderCommand } from "../utils/renderTargetUtils.js";
5
+ /**
6
+ * The shader program for the block.
7
+ */
8
+ const BlockShaderProgram = {
9
+ vertex: undefined,
10
+ fragment: {
11
+ uniform: `
12
+ uniform sampler2D _input_; // main`,
13
+ mainInputTexture: "_input_",
14
+ mainFunctionName: "_copy_",
15
+ functions: [
16
+ {
17
+ name: "_copy_",
18
+ code: `
19
+ vec4 _copy_(vec2 vUV) {
20
+ return texture2D(_input_, vUV);
21
+ }
22
+
23
+ `,
24
+ },
25
+ ],
26
+ },
27
+ };
28
+ /**
29
+ * The uniform names for this shader, to be used in the shader binding so
30
+ * that the names are always in sync.
31
+ */
32
+ const Uniforms = {
33
+ input: "input",
34
+ };
35
+ /**
36
+ * The output block of a smart filter.
37
+ *
38
+ * Only the smart filter will internally create and host the output block.
39
+ * It should not be exported through the main index.ts module.
40
+ */
41
+ export class OutputBlock extends BaseBlock {
42
+ /**
43
+ * Create a new output block.
44
+ * @param smartFilter - The smart filter this block belongs to
45
+ */
46
+ constructor(smartFilter) {
47
+ super(smartFilter, "output");
48
+ /**
49
+ * Input connection point of the output block.
50
+ * This takes a texture as input.
51
+ */
52
+ this.input = this._registerInput("input", ConnectionPointType.Texture);
53
+ /**
54
+ * If supplied, the Smart Filter will render into this RenderTargetWrapper. Otherwise, it renders
55
+ * into the the canvas or WebGL context the ThinEngine is using for rendering.
56
+ */
57
+ this.renderTargetWrapper = null;
58
+ }
59
+ /**
60
+ * Prepares all blocks for runtime by traversing the graph.
61
+ */
62
+ prepareForRuntime() {
63
+ this.visit({}, (block, _extraData) => {
64
+ if (block !== this) {
65
+ block.prepareForRuntime();
66
+ }
67
+ });
68
+ }
69
+ /**
70
+ * Propagates the runtime data for all graph blocks.
71
+ */
72
+ propagateRuntimeData() {
73
+ this.visit({}, (block, _extraData) => {
74
+ if (block !== this) {
75
+ block.propagateRuntimeData();
76
+ }
77
+ });
78
+ this._confirmRuntimeDataSupplied(this.input);
79
+ }
80
+ /**
81
+ * Generates the commands needed to execute the block at runtime and gathers promises for initialization work
82
+ * @param initializationData - The initialization data to use
83
+ * @param finalOutput - Defines if the block is the final output of the smart filter
84
+ */
85
+ generateCommandsAndGatherInitPromises(initializationData, finalOutput) {
86
+ // In the case that this OutputBlock is directly connected to a texture InputBlock, we must
87
+ // use a shader to copy the texture to the render target texture.
88
+ if (this.input.connectedTo?.ownerBlock.isInput && this.input.runtimeData) {
89
+ const runtime = initializationData.runtime;
90
+ const shaderBlockRuntime = new ShaderRuntime(runtime.effectRenderer, BlockShaderProgram, new OutputShaderBinding(this.input.runtimeData));
91
+ initializationData.initializationPromises.push(shaderBlockRuntime.onReadyAsync);
92
+ runtime.registerResource(shaderBlockRuntime);
93
+ RegisterFinalRenderCommand(this, runtime, this, shaderBlockRuntime);
94
+ super.generateCommandsAndGatherInitPromises(initializationData, finalOutput);
95
+ }
96
+ }
97
+ }
98
+ /**
99
+ * The class name of the block.
100
+ */
101
+ OutputBlock.ClassName = "OutputBlock";
102
+ /**
103
+ * Shader binding to use when the OutputBlock is directly connected to a texture InputBlock.
104
+ */
105
+ class OutputShaderBinding extends ShaderBinding {
106
+ /**
107
+ * Creates a new shader binding instance.
108
+ * @param inputTexture - defines the input texture to copy
109
+ */
110
+ constructor(inputTexture) {
111
+ super();
112
+ this._inputTexture = inputTexture;
113
+ }
114
+ /**
115
+ * Binds all the required data to the shader when rendering.
116
+ * @param effect - defines the effect to bind the data to
117
+ * @internal
118
+ */
119
+ bind(effect) {
120
+ effect.setTexture(this.getRemappedName(Uniforms.input), this._inputTexture.value);
121
+ }
122
+ }
123
+ //# sourceMappingURL=outputBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputBlock.js","sourceRoot":"","sources":["../../src/blockFoundation/outputBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAK3E;;GAEG;AACH,MAAM,kBAAkB,GAAkB;IACtC,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE;QACN,OAAO,EAAE;+CAC8B;QACvC,gBAAgB,EAAE,SAAS;QAC3B,gBAAgB,EAAE,QAAQ;QAC1B,SAAS,EAAE;YACP;gBACI,IAAI,EAAE,QAAQ;gBACd,IA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G,IAAI,aAAa,CAAC,OAAO,CAAC,cAAc,EAAE,kBAAkB,EAAE,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;YAC1I,kBAAkB,CAAC,sBAAsB,CAAC,IAAI,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC;YAChF,OAAO,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;YAE7C,0BAA0B,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;YAEpE,KAAK,CAAC,qCAAqC,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;QACjF,CAAC;IACL,CAAC;;AAnED;;GAEG;AACoB,qBAAS,GAAG,aAAa,AAAhB,CAAiB;AAmErD;;GAEG;AACH,MAAM,mBAAoB,SAAQ,aAAa;IAG3C;;;OAGG;IACH,YAAY,YAAsD;QAC9D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACa,IAAI,CAAC,MAAc;QAC/B,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC;CACJ"}
@@ -0,0 +1,64 @@
1
+ import "@onerjs/core/Engines/Extensions/engine.renderTarget.js";
2
+ import type { InitializationData, SmartFilter } from "../smartFilter.js";
3
+ import type { ShaderProgram } from "../utils/shaderCodeUtils.js";
4
+ import type { ShaderBinding } from "../runtime/shaderRuntime.js";
5
+ import type { ConnectionPoint } from "../connection/connectionPoint.js";
6
+ import { ConnectionPointType } from "../connection/connectionPointType.js";
7
+ import { BaseBlock } from "./baseBlock.js";
8
+ import { type OutputTextureOptions } from "./textureOptions.js";
9
+ /**
10
+ * This is the base class for all shader blocks.
11
+ *
12
+ * It contains the redundant part of wrapping a shader for a full screen pass.
13
+ *
14
+ * The only required function to implement is the bind function.
15
+ */
16
+ export declare abstract class ShaderBlock extends BaseBlock {
17
+ /**
18
+ * The class name of the block.
19
+ */
20
+ static ClassName: string;
21
+ /**
22
+ * Get the class instance that binds all the required data to the shader (effect) when rendering.
23
+ * It should throw an error if required inputs are missing.
24
+ * @returns The class instance that binds the data to the effect
25
+ */
26
+ abstract getShaderBinding(): ShaderBinding;
27
+ /**
28
+ * The shader program (vertex and fragment code) to use to render the block
29
+ */
30
+ static ShaderCode: ShaderProgram;
31
+ /**
32
+ * The output connection point of the block.
33
+ */
34
+ readonly output: ConnectionPoint<ConnectionPointType.Texture>;
35
+ /**
36
+ * The options used when creating the texture this block outputs to
37
+ */
38
+ outputTextureOptions: OutputTextureOptions;
39
+ /**
40
+ * Disconnects the block from the graph.
41
+ * @param disconnectedConnections - Stores the connections that have been broken in the process. You can reconnect them later if needed.
42
+ */
43
+ disconnectFromGraph(disconnectedConnections?: [ConnectionPoint, ConnectionPoint][]): void;
44
+ protected _getConnectionForMainInputTexture(): ConnectionPoint;
45
+ /**
46
+ * Instantiates a new block.
47
+ * @param smartFilter - Defines the smart filter the block belongs to
48
+ * @param name - Defines the name of the block
49
+ * @param disableOptimization - Defines if the block should not be optimized (default: false)
50
+ */
51
+ constructor(smartFilter: SmartFilter, name: string, disableOptimization?: boolean);
52
+ /**
53
+ * Gets the shader program to use to render the block.
54
+ * @returns The shader program to use to render the block
55
+ */
56
+ getShaderProgram(): ShaderProgram;
57
+ /**
58
+ * Generates the commands needed to execute the block at runtime and gathers promises for initialization work
59
+ * @param initializationData - The initialization data to use
60
+ * @param finalOutput - Defines if the block is the final output of the smart filter
61
+ */
62
+ generateCommandsAndGatherInitPromises(initializationData: InitializationData, finalOutput: boolean): void;
63
+ }
64
+ //# sourceMappingURL=shaderBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shaderBlock.d.ts","sourceRoot":"","sources":["../../src/blockFoundation/shaderBlock.ts"],"names":[],"mappings":"AACA,gEAAwD;AAExD,OAAO,KAAK,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAI3E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAA8B,KAAK,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAM5F;;;;;;GAMG;AACH,8BAAsB,WAAY,SAAQ,SAAS;IAC/C;;OAEG;IACH,OAAuB,SAAS,SAAiB;IAEjD;;;;OAIG;aACa,gBAAgB,IAAI,aAAa;IAEjD;;OAEG;IACH,OAAc,UAAU,EAAE,aAAa,CAAC;IAExC;;OAEG;IACH,SAAgB,MAAM,+CAA+D;IAErF;;OAEG;IAyBI,oBAAoB,EAAE,oBAAoB,CAI/C;IAEF;;;OAGG;IACa,mBAAmB,CAAC,uBAAuB,CAAC,EAAE,CAAC,eAAe,EAAE,eAAe,CAAC,EAAE,GAAG,IAAI;IASzG,SAAS,CAAC,iCAAiC,IAAI,eAAe;IAc9D;;;;;OAKG;gBACS,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,UAAQ;IAI/E;;;OAGG;IACI,gBAAgB;IAIvB;;;;OAIG;IACa,qCAAqC,CAAC,kBAAkB,EAAE,kBAAkB,EAAE,WAAW,EAAE,OAAO,GAAG,IAAI;CAuB5H"}