@onerjs/smart-filters 8.25.1 → 8.25.3
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,276 @@
|
|
|
1
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
2
|
+
import { ConnectionPoint } from "../connection/connectionPoint.js";
|
|
3
|
+
import { ConnectionPointWithDefault } from "../connection/connectionPointWithDefault.js";
|
|
4
|
+
import { ConnectionPointDirection } from "../connection/connectionPointDirection.js";
|
|
5
|
+
import { UniqueIdGenerator } from "../utils/uniqueIdGenerator.js";
|
|
6
|
+
/**
|
|
7
|
+
* This class represents the base class for all smart filter blocks.
|
|
8
|
+
*
|
|
9
|
+
* It defines the basic structure of a smart filter block and provides the base implementation for
|
|
10
|
+
* managing the connection points.
|
|
11
|
+
*
|
|
12
|
+
* It enforces common behavior for all smart filter blocks.
|
|
13
|
+
*/
|
|
14
|
+
export class BaseBlock {
|
|
15
|
+
/**
|
|
16
|
+
* The type of the block - used when serializing / deserializing the block, and in the editor.
|
|
17
|
+
* For programmatically created blocks, this should be the class name of the block.
|
|
18
|
+
* For custom blocks, this is specified in the block definition.
|
|
19
|
+
*/
|
|
20
|
+
get blockType() {
|
|
21
|
+
return this.getClassName();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
|
|
25
|
+
* By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
|
|
26
|
+
*/
|
|
27
|
+
get namespace() {
|
|
28
|
+
// Note that we use a static property instead of doing this.constructor.name to avoid problems with minifiers that would change the name of the class
|
|
29
|
+
return this.constructor.Namespace;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Instantiates a new block.
|
|
33
|
+
* @param smartFilter - Defines the smart filter the block belongs to
|
|
34
|
+
* @param name - Defines the name of the block
|
|
35
|
+
* @param disableOptimization - Defines if the block is optimizable or not
|
|
36
|
+
*/
|
|
37
|
+
constructor(smartFilter, name, disableOptimization = false) {
|
|
38
|
+
this.disableOptimization = disableOptimization;
|
|
39
|
+
/**
|
|
40
|
+
* User provided comments about the block. It can be used to document the block.
|
|
41
|
+
*/
|
|
42
|
+
this.comments = null;
|
|
43
|
+
this._inputs = [];
|
|
44
|
+
this._outputs = [];
|
|
45
|
+
this.uniqueId = UniqueIdGenerator.UniqueId;
|
|
46
|
+
this.name = name;
|
|
47
|
+
this.smartFilter = smartFilter;
|
|
48
|
+
// Register the block in the smart filter
|
|
49
|
+
smartFilter.registerBlock(this);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns the inputs connection points of the current block.
|
|
53
|
+
*/
|
|
54
|
+
get inputs() {
|
|
55
|
+
return this._inputs;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns the outputs connection points of the current block.
|
|
59
|
+
*/
|
|
60
|
+
get outputs() {
|
|
61
|
+
return this._outputs;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Returns if the block is an input block.
|
|
65
|
+
*/
|
|
66
|
+
get isInput() {
|
|
67
|
+
return this._inputs.length === 0;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Returns if the block is an output block.
|
|
71
|
+
*/
|
|
72
|
+
get isOutput() {
|
|
73
|
+
return this._outputs.length === 0;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @returns the class name of the block
|
|
77
|
+
*/
|
|
78
|
+
getClassName() {
|
|
79
|
+
// Note that we use a static property instead of doing this.constructor.name to avoid problems with minifiers that would change the name of the class
|
|
80
|
+
return this.constructor.ClassName;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Checks if the block is an "ancestor" of another giving block.
|
|
84
|
+
* @param block - Defines the block to check against
|
|
85
|
+
* @returns True if the block is an ancestor of the given block, otherwise false
|
|
86
|
+
*/
|
|
87
|
+
isAnAncestorOf(block) {
|
|
88
|
+
for (const output of this._outputs) {
|
|
89
|
+
if (!output.endpoints.length) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
for (const endpoint of output.endpoints) {
|
|
93
|
+
if (endpoint.ownerBlock === block) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if (endpoint.ownerBlock.isAnAncestorOf(block)) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
_visitInputs(extraData, callback, alreadyVisited) {
|
|
104
|
+
for (const input of this.inputs) {
|
|
105
|
+
if (!input.connectedTo) {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const block = input.connectedTo.ownerBlock;
|
|
109
|
+
block.visit(extraData, callback, alreadyVisited);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Visits the block and its inputs recursively.
|
|
114
|
+
* When starting from the smart filter output block, this will visit all the blocks in the smart filter.
|
|
115
|
+
* Note that it's a depth first visit: the callback is called on the block AFTER visiting its inputs.
|
|
116
|
+
* @param extraData - The extra data to pass to the callback
|
|
117
|
+
* @param callback - The callback to call on each block
|
|
118
|
+
* @param alreadyVisitedBlocks - Defines the set of blocks already visited (if not provided, a new set will be created)
|
|
119
|
+
*/
|
|
120
|
+
visit(extraData, callback, alreadyVisitedBlocks) {
|
|
121
|
+
if (!alreadyVisitedBlocks) {
|
|
122
|
+
alreadyVisitedBlocks = BaseBlock._AlreadyVisitedBlocks;
|
|
123
|
+
alreadyVisitedBlocks.clear();
|
|
124
|
+
}
|
|
125
|
+
if (!alreadyVisitedBlocks.has(this)) {
|
|
126
|
+
alreadyVisitedBlocks.add(this);
|
|
127
|
+
this._visitInputs(extraData, callback, alreadyVisitedBlocks);
|
|
128
|
+
callback(this, extraData);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Finds the input connection point with the given name.
|
|
133
|
+
* @param name - Name of the input to find
|
|
134
|
+
* @returns The connection point with the given name or null if not found
|
|
135
|
+
*/
|
|
136
|
+
findInput(name) {
|
|
137
|
+
for (const input of this._inputs) {
|
|
138
|
+
if (input.name === name) {
|
|
139
|
+
return input;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Disconnects the block from the graph.
|
|
146
|
+
* @param _disconnectedConnections - Stores the connections that have been broken in the process. You can reconnect them later if needed.
|
|
147
|
+
*/
|
|
148
|
+
disconnectFromGraph(_disconnectedConnections) { }
|
|
149
|
+
/**
|
|
150
|
+
* Prepares the block for runtime.
|
|
151
|
+
* This is called by the smart filter just before creating the smart filter runtime, and by the optimizer.
|
|
152
|
+
*/
|
|
153
|
+
prepareForRuntime() { }
|
|
154
|
+
/**
|
|
155
|
+
* Propagates the runtime data - telling all outputs to propagate their runtime data forward through the graph
|
|
156
|
+
*/
|
|
157
|
+
propagateRuntimeData() {
|
|
158
|
+
for (const output of this._outputs) {
|
|
159
|
+
output.propagateRuntimeData();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Generates the commands needed to execute the block at runtime and gathers promises for initialization work
|
|
164
|
+
* @param initializationData - The initialization data to use
|
|
165
|
+
* @param _finalOutput - Defines if the block is the final output of the smart filter
|
|
166
|
+
*/
|
|
167
|
+
generateCommandsAndGatherInitPromises(initializationData, _finalOutput) {
|
|
168
|
+
// Check if any inputs are Textures which aren't yet ready, and if so, ensure init waits for them to be ready
|
|
169
|
+
for (const input of this._inputs) {
|
|
170
|
+
if (input.type === ConnectionPointType.Texture) {
|
|
171
|
+
const texture = input.runtimeData?.value;
|
|
172
|
+
if (texture && !texture.isReady()) {
|
|
173
|
+
const internalTexture = texture.getInternalTexture();
|
|
174
|
+
if (internalTexture) {
|
|
175
|
+
const textureReadyPromise = new Promise((resolve, reject) => {
|
|
176
|
+
internalTexture.onLoadedObservable.add(() => {
|
|
177
|
+
resolve();
|
|
178
|
+
});
|
|
179
|
+
internalTexture.onErrorObservable.add((error) => {
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
181
|
+
reject(error);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
initializationData.initializationPromises.push(textureReadyPromise);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Disconnects all the inputs and outputs from the Block.
|
|
192
|
+
*/
|
|
193
|
+
disconnect() {
|
|
194
|
+
// Detach inputs
|
|
195
|
+
for (const input of this._inputs) {
|
|
196
|
+
input.connectedTo?.disconnectFrom(input);
|
|
197
|
+
}
|
|
198
|
+
// Detach outputs
|
|
199
|
+
for (const output of this._outputs) {
|
|
200
|
+
output.disconnectAllEndpoints();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Registers a new input connection point in the block which must have a connection before the graph can be used.
|
|
205
|
+
* @param name - Defines the name of the input connection point
|
|
206
|
+
* @param type - Defines the type of the input connection point
|
|
207
|
+
* @param defaultValue - Defines the optional default value of the input connection point to use if not connection is made
|
|
208
|
+
* @returns The new ConnectionPoint
|
|
209
|
+
* @internal
|
|
210
|
+
*/
|
|
211
|
+
_registerInput(name, type, defaultValue = null) {
|
|
212
|
+
const input = new ConnectionPoint(name, this, type, ConnectionPointDirection.Input, defaultValue);
|
|
213
|
+
this._inputs.push(input);
|
|
214
|
+
return input;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Registers a new input connection point in the block which doesn't require a connection because it has a default value.
|
|
218
|
+
* @param name - Defines the name of the input connection point
|
|
219
|
+
* @param type - Defines the type of the input connection point
|
|
220
|
+
* @param defaultValue - Defines the default value to use if nothing is connected to this connection point
|
|
221
|
+
* @returns The new ConnectionPointWithDefault
|
|
222
|
+
* @internal
|
|
223
|
+
*/
|
|
224
|
+
_registerOptionalInput(name, type, defaultValue) {
|
|
225
|
+
const input = new ConnectionPointWithDefault(name, this, type, ConnectionPointDirection.Input, defaultValue);
|
|
226
|
+
this._inputs.push(input);
|
|
227
|
+
return input;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Registers a new output connection point in the block.
|
|
231
|
+
* @param name - Defines the name of the output connection point
|
|
232
|
+
* @param type - Defines the type of the output connection point
|
|
233
|
+
* @returns The new output connection point
|
|
234
|
+
* @internal
|
|
235
|
+
*/
|
|
236
|
+
_registerOutput(name, type) {
|
|
237
|
+
const output = new ConnectionPoint(name, this, type, ConnectionPointDirection.Output);
|
|
238
|
+
this._outputs.push(output);
|
|
239
|
+
return output;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Registers a new output connection point in the block that always has runtimeData because it has a default value and doesn't allow it to be overwritten with null.
|
|
243
|
+
* @param name - Defines the name of the output connection point
|
|
244
|
+
* @param type - Defines the type of the output connection point
|
|
245
|
+
* @param initialValue - Defines the initial value of the output connection point
|
|
246
|
+
* @returns The new output connection point with a default value
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
_registerOutputWithDefault(name, type, initialValue) {
|
|
250
|
+
const output = new ConnectionPointWithDefault(name, this, type, ConnectionPointDirection.Output, initialValue);
|
|
251
|
+
this._outputs.push(output);
|
|
252
|
+
return output;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Gets the required RuntimeData for the given input, throwing with a clear message if it is null
|
|
256
|
+
* @param input - The input to get the runtime data for
|
|
257
|
+
* @returns The runtimeData or throws if it was undefined
|
|
258
|
+
*/
|
|
259
|
+
_confirmRuntimeDataSupplied(input) {
|
|
260
|
+
if (!input.runtimeData) {
|
|
261
|
+
throw new Error(`The ${ConnectionPointType[input.type]} input named "${input.name}" is missing for the ${this.getClassName()} named "${this.name}"`);
|
|
262
|
+
}
|
|
263
|
+
return input.runtimeData;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
BaseBlock._AlreadyVisitedBlocks = new Set();
|
|
267
|
+
/**
|
|
268
|
+
* The class name of the block.
|
|
269
|
+
*/
|
|
270
|
+
BaseBlock.ClassName = "BaseBlock";
|
|
271
|
+
/**
|
|
272
|
+
* The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
|
|
273
|
+
* By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
|
|
274
|
+
*/
|
|
275
|
+
BaseBlock.Namespace = null;
|
|
276
|
+
//# sourceMappingURL=baseBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseBlock.js","sourceRoot":"","sources":["../../src/blockFoundation/baseBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAA6B,MAAM,sCAAsC,CAAC;AAGtG,OAAO,EAAE,eAAe,EAAoB,MAAM,kCAAkC,CAAC;AACrF,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAQlE;;;;;;;GAOG;AACH,MAAM,OAAgB,SAAS;IA6B3B;;;;OAIG;IACH,IAAW,SAAS;QAChB,OAAO,IAAI,CAAC,YAAY,EAAE,CAAC;IAC/B,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS;QAChB,qJAAqJ;QACrJ,OAAQ,IAAI,CAAC,WAAgC,CAAC,SAAS,CAAC;IAC5D,CAAC;IAUD;;;;;OAKG;IACH,YACI,WAAwB,EACxB,IAAY,EACI,sBAAsB,KAAK;QAA3B,wBAAmB,GAAnB,mBAAmB,CAAQ;QAjB/C;;WAEG;QACI,aAAQ,GAAqB,IAAI,CAAC;QAExB,YAAO,GAAsB,EAAE,CAAC;QAChC,aAAQ,GAAsB,EAAE,CAAC;QAa9C,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC,QAAQ,CAAC;QAC3C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,yCAAyC;QACzC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;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AzTgB,+BAAqB,GAAG,IAAI,GAAG,EAAa,AAAvB,CAAwB;AAE9D;;GAEG;AACW,mBAAS,GAAG,WAAW,AAAd,CAAe;AAEtC;;;GAGG;AACW,mBAAS,GAAqB,IAAI,AAAzB,CAA0B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ThinEngine } from "@onerjs/core/Engines/thinEngine.js";
|
|
2
|
+
import type { SmartFilterDeserializer, SerializedBlockDefinition } from "../serialization/index.js";
|
|
3
|
+
import type { SmartFilter } from "../smartFilter.js";
|
|
4
|
+
import { AggregateBlock } from "./aggregateBlock.js";
|
|
5
|
+
import type { BaseBlock } from "./baseBlock.js";
|
|
6
|
+
import type { Nullable } from "@onerjs/core/types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Loads a serialized Smart Filter into a block which can be used in another SmartFilter.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CustomAggregateBlock extends AggregateBlock {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new CustomAggregateBlock
|
|
13
|
+
* @param smartFilter - The Smart Filter to create the block for
|
|
14
|
+
* @param engine - The ThinEngine to use
|
|
15
|
+
* @param name - The friendly name of the block
|
|
16
|
+
* @param serializedSmartFilter - The serialized SmartFilter to load into the block
|
|
17
|
+
* @param smartFilterDeserializer - The deserializer to use
|
|
18
|
+
* @returns A promise that resolves to the new CustomAggregateBlock
|
|
19
|
+
*/
|
|
20
|
+
static Create(smartFilter: SmartFilter, engine: ThinEngine, name: string, serializedSmartFilter: SerializedBlockDefinition, smartFilterDeserializer: SmartFilterDeserializer): Promise<BaseBlock>;
|
|
21
|
+
/**
|
|
22
|
+
* The class name of the block.
|
|
23
|
+
*/
|
|
24
|
+
static ClassName: string;
|
|
25
|
+
private readonly _blockType;
|
|
26
|
+
private readonly _namespace;
|
|
27
|
+
/**
|
|
28
|
+
* The type of the block - used when serializing / deserializing the block, and in the editor.
|
|
29
|
+
*/
|
|
30
|
+
get blockType(): string;
|
|
31
|
+
/**
|
|
32
|
+
* The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
|
|
33
|
+
* By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
|
|
34
|
+
*/
|
|
35
|
+
get namespace(): Nullable<string>;
|
|
36
|
+
private constructor();
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=customAggregateBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customAggregateBlock.d.ts","sourceRoot":"","sources":["../../src/blockFoundation/customAggregateBlock.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,2CAAmC;AAC7D,OAAO,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACpG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,8BAAsB;AAE9C;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,cAAc;IACpD;;;;;;;;OAQG;WAEiB,MAAM,CACtB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,qBAAqB,EAAE,yBAAyB,EAChD,uBAAuB,EAAE,uBAAuB,GACjD,OAAO,CAAC,SAAS,CAAC;IAKrB;;OAEG;IACH,OAAuB,SAAS,SAA0B;IAE1D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAE9C;;OAEG;IACH,IAAoB,SAAS,IAAI,MAAM,CAEtC;IAED;;;OAGG;IACH,IAAoB,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,CAEhD;IAED,OAAO;CA+BV"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { AggregateBlock } from "./aggregateBlock.js";
|
|
2
|
+
/**
|
|
3
|
+
* Loads a serialized Smart Filter into a block which can be used in another SmartFilter.
|
|
4
|
+
*/
|
|
5
|
+
export class CustomAggregateBlock extends AggregateBlock {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a new CustomAggregateBlock
|
|
8
|
+
* @param smartFilter - The Smart Filter to create the block for
|
|
9
|
+
* @param engine - The ThinEngine to use
|
|
10
|
+
* @param name - The friendly name of the block
|
|
11
|
+
* @param serializedSmartFilter - The serialized SmartFilter to load into the block
|
|
12
|
+
* @param smartFilterDeserializer - The deserializer to use
|
|
13
|
+
* @returns A promise that resolves to the new CustomAggregateBlock
|
|
14
|
+
*/
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
|
+
static async Create(smartFilter, engine, name, serializedSmartFilter, smartFilterDeserializer) {
|
|
17
|
+
const innerSmartFilter = await smartFilterDeserializer.deserialize(engine, serializedSmartFilter);
|
|
18
|
+
return new CustomAggregateBlock(smartFilter, name, serializedSmartFilter.blockType, serializedSmartFilter.namespace, innerSmartFilter, false);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The type of the block - used when serializing / deserializing the block, and in the editor.
|
|
22
|
+
*/
|
|
23
|
+
get blockType() {
|
|
24
|
+
return this._blockType;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
|
|
28
|
+
* By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
|
|
29
|
+
*/
|
|
30
|
+
get namespace() {
|
|
31
|
+
return this._namespace;
|
|
32
|
+
}
|
|
33
|
+
constructor(smartFilter, name, blockType, namespace, innerSmartFilter, disableOptimization) {
|
|
34
|
+
super(smartFilter, name, disableOptimization);
|
|
35
|
+
this._blockType = blockType;
|
|
36
|
+
this._namespace = namespace;
|
|
37
|
+
const attachedBlocks = innerSmartFilter.attachedBlocks;
|
|
38
|
+
for (let index = 0; index < attachedBlocks.length; index++) {
|
|
39
|
+
const block = attachedBlocks[index];
|
|
40
|
+
if (block && block.isInput && block.outputs[0]) {
|
|
41
|
+
// If this input block is connected to anything (has any endpoints), create an input connection point for it
|
|
42
|
+
if (block.outputs[0].endpoints.length > 0) {
|
|
43
|
+
this._registerSubfilterInput(block.name, block.outputs[0].endpoints.slice(), block.outputs[0].runtimeData ?? null);
|
|
44
|
+
}
|
|
45
|
+
// Remove this input block from the Smart Filter graph - this will reset the runtimeData to the
|
|
46
|
+
// default for that connection point (which may be null)
|
|
47
|
+
innerSmartFilter.removeBlock(block);
|
|
48
|
+
index--;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (!innerSmartFilter.output.connectedTo) {
|
|
52
|
+
throw new Error("The inner smart filter must have an output connected to something");
|
|
53
|
+
}
|
|
54
|
+
this._registerSubfilterOutput("output", innerSmartFilter.output.connectedTo);
|
|
55
|
+
// Disconnect the inner Smart Filter output from the inner Smart Filter
|
|
56
|
+
innerSmartFilter.output.connectedTo.disconnectFrom(innerSmartFilter.output);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The class name of the block.
|
|
61
|
+
*/
|
|
62
|
+
CustomAggregateBlock.ClassName = "CustomAggregateBlock";
|
|
63
|
+
//# sourceMappingURL=customAggregateBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customAggregateBlock.js","sourceRoot":"","sources":["../../src/blockFoundation/customAggregateBlock.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAIrD;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,cAAc;IACpD;;;;;;;;OAQG;IACH,gEAAgE;IACzD,MAAM,CAAC,KAAK,CAAC,MAAM,CACtB,WAAwB,EACxB,MAAkB,EAClB,IAAY,EACZ,qBAAgD,EAChD,uBAAgD;QAEhD,MAAM,gBAAg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AI,CAAC,CAAC;gBACvH,CAAC;gBAED,+FAA+F;gBAC/F,wDAAwD;gBACxD,gBAAgB,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;gBACpC,KAAK,EAAE,CAAC;YACZ,CAAC;QACL,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;QACzF,CAAC;QAED,IAAI,CAAC,wBAAwB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAE7E,uEAAuE;QACvE,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChF,CAAC;;AArDD;;GAEG;AACoB,8BAAS,GAAG,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ShaderBinding } from "../runtime/shaderRuntime.js";
|
|
2
|
+
import type { SerializedShaderBlockDefinition } from "../serialization/serializedShaderBlockDefinition.js";
|
|
3
|
+
import type { SmartFilter } from "../smartFilter.js";
|
|
4
|
+
import type { ShaderProgram } from "../utils/shaderCodeUtils.js";
|
|
5
|
+
import { ShaderBlock } from "./shaderBlock.js";
|
|
6
|
+
import type { Nullable } from "@onerjs/core/types.js";
|
|
7
|
+
/**
|
|
8
|
+
* A block which loads a SerializedBlockDefinition for use in a SmartFilter.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CustomShaderBlock extends ShaderBlock {
|
|
11
|
+
/**
|
|
12
|
+
* Deserializes a CustomShaderBlock from a serialized block definition.
|
|
13
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
14
|
+
* @param name - Defines the name of the block
|
|
15
|
+
* @param blockDefinition - The serialized block definition
|
|
16
|
+
* @returns The deserialized CustomShaderBlock instance
|
|
17
|
+
*/
|
|
18
|
+
static Create(smartFilter: SmartFilter, name: string, blockDefinition: SerializedShaderBlockDefinition): CustomShaderBlock;
|
|
19
|
+
/**
|
|
20
|
+
* The class name of the block.
|
|
21
|
+
*/
|
|
22
|
+
static ClassName: string;
|
|
23
|
+
private readonly _shaderProgram;
|
|
24
|
+
private readonly _blockType;
|
|
25
|
+
private readonly _namespace;
|
|
26
|
+
private _autoBoundInputs;
|
|
27
|
+
/**
|
|
28
|
+
* The type of the block - used when serializing / deserializing the block, and in the editor.
|
|
29
|
+
*/
|
|
30
|
+
get blockType(): string;
|
|
31
|
+
/**
|
|
32
|
+
* The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
|
|
33
|
+
* By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
|
|
34
|
+
*/
|
|
35
|
+
get namespace(): Nullable<string>;
|
|
36
|
+
/**
|
|
37
|
+
* Instantiates a new custom shader block.
|
|
38
|
+
* @param smartFilter - The smart filter this block belongs to
|
|
39
|
+
* @param name - The name of the block
|
|
40
|
+
* @param disableOptimization - If true, this optimizer will not attempt to optimize this block
|
|
41
|
+
* @param blockType - The type of the block
|
|
42
|
+
* @param namespace - The namespace of the block
|
|
43
|
+
* @param inputConnectionPoints - The input connection points of the
|
|
44
|
+
* @param shaderProgram - The shader program for the block
|
|
45
|
+
*/
|
|
46
|
+
private constructor();
|
|
47
|
+
/**
|
|
48
|
+
* Gets the shader program to use to render the block.
|
|
49
|
+
* @returns The shader program to use to render the block
|
|
50
|
+
*/
|
|
51
|
+
getShaderProgram(): ShaderProgram;
|
|
52
|
+
/**
|
|
53
|
+
* Checks a specific input connection point type to see if it has a default value, and registers the input
|
|
54
|
+
* connection point accordingly.
|
|
55
|
+
* @param connectionPoint - The input connection point to register
|
|
56
|
+
*/
|
|
57
|
+
private _registerSerializedInputConnectionPointV1;
|
|
58
|
+
/**
|
|
59
|
+
* Gets the shader binding for the custom shader block.
|
|
60
|
+
* @returns The shader binding for the custom shader block
|
|
61
|
+
*/
|
|
62
|
+
getShaderBinding(): ShaderBinding;
|
|
63
|
+
/**
|
|
64
|
+
* Validates the default value of a connection point and returns it if valid.
|
|
65
|
+
* If the default value is not provided or is invalid, this returns null.
|
|
66
|
+
* @param connectionPointType - The type of the connection point
|
|
67
|
+
* @param connectionPointName - The name of the connection point
|
|
68
|
+
* @param defaultValue - The default value of the connection point
|
|
69
|
+
* @returns The default value, or null if no default value is provided or it was invalid
|
|
70
|
+
*/
|
|
71
|
+
private _validateDefaultValue;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=customShaderBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customShaderBlock.d.ts","sourceRoot":"","sources":["../../src/blockFoundation/customShaderBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,qDAAqD,CAAC;AAE3G,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,8BAAsB;AA6E9C;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,WAAW;IAC9C;;;;;;OAMG;WACW,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,eAAe,EAAE,+BAA+B,GAAG,iBAAiB;IAcjI;;OAEG;IACH,OAAuB,SAAS,SAAuB;IAEvD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;IAC/C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,OAAO,CAAC,gBAAgB,CAAsD;IAE9E;;OAEG;IACH,IAAoB,SAAS,IAAI,MAAM,CAEtC;IAED;;;OAGG;IACH,IAAoB,SAAS,IAAI,QAAQ,CAAC,MAAM,CAAC,CAEhD;IAED;;;;;;;;;OASG;IACH,OAAO;IAoBP;;;OAGG;IACa,gBAAgB;IAIhC;;;;OAIG;IACH,OAAO,CAAC,yCAAyC;IAkBjD;;;OAGG;IACa,gBAAgB,IAAI,aAAa;IAgCjD;;;;;;;OAOG;IACH,OAAO,CAAC,qBAAqB;CAuChC"}
|