@voluma/vlam 0.2.1 → 0.2.3
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/README.md +1 -3
- package/dist/effects.d.ts +90 -5
- package/dist/effects.js +183 -114
- package/dist/effects.js.map +1 -1
- package/dist/formats/lcc.js +320 -292
- package/dist/formats/lcc.js.map +1 -1
- package/dist/formats/rad.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +748 -651
- package/dist/index.js.map +1 -1
- package/dist/lod-source.d.ts +7 -0
- package/dist/relighting-pass.d.ts +49 -0
- package/dist/{splat-budget-PSojLJPO.js → splat-budget-DXew_86c.js} +64 -57
- package/dist/splat-budget-DXew_86c.js.map +1 -0
- package/dist/splat-budget.d.ts +24 -4
- package/dist/{splat-mesh-types-8QDjTbZO.js → splat-mesh-types-CTN_duw2.js} +2 -2
- package/dist/{splat-mesh-types-8QDjTbZO.js.map → splat-mesh-types-CTN_duw2.js.map} +1 -1
- package/dist/streamed-splat-mesh-utils.d.ts +1 -1
- package/dist/streamed-splat-mesh.d.ts +51 -25
- package/dist/worker-sorter.d.ts +13 -0
- package/package.json +1 -1
- package/dist/splat-budget-PSojLJPO.js.map +0 -1
package/README.md
CHANGED
|
@@ -16,9 +16,7 @@ Local site and generated API: `npm run dev` (http://localhost:5170, viewer at `/
|
|
|
16
16
|
> Package `@voluma/vlam`, public **0.2.0**. APIs may still move before 1.0.
|
|
17
17
|
|
|
18
18
|
## Important notice!
|
|
19
|
-
This is a pre-release. The API can still change in breaking ways before v1.0.
|
|
20
|
-
|
|
21
|
-
Phones and laptops with integrated graphics, like a MacBook Air, still need a lot of testing and tuning. Frame rate and image quality on those devices are not final.
|
|
19
|
+
This is a pre-release not yet recommended for production. The API can still change in breaking ways before v1.0.
|
|
22
20
|
|
|
23
21
|
|
|
24
22
|
## Install
|
package/dist/effects.d.ts
CHANGED
|
@@ -15,6 +15,12 @@
|
|
|
15
15
|
* tiles (or raw geometries) for PlayCanvas-style {@link SplatMesh.setRelighting}.
|
|
16
16
|
* - {@link createRelightingShadowFactorMaterial}: writes a shadow **multiplier**
|
|
17
17
|
* (1 = lit, <1 = umbra) so coverage does not statically tint splats.
|
|
18
|
+
* Accepts one light or {@link RelightingLightContribution}[] with intensity
|
|
19
|
+
* weights. Optional `color` / `diffuse` / `direction` add a Lambert boost on
|
|
20
|
+
* top of that identity (RGB may exceed 1 on a HalfFloat lighting RT).
|
|
21
|
+
* - {@link renderRelightingFactorMap}: host-safe lighting pass. Isolates
|
|
22
|
+
* `autoClear`, shadow maps, and swaps a passthrough `contextNode` so the
|
|
23
|
+
* example works on an existing `WebGPURenderer`, not only `createSplatRenderer`.
|
|
18
24
|
* - {@link worldWarpPreset}: camera-centered sphere wrap (planet / bowl).
|
|
19
25
|
* - {@link depthOfFieldPreset}: stylized modifier-based depth-of-field (M13).
|
|
20
26
|
* For physically-modeled camera DoF prefer the core
|
|
@@ -262,6 +268,7 @@ export declare function worldWarpPreset(options?: {
|
|
|
262
268
|
intensity?: number;
|
|
263
269
|
radius?: number;
|
|
264
270
|
}): WorldWarpPreset;
|
|
271
|
+
export { renderRelightingFactorMap, type RelightingFactorRenderer } from './relighting-pass';
|
|
265
272
|
/** Handle returned by {@link createRelightingProxy}. */
|
|
266
273
|
export interface RelightingProxy {
|
|
267
274
|
/** World-space group of lit proxy meshes (hide from the main splat scene). */
|
|
@@ -274,14 +281,68 @@ export interface RelightingProxy {
|
|
|
274
281
|
/** Disposes geometries and the default material owned by this helper. */
|
|
275
282
|
dispose(): void;
|
|
276
283
|
}
|
|
284
|
+
/** One independent shadow-casting light for {@link createRelightingShadowFactorMaterial}. */
|
|
285
|
+
export type RelightingLightContribution = {
|
|
286
|
+
light: THREE.Light;
|
|
287
|
+
/** Relative umbra weight. Default `1`. Values `<= 0` are skipped. */
|
|
288
|
+
intensity?: number;
|
|
289
|
+
};
|
|
290
|
+
/** Options for {@link createRelightingShadowFactorMaterial}. */
|
|
291
|
+
export type RelightingShadowFactorOptions = {
|
|
292
|
+
umbra?: number;
|
|
293
|
+
receiveUpMin?: number;
|
|
294
|
+
color?: THREE.Color;
|
|
295
|
+
diffuse?: number;
|
|
296
|
+
direction?: THREE.Vector3;
|
|
297
|
+
/**
|
|
298
|
+
* How independent contributions combine into one multiplier.
|
|
299
|
+
* - `average` (default): intensity-weighted mean of shadows (fill lights).
|
|
300
|
+
* - `min`: union of umbras — each caster keeps its own silhouette. Contribution
|
|
301
|
+
* `intensity` scales umbra depth: `0` → none, `1` → default `umbra`,
|
|
302
|
+
* `>1` → darker than default (`umbra_i = clamp(1 - I*(1-umbra), 0, 1)`).
|
|
303
|
+
*/
|
|
304
|
+
combine?: 'average' | 'min';
|
|
305
|
+
midLight?: THREE.Light;
|
|
306
|
+
midRadius?: number;
|
|
307
|
+
outerLight?: THREE.Light;
|
|
308
|
+
outerRadius?: number;
|
|
309
|
+
farLight?: THREE.Light;
|
|
310
|
+
nearRadius?: number;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* Cap on independent shadow lights (cascades of the first directional do not
|
|
314
|
+
* count). Extra contributions are ignored. The compiled graph unrolls only
|
|
315
|
+
* the live contribution count, not a padded 32-wide loop.
|
|
316
|
+
*/
|
|
317
|
+
export declare const MAX_RELIGHTING_SHADOW_LIGHTS = 32;
|
|
277
318
|
/**
|
|
278
319
|
* Node material for a **shadow-factor** lighting RT used with
|
|
279
320
|
* {@link SplatMesh.setRelighting}.
|
|
280
321
|
*
|
|
281
|
-
* Fragment output is `vec4(vec3(mix(umbra, 1, shadow
|
|
322
|
+
* Fragment output is `vec4(vec3(mix(umbra, 1, shadow)) + boost, 1)`:
|
|
282
323
|
* - covered + lit → RGB ≈ 1 (identity modulate when brightness/background are 1)
|
|
283
324
|
* - covered + umbra → RGB ≈ `umbra` (soft darken; never pure black)
|
|
284
325
|
* - uncovered stays clear-alpha 0 from the RT clear
|
|
326
|
+
* - with `diffuse` > 0, facing surfaces add `color * NdotL * diffuse`
|
|
327
|
+
* (RGB may exceed 1; use a HalfFloat lighting RT)
|
|
328
|
+
*
|
|
329
|
+
* Pass one {@link THREE.Light} (demo / single-sun) or an array of
|
|
330
|
+
* {@link RelightingLightContribution} so independent lights share one
|
|
331
|
+
* multiplier. Default combine is intensity-weighted average
|
|
332
|
+
* (`illum = sum(I_i * shadow_i) / sum(I_i)`); pass `combine: 'min'` for a
|
|
333
|
+
* union of umbras so each caster keeps its silhouette. Spot / point lights
|
|
334
|
+
* with `distance > 0` fade their umbra to lit via a Frostbite cutoff window
|
|
335
|
+
* (steepened by `decay`) so the shadow map far plane is not a hard cliff.
|
|
336
|
+
* Cascades (`midLight` / `outerLight` / `farLight`) still attach to the
|
|
337
|
+
* **first** directional only. At most {@link MAX_RELIGHTING_SHADOW_LIGHTS}
|
|
338
|
+
* independent lights are used; extras are ignored. Graph size follows the
|
|
339
|
+
* live contribution count (not a padded loop of that width).
|
|
340
|
+
*
|
|
341
|
+
* By default, only **upward** proxy faces receive (`receiveUpMin`). Vertical
|
|
342
|
+
* and noisy foliage triangles still **cast**, but they do not self-shadow —
|
|
343
|
+
* that PCF acne reads as per-frame sparkle in trees. Pass `receiveUpMin: 0`
|
|
344
|
+
* to receive on every face. The Lambert term uses the same slope gate, so
|
|
345
|
+
* steep foliage does not pick up a noisy tint.
|
|
285
346
|
*
|
|
286
347
|
* Clear the lighting RT to **RGB 1, A 0** (not black). Softness / bilinear
|
|
287
348
|
* samples at coverage edges otherwise pull in black and draw a dark outline
|
|
@@ -292,12 +353,36 @@ export interface RelightingProxy {
|
|
|
292
353
|
* Assign to proxy meshes with `castShadow` and `receiveShadow` both true; the
|
|
293
354
|
* umbra shape follows those triangles (splat foliage cannot cast).
|
|
294
355
|
*
|
|
295
|
-
* @param
|
|
356
|
+
* @param lights - Shadow-casting light, or intensity-weighted contributions.
|
|
357
|
+
* The first entry is the innermost cascade when `midLight` / `outerLight` /
|
|
358
|
+
* `farLight` are set.
|
|
296
359
|
* @param options.umbra - Multiplier in full shadow, in `[0, 1]`. Default `0.45`.
|
|
360
|
+
* @param options.receiveUpMin - World-up `normal.y` below which the face does
|
|
361
|
+
* not receive. Default `0.25`. `0` disables the slope gate.
|
|
362
|
+
* @param options.color - Light tint for the optional Lambert boost. Mutate
|
|
363
|
+
* in place; the material holds this object. Default white.
|
|
364
|
+
* @param options.diffuse - Lambert boost on top of identity. Default `0`
|
|
365
|
+
* (shadow multiplier only). Facing, unshadowed coverage becomes
|
|
366
|
+
* `1 + color * NdotL * diffuse`.
|
|
367
|
+
* @param options.direction - World-space direction **toward** the light.
|
|
368
|
+
* Mutate in place each frame as the sun moves. Default `(0, 1, 0)`.
|
|
369
|
+
* @param options.midLight - Optional mid cascade (demo: ~50 m). Blend from
|
|
370
|
+
* the first light over `nearRadius`.
|
|
371
|
+
* @param options.midRadius - World metres where the mid cascade yields to
|
|
372
|
+
* `outerLight` (or `farLight`). Default `50`.
|
|
373
|
+
* @param options.outerLight - Optional outer cascade (demo: ~160 m) between
|
|
374
|
+
* mid and scene-sized far. Blend from mid over `midRadius`, then to
|
|
375
|
+
* `farLight` over `outerRadius`.
|
|
376
|
+
* @param options.outerRadius - World metres where the outer cascade yields to
|
|
377
|
+
* `farLight`. Default `160`. Ignored without `outerLight` and `farLight`.
|
|
378
|
+
* @param options.farLight - Optional scene-sized cascade. Out-of-frustum
|
|
379
|
+
* `shadow()` is 1 (lit), so inner maps can stay tight without clipping
|
|
380
|
+
* distant umbras. Blend by camera distance.
|
|
381
|
+
* @param options.nearRadius - World metres where the inner cascade yields to
|
|
382
|
+
* `midLight` (or to `farLight` if there is no mid). Default `20` with
|
|
383
|
+
* `midLight`, else `100`.
|
|
297
384
|
*/
|
|
298
|
-
export declare function createRelightingShadowFactorMaterial(
|
|
299
|
-
umbra?: number;
|
|
300
|
-
}): THREE.MeshStandardNodeMaterial;
|
|
385
|
+
export declare function createRelightingShadowFactorMaterial(lights: THREE.Light | RelightingLightContribution[], options?: RelightingShadowFactorOptions): THREE.MeshStandardNodeMaterial;
|
|
301
386
|
/**
|
|
302
387
|
* Builds a PlayCanvas-style relighting **proxy** from collision tiles or raw
|
|
303
388
|
* geometries. The host places {@link RelightingProxy.group} on a dedicated
|
package/dist/effects.js
CHANGED
|
@@ -1,87 +1,100 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import {
|
|
3
|
-
import { w as
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import * as p from "three/webgpu";
|
|
2
|
+
import { context as ct, positionWorld as et, cameraPosition as rt, smoothstep as O, float as a, normalWorld as Z, mix as b, min as lt, uniform as C, vec4 as A, vec3 as M, wgslFn as ut, uniformArray as dt, shadow as S, int as ft, mat3 as mt, modelViewMatrix as ht, vec2 as gt } from "three/tsl";
|
|
3
|
+
import { w as xt } from "./logging-BfPdd7NJ.js";
|
|
4
|
+
const J = new p.Vector2(), tt = new p.Color(), bt = ct({
|
|
5
|
+
getOutput: (t) => t
|
|
6
|
+
});
|
|
7
|
+
function Nt(t, e, r, i) {
|
|
8
|
+
t.getDrawingBufferSize(J), i.setSize(Math.max(1, J.x), Math.max(1, J.y));
|
|
9
|
+
const f = t.getRenderTarget(), u = t.getActiveCubeFace(), d = t.getActiveMipmapLevel(), n = t.getMRT(), h = t.getClearAlpha(), s = t.autoClear, m = t.shadowMap.enabled, l = t.shadowMap.autoUpdate, o = t.contextNode;
|
|
10
|
+
t.getClearColor(tt);
|
|
11
|
+
try {
|
|
12
|
+
t.contextNode = bt, t.autoClear = !0, t.shadowMap.enabled = !0, l === !1 && (t.shadowMap.autoUpdate = !0), t.setMRT(null), t.setRenderTarget(i), t.setClearColor(16777215, 0), t.clear(), t.render(e, r);
|
|
13
|
+
} finally {
|
|
14
|
+
t.setRenderTarget(f, u, d), t.setMRT(n), t.setClearColor(tt, h), t.autoClear = s, t.shadowMap.enabled = m, l !== void 0 && (t.shadowMap.autoUpdate = l), t.contextNode = o;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const K = 5, pt = { tint: 0, desaturate: 1, hide: 2, rim: 3 }, wt = [0, 0, 0], Mt = [1, 1, 1], yt = [0, 0, 0, 1];
|
|
18
|
+
function Ft(t = [], e = {}) {
|
|
19
|
+
const r = Math.max(1, Math.floor(e.maxShapes ?? 32)), i = [];
|
|
20
|
+
for (let s = 0; s < r * K; s++) i.push(new p.Vector4());
|
|
21
|
+
const f = dt(i, "vec4"), u = C(0, "int");
|
|
22
|
+
let d = !1;
|
|
23
|
+
const n = (s) => {
|
|
24
|
+
const m = Math.min(s.length, r);
|
|
25
|
+
s.length > r && !d && (d = !0, xt(
|
|
26
|
+
`sdfEffects: ${s.length} shapes exceeds maxShapes=${r}; extra shapes are ignored. Raise maxShapes if you need more.`
|
|
14
27
|
));
|
|
15
|
-
for (let
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
if (!
|
|
28
|
+
for (let l = 0; l < m; l++) {
|
|
29
|
+
const o = s[l];
|
|
30
|
+
if (o.kind === "box") {
|
|
31
|
+
const c = o.halfExtents;
|
|
32
|
+
if (!c || !(c[0] > 0) || !(c[1] > 0) || !(c[2] > 0))
|
|
20
33
|
throw new Error(
|
|
21
|
-
`sdfEffects.setShapes: shape ${
|
|
34
|
+
`sdfEffects.setShapes: shape ${l} is a box and requires halfExtents with three positive components (got ${c ? `[${c.join(", ")}]` : "undefined"}).`
|
|
22
35
|
);
|
|
23
|
-
} else if (typeof
|
|
24
|
-
if (
|
|
36
|
+
} else if (typeof o.radius == "number" && o.radius > 0) {
|
|
37
|
+
if (o.kind === "cylinder" && !(typeof o.height == "number" && o.height > 0))
|
|
25
38
|
throw new Error(
|
|
26
|
-
`sdfEffects.setShapes: shape ${
|
|
39
|
+
`sdfEffects.setShapes: shape ${l} is a cylinder and requires a positive height (got ${String(o.height)}).`
|
|
27
40
|
);
|
|
28
41
|
} else throw new Error(
|
|
29
|
-
`sdfEffects.setShapes: shape ${
|
|
42
|
+
`sdfEffects.setShapes: shape ${l} is a ${o.kind} and requires a positive radius (got ${String(o.radius)}).`
|
|
30
43
|
);
|
|
31
44
|
}
|
|
32
|
-
for (let
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
} else
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
for (let l = 0; l < m; l++) {
|
|
46
|
+
const o = s[l], c = l * K, x = o.center ?? wt, g = o.color ?? Mt, w = o.rotation ?? yt, v = o.kind === "box" ? 1 : o.kind === "cylinder" ? 2 : 0;
|
|
47
|
+
if (i[c + 0].set(x[0], x[1], x[2], v), o.kind === "box") {
|
|
48
|
+
const y = o.halfExtents;
|
|
49
|
+
i[c + 1].set(y[0], y[1], y[2], o.falloff ?? 0);
|
|
50
|
+
} else o.kind === "cylinder" ? i[c + 1].set(
|
|
51
|
+
o.radius,
|
|
52
|
+
o.height / 2,
|
|
40
53
|
0,
|
|
41
|
-
|
|
42
|
-
) :
|
|
43
|
-
|
|
54
|
+
o.falloff ?? 0
|
|
55
|
+
) : i[c + 1].set(o.radius, 0, 0, o.falloff ?? 0);
|
|
56
|
+
i[c + 2].set(g[0], g[1], g[2], pt[o.mode]), i[c + 3].set(w[0], w[1], w[2], w[3]), i[c + 4].set(o.invert ? 1 : 0, o.strength ?? 1, 0, 0);
|
|
44
57
|
}
|
|
45
|
-
|
|
58
|
+
u.value = m;
|
|
46
59
|
};
|
|
47
|
-
return
|
|
48
|
-
const m =
|
|
49
|
-
let
|
|
50
|
-
for (let
|
|
51
|
-
const
|
|
52
|
-
|
|
60
|
+
return n(t), { modifier: (s) => {
|
|
61
|
+
const m = s.localCenter;
|
|
62
|
+
let l = s.color.rgb, o = a(1);
|
|
63
|
+
for (let c = 0; c < r; c++) {
|
|
64
|
+
const x = c * K, g = (it) => f.element(x + it), w = g(0), v = g(1), y = g(2), L = g(3), N = g(4), j = w.xyz, F = w.w, k = v.xyz, U = v.w.max(1e-4), _ = y.xyz, T = y.w, X = N.x, I = N.y, B = ft(c).lessThan(u).select(a(1), a(0)), G = m.sub(j), z = Tt(L, G), D = z.length().sub(k.x), R = vt(z, k), V = Ct(z, k.x, k.y), P = F.greaterThan(0.5).and(F.lessThan(1.5)).select(a(1), a(0)), W = F.greaterThan(1.5).select(a(1), a(0)), $ = b(b(D, R, P), V, W), q = b($, $.negate(), X), E = a(1).sub(O(0, U, q)).mul(I).mul(B), H = a(1).sub(O(0, U, q.abs())).mul(I).mul(B), Q = T.lessThan(0.5).select(a(1), a(0)), ot = T.greaterThan(0.5).and(T.lessThan(1.5)).select(a(1), a(0)), st = T.greaterThan(1.5).and(T.lessThan(2.5)).select(a(1), a(0)), nt = T.greaterThan(2.5).select(a(1), a(0)), at = l.dot(M(0.2126, 0.7152, 0.0722));
|
|
65
|
+
l = b(l, _, E.mul(Q)), l = b(l, M(at), E.mul(ot)), l = b(l, _, H.mul(nt)), o = o.mul(a(1).sub(E.mul(st)));
|
|
53
66
|
}
|
|
54
|
-
return { color:
|
|
55
|
-
}, setShapes:
|
|
67
|
+
return { color: A(l, s.color.a.mul(o)) };
|
|
68
|
+
}, setShapes: n, maxShapes: r, _uniforms: { slots: i, count: u } };
|
|
56
69
|
}
|
|
57
|
-
function
|
|
58
|
-
const r =
|
|
59
|
-
return
|
|
70
|
+
function vt(t, e) {
|
|
71
|
+
const r = t.abs().sub(e), i = r.max(M(0, 0, 0)).length(), f = r.x.max(r.y.max(r.z)).min(0);
|
|
72
|
+
return i.add(f);
|
|
60
73
|
}
|
|
61
|
-
function
|
|
62
|
-
const
|
|
63
|
-
return
|
|
74
|
+
function Ct(t, e, r) {
|
|
75
|
+
const i = t.xz.length().sub(e), f = t.y.abs().sub(r), u = gt(i.max(0), f.max(0)).length(), d = i.max(f).min(0);
|
|
76
|
+
return u.add(d);
|
|
64
77
|
}
|
|
65
|
-
function
|
|
66
|
-
const r =
|
|
67
|
-
return
|
|
78
|
+
function Tt(t, e) {
|
|
79
|
+
const r = t.xyz, i = t.w, f = r.cross(e).mul(2);
|
|
80
|
+
return e.sub(f.mul(i)).add(r.cross(f));
|
|
68
81
|
}
|
|
69
|
-
function
|
|
70
|
-
const
|
|
71
|
-
return { modifier: (
|
|
72
|
-
const
|
|
73
|
-
return { color:
|
|
82
|
+
function Dt(t = {}) {
|
|
83
|
+
const e = new p.Vector3(...t.direction ?? [0.3, 1, 0.6]).normalize(), r = C(e), i = a(t.ambient ?? 0.35), f = a(t.diffuse ?? 0.75);
|
|
84
|
+
return { modifier: (d) => {
|
|
85
|
+
const n = d.normal.dot(r.normalize()).max(0), h = i.add(n.mul(f));
|
|
86
|
+
return { color: A(d.color.rgb.mul(h), d.color.a) };
|
|
74
87
|
}, direction: r };
|
|
75
88
|
}
|
|
76
|
-
function
|
|
77
|
-
const
|
|
78
|
-
return { modifier: (
|
|
79
|
-
const
|
|
80
|
-
return { scale:
|
|
81
|
-
}, focusDistance:
|
|
89
|
+
function Pt(t = {}) {
|
|
90
|
+
const e = C(Math.max(1e-4, t.focusDistance ?? 10)), r = C(Math.max(0, t.aperture ?? 0.5)), i = a(Math.max(0, t.maxBlur ?? 6));
|
|
91
|
+
return { modifier: (u) => {
|
|
92
|
+
const d = u.viewCenter.z.negate().max(1e-4), n = e.max(1e-4), h = d.sub(n).abs().div(n).mul(r).min(i), s = a(1).add(h), m = u.color.a.div(s.mul(s));
|
|
93
|
+
return { scale: u.scale.mul(s), color: A(u.color.rgb, m) };
|
|
94
|
+
}, focusDistance: e, aperture: r };
|
|
82
95
|
}
|
|
83
|
-
function
|
|
84
|
-
const
|
|
96
|
+
function Ot(t = {}) {
|
|
97
|
+
const e = C(0), r = t.frequency ?? 3, i = Math.min(Math.max(t.edge ?? 0.08, 0), 0.5), f = ut(
|
|
85
98
|
/* wgsl */
|
|
86
99
|
`
|
|
87
100
|
fn vnoise( x: vec3<f32> ) -> f32 {
|
|
@@ -108,73 +121,129 @@ function Me(o = {}) {
|
|
|
108
121
|
}
|
|
109
122
|
`
|
|
110
123
|
);
|
|
111
|
-
return { modifier: (u) => {
|
|
112
|
-
const l = d({ x: u.localCenter.mul(r) }), b = l.mul(1 - 2 * t).add(t), e = X(b.sub(t), b.add(t), n), m = n.greaterThan(b.sub(t));
|
|
113
|
-
return { color: O(u.color.rgb, u.color.a.mul(e)), visible: m };
|
|
114
|
-
}, progress: n };
|
|
115
|
-
}
|
|
116
|
-
function ke(o = {}) {
|
|
117
|
-
const n = C(Math.min(1, Math.max(-1, o.intensity ?? 0))), r = C(Math.max(1e-4, o.radius ?? 1));
|
|
118
124
|
return { modifier: (d) => {
|
|
119
|
-
const
|
|
125
|
+
const n = f({ x: d.localCenter.mul(r) }), h = n.mul(1 - 2 * i).add(i), s = O(h.sub(i), h.add(i), e), m = e.greaterThan(h.sub(i));
|
|
126
|
+
return { color: A(d.color.rgb, d.color.a.mul(s)), visible: m };
|
|
127
|
+
}, progress: e };
|
|
128
|
+
}
|
|
129
|
+
function Ut(t = {}) {
|
|
130
|
+
const e = C(Math.min(1, Math.max(-1, t.intensity ?? 0))), r = C(Math.max(1e-4, t.radius ?? 1));
|
|
131
|
+
return { modifier: (f) => {
|
|
132
|
+
const u = e.clamp(-1, 1), d = r.max(1e-4), n = f.viewCenter, h = u.max(0), s = u.negate().max(0), m = n.z.negate().max(0), l = m.div(d).atan().mul(a(Math.PI * 0.5)), o = l.cos(), c = l.sin(), x = c.negate(), g = M(n.x, n.y.mul(o).sub(n.z.mul(c)), n.y.mul(c).add(n.z.mul(o))), w = M(n.x, n.y.mul(o).sub(n.z.mul(x)), n.y.mul(x).add(n.z.mul(o))), v = b(b(n, g, s), w, h), y = a(Math.PI * 0.5).mul(d), L = n.z.lessThan(0).select(y.negate().div(m.mul(m).add(d.mul(d))), a(0)), N = L.negate(), j = M(1, 0, 0), F = M(0, o, c), k = M(0, c.negate().sub(g.z.mul(L)), o.add(g.y.mul(L))), U = M(1, 0, 0), _ = M(0, o, x), T = M(
|
|
120
133
|
0,
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
),
|
|
134
|
+
x.negate().sub(w.z.mul(N)),
|
|
135
|
+
o.add(w.y.mul(N))
|
|
136
|
+
), X = M(1, 0, 0), I = M(0, 1, 0), B = M(0, 0, 1), G = b(b(X, j, s), U, h), z = b(b(I, F, s), _, h), D = b(b(B, k, s), T, h), R = G.div(G.length().max(1e-6)), V = z.sub(R.mul(R.dot(z))), P = V.div(V.length().max(1e-6)), W = D.sub(R.mul(R.dot(D))).sub(P.mul(P.dot(D))), $ = W.div(W.length().max(1e-6)), q = mt(R, P, $), E = ht.toMat3(), H = E.transpose(), Q = H.mul(q).mul(E);
|
|
124
137
|
return {
|
|
125
|
-
offset:
|
|
126
|
-
rotation:
|
|
138
|
+
offset: f.offset.add(H.mul(v.sub(n))),
|
|
139
|
+
rotation: Q.mul(f.rotation)
|
|
127
140
|
};
|
|
128
|
-
}, intensity:
|
|
141
|
+
}, intensity: e, radius: r };
|
|
129
142
|
}
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
143
|
+
const Rt = 32, Y = (t) => {
|
|
144
|
+
const e = t.intensity;
|
|
145
|
+
return Number.isFinite(e) ? Math.max(0, e) : 1;
|
|
146
|
+
}, St = (t) => {
|
|
147
|
+
const e = t;
|
|
148
|
+
if (!(e.isSpotLight === !0 || e.isPointLight === !0)) return a(1);
|
|
149
|
+
const i = Number(e.distance);
|
|
150
|
+
if (!(i > 0)) return a(1);
|
|
151
|
+
const f = Math.max(Number(e.decay) || 1, 0.01), u = et.distance(C(e.position)), d = u.div(a(i)).pow4().oneMinus().clamp().pow2();
|
|
152
|
+
return d.pow(a(f));
|
|
153
|
+
}, kt = (t) => {
|
|
154
|
+
const e = Array.isArray(t) ? t : [{ light: t, intensity: 1 }], r = [];
|
|
155
|
+
for (const i of e) {
|
|
156
|
+
if (r.length >= Rt) break;
|
|
157
|
+
Y(i) <= 0 || r.push(i);
|
|
158
|
+
}
|
|
159
|
+
return r;
|
|
160
|
+
}, zt = (t, e, r) => {
|
|
161
|
+
const i = Number.isFinite(e.nearRadius) ? Math.max(1, e.nearRadius) : e.midLight ? 20 : 100, f = Number.isFinite(e.midRadius) ? Math.max(i, e.midRadius) : 50, u = Number.isFinite(e.outerRadius) ? Math.max(f, e.outerRadius) : 160, d = (h, s, m) => b(h, s, O(a(m * 0.7), a(m * 0.95), r));
|
|
162
|
+
let n = S(t);
|
|
163
|
+
return e.midLight ? (n = d(n, S(e.midLight), i), e.outerLight ? (n = d(n, S(e.outerLight), f), e.farLight && (n = d(n, S(e.farLight), u))) : e.farLight && (n = d(n, S(e.farLight), f))) : e.farLight && (n = d(n, S(e.farLight), i)), n;
|
|
164
|
+
};
|
|
165
|
+
function _t(t, e = {}) {
|
|
166
|
+
const r = Number.isFinite(e.umbra) ? Math.min(1, Math.max(0, e.umbra)) : 0.45, i = Number.isFinite(e.receiveUpMin) ? Math.min(0.95, Math.max(0, e.receiveUpMin)) : 0.25, f = Number.isFinite(e.diffuse) ? Math.max(0, e.diffuse) : 0, u = new p.MeshStandardNodeMaterial();
|
|
167
|
+
u.side = p.DoubleSide, u.color = new p.Color(1, 1, 1), u.roughness = 1, u.metalness = 0, u.transparent = !1, u.depthWrite = !0, u.polygonOffset = !0, u.polygonOffsetFactor = 2, u.polygonOffsetUnits = 2;
|
|
168
|
+
const d = et.distance(rt), n = kt(t), h = i > 0 ? O(a(i), a(i + 0.3), Z.y) : a(1), s = (o, c) => {
|
|
169
|
+
const x = o === 0 ? zt(c, e, d) : S(c);
|
|
170
|
+
return b(a(1), x, St(c));
|
|
171
|
+
};
|
|
172
|
+
let m, l = a(1);
|
|
173
|
+
if (e.combine === "min" && n.length > 0) {
|
|
174
|
+
let o = a(1);
|
|
175
|
+
for (let c = 0; c < n.length; c++) {
|
|
176
|
+
const x = n[c], g = Y(x), w = Math.min(1, Math.max(0, 1 - g * (1 - r))), v = s(c, x.light), y = b(a(w), a(1), v);
|
|
177
|
+
o = lt(o, y);
|
|
178
|
+
}
|
|
179
|
+
l = o, m = b(a(1), o, h);
|
|
180
|
+
} else {
|
|
181
|
+
if (n.length === 1)
|
|
182
|
+
l = s(0, n[0].light);
|
|
183
|
+
else if (n.length > 1) {
|
|
184
|
+
let c = a(0), x = 0;
|
|
185
|
+
for (let g = 0; g < n.length; g++) {
|
|
186
|
+
const w = n[g], v = Y(w);
|
|
187
|
+
x += v;
|
|
188
|
+
const y = s(g, w.light);
|
|
189
|
+
c = c.add(a(v).mul(y));
|
|
190
|
+
}
|
|
191
|
+
l = x > 0 ? c.div(a(x)) : a(1);
|
|
192
|
+
}
|
|
193
|
+
const o = b(a(1), l, h);
|
|
194
|
+
m = b(a(r), a(1), o);
|
|
195
|
+
}
|
|
196
|
+
if (f > 0) {
|
|
197
|
+
const o = C(e.color ?? new p.Color(1, 1, 1)), c = C(e.direction ?? new p.Vector3(0, 1, 0)), x = Z.dot(c.normalize()).max(0), g = o.mul(x).mul(a(f)).mul(h).mul(l);
|
|
198
|
+
u.outputNode = A(M(m).add(g), a(1));
|
|
199
|
+
} else
|
|
200
|
+
u.outputNode = A(M(m), a(1));
|
|
201
|
+
return u;
|
|
135
202
|
}
|
|
136
|
-
function
|
|
137
|
-
const
|
|
138
|
-
return
|
|
203
|
+
function Et(t) {
|
|
204
|
+
const e = new p.BufferGeometry();
|
|
205
|
+
return e.setAttribute("position", new p.BufferAttribute(t.positions.slice(), 3)), e.setIndex(new p.BufferAttribute(t.indices.slice(), 1)), e;
|
|
139
206
|
}
|
|
140
|
-
function
|
|
141
|
-
const
|
|
142
|
-
color: new
|
|
207
|
+
function It(t = {}) {
|
|
208
|
+
const e = t.albedo ?? 0.5, r = new p.Group(), i = t.matrixWorld ?? null, f = [], u = new p.MeshStandardMaterial({
|
|
209
|
+
color: new p.Color(e, e, e),
|
|
143
210
|
roughness: 1,
|
|
144
211
|
metalness: 0,
|
|
145
|
-
side:
|
|
146
|
-
}),
|
|
147
|
-
|
|
148
|
-
},
|
|
149
|
-
let
|
|
150
|
-
|
|
151
|
-
const
|
|
152
|
-
|
|
153
|
-
}, r.add(
|
|
212
|
+
side: p.DoubleSide
|
|
213
|
+
}), d = (s) => {
|
|
214
|
+
i && s.applyMatrix4(i);
|
|
215
|
+
}, n = (s, m) => {
|
|
216
|
+
let l = s, o = m;
|
|
217
|
+
i && !m && (l = s.clone(), o = !0), d(l), l.computeVertexNormals(), o && f.push(l);
|
|
218
|
+
const c = new p.Mesh(l, u);
|
|
219
|
+
c.castShadow = !0, c.receiveShadow = !0, c.raycast = () => {
|
|
220
|
+
}, r.add(c);
|
|
154
221
|
};
|
|
155
|
-
for (const
|
|
156
|
-
|
|
157
|
-
for (const
|
|
158
|
-
|
|
222
|
+
for (const s of t.tiles ?? [])
|
|
223
|
+
n(Et(s.data), !0);
|
|
224
|
+
for (const s of t.geometries ?? [])
|
|
225
|
+
n(s, !1);
|
|
159
226
|
return {
|
|
160
227
|
group: r,
|
|
161
|
-
configureMaterial: (
|
|
162
|
-
|
|
228
|
+
configureMaterial: (s) => {
|
|
229
|
+
s.side = p.DoubleSide, s.transparent = !1, s.opacity = 1, "color" in s && s.color instanceof p.Color && s.color.setRGB(e, e, e), "roughness" in s && typeof s.roughness == "number" && (s.roughness = 1), "metalness" in s && typeof s.metalness == "number" && (s.metalness = 0);
|
|
163
230
|
},
|
|
164
231
|
dispose: () => {
|
|
165
|
-
|
|
166
|
-
for (const
|
|
232
|
+
u.dispose();
|
|
233
|
+
for (const s of f) s.dispose();
|
|
167
234
|
r.clear();
|
|
168
235
|
}
|
|
169
236
|
};
|
|
170
237
|
}
|
|
171
238
|
export {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
239
|
+
Rt as MAX_RELIGHTING_SHADOW_LIGHTS,
|
|
240
|
+
It as createRelightingProxy,
|
|
241
|
+
_t as createRelightingShadowFactorMaterial,
|
|
242
|
+
Pt as depthOfFieldPreset,
|
|
243
|
+
Dt as lightingPreset,
|
|
244
|
+
Nt as renderRelightingFactorMap,
|
|
245
|
+
Ot as revealPreset,
|
|
246
|
+
Ft as sdfEffects,
|
|
247
|
+
Ut as worldWarpPreset
|
|
179
248
|
};
|
|
180
249
|
//# sourceMappingURL=effects.js.map
|