@babylonjs/smart-filters 0.4.3-alpha → 0.6.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/blocks/baseBlock.d.ts +6 -0
- package/dist/blocks/baseBlock.d.ts.map +1 -1
- package/dist/blocks/baseBlock.js +8 -0
- package/dist/blocks/baseBlock.js.map +1 -1
- package/dist/blocks/customShaderBlock.d.ts +55 -0
- package/dist/blocks/customShaderBlock.d.ts.map +1 -0
- package/dist/blocks/customShaderBlock.js +139 -0
- package/dist/blocks/customShaderBlock.js.map +1 -0
- package/dist/blocks/inputBlock.deserializer.d.ts +1 -1
- package/dist/blocks/inputBlock.deserializer.d.ts.map +1 -1
- package/dist/blocks/inputBlock.serializer.d.ts +1 -1
- package/dist/blocks/inputBlock.serializer.d.ts.map +1 -1
- package/dist/blocks/inputBlock.serializer.js +3 -3
- package/dist/blocks/inputBlock.serializer.js.map +1 -1
- package/dist/blocks/shaderBlock.d.ts +3 -7
- package/dist/blocks/shaderBlock.d.ts.map +1 -1
- package/dist/blocks/shaderBlock.js +45 -15
- package/dist/blocks/shaderBlock.js.map +1 -1
- package/dist/blocks/textureOptions.d.ts +47 -0
- package/dist/blocks/textureOptions.d.ts.map +1 -0
- package/dist/blocks/textureOptions.js +37 -0
- package/dist/blocks/textureOptions.js.map +1 -0
- package/dist/command/command.d.ts +2 -3
- package/dist/command/command.d.ts.map +1 -1
- package/dist/command/command.js.map +1 -1
- package/dist/command/commandBufferDebugger.js +1 -1
- package/dist/command/commandBufferDebugger.js.map +1 -1
- package/dist/connection/connectionPointType.d.ts +4 -0
- package/dist/connection/connectionPointType.d.ts.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.d.ts +4 -0
- package/dist/editorUtils/editableInPropertyPage.d.ts.map +1 -1
- package/dist/editorUtils/editableInPropertyPage.js +1 -0
- package/dist/editorUtils/editableInPropertyPage.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/optimization/smartFilterOptimizer.d.ts +1 -1
- package/dist/optimization/smartFilterOptimizer.d.ts.map +1 -1
- package/dist/optimization/smartFilterOptimizer.js +10 -9
- package/dist/optimization/smartFilterOptimizer.js.map +1 -1
- package/dist/runtime/renderTargetGenerator.d.ts +8 -1
- package/dist/runtime/renderTargetGenerator.d.ts.map +1 -1
- package/dist/runtime/renderTargetGenerator.js +37 -18
- package/dist/runtime/renderTargetGenerator.js.map +1 -1
- package/dist/serialization/importCustomShaderBlockDefinition.d.ts +11 -0
- package/dist/serialization/importCustomShaderBlockDefinition.d.ts.map +1 -0
- package/dist/serialization/importCustomShaderBlockDefinition.js +80 -0
- package/dist/serialization/importCustomShaderBlockDefinition.js.map +1 -0
- package/dist/serialization/index.d.ts +1 -0
- package/dist/serialization/index.d.ts.map +1 -1
- package/dist/serialization/index.js +1 -0
- package/dist/serialization/index.js.map +1 -1
- package/dist/serialization/serializedBlockDefinition.d.ts +7 -0
- package/dist/serialization/serializedBlockDefinition.d.ts.map +1 -0
- package/dist/serialization/serializedBlockDefinition.js +2 -0
- package/dist/serialization/serializedBlockDefinition.js.map +1 -0
- package/dist/serialization/serializedSmartFilter.d.ts +1 -1
- package/dist/serialization/serializedSmartFilter.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.d.ts +12 -4
- package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.js +63 -34
- 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 +9 -6
- package/dist/serialization/smartFilterSerializer.js.map +1 -1
- package/dist/serialization/v1/blockSerialization.types.d.ts +55 -0
- package/dist/serialization/v1/blockSerialization.types.d.ts.map +1 -0
- package/dist/serialization/v1/blockSerialization.types.js +7 -0
- package/dist/serialization/v1/blockSerialization.types.js.map +1 -0
- package/dist/serialization/v1/defaultBlockSerializer.d.ts +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.js +1 -1
- package/dist/serialization/v1/defaultBlockSerializer.js.map +1 -1
- package/dist/serialization/v1/index.d.ts +1 -1
- package/dist/serialization/v1/index.d.ts.map +1 -1
- package/dist/serialization/v1/index.js +1 -1
- package/dist/serialization/v1/index.js.map +1 -1
- package/dist/serialization/v1/{serialization.types.d.ts → smartFilterSerialization.types.d.ts} +12 -11
- package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -0
- package/dist/serialization/v1/smartFilterSerialization.types.js +2 -0
- package/dist/serialization/v1/smartFilterSerialization.types.js.map +1 -0
- package/dist/utils/buildTools/buildShaders.js +1 -1
- package/dist/utils/buildTools/buildShaders.js.map +1 -1
- package/dist/utils/buildTools/convertShaderForHardcodedBlock.d.ts +13 -0
- package/dist/utils/buildTools/convertShaderForHardcodedBlock.d.ts.map +1 -0
- package/dist/utils/buildTools/convertShaderForHardcodedBlock.js +116 -0
- package/dist/utils/buildTools/convertShaderForHardcodedBlock.js.map +1 -0
- package/dist/utils/buildTools/shaderCode.types.d.ts +43 -0
- package/dist/utils/buildTools/shaderCode.types.d.ts.map +1 -0
- package/dist/utils/buildTools/shaderCode.types.js +2 -0
- package/dist/utils/buildTools/shaderCode.types.js.map +1 -0
- package/dist/utils/buildTools/shaderConverter.d.ts +56 -8
- package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -1
- package/dist/utils/buildTools/shaderConverter.js +87 -137
- package/dist/utils/buildTools/shaderConverter.js.map +1 -1
- package/dist/utils/buildTools/watchShaders.js +2 -2
- package/dist/utils/buildTools/watchShaders.js.map +1 -1
- package/dist/utils/renderTargetUtils.js +3 -3
- package/dist/utils/renderTargetUtils.js.map +1 -1
- package/dist/utils/shaderCodeUtils.d.ts +1 -42
- package/dist/utils/shaderCodeUtils.d.ts.map +1 -1
- package/dist/utils/shaderCodeUtils.js.map +1 -1
- package/package.json +1 -1
- package/readme.md +19 -15
- package/src/blocks/baseBlock.ts +9 -0
- package/src/blocks/customShaderBlock.ts +217 -0
- package/src/blocks/inputBlock.deserializer.ts +1 -1
- package/src/blocks/inputBlock.serializer.ts +4 -4
- package/src/blocks/shaderBlock.ts +36 -15
- package/src/blocks/textureOptions.ts +57 -0
- package/src/command/command.ts +2 -3
- package/src/command/commandBufferDebugger.ts +1 -1
- package/src/connection/connectionPointType.ts +11 -0
- package/src/editorUtils/editableInPropertyPage.ts +5 -0
- package/src/index.ts +2 -0
- package/src/optimization/smartFilterOptimizer.ts +11 -10
- package/src/runtime/renderTargetGenerator.ts +55 -20
- package/src/serialization/importCustomShaderBlockDefinition.ts +85 -0
- package/src/serialization/index.ts +1 -0
- package/src/serialization/serializedBlockDefinition.ts +7 -0
- package/src/serialization/serializedSmartFilter.ts +1 -1
- package/src/serialization/smartFilterDeserializer.ts +106 -52
- package/src/serialization/smartFilterSerializer.ts +11 -7
- package/src/serialization/v1/blockSerialization.types.ts +63 -0
- package/src/serialization/v1/defaultBlockSerializer.ts +2 -2
- package/src/serialization/v1/index.ts +1 -1
- package/src/serialization/v1/{serialization.types.ts → smartFilterSerialization.types.ts} +11 -10
- package/src/utils/buildTools/buildShaders.ts +1 -1
- package/src/utils/buildTools/convertShaderForHardcodedBlock.ts +149 -0
- package/src/utils/buildTools/shaderCode.types.ts +49 -0
- package/src/utils/buildTools/shaderConverter.ts +158 -178
- package/src/utils/buildTools/watchShaders.ts +2 -2
- package/src/utils/renderTargetUtils.ts +3 -3
- package/src/utils/shaderCodeUtils.ts +1 -50
- package/dist/serialization/v1/serialization.types.d.ts.map +0 -1
- package/dist/serialization/v1/serialization.types.js +0 -2
- package/dist/serialization/v1/serialization.types.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/serialization/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SerializedBlockDefinitionV1 } from "./v1/blockSerialization.types";
|
|
2
|
+
/**
|
|
3
|
+
* Type union of all versions of serialized SmartFilter block definitions
|
|
4
|
+
* A block definition is an object which is used to create a CustomShaderBlock instance.
|
|
5
|
+
*/
|
|
6
|
+
export type SerializedBlockDefinition = SerializedBlockDefinitionV1;
|
|
7
|
+
//# sourceMappingURL=serializedBlockDefinition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializedBlockDefinition.d.ts","sourceRoot":"","sources":["../../src/serialization/serializedBlockDefinition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,yBAAyB,GAAG,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serializedBlockDefinition.js","sourceRoot":"","sources":["../../src/serialization/serializedBlockDefinition.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializedSmartFilter.d.ts","sourceRoot":"","sources":["../../src/serialization/serializedSmartFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"serializedSmartFilter.d.ts","sourceRoot":"","sources":["../../src/serialization/serializedSmartFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAEnF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,uBAAuB,CAAC"}
|
|
@@ -1,19 +1,26 @@
|
|
|
1
|
+
import type { BaseBlock } from "../blocks/baseBlock";
|
|
1
2
|
import { SmartFilter } from "../smartFilter.js";
|
|
2
3
|
import type { ThinEngine } from "@babylonjs/core/Engines/thinEngine";
|
|
3
|
-
import type {
|
|
4
|
+
import type { ISerializedBlockV1, OptionalBlockDeserializerV1 } from "./v1/smartFilterSerialization.types";
|
|
5
|
+
import type { Nullable } from "@babylonjs/core/types";
|
|
6
|
+
/**
|
|
7
|
+
* A function that creates a block instance of the given class block type, or return null if it cannot.
|
|
8
|
+
*/
|
|
9
|
+
export type BlockFactory = (smartFilter: SmartFilter, engine: ThinEngine, serializedBlock: ISerializedBlockV1) => Promise<Nullable<BaseBlock>>;
|
|
4
10
|
/**
|
|
5
11
|
* Deserializes serialized SmartFilters. The caller passes in a map of block deserializers it wants to use,
|
|
6
12
|
* which allows the caller to provide custom deserializers for blocks beyond the core blocks.
|
|
7
13
|
* The deserializer supports versioned serialized SmartFilters.
|
|
8
14
|
*/
|
|
9
15
|
export declare class SmartFilterDeserializer {
|
|
10
|
-
private readonly
|
|
16
|
+
private readonly _blockFactory;
|
|
17
|
+
private readonly _customInputBlockDeserializer?;
|
|
11
18
|
/**
|
|
12
19
|
* Creates a new SmartFilterDeserializer
|
|
13
|
-
* @param
|
|
20
|
+
* @param blockFactory - A function that creates a block of the given class name, or returns null if it cannot
|
|
14
21
|
* @param customInputBlockDeserializer - An optional custom deserializer for InputBlocks - if supplied and it returns null, the default deserializer will be used
|
|
15
22
|
*/
|
|
16
|
-
constructor(
|
|
23
|
+
constructor(blockFactory: BlockFactory, customInputBlockDeserializer?: OptionalBlockDeserializerV1);
|
|
17
24
|
/**
|
|
18
25
|
* Deserializes a SmartFilter from a JSON object - can be safely called multiple times and has no side effects within the class.
|
|
19
26
|
* @param engine - The ThinEngine to pass to the new SmartFilter
|
|
@@ -22,5 +29,6 @@ export declare class SmartFilterDeserializer {
|
|
|
22
29
|
*/
|
|
23
30
|
deserialize(engine: ThinEngine, smartFilterJson: any): Promise<SmartFilter>;
|
|
24
31
|
private _deserializeV1;
|
|
32
|
+
private _deserializeBlockV1;
|
|
25
33
|
}
|
|
26
34
|
//# sourceMappingURL=smartFilterDeserializer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartFilterDeserializer.d.ts","sourceRoot":"","sources":["../../src/serialization/smartFilterDeserializer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"smartFilterDeserializer.d.ts","sourceRoot":"","sources":["../../src/serialization/smartFilterDeserializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAErE,OAAO,KAAK,EACR,kBAAkB,EAElB,2BAA2B,EAE9B,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CACvB,WAAW,EAAE,WAAW,EACxB,MAAM,EAAE,UAAU,EAClB,eAAe,EAAE,kBAAkB,KAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;AAElC;;;;GAIG;AACH,qBAAa,uBAAuB;IAChC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAC7C,OAAO,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAA8B;IAE7E;;;;OAIG;gBACgB,YAAY,EAAE,YAAY,EAAE,4BAA4B,CAAC,EAAE,2BAA2B;IAKzG;;;;;OAKG;IACU,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,eAAe,EAAE,GAAG,GAAG,OAAO,CAAC,WAAW,CAAC;YAe1E,cAAc;YAoFd,mBAAmB;CAyDpC"}
|
|
@@ -11,22 +11,12 @@ import { UniqueIdGenerator } from "../utils/uniqueIdGenerator.js";
|
|
|
11
11
|
export class SmartFilterDeserializer {
|
|
12
12
|
/**
|
|
13
13
|
* Creates a new SmartFilterDeserializer
|
|
14
|
-
* @param
|
|
14
|
+
* @param blockFactory - A function that creates a block of the given class name, or returns null if it cannot
|
|
15
15
|
* @param customInputBlockDeserializer - An optional custom deserializer for InputBlocks - if supplied and it returns null, the default deserializer will be used
|
|
16
16
|
*/
|
|
17
|
-
constructor(
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
20
|
-
this._blockDeserializersV1.set(InputBlock.ClassName, async (smartFilter, serializedBlock, engine) => {
|
|
21
|
-
if (customInputBlockDeserializer) {
|
|
22
|
-
const customDeserializerResult = await customInputBlockDeserializer(smartFilter, serializedBlock, engine);
|
|
23
|
-
if (customDeserializerResult !== null) {
|
|
24
|
-
return customDeserializerResult;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return inputBlockDeserializer(smartFilter, serializedBlock);
|
|
28
|
-
});
|
|
29
|
-
this._blockDeserializersV1.set(OutputBlock.ClassName, (smartFilter) => Promise.resolve(smartFilter.output.ownerBlock));
|
|
17
|
+
constructor(blockFactory, customInputBlockDeserializer) {
|
|
18
|
+
this._blockFactory = blockFactory;
|
|
19
|
+
this._customInputBlockDeserializer = customInputBlockDeserializer;
|
|
30
20
|
}
|
|
31
21
|
/**
|
|
32
22
|
* Deserializes a SmartFilter from a JSON object - can be safely called multiple times and has no side effects within the class.
|
|
@@ -36,7 +26,12 @@ export class SmartFilterDeserializer {
|
|
|
36
26
|
*/
|
|
37
27
|
async deserialize(engine, smartFilterJson) {
|
|
38
28
|
const serializedSmartFilter = smartFilterJson;
|
|
39
|
-
|
|
29
|
+
// Back-compat for the rename of version to formatVersion, didn't warrant a new version
|
|
30
|
+
if (serializedSmartFilter.version && serializedSmartFilter.formatVersion === undefined) {
|
|
31
|
+
serializedSmartFilter.formatVersion = serializedSmartFilter.version;
|
|
32
|
+
delete serializedSmartFilter.version;
|
|
33
|
+
}
|
|
34
|
+
switch (serializedSmartFilter.formatVersion) {
|
|
40
35
|
case 1:
|
|
41
36
|
return await this._deserializeV1(engine, serializedSmartFilter);
|
|
42
37
|
}
|
|
@@ -51,26 +46,15 @@ export class SmartFilterDeserializer {
|
|
|
51
46
|
smartFilter.editorData = serializedSmartFilter.editorData;
|
|
52
47
|
// Deserialize the blocks
|
|
53
48
|
const blockDeserializationWork = [];
|
|
49
|
+
const blockDefinitionsWhichCouldNotBeDeserialized = [];
|
|
54
50
|
serializedSmartFilter.blocks.forEach((serializedBlock) => {
|
|
55
|
-
|
|
56
|
-
if (!blockDeserializer) {
|
|
57
|
-
throw new Error(`No deserializer found for block type ${serializedBlock.className}`);
|
|
58
|
-
}
|
|
59
|
-
blockDeserializationWork.push(blockDeserializer(smartFilter, serializedBlock, engine).then((newBlock) => {
|
|
60
|
-
// Deserializers are not responsible for setting the uniqueId or comments.
|
|
61
|
-
// This is so they don't have to be passed into the constructors when programmatically creating
|
|
62
|
-
// blocks, and so each deserializer doesn't have to remember to do it.
|
|
63
|
-
newBlock.uniqueId = serializedBlock.uniqueId;
|
|
64
|
-
newBlock.comments = serializedBlock.comments;
|
|
65
|
-
// We need to ensure any uniqueIds generated in the future (e.g. a new block is added to the SmartFilter)
|
|
66
|
-
// are higher than this one.
|
|
67
|
-
UniqueIdGenerator.EnsureIdsGreaterThan(newBlock.uniqueId);
|
|
68
|
-
// Save in the map
|
|
69
|
-
blockIdMap.set(newBlock.uniqueId, newBlock);
|
|
70
|
-
blockNameMap.set(newBlock.name, newBlock);
|
|
71
|
-
}));
|
|
51
|
+
blockDeserializationWork.push(this._deserializeBlockV1(smartFilter, serializedBlock, engine, blockDefinitionsWhichCouldNotBeDeserialized, blockIdMap, blockNameMap));
|
|
72
52
|
});
|
|
73
53
|
await Promise.all(blockDeserializationWork);
|
|
54
|
+
// If any block definitions could not be deserialized, throw an error
|
|
55
|
+
if (blockDefinitionsWhichCouldNotBeDeserialized.length > 0) {
|
|
56
|
+
throw new Error(`Could not deserialize the following block definitions: ${blockDefinitionsWhichCouldNotBeDeserialized.join(", ")}`);
|
|
57
|
+
}
|
|
74
58
|
// Deserialize the connections
|
|
75
59
|
serializedSmartFilter.connections.forEach((connection) => {
|
|
76
60
|
// Find the source block and its connection point's connectTo function
|
|
@@ -80,7 +64,7 @@ export class SmartFilterDeserializer {
|
|
|
80
64
|
if (!sourceBlock) {
|
|
81
65
|
throw new Error(`Source block ${connection.outputBlock} not found`);
|
|
82
66
|
}
|
|
83
|
-
const sourceConnectionPoint = sourceBlock
|
|
67
|
+
const sourceConnectionPoint = sourceBlock.outputs.find((output) => output.name === connection.outputConnectionPoint);
|
|
84
68
|
if (!sourceConnectionPoint || typeof sourceConnectionPoint.connectTo !== "function") {
|
|
85
69
|
throw new Error(`Block ${connection.outputBlock} does not have an connection point named ${connection.outputConnectionPoint}`);
|
|
86
70
|
}
|
|
@@ -92,7 +76,7 @@ export class SmartFilterDeserializer {
|
|
|
92
76
|
if (!targetBlock) {
|
|
93
77
|
throw new Error(`Target block ${connection.inputBlock} not found`);
|
|
94
78
|
}
|
|
95
|
-
const targetConnectionPoint = targetBlock
|
|
79
|
+
const targetConnectionPoint = targetBlock.inputs.find((input) => input.name === connection.inputConnectionPoint);
|
|
96
80
|
if (!targetConnectionPoint || typeof targetConnectionPoint !== "object") {
|
|
97
81
|
throw new Error(`Block ${connection.inputBlock} does not have a connection point named ${connection.inputConnectionPoint}`);
|
|
98
82
|
}
|
|
@@ -101,5 +85,50 @@ export class SmartFilterDeserializer {
|
|
|
101
85
|
});
|
|
102
86
|
return smartFilter;
|
|
103
87
|
}
|
|
88
|
+
async _deserializeBlockV1(smartFilter, serializedBlock, engine, blockTypesWhichCouldNotBeDeserialized, blockIdMap, blockNameMap) {
|
|
89
|
+
let newBlock = null;
|
|
90
|
+
// Back compat for early Smart Filter V1 serialization where the blockType was stored in className
|
|
91
|
+
// Not worth creating a new version for this, as it's only used in the deserializer
|
|
92
|
+
if (serializedBlock.className && !serializedBlock.blockType) {
|
|
93
|
+
serializedBlock.blockType = serializedBlock.className;
|
|
94
|
+
}
|
|
95
|
+
// Get the instance of the block
|
|
96
|
+
switch (serializedBlock.blockType) {
|
|
97
|
+
case InputBlock.ClassName:
|
|
98
|
+
{
|
|
99
|
+
if (this._customInputBlockDeserializer) {
|
|
100
|
+
newBlock = await this._customInputBlockDeserializer(smartFilter, serializedBlock, engine);
|
|
101
|
+
}
|
|
102
|
+
if (newBlock === null) {
|
|
103
|
+
newBlock = inputBlockDeserializer(smartFilter, serializedBlock);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
case OutputBlock.ClassName:
|
|
108
|
+
{
|
|
109
|
+
newBlock = smartFilter.output.ownerBlock;
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
default: {
|
|
113
|
+
// If it's not an input or output block, use the provided block factory
|
|
114
|
+
newBlock = await this._blockFactory(smartFilter, engine, serializedBlock);
|
|
115
|
+
if (!newBlock) {
|
|
116
|
+
blockTypesWhichCouldNotBeDeserialized.push(serializedBlock.blockType);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Deserializers are not responsible for setting the uniqueId or comments.
|
|
122
|
+
// This is so they don't have to be passed into the constructors when programmatically creating
|
|
123
|
+
// blocks, and so each deserializer doesn't have to remember to do it.
|
|
124
|
+
newBlock.uniqueId = serializedBlock.uniqueId;
|
|
125
|
+
newBlock.comments = serializedBlock.comments;
|
|
126
|
+
// We need to ensure any uniqueIds generated in the future (e.g. a new block is added to the SmartFilter)
|
|
127
|
+
// are higher than this one.
|
|
128
|
+
UniqueIdGenerator.EnsureIdsGreaterThan(newBlock.uniqueId);
|
|
129
|
+
// Save in the map
|
|
130
|
+
blockIdMap.set(newBlock.uniqueId, newBlock);
|
|
131
|
+
blockNameMap.set(newBlock.name, newBlock);
|
|
132
|
+
}
|
|
104
133
|
}
|
|
105
134
|
//# sourceMappingURL=smartFilterDeserializer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartFilterDeserializer.js","sourceRoot":"","sources":["../../src/serialization/smartFilterDeserializer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"smartFilterDeserializer.js","sourceRoot":"","sources":["../../src/serialization/smartFilterDeserializer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CA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
|
|
1
1
|
import type { SmartFilter } from "../smartFilter";
|
|
2
|
-
import type { IBlockSerializerV1, SerializedSmartFilterV1 } from "./v1/
|
|
2
|
+
import type { IBlockSerializerV1, SerializedSmartFilterV1 } from "./v1/smartFilterSerialization.types";
|
|
3
3
|
/**
|
|
4
4
|
* Serializes SmartFilters using the latest SmartFilter serialization version.
|
|
5
5
|
* The caller passes in information necessary to serialize the blocks in the SmartFilter.
|
|
@@ -9,7 +9,7 @@ export declare class SmartFilterSerializer {
|
|
|
9
9
|
private readonly _blockSerializers;
|
|
10
10
|
/**
|
|
11
11
|
* Creates a new SmartFilterSerializer
|
|
12
|
-
* @param blocksUsingDefaultSerialization - A list of the
|
|
12
|
+
* @param blocksUsingDefaultSerialization - A list of the blockType of blocks which can use default serialization (they only have ConnectionPoint properties and no constructor parameters)
|
|
13
13
|
* @param additionalBlockSerializers - An array of block serializers to use, beyond those for the core blocks
|
|
14
14
|
*/
|
|
15
15
|
constructor(blocksUsingDefaultSerialization: string[], additionalBlockSerializers: IBlockSerializerV1[]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartFilterSerializer.d.ts","sourceRoot":"","sources":["../../src/serialization/smartFilterSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMlD,OAAO,KAAK,EACR,kBAAkB,EAIlB,uBAAuB,EAC1B,MAAM,
|
|
1
|
+
{"version":3,"file":"smartFilterSerializer.d.ts","sourceRoot":"","sources":["../../src/serialization/smartFilterSerializer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAMlD,OAAO,KAAK,EACR,kBAAkB,EAIlB,uBAAuB,EAC1B,MAAM,qCAAqC,CAAC;AAkB7C;;;;GAIG;AACH,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAA4C;IAE9E;;;;OAIG;gBACgB,+BAA+B,EAAE,MAAM,EAAE,EAAE,0BAA0B,EAAE,kBAAkB,EAAE;IAW9G;;;;OAIG;IACI,SAAS,CAAC,WAAW,EAAE,WAAW,GAAG,uBAAuB;CAyDtE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { inputBlockSerializer } from "../blocks/inputBlock.serializer.js";
|
|
2
2
|
import { defaultBlockSerializer } from "./v1/defaultBlockSerializer.js";
|
|
3
3
|
import { OutputBlock } from "../blocks/outputBlock.js";
|
|
4
|
+
import { CustomShaderBlock } from "../blocks/customShaderBlock.js";
|
|
4
5
|
/**
|
|
5
6
|
* Determines if two serialized connection points are equivalent to each other
|
|
6
7
|
* @param a - The first connection point to compare
|
|
@@ -21,17 +22,17 @@ function serializedConnectionPointsEqual(a, b) {
|
|
|
21
22
|
export class SmartFilterSerializer {
|
|
22
23
|
/**
|
|
23
24
|
* Creates a new SmartFilterSerializer
|
|
24
|
-
* @param blocksUsingDefaultSerialization - A list of the
|
|
25
|
+
* @param blocksUsingDefaultSerialization - A list of the blockType of blocks which can use default serialization (they only have ConnectionPoint properties and no constructor parameters)
|
|
25
26
|
* @param additionalBlockSerializers - An array of block serializers to use, beyond those for the core blocks
|
|
26
27
|
*/
|
|
27
28
|
constructor(blocksUsingDefaultSerialization, additionalBlockSerializers) {
|
|
28
29
|
this._blockSerializers = new Map();
|
|
29
|
-
this._blockSerializers.set(inputBlockSerializer.
|
|
30
|
+
this._blockSerializers.set(inputBlockSerializer.blockType, inputBlockSerializer.serialize);
|
|
30
31
|
this._blockSerializers.set(OutputBlock.ClassName, defaultBlockSerializer);
|
|
31
32
|
blocksUsingDefaultSerialization.forEach((block) => {
|
|
32
33
|
this._blockSerializers.set(block, defaultBlockSerializer);
|
|
33
34
|
});
|
|
34
|
-
additionalBlockSerializers.forEach((serializer) => this._blockSerializers.set(serializer.
|
|
35
|
+
additionalBlockSerializers.forEach((serializer) => this._blockSerializers.set(serializer.blockType, serializer.serialize));
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Serializes a SmartFilter to a JSON object of the latest version
|
|
@@ -42,9 +43,11 @@ export class SmartFilterSerializer {
|
|
|
42
43
|
const connections = [];
|
|
43
44
|
const blocks = smartFilter.attachedBlocks.map((block) => {
|
|
44
45
|
// Serialize the block itself
|
|
45
|
-
const serializeFn =
|
|
46
|
+
const serializeFn = block.getClassName() === CustomShaderBlock.ClassName
|
|
47
|
+
? defaultBlockSerializer
|
|
48
|
+
: this._blockSerializers.get(block.blockType);
|
|
46
49
|
if (!serializeFn) {
|
|
47
|
-
throw new Error(`No serializer was provided for a block of type ${block.
|
|
50
|
+
throw new Error(`No serializer was provided for a block of type ${block.blockType}`);
|
|
48
51
|
}
|
|
49
52
|
const serializedBlock = serializeFn(block);
|
|
50
53
|
// Serialize the connections to the inputs
|
|
@@ -79,7 +82,7 @@ export class SmartFilterSerializer {
|
|
|
79
82
|
return serializedBlock;
|
|
80
83
|
});
|
|
81
84
|
return {
|
|
82
|
-
|
|
85
|
+
formatVersion: 1,
|
|
83
86
|
name: smartFilter.name,
|
|
84
87
|
comments: smartFilter.comments,
|
|
85
88
|
editorData: smartFilter.editorData,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smartFilterSerializer.js","sourceRoot":"","sources":["../../src/serialization/smartFilterSerializer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"smartFilterSerializer.js","sourceRoot":"","sources":["../../src/serialization/smartFilterSerializer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,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,WAAW,EAAE,KAAK,CAAC,QAAQ;wBAC3B,qBAAqB,EAAE,MAAM,CAAC,IAAI;qBACrC,CAAC;oBACF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,+BAA+B,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;wBACtF,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;oBACpC,CAAC;gBACL,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;YAEH,OAAO,eAAe,CAAC;QAC3B,CAAC,CAAC,CAAC;QAEH,OAAO;YACH,aAAa,EAAE,CAAC;YAChB,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,QAAQ,EAAE,WAAW,CAAC,QAAQ;YAC9B,UAAU,EAAE,WAAW,CAAC,UAAU;YAClC,MAAM;YACN,WAAW;SACd,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Data Types Used For Block Serialization
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
*/
|
|
6
|
+
import type { AllConnectionPointTypes, ConnectionPointValue } from "../../connection/connectionPointType";
|
|
7
|
+
import type { ShaderProgram } from "../../utils/shaderCodeUtils";
|
|
8
|
+
/**
|
|
9
|
+
* The V1 definition of a serialized block. A block definition is loaded by a CustomShaderBlock and defines how a
|
|
10
|
+
* blockType works. This should not be confused with an ISerializedBockV1, which is a serialized instance of a block in a
|
|
11
|
+
* serialized SmartFilter graph. It is referenced by blockType in a serialized SmartFilter.
|
|
12
|
+
*/
|
|
13
|
+
export type SerializedBlockDefinitionV1 = {
|
|
14
|
+
/**
|
|
15
|
+
* The version of the block definition format (format of the serialized data, not the version of the block definition itself).
|
|
16
|
+
*/
|
|
17
|
+
formatVersion: 1;
|
|
18
|
+
/**
|
|
19
|
+
* The type used to refer to the block in serialized SmartFilters and in the editor UI.
|
|
20
|
+
* The application doing the deserialization will use this to instantiate the correct block definition.
|
|
21
|
+
* Block types are expected to be unique and their behavior should be semantically equivalent across implementations
|
|
22
|
+
* (their results must be similar enough that the differences are not perceivable).
|
|
23
|
+
*/
|
|
24
|
+
blockType: string;
|
|
25
|
+
/**
|
|
26
|
+
* The shader program for the block.
|
|
27
|
+
*/
|
|
28
|
+
shaderProgram: ShaderProgram;
|
|
29
|
+
/**
|
|
30
|
+
* The input connection points of the block.
|
|
31
|
+
*/
|
|
32
|
+
inputConnectionPoints: SerializedInputConnectionPointV1[];
|
|
33
|
+
/**
|
|
34
|
+
* If true, the optimizer will not attempt to optimize this block.
|
|
35
|
+
*/
|
|
36
|
+
disableOptimization: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A V1 input connection point of a serialized block definition.
|
|
40
|
+
*/
|
|
41
|
+
export type SerializedInputConnectionPointV1<U extends AllConnectionPointTypes = AllConnectionPointTypes> = {
|
|
42
|
+
/**
|
|
43
|
+
* The name of the connection point.
|
|
44
|
+
*/
|
|
45
|
+
name: string;
|
|
46
|
+
/**
|
|
47
|
+
* The type of the connection point.
|
|
48
|
+
*/
|
|
49
|
+
type: U;
|
|
50
|
+
/**
|
|
51
|
+
* The optional default value of the connection point.
|
|
52
|
+
*/
|
|
53
|
+
defaultValue?: ConnectionPointValue<U>;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=blockSerialization.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockSerialization.types.d.ts","sourceRoot":"","sources":["../../../src/serialization/v1/blockSerialization.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC1G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACtC;;OAEG;IACH,aAAa,EAAE,CAAC,CAAC;IAEjB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;IAE7B;;OAEG;IACH,qBAAqB,EAAE,gCAAgC,EAAE,CAAC;IAE1D;;OAEG;IACH,mBAAmB,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gCAAgC,CAAC,CAAC,SAAS,uBAAuB,GAAG,uBAAuB,IAAI;IACxG;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC;IAER;;OAEG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;CAC1C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ----------------------------------------------------------------------------
|
|
3
|
+
* Data Types Used For Block Serialization
|
|
4
|
+
* ----------------------------------------------------------------------------
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=blockSerialization.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blockSerialization.types.js","sourceRoot":"","sources":["../../../src/serialization/v1/blockSerialization.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SerializeBlockV1 } from "./
|
|
1
|
+
import type { SerializeBlockV1 } from "./smartFilterSerialization.types";
|
|
2
2
|
/**
|
|
3
3
|
* The default V1 block serializer which can be used for any block that relies only on ConnectionPoints
|
|
4
4
|
* and does not have any constructor parameters or class properties that need to be serialized.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultBlockSerializer.d.ts","sourceRoot":"","sources":["../../../src/serialization/v1/defaultBlockSerializer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"defaultBlockSerializer.d.ts","sourceRoot":"","sources":["../../../src/serialization/v1/defaultBlockSerializer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAsB,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAE7F;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,EAAE,gBAQpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultBlockSerializer.js","sourceRoot":"","sources":["../../../src/serialization/v1/defaultBlockSerializer.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAqB,CAAC,KAAgB,EAAsB,EAAE;IAC7F,OAAO;QACH,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"defaultBlockSerializer.js","sourceRoot":"","sources":["../../../src/serialization/v1/defaultBlockSerializer.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAqB,CAAC,KAAgB,EAAsB,EAAE;IAC7F,OAAO;QACH,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,IAAI,EAAE,SAAS;KAClB,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/serialization/v1/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/serialization/v1/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/serialization/v1/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/serialization/v1/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qCAAqC,CAAC"}
|
package/dist/serialization/v1/{serialization.types.d.ts → smartFilterSerialization.types.d.ts}
RENAMED
|
@@ -12,8 +12,8 @@ import type { IEditorData } from "@babylonjs/shared-ui-components/nodeGraphSyste
|
|
|
12
12
|
* V1 Serialized Smart Filter
|
|
13
13
|
*/
|
|
14
14
|
export type SerializedSmartFilterV1 = {
|
|
15
|
-
/** The version of the serialized data
|
|
16
|
-
|
|
15
|
+
/** The format version of the serialized data (not the version of the SmartFilter itself).*/
|
|
16
|
+
formatVersion: 1;
|
|
17
17
|
/** The SmartFilter name */
|
|
18
18
|
name: string;
|
|
19
19
|
/** The SmartFilter comments */
|
|
@@ -26,15 +26,16 @@ export type SerializedSmartFilterV1 = {
|
|
|
26
26
|
connections: ISerializedConnectionV1[];
|
|
27
27
|
};
|
|
28
28
|
/**
|
|
29
|
-
* V1
|
|
29
|
+
* V1 format of a block in a serialized Smart Filter.
|
|
30
|
+
* Not to be confused with a SerializedBlockDefinitionV1 which serializes the definition of a CustomShaderBlock.
|
|
30
31
|
*/
|
|
31
32
|
export interface ISerializedBlockV1 {
|
|
32
33
|
/** The name of the block */
|
|
33
34
|
name: string;
|
|
34
35
|
/** The unique ID of the block - correlates with the ID in the editorData for block position, etc. */
|
|
35
36
|
uniqueId: number;
|
|
36
|
-
/** The
|
|
37
|
-
|
|
37
|
+
/** The blockType of the block - used to determine how to instantiate the block during deserialization */
|
|
38
|
+
blockType: string;
|
|
38
39
|
/** The comments for the block */
|
|
39
40
|
comments: Nullable<string>;
|
|
40
41
|
/** Block specific serialized data */
|
|
@@ -63,12 +64,12 @@ export interface ISerializedConnectionV1 {
|
|
|
63
64
|
*/
|
|
64
65
|
export type SerializeBlockV1 = (block: BaseBlock) => ISerializedBlockV1;
|
|
65
66
|
/**
|
|
66
|
-
* A V1
|
|
67
|
+
* A V1 serializer for blocks in a SmartFilter
|
|
67
68
|
*/
|
|
68
69
|
export interface IBlockSerializerV1 {
|
|
69
|
-
/** The
|
|
70
|
-
|
|
71
|
-
/** The function that serializes the block */
|
|
70
|
+
/** The blockType of the block that this serializer can serialize */
|
|
71
|
+
blockType: string;
|
|
72
|
+
/** The function that serializes the block in the Smart Filter */
|
|
72
73
|
serialize: SerializeBlockV1;
|
|
73
74
|
}
|
|
74
75
|
/**
|
|
@@ -77,11 +78,11 @@ export interface IBlockSerializerV1 {
|
|
|
77
78
|
* ----------------------------------------------------------------------------
|
|
78
79
|
*/
|
|
79
80
|
/**
|
|
80
|
-
* A function that deserializes a block
|
|
81
|
+
* A function that deserializes a V1 block in a SmartFilter
|
|
81
82
|
*/
|
|
82
83
|
export type DeserializeBlockV1 = (smartFilter: SmartFilter, serializedBlock: ISerializedBlockV1, engine: ThinEngine) => Promise<BaseBlock>;
|
|
83
84
|
/**
|
|
84
85
|
* A function that optionally deserializes a block from a V1 serialized block object, returning null if it cannot
|
|
85
86
|
*/
|
|
86
87
|
export type OptionalBlockDeserializerV1 = (smartFilter: SmartFilter, serializedBlock: ISerializedBlockV1, engine: ThinEngine) => Promise<Nullable<BaseBlock>>;
|
|
87
|
-
//# sourceMappingURL=
|
|
88
|
+
//# sourceMappingURL=smartFilterSerialization.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smartFilterSerialization.types.d.ts","sourceRoot":"","sources":["../../../src/serialization/v1/smartFilterSerialization.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;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AAW,kBAAkB;IAC/B,oEAAoE;IACpE,SAAS,EAAE,MAAM,CAAC;IAElB,iEAAiE;IACjE,SAAS,EAAE,gBAAgB,CAAC;CAC/B;AAED;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAC7B,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,kBAAkB,EACnC,MAAM,EAAE,UAAU,KACjB,OAAO,CAAC,SAAS,CAAC,CAAC;AAExB;;GAEG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACtC,WAAW,EAAE,WAAW,EACxB,eAAe,EAAE,kBAAkB,EACnC,MAAM,EAAE,UAAU,KACjB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smartFilterSerialization.types.js","sourceRoot":"","sources":["../../../src/serialization/v1/smartFilterSerialization.types.ts"],"names":[],"mappings":""}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* @param importPath - The path to import the converted shaders
|
|
5
5
|
* @example node buildShaders.js <shaderPath> <importPath>
|
|
6
6
|
*/
|
|
7
|
-
import { convertShaders } from "./
|
|
7
|
+
import { convertShaders } from "./convertShaderForHardcodedBlock.js";
|
|
8
8
|
const externalArguments = process.argv.slice(2);
|
|
9
9
|
if (externalArguments.length >= 2 && externalArguments[0] && externalArguments[1]) {
|
|
10
10
|
convertShaders(externalArguments[0], externalArguments[1]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildShaders.js","sourceRoot":"","sources":["../../../src/utils/buildTools/buildShaders.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"buildShaders.js","sourceRoot":"","sources":["../../../src/utils/buildTools/buildShaders.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,MAAM,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAChD,IAAI,iBAAiB,CAAC,MAAM,IAAI,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;IAChF,cAAc,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a single shader to a .ts file which can be imported by a hardcoded block
|
|
3
|
+
* @param fragmentShaderPath - The path to the fragment file for the shader
|
|
4
|
+
* @param importPath - The path to import the ShaderProgram type from
|
|
5
|
+
*/
|
|
6
|
+
export declare function convertShaderForHardcodedBlock(fragmentShaderPath: string, importPath: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* Converts .fragment.glsl and vertex.glsl file pairs into .shader.ts files which export a ShaderProgram object.
|
|
9
|
+
* @param shaderPath - The path to the .glsl files to convert.
|
|
10
|
+
* @param importPath - The path to import the ShaderProgram type from.
|
|
11
|
+
*/
|
|
12
|
+
export declare function convertShaders(shaderPath: string, importPath: string): void;
|
|
13
|
+
//# sourceMappingURL=convertShaderForHardcodedBlock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertShaderForHardcodedBlock.d.ts","sourceRoot":"","sources":["../../../src/utils/buildTools/convertShaderForHardcodedBlock.ts"],"names":[],"mappings":"AA0DA;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAoDnG;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAapE"}
|