@roomle/web-sdk 4.2.0 → 4.3.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/lib/ConfiguratorKernel.wasm +0 -0
  2. package/lib/{GaussianBlurNode-DEczNsyD.mjs → GaussianBlurNode-Bjszve7N.mjs} +15 -15
  3. package/lib/{GaussianBlurNode-DEczNsyD.mjs.map → GaussianBlurNode-Bjszve7N.mjs.map} +1 -1
  4. package/lib/RoomleCore.wasm +0 -0
  5. package/lib/RoomleToolsCore.wasm +0 -0
  6. package/lib/{api-B6sLiuiL.mjs → api-C0UElaCW.mjs} +2 -2
  7. package/lib/{api-B6sLiuiL.mjs.map → api-C0UElaCW.mjs.map} +1 -1
  8. package/lib/asset-loader.worker-eqHzNAwa.mjs.map +1 -1
  9. package/lib/{banana-for-scale-C-grIlTK.mjs → banana-for-scale-DGYmxeBG.mjs} +3 -3
  10. package/lib/{banana-for-scale-C-grIlTK.mjs.map → banana-for-scale-DGYmxeBG.mjs.map} +1 -1
  11. package/lib/budgeteer.sw-BUMElkO1.mjs.map +1 -1
  12. package/lib/{common-utils-6T8eGlhX.mjs → common-utils-CyQUubmw.mjs} +29 -15
  13. package/lib/{common-utils-6T8eGlhX.mjs.map → common-utils-CyQUubmw.mjs.map} +1 -1
  14. package/lib/{component-dimensioning-DJuokZnv.mjs → component-dimensioning--4sX2AgY.mjs} +4 -4
  15. package/lib/{component-dimensioning-DJuokZnv.mjs.map → component-dimensioning--4sX2AgY.mjs.map} +1 -1
  16. package/lib/{component-raycast-helper-SZg14d7A.mjs → component-raycast-helper-CskJedpv.mjs} +3 -3
  17. package/lib/{component-raycast-helper-SZg14d7A.mjs.map → component-raycast-helper-CskJedpv.mjs.map} +1 -1
  18. package/lib/configurator-CjFo24FH.mjs +2 -0
  19. package/lib/{configurator-Cbof6AET.mjs → configurator-vxRFxJ-B.mjs} +4 -4
  20. package/lib/{configurator-Cbof6AET.mjs.map → configurator-vxRFxJ-B.mjs.map} +1 -1
  21. package/lib/{decorate-CX1ZGuFY.mjs → decorate-CjaqqbUP.mjs} +12 -9
  22. package/lib/decorate-CjaqqbUP.mjs.map +1 -0
  23. package/lib/dimensioning-helper-0s61LK9R.mjs +2 -0
  24. package/lib/{dimensioning-helper-BwvR76_I.mjs → dimensioning-helper-Cgao7A18.mjs} +2 -2
  25. package/lib/{dimensioning-helper-BwvR76_I.mjs.map → dimensioning-helper-Cgao7A18.mjs.map} +1 -1
  26. package/lib/{glb-viewer-DmVh1uJg.mjs → glb-viewer-B-r0E1aa.mjs} +6 -6
  27. package/lib/{glb-viewer-DmVh1uJg.mjs.map → glb-viewer-B-r0E1aa.mjs.map} +1 -1
  28. package/lib/glb-viewer-BnJkmakv.mjs +2 -0
  29. package/lib/{highlight-coordinator-Qonmfsu1.mjs → highlight-coordinator-CR5rcFh_.mjs} +2 -2
  30. package/lib/{highlight-coordinator-Qonmfsu1.mjs.map → highlight-coordinator-CR5rcFh_.mjs.map} +1 -1
  31. package/lib/{homag-intelligence-CzD_RMQo.mjs → homag-intelligence-DHTCBB64.mjs} +8 -5
  32. package/lib/{homag-intelligence-CzD_RMQo.mjs.map → homag-intelligence-DHTCBB64.mjs.map} +1 -1
  33. package/lib/{imos-ix-poc-export-helper-Q6-OXziY.mjs → imos-ix-poc-export-helper-DRQK_p2h.mjs} +2 -2
  34. package/lib/{imos-ix-poc-export-helper-Q6-OXziY.mjs.map → imos-ix-poc-export-helper-DRQK_p2h.mjs.map} +1 -1
  35. package/lib/{material-viewer-BkSh-aG7.mjs → material-viewer-ZlNDhA8D.mjs} +6 -6
  36. package/lib/{material-viewer-BkSh-aG7.mjs.map → material-viewer-ZlNDhA8D.mjs.map} +1 -1
  37. package/lib/{packages-BGVMQMZK.mjs → packages-C9J0u-cc.mjs} +5 -5
  38. package/lib/{packages-BGVMQMZK.mjs.map → packages-C9J0u-cc.mjs.map} +1 -1
  39. package/lib/planner-C-5Mg-Lv.mjs +2 -0
  40. package/lib/{planner-DFa8uJOF.mjs → planner-ClY-VUWt.mjs} +3 -3
  41. package/lib/{planner-DFa8uJOF.mjs.map → planner-ClY-VUWt.mjs.map} +1 -1
  42. package/lib/{plugin-system-CqXT37-v.mjs → plugin-system-vlnG8j2T.mjs} +3 -3
  43. package/lib/{plugin-system-CqXT37-v.mjs.map → plugin-system-vlnG8j2T.mjs.map} +1 -1
  44. package/lib/{roomle-headless-setup-7xnQlZl3.mjs → roomle-headless-setup-DbO_rLjK.mjs} +54 -40
  45. package/lib/roomle-headless-setup-DbO_rLjK.mjs.map +1 -0
  46. package/lib/roomle-headless.d.ts +125 -115
  47. package/lib/roomle-headless.js +289 -358
  48. package/lib/roomle-headless.js.map +1 -1
  49. package/lib/roomle-renderer-FUqNfNIf.mjs.map +1 -1
  50. package/lib/{roomle-sdk-B73VmWod.mjs → roomle-sdk-BpCPIwDm.mjs} +2447 -2306
  51. package/lib/roomle-sdk-BpCPIwDm.mjs.map +1 -0
  52. package/lib/roomle-sdk.d.ts +79 -4
  53. package/lib/roomle-sdk.js +7 -7
  54. package/lib/{roomle-webgpu-renderer-Dzuy_Y39.mjs → roomle-webgpu-renderer-Lt55gNj5.mjs} +370 -303
  55. package/lib/roomle-webgpu-renderer-Lt55gNj5.mjs.map +1 -0
  56. package/lib/{scene-renderer-DR7EFd-8.mjs → scene-renderer-CLkhNnnv.mjs} +5 -5
  57. package/lib/{scene-renderer-DR7EFd-8.mjs.map → scene-renderer-CLkhNnnv.mjs.map} +1 -1
  58. package/lib/{script-loader-BlsGBrYo.mjs → script-loader-9GrUxzSB.mjs} +3 -3
  59. package/lib/{script-loader-BlsGBrYo.mjs.map → script-loader-9GrUxzSB.mjs.map} +1 -1
  60. package/lib/{shading-settings-Bnt9v9xJ.mjs → shading-settings-CRNmMpcn.mjs} +2 -2
  61. package/lib/{shading-settings-Bnt9v9xJ.mjs.map → shading-settings-CRNmMpcn.mjs.map} +1 -1
  62. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/package.json +1 -1
  63. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/ConfiguratorKernel.wasm +0 -0
  64. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleCore.wasm +0 -0
  65. package/lib/static/roomle-core-hsc/node_modules/roomle-core-hsc/wasm_modern/RoomleToolsCore.wasm +0 -0
  66. package/lib/{stats-helper-vEwFkDIt.mjs → stats-helper-D9l8soWd.mjs} +3 -3
  67. package/lib/{stats-helper-vEwFkDIt.mjs.map → stats-helper-D9l8soWd.mjs.map} +1 -1
  68. package/lib/three.tsl-BnL9nfJa.mjs +2 -0
  69. package/lib/{three.tsl-BElp7_oF.mjs → three.tsl-Dew9p5yF.mjs} +46 -48
  70. package/lib/{three.tsl-BElp7_oF.mjs.map → three.tsl-Dew9p5yF.mjs.map} +1 -1
  71. package/lib/{threejs-utils-C9zED_Tu.mjs → threejs-utils-CKV1QNU9.mjs} +4 -3
  72. package/lib/threejs-utils-CKV1QNU9.mjs.map +1 -0
  73. package/lib/{tools-core-DKYMilYC.mjs → tools-core-CKaB3WsP.mjs} +3 -3
  74. package/lib/{tools-core-DKYMilYC.mjs.map → tools-core-CKaB3WsP.mjs.map} +1 -1
  75. package/lib/{webgpu-BMwlJflc.mjs → webgpu-B0rxiqW-.mjs} +313 -313
  76. package/lib/{webgpu-BMwlJflc.mjs.map → webgpu-B0rxiqW-.mjs.map} +1 -1
  77. package/package.json +2 -2
  78. package/lib/configurator-BFd5022u.mjs +0 -2
  79. package/lib/decorate-CX1ZGuFY.mjs.map +0 -1
  80. package/lib/dimensioning-helper-yMfkA1IY.mjs +0 -2
  81. package/lib/glb-viewer-DlH5_aTU.mjs +0 -2
  82. package/lib/planner-CSKuhBke.mjs +0 -2
  83. package/lib/roomle-headless-setup-7xnQlZl3.mjs.map +0 -1
  84. package/lib/roomle-sdk-B73VmWod.mjs.map +0 -1
  85. package/lib/roomle-webgpu-renderer-Dzuy_Y39.mjs.map +0 -1
  86. package/lib/three.tsl-BtDRDR0q.mjs +0 -2
  87. package/lib/threejs-utils-C9zED_Tu.mjs.map +0 -1
@@ -1,10 +1,10 @@
1
1
  import { Ar as e, Bt as t, Ci as n, Di as r, E as i, Er as a, Gn as o, Hr as s, Mr as c, On as l, Qr as u, S as d, Si as f, U as p, Ur as m, V as h, Xr as g, Yt as _, Zr as v, ci as y, cn as b, ct as x, f as S, h as C, ht as w, jr as ee, kn as te, kr as ne, ln as re, m as ie, on as ae, qt as T, si as oe, sn as E, ui as D, vi as se, w as ce, wi as le, yn as ue } from "./three.core-0KaTx8dm.mjs";
2
2
  import { t as de } from "./Pass-DLiMLT5k.mjs";
3
3
  import { C as fe, Dt as pe, Fn as me, Gn as he, H as ge, Hn as O, Rn as k, Vn as _e, X as A, ln as ve, vt as ye } from "./three.webgpu-ylONY593.mjs";
4
- import { At as be, Ct as xe, Et as Se, F as Ce, I as we, Lt as Te, Nt as Ee, Rt as j, St as M, Tt as N, _t as P, bt as F, ct as De, k as Oe, kt as ke, w as Ae, wt as je } from "./three.tsl-BElp7_oF.mjs";
5
- var Me = 1.25, Ne = 65535;
6
- Ne << 16;
7
- var Pe = 2 ** -24, Fe = Symbol("SKIP_GENERATION"), Ie = {
4
+ import { At as be, Ct as j, Dt as xe, Et as M, I as Se, L as Ce, Pt as we, Rt as Te, Tt as Ee, jt as De, k as Oe, lt as ke, vt as N, w as Ae, wt as je, xt as Me, zt as P } from "./three.tsl-Dew9p5yF.mjs";
5
+ var Ne = 1.25, Pe = 65535;
6
+ Pe << 16;
7
+ var Fe = 2 ** -24, Ie = Symbol("SKIP_GENERATION"), Le = {
8
8
  strategy: 0,
9
9
  maxDepth: 40,
10
10
  targetLeafSize: 10,
@@ -14,14 +14,14 @@ var Pe = 2 ** -24, Fe = Symbol("SKIP_GENERATION"), Ie = {
14
14
  indirect: !1,
15
15
  verbose: !0,
16
16
  range: null,
17
- [Fe]: !1
17
+ [Ie]: !1
18
18
  };
19
19
  //#endregion
20
20
  //#region ../../node_modules/three-mesh-bvh/src/utils/ArrayBoxUtilities.js
21
- function I(e, t, n) {
21
+ function F(e, t, n) {
22
22
  return n.min.x = t[e], n.min.y = t[e + 1], n.min.z = t[e + 2], n.max.x = t[e + 3], n.max.y = t[e + 4], n.max.z = t[e + 5], n;
23
23
  }
24
- function Le(e) {
24
+ function Re(e) {
25
25
  let t = -1, n = -Infinity;
26
26
  for (let r = 0; r < 3; r++) {
27
27
  let i = e[r + 3] - e[r];
@@ -29,52 +29,52 @@ function Le(e) {
29
29
  }
30
30
  return t;
31
31
  }
32
- function Re(e, t) {
32
+ function ze(e, t) {
33
33
  t.set(e);
34
34
  }
35
- function ze(e, t, n) {
35
+ function Be(e, t, n) {
36
36
  let r, i;
37
37
  for (let a = 0; a < 3; a++) {
38
38
  let o = a + 3;
39
39
  r = e[a], i = t[a], n[a] = r < i ? r : i, r = e[o], i = t[o], n[o] = r > i ? r : i;
40
40
  }
41
41
  }
42
- function Be(e, t, n) {
42
+ function Ve(e, t, n) {
43
43
  for (let r = 0; r < 3; r++) {
44
44
  let i = t[e + 2 * r], a = t[e + 2 * r + 1], o = i - a, s = i + a;
45
45
  o < n[r] && (n[r] = o), s > n[r + 3] && (n[r + 3] = s);
46
46
  }
47
47
  }
48
- function Ve(e) {
48
+ function He(e) {
49
49
  let t = e[3] - e[0], n = e[4] - e[1], r = e[5] - e[2];
50
50
  return 2 * (t * n + n * r + r * t);
51
51
  }
52
52
  //#endregion
53
53
  //#region ../../node_modules/three-mesh-bvh/src/core/utils/nodeBufferUtils.js
54
- function L(e, t) {
55
- return t[e + 15] === Ne;
54
+ function I(e, t) {
55
+ return t[e + 15] === Pe;
56
56
  }
57
- function R(e, t) {
57
+ function L(e, t) {
58
58
  return t[e + 6];
59
59
  }
60
- function z(e, t) {
60
+ function R(e, t) {
61
61
  return t[e + 14];
62
62
  }
63
- function B(e) {
63
+ function z(e) {
64
64
  return e + 8;
65
65
  }
66
- function V(e, t) {
66
+ function B(e, t) {
67
67
  return e + t[e + 6] * 8;
68
68
  }
69
- function He(e, t) {
69
+ function Ue(e, t) {
70
70
  return t[e + 7];
71
71
  }
72
- function H(e) {
72
+ function V(e) {
73
73
  return e;
74
74
  }
75
75
  //#endregion
76
76
  //#region ../../node_modules/three-mesh-bvh/src/core/build/computeBoundsUtils.js
77
- function Ue(e, t, n, r, i) {
77
+ function We(e, t, n, r, i) {
78
78
  let a = Infinity, o = Infinity, s = Infinity, c = -Infinity, l = -Infinity, u = -Infinity, d = Infinity, f = Infinity, p = Infinity, m = -Infinity, h = -Infinity, g = -Infinity, _ = e.offset || 0;
79
79
  for (let r = (t - _) * 6, i = (t + n - _) * 6; r < i; r += 6) {
80
80
  let t = e[r + 0], n = e[r + 1], i = t - n, _ = t + n;
@@ -88,23 +88,23 @@ function Ue(e, t, n, r, i) {
88
88
  }
89
89
  //#endregion
90
90
  //#region ../../node_modules/three-mesh-bvh/src/core/build/splitUtils.js
91
- var We = 32, Ge = (e, t) => e.candidate - t.candidate, Ke = /* @__PURE__ */ Array(We).fill().map(() => ({
91
+ var Ge = 32, Ke = (e, t) => e.candidate - t.candidate, qe = /* @__PURE__ */ Array(Ge).fill().map(() => ({
92
92
  count: 0,
93
93
  bounds: new Float32Array(6),
94
94
  rightCacheBounds: new Float32Array(6),
95
95
  leftCacheBounds: new Float32Array(6),
96
96
  candidate: 0
97
- })), qe = /* @__PURE__ */ new Float32Array(6);
98
- function Je(e, t, n, r, i, a) {
97
+ })), Je = /* @__PURE__ */ new Float32Array(6);
98
+ function Ye(e, t, n, r, i, a) {
99
99
  let o = -1, s = 0;
100
- if (a === 0) o = Le(t), o !== -1 && (s = (t[o] + t[o + 3]) / 2);
101
- else if (a === 1) o = Le(e), o !== -1 && (s = Ye(n, r, i, o));
100
+ if (a === 0) o = Re(t), o !== -1 && (s = (t[o] + t[o + 3]) / 2);
101
+ else if (a === 1) o = Re(e), o !== -1 && (s = Xe(n, r, i, o));
102
102
  else if (a === 2) {
103
- let a = Ve(e), c = Me * i, l = n.offset || 0, u = (r - l) * 6, d = (r + i - l) * 6;
103
+ let a = He(e), c = Ne * i, l = n.offset || 0, u = (r - l) * 6, d = (r + i - l) * 6;
104
104
  for (let e = 0; e < 3; e++) {
105
- let r = t[e], l = (t[e + 3] - r) / We;
106
- if (i < We / 4) {
107
- let t = [...Ke];
105
+ let r = t[e], l = (t[e + 3] - r) / Ge;
106
+ if (i < Ge / 4) {
107
+ let t = [...qe];
108
108
  t.length = i;
109
109
  let r = 0;
110
110
  for (let i = u; i < d; i += 6, r++) {
@@ -112,9 +112,9 @@ function Je(e, t, n, r, i, a) {
112
112
  a.candidate = n[i + 2 * e], a.count = 0;
113
113
  let { bounds: o, leftCacheBounds: s, rightCacheBounds: c } = a;
114
114
  for (let e = 0; e < 3; e++) c[e] = Infinity, c[e + 3] = -Infinity, s[e] = Infinity, s[e + 3] = -Infinity, o[e] = Infinity, o[e + 3] = -Infinity;
115
- Be(i, n, o);
115
+ Ve(i, n, o);
116
116
  }
117
- t.sort(Ge);
117
+ t.sort(Ke);
118
118
  let l = i;
119
119
  for (let e = 0; e < l; e++) {
120
120
  let n = t[e];
@@ -124,45 +124,45 @@ function Je(e, t, n, r, i, a) {
124
124
  let i = n[r + 2 * e];
125
125
  for (let e = 0; e < l; e++) {
126
126
  let a = t[e];
127
- i >= a.candidate ? Be(r, n, a.rightCacheBounds) : (Be(r, n, a.leftCacheBounds), a.count++);
127
+ i >= a.candidate ? Ve(r, n, a.rightCacheBounds) : (Ve(r, n, a.leftCacheBounds), a.count++);
128
128
  }
129
129
  }
130
130
  for (let n = 0; n < l; n++) {
131
131
  let r = t[n], l = r.count, u = i - r.count, d = r.leftCacheBounds, f = r.rightCacheBounds, p = 0;
132
- l !== 0 && (p = Ve(d) / a);
132
+ l !== 0 && (p = He(d) / a);
133
133
  let m = 0;
134
- u !== 0 && (m = Ve(f) / a);
135
- let h = 1 + Me * (p * l + m * u);
134
+ u !== 0 && (m = He(f) / a);
135
+ let h = 1 + Ne * (p * l + m * u);
136
136
  h < c && (o = e, c = h, s = r.candidate);
137
137
  }
138
138
  } else {
139
- for (let e = 0; e < We; e++) {
140
- let t = Ke[e];
139
+ for (let e = 0; e < Ge; e++) {
140
+ let t = qe[e];
141
141
  t.count = 0, t.candidate = r + l + e * l;
142
142
  let n = t.bounds;
143
143
  for (let e = 0; e < 3; e++) n[e] = Infinity, n[e + 3] = -Infinity;
144
144
  }
145
145
  for (let t = u; t < d; t += 6) {
146
146
  let i = ~~((n[t + 2 * e] - r) / l);
147
- i >= We && (i = We - 1);
148
- let a = Ke[i];
149
- a.count++, Be(t, n, a.bounds);
147
+ i >= Ge && (i = Ge - 1);
148
+ let a = qe[i];
149
+ a.count++, Ve(t, n, a.bounds);
150
150
  }
151
- let t = Ke[We - 1];
152
- Re(t.bounds, t.rightCacheBounds);
153
- for (let e = We - 2; e >= 0; e--) {
154
- let t = Ke[e], n = Ke[e + 1];
155
- ze(t.bounds, n.rightCacheBounds, t.rightCacheBounds);
151
+ let t = qe[Ge - 1];
152
+ ze(t.bounds, t.rightCacheBounds);
153
+ for (let e = Ge - 2; e >= 0; e--) {
154
+ let t = qe[e], n = qe[e + 1];
155
+ Be(t.bounds, n.rightCacheBounds, t.rightCacheBounds);
156
156
  }
157
157
  let f = 0;
158
- for (let t = 0; t < We - 1; t++) {
159
- let n = Ke[t], r = n.count, l = n.bounds, u = Ke[t + 1].rightCacheBounds;
160
- r !== 0 && (f === 0 ? Re(l, qe) : ze(l, qe, qe)), f += r;
158
+ for (let t = 0; t < Ge - 1; t++) {
159
+ let n = qe[t], r = n.count, l = n.bounds, u = qe[t + 1].rightCacheBounds;
160
+ r !== 0 && (f === 0 ? ze(l, Je) : Be(l, Je, Je)), f += r;
161
161
  let d = 0, p = 0;
162
- f !== 0 && (d = Ve(qe) / a);
162
+ f !== 0 && (d = He(Je) / a);
163
163
  let m = i - f;
164
- m !== 0 && (p = Ve(u) / a);
165
- let h = 1 + Me * (d * f + p * m);
164
+ m !== 0 && (p = He(u) / a);
165
+ let h = 1 + Ne * (d * f + p * m);
166
166
  h < c && (o = e, c = h, s = n.candidate);
167
167
  }
168
168
  }
@@ -173,21 +173,21 @@ function Je(e, t, n, r, i, a) {
173
173
  pos: s
174
174
  };
175
175
  }
176
- function Ye(e, t, n, r) {
176
+ function Xe(e, t, n, r) {
177
177
  let i = 0, a = e.offset;
178
178
  for (let o = t, s = t + n; o < s; o++) i += e[(o - a) * 6 + r * 2];
179
179
  return i / n;
180
180
  }
181
181
  //#endregion
182
182
  //#region ../../node_modules/three-mesh-bvh/src/core/BVHNode.js
183
- var Xe = class {
183
+ var Ze = class {
184
184
  constructor() {
185
185
  this.boundingData = new Float32Array(6);
186
186
  }
187
187
  };
188
188
  //#endregion
189
189
  //#region ../../node_modules/three-mesh-bvh/src/core/build/sortUtils.js
190
- function Ze(e, t, n, r, i, a) {
190
+ function Qe(e, t, n, r, i, a) {
191
191
  let o = r, s = r + i - 1, c = a.pos, l = a.axis * 2, u = n.offset || 0;
192
192
  for (;;) {
193
193
  for (; o <= s && n[(o - u) * 6 + l] < c;) o++;
@@ -207,28 +207,28 @@ function Ze(e, t, n, r, i, a) {
207
207
  }
208
208
  //#endregion
209
209
  //#region ../../node_modules/three-mesh-bvh/src/core/build/buildUtils.js
210
- var Qe, $e, et, tt, nt = 2 ** 32;
211
- function rt(e) {
212
- return "count" in e ? 1 : 1 + rt(e.left) + rt(e.right);
210
+ var $e, et, tt, nt, rt = 2 ** 32;
211
+ function it(e) {
212
+ return "count" in e ? 1 : 1 + it(e.left) + it(e.right);
213
213
  }
214
- function it(e, t, n) {
215
- return Qe = new Float32Array(n), $e = new Uint32Array(n), et = new Uint16Array(n), tt = new Uint8Array(n), at(e, t);
214
+ function at(e, t, n) {
215
+ return $e = new Float32Array(n), et = new Uint32Array(n), tt = new Uint16Array(n), nt = new Uint8Array(n), ot(e, t);
216
216
  }
217
- function at(e, t) {
217
+ function ot(e, t) {
218
218
  let n = e / 4, r = e / 2, i = "count" in t, a = t.boundingData;
219
- for (let e = 0; e < 6; e++) Qe[n + e] = a[e];
220
- if (i) return t.buffer ? (tt.set(new Uint8Array(t.buffer), e), e + t.buffer.byteLength) : ($e[n + 6] = t.offset, et[r + 14] = t.count, et[r + 15] = Ne, e + 32);
219
+ for (let e = 0; e < 6; e++) $e[n + e] = a[e];
220
+ if (i) return t.buffer ? (nt.set(new Uint8Array(t.buffer), e), e + t.buffer.byteLength) : (et[n + 6] = t.offset, tt[r + 14] = t.count, tt[r + 15] = Pe, e + 32);
221
221
  {
222
- let { left: r, right: i, splitAxis: a } = t, o = at(e + 32, r), s = e / 32, c = o / 32 - s;
223
- if (c > nt) throw Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");
224
- return $e[n + 6] = c, $e[n + 7] = a, at(o, i);
222
+ let { left: r, right: i, splitAxis: a } = t, o = ot(e + 32, r), s = e / 32, c = o / 32 - s;
223
+ if (c > rt) throw Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");
224
+ return et[n + 6] = c, et[n + 7] = a, ot(o, i);
225
225
  }
226
226
  }
227
227
  //#endregion
228
228
  //#region ../../node_modules/three-mesh-bvh/src/core/build/buildTree.js
229
- function ot(e, t, n, r, i, a) {
230
- let { maxDepth: o, verbose: s, targetLeafSize: c, _strictLeafSize: l = Infinity, strategy: u, onProgress: d } = i, f = e.primitiveBuffer, p = e.primitiveBufferStride, m = new Float32Array(6), h = !1, g = new Xe();
231
- return Ue(t, n, r, g.boundingData, m), v(g, n, r, m), g;
229
+ function st(e, t, n, r, i, a) {
230
+ let { maxDepth: o, verbose: s, targetLeafSize: c, _strictLeafSize: l = Infinity, strategy: u, onProgress: d } = i, f = e.primitiveBuffer, p = e.primitiveBufferStride, m = new Float32Array(6), h = !1, g = new Ze();
231
+ return We(t, n, r, g.boundingData, m), v(g, n, r, m), g;
232
232
  function _(e) {
233
233
  d && d((e - a.offset) / a.count);
234
234
  }
@@ -236,31 +236,31 @@ function ot(e, t, n, r, i, a) {
236
236
  !h && a >= o && (h = !0, s && console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`));
237
237
  let d = r > l;
238
238
  if (r <= c && !d || a >= o) return _(n + r), e.offset = n, e.count = r, e;
239
- let g = Je(e.boundingData, i, t, n, r, u), y = g.axis === -1 ? -1 : Ze(f, p, t, n, r, g);
239
+ let g = Ye(e.boundingData, i, t, n, r, u), y = g.axis === -1 ? -1 : Qe(f, p, t, n, r, g);
240
240
  if (g.axis === -1 || y === n || y === n + r) {
241
241
  if (!d) return _(n + r), e.offset = n, e.count = r, e;
242
- g.axis = Math.max(0, Le(e.boundingData)), y = n + Math.max(1, Math.floor(r / 2));
242
+ g.axis = Math.max(0, Re(e.boundingData)), y = n + Math.max(1, Math.floor(r / 2));
243
243
  }
244
244
  e.splitAxis = g.axis;
245
- let b = new Xe(), x = n, S = y - n;
246
- e.left = b, Ue(t, x, S, b.boundingData, m), v(b, x, S, m, a + 1);
247
- let C = new Xe(), w = y, ee = r - S;
248
- return e.right = C, Ue(t, w, ee, C.boundingData, m), v(C, w, ee, m, a + 1), e;
245
+ let b = new Ze(), x = n, S = y - n;
246
+ e.left = b, We(t, x, S, b.boundingData, m), v(b, x, S, m, a + 1);
247
+ let C = new Ze(), w = y, ee = r - S;
248
+ return e.right = C, We(t, w, ee, C.boundingData, m), v(C, w, ee, m, a + 1), e;
249
249
  }
250
250
  }
251
- function st(e, t) {
251
+ function ct(e, t) {
252
252
  let n = t.useSharedArrayBuffer ? SharedArrayBuffer : ArrayBuffer, r = e.getRootRanges(t.range), i = r[0], a = r[r.length - 1], o = {
253
253
  offset: i.offset,
254
254
  count: a.offset + a.count - i.offset
255
255
  }, s = new Float32Array(6 * o.count);
256
256
  s.offset = o.offset, e.computePrimitiveBounds(o.offset, o.count, s), e._roots = r.map((r) => {
257
- let i = ot(e, s, r.offset, r.count, t, o), a = new n(32 * rt(i));
258
- return it(0, i, a), a;
257
+ let i = st(e, s, r.offset, r.count, t, o), a = new n(32 * it(i));
258
+ return at(0, i, a), a;
259
259
  });
260
260
  }
261
261
  //#endregion
262
262
  //#region ../../node_modules/three-mesh-bvh/src/utils/PrimitivePool.js
263
- var ct = class {
263
+ var lt = class {
264
264
  constructor(e) {
265
265
  this._getNewPrimitive = e, this._primitives = [];
266
266
  }
@@ -271,7 +271,7 @@ var ct = class {
271
271
  releasePrimitive(e) {
272
272
  this._primitives.push(e);
273
273
  }
274
- }, U = /* @__PURE__ */ new class {
274
+ }, H = /* @__PURE__ */ new class {
275
275
  constructor() {
276
276
  this.float32Array = null, this.uint16Array = null, this.uint32Array = null;
277
277
  let e = [], t = null;
@@ -281,103 +281,103 @@ var ct = class {
281
281
  t = null, this.float32Array = null, this.uint16Array = null, this.uint32Array = null, e.length !== 0 && this.setBuffer(e.pop());
282
282
  };
283
283
  }
284
- }(), lt, ut, dt = [], ft = /* @__PURE__ */ new ct(() => new S());
285
- function pt(e, t, n, r, i, a) {
286
- lt = ft.getPrimitive(), ut = ft.getPrimitive(), dt.push(lt, ut), U.setBuffer(e._roots[t]);
287
- let o = mt(0, e.geometry, n, r, i, a);
288
- U.clearBuffer(), ft.releasePrimitive(lt), ft.releasePrimitive(ut), dt.pop(), dt.pop();
289
- let s = dt.length;
290
- return s > 0 && (ut = dt[s - 1], lt = dt[s - 2]), o;
284
+ }(), ut, dt, ft = [], pt = /* @__PURE__ */ new lt(() => new S());
285
+ function mt(e, t, n, r, i, a) {
286
+ ut = pt.getPrimitive(), dt = pt.getPrimitive(), ft.push(ut, dt), H.setBuffer(e._roots[t]);
287
+ let o = ht(0, e.geometry, n, r, i, a);
288
+ H.clearBuffer(), pt.releasePrimitive(ut), pt.releasePrimitive(dt), ft.pop(), ft.pop();
289
+ let s = ft.length;
290
+ return s > 0 && (dt = ft[s - 1], ut = ft[s - 2]), o;
291
291
  }
292
- function mt(e, t, n, r, i = null, a = 0, o = 0) {
293
- let { float32Array: s, uint16Array: c, uint32Array: l } = U, u = e * 2;
294
- if (L(u, c)) {
295
- let t = R(e, l), n = z(u, c);
296
- return I(H(e), s, lt), r(t, n, !1, o, a + e / 8, lt);
292
+ function ht(e, t, n, r, i = null, a = 0, o = 0) {
293
+ let { float32Array: s, uint16Array: c, uint32Array: l } = H, u = e * 2;
294
+ if (I(u, c)) {
295
+ let t = L(e, l), n = R(u, c);
296
+ return F(V(e), s, ut), r(t, n, !1, o, a + e / 8, ut);
297
297
  } else {
298
- let u = B(e), d = V(e, l), f = u, p = d, m, h, g, _;
299
- if (i && (g = lt, _ = ut, I(H(f), s, g), I(H(p), s, _), m = i(g), h = i(_), h < m)) {
298
+ let u = z(e), d = B(e, l), f = u, p = d, m, h, g, _;
299
+ if (i && (g = ut, _ = dt, F(V(f), s, g), F(V(p), s, _), m = i(g), h = i(_), h < m)) {
300
300
  f = d, p = u;
301
301
  let e = m;
302
302
  m = h, h = e, g = _;
303
303
  }
304
- g || (g = lt, I(H(f), s, g));
305
- let v = L(f * 2, c), y = n(g, v, m, o + 1, a + f / 8), b;
304
+ g || (g = ut, F(V(f), s, g));
305
+ let v = I(f * 2, c), y = n(g, v, m, o + 1, a + f / 8), b;
306
306
  if (y === 2) {
307
307
  let e = w(f);
308
308
  b = r(e, ee(f) - e, !0, o + 1, a + f / 8, g);
309
- } else b = y && mt(f, t, n, r, i, a, o + 1);
309
+ } else b = y && ht(f, t, n, r, i, a, o + 1);
310
310
  if (b) return !0;
311
- _ = ut, I(H(p), s, _);
312
- let x = L(p * 2, c), S = n(_, x, h, o + 1, a + p / 8), C;
311
+ _ = dt, F(V(p), s, _);
312
+ let x = I(p * 2, c), S = n(_, x, h, o + 1, a + p / 8), C;
313
313
  if (S === 2) {
314
314
  let e = w(p);
315
315
  C = r(e, ee(p) - e, !0, o + 1, a + p / 8, _);
316
- } else C = S && mt(p, t, n, r, i, a, o + 1);
316
+ } else C = S && ht(p, t, n, r, i, a, o + 1);
317
317
  if (C) return !0;
318
318
  return !1;
319
319
  function w(e) {
320
- let { uint16Array: t, uint32Array: n } = U, r = e * 2;
321
- for (; !L(r, t);) e = B(e), r = e * 2;
322
- return R(e, n);
320
+ let { uint16Array: t, uint32Array: n } = H, r = e * 2;
321
+ for (; !I(r, t);) e = z(e), r = e * 2;
322
+ return L(e, n);
323
323
  }
324
324
  function ee(e) {
325
- let { uint16Array: t, uint32Array: n } = U, r = e * 2;
326
- for (; !L(r, t);) e = V(e, n), r = e * 2;
327
- return R(e, n) + z(r, t);
325
+ let { uint16Array: t, uint32Array: n } = H, r = e * 2;
326
+ for (; !I(r, t);) e = B(e, n), r = e * 2;
327
+ return L(e, n) + R(r, t);
328
328
  }
329
329
  }
330
330
  }
331
331
  //#endregion
332
332
  //#region ../../node_modules/three-mesh-bvh/src/core/cast/bvhcast.js
333
- var ht = /* @__PURE__ */ new U.constructor(), gt = /* @__PURE__ */ new U.constructor(), _t = /* @__PURE__ */ new ct(() => new S()), vt = /* @__PURE__ */ new S(), yt = /* @__PURE__ */ new S(), bt = /* @__PURE__ */ new S(), xt = /* @__PURE__ */ new S(), St = !1;
334
- function Ct(e, t, n, r) {
335
- if (St) throw Error("MeshBVH: Recursive calls to bvhcast not supported.");
336
- St = !0;
333
+ var gt = /* @__PURE__ */ new H.constructor(), _t = /* @__PURE__ */ new H.constructor(), vt = /* @__PURE__ */ new lt(() => new S()), yt = /* @__PURE__ */ new S(), bt = /* @__PURE__ */ new S(), xt = /* @__PURE__ */ new S(), St = /* @__PURE__ */ new S(), Ct = !1;
334
+ function wt(e, t, n, r) {
335
+ if (Ct) throw Error("MeshBVH: Recursive calls to bvhcast not supported.");
336
+ Ct = !0;
337
337
  let i = e._roots, a = t._roots, o, s = 0, c = 0, l = new E().copy(n).invert();
338
338
  for (let e = 0, t = i.length; e < t; e++) {
339
- ht.setBuffer(i[e]), c = 0;
340
- let t = _t.getPrimitive();
341
- I(H(0), ht.float32Array, t), t.applyMatrix4(l);
342
- for (let e = 0, i = a.length; e < i && (gt.setBuffer(a[e]), o = wt(0, 0, n, l, r, s, c, 0, 0, t), gt.clearBuffer(), c += a[e].byteLength / 32, !o); e++);
343
- if (_t.releasePrimitive(t), ht.clearBuffer(), s += i[e].byteLength / 32, o) break;
339
+ gt.setBuffer(i[e]), c = 0;
340
+ let t = vt.getPrimitive();
341
+ F(V(0), gt.float32Array, t), t.applyMatrix4(l);
342
+ for (let e = 0, i = a.length; e < i && (_t.setBuffer(a[e]), o = U(0, 0, n, l, r, s, c, 0, 0, t), _t.clearBuffer(), c += a[e].byteLength / 32, !o); e++);
343
+ if (vt.releasePrimitive(t), gt.clearBuffer(), s += i[e].byteLength / 32, o) break;
344
344
  }
345
- return St = !1, o;
345
+ return Ct = !1, o;
346
346
  }
347
- function wt(e, t, n, r, i, a = 0, o = 0, s = 0, c = 0, l = null, u = !1) {
347
+ function U(e, t, n, r, i, a = 0, o = 0, s = 0, c = 0, l = null, u = !1) {
348
348
  let d, f;
349
- u ? (d = gt, f = ht) : (d = ht, f = gt);
350
- let p = d.float32Array, m = d.uint32Array, h = d.uint16Array, g = f.float32Array, _ = f.uint32Array, v = f.uint16Array, y = e * 2, b = t * 2, x = L(y, h), S = L(b, v), C = !1;
351
- if (S && x) C = u ? i(R(t, _), z(t * 2, v), R(e, m), z(e * 2, h), c, o + t / 8, s, a + e / 8) : i(R(e, m), z(e * 2, h), R(t, _), z(t * 2, v), s, a + e / 8, c, o + t / 8);
349
+ u ? (d = _t, f = gt) : (d = gt, f = _t);
350
+ let p = d.float32Array, m = d.uint32Array, h = d.uint16Array, g = f.float32Array, _ = f.uint32Array, v = f.uint16Array, y = e * 2, b = t * 2, x = I(y, h), S = I(b, v), C = !1;
351
+ if (S && x) C = u ? i(L(t, _), R(t * 2, v), L(e, m), R(e * 2, h), c, o + t / 8, s, a + e / 8) : i(L(e, m), R(e * 2, h), L(t, _), R(t * 2, v), s, a + e / 8, c, o + t / 8);
352
352
  else if (S) {
353
- let l = _t.getPrimitive();
354
- I(H(t), g, l), l.applyMatrix4(n);
355
- let d = B(e), f = V(e, m);
356
- I(H(d), p, vt), I(H(f), p, yt);
357
- let h = l.intersectsBox(vt), _ = l.intersectsBox(yt);
358
- C = h && wt(t, d, r, n, i, o, a, c, s + 1, l, !u) || _ && wt(t, f, r, n, i, o, a, c, s + 1, l, !u), _t.releasePrimitive(l);
353
+ let l = vt.getPrimitive();
354
+ F(V(t), g, l), l.applyMatrix4(n);
355
+ let d = z(e), f = B(e, m);
356
+ F(V(d), p, yt), F(V(f), p, bt);
357
+ let h = l.intersectsBox(yt), _ = l.intersectsBox(bt);
358
+ C = h && U(t, d, r, n, i, o, a, c, s + 1, l, !u) || _ && U(t, f, r, n, i, o, a, c, s + 1, l, !u), vt.releasePrimitive(l);
359
359
  } else {
360
- let d = B(t), f = V(t, _);
361
- I(H(d), g, bt), I(H(f), g, xt);
362
- let h = l.intersectsBox(bt), v = l.intersectsBox(xt);
363
- if (h && v) C = wt(e, d, n, r, i, a, o, s, c + 1, l, u) || wt(e, f, n, r, i, a, o, s, c + 1, l, u);
364
- else if (h) if (x) C = wt(e, d, n, r, i, a, o, s, c + 1, l, u);
360
+ let d = z(t), f = B(t, _);
361
+ F(V(d), g, xt), F(V(f), g, St);
362
+ let h = l.intersectsBox(xt), v = l.intersectsBox(St);
363
+ if (h && v) C = U(e, d, n, r, i, a, o, s, c + 1, l, u) || U(e, f, n, r, i, a, o, s, c + 1, l, u);
364
+ else if (h) if (x) C = U(e, d, n, r, i, a, o, s, c + 1, l, u);
365
365
  else {
366
- let t = _t.getPrimitive();
367
- t.copy(bt).applyMatrix4(n);
368
- let l = B(e), f = V(e, m);
369
- I(H(l), p, vt), I(H(f), p, yt);
370
- let h = t.intersectsBox(vt), g = t.intersectsBox(yt);
371
- C = h && wt(d, l, r, n, i, o, a, c, s + 1, t, !u) || g && wt(d, f, r, n, i, o, a, c, s + 1, t, !u), _t.releasePrimitive(t);
366
+ let t = vt.getPrimitive();
367
+ t.copy(xt).applyMatrix4(n);
368
+ let l = z(e), f = B(e, m);
369
+ F(V(l), p, yt), F(V(f), p, bt);
370
+ let h = t.intersectsBox(yt), g = t.intersectsBox(bt);
371
+ C = h && U(d, l, r, n, i, o, a, c, s + 1, t, !u) || g && U(d, f, r, n, i, o, a, c, s + 1, t, !u), vt.releasePrimitive(t);
372
372
  }
373
- else if (v) if (x) C = wt(e, f, n, r, i, a, o, s, c + 1, l, u);
373
+ else if (v) if (x) C = U(e, f, n, r, i, a, o, s, c + 1, l, u);
374
374
  else {
375
- let t = _t.getPrimitive();
376
- t.copy(xt).applyMatrix4(n);
377
- let l = B(e), d = V(e, m);
378
- I(H(l), p, vt), I(H(d), p, yt);
379
- let h = t.intersectsBox(vt), g = t.intersectsBox(yt);
380
- C = h && wt(f, l, r, n, i, o, a, c, s + 1, t, !u) || g && wt(f, d, r, n, i, o, a, c, s + 1, t, !u), _t.releasePrimitive(t);
375
+ let t = vt.getPrimitive();
376
+ t.copy(St).applyMatrix4(n);
377
+ let l = z(e), d = B(e, m);
378
+ F(V(l), p, yt), F(V(d), p, bt);
379
+ let h = t.intersectsBox(yt), g = t.intersectsBox(bt);
380
+ C = h && U(f, l, r, n, i, o, a, c, s + 1, t, !u) || g && U(f, d, r, n, i, o, a, c, s + 1, t, !u), vt.releasePrimitive(t);
381
381
  }
382
382
  }
383
383
  return C;
@@ -394,17 +394,17 @@ var Tt = new class {
394
394
  this.root = null, this.buffer = e = null, this.uint16Array = n = null, this.uint32Array = t = null;
395
395
  }, this.getRangeStart = (e) => {
396
396
  let r = e * 2;
397
- for (; !L(r, n);) e = B(e), r = e * 2;
398
- return R(e, t);
397
+ for (; !I(r, n);) e = z(e), r = e * 2;
398
+ return L(e, t);
399
399
  }, this.getRangeEnd = (e) => {
400
400
  let r = e * 2;
401
- for (; !L(r, n);) e = V(e, t), r = e * 2;
402
- return R(e, t) + z(r, n);
401
+ for (; !I(r, n);) e = B(e, t), r = e * 2;
402
+ return L(e, t) + R(r, n);
403
403
  };
404
404
  let i = (e, r, a) => {
405
- let o = L(r * 2, n);
405
+ let o = I(r * 2, n);
406
406
  if (!e(a, o, r) && !o) {
407
- let n = B(r), o = V(r, t);
407
+ let n = z(r), o = B(r, t);
408
408
  i(e, n, a + 1), i(e, o, a + 1);
409
409
  }
410
410
  };
@@ -422,7 +422,7 @@ var Tt = new class {
422
422
  let s = o * 2, c = t[o + 6], l = n[s + 14];
423
423
  return r(i, a, new Float32Array(e, o * 4, 6), c, l);
424
424
  } else {
425
- let n = He(o, t);
425
+ let n = Ue(o, t);
426
426
  return r(i, a, new Float32Array(e, o * 4, 6), n);
427
427
  }
428
428
  });
@@ -434,12 +434,12 @@ var Tt = new class {
434
434
  }
435
435
  init(e) {
436
436
  e = {
437
- ...Ie,
437
+ ...Le,
438
438
  ...e
439
439
  }, "maxLeafSize" in e && (console.warn("BVH: \"maxLeafSize\" option has been deprecated. Use \"targetLeafSize\", instead."), e = {
440
440
  ...e,
441
441
  targetLeafSize: e.maxLeafSize
442
- }), st(this, e);
442
+ }), ct(this, e);
443
443
  }
444
444
  getRootRanges() {
445
445
  throw Error("BVH: getRootRanges() not implemented");
@@ -461,7 +461,7 @@ var Tt = new class {
461
461
  for (let i = e, a = e + t; i < a; i++) {
462
462
  this.writePrimitiveBounds(i, Dt, 0);
463
463
  let [e, t, a, o, s, c] = Dt, l = (e + o) / 2, u = (t + s) / 2, d = (a + c) / 2, f = (o - e) / 2, p = (s - t) / 2, m = (c - a) / 2, h = (i - r) * 6;
464
- n[h + 0] = l, n[h + 1] = f + (Math.abs(l) + f) * Pe, n[h + 2] = u, n[h + 3] = p + (Math.abs(u) + p) * Pe, n[h + 4] = d, n[h + 5] = m + (Math.abs(d) + m) * Pe;
464
+ n[h + 0] = l, n[h + 1] = f + (Math.abs(l) + f) * Fe, n[h + 2] = u, n[h + 3] = p + (Math.abs(u) + p) * Fe, n[h + 4] = d, n[h + 5] = m + (Math.abs(d) + m) * Fe;
465
465
  }
466
466
  return n;
467
467
  }
@@ -474,7 +474,7 @@ var Tt = new class {
474
474
  let r = t[n], i = new Uint32Array(r), a = new Uint16Array(r), o = r.byteLength / 32;
475
475
  for (let t = 0; t < o; t++) {
476
476
  let n = 8 * t;
477
- L(2 * n, a) && (i[n + 6] += e);
477
+ I(2 * n, a) && (i[n + 6] += e);
478
478
  }
479
479
  }
480
480
  }
@@ -488,11 +488,11 @@ var Tt = new class {
488
488
  let n = e[t], r = new Uint32Array(n), i = new Uint16Array(n), a = new Float32Array(n), o = n.byteLength / 32;
489
489
  for (let e = o - 1; e >= 0; e--) {
490
490
  let t = e * 8, n = t * 2;
491
- if (L(n, i)) {
492
- let e = R(t, r), o = z(n, i);
491
+ if (I(n, i)) {
492
+ let e = L(t, r), o = R(n, i);
493
493
  this.writePrimitiveRangeBounds(e, o, Dt, 0), a.set(Dt, t);
494
494
  } else {
495
- let e = B(t), n = V(t, r);
495
+ let e = z(t), n = B(t, r);
496
496
  for (let r = 0; r < 3; r++) {
497
497
  let i = a[e + r], o = a[e + r + 3], s = a[n + r], c = a[n + r + 3];
498
498
  a[t + r] = i < s ? i : s, a[t + r + 3] = o > c ? o : c;
@@ -503,7 +503,7 @@ var Tt = new class {
503
503
  }
504
504
  getBoundingBox(e) {
505
505
  return e.makeEmpty(), this._roots.forEach((t) => {
506
- I(0, new Float32Array(t), Et), e.union(Et);
506
+ F(0, new Float32Array(t), Et), e.union(Et);
507
507
  }), e;
508
508
  }
509
509
  shapecast(e) {
@@ -515,14 +515,14 @@ var Tt = new class {
515
515
  let s = !1, c = 0, l = this._roots;
516
516
  for (let e = 0, i = l.length; e < i; e++) {
517
517
  let i = l[e];
518
- if (s = pt(this, e, n, r, t, c), s) break;
518
+ if (s = mt(this, e, n, r, t, c), s) break;
519
519
  c += i.byteLength / 32;
520
520
  }
521
521
  return s;
522
522
  }
523
523
  bvhcast(e, t, n) {
524
524
  let { intersectsRanges: r } = n;
525
- return Ct(this, e, t, r);
525
+ return wt(this, e, t, r);
526
526
  }
527
527
  };
528
528
  //#endregion
@@ -617,9 +617,9 @@ var Rt = class extends Ot {
617
617
  if (e.index && e.index.isInterleavedBufferAttribute) throw Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");
618
618
  if (t.useSharedArrayBuffer && !kt()) throw Error("BVH: SharedArrayBuffer is not available.");
619
619
  super(), this.geometry = e, this.resolvePrimitiveIndex = t.indirect ? (e) => this._indirectBuffer[e] : (e) => e, this.primitiveBuffer = null, this.primitiveBufferStride = null, this._indirectBuffer = null, t = {
620
- ...Ie,
620
+ ...Le,
621
621
  ...t
622
- }, t[Fe] || this.init(t);
622
+ }, t[Ie] || this.init(t);
623
623
  }
624
624
  init(e) {
625
625
  let { geometry: t, primitiveStride: n } = this;
@@ -1031,7 +1031,7 @@ K.prototype.update = (function() {
1031
1031
  return Math.sqrt(p);
1032
1032
  };
1033
1033
  })();
1034
- var q = /* @__PURE__ */ new class extends ct {
1034
+ var q = /* @__PURE__ */ new class extends lt {
1035
1035
  constructor() {
1036
1036
  super(() => new G());
1037
1037
  }
@@ -1155,15 +1155,15 @@ function hn(e, t = null) {
1155
1155
  for (let e = 0, t = u.length; e < t; e++) a = u[e], o = new Uint32Array(a), s = new Uint16Array(a), c = new Float32Array(a), d(0, l), l += a.byteLength;
1156
1156
  function d(e, n, a = !1) {
1157
1157
  let l = e * 2;
1158
- if (L(l, s)) {
1159
- let t = R(e, o), n = z(l, s), a = Infinity, u = Infinity, d = Infinity, f = -Infinity, p = -Infinity, m = -Infinity;
1158
+ if (I(l, s)) {
1159
+ let t = L(e, o), n = R(l, s), a = Infinity, u = Infinity, d = Infinity, f = -Infinity, p = -Infinity, m = -Infinity;
1160
1160
  for (let e = 3 * t, o = 3 * (t + n); e < o; e++) {
1161
1161
  let t = r[e], n = i.getX(t), o = i.getY(t), s = i.getZ(t);
1162
1162
  n < a && (a = n), n > f && (f = n), o < u && (u = o), o > p && (p = o), s < d && (d = s), s > m && (m = s);
1163
1163
  }
1164
1164
  return c[e + 0] !== a || c[e + 1] !== u || c[e + 2] !== d || c[e + 3] !== f || c[e + 4] !== p || c[e + 5] !== m ? (c[e + 0] = a, c[e + 1] = u, c[e + 2] = d, c[e + 3] = f, c[e + 4] = p, c[e + 5] = m, !0) : !1;
1165
1165
  } else {
1166
- let r = B(e), i = V(e, o), s = a, l = !1, u = !1;
1166
+ let r = z(e), i = B(e, o), s = a, l = !1, u = !1;
1167
1167
  if (t) {
1168
1168
  if (!s) {
1169
1169
  let e = r / 8 + n / 32, a = i / 8 + n / 32;
@@ -1214,15 +1214,15 @@ function yn(e, t, n, r, i, a, o) {
1214
1214
  //#endregion
1215
1215
  //#region ../../node_modules/three-mesh-bvh/src/core/cast/raycast.generated.js
1216
1216
  function bn(e, t, n, r, i, a, o) {
1217
- U.setBuffer(e._roots[t]), xn(0, e, n, r, i, a, o), U.clearBuffer();
1217
+ H.setBuffer(e._roots[t]), xn(0, e, n, r, i, a, o), H.clearBuffer();
1218
1218
  }
1219
1219
  function xn(e, t, n, r, i, a, o) {
1220
- let { float32Array: s, uint16Array: c, uint32Array: l } = U, u = e * 2;
1221
- if (L(u, c)) fn(t, n, r, R(e, l), z(u, c), i, a, o);
1220
+ let { float32Array: s, uint16Array: c, uint32Array: l } = H, u = e * 2;
1221
+ if (I(u, c)) fn(t, n, r, L(e, l), R(u, c), i, a, o);
1222
1222
  else {
1223
- let c = B(e);
1223
+ let c = z(e);
1224
1224
  gn(c, s, r, a, o) && xn(c, t, n, r, i, a, o);
1225
- let u = V(e, l);
1225
+ let u = B(e, l);
1226
1226
  gn(u, s, r, a, o) && xn(u, t, n, r, i, a, o);
1227
1227
  }
1228
1228
  }
@@ -1234,16 +1234,16 @@ var Sn = [
1234
1234
  "z"
1235
1235
  ];
1236
1236
  function Cn(e, t, n, r, i, a) {
1237
- U.setBuffer(e._roots[t]);
1237
+ H.setBuffer(e._roots[t]);
1238
1238
  let o = wn(0, e, n, r, i, a);
1239
- return U.clearBuffer(), o;
1239
+ return H.clearBuffer(), o;
1240
1240
  }
1241
1241
  function wn(e, t, n, r, i, a) {
1242
- let { float32Array: o, uint16Array: s, uint32Array: c } = U, l = e * 2;
1243
- if (L(l, s)) return pn(t, n, r, R(e, c), z(l, s), i, a);
1242
+ let { float32Array: o, uint16Array: s, uint32Array: c } = H, l = e * 2;
1243
+ if (I(l, s)) return pn(t, n, r, L(e, c), R(l, s), i, a);
1244
1244
  {
1245
- let s = He(e, c), l = Sn[s], u = r.direction[l] >= 0, d, f;
1246
- u ? (d = B(e), f = V(e, c)) : (d = V(e, c), f = B(e));
1245
+ let s = Ue(e, c), l = Sn[s], u = r.direction[l] >= 0, d, f;
1246
+ u ? (d = z(e), f = B(e, c)) : (d = B(e, c), f = z(e));
1247
1247
  let p = gn(d, o, r, i, a) ? wn(d, t, n, r, i, a) : null;
1248
1248
  if (p) {
1249
1249
  let e = p.point[l];
@@ -1257,15 +1257,15 @@ function wn(e, t, n, r, i, a) {
1257
1257
  //#region ../../node_modules/three-mesh-bvh/src/core/cast/intersectsGeometry.generated.js
1258
1258
  var Tn = /* @__PURE__ */ new S(), En = /* @__PURE__ */ new G(), Dn = /* @__PURE__ */ new G(), On = /* @__PURE__ */ new E(), kn = /* @__PURE__ */ new K(), An = /* @__PURE__ */ new K();
1259
1259
  function jn(e, t, n, r) {
1260
- U.setBuffer(e._roots[t]);
1260
+ H.setBuffer(e._roots[t]);
1261
1261
  let i = Mn(0, e, n, r);
1262
- return U.clearBuffer(), i;
1262
+ return H.clearBuffer(), i;
1263
1263
  }
1264
1264
  function Mn(e, t, n, r, i = null) {
1265
- let { float32Array: a, uint16Array: o, uint32Array: s } = U, c = e * 2;
1266
- if (i === null && (n.boundingBox || n.computeBoundingBox(), kn.set(n.boundingBox.min, n.boundingBox.max, r), i = kn), L(c, o)) {
1267
- let i = t.geometry, l = i.index, u = i.attributes.position, d = n.index, f = n.attributes.position, p = R(e, s), m = z(c, o);
1268
- if (On.copy(r).invert(), n.boundsTree) return I(H(e), a, An), An.matrix.copy(On), An.needsUpdate = !0, n.boundsTree.shapecast({
1265
+ let { float32Array: a, uint16Array: o, uint32Array: s } = H, c = e * 2;
1266
+ if (i === null && (n.boundingBox || n.computeBoundingBox(), kn.set(n.boundingBox.min, n.boundingBox.max, r), i = kn), I(c, o)) {
1267
+ let i = t.geometry, l = i.index, u = i.attributes.position, d = n.index, f = n.attributes.position, p = L(e, s), m = R(c, o);
1268
+ if (On.copy(r).invert(), n.boundsTree) return F(V(e), a, An), An.matrix.copy(On), An.needsUpdate = !0, n.boundsTree.shapecast({
1269
1269
  intersectsBounds: (e) => An.intersectsBox(e),
1270
1270
  intersectsTriangle: (e) => {
1271
1271
  e.a.applyMatrix4(r), e.b.applyMatrix4(r), e.c.applyMatrix4(r), e.needsUpdate = !0;
@@ -1281,8 +1281,8 @@ function Mn(e, t, n, r, i = null) {
1281
1281
  }
1282
1282
  }
1283
1283
  } else {
1284
- let o = B(e), c = V(e, s);
1285
- return I(H(o), a, Tn), !!(i.intersectsBox(Tn) && Mn(o, t, n, r, i) || (I(H(c), a, Tn), i.intersectsBox(Tn) && Mn(c, t, n, r, i)));
1284
+ let o = z(e), c = B(e, s);
1285
+ return F(V(o), a, Tn), !!(i.intersectsBox(Tn) && Mn(o, t, n, r, i) || (F(V(c), a, Tn), i.intersectsBox(Tn) && Mn(c, t, n, r, i)));
1286
1286
  }
1287
1287
  }
1288
1288
  //#endregion
@@ -1333,8 +1333,8 @@ function Vn(e, t = null) {
1333
1333
  for (let e = 0, t = u.length; e < t; e++) a = u[e], o = new Uint32Array(a), s = new Uint16Array(a), c = new Float32Array(a), d(0, l), l += a.byteLength;
1334
1334
  function d(n, a, l = !1) {
1335
1335
  let u = n * 2;
1336
- if (L(u, s)) {
1337
- let t = R(n, o), a = z(u, s), l = Infinity, d = Infinity, f = Infinity, p = -Infinity, m = -Infinity, h = -Infinity;
1336
+ if (I(u, s)) {
1337
+ let t = L(n, o), a = R(u, s), l = Infinity, d = Infinity, f = Infinity, p = -Infinity, m = -Infinity, h = -Infinity;
1338
1338
  for (let n = t, o = t + a; n < o; n++) {
1339
1339
  let t = 3 * e.resolveTriangleIndex(n);
1340
1340
  for (let e = 0; e < 3; e++) {
@@ -1346,7 +1346,7 @@ function Vn(e, t = null) {
1346
1346
  }
1347
1347
  return c[n + 0] !== l || c[n + 1] !== d || c[n + 2] !== f || c[n + 3] !== p || c[n + 4] !== m || c[n + 5] !== h ? (c[n + 0] = l, c[n + 1] = d, c[n + 2] = f, c[n + 3] = p, c[n + 4] = m, c[n + 5] = h, !0) : !1;
1348
1348
  } else {
1349
- let e = B(n), r = V(n, o), i = l, s = !1, u = !1;
1349
+ let e = z(n), r = B(n, o), i = l, s = !1, u = !1;
1350
1350
  if (t) {
1351
1351
  if (!i) {
1352
1352
  let n = e / 8 + a / 32, o = r / 8 + a / 32;
@@ -1369,15 +1369,15 @@ function Vn(e, t = null) {
1369
1369
  //#endregion
1370
1370
  //#region ../../node_modules/three-mesh-bvh/src/core/cast/raycast_indirect.generated.js
1371
1371
  function Hn(e, t, n, r, i, a, o) {
1372
- U.setBuffer(e._roots[t]), Un(0, e, n, r, i, a, o), U.clearBuffer();
1372
+ H.setBuffer(e._roots[t]), Un(0, e, n, r, i, a, o), H.clearBuffer();
1373
1373
  }
1374
1374
  function Un(e, t, n, r, i, a, o) {
1375
- let { float32Array: s, uint16Array: c, uint32Array: l } = U, u = e * 2;
1376
- if (L(u, c)) _n(t, n, r, R(e, l), z(u, c), i, a, o);
1375
+ let { float32Array: s, uint16Array: c, uint32Array: l } = H, u = e * 2;
1376
+ if (I(u, c)) _n(t, n, r, L(e, l), R(u, c), i, a, o);
1377
1377
  else {
1378
- let c = B(e);
1378
+ let c = z(e);
1379
1379
  gn(c, s, r, a, o) && Un(c, t, n, r, i, a, o);
1380
- let u = V(e, l);
1380
+ let u = B(e, l);
1381
1381
  gn(u, s, r, a, o) && Un(u, t, n, r, i, a, o);
1382
1382
  }
1383
1383
  }
@@ -1389,16 +1389,16 @@ var Wn = [
1389
1389
  "z"
1390
1390
  ];
1391
1391
  function Gn(e, t, n, r, i, a) {
1392
- U.setBuffer(e._roots[t]);
1392
+ H.setBuffer(e._roots[t]);
1393
1393
  let o = Kn(0, e, n, r, i, a);
1394
- return U.clearBuffer(), o;
1394
+ return H.clearBuffer(), o;
1395
1395
  }
1396
1396
  function Kn(e, t, n, r, i, a) {
1397
- let { float32Array: o, uint16Array: s, uint32Array: c } = U, l = e * 2;
1398
- if (L(l, s)) return vn(t, n, r, R(e, c), z(l, s), i, a);
1397
+ let { float32Array: o, uint16Array: s, uint32Array: c } = H, l = e * 2;
1398
+ if (I(l, s)) return vn(t, n, r, L(e, c), R(l, s), i, a);
1399
1399
  {
1400
- let s = He(e, c), l = Wn[s], u = r.direction[l] >= 0, d, f;
1401
- u ? (d = B(e), f = V(e, c)) : (d = V(e, c), f = B(e));
1400
+ let s = Ue(e, c), l = Wn[s], u = r.direction[l] >= 0, d, f;
1401
+ u ? (d = z(e), f = B(e, c)) : (d = B(e, c), f = z(e));
1402
1402
  let p = gn(d, o, r, i, a) ? Kn(d, t, n, r, i, a) : null;
1403
1403
  if (p) {
1404
1404
  let e = p.point[l];
@@ -1412,15 +1412,15 @@ function Kn(e, t, n, r, i, a) {
1412
1412
  //#region ../../node_modules/three-mesh-bvh/src/core/cast/intersectsGeometry_indirect.generated.js
1413
1413
  var qn = /* @__PURE__ */ new S(), Jn = /* @__PURE__ */ new G(), Yn = /* @__PURE__ */ new G(), Xn = /* @__PURE__ */ new E(), Zn = /* @__PURE__ */ new K(), Qn = /* @__PURE__ */ new K();
1414
1414
  function $n(e, t, n, r) {
1415
- U.setBuffer(e._roots[t]);
1415
+ H.setBuffer(e._roots[t]);
1416
1416
  let i = er(0, e, n, r);
1417
- return U.clearBuffer(), i;
1417
+ return H.clearBuffer(), i;
1418
1418
  }
1419
1419
  function er(e, t, n, r, i = null) {
1420
- let { float32Array: a, uint16Array: o, uint32Array: s } = U, c = e * 2;
1421
- if (i === null && (n.boundingBox || n.computeBoundingBox(), Zn.set(n.boundingBox.min, n.boundingBox.max, r), i = Zn), L(c, o)) {
1422
- let i = t.geometry, l = i.index, u = i.attributes.position, d = n.index, f = n.attributes.position, p = R(e, s), m = z(c, o);
1423
- if (Xn.copy(r).invert(), n.boundsTree) return I(H(e), a, Qn), Qn.matrix.copy(Xn), Qn.needsUpdate = !0, n.boundsTree.shapecast({
1420
+ let { float32Array: a, uint16Array: o, uint32Array: s } = H, c = e * 2;
1421
+ if (i === null && (n.boundingBox || n.computeBoundingBox(), Zn.set(n.boundingBox.min, n.boundingBox.max, r), i = Zn), I(c, o)) {
1422
+ let i = t.geometry, l = i.index, u = i.attributes.position, d = n.index, f = n.attributes.position, p = L(e, s), m = R(c, o);
1423
+ if (Xn.copy(r).invert(), n.boundsTree) return F(V(e), a, Qn), Qn.matrix.copy(Xn), Qn.needsUpdate = !0, n.boundsTree.shapecast({
1424
1424
  intersectsBounds: (e) => Qn.intersectsBox(e),
1425
1425
  intersectsTriangle: (e) => {
1426
1426
  e.a.applyMatrix4(r), e.b.applyMatrix4(r), e.c.applyMatrix4(r), e.needsUpdate = !0;
@@ -1436,8 +1436,8 @@ function er(e, t, n, r, i = null) {
1436
1436
  }
1437
1437
  }
1438
1438
  } else {
1439
- let o = B(e), c = V(e, s);
1440
- return I(H(o), a, qn), !!(i.intersectsBox(qn) && er(o, t, n, r, i) || (I(H(c), a, qn), i.intersectsBox(qn) && er(c, t, n, r, i)));
1439
+ let o = z(e), c = B(e, s);
1440
+ return F(V(o), a, qn), !!(i.intersectsBox(qn) && er(o, t, n, r, i) || (F(V(c), a, qn), i.intersectsBox(qn) && er(c, t, n, r, i)));
1441
1441
  }
1442
1442
  }
1443
1443
  //#endregion
@@ -1517,7 +1517,7 @@ var ur = /* @__PURE__ */ new K(), dr = /* @__PURE__ */ new a(), fr = /* @__PURE_
1517
1517
  t.version || (console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."), c(a));
1518
1518
  let s = new e(n, {
1519
1519
  ...r,
1520
- [Fe]: !0
1520
+ [Ie]: !0
1521
1521
  });
1522
1522
  if (s._roots = a, s._indirectBuffer = o || null, r.setIndex) {
1523
1523
  let e = n.getIndex();
@@ -1532,7 +1532,7 @@ var ur = /* @__PURE__ */ new K(), dr = /* @__PURE__ */ new a(), fr = /* @__PURE_
1532
1532
  let n = e[t], r = new Uint32Array(n), i = new Uint16Array(n);
1533
1533
  for (let e = 0, t = n.byteLength / 32; e < t; e++) {
1534
1534
  let t = 8 * e;
1535
- L(2 * t, i) || (r[t + 6] = r[t + 6] / 8 - e);
1535
+ I(2 * t, i) || (r[t + 6] = r[t + 6] / 8 - e);
1536
1536
  }
1537
1537
  }
1538
1538
  }
@@ -1584,7 +1584,7 @@ var ur = /* @__PURE__ */ new K(), dr = /* @__PURE__ */ new a(), fr = /* @__PURE_
1584
1584
  let u = r;
1585
1585
  i > u && (u = i), o > u && (u = o);
1586
1586
  let f = (u - l) / 2, g = e * 2;
1587
- n[t + g + 0] = l + f, n[t + g + 1] = f + (Math.abs(l) + f) * Pe;
1587
+ n[t + g + 0] = l + f, n[t + g + 1] = f + (Math.abs(l) + f) * Fe;
1588
1588
  }
1589
1589
  }
1590
1590
  return n;
@@ -1850,8 +1850,8 @@ var Ar = /* @__PURE__ */ new n(), jr = /* @__PURE__ */ new n(), Mr = /* @__PURE_
1850
1850
  if (!e.isMesh) throw Error("SkinnedMeshBVH: First argument must be a Mesh.");
1851
1851
  super(e.geometry, {
1852
1852
  ...t,
1853
- [Fe]: !0
1854
- }), this.mesh = e, t[Fe] || this.init(t);
1853
+ [Ie]: !0
1854
+ }), this.mesh = e, t[Ie] || this.init(t);
1855
1855
  }
1856
1856
  writePrimitiveBounds(e, t, n) {
1857
1857
  let { mesh: r, geometry: i } = this, a = this._indirectBuffer, o = i.index ? i.index.array : null, s = (a ? a[e] : e) * 3, c = s + 0, l = s + 1, u = s + 2;
@@ -2082,7 +2082,7 @@ function ci(e, t, n, r, i, a = !1) {
2082
2082
  u += e, t += e;
2083
2083
  }
2084
2084
  o[h + 14] = t;
2085
- } else s[m + 6] = d[f + 6] + t, o[h + 14] = i[p + 14], o[h + 15] = Ne;
2085
+ } else s[m + 6] = d[f + 6] + t, o[h + 14] = i[p + 14], o[h + 15] = Pe;
2086
2086
  else s[m + 6] = d[f + 6], s[m + 7] = d[f + 7];
2087
2087
  r++;
2088
2088
  }
@@ -2214,7 +2214,7 @@ var yi = class extends ge {
2214
2214
  for (let t in e) typeof e[t] == "string" && (e[t] = new fi(e[t]));
2215
2215
  }
2216
2216
  return e.call(...t);
2217
- }, e), $ = (e, ...t) => xi(new yi(e, t)), Si = (e, ...t) => new bi(e, t), Ci = je(60);
2217
+ }, e), $ = (e, ...t) => xi(new yi(e, t)), Si = (e, ...t) => new bi(e, t), Ci = Ee(60);
2218
2218
  //#endregion
2219
2219
  //#region ../../node_modules/three-gpu-pathtracer/src/webgpu/lib/three-mesh-bvh/shapecastFns/getShapecastFn.js
2220
2220
  function wi(e, t) {
@@ -2604,7 +2604,7 @@ function ki(e) {
2604
2604
  //#endregion
2605
2605
  //#region ../../node_modules/three-gpu-pathtracer/src/webgpu/lib/three-mesh-bvh/shapecastFns/getClosestPointToPointFn.js
2606
2606
  function Ai(e) {
2607
- let { index: t, attributes: n, transforms: r } = e.storage, i = we().toVar("bvh_toWorldMat");
2607
+ let { index: t, attributes: n, transforms: r } = e.storage, i = Ce().toVar("bvh_toWorldMat");
2608
2608
  return e.getShapecastFn({
2609
2609
  name: "bvh_ClosestPointToPoint",
2610
2610
  shapeStruct: "vec3f",
@@ -2786,7 +2786,7 @@ var Fi = class {
2786
2786
  i.forEach((e, t) => {
2787
2787
  Mi.copy(n.matrixWorld).invert(), this.writeTransformData(e, Mi, t, g);
2788
2788
  });
2789
- let _ = P(new me(new Uint32Array(h), 1), Yr).toReadOnly().setName("bvh_nodes"), v = P(new me(new Uint32Array(g), 1), t.transform).toReadOnly().setName("bvh_transforms"), y = P(new me(p, 1), "uint").toReadOnly().setName("bvh_index"), b = P(new me(new Uint32Array(m), l.getLength()), l).toReadOnly().setName("bvh_attributes");
2789
+ let _ = N(new me(new Uint32Array(h), 1), Yr).toReadOnly().setName("bvh_nodes"), v = N(new me(new Uint32Array(g), 1), t.transform).toReadOnly().setName("bvh_transforms"), y = N(new me(p, 1), "uint").toReadOnly().setName("bvh_index"), b = N(new me(new Uint32Array(m), l.getLength()), l).toReadOnly().setName("bvh_attributes");
2790
2790
  this.storage.transforms = v, this.storage.nodes = _, this.storage.index = y, this.storage.attributes = b, this.structs.attributes = l, this.fns.sampleTrianglePoint = ki(this), this._bvhCache.clear();
2791
2791
  }
2792
2792
  writeTransformData(e, t, n, r) {
@@ -2844,7 +2844,7 @@ var Fi = class {
2844
2844
  }
2845
2845
  });
2846
2846
  }
2847
- }, Li = j("\n fn sampleTexel( tex: texture_2d<f32>, coord: vec2f ) -> vec4f {\n\n // Manual bilinear filtering using textureLoad to support filterable float32 textures\n // on all devices\n let size = vec2f( textureDimensions( tex, 0 ) );\n let pxCoord = coord * size - 0.5;\n let px = vec2i( floor( pxCoord ) );\n let fr = fract( pxCoord );\n\n // get the four sibling samples\n let s00 = textureLoad( tex, clamp( px, vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s10 = textureLoad( tex, clamp( px + vec2i( 1, 0 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s01 = textureLoad( tex, clamp( px + vec2i( 0, 1 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s11 = textureLoad( tex, clamp( px + vec2i( 1, 1 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n\n // interpolate on the x axis\n let y0 = mix( s00, s10, fr.x );\n let y1 = mix( s01, s11, fr.x );\n\n // then y\n return mix( y0, y1, fr.y );\n\n }\n"), Ri = class extends ye {
2847
+ }, Li = P("\n fn sampleTexel( tex: texture_2d<f32>, coord: vec2f ) -> vec4f {\n\n // Manual bilinear filtering using textureLoad to support filterable float32 textures\n // on all devices\n let size = vec2f( textureDimensions( tex, 0 ) );\n let pxCoord = coord * size - 0.5;\n let px = vec2i( floor( pxCoord ) );\n let fr = fract( pxCoord );\n\n // get the four sibling samples\n let s00 = textureLoad( tex, clamp( px, vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s10 = textureLoad( tex, clamp( px + vec2i( 1, 0 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s01 = textureLoad( tex, clamp( px + vec2i( 0, 1 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n let s11 = textureLoad( tex, clamp( px + vec2i( 1, 1 ), vec2i( 0 ), vec2i( size ) - 1 ), 0 );\n\n // interpolate on the x axis\n let y0 = mix( s00, s10, fr.x );\n let y1 = mix( s01, s11, fr.x );\n\n // then y\n return mix( y0, y1, fr.y );\n\n }\n"), Ri = class extends ye {
2848
2848
  get texture() {
2849
2849
  return this._texNode.value;
2850
2850
  }
@@ -2877,13 +2877,13 @@ var Fi = class {
2877
2877
  }
2878
2878
  constructor(e) {
2879
2879
  super();
2880
- let t = F(new k());
2880
+ let t = Me(new k());
2881
2881
  this._texNode = t;
2882
- let n = F(new k());
2882
+ let n = Me(new k());
2883
2883
  this._fromTexNode = n;
2884
- let r = be(ke()), i = N(1);
2884
+ let r = De(be()), i = M(1);
2885
2885
  this._transitionUniform = i;
2886
- let a = xe(0, 1, $`
2886
+ let a = je(0, 1, $`
2887
2887
  fn fade( uv: vec2f ) -> vec4f {
2888
2888
 
2889
2889
  if ( ${i} <= 0.0 ) {
@@ -2904,7 +2904,7 @@ var Fi = class {
2904
2904
 
2905
2905
  }
2906
2906
  `(r));
2907
- this._toneMapping = a, this.transparent = !0, this.colorNode = Ee(a.rgb, a.a), this.setValues(e);
2907
+ this._toneMapping = a, this.transparent = !0, this.colorNode = we(a.rgb, a.a), this.setValues(e);
2908
2908
  }
2909
2909
  }, zi = class {
2910
2910
  get computeNode() {
@@ -2945,12 +2945,12 @@ var Fi = class {
2945
2945
  return r.length = 3, r[0] = Math.ceil(e / i), r[1] = Math.ceil(t / a), r[2] = Math.ceil(n / o), r;
2946
2946
  }
2947
2947
  }, Bi = Te("\n\n struct PcgState {\n s0: vec4u,\n s1: vec4u,\n };\n\n var<private> g_state: PcgState;\n");
2948
- j("\n fn pcgInitialize( pixelIndex: u32, pathIndex: u32, bounceIndex: u32 ) -> void {\n let pixel = vec2( ( pixelIndex >> 16 ) & 0xFF, pixelIndex & 0xFF );\n\n //white noise seed\n g_state.s0 = vec4u( pixel | vec2( bounceIndex << 16 ), pathIndex, pixel.x + pixel.y);\n\n //blue noise seed\n g_state.s1 = vec4u(pathIndex, pathIndex*15843, pathIndex*31 + 4566, pathIndex*2345 + 58585);\n\n }\n", [Bi]);
2949
- var Vi = j("\n fn pcg4d(v: ptr<private, vec4u>) -> void {\n *v = *v * 1664525u + 1013904223u;\n *v = *v + v.yzxy * v.wxyz;\n *v = *v ^ (*v >> vec4u(16u));\n *v = *v + v.yzxy * v.wxyz;\n }\n");
2950
- j("\n fn pcgRand( _id: u32 ) -> f32 {\n pcg4d(&g_state.s0);\n return abs( f32( g_state.s0.x ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), j("\n fn pcgRand2( _id: u32 ) -> vec2f {\n pcg4d(&g_state.s0);\n return abs( vec2f( g_state.s0.xy ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), j("\n fn pcgRand3( _id: u32 ) -> vec3f {\n pcg4d(&g_state.s0);\n return abs( vec3f( g_state.s0.xyz ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), j("\n fn pcgRand4( _id: u32 ) -> vec4f {\n pcg4d(&g_state.s0);\n return abs( vec4f( g_state.s0 ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), j("fn noop() -> void {}");
2951
- var Hi = je(256 * 256), Ui = Ae(1 / 16777216), Wi = Te("\n\n const SOBOL_DIRECTIONS_1 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0xa0000000u, 0xf0000000u,\n 0x88000000u, 0xcc000000u, 0xaa000000u, 0xff000000u,\n 0x80800000u, 0xc0c00000u, 0xa0a00000u, 0xf0f00000u,\n 0x88880000u, 0xcccc0000u, 0xaaaa0000u, 0xffff0000u,\n 0x80008000u, 0xc000c000u, 0xa000a000u, 0xf000f000u,\n 0x88008800u, 0xcc00cc00u, 0xaa00aa00u, 0xff00ff00u,\n 0x80808080u, 0xc0c0c0c0u, 0xa0a0a0a0u, 0xf0f0f0f0u,\n 0x88888888u, 0xccccccccu, 0xaaaaaaaau, 0xffffffffu\n );\n\n const SOBOL_DIRECTIONS_2 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0x60000000u, 0x90000000u,\n 0xe8000000u, 0x5c000000u, 0x8e000000u, 0xc5000000u,\n 0x68800000u, 0x9cc00000u, 0xee600000u, 0x55900000u,\n 0x80680000u, 0xc09c0000u, 0x60ee0000u, 0x90550000u,\n 0xe8808000u, 0x5cc0c000u, 0x8e606000u, 0xc5909000u,\n 0x6868e800u, 0x9c9c5c00u, 0xeeee8e00u, 0x5555c500u,\n 0x8000e880u, 0xc0005cc0u, 0x60008e60u, 0x9000c590u,\n 0xe8006868u, 0x5c009c9cu, 0x8e00eeeeu, 0xc5005555u\n );\n\n const SOBOL_DIRECTIONS_3 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0x20000000u, 0x50000000u,\n 0xf8000000u, 0x74000000u, 0xa2000000u, 0x93000000u,\n 0xd8800000u, 0x25400000u, 0x59e00000u, 0xe6d00000u,\n 0x78080000u, 0xb40c0000u, 0x82020000u, 0xc3050000u,\n 0x208f8000u, 0x51474000u, 0xfbea2000u, 0x75d93000u,\n 0xa0858800u, 0x914e5400u, 0xdbe79e00u, 0x25db6d00u,\n 0x58800080u, 0xe54000c0u, 0x79e00020u, 0xb6d00050u,\n 0x800800f8u, 0xc00c0074u, 0x200200a2u, 0x50050093u\n );\n\n const SOBOL_DIRECTIONS_4 = array<u32, 32>(\n 0x80000000u, 0x40000000u, 0x20000000u, 0xb0000000u,\n 0xf8000000u, 0xdc000000u, 0x7a000000u, 0x9d000000u,\n 0x5a800000u, 0x2fc00000u, 0xa1600000u, 0xf0b00000u,\n 0xda880000u, 0x6fc40000u, 0x81620000u, 0x40bb0000u,\n 0x22878000u, 0xb3c9c000u, 0xfb65a000u, 0xddb2d000u,\n 0x78022800u, 0x9c0b3c00u, 0x5a0fb600u, 0x2d0ddb00u,\n 0xa2878080u, 0xf3c9c040u, 0xdb65a020u, 0x6db2d0b0u,\n 0x800228f8u, 0x400b3cdcu, 0x200fb67au, 0xb00ddb9du\n );\n\n"), Gi = je(0).toVar("sobolPixelIndex"), Ki = je(0).toVar("sobolPathIndex"), qi = je(0).toVar("sobolBounceIndex"), Ji = j("\n\n fn getMaskedSobol( index: u32, directions: array<u32, 32> ) -> u32 {\n\n var X = 0u;\n for ( var bit = 0u; bit < 32u; bit ++ ) {\n\n let mask = ( index >> bit ) & 1u;\n X ^= mask * directions[ bit ];\n\n }\n return X;\n\n }\n\n"), Yi = (e = 1) => {
2948
+ P("\n fn pcgInitialize( pixelIndex: u32, pathIndex: u32, bounceIndex: u32 ) -> void {\n let pixel = vec2( ( pixelIndex >> 16 ) & 0xFF, pixelIndex & 0xFF );\n\n //white noise seed\n g_state.s0 = vec4u( pixel | vec2( bounceIndex << 16 ), pathIndex, pixel.x + pixel.y);\n\n //blue noise seed\n g_state.s1 = vec4u(pathIndex, pathIndex*15843, pathIndex*31 + 4566, pathIndex*2345 + 58585);\n\n }\n", [Bi]);
2949
+ var Vi = P("\n fn pcg4d(v: ptr<private, vec4u>) -> void {\n *v = *v * 1664525u + 1013904223u;\n *v = *v + v.yzxy * v.wxyz;\n *v = *v ^ (*v >> vec4u(16u));\n *v = *v + v.yzxy * v.wxyz;\n }\n");
2950
+ P("\n fn pcgRand( _id: u32 ) -> f32 {\n pcg4d(&g_state.s0);\n return abs( f32( g_state.s0.x ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), P("\n fn pcgRand2( _id: u32 ) -> vec2f {\n pcg4d(&g_state.s0);\n return abs( vec2f( g_state.s0.xy ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), P("\n fn pcgRand3( _id: u32 ) -> vec3f {\n pcg4d(&g_state.s0);\n return abs( vec3f( g_state.s0.xyz ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), P("\n fn pcgRand4( _id: u32 ) -> vec4f {\n pcg4d(&g_state.s0);\n return abs( vec4f( g_state.s0 ) / f32(0xffffffffu) );\n }\n", [Vi, Bi]), P("fn noop() -> void {}");
2951
+ var Hi = Ee(256 * 256), Ui = Ae(1 / 16777216), Wi = Te("\n\n const SOBOL_DIRECTIONS_1 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0xa0000000u, 0xf0000000u,\n 0x88000000u, 0xcc000000u, 0xaa000000u, 0xff000000u,\n 0x80800000u, 0xc0c00000u, 0xa0a00000u, 0xf0f00000u,\n 0x88880000u, 0xcccc0000u, 0xaaaa0000u, 0xffff0000u,\n 0x80008000u, 0xc000c000u, 0xa000a000u, 0xf000f000u,\n 0x88008800u, 0xcc00cc00u, 0xaa00aa00u, 0xff00ff00u,\n 0x80808080u, 0xc0c0c0c0u, 0xa0a0a0a0u, 0xf0f0f0f0u,\n 0x88888888u, 0xccccccccu, 0xaaaaaaaau, 0xffffffffu\n );\n\n const SOBOL_DIRECTIONS_2 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0x60000000u, 0x90000000u,\n 0xe8000000u, 0x5c000000u, 0x8e000000u, 0xc5000000u,\n 0x68800000u, 0x9cc00000u, 0xee600000u, 0x55900000u,\n 0x80680000u, 0xc09c0000u, 0x60ee0000u, 0x90550000u,\n 0xe8808000u, 0x5cc0c000u, 0x8e606000u, 0xc5909000u,\n 0x6868e800u, 0x9c9c5c00u, 0xeeee8e00u, 0x5555c500u,\n 0x8000e880u, 0xc0005cc0u, 0x60008e60u, 0x9000c590u,\n 0xe8006868u, 0x5c009c9cu, 0x8e00eeeeu, 0xc5005555u\n );\n\n const SOBOL_DIRECTIONS_3 = array<u32, 32>(\n 0x80000000u, 0xc0000000u, 0x20000000u, 0x50000000u,\n 0xf8000000u, 0x74000000u, 0xa2000000u, 0x93000000u,\n 0xd8800000u, 0x25400000u, 0x59e00000u, 0xe6d00000u,\n 0x78080000u, 0xb40c0000u, 0x82020000u, 0xc3050000u,\n 0x208f8000u, 0x51474000u, 0xfbea2000u, 0x75d93000u,\n 0xa0858800u, 0x914e5400u, 0xdbe79e00u, 0x25db6d00u,\n 0x58800080u, 0xe54000c0u, 0x79e00020u, 0xb6d00050u,\n 0x800800f8u, 0xc00c0074u, 0x200200a2u, 0x50050093u\n );\n\n const SOBOL_DIRECTIONS_4 = array<u32, 32>(\n 0x80000000u, 0x40000000u, 0x20000000u, 0xb0000000u,\n 0xf8000000u, 0xdc000000u, 0x7a000000u, 0x9d000000u,\n 0x5a800000u, 0x2fc00000u, 0xa1600000u, 0xf0b00000u,\n 0xda880000u, 0x6fc40000u, 0x81620000u, 0x40bb0000u,\n 0x22878000u, 0xb3c9c000u, 0xfb65a000u, 0xddb2d000u,\n 0x78022800u, 0x9c0b3c00u, 0x5a0fb600u, 0x2d0ddb00u,\n 0xa2878080u, 0xf3c9c040u, 0xdb65a020u, 0x6db2d0b0u,\n 0x800228f8u, 0x400b3cdcu, 0x200fb67au, 0xb00ddb9du\n );\n\n"), Gi = Ee(0).toVar("sobolPixelIndex"), Ki = Ee(0).toVar("sobolPathIndex"), qi = Ee(0).toVar("sobolBounceIndex"), Ji = P("\n\n fn getMaskedSobol( index: u32, directions: array<u32, 32> ) -> u32 {\n\n var X = 0u;\n for ( var bit = 0u; bit < 32u; bit ++ ) {\n\n let mask = ( index >> bit ) & 1u;\n X ^= mask * directions[ bit ];\n\n }\n return X;\n\n }\n\n"), Yi = (e = 1) => {
2952
2952
  if (e <= 0) return;
2953
- let t = e > 1 ? `vec${e}u` : "u32", n = j(`
2953
+ let t = e > 1 ? `vec${e}u` : "u32", n = P(`
2954
2954
 
2955
2955
  fn sobolReverseBits_${t}( in: ${t} ) -> ${t} {
2956
2956
 
@@ -2963,7 +2963,7 @@ var Hi = je(256 * 256), Ui = Ae(1 / 16777216), Wi = Te("\n\n const SOBOL_DIRECTI
2963
2963
 
2964
2964
  }
2965
2965
 
2966
- `), r = j(`
2966
+ `), r = P(`
2967
2967
 
2968
2968
  fn sobolHashCombine_${t}( seed: u32, v: ${t} ) -> ${t} {
2969
2969
 
@@ -2971,7 +2971,7 @@ var Hi = je(256 * 256), Ui = Ae(1 / 16777216), Wi = Te("\n\n const SOBOL_DIRECTI
2971
2971
 
2972
2972
  }
2973
2973
 
2974
- `), i = j(`
2974
+ `), i = P(`
2975
2975
 
2976
2976
  fn sobolLaineKarrasPermutation_${t}( in: ${t}, seed: ${t} ) -> ${t} {
2977
2977
 
@@ -3026,7 +3026,7 @@ var Hi = je(256 * 256), Ui = Ae(1 / 16777216), Wi = Te("\n\n const SOBOL_DIRECTI
3026
3026
 
3027
3027
  }
3028
3028
 
3029
- `, Qi = j("\n\n fn sobolHash( in: u32 ) -> u32 {\n\n var x = in;\n // finalizer from murmurhash3\n x ^= x >> 16;\n x *= 0x85ebca6bu;\n x ^= x >> 13;\n x *= 0xc2b2ae35u;\n x ^= x >> 16;\n return x;\n\n }\n\n"), $i = $`
3029
+ `, Qi = P("\n\n fn sobolHash( in: u32 ) -> u32 {\n\n var x = in;\n // finalizer from murmurhash3\n x ^= x >> 16;\n x *= 0x85ebca6bu;\n x ^= x >> 13;\n x *= 0xc2b2ae35u;\n x ^= x >> 16;\n return x;\n\n }\n\n"), $i = $`
3030
3030
 
3031
3031
  fn sobolGetSeed( effect: u32 ) -> u32 {
3032
3032
 
@@ -3203,7 +3203,7 @@ var ra = $`
3203
3203
  VdotNc: "float",
3204
3204
  LdotNc: "float",
3205
3205
  HdotNc: "float"
3206
- }, "BxDFContext"), fa = j("\n\n fn inverse(m: mat3x3f) -> mat3x3f {\n var adj: mat3x3f;\n adj[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]);\n adj[1][0] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);\n adj[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]);\n adj[0][1] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);\n adj[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]);\n adj[2][1] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);\n adj[0][2] = (m[0][1] * m[1][2] - m[1][1] * m[0][2]);\n adj[1][2] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);\n adj[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]);\n\n let det = ( m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])\n - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])\n + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]));\n\n return adj * ( 1.0 / det );\n }\n\n"), pa = j("\n\n fn getBasisFromNormal( normal: vec3f ) -> mat3x3f {\n\n var other: vec3f;\n if ( abs( normal.x ) > 0.5 ) {\n\n other = vec3f( 0.0, 1.0, 0.0 );\n\n } else {\n\n other = vec3f( 1.0, 0.0, 0.0 );\n\n }\n\n let ortho = normalize( cross( normal, other ) );\n let ortho2 = normalize( cross( normal, ortho ) );\n return mat3x3f( ortho2, ortho, normal );\n\n }\n\n"), ma = j("\n\n fn iorToF0( ior: f32 ) -> f32 {\n return pow( ( 1 - ior ) / ( 1 + ior ), 2 );\n }\n\n"), ha = j("\n\n fn iorToF0General( transmittedIor: f32, incidentIor: f32 ) -> f32 {\n\n return pow( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ), 2 );\n\n }\n\n"), ga = j("\n\n fn iorToF0GeneralVec( transmittedIor: vec3f, incidentIor: vec3f ) -> vec3f {\n\n let v = ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor );\n return v * v;\n\n }\n\n"), _a = j("\n\n fn fresnel0ToIor( f0: vec3f ) -> vec3f {\n\n let sqrtF0 = sqrt( f0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\n }\n\n"), va = j("\n\n fn schlickFresnel( cosine: f32, f0: f32 ) -> f32 {\n\n return f0 + ( 1.0 - f0 ) * pow( 1.0 - cosine, 5.0 );\n\n }\n\n"), ya = j("\n\n fn schlickFresnelVec( cosine: f32, f0: vec3f, f90: vec3f ) -> vec3f {\n\n return f0 + ( f90 - f0 ) * pow( 1.0 - cosine, 5.0 );\n\n }\n\n"), ba = j("\n\n fn evaluateFresnel( cosine: f32, eta: f32, f0: vec3f, f90: vec3f ) -> vec3f {\n\n if ( totalInternalReflection( cosine, eta ) ) {\n\n return f90;\n\n }\n\n return f0 + ( f90 - f0 ) * pow( 1.0 - cosine, 5.0 );\n }\n\n", [j("\n\n fn totalInternalReflection( cosTheta: f32, eta: f32 ) -> bool {\n\n let sinTheta = sqrt( 1.0 - cosTheta * cosTheta );\n return eta * sinTheta > 1.0;\n\n }\n\n")]), xa = j("\n\n fn isTerminatingScatter( scatterRec: ScatterRecord ) -> bool {\n return scatterRec.pdf <= 0;\n }\n\n", [oa]), Sa = j("\n\n fn applyWrap( v: f32, wrapMode: i32 ) -> f32 {\n\n var res = v;\n if ( wrapMode == 1 ) {\n\n // ClampToEdge\n res = clamp( res, 0.0, 1.0 );\n\n } else if ( wrapMode == 2 ) {\n\n // MirroredRepeat\n res = 1.0 - abs( 2.0 * fract( res * 0.5 ) - 1.0 );\n\n } else {\n\n // Repeat\n res = fract( res );\n\n }\n\n return res;\n\n }\n\n"), Ca = (e, t, n) => $`
3206
+ }, "BxDFContext"), fa = P("\n\n fn inverse(m: mat3x3f) -> mat3x3f {\n var adj: mat3x3f;\n adj[0][0] = (m[1][1] * m[2][2] - m[2][1] * m[1][2]);\n adj[1][0] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);\n adj[2][0] = (m[1][0] * m[2][1] - m[2][0] * m[1][1]);\n adj[0][1] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);\n adj[1][1] = (m[0][0] * m[2][2] - m[2][0] * m[0][2]);\n adj[2][1] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);\n adj[0][2] = (m[0][1] * m[1][2] - m[1][1] * m[0][2]);\n adj[1][2] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);\n adj[2][2] = (m[0][0] * m[1][1] - m[1][0] * m[0][1]);\n\n let det = ( m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])\n - m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])\n + m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]));\n\n return adj * ( 1.0 / det );\n }\n\n"), pa = P("\n\n fn getBasisFromNormal( normal: vec3f ) -> mat3x3f {\n\n var other: vec3f;\n if ( abs( normal.x ) > 0.5 ) {\n\n other = vec3f( 0.0, 1.0, 0.0 );\n\n } else {\n\n other = vec3f( 1.0, 0.0, 0.0 );\n\n }\n\n let ortho = normalize( cross( normal, other ) );\n let ortho2 = normalize( cross( normal, ortho ) );\n return mat3x3f( ortho2, ortho, normal );\n\n }\n\n"), ma = P("\n\n fn iorToF0( ior: f32 ) -> f32 {\n return pow( ( 1 - ior ) / ( 1 + ior ), 2 );\n }\n\n"), ha = P("\n\n fn iorToF0General( transmittedIor: f32, incidentIor: f32 ) -> f32 {\n\n return pow( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ), 2 );\n\n }\n\n"), ga = P("\n\n fn iorToF0GeneralVec( transmittedIor: vec3f, incidentIor: vec3f ) -> vec3f {\n\n let v = ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor );\n return v * v;\n\n }\n\n"), _a = P("\n\n fn fresnel0ToIor( f0: vec3f ) -> vec3f {\n\n let sqrtF0 = sqrt( f0 );\n return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );\n\n }\n\n"), va = P("\n\n fn schlickFresnel( cosine: f32, f0: f32 ) -> f32 {\n\n return f0 + ( 1.0 - f0 ) * pow( 1.0 - cosine, 5.0 );\n\n }\n\n"), ya = P("\n\n fn schlickFresnelVec( cosine: f32, f0: vec3f, f90: vec3f ) -> vec3f {\n\n return f0 + ( f90 - f0 ) * pow( 1.0 - cosine, 5.0 );\n\n }\n\n"), ba = P("\n\n fn evaluateFresnel( cosine: f32, eta: f32, f0: vec3f, f90: vec3f ) -> vec3f {\n\n if ( totalInternalReflection( cosine, eta ) ) {\n\n return f90;\n\n }\n\n return f0 + ( f90 - f0 ) * pow( 1.0 - cosine, 5.0 );\n }\n\n", [P("\n\n fn totalInternalReflection( cosTheta: f32, eta: f32 ) -> bool {\n\n let sinTheta = sqrt( 1.0 - cosTheta * cosTheta );\n return eta * sinTheta > 1.0;\n\n }\n\n")]), xa = P("\n\n fn isTerminatingScatter( scatterRec: ScatterRecord ) -> bool {\n return scatterRec.pdf <= 0;\n }\n\n", [oa]), Sa = P("\n\n fn applyWrap( v: f32, wrapMode: i32 ) -> f32 {\n\n var res = v;\n if ( wrapMode == 1 ) {\n\n // ClampToEdge\n res = clamp( res, 0.0, 1.0 );\n\n } else if ( wrapMode == 2 ) {\n\n // MirroredRepeat\n res = 1.0 - abs( 2.0 * fract( res * 0.5 ) - 1.0 );\n\n } else {\n\n // Repeat\n res = fract( res );\n\n }\n\n return res;\n\n }\n\n"), Ca = (e, t, n) => $`
3207
3207
 
3208
3208
  fn sampleTexel( uv: vec2f, packed: i32, lod: f32 ) -> vec4f {
3209
3209
 
@@ -3247,41 +3247,41 @@ var ra = $`
3247
3247
  }
3248
3248
 
3249
3249
  }
3250
- `, wa = j("\n\n fn diffuseDirection( wo: vec3f, uv: vec2f ) -> vec3f {\n\n var lightDirection = sampleSphere( uv );\n lightDirection.z += 1.0;\n lightDirection = normalize( lightDirection );\n\n return lightDirection;\n\n }\n\n", [j("\n\n fn sampleSphere( uv: vec2f ) -> vec3f {\n\n let u = ( uv.x - 0.5 ) * 2.0;\n let t = uv.y * PI * 2.0;\n let f = sqrt( 1.0 - u * u );\n\n return vec3f( f * cos( t ), f * sin( t ), u );\n\n }\n\n", [aa])]), Ta = j("\n\n fn getLobeWeights(wo: vec3f, woClearcoat: vec3f, wh: vec3f, clearcoatIor: f32, surf: SurfaceRecord) -> LobeWeights {\n\n // TODO: experiment with this; I don't see any usage of normal?\n let metalness = surf.metalness;\n let transmission = surf.transmission;\n let HdotL = dot( wh, wo );\n let fEstimate = evaluateFresnel( HdotL, surf.eta, vec3f( surf.f0 ), vec3f( 1.0 ) ).x;\n\n let transSpecularProb = mix( max( 0.25, fEstimate ), 1.0, metalness );\n let diffSpecularProb = 0.5 + 0.5 * metalness;\n\n var weights: LobeWeights;\n weights.diffuse = ( 1.0 - transmission ) * ( 1.0 - diffSpecularProb );\n weights.specular = transmission * transSpecularProb + ( 1.0 - transmission ) * diffSpecularProb;\n\n let clearcoatF0 = iorToF0( clearcoatIor );\n let clearcoatFresnel = schlickFresnel( saturate( woClearcoat.z ), clearcoatF0 );\n weights.clearcoat = surf.clearcoat * clearcoatFresnel;\n\n weights.transmission = transmission * ( 1.0 - transSpecularProb );\n\n let totalWeight = weights.diffuse + weights.specular;\n if ( totalWeight > 0 ) {\n weights.diffuse = ( weights.diffuse / totalWeight ) * ( 1 - weights.clearcoat );\n weights.specular = ( weights.specular / totalWeight ) * ( 1 - weights.clearcoat );\n }\n // weights.transmission /= totalWeight;\n\n return weights;\n\n }\n\n", [
3250
+ `, wa = P("\n\n fn diffuseDirection( wo: vec3f, uv: vec2f ) -> vec3f {\n\n var lightDirection = sampleSphere( uv );\n lightDirection.z += 1.0;\n lightDirection = normalize( lightDirection );\n\n return lightDirection;\n\n }\n\n", [P("\n\n fn sampleSphere( uv: vec2f ) -> vec3f {\n\n let u = ( uv.x - 0.5 ) * 2.0;\n let t = uv.y * PI * 2.0;\n let f = sqrt( 1.0 - u * u );\n\n return vec3f( f * cos( t ), f * sin( t ), u );\n\n }\n\n", [aa])]), Ta = P("\n\n fn getLobeWeights(wo: vec3f, woClearcoat: vec3f, wh: vec3f, clearcoatIor: f32, surf: SurfaceRecord) -> LobeWeights {\n\n // TODO: experiment with this; I don't see any usage of normal?\n let metalness = surf.metalness;\n let transmission = surf.transmission;\n let HdotL = dot( wh, wo );\n let fEstimate = evaluateFresnel( HdotL, surf.eta, vec3f( surf.f0 ), vec3f( 1.0 ) ).x;\n\n let transSpecularProb = mix( max( 0.25, fEstimate ), 1.0, metalness );\n let diffSpecularProb = 0.5 + 0.5 * metalness;\n\n var weights: LobeWeights;\n weights.diffuse = ( 1.0 - transmission ) * ( 1.0 - diffSpecularProb );\n weights.specular = transmission * transSpecularProb + ( 1.0 - transmission ) * diffSpecularProb;\n\n let clearcoatF0 = iorToF0( clearcoatIor );\n let clearcoatFresnel = schlickFresnel( saturate( woClearcoat.z ), clearcoatF0 );\n weights.clearcoat = surf.clearcoat * clearcoatFresnel;\n\n weights.transmission = transmission * ( 1.0 - transSpecularProb );\n\n let totalWeight = weights.diffuse + weights.specular;\n if ( totalWeight > 0 ) {\n weights.diffuse = ( weights.diffuse / totalWeight ) * ( 1 - weights.clearcoat );\n weights.specular = ( weights.specular / totalWeight ) * ( 1 - weights.clearcoat );\n }\n // weights.transmission /= totalWeight;\n\n return weights;\n\n }\n\n", [
3251
3251
  va,
3252
3252
  ma,
3253
3253
  ba,
3254
3254
  ua,
3255
3255
  aa
3256
- ]), Ea = j("\n\n fn sampleEnvironment(\n envMap: texture_2d<f32>,\n envMapSampler: sampler,\n env: EnvironmentInfo,\n direction: vec3f,\n uv: vec2f,\n ) -> vec4f {\n\n let offsetDir = sampleHemisphere( direction, uv ) * 0.5 * env.blur;\n let sampleDir = normalize( env.rotation * direction + offsetDir );\n let col = sampleEquirectColor( envMap, envMapSampler, sampleDir );\n\n return vec4f( env.intensity * col.rgb, col.a );\n\n }\n\n", [
3257
- j("\n\n fn sampleEquirectColor( envMap: texture_2d<f32>, envMapSampler: sampler, direction: vec3f ) -> vec4f {\n\n return textureSampleLevel( envMap, envMapSampler, equirectDirectionToUv( direction ), 0 );\n\n }\n\n", [j("\n\n fn equirectDirectionToUv(direction: vec3f) -> vec2f {\n\n // from Spherical.setFromCartesianCoords\n var uv = vec2f( atan2( direction.z, direction.x ), acos( direction.y ) );\n uv /= vec2f( 2.0 * PI, PI );\n\n // apply adjustments to get values in range [0, 1] and y right side up\n uv.x += 0.5;\n uv.y = 1.0 - uv.y;\n return uv;\n\n }\n\n")]),
3258
- j("\n\n fn sampleHemisphere( n: vec3f, uv: vec2f ) -> vec3f {\n\n // https://www.rorydriscoll.com/2009/01/07/better-sampling/\n // https://graphics.pixar.com/library/OrthonormalB/paper.pdf\n let sign = select( sign( n.z ), 1.0, n.z == 0.0 );\n let a = - 1.0 / ( sign + n.z );\n let b = n.x * n.y * a;\n let b1 = vec3( 1.0 + sign * n.x * n.x * a, sign * b, - sign * n.x );\n let b2 = vec3( b, sign + n.y * n.y * a, - n.y );\n\n let r = sqrt( uv.x );\n let theta = 2.0 * PI * uv.y;\n let x = r * cos( theta );\n let y = r * sin( theta );\n return x * b1 + y * b2 + sqrt( 1.0 - uv.x ) * n;\n\n }\n\n", [aa]),
3256
+ ]), Ea = P("\n\n fn sampleEnvironment(\n envMap: texture_2d<f32>,\n envMapSampler: sampler,\n env: EnvironmentInfo,\n direction: vec3f,\n uv: vec2f,\n ) -> vec4f {\n\n let offsetDir = sampleHemisphere( direction, uv ) * 0.5 * env.blur;\n let sampleDir = normalize( env.rotation * direction + offsetDir );\n let col = sampleEquirectColor( envMap, envMapSampler, sampleDir );\n\n return vec4f( env.intensity * col.rgb, col.a );\n\n }\n\n", [
3257
+ P("\n\n fn sampleEquirectColor( envMap: texture_2d<f32>, envMapSampler: sampler, direction: vec3f ) -> vec4f {\n\n return textureSampleLevel( envMap, envMapSampler, equirectDirectionToUv( direction ), 0 );\n\n }\n\n", [P("\n\n fn equirectDirectionToUv(direction: vec3f) -> vec2f {\n\n // from Spherical.setFromCartesianCoords\n var uv = vec2f( atan2( direction.z, direction.x ), acos( direction.y ) );\n uv /= vec2f( 2.0 * PI, PI );\n\n // apply adjustments to get values in range [0, 1] and y right side up\n uv.x += 0.5;\n uv.y = 1.0 - uv.y;\n return uv;\n\n }\n\n")]),
3258
+ P("\n\n fn sampleHemisphere( n: vec3f, uv: vec2f ) -> vec3f {\n\n // https://www.rorydriscoll.com/2009/01/07/better-sampling/\n // https://graphics.pixar.com/library/OrthonormalB/paper.pdf\n let sign = select( sign( n.z ), 1.0, n.z == 0.0 );\n let a = - 1.0 / ( sign + n.z );\n let b = n.x * n.y * a;\n let b1 = vec3( 1.0 + sign * n.x * n.x * a, sign * b, - sign * n.x );\n let b2 = vec3( b, sign + n.y * n.y * a, - n.y );\n\n let r = sqrt( uv.x );\n let theta = 2.0 * PI * uv.y;\n let x = r * cos( theta );\n let y = r * sin( theta );\n return x * b1 + y * b2 + sqrt( 1.0 - uv.x ) * n;\n\n }\n\n", [aa]),
3259
3259
  la
3260
- ]), Da = j("\n\n fn weightedAlphaBlend( prevColor: vec4f, newColor: vec4f, weight: f32 ) -> vec4f {\n\n let invWeight = 1.0 - weight;\n let totalAlpha = prevColor.a * invWeight + newColor.a * weight;\n var blendedColor = vec4f( 0 );\n if ( totalAlpha != 0.0 ) {\n\n let prevContrib = prevColor.rgb * invWeight * prevColor.a / totalAlpha;\n let resContrib = newColor.rgb * weight * newColor.a / totalAlpha;\n blendedColor = vec4f( prevContrib + resContrib, totalAlpha );\n\n }\n\n return blendedColor;\n\n }\n\n"), Oa = class extends zi {
3260
+ ]), Da = P("\n\n fn weightedAlphaBlend( prevColor: vec4f, newColor: vec4f, weight: f32 ) -> vec4f {\n\n let invWeight = 1.0 - weight;\n let totalAlpha = prevColor.a * invWeight + newColor.a * weight;\n var blendedColor = vec4f( 0 );\n if ( totalAlpha != 0.0 ) {\n\n let prevContrib = prevColor.rgb * invWeight * prevColor.a / totalAlpha;\n let resContrib = newColor.rgb * weight * newColor.a / totalAlpha;\n blendedColor = vec4f( prevContrib + resContrib, totalAlpha );\n\n }\n\n return blendedColor;\n\n }\n\n"), Oa = class extends zi {
3261
3261
  constructor() {
3262
3262
  let e = {
3263
3263
  bvhData: { value: null },
3264
3264
  material: { value: null },
3265
- prevOutputTarget: M(new k(1, 1)).toReadOnly(),
3266
- outputTarget: M(new k(1, 1)).toWriteOnly(),
3267
- sampleCountTarget: M(new k(1, 1)).toReadWrite(),
3268
- offset: N(new f()),
3269
- tileSize: N(new f()),
3270
- seed: N(0),
3271
- bounces: N(5),
3272
- inverseProjectionMatrix: N(new E()),
3273
- cameraToModelMatrix: N(new E()),
3274
- envMap: F(new h()),
3275
- envMapSampler: De(new h()),
3276
- envMapRotation: N(new ae()),
3277
- envMapIntensity: N(1),
3278
- background: F(new h()),
3279
- backgroundSampler: De(new h()),
3280
- backgroundRotation: N(new ae()),
3281
- backgroundIntensity: N(1),
3282
- backgroundBlurriness: N(0),
3283
- textures: F(new h()),
3284
- textureSampler: De(new h()),
3265
+ prevOutputTarget: j(new k(1, 1)).toReadOnly(),
3266
+ outputTarget: j(new k(1, 1)).toWriteOnly(),
3267
+ sampleCountTarget: j(new k(1, 1)).toReadWrite(),
3268
+ offset: M(new f()),
3269
+ tileSize: M(new f()),
3270
+ seed: M(0),
3271
+ bounces: M(5),
3272
+ inverseProjectionMatrix: M(new E()),
3273
+ cameraToModelMatrix: M(new E()),
3274
+ envMap: Me(new h()),
3275
+ envMapSampler: ke(new h()),
3276
+ envMapRotation: M(new ae()),
3277
+ envMapIntensity: M(1),
3278
+ background: Me(new h()),
3279
+ backgroundSampler: ke(new h()),
3280
+ backgroundRotation: M(new ae()),
3281
+ backgroundIntensity: M(1),
3282
+ backgroundBlurriness: M(0),
3283
+ textures: Me(new h()),
3284
+ textureSampler: ke(new h()),
3285
3285
  globalId: Oe
3286
3286
  }, t = ni("bvhData.value.fns.raycastFirstHit.outputType", e), n = ri("bvhData.value.fns.raycastFirstHit", e), r = ri("bvhData.value.fns.sampleTrianglePoint", e), i = ri("bvhData.value.fns.getSurfaceRecord", e), a = ri("material.value.bsdfSample", e), o = $`
3287
3287
 
@@ -3533,7 +3533,7 @@ var Na = class {
3533
3533
  constructor() {
3534
3534
  let e = {
3535
3535
  globalId: Oe,
3536
- outputTarget: M(new k(1, 1)).toWriteOnly()
3536
+ outputTarget: j(new k(1, 1)).toWriteOnly()
3537
3537
  }, t = $`
3538
3538
  fn compute( globalId: vec3u ) -> void {
3539
3539
 
@@ -3635,14 +3635,14 @@ var Na = class {
3635
3635
  }, "QueuedHit"), za = class extends zi {
3636
3636
  constructor() {
3637
3637
  let e = {
3638
- rayWorkGroupSize: N(new n()),
3639
- tileSize: N(new f()),
3640
- tileCount: N(new f()),
3641
- tileOffset: N(1),
3642
- rayQueue: P(new A(1, La.getLength()), La).toReadOnly(),
3643
- queueSizes: P(new A(4, 1), "u32"),
3644
- outputTileIndex: P(new A(2, 1), "u32").setName("outputTileIndex"),
3645
- outputDispatch: P(new A(3, 1), "u32").setName("outputDispatch")
3638
+ rayWorkGroupSize: M(new n()),
3639
+ tileSize: M(new f()),
3640
+ tileCount: M(new f()),
3641
+ tileOffset: M(1),
3642
+ rayQueue: N(new A(1, La.getLength()), La).toReadOnly(),
3643
+ queueSizes: N(new A(4, 1), "u32"),
3644
+ outputTileIndex: N(new A(2, 1), "u32").setName("outputTileIndex"),
3645
+ outputDispatch: N(new A(3, 1), "u32").setName("outputDispatch")
3646
3646
  }, t = $`
3647
3647
  fn compute(
3648
3648
  rayWorkGroupSize: vec3u,
@@ -3710,14 +3710,14 @@ var Na = class {
3710
3710
  }, Ba = class extends zi {
3711
3711
  constructor() {
3712
3712
  let e = {
3713
- cameraToModelMatrix: N(new E()),
3714
- inverseProjectionMatrix: N(new E()),
3715
- seed: N(0),
3716
- tileIndexBuffer: P(new A(2, 1), "u32"),
3717
- tileSize: N(new f()),
3718
- rayQueue: P(new A(1, La.getLength()), La),
3719
- queueSizes: P(new A(4, 1), "u32").toAtomic(),
3720
- sampleCountTarget: M(new k()).toReadWrite(),
3713
+ cameraToModelMatrix: M(new E()),
3714
+ inverseProjectionMatrix: M(new E()),
3715
+ seed: M(0),
3716
+ tileIndexBuffer: N(new A(2, 1), "u32"),
3717
+ tileSize: M(new f()),
3718
+ rayQueue: N(new A(1, La.getLength()), La),
3719
+ queueSizes: N(new A(4, 1), "u32").toAtomic(),
3720
+ sampleCountTarget: j(new k()).toReadWrite(),
3721
3721
  globalId: Oe
3722
3722
  }, t = $`
3723
3723
  fn compute(
@@ -3798,21 +3798,21 @@ var Na = class {
3798
3798
  constructor() {
3799
3799
  let e = {
3800
3800
  bvhData: { value: null },
3801
- prevOutputTarget: M(new k(1, 1)).toReadOnly(),
3802
- outputTarget: M(new k(1, 1)).toWriteOnly(),
3803
- sampleCountTarget: M(new k(1, 1)).toReadWrite(),
3804
- rayQueue: P(new A(1, La.getLength()), La).toReadOnly(),
3805
- hitQueue: P(new A(1, Ra.getLength()), Ra),
3806
- queueSizes: P(new A(4, 1), "u32").toAtomic(),
3807
- envMap: F(new h()),
3808
- envMapSampler: De(new h()),
3809
- envMapRotation: N(new ae()),
3810
- envMapIntensity: N(1),
3811
- background: F(new h()),
3812
- backgroundSampler: De(new h()),
3813
- backgroundRotation: N(new ae()),
3814
- backgroundIntensity: N(1),
3815
- backgroundBlurriness: N(0),
3801
+ prevOutputTarget: j(new k(1, 1)).toReadOnly(),
3802
+ outputTarget: j(new k(1, 1)).toWriteOnly(),
3803
+ sampleCountTarget: j(new k(1, 1)).toReadWrite(),
3804
+ rayQueue: N(new A(1, La.getLength()), La).toReadOnly(),
3805
+ hitQueue: N(new A(1, Ra.getLength()), Ra),
3806
+ queueSizes: N(new A(4, 1), "u32").toAtomic(),
3807
+ envMap: Me(new h()),
3808
+ envMapSampler: ke(new h()),
3809
+ envMapRotation: M(new ae()),
3810
+ envMapIntensity: M(1),
3811
+ background: Me(new h()),
3812
+ backgroundSampler: ke(new h()),
3813
+ backgroundRotation: M(new ae()),
3814
+ backgroundIntensity: M(1),
3815
+ backgroundBlurriness: M(0),
3816
3816
  globalId: Oe
3817
3817
  }, t = ni("bvhData.value.fns.raycastFirstHit.outputType", e), n = ni("bvhData.value.fns.raycastFirstHit", e), r = $`
3818
3818
 
@@ -3914,8 +3914,8 @@ var Na = class {
3914
3914
  }, Ha = class extends zi {
3915
3915
  constructor() {
3916
3916
  let e = {
3917
- processed: N(0),
3918
- queueSizes: P(new A(4, 1), "u32")
3917
+ processed: M(0),
3918
+ queueSizes: N(new A(4, 1), "u32")
3919
3919
  }, t = $`
3920
3920
  fn compute( processed: u32 ) -> void {
3921
3921
 
@@ -3939,7 +3939,7 @@ var Na = class {
3939
3939
  constructor(e = {}) {
3940
3940
  let { type: t = "u32" } = e, n = {
3941
3941
  globalId: Oe,
3942
- outputTarget: P(new A(1, 1), t)
3942
+ outputTarget: N(new A(1, 1), t)
3943
3943
  }, r = $`
3944
3944
  fn compute( globalId: vec3u ) -> void {
3945
3945
 
@@ -3954,16 +3954,16 @@ var Na = class {
3954
3954
  let e = {
3955
3955
  bvhData: { value: null },
3956
3956
  material: { value: null },
3957
- prevOutputTarget: M(new k(1, 1)).toReadOnly(),
3958
- outputTarget: M(new k(1, 1)).toWriteOnly(),
3959
- sampleCountTarget: M(new k(1, 1)).toReadWrite(),
3960
- smoothNormals: N(1),
3961
- bounces: N(1),
3962
- rayQueue: P(new A(1, La.getLength()), La),
3963
- hitQueue: P(new A(1, Ra.getLength()), Ra),
3964
- queueSizes: P(new A(4, 1), "u32").toAtomic(),
3965
- textures: F(new h()),
3966
- textureSampler: De(new h()),
3957
+ prevOutputTarget: j(new k(1, 1)).toReadOnly(),
3958
+ outputTarget: j(new k(1, 1)).toWriteOnly(),
3959
+ sampleCountTarget: j(new k(1, 1)).toReadWrite(),
3960
+ smoothNormals: M(1),
3961
+ bounces: M(1),
3962
+ rayQueue: N(new A(1, La.getLength()), La),
3963
+ hitQueue: N(new A(1, Ra.getLength()), Ra),
3964
+ queueSizes: N(new A(4, 1), "u32").toAtomic(),
3965
+ textures: Me(new h()),
3966
+ textureSampler: ke(new h()),
3967
3967
  globalId: Oe
3968
3968
  }, t = ri("bvhData.value.fns.sampleTrianglePoint", e), n = ri("bvhData.value.fns.getSurfaceRecord", e), r = ri("material.value.bsdfSample", e), i = $`
3969
3969
 
@@ -4162,18 +4162,18 @@ function $a(e) {
4162
4162
  }
4163
4163
  //#endregion
4164
4164
  //#region ../../node_modules/three-gpu-pathtracer/src/webgpu/nodes/ggx.wgsl.js
4165
- var eo = j("\n\n fn ggxDirection( incidentDir: vec3f, alpha: vec2f, uv: vec2f ) -> vec3f {\n\n // Implementation from reference [1]\n // stretch view\n let V = normalize( vec3f( alpha * incidentDir.xy, incidentDir.z ) );\n\n // orthonormal basis\n var T1: vec3f;\n if ( V.z < 0.9999 ) {\n T1 = normalize( cross( V, vec3( 0.0, 0.0, 1.0 ) ) );\n } else {\n T1 = vec3( 1.0, 0.0, 0.0 );\n }\n\n let T2 = cross( T1, V );\n\n // sample point with polar coordinates (r, phi)\n let a = 1.0 / ( 1.0 + V.z );\n let r = sqrt( uv.x );\n var phi: f32;\n if ( uv.y < a ) {\n phi = uv.y / a * PI;\n } else {\n phi = PI + ( uv.y - a ) / ( 1.0 - a ) * PI;\n }\n let P1 = r * cos( phi );\n var P2 = r * sin( phi );\n if ( uv.y >= a ) {\n P2 *= V.z;\n }\n\n // compute normal\n var N = P1 * T1 + P2 * T2 + V * sqrt( max( 0.0, 1.0 - P1 * P1 - P2 * P2 ) );\n\n // unstretch\n N = normalize( vec3( alpha * N.xy, max( 0.0, N.z ) ) );\n\n return N;\n\n }\n\n", [aa]), to = j("\n\n fn ggxLamda( theta: f32, alpha: f32 ) -> f32 {\n\n let tanTheta = tan( theta );\n let tanTheta2 = tanTheta * tanTheta;\n let alpha2 = alpha * alpha;\n\n let numerator = - 1.0 + sqrt( 1.0 + alpha2 * tanTheta2 );\n return numerator / 2.0;\n\n }\n\n"), no = j("\n\n fn ggxShadowMaskG1( cosTheta: f32, alpha: f32 ) -> f32 {\n\n let a2 = alpha * alpha;\n let cosTheta2 = cosTheta * cosTheta;\n let denom = cosTheta + sqrt( cosTheta2 * ( 1 - a2 ) + a2 );\n return 2.0 * cosTheta / denom;\n\n }\n\n", [to]), ro = j("\n\n fn ggxSmithVisibility( NdotV: f32, NdotL: f32, alpha: f32 ) -> f32 {\n\n // Original formulation of G_SmithGGX Correlated\n // lambda_v = ( -1 + sqrt ( alphaG2 * (1 - NdotL2 ) / NdotL2 + 1)) * 0.5 f;\n // lambda_l = ( -1 + sqrt ( alphaG2 * (1 - NdotV2 ) / NdotV2 + 1)) * 0.5 f;\n // G_SmithGGXCorrelated = 1 / (1 + lambda_v + lambda_l );\n // V_SmithGGXCorrelated = G_SmithGGXCorrelated / (4.0 f * NdotL * NdotV );\n\n // This is an optimized version\n let alpha2 = alpha * alpha;\n // Caution: the \"NdotL *\" and \"NdotV *\" are explicitely inversed , this is not a mistake.\n let Lambda_GGXV = NdotL * sqrt (( - NdotV * alpha2 + NdotV ) * NdotV + alpha2 );\n let Lambda_GGXL = NdotV * sqrt (( - NdotL * alpha2 + NdotL ) * NdotL + alpha2 );\n\n return 0.5 / ( Lambda_GGXV + Lambda_GGXL );\n\n }\n\n", [to]), io = j("\n fn ggxDistribution( NdotH: f32, alpha: f32 ) -> f32 {\n\n let a2 = max( alpha * alpha, EPSILON );\n let denom = NdotH * NdotH * ( a2 - 1 ) + 1;\n\n return ( a2 / ( PI * denom * denom ) );\n\n }\n"), ao = j("\n fn ggxReflectionAdjustedPDF( NdotV: f32, NdotH: f32, alpha: f32 ) -> f32 {\n\n let D = ggxDistribution( NdotH, alpha );\n let G1 = ggxShadowMaskG1( NdotV, alpha );\n\n return D * G1 / ( 4 * NdotV );\n\n }\n", [io, no]), oo = (e) => j("\n\n fn getSurfaceRecord(\n material: Material,\n vertexData: bvh_GeometryStruct,\n side: f32,\n faceNormal: vec3f,\n ) -> SurfaceRecord {\n let uv = vertexData.uv.xy;\n\n var normal = faceNormal * side;\n if ( material.flatShading == 0 ) {\n\n normal = vertexData.normal.xyz;\n\n }\n normal = normalize( normal );\n let baseNormal = normal;\n\n if ( material.normalMap != -1 ) {\n\n // some provided tangents can be malformed (0, 0, 0) causing the normal to be degenerate\n // resulting in NaNs and slow path tracing.\n if ( length( vertexData.tangent.xyz ) > 0.0 && vertexData.tangent.w != 0.0 ) {\n\n let tangent = normalize( vertexData.tangent.xyz );\n let bitangent = normalize( cross( baseNormal, tangent ) * vertexData.tangent.w );\n let vTBN = mat3x3f( tangent, bitangent, baseNormal );\n\n let uvPrime = material.normalMapTransform * vec3( uv, 1.0 );\n var texNormal = sampleTexel( uvPrime.xy, material.normalMap, 0 ).xyz;\n texNormal = texNormal * 2.0 - 1.0;\n texNormal = texNormal * vec3f( material.normalScale, 1.0 );\n normal = normalize( vTBN * texNormal );\n\n }\n\n }\n\n normal *= side;\n\n var albedo = vec4( material.color, material.opacity );\n\n if ( material.vertexColors == 1 ) {\n\n let vertexColor = vertexData.color.xyz;\n albedo *= vec4f( vertexColor, 1.0 );\n\n }\n\n if ( material.map != -1 ) {\n\n let uvPrime = material.mapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.map, 0 );\n albedo *= vec4f( texColor.rgb, 1.0 );\n\n }\n\n var roughness = material.roughness;\n if ( material.roughnessMap != -1 ) {\n\n let uvPrime = material.roughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.roughnessMap, 0 );\n roughness *= texColor.g;\n\n }\n\n var metalness = material.metalness;\n if ( material.metalnessMap != -1 ) {\n\n let uvPrime = material.metalnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.metalnessMap, 0 );\n metalness *= texColor.b;\n\n }\n\n var emission = material.emissiveIntensity * material.emissive;\n if ( material.emissiveMap != -1 ) {\n\n let uvPrime = material.emissiveMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.emissiveMap, 0 );\n emission *= texColor.rgb;\n\n }\n\n var transmission = material.transmission;\n if ( material.transmissionMap != -1 ) {\n\n let uvPrime = material.transmissionMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.transmissionMap, 0 );\n transmission *= texColor.r;\n\n }\n\n var clearcoat = material.clearcoat;\n if ( material.clearcoatMap != -1 ) {\n\n let uvPrime = material.clearcoatMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.clearcoatMap, 0 );\n clearcoat *= texColor.r;\n\n }\n\n var clearcoatRoughness = material.clearcoatRoughness;\n if ( material.clearcoatRoughnessMap != -1 ) {\n\n let uvPrime = material.clearcoatRoughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.clearcoatRoughnessMap, 0 );\n clearcoatRoughness *= texColor.g;\n\n }\n\n var clearcoatNormal = baseNormal;\n if ( material.clearcoatNormalMap != -1 ) {\n\n // some provided tangents can be malformed (0, 0, 0) causing the normal to be degenerate\n // resulting in NaNs and slow path tracing.\n if ( length( vertexData.tangent.xyz ) > 0.0 && vertexData.tangent.w != 0.0 ) {\n\n let tangent = normalize( vertexData.tangent.xyz );\n let bitangent = normalize( cross( baseNormal, tangent ) * vertexData.tangent.w );\n let vTBN = mat3x3f( tangent, bitangent, baseNormal );\n\n let uvPrime = material.clearcoatNormalMapTransform * vec3( uv, 1.0 );\n var texNormal = sampleTexel( uvPrime.xy, material.clearcoatNormalMap, 0 ).xyz;\n texNormal = texNormal * 2.0 - 1.0;\n texNormal = texNormal * vec3f( material.clearcoatNormalScale, 1.0 );\n clearcoatNormal = normalize( vTBN * texNormal );\n\n }\n\n }\n clearcoatNormal *= side;\n\n var sheenColor = material.sheenColor;\n if ( material.sheenColorMap != -1 ) {\n\n let uvPrime = material.sheenColorMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.sheenColorMap, 0 );\n sheenColor *= texColor.rgb;\n\n }\n\n var sheenRoughness = material.sheenRoughness;\n if ( material.sheenRoughnessMap != -1 ) {\n\n let uvPrime = material.sheenRoughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.sheenRoughnessMap, 0 );\n sheenRoughness *= texColor.r;\n\n }\n\n var iridescence = material.iridescence;\n if ( material.iridescenceMap != -1 ) {\n\n let uvPrime = material.iridescenceMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.iridescenceMap, 0 );\n iridescence *= texColor.r;\n\n }\n\n var iridescenceThickness = material.iridescenceThicknessMaximum;\n if ( material.iridescenceThicknessMap != -1 ) {\n\n let uvPrime = material.iridescenceThicknessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.iridescenceThicknessMap, 0 );\n\n iridescenceThickness = mix(\n material.iridescenceThicknessMinimum,\n material.iridescenceThicknessMaximum,\n texColor.g,\n );\n\n }\n\n var specularColor = material.specularColor;\n if ( material.specularColorMap != -1 ) {\n\n let uvPrime = material.specularColorMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.specularColorMap, 0 );\n specularColor *= texColor.rgb;\n\n }\n\n var specularIntensity = material.specularIntensity;\n if ( material.specularIntensityMap != -1 ) {\n\n let uvPrime = material.specularIntensityMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.specularIntensityMap, 0 );\n specularIntensity *= texColor.r;\n\n }\n\n var surf: SurfaceRecord;\n\n surf.volumeParticle = false;\n surf.faceNormal = faceNormal;\n surf.normal = normal;\n\n surf.metalness = metalness;\n surf.color = albedo.rgb;\n surf.emission = emission;\n\n surf.ior = material.ior;\n surf.transmission = transmission;\n surf.thinFilm = material.thinFilm == 1;\n surf.attenuationColor = material.attenuationColor;\n surf.attenuationDistance = material.attenuationDistance;\n\n surf.clearcoatNormal = clearcoatNormal;\n surf.clearcoat = clearcoat;\n\n surf.iridescence = iridescence;\n surf.iridescenceIor = material.iridescenceIor;\n surf.iridescenceThickness = iridescenceThickness;\n\n surf.specularColor = specularColor;\n surf.specularIntensity = specularIntensity;\n\n surf.roughness = clamp( roughness, MIN_ROUGHNESS, 1.0 );\n surf.clearcoatRoughness = clamp( clearcoatRoughness, MIN_ROUGHNESS, 1.0 );\n surf.sheenRoughness = clamp( sheenRoughness, MIN_ROUGHNESS, 1.0 );\n\n // frontFace is used to determine transmissive properties and PDF. If no transmission is used\n // then we can just always assume this is a front face.\n surf.frontFace = side == 1.0 || transmission == 0.0;\n if ( material.thinFilm == 1 || surf.frontFace ) {\n surf.eta = 1.0 / material.ior;\n } else {\n surf.eta = material.ior;\n }\n surf.f0 = iorToF0( surf.eta );\n\n // get the normal frames\n surf.normalBasis = getBasisFromNormal( surf.normal );\n surf.normalInvBasis = inverse( surf.normalBasis );\n\n surf.clearcoatBasis = getBasisFromNormal( surf.clearcoatNormal );\n surf.clearcoatInvBasis = inverse( surf.clearcoatBasis );\n\n return surf;\n }\n\n", [
4165
+ var eo = P("\n\n fn ggxDirection( incidentDir: vec3f, alpha: vec2f, uv: vec2f ) -> vec3f {\n\n // Implementation from reference [1]\n // stretch view\n let V = normalize( vec3f( alpha * incidentDir.xy, incidentDir.z ) );\n\n // orthonormal basis\n var T1: vec3f;\n if ( V.z < 0.9999 ) {\n T1 = normalize( cross( V, vec3( 0.0, 0.0, 1.0 ) ) );\n } else {\n T1 = vec3( 1.0, 0.0, 0.0 );\n }\n\n let T2 = cross( T1, V );\n\n // sample point with polar coordinates (r, phi)\n let a = 1.0 / ( 1.0 + V.z );\n let r = sqrt( uv.x );\n var phi: f32;\n if ( uv.y < a ) {\n phi = uv.y / a * PI;\n } else {\n phi = PI + ( uv.y - a ) / ( 1.0 - a ) * PI;\n }\n let P1 = r * cos( phi );\n var P2 = r * sin( phi );\n if ( uv.y >= a ) {\n P2 *= V.z;\n }\n\n // compute normal\n var N = P1 * T1 + P2 * T2 + V * sqrt( max( 0.0, 1.0 - P1 * P1 - P2 * P2 ) );\n\n // unstretch\n N = normalize( vec3( alpha * N.xy, max( 0.0, N.z ) ) );\n\n return N;\n\n }\n\n", [aa]), to = P("\n\n fn ggxLamda( theta: f32, alpha: f32 ) -> f32 {\n\n let tanTheta = tan( theta );\n let tanTheta2 = tanTheta * tanTheta;\n let alpha2 = alpha * alpha;\n\n let numerator = - 1.0 + sqrt( 1.0 + alpha2 * tanTheta2 );\n return numerator / 2.0;\n\n }\n\n"), no = P("\n\n fn ggxShadowMaskG1( cosTheta: f32, alpha: f32 ) -> f32 {\n\n let a2 = alpha * alpha;\n let cosTheta2 = cosTheta * cosTheta;\n let denom = cosTheta + sqrt( cosTheta2 * ( 1 - a2 ) + a2 );\n return 2.0 * cosTheta / denom;\n\n }\n\n", [to]), ro = P("\n\n fn ggxSmithVisibility( NdotV: f32, NdotL: f32, alpha: f32 ) -> f32 {\n\n // Original formulation of G_SmithGGX Correlated\n // lambda_v = ( -1 + sqrt ( alphaG2 * (1 - NdotL2 ) / NdotL2 + 1)) * 0.5 f;\n // lambda_l = ( -1 + sqrt ( alphaG2 * (1 - NdotV2 ) / NdotV2 + 1)) * 0.5 f;\n // G_SmithGGXCorrelated = 1 / (1 + lambda_v + lambda_l );\n // V_SmithGGXCorrelated = G_SmithGGXCorrelated / (4.0 f * NdotL * NdotV );\n\n // This is an optimized version\n let alpha2 = alpha * alpha;\n // Caution: the \"NdotL *\" and \"NdotV *\" are explicitely inversed , this is not a mistake.\n let Lambda_GGXV = NdotL * sqrt (( - NdotV * alpha2 + NdotV ) * NdotV + alpha2 );\n let Lambda_GGXL = NdotV * sqrt (( - NdotL * alpha2 + NdotL ) * NdotL + alpha2 );\n\n return 0.5 / ( Lambda_GGXV + Lambda_GGXL );\n\n }\n\n", [to]), io = P("\n fn ggxDistribution( NdotH: f32, alpha: f32 ) -> f32 {\n\n let a2 = max( alpha * alpha, EPSILON );\n let denom = NdotH * NdotH * ( a2 - 1 ) + 1;\n\n return ( a2 / ( PI * denom * denom ) );\n\n }\n"), ao = P("\n fn ggxReflectionAdjustedPDF( NdotV: f32, NdotH: f32, alpha: f32 ) -> f32 {\n\n let D = ggxDistribution( NdotH, alpha );\n let G1 = ggxShadowMaskG1( NdotV, alpha );\n\n return D * G1 / ( 4 * NdotV );\n\n }\n", [io, no]), oo = (e) => P("\n\n fn getSurfaceRecord(\n material: Material,\n vertexData: bvh_GeometryStruct,\n side: f32,\n faceNormal: vec3f,\n ) -> SurfaceRecord {\n let uv = vertexData.uv.xy;\n\n var normal = faceNormal * side;\n if ( material.flatShading == 0 ) {\n\n normal = vertexData.normal.xyz;\n\n }\n normal = normalize( normal );\n let baseNormal = normal;\n\n if ( material.normalMap != -1 ) {\n\n // some provided tangents can be malformed (0, 0, 0) causing the normal to be degenerate\n // resulting in NaNs and slow path tracing.\n if ( length( vertexData.tangent.xyz ) > 0.0 && vertexData.tangent.w != 0.0 ) {\n\n let tangent = normalize( vertexData.tangent.xyz );\n let bitangent = normalize( cross( baseNormal, tangent ) * vertexData.tangent.w );\n let vTBN = mat3x3f( tangent, bitangent, baseNormal );\n\n let uvPrime = material.normalMapTransform * vec3( uv, 1.0 );\n var texNormal = sampleTexel( uvPrime.xy, material.normalMap, 0 ).xyz;\n texNormal = texNormal * 2.0 - 1.0;\n texNormal = texNormal * vec3f( material.normalScale, 1.0 );\n normal = normalize( vTBN * texNormal );\n\n }\n\n }\n\n normal *= side;\n\n var albedo = vec4( material.color, material.opacity );\n\n if ( material.vertexColors == 1 ) {\n\n let vertexColor = vertexData.color.xyz;\n albedo *= vec4f( vertexColor, 1.0 );\n\n }\n\n if ( material.map != -1 ) {\n\n let uvPrime = material.mapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.map, 0 );\n albedo *= vec4f( texColor.rgb, 1.0 );\n\n }\n\n var roughness = material.roughness;\n if ( material.roughnessMap != -1 ) {\n\n let uvPrime = material.roughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.roughnessMap, 0 );\n roughness *= texColor.g;\n\n }\n\n var metalness = material.metalness;\n if ( material.metalnessMap != -1 ) {\n\n let uvPrime = material.metalnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.metalnessMap, 0 );\n metalness *= texColor.b;\n\n }\n\n var emission = material.emissiveIntensity * material.emissive;\n if ( material.emissiveMap != -1 ) {\n\n let uvPrime = material.emissiveMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.emissiveMap, 0 );\n emission *= texColor.rgb;\n\n }\n\n var transmission = material.transmission;\n if ( material.transmissionMap != -1 ) {\n\n let uvPrime = material.transmissionMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.transmissionMap, 0 );\n transmission *= texColor.r;\n\n }\n\n var clearcoat = material.clearcoat;\n if ( material.clearcoatMap != -1 ) {\n\n let uvPrime = material.clearcoatMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.clearcoatMap, 0 );\n clearcoat *= texColor.r;\n\n }\n\n var clearcoatRoughness = material.clearcoatRoughness;\n if ( material.clearcoatRoughnessMap != -1 ) {\n\n let uvPrime = material.clearcoatRoughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.clearcoatRoughnessMap, 0 );\n clearcoatRoughness *= texColor.g;\n\n }\n\n var clearcoatNormal = baseNormal;\n if ( material.clearcoatNormalMap != -1 ) {\n\n // some provided tangents can be malformed (0, 0, 0) causing the normal to be degenerate\n // resulting in NaNs and slow path tracing.\n if ( length( vertexData.tangent.xyz ) > 0.0 && vertexData.tangent.w != 0.0 ) {\n\n let tangent = normalize( vertexData.tangent.xyz );\n let bitangent = normalize( cross( baseNormal, tangent ) * vertexData.tangent.w );\n let vTBN = mat3x3f( tangent, bitangent, baseNormal );\n\n let uvPrime = material.clearcoatNormalMapTransform * vec3( uv, 1.0 );\n var texNormal = sampleTexel( uvPrime.xy, material.clearcoatNormalMap, 0 ).xyz;\n texNormal = texNormal * 2.0 - 1.0;\n texNormal = texNormal * vec3f( material.clearcoatNormalScale, 1.0 );\n clearcoatNormal = normalize( vTBN * texNormal );\n\n }\n\n }\n clearcoatNormal *= side;\n\n var sheenColor = material.sheenColor;\n if ( material.sheenColorMap != -1 ) {\n\n let uvPrime = material.sheenColorMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.sheenColorMap, 0 );\n sheenColor *= texColor.rgb;\n\n }\n\n var sheenRoughness = material.sheenRoughness;\n if ( material.sheenRoughnessMap != -1 ) {\n\n let uvPrime = material.sheenRoughnessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.sheenRoughnessMap, 0 );\n sheenRoughness *= texColor.r;\n\n }\n\n var iridescence = material.iridescence;\n if ( material.iridescenceMap != -1 ) {\n\n let uvPrime = material.iridescenceMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.iridescenceMap, 0 );\n iridescence *= texColor.r;\n\n }\n\n var iridescenceThickness = material.iridescenceThicknessMaximum;\n if ( material.iridescenceThicknessMap != -1 ) {\n\n let uvPrime = material.iridescenceThicknessMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.iridescenceThicknessMap, 0 );\n\n iridescenceThickness = mix(\n material.iridescenceThicknessMinimum,\n material.iridescenceThicknessMaximum,\n texColor.g,\n );\n\n }\n\n var specularColor = material.specularColor;\n if ( material.specularColorMap != -1 ) {\n\n let uvPrime = material.specularColorMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.specularColorMap, 0 );\n specularColor *= texColor.rgb;\n\n }\n\n var specularIntensity = material.specularIntensity;\n if ( material.specularIntensityMap != -1 ) {\n\n let uvPrime = material.specularIntensityMapTransform * vec3f( uv, 1 );\n let texColor = sampleTexel( uvPrime.xy, material.specularIntensityMap, 0 );\n specularIntensity *= texColor.r;\n\n }\n\n var surf: SurfaceRecord;\n\n surf.volumeParticle = false;\n surf.faceNormal = faceNormal;\n surf.normal = normal;\n\n surf.metalness = metalness;\n surf.color = albedo.rgb;\n surf.emission = emission;\n\n surf.ior = material.ior;\n surf.transmission = transmission;\n surf.thinFilm = material.thinFilm == 1;\n surf.attenuationColor = material.attenuationColor;\n surf.attenuationDistance = material.attenuationDistance;\n\n surf.clearcoatNormal = clearcoatNormal;\n surf.clearcoat = clearcoat;\n\n surf.iridescence = iridescence;\n surf.iridescenceIor = material.iridescenceIor;\n surf.iridescenceThickness = iridescenceThickness;\n\n surf.specularColor = specularColor;\n surf.specularIntensity = specularIntensity;\n\n surf.roughness = clamp( roughness, MIN_ROUGHNESS, 1.0 );\n surf.clearcoatRoughness = clamp( clearcoatRoughness, MIN_ROUGHNESS, 1.0 );\n surf.sheenRoughness = clamp( sheenRoughness, MIN_ROUGHNESS, 1.0 );\n\n // frontFace is used to determine transmissive properties and PDF. If no transmission is used\n // then we can just always assume this is a front face.\n surf.frontFace = side == 1.0 || transmission == 0.0;\n if ( material.thinFilm == 1 || surf.frontFace ) {\n surf.eta = 1.0 / material.ior;\n } else {\n surf.eta = material.ior;\n }\n surf.f0 = iorToF0( surf.eta );\n\n // get the normal frames\n surf.normalBasis = getBasisFromNormal( surf.normal );\n surf.normalInvBasis = inverse( surf.normalBasis );\n\n surf.clearcoatBasis = getBasisFromNormal( surf.clearcoatNormal );\n surf.clearcoatInvBasis = inverse( surf.clearcoatBasis );\n\n return surf;\n }\n\n", [
4166
4166
  fa,
4167
4167
  ma,
4168
4168
  pa,
4169
4169
  e,
4170
4170
  ca,
4171
4171
  aa
4172
- ]), so = j("\n\n fn diffuseBrdf( NdotV: f32, NdotL: f32, VdotH: f32, surf: SurfaceRecord ) -> vec3f {\n\n // https://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf\n // See equation (4)\n\n let fl = schlickFresnel( NdotL, 0.0 );\n let fv = schlickFresnel( NdotV, 0.0 );\n\n let alpha = surf.roughness * surf.roughness;\n let bias = mix( 0.0, 0.5, alpha ) - 1;\n let energyFactor = mix( 1.0, 1.0 / 1.51, alpha );\n\n let rr = 2.0 * alpha * VdotH * VdotH;\n let retro = rr * ( fl + fv + fl * fv * ( rr + 2.0 * bias ) );\n let fresnel = ( 1.0 + bias * fl ) * ( 1.0f + bias * fv );\n\n // TODO: subsurface approx?\n\n return energyFactor * ( surf.color / PI ) * ( retro + fresnel );\n\n }\n\n", [
4172
+ ]), so = P("\n\n fn diffuseBrdf( NdotV: f32, NdotL: f32, VdotH: f32, surf: SurfaceRecord ) -> vec3f {\n\n // https://blog.selfshadow.com/publications/s2015-shading-course/burley/s2015_pbs_disney_bsdf_notes.pdf\n // See equation (4)\n\n let fl = schlickFresnel( NdotL, 0.0 );\n let fv = schlickFresnel( NdotV, 0.0 );\n\n let alpha = surf.roughness * surf.roughness;\n let bias = mix( 0.0, 0.5, alpha ) - 1;\n let energyFactor = mix( 1.0, 1.0 / 1.51, alpha );\n\n let rr = 2.0 * alpha * VdotH * VdotH;\n let retro = rr * ( fl + fv + fl * fv * ( rr + 2.0 * bias ) );\n let fresnel = ( 1.0 + bias * fl ) * ( 1.0f + bias * fv );\n\n // TODO: subsurface approx?\n\n return energyFactor * ( surf.color / PI ) * ( retro + fresnel );\n\n }\n\n", [
4173
4173
  aa,
4174
4174
  va,
4175
4175
  ca
4176
- ]), co = j("\n\n fn specularBrdf( NdotL: f32, NdotV: f32, NdotH: f32, alpha: f32 ) -> vec3f {\n\n let Vis = ggxSmithVisibility( NdotV, NdotL, alpha );\n let D = ggxDistribution( NdotH, alpha );\n\n return vec3f( D * Vis );\n\n }\n\n", [ro, io]), lo = j("\n\n fn fresnelMix( VdotH: f32, ior: f32, base: vec3f, layer: vec3f ) -> vec3f {\n\n let f0 = iorToF0( ior );\n let F = schlickFresnel( abs( VdotH ), f0 );\n\n return base + F * layer;\n\n }\n\n", [va, ma]), uo = Ce(3.2404542, -.969266, .0556434, -1.5371385, 1.8760108, -.2040259, -.4985314, .041556, 1.0572252), fo = j("\n\n fn iridescentFresnel(\n cosTheta1: f32, baseF0: vec3f, iridescenceIor: f32,\n outsideIor: f32, iridescenceThickness: f32,\n ) -> vec3f {\n\n let sinTheta2Sq = pow( outsideIor / iridescenceIor, 2.0 ) * ( 1.0 - pow( cosTheta1, 2.0 ) );\n let cosTheta2Sq = 1.0 - sinTheta2Sq;\n\n // Handle total internal reflection\n if ( cosTheta2Sq < 0.0 ) {\n\n return vec3( 1.0 );\n\n }\n\n let cosTheta2 = sqrt( cosTheta2Sq );\n\n // First interface: air -> iridescent thin film\n let R0 = iorToF0General( iridescenceIor, outsideIor );\n let R12 = schlickFresnel( cosTheta1, R0 );\n let R21 = R12;\n let T121 = 1.0 - R12;\n let phi12 = select( 0.0, PI, iridescenceIor < outsideIor );\n let phi21 = PI - phi12;\n\n // Second interface: iridescent thin film -> base material\n let baseIor = fresnel0ToIor( baseF0 + 0.0001 ); // guard against 1.0\n let R1 = iorToF0GeneralVec( baseIor, vec3( iridescenceIor ) );\n let R23 = schlickFresnelVec( cosTheta2, R1, vec3( 1.0 ) );\n let phi23 = select( vec3( 0.0 ), vec3( PI ), baseIor < vec3( iridescenceIor ) );\n\n // Phase shift\n let OPD = 2.0 * iridescenceIor * iridescenceThickness * cosTheta2;\n let phi = vec3( phi21 ) + phi23;\n\n // Analytical integration\n // Compound terms\n let R123 = clamp( R12 * R23, vec3( 1e-5 ), vec3( 0.9999 ) );\n let r123 = sqrt( R123 );\n let Rs = T121 * T121 * R23 / ( vec3( 1.0 ) - R123 );\n\n // Reflectance term for m = 0 (DC term amplitude)\n let C0 = R12 + Rs;\n var I = C0;\n\n // Reflectance term for m > 0 (pairs of diracs)\n var Cm = Rs - T121;\n for (var m = 1; m <= 2; m += 1) {\n\n Cm *= r123;\n let Sm = 2.0 * evalSensitivity( f32( m ) * OPD, f32( m ) * phi );\n I += Cm * Sm;\n\n }\n\n return max( I, vec3(0.0) );\n\n }\n\n", [
4176
+ ]), co = P("\n\n fn specularBrdf( NdotL: f32, NdotV: f32, NdotH: f32, alpha: f32 ) -> vec3f {\n\n let Vis = ggxSmithVisibility( NdotV, NdotL, alpha );\n let D = ggxDistribution( NdotH, alpha );\n\n return vec3f( D * Vis );\n\n }\n\n", [ro, io]), lo = P("\n\n fn fresnelMix( VdotH: f32, ior: f32, base: vec3f, layer: vec3f ) -> vec3f {\n\n let f0 = iorToF0( ior );\n let F = schlickFresnel( abs( VdotH ), f0 );\n\n return base + F * layer;\n\n }\n\n", [va, ma]), uo = Se(3.2404542, -.969266, .0556434, -1.5371385, 1.8760108, -.2040259, -.4985314, .041556, 1.0572252), fo = P("\n\n fn iridescentFresnel(\n cosTheta1: f32, baseF0: vec3f, iridescenceIor: f32,\n outsideIor: f32, iridescenceThickness: f32,\n ) -> vec3f {\n\n let sinTheta2Sq = pow( outsideIor / iridescenceIor, 2.0 ) * ( 1.0 - pow( cosTheta1, 2.0 ) );\n let cosTheta2Sq = 1.0 - sinTheta2Sq;\n\n // Handle total internal reflection\n if ( cosTheta2Sq < 0.0 ) {\n\n return vec3( 1.0 );\n\n }\n\n let cosTheta2 = sqrt( cosTheta2Sq );\n\n // First interface: air -> iridescent thin film\n let R0 = iorToF0General( iridescenceIor, outsideIor );\n let R12 = schlickFresnel( cosTheta1, R0 );\n let R21 = R12;\n let T121 = 1.0 - R12;\n let phi12 = select( 0.0, PI, iridescenceIor < outsideIor );\n let phi21 = PI - phi12;\n\n // Second interface: iridescent thin film -> base material\n let baseIor = fresnel0ToIor( baseF0 + 0.0001 ); // guard against 1.0\n let R1 = iorToF0GeneralVec( baseIor, vec3( iridescenceIor ) );\n let R23 = schlickFresnelVec( cosTheta2, R1, vec3( 1.0 ) );\n let phi23 = select( vec3( 0.0 ), vec3( PI ), baseIor < vec3( iridescenceIor ) );\n\n // Phase shift\n let OPD = 2.0 * iridescenceIor * iridescenceThickness * cosTheta2;\n let phi = vec3( phi21 ) + phi23;\n\n // Analytical integration\n // Compound terms\n let R123 = clamp( R12 * R23, vec3( 1e-5 ), vec3( 0.9999 ) );\n let r123 = sqrt( R123 );\n let Rs = T121 * T121 * R23 / ( vec3( 1.0 ) - R123 );\n\n // Reflectance term for m = 0 (DC term amplitude)\n let C0 = R12 + Rs;\n var I = C0;\n\n // Reflectance term for m > 0 (pairs of diracs)\n var Cm = Rs - T121;\n for (var m = 1; m <= 2; m += 1) {\n\n Cm *= r123;\n let Sm = 2.0 * evalSensitivity( f32( m ) * OPD, f32( m ) * phi );\n I += Cm * Sm;\n\n }\n\n return max( I, vec3(0.0) );\n\n }\n\n", [
4177
4177
  ha,
4178
4178
  ga,
4179
4179
  va,
@@ -4197,11 +4197,11 @@ var eo = j("\n\n fn ggxDirection( incidentDir: vec3f, alpha: vec2f, uv: vec2f )
4197
4197
  }
4198
4198
 
4199
4199
  `
4200
- ]), po = j("\n\n fn iridescentDielectricLayer(\n dielectricBase: vec3f, base: vec3f, specular: vec3f, HdotL: f32,\n outsideIor: f32, baseIor: f32, iridescenceIor: f32, thickness: f32, strength: f32,\n ) -> vec3f {\n\n let baseF0 = vec3( iorToF0( baseIor ) );\n\n let iridescentF = iridescentFresnel( HdotL, baseF0, iridescenceIor, outsideIor, thickness );\n\n return mix( dielectricBase, rgbMix( base, specular, iridescentF ), strength );\n\n }\n\n", [
4200
+ ]), po = P("\n\n fn iridescentDielectricLayer(\n dielectricBase: vec3f, base: vec3f, specular: vec3f, HdotL: f32,\n outsideIor: f32, baseIor: f32, iridescenceIor: f32, thickness: f32, strength: f32,\n ) -> vec3f {\n\n let baseF0 = vec3( iorToF0( baseIor ) );\n\n let iridescentF = iridescentFresnel( HdotL, baseF0, iridescenceIor, outsideIor, thickness );\n\n return mix( dielectricBase, rgbMix( base, specular, iridescentF ), strength );\n\n }\n\n", [
4201
4201
  ma,
4202
4202
  fo,
4203
- j("\n\n fn rgbMix( base: vec3f, specular: vec3f, rgbAlpha: vec3f ) -> vec3f {\n\n let alphaMax = max( max( rgbAlpha.x, rgbAlpha.y ), rgbAlpha.z );\n return ( 1 - alphaMax ) * base + rgbAlpha * specular;\n\n }\n\n")
4204
- ]), mo = j("\n\n fn iridescentConductorLayer(\n metalBase: vec3f, specular: vec3f, baseF0: vec3f, HdotL: f32,\n outsideIor: f32, iridescenceIor: f32, thickness: f32, strength: f32,\n ) -> vec3f {\n\n let iridescenceF = iridescentFresnel( HdotL, baseF0, iridescenceIor, outsideIor, thickness );\n\n return mix( metalBase, specular * iridescenceF, strength );\n\n }\n\n", [fo]), ho = (e) => j("\n\n fn conductorFresnel( NdotV: f32, VdotH: f32, f0: vec3f, bsdf: vec3f, alpha: f32 ) -> vec3f {\n\n let ss = bsdf * schlickFresnelVec( abs( VdotH ), f0, vec3f( 1 ) );\n\n let uv = vec2( NdotV, sqrt( alpha ) );\n let energySs = max( textureSampleLevel( turquinTexture, turquinTexture_sampler, uv, 0 ).r, 1e-5 );\n\n return ss * ( 1.0 + f0 * ( 1.0 - energySs ) / energySs );\n\n }\n\n", [ya, e]), go = j("\n\n fn fresnelCoat( VdotNc: f32, ior: f32, base: vec3f, layer: vec3f, weight: f32 ) -> vec3f {\n\n let f0 = iorToF0( ior );\n let F = schlickFresnel( abs( VdotNc ), f0 );\n\n return mix( base, layer, weight * F );\n\n }\n\n", [ma, va]), _o = $`
4203
+ P("\n\n fn rgbMix( base: vec3f, specular: vec3f, rgbAlpha: vec3f ) -> vec3f {\n\n let alphaMax = max( max( rgbAlpha.x, rgbAlpha.y ), rgbAlpha.z );\n return ( 1 - alphaMax ) * base + rgbAlpha * specular;\n\n }\n\n")
4204
+ ]), mo = P("\n\n fn iridescentConductorLayer(\n metalBase: vec3f, specular: vec3f, baseF0: vec3f, HdotL: f32,\n outsideIor: f32, iridescenceIor: f32, thickness: f32, strength: f32,\n ) -> vec3f {\n\n let iridescenceF = iridescentFresnel( HdotL, baseF0, iridescenceIor, outsideIor, thickness );\n\n return mix( metalBase, specular * iridescenceF, strength );\n\n }\n\n", [fo]), ho = (e) => P("\n\n fn conductorFresnel( NdotV: f32, VdotH: f32, f0: vec3f, bsdf: vec3f, alpha: f32 ) -> vec3f {\n\n let ss = bsdf * schlickFresnelVec( abs( VdotH ), f0, vec3f( 1 ) );\n\n let uv = vec2( NdotV, sqrt( alpha ) );\n let energySs = max( textureSampleLevel( turquinTexture, turquinTexture_sampler, uv, 0 ).r, 1e-5 );\n\n return ss * ( 1.0 + f0 * ( 1.0 - energySs ) / energySs );\n\n }\n\n", [ya, e]), go = P("\n\n fn fresnelCoat( VdotNc: f32, ior: f32, base: vec3f, layer: vec3f, weight: f32 ) -> vec3f {\n\n let f0 = iorToF0( ior );\n let F = schlickFresnel( abs( VdotNc ), f0 );\n\n return mix( base, layer, weight * F );\n\n }\n\n", [ma, va]), _o = $`
4205
4205
 
4206
4206
  fn albedo(
4207
4207
  texture: texture_storage_2d<r16float, write>,
@@ -4421,7 +4421,7 @@ var wo = class {
4421
4421
  }), this.structs.transform = Eo, this.structs.material = sa, this.storage.materials = null, this.materials = [], this.bvhMap = /* @__PURE__ */ new Map(), this.textureAtlas = new wo();
4422
4422
  }
4423
4423
  useTransparencyRaycastFn() {
4424
- let { textureAtlas: e, storage: t, structs: n, fns: r } = this, i = e.texture, a = Ca(Se(e.textureInfo, "uvec4"), F(i), De(i));
4424
+ let { textureAtlas: e, storage: t, structs: n, fns: r } = this, i = e.texture, a = Ca(xe(e.textureInfo, "uvec4"), Me(i), ke(i));
4425
4425
  r.getSurfaceRecord = oo(a);
4426
4426
  let o = new _e(n.material).toVar("bvh_material"), s = Ae(1).toVar("bvh_rayScalar"), c = Ae(1).toVar("bvh_baseOpacity");
4427
4427
  r.raycastFirstHit = this.getShapecastFn({
@@ -4606,7 +4606,7 @@ var wo = class {
4606
4606
  super.update();
4607
4607
  let { materials: e, structs: t } = this, { materialData: n, textures: r } = this.writeMaterialsBuffer(e);
4608
4608
  this.textures = r;
4609
- let i = P(new me(n, t.material.getLength()), t.material).toReadOnly().setName("bvh_materials");
4609
+ let i = N(new me(n, t.material.getLength()), t.material).toReadOnly().setName("bvh_materials");
4610
4610
  this.storage.materials = i, this.bvhMap.clear(), this.materials.length = 0, this.useTransparencyRaycastFn();
4611
4611
  }
4612
4612
  writeMaterialsBuffer(e) {
@@ -4723,7 +4723,7 @@ var wo = class {
4723
4723
  this._layerUniform.value = e;
4724
4724
  }
4725
4725
  constructor() {
4726
- super(), this.blending = 0, this._texNode = F(new h()), this._layerUniform = N(0), this.colorNode = j("\n fn atlasDebug( tex: texture_2d_array<f32>, coord: vec2f, layer: f32 ) -> vec4f {\n\n // flip y so texel origin shows at the top-left\n let dims = vec2f( textureDimensions( tex, 0 ).xy );\n let texel = vec2i( vec2f( coord.x, 1.0 - coord.y ) * dims );\n return textureLoad( tex, texel, i32( layer ), 0 );\n\n }\n ")(this._texNode, be(ke()), this._layerUniform);
4726
+ super(), this.blending = 0, this._texNode = Me(new h()), this._layerUniform = M(0), this.colorNode = P("\n fn atlasDebug( tex: texture_2d_array<f32>, coord: vec2f, layer: f32 ) -> vec4f {\n\n // flip y so texel origin shows at the top-left\n let dims = vec2f( textureDimensions( tex, 0 ).xy );\n let texel = vec2i( vec2f( coord.x, 1.0 - coord.y ) * dims );\n return textureLoad( tex, texel, i32( layer ), 0 );\n\n }\n ")(this._texNode, De(be()), this._layerUniform);
4727
4727
  }
4728
4728
  };
4729
4729
  //#endregion
@@ -4783,13 +4783,13 @@ var Ao = class {
4783
4783
  super();
4784
4784
  let { specularBrdf: t = co, diffuseBrdf: n = so, fresnelMix: r = lo, conductorFresnel: i = ho, fresnelCoat: a = go, iridescentDielectricLayer: o = po, iridescentConductorLayer: s = mo, calculateTurquinTexture: c = !1 } = e;
4785
4785
  c ? (this.turquinTexture = new k(32, 32), this.turquinTexture.type = w) : (this.turquinTexture = Mo, this.turquinTexture.flipY = !1), this.turquinTexture.format = ne, this.turquinTexture.minFilter = T, this.turquinTexture.magFilter = T;
4786
- let l = F(this.turquinTexture).setName("turquinTexture");
4786
+ let l = Me(this.turquinTexture).setName("turquinTexture");
4787
4787
  this.specularBrdf = t, this.diffuseBrdf = n, this.fresnelMix = r, this.conductorFresnel = i(l), this.fresnelCoat = a, this.iridescentDielectricLayer = o, this.iridescentConductorLayer = s, this.calculateTurquinTexture = c;
4788
4788
  }
4789
4789
  init(e) {
4790
4790
  if (!this.calculateTurquinTexture) return;
4791
4791
  let t = new zi(_o({
4792
- texture: M(this.turquinTexture).toWriteOnly(),
4792
+ texture: j(this.turquinTexture).toWriteOnly(),
4793
4793
  globalId: Oe
4794
4794
  }), { workgroupSize: [
4795
4795
  16,
@@ -5081,4 +5081,4 @@ function zo(e, t, n) {
5081
5081
  //#endregion
5082
5082
  export { Ro as WebGPUPathTracer };
5083
5083
 
5084
- //# sourceMappingURL=webgpu-BMwlJflc.mjs.map
5084
+ //# sourceMappingURL=webgpu-B0rxiqW-.mjs.map