@onerjs/smart-filters-blocks 8.25.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.
- package/license.md +21 -0
- package/package.json +54 -0
- package/readme.md +7 -0
- package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.block.glsl +18 -0
- package/src/blocks/babylon/demo/effects/blackAndWhiteBlock.block.ts +133 -0
- package/src/blocks/babylon/demo/effects/blurBlock.deserializer.ts +37 -0
- package/src/blocks/babylon/demo/effects/blurBlock.serializer.ts +31 -0
- package/src/blocks/babylon/demo/effects/blurBlock.ts +115 -0
- package/src/blocks/babylon/demo/effects/compositionBlock.deserializer.ts +31 -0
- package/src/blocks/babylon/demo/effects/compositionBlock.fragment.glsl +38 -0
- package/src/blocks/babylon/demo/effects/compositionBlock.fragment.ts +74 -0
- package/src/blocks/babylon/demo/effects/compositionBlock.serializer.ts +28 -0
- package/src/blocks/babylon/demo/effects/compositionBlock.ts +211 -0
- package/src/blocks/babylon/demo/effects/contrastBlock.block.glsl +36 -0
- package/src/blocks/babylon/demo/effects/contrastBlock.block.ts +178 -0
- package/src/blocks/babylon/demo/effects/desaturateBlock.block.glsl +24 -0
- package/src/blocks/babylon/demo/effects/desaturateBlock.block.ts +155 -0
- package/src/blocks/babylon/demo/effects/directionalBlurBlock.deserializer.ts +43 -0
- package/src/blocks/babylon/demo/effects/directionalBlurBlock.serializer.ts +30 -0
- package/src/blocks/babylon/demo/effects/directionalBlurBlock.ts +192 -0
- package/src/blocks/babylon/demo/effects/exposureBlock.block.glsl +15 -0
- package/src/blocks/babylon/demo/effects/exposureBlock.block.ts +142 -0
- package/src/blocks/babylon/demo/effects/greenScreenBlock.block.glsl +23 -0
- package/src/blocks/babylon/demo/effects/greenScreenBlock.block.ts +174 -0
- package/src/blocks/babylon/demo/effects/index.ts +14 -0
- package/src/blocks/babylon/demo/effects/kaleidoscopeBlock.ts +188 -0
- package/src/blocks/babylon/demo/effects/maskBlock.block.glsl +18 -0
- package/src/blocks/babylon/demo/effects/maskBlock.block.ts +145 -0
- package/src/blocks/babylon/demo/effects/pixelateBlock.block.glsl +29 -0
- package/src/blocks/babylon/demo/effects/pixelateBlock.block.ts +174 -0
- package/src/blocks/babylon/demo/effects/posterizeBlock.block.glsl +25 -0
- package/src/blocks/babylon/demo/effects/posterizeBlock.block.ts +156 -0
- package/src/blocks/babylon/demo/effects/spritesheetBlock.fragment.glsl +26 -0
- package/src/blocks/babylon/demo/effects/spritesheetBlock.fragment.ts +63 -0
- package/src/blocks/babylon/demo/effects/spritesheetBlock.ts +135 -0
- package/src/blocks/babylon/demo/effects/tintBlock.ts +51 -0
- package/src/blocks/babylon/demo/transitions/index.ts +1 -0
- package/src/blocks/babylon/demo/transitions/wipeBlock.block.glsl +11 -0
- package/src/blocks/babylon/demo/transitions/wipeBlock.block.ts +152 -0
- package/src/blocks/babylon/demo/utilities/index.ts +1 -0
- package/src/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.glsl +14 -0
- package/src/blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.ts +129 -0
- package/src/blocks/blockNamespaces.ts +6 -0
- package/src/blocks/blockTypes.ts +23 -0
- package/src/blocks/index.ts +6 -0
- package/src/index.ts +3 -0
- package/src/registration/IBlockRegistration.ts +43 -0
- package/src/registration/blockSerializers.ts +50 -0
- package/src/registration/builtInBlockRegistrations.ts +293 -0
- package/src/registration/index.ts +4 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/* eslint-disable prettier/prettier */
|
|
2
|
+
// ************************************************************
|
|
3
|
+
// Note: this file is auto-generated, do not modify it directly
|
|
4
|
+
// ************************************************************
|
|
5
|
+
|
|
6
|
+
// It was generated by convertGlslIntoBlock() from
|
|
7
|
+
// an annotated .glsl file. Modify the .glsl file to make changes
|
|
8
|
+
// to the block. This file will get overwritten when the build
|
|
9
|
+
// is run or during a watch when the .glsl file is updated.
|
|
10
|
+
|
|
11
|
+
import type { Effect } from "core/Materials/effect.js";
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
DisableableShaderBinding,
|
|
15
|
+
type RuntimeData,
|
|
16
|
+
ConnectionPointType,
|
|
17
|
+
type SmartFilter,
|
|
18
|
+
DisableableShaderBlock,
|
|
19
|
+
type ShaderProgram,
|
|
20
|
+
type IDisableableBlock,
|
|
21
|
+
BlockDisableStrategy} from "smart-filters";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The shader program for the block.
|
|
25
|
+
*/
|
|
26
|
+
const BlockShaderProgram: ShaderProgram = {
|
|
27
|
+
vertex: undefined,
|
|
28
|
+
fragment: {
|
|
29
|
+
uniform: `
|
|
30
|
+
uniform sampler2D _input_; // main`,
|
|
31
|
+
mainInputTexture: "_input_",
|
|
32
|
+
mainFunctionName: "_premultiply_",
|
|
33
|
+
functions: [
|
|
34
|
+
{
|
|
35
|
+
name: "_premultiply_",
|
|
36
|
+
code: `
|
|
37
|
+
vec4 _premultiply_(vec2 vUV) {
|
|
38
|
+
vec4 color = texture2D(_input_, vUV);
|
|
39
|
+
return vec4(color.rgb * color.a, color.a);
|
|
40
|
+
}
|
|
41
|
+
`,
|
|
42
|
+
params: "vec2 vUV",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The uniform names for this shader, to be used in the shader binding so
|
|
50
|
+
* that the names are always in sync.
|
|
51
|
+
*/
|
|
52
|
+
const Uniforms = {
|
|
53
|
+
input: "input",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The shader binding for the PremultiplyAlphaBlock, used by the runtime
|
|
59
|
+
*/
|
|
60
|
+
class PremultiplyAlphaBlockShaderBinding extends DisableableShaderBinding {
|
|
61
|
+
private readonly _input: RuntimeData<ConnectionPointType.Texture>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Creates a new shader binding instance for the block.
|
|
65
|
+
* @param parentBlock - IDisableableBlock
|
|
66
|
+
* @param input - The input runtime value
|
|
67
|
+
*/
|
|
68
|
+
constructor(
|
|
69
|
+
parentBlock: IDisableableBlock,
|
|
70
|
+
input: RuntimeData<ConnectionPointType.Texture>
|
|
71
|
+
) {
|
|
72
|
+
super(parentBlock);
|
|
73
|
+
this._input = input;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Binds all the required data to the shader when rendering.
|
|
78
|
+
* @param effect - defines the effect to bind the data to
|
|
79
|
+
*/
|
|
80
|
+
public override bind(effect: Effect): void {
|
|
81
|
+
super.bind(effect);
|
|
82
|
+
effect.setTexture(this.getRemappedName(Uniforms.input), this._input.value);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The implementation of the PremultiplyAlphaBlock
|
|
88
|
+
*/
|
|
89
|
+
export class PremultiplyAlphaBlock extends DisableableShaderBlock {
|
|
90
|
+
/**
|
|
91
|
+
* The class name of the block.
|
|
92
|
+
*/
|
|
93
|
+
public static override ClassName = "PremultiplyAlphaBlock";
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The namespace of the block.
|
|
97
|
+
*/
|
|
98
|
+
public static override Namespace = "Babylon.Demo.Utilities";
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The input connection point.
|
|
102
|
+
*/
|
|
103
|
+
public readonly input = this._registerInput(Uniforms.input, ConnectionPointType.Texture);
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The shader program (vertex and fragment code) to use to render the block
|
|
107
|
+
*/
|
|
108
|
+
public static override ShaderCode = BlockShaderProgram;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Instantiates a new PremultiplyAlphaBlock.
|
|
112
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
113
|
+
* @param name - The friendly name of the block
|
|
114
|
+
*/
|
|
115
|
+
constructor(smartFilter: SmartFilter, name: string) {
|
|
116
|
+
super(smartFilter, name, false, BlockDisableStrategy.AutoSample);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Get the class instance that binds all the required data to the shader (effect) when rendering.
|
|
121
|
+
* @returns The class instance that binds the data to the effect
|
|
122
|
+
*/
|
|
123
|
+
public getShaderBinding(): DisableableShaderBinding {
|
|
124
|
+
const input = this._confirmRuntimeDataSupplied(this.input);
|
|
125
|
+
|
|
126
|
+
return new PremultiplyAlphaBlockShaderBinding(this,input);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
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 */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
|
+
export const pixelateBlockType = "PixelateBlock";
|
|
3
|
+
export const blackAndWhiteBlockType = "BlackAndWhiteBlock";
|
|
4
|
+
export const exposureBlockType = "ExposureBlock";
|
|
5
|
+
export const contrastBlockType = "ContrastBlock";
|
|
6
|
+
export const desaturateBlockType = "DesaturateBlock";
|
|
7
|
+
export const posterizeBlockType = "PosterizeBlock";
|
|
8
|
+
export const kaleidoscopeBlockType = "KaleidoscopeBlock";
|
|
9
|
+
export const greenScreenBlockType = "GreenScreenBlock";
|
|
10
|
+
export const glassBlockType = "GlassBlock";
|
|
11
|
+
export const frameBlockType = "FrameBlock";
|
|
12
|
+
export const blurBlockType = "BlurBlock";
|
|
13
|
+
export const directionalBlurBlockType = "DirectionalBlurBlock";
|
|
14
|
+
export const compositionBlockType = "CompositionBlock";
|
|
15
|
+
export const glitchBlockType = "GlitchBlock";
|
|
16
|
+
export const tileBlockType = "TileBlock";
|
|
17
|
+
export const wipeBlockType = "WipeBlock";
|
|
18
|
+
export const maskBlockType = "MaskBlock";
|
|
19
|
+
export const particleBlockType = "ParticleBlock";
|
|
20
|
+
export const spritesheetBlockType = "SpritesheetBlock";
|
|
21
|
+
export const tintBlockType = "TintBlock";
|
|
22
|
+
export const premultiplyAlphaBlockType = "PremultiplyAlphaBlock";
|
|
23
|
+
/* eslint-enable @typescript-eslint/naming-convention */
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* eslint-disable import/no-internal-modules */
|
|
2
|
+
export * from "./babylon/demo/effects/index.js";
|
|
3
|
+
export * from "./babylon/demo/transitions/index.js";
|
|
4
|
+
export * from "./babylon/demo/utilities/index.js";
|
|
5
|
+
export * from "./blockTypes.js";
|
|
6
|
+
export * from "./blockNamespaces.js";
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ThinEngine } from "core/Engines/thinEngine.js";
|
|
2
|
+
import type { SmartFilter, SmartFilterDeserializer, ISerializedBlockV1, BaseBlock } from "smart-filters";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* An object which describes a block definition, as well as a factory for creating a new instance of the block or
|
|
6
|
+
* deserializing it
|
|
7
|
+
*/
|
|
8
|
+
export interface IBlockRegistration {
|
|
9
|
+
/**
|
|
10
|
+
* The block type of the block
|
|
11
|
+
*/
|
|
12
|
+
blockType: string;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Creates an instance of the block, either fresh or deserialized from a serialized block
|
|
16
|
+
* @param smartFilter - The smart filter to create the block for
|
|
17
|
+
* @param engine - The engine to use for creating blocks
|
|
18
|
+
* @param smartFilterDeserializer - The deserializer to use for deserializing blocks
|
|
19
|
+
* @param serializedBlock - The serialized block to deserialize, if any
|
|
20
|
+
* @returns - A promise for a new instance of the block
|
|
21
|
+
*/
|
|
22
|
+
factory?: (smartFilter: SmartFilter, engine: ThinEngine, smartFilterDeserializer: SmartFilterDeserializer, serializedBlock?: ISerializedBlockV1) => Promise<BaseBlock>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The namespace of the block
|
|
26
|
+
*/
|
|
27
|
+
namespace: string;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* A tooltip for the block if displayed in an editor, for instance
|
|
31
|
+
*/
|
|
32
|
+
tooltip: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* True if this is an input block
|
|
36
|
+
*/
|
|
37
|
+
isInput?: boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* If true, this represents a custom block (not one that was programmatically included)
|
|
41
|
+
*/
|
|
42
|
+
isCustom?: boolean;
|
|
43
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { IBlockSerializerV1 } from "smart-filters";
|
|
2
|
+
import { BlurBlockSerializer } from "../blocks/babylon/demo/effects/blurBlock.serializer.js";
|
|
3
|
+
import { DirectionalBlurBlockSerializer } from "../blocks/babylon/demo/effects/directionalBlurBlock.serializer.js";
|
|
4
|
+
import { CompositionBlockSerializer } from "../blocks/babylon/demo/effects/compositionBlock.serializer.js";
|
|
5
|
+
import {
|
|
6
|
+
blackAndWhiteBlockType,
|
|
7
|
+
pixelateBlockType,
|
|
8
|
+
exposureBlockType,
|
|
9
|
+
contrastBlockType,
|
|
10
|
+
desaturateBlockType,
|
|
11
|
+
posterizeBlockType,
|
|
12
|
+
kaleidoscopeBlockType,
|
|
13
|
+
greenScreenBlockType,
|
|
14
|
+
maskBlockType,
|
|
15
|
+
particleBlockType,
|
|
16
|
+
spritesheetBlockType,
|
|
17
|
+
tintBlockType,
|
|
18
|
+
premultiplyAlphaBlockType,
|
|
19
|
+
wipeBlockType,
|
|
20
|
+
} from "../blocks/blockTypes.js";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Any blocks that do not need to make use of ISerializedBlockV1.data can use the default serialization and
|
|
24
|
+
* should go in this list. If the serializer needs to store additional info in ISerializedBlockV1.data (e.g.
|
|
25
|
+
* webcam source name), then it should be registered in additionalBlockSerializers below.
|
|
26
|
+
*/
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
28
|
+
export const blocksUsingDefaultSerialization: string[] = [
|
|
29
|
+
blackAndWhiteBlockType,
|
|
30
|
+
pixelateBlockType,
|
|
31
|
+
exposureBlockType,
|
|
32
|
+
contrastBlockType,
|
|
33
|
+
desaturateBlockType,
|
|
34
|
+
posterizeBlockType,
|
|
35
|
+
kaleidoscopeBlockType,
|
|
36
|
+
greenScreenBlockType,
|
|
37
|
+
maskBlockType,
|
|
38
|
+
particleBlockType,
|
|
39
|
+
spritesheetBlockType,
|
|
40
|
+
tintBlockType,
|
|
41
|
+
premultiplyAlphaBlockType,
|
|
42
|
+
wipeBlockType,
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Any blocks which require serializing more information than just the connections should be registered here.
|
|
47
|
+
* They should make use of the ISerializedBlockV1.data field to store this information.
|
|
48
|
+
*/
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
50
|
+
export const additionalBlockSerializers: IBlockSerializerV1[] = [BlurBlockSerializer, DirectionalBlurBlockSerializer, CompositionBlockSerializer];
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import type { ThinEngine } from "core/Engines/thinEngine.js";
|
|
2
|
+
import { InputBlock, type SmartFilter, type SmartFilterDeserializer, type ISerializedBlockV1, ConnectionPointType, CustomShaderBlock } from "smart-filters";
|
|
3
|
+
import type { IBlockRegistration } from "./IBlockRegistration.js";
|
|
4
|
+
import { babylonDemoEffectsNamespace, babylonDemoTransitionsNamespace, babylonDemoUtilitiesNamespace, inputsNamespace } from "../blocks/blockNamespaces.js";
|
|
5
|
+
import {
|
|
6
|
+
blackAndWhiteBlockType,
|
|
7
|
+
kaleidoscopeBlockType,
|
|
8
|
+
posterizeBlockType,
|
|
9
|
+
desaturateBlockType,
|
|
10
|
+
contrastBlockType,
|
|
11
|
+
greenScreenBlockType,
|
|
12
|
+
pixelateBlockType,
|
|
13
|
+
exposureBlockType,
|
|
14
|
+
maskBlockType,
|
|
15
|
+
spritesheetBlockType,
|
|
16
|
+
premultiplyAlphaBlockType,
|
|
17
|
+
wipeBlockType,
|
|
18
|
+
blurBlockType,
|
|
19
|
+
compositionBlockType,
|
|
20
|
+
tintBlockType,
|
|
21
|
+
} from "../blocks/blockTypes.js";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The list of block registrations.
|
|
25
|
+
*
|
|
26
|
+
* Important notes:
|
|
27
|
+
* 1. Do not import the block code directly in this file. Instead, use dynamic imports to ensure that the block code
|
|
28
|
+
* is only loaded when needed.
|
|
29
|
+
* 2. If the deserializer is trivial (doesn't require consulting the serializedBlock.data), it can be implemented here
|
|
30
|
+
* 3. If the deserializer is non-trivial (needs serializedBlock.data), implement it in a separate file alongside the block
|
|
31
|
+
* in the form blockClassName.deserializer.ts
|
|
32
|
+
*/
|
|
33
|
+
export const BuiltInBlockRegistrations: IBlockRegistration[] = [
|
|
34
|
+
// Blocks with trivial deserializers
|
|
35
|
+
// Note that some choose to predefine corresponding input blocks if not being deserialized
|
|
36
|
+
// ---------------------------------------------------------------------------------------
|
|
37
|
+
{
|
|
38
|
+
blockType: blackAndWhiteBlockType,
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
40
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
41
|
+
const module = await import(/* webpackChunkName: "blackAndWhiteBlock" */ "../blocks/babylon/demo/effects/blackAndWhiteBlock.block.js");
|
|
42
|
+
return new module.BlackAndWhiteBlock(smartFilter, serializedBlock?.name || "BlackAndWhite");
|
|
43
|
+
},
|
|
44
|
+
namespace: babylonDemoEffectsNamespace,
|
|
45
|
+
tooltip: "Transform the input texture to black and white",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
blockType: kaleidoscopeBlockType,
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
50
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
51
|
+
const module = await import(/* webpackChunkName: "kaleidoscopeBlock" */ "../blocks/babylon/demo/effects/kaleidoscopeBlock.js");
|
|
52
|
+
const block = new module.KaleidoscopeBlock(smartFilter, serializedBlock?.name || "Kaleidoscope");
|
|
53
|
+
if (!serializedBlock) {
|
|
54
|
+
const input = new InputBlock(smartFilter, "Angle", ConnectionPointType.Float, 0);
|
|
55
|
+
input.output.connectTo(block.time);
|
|
56
|
+
}
|
|
57
|
+
return block;
|
|
58
|
+
},
|
|
59
|
+
namespace: babylonDemoEffectsNamespace,
|
|
60
|
+
tooltip: "Kaleidoscope effect",
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
blockType: posterizeBlockType,
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
65
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
66
|
+
const module = await import(/* webpackChunkName: "posterizeBlock" */ "../blocks/babylon/demo/effects/posterizeBlock.block.js");
|
|
67
|
+
const block = new module.PosterizeBlock(smartFilter, serializedBlock?.name || "Posterize");
|
|
68
|
+
if (!serializedBlock) {
|
|
69
|
+
const input = new InputBlock(smartFilter, "Intensity", ConnectionPointType.Float, 0.5);
|
|
70
|
+
input.output.connectTo(block.intensity);
|
|
71
|
+
}
|
|
72
|
+
return block;
|
|
73
|
+
},
|
|
74
|
+
namespace: babylonDemoEffectsNamespace,
|
|
75
|
+
tooltip: "Posterize to the input texture",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
blockType: desaturateBlockType,
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
80
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
81
|
+
const module = await import(/* webpackChunkName: "desaturateBlock" */ "../blocks/babylon/demo/effects/desaturateBlock.block.js");
|
|
82
|
+
const block = new module.DesaturateBlock(smartFilter, serializedBlock?.name || "Desaturate");
|
|
83
|
+
if (!serializedBlock) {
|
|
84
|
+
const input = new InputBlock(smartFilter, "Intensity", ConnectionPointType.Float, 0.5);
|
|
85
|
+
input.output.connectTo(block.intensity);
|
|
86
|
+
}
|
|
87
|
+
return block;
|
|
88
|
+
},
|
|
89
|
+
namespace: babylonDemoEffectsNamespace,
|
|
90
|
+
tooltip: "Applies a desaturated effect to the input texture",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
blockType: contrastBlockType,
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
95
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
96
|
+
const module = await import(/* webpackChunkName: "contrastBlock" */ "../blocks/babylon/demo/effects/contrastBlock.block.js");
|
|
97
|
+
const block = new module.ContrastBlock(smartFilter, serializedBlock?.name || "Contrast");
|
|
98
|
+
if (!serializedBlock) {
|
|
99
|
+
const input = new InputBlock(smartFilter, "Intensity", ConnectionPointType.Float, 0.5);
|
|
100
|
+
input.output.connectTo(block.intensity);
|
|
101
|
+
}
|
|
102
|
+
return block;
|
|
103
|
+
},
|
|
104
|
+
namespace: babylonDemoEffectsNamespace,
|
|
105
|
+
tooltip: "Change the contrast of the input texture",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
blockType: greenScreenBlockType,
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
110
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
111
|
+
const module = await import(/* webpackChunkName: "greenScreenBlock" */ "../blocks/babylon/demo/effects/greenScreenBlock.block.js");
|
|
112
|
+
const block = new module.GreenScreenBlock(smartFilter, serializedBlock?.name || "GreenScreen");
|
|
113
|
+
if (!serializedBlock) {
|
|
114
|
+
const reference = new InputBlock(smartFilter, "Reference", ConnectionPointType.Color3, {
|
|
115
|
+
r: 92 / 255,
|
|
116
|
+
g: 204 / 255,
|
|
117
|
+
b: 78 / 255,
|
|
118
|
+
});
|
|
119
|
+
const distance = new InputBlock(smartFilter, "Distance", ConnectionPointType.Float, 0.25);
|
|
120
|
+
reference.output.connectTo(block.reference);
|
|
121
|
+
distance.output.connectTo(block.distance);
|
|
122
|
+
}
|
|
123
|
+
return block;
|
|
124
|
+
},
|
|
125
|
+
namespace: babylonDemoEffectsNamespace,
|
|
126
|
+
tooltip: "Replaces a green screen background with a different texture",
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
blockType: pixelateBlockType,
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
131
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
132
|
+
const module = await import(/* webpackChunkName: "pixelateBlock" */ "../blocks/babylon/demo/effects/pixelateBlock.block.js");
|
|
133
|
+
const block = new module.PixelateBlock(smartFilter, serializedBlock?.name || "Pixelate");
|
|
134
|
+
if (!serializedBlock) {
|
|
135
|
+
const input = new InputBlock(smartFilter, "Intensity", ConnectionPointType.Float, 0.4);
|
|
136
|
+
input.output.connectTo(block.intensity);
|
|
137
|
+
}
|
|
138
|
+
return block;
|
|
139
|
+
},
|
|
140
|
+
namespace: babylonDemoEffectsNamespace,
|
|
141
|
+
tooltip: "Add pixelation to the input texture",
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
blockType: exposureBlockType,
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
146
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
147
|
+
const module = await import(/* webpackChunkName: "exposureBlock" */ "../blocks/babylon/demo/effects/exposureBlock.block.js");
|
|
148
|
+
const block = new module.ExposureBlock(smartFilter, serializedBlock?.name || "Exposure");
|
|
149
|
+
if (!serializedBlock) {
|
|
150
|
+
const input = new InputBlock(smartFilter, "Amount", ConnectionPointType.Float, 0.7);
|
|
151
|
+
input.output.connectTo(block.amount);
|
|
152
|
+
}
|
|
153
|
+
return block;
|
|
154
|
+
},
|
|
155
|
+
namespace: babylonDemoEffectsNamespace,
|
|
156
|
+
tooltip: "Alters the exposure of the input texture",
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
blockType: maskBlockType,
|
|
160
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
161
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
162
|
+
const module = await import(/* webpackChunkName: "maskBlock" */ "../blocks/babylon/demo/effects/maskBlock.block.js");
|
|
163
|
+
return new module.MaskBlock(smartFilter, serializedBlock?.name || "Mask");
|
|
164
|
+
},
|
|
165
|
+
namespace: babylonDemoEffectsNamespace,
|
|
166
|
+
tooltip: "Applies mask in one texture to another texture",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
blockType: spritesheetBlockType,
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
171
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
172
|
+
const module = await import(/* webpackChunkName: "spritesheetBlock" */ "../blocks/babylon/demo/effects/spritesheetBlock.js");
|
|
173
|
+
return new module.SpritesheetBlock(smartFilter, serializedBlock?.name || "Spritesheet");
|
|
174
|
+
},
|
|
175
|
+
namespace: babylonDemoEffectsNamespace,
|
|
176
|
+
tooltip: "Animates a sprite sheet texture",
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
blockType: premultiplyAlphaBlockType,
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
181
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
182
|
+
const module = await import(/* webpackChunkName: "premultiplyAlphaBlock" */ "../blocks/babylon/demo/utilities/premultiplyAlphaBlock.block.js");
|
|
183
|
+
return new module.PremultiplyAlphaBlock(smartFilter, serializedBlock?.name || "PremultiplyAlpha");
|
|
184
|
+
},
|
|
185
|
+
namespace: babylonDemoUtilitiesNamespace,
|
|
186
|
+
tooltip: "Premultiplies the input texture's color against its alpha",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
blockType: wipeBlockType,
|
|
190
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
191
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
192
|
+
const module = await import(/* webpackChunkName: "wipeBlock" */ "../blocks/babylon/demo/transitions/wipeBlock.block.js");
|
|
193
|
+
return new module.WipeBlock(smartFilter, serializedBlock?.name || "Wipe");
|
|
194
|
+
},
|
|
195
|
+
namespace: babylonDemoTransitionsNamespace,
|
|
196
|
+
tooltip: "Transition from one texture to another using a wipe",
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
// Blocks with custom deserializers
|
|
200
|
+
// --------------------------------
|
|
201
|
+
{
|
|
202
|
+
blockType: blurBlockType,
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
204
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
205
|
+
if (serializedBlock) {
|
|
206
|
+
const module = await import(/* webpackChunkName: "blurBlockDeserializer" */ "../blocks/babylon/demo/effects/blurBlock.deserializer.js");
|
|
207
|
+
return module.BlurBlockDeserializer(smartFilter, serializedBlock);
|
|
208
|
+
} else {
|
|
209
|
+
const module = await import(/* webpackChunkName: "blurBlock" */ "../blocks/babylon/demo/effects/blurBlock.js");
|
|
210
|
+
return new module.BlurBlock(smartFilter, "Blur");
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
namespace: babylonDemoEffectsNamespace,
|
|
214
|
+
tooltip: "Blur the input texture",
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
blockType: compositionBlockType,
|
|
218
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
219
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
220
|
+
if (serializedBlock) {
|
|
221
|
+
const module = await import(/* webpackChunkName: "compositionBlockDeserializer" */ "../blocks/babylon/demo/effects/compositionBlock.deserializer.js");
|
|
222
|
+
return module.CompositionDeserializer(smartFilter, serializedBlock);
|
|
223
|
+
} else {
|
|
224
|
+
const module = await import(/* webpackChunkName: "compositionBlock" */ "../blocks/babylon/demo/effects/compositionBlock.js");
|
|
225
|
+
const block = new module.CompositionBlock(smartFilter, "Composition");
|
|
226
|
+
const top = new InputBlock(smartFilter, "Top", ConnectionPointType.Float, 0.0);
|
|
227
|
+
const left = new InputBlock(smartFilter, "Left", ConnectionPointType.Float, 0.0);
|
|
228
|
+
const width = new InputBlock(smartFilter, "Width", ConnectionPointType.Float, 1.0);
|
|
229
|
+
const height = new InputBlock(smartFilter, "Height", ConnectionPointType.Float, 1.0);
|
|
230
|
+
|
|
231
|
+
top.output.connectTo(block.foregroundTop);
|
|
232
|
+
left.output.connectTo(block.foregroundLeft);
|
|
233
|
+
width.output.connectTo(block.foregroundWidth);
|
|
234
|
+
height.output.connectTo(block.foregroundHeight);
|
|
235
|
+
return block;
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
namespace: babylonDemoEffectsNamespace,
|
|
239
|
+
tooltip: "Composite the foreground texture over the background texture",
|
|
240
|
+
},
|
|
241
|
+
|
|
242
|
+
// Blocks defined by serialized definitions
|
|
243
|
+
// ----------------------------------------
|
|
244
|
+
{
|
|
245
|
+
blockType: tintBlockType,
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
247
|
+
factory: async (smartFilter: SmartFilter, _engine: ThinEngine, _smartFilterDeserializer: SmartFilterDeserializer, serializedBlock: ISerializedBlockV1 | undefined) => {
|
|
248
|
+
const module = await import(/* webpackChunkName: "tintBlock" */ "../blocks/babylon/demo/effects/tintBlock.js");
|
|
249
|
+
return CustomShaderBlock.Create(smartFilter, serializedBlock?.name || "Tint", module.DeserializedTintBlockDefinition);
|
|
250
|
+
},
|
|
251
|
+
namespace: babylonDemoEffectsNamespace,
|
|
252
|
+
tooltip: "Adds colored tint to the input texture",
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
// Standard input blocks
|
|
256
|
+
// ---------------------
|
|
257
|
+
{
|
|
258
|
+
blockType: "Float",
|
|
259
|
+
namespace: inputsNamespace,
|
|
260
|
+
isInput: true,
|
|
261
|
+
tooltip: "A floating point number representing a value with a fractional component",
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
blockType: "Color3",
|
|
265
|
+
namespace: inputsNamespace,
|
|
266
|
+
isInput: true,
|
|
267
|
+
tooltip: "A set of 3 floating point numbers representing a color",
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
blockType: "Color4",
|
|
271
|
+
namespace: inputsNamespace,
|
|
272
|
+
isInput: true,
|
|
273
|
+
tooltip: "A set of 4 floating point numbers representing a color",
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
blockType: "Texture",
|
|
277
|
+
namespace: inputsNamespace,
|
|
278
|
+
isInput: true,
|
|
279
|
+
tooltip: "A texture to be used as input",
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
blockType: "Vector2",
|
|
283
|
+
namespace: inputsNamespace,
|
|
284
|
+
isInput: true,
|
|
285
|
+
tooltip: "A Vector2 to be used as input",
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
blockType: "Boolean",
|
|
289
|
+
namespace: inputsNamespace,
|
|
290
|
+
isInput: true,
|
|
291
|
+
tooltip: "A boolean to be used as input",
|
|
292
|
+
},
|
|
293
|
+
];
|