@takram/three-geospatial 0.8.0 → 0.9.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 (62) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/build/index.cjs +1 -1
  3. package/build/index.cjs.map +1 -1
  4. package/build/index.js +580 -598
  5. package/build/index.js.map +1 -1
  6. package/build/r3f.cjs +1 -1
  7. package/build/r3f.js +1 -1
  8. package/build/shared2.cjs +1 -1
  9. package/build/shared2.cjs.map +1 -1
  10. package/build/shared2.js +27 -212
  11. package/build/shared2.js.map +1 -1
  12. package/build/shared3.cjs +1 -1
  13. package/build/shared3.cjs.map +1 -1
  14. package/build/shared3.js +213 -8
  15. package/build/shared3.js.map +1 -1
  16. package/build/webgpu.cjs +6 -1
  17. package/build/webgpu.cjs.map +1 -1
  18. package/build/webgpu.js +993 -807
  19. package/build/webgpu.js.map +1 -1
  20. package/package.json +1 -1
  21. package/src/PointOfView.ts +12 -5
  22. package/src/STBNLoader.ts +41 -19
  23. package/src/webgpu/CascadedShadowMapsNode.ts +48 -0
  24. package/src/webgpu/DualMipmapFilterNode.ts +8 -4
  25. package/src/webgpu/FilterNode.ts +3 -2
  26. package/src/webgpu/FnLayout.ts +17 -16
  27. package/src/webgpu/HighpVelocityNode.ts +2 -2
  28. package/src/webgpu/LensFlareNode.ts +1 -1
  29. package/src/webgpu/LensGlareNode.ts +26 -26
  30. package/src/webgpu/LensHaloNode.ts +2 -1
  31. package/src/webgpu/STBNTextureNode.ts +58 -0
  32. package/src/webgpu/ScreenSpaceShadowNode.ts +30 -35
  33. package/src/webgpu/SeparableFilterNode.ts +8 -5
  34. package/src/webgpu/SingleFilterNode.ts +5 -2
  35. package/src/webgpu/StorageTexture3DNode.ts +30 -0
  36. package/src/webgpu/TemporalAntialiasNode.ts +50 -31
  37. package/src/webgpu/accessors.ts +75 -36
  38. package/src/webgpu/debug.ts +38 -47
  39. package/src/webgpu/events.ts +18 -0
  40. package/src/webgpu/index.ts +4 -0
  41. package/src/webgpu/math.ts +116 -15
  42. package/src/webgpu/sampling.ts +39 -5
  43. package/src/webgpu/transformations.ts +71 -44
  44. package/types/PointOfView.d.ts +1 -1
  45. package/types/STBNLoader.d.ts +3 -4
  46. package/types/webgpu/CascadedShadowMapsNode.d.ts +13 -0
  47. package/types/webgpu/DualMipmapFilterNode.d.ts +1 -2
  48. package/types/webgpu/FnLayout.d.ts +4 -4
  49. package/types/webgpu/LensGlareNode.d.ts +1 -1
  50. package/types/webgpu/STBNTextureNode.d.ts +9 -0
  51. package/types/webgpu/ScreenSpaceShadowNode.d.ts +2 -4
  52. package/types/webgpu/SeparableFilterNode.d.ts +2 -3
  53. package/types/webgpu/SingleFilterNode.d.ts +1 -2
  54. package/types/webgpu/StorageTexture3DNode.d.ts +9 -0
  55. package/types/webgpu/TemporalAntialiasNode.d.ts +1 -1
  56. package/types/webgpu/accessors.d.ts +9 -8
  57. package/types/webgpu/debug.d.ts +4 -3
  58. package/types/webgpu/events.d.ts +3 -0
  59. package/types/webgpu/index.d.ts +4 -0
  60. package/types/webgpu/math.d.ts +3 -0
  61. package/types/webgpu/sampling.d.ts +2 -1
  62. package/types/webgpu/transformations.d.ts +7 -10
package/build/webgpu.js CHANGED
@@ -1,82 +1,181 @@
1
- import { Vector3 as tt, Mesh as Te, Scene as zt, Camera as Ct, RenderTarget as st, RGBAFormat as ot, HalfFloatType as nt, LinearFilter as ae, Vector2 as P, Matrix4 as ne, AdditiveBlending as Rt, PlaneGeometry as Dt, PerspectiveCamera as Vt, SRGBColorSpace as Bt, CanvasTexture as At, Vector4 as it, NoColorSpace as Pt, DepthTexture as Ft } from "three";
2
- import { reference as ce, uniform as g, vec4 as b, positionGeometry as rt, texture as ie, uv as q, vec2 as f, add as D, luminance as jt, smoothstep as at, Fn as k, screenCoordinate as ut, time as kt, vec3 as N, equirectUV as Ot, fwidth as Ut, abs as X, positionLocal as It, positionPrevious as Et, sub as ue, nodeImmutable as Lt, instancedArray as Le, storage as Wt, uvec2 as lt, If as K, globalId as Ce, Return as Gt, atomicAdd as qt, instanceIndex as Ht, mat3 as ct, struct as Pe, min as ht, mul as $t, fract as Yt, distance as Xt, mix as re, rtt as Zt, convertToTexture as De, sqrt as Se, dot as ye, color as Qt, mat4 as Kt, mat2 as _t, bvec4 as Jt, uvec4 as es, ivec4 as ts, bvec3 as ss, uvec3 as os, ivec3 as ns, bvec2 as is, ivec2 as j, bool as rs, uint as as, int as Z, float as pe, textureSize as ve, viewZToLogarithmicDepth as dt, logarithmicDepthToViewZ as pt, perspectiveDepthToViewZ as mt, orthographicDepthToViewZ as us, PI2 as ls, PI as cs, cos as We, sin as Ge, viewZToPerspectiveDepth as hs, workgroupArray as ds, greaterThan as ps, invocationLocalIndex as xe, workgroupBarrier as ms, textureStore as fs, workgroupId as qe, and as ft, screenUV as xs, step as gs, max as xt, select as ys } from "three/tsl";
3
- import { NodeMaterial as le, TextureNode as vs, TempNode as _, NodeUpdateType as Q, RendererUtils as me, QuadMesh as Ne, StorageBufferAttribute as ws, MeshBasicNodeMaterial as Ts, NodeBuilder as Ss, Node as Ns, Texture3DNode as Ms, StorageTexture as bs } from "three/webgpu";
4
- import { Q as Fe } from "./shared3.js";
5
- import { i as w } from "./shared.js";
6
- import { hash as je } from "three/src/nodes/core/NodeUtils.js";
7
- let Re;
8
- function J(n, e, t) {
9
- Re ??= /* @__PURE__ */ new WeakMap();
10
- let s = Re.get(n);
11
- return s == null && (s = {}, Re.set(n, s)), s[e] ??= t();
1
+ import { Fn as U, logarithmicDepthToViewZ as ct, perspectiveDepthToViewZ as ut, orthographicDepthToViewZ as Et, viewZToLogarithmicDepth as lt, sub as ie, PI2 as kt, PI as It, cos as Xe, vec3 as M, sin as Ze, viewZToPerspectiveDepth as Lt, int as K, vec4 as z, cameraNear as je, cameraFar as Ee, depth as Wt, cameraPosition as $t, cameraProjectionMatrixInverse as qt, cameraWorldMatrix as Gt, cameraProjectionMatrix as Ht, cameraViewMatrix as Yt, uniform as g, reference as le, positionGeometry as ht, texture as oe, uv as I, vec2 as f, add as B, luminance as Xt, smoothstep as dt, OnBeforeObjectUpdate as Zt, OnObjectUpdate as _t, screenCoordinate as ke, time as Kt, equirectUV as Qt, fwidth as Jt, abs as _, positionLocal as es, positionPrevious as ts, nodeImmutable as pt, instancedArray as _e, storage as ss, uvec2 as re, If as ae, globalId as Ae, Return as os, atomicAdd as ns, instanceIndex as is, mat3 as mt, struct as Ie, min as ft, mul as rs, fract as as, distance as cs, mix as ne, rtt as us, convertToTexture as Oe, overloadingFn as Le, sqrt as be, dot as Ne, bvec2 as xt, bvec3 as gt, uvec3 as pe, bvec4 as vt, uvec4 as me, bool as Me, color as ls, mat4 as hs, mat2 as ds, ivec4 as yt, ivec3 as ps, ivec2 as O, uint as ms, float as G, workgroupArray as fs, greaterThan as xs, invocationLocalIndex as we, workgroupBarrier as gs, textureStore as vs, workgroupId as Ke, and as wt, frameId as ys, screenUV as ws, step as Ts, textureSize as Ns, max as Tt } from "three/tsl";
2
+ import { StructTypeNode as Ss, NodeMaterial as ce, TextureNode as bs, TempNode as Q, NodeUpdateType as H, RendererUtils as ge, QuadMesh as ze, IndirectStorageBufferAttribute as Ms, MeshBasicNodeMaterial as zs, NodeBuilder as Cs, Node as Rs, Texture3DNode as Nt, StorageTexture as Ds, Data3DTexture as Bs, RedFormat as As, NearestFilter as Qe, RepeatWrapping as Ve, StorageTextureNode as Vs } from "three/webgpu";
3
+ import { Vector3 as St, Plane as Ps, Mesh as bt, Scene as Fs, Camera as Os, RenderTarget as Mt, RGBAFormat as zt, HalfFloatType as Ct, LinearFilter as ue, Matrix4 as Se, Vector2 as ve, AdditiveBlending as Us, PlaneGeometry as js, PerspectiveCamera as Es, SRGBColorSpace as ks, CanvasTexture as Is, NoColorSpace as Ls, Vector4 as Ws, DepthTexture as $s } from "three";
4
+ import { CSMShadowNode as qs } from "three/examples/jsm/csm/CSMShadowNode.js";
5
+ import { Q as Gs, D as Hs, S as Ys } from "./shared2.js";
6
+ import { i as y } from "./shared.js";
7
+ import { hash as We, hashString as Xs } from "three/src/nodes/core/NodeUtils.js";
8
+ function Je(s) {
9
+ if (typeof s == "string")
10
+ return s;
11
+ if ("layout" in s && s.layout instanceof Ss) {
12
+ if (s.layout.name == null)
13
+ throw new Error("Struct name is required.");
14
+ return s.layout.name;
15
+ }
16
+ throw new Error(`Unsupported layout type: ${s}`);
12
17
  }
13
- const No = (n) => J(
14
- n,
18
+ function V({
19
+ typeOnly: s = !1,
20
+ ...e
21
+ }) {
22
+ return s ? (t) => U(t) : (t) => U(t).setLayout({
23
+ ...e,
24
+ type: Je(e.type),
25
+ inputs: e.inputs?.map((o) => ({
26
+ ...o,
27
+ type: Je(o.type)
28
+ })) ?? []
29
+ });
30
+ }
31
+ function L(s) {
32
+ return U((e, t) => {
33
+ const o = s(...e);
34
+ return typeof o == "function" ? o(t) : o;
35
+ });
36
+ }
37
+ const Rt = /* @__PURE__ */ L(
38
+ (s, e, t, o) => (n) => {
39
+ t ??= fe(e), o ??= xe(e);
40
+ const i = e?.isPerspectiveCamera === !0;
41
+ return n.renderer.logarithmicDepthBuffer ? ct(s, t, o) : i ? ut(s, t, o) : Et(s, t, o);
42
+ }
43
+ ), Ue = (s, e, t) => {
44
+ e ??= je, t ??= Ee;
45
+ const o = ct(s, e, t);
46
+ return Lt(o, e, t);
47
+ }, un = (s, e, t) => {
48
+ e ??= je, t ??= Ee;
49
+ const o = ut(s, e, t);
50
+ return lt(o, e, t);
51
+ }, ln = (s, e, t, o, n) => {
52
+ const i = o.element(K(2)).element(K(3)), r = o.element(K(3)).element(K(3)), a = z(M(s.flipY(), e).mul(2).sub(1), 1).mul(t.mul(i).add(r));
53
+ return n.mul(a).xyz;
54
+ }, Pe = [
55
+ [58.1375, 2.7747, 26.8183],
56
+ [-150.5666, 4.2109, -88.5066],
57
+ [130.5887, -14.0195, 109.0745],
58
+ [-42.3277, 4.8052, -60.1097],
59
+ [4.5974, 2.1856, 12.5925],
60
+ [0.1357, 0.0914, 0.1067]
61
+ ], Zs = /* @__PURE__ */ V({
62
+ name: "turbo",
63
+ type: "vec3",
64
+ inputs: [{ name: "x", type: "float" }]
65
+ })(([s]) => {
66
+ const e = M(...Pe[0]).toVar();
67
+ for (let t = 1; t < Pe.length; ++t)
68
+ e.assign(M(...Pe[t]).add(s.mul(e)));
69
+ return e;
70
+ }), hn = L(
71
+ (s, e, t, o) => {
72
+ t ??= fe(e), o ??= xe(e);
73
+ const n = Rt(s, e, t, o);
74
+ return Zs(lt(n, t, o));
75
+ }
76
+ ), dn = /* @__PURE__ */ V({
77
+ name: "equirectToDirectionWorld",
78
+ type: "vec3",
79
+ inputs: [{ name: "uv", type: "vec2" }]
80
+ })(([s]) => {
81
+ const e = ie(0.5, s.x).mul(kt), t = ie(s.y, 0.5).mul(It), o = Xe(t);
82
+ return M(o.mul(Xe(e)), Ze(t), o.mul(Ze(e)));
83
+ });
84
+ let Fe;
85
+ function J(s, e, t) {
86
+ Fe ??= /* @__PURE__ */ new WeakMap();
87
+ let o = Fe.get(s);
88
+ return o == null && (o = {}, Fe.set(s, o)), o[e] ??= t();
89
+ }
90
+ const pn = (s) => s != null ? J(
91
+ s,
15
92
  "projectionMatrix",
16
- () => ce("projectionMatrix", "mat4", n).setName("projectionMatrix")
17
- ), Mo = (n) => J(
18
- n,
93
+ () => le("projectionMatrix", "mat4", s).setName(
94
+ "projectionMatrix"
95
+ )
96
+ ) : Ht, mn = (s) => s != null ? J(
97
+ s,
19
98
  "viewMatrix",
20
- () => ce("matrixWorldInverse", "mat4", n).setName("viewMatrix")
21
- ), bo = (n) => J(
22
- n,
99
+ () => le("matrixWorldInverse", "mat4", s).setName("viewMatrix")
100
+ ) : Yt, fn = (s) => s != null ? J(
101
+ s,
23
102
  "inverseProjectionMatrix",
24
- () => ce("projectionMatrixInverse", "mat4", n).setName(
103
+ () => le("projectionMatrixInverse", "mat4", s).setName(
25
104
  "inverseProjectionMatrix"
26
105
  )
27
- ), zo = (n) => J(
28
- n,
106
+ ) : qt, xn = (s) => s != null ? J(
107
+ s,
29
108
  "inverseViewMatrix",
30
- () => ce("matrixWorld", "mat4", n).setName("inverseViewMatrix")
31
- ), Co = (n) => J(
32
- n,
109
+ () => le("matrixWorld", "mat4", s).setName("inverseViewMatrix")
110
+ ) : Gt, gn = (s) => s != null ? J(
111
+ s,
33
112
  "cameraPositionWorld",
34
- () => g(new tt()).setName("cameraPositionWorld").onRenderUpdate((e, { value: t }) => {
35
- t.setFromMatrixPosition(n.matrixWorld);
113
+ () => g("vec3").setName("cameraPositionWorld").onRenderUpdate((e, { value: t }) => {
114
+ t.setFromMatrixPosition(s.matrixWorld);
36
115
  })
37
- ), Ve = (n) => J(
38
- n,
116
+ ) : $t, fe = (s) => s != null ? J(
117
+ s,
39
118
  "cameraNear",
40
- () => ce("near", "float", n).setName("cameraNear")
41
- ), Be = (n) => J(
42
- n,
119
+ () => le("near", "float", s).setName("cameraNear")
120
+ ) : je, xe = (s) => s != null ? J(
121
+ s,
43
122
  "cameraFar",
44
- () => ce("far", "float", n).setName("cameraFar")
45
- );
46
- async function ke(n, e) {
47
- return await n.debug.getShaderAsync(new zt(), new Ct(), e).then((t) => t).catch((t) => (console.error(t), { fragmentShader: null, vertexShader: null }));
123
+ () => le("far", "float", s).setName("cameraFar")
124
+ ) : Ee, vn = U(
125
+ ({ camera: s }) => Rt(Wt, s)
126
+ ).once()().toVar("viewZ"), _s = /* @__PURE__ */ new St(), Ks = /* @__PURE__ */ new Ps();
127
+ class yn extends qs {
128
+ updateBefore(e) {
129
+ super.updateBefore(e);
130
+ const { lights: t } = this;
131
+ if (t.length < 2)
132
+ return;
133
+ const o = t[t.length - 1], n = _s.subVectors(o.target.position, o.position).normalize(), i = Ks.setFromNormalAndCoplanarPoint(
134
+ n,
135
+ o.position
136
+ );
137
+ for (let r = 0; r < t.length - 1; ++r) {
138
+ const c = t[r];
139
+ i.projectPoint(c.position, c.position), c.target.position.copy(c.position).add(n);
140
+ }
141
+ }
48
142
  }
49
- function Ro(n, e) {
50
- const t = new Te(new Fe(), e);
51
- ke(n, t).then((s) => {
52
- console.log(s.fragmentShader);
53
- }).finally(() => {
143
+ async function Ce(s, e) {
144
+ const t = new bt(new Gs(), e);
145
+ try {
146
+ return await s.debug.getShaderAsync(new Fs(), new Os(), t);
147
+ } catch (o) {
148
+ return console.error(o), { vertexShader: null, fragmentShader: null };
149
+ } finally {
54
150
  t.geometry.dispose();
55
- });
151
+ }
56
152
  }
57
- function Do(n, e) {
58
- const t = new Te(new Fe(), e);
59
- ke(n, t).then((s) => {
60
- console.log(s.vertexShader);
61
- }).finally(() => {
62
- t.geometry.dispose();
63
- });
153
+ async function wn(s, e) {
154
+ const { vertexShader: t, fragmentShader: o } = await Ce(s, e);
155
+ return t != null && o != null ? `// Vertex shader
156
+
157
+ ${t}
158
+ // Fragment shader
159
+
160
+ ${o}` : null;
64
161
  }
65
- function Vo(n, e) {
66
- const t = new le();
67
- t.vertexNode = b(rt.xy, 0, 1), t.fragmentNode = e;
68
- const s = new Te(new Fe(), t);
69
- ke(n, s).then((o) => {
70
- console.log(o.fragmentShader);
71
- }).finally(() => {
72
- t.dispose(), s.geometry.dispose();
73
- });
162
+ async function Tn(s, e) {
163
+ return (await Ce(s, e)).vertexShader;
74
164
  }
75
- function Bo(n, e, t) {
76
- const s = n[e];
77
- return n[e] = ((...o) => (t(...o), s.apply(n, o))), n;
165
+ async function Nn(s, e) {
166
+ return (await Ce(s, e)).fragmentShader;
78
167
  }
79
- class zs extends vs {
168
+ async function Sn(s, e) {
169
+ const t = new ce();
170
+ t.vertexNode = z(ht.xy, 0, 1), t.fragmentNode = e.toConst("debugNode");
171
+ const o = await Ce(s, t);
172
+ return t.dispose(), o.fragmentShader;
173
+ }
174
+ function bn(s, e, t) {
175
+ const o = s[e];
176
+ return s[e] = ((...n) => (t(...n), o.apply(s, n))), s;
177
+ }
178
+ class Qs extends bs {
80
179
  static get type() {
81
180
  return "OutputTextureNode";
82
181
  }
@@ -90,26 +189,26 @@ class zs extends vs {
90
189
  return new this.constructor(this.owner, this.value);
91
190
  }
92
191
  }
93
- const Oe = (...n) => new zs(...n);
94
- class Me extends _ {
192
+ const $e = (...s) => new Qs(...s);
193
+ class Re extends Q {
95
194
  constructor(e) {
96
- super("vec4"), this.resolutionScale = 1, this.renderTargets = [], this.inputNode = e, this.updateBeforeType = Q.FRAME;
195
+ super("vec4"), this.resolutionScale = 1, this.renderTargets = [], this.updateBeforeType = H.FRAME, this.inputNode = e;
97
196
  }
98
197
  static get type() {
99
198
  return "FilterNode";
100
199
  }
101
200
  createRenderTarget(e) {
102
- const t = new st(1, 1, {
201
+ const t = new Mt(1, 1, {
103
202
  depthBuffer: !1,
104
- type: nt,
105
- format: ot
106
- }), s = t.texture;
107
- s.minFilter = ae, s.magFilter = ae, s.generateMipmaps = !1;
108
- const o = this.constructor.type;
109
- return s.name = e != null ? `${o}.${e}` : o, this.renderTargets.push(t), t;
203
+ type: Ct,
204
+ format: zt
205
+ }), o = t.texture;
206
+ o.minFilter = ue, o.magFilter = ue, o.generateMipmaps = !1;
207
+ const n = this.constructor.type;
208
+ return o.name = e != null ? `${n}_${e}` : n, this.renderTargets.push(t), t;
110
209
  }
111
210
  getTextureNode() {
112
- return w(
211
+ return y(
113
212
  this.textureNode != null,
114
213
  "outputTexture must be specified before getTextureNode() is called."
115
214
  ), this.textureNode;
@@ -118,17 +217,17 @@ class Me extends _ {
118
217
  return this.textureNode?.value ?? null;
119
218
  }
120
219
  set outputTexture(e) {
121
- this.textureNode = e != null ? Oe(this, e) : void 0;
220
+ this.textureNode = e != null ? $e(this, e) : void 0;
122
221
  }
123
222
  setup(e) {
124
- const { inputNode: t, textureNode: s } = this;
125
- return w(
223
+ const { inputNode: t, textureNode: o } = this;
224
+ return y(
126
225
  t != null,
127
226
  "inputNode must be specified before being setup."
128
- ), w(
129
- s != null,
227
+ ), y(
228
+ o != null,
130
229
  "outputTexture must be specified before being setup."
131
- ), s.uvNode = t.uvNode, s;
230
+ ), o.uvNode = t.uvNode, o;
132
231
  }
133
232
  dispose() {
134
233
  for (const e of this.renderTargets)
@@ -136,20 +235,22 @@ class Me extends _ {
136
235
  super.dispose();
137
236
  }
138
237
  }
139
- const { resetRendererState: Cs, restoreRendererState: Rs } = me;
140
- class Ue extends Me {
238
+ const { resetRendererState: Js, restoreRendererState: eo } = ge;
239
+ class qe extends Re {
141
240
  constructor(e, t) {
142
- super(e), this.downsampleRTs = [], this.upsampleRTs = [], this.downsampleMaterial = new le(), this.upsampleMaterial = new le(), this.mesh = new Ne(), this.inputTexelSize = g(new P()), this.downsampleNode = ie();
143
- for (let s = 0; s < t; ++s)
144
- this.downsampleRTs[s] = this.createRenderTarget(`Downsample${s}`), s < t - 1 && (this.upsampleRTs[s] = this.createRenderTarget(`Upsample${s}`));
241
+ super(e), this.downsampleRTs = [], this.upsampleRTs = [], this.downsampleMaterial = new ce(), this.upsampleMaterial = new ce(), this.mesh = new ze(), this.inputTexelSize = g("vec2"), this.downsampleNode = oe();
242
+ const o = this.constructor.type.replace(/Node$/, "");
243
+ this.downsampleMaterial.name = `${o}_downsample`, this.upsampleMaterial.name = `${o}_upsample`, this.mesh.name = o;
244
+ for (let n = 0; n < t; ++n)
245
+ this.downsampleRTs[n] = this.createRenderTarget(`downsample${n}`), n < t - 1 && (this.upsampleRTs[n] = this.createRenderTarget(`upsample${n}`));
145
246
  this.outputTexture = this.upsampleRTs[0].texture;
146
247
  }
147
248
  setSize(e, t) {
148
- const { resolutionScale: s } = this;
149
- let o = Math.max(Math.round(e * s), 1), i = Math.max(Math.round(t * s), 1);
150
- const { downsampleRTs: r, upsampleRTs: u } = this;
249
+ const { resolutionScale: o } = this;
250
+ let n = Math.max(Math.round(e * o), 1), i = Math.max(Math.round(t * o), 1);
251
+ const { downsampleRTs: r, upsampleRTs: c } = this;
151
252
  for (let a = 0; a < r.length; ++a)
152
- o = Math.max(Math.round(o / 2), 1), i = Math.max(Math.round(i / 2), 1), r[a].setSize(o, i), a < u.length && u[a].setSize(o, i);
253
+ n = Math.max(Math.round(n / 2), 1), i = Math.max(Math.round(i / 2), 1), r[a].setSize(n, i), a < c.length && c[a].setSize(n, i);
153
254
  return this;
154
255
  }
155
256
  updateBefore({ renderer: e }) {
@@ -157,33 +258,33 @@ class Ue extends Me {
157
258
  return;
158
259
  const {
159
260
  downsampleRTs: t,
160
- upsampleRTs: s,
161
- mesh: o,
261
+ upsampleRTs: o,
262
+ mesh: n,
162
263
  inputNode: i,
163
264
  inputTexelSize: r,
164
- downsampleNode: u
265
+ downsampleNode: c
165
266
  } = this;
166
- w(i != null);
167
- const { width: a, height: l } = i.value;
168
- this.setSize(a, l);
169
- const c = i.value;
170
- this.rendererState = Cs(e, this.rendererState), o.material = this.downsampleMaterial;
171
- for (const h of t) {
267
+ y(i != null);
268
+ const { width: a, height: h } = i.value;
269
+ this.setSize(a, h);
270
+ const l = i.value;
271
+ this.rendererState = Js(e, this.rendererState), n.material = this.downsampleMaterial;
272
+ for (const u of t) {
172
273
  const { width: p, height: d } = i.value;
173
- r.value.set(1 / p, 1 / d), e.setRenderTarget(h), o.render(e), i.value = h.texture;
274
+ r.value.set(1 / p, 1 / d), e.setRenderTarget(u), n.render(e), i.value = u.texture;
174
275
  }
175
- o.material = this.upsampleMaterial;
176
- for (let h = s.length - 1; h >= 0; --h) {
177
- const p = s[h], { width: d, height: m } = i.value;
178
- r.value.set(1 / d, 1 / m), u.value = t[h].texture, e.setRenderTarget(p), o.render(e), i.value = p.texture;
276
+ n.material = this.upsampleMaterial;
277
+ for (let u = o.length - 1; u >= 0; --u) {
278
+ const p = o[u], { width: d, height: m } = i.value;
279
+ r.value.set(1 / d, 1 / m), c.value = t[u].texture, e.setRenderTarget(p), n.render(e), i.value = p.texture;
179
280
  }
180
- Rs(e, this.rendererState), i.value = c;
281
+ eo(e, this.rendererState), i.value = l;
181
282
  }
182
283
  setup(e) {
183
284
  const { inputNode: t } = this;
184
- w(t != null);
185
- const { downsampleMaterial: s, upsampleMaterial: o } = this;
186
- return s.fragmentNode = this.setupDownsampleNode(e), o.fragmentNode = this.setupUpsampleNode(e), s.needsUpdate = !0, o.needsUpdate = !0, super.setup(e);
285
+ y(t != null);
286
+ const { downsampleMaterial: o, upsampleMaterial: n } = this;
287
+ return o.fragmentNode = this.setupDownsampleNode(e), n.fragmentNode = this.setupUpsampleNode(e), o.needsUpdate = !0, n.needsUpdate = !0, super.setup(e);
187
288
  }
188
289
  dispose() {
189
290
  for (const e of this.downsampleRTs)
@@ -193,48 +294,48 @@ class Ue extends Me {
193
294
  this.downsampleMaterial.dispose(), this.upsampleMaterial.dispose(), this.mesh.geometry.dispose(), super.dispose();
194
295
  }
195
296
  }
196
- const gt = (n, e) => {
197
- const t = q(), s = b(1, 1, -1, -1).mul(e.xyxy).add(t.xyxy).toVertexStage(), o = b(2, 2, -2, -2).mul(e.xyxy).add(t.xyxy).toVertexStage(), i = s.zy, r = s.xy, u = s.zw, a = s.xw, l = f(t.x, o.y), c = f(o.z, t.y), h = f(o.x, t.y), p = f(t.x, o.w), d = o.zy, m = o.xy, x = o.zw, z = o.xw;
198
- return D(
199
- D(
200
- n.sample(t),
201
- n.sample(i),
202
- n.sample(r),
203
- n.sample(u),
204
- n.sample(a)
297
+ const Dt = (s, e) => {
298
+ const t = I(), o = z(1, 1, -1, -1).mul(e.xyxy).add(t.xyxy).toVertexStage(), n = z(2, 2, -2, -2).mul(e.xyxy).add(t.xyxy).toVertexStage(), i = o.zy, r = o.xy, c = o.zw, a = o.xw, h = f(t.x, n.y), l = f(n.z, t.y), u = f(n.x, t.y), p = f(t.x, n.w), d = n.zy, m = n.xy, x = n.zw, w = n.xw;
299
+ return B(
300
+ B(
301
+ s.sample(t),
302
+ s.sample(i),
303
+ s.sample(r),
304
+ s.sample(c),
305
+ s.sample(a)
205
306
  ).mul(1 / 8),
206
- D(
207
- n.sample(l),
208
- n.sample(c),
209
- n.sample(h),
210
- n.sample(p)
307
+ B(
308
+ s.sample(h),
309
+ s.sample(l),
310
+ s.sample(u),
311
+ s.sample(p)
211
312
  ).mul(1 / 16),
212
- D(
213
- n.sample(d),
214
- n.sample(m),
215
- n.sample(x),
216
- n.sample(z)
313
+ B(
314
+ s.sample(d),
315
+ s.sample(m),
316
+ s.sample(x),
317
+ s.sample(w)
217
318
  ).mul(1 / 32)
218
319
  );
219
- }, Ds = (n, e) => {
220
- const t = q(), s = b(1, 1, -1, -1).mul(e.xyxy).add(t.xyxy).toVertexStage(), o = f(t.x, s.y), i = f(s.z, t.y), r = f(s.x, t.y), u = f(t.x, s.w), a = s.zy, l = s.xy, c = s.zw, h = s.xw;
221
- return D(
222
- n.sample(t).mul(0.25),
223
- D(
224
- n.sample(o),
225
- n.sample(i),
226
- n.sample(r),
227
- n.sample(u)
320
+ }, to = (s, e) => {
321
+ const t = I(), o = z(1, 1, -1, -1).mul(e.xyxy).add(t.xyxy).toVertexStage(), n = f(t.x, o.y), i = f(o.z, t.y), r = f(o.x, t.y), c = f(t.x, o.w), a = o.zy, h = o.xy, l = o.zw, u = o.xw;
322
+ return B(
323
+ s.sample(t).mul(0.25),
324
+ B(
325
+ s.sample(n),
326
+ s.sample(i),
327
+ s.sample(r),
328
+ s.sample(c)
228
329
  ).mul(0.125),
229
- D(
230
- n.sample(a),
231
- n.sample(l),
232
- n.sample(c),
233
- n.sample(h)
330
+ B(
331
+ s.sample(a),
332
+ s.sample(h),
333
+ s.sample(l),
334
+ s.sample(u)
234
335
  ).mul(0.0625)
235
336
  );
236
337
  };
237
- class Vs extends Ue {
338
+ class so extends qe {
238
339
  static get type() {
239
340
  return "MipmapBlurNode";
240
341
  }
@@ -242,40 +343,42 @@ class Vs extends Ue {
242
343
  super(e, t), this.resolutionScale = 0.5;
243
344
  }
244
345
  setupDownsampleNode(e) {
245
- return w(this.inputNode != null), gt(this.inputNode, this.inputTexelSize);
346
+ return y(this.inputNode != null), Dt(this.inputNode, this.inputTexelSize);
246
347
  }
247
348
  setupUpsampleNode(e) {
248
- return w(this.inputNode != null), Ds(this.inputNode, this.inputTexelSize);
349
+ return y(this.inputNode != null), to(this.inputNode, this.inputTexelSize);
249
350
  }
250
351
  }
251
- const Ao = (...n) => new Vs(...n), { resetRendererState: Bs, restoreRendererState: As } = me;
252
- class Ps extends Me {
352
+ const Mn = (...s) => new so(...s), { resetRendererState: oo, restoreRendererState: no } = ge;
353
+ class io extends Re {
253
354
  constructor(e) {
254
- super(e), this.material = new le(), this.mesh = new Ne(this.material), this.inputTexelSize = g(new P()), this.renderTarget = this.createRenderTarget(), this.outputTexture = this.renderTarget.texture;
355
+ super(e), this.material = new ce(), this.mesh = new ze(this.material), this.inputTexelSize = g("vec2");
356
+ const t = this.constructor.type.replace(/Node$/, "");
357
+ this.material.name = t, this.mesh.name = t, this.renderTarget = this.createRenderTarget(), this.outputTexture = this.renderTarget.texture;
255
358
  }
256
359
  setSize(e, t) {
257
- const { resolutionScale: s } = this, o = Math.max(Math.round(e * s), 1), i = Math.max(Math.round(t * s), 1);
258
- return this.renderTarget.setSize(o, i), this;
360
+ const { resolutionScale: o } = this, n = Math.max(Math.round(e * o), 1), i = Math.max(Math.round(t * o), 1);
361
+ return this.renderTarget.setSize(n, i), this;
259
362
  }
260
363
  updateBefore({ renderer: e }) {
261
364
  if (e == null)
262
365
  return;
263
366
  const { inputNode: t } = this;
264
- w(t != null);
265
- const { width: s, height: o } = t.value;
266
- this.setSize(s, o), this.inputTexelSize.value.set(1 / s, 1 / o), this.rendererState = Bs(e, this.rendererState), e.setRenderTarget(this.renderTarget), this.mesh.render(e), As(e, this.rendererState);
367
+ y(t != null);
368
+ const { width: o, height: n } = t.value;
369
+ this.setSize(o, n), this.inputTexelSize.value.set(1 / o, 1 / n), this.rendererState = oo(e, this.rendererState), e.setRenderTarget(this.renderTarget), this.mesh.render(e), no(e, this.rendererState);
267
370
  }
268
371
  setup(e) {
269
372
  const { inputNode: t } = this;
270
- w(t != null);
271
- const { material: s } = this;
272
- return s.fragmentNode = this.setupOutputNode(e), s.needsUpdate = !0, super.setup(e);
373
+ y(t != null);
374
+ const { material: o } = this;
375
+ return o.fragmentNode = this.setupOutputNode(e), o.needsUpdate = !0, super.setup(e);
273
376
  }
274
377
  dispose() {
275
378
  this.renderTarget.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
276
379
  }
277
380
  }
278
- class yt extends Ps {
381
+ class Bt extends io {
279
382
  constructor(e) {
280
383
  super(e), this.thresholdLevel = g(5), this.thresholdRange = g(1), this.resolutionScale = 0.5;
281
384
  }
@@ -283,108 +386,89 @@ class yt extends Ps {
283
386
  return "DownsampleThresholdNode";
284
387
  }
285
388
  setupOutputNode() {
286
- const { inputNode: e, thresholdLevel: t, thresholdRange: s, inputTexelSize: o } = this;
287
- w(e != null);
288
- const i = gt(e, o), r = jt(i.rgb), u = at(
389
+ const { inputNode: e, thresholdLevel: t, thresholdRange: o, inputTexelSize: n } = this;
390
+ y(e != null);
391
+ const i = Dt(e, n), r = Xt(i.rgb), c = dt(
289
392
  t,
290
- t.add(s),
393
+ t.add(o),
291
394
  r
292
395
  );
293
- return b(i.rgb, r).mul(u);
396
+ return z(i.rgb, r).mul(c);
294
397
  }
295
398
  }
296
- const Po = (...n) => new yt(...n);
297
- function He(n) {
298
- if (typeof n == "string")
299
- return n;
300
- if (n.layout.name == null)
301
- throw new Error("Struct name is required.");
302
- return n.layout.name;
303
- }
304
- function we({
305
- typeOnly: n = !1,
306
- ...e
307
- }) {
308
- return n ? (t) => k(t) : (t) => k(t).setLayout({
309
- ...e,
310
- type: He(e.type),
311
- inputs: e.inputs?.map((s) => ({
312
- ...s,
313
- type: He(s.type)
314
- })) ?? []
315
- });
316
- }
317
- function ee(n) {
318
- return k((e, t) => {
319
- const s = n(...e);
320
- return typeof s == "function" ? s(t) : s;
321
- });
322
- }
323
- const { resetRendererState: Fs, restoreRendererState: js } = me;
324
- class ks extends Me {
399
+ const zn = (...s) => new Bt(...s), Cn = (s) => {
400
+ const e = _t(s);
401
+ return e.updateType = H.NONE, e;
402
+ }, Rn = (s) => {
403
+ const e = Zt(s);
404
+ return e.updateBeforeType = H.FRAME, e;
405
+ }, { resetRendererState: ro, restoreRendererState: ao } = ge;
406
+ class co extends Re {
325
407
  constructor(e) {
326
- super(e), this.iterations = 1, this.material = new le(), this.mesh = new Ne(this.material), this.inputTexelSize = g(new P()), this.direction = g(new P()), this.horizontalRT = this.createRenderTarget("Horizontal"), this.verticalRT = this.createRenderTarget("Vertical"), this.outputTexture = this.verticalRT.texture;
408
+ super(e), this.iterations = 1, this.material = new ce(), this.mesh = new ze(this.material), this.inputTexelSize = g("vec2"), this.direction = g("vec2");
409
+ const t = this.constructor.type.replace(/Node$/, "");
410
+ this.material.name = t, this.mesh.name = t, this.horizontalRT = this.createRenderTarget("horizontal"), this.verticalRT = this.createRenderTarget("vertical"), this.outputTexture = this.verticalRT.texture;
327
411
  }
328
412
  setSize(e, t) {
329
- const { resolutionScale: s } = this, o = Math.max(Math.round(e * s), 1), i = Math.max(Math.round(t * s), 1);
330
- return this.horizontalRT.setSize(o, i), this.verticalRT.setSize(o, i), this;
413
+ const { resolutionScale: o } = this, n = Math.max(Math.round(e * o), 1), i = Math.max(Math.round(t * o), 1);
414
+ return this.horizontalRT.setSize(n, i), this.verticalRT.setSize(n, i), this;
331
415
  }
332
416
  updateBefore({ renderer: e }) {
333
417
  if (e == null)
334
418
  return;
335
- const { horizontalRT: t, verticalRT: s, mesh: o, inputNode: i, direction: r } = this;
336
- w(i != null);
337
- const { width: u, height: a } = i.value;
338
- this.setSize(u, a), this.inputTexelSize.value.set(1 / u, 1 / a);
339
- const l = i.value;
340
- this.rendererState = Fs(e, this.rendererState);
341
- for (let c = 0; c < this.iterations; ++c)
342
- r.value.set(1, 0), e.setRenderTarget(t), o.render(e), i.value = t.texture, r.value.set(0, 1), e.setRenderTarget(s), o.render(e), i.value = s.texture;
343
- js(e, this.rendererState), i.value = l;
419
+ const { horizontalRT: t, verticalRT: o, mesh: n, inputNode: i, direction: r } = this;
420
+ y(i != null);
421
+ const { width: c, height: a } = i.value;
422
+ this.setSize(c, a), this.inputTexelSize.value.set(1 / c, 1 / a);
423
+ const h = i.value;
424
+ this.rendererState = ro(e, this.rendererState);
425
+ for (let l = 0; l < this.iterations; ++l)
426
+ r.value.set(1, 0), e.setRenderTarget(t), n.render(e), i.value = t.texture, r.value.set(0, 1), e.setRenderTarget(o), n.render(e), i.value = o.texture;
427
+ ao(e, this.rendererState), i.value = h;
344
428
  }
345
429
  setup(e) {
346
430
  const { inputNode: t } = this;
347
- w(t != null);
348
- const { material: s } = this;
349
- return s.fragmentNode = this.setupOutputNode(e), s.needsUpdate = !0, super.setup(e);
431
+ y(t != null);
432
+ const { material: o } = this;
433
+ return o.fragmentNode = this.setupOutputNode(e), o.needsUpdate = !0, super.setup(e);
350
434
  }
351
435
  dispose() {
352
436
  this.horizontalRT.dispose(), this.verticalRT.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
353
437
  }
354
438
  }
355
- function $e(n) {
356
- if (w(n >= 0), n === 0)
439
+ function et(s) {
440
+ if (y(s >= 0), s === 0)
357
441
  return new Float64Array(0);
358
- if (n === 1)
442
+ if (s === 1)
359
443
  return new Float64Array([1]);
360
- let e = new Float64Array(n), t = new Float64Array(n), s = t;
361
- for (let o = 1; o <= n; ++o) {
362
- for (let i = 0; i < o; ++i)
363
- t[i] = i === 0 || i === o - 1 ? 1 : e[i - 1] + e[i];
364
- s = t, t = e, e = s;
444
+ let e = new Float64Array(s), t = new Float64Array(s), o = t;
445
+ for (let n = 1; n <= s; ++n) {
446
+ for (let i = 0; i < n; ++i)
447
+ t[i] = i === 0 || i === n - 1 ? 1 : e[i - 1] + e[i];
448
+ o = t, t = e, e = o;
365
449
  }
366
- return s;
450
+ return o;
367
451
  }
368
- function Os(n, e = 2) {
369
- w(n >= 3);
370
- const t = n + e * 2, s = e > 0 ? $e(t).slice(e, -e) : $e(t), o = Math.floor((s.length - 1) / 2), i = s.reduce((h, p) => h + p, 0), r = s.slice(o), u = [...Array(o + 1).keys()], a = new Float64Array(Math.floor(u.length / 2)), l = new Float64Array(a.length);
452
+ function uo(s, e = 2) {
453
+ y(s >= 3);
454
+ const t = s + e * 2, o = e > 0 ? et(t).slice(e, -e) : et(t), n = Math.floor((o.length - 1) / 2), i = o.reduce((u, p) => u + p, 0), r = o.slice(n), c = [...Array(n + 1).keys()], a = new Float64Array(Math.floor(c.length / 2)), h = new Float64Array(a.length);
371
455
  a[0] = r[0] / i;
372
- for (let h = 1, p = 1; h < u.length - 1; h += 2, ++p) {
373
- const d = u[h], m = u[h + 1], x = r[h], z = r[h + 1], T = x + z, B = (d * x + m * z) / T;
374
- a[p] = T / i, l[p] = B;
456
+ for (let u = 1, p = 1; u < c.length - 1; u += 2, ++p) {
457
+ const d = c[u], m = c[u + 1], x = r[u], w = r[u + 1], T = x + w, C = (d * x + m * w) / T;
458
+ a[p] = T / i, h[p] = C;
375
459
  }
376
- const c = (a.reduce((h, p) => h + p, 0) - a[0] * 0.5) * 2;
377
- if (c !== 0) {
378
- const h = 1 / c;
460
+ const l = (a.reduce((u, p) => u + p, 0) - a[0] * 0.5) * 2;
461
+ if (l !== 0) {
462
+ const u = 1 / l;
379
463
  for (let p = 0; p < a.length; ++p)
380
- a[p] *= h;
464
+ a[p] *= u;
381
465
  }
382
466
  return {
383
- offsets: l,
467
+ offsets: h,
384
468
  weights: a
385
469
  };
386
470
  }
387
- class vt extends ks {
471
+ class At extends co {
388
472
  static get type() {
389
473
  return "GaussianBlurNode";
390
474
  }
@@ -392,34 +476,34 @@ class vt extends ks {
392
476
  super(e), this.kernelSize = t;
393
477
  }
394
478
  setupOutputNode(e) {
395
- const { inputNode: t, inputTexelSize: s, direction: o } = this;
396
- w(t != null);
397
- const { offsets: i, weights: r } = Os(this.kernelSize);
398
- return k(() => {
399
- const u = q(), a = o.mul(s).toVertexStage(), l = t.sample(u).mul(r[0]);
400
- for (let c = 1; c < i.length; ++c) {
401
- const h = a.mul(i[c]);
402
- l.addAssign(
403
- D(
404
- t.sample(u.add(h)),
405
- t.sample(u.sub(h))
406
- ).mul(r[c])
479
+ const { inputNode: t, inputTexelSize: o, direction: n } = this;
480
+ y(t != null);
481
+ const { offsets: i, weights: r } = uo(this.kernelSize);
482
+ return U(() => {
483
+ const c = I(), a = n.mul(o).toVertexStage(), h = t.sample(c).mul(r[0]);
484
+ for (let l = 1; l < i.length; ++l) {
485
+ const u = a.mul(i[l]);
486
+ h.addAssign(
487
+ B(
488
+ t.sample(c.add(u)),
489
+ t.sample(c.sub(u))
490
+ ).mul(r[l])
407
491
  );
408
492
  }
409
- return l;
493
+ return h;
410
494
  })();
411
495
  }
412
496
  }
413
- const Fo = (...n) => new vt(...n), Us = (n) => n.dot(f(0.06711056, 583715e-8)).fract().mul(52.9829189).fract(), jo = /* @__PURE__ */ k(() => {
414
- const n = f(ut.xy).add(kt.fract().mul(1337)), e = Us(n);
415
- return N(e, e.oneMinus(), e).sub(0.5).div(255);
416
- }).once()(), ko = (n, e, t = f(90, 45)) => {
417
- const s = Ot(n), o = Ut(s), i = e.mul(o).mul(0.5), r = X(s.mul(t).fract().sub(0.5)).div(t), u = at(i, i.add(o), r).oneMinus();
418
- return u.x.add(u.y).clamp(0, 1);
497
+ const Dn = (...s) => new At(...s), lo = (s) => s.dot(f(0.06711056, 583715e-8)).fract().mul(52.9829189).fract(), Bn = /* @__PURE__ */ U(() => {
498
+ const s = f(ke.xy).add(Kt.fract().mul(1337)), e = lo(s);
499
+ return M(e, e.oneMinus(), e).sub(0.5).div(255);
500
+ }).once()(), An = (s, e, t = f(90, 45)) => {
501
+ const o = Qt(s), n = Jt(o), i = e.mul(n).mul(0.5), r = _(o.mul(t).fract().sub(0.5)).div(t), c = dt(i, i.add(n), r).oneMinus();
502
+ return c.x.add(c.y).clamp(0, 1);
419
503
  };
420
- class Is extends _ {
504
+ class ho extends Q {
421
505
  constructor() {
422
- super("vec3"), this.currentProjectionMatrix = g(new ne()), this.previousProjectionMatrix = g("mat4"), this.currentModelViewMatrix = g(new ne()), this.previousModelViewMatrix = g("mat4"), this.objectModelViewMatrices = /* @__PURE__ */ new WeakMap(), this.updateType = Q.FRAME, this.updateBeforeType = Q.OBJECT, this.updateAfterType = Q.OBJECT;
506
+ super("vec3"), this.currentProjectionMatrix = g("mat4"), this.previousProjectionMatrix = g("mat4"), this.currentModelViewMatrix = g("mat4"), this.previousModelViewMatrix = g("mat4"), this.objectModelViewMatrices = /* @__PURE__ */ new WeakMap(), this.updateType = H.FRAME, this.updateBeforeType = H.OBJECT, this.updateAfterType = H.OBJECT;
423
507
  }
424
508
  static get type() {
425
509
  return "HighpVelocityNode";
@@ -433,23 +517,23 @@ class Is extends _ {
433
517
  return;
434
518
  const {
435
519
  currentProjectionMatrix: t,
436
- previousProjectionMatrix: s
437
- } = this, o = this.projectionMatrix ?? e.projectionMatrix;
438
- s.value == null ? s.value = new ne().copy(o) : s.value.copy(t.value), t.value.copy(o);
520
+ previousProjectionMatrix: o
521
+ } = this, n = this.projectionMatrix ?? e.projectionMatrix;
522
+ o.value == null ? o.value = new Se().copy(n) : o.value.copy(t.value), t.value.copy(n);
439
523
  }
440
524
  // Executed once per object before rendering:
441
525
  updateBefore({ object: e, camera: t }) {
442
526
  if (e == null || t == null)
443
527
  return;
444
528
  const {
445
- currentModelViewMatrix: s,
446
- previousModelViewMatrix: o,
529
+ currentModelViewMatrix: o,
530
+ previousModelViewMatrix: n,
447
531
  objectModelViewMatrices: i
448
532
  } = this;
449
- s.value.multiplyMatrices(
533
+ o.value.multiplyMatrices(
450
534
  t.matrixWorldInverse,
451
535
  e.matrixWorld
452
- ), o.value = i.get(e) ?? s.value;
536
+ ), n.value = i.get(e) ?? o.value;
453
537
  }
454
538
  // Executed once per object after rendering:
455
539
  updateAfter({ object: e }) {
@@ -457,18 +541,18 @@ class Is extends _ {
457
541
  return;
458
542
  const {
459
543
  currentModelViewMatrix: t,
460
- objectModelViewMatrices: s
544
+ objectModelViewMatrices: o
461
545
  } = this;
462
- let o = s.get(e);
463
- o == null && (o = new ne(), s.set(e, o)), o.copy(t.value);
546
+ let n = o.get(e);
547
+ n == null && (n = new Se(), o.set(e, n)), n.copy(t.value);
464
548
  }
465
549
  setup(e) {
466
- const t = this.currentProjectionMatrix.mul(this.currentModelViewMatrix).mul(It).toVertexStage(), s = this.previousProjectionMatrix.mul(this.previousModelViewMatrix).mul(Et).toVertexStage(), o = t.xyz.div(t.w), i = s.xyz.div(s.w);
467
- return ue(o, i);
550
+ const t = this.currentProjectionMatrix.mul(this.currentModelViewMatrix).mul(es).toVertexStage(), o = this.previousProjectionMatrix.mul(this.previousModelViewMatrix).mul(ts).toVertexStage(), n = t.xyz.div(t.w), i = o.xyz.div(o.w);
551
+ return ie(n, i);
468
552
  }
469
553
  }
470
- const Ye = /* @__PURE__ */ Lt(Is);
471
- class Es extends Ue {
554
+ const tt = /* @__PURE__ */ pt(ho);
555
+ class po extends qe {
472
556
  static get type() {
473
557
  return "KawaseBlurNode";
474
558
  }
@@ -476,39 +560,39 @@ class Es extends Ue {
476
560
  super(e, t), this.resolutionScale = 0.5;
477
561
  }
478
562
  setupDownsampleNode(e) {
479
- const { inputNode: t, inputTexelSize: s } = this;
480
- w(t != null);
481
- const o = q(), i = b(1, 1, -1, -1).mul(s.xyxy.mul(0.5)).add(o.xyxy).toVertexStage(), r = i.zy, u = i.xy, a = i.xw, l = i.zw;
482
- return D(
483
- t.sample(o).mul(4),
563
+ const { inputNode: t, inputTexelSize: o } = this;
564
+ y(t != null);
565
+ const n = I(), i = z(1, 1, -1, -1).mul(o.xyxy.mul(0.5)).add(n.xyxy).toVertexStage(), r = i.zy, c = i.xy, a = i.xw, h = i.zw;
566
+ return B(
567
+ t.sample(n).mul(4),
484
568
  t.sample(r),
485
- t.sample(u),
569
+ t.sample(c),
486
570
  t.sample(a),
487
- t.sample(l)
571
+ t.sample(h)
488
572
  ).mul(1 / 8);
489
573
  }
490
574
  setupUpsampleNode(e) {
491
- const { inputNode: t, inputTexelSize: s } = this;
492
- w(t != null);
493
- const o = q(), i = b(1, 1, -1, -1).mul(s.xyxy.mul(0.5)).add(o.xyxy).toVertexStage(), r = i.zy, u = i.xy, a = i.xw, l = i.zw, c = f(i.z, o.y), h = f(i.x, o.y), p = f(o.x, i.y), d = f(o.x, i.w);
494
- return D(
495
- D(
575
+ const { inputNode: t, inputTexelSize: o } = this;
576
+ y(t != null);
577
+ const n = I(), i = z(1, 1, -1, -1).mul(o.xyxy.mul(0.5)).add(n.xyxy).toVertexStage(), r = i.zy, c = i.xy, a = i.xw, h = i.zw, l = f(i.z, n.y), u = f(i.x, n.y), p = f(n.x, i.y), d = f(n.x, i.w);
578
+ return B(
579
+ B(
496
580
  t.sample(r),
497
- t.sample(u),
581
+ t.sample(c),
498
582
  t.sample(a),
499
- t.sample(l)
583
+ t.sample(h)
500
584
  ).mul(1 / 12),
501
- D(
502
- t.sample(c),
503
- t.sample(h),
585
+ B(
586
+ t.sample(l),
587
+ t.sample(u),
504
588
  t.sample(p),
505
589
  t.sample(d)
506
590
  ).mul(1 / 6)
507
591
  );
508
592
  }
509
593
  }
510
- const Oo = (...n) => new Es(...n);
511
- class Ls extends _ {
594
+ const Vn = (...s) => new po(...s);
595
+ class mo extends Q {
512
596
  constructor(e) {
513
597
  super("vec3"), this.intensity = g(1e-5), this.inputNode = e;
514
598
  }
@@ -516,9 +600,9 @@ class Ls extends _ {
516
600
  return "LensGhostNode";
517
601
  }
518
602
  setup(e) {
519
- const { inputNode: t, intensity: s } = this;
520
- w(t != null);
521
- const o = we({
603
+ const { inputNode: t, intensity: o } = this;
604
+ y(t != null);
605
+ const n = V({
522
606
  name: "sampleGhost",
523
607
  type: "vec3",
524
608
  inputs: [
@@ -527,33 +611,33 @@ class Ls extends _ {
527
611
  { name: "color", type: "vec3" },
528
612
  { name: "offset", type: "float" }
529
613
  ]
530
- })(([a, l, c, h]) => {
531
- const p = l.mul(h).add(a.oneMinus()).saturate(), d = t.sample(p).rgb.mul(c), m = ue(0.5, p).length().mul(1 / (Math.SQRT2 / 4)).saturate();
614
+ })(([a, h, l, u]) => {
615
+ const p = h.mul(u).add(a.oneMinus()).saturate(), d = t.sample(p).rgb.mul(l), m = ie(0.5, p).length().mul(1 / (Math.SQRT2 / 4)).saturate();
532
616
  return d.mulAssign(m.oneMinus().pow(3)), d;
533
- }), i = q(), r = i.sub(0.5);
534
- return D(
535
- o(i, r, N(0.8, 0.8, 1), -5),
536
- o(i, r, N(1, 0.8, 0.4), -1.5),
537
- o(i, r, N(0.9, 1, 0.8), -0.4),
538
- o(i, r, N(1, 0.8, 0.4), -0.2),
539
- o(i, r, N(0.9, 0.7, 0.7), -0.1),
540
- o(i, r, N(0.5, 1, 0.4), 0.7),
541
- o(i, r, N(0.5, 0.5, 0.5), 1),
542
- o(i, r, N(1, 1, 0.6), 2.5),
543
- o(i, r, N(0.5, 0.8, 1), 10)
544
- ).mul(s);
617
+ }), i = I(), r = i.sub(0.5);
618
+ return B(
619
+ n(i, r, M(0.8, 0.8, 1), -5),
620
+ n(i, r, M(1, 0.8, 0.4), -1.5),
621
+ n(i, r, M(0.9, 1, 0.8), -0.4),
622
+ n(i, r, M(1, 0.8, 0.4), -0.2),
623
+ n(i, r, M(0.9, 0.7, 0.7), -0.1),
624
+ n(i, r, M(0.5, 1, 0.4), 0.7),
625
+ n(i, r, M(0.5, 0.5, 0.5), 1),
626
+ n(i, r, M(1, 1, 0.6), 2.5),
627
+ n(i, r, M(0.5, 0.8, 1), 10)
628
+ ).mul(o);
545
629
  }
546
630
  }
547
- const { resetRendererState: Ws, restoreRendererState: Gs } = me;
548
- function qs() {
549
- const s = document.createElement("canvas");
550
- s.width = 256, s.height = 32;
551
- const o = s.getContext("2d");
552
- w(o != null), o.beginPath(), o.moveTo(0, 32 / 2), o.lineTo(256 / 2, 5), o.lineTo(256, 32 / 2), o.lineTo(256 / 2, 27), o.closePath();
553
- const i = o.createLinearGradient(0, 0, 256, 0);
554
- return i.addColorStop(0, "#000000"), i.addColorStop(0.5, "#ffffff"), i.addColorStop(1, "#000000"), o.fillStyle = i, o.fill(), new At(s);
631
+ const { resetRendererState: fo, restoreRendererState: xo } = ge;
632
+ function go() {
633
+ const o = document.createElement("canvas");
634
+ o.width = 256, o.height = 32;
635
+ const n = o.getContext("2d");
636
+ y(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();
637
+ const i = n.createLinearGradient(0, 0, 256, 0);
638
+ return i.addColorStop(0, "#000000"), i.addColorStop(0.5, "#ffffff"), i.addColorStop(1, "#000000"), n.fillStyle = i, n.fill(), new Is(o);
555
639
  }
556
- const Xe = /* @__PURE__ */ Pe({
640
+ const st = /* @__PURE__ */ Ie({
557
641
  color: "vec3",
558
642
  luminance: "float",
559
643
  position: "vec2",
@@ -561,68 +645,70 @@ const Xe = /* @__PURE__ */ Pe({
561
645
  sin: "float",
562
646
  cos: "float"
563
647
  });
564
- class Hs extends Me {
648
+ class vo extends Re {
565
649
  constructor(e) {
566
- super(e), this.spikePairCount = 6, this.wireframe = !1, this.intensity = g(1e-5), this.sizeScale = g(new P(1.5, 0.01)), this.luminanceThreshold = g(100), this.counterBuffer = new ws(1, 1), this.instanceBuffer = Le(1, Xe), this.renderTarget = this.createRenderTarget(), this.material = new Ts({
650
+ super(e), this.spikePairCount = 6, this.wireframe = !1, this.intensity = g(1e-5), this.sizeScale = g(new ve(1.5, 0.01)), this.luminanceThreshold = g(100), this.indirectBuffer = new Ms(
651
+ new Uint32Array([6, 0, 0, 0, 0]),
652
+ 1
653
+ ), this.instanceBuffer = _e(1, st), this.renderTarget = this.createRenderTarget(), this.material = new zs({
567
654
  depthTest: !1,
568
655
  depthWrite: !1,
569
656
  transparent: !0,
570
- blending: Rt
571
- }), this.mesh = new Te(new Dt(1, 1), this.material), this.camera = new Vt(), this.inputTexelSize = g(new P()), this.outputTexelSize = g(new P()), this.geometryRatio = g(new P()), this.inputNode = e, this.resolutionScale = 0.5, this.outputTexture = this.renderTarget.texture;
657
+ blending: Us
658
+ }), this.mesh = new bt(new js(1, 1), this.material), this.camera = new Es(), this.inputTexelSize = g("vec2"), this.outputTexelSize = g("vec2"), this.geometryRatio = g("vec2"), this.material.name = "LensGlare", this.inputNode = e, this.resolutionScale = 0.5, this.outputTexture = this.renderTarget.texture, this.mesh.geometry.indirect = this.indirectBuffer;
572
659
  }
573
660
  customCacheKey() {
574
- return je(this.spikePairCount, +this.wireframe);
661
+ return We(this.spikePairCount, +this.wireframe);
575
662
  }
576
663
  setSize(e, t) {
577
- const { resolutionScale: s } = this, o = Math.max(Math.round(e * s), 1), i = Math.max(Math.round(t * s), 1);
578
- this.renderTarget.setSize(o, i);
579
- const r = Math.floor(o / 2), u = Math.floor(i / 2), a = r * u;
580
- return this.instanceBuffer.bufferCount < a && (this.instanceBuffer.dispose(), this.instanceBuffer = Le(a, Xe), this.setupCompute(r, u), this.setupMaterial()), this;
664
+ const { resolutionScale: o } = this, n = Math.max(Math.round(e * o), 1), i = Math.max(Math.round(t * o), 1);
665
+ this.renderTarget.setSize(n, i);
666
+ const r = Math.floor(n / 2), c = Math.floor(i / 2), a = r * c;
667
+ return this.instanceBuffer.bufferCount < a && (this.instanceBuffer.dispose(), this.instanceBuffer = _e(a, st), this.setupCompute(r, c), this.setupMaterial()), this;
581
668
  }
582
669
  updateBefore({ renderer: e }) {
583
670
  if (e == null)
584
671
  return;
585
672
  const { inputNode: t } = this;
586
- w(t != null);
587
- const { width: s, height: o } = t.value;
588
- this.setSize(s, o);
589
- const { computeNode: i, counterBuffer: r, renderTarget: u } = this;
590
- w(i != null), this.inputTexelSize.value.set(1 / s, 1 / o);
591
- const a = s / o;
673
+ y(t != null);
674
+ const { width: o, height: n } = t.value;
675
+ this.setSize(o, n);
676
+ const { computeNode: i, indirectBuffer: r, renderTarget: c } = this;
677
+ y(i != null), this.inputTexelSize.value.set(1 / o, 1 / n);
678
+ const a = o / n;
592
679
  a > 1 ? this.geometryRatio.value.set(1 / a, 1) : this.geometryRatio.value.set(1, a);
593
- const { width: l, height: c } = u;
594
- this.outputTexelSize.value.set(1 / l, 1 / c), r.array[0] = 0, r.needsUpdate = !0, e.compute(i), e.getArrayBufferAsync(r).then((h) => {
595
- this.mesh.count = new Uint32Array(h)[0];
596
- }).catch((h) => {
597
- console.error(h);
598
- }), this.rendererState = Ws(e, this.rendererState), e.setRenderTarget(u), e.render(this.mesh, this.camera), Gs(e, this.rendererState);
680
+ const { width: h, height: l } = c;
681
+ this.outputTexelSize.value.set(1 / h, 1 / l), r.array[1] = 0, r.needsUpdate = !0, e.compute(i), this.rendererState = fo(e, this.rendererState), e.setRenderTarget(c), e.render(this.mesh, this.camera), xo(e, this.rendererState);
599
682
  }
600
683
  setupCompute(e, t) {
601
684
  const {
602
- spikePairCount: s,
603
- inputNode: o,
604
- counterBuffer: i,
685
+ spikePairCount: o,
686
+ inputNode: n,
687
+ indirectBuffer: i,
605
688
  instanceBuffer: r,
606
- outputTexelSize: u
689
+ outputTexelSize: c
607
690
  } = this;
608
- w(o != null);
609
- const a = Wt(
691
+ y(n != null);
692
+ const a = ss(
610
693
  i,
611
694
  "uint",
612
695
  i.count
613
696
  ).toAtomic();
614
- this.computeNode = k(() => {
615
- const l = lt(e, t);
616
- K(Ce.xy.greaterThanEqual(l).any(), () => {
617
- Gt();
697
+ this.computeNode = U(() => {
698
+ const h = re(e, t);
699
+ ae(Ae.xy.greaterThanEqual(h).any(), () => {
700
+ os();
618
701
  });
619
- const c = f(Ce.xy).mul(u).mul(2), h = o.sample(c), p = h.a;
620
- K(p.greaterThan(0.1), () => {
621
- const d = qt(a.element(0), s);
622
- for (let m = 0; m < s; ++m) {
702
+ const l = f(Ae.xy).mul(c).mul(2), u = n.sample(l), p = u.a;
703
+ ae(p.greaterThan(0.1), () => {
704
+ const d = ns(
705
+ a.element(1),
706
+ o
707
+ );
708
+ for (let m = 0; m < o; ++m) {
623
709
  const x = r.element(d.add(m));
624
- x.get("color").assign(h.rgb), x.get("luminance").assign(p), x.get("position").assign(Ce.xy), x.get("scale").assign(m % 2 === 0 ? 1 : 0.5);
625
- const z = Math.PI * (3 - Math.sqrt(5)), T = Math.PI / s * m + z;
710
+ x.get("color").assign(u.rgb), x.get("luminance").assign(p), x.get("position").assign(Ae.xy), x.get("scale").assign(m % 2 === 0 ? 1 : 0.5);
711
+ const w = Math.PI * (3 - Math.sqrt(5)), T = Math.PI / o * m + w;
626
712
  x.get("sin").assign(Math.sin(T)), x.get("cos").assign(Math.cos(T));
627
713
  }
628
714
  });
@@ -636,29 +722,29 @@ class Hs extends Me {
636
722
  const {
637
723
  inputNode: e,
638
724
  spikeNode: t,
639
- instanceBuffer: s,
640
- luminanceThreshold: o,
725
+ instanceBuffer: o,
726
+ luminanceThreshold: n,
641
727
  intensity: i,
642
728
  sizeScale: r,
643
- outputTexelSize: u,
729
+ outputTexelSize: c,
644
730
  geometryRatio: a
645
731
  } = this;
646
- w(e != null), w(t != null);
647
- const l = s.element(Ht);
648
- this.material.colorNode = this.wireframe ? b(1) : t.mul(l.get("color").mul(i)), this.material.vertexNode = k(() => {
649
- const c = l.get("sin"), h = l.get("cos"), p = ct(h, c, 0, c.negate(), h, 0, 0, 0, 1), m = l.get("position").mul(u).mul(2), x = m.flipY().mul(2).sub(1), T = l.get("luminance").div(o).saturate(), B = f(T, 1).mul(
650
- l.get("scale"),
732
+ y(e != null), y(t != null);
733
+ const h = o.element(is);
734
+ this.material.colorNode = this.wireframe ? z(1) : t.mul(h.get("color").mul(i)), this.material.vertexNode = U(() => {
735
+ const l = h.get("sin"), u = h.get("cos"), p = mt(u, l, 0, l.negate(), u, 0, 0, 0, 1), m = h.get("position").mul(c).mul(2), x = m.flipY().mul(2).sub(1), T = h.get("luminance").div(n).saturate(), C = f(T, 1).mul(
736
+ h.get("scale"),
651
737
  r,
652
738
  // Make the spike to shrink at screen borders:
653
739
  m.sub(0.5).length().mul(2).oneMinus().mul(0.5).add(0.5)
654
- ), O = p.mul(rt.mul(b(B, 1, 1))).mul(a).add(N(x, 0));
655
- return b(O, 1);
740
+ ), j = p.mul(ht.mul(z(C, 1, 1))).mul(a).add(M(x, 0));
741
+ return z(j, 1);
656
742
  })(), this.material.wireframe = this.wireframe, this.material.needsUpdate = !0;
657
743
  }
658
744
  setup(e) {
659
745
  if (this.spikeNode == null) {
660
- const t = qs();
661
- t.colorSpace = Bt, this.spikeNode = ie(t);
746
+ const t = go();
747
+ t.colorSpace = ks, this.spikeNode = oe(t);
662
748
  }
663
749
  return this.setupMaterial(), super.setup(e);
664
750
  }
@@ -666,10 +752,10 @@ class Hs extends Me {
666
752
  this.renderTarget.dispose(), this.material.dispose(), this.mesh.geometry.dispose(), super.dispose();
667
753
  }
668
754
  }
669
- const $s = /* @__PURE__ */ new P();
670
- class Ys extends _ {
755
+ const yo = /* @__PURE__ */ new ve();
756
+ class wo extends Q {
671
757
  constructor(e) {
672
- super("vec3"), this.intensity = g(1e-5), this.chromaticAberration = g(5e-3), this.aspectRatio = g(0), this.inputNode = e, this.updateBeforeType = Q.FRAME;
758
+ super("vec3"), this.intensity = g(1e-5), this.chromaticAberration = g(5e-3), this.aspectRatio = g(0), this.updateBeforeType = H.FRAME, this.inputNode = e;
673
759
  }
674
760
  static get type() {
675
761
  return "LensHaloNode";
@@ -677,13 +763,13 @@ class Ys extends _ {
677
763
  updateBefore({ renderer: e }) {
678
764
  if (e == null)
679
765
  return;
680
- const { width: t, height: s } = e.getDrawingBufferSize($s);
681
- this.aspectRatio.value = t / s;
766
+ const { width: t, height: o } = e.getDrawingBufferSize(yo);
767
+ this.aspectRatio.value = t / o;
682
768
  }
683
769
  setup(e) {
684
- const { inputNode: t, intensity: s, chromaticAberration: o, aspectRatio: i } = this;
685
- w(t != null);
686
- const r = we({
770
+ const { inputNode: t, intensity: o, chromaticAberration: n, aspectRatio: i } = this;
771
+ y(t != null);
772
+ const r = V({
687
773
  name: "cubicRingMask",
688
774
  type: "float",
689
775
  inputs: [
@@ -691,29 +777,29 @@ class Ys extends _ {
691
777
  { name: "radius", type: "float" },
692
778
  { name: "thickness", type: "float" }
693
779
  ]
694
- })(([c, h, p]) => {
695
- const d = ht(X(c.sub(h)).div(p), 1);
696
- return $t(d, d, ue(3, d.mul(2))).oneMinus();
697
- }), u = we({
780
+ })(([l, u, p]) => {
781
+ const d = ft(_(l.sub(u)).div(p), 1);
782
+ return rs(d, d, ie(3, d.mul(2))).oneMinus();
783
+ }), c = V({
698
784
  name: "sampleHalo",
699
785
  type: "vec3",
700
786
  inputs: [
701
787
  { name: "uv", type: "vec2" },
702
788
  { name: "radius", type: "float" }
703
789
  ]
704
- })(([c, h]) => {
705
- const p = f(i, 1), d = c.sub(0.5).mul(p).normalize().div(p), m = N(o).mul(N(-1, 0, 1)), x = Yt(d.mul(h).add(c.oneMinus())), z = N(
790
+ })(([l, u]) => {
791
+ const p = f(i, 1), d = l.sub(0.5).mul(p).normalize().div(p), m = M(n).mul(M(-1, 0, 1)), x = as(d.mul(u).add(l.oneMinus())), w = M(
706
792
  t.sample(d.mul(m.r).add(x)).r,
707
793
  t.sample(d.mul(m.g).add(x)).g,
708
794
  t.sample(d.mul(m.b).add(x)).b
709
- ), T = c.sub(f(0.5, 0)).mul(p).add(f(0.5, 0)), B = Xt(T, f(0.5)).saturate();
710
- return z.mulAssign(r(B, 0.45, 0.25)), z;
711
- }), a = q();
712
- return u(a, 0.3).mul(s);
795
+ ), T = l.sub(f(0.5, 0)).mul(p).add(f(0.5, 0)), C = cs(T, f(0.5)).saturate();
796
+ return w.mulAssign(r(C, 0.45, 0.25)), w;
797
+ }), a = I();
798
+ return c(a, 0.3).mul(o);
713
799
  }
714
800
  }
715
- const F = (n) => n.greaterThanEqual(0).all().and(n.lessThanEqual(1).all()).toFloat();
716
- class wt extends Ue {
801
+ const E = (s) => s.greaterThanEqual(0).all().and(s.lessThanEqual(1).all()).toFloat();
802
+ class Vt extends qe {
717
803
  constructor(e, t = 4) {
718
804
  super(e, t), this.blendAmount = g(0.85), this.resolutionScale = 0.5;
719
805
  }
@@ -721,71 +807,71 @@ class wt extends Ue {
721
807
  return "MipmapSurfaceBlurNode";
722
808
  }
723
809
  setupDownsampleNode(e) {
724
- const { inputNode: t, inputTexelSize: s } = this;
725
- return w(t != null), k(() => {
726
- const o = q(), i = b(1, 1, -1, -1).mul(s.xyxy).add(o.xyxy).toVertexStage(), r = b(2, 2, -2, -2).mul(s.xyxy).add(o.xyxy).toVertexStage(), u = i.zy, a = i.xy, l = i.zw, c = i.xw, h = r.zy, p = r.xy, d = r.zw, m = r.xw, x = f(o.x, r.y), z = f(r.z, o.y), T = f(r.x, o.y), B = f(o.x, r.w), O = 1 / 4 / 2, C = 1 / 9 / 2, V = t.sample(o).mul(C);
727
- let S;
728
- return S = b(
729
- F(u),
730
- F(a),
731
- F(l),
732
- F(c)
733
- ).mul(O), V.addAssign(
734
- t.sample(u).mul(S.x),
735
- t.sample(a).mul(S.y),
736
- t.sample(l).mul(S.z),
737
- t.sample(c).mul(S.w)
738
- ), S = b(
739
- F(h),
740
- F(p),
741
- F(d),
742
- F(m)
743
- ).mul(C), V.addAssign(
744
- t.sample(h).mul(S.x),
745
- t.sample(p).mul(S.y),
746
- t.sample(d).mul(S.z),
747
- t.sample(m).mul(S.w)
748
- ), S = b(
749
- F(x),
750
- F(z),
751
- F(T),
752
- F(B)
753
- ).mul(C), V.addAssign(
754
- t.sample(x).mul(S.x),
755
- t.sample(z).mul(S.y),
756
- t.sample(T).mul(S.z),
757
- t.sample(B).mul(S.w)
758
- ), V;
810
+ const { inputNode: t, inputTexelSize: o } = this;
811
+ return y(t != null), U(() => {
812
+ const n = I(), i = z(1, 1, -1, -1).mul(o.xyxy).add(n.xyxy).toVertexStage(), r = z(2, 2, -2, -2).mul(o.xyxy).add(n.xyxy).toVertexStage(), c = i.zy, a = i.xy, h = i.zw, l = i.xw, u = r.zy, p = r.xy, d = r.zw, m = r.xw, x = f(n.x, r.y), w = f(r.z, n.y), T = f(r.x, n.y), C = f(n.x, r.w), j = 1 / 4 / 2, R = 1 / 9 / 2, F = t.sample(n).mul(R);
813
+ let b;
814
+ return b = z(
815
+ E(c),
816
+ E(a),
817
+ E(h),
818
+ E(l)
819
+ ).mul(j), F.addAssign(
820
+ t.sample(c).mul(b.x),
821
+ t.sample(a).mul(b.y),
822
+ t.sample(h).mul(b.z),
823
+ t.sample(l).mul(b.w)
824
+ ), b = z(
825
+ E(u),
826
+ E(p),
827
+ E(d),
828
+ E(m)
829
+ ).mul(R), F.addAssign(
830
+ t.sample(u).mul(b.x),
831
+ t.sample(p).mul(b.y),
832
+ t.sample(d).mul(b.z),
833
+ t.sample(m).mul(b.w)
834
+ ), b = z(
835
+ E(x),
836
+ E(w),
837
+ E(T),
838
+ E(C)
839
+ ).mul(R), F.addAssign(
840
+ t.sample(x).mul(b.x),
841
+ t.sample(w).mul(b.y),
842
+ t.sample(T).mul(b.z),
843
+ t.sample(C).mul(b.w)
844
+ ), F;
759
845
  })();
760
846
  }
761
847
  setupUpsampleNode(e) {
762
- const { inputNode: t, inputTexelSize: s, downsampleNode: o } = this;
763
- w(t != null);
764
- const i = q(), r = b(1, 1, -1, -1).mul(s.xyxy).add(i.xyxy).toVertexStage(), u = f(i.x, r.y), a = f(r.z, i.y), l = f(r.x, i.y), c = f(i.x, r.w), h = r.zy, p = r.xy, d = r.zw, m = r.xw, x = D(
848
+ const { inputNode: t, inputTexelSize: o, downsampleNode: n } = this;
849
+ y(t != null);
850
+ const i = I(), r = z(1, 1, -1, -1).mul(o.xyxy).add(i.xyxy).toVertexStage(), c = f(i.x, r.y), a = f(r.z, i.y), h = f(r.x, i.y), l = f(i.x, r.w), u = r.zy, p = r.xy, d = r.zw, m = r.xw, x = B(
765
851
  t.sample(i).mul(1 / 4),
766
- D(
767
- t.sample(u),
852
+ B(
853
+ t.sample(c),
768
854
  t.sample(a),
769
- t.sample(l),
770
- t.sample(c)
771
- ).mul(1 / 8),
772
- D(
773
855
  t.sample(h),
856
+ t.sample(l)
857
+ ).mul(1 / 8),
858
+ B(
859
+ t.sample(u),
774
860
  t.sample(p),
775
861
  t.sample(d),
776
862
  t.sample(m)
777
863
  ).mul(1 / 16)
778
864
  );
779
- return re(o.sample(i), x, this.blendAmount);
865
+ return ne(n.sample(i), x, this.blendAmount);
780
866
  }
781
867
  }
782
- const Uo = (...n) => new wt(...n);
783
- function Tt(n) {
784
- return (n instanceof Ss ? n.renderer.backend : "backend" in n ? n.backend : n).isWebGPUBackend === !0;
868
+ const Pn = (...s) => new Vt(...s);
869
+ function Pt(s) {
870
+ return (s instanceof Cs ? s.renderer.backend : "backend" in s ? s.backend : s).isWebGPUBackend === !0;
785
871
  }
786
- class Xs extends _ {
872
+ class To extends Q {
787
873
  constructor(e) {
788
- super("vec4"), this.bloomIntensity = g(0.05), this.inputNode = e, this.thresholdNode = new yt(), this.blurNode = new vt(), this.ghostNode = new Ls(), this.haloNode = new Ys(), this.bloomNode = new wt(null, 8), this.glareNode = new Hs(), this.featuresNode = Zt(D(this.ghostNode, this.haloNode)), this.featuresNode.value.name = "LensFlareNode.Features", this.featuresNode.pixelRatio = 0.5, this.blurNode.resolutionScale = 1, this.bloomNode.resolutionScale = 1, this.glareNode.resolutionScale = 1;
874
+ super("vec4"), this.bloomIntensity = g(0.05), this.inputNode = e, this.thresholdNode = new Bt(), this.blurNode = new At(), this.ghostNode = new mo(), this.haloNode = new wo(), this.bloomNode = new Vt(null, 8), this.glareNode = new vo(), this.featuresNode = us(B(this.ghostNode, this.haloNode)), this.featuresNode.value.name = "LensFlare_features", this.featuresNode.pixelRatio = 0.5, this.blurNode.resolutionScale = 1, this.bloomNode.resolutionScale = 1, this.glareNode.resolutionScale = 1;
789
875
  }
790
876
  static get type() {
791
877
  return "LensFlareNode";
@@ -793,80 +879,139 @@ class Xs extends _ {
793
879
  setup(e) {
794
880
  const {
795
881
  inputNode: t,
796
- thresholdNode: s,
797
- blurNode: o,
882
+ thresholdNode: o,
883
+ blurNode: n,
798
884
  ghostNode: i,
799
885
  haloNode: r,
800
- bloomNode: u,
886
+ bloomNode: c,
801
887
  featuresNode: a,
802
- glareNode: l
888
+ glareNode: h
803
889
  } = this;
804
- w(t != null);
805
- const c = s.getTextureNode(), h = o.getTextureNode();
806
- s.inputNode = t, o.inputNode = c, i.inputNode = h, r.inputNode = h, u.inputNode = c, l.inputNode = c;
807
- const p = u.getTextureNode().mul(this.bloomIntensity), d = l.getTextureNode();
808
- return k(() => {
890
+ y(t != null);
891
+ const l = o.getTextureNode(), u = n.getTextureNode();
892
+ o.inputNode = t, n.inputNode = l, i.inputNode = u, r.inputNode = u, c.inputNode = l, h.inputNode = l;
893
+ const p = c.getTextureNode().mul(this.bloomIntensity), d = h.getTextureNode();
894
+ return U(() => {
809
895
  const m = t;
810
- return m.addAssign(p), Tt(e) && m.addAssign(d), m.add(a);
896
+ return m.addAssign(p), Pt(e) && m.addAssign(d), m.add(a);
811
897
  })();
812
898
  }
813
899
  dispose() {
814
900
  this.thresholdNode.dispose(), this.blurNode.dispose(), this.ghostNode.dispose(), this.haloNode.dispose(), this.bloomNode.dispose(), this.glareNode.dispose(), this.featuresNode.dispose(), super.dispose();
815
901
  }
816
902
  }
817
- const Io = (n) => new Xs(n != null ? De(n) : null), Eo = /* @__PURE__ */ ee(
818
- (n, e, t, s) => {
819
- const o = n.sub(t), i = ye(e, o), r = ye(o, o).sub(s.pow2()), u = i.pow2().sub(r).toVar(), a = f(-1);
820
- return K(u.greaterThanEqual(0), () => {
821
- const l = Se(u);
822
- a.assign(f(i.negate().sub(l), i.negate().add(l)));
903
+ const Fn = (s) => new To(s != null ? Oe(s) : null), No = /* @__PURE__ */ V({
904
+ name: "bvec2Not",
905
+ type: "bvec2",
906
+ inputs: [{ name: "x", type: "bvec2" }]
907
+ })(([s]) => s.notEqual(Me(!0))), So = /* @__PURE__ */ V({
908
+ name: "bvec3Not",
909
+ type: "bvec3",
910
+ inputs: [{ name: "x", type: "bvec3" }]
911
+ })(([s]) => s.notEqual(Me(!0))), bo = /* @__PURE__ */ V({
912
+ name: "bvec4Not",
913
+ type: "bvec4",
914
+ inputs: [{ name: "x", type: "bvec4" }]
915
+ })(([s]) => s.notEqual(Me(!0))), On = /* @__PURE__ */ Le([
916
+ No,
917
+ So,
918
+ bo
919
+ ]), Mo = /* @__PURE__ */ V({
920
+ name: "bvec2And",
921
+ type: "bvec2",
922
+ inputs: [
923
+ { name: "x", type: "bvec2" },
924
+ { name: "y", type: "bvec2" }
925
+ ]
926
+ })(([s, e]) => xt(re(s).mul(re(e)))), zo = /* @__PURE__ */ V({
927
+ name: "bvec3And",
928
+ type: "bvec3",
929
+ inputs: [
930
+ { name: "x", type: "bvec3" },
931
+ { name: "y", type: "bvec3" }
932
+ ]
933
+ })(([s, e]) => gt(pe(s).mul(pe(e)))), Co = /* @__PURE__ */ V({
934
+ name: "bvec4And",
935
+ type: "bvec4",
936
+ inputs: [
937
+ { name: "x", type: "bvec4" },
938
+ { name: "y", type: "bvec4" }
939
+ ]
940
+ })(([s, e]) => vt(me(s).mul(me(e)))), Un = /* @__PURE__ */ Le([
941
+ Mo,
942
+ zo,
943
+ Co
944
+ ]), Ro = /* @__PURE__ */ V({
945
+ name: "bvec2Or",
946
+ type: "bvec2",
947
+ inputs: [
948
+ { name: "x", type: "bvec2" },
949
+ { name: "y", type: "bvec2" }
950
+ ]
951
+ })(([s, e]) => re(s).add(re(e)).notEqual(0)), Do = /* @__PURE__ */ V({
952
+ name: "bvec3Or",
953
+ type: "bvec3",
954
+ inputs: [
955
+ { name: "x", type: "bvec3" },
956
+ { name: "y", type: "bvec3" }
957
+ ]
958
+ })(([s, e]) => pe(s).add(pe(e)).notEqual(0)), Bo = /* @__PURE__ */ V({
959
+ name: "bvec4Or",
960
+ type: "bvec4",
961
+ inputs: [
962
+ { name: "x", type: "bvec4" },
963
+ { name: "y", type: "bvec4" }
964
+ ]
965
+ })(([s, e]) => me(s).add(me(e)).notEqual(0)), jn = /* @__PURE__ */ Le([Ro, Do, Bo]), En = /* @__PURE__ */ L(
966
+ (s, e, t, o) => {
967
+ const n = s.sub(t), i = Ne(e, n), r = Ne(n, n).sub(o.pow2()), c = i.pow2().sub(r).toConst(), a = f(-1);
968
+ return ae(c.greaterThanEqual(0), () => {
969
+ const h = be(c);
970
+ a.assign(f(i.negate().sub(h), i.negate().add(h)));
823
971
  }), a;
824
972
  }
825
- ), Zs = /* @__PURE__ */ Pe(
826
- { near: "vec4", far: "vec4" },
827
- "raySpheresIntersections"
828
- ), Lo = /* @__PURE__ */ ee(
829
- (n, e, t, s) => {
830
- const o = n.sub(t), i = ye(e, o), r = ye(o, o).sub(s.pow2()), u = i.pow2().sub(r).toVar(), a = b(-1), l = b(-1);
831
- return K(u.greaterThanEqual(0), () => {
832
- const c = Se(u);
833
- a.assign(i.negate().sub(c)), l.assign(i.negate().add(c));
834
- }), Zs(a, l);
835
- }
836
- ), Wo = /* @__PURE__ */ ee(
837
- (n, e, t) => {
838
- const s = n.div(t), o = e.div(t), i = o.dot(o), r = s.dot(o), u = s.dot(s), a = r.pow2().sub(i.mul(u.sub(1))).toVar(), l = f(-1);
839
- return K(a.greaterThanEqual(0), () => {
840
- const c = Se(a);
841
- l.assign(f(r.negate().sub(c), r.negate().add(c)).div(i));
842
- }), l;
843
- }
844
- ), Qs = {
845
- float: pe,
846
- int: Z,
847
- uint: as,
848
- bool: rs,
973
+ ), Ao = /* @__PURE__ */ Ie({
974
+ near: "vec4",
975
+ far: "vec4"
976
+ }), kn = /* @__PURE__ */ L(
977
+ (s, e, t, o) => {
978
+ const n = s.sub(t), i = Ne(e, n), r = Ne(n, n).sub(o.pow2()), c = i.pow2().sub(r).toConst(), a = f(c.greaterThanEqual(0)).toConst(), h = a.oneMinus().toConst(), l = be(c.max(0)).toConst(), u = a.mul(i.negate().sub(l)).sub(h), p = a.mul(i.negate().add(l)).sub(h);
979
+ return Ao(u, p);
980
+ }
981
+ ), In = /* @__PURE__ */ L(
982
+ (s, e, t) => {
983
+ const o = s.div(t), n = e.div(t), i = n.dot(n), r = o.dot(n), c = o.dot(o), a = r.pow2().sub(i.mul(c.sub(1))).toConst(), h = f(-1);
984
+ return ae(a.greaterThanEqual(0), () => {
985
+ const l = be(a);
986
+ h.assign(f(r.negate().sub(l), r.negate().add(l)).div(i));
987
+ }), h;
988
+ }
989
+ ), Vo = {
990
+ float: G,
991
+ int: K,
992
+ uint: ms,
993
+ bool: Me,
849
994
  vec2: f,
850
- ivec2: j,
851
- uvec2: lt,
852
- bvec2: is,
853
- vec3: N,
854
- ivec3: ns,
855
- uvec3: os,
856
- bvec3: ss,
857
- vec4: b,
858
- ivec4: ts,
859
- uvec4: es,
860
- bvec4: Jt,
861
- mat2: _t,
862
- mat3: ct,
863
- mat4: Kt,
864
- color: Qt
865
- }, Go = Ns;
866
- function qo(n) {
867
- return Qs[n];
995
+ ivec2: O,
996
+ uvec2: re,
997
+ bvec2: xt,
998
+ vec3: M,
999
+ ivec3: ps,
1000
+ uvec3: pe,
1001
+ bvec3: gt,
1002
+ vec4: z,
1003
+ ivec4: yt,
1004
+ uvec4: me,
1005
+ bvec4: vt,
1006
+ mat2: ds,
1007
+ mat3: mt,
1008
+ mat4: hs,
1009
+ color: ls
1010
+ }, Ln = Rs;
1011
+ function Wn(s) {
1012
+ return Vo[s];
868
1013
  }
869
- class Ks extends Ms {
1014
+ class Po extends Nt {
870
1015
  static get type() {
871
1016
  return "OutputTexture3DNode";
872
1017
  }
@@ -880,48 +1025,47 @@ class Ks extends Ms {
880
1025
  return new this.constructor(this.owner, this.value);
881
1026
  }
882
1027
  }
883
- const Ho = (...n) => new Ks(...n), $o = /* @__PURE__ */ ee(
884
- (n, e) => {
885
- const t = f(ve(n)), s = t.reciprocal(), o = e.mul(t), i = o.sub(0.5).floor().add(0.5), r = o.sub(i), u = r.mul(r.mul(r.mul(0.5).oneMinus()).sub(0.5)), a = r.mul(r).mul(r.mul(1.5).sub(2.5)).add(1), l = r.mul(r.mul(ue(2, r.mul(1.5))).add(0.5)), c = r.mul(r).mul(r.mul(0.5).sub(0.5)), h = a.add(l), p = l.div(a.add(l)), d = i.sub(1).mul(s), m = i.add(2).mul(s), x = i.add(p).mul(s);
886
- return D(
887
- n.sample(f(d.x, d.y)).mul(u.x).mul(u.y),
888
- n.sample(f(x.x, d.y)).mul(h.x).mul(u.y),
889
- n.sample(f(m.x, d.y)).mul(c.x).mul(u.y),
890
- n.sample(f(d.x, x.y)).mul(u.x).mul(h.y),
891
- n.sample(f(x.x, x.y)).mul(h.x).mul(h.y),
892
- n.sample(f(m.x, x.y)).mul(c.x).mul(h.y),
893
- n.sample(f(d.x, m.y)).mul(u.x).mul(c.y),
894
- n.sample(f(x.x, m.y)).mul(h.x).mul(c.y),
895
- n.sample(f(m.x, m.y)).mul(c.x).mul(c.y)
1028
+ const $n = (...s) => new Po(...s), Fo = ["x", "y", "z", "w"], qn = /* @__PURE__ */ L(
1029
+ (s, e, t = 0) => {
1030
+ let o;
1031
+ if (typeof t == "number")
1032
+ o = t;
1033
+ else if (t?.isConstNode === !0)
1034
+ o = t.value;
1035
+ else
1036
+ throw new Error("Component must be a constant.");
1037
+ const n = s.size(), i = O(e.mul(n).sub(0.5).floor()).toConst(), r = yt(i, i.add(1)).toConst(), c = Fo[o];
1038
+ return z(
1039
+ s.load(r.xw)[c],
1040
+ // min, max
1041
+ s.load(r.zw)[c],
1042
+ // max, max
1043
+ s.load(r.zy)[c],
1044
+ // max, min
1045
+ s.load(r.xy)[c]
1046
+ // min, min
1047
+ );
1048
+ }
1049
+ ), Gn = /* @__PURE__ */ L(
1050
+ (s, e = I()) => {
1051
+ const t = f(s.size()), o = t.reciprocal(), n = e.mul(t), i = n.sub(0.5).floor().add(0.5), r = n.sub(i), c = r.mul(r.mul(r.mul(0.5).oneMinus()).sub(0.5)), a = r.mul(r).mul(r.mul(1.5).sub(2.5)).add(1), h = r.mul(r.mul(ie(2, r.mul(1.5))).add(0.5)), l = r.mul(r).mul(r.mul(0.5).sub(0.5)), u = a.add(h), p = h.div(a.add(h)), d = i.sub(1).mul(o), m = i.add(2).mul(o), x = i.add(p).mul(o);
1052
+ return B(
1053
+ s.sample(f(d.x, d.y)).mul(c.x).mul(c.y),
1054
+ s.sample(f(x.x, d.y)).mul(u.x).mul(c.y),
1055
+ s.sample(f(m.x, d.y)).mul(l.x).mul(c.y),
1056
+ s.sample(f(d.x, x.y)).mul(c.x).mul(u.y),
1057
+ s.sample(f(x.x, x.y)).mul(u.x).mul(u.y),
1058
+ s.sample(f(m.x, x.y)).mul(l.x).mul(u.y),
1059
+ s.sample(f(d.x, m.y)).mul(c.x).mul(l.y),
1060
+ s.sample(f(x.x, m.y)).mul(u.x).mul(l.y),
1061
+ s.sample(f(m.x, m.y)).mul(l.x).mul(l.y)
896
1062
  );
897
1063
  }
898
- ), _s = (n, e, t, { perspective: s = !0, logarithmic: o = !1 } = {}) => o ? pt(n, e, t) : s ? mt(n, e, t) : us(n, e, t), Ae = (n, e, t) => {
899
- const s = pt(n, e, t);
900
- return hs(s, e, t);
901
- }, Yo = (n, e, t) => {
902
- const s = mt(n, e, t);
903
- return dt(s, e, t);
904
- }, Xo = (n, e, t, s, o) => {
905
- const i = s.element(Z(2)).element(Z(3)), r = s.element(Z(3)).element(Z(3)), a = b(N(n.flipY(), e).mul(2).sub(1), 1).mul(t.mul(i).add(r));
906
- return o.mul(a).xyz;
907
- }, Ze = [
908
- /* @__PURE__ */ N(58.1375, 2.7747, 26.8183),
909
- /* @__PURE__ */ N(-150.5666, 4.2109, -88.5066),
910
- /* @__PURE__ */ N(130.5887, -14.0195, 109.0745),
911
- /* @__PURE__ */ N(-42.3277, 4.8052, -60.1097),
912
- /* @__PURE__ */ N(4.5974, 2.1856, 12.5925),
913
- /* @__PURE__ */ N(0.1357, 0.0914, 0.1067)
914
- ], Js = (n) => Ze.slice(1).reduce((e, t) => t.add(n.mul(e)), Ze[0]), Zo = (n, e, t, s) => {
915
- const o = _s(n, e, t, s);
916
- return Js(dt(o, e, t));
917
- }, Qo = (n) => {
918
- const e = ue(0.5, n.x).mul(ls), t = ue(n.y, 0.5).mul(cs), s = We(t);
919
- return N(s.mul(We(e)), Ge(t), s.mul(Ge(e)));
920
- }, R = 64;
921
- function ge(n) {
922
- return Math.floor(Math.max(0, n) / R);
1064
+ ), D = 64;
1065
+ function Te(s) {
1066
+ return Math.floor(Math.max(0, s) / D);
923
1067
  }
924
- class eo {
1068
+ class Oo {
925
1069
  constructor() {
926
1070
  this.size = [0, 0, 0], this.offset = { x: 0, y: 0 };
927
1071
  }
@@ -929,22 +1073,22 @@ class eo {
929
1073
  return [this.size[0], this.size[1], this.size[2]] = e.size, this.offset.x = e.offset.x, this.offset.y = e.offset.y, this;
930
1074
  }
931
1075
  }
932
- const to = /* @__PURE__ */ new tt(), so = /* @__PURE__ */ new it(), oo = /* @__PURE__ */ new P(), no = /* @__PURE__ */ new ne();
933
- class io extends _ {
934
- constructor(e, t, s) {
935
- super("float"), this.sampleCount = 60, this.hardShadowSamples = 4, this.fadeOutSamples = 8, this.thickness = g(5e-3), this.shadowContrast = g(4), this.shadowIntensity = g(1), this.bilinearThreshold = g(0.02), this.nearDepth = g(0), this.farDepth = g(1), this.lightCoordinate = g(new it()), this.dispatchOffset = g(new P(), "ivec2"), this.dispatchIndex = g(0), this.dispatches = Array.from(
1076
+ const Uo = /* @__PURE__ */ new St(), jo = /* @__PURE__ */ new Ws(), Eo = /* @__PURE__ */ new ve(), ko = /* @__PURE__ */ new Se();
1077
+ class Io extends Q {
1078
+ constructor(e, t, o) {
1079
+ super("float"), this.sampleCount = 60, this.hardShadowSamples = 4, this.fadeOutSamples = 8, this.thickness = g(5e-3), this.shadowContrast = g(4), this.shadowIntensity = g(1), this.bilinearThreshold = g(0.02), this.lightCoordinate = g("vec4"), this.dispatchOffset = g("ivec2"), this.dispatchIndex = g(0), this.dispatches = Array.from(
936
1080
  // Populate the max number of dispatches
937
1081
  { length: 8 },
938
- () => new eo()
939
- ), this.dispatchCount = 0, this.depthNode = e, this.camera = t, this.mainLight = s;
940
- const o = new bs(1, 1);
941
- o.colorSpace = Pt, o.minFilter = ae, o.magFilter = ae, o.generateMipmaps = !1, o.name = "ScreenSpaceShadowNode", this.outputTexture = o, this.textureNode = Oe(this, o), this.updateBeforeType = Q.FRAME;
1082
+ () => new Oo()
1083
+ ), this.dispatchCount = 0, this.updateBeforeType = H.FRAME, this.depthNode = e, this.camera = t, this.mainLight = o;
1084
+ const n = new Ds(1, 1);
1085
+ n.colorSpace = Ls, n.minFilter = ue, n.magFilter = ue, n.generateMipmaps = !1, n.name = "ScreenSpaceShadow", this.outputTexture = n, this.textureNode = $e(this, n), this.computeNode = this.createComputeNode();
942
1086
  }
943
1087
  get type() {
944
1088
  return "ScreenSpaceShadowNode";
945
1089
  }
946
1090
  customCacheKey() {
947
- return je(
1091
+ return We(
948
1092
  this.camera?.id ?? -1,
949
1093
  this.mainLight?.id ?? -1,
950
1094
  this.sampleCount,
@@ -956,173 +1100,201 @@ class io extends _ {
956
1100
  return this.textureNode;
957
1101
  }
958
1102
  setSize(e, t) {
959
- const { outputTexture: s } = this;
960
- return (e !== s.width || t !== s.height) && (s.setSize(e, t, 0), s.needsUpdate = !0), this;
1103
+ const { outputTexture: o } = this;
1104
+ return (e !== o.width || t !== o.height) && (o.setSize(e, t, 0), o.needsUpdate = !0), this;
961
1105
  }
962
1106
  updateBefore(e) {
963
1107
  const { renderer: t } = e;
964
1108
  if (t == null)
965
1109
  return;
966
- const s = t.getDrawingBufferSize(oo);
967
- this.setSize(s.width, s.height);
968
- const { camera: o, mainLight: i } = this, r = no.multiplyMatrices(
969
- o.projectionMatrix,
970
- o.matrixWorldInverse
971
- ), u = to.copy(i.position).sub(i.target.position).normalize(), a = so.set(u.x, u.y, u.z, 0).applyMatrix4(r);
972
- this.updateDispatchList(a, s), w(this.computeNode != null);
973
- for (let l = 0; l < this.dispatchCount; ++l) {
974
- const c = this.dispatches[l];
975
- this.dispatchOffset.value.set(c.offset.x, c.offset.y), this.dispatchIndex.value = l, t.compute(this.computeNode, c.size);
1110
+ const o = t.getDrawingBufferSize(Eo);
1111
+ this.setSize(o.width, o.height);
1112
+ const { camera: n, mainLight: i } = this, r = ko.multiplyMatrices(
1113
+ n.projectionMatrix,
1114
+ n.matrixWorldInverse
1115
+ ), c = Uo.copy(i.position).sub(i.target.position).normalize(), a = jo.set(c.x, c.y, c.z, 0).applyMatrix4(r);
1116
+ this.updateDispatchList(a, o);
1117
+ for (let h = 0; h < this.dispatchCount; ++h) {
1118
+ const l = this.dispatches[h];
1119
+ this.dispatchOffset.value.set(l.offset.x, l.offset.y), this.dispatchIndex.value = h, t.compute(this.computeNode, l.size);
976
1120
  }
977
1121
  }
978
1122
  // See bend_sss_cpu.h
979
- updateDispatchList(e, { width: t, height: s }) {
980
- let o = e.w;
981
- const i = 2e-6 * R;
982
- o >= 0 && o < i ? o = i : o < 0 && o > -i && (o = -i), this.lightCoordinate.value.set(
983
- (e.x / o * 0.5 + 0.5) * t,
984
- (e.y / o * -0.5 + 0.5) * s,
1123
+ updateDispatchList(e, { width: t, height: o }) {
1124
+ let n = e.w;
1125
+ const i = 2e-6 * D;
1126
+ n >= 0 && n < i ? n = i : n < 0 && n > -i && (n = -i), this.lightCoordinate.value.set(
1127
+ (e.x / n * 0.5 + 0.5) * t,
1128
+ (e.y / n * -0.5 + 0.5) * o,
985
1129
  e.w === 0 ? 0 : e.z / e.w,
986
1130
  e.w > 0 ? 1 : -1
987
1131
  );
988
- const r = Math.round(this.lightCoordinate.value.x), u = Math.round(this.lightCoordinate.value.y), a = -r, l = -(s - u), c = t - r, h = u;
1132
+ const r = Math.round(this.lightCoordinate.value.x), c = Math.round(this.lightCoordinate.value.y), a = -r, h = -(o - c), l = t - r, u = c;
989
1133
  let p = 0;
990
1134
  for (let d = 0; d < 4; ++d) {
991
- const m = d === 0 || d === 3, x = (d & 1) > 0, z = (d & 2) > 0, T = ge(x ? a : -c), B = ge(z ? l : -h), O = R * (m ? 1 : 2) - 1, C = R * (m ? 2 : 1) - 1, V = ge((x ? c : -a) + O), S = ge((z ? h : -l) + C);
992
- if (V - T > 0 && S - B > 0) {
993
- const H = d === 2 || d === 3 ? 1 : 0, U = d === 1 || d === 3 ? 1 : 0, v = this.dispatches[p++];
994
- v.size[0] = R, v.size[1] = V - T, v.size[2] = S - B, v.offset.x = (x ? T : -V) + H, v.offset.y = (z ? -S : B) + U;
1135
+ const m = d === 0 || d === 3, x = (d & 1) > 0, w = (d & 2) > 0, T = Te(x ? a : -l), C = Te(w ? h : -u), j = D * (m ? 1 : 2) - 1, R = D * (m ? 2 : 1) - 1, F = Te((x ? l : -a) + j), b = Te((w ? u : -h) + R);
1136
+ if (F - T > 0 && b - C > 0) {
1137
+ const k = d === 2 || d === 3 ? 1 : 0, W = d === 1 || d === 3 ? 1 : 0, v = this.dispatches[p++];
1138
+ v.size[0] = D, v.size[1] = F - T, v.size[2] = b - C, v.offset.x = (x ? T : -F) + k, v.offset.y = (w ? -b : C) + W;
995
1139
  let A;
996
- if (d === 0 ? A = a - l : d === 1 ? A = c + l : d === 2 ? A = -a - h : A = -c + h, A = (A + R - 1) / R | 0, A > 0) {
997
- const y = this.dispatches[p++].copy(v);
998
- d === 0 ? (y.size[2] = Math.min(v.size[2], A), v.size[2] -= y.size[2], y.offset.y = v.offset.y + v.size[2], y.offset.x -= 1, y.size[1] += 1) : d === 1 ? (y.size[1] = Math.min(v.size[1], A), v.size[1] -= y.size[1], y.offset.x = v.offset.x + v.size[1], y.size[2] += 1) : d === 2 ? (y.size[1] = Math.min(v.size[1], A), v.size[1] -= y.size[1], v.offset.x += y.size[1], y.size[2] += 1, y.offset.y -= 1) : d === 3 && (y.size[2] = Math.min(v.size[2], A), v.size[2] -= y.size[2], v.offset.y += y.size[2], ++y.size[1]), (y.size[1] <= 0 || y.size[2] <= 0) && y.copy(this.dispatches[--p]), (v.size[1] <= 0 || v.size[2] <= 0) && v.copy(this.dispatches[--p]);
1140
+ if (d === 0 ? A = a - h : d === 1 ? A = l + h : d === 2 ? A = -a - u : A = -l + u, A = (A + D - 1) / D | 0, A > 0) {
1141
+ const N = this.dispatches[p++].copy(v);
1142
+ d === 0 ? (N.size[2] = Math.min(v.size[2], A), v.size[2] -= N.size[2], N.offset.y = v.offset.y + v.size[2], N.offset.x -= 1, N.size[1] += 1) : d === 1 ? (N.size[1] = Math.min(v.size[1], A), v.size[1] -= N.size[1], N.offset.x = v.offset.x + v.size[1], N.size[2] += 1) : d === 2 ? (N.size[1] = Math.min(v.size[1], A), v.size[1] -= N.size[1], v.offset.x += N.size[1], N.size[2] += 1, N.offset.y -= 1) : d === 3 && (N.size[2] = Math.min(v.size[2], A), v.size[2] -= N.size[2], v.offset.y += N.size[2], ++N.size[1]), (N.size[1] <= 0 || N.size[2] <= 0) && N.copy(this.dispatches[--p]), (v.size[1] <= 0 || v.size[2] <= 0) && v.copy(this.dispatches[--p]);
999
1143
  }
1000
1144
  }
1001
1145
  }
1002
1146
  for (let d = 0; d < p; ++d) {
1003
1147
  const m = this.dispatches[d];
1004
- m.offset.x *= R, m.offset.y *= R;
1148
+ m.offset.x *= D, m.offset.y *= D;
1005
1149
  }
1006
1150
  this.dispatchCount = p;
1007
1151
  }
1008
1152
  // See bend_sss_gpu.h
1009
- setupCompute(e) {
1153
+ createComputeNode() {
1010
1154
  const {
1011
- depthNode: t,
1012
- camera: s,
1155
+ depthNode: e,
1156
+ camera: t,
1013
1157
  sampleCount: o,
1014
- hardShadowSamples: i,
1015
- fadeOutSamples: r,
1016
- outputTexture: u,
1017
- thickness: a,
1018
- shadowContrast: l,
1019
- shadowIntensity: c,
1020
- bilinearThreshold: h,
1021
- farDepth: p,
1022
- nearDepth: d,
1023
- lightCoordinate: m,
1024
- dispatchOffset: x
1025
- } = this, z = Math.floor(o / R) + 2, T = ds("float", z * R), B = () => {
1026
- const C = j(qe.yz).mul(R).add(x).toConst(), V = m.xy.floor().add(0.5).toConst(), S = m.xy.sub(V).toConst(), H = m.w.greaterThan(0), U = j(C.sign()).toConst(), v = X(C.x.add(U.y)).lessThan(X(C.y.sub(U.x))).toConst(), A = j(
1027
- v.select(U.y, 0),
1028
- v.select(0, U.x.negate())
1029
- ), y = f(A.mul(qe.x).add(C)).toConst(), te = X(y.x).greaterThan(X(y.y)).toConst(), $ = te.select(y.x, y.y).toConst(), W = $.abs().toConst(), se = W.sub(R), I = te.select(S.x, S.y).toVar();
1030
- I.assign(
1031
- $.greaterThan(0).select(I.negate(), I)
1158
+ hardShadowSamples: n,
1159
+ fadeOutSamples: i,
1160
+ outputTexture: r,
1161
+ thickness: c,
1162
+ shadowContrast: a,
1163
+ shadowIntensity: h,
1164
+ bilinearThreshold: l,
1165
+ lightCoordinate: u,
1166
+ dispatchOffset: p
1167
+ } = this, d = Math.floor(o / D) + 2, m = fs("float", d * D), x = () => {
1168
+ const w = O(Ke.yz).mul(D).add(p).toConst(), T = u.xy.floor().add(0.5).toConst(), C = u.xy.sub(T).toConst(), j = u.w.greaterThan(0), R = O(w.sign()).toConst(), F = _(w.x.add(R.y)).lessThan(_(w.y.sub(R.x))).toConst(), b = O(
1169
+ F.select(R.y, 0),
1170
+ F.select(0, R.x.negate())
1171
+ ), k = f(b.mul(Ke.x).add(w)).toConst(), W = _(k.x).greaterThan(_(k.y)).toConst(), v = W.select(k.x, k.y).toConst(), A = v.abs().toConst(), N = A.sub(D), $ = W.select(C.x, C.y).toVar();
1172
+ $.assign(
1173
+ v.greaterThan(0).select($.negate(), $)
1032
1174
  );
1033
- const G = y.add(V).toConst(), E = re(
1034
- m.xy,
1035
- G,
1036
- se.add(I).div(W.add(I))
1037
- ).toConst(), fe = G.sub(E).toConst(), Y = pe(
1038
- H.select(
1039
- xe,
1040
- xe.bitXor(R - 1)
1175
+ const Y = k.add(T).toConst(), X = ne(
1176
+ u.xy,
1177
+ Y,
1178
+ N.add($).div(A.add($))
1179
+ ).toConst(), ee = Y.sub(X).toConst(), te = G(
1180
+ j.select(
1181
+ we,
1182
+ we.bitXor(D - 1)
1041
1183
  )
1042
- ).toConst(), M = re(G, E, Y.div(R)).toVar(), L = W.sub(Y).add(I).toConst();
1043
- return { pixelXY: M, pixelDistance: L, xyDelta: fe, xAxisMajor: te };
1044
- }, O = (C) => {
1045
- const V = t.load(C).toVar();
1046
- return e.renderer.logarithmicDepthBuffer && V.assign(
1047
- Ae(
1048
- V,
1049
- Ve(s),
1050
- Be(s)
1051
- )
1052
- ), ft(
1053
- C.greaterThanEqual(0).all(),
1054
- C.lessThan(ve(t)).all()
1055
- ).select(V, p);
1184
+ ).toConst(), Z = ne(Y, X, te.div(D)).toVar(), q = A.sub(te).add($).toConst();
1185
+ return { pixelXY: Z, pixelDistance: q, xyDelta: ee, xAxisMajor: W };
1056
1186
  };
1057
- this.computeNode = k(() => {
1058
- const { pixelXY: C, xyDelta: V, pixelDistance: S, xAxisMajor: H } = B(), U = m.w.negate(), v = d.greaterThan(p).select(-1, 1).toConst(), A = j(C.floor()).toConst();
1059
- let y, te, $;
1060
- for (let M = 0; M < z; ++M) {
1061
- const L = j(C.floor()).toConst(), de = H.select(C.y, C.x).fract().sub(0.5).greaterThan(0).select(1, -1).toConst(), St = j(
1062
- H.select(0, de),
1063
- H.select(de, 0)
1064
- ), oe = O(L).toConst(), Ie = O(L.add(St)).toConst(), Ee = p.sub(oe).abs().toConst(), Nt = ps(
1065
- oe.sub(Ie).abs(),
1066
- Ee.mul(h)
1067
- ), Mt = oe.add(
1068
- X(oe.sub(Ie)).mul(v)
1069
- ), bt = Nt.select(oe, Mt), be = M === 0 ? S : U.mul(R * M).add(S).toConst();
1070
- let ze = bt.sub(m.z).div(be).toConst();
1071
- M > 0 && (ze = be.greaterThan(0).select(ze, 1e10).toConst()), T.element(xe.add(R * M)).assign(ze), M === 0 && (y = oe, te = Ee, $ = be), C.addAssign(V.mul(U));
1187
+ return U((w) => {
1188
+ const [T, C] = w.renderer.reversedDepthBuffer ? [G(1), G(0)] : [G(0), G(1)], j = (S) => {
1189
+ let P = e.load(S);
1190
+ return w.renderer.logarithmicDepthBuffer && (P = Ue(
1191
+ P,
1192
+ fe(t),
1193
+ xe(t)
1194
+ )), P = P.toConst(), wt(
1195
+ S.greaterThanEqual(0).all(),
1196
+ S.lessThan(e.size()).all()
1197
+ ).select(P, C);
1198
+ }, { pixelXY: R, xyDelta: F, pixelDistance: b, xAxisMajor: k } = x(), W = u.w.negate(), v = T.greaterThan(C).select(-1, 1).toConst(), A = O(R.floor()).toConst();
1199
+ let N, $, Y;
1200
+ for (let S = 0; S < d; ++S) {
1201
+ const P = O(R.floor()).toConst(), de = k.select(R.y, R.x).fract().sub(0.5).greaterThan(0).select(1, -1).toConst(), Ft = O(
1202
+ k.select(0, de),
1203
+ k.select(de, 0)
1204
+ ), se = j(P).toConst(), He = j(P.add(Ft)).toConst(), Ye = C.sub(se).abs().toConst(), Ot = xs(
1205
+ se.sub(He).abs(),
1206
+ Ye.mul(l)
1207
+ ), Ut = se.add(
1208
+ _(se.sub(He)).mul(v)
1209
+ ), jt = Ot.select(se, Ut), De = S === 0 ? b : W.mul(D * S).add(b).toConst();
1210
+ let Be = jt.sub(u.z).div(De).toConst();
1211
+ S > 0 && (Be = De.greaterThan(0).select(Be, 1e10).toConst()), m.element(we.add(D * S)).assign(Be), S === 0 && (N = se, $ = Ye, Y = De), R.addAssign(F.mul(W));
1072
1212
  }
1073
- ms();
1074
- const W = y.sub(m.z).div($).toVar(), se = $.add(U).min(a.reciprocal()).mul($).div(te).toConst();
1075
- W.assign(W.mul(se).sub(v));
1076
- const I = xe.add(1).toConst(), G = pe(1).toVar();
1077
- for (let M = 0; M < i; ++M) {
1078
- const L = W.sub(T.element(I.add(M)).mul(se)).abs();
1079
- G.assign(G.min(L));
1213
+ gs();
1214
+ const X = N.sub(u.z).div(Y).toVar(), ee = Y.add(W).min(c.reciprocal()).mul(Y).div($).toConst();
1215
+ X.assign(X.mul(ee).sub(v));
1216
+ const te = we.add(1).toConst(), Z = G(1).toVar();
1217
+ for (let S = 0; S < n; ++S) {
1218
+ const P = X.sub(m.element(te.add(S)).mul(ee)).abs();
1219
+ Z.assign(Z.min(P));
1080
1220
  }
1081
- const E = b(1).toVar();
1082
- for (let M = i; M < o - r; ++M) {
1083
- const L = W.sub(T.element(I.add(M)).mul(se)).abs(), he = Z(M & 3).toConst();
1084
- E.element(he).assign(E.element(he).min(L));
1221
+ const q = z(1).toVar();
1222
+ for (let S = n; S < o - i; ++S) {
1223
+ const P = X.sub(m.element(te.add(S)).mul(ee)).abs(), he = K(S & 3).toConst();
1224
+ q.element(he).assign(q.element(he).min(P));
1085
1225
  }
1086
- for (let M = o - r; M < o; ++M) {
1087
- const L = W.sub(T.element(I.add(M)).mul(se)).abs(), he = (M + 1 - (o - r)) / (r + 1) * 0.75, de = Z(M & 3).toConst();
1088
- E.element(de).assign(E.element(de).min(L.add(he)));
1226
+ for (let S = o - i; S < o; ++S) {
1227
+ const P = X.sub(m.element(te.add(S)).mul(ee)).abs(), he = (S + 1 - (o - i)) / (i + 1) * 0.75, de = K(S & 3).toConst();
1228
+ q.element(de).assign(q.element(de).min(P.add(he)));
1089
1229
  }
1090
- const fe = l.oneMinus().toConst();
1091
- G.assign(
1092
- G.mul(l).add(fe).saturate()
1093
- ), E.assign(
1094
- E.mul(l).add(fe).saturate()
1230
+ const Ge = a.oneMinus().toConst();
1231
+ Z.assign(
1232
+ Z.mul(a).add(Ge).saturate()
1233
+ ), q.assign(
1234
+ q.mul(a).add(Ge).saturate()
1095
1235
  );
1096
- const Y = pe().toVar();
1097
- Y.assign(E.dot(b(0.25))), Y.assign(ht(G, Y)), fs(u, A, re(1, Y, c));
1098
- })().compute(
1099
- 0,
1100
- // Determine this later
1101
- [R, 1, 1]
1102
- );
1236
+ const ye = G(0).toVar();
1237
+ ye.assign(q.dot(z(0.25))), ye.assign(ft(Z, ye)), vs(r, A, ne(1, ye, h));
1238
+ })().computeKernel([D, 1, 1]);
1103
1239
  }
1104
1240
  setup(e) {
1105
- return this.setupCompute(e), this.textureNode;
1241
+ return this.textureNode;
1106
1242
  }
1107
1243
  dispose() {
1108
1244
  this.outputTexture.dispose();
1109
1245
  }
1110
1246
  }
1111
- const Ko = (...n) => new io(...n);
1112
- function Qe(n, e) {
1113
- let t = 1, s = 0;
1114
- for (; n > 0; )
1115
- t /= e, s += t * (n % e), n = Math.floor(n / e);
1116
- return s;
1247
+ const Hn = (...s) => new Io(...s), Lo = /* @__PURE__ */ (() => {
1248
+ const s = new Bs(new Uint8Array(1));
1249
+ return s.format = As, s.minFilter = Qe, s.magFilter = Qe, s.wrapS = Ve, s.wrapT = Ve, s.wrapR = Ve, s.needsUpdate = !0, s;
1250
+ })();
1251
+ class Wo extends Nt {
1252
+ constructor() {
1253
+ super(Lo), this.url = Hs;
1254
+ }
1255
+ customCacheKey() {
1256
+ return Xs(this.url);
1257
+ }
1258
+ setup(e) {
1259
+ return new Ys().loadAsync(this.url).then((t) => {
1260
+ this.value = t;
1261
+ }).catch((t) => {
1262
+ console.error(t);
1263
+ }), super.setup(e);
1264
+ }
1117
1265
  }
1118
- const Ke = /* @__PURE__ */ Array.from(
1266
+ const $o = /* @__PURE__ */ pt(Wo), Yn = /* @__PURE__ */ U(() => $o.sample(M(ke.xy, ys.mod(64)).div(M(128, 128, 64))).r.toConst("stbn")).once()();
1267
+ class qo extends Vs {
1268
+ static get type() {
1269
+ return "StorageTexture3DNode";
1270
+ }
1271
+ getDefaultUV() {
1272
+ return M(0.5, 0.5, 0.5);
1273
+ }
1274
+ setUpdateMatrix(e) {
1275
+ }
1276
+ generateUV(e, t) {
1277
+ return t.build(e, this.sampler ? "vec3" : "ivec3");
1278
+ }
1279
+ generateOffset(e, t) {
1280
+ return t.build(e, "ivec3");
1281
+ }
1282
+ }
1283
+ const Xn = (...s) => new qo(...s);
1284
+ function ot(s, e) {
1285
+ let t = 1, o = 0;
1286
+ for (; s > 0; )
1287
+ t /= e, o += t * (s % e), s = Math.floor(s / e);
1288
+ return o;
1289
+ }
1290
+ const nt = /* @__PURE__ */ Array.from(
1119
1291
  { length: 16 },
1120
- (n, e) => new P(Qe(e + 1, 2), Qe(e + 1, 3))
1121
- ), { resetRendererState: ro, restoreRendererState: ao } = me;
1122
- function uo(n) {
1123
- return n.isPerspectiveCamera === !0 || n.isOrthographicCamera === !0 || "updateProjectionMatrix" in n && "setViewOffset" in n && "clearViewOffset" in n;
1292
+ (s, e) => new ve(ot(e + 1, 2), ot(e + 1, 3))
1293
+ ), { resetRendererState: Go, restoreRendererState: Ho } = ge;
1294
+ function Yo(s) {
1295
+ return s.isPerspectiveCamera === !0 || s.isOrthographicCamera === !0 || "updateProjectionMatrix" in s && "setViewOffset" in s && "clearViewOffset" in s;
1124
1296
  }
1125
- const lo = /* @__PURE__ */ we({
1297
+ const Xo = /* @__PURE__ */ V({
1126
1298
  name: "clipAABB",
1127
1299
  type: "vec4",
1128
1300
  inputs: [
@@ -1131,14 +1303,10 @@ const lo = /* @__PURE__ */ we({
1131
1303
  { name: "minColor", type: "vec4" },
1132
1304
  { name: "maxColor", type: "vec4" }
1133
1305
  ]
1134
- })(([n, e, t, s]) => {
1135
- const o = s.rgb.add(t.rgb).mul(0.5).toConst(), i = s.rgb.sub(t.rgb).mul(0.5).add(1e-7), r = e.sub(b(o, n.a)).toConst(), a = r.xyz.div(i).abs().toConst(), l = xt(a.x, a.y, a.z).toConst();
1136
- return ys(
1137
- l.greaterThan(1),
1138
- b(o, n.a).add(r.div(l)),
1139
- e
1140
- );
1141
- }), _e = [
1306
+ })(([s, e, t, o]) => {
1307
+ const n = o.rgb.add(t.rgb).mul(0.5).toConst(), i = o.rgb.sub(t.rgb).mul(0.5).add(1e-7), r = e.sub(z(n, s.a)).toConst(), a = r.xyz.div(i).abs().toConst(), h = Tt(a.x, a.y, a.z).toConst();
1308
+ return h.greaterThan(1).select(z(n, s.a).add(r.div(h)), e);
1309
+ }), it = [
1142
1310
  [-1, -1],
1143
1311
  [-1, 1],
1144
1312
  [1, -1],
@@ -1147,17 +1315,17 @@ const lo = /* @__PURE__ */ we({
1147
1315
  [0, -1],
1148
1316
  [0, 1],
1149
1317
  [-1, 0]
1150
- ], co = /* @__PURE__ */ ee(
1151
- (n, e, t, s, o) => {
1318
+ ], Zo = /* @__PURE__ */ L(
1319
+ (s, e, t, o, n) => {
1152
1320
  const i = t.toVar(), r = t.pow2().toVar();
1153
- for (const [p, d] of _e) {
1154
- const m = n.load(e.add(j(p, d))).toConst();
1321
+ for (const [p, d] of it) {
1322
+ const m = s.load(e.add(O(p, d))).toConst();
1155
1323
  i.addAssign(m), r.addAssign(m.pow2());
1156
1324
  }
1157
- const u = _e.length + 1, a = i.div(u).toConst(), l = Se(r.div(u).sub(a.pow2()).max(0)).mul(o).toConst(), c = a.sub(l).toConst(), h = a.add(l).toConst();
1158
- return lo(a.clamp(c, h), s, c, h);
1325
+ const c = it.length + 1, a = i.div(c).toConst(), h = be(r.div(c).sub(a.pow2()).max(0)).mul(n).toConst(), l = a.sub(h).toConst(), u = a.add(h).toConst();
1326
+ return Xo(a.clamp(l, u), o, l, u);
1159
1327
  }
1160
- ), ho = [
1328
+ ), _o = [
1161
1329
  [-1, -1],
1162
1330
  [-1, 0],
1163
1331
  [-1, 1],
@@ -1167,70 +1335,71 @@ const lo = /* @__PURE__ */ we({
1167
1335
  [1, -1],
1168
1336
  [1, 0],
1169
1337
  [1, 1]
1170
- ], po = /* @__PURE__ */ Pe({
1338
+ ], Ko = /* @__PURE__ */ Ie({
1171
1339
  closestCoord: "ivec2",
1172
1340
  closestDepth: "float"
1173
- }), mo = /* @__PURE__ */ ee(
1174
- (n, e) => {
1175
- const t = j(0).toVar(), s = pe(1).toVar();
1176
- for (const [o, i] of ho) {
1177
- const r = e.add(j(o, i)).toConst(), u = n.load(r).r.toConst();
1178
- K(u.lessThan(s), () => {
1179
- t.assign(r), s.assign(u);
1341
+ }), Qo = /* @__PURE__ */ L(
1342
+ (s, e) => (t) => {
1343
+ const o = O(0).toVar(), n = G(1).toVar();
1344
+ for (const [i, r] of _o) {
1345
+ const c = e.add(O(i, r)).toConst();
1346
+ let a = s.load(c).r;
1347
+ t.renderer.reversedDepthBuffer && (a = a.oneMinus()), a = a.toConst(), ae(a.lessThan(n), () => {
1348
+ o.assign(c), n.assign(a);
1180
1349
  });
1181
1350
  }
1182
- return po(t, s);
1351
+ return Ko(o, n);
1183
1352
  }
1184
- ), fo = ee(
1185
- (n, e) => {
1186
- const s = n.mul(e).fract().abs(), o = xt(s, s.oneMinus());
1187
- return o.x.mul(o.y).oneMinus().div(0.75);
1353
+ ), Jo = /* @__PURE__ */ L(
1354
+ (s, e) => {
1355
+ const o = s.mul(e).fract().abs(), n = Tt(o, o.oneMinus());
1356
+ return n.x.mul(n.y).oneMinus().div(0.75);
1188
1357
  }
1189
- ), Je = /* @__PURE__ */ new P(), xo = /* @__PURE__ */ new Ft(1, 1);
1190
- class et extends _ {
1191
- constructor(e, t, s, o) {
1192
- if (super("vec4"), this.temporalAlpha = g(0.05), this.varianceGamma = g(1), this.velocityThreshold = g(0.1), this.depthError = g(1e-3), this.debugShowRejection = !1, this.resolveRT = this.createRenderTarget("Resolve"), this.historyRT = this.createRenderTarget("History"), this.resolveMaterial = new le(), this.mesh = new Ne(), this.needsSyncPostProcessing = !1, this.needsClearHistory = !1, this.resolveNode = ie(this.resolveRT.texture), this.historyNode = ie(this.historyRT.texture), this.previousDepthNode = ie(xo), this.originalProjectionMatrix = new ne(), this.jitterIndex = 0, this.inputNode = e, this.depthNode = t, this.velocityNode = s, !uo(o))
1358
+ ), rt = /* @__PURE__ */ new ve(), en = /* @__PURE__ */ new $s(1, 1);
1359
+ class at extends Q {
1360
+ constructor(e, t, o, n) {
1361
+ if (super("vec4"), this.temporalAlpha = g(0.05), this.varianceGamma = g(1), this.velocityThreshold = g(0.1), this.depthError = g(1e-3), this.debugShowRejection = !1, this.resolveRT = this.createRenderTarget("resolve"), this.historyRT = this.createRenderTarget("history"), this.resolveMaterial = new ce(), this.mesh = new ze(), this.needsSyncRenderPipeline = !1, this.needsClearHistory = !1, this.resolveNode = oe(this.resolveRT.texture), this.historyNode = oe(this.historyRT.texture), this.previousDepthNode = oe(en), this.originalProjectionMatrix = new Se(), this.jitterIndex = 0, this.updateBeforeType = H.FRAME, this.resolveMaterial.name = "TemporalAntialias_resolve", this.mesh.name = "TemporalAntialias", this.inputNode = e, this.depthNode = t, this.velocityNode = o, !Yo(n))
1193
1362
  throw new Error("The provided camera is not supported.");
1194
- this.camera = o, this.textureNode = Oe(this, this.resolveRT.texture), this.updateBeforeType = Q.FRAME;
1363
+ this.camera = n, this.textureNode = $e(this, this.resolveRT.texture);
1195
1364
  }
1196
1365
  static get type() {
1197
1366
  return "TemporalAntialiasNode";
1198
1367
  }
1199
1368
  customCacheKey() {
1200
- return je(this.camera.id, +this.debugShowRejection);
1369
+ return We(this.camera.id, +this.debugShowRejection);
1201
1370
  }
1202
1371
  createRenderTarget(e) {
1203
- const t = new st(1, 1, {
1372
+ const t = new Mt(1, 1, {
1204
1373
  depthBuffer: !1,
1205
- type: nt,
1206
- format: ot
1207
- }), s = t.texture;
1208
- s.minFilter = ae, s.magFilter = ae, s.generateMipmaps = !1;
1209
- const o = this.constructor.type;
1210
- return s.name = e != null ? `${o}.${e}` : o, t;
1374
+ type: Ct,
1375
+ format: zt
1376
+ }), o = t.texture;
1377
+ o.minFilter = ue, o.magFilter = ue, o.generateMipmaps = !1;
1378
+ const n = this.constructor.type;
1379
+ return o.name = e != null ? `${n}_${e}` : n, t;
1211
1380
  }
1212
1381
  getTextureNode() {
1213
1382
  return this.textureNode;
1214
1383
  }
1215
1384
  setSize(e, t) {
1216
- const { resolveRT: s, historyRT: o } = this;
1217
- return (e !== o.width || t !== o.height) && (s.setSize(e, t), o.setSize(e, t), this.needsClearHistory = !0), this;
1385
+ const { resolveRT: o, historyRT: n } = this;
1386
+ return (e !== n.width || t !== n.height) && (o.setSize(e, t), n.setSize(e, t), this.needsClearHistory = !0), this;
1218
1387
  }
1219
1388
  clearHistory(e) {
1220
1389
  e.setRenderTarget(this.resolveRT), e.clear(), e.setRenderTarget(this.historyRT), e.clear(), this.needsClearHistory = !1;
1221
1390
  }
1222
1391
  setViewOffset(e, t) {
1223
- const { camera: s } = this;
1224
- s.updateProjectionMatrix(), this.originalProjectionMatrix.copy(s.projectionMatrix), Ye.setProjectionMatrix(this.originalProjectionMatrix);
1225
- const o = Ke[this.jitterIndex], i = o.x - 0.5, r = o.y - 0.5;
1226
- s.setViewOffset(e, t, i, r, e, t);
1392
+ const { camera: o } = this;
1393
+ o.updateProjectionMatrix(), this.originalProjectionMatrix.copy(o.projectionMatrix), tt.setProjectionMatrix(this.originalProjectionMatrix);
1394
+ const n = nt[this.jitterIndex], i = n.x - 0.5, r = n.y - 0.5;
1395
+ o.setViewOffset(e, t, i, r, e, t);
1227
1396
  }
1228
1397
  clearViewOffset() {
1229
- this.camera.clearViewOffset(), Ye.setProjectionMatrix(null), this.jitterIndex = (this.jitterIndex + 1) % Ke.length;
1398
+ this.camera.clearViewOffset(), tt.setProjectionMatrix(null), this.jitterIndex = (this.jitterIndex + 1) % nt.length;
1230
1399
  }
1231
1400
  copyDepthTexture(e) {
1232
- const t = this.depthNode.value, s = this.previousDepthTexture ??= t.clone();
1233
- (s.image.width !== t.width || s.image.height !== t.height) && (s.image.width = t.width, s.image.height = t.height, s.needsUpdate = !0), e.copyTextureToTexture(t, s), this.previousDepthNode.value = s;
1401
+ const t = this.depthNode.value, o = this.previousDepthTexture ??= t.clone();
1402
+ (o.image.width !== t.width || o.image.height !== t.height) && (o.image.width = t.width, o.image.height = t.height, o.needsUpdate = !0), e.copyTextureToTexture(t, o), this.previousDepthNode.value = o;
1234
1403
  }
1235
1404
  swapBuffers() {
1236
1405
  const { resolveRT: e, historyRT: t } = this;
@@ -1239,136 +1408,153 @@ class et extends _ {
1239
1408
  updateBefore({ renderer: e }) {
1240
1409
  if (e == null)
1241
1410
  return;
1242
- const t = e.getDrawingBufferSize(Je);
1243
- this.setSize(t.x, t.y), this.rendererState = ro(e, this.rendererState), this.needsClearHistory && this.clearHistory(e), e.setRenderTarget(this.resolveRT), this.mesh.material = this.resolveMaterial, this.mesh.render(e), ao(e, this.rendererState), Tt(e) && this.copyDepthTexture(e), this.swapBuffers(), this.needsSyncPostProcessing && this.clearViewOffset();
1411
+ const t = e.getDrawingBufferSize(rt);
1412
+ this.setSize(t.x, t.y), this.rendererState = Go(e, this.rendererState), this.needsClearHistory && this.clearHistory(e), e.setRenderTarget(this.resolveRT), this.mesh.material = this.resolveMaterial, this.mesh.render(e), Ho(e, this.rendererState), Pt(e) && this.copyDepthTexture(e), this.swapBuffers(), this.needsSyncRenderPipeline && this.clearViewOffset();
1244
1413
  }
1245
1414
  setupResolveNode({ renderer: e }) {
1246
- const t = (s) => {
1247
- const { previousDepthNode: o } = this, i = o.load(j(s.mul(ve(o)).sub(0.5))).toConst();
1248
- return e.logarithmicDepthBuffer ? Ae(
1415
+ const t = (o) => {
1416
+ const { previousDepthNode: n } = this, i = n.load(O(o.mul(n.size()).sub(0.5))).toConst();
1417
+ return e.logarithmicDepthBuffer ? Ue(
1249
1418
  i,
1250
- Ve(this.camera),
1251
- Be(this.camera)
1252
- ) : i;
1419
+ fe(this.camera),
1420
+ xe(this.camera)
1421
+ ) : e.reversedDepthBuffer ? i.oneMinus() : i;
1253
1422
  };
1254
- return k(() => {
1255
- const s = j(ut), o = xs, i = mo(this.depthNode, s).toConst(), r = i.get("closestCoord"), u = i.get("closestDepth"), a = this.velocityNode.load(r).xyz.mul(N(0.5, -0.5, 0.5)).toConst(), l = a.xy.length().div(this.velocityThreshold).oneMinus().saturate(), c = o.sub(a.xy).toConst(), h = t(c), p = e.logarithmicDepthBuffer ? Ae(
1256
- u,
1257
- Ve(this.camera),
1258
- Be(this.camera)
1259
- ) : u, d = gs(
1423
+ return U(() => {
1424
+ const o = O(ke), n = ws, i = Qo(this.depthNode, o).toConst(), r = i.get("closestCoord"), c = i.get("closestDepth"), a = this.velocityNode.load(r).xyz.mul(M(0.5, -0.5, 0.5)).toConst(), h = a.xy.length().div(this.velocityThreshold).oneMinus().saturate(), l = n.sub(a.xy).toConst(), u = t(l), p = e.logarithmicDepthBuffer ? Ue(
1425
+ c,
1426
+ fe(this.camera),
1427
+ xe(this.camera)
1428
+ ) : c, d = Ts(
1260
1429
  p.add(a.z),
1261
- h.add(this.depthError)
1262
- ), m = l.mul(d), x = ft(
1263
- c.greaterThanEqual(0).all(),
1264
- c.lessThanEqual(1).all()
1265
- ).toFloat(), z = u.notEqual(1).toFloat(), T = this.inputNode.load(s).toVar();
1266
- return K(x.mul(z).mul(m).greaterThan(0), () => {
1267
- const B = ie(this.historyNode, c), O = co(
1430
+ u.add(this.depthError)
1431
+ ), m = h.mul(d), x = wt(
1432
+ l.greaterThanEqual(0).all(),
1433
+ l.lessThanEqual(1).all()
1434
+ ).toFloat(), w = c.notEqual(1).toFloat(), T = this.inputNode.load(o).toVar();
1435
+ return ae(x.mul(w).mul(m).greaterThan(0), () => {
1436
+ const C = oe(this.historyNode, l), j = Zo(
1268
1437
  this.inputNode,
1269
- s,
1438
+ o,
1270
1439
  T,
1271
- B,
1440
+ C,
1272
1441
  this.varianceGamma
1273
- ), C = re(
1442
+ ), R = ne(
1274
1443
  this.temporalAlpha,
1275
- 0.8,
1276
- fo(a.xy, ve(this.inputNode))
1444
+ 0.4,
1445
+ Jo(a.xy, Ns(this.inputNode))
1277
1446
  ).saturate();
1278
- T.assign(re(O, T, C));
1447
+ T.assign(ne(j, T, R));
1279
1448
  }).Else(() => {
1280
- this.debugShowRejection && T.assign(N(1, 0, 0));
1449
+ this.debugShowRejection && T.assign(M(1, 0, 0));
1281
1450
  }), T;
1282
1451
  })();
1283
1452
  }
1284
1453
  setup(e) {
1285
- const { context: t } = e.context.postProcessing ?? {};
1286
- if (t != null) {
1287
- const { onBeforePostProcessing: o } = t;
1288
- t.onBeforePostProcessing = () => {
1289
- o?.();
1290
- const i = e.renderer.getDrawingBufferSize(Je);
1291
- this.setViewOffset(i.width, i.height);
1292
- }, this.needsSyncPostProcessing = !0;
1454
+ const t = () => {
1455
+ const n = e.renderer.getDrawingBufferSize(rt);
1456
+ this.setViewOffset(n.width, n.height);
1457
+ };
1458
+ if (e.context.renderPipeline != null) {
1459
+ const { context: n } = e.context.renderPipeline;
1460
+ n.onBeforeRenderPipeline = t, this.needsSyncRenderPipeline = !0;
1461
+ }
1462
+ if (e.context.postProcessing != null) {
1463
+ const { context: n } = e.context.postProcessing;
1464
+ n.onBeforePostProcessing = t, this.needsSyncRenderPipeline = !0;
1293
1465
  }
1294
- const { resolveMaterial: s } = this;
1295
- return s.fragmentNode = this.setupResolveNode(e), s.needsUpdate = !0, this.textureNode.uvNode = this.inputNode.uvNode, this.textureNode;
1466
+ const { resolveMaterial: o } = this;
1467
+ return o.fragmentNode = this.setupResolveNode(e), o.needsUpdate = !0, this.textureNode.uvNode = this.inputNode.uvNode, this.textureNode;
1296
1468
  }
1297
1469
  dispose() {
1298
1470
  this.resolveRT.dispose(), this.historyRT.dispose(), this.previousDepthTexture?.dispose(), this.resolveMaterial.dispose(), this.mesh.geometry.dispose(), super.dispose();
1299
1471
  }
1300
1472
  }
1301
- function _o(...n) {
1302
- if (n.length === 1)
1303
- return (i, r, u, a) => new et(
1304
- De(i),
1473
+ function Zn(...s) {
1474
+ if (s.length === 1)
1475
+ return (i, r, c, a) => new at(
1476
+ Oe(i),
1305
1477
  r,
1306
- u,
1478
+ c,
1307
1479
  a
1308
1480
  );
1309
- const [e, t, s, o] = n;
1310
- return new et(
1311
- De(e),
1481
+ const [e, t, o, n] = s;
1482
+ return new at(
1483
+ Oe(e),
1312
1484
  t,
1313
- s,
1314
- o
1485
+ o,
1486
+ n
1315
1487
  );
1316
1488
  }
1317
1489
  export {
1318
- yt as DownsampleThresholdNode,
1319
- we as FnLayout,
1320
- ee as FnVar,
1321
- vt as GaussianBlurNode,
1322
- Is as HighpVelocityNode,
1323
- Es as KawaseBlurNode,
1324
- Xs as LensFlareNode,
1325
- Vs as MipmapBlurNode,
1326
- wt as MipmapSurfaceBlurNode,
1327
- Go as Node,
1328
- Ks as OutputTexture3DNode,
1329
- zs as OutputTextureNode,
1330
- io as ScreenSpaceShadowNode,
1331
- et as TemporalAntialiasNode,
1332
- Be as cameraFar,
1333
- Ve as cameraNear,
1334
- Co as cameraPositionWorld,
1335
- Ro as debugFragmentNode,
1336
- Vo as debugNode,
1337
- Do as debugVertexNode,
1338
- Zo as depthToColor,
1339
- _s as depthToViewZ,
1340
- jo as dithering,
1341
- Po as downsampleThreshold,
1342
- ko as equirectGrid,
1343
- Qo as equirectToDirectionWorld,
1344
- Fo as gaussianBlur,
1345
- Ye as highpVelocity,
1346
- Bo as hookFunction,
1347
- Us as interleavedGradientNoise,
1348
- bo as inverseProjectionMatrix,
1349
- zo as inverseViewMatrix,
1350
- Tt as isWebGPU,
1351
- Oo as kawaseBlur,
1352
- Io as lensFlare,
1353
- Ae as logarithmicToPerspectiveDepth,
1354
- Ao as mipmapBlur,
1355
- gt as mipmapBlurDownsample,
1356
- Ds as mipmapBlurUpsample,
1357
- Uo as mipmapSurfaceBlur,
1358
- qo as node,
1359
- Oe as outputTexture,
1360
- Ho as outputTexture3D,
1361
- Yo as perspectiveToLogarithmicDepth,
1362
- No as projectionMatrix,
1363
- Wo as rayEllipsoidIntersection,
1364
- Eo as raySphereIntersection,
1365
- Lo as raySpheresIntersections,
1366
- Zs as raySpheresIntersectionsStruct,
1367
- Ko as screenSpaceShadow,
1368
- Xo as screenToPositionView,
1369
- _o as temporalAntialias,
1370
- $o as textureCatmullRom,
1371
- Js as turbo,
1372
- Mo as viewMatrix
1490
+ yn as CascadedShadowMapsNode,
1491
+ Bt as DownsampleThresholdNode,
1492
+ V as FnLayout,
1493
+ L as FnVar,
1494
+ At as GaussianBlurNode,
1495
+ ho as HighpVelocityNode,
1496
+ po as KawaseBlurNode,
1497
+ To as LensFlareNode,
1498
+ so as MipmapBlurNode,
1499
+ Vt as MipmapSurfaceBlurNode,
1500
+ Ln as Node,
1501
+ Rn as OnBeforeFrameUpdate,
1502
+ Cn as OnFrameUpdate,
1503
+ Po as OutputTexture3DNode,
1504
+ Qs as OutputTextureNode,
1505
+ Wo as STBNTextureNode,
1506
+ Io as ScreenSpaceShadowNode,
1507
+ qo as StorageTexture3DNode,
1508
+ at as TemporalAntialiasNode,
1509
+ Un as bvecAnd,
1510
+ On as bvecNot,
1511
+ jn as bvecOr,
1512
+ xe as cameraFar,
1513
+ fe as cameraNear,
1514
+ gn as cameraPositionWorld,
1515
+ Nn as debugFragmentNode,
1516
+ wn as debugMaterial,
1517
+ Sn as debugNode,
1518
+ Tn as debugVertexNode,
1519
+ hn as depthToColor,
1520
+ Rt as depthToViewZ,
1521
+ Bn as dithering,
1522
+ zn as downsampleThreshold,
1523
+ An as equirectGrid,
1524
+ dn as equirectToDirectionWorld,
1525
+ Dn as gaussianBlur,
1526
+ tt as highpVelocity,
1527
+ bn as hookFunction,
1528
+ lo as interleavedGradientNoise,
1529
+ fn as inverseProjectionMatrix,
1530
+ xn as inverseViewMatrix,
1531
+ Pt as isWebGPU,
1532
+ Vn as kawaseBlur,
1533
+ Fn as lensFlare,
1534
+ Ue as logarithmicToPerspectiveDepth,
1535
+ Mn as mipmapBlur,
1536
+ Dt as mipmapBlurDownsample,
1537
+ to as mipmapBlurUpsample,
1538
+ Pn as mipmapSurfaceBlur,
1539
+ Wn as node,
1540
+ $e as outputTexture,
1541
+ $n as outputTexture3D,
1542
+ un as perspectiveToLogarithmicDepth,
1543
+ pn as projectionMatrix,
1544
+ In as rayEllipsoidIntersection,
1545
+ En as raySphereIntersection,
1546
+ kn as raySpheresIntersections,
1547
+ Ao as raySpheresIntersectionsStruct,
1548
+ Hn as screenSpaceShadow,
1549
+ ln as screenToPositionView,
1550
+ Yn as stbn,
1551
+ $o as stbnTexture,
1552
+ Xn as storageTexture3D,
1553
+ Zn as temporalAntialias,
1554
+ Gn as textureCatmullRom,
1555
+ qn as textureGather,
1556
+ Zs as turbo,
1557
+ mn as viewMatrix,
1558
+ vn as viewZ
1373
1559
  };
1374
1560
  //# sourceMappingURL=webgpu.js.map