@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,101 @@
|
|
|
1
|
+
import "@babylonjs/core/Engines/Extensions/engine.renderTarget.js";
|
|
2
|
+
import { ShaderRuntime } from "../runtime/shaderRuntime.js";
|
|
3
|
+
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
4
|
+
import { createCommand } from "../command/command.js";
|
|
5
|
+
import { DisableableBlock } from "./disableableBlock.js";
|
|
6
|
+
import { undecorateSymbol } from "../utils/shaderCodeUtils.js";
|
|
7
|
+
/**
|
|
8
|
+
* This is the base class for all shader blocks.
|
|
9
|
+
*
|
|
10
|
+
* It contains the redundant part of wrapping a shader for a full screen pass.
|
|
11
|
+
*
|
|
12
|
+
* The only required function to implement is the bind function.
|
|
13
|
+
*/
|
|
14
|
+
export class ShaderBlock extends DisableableBlock {
|
|
15
|
+
/**
|
|
16
|
+
* Gets the texture ratio of the output texture.
|
|
17
|
+
*/
|
|
18
|
+
get textureRatio() {
|
|
19
|
+
return this._textureRatio;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Sets the texture ratio of the output texture.
|
|
23
|
+
*/
|
|
24
|
+
set textureRatio(value) {
|
|
25
|
+
this._textureRatio = value;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Disconnects the block from the graph.
|
|
29
|
+
* @param disconnectedConnections - Stores the connections that have been broken in the process. You can reconnect them later if needed.
|
|
30
|
+
*/
|
|
31
|
+
disconnectFromGraph(disconnectedConnections) {
|
|
32
|
+
const input = this._getConnectionForMainInputTexture();
|
|
33
|
+
for (const endpoint of this.output.endpoints) {
|
|
34
|
+
disconnectedConnections === null || disconnectedConnections === void 0 ? void 0 : disconnectedConnections.push([endpoint, this.output]);
|
|
35
|
+
input.connectTo(endpoint);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
_getConnectionForMainInputTexture() {
|
|
39
|
+
const mainInputTextureName = this.getShaderProgram().fragment.mainInputTexture;
|
|
40
|
+
if (!mainInputTextureName) {
|
|
41
|
+
throw `The block named "${this.name}" does not have a main input texture defined!`;
|
|
42
|
+
}
|
|
43
|
+
const mainInputTexture = this.findInput(undecorateSymbol(mainInputTextureName));
|
|
44
|
+
if (!mainInputTexture || !mainInputTexture.connectedTo) {
|
|
45
|
+
throw `The main input texture "${mainInputTextureName}" of block named "${this.name}" is not connected!`;
|
|
46
|
+
}
|
|
47
|
+
return mainInputTexture.connectedTo;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Instantiates a new block.
|
|
51
|
+
* @param smartFilter - Defines the smart filter the block belongs to
|
|
52
|
+
* @param name - Defines the name of the block
|
|
53
|
+
* @param disableOptimization - Defines if the block should not be optimized (default: false)
|
|
54
|
+
*/
|
|
55
|
+
constructor(smartFilter, name, disableOptimization = false) {
|
|
56
|
+
super(smartFilter, name, disableOptimization);
|
|
57
|
+
/**
|
|
58
|
+
* The output connection point of the block.
|
|
59
|
+
*/
|
|
60
|
+
this.output = this._registerOutput("output", ConnectionPointType.Texture);
|
|
61
|
+
this._textureRatio = 1;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Gets the shader program to use to render the block.
|
|
65
|
+
* @returns The shader program to use to render the block
|
|
66
|
+
*/
|
|
67
|
+
getShaderProgram() {
|
|
68
|
+
return this.constructor.ShaderCode;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Generates the commands needed to execute the block at runtime and gathers promises for initialization work
|
|
72
|
+
* @param initializationData - The initialization data to use
|
|
73
|
+
* @param finalOutput - Defines if the block is the final output of the smart filter
|
|
74
|
+
*/
|
|
75
|
+
generateCommandsAndGatherInitPromises(initializationData, finalOutput) {
|
|
76
|
+
const runtime = initializationData.runtime;
|
|
77
|
+
const shaderBlockRuntime = new ShaderRuntime(runtime.effectRenderer, this.getShaderProgram(), this.getShaderBinding());
|
|
78
|
+
initializationData.initializationPromises.push(shaderBlockRuntime.onReadyAsync);
|
|
79
|
+
runtime.registerResource(shaderBlockRuntime);
|
|
80
|
+
if (finalOutput) {
|
|
81
|
+
runtime.registerCommand(createCommand(`${this.getClassName()}.renderToCanvas`, this, () => {
|
|
82
|
+
shaderBlockRuntime.renderToCanvas();
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const rtt = this.output.runtimeData && this.output.runtimeData.value.renderTarget;
|
|
87
|
+
if (!rtt) {
|
|
88
|
+
throw new Error("ShaderBlock does not have a render target texture.");
|
|
89
|
+
}
|
|
90
|
+
runtime.registerCommand(createCommand(`${this.getClassName()}.render`, this, () => {
|
|
91
|
+
shaderBlockRuntime.renderToTexture(rtt);
|
|
92
|
+
}));
|
|
93
|
+
}
|
|
94
|
+
super.generateCommandsAndGatherInitPromises(initializationData, finalOutput);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The class name of the block.
|
|
99
|
+
*/
|
|
100
|
+
ShaderBlock.ClassName = "ShaderBlock";
|
|
101
|
+
//# sourceMappingURL=sha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AAC,CACL,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,MAAM,GAAG,GACL,IAAI,CAAC,MAAM,CAAC,WAAW,IAAK,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,KAAiC,CAAC,YAAY,CAAC;YACvG,IAAI,CAAC,GAAG,EAAE,CAAC;gBACP,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;YAC1E,CAAC;YAED,OAAO,CAAC,eAAe,CACnB,aAAa,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE;gBACtD,kBAAkB,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;YAC5C,CAAC,CAAC,CACL,CAAC;QACN,CAAC;QAED,KAAK,CAAC,qCAAqC,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAC;IACjF,CAAC;;AA1HD;;GAEG;AACoB,qBAAS,GAAG,aAAa,AAAhB,CAAiB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the owner of a command.
|
|
3
|
+
* In practice, it will mostly be a block, the smart filter or a tool injecting commands.
|
|
4
|
+
*/
|
|
5
|
+
export interface ICommandOwner {
|
|
6
|
+
/**
|
|
7
|
+
* The friendly name of the owner.
|
|
8
|
+
*/
|
|
9
|
+
readonly name: string;
|
|
10
|
+
/**
|
|
11
|
+
* Gets the class name of the owner.
|
|
12
|
+
*/
|
|
13
|
+
getClassName(): string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents a the action of a @see Command. This is what will be executed during a command buffer execution.
|
|
17
|
+
*/
|
|
18
|
+
export type CommandAction = () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Represents a command to execute.
|
|
21
|
+
*
|
|
22
|
+
* A command contains a function that will be executed at runtime by the smart filter.
|
|
23
|
+
*
|
|
24
|
+
* It also contains the owner of the command for debugging purposes.
|
|
25
|
+
*/
|
|
26
|
+
export type Command = {
|
|
27
|
+
/**
|
|
28
|
+
* The friendly name of the command.
|
|
29
|
+
*/
|
|
30
|
+
readonly name: string;
|
|
31
|
+
/**
|
|
32
|
+
* The owner of the command.
|
|
33
|
+
* In practice, it will mostly be a block, the smart filter or a tool injecting commands.
|
|
34
|
+
*/
|
|
35
|
+
readonly owner: ICommandOwner;
|
|
36
|
+
/**
|
|
37
|
+
* Defines the action to execute.
|
|
38
|
+
*/
|
|
39
|
+
readonly action: CommandAction;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new command.
|
|
43
|
+
* @param name - The friendly name of the command
|
|
44
|
+
* @param owner - The owner of the command
|
|
45
|
+
* @param action - The action to execute when the command is executed
|
|
46
|
+
* @returns The new command
|
|
47
|
+
*/
|
|
48
|
+
export declare function createCommand(name: string, owner: ICommandOwner, action: CommandAction): Command;
|
|
49
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/command/command.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,YAAY,IAAI,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,MAAM,OAAO,GAAG;IAClB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAClC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO,CAMhG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a new command.
|
|
3
|
+
* @param name - The friendly name of the command
|
|
4
|
+
* @param owner - The owner of the command
|
|
5
|
+
* @param action - The action to execute when the command is executed
|
|
6
|
+
* @returns The new command
|
|
7
|
+
*/
|
|
8
|
+
export function createCommand(name, owner, action) {
|
|
9
|
+
return {
|
|
10
|
+
name,
|
|
11
|
+
owner,
|
|
12
|
+
action,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/command/command.ts"],"names":[],"mappings":"AA8CA;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,KAAoB,EAAE,MAAqB;IACnF,OAAO;QACH,IAAI;QACJ,KAAK;QACL,MAAM;KACT,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Command } from "./command";
|
|
2
|
+
/**
|
|
3
|
+
* Represents the action to run when calling `visitCommands` on a @see CommandBuffer.
|
|
4
|
+
*/
|
|
5
|
+
export type CommandsVisitor = (command: Command) => void;
|
|
6
|
+
/**
|
|
7
|
+
* A command buffer is a list of commands to execute.
|
|
8
|
+
* This is used to store the list of tasks the current smart filter needs to execute.
|
|
9
|
+
*/
|
|
10
|
+
export declare class CommandBuffer {
|
|
11
|
+
private readonly _commands;
|
|
12
|
+
/**
|
|
13
|
+
* Creates a new command buffer.
|
|
14
|
+
* @param args - the list of commands to add to the command buffer
|
|
15
|
+
*/
|
|
16
|
+
constructor(...args: Command[]);
|
|
17
|
+
/**
|
|
18
|
+
* Adds a command to the command buffer.
|
|
19
|
+
* @param command - the command to add
|
|
20
|
+
*/
|
|
21
|
+
push(command: Command): void;
|
|
22
|
+
/**
|
|
23
|
+
* Clears the command buffer and empty the list of commands.
|
|
24
|
+
*/
|
|
25
|
+
clear(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Visits all the commands in the command buffer.
|
|
28
|
+
* @param commandVisitor - The action to execute on each command
|
|
29
|
+
*/
|
|
30
|
+
visitCommands(commandVisitor: CommandsVisitor): void;
|
|
31
|
+
/**
|
|
32
|
+
* Execute all the commands in the command buffer.
|
|
33
|
+
*/
|
|
34
|
+
execute(): void;
|
|
35
|
+
/**
|
|
36
|
+
* Dispose the resources associated to the command buffer.
|
|
37
|
+
*/
|
|
38
|
+
dispose(): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=commandBuffer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandBuffer.d.ts","sourceRoot":"","sources":["../../src/command/commandBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;AAUzD;;;GAGG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAE3C;;;OAGG;gBACS,GAAG,IAAI,EAAE,OAAO,EAAE;IAM9B;;;OAGG;IACI,IAAI,CAAC,OAAO,EAAE,OAAO;IAI5B;;OAEG;IACI,KAAK;IAIZ;;;OAGG;IACI,aAAa,CAAC,cAAc,EAAE,eAAe,GAAG,IAAI;IAM3D;;OAEG;IACI,OAAO;IAId;;OAEG;IACI,OAAO;CAGjB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @see CommandsVisitor used to execute the commands of a @see CommandBuffer.
|
|
3
|
+
* @param command - The command to execute.
|
|
4
|
+
*/
|
|
5
|
+
function executeCommandsVisitor(command) {
|
|
6
|
+
command.action();
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A command buffer is a list of commands to execute.
|
|
10
|
+
* This is used to store the list of tasks the current smart filter needs to execute.
|
|
11
|
+
*/
|
|
12
|
+
export class CommandBuffer {
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new command buffer.
|
|
15
|
+
* @param args - the list of commands to add to the command buffer
|
|
16
|
+
*/
|
|
17
|
+
constructor(...args) {
|
|
18
|
+
this._commands = [];
|
|
19
|
+
for (const command of args) {
|
|
20
|
+
this.push(command);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Adds a command to the command buffer.
|
|
25
|
+
* @param command - the command to add
|
|
26
|
+
*/
|
|
27
|
+
push(command) {
|
|
28
|
+
this._commands.push(command);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Clears the command buffer and empty the list of commands.
|
|
32
|
+
*/
|
|
33
|
+
clear() {
|
|
34
|
+
this._commands.length = 0;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Visits all the commands in the command buffer.
|
|
38
|
+
* @param commandVisitor - The action to execute on each command
|
|
39
|
+
*/
|
|
40
|
+
visitCommands(commandVisitor) {
|
|
41
|
+
for (const command of this._commands) {
|
|
42
|
+
commandVisitor(command);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Execute all the commands in the command buffer.
|
|
47
|
+
*/
|
|
48
|
+
execute() {
|
|
49
|
+
this.visitCommands(executeCommandsVisitor);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Dispose the resources associated to the command buffer.
|
|
53
|
+
*/
|
|
54
|
+
dispose() {
|
|
55
|
+
this.clear();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=commandBuffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandBuffer.js","sourceRoot":"","sources":["../../src/command/commandBuffer.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,SAAS,sBAAsB,CAAC,OAAgB;IAC5C,OAAO,CAAC,MAAM,EAAE,CAAC;AACrB,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,aAAa;IAGtB;;;OAGG;IACH,YAAY,GAAG,IAAe;QANb,cAAS,GAAc,EAAE,CAAC;QAOvC,KAAK,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;YACzB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,IAAI,CAAC,OAAgB;QACxB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,KAAK;QACR,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,aAAa,CAAC,cAA+B;QAChD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC5B,CAAC;IACL,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,aAAa,CAAC,sBAAsB,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;CACJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CommandBuffer } from "./commandBuffer";
|
|
2
|
+
/**
|
|
3
|
+
* Logs all the commands associated to a command buffer.
|
|
4
|
+
* @param commandBuffer - The command buffer to log
|
|
5
|
+
*/
|
|
6
|
+
export declare function logCommands(commandBuffer: Readonly<CommandBuffer>): void;
|
|
7
|
+
//# sourceMappingURL=commandBufferDebugger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandBufferDebugger.d.ts","sourceRoot":"","sources":["../../src/command/commandBufferDebugger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,QAAQ,CAAC,aAAa,CAAC,QAMjE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logs all the commands associated to a command buffer.
|
|
3
|
+
* @param commandBuffer - The command buffer to log
|
|
4
|
+
*/
|
|
5
|
+
export function logCommands(commandBuffer) {
|
|
6
|
+
console.log("----- Command buffer commands -----");
|
|
7
|
+
commandBuffer.visitCommands((command) => {
|
|
8
|
+
console.log(` Owner: ${command.owner.getClassName()} (${command.owner.name}) - Command: ${command.name}`);
|
|
9
|
+
});
|
|
10
|
+
console.log("-----------------------------------");
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=commandBufferDebugger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandBufferDebugger.js","sourceRoot":"","sources":["../../src/command/commandBufferDebugger.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,aAAsC;IAC9D,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;IACnD,aAAa,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,EAAE;QACpC,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,OAAO,CAAC,KAAK,CAAC,IAAI,gBAAgB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAC/G,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { Nullable } from "@babylonjs/core/types";
|
|
2
|
+
import { ConnectionPointCompatibilityState } from "./connectionPointCompatibilityState.js";
|
|
3
|
+
import { ConnectionPointDirection } from "./connectionPointDirection.js";
|
|
4
|
+
import type { BaseBlock } from "../blocks/baseBlock";
|
|
5
|
+
import type { ConnectionPointType, ConnectionPointValue } from "./connectionPointType";
|
|
6
|
+
import type { StrongRef } from "../runtime/strongRef";
|
|
7
|
+
/**
|
|
8
|
+
* This represents a strong reference to the data being passed through a connection point.
|
|
9
|
+
*/
|
|
10
|
+
export type RuntimeData<U extends ConnectionPointType> = StrongRef<ConnectionPointValue<U>>;
|
|
11
|
+
/**
|
|
12
|
+
* This defines a connection point.
|
|
13
|
+
*
|
|
14
|
+
* A connection point is any input/output of a block.
|
|
15
|
+
* It can be linked to another connection point following some rules:
|
|
16
|
+
* - The type of the connection point must be compatible with the other one.
|
|
17
|
+
* - The direction of the connection point must be different from the other one.
|
|
18
|
+
* - The connection cannot create a cycle in the list of blocks.
|
|
19
|
+
* The relationship is always 1:N for input:output
|
|
20
|
+
*/
|
|
21
|
+
export declare class ConnectionPoint<U extends ConnectionPointType = ConnectionPointType> {
|
|
22
|
+
/**
|
|
23
|
+
* The name of the connection point.
|
|
24
|
+
* This is used to identify the connection point inside a block.
|
|
25
|
+
*/
|
|
26
|
+
readonly name: string;
|
|
27
|
+
/**
|
|
28
|
+
* The type of the connection point (float, texture, etc.)
|
|
29
|
+
*/
|
|
30
|
+
readonly type: U;
|
|
31
|
+
/**
|
|
32
|
+
* The direction of the connection point (input or output)
|
|
33
|
+
*/
|
|
34
|
+
readonly direction: ConnectionPointDirection;
|
|
35
|
+
/**
|
|
36
|
+
* The smart filter block the connection point belongs to.
|
|
37
|
+
*/
|
|
38
|
+
readonly ownerBlock: BaseBlock;
|
|
39
|
+
/**
|
|
40
|
+
* User provided name for the connection point.
|
|
41
|
+
*/
|
|
42
|
+
displayName: Nullable<string>;
|
|
43
|
+
/**
|
|
44
|
+
* The @see RunTimeData used during the init phase to reference the result of the previous block.
|
|
45
|
+
* Those are only used for input connection points.
|
|
46
|
+
* The previous block are "pushing" this in during the init stage.
|
|
47
|
+
*/
|
|
48
|
+
runtimeData: Nullable<RuntimeData<U>>;
|
|
49
|
+
/**
|
|
50
|
+
* The default runtimeData used when no connection is made to the connection point.
|
|
51
|
+
*/
|
|
52
|
+
readonly defaultRuntimeData: Nullable<RuntimeData<U>>;
|
|
53
|
+
private _connectedTo;
|
|
54
|
+
private _endpoints;
|
|
55
|
+
/**
|
|
56
|
+
* Create a new connection point.
|
|
57
|
+
* @param name - The name the connection point has in the block
|
|
58
|
+
* @param ownerBlock - The block the connection point belongs to
|
|
59
|
+
* @param type - The type of the connection point
|
|
60
|
+
* @param direction - The direction of the connection point
|
|
61
|
+
* @param defaultRuntimeData - The default runtime data to use when no connection is made to the connection point
|
|
62
|
+
*/
|
|
63
|
+
constructor(name: string, ownerBlock: BaseBlock, type: U, direction: ConnectionPointDirection, defaultRuntimeData?: Nullable<RuntimeData<U>>);
|
|
64
|
+
/**
|
|
65
|
+
* @returns the connection point this connection point is connected to.
|
|
66
|
+
* (the one on the other side of the connection)
|
|
67
|
+
* Only input connection points have a connected point which they received their value from.
|
|
68
|
+
* (Relation is always 1:N for input:output)
|
|
69
|
+
*/
|
|
70
|
+
get connectedTo(): Nullable<ConnectionPoint<U>>;
|
|
71
|
+
/**
|
|
72
|
+
* @returns the connection point this connection point is to.
|
|
73
|
+
* (the one on the other side of the connection)
|
|
74
|
+
* Only output connection points have a list of endpoints which they provide their value to.
|
|
75
|
+
* (Relation is always 1:N for input:output)
|
|
76
|
+
*/
|
|
77
|
+
get endpoints(): ReadonlyArray<ConnectionPoint<U>>;
|
|
78
|
+
/**
|
|
79
|
+
* Gets a state indicating if the current point can be connected to another point
|
|
80
|
+
* @param other - defines the other connection point
|
|
81
|
+
* @returns the compatibility state
|
|
82
|
+
*/
|
|
83
|
+
checkCompatibilityState(other: ConnectionPoint<U>): ConnectionPointCompatibilityState;
|
|
84
|
+
/**
|
|
85
|
+
* Checks if the connection point can be connected to another one.
|
|
86
|
+
* @param connectionPoint - The other connection point to check compatibility with
|
|
87
|
+
* @returns true if the connection point can be connected to the other one
|
|
88
|
+
*/
|
|
89
|
+
canConnectTo(connectionPoint: ConnectionPoint<U>): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Connect this connection point to another one.
|
|
92
|
+
* @param other - The other connection point to connect to
|
|
93
|
+
* @throws if the connection point cannot be connected to the other one
|
|
94
|
+
*/
|
|
95
|
+
connectTo(other: ConnectionPoint<U>): void;
|
|
96
|
+
/**
|
|
97
|
+
* Disconnects this point from one of his endpoint
|
|
98
|
+
* @param endpoint - defines the other connection point
|
|
99
|
+
*/
|
|
100
|
+
disconnectFrom(endpoint: ConnectionPoint<U>): void;
|
|
101
|
+
/**
|
|
102
|
+
* Disconnects this point from all its endpoints.
|
|
103
|
+
*/
|
|
104
|
+
disconnectAllEndpoints(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Propagates the current runtime data to all endpoints.
|
|
107
|
+
*/
|
|
108
|
+
propagateRuntimeData(): void;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=connectionPoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectionPoint.d.ts","sourceRoot":"","sources":["../../src/connection/connectionPoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACH,iCAAiC,EAEpC,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,mBAAmB,IAAI,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC;AAE5F;;;;;;;;;GASG;AACH,qBAAa,eAAe,CAAC,CAAC,SAAS,mBAAmB,GAAG,mBAAmB;IAC5E;;;OAGG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,SAAgB,IAAI,EAAE,CAAC,CA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ibilityState, getCompatibilityIssueMessage, } from "./connectionPointCompatibilityState.js";
|
|
2
|
+
import { ConnectionPointDirection } from "./connectionPointDirection.js";
|
|
3
|
+
/**
|
|
4
|
+
* This defines a connection point.
|
|
5
|
+
*
|
|
6
|
+
* A connection point is any input/output of a block.
|
|
7
|
+
* It can be linked to another connection point following some rules:
|
|
8
|
+
* - The type of the connection point must be compatible with the other one.
|
|
9
|
+
* - The direction of the connection point must be different from the other one.
|
|
10
|
+
* - The connection cannot create a cycle in the list of blocks.
|
|
11
|
+
* The relationship is always 1:N for input:output
|
|
12
|
+
*/
|
|
13
|
+
export class ConnectionPoint {
|
|
14
|
+
/**
|
|
15
|
+
* Create a new connection point.
|
|
16
|
+
* @param name - The name the connection point has in the block
|
|
17
|
+
* @param ownerBlock - The block the connection point belongs to
|
|
18
|
+
* @param type - The type of the connection point
|
|
19
|
+
* @param direction - The direction of the connection point
|
|
20
|
+
* @param defaultRuntimeData - The default runtime data to use when no connection is made to the connection point
|
|
21
|
+
*/
|
|
22
|
+
constructor(name, ownerBlock, type, direction, defaultRuntimeData = null) {
|
|
23
|
+
/**
|
|
24
|
+
* User provided name for the connection point.
|
|
25
|
+
*/
|
|
26
|
+
this.displayName = null;
|
|
27
|
+
/**
|
|
28
|
+
* The @see RunTimeData used during the init phase to reference the result of the previous block.
|
|
29
|
+
* Those are only used for input connection points.
|
|
30
|
+
* The previous block are "pushing" this in during the init stage.
|
|
31
|
+
*/
|
|
32
|
+
this.runtimeData = null;
|
|
33
|
+
/**
|
|
34
|
+
* The default runtimeData used when no connection is made to the connection point.
|
|
35
|
+
*/
|
|
36
|
+
this.defaultRuntimeData = null;
|
|
37
|
+
this._connectedTo = null;
|
|
38
|
+
this._endpoints = [];
|
|
39
|
+
this.name = name;
|
|
40
|
+
this.ownerBlock = ownerBlock;
|
|
41
|
+
this.type = type;
|
|
42
|
+
this.direction = direction;
|
|
43
|
+
this.defaultRuntimeData = defaultRuntimeData;
|
|
44
|
+
this.runtimeData = defaultRuntimeData;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @returns the connection point this connection point is connected to.
|
|
48
|
+
* (the one on the other side of the connection)
|
|
49
|
+
* Only input connection points have a connected point which they received their value from.
|
|
50
|
+
* (Relation is always 1:N for input:output)
|
|
51
|
+
*/
|
|
52
|
+
get connectedTo() {
|
|
53
|
+
return this._connectedTo;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* @returns the connection point this connection point is to.
|
|
57
|
+
* (the one on the other side of the connection)
|
|
58
|
+
* Only output connection points have a list of endpoints which they provide their value to.
|
|
59
|
+
* (Relation is always 1:N for input:output)
|
|
60
|
+
*/
|
|
61
|
+
get endpoints() {
|
|
62
|
+
return this._endpoints;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Gets a state indicating if the current point can be connected to another point
|
|
66
|
+
* @param other - defines the other connection point
|
|
67
|
+
* @returns the compatibility state
|
|
68
|
+
*/
|
|
69
|
+
checkCompatibilityState(other) {
|
|
70
|
+
// Only connects output to input
|
|
71
|
+
if (this.direction === ConnectionPointDirection.Input) {
|
|
72
|
+
return other.checkCompatibilityState(this);
|
|
73
|
+
}
|
|
74
|
+
// Check types
|
|
75
|
+
if (this.type !== other.type) {
|
|
76
|
+
return ConnectionPointCompatibilityState.TypeIncompatible;
|
|
77
|
+
}
|
|
78
|
+
// Check directions
|
|
79
|
+
if (this.direction === other.direction) {
|
|
80
|
+
return ConnectionPointCompatibilityState.DirectionIncompatible;
|
|
81
|
+
}
|
|
82
|
+
// Check hierarchy
|
|
83
|
+
if (other.ownerBlock.isAnAncestorOf(this.ownerBlock)) {
|
|
84
|
+
return ConnectionPointCompatibilityState.HierarchyIssue;
|
|
85
|
+
}
|
|
86
|
+
return ConnectionPointCompatibilityState.Compatible;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Checks if the connection point can be connected to another one.
|
|
90
|
+
* @param connectionPoint - The other connection point to check compatibility with
|
|
91
|
+
* @returns true if the connection point can be connected to the other one
|
|
92
|
+
*/
|
|
93
|
+
canConnectTo(connectionPoint) {
|
|
94
|
+
return this.checkCompatibilityState(connectionPoint) === ConnectionPointCompatibilityState.Compatible;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Connect this connection point to another one.
|
|
98
|
+
* @param other - The other connection point to connect to
|
|
99
|
+
* @throws if the connection point cannot be connected to the other one
|
|
100
|
+
*/
|
|
101
|
+
connectTo(other) {
|
|
102
|
+
// Only connects output to input
|
|
103
|
+
if (this.direction === ConnectionPointDirection.Input) {
|
|
104
|
+
other.connectTo(this);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
// Check compatibility
|
|
108
|
+
const compatibility = this.checkCompatibilityState(other);
|
|
109
|
+
if (compatibility !== ConnectionPointCompatibilityState.Compatible) {
|
|
110
|
+
throw getCompatibilityIssueMessage(compatibility);
|
|
111
|
+
}
|
|
112
|
+
// Adds the connection point to the list of endpoints
|
|
113
|
+
this._endpoints.push(other);
|
|
114
|
+
// Fill at the same time the connectedTo property of the other connection point
|
|
115
|
+
other._connectedTo = this;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Disconnects this point from one of his endpoint
|
|
119
|
+
* @param endpoint - defines the other connection point
|
|
120
|
+
*/
|
|
121
|
+
disconnectFrom(endpoint) {
|
|
122
|
+
const index = this._endpoints.indexOf(endpoint);
|
|
123
|
+
if (index === -1) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
// Remove the connection point from the list of endpoints
|
|
127
|
+
this._endpoints.splice(index, 1);
|
|
128
|
+
// Empty at the same time the connectedTo property of the other connection point
|
|
129
|
+
endpoint._connectedTo = null;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Disconnects this point from all its endpoints.
|
|
133
|
+
*/
|
|
134
|
+
disconnectAllEndpoints() {
|
|
135
|
+
// Detach outputs
|
|
136
|
+
let endpoint;
|
|
137
|
+
while ((endpoint = this._endpoints[0])) {
|
|
138
|
+
this.disconnectFrom(endpoint);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Propagates the current runtime data to all endpoints.
|
|
143
|
+
*/
|
|
144
|
+
propagateRuntimeData() {
|
|
145
|
+
if (!this.runtimeData) {
|
|
146
|
+
this.runtimeData = {};
|
|
147
|
+
}
|
|
148
|
+
for (const endpoint of this.endpoints) {
|
|
149
|
+
endpoint.runtimeData = this.runtimeData;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=connectionPoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectionPoint.js","sourceRoot":"","sources":["../../src/connection/connectionPoint.ts"],"names":[],"mappings":"AACA,OAAO,EACH,iCAAiC,EACjC,4BAA4B,GAC/B,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAUzE;;;;;;;;;GASG;AACH,MAAM,OAAO,eAAe;IA0CxB;;;;;;;OAOG;IACH,YACI,IAAY,EACZ,UAAqB,EACrB,IAAO,EACP,SAAmC,EACnC,qBAA+C,IAAI;QAjCvD;;WAEG;QACI,gBAAW,GAAqB,IAAI,CAAC;QAE5C;;;;WAIG;QACI,gBAAW,GAA6B,IAAI,CAAC;QAEpD;;WAEG;QACa,uBAAkB,GAA6B,IAAI,CAAC;QAE5D,iBAAY,GAAiC,IAAI,CAAC;QAClD,eAAU,GAA8B,EAAE,CAAC;QAiB/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,kBAAkB,CAAC;IAC1C,CAAC;IA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+
/** Points are compatibles */
|
|
6
|
+
Compatible = 0,
|
|
7
|
+
/** Points are incompatible because of their types */
|
|
8
|
+
TypeIncompatible = 1,
|
|
9
|
+
/** Points are incompatible because of their directions */
|
|
10
|
+
DirectionIncompatible = 2,
|
|
11
|
+
/** Points are incompatible because they are in the same hierarchy **/
|
|
12
|
+
HierarchyIssue = 3
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Gets a user friendly message for the given compatibility state.
|
|
16
|
+
* @param state - Defines the compatibility state
|
|
17
|
+
* @returns the message associated with a compatibility state.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getCompatibilityIssueMessage(state: ConnectionPointCompatibilityState): string;
|
|
20
|
+
//# sourceMappingURL=connectionPointCompatibilityState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectionPointCompatibilityState.d.ts","sourceRoot":"","sources":["../../src/connection/connectionPointCompatibilityState.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,iCAAiC;IACzC,6BAA6B;IAC7B,UAAU,IAAA;IACV,qDAAqD;IACrD,gBAAgB,IAAA;IAChB,0DAA0D;IAC1D,qBAAqB,IAAA;IACrB,sEAAsE;IACtE,cAAc,IAAA;CACjB;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,iCAAiC,GAAG,MAAM,CAW7F"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines how compatible connection points are.
|
|
3
|
+
*/
|
|
4
|
+
export var ConnectionPointCompatibilityState;
|
|
5
|
+
(function (ConnectionPointCompatibilityState) {
|
|
6
|
+
/** Points are compatibles */
|
|
7
|
+
ConnectionPointCompatibilityState[ConnectionPointCompatibilityState["Compatible"] = 0] = "Compatible";
|
|
8
|
+
/** Points are incompatible because of their types */
|
|
9
|
+
ConnectionPointCompatibilityState[ConnectionPointCompatibilityState["TypeIncompatible"] = 1] = "TypeIncompatible";
|
|
10
|
+
/** Points are incompatible because of their directions */
|
|
11
|
+
ConnectionPointCompatibilityState[ConnectionPointCompatibilityState["DirectionIncompatible"] = 2] = "DirectionIncompatible";
|
|
12
|
+
/** Points are incompatible because they are in the same hierarchy **/
|
|
13
|
+
ConnectionPointCompatibilityState[ConnectionPointCompatibilityState["HierarchyIssue"] = 3] = "HierarchyIssue";
|
|
14
|
+
})(ConnectionPointCompatibilityState || (ConnectionPointCompatibilityState = {}));
|
|
15
|
+
/**
|
|
16
|
+
* Gets a user friendly message for the given compatibility state.
|
|
17
|
+
* @param state - Defines the compatibility state
|
|
18
|
+
* @returns the message associated with a compatibility state.
|
|
19
|
+
*/
|
|
20
|
+
export function getCompatibilityIssueMessage(state) {
|
|
21
|
+
switch (state) {
|
|
22
|
+
case ConnectionPointCompatibilityState.TypeIncompatible:
|
|
23
|
+
return "Cannot connect two different connection types";
|
|
24
|
+
case ConnectionPointCompatibilityState.DirectionIncompatible:
|
|
25
|
+
return "Cannot connect with the same direction";
|
|
26
|
+
case ConnectionPointCompatibilityState.HierarchyIssue:
|
|
27
|
+
return "Source block cannot be connected with one of its ancestors";
|
|
28
|
+
default:
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=connectionPointCompatibilityState.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectionPointCompatibilityState.js","sourceRoot":"","sources":["../../src/connection/connectionPointCompatibilityState.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,iCASX;AATD,WAAY,iCAAiC;IACzC,6BAA6B;IAC7B,qGAAU,CAAA;IACV,qDAAqD;IACrD,iHAAgB,CAAA;IAChB,0DAA0D;IAC1D,2HAAqB,CAAA;IACrB,sEAAsE;IACtE,6GAAc,CAAA;AAClB,CAAC,EATW,iCAAiC,KAAjC,iCAAiC,QAS5C;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAwC;IACjF,QAAQ,KAAK,EAAE,CAAC;QACZ,KAAK,iCAAiC,CAAC,gBAAgB;YACnD,OAAO,+CAA+C,CAAC;QAC3D,KAAK,iCAAiC,CAAC,qBAAqB;YACxD,OAAO,wCAAwC,CAAC;QACpD,KAAK,iCAAiC,CAAC,cAAc;YACjD,OAAO,4DAA4D,CAAC;QACxE;YACI,OAAO,EAAE,CAAC;IAClB,CAAC;AACL,CAAC"}
|