@babylonjs/smart-filters-blocks 1.0.13 → 8.18.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 (147) hide show
  1. package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.d.ts.map +1 -1
  2. package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.js +5 -5
  3. package/dist/blocks/babylon/demo/effects/blackAndWhiteBlock.block.js.map +1 -1
  4. package/dist/blocks/babylon/demo/effects/blurBlock.d.ts.map +1 -1
  5. package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts +1 -1
  6. package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.d.ts.map +1 -1
  7. package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js +3 -5
  8. package/dist/blocks/babylon/demo/effects/blurBlock.deserializer.js.map +1 -1
  9. package/dist/blocks/babylon/demo/effects/blurBlock.js +8 -13
  10. package/dist/blocks/babylon/demo/effects/blurBlock.js.map +1 -1
  11. package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts +1 -1
  12. package/dist/blocks/babylon/demo/effects/blurBlock.serializer.d.ts.map +1 -1
  13. package/dist/blocks/babylon/demo/effects/blurBlock.serializer.js +1 -1
  14. package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts +7 -7
  15. package/dist/blocks/babylon/demo/effects/compositionBlock.d.ts.map +1 -1
  16. package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts +1 -1
  17. package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.d.ts.map +1 -1
  18. package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js +2 -3
  19. package/dist/blocks/babylon/demo/effects/compositionBlock.deserializer.js.map +1 -1
  20. package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts +4 -2
  21. package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.d.ts.map +1 -1
  22. package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js +5 -2
  23. package/dist/blocks/babylon/demo/effects/compositionBlock.fragment.js.map +1 -1
  24. package/dist/blocks/babylon/demo/effects/compositionBlock.js +2 -6
  25. package/dist/blocks/babylon/demo/effects/compositionBlock.js.map +1 -1
  26. package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts +1 -1
  27. package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.d.ts.map +1 -1
  28. package/dist/blocks/babylon/demo/effects/compositionBlock.serializer.js +1 -1
  29. package/dist/blocks/babylon/demo/effects/contrastBlock.block.d.ts +1 -1
  30. package/dist/blocks/babylon/demo/effects/contrastBlock.block.d.ts.map +1 -1
  31. package/dist/blocks/babylon/demo/effects/contrastBlock.block.js +6 -6
  32. package/dist/blocks/babylon/demo/effects/contrastBlock.block.js.map +1 -1
  33. package/dist/blocks/babylon/demo/effects/desaturateBlock.block.d.ts +1 -1
  34. package/dist/blocks/babylon/demo/effects/desaturateBlock.block.d.ts.map +1 -1
  35. package/dist/blocks/babylon/demo/effects/desaturateBlock.block.js +6 -6
  36. package/dist/blocks/babylon/demo/effects/desaturateBlock.block.js.map +1 -1
  37. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts +3 -1
  38. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.d.ts.map +1 -1
  39. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts +1 -1
  40. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.d.ts.map +1 -1
  41. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js +4 -5
  42. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.js.map +1 -1
  43. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js +32 -37
  44. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.js.map +1 -1
  45. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts +1 -1
  46. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.d.ts.map +1 -1
  47. package/dist/blocks/babylon/demo/effects/directionalBlurBlock.serializer.js +1 -1
  48. package/dist/blocks/babylon/demo/effects/exposureBlock.block.d.ts.map +1 -1
  49. package/dist/blocks/babylon/demo/effects/exposureBlock.block.js +7 -7
  50. package/dist/blocks/babylon/demo/effects/exposureBlock.block.js.map +1 -1
  51. package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.d.ts.map +1 -1
  52. package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.js +11 -11
  53. package/dist/blocks/babylon/demo/effects/greenScreenBlock.block.js.map +1 -1
  54. package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts +6 -1
  55. package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.d.ts.map +1 -1
  56. package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js +71 -71
  57. package/dist/blocks/babylon/demo/effects/kaleidoscopeBlock.js.map +1 -1
  58. package/dist/blocks/babylon/demo/effects/maskBlock.block.d.ts.map +1 -1
  59. package/dist/blocks/babylon/demo/effects/maskBlock.block.js +7 -7
  60. package/dist/blocks/babylon/demo/effects/maskBlock.block.js.map +1 -1
  61. package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts +2 -2
  62. package/dist/blocks/babylon/demo/effects/pixelateBlock.block.d.ts.map +1 -1
  63. package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js +8 -8
  64. package/dist/blocks/babylon/demo/effects/pixelateBlock.block.js.map +1 -1
  65. package/dist/blocks/babylon/demo/effects/posterizeBlock.block.d.ts +1 -1
  66. package/dist/blocks/babylon/demo/effects/posterizeBlock.block.d.ts.map +1 -1
  67. package/dist/blocks/babylon/demo/effects/posterizeBlock.block.js +6 -6
  68. package/dist/blocks/babylon/demo/effects/posterizeBlock.block.js.map +1 -1
  69. package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts +5 -5
  70. package/dist/blocks/babylon/demo/effects/spritesheetBlock.d.ts.map +1 -1
  71. package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.d.ts +4 -2
  72. package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.d.ts.map +1 -1
  73. package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.js +5 -2
  74. package/dist/blocks/babylon/demo/effects/spritesheetBlock.fragment.js.map +1 -1
  75. package/dist/blocks/babylon/demo/effects/spritesheetBlock.js.map +1 -1
  76. package/dist/blocks/babylon/demo/effects/tintBlock.d.ts +1 -1
  77. package/dist/blocks/babylon/demo/effects/tintBlock.d.ts.map +1 -1
  78. package/dist/blocks/babylon/demo/effects/tintBlock.js +10 -10
  79. package/dist/blocks/babylon/demo/effects/tintBlock.js.map +1 -1
  80. package/dist/blocks/babylon/demo/transitions/wipeBlock.block.d.ts.map +1 -1
  81. package/dist/blocks/babylon/demo/transitions/wipeBlock.block.js +9 -9
  82. package/dist/blocks/babylon/demo/transitions/wipeBlock.block.js.map +1 -1
  83. package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.d.ts.map +1 -1
  84. package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js +5 -5
  85. package/dist/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js.map +1 -1
  86. package/dist/blocks/blockNamespaces.d.ts.map +1 -1
  87. package/dist/blocks/blockNamespaces.js +2 -0
  88. package/dist/blocks/blockNamespaces.js.map +1 -1
  89. package/dist/blocks/blockTypes.d.ts.map +1 -1
  90. package/dist/blocks/blockTypes.js +2 -0
  91. package/dist/blocks/blockTypes.js.map +1 -1
  92. package/dist/blocks/index.d.ts.map +1 -1
  93. package/dist/blocks/index.js +1 -0
  94. package/dist/blocks/index.js.map +1 -1
  95. package/dist/index.d.ts.map +1 -1
  96. package/dist/index.js +1 -0
  97. package/dist/index.js.map +1 -1
  98. package/dist/registration/IBlockRegistration.d.ts +1 -1
  99. package/dist/registration/IBlockRegistration.d.ts.map +1 -1
  100. package/dist/registration/blockSerializers.d.ts.map +1 -1
  101. package/dist/registration/blockSerializers.js +6 -8
  102. package/dist/registration/blockSerializers.js.map +1 -1
  103. package/dist/registration/builtInBlockRegistrations.d.ts +1 -1
  104. package/dist/registration/builtInBlockRegistrations.d.ts.map +1 -1
  105. package/dist/registration/builtInBlockRegistrations.js +50 -52
  106. package/dist/registration/builtInBlockRegistrations.js.map +1 -1
  107. package/dist/registration/index.d.ts +1 -0
  108. package/dist/registration/index.d.ts.map +1 -1
  109. package/dist/registration/index.js +2 -0
  110. package/dist/registration/index.js.map +1 -1
  111. package/license.md +21 -21
  112. package/package.json +15 -13
  113. package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.block.ts +8 -7
  114. package/src/blocks/babylon/demo/effects/blurBlock.deserializer.ts +37 -37
  115. package/src/blocks/babylon/demo/effects/blurBlock.serializer.ts +31 -31
  116. package/src/blocks/babylon/demo/effects/blurBlock.ts +115 -122
  117. package/src/blocks/babylon/demo/effects/compositionBlock.deserializer.ts +31 -31
  118. package/src/blocks/babylon/demo/effects/compositionBlock.fragment.ts +7 -3
  119. package/src/blocks/babylon/demo/effects/compositionBlock.serializer.ts +28 -28
  120. package/src/blocks/babylon/demo/effects/compositionBlock.ts +211 -243
  121. package/src/blocks/babylon/demo/effects/contrastBlock.block.ts +9 -8
  122. package/src/blocks/babylon/demo/effects/desaturateBlock.block.ts +9 -8
  123. package/src/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.ts +43 -46
  124. package/src/blocks/babylon/demo/effects/directionalBlurBlock.serializer.ts +30 -30
  125. package/src/blocks/babylon/demo/effects/directionalBlurBlock.ts +192 -196
  126. package/src/blocks/babylon/demo/effects/exposureBlock.block.ts +10 -9
  127. package/src/blocks/babylon/demo/effects/greenScreenBlock.block.ts +14 -13
  128. package/src/blocks/babylon/demo/effects/index.ts +14 -14
  129. package/src/blocks/babylon/demo/effects/kaleidoscopeBlock.ts +188 -192
  130. package/src/blocks/babylon/demo/effects/maskBlock.block.ts +10 -9
  131. package/src/blocks/babylon/demo/effects/pixelateBlock.block.ts +11 -10
  132. package/src/blocks/babylon/demo/effects/posterizeBlock.block.ts +9 -8
  133. package/src/blocks/babylon/demo/effects/spritesheetBlock.fragment.ts +7 -3
  134. package/src/blocks/babylon/demo/effects/spritesheetBlock.ts +135 -138
  135. package/src/blocks/babylon/demo/effects/tintBlock.ts +51 -51
  136. package/src/blocks/babylon/demo/transitions/index.ts +1 -1
  137. package/src/blocks/babylon/demo/transitions/wipeBlock.block.ts +12 -11
  138. package/src/blocks/babylon/demo/utilities/index.ts +1 -1
  139. package/src/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.ts +8 -7
  140. package/src/blocks/blockNamespaces.ts +6 -4
  141. package/src/blocks/blockTypes.ts +23 -21
  142. package/src/blocks/index.ts +6 -5
  143. package/src/index.ts +3 -2
  144. package/src/registration/IBlockRegistration.ts +43 -48
  145. package/src/registration/blockSerializers.ts +50 -52
  146. package/src/registration/builtInBlockRegistrations.ts +293 -403
  147. package/src/registration/index.ts +4 -2
@@ -1,122 +1,115 @@
1
- import {
2
- type ConnectionPointType,
3
- AggregateBlock,
4
- type ConnectionPoint,
5
- editableInPropertyPage,
6
- PropertyTypeForEdition,
7
- SmartFilter,
8
- } from "@babylonjs/smart-filters";
9
- import { DirectionalBlurBlock } from "./directionalBlurBlock.js";
10
- import { blurBlockType } from "../../../blockTypes.js";
11
- import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
12
-
13
- const defaultBlurTextureRatioPerPass = 0.5;
14
- const defaultBlurSize = 2;
15
-
16
- /**
17
- * A block performing a blur on the input texture.
18
- *
19
- * It performs the blur in 4 consecutive passes, 2 verticals and 2 horizontals downsizing the texture as we go.
20
- */
21
- export class BlurBlock extends AggregateBlock {
22
- /**
23
- * The class name of the block.
24
- */
25
- public static override ClassName = blurBlockType;
26
-
27
- /**
28
- * The namespace of the block.
29
- */
30
- public static override Namespace = babylonDemoEffectsNamespace;
31
-
32
- /**
33
- * The input texture connection point.
34
- */
35
- public readonly input: ConnectionPoint<ConnectionPointType.Texture>;
36
-
37
- /**
38
- * The output blurred texture connection point.
39
- */
40
- public readonly output: ConnectionPoint<ConnectionPointType.Texture>;
41
-
42
- private _blurTextureRatioPerPass = defaultBlurTextureRatioPerPass;
43
- private _blurSize = defaultBlurSize;
44
-
45
- private readonly _intermediateBlurV: DirectionalBlurBlock;
46
- private readonly _intermediateBlurH: DirectionalBlurBlock;
47
- private readonly _finalBlurV: DirectionalBlurBlock;
48
- private readonly _finalBlurH: DirectionalBlurBlock;
49
-
50
- /**
51
- * Gets how much smaller we should make the texture between the 2 consecutive bi lateral passes.
52
- */
53
- public get blurTextureRatioPerPass(): number {
54
- return this._blurTextureRatioPerPass;
55
- }
56
-
57
- /**
58
- * Sets how much smaller we should make the texture between the 2 consecutive bi lateral passes.
59
- */
60
- @editableInPropertyPage("Pass Texture Ratio", PropertyTypeForEdition.Float, "PROPERTIES", {
61
- min: 0,
62
- max: 1,
63
- notifiers: { rebuild: true },
64
- })
65
- public set blurTextureRatioPerPass(value: number) {
66
- this._blurTextureRatioPerPass = value;
67
- this._intermediateBlurV.blurTextureRatio = value;
68
- this._intermediateBlurH.blurTextureRatio = value;
69
- this._finalBlurV.blurTextureRatio = value * value;
70
- this._finalBlurH.blurTextureRatio = value * value;
71
- }
72
-
73
- /**
74
- * Gets how far the kernel might fetch the data from.
75
- */
76
- public get blurSize(): number {
77
- return this._blurSize;
78
- }
79
-
80
- /**
81
- * Sets how far the kernel might fetch the data from.
82
- */
83
- @editableInPropertyPage("Size", PropertyTypeForEdition.Float, "PROPERTIES", {
84
- notifiers: { rebuild: true },
85
- })
86
- public set blurSize(value: number) {
87
- this._blurSize = value;
88
- this._intermediateBlurV.blurHorizontalWidth = value;
89
- this._intermediateBlurH.blurVerticalWidth = value;
90
- this._finalBlurV.blurHorizontalWidth = value;
91
- this._finalBlurH.blurVerticalWidth = value;
92
- }
93
-
94
- /**
95
- * Instantiates a new Block.
96
- * @param smartFilter - The smart filter this block belongs to
97
- * @param name - The friendly name of the block
98
- */
99
- constructor(smartFilter: SmartFilter, name: string) {
100
- super(smartFilter, name);
101
-
102
- const internalFilter = new SmartFilter(name + "_BlurBlock_Aggregated");
103
- this._intermediateBlurV = new DirectionalBlurBlock(internalFilter, name + "IV");
104
- this._intermediateBlurH = new DirectionalBlurBlock(internalFilter, name + "IH");
105
- this._finalBlurV = new DirectionalBlurBlock(internalFilter, name + "V");
106
- this._finalBlurH = new DirectionalBlurBlock(internalFilter, name + "H");
107
-
108
- this._intermediateBlurV.output.connectTo(this._intermediateBlurH.input);
109
- this._intermediateBlurH.output.connectTo(this._finalBlurV.input);
110
- this._finalBlurV.output.connectTo(this._finalBlurH.input);
111
-
112
- this.input = this._registerSubfilterInput("input", [this._intermediateBlurV.input]);
113
- this.output = this._registerSubfilterOutput("output", this._finalBlurH.output);
114
-
115
- this.blurSize = defaultBlurSize;
116
- this.blurTextureRatioPerPass = defaultBlurTextureRatioPerPass;
117
- this._intermediateBlurV.blurVerticalWidth = 0;
118
- this._intermediateBlurH.blurHorizontalWidth = 0;
119
- this._finalBlurV.blurVerticalWidth = 0;
120
- this._finalBlurH.blurHorizontalWidth = 0;
121
- }
122
- }
1
+ import { type ConnectionPointType, AggregateBlock, type ConnectionPoint, editableInPropertyPage, PropertyTypeForEdition, SmartFilter } from "smart-filters";
2
+ import { DirectionalBlurBlock } from "./directionalBlurBlock.js";
3
+ import { blurBlockType } from "../../../blockTypes.js";
4
+ import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
5
+
6
+ const DefaultBlurTextureRatioPerPass = 0.5;
7
+ const DefaultBlurSize = 2;
8
+
9
+ /**
10
+ * A block performing a blur on the input texture.
11
+ *
12
+ * It performs the blur in 4 consecutive passes, 2 verticals and 2 horizontals downsizing the texture as we go.
13
+ */
14
+ export class BlurBlock extends AggregateBlock {
15
+ /**
16
+ * The class name of the block.
17
+ */
18
+ public static override ClassName = blurBlockType;
19
+
20
+ /**
21
+ * The namespace of the block.
22
+ */
23
+ public static override Namespace = babylonDemoEffectsNamespace;
24
+
25
+ /**
26
+ * The input texture connection point.
27
+ */
28
+ public readonly input: ConnectionPoint<ConnectionPointType.Texture>;
29
+
30
+ /**
31
+ * The output blurred texture connection point.
32
+ */
33
+ public readonly output: ConnectionPoint<ConnectionPointType.Texture>;
34
+
35
+ private _blurTextureRatioPerPass = DefaultBlurTextureRatioPerPass;
36
+ private _blurSize = DefaultBlurSize;
37
+
38
+ private readonly _intermediateBlurV: DirectionalBlurBlock;
39
+ private readonly _intermediateBlurH: DirectionalBlurBlock;
40
+ private readonly _finalBlurV: DirectionalBlurBlock;
41
+ private readonly _finalBlurH: DirectionalBlurBlock;
42
+
43
+ /**
44
+ * Gets how much smaller we should make the texture between the 2 consecutive bi lateral passes.
45
+ */
46
+ public get blurTextureRatioPerPass(): number {
47
+ return this._blurTextureRatioPerPass;
48
+ }
49
+
50
+ /**
51
+ * Sets how much smaller we should make the texture between the 2 consecutive bi lateral passes.
52
+ */
53
+ @editableInPropertyPage("Pass Texture Ratio", PropertyTypeForEdition.Float, "PROPERTIES", {
54
+ min: 0,
55
+ max: 1,
56
+ notifiers: { rebuild: true },
57
+ })
58
+ public set blurTextureRatioPerPass(value: number) {
59
+ this._blurTextureRatioPerPass = value;
60
+ this._intermediateBlurV.blurTextureRatio = value;
61
+ this._intermediateBlurH.blurTextureRatio = value;
62
+ this._finalBlurV.blurTextureRatio = value * value;
63
+ this._finalBlurH.blurTextureRatio = value * value;
64
+ }
65
+
66
+ /**
67
+ * Gets how far the kernel might fetch the data from.
68
+ */
69
+ public get blurSize(): number {
70
+ return this._blurSize;
71
+ }
72
+
73
+ /**
74
+ * Sets how far the kernel might fetch the data from.
75
+ */
76
+ @editableInPropertyPage("Size", PropertyTypeForEdition.Float, "PROPERTIES", {
77
+ notifiers: { rebuild: true },
78
+ })
79
+ public set blurSize(value: number) {
80
+ this._blurSize = value;
81
+ this._intermediateBlurV.blurHorizontalWidth = value;
82
+ this._intermediateBlurH.blurVerticalWidth = value;
83
+ this._finalBlurV.blurHorizontalWidth = value;
84
+ this._finalBlurH.blurVerticalWidth = value;
85
+ }
86
+
87
+ /**
88
+ * Instantiates a new Block.
89
+ * @param smartFilter - The smart filter this block belongs to
90
+ * @param name - The friendly name of the block
91
+ */
92
+ constructor(smartFilter: SmartFilter, name: string) {
93
+ super(smartFilter, name);
94
+
95
+ const internalFilter = new SmartFilter(name + "_BlurBlock_Aggregated");
96
+ this._intermediateBlurV = new DirectionalBlurBlock(internalFilter, name + "IV");
97
+ this._intermediateBlurH = new DirectionalBlurBlock(internalFilter, name + "IH");
98
+ this._finalBlurV = new DirectionalBlurBlock(internalFilter, name + "V");
99
+ this._finalBlurH = new DirectionalBlurBlock(internalFilter, name + "H");
100
+
101
+ this._intermediateBlurV.output.connectTo(this._intermediateBlurH.input);
102
+ this._intermediateBlurH.output.connectTo(this._finalBlurV.input);
103
+ this._finalBlurV.output.connectTo(this._finalBlurH.input);
104
+
105
+ this.input = this._registerSubfilterInput("input", [this._intermediateBlurV.input]);
106
+ this.output = this._registerSubfilterOutput("output", this._finalBlurH.output);
107
+
108
+ this.blurSize = DefaultBlurSize;
109
+ this.blurTextureRatioPerPass = DefaultBlurTextureRatioPerPass;
110
+ this._intermediateBlurV.blurVerticalWidth = 0;
111
+ this._intermediateBlurH.blurHorizontalWidth = 0;
112
+ this._finalBlurV.blurVerticalWidth = 0;
113
+ this._finalBlurH.blurHorizontalWidth = 0;
114
+ }
115
+ }
@@ -1,31 +1,31 @@
1
- import type { ISerializedBlockV1, SmartFilter } from "@babylonjs/smart-filters";
2
- import { CompositionBlock } from "./compositionBlock.js";
3
-
4
- /**
5
- * The definition of the extra data serialized for composition blocks.
6
- */
7
- export interface ISerializedCompositionBlockV1 extends ISerializedBlockV1 {
8
- /**
9
- * The extra data of the block.
10
- */
11
- data: {
12
- /**
13
- * The alpha mode of the composition.
14
- */
15
- alphaMode: number;
16
- };
17
- }
18
-
19
- /**
20
- * V1 Composition Deserializer.
21
- * @param smartFilter - The SmartFilter to deserialize the block into
22
- * @param serializedBlock - The serialized block data
23
- * @returns A deserialized CompositionBlock
24
- */
25
- export function compositionDeserializer(smartFilter: SmartFilter, serializedBlock: ISerializedCompositionBlockV1) {
26
- const block = new CompositionBlock(smartFilter, serializedBlock.name);
27
-
28
- // If data is missing, use the default value set by the block
29
- block.alphaMode = serializedBlock.data.alphaMode ?? block.alphaMode;
30
- return block;
31
- }
1
+ import type { ISerializedBlockV1, SmartFilter } from "smart-filters";
2
+ import { CompositionBlock } from "./compositionBlock.js";
3
+
4
+ /**
5
+ * The definition of the extra data serialized for composition blocks.
6
+ */
7
+ export interface ISerializedCompositionBlockV1 extends ISerializedBlockV1 {
8
+ /**
9
+ * The extra data of the block.
10
+ */
11
+ data: {
12
+ /**
13
+ * The alpha mode of the composition.
14
+ */
15
+ alphaMode: number;
16
+ };
17
+ }
18
+
19
+ /**
20
+ * V1 Composition Deserializer.
21
+ * @param smartFilter - The SmartFilter to deserialize the block into
22
+ * @param serializedBlock - The serialized block data
23
+ * @returns A deserialized CompositionBlock
24
+ */
25
+ export function CompositionDeserializer(smartFilter: SmartFilter, serializedBlock: ISerializedCompositionBlockV1) {
26
+ const block = new CompositionBlock(smartFilter, serializedBlock.name);
27
+
28
+ // If data is missing, use the default value set by the block
29
+ block.alphaMode = serializedBlock.data.alphaMode ?? block.alphaMode;
30
+ return block;
31
+ }
@@ -1,9 +1,9 @@
1
- import type { ShaderProgram } from "@babylonjs/smart-filters";
1
+ import type { ShaderProgram } from "smart-filters";
2
2
 
3
3
  /**
4
4
  * The shader program for the block.
5
5
  */
6
- export const shaderProgram: ShaderProgram = {
6
+ const BlockShaderProgram: ShaderProgram = {
7
7
  vertex: undefined,
8
8
  fragment: {
9
9
  uniform: `
@@ -60,7 +60,7 @@ export const shaderProgram: ShaderProgram = {
60
60
  * The uniform names for this shader, to be used in the shader binding so
61
61
  * that the names are always in sync.
62
62
  */
63
- export const uniforms = {
63
+ const Uniforms = {
64
64
  background: "background",
65
65
  foreground: "foreground",
66
66
  scaleUV: "scaleUV",
@@ -68,3 +68,7 @@ export const uniforms = {
68
68
  alphaMode: "alphaMode",
69
69
  foregroundAlphaScale: "foregroundAlphaScale",
70
70
  };
71
+
72
+ export { BlockShaderProgram, Uniforms };
73
+ // Back compat for when camelCase was used
74
+ export { BlockShaderProgram as shaderProgram, Uniforms as uniforms };
@@ -1,28 +1,28 @@
1
- import type { CompositionBlock } from "./compositionBlock";
2
- import { compositionBlockType } from "../../../blockTypes.js";
3
- import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
4
- import type { IBlockSerializerV1, BaseBlock } from "@babylonjs/smart-filters";
5
-
6
- /**
7
- * The V1 serializer for a Composition Block
8
- */
9
- export const compositionBlockSerializer: IBlockSerializerV1 = {
10
- blockType: compositionBlockType,
11
- serialize: (block: BaseBlock) => {
12
- if (block.getClassName() !== compositionBlockType) {
13
- throw new Error("Was asked to serialize an unrecognized block type");
14
- }
15
-
16
- const compositionBlock = block as unknown as CompositionBlock;
17
- return {
18
- name: block.name,
19
- uniqueId: block.uniqueId,
20
- blockType: compositionBlockType,
21
- namespace: babylonDemoEffectsNamespace,
22
- comments: block.comments,
23
- data: {
24
- alphaMode: compositionBlock.alphaMode,
25
- },
26
- };
27
- },
28
- };
1
+ import type { CompositionBlock } from "./compositionBlock.js";
2
+ import { compositionBlockType } from "../../../blockTypes.js";
3
+ import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
4
+ import type { IBlockSerializerV1, BaseBlock } from "smart-filters";
5
+
6
+ /**
7
+ * The V1 serializer for a Composition Block
8
+ */
9
+ export const CompositionBlockSerializer: IBlockSerializerV1 = {
10
+ blockType: compositionBlockType,
11
+ serialize: (block: BaseBlock) => {
12
+ if (block.getClassName() !== compositionBlockType) {
13
+ throw new Error("Was asked to serialize an unrecognized block type");
14
+ }
15
+
16
+ const compositionBlock = block as unknown as CompositionBlock;
17
+ return {
18
+ name: block.name,
19
+ uniqueId: block.uniqueId,
20
+ blockType: compositionBlockType,
21
+ namespace: babylonDemoEffectsNamespace,
22
+ comments: block.comments,
23
+ data: {
24
+ alphaMode: compositionBlock.alphaMode,
25
+ },
26
+ };
27
+ },
28
+ };