@babylonjs/smart-filters 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.
- package/dist/blockFoundation/aggregateBlock.d.ts +3 -3
- package/dist/blockFoundation/aggregateBlock.d.ts.map +1 -1
- package/dist/blockFoundation/aggregateBlock.js +1 -2
- package/dist/blockFoundation/aggregateBlock.js.map +1 -1
- package/dist/blockFoundation/baseBlock.d.ts +2 -2
- package/dist/blockFoundation/baseBlock.d.ts.map +1 -1
- package/dist/blockFoundation/baseBlock.js +5 -6
- package/dist/blockFoundation/baseBlock.js.map +1 -1
- package/dist/blockFoundation/customAggregateBlock.d.ts.map +1 -1
- package/dist/blockFoundation/customAggregateBlock.js +2 -2
- package/dist/blockFoundation/customAggregateBlock.js.map +1 -1
- package/dist/blockFoundation/customShaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/customShaderBlock.js +4 -6
- package/dist/blockFoundation/customShaderBlock.js.map +1 -1
- package/dist/blockFoundation/disableableShaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/disableableShaderBlock.js +4 -4
- package/dist/blockFoundation/disableableShaderBlock.js.map +1 -1
- package/dist/blockFoundation/index.js +0 -2
- package/dist/blockFoundation/index.js.map +1 -1
- package/dist/blockFoundation/inputBlock.d.ts +8 -8
- package/dist/blockFoundation/inputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.d.ts +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.js +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.js.map +1 -1
- package/dist/blockFoundation/inputBlock.js +7 -7
- package/dist/blockFoundation/inputBlock.js.map +1 -1
- package/dist/blockFoundation/inputBlock.serialization.types.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.serializer.d.ts +1 -1
- package/dist/blockFoundation/inputBlock.serializer.js +26 -28
- package/dist/blockFoundation/inputBlock.serializer.js.map +1 -1
- package/dist/blockFoundation/outputBlock.d.ts +4 -9
- package/dist/blockFoundation/outputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/outputBlock.js +13 -14
- package/dist/blockFoundation/outputBlock.js.map +1 -1
- package/dist/blockFoundation/shaderBlock.d.ts +4 -4
- package/dist/blockFoundation/shaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/shaderBlock.js +13 -19
- package/dist/blockFoundation/shaderBlock.js.map +1 -1
- package/dist/blockFoundation/textureOptions.d.ts +1 -1
- package/dist/blockFoundation/textureOptions.js +1 -1
- package/dist/command/command.d.ts +1 -1
- package/dist/command/command.js +1 -1
- package/dist/command/commandBuffer.d.ts +1 -1
- package/dist/command/commandBuffer.d.ts.map +1 -1
- package/dist/command/commandBuffer.js +2 -2
- package/dist/command/commandBufferDebugger.d.ts +2 -2
- package/dist/command/commandBufferDebugger.d.ts.map +1 -1
- package/dist/command/commandBufferDebugger.js +1 -1
- package/dist/command/commandBufferDebugger.js.map +1 -1
- package/dist/command/index.d.ts +3 -1
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +5 -1
- package/dist/command/index.js.map +1 -1
- package/dist/connection/connectionPoint.d.ts +3 -3
- package/dist/connection/connectionPoint.d.ts.map +1 -1
- package/dist/connection/connectionPoint.js +2 -2
- package/dist/connection/connectionPoint.js.map +1 -1
- package/dist/connection/connectionPointCompatibilityState.d.ts +1 -1
- package/dist/connection/connectionPointCompatibilityState.js +1 -1
- package/dist/connection/connectionPointType.d.ts +3 -3
- package/dist/connection/connectionPointType.d.ts.map +1 -1
- package/dist/connection/connectionPointWithDefault.d.ts +3 -3
- package/dist/connection/connectionPointWithDefault.d.ts.map +1 -1
- package/dist/connection/connectionPointWithDefault.js.map +1 -1
- package/dist/connection/index.d.ts +2 -1
- package/dist/connection/index.d.ts.map +1 -1
- package/dist/connection/index.js +3 -3
- package/dist/connection/index.js.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.d.ts +2 -2
- package/dist/editorUtils/editableInPropertyPage.d.ts.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.js +2 -2
- package/dist/editorUtils/editableInPropertyPage.js.map +1 -1
- package/dist/editorUtils/index.d.ts +1 -0
- package/dist/editorUtils/index.d.ts.map +1 -1
- package/dist/editorUtils/index.js +2 -0
- package/dist/editorUtils/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/optimization/dependencyGraph.js.map +1 -1
- package/dist/optimization/optimizedShaderBlock.d.ts +4 -4
- package/dist/optimization/optimizedShaderBlock.d.ts.map +1 -1
- package/dist/optimization/optimizedShaderBlock.js.map +1 -1
- package/dist/optimization/smartFilterOptimizer.d.ts +2 -2
- package/dist/optimization/smartFilterOptimizer.d.ts.map +1 -1
- package/dist/optimization/smartFilterOptimizer.js +34 -57
- package/dist/optimization/smartFilterOptimizer.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts.map +1 -1
- package/dist/runtime/renderTargetGenerator.js +5 -7
- package/dist/runtime/renderTargetGenerator.js.map +1 -1
- package/dist/runtime/shaderRuntime.d.ts +7 -7
- package/dist/runtime/shaderRuntime.d.ts.map +1 -1
- package/dist/runtime/shaderRuntime.js +7 -8
- package/dist/runtime/shaderRuntime.js.map +1 -1
- package/dist/runtime/smartFilterRuntime.d.ts +3 -3
- package/dist/runtime/smartFilterRuntime.d.ts.map +1 -1
- package/dist/runtime/smartFilterRuntime.js.map +1 -1
- package/dist/runtime/strongRef.d.ts +1 -1
- package/dist/runtime/strongRef.js +1 -1
- package/dist/serialization/importCustomBlockDefinition.d.ts +1 -1
- package/dist/serialization/importCustomBlockDefinition.js +8 -9
- package/dist/serialization/importCustomBlockDefinition.js.map +1 -1
- package/dist/serialization/index.d.ts +1 -0
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/index.js +3 -0
- package/dist/serialization/index.js.map +1 -1
- package/dist/serialization/serializedBlockDefinition.d.ts +2 -2
- package/dist/serialization/serializedBlockDefinition.d.ts.map +1 -1
- package/dist/serialization/serializedShaderBlockDefinition.d.ts +1 -1
- package/dist/serialization/serializedShaderBlockDefinition.d.ts.map +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.d.ts +6 -6
- package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.js +9 -12
- package/dist/serialization/smartFilterDeserializer.js.map +1 -1
- package/dist/serialization/smartFilterSerializer.d.ts +2 -2
- package/dist/serialization/smartFilterSerializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterSerializer.js +10 -13
- package/dist/serialization/smartFilterSerializer.js.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.d.ts +2 -2
- package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.js +1 -1
- package/dist/serialization/v1/index.d.ts +1 -0
- package/dist/serialization/v1/index.d.ts.map +1 -1
- package/dist/serialization/v1/index.js +2 -0
- package/dist/serialization/v1/index.js.map +1 -1
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts +3 -3
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts.map +1 -1
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts +2 -2
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -1
- package/dist/smartFilter.d.ts +8 -8
- package/dist/smartFilter.d.ts.map +1 -1
- package/dist/smartFilter.js +6 -7
- package/dist/smartFilter.js.map +1 -1
- package/dist/utils/buildTools/buildShaders.d.ts +3 -2
- package/dist/utils/buildTools/buildShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/buildShaders.js +7 -6
- package/dist/utils/buildTools/buildShaders.js.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts +4 -2
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoBlock.js +136 -141
- package/dist/utils/buildTools/convertGlslIntoBlock.js.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts +4 -4
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js +55 -48
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js.map +1 -1
- package/dist/utils/buildTools/convertShaders.d.ts +8 -5
- package/dist/utils/buildTools/convertShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/convertShaders.js +38 -14
- package/dist/utils/buildTools/convertShaders.js.map +1 -1
- package/dist/utils/buildTools/shaderConverter.d.ts +4 -4
- package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -1
- package/dist/utils/buildTools/shaderConverter.js +17 -21
- package/dist/utils/buildTools/shaderConverter.js.map +1 -1
- package/dist/utils/buildTools/watchShaders.d.ts +3 -2
- package/dist/utils/buildTools/watchShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/watchShaders.js +10 -8
- package/dist/utils/buildTools/watchShaders.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/renderTargetUtils.d.ts +3 -3
- package/dist/utils/renderTargetUtils.d.ts.map +1 -1
- package/dist/utils/renderTargetUtils.js +4 -4
- package/dist/utils/renderTargetUtils.js.map +1 -1
- package/dist/utils/shaderCodeUtils.d.ts +8 -8
- package/dist/utils/shaderCodeUtils.d.ts.map +1 -1
- package/dist/utils/shaderCodeUtils.js +16 -28
- package/dist/utils/shaderCodeUtils.js.map +1 -1
- package/dist/utils/textureLoaders.d.ts +2 -2
- package/dist/utils/textureLoaders.d.ts.map +1 -1
- package/dist/utils/textureLoaders.js +2 -3
- package/dist/utils/textureLoaders.js.map +1 -1
- package/dist/utils/textureUtils.d.ts +5 -5
- package/dist/utils/textureUtils.d.ts.map +1 -1
- package/dist/utils/textureUtils.js +1 -1
- package/dist/utils/textureUtils.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/license.md +21 -21
- package/package.json +13 -8
- package/src/blockFoundation/aggregateBlock.ts +148 -151
- package/src/blockFoundation/baseBlock.ts +339 -364
- package/src/blockFoundation/customAggregateBlock.ts +88 -104
- package/src/blockFoundation/customShaderBlock.ts +312 -326
- package/src/blockFoundation/disableableShaderBlock.ts +91 -100
- package/src/blockFoundation/index.ts +9 -9
- package/src/blockFoundation/inputBlock.deserializer.ts +72 -97
- package/src/blockFoundation/inputBlock.serialization.types.ts +126 -132
- package/src/blockFoundation/inputBlock.serializer.ts +150 -150
- package/src/blockFoundation/inputBlock.ts +181 -192
- package/src/blockFoundation/outputBlock.ts +144 -151
- package/src/blockFoundation/shaderBlock.ts +156 -163
- package/src/blockFoundation/textureOptions.ts +57 -57
- package/src/command/command.ts +59 -59
- package/src/command/commandBuffer.ts +71 -71
- package/src/command/commandBufferDebugger.ts +14 -14
- package/src/command/index.ts +7 -3
- package/src/connection/connectionPoint.ts +205 -214
- package/src/connection/connectionPointCompatibilityState.ts +31 -31
- package/src/connection/connectionPointType.ts +45 -45
- package/src/connection/connectionPointWithDefault.ts +27 -35
- package/src/connection/index.ts +8 -9
- package/src/editorUtils/editableInPropertyPage.ts +106 -106
- package/src/editorUtils/index.ts +3 -1
- package/src/index.ts +16 -15
- package/src/optimization/dependencyGraph.ts +96 -96
- package/src/optimization/index.ts +1 -1
- package/src/optimization/optimizedShaderBlock.ts +131 -134
- package/src/optimization/smartFilterOptimizer.ts +757 -825
- package/src/runtime/index.ts +8 -6
- package/src/runtime/renderTargetGenerator.ts +222 -248
- package/src/runtime/shaderRuntime.ts +174 -173
- package/src/runtime/smartFilterRuntime.ts +112 -112
- package/src/runtime/strongRef.ts +18 -18
- package/src/serialization/importCustomBlockDefinition.ts +86 -86
- package/src/serialization/index.ts +10 -7
- package/src/serialization/serializedBlockDefinition.ts +12 -12
- package/src/serialization/serializedShaderBlockDefinition.ts +7 -7
- package/src/serialization/serializedSmartFilter.ts +6 -6
- package/src/serialization/smartFilterDeserializer.ts +190 -220
- package/src/serialization/smartFilterSerializer.ts +110 -121
- package/src/serialization/v1/defaultBlockSerializer.ts +21 -21
- package/src/serialization/v1/index.ts +4 -2
- package/src/serialization/v1/shaderBlockSerialization.types.ts +85 -85
- package/src/serialization/v1/smartFilterSerialization.types.ts +129 -133
- package/src/smartFilter.ts +255 -260
- package/src/utils/buildTools/buildShaders.ts +14 -13
- package/src/utils/buildTools/convertGlslIntoBlock.ts +370 -385
- package/src/utils/buildTools/convertGlslIntoShaderProgram.ts +173 -172
- package/src/utils/buildTools/convertShaders.ts +65 -43
- package/src/utils/buildTools/recordVersionNumber.js +17 -0
- package/src/utils/buildTools/shaderConverter.ts +466 -478
- package/src/utils/buildTools/watchShaders.ts +44 -42
- package/src/utils/index.ts +4 -2
- package/src/utils/renderTargetUtils.ts +30 -35
- package/src/utils/shaderCodeUtils.ts +192 -207
- package/src/utils/textureLoaders.ts +31 -43
- package/src/utils/textureUtils.ts +28 -32
- package/src/version.ts +2 -2
- package/dist/utils/buildTools/determineVersion.d.ts +0 -36
- package/dist/utils/buildTools/determineVersion.d.ts.map +0 -1
- package/dist/utils/buildTools/determineVersion.js +0 -109
- package/dist/utils/buildTools/determineVersion.js.map +0 -1
- package/dist/utils/buildTools/versionUp.d.ts +0 -2
- package/dist/utils/buildTools/versionUp.d.ts.map +0 -1
- package/dist/utils/buildTools/versionUp.js +0 -53
- package/dist/utils/buildTools/versionUp.js.map +0 -1
- package/src/utils/buildTools/determineVersion.ts +0 -128
- package/src/utils/buildTools/versionUp.ts +0 -61
|
@@ -1,100 +1,91 @@
|
|
|
1
|
-
import type { SmartFilter } from "../smartFilter.js";
|
|
2
|
-
import type { ConnectionPoint } from "../connection/connectionPoint.js";
|
|
3
|
-
|
|
4
|
-
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
5
|
-
import {
|
|
6
|
-
import { ShaderBlock } from "./shaderBlock.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The interface that describes the disableable block.
|
|
11
|
-
*/
|
|
12
|
-
export interface IDisableableBlock {
|
|
13
|
-
/**
|
|
14
|
-
* The disabled connection point of the block.
|
|
15
|
-
*/
|
|
16
|
-
disabled: ConnectionPoint<ConnectionPointType.Boolean>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The strategy to use for making a block disableable.
|
|
21
|
-
*/
|
|
22
|
-
export enum BlockDisableStrategy {
|
|
23
|
-
/**
|
|
24
|
-
* The shader code is responsible for defining and consulting a uniform named disabled
|
|
25
|
-
* and no-oping (returning texture2D(mainInputTexture, vUV)) if the value is true.
|
|
26
|
-
*/
|
|
27
|
-
Manual = 0,
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The Smart Filter system will automatically add code to sample the mainInputTexture and return immediately if disabled,
|
|
31
|
-
* and otherwise use the value within the block's shader code. If you need to modify UVs before sampling the default input texture,
|
|
32
|
-
* you'll need to use the Manual strategy instead.
|
|
33
|
-
*/
|
|
34
|
-
AutoSample = 1,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A ShaderBlock that can be disabled. The optimizer can optionally remove disabled blocks from the graph,
|
|
39
|
-
* or they can be controlled by the disabled connection point at runtime. If disabled, they pass the
|
|
40
|
-
* mainInputTexture through to the output connection point.
|
|
41
|
-
*/
|
|
42
|
-
export abstract class DisableableShaderBlock extends ShaderBlock implements IDisableableBlock {
|
|
43
|
-
/**
|
|
44
|
-
* The disabled connection point of the block.
|
|
45
|
-
*/
|
|
46
|
-
public readonly disabled = this._registerOptionalInput(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
//
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
private
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const shaderProgram = this.getShaderProgram();
|
|
93
|
-
switch (this.blockDisableStrategy) {
|
|
94
|
-
case BlockDisableStrategy.AutoSample:
|
|
95
|
-
injectAutoSampleDisableCode(shaderProgram);
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
1
|
+
import type { SmartFilter } from "../smartFilter.js";
|
|
2
|
+
import type { ConnectionPoint } from "../connection/connectionPoint.js";
|
|
3
|
+
|
|
4
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
5
|
+
import { CreateStrongRef } from "../runtime/strongRef.js";
|
|
6
|
+
import { ShaderBlock } from "./shaderBlock.js";
|
|
7
|
+
import { InjectAutoSampleDisableCode } from "../utils/shaderCodeUtils.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The interface that describes the disableable block.
|
|
11
|
+
*/
|
|
12
|
+
export interface IDisableableBlock {
|
|
13
|
+
/**
|
|
14
|
+
* The disabled connection point of the block.
|
|
15
|
+
*/
|
|
16
|
+
disabled: ConnectionPoint<ConnectionPointType.Boolean>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The strategy to use for making a block disableable.
|
|
21
|
+
*/
|
|
22
|
+
export enum BlockDisableStrategy {
|
|
23
|
+
/**
|
|
24
|
+
* The shader code is responsible for defining and consulting a uniform named disabled
|
|
25
|
+
* and no-oping (returning texture2D(mainInputTexture, vUV)) if the value is true.
|
|
26
|
+
*/
|
|
27
|
+
Manual = 0,
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* The Smart Filter system will automatically add code to sample the mainInputTexture and return immediately if disabled,
|
|
31
|
+
* and otherwise use the value within the block's shader code. If you need to modify UVs before sampling the default input texture,
|
|
32
|
+
* you'll need to use the Manual strategy instead.
|
|
33
|
+
*/
|
|
34
|
+
AutoSample = 1,
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A ShaderBlock that can be disabled. The optimizer can optionally remove disabled blocks from the graph,
|
|
39
|
+
* or they can be controlled by the disabled connection point at runtime. If disabled, they pass the
|
|
40
|
+
* mainInputTexture through to the output connection point.
|
|
41
|
+
*/
|
|
42
|
+
export abstract class DisableableShaderBlock extends ShaderBlock implements IDisableableBlock {
|
|
43
|
+
/**
|
|
44
|
+
* The disabled connection point of the block.
|
|
45
|
+
*/
|
|
46
|
+
public readonly disabled = this._registerOptionalInput("disabled", ConnectionPointType.Boolean, CreateStrongRef(false));
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The strategy to use for making this block disableable.
|
|
50
|
+
*/
|
|
51
|
+
public readonly blockDisableStrategy: BlockDisableStrategy;
|
|
52
|
+
|
|
53
|
+
// The shader code is a static per block type. When an instance of a block is created, we may need to alter
|
|
54
|
+
// that code based on the block's disable strategy. We only want to do this once per block type, or we could
|
|
55
|
+
// incorrectly modify the shader code multiple times (once per block instance). Here we use a static boolean
|
|
56
|
+
// which will be per block type to track if we've already modified the shader code for this block type.
|
|
57
|
+
// This is more memory efficient than the alternative of making a copy of the shader code for each block instance
|
|
58
|
+
// and modifying each copy.
|
|
59
|
+
private static _HasModifiedShaderCode = false;
|
|
60
|
+
private get _hasModifiedShaderCode() {
|
|
61
|
+
return (this.constructor as typeof DisableableShaderBlock)._HasModifiedShaderCode;
|
|
62
|
+
}
|
|
63
|
+
private set _hasModifiedShaderCode(value: boolean) {
|
|
64
|
+
(this.constructor as typeof DisableableShaderBlock)._HasModifiedShaderCode = value;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Instantiates a new block.
|
|
69
|
+
* @param smartFilter - Defines the smart filter the block belongs to
|
|
70
|
+
* @param name - Defines the name of the block
|
|
71
|
+
* @param disableOptimization - Defines if the block should not be optimized (default: false)
|
|
72
|
+
* @param disableStrategy - Defines the strategy to use for making this block disableable (default: BlockDisableStrategy.AutoSample)
|
|
73
|
+
*/
|
|
74
|
+
constructor(smartFilter: SmartFilter, name: string, disableOptimization = false, disableStrategy = BlockDisableStrategy.AutoSample) {
|
|
75
|
+
super(smartFilter, name, disableOptimization);
|
|
76
|
+
this.blockDisableStrategy = disableStrategy;
|
|
77
|
+
|
|
78
|
+
// If we haven't already modified the shader code for this block type, do so now
|
|
79
|
+
if (!this._hasModifiedShaderCode) {
|
|
80
|
+
this._hasModifiedShaderCode = true;
|
|
81
|
+
|
|
82
|
+
// Apply the disable strategy
|
|
83
|
+
const shaderProgram = this.getShaderProgram();
|
|
84
|
+
switch (this.blockDisableStrategy) {
|
|
85
|
+
case BlockDisableStrategy.AutoSample:
|
|
86
|
+
InjectAutoSampleDisableCode(shaderProgram);
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { BaseBlock } from "./baseBlock.js";
|
|
2
|
-
export { InputBlock, type InputBlockEditorData } from "./inputBlock.js";
|
|
3
|
-
export { type AnyInputBlock } from "./inputBlock.js";
|
|
4
|
-
export { ShaderBlock } from "./shaderBlock.js";
|
|
5
|
-
export { CustomShaderBlock } from "./customShaderBlock.js";
|
|
6
|
-
export { CustomAggregateBlock } from "./customAggregateBlock.js";
|
|
7
|
-
export { DisableableShaderBlock, BlockDisableStrategy } from "./disableableShaderBlock.js";
|
|
8
|
-
export { AggregateBlock } from "./aggregateBlock.js";
|
|
9
|
-
export { type IDisableableBlock } from "./disableableShaderBlock.js";
|
|
1
|
+
export { BaseBlock } from "./baseBlock.js";
|
|
2
|
+
export { InputBlock, type InputBlockEditorData } from "./inputBlock.js";
|
|
3
|
+
export { type AnyInputBlock } from "./inputBlock.js";
|
|
4
|
+
export { ShaderBlock } from "./shaderBlock.js";
|
|
5
|
+
export { CustomShaderBlock } from "./customShaderBlock.js";
|
|
6
|
+
export { CustomAggregateBlock } from "./customAggregateBlock.js";
|
|
7
|
+
export { DisableableShaderBlock, BlockDisableStrategy } from "./disableableShaderBlock.js";
|
|
8
|
+
export { AggregateBlock } from "./aggregateBlock.js";
|
|
9
|
+
export { type IDisableableBlock } from "./disableableShaderBlock.js";
|
|
@@ -1,97 +1,72 @@
|
|
|
1
|
-
import { InputBlock } from "./inputBlock.js";
|
|
2
|
-
import type { SerializedInputBlockData } from "./inputBlock.serialization.types.js";
|
|
3
|
-
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
4
|
-
import type { SmartFilter } from "../smartFilter.js";
|
|
5
|
-
import type { ISerializedBlockV1 } from "../serialization/v1/smartFilterSerialization.types.js";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* V1 Input Block Deserializer
|
|
9
|
-
* @param smartFilter - The SmartFilter to deserialize the block into
|
|
10
|
-
* @param serializedBlock - The serialized block data
|
|
11
|
-
* @returns A deserialized InputBlock
|
|
12
|
-
*/
|
|
13
|
-
export function
|
|
14
|
-
const blockData = serializedBlock.data as SerializedInputBlockData;
|
|
15
|
-
let inputBlock;
|
|
16
|
-
|
|
17
|
-
switch (blockData.inputType) {
|
|
18
|
-
case ConnectionPointType.Boolean:
|
|
19
|
-
{
|
|
20
|
-
inputBlock = new InputBlock(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
break;
|
|
59
|
-
case ConnectionPointType.
|
|
60
|
-
{
|
|
61
|
-
inputBlock = new InputBlock(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
serializedBlock.name,
|
|
74
|
-
ConnectionPointType.Color4,
|
|
75
|
-
blockData.value
|
|
76
|
-
);
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
case ConnectionPointType.Vector2:
|
|
80
|
-
{
|
|
81
|
-
inputBlock = new InputBlock(
|
|
82
|
-
smartFilter,
|
|
83
|
-
serializedBlock.name,
|
|
84
|
-
ConnectionPointType.Vector2,
|
|
85
|
-
blockData.value
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (inputBlock) {
|
|
91
|
-
inputBlock.appMetadata = blockData.appMetadata;
|
|
92
|
-
|
|
93
|
-
return inputBlock;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
throw new Error("Could not deserialize input block, unknown input type");
|
|
97
|
-
}
|
|
1
|
+
import { InputBlock } from "./inputBlock.js";
|
|
2
|
+
import type { SerializedInputBlockData } from "./inputBlock.serialization.types.js";
|
|
3
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
4
|
+
import type { SmartFilter } from "../smartFilter.js";
|
|
5
|
+
import type { ISerializedBlockV1 } from "../serialization/v1/smartFilterSerialization.types.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* V1 Input Block Deserializer
|
|
9
|
+
* @param smartFilter - The SmartFilter to deserialize the block into
|
|
10
|
+
* @param serializedBlock - The serialized block data
|
|
11
|
+
* @returns A deserialized InputBlock
|
|
12
|
+
*/
|
|
13
|
+
export function InputBlockDeserializer(smartFilter: SmartFilter, serializedBlock: ISerializedBlockV1) {
|
|
14
|
+
const blockData = serializedBlock.data as SerializedInputBlockData;
|
|
15
|
+
let inputBlock;
|
|
16
|
+
|
|
17
|
+
switch (blockData.inputType) {
|
|
18
|
+
case ConnectionPointType.Boolean:
|
|
19
|
+
{
|
|
20
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Boolean, blockData.value);
|
|
21
|
+
}
|
|
22
|
+
break;
|
|
23
|
+
case ConnectionPointType.Float:
|
|
24
|
+
{
|
|
25
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Float, blockData.value);
|
|
26
|
+
inputBlock.editorData = {
|
|
27
|
+
animationType: blockData.animationType,
|
|
28
|
+
valueDeltaPerMs: blockData.valueDeltaPerMs,
|
|
29
|
+
min: blockData.min,
|
|
30
|
+
max: blockData.max,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
break;
|
|
34
|
+
case ConnectionPointType.Texture:
|
|
35
|
+
{
|
|
36
|
+
// Create the input block
|
|
37
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Texture, null);
|
|
38
|
+
|
|
39
|
+
// If editor data was serialized, set it on the deserialized block
|
|
40
|
+
inputBlock.editorData = {
|
|
41
|
+
url: blockData.url,
|
|
42
|
+
urlTypeHint: blockData.urlTypeHint,
|
|
43
|
+
anisotropicFilteringLevel: blockData.anisotropicFilteringLevel,
|
|
44
|
+
flipY: blockData.flipY,
|
|
45
|
+
forcedExtension: blockData.forcedExtension,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
break;
|
|
49
|
+
case ConnectionPointType.Color3:
|
|
50
|
+
{
|
|
51
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Color3, blockData.value);
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case ConnectionPointType.Color4:
|
|
55
|
+
{
|
|
56
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Color4, blockData.value);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case ConnectionPointType.Vector2:
|
|
60
|
+
{
|
|
61
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Vector2, blockData.value);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
if (inputBlock) {
|
|
66
|
+
inputBlock.appMetadata = blockData.appMetadata;
|
|
67
|
+
|
|
68
|
+
return inputBlock;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
throw new Error("Could not deserialize input block, unknown input type");
|
|
72
|
+
}
|
|
@@ -1,132 +1,126 @@
|
|
|
1
|
-
import type { Nullable } from "
|
|
2
|
-
import type { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
3
|
-
import type { IColor3Like, IColor4Like, IVector2Like } from "
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Data that all serialized InputBlocks share
|
|
7
|
-
*/
|
|
8
|
-
export type CommonInputBlockData = {
|
|
9
|
-
/**
|
|
10
|
-
* Metadata the hosting app wants to track for this input. For example, a hint for what data to
|
|
11
|
-
* assign to this input, or hints about how to draw dynamic UI to allow users to control this value.
|
|
12
|
-
*/
|
|
13
|
-
appMetadata: unknown;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The data for an InputBlock for ConnectionPointType.Texture inputs
|
|
18
|
-
*/
|
|
19
|
-
export type TextureInputBlockData = CommonInputBlockData & {
|
|
20
|
-
/** The type of the input block */
|
|
21
|
-
inputType: ConnectionPointType.Texture;
|
|
22
|
-
|
|
23
|
-
/** The URL, if available, of the texture */
|
|
24
|
-
url: Nullable<string>;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* If supplied, gives a hint as to which type of texture the URL points to.
|
|
28
|
-
* Default is assumed to be "image"
|
|
29
|
-
*/
|
|
30
|
-
urlTypeHint: Nullable<"image" | "video">;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Defines the anisotropic level to use, or default if null
|
|
34
|
-
*/
|
|
35
|
-
anisotropicFilteringLevel: Nullable<number>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Indicates if the Y axis should be flipped, or default if null
|
|
39
|
-
*/
|
|
40
|
-
flipY: Nullable<boolean>;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The file extension to use, or default if null.
|
|
44
|
-
*/
|
|
45
|
-
forcedExtension: Nullable<string>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* The data for an InputBlock for ConnectionPointType.Boolean inputs
|
|
50
|
-
*/
|
|
51
|
-
export type BooleanInputBlockData = CommonInputBlockData & {
|
|
52
|
-
/** The type of the input block */
|
|
53
|
-
inputType: ConnectionPointType.Boolean;
|
|
54
|
-
|
|
55
|
-
/** The value of the input block */
|
|
56
|
-
value: boolean;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* The data for an InputBlock for ConnectionPointType.Float inputs
|
|
61
|
-
*/
|
|
62
|
-
export type FloatInputBlockData = CommonInputBlockData & {
|
|
63
|
-
/** The type of the input block */
|
|
64
|
-
inputType: ConnectionPointType.Float;
|
|
65
|
-
|
|
66
|
-
/** The value of the input block */
|
|
67
|
-
value: number;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* If supplied, how this should be animated by the editor. Will not affect runtime behavior.
|
|
71
|
-
*/
|
|
72
|
-
animationType: Nullable<"time">;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* If supplied, the amount to change the value per millisecond when animating.
|
|
76
|
-
*/
|
|
77
|
-
valueDeltaPerMs: Nullable<number>;
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* The minimum value of the float, used for slider control.
|
|
81
|
-
*/
|
|
82
|
-
min: Nullable<number>;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* The maximum value of the float, used for slider control.
|
|
86
|
-
*/
|
|
87
|
-
max: Nullable<number>;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* The data for an InputBlock for ConnectionPointType.Color3 inputs
|
|
92
|
-
*/
|
|
93
|
-
export type Color3InputBlockData = CommonInputBlockData & {
|
|
94
|
-
/** The type of the input block */
|
|
95
|
-
inputType: ConnectionPointType.Color3;
|
|
96
|
-
|
|
97
|
-
/** The value of the input block */
|
|
98
|
-
value: IColor3Like;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* The data for an InputBlock for ConnectionPointType.Color4 inputs
|
|
103
|
-
*/
|
|
104
|
-
export type Color4InputBlockData = CommonInputBlockData & {
|
|
105
|
-
/** The type of the input block */
|
|
106
|
-
inputType: ConnectionPointType.Color4;
|
|
107
|
-
|
|
108
|
-
/** The value of the input block */
|
|
109
|
-
value: IColor4Like;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* The data for an InputBlock for ConnectionPointType.Vector2 inputs
|
|
114
|
-
*/
|
|
115
|
-
export type Vector2InputBlockData = CommonInputBlockData & {
|
|
116
|
-
/** The type of the input block */
|
|
117
|
-
inputType: ConnectionPointType.Vector2;
|
|
118
|
-
|
|
119
|
-
/** The value of the input block */
|
|
120
|
-
value: IVector2Like;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Type union of all possible InputBlock data types
|
|
125
|
-
*/
|
|
126
|
-
export type SerializedInputBlockData =
|
|
127
|
-
| TextureInputBlockData
|
|
128
|
-
| BooleanInputBlockData
|
|
129
|
-
| FloatInputBlockData
|
|
130
|
-
| Color3InputBlockData
|
|
131
|
-
| Color4InputBlockData
|
|
132
|
-
| Vector2InputBlockData;
|
|
1
|
+
import type { Nullable } from "core/types.js";
|
|
2
|
+
import type { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
3
|
+
import type { IColor3Like, IColor4Like, IVector2Like } from "core/Maths/math.like.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Data that all serialized InputBlocks share
|
|
7
|
+
*/
|
|
8
|
+
export type CommonInputBlockData = {
|
|
9
|
+
/**
|
|
10
|
+
* Metadata the hosting app wants to track for this input. For example, a hint for what data to
|
|
11
|
+
* assign to this input, or hints about how to draw dynamic UI to allow users to control this value.
|
|
12
|
+
*/
|
|
13
|
+
appMetadata: unknown;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The data for an InputBlock for ConnectionPointType.Texture inputs
|
|
18
|
+
*/
|
|
19
|
+
export type TextureInputBlockData = CommonInputBlockData & {
|
|
20
|
+
/** The type of the input block */
|
|
21
|
+
inputType: ConnectionPointType.Texture;
|
|
22
|
+
|
|
23
|
+
/** The URL, if available, of the texture */
|
|
24
|
+
url: Nullable<string>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* If supplied, gives a hint as to which type of texture the URL points to.
|
|
28
|
+
* Default is assumed to be "image"
|
|
29
|
+
*/
|
|
30
|
+
urlTypeHint: Nullable<"image" | "video">;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Defines the anisotropic level to use, or default if null
|
|
34
|
+
*/
|
|
35
|
+
anisotropicFilteringLevel: Nullable<number>;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Indicates if the Y axis should be flipped, or default if null
|
|
39
|
+
*/
|
|
40
|
+
flipY: Nullable<boolean>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The file extension to use, or default if null.
|
|
44
|
+
*/
|
|
45
|
+
forcedExtension: Nullable<string>;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The data for an InputBlock for ConnectionPointType.Boolean inputs
|
|
50
|
+
*/
|
|
51
|
+
export type BooleanInputBlockData = CommonInputBlockData & {
|
|
52
|
+
/** The type of the input block */
|
|
53
|
+
inputType: ConnectionPointType.Boolean;
|
|
54
|
+
|
|
55
|
+
/** The value of the input block */
|
|
56
|
+
value: boolean;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The data for an InputBlock for ConnectionPointType.Float inputs
|
|
61
|
+
*/
|
|
62
|
+
export type FloatInputBlockData = CommonInputBlockData & {
|
|
63
|
+
/** The type of the input block */
|
|
64
|
+
inputType: ConnectionPointType.Float;
|
|
65
|
+
|
|
66
|
+
/** The value of the input block */
|
|
67
|
+
value: number;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* If supplied, how this should be animated by the editor. Will not affect runtime behavior.
|
|
71
|
+
*/
|
|
72
|
+
animationType: Nullable<"time">;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* If supplied, the amount to change the value per millisecond when animating.
|
|
76
|
+
*/
|
|
77
|
+
valueDeltaPerMs: Nullable<number>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The minimum value of the float, used for slider control.
|
|
81
|
+
*/
|
|
82
|
+
min: Nullable<number>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The maximum value of the float, used for slider control.
|
|
86
|
+
*/
|
|
87
|
+
max: Nullable<number>;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The data for an InputBlock for ConnectionPointType.Color3 inputs
|
|
92
|
+
*/
|
|
93
|
+
export type Color3InputBlockData = CommonInputBlockData & {
|
|
94
|
+
/** The type of the input block */
|
|
95
|
+
inputType: ConnectionPointType.Color3;
|
|
96
|
+
|
|
97
|
+
/** The value of the input block */
|
|
98
|
+
value: IColor3Like;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* The data for an InputBlock for ConnectionPointType.Color4 inputs
|
|
103
|
+
*/
|
|
104
|
+
export type Color4InputBlockData = CommonInputBlockData & {
|
|
105
|
+
/** The type of the input block */
|
|
106
|
+
inputType: ConnectionPointType.Color4;
|
|
107
|
+
|
|
108
|
+
/** The value of the input block */
|
|
109
|
+
value: IColor4Like;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* The data for an InputBlock for ConnectionPointType.Vector2 inputs
|
|
114
|
+
*/
|
|
115
|
+
export type Vector2InputBlockData = CommonInputBlockData & {
|
|
116
|
+
/** The type of the input block */
|
|
117
|
+
inputType: ConnectionPointType.Vector2;
|
|
118
|
+
|
|
119
|
+
/** The value of the input block */
|
|
120
|
+
value: IVector2Like;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Type union of all possible InputBlock data types
|
|
125
|
+
*/
|
|
126
|
+
export type SerializedInputBlockData = TextureInputBlockData | BooleanInputBlockData | FloatInputBlockData | Color3InputBlockData | Color4InputBlockData | Vector2InputBlockData;
|