@takram/three-geospatial 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/index.cjs +1 -1
  3. package/build/index.cjs.map +1 -1
  4. package/build/index.js +359 -373
  5. package/build/index.js.map +1 -1
  6. package/build/r3f.cjs.map +1 -1
  7. package/build/r3f.js.map +1 -1
  8. package/build/shaders.cjs.map +1 -1
  9. package/build/shaders.js.map +1 -1
  10. package/build/shared.cjs.map +1 -1
  11. package/build/shared.js.map +1 -1
  12. package/build/shared2.cjs +1 -1
  13. package/build/shared2.cjs.map +1 -1
  14. package/build/shared2.js +55 -61
  15. package/build/shared2.js.map +1 -1
  16. package/build/shared3.cjs.map +1 -1
  17. package/build/shared3.js.map +1 -1
  18. package/build/webgpu.cjs +1 -1
  19. package/build/webgpu.cjs.map +1 -1
  20. package/build/webgpu.js +511 -630
  21. package/build/webgpu.js.map +1 -1
  22. package/package.json +1 -2
  23. package/src/EXR3DTextureLoader.ts +1 -1
  24. package/src/EXRTextureLoader.ts +1 -1
  25. package/src/webgpu/DownsampleThresholdNode.ts +3 -4
  26. package/src/webgpu/DualMipmapFilterNode.ts +1 -1
  27. package/src/webgpu/FnLayout.ts +5 -5
  28. package/src/webgpu/GaussianBlurNode.ts +3 -3
  29. package/src/webgpu/HighpVelocityNode.ts +8 -4
  30. package/src/webgpu/KawaseBlurNode.ts +3 -3
  31. package/src/webgpu/LensFlareNode.ts +10 -19
  32. package/src/webgpu/LensGlareNode.ts +8 -11
  33. package/src/webgpu/MipmapBlurNode.ts +7 -7
  34. package/src/webgpu/MipmapSurfaceBlurNode.ts +5 -6
  35. package/src/webgpu/OutputTexture3DNode.ts +1 -5
  36. package/src/webgpu/OutputTextureNode.ts +1 -4
  37. package/src/webgpu/RTTextureNode.ts +6 -8
  38. package/src/webgpu/TemporalAntialiasNode.ts +20 -23
  39. package/src/webgpu/accessors.ts +8 -10
  40. package/src/webgpu/generators.ts +7 -9
  41. package/src/webgpu/math.ts +13 -13
  42. package/src/webgpu/node.ts +3 -6
  43. package/src/webgpu/sampling.ts +3 -51
  44. package/src/webgpu/transformations.ts +30 -35
  45. package/src/webgpu/utils.ts +9 -9
  46. package/types/webgpu/DownsampleThresholdNode.d.ts +4 -4
  47. package/types/webgpu/DualMipmapFilterNode.d.ts +2 -2
  48. package/types/webgpu/FnLayout.d.ts +3 -3
  49. package/types/webgpu/GaussianBlurNode.d.ts +2 -2
  50. package/types/webgpu/HighpVelocityNode.d.ts +2 -3
  51. package/types/webgpu/KawaseBlurNode.d.ts +2 -2
  52. package/types/webgpu/LensFlareNode.d.ts +4 -4
  53. package/types/webgpu/LensGhostNode.d.ts +1 -1
  54. package/types/webgpu/LensGlareNode.d.ts +5 -5
  55. package/types/webgpu/LensHaloNode.d.ts +2 -2
  56. package/types/webgpu/MipmapBlurNode.d.ts +4 -4
  57. package/types/webgpu/MipmapSurfaceBlurNode.d.ts +3 -3
  58. package/types/webgpu/OutputTexture3DNode.d.ts +1 -2
  59. package/types/webgpu/OutputTextureNode.d.ts +1 -2
  60. package/types/webgpu/RTTextureNode.d.ts +2 -3
  61. package/types/webgpu/SeparableFilterNode.d.ts +2 -2
  62. package/types/webgpu/SingleFilterNode.d.ts +1 -1
  63. package/types/webgpu/TemporalAntialiasNode.d.ts +6 -6
  64. package/types/webgpu/accessors.d.ts +8 -8
  65. package/types/webgpu/generators.d.ts +4 -4
  66. package/types/webgpu/node.d.ts +4 -5
  67. package/types/webgpu/sampling.d.ts +0 -1
  68. package/types/webgpu/transformations.d.ts +8 -8
  69. package/types/webgpu/utils.d.ts +1 -2
package/build/shared2.js CHANGED
@@ -1,30 +1,23 @@
1
- import { Vector3 as a, Matrix4 as G, BufferGeometry as j, BufferAttribute as N } from "three";
2
- import { i as L } from "./shared.js";
3
- const B = /* @__PURE__ */ new a();
4
- function O(v, t, i = new a(), s) {
5
- const { x: r, y: e, z: n } = v, o = t.x, h = t.y, u = t.z, d = r * r * o, m = e * e * h, c = n * n * u, l = d + m + c, y = Math.sqrt(1 / l);
6
- if (!Number.isFinite(y))
1
+ import { Vector3 as a, Matrix4 as T, BufferGeometry as W, BufferAttribute as S } from "three";
2
+ import { i as O } from "./shared.js";
3
+ const $ = /* @__PURE__ */ new a();
4
+ function D(q, t, i = new a(), s) {
5
+ const { x: r, y: e, z: n } = q, o = t.x, h = t.y, u = t.z, d = r * r * o, m = e * e * h, c = n * n * u, l = d + m + c, p = Math.sqrt(1 / l);
6
+ if (!Number.isFinite(p))
7
7
  return;
8
- const w = B.copy(v).multiplyScalar(y);
8
+ const w = $.copy(q).multiplyScalar(p);
9
9
  if (l < (s?.centerTolerance ?? 0.1))
10
10
  return i.copy(w);
11
- const z = w.multiply(t).multiplyScalar(2);
12
- let p = (1 - y) * v.length() / (z.length() / 2), f = 0, x, M, g, I;
11
+ const f = w.multiply(t).multiplyScalar(2);
12
+ let y = (1 - p) * q.length() / (f.length() / 2), I = 0, x, M, g, v;
13
13
  do {
14
- p -= f, x = 1 / (1 + p * o), M = 1 / (1 + p * h), g = 1 / (1 + p * u);
15
- const U = x * x, V = M * M, F = g * g, P = U * x, C = V * M, D = F * g;
16
- I = d * U + m * V + c * F - 1, f = I / ((d * P * o + m * C * h + c * D * u) * -2);
17
- } while (Math.abs(I) > 1e-12);
14
+ y -= I, x = 1 / (1 + y * o), M = 1 / (1 + y * h), g = 1 / (1 + y * u);
15
+ const V = x * x, F = M * M, L = g * g, G = V * x, j = F * M, B = L * g;
16
+ v = d * V + m * F + c * L - 1, I = v / ((d * G * o + m * j * h + c * B * u) * -2);
17
+ } while (Math.abs(v) > 1e-12);
18
18
  return i.set(r * x, e * M, n * g);
19
19
  }
20
- const E = /* @__PURE__ */ new a(), b = /* @__PURE__ */ new a(), S = /* @__PURE__ */ new a();
21
- class A {
22
- static WGS84 = /* @__PURE__ */ new A(
23
- 6378137,
24
- 6378137,
25
- 6356752314245179e-9
26
- );
27
- radii;
20
+ const E = /* @__PURE__ */ new a(), R = /* @__PURE__ */ new a(), U = /* @__PURE__ */ new a(), b = class b {
28
21
  constructor(t, i, s) {
29
22
  this.radii = new a(t, i, s);
30
23
  }
@@ -55,7 +48,7 @@ class A {
55
48
  return t.set(1 / i ** 2, 1 / s ** 2, 1 / r ** 2);
56
49
  }
57
50
  projectOnSurface(t, i = new a(), s) {
58
- return O(
51
+ return D(
59
52
  t,
60
53
  this.reciprocalRadiiSquared(),
61
54
  i,
@@ -68,16 +61,16 @@ class A {
68
61
  getEastNorthUpVectors(t, i = new a(), s = new a(), r = new a()) {
69
62
  this.getSurfaceNormal(t, r), i.set(-t.y, t.x, 0).normalize(), s.crossVectors(r, i).normalize();
70
63
  }
71
- getEastNorthUpFrame(t, i = new G()) {
72
- const s = E, r = b, e = S;
64
+ getEastNorthUpFrame(t, i = new T()) {
65
+ const s = E, r = R, e = U;
73
66
  return this.getEastNorthUpVectors(t, s, r, e), i.makeBasis(s, r, e).setPosition(t);
74
67
  }
75
- getNorthUpEastFrame(t, i = new G()) {
76
- const s = E, r = b, e = S;
68
+ getNorthUpEastFrame(t, i = new T()) {
69
+ const s = E, r = R, e = U;
77
70
  return this.getEastNorthUpVectors(t, s, r, e), i.makeBasis(r, e, s).setPosition(t);
78
71
  }
79
72
  getIntersection(t, i = new a()) {
80
- const s = this.reciprocalRadii(E), r = b.copy(s).multiply(t.origin), e = S.copy(s).multiply(t.direction), n = r.lengthSq(), o = e.lengthSq(), h = r.dot(e), u = h ** 2 - o * (n - 1);
73
+ const s = this.reciprocalRadii(E), r = R.copy(s).multiply(t.origin), e = U.copy(s).multiply(t.direction), n = r.lengthSq(), o = e.lengthSq(), h = r.dot(e), u = h ** 2 - o * (n - 1);
81
74
  if (n === 1)
82
75
  return i.copy(t.origin);
83
76
  if (n > 1) {
@@ -94,7 +87,7 @@ class A {
94
87
  return t.at(-h / o, i);
95
88
  }
96
89
  getOsculatingSphereCenter(t, i, s = new a()) {
97
- L(this.radii.x === this.radii.y);
90
+ O(this.radii.x === this.radii.y);
98
91
  const r = this.radii.x ** 2, e = this.radii.z ** 2, n = E.set(
99
92
  t.x / r,
100
93
  t.y / r,
@@ -103,59 +96,58 @@ class A {
103
96
  return s.copy(n.multiplyScalar(-i).add(t));
104
97
  }
105
98
  getNormalAtHorizon(t, i, s = new a()) {
106
- L(this.radii.x === this.radii.y);
99
+ O(this.radii.x === this.radii.y);
107
100
  const r = this.radii.x ** 2, e = this.radii.z ** 2, n = t, o = i;
108
101
  let h = (n.x * o.x + n.y * o.y) / r + n.z * o.z / e;
109
102
  h /= (n.x ** 2 + n.y ** 2) / r + n.z ** 2 / e;
110
103
  const u = E.copy(o).multiplyScalar(-h).add(t);
111
104
  return s.set(u.x / r, u.y / r, u.z / e).normalize();
112
105
  }
113
- }
114
- class k extends j {
115
- type = "EllipsoidGeometry";
116
- parameters;
106
+ };
107
+ b.WGS84 = /* @__PURE__ */ new b(
108
+ 6378137,
109
+ 6378137,
110
+ 6356752314245179e-9
111
+ );
112
+ let N = b;
113
+ class Q extends W {
117
114
  constructor(t = new a(1, 1, 1), i = 32, s = 16) {
118
- super(), this.parameters = {
115
+ super(), this.type = "EllipsoidGeometry", this.parameters = {
119
116
  radii: t,
120
117
  longitudeSegments: i,
121
118
  latitudeSegments: s
122
119
  }, i = Math.max(3, Math.floor(i)), s = Math.max(2, Math.floor(s));
123
120
  const r = (i + 1) * (s + 1), e = new a(), n = new a(), o = new Float32Array(r * 3), h = new Float32Array(r * 3), u = new Float32Array(r * 2), d = [], m = [];
124
- for (let c = 0, l = 0, y = 0, w = 0; c <= s; ++c) {
125
- const z = [], p = c / s, f = p * Math.PI;
121
+ for (let c = 0, l = 0, p = 0, w = 0; c <= s; ++c) {
122
+ const f = [], y = c / s, I = y * Math.PI;
126
123
  let x = 0;
127
124
  c === 0 ? x = 0.5 / i : c === s && (x = -0.5 / i);
128
- for (let M = 0; M <= i; ++M, l += 3, y += 2, ++w) {
129
- const g = M / i, I = g * Math.PI * 2;
130
- e.x = t.x * Math.cos(I) * Math.sin(f), e.y = t.y * Math.sin(I) * Math.sin(f), e.z = t.z * Math.cos(f), o[l] = e.x, o[l + 1] = e.y, o[l + 2] = e.z, n.copy(e).normalize(), h[l] = n.x, h[l + 1] = n.y, h[l + 2] = n.z, u[y] = g + x, u[y + 1] = 1 - p, z.push(w);
125
+ for (let M = 0; M <= i; ++M, l += 3, p += 2, ++w) {
126
+ const g = M / i, v = g * Math.PI * 2;
127
+ e.x = t.x * Math.cos(v) * Math.sin(I), e.y = t.y * Math.sin(v) * Math.sin(I), e.z = t.z * Math.cos(I), o[l] = e.x, o[l + 1] = e.y, o[l + 2] = e.z, n.copy(e).normalize(), h[l] = n.x, h[l + 1] = n.y, h[l + 2] = n.z, u[p] = g + x, u[p + 1] = 1 - y, f.push(w);
131
128
  }
132
- d.push(z);
129
+ d.push(f);
133
130
  }
134
131
  for (let c = 0; c < s; ++c)
135
132
  for (let l = 0; l < i; ++l) {
136
- const y = d[c][l + 1], w = d[c][l], z = d[c + 1][l], p = d[c + 1][l + 1];
137
- c !== 0 && m.push(y, w, p), c !== s - 1 && m.push(w, z, p);
133
+ const p = d[c][l + 1], w = d[c][l], f = d[c + 1][l], y = d[c + 1][l + 1];
134
+ c !== 0 && m.push(p, w, y), c !== s - 1 && m.push(w, f, y);
138
135
  }
139
- this.setIndex(m), this.setAttribute("position", new N(o, 3)), this.setAttribute("normal", new N(h, 3)), this.setAttribute("uv", new N(u, 2));
136
+ this.setIndex(m), this.setAttribute("position", new S(o, 3)), this.setAttribute("normal", new S(h, 3)), this.setAttribute("uv", new S(u, 2));
140
137
  }
141
138
  copy(t) {
142
139
  return super.copy(t), this.parameters = { ...t.parameters }, this;
143
140
  }
144
141
  }
145
- const q = /* @__PURE__ */ new a(), T = /* @__PURE__ */ new a();
146
- class R {
142
+ const A = /* @__PURE__ */ new a(), P = /* @__PURE__ */ new a(), z = class z {
147
143
  constructor(t = 0, i = 0, s = 0) {
148
144
  this.longitude = t, this.latitude = i, this.height = s;
149
145
  }
150
- static MIN_LONGITUDE = -Math.PI;
151
- static MAX_LONGITUDE = Math.PI;
152
- static MIN_LATITUDE = -Math.PI / 2;
153
- static MAX_LATITUDE = Math.PI / 2;
154
146
  set(t, i, s) {
155
147
  return this.longitude = t, this.latitude = i, s != null && (this.height = s), this;
156
148
  }
157
149
  clone() {
158
- return new R(this.longitude, this.latitude, this.height);
150
+ return new z(this.longitude, this.latitude, this.height);
159
151
  }
160
152
  copy(t) {
161
153
  return this.longitude = t.longitude, this.latitude = t.latitude, this.height = t.height, this;
@@ -173,33 +165,33 @@ class R {
173
165
  return this.height = t, this;
174
166
  }
175
167
  normalize() {
176
- return this.longitude < R.MIN_LONGITUDE && (this.longitude += Math.PI * 2), this;
168
+ return this.longitude < z.MIN_LONGITUDE && (this.longitude += Math.PI * 2), this;
177
169
  }
178
170
  // See: https://en.wikipedia.org/wiki/Geographic_coordinate_conversion
179
171
  // Reference: https://github.com/CesiumGS/cesium/blob/1.122/packages/engine/Source/Core/Geodetic.js#L119
180
172
  setFromECEF(t, i) {
181
- const r = (i?.ellipsoid ?? A.WGS84).reciprocalRadiiSquared(q), e = O(
173
+ const r = (i?.ellipsoid ?? N.WGS84).reciprocalRadiiSquared(A), e = D(
182
174
  t,
183
175
  r,
184
- T,
176
+ P,
185
177
  i
186
178
  );
187
179
  if (e == null)
188
180
  throw new Error(
189
181
  `Could not project position to ellipsoid surface: ${t.toArray()}`
190
182
  );
191
- const n = q.multiplyVectors(e, r).normalize();
183
+ const n = A.multiplyVectors(e, r).normalize();
192
184
  this.longitude = Math.atan2(n.y, n.x), this.latitude = Math.asin(n.z);
193
- const o = q.subVectors(t, e);
185
+ const o = A.subVectors(t, e);
194
186
  return this.height = Math.sign(o.dot(t)) * o.length(), this;
195
187
  }
196
188
  // See: https://en.wikipedia.org/wiki/Geographic_coordinate_conversion
197
189
  // Reference: https://github.com/CesiumGS/cesium/blob/1.122/packages/engine/Source/Core/Cartesian3.js#L916
198
190
  toECEF(t = new a(), i) {
199
- const s = i?.ellipsoid ?? A.WGS84, r = q.multiplyVectors(
191
+ const s = i?.ellipsoid ?? N.WGS84, r = A.multiplyVectors(
200
192
  s.radii,
201
193
  s.radii
202
- ), e = Math.cos(this.latitude), n = T.set(
194
+ ), e = Math.cos(this.latitude), n = P.set(
203
195
  e * Math.cos(this.longitude),
204
196
  e * Math.sin(this.longitude),
205
197
  Math.sin(this.latitude)
@@ -215,10 +207,12 @@ class R {
215
207
  *[Symbol.iterator]() {
216
208
  yield this.longitude, yield this.latitude, yield this.height;
217
209
  }
218
- }
210
+ };
211
+ z.MIN_LONGITUDE = -Math.PI, z.MAX_LONGITUDE = Math.PI, z.MIN_LATITUDE = -Math.PI / 2, z.MAX_LATITUDE = Math.PI / 2;
212
+ let C = z;
219
213
  export {
220
- A as E,
221
- R as G,
222
- k as a
214
+ N as E,
215
+ C as G,
216
+ Q as a
223
217
  };
224
218
  //# sourceMappingURL=shared2.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared2.js","sources":["../src/helpers/projectOnEllipsoidSurface.ts","../src/Ellipsoid.ts","../src/EllipsoidGeometry.ts","../src/Geodetic.ts"],"sourcesContent":null,"names":["vectorScratch","Vector3","projectOnEllipsoidSurface","position","reciprocalRadiiSquared","result","options","x","y","z","rx","ry","rz","x2","y2","z2","normSquared","ratio","intersection","gradient","lambda","correction","sx","sy","sz","error","sx2","sy2","sz2","sx3","sy3","sz3","vectorScratch1","vectorScratch2","vectorScratch3","Ellipsoid","a2","b2","east","north","up","Matrix4","ray","reciprocalRadii","p","d","p2","d2","pd","discriminant","Q","t1","t2","t","surfacePosition","radius","invariant","normal","direction","v","q","EllipsoidGeometry","BufferGeometry","radii","longitudeSegments","latitudeSegments","elementCount","vertex","vertices","normals","uvs","grid","indices","vertexIndex","uvIndex","rowIndex","rowIndices","phi","uOffset","u","theta","a","b","c","BufferAttribute","source","Geodetic","longitude","latitude","height","other","value","projection","ell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GAENE,IAAc,KAAK,IAAI,KAAK,QAAQ,GACpCtC,IAASxB,EACZ;AAAA,MACC8D,IAAc,KAAK,IAAI,KAAK,SAAS;AAAA,MACrCA,IAAc,KAAK,IAAI,KAAK,SAAS;AAAA,MACrC,KAAK,IAAI,KAAK,QAAQ;AAAA,IAAA,EAEvB,UAAA;AACH,WAAA1F,EAAO,gBAAgByF,GAAcrC,CAAM,GACpCpD,EACJ,aAAa,KAAK,KAAKoD,EAAO,IAAIpD,CAAM,CAAC,CAAC,EAC1C,IAAIoD,EAAO,eAAe,KAAK,MAAM,CAAC;AAAA,EAC3C;AAAA,EAEA,UAAUuC,GAA0BC,IAAS,GAAS;AACpD,gBAAK,YAAYD,EAAMC,CAAM,GAC7B,KAAK,WAAWD,EAAMC,IAAS,CAAC,GAChC,KAAK,SAASD,EAAMC,IAAS,CAAC,GACvB;AAAA,EACT;AAAA,EAEA,QAAQD,IAAkB,IAAIC,IAAS,GAAa;AAClD,WAAAD,EAAMC,CAAM,IAAI,KAAK,WACrBD,EAAMC,IAAS,CAAC,IAAI,KAAK,UACzBD,EAAMC,IAAS,CAAC,IAAI,KAAK,QAClBD;AAAA,EACT;AAAA,EAEA,EAAE,OAAO,QAAQ,IAAuB;AACtC,UAAM,KAAK,WACX,MAAM,KAAK,UACX,MAAM,KAAK;AAAA,EACb;AACF;"}
1
+ {"version":3,"file":"shared2.js","sources":["../src/helpers/projectOnEllipsoidSurface.ts","../src/Ellipsoid.ts","../src/EllipsoidGeometry.ts","../src/Geodetic.ts"],"names":["vectorScratch","Vector3","projectOnEllipsoidSurface","position","reciprocalRadiiSquared","result","options","x","y","z","rx","ry","rz","x2","y2","z2","normSquared","ratio","intersection","gradient","lambda","correction","sx","sy","sz","error","sx2","sy2","sz2","sx3","sy3","sz3","vectorScratch1","vectorScratch2","vectorScratch3","_Ellipsoid","a2","b2","east","north","up","Matrix4","ray","reciprocalRadii","p","d","p2","d2","pd","discriminant","Q","t1","t2","t","surfacePosition","radius","invariant","normal","direction","v","q","Ellipsoid","EllipsoidGeometry","BufferGeometry","radii","longitudeSegments","latitudeSegments","elementCount","vertex","vertices","normals","uvs","grid","indices","vertexIndex","uvIndex","rowIndex","rowIndices","phi","uOffset","u","theta","a","b","c","BufferAttribute","source","_Geodetic","longitude","latitude","height","other","value","projection","ellipsoid","radiiSquared","cosLatitude","array","offset","Geodetic"],"mappings":";;AAEA,MAAMA,wBAAkCC,EAAA;AASjC,SAASC,EACdC,GACAC,GACAC,IAAS,IAAIJ,EAAA,GACbK,GACqB;AACrB,QAAM,EAAE,GAAAC,GAAG,GAAAC,GAAG,GAAAC,EAAA,IAAMN,GACdO,IAAKN,EAAuB,GAC5BO,IAAKP,EAAuB,GAC5BQ,IAAKR,EAAuB,GAC5BS,IAAKN,IAAIA,IAAIG,GACbI,IAAKN,IAAIA,IAAIG,GACbI,IAAKN,IAAIA,IAAIG,GAGbI,IAAcH,IAAKC,IAAKC,GACxBE,IAAQ,KAAK,KAAK,IAAID,CAAW;AAGvC,MAAI,CAAC,OAAO,SAASC,CAAK;AACxB;AAKF,QAAMC,IAAelB,EAAc,KAAKG,CAAQ,EAAE,eAAec,CAAK;AACtE,MAAID,KAAeV,GAAS,mBAAmB;AAC7C,WAAOD,EAAO,KAAKa,CAAY;AAKjC,QAAMC,IAAWD,EACd,SAASd,CAAsB,EAC/B,eAAe,CAAC;AAGnB,MAAIgB,KAAW,IAAIH,KAASd,EAAS,YAAagB,EAAS,WAAW,IAElEE,IAAa,GACbC,GACAC,GACAC,GACAC;AACJ,KAAG;AACD,IAAAL,KAAUC,GACVC,IAAK,KAAK,IAAIF,IAASV,IACvBa,IAAK,KAAK,IAAIH,IAAST,IACvBa,IAAK,KAAK,IAAIJ,IAASR;AACvB,UAAMc,IAAMJ,IAAKA,GACXK,IAAMJ,IAAKA,GACXK,IAAMJ,IAAKA,GACXK,IAAMH,IAAMJ,GACZQ,IAAMH,IAAMJ,GACZQ,IAAMH,IAAMJ;AAClB,IAAAC,IAAQZ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EAAe;AAAA,MAClC8D,EAAU;AAAA,MACVA,EAAU;AAAA,IAAA,GAENE,IAAc,KAAK,IAAI,KAAK,QAAQ,GACpCvC,IAASxB,EACZ;AAAA,MACC+D,IAAc,KAAK,IAAI,KAAK,SAAS;AAAA,MACrCA,IAAc,KAAK,IAAI,KAAK,SAAS;AAAA,MACrC,KAAK,IAAI,KAAK,QAAQ;AAAA,IAAA,EAEvB,UAAA;AACH,WAAA3F,EAAO,gBAAgB0F,GAActC,CAAM,GACpCpD,EACJ,aAAa,KAAK,KAAKoD,EAAO,IAAIpD,CAAM,CAAC,CAAC,EAC1C,IAAIoD,EAAO,eAAe,KAAK,MAAM,CAAC;AAAA,EAC3C;AAAA,EAEA,UAAUwC,GAA0BC,IAAS,GAAS;AACpD,gBAAK,YAAYD,EAAMC,CAAM,GAC7B,KAAK,WAAWD,EAAMC,IAAS,CAAC,GAChC,KAAK,SAASD,EAAMC,IAAS,CAAC,GACvB;AAAA,EACT;AAAA,EAEA,QAAQD,IAAkB,IAAIC,IAAS,GAAa;AAClD,WAAAD,EAAMC,CAAM,IAAI,KAAK,WACrBD,EAAMC,IAAS,CAAC,IAAI,KAAK,UACzBD,EAAMC,IAAS,CAAC,IAAI,KAAK,QAClBD;AAAA,EACT;AAAA,EAEA,EAAE,OAAO,QAAQ,IAAuB;AACtC,UAAM,KAAK,WACX,MAAM,KAAK,UACX,MAAM,KAAK;AAAA,EACb;AACF;AA3IEV,EAAgB,gBAAgB,CAAC,KAAK,IACtCA,EAAgB,gBAAgB,KAAK,IACrCA,EAAgB,eAAe,CAAC,KAAK,KAAK,GAC1CA,EAAgB,eAAe,KAAK,KAAK;AAJpC,IAAMY,IAANZ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"shared3.cjs","sources":["../src/QuadGeometry.ts"],"sourcesContent":null,"names":["QuadGeometry","BufferGeometry","Sphere","Vector3","Float32BufferAttribute"],"mappings":"sCAEO,MAAMA,UAAqBC,EAAAA,cAAe,CAC/C,aAAc,CACZ,MAAA,EACA,KAAK,eAAiB,IAAIC,SAC1B,KAAK,eAAe,IAAI,IAAIC,EAAAA,QAAW,GAAQ,EAC/C,KAAK,aACH,WACA,IAAIC,yBAAuB,CAAC,GAAI,EAAG,EAAG,GAAI,GAAI,EAAG,EAAG,GAAI,CAAC,EAAG,CAAC,CAAA,EAE/D,KAAK,aAAa,KAAM,IAAIA,EAAAA,uBAAuB,CAAC,EAAG,GAAI,EAAG,EAAG,EAAG,CAAC,EAAG,CAAC,CAAC,CAC5E,CACF"}
1
+ {"version":3,"file":"shared3.cjs","sources":["../src/QuadGeometry.ts"],"names":["QuadGeometry","BufferGeometry","Sphere","Vector3","Float32BufferAttribute"],"mappings":"sCAEO,MAAMA,UAAqBC,EAAAA,cAAe,CAC/C,aAAc,CACZ,MAAA,EACA,KAAK,eAAiB,IAAIC,SAC1B,KAAK,eAAe,IAAI,IAAIC,EAAAA,QAAW,GAAQ,EAC/C,KAAK,aACH,WACA,IAAIC,yBAAuB,CAAC,GAAI,EAAG,EAAG,GAAI,GAAI,EAAG,EAAG,GAAI,CAAC,EAAG,CAAC,CAAA,EAE/D,KAAK,aAAa,KAAM,IAAIA,EAAAA,uBAAuB,CAAC,EAAG,GAAI,EAAG,EAAG,EAAG,CAAC,EAAG,CAAC,CAAC,CAC5E,CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"shared3.js","sources":["../src/QuadGeometry.ts"],"sourcesContent":null,"names":["QuadGeometry","BufferGeometry","Sphere","Vector3","Float32BufferAttribute"],"mappings":";AAEO,MAAMA,UAAqBC,EAAe;AAAA,EAC/C,cAAc;AACZ,UAAA,GACA,KAAK,iBAAiB,IAAIC,EAAA,GAC1B,KAAK,eAAe,IAAI,IAAIC,EAAA,GAAW,KAAQ,GAC/C,KAAK;AAAA,MACH;AAAA,MACA,IAAIC,EAAuB,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AAAA,IAAA,GAE/D,KAAK,aAAa,MAAM,IAAIA,EAAuB,CAAC,GAAG,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;AAAA,EAC5E;AACF;"}
1
+ {"version":3,"file":"shared3.js","sources":["../src/QuadGeometry.ts"],"names":["QuadGeometry","BufferGeometry","Sphere","Vector3","Float32BufferAttribute"],"mappings":";AAEO,MAAMA,UAAqBC,EAAe;AAAA,EAC/C,cAAc;AACZ,UAAA,GACA,KAAK,iBAAiB,IAAIC,EAAA,GAC1B,KAAK,eAAe,IAAI,IAAIC,EAAA,GAAW,KAAQ,GAC/C,KAAK;AAAA,MACH;AAAA,MACA,IAAIC,EAAuB,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AAAA,IAAA,GAE/D,KAAK,aAAa,MAAM,IAAIA,EAAuB,CAAC,GAAG,IAAI,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;AAAA,EAC5E;AACF;"}
package/build/webgpu.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("three"),e=require("three/tsl"),v=require("three/webgpu"),U=require("./shared3.cjs"),y=require("./shared.cjs"),te=require("three/src/nodes/core/NodeUtils.js");let C;function z(r,t,s){C??=new WeakMap;let o=C.get(r);return o==null&&(o={},C.set(r,o)),o[t]??=s()}const xe=r=>z(r,"projectionMatrix",()=>e.reference("projectionMatrix","mat4",r).setName("projectionMatrix")),ge=r=>z(r,"viewMatrix",()=>e.reference("matrixWorldInverse","mat4",r).setName("viewMatrix")),fe=r=>z(r,"inverseProjectionMatrix",()=>e.reference("projectionMatrixInverse","mat4",r).setName("inverseProjectionMatrix")),ye=r=>z(r,"inverseViewMatrix",()=>e.reference("matrixWorld","mat4",r).setName("inverseViewMatrix")),we=r=>z(r,"cameraPositionWorld",()=>e.uniform(new g.Vector3).setName("cameraPositionWorld").onRenderUpdate((t,{value:s})=>{s.setFromMatrixPosition(r.matrixWorld)})),A=r=>z(r,"cameraNear",()=>e.reference("near","float",r).setName("cameraNear")),D=r=>z(r,"cameraFar",()=>e.reference("far","float",r).setName("cameraFar"));async function O(r,t){return await r.debug.getShaderAsync(new g.Scene,new g.Camera,t).then(s=>s).catch(s=>(console.error(s),{fragmentShader:null,vertexShader:null}))}function Te(r,t){const s=new g.Mesh(new U.QuadGeometry,t);O(r,s).then(o=>{console.log(o.fragmentShader)}).finally(()=>{s.geometry.dispose()})}function Ne(r,t){const s=new g.Mesh(new U.QuadGeometry,t);O(r,s).then(o=>{console.log(o.vertexShader)}).finally(()=>{s.geometry.dispose()})}function Se(r,t){const s=new v.NodeMaterial;s.vertexNode=e.vec4(e.positionGeometry.xy,0,1),s.fragmentNode=t;const o=new g.Mesh(new U.QuadGeometry,s);O(r,o).then(n=>{console.log(n.fragmentShader)}).finally(()=>{s.dispose(),o.geometry.dispose()})}function be(r,t,s){const o=r[t];return r[t]=((...n)=>(s(...n),o.apply(r,n))),r}class se extends v.TextureNode{static get type(){return"OutputTextureNode"}owner;constructor(t,s){super(s),this.owner=t,this.setUpdateMatrix(!1)}setup(t){return this.owner.build(t),super.setup(t)}clone(){return new this.constructor(this.owner,this.value)}}const I=(...r)=>e.nodeObject(new se(...r));class P extends v.TempNode{static get type(){return"FilterNode"}inputNode;resolutionScale=1;textureNode;renderTargets=[];constructor(t){super("vec4"),this.inputNode=t,this.updateBeforeType=v.NodeUpdateType.FRAME}createRenderTarget(t){const s=new g.RenderTarget(1,1,{depthBuffer:!1,type:g.HalfFloatType,format:g.RGBAFormat}),o=s.texture;o.minFilter=g.LinearFilter,o.magFilter=g.LinearFilter,o.generateMipmaps=!1;const n=this.constructor.type;return o.name=t!=null?`${n}.${t}`:n,this.renderTargets.push(s),s}getTextureNode(){return y.invariant(this.textureNode!=null,"outputTexture must be specified before getTextureNode() is called."),this.textureNode}get outputTexture(){return this.textureNode?.value??null}set outputTexture(t){this.textureNode=t!=null?I(this,t):void 0}setup(t){const{inputNode:s,textureNode:o}=this;return y.invariant(s!=null,"inputNode must be specified before being setup."),y.invariant(o!=null,"outputTexture must be specified before being setup."),o.uvNode=s.uvNode,o}dispose(){for(const t of this.renderTargets)t.dispose();super.dispose()}}const{resetRendererState:Me,restoreRendererState:Re}=v.RendererUtils;class G extends P{downsampleRTs=[];upsampleRTs=[];downsampleMaterial=new v.NodeMaterial;upsampleMaterial=new v.NodeMaterial;mesh=new v.QuadMesh;rendererState;inputTexelSize=e.uniform(new g.Vector2);downsampleNode=e.texture(null);constructor(t,s){super(t);for(let o=0;o<s;++o)this.downsampleRTs[o]=this.createRenderTarget(`Downsample${o}`),o<s-1&&(this.upsampleRTs[o]=this.createRenderTarget(`Upsample${o}`));this.outputTexture=this.upsampleRTs[0].texture}setSize(t,s){const{resolutionScale:o}=this;let n=Math.max(Math.round(t*o),1),i=Math.max(Math.round(s*o),1);const{downsampleRTs:a,upsampleRTs:c}=this;for(let u=0;u<a.length;++u)n=Math.max(Math.round(n/2),1),i=Math.max(Math.round(i/2),1),a[u].setSize(n,i),u<c.length&&c[u].setSize(n,i);return this}updateBefore({renderer:t}){if(t==null)return;const{downsampleRTs:s,upsampleRTs:o,mesh:n,inputNode:i,inputTexelSize:a,downsampleNode:c}=this;y.invariant(i!=null);const{width:u,height:p}=i.value;this.setSize(u,p);const l=i.value;this.rendererState=Me(t,this.rendererState),n.material=this.downsampleMaterial;for(const d of s){const{width:h,height:m}=i.value;a.value.set(1/h,1/m),t.setRenderTarget(d),n.render(t),i.value=d.texture}n.material=this.upsampleMaterial;for(let d=o.length-1;d>=0;--d){const h=o[d],{width:m,height:x}=i.value;a.value.set(1/m,1/x),c.value=s[d].texture,t.setRenderTarget(h),n.render(t),i.value=h.texture}Re(t,this.rendererState),i.value=l}setup(t){const{inputNode:s}=this;y.invariant(s!=null);const{downsampleMaterial:o,upsampleMaterial:n}=this;return o.fragmentNode=this.setupDownsampleNode(t),n.fragmentNode=this.setupUpsampleNode(t),o.needsUpdate=!0,n.needsUpdate=!0,super.setup(t)}dispose(){for(const t of this.downsampleRTs)t.dispose();for(const t of this.upsampleRTs)t.dispose();this.downsampleMaterial.dispose(),this.upsampleMaterial.dispose(),this.mesh.geometry.dispose(),super.dispose()}}const L=(r,t)=>{const s=e.uv(),o=e.vec4(1,1,-1,-1).mul(t.xyxy).add(s.xyxy),n=e.vec4(2,2,-2,-2).mul(t.xyxy).add(s.xyxy),i=o.zy.toVertexStage(),a=o.xy.toVertexStage(),c=o.zw.toVertexStage(),u=o.xw.toVertexStage(),p=e.vec2(s.x,n.y).toVertexStage(),l=e.vec2(n.z,s.y).toVertexStage(),d=e.vec2(n.x,s.y).toVertexStage(),h=e.vec2(s.x,n.w).toVertexStage(),m=n.zy.toVertexStage(),x=n.xy.toVertexStage(),f=n.zw.toVertexStage(),w=n.xw.toVertexStage();return e.add(e.add(r.sample(s),r.sample(i),r.sample(a),r.sample(c),r.sample(u)).mul(1/8),e.add(r.sample(p),r.sample(l),r.sample(d),r.sample(h)).mul(1/16),e.add(r.sample(m),r.sample(x),r.sample(f),r.sample(w)).mul(1/32))},oe=(r,t)=>{const s=e.uv(),o=e.vec4(1,1,-1,-1).mul(t.xyxy).add(s.xyxy),n=e.vec2(s.x,o.y).toVertexStage(),i=e.vec2(o.z,s.y).toVertexStage(),a=e.vec2(o.x,s.y).toVertexStage(),c=e.vec2(s.x,o.w).toVertexStage(),u=o.zy.toVertexStage(),p=o.xy.toVertexStage(),l=o.zw.toVertexStage(),d=o.xw.toVertexStage();return e.add(r.sample(s).mul(.25),e.add(r.sample(n),r.sample(i),r.sample(a),r.sample(c)).mul(.125),e.add(r.sample(u),r.sample(p),r.sample(l),r.sample(d)).mul(.0625))};class re extends G{static get type(){return"MipmapBlurNode"}constructor(t,s=4){super(t,s),this.resolutionScale=.5}setupDownsampleNode(t){return y.invariant(this.inputNode!=null),L(this.inputNode,this.inputTexelSize)}setupUpsampleNode(t){return y.invariant(this.inputNode!=null),oe(this.inputNode,this.inputTexelSize)}}const Ve=(...r)=>e.nodeObject(new re(...r)),{resetRendererState:ze,restoreRendererState:Be}=v.RendererUtils;class Fe extends P{renderTarget;material=new v.NodeMaterial;mesh=new v.QuadMesh(this.material);rendererState;inputTexelSize=e.uniform(new g.Vector2);constructor(t){super(t),this.renderTarget=this.createRenderTarget(),this.outputTexture=this.renderTarget.texture}setSize(t,s){const{resolutionScale:o}=this,n=Math.max(Math.round(t*o),1),i=Math.max(Math.round(s*o),1);return this.renderTarget.setSize(n,i),this}updateBefore({renderer:t}){if(t==null)return;const{inputNode:s}=this;y.invariant(s!=null);const{width:o,height:n}=s.value;this.setSize(o,n),this.inputTexelSize.value.set(1/o,1/n),this.rendererState=ze(t,this.rendererState),t.setRenderTarget(this.renderTarget),this.mesh.render(t),Be(t,this.rendererState)}setup(t){const{inputNode:s}=this;y.invariant(s!=null);const{material:o}=this;return o.fragmentNode=this.setupOutputNode(t),o.needsUpdate=!0,super.setup(t)}dispose(){this.renderTarget.dispose(),this.material.dispose(),this.mesh.geometry.dispose(),super.dispose()}}class k extends Fe{static get type(){return"DownsampleThresholdNode"}thresholdLevel=e.uniform(5);thresholdRange=e.uniform(1);constructor(t){super(t),this.resolutionScale=.5}setupOutputNode(){const{inputNode:t,thresholdLevel:s,thresholdRange:o,inputTexelSize:n}=this;y.invariant(t!=null);const i=L(t,n),a=e.luminance(i.rgb),c=e.smoothstep(s,s.add(o),a);return e.vec4(i.rgb,a).mul(c)}}const Pe=(...r)=>e.nodeObject(new k(...r));function Q(r){if(typeof r=="string")return r;if(r.layout.name==null)throw new Error("Struct name is required.");return r.layout.name}function F({typeOnly:r=!1,...t}){return r?s=>e.Fn(s):s=>e.Fn(s).setLayout({...t,type:Q(t.type),inputs:t.inputs?.map(o=>({...o,type:Q(o.type)}))??[]})}function V(r){return e.Fn((t,s)=>{const o=r(...t);return typeof o=="function"?o(s):o})}const{resetRendererState:Ce,restoreRendererState:Ae}=v.RendererUtils;class De extends P{iterations=1;horizontalRT;verticalRT;material=new v.NodeMaterial;mesh=new v.QuadMesh(this.material);rendererState;inputTexelSize=e.uniform(new g.Vector2);direction=e.uniform(new g.Vector2);constructor(t){super(t),this.horizontalRT=this.createRenderTarget("Horizontal"),this.verticalRT=this.createRenderTarget("Vertical"),this.outputTexture=this.verticalRT.texture}setSize(t,s){const{resolutionScale:o}=this,n=Math.max(Math.round(t*o),1),i=Math.max(Math.round(s*o),1);return this.horizontalRT.setSize(n,i),this.verticalRT.setSize(n,i),this}updateBefore({renderer:t}){if(t==null)return;const{horizontalRT:s,verticalRT:o,mesh:n,inputNode:i,direction:a}=this;y.invariant(i!=null);const{width:c,height:u}=i.value;this.setSize(c,u),this.inputTexelSize.value.set(1/c,1/u);const p=i.value;this.rendererState=Ce(t,this.rendererState);for(let l=0;l<this.iterations;++l)a.value.set(1,0),t.setRenderTarget(s),n.render(t),i.value=s.texture,a.value.set(0,1),t.setRenderTarget(o),n.render(t),i.value=o.texture;Ae(t,this.rendererState),i.value=p}setup(t){const{inputNode:s}=this;y.invariant(s!=null);const{material:o}=this;return o.fragmentNode=this.setupOutputNode(t),o.needsUpdate=!0,super.setup(t)}dispose(){this.horizontalRT.dispose(),this.verticalRT.dispose(),this.material.dispose(),this.mesh.geometry.dispose(),super.dispose()}}function Z(r){if(y.invariant(r>=0),r===0)return new Float64Array(0);if(r===1)return new Float64Array([1]);let t=new Float64Array(r),s=new Float64Array(r),o=s;for(let n=1;n<=r;++n){for(let i=0;i<n;++i)s[i]=i===0||i===n-1?1:t[i-1]+t[i];o=s,s=t,t=o}return o}function je(r,t=2){y.invariant(r>=3);const s=r+t*2,o=t>0?Z(s).slice(t,-t):Z(s),n=Math.floor((o.length-1)/2),i=o.reduce((d,h)=>d+h,0),a=o.slice(n),c=[...Array(n+1).keys()],u=new Float64Array(Math.floor(c.length/2)),p=new Float64Array(u.length);u[0]=a[0]/i;for(let d=1,h=1;d<c.length-1;d+=2,++h){const m=c[d],x=c[d+1],f=a[d],w=a[d+1],T=f+w,S=(m*f+x*w)/T;u[h]=T/i,p[h]=S}const l=(u.reduce((d,h)=>d+h,0)-u[0]*.5)*2;if(l!==0){const d=1/l;for(let h=0;h<u.length;++h)u[h]*=d}return{offsets:p,weights:u}}class q extends De{static get type(){return"GaussianBlurNode"}kernelSize;constructor(t,s=35){super(t),this.kernelSize=s}setupOutputNode(t){const{inputNode:s,inputTexelSize:o,direction:n}=this;y.invariant(s!=null);const{offsets:i,weights:a}=je(this.kernelSize);return e.Fn(()=>{const c=e.uv(),u=n.mul(o).toVertexStage(),p=s.sample(c).mul(a[0]);for(let l=1;l<i.length;++l){const d=u.mul(i[l]);p.addAssign(e.add(s.sample(c.add(d)),s.sample(c.sub(d))).mul(a[l]))}return p})()}}const Ue=(...r)=>e.nodeObject(new q(...r)),ne=r=>r.dot(e.vec2(.06711056,.00583715)).fract().mul(52.9829189).fract(),Oe=e.Fn(()=>{const r=e.vec2(e.screenCoordinate.xy).add(e.time.fract().mul(1337)),t=ne(r);return e.vec3(t,t.oneMinus(),t).sub(.5).div(255)}).once()(),Ie=(r,t,s=e.vec2(90,45))=>{const o=e.equirectUV(r),n=e.fwidth(o),i=t.mul(n).mul(.5),a=e.abs(o.mul(s).fract().sub(.5)).div(s),c=e.smoothstep(i,i.add(n),a).oneMinus();return c.x.add(c.y).clamp(0,1)};class ie extends v.TempNode{static get type(){return"HighpVelocityNode"}projectionMatrix;currentProjectionMatrix=e.uniform(new g.Matrix4);previousProjectionMatrix=e.uniform("mat4");currentModelViewMatrix=e.uniform(new g.Matrix4);previousModelViewMatrix=e.uniform("mat4");objectModelViewMatrices=new WeakMap;constructor(){super("vec3"),this.updateType=v.NodeUpdateType.FRAME,this.updateBeforeType=v.NodeUpdateType.OBJECT,this.updateAfterType=v.NodeUpdateType.OBJECT}update({camera:t}){if(t==null)return;const{currentProjectionMatrix:s,previousProjectionMatrix:o}=this,n=this.projectionMatrix??t.projectionMatrix;o.value==null?o.value=new g.Matrix4().copy(n):o.value.copy(s.value),s.value.copy(n)}updateBefore({object:t,camera:s}){if(t==null||s==null)return;const{currentModelViewMatrix:o,previousModelViewMatrix:n,objectModelViewMatrices:i}=this;o.value.multiplyMatrices(s.matrixWorldInverse,t.matrixWorld),n.value=i.get(t)??o.value}updateAfter({object:t}){if(t==null)return;const{currentModelViewMatrix:s,objectModelViewMatrices:o}=this;let n=o.get(t);n==null&&(n=new g.Matrix4,o.set(t,n)),n.copy(s.value)}setup(t){const s=this.currentProjectionMatrix.mul(this.currentModelViewMatrix).mul(e.positionLocal).toVertexStage(),o=this.previousProjectionMatrix.mul(this.previousModelViewMatrix).mul(e.positionPrevious).toVertexStage(),n=s.xyz.div(s.w),i=o.xyz.div(o.w);return e.sub(n,i)}}const Ge=e.nodeImmutable(ie);class ae extends G{static get type(){return"KawaseBlurNode"}constructor(t,s=4){super(t,s),this.resolutionScale=.5}setupDownsampleNode(t){const{inputNode:s,inputTexelSize:o}=this;y.invariant(s!=null);const n=e.uv(),i=e.vec4(1,1,-1,-1).mul(o.xyxy.mul(.5)).add(n.xyxy),a=i.zy.toVertexStage(),c=i.xy.toVertexStage(),u=i.xw.toVertexStage(),p=i.zw.toVertexStage();return e.add(s.sample(n).mul(4),s.sample(a),s.sample(c),s.sample(u),s.sample(p)).mul(1/8)}setupUpsampleNode(t){const{inputNode:s,inputTexelSize:o}=this;y.invariant(s!=null);const n=e.uv(),i=e.vec4(1,1,-1,-1).mul(o.xyxy.mul(.5)).add(n.xyxy),a=i.zy.toVertexStage(),c=i.xy.toVertexStage(),u=i.xw.toVertexStage(),p=i.zw.toVertexStage(),l=e.vec2(i.z,n.y).toVertexStage(),d=e.vec2(i.x,n.y).toVertexStage(),h=e.vec2(n.x,i.y).toVertexStage(),m=e.vec2(n.x,i.w).toVertexStage();return e.add(e.add(s.sample(a),s.sample(c),s.sample(u),s.sample(p)).mul(1/12),e.add(s.sample(l),s.sample(d),s.sample(h),s.sample(m)).mul(1/6))}}const Le=(...r)=>e.nodeObject(new ae(...r));class ke extends v.TempNode{static get type(){return"LensGhostNode"}inputNode;intensity=e.uniform(1e-5);constructor(t){super("vec3"),this.inputNode=t}setup(t){const{inputNode:s,intensity:o}=this;y.invariant(s!=null);const n=F({name:"sampleGhost",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"direction",type:"vec2"},{name:"color",type:"vec3"},{name:"offset",type:"float"}]})(([u,p,l,d])=>{const h=p.mul(d).add(u.oneMinus()).saturate(),m=s.sample(h).rgb.mul(l),x=e.sub(.5,h).length().mul(1/(Math.SQRT2/4)).saturate();return m.mulAssign(x.oneMinus().pow(3)),m}),i=e.uv(),a=i.sub(.5);return e.add(n(i,a,e.vec3(.8,.8,1),-5),n(i,a,e.vec3(1,.8,.4),-1.5),n(i,a,e.vec3(.9,1,.8),-.4),n(i,a,e.vec3(1,.8,.4),-.2),n(i,a,e.vec3(.9,.7,.7),-.1),n(i,a,e.vec3(.5,1,.4),.7),n(i,a,e.vec3(.5,.5,.5),1),n(i,a,e.vec3(1,1,.6),2.5),n(i,a,e.vec3(.5,.8,1),10)).mul(o)}}const{resetRendererState:qe,restoreRendererState:We}=v.RendererUtils;function Ee(){const r=new v.RenderTarget(1,1,{depthBuffer:!1,type:v.HalfFloatType,format:v.RGBAFormat}),t=r.texture;return t.minFilter=v.LinearFilter,t.magFilter=v.LinearFilter,t.generateMipmaps=!1,r}const He=new v.Vector2;class W extends v.TextureNode{static get type(){return"RTTextureNode"}node;resolutionScale=1;renderTarget;material=new v.NodeMaterial;mesh=new v.QuadMesh(this.material);rendererState;constructor(t,s){const o=Ee();super(o.texture,s!=null?e.nodeObject(s):e.uv()),this.node=t,this.renderTarget=o,this.updateBeforeType=v.NodeUpdateType.FRAME}setSize(t,s){const{resolutionScale:o}=this,n=Math.max(Math.round(t*o),1),i=Math.max(Math.round(s*o),1);return this.renderTarget.setSize(n,i),this}updateBefore({renderer:t}){if(t==null)return;const s=t.getDrawingBufferSize(He);this.setSize(s.x,s.y),this.rendererState=qe(t,this.rendererState),t.setRenderTarget(this.renderTarget),this.mesh.render(t),We(t,this.rendererState)}setup(t){const{material:s}=this;return s.fragmentNode=e.nodeObject(this.node).context(t.getContext()),s.needsUpdate=!0,super.setup(t)}dispose(){this.renderTarget.dispose(),this.material.dispose(),this.mesh.geometry.dispose(),super.dispose()}clone(){const t=new v.TextureNode(this.value,this.uvNode,this.levelNode);return t.sampler=this.sampler,t.referenceNode=this,t}}const ue=(...r)=>e.nodeObject(new W(...r)),E=(r,t)=>{let s;return r.isTextureNode===!0||r.isSampleNode===!0?s=r:r.getTextureNode!=null?s=r.getTextureNode():(s=new W(r),t!=null&&(s.value.name=t)),e.nodeObject(s)},{resetRendererState:$e,restoreRendererState:Qe}=v.RendererUtils;function Ze(){const o=document.createElement("canvas");o.width=256,o.height=32;const n=o.getContext("2d");y.invariant(n!=null),n.beginPath(),n.moveTo(0,32/2),n.lineTo(256/2,5),n.lineTo(256,32/2),n.lineTo(256/2,27),n.closePath();const i=n.createLinearGradient(0,0,256,0);return i.addColorStop(0,"#000000"),i.addColorStop(.5,"#ffffff"),i.addColorStop(1,"#000000"),n.fillStyle=i,n.fill(),new g.CanvasTexture(o)}const K=e.struct({color:"vec3",luminance:"float",position:"vec2",scale:"float",sin:"float",cos:"float"});class Ke extends P{spikeNode;spikePairCount=6;wireframe=!1;intensity=e.uniform(1e-5);sizeScale=e.uniform(new g.Vector2(1.5,.01));luminanceThreshold=e.uniform(100);computeNode;counterBuffer=new v.StorageBufferAttribute(1,1);instanceBuffer=e.instancedArray(1,K);renderTarget=this.createRenderTarget();material=new v.MeshBasicNodeMaterial({depthTest:!1,depthWrite:!1,transparent:!0,blending:g.AdditiveBlending});mesh=new g.Mesh(new g.PlaneGeometry(1,1),this.material);camera=new g.PerspectiveCamera;rendererState;inputTexelSize=e.uniform(new g.Vector2);outputTexelSize=e.uniform(new g.Vector2);geometryRatio=e.uniform(new g.Vector2);constructor(t){super(t),this.inputNode=t,this.resolutionScale=.5,this.outputTexture=this.renderTarget.texture}customCacheKey(){return te.hash(this.spikePairCount,+this.wireframe)}setSize(t,s){const{resolutionScale:o}=this,n=Math.max(Math.round(t*o),1),i=Math.max(Math.round(s*o),1);this.renderTarget.setSize(n,i);const a=Math.floor(n/2),c=Math.floor(i/2),u=a*c;return this.instanceBuffer.bufferCount<u&&(this.instanceBuffer.dispose(),this.instanceBuffer=e.instancedArray(u,K),this.setupCompute(a,c),this.setupMaterial()),this}updateBefore({renderer:t}){if(t==null)return;const{inputNode:s}=this;y.invariant(s!=null);const{width:o,height:n}=s.value;this.setSize(o,n);const{computeNode:i,counterBuffer:a,renderTarget:c}=this;y.invariant(i!=null),this.inputTexelSize.value.set(1/o,1/n);const u=o/n;u>1?this.geometryRatio.value.set(1/u,1):this.geometryRatio.value.set(1,u);const{width:p,height:l}=c;this.outputTexelSize.value.set(1/p,1/l),a.array[0]=0,a.needsUpdate=!0,t.compute(i),t.getArrayBufferAsync(a).then(d=>{this.mesh.count=new Uint32Array(d)[0]}).catch(d=>{console.error(d)}),this.rendererState=$e(t,this.rendererState),t.setRenderTarget(c),t.render(this.mesh,this.camera),Qe(t,this.rendererState)}setupCompute(t,s){const{spikePairCount:o,inputNode:n,counterBuffer:i,instanceBuffer:a,outputTexelSize:c}=this;y.invariant(n!=null);const u=e.storage(i,"uint",i.count).toAtomic();this.computeNode=e.Fn(()=>{const p=e.uvec2(t,s);e.If(e.globalId.xy.greaterThanEqual(p).any(),()=>{e.Return()});const l=e.vec2(e.globalId.xy).mul(c).mul(2),d=n.sample(l),h=d.a;e.If(h.greaterThan(.1),()=>{const m=e.atomicAdd(u.element(0),o);for(let x=0;x<o;++x){const f=a.element(m.add(x));f.get("color").assign(d.rgb),f.get("luminance").assign(h),f.get("position").assign(e.globalId.xy),f.get("scale").assign(x%2===0?1:.5);const w=Math.PI*(3-Math.sqrt(5)),T=Math.PI/o*x+w;f.get("sin").assign(Math.sin(T)),f.get("cos").assign(Math.cos(T))}})})().compute([Math.ceil(t/8),Math.ceil(s/8),1],[8,8,1])}setupMaterial(){const{inputNode:t,spikeNode:s,instanceBuffer:o,luminanceThreshold:n,intensity:i,sizeScale:a,outputTexelSize:c,geometryRatio:u}=this;y.invariant(t!=null),y.invariant(s!=null);const p=o.element(e.instanceIndex);this.material.colorNode=this.wireframe?e.vec4(1):e.nodeObject(s).mul(p.get("color").mul(i)),this.material.vertexNode=e.Fn(()=>{const l=p.get("sin"),d=p.get("cos"),h=e.mat3(d,l,0,l.negate(),d,0,0,0,1),x=p.get("position").mul(c).mul(2),f=x.flipY().mul(2).sub(1),T=p.get("luminance").div(n).saturate(),S=e.vec2(T,1).mul(p.get("scale"),a,x.sub(.5).length().mul(2).oneMinus().mul(.5).add(.5)),R=h.mul(e.positionGeometry.mul(e.vec4(S,1,1))).mul(u).add(e.vec3(f,0));return e.vec4(R,1)})(),this.material.wireframe=this.wireframe,this.material.needsUpdate=!0}setup(t){if(this.spikeNode==null){const s=Ze();s.colorSpace=g.SRGBColorSpace,this.spikeNode=e.texture(s)}return this.setupMaterial(),super.setup(t)}dispose(){this.renderTarget.dispose(),this.material.dispose(),this.mesh.geometry.dispose(),super.dispose()}}const _e=new g.Vector2;class Je extends v.TempNode{static get type(){return"LensHaloNode"}inputNode;intensity=e.uniform(1e-5);chromaticAberration=e.uniform(.005);aspectRatio=e.uniform(0);constructor(t){super("vec3"),this.inputNode=t,this.updateBeforeType=v.NodeUpdateType.FRAME}updateBefore({renderer:t}){if(t==null)return;const{width:s,height:o}=t.getDrawingBufferSize(_e);this.aspectRatio.value=s/o}setup(t){const{inputNode:s,intensity:o,chromaticAberration:n,aspectRatio:i}=this;y.invariant(s!=null);const a=F({name:"cubicRingMask",type:"float",inputs:[{name:"x",type:"float"},{name:"radius",type:"float"},{name:"thickness",type:"float"}]})(([l,d,h])=>{const m=e.min(e.abs(l.sub(d)).div(h),1);return e.mul(m,m,e.sub(3,m.mul(2))).oneMinus()}),c=F({name:"sampleHalo",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"radius",type:"float"}]})(([l,d])=>{const h=e.vec2(i,1),m=l.sub(.5).mul(h).normalize().div(h),x=e.vec3(n).mul(e.vec3(-1,0,1)),f=e.fract(m.mul(d).add(l.oneMinus())),w=e.vec3(s.sample(m.mul(x.r).add(f)).r,s.sample(m.mul(x.g).add(f)).g,s.sample(m.mul(x.b).add(f)).b),T=l.sub(e.vec2(.5,0)).mul(h).add(e.vec2(.5,0)),S=e.distance(T,e.vec2(.5)).saturate();return w.mulAssign(a(S,.45,.25)),w}),u=e.uv();return c(u,.3).mul(o)}}const b=r=>r.greaterThanEqual(0).all().and(r.lessThanEqual(1).all()).toFloat();class H extends G{static get type(){return"MipmapSurfaceBlurNode"}blendAmount=e.uniform(.85);constructor(t,s=4){super(t,s),this.resolutionScale=.5}setupDownsampleNode(t){const{inputNode:s,inputTexelSize:o}=this;return y.invariant(s!=null),e.Fn(()=>{const n=e.uv(),i=e.vec4(1,1,-1,-1).mul(o.xyxy).add(n.xyxy),a=e.vec4(2,2,-2,-2).mul(o.xyxy).add(n.xyxy),c=i.zy.toVertexStage(),u=i.xy.toVertexStage(),p=i.zw.toVertexStage(),l=i.xw.toVertexStage(),d=a.zy.toVertexStage(),h=a.xy.toVertexStage(),m=a.zw.toVertexStage(),x=a.xw.toVertexStage(),f=e.vec2(n.x,a.y).toVertexStage(),w=e.vec2(a.z,n.y).toVertexStage(),T=e.vec2(a.x,n.y).toVertexStage(),S=e.vec2(n.x,a.w).toVertexStage(),R=1/4/2,M=1/9/2,B=s.sample(n).mul(M);let N;return N=e.vec4(b(c),b(u),b(p),b(l)).mul(R),B.addAssign(s.sample(c).mul(N.x),s.sample(u).mul(N.y),s.sample(p).mul(N.z),s.sample(l).mul(N.w)),N=e.vec4(b(d),b(h),b(m),b(x)).mul(M),B.addAssign(s.sample(d).mul(N.x),s.sample(h).mul(N.y),s.sample(m).mul(N.z),s.sample(x).mul(N.w)),N=e.vec4(b(f),b(w),b(T),b(S)).mul(M),B.addAssign(s.sample(f).mul(N.x),s.sample(w).mul(N.y),s.sample(T).mul(N.z),s.sample(S).mul(N.w)),B})()}setupUpsampleNode(t){const{inputNode:s,inputTexelSize:o,downsampleNode:n}=this;y.invariant(s!=null);const i=e.uv(),a=e.vec4(1,1,-1,-1).mul(o.xyxy).add(i.xyxy),c=e.vec2(i.x,a.y).toVertexStage(),u=e.vec2(a.z,i.y).toVertexStage(),p=e.vec2(a.x,i.y).toVertexStage(),l=e.vec2(i.x,a.w).toVertexStage(),d=a.zy.toVertexStage(),h=a.xy.toVertexStage(),m=a.zw.toVertexStage(),x=a.xw.toVertexStage(),f=e.add(s.sample(i).mul(1/4),e.add(s.sample(c),s.sample(u),s.sample(p),s.sample(l)).mul(1/8),e.add(s.sample(d),s.sample(h),s.sample(m),s.sample(x)).mul(1/16));return e.mix(n.sample(i),f,this.blendAmount)}}const Ye=(...r)=>e.nodeObject(new H(...r));function $(r){const t=r instanceof v.NodeBuilder?r.renderer:r;return("backend"in t?t.backend:r).isWebGPUBackend===!0}class ce extends v.TempNode{static get type(){return"LensFlareNode"}inputNode;thresholdNode;blurNode;ghostNode;haloNode;bloomNode;glareNode;bloomIntensity=e.uniform(.05);featuresNode;constructor(t){super("vec4"),this.inputNode=t,this.thresholdNode=new k,this.blurNode=new q,this.ghostNode=new ke,this.haloNode=new Je,this.bloomNode=new H(null,8),this.glareNode=new Ke,this.featuresNode=ue(e.add(this.ghostNode,this.haloNode)),this.featuresNode.value.name="LensFlareNode.Features",this.featuresNode.resolutionScale=.5,this.blurNode.resolutionScale=1,this.bloomNode.resolutionScale=1,this.glareNode.resolutionScale=1}setup(t){const{inputNode:s,thresholdNode:o,blurNode:n,ghostNode:i,haloNode:a,bloomNode:c,featuresNode:u,glareNode:p}=this;y.invariant(s!=null);const l=o.getTextureNode(),d=n.getTextureNode();o.inputNode=s,n.inputNode=l,i.inputNode=d,a.inputNode=d,c.inputNode=l,p.inputNode=l;const h=e.nodeObject(c.getTextureNode()).mul(this.bloomIntensity),m=p.getTextureNode();return e.Fn(()=>{const x=e.nodeObject(s);return x.addAssign(h),$(t)&&x.addAssign(m),x.add(u)})()}dispose(){this.thresholdNode.dispose(),this.blurNode.dispose(),this.ghostNode.dispose(),this.haloNode.dispose(),this.bloomNode.dispose(),this.glareNode.dispose(),this.featuresNode.dispose(),super.dispose()}}const Xe=r=>e.nodeObject(new ce(r!=null?E(r,"LensFlareNode.Input"):null)),et=V((r,t,s,o)=>{const n=r.sub(s),i=e.dot(t,n),a=e.dot(n,n).sub(o.pow2()),c=i.pow2().sub(a).toVar(),u=e.vec2(-1);return e.If(c.greaterThanEqual(0),()=>{const p=e.sqrt(c);u.assign(e.vec2(i.negate().sub(p),i.negate().add(p)))}),u}),le=e.struct({near:"vec4",far:"vec4"},"raySpheresIntersections"),tt=V((r,t,s,o)=>{const n=r.sub(s),i=e.dot(t,n),a=e.dot(n,n).sub(o.pow2()),c=i.pow2().sub(a).toVar(),u=e.vec4(-1),p=e.vec4(-1);return e.If(c.greaterThanEqual(0),()=>{const l=e.sqrt(c);u.assign(i.negate().sub(l)),p.assign(i.negate().add(l))}),le(u,p)}),st=V((r,t,s)=>{const o=r.div(s),n=t.div(s),i=n.dot(n),a=o.dot(n),c=o.dot(o),u=a.pow2().sub(i.mul(c.sub(1))).toVar(),p=e.vec2(-1);return e.If(u.greaterThanEqual(0),()=>{const l=e.sqrt(u);p.assign(e.vec2(a.negate().sub(l),a.negate().add(l)).div(i))}),p}),ot={float:e.float,int:e.int,uint:e.uint,bool:e.bool,vec2:e.vec2,ivec2:e.ivec2,uvec2:e.uvec2,bvec2:e.bvec2,vec3:e.vec3,ivec3:e.ivec3,uvec3:e.uvec3,bvec3:e.bvec3,vec4:e.vec4,ivec4:e.ivec4,uvec4:e.uvec4,bvec4:e.bvec4,mat2:e.mat2,mat3:e.mat3,mat4:e.mat4,color:e.color};function rt(r){return ot[r]}class de extends v.Texture3DNode{static get type(){return"OutputTexture3DNode"}owner;constructor(t,s){super(s),this.owner=t,this.setUpdateMatrix(!1)}setup(t){return this.owner.build(t),super.setup(t)}clone(){return new this.constructor(this.owner,this.value)}}const nt=(...r)=>e.nodeObject(new de(...r)),pe=V((r,t,s=.4)=>{const o=e.vec2(e.textureSize(r)),n=o.reciprocal(),i=o.mul(t),a=i.sub(.5).floor().add(.5),c=i.sub(a),u=c.mul(c),p=c.mul(u),l=e.nodeObject(s),d=l.mul(c),h=l.negate().mul(p).add(l.mul(2).mul(u).sub(d)),m=e.sub(2,l).mul(p).sub(e.sub(3,l).mul(u)).add(1),x=e.sub(2,l).negate().mul(p).add(e.sub(3,l.mul(2)).mul(u)).add(d),f=l.mul(p).sub(l.mul(u)),w=m.add(x),T=n.mul(a.add(x.div(w))),S=r.sample(T).rgb,R=n.mul(a.sub(1)),M=n.mul(a.add(2));return e.add(e.vec4(r.sample(e.vec2(T.x,R.y)).rgb,1).mul(w.x.mul(h.y)),e.vec4(r.sample(e.vec2(R.x,T.y)).rgb,1).mul(h.x.mul(w.y)),e.vec4(S,1).mul(w.x.mul(w.y)),e.vec4(r.sample(e.vec2(M.x,T.y)).rgb,1).mul(f.x.mul(w.y)),e.vec4(r.sample(e.vec2(T.x,M.y)).rgb,1).mul(w.x.mul(f.y)))}),it=V((r,t)=>{const s=e.vec2(e.textureSize(r)),o=s.reciprocal(),n=t.mul(s),i=n.sub(.5).floor().add(.5),a=n.sub(i),c=a.mul(a.mul(a.mul(.5).oneMinus()).sub(.5)),u=a.mul(a).mul(a.mul(1.5).sub(2.5)).add(1),p=a.mul(a.mul(e.sub(2,a.mul(1.5))).add(.5)),l=a.mul(a).mul(a.mul(.5).sub(.5)),d=u.add(p),h=p.div(u.add(p)),m=i.sub(1).mul(o),x=i.add(2).mul(o),f=i.add(h).mul(o);return e.add(r.sample(e.vec2(m.x,m.y)).mul(c.x).mul(c.y),r.sample(e.vec2(f.x,m.y)).mul(d.x).mul(c.y),r.sample(e.vec2(x.x,m.y)).mul(l.x).mul(c.y),r.sample(e.vec2(m.x,f.y)).mul(c.x).mul(d.y),r.sample(e.vec2(f.x,f.y)).mul(d.x).mul(d.y),r.sample(e.vec2(x.x,f.y)).mul(l.x).mul(d.y),r.sample(e.vec2(m.x,x.y)).mul(c.x).mul(l.y),r.sample(e.vec2(f.x,x.y)).mul(d.x).mul(l.y),r.sample(e.vec2(x.x,x.y)).mul(l.x).mul(l.y))});function _(r,t){let s=1,o=0;for(;r>0;)s/=t,o+=s*(r%t),r=Math.floor(r/t);return o}const J=Array.from({length:16},(r,t)=>new g.Vector2(_(t+1,2),_(t+1,3))),he=(r,t,s,{perspective:o=!0,logarithmic:n=!1}={})=>n?e.logarithmicDepthToViewZ(r,t,s):o?e.perspectiveDepthToViewZ(r,t,s):e.orthographicDepthToViewZ(r,t,s),j=(r,t,s)=>{const o=e.logarithmicDepthToViewZ(r,t,s);return e.viewZToPerspectiveDepth(o,t,s)},at=(r,t,s)=>{const o=e.nodeObject(e.perspectiveDepthToViewZ(r,t,s));return e.viewZToLogarithmicDepth(o,t,s)},ut=(r,t,s,o,n)=>{const i=o.element(e.int(2)).element(e.int(3)),a=o.element(e.int(3)).element(e.int(3)),u=e.vec4(e.vec3(r.flipY(),t).mul(2).sub(1),1).mul(s.mul(i).add(a));return n.mul(u).xyz},Y=[e.vec3(58.1375,2.7747,26.8183),e.vec3(-150.5666,4.2109,-88.5066),e.vec3(130.5887,-14.0195,109.0745),e.vec3(-42.3277,4.8052,-60.1097),e.vec3(4.5974,2.1856,12.5925),e.vec3(.1357,.0914,.1067)],me=r=>Y.slice(1).reduce((t,s)=>s.add(r.mul(t)),Y[0]),ct=(r,t,s,o)=>{const n=he(r,t,s,o);return me(e.viewZToLogarithmicDepth(n,t,s))},lt=r=>{const t=e.sub(.5,r.x).mul(e.PI2),s=e.sub(r.y,.5).mul(e.PI),o=e.cos(s);return e.vec3(o.mul(e.cos(t)),e.sin(s),o.mul(e.sin(t)))},{resetRendererState:dt,restoreRendererState:pt}=v.RendererUtils;function ht(r){return r.isPerspectiveCamera===!0||r.isOrthographicCamera===!0||"updateProjectionMatrix"in r&&"setViewOffset"in r&&"clearViewOffset"in r}const mt=F({name:"clipAABB",type:"vec4",inputs:[{name:"current",type:"vec4"},{name:"history",type:"vec4"},{name:"minColor",type:"vec4"},{name:"maxColor",type:"vec4"}]})(([r,t,s,o])=>{const n=o.rgb.add(s.rgb).mul(.5),i=o.rgb.sub(s.rgb).mul(.5).add(1e-7),a=t.sub(e.vec4(n,r.a)),u=a.xyz.div(i).abs(),p=e.max(u.x,u.y,u.z);return e.select(p.greaterThan(1),e.vec4(n,r.a).add(a.div(p)),t)}),X=[e.ivec2(-1,-1),e.ivec2(-1,1),e.ivec2(1,-1),e.ivec2(1,1),e.ivec2(1,0),e.ivec2(0,-1),e.ivec2(0,1),e.ivec2(-1,0)],vt=V((r,t,s,o,n)=>{const i=s.toVar(),a=s.pow2().toVar();for(const h of X){const m=r.load(t.add(h));i.addAssign(m),a.addAssign(m.pow2())}const c=e.float(X.length+1),u=i.div(c),p=e.sqrt(a.div(c).sub(u.pow2()).max(0)).mul(n),l=u.sub(p),d=u.add(p);return mt(u.clamp(l,d),o,l,d)}),xt=[e.ivec2(-1,-1),e.ivec2(-1,0),e.ivec2(-1,1),e.ivec2(0,-1),e.ivec2(0,0),e.ivec2(0,1),e.ivec2(1,-1),e.ivec2(1,0),e.ivec2(1,1)],gt=e.struct({coord:"ivec2",depth:"float"}),ft=V((r,t)=>{const s=e.float(1),o=e.ivec2(0);for(const n of xt){const i=t.add(n).toVar(),a=r.load(i).toVar();e.If(a.r.lessThan(s),()=>{o.assign(i),s.assign(a.r)})}return gt(o,s)}),ee=new g.Vector2,yt=new g.DepthTexture(1,1);class ve extends v.TempNode{static get type(){return"TemporalAntialiasNode"}velocityNodeImmutable;inputNode;depthNode;velocityNode;camera;temporalAlpha=e.uniform(.05);varianceGamma=e.uniform(1);velocityThreshold=e.uniform(.1);depthError=e.uniform(.001);debugShowRejection=!1;textureNode;resolveRT=this.createRenderTarget("Resolve");historyRT=this.createRenderTarget("History");previousDepthTexture;resolveMaterial=new v.NodeMaterial;copyMaterial=new v.NodeMaterial;mesh=new v.QuadMesh;rendererState;needsSyncPostProcessing=!1;needsClearHistory=!1;resolveNode=e.texture(this.resolveRT.texture);historyNode=e.texture(this.historyRT.texture);previousDepthNode=e.texture(yt);originalProjectionMatrix=new g.Matrix4;jitterIndex=0;constructor(t,s,o,n,i){if(super("vec4"),this.velocityNodeImmutable=t,this.inputNode=s,this.depthNode=o,this.velocityNode=n,!ht(i))throw new Error("The provided camera is not supported.");this.camera=i,this.textureNode=I(this,this.resolveRT.texture),this.updateBeforeType=v.NodeUpdateType.FRAME}customCacheKey(){return te.hash(this.camera.id,+this.debugShowRejection)}createRenderTarget(t){const s=new g.RenderTarget(1,1,{depthBuffer:!1,type:g.HalfFloatType,format:g.RGBAFormat}),o=s.texture;o.minFilter=g.LinearFilter,o.magFilter=g.LinearFilter,o.generateMipmaps=!1;const n=this.constructor.type;return o.name=t!=null?`${n}.${t}`:n,s}getTextureNode(){return this.textureNode}setProjectionMatrix(t){const{velocityNodeImmutable:s}=this;s!=null&&(s.projectionMatrix=t)}setSize(t,s){const{resolveRT:o,historyRT:n}=this;return(t!==n.width||s!==n.height)&&(o.setSize(t,s),n.setSize(t,s),this.needsClearHistory=!0),this}clearHistory(t){t.setRenderTarget(this.resolveRT),t.clear(),t.setRenderTarget(this.historyRT),t.clear(),t.setRenderTarget(this.historyRT),this.mesh.material=this.copyMaterial,this.mesh.render(t),this.needsClearHistory=!1}setViewOffset(t,s){const{camera:o}=this;o.updateProjectionMatrix(),this.originalProjectionMatrix.copy(o.projectionMatrix),this.setProjectionMatrix(this.originalProjectionMatrix);const n=J[this.jitterIndex],i=n.x-.5,a=n.y-.5;o.setViewOffset(t,s,i,a,t,s)}clearViewOffset(){this.camera.clearViewOffset(),this.setProjectionMatrix(null),this.jitterIndex=(this.jitterIndex+1)%J.length}copyDepthTexture(t){const s=this.depthNode.value,o=this.previousDepthTexture??=s.clone();(o.image.width!==s.width||o.image.height!==s.height)&&(o.image.width=s.width,o.image.height=s.height,o.needsUpdate=!0),t.copyTextureToTexture(s,o),this.previousDepthNode.value=o}swapBuffers(){const{resolveRT:t,historyRT:s}=this;this.resolveRT=s,this.historyRT=t,this.resolveNode.value=s.texture,this.historyNode.value=t.texture,this.textureNode.value=t.texture}updateBefore({renderer:t}){if(t==null)return;const s=t.getDrawingBufferSize(ee);this.setSize(s.x,s.y),this.rendererState=dt(t,this.rendererState),this.needsClearHistory&&this.clearHistory(t),t.setRenderTarget(this.resolveRT),this.mesh.material=this.resolveMaterial,this.mesh.render(t),pt(t,this.rendererState),$(t)&&this.copyDepthTexture(t),this.swapBuffers(),this.needsSyncPostProcessing&&this.clearViewOffset()}setupResolveNode({renderer:t}){const s=o=>{const{previousDepthNode:n}=this,i=n.load(e.ivec2(o.mul(n.size(0)).sub(.5))).toVar();return t.logarithmicDepthBuffer?j(i,A(this.camera),D(this.camera)):i};return e.Fn(()=>{const o=e.ivec2(e.screenCoordinate),n=e.screenUV,i=this.inputNode.load(o),a=ft(this.depthNode,o),c=a.get("coord"),u=this.velocityNode.load(c).xyz.mul(e.vec3(.5,-.5,.5)).toVar(),p=u.xy.length().div(this.velocityThreshold).oneMinus().saturate(),l=n.sub(u.xy).toVar(),d=s(l),h=t.logarithmicDepthBuffer?j(a.get("depth"),A(this.camera),D(this.camera)):a.get("depth"),m=e.step(h.add(u.z),d.add(this.depthError)),x=p.mul(m),f=e.and(l.greaterThanEqual(0).all(),l.lessThanEqual(1).all()).toFloat(),w=a.get("depth").notEqual(1).toFloat(),T=e.vec4(0).toVar();return e.If(f.mul(w).mul(x).greaterThan(0),()=>{const S=pe(this.historyNode,l),R=vt(this.inputNode,o,i,S,this.varianceGamma),M=u.xy.abs().mul(e.screenSize),B=e.max(M.x,M.y).fract().mul(.5),N=e.mix(this.temporalAlpha,.8,B).saturate();T.assign(e.mix(R,i,N))}).Else(()=>{T.assign(i),this.debugShowRejection&&T.assign(e.vec3(1,0,0))}),T})()}setup(t){const{context:s}=t.getContext().postProcessing??{};if(s!=null){const{onBeforePostProcessing:i}=s;s.onBeforePostProcessing=()=>{i?.();const a=t.renderer.getDrawingBufferSize(ee);this.setViewOffset(a.width,a.height)},this.needsSyncPostProcessing=!0}const{resolveMaterial:o,copyMaterial:n}=this;return o.fragmentNode=this.setupResolveNode(t),o.needsUpdate=!0,n.fragmentNode=this.inputNode,n.needsUpdate=!0,this.textureNode.uvNode=this.inputNode.uvNode,this.textureNode}dispose(){this.resolveRT.dispose(),this.historyRT.dispose(),this.previousDepthTexture?.dispose(),this.resolveMaterial.dispose(),this.copyMaterial.dispose(),this.mesh.geometry.dispose(),super.dispose()}}const wt=r=>(t,s,o,n)=>e.nodeObject(new ve(r,E(t,"TemporalAntialiasNode.Input"),s,o,n));exports.DownsampleThresholdNode=k;exports.FnLayout=F;exports.FnVar=V;exports.GaussianBlurNode=q;exports.HighpVelocityNode=ie;exports.KawaseBlurNode=ae;exports.LensFlareNode=ce;exports.MipmapBlurNode=re;exports.MipmapSurfaceBlurNode=H;exports.OutputTexture3DNode=de;exports.OutputTextureNode=se;exports.RTTextureNode=W;exports.TemporalAntialiasNode=ve;exports.cameraFar=D;exports.cameraNear=A;exports.cameraPositionWorld=we;exports.convertToTexture=E;exports.debugFragmentNode=Te;exports.debugNode=Se;exports.debugVertexNode=Ne;exports.depthToColor=ct;exports.depthToViewZ=he;exports.dithering=Oe;exports.downsampleThreshold=Pe;exports.equirectGrid=Ie;exports.equirectToDirectionWorld=lt;exports.gaussianBlur=Ue;exports.highpVelocity=Ge;exports.hookFunction=be;exports.interleavedGradientNoise=ne;exports.inverseProjectionMatrix=fe;exports.inverseViewMatrix=ye;exports.isWebGPU=$;exports.kawaseBlur=Le;exports.lensFlare=Xe;exports.logarithmicToPerspectiveDepth=j;exports.mipmapBlur=Ve;exports.mipmapBlurDownsample=L;exports.mipmapBlurUpsample=oe;exports.mipmapSurfaceBlur=Ye;exports.node=rt;exports.outputTexture=I;exports.outputTexture3D=nt;exports.perspectiveToLogarithmicDepth=at;exports.projectionMatrix=xe;exports.rayEllipsoidIntersection=st;exports.raySphereIntersection=et;exports.raySpheresIntersections=tt;exports.raySpheresIntersectionsStruct=le;exports.rtTexture=ue;exports.screenToPositionView=ut;exports.temporalAntialias=wt;exports.textureBicubic=pe;exports.textureCatmullRom=it;exports.turbo=me;exports.viewMatrix=ge;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("three"),e=require("three/tsl"),m=require("three/webgpu"),I=require("./shared3.cjs"),y=require("./shared.cjs"),te=require("three/src/nodes/core/NodeUtils.js");let C;function b(r,t,s){C??=new WeakMap;let o=C.get(r);return o==null&&(o={},C.set(r,o)),o[t]??=s()}const ve=r=>b(r,"projectionMatrix",()=>e.reference("projectionMatrix","mat4",r).setName("projectionMatrix")),xe=r=>b(r,"viewMatrix",()=>e.reference("matrixWorldInverse","mat4",r).setName("viewMatrix")),ge=r=>b(r,"inverseProjectionMatrix",()=>e.reference("projectionMatrixInverse","mat4",r).setName("inverseProjectionMatrix")),fe=r=>b(r,"inverseViewMatrix",()=>e.reference("matrixWorld","mat4",r).setName("inverseViewMatrix")),ye=r=>b(r,"cameraPositionWorld",()=>e.uniform(new x.Vector3).setName("cameraPositionWorld").onRenderUpdate((t,{value:s})=>{s.setFromMatrixPosition(r.matrixWorld)})),A=r=>b(r,"cameraNear",()=>e.reference("near","float",r).setName("cameraNear")),D=r=>b(r,"cameraFar",()=>e.reference("far","float",r).setName("cameraFar"));async function j(r,t){return await r.debug.getShaderAsync(new x.Scene,new x.Camera,t).then(s=>s).catch(s=>(console.error(s),{fragmentShader:null,vertexShader:null}))}function we(r,t){const s=new x.Mesh(new I.QuadGeometry,t);j(r,s).then(o=>{console.log(o.fragmentShader)}).finally(()=>{s.geometry.dispose()})}function Te(r,t){const s=new x.Mesh(new I.QuadGeometry,t);j(r,s).then(o=>{console.log(o.vertexShader)}).finally(()=>{s.geometry.dispose()})}function Ne(r,t){const s=new m.NodeMaterial;s.vertexNode=e.vec4(e.positionGeometry.xy,0,1),s.fragmentNode=t;const o=new x.Mesh(new I.QuadGeometry,s);j(r,o).then(i=>{console.log(i.fragmentShader)}).finally(()=>{s.dispose(),o.geometry.dispose()})}function Se(r,t,s){const o=r[t];return r[t]=((...i)=>(s(...i),o.apply(r,i))),r}class se extends m.TextureNode{static get type(){return"OutputTextureNode"}constructor(t,s){super(s),this.owner=t,this.setUpdateMatrix(!1)}setup(t){return this.owner.build(t),super.setup(t)}clone(){return new this.constructor(this.owner,this.value)}}const G=(...r)=>new se(...r);class P extends m.TempNode{constructor(t){super("vec4"),this.resolutionScale=1,this.renderTargets=[],this.inputNode=t,this.updateBeforeType=m.NodeUpdateType.FRAME}static get type(){return"FilterNode"}createRenderTarget(t){const s=new x.RenderTarget(1,1,{depthBuffer:!1,type:x.HalfFloatType,format:x.RGBAFormat}),o=s.texture;o.minFilter=x.LinearFilter,o.magFilter=x.LinearFilter,o.generateMipmaps=!1;const i=this.constructor.type;return o.name=t!=null?`${i}.${t}`:i,this.renderTargets.push(s),s}getTextureNode(){return y.invariant(this.textureNode!=null,"outputTexture must be specified before getTextureNode() is called."),this.textureNode}get outputTexture(){return this.textureNode?.value??null}set outputTexture(t){this.textureNode=t!=null?G(this,t):void 0}setup(t){const{inputNode:s,textureNode:o}=this;return y.invariant(s!=null,"inputNode must be specified before being setup."),y.invariant(o!=null,"outputTexture must be specified before being setup."),o.uvNode=s.uvNode,o}dispose(){for(const t of this.renderTargets)t.dispose();super.dispose()}}const{resetRendererState:Me,restoreRendererState:be}=m.RendererUtils;class L extends P{constructor(t,s){super(t),this.downsampleRTs=[],this.upsampleRTs=[],this.downsampleMaterial=new m.NodeMaterial,this.upsampleMaterial=new m.NodeMaterial,this.mesh=new m.QuadMesh,this.inputTexelSize=e.uniform(new x.Vector2),this.downsampleNode=e.texture();for(let o=0;o<s;++o)this.downsampleRTs[o]=this.createRenderTarget(`Downsample${o}`),o<s-1&&(this.upsampleRTs[o]=this.createRenderTarget(`Upsample${o}`));this.outputTexture=this.upsampleRTs[0].texture}setSize(t,s){const{resolutionScale:o}=this;let i=Math.max(Math.round(t*o),1),n=Math.max(Math.round(s*o),1);const{downsampleRTs:a,upsampleRTs:c}=this;for(let u=0;u<a.length;++u)i=Math.max(Math.round(i/2),1),n=Math.max(Math.round(n/2),1),a[u].setSize(i,n),u<c.length&&c[u].setSize(i,n);return this}updateBefore({renderer:t}){if(t==null)return;const{downsampleRTs:s,upsampleRTs:o,mesh:i,inputNode:n,inputTexelSize:a,downsampleNode:c}=this;y.invariant(n!=null);const{width:u,height:h}=n.value;this.setSize(u,h);const d=n.value;this.rendererState=Me(t,this.rendererState),i.material=this.downsampleMaterial;for(const l of s){const{width:p,height:v}=n.value;a.value.set(1/p,1/v),t.setRenderTarget(l),i.render(t),n.value=l.texture}i.material=this.upsampleMaterial;for(let l=o.length-1;l>=0;--l){const p=o[l],{width:v,height:g}=n.value;a.value.set(1/v,1/g),c.value=s[l].texture,t.setRenderTarget(p),i.render(t),n.value=p.texture}be(t,this.rendererState),n.value=d}setup(t){const{inputNode:s}=this;y.invariant(s!=null);const{downsampleMaterial:o,upsampleMaterial:i}=this;return o.fragmentNode=this.setupDownsampleNode(t),i.fragmentNode=this.setupUpsampleNode(t),o.needsUpdate=!0,i.needsUpdate=!0,super.setup(t)}dispose(){for(const t of this.downsampleRTs)t.dispose();for(const t of this.upsampleRTs)t.dispose();this.downsampleMaterial.dispose(),this.upsampleMaterial.dispose(),this.mesh.geometry.dispose(),super.dispose()}}const k=(r,t)=>{const s=e.uv(),o=e.vec4(1,1,-1,-1).mul(t.xyxy).add(s.xyxy),i=e.vec4(2,2,-2,-2).mul(t.xyxy).add(s.xyxy),n=o.zy.toVertexStage(),a=o.xy.toVertexStage(),c=o.zw.toVertexStage(),u=o.xw.toVertexStage(),h=e.vec2(s.x,i.y).toVertexStage(),d=e.vec2(i.z,s.y).toVertexStage(),l=e.vec2(i.x,s.y).toVertexStage(),p=e.vec2(s.x,i.w).toVertexStage(),v=i.zy.toVertexStage(),g=i.xy.toVertexStage(),f=i.zw.toVertexStage(),N=i.xw.toVertexStage();return e.add(e.add(r.sample(s),r.sample(n),r.sample(a),r.sample(c),r.sample(u)).mul(1/8),e.add(r.sample(h),r.sample(d),r.sample(l),r.sample(p)).mul(1/16),e.add(r.sample(v),r.sample(g),r.sample(f),r.sample(N)).mul(1/32))},oe=(r,t)=>{const s=e.uv(),o=e.vec4(1,1,-1,-1).mul(t.xyxy).add(s.xyxy),i=e.vec2(s.x,o.y).toVertexStage(),n=e.vec2(o.z,s.y).toVertexStage(),a=e.vec2(o.x,s.y).toVertexStage(),c=e.vec2(s.x,o.w).toVertexStage(),u=o.zy.toVertexStage(),h=o.xy.toVertexStage(),d=o.zw.toVertexStage(),l=o.xw.toVertexStage();return e.add(r.sample(s).mul(.25),e.add(r.sample(i),r.sample(n),r.sample(a),r.sample(c)).mul(.125),e.add(r.sample(u),r.sample(h),r.sample(d),r.sample(l)).mul(.0625))};class re extends L{static get type(){return"MipmapBlurNode"}constructor(t,s=4){super(t,s),this.resolutionScale=.5}setupDownsampleNode(t){return y.invariant(this.inputNode!=null),k(this.inputNode,this.inputTexelSize)}setupUpsampleNode(t){return y.invariant(this.inputNode!=null),oe(this.inputNode,this.inputTexelSize)}}const Re=(...r)=>new re(...r),{resetRendererState:Ve,restoreRendererState:ze}=m.RendererUtils;class Be extends P{constructor(t){super(t),this.material=new m.NodeMaterial,this.mesh=new m.QuadMesh(this.material),this.inputTexelSize=e.uniform(new x.Vector2),this.renderTarget=this.createRenderTarget(),this.outputTexture=this.renderTarget.texture}setSize(t,s){const{resolutionScale:o}=this,i=Math.max(Math.round(t*o),1),n=Math.max(Math.round(s*o),1);return this.renderTarget.setSize(i,n),this}updateBefore({renderer:t}){if(t==null)return;const{inputNode:s}=this;y.invariant(s!=null);const{width:o,height:i}=s.value;this.setSize(o,i),this.inputTexelSize.value.set(1/o,1/i),this.rendererState=Ve(t,this.rendererState),t.setRenderTarget(this.renderTarget),this.mesh.render(t),ze(t,this.rendererState)}setup(t){const{inputNode:s}=this;y.invariant(s!=null);const{material:o}=this;return o.fragmentNode=this.setupOutputNode(t),o.needsUpdate=!0,super.setup(t)}dispose(){this.renderTarget.dispose(),this.material.dispose(),this.mesh.geometry.dispose(),super.dispose()}}class q extends Be{constructor(t){super(t),this.thresholdLevel=e.uniform(5),this.thresholdRange=e.uniform(1),this.resolutionScale=.5}static get type(){return"DownsampleThresholdNode"}setupOutputNode(){const{inputNode:t,thresholdLevel:s,thresholdRange:o,inputTexelSize:i}=this;y.invariant(t!=null);const n=k(t,i),a=e.luminance(n.rgb),c=e.smoothstep(s,s.add(o),a);return e.vec4(n.rgb,a).mul(c)}}const Fe=(...r)=>new q(...r);function Q(r){if(typeof r=="string")return r;if(r.layout.name==null)throw new Error("Struct name is required.");return r.layout.name}function F({typeOnly:r=!1,...t}){return r?s=>e.Fn(s):s=>e.Fn(s).setLayout({...t,type:Q(t.type),inputs:t.inputs?.map(o=>({...o,type:Q(o.type)}))??[]})}function R(r){return e.Fn((t,s)=>{const o=r(...t);return typeof o=="function"?o(s):o})}const{resetRendererState:Pe,restoreRendererState:Ce}=m.RendererUtils;class Ae extends P{constructor(t){super(t),this.iterations=1,this.material=new m.NodeMaterial,this.mesh=new m.QuadMesh(this.material),this.inputTexelSize=e.uniform(new x.Vector2),this.direction=e.uniform(new x.Vector2),this.horizontalRT=this.createRenderTarget("Horizontal"),this.verticalRT=this.createRenderTarget("Vertical"),this.outputTexture=this.verticalRT.texture}setSize(t,s){const{resolutionScale:o}=this,i=Math.max(Math.round(t*o),1),n=Math.max(Math.round(s*o),1);return this.horizontalRT.setSize(i,n),this.verticalRT.setSize(i,n),this}updateBefore({renderer:t}){if(t==null)return;const{horizontalRT:s,verticalRT:o,mesh:i,inputNode:n,direction:a}=this;y.invariant(n!=null);const{width:c,height:u}=n.value;this.setSize(c,u),this.inputTexelSize.value.set(1/c,1/u);const h=n.value;this.rendererState=Pe(t,this.rendererState);for(let d=0;d<this.iterations;++d)a.value.set(1,0),t.setRenderTarget(s),i.render(t),n.value=s.texture,a.value.set(0,1),t.setRenderTarget(o),i.render(t),n.value=o.texture;Ce(t,this.rendererState),n.value=h}setup(t){const{inputNode:s}=this;y.invariant(s!=null);const{material:o}=this;return o.fragmentNode=this.setupOutputNode(t),o.needsUpdate=!0,super.setup(t)}dispose(){this.horizontalRT.dispose(),this.verticalRT.dispose(),this.material.dispose(),this.mesh.geometry.dispose(),super.dispose()}}function Z(r){if(y.invariant(r>=0),r===0)return new Float64Array(0);if(r===1)return new Float64Array([1]);let t=new Float64Array(r),s=new Float64Array(r),o=s;for(let i=1;i<=r;++i){for(let n=0;n<i;++n)s[n]=n===0||n===i-1?1:t[n-1]+t[n];o=s,s=t,t=o}return o}function De(r,t=2){y.invariant(r>=3);const s=r+t*2,o=t>0?Z(s).slice(t,-t):Z(s),i=Math.floor((o.length-1)/2),n=o.reduce((l,p)=>l+p,0),a=o.slice(i),c=[...Array(i+1).keys()],u=new Float64Array(Math.floor(c.length/2)),h=new Float64Array(u.length);u[0]=a[0]/n;for(let l=1,p=1;l<c.length-1;l+=2,++p){const v=c[l],g=c[l+1],f=a[l],N=a[l+1],w=f+N,M=(v*f+g*N)/w;u[p]=w/n,h[p]=M}const d=(u.reduce((l,p)=>l+p,0)-u[0]*.5)*2;if(d!==0){const l=1/d;for(let p=0;p<u.length;++p)u[p]*=l}return{offsets:h,weights:u}}class O extends Ae{static get type(){return"GaussianBlurNode"}constructor(t,s=35){super(t),this.kernelSize=s}setupOutputNode(t){const{inputNode:s,inputTexelSize:o,direction:i}=this;y.invariant(s!=null);const{offsets:n,weights:a}=De(this.kernelSize);return e.Fn(()=>{const c=e.uv(),u=i.mul(o).toVertexStage(),h=s.sample(c).mul(a[0]);for(let d=1;d<n.length;++d){const l=u.mul(n[d]);h.addAssign(e.add(s.sample(c.add(l)),s.sample(c.sub(l))).mul(a[d]))}return h})()}}const Ue=(...r)=>new O(...r),ie=r=>r.dot(e.vec2(.06711056,.00583715)).fract().mul(52.9829189).fract(),Ie=e.Fn(()=>{const r=e.vec2(e.screenCoordinate.xy).add(e.time.fract().mul(1337)),t=ie(r);return e.vec3(t,t.oneMinus(),t).sub(.5).div(255)}).once()(),je=(r,t,s=e.vec2(90,45))=>{const o=e.equirectUV(r),i=e.fwidth(o),n=t.mul(i).mul(.5),a=e.abs(o.mul(s).fract().sub(.5)).div(s),c=e.smoothstep(n,n.add(i),a).oneMinus();return c.x.add(c.y).clamp(0,1)};class ne extends m.TempNode{constructor(){super("vec3"),this.currentProjectionMatrix=e.uniform(new x.Matrix4),this.previousProjectionMatrix=e.uniform("mat4"),this.currentModelViewMatrix=e.uniform(new x.Matrix4),this.previousModelViewMatrix=e.uniform("mat4"),this.objectModelViewMatrices=new WeakMap,this.updateType=m.NodeUpdateType.FRAME,this.updateBeforeType=m.NodeUpdateType.OBJECT,this.updateAfterType=m.NodeUpdateType.OBJECT}static get type(){return"HighpVelocityNode"}update({camera:t}){if(t==null)return;const{currentProjectionMatrix:s,previousProjectionMatrix:o}=this,i=this.projectionMatrix??t.projectionMatrix;o.value==null?o.value=new x.Matrix4().copy(i):o.value.copy(s.value),s.value.copy(i)}updateBefore({object:t,camera:s}){if(t==null||s==null)return;const{currentModelViewMatrix:o,previousModelViewMatrix:i,objectModelViewMatrices:n}=this;o.value.multiplyMatrices(s.matrixWorldInverse,t.matrixWorld),i.value=n.get(t)??o.value}updateAfter({object:t}){if(t==null)return;const{currentModelViewMatrix:s,objectModelViewMatrices:o}=this;let i=o.get(t);i==null&&(i=new x.Matrix4,o.set(t,i)),i.copy(s.value)}setup(t){const s=this.currentProjectionMatrix.mul(this.currentModelViewMatrix).mul(e.positionLocal).toVertexStage(),o=this.previousProjectionMatrix.mul(this.previousModelViewMatrix).mul(e.positionPrevious).toVertexStage(),i=s.xyz.div(s.w),n=o.xyz.div(o.w);return e.sub(i,n)}}const Ge=e.nodeImmutable(ne);class ae extends L{static get type(){return"KawaseBlurNode"}constructor(t,s=4){super(t,s),this.resolutionScale=.5}setupDownsampleNode(t){const{inputNode:s,inputTexelSize:o}=this;y.invariant(s!=null);const i=e.uv(),n=e.vec4(1,1,-1,-1).mul(o.xyxy.mul(.5)).add(i.xyxy),a=n.zy.toVertexStage(),c=n.xy.toVertexStage(),u=n.xw.toVertexStage(),h=n.zw.toVertexStage();return e.add(s.sample(i).mul(4),s.sample(a),s.sample(c),s.sample(u),s.sample(h)).mul(1/8)}setupUpsampleNode(t){const{inputNode:s,inputTexelSize:o}=this;y.invariant(s!=null);const i=e.uv(),n=e.vec4(1,1,-1,-1).mul(o.xyxy.mul(.5)).add(i.xyxy),a=n.zy.toVertexStage(),c=n.xy.toVertexStage(),u=n.xw.toVertexStage(),h=n.zw.toVertexStage(),d=e.vec2(n.z,i.y).toVertexStage(),l=e.vec2(n.x,i.y).toVertexStage(),p=e.vec2(i.x,n.y).toVertexStage(),v=e.vec2(i.x,n.w).toVertexStage();return e.add(e.add(s.sample(a),s.sample(c),s.sample(u),s.sample(h)).mul(1/12),e.add(s.sample(d),s.sample(l),s.sample(p),s.sample(v)).mul(1/6))}}const Le=(...r)=>new ae(...r);class ke extends m.TempNode{constructor(t){super("vec3"),this.intensity=e.uniform(1e-5),this.inputNode=t}static get type(){return"LensGhostNode"}setup(t){const{inputNode:s,intensity:o}=this;y.invariant(s!=null);const i=F({name:"sampleGhost",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"direction",type:"vec2"},{name:"color",type:"vec3"},{name:"offset",type:"float"}]})(([u,h,d,l])=>{const p=h.mul(l).add(u.oneMinus()).saturate(),v=s.sample(p).rgb.mul(d),g=e.sub(.5,p).length().mul(1/(Math.SQRT2/4)).saturate();return v.mulAssign(g.oneMinus().pow(3)),v}),n=e.uv(),a=n.sub(.5);return e.add(i(n,a,e.vec3(.8,.8,1),-5),i(n,a,e.vec3(1,.8,.4),-1.5),i(n,a,e.vec3(.9,1,.8),-.4),i(n,a,e.vec3(1,.8,.4),-.2),i(n,a,e.vec3(.9,.7,.7),-.1),i(n,a,e.vec3(.5,1,.4),.7),i(n,a,e.vec3(.5,.5,.5),1),i(n,a,e.vec3(1,1,.6),2.5),i(n,a,e.vec3(.5,.8,1),10)).mul(o)}}const{resetRendererState:qe,restoreRendererState:Oe}=m.RendererUtils;function We(){const r=new m.RenderTarget(1,1,{depthBuffer:!1,type:m.HalfFloatType,format:m.RGBAFormat}),t=r.texture;return t.minFilter=m.LinearFilter,t.magFilter=m.LinearFilter,t.generateMipmaps=!1,r}const Ee=new m.Vector2;class W extends m.TextureNode{constructor(t,s){const o=We();super(o.texture,s??e.uv()),this.resolutionScale=1,this.material=new m.NodeMaterial,this.mesh=new m.QuadMesh(this.material),this.node=t,this.renderTarget=o,this.updateBeforeType=m.NodeUpdateType.FRAME}static get type(){return"RTTextureNode"}setSize(t,s){const{resolutionScale:o}=this,i=Math.max(Math.round(t*o),1),n=Math.max(Math.round(s*o),1);return this.renderTarget.setSize(i,n),this}updateBefore({renderer:t}){if(t==null)return;const s=t.getDrawingBufferSize(Ee);this.setSize(s.x,s.y),this.rendererState=qe(t,this.rendererState),t.setRenderTarget(this.renderTarget),this.mesh.render(t),Oe(t,this.rendererState)}setup(t){const{material:s}=this;return s.fragmentNode=this.node.context(t.getContext()),s.needsUpdate=!0,super.setup(t)}dispose(){this.renderTarget.dispose(),this.material.dispose(),this.mesh.geometry.dispose(),super.dispose()}clone(){const t=new m.TextureNode(this.value,this.uvNode,this.levelNode);return t.sampler=this.sampler,t.referenceNode=this,t}}const ue=(...r)=>new W(...r),E=(r,t)=>{let s;return r.isTextureNode===!0||r.isSampleNode===!0?s=r:r.getTextureNode!=null?s=r.getTextureNode():(s=new W(r),t!=null&&(s.value.name=t)),s},{resetRendererState:He,restoreRendererState:$e}=m.RendererUtils;function Qe(){const o=document.createElement("canvas");o.width=256,o.height=32;const i=o.getContext("2d");y.invariant(i!=null),i.beginPath(),i.moveTo(0,32/2),i.lineTo(256/2,5),i.lineTo(256,32/2),i.lineTo(256/2,27),i.closePath();const n=i.createLinearGradient(0,0,256,0);return n.addColorStop(0,"#000000"),n.addColorStop(.5,"#ffffff"),n.addColorStop(1,"#000000"),i.fillStyle=n,i.fill(),new x.CanvasTexture(o)}const K=e.struct({color:"vec3",luminance:"float",position:"vec2",scale:"float",sin:"float",cos:"float"});class Ze extends P{constructor(t){super(t),this.spikePairCount=6,this.wireframe=!1,this.intensity=e.uniform(1e-5),this.sizeScale=e.uniform(new x.Vector2(1.5,.01)),this.luminanceThreshold=e.uniform(100),this.counterBuffer=new m.StorageBufferAttribute(1,1),this.instanceBuffer=e.instancedArray(1,K),this.renderTarget=this.createRenderTarget(),this.material=new m.MeshBasicNodeMaterial({depthTest:!1,depthWrite:!1,transparent:!0,blending:x.AdditiveBlending}),this.mesh=new x.Mesh(new x.PlaneGeometry(1,1),this.material),this.camera=new x.PerspectiveCamera,this.inputTexelSize=e.uniform(new x.Vector2),this.outputTexelSize=e.uniform(new x.Vector2),this.geometryRatio=e.uniform(new x.Vector2),this.inputNode=t,this.resolutionScale=.5,this.outputTexture=this.renderTarget.texture}customCacheKey(){return te.hash(this.spikePairCount,+this.wireframe)}setSize(t,s){const{resolutionScale:o}=this,i=Math.max(Math.round(t*o),1),n=Math.max(Math.round(s*o),1);this.renderTarget.setSize(i,n);const a=Math.floor(i/2),c=Math.floor(n/2),u=a*c;return this.instanceBuffer.bufferCount<u&&(this.instanceBuffer.dispose(),this.instanceBuffer=e.instancedArray(u,K),this.setupCompute(a,c),this.setupMaterial()),this}updateBefore({renderer:t}){if(t==null)return;const{inputNode:s}=this;y.invariant(s!=null);const{width:o,height:i}=s.value;this.setSize(o,i);const{computeNode:n,counterBuffer:a,renderTarget:c}=this;y.invariant(n!=null),this.inputTexelSize.value.set(1/o,1/i);const u=o/i;u>1?this.geometryRatio.value.set(1/u,1):this.geometryRatio.value.set(1,u);const{width:h,height:d}=c;this.outputTexelSize.value.set(1/h,1/d),a.array[0]=0,a.needsUpdate=!0,t.compute(n),t.getArrayBufferAsync(a).then(l=>{this.mesh.count=new Uint32Array(l)[0]}).catch(l=>{console.error(l)}),this.rendererState=He(t,this.rendererState),t.setRenderTarget(c),t.render(this.mesh,this.camera),$e(t,this.rendererState)}setupCompute(t,s){const{spikePairCount:o,inputNode:i,counterBuffer:n,instanceBuffer:a,outputTexelSize:c}=this;y.invariant(i!=null);const u=e.storage(n,"uint",n.count).toAtomic();this.computeNode=e.Fn(()=>{const h=e.uvec2(t,s);e.If(e.globalId.xy.greaterThanEqual(h).any(),()=>{e.Return()});const d=e.vec2(e.globalId.xy).mul(c).mul(2),l=i.sample(d),p=l.a;e.If(p.greaterThan(.1),()=>{const v=e.atomicAdd(u.element(0),o);for(let g=0;g<o;++g){const f=a.element(v.add(g));f.get("color").assign(l.rgb),f.get("luminance").assign(p),f.get("position").assign(e.globalId.xy),f.get("scale").assign(g%2===0?1:.5);const N=Math.PI*(3-Math.sqrt(5)),w=Math.PI/o*g+N;f.get("sin").assign(Math.sin(w)),f.get("cos").assign(Math.cos(w))}})})().compute([Math.ceil(t/8),Math.ceil(s/8),1],[8,8,1])}setupMaterial(){const{inputNode:t,spikeNode:s,instanceBuffer:o,luminanceThreshold:i,intensity:n,sizeScale:a,outputTexelSize:c,geometryRatio:u}=this;y.invariant(t!=null),y.invariant(s!=null);const h=o.element(e.instanceIndex);this.material.colorNode=this.wireframe?e.vec4(1):s.mul(h.get("color").mul(n)),this.material.vertexNode=e.Fn(()=>{const d=h.get("sin"),l=h.get("cos"),p=e.mat3(l,d,0,d.negate(),l,0,0,0,1),g=h.get("position").mul(c).mul(2),f=g.flipY().mul(2).sub(1),w=h.get("luminance").div(i).saturate(),M=e.vec2(w,1).mul(h.get("scale"),a,g.sub(.5).length().mul(2).oneMinus().mul(.5).add(.5)),B=p.mul(e.positionGeometry.mul(e.vec4(M,1,1))).mul(u).add(e.vec3(f,0));return e.vec4(B,1)})(),this.material.wireframe=this.wireframe,this.material.needsUpdate=!0}setup(t){if(this.spikeNode==null){const s=Qe();s.colorSpace=x.SRGBColorSpace,this.spikeNode=e.texture(s)}return this.setupMaterial(),super.setup(t)}dispose(){this.renderTarget.dispose(),this.material.dispose(),this.mesh.geometry.dispose(),super.dispose()}}const Ke=new x.Vector2;class _e extends m.TempNode{constructor(t){super("vec3"),this.intensity=e.uniform(1e-5),this.chromaticAberration=e.uniform(.005),this.aspectRatio=e.uniform(0),this.inputNode=t,this.updateBeforeType=m.NodeUpdateType.FRAME}static get type(){return"LensHaloNode"}updateBefore({renderer:t}){if(t==null)return;const{width:s,height:o}=t.getDrawingBufferSize(Ke);this.aspectRatio.value=s/o}setup(t){const{inputNode:s,intensity:o,chromaticAberration:i,aspectRatio:n}=this;y.invariant(s!=null);const a=F({name:"cubicRingMask",type:"float",inputs:[{name:"x",type:"float"},{name:"radius",type:"float"},{name:"thickness",type:"float"}]})(([d,l,p])=>{const v=e.min(e.abs(d.sub(l)).div(p),1);return e.mul(v,v,e.sub(3,v.mul(2))).oneMinus()}),c=F({name:"sampleHalo",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"radius",type:"float"}]})(([d,l])=>{const p=e.vec2(n,1),v=d.sub(.5).mul(p).normalize().div(p),g=e.vec3(i).mul(e.vec3(-1,0,1)),f=e.fract(v.mul(l).add(d.oneMinus())),N=e.vec3(s.sample(v.mul(g.r).add(f)).r,s.sample(v.mul(g.g).add(f)).g,s.sample(v.mul(g.b).add(f)).b),w=d.sub(e.vec2(.5,0)).mul(p).add(e.vec2(.5,0)),M=e.distance(w,e.vec2(.5)).saturate();return N.mulAssign(a(M,.45,.25)),N}),u=e.uv();return c(u,.3).mul(o)}}const S=r=>r.greaterThanEqual(0).all().and(r.lessThanEqual(1).all()).toFloat();class H extends L{constructor(t,s=4){super(t,s),this.blendAmount=e.uniform(.85),this.resolutionScale=.5}static get type(){return"MipmapSurfaceBlurNode"}setupDownsampleNode(t){const{inputNode:s,inputTexelSize:o}=this;return y.invariant(s!=null),e.Fn(()=>{const i=e.uv(),n=e.vec4(1,1,-1,-1).mul(o.xyxy).add(i.xyxy),a=e.vec4(2,2,-2,-2).mul(o.xyxy).add(i.xyxy),c=n.zy.toVertexStage(),u=n.xy.toVertexStage(),h=n.zw.toVertexStage(),d=n.xw.toVertexStage(),l=a.zy.toVertexStage(),p=a.xy.toVertexStage(),v=a.zw.toVertexStage(),g=a.xw.toVertexStage(),f=e.vec2(i.x,a.y).toVertexStage(),N=e.vec2(a.z,i.y).toVertexStage(),w=e.vec2(a.x,i.y).toVertexStage(),M=e.vec2(i.x,a.w).toVertexStage(),B=1/4/2,V=1/9/2,z=s.sample(i).mul(V);let T;return T=e.vec4(S(c),S(u),S(h),S(d)).mul(B),z.addAssign(s.sample(c).mul(T.x),s.sample(u).mul(T.y),s.sample(h).mul(T.z),s.sample(d).mul(T.w)),T=e.vec4(S(l),S(p),S(v),S(g)).mul(V),z.addAssign(s.sample(l).mul(T.x),s.sample(p).mul(T.y),s.sample(v).mul(T.z),s.sample(g).mul(T.w)),T=e.vec4(S(f),S(N),S(w),S(M)).mul(V),z.addAssign(s.sample(f).mul(T.x),s.sample(N).mul(T.y),s.sample(w).mul(T.z),s.sample(M).mul(T.w)),z})()}setupUpsampleNode(t){const{inputNode:s,inputTexelSize:o,downsampleNode:i}=this;y.invariant(s!=null);const n=e.uv(),a=e.vec4(1,1,-1,-1).mul(o.xyxy).add(n.xyxy),c=e.vec2(n.x,a.y).toVertexStage(),u=e.vec2(a.z,n.y).toVertexStage(),h=e.vec2(a.x,n.y).toVertexStage(),d=e.vec2(n.x,a.w).toVertexStage(),l=a.zy.toVertexStage(),p=a.xy.toVertexStage(),v=a.zw.toVertexStage(),g=a.xw.toVertexStage(),f=e.add(s.sample(n).mul(1/4),e.add(s.sample(c),s.sample(u),s.sample(h),s.sample(d)).mul(1/8),e.add(s.sample(l),s.sample(p),s.sample(v),s.sample(g)).mul(1/16));return e.mix(i.sample(n),f,this.blendAmount)}}const Je=(...r)=>new H(...r);function $(r){return(r instanceof m.NodeBuilder?r.renderer.backend:"backend"in r?r.backend:r).isWebGPUBackend===!0}class ce extends m.TempNode{constructor(t){super("vec4"),this.bloomIntensity=e.uniform(.05),this.inputNode=t,this.thresholdNode=new q,this.blurNode=new O,this.ghostNode=new ke,this.haloNode=new _e,this.bloomNode=new H(null,8),this.glareNode=new Ze,this.featuresNode=ue(e.add(this.ghostNode,this.haloNode)),this.featuresNode.value.name="LensFlareNode.Features",this.featuresNode.resolutionScale=.5,this.blurNode.resolutionScale=1,this.bloomNode.resolutionScale=1,this.glareNode.resolutionScale=1}static get type(){return"LensFlareNode"}setup(t){const{inputNode:s,thresholdNode:o,blurNode:i,ghostNode:n,haloNode:a,bloomNode:c,featuresNode:u,glareNode:h}=this;y.invariant(s!=null);const d=o.getTextureNode(),l=i.getTextureNode();o.inputNode=s,i.inputNode=d,n.inputNode=l,a.inputNode=l,c.inputNode=d,h.inputNode=d;const p=c.getTextureNode().mul(this.bloomIntensity),v=h.getTextureNode();return e.Fn(()=>{const g=s;return g.addAssign(p),$(t)&&g.addAssign(v),g.add(u)})()}dispose(){this.thresholdNode.dispose(),this.blurNode.dispose(),this.ghostNode.dispose(),this.haloNode.dispose(),this.bloomNode.dispose(),this.glareNode.dispose(),this.featuresNode.dispose(),super.dispose()}}const Ye=r=>new ce(r!=null?E(r,"LensFlareNode.Input"):null),Xe=R((r,t,s,o)=>{const i=r.sub(s),n=e.dot(t,i),a=e.dot(i,i).sub(o.pow2()),c=n.pow2().sub(a).toVar(),u=e.vec2(-1);return e.If(c.greaterThanEqual(0),()=>{const h=e.sqrt(c);u.assign(e.vec2(n.negate().sub(h),n.negate().add(h)))}),u}),le=e.struct({near:"vec4",far:"vec4"},"raySpheresIntersections"),et=R((r,t,s,o)=>{const i=r.sub(s),n=e.dot(t,i),a=e.dot(i,i).sub(o.pow2()),c=n.pow2().sub(a).toVar(),u=e.vec4(-1),h=e.vec4(-1);return e.If(c.greaterThanEqual(0),()=>{const d=e.sqrt(c);u.assign(n.negate().sub(d)),h.assign(n.negate().add(d))}),le(u,h)}),tt=R((r,t,s)=>{const o=r.div(s),i=t.div(s),n=i.dot(i),a=o.dot(i),c=o.dot(o),u=a.pow2().sub(n.mul(c.sub(1))).toVar(),h=e.vec2(-1);return e.If(u.greaterThanEqual(0),()=>{const d=e.sqrt(u);h.assign(e.vec2(a.negate().sub(d),a.negate().add(d)).div(n))}),h}),st={float:e.float,int:e.int,uint:e.uint,bool:e.bool,vec2:e.vec2,ivec2:e.ivec2,uvec2:e.uvec2,bvec2:e.bvec2,vec3:e.vec3,ivec3:e.ivec3,uvec3:e.uvec3,bvec3:e.bvec3,vec4:e.vec4,ivec4:e.ivec4,uvec4:e.uvec4,bvec4:e.bvec4,mat2:e.mat2,mat3:e.mat3,mat4:e.mat4,color:e.color},ot=m.Node;function rt(r){return st[r]}class de extends m.Texture3DNode{static get type(){return"OutputTexture3DNode"}constructor(t,s){super(s),this.owner=t,this.setUpdateMatrix(!1)}setup(t){return this.owner.build(t),super.setup(t)}clone(){return new this.constructor(this.owner,this.value)}}const it=(...r)=>new de(...r),nt=R((r,t)=>{const s=e.vec2(e.textureSize(r)),o=s.reciprocal(),i=t.mul(s),n=i.sub(.5).floor().add(.5),a=i.sub(n),c=a.mul(a.mul(a.mul(.5).oneMinus()).sub(.5)),u=a.mul(a).mul(a.mul(1.5).sub(2.5)).add(1),h=a.mul(a.mul(e.sub(2,a.mul(1.5))).add(.5)),d=a.mul(a).mul(a.mul(.5).sub(.5)),l=u.add(h),p=h.div(u.add(h)),v=n.sub(1).mul(o),g=n.add(2).mul(o),f=n.add(p).mul(o);return e.add(r.sample(e.vec2(v.x,v.y)).mul(c.x).mul(c.y),r.sample(e.vec2(f.x,v.y)).mul(l.x).mul(c.y),r.sample(e.vec2(g.x,v.y)).mul(d.x).mul(c.y),r.sample(e.vec2(v.x,f.y)).mul(c.x).mul(l.y),r.sample(e.vec2(f.x,f.y)).mul(l.x).mul(l.y),r.sample(e.vec2(g.x,f.y)).mul(d.x).mul(l.y),r.sample(e.vec2(v.x,g.y)).mul(c.x).mul(d.y),r.sample(e.vec2(f.x,g.y)).mul(l.x).mul(d.y),r.sample(e.vec2(g.x,g.y)).mul(d.x).mul(d.y))});function _(r,t){let s=1,o=0;for(;r>0;)s/=t,o+=s*(r%t),r=Math.floor(r/t);return o}const J=Array.from({length:16},(r,t)=>new x.Vector2(_(t+1,2),_(t+1,3))),he=(r,t,s,{perspective:o=!0,logarithmic:i=!1}={})=>i?e.logarithmicDepthToViewZ(r,t,s):o?e.perspectiveDepthToViewZ(r,t,s):e.orthographicDepthToViewZ(r,t,s),U=(r,t,s)=>{const o=e.logarithmicDepthToViewZ(r,t,s);return e.viewZToPerspectiveDepth(o,t,s)},at=(r,t,s)=>{const o=e.perspectiveDepthToViewZ(r,t,s);return e.viewZToLogarithmicDepth(o,t,s)},ut=(r,t,s,o,i)=>{const n=o.element(e.int(2)).element(e.int(3)),a=o.element(e.int(3)).element(e.int(3)),u=e.vec4(e.vec3(r.flipY(),t).mul(2).sub(1),1).mul(s.mul(n).add(a));return i.mul(u).xyz},Y=[e.vec3(58.1375,2.7747,26.8183),e.vec3(-150.5666,4.2109,-88.5066),e.vec3(130.5887,-14.0195,109.0745),e.vec3(-42.3277,4.8052,-60.1097),e.vec3(4.5974,2.1856,12.5925),e.vec3(.1357,.0914,.1067)],pe=r=>Y.slice(1).reduce((t,s)=>s.add(r.mul(t)),Y[0]),ct=(r,t,s,o)=>{const i=he(r,t,s,o);return pe(e.viewZToLogarithmicDepth(i,t,s))},lt=r=>{const t=e.sub(.5,r.x).mul(e.PI2),s=e.sub(r.y,.5).mul(e.PI),o=e.cos(s);return e.vec3(o.mul(e.cos(t)),e.sin(s),o.mul(e.sin(t)))},{resetRendererState:dt,restoreRendererState:ht}=m.RendererUtils;function pt(r){return r.isPerspectiveCamera===!0||r.isOrthographicCamera===!0||"updateProjectionMatrix"in r&&"setViewOffset"in r&&"clearViewOffset"in r}const mt=F({name:"clipAABB",type:"vec4",inputs:[{name:"current",type:"vec4"},{name:"history",type:"vec4"},{name:"minColor",type:"vec4"},{name:"maxColor",type:"vec4"}]})(([r,t,s,o])=>{const i=o.rgb.add(s.rgb).mul(.5),n=o.rgb.sub(s.rgb).mul(.5).add(1e-7),a=t.sub(e.vec4(i,r.a)),u=a.xyz.div(n).abs(),h=e.max(u.x,u.y,u.z);return e.select(h.greaterThan(1),e.vec4(i,r.a).add(a.div(h)),t)}),X=[e.ivec2(-1,-1),e.ivec2(-1,1),e.ivec2(1,-1),e.ivec2(1,1),e.ivec2(1,0),e.ivec2(0,-1),e.ivec2(0,1),e.ivec2(-1,0)],vt=R((r,t,s,o,i)=>{const n=s.toVar(),a=s.pow2().toVar();for(const p of X){const v=r.load(t.add(p));n.addAssign(v),a.addAssign(v.pow2())}const c=e.float(X.length+1),u=n.div(c),h=e.sqrt(a.div(c).sub(u.pow2()).max(0)).mul(i),d=u.sub(h),l=u.add(h);return mt(u.clamp(d,l),o,d,l)}),xt=[e.ivec2(-1,-1),e.ivec2(-1,0),e.ivec2(-1,1),e.ivec2(0,-1),e.ivec2(0,0),e.ivec2(0,1),e.ivec2(1,-1),e.ivec2(1,0),e.ivec2(1,1)],gt=e.struct({coord:"ivec2",depth:"float"}),ft=R((r,t)=>{const s=e.float(1),o=e.ivec2(0);for(const i of xt){const n=t.add(i).toVar(),a=r.load(n).toVar();e.If(a.r.lessThan(s),()=>{o.assign(n),s.assign(a.r)})}return gt(o,s)}),ee=new x.Vector2,yt=new x.DepthTexture(1,1);class me extends m.TempNode{constructor(t,s,o,i,n){if(super("vec4"),this.temporalAlpha=e.uniform(.05),this.varianceGamma=e.uniform(1),this.velocityThreshold=e.uniform(.1),this.depthError=e.uniform(.001),this.debugShowRejection=!1,this.resolveRT=this.createRenderTarget("Resolve"),this.historyRT=this.createRenderTarget("History"),this.resolveMaterial=new m.NodeMaterial,this.copyMaterial=new m.NodeMaterial,this.mesh=new m.QuadMesh,this.needsSyncPostProcessing=!1,this.needsClearHistory=!1,this.resolveNode=e.texture(this.resolveRT.texture),this.historyNode=e.texture(this.historyRT.texture),this.previousDepthNode=e.texture(yt),this.originalProjectionMatrix=new x.Matrix4,this.jitterIndex=0,this.velocityNodeImmutable=t,this.inputNode=s,this.depthNode=o,this.velocityNode=i,!pt(n))throw new Error("The provided camera is not supported.");this.camera=n,this.textureNode=G(this,this.resolveRT.texture),this.updateBeforeType=m.NodeUpdateType.FRAME}static get type(){return"TemporalAntialiasNode"}customCacheKey(){return te.hash(this.camera.id,+this.debugShowRejection)}createRenderTarget(t){const s=new x.RenderTarget(1,1,{depthBuffer:!1,type:x.HalfFloatType,format:x.RGBAFormat}),o=s.texture;o.minFilter=x.LinearFilter,o.magFilter=x.LinearFilter,o.generateMipmaps=!1;const i=this.constructor.type;return o.name=t!=null?`${i}.${t}`:i,s}getTextureNode(){return this.textureNode}setProjectionMatrix(t){const{velocityNodeImmutable:s}=this;s!=null&&(s.projectionMatrix=t)}setSize(t,s){const{resolveRT:o,historyRT:i}=this;return(t!==i.width||s!==i.height)&&(o.setSize(t,s),i.setSize(t,s),this.needsClearHistory=!0),this}clearHistory(t){t.setRenderTarget(this.resolveRT),t.clear(),t.setRenderTarget(this.historyRT),t.clear(),t.setRenderTarget(this.historyRT),this.mesh.material=this.copyMaterial,this.mesh.render(t),this.needsClearHistory=!1}setViewOffset(t,s){const{camera:o}=this;o.updateProjectionMatrix(),this.originalProjectionMatrix.copy(o.projectionMatrix),this.setProjectionMatrix(this.originalProjectionMatrix);const i=J[this.jitterIndex],n=i.x-.5,a=i.y-.5;o.setViewOffset(t,s,n,a,t,s)}clearViewOffset(){this.camera.clearViewOffset(),this.setProjectionMatrix(null),this.jitterIndex=(this.jitterIndex+1)%J.length}copyDepthTexture(t){const s=this.depthNode.value,o=this.previousDepthTexture??=s.clone();(o.image.width!==s.width||o.image.height!==s.height)&&(o.image.width=s.width,o.image.height=s.height,o.needsUpdate=!0),t.copyTextureToTexture(s,o),this.previousDepthNode.value=o}swapBuffers(){const{resolveRT:t,historyRT:s}=this;this.resolveRT=s,this.historyRT=t,this.resolveNode.value=s.texture,this.historyNode.value=t.texture,this.textureNode.value=t.texture}updateBefore({renderer:t}){if(t==null)return;const s=t.getDrawingBufferSize(ee);this.setSize(s.x,s.y),this.rendererState=dt(t,this.rendererState),this.needsClearHistory&&this.clearHistory(t),t.setRenderTarget(this.resolveRT),this.mesh.material=this.resolveMaterial,this.mesh.render(t),ht(t,this.rendererState),$(t)&&this.copyDepthTexture(t),this.swapBuffers(),this.needsSyncPostProcessing&&this.clearViewOffset()}setupResolveNode({renderer:t}){const s=o=>{const{previousDepthNode:i}=this,n=i.load(e.ivec2(o.mul(e.textureSize(i)).sub(.5))).toVar();return t.logarithmicDepthBuffer?U(n,A(this.camera),D(this.camera)):n};return e.Fn(()=>{const o=e.ivec2(e.screenCoordinate),i=e.screenUV,n=this.inputNode.load(o),a=ft(this.depthNode,o),c=a.get("coord"),u=this.velocityNode.load(c).xyz.mul(e.vec3(.5,-.5,.5)).toVar(),h=u.xy.length().div(this.velocityThreshold).oneMinus().saturate(),d=i.sub(u.xy).toVar(),l=s(d),p=t.logarithmicDepthBuffer?U(a.get("depth"),A(this.camera),D(this.camera)):a.get("depth"),v=e.step(p.add(u.z),l.add(this.depthError)),g=h.mul(v),f=e.and(d.greaterThanEqual(0).all(),d.lessThanEqual(1).all()).toFloat(),N=a.get("depth").notEqual(1).toFloat(),w=e.vec4(0).toVar();return e.If(f.mul(N).mul(g).greaterThan(0),()=>{const M=e.texture(this.historyNode,d),B=vt(this.inputNode,o,n,M,this.varianceGamma),V=u.xy.abs().mul(e.screenSize),z=e.max(V.x,V.y).fract().mul(.5),T=e.mix(this.temporalAlpha,.8,z).saturate();w.assign(e.mix(B,n,T))}).Else(()=>{w.assign(n),this.debugShowRejection&&w.assign(e.vec3(1,0,0))}),w})()}setup(t){const{context:s}=t.getContext().postProcessing??{};if(s!=null){const{onBeforePostProcessing:n}=s;s.onBeforePostProcessing=()=>{n?.();const a=t.renderer.getDrawingBufferSize(ee);this.setViewOffset(a.width,a.height)},this.needsSyncPostProcessing=!0}const{resolveMaterial:o,copyMaterial:i}=this;return o.fragmentNode=this.setupResolveNode(t),o.needsUpdate=!0,i.fragmentNode=this.inputNode,i.needsUpdate=!0,this.textureNode.uvNode=this.inputNode.uvNode,this.textureNode}dispose(){this.resolveRT.dispose(),this.historyRT.dispose(),this.previousDepthTexture?.dispose(),this.resolveMaterial.dispose(),this.copyMaterial.dispose(),this.mesh.geometry.dispose(),super.dispose()}}const wt=r=>(t,s,o,i)=>new me(r,E(t,"TemporalAntialiasNode.Input"),s,o,i);exports.DownsampleThresholdNode=q;exports.FnLayout=F;exports.FnVar=R;exports.GaussianBlurNode=O;exports.HighpVelocityNode=ne;exports.KawaseBlurNode=ae;exports.LensFlareNode=ce;exports.MipmapBlurNode=re;exports.MipmapSurfaceBlurNode=H;exports.Node=ot;exports.OutputTexture3DNode=de;exports.OutputTextureNode=se;exports.RTTextureNode=W;exports.TemporalAntialiasNode=me;exports.cameraFar=D;exports.cameraNear=A;exports.cameraPositionWorld=ye;exports.convertToTexture=E;exports.debugFragmentNode=we;exports.debugNode=Ne;exports.debugVertexNode=Te;exports.depthToColor=ct;exports.depthToViewZ=he;exports.dithering=Ie;exports.downsampleThreshold=Fe;exports.equirectGrid=je;exports.equirectToDirectionWorld=lt;exports.gaussianBlur=Ue;exports.highpVelocity=Ge;exports.hookFunction=Se;exports.interleavedGradientNoise=ie;exports.inverseProjectionMatrix=ge;exports.inverseViewMatrix=fe;exports.isWebGPU=$;exports.kawaseBlur=Le;exports.lensFlare=Ye;exports.logarithmicToPerspectiveDepth=U;exports.mipmapBlur=Re;exports.mipmapBlurDownsample=k;exports.mipmapBlurUpsample=oe;exports.mipmapSurfaceBlur=Je;exports.node=rt;exports.outputTexture=G;exports.outputTexture3D=it;exports.perspectiveToLogarithmicDepth=at;exports.projectionMatrix=ve;exports.rayEllipsoidIntersection=tt;exports.raySphereIntersection=Xe;exports.raySpheresIntersections=et;exports.raySpheresIntersectionsStruct=le;exports.rtTexture=ue;exports.screenToPositionView=ut;exports.temporalAntialias=wt;exports.textureCatmullRom=nt;exports.turbo=pe;exports.viewMatrix=xe;
2
2
  //# sourceMappingURL=webgpu.cjs.map