@babylonjs/smart-filters-blocks 1.0.13 → 8.19.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
@@ -8,7 +8,7 @@
8
8
  // to the block. This file will get overwritten when the build
9
9
  // is run or during a watch when the .glsl file is updated.
10
10
 
11
- import type { Effect } from "@babylonjs/core/Materials/effect";
11
+ import type { Effect } from "core/Materials/effect.js";
12
12
 
13
13
  import {
14
14
  DisableableShaderBinding,
@@ -19,12 +19,12 @@ import {
19
19
  type ShaderProgram,
20
20
  createStrongRef,
21
21
  type IDisableableBlock,
22
- BlockDisableStrategy} from "@babylonjs/smart-filters";
22
+ BlockDisableStrategy} from "smart-filters";
23
23
 
24
24
  /**
25
25
  * The shader program for the block.
26
26
  */
27
- const shaderProgram: ShaderProgram = {
27
+ const BlockShaderProgram: ShaderProgram = {
28
28
  vertex: undefined,
29
29
  fragment: {
30
30
  uniform: `
@@ -59,11 +59,12 @@ const shaderProgram: ShaderProgram = {
59
59
  * The uniform names for this shader, to be used in the shader binding so
60
60
  * that the names are always in sync.
61
61
  */
62
- const uniforms = {
62
+ const Uniforms = {
63
63
  input: "input",
64
64
  intensity: "intensity",
65
65
  };
66
66
 
67
+
67
68
  /**
68
69
  * The shader binding for the PosterizeBlock, used by the runtime
69
70
  */
@@ -93,8 +94,8 @@ class PosterizeBlockShaderBinding extends DisableableShaderBinding {
93
94
  */
94
95
  public override bind(effect: Effect): void {
95
96
  super.bind(effect);
96
- effect.setTexture(this.getRemappedName(uniforms.input), this._input.value);
97
- effect.setFloat(this.getRemappedName(uniforms.intensity), this._intensity.value);
97
+ effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
98
+ effect.setFloat(this.getRemappedName(Uniforms.intensity), this._intensity.value);
98
99
  }
99
100
  }
100
101
 
@@ -115,7 +116,7 @@ export class PosterizeBlock extends DisableableShaderBlock {
115
116
  /**
116
117
  * The input connection point.
117
118
  */
118
- public readonly input = this._registerInput(uniforms.input, ConnectionPointType.Texture);
119
+ public readonly input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
119
120
 
120
121
  /**
121
122
  /**
@@ -130,7 +131,7 @@ export class PosterizeBlock extends DisableableShaderBlock {
130
131
  /**
131
132
  * The shader program (vertex and fragment code) to use to render the block
132
133
  */
133
- public static override ShaderCode = shaderProgram;
134
+ public static override ShaderCode = BlockShaderProgram;
134
135
 
135
136
  /**
136
137
  * Instantiates a new PosterizeBlock.
@@ -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: `
@@ -49,7 +49,7 @@ export const shaderProgram: ShaderProgram = {
49
49
  * The uniform names for this shader, to be used in the shader binding so
50
50
  * that the names are always in sync.
51
51
  */
52
- export const uniforms = {
52
+ const Uniforms = {
53
53
  input: "input",
54
54
  time: "time",
55
55
  rows: "rows",
@@ -57,3 +57,7 @@ export const uniforms = {
57
57
  frames: "frames",
58
58
  disabled: "disabled",
59
59
  };
60
+
61
+ export { BlockShaderProgram, Uniforms };
62
+ // Back compat for when camelCase was used
63
+ export { BlockShaderProgram as shaderProgram, Uniforms as uniforms };
@@ -1,138 +1,135 @@
1
- import type { Effect } from "@babylonjs/core/Materials/effect";
2
-
3
- import { spritesheetBlockType } from "../../../blockTypes.js";
4
- import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
5
- import { shaderProgram, uniforms } from "./spritesheetBlock.fragment.js";
6
- import {
7
- DisableableShaderBinding,
8
- type RuntimeData,
9
- ConnectionPointType,
10
- type IDisableableBlock,
11
- DisableableShaderBlock,
12
- type SmartFilter,
13
- createStrongRef,
14
- BlockDisableStrategy,
15
- } from "@babylonjs/smart-filters";
16
-
17
- /**
18
- * The shader bindings for the Spritesheet block.
19
- */
20
- export class SpritesheetShaderBinding extends DisableableShaderBinding {
21
- private readonly _inputTexture: RuntimeData<ConnectionPointType.Texture>;
22
- private readonly _time: RuntimeData<ConnectionPointType.Float>;
23
- private readonly _rows: RuntimeData<ConnectionPointType.Float>;
24
- private readonly _cols: RuntimeData<ConnectionPointType.Float>;
25
- private readonly _frames: RuntimeData<ConnectionPointType.Float>;
26
-
27
- /**
28
- * Creates a new shader binding instance for the SpriteSheet block.
29
- * @param parentBlock - The parent block
30
- * @param inputTexture - The input texture
31
- * @param time - The time passed since the start of the effect
32
- * @param rows - The number of rows in the sprite sheet
33
- * @param cols - The number of columns in the sprite sheet
34
- * @param frames - The number of frames to show
35
- */
36
- constructor(
37
- parentBlock: IDisableableBlock,
38
- inputTexture: RuntimeData<ConnectionPointType.Texture>,
39
- time: RuntimeData<ConnectionPointType.Float>,
40
- rows: RuntimeData<ConnectionPointType.Float>,
41
- cols: RuntimeData<ConnectionPointType.Float>,
42
- frames: RuntimeData<ConnectionPointType.Float>
43
- ) {
44
- super(parentBlock);
45
- this._inputTexture = inputTexture;
46
- this._time = time;
47
- this._rows = rows;
48
- this._cols = cols;
49
- this._frames = frames;
50
- }
51
-
52
- /**
53
- * Binds all the required data to the shader when rendering.
54
- * @param effect - defines the effect to bind the data to
55
- */
56
- public override bind(effect: Effect): void {
57
- super.bind(effect);
58
- effect.setTexture(this.getRemappedName(uniforms.input), this._inputTexture.value);
59
- effect.setFloat(this.getRemappedName(uniforms.time), this._time.value);
60
- effect.setFloat(this.getRemappedName(uniforms.rows), this._rows.value);
61
- effect.setFloat(this.getRemappedName(uniforms.cols), this._cols.value);
62
-
63
- // Apply default value for frame count if it was not provided
64
- effect.setFloat(
65
- this.getRemappedName(uniforms.frames),
66
- this._frames.value > 0 ? this._frames.value : this._rows.value * this._cols.value
67
- );
68
- }
69
- }
70
-
71
- /**
72
- * A block that animates a sprite sheet texture.
73
- */
74
- export class SpritesheetBlock extends DisableableShaderBlock {
75
- /**
76
- * The class name of the block.
77
- */
78
- public static override ClassName = spritesheetBlockType;
79
-
80
- /**
81
- * The namespace of the block.
82
- */
83
- public static override Namespace = babylonDemoEffectsNamespace;
84
-
85
- /**
86
- * The input texture connection point
87
- */
88
- public readonly input = this._registerInput("input", ConnectionPointType.Texture);
89
-
90
- /**
91
- * The time connection point to animate the effect.
92
- */
93
- public readonly time = this._registerOptionalInput("time", ConnectionPointType.Float, createStrongRef(0.0));
94
-
95
- /**
96
- * The number of rows in the sprite sheet, as a connection point.
97
- */
98
- public readonly rows = this._registerOptionalInput("rows", ConnectionPointType.Float, createStrongRef(1.0));
99
-
100
- /**
101
- * The number of columns in the sprite sheet, as a connection point.
102
- */
103
- public readonly columns = this._registerOptionalInput("columns", ConnectionPointType.Float, createStrongRef(1.0));
104
-
105
- /**
106
- * The number of frames to animate from the beginning, as a connection point.
107
- * Defaults to rows * columns at runtime.
108
- */
109
- public readonly frames = this._registerOptionalInput("frames", ConnectionPointType.Float, createStrongRef(0.0));
110
-
111
- /**
112
- * The shader program (vertex and fragment code) to use to render the block
113
- */
114
- public static override ShaderCode = shaderProgram;
115
-
116
- /**
117
- * Instantiates a new Block.
118
- * @param smartFilter - The smart filter this block belongs to
119
- * @param name - The friendly name of the block
120
- */
121
- constructor(smartFilter: SmartFilter, name: string) {
122
- super(smartFilter, name, false, BlockDisableStrategy.Manual);
123
- }
124
-
125
- /**
126
- * Get the class instance that binds all the required data to the shader (effect) when rendering.
127
- * @returns The class instance that binds the data to the effect
128
- */
129
- public getShaderBinding(): DisableableShaderBinding {
130
- const input = this._confirmRuntimeDataSupplied(this.input);
131
- const rows = this.rows.runtimeData;
132
- const columns = this.columns.runtimeData;
133
- const time = this.time.runtimeData;
134
- const frames = this.frames.runtimeData;
135
-
136
- return new SpritesheetShaderBinding(this, input, time, rows, columns, frames);
137
- }
138
- }
1
+ import type { Effect } from "core/Materials/effect.js";
2
+
3
+ import { spritesheetBlockType } from "../../../blockTypes.js";
4
+ import { babylonDemoEffectsNamespace } from "../../../blockNamespaces.js";
5
+ import { shaderProgram, uniforms } from "./spritesheetBlock.fragment.js";
6
+ import {
7
+ DisableableShaderBinding,
8
+ type RuntimeData,
9
+ ConnectionPointType,
10
+ type IDisableableBlock,
11
+ DisableableShaderBlock,
12
+ type SmartFilter,
13
+ createStrongRef,
14
+ BlockDisableStrategy,
15
+ } from "smart-filters";
16
+
17
+ /**
18
+ * The shader bindings for the Spritesheet block.
19
+ */
20
+ export class SpritesheetShaderBinding extends DisableableShaderBinding {
21
+ private readonly _inputTexture: RuntimeData<ConnectionPointType.Texture>;
22
+ private readonly _time: RuntimeData<ConnectionPointType.Float>;
23
+ private readonly _rows: RuntimeData<ConnectionPointType.Float>;
24
+ private readonly _cols: RuntimeData<ConnectionPointType.Float>;
25
+ private readonly _frames: RuntimeData<ConnectionPointType.Float>;
26
+
27
+ /**
28
+ * Creates a new shader binding instance for the SpriteSheet block.
29
+ * @param parentBlock - The parent block
30
+ * @param inputTexture - The input texture
31
+ * @param time - The time passed since the start of the effect
32
+ * @param rows - The number of rows in the sprite sheet
33
+ * @param cols - The number of columns in the sprite sheet
34
+ * @param frames - The number of frames to show
35
+ */
36
+ constructor(
37
+ parentBlock: IDisableableBlock,
38
+ inputTexture: RuntimeData<ConnectionPointType.Texture>,
39
+ time: RuntimeData<ConnectionPointType.Float>,
40
+ rows: RuntimeData<ConnectionPointType.Float>,
41
+ cols: RuntimeData<ConnectionPointType.Float>,
42
+ frames: RuntimeData<ConnectionPointType.Float>
43
+ ) {
44
+ super(parentBlock);
45
+ this._inputTexture = inputTexture;
46
+ this._time = time;
47
+ this._rows = rows;
48
+ this._cols = cols;
49
+ this._frames = frames;
50
+ }
51
+
52
+ /**
53
+ * Binds all the required data to the shader when rendering.
54
+ * @param effect - defines the effect to bind the data to
55
+ */
56
+ public override bind(effect: Effect): void {
57
+ super.bind(effect);
58
+ effect.setTexture(this.getRemappedName(uniforms.input), this._inputTexture.value);
59
+ effect.setFloat(this.getRemappedName(uniforms.time), this._time.value);
60
+ effect.setFloat(this.getRemappedName(uniforms.rows), this._rows.value);
61
+ effect.setFloat(this.getRemappedName(uniforms.cols), this._cols.value);
62
+
63
+ // Apply default value for frame count if it was not provided
64
+ effect.setFloat(this.getRemappedName(uniforms.frames), this._frames.value > 0 ? this._frames.value : this._rows.value * this._cols.value);
65
+ }
66
+ }
67
+
68
+ /**
69
+ * A block that animates a sprite sheet texture.
70
+ */
71
+ export class SpritesheetBlock extends DisableableShaderBlock {
72
+ /**
73
+ * The class name of the block.
74
+ */
75
+ public static override ClassName = spritesheetBlockType;
76
+
77
+ /**
78
+ * The namespace of the block.
79
+ */
80
+ public static override Namespace = babylonDemoEffectsNamespace;
81
+
82
+ /**
83
+ * The input texture connection point
84
+ */
85
+ public readonly input = this._registerInput("input", ConnectionPointType.Texture);
86
+
87
+ /**
88
+ * The time connection point to animate the effect.
89
+ */
90
+ public readonly time = this._registerOptionalInput("time", ConnectionPointType.Float, createStrongRef(0.0));
91
+
92
+ /**
93
+ * The number of rows in the sprite sheet, as a connection point.
94
+ */
95
+ public readonly rows = this._registerOptionalInput("rows", ConnectionPointType.Float, createStrongRef(1.0));
96
+
97
+ /**
98
+ * The number of columns in the sprite sheet, as a connection point.
99
+ */
100
+ public readonly columns = this._registerOptionalInput("columns", ConnectionPointType.Float, createStrongRef(1.0));
101
+
102
+ /**
103
+ * The number of frames to animate from the beginning, as a connection point.
104
+ * Defaults to rows * columns at runtime.
105
+ */
106
+ public readonly frames = this._registerOptionalInput("frames", ConnectionPointType.Float, createStrongRef(0.0));
107
+
108
+ /**
109
+ * The shader program (vertex and fragment code) to use to render the block
110
+ */
111
+ public static override ShaderCode = shaderProgram;
112
+
113
+ /**
114
+ * Instantiates a new Block.
115
+ * @param smartFilter - The smart filter this block belongs to
116
+ * @param name - The friendly name of the block
117
+ */
118
+ constructor(smartFilter: SmartFilter, name: string) {
119
+ super(smartFilter, name, false, BlockDisableStrategy.Manual);
120
+ }
121
+
122
+ /**
123
+ * Get the class instance that binds all the required data to the shader (effect) when rendering.
124
+ * @returns The class instance that binds the data to the effect
125
+ */
126
+ public getShaderBinding(): DisableableShaderBinding {
127
+ const input = this._confirmRuntimeDataSupplied(this.input);
128
+ const rows = this.rows.runtimeData;
129
+ const columns = this.columns.runtimeData;
130
+ const time = this.time.runtimeData;
131
+ const frames = this.frames.runtimeData;
132
+
133
+ return new SpritesheetShaderBinding(this, input, time, rows, columns, frames);
134
+ }
135
+ }
@@ -1,51 +1,51 @@
1
- import { ConnectionPointType, type SerializedShaderBlockDefinition } from "@babylonjs/smart-filters";
2
-
3
- /**
4
- * This is included to show how a serialized block definition can be loaded and used.
5
- * This object could have been deserialized from a JSON file, for example.
6
- */
7
- export const deserializedTintBlockDefinition: SerializedShaderBlockDefinition = {
8
- format: "shaderBlockDefinition",
9
- formatVersion: 1,
10
- blockType: "TintBlock",
11
- namespace: "Babylon.Demo.Effects",
12
- shaderProgram: {
13
- fragment: {
14
- uniform: `
15
- uniform sampler2D _input_; // main
16
- uniform vec3 _tint_;
17
- uniform float _amount_;
18
- `,
19
- mainInputTexture: "_input_",
20
- mainFunctionName: "_mainImage_",
21
- functions: [
22
- {
23
- name: "_mainImage_",
24
- code: `
25
- vec4 _mainImage_(vec2 vUV) {
26
- vec4 color = texture2D(_input_, vUV);
27
- vec3 tinted = mix(color.rgb, _tint_, _amount_);
28
- return vec4(tinted, color.a);
29
- }`,
30
- },
31
- ],
32
- },
33
- },
34
- inputConnectionPoints: [
35
- {
36
- name: "input",
37
- type: ConnectionPointType.Texture,
38
- },
39
- {
40
- name: "tint",
41
- type: ConnectionPointType.Color3,
42
- defaultValue: { r: 1, g: 0, b: 0 },
43
- },
44
- {
45
- name: "amount",
46
- type: ConnectionPointType.Float,
47
- defaultValue: 0.25,
48
- },
49
- ],
50
- disableOptimization: false,
51
- };
1
+ import { ConnectionPointType, type SerializedShaderBlockDefinition } from "smart-filters";
2
+
3
+ /**
4
+ * This is included to show how a serialized block definition can be loaded and used.
5
+ * This object could have been deserialized from a JSON file, for example.
6
+ */
7
+ export const DeserializedTintBlockDefinition: SerializedShaderBlockDefinition = {
8
+ format: "shaderBlockDefinition",
9
+ formatVersion: 1,
10
+ blockType: "TintBlock",
11
+ namespace: "Babylon.Demo.Effects",
12
+ shaderProgram: {
13
+ fragment: {
14
+ uniform: `
15
+ uniform sampler2D _input_; // main
16
+ uniform vec3 _tint_;
17
+ uniform float _amount_;
18
+ `,
19
+ mainInputTexture: "_input_",
20
+ mainFunctionName: "_mainImage_",
21
+ functions: [
22
+ {
23
+ name: "_mainImage_",
24
+ code: `
25
+ vec4 _mainImage_(vec2 vUV) {
26
+ vec4 color = texture2D(_input_, vUV);
27
+ vec3 tinted = mix(color.rgb, _tint_, _amount_);
28
+ return vec4(tinted, color.a);
29
+ }`,
30
+ },
31
+ ],
32
+ },
33
+ },
34
+ inputConnectionPoints: [
35
+ {
36
+ name: "input",
37
+ type: ConnectionPointType.Texture,
38
+ },
39
+ {
40
+ name: "tint",
41
+ type: ConnectionPointType.Color3,
42
+ defaultValue: { r: 1, g: 0, b: 0 },
43
+ },
44
+ {
45
+ name: "amount",
46
+ type: ConnectionPointType.Float,
47
+ defaultValue: 0.25,
48
+ },
49
+ ],
50
+ disableOptimization: false,
51
+ };
@@ -1 +1 @@
1
- export * from "./wipeBlock.block.js";
1
+ export * from "./wipeBlock.block.js";
@@ -8,7 +8,7 @@
8
8
  // to the block. This file will get overwritten when the build
9
9
  // is run or during a watch when the .glsl file is updated.
10
10
 
11
- import type { Effect } from "@babylonjs/core/Materials/effect";
11
+ import type { Effect } from "core/Materials/effect.js";
12
12
 
13
13
  import {
14
14
  ShaderBinding,
@@ -17,12 +17,12 @@ import {
17
17
  type SmartFilter,
18
18
  ShaderBlock,
19
19
  type ShaderProgram,
20
- } from "@babylonjs/smart-filters";
20
+ } from "smart-filters";
21
21
 
22
22
  /**
23
23
  * The shader program for the block.
24
24
  */
25
- const shaderProgram: ShaderProgram = {
25
+ const BlockShaderProgram: ShaderProgram = {
26
26
  vertex: undefined,
27
27
  fragment: {
28
28
  uniform: `
@@ -51,12 +51,13 @@ const shaderProgram: ShaderProgram = {
51
51
  * The uniform names for this shader, to be used in the shader binding so
52
52
  * that the names are always in sync.
53
53
  */
54
- const uniforms = {
54
+ const Uniforms = {
55
55
  textureA: "textureA",
56
56
  textureB: "textureB",
57
57
  progress: "progress",
58
58
  };
59
59
 
60
+
60
61
  /**
61
62
  * The shader binding for the WipeBlock, used by the runtime
62
63
  */
@@ -87,9 +88,9 @@ class WipeBlockShaderBinding extends ShaderBinding {
87
88
  * @param effect - defines the effect to bind the data to
88
89
  */
89
90
  public override bind(effect: Effect): void {
90
- effect.setTexture(this.getRemappedName(uniforms.textureA), this._textureA.value);
91
- effect.setTexture(this.getRemappedName(uniforms.textureB), this._textureB.value);
92
- effect.setFloat(this.getRemappedName(uniforms.progress), this._progress.value);
91
+ effect.setTexture(this.getRemappedName(Uniforms.textureA), this._textureA.value);
92
+ effect.setTexture(this.getRemappedName(Uniforms.textureB), this._textureB.value);
93
+ effect.setFloat(this.getRemappedName(Uniforms.progress), this._progress.value);
93
94
  }
94
95
  }
95
96
 
@@ -110,22 +111,22 @@ export class WipeBlock extends ShaderBlock {
110
111
  /**
111
112
  * The textureA connection point.
112
113
  */
113
- public readonly textureA = this._registerInput(uniforms.textureA, ConnectionPointType.Texture);
114
+ public readonly textureA = this._registerInput(Uniforms.textureA, ConnectionPointType.Texture);
114
115
 
115
116
  /**
116
117
  * The textureB connection point.
117
118
  */
118
- public readonly textureB = this._registerInput(uniforms.textureB, ConnectionPointType.Texture);
119
+ public readonly textureB = this._registerInput(Uniforms.textureB, ConnectionPointType.Texture);
119
120
 
120
121
  /**
121
122
  * The progress connection point.
122
123
  */
123
- public readonly progress = this._registerInput(uniforms.progress, ConnectionPointType.Float);
124
+ public readonly progress = this._registerInput(Uniforms.progress, ConnectionPointType.Float);
124
125
 
125
126
  /**
126
127
  * The shader program (vertex and fragment code) to use to render the block
127
128
  */
128
- public static override ShaderCode = shaderProgram;
129
+ public static override ShaderCode = BlockShaderProgram;
129
130
 
130
131
  /**
131
132
  * Instantiates a new WipeBlock.
@@ -1 +1 @@
1
- export * from "./premultiplyAlphaBlock.block.js";
1
+ export * from "./premultiplyAlphaBlock.block.js";
@@ -8,7 +8,7 @@
8
8
  // to the block. This file will get overwritten when the build
9
9
  // is run or during a watch when the .glsl file is updated.
10
10
 
11
- import type { Effect } from "@babylonjs/core/Materials/effect";
11
+ import type { Effect } from "core/Materials/effect.js";
12
12
 
13
13
  import {
14
14
  DisableableShaderBinding,
@@ -18,12 +18,12 @@ import {
18
18
  DisableableShaderBlock,
19
19
  type ShaderProgram,
20
20
  type IDisableableBlock,
21
- BlockDisableStrategy} from "@babylonjs/smart-filters";
21
+ BlockDisableStrategy} from "smart-filters";
22
22
 
23
23
  /**
24
24
  * The shader program for the block.
25
25
  */
26
- const shaderProgram: ShaderProgram = {
26
+ const BlockShaderProgram: ShaderProgram = {
27
27
  vertex: undefined,
28
28
  fragment: {
29
29
  uniform: `
@@ -49,10 +49,11 @@ const shaderProgram: ShaderProgram = {
49
49
  * The uniform names for this shader, to be used in the shader binding so
50
50
  * that the names are always in sync.
51
51
  */
52
- const uniforms = {
52
+ const Uniforms = {
53
53
  input: "input",
54
54
  };
55
55
 
56
+
56
57
  /**
57
58
  * The shader binding for the PremultiplyAlphaBlock, used by the runtime
58
59
  */
@@ -78,7 +79,7 @@ class PremultiplyAlphaBlockShaderBinding extends DisableableShaderBinding {
78
79
  */
79
80
  public override bind(effect: Effect): void {
80
81
  super.bind(effect);
81
- effect.setTexture(this.getRemappedName(uniforms.input), this._input.value);
82
+ effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
82
83
  }
83
84
  }
84
85
 
@@ -99,12 +100,12 @@ export class PremultiplyAlphaBlock extends DisableableShaderBlock {
99
100
  /**
100
101
  * The input connection point.
101
102
  */
102
- public readonly input = this._registerInput(uniforms.input, ConnectionPointType.Texture);
103
+ public readonly input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
103
104
 
104
105
  /**
105
106
  * The shader program (vertex and fragment code) to use to render the block
106
107
  */
107
- public static override ShaderCode = shaderProgram;
108
+ public static override ShaderCode = BlockShaderProgram;
108
109
 
109
110
  /**
110
111
  * Instantiates a new PremultiplyAlphaBlock.
@@ -1,4 +1,6 @@
1
- export const babylonDemoEffectsNamespace = "Babylon.Demo.Effects";
2
- export const babylonDemoUtilitiesNamespace = "Babylon.Demo.Utilities";
3
- export const babylonDemoTransitionsNamespace = "Babylon.Demo.Transitions";
4
- export const inputsNamespace = "Inputs";
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ export const babylonDemoEffectsNamespace = "Babylon.Demo.Effects";
3
+ export const babylonDemoUtilitiesNamespace = "Babylon.Demo.Utilities";
4
+ export const babylonDemoTransitionsNamespace = "Babylon.Demo.Transitions";
5
+ export const inputsNamespace = "Inputs";
6
+ /* eslint-enable @typescript-eslint/naming-convention */