@babylonjs/smart-filters 0.3.0-alpha → 0.3.2-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/copyBlock.shader.d.ts.map +1 -1
- package/dist/blocks/copyBlock.shader.js +5 -2
- package/dist/blocks/copyBlock.shader.js.map +1 -1
- package/dist/blocks/inputBlock.d.ts +26 -0
- package/dist/blocks/inputBlock.d.ts.map +1 -1
- package/dist/blocks/inputBlock.deserializer.d.ts +1 -1
- package/dist/blocks/inputBlock.deserializer.d.ts.map +1 -1
- package/dist/blocks/inputBlock.deserializer.js +25 -2
- package/dist/blocks/inputBlock.deserializer.js.map +1 -1
- package/dist/blocks/inputBlock.js +4 -0
- package/dist/blocks/inputBlock.js.map +1 -1
- package/dist/blocks/inputBlock.serialization.types.d.ts +13 -1
- package/dist/blocks/inputBlock.serialization.types.d.ts.map +1 -1
- package/dist/blocks/inputBlock.serializer.d.ts.map +1 -1
- package/dist/blocks/inputBlock.serializer.js +7 -2
- package/dist/blocks/inputBlock.serializer.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/serialization/smartFilterDeserializer.d.ts.map +1 -1
- package/dist/serialization/smartFilterDeserializer.js +16 -20
- package/dist/serialization/smartFilterDeserializer.js.map +1 -1
- package/dist/smartFilter.d.ts.map +1 -1
- package/dist/smartFilter.js +9 -5
- package/dist/smartFilter.js.map +1 -1
- package/dist/utils/buildTools/determineVersion.d.ts +36 -0
- package/dist/utils/buildTools/determineVersion.d.ts.map +1 -0
- package/dist/utils/buildTools/determineVersion.js +109 -0
- package/dist/utils/buildTools/determineVersion.js.map +1 -0
- package/dist/utils/buildTools/shaderConverter.js +11 -5
- package/dist/utils/buildTools/shaderConverter.js.map +1 -1
- package/dist/utils/buildTools/versionUp.d.ts +2 -0
- package/dist/utils/buildTools/versionUp.d.ts.map +1 -0
- package/dist/utils/buildTools/versionUp.js +45 -0
- package/dist/utils/buildTools/versionUp.js.map +1 -0
- package/dist/utils/textureLoaders.d.ts +2 -1
- package/dist/utils/textureLoaders.d.ts.map +1 -1
- package/dist/utils/textureLoaders.js +2 -2
- package/dist/utils/textureLoaders.js.map +1 -1
- package/package.json +4 -4
- package/src/blocks/copyBlock.shader.ts +5 -2
- package/src/blocks/inputBlock.deserializer.ts +30 -8
- package/src/blocks/inputBlock.serialization.types.ts +16 -1
- package/src/blocks/inputBlock.serializer.ts +6 -1
- package/src/blocks/inputBlock.ts +33 -0
- package/src/index.ts +1 -1
- package/src/serialization/smartFilterDeserializer.ts +22 -22
- package/src/smartFilter.ts +8 -6
- package/src/utils/buildTools/determineVersion.ts +127 -0
- package/src/utils/buildTools/shaderConverter.ts +17 -6
- package/src/utils/buildTools/versionUp.ts +52 -0
- package/src/utils/textureLoaders.ts +3 -2
|
@@ -31,7 +31,8 @@ const ShaderTemplate = `import type { ShaderProgram } from "${TYPE_IMPORT_PATH}"
|
|
|
31
31
|
export const shaderProgram: ShaderProgram = {
|
|
32
32
|
vertex: ${VERTEX_SHADER},
|
|
33
33
|
fragment: {
|
|
34
|
-
uniform: \`${UNIFORMS}
|
|
34
|
+
uniform: \`${UNIFORMS}
|
|
35
|
+
uniform bool _disabled_;\`,${CONSTS_PROPERTY}
|
|
35
36
|
mainInputTexture: "${MAIN_INPUT_NAME}",
|
|
36
37
|
mainFunctionName: "${MAIN_FUNCTION_NAME}",
|
|
37
38
|
functions: [${FUNCTIONS}
|
|
@@ -127,14 +128,14 @@ function processFragmentShaderV1(fragmentShader) {
|
|
|
127
128
|
const finalUniforms = [...fragmentShaderWithRenamedSymbols.matchAll(/^\s*(uniform\s.*)/gm)].map((match) => match[1]);
|
|
128
129
|
// Extract all the consts
|
|
129
130
|
const finalConsts = [...fragmentShaderWithRenamedSymbols.matchAll(/^\s*(const\s.*)/gm)].map((match) => match[1]);
|
|
130
|
-
// Extract all the functions
|
|
131
|
-
const { extractedFunctions, mainFunctionName } = extractFunctions(fragmentShaderWithRenamedSymbols);
|
|
132
131
|
// Find the main input
|
|
133
132
|
const mainInputs = [...fragmentShaderWithRenamedSymbols.matchAll(/\S*uniform.*\s(\w*);\s*\/\/\s*main/gm)].map((match) => match[1]);
|
|
134
133
|
if (mainInputs.length !== 1 || !mainInputs[0]) {
|
|
135
134
|
throw new Error("Exactly one main input must be defined in the shader");
|
|
136
135
|
}
|
|
137
136
|
const mainInputName = mainInputs[0];
|
|
137
|
+
// Extract all the functions
|
|
138
|
+
const { extractedFunctions, mainFunctionName } = extractFunctions(fragmentShaderWithRenamedSymbols, mainInputName);
|
|
138
139
|
return {
|
|
139
140
|
finalUniforms,
|
|
140
141
|
mainFunctionName,
|
|
@@ -159,9 +160,10 @@ function addLinePrefixes(input, prefix) {
|
|
|
159
160
|
/**
|
|
160
161
|
* Extracts all the functions from the shader
|
|
161
162
|
* @param fragment - The shader code to process
|
|
163
|
+
* @param mainInputName - The name of the main input
|
|
162
164
|
* @returns A list of functions
|
|
163
165
|
*/
|
|
164
|
-
function extractFunctions(fragment) {
|
|
166
|
+
function extractFunctions(fragment, mainInputName) {
|
|
165
167
|
const lines = fragment.split("\n");
|
|
166
168
|
const extractedFunctions = [];
|
|
167
169
|
let mainFunctionName;
|
|
@@ -186,7 +188,11 @@ function extractFunctions(fragment) {
|
|
|
186
188
|
if (inFunction && depth === 0) {
|
|
187
189
|
inFunction = false;
|
|
188
190
|
const { functionBody, functionName, isMainFunction } = processFunctionBody(currentFunction);
|
|
189
|
-
|
|
191
|
+
let body = functionBody;
|
|
192
|
+
if (isMainFunction) {
|
|
193
|
+
body = functionBody.replace("{", `{\n if (_disabled_) return texture2D(${mainInputName}, vUV);\n`);
|
|
194
|
+
}
|
|
195
|
+
extractedFunctions.push(FunctionTemplate.replace(FUNCTION_NAME, functionName).replace(FUNCTION_CODE, addLinePrefixes(body, CodeLinePrefix)));
|
|
190
196
|
if (isMainFunction) {
|
|
191
197
|
if (mainFunctionName) {
|
|
192
198
|
throw new Error("Multiple main functions found in shader code");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shaderConverter.js","sourceRoot":"","sources":["../../../src/utils/buildTools/shaderConverter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAC9C,MAAM,aAAa,GAAG,iBAAiB,CAAC;AACxC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAC9B,MAAM,YAAY,GAAG,UAAU,CAAC;AAChC,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AAClD,MAAM,SAAS,GAAG,aAAa,CAAC;AAChC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AACxC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AACxC,MAAM,aAAa,GAAG,iBAAiB,CAAC;AAExC,MAAM,cAAc,GAAG;mBACJ,YAAY,KAAK,CAAC;AAErC,MAAM,gBAAgB,GAAG;;yBAEA,aAAa;;EAEpC,aAAa;;eAEA,CAAC;AAEhB,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAC9C,MAAM,iBAAiB,GAAG,cAAc,CAAC;AACzC,MAAM,eAAe,GAAG,cAAc,CAAC;AAEvC,MAAM,cAAc,GAAG,uCAAuC,gBAAgB;;;;;;cAMhE,aAAa;;qBAEN,QAAQ,
|
|
1
|
+
{"version":3,"file":"shaderConverter.js","sourceRoot":"","sources":["../../../src/utils/buildTools/shaderConverter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AAC9C,MAAM,aAAa,GAAG,iBAAiB,CAAC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AAM,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;AAED,sFAAsF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versionUp.d.ts","sourceRoot":"","sources":["../../../src/utils/buildTools/versionUp.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import { exec } from "child_process";
|
|
3
|
+
import { compareVersions, determineVersion, getNpmVersion } from "./determineVersion.js";
|
|
4
|
+
const alpha = process.argv.includes("--alpha");
|
|
5
|
+
const packageText = fs.readFileSync("package.json");
|
|
6
|
+
const packageJSON = JSON.parse(packageText.toString());
|
|
7
|
+
const packageName = packageJSON.name;
|
|
8
|
+
console.log("Processing package:", packageName);
|
|
9
|
+
console.log("Alpha flag:", alpha);
|
|
10
|
+
console.log("Current package.json version:", packageJSON.version);
|
|
11
|
+
/**
|
|
12
|
+
* Queries the NPM registry for the specified version type
|
|
13
|
+
* @param versionType - The type of version to query
|
|
14
|
+
* @param callback - The callback to call with the NPM version
|
|
15
|
+
*/
|
|
16
|
+
function queryNpmFeed(versionType, callback) {
|
|
17
|
+
exec(`npm view ${packageName} dist-tags.${versionType}`, (err, stdout) => {
|
|
18
|
+
let npmVersion = getNpmVersion(versionType, err, stdout);
|
|
19
|
+
if (npmVersion !== null) {
|
|
20
|
+
npmVersion = npmVersion.trim();
|
|
21
|
+
console.log(`NPM Registry ${versionType} version:`, npmVersion);
|
|
22
|
+
}
|
|
23
|
+
callback(npmVersion);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
queryNpmFeed("preview", (npmPreviewVersion) => {
|
|
27
|
+
queryNpmFeed("latest", (npmLatestVersion) => {
|
|
28
|
+
let highestNpmVersion = npmLatestVersion;
|
|
29
|
+
if (npmPreviewVersion && (!highestNpmVersion || compareVersions(npmPreviewVersion, highestNpmVersion) === 1)) {
|
|
30
|
+
highestNpmVersion = npmPreviewVersion;
|
|
31
|
+
}
|
|
32
|
+
console.log("Highest NPM Registry version:", highestNpmVersion);
|
|
33
|
+
const versionToUse = determineVersion(highestNpmVersion, packageJSON.version, alpha);
|
|
34
|
+
console.log("Version to use:", versionToUse);
|
|
35
|
+
if (packageJSON.version !== versionToUse) {
|
|
36
|
+
packageJSON.version = versionToUse;
|
|
37
|
+
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 4));
|
|
38
|
+
console.log("Version updated in package.json");
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.log("No need to update package.json");
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=versionUp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"versionUp.js","sourceRoot":"","sources":["../../../src/utils/buildTools/versionUp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,IAAI,EAAsB,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,aAAa,EAAoB,MAAM,uBAAuB,CAAC;AAG3G,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAC/C,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;AACpD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;AAEvD,MAAM,WAAW,GAAG,WAAW,CAAC,IAAI,CAAC;AACrC,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;AAChD,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,K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E,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YACvE,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QACnD,CAAC;aAAM,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;QAClD,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ThinTexture } from "@babylonjs/core/Materials/Textures/thinTexture.js";
|
|
2
2
|
import { type ThinEngine } from "@babylonjs/core/Engines/thinEngine.js";
|
|
3
|
+
import type { Nullable } from "@babylonjs/core/types";
|
|
3
4
|
/**
|
|
4
5
|
* Helper that takes in a URL to an image and returns a ThinTexture
|
|
5
6
|
* @param engine - defines the engine to use to create the texture
|
|
@@ -11,5 +12,5 @@ import { type ThinEngine } from "@babylonjs/core/Engines/thinEngine.js";
|
|
|
11
12
|
* @param forcedExtension - defines the extension to use to pick the right loader
|
|
12
13
|
* @returns A ThinTexture of the image
|
|
13
14
|
*/
|
|
14
|
-
export declare function createImageTexture(engine: ThinEngine, url: string, flipY?: boolean
|
|
15
|
+
export declare function createImageTexture(engine: ThinEngine, url: string, flipY?: Nullable<boolean>, samplingMode?: number | undefined, forcedExtension?: string | null): ThinTexture;
|
|
15
16
|
//# sourceMappingURL=textureLoaders.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textureLoaders.d.ts","sourceRoot":"","sources":["../../src/utils/textureLoaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AAChF,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"textureLoaders.d.ts","sourceRoot":"","sources":["../../src/utils/textureLoaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AAChF,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAC9B,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,MAAM,EACX,KAAK,GAAE,QAAQ,CAAC,OAAO,CAAQ,EAC/B,YAAY,GAAE,MAAM,GAAG,SAAqB,EAC5C,eAAe,GAAE,MAAM,GAAG,IAAW,GACtC,WAAW,CAeb"}
|
|
@@ -11,8 +11,8 @@ import {} from "@babylonjs/core/Engines/thinEngine.js";
|
|
|
11
11
|
* @param forcedExtension - defines the extension to use to pick the right loader
|
|
12
12
|
* @returns A ThinTexture of the image
|
|
13
13
|
*/
|
|
14
|
-
export function createImageTexture(engine, url, flipY =
|
|
15
|
-
const internalTexture = engine.createTexture(url, true, flipY, null, samplingMode, null, null, null, null, null, forcedExtension);
|
|
14
|
+
export function createImageTexture(engine, url, flipY = null, samplingMode = undefined, forcedExtension = null) {
|
|
15
|
+
const internalTexture = engine.createTexture(url, true, flipY !== null && flipY !== void 0 ? flipY : true, null, samplingMode, null, null, null, null, null, forcedExtension);
|
|
16
16
|
return new ThinTexture(internalTexture);
|
|
17
17
|
}
|
|
18
18
|
/*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textureLoaders.js","sourceRoot":"","sources":["../../src/utils/textureLoaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AAChF,OAAO,EAAmB,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"textureLoaders.js","sourceRoot":"","sources":["../../src/utils/textureLoaders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mDAAmD,CAAC;AAChF,OAAO,EAAmB,MAAM,uCAAuC,CAAC;AAGxE;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CAC9B,MAAkB,EAClB,GAAW,EACX,QAA2B,IAAI,EAC/B,eAAmC,SAAS,EAC5C,kBAAiC,IAAI;IAErC,MAAM,eAAe,GAAG,MAAM,CAAC,aAAa,CACxC,GAAG,EACH,IAAI,EACJ,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,EACb,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,eAAe,CAClB,CAAC;IACF,OAAO,IAAI,WAAW,CAAC,eAAe,CAAC,CAAC;AAC5C,CAAC;AAED;;;;EAIE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs/smart-filters",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2-alpha",
|
|
4
4
|
"description": "Babylon.js Smart Filter core",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Sebastien VANDENBERGHE"
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"readme.md"
|
|
39
39
|
],
|
|
40
40
|
"scripts": {
|
|
41
|
-
"clean": "rimraf dist && rimraf tsconfig.build.tsbuildinfo",
|
|
42
|
-
"
|
|
41
|
+
"clean": "rimraf dist && rimraf buildTools && rimraf tsconfig.build.tsbuildinfo && rimraf ../../tsconfig.buildTools.build.tsbuildinfo",
|
|
42
|
+
"preparePublish": "node buildTools/versionUp.js --alpha",
|
|
43
43
|
"build": "npm run build:buildTools && npm run build:runTools && npm run build:core",
|
|
44
44
|
"build:core": "tsc -p ./tsconfig.build.json",
|
|
45
45
|
"build:buildTools": "tsc -p ./tsconfig.buildTools.build.json",
|
|
46
|
-
"build:runTools": "node buildTools/
|
|
46
|
+
"build:runTools": "node buildTools/shaderConverter.js ./src/blocks ../utils/shaderCodeUtils",
|
|
47
47
|
"watch": "tsc -p ./tsconfig.build.json --watch",
|
|
48
48
|
"test": "echo \"Error: run test from the root of the monorepo\" && exit 1"
|
|
49
49
|
},
|
|
@@ -7,14 +7,17 @@ export const shaderProgram: ShaderProgram = {
|
|
|
7
7
|
vertex: undefined,
|
|
8
8
|
fragment: {
|
|
9
9
|
uniform: `
|
|
10
|
-
uniform sampler2D _input_; // main
|
|
10
|
+
uniform sampler2D _input_; // main
|
|
11
|
+
uniform bool _disabled_;`,
|
|
11
12
|
mainInputTexture: "_input_",
|
|
12
13
|
mainFunctionName: "_copy_",
|
|
13
14
|
functions: [
|
|
14
15
|
{
|
|
15
16
|
name: "_copy_",
|
|
16
17
|
code: `
|
|
17
|
-
vec4 _copy_(vec2 vUV) {
|
|
18
|
+
vec4 _copy_(vec2 vUV) {
|
|
19
|
+
if (_disabled_) return texture2D(_input_, vUV);
|
|
20
|
+
// main
|
|
18
21
|
return texture2D(_input_, vUV);
|
|
19
22
|
}
|
|
20
23
|
|
|
@@ -5,7 +5,8 @@ import type { SmartFilter } from "../smartFilter.js";
|
|
|
5
5
|
import type { ISerializedBlockV1 } from "../serialization/v1/serialization.types.js";
|
|
6
6
|
import { createImageTexture } from "../utils/textureLoaders.js";
|
|
7
7
|
import type { ThinEngine } from "@babylonjs/core/Engines/thinEngine.js";
|
|
8
|
-
|
|
8
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
|
9
|
+
import type { ThinTexture } from "@babylonjs/core/Materials/Textures/thinTexture.js";
|
|
9
10
|
/**
|
|
10
11
|
* V1 Input Block Deserializer
|
|
11
12
|
* @param smartFilter - The SmartFilter to deserialize the block into
|
|
@@ -25,13 +26,34 @@ export function inputBlockDeserializer(
|
|
|
25
26
|
return new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Boolean, blockData.value);
|
|
26
27
|
case ConnectionPointType.Float:
|
|
27
28
|
return new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Float, blockData.value);
|
|
28
|
-
case ConnectionPointType.Texture:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
case ConnectionPointType.Texture: {
|
|
30
|
+
// If information necessary to load an image was serialized, load the image
|
|
31
|
+
const texture: Nullable<ThinTexture> = blockData.url
|
|
32
|
+
? createImageTexture(engine, blockData.url, blockData.flipY)
|
|
33
|
+
: null;
|
|
34
|
+
if (texture && blockData.anisotropicFilteringLevel !== null) {
|
|
35
|
+
texture.anisotropicFilteringLevel = blockData.anisotropicFilteringLevel;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Create the input block
|
|
39
|
+
const inputBlock = new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Texture, texture);
|
|
40
|
+
|
|
41
|
+
// If editor data was serialized, set it on the deserialized block
|
|
42
|
+
inputBlock.editorData = {
|
|
43
|
+
url: blockData.url,
|
|
44
|
+
anisotropicFilteringLevel: blockData.anisotropicFilteringLevel,
|
|
45
|
+
flipY: blockData.flipY,
|
|
46
|
+
forcedExtension: blockData.forcedExtension,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return inputBlock;
|
|
50
|
+
}
|
|
51
|
+
case ConnectionPointType.Color3:
|
|
52
|
+
return new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Color3, blockData.value);
|
|
53
|
+
case ConnectionPointType.Color4:
|
|
54
|
+
return new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Color4, blockData.value);
|
|
55
|
+
case ConnectionPointType.Vector2:
|
|
56
|
+
return new InputBlock(smartFilter, serializedBlock.name, ConnectionPointType.Vector2, blockData.value);
|
|
35
57
|
}
|
|
36
58
|
|
|
37
59
|
throw new Error("Could not deserialize input block, unknown input type");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Nullable } from "@babylonjs/core";
|
|
1
|
+
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
|
|
|
@@ -11,6 +11,21 @@ export type TextureInputBlockData = {
|
|
|
11
11
|
|
|
12
12
|
/** The URL, if available, of the texture */
|
|
13
13
|
url: Nullable<string>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Defines the anisotropic level to use, or default if null
|
|
17
|
+
*/
|
|
18
|
+
anisotropicFilteringLevel: Nullable<number>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Indicates if the Y axis should be flipped, or default if null
|
|
22
|
+
*/
|
|
23
|
+
flipY: Nullable<boolean>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The file extension to use, or default if null.
|
|
27
|
+
*/
|
|
28
|
+
forcedExtension: Nullable<string>;
|
|
14
29
|
};
|
|
15
30
|
|
|
16
31
|
/**
|
|
@@ -41,9 +41,14 @@ function serializeInputBlockData(inputBlock: InputBlockBase): SerializedInputBlo
|
|
|
41
41
|
* @returns The serialized data for the InputBlock
|
|
42
42
|
*/
|
|
43
43
|
function serializeTextureInputBlock(inputBlock: InputBlock<ConnectionPointType.Texture>): TextureInputBlockData {
|
|
44
|
+
const internalTexture = inputBlock.runtimeValue.value?.getInternalTexture();
|
|
45
|
+
const forcedExtension = internalTexture?._extension ?? null;
|
|
44
46
|
return {
|
|
45
47
|
inputType: ConnectionPointType.Texture,
|
|
46
|
-
url:
|
|
48
|
+
url: internalTexture?.url ?? null,
|
|
49
|
+
flipY: internalTexture?.invertY ?? null,
|
|
50
|
+
anisotropicFilteringLevel: internalTexture?.anisotropicFilteringLevel ?? null,
|
|
51
|
+
forcedExtension: forcedExtension !== "" ? forcedExtension : null,
|
|
47
52
|
};
|
|
48
53
|
}
|
|
49
54
|
|
package/src/blocks/inputBlock.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { DisableableBlock } from "./disableableBlock";
|
|
|
6
6
|
import { BaseBlock } from "../blocks/baseBlock.js";
|
|
7
7
|
import { createStrongRef } from "../runtime/strongRef.js";
|
|
8
8
|
import { ConnectionPointType } from "../connection/connectionPointType.js";
|
|
9
|
+
import type { Nullable } from "@babylonjs/core/types";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Type predicate to check if value is a strong ref or a direct value
|
|
@@ -52,6 +53,33 @@ export abstract class InputBlockBase extends BaseBlock {
|
|
|
52
53
|
public abstract readonly type: ConnectionPointType;
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Describes the editor data that can be stored with an InputBlock of a given type.
|
|
58
|
+
*/
|
|
59
|
+
export type InputBlockEditorData<T extends ConnectionPointType> = T extends ConnectionPointType.Texture
|
|
60
|
+
? {
|
|
61
|
+
/**
|
|
62
|
+
* The URL of the texture, or default if null.
|
|
63
|
+
*/
|
|
64
|
+
url: Nullable<string>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* The anisotropic filtering level of the texture, or default if null.
|
|
68
|
+
*/
|
|
69
|
+
anisotropicFilteringLevel: Nullable<number>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Whether the Y axis should be flipped, or default if null.
|
|
73
|
+
*/
|
|
74
|
+
flipY: Nullable<boolean>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The file extension to use, or default if null.
|
|
78
|
+
*/
|
|
79
|
+
forcedExtension: Nullable<string>;
|
|
80
|
+
}
|
|
81
|
+
: {};
|
|
82
|
+
|
|
55
83
|
/**
|
|
56
84
|
* This represents any inputs used in the graph.
|
|
57
85
|
*
|
|
@@ -70,6 +98,11 @@ export class InputBlock<U extends ConnectionPointType> extends InputBlockBase {
|
|
|
70
98
|
*/
|
|
71
99
|
public readonly type: U;
|
|
72
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Data used by the Editor to store options required for instantiating the block in the Editor.
|
|
103
|
+
*/
|
|
104
|
+
public editorData: Nullable<InputBlockEditorData<U>> = null;
|
|
105
|
+
|
|
73
106
|
/**
|
|
74
107
|
* Gets the current value of the input.
|
|
75
108
|
*/
|
package/src/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ export { ConnectionPoint } from "./connection/connectionPoint.js";
|
|
|
17
17
|
export { type RuntimeData } from "./connection/connectionPoint.js";
|
|
18
18
|
|
|
19
19
|
export { BaseBlock } from "./blocks/baseBlock.js";
|
|
20
|
-
export { InputBlock } from "./blocks/inputBlock.js";
|
|
20
|
+
export { InputBlock, type InputBlockEditorData } from "./blocks/inputBlock.js";
|
|
21
21
|
export { type AnyInputBlock } from "./blocks/inputBlock.js";
|
|
22
22
|
export { ShaderBlock } from "./blocks/shaderBlock.js";
|
|
23
23
|
export { AggregateBlock } from "./blocks/aggregateBlock.js";
|
|
@@ -34,6 +34,10 @@ export class SmartFilterDeserializer {
|
|
|
34
34
|
(smartFilter: SmartFilter, serializedBlock: ISerializedBlockV1, engine: ThinEngine) =>
|
|
35
35
|
Promise.resolve(inputBlockDeserializer(smartFilter, serializedBlock, engine))
|
|
36
36
|
);
|
|
37
|
+
|
|
38
|
+
this._blockDeserializersV1.set(OutputBlock.ClassName, (smartFilter: SmartFilter) =>
|
|
39
|
+
Promise.resolve(smartFilter.output.ownerBlock)
|
|
40
|
+
);
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
/**
|
|
@@ -64,30 +68,26 @@ export class SmartFilterDeserializer {
|
|
|
64
68
|
// Deserialize the blocks
|
|
65
69
|
const blockDeserializationWork: Promise<void>[] = [];
|
|
66
70
|
serializedSmartFilter.blocks.forEach((serializedBlock: ISerializedBlockV1) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// blocks, and so each deserializer doesn't have to remember to do it.
|
|
79
|
-
newBlock.uniqueId = serializedBlock.uniqueId;
|
|
80
|
-
newBlock.comments = serializedBlock.comments;
|
|
71
|
+
const blockDeserializer = this._blockDeserializersV1.get(serializedBlock.className);
|
|
72
|
+
if (!blockDeserializer) {
|
|
73
|
+
throw new Error(`No deserializer found for block type ${serializedBlock.className}`);
|
|
74
|
+
}
|
|
75
|
+
blockDeserializationWork.push(
|
|
76
|
+
blockDeserializer(smartFilter, serializedBlock, engine).then((newBlock) => {
|
|
77
|
+
// Deserializers are not responsible for setting the uniqueId or comments.
|
|
78
|
+
// This is so they don't have to be passed into the constructors when programmatically creating
|
|
79
|
+
// blocks, and so each deserializer doesn't have to remember to do it.
|
|
80
|
+
newBlock.uniqueId = serializedBlock.uniqueId;
|
|
81
|
+
newBlock.comments = serializedBlock.comments;
|
|
81
82
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
// We need to ensure any uniqueIds generated in the future (e.g. a new block is added to the SmartFilter)
|
|
84
|
+
// are higher than this one.
|
|
85
|
+
UniqueIdGenerator.EnsureIdsGreaterThan(newBlock.uniqueId);
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
87
|
+
// Save in the map
|
|
88
|
+
blockMap.set(newBlock.name, newBlock);
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
91
|
});
|
|
92
92
|
await Promise.all(blockDeserializationWork);
|
|
93
93
|
|
package/src/smartFilter.ts
CHANGED
|
@@ -216,12 +216,14 @@ export class SmartFilter {
|
|
|
216
216
|
}
|
|
217
217
|
});
|
|
218
218
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
block
|
|
219
|
+
try {
|
|
220
|
+
// Do the passed in work
|
|
221
|
+
work();
|
|
222
|
+
} finally {
|
|
223
|
+
// Restore all aggregate blocks, even if work throws
|
|
224
|
+
for (const block of mergedAggregateBlocks) {
|
|
225
|
+
block._unmergeFromSmartFilter();
|
|
226
|
+
}
|
|
225
227
|
}
|
|
226
228
|
}
|
|
227
229
|
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Nullable } from "@babylonjs/core/types";
|
|
2
|
+
import type { ExecException } from "child_process";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Determines if the major and minor versions of two semver strings match
|
|
6
|
+
* @param version1 - The first semver string
|
|
7
|
+
* @param version2 - The second semver string
|
|
8
|
+
* @returns True if the major and minor versions match, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
function majorAndMinorVersionsMatch(version1: string, version2: string): boolean {
|
|
11
|
+
const version1split = version1.split(".");
|
|
12
|
+
const version2split = version2.split(".");
|
|
13
|
+
return version1split[0] === version2split[0] && version1split[1] === version2split[1];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Takes in a semver string (e.g. "0.1.0") and increments the patch version.
|
|
18
|
+
* Note: it does not preserve any prerelease flags in the patch version.
|
|
19
|
+
* @param version - The semver string to operate on
|
|
20
|
+
* @returns The incremented version string
|
|
21
|
+
*/
|
|
22
|
+
function incrementPatchVersion(version: string): string {
|
|
23
|
+
const spl = version.split(".");
|
|
24
|
+
if (spl.length < 3) {
|
|
25
|
+
throw new Error("version string must have at least 3 parts");
|
|
26
|
+
}
|
|
27
|
+
spl[spl.length - 1] = (Number.parseInt(spl[spl.length - 1]!) + 1).toString();
|
|
28
|
+
return spl.join(".");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Takes in a semver string (e.g. "0.1.0" or "0.1.0-alpha") and removes any prerelease flag.
|
|
33
|
+
* @param version - The semver string to operate on
|
|
34
|
+
* @returns The version string with the prerelease flag removed
|
|
35
|
+
*/
|
|
36
|
+
export function removePrereleaseFlags(version: string): string {
|
|
37
|
+
const spl = version.split(".");
|
|
38
|
+
if (spl.length < 3) {
|
|
39
|
+
throw new Error("version string must have at least 3 parts");
|
|
40
|
+
}
|
|
41
|
+
spl[spl.length - 1] = Number.parseInt(spl[spl.length - 1]!).toString();
|
|
42
|
+
return spl.join(".");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Given the npmVersion, packageJSONVersion, and alpha flag, determines the version to use
|
|
47
|
+
* @param npmVersion - The version from the NPM registry
|
|
48
|
+
* @param packageJSONVersion - The version from the package.json file
|
|
49
|
+
* @param alpha - A flag to indicate if the version should have an alpha prerelease flag
|
|
50
|
+
* @returns The version to use
|
|
51
|
+
*/
|
|
52
|
+
export function determineVersion(npmVersion: Nullable<string>, packageJSONVersion: string, alpha: boolean): string {
|
|
53
|
+
packageJSONVersion = removePrereleaseFlags(packageJSONVersion);
|
|
54
|
+
npmVersion = npmVersion === null ? null : removePrereleaseFlags(npmVersion);
|
|
55
|
+
|
|
56
|
+
let versionToUse;
|
|
57
|
+
if (npmVersion === null || !majorAndMinorVersionsMatch(npmVersion, packageJSONVersion)) {
|
|
58
|
+
console.log("Major & minor versions do not match: using the current package.json version");
|
|
59
|
+
versionToUse = packageJSONVersion;
|
|
60
|
+
} else {
|
|
61
|
+
console.log("Major & minor versions match: using the NPM registry version with an incremented patch version.");
|
|
62
|
+
versionToUse = incrementPatchVersion(npmVersion);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (alpha) {
|
|
66
|
+
console.log("Ensuring -alpha prerelease flag is present");
|
|
67
|
+
versionToUse += "-alpha";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return versionToUse;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The supported version types
|
|
75
|
+
*/
|
|
76
|
+
export type VersionType = "preview" | "latest";
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Handles error cases and returns the JSON of the package versions
|
|
80
|
+
* @param versionType - The type of version to get
|
|
81
|
+
* @param err - The error object
|
|
82
|
+
* @param stdout - The stdout string
|
|
83
|
+
* @returns The JSON of the package versions
|
|
84
|
+
*/
|
|
85
|
+
export function getNpmVersion(
|
|
86
|
+
versionType: VersionType,
|
|
87
|
+
err: Nullable<ExecException>,
|
|
88
|
+
stdout: string
|
|
89
|
+
): Nullable<string> {
|
|
90
|
+
let npmVersion = null;
|
|
91
|
+
if (err?.message && err.message.indexOf("E404") !== -1) {
|
|
92
|
+
console.warn(`NPM registry does not have any ${versionType} version`);
|
|
93
|
+
} else if (err) {
|
|
94
|
+
console.error(err);
|
|
95
|
+
throw err;
|
|
96
|
+
} else {
|
|
97
|
+
npmVersion = stdout;
|
|
98
|
+
}
|
|
99
|
+
return npmVersion;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Compares two semver strings, returning -1 if version1 is less than version2, 1 if version1 is greater than version2, and 0 if they are equal
|
|
104
|
+
* @param version1 - The first semver string
|
|
105
|
+
* @param version2 - The second semver string
|
|
106
|
+
* @returns -1 if version1 is less than version2, 1 if version1 is greater than version2, and 0 if they are equal
|
|
107
|
+
*/
|
|
108
|
+
export function compareVersions(version1: string, version2: string): number {
|
|
109
|
+
const version1split = removePrereleaseFlags(version1).split(".");
|
|
110
|
+
const version2split = removePrereleaseFlags(version2).split(".");
|
|
111
|
+
|
|
112
|
+
if (version1split.length !== 3 || version2split.length !== 3) {
|
|
113
|
+
throw new Error("version strings must have 3 parts");
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
for (let i = 0; i < 3; i++) {
|
|
117
|
+
const v1 = Number.parseInt(version1split[i]!);
|
|
118
|
+
const v2 = Number.parseInt(version2split[i]!);
|
|
119
|
+
|
|
120
|
+
if (v1 < v2) {
|
|
121
|
+
return -1;
|
|
122
|
+
} else if (v1 > v2) {
|
|
123
|
+
return 1;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return 0;
|
|
127
|
+
}
|