@babylonjs/smart-filters 1.0.12 → 8.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blockFoundation/aggregateBlock.d.ts +3 -3
- package/dist/blockFoundation/aggregateBlock.d.ts.map +1 -1
- package/dist/blockFoundation/aggregateBlock.js +1 -2
- package/dist/blockFoundation/aggregateBlock.js.map +1 -1
- package/dist/blockFoundation/baseBlock.d.ts +2 -2
- package/dist/blockFoundation/baseBlock.d.ts.map +1 -1
- package/dist/blockFoundation/baseBlock.js +5 -6
- package/dist/blockFoundation/baseBlock.js.map +1 -1
- package/dist/blockFoundation/customAggregateBlock.d.ts.map +1 -1
- package/dist/blockFoundation/customAggregateBlock.js +2 -2
- package/dist/blockFoundation/customAggregateBlock.js.map +1 -1
- package/dist/blockFoundation/customShaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/customShaderBlock.js +4 -6
- package/dist/blockFoundation/customShaderBlock.js.map +1 -1
- package/dist/blockFoundation/disableableShaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/disableableShaderBlock.js +4 -4
- package/dist/blockFoundation/disableableShaderBlock.js.map +1 -1
- package/dist/blockFoundation/index.js +0 -2
- package/dist/blockFoundation/index.js.map +1 -1
- package/dist/blockFoundation/inputBlock.d.ts +8 -8
- package/dist/blockFoundation/inputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.d.ts +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.js +1 -1
- package/dist/blockFoundation/inputBlock.deserializer.js.map +1 -1
- package/dist/blockFoundation/inputBlock.js +7 -7
- package/dist/blockFoundation/inputBlock.js.map +1 -1
- package/dist/blockFoundation/inputBlock.serialization.types.d.ts.map +1 -1
- package/dist/blockFoundation/inputBlock.serializer.d.ts +1 -1
- package/dist/blockFoundation/inputBlock.serializer.js +26 -28
- package/dist/blockFoundation/inputBlock.serializer.js.map +1 -1
- package/dist/blockFoundation/outputBlock.d.ts +4 -9
- package/dist/blockFoundation/outputBlock.d.ts.map +1 -1
- package/dist/blockFoundation/outputBlock.js +13 -14
- package/dist/blockFoundation/outputBlock.js.map +1 -1
- package/dist/blockFoundation/shaderBlock.d.ts +4 -4
- package/dist/blockFoundation/shaderBlock.d.ts.map +1 -1
- package/dist/blockFoundation/shaderBlock.js +13 -19
- package/dist/blockFoundation/shaderBlock.js.map +1 -1
- package/dist/blockFoundation/textureOptions.d.ts +1 -1
- package/dist/blockFoundation/textureOptions.js +1 -1
- package/dist/command/command.d.ts +1 -1
- package/dist/command/command.js +1 -1
- package/dist/command/commandBuffer.d.ts +1 -1
- package/dist/command/commandBuffer.d.ts.map +1 -1
- package/dist/command/commandBuffer.js +2 -2
- package/dist/command/commandBufferDebugger.d.ts +2 -2
- package/dist/command/commandBufferDebugger.d.ts.map +1 -1
- package/dist/command/commandBufferDebugger.js +1 -1
- package/dist/command/commandBufferDebugger.js.map +1 -1
- package/dist/command/index.d.ts +3 -1
- package/dist/command/index.d.ts.map +1 -1
- package/dist/command/index.js +5 -1
- package/dist/command/index.js.map +1 -1
- package/dist/connection/connectionPoint.d.ts +3 -3
- package/dist/connection/connectionPoint.d.ts.map +1 -1
- package/dist/connection/connectionPoint.js +2 -2
- package/dist/connection/connectionPoint.js.map +1 -1
- package/dist/connection/connectionPointCompatibilityState.d.ts +1 -1
- package/dist/connection/connectionPointCompatibilityState.js +1 -1
- package/dist/connection/connectionPointType.d.ts +3 -3
- package/dist/connection/connectionPointType.d.ts.map +1 -1
- package/dist/connection/connectionPointWithDefault.d.ts +3 -3
- package/dist/connection/connectionPointWithDefault.d.ts.map +1 -1
- package/dist/connection/connectionPointWithDefault.js.map +1 -1
- package/dist/connection/index.d.ts +2 -1
- package/dist/connection/index.d.ts.map +1 -1
- package/dist/connection/index.js +3 -3
- package/dist/connection/index.js.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.d.ts +2 -2
- package/dist/editorUtils/editableInPropertyPage.d.ts.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.js +2 -2
- package/dist/editorUtils/editableInPropertyPage.js.map +1 -1
- package/dist/editorUtils/index.d.ts +1 -0
- package/dist/editorUtils/index.d.ts.map +1 -1
- package/dist/editorUtils/index.js +2 -0
- package/dist/editorUtils/index.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/optimization/dependencyGraph.js.map +1 -1
- package/dist/optimization/optimizedShaderBlock.d.ts +4 -4
- package/dist/optimization/optimizedShaderBlock.d.ts.map +1 -1
- package/dist/optimization/optimizedShaderBlock.js.map +1 -1
- package/dist/optimization/smartFilterOptimizer.d.ts +2 -2
- package/dist/optimization/smartFilterOptimizer.d.ts.map +1 -1
- package/dist/optimization/smartFilterOptimizer.js +34 -57
- package/dist/optimization/smartFilterOptimizer.js.map +1 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts.map +1 -1
- package/dist/runtime/renderTargetGenerator.js +5 -7
- package/dist/runtime/renderTargetGenerator.js.map +1 -1
- package/dist/runtime/shaderRuntime.d.ts +7 -7
- package/dist/runtime/shaderRuntime.d.ts.map +1 -1
- package/dist/runtime/shaderRuntime.js +7 -8
- package/dist/runtime/shaderRuntime.js.map +1 -1
- package/dist/runtime/smartFilterRuntime.d.ts +3 -3
- package/dist/runtime/smartFilterRuntime.d.ts.map +1 -1
- package/dist/runtime/smartFilterRuntime.js.map +1 -1
- package/dist/runtime/strongRef.d.ts +1 -1
- package/dist/runtime/strongRef.js +1 -1
- package/dist/serialization/importCustomBlockDefinition.d.ts +1 -1
- package/dist/serialization/importCustomBlockDefinition.js +8 -9
- package/dist/serialization/importCustomBlockDefinition.js.map +1 -1
- package/dist/serialization/index.d.ts +1 -0
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/index.js +3 -0
- package/dist/serialization/index.js.map +1 -1
- package/dist/serialization/serializedBlockDefinition.d.ts +2 -2
- package/dist/serialization/serializedBlockDefinition.d.ts.map +1 -1
- package/dist/serialization/serializedShaderBlockDefinition.d.ts +1 -1
- package/dist/serialization/serializedShaderBlockDefinition.d.ts.map +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.d.ts +6 -6
- package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.js +14 -12
- package/dist/serialization/smartFilterDeserializer.js.map +1 -1
- package/dist/serialization/smartFilterSerializer.d.ts +2 -2
- package/dist/serialization/smartFilterSerializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterSerializer.js +10 -13
- package/dist/serialization/smartFilterSerializer.js.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.d.ts +2 -2
- package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.js +3 -1
- package/dist/serialization/v1/defaultBlockSerializer.js.map +1 -1
- package/dist/serialization/v1/index.d.ts +1 -0
- package/dist/serialization/v1/index.d.ts.map +1 -1
- package/dist/serialization/v1/index.js +2 -0
- package/dist/serialization/v1/index.js.map +1 -1
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts +3 -3
- package/dist/serialization/v1/shaderBlockSerialization.types.d.ts.map +1 -1
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts +5 -2
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -1
- package/dist/smartFilter.d.ts +8 -8
- package/dist/smartFilter.d.ts.map +1 -1
- package/dist/smartFilter.js +6 -7
- package/dist/smartFilter.js.map +1 -1
- package/dist/utils/buildTools/buildShaders.d.ts +3 -2
- package/dist/utils/buildTools/buildShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/buildShaders.js +7 -6
- package/dist/utils/buildTools/buildShaders.js.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts +4 -2
- package/dist/utils/buildTools/convertGlslIntoBlock.d.ts.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoBlock.js +136 -141
- package/dist/utils/buildTools/convertGlslIntoBlock.js.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts +4 -4
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.d.ts.map +1 -1
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js +55 -48
- package/dist/utils/buildTools/convertGlslIntoShaderProgram.js.map +1 -1
- package/dist/utils/buildTools/convertShaders.d.ts +8 -5
- package/dist/utils/buildTools/convertShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/convertShaders.js +38 -14
- package/dist/utils/buildTools/convertShaders.js.map +1 -1
- package/dist/utils/buildTools/shaderConverter.d.ts +4 -4
- package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -1
- package/dist/utils/buildTools/shaderConverter.js +17 -21
- package/dist/utils/buildTools/shaderConverter.js.map +1 -1
- package/dist/utils/buildTools/watchShaders.d.ts +3 -2
- package/dist/utils/buildTools/watchShaders.d.ts.map +1 -1
- package/dist/utils/buildTools/watchShaders.js +10 -8
- package/dist/utils/buildTools/watchShaders.js.map +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/renderTargetUtils.d.ts +3 -3
- package/dist/utils/renderTargetUtils.d.ts.map +1 -1
- package/dist/utils/renderTargetUtils.js +4 -4
- package/dist/utils/renderTargetUtils.js.map +1 -1
- package/dist/utils/shaderCodeUtils.d.ts +8 -8
- package/dist/utils/shaderCodeUtils.d.ts.map +1 -1
- package/dist/utils/shaderCodeUtils.js +16 -28
- package/dist/utils/shaderCodeUtils.js.map +1 -1
- package/dist/utils/textureLoaders.d.ts +2 -2
- package/dist/utils/textureLoaders.d.ts.map +1 -1
- package/dist/utils/textureLoaders.js +2 -3
- package/dist/utils/textureLoaders.js.map +1 -1
- package/dist/utils/textureUtils.d.ts +5 -5
- package/dist/utils/textureUtils.d.ts.map +1 -1
- package/dist/utils/textureUtils.js +1 -1
- package/dist/utils/textureUtils.js.map +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/license.md +21 -21
- package/package.json +14 -9
- package/src/blockFoundation/aggregateBlock.ts +148 -151
- package/src/blockFoundation/baseBlock.ts +339 -364
- package/src/blockFoundation/customAggregateBlock.ts +88 -104
- package/src/blockFoundation/customShaderBlock.ts +312 -326
- package/src/blockFoundation/disableableShaderBlock.ts +91 -100
- package/src/blockFoundation/index.ts +9 -9
- package/src/blockFoundation/inputBlock.deserializer.ts +72 -97
- package/src/blockFoundation/inputBlock.serialization.types.ts +126 -132
- package/src/blockFoundation/inputBlock.serializer.ts +150 -150
- package/src/blockFoundation/inputBlock.ts +181 -192
- package/src/blockFoundation/outputBlock.ts +144 -151
- package/src/blockFoundation/shaderBlock.ts +156 -163
- package/src/blockFoundation/textureOptions.ts +57 -57
- package/src/command/command.ts +59 -59
- package/src/command/commandBuffer.ts +71 -71
- package/src/command/commandBufferDebugger.ts +14 -14
- package/src/command/index.ts +7 -3
- package/src/connection/connectionPoint.ts +205 -214
- package/src/connection/connectionPointCompatibilityState.ts +31 -31
- package/src/connection/connectionPointType.ts +45 -45
- package/src/connection/connectionPointWithDefault.ts +27 -35
- package/src/connection/index.ts +8 -9
- package/src/editorUtils/editableInPropertyPage.ts +106 -106
- package/src/editorUtils/index.ts +3 -1
- package/src/index.ts +16 -15
- package/src/optimization/dependencyGraph.ts +96 -96
- package/src/optimization/index.ts +1 -1
- package/src/optimization/optimizedShaderBlock.ts +131 -134
- package/src/optimization/smartFilterOptimizer.ts +757 -825
- package/src/runtime/index.ts +8 -6
- package/src/runtime/renderTargetGenerator.ts +222 -248
- package/src/runtime/shaderRuntime.ts +174 -173
- package/src/runtime/smartFilterRuntime.ts +112 -112
- package/src/runtime/strongRef.ts +18 -18
- package/src/serialization/importCustomBlockDefinition.ts +86 -86
- package/src/serialization/index.ts +10 -7
- package/src/serialization/serializedBlockDefinition.ts +12 -12
- package/src/serialization/serializedShaderBlockDefinition.ts +7 -7
- package/src/serialization/serializedSmartFilter.ts +6 -6
- package/src/serialization/smartFilterDeserializer.ts +190 -214
- package/src/serialization/smartFilterSerializer.ts +110 -121
- package/src/serialization/v1/defaultBlockSerializer.ts +21 -19
- package/src/serialization/v1/index.ts +4 -2
- package/src/serialization/v1/shaderBlockSerialization.types.ts +85 -85
- package/src/serialization/v1/smartFilterSerialization.types.ts +129 -129
- package/src/smartFilter.ts +255 -260
- package/src/utils/buildTools/buildShaders.ts +14 -13
- package/src/utils/buildTools/convertGlslIntoBlock.ts +370 -385
- package/src/utils/buildTools/convertGlslIntoShaderProgram.ts +173 -172
- package/src/utils/buildTools/convertShaders.ts +65 -43
- package/src/utils/buildTools/recordVersionNumber.js +17 -0
- package/src/utils/buildTools/shaderConverter.ts +466 -478
- package/src/utils/buildTools/watchShaders.ts +44 -42
- package/src/utils/index.ts +4 -2
- package/src/utils/renderTargetUtils.ts +30 -35
- package/src/utils/shaderCodeUtils.ts +192 -207
- package/src/utils/textureLoaders.ts +31 -43
- package/src/utils/textureUtils.ts +28 -32
- package/src/version.ts +2 -2
- package/dist/utils/buildTools/determineVersion.d.ts +0 -36
- package/dist/utils/buildTools/determineVersion.d.ts.map +0 -1
- package/dist/utils/buildTools/determineVersion.js +0 -109
- package/dist/utils/buildTools/determineVersion.js.map +0 -1
- package/dist/utils/buildTools/versionUp.d.ts +0 -2
- package/dist/utils/buildTools/versionUp.d.ts.map +0 -1
- package/dist/utils/buildTools/versionUp.js +0 -53
- package/dist/utils/buildTools/versionUp.js.map +0 -1
- package/src/utils/buildTools/determineVersion.ts +0 -128
- package/src/utils/buildTools/versionUp.ts +0 -61
|
@@ -1,121 +1,110 @@
|
|
|
1
|
-
import type { SmartFilter } from "../smartFilter";
|
|
2
|
-
import type { BaseBlock } from "../blockFoundation/baseBlock";
|
|
3
|
-
import {
|
|
4
|
-
import type { ConnectionPoint } from "../connection/connectionPoint";
|
|
5
|
-
import {
|
|
6
|
-
import { OutputBlock } from "../blockFoundation/outputBlock.js";
|
|
7
|
-
import type {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// Serialize the
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
format: "smartFilter",
|
|
112
|
-
formatVersion: 1,
|
|
113
|
-
name: smartFilter.name,
|
|
114
|
-
namespace: smartFilter.namespace,
|
|
115
|
-
comments: smartFilter.comments,
|
|
116
|
-
editorData: smartFilter.editorData,
|
|
117
|
-
blocks,
|
|
118
|
-
connections,
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
}
|
|
1
|
+
import type { SmartFilter } from "../smartFilter.js";
|
|
2
|
+
import type { BaseBlock } from "../blockFoundation/baseBlock.js";
|
|
3
|
+
import { InputBlockSerializer } from "../blockFoundation/inputBlock.serializer.js";
|
|
4
|
+
import type { ConnectionPoint } from "../connection/connectionPoint.js";
|
|
5
|
+
import { DefaultBlockSerializer } from "./v1/defaultBlockSerializer.js";
|
|
6
|
+
import { OutputBlock } from "../blockFoundation/outputBlock.js";
|
|
7
|
+
import type { IBlockSerializerV1, ISerializedBlockV1, ISerializedConnectionV1, SerializeBlockV1, SerializedSmartFilterV1 } from "./v1/smartFilterSerialization.types.js";
|
|
8
|
+
import { CustomShaderBlock } from "../blockFoundation/customShaderBlock.js";
|
|
9
|
+
import { CustomAggregateBlock } from "../blockFoundation/customAggregateBlock.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Determines if two serialized connection points are equivalent to each other
|
|
13
|
+
* @param a - The first connection point to compare
|
|
14
|
+
* @param b - The second connection point to compare
|
|
15
|
+
* @returns True if the connection points are equivalent, false otherwise
|
|
16
|
+
*/
|
|
17
|
+
function SerializedConnectionPointsEqual(a: ISerializedConnectionV1, b: ISerializedConnectionV1): boolean {
|
|
18
|
+
return (
|
|
19
|
+
a.inputBlock === b.inputBlock && a.inputConnectionPoint === b.inputConnectionPoint && a.outputBlock === b.outputBlock && a.outputConnectionPoint === b.outputConnectionPoint
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Serializes SmartFilters using the latest SmartFilter serialization version.
|
|
25
|
+
* The caller passes in information necessary to serialize the blocks in the SmartFilter.
|
|
26
|
+
* This allows the caller to provide custom serializers for blocks beyond the core blocks.
|
|
27
|
+
*/
|
|
28
|
+
export class SmartFilterSerializer {
|
|
29
|
+
private readonly _blockSerializers: Map<string, SerializeBlockV1> = new Map();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Creates a new SmartFilterSerializer
|
|
33
|
+
* @param blocksUsingDefaultSerialization - A list of the blockType of blocks which can use default serialization (they only have ConnectionPoint properties and no constructor parameters)
|
|
34
|
+
* @param additionalBlockSerializers - An array of block serializers to use, beyond those for the core blocks
|
|
35
|
+
*/
|
|
36
|
+
public constructor(blocksUsingDefaultSerialization: string[], additionalBlockSerializers: IBlockSerializerV1[]) {
|
|
37
|
+
this._blockSerializers.set(InputBlockSerializer.blockType, InputBlockSerializer.serialize);
|
|
38
|
+
this._blockSerializers.set(OutputBlock.ClassName, DefaultBlockSerializer);
|
|
39
|
+
blocksUsingDefaultSerialization.forEach((block) => {
|
|
40
|
+
this._blockSerializers.set(block, DefaultBlockSerializer);
|
|
41
|
+
});
|
|
42
|
+
additionalBlockSerializers.forEach((serializer) => this._blockSerializers.set(serializer.blockType, serializer.serialize));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Serializes a SmartFilter to a JSON object of the latest version
|
|
47
|
+
* @param smartFilter - The SmartFilter to serialize
|
|
48
|
+
* @returns The serialized SmartFilter
|
|
49
|
+
*/
|
|
50
|
+
public serialize(smartFilter: SmartFilter): SerializedSmartFilterV1 {
|
|
51
|
+
const connections: ISerializedConnectionV1[] = [];
|
|
52
|
+
|
|
53
|
+
const blocks = smartFilter.attachedBlocks.map((block: BaseBlock) => {
|
|
54
|
+
// Serialize the block itself
|
|
55
|
+
const blockClassName = block.getClassName();
|
|
56
|
+
const serializeFn =
|
|
57
|
+
blockClassName === CustomShaderBlock.ClassName || blockClassName === CustomAggregateBlock.ClassName
|
|
58
|
+
? DefaultBlockSerializer
|
|
59
|
+
: this._blockSerializers.get(block.blockType);
|
|
60
|
+
if (!serializeFn) {
|
|
61
|
+
throw new Error(`No serializer was provided for a block of type ${block.blockType}`);
|
|
62
|
+
}
|
|
63
|
+
const serializedBlock: ISerializedBlockV1 = serializeFn(block);
|
|
64
|
+
|
|
65
|
+
// Serialize the connections to the inputs
|
|
66
|
+
block.inputs.forEach((input: ConnectionPoint) => {
|
|
67
|
+
const connectedTo = input.connectedTo;
|
|
68
|
+
if (connectedTo) {
|
|
69
|
+
const newConnection: ISerializedConnectionV1 = {
|
|
70
|
+
inputBlock: block.uniqueId,
|
|
71
|
+
inputConnectionPoint: input.name,
|
|
72
|
+
outputBlock: connectedTo.ownerBlock.uniqueId,
|
|
73
|
+
outputConnectionPoint: connectedTo.name,
|
|
74
|
+
};
|
|
75
|
+
if (!connections.find((other) => SerializedConnectionPointsEqual(newConnection, other))) {
|
|
76
|
+
connections.push(newConnection);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Serialize the connections to the outputs
|
|
82
|
+
block.outputs.forEach((output: ConnectionPoint) => {
|
|
83
|
+
output.endpoints.forEach((input: ConnectionPoint) => {
|
|
84
|
+
const newConnection: ISerializedConnectionV1 = {
|
|
85
|
+
inputBlock: input.ownerBlock.uniqueId,
|
|
86
|
+
inputConnectionPoint: input.name,
|
|
87
|
+
outputBlock: block.uniqueId,
|
|
88
|
+
outputConnectionPoint: output.name,
|
|
89
|
+
};
|
|
90
|
+
if (!connections.find((other) => SerializedConnectionPointsEqual(newConnection, other))) {
|
|
91
|
+
connections.push(newConnection);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return serializedBlock;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
format: "smartFilter",
|
|
101
|
+
formatVersion: 1,
|
|
102
|
+
name: smartFilter.name,
|
|
103
|
+
namespace: smartFilter.namespace,
|
|
104
|
+
comments: smartFilter.comments,
|
|
105
|
+
editorData: smartFilter.editorData,
|
|
106
|
+
blocks,
|
|
107
|
+
connections,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { ShaderBlock } from "../../blockFoundation/shaderBlock.js";
|
|
2
|
+
import type { BaseBlock } from "../../blockFoundation/baseBlock.js";
|
|
3
|
+
import type { ISerializedBlockV1, SerializeBlockV1 } from "./smartFilterSerialization.types.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The default V1 block serializer which can be used for any block that relies only on ConnectionPoints
|
|
7
|
+
* and does not have any constructor parameters or class properties that need to be serialized.
|
|
8
|
+
* @param block - The block to serialize
|
|
9
|
+
* @returns The serialized block
|
|
10
|
+
*/
|
|
11
|
+
export const DefaultBlockSerializer: SerializeBlockV1 = (block: BaseBlock): ISerializedBlockV1 => {
|
|
12
|
+
return {
|
|
13
|
+
name: block.name,
|
|
14
|
+
uniqueId: block.uniqueId,
|
|
15
|
+
blockType: block.blockType,
|
|
16
|
+
namespace: block.namespace,
|
|
17
|
+
comments: block.comments,
|
|
18
|
+
data: undefined,
|
|
19
|
+
outputTextureOptions: block instanceof ShaderBlock ? block.outputTextureOptions : undefined,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export * from "./defaultBlockSerializer.js";
|
|
2
|
-
|
|
1
|
+
export * from "./defaultBlockSerializer.js";
|
|
2
|
+
// Back compat for when camelCase was used
|
|
3
|
+
export { DefaultBlockSerializer as defaultBlockSerializer } from "./defaultBlockSerializer.js";
|
|
4
|
+
export * from "./smartFilterSerialization.types.js";
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ----------------------------------------------------------------------------
|
|
3
|
-
* Data Types Used For Block Serialization
|
|
4
|
-
* ----------------------------------------------------------------------------
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { Nullable } from "
|
|
8
|
-
import type { AllConnectionPointTypes, ConnectionPointValue } from "../../connection/connectionPointType";
|
|
9
|
-
import type { ShaderProgram } from "../../utils/shaderCodeUtils";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* The V1 definition of a serialized shader block. This block definition is loaded by a CustomShaderBlock and defines how a
|
|
13
|
-
* blockType works. This should not be confused with an ISerializedBockV1, which is a serialized instance of a block in a
|
|
14
|
-
* serialized SmartFilter graph. It is referenced by blockType in a serialized SmartFilter.
|
|
15
|
-
*/
|
|
16
|
-
export type SerializedShaderBlockDefinitionV1 = {
|
|
17
|
-
/**
|
|
18
|
-
* Which type of serialized data this is.
|
|
19
|
-
*/
|
|
20
|
-
format: "shaderBlockDefinition";
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* The version of the block definition format (format of the serialized data, not the version of the block definition itself).
|
|
24
|
-
*/
|
|
25
|
-
formatVersion: 1;
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* The type used to refer to the block in serialized SmartFilters and in the editor UI.
|
|
29
|
-
* The application doing the deserialization will use this to instantiate the correct block definition.
|
|
30
|
-
* Block types are expected to be unique and their behavior should be semantically equivalent across implementations
|
|
31
|
-
* (their results must be similar enough that the differences are not perceivable).
|
|
32
|
-
*/
|
|
33
|
-
blockType: string;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
|
|
37
|
-
* By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
|
|
38
|
-
*/
|
|
39
|
-
namespace: Nullable<string>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* The shader program for the block.
|
|
43
|
-
*/
|
|
44
|
-
shaderProgram: ShaderProgram;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* The input connection points of the block.
|
|
48
|
-
*/
|
|
49
|
-
inputConnectionPoints: SerializedInputConnectionPointV1[];
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* If true, the optimizer will not attempt to optimize this block.
|
|
53
|
-
*/
|
|
54
|
-
disableOptimization: boolean;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Possible V1 auto bind values for input connection points.
|
|
59
|
-
*/
|
|
60
|
-
export type InputAutoBindV1 = "outputResolution" | "outputAspectRatio";
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* A V1 input connection point of a serialized block definition.
|
|
64
|
-
*/
|
|
65
|
-
export type SerializedInputConnectionPointV1<U extends AllConnectionPointTypes = AllConnectionPointTypes> = {
|
|
66
|
-
/**
|
|
67
|
-
* The name of the connection point.
|
|
68
|
-
*/
|
|
69
|
-
name: string;
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* The type of the connection point.
|
|
73
|
-
*/
|
|
74
|
-
type: U;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The optional default value of the connection point.
|
|
78
|
-
*/
|
|
79
|
-
defaultValue?: ConnectionPointValue<U>;
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* If supplied, the input will be automatically bound to this value, instead of creating an input connection point.
|
|
83
|
-
*/
|
|
84
|
-
autoBind?: InputAutoBindV1;
|
|
85
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Data Types Used For Block Serialization
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import type { Nullable } from "core/types.js";
|
|
8
|
+
import type { AllConnectionPointTypes, ConnectionPointValue } from "../../connection/connectionPointType.js";
|
|
9
|
+
import type { ShaderProgram } from "../../utils/shaderCodeUtils.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The V1 definition of a serialized shader block. This block definition is loaded by a CustomShaderBlock and defines how a
|
|
13
|
+
* blockType works. This should not be confused with an ISerializedBockV1, which is a serialized instance of a block in a
|
|
14
|
+
* serialized SmartFilter graph. It is referenced by blockType in a serialized SmartFilter.
|
|
15
|
+
*/
|
|
16
|
+
export type SerializedShaderBlockDefinitionV1 = {
|
|
17
|
+
/**
|
|
18
|
+
* Which type of serialized data this is.
|
|
19
|
+
*/
|
|
20
|
+
format: "shaderBlockDefinition";
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The version of the block definition format (format of the serialized data, not the version of the block definition itself).
|
|
24
|
+
*/
|
|
25
|
+
formatVersion: 1;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The type used to refer to the block in serialized SmartFilters and in the editor UI.
|
|
29
|
+
* The application doing the deserialization will use this to instantiate the correct block definition.
|
|
30
|
+
* Block types are expected to be unique and their behavior should be semantically equivalent across implementations
|
|
31
|
+
* (their results must be similar enough that the differences are not perceivable).
|
|
32
|
+
*/
|
|
33
|
+
blockType: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
|
|
37
|
+
* By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
|
|
38
|
+
*/
|
|
39
|
+
namespace: Nullable<string>;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The shader program for the block.
|
|
43
|
+
*/
|
|
44
|
+
shaderProgram: ShaderProgram;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The input connection points of the block.
|
|
48
|
+
*/
|
|
49
|
+
inputConnectionPoints: SerializedInputConnectionPointV1[];
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* If true, the optimizer will not attempt to optimize this block.
|
|
53
|
+
*/
|
|
54
|
+
disableOptimization: boolean;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Possible V1 auto bind values for input connection points.
|
|
59
|
+
*/
|
|
60
|
+
export type InputAutoBindV1 = "outputResolution" | "outputAspectRatio";
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* A V1 input connection point of a serialized block definition.
|
|
64
|
+
*/
|
|
65
|
+
export type SerializedInputConnectionPointV1<U extends AllConnectionPointTypes = AllConnectionPointTypes> = {
|
|
66
|
+
/**
|
|
67
|
+
* The name of the connection point.
|
|
68
|
+
*/
|
|
69
|
+
name: string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The type of the connection point.
|
|
73
|
+
*/
|
|
74
|
+
type: U;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The optional default value of the connection point.
|
|
78
|
+
*/
|
|
79
|
+
defaultValue?: ConnectionPointValue<U>;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* If supplied, the input will be automatically bound to this value, instead of creating an input connection point.
|
|
83
|
+
*/
|
|
84
|
+
autoBind?: InputAutoBindV1;
|
|
85
|
+
};
|