@babylonjs-toolkit/next 9.22.2 → 9.25.1
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/lib/index.d.ts +9 -11
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +9 -11
- package/lib/ipostprocessparameter.d.ts +6 -0
- package/lib/ipostprocessparameter.d.ts.map +1 -0
- package/lib/ipostprocessparameter.js +1 -0
- package/lib/project.d.ts +1 -0
- package/lib/project.d.ts.map +1 -1
- package/lib/project.js +42 -2
- package/lib/scenemanager.d.ts +1567 -81
- package/lib/scenemanager.d.ts.map +1 -1
- package/lib/scenemanager.js +10036 -1067
- package/package.json +14 -14
- package/lib/channelmixerplugin.d.ts +0 -11
- package/lib/channelmixerplugin.d.ts.map +0 -1
- package/lib/channelmixerplugin.js +0 -34
- package/lib/lutblendplugin.d.ts +0 -13
- package/lib/lutblendplugin.d.ts.map +0 -1
- package/lib/lutblendplugin.js +0 -153
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@babylonjs-toolkit/next",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.25.1",
|
|
4
4
|
"description": "Babylon Toolkit Runtime Library (ES6)",
|
|
5
5
|
"author": "MackeyK24 <mackeyk24@gmail.com>",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -160,23 +160,23 @@
|
|
|
160
160
|
"lib/**/*"
|
|
161
161
|
],
|
|
162
162
|
"devDependencies": {
|
|
163
|
-
"@babylonjs/core": "9.
|
|
164
|
-
"@babylonjs/gui": "9.
|
|
163
|
+
"@babylonjs/core": "9.25.0",
|
|
164
|
+
"@babylonjs/gui": "9.25.0",
|
|
165
165
|
"@babylonjs/havok": "^1.3.14",
|
|
166
|
-
"@babylonjs/addons": "9.
|
|
167
|
-
"@babylonjs/loaders": "9.
|
|
168
|
-
"@babylonjs/materials": "9.
|
|
169
|
-
"@babylonjs/inspector": "9.
|
|
166
|
+
"@babylonjs/addons": "9.25.0",
|
|
167
|
+
"@babylonjs/loaders": "9.25.0",
|
|
168
|
+
"@babylonjs/materials": "9.25.0",
|
|
169
|
+
"@babylonjs/inspector": "9.25.0",
|
|
170
170
|
"rimraf": "^6.0.1",
|
|
171
171
|
"typescript": "^6.0.3"
|
|
172
172
|
},
|
|
173
173
|
"peerDependencies": {
|
|
174
|
-
"@babylonjs/core": "9.
|
|
175
|
-
"@babylonjs/gui": "9.
|
|
176
|
-
"@babylonjs/havok": "^1.3.
|
|
177
|
-
"@babylonjs/addons": "9.
|
|
178
|
-
"@babylonjs/loaders": "9.
|
|
179
|
-
"@babylonjs/materials": "9.
|
|
180
|
-
"@babylonjs/inspector": "9.
|
|
174
|
+
"@babylonjs/core": "9.25.0",
|
|
175
|
+
"@babylonjs/gui": "9.25.0",
|
|
176
|
+
"@babylonjs/havok": "^1.3.14",
|
|
177
|
+
"@babylonjs/addons": "9.25.0",
|
|
178
|
+
"@babylonjs/loaders": "9.25.0",
|
|
179
|
+
"@babylonjs/materials": "9.25.0",
|
|
180
|
+
"@babylonjs/inspector": "9.25.0"
|
|
181
181
|
}
|
|
182
182
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Scene } from '@babylonjs/core/scene';
|
|
2
|
-
import { Camera } from '@babylonjs/core/Cameras/camera';
|
|
3
|
-
import { PostProcess } from '@babylonjs/core';
|
|
4
|
-
export declare class ChannelMixerPlugin {
|
|
5
|
-
static CreatePostProcess(scene: Scene, camera: Camera, options?: {
|
|
6
|
-
red?: number[];
|
|
7
|
-
green?: number[];
|
|
8
|
-
blue?: number[];
|
|
9
|
-
}): PostProcess;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=channelmixerplugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"channelmixerplugin.d.ts","sourceRoot":"","sources":["../src/channelmixerplugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,qBAAa,kBAAkB;WAKT,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QACpE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAClB;CAiCJ"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { Texture } from '@babylonjs/core/Materials/Textures/texture';
|
|
2
|
-
import { PostProcess } from '@babylonjs/core';
|
|
3
|
-
export class ChannelMixerPlugin {
|
|
4
|
-
static CreatePostProcess(scene, camera, options) {
|
|
5
|
-
const opts = options || {};
|
|
6
|
-
const red = opts.red || [1, 0, 0];
|
|
7
|
-
const green = opts.green || [0, 1, 0];
|
|
8
|
-
const blue = opts.blue || [0, 0, 1];
|
|
9
|
-
const fragment = `
|
|
10
|
-
precision highp float;
|
|
11
|
-
varying vec2 vUV;
|
|
12
|
-
uniform sampler2D textureSampler;
|
|
13
|
-
uniform vec3 redMix;
|
|
14
|
-
uniform vec3 greenMix;
|
|
15
|
-
uniform vec3 blueMix;
|
|
16
|
-
|
|
17
|
-
void main(void) {
|
|
18
|
-
vec4 sceneColor = texture2D(textureSampler, vUV);
|
|
19
|
-
vec3 rgb = sceneColor.rgb;
|
|
20
|
-
float newR = dot(rgb, redMix);
|
|
21
|
-
float newG = dot(rgb, greenMix);
|
|
22
|
-
float newB = dot(rgb, blueMix);
|
|
23
|
-
gl_FragColor = vec4(newR, newG, newB, sceneColor.a);
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
26
|
-
const post = new PostProcess("channelMixer", fragment, ["redMix", "greenMix", "blueMix"], [], 1.0, camera, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
|
|
27
|
-
post.onApply = (effect) => {
|
|
28
|
-
effect.setFloat3('redMix', red[0] || 1, red[1] || 0, red[2] || 0);
|
|
29
|
-
effect.setFloat3('greenMix', green[0] || 0, green[1] || 1, green[2] || 0);
|
|
30
|
-
effect.setFloat3('blueMix', blue[0] || 0, blue[1] || 0, blue[2] || 1);
|
|
31
|
-
};
|
|
32
|
-
return post;
|
|
33
|
-
}
|
|
34
|
-
}
|
package/lib/lutblendplugin.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Scene } from '@babylonjs/core/scene';
|
|
2
|
-
import { Camera } from '@babylonjs/core/Cameras/camera';
|
|
3
|
-
import { Texture } from '@babylonjs/core/Materials/Textures/texture';
|
|
4
|
-
import { PostProcess } from '@babylonjs/core';
|
|
5
|
-
export declare class LUTBlendPlugin {
|
|
6
|
-
static CreatePostProcess(scene: Scene, camera: Camera, options?: {
|
|
7
|
-
lutA?: string | Texture;
|
|
8
|
-
lutB?: string | Texture;
|
|
9
|
-
mix?: number;
|
|
10
|
-
}): PostProcess;
|
|
11
|
-
getWGSLShaderCode(): string;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=lutblendplugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lutblendplugin.d.ts","sourceRoot":"","sources":["../src/lutblendplugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,4CAA4C,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAG9C,qBAAa,cAAc;WAKL,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QACpE,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QACxB,GAAG,CAAC,EAAE,MAAM,CAAA;KACf;IA8GM,iBAAiB,IAAI,MAAM;CAiDrC"}
|
package/lib/lutblendplugin.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { Texture } from '@babylonjs/core/Materials/Textures/texture';
|
|
2
|
-
import { PostProcess } from '@babylonjs/core';
|
|
3
|
-
export class LUTBlendPlugin {
|
|
4
|
-
static CreatePostProcess(scene, camera, options) {
|
|
5
|
-
const lutA = options?.lutA || null;
|
|
6
|
-
const lutB = options?.lutB || null;
|
|
7
|
-
const mix = options?.mix ?? 0.0;
|
|
8
|
-
const fragment = `
|
|
9
|
-
precision highp float;
|
|
10
|
-
varying vec2 vUV;
|
|
11
|
-
uniform sampler2D textureSampler;
|
|
12
|
-
uniform sampler2D lutA;
|
|
13
|
-
uniform sampler2D lutB;
|
|
14
|
-
uniform float mixVal;
|
|
15
|
-
uniform float lutTileCountA; // number of tiles per row for LUT A
|
|
16
|
-
uniform float lutTileCountB; // number of tiles per row for LUT B
|
|
17
|
-
|
|
18
|
-
vec3 sampleLUT(in sampler2D lut, in vec3 color, in float tileCount) {
|
|
19
|
-
if (tileCount <= 0.5) return color;
|
|
20
|
-
float tc = floor(tileCount + 0.5);
|
|
21
|
-
float tileSize = 1.0 / tc;
|
|
22
|
-
|
|
23
|
-
// For normalized RGB [0..1], compute position in LUT
|
|
24
|
-
float r = color.r;
|
|
25
|
-
float g = color.g;
|
|
26
|
-
float b = color.b;
|
|
27
|
-
|
|
28
|
-
// Determine slice and tile coords
|
|
29
|
-
float slice = b * (tc - 1.0);
|
|
30
|
-
float sliceIndex = floor(slice + 0.5);
|
|
31
|
-
|
|
32
|
-
float tx = mod(sliceIndex, tc);
|
|
33
|
-
float ty = floor(sliceIndex / tc);
|
|
34
|
-
|
|
35
|
-
vec2 uv = vec2(tx * tileSize + r * tileSize, ty * tileSize + g * tileSize);
|
|
36
|
-
vec3 sampled = texture2D(lut, uv).rgb;
|
|
37
|
-
return sampled;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
void main(void) {
|
|
41
|
-
vec4 sceneColor = texture2D(textureSampler, vUV);
|
|
42
|
-
vec3 a = sceneColor.rgb;
|
|
43
|
-
if (lutTileCountA <= 0.5 || lutTileCountB <= 0.5) {
|
|
44
|
-
// No LUT size provided fallback to passthrough
|
|
45
|
-
gl_FragColor = sceneColor;
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
vec3 colA = sampleLUT(lutA, a, lutTileCountA);
|
|
49
|
-
vec3 colB = sampleLUT(lutB, a, lutTileCountB);
|
|
50
|
-
vec3 outc = mix(colA, colB, mixVal);
|
|
51
|
-
gl_FragColor = vec4(outc, sceneColor.a);
|
|
52
|
-
}
|
|
53
|
-
`;
|
|
54
|
-
const post = new PostProcess("lutBlend", fragment, ["mixVal", "lutTileCountA", "lutTileCountB"], ["lutA", "lutB"], 1.0, camera, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
|
|
55
|
-
function detectTileCountFromDims(w, h) {
|
|
56
|
-
if (!w || !h)
|
|
57
|
-
return 0;
|
|
58
|
-
if (w % h === 0)
|
|
59
|
-
return Math.round(w / h);
|
|
60
|
-
if (h % w === 0)
|
|
61
|
-
return Math.round(h / w);
|
|
62
|
-
if (w === h) {
|
|
63
|
-
const t = Math.round(Math.sqrt(w));
|
|
64
|
-
if (t * t === w)
|
|
65
|
-
return t;
|
|
66
|
-
return Math.round(Math.sqrt(w));
|
|
67
|
-
}
|
|
68
|
-
return Math.round(Math.pow(w * h, 1.0 / 3.0));
|
|
69
|
-
}
|
|
70
|
-
let tileA = 0, tileB = 0;
|
|
71
|
-
post.onApply = (effect) => {
|
|
72
|
-
effect.setFloat('mixVal', mix);
|
|
73
|
-
if (lutA && typeof lutA === 'string') {
|
|
74
|
-
const tA = new Texture(lutA, scene, true, false, Texture.TRILINEAR_SAMPLINGMODE, undefined, undefined, undefined, false);
|
|
75
|
-
tA.onLoadObservable.addOnce(() => {
|
|
76
|
-
tileA = detectTileCountFromDims(tA.getSize ? tA.getSize().width : tA.width, tA.getSize ? tA.getSize().height : tA.height);
|
|
77
|
-
});
|
|
78
|
-
effect.setTexture('lutA', tA);
|
|
79
|
-
}
|
|
80
|
-
else if (lutA instanceof Texture) {
|
|
81
|
-
const tA = lutA;
|
|
82
|
-
tileA = detectTileCountFromDims(tA.getSize ? tA.getSize().width : tA.width, tA.getSize ? tA.getSize().height : tA.height);
|
|
83
|
-
effect.setTexture('lutA', tA);
|
|
84
|
-
}
|
|
85
|
-
if (lutB && typeof lutB === 'string') {
|
|
86
|
-
const tB = new Texture(lutB, scene, true, false, Texture.TRILINEAR_SAMPLINGMODE, undefined, undefined, undefined, false);
|
|
87
|
-
tB.onLoadObservable.addOnce(() => {
|
|
88
|
-
tileB = detectTileCountFromDims(tB.getSize ? tB.getSize().width : tB.width, tB.getSize ? tB.getSize().height : tB.height);
|
|
89
|
-
});
|
|
90
|
-
effect.setTexture('lutB', tB);
|
|
91
|
-
}
|
|
92
|
-
else if (lutB instanceof Texture) {
|
|
93
|
-
const tB = lutB;
|
|
94
|
-
tileB = detectTileCountFromDims(tB.getSize ? tB.getSize().width : tB.width, tB.getSize ? tB.getSize().height : tB.height);
|
|
95
|
-
effect.setTexture('lutB', tB);
|
|
96
|
-
}
|
|
97
|
-
effect.setFloat('lutTileCountA', tileA);
|
|
98
|
-
effect.setFloat('lutTileCountB', tileB);
|
|
99
|
-
};
|
|
100
|
-
post._detectedTileCountA = () => tileA;
|
|
101
|
-
post._detectedTileCountB = () => tileB;
|
|
102
|
-
return post;
|
|
103
|
-
}
|
|
104
|
-
getWGSLShaderCode() {
|
|
105
|
-
return `
|
|
106
|
-
[[group(0), binding(0)]] var textureSampler: texture_2d<f32>;
|
|
107
|
-
[[group(0), binding(1)]] var textureSamplerSampler: sampler;
|
|
108
|
-
[[group(0), binding(2)]] var lutA: texture_2d<f32>;
|
|
109
|
-
[[group(0), binding(3)]] var lutASampler: sampler;
|
|
110
|
-
[[group(0), binding(4)]] var lutB: texture_2d<f32>;
|
|
111
|
-
[[group(0), binding(5)]] var lutBSampler: sampler;
|
|
112
|
-
|
|
113
|
-
[[block]] struct Uniforms {
|
|
114
|
-
mixVal: f32;
|
|
115
|
-
lutTileCountA: f32;
|
|
116
|
-
lutTileCountB: f32;
|
|
117
|
-
};
|
|
118
|
-
[[group(0), binding(6)]] var<uniform> uniforms: Uniforms;
|
|
119
|
-
|
|
120
|
-
fn sampleLUT(lut: texture_2d<f32>, lutSamp: sampler, color: vec3<f32>, tileCount: f32) -> vec3<f32> {
|
|
121
|
-
if (tileCount <= 0.5) { return color; }
|
|
122
|
-
let tc = floor(tileCount + 0.5);
|
|
123
|
-
let tileSize = 1.0 / tc;
|
|
124
|
-
|
|
125
|
-
let r = color.r;
|
|
126
|
-
let g = color.g;
|
|
127
|
-
let b = color.b;
|
|
128
|
-
|
|
129
|
-
let slice = b * (tc - 1.0);
|
|
130
|
-
let sliceIndex = floor(slice + 0.5);
|
|
131
|
-
|
|
132
|
-
let tx = sliceIndex % tc;
|
|
133
|
-
let ty = floor(sliceIndex / tc);
|
|
134
|
-
|
|
135
|
-
let uv = vec2<f32>(tx * tileSize + r * tileSize, ty * tileSize + g * tileSize);
|
|
136
|
-
let sampled = textureSample(lut, lutSamp, uv).rgb;
|
|
137
|
-
return sampled;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
fn mainImage(vUV: vec2<f32>) -> vec4<f32> {
|
|
141
|
-
let sceneColor = textureSample(textureSampler, textureSamplerSampler, vUV);
|
|
142
|
-
let a = sceneColor.rgb;
|
|
143
|
-
if (uniforms.lutTileCountA <= 0.5 || uniforms.lutTileCountB <= 0.5) {
|
|
144
|
-
return sceneColor;
|
|
145
|
-
}
|
|
146
|
-
let colA = sampleLUT(lutA, lutASampler, a, uniforms.lutTileCountA);
|
|
147
|
-
let colB = sampleLUT(lutB, lutBSampler, a, uniforms.lutTileCountB);
|
|
148
|
-
let outc = mix(colA, colB, uniforms.mixVal);
|
|
149
|
-
return vec4<f32>(outc, sceneColor.a);
|
|
150
|
-
}
|
|
151
|
-
`;
|
|
152
|
-
}
|
|
153
|
-
}
|