@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
|
@@ -36,7 +36,8 @@ const ShaderTemplate = `import type { ShaderProgram } from "${TYPE_IMPORT_PATH}"
|
|
|
36
36
|
export const shaderProgram: ShaderProgram = {
|
|
37
37
|
vertex: ${VERTEX_SHADER},
|
|
38
38
|
fragment: {
|
|
39
|
-
uniform: \`${UNIFORMS}
|
|
39
|
+
uniform: \`${UNIFORMS}
|
|
40
|
+
uniform bool _disabled_;\`,${CONSTS_PROPERTY}
|
|
40
41
|
mainInputTexture: "${MAIN_INPUT_NAME}",
|
|
41
42
|
mainFunctionName: "${MAIN_FUNCTION_NAME}",
|
|
42
43
|
functions: [${FUNCTIONS}
|
|
@@ -195,9 +196,6 @@ function processFragmentShaderV1(fragmentShader: string): FragmentShaderInfo {
|
|
|
195
196
|
// Extract all the consts
|
|
196
197
|
const finalConsts = [...fragmentShaderWithRenamedSymbols.matchAll(/^\s*(const\s.*)/gm)].map((match) => match[1]);
|
|
197
198
|
|
|
198
|
-
// Extract all the functions
|
|
199
|
-
const { extractedFunctions, mainFunctionName } = extractFunctions(fragmentShaderWithRenamedSymbols);
|
|
200
|
-
|
|
201
199
|
// Find the main input
|
|
202
200
|
const mainInputs = [...fragmentShaderWithRenamedSymbols.matchAll(/\S*uniform.*\s(\w*);\s*\/\/\s*main/gm)].map(
|
|
203
201
|
(match) => match[1]
|
|
@@ -207,6 +205,9 @@ function processFragmentShaderV1(fragmentShader: string): FragmentShaderInfo {
|
|
|
207
205
|
}
|
|
208
206
|
const mainInputName = mainInputs[0];
|
|
209
207
|
|
|
208
|
+
// Extract all the functions
|
|
209
|
+
const { extractedFunctions, mainFunctionName } = extractFunctions(fragmentShaderWithRenamedSymbols, mainInputName);
|
|
210
|
+
|
|
210
211
|
return {
|
|
211
212
|
finalUniforms,
|
|
212
213
|
mainFunctionName,
|
|
@@ -233,9 +234,13 @@ function addLinePrefixes(input: string, prefix: string): string {
|
|
|
233
234
|
/**
|
|
234
235
|
* Extracts all the functions from the shader
|
|
235
236
|
* @param fragment - The shader code to process
|
|
237
|
+
* @param mainInputName - The name of the main input
|
|
236
238
|
* @returns A list of functions
|
|
237
239
|
*/
|
|
238
|
-
function extractFunctions(
|
|
240
|
+
function extractFunctions(
|
|
241
|
+
fragment: string,
|
|
242
|
+
mainInputName: string
|
|
243
|
+
): {
|
|
239
244
|
/**
|
|
240
245
|
* The extracted functions
|
|
241
246
|
*/
|
|
@@ -270,10 +275,16 @@ function extractFunctions(fragment: string): {
|
|
|
270
275
|
if (inFunction && depth === 0) {
|
|
271
276
|
inFunction = false;
|
|
272
277
|
const { functionBody, functionName, isMainFunction } = processFunctionBody(currentFunction);
|
|
278
|
+
|
|
279
|
+
let body = functionBody;
|
|
280
|
+
if (isMainFunction) {
|
|
281
|
+
body = functionBody.replace("{", `{\n if (_disabled_) return texture2D(${mainInputName}, vUV);\n`);
|
|
282
|
+
}
|
|
283
|
+
|
|
273
284
|
extractedFunctions.push(
|
|
274
285
|
FunctionTemplate.replace(FUNCTION_NAME, functionName).replace(
|
|
275
286
|
FUNCTION_CODE,
|
|
276
|
-
addLinePrefixes(
|
|
287
|
+
addLinePrefixes(body, CodeLinePrefix)
|
|
277
288
|
)
|
|
278
289
|
);
|
|
279
290
|
if (isMainFunction) {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import { exec, type ExecException } from "child_process";
|
|
3
|
+
import { compareVersions, determineVersion, getNpmVersion, type VersionType } from "./determineVersion.js";
|
|
4
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
|
5
|
+
|
|
6
|
+
const alpha = process.argv.includes("--alpha");
|
|
7
|
+
const packageText = fs.readFileSync("package.json");
|
|
8
|
+
const packageJSON = JSON.parse(packageText.toString());
|
|
9
|
+
|
|
10
|
+
const packageName = packageJSON.name;
|
|
11
|
+
console.log("Processing package:", packageName);
|
|
12
|
+
console.log("Alpha flag:", alpha);
|
|
13
|
+
console.log("Current package.json version:", packageJSON.version);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Queries the NPM registry for the specified version type
|
|
17
|
+
* @param versionType - The type of version to query
|
|
18
|
+
* @param callback - The callback to call with the NPM version
|
|
19
|
+
*/
|
|
20
|
+
function queryNpmFeed(versionType: VersionType, callback: (npmVersion: Nullable<string>) => void) {
|
|
21
|
+
exec(`npm view ${packageName} dist-tags.${versionType}`, (err: Nullable<ExecException>, stdout) => {
|
|
22
|
+
let npmVersion = getNpmVersion(versionType, err, stdout);
|
|
23
|
+
if (npmVersion !== null) {
|
|
24
|
+
npmVersion = npmVersion.trim();
|
|
25
|
+
console.log(`NPM Registry ${versionType} version:`, npmVersion);
|
|
26
|
+
}
|
|
27
|
+
callback(npmVersion);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
queryNpmFeed("preview", (npmPreviewVersion) => {
|
|
32
|
+
queryNpmFeed("latest", (npmLatestVersion) => {
|
|
33
|
+
let highestNpmVersion: Nullable<string> = npmLatestVersion;
|
|
34
|
+
if (npmPreviewVersion && (!highestNpmVersion || compareVersions(npmPreviewVersion, highestNpmVersion) === 1)) {
|
|
35
|
+
highestNpmVersion = npmPreviewVersion;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log("Highest NPM Registry version:", highestNpmVersion);
|
|
39
|
+
|
|
40
|
+
const versionToUse = determineVersion(highestNpmVersion, packageJSON.version, alpha);
|
|
41
|
+
|
|
42
|
+
console.log("Version to use:", versionToUse);
|
|
43
|
+
|
|
44
|
+
if (packageJSON.version !== versionToUse) {
|
|
45
|
+
packageJSON.version = versionToUse;
|
|
46
|
+
fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 4));
|
|
47
|
+
console.log("Version updated in package.json");
|
|
48
|
+
} else {
|
|
49
|
+
console.log("No need to update package.json");
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -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
|
/**
|
|
5
6
|
* Helper that takes in a URL to an image and returns a ThinTexture
|
|
@@ -15,14 +16,14 @@ import { type ThinEngine } from "@babylonjs/core/Engines/thinEngine.js";
|
|
|
15
16
|
export function createImageTexture(
|
|
16
17
|
engine: ThinEngine,
|
|
17
18
|
url: string,
|
|
18
|
-
flipY: boolean =
|
|
19
|
+
flipY: Nullable<boolean> = null,
|
|
19
20
|
samplingMode: number | undefined = undefined,
|
|
20
21
|
forcedExtension: string | null = null
|
|
21
22
|
): ThinTexture {
|
|
22
23
|
const internalTexture = engine.createTexture(
|
|
23
24
|
url,
|
|
24
25
|
true,
|
|
25
|
-
flipY,
|
|
26
|
+
flipY ?? true,
|
|
26
27
|
null,
|
|
27
28
|
samplingMode,
|
|
28
29
|
null,
|