material-designer-runtime 0.1.3 → 0.1.5

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/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as e from "three";
2
- import { NearestFilter as t, NoColorSpace as n, OrthographicCamera as r, RepeatWrapping as i, Scene as a } from "three";
3
- import { MeshBasicNodeMaterial as o, MeshLambertNodeMaterial as s, MeshMatcapNodeMaterial as c, MeshPhongNodeMaterial as l, MeshPhysicalNodeMaterial as u, MeshStandardNodeMaterial as d, MeshToonNodeMaterial as f, QuadMesh as p, RenderTarget as m } from "three/webgpu";
4
- import { Fn as h, abs as g, acos as _, asin as v, atan as y, attribute as b, bool as x, bumpMap as S, ceil as C, clamp as w, color as T, cos as E, cosh as D, cross as ee, dFdx as te, dFdy as ne, degrees as re, dot as O, exp as ie, exp2 as ae, float as k, floatBitsToUint as oe, floor as A, fract as j, fwidth as se, int as M, inverseSqrt as ce, length as le, log as ue, luminance as de, max as N, min as P, mix as F, mod as I, mx_noise_float as fe, normalLocal as pe, normalMap as me, normalWorld as he, normalize as ge, parallaxDirection as _e, positionLocal as ve, positionWorld as ye, pow as L, radians as be, reflect as xe, round as Se, sRGBTransferOETF as Ce, saturate as we, select as R, sign as Te, sin as z, sinh as Ee, smoothstep as B, sqrt as De, step as Oe, tan as ke, tanh as Ae, texture as V, trunc as je, uint as H, uniform as U, uniformArray as Me, uv as W, vec2 as G, vec3 as K, vec4 as Ne } from "three/tsl";
5
- var Pe = {
2
+ import { LinearFilter as t, LinearMipmapLinearFilter as n, NearestFilter as r, NoColorSpace as i, OrthographicCamera as a, REVISION as o, RepeatWrapping as s, SRGBColorSpace as c, Scene as l } from "three";
3
+ import { MeshBasicNodeMaterial as u, MeshLambertNodeMaterial as d, MeshMatcapNodeMaterial as f, MeshPhongNodeMaterial as p, MeshPhysicalNodeMaterial as m, MeshStandardNodeMaterial as h, MeshToonNodeMaterial as g, QuadMesh as _, RenderTarget as v } from "three/webgpu";
4
+ import { Fn as y, abs as b, acos as x, asin as S, atan as C, attribute as w, bool as ee, bumpMap as te, ceil as ne, clamp as T, color as re, cos as E, cosh as ie, cross as D, dFdx as ae, dFdy as oe, degrees as se, dot as O, exp as ce, exp2 as le, float as k, floatBitsToUint as ue, floor as A, fract as j, fwidth as de, int as M, inverseSqrt as fe, length as pe, log as me, luminance as he, max as N, min as P, mix as F, mod as I, mx_noise_float as ge, normalLocal as _e, normalMap as ve, normalWorld as ye, normalize as be, parallaxDirection as xe, positionLocal as Se, positionWorld as Ce, pow as L, radians as we, reflect as Te, round as Ee, sRGBTransferOETF as De, saturate as Oe, select as R, sign as ke, sin as z, sinh as Ae, smoothstep as B, sqrt as je, step as Me, tan as Ne, tanh as Pe, texture as V, trunc as Fe, uint as H, uniform as Ie, uniformArray as Le, uv as U, vec2 as W, vec3 as G, vec4 as Re } from "three/tsl";
5
+ var ze = {
6
6
  version: 3,
7
7
  nodes: [{
8
8
  id: "pr",
@@ -29,20 +29,20 @@ var Pe = {
29
29
  toNode: "out",
30
30
  toInput: "surface"
31
31
  }]
32
- }, Fe = [
32
+ }, Be = [
33
33
  0,
34
34
  .25,
35
35
  .5,
36
36
  .75,
37
37
  1
38
- ], Ie = [
38
+ ], Ve = [
39
39
  "C",
40
40
  "R",
41
41
  "G",
42
42
  "B"
43
43
  ];
44
- function Le(e) {
45
- let t = (e) => Array.from({ length: 5 }, (t, n) => e?.[n] ?? Fe[n]);
44
+ function He(e) {
45
+ let t = (e) => Array.from({ length: 5 }, (t, n) => e?.[n] ?? Be[n]);
46
46
  return [
47
47
  ...t(e?.C),
48
48
  ...t(e?.R),
@@ -50,14 +50,14 @@ function Le(e) {
50
50
  ...t(e?.B)
51
51
  ];
52
52
  }
53
- var Re = [
53
+ var Ue = [
54
54
  "standard",
55
55
  "physical",
56
56
  "lambert",
57
57
  "toon",
58
58
  "phong",
59
59
  "matcap"
60
- ], ze = {
60
+ ], We = {
61
61
  standard: {
62
62
  roughMetal: !0,
63
63
  physicalLobes: !1,
@@ -95,17 +95,17 @@ var Re = [
95
95
  emissive: !1
96
96
  }
97
97
  };
98
- function Be(e) {
99
- return Re.includes(e) ? e : "physical";
98
+ function Ge(e) {
99
+ return Ue.includes(e) ? e : "physical";
100
100
  }
101
- var Ve = "group", He = "group-input", Ue = "group-output", q = "material-output", We = "shader-material", Ge = [
101
+ var Ke = "group", qe = "group-input", Je = "group-output", Ye = "material-output", Xe = "shader-material", Ze = [
102
102
  "baseColor",
103
103
  "normal",
104
104
  "emission",
105
105
  "roughness",
106
106
  "metallic",
107
107
  "ambientOcclusion"
108
- ], Ke = {
108
+ ], Qe = {
109
109
  float: {
110
110
  float: "identity",
111
111
  vector: "float-to-vector",
@@ -123,28 +123,28 @@ var Ve = "group", He = "group-input", Ue = "group-output", q = "material-output"
123
123
  },
124
124
  shader: { shader: "identity" }
125
125
  };
126
- function qe(e, t) {
127
- return Ke[e]?.[t];
126
+ function $e(e, t) {
127
+ return Qe[e]?.[t];
128
128
  }
129
129
  //#endregion
130
130
  //#region src/tsl/blender-noise.ts
131
- var Je = (e, t) => e.shiftLeft(t).bitOr(e.shiftRight(32 - t));
132
- function Ye(e, t, n) {
131
+ var et = (e, t) => e.shiftLeft(t).bitOr(e.shiftRight(32 - t));
132
+ function tt(e, t, n) {
133
133
  let r = 3735928584, i = H(r).toVar(), a = H(r).toVar(), o = H(r).toVar();
134
- return o.assign(o.add(n)), a.assign(a.add(t)), i.assign(i.add(e)), o.assign(o.bitXor(a)), o.assign(o.sub(Je(a, 14))), i.assign(i.bitXor(o)), i.assign(i.sub(Je(o, 11))), a.assign(a.bitXor(i)), a.assign(a.sub(Je(i, 25))), o.assign(o.bitXor(a)), o.assign(o.sub(Je(a, 16))), i.assign(i.bitXor(o)), i.assign(i.sub(Je(o, 4))), a.assign(a.bitXor(i)), a.assign(a.sub(Je(i, 14))), o.assign(o.bitXor(a)), o.assign(o.sub(Je(a, 24))), o;
134
+ return o.assign(o.add(n)), a.assign(a.add(t)), i.assign(i.add(e)), o.assign(o.bitXor(a)), o.assign(o.sub(et(a, 14))), i.assign(i.bitXor(o)), i.assign(i.sub(et(o, 11))), a.assign(a.bitXor(i)), a.assign(a.sub(et(i, 25))), o.assign(o.bitXor(a)), o.assign(o.sub(et(a, 16))), i.assign(i.bitXor(o)), i.assign(i.sub(et(o, 4))), a.assign(a.bitXor(i)), a.assign(a.sub(et(i, 14))), o.assign(o.bitXor(a)), o.assign(o.sub(et(a, 24))), o;
135
135
  }
136
- var Xe = (e, t, n) => Ye(H(e), H(t), H(n)), Ze = (e) => e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10)), Qe = (e, t) => R(t.notEqual(H(0)), e.negate(), e);
137
- function $e(e, t, n, r) {
136
+ var nt = (e, t, n) => tt(H(e), H(t), H(n)), rt = (e) => e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10)), it = (e, t) => R(t.notEqual(H(0)), e.negate(), e);
137
+ function at(e, t, n, r) {
138
138
  let i = e.bitAnd(H(15)).toVar(), a = R(i.lessThan(H(8)), t, n), o = R(i.equal(H(12)).or(i.equal(H(14))), t, r), s = R(i.lessThan(H(4)), n, o);
139
- return Qe(a, i.bitAnd(H(1))).add(Qe(s, i.bitAnd(H(2))));
139
+ return it(a, i.bitAnd(H(1))).add(it(s, i.bitAnd(H(2))));
140
140
  }
141
- function et(e, t, n, r) {
141
+ function ot(e, t, n, r) {
142
142
  let i = k(1).sub(t), a = k(1).sub(n);
143
143
  return k(1).sub(r).mul(a.mul(e[0].mul(i).add(e[1].mul(t))).add(n.mul(e[2].mul(i).add(e[3].mul(t))))).add(r.mul(a.mul(e[4].mul(i).add(e[5].mul(t))).add(n.mul(e[6].mul(i).add(e[7].mul(t))))));
144
144
  }
145
- function tt(e) {
146
- let t = A(e.x).toVar(), n = A(e.y).toVar(), r = A(e.z).toVar(), i = e.x.sub(t).toVar(), a = e.y.sub(n).toVar(), o = e.z.sub(r).toVar(), s = M(t), c = M(n), l = M(r), u = Ze(i), d = Ze(a), f = Ze(o), p = (e, t, n) => $e(Xe(s.add(e), c.add(t), l.add(n)), i.sub(e), a.sub(t), o.sub(n));
147
- return et([
145
+ function st(e) {
146
+ let t = A(e.x).toVar(), n = A(e.y).toVar(), r = A(e.z).toVar(), i = e.x.sub(t).toVar(), a = e.y.sub(n).toVar(), o = e.z.sub(r).toVar(), s = M(t), c = M(n), l = M(r), u = rt(i), d = rt(a), f = rt(o), p = (e, t, n) => at(nt(s.add(e), c.add(t), l.add(n)), i.sub(e), a.sub(t), o.sub(n));
147
+ return ot([
148
148
  p(0, 0, 0),
149
149
  p(1, 0, 0),
150
150
  p(0, 1, 0),
@@ -155,18 +155,18 @@ function tt(e) {
155
155
  p(1, 1, 1)
156
156
  ], u, d, f);
157
157
  }
158
- var nt = (e) => tt(e).mul(.982);
159
- function rt(e, t, n, r) {
158
+ var ct = (e) => st(e).mul(.982);
159
+ function lt(e, t, n, r) {
160
160
  let i = Math.max(0, Math.min(15, Math.floor(t)));
161
- return h(() => {
161
+ return y(() => {
162
162
  let t = k(1).toVar(), a = k(1).toVar(), o = k(0).toVar(), s = k(0).toVar();
163
- for (let c = 0; c <= i; c++) o.assign(o.add(nt(e.mul(a)).mul(t))), s.assign(s.add(t)), t.assign(t.mul(n)), a.assign(a.mul(r));
163
+ for (let c = 0; c <= i; c++) o.assign(o.add(ct(e.mul(a)).mul(t))), s.assign(s.add(t)), t.assign(t.mul(n)), a.assign(a.mul(r));
164
164
  return o.div(s).mul(.5).add(.5);
165
165
  })();
166
166
  }
167
167
  //#endregion
168
168
  //#region src/graph/nodes/texture/fbm.ts
169
- var it = {
169
+ var ut = {
170
170
  type: "fbm",
171
171
  nodeClass: "texture",
172
172
  label: "Noise (FBM)",
@@ -217,9 +217,9 @@ var it = {
217
217
  }
218
218
  ],
219
219
  build(e) {
220
- return { field: rt((e.inputs.coord ?? e.coord).mul(e.live("scale")), e.constant("octaves") ?? 4, e.live("gain"), e.live("lacunarity")) };
220
+ return { field: lt((e.inputs.coord ?? e.coord).mul(e.live("scale")), e.constant("octaves") ?? 4, e.live("gain"), e.live("lacunarity")) };
221
221
  }
222
- }, at = {
222
+ }, dt = {
223
223
  type: "domain-warp",
224
224
  nodeClass: "vector",
225
225
  label: "Domain Warp",
@@ -249,35 +249,35 @@ var it = {
249
249
  default: 1
250
250
  }],
251
251
  build(e) {
252
- let t = e.inputs.coord ?? e.coord, n = t.div(e.live("scale")), r = fe(n.add(K(11.3, 0, 0))), i = fe(n.add(K(0, 47.7, 0))), a = fe(n.add(K(0, 0, 93.1)));
253
- return { coord: t.add(K(r, i, a).mul(e.live("amount"))) };
252
+ let t = e.inputs.coord ?? e.coord, n = t.div(e.live("scale")), r = ge(n.add(G(11.3, 0, 0))), i = ge(n.add(G(0, 47.7, 0))), a = ge(n.add(G(0, 0, 93.1)));
253
+ return { coord: t.add(G(r, i, a).mul(e.live("amount"))) };
254
254
  }
255
- }, ot = (e) => I(e.mul(34).add(1).mul(e), 289), st = (e) => e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10)), ct = h(([e, t]) => {
256
- let n = A(e.xyxy).add(Ne(0, 0, 1, 1)), r = j(e.xyxy).sub(Ne(0, 0, 1, 1)), i = I(I(n, t.xyxy), 289), a = i.xzxz, o = i.yyww, s = r.xzxz, c = r.yyww, l = j(ot(ot(a).add(o)).mul(.0243902439)).mul(2).sub(1), u = g(l).sub(.5), d = l.sub(A(l.add(.5))), f = G(d.x, u.x), p = G(d.y, u.y), m = G(d.z, u.z), h = G(d.w, u.w), _ = k(1.79284291400159).sub(k(.85373472095314).mul(Ne(O(f, f), O(m, m), O(p, p), O(h, h))));
257
- f = f.mul(_.x), m = m.mul(_.y), p = p.mul(_.z), h = h.mul(_.w);
258
- let v = O(f, G(s.x, c.x)), y = O(p, G(s.y, c.y)), b = O(m, G(s.z, c.z)), x = O(h, G(s.w, c.w)), S = st(r.xy), C = F(G(v, b), G(y, x), S.x);
255
+ }, ft = (e) => I(e.mul(34).add(1).mul(e), 289), pt = (e) => e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10)), mt = y(([e, t]) => {
256
+ let n = A(e.xyxy).add(Re(0, 0, 1, 1)), r = j(e.xyxy).sub(Re(0, 0, 1, 1)), i = I(I(n, t.xyxy), 289), a = i.xzxz, o = i.yyww, s = r.xzxz, c = r.yyww, l = j(ft(ft(a).add(o)).mul(.0243902439)).mul(2).sub(1), u = b(l).sub(.5), d = l.sub(A(l.add(.5))), f = W(d.x, u.x), p = W(d.y, u.y), m = W(d.z, u.z), h = W(d.w, u.w), g = k(1.79284291400159).sub(k(.85373472095314).mul(Re(O(f, f), O(m, m), O(p, p), O(h, h))));
257
+ f = f.mul(g.x), m = m.mul(g.y), p = p.mul(g.z), h = h.mul(g.w);
258
+ let _ = O(f, W(s.x, c.x)), v = O(p, W(s.y, c.y)), y = O(m, W(s.z, c.z)), x = O(h, W(s.w, c.w)), S = pt(r.xy), C = F(W(_, y), W(v, x), S.x);
259
259
  return F(C.x, C.y, S.y).mul(2.3);
260
260
  });
261
- function lt(e, t, n, r, i, a, o = 2) {
262
- let s = typeof t == "number" ? k(Math.max(1, Math.round(t))) : t, c = typeof n == "number" ? k(Math.max(1, Math.round(n))) : n, l = se(e), u = k(0), d = k(0), f = k(1), p = Math.max(2, Math.round(o));
261
+ function ht(e, t, n, r, i, a, o = 2) {
262
+ let s = typeof t == "number" ? k(Math.max(1, Math.round(t))) : t, c = typeof n == "number" ? k(Math.max(1, Math.round(n))) : n, l = de(e), u = k(0), d = k(0), f = k(1), p = Math.max(2, Math.round(o));
263
263
  for (let t = 0; t < Math.max(1, r); t++) {
264
- let n = Math.round(p ** +t), r = G(s.mul(n), c.mul(n)), o = f;
264
+ let n = Math.round(p ** +t), r = W(s.mul(n), c.mul(n)), o = f;
265
265
  if (a !== void 0) {
266
- let e = N(r.x.mul(l.x), r.y.mul(l.y)), t = w(k(1).sub(B(.2, .5, e)), 0, 1);
266
+ let e = N(r.x.mul(l.x), r.y.mul(l.y)), t = T(k(1).sub(B(.2, .5, e)), 0, 1);
267
267
  o = f.mul(F(k(1), t, a));
268
268
  }
269
- u = u.add(o.mul(ct(e.mul(r), r))), d = d.add(o), f = f.mul(i);
269
+ u = u.add(o.mul(mt(e.mul(r), r))), d = d.add(o), f = f.mul(i);
270
270
  }
271
271
  return F(k(0), u.div(d.max(1e-4)), P(d, 1));
272
272
  }
273
273
  //#endregion
274
274
  //#region src/tsl/noise/fbm.ts
275
- function ut(e, t, n, r, i, a, o, s = 2) {
276
- let c = typeof t == "number" ? k(Math.max(1, Math.round(t))) : t, l = typeof n == "number" ? k(Math.max(1, Math.round(n))) : n, u = se(e), d = k(0), f = k(0), p = k(1), m = Math.max(2, Math.round(s));
275
+ function gt(e, t, n, r, i, a, o, s = 2) {
276
+ let c = typeof t == "number" ? k(Math.max(1, Math.round(t))) : t, l = typeof n == "number" ? k(Math.max(1, Math.round(n))) : n, u = de(e), d = k(0), f = k(0), p = k(1), m = Math.max(2, Math.round(s));
277
277
  for (let t = 0; t < Math.max(1, r); t++) {
278
- let n = Math.round(m ** +t), r = c.mul(n), s = l.mul(n), h = e.mul(G(r, s)), g = p;
278
+ let n = Math.round(m ** +t), r = c.mul(n), s = l.mul(n), h = e.mul(W(r, s)), g = p;
279
279
  if (o !== void 0) {
280
- let e = N(r.mul(u.x), s.mul(u.y)), t = w(k(1).sub(B(.2, .5, e)), 0, 1);
280
+ let e = N(r.mul(u.x), s.mul(u.y)), t = T(k(1).sub(B(.2, .5, e)), 0, 1);
281
281
  g = p.mul(F(k(1), t, o));
282
282
  }
283
283
  d = d.add(g.mul(a(h, r, s))), f = f.add(g), p = p.mul(i);
@@ -286,78 +286,78 @@ function ut(e, t, n, r, i, a, o, s = 2) {
286
286
  }
287
287
  //#endregion
288
288
  //#region src/tsl/noise/hash.ts
289
- var dt = 1 / 2147483648, ft = h(([e, t, n]) => {
289
+ var _t = 1 / 2147483648, vt = y(([e, t, n]) => {
290
290
  let r = e.mul(1664525).add(1013904223).toVar(), i = t.mul(1664525).add(1013904223).toVar(), a = n.mul(1664525).add(1013904223).toVar();
291
291
  r.assign(r.add(i.mul(a))), i.assign(i.add(a.mul(r))), a.assign(a.add(r.mul(i))), r.assign(r.bitXor(r.shiftRight(16))), i.assign(i.bitXor(i.shiftRight(16))), a.assign(a.bitXor(a.shiftRight(16))), r.assign(r.add(i.mul(a))), i.assign(i.add(a.mul(r))), a.assign(a.add(r.mul(i)));
292
292
  let o = M(2147483647);
293
- return K(k(r.bitAnd(o)).mul(dt), k(i.bitAnd(o)).mul(dt), k(a.bitAnd(o)).mul(dt));
293
+ return G(k(r.bitAnd(o)).mul(_t), k(i.bitAnd(o)).mul(_t), k(a.bitAnd(o)).mul(_t));
294
294
  });
295
- function pt(e, t) {
295
+ function yt(e, t) {
296
296
  return typeof t == "number" && t <= 0 ? e : e.sub(M(A(k(e).div(t))).mul(M(t)));
297
297
  }
298
- function mt(e, t, n, r) {
299
- return ft(pt(e, n), pt(t, r), M(0)).x;
298
+ function bt(e, t, n, r) {
299
+ return vt(yt(e, n), yt(t, r), M(0)).x;
300
300
  }
301
- function ht(e, t, n, r) {
302
- return ft(pt(e, n), pt(t, r), M(0));
301
+ function xt(e, t, n, r) {
302
+ return vt(yt(e, n), yt(t, r), M(0));
303
303
  }
304
- function J(e, t, n, r, i) {
305
- return ft(pt(e, r), pt(t, i), M(n));
304
+ function K(e, t, n, r, i) {
305
+ return vt(yt(e, r), yt(t, i), M(n));
306
306
  }
307
307
  //#endregion
308
308
  //#region src/tsl/noise/value.ts
309
- function gt(e, t, n) {
310
- let r = A(e), i = e.sub(r), a = i.mul(i).mul(k(3).sub(i.mul(2))), o = M(r.x), s = M(r.y), c = mt(o, s, t, n), l = mt(o.add(1), s, t, n), u = mt(o, s.add(1), t, n), d = mt(o.add(1), s.add(1), t, n);
309
+ function St(e, t, n) {
310
+ let r = A(e), i = e.sub(r), a = i.mul(i).mul(k(3).sub(i.mul(2))), o = M(r.x), s = M(r.y), c = bt(o, s, t, n), l = bt(o.add(1), s, t, n), u = bt(o, s.add(1), t, n), d = bt(o.add(1), s.add(1), t, n);
311
311
  return F(F(c, l, a.x), F(u, d, a.x), a.y);
312
312
  }
313
313
  //#endregion
314
314
  //#region src/tsl/noise/cellular.ts
315
- var _t = 2;
316
- function vt(e, t, n) {
317
- let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = K(i.x, i.y, k(0)), c = k(1e10);
315
+ var Ct = 2;
316
+ function wt(e, t, n) {
317
+ let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = G(i.x, i.y, k(0)), c = k(1e10);
318
318
  for (let e = -1; e <= 1; e++) for (let r = -1; r <= 1; r++) {
319
- let i = ht(a.add(e), o.add(r), t, n), l = K(k(e).add(i.x), k(r).add(i.y), i.z);
320
- c = P(c, le(l.sub(s)));
319
+ let i = xt(a.add(e), o.add(r), t, n), l = G(k(e).add(i.x), k(r).add(i.y), i.z);
320
+ c = P(c, pe(l.sub(s)));
321
321
  }
322
- return w(k(1).sub(c), 0, 1);
322
+ return T(k(1).sub(c), 0, 1);
323
323
  }
324
- function yt(e, t, n) {
324
+ function Tt(e, t, n) {
325
325
  let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = k(0), c = k(0);
326
326
  for (let e = -1; e <= 1; e++) for (let r = -1; r <= 1; r++) {
327
- let l = ht(a.add(e), o.add(r), t, n), u = L(B(1.414, 0, le(G(e, r).sub(i).add(G(l.x, l.y)))), _t);
327
+ let l = xt(a.add(e), o.add(r), t, n), u = L(B(1.414, 0, pe(W(e, r).sub(i).add(W(l.x, l.y)))), Ct);
328
328
  s = s.add(l.z.mul(u)), c = c.add(u);
329
329
  }
330
330
  return s.div(c.max(1e-4));
331
331
  }
332
332
  //#endregion
333
333
  //#region src/tsl/noise/flow.ts
334
- var bt = (e, t) => ct(e, G(t, t)), xt = h(([e, t]) => {
335
- let n = k(.1), r = bt(e.add(G(n, 0)), t), i = bt(e.add(G(0, n)), t), a = bt(e.sub(G(n, 0)), t), o = bt(e.sub(G(0, n)), t);
336
- return G(r.sub(a), i.sub(o)).div(n).mul(.5);
334
+ var Et = (e, t) => mt(e, W(t, t)), Dt = y(([e, t]) => {
335
+ let n = k(.1), r = Et(e.add(W(n, 0)), t), i = Et(e.add(W(0, n)), t), a = Et(e.sub(W(n, 0)), t), o = Et(e.sub(W(0, n)), t);
336
+ return W(r.sub(a), i.sub(o)).div(n).mul(.5);
337
337
  });
338
- function St(e, t, n) {
339
- let r = xt(e, t);
340
- return K(r.x, r.y, k(0));
338
+ function Ot(e, t, n) {
339
+ let r = Dt(e, t);
340
+ return G(r.x, r.y, k(0));
341
341
  }
342
- function Ct(e, t, n) {
343
- return w(xt(e, t).length().mul(.6).add(.2), 0, 1);
342
+ function kt(e, t, n) {
343
+ return T(Dt(e, t).length().mul(.6).add(.2), 0, 1);
344
344
  }
345
- function wt(e, t, n) {
346
- let r = xt(e, t);
347
- return w(N(g(r.x), g(r.y)), 0, 1);
345
+ function At(e, t, n) {
346
+ let r = Dt(e, t);
347
+ return T(N(b(r.x), b(r.y)), 0, 1);
348
348
  }
349
- function Tt(e, t, n) {
350
- let r = xt(e, t).mul(.4);
351
- return bt(e.add(r), t).mul(.5).add(.5);
349
+ function jt(e, t, n) {
350
+ let r = Dt(e, t).mul(.4);
351
+ return Et(e.add(r), t).mul(.5).add(.5);
352
352
  }
353
353
  //#endregion
354
354
  //#region src/tsl/noise/gabor.ts
355
- var Et = 6.283185307179586, Dt = Math.PI, Ot = 8, kt = h(([e, t, n, r, i]) => {
355
+ var Mt = 6.283185307179586, Nt = Math.PI, Pt = 8, Ft = y(([e, t, n, r, i]) => {
356
356
  let a = e.mul(t), o = A(a), s = a.sub(o), c = k(0).toVar();
357
357
  for (let e = -1; e <= 1; e++) for (let a = -1; a <= 1; a++) {
358
- let l = M(o.x).add(a), u = M(o.y).add(e), d = s.sub(G(a, e));
359
- for (let e = 0; e < Ot; e++) {
360
- let a = J(l, u, e * 2, t, t), o = J(l, u, e * 2 + 1, t, t), s = i.add(o.x.sub(.5).mul(Dt).mul(r)), f = d.sub(G(a.x, a.y)), p = O(f, f), m = ie(p.mul(-Dt)).mul(k(.5).add(E(p.mul(Dt)).mul(.5))), h = O(f, G(E(s), z(s)).mul(n)).mul(Et), g = F(k(-1), k(1), Oe(.5, a.z)), _ = k(1).sub(Oe(1, p));
358
+ let l = M(o.x).add(a), u = M(o.y).add(e), d = s.sub(W(a, e));
359
+ for (let e = 0; e < Pt; e++) {
360
+ let a = K(l, u, e * 2, t, t), o = K(l, u, e * 2 + 1, t, t), s = i.add(o.x.sub(.5).mul(Nt).mul(r)), f = d.sub(W(a.x, a.y)), p = O(f, f), m = ce(p.mul(-Nt)).mul(k(.5).add(E(p.mul(Nt)).mul(.5))), h = O(f, W(E(s), z(s)).mul(n)).mul(Mt), g = F(k(-1), k(1), Me(.5, a.z)), _ = k(1).sub(Me(1, p));
361
361
  c.addAssign(z(h).mul(m).mul(g).mul(_));
362
362
  }
363
363
  }
@@ -365,28 +365,28 @@ var Et = 6.283185307179586, Dt = Math.PI, Ot = 8, kt = h(([e, t, n, r, i]) => {
365
365
  });
366
366
  //#endregion
367
367
  //#region src/tsl/noise/simplex.ts
368
- function At(e, t, n) {
369
- let r = G(e.x.add(e.y.mul(.5)), e.y), i = A(r), a = r.sub(i), o = Oe(a.y, a.x), s = G(o, k(1).sub(o)), c = G(i.x.sub(i.y.mul(.5)), i.y), l = G(c.x.add(s.x).sub(s.y.mul(.5)), c.y.add(s.y)), u = G(c.x.add(.5), c.y.add(1)), d = e.sub(c), f = e.sub(l), p = e.sub(u), m = I(K(c.x, l.x, u.x), k(t)), h = I(K(c.y, l.y, u.y), k(n)), g = A(m.add(h.mul(.5)).add(.5)), _ = A(h.add(.5)), v = I(g, 289);
368
+ function It(e, t, n) {
369
+ let r = W(e.x.add(e.y.mul(.5)), e.y), i = A(r), a = r.sub(i), o = Me(a.y, a.x), s = W(o, k(1).sub(o)), c = W(i.x.sub(i.y.mul(.5)), i.y), l = W(c.x.add(s.x).sub(s.y.mul(.5)), c.y.add(s.y)), u = W(c.x.add(.5), c.y.add(1)), d = e.sub(c), f = e.sub(l), p = e.sub(u), m = I(G(c.x, l.x, u.x), k(t)), h = I(G(c.y, l.y, u.y), k(n)), g = A(m.add(h.mul(.5)).add(.5)), _ = A(h.add(.5)), v = I(g, 289);
370
370
  v = I(v.mul(51).add(2).mul(v).add(_), 289), v = I(v.mul(34).add(10).mul(v), 289);
371
- let y = v.mul(.07482), b = E(y), x = z(y), S = G(b.x, x.x), C = G(b.y, x.y), T = G(b.z, x.z), D = N(k(.8).sub(K(O(d, d), O(f, f), O(p, p))), 0), ee = D.mul(D);
372
- return w(O(ee.mul(ee), K(O(S, d), O(C, f), O(T, p))).mul(10.9).mul(.5).add(.5), 0, 1);
371
+ let y = v.mul(.07482), b = E(y), x = z(y), S = W(b.x, x.x), C = W(b.y, x.y), w = W(b.z, x.z), ee = N(k(.8).sub(G(O(d, d), O(f, f), O(p, p))), 0), te = ee.mul(ee);
372
+ return T(O(te.mul(te), G(O(S, d), O(C, f), O(w, p))).mul(10.9).mul(.5).add(.5), 0, 1);
373
373
  }
374
374
  //#endregion
375
375
  //#region src/tsl/noise/wavelet.ts
376
- var jt = 6.283185307179586;
377
- function Mt(e, t, n) {
378
- let r = A(e), i = j(e).sub(.5), a = mt(M(r.x), M(r.y), t, n).mul(jt), o = E(a), s = z(a), c = o.mul(i.x).sub(s.mul(i.y)), l = s.mul(i.x).add(o.mul(i.y)), u = B(.25, 0, O(G(c, l), G(c, l)));
379
- return w(z(c.mul(10)).mul(u).mul(.5).add(.5), 0, 1);
376
+ var Lt = 6.283185307179586;
377
+ function Rt(e, t, n) {
378
+ let r = A(e), i = j(e).sub(.5), a = bt(M(r.x), M(r.y), t, n).mul(Lt), o = E(a), s = z(a), c = o.mul(i.x).sub(s.mul(i.y)), l = s.mul(i.x).add(o.mul(i.y)), u = B(.25, 0, O(W(c, l), W(c, l)));
379
+ return T(z(c.mul(10)).mul(u).mul(.5).add(.5), 0, 1);
380
380
  }
381
381
  //#endregion
382
382
  //#region src/tsl/noise/erosion.ts
383
- function Nt(e, t, n) {
384
- let r = xt(e, t), i = ct(e.add(r.mul(.6)), G(t, t)).mul(.5).add(.5);
385
- return w(k(1).sub(i.mul(2).sub(1).abs()), 0, 1);
383
+ function zt(e, t, n) {
384
+ let r = Dt(e, t), i = mt(e.add(r.mul(.6)), W(t, t)).mul(.5).add(.5);
385
+ return T(k(1).sub(i.mul(2).sub(1).abs()), 0, 1);
386
386
  }
387
387
  //#endregion
388
388
  //#region src/graph/nodes/texture/tileable-noise.ts
389
- var Pt = [
389
+ var Bt = [
390
390
  "perlin-fbm",
391
391
  "value",
392
392
  "worley",
@@ -394,30 +394,30 @@ var Pt = [
394
394
  "gabor",
395
395
  "simplex",
396
396
  "wavelet"
397
- ], Ft = [
397
+ ], Vt = [
398
398
  "none",
399
399
  "curl",
400
400
  "paper",
401
401
  "wool",
402
402
  "stone",
403
403
  "erosion"
404
- ], Y = [
404
+ ], q = [
405
405
  "octaves",
406
406
  "gain",
407
407
  "lacunarity",
408
408
  "antialias",
409
409
  "tileSize"
410
- ], It = {
411
- "perlin-fbm": ["aspect", ...Y],
412
- value: ["aspect", ...Y],
413
- worley: Y,
414
- "voronoi-smooth": Y,
415
- stone: Y,
416
- paper: Y,
417
- wool: Y,
418
- simplex: Y,
419
- wavelet: Y,
420
- erosion: Y,
410
+ ], Ht = {
411
+ "perlin-fbm": ["aspect", ...q],
412
+ value: ["aspect", ...q],
413
+ worley: q,
414
+ "voronoi-smooth": q,
415
+ stone: q,
416
+ paper: q,
417
+ wool: q,
418
+ simplex: q,
419
+ wavelet: q,
420
+ erosion: q,
421
421
  gabor: [
422
422
  "gaborFreq",
423
423
  "gaborAniso",
@@ -425,25 +425,25 @@ var Pt = [
425
425
  "tileSize"
426
426
  ],
427
427
  curl: []
428
- }, Lt = {
429
- value: gt,
430
- worley: vt,
431
- "voronoi-smooth": yt,
432
- stone: Tt,
433
- paper: Ct,
434
- wool: wt,
435
- wavelet: Mt,
436
- erosion: Nt
437
- }, Rt = [{
428
+ }, Ut = {
429
+ value: St,
430
+ worley: wt,
431
+ "voronoi-smooth": Tt,
432
+ stone: jt,
433
+ paper: kt,
434
+ wool: At,
435
+ wavelet: Rt,
436
+ erosion: zt
437
+ }, Wt = [{
438
438
  key: "field",
439
439
  kind: "float"
440
- }], zt = [{
440
+ }], Gt = [{
441
441
  key: "field",
442
442
  kind: "float"
443
443
  }, {
444
444
  key: "vector",
445
445
  kind: "vector"
446
- }], Bt = {
446
+ }], Kt = {
447
447
  type: "tileable-noise",
448
448
  nodeClass: "texture",
449
449
  label: "Tileable Noise",
@@ -461,14 +461,14 @@ var Pt = [
461
461
  key: "noiseType",
462
462
  label: "algorithm",
463
463
  type: "select",
464
- options: Pt,
464
+ options: Bt,
465
465
  default: "perlin-fbm"
466
466
  },
467
467
  {
468
468
  key: "preset",
469
469
  label: "preset",
470
470
  type: "select",
471
- options: Ft,
471
+ options: Vt,
472
472
  default: "none"
473
473
  },
474
474
  {
@@ -573,23 +573,23 @@ var Pt = [
573
573
  key: "coord",
574
574
  kind: "vector"
575
575
  }],
576
- outputs: e.noiseType === "perlin-fbm" && e.preset === "curl" ? zt : Rt
576
+ outputs: e.noiseType === "perlin-fbm" && e.preset === "curl" ? Gt : Wt
577
577
  };
578
578
  },
579
579
  paramsFor(e) {
580
- let t = e.noiseType ?? "perlin-fbm", n = e.preset ?? "none", r = It[t === "perlin-fbm" && n !== "none" ? n : t] ?? [], i = new Set([
580
+ let t = e.noiseType ?? "perlin-fbm", n = e.preset ?? "none", r = Ht[t === "perlin-fbm" && n !== "none" ? n : t] ?? [], i = new Set([
581
581
  "noiseType",
582
582
  "scale",
583
583
  ...r
584
584
  ]);
585
- return t === "perlin-fbm" && i.add("preset"), Bt.params.filter((e) => i.has(e.key));
585
+ return t === "perlin-fbm" && i.add("preset"), Kt.params.filter((e) => i.has(e.key));
586
586
  },
587
587
  build(e) {
588
588
  let t = e.inputs.coord ?? e.coord, n = Math.max(1, Math.round(Number.isFinite(Number(e.constant("octaves"))) ? Number(e.constant("octaves")) : 4)), r = e.constant("noiseType") ?? "perlin-fbm", i = e.constant("preset") ?? "none", a = r === "perlin-fbm" && i !== "none" ? i : r, o = e.live("gain"), s = e.live("scale");
589
- if (e.backend === "live") return { field: rt(t.mul(s), n, o, e.live("lacunarity")) };
590
- let c = Math.max(2, Math.round(Number.isFinite(Number(e.constant("lacunarity"))) ? Number(e.constant("lacunarity")) : 2)), l = G(t.x, t.y), u = e.live("antialias"), d = Math.max(1, Math.round(e.tileRepeat ?? 1)), f = N(A((d > 1 ? s.div(k(d)) : s).add(.5)), k(1)), p = e.live("aspect"), m = N(A(f.mul(p).add(.5)), k(1));
589
+ if (e.backend === "live") return { field: lt(t.mul(s), n, o, e.live("lacunarity")) };
590
+ let c = Math.max(2, Math.round(Number.isFinite(Number(e.constant("lacunarity"))) ? Number(e.constant("lacunarity")) : 2)), l = W(t.x, t.y), u = e.live("antialias"), d = Math.max(1, Math.round(e.tileRepeat ?? 1)), f = N(A((d > 1 ? s.div(k(d)) : s).add(.5)), k(1)), p = e.live("aspect"), m = N(A(f.mul(p).add(.5)), k(1));
591
591
  if (a === "curl") {
592
- let e = St(l.mul(f), f, f);
592
+ let e = Ot(l.mul(f), f, f);
593
593
  return {
594
594
  field: e.length(),
595
595
  vector: e
@@ -597,33 +597,33 @@ var Pt = [
597
597
  }
598
598
  if (a === "simplex") {
599
599
  let e = f.add(I(f, k(2)));
600
- return { field: ut(l, e, e, n, o, At, u, c) };
600
+ return { field: gt(l, e, e, n, o, It, u, c) };
601
601
  }
602
602
  if (a === "gabor") {
603
603
  let t = k(1).sub(e.live("gaborAniso"));
604
- return { field: kt(l, f, e.live("gaborFreq"), t, e.live("gaborOrient")) };
604
+ return { field: Ft(l, f, e.live("gaborFreq"), t, e.live("gaborOrient")) };
605
605
  }
606
- let h = Lt[a];
607
- return h ? { field: ut(l, a === "value" ? m : f, f, n, o, h, u, c) } : { field: lt(l, m, f, n, o, u, c).mul(.5).add(.5) };
606
+ let h = Ut[a];
607
+ return h ? { field: gt(l, a === "value" ? m : f, f, n, o, h, u, c) } : { field: ht(l, m, f, n, o, u, c).mul(.5).add(.5) };
608
608
  }
609
- }, Vt = 4294967295;
610
- function Ht(e) {
611
- let t = oe(e.mul(G(141421356, 2718281828)));
612
- return k(t.x.bitXor(t.y).mul(H(3141592653))).div(Vt);
609
+ }, qt = 4294967295;
610
+ function Jt(e) {
611
+ let t = ue(e.mul(W(141421356, 2718281828)));
612
+ return k(t.x.bitXor(t.y).mul(H(3141592653))).div(qt);
613
613
  }
614
- function Ut(e) {
615
- return j(k(52.9829189).mul(j(O(e, G(.06711056, .00583715)))));
614
+ function Yt(e) {
615
+ return j(k(52.9829189).mul(j(O(e, W(.06711056, .00583715)))));
616
616
  }
617
- function Wt(e) {
617
+ function Xt(e) {
618
618
  let t = H(e.x), n = H(e.y);
619
- return k(t.mul(H(3242174889)).add(n.mul(H(2447445413)))).mul(ae(-32));
619
+ return k(t.mul(H(3242174889)).add(n.mul(H(2447445413)))).mul(le(-32));
620
620
  }
621
- function Gt(e) {
621
+ function Zt(e) {
622
622
  let t = k(0);
623
- for (let n = 0; n < 9; n++) t = t.add(Ht(e.add(G(n % 3 - 1, Math.floor(n / 3) - 1))));
624
- return k(.9).mul(k(1.125).mul(Ht(e)).sub(t.div(8))).add(.5);
623
+ for (let n = 0; n < 9; n++) t = t.add(Jt(e.add(W(n % 3 - 1, Math.floor(n / 3) - 1))));
624
+ return k(.9).mul(k(1.125).mul(Jt(e)).sub(t.div(8))).add(.5);
625
625
  }
626
- var Kt = h(([e, t]) => {
626
+ var Qt = y(([e, t]) => {
627
627
  let n = e.toVar(), r = t.toVar(), i = M(0).toVar();
628
628
  for (let e = 256; e > 0; e >>= 1) {
629
629
  let t = M(e), a = R(n.bitAnd(t).notEqual(M(0)), M(1), M(0)), o = R(r.bitAnd(t).notEqual(M(0)), M(1), M(0));
@@ -633,24 +633,24 @@ var Kt = h(([e, t]) => {
633
633
  }
634
634
  return i;
635
635
  });
636
- function qt(e) {
637
- let t = Kt(M(e.x), M(e.y));
636
+ function $t(e) {
637
+ let t = Qt(M(e.x), M(e.y));
638
638
  return j(k(.6180339887498948).mul(k(t.mod(M(262144)))));
639
639
  }
640
- var Jt = h(([e, t]) => {
640
+ var en = y(([e, t]) => {
641
641
  let n = A(e).toVar(), r = e.sub(n);
642
642
  n.x.assign(A(z(n.x.mul(51024)).mul(3104))), n.y.assign(A(z(n.y.mul(1324)).mul(554)));
643
643
  let i = n.x.add(n.y);
644
- r = r.mul(2).sub(1), r = r.mul(E(i)).add(G(r.y.negate(), r.x).mul(z(i))), r = r.add(z(n.x.sub(n.y))), r = r.mul(.5).add(.5);
645
- let a = z(n.x.add(r.y.mul(3.1415))).add(z(n.y.add(r.y.mul(3.1415)))).mul(.2), o = g(r.x.sub(.5).add(a));
646
- return o = k(.5).sub(o.mul(t)), o = B(-2, se(o).mul(1.5).add(16), o).mul(12), o.mul(r.y);
644
+ r = r.mul(2).sub(1), r = r.mul(E(i)).add(W(r.y.negate(), r.x).mul(z(i))), r = r.add(z(n.x.sub(n.y))), r = r.mul(.5).add(.5);
645
+ let a = z(n.x.add(r.y.mul(3.1415))).add(z(n.y.add(r.y.mul(3.1415)))).mul(.2), o = b(r.x.sub(.5).add(a));
646
+ return o = k(.5).sub(o.mul(t)), o = B(-2, de(o).mul(1.5).add(16), o).mul(12), o.mul(r.y);
647
647
  });
648
- function Yt(e, t) {
648
+ function tn(e, t) {
649
649
  let n = e, r = t, i = k(0);
650
- for (let e = 0; e < 8; e++) i = N(i, Jt(n, r)), n = G(n.x.sub(n.y.mul(.7)), n.x.mul(.7).add(n.y)).sub(12.31);
650
+ for (let e = 0; e < 8; e++) i = N(i, en(n, r)), n = W(n.x.sub(n.y.mul(.7)), n.x.mul(.7).add(n.y)).sub(12.31);
651
651
  return i;
652
652
  }
653
- var Xt = {
653
+ var nn = {
654
654
  type: "screen-noise",
655
655
  nodeClass: "texture",
656
656
  label: "Screen Noise",
@@ -684,17 +684,17 @@ var Xt = {
684
684
  default: 512
685
685
  }],
686
686
  build(e) {
687
- let t = e.inputs.coord ?? e.coord, n = G(t.x, t.y), r = e.constant("noiseType") ?? "blue";
688
- if (r === "scratches") return { field: Yt(n.mul(5), k(3)) };
687
+ let t = e.inputs.coord ?? e.coord, n = W(t.x, t.y), r = e.constant("noiseType") ?? "blue";
688
+ if (r === "scratches") return { field: tn(n.mul(5), k(3)) };
689
689
  let i = n.mul(e.live("resolution"));
690
690
  switch (r) {
691
- case "hilbert-blue": return { field: qt(A(i)) };
692
- case "ign": return { field: Ut(A(i)) };
693
- case "golden-ign": return { field: Wt(A(i)) };
694
- default: return { field: Gt(A(i)) };
691
+ case "hilbert-blue": return { field: $t(A(i)) };
692
+ case "ign": return { field: Yt(A(i)) };
693
+ case "golden-ign": return { field: Xt(A(i)) };
694
+ default: return { field: Zt(A(i)) };
695
695
  }
696
696
  }
697
- }, Zt = {
697
+ }, rn = {
698
698
  type: "tileable-warp",
699
699
  nodeClass: "vector",
700
700
  label: "Tileable Warp",
@@ -717,35 +717,35 @@ var Xt = {
717
717
  }, {
718
718
  key: "scale",
719
719
  label: "scale",
720
- type: "int",
720
+ type: "float",
721
721
  min: 1,
722
722
  max: 64,
723
723
  step: 1,
724
724
  default: 4
725
725
  }],
726
726
  build(e) {
727
- let t = e.inputs.coord ?? e.coord, n = e.live("amount");
727
+ let t = e.inputs.coord ?? e.coord, n = e.live("amount"), r = e.live("scale").round().clamp(1, 64);
728
728
  if (e.backend === "live") {
729
- let r = t.div(Math.max(1, Number(e.constant("scale") ?? 4))), i = fe(r.add(K(11.3, 0, 0))), a = fe(r.add(K(0, 47.7, 0))), o = fe(r.add(K(0, 0, 93.1)));
730
- return { coord: t.add(K(i, a, o).mul(n)) };
729
+ let e = t.div(r), i = ge(e.add(G(11.3, 0, 0))), a = ge(e.add(G(0, 47.7, 0))), o = ge(e.add(G(0, 0, 93.1)));
730
+ return { coord: t.add(G(i, a, o).mul(n)) };
731
731
  }
732
- let r = Math.max(1, Math.round(Number(e.constant("scale") ?? 4))), i = G(t.x, t.y), a = G(r, r), o = ct(i.mul(r), a), s = ct(i.mul(r).add(G(5.2, 1.3)), a), c = i.add(G(o, s).mul(n));
733
- return { coord: K(c.x, c.y, t.z) };
732
+ let i = W(t.x, t.y), a = W(r, r), o = mt(i.mul(r), a), s = mt(i.mul(r).add(W(5.2, 1.3)), a), c = i.add(W(o, s).mul(n));
733
+ return { coord: G(c.x, c.y, t.z) };
734
734
  }
735
- }, Qt = 1 / 2147483648;
736
- function $t(e, t, n) {
735
+ }, an = 1 / 2147483648;
736
+ function on(e, t, n) {
737
737
  let r = e.mul(1664525).add(1013904223).toVar(), i = t.mul(1664525).add(1013904223).toVar(), a = n.mul(1664525).add(1013904223).toVar();
738
738
  r.assign(r.add(i.mul(a))), i.assign(i.add(a.mul(r))), a.assign(a.add(r.mul(i))), r.assign(r.bitXor(r.shiftRight(16))), i.assign(i.bitXor(i.shiftRight(16))), a.assign(a.bitXor(a.shiftRight(16))), r.assign(r.add(i.mul(a))), i.assign(i.add(a.mul(r))), a.assign(a.add(r.mul(i)));
739
739
  let o = M(2147483647);
740
- return K(k(r.bitAnd(o)).mul(Qt), k(i.bitAnd(o)).mul(Qt), k(a.bitAnd(o)).mul(Qt));
740
+ return G(k(r.bitAnd(o)).mul(an), k(i.bitAnd(o)).mul(an), k(a.bitAnd(o)).mul(an));
741
741
  }
742
- function en(e, t) {
742
+ function sn(e, t) {
743
743
  return e.sub(M(A(k(e).div(t))).mul(M(t)));
744
744
  }
745
- function tn(e, t, n, r) {
746
- return typeof r == "number" && r <= 0 ? $t(e, t, n) : $t(en(e, r), en(t, r), en(n, r));
745
+ function cn(e, t, n, r) {
746
+ return typeof r == "number" && r <= 0 ? on(e, t, n) : on(sn(e, r), sn(t, r), sn(n, r));
747
747
  }
748
- function nn(e, t, n, r) {
748
+ function ln(e, t, n, r) {
749
749
  let i = e.sub(t).abs();
750
750
  if (n === 1) return i.x.add(i.y).add(i.z);
751
751
  if (n === 2) return i.x.max(i.y.max(i.z));
@@ -755,32 +755,32 @@ function nn(e, t, n, r) {
755
755
  }
756
756
  return e.sub(t).length();
757
757
  }
758
- function rn(e, t, n, r, i, a) {
759
- return h(() => {
760
- let o = A(e), s = e.sub(o), c = M(o.x), l = M(o.y), u = M(o.z), d = k(1e10).toVar(), f = K(0, 0, 0).toVar(), p = K(0, 0, 0).toVar();
758
+ function un(e, t, n, r, i, a) {
759
+ return y(() => {
760
+ let o = A(e), s = e.sub(o), c = M(o.x), l = M(o.y), u = M(o.z), d = k(1e10).toVar(), f = G(0, 0, 0).toVar(), p = G(0, 0, 0).toVar();
761
761
  for (let e = -1; e <= 1; e++) for (let i = -1; i <= 1; i++) for (let o = -1; o <= 1; o++) {
762
- let m = K(o, i, e), h = m.add(tn(c.add(o), l.add(i), u.add(e), a).mul(t)), g = nn(h, s, n, r), _ = g.lessThan(d);
762
+ let m = G(o, i, e), h = m.add(cn(c.add(o), l.add(i), u.add(e), a).mul(t)), g = ln(h, s, n, r), _ = g.lessThan(d);
763
763
  d.assign(_.select(g, d)), f.assign(_.select(m, f)), p.assign(_.select(h, p));
764
764
  }
765
- return i === "color" ? tn(c.add(M(f.x)), l.add(M(f.y)), u.add(M(f.z)), a) : i === "position" ? p.add(o) : d;
765
+ return i === "color" ? cn(c.add(M(f.x)), l.add(M(f.y)), u.add(M(f.z)), a) : i === "position" ? p.add(o) : d;
766
766
  })();
767
767
  }
768
- function an(e, t, n, r, i, a) {
769
- return h(() => {
770
- let o = A(e), s = e.sub(o), c = M(o.x), l = M(o.y), u = M(o.z), d = k(1e10).toVar(), f = k(1e10).toVar(), p = K(0, 0, 0).toVar(), m = K(0, 0, 0).toVar(), h = K(0, 0, 0).toVar(), g = K(0, 0, 0).toVar();
768
+ function dn(e, t, n, r, i, a) {
769
+ return y(() => {
770
+ let o = A(e), s = e.sub(o), c = M(o.x), l = M(o.y), u = M(o.z), d = k(1e10).toVar(), f = k(1e10).toVar(), p = G(0, 0, 0).toVar(), m = G(0, 0, 0).toVar(), h = G(0, 0, 0).toVar(), g = G(0, 0, 0).toVar();
771
771
  for (let e = -1; e <= 1; e++) for (let i = -1; i <= 1; i++) for (let o = -1; o <= 1; o++) {
772
- let _ = K(o, i, e), v = _.add(tn(c.add(o), l.add(i), u.add(e), a).mul(t)), y = nn(v, s, n, r), b = y.lessThan(d).toVar(), x = y.lessThan(f).toVar(), S = R(b, d, R(x, y, f)), C = R(b, p, R(x, _, m)), w = R(b, h, R(x, v, g)), T = R(b, y, d), E = R(b, _, p), D = R(b, v, h);
773
- f.assign(S), m.assign(C), g.assign(w), d.assign(T), p.assign(E), h.assign(D);
772
+ let _ = G(o, i, e), v = _.add(cn(c.add(o), l.add(i), u.add(e), a).mul(t)), y = ln(v, s, n, r), b = y.lessThan(d).toVar(), x = y.lessThan(f).toVar(), S = R(b, d, R(x, y, f)), C = R(b, p, R(x, _, m)), w = R(b, h, R(x, v, g)), ee = R(b, y, d), te = R(b, _, p), ne = R(b, v, h);
773
+ f.assign(S), m.assign(C), g.assign(w), d.assign(ee), p.assign(te), h.assign(ne);
774
774
  }
775
- return i === "color" ? tn(c.add(M(m.x)), l.add(M(m.y)), u.add(M(m.z)), a) : i === "position" ? g.add(o) : f;
775
+ return i === "color" ? cn(c.add(M(m.x)), l.add(M(m.y)), u.add(M(m.z)), a) : i === "position" ? g.add(o) : f;
776
776
  })();
777
777
  }
778
- var on = 1;
779
- function sn(e, t, n, r, i, a, o) {
780
- return h(() => {
781
- let s = A(e), c = e.sub(s), l = M(s.x), u = M(s.y), d = M(s.z), f = N(i, k(1e-6)), p = k(0).toVar(), m = K(0, 0, 0).toVar(), h = K(0, 0, 0).toVar(), g = k(-1).toVar();
782
- for (let e = -1; e <= on; e++) for (let i = -1; i <= on; i++) for (let a = -1; a <= on; a++) {
783
- let s = K(a, i, e), _ = tn(l.add(a), u.add(i), d.add(e), o), v = s.add(_.mul(t)), y = nn(v, c, n, r);
778
+ var fn = 1;
779
+ function pn(e, t, n, r, i, a, o) {
780
+ return y(() => {
781
+ let s = A(e), c = e.sub(s), l = M(s.x), u = M(s.y), d = M(s.z), f = N(i, k(1e-6)), p = k(0).toVar(), m = G(0, 0, 0).toVar(), h = G(0, 0, 0).toVar(), g = k(-1).toVar();
782
+ for (let e = -1; e <= fn; e++) for (let i = -1; i <= fn; i++) for (let a = -1; a <= fn; a++) {
783
+ let s = G(a, i, e), _ = cn(l.add(a), u.add(i), d.add(e), o), v = s.add(_.mul(t)), y = ln(v, c, n, r);
784
784
  g.assign(R(g.equal(-1), k(1), B(0, 1, k(.5).add(p.sub(y).mul(.5).div(f)))));
785
785
  let b = f.mul(g).mul(k(1).sub(g)).toVar();
786
786
  p.assign(F(p, y, g).sub(b)), b.assign(b.div(k(1).add(f.mul(3)))), m.assign(F(m, _, g).sub(b)), h.assign(F(h, v, g).sub(b));
@@ -788,10 +788,10 @@ function sn(e, t, n, r, i, a, o) {
788
788
  return a === "color" ? m : a === "position" ? h.add(s) : p;
789
789
  })();
790
790
  }
791
- var cn = (e, t, n, r, i = 0) => rn(e, t, n, r, "distance", i), ln = (e, t, n, r, i = 0) => rn(e, t, n, r, "color", i), un = (e, t, n, r, i = 0) => rn(e, t, n, r, "position", i), dn = (e, t, n, r, i = 0) => an(e, t, n, r, "distance", i), fn = (e, t, n, r, i = 0) => an(e, t, n, r, "color", i), pn = (e, t, n, r, i = 0) => an(e, t, n, r, "position", i), mn = (e, t, n, r, i, a = 0) => sn(e, t, n, r, i, "distance", a), hn = (e, t, n, r, i, a = 0) => sn(e, t, n, r, i, "color", a), gn = (e, t, n, r, i, a = 0) => sn(e, t, n, r, i, "position", a);
792
- function _n(e, t, n = 0) {
793
- return h(() => {
794
- let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = M(r.z), c = (e, r, c) => K(e, r, c).add(tn(a.add(e), o.add(r), s.add(c), n).mul(t)).sub(i), l = K(0, 0, 0).toVar(), u = k(1e10).toVar();
791
+ var mn = (e, t, n, r, i = 0) => un(e, t, n, r, "distance", i), hn = (e, t, n, r, i = 0) => un(e, t, n, r, "color", i), gn = (e, t, n, r, i = 0) => un(e, t, n, r, "position", i), _n = (e, t, n, r, i = 0) => dn(e, t, n, r, "distance", i), vn = (e, t, n, r, i = 0) => dn(e, t, n, r, "color", i), yn = (e, t, n, r, i = 0) => dn(e, t, n, r, "position", i), bn = (e, t, n, r, i, a = 0) => pn(e, t, n, r, i, "distance", a), xn = (e, t, n, r, i, a = 0) => pn(e, t, n, r, i, "color", a), Sn = (e, t, n, r, i, a = 0) => pn(e, t, n, r, i, "position", a);
792
+ function Cn(e, t, n = 0) {
793
+ return y(() => {
794
+ let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = M(r.z), c = (e, r, c) => G(e, r, c).add(cn(a.add(e), o.add(r), s.add(c), n).mul(t)).sub(i), l = G(0, 0, 0).toVar(), u = k(1e10).toVar();
795
795
  for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) for (let n = -1; n <= 1; n++) {
796
796
  let r = c(n, t, e), i = r.dot(r), a = i.lessThan(u);
797
797
  u.assign(a.select(i, u)), l.assign(a.select(r, l));
@@ -806,20 +806,20 @@ function _n(e, t, n = 0) {
806
806
  }
807
807
  //#endregion
808
808
  //#region src/tsl/lloyd-points.ts
809
- function vn(e, t, n) {
809
+ function wn(e, t, n) {
810
810
  let r = Math.imul(e, 374761393) + Math.imul(t, 668265263) + Math.imul(n, 362437) >>> 0;
811
811
  r = Math.imul(r ^ r >>> 13, 1274126177) >>> 0;
812
812
  let i = (r & 65535) / 65536;
813
813
  return r = Math.imul(r ^ r >>> 16, 2246822519) >>> 0, [i, (r >>> 8 & 65535) / 65536];
814
814
  }
815
- function yn(e, t, n) {
815
+ function Tn(e, t, n) {
816
816
  let r = e - t;
817
817
  return r -= n * Math.round(r / n), r;
818
818
  }
819
- function bn(e, t, n, r = 0) {
819
+ function En(e, t, n, r = 0) {
820
820
  let i = e * e, a = new Float64Array(i), o = new Float64Array(i);
821
821
  for (let n = 0; n < e; n++) for (let i = 0; i < e; i++) {
822
- let [s, c] = vn(i, n, r), l = n * e + i;
822
+ let [s, c] = wn(i, n, r), l = n * e + i;
823
823
  a[l] = i + .5 + (s - .5) * t, o[l] = n + .5 + (c - .5) * t;
824
824
  }
825
825
  let s = Math.max(64, e * 24);
@@ -830,10 +830,10 @@ function bn(e, t, n, r = 0) {
830
830
  for (let i = 0; i < s; i++) {
831
831
  let u = (i + .5) / s * e, d = Math.floor(u), f = Infinity, p = 0;
832
832
  for (let t = -1; t <= 1; t++) for (let n = -1; n <= 1; n++) {
833
- let r = ((d + n) % e + e) % e, i = ((l + t) % e + e) % e * e + r, s = yn(a[i], u, e), m = yn(o[i], c, e), h = s * s + m * m;
833
+ let r = ((d + n) % e + e) % e, i = ((l + t) % e + e) % e * e + r, s = Tn(a[i], u, e), m = Tn(o[i], c, e), h = s * s + m * m;
834
834
  h < f && (f = h, p = i);
835
835
  }
836
- t[p] += a[p] + yn(u, a[p], e), n[p] += o[p] + yn(c, o[p], e), r[p]++;
836
+ t[p] += a[p] + Tn(u, a[p], e), n[p] += o[p] + Tn(c, o[p], e), r[p]++;
837
837
  }
838
838
  }
839
839
  for (let s = 0; s < i; s++) r[s] > 0 && (a[s] = (t[s] / r[s] % e + e) % e, o[s] = (n[s] / r[s] % e + e) % e);
@@ -847,9 +847,9 @@ function bn(e, t, n, r = 0) {
847
847
  }
848
848
  //#endregion
849
849
  //#region src/tsl/relaxed-voronoi.ts
850
- function xn(e, t) {
851
- return h(() => {
852
- let n = A(e), r = e.sub(n), i = M(n.x), a = M(n.y), o = (e, n) => K(e, n, 0).add(t(i.add(e), a.add(n))).sub(r), s = K(0, 0, 0).toVar(), c = k(1e10).toVar();
850
+ function Dn(e, t) {
851
+ return y(() => {
852
+ let n = A(e), r = e.sub(n), i = M(n.x), a = M(n.y), o = (e, n) => G(e, n, 0).add(t(i.add(e), a.add(n))).sub(r), s = G(0, 0, 0).toVar(), c = k(1e10).toVar();
853
853
  for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
854
854
  let n = o(t, e), r = n.dot(n), i = r.lessThan(c);
855
855
  c.assign(i.select(r, c)), s.assign(i.select(n, s));
@@ -862,9 +862,9 @@ function xn(e, t) {
862
862
  return l;
863
863
  })();
864
864
  }
865
- function Sn(e, t, n) {
866
- return h(() => {
867
- let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = (e, n) => K(e, n, 0).add(t(a.add(e), o.add(n))).sub(i), c = k(1e10).toVar(), l = M(0).toVar(), u = M(0).toVar();
865
+ function On(e, t, n) {
866
+ return y(() => {
867
+ let r = A(e), i = e.sub(r), a = M(r.x), o = M(r.y), s = (e, n) => G(e, n, 0).add(t(a.add(e), o.add(n))).sub(i), c = k(1e10).toVar(), l = M(0).toVar(), u = M(0).toVar();
868
868
  for (let e = -1; e <= 1; e++) for (let t = -1; t <= 1; t++) {
869
869
  let n = s(t, e), r = n.dot(n), i = r.lessThan(c);
870
870
  c.assign(i.select(r, c)), l.assign(i.select(a.add(t), l)), u.assign(i.select(o.add(e), u));
@@ -874,17 +874,17 @@ function Sn(e, t, n) {
874
874
  }
875
875
  //#endregion
876
876
  //#region src/graph/nodes/texture/voronoi.ts
877
- var Cn = [
877
+ var kn = [
878
878
  "euclidean",
879
879
  "manhattan",
880
880
  "chebychev",
881
881
  "minkowski"
882
- ], wn = [
882
+ ], An = [
883
883
  "f1",
884
884
  "f2",
885
885
  "smooth-f1",
886
886
  "distance-to-edge"
887
- ], Tn = [
887
+ ], jn = [
888
888
  {
889
889
  key: "distance",
890
890
  label: "Distance",
@@ -900,7 +900,7 @@ var Cn = [
900
900
  label: "Position",
901
901
  kind: "vector"
902
902
  }
903
- ], En = [
903
+ ], Mn = [
904
904
  {
905
905
  key: "distance",
906
906
  label: "Distance",
@@ -916,11 +916,11 @@ var Cn = [
916
916
  label: "Random",
917
917
  kind: "float"
918
918
  }
919
- ], Dn = [{
919
+ ], Nn = [{
920
920
  key: "coord",
921
921
  kind: "vector"
922
922
  }];
923
- function On(e) {
923
+ function Pn(e) {
924
924
  let t = Array(e);
925
925
  for (let n = 0; n < e; n++) {
926
926
  let e = Math.sin(n * 12.9898 + 78.233) * 43758.5453;
@@ -928,19 +928,19 @@ function On(e) {
928
928
  }
929
929
  return t;
930
930
  }
931
- var kn = {
931
+ var Fn = {
932
932
  type: "voronoi",
933
933
  nodeClass: "texture",
934
934
  label: "Voronoi",
935
- inputs: Dn,
936
- outputs: Tn,
935
+ inputs: Nn,
936
+ outputs: jn,
937
937
  params: [
938
938
  {
939
939
  key: "scale",
940
940
  label: "scale",
941
941
  type: "float",
942
942
  min: .1,
943
- max: 64,
943
+ max: 512,
944
944
  step: .05,
945
945
  default: 1
946
946
  },
@@ -957,14 +957,14 @@ var kn = {
957
957
  key: "metric",
958
958
  label: "metric",
959
959
  type: "select",
960
- options: Cn,
960
+ options: kn,
961
961
  default: "euclidean"
962
962
  },
963
963
  {
964
964
  key: "feature",
965
965
  label: "feature",
966
966
  type: "select",
967
- options: wn,
967
+ options: An,
968
968
  default: "f1"
969
969
  },
970
970
  {
@@ -1006,8 +1006,8 @@ var kn = {
1006
1006
  ],
1007
1007
  declare(e) {
1008
1008
  return {
1009
- inputs: Dn,
1010
- outputs: (e.feature ?? "f1") === "distance-to-edge" ? En : Tn
1009
+ inputs: Nn,
1010
+ outputs: (e.feature ?? "f1") === "distance-to-edge" ? Mn : jn
1011
1011
  };
1012
1012
  },
1013
1013
  paramsFor(e) {
@@ -1019,49 +1019,51 @@ var kn = {
1019
1019
  ]);
1020
1020
  t === "minkowski" && i.add("exponent"), n === "smooth-f1" && i.add("smoothness"), n === "distance-to-edge" && (i.add("relax"), i.add("edgeWidth"));
1021
1021
  let a = n === "distance-to-edge" && r > 0;
1022
- return kn.params.filter((e) => i.has(e.key)).map((e) => a && (e.key === "scale" || e.key === "randomness") ? {
1022
+ return Fn.params.filter((e) => i.has(e.key)).map((e) => a && (e.key === "scale" || e.key === "randomness") ? {
1023
1023
  ...e,
1024
1024
  bakeStructural: !0
1025
1025
  } : e);
1026
1026
  },
1027
1027
  build(e) {
1028
- let t = e.backend === "offline", n = Math.max(0, Cn.indexOf(e.constant("metric"))), r = e.constant("feature") ?? "f1", i = e.inputs.coord ?? e.coord, a = Math.max(0, Math.round(Number(e.constant("relax") ?? 0)));
1028
+ let t = e.backend === "offline", n = Math.max(0, kn.indexOf(e.constant("metric"))), r = e.constant("feature") ?? "f1", i = e.inputs.coord ?? e.coord, a = Math.max(0, Math.round(Number(e.constant("relax") ?? 0)));
1029
1029
  if (r === "distance-to-edge" && t && a > 0) {
1030
- let t = Math.max(1, Math.round(Number(e.constant("scale") ?? 1))), n = Number(e.constant("randomness") ?? 1), r = i.mul(t), o = e.constantArray("seeds", () => bn(t, n, a), "vec3"), s = (e) => e.sub(M(A(k(e).div(t))).mul(M(t))), c = (e, n) => o.element(s(n).mul(t).add(s(e))), l = e.constantArray("randoms", () => On(t * t), "float"), u = (e, n) => l.element(s(n).mul(t).add(s(e))), d = e.live("edgeWidth"), f = xn(r, c);
1030
+ let t = Math.max(1, Math.round(Number(e.constant("scale") ?? 1))), n = Math.min(64, t);
1031
+ t > 64 && console.warn(`[voronoi] relaxed cells capped at scale 64 (requested ${t} exceeds the uniform-buffer limit); set relax = 0 for finer faithful cells.`);
1032
+ let r = Number(e.constant("randomness") ?? 1), o = i.mul(n), s = e.constantArray("seeds", () => En(n, r, a), "vec3"), c = (e) => e.sub(M(A(k(e).div(n))).mul(M(n))), l = (e, t) => s.element(c(t).mul(n).add(c(e))), u = e.constantArray("randoms", () => Pn(n * n), "float"), d = (e, t) => u.element(c(t).mul(n).add(c(e))), f = e.live("edgeWidth"), p = Dn(o, l);
1031
1033
  return {
1032
- distance: f,
1033
- edges: B(k(0), d, f).oneMinus(),
1034
- random: Sn(r, c, u)
1034
+ distance: p,
1035
+ edges: B(k(0), f, p).oneMinus(),
1036
+ random: On(o, l, d)
1035
1037
  };
1036
1038
  }
1037
1039
  let o = e.live("randomness"), s = e.live("exponent"), c = e.live("smoothness"), l = e.live("edgeWidth"), u = e.live("scale"), d = N(A(u.add(.5)), k(1)), f = i.mul(t ? d : u), p = t ? d : 0;
1038
1040
  switch (r) {
1039
1041
  case "distance-to-edge": {
1040
- let e = _n(f, o, p);
1042
+ let e = Cn(f, o, p);
1041
1043
  return {
1042
1044
  distance: e,
1043
1045
  edges: B(k(0), l, e).oneMinus(),
1044
- random: ln(f, o, n, s, p).x
1046
+ random: hn(f, o, n, s, p).x
1045
1047
  };
1046
1048
  }
1047
1049
  case "f2": return {
1048
- distance: dn(f, o, n, s, p),
1049
- color: fn(f, o, n, s, p),
1050
- position: pn(f, o, n, s, p)
1050
+ distance: _n(f, o, n, s, p),
1051
+ color: vn(f, o, n, s, p),
1052
+ position: yn(f, o, n, s, p)
1051
1053
  };
1052
1054
  case "smooth-f1": return {
1053
- distance: mn(f, o, n, s, c, p),
1054
- color: hn(f, o, n, s, c, p),
1055
- position: gn(f, o, n, s, c, p)
1055
+ distance: bn(f, o, n, s, c, p),
1056
+ color: xn(f, o, n, s, c, p),
1057
+ position: Sn(f, o, n, s, c, p)
1056
1058
  };
1057
1059
  default: return {
1058
- distance: cn(f, o, n, s, p),
1059
- color: ln(f, o, n, s, p),
1060
- position: un(f, o, n, s, p)
1060
+ distance: mn(f, o, n, s, p),
1061
+ color: hn(f, o, n, s, p),
1062
+ position: gn(f, o, n, s, p)
1061
1063
  };
1062
1064
  }
1063
1065
  }
1064
- }, An = {
1066
+ }, In = {
1065
1067
  type: "checker",
1066
1068
  nodeClass: "texture",
1067
1069
  label: "Checker",
@@ -1119,54 +1121,54 @@ var kn = {
1119
1121
  fac: R(n, k(1), k(0))
1120
1122
  };
1121
1123
  }
1122
- }, jn = 6.283185307179586;
1123
- function Mn(e, t, n) {
1124
- let { columns: r, rows: i, offsetFreq: a } = t, o = G(e.x.mul(r), e.y.mul(i)), s = h(() => {
1124
+ }, Ln = 6.283185307179586;
1125
+ function Rn(e, t, n) {
1126
+ let { columns: r, rows: i, offsetFreq: a } = t, o = W(e.x.mul(r), e.y.mul(i)), s = y(() => {
1125
1127
  let e = A(o.y), t = k(-1e9).toVar(), s = k(0).toVar(), c = k(0).toVar(), l = k(0).toVar();
1126
1128
  for (let u = -1; u <= 1; u++) {
1127
1129
  let d = e.add(u), f = M(d), p = R(I(d, k(a)).notEqual(0), n.rowOffset, k(0)), m = A(o.x.sub(p));
1128
1130
  for (let e = -1; e <= 1; e++) {
1129
- let a = m.add(e), u = M(a), h = J(u, f, 0, r, i), _ = J(u, f, 1, r, i), v = h.x.sub(.5).mul(n.posRandom), y = h.y.sub(.5).mul(n.posRandom), b = a.add(.5).add(p).add(v), x = d.add(.5).add(y), S = o.x.sub(b).div(r), C = o.y.sub(x).div(i), w = _.x.sub(.5).mul(2).mul(n.rotRandom).mul(jn * .5).negate(), T = E(w), D = z(w), ee = T.mul(S).sub(D.mul(C)), te = D.mul(S).add(T.mul(C)), ne = k(1).add(h.z.sub(.5).mul(2).mul(n.sizeRandom)), re = k(.5).div(r).mul(ne).sub(n.gap), O = k(.5).div(i).mul(ne).sub(n.gap), ie = n.roundness.mul(P(re, O)), ae = g(ee).sub(re.sub(ie)), oe = g(te).sub(O.sub(ie)), A = le(G(N(ae, 0), N(oe, 0))), j = P(N(ae, oe), 0), se = A.add(j).sub(ie).negate(), ce = se.greaterThan(t);
1130
- s.assign(R(ce, _.y, s)), c.assign(R(ce, a, c)), l.assign(R(ce, d, l)), t.assign(R(ce, se, t));
1131
+ let a = m.add(e), u = M(a), h = K(u, f, 0, r, i), g = K(u, f, 1, r, i), _ = h.x.sub(.5).mul(n.posRandom), v = h.y.sub(.5).mul(n.posRandom), y = a.add(.5).add(p).add(_), x = d.add(.5).add(v), S = o.x.sub(y).div(r), C = o.y.sub(x).div(i), w = g.x.sub(.5).mul(2).mul(n.rotRandom).mul(Ln * .5).negate(), ee = E(w), te = z(w), ne = ee.mul(S).sub(te.mul(C)), T = te.mul(S).add(ee.mul(C)), re = k(1).add(h.z.sub(.5).mul(2).mul(n.sizeRandom)), ie = k(.5).div(r).mul(re).sub(n.gap), D = k(.5).div(i).mul(re).sub(n.gap), ae = n.roundness.mul(P(ie, D)), oe = b(ne).sub(ie.sub(ae)), se = b(T).sub(D.sub(ae)), O = pe(W(N(oe, 0), N(se, 0))), ce = P(N(oe, se), 0), le = O.add(ce).sub(ae).negate(), ue = le.greaterThan(t);
1132
+ s.assign(R(ue, g.y, s)), c.assign(R(ue, a, c)), l.assign(R(ue, d, l)), t.assign(R(ue, le, t));
1131
1133
  }
1132
1134
  }
1133
- return Ne(B(0, n.edge.add(1e-5), t), s, c, l);
1134
- })(), c = s.x, l = s.y, u = s.z, d = s.w, f = M(u), p = M(d), m = R(I(d, k(a)).notEqual(0), n.rowOffset, k(0)), _ = J(f, p, 0, r, i), v = u.add(.5).add(m).add(_.x.sub(.5).mul(n.posRandom)), y = d.add(.5).add(_.y.sub(.5).mul(n.posRandom));
1135
+ return Re(B(0, n.edge.add(1e-5), t), s, c, l);
1136
+ })(), c = s.x, l = s.y, u = s.z, d = s.w, f = M(u), p = M(d), m = R(I(d, k(a)).notEqual(0), n.rowOffset, k(0)), h = K(f, p, 0, r, i), g = u.add(.5).add(m).add(h.x.sub(.5).mul(n.posRandom)), _ = d.add(.5).add(h.y.sub(.5).mul(n.posRandom));
1135
1137
  return {
1136
1138
  mask: c,
1137
1139
  value: l,
1138
- cellCoord: K(o.x.sub(v), o.y.sub(y), 0),
1139
- cellRandom: J(f, p, 2, r, i)
1140
+ cellCoord: G(o.x.sub(g), o.y.sub(_), 0),
1141
+ cellRandom: K(f, p, 2, r, i)
1140
1142
  };
1141
1143
  }
1142
- function Nn(e, t, n, r, i) {
1143
- let a = t, o = n, s = h(() => {
1144
- let t = G(e.x.mul(a), e.y.mul(o)), n = A(t.y), s = k(1e9).toVar(), c = k(0).toVar(), l = k(0).toVar(), u = k(0).toVar(), d = k(0).toVar(), f = k(0).toVar();
1144
+ function zn(e, t, n, r, i) {
1145
+ let a = t, o = n, s = y(() => {
1146
+ let t = W(e.x.mul(a), e.y.mul(o)), n = A(t.y), s = k(1e9).toVar(), c = k(0).toVar(), l = k(0).toVar(), u = k(0).toVar(), d = k(0).toVar(), f = k(0).toVar();
1145
1147
  for (let r = -1; r <= 1; r++) {
1146
1148
  let i = n.add(r), p = R(I(i, k(2)).notEqual(0), k(.5), k(0)), m = A(t.x.sub(p));
1147
1149
  for (let t = -1; t <= 1; t++) {
1148
- let n = m.add(t), r = n.add(.5).add(p).div(a), h = i.add(.5).div(o), g = le(G(e.x.sub(r), e.y.sub(h))), _ = g.lessThan(s);
1149
- s.assign(R(_, g, s)), c.assign(R(_, r, c)), l.assign(R(_, h, l)), d.assign(R(_, n, d)), f.assign(R(_, i, f)), u.assign(R(_, mt(M(n), M(i), a, o), u));
1150
+ let n = m.add(t), r = n.add(.5).add(p).div(a), h = i.add(.5).div(o), g = pe(W(e.x.sub(r), e.y.sub(h))), _ = g.lessThan(s);
1151
+ s.assign(R(_, g, s)), c.assign(R(_, r, c)), l.assign(R(_, h, l)), d.assign(R(_, n, d)), f.assign(R(_, i, f)), u.assign(R(_, bt(M(n), M(i), a, o), u));
1150
1152
  }
1151
1153
  }
1152
1154
  let p = k(1e9).toVar();
1153
1155
  for (let r = -1; r <= 1; r++) {
1154
1156
  let i = n.add(r), s = R(I(i, k(2)).notEqual(0), k(.5), k(0)), u = A(t.x.sub(s));
1155
1157
  for (let t = -1; t <= 1; t++) {
1156
- let n = u.add(t).add(.5).add(s).div(a), r = i.add(.5).div(o), d = n.sub(c), f = r.sub(l), m = le(G(d, f)).add(1e-9), h = c.add(n).mul(.5), g = l.add(r).mul(.5), _ = h.sub(e.x).mul(d.div(m)).add(g.sub(e.y).mul(f.div(m))), v = m.lessThan(1e-4);
1158
+ let n = u.add(t).add(.5).add(s).div(a), r = i.add(.5).div(o), d = n.sub(c), f = r.sub(l), m = pe(W(d, f)).add(1e-9), h = c.add(n).mul(.5), g = l.add(r).mul(.5), _ = h.sub(e.x).mul(d.div(m)).add(g.sub(e.y).mul(f.div(m))), v = m.lessThan(1e-4);
1157
1159
  p.assign(P(p, R(v, k(1e9), _)));
1158
1160
  }
1159
1161
  }
1160
- return Ne(B(r, r.add(i).add(1e-5), p), u, d, f);
1162
+ return Re(B(r, r.add(i).add(1e-5), p), u, d, f);
1161
1163
  })(), c = s.x, l = s.y, u = s.z, d = s.w, f = R(I(d, k(2)).notEqual(0), k(.5), k(0)), p = u.add(.5).add(f).div(a), m = d.add(.5).div(o);
1162
1164
  return {
1163
1165
  mask: c,
1164
1166
  value: l,
1165
- cellCoord: K(e.x.sub(p).mul(a), e.y.sub(m).mul(o), 0),
1166
- cellRandom: J(M(u), M(d), 2, a, o)
1167
+ cellCoord: G(e.x.sub(p).mul(a), e.y.sub(m).mul(o), 0),
1168
+ cellRandom: K(M(u), M(d), 2, a, o)
1167
1169
  };
1168
1170
  }
1169
- var Pn = {
1171
+ var Bn = {
1170
1172
  type: "tile",
1171
1173
  nodeClass: "texture",
1172
1174
  label: "Tile Generator",
@@ -1298,7 +1300,7 @@ var Pn = {
1298
1300
  build(e) {
1299
1301
  let t = e.inputs.coord ?? e.coord, n = Math.max(1, Math.round(Number(e.constant("columns") ?? 6)));
1300
1302
  if (e.constant("lattice") === "hex") {
1301
- let { mask: r, value: i, cellCoord: a, cellRandom: o } = Nn(t, n, Math.max(2, Math.round(n * 2 / Math.sqrt(3) / 2) * 2), e.live("gap"), e.live("edge"));
1303
+ let { mask: r, value: i, cellCoord: a, cellRandom: o } = zn(t, n, Math.max(2, Math.round(n * 2 / Math.sqrt(3) / 2) * 2), e.live("gap"), e.live("edge"));
1302
1304
  return {
1303
1305
  mask: r,
1304
1306
  value: i,
@@ -1306,7 +1308,7 @@ var Pn = {
1306
1308
  cellRandom: o
1307
1309
  };
1308
1310
  }
1309
- let r = Math.max(1, Math.round(Number(e.constant("offsetFreq") ?? 2))), i = Math.max(1, Math.round(Number(e.constant("rows") ?? 12))), { mask: a, value: o, cellCoord: s, cellRandom: c } = Mn(t, {
1311
+ let r = Math.max(1, Math.round(Number(e.constant("offsetFreq") ?? 2))), i = Math.max(1, Math.round(Number(e.constant("rows") ?? 12))), { mask: a, value: o, cellCoord: s, cellRandom: c } = Rn(t, {
1310
1312
  columns: n,
1311
1313
  rows: Math.ceil(i / r) * r,
1312
1314
  offsetFreq: r
@@ -1326,28 +1328,28 @@ var Pn = {
1326
1328
  cellRandom: c
1327
1329
  };
1328
1330
  }
1329
- }, Fn = Math.PI;
1330
- function In(e, t, n) {
1331
- let r = t, i = h(() => {
1332
- let t = G(e.x.mul(r), e.y.mul(r)), i = A(t.x), a = A(t.y), o = k(1e9).toVar(), s = k(10).toVar(), c = k(10).toVar(), l = k(0).toVar(), u = k(1).toVar();
1331
+ }, Vn = Math.PI;
1332
+ function Hn(e, t, n) {
1333
+ let r = t, i = y(() => {
1334
+ let t = W(e.x.mul(r), e.y.mul(r)), i = A(t.x), a = A(t.y), o = k(1e9).toVar(), s = k(10).toVar(), c = k(10).toVar(), l = k(0).toVar(), u = k(1).toVar();
1333
1335
  for (let e = -1; e <= 1; e++) {
1334
1336
  let d = a.add(e), f = M(d);
1335
1337
  for (let e = -1; e <= 1; e++) {
1336
- let a = i.add(e), p = M(a), m = J(p, f, 0, r, r), h = J(p, f, 1, r, r), g = h.z.lessThan(n.amount), _ = k(1).add(m.z.sub(.5).mul(2).mul(n.sizeRandom)), v = n.radius.div(r).mul(_), y = m.x.sub(.5).mul(n.posRandom), b = m.y.sub(.5).mul(n.posRandom), x = a.add(.5).add(y), S = d.add(.5).add(b), C = t.x.sub(x).div(r), w = t.y.sub(S).div(r), T = R(g, le(G(C, w)), k(1e9)), D = h.x.sub(.5).mul(2).mul(n.rotRandom).mul(Fn).negate(), ee = E(D), te = z(D), ne = ee.mul(C).sub(te.mul(w)).div(v.add(1e-9)), re = te.mul(C).add(ee.mul(w)).div(v.add(1e-9)), O = T.lessThan(o);
1337
- s.assign(R(O, ne, s)), c.assign(R(O, re, c)), l.assign(R(O, h.y, l)), u.assign(R(O, _, u)), o.assign(R(O, T, o));
1338
+ let a = i.add(e), p = M(a), m = K(p, f, 0, r, r), h = K(p, f, 1, r, r), g = h.z.lessThan(n.amount), _ = k(1).add(m.z.sub(.5).mul(2).mul(n.sizeRandom)), v = n.radius.div(r).mul(_), y = m.x.sub(.5).mul(n.posRandom), b = m.y.sub(.5).mul(n.posRandom), x = a.add(.5).add(y), S = d.add(.5).add(b), C = t.x.sub(x).div(r), w = t.y.sub(S).div(r), ee = R(g, pe(W(C, w)), k(1e9)), te = h.x.sub(.5).mul(2).mul(n.rotRandom).mul(Vn).negate(), ne = E(te), T = z(te), re = ne.mul(C).sub(T.mul(w)).div(v.add(1e-9)), ie = T.mul(C).add(ne.mul(w)).div(v.add(1e-9)), D = ee.lessThan(o);
1339
+ s.assign(R(D, re, s)), c.assign(R(D, ie, c)), l.assign(R(D, h.y, l)), u.assign(R(D, _, u)), o.assign(R(D, ee, o));
1338
1340
  }
1339
1341
  }
1340
- return Ne(s, c, l, u);
1342
+ return Re(s, c, l, u);
1341
1343
  })();
1342
1344
  return {
1343
- coord: K(i.x, i.y, 0),
1345
+ coord: G(i.x, i.y, 0),
1344
1346
  value: i.z,
1345
1347
  size: i.w
1346
1348
  };
1347
1349
  }
1348
1350
  //#endregion
1349
1351
  //#region src/graph/nodes/texture/scatter.ts
1350
- var Ln = {
1352
+ var Un = {
1351
1353
  type: "scatter",
1352
1354
  nodeClass: "texture",
1353
1355
  label: "Scatter",
@@ -1429,7 +1431,7 @@ var Ln = {
1429
1431
  }
1430
1432
  ],
1431
1433
  build(e) {
1432
- let t = e.inputs.coord ?? e.coord, n = Math.round(Number(e.constant("density") ?? 10)), { coord: r, value: i, size: a } = In(t, Number.isFinite(n) ? Math.max(1, n) : 10, {
1434
+ let t = e.inputs.coord ?? e.coord, n = Math.round(Number(e.constant("density") ?? 10)), { coord: r, value: i, size: a } = Hn(t, Number.isFinite(n) ? Math.max(1, n) : 10, {
1433
1435
  amount: e.live("amount"),
1434
1436
  radius: e.live("radius"),
1435
1437
  sizeRandom: e.live("sizeRandom"),
@@ -1442,26 +1444,41 @@ var Ln = {
1442
1444
  size: a
1443
1445
  };
1444
1446
  }
1445
- }, Rn = 6.283185307179586;
1446
- function zn(e, t, n, r, i) {
1447
- let a = r ?? k(0), o = h(() => {
1448
- let r = le(G(e.x, e.y)), o = y(e.y, e.x), s, c;
1449
- if (t === "polygon") {
1450
- let e = Math.max(3, Math.round(n)), t = Rn / e, a = E(A(o.div(t).add(.5)).mul(t).sub(o)).mul(r), l = Math.cos(Math.PI / e), u = w(a.div(l), 0, 1);
1451
- s = B(0, i.edge.add(1e-4), u.oneMinus()), c = u.oneMinus();
1452
- } else {
1453
- let e = j(a.mul(13.13)).mul(Rn), t = j(a.mul(27.71)).mul(Rn), n = j(a.mul(51.37)).mul(Rn), l = z(o.mul(2).add(e)).mul(.5).add(z(o.mul(3).add(t)).mul(.3)).add(z(o.mul(5).add(n)).mul(.2)), u = k(1).add(l.mul(i.irregularity.mul(.4))), d = w(r.div(u.add(1e-6)), 0, 1);
1454
- s = B(0, i.edge.add(1e-4), d.oneMinus()), c = d.oneMinus();
1447
+ }, Wn = 6.283185307179586, Gn = [
1448
+ .13,
1449
+ .21,
1450
+ .09,
1451
+ .17
1452
+ ];
1453
+ function Kn(e, t, n, r, i, a) {
1454
+ let o = i ?? k(0), s = y(() => {
1455
+ let i = j(o.mul(13.13)).mul(Wn), s = j(o.mul(27.71)).mul(Wn), c = j(o.mul(51.37)).mul(Wn), l = j(o.mul(91.7)).mul(2).sub(1), u = a.dome.mul(k(1).add(a.formRandom.mul(l).mul(.8))).max(.2), d = j(o.mul(71.13)).mul(Wn), f = (e, r) => {
1456
+ let o = pe(W(e, r)), l = C(r, e), f, p;
1457
+ if (t === "polygon") {
1458
+ let e = Math.max(3, Math.round(n)), t = Wn / e, r = E(A(l.div(t).add(.5)).mul(t).sub(l)).mul(o), i = Math.cos(Math.PI / e), s = T(r.div(i), 0, 1);
1459
+ f = B(0, a.edge.add(1e-4), s.oneMinus()), p = s.oneMinus();
1460
+ } else {
1461
+ let e = z(l.mul(2).add(i)).mul(.5).add(z(l.mul(3).add(s)).mul(.3)).add(z(l.mul(5).add(c)).mul(.2)), t = k(1).add(e.mul(a.irregularity.mul(.4))), n = T(o.div(t.add(1e-6)), 0, 1);
1462
+ f = B(0, a.edge.add(1e-4), n.oneMinus()), p = n.oneMinus();
1463
+ }
1464
+ let m = T(o, 0, 1), h = L(T(m.mul(m).oneMinus(), 0, 1), u), g = E(d).mul(e).add(z(d).mul(r)), _ = h.mul(T(k(1).add(a.tilt.mul(g)), 0, 2)), v = B(0, .3, p), y = T(_, 0, 1.5).mul(v);
1465
+ return {
1466
+ mask: f,
1467
+ height: y
1468
+ };
1469
+ }, p = f(e.x, e.y), m = p.mask, h = p.height, g = Math.max(0, Math.min(Gn.length, Math.round(r))), _ = g > 0 ? j(o.mul(33.19)).mul(Wn) : null;
1470
+ for (let t = 0; t < g; t++) {
1471
+ let n = _.add(t / g * Wn), r = a.erode.mul(Gn[t]), i = f(e.x.add(E(n).mul(r)), e.y.add(z(n).mul(r)));
1472
+ m = m.min(i.mask), h = h.min(i.height);
1455
1473
  }
1456
- let l = w(r, 0, 1), u = L(w(l.mul(l).oneMinus(), 0, 1), i.dome), d = B(0, .3, c), f = u.mul(d);
1457
- return K(s, f, 0);
1474
+ return G(m, h, 0);
1458
1475
  })();
1459
1476
  return {
1460
- mask: o.x,
1461
- height: o.y
1477
+ mask: s.x,
1478
+ height: s.y
1462
1479
  };
1463
1480
  }
1464
- var Bn = {
1481
+ var qn = {
1465
1482
  type: "shape",
1466
1483
  nodeClass: "texture",
1467
1484
  label: "Shape",
@@ -1525,21 +1542,58 @@ var Bn = {
1525
1542
  max: .3,
1526
1543
  step: .002,
1527
1544
  default: .04
1545
+ },
1546
+ {
1547
+ key: "tilt",
1548
+ label: "tilt",
1549
+ type: "float",
1550
+ min: 0,
1551
+ max: 1,
1552
+ step: .01,
1553
+ default: 0
1554
+ },
1555
+ {
1556
+ key: "formRandom",
1557
+ label: "form rand",
1558
+ type: "float",
1559
+ min: 0,
1560
+ max: 1,
1561
+ step: .01,
1562
+ default: 0
1563
+ },
1564
+ {
1565
+ key: "erode",
1566
+ label: "erode",
1567
+ type: "float",
1568
+ min: 0,
1569
+ max: 1,
1570
+ step: .01,
1571
+ default: 0
1572
+ },
1573
+ {
1574
+ key: "erodeTaps",
1575
+ label: "erode taps",
1576
+ type: "select",
1577
+ options: ["off", "4"],
1578
+ default: "off"
1528
1579
  }
1529
1580
  ],
1530
1581
  build(e) {
1531
- let t = e.inputs.coord ?? e.coord, n = e.inputs.seed, r = e.constant("shape") ?? "blob", i = Math.round(Number(e.constant("sides") ?? 6)), { mask: a, height: o } = zn(t, r, Number.isFinite(i) ? Math.max(3, i) : 6, n ?? null, {
1582
+ let t = e.inputs.coord ?? e.coord, n = e.inputs.seed, r = e.constant("shape") ?? "blob", i = Math.round(Number(e.constant("sides") ?? 6)), { mask: a, height: o } = Kn(t, r, Number.isFinite(i) ? Math.max(3, i) : 6, parseInt(String(e.constant("erodeTaps") ?? "off"), 10) || 0, n ?? null, {
1532
1583
  irregularity: e.live("irregularity"),
1533
1584
  dome: e.live("dome"),
1534
- edge: e.live("edge")
1585
+ edge: e.live("edge"),
1586
+ tilt: e.live("tilt"),
1587
+ formRandom: e.live("formRandom"),
1588
+ erode: e.live("erode")
1535
1589
  });
1536
1590
  return {
1537
1591
  mask: a,
1538
1592
  height: o
1539
1593
  };
1540
1594
  }
1541
- }, Vn = Math.PI * 2;
1542
- function Hn(e, t) {
1595
+ }, Jn = Math.PI * 2;
1596
+ function Yn(e, t) {
1543
1597
  let n = e.x, r = e.y, i = e.z, a;
1544
1598
  switch (t) {
1545
1599
  case 1: {
@@ -1556,7 +1610,7 @@ function Hn(e, t) {
1556
1610
  a = n.add(r).mul(.5);
1557
1611
  break;
1558
1612
  case 4:
1559
- a = y(r, n).div(Vn).add(.5);
1613
+ a = C(r, n).div(Jn).add(.5);
1560
1614
  break;
1561
1615
  case 5: {
1562
1616
  let e = k(.999999).sub(n.mul(n).add(r.mul(r)).add(i.mul(i)).sqrt()).max(0);
@@ -1572,7 +1626,7 @@ function Hn(e, t) {
1572
1626
  }
1573
1627
  //#endregion
1574
1628
  //#region src/graph/nodes/texture/gradient.ts
1575
- var Un = [
1629
+ var Xn = [
1576
1630
  "linear",
1577
1631
  "quadratic",
1578
1632
  "easing",
@@ -1580,7 +1634,7 @@ var Un = [
1580
1634
  "radial",
1581
1635
  "quadratic-sphere",
1582
1636
  "sphere"
1583
- ], Wn = {
1637
+ ], Zn = {
1584
1638
  type: "gradient",
1585
1639
  nodeClass: "texture",
1586
1640
  label: "Gradient",
@@ -1604,68 +1658,68 @@ var Un = [
1604
1658
  key: "gradientType",
1605
1659
  label: "type",
1606
1660
  type: "select",
1607
- options: Un,
1661
+ options: Xn,
1608
1662
  default: "linear"
1609
1663
  }],
1610
1664
  build(e) {
1611
- return { field: Hn((e.inputs.coord ?? e.coord).mul(e.live("scale")), Math.max(0, Un.indexOf(e.constant("gradientType")))) };
1665
+ return { field: Yn((e.inputs.coord ?? e.coord).mul(e.live("scale")), Math.max(0, Xn.indexOf(e.constant("gradientType")))) };
1612
1666
  }
1613
- }, X = Math.PI * 2, Gn = Math.PI / 2, Kn = 20, qn = 10;
1614
- function Jn(e, t) {
1615
- if (t === 0) return k(.5).add(z(e.sub(Gn)).mul(.5));
1667
+ }, Qn = Math.PI * 2, $n = Math.PI / 2, er = 20, tr = 10;
1668
+ function nr(e, t) {
1669
+ if (t === 0) return k(.5).add(z(e.sub($n)).mul(.5));
1616
1670
  if (t === 1) {
1617
- let t = e.div(X);
1671
+ let t = e.div(Qn);
1618
1672
  return t.sub(A(t));
1619
1673
  }
1620
- let n = e.div(X);
1674
+ let n = e.div(Qn);
1621
1675
  return n.sub(A(n.add(.5))).abs().mul(2);
1622
1676
  }
1623
- function Yn(e, t, n, r, i) {
1624
- let a = Math.max(1, Math.round(i.scaleNum * Kn / X)), o = Math.max(1, Math.round(i.scaleNum * qn / X)), s;
1625
- if (s = i.dir === 0 ? e.x.mul(a * X) : i.dir === 1 ? e.y.mul(a * X) : i.dir === 2 ? e.z.mul(a * X) : e.x.add(e.y).add(e.z).mul(o * X), s = s.add(t), i.withDistortion) {
1677
+ function rr(e, t, n, r, i) {
1678
+ let a = Math.max(1, Math.round(i.scaleNum * er / Qn)), o = Math.max(1, Math.round(i.scaleNum * tr / Qn)), s;
1679
+ if (s = i.dir === 0 ? e.x.mul(a * Qn) : i.dir === 1 ? e.y.mul(a * Qn) : i.dir === 2 ? e.z.mul(a * Qn) : e.x.add(e.y).add(e.z).mul(o * Qn), s = s.add(t), i.withDistortion) {
1626
1680
  let t = Math.max(1, Math.round(i.scaleNum * i.detailScaleNum)), a = t, o = t;
1627
1681
  i.dir === 0 ? o = 2 : i.dir === 1 && (a = 2);
1628
- let c = lt(G(e.x, e.y), a, o, Math.max(1, i.detail), r);
1682
+ let c = ht(W(e.x, e.y), a, o, Math.max(1, i.detail), r);
1629
1683
  s = s.add(n.mul(c));
1630
1684
  }
1631
- return Jn(s, i.profile);
1685
+ return nr(s, i.profile);
1632
1686
  }
1633
- function Xn(e, t, n, r, i, a) {
1634
- let o = (e) => e.sub(Se(e)), s;
1635
- s = a.dir === 0 ? K(k(0), o(e.y), o(e.z)) : a.dir === 1 ? K(o(e.x), k(0), o(e.z)) : a.dir === 2 ? K(o(e.x), o(e.y), k(0)) : K(o(e.x), o(e.y), o(e.z));
1636
- let c = s.length().mul(t).mul(Kn).add(n);
1687
+ function ir(e, t, n, r, i, a) {
1688
+ let o = (e) => e.sub(Ee(e)), s;
1689
+ s = a.dir === 0 ? G(k(0), o(e.y), o(e.z)) : a.dir === 1 ? G(o(e.x), k(0), o(e.z)) : a.dir === 2 ? G(o(e.x), o(e.y), k(0)) : G(o(e.x), o(e.y), o(e.z));
1690
+ let c = s.length().mul(t).mul(er).add(n);
1637
1691
  if (a.withDistortion) {
1638
- let t = Math.max(1, Math.round(a.scaleNum * a.detailScaleNum)), n = lt(G(e.x, e.y), t, t, Math.max(1, a.detail), i);
1692
+ let t = Math.max(1, Math.round(a.scaleNum * a.detailScaleNum)), n = ht(W(e.x, e.y), t, t, Math.max(1, a.detail), i);
1639
1693
  c = c.add(r.mul(n));
1640
1694
  }
1641
- return Jn(c, a.profile);
1695
+ return nr(c, a.profile);
1642
1696
  }
1643
- function Zn(e, t, n, r, i, a, o) {
1644
- if (o.tileable) return o.waveType === 0 ? Yn(e, n, r, a, o) : Xn(e, t, n, r, a, o);
1697
+ function ar(e, t, n, r, i, a, o) {
1698
+ if (o.tileable) return o.waveType === 0 ? rr(e, n, r, a, o) : ir(e, t, n, r, a, o);
1645
1699
  let s = e.mul(t).add(1e-6).mul(.999999), c;
1646
- if (o.waveType === 0) c = o.dir === 0 ? s.x.mul(Kn) : o.dir === 1 ? s.y.mul(Kn) : o.dir === 2 ? s.z.mul(Kn) : s.x.add(s.y).add(s.z).mul(qn);
1700
+ if (o.waveType === 0) c = o.dir === 0 ? s.x.mul(er) : o.dir === 1 ? s.y.mul(er) : o.dir === 2 ? s.z.mul(er) : s.x.add(s.y).add(s.z).mul(tr);
1647
1701
  else {
1648
1702
  let e = s;
1649
- o.dir === 0 ? e = s.mul(K(0, 1, 1)) : o.dir === 1 ? e = s.mul(K(1, 0, 1)) : o.dir === 2 && (e = s.mul(K(1, 1, 0))), c = e.length().mul(Kn);
1703
+ o.dir === 0 ? e = s.mul(G(0, 1, 1)) : o.dir === 1 ? e = s.mul(G(1, 0, 1)) : o.dir === 2 && (e = s.mul(G(1, 1, 0))), c = e.length().mul(er);
1650
1704
  }
1651
1705
  if (c = c.add(n), o.withDistortion) {
1652
- let e = rt(s.mul(i), o.detail, a, k(2));
1706
+ let e = lt(s.mul(i), o.detail, a, k(2));
1653
1707
  c = c.add(r.mul(e.mul(2).sub(1)));
1654
1708
  }
1655
- return Jn(c, o.profile);
1709
+ return nr(c, o.profile);
1656
1710
  }
1657
1711
  //#endregion
1658
1712
  //#region src/graph/nodes/texture/wave.ts
1659
- var Qn = ["bands", "rings"], $n = [
1713
+ var or = ["bands", "rings"], sr = [
1660
1714
  "x",
1661
1715
  "y",
1662
1716
  "z",
1663
1717
  "diagonal"
1664
- ], er = [
1718
+ ], cr = [
1665
1719
  "sine",
1666
1720
  "saw",
1667
1721
  "triangle"
1668
- ], tr = {
1722
+ ], lr = {
1669
1723
  type: "wave",
1670
1724
  nodeClass: "texture",
1671
1725
  label: "Wave",
@@ -1692,21 +1746,21 @@ var Qn = ["bands", "rings"], $n = [
1692
1746
  key: "waveType",
1693
1747
  label: "type",
1694
1748
  type: "select",
1695
- options: Qn,
1749
+ options: or,
1696
1750
  default: "bands"
1697
1751
  },
1698
1752
  {
1699
1753
  key: "direction",
1700
1754
  label: "direction",
1701
1755
  type: "select",
1702
- options: $n,
1756
+ options: sr,
1703
1757
  default: "x"
1704
1758
  },
1705
1759
  {
1706
1760
  key: "profile",
1707
1761
  label: "profile",
1708
1762
  type: "select",
1709
- options: er,
1763
+ options: cr,
1710
1764
  default: "sine"
1711
1765
  },
1712
1766
  {
@@ -1759,18 +1813,18 @@ var Qn = ["bands", "rings"], $n = [
1759
1813
  ],
1760
1814
  build(e) {
1761
1815
  let t = e.inputs.coord ?? e.coord, n = {
1762
- waveType: Math.max(0, Qn.indexOf(e.constant("waveType"))),
1763
- dir: Math.max(0, $n.indexOf(e.constant("direction"))),
1764
- profile: Math.max(0, er.indexOf(e.constant("profile"))),
1816
+ waveType: Math.max(0, or.indexOf(e.constant("waveType"))),
1817
+ dir: Math.max(0, sr.indexOf(e.constant("direction"))),
1818
+ profile: Math.max(0, cr.indexOf(e.constant("profile"))),
1765
1819
  withDistortion: Number(e.constant("distortion") ?? 0) > 0,
1766
1820
  detail: e.constant("detail") ?? 2,
1767
1821
  tileable: e.backend === "offline",
1768
1822
  scaleNum: Number(e.constant("scale") ?? 1),
1769
1823
  detailScaleNum: Number(e.constant("detailScale") ?? 1)
1770
1824
  };
1771
- return { field: Zn(t, e.live("scale"), e.live("phase"), e.live("distortion"), e.live("detailScale"), e.live("detailRoughness"), n) };
1825
+ return { field: ar(t, e.live("scale"), e.live("phase"), e.live("distortion"), e.live("detailScale"), e.live("detailRoughness"), n) };
1772
1826
  }
1773
- }, nr = 6.283185307179586, rr = {
1827
+ }, ur = 6.283185307179586, dr = {
1774
1828
  type: "anisotropic-stripes",
1775
1829
  nodeClass: "texture",
1776
1830
  label: "Anisotropic Stripes",
@@ -1821,10 +1875,10 @@ var Qn = ["bands", "rings"], $n = [
1821
1875
  }
1822
1876
  ],
1823
1877
  build(e) {
1824
- let t = e.inputs.coord ?? e.coord, n = y(t.z, t.x).div(nr), r = fe(K(t.y.mul(.6), n.mul(6), k(0))).mul(e.live("waviness"));
1825
- return { field: n.mul(e.live("count")).add(r).mul(nr).sin().mul(.5).add(.5).pow(e.live("sharpness")).mul(e.live("contrast")) };
1878
+ let t = e.inputs.coord ?? e.coord, n = C(t.z, t.x).div(ur), r = ge(G(t.y.mul(.6), n.mul(6), k(0))).mul(e.live("waviness"));
1879
+ return { field: n.mul(e.live("count")).add(r).mul(ur).sin().mul(.5).add(.5).pow(e.live("sharpness")).mul(e.live("contrast")) };
1826
1880
  }
1827
- }, ir = /* @__PURE__ */ "add.subtract.multiply.divide.multiply-add.power.logarithm.sqrt.inverse-sqrt.absolute.exponent.min.max.less-than.greater-than.sign.compare.smooth-min.smooth-max.round.floor.ceil.truncate.fraction.modulo.floored-modulo.wrap.snap.pingpong.sine.cosine.tangent.arcsine.arccosine.arctangent.arctan2.sinh.cosh.tanh.radians.degrees.mix".split("."), ar = new Set([
1881
+ }, fr = /* @__PURE__ */ "add.subtract.multiply.divide.multiply-add.power.logarithm.sqrt.inverse-sqrt.absolute.exponent.min.max.less-than.greater-than.sign.compare.smooth-min.smooth-max.round.floor.ceil.truncate.fraction.modulo.floored-modulo.wrap.snap.pingpong.sine.cosine.tangent.arcsine.arccosine.arctangent.arctan2.sinh.cosh.tanh.radians.degrees.mix".split("."), pr = new Set([
1828
1882
  "sqrt",
1829
1883
  "inverse-sqrt",
1830
1884
  "absolute",
@@ -1846,13 +1900,13 @@ var Qn = ["bands", "rings"], $n = [
1846
1900
  "tanh",
1847
1901
  "radians",
1848
1902
  "degrees"
1849
- ]), or = new Set([
1903
+ ]), mr = new Set([
1850
1904
  "multiply-add",
1851
1905
  "compare",
1852
1906
  "smooth-min",
1853
1907
  "smooth-max",
1854
1908
  "wrap"
1855
- ]), sr = {
1909
+ ]), hr = {
1856
1910
  power: ["Base", "Exponent"],
1857
1911
  logarithm: ["Value", "Base"],
1858
1912
  "multiply-add": [
@@ -1885,8 +1939,8 @@ var Qn = ["bands", "rings"], $n = [
1885
1939
  radians: ["Degrees"],
1886
1940
  degrees: ["Radians"]
1887
1941
  };
1888
- function cr(e) {
1889
- let [t, n, r] = sr[e] ?? [
1942
+ function gr(e) {
1943
+ let [t, n, r] = hr[e] ?? [
1890
1944
  "A",
1891
1945
  "B",
1892
1946
  "C"
@@ -1895,17 +1949,17 @@ function cr(e) {
1895
1949
  label: t,
1896
1950
  kind: "float"
1897
1951
  }];
1898
- return ar.has(e) || i.push({
1952
+ return pr.has(e) || i.push({
1899
1953
  key: "b",
1900
1954
  label: n ?? "B",
1901
1955
  kind: "float"
1902
- }), or.has(e) && i.push({
1956
+ }), mr.has(e) && i.push({
1903
1957
  key: "c",
1904
1958
  label: r ?? "C",
1905
1959
  kind: "float"
1906
1960
  }), i;
1907
1961
  }
1908
- var lr = {
1962
+ var _r = {
1909
1963
  type: "math",
1910
1964
  nodeClass: "converter",
1911
1965
  label: "Math",
@@ -1927,7 +1981,7 @@ var lr = {
1927
1981
  key: "op",
1928
1982
  label: "op",
1929
1983
  type: "select",
1930
- options: ir,
1984
+ options: fr,
1931
1985
  default: "mix"
1932
1986
  },
1933
1987
  {
@@ -1951,7 +2005,7 @@ var lr = {
1951
2005
  ],
1952
2006
  declare(e) {
1953
2007
  return {
1954
- inputs: cr(e.op ?? "mix"),
2008
+ inputs: gr(e.op ?? "mix"),
1955
2009
  outputs: [{
1956
2010
  key: "field",
1957
2011
  kind: "float"
@@ -1967,60 +2021,60 @@ var lr = {
1967
2021
  case "divide": return { field: R(n.equal(0), k(0), t.div(n)) };
1968
2022
  case "multiply-add": return { field: t.mul(n).add(r) };
1969
2023
  case "power": return { field: L(t, n) };
1970
- case "logarithm": return { field: R(t.greaterThan(0).and(n.greaterThan(0)), ue(t).div(ue(n)), k(0)) };
1971
- case "sqrt": return { field: De(t) };
1972
- case "inverse-sqrt": return { field: R(t.greaterThan(0), ce(t), k(0)) };
1973
- case "absolute": return { field: g(t) };
1974
- case "exponent": return { field: ie(t) };
2024
+ case "logarithm": return { field: R(t.greaterThan(0).and(n.greaterThan(0)), me(t).div(me(n)), k(0)) };
2025
+ case "sqrt": return { field: je(t) };
2026
+ case "inverse-sqrt": return { field: R(t.greaterThan(0), fe(t), k(0)) };
2027
+ case "absolute": return { field: b(t) };
2028
+ case "exponent": return { field: ce(t) };
1975
2029
  case "min": return { field: P(t, n) };
1976
2030
  case "max": return { field: N(t, n) };
1977
2031
  case "less-than": return { field: R(t.lessThan(n), k(1), k(0)) };
1978
2032
  case "greater-than": return { field: R(t.greaterThan(n), k(1), k(0)) };
1979
- case "sign": return { field: Te(t) };
2033
+ case "sign": return { field: ke(t) };
1980
2034
  case "compare": return { field: R(t.sub(n).abs().lessThanEqual(N(r, k(1e-5))), k(1), k(0)) };
1981
- case "smooth-min": return { field: ur(t, n, r) };
1982
- case "smooth-max": return { field: ur(t.negate(), n.negate(), r).negate() };
1983
- case "round": return { field: Se(t) };
2035
+ case "smooth-min": return { field: vr(t, n, r) };
2036
+ case "smooth-max": return { field: vr(t.negate(), n.negate(), r).negate() };
2037
+ case "round": return { field: Ee(t) };
1984
2038
  case "floor": return { field: A(t) };
1985
- case "ceil": return { field: C(t) };
1986
- case "truncate": return { field: je(t) };
2039
+ case "ceil": return { field: ne(t) };
2040
+ case "truncate": return { field: Fe(t) };
1987
2041
  case "fraction": return { field: j(t) };
1988
- case "modulo": return { field: R(n.equal(0), k(0), t.sub(n.mul(je(t.div(n))))) };
2042
+ case "modulo": return { field: R(n.equal(0), k(0), t.sub(n.mul(Fe(t.div(n))))) };
1989
2043
  case "floored-modulo": return { field: R(n.equal(0), k(0), t.sub(n.mul(A(t.div(n))))) };
1990
- case "wrap": return { field: dr(t, n, r) };
2044
+ case "wrap": return { field: yr(t, n, r) };
1991
2045
  case "snap": return { field: R(n.equal(0), k(0), A(t.div(n)).mul(n)) };
1992
- case "pingpong": return { field: fr(t, n) };
2046
+ case "pingpong": return { field: br(t, n) };
1993
2047
  case "sine": return { field: z(t) };
1994
2048
  case "cosine": return { field: E(t) };
1995
- case "tangent": return { field: ke(t) };
1996
- case "arcsine": return { field: R(t.abs().lessThanEqual(1), v(t), k(0)) };
1997
- case "arccosine": return { field: R(t.abs().lessThanEqual(1), _(t), k(0)) };
1998
- case "arctangent": return { field: y(t) };
1999
- case "arctan2": return { field: y(t, n) };
2000
- case "sinh": return { field: Ee(t) };
2001
- case "cosh": return { field: D(t) };
2002
- case "tanh": return { field: Ae(t) };
2003
- case "radians": return { field: be(t) };
2004
- case "degrees": return { field: re(t) };
2049
+ case "tangent": return { field: Ne(t) };
2050
+ case "arcsine": return { field: R(t.abs().lessThanEqual(1), S(t), k(0)) };
2051
+ case "arccosine": return { field: R(t.abs().lessThanEqual(1), x(t), k(0)) };
2052
+ case "arctangent": return { field: C(t) };
2053
+ case "arctan2": return { field: C(t, n) };
2054
+ case "sinh": return { field: Ae(t) };
2055
+ case "cosh": return { field: ie(t) };
2056
+ case "tanh": return { field: Pe(t) };
2057
+ case "radians": return { field: we(t) };
2058
+ case "degrees": return { field: se(t) };
2005
2059
  default: return { field: F(t, n, e.live("factor")) };
2006
2060
  }
2007
2061
  }
2008
2062
  };
2009
- function ur(e, t, n) {
2063
+ function vr(e, t, n) {
2010
2064
  let r = N(n.sub(e.sub(t).abs()), k(0)).div(n), i = P(e, t).sub(r.mul(r).mul(r).mul(n).div(6));
2011
2065
  return R(n.equal(0), P(e, t), i);
2012
2066
  }
2013
- function dr(e, t, n) {
2067
+ function yr(e, t, n) {
2014
2068
  let r = t.sub(n);
2015
2069
  return R(r.equal(0), n, e.sub(r.mul(A(e.sub(n).div(r)))));
2016
2070
  }
2017
- function fr(e, t) {
2071
+ function br(e, t) {
2018
2072
  let n = t.mul(2);
2019
2073
  return R(t.equal(0), k(0), j(e.sub(t).div(n)).mul(n).sub(t).abs());
2020
2074
  }
2021
2075
  //#endregion
2022
2076
  //#region src/graph/nodes/converter/levels.ts
2023
- var pr = {
2077
+ var xr = {
2024
2078
  type: "levels",
2025
2079
  nodeClass: "converter",
2026
2080
  label: "Levels / Remap",
@@ -2062,7 +2116,7 @@ var pr = {
2062
2116
  let t = e.inputs.field ?? k(.5), n = e.constant("invert") ? t.oneMinus() : t;
2063
2117
  return { field: F(e.live("min"), e.live("max"), n) };
2064
2118
  }
2065
- }, mr = {
2119
+ }, Sr = {
2066
2120
  type: "color-ramp",
2067
2121
  nodeClass: "converter",
2068
2122
  label: "Color Ramp",
@@ -2107,10 +2161,10 @@ var pr = {
2107
2161
  }
2108
2162
  ],
2109
2163
  build(e) {
2110
- let t = e.inputs.field ?? k(.5), n = e.live("low"), r = e.live("high"), i = w(t.sub(n).div(r.sub(n).max(1e-5)), 0, 1);
2164
+ let t = e.inputs.field ?? k(.5), n = e.live("low"), r = e.live("high"), i = T(t.sub(n).div(r.sub(n).max(1e-5)), 0, 1);
2111
2165
  return { color: F(e.live("colorA"), e.live("colorB"), i) };
2112
2166
  }
2113
- }, hr = {
2167
+ }, Cr = {
2114
2168
  type: "height-blend",
2115
2169
  nodeClass: "converter",
2116
2170
  label: "Height Blend",
@@ -2149,7 +2203,7 @@ var pr = {
2149
2203
  key: "width",
2150
2204
  label: "width",
2151
2205
  type: "float",
2152
- min: .01,
2206
+ min: 0,
2153
2207
  max: 1,
2154
2208
  step: .01,
2155
2209
  default: .25
@@ -2167,10 +2221,10 @@ var pr = {
2167
2221
  build(e) {
2168
2222
  let t = e.inputs.heightA ?? k(.5), n = e.inputs.heightB ?? k(.5), r = e.live("transition"), i = e.live("width");
2169
2223
  e.inputs.breakup !== void 0 && (n = n.add(e.inputs.breakup.sub(.5).mul(e.live("breakup"))));
2170
- let a = n.sub(t).add(r.mul(2).sub(1));
2171
- return { fac: B(i.negate(), i, a) };
2224
+ let a = n.sub(t).add(r.mul(2).sub(1)), o = N(i, de(a));
2225
+ return { fac: B(o.negate(), o, a) };
2172
2226
  }
2173
- }, gr = {
2227
+ }, wr = {
2174
2228
  type: "blend",
2175
2229
  nodeClass: "color",
2176
2230
  label: "Blend",
@@ -2215,7 +2269,7 @@ var pr = {
2215
2269
  default: 1
2216
2270
  }],
2217
2271
  build(e) {
2218
- let t = e.inputs.a ?? T(0), n = e.inputs.b ?? T(16777215), r;
2272
+ let t = e.inputs.a ?? re(0), n = e.inputs.b ?? re(16777215), r;
2219
2273
  switch (e.constant("mode")) {
2220
2274
  case "multiply":
2221
2275
  r = t.mul(n);
@@ -2233,7 +2287,7 @@ var pr = {
2233
2287
  let i = (e.inputs.mask ?? k(1)).mul(e.live("opacity"));
2234
2288
  return { color: F(t, r, i) };
2235
2289
  }
2236
- }, _r = {
2290
+ }, Tr = {
2237
2291
  type: "invert",
2238
2292
  nodeClass: "color",
2239
2293
  label: "Invert Color",
@@ -2260,10 +2314,10 @@ var pr = {
2260
2314
  default: 1
2261
2315
  }],
2262
2316
  build(e) {
2263
- let t = e.inputs.color ?? K(0, 0, 0), n = e.inputs.fac ?? e.live("fac");
2264
- return { color: F(t, K(1, 1, 1).sub(t), n) };
2317
+ let t = e.inputs.color ?? G(0, 0, 0), n = e.inputs.fac ?? e.live("fac");
2318
+ return { color: F(t, G(1, 1, 1).sub(t), n) };
2265
2319
  }
2266
- }, vr = {
2320
+ }, Er = {
2267
2321
  type: "bright-contrast",
2268
2322
  nodeClass: "color",
2269
2323
  label: "Bright / Contrast",
@@ -2306,21 +2360,21 @@ var pr = {
2306
2360
  default: 0
2307
2361
  }],
2308
2362
  build(e) {
2309
- let t = e.inputs.color ?? K(0, 0, 0), n = e.inputs.contrast ?? e.live("contrast"), r = e.inputs.bright ?? e.live("bright"), i = k(1).add(n), a = r.sub(n.mul(.5));
2363
+ let t = e.inputs.color ?? G(0, 0, 0), n = e.inputs.contrast ?? e.live("contrast"), r = e.inputs.bright ?? e.live("bright"), i = k(1).add(n), a = r.sub(n.mul(.5));
2310
2364
  return { color: t.mul(i).add(a).max(0) };
2311
2365
  }
2312
- }, yr = 1e-10;
2313
- function br(e) {
2314
- let t = e.x, n = e.y, r = e.z, i = N(t, N(n, r)), a = P(t, P(n, r)), o = i.sub(a), s = i, c = R(i.equal(0), k(0), o.div(N(i, k(yr)))), l = K(i, i, i).sub(e).div(N(o, k(yr))), u = l.z.sub(l.y), d = k(2).add(l.x).sub(l.z), f = k(4).add(l.y).sub(l.x), p = R(n.equal(i), d, f);
2315
- return p = R(t.equal(i), u, p), p = p.div(6), p = R(p.lessThan(0), p.add(1), p), p = R(c.equal(0), k(0), p), K(p, c, s);
2366
+ }, Dr = 1e-10;
2367
+ function Or(e) {
2368
+ let t = e.x, n = e.y, r = e.z, i = N(t, N(n, r)), a = P(t, P(n, r)), o = i.sub(a), s = i, c = R(i.equal(0), k(0), o.div(N(i, k(Dr)))), l = G(i, i, i).sub(e).div(N(o, k(Dr))), u = l.z.sub(l.y), d = k(2).add(l.x).sub(l.z), f = k(4).add(l.y).sub(l.x), p = R(n.equal(i), d, f);
2369
+ return p = R(t.equal(i), u, p), p = p.div(6), p = R(p.lessThan(0), p.add(1), p), p = R(c.equal(0), k(0), p), G(p, c, s);
2316
2370
  }
2317
- function xr(e) {
2318
- let t = e.x, n = e.y, r = e.z, i = R(t.equal(1), k(0), t).mul(6), a = A(i), o = i.sub(a), s = r.mul(k(1).sub(n)), c = r.mul(k(1).sub(n.mul(o))), l = r.mul(k(1).sub(n.mul(k(1).sub(o)))), u = K(r, s, c);
2319
- return u = R(a.equal(4), K(l, s, r), u), u = R(a.equal(3), K(s, c, r), u), u = R(a.equal(2), K(s, r, l), u), u = R(a.equal(1), K(c, r, s), u), u = R(a.equal(0), K(r, l, s), u), R(n.equal(0), K(r, r, r), u);
2371
+ function kr(e) {
2372
+ let t = e.x, n = e.y, r = e.z, i = R(t.equal(1), k(0), t).mul(6), a = A(i), o = i.sub(a), s = r.mul(k(1).sub(n)), c = r.mul(k(1).sub(n.mul(o))), l = r.mul(k(1).sub(n.mul(k(1).sub(o)))), u = G(r, s, c);
2373
+ return u = R(a.equal(4), G(l, s, r), u), u = R(a.equal(3), G(s, c, r), u), u = R(a.equal(2), G(s, r, l), u), u = R(a.equal(1), G(c, r, s), u), u = R(a.equal(0), G(r, l, s), u), R(n.equal(0), G(r, r, r), u);
2320
2374
  }
2321
2375
  //#endregion
2322
2376
  //#region src/graph/nodes/color/hue-sat-val.ts
2323
- var Sr = {
2377
+ var Ar = {
2324
2378
  type: "hue-sat-val",
2325
2379
  nodeClass: "color",
2326
2380
  label: "Hue / Saturation",
@@ -2372,17 +2426,17 @@ var Sr = {
2372
2426
  }
2373
2427
  ],
2374
2428
  build(e) {
2375
- let t = e.inputs.color ?? K(.8, .8, .8), n = br(t);
2376
- return { color: F(t, xr(K(j(n.x.add(e.live("hue")).add(.5)), n.y.mul(e.live("saturation")).clamp(0, 1), n.z.mul(e.live("value")))), e.live("fac")) };
2429
+ let t = e.inputs.color ?? G(.8, .8, .8), n = Or(t);
2430
+ return { color: F(t, kr(G(j(n.x.add(e.live("hue")).add(.5)), n.y.mul(e.live("saturation")).clamp(0, 1), n.z.mul(e.live("value")))), e.live("fac")) };
2377
2431
  }
2378
- }, Cr = (e, t, n, r, i) => R(e.equal(0), t, R(e.equal(1), n, R(e.equal(2), r, i)));
2379
- function wr(e, t) {
2380
- let n = e.clamp(0, 1).mul(4), r = A(n).clamp(0, 3), i = n.sub(r), a = Cr(r, t[0], t[0], t[1], t[2]), o = Cr(r, t[0], t[1], t[2], t[3]), s = Cr(r, t[1], t[2], t[3], t[4]), c = Cr(r, t[2], t[3], t[4], t[4]), l = i.mul(i), u = l.mul(i);
2432
+ }, jr = (e, t, n, r, i) => R(e.equal(0), t, R(e.equal(1), n, R(e.equal(2), r, i)));
2433
+ function Mr(e, t) {
2434
+ let n = e.clamp(0, 1).mul(4), r = A(n).clamp(0, 3), i = n.sub(r), a = jr(r, t[0], t[0], t[1], t[2]), o = jr(r, t[0], t[1], t[2], t[3]), s = jr(r, t[1], t[2], t[3], t[4]), c = jr(r, t[2], t[3], t[4], t[4]), l = i.mul(i), u = l.mul(i);
2381
2435
  return o.mul(2).add(s.sub(a).mul(i)).add(a.mul(2).sub(o.mul(5)).add(s.mul(4)).sub(c).mul(l)).add(o.mul(3).sub(s.mul(3)).add(c).sub(a).mul(u)).mul(.5);
2382
2436
  }
2383
2437
  //#endregion
2384
2438
  //#region src/graph/nodes/color/rgb-curves.ts
2385
- var Tr = () => [...Fe], Er = {
2439
+ var Nr = () => [...Be], Pr = {
2386
2440
  type: "rgb-curves",
2387
2441
  nodeClass: "color",
2388
2442
  label: "RGB Curves",
@@ -2412,14 +2466,14 @@ var Tr = () => [...Fe], Er = {
2412
2466
  label: "curves",
2413
2467
  type: "curve",
2414
2468
  default: {
2415
- C: Tr(),
2416
- R: Tr(),
2417
- G: Tr(),
2418
- B: Tr()
2469
+ C: Nr(),
2470
+ R: Nr(),
2471
+ G: Nr(),
2472
+ B: Nr()
2419
2473
  }
2420
2474
  }],
2421
2475
  build(e) {
2422
- let t = e.inputs.color ?? K(0, 0, 0), n = e.live("curves"), r = (e) => [
2476
+ let t = e.inputs.color ?? G(0, 0, 0), n = e.live("curves"), r = (e) => [
2423
2477
  0,
2424
2478
  1,
2425
2479
  2,
@@ -2430,10 +2484,10 @@ var Tr = () => [...Fe], Er = {
2430
2484
  r(5),
2431
2485
  r(10),
2432
2486
  r(15)
2433
- ], c = wr(wr(t.x, i), a), l = wr(wr(t.y, i), o), u = wr(wr(t.z, i), s), d = e.inputs.fac ?? e.live("fac");
2434
- return { color: F(t, K(c, l, u), d) };
2487
+ ], c = Mr(Mr(t.x, i), a), l = Mr(Mr(t.y, i), o), u = Mr(Mr(t.z, i), s), d = e.inputs.fac ?? e.live("fac");
2488
+ return { color: F(t, G(c, l, u), d) };
2435
2489
  }
2436
- }, Dr = {
2490
+ }, Fr = {
2437
2491
  type: "luminance",
2438
2492
  nodeClass: "converter",
2439
2493
  label: "Luminance",
@@ -2448,9 +2502,9 @@ var Tr = () => [...Fe], Er = {
2448
2502
  params: [],
2449
2503
  build(e) {
2450
2504
  let t = e.inputs.color;
2451
- return { field: t ? de(t) : k(0) };
2505
+ return { field: t ? he(t) : k(0) };
2452
2506
  }
2453
- }, Or = {
2507
+ }, Ir = {
2454
2508
  type: "split-channels",
2455
2509
  nodeClass: "converter",
2456
2510
  label: "Split Channels",
@@ -2485,7 +2539,7 @@ var Tr = () => [...Fe], Er = {
2485
2539
  b: k(0)
2486
2540
  };
2487
2541
  }
2488
- }, kr = {
2542
+ }, Lr = {
2489
2543
  type: "combine-channels",
2490
2544
  nodeClass: "converter",
2491
2545
  label: "Combine Channels",
@@ -2509,9 +2563,9 @@ var Tr = () => [...Fe], Er = {
2509
2563
  }],
2510
2564
  params: [],
2511
2565
  build(e) {
2512
- return { color: K(e.inputs.r ?? k(0), e.inputs.g ?? k(0), e.inputs.b ?? k(0)) };
2566
+ return { color: G(e.inputs.r ?? k(0), e.inputs.g ?? k(0), e.inputs.b ?? k(0)) };
2513
2567
  }
2514
- }, Ar = {
2568
+ }, Rr = {
2515
2569
  type: "clamp",
2516
2570
  nodeClass: "converter",
2517
2571
  label: "Clamp",
@@ -2565,9 +2619,9 @@ var Tr = () => [...Fe], Er = {
2565
2619
  ],
2566
2620
  build(e) {
2567
2621
  let t = e.inputs.value ?? k(0), n = e.inputs.min ?? e.live("min"), r = e.inputs.max ?? e.live("max");
2568
- return e.constant("mode") === "range" ? { field: t.clamp(P(n, r), N(n, r)) } : { field: w(t, n, r) };
2622
+ return e.constant("mode") === "range" ? { field: t.clamp(P(n, r), N(n, r)) } : { field: T(t, n, r) };
2569
2623
  }
2570
- }, jr = {
2624
+ }, zr = {
2571
2625
  type: "separate-xyz",
2572
2626
  nodeClass: "converter",
2573
2627
  label: "Separate XYZ",
@@ -2591,14 +2645,14 @@ var Tr = () => [...Fe], Er = {
2591
2645
  ],
2592
2646
  params: [],
2593
2647
  build(e) {
2594
- let t = e.inputs.vector ?? K(0, 0, 0);
2648
+ let t = e.inputs.vector ?? G(0, 0, 0);
2595
2649
  return {
2596
2650
  x: t.x,
2597
2651
  y: t.y,
2598
2652
  z: t.z
2599
2653
  };
2600
2654
  }
2601
- }, Mr = {
2655
+ }, Br = {
2602
2656
  type: "combine-xyz",
2603
2657
  nodeClass: "converter",
2604
2658
  label: "Combine XYZ",
@@ -2650,9 +2704,9 @@ var Tr = () => [...Fe], Er = {
2650
2704
  }
2651
2705
  ],
2652
2706
  build(e) {
2653
- return { vector: K(e.inputs.x ?? e.live("x"), e.inputs.y ?? e.live("y"), e.inputs.z ?? e.live("z")) };
2707
+ return { vector: G(e.inputs.x ?? e.live("x"), e.inputs.y ?? e.live("y"), e.inputs.z ?? e.live("z")) };
2654
2708
  }
2655
- }, Nr = {
2709
+ }, Vr = {
2656
2710
  type: "constant-field",
2657
2711
  nodeClass: "input",
2658
2712
  label: "Constant (Field)",
@@ -2673,7 +2727,7 @@ var Tr = () => [...Fe], Er = {
2673
2727
  build(e) {
2674
2728
  return { field: e.live("value") };
2675
2729
  }
2676
- }, Pr = {
2730
+ }, Hr = {
2677
2731
  type: "constant-color",
2678
2732
  nodeClass: "input",
2679
2733
  label: "Constant (Color)",
@@ -2691,7 +2745,7 @@ var Tr = () => [...Fe], Er = {
2691
2745
  build(e) {
2692
2746
  return { color: e.live("color") };
2693
2747
  }
2694
- }, Fr = {
2748
+ }, Ur = {
2695
2749
  type: "tex-coordinate",
2696
2750
  nodeClass: "input",
2697
2751
  label: "Texture Coordinate",
@@ -2720,20 +2774,20 @@ var Tr = () => [...Fe], Er = {
2720
2774
  ],
2721
2775
  params: [],
2722
2776
  build(e) {
2723
- let t = K(W().x, W().y, k(0));
2777
+ let t = G(U().x, U().y, k(0));
2724
2778
  return e.backend === "offline" ? {
2725
2779
  generated: t,
2726
2780
  uv: t,
2727
2781
  object: t,
2728
2782
  normal: t
2729
2783
  } : {
2730
- generated: ve,
2784
+ generated: Se,
2731
2785
  uv: t,
2732
- object: ve,
2733
- normal: pe
2786
+ object: Se,
2787
+ normal: _e
2734
2788
  };
2735
2789
  }
2736
- }, Ir = [
2790
+ }, Wr = [
2737
2791
  "add",
2738
2792
  "subtract",
2739
2793
  "multiply",
@@ -2756,11 +2810,11 @@ var Tr = () => [...Fe], Er = {
2756
2810
  "sine",
2757
2811
  "cosine",
2758
2812
  "tangent"
2759
- ], Lr = new Set([
2813
+ ], Gr = new Set([
2760
2814
  "dot",
2761
2815
  "distance",
2762
2816
  "length"
2763
- ]), Rr = [{
2817
+ ]), Kr = [{
2764
2818
  key: "vector1",
2765
2819
  label: "A",
2766
2820
  kind: "vector"
@@ -2768,11 +2822,11 @@ var Tr = () => [...Fe], Er = {
2768
2822
  key: "vector2",
2769
2823
  label: "B",
2770
2824
  kind: "vector"
2771
- }], zr = {
2825
+ }], qr = {
2772
2826
  type: "vector-math",
2773
2827
  nodeClass: "vector",
2774
2828
  label: "Vector Math",
2775
- inputs: Rr,
2829
+ inputs: Kr,
2776
2830
  outputs: [{
2777
2831
  key: "vector",
2778
2832
  label: "Vector",
@@ -2782,7 +2836,7 @@ var Tr = () => [...Fe], Er = {
2782
2836
  key: "operation",
2783
2837
  label: "op",
2784
2838
  type: "select",
2785
- options: Ir,
2839
+ options: Wr,
2786
2840
  default: "add"
2787
2841
  }, {
2788
2842
  key: "scale",
@@ -2796,8 +2850,8 @@ var Tr = () => [...Fe], Er = {
2796
2850
  declare(e) {
2797
2851
  let t = e.operation ?? "add";
2798
2852
  return {
2799
- inputs: Rr,
2800
- outputs: Lr.has(t) ? [{
2853
+ inputs: Kr,
2854
+ outputs: Gr.has(t) ? [{
2801
2855
  key: "value",
2802
2856
  label: "Value",
2803
2857
  kind: "float"
@@ -2809,14 +2863,14 @@ var Tr = () => [...Fe], Er = {
2809
2863
  };
2810
2864
  },
2811
2865
  build(e) {
2812
- let t = e.inputs.vector1 ?? e.coord, n = e.inputs.vector2 ?? K(0, 0, 0);
2866
+ let t = e.inputs.vector1 ?? e.coord, n = e.inputs.vector2 ?? G(0, 0, 0);
2813
2867
  switch (e.constant("operation") ?? "add") {
2814
2868
  case "subtract": return { vector: t.sub(n) };
2815
2869
  case "multiply": return { vector: t.mul(n) };
2816
2870
  case "divide": return { vector: t.div(n) };
2817
- case "cross": return { vector: ee(t, n) };
2871
+ case "cross": return { vector: D(t, n) };
2818
2872
  case "project": return { vector: n.mul(O(t, n).div(O(n, n))) };
2819
- case "reflect": return { vector: xe(t, n.normalize()) };
2873
+ case "reflect": return { vector: Te(t, n.normalize()) };
2820
2874
  case "dot": return { value: O(t, n) };
2821
2875
  case "distance": return { value: t.sub(n).length() };
2822
2876
  case "length": return { value: t.length() };
@@ -2824,31 +2878,31 @@ var Tr = () => [...Fe], Er = {
2824
2878
  case "normalize": return { vector: t.normalize() };
2825
2879
  case "snap": return { vector: A(t.div(n)).mul(n) };
2826
2880
  case "floor": return { vector: A(t) };
2827
- case "ceil": return { vector: C(t) };
2881
+ case "ceil": return { vector: ne(t) };
2828
2882
  case "fraction": return { vector: j(t) };
2829
2883
  case "absolute": return { vector: t.abs() };
2830
2884
  case "minimum": return { vector: P(t, n) };
2831
2885
  case "maximum": return { vector: N(t, n) };
2832
2886
  case "sine": return { vector: z(t) };
2833
2887
  case "cosine": return { vector: E(t) };
2834
- case "tangent": return { vector: ke(t) };
2888
+ case "tangent": return { vector: Ne(t) };
2835
2889
  default: return { vector: t.add(n) };
2836
2890
  }
2837
2891
  }
2838
2892
  };
2839
2893
  //#endregion
2840
2894
  //#region src/tsl/vector-rotate.ts
2841
- function Br(e, t, n, r) {
2895
+ function Jr(e, t, n, r) {
2842
2896
  let i = e.sub(t), a = E(n), o = z(n), s, c, l;
2843
- return r === 0 ? (s = i.x, c = a.mul(i.y).sub(o.mul(i.z)), l = o.mul(i.y).add(a.mul(i.z))) : r === 1 ? (c = i.y, l = a.mul(i.z).sub(o.mul(i.x)), s = o.mul(i.z).add(a.mul(i.x))) : (l = i.z, s = a.mul(i.x).sub(o.mul(i.y)), c = o.mul(i.x).add(a.mul(i.y))), t.add(K(s, c, l));
2897
+ return r === 0 ? (s = i.x, c = a.mul(i.y).sub(o.mul(i.z)), l = o.mul(i.y).add(a.mul(i.z))) : r === 1 ? (c = i.y, l = a.mul(i.z).sub(o.mul(i.x)), s = o.mul(i.z).add(a.mul(i.x))) : (l = i.z, s = a.mul(i.x).sub(o.mul(i.y)), c = o.mul(i.x).add(a.mul(i.y))), t.add(G(s, c, l));
2844
2898
  }
2845
2899
  //#endregion
2846
2900
  //#region src/graph/nodes/vector/vector-rotate.ts
2847
- var Vr = [
2901
+ var Yr = [
2848
2902
  "x",
2849
2903
  "y",
2850
2904
  "z"
2851
- ], Hr = {
2905
+ ], Xr = {
2852
2906
  type: "vector-rotate",
2853
2907
  nodeClass: "vector",
2854
2908
  label: "Vector Rotate",
@@ -2874,7 +2928,7 @@ var Vr = [
2874
2928
  key: "axis",
2875
2929
  label: "axis",
2876
2930
  type: "select",
2877
- options: Vr,
2931
+ options: Yr,
2878
2932
  default: "z"
2879
2933
  }, {
2880
2934
  key: "angle",
@@ -2886,9 +2940,9 @@ var Vr = [
2886
2940
  default: 0
2887
2941
  }],
2888
2942
  build(e) {
2889
- return { vector: Br(e.inputs.vector ?? e.coord, e.inputs.center ?? K(0, 0, 0), e.inputs.angle ?? e.live("angle"), Math.max(0, Vr.indexOf(e.constant("axis")))) };
2943
+ return { vector: Jr(e.inputs.vector ?? e.coord, e.inputs.center ?? G(0, 0, 0), e.inputs.angle ?? e.live("angle"), Math.max(0, Yr.indexOf(e.constant("axis")))) };
2890
2944
  }
2891
- }, Ur = 1, Wr = {
2945
+ }, Zr = 8, Qr = {
2892
2946
  type: "normal-from-height",
2893
2947
  nodeClass: "vector",
2894
2948
  label: "Normal From Height",
@@ -2912,11 +2966,11 @@ var Vr = [
2912
2966
  }],
2913
2967
  build(e) {
2914
2968
  let t = e.inputs.height ?? k(.5);
2915
- if (e.backend === "live") return { normal: S(t, e.live("strength")) };
2916
- let n = t, r = W(), i = te(n).div(te(r.x)), a = ne(n).div(ne(r.y)), o = e.live("strength"), s = G(i, a).mul(o), c = k(Ur), l = s.mul(c.div(s.length().max(c)));
2917
- return { normal: ge(K(l.x.negate(), l.y.negate(), k(1))).mul(.5).add(.5) };
2969
+ if (e.backend === "live") return { normal: te(t, e.live("strength")) };
2970
+ let n = t, r = U(), i = ae(n).div(ae(r.x)), a = oe(n).div(oe(r.y)), o = e.live("strength"), s = W(i, a).mul(o), c = k(Zr), l = s.mul(c.div(s.length().pow(2).add(c.mul(c)).sqrt()));
2971
+ return { normal: be(G(l.x.negate(), l.y.negate(), k(1))).mul(.5).add(.5) };
2918
2972
  }
2919
- }, Gr = {
2973
+ }, $r = {
2920
2974
  type: "normal-map",
2921
2975
  nodeClass: "vector",
2922
2976
  label: "Normal Map",
@@ -2943,12 +2997,12 @@ var Vr = [
2943
2997
  default: 1
2944
2998
  }],
2945
2999
  build(e) {
2946
- return { normal: me(e.inputs.color ?? K(.5, .5, 1), e.inputs.strength ?? e.live("strength")) };
3000
+ return { normal: ve(e.inputs.color ?? G(.5, .5, 1), e.inputs.strength ?? e.live("strength")) };
2947
3001
  }
2948
3002
  };
2949
3003
  //#endregion
2950
3004
  //#region src/tsl/blender-mapping.ts
2951
- function Kr(e) {
3005
+ function ei(e) {
2952
3006
  let t = E(e.x), n = E(e.y), r = E(e.z), i = z(e.x), a = z(e.y), o = z(e.z), s = t.mul(r), c = t.mul(o), l = i.mul(r), u = i.mul(o);
2953
3007
  return {
2954
3008
  m00: n.mul(r),
@@ -2962,24 +3016,24 @@ function Kr(e) {
2962
3016
  m22: n.mul(t)
2963
3017
  };
2964
3018
  }
2965
- function qr(e, t) {
2966
- return K(e.m00.mul(t.x).add(e.m10.mul(t.y)).add(e.m20.mul(t.z)), e.m01.mul(t.x).add(e.m11.mul(t.y)).add(e.m21.mul(t.z)), e.m02.mul(t.x).add(e.m12.mul(t.y)).add(e.m22.mul(t.z)));
3019
+ function ti(e, t) {
3020
+ return G(e.m00.mul(t.x).add(e.m10.mul(t.y)).add(e.m20.mul(t.z)), e.m01.mul(t.x).add(e.m11.mul(t.y)).add(e.m21.mul(t.z)), e.m02.mul(t.x).add(e.m12.mul(t.y)).add(e.m22.mul(t.z)));
2967
3021
  }
2968
- function Jr(e, t) {
2969
- return K(e.m00.mul(t.x).add(e.m01.mul(t.y)).add(e.m02.mul(t.z)), e.m10.mul(t.x).add(e.m11.mul(t.y)).add(e.m12.mul(t.z)), e.m20.mul(t.x).add(e.m21.mul(t.y)).add(e.m22.mul(t.z)));
3022
+ function ni(e, t) {
3023
+ return G(e.m00.mul(t.x).add(e.m01.mul(t.y)).add(e.m02.mul(t.z)), e.m10.mul(t.x).add(e.m11.mul(t.y)).add(e.m12.mul(t.z)), e.m20.mul(t.x).add(e.m21.mul(t.y)).add(e.m22.mul(t.z)));
2970
3024
  }
2971
- function Yr(e, t, n, r, i) {
2972
- let a = Kr(n);
2973
- return i === 1 ? Jr(a, e.sub(t)).div(r) : i === 2 ? qr(a, e.mul(r)) : i === 3 ? qr(a, e.div(r)).normalize() : qr(a, e.mul(r)).add(t);
3025
+ function ri(e, t, n, r, i) {
3026
+ let a = ei(n);
3027
+ return i === 1 ? ni(a, e.sub(t)).div(r) : i === 2 ? ti(a, e.mul(r)) : i === 3 ? ti(a, e.div(r)).normalize() : ti(a, e.mul(r)).add(t);
2974
3028
  }
2975
3029
  //#endregion
2976
3030
  //#region src/graph/nodes/vector/mapping.ts
2977
- var Xr = [
3031
+ var ii = [
2978
3032
  "point",
2979
3033
  "texture",
2980
3034
  "vector",
2981
3035
  "normal"
2982
- ], Zr = {
3036
+ ], ai = {
2983
3037
  type: "mapping",
2984
3038
  nodeClass: "vector",
2985
3039
  label: "Mapping",
@@ -2996,7 +3050,7 @@ var Xr = [
2996
3050
  key: "mappingType",
2997
3051
  label: "type",
2998
3052
  type: "select",
2999
- options: Xr,
3053
+ options: ii,
3000
3054
  default: "point"
3001
3055
  },
3002
3056
  {
@@ -3031,10 +3085,10 @@ var Xr = [
3031
3085
  }
3032
3086
  ],
3033
3087
  build(e) {
3034
- let t = e.inputs.vector ?? e.coord, n = Math.max(0, Xr.indexOf(e.constant("mappingType")));
3035
- return { vector: Yr(t, e.live("location"), e.live("rotation"), e.live("scale"), n) };
3088
+ let t = e.inputs.vector ?? e.coord, n = Math.max(0, ii.indexOf(e.constant("mappingType")));
3089
+ return { vector: ri(t, e.live("location"), e.live("rotation"), e.live("scale"), n) };
3036
3090
  }
3037
- }, Z = {
3091
+ }, J = {
3038
3092
  baseColor: {
3039
3093
  key: "baseColor",
3040
3094
  label: "Base Color",
@@ -3110,35 +3164,35 @@ var Xr = [
3110
3164
  label: "Emission Strength",
3111
3165
  kind: "float"
3112
3166
  }
3113
- }, Qr = [
3114
- Z.baseColor,
3115
- Z.alpha,
3116
- Z.normal,
3117
- Z.height,
3118
- Z.ambientOcclusion,
3119
- Z.emission,
3120
- Z.emissionStrength
3121
- ], $r = [
3122
- Z.baseColor,
3123
- Z.alpha,
3124
- Z.normal,
3125
- Z.height
3126
- ], ei = [Z.metallic, Z.roughness], ti = [
3127
- Z.ior,
3128
- Z.coat,
3129
- Z.coatRoughness,
3130
- Z.sheen,
3131
- Z.sheenRoughness,
3132
- Z.transmission
3133
- ], ni = [{
3167
+ }, oi = [
3168
+ J.baseColor,
3169
+ J.alpha,
3170
+ J.normal,
3171
+ J.height,
3172
+ J.ambientOcclusion,
3173
+ J.emission,
3174
+ J.emissionStrength
3175
+ ], si = [
3176
+ J.baseColor,
3177
+ J.alpha,
3178
+ J.normal,
3179
+ J.height
3180
+ ], ci = [J.metallic, J.roughness], li = [
3181
+ J.ior,
3182
+ J.coat,
3183
+ J.coatRoughness,
3184
+ J.sheen,
3185
+ J.sheenRoughness,
3186
+ J.transmission
3187
+ ], ui = [{
3134
3188
  key: "bsdf",
3135
3189
  kind: "shader"
3136
- }], ri = [
3190
+ }], di = [
3137
3191
  {
3138
3192
  key: "materialType",
3139
3193
  label: "type",
3140
3194
  type: "select",
3141
- options: Re,
3195
+ options: Ue,
3142
3196
  default: "physical"
3143
3197
  },
3144
3198
  {
@@ -3278,9 +3332,9 @@ var Xr = [
3278
3332
  options: ["default"],
3279
3333
  default: "default"
3280
3334
  }
3281
- ], ii = Object.fromEntries(ri.filter((e) => e.type === "float" || e.type === "int").map((e) => [e.key, e.default]));
3282
- function ai(e) {
3283
- let t = Be(e.materialType), n = new Set([
3335
+ ], fi = Object.fromEntries(di.filter((e) => e.type === "float" || e.type === "int").map((e) => [e.key, e.default]));
3336
+ function pi(e) {
3337
+ let t = Ge(e.materialType), n = new Set([
3284
3338
  "materialType",
3285
3339
  "baseColor",
3286
3340
  "alpha",
@@ -3295,46 +3349,46 @@ function ai(e) {
3295
3349
  "sheenRoughness",
3296
3350
  "transmission"
3297
3351
  ]) n.add(e);
3298
- return t === "phong" && (n.add("shininess"), n.add("specular")), t === "toon" && n.add("gradientSteps"), t === "matcap" && (n.delete("emission"), n.delete("emissionStrength"), n.add("matcap")), ri.filter((e) => n.has(e.key));
3352
+ return t === "phong" && (n.add("shininess"), n.add("specular")), t === "toon" && n.add("gradientSteps"), t === "matcap" && (n.delete("emission"), n.delete("emissionStrength"), n.add("matcap")), di.filter((e) => n.has(e.key));
3299
3353
  }
3300
- var oi = {
3301
- type: We,
3354
+ var mi = {
3355
+ type: Xe,
3302
3356
  nodeClass: "shader",
3303
3357
  label: "Material",
3304
3358
  inputs: [
3305
- ...Qr,
3306
- ...ei,
3307
- ...ti
3359
+ ...oi,
3360
+ ...ci,
3361
+ ...li
3308
3362
  ],
3309
- outputs: ni,
3310
- params: ri,
3363
+ outputs: ui,
3364
+ params: di,
3311
3365
  declare(e) {
3312
- switch (Be(e.materialType)) {
3366
+ switch (Ge(e.materialType)) {
3313
3367
  case "standard": return {
3314
- inputs: [...Qr, ...ei],
3315
- outputs: ni
3368
+ inputs: [...oi, ...ci],
3369
+ outputs: ui
3316
3370
  };
3317
3371
  case "physical": return {
3318
3372
  inputs: [
3319
- ...Qr,
3320
- ...ei,
3321
- ...ti
3373
+ ...oi,
3374
+ ...ci,
3375
+ ...li
3322
3376
  ],
3323
- outputs: ni
3377
+ outputs: ui
3324
3378
  };
3325
3379
  case "matcap": return {
3326
- inputs: $r,
3327
- outputs: ni
3380
+ inputs: si,
3381
+ outputs: ui
3328
3382
  };
3329
3383
  default: return {
3330
- inputs: Qr,
3331
- outputs: ni
3384
+ inputs: oi,
3385
+ outputs: ui
3332
3386
  };
3333
3387
  }
3334
3388
  },
3335
- paramsFor: ai,
3389
+ paramsFor: pi,
3336
3390
  build(e) {
3337
- let t = ze[Be(e.constant("materialType"))], n = (t) => e.inputs[t] ?? e.live(t), r = (t) => Number(e.constant(t) ?? ii[t] ?? 0), i = (t) => e.inputs[t] === void 0 ? r(t) > 0 ? e.live(t) : void 0 : e.inputs[t], a = e.inputs.emission !== void 0 || e.inputs.emissionStrength !== void 0 || (e.constant("emission") ?? "#000000") !== "#000000", o = t.emissive && a ? (e.inputs.emission ?? e.live("emission")).mul(e.inputs.emissionStrength ?? e.live("emissionStrength")) : void 0, s = {
3391
+ let t = We[Ge(e.constant("materialType"))], n = (t) => e.inputs[t] ?? e.live(t), r = (t) => Number(e.constant(t) ?? fi[t] ?? 0), i = (t) => e.inputs[t] === void 0 ? r(t) > 0 ? e.live(t) : void 0 : e.inputs[t], a = e.inputs.emission !== void 0 || e.inputs.emissionStrength !== void 0 || (e.constant("emission") ?? "#000000") !== "#000000", o = t.emissive && a ? (e.inputs.emission ?? e.live("emission")).mul(e.inputs.emissionStrength ?? e.live("emissionStrength")) : void 0, s = {
3338
3392
  baseColor: n("baseColor"),
3339
3393
  normal: e.inputs.normal,
3340
3394
  height: e.inputs.height,
@@ -3347,7 +3401,7 @@ var oi = {
3347
3401
  }
3348
3402
  return { bsdf: s };
3349
3403
  }
3350
- }, si = [
3404
+ }, hi = [
3351
3405
  {
3352
3406
  key: "baseColor",
3353
3407
  label: "base color",
@@ -3452,7 +3506,7 @@ var oi = {
3452
3506
  step: .1,
3453
3507
  default: 1
3454
3508
  }
3455
- ], ci = Object.fromEntries(si.filter((e) => e.type === "float" || e.type === "int").map((e) => [e.key, e.default])), li = {
3509
+ ], gi = Object.fromEntries(hi.filter((e) => e.type === "float" || e.type === "int").map((e) => [e.key, e.default])), _i = {
3456
3510
  type: "principled-bsdf",
3457
3511
  nodeClass: "shader",
3458
3512
  label: "Principled BSDF",
@@ -3537,9 +3591,9 @@ var oi = {
3537
3591
  key: "bsdf",
3538
3592
  kind: "shader"
3539
3593
  }],
3540
- params: si,
3594
+ params: hi,
3541
3595
  build(e) {
3542
- let t = (t) => e.inputs[t] ?? e.live(t), n = (t) => Number(e.constant(t) ?? ci[t] ?? 0), r = (t) => e.inputs[t] === void 0 ? n(t) > 0 ? e.live(t) : void 0 : e.inputs[t], i = e.inputs.emission !== void 0 || e.inputs.emissionStrength !== void 0 || (e.constant("emission") ?? "#000000") !== "#000000" ? (e.inputs.emission ?? e.live("emission")).mul(e.inputs.emissionStrength ?? e.live("emissionStrength")) : void 0, a = r("coat"), o = r("sheen");
3596
+ let t = (t) => e.inputs[t] ?? e.live(t), n = (t) => Number(e.constant(t) ?? gi[t] ?? 0), r = (t) => e.inputs[t] === void 0 ? n(t) > 0 ? e.live(t) : void 0 : e.inputs[t], i = e.inputs.emission !== void 0 || e.inputs.emissionStrength !== void 0 || (e.constant("emission") ?? "#000000") !== "#000000" ? (e.inputs.emission ?? e.live("emission")).mul(e.inputs.emissionStrength ?? e.live("emissionStrength")) : void 0, a = r("coat"), o = r("sheen");
3543
3597
  return { bsdf: {
3544
3598
  baseColor: t("baseColor"),
3545
3599
  metallic: t("metallic"),
@@ -3557,7 +3611,7 @@ var oi = {
3557
3611
  transmission: r("transmission")
3558
3612
  } };
3559
3613
  }
3560
- }, ui = {
3614
+ }, vi = {
3561
3615
  type: "emission",
3562
3616
  nodeClass: "shader",
3563
3617
  label: "Emission",
@@ -3591,20 +3645,20 @@ var oi = {
3591
3645
  build(e) {
3592
3646
  let t = e.inputs.color ?? e.live("color"), n = e.inputs.strength ?? e.live("strength");
3593
3647
  return { bsdf: {
3594
- baseColor: K(0),
3648
+ baseColor: G(0),
3595
3649
  roughness: k(1),
3596
3650
  metallic: k(0),
3597
3651
  emission: t.mul(n)
3598
3652
  } };
3599
3653
  }
3600
- }, di = {
3601
- emission: K(0, 0, 0),
3654
+ }, yi = {
3655
+ emission: G(0, 0, 0),
3602
3656
  ambientOcclusion: k(1),
3603
3657
  alpha: k(1),
3604
3658
  coat: k(0),
3605
3659
  sheen: k(0),
3606
3660
  transmission: k(0)
3607
- }, fi = [
3661
+ }, bi = [
3608
3662
  "baseColor",
3609
3663
  "metallic",
3610
3664
  "roughness",
@@ -3619,21 +3673,21 @@ var oi = {
3619
3673
  "sheenRoughness",
3620
3674
  "transmission"
3621
3675
  ];
3622
- function pi(e, t, n) {
3676
+ function xi(e, t, n) {
3623
3677
  let r = {};
3624
- for (let i of fi) {
3678
+ for (let i of bi) {
3625
3679
  let a = e[i], o = t[i];
3626
3680
  if (a === void 0 && o === void 0) continue;
3627
3681
  if (a !== void 0 && o !== void 0) {
3628
3682
  r[i] = F(a, o, n);
3629
3683
  continue;
3630
3684
  }
3631
- let s = di[i];
3685
+ let s = yi[i];
3632
3686
  s === void 0 ? r[i] = a ?? o : r[i] = a === void 0 ? F(s, o, n) : F(a, s, n);
3633
3687
  }
3634
3688
  return r;
3635
3689
  }
3636
- var mi = {
3690
+ var Si = {
3637
3691
  type: "mix-shader",
3638
3692
  nodeClass: "shader",
3639
3693
  label: "Mix Shader",
@@ -3668,9 +3722,9 @@ var mi = {
3668
3722
  default: .5
3669
3723
  }],
3670
3724
  build(e) {
3671
- return { shader: pi(e.inputs.shaderA ?? {}, e.inputs.shaderB ?? {}, e.inputs.fac ?? e.live("fac")) };
3725
+ return { shader: xi(e.inputs.shaderA ?? {}, e.inputs.shaderB ?? {}, e.inputs.fac ?? e.live("fac")) };
3672
3726
  }
3673
- }, hi = {
3727
+ }, Ci = {
3674
3728
  type: "material-output",
3675
3729
  nodeClass: "output",
3676
3730
  label: "Material Output",
@@ -3697,7 +3751,7 @@ var mi = {
3697
3751
  build() {
3698
3752
  return {};
3699
3753
  }
3700
- }, gi = {
3754
+ }, wi = {
3701
3755
  type: "group",
3702
3756
  nodeClass: "group",
3703
3757
  label: "Group",
@@ -3707,7 +3761,7 @@ var mi = {
3707
3761
  build() {
3708
3762
  return {};
3709
3763
  }
3710
- }, _i = {
3764
+ }, Ti = {
3711
3765
  type: "group-input",
3712
3766
  nodeClass: "input",
3713
3767
  label: "Group Input",
@@ -3717,7 +3771,7 @@ var mi = {
3717
3771
  build() {
3718
3772
  return {};
3719
3773
  }
3720
- }, vi = {
3774
+ }, Ei = {
3721
3775
  type: "group-output",
3722
3776
  nodeClass: "output",
3723
3777
  label: "Group Output",
@@ -3730,7 +3784,7 @@ var mi = {
3730
3784
  };
3731
3785
  //#endregion
3732
3786
  //#region src/graph/registry.ts
3733
- function Q(e, t) {
3787
+ function Y(e, t) {
3734
3788
  if (e.ports) return e.ports;
3735
3789
  let n = t.get(e.type);
3736
3790
  return n.declare ? n.declare(e.params) : {
@@ -3738,11 +3792,11 @@ function Q(e, t) {
3738
3792
  outputs: n.outputs
3739
3793
  };
3740
3794
  }
3741
- function yi(e, t) {
3795
+ function Di(e, t) {
3742
3796
  let n = t.get(e.type);
3743
3797
  return n.paramsFor ? n.paramsFor(e.params) : n.params;
3744
3798
  }
3745
- var bi = class {
3799
+ var Oi = class {
3746
3800
  defs = /* @__PURE__ */ new Map();
3747
3801
  register(e) {
3748
3802
  if (this.defs.has(e.type)) throw Error(`Duplicate node type: ${e.type}`);
@@ -3760,25 +3814,25 @@ var bi = class {
3760
3814
  return [...this.defs.values()];
3761
3815
  }
3762
3816
  };
3763
- function xi() {
3764
- return new bi().register(it).register(at).register(Bt).register(Xt).register(Zt).register(kn).register(An).register(Pn).register(Ln).register(Bn).register(Wn).register(tr).register(rr).register(lr).register(pr).register(mr).register(hr).register(gr).register(_r).register(vr).register(Sr).register(Er).register(Dr).register(Or).register(kr).register(Ar).register(jr).register(Mr).register(Nr).register(Pr).register(Fr).register(zr).register(Hr).register(Wr).register(Gr).register(Zr).register(oi).register(li).register(ui).register(mi).register(hi).register(gi).register(_i).register(vi);
3817
+ function ki() {
3818
+ return new Oi().register(ut).register(dt).register(Kt).register(nn).register(rn).register(Fn).register(In).register(Bn).register(Un).register(qn).register(Zn).register(lr).register(dr).register(_r).register(xr).register(Sr).register(Cr).register(wr).register(Tr).register(Er).register(Ar).register(Pr).register(Fr).register(Ir).register(Lr).register(Rr).register(zr).register(Br).register(Vr).register(Hr).register(Ur).register(qr).register(Xr).register(Qr).register($r).register(ai).register(mi).register(_i).register(vi).register(Si).register(Ci).register(wi).register(Ti).register(Ei);
3765
3819
  }
3766
- var Si = xi(), Ci = /* @__PURE__ */ new Map();
3767
- function wi(t) {
3768
- let n = Math.max(2, Math.min(5, Math.round(t ?? 3))), r = Ci.get(n);
3820
+ var Ai = ki(), ji = /* @__PURE__ */ new Map();
3821
+ function Mi(t) {
3822
+ let n = Math.max(2, Math.min(5, Math.round(t ?? 3))), r = ji.get(n);
3769
3823
  if (r) return r;
3770
3824
  let i = new Uint8Array(n);
3771
3825
  for (let e = 0; e < n; e++) i[e] = Math.round(e / (n - 1) * 255);
3772
3826
  let a = new e.DataTexture(i, n, 1, e.RedFormat);
3773
- return a.minFilter = e.NearestFilter, a.magFilter = e.NearestFilter, a.needsUpdate = !0, Ci.set(n, a), a;
3827
+ return a.minFilter = e.NearestFilter, a.magFilter = e.NearestFilter, a.needsUpdate = !0, ji.set(n, a), a;
3774
3828
  }
3775
- function Ti(e) {
3829
+ function Ni(e) {
3776
3830
  return null;
3777
3831
  }
3778
3832
  //#endregion
3779
3833
  //#region src/graph/compiler.ts
3780
- var Ei = 2048;
3781
- function Di(e, t, n) {
3834
+ var Pi = 2048;
3835
+ function Fi(e, t, n) {
3782
3836
  let r = new Map(t.nodes.map((e) => [e.id, e])), i = /* @__PURE__ */ new Set(), a = [e];
3783
3837
  for (; a.length;) {
3784
3838
  let e = a.pop();
@@ -3792,11 +3846,11 @@ function Di(e, t, n) {
3792
3846
  }
3793
3847
  return !1;
3794
3848
  }
3795
- function Oi(e, t) {
3849
+ function Ii(e, t) {
3796
3850
  let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = (e) => {
3797
3851
  let t = a.get(e);
3798
3852
  return t || (t = new Map(e.nodes.map((e) => [e.id, e])), a.set(e, t)), t;
3799
- }, s = (e) => e.nodes.find((e) => e.type === He)?.id, c = (e, t, r, i) => {
3853
+ }, s = (e) => e.nodes.find((e) => e.type === qe)?.id, c = (e, t, r, i) => {
3800
3854
  if (t === s(e)) {
3801
3855
  i(r);
3802
3856
  return;
@@ -3820,7 +3874,7 @@ function Oi(e, t) {
3820
3874
  i.add(a);
3821
3875
  let o = e.subgraph;
3822
3876
  if (!o) return;
3823
- let s = o.nodes.find((e) => e.type === Ue), l = s && o.edges.find((e) => e.toNode === s.id && e.toInput === t);
3877
+ let s = o.nodes.find((e) => e.type === Je), l = s && o.edges.find((e) => e.toNode === s.id && e.toInput === t);
3824
3878
  l && c(o, l.fromNode, l.fromOutput, (t) => {
3825
3879
  for (let i of n.edges) i.toNode === e.id && i.toInput === t && c(n, i.fromNode, i.fromOutput, r);
3826
3880
  });
@@ -3831,19 +3885,19 @@ function Oi(e, t) {
3831
3885
  };
3832
3886
  return d(e, () => {}), n;
3833
3887
  }
3834
- function ki(e, t) {
3835
- return t === "float" ? K(e) : e;
3888
+ function Li(e, t) {
3889
+ return t === "float" ? G(e) : e;
3836
3890
  }
3837
- function Ai(e, t) {
3838
- let n = V(e, W());
3891
+ function Ri(e, t) {
3892
+ let n = V(e, U());
3839
3893
  return t === "float" ? n.r : n.xyz;
3840
3894
  }
3841
- function ji(e) {
3842
- let t = e.nodes.find((e) => e.type === q)?.params?.outputResolution, n = typeof t == "string" ? Number(t) : typeof t == "number" ? t : NaN;
3895
+ function zi(e) {
3896
+ let t = e.nodes.find((e) => e.type === Ye)?.params?.outputResolution, n = typeof t == "string" ? Number(t) : typeof t == "number" ? t : NaN;
3843
3897
  return Number.isFinite(n) && n > 0 ? n : 1024;
3844
3898
  }
3845
- function Mi(e) {
3846
- let t = e.nodes.find((e) => e.type === q), n = t && e.edges.find((e) => e.toNode === t.id && e.toInput === "surface"), r = n && e.nodes.find((e) => e.id === n.fromNode);
3899
+ function Bi(e) {
3900
+ let t = e.nodes.find((e) => e.type === Ye), n = t && e.edges.find((e) => e.toNode === t.id && e.toInput === "surface"), r = n && e.nodes.find((e) => e.id === n.fromNode);
3847
3901
  if (!r || r.type !== "shader-material") return {
3848
3902
  type: "physical",
3849
3903
  settings: {}
@@ -3853,7 +3907,7 @@ function Mi(e) {
3853
3907
  return Number.isFinite(n) ? n : t;
3854
3908
  };
3855
3909
  return {
3856
- type: Be(i.materialType),
3910
+ type: Ge(i.materialType),
3857
3911
  settings: {
3858
3912
  shininess: a(i.shininess, 30),
3859
3913
  specular: typeof i.specular == "string" ? i.specular : "#111111",
@@ -3862,13 +3916,13 @@ function Mi(e) {
3862
3916
  }
3863
3917
  };
3864
3918
  }
3865
- function Ni(e) {
3866
- let t = e.nodes.find((e) => e.type === q), n = t && e.edges.find((e) => e.toNode === t.id && e.toInput === "surface"), r = n && e.nodes.find((e) => e.id === n.fromNode), i = r && r.type === "shader-material" ? r.params : {}, a = (e, t) => {
3919
+ function Vi(e) {
3920
+ let t = e.nodes.find((e) => e.type === Ye), n = t && e.edges.find((e) => e.toNode === t.id && e.toInput === "surface"), r = n && e.nodes.find((e) => e.id === n.fromNode), i = r && r.type === "shader-material" ? r.params : {}, a = (e, t) => {
3867
3921
  let n = Number(e);
3868
3922
  return Number.isFinite(n) ? n : t;
3869
3923
  }, o = (e, t) => typeof e == "string" ? e : t;
3870
3924
  return {
3871
- type: Be(i.materialType),
3925
+ type: Ge(i.materialType),
3872
3926
  baseColor: o(i.baseColor, "#cccccc"),
3873
3927
  metallic: a(i.metallic, 0),
3874
3928
  roughness: a(i.roughness, .5),
@@ -3887,14 +3941,14 @@ function Ni(e) {
3887
3941
  matcap: o(i.matcap, "default")
3888
3942
  };
3889
3943
  }
3890
- function Pi(e, t, n) {
3944
+ function Hi(e, t, n) {
3891
3945
  if (n.backend === "live" || !n.allocCache || !t.bakeTileable) return 1;
3892
3946
  let r = e.params.tileSize, i = typeof r == "string" && r !== "off" ? Number(r) : NaN;
3893
3947
  if (!Number.isFinite(i) || i <= 0) return 1;
3894
3948
  let a = n.outputResolution ?? 1024, o = Math.max(1, Math.round(Number(e.params.scale) || 1));
3895
3949
  return Math.max(1, Math.min(Math.round(a / i), o));
3896
3950
  }
3897
- function Fi(e, t, n, r, i, a) {
3951
+ function Ui(e, t, n, r, i, a) {
3898
3952
  if (r.backend === "live" || !r.allocCache || !t.bakeTileable || n.vector !== void 0 || n.field === void 0) return;
3899
3953
  let o = e.params.tileSize, s = typeof o == "string" && o !== "off" ? Number(o) : NaN;
3900
3954
  if (!Number.isFinite(s) || s <= 0) return;
@@ -3902,41 +3956,41 @@ function Fi(e, t, n, r, i, a) {
3902
3956
  return i.push({
3903
3957
  cacheId: c,
3904
3958
  kind: "float",
3905
- colorNode: ki(n.field, "float"),
3959
+ colorNode: Li(n.field, "float"),
3906
3960
  sizing: { size: s }
3907
- }), { field: V(l, W().mul(k(a))).r };
3961
+ }), { field: V(l, U().mul(k(a))).r };
3908
3962
  }
3909
- function Ii(e) {
3963
+ function Wi(e) {
3910
3964
  let t = 0;
3911
- for (let n of e.nodes) t += 1, n.type === "group" && n.subgraph && (t += Ii(n.subgraph));
3965
+ for (let n of e.nodes) t += 1, n.type === "group" && n.subgraph && (t += Wi(n.subgraph));
3912
3966
  return t;
3913
3967
  }
3914
- function Li(e, t, n) {
3968
+ function Gi(e, t, n) {
3915
3969
  let r = {
3916
3970
  ...n,
3917
- outputResolution: n.outputResolution ?? ji(e)
3918
- }, i = r.backend === "live" ? ye : K(W().x, W().y, k(0)), a = r.soloNodeId ? { id: r.soloNodeId } : void 0, o = [], { outputs: s, uniforms: c, usage: l } = zi(e, t, r, i, o, r.allocCache ? Oi(e, t) : /* @__PURE__ */ new Set(), void 0, a);
3971
+ outputResolution: n.outputResolution ?? zi(e)
3972
+ }, i = r.backend === "live" ? Ce : G(U().x, U().y, k(0)), a = r.soloNodeId ? { id: r.soloNodeId } : void 0, o = [], { outputs: s, uniforms: c, usage: l } = qi(e, t, r, i, o, r.allocCache ? Ii(e, t) : /* @__PURE__ */ new Set(), void 0, a);
3919
3973
  return {
3920
- bundle: a && a.value !== void 0 && a.kind && a.kind !== "shader" ? Ri(a.value, a.kind) : Xi(e, t, s),
3974
+ bundle: a && a.value !== void 0 && a.kind && a.kind !== "shader" ? Ki(a.value, a.kind) : ia(e, t, s),
3921
3975
  uniforms: c,
3922
3976
  cachePlan: o,
3923
3977
  paramUsage: l
3924
3978
  };
3925
3979
  }
3926
- function Ri(e, t) {
3980
+ function Ki(e, t) {
3927
3981
  return {
3928
- baseColor: t === "float" ? K(e) : e,
3982
+ baseColor: t === "float" ? G(e) : e,
3929
3983
  roughness: k(1),
3930
3984
  metallic: k(0)
3931
3985
  };
3932
3986
  }
3933
- function zi(e, t, n, r, i, a, o, s) {
3934
- Qi(e, t, o !== void 0);
3935
- let c = Zi(e), l = new Map(e.nodes.map((e) => [e.id, e])), u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
3987
+ function qi(e, t, n, r, i, a, o, s) {
3988
+ oa(e, t, o !== void 0);
3989
+ let c = aa(e), l = new Map(e.nodes.map((e) => [e.id, e])), u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
3936
3990
  for (let p of c) {
3937
3991
  let c = l.get(p);
3938
3992
  if (!c) continue;
3939
- let m = Q(c, t);
3993
+ let m = Y(c, t);
3940
3994
  if (c.type === "group-input") {
3941
3995
  let e = {};
3942
3996
  for (let t of m.outputs) e[t.key] = o?.[t.key];
@@ -3944,19 +3998,19 @@ function zi(e, t, n, r, i, a, o, s) {
3944
3998
  continue;
3945
3999
  }
3946
4000
  if (c.type === "group") {
3947
- let o = Vi(c, t, n, r, i, a, Ki(c, e, u, l, t), s);
4001
+ let o = Yi(c, t, n, r, i, a, ea(c, e, u, l, t), s);
3948
4002
  u.set(p, o.outputs);
3949
4003
  for (let [e, t] of o.uniforms) d.set(e, t);
3950
4004
  for (let [e, t] of o.usage) f.set(e, t);
3951
4005
  continue;
3952
4006
  }
3953
- let h = Ki(c, e, u, l, t), g = t.get(c.type), _ = Yi(g, c);
4007
+ let h = ea(c, e, u, l, t), g = t.get(c.type), _ = ra(g, c);
3954
4008
  d.set(p, _);
3955
- let v = Pi(c, g, n), y = Bi(p, c, g, h, _, r, n, v, f), b = g.build(y);
3956
- u.set(p, Fi(c, g, b, n, i, v) ?? b);
4009
+ let v = Hi(c, g, n), y = Ji(p, c, g, h, _, r, n, v, f), b = g.build(y);
4010
+ u.set(p, Ui(c, g, b, n, i, v) ?? b);
3957
4011
  }
3958
4012
  if (s && s.value === void 0) {
3959
- let e = l.get(s.id), n = e ? Q(e, t).outputs[0] : void 0;
4013
+ let e = l.get(s.id), n = e ? Y(e, t).outputs[0] : void 0;
3960
4014
  e && n && (s.value = u.get(s.id)?.[n.key], s.kind = n.kind);
3961
4015
  }
3962
4016
  return {
@@ -3965,7 +4019,7 @@ function zi(e, t, n, r, i, a, o, s) {
3965
4019
  usage: f
3966
4020
  };
3967
4021
  }
3968
- function Bi(t, n, r, i, a, o, s, c, l) {
4022
+ function Ji(t, n, r, i, a, o, s, c, l) {
3969
4023
  let u = {};
3970
4024
  l.set(t, u);
3971
4025
  let d = n.params, f = (e) => r.params.find((t) => t.key === e)?.default;
@@ -3987,36 +4041,36 @@ function Bi(t, n, r, i, a, o, s, c, l) {
3987
4041
  if (i === "vec3") {
3988
4042
  let t = [];
3989
4043
  for (let n = 0; n < a.length; n += 3) t.push(new e.Vector3(a[n], a[n + 1], a[n + 2]));
3990
- return Me(t);
4044
+ return Le(t);
3991
4045
  }
3992
- return Me(Array.from(a), "float");
4046
+ return Le(Array.from(a), "float");
3993
4047
  }
3994
4048
  };
3995
4049
  }
3996
- function Vi(e, t, n, r, i, a, o, s) {
4050
+ function Yi(e, t, n, r, i, a, o, s) {
3997
4051
  let c = e.subgraph;
3998
4052
  if (!c) return {
3999
4053
  outputs: {},
4000
4054
  uniforms: /* @__PURE__ */ new Map(),
4001
4055
  usage: /* @__PURE__ */ new Map()
4002
4056
  };
4003
- let { outputs: l, uniforms: u, usage: d } = zi(c, t, n, r, i, a, o, s), f = c.nodes.find((e) => e.type === Ue), p = {};
4057
+ let { outputs: l, uniforms: u, usage: d } = qi(c, t, n, r, i, a, o, s), f = c.nodes.find((e) => e.type === Je), p = {};
4004
4058
  if (!f) return {
4005
4059
  outputs: p,
4006
4060
  uniforms: u,
4007
4061
  usage: d
4008
4062
  };
4009
4063
  let m = new Map(c.nodes.map((e) => [e.id, e]));
4010
- for (let r of Q(f, t).inputs) {
4011
- let o = c.edges.find((e) => e.toNode === f.id && e.toInput === r.key), u = o ? qi(o, r.kind, l, m, t) : void 0;
4064
+ for (let r of Y(f, t).inputs) {
4065
+ let o = c.edges.find((e) => e.toNode === f.id && e.toInput === r.key), u = o ? ta(o, r.kind, l, m, t) : void 0;
4012
4066
  if (n.allocCache && u !== void 0 && r.kind !== "shader" && !s) {
4013
- let s = `${e.id}/${r.key}`, l = o && Di(o.fromNode, c, t) || a.has(s) ? { minSize: Ei } : void 0, d = n.allocCache(s, r.kind, l);
4067
+ let s = `${e.id}/${r.key}`, l = o && Fi(o.fromNode, c, t) || a.has(s) ? { minSize: Pi } : void 0, d = n.allocCache(s, r.kind, l);
4014
4068
  i.push({
4015
4069
  cacheId: s,
4016
4070
  kind: r.kind,
4017
- colorNode: ki(u, r.kind),
4071
+ colorNode: Li(u, r.kind),
4018
4072
  sizing: l
4019
- }), p[r.key] = Ai(d, r.kind);
4073
+ }), p[r.key] = Ri(d, r.kind);
4020
4074
  } else p[r.key] = u;
4021
4075
  }
4022
4076
  return {
@@ -4025,110 +4079,110 @@ function Vi(e, t, n, r, i, a, o, s) {
4025
4079
  usage: d
4026
4080
  };
4027
4081
  }
4028
- var Hi = {
4082
+ var Xi = {
4029
4083
  side: e.DoubleSide,
4030
4084
  polygonOffset: !0,
4031
4085
  polygonOffsetFactor: 1,
4032
4086
  polygonOffsetUnits: 1
4033
4087
  };
4034
- function Ui(t = "physical", n = {}) {
4088
+ function Zi(t = "physical", n = {}) {
4035
4089
  switch (t) {
4036
- case "standard": return new d({
4090
+ case "standard": return new h({
4037
4091
  metalness: 0,
4038
4092
  roughness: .9,
4039
- ...Hi
4093
+ ...Xi
4040
4094
  });
4041
- case "lambert": return new s({ ...Hi });
4042
- case "phong": return new l({
4095
+ case "lambert": return new d({ ...Xi });
4096
+ case "phong": return new p({
4043
4097
  shininess: n.shininess ?? 30,
4044
4098
  specular: new e.Color(n.specular ?? "#111111"),
4045
- ...Hi
4099
+ ...Xi
4046
4100
  });
4047
- case "toon": return new f({
4048
- gradientMap: wi(n.gradientSteps),
4049
- ...Hi
4101
+ case "toon": return new g({
4102
+ gradientMap: Mi(n.gradientSteps),
4103
+ ...Xi
4050
4104
  });
4051
- case "matcap": return new c({
4052
- matcap: Ti(n.matcap),
4053
- ...Hi
4105
+ case "matcap": return new f({
4106
+ matcap: Ni(n.matcap),
4107
+ ...Xi
4054
4108
  });
4055
- default: return new u({
4109
+ default: return new m({
4056
4110
  metalness: 0,
4057
4111
  roughness: .9,
4058
- ...Hi
4112
+ ...Xi
4059
4113
  });
4060
4114
  }
4061
4115
  }
4062
- function Wi(e, t, n) {
4063
- let r = ze[n], i = e;
4116
+ function Qi(e, t, n) {
4117
+ let r = We[n], i = e;
4064
4118
  if (t.baseColor && (i.colorNode = t.baseColor), t.normal && (i.normalNode = t.normal), t.alpha && (i.opacityNode = t.alpha, i.transparent = !0), r.ao) {
4065
- let e = b("vertexAo", "float");
4119
+ let e = w("vertexAo", "float");
4066
4120
  i.aoNode = t.ambientOcclusion ? t.ambientOcclusion.mul(e) : e;
4067
4121
  }
4068
4122
  r.emissive && t.emission && (i.emissiveNode = t.emission), r.roughMetal && (t.roughness && (i.roughnessNode = t.roughness), t.metallic && (i.metalnessNode = t.metallic)), r.physicalLobes && (t.ior && (i.iorNode = t.ior), t.coat && (i.clearcoatNode = t.coat), t.coatRoughness && (i.clearcoatRoughnessNode = t.coatRoughness), t.sheen && (i.sheenNode = t.sheen), t.sheenRoughness && (i.sheenRoughnessNode = t.sheenRoughness), t.transmission && (i.transmissionNode = t.transmission));
4069
4123
  }
4070
- function Gi(e, t, n) {
4071
- let { bundle: r, uniforms: i } = Li(e, t, n), { type: a, settings: o } = Mi(e), s = Ui(a, o);
4072
- return Wi(s, r, a), {
4124
+ function $i(e, t, n) {
4125
+ let { bundle: r, uniforms: i } = Gi(e, t, n), { type: a, settings: o } = Bi(e), s = Zi(a, o);
4126
+ return Qi(s, r, a), {
4073
4127
  material: s,
4074
4128
  uniforms: i
4075
4129
  };
4076
4130
  }
4077
- function Ki(e, t, n, r, i) {
4131
+ function ea(e, t, n, r, i) {
4078
4132
  let a = {};
4079
- for (let o of Q(e, i).inputs) {
4133
+ for (let o of Y(e, i).inputs) {
4080
4134
  let s = t.edges.find((t) => t.toNode === e.id && t.toInput === o.key);
4081
- a[o.key] = s ? qi(s, o.kind, n, r, i) : void 0;
4135
+ a[o.key] = s ? ta(s, o.kind, n, r, i) : void 0;
4082
4136
  }
4083
4137
  return a;
4084
4138
  }
4085
- function qi(e, t, n, r, i) {
4139
+ function ta(e, t, n, r, i) {
4086
4140
  let a = n.get(e.fromNode)?.[e.fromOutput];
4087
4141
  if (a === void 0) return;
4088
- let o = r.get(e.fromNode), s = o ? Q(o, i).outputs.find((t) => t.key === e.fromOutput)?.kind : void 0;
4142
+ let o = r.get(e.fromNode), s = o ? Y(o, i).outputs.find((t) => t.key === e.fromOutput)?.kind : void 0;
4089
4143
  if (s && s !== t) {
4090
- let e = qe(s, t);
4091
- e && (a = Ji(a, e));
4144
+ let e = $e(s, t);
4145
+ e && (a = na(a, e));
4092
4146
  }
4093
4147
  return a;
4094
4148
  }
4095
- function Ji(e, t) {
4149
+ function na(e, t) {
4096
4150
  switch (t) {
4097
4151
  case "float-to-vector":
4098
- case "float-to-color": return K(e);
4152
+ case "float-to-color": return G(e);
4099
4153
  case "vector-to-float": return e.x.add(e.y).add(e.z).div(3);
4100
- case "color-to-float": return de(e);
4154
+ case "color-to-float": return he(e);
4101
4155
  case "identity":
4102
4156
  case "vector-to-color":
4103
4157
  case "color-to-vector": return e;
4104
4158
  }
4105
4159
  }
4106
- function Yi(t, n) {
4160
+ function ra(t, n) {
4107
4161
  let r = {};
4108
4162
  for (let i of t.params) {
4109
4163
  let t = n.params[i.key] ?? i.default;
4110
- if (i.type === "color") r[i.key] = U(new e.Color(t));
4164
+ if (i.type === "color") r[i.key] = Ie(new e.Color(t));
4111
4165
  else if (i.type === "vec3") {
4112
4166
  let n = t ?? {
4113
4167
  x: 0,
4114
4168
  y: 0,
4115
4169
  z: 0
4116
4170
  };
4117
- r[i.key] = U(new e.Vector3(n.x, n.y, n.z));
4171
+ r[i.key] = Ie(new e.Vector3(n.x, n.y, n.z));
4118
4172
  } else if (i.type === "float" || i.type === "int") {
4119
4173
  let e = Number(t);
4120
- r[i.key] = U(Number.isFinite(e) ? e : Number(i.default) || 0);
4121
- } else i.type === "curve" && (r[i.key] = Me(Le(t), "float"));
4174
+ r[i.key] = Ie(Number.isFinite(e) ? e : Number(i.default) || 0);
4175
+ } else i.type === "curve" && (r[i.key] = Le(He(t), "float"));
4122
4176
  }
4123
4177
  return r;
4124
4178
  }
4125
- function Xi(e, t, n) {
4126
- let r = e.nodes.find((e) => e.type === q);
4179
+ function ia(e, t, n) {
4180
+ let r = e.nodes.find((e) => e.type === Ye);
4127
4181
  if (!r) return {};
4128
4182
  let i = e.edges.find((e) => e.toNode === r.id && e.toInput === "surface");
4129
- return i ? qi(i, "shader", n, new Map(e.nodes.map((e) => [e.id, e])), t) ?? {} : {};
4183
+ return i ? ta(i, "shader", n, new Map(e.nodes.map((e) => [e.id, e])), t) ?? {} : {};
4130
4184
  }
4131
- function Zi(e) {
4185
+ function aa(e) {
4132
4186
  let t = /* @__PURE__ */ new Map();
4133
4187
  for (let n of e.nodes) t.set(n.id, 0);
4134
4188
  let n = /* @__PURE__ */ new Map();
@@ -4145,18 +4199,18 @@ function Zi(e) {
4145
4199
  if (i.length !== e.nodes.length) throw Error("Material graph has a cycle");
4146
4200
  return i;
4147
4201
  }
4148
- function Qi(e, t, n = !1) {
4149
- let r = n ? Ue : q, i = e.nodes.filter((e) => e.type === r);
4202
+ function oa(e, t, n = !1) {
4203
+ let r = n ? Je : Ye, i = e.nodes.filter((e) => e.type === r);
4150
4204
  if (i.length !== 1) throw Error(`Expected exactly one ${r} node, found ${i.length}`);
4151
4205
  let a = new Map(e.nodes.map((e) => [e.id, e])), o = /* @__PURE__ */ new Set();
4152
4206
  for (let n of e.edges) {
4153
4207
  let e = a.get(n.fromNode), r = a.get(n.toNode);
4154
4208
  if (!e) throw Error(`Edge from unknown node '${n.fromNode}'`);
4155
4209
  if (!r) throw Error(`Edge to unknown node '${n.toNode}'`);
4156
- let i = Q(e, t).outputs.find((e) => e.key === n.fromOutput), s = Q(r, t).inputs.find((e) => e.key === n.toInput);
4210
+ let i = Y(e, t).outputs.find((e) => e.key === n.fromOutput), s = Y(r, t).inputs.find((e) => e.key === n.toInput);
4157
4211
  if (!i) throw Error(`Node '${e.type}' has no output '${n.fromOutput}'`);
4158
4212
  if (!s) throw Error(`Node '${r.type}' has no input '${n.toInput}'`);
4159
- if (i.kind !== s.kind && !qe(i.kind, s.kind)) throw Error(`Type mismatch (no coercion): ${e.type}.${n.fromOutput} (${i.kind}) -> ${r.type}.${n.toInput} (${s.kind})`);
4213
+ if (i.kind !== s.kind && !$e(i.kind, s.kind)) throw Error(`Type mismatch (no coercion): ${e.type}.${n.fromOutput} (${i.kind}) -> ${r.type}.${n.toInput} (${s.kind})`);
4160
4214
  let c = `${n.toNode}/${n.toInput}`;
4161
4215
  if (o.has(c)) throw Error(`Multiple connections into ${r.type}.${n.toInput}`);
4162
4216
  o.add(c);
@@ -4164,54 +4218,54 @@ function Qi(e, t, n = !1) {
4164
4218
  }
4165
4219
  //#endregion
4166
4220
  //#region src/document.ts
4167
- var $i = 4;
4168
- function ea(e) {
4221
+ var sa = 4;
4222
+ function ca(e) {
4169
4223
  return structuredClone(e);
4170
4224
  }
4171
- function ta() {
4172
- return ea(Pe);
4225
+ function la() {
4226
+ return ca(ze);
4173
4227
  }
4174
- function na(e) {
4175
- for (let t of e.nodes) t.type === "principled-bsdf" && (t.type = We, t.params = {
4228
+ function ua(e) {
4229
+ for (let t of e.nodes) t.type === "principled-bsdf" && (t.type = Xe, t.params = {
4176
4230
  ...t.params,
4177
4231
  materialType: "physical"
4178
- }), t.subgraph && na(t.subgraph);
4232
+ }), t.subgraph && ua(t.subgraph);
4179
4233
  }
4180
- var ra = new Set([
4234
+ var da = new Set([
4181
4235
  "curl",
4182
4236
  "paper",
4183
4237
  "wool",
4184
4238
  "stone",
4185
4239
  "erosion"
4186
4240
  ]);
4187
- function ia(e) {
4188
- for (let t of e.nodes) t.type === "tileable-noise" && ra.has(t.params.noiseType) && (t.params = {
4241
+ function fa(e) {
4242
+ for (let t of e.nodes) t.type === "tileable-noise" && da.has(t.params.noiseType) && (t.params = {
4189
4243
  ...t.params,
4190
4244
  preset: t.params.noiseType,
4191
4245
  noiseType: "perlin-fbm"
4192
- }), t.subgraph && ia(t.subgraph);
4246
+ }), t.subgraph && fa(t.subgraph);
4193
4247
  }
4194
- function aa(e) {
4195
- let t = ea(e);
4196
- return (e.version ?? 0) < 3 && na(t), (e.version ?? 0) < 4 && ia(t), t.version = 4, t;
4248
+ function pa(e) {
4249
+ let t = ca(e);
4250
+ return (e.version ?? 0) < 3 && ua(t), (e.version ?? 0) < 4 && fa(t), t.version = 4, t;
4197
4251
  }
4198
- function oa(e, t) {
4252
+ function ma(e, t) {
4199
4253
  return e.nodes.find((e) => e.id === t);
4200
4254
  }
4201
- function sa(e, t) {
4255
+ function ha(e, t) {
4202
4256
  return e.find((e) => e.key === t);
4203
4257
  }
4204
- function ca(e) {
4258
+ function ga(e) {
4205
4259
  return e.structural ? "structural" : e.type === "float" || e.type === "color" || e.type === "vec3" || e.type === "curve" ? "param" : "structural";
4206
4260
  }
4207
- var la = class {
4261
+ var _a = class {
4208
4262
  registry;
4209
4263
  doc;
4210
4264
  listeners = /* @__PURE__ */ new Set();
4211
4265
  lastError_ = null;
4212
4266
  soloNode_ = null;
4213
- constructor(e = ta(), t = Si) {
4214
- this.registry = t, this.doc = aa(e), this.validate(this.doc);
4267
+ constructor(e = la(), t = Ai) {
4268
+ this.registry = t, this.doc = pa(e), this.validate(this.doc);
4215
4269
  }
4216
4270
  get document() {
4217
4271
  return this.doc;
@@ -4227,7 +4281,7 @@ var la = class {
4227
4281
  }
4228
4282
  compileBundle(e) {
4229
4283
  try {
4230
- let t = Li(this.doc, this.registry, e);
4284
+ let t = Gi(this.doc, this.registry, e);
4231
4285
  return this.lastError_ = null, t;
4232
4286
  } catch (e) {
4233
4287
  throw this.lastError_ = e instanceof Error ? e.message : String(e), e;
@@ -4237,17 +4291,17 @@ var la = class {
4237
4291
  return this.listeners.add(e), () => this.listeners.delete(e);
4238
4292
  }
4239
4293
  setDocument(e) {
4240
- let t = aa(e);
4294
+ let t = pa(e);
4241
4295
  this.validate(t), this.doc = t, this.emit({ kind: "structural" });
4242
4296
  }
4243
4297
  getDocument() {
4244
- return ea(this.doc);
4298
+ return ca(this.doc);
4245
4299
  }
4246
4300
  setSoloNode(e) {
4247
4301
  e !== this.soloNode_ && (this.soloNode_ = e, this.emit({ kind: "structural" }));
4248
4302
  }
4249
4303
  setOutputResolution(e) {
4250
- let t = this.doc.nodes.find((e) => e.type === q);
4304
+ let t = this.doc.nodes.find((e) => e.type === Ye);
4251
4305
  if (!t) return;
4252
4306
  let n = String(e);
4253
4307
  t.params.outputResolution !== n && (t.params.outputResolution = n, this.emit({ kind: "structural" }));
@@ -4256,10 +4310,10 @@ var la = class {
4256
4310
  this.setOutputResolution(e.resolution ?? e.size ?? 1024);
4257
4311
  }
4258
4312
  setNodeParam(e, t, n) {
4259
- let r = oa(this.doc, e);
4313
+ let r = ma(this.doc, e);
4260
4314
  if (!r) return !1;
4261
- let i = this.registry.get(r.type), a = sa(yi(r, this.registry), t) ?? sa(i.params, t);
4262
- return a ? Object.is(r.params[t], n) ? !0 : (r.params[t] = n, ca(a) === "param" ? this.emit({
4315
+ let i = this.registry.get(r.type), a = ha(Di(r, this.registry), t) ?? ha(i.params, t);
4316
+ return a ? Object.is(r.params[t], n) ? !0 : (r.params[t] = n, ga(a) === "param" ? this.emit({
4263
4317
  kind: "param",
4264
4318
  nodeId: e,
4265
4319
  key: t,
@@ -4274,83 +4328,284 @@ var la = class {
4274
4328
  return n;
4275
4329
  }
4276
4330
  validate(e) {
4277
- Li(e, this.registry, { backend: "live" }), this.lastError_ = null;
4331
+ Gi(e, this.registry, { backend: "live" }), this.lastError_ = null;
4278
4332
  }
4279
4333
  emit(e) {
4280
4334
  for (let t of this.listeners) t(e);
4281
4335
  }
4282
- }, ua = [
4336
+ }, va = [
4283
4337
  "roughness",
4284
4338
  "metallic",
4285
4339
  "ambientOcclusion"
4286
- ], da = ["baseColor", "emission"];
4287
- function fa(e, t) {
4288
- return ua.includes(t) ? K(e) : da.includes(t) ? Ce(e) : e;
4289
- }
4290
- var $ = 2, pa = new p(new o()), ma = new o();
4291
- function ha(e, t, n) {
4292
- let r = ($ - 1) / 2, i = K(0, 0, 0);
4293
- for (let a = 0; a < $; a++) for (let o = 0; o < $; o++) {
4294
- let s = G(o - r, a - r).mul(t), c = V(e, W().add(s)).xyz;
4340
+ ], ya = ["baseColor", "emission"];
4341
+ function ba(e, t) {
4342
+ return va.includes(t) ? G(e) : ya.includes(t) ? De(e) : e;
4343
+ }
4344
+ var X = 2, xa = new _(new u());
4345
+ function Sa(e, t, n) {
4346
+ let r = (X - 1) / 2, i = G(0, 0, 0);
4347
+ for (let a = 0; a < X; a++) for (let o = 0; o < X; o++) {
4348
+ let s = W(o - r, a - r).mul(t), c = V(e, U().add(s)).xyz;
4295
4349
  n && (c = c.mul(2).sub(1)), i = i.add(c);
4296
4350
  }
4297
- return i = i.div($ * $), n ? ge(i).mul(.5).add(.5) : i;
4351
+ return i = i.div(X * X), n ? be(i).mul(.5).add(.5) : i;
4298
4352
  }
4299
- var ga = /* @__PURE__ */ new Map();
4300
- function _a(e, r) {
4301
- let a = `${e}x${r}`, s = ga.get(a);
4302
- if (s) return s;
4303
- let c = new m(e, r, {
4353
+ var Ca = /* @__PURE__ */ new Map();
4354
+ function wa() {
4355
+ return [...Ca.keys()];
4356
+ }
4357
+ function Ta(e, t) {
4358
+ let n = `${e}x${t}`, a = Ca.get(n);
4359
+ if (a) return a;
4360
+ let o = new v(e, t, {
4304
4361
  depthBuffer: !1,
4305
4362
  stencilBuffer: !1
4306
4363
  });
4307
- c.texture.colorSpace = n, c.texture.minFilter = c.texture.magFilter = t, c.texture.wrapS = c.texture.wrapT = i;
4308
- let l = G(1 / e, 1 / r), u = (e) => {
4309
- let t = new o();
4310
- return t.colorNode = ha(c.texture, l, e), new p(t);
4364
+ o.texture.colorSpace = i, o.texture.minFilter = o.texture.magFilter = r, o.texture.wrapS = o.texture.wrapT = s;
4365
+ let c = W(1 / e, 1 / t), l = (e) => {
4366
+ let t = new u();
4367
+ return t.colorNode = Sa(o.texture, c, e), new _(t);
4311
4368
  }, d = {
4312
- ssRT: c,
4313
- downColorQuad: u(!1),
4314
- downNormalQuad: u(!0)
4369
+ ssRT: o,
4370
+ downColorQuad: l(!1),
4371
+ downNormalQuad: l(!0)
4315
4372
  };
4316
- return ga.set(a, d), d;
4373
+ return Ca.set(n, d), d;
4374
+ }
4375
+ function Ea() {
4376
+ return new u();
4317
4377
  }
4318
- function va() {
4319
- return new o();
4378
+ function Da(e, r) {
4379
+ e.colorSpace = r !== "height" && ya.includes(r) ? c : i, e.wrapS = e.wrapT = s, e.generateMipmaps = !0, e.minFilter = n, e.magFilter = t, e.anisotropy = 8;
4320
4380
  }
4321
- var ya = new a(), ba = new r(-1, 1, 1, -1, 0, 1), xa = [];
4322
- async function Sa(e, t, n) {
4323
- for (; xa.length < t.length;) xa.push(new p());
4324
- ya.clear();
4325
- for (let e = 0; e < t.length; e++) xa[e].material = t[e], ya.add(xa[e]);
4381
+ var Oa = new l(), ka = new a(-1, 1, 1, -1, 0, 1), Aa = [];
4382
+ async function ja(e, t, n) {
4383
+ for (; Aa.length < t.length;) Aa.push(new _());
4384
+ Oa.clear();
4385
+ for (let e = 0; e < t.length; e++) Aa[e].material = t[e], Oa.add(Aa[e]);
4326
4386
  let r = e.getRenderTarget();
4327
- e.setRenderTarget(_a(n * $, n * $).ssRT), await e.compileAsync(ya, ba), e.setRenderTarget(r);
4387
+ e.setRenderTarget(Ta(n * X, n * X).ssRT), await e.compileAsync(Oa, ka), e.setRenderTarget(r);
4328
4388
  }
4329
- function Ca(e, t, n) {
4330
- pa.material = t;
4389
+ function Ma(e, t, n) {
4390
+ xa.material = t;
4331
4391
  let r = e.getRenderTarget();
4332
- e.setRenderTarget(n), pa.render(e), e.setRenderTarget(r);
4392
+ e.setRenderTarget(n), xa.render(e), e.setRenderTarget(r);
4333
4393
  }
4334
- function wa(e, t, n, r = !1) {
4335
- let { ssRT: i, downColorQuad: a, downNormalQuad: o } = _a(n.width * $, n.height * $);
4336
- pa.material = t;
4394
+ function Na(e, t, n, r = !1) {
4395
+ let { ssRT: i, downColorQuad: a, downNormalQuad: o } = Ta(n.width * X, n.height * X);
4396
+ xa.material = t;
4337
4397
  let s = e.getRenderTarget();
4338
- e.setRenderTarget(i), pa.render(e), e.setRenderTarget(n), (r ? o : a).render(e), e.setRenderTarget(s);
4398
+ e.setRenderTarget(i), xa.render(e), e.setRenderTarget(n), (r ? o : a).render(e), e.setRenderTarget(s);
4339
4399
  }
4340
- function Ta(e, t, n, r = !1) {
4341
- ma.colorNode = t, ma.needsUpdate = !0, wa(e, ma, n, r);
4400
+ function Pa(e, t, n, r = !1) {
4401
+ let i = new u();
4402
+ i.colorNode = t, i.needsUpdate = !0, Na(e, i, n, r), i.dispose();
4403
+ }
4404
+ //#endregion
4405
+ //#region src/graph/texture-transfer.ts
4406
+ function Fa(e) {
4407
+ return e * e * 4;
4408
+ }
4409
+ function Ia(e) {
4410
+ return Math.ceil(e * 4 / 256) * 256;
4411
+ }
4412
+ function La(e, t, n) {
4413
+ let r = t * 4, i = r * n;
4414
+ if (e.length === i) return e;
4415
+ let a = Ia(t), o = new Uint8Array(i);
4416
+ for (let t = 0; t < n; t++) {
4417
+ let n = t * a;
4418
+ o.set(e.subarray(n, n + r), t * r);
4419
+ }
4420
+ return o;
4421
+ }
4422
+ function Ra(e, t, n) {
4423
+ let r = new Uint8Array(t * n * 4);
4424
+ return za(e, r, t, n), r;
4425
+ }
4426
+ function za(e, t, n, r) {
4427
+ let i = n * 4;
4428
+ for (let n = 0; n < r; n++) {
4429
+ let a = (r - 1 - n) * i;
4430
+ t.set(e.subarray(a, a + i), n * i);
4431
+ }
4432
+ }
4433
+ async function Ba(e, t) {
4434
+ let { width: n, height: r } = t;
4435
+ return Ra(La(await e.readRenderTargetPixelsAsync(t, 0, 0, n, r), n, r), n, r);
4436
+ }
4437
+ var Va = /* @__PURE__ */ new Map();
4438
+ function Ha(t, n) {
4439
+ let r = `${t}|${n || "none"}`, i = Va.get(r);
4440
+ if (i) return i;
4441
+ let a = new e.DataTexture(new Uint8Array(Fa(t)), t, t, e.RGBAFormat, e.UnsignedByteType);
4442
+ return a.colorSpace = n, a.minFilter = a.magFilter = e.NearestFilter, a.generateMipmaps = !1, a.flipY = !1, a.needsUpdate = !0, Va.set(r, a), a;
4443
+ }
4444
+ function Ua() {
4445
+ return [...Va.keys()];
4446
+ }
4447
+ function Wa() {
4448
+ for (let e of Va.values()) e.dispose();
4449
+ Va.clear();
4450
+ }
4451
+ function Ga(t, n, r) {
4452
+ let i = Ra(t, n, n), a = new e.DataTexture(i, n, n, e.RGBAFormat, e.UnsignedByteType);
4453
+ return Da(a, r), a.flipY = !1, a.needsUpdate = !0, a;
4454
+ }
4455
+ function Ka(e, t, n) {
4456
+ let { width: r, height: i } = t;
4457
+ if (n.length !== r * i * 4) throw Error(`texel length ${n.length} does not match target ${r}x${i} (expected ${r * i * 4})`);
4458
+ e.initRenderTarget(t);
4459
+ let a = Ha(r, t.texture.colorSpace);
4460
+ za(n, a.image.data, r, i), a.needsUpdate = !0, e.copyTextureToTexture(a, t.texture);
4461
+ }
4462
+ //#endregion
4463
+ //#region src/version.ts
4464
+ var qa = "0.1.5";
4465
+ //#endregion
4466
+ //#region src/topology.ts
4467
+ function Ja(e) {
4468
+ return Z(e);
4469
+ }
4470
+ function Z(e) {
4471
+ return Array.isArray(e) ? `[${e.map(Z).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => `${e}:${Z(t)}`).join(",")}}` : JSON.stringify(e);
4472
+ }
4473
+ function Ya(e, t) {
4474
+ let n = t.get(e.type), r = n.paramsFor ? n.paramsFor(e.params) : n.params, i = {};
4475
+ for (let t of r) (t.type === "int" || t.type === "bool" || t.type === "select" || t.bakeStructural) && (i[t.key] = e.params[t.key]);
4476
+ return i;
4477
+ }
4478
+ function Xa(e, t) {
4479
+ return {
4480
+ id: e.id,
4481
+ type: e.type,
4482
+ enabled: e.enabled,
4483
+ ports: Y(e, t),
4484
+ params: Ya(e, t),
4485
+ subgraph: e.subgraph ? Za(e.subgraph, t) : null
4486
+ };
4487
+ }
4488
+ function Za(e, t) {
4489
+ return {
4490
+ version: e.version,
4491
+ nodes: e.nodes.map((e) => Xa(e, t)).sort((e, t) => String(e.id).localeCompare(String(t.id))),
4492
+ edges: [...e.edges].sort((e, t) => Z(e).localeCompare(Z(t)))
4493
+ };
4494
+ }
4495
+ function Qa(e, t) {
4496
+ return Z(Za(e, t));
4497
+ }
4498
+ function $a(e) {
4499
+ let t = typeof e == "number" ? e : Number(e);
4500
+ if (!Number.isFinite(t)) return typeof e == "number" ? "nan" : `raw:${String(e)}`;
4501
+ let n = Number(t.toPrecision(9));
4502
+ return Object.is(n, -0) ? "0" : String(n);
4503
+ }
4504
+ function eo(e) {
4505
+ if (typeof e == "number") return `#${(e >>> 0 & 16777215).toString(16).padStart(6, "0")}`;
4506
+ if (typeof e == "string") {
4507
+ let t = e.trim().toLowerCase();
4508
+ return /^#[0-9a-f]{3}$/.test(t) ? `#${t[1]}${t[1]}${t[2]}${t[2]}${t[3]}${t[3]}` : t;
4509
+ }
4510
+ if (e && typeof e == "object") {
4511
+ let t = e;
4512
+ if (typeof t.r == "number") return `rgb(${$a(t.r)},${$a(t.g)},${$a(t.b)})`;
4513
+ }
4514
+ return Z(e);
4515
+ }
4516
+ function to(e, t) {
4517
+ switch (t.type) {
4518
+ case "float":
4519
+ case "int": return $a(e);
4520
+ case "bool": return (typeof e == "string" ? e.trim().toLowerCase() === "true" : e) ? "true" : "false";
4521
+ case "color": return eo(e);
4522
+ case "select": return String(e);
4523
+ case "vec3": {
4524
+ let t = e ?? {};
4525
+ return `(${$a(t.x)},${$a(t.y)},${$a(t.z)})`;
4526
+ }
4527
+ case "curve": return `[${He(e).map($a).join(",")}]`;
4528
+ default: return Z(e);
4529
+ }
4530
+ }
4531
+ function no(e, t) {
4532
+ if (!t.has(e.type)) return `${e.id}!${Z(e.params)}`;
4533
+ let n = t.get(e.type).params, r = [];
4534
+ for (let t of n) {
4535
+ let n = e.params[t.key] === void 0 ? t.default : e.params[t.key];
4536
+ r.push(`${t.key}=${to(n, t)}`);
4537
+ }
4538
+ let i = new Set(n.map((e) => e.key)), a = Object.keys(e.params).filter((e) => !i.has(e)).sort();
4539
+ for (let t of a) r.push(`${t}~${Z(e.params[t])}`);
4540
+ return `${e.id}{${r.join(",")}}`;
4541
+ }
4542
+ function ro(e, t) {
4543
+ return [...e.nodes].sort((e, t) => e.id.localeCompare(t.id)).map((e) => {
4544
+ let n = no(e, t);
4545
+ return e.subgraph ? `${n}/[${ro(e.subgraph, t)}]` : n;
4546
+ }).join(";");
4547
+ }
4548
+ //#endregion
4549
+ //#region src/cache/key.ts
4550
+ var io = 1, ao = 1, oo = `mdbc1.1.4.${qa}`, so = oo;
4551
+ function co(e) {
4552
+ let t = 3421674724, n = 2216829733;
4553
+ for (let r = 0; r < e.length; r++) {
4554
+ n = (n ^ e.charCodeAt(r) & 255) >>> 0;
4555
+ let i = n & 65535, a = n >>> 16, o = t & 65535, s = t >>> 16, c = i * 435, l = a * 435 + (c >>> 16), u = o * 435 + i * 256 + (l >>> 16), d = s * 435 + a * 256 + (u >>> 16);
4556
+ n = ((l & 65535) << 16 | c & 65535) >>> 0, t = ((d & 65535) << 16 | u & 65535) >>> 0;
4557
+ }
4558
+ return t.toString(16).padStart(8, "0") + n.toString(16).padStart(8, "0");
4559
+ }
4560
+ function lo(e) {
4561
+ let { document: t, registry: n, size: r, channels: i, backend: a = "webgpu", namespace: s = "" } = e, c = [
4562
+ oo,
4563
+ `three:${o}`,
4564
+ `backend:${a}`,
4565
+ `ns:${s}`,
4566
+ `size:${r}`,
4567
+ `ch:${[...i].sort().join(",")}`,
4568
+ `topo:${Qa(t, n)}`,
4569
+ `params:${ro(t, n)}`
4570
+ ].join("\n");
4571
+ return {
4572
+ id: `${oo}-${co(c)}-${c.length.toString(36)}`,
4573
+ key: c
4574
+ };
4575
+ }
4576
+ //#endregion
4577
+ //#region src/graph/node-profiler.ts
4578
+ function uo(e, t, n) {
4579
+ let r = n && n.length ? new Set(n) : null;
4580
+ return e.nodes.filter((e) => {
4581
+ if (e.enabled === !1 || r && !r.has(e.id)) return !1;
4582
+ let n = t.has(e.type) ? t.get(e.type) : null;
4583
+ return n ? n.nodeClass !== "shader" && n.nodeClass !== "output" : !1;
4584
+ });
4585
+ }
4586
+ function fo(e) {
4587
+ if (!e.length) return 0;
4588
+ let t = [...e].sort((e, t) => e - t), n = t.length >> 1;
4589
+ return t.length % 2 ? t[n] : (t[n - 1] + t[n]) / 2;
4590
+ }
4591
+ function po(e, t, n) {
4592
+ let r = new Map(e.map((e) => [e.nodeId, e]));
4593
+ for (let i of e) {
4594
+ let e = t.edges.filter((e) => e.toNode === i.nodeId).map((e) => r.get(e.fromNode)?.renderMs).filter((e) => e !== void 0), a = e.length ? Math.max(...e) : n;
4595
+ i.marginalMs = Math.max(0, i.renderMs - a);
4596
+ }
4342
4597
  }
4343
4598
  //#endregion
4344
4599
  //#region src/graph/bake-service.ts
4345
- var Ea = 1024, Da = 8, Oa = 4096;
4346
- function ka(e, t) {
4600
+ var mo = 1024, ho = 4096;
4601
+ function go(e, t) {
4347
4602
  let n = t?.size ?? Math.max(e, t?.minSize ?? 0);
4348
- return Math.min(n, Oa);
4603
+ return Math.min(n, ho);
4349
4604
  }
4350
- function Aa(e) {
4605
+ function _o(e) {
4351
4606
  return e?.minSize != null;
4352
4607
  }
4353
- var ja = typeof navigator < "u" && /chrome|chromium|crios|edg\//i.test(navigator.userAgent) && !/firefox|fxios/i.test(navigator.userAgent), Ma = [
4608
+ var vo = typeof navigator < "u" && /chrome|chromium|crios|edg\//i.test(navigator.userAgent) && !/firefox|fxios/i.test(navigator.userAgent), yo = [
4354
4609
  "baseColor",
4355
4610
  "roughness",
4356
4611
  "metallic",
@@ -4358,22 +4613,22 @@ var ja = typeof navigator < "u" && /chrome|chromium|crios|edg\//i.test(navigator
4358
4613
  "normal",
4359
4614
  "emission"
4360
4615
  ];
4361
- function Na(t, n) {
4362
- let r = new m(n, n, {
4616
+ function bo(e, t) {
4617
+ let n = new v(t, t, {
4363
4618
  depthBuffer: !1,
4364
4619
  stencilBuffer: !1
4365
- }), i = r.texture;
4366
- return i.colorSpace = t !== "height" && da.includes(t) ? e.SRGBColorSpace : e.NoColorSpace, i.wrapS = i.wrapT = e.RepeatWrapping, i.generateMipmaps = !0, i.minFilter = e.LinearMipmapLinearFilter, i.magFilter = e.LinearFilter, i.anisotropy = Da, r;
4620
+ });
4621
+ return Da(n.texture, e), n;
4367
4622
  }
4368
- function Pa(t, n = !1) {
4369
- let r = new m(t, t, {
4623
+ function xo(t, n = !1) {
4624
+ let r = new v(t, t, {
4370
4625
  type: e.HalfFloatType,
4371
4626
  depthBuffer: !1,
4372
4627
  stencilBuffer: !1
4373
4628
  }), i = r.texture;
4374
4629
  return i.colorSpace = e.NoColorSpace, i.wrapS = i.wrapT = e.RepeatWrapping, i.generateMipmaps = n, i.minFilter = n ? e.LinearMipmapLinearFilter : e.LinearFilter, i.magFilter = e.LinearFilter, r;
4375
4630
  }
4376
- var Fa = class {
4631
+ var So = class {
4377
4632
  channels;
4378
4633
  targets = /* @__PURE__ */ new Map();
4379
4634
  mats = /* @__PURE__ */ new Map();
@@ -4387,32 +4642,36 @@ var Fa = class {
4387
4642
  hasHeight = !1;
4388
4643
  present = /* @__PURE__ */ new Set();
4389
4644
  signature = "";
4645
+ restored = !1;
4646
+ contentStamp = 0;
4647
+ lastRebuildMs = 0;
4648
+ disposed = !1;
4390
4649
  size;
4391
4650
  constructor(e, t) {
4392
4651
  this.channels = t, this.size = e;
4393
4652
  }
4394
4653
  resize(e) {
4395
4654
  if (e !== this.size) {
4396
- this.size = e;
4655
+ this.size = e, this.restored = !1, this.contentStamp += 1;
4397
4656
  for (let t of this.targets.values()) t.setSize(e, e), t.texture.needsUpdate = !0;
4398
4657
  this.heightTarget && (this.heightTarget.setSize(e, e), this.heightTarget.texture.needsUpdate = !0), this.flushCaches();
4399
4658
  }
4400
4659
  }
4401
4660
  target(e) {
4402
4661
  let t = this.targets.get(e);
4403
- return t || (t = Na(e, this.size), this.targets.set(e, t)), t;
4662
+ return t || (t = bo(e, this.size), this.targets.set(e, t)), t;
4404
4663
  }
4405
4664
  channelMaterial(e) {
4406
4665
  let t = this.mats.get(e);
4407
- return t || (t = va(), this.mats.set(e, t)), t;
4666
+ return t || (t = Ea(), this.mats.set(e, t)), t;
4408
4667
  }
4409
4668
  cacheTarget(e, t = this.size, n = !1) {
4410
4669
  let r = this.cacheTargets.get(e);
4411
- return r && r.texture.generateMipmaps !== n && (r.dispose(), this.cacheTargets.delete(e), r = void 0), r ? (r.width !== t || r.height !== t) && r.setSize(t, t) : (r = Pa(t, n), this.cacheTargets.set(e, r)), r;
4670
+ return r && r.texture.generateMipmaps !== n && (r.dispose(), this.cacheTargets.delete(e), r = void 0), r ? (r.width !== t || r.height !== t) && r.setSize(t, t) : (r = xo(t, n), this.cacheTargets.set(e, r)), r;
4412
4671
  }
4413
4672
  cacheMaterial(e) {
4414
4673
  let t = this.cacheMats.get(e);
4415
- return t || (t = va(), this.cacheMats.set(e, t)), t;
4674
+ return t || (t = Ea(), this.cacheMats.set(e, t)), t;
4416
4675
  }
4417
4676
  cacheTexture(e, t, n = !1) {
4418
4677
  return this.cacheTarget(e, t, n).texture;
@@ -4426,11 +4685,15 @@ var Fa = class {
4426
4685
  return this.heightTarget;
4427
4686
  }
4428
4687
  ensureHeightTarget() {
4429
- return this.heightTarget ||= Na("height", this.size), this.heightTarget;
4688
+ return this.heightTarget ||= bo("height", this.size), this.heightTarget;
4430
4689
  }
4431
4690
  texture(e) {
4432
4691
  return this.targets.get(e)?.texture ?? null;
4433
4692
  }
4693
+ setPresence(e, t) {
4694
+ let n = [...e].sort().join(",") + (t ? "|h" : ""), r = n !== this.signature;
4695
+ return this.present = e, this.hasHeight = t, this.signature = n, r;
4696
+ }
4434
4697
  allocConstantArray(t, n, r, i) {
4435
4698
  let a = `${t}/${n}`, o = this.constArrays.get(a);
4436
4699
  if (o && o.length === r.length && o.elementType === i) {
@@ -4448,15 +4711,27 @@ var Fa = class {
4448
4711
  if (i === "vec3") {
4449
4712
  let t = [];
4450
4713
  for (let n = 0; n < r.length; n += 3) t.push(new e.Vector3(r[n], r[n + 1], r[n + 2]));
4451
- s = Me(t);
4452
- } else s = Me(Array.from(r), "float");
4714
+ s = Le(t);
4715
+ } else s = Le(Array.from(r), "float");
4453
4716
  return this.constArrays.set(a, {
4454
4717
  node: s,
4455
4718
  length: r.length,
4456
4719
  elementType: i
4457
4720
  }), s;
4458
4721
  }
4722
+ debugCounts() {
4723
+ return {
4724
+ channelTargets: this.targets.size,
4725
+ channelMats: this.mats.size,
4726
+ cacheTargets: this.cacheTargets.size,
4727
+ cacheMats: this.cacheMats.size,
4728
+ constArrays: this.constArrays.size,
4729
+ heightTarget: +!!this.heightTarget,
4730
+ restored: +!!this.restored
4731
+ };
4732
+ }
4459
4733
  flushCaches() {
4734
+ this.restored = !1;
4460
4735
  for (let e of this.mats.values()) e.dispose();
4461
4736
  this.mats.clear();
4462
4737
  for (let e of this.cacheTargets.values()) e.dispose();
@@ -4465,6 +4740,7 @@ var Fa = class {
4465
4740
  this.cacheMats.clear(), this.cachePlan = [], this.uniforms = /* @__PURE__ */ new Map(), this.paramUsage = /* @__PURE__ */ new Map(), this.constArrays.clear();
4466
4741
  }
4467
4742
  dispose() {
4743
+ this.disposed = !0, this.restored = !1;
4468
4744
  for (let e of this.targets.values()) e.dispose();
4469
4745
  this.targets.clear();
4470
4746
  for (let e of this.mats.values()) e.dispose();
@@ -4474,7 +4750,7 @@ var Fa = class {
4474
4750
  for (let e of this.cacheMats.values()) e.dispose();
4475
4751
  this.cacheMats.clear(), this.cachePlan = [], this.uniforms = /* @__PURE__ */ new Map(), this.paramUsage = /* @__PURE__ */ new Map(), this.constArrays.clear(), this.heightTarget?.dispose(), this.heightTarget = null;
4476
4752
  }
4477
- }, Ia = class {
4753
+ }, Co = class {
4478
4754
  renderer = null;
4479
4755
  compileGateDepth = 0;
4480
4756
  get rendererBusy() {
@@ -4491,6 +4767,9 @@ var Fa = class {
4491
4767
  scratchSize = 0;
4492
4768
  scratchCaches = /* @__PURE__ */ new Map();
4493
4769
  scratchCacheSize = 0;
4770
+ cache_ = null;
4771
+ pendingWrites = /* @__PURE__ */ new Map();
4772
+ pendingStores = /* @__PURE__ */ new Set();
4494
4773
  attachRenderer(e) {
4495
4774
  this.renderer = e;
4496
4775
  }
@@ -4526,80 +4805,80 @@ var Fa = class {
4526
4805
  });
4527
4806
  return this.queue = n.then(() => void 0, () => void 0), n;
4528
4807
  }
4529
- createTextureSet(e = Ma, t = Ea) {
4530
- return new Fa(t, e);
4808
+ createTextureSet(e = yo, t = mo) {
4809
+ return new So(t, e);
4531
4810
  }
4532
4811
  bakeInto(e, t, n = {}) {
4533
4812
  return this.enqueue(n.label ?? "surface", async () => {
4534
4813
  let r = this.renderer;
4535
4814
  if (!r) return !1;
4536
- let i = performance.now(), { bundle: a, uniforms: o, cachePlan: s, paramUsage: c } = t.compileBundle({
4815
+ let i = await this.tryRestoreFromCache(r, e, t, n);
4816
+ if (i) return i.changed;
4817
+ let a = performance.now(), { bundle: o, uniforms: s, cachePlan: c, paramUsage: l } = t.compileBundle({
4537
4818
  backend: "offline",
4538
4819
  soloNodeId: n.soloNodeId,
4539
- allocCache: (t, n, r) => e.cacheTexture(t, ka(e.size, r), Aa(r)),
4820
+ allocCache: (t, n, r) => e.cacheTexture(t, go(e.size, r), _o(r)),
4540
4821
  allocConstantArray: (t, n, r, i) => e.allocConstantArray(t, n, r, i)
4541
- }), l = performance.now() - i, u = Ii(t.document);
4542
- e.uniforms = o, e.paramUsage = c, e.cachePlan = s, n.soloNodeId || e.pruneCaches(new Set(s.map((e) => e.cacheId)));
4543
- let d = n.channels ?? e.channels, f = /* @__PURE__ */ new Set(), p = [];
4544
- for (let t of d) {
4545
- let n = a[t];
4822
+ }), u = performance.now() - a, d = Wi(t.document);
4823
+ e.uniforms = s, e.paramUsage = l, e.cachePlan = c, n.soloNodeId || e.pruneCaches(new Set(c.map((e) => e.cacheId)));
4824
+ let f = n.channels ?? e.channels, p = /* @__PURE__ */ new Set(), m = [];
4825
+ for (let t of f) {
4826
+ let n = o[t];
4546
4827
  if (!n) continue;
4547
4828
  let r = e.channelMaterial(t);
4548
- r.colorNode = fa(n, t), r.needsUpdate = !0, p.push({
4829
+ r.colorNode = ba(n, t), r.needsUpdate = !0, m.push({
4549
4830
  mat: r,
4550
4831
  target: e.target(t),
4551
4832
  isNormal: t === "normal"
4552
- }), f.add(t);
4833
+ }), p.add(t);
4553
4834
  }
4554
- if (e.hasHeight = a.height !== void 0, e.hasHeight) {
4835
+ if (e.hasHeight = o.height !== void 0, e.hasHeight) {
4555
4836
  let t = e.channelMaterial("height");
4556
- t.colorNode = K(a.height), t.needsUpdate = !0, p.push({
4837
+ t.colorNode = G(o.height), t.needsUpdate = !0, m.push({
4557
4838
  mat: t,
4558
4839
  target: e.ensureHeightTarget(),
4559
4840
  isNormal: !1
4560
4841
  });
4561
4842
  }
4562
- let m = {
4843
+ let h = {
4563
4844
  runId: ++this.bakeRunId,
4564
4845
  source: n.source,
4565
4846
  phase: "nodes",
4566
- nodeCount: u,
4567
- compileMs: l,
4568
- texturesTotal: p.length,
4847
+ nodeCount: d,
4848
+ compileMs: u,
4849
+ texturesTotal: m.length,
4569
4850
  totalMs: 0
4570
4851
  };
4571
- this.emitReport(m);
4572
- for (let t of s) {
4852
+ this.emitReport(h);
4853
+ for (let t of c) {
4573
4854
  let n = e.cacheMaterial(t.cacheId);
4574
- n.colorNode = t.colorNode, n.needsUpdate = !0, Ca(r, n, e.cacheTarget(t.cacheId, ka(e.size, t.sizing), Aa(t.sizing)));
4855
+ n.colorNode = t.colorNode, n.needsUpdate = !0, Ma(r, n, e.cacheTarget(t.cacheId, go(e.size, t.sizing), _o(t.sizing)));
4575
4856
  }
4576
- let h = 0;
4577
- if (ja) {
4857
+ let g = 0;
4858
+ if (vo) {
4578
4859
  this.emitReport({
4579
- ...m,
4860
+ ...h,
4580
4861
  phase: "shaders"
4581
4862
  });
4582
4863
  let t = performance.now();
4583
4864
  this.compileGateDepth += 1;
4584
4865
  try {
4585
- await Sa(r, p.map((e) => e.mat), e.size);
4866
+ await ja(r, m.map((e) => e.mat), e.size);
4586
4867
  } finally {
4587
4868
  --this.compileGateDepth;
4588
4869
  }
4589
- h = performance.now() - t;
4870
+ g = performance.now() - t;
4590
4871
  }
4591
- let g = performance.now();
4592
- for (let e of p) wa(r, e.mat, e.target, e.isNormal);
4593
- let _ = performance.now() - g, v = [...f].sort().join(",") + (e.hasHeight ? "|h" : ""), y = v !== e.signature;
4594
- e.present = f, e.signature = v;
4595
- let b = performance.now();
4596
- await this.gpuSync(e);
4597
- let x = performance.now() - b, S = l + h + _ + x;
4872
+ let _ = performance.now();
4873
+ for (let e of m) Na(r, e.mat, e.target, e.isNormal);
4874
+ let v = performance.now() - _, y = e.setPresence(p, e.hasHeight), b = performance.now();
4875
+ await this.gpuSync(e.firstTarget());
4876
+ let x = performance.now() - b, S = u + g + v + x;
4598
4877
  return this.emitReport({
4599
- ...m,
4878
+ ...h,
4600
4879
  phase: "done",
4601
4880
  totalMs: S
4602
- }), console.log(`[bake-prof] rebuild compile=${l.toFixed(1)} precompile=${h.toFixed(1)} dispatch=${_.toFixed(1)} gpuWait=${x.toFixed(1)} total=${S.toFixed(1)}ms`), y;
4881
+ }), console.log(`[bake-prof] rebuild compile=${u.toFixed(1)} precompile=${g.toFixed(1)} dispatch=${v.toFixed(1)} gpuWait=${x.toFixed(1)} total=${S.toFixed(1)}ms`), e.restored = !1, e.contentStamp += 1, e.lastRebuildMs = S, this.scheduleCacheWrite(e, t, n), y;
4603
4882
  });
4604
4883
  }
4605
4884
  async gpuSync(e) {
@@ -4610,13 +4889,12 @@ var Fa = class {
4610
4889
  await n.onSubmittedWorkDone();
4611
4890
  return;
4612
4891
  }
4613
- let r = e.firstTarget();
4614
- r && await t.readRenderTargetPixelsAsync(r, 0, 0, 1, 1);
4892
+ e && await t.readRenderTargetPixelsAsync(e, 0, 0, 1, 1);
4615
4893
  }
4616
4894
  rerenderInto(e, t) {
4617
4895
  let n = this.queue.then(async () => {
4618
4896
  let n = this.renderer;
4619
- if (!n) return;
4897
+ if (!n || e.restored) return;
4620
4898
  let r = e.present.size + (e.hasHeight && e.heightTarget ? 1 : 0), i = {
4621
4899
  runId: ++this.bakeRunId,
4622
4900
  source: t,
@@ -4628,17 +4906,17 @@ var Fa = class {
4628
4906
  };
4629
4907
  this.emitReport(i);
4630
4908
  let a = performance.now();
4631
- for (let t of e.cachePlan) Ca(n, e.cacheMaterial(t.cacheId), e.cacheTarget(t.cacheId, ka(e.size, t.sizing), Aa(t.sizing)));
4632
- for (let t of e.present) wa(n, e.channelMaterial(t), e.target(t), t === "normal");
4633
- e.hasHeight && e.heightTarget && wa(n, e.channelMaterial("height"), e.heightTarget, !1);
4909
+ for (let t of e.cachePlan) Ma(n, e.cacheMaterial(t.cacheId), e.cacheTarget(t.cacheId, go(e.size, t.sizing), _o(t.sizing)));
4910
+ for (let t of e.present) Na(n, e.channelMaterial(t), e.target(t), t === "normal");
4911
+ e.hasHeight && e.heightTarget && Na(n, e.channelMaterial("height"), e.heightTarget, !1);
4634
4912
  let o = performance.now() - a, s = performance.now();
4635
- await this.gpuSync(e);
4913
+ await this.gpuSync(e.firstTarget());
4636
4914
  let c = performance.now() - s;
4637
4915
  this.emitReport({
4638
4916
  ...i,
4639
4917
  phase: "done",
4640
4918
  totalMs: o + c
4641
- }), console.log(`[bake-prof] rerender dispatch=${o.toFixed(1)} gpuWait=${c.toFixed(1)}ms`);
4919
+ }), console.log(`[bake-prof] rerender dispatch=${o.toFixed(1)} gpuWait=${c.toFixed(1)}ms`), e.contentStamp += 1;
4642
4920
  });
4643
4921
  return this.queue = n.then(() => void 0, () => void 0), n;
4644
4922
  }
@@ -4652,17 +4930,17 @@ var Fa = class {
4652
4930
  if (!r) return null;
4653
4931
  let { bundle: i, cachePlan: a } = e.compileBundle({
4654
4932
  backend: "offline",
4655
- allocCache: (e, t, r) => this.scratchCache(e, n, ka(n, r), Aa(r)).rt.texture
4933
+ allocCache: (e, t, r) => this.scratchCache(e, n, go(n, r), _o(r)).rt.texture
4656
4934
  }), o = i[t];
4657
4935
  if (!o) return null;
4658
4936
  let s = new Set(a.map((e) => e.cacheId));
4659
4937
  for (let [e, t] of this.scratchCaches) s.has(e) || (t.rt.dispose(), t.mat.dispose(), this.scratchCaches.delete(e));
4660
4938
  for (let e of a) {
4661
- let t = this.scratchCache(e.cacheId, n, ka(n, e.sizing), Aa(e.sizing));
4662
- t.mat.colorNode = e.colorNode, t.mat.needsUpdate = !0, Ca(r, t.mat, t.rt);
4939
+ let t = this.scratchCache(e.cacheId, n, go(n, e.sizing), _o(e.sizing));
4940
+ t.mat.colorNode = e.colorNode, t.mat.needsUpdate = !0, Ma(r, t.mat, t.rt);
4663
4941
  }
4664
4942
  let c = this.scratchTarget(n);
4665
- Ta(r, fa(o, t), c, t === "normal");
4943
+ Pa(r, ba(o, t), c, t === "normal");
4666
4944
  let l = await r.readRenderTargetPixelsAsync(c, 0, 0, n, n), u = new Uint8ClampedArray(n * n * 4), d = n * 4;
4667
4945
  for (let e = 0; e < n; e++) {
4668
4946
  let t = (n - 1 - e) * d;
@@ -4671,12 +4949,200 @@ var Fa = class {
4671
4949
  return new ImageData(u, n, n);
4672
4950
  });
4673
4951
  }
4952
+ gpuInfo() {
4953
+ let e = this.renderer?.info;
4954
+ return {
4955
+ rendererTextures: e?.memory?.textures ?? -1,
4956
+ rendererGeometries: e?.memory?.geometries ?? -1,
4957
+ scratchTarget: this.scratch ? `${this.scratchSize}px` : "none",
4958
+ scratchCaches: this.scratchCaches.size,
4959
+ ssPool: wa(),
4960
+ transferPool: Ua(),
4961
+ cache: this.cache_ ? this.cache_.info() : "off"
4962
+ };
4963
+ }
4964
+ setCache(e) {
4965
+ this.cache_ = e;
4966
+ }
4967
+ get cache() {
4968
+ return this.cache_;
4969
+ }
4970
+ cacheMetrics() {
4971
+ return this.cache_ ? this.cache_.metrics() : Promise.resolve(null);
4972
+ }
4973
+ cacheKeyFor(e, t, n = yo) {
4974
+ return lo({
4975
+ document: e.document,
4976
+ registry: e.getRegistry(),
4977
+ size: t,
4978
+ channels: n,
4979
+ namespace: this.cache_?.namespace
4980
+ });
4981
+ }
4982
+ async tryRestoreFromCache(e, t, n, r) {
4983
+ let i = this.cache_;
4984
+ if (!i?.enabled || r.bypassCache || r.soloNodeId) return null;
4985
+ try {
4986
+ let a = performance.now(), o = this.cacheKeyFor(n, t.size, r.channels ?? t.channels), s = await i.read(o);
4987
+ if (!s) return null;
4988
+ let c = Fa(t.size), l = new Set(r.channels ?? t.channels);
4989
+ if (!(s.size === t.size && s.textures.length > 0 && s.textures.every((e) => (e.channel === "height" || l.has(e.channel)) && e.bytes.length === c))) return await i.delete(o), null;
4990
+ t.flushCaches();
4991
+ let u = /* @__PURE__ */ new Set(), d = !1;
4992
+ for (let n of s.textures) {
4993
+ if (n.channel === "height") {
4994
+ Ka(e, t.ensureHeightTarget(), n.bytes), d = !0;
4995
+ continue;
4996
+ }
4997
+ Ka(e, t.target(n.channel), n.bytes), u.add(n.channel);
4998
+ }
4999
+ let f = {
5000
+ runId: ++this.bakeRunId,
5001
+ source: r.source,
5002
+ phase: "restore",
5003
+ nodeCount: 0,
5004
+ compileMs: 0,
5005
+ texturesTotal: s.textures.length,
5006
+ totalMs: 0
5007
+ };
5008
+ this.emitReport(f);
5009
+ let p = t.setPresence(u, d);
5010
+ t.restored = !0, t.contentStamp += 1, await this.gpuSync(t.firstTarget());
5011
+ let m = performance.now() - a;
5012
+ return this.emitReport({
5013
+ ...f,
5014
+ phase: "done",
5015
+ totalMs: m
5016
+ }), console.log(`[bake-prof] restore channels=${s.textures.length} bytes=${s.bytes} savedBake=${s.bakeMs.toFixed(0)}ms total=${m.toFixed(1)}ms`), { changed: p };
5017
+ } catch (e) {
5018
+ return console.warn("[bake] cache restore failed, baking instead:", e), null;
5019
+ }
5020
+ }
5021
+ scheduleCacheWrite(e, t, n = {}) {
5022
+ let r = this.cache_;
5023
+ if (!r?.enabled || n.soloNodeId || !this.renderer || e.disposed) return;
5024
+ let i = this.pendingWrites.get(e);
5025
+ i && clearTimeout(i.timer);
5026
+ let a = {
5027
+ set: e,
5028
+ graph: t,
5029
+ opts: n,
5030
+ stamp: e.contentStamp,
5031
+ timer: setTimeout(() => {
5032
+ this.pendingWrites.delete(e);
5033
+ let t = this.queue.then(() => this.runCacheWrite(a));
5034
+ this.queue = t.then(() => void 0, () => void 0);
5035
+ }, r.writeDelayMs)
5036
+ };
5037
+ this.pendingWrites.set(e, a);
5038
+ }
5039
+ async flushCacheWrites() {
5040
+ let e = [...this.pendingWrites.values()];
5041
+ this.pendingWrites.clear();
5042
+ for (let t of e) {
5043
+ clearTimeout(t.timer);
5044
+ let e = this.queue.then(() => this.runCacheWrite(t));
5045
+ this.queue = e.then(() => void 0, () => void 0);
5046
+ }
5047
+ await this.queue, await Promise.all([...this.pendingStores]);
5048
+ }
5049
+ async runCacheWrite(e) {
5050
+ let { set: t, graph: n, opts: r, stamp: i } = e, a = this.cache_, o = this.renderer;
5051
+ if (!(!a?.enabled || !o || t.disposed) && t.contentStamp === i && !t.restored) try {
5052
+ let e = (r.channels ?? t.channels).filter((e) => t.present.has(e)), s = t.hasHeight && t.heightTarget !== null, c = e.length + +!!s;
5053
+ if (c === 0) return;
5054
+ let l = Fa(t.size) * c;
5055
+ if (!a.canWrite(t.lastRebuildMs, l)) return;
5056
+ let u = this.cacheKeyFor(n, t.size, r.channels ?? t.channels);
5057
+ if (await a.peek(u)) return;
5058
+ let d = [];
5059
+ for (let n of e) if (d.push({
5060
+ channel: n,
5061
+ encoding: "rgba8",
5062
+ bytes: await Ba(o, t.target(n))
5063
+ }), t.contentStamp !== i || t.disposed) return;
5064
+ if (s && d.push({
5065
+ channel: "height",
5066
+ encoding: "rgba8",
5067
+ bytes: await Ba(o, t.heightTarget)
5068
+ }), t.contentStamp !== i || t.disposed) return;
5069
+ let f = a.write(u, {
5070
+ size: t.size,
5071
+ channels: e,
5072
+ hasHeight: s,
5073
+ bakeMs: t.lastRebuildMs,
5074
+ textures: d
5075
+ }).catch((e) => {
5076
+ console.warn("[bake] cache write failed:", e);
5077
+ });
5078
+ this.pendingStores.add(f), f.finally(() => this.pendingStores.delete(f));
5079
+ } catch (e) {
5080
+ console.warn("[bake] cache write failed:", e);
5081
+ }
5082
+ }
4674
5083
  scratchTarget(e) {
4675
- return (!this.scratch || this.scratchSize !== e) && (this.scratch?.dispose(), this.scratch = new m(e, e, {
5084
+ return (!this.scratch || this.scratchSize !== e) && (this.scratch?.dispose(), this.scratch = new v(e, e, {
4676
5085
  depthBuffer: !1,
4677
5086
  stencilBuffer: !1
4678
5087
  }), this.scratchSize = e), this.scratch;
4679
5088
  }
5089
+ profileNodes(e, t = {}) {
5090
+ let n = Math.max(64, Math.min(2048, t.size ?? 512)), r = Math.max(1, Math.min(32, t.runs ?? 6));
5091
+ return this.enqueue("profile", async () => {
5092
+ let i = this.renderer, a = {
5093
+ size: n,
5094
+ runs: r,
5095
+ overheadMs: 0,
5096
+ nodes: []
5097
+ };
5098
+ if (!i) return a;
5099
+ let o = this.scratchTarget(n), s = e.document, c = async (e) => {
5100
+ let t = performance.now();
5101
+ Ma(i, e, o), await this.gpuSync(o);
5102
+ let n = performance.now() - t, a = [];
5103
+ for (let t = 0; t < r; t++) {
5104
+ let t = performance.now();
5105
+ Ma(i, e, o), await this.gpuSync(o), a.push(performance.now() - t);
5106
+ }
5107
+ return {
5108
+ pipelineMs: n,
5109
+ renderMs: fo(a)
5110
+ };
5111
+ }, l = Ea();
5112
+ l.colorNode = G(.5, .5, .5), l.needsUpdate = !0, a.overheadMs = (await c(l)).renderMs, l.dispose();
5113
+ for (let n of uo(s, e.getRegistry(), t.nodeIds)) {
5114
+ let t = {
5115
+ nodeId: n.id,
5116
+ type: n.type,
5117
+ label: n.label,
5118
+ pipelineMs: 0,
5119
+ renderMs: 0,
5120
+ marginalMs: 0
5121
+ };
5122
+ a.nodes.push(t);
5123
+ let r;
5124
+ try {
5125
+ let { bundle: t } = e.compileBundle({
5126
+ backend: "offline",
5127
+ soloNodeId: n.id
5128
+ });
5129
+ r = t.baseColor;
5130
+ } catch (e) {
5131
+ t.error = e instanceof Error ? e.message : String(e);
5132
+ continue;
5133
+ }
5134
+ if (!r) {
5135
+ t.error = "no solo output";
5136
+ continue;
5137
+ }
5138
+ let i = Ea();
5139
+ i.colorNode = r, i.needsUpdate = !0;
5140
+ let o = await c(i);
5141
+ i.dispose(), t.pipelineMs = o.pipelineMs, t.renderMs = o.renderMs;
5142
+ }
5143
+ return po(a.nodes, s, a.overheadMs), a.nodes.sort((e, t) => t.renderMs - e.renderMs), a;
5144
+ });
5145
+ }
4680
5146
  scratchCache(e, t, n, r = !1) {
4681
5147
  if (this.scratchCacheSize !== t) {
4682
5148
  for (let e of this.scratchCaches.values()) e.rt.dispose(), e.mat.dispose();
@@ -4684,39 +5150,39 @@ var Fa = class {
4684
5150
  }
4685
5151
  let i = this.scratchCaches.get(e);
4686
5152
  return i && i.rt.texture.generateMipmaps !== r && (i.rt.dispose(), i.mat.dispose(), this.scratchCaches.delete(e), i = void 0), i ? (i.rt.width !== n || i.rt.height !== n) && i.rt.setSize(n, n) : (i = {
4687
- rt: Pa(n, r),
4688
- mat: va()
5153
+ rt: xo(n, r),
5154
+ mat: Ea()
4689
5155
  }, this.scratchCaches.set(e, i)), i;
4690
5156
  }
4691
- }, La = new Ia();
5157
+ }, wo = new Co();
4692
5158
  //#endregion
4693
5159
  //#region src/tsl/triplanar.ts
4694
- function Ra(e) {
4695
- let t = L(he.abs(), e);
4696
- return t.div(t.dot(K(1, 1, 1)).max(1e-4));
5160
+ function To(e) {
5161
+ let t = L(ye.abs(), e);
5162
+ return t.div(t.dot(G(1, 1, 1)).max(1e-4));
4697
5163
  }
4698
- function za(e, t, n) {
4699
- return h(() => {
4700
- let r = ye.mul(t), i = Ra(n), a = V(e, r.yz).mul(i.x), o = V(e, r.zx).mul(i.y), s = V(e, r.xy).mul(i.z);
5164
+ function Eo(e, t, n) {
5165
+ return y(() => {
5166
+ let r = Ce.mul(t), i = To(n), a = V(e, r.yz).mul(i.x), o = V(e, r.zx).mul(i.y), s = V(e, r.xy).mul(i.z);
4701
5167
  return a.add(o).add(s);
4702
5168
  })();
4703
5169
  }
4704
5170
  //#endregion
4705
5171
  //#region src/tsl/triplanar-normal.ts
4706
- function Ba(e, t, n) {
4707
- return h(() => {
4708
- let r = ye.mul(t), i = Ra(n), a = he.sign(), o = V(e, r.yz).xyz.mul(2).sub(1), s = V(e, r.zx).xyz.mul(2).sub(1), c = V(e, r.xy).xyz.mul(2).sub(1), l = K(o.x, o.y, o.z.mul(a.x)), u = K(s.x, s.y, s.z.mul(a.y)), d = K(c.x, c.y, c.z.mul(a.z));
5172
+ function Do(e, t, n) {
5173
+ return y(() => {
5174
+ let r = Ce.mul(t), i = To(n), a = ye.sign(), o = V(e, r.yz).xyz.mul(2).sub(1), s = V(e, r.zx).xyz.mul(2).sub(1), c = V(e, r.xy).xyz.mul(2).sub(1), l = G(o.x, o.y, o.z.mul(a.x)), u = G(s.x, s.y, s.z.mul(a.y)), d = G(c.x, c.y, c.z.mul(a.z));
4709
5175
  return l.zxy.mul(i.x).add(u.yzx.mul(i.y)).add(d.xyz.mul(i.z)).normalize();
4710
5176
  })();
4711
5177
  }
4712
5178
  //#endregion
4713
5179
  //#region src/tsl/parallax.ts
4714
- var Va = .3;
4715
- function Ha(e, t, n, r) {
4716
- return h(() => {
4717
- let i = _e.normalize(), a = (t) => V(e, t).x, o = 1 / r, s = i.xy.div(i.z.abs().max(Va)).mul(n).mul(o), c = t.toVar(), l = x(!1).toVar(), u = t, d = k(1).sub(a(u));
5180
+ var Oo = .3;
5181
+ function ko(e, t, n, r) {
5182
+ return y(() => {
5183
+ let i = xe.normalize(), a = (t) => V(e, t).x, o = 1 / r, s = i.xy.div(i.z.abs().max(Oo)).mul(n).mul(o), c = t.toVar(), l = ee(!1).toVar(), u = t, d = k(1).sub(a(u));
4718
5184
  for (let e = 0; e < r; e++) {
4719
- let t = u.sub(s), n = k(1).sub(a(t)), r = (e + 1) * o, i = k(r).greaterThanEqual(n), f = n.sub(r), p = d.sub(e * o), m = we(f.div(f.sub(p).max(1e-5))), h = F(t, u, m);
5185
+ let t = u.sub(s), n = k(1).sub(a(t)), r = (e + 1) * o, i = k(r).greaterThanEqual(n), f = n.sub(r), p = d.sub(e * o), m = Oe(f.div(f.sub(p).max(1e-5))), h = F(t, u, m);
4720
5186
  c.assign(R(l.not().and(i), h, c)), l.assign(l.or(i)), u = t, d = n;
4721
5187
  }
4722
5188
  return c;
@@ -4724,8 +5190,8 @@ function Ha(e, t, n, r) {
4724
5190
  }
4725
5191
  //#endregion
4726
5192
  //#region src/graph/textured-surface.ts
4727
- var Ua = 12;
4728
- function Wa(e, t) {
5193
+ var Ao = 12;
5194
+ function jo(e, t) {
4729
5195
  return [
4730
5196
  e,
4731
5197
  t.shininess,
@@ -4734,21 +5200,18 @@ function Wa(e, t) {
4734
5200
  t.matcap
4735
5201
  ].join("|");
4736
5202
  }
4737
- var Ga = class {
5203
+ var Mo = class {
4738
5204
  graph;
4739
5205
  service;
4740
5206
  source;
4741
- offlineMat = Ui();
5207
+ offlineMat = Zi();
4742
5208
  matType = "physical";
4743
5209
  matSig = "";
4744
5210
  liveUniforms = /* @__PURE__ */ new Map();
4745
5211
  material_;
4746
- scaleUniform = U(1.2);
4747
- sharpnessUniform = U(8);
4748
- roughnessFactor = U(1);
4749
- metalnessFactor = U(1);
4750
- colorTint = U(new e.Color(1, 1, 1));
4751
- parallaxScale = U(0);
5212
+ scaleUniform = Ie(1.2);
5213
+ sharpnessUniform = Ie(8);
5214
+ parallaxScale = Ie(0);
4752
5215
  lastBakeMs = 0;
4753
5216
  set;
4754
5217
  backend = "offline";
@@ -4759,13 +5222,14 @@ var Ga = class {
4759
5222
  updateInFlight = !1;
4760
5223
  pendingKind = "none";
4761
5224
  flushRequested = !1;
5225
+ bypassCacheOnce = !1;
4762
5226
  listeners = /* @__PURE__ */ new Set();
4763
5227
  textureListeners = /* @__PURE__ */ new Set();
4764
5228
  lastError_ = null;
4765
5229
  processingDepth = 0;
4766
5230
  idleWaiters = [];
4767
5231
  constructor(e, t, n) {
4768
- this.graph = e, this.service = t, this.source = n, this.set = t.createTextureSet(Ma, this.surfaceBakeSize()), this.material_ = this.buildLive(), this.graph.onChange((e) => this.onGraphChange(e));
5232
+ this.graph = e, this.service = t, this.source = n, this.set = t.createTextureSet(yo, this.surfaceBakeSize()), this.material_ = this.buildLive(), this.graph.onChange((e) => this.onGraphChange(e));
4769
5233
  }
4770
5234
  get material() {
4771
5235
  return this.material_;
@@ -4820,7 +5284,14 @@ var Ga = class {
4820
5284
  await this.whenIdle(), this.set.flushCaches();
4821
5285
  }
4822
5286
  regenerate() {
4823
- this.flushRequested = !0, this.requestUpdate("rebuild");
5287
+ this.flushRequested = !0, this.bypassCacheOnce = !0, this.requestUpdate("rebuild");
5288
+ }
5289
+ debugReport() {
5290
+ return {
5291
+ busy: this.busy,
5292
+ backend: this.backend,
5293
+ set: this.set.debugCounts()
5294
+ };
4824
5295
  }
4825
5296
  setScale(e) {
4826
5297
  this.scaleUniform.value = e;
@@ -4828,15 +5299,6 @@ var Ga = class {
4828
5299
  setSharpness(e) {
4829
5300
  this.sharpnessUniform.value = e;
4830
5301
  }
4831
- setRoughnessFactor(e) {
4832
- this.roughnessFactor.value = e;
4833
- }
4834
- setMetalnessFactor(e) {
4835
- this.metalnessFactor.value = e;
4836
- }
4837
- setColorTint(e) {
4838
- this.colorTint.value.set(e);
4839
- }
4840
5302
  setParallaxScale(e) {
4841
5303
  let t = this.parallaxScale.value > 0;
4842
5304
  this.parallaxScale.value = e, e > 0 !== t && this.wire(this.lastPresent);
@@ -4877,7 +5339,7 @@ var Ga = class {
4877
5339
  let e = n.value;
4878
5340
  t.value.set(e.x, e.y, e.z);
4879
5341
  } else if (n.paramType === "curve") {
4880
- let e = Le(n.value), r = t.array;
5342
+ let e = He(n.value), r = t.array;
4881
5343
  for (let t = 0; t < e.length; t++) r[t] = e[t];
4882
5344
  } else t.value = Number(n.value);
4883
5345
  }
@@ -4910,7 +5372,7 @@ var Ga = class {
4910
5372
  if (!(this.backend !== "offline" || !this.service.hasRenderer)) {
4911
5373
  this.enterProcessing();
4912
5374
  try {
4913
- await this.service.rerenderInto(this.set, this.source), this.lastError_ = this.graph.lastError, this.notifyTexturesUpdated();
5375
+ await this.service.rerenderInto(this.set, this.source), this.lastError_ = this.graph.lastError, this.notifyTexturesUpdated(), this.service.scheduleCacheWrite(this.set, this.graph, { source: this.source });
4914
5376
  } catch (e) {
4915
5377
  this.lastError_ = e instanceof Error ? e.message : String(e), console.warn("[textured-surface] re-render failed:", this.lastError_);
4916
5378
  } finally {
@@ -4919,7 +5381,10 @@ var Ga = class {
4919
5381
  }
4920
5382
  }
4921
5383
  surfaceBakeSize() {
4922
- return Math.max(64, Math.round(ji(this.graph.document) / 64) * 64);
5384
+ return Math.max(64, Math.round(zi(this.graph.document) / 64) * 64);
5385
+ }
5386
+ get bakeSize() {
5387
+ return this.surfaceBakeSize();
4923
5388
  }
4924
5389
  async rebuild() {
4925
5390
  this.enterProcessing();
@@ -4929,14 +5394,17 @@ var Ga = class {
4929
5394
  if (this.backend === "offline" && this.service.hasRenderer) {
4930
5395
  let e = this.surfaceBakeSize();
4931
5396
  this.flushRequested && (this.flushRequested = !1, this.set.flushCaches()), this.set.resize(e);
4932
- let { type: n, settings: r } = Mi(this.graph.document), i = Wa(n, r), a = i !== this.matSig;
4933
- a && (t = this.offlineMat, this.offlineMat = Ui(n, r), this.matType = n, this.matSig = i);
4934
- let o = this.graph.soloNode ?? void 0, s = performance.now(), c = await this.service.bakeInto(this.set, this.graph, {
5397
+ let { type: n, settings: r } = Bi(this.graph.document), i = jo(n, r), a = i !== this.matSig;
5398
+ a && (t = this.offlineMat, this.offlineMat = Zi(n, r), this.matType = n, this.matSig = i);
5399
+ let o = this.graph.soloNode ?? void 0, s = this.bypassCacheOnce;
5400
+ this.bypassCacheOnce = !1;
5401
+ let c = performance.now(), l = await this.service.bakeInto(this.set, this.graph, {
4935
5402
  soloNodeId: o,
4936
5403
  label: "surface",
4937
- source: this.source
5404
+ source: this.source,
5405
+ bypassCache: s
4938
5406
  });
4939
- this.lastBakeMs = performance.now() - s, (c || !this.wiredOnce || a) && (this.wire(this.set.present), this.wiredOnce = !0), this.material_ = this.offlineMat;
5407
+ this.lastBakeMs = performance.now() - c, (l || !this.wiredOnce || a) && (this.wire(this.set.present), this.wiredOnce = !0), this.material_ = this.offlineMat;
4940
5408
  } else this.material_ = this.buildLive();
4941
5409
  this.lastError_ = this.graph.lastError;
4942
5410
  } catch (e) {
@@ -4948,7 +5416,7 @@ var Ga = class {
4948
5416
  }
4949
5417
  }
4950
5418
  buildLive() {
4951
- let e = this.graph.soloNode ?? void 0, { material: t, uniforms: n } = Gi(this.graph.document, this.graph.getRegistry(), {
5419
+ let e = this.graph.soloNode ?? void 0, { material: t, uniforms: n } = $i(this.graph.document, this.graph.getRegistry(), {
4952
5420
  backend: "live",
4953
5421
  soloNodeId: e
4954
5422
  });
@@ -4956,13 +5424,13 @@ var Ga = class {
4956
5424
  }
4957
5425
  wire(e) {
4958
5426
  this.lastPresent = e;
4959
- let t = this.offlineMat, n = ze[this.matType], r = this.scaleUniform, i = this.sharpnessUniform, a = this.set.hasHeight && !this.triplanar && this.parallaxScale.value > 0, o = W(), s = a ? Ha(this.set.heightTarget.texture, o, this.parallaxScale, Ua) : void 0, c = o.dFdx(), l = o.dFdy(), u = (e) => a ? V(e, s).grad(c, l) : V(e), d = (e) => this.triplanar ? za(this.set.texture(e), r, i) : u(this.set.texture(e)), f = e.has("normal") ? this.triplanar ? Ba(this.set.texture("normal"), r, i) : me(u(this.set.texture("normal")).xyz, k(1)) : he;
5427
+ let t = this.offlineMat, n = We[this.matType], r = this.scaleUniform, i = this.sharpnessUniform, a = this.set.hasHeight && !this.triplanar && this.parallaxScale.value > 0, o = U(), s = a ? ko(this.set.heightTarget.texture, o, this.parallaxScale, Ao) : void 0, c = o.dFdx(), l = o.dFdy(), u = (e) => a ? V(e, s).grad(c, l) : V(e), d = (e) => this.triplanar ? Eo(this.set.texture(e), r, i) : u(this.set.texture(e)), f = e.has("normal") ? this.triplanar ? Do(this.set.texture("normal"), r, i) : ve(u(this.set.texture("normal")).xyz, k(1)) : ye;
4960
5428
  if (this.debugNormals) {
4961
- t.colorNode = K(0, 0, 0), t.emissiveNode = f.normalize().mul(.5).add(.5), t.roughnessNode = t.metalnessNode = t.aoNode = t.normalNode = null, t.needsUpdate = !0;
5429
+ t.colorNode = G(0, 0, 0), t.emissiveNode = f.normalize().mul(.5).add(.5), t.roughnessNode = t.metalnessNode = t.aoNode = t.normalNode = null, t.needsUpdate = !0;
4962
5430
  return;
4963
5431
  }
4964
- if (t.colorNode = e.has("baseColor") ? d("baseColor").mul(this.colorTint) : null, t.normalNode = e.has("normal") ? f : null, n.roughMetal && (t.roughnessNode = e.has("roughness") ? d("roughness").r.mul(this.roughnessFactor) : null, t.metalnessNode = e.has("metallic") ? d("metallic").r.mul(this.metalnessFactor) : null), n.ao) {
4965
- let n = b("vertexAo", "float");
5432
+ if (t.colorNode = e.has("baseColor") ? d("baseColor") : null, t.normalNode = e.has("normal") ? f : null, n.roughMetal && (t.roughnessNode = e.has("roughness") ? d("roughness").r : null, t.metalnessNode = e.has("metallic") ? d("metallic").r : null), n.ao) {
5433
+ let n = w("vertexAo", "float");
4966
5434
  t.aoNode = e.has("ambientOcclusion") ? d("ambientOcclusion").r.mul(n) : n;
4967
5435
  }
4968
5436
  n.emissive && (t.emissiveNode = e.has("emission") ? d("emission") : null), t.needsUpdate = !0;
@@ -4973,7 +5441,7 @@ var Ga = class {
4973
5441
  };
4974
5442
  //#endregion
4975
5443
  //#region src/graph/mesh-material.ts
4976
- function Ka(t) {
5444
+ function No(t) {
4977
5445
  let n = { side: e.DoubleSide };
4978
5446
  switch (t) {
4979
5447
  case "standard": return new e.MeshStandardMaterial(n);
@@ -4984,8 +5452,8 @@ function Ka(t) {
4984
5452
  default: return new e.MeshPhysicalMaterial(n);
4985
5453
  }
4986
5454
  }
4987
- function qa(e, t) {
4988
- let n = Ni(e), r = ze[n.type], i = Ka(n.type), a = i, o = (e) => t.get(e), s = o("baseColor");
5455
+ function Po(e, t) {
5456
+ let n = Vi(e), r = We[n.type], i = No(n.type), a = i, o = (e) => t.get(e), s = o("baseColor");
4989
5457
  s ? (a.map = s, a.color.set(16777215)) : a.color.set(n.baseColor);
4990
5458
  let c = o("normal");
4991
5459
  if (c && (a.normalMap = c), n.alpha < 1 && (a.transparent = !0, a.opacity = n.alpha), r.ao) {
@@ -5002,22 +5470,639 @@ function qa(e, t) {
5002
5470
  let t = o("metallic");
5003
5471
  t ? (a.metalnessMap = t, a.metalness = 1) : a.metalness = n.metallic;
5004
5472
  }
5005
- return r.physicalLobes && (a.ior = n.ior, a.clearcoat = n.coat, a.clearcoatRoughness = n.coatRoughness, a.sheen = n.sheen, n.sheen > 0 && a.sheenColor.set(16777215), a.sheenRoughness = n.sheenRoughness, a.transmission = n.transmission), n.type === "phong" && (a.shininess = n.shininess, a.specular.set(n.specular)), n.type === "toon" && (a.gradientMap = wi(n.gradientSteps)), n.type === "matcap" && (a.matcap = Ti(n.matcap)), i;
5473
+ return r.physicalLobes && (a.ior = n.ior, a.clearcoat = n.coat, a.clearcoatRoughness = n.coatRoughness, a.sheen = n.sheen, n.sheen > 0 && a.sheenColor.set(16777215), a.sheenRoughness = n.sheenRoughness, a.transmission = n.transmission), n.type === "phong" && (a.shininess = n.shininess, a.specular.set(n.specular)), n.type === "toon" && (a.gradientMap = Mi(n.gradientSteps)), n.type === "matcap" && (a.matcap = Ni(n.matcap)), i;
5474
+ }
5475
+ //#endregion
5476
+ //#region src/cache/codec.ts
5477
+ function Fo() {
5478
+ return typeof OffscreenCanvas < "u" && typeof createImageBitmap < "u" && typeof ImageData < "u";
5479
+ }
5480
+ function Io(e) {
5481
+ let t = new OffscreenCanvas(e, e).getContext("2d", {
5482
+ colorSpace: "srgb",
5483
+ willReadFrequently: !0
5484
+ });
5485
+ if (!t) throw Error("OffscreenCanvas 2D context unavailable");
5486
+ return t;
5487
+ }
5488
+ async function Lo(e, t) {
5489
+ let n = new Uint8ClampedArray(e.length);
5490
+ n.set(e);
5491
+ for (let e = 3; e < n.length; e += 4) n[e] = 255;
5492
+ let r = Io(t);
5493
+ r.putImageData(new ImageData(n, t, t, { colorSpace: "srgb" }), 0, 0);
5494
+ let i = await r.canvas.convertToBlob({ type: "image/png" });
5495
+ return new Uint8Array(await i.arrayBuffer());
5496
+ }
5497
+ async function Ro(e, t) {
5498
+ let n = new Blob([e], { type: "image/png" }), r = await createImageBitmap(n, {
5499
+ premultiplyAlpha: "none",
5500
+ colorSpaceConversion: "none"
5501
+ });
5502
+ try {
5503
+ let e = Io(t);
5504
+ e.drawImage(r, 0, 0);
5505
+ let n = e.getImageData(0, 0, t, t, { colorSpace: "srgb" }).data, i = new Uint8Array(n.length);
5506
+ i.set(n);
5507
+ for (let e = 3; e < i.length; e += 4) i[e] = 255;
5508
+ return i;
5509
+ } finally {
5510
+ r.close();
5511
+ }
5512
+ }
5513
+ function zo() {
5514
+ return typeof CompressionStream < "u" && typeof DecompressionStream < "u";
5515
+ }
5516
+ async function Bo(e, t) {
5517
+ let n = new Blob([e]).stream().pipeThrough(t);
5518
+ return new Uint8Array(await new Response(n).arrayBuffer());
5519
+ }
5520
+ function Vo(e) {
5521
+ return Bo(e, new CompressionStream("deflate-raw"));
5522
+ }
5523
+ function Ho(e) {
5524
+ return Bo(e, new DecompressionStream("deflate-raw"));
5525
+ }
5526
+ async function Uo(e, t, n) {
5527
+ return n === "png" && Fo() ? {
5528
+ bytes: await Lo(e, t),
5529
+ encoding: "png"
5530
+ } : n === "deflate" && zo() ? {
5531
+ bytes: await Vo(e),
5532
+ encoding: "deflate"
5533
+ } : {
5534
+ bytes: e,
5535
+ encoding: "rgba8"
5536
+ };
5537
+ }
5538
+ async function Wo(e, t, n) {
5539
+ let r = e;
5540
+ n === "png" ? r = await Ro(e, t) : n === "deflate" && (r = await Ho(e));
5541
+ let i = t * t * 4;
5542
+ if (r.length !== i) throw Error(`decoded ${r.length} bytes, expected ${i} for ${t}x${t}`);
5543
+ return r;
5544
+ }
5545
+ async function Go(e = 64) {
5546
+ if (!Fo()) return !1;
5547
+ let t = new Uint8Array(e * e * 4);
5548
+ for (let e = 0; e < t.length; e += 4) t[e] = e % 256, t[e + 1] = e * 7 % 256, t[e + 2] = e * 13 % 256, t[e + 3] = 255;
5549
+ let n = await Ro(await Lo(t, e), e);
5550
+ if (n.length !== t.length) return !1;
5551
+ for (let e = 0; e < t.length; e++) if (t[e] !== n[e]) return !1;
5552
+ return !0;
5553
+ }
5554
+ //#endregion
5555
+ //#region src/cache/idb-core.ts
5556
+ var Ko = "material-designer-textures", qo = 1, Q = "meta", $ = "data";
5557
+ function Jo() {
5558
+ try {
5559
+ return typeof indexedDB < "u" && indexedDB !== null;
5560
+ } catch {
5561
+ return !1;
5562
+ }
5563
+ }
5564
+ function Yo(e) {
5565
+ return e ? `${Ko}-${e}` : Ko;
5566
+ }
5567
+ function Xo(e) {
5568
+ return new Promise((t, n) => {
5569
+ e.onsuccess = () => t(e.result), e.onerror = () => n(e.error ?? /* @__PURE__ */ Error("IndexedDB request failed"));
5570
+ });
5571
+ }
5572
+ function Zo(e) {
5573
+ return new Promise((t, n) => {
5574
+ e.oncomplete = () => t(), e.onabort = () => n(e.error ?? /* @__PURE__ */ Error("IndexedDB transaction aborted")), e.onerror = () => n(e.error ?? /* @__PURE__ */ Error("IndexedDB transaction failed"));
5575
+ });
5576
+ }
5577
+ function Qo(e) {
5578
+ return new Promise((t, n) => {
5579
+ let r = indexedDB.open(e, 1);
5580
+ r.onupgradeneeded = () => {
5581
+ let e = r.result;
5582
+ e.objectStoreNames.contains("meta") || e.createObjectStore(Q, { keyPath: "id" }), e.objectStoreNames.contains("data") || e.createObjectStore($, { keyPath: "id" });
5583
+ }, r.onsuccess = () => {
5584
+ let e = r.result;
5585
+ e.onversionchange = () => e.close(), t(e);
5586
+ }, r.onerror = () => n(r.error ?? /* @__PURE__ */ Error("IndexedDB open failed")), r.onblocked = () => n(/* @__PURE__ */ Error("IndexedDB open blocked by another connection"));
5587
+ });
5588
+ }
5589
+ async function $o(e, t) {
5590
+ let n = e.transaction([Q, $], "readonly"), [r, i] = await Promise.all([Xo(n.objectStore(Q).get(t)), Xo(n.objectStore($).get(t))]);
5591
+ return !r || !i ? null : {
5592
+ meta: r,
5593
+ data: i
5594
+ };
5595
+ }
5596
+ async function es(e, t, n) {
5597
+ let r = e.transaction([Q, $], "readwrite");
5598
+ r.objectStore(Q).put(t), r.objectStore($).put(n), await Zo(r);
5599
+ }
5600
+ async function ts(e, t, n) {
5601
+ let r = e.transaction(Q, "readwrite"), i = r.objectStore(Q), a = await Xo(i.get(t));
5602
+ a && i.put({
5603
+ ...a,
5604
+ lastUsedAt: n
5605
+ }), await Zo(r);
5606
+ }
5607
+ async function ns(e, t) {
5608
+ let n = e.transaction([Q, $], "readwrite");
5609
+ n.objectStore(Q).delete(t), n.objectStore($).delete(t), await Zo(n);
5610
+ }
5611
+ async function rs(e) {
5612
+ return Xo(e.transaction(Q, "readonly").objectStore(Q).getAll());
5613
+ }
5614
+ async function is(e) {
5615
+ let t = e.transaction([Q, $], "readwrite");
5616
+ t.objectStore(Q).clear(), t.objectStore($).clear(), await Zo(t);
5617
+ }
5618
+ function as(e) {
5619
+ return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.slice().buffer;
5620
+ }
5621
+ //#endregion
5622
+ //#region src/cache/memory-store.ts
5623
+ function os(e) {
5624
+ return {
5625
+ ...e,
5626
+ channels: [...e.channels],
5627
+ textures: e.textures.map((e) => ({
5628
+ ...e,
5629
+ bytes: new Uint8Array(e.bytes)
5630
+ }))
5631
+ };
5632
+ }
5633
+ function ss(e) {
5634
+ let { textures: t, ...n } = e;
5635
+ return {
5636
+ ...n,
5637
+ channels: [...n.channels]
5638
+ };
5639
+ }
5640
+ function cs() {
5641
+ let e = /* @__PURE__ */ new Map();
5642
+ return {
5643
+ name: "memory",
5644
+ async get(t) {
5645
+ let n = e.get(t);
5646
+ return n ? os(n) : null;
5647
+ },
5648
+ async put(t) {
5649
+ e.set(t.id, os(t));
5650
+ },
5651
+ async touch(t, n) {
5652
+ let r = e.get(t);
5653
+ r && (r.lastUsedAt = n);
5654
+ },
5655
+ async delete(t) {
5656
+ e.delete(t);
5657
+ },
5658
+ async list() {
5659
+ return [...e.values()].map(ss);
5660
+ },
5661
+ async clear() {
5662
+ e.clear();
5663
+ },
5664
+ async estimate() {
5665
+ let t = 0;
5666
+ for (let n of e.values()) t += n.bytes;
5667
+ return {
5668
+ entries: e.size,
5669
+ bytes: t
5670
+ };
5671
+ }
5672
+ };
5673
+ }
5674
+ //#endregion
5675
+ //#region src/cache/cache.worker.ts?worker&inline
5676
+ var ls = "function e(){return typeof OffscreenCanvas<`u`&&typeof createImageBitmap<`u`&&typeof ImageData<`u`}function t(e){let t=new OffscreenCanvas(e,e).getContext(`2d`,{colorSpace:`srgb`,willReadFrequently:!0});if(!t)throw Error(`OffscreenCanvas 2D context unavailable`);return t}async function n(e,n){let r=new Uint8ClampedArray(e.length);r.set(e);for(let e=3;e<r.length;e+=4)r[e]=255;let i=t(n);i.putImageData(new ImageData(r,n,n,{colorSpace:`srgb`}),0,0);let a=await i.canvas.convertToBlob({type:`image/png`});return new Uint8Array(await a.arrayBuffer())}async function r(e,n){let r=new Blob([e],{type:`image/png`}),i=await createImageBitmap(r,{premultiplyAlpha:`none`,colorSpaceConversion:`none`});try{let e=t(n);e.drawImage(i,0,0);let r=e.getImageData(0,0,n,n,{colorSpace:`srgb`}).data,a=new Uint8Array(r.length);a.set(r);for(let e=3;e<a.length;e+=4)a[e]=255;return a}finally{i.close()}}function i(){return typeof CompressionStream<`u`&&typeof DecompressionStream<`u`}async function a(e,t){let n=new Blob([e]).stream().pipeThrough(t);return new Uint8Array(await new Response(n).arrayBuffer())}function o(e){return a(e,new CompressionStream(`deflate-raw`))}function s(e){return a(e,new DecompressionStream(`deflate-raw`))}async function c(t,r,a){return a===`png`&&e()?{bytes:await n(t,r),encoding:`png`}:a===`deflate`&&i()?{bytes:await o(t),encoding:`deflate`}:{bytes:t,encoding:`rgba8`}}async function l(e,t,n){let i=e;n===`png`?i=await r(e,t):n===`deflate`&&(i=await s(e));let a=t*t*4;if(i.length!==a)throw Error(`decoded ${i.length} bytes, expected ${a} for ${t}x${t}`);return i}const u=`material-designer-textures`,d=`meta`,f=`data`;function p(e){return e?`${u}-${e}`:u}function m(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error??Error(`IndexedDB request failed`))})}function h(e){return new Promise((t,n)=>{e.oncomplete=()=>t(),e.onabort=()=>n(e.error??Error(`IndexedDB transaction aborted`)),e.onerror=()=>n(e.error??Error(`IndexedDB transaction failed`))})}function g(e){return new Promise((t,n)=>{let r=indexedDB.open(e,1);r.onupgradeneeded=()=>{let e=r.result;e.objectStoreNames.contains(`meta`)||e.createObjectStore(d,{keyPath:`id`}),e.objectStoreNames.contains(`data`)||e.createObjectStore(f,{keyPath:`id`})},r.onsuccess=()=>{let e=r.result;e.onversionchange=()=>e.close(),t(e)},r.onerror=()=>n(r.error??Error(`IndexedDB open failed`)),r.onblocked=()=>n(Error(`IndexedDB open blocked by another connection`))})}async function _(e,t){let n=e.transaction([d,f],`readonly`),[r,i]=await Promise.all([m(n.objectStore(d).get(t)),m(n.objectStore(f).get(t))]);return!r||!i?null:{meta:r,data:i}}async function v(e,t,n){let r=e.transaction([d,f],`readwrite`);r.objectStore(d).put(t),r.objectStore(f).put(n),await h(r)}async function y(e,t,n){let r=e.transaction(d,`readwrite`),i=r.objectStore(d),a=await m(i.get(t));a&&i.put({...a,lastUsedAt:n}),await h(r)}async function b(e,t){let n=e.transaction([d,f],`readwrite`);n.objectStore(d).delete(t),n.objectStore(f).delete(t),await h(n)}async function x(e){return m(e.transaction(d,`readonly`).objectStore(d).getAll())}async function S(e){let t=e.transaction([d,f],`readwrite`);t.objectStore(d).clear(),t.objectStore(f).clear(),await h(t)}function C(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.slice().buffer}const w=self;let T=null,E=p(``),D=`png`;function O(){return T||=g(E).catch(e=>{throw T=null,e}),T}async function k(e){let t=await _(await O(),e);if(!t)return{entry:null,transfer:[]};let{meta:n,data:r}=t,i=await Promise.all(r.textures.map(async e=>({channel:e.channel,encoding:`rgba8`,bytes:await l(new Uint8Array(e.bytes),n.size,e.encoding)})));return{entry:{...n,textures:i},transfer:i.map(e=>e.bytes.buffer)}}async function A(e){let t=await Promise.all(e.textures.map(async t=>({channel:t.channel,encoded:await c(t.bytes,e.size,D)}))),n=0,r=t.map(({channel:e,encoded:t})=>(n+=t.bytes.byteLength,{channel:e,encoding:t.encoding,bytes:C(t.bytes)})),i={...j(e),bytes:n},a={id:e.id,textures:r};await v(await O(),i,a)}function j(e){let{textures:t,...n}=e;return n}async function M(e){switch(e.op){case`configure`:{let{namespace:t,encoding:n}=e.payload,r=p(t??``);return r!==E&&(T?.then(e=>e.close()).catch(()=>void 0),T=null,E=r),n&&(D=n),{result:{ok:!0}}}case`get`:{let{entry:t,transfer:n}=await k(e.payload);return{result:t,transfer:n}}case`put`:return await A(e.payload),{};case`touch`:{let{id:t,lastUsedAt:n}=e.payload;return await y(await O(),t,n),{}}case`delete`:return await b(await O(),e.payload),{};case`list`:return{result:await x(await O())};case`clear`:return await S(await O()),{};case`estimate`:{let e=await x(await O()),t=0;for(let n of e)t+=n.bytes;return{result:{entries:e.length,bytes:t}}}default:throw Error(`unknown cache worker op: ${String(e.op)}`)}}w.onmessage=async e=>{let t=e.data;try{let{result:e,transfer:n}=await M(t),r={id:t.id,ok:!0,result:e};w.postMessage(r,n??[])}catch(e){let n={id:t.id,ok:!1,error:e instanceof Error?e.message:String(e)};w.postMessage(n)}};", us = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", ls], { type: "text/javascript;charset=utf-8" });
5677
+ function ds(e) {
5678
+ let t;
5679
+ try {
5680
+ if (t = us && (self.URL || self.webkitURL).createObjectURL(us), !t) throw "";
5681
+ let n = new Worker(t, {
5682
+ type: "module",
5683
+ name: e?.name
5684
+ });
5685
+ return n.addEventListener("error", () => {
5686
+ (self.URL || self.webkitURL).revokeObjectURL(t);
5687
+ }), n;
5688
+ } catch {
5689
+ return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(ls), {
5690
+ type: "module",
5691
+ name: e?.name
5692
+ });
5693
+ }
5694
+ }
5695
+ //#endregion
5696
+ //#region src/cache/worker-client.ts
5697
+ function fs() {
5698
+ return typeof Worker < "u" && typeof indexedDB < "u";
5699
+ }
5700
+ function ps(e) {
5701
+ return e ? new Worker(e, { type: "module" }) : new ds();
5702
+ }
5703
+ function ms(e = {}) {
5704
+ if (!fs()) return null;
5705
+ let t;
5706
+ try {
5707
+ t = ps(e.url);
5708
+ } catch {
5709
+ return null;
5710
+ }
5711
+ let n = /* @__PURE__ */ new Map(), r = 1, i = null;
5712
+ t.onmessage = (e) => {
5713
+ let { id: t, ok: r, result: i, error: a } = e.data, o = n.get(t);
5714
+ o && (n.delete(t), r ? o.resolve(i) : o.reject(Error(a ?? "cache worker error")));
5715
+ };
5716
+ let a = (e) => {
5717
+ i = Error(e);
5718
+ for (let e of n.values()) e.reject(i);
5719
+ n.clear();
5720
+ };
5721
+ t.onerror = (e) => a(e.message || "cache worker crashed"), t.onmessageerror = () => a("cache worker message could not be deserialized");
5722
+ let o = (e, a, o = []) => {
5723
+ if (i) return Promise.reject(i);
5724
+ let s = r++;
5725
+ return new Promise((r, i) => {
5726
+ n.set(s, {
5727
+ resolve: r,
5728
+ reject: i
5729
+ });
5730
+ try {
5731
+ t.postMessage({
5732
+ id: s,
5733
+ op: e,
5734
+ payload: a
5735
+ }, o);
5736
+ } catch (e) {
5737
+ n.delete(s), i(e instanceof Error ? e : Error(String(e)));
5738
+ }
5739
+ });
5740
+ };
5741
+ return o("configure", {
5742
+ namespace: e.namespace ?? "",
5743
+ encoding: e.encoding ?? "png"
5744
+ }), {
5745
+ name: "worker-indexeddb",
5746
+ async get(e) {
5747
+ return await o("get", e) ?? null;
5748
+ },
5749
+ async put(e) {
5750
+ await o("put", e, e.textures.map((e) => e.bytes.buffer));
5751
+ },
5752
+ async touch(e, t) {
5753
+ await o("touch", {
5754
+ id: e,
5755
+ lastUsedAt: t
5756
+ });
5757
+ },
5758
+ async delete(e) {
5759
+ await o("delete", e);
5760
+ },
5761
+ async list() {
5762
+ return o("list");
5763
+ },
5764
+ async clear() {
5765
+ await o("clear");
5766
+ },
5767
+ async estimate() {
5768
+ return o("estimate");
5769
+ }
5770
+ };
5771
+ }
5772
+ //#endregion
5773
+ //#region src/cache/indexeddb-store.ts
5774
+ function hs(e = {}) {
5775
+ let t = Yo(e.namespace ?? ""), n = e.encoding ?? "png", r = null, i = () => (r ||= Qo(t).catch((e) => {
5776
+ throw r = null, e;
5777
+ }), r);
5778
+ return {
5779
+ name: "indexeddb",
5780
+ async get(e) {
5781
+ let t = await $o(await i(), e);
5782
+ if (!t) return null;
5783
+ let { meta: n, data: r } = t, a = await Promise.all(r.textures.map(async (e) => ({
5784
+ channel: e.channel,
5785
+ encoding: "rgba8",
5786
+ bytes: await Wo(new Uint8Array(e.bytes), n.size, e.encoding)
5787
+ })));
5788
+ return {
5789
+ ...n,
5790
+ textures: a
5791
+ };
5792
+ },
5793
+ async put(e) {
5794
+ let t = await Promise.all(e.textures.map(async (t) => ({
5795
+ channel: t.channel,
5796
+ encoded: await Uo(t.bytes, e.size, n)
5797
+ }))), r = 0, a = t.map(({ channel: e, encoded: t }) => (r += t.bytes.byteLength, {
5798
+ channel: e,
5799
+ encoding: t.encoding,
5800
+ bytes: as(t.bytes)
5801
+ })), { textures: o, ...s } = e, c = {
5802
+ ...s,
5803
+ bytes: r
5804
+ }, l = {
5805
+ id: e.id,
5806
+ textures: a
5807
+ };
5808
+ await es(await i(), c, l);
5809
+ },
5810
+ async touch(e, t) {
5811
+ await ts(await i(), e, t);
5812
+ },
5813
+ async delete(e) {
5814
+ await ns(await i(), e);
5815
+ },
5816
+ async list() {
5817
+ return rs(await i());
5818
+ },
5819
+ async clear() {
5820
+ await is(await i());
5821
+ },
5822
+ async estimate() {
5823
+ let e = await rs(await i()), t = 0;
5824
+ for (let n of e) t += n.bytes;
5825
+ return {
5826
+ entries: e.length,
5827
+ bytes: t
5828
+ };
5829
+ }
5830
+ };
5831
+ }
5832
+ function gs(e = {}) {
5833
+ let { worker: t = !0, ...n } = e;
5834
+ if (t !== !1) {
5835
+ let e = ms({
5836
+ ...n,
5837
+ url: typeof t == "object" ? t.url : void 0
5838
+ });
5839
+ if (e) return e;
5840
+ }
5841
+ return Jo() ? hs(n) : cs();
5842
+ }
5843
+ //#endregion
5844
+ //#region src/cache/bake-cache.ts
5845
+ var _s = 256 * 1024 * 1024, vs = 256 * 1024 * 1024, ys = 250, bs = 750;
5846
+ function xs(e) {
5847
+ let t = 0;
5848
+ for (let n of e) t += n.bytes.byteLength;
5849
+ return t;
5850
+ }
5851
+ function Ss(e) {
5852
+ if (!e || typeof e != "object") return !1;
5853
+ let t = e.name;
5854
+ return t === "QuotaExceededError" || t === "NS_ERROR_DOM_QUOTA_REACHED";
5855
+ }
5856
+ var Cs = class {
5857
+ store;
5858
+ ownsStore;
5859
+ enabled_;
5860
+ options;
5861
+ onEvent;
5862
+ workerOption;
5863
+ hits = 0;
5864
+ misses = 0;
5865
+ writes = 0;
5866
+ evictions = 0;
5867
+ collisions = 0;
5868
+ lastError_ = null;
5869
+ quotaFailures = 0;
5870
+ gcDone = !1;
5871
+ constructor(e = {}) {
5872
+ let t = e.encoding ?? "deflate";
5873
+ this.ownsStore = e.store === void 0, this.workerOption = e.worker, this.store = e.store ?? gs({
5874
+ namespace: e.namespace ?? "",
5875
+ encoding: t,
5876
+ worker: e.worker
5877
+ }), this.enabled_ = e.enabled ?? !1, this.onEvent = e.onEvent, this.options = {
5878
+ encoding: t,
5879
+ budgetBytes: e.budgetBytes ?? _s,
5880
+ maxEntryBytes: e.maxEntryBytes ?? vs,
5881
+ minBakeMs: e.minBakeMs ?? ys,
5882
+ writeDelayMs: e.writeDelayMs ?? bs,
5883
+ namespace: e.namespace ?? ""
5884
+ };
5885
+ }
5886
+ get enabled() {
5887
+ return this.enabled_ && this.store !== null;
5888
+ }
5889
+ get available() {
5890
+ return this.store !== null;
5891
+ }
5892
+ get storeName() {
5893
+ return this.store?.name ?? "none";
5894
+ }
5895
+ get encoding() {
5896
+ return this.options.encoding;
5897
+ }
5898
+ get namespace() {
5899
+ return this.options.namespace;
5900
+ }
5901
+ get writeDelayMs() {
5902
+ return this.options.writeDelayMs;
5903
+ }
5904
+ get lastError() {
5905
+ return this.lastError_;
5906
+ }
5907
+ setEnabled(e) {
5908
+ this.enabled_ = e;
5909
+ }
5910
+ configure(e) {
5911
+ e.store !== void 0 && (this.store = e.store, this.ownsStore = !1, this.gcDone = !1, this.quotaFailures = 0), e.enabled !== void 0 && (this.enabled_ = e.enabled), e.onEvent !== void 0 && (this.onEvent = e.onEvent), e.budgetBytes !== void 0 && (this.options.budgetBytes = e.budgetBytes), e.maxEntryBytes !== void 0 && (this.options.maxEntryBytes = e.maxEntryBytes), e.minBakeMs !== void 0 && (this.options.minBakeMs = e.minBakeMs), e.writeDelayMs !== void 0 && (this.options.writeDelayMs = e.writeDelayMs), e.worker !== void 0 && (this.workerOption = e.worker);
5912
+ let t = e.encoding !== void 0 && e.encoding !== this.options.encoding, n = e.namespace !== void 0 && e.namespace !== this.options.namespace;
5913
+ e.encoding !== void 0 && (this.options.encoding = e.encoding), e.namespace !== void 0 && (this.options.namespace = e.namespace), (t || n || e.worker !== void 0) && this.ownsStore && (this.store = gs({
5914
+ namespace: this.options.namespace,
5915
+ encoding: this.options.encoding,
5916
+ worker: this.workerOption
5917
+ }), this.gcDone = !1, this.quotaFailures = 0);
5918
+ }
5919
+ async read(e) {
5920
+ if (!this.enabled || !this.store) return null;
5921
+ await this.ensureGc();
5922
+ let t = await this.guard("read", () => this.store.get(e.id), null);
5923
+ return t ? t.key === e.key ? (this.hits += 1, this.emit({
5924
+ kind: "hit",
5925
+ id: e.id,
5926
+ bytes: t.bytes
5927
+ }), this.guard("touch", () => this.store.touch(e.id, Date.now()), void 0), t) : (this.collisions += 1, this.misses += 1, this.emit({
5928
+ kind: "collision",
5929
+ id: e.id
5930
+ }), await this.guard("collision-delete", () => this.store.delete(e.id), void 0), null) : (this.misses += 1, this.emit({
5931
+ kind: "miss",
5932
+ id: e.id
5933
+ }), null);
5934
+ }
5935
+ async peek(e) {
5936
+ if (!this.enabled || !this.store) return null;
5937
+ let t = await this.guard("peek", () => this.store.get(e.id), null);
5938
+ if (!t || t.key !== e.key) return null;
5939
+ let { textures: n, ...r } = t;
5940
+ return r;
5941
+ }
5942
+ async entries() {
5943
+ return this.store ? this.guard("list", () => this.store.list(), []) : [];
5944
+ }
5945
+ canWrite(e, t) {
5946
+ return !this.enabled || !this.store || t <= 0 || t > this.options.maxEntryBytes ? !1 : e >= this.options.minBakeMs;
5947
+ }
5948
+ async write(e, t) {
5949
+ if (!this.enabled || !this.store) return;
5950
+ let n = xs(t.textures);
5951
+ if (!this.canWrite(t.bakeMs, n)) return;
5952
+ let r = Date.now(), i = {
5953
+ id: e.id,
5954
+ key: e.key,
5955
+ schema: so,
5956
+ size: t.size,
5957
+ encoding: this.options.encoding,
5958
+ channels: [...t.channels],
5959
+ hasHeight: t.hasHeight,
5960
+ bytes: n,
5961
+ bakeMs: t.bakeMs,
5962
+ createdAt: r,
5963
+ lastUsedAt: r,
5964
+ textures: t.textures
5965
+ };
5966
+ await this.evictTo(Math.max(0, this.options.budgetBytes - n), e.id), await this.put(i) && (this.writes += 1, this.emit({
5967
+ kind: "write",
5968
+ id: e.id,
5969
+ bytes: n
5970
+ }));
5971
+ }
5972
+ async delete(e) {
5973
+ if (!this.store) return;
5974
+ let t = typeof e == "string" ? e : e.id;
5975
+ await this.guard("delete", () => this.store.delete(t), void 0);
5976
+ }
5977
+ async clear() {
5978
+ this.store && await this.guard("clear", () => this.store.clear(), void 0);
5979
+ }
5980
+ async gc() {
5981
+ if (!this.store) return 0;
5982
+ let e = await this.entries(), t = 0;
5983
+ for (let n of e) n.schema !== so && (await this.guard("gc-delete", () => this.store.delete(n.id), void 0), t += 1);
5984
+ return t;
5985
+ }
5986
+ async evict() {
5987
+ return this.evictTo(this.options.budgetBytes);
5988
+ }
5989
+ async metrics() {
5990
+ let e = await this.entries(), t = 0;
5991
+ for (let n of e) t += n.bytes;
5992
+ return {
5993
+ enabled: this.enabled,
5994
+ available: this.available,
5995
+ store: this.storeName,
5996
+ encoding: this.options.encoding,
5997
+ entries: e.length,
5998
+ bytes: t,
5999
+ budgetBytes: this.options.budgetBytes,
6000
+ hits: this.hits,
6001
+ misses: this.misses,
6002
+ writes: this.writes,
6003
+ evictions: this.evictions,
6004
+ collisions: this.collisions,
6005
+ quota: await ws(),
6006
+ lastError: this.lastError_
6007
+ };
6008
+ }
6009
+ info() {
6010
+ return {
6011
+ enabled: this.enabled,
6012
+ store: this.storeName,
6013
+ encoding: this.options.encoding,
6014
+ hits: this.hits,
6015
+ misses: this.misses,
6016
+ writes: this.writes,
6017
+ evictions: this.evictions,
6018
+ collisions: this.collisions,
6019
+ lastError: this.lastError_
6020
+ };
6021
+ }
6022
+ async put(e) {
6023
+ try {
6024
+ return await this.store.put(e), this.quotaFailures = 0, !0;
6025
+ } catch (t) {
6026
+ if (!Ss(t)) return this.fail("put", t), !1;
6027
+ this.quotaFailures += 1, await this.evictTo(Math.floor(this.options.budgetBytes / 2), e.id);
6028
+ try {
6029
+ return await this.store.put(e), this.quotaFailures = 0, !0;
6030
+ } catch (e) {
6031
+ return this.fail("put-retry", e), this.quotaFailures >= 2 && (this.enabled_ = !1, this.emit({
6032
+ kind: "disabled",
6033
+ message: "storage quota exhausted"
6034
+ })), !1;
6035
+ }
6036
+ }
6037
+ }
6038
+ async evictTo(e, t) {
6039
+ if (!this.store) return 0;
6040
+ let n = await this.entries(), r = 0;
6041
+ for (let e of n) r += e.bytes;
6042
+ if (r <= e) return 0;
6043
+ let i = n.filter((e) => e.id !== t).sort((e, t) => e.lastUsedAt - t.lastUsedAt), a = 0;
6044
+ for (let t of i) {
6045
+ if (r <= e) break;
6046
+ await this.guard("evict", () => this.store.delete(t.id), void 0), r -= t.bytes, a += 1, this.evictions += 1, this.emit({
6047
+ kind: "evict",
6048
+ id: t.id,
6049
+ bytes: t.bytes
6050
+ });
6051
+ }
6052
+ return a;
6053
+ }
6054
+ async ensureGc() {
6055
+ this.gcDone || (this.gcDone = !0, await this.gc());
6056
+ }
6057
+ async guard(e, t, n) {
6058
+ try {
6059
+ return await t();
6060
+ } catch (t) {
6061
+ return this.fail(e, t), n;
6062
+ }
6063
+ }
6064
+ fail(e, t) {
6065
+ this.lastError_ = `${e}: ${t instanceof Error ? t.message : String(t)}`, this.emit({
6066
+ kind: "error",
6067
+ message: this.lastError_
6068
+ });
6069
+ }
6070
+ emit(e) {
6071
+ if (this.onEvent) try {
6072
+ this.onEvent(e);
6073
+ } catch {}
6074
+ }
6075
+ };
6076
+ async function ws() {
6077
+ let e = typeof navigator < "u" ? navigator.storage : void 0;
6078
+ if (!e?.estimate) return null;
6079
+ try {
6080
+ let { usage: t, quota: n } = await e.estimate();
6081
+ return {
6082
+ usage: t ?? 0,
6083
+ quota: n ?? 0
6084
+ };
6085
+ } catch {
6086
+ return null;
6087
+ }
5006
6088
  }
5007
6089
  //#endregion
5008
6090
  //#region src/runtime.ts
5009
- var Ja = class {
6091
+ var Ts = class {
5010
6092
  graph;
5011
6093
  surface;
5012
6094
  service;
5013
6095
  constructor(e = {}) {
5014
- this.service = e.bakeService ?? La, this.graph = new la(e.document, e.registry ?? Si), this.surface = new Ga(this.graph, this.service, e.source);
6096
+ this.service = e.bakeService ?? wo, this.graph = new _a(e.document, e.registry ?? Ai), this.surface = new Mo(this.graph, this.service, e.source), e.cache instanceof Cs ? this.service.setCache(e.cache) : e.cache && this.service.setCache(new Cs({
6097
+ enabled: !0,
6098
+ ...e.cache
6099
+ }));
5015
6100
  }
5016
6101
  getNodeMaterial() {
5017
6102
  return this.surface.material;
5018
6103
  }
5019
6104
  getMeshMaterial() {
5020
- return qa(this.graph.document, { get: (e) => this.surface.getChannelTexture(e) });
6105
+ return Po(this.graph.document, { get: (e) => this.surface.getChannelTexture(e) });
5021
6106
  }
5022
6107
  releaseCaches() {
5023
6108
  return this.surface.releaseCaches();
@@ -5064,40 +6149,63 @@ var Ja = class {
5064
6149
  dispose() {
5065
6150
  this.surface.dispose();
5066
6151
  }
6152
+ get cache() {
6153
+ return this.service.cache;
6154
+ }
6155
+ setCacheEnabled(e) {
6156
+ let t = this.service.cache;
6157
+ return t ? (t.setEnabled(e), this) : (e && this.service.setCache(new Cs({ enabled: !0 })), this);
6158
+ }
6159
+ get cacheEnabled() {
6160
+ return this.service.cache?.enabled ?? !1;
6161
+ }
6162
+ clearCache() {
6163
+ return this.service.cache?.clear() ?? Promise.resolve();
6164
+ }
6165
+ async rebuildCache() {
6166
+ let e = this.service.cache;
6167
+ e && (await e.delete(this.cacheKey()), this.surface.regenerate(), await this.surface.whenIdle(), await this.service.flushCacheWrites());
6168
+ }
6169
+ getCachedTextures() {
6170
+ return this.service.cache?.peek(this.cacheKey()) ?? Promise.resolve(null);
6171
+ }
6172
+ async listCachedTextures() {
6173
+ return (await this.service.cache?.entries() ?? []).sort((e, t) => t.lastUsedAt - e.lastUsedAt);
6174
+ }
6175
+ async loadCachedChannelTextures() {
6176
+ let e = this.service.cache;
6177
+ if (!e) return null;
6178
+ let t = await e.read(this.cacheKey());
6179
+ if (!t) return null;
6180
+ let n = /* @__PURE__ */ new Map(), r = null;
6181
+ for (let e of t.textures) {
6182
+ let i = Ga(e.bytes, t.size, e.channel);
6183
+ e.channel === "height" ? r = i : n.set(e.channel, i);
6184
+ }
6185
+ return {
6186
+ size: t.size,
6187
+ channels: [...n.keys()],
6188
+ height: r,
6189
+ get: (e) => n.get(e) ?? null,
6190
+ dispose: () => {
6191
+ for (let e of n.values()) e.dispose();
6192
+ r?.dispose(), n.clear(), r = null;
6193
+ }
6194
+ };
6195
+ }
6196
+ cacheMetrics() {
6197
+ return this.service.cacheMetrics();
6198
+ }
6199
+ flushCache() {
6200
+ return this.service.flushCacheWrites();
6201
+ }
6202
+ cacheKey() {
6203
+ return this.service.cacheKeyFor(this.graph, this.surface.bakeSize, yo);
6204
+ }
5067
6205
  };
5068
6206
  //#endregion
5069
- //#region src/topology.ts
5070
- function Ya(e) {
5071
- return Array.isArray(e) ? `[${e.map(Ya).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).sort(([e], [t]) => e.localeCompare(t)).map(([e, t]) => `${e}:${Ya(t)}`).join(",")}}` : JSON.stringify(e);
5072
- }
5073
- function Xa(e, t) {
5074
- let n = t.get(e.type), r = n.paramsFor ? n.paramsFor(e.params) : n.params, i = {};
5075
- for (let t of r) (t.type === "int" || t.type === "bool" || t.type === "select" || t.bakeStructural) && (i[t.key] = e.params[t.key]);
5076
- return i;
5077
- }
5078
- function Za(e, t) {
5079
- return {
5080
- id: e.id,
5081
- type: e.type,
5082
- enabled: e.enabled,
5083
- ports: Q(e, t),
5084
- params: Xa(e, t),
5085
- subgraph: e.subgraph ? Qa(e.subgraph, t) : null
5086
- };
5087
- }
5088
- function Qa(e, t) {
5089
- return {
5090
- version: e.version,
5091
- nodes: e.nodes.map((e) => Za(e, t)).sort((e, t) => String(e.id).localeCompare(String(t.id))),
5092
- edges: [...e.edges].sort((e, t) => Ya(e).localeCompare(Ya(t)))
5093
- };
5094
- }
5095
- function $a(e, t) {
5096
- return Ya(Qa(e, t));
5097
- }
5098
- //#endregion
5099
6207
  //#region src/graph/tiling-test.ts
5100
- function eo(e) {
6208
+ function Es(e) {
5101
6209
  return {
5102
6210
  version: 4,
5103
6211
  nodes: [
@@ -5150,7 +6258,7 @@ function eo(e) {
5150
6258
  }]
5151
6259
  };
5152
6260
  }
5153
- function to(e, t) {
6261
+ function Ds(e, t) {
5154
6262
  let n = (n, r) => e.data[(r * t + n) * 4], r = 0, i = 0;
5155
6263
  for (let e = 0; e < t; e++) {
5156
6264
  r += Math.abs(n(t - 1, e) - n(0, e));
@@ -5170,10 +6278,10 @@ function to(e, t) {
5170
6278
  ratioV: a / Math.max(o, .001)
5171
6279
  };
5172
6280
  }
5173
- async function no(e, t, n = {}) {
6281
+ async function Os(e, t, n = {}) {
5174
6282
  let r = n.size ?? 256, i = n.threshold ?? 3, a = n.channel ?? "baseColor", o = t.get("tileable-noise").params, s = o.find((e) => e.key === "noiseType")?.options ?? [], c = (o.find((e) => e.key === "preset")?.options ?? []).filter((e) => e !== "none"), l = new Set(c), u = n.types ?? [...s, ...c], d = [];
5175
6283
  for (let o of u) {
5176
- let s = new la(eo(l.has(o) ? {
6284
+ let s = new _a(Es(l.has(o) ? {
5177
6285
  noiseType: "perlin-fbm",
5178
6286
  preset: o
5179
6287
  } : { noiseType: o }), t), c = await e.readImage(s, a, r);
@@ -5191,7 +6299,7 @@ async function no(e, t, n = {}) {
5191
6299
  continue;
5192
6300
  }
5193
6301
  n.onTile && await n.onTile(o, c);
5194
- let u = to(c, r);
6302
+ let u = Ds(c, r);
5195
6303
  d.push({
5196
6304
  type: o,
5197
6305
  ...u,
@@ -5201,4 +6309,4 @@ async function no(e, t, n = {}) {
5201
6309
  return d;
5202
6310
  }
5203
6311
  //#endregion
5204
- export { Fa as BakedTextureSet, Ke as COERCION_MATRIX, Ie as CURVE_CHANNELS, Fe as CURVE_IDENTITY, He as GROUP_INPUT_TYPE, Ue as GROUP_OUTPUT_TYPE, Ve as GROUP_TYPE, $i as MATERIAL_DOCUMENT_VERSION, q as MATERIAL_OUTPUT_TYPE, Re as MATERIAL_TYPES, ze as MATERIAL_TYPE_CAPS, Ia as MaterialBakeService, Ja as MaterialGraphRuntime, la as MaterialGraphSession, bi as NodeRegistry, Ge as PBR_SOCKETS, We as SHADER_MATERIAL_TYPE, Ma as SURFACE_CHANNELS, Ga as TexturedSurface, La as bakeService, qa as buildMeshMaterial, ea as cloneMaterialDocument, qe as coercionFor, Gi as compileGraph, Li as compileSockets, Ii as countGraphNodes, ta as createDefaultMaterialDocument, xi as createDefaultRegistry, $a as createMaterialTopologyKey, Le as curveToArray, Si as defaultRegistry, aa as migrateMaterialDocument, Ui as newSurfaceMaterial, yi as nodeParamDefs, Q as nodePorts, Be as normalizeMaterialType, Ni as readMaterialConfig, Mi as readMaterialSurface, ji as readOutputResolution, no as runTilingTest };
6312
+ export { Ko as BAKE_CACHE_DB_NAME, qo as BAKE_CACHE_DB_VERSION, oo as BAKE_CACHE_ID_PREFIX, so as BAKE_CACHE_SCHEMA, io as BAKE_CACHE_VERSION, ao as BAKE_ENCODER_VERSION, Cs as BakeTextureCache, So as BakedTextureSet, Qe as COERCION_MATRIX, Ve as CURVE_CHANNELS, Be as CURVE_IDENTITY, qe as GROUP_INPUT_TYPE, Je as GROUP_OUTPUT_TYPE, Ke as GROUP_TYPE, sa as MATERIAL_DOCUMENT_VERSION, Ye as MATERIAL_OUTPUT_TYPE, qa as MATERIAL_RUNTIME_VERSION, Ue as MATERIAL_TYPES, We as MATERIAL_TYPE_CAPS, Co as MaterialBakeService, Ts as MaterialGraphRuntime, _a as MaterialGraphSession, Oi as NodeRegistry, Ze as PBR_SOCKETS, Xe as SHADER_MATERIAL_TYPE, yo as SURFACE_CHANNELS, Mo as TexturedSurface, wo as bakeService, Po as buildMeshMaterial, zo as canDeflate, Fo as canEncodePng, Ja as canonicalStringify, Fa as channelByteLength, Ga as channelDataTexture, ca as cloneMaterialDocument, $e as coercionFor, $i as compileGraph, Gi as compileSockets, Wi as countGraphNodes, lo as createBakeCacheKey, gs as createDefaultCacheStore, la as createDefaultMaterialDocument, ki as createDefaultRegistry, hs as createIndexedDbCacheStore, ro as createMaterialParamKey, Qa as createMaterialTopologyKey, cs as createMemoryCacheStore, ms as createWorkerCacheStore, He as curveToArray, Wo as decodeTexels, Ai as defaultRegistry, Vo as deflateBytes, La as depadRows, Wa as disposeTransferPool, Uo as encodeTexels, Ra as flipRows, co as fnv1a64, Ho as inflateBytes, Jo as isIndexedDbAvailable, fs as isWorkerCacheAvailable, pa as migrateMaterialDocument, Zi as newSurfaceMaterial, Di as nodeParamDefs, Y as nodePorts, Ge as normalizeMaterialType, Ia as paddedBytesPerRow, Go as pngRoundTripIsLossless, Vi as readMaterialConfig, Bi as readMaterialSurface, zi as readOutputResolution, Ba as readTargetTexels, Os as runTilingTest, Ua as transferPoolInfo, Ka as writeTargetTexels };