@babylonjs/smart-filters 0.7.3-alpha → 0.7.5-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.
Files changed (84) hide show
  1. package/dist/blocks/aggregateBlock.d.ts.map +1 -1
  2. package/dist/blocks/aggregateBlock.js +10 -0
  3. package/dist/blocks/aggregateBlock.js.map +1 -1
  4. package/dist/blocks/baseBlock.d.ts +10 -0
  5. package/dist/blocks/baseBlock.d.ts.map +1 -1
  6. package/dist/blocks/baseBlock.js +13 -0
  7. package/dist/blocks/baseBlock.js.map +1 -1
  8. package/dist/blocks/customAggregateBlock.d.ts +9 -2
  9. package/dist/blocks/customAggregateBlock.d.ts.map +1 -1
  10. package/dist/blocks/customAggregateBlock.js +14 -6
  11. package/dist/blocks/customAggregateBlock.js.map +1 -1
  12. package/dist/blocks/customShaderBlock.d.ts +8 -0
  13. package/dist/blocks/customShaderBlock.d.ts.map +1 -1
  14. package/dist/blocks/customShaderBlock.js +11 -2
  15. package/dist/blocks/customShaderBlock.js.map +1 -1
  16. package/dist/blocks/inputBlock.d.ts +6 -1
  17. package/dist/blocks/inputBlock.d.ts.map +1 -1
  18. package/dist/blocks/inputBlock.deserializer.d.ts +1 -1
  19. package/dist/blocks/inputBlock.deserializer.d.ts.map +1 -1
  20. package/dist/blocks/inputBlock.deserializer.js +46 -27
  21. package/dist/blocks/inputBlock.deserializer.js.map +1 -1
  22. package/dist/blocks/inputBlock.js +5 -0
  23. package/dist/blocks/inputBlock.js.map +1 -1
  24. package/dist/blocks/inputBlock.serialization.types.d.ts +16 -6
  25. package/dist/blocks/inputBlock.serialization.types.d.ts.map +1 -1
  26. package/dist/blocks/inputBlock.serializer.d.ts.map +1 -1
  27. package/dist/blocks/inputBlock.serializer.js +7 -0
  28. package/dist/blocks/inputBlock.serializer.js.map +1 -1
  29. package/dist/connection/connectionPoint.d.ts +3 -3
  30. package/dist/connection/connectionPoint.js +3 -3
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +1 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/serialization/importCustomBlockDefinition.js +1 -0
  36. package/dist/serialization/importCustomBlockDefinition.js.map +1 -1
  37. package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -1
  38. package/dist/serialization/smartFilterDeserializer.js +8 -3
  39. package/dist/serialization/smartFilterDeserializer.js.map +1 -1
  40. package/dist/serialization/smartFilterSerializer.d.ts.map +1 -1
  41. package/dist/serialization/smartFilterSerializer.js +1 -0
  42. package/dist/serialization/smartFilterSerializer.js.map +1 -1
  43. package/dist/serialization/v1/defaultBlockSerializer.d.ts.map +1 -1
  44. package/dist/serialization/v1/defaultBlockSerializer.js +1 -0
  45. package/dist/serialization/v1/defaultBlockSerializer.js.map +1 -1
  46. package/dist/serialization/v1/shaderBlockSerialization.types.d.ts +6 -0
  47. package/dist/serialization/v1/shaderBlockSerialization.types.d.ts.map +1 -1
  48. package/dist/serialization/v1/smartFilterSerialization.types.d.ts +4 -0
  49. package/dist/serialization/v1/smartFilterSerialization.types.d.ts.map +1 -1
  50. package/dist/smartFilter.d.ts +6 -1
  51. package/dist/smartFilter.d.ts.map +1 -1
  52. package/dist/smartFilter.js +3 -1
  53. package/dist/smartFilter.js.map +1 -1
  54. package/dist/utils/buildTools/shaderConverter.d.ts +5 -0
  55. package/dist/utils/buildTools/shaderConverter.d.ts.map +1 -1
  56. package/dist/utils/buildTools/shaderConverter.js +2 -0
  57. package/dist/utils/buildTools/shaderConverter.js.map +1 -1
  58. package/dist/utils/buildTools/versionUp.js +7 -0
  59. package/dist/utils/buildTools/versionUp.js.map +1 -1
  60. package/dist/version.d.ts +5 -0
  61. package/dist/version.d.ts.map +1 -0
  62. package/dist/version.js +5 -0
  63. package/dist/version.js.map +1 -0
  64. package/package.json +1 -1
  65. package/src/blocks/aggregateBlock.ts +9 -0
  66. package/src/blocks/baseBlock.ts +15 -0
  67. package/src/blocks/customAggregateBlock.ts +24 -5
  68. package/src/blocks/customShaderBlock.ts +13 -0
  69. package/src/blocks/inputBlock.deserializer.ts +72 -33
  70. package/src/blocks/inputBlock.serialization.types.ts +17 -6
  71. package/src/blocks/inputBlock.serializer.ts +7 -0
  72. package/src/blocks/inputBlock.ts +7 -1
  73. package/src/connection/connectionPoint.ts +3 -3
  74. package/src/index.ts +1 -0
  75. package/src/serialization/importCustomBlockDefinition.ts +1 -0
  76. package/src/serialization/smartFilterDeserializer.ts +9 -3
  77. package/src/serialization/smartFilterSerializer.ts +1 -0
  78. package/src/serialization/v1/defaultBlockSerializer.ts +1 -0
  79. package/src/serialization/v1/shaderBlockSerialization.types.ts +7 -0
  80. package/src/serialization/v1/smartFilterSerialization.types.ts +6 -0
  81. package/src/smartFilter.ts +8 -1
  82. package/src/utils/buildTools/shaderConverter.ts +12 -0
  83. package/src/utils/buildTools/versionUp.ts +8 -0
  84. package/src/version.ts +4 -0
@@ -29,6 +29,12 @@ export abstract class BaseBlock implements ICommandOwner {
29
29
  */
30
30
  public static ClassName = "BaseBlock";
31
31
 
32
+ /**
33
+ * The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
34
+ * By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
35
+ */
36
+ public static Namespace: Nullable<string> = null;
37
+
32
38
  /**
33
39
  * The smart filter the block belongs to.
34
40
  */
@@ -53,6 +59,15 @@ export abstract class BaseBlock implements ICommandOwner {
53
59
  return this.getClassName();
54
60
  }
55
61
 
62
+ /**
63
+ * The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
64
+ * By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
65
+ */
66
+ public get namespace(): Nullable<string> {
67
+ // Note that we use a static property instead of doing this.constructor.name to avoid problems with minifiers that would change the name of the class
68
+ return (this.constructor as typeof BaseBlock).Namespace;
69
+ }
70
+
56
71
  /**
57
72
  * User provided comments about the block. It can be used to document the block.
58
73
  */
@@ -3,14 +3,15 @@ import type { SmartFilterDeserializer, SerializedBlockDefinition } from "../seri
3
3
  import type { SmartFilter } from "../smartFilter.js";
4
4
  import { AggregateBlock } from "./aggregateBlock.js";
5
5
  import type { BaseBlock } from "./baseBlock.js";
6
+ import type { Nullable } from "@babylonjs/core/types.js";
6
7
 
7
8
  /**
8
- * Loads a serialized SmartFilter into a block which can be used in another SmartFilter.
9
+ * Loads a serialized Smart Filter into a block which can be used in another SmartFilter.
9
10
  */
10
11
  export class CustomAggregateBlock extends AggregateBlock {
11
12
  /**
12
13
  * Creates a new CustomAggregateBlock
13
- * @param smartFilter - The SmartFilter to create the block for
14
+ * @param smartFilter - The Smart Filter to create the block for
14
15
  * @param engine - The ThinEngine to use
15
16
  * @param name - The friendly name of the block
16
17
  * @param serializedSmartFilter - The serialized SmartFilter to load into the block
@@ -25,7 +26,14 @@ export class CustomAggregateBlock extends AggregateBlock {
25
26
  smartFilterDeserializer: SmartFilterDeserializer
26
27
  ): Promise<BaseBlock> {
27
28
  const innerSmartFilter = await smartFilterDeserializer.deserialize(engine, serializedSmartFilter);
28
- return new CustomAggregateBlock(smartFilter, name, serializedSmartFilter.blockType, innerSmartFilter, false);
29
+ return new CustomAggregateBlock(
30
+ smartFilter,
31
+ name,
32
+ serializedSmartFilter.blockType,
33
+ serializedSmartFilter.namespace,
34
+ innerSmartFilter,
35
+ false
36
+ );
29
37
  }
30
38
 
31
39
  /**
@@ -34,6 +42,7 @@ export class CustomAggregateBlock extends AggregateBlock {
34
42
  public static override ClassName = "CustomAggregateBlock";
35
43
 
36
44
  private readonly _blockType: string;
45
+ private readonly _namespace: Nullable<string>;
37
46
 
38
47
  /**
39
48
  * The type of the block - used when serializing / deserializing the block, and in the editor.
@@ -42,16 +51,26 @@ export class CustomAggregateBlock extends AggregateBlock {
42
51
  return this._blockType;
43
52
  }
44
53
 
54
+ /**
55
+ * The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
56
+ * By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
57
+ */
58
+ public override get namespace(): Nullable<string> {
59
+ return this._namespace;
60
+ }
61
+
45
62
  private constructor(
46
63
  smartFilter: SmartFilter,
47
64
  name: string,
48
65
  blockType: string,
66
+ namespace: Nullable<string>,
49
67
  innerSmartFilter: SmartFilter,
50
68
  disableOptimization: boolean
51
69
  ) {
52
70
  super(smartFilter, name, disableOptimization);
53
71
 
54
72
  this._blockType = blockType;
73
+ this._namespace = namespace;
55
74
 
56
75
  const attachedBlocks = innerSmartFilter.attachedBlocks;
57
76
  for (let index = 0; index < attachedBlocks.length; index++) {
@@ -66,7 +85,7 @@ export class CustomAggregateBlock extends AggregateBlock {
66
85
  );
67
86
  }
68
87
 
69
- // Remove this input block from the smart filter graph - this will reset the runtimeData to the
88
+ // Remove this input block from the Smart Filter graph - this will reset the runtimeData to the
70
89
  // default for that connection point (which may be null)
71
90
  innerSmartFilter.removeBlock(block);
72
91
  index--;
@@ -79,7 +98,7 @@ export class CustomAggregateBlock extends AggregateBlock {
79
98
 
80
99
  this._registerSubfilterOutput("output", innerSmartFilter.output.connectedTo);
81
100
 
82
- // Disconnect the inner smart filter output from the inner smart filter
101
+ // Disconnect the inner Smart Filter output from the inner Smart Filter
83
102
  innerSmartFilter.output.connectedTo.disconnectFrom(innerSmartFilter.output);
84
103
  }
85
104
  }
@@ -101,6 +101,7 @@ export class CustomShaderBlock extends ShaderBlock {
101
101
  name,
102
102
  blockDefinition.disableOptimization,
103
103
  blockDefinition.blockType,
104
+ blockDefinition.namespace,
104
105
  blockDefinition.inputConnectionPoints,
105
106
  blockDefinition.shaderProgram
106
107
  );
@@ -113,6 +114,7 @@ export class CustomShaderBlock extends ShaderBlock {
113
114
 
114
115
  private readonly _shaderProgram: ShaderProgram;
115
116
  private readonly _blockType: string;
117
+ private readonly _namespace: Nullable<string>;
116
118
  private _autoBoundInputs: Nullable<SerializedInputConnectionPointV1[]> = null;
117
119
 
118
120
  /**
@@ -122,12 +124,21 @@ export class CustomShaderBlock extends ShaderBlock {
122
124
  return this._blockType;
123
125
  }
124
126
 
127
+ /**
128
+ * The namespace of the block, which is used to reduce name collisions between blocks and also to group blocks in the editor UI.
129
+ * By convention, sub namespaces are separated by a period (e.g. "Babylon.Demo.Effects").
130
+ */
131
+ public override get namespace(): Nullable<string> {
132
+ return this._namespace;
133
+ }
134
+
125
135
  /**
126
136
  * Instantiates a new custom shader block.
127
137
  * @param smartFilter - The smart filter this block belongs to
128
138
  * @param name - The name of the block
129
139
  * @param disableOptimization - If true, this optimizer will not attempt to optimize this block
130
140
  * @param blockType - The type of the block
141
+ * @param namespace - The namespace of the block
131
142
  * @param inputConnectionPoints - The input connection points of the
132
143
  * @param shaderProgram - The shader program for the block
133
144
  */
@@ -136,11 +147,13 @@ export class CustomShaderBlock extends ShaderBlock {
136
147
  name: string,
137
148
  disableOptimization: boolean,
138
149
  blockType: string,
150
+ namespace: Nullable<string>,
139
151
  inputConnectionPoints: SerializedInputConnectionPointV1[],
140
152
  shaderProgram: ShaderProgram
141
153
  ) {
142
154
  super(smartFilter, name, disableOptimization);
143
155
  this._blockType = blockType;
156
+ this._namespace = namespace;
144
157
 
145
158
  for (const input of inputConnectionPoints) {
146
159
  this._registerSerializedInputConnectionPointV1(input);
@@ -12,46 +12,85 @@ import type { ISerializedBlockV1 } from "../serialization/v1/smartFilterSerializ
12
12
  */
13
13
  export function inputBlockDeserializer(smartFilter: SmartFilter, serializedBlock: ISerializedBlockV1) {
14
14
  const blockData = serializedBlock.data as SerializedInputBlockData;
15
+ let inputBlock;
15
16
 
16
17
  switch (blockData.inputType) {
17
18
  case ConnectionPointType.Boolean:
18
- return new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Boolean, blockData.value);
19
- case ConnectionPointType.Float: {
20
- const inputBlock = new InputBlock(
21
- smartFilter,
22
- serializedBlock.name,
23
- ConnectionPointType.Float,
24
- blockData.value
25
- );
26
- inputBlock.editorData = {
27
- animationType: blockData.animationType,
28
- valueDeltaPerMs: blockData.valueDeltaPerMs,
29
- min: blockData.min,
30
- max: blockData.max,
31
- };
32
- return inputBlock;
33
- }
34
- case ConnectionPointType.Texture: {
35
- // Create the input block
36
- const inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Texture, null);
19
+ {
20
+ inputBlock = new InputBlock(
21
+ smartFilter,
22
+ serializedBlock.name,
23
+ ConnectionPointType.Boolean,
24
+ blockData.value
25
+ );
26
+ }
27
+ break;
28
+ case ConnectionPointType.Float:
29
+ {
30
+ inputBlock = new InputBlock(
31
+ smartFilter,
32
+ serializedBlock.name,
33
+ ConnectionPointType.Float,
34
+ blockData.value
35
+ );
36
+ inputBlock.editorData = {
37
+ animationType: blockData.animationType,
38
+ valueDeltaPerMs: blockData.valueDeltaPerMs,
39
+ min: blockData.min,
40
+ max: blockData.max,
41
+ };
42
+ }
43
+ break;
44
+ case ConnectionPointType.Texture:
45
+ {
46
+ // Create the input block
47
+ inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Texture, null);
37
48
 
38
- // If editor data was serialized, set it on the deserialized block
39
- inputBlock.editorData = {
40
- url: blockData.url,
41
- urlTypeHint: blockData.urlTypeHint,
42
- anisotropicFilteringLevel: blockData.anisotropicFilteringLevel,
43
- flipY: blockData.flipY,
44
- forcedExtension: blockData.forcedExtension,
45
- };
46
-
47
- return inputBlock;
48
- }
49
+ // If editor data was serialized, set it on the deserialized block
50
+ inputBlock.editorData = {
51
+ url: blockData.url,
52
+ urlTypeHint: blockData.urlTypeHint,
53
+ anisotropicFilteringLevel: blockData.anisotropicFilteringLevel,
54
+ flipY: blockData.flipY,
55
+ forcedExtension: blockData.forcedExtension,
56
+ };
57
+ }
58
+ break;
49
59
  case ConnectionPointType.Color3:
50
- return new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Color3, blockData.value);
60
+ {
61
+ inputBlock = new InputBlock(
62
+ smartFilter,
63
+ serializedBlock.name,
64
+ ConnectionPointType.Color3,
65
+ blockData.value
66
+ );
67
+ }
68
+ break;
51
69
  case ConnectionPointType.Color4:
52
- return new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Color4, blockData.value);
70
+ {
71
+ inputBlock = new InputBlock(
72
+ smartFilter,
73
+ serializedBlock.name,
74
+ ConnectionPointType.Color4,
75
+ blockData.value
76
+ );
77
+ }
78
+ break;
53
79
  case ConnectionPointType.Vector2:
54
- return new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Vector2, blockData.value);
80
+ {
81
+ inputBlock = new InputBlock(
82
+ smartFilter,
83
+ serializedBlock.name,
84
+ ConnectionPointType.Vector2,
85
+ blockData.value
86
+ );
87
+ }
88
+ break;
89
+ }
90
+ if (inputBlock) {
91
+ inputBlock.appMetadata = blockData.appMetadata;
92
+
93
+ return inputBlock;
55
94
  }
56
95
 
57
96
  throw new Error("Could not deserialize input block, unknown input type");
@@ -2,10 +2,21 @@ import type { Nullable } from "@babylonjs/core/types.js";
2
2
  import type { ConnectionPointType } from "../connection/connectionPointType.js";
3
3
  import type { IColor3Like, IColor4Like, IVector2Like } from "@babylonjs/core/Maths/math.like.js";
4
4
 
5
+ /**
6
+ * Data that all serialized InputBlocks share
7
+ */
8
+ export type CommonInputBlockData = {
9
+ /**
10
+ * Metadata the hosting app wants to track for this input. For example, a hint for what data to
11
+ * assign to this input, or hints about how to draw dynamic UI to allow users to control this value.
12
+ */
13
+ appMetadata: unknown;
14
+ };
15
+
5
16
  /**
6
17
  * The data for an InputBlock for ConnectionPointType.Texture inputs
7
18
  */
8
- export type TextureInputBlockData = {
19
+ export type TextureInputBlockData = CommonInputBlockData & {
9
20
  /** The type of the input block */
10
21
  inputType: ConnectionPointType.Texture;
11
22
 
@@ -37,7 +48,7 @@ export type TextureInputBlockData = {
37
48
  /**
38
49
  * The data for an InputBlock for ConnectionPointType.Boolean inputs
39
50
  */
40
- export type BooleanInputBlockData = {
51
+ export type BooleanInputBlockData = CommonInputBlockData & {
41
52
  /** The type of the input block */
42
53
  inputType: ConnectionPointType.Boolean;
43
54
 
@@ -48,7 +59,7 @@ export type BooleanInputBlockData = {
48
59
  /**
49
60
  * The data for an InputBlock for ConnectionPointType.Float inputs
50
61
  */
51
- export type FloatInputBlockData = {
62
+ export type FloatInputBlockData = CommonInputBlockData & {
52
63
  /** The type of the input block */
53
64
  inputType: ConnectionPointType.Float;
54
65
 
@@ -79,7 +90,7 @@ export type FloatInputBlockData = {
79
90
  /**
80
91
  * The data for an InputBlock for ConnectionPointType.Color3 inputs
81
92
  */
82
- export type Color3InputBlockData = {
93
+ export type Color3InputBlockData = CommonInputBlockData & {
83
94
  /** The type of the input block */
84
95
  inputType: ConnectionPointType.Color3;
85
96
 
@@ -90,7 +101,7 @@ export type Color3InputBlockData = {
90
101
  /**
91
102
  * The data for an InputBlock for ConnectionPointType.Color4 inputs
92
103
  */
93
- export type Color4InputBlockData = {
104
+ export type Color4InputBlockData = CommonInputBlockData & {
94
105
  /** The type of the input block */
95
106
  inputType: ConnectionPointType.Color4;
96
107
 
@@ -101,7 +112,7 @@ export type Color4InputBlockData = {
101
112
  /**
102
113
  * The data for an InputBlock for ConnectionPointType.Vector2 inputs
103
114
  */
104
- export type Vector2InputBlockData = {
115
+ export type Vector2InputBlockData = CommonInputBlockData & {
105
116
  /** The type of the input block */
106
117
  inputType: ConnectionPointType.Vector2;
107
118
 
@@ -56,6 +56,7 @@ function serializeTextureInputBlock(inputBlock: InputBlock<ConnectionPointType.T
56
56
  flipY: internalTexture?.invertY ?? null,
57
57
  anisotropicFilteringLevel: internalTexture?.anisotropicFilteringLevel ?? null,
58
58
  forcedExtension: forcedExtension !== "" ? forcedExtension : null,
59
+ appMetadata: inputBlock.appMetadata,
59
60
  };
60
61
  }
61
62
 
@@ -68,6 +69,7 @@ function serializeBooleanInputBlock(inputBlock: InputBlock<ConnectionPointType.B
68
69
  return {
69
70
  inputType: ConnectionPointType.Boolean,
70
71
  value: inputBlock.runtimeValue.value,
72
+ appMetadata: inputBlock.appMetadata,
71
73
  };
72
74
  }
73
75
 
@@ -84,6 +86,7 @@ function serializeFloatInputBlock(inputBlock: InputBlock<ConnectionPointType.Flo
84
86
  valueDeltaPerMs: inputBlock.editorData?.valueDeltaPerMs ?? null,
85
87
  min: inputBlock.editorData?.min ?? null,
86
88
  max: inputBlock.editorData?.max ?? null,
89
+ appMetadata: inputBlock.appMetadata,
87
90
  };
88
91
  }
89
92
 
@@ -96,6 +99,7 @@ function serializeColor3InputBlock(inputBlock: InputBlock<ConnectionPointType.Co
96
99
  return {
97
100
  inputType: ConnectionPointType.Color3,
98
101
  value: inputBlock.runtimeValue.value,
102
+ appMetadata: inputBlock.appMetadata,
99
103
  };
100
104
  }
101
105
 
@@ -108,6 +112,7 @@ function serializeColor4InputBlock(inputBlock: InputBlock<ConnectionPointType.Co
108
112
  return {
109
113
  inputType: ConnectionPointType.Color4,
110
114
  value: inputBlock.runtimeValue.value,
115
+ appMetadata: inputBlock.appMetadata,
111
116
  };
112
117
  }
113
118
 
@@ -120,6 +125,7 @@ function serializeVector2InputBlock(inputBlock: InputBlock<ConnectionPointType.V
120
125
  return {
121
126
  inputType: ConnectionPointType.Vector2,
122
127
  value: inputBlock.runtimeValue.value,
128
+ appMetadata: inputBlock.appMetadata,
123
129
  };
124
130
  }
125
131
 
@@ -136,6 +142,7 @@ export const inputBlockSerializer: IBlockSerializerV1 = {
136
142
  name: block.name,
137
143
  uniqueId: block.uniqueId,
138
144
  blockType: InputBlockBase.ClassName,
145
+ namespace: null,
139
146
  comments: block.comments,
140
147
  data: serializeInputBlockData(block as unknown as InputBlockBase),
141
148
  };
@@ -115,7 +115,7 @@ export type InputBlockEditorData<T extends ConnectionPointType> = T extends Conn
115
115
  *
116
116
  * The value is dynamically set by the user.
117
117
  */
118
- export class InputBlock<U extends ConnectionPointType> extends InputBlockBase {
118
+ export class InputBlock<U extends ConnectionPointType, V = unknown> extends InputBlockBase {
119
119
  /**
120
120
  * The output connection point of the block.
121
121
  */
@@ -131,6 +131,12 @@ export class InputBlock<U extends ConnectionPointType> extends InputBlockBase {
131
131
  */
132
132
  public editorData: Nullable<InputBlockEditorData<U>> = null;
133
133
 
134
+ /**
135
+ * Metadata the hosting app wants to track for this input. For example, a hint for what data to
136
+ * assign to this input, or hints about how to draw dynamic UI to allow users to control this value.
137
+ */
138
+ public appMetadata: Nullable<V> = null;
139
+
134
140
  /**
135
141
  * Gets the current value of the input.
136
142
  */
@@ -89,7 +89,7 @@ export class ConnectionPoint<U extends ConnectionPointType = ConnectionPointType
89
89
  }
90
90
 
91
91
  /**
92
- * @returns the connection point this connection point is connected to.
92
+ * @returns The connection point this connection point is connected to.
93
93
  * (the one on the other side of the connection)
94
94
  * Only input connection points have a connected point which they received their value from.
95
95
  * (Relation is always 1:N for input:output)
@@ -99,8 +99,8 @@ export class ConnectionPoint<U extends ConnectionPointType = ConnectionPointType
99
99
  }
100
100
 
101
101
  /**
102
- * @returns the connection point this connection point is to.
103
- * (the one on the other side of the connection)
102
+ * @returns The connection points this output connection point is connected to.
103
+ * (the ones on the other side of the connection)
104
104
  * Only output connection points have a list of endpoints which they provide their value to.
105
105
  * (Relation is always 1:N for input:output)
106
106
  */
package/src/index.ts CHANGED
@@ -39,3 +39,4 @@ export * from "./utils/textureLoaders.js";
39
39
  export * from "./serialization/index.js";
40
40
  export * from "./editorUtils/editableInPropertyPage.js";
41
41
  export * from "./serialization/importCustomBlockDefinition.js";
42
+ export * from "./version.js";
@@ -95,6 +95,7 @@ function importAnnotatedGlsl(fragmentShader: string): SerializedShaderBlockDefin
95
95
  format: "shaderBlockDefinition",
96
96
  formatVersion: 1,
97
97
  blockType: fragmentShaderInfo.blockType,
98
+ namespace: fragmentShaderInfo.namespace,
98
99
  shaderProgram: {
99
100
  fragment: fragmentShaderInfo.shaderCode,
100
101
  },
@@ -55,7 +55,6 @@ export class SmartFilterDeserializer {
55
55
  // Back-compat for the rename of version to formatVersion, didn't warrant a new version
56
56
  if ((serializedSmartFilter as any).version && serializedSmartFilter.formatVersion === undefined) {
57
57
  serializedSmartFilter.formatVersion = (serializedSmartFilter as any).version;
58
- delete (serializedSmartFilter as any).version;
59
58
  }
60
59
 
61
60
  switch (serializedSmartFilter.formatVersion) {
@@ -68,7 +67,7 @@ export class SmartFilterDeserializer {
68
67
  engine: ThinEngine,
69
68
  serializedSmartFilter: SerializedSmartFilterV1
70
69
  ): Promise<SmartFilter> {
71
- const smartFilter = new SmartFilter(serializedSmartFilter.name);
70
+ const smartFilter = new SmartFilter(serializedSmartFilter.name, serializedSmartFilter.namespace);
72
71
  const blockIdMap = new Map<number, BaseBlock>();
73
72
 
74
73
  // Only needed for smart filters saved before we started using uniqueIds for the maps, didn't warrant new version
@@ -164,6 +163,11 @@ export class SmartFilterDeserializer {
164
163
  serializedBlock.blockType = (serializedBlock as any).className;
165
164
  }
166
165
 
166
+ // Back compat for early Smart Filter V1 serialization where the namespace was not stored
167
+ if (serializedBlock.namespace === undefined) {
168
+ serializedBlock.namespace = null;
169
+ }
170
+
167
171
  // Get the instance of the block
168
172
  switch (serializedBlock.blockType) {
169
173
  case InputBlock.ClassName:
@@ -185,7 +189,9 @@ export class SmartFilterDeserializer {
185
189
  // If it's not an input or output block, use the provided block factory
186
190
  newBlock = await this._blockFactory(smartFilter, engine, serializedBlock, this);
187
191
  if (!newBlock) {
188
- blockTypesWhichCouldNotBeDeserialized.push(serializedBlock.blockType);
192
+ if (blockTypesWhichCouldNotBeDeserialized.indexOf(serializedBlock.blockType) === -1) {
193
+ blockTypesWhichCouldNotBeDeserialized.push(serializedBlock.blockType);
194
+ }
189
195
  return;
190
196
  }
191
197
  }
@@ -111,6 +111,7 @@ export class SmartFilterSerializer {
111
111
  format: "smartFilter",
112
112
  formatVersion: 1,
113
113
  name: smartFilter.name,
114
+ namespace: smartFilter.namespace,
114
115
  comments: smartFilter.comments,
115
116
  editorData: smartFilter.editorData,
116
117
  blocks,
@@ -12,6 +12,7 @@ export const defaultBlockSerializer: SerializeBlockV1 = (block: BaseBlock): ISer
12
12
  name: block.name,
13
13
  uniqueId: block.uniqueId,
14
14
  blockType: block.blockType,
15
+ namespace: block.namespace,
15
16
  comments: block.comments,
16
17
  data: undefined,
17
18
  };
@@ -4,6 +4,7 @@
4
4
  * ----------------------------------------------------------------------------
5
5
  */
6
6
 
7
+ import type { Nullable } from "@babylonjs/core/types";
7
8
  import type { AllConnectionPointTypes, ConnectionPointValue } from "../../connection/connectionPointType";
8
9
  import type { ShaderProgram } from "../../utils/shaderCodeUtils";
9
10
 
@@ -31,6 +32,12 @@ export type SerializedShaderBlockDefinitionV1 = {
31
32
  */
32
33
  blockType: string;
33
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
+
34
41
  /**
35
42
  * The shader program for the block.
36
43
  */
@@ -24,6 +24,9 @@ export type SerializedSmartFilterV1 = {
24
24
  /** The SmartFilter name */
25
25
  name: string;
26
26
 
27
+ /** The namespace of the SmartFilter */
28
+ namespace: Nullable<string>;
29
+
27
30
  /** The SmartFilter comments */
28
31
  comments: Nullable<string>;
29
32
 
@@ -45,6 +48,9 @@ export interface ISerializedBlockV1 {
45
48
  /** The name of the block */
46
49
  name: string;
47
50
 
51
+ /** The namespace of the block */
52
+ namespace: Nullable<string>;
53
+
48
54
  /** The unique ID of the block - correlates with the ID in the editorData for block position, etc. */
49
55
  uniqueId: number;
50
56
 
@@ -59,6 +59,11 @@ export class SmartFilter {
59
59
  */
60
60
  public readonly name: string;
61
61
 
62
+ /**
63
+ * The namespace of the smart filter.
64
+ */
65
+ public readonly namespace: Nullable<string>;
66
+
62
67
  /**
63
68
  * The smart filter output (input connection point of the output block...).
64
69
  *
@@ -85,9 +90,11 @@ export class SmartFilter {
85
90
  /**
86
91
  * Creates a new instance of a @see SmartFilter.
87
92
  * @param name - The friendly name of the smart filter
93
+ * @param namespace - The namespace of the smart filter
88
94
  */
89
- constructor(name: string) {
95
+ constructor(name: string, namespace: Nullable<string> = null) {
90
96
  this.name = name;
97
+ this.namespace = namespace;
91
98
 
92
99
  this._attachedBlocks = new Array<BaseBlock>();
93
100
  this.outputBlock = new OutputBlock(this);
@@ -48,6 +48,11 @@ export type FragmentShaderInfo = {
48
48
  */
49
49
  blockType?: string;
50
50
 
51
+ /**
52
+ * If supplied, the namespace of the block
53
+ */
54
+ namespace: Nullable<string>;
55
+
51
56
  /**
52
57
  * If true, optimization should be disabled for this shader
53
58
  */
@@ -73,6 +78,7 @@ export function parseFragmentShader(fragmentShader: string): FragmentShaderInfo
73
78
  const { header, fragmentShaderWithoutHeader } = readHeader(fragmentShader);
74
79
  fragmentShader = fragmentShaderWithoutHeader;
75
80
  const blockType = header?.[SmartFilterBlockTypeKey] || undefined;
81
+ const namespace = header?.namespace || null;
76
82
 
77
83
  // Read the uniforms
78
84
  const uniforms: UniformMetadata[] = [];
@@ -167,6 +173,7 @@ export function parseFragmentShader(fragmentShader: string): FragmentShaderInfo
167
173
 
168
174
  return {
169
175
  blockType,
176
+ namespace,
170
177
  shaderCode,
171
178
  uniforms,
172
179
  disableOptimization: !!header?.disableOptimizer,
@@ -320,6 +327,11 @@ type GlslHeader = {
320
327
  */
321
328
  [SmartFilterBlockTypeKey]: string;
322
329
 
330
+ /**
331
+ * The namespace to use for the block
332
+ */
333
+ namespace?: string;
334
+
323
335
  /**
324
336
  * If true, optimization should be disabled for this shader
325
337
  */
@@ -41,6 +41,7 @@ queryNpmFeed("preview", (npmPreviewVersion) => {
41
41
 
42
42
  console.log("Version to use:", versionToUse);
43
43
 
44
+ // Update package.json if needed
44
45
  if (packageJSON.version !== versionToUse) {
45
46
  packageJSON.version = versionToUse;
46
47
  fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 4));
@@ -48,5 +49,12 @@ queryNpmFeed("preview", (npmPreviewVersion) => {
48
49
  } else {
49
50
  console.log("No need to update package.json");
50
51
  }
52
+
53
+ // Write out to version.ts
54
+ const versionTsText = `/**
55
+ * The version of the SmartFilter core. During publish, this file is overwritten by versionUp.ts with the same version that is used for the NPM publish.
56
+ */
57
+ export const SmartFilterCoreVersion = "${versionToUse}";\n`;
58
+ fs.writeFileSync("src/version.ts", versionTsText);
51
59
  });
52
60
  });
package/src/version.ts ADDED
@@ -0,0 +1,4 @@
1
+ /**
2
+ * The version of the SmartFilter core. During publish, this file is overwritten by versionUp.ts with the same version that is used for the NPM publish.
3
+ */
4
+ export const SmartFilterCoreVersion = "0.7.5-alpha";