@onerjs/smart-filters 8.25.2 → 8.25.4
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/IDisposable.d.ts +10 -0
- package/dist/IDisposable.d.ts.map +1 -0
- package/dist/IDisposable.js +2 -0
- package/dist/IDisposable.js.map +1 -0
- package/dist/blockFoundation/aggregateBlock.d.ts +56 -0
- package/dist/blockFoundation/aggregateBlock.d.ts.map +1 -0
- package/dist/blockFoundation/aggregateBlock.js +130 -0
- package/dist/blockFoundation/aggregateBlock.js.map +1 -0
- package/dist/blockFoundation/baseBlock.d.ts +176 -0
- package/dist/blockFoundation/baseBlock.d.ts.map +1 -0
- package/dist/blockFoundation/baseBlock.js +276 -0
- package/dist/blockFoundation/baseBlock.js.map +1 -0
- package/dist/blockFoundation/customAggregateBlock.d.ts +38 -0
- package/dist/blockFoundation/customAggregateBlock.d.ts.map +1 -0
- package/dist/blockFoundation/customAggregateBlock.js +63 -0
- package/dist/blockFoundation/customAggregateBlock.js.map +1 -0
- package/dist/blockFoundation/customShaderBlock.d.ts +73 -0
- package/dist/blockFoundation/customShaderBlock.d.ts.map +1 -0
- package/dist/blockFoundation/customShaderBlock.js +232 -0
- package/dist/blockFoundation/customShaderBlock.js.map +1 -0
- package/dist/blockFoundation/disableableShaderBlock.d.ts +56 -0
- package/dist/blockFoundation/disableableShaderBlock.d.ts.map +1 -0
- package/dist/blockFoundation/disableableShaderBlock.js +68 -0
- package/dist/blockFoundation/disableableShaderBlock.js.map +1 -0
- package/dist/blockFoundation/index.d.ts +10 -0
- package/dist/blockFoundation/index.d.ts.map +1 -0
- package/dist/blockFoundation/index.js +8 -0
- package/dist/blockFoundation/index.js.map +1 -0
- package/dist/blockFoundation/inputBlock.d.ts +127 -0
- package/dist/blockFoundation/inputBlock.d.ts.map +1 -0
- package/dist/blockFoundation/inputBlock.deserializer.d.ts +12 -0
- package/dist/blockFoundation/inputBlock.deserializer.d.ts.map +1 -0
- package/dist/blockFoundation/inputBlock.deserializer.js +65 -0
- package/dist/blockFoundation/inputBlock.deserializer.js.map +1 -0
- package/dist/blockFoundation/inputBlock.js +89 -0
- package/dist/blockFoundation/inputBlock.js.map +1 -0
- package/dist/blockFoundation/inputBlock.serialization.types.d.ts +105 -0
- package/dist/blockFoundation/inputBlock.serialization.types.d.ts.map +1 -0
- package/dist/blockFoundation/inputBlock.serialization.types.js +2 -0
- package/dist/blockFoundation/inputBlock.serialization.types.js.map +1 -0
- package/dist/blockFoundation/inputBlock.serializer.d.ts +6 -0
- package/dist/blockFoundation/inputBlock.serializer.d.ts.map +1 -0
- package/dist/blockFoundation/inputBlock.serializer.js +130 -0
- package/dist/blockFoundation/inputBlock.serializer.js.map +1 -0
- package/dist/blockFoundation/outputBlock.d.ts +47 -0
- package/dist/blockFoundation/outputBlock.d.ts.map +1 -0
- package/dist/blockFoundation/outputBlock.js +123 -0
- package/dist/blockFoundation/outputBlock.js.map +1 -0
- package/dist/blockFoundation/shaderBlock.d.ts +64 -0
- package/dist/blockFoundation/shaderBlock.d.ts.map +1 -0
- package/dist/blockFoundation/shaderBlock.js +125 -0
- package/dist/blockFoundation/shaderBlock.js.map +1 -0
- package/dist/blockFoundation/textureOptions.d.ts +47 -0
- package/dist/blockFoundation/textureOptions.d.ts.map +1 -0
- package/dist/blockFoundation/textureOptions.js +37 -0
- package/dist/blockFoundation/textureOptions.js.map +1 -0
- package/dist/command/command.d.ts +48 -0
- package/dist/command/command.d.ts.map +1 -0
- package/dist/command/command.js +15 -0
- package/dist/command/command.js.map +1 -0
- package/dist/command/commandBuffer.d.ts +40 -0
- package/dist/command/commandBuffer.d.ts.map +1 -0
- package/dist/command/commandBuffer.js +58 -0
- package/dist/command/commandBuffer.js.map +1 -0
- package/dist/command/commandBufferDebugger.d.ts +7 -0
- package/dist/command/commandBufferDebugger.d.ts.map +1 -0
- package/dist/command/commandBufferDebugger.js +13 -0
- package/dist/command/commandBufferDebugger.js.map +1 -0
- package/dist/command/index.d.ts +6 -0
- package/dist/command/index.d.ts.map +1 -0
- package/dist/command/index.js +8 -0
- package/dist/command/index.js.map +1 -0
- package/dist/connection/connectionPoint.d.ts +110 -0
- package/dist/connection/connectionPoint.d.ts.map +1 -0
- package/dist/connection/connectionPoint.js +154 -0
- package/dist/connection/connectionPoint.js.map +1 -0
- package/dist/connection/connectionPointCompatibilityState.d.ts +20 -0
- package/dist/connection/connectionPointCompatibilityState.d.ts.map +1 -0
- package/dist/connection/connectionPointCompatibilityState.js +32 -0
- package/dist/connection/connectionPointCompatibilityState.js.map +1 -0
- package/dist/connection/connectionPointDirection.d.ts +10 -0
- package/dist/connection/connectionPointDirection.d.ts.map +1 -0
- package/dist/connection/connectionPointDirection.js +11 -0
- package/dist/connection/connectionPointDirection.js.map +1 -0
- package/dist/connection/connectionPointType.d.ts +29 -0
- package/dist/connection/connectionPointType.d.ts.map +1 -0
- package/dist/connection/connectionPointType.js +19 -0
- package/dist/connection/connectionPointType.js.map +1 -0
- package/dist/connection/connectionPointWithDefault.d.ts +23 -0
- package/dist/connection/connectionPointWithDefault.d.ts.map +1 -0
- package/dist/connection/connectionPointWithDefault.js +19 -0
- package/dist/connection/connectionPointWithDefault.js.map +1 -0
- package/dist/connection/index.d.ts +8 -0
- package/dist/connection/index.d.ts.map +1 -0
- package/dist/connection/index.js +7 -0
- package/dist/connection/index.js.map +1 -0
- package/dist/editorUtils/editableInPropertyPage.d.ts +80 -0
- package/dist/editorUtils/editableInPropertyPage.d.ts.map +1 -0
- package/dist/editorUtils/editableInPropertyPage.js +42 -0
- package/dist/editorUtils/editableInPropertyPage.js.map +1 -0
- package/dist/editorUtils/index.d.ts +3 -0
- package/dist/editorUtils/index.d.ts.map +1 -0
- package/dist/editorUtils/index.js +4 -0
- package/dist/editorUtils/index.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/optimization/dependencyGraph.d.ts +31 -0
- package/dist/optimization/dependencyGraph.d.ts.map +1 -0
- package/dist/optimization/dependencyGraph.js +78 -0
- package/dist/optimization/dependencyGraph.js.map +1 -0
- package/dist/optimization/index.d.ts +2 -0
- package/dist/optimization/index.d.ts.map +1 -0
- package/dist/optimization/index.js +2 -0
- package/dist/optimization/index.js.map +1 -0
- package/dist/optimization/optimizedShaderBlock.d.ts +75 -0
- package/dist/optimization/optimizedShaderBlock.d.ts.map +1 -0
- package/dist/optimization/optimizedShaderBlock.js +105 -0
- package/dist/optimization/optimizedShaderBlock.js.map +1 -0
- package/dist/optimization/smartFilterOptimizer.d.ts +126 -0
- package/dist/optimization/smartFilterOptimizer.d.ts.map +1 -0
- package/dist/optimization/smartFilterOptimizer.js +666 -0
- package/dist/optimization/smartFilterOptimizer.js.map +1 -0
- package/dist/runtime/index.d.ts +8 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +7 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/renderTargetGenerator.d.ts +43 -0
- package/dist/runtime/renderTargetGenerator.d.ts.map +1 -0
- package/dist/runtime/renderTargetGenerator.js +169 -0
- package/dist/runtime/renderTargetGenerator.js.map +1 -0
- package/dist/runtime/shaderRuntime.d.ts +103 -0
- package/dist/runtime/shaderRuntime.d.ts.map +1 -0
- package/dist/runtime/shaderRuntime.js +132 -0
- package/dist/runtime/shaderRuntime.js.map +1 -0
- package/dist/runtime/smartFilterRuntime.d.ts +69 -0
- package/dist/runtime/smartFilterRuntime.d.ts.map +1 -0
- package/dist/runtime/smartFilterRuntime.js +63 -0
- package/dist/runtime/smartFilterRuntime.js.map +1 -0
- package/dist/runtime/strongRef.d.ts +16 -0
- package/dist/runtime/strongRef.d.ts.map +1 -0
- package/dist/runtime/strongRef.js +9 -0
- package/dist/runtime/strongRef.js.map +1 -0
- package/dist/serialization/importCustomBlockDefinition.d.ts +15 -0
- package/dist/serialization/importCustomBlockDefinition.d.ts.map +1 -0
- package/dist/serialization/importCustomBlockDefinition.js +76 -0
- package/dist/serialization/importCustomBlockDefinition.js.map +1 -0
- package/dist/serialization/index.d.ts +9 -0
- package/dist/serialization/index.d.ts.map +1 -0
- package/dist/serialization/index.js +11 -0
- package/dist/serialization/index.js.map +1 -0
- package/dist/serialization/serializedBlockDefinition.d.ts +12 -0
- package/dist/serialization/serializedBlockDefinition.d.ts.map +1 -0
- package/dist/serialization/serializedBlockDefinition.js +2 -0
- package/dist/serialization/serializedBlockDefinition.js.map +1 -0
- package/dist/serialization/serializedShaderBlockDefinition.d.ts +7 -0
- package/dist/serialization/serializedShaderBlockDefinition.d.ts.map +1 -0
- package/dist/serialization/serializedShaderBlockDefinition.js +2 -0
- package/dist/serialization/serializedShaderBlockDefinition.js.map +1 -0
- package/dist/serialization/serializedSmartFilter.d.ts +6 -0
- package/dist/serialization/serializedSmartFilter.d.ts.map +1 -0
- package/dist/serialization/serializedSmartFilter.js +2 -0
- package/dist/serialization/serializedSmartFilter.js.map +1 -0
- package/dist/serialization/smartFilterDeserializer.d.ts +34 -0
- package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -0
- package/dist/serialization/smartFilterDeserializer.js +141 -0
- package/dist/serialization/smartFilterDeserializer.js.map +1 -0
- package/dist/serialization/smartFilterSerializer.d.ts +23 -0
- package/dist/serialization/smartFilterSerializer.d.ts.map +1 -0
- package/dist/serialization/smartFilterSerializer.js +95 -0
- package/dist/serialization/smartFilterSerializer.js.map +1 -0
- package/dist/serialization/v1/defaultBlockSerializer.d.ts +9 -0
- package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -0
- package/dist/serialization/v1/defaultBlockSerializer.js +19 -0
- package/dist/serialization/v1/defaultBlockSerializer.js.map +1 -0
- package/dist/serialization/v1/index.d.ts +4 -0
- package/dist/serialization/v1/index.d.ts.map +1 -0
- package/dist/serialization/v1/index.js +5 -0
- package/dist/serialization/v1/index.js.map +1 -0
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts +73 -0
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts.map +1 -0
- package/dist/serialization/v1/shaderBlockSerialization.types.js +7 -0
- package/dist/serialization/v1/shaderBlockSerialization.types.js.map +1 -0
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts +98 -0
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -0
- package/dist/serialization/v1/smartFilterSerialization.types.js +2 -0
- package/dist/serialization/v1/smartFilterSerialization.types.js.map +1 -0
- package/dist/smartFilter.d.ts +118 -0
- package/dist/smartFilter.d.ts.map +1 -0
- package/dist/smartFilter.js +169 -0
- package/dist/smartFilter.js.map +1 -0
- package/dist/utils/buildTools/buildShaders.d.ts +9 -0
- package/dist/utils/buildTools/buildShaders.d.ts.map +1 -0
- package/dist/utils/buildTools/buildShaders.js +13 -0
- package/dist/utils/buildTools/buildShaders.js.map +1 -0
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts +9 -0
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts.map +1 -0
- package/dist/utils/buildTools/convertGlslIntoBlock.js +346 -0
- package/dist/utils/buildTools/convertGlslIntoBlock.js.map +1 -0
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts +26 -0
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts.map +1 -0
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js +141 -0
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js.map +1 -0
- package/dist/utils/buildTools/convertShaders.d.ts +16 -0
- package/dist/utils/buildTools/convertShaders.d.ts.map +1 -0
- package/dist/utils/buildTools/convertShaders.js +62 -0
- package/dist/utils/buildTools/convertShaders.js.map +1 -0
- package/dist/utils/buildTools/shaderCode.types.d.ts +51 -0
- package/dist/utils/buildTools/shaderCode.types.d.ts.map +1 -0
- package/dist/utils/buildTools/shaderCode.types.js +2 -0
- package/dist/utils/buildTools/shaderCode.types.js.map +1 -0
- package/dist/utils/buildTools/shaderConverter.d.ts +77 -0
- package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -0
- package/dist/utils/buildTools/shaderConverter.js +297 -0
- package/dist/utils/buildTools/shaderConverter.js.map +1 -0
- package/dist/utils/buildTools/watchShaders.d.ts +9 -0
- package/dist/utils/buildTools/watchShaders.d.ts.map +1 -0
- package/dist/utils/buildTools/watchShaders.js +39 -0
- package/dist/utils/buildTools/watchShaders.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/renderTargetUtils.d.ts +14 -0
- package/dist/utils/renderTargetUtils.d.ts.map +1 -0
- package/dist/utils/renderTargetUtils.js +23 -0
- package/dist/utils/renderTargetUtils.js.map +1 -0
- package/dist/utils/shaderCodeUtils.d.ts +91 -0
- package/dist/utils/shaderCodeUtils.d.ts.map +1 -0
- package/dist/utils/shaderCodeUtils.js +111 -0
- package/dist/utils/shaderCodeUtils.js.map +1 -0
- package/dist/utils/textureLoaders.d.ts +16 -0
- package/dist/utils/textureLoaders.d.ts.map +1 -0
- package/dist/utils/textureLoaders.js +22 -0
- package/dist/utils/textureLoaders.js.map +1 -0
- package/dist/utils/textureUtils.d.ts +13 -0
- package/dist/utils/textureUtils.d.ts.map +1 -0
- package/dist/utils/textureUtils.js +25 -0
- package/dist/utils/textureUtils.js.map +1 -0
- package/dist/utils/uniqueIdGenerator.d.ts +19 -0
- package/dist/utils/uniqueIdGenerator.d.ts.map +1 -0
- package/dist/utils/uniqueIdGenerator.js +27 -0
- package/dist/utils/uniqueIdGenerator.js.map +1 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +1 -1
- package/src/optimization/smartFilterOptimizer.ts +305 -158
- package/src/version.ts +1 -1
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Logger } from "@onerjs/core/Misc/logger.js";
|
|
2
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
3
|
+
import { ShaderBinding } from "../runtime/shaderRuntime.js";
|
|
4
|
+
import { CreateStrongRef } from "../runtime/strongRef.js";
|
|
5
|
+
import { ShaderBlock } from "./shaderBlock.js";
|
|
6
|
+
/**
|
|
7
|
+
* The binding for a CustomShaderBlock
|
|
8
|
+
*/
|
|
9
|
+
class CustomShaderBlockBinding extends ShaderBinding {
|
|
10
|
+
/**
|
|
11
|
+
* Creates a new shader binding instance for the CustomShaderBlock block.
|
|
12
|
+
* @param inputsWithRuntimeData - The input connection points of the block
|
|
13
|
+
*/
|
|
14
|
+
constructor(inputsWithRuntimeData) {
|
|
15
|
+
super();
|
|
16
|
+
this._bindSteps = [];
|
|
17
|
+
for (const input of inputsWithRuntimeData) {
|
|
18
|
+
switch (input.type) {
|
|
19
|
+
case ConnectionPointType.Float:
|
|
20
|
+
this._bindSteps.push((effect) => {
|
|
21
|
+
effect.setFloat(this.getRemappedName(input.name), input.runtimeData.value);
|
|
22
|
+
});
|
|
23
|
+
break;
|
|
24
|
+
case ConnectionPointType.Texture:
|
|
25
|
+
this._bindSteps.push((effect) => {
|
|
26
|
+
effect.setTexture(this.getRemappedName(input.name), input.runtimeData.value);
|
|
27
|
+
});
|
|
28
|
+
break;
|
|
29
|
+
case ConnectionPointType.Color3:
|
|
30
|
+
this._bindSteps.push((effect) => {
|
|
31
|
+
effect.setColor3(this.getRemappedName(input.name), input.runtimeData.value);
|
|
32
|
+
});
|
|
33
|
+
break;
|
|
34
|
+
case ConnectionPointType.Color4:
|
|
35
|
+
this._bindSteps.push((effect) => {
|
|
36
|
+
effect.setDirectColor4(this.getRemappedName(input.name), input.runtimeData.value);
|
|
37
|
+
});
|
|
38
|
+
break;
|
|
39
|
+
case ConnectionPointType.Boolean:
|
|
40
|
+
this._bindSteps.push((effect) => {
|
|
41
|
+
effect.setBool(this.getRemappedName(input.name), input.runtimeData.value);
|
|
42
|
+
});
|
|
43
|
+
break;
|
|
44
|
+
case ConnectionPointType.Vector2:
|
|
45
|
+
switch (input.autoBind) {
|
|
46
|
+
case "outputResolution":
|
|
47
|
+
this._bindSteps.push((effect, width, height) => {
|
|
48
|
+
effect.setFloat2(this.getRemappedName(input.name), width, height);
|
|
49
|
+
});
|
|
50
|
+
break;
|
|
51
|
+
case "outputAspectRatio":
|
|
52
|
+
this._bindSteps.push((effect, width, height) => {
|
|
53
|
+
effect.setFloat2(this.getRemappedName(input.name), width / height, height / width);
|
|
54
|
+
});
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
this._bindSteps.push((effect) => {
|
|
58
|
+
effect.setVector2(this.getRemappedName(input.name), input.runtimeData.value);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Binds all the required data to the shader when rendering.
|
|
67
|
+
* @param effect - The effect to bind the data to
|
|
68
|
+
* @param width - defines the width of the output
|
|
69
|
+
* @param height - defines the height of the output
|
|
70
|
+
*/
|
|
71
|
+
bind(effect, width, height) {
|
|
72
|
+
for (let i = 0; i < this._bindSteps.length; i++) {
|
|
73
|
+
this._bindSteps[i](effect, width, height);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A block which loads a SerializedBlockDefinition for use in a SmartFilter.
|
|
79
|
+
*/
|
|
80
|
+
export class CustomShaderBlock extends ShaderBlock {
|
|
81
|
+
/**
|
|
82
|
+
* Deserializes a CustomShaderBlock from a serialized block definition.
|
|
83
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
84
|
+
* @param name - Defines the name of the block
|
|
85
|
+
* @param blockDefinition - The serialized block definition
|
|
86
|
+
* @returns The deserialized CustomShaderBlock instance
|
|
87
|
+
*/
|
|
88
|
+
static Create(smartFilter, name, blockDefinition) {
|
|
89
|
+
// When a new version of SerializedBlockDefinition is created, this function should be updated to handle the new properties.
|
|
90
|
+
return new CustomShaderBlock(smartFilter, name, blockDefinition.disableOptimization, blockDefinition.blockType, blockDefinition.namespace, blockDefinition.inputConnectionPoints, blockDefinition.shaderProgram);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The type of the block - used when serializing / deserializing the block, and in the editor.
|
|
94
|
+
*/
|
|
95
|
+
get blockType() {
|
|
96
|
+
return this._blockType;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
|
|
100
|
+
* By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
|
|
101
|
+
*/
|
|
102
|
+
get namespace() {
|
|
103
|
+
return this._namespace;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Instantiates a new custom shader block.
|
|
107
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
108
|
+
* @param name - The name of the block
|
|
109
|
+
* @param disableOptimization - If true, this optimizer will not attempt to optimize this block
|
|
110
|
+
* @param blockType - The type of the block
|
|
111
|
+
* @param namespace - The namespace of the block
|
|
112
|
+
* @param inputConnectionPoints - The input connection points of the
|
|
113
|
+
* @param shaderProgram - The shader program for the block
|
|
114
|
+
*/
|
|
115
|
+
constructor(smartFilter, name, disableOptimization, blockType, namespace, inputConnectionPoints, shaderProgram) {
|
|
116
|
+
super(smartFilter, name, disableOptimization);
|
|
117
|
+
this._autoBoundInputs = null;
|
|
118
|
+
this._blockType = blockType;
|
|
119
|
+
this._namespace = namespace;
|
|
120
|
+
for (const input of inputConnectionPoints) {
|
|
121
|
+
this._registerSerializedInputConnectionPointV1(input);
|
|
122
|
+
}
|
|
123
|
+
this._shaderProgram = shaderProgram;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Gets the shader program to use to render the block.
|
|
127
|
+
* @returns The shader program to use to render the block
|
|
128
|
+
*/
|
|
129
|
+
getShaderProgram() {
|
|
130
|
+
return this._shaderProgram;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Checks a specific input connection point type to see if it has a default value, and registers the input
|
|
134
|
+
* connection point accordingly.
|
|
135
|
+
* @param connectionPoint - The input connection point to register
|
|
136
|
+
*/
|
|
137
|
+
_registerSerializedInputConnectionPointV1(connectionPoint) {
|
|
138
|
+
if (connectionPoint.autoBind) {
|
|
139
|
+
// Auto bound inputs are not registered as input connection points
|
|
140
|
+
if (this._autoBoundInputs === null) {
|
|
141
|
+
this._autoBoundInputs = [];
|
|
142
|
+
}
|
|
143
|
+
this._autoBoundInputs.push(connectionPoint);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
// If not auto bound, register as an input connection point
|
|
147
|
+
const defaultValue = this._validateDefaultValue(connectionPoint.type, connectionPoint.name, connectionPoint.defaultValue);
|
|
148
|
+
if (defaultValue != null) {
|
|
149
|
+
this._registerOptionalInput(connectionPoint.name, connectionPoint.type, CreateStrongRef(defaultValue));
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this._registerInput(connectionPoint.name, connectionPoint.type);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Gets the shader binding for the custom shader block.
|
|
158
|
+
* @returns The shader binding for the custom shader block
|
|
159
|
+
*/
|
|
160
|
+
getShaderBinding() {
|
|
161
|
+
const inputs = this.inputs;
|
|
162
|
+
const inputsToBind = inputs.map((input) => {
|
|
163
|
+
return {
|
|
164
|
+
name: input.name,
|
|
165
|
+
type: input.type,
|
|
166
|
+
runtimeData: this._confirmRuntimeDataSupplied(input),
|
|
167
|
+
autoBind: undefined,
|
|
168
|
+
};
|
|
169
|
+
});
|
|
170
|
+
if (this._autoBoundInputs) {
|
|
171
|
+
for (const autoBoundInput of this._autoBoundInputs) {
|
|
172
|
+
if ((autoBoundInput.autoBind === "outputResolution" && autoBoundInput.type == ConnectionPointType.Vector2) ||
|
|
173
|
+
(autoBoundInput.autoBind === "outputAspectRatio" && autoBoundInput.type == ConnectionPointType.Vector2)) {
|
|
174
|
+
inputsToBind.push({
|
|
175
|
+
name: autoBoundInput.name,
|
|
176
|
+
type: autoBoundInput.type,
|
|
177
|
+
autoBind: autoBoundInput.autoBind,
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
throw new Error(`Auto bound input ${autoBoundInput.name} has an unsupported type or auto bind value`);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return new CustomShaderBlockBinding(inputsToBind);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Validates the default value of a connection point and returns it if valid.
|
|
189
|
+
* If the default value is not provided or is invalid, this returns null.
|
|
190
|
+
* @param connectionPointType - The type of the connection point
|
|
191
|
+
* @param connectionPointName - The name of the connection point
|
|
192
|
+
* @param defaultValue - The default value of the connection point
|
|
193
|
+
* @returns The default value, or null if no default value is provided or it was invalid
|
|
194
|
+
*/
|
|
195
|
+
_validateDefaultValue(connectionPointType, connectionPointName, defaultValue) {
|
|
196
|
+
if (defaultValue === undefined || defaultValue === null) {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
// Validate the default value based on the connection point type
|
|
200
|
+
let returnValue = null;
|
|
201
|
+
switch (connectionPointType) {
|
|
202
|
+
case ConnectionPointType.Float:
|
|
203
|
+
returnValue = typeof defaultValue === "number" ? defaultValue : null;
|
|
204
|
+
break;
|
|
205
|
+
case ConnectionPointType.Color3:
|
|
206
|
+
returnValue = typeof defaultValue === "object" && "r" in defaultValue && "g" in defaultValue && "b" in defaultValue ? defaultValue : null;
|
|
207
|
+
break;
|
|
208
|
+
case ConnectionPointType.Color4:
|
|
209
|
+
returnValue = typeof defaultValue === "object" && "r" in defaultValue && "g" in defaultValue && "b" in defaultValue && "a" in defaultValue ? defaultValue : null;
|
|
210
|
+
break;
|
|
211
|
+
case ConnectionPointType.Boolean:
|
|
212
|
+
returnValue = typeof defaultValue === "boolean" ? defaultValue : null;
|
|
213
|
+
break;
|
|
214
|
+
case ConnectionPointType.Vector2:
|
|
215
|
+
returnValue = typeof defaultValue === "object" && "x" in defaultValue && "y" in defaultValue ? defaultValue : null;
|
|
216
|
+
break;
|
|
217
|
+
default: {
|
|
218
|
+
Logger.Warn(`Default value supplied when unsupported. Block Type: "${this.blockType}" Connection Point: "${connectionPointName}"`);
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
if (returnValue === null) {
|
|
223
|
+
Logger.Warn(`Invalid default value. Block Type: "${this.blockType}" Connection Point: "${connectionPointName}"`);
|
|
224
|
+
}
|
|
225
|
+
return returnValue;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* The class name of the block.
|
|
230
|
+
*/
|
|
231
|
+
CustomShaderBlock.ClassName = "CustomShaderBlock";
|
|
232
|
+
//# sourceMappingURL=customShaderBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customShaderBlock.js","sourceRoot":"","sources":["../../src/blockFoundation/customShaderBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,oCAA4B;AAE7C,OAAO,EAAE,mBAAmB,EAA6B,MAAM,sCAAsC,CAAC;AACtG,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAK1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;GAEG;AACH,MAAM,wBAAyB,SAAQ,aAAa;IAGhD;;;OAGG;IACH,YAAmB,qBAAgD;QAC/D,KAAK,EAAE,CAAC;QAPK,eAAU,GAAgE,EAAE,CAAC;QAS1F,KAAK,MAAM,KAAK,IAAI,qBAAqB,EAAE,CAAC;YACxC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;gBACjB,KAAK,mBAAmB,CAAC,KAAK;oBAC1B,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CA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Y,CAAC,CAAC,CAAC,IAAI,CAAC;gBACjK,MAAM;YACV,KAAK,mBAAmB,CAAC,OAAO;gBAC5B,WAAW,GAAG,OAAO,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;gBACtE,MAAM;YACV,KAAK,mBAAmB,CAAC,OAAO;gBAC5B,WAAW,GAAG,OAAO,YAAY,KAAK,QAAQ,IAAI,GAAG,IAAI,YAAY,IAAI,GAAG,IAAI,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;gBACnH,MAAM;YACV,OAAO,CAAC,CAAC,CAAC;gBACN,MAAM,CAAC,IAAI,CAAC,yDAAyD,IAAI,CAAC,SAAS,wBAAwB,mBAAmB,GAAG,CAAC,CAAC;gBACnI,OAAO,IAAI,CAAC;YAChB,CAAC;QACL,CAAC;QAED,IAAI,WAAW,KAAK,IAAI,EAAE,CAAC;YACvB,MAAM,CAAC,IAAI,CAAC,uCAAuC,IAAI,CAAC,SAAS,wBAAwB,mBAAmB,GAAG,CAAC,CAAC;QACrH,CAAC;QAED,OAAO,WAAW,CAAC;IACvB,CAAC;;AAxKD;;GAEG;AACoB,2BAAS,GAAG,mBAAmB,AAAtB,CAAuB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { SmartFilter } from "../smartFilter.js";
|
|
2
|
+
import type { ConnectionPoint } from "../connection/connectionPoint.js";
|
|
3
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
4
|
+
import { ShaderBlock } from "./shaderBlock.js";
|
|
5
|
+
/**
|
|
6
|
+
* The interface that describes the disableable block.
|
|
7
|
+
*/
|
|
8
|
+
export interface IDisableableBlock {
|
|
9
|
+
/**
|
|
10
|
+
* The disabled connection point of the block.
|
|
11
|
+
*/
|
|
12
|
+
disabled: ConnectionPoint<ConnectionPointType.Boolean>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The strategy to use for making a block disableable.
|
|
16
|
+
*/
|
|
17
|
+
export declare enum BlockDisableStrategy {
|
|
18
|
+
/**
|
|
19
|
+
* The shader code is responsible for defining and consulting a uniform named disabled
|
|
20
|
+
* and no-oping (returning texture2D(mainInputTexture, vUV)) if the value is true.
|
|
21
|
+
*/
|
|
22
|
+
Manual = 0,
|
|
23
|
+
/**
|
|
24
|
+
* The Smart Filter system will automatically add code to sample the mainInputTexture and return immediately if disabled,
|
|
25
|
+
* and otherwise use the value within the block's shader code. If you need to modify UVs before sampling the default input texture,
|
|
26
|
+
* you'll need to use the Manual strategy instead.
|
|
27
|
+
*/
|
|
28
|
+
AutoSample = 1
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A ShaderBlock that can be disabled. The optimizer can optionally remove disabled blocks from the graph,
|
|
32
|
+
* or they can be controlled by the disabled connection point at runtime. If disabled, they pass the
|
|
33
|
+
* mainInputTexture through to the output connection point.
|
|
34
|
+
*/
|
|
35
|
+
export declare abstract class DisableableShaderBlock extends ShaderBlock implements IDisableableBlock {
|
|
36
|
+
/**
|
|
37
|
+
* The disabled connection point of the block.
|
|
38
|
+
*/
|
|
39
|
+
readonly disabled: import("../connection/connectionPointWithDefault.js").ConnectionPointWithDefault<ConnectionPointType.Boolean>;
|
|
40
|
+
/**
|
|
41
|
+
* The strategy to use for making this block disableable.
|
|
42
|
+
*/
|
|
43
|
+
readonly blockDisableStrategy: BlockDisableStrategy;
|
|
44
|
+
private static _HasModifiedShaderCode;
|
|
45
|
+
private get _hasModifiedShaderCode();
|
|
46
|
+
private set _hasModifiedShaderCode(value);
|
|
47
|
+
/**
|
|
48
|
+
* Instantiates a new block.
|
|
49
|
+
* @param smartFilter - Defines the smart filter the block belongs to
|
|
50
|
+
* @param name - Defines the name of the block
|
|
51
|
+
* @param disableOptimization - Defines if the block should not be optimized (default: false)
|
|
52
|
+
* @param disableStrategy - Defines the strategy to use for making this block disableable (default: BlockDisableStrategy.AutoSample)
|
|
53
|
+
*/
|
|
54
|
+
constructor(smartFilter: SmartFilter, name: string, disableOptimization?: boolean, disableStrategy?: BlockDisableStrategy);
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=disableableShaderBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disableableShaderBlock.d.ts","sourceRoot":"","sources":["../../src/blockFoundation/disableableShaderBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAExE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,QAAQ,EAAE,eAAe,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;CAC1D;AAED;;GAEG;AACH,oBAAY,oBAAoB;IAC5B;;;OAGG;IACH,MAAM,IAAI;IAEV;;;;OAIG;IACH,UAAU,IAAI;CACjB;AAED;;;;GAIG;AACH,8BAAsB,sBAAuB,SAAQ,WAAY,YAAW,iBAAiB;IACzF;;OAEG;IACH,SAAgB,QAAQ,gHAAgG;IAExH;;OAEG;IACH,SAAgB,oBAAoB,EAAE,oBAAoB,CAAC;IAQ3D,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAS;IAC9C,OAAO,KAAK,sBAAsB,GAEjC;IACD,OAAO,KAAK,sBAAsB,QAEjC;IAED;;;;;;OAMG;gBACS,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,mBAAmB,UAAQ,EAAE,eAAe,uBAAkC;CAiBrI"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
2
|
+
import { CreateStrongRef } from "../runtime/strongRef.js";
|
|
3
|
+
import { ShaderBlock } from "./shaderBlock.js";
|
|
4
|
+
import { InjectAutoSampleDisableCode } from "../utils/shaderCodeUtils.js";
|
|
5
|
+
/**
|
|
6
|
+
* The strategy to use for making a block disableable.
|
|
7
|
+
*/
|
|
8
|
+
export var BlockDisableStrategy;
|
|
9
|
+
(function (BlockDisableStrategy) {
|
|
10
|
+
/**
|
|
11
|
+
* The shader code is responsible for defining and consulting a uniform named disabled
|
|
12
|
+
* and no-oping (returning texture2D(mainInputTexture, vUV)) if the value is true.
|
|
13
|
+
*/
|
|
14
|
+
BlockDisableStrategy[BlockDisableStrategy["Manual"] = 0] = "Manual";
|
|
15
|
+
/**
|
|
16
|
+
* The Smart Filter system will automatically add code to sample the mainInputTexture and return immediately if disabled,
|
|
17
|
+
* and otherwise use the value within the block's shader code. If you need to modify UVs before sampling the default input texture,
|
|
18
|
+
* you'll need to use the Manual strategy instead.
|
|
19
|
+
*/
|
|
20
|
+
BlockDisableStrategy[BlockDisableStrategy["AutoSample"] = 1] = "AutoSample";
|
|
21
|
+
})(BlockDisableStrategy || (BlockDisableStrategy = {}));
|
|
22
|
+
/**
|
|
23
|
+
* A ShaderBlock that can be disabled. The optimizer can optionally remove disabled blocks from the graph,
|
|
24
|
+
* or they can be controlled by the disabled connection point at runtime. If disabled, they pass the
|
|
25
|
+
* mainInputTexture through to the output connection point.
|
|
26
|
+
*/
|
|
27
|
+
export class DisableableShaderBlock extends ShaderBlock {
|
|
28
|
+
get _hasModifiedShaderCode() {
|
|
29
|
+
return this.constructor._HasModifiedShaderCode;
|
|
30
|
+
}
|
|
31
|
+
set _hasModifiedShaderCode(value) {
|
|
32
|
+
this.constructor._HasModifiedShaderCode = value;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Instantiates a new block.
|
|
36
|
+
* @param smartFilter - Defines the smart filter the block belongs to
|
|
37
|
+
* @param name - Defines the name of the block
|
|
38
|
+
* @param disableOptimization - Defines if the block should not be optimized (default: false)
|
|
39
|
+
* @param disableStrategy - Defines the strategy to use for making this block disableable (default: BlockDisableStrategy.AutoSample)
|
|
40
|
+
*/
|
|
41
|
+
constructor(smartFilter, name, disableOptimization = false, disableStrategy = BlockDisableStrategy.AutoSample) {
|
|
42
|
+
super(smartFilter, name, disableOptimization);
|
|
43
|
+
/**
|
|
44
|
+
* The disabled connection point of the block.
|
|
45
|
+
*/
|
|
46
|
+
this.disabled = this._registerOptionalInput("disabled", ConnectionPointType.Boolean, CreateStrongRef(false));
|
|
47
|
+
this.blockDisableStrategy = disableStrategy;
|
|
48
|
+
// If we haven't already modified the shader code for this block type, do so now
|
|
49
|
+
if (!this._hasModifiedShaderCode) {
|
|
50
|
+
this._hasModifiedShaderCode = true;
|
|
51
|
+
// Apply the disable strategy
|
|
52
|
+
const shaderProgram = this.getShaderProgram();
|
|
53
|
+
switch (this.blockDisableStrategy) {
|
|
54
|
+
case BlockDisableStrategy.AutoSample:
|
|
55
|
+
InjectAutoSampleDisableCode(shaderProgram);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
// The shader code is a static per block type. When an instance of a block is created, we may need to alter
|
|
62
|
+
// that code based on the block's disable strategy. We only want to do this once per block type, or we could
|
|
63
|
+
// incorrectly modify the shader code multiple times (once per block instance). Here we use a static boolean
|
|
64
|
+
// which will be per block type to track if we've already modified the shader code for this block type.
|
|
65
|
+
// This is more memory efficient than the alternative of making a copy of the shader code for each block instance
|
|
66
|
+
// and modifying each copy.
|
|
67
|
+
DisableableShaderBlock._HasModifiedShaderCode = false;
|
|
68
|
+
//# sourceMappingURL=disableableShaderBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disableableShaderBlock.js","sourceRoot":"","sources":["../../src/blockFoundation/disableableShaderBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CA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;IACL,CAAC;;AArCD,2GAA2G;AAC3G,4GAA4G;AAC5G,4GAA4G;AAC5G,uGAAuG;AACvG,iHAAiH;AACjH,2BAA2B;AACZ,6CAAsB,GAAG,KAAK,AAAR,CAAS"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/blockFoundation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BaseBlock } from "./baseBlock.js";
|
|
2
|
+
export { InputBlock } from "./inputBlock.js";
|
|
3
|
+
export { ShaderBlock } from "./shaderBlock.js";
|
|
4
|
+
export { CustomShaderBlock } from "./customShaderBlock.js";
|
|
5
|
+
export { CustomAggregateBlock } from "./customAggregateBlock.js";
|
|
6
|
+
export { DisableableShaderBlock, BlockDisableStrategy } from "./disableableShaderBlock.js";
|
|
7
|
+
export { AggregateBlock } from "./aggregateBlock.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/blockFoundation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAA6B,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { SmartFilter } from "../smartFilter.js";
|
|
2
|
+
import type { ConnectionPointValue } from "../connection/connectionPointType.js";
|
|
3
|
+
import type { RuntimeData } from "../connection/connectionPoint.js";
|
|
4
|
+
import type { ConnectionPointWithDefault } from "../connection/connectionPointWithDefault.js";
|
|
5
|
+
import type { DisableableShaderBlock } from "./disableableShaderBlock.js";
|
|
6
|
+
import { BaseBlock } from "./baseBlock.js";
|
|
7
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
8
|
+
import type { Nullable } from "@onerjs/core/types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Predicate to check if a block is a texture input block.
|
|
11
|
+
* @param block - The block to check
|
|
12
|
+
* @returns true if the block is a texture input block, otherwise false
|
|
13
|
+
*/
|
|
14
|
+
export declare function IsTextureInputBlock(block: BaseBlock): block is InputBlock<ConnectionPointType.Texture>;
|
|
15
|
+
/**
|
|
16
|
+
* Predicate to check if a block is a disableable block.
|
|
17
|
+
* @param block - The block to check
|
|
18
|
+
* @returns true if the block is a disableable block, otherwise false
|
|
19
|
+
*/
|
|
20
|
+
export declare function IsDisableableShaderBlock(block: BaseBlock): block is DisableableShaderBlock;
|
|
21
|
+
/**
|
|
22
|
+
* This base class exists to provide a type that the serializer can use to represent
|
|
23
|
+
* any InputBlock without knowing the exact type it is.
|
|
24
|
+
*/
|
|
25
|
+
export declare abstract class InputBlockBase extends BaseBlock {
|
|
26
|
+
/**
|
|
27
|
+
* The class name of the block.
|
|
28
|
+
*/
|
|
29
|
+
static ClassName: string;
|
|
30
|
+
/**
|
|
31
|
+
* The type of the input.
|
|
32
|
+
*/
|
|
33
|
+
abstract readonly type: ConnectionPointType;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Describes the editor data that can be stored with an InputBlock of a given type.
|
|
37
|
+
*/
|
|
38
|
+
export type InputBlockEditorData<T extends ConnectionPointType> = T extends ConnectionPointType.Texture ? {
|
|
39
|
+
/**
|
|
40
|
+
* The URL of the texture, or default if null.
|
|
41
|
+
*/
|
|
42
|
+
url: Nullable<string>;
|
|
43
|
+
/**
|
|
44
|
+
* If supplied, gives a hint as to which type of texture the URL points to.
|
|
45
|
+
* Default is assumed to be "image"
|
|
46
|
+
*/
|
|
47
|
+
urlTypeHint: Nullable<"image" | "video">;
|
|
48
|
+
/**
|
|
49
|
+
* The anisotropic filtering level of the texture, or default if null.
|
|
50
|
+
*/
|
|
51
|
+
anisotropicFilteringLevel: Nullable<number>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the Y axis should be flipped, or default if null.
|
|
54
|
+
*/
|
|
55
|
+
flipY: Nullable<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* The file extension to use, or default if null.
|
|
58
|
+
*/
|
|
59
|
+
forcedExtension: Nullable<string>;
|
|
60
|
+
} : T extends ConnectionPointType.Float ? {
|
|
61
|
+
/**
|
|
62
|
+
* If supplied, how this should be animated by the editor. Will not affect runtime behavior.
|
|
63
|
+
*/
|
|
64
|
+
animationType: Nullable<"time">;
|
|
65
|
+
/**
|
|
66
|
+
* If supplied, the amount to change the value per millisecond when animating.
|
|
67
|
+
*/
|
|
68
|
+
valueDeltaPerMs: Nullable<number>;
|
|
69
|
+
/**
|
|
70
|
+
* The minimum value of the float, used for slider control.
|
|
71
|
+
*/
|
|
72
|
+
min: Nullable<number>;
|
|
73
|
+
/**
|
|
74
|
+
* The maximum value of the float, used for slider control.
|
|
75
|
+
*/
|
|
76
|
+
max: Nullable<number>;
|
|
77
|
+
} : {};
|
|
78
|
+
/**
|
|
79
|
+
* This represents any inputs used in the graph.
|
|
80
|
+
*
|
|
81
|
+
* This is used to provide a way to connect the graph to the outside world.
|
|
82
|
+
*
|
|
83
|
+
* The value is dynamically set by the user.
|
|
84
|
+
*/
|
|
85
|
+
export declare class InputBlock<U extends ConnectionPointType, V = unknown> extends InputBlockBase {
|
|
86
|
+
/**
|
|
87
|
+
* The output connection point of the block.
|
|
88
|
+
*/
|
|
89
|
+
readonly output: ConnectionPointWithDefault<U>;
|
|
90
|
+
/**
|
|
91
|
+
* The type of the input.
|
|
92
|
+
*/
|
|
93
|
+
readonly type: U;
|
|
94
|
+
/**
|
|
95
|
+
* Data used by the Editor to store options required for instantiating the block in the Editor.
|
|
96
|
+
*/
|
|
97
|
+
editorData: Nullable<InputBlockEditorData<U>>;
|
|
98
|
+
/**
|
|
99
|
+
* Metadata the hosting app wants to track for this input. For example, a hint for what data to
|
|
100
|
+
* assign to this input, or hints about how to draw dynamic UI to allow users to control this value.
|
|
101
|
+
*/
|
|
102
|
+
appMetadata: Nullable<V>;
|
|
103
|
+
/**
|
|
104
|
+
* Gets the current value of the input.
|
|
105
|
+
*/
|
|
106
|
+
get runtimeValue(): RuntimeData<U>;
|
|
107
|
+
/**
|
|
108
|
+
* Sets the current value of the input.
|
|
109
|
+
*/
|
|
110
|
+
set runtimeValue(value: RuntimeData<U>);
|
|
111
|
+
/**
|
|
112
|
+
* Creates a new InputBlock.
|
|
113
|
+
* @param smartFilter - The smart filter to add the block to
|
|
114
|
+
* @param name - The friendly name of the block
|
|
115
|
+
* @param type - The type of the input
|
|
116
|
+
* @param initialValue - The initial value of the input
|
|
117
|
+
* @remarks the initial value can either be a strong reference or a value
|
|
118
|
+
*/
|
|
119
|
+
constructor(smartFilter: SmartFilter, name: string, type: U, initialValue: ConnectionPointValue<U> | RuntimeData<U>);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Unionized type of all the possible input types.
|
|
123
|
+
*/
|
|
124
|
+
export type AnyInputBlock = {
|
|
125
|
+
[T in keyof typeof ConnectionPointType]: InputBlock<(typeof ConnectionPointType)[T]>;
|
|
126
|
+
}[keyof typeof ConnectionPointType];
|
|
127
|
+
//# sourceMappingURL=inputBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputBlock.d.ts","sourceRoot":"","sources":["../../src/blockFoundation/inputBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AACpE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AAC9F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,mBAAmB,EAAE,M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SAAS,mBAAmB,EAAE,CAAC,GAAG,OAAO,CAAE,SAAQ,cAAc;IACtF;;OAEG;IACH,SAAgB,MAAM,EAAE,0BAA0B,CAAC,CAAC,CAAC,CAAC;IAEtD;;OAEG;IACH,SAAgB,IAAI,EAAE,CAAC,CAAC;IAExB;;OAEG;IACI,UAAU,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAQ;IAE5D;;;OAGG;IACI,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAQ;IAEvC;;OAEG;IACH,IAAW,YAAY,IAAI,WAAW,CAAC,CAAC,CAAC,CAExC;IAED;;OAEG;IACH,IAAW,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAE5C;IAED;;;;;;;OAOG;gBACS,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;CActH;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;KACvB,CAAC,IAAI,MAAM,OAAO,mBAAmB,GAAG,UAAU,CAAC,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;CACvF,CAAC,MAAM,OAAO,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InputBlock } from "./inputBlock.js";
|
|
2
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
3
|
+
import type { SmartFilter } from "../smartFilter.js";
|
|
4
|
+
import type { ISerializedBlockV1 } from "../serialization/v1/smartFilterSerialization.types.js";
|
|
5
|
+
/**
|
|
6
|
+
* V1 Input Block Deserializer
|
|
7
|
+
* @param smartFilter - The SmartFilter to deserialize the block into
|
|
8
|
+
* @param serializedBlock - The serialized block data
|
|
9
|
+
* @returns A deserialized InputBlock
|
|
10
|
+
*/
|
|
11
|
+
export declare function InputBlockDeserializer(smartFilter: SmartFilter, serializedBlock: ISerializedBlockV1): InputBlock<ConnectionPointType.Texture, unknown> | InputBlock<ConnectionPointType.Boolean, unknown> | InputBlock<ConnectionPointType.Float, unknown> | InputBlock<ConnectionPointType.Color3, unknown> | InputBlock<ConnectionPointType.Color4, unknown> | InputBlock<ConnectionPointType.Vector2, unknown>;
|
|
12
|
+
//# sourceMappingURL=inputBlock.deserializer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputBlock.deserializer.d.ts","sourceRoot":"","sources":["../../src/blockFoundation/inputBlock.deserializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uDAAuD,CAAC;AAEhG;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,kBAAkB,+SA2DnG"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { InputBlock } from "./inputBlock.js";
|
|
2
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
3
|
+
/**
|
|
4
|
+
* V1 Input Block Deserializer
|
|
5
|
+
* @param smartFilter - The SmartFilter to deserialize the block into
|
|
6
|
+
* @param serializedBlock - The serialized block data
|
|
7
|
+
* @returns A deserialized InputBlock
|
|
8
|
+
*/
|
|
9
|
+
export function InputBlockDeserializer(smartFilter, serializedBlock) {
|
|
10
|
+
const blockData = serializedBlock.data;
|
|
11
|
+
let inputBlock;
|
|
12
|
+
switch (blockData.inputType) {
|
|
13
|
+
case ConnectionPointType.Boolean:
|
|
14
|
+
{
|
|
15
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Boolean, blockData.value);
|
|
16
|
+
}
|
|
17
|
+
break;
|
|
18
|
+
case ConnectionPointType.Float:
|
|
19
|
+
{
|
|
20
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Float, blockData.value);
|
|
21
|
+
inputBlock.editorData = {
|
|
22
|
+
animationType: blockData.animationType,
|
|
23
|
+
valueDeltaPerMs: blockData.valueDeltaPerMs,
|
|
24
|
+
min: blockData.min,
|
|
25
|
+
max: blockData.max,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
break;
|
|
29
|
+
case ConnectionPointType.Texture:
|
|
30
|
+
{
|
|
31
|
+
// Create the input block
|
|
32
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Texture, null);
|
|
33
|
+
// If editor data was serialized, set it on the deserialized block
|
|
34
|
+
inputBlock.editorData = {
|
|
35
|
+
url: blockData.url,
|
|
36
|
+
urlTypeHint: blockData.urlTypeHint,
|
|
37
|
+
anisotropicFilteringLevel: blockData.anisotropicFilteringLevel,
|
|
38
|
+
flipY: blockData.flipY,
|
|
39
|
+
forcedExtension: blockData.forcedExtension,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
case ConnectionPointType.Color3:
|
|
44
|
+
{
|
|
45
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Color3, blockData.value);
|
|
46
|
+
}
|
|
47
|
+
break;
|
|
48
|
+
case ConnectionPointType.Color4:
|
|
49
|
+
{
|
|
50
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Color4, blockData.value);
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case ConnectionPointType.Vector2:
|
|
54
|
+
{
|
|
55
|
+
inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Vector2, blockData.value);
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
if (inputBlock) {
|
|
60
|
+
inputBlock.appMetadata = blockData.appMetadata;
|
|
61
|
+
return inputBlock;
|
|
62
|
+
}
|
|
63
|
+
throw new Error("Could not deserialize input block, unknown input type");
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=inputBlock.deserializer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inputBlock.deserializer.js","sourceRoot":"","sources":["../../src/blockFoundation/inputBlock.deserializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAI3E;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,WAAwB,EAAE,eAAmC;IAChG,MAAM,SAAS,GAAG,eAAe,CAAC,IAAgC,CAAC;IACnE,IAAI,UAAU,CAAC;IAEf,QAAQ,SAAS,CAAC,SAAS,EAAE,CAAC;QAC1B,KAAK,mBAAmB,CAAC,OAAO;YAC5B,CAAC;gBACG,UAAU,GAAG,IAAI,UAAU,CAAC,WAAW,EAAE,eAAe,CAAC,IAAI,EAAE,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;YACjH,CAAC;YACD,MAAM;QACV,KAAK,mBAAmB,CAAC,KAAK;YAC1B,CAAC;gBACG,UAAU,GAAG,IAAI,UAAU,CAAC,WAAW,EAAE,eAAe,CAAC,IAAI,EAAE,mBAAmB,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;gBAC3G,UAAU,CAAC,UAAU,GAAG;oBACpB,aAAa,EAAE,SAAS,CAAC,aAAa;oBACtC,eAAe,EAAE,SAAS,CAAC,eAAe;oBAC1C,GAAG,EAAE,SAAS,CAAC,GAAG;oBAClB,GAAG,EAAE,SAAS,CAAC,GAAG;iBACrB,CAAC;YACN,CAAC;YACD,MAAM;QACV,KAAK,mBAAmB,CAAC,OAAO;YAC5B,CAAC;gBACG,yBAAyB;gBACzB,UAAU,GA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