@babylonjs/smart-filters 0.1.0-alpha
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/blocks/aggregateBlock.d.ts +50 -0
- package/dist/blocks/aggregateBlock.d.ts.map +1 -0
- package/dist/blocks/aggregateBlock.js +103 -0
- package/dist/blocks/aggregateBlock.js.map +1 -0
- package/dist/blocks/baseBlock.d.ts +160 -0
- package/dist/blocks/baseBlock.d.ts.map +1 -0
- package/dist/blocks/baseBlock.js +256 -0
- package/dist/blocks/baseBlock.js.map +1 -0
- package/dist/blocks/copyBlock.d.ts +59 -0
- package/dist/blocks/copyBlock.d.ts.map +1 -0
- package/dist/blocks/copyBlock.js +84 -0
- package/dist/blocks/copyBlock.js.map +1 -0
- package/dist/blocks/disableableBlock.d.ts +30 -0
- package/dist/blocks/disableableBlock.d.ts.map +1 -0
- package/dist/blocks/disableableBlock.js +22 -0
- package/dist/blocks/disableableBlock.js.map +1 -0
- package/dist/blocks/inputBlock.d.ts +64 -0
- package/dist/blocks/inputBlock.d.ts.map +1 -0
- package/dist/blocks/inputBlock.js +74 -0
- package/dist/blocks/inputBlock.js.map +1 -0
- package/dist/blocks/outputBlock.d.ts +42 -0
- package/dist/blocks/outputBlock.d.ts.map +1 -0
- package/dist/blocks/outputBlock.js +74 -0
- package/dist/blocks/outputBlock.js.map +1 -0
- package/dist/blocks/shaderBlock.d.ts +68 -0
- package/dist/blocks/shaderBlock.d.ts.map +1 -0
- package/dist/blocks/shaderBlock.js +101 -0
- package/dist/blocks/shaderBlock.js.map +1 -0
- package/dist/command/command.d.ts +49 -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 +12 -0
- package/dist/command/commandBufferDebugger.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 +153 -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 +22 -0
- package/dist/connection/connectionPointType.d.ts.map +1 -0
- package/dist/connection/connectionPointType.js +17 -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/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -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 +77 -0
- package/dist/optimization/dependencyGraph.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 +72 -0
- package/dist/optimization/smartFilterOptimizer.d.ts.map +1 -0
- package/dist/optimization/smartFilterOptimizer.js +482 -0
- package/dist/optimization/smartFilterOptimizer.js.map +1 -0
- package/dist/runtime/renderTargetGenerator.d.ts +35 -0
- package/dist/runtime/renderTargetGenerator.d.ts.map +1 -0
- package/dist/runtime/renderTargetGenerator.js +153 -0
- package/dist/runtime/renderTargetGenerator.js.map +1 -0
- package/dist/runtime/shaderRuntime.d.ts +95 -0
- package/dist/runtime/shaderRuntime.d.ts.map +1 -0
- package/dist/runtime/shaderRuntime.js +120 -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 +57 -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/smartFilter.d.ts +100 -0
- package/dist/smartFilter.d.ts.map +1 -0
- package/dist/smartFilter.js +154 -0
- package/dist/smartFilter.js.map +1 -0
- package/dist/utils/shaderCodeUtils.d.ts +131 -0
- package/dist/utils/shaderCodeUtils.d.ts.map +1 -0
- package/dist/utils/shaderCodeUtils.js +115 -0
- package/dist/utils/shaderCodeUtils.js.map +1 -0
- package/dist/utils/textureLoaders.d.ts +14 -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/license.md +21 -0
- package/package.json +47 -0
- package/readme.md +165 -0
- package/src/IDisposable.ts +9 -0
- package/src/blocks/aggregateBlock.ts +121 -0
- package/src/blocks/baseBlock.ts +341 -0
- package/src/blocks/copyBlock.ts +103 -0
- package/src/blocks/disableableBlock.ts +40 -0
- package/src/blocks/inputBlock.ts +114 -0
- package/src/blocks/outputBlock.ts +97 -0
- package/src/blocks/shaderBlock.ts +145 -0
- package/src/command/command.ts +60 -0
- package/src/command/commandBuffer.ts +71 -0
- package/src/command/commandBufferDebugger.ts +13 -0
- package/src/connection/connectionPoint.ts +212 -0
- package/src/connection/connectionPointCompatibilityState.ts +31 -0
- package/src/connection/connectionPointDirection.ts +9 -0
- package/src/connection/connectionPointType.ts +30 -0
- package/src/connection/connectionPointWithDefault.ts +35 -0
- package/src/index.ts +36 -0
- package/src/optimization/dependencyGraph.ts +94 -0
- package/src/optimization/optimizedShaderBlock.ts +133 -0
- package/src/optimization/smartFilterOptimizer.ts +706 -0
- package/src/runtime/renderTargetGenerator.ts +204 -0
- package/src/runtime/shaderRuntime.ts +155 -0
- package/src/runtime/smartFilterRuntime.ts +104 -0
- package/src/runtime/strongRef.ts +18 -0
- package/src/smartFilter.ts +227 -0
- package/src/utils/shaderCodeUtils.ts +242 -0
- package/src/utils/textureLoaders.ts +28 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IDisposable.d.ts","sourceRoot":"","sources":["../src/IDisposable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IDisposable.js","sourceRoot":"","sources":["../src/IDisposable.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ConnectionPoint } from "../connection/connectionPoint";
|
|
2
|
+
import type { ConnectionPointType } from "../connection/connectionPointType";
|
|
3
|
+
import { BaseBlock } from "../blocks/baseBlock.js";
|
|
4
|
+
/**
|
|
5
|
+
* The aggregate block class is the base class for all blocks that be created from other blocks.
|
|
6
|
+
*
|
|
7
|
+
* It is responsible for managing a hidden chain of smart filter blocks in order and expose them through
|
|
8
|
+
* its own connection points.
|
|
9
|
+
*
|
|
10
|
+
* The internal state is basically a filter itself.
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class AggregateBlock extends BaseBlock {
|
|
13
|
+
/**
|
|
14
|
+
* The class name of the block.
|
|
15
|
+
*/
|
|
16
|
+
static ClassName: string;
|
|
17
|
+
/**
|
|
18
|
+
* The list of relationships between the internal graph output and the outside ones.
|
|
19
|
+
*/
|
|
20
|
+
private readonly _aggregatedOutputs;
|
|
21
|
+
/**
|
|
22
|
+
* The list of relationships between the internal graph inputs and the outside ones.
|
|
23
|
+
*/
|
|
24
|
+
private readonly _aggregatedInputs;
|
|
25
|
+
/**
|
|
26
|
+
* @internal
|
|
27
|
+
* Merges the internal graph into the SmartFilter
|
|
28
|
+
*/
|
|
29
|
+
_mergeIntoSmartFilter(mergedAggregateBlocks: AggregateBlock[]): void;
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
* Undoes a previous mergeIntoSmartFilter call.
|
|
33
|
+
*/
|
|
34
|
+
_unmergeFromSmartFilter(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Registers an input connection from the internal graph as an input of the aggregated graph.
|
|
37
|
+
* @param name - The name of the exposed input connection point
|
|
38
|
+
* @param internalConnectionPoint - The input connection point in the inner graph to expose as an input on the aggregate block
|
|
39
|
+
* @returns the connection point referencing the input block
|
|
40
|
+
*/
|
|
41
|
+
protected _registerSubfilterInput<U extends ConnectionPointType>(name: string, internalConnectionPoint: ConnectionPoint<U>): ConnectionPoint<U>;
|
|
42
|
+
/**
|
|
43
|
+
* Registers an output connection point from the internal graph as an output of the aggregated graph.
|
|
44
|
+
* @param name - The name of the exposed output connection point
|
|
45
|
+
* @param internalConnectionPoint - The output connection point in the inner graph to expose as an output on the aggregate block
|
|
46
|
+
* @returns the connection point referencing the output connection point
|
|
47
|
+
*/
|
|
48
|
+
protected _registerSubfilterOutput<U extends ConnectionPointType>(name: string, internalConnectionPoint: ConnectionPoint<U>): ConnectionPoint<U>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=aggregateBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregateBlock.d.ts","sourceRoot":"","sources":["../../src/blocks/aggregateBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAE7E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;;;;;;GAOG;AACH,8BAAsB,cAAe,SAAQ,SAAS;IAClD;;OAEG;IACH,OAAuB,SAAS,SAAoB;IAEpD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA4C;IAE/E;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA4C;IAE9E;;;OAGG;IACI,qBAAqB,CAAC,qBAAqB,EAAE,cAAc,EAAE,GAAG,IAAI;IAkC3E;;;OAGG;IACI,uBAAuB,IAAI,IAAI;IAkBtC;;;;;OAKG;IACH,SAAS,CAAC,uBAAuB,CAAC,CAAC,SAAS,mBAAmB,EAC3D,IAAI,EAAE,MAAM,EACZ,uBAAuB,EAAE,eAAe,CAAC,CAAC,CAAC,GAC5C,eAAe,CAAC,CAAC,CAAC;IAOrB;;;;;OAKG;IACH,SAAS,CAAC,wBAAwB,CAAC,CAAC,SAAS,mBAAmB,EAC5D,IAAI,EAAE,MAAM,EACZ,uBAAuB,EAAE,eAAe,CAAC,CAAC,CAAC,GAC5C,eAAe,CAAC,CAAC,CAAC;CAMxB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { BaseBlock } from "../blocks/baseBlock.js";
|
|
2
|
+
/**
|
|
3
|
+
* The aggregate block class is the base class for all blocks that be created from other blocks.
|
|
4
|
+
*
|
|
5
|
+
* It is responsible for managing a hidden chain of smart filter blocks in order and expose them through
|
|
6
|
+
* its own connection points.
|
|
7
|
+
*
|
|
8
|
+
* The internal state is basically a filter itself.
|
|
9
|
+
*/
|
|
10
|
+
export class AggregateBlock extends BaseBlock {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
/**
|
|
14
|
+
* The list of relationships between the internal graph output and the outside ones.
|
|
15
|
+
*/
|
|
16
|
+
this._aggregatedOutputs = [];
|
|
17
|
+
/**
|
|
18
|
+
* The list of relationships between the internal graph inputs and the outside ones.
|
|
19
|
+
*/
|
|
20
|
+
this._aggregatedInputs = [];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
* Merges the internal graph into the SmartFilter
|
|
25
|
+
*/
|
|
26
|
+
_mergeIntoSmartFilter(mergedAggregateBlocks) {
|
|
27
|
+
// Rewire output connections
|
|
28
|
+
for (const [internalConnectionPoint, externalConnectionPoint] of this._aggregatedOutputs) {
|
|
29
|
+
const endpointsToConnectTo = externalConnectionPoint.endpoints.slice();
|
|
30
|
+
externalConnectionPoint.disconnectAllEndpoints();
|
|
31
|
+
for (const endpoint of endpointsToConnectTo) {
|
|
32
|
+
internalConnectionPoint.connectTo(endpoint);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
// Rewire input connections
|
|
36
|
+
for (const [internalConnectionPoint, externalConnectionPoint] of this._aggregatedInputs) {
|
|
37
|
+
const connectedToExternalConnectionPoint = externalConnectionPoint.connectedTo;
|
|
38
|
+
if (connectedToExternalConnectionPoint) {
|
|
39
|
+
connectedToExternalConnectionPoint.disconnectFrom(externalConnectionPoint);
|
|
40
|
+
connectedToExternalConnectionPoint.connectTo(internalConnectionPoint);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Tell any internal aggregate blocks to merge
|
|
44
|
+
// Must be done after the inputs and outputs were merged at our level, or the internal aggregate block may not be wired up to anything
|
|
45
|
+
for (const aggregateOutput of this._aggregatedOutputs) {
|
|
46
|
+
const internalConnectionPoint = aggregateOutput[0];
|
|
47
|
+
internalConnectionPoint.ownerBlock.visit({}, (block, _extraData) => {
|
|
48
|
+
if (block instanceof AggregateBlock) {
|
|
49
|
+
block._mergeIntoSmartFilter(mergedAggregateBlocks);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// Add ourselves to the list of merged aggregate blocks
|
|
54
|
+
mergedAggregateBlocks.push(this);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @internal
|
|
58
|
+
* Undoes a previous mergeIntoSmartFilter call.
|
|
59
|
+
*/
|
|
60
|
+
_unmergeFromSmartFilter() {
|
|
61
|
+
for (const [internalConnectionPoint, externalConnectionPoint] of this._aggregatedOutputs) {
|
|
62
|
+
const endpointsToConnectTo = internalConnectionPoint.endpoints.slice();
|
|
63
|
+
internalConnectionPoint.disconnectAllEndpoints();
|
|
64
|
+
for (const endpoint of endpointsToConnectTo) {
|
|
65
|
+
externalConnectionPoint.connectTo(endpoint);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
for (const [internalConnectionPoint, externalConnectionPoint] of this._aggregatedInputs) {
|
|
69
|
+
const connectedToInternalConnectionPoint = internalConnectionPoint.connectedTo;
|
|
70
|
+
if (connectedToInternalConnectionPoint) {
|
|
71
|
+
connectedToInternalConnectionPoint.disconnectFrom(internalConnectionPoint);
|
|
72
|
+
connectedToInternalConnectionPoint.connectTo(externalConnectionPoint);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Registers an input connection from the internal graph as an input of the aggregated graph.
|
|
78
|
+
* @param name - The name of the exposed input connection point
|
|
79
|
+
* @param internalConnectionPoint - The input connection point in the inner graph to expose as an input on the aggregate block
|
|
80
|
+
* @returns the connection point referencing the input block
|
|
81
|
+
*/
|
|
82
|
+
_registerSubfilterInput(name, internalConnectionPoint) {
|
|
83
|
+
const externalInputConnectionPoint = this._registerInput(name, internalConnectionPoint.type);
|
|
84
|
+
this._aggregatedInputs.push([internalConnectionPoint, externalInputConnectionPoint]);
|
|
85
|
+
return externalInputConnectionPoint;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Registers an output connection point from the internal graph as an output of the aggregated graph.
|
|
89
|
+
* @param name - The name of the exposed output connection point
|
|
90
|
+
* @param internalConnectionPoint - The output connection point in the inner graph to expose as an output on the aggregate block
|
|
91
|
+
* @returns the connection point referencing the output connection point
|
|
92
|
+
*/
|
|
93
|
+
_registerSubfilterOutput(name, internalConnectionPoint) {
|
|
94
|
+
const externalOutputConnectionPoint = this._registerOutput(name, internalConnectionPoint.type);
|
|
95
|
+
this._aggregatedOutputs.push([internalConnectionPoint, externalOutputConnectionPoint]);
|
|
96
|
+
return externalOutputConnectionPoint;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The class name of the block.
|
|
101
|
+
*/
|
|
102
|
+
AggregateBlock.ClassName = "AggregateBlock";
|
|
103
|
+
//# sourceMappingURL=aggregateBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aggregateBlock.js","sourceRoot":"","sources":["../../src/blocks/aggregateBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,OAAgB,cAAe,SAAQ,SAAS;IAAtD;;QAMI;;WAEG;QACc,uBAAkB,GAAyC,EAAE,CAAC;QAE/E;;WAEG;QACc,sBAAiB,GAAyC,EAAE,CAAC;IA6FlF,CAAC;IA3FG;;;OAGG;IACI,qBAAqB,CAAC,qBAAuC;QAChE,4BAA4B;QAC5B,KAAK,MAAM,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACvF,MAAM,oBAAoB,GAAG,uBAAuB,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;YACvE,uBAAuB,CAAC,sBAAsB,EAAE,CAAC;YACjD,KAAK,MA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C,CAAC;YAChD,CAAC;QACL,CAAC;QAED,KAAK,MAAM,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;YACtF,MAAM,kCAAkC,GAAG,uBAAuB,CAAC,WAAW,CAAC;YAC/E,IAAI,kCAAkC,EAAE,CAAC;gBACrC,kCAAkC,CAAC,cAAc,CAAC,uBAAuB,CAAC,CAAC;gBAC3E,kCAAkC,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;YAC1E,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACO,uBAAuB,CAC7B,IAAY,EACZ,uBAA2C;QAE3C,MAAM,4BAA4B,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAE7F,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,uBAAuB,EAAE,4BAA4B,CAAC,CAAC,CAAC;QACrF,OAAO,4BAA4B,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACO,wBAAwB,CAC9B,IAAY,EACZ,uBAA2C;QAE3C,MAAM,6BAA6B,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,uBAAuB,CAAC,IAAI,CAAC,CAAC;QAE/F,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,uBAAuB,EAAE,6BAA6B,CAAC,CAAC,CAAC;QACvF,OAAO,6BAA6B,CAAC;IACzC,CAAC;;AAzGD;;GAEG;AACoB,wBAAS,GAAG,gBAAgB,AAAnB,CAAoB"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { Nullable } from "@babylonjs/core/types";
|
|
2
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
3
|
+
import type { InitializationData, SmartFilter } from "../smartFilter";
|
|
4
|
+
import type { ICommandOwner } from "../command/command";
|
|
5
|
+
import { ConnectionPoint, type RuntimeData } from "../connection/connectionPoint.js";
|
|
6
|
+
import { ConnectionPointWithDefault } from "../connection/connectionPointWithDefault.js";
|
|
7
|
+
/**
|
|
8
|
+
* Defines a callback function that is triggered when visiting a block,
|
|
9
|
+
* It also carries over extra data preventing the need to use global variables or closures.
|
|
10
|
+
*/
|
|
11
|
+
export type BlockVisitor<T extends object> = (block: BaseBlock, extraData: T) => void;
|
|
12
|
+
/**
|
|
13
|
+
* This class represents the base class for all smart filter blocks.
|
|
14
|
+
*
|
|
15
|
+
* It defines the basic structure of a smart filter block and provides the base implementation for
|
|
16
|
+
* managing the connection points.
|
|
17
|
+
*
|
|
18
|
+
* It enforces common behavior for all smart filter blocks.
|
|
19
|
+
*/
|
|
20
|
+
export declare abstract class BaseBlock implements ICommandOwner {
|
|
21
|
+
readonly disableOptimization: boolean;
|
|
22
|
+
protected static _alreadyVisitedBlocks: Set<BaseBlock>;
|
|
23
|
+
/**
|
|
24
|
+
* The class name of the block.
|
|
25
|
+
*/
|
|
26
|
+
static ClassName: string;
|
|
27
|
+
/**
|
|
28
|
+
* The smart filter the block belongs to.
|
|
29
|
+
*/
|
|
30
|
+
readonly smartFilter: SmartFilter;
|
|
31
|
+
/**
|
|
32
|
+
* Global unique id of the block (This is unique for the current session).
|
|
33
|
+
*/
|
|
34
|
+
readonly uniqueId: number;
|
|
35
|
+
/**
|
|
36
|
+
* The name of the block. This is used to identify the block in the smart filter or in debug.
|
|
37
|
+
*/
|
|
38
|
+
readonly name: string;
|
|
39
|
+
/**
|
|
40
|
+
* User provided comments about the block. It can be used to document the block.
|
|
41
|
+
*/
|
|
42
|
+
comments: Nullable<string>;
|
|
43
|
+
private readonly _inputs;
|
|
44
|
+
private readonly _outputs;
|
|
45
|
+
/**
|
|
46
|
+
* Instantiates a new block.
|
|
47
|
+
* @param smartFilter - Defines the smart filter the block belongs to
|
|
48
|
+
* @param name - Defines the name of the block
|
|
49
|
+
* @param disableOptimization - Defines if the block is optimizable or not
|
|
50
|
+
*/
|
|
51
|
+
constructor(smartFilter: SmartFilter, name: string, disableOptimization?: boolean);
|
|
52
|
+
/**
|
|
53
|
+
* Returns the inputs connection points of the current block.
|
|
54
|
+
*/
|
|
55
|
+
get inputs(): ReadonlyArray<ConnectionPoint>;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the outputs connection points of the current block.
|
|
58
|
+
*/
|
|
59
|
+
get outputs(): ReadonlyArray<ConnectionPoint>;
|
|
60
|
+
/**
|
|
61
|
+
* Returns if the block is an input block.
|
|
62
|
+
*/
|
|
63
|
+
get isInput(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Returns if the block is an output block.
|
|
66
|
+
*/
|
|
67
|
+
get isOutput(): boolean;
|
|
68
|
+
/**
|
|
69
|
+
* @returns the class name of the block
|
|
70
|
+
*/
|
|
71
|
+
getClassName(): string;
|
|
72
|
+
/**
|
|
73
|
+
* Checks if the block is an "ancestor" of another giving block.
|
|
74
|
+
* @param block - Defines the block to check against
|
|
75
|
+
* @returns True if the block is an ancestor of the given block, otherwise false
|
|
76
|
+
*/
|
|
77
|
+
isAnAncestorOf(block: BaseBlock): boolean;
|
|
78
|
+
protected _visitInputs<T extends object>(extraData: T, callback: BlockVisitor<T>, alreadyVisited: Set<BaseBlock>): void;
|
|
79
|
+
/**
|
|
80
|
+
* Visits the block and its inputs recursively.
|
|
81
|
+
* When starting from the smart filter output block, this will visit all the blocks in the smart filter.
|
|
82
|
+
* Note that it's a depth first visit: the callback is called on the block AFTER visiting its inputs.
|
|
83
|
+
* @param extraData - The extra data to pass to the callback
|
|
84
|
+
* @param callback - The callback to call on each block
|
|
85
|
+
* @param alreadyVisitedBlocks - Defines the set of blocks already visited (if not provided, a new set will be created)
|
|
86
|
+
*/
|
|
87
|
+
visit<T extends object>(extraData: T, callback: BlockVisitor<T>, alreadyVisitedBlocks?: Set<BaseBlock>): void;
|
|
88
|
+
/**
|
|
89
|
+
* Finds the input connection point with the given name.
|
|
90
|
+
* @param name - Name of the input to find
|
|
91
|
+
* @returns The connection point with the given name or null if not found
|
|
92
|
+
*/
|
|
93
|
+
findInput<U extends ConnectionPointType>(name: string): Nullable<ConnectionPoint<U>>;
|
|
94
|
+
/**
|
|
95
|
+
* Disconnects the block from the graph.
|
|
96
|
+
* @param _disconnectedConnections - Stores the connections that have been broken in the process. You can reconnect them later if needed.
|
|
97
|
+
*/
|
|
98
|
+
disconnectFromGraph(_disconnectedConnections?: [ConnectionPoint, ConnectionPoint][]): void;
|
|
99
|
+
/**
|
|
100
|
+
* Prepares the block for runtime.
|
|
101
|
+
* This is called by the smart filter just before creating the smart filter runtime, and by the optimizer.
|
|
102
|
+
*/
|
|
103
|
+
prepareForRuntime(): void;
|
|
104
|
+
/**
|
|
105
|
+
* Propagates the runtime data - telling all outputs to propagate their runtime data forward through the graph
|
|
106
|
+
*/
|
|
107
|
+
propagateRuntimeData(): void;
|
|
108
|
+
/**
|
|
109
|
+
* Generates the commands needed to execute the block at runtime and gathers promises for initialization work
|
|
110
|
+
* @param initializationData - The initialization data to use
|
|
111
|
+
* @param _finalOutput - Defines if the block is the final output of the smart filter
|
|
112
|
+
*/
|
|
113
|
+
generateCommandsAndGatherInitPromises(initializationData: InitializationData, _finalOutput: boolean): void;
|
|
114
|
+
/**
|
|
115
|
+
* Disconnects all the inputs and outputs from the Block.
|
|
116
|
+
*/
|
|
117
|
+
disconnect(): void;
|
|
118
|
+
/**
|
|
119
|
+
* Registers a new input connection point in the block which must have a connection before the graph can be used.
|
|
120
|
+
* @param name - Defines the name of the input connection point
|
|
121
|
+
* @param type - Defines the type of the input connection point
|
|
122
|
+
* @param defaultValue - Defines the optional default value of the input connection point to use if not connection is made
|
|
123
|
+
* @returns The new ConnectionPoint
|
|
124
|
+
* @internal
|
|
125
|
+
*/
|
|
126
|
+
_registerInput<U extends ConnectionPointType>(name: string, type: U, defaultValue?: Nullable<RuntimeData<U>>): ConnectionPoint<U>;
|
|
127
|
+
/**
|
|
128
|
+
* Registers a new input connection point in the block which doesn't require a connection because it has a default value.
|
|
129
|
+
* @param name - Defines the name of the input connection point
|
|
130
|
+
* @param type - Defines the type of the input connection point
|
|
131
|
+
* @param defaultValue - Defines the default value to use if nothing is connected to this connection point
|
|
132
|
+
* @returns The new ConnectionPointWithDefault
|
|
133
|
+
* @internal
|
|
134
|
+
*/
|
|
135
|
+
_registerOptionalInput<U extends ConnectionPointType>(name: string, type: U, defaultValue: RuntimeData<U>): ConnectionPointWithDefault<U>;
|
|
136
|
+
/**
|
|
137
|
+
* Registers a new output connection point in the block.
|
|
138
|
+
* @param name - Defines the name of the output connection point
|
|
139
|
+
* @param type - Defines the type of the output connection point
|
|
140
|
+
* @returns The new output connection point
|
|
141
|
+
* @internal
|
|
142
|
+
*/
|
|
143
|
+
_registerOutput<U extends ConnectionPointType>(name: string, type: U): ConnectionPoint<U>;
|
|
144
|
+
/**
|
|
145
|
+
* 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.
|
|
146
|
+
* @param name - Defines the name of the output connection point
|
|
147
|
+
* @param type - Defines the type of the output connection point
|
|
148
|
+
* @param initialValue - Defines the initial value of the output connection point
|
|
149
|
+
* @returns The new output connection point with a default value
|
|
150
|
+
* @internal
|
|
151
|
+
*/
|
|
152
|
+
_registerOutputWithDefault<U extends ConnectionPointType>(name: string, type: U, initialValue: RuntimeData<U>): ConnectionPointWithDefault<U>;
|
|
153
|
+
/**
|
|
154
|
+
* Gets the required RuntimeData for the given input, throwing with a clear message if it is null
|
|
155
|
+
* @param input - The input to get the runtime data for
|
|
156
|
+
* @returns The runtimeData or throws if it was undefined
|
|
157
|
+
*/
|
|
158
|
+
protected _confirmRuntimeDataSupplied<U extends ConnectionPointType = ConnectionPointType>(input: ConnectionPoint<U>): RuntimeData<U>;
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=baseBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseBlock.d.ts","sourceRoot":"","sources":["../../src/blocks/baseBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK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AAC,EACP,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,GAC7B,0BAA0B,CAAC,CAAC,CAAC;IAMhC;;;;;;OAMG;IACI,eAAe,CAAC,CAAC,SAAS,mBAAmB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC;IAMhG;;;;;;;OAOG;IACI,0BAA0B,CAAC,CAAC,SAAS,mBAAmB,EAC3D,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,CAAC,EACP,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,GAC7B,0BAA0B,CAAC,CAAC,CAAC;IAMhC;;;;OAIG;IACH,SAAS,CAAC,2BAA2B,CAAC,CAAC,SAAS,mBAAmB,GAAG,mBAAmB,EACrF,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,WAAW,CAAC,CAAC,CAAC;CAUpB"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { UniqueIdGenerator } from "@babylonjs/core/Misc/uniqueIdGenerator.js";
|
|
2
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
3
|
+
import { ConnectionPoint } from "../connection/connectionPoint.js";
|
|
4
|
+
import { ConnectionPointWithDefault } from "../connection/connectionPointWithDefault.js";
|
|
5
|
+
import { ConnectionPointDirection } from "../connection/connectionPointDirection.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
|
+
* Instantiates a new block.
|
|
17
|
+
* @param smartFilter - Defines the smart filter the block belongs to
|
|
18
|
+
* @param name - Defines the name of the block
|
|
19
|
+
* @param disableOptimization - Defines if the block is optimizable or not
|
|
20
|
+
*/
|
|
21
|
+
constructor(smartFilter, name, disableOptimization = false) {
|
|
22
|
+
this.disableOptimization = disableOptimization;
|
|
23
|
+
/**
|
|
24
|
+
* User provided comments about the block. It can be used to document the block.
|
|
25
|
+
*/
|
|
26
|
+
this.comments = null;
|
|
27
|
+
this._inputs = [];
|
|
28
|
+
this._outputs = [];
|
|
29
|
+
this.uniqueId = UniqueIdGenerator.UniqueId;
|
|
30
|
+
this.name = name;
|
|
31
|
+
this.smartFilter = smartFilter;
|
|
32
|
+
// Register the block in the smart filter
|
|
33
|
+
smartFilter.registerBlock(this);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns the inputs connection points of the current block.
|
|
37
|
+
*/
|
|
38
|
+
get inputs() {
|
|
39
|
+
return this._inputs;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns the outputs connection points of the current block.
|
|
43
|
+
*/
|
|
44
|
+
get outputs() {
|
|
45
|
+
return this._outputs;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Returns if the block is an input block.
|
|
49
|
+
*/
|
|
50
|
+
get isInput() {
|
|
51
|
+
return this._inputs.length === 0;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns if the block is an output block.
|
|
55
|
+
*/
|
|
56
|
+
get isOutput() {
|
|
57
|
+
return this._outputs.length === 0;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* @returns the class name of the block
|
|
61
|
+
*/
|
|
62
|
+
getClassName() {
|
|
63
|
+
// 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
|
|
64
|
+
return this.constructor.ClassName;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Checks if the block is an "ancestor" of another giving block.
|
|
68
|
+
* @param block - Defines the block to check against
|
|
69
|
+
* @returns True if the block is an ancestor of the given block, otherwise false
|
|
70
|
+
*/
|
|
71
|
+
isAnAncestorOf(block) {
|
|
72
|
+
for (const output of this._outputs) {
|
|
73
|
+
if (!output.endpoints.length) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
for (const endpoint of output.endpoints) {
|
|
77
|
+
if (endpoint.ownerBlock === block) {
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
if (endpoint.ownerBlock.isAnAncestorOf(block)) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
_visitInputs(extraData, callback, alreadyVisited) {
|
|
88
|
+
for (const input of this.inputs) {
|
|
89
|
+
if (!input.connectedTo) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const block = input.connectedTo.ownerBlock;
|
|
93
|
+
block.visit(extraData, callback, alreadyVisited);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Visits the block and its inputs recursively.
|
|
98
|
+
* When starting from the smart filter output block, this will visit all the blocks in the smart filter.
|
|
99
|
+
* Note that it's a depth first visit: the callback is called on the block AFTER visiting its inputs.
|
|
100
|
+
* @param extraData - The extra data to pass to the callback
|
|
101
|
+
* @param callback - The callback to call on each block
|
|
102
|
+
* @param alreadyVisitedBlocks - Defines the set of blocks already visited (if not provided, a new set will be created)
|
|
103
|
+
*/
|
|
104
|
+
visit(extraData, callback, alreadyVisitedBlocks) {
|
|
105
|
+
if (!alreadyVisitedBlocks) {
|
|
106
|
+
alreadyVisitedBlocks = BaseBlock._alreadyVisitedBlocks;
|
|
107
|
+
alreadyVisitedBlocks.clear();
|
|
108
|
+
}
|
|
109
|
+
if (!alreadyVisitedBlocks.has(this)) {
|
|
110
|
+
alreadyVisitedBlocks.add(this);
|
|
111
|
+
this._visitInputs(extraData, callback, alreadyVisitedBlocks);
|
|
112
|
+
callback(this, extraData);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Finds the input connection point with the given name.
|
|
117
|
+
* @param name - Name of the input to find
|
|
118
|
+
* @returns The connection point with the given name or null if not found
|
|
119
|
+
*/
|
|
120
|
+
findInput(name) {
|
|
121
|
+
for (const input of this._inputs) {
|
|
122
|
+
if (input.name === name) {
|
|
123
|
+
return input;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Disconnects the block from the graph.
|
|
130
|
+
* @param _disconnectedConnections - Stores the connections that have been broken in the process. You can reconnect them later if needed.
|
|
131
|
+
*/
|
|
132
|
+
disconnectFromGraph(_disconnectedConnections) { }
|
|
133
|
+
/**
|
|
134
|
+
* Prepares the block for runtime.
|
|
135
|
+
* This is called by the smart filter just before creating the smart filter runtime, and by the optimizer.
|
|
136
|
+
*/
|
|
137
|
+
prepareForRuntime() { }
|
|
138
|
+
/**
|
|
139
|
+
* Propagates the runtime data - telling all outputs to propagate their runtime data forward through the graph
|
|
140
|
+
*/
|
|
141
|
+
propagateRuntimeData() {
|
|
142
|
+
for (const output of this._outputs) {
|
|
143
|
+
output.propagateRuntimeData();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Generates the commands needed to execute the block at runtime and gathers promises for initialization work
|
|
148
|
+
* @param initializationData - The initialization data to use
|
|
149
|
+
* @param _finalOutput - Defines if the block is the final output of the smart filter
|
|
150
|
+
*/
|
|
151
|
+
generateCommandsAndGatherInitPromises(initializationData, _finalOutput) {
|
|
152
|
+
var _a;
|
|
153
|
+
// Check if any inputs are Textures which aren't yet ready, and if so, ensure init waits for them to be ready
|
|
154
|
+
for (const input of this._inputs) {
|
|
155
|
+
if (input.type === ConnectionPointType.Texture) {
|
|
156
|
+
const texture = (_a = input.runtimeData) === null || _a === void 0 ? void 0 : _a.value;
|
|
157
|
+
if (texture && !texture.isReady()) {
|
|
158
|
+
const internalTexture = texture.getInternalTexture();
|
|
159
|
+
if (internalTexture) {
|
|
160
|
+
const textureReadyPromise = new Promise((resolve, reject) => {
|
|
161
|
+
internalTexture.onLoadedObservable.add(() => {
|
|
162
|
+
resolve();
|
|
163
|
+
});
|
|
164
|
+
internalTexture.onErrorObservable.add((error) => {
|
|
165
|
+
reject(error);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
initializationData.initializationPromises.push(textureReadyPromise);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Disconnects all the inputs and outputs from the Block.
|
|
176
|
+
*/
|
|
177
|
+
disconnect() {
|
|
178
|
+
var _a;
|
|
179
|
+
// Detach inputs
|
|
180
|
+
for (const input of this._inputs) {
|
|
181
|
+
(_a = input.connectedTo) === null || _a === void 0 ? void 0 : _a.disconnectFrom(input);
|
|
182
|
+
}
|
|
183
|
+
// Detach outputs
|
|
184
|
+
for (const output of this._outputs) {
|
|
185
|
+
output.disconnectAllEndpoints();
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Registers a new input connection point in the block which must have a connection before the graph can be used.
|
|
190
|
+
* @param name - Defines the name of the input connection point
|
|
191
|
+
* @param type - Defines the type of the input connection point
|
|
192
|
+
* @param defaultValue - Defines the optional default value of the input connection point to use if not connection is made
|
|
193
|
+
* @returns The new ConnectionPoint
|
|
194
|
+
* @internal
|
|
195
|
+
*/
|
|
196
|
+
_registerInput(name, type, defaultValue = null) {
|
|
197
|
+
const input = new ConnectionPoint(name, this, type, ConnectionPointDirection.Input, defaultValue);
|
|
198
|
+
this._inputs.push(input);
|
|
199
|
+
return input;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Registers a new input connection point in the block which doesn't require a connection because it has a default value.
|
|
203
|
+
* @param name - Defines the name of the input connection point
|
|
204
|
+
* @param type - Defines the type of the input connection point
|
|
205
|
+
* @param defaultValue - Defines the default value to use if nothing is connected to this connection point
|
|
206
|
+
* @returns The new ConnectionPointWithDefault
|
|
207
|
+
* @internal
|
|
208
|
+
*/
|
|
209
|
+
_registerOptionalInput(name, type, defaultValue) {
|
|
210
|
+
const input = new ConnectionPointWithDefault(name, this, type, ConnectionPointDirection.Input, defaultValue);
|
|
211
|
+
this._inputs.push(input);
|
|
212
|
+
return input;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Registers a new output connection point in the block.
|
|
216
|
+
* @param name - Defines the name of the output connection point
|
|
217
|
+
* @param type - Defines the type of the output connection point
|
|
218
|
+
* @returns The new output connection point
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
_registerOutput(name, type) {
|
|
222
|
+
const output = new ConnectionPoint(name, this, type, ConnectionPointDirection.Output);
|
|
223
|
+
this._outputs.push(output);
|
|
224
|
+
return output;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* 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.
|
|
228
|
+
* @param name - Defines the name of the output connection point
|
|
229
|
+
* @param type - Defines the type of the output connection point
|
|
230
|
+
* @param initialValue - Defines the initial value of the output connection point
|
|
231
|
+
* @returns The new output connection point with a default value
|
|
232
|
+
* @internal
|
|
233
|
+
*/
|
|
234
|
+
_registerOutputWithDefault(name, type, initialValue) {
|
|
235
|
+
const output = new ConnectionPointWithDefault(name, this, type, ConnectionPointDirection.Output, initialValue);
|
|
236
|
+
this._outputs.push(output);
|
|
237
|
+
return output;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Gets the required RuntimeData for the given input, throwing with a clear message if it is null
|
|
241
|
+
* @param input - The input to get the runtime data for
|
|
242
|
+
* @returns The runtimeData or throws if it was undefined
|
|
243
|
+
*/
|
|
244
|
+
_confirmRuntimeDataSupplied(input) {
|
|
245
|
+
if (!input.runtimeData) {
|
|
246
|
+
throw new Error(`The ${ConnectionPointType[input.type]} input named "${input.name}" is missing for the ${this.getClassName()} named "${this.name}"`);
|
|
247
|
+
}
|
|
248
|
+
return input.runtimeData;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
BaseBlock._alreadyVisitedBlocks = new Set();
|
|
252
|
+
/**
|
|
253
|
+
* The class name of the block.
|
|
254
|
+
*/
|
|
255
|
+
BaseBlock.ClassName = "BaseBlock";
|
|
256
|
+
//# sourceMappingURL=baseBlock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"baseBlock.js","sourceRoot":"","sources":["../../src/blocks/baseBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAE9E,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;AAQrF;;;;;;;GAOG;AACH,MAAM,OAAgB,SAAS;IA+B3B;;;;;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;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAW,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