@voluma/vlam 0.2.3 → 0.3.0

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 (91) hide show
  1. package/README.md +3 -2
  2. package/dist/budget-governor.d.ts +4 -4
  3. package/dist/camera-budget-governor.d.ts +11 -11
  4. package/dist/chunk-cache-budget.d.ts +5 -5
  5. package/dist/chunk-fetch-scheduler.d.ts +4 -4
  6. package/dist/chunk-loader-DlNwggfG.js +1859 -0
  7. package/dist/chunk-loader-DlNwggfG.js.map +1 -0
  8. package/dist/chunk-loader.d.ts +2 -2
  9. package/dist/compute-sorter.d.ts +1 -1
  10. package/dist/effects.d.ts +26 -16
  11. package/dist/effects.js +199 -165
  12. package/dist/effects.js.map +1 -1
  13. package/dist/formats/ksplat/index.d.ts +1 -1
  14. package/dist/formats/lcc/collision-mesh.d.ts +2 -2
  15. package/dist/formats/lcc.js +17 -16
  16. package/dist/formats/lcc.js.map +1 -1
  17. package/dist/formats/ply/index.d.ts +1 -1
  18. package/dist/formats/ply/parse-splat-ply.d.ts +2 -2
  19. package/dist/formats/ply.js +1 -1
  20. package/dist/formats/ply.js.map +1 -1
  21. package/dist/formats/rad/index.d.ts +1 -1
  22. package/dist/formats/rad/parse-rad.d.ts +1 -1
  23. package/dist/formats/rad/rad.d.ts +2 -2
  24. package/dist/formats/rad.js +3 -3
  25. package/dist/formats/rad.js.map +1 -1
  26. package/dist/formats/sog/index.d.ts +1 -1
  27. package/dist/formats/sog/parse-sog.d.ts +4 -4
  28. package/dist/formats/sog.js.map +1 -1
  29. package/dist/formats/splat/index.d.ts +1 -1
  30. package/dist/formats/spz/index.d.ts +1 -1
  31. package/dist/index.d.ts +16 -25
  32. package/dist/index.js +253 -9047
  33. package/dist/index.js.map +1 -1
  34. package/dist/{load-scene.d.ts → load-splat-data.d.ts} +15 -13
  35. package/dist/loaders.d.ts +15 -0
  36. package/dist/loaders.js +26 -0
  37. package/dist/loaders.js.map +1 -0
  38. package/dist/loading-wLo8vRbA.js.map +1 -1
  39. package/dist/loading.d.ts +8 -8
  40. package/dist/{splat-mesh-types-CTN_duw2.js → lod-scheduler-B0a_uBlv.js} +133 -140
  41. package/dist/lod-scheduler-B0a_uBlv.js.map +1 -0
  42. package/dist/lod-scheduler.d.ts +1 -1
  43. package/dist/lod-source.d.ts +5 -5
  44. package/dist/{splat-scene.d.ts → merged-splat-mesh.d.ts} +14 -15
  45. package/dist/orientation.d.ts +7 -7
  46. package/dist/{ply-header-BwgExCn-.js → ply-header-B9WllbPg.js} +3 -3
  47. package/dist/{ply-header-BwgExCn-.js.map → ply-header-B9WllbPg.js.map} +1 -1
  48. package/dist/radix-sorter-R0FCSqKu.js +178 -0
  49. package/dist/radix-sorter-R0FCSqKu.js.map +1 -0
  50. package/dist/relighting-CSQF3UcL.js +969 -0
  51. package/dist/relighting-CSQF3UcL.js.map +1 -0
  52. package/dist/relighting.d.ts +1 -1
  53. package/dist/selection.d.ts +13 -0
  54. package/dist/selection.js +137 -0
  55. package/dist/selection.js.map +1 -0
  56. package/dist/source-transform.d.ts +4 -4
  57. package/dist/{splat-budget-DXew_86c.js → splat-budget-DuVZspPQ.js} +7 -7
  58. package/dist/{splat-budget-DXew_86c.js.map → splat-budget-DuVZspPQ.js.map} +1 -1
  59. package/dist/splat-budget.d.ts +1 -1
  60. package/dist/splat-data-BZM5dhhx.js.map +1 -1
  61. package/dist/splat-data.d.ts +4 -4
  62. package/dist/splat-mesh-aQdcWA6v.js +1942 -0
  63. package/dist/splat-mesh-aQdcWA6v.js.map +1 -0
  64. package/dist/splat-mesh-material.d.ts +2 -2
  65. package/dist/splat-mesh-types-BZIko-_9.js +18 -0
  66. package/dist/splat-mesh-types-BZIko-_9.js.map +1 -0
  67. package/dist/splat-mesh-types.d.ts +14 -8
  68. package/dist/splat-mesh.d.ts +4 -4
  69. package/dist/splat-modifier.d.ts +5 -5
  70. package/dist/splat-partition.d.ts +1 -1
  71. package/dist/static-lod-entry.d.ts +12 -0
  72. package/dist/static-lod-splat-mesh.d.ts +2 -2
  73. package/dist/{static-lod-worker-D2fyqQZO.js → static-lod-worker-DktKnJkR.js} +46 -46
  74. package/dist/{static-lod-worker-D2fyqQZO.js.map → static-lod-worker-DktKnJkR.js.map} +1 -1
  75. package/dist/static-lod.js +148 -0
  76. package/dist/static-lod.js.map +1 -0
  77. package/dist/streamed-splat-mesh.d.ts +21 -27
  78. package/dist/streaming.d.ts +23 -0
  79. package/dist/streaming.js +2877 -0
  80. package/dist/streaming.js.map +1 -0
  81. package/dist/{unified-splat-renderer.d.ts → unified-splat-mesh.d.ts} +10 -10
  82. package/dist/unified-work-buffer.d.ts +66 -0
  83. package/dist/unified.d.ts +11 -0
  84. package/dist/unified.js +738 -0
  85. package/dist/unified.js.map +1 -0
  86. package/dist/webgpu-limits-Y3CI_6_6.js +43 -0
  87. package/dist/webgpu-limits-Y3CI_6_6.js.map +1 -0
  88. package/dist/webgpu-limits.d.ts +0 -59
  89. package/dist/work-buffer-gather.d.ts +1 -1
  90. package/package.json +24 -4
  91. package/dist/splat-mesh-types-CTN_duw2.js.map +0 -1
package/dist/effects.js CHANGED
@@ -1,100 +1,100 @@
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({
1
+ import * as w from "three/webgpu";
2
+ import { context as mt, positionWorld as ot, cameraPosition as ft, smoothstep as F, float as a, normalWorld as Q, mix as p, min as ht, vec3 as v, uniform as R, vec4 as U, wgslFn as gt, uniformArray as xt, shadow as L, objectPosition as O, cos as nt, int as bt, mat3 as pt, modelViewMatrix as wt, reference as Mt, frameGroup as vt, vec2 as yt } from "three/tsl";
3
+ import { w as Ct } from "./logging-BfPdd7NJ.js";
4
+ const Z = new w.Vector2(), st = new w.Color(), Tt = mt({
5
5
  getOutput: (t) => t
6
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);
7
+ function Gt(t, e, c, o) {
8
+ t.getDrawingBufferSize(Z), o.setSize(Math.max(1, Z.x), Math.max(1, Z.y));
9
+ const m = t.getRenderTarget(), l = t.getActiveCubeFace(), d = t.getActiveMipmapLevel(), i = t.getMRT(), b = t.getClearAlpha(), n = t.autoClear, x = t.shadowMap.enabled, u = t.shadowMap.autoUpdate, s = t.contextNode;
10
+ t.getClearColor(st);
11
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);
12
+ t.contextNode = Tt, t.autoClear = !0, t.shadowMap.enabled = !0, u === !1 && (t.shadowMap.autoUpdate = !0), t.setMRT(null), t.setRenderTarget(o), t.setClearColor(16777215, 0), t.clear(), t.render(e, c);
13
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;
14
+ t.setRenderTarget(m, l, d), t.setMRT(i), t.setClearColor(st, b), t.autoClear = n, t.shadowMap.enabled = x, u !== void 0 && (t.shadowMap.autoUpdate = u), t.contextNode = s;
15
15
  }
16
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");
17
+ const tt = 5, Rt = { tint: 0, desaturate: 1, hide: 2, rim: 3 }, St = [0, 0, 0], kt = [1, 1, 1], Lt = [0, 0, 0, 1];
18
+ function Vt(t = [], e = {}) {
19
+ const c = Math.max(1, Math.floor(e.maxShapes ?? 32)), o = [];
20
+ for (let n = 0; n < c * tt; n++) o.push(new w.Vector4());
21
+ const m = xt(o, "vec4"), l = R(0, "int");
22
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.`
23
+ const i = (n) => {
24
+ const x = Math.min(n.length, c);
25
+ n.length > c && !d && (d = !0, Ct(
26
+ `sdfEffects: ${n.length} shapes exceeds maxShapes=${c}; extra shapes are ignored. Raise maxShapes if you need more.`
27
27
  ));
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))
28
+ for (let u = 0; u < x; u++) {
29
+ const s = n[u];
30
+ if (s.kind === "box") {
31
+ const f = s.halfExtents;
32
+ if (!f || !(f[0] > 0) || !(f[1] > 0) || !(f[2] > 0))
33
33
  throw new Error(
34
- `sdfEffects.setShapes: shape ${l} is a box and requires halfExtents with three positive components (got ${c ? `[${c.join(", ")}]` : "undefined"}).`
34
+ `sdfEffects.setShapes: shape ${u} is a box and requires halfExtents with three positive components (got ${f ? `[${f.join(", ")}]` : "undefined"}).`
35
35
  );
36
- } else if (typeof o.radius == "number" && o.radius > 0) {
37
- if (o.kind === "cylinder" && !(typeof o.height == "number" && o.height > 0))
36
+ } else if (typeof s.radius == "number" && s.radius > 0) {
37
+ if (s.kind === "cylinder" && !(typeof s.height == "number" && s.height > 0))
38
38
  throw new Error(
39
- `sdfEffects.setShapes: shape ${l} is a cylinder and requires a positive height (got ${String(o.height)}).`
39
+ `sdfEffects.setShapes: shape ${u} is a cylinder and requires a positive height (got ${String(s.height)}).`
40
40
  );
41
41
  } else throw new Error(
42
- `sdfEffects.setShapes: shape ${l} is a ${o.kind} and requires a positive radius (got ${String(o.radius)}).`
42
+ `sdfEffects.setShapes: shape ${u} is a ${s.kind} and requires a positive radius (got ${String(s.radius)}).`
43
43
  );
44
44
  }
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,
45
+ for (let u = 0; u < x; u++) {
46
+ const s = n[u], f = u * tt, h = s.center ?? St, r = s.color ?? kt, g = s.rotation ?? Lt, y = s.kind === "box" ? 1 : s.kind === "cylinder" ? 2 : 0;
47
+ if (o[f + 0].set(h[0], h[1], h[2], y), s.kind === "box") {
48
+ const M = s.halfExtents;
49
+ o[f + 1].set(M[0], M[1], M[2], s.falloff ?? 0);
50
+ } else s.kind === "cylinder" ? o[f + 1].set(
51
+ s.radius,
52
+ s.height / 2,
53
53
  0,
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);
54
+ s.falloff ?? 0
55
+ ) : o[f + 1].set(s.radius, 0, 0, s.falloff ?? 0);
56
+ o[f + 2].set(r[0], r[1], r[2], Rt[s.mode]), o[f + 3].set(g[0], g[1], g[2], g[3]), o[f + 4].set(s.invert ? 1 : 0, s.strength ?? 1, 0, 0);
57
57
  }
58
- u.value = m;
58
+ l.value = x;
59
59
  };
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)));
60
+ return i(t), { modifier: (n) => {
61
+ const x = n.localCenter;
62
+ let u = n.color.rgb, s = a(1);
63
+ for (let f = 0; f < c; f++) {
64
+ const h = f * tt, r = (dt) => m.element(h + dt), g = r(0), y = r(1), M = r(2), C = r(3), T = r(4), J = g.xyz, N = g.w, z = y.xyz, _ = y.w.max(1e-4), G = M.xyz, S = M.w, K = T.x, V = T.y, B = bt(f).lessThan(l).select(a(1), a(0)), W = x.sub(J), E = At(C, W), P = E.length().sub(z.x), k = zt(E, z), $ = Et(E, z.x, z.y), D = N.greaterThan(0.5).and(N.lessThan(1.5)).select(a(1), a(0)), j = N.greaterThan(1.5).select(a(1), a(0)), q = p(p(P, k, D), $, j), H = p(q, q.negate(), K), A = a(1).sub(F(0, _, H)).mul(V).mul(B), X = a(1).sub(F(0, _, H.abs())).mul(V).mul(B), Y = S.lessThan(0.5).select(a(1), a(0)), ct = S.greaterThan(0.5).and(S.lessThan(1.5)).select(a(1), a(0)), rt = S.greaterThan(1.5).and(S.lessThan(2.5)).select(a(1), a(0)), lt = S.greaterThan(2.5).select(a(1), a(0)), ut = u.dot(v(0.2126, 0.7152, 0.0722));
65
+ u = p(u, G, A.mul(Y)), u = p(u, v(ut), A.mul(ct)), u = p(u, G, X.mul(lt)), s = s.mul(a(1).sub(A.mul(rt)));
66
66
  }
67
- return { color: A(l, s.color.a.mul(o)) };
68
- }, setShapes: n, maxShapes: r, _uniforms: { slots: i, count: u } };
67
+ return { color: U(u, n.color.a.mul(s)) };
68
+ }, setShapes: i, maxShapes: c, _uniforms: { slots: o, count: l } };
69
69
  }
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);
70
+ function zt(t, e) {
71
+ const c = t.abs().sub(e), o = c.max(v(0, 0, 0)).length(), m = c.x.max(c.y.max(c.z)).min(0);
72
+ return o.add(m);
73
73
  }
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);
74
+ function Et(t, e, c) {
75
+ const o = t.xz.length().sub(e), m = t.y.abs().sub(c), l = yt(o.max(0), m.max(0)).length(), d = o.max(m).min(0);
76
+ return l.add(d);
77
77
  }
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));
78
+ function At(t, e) {
79
+ const c = t.xyz, o = t.w, m = c.cross(e).mul(2);
80
+ return e.sub(m.mul(o)).add(c.cross(m));
81
81
  }
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);
82
+ function Bt(t = {}) {
83
+ const e = new w.Vector3(...t.direction ?? [0.3, 1, 0.6]).normalize(), c = R(e), o = a(t.ambient ?? 0.35), m = a(t.diffuse ?? 0.75);
84
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) };
87
- }, direction: r };
85
+ const i = d.normal.dot(c.normalize()).max(0), b = o.add(i.mul(m));
86
+ return { color: U(d.color.rgb.mul(b), d.color.a) };
87
+ }, direction: c };
88
88
  }
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 };
89
+ function Wt(t = {}) {
90
+ const e = R(Math.max(1e-4, t.focusDistance ?? 10)), c = R(Math.max(0, t.aperture ?? 0.5)), o = a(Math.max(0, t.maxBlur ?? 6));
91
+ return { modifier: (l) => {
92
+ const d = l.viewCenter.z.negate().max(1e-4), i = e.max(1e-4), b = d.sub(i).abs().div(i).mul(c).min(o), n = a(1).add(b), x = l.color.a.div(n.mul(n));
93
+ return { scale: l.scale.mul(n), color: U(l.color.rgb, x) };
94
+ }, focusDistance: e, aperture: c };
95
95
  }
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(
96
+ function $t(t = {}) {
97
+ const e = R(0), c = t.frequency ?? 3, o = Math.min(Math.max(t.edge ?? 0.08, 0), 0.5), m = gt(
98
98
  /* wgsl */
99
99
  `
100
100
  fn vnoise( x: vec3<f32> ) -> f32 {
@@ -122,128 +122,162 @@ function Ot(t = {}) {
122
122
  `
123
123
  );
124
124
  return { modifier: (d) => {
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 };
125
+ const i = m({ x: d.localCenter.mul(c) }), b = i.mul(1 - 2 * o).add(o), n = F(b.sub(o), b.add(o), e), x = e.greaterThan(b.sub(o));
126
+ return { color: U(d.color.rgb, d.color.a.mul(n)), visible: x };
127
127
  }, progress: e };
128
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(
129
+ function jt(t = {}) {
130
+ const e = R(Math.min(1, Math.max(-1, t.intensity ?? 0))), c = R(Math.max(1e-4, t.radius ?? 1));
131
+ return { modifier: (m) => {
132
+ const l = e.clamp(-1, 1), d = c.max(1e-4), i = m.viewCenter, b = l.max(0), n = l.negate().max(0), x = i.z.negate().max(0), u = x.div(d).atan().mul(a(Math.PI * 0.5)), s = u.cos(), f = u.sin(), h = f.negate(), r = v(i.x, i.y.mul(s).sub(i.z.mul(f)), i.y.mul(f).add(i.z.mul(s))), g = v(i.x, i.y.mul(s).sub(i.z.mul(h)), i.y.mul(h).add(i.z.mul(s))), y = p(p(i, r, n), g, b), M = a(Math.PI * 0.5).mul(d), C = i.z.lessThan(0).select(M.negate().div(x.mul(x).add(d.mul(d))), a(0)), T = C.negate(), J = v(1, 0, 0), N = v(0, s, f), z = v(0, f.negate().sub(r.z.mul(C)), s.add(r.y.mul(C))), _ = v(1, 0, 0), G = v(0, s, h), S = v(
133
133
  0,
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);
134
+ h.negate().sub(g.z.mul(T)),
135
+ s.add(g.y.mul(T))
136
+ ), K = v(1, 0, 0), V = v(0, 1, 0), B = v(0, 0, 1), W = p(p(K, J, n), _, b), E = p(p(V, N, n), G, b), P = p(p(B, z, n), S, b), k = W.div(W.length().max(1e-6)), $ = E.sub(k.mul(k.dot(E))), D = $.div($.length().max(1e-6)), j = P.sub(k.mul(k.dot(P))).sub(D.mul(D.dot(P))), q = j.div(j.length().max(1e-6)), H = pt(k, D, q), A = wt.toMat3(), X = A.transpose(), Y = X.mul(H).mul(A);
137
137
  return {
138
- offset: f.offset.add(H.mul(v.sub(n))),
139
- rotation: Q.mul(f.rotation)
138
+ offset: m.offset.add(X.mul(y.sub(i))),
139
+ rotation: Y.mul(m.rotation)
140
140
  };
141
- }, intensity: e, radius: r };
141
+ }, intensity: e, radius: c };
142
142
  }
143
- const Rt = 32, Y = (t) => {
143
+ const Ft = 32, et = (t) => {
144
144
  const e = t.intensity;
145
145
  return Number.isFinite(e) ? Math.max(0, e) : 1;
146
- }, St = (t) => {
146
+ }, it = (t) => {
147
+ const e = t.fill;
148
+ return Number.isFinite(e) ? Math.max(0, e) : 0;
149
+ }, I = (t, e, c) => {
150
+ const o = Mt(t, e, c);
151
+ return o.setGroup(vt), o;
152
+ }, at = (t) => {
147
153
  const e = t;
148
154
  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);
155
+ if (!(Number(e.distance) > 0)) return a(1);
156
+ const m = Math.max(Number(e.decay) || 1, 0.01), l = ot.distance(O(e)), d = I("distance", "float", e).max(1e-4), i = l.div(d).pow4().oneMinus().clamp().pow2();
157
+ return i.pow(a(m));
158
+ }, Nt = (t, e, c) => {
159
+ const o = t, m = o.isSpotLight === !0, l = o.isPointLight === !0;
160
+ if (!m && !l) return v(0, 0, 0);
161
+ const d = O(o), i = d.sub(ot), b = i.length().max(1e-4), n = i.div(b), x = Q.dot(n).max(0), u = at(t);
162
+ let s = u.mul(x).mul(c);
163
+ if (m) {
164
+ const h = t, r = O(h.target).sub(d).normalize(), g = I("angle", "float", h).max(1e-3), y = I("penumbra", "float", h).clamp(0, 0.95), M = g.mul(a(1).sub(y)).max(1e-3), C = F(nt(g), nt(M), n.negate().dot(r));
165
+ s = s.mul(C);
158
166
  }
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;
167
+ const f = I("color", "color", t);
168
+ return f.mul(a(e)).mul(s);
169
+ }, Pt = (t, e, c) => {
170
+ const o = t;
171
+ if (o.isDirectionalLight !== !0) return v(0, 0, 0);
172
+ const m = O(o.target).sub(O(o)).normalize(), l = Q.dot(m.negate()).max(0), d = I("color", "color", t);
173
+ return d.mul(a(e)).mul(l).mul(c);
174
+ }, Dt = (t) => {
175
+ const e = Array.isArray(t) ? t : [{ light: t, intensity: 1 }], c = [];
176
+ for (const o of e) {
177
+ if (c.length >= Ft) break;
178
+ et(o) <= 0 && it(o) <= 0 || c.push(o);
179
+ }
180
+ return c;
181
+ }, It = (t, e, c) => {
182
+ const o = Number.isFinite(e.nearRadius) ? Math.max(1, e.nearRadius) : e.midLight ? 20 : 100, m = Number.isFinite(e.midRadius) ? Math.max(o, e.midRadius) : 50, l = Number.isFinite(e.outerRadius) ? Math.max(m, e.outerRadius) : 160, d = (b, n, x) => p(b, n, F(a(x * 0.7), a(x * 0.95), c));
183
+ let i = L(t);
184
+ return e.midLight ? (i = d(i, L(e.midLight), o), e.outerLight ? (i = d(i, L(e.outerLight), m), e.farLight && (i = d(i, L(e.farLight), l))) : e.farLight && (i = d(i, L(e.farLight), m))) : e.farLight && (i = d(i, L(e.farLight), o)), i;
164
185
  };
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);
186
+ function qt(t, e = {}) {
187
+ const c = Number.isFinite(e.umbra) ? Math.min(1, Math.max(0, e.umbra)) : 0.45, o = Number.isFinite(e.receiveUpMin) ? Math.min(0.95, Math.max(0, e.receiveUpMin)) : 0.25, m = Number.isFinite(e.diffuse) ? Math.max(0, e.diffuse) : 0, l = new w.MeshStandardNodeMaterial();
188
+ l.side = w.DoubleSide, l.color = new w.Color(1, 1, 1), l.roughness = 1, l.metalness = 0, l.transparent = !1, l.depthWrite = !0, l.polygonOffset = !0, l.polygonOffsetFactor = 2, l.polygonOffsetUnits = 2;
189
+ const d = ot.distance(ft), i = Dt(t), b = o > 0 ? F(a(o), a(o + 0.3), Q.y) : a(1), n = (h, r) => {
190
+ const g = h === 0 ? It(r, e, d) : L(r);
191
+ return p(a(1), g, at(r));
192
+ }, x = i.map(
193
+ (h, r) => n(r, h.light)
194
+ );
195
+ let u, s = a(1);
196
+ if (e.combine === "min" && i.length > 0) {
197
+ let h = a(1);
198
+ for (let r = 0; r < i.length; r++) {
199
+ const g = i[r], y = et(g);
200
+ if (y <= 0) continue;
201
+ const M = Math.min(1, Math.max(0, 1 - y * (1 - c))), C = x[r], T = p(a(M), a(1), C);
202
+ h = ht(h, T);
178
203
  }
179
- l = o, m = b(a(1), o, h);
204
+ s = h, u = p(a(1), h, b);
180
205
  } 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));
206
+ const h = i.map((r, g) => ({ index: g, intensity: et(r) })).filter(({ intensity: r }) => r > 0);
207
+ if (h.length === 1)
208
+ s = x[h[0].index];
209
+ else if (h.length > 1) {
210
+ let r = a(0), g = 0;
211
+ for (const { index: y, intensity: M } of h) {
212
+ g += M;
213
+ const C = x[y];
214
+ r = r.add(a(M).mul(C));
190
215
  }
191
- l = x > 0 ? c.div(a(x)) : a(1);
216
+ s = r.div(a(g));
192
217
  }
193
- const o = b(a(1), l, h);
194
- m = b(a(r), a(1), o);
218
+ if (h.length > 0) {
219
+ const r = p(a(1), s, b);
220
+ u = p(a(c), a(1), r);
221
+ } else
222
+ u = a(1);
223
+ }
224
+ let f = v(0, 0, 0);
225
+ if (m > 0) {
226
+ const h = R(e.color ?? new w.Color(1, 1, 1)), r = R(e.direction ?? new w.Vector3(0, 1, 0)), g = Q.dot(r.normalize()).max(0);
227
+ f = h.mul(g).mul(a(m)).mul(b).mul(s);
228
+ }
229
+ for (let h = 0; h < i.length; h++) {
230
+ const r = i[h], g = it(r);
231
+ if (g <= 0) continue;
232
+ const y = r.light, M = x[h], C = Nt(y, g, M), T = Pt(y, g, M);
233
+ f = f.add(C).add(T);
195
234
  }
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;
235
+ return l.outputNode = U(v(u).add(f), a(1)), l;
202
236
  }
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;
237
+ function Ot(t) {
238
+ const e = new w.BufferGeometry();
239
+ return e.setAttribute("position", new w.BufferAttribute(t.positions.slice(), 3)), e.setIndex(new w.BufferAttribute(t.indices.slice(), 1)), e;
206
240
  }
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),
241
+ function Ht(t = {}) {
242
+ const e = t.albedo ?? 0.5, c = new w.Group(), o = t.matrixWorld ?? null, m = [], l = new w.MeshStandardMaterial({
243
+ color: new w.Color(e, e, e),
210
244
  roughness: 1,
211
245
  metalness: 0,
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);
246
+ side: w.DoubleSide
247
+ }), d = (n) => {
248
+ o && n.applyMatrix4(o);
249
+ }, i = (n, x) => {
250
+ let u = n, s = x;
251
+ o && !x && (u = n.clone(), s = !0), d(u), u.computeVertexNormals(), s && m.push(u);
252
+ const f = new w.Mesh(u, l);
253
+ f.castShadow = !0, f.receiveShadow = !0, f.raycast = () => {
254
+ }, c.add(f);
221
255
  };
222
- for (const s of t.tiles ?? [])
223
- n(Et(s.data), !0);
224
- for (const s of t.geometries ?? [])
225
- n(s, !1);
256
+ for (const n of t.tiles ?? [])
257
+ i(Ot(n.data), !0);
258
+ for (const n of t.geometries ?? [])
259
+ i(n, !1);
226
260
  return {
227
- group: r,
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);
261
+ group: c,
262
+ configureMaterial: (n) => {
263
+ n.side = w.DoubleSide, n.transparent = !1, n.opacity = 1, "color" in n && n.color instanceof w.Color && n.color.setRGB(e, e, e), "roughness" in n && typeof n.roughness == "number" && (n.roughness = 1), "metalness" in n && typeof n.metalness == "number" && (n.metalness = 0);
230
264
  },
231
265
  dispose: () => {
232
- u.dispose();
233
- for (const s of f) s.dispose();
234
- r.clear();
266
+ l.dispose();
267
+ for (const n of m) n.dispose();
268
+ c.clear();
235
269
  }
236
270
  };
237
271
  }
238
272
  export {
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
273
+ Ft as MAX_RELIGHTING_SHADOW_LIGHTS,
274
+ Ht as createRelightingProxy,
275
+ qt as createRelightingShadowFactorMaterial,
276
+ Wt as depthOfFieldPreset,
277
+ Bt as lightingPreset,
278
+ Gt as renderRelightingFactorMap,
279
+ $t as revealPreset,
280
+ Vt as sdfEffects,
281
+ jt as worldWarpPreset
248
282
  };
249
283
  //# sourceMappingURL=effects.js.map