hz-particles 1.5.1 → 1.5.2

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.
@@ -1,4 +1,4 @@
1
- class Ys {
1
+ class qs {
2
2
  constructor(t = {}) {
3
3
  this.config = t, this._posOut = [0, 0, 0], this._rotMatrix = null, this._invRotMatrix = null, this._cachedRotX = void 0, this._cachedRotY = void 0, this._cachedRotZ = void 0;
4
4
  }
@@ -10,17 +10,17 @@ class Ys {
10
10
  if (t === this._cachedRotX && e === this._cachedRotY && i === this._cachedRotZ)
11
11
  return;
12
12
  this._cachedRotX = t, this._cachedRotY = e, this._cachedRotZ = i;
13
- const r = t * Math.PI / 180, n = e * Math.PI / 180, a = i * Math.PI / 180, o = Math.cos(r), c = Math.sin(r), l = Math.cos(n), d = Math.sin(n), S = Math.cos(a), b = Math.sin(a);
13
+ const r = t * Math.PI / 180, n = e * Math.PI / 180, a = i * Math.PI / 180, o = Math.cos(r), l = Math.sin(r), c = Math.cos(n), d = Math.sin(n), S = Math.cos(a), b = Math.sin(a);
14
14
  this._rotMatrix = [
15
- l * S,
16
- c * d * S - o * b,
17
- o * d * S + c * b,
18
- l * b,
19
- c * d * b + o * S,
20
- o * d * b - c * S,
15
+ c * S,
16
+ l * d * S - o * b,
17
+ o * d * S + l * b,
18
+ c * b,
19
+ l * d * b + o * S,
20
+ o * d * b - l * S,
21
21
  -d,
22
- c * l,
23
- o * l
22
+ l * c,
23
+ o * c
24
24
  ], this._invRotMatrix = [
25
25
  this._rotMatrix[0],
26
26
  this._rotMatrix[3],
@@ -37,8 +37,8 @@ class Ys {
37
37
  const r = this._posOut;
38
38
  if (this.config.emissionShape === "cube" || this.config.emissionShape === "box" ? this._emitFromCube(r) : this.config.emissionShape === "sphere" ? this._emitFromSphere(r) : this.config.emissionShape === "square" ? this._emitFromSquare(r) : this.config.emissionShape === "circle" ? this._emitFromCircle(r) : this.config.emissionShape === "cylinder" ? this._emitFromCylinder(r) : this.config.emissionShape === "plain" ? this._emitFromPlain(r) : this.config.emissionShape === "cone" ? this._emitFromCone(r) : this.config.emissionShape === "torus" ? this._emitFromTorus(r) : this.config.emissionShape === "line" ? this._emitFromLine(r) : this.config.emissionShape === "hemisphere" ? this._emitFromHemisphere(r) : this.config.emissionShape === "disc" ? this._emitFromDisc(r) : this.config.emissionShape === "annulus" ? this._emitFromAnnulus(r) : this.config.emissionShape === "capsule" ? this._emitFromCapsule(r) : this.config.emissionShape === "arc" ? this._emitFromArc(r) : this.config.emissionShape === "spiral" ? this._emitFromSpiral(r) : this.config.emissionShape === "frustum" ? this._emitFromFrustum(r) : this.config.emissionShape === "frustumSurface" ? this._emitFromFrustumSurface(r) : this.config.emissionShape === "cubeSurface" ? this._emitFromCubeSurface(r) : this.config.emissionShape === "sphereSurface" ? this._emitFromSphereSurface(r) : this.config.emissionShape === "boxFrame" ? this._emitFromBoxFrame(r) : this.config.emissionShape === "polygon" ? this._emitFromPolygon(r) : this.config.emissionShape === "rectangle" ? this._emitFromRectangle(r) : (r[0] = 0, r[1] = 0, r[2] = 0), this.config.emissionRotationX || this.config.emissionRotationY || this.config.emissionRotationZ) {
39
39
  this._updateRotationMatrix();
40
- const o = this._rotMatrix, c = r[0], l = r[1], d = r[2];
41
- r[0] = o[0] * c + o[1] * l + o[2] * d, r[1] = o[3] * c + o[4] * l + o[5] * d, r[2] = o[6] * c + o[7] * l + o[8] * d;
40
+ const o = this._rotMatrix, l = r[0], c = r[1], d = r[2];
41
+ r[0] = o[0] * l + o[1] * c + o[2] * d, r[1] = o[3] * l + o[4] * c + o[5] * d, r[2] = o[6] * l + o[7] * c + o[8] * d;
42
42
  }
43
43
  (this.config.emissionPositionX || this.config.emissionPositionY || this.config.emissionPositionZ) && (r[0] += this.config.emissionPositionX || 0, r[1] += this.config.emissionPositionY || 0, r[2] += this.config.emissionPositionZ || 0);
44
44
  const n = e * 8;
@@ -70,29 +70,29 @@ class Ys {
70
70
  let e = this.config.innerLength || 0, i = this.config.outerLength || this.config.cubeLength;
71
71
  if (e > 0) {
72
72
  const r = Math.floor(Math.random() * 6), n = Math.random() - 0.5, a = Math.random() - 0.5;
73
- let o, c, l;
73
+ let o, l, c;
74
74
  switch (r) {
75
75
  case 0:
76
- o = n, c = a, l = 0.5;
76
+ o = n, l = a, c = 0.5;
77
77
  break;
78
78
  case 1:
79
- o = n, c = a, l = -0.5;
79
+ o = n, l = a, c = -0.5;
80
80
  break;
81
81
  case 2:
82
- o = 0.5, c = n, l = a;
82
+ o = 0.5, l = n, c = a;
83
83
  break;
84
84
  case 3:
85
- o = -0.5, c = n, l = a;
85
+ o = -0.5, l = n, c = a;
86
86
  break;
87
87
  case 4:
88
- o = n, c = 0.5, l = a;
88
+ o = n, l = 0.5, c = a;
89
89
  break;
90
90
  case 5:
91
- o = n, c = -0.5, l = a;
91
+ o = n, l = -0.5, c = a;
92
92
  break;
93
93
  }
94
94
  const d = Math.random(), S = e + d * (i - e);
95
- t[0] = o * S, t[1] = c * S, t[2] = l * S;
95
+ t[0] = o * S, t[1] = l * S, t[2] = c * S;
96
96
  } else
97
97
  t[0] = (Math.random() - 0.5) * i, t[1] = (Math.random() - 0.5) * i, t[2] = (Math.random() - 0.5) * i;
98
98
  }
@@ -134,14 +134,14 @@ class Ys {
134
134
  t[0] = (Math.random() - 0.5) * e, t[1] = 0, t[2] = (Math.random() - 0.5) * i;
135
135
  }
136
136
  _emitFromCone(t) {
137
- const e = this.config.coneInnerRadius || 0, i = this.config.coneOuterRadius || 2, r = this.config.coneHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r, c = i * (1 - a);
138
- let l;
137
+ const e = this.config.coneInnerRadius || 0, i = this.config.coneOuterRadius || 2, r = this.config.coneHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r, l = i * (1 - a);
138
+ let c;
139
139
  if (e > 0) {
140
140
  const d = e * (1 - a);
141
- l = d + (c - d) * Math.random();
141
+ c = d + (l - d) * Math.random();
142
142
  } else
143
- l = c * Math.sqrt(Math.random());
144
- t[0] = Math.cos(n) * l, t[1] = o, t[2] = Math.sin(n) * l;
143
+ c = l * Math.sqrt(Math.random());
144
+ t[0] = Math.cos(n) * c, t[1] = o, t[2] = Math.sin(n) * c;
145
145
  }
146
146
  _emitFromTorus(t) {
147
147
  const e = this.config.torusMajorRadius || 2, i = this.config.torusMinorRadius || 0.5, r = Math.random() * Math.PI * 2, n = Math.random() * Math.PI * 2, a = i * Math.sqrt(Math.random());
@@ -152,9 +152,9 @@ class Ys {
152
152
  t[0] = 0, t[1] = (i - 0.5) * e, t[2] = 0;
153
153
  }
154
154
  _emitFromHemisphere(t) {
155
- const e = this.config.hemisphereInnerRadius || 0, i = this.config.hemisphereOuterRadius || 2, r = Math.random() * Math.PI * 2, n = Math.acos(Math.random()), a = Math.sin(n) * Math.cos(r), o = Math.cos(n), c = Math.sin(n) * Math.sin(r);
156
- let l;
157
- e > 0 ? l = e + (i - e) * Math.random() : l = i * Math.cbrt(Math.random()), t[0] = a * l, t[1] = o * l, t[2] = c * l;
155
+ const e = this.config.hemisphereInnerRadius || 0, i = this.config.hemisphereOuterRadius || 2, r = Math.random() * Math.PI * 2, n = Math.acos(Math.random()), a = Math.sin(n) * Math.cos(r), o = Math.cos(n), l = Math.sin(n) * Math.sin(r);
156
+ let c;
157
+ e > 0 ? c = e + (i - e) * Math.random() : c = i * Math.cbrt(Math.random()), t[0] = a * c, t[1] = o * c, t[2] = l * c;
158
158
  }
159
159
  _emitFromDisc(t) {
160
160
  const e = this.config.discRadius || 2, i = Math.random() * Math.PI * 2, r = e * Math.sqrt(Math.random());
@@ -167,37 +167,37 @@ class Ys {
167
167
  _emitFromCapsule(t) {
168
168
  const e = this.config.capsuleRadius || 0.5, i = this.config.capsuleHeight || 4, r = i * 0.5, n = Math.PI * e * e * i, a = 4 / 3 * Math.PI * e * e * e, o = n / (n + a);
169
169
  if (Math.random() < o) {
170
- const c = Math.random() * Math.PI * 2, l = e * Math.sqrt(Math.random());
171
- t[0] = Math.cos(c) * l, t[1] = (Math.random() - 0.5) * i, t[2] = Math.sin(c) * l;
170
+ const l = Math.random() * Math.PI * 2, c = e * Math.sqrt(Math.random());
171
+ t[0] = Math.cos(l) * c, t[1] = (Math.random() - 0.5) * i, t[2] = Math.sin(l) * c;
172
172
  } else {
173
- const c = Math.random() * Math.PI * 2, l = Math.acos(2 * Math.random() - 1), d = e * Math.cbrt(Math.random());
174
- t[0] = d * Math.sin(l) * Math.cos(c), t[1] = d * Math.cos(l), t[2] = d * Math.sin(l) * Math.sin(c), t[1] += t[1] >= 0 ? r : -r;
173
+ const l = Math.random() * Math.PI * 2, c = Math.acos(2 * Math.random() - 1), d = e * Math.cbrt(Math.random());
174
+ t[0] = d * Math.sin(c) * Math.cos(l), t[1] = d * Math.cos(c), t[2] = d * Math.sin(c) * Math.sin(l), t[1] += t[1] >= 0 ? r : -r;
175
175
  }
176
176
  }
177
177
  _emitFromArc(t) {
178
- const e = this.config.arcStartAngle || 0, i = this.config.arcEndAngle || 180, r = this.config.arcInnerRadius || 0, n = this.config.arcOuterRadius || 2, a = e * Math.PI / 180, o = i * Math.PI / 180, c = a + Math.random() * (o - a);
179
- let l;
180
- r > 0 ? l = r + (n - r) * Math.random() : l = n * Math.sqrt(Math.random()), t[0] = Math.cos(c) * l, t[1] = Math.sin(c) * l, t[2] = 0;
178
+ const e = this.config.arcStartAngle || 0, i = this.config.arcEndAngle || 180, r = this.config.arcInnerRadius || 0, n = this.config.arcOuterRadius || 2, a = e * Math.PI / 180, o = i * Math.PI / 180, l = a + Math.random() * (o - a);
179
+ let c;
180
+ r > 0 ? c = r + (n - r) * Math.random() : c = n * Math.sqrt(Math.random()), t[0] = Math.cos(l) * c, t[1] = Math.sin(l) * c, t[2] = 0;
181
181
  }
182
182
  _emitFromSpiral(t) {
183
- const e = this.config.spiralTurns || 3, i = this.config.spiralRadiusStart || 0.5, r = this.config.spiralRadiusEnd || 2, n = this.config.spiralHeight || 4, a = Math.random(), o = a * e * Math.PI * 2, c = i + (r - i) * a;
184
- t[0] = Math.cos(o) * c, t[1] = (a - 0.5) * n, t[2] = Math.sin(o) * c;
183
+ const e = this.config.spiralTurns || 3, i = this.config.spiralRadiusStart || 0.5, r = this.config.spiralRadiusEnd || 2, n = this.config.spiralHeight || 4, a = Math.random(), o = a * e * Math.PI * 2, l = i + (r - i) * a;
184
+ t[0] = Math.cos(o) * l, t[1] = (a - 0.5) * n, t[2] = Math.sin(o) * l;
185
185
  }
186
186
  _emitFromFrustum(t) {
187
- const e = this.config.frustumRadiusNear || 0.5, i = this.config.frustumRadiusFar || 2, r = this.config.frustumHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r, l = (e + (i - e) * a) * Math.sqrt(Math.random());
188
- t[0] = Math.cos(n) * l, t[1] = o, t[2] = Math.sin(n) * l;
187
+ const e = this.config.frustumRadiusNear || 0.5, i = this.config.frustumRadiusFar || 2, r = this.config.frustumHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r, c = (e + (i - e) * a) * Math.sqrt(Math.random());
188
+ t[0] = Math.cos(n) * c, t[1] = o, t[2] = Math.sin(n) * c;
189
189
  }
190
190
  _emitFromFrustumSurface(t) {
191
191
  const e = this.config.frustumRadiusNear ?? 0.5, i = this.config.frustumRadiusFar ?? 2, r = this.config.frustumHeight ?? 4, n = Math.random() * Math.PI * 2, a = i - e, o = e + a * 0.5;
192
- let c;
192
+ let l;
193
193
  if (Math.abs(a) < 1e-6 || o <= 1e-6)
194
- c = Math.random();
194
+ l = Math.random();
195
195
  else {
196
- const S = Math.random(), b = 0.5 * a, p = e, v = -S * o, E = Math.max(0, p * p - 4 * b * v);
197
- c = (-p + Math.sqrt(E)) / (2 * b), Number.isFinite(c) || (c = Math.random()), c = Math.min(1, Math.max(0, c));
196
+ const S = Math.random(), b = 0.5 * a, h = e, v = -S * o, C = Math.max(0, h * h - 4 * b * v);
197
+ l = (-h + Math.sqrt(C)) / (2 * b), Number.isFinite(l) || (l = Math.random()), l = Math.min(1, Math.max(0, l));
198
198
  }
199
- const l = c * r, d = e + a * c;
200
- t[0] = Math.cos(n) * d, t[1] = l, t[2] = Math.sin(n) * d;
199
+ const c = l * r, d = e + a * l;
200
+ t[0] = Math.cos(n) * d, t[1] = c, t[2] = Math.sin(n) * d;
201
201
  }
202
202
  _emitFromCubeSurface(t) {
203
203
  const e = this.config.cubeSurfaceSize || 2, i = e * 0.5, r = Math.floor(Math.random() * 6), n = (Math.random() - 0.5) * e, a = (Math.random() - 0.5) * e;
@@ -229,22 +229,22 @@ class Ys {
229
229
  _emitFromBoxFrame(t) {
230
230
  const e = this.config.boxFrameSize || 2, i = e * 0.5, r = Math.floor(Math.random() * 12), a = (Math.random() - 0.5) * e, o = [[-1, -1], [-1, 1], [1, -1], [1, 1]];
231
231
  if (r < 4) {
232
- const [c, l] = o[r];
233
- t[0] = a, t[1] = c * i, t[2] = l * i;
232
+ const [l, c] = o[r];
233
+ t[0] = a, t[1] = l * i, t[2] = c * i;
234
234
  } else if (r < 8) {
235
- const [c, l] = o[r - 4];
236
- t[0] = c * i, t[1] = a, t[2] = l * i;
235
+ const [l, c] = o[r - 4];
236
+ t[0] = l * i, t[1] = a, t[2] = c * i;
237
237
  } else {
238
- const [c, l] = o[r - 8];
239
- t[0] = c * i, t[1] = l * i, t[2] = a;
238
+ const [l, c] = o[r - 8];
239
+ t[0] = l * i, t[1] = c * i, t[2] = a;
240
240
  }
241
241
  }
242
242
  _emitFromPolygon(t) {
243
243
  const e = Math.max(3, Math.floor(this.config.polygonSides || 6)), i = this.config.polygonRadius || 2, r = Math.floor(Math.random() * e), n = r / e * Math.PI * 2, a = (r + 1) / e * Math.PI * 2;
244
- let o = Math.random(), c = Math.random();
245
- o + c > 1 && (o = 1 - o, c = 1 - c);
246
- const l = o * Math.cos(n) + c * Math.cos(a), d = o * Math.sin(n) + c * Math.sin(a);
247
- t[0] = l * i, t[1] = d * i, t[2] = 0;
244
+ let o = Math.random(), l = Math.random();
245
+ o + l > 1 && (o = 1 - o, l = 1 - l);
246
+ const c = o * Math.cos(n) + l * Math.cos(a), d = o * Math.sin(n) + l * Math.sin(a);
247
+ t[0] = c * i, t[1] = d * i, t[2] = 0;
248
248
  }
249
249
  _emitFromRectangle(t) {
250
250
  const e = this.config.rectangleWidth || 2, i = this.config.rectangleHeight || 2;
@@ -256,33 +256,33 @@ class Ys {
256
256
  e > 0 ? a = e + (i - e) * Math.random() : a = i * Math.sqrt(Math.random()), t[0] = Math.cos(n) * a, t[1] = (Math.random() - 0.5) * r, t[2] = Math.sin(n) * a;
257
257
  }
258
258
  calculateVelocity(t, e, i, r, n) {
259
- const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, d = e - o, S = i - c, b = Math.sqrt(l * l + d * d + S * S);
260
- let p, v, E;
259
+ const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, l = this.config.emissionPositionZ || 0, c = t - a, d = e - o, S = i - l, b = Math.sqrt(c * c + d * d + S * S);
260
+ let h, v, C;
261
261
  if (b > 1e-4) {
262
- let z = !1;
262
+ let D = !1;
263
263
  if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
264
- const _ = this.inverseRotation(l, d, S), W = Math.sqrt(_[0] * _[0] + _[1] * _[1]);
265
- if (W > 1e-4) {
266
- const T = -_[1] / W, F = _[0] / W, G = this.applyRotation(T, F, 0);
267
- p = G[0], v = G[1], E = G[2], z = !0;
264
+ const _ = this.inverseRotation(c, d, S), Z = Math.sqrt(_[0] * _[0] + _[1] * _[1]);
265
+ if (Z > 1e-4) {
266
+ const T = -_[1] / Z, F = _[0] / Z, G = this.applyRotation(T, F, 0);
267
+ h = G[0], v = G[1], C = G[2], D = !0;
268
268
  }
269
269
  } else if (this.config.emissionShape === "cylinder" && this.config.cylinderVelocityDirection === "tangential") {
270
- const _ = this.inverseRotation(l, d, S), W = Math.sqrt(_[0] * _[0] + _[2] * _[2]);
271
- if (W > 1e-4) {
272
- const T = -_[2] / W, F = _[0] / W, G = this.applyRotation(T, 0, F);
273
- p = G[0], v = G[1], E = G[2], z = !0;
270
+ const _ = this.inverseRotation(c, d, S), Z = Math.sqrt(_[0] * _[0] + _[2] * _[2]);
271
+ if (Z > 1e-4) {
272
+ const T = -_[2] / Z, F = _[0] / Z, G = this.applyRotation(T, 0, F);
273
+ h = G[0], v = G[1], C = G[2], D = !0;
274
274
  } else {
275
275
  const T = Math.random() * Math.PI * 2, F = this.applyRotation(Math.cos(T), 0, Math.sin(T));
276
- p = F[0], v = F[1], E = F[2], z = !0;
276
+ h = F[0], v = F[1], C = F[2], D = !0;
277
277
  }
278
278
  }
279
- z || (p = l / b, v = d / b, E = S / b);
279
+ D || (h = c / b, v = d / b, C = S / b);
280
280
  } else {
281
- const z = Math.random() * Math.PI * 2, _ = Math.acos(2 * Math.random() - 1);
282
- p = Math.sin(_) * Math.cos(z), v = Math.sin(_) * Math.sin(z), E = Math.cos(_);
281
+ const D = Math.random() * Math.PI * 2, _ = Math.acos(2 * Math.random() - 1);
282
+ h = Math.sin(_) * Math.cos(D), v = Math.sin(_) * Math.sin(D), C = Math.cos(_);
283
283
  }
284
- let I;
285
- this.config.randomSpeed ? I = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : I = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : p * I, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : v * I, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : E * I, r[n + 3] = 0;
284
+ let z;
285
+ this.config.randomSpeed ? z = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : z = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : h * z, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : v * z, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : C * z, r[n + 3] = 0;
286
286
  }
287
287
  setParticleColor(t, e) {
288
288
  if (this.config.randomColorEnabled && this.config.randomColors.length > 0) {
@@ -295,7 +295,7 @@ class Ys {
295
295
  t[e + 6] = 0, t[e + 7] = i + (Math.random() * 0.4 - 0.2) * i;
296
296
  }
297
297
  }
298
- const js = `
298
+ const Hs = `
299
299
  struct Uniforms {
300
300
  transform: mat4x4<f32>,
301
301
  cameraPosition: vec3<f32>,
@@ -376,8 +376,26 @@ const js = `
376
376
  @location(3) noiseOffset : vec2<f32>,
377
377
  }
378
378
 
379
+ // Hachage SANS TRANSCENDANTAL (Dave Hoskins, « Hash without Sine »).
380
+ //
381
+ // ⚠️ LE fract(sin(dot(...))) QU'IL REMPLACE ÉTAIT LE PREMIER POSTE DE COÛT DE CE SHADER. Il est
382
+ // appelé QUATRE fois par valueNoise, et la distorsion en appelle DEUX : huit sin par pixel couvert.
383
+ // Sur un GPU mobile, sin n'est pas une instruction à un cycle — elle est souvent émulée, et elle
384
+ // domine tout le reste du fragment.
385
+ //
386
+ // ⚠️ ET AUCUN ACCENT GRAVE DANS CE COMMENTAIRE : on est à l'intérieur d'un littéral gabarit
387
+ // JavaScript. Un seul le referme, et le shader entier devient une erreur de syntaxe.
388
+ //
389
+ // Mesuré sur la map du propriétaire : 27 nuages additifs de 4,2 m qui se recouvrent, soit ~19 écrans
390
+ // pleins de pixels couverts — donc ~150 sin par pixel d'écran et par image. Il rapportait
391
+ // « ça lag pour de pauvres nuages », et éteindre le bruit supprimait le lag.
392
+ //
393
+ // Le remplaçant tient en trois lignes de fract/dot, sans aucune fonction transcendantale, et
394
+ // garde les mêmes propriétés statistiques (distribution uniforme, décorrélation spatiale).
379
395
  fn hash21(p: vec2<f32>) -> f32 {
380
- return fract(sin(dot(p, vec2<f32>(127.1, 311.7))) * 43758.5453);
396
+ var p3 = fract(vec3<f32>(p.x, p.y, p.x) * 0.1031);
397
+ p3 = p3 + dot(p3, vec3<f32>(p3.y, p3.z, p3.x) + 33.33);
398
+ return fract((p3.x + p3.y) * p3.z);
381
399
  }
382
400
 
383
401
  fn valueNoise(p: vec2<f32>) -> f32 {
@@ -719,7 +737,7 @@ const js = `
719
737
  return vec4<f32>(input.color, alpha);
720
738
  }
721
739
  }
722
- `, qs = `
740
+ `, Zs = `
723
741
  struct BloomUniforms {
724
742
  direction: vec2<f32>,
725
743
  resolution: vec2<f32>,
@@ -779,7 +797,7 @@ const js = `
779
797
 
780
798
  return result / totalWeight * 1.1;
781
799
  }
782
- `, Zs = `
800
+ `, Ws = `
783
801
  struct BloomIntensityUniforms {
784
802
  intensity: f32,
785
803
  color: vec3<f32>,
@@ -825,7 +843,7 @@ const js = `
825
843
 
826
844
  return vec4<f32>(originalColor.rgb + (mappedBloom * bloomUniforms.intensity), originalColor.a);
827
845
  }
828
- `, Hs = `
846
+ `, $s = `
829
847
  struct BloomIntensityUniforms {
830
848
  intensity: f32,
831
849
  color: vec3<f32>,
@@ -866,7 +884,7 @@ const js = `
866
884
  fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
867
885
  return textureSample(originalTexture, texSampler, input.texCoord);
868
886
  }
869
- `, Ws = `
887
+ `, Js = `
870
888
  @binding(0) @group(0) var texSampler: sampler;
871
889
  @binding(1) @group(0) var originalTexture: texture_2d<f32>;
872
890
  @binding(2) @group(0) var blurredTexture: texture_2d<f32>;
@@ -898,7 +916,7 @@ const js = `
898
916
  let c = textureSample(originalTexture, texSampler, input.texCoord);
899
917
  return vec4<f32>(aces(c.rgb), c.a);
900
918
  }
901
- `, $s = `
919
+ `, Ks = `
902
920
  struct PhysicsUniforms {
903
921
  deltaTime: f32,
904
922
  particleSpeed: f32,
@@ -1108,7 +1126,7 @@ const js = `
1108
1126
  particleBuffer[baseIndex + 1u] = newPos.y;
1109
1127
  particleBuffer[baseIndex + 2u] = newPos.z;
1110
1128
  }
1111
- `, Js = `
1129
+ `, Qs = `
1112
1130
  @group(0) @binding(0) var<storage, read> restData: array<f32>;
1113
1131
  @group(0) @binding(1) var<storage, read> jointWeightsData: array<f32>;
1114
1132
  @group(0) @binding(2) var<storage, read> jointIndicesData: array<u32>;
@@ -1165,7 +1183,7 @@ const js = `
1165
1183
  outputData[outBase + 7u] = uv_v;
1166
1184
  }
1167
1185
  `;
1168
- class Ks {
1186
+ class er {
1169
1187
  constructor(t, e = 1e4) {
1170
1188
  this.device = t, this.physicsSettings = {
1171
1189
  deltaTime: 0.016,
@@ -1254,7 +1272,7 @@ class Ks {
1254
1272
  }),
1255
1273
  compute: {
1256
1274
  module: this.device.createShaderModule({
1257
- code: $s
1275
+ code: Ks
1258
1276
  }),
1259
1277
  entryPoint: "main"
1260
1278
  }
@@ -1283,12 +1301,12 @@ class Ks {
1283
1301
  updatePhysics(t, e, i, r, n, a) {
1284
1302
  if (e <= 0 || !this.computeReady)
1285
1303
  return;
1286
- const o = this._physicsData, c = this.physicsSettings;
1287
- o[0] = t, o[1] = i.particleSpeed, o[2] = c.gravity, o[3] = c.turbulence, o[4] = c.attractorStrength, o[5] = c.damping, o[6] = c.attractorPosition[0], o[7] = c.attractorPosition[1], o[8] = c.attractorPosition[2], this._physicsDataU32View[9] = e, o[10] = c.confinementEnabled ? 1 : 0, o[11] = c.confinementShape === "sphere" ? 1 : 0, o[12] = c.confinementMode === "kill" ? 1 : 0, o[13] = c.confinementSpace === "local" ? 1 : 0, o[14] = c.confinementBoxHalfSize[0], o[15] = c.confinementBoxHalfSize[1], o[16] = c.confinementBoxHalfSize[2], o[17] = c.confinementSphereRadius, o[18] = c.confinementRestitution, o[19] = c.confinementFriction, o[20] = c.confinementCenter[0], o[21] = c.confinementCenter[1], o[22] = c.confinementCenter[2], o[23] = c.softBoundaryEnabled ? 1 : 0, o[24] = c.softBoundaryStrength, o[25] = c.softBoundaryFalloff, o[26] = i.velocityStretchEnabled ? 1 : 0, o[27] = i.velocityStretchFactor ?? 1, o[28] = 0, o[29] = 0, o[30] = 0, o[31] = 0, this.device.queue.writeBuffer(this.physicsUniformBuffer, 0, o);
1288
- const l = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }), d = l.beginComputePass({ label: "ParticlePhysicsPass" });
1304
+ const o = this._physicsData, l = this.physicsSettings;
1305
+ o[0] = t, o[1] = i.particleSpeed, o[2] = l.gravity, o[3] = l.turbulence, o[4] = l.attractorStrength, o[5] = l.damping, o[6] = l.attractorPosition[0], o[7] = l.attractorPosition[1], o[8] = l.attractorPosition[2], this._physicsDataU32View[9] = e, o[10] = l.confinementEnabled ? 1 : 0, o[11] = l.confinementShape === "sphere" ? 1 : 0, o[12] = l.confinementMode === "kill" ? 1 : 0, o[13] = l.confinementSpace === "local" ? 1 : 0, o[14] = l.confinementBoxHalfSize[0], o[15] = l.confinementBoxHalfSize[1], o[16] = l.confinementBoxHalfSize[2], o[17] = l.confinementSphereRadius, o[18] = l.confinementRestitution, o[19] = l.confinementFriction, o[20] = l.confinementCenter[0], o[21] = l.confinementCenter[1], o[22] = l.confinementCenter[2], o[23] = l.softBoundaryEnabled ? 1 : 0, o[24] = l.softBoundaryStrength, o[25] = l.softBoundaryFalloff, o[26] = i.velocityStretchEnabled ? 1 : 0, o[27] = i.velocityStretchFactor ?? 1, o[28] = 0, o[29] = 0, o[30] = 0, o[31] = 0, this.device.queue.writeBuffer(this.physicsUniformBuffer, 0, o);
1306
+ const c = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }), d = c.beginComputePass({ label: "ParticlePhysicsPass" });
1289
1307
  d.setPipeline(this.computePipeline), d.setBindGroup(0, this.computeBindGroup);
1290
1308
  const S = Math.max(1, Math.ceil(e / 64));
1291
- d.dispatchWorkgroups(S, 1, 1), d.end(), a || this.device.queue.submit([l.finish()]), this.lastUpdateTime = performance.now() / 1e3;
1309
+ d.dispatchWorkgroups(S, 1, 1), d.end(), a || this.device.queue.submit([c.finish()]), this.lastUpdateTime = performance.now() / 1e3;
1292
1310
  }
1293
1311
  async readbackAndProcessParticles(t, e, i, r, n) {
1294
1312
  if (t <= 0)
@@ -1307,23 +1325,23 @@ class Ks {
1307
1325
  0,
1308
1326
  o
1309
1327
  );
1310
- const c = t * 4 * 4;
1328
+ const l = t * 4 * 4;
1311
1329
  return a.copyBufferToBuffer(
1312
1330
  n,
1313
1331
  0,
1314
1332
  this._velocityStagingBuffer,
1315
1333
  0,
1316
- c
1334
+ l
1317
1335
  ), this.device.queue.submit([a.finish()]), await Promise.all([
1318
1336
  (async () => {
1319
1337
  await this._particleDataStagingBuffer.mapAsync(GPUMapMode.READ, 0, o);
1320
- const l = new Float32Array(this._particleDataStagingBuffer.getMappedRange(0, o));
1321
- e.set(l), this._particleDataStagingBuffer.unmap();
1338
+ const c = new Float32Array(this._particleDataStagingBuffer.getMappedRange(0, o));
1339
+ e.set(c), this._particleDataStagingBuffer.unmap();
1322
1340
  })(),
1323
1341
  (async () => {
1324
- await this._velocityStagingBuffer.mapAsync(GPUMapMode.READ, 0, c);
1325
- const l = new Float32Array(this._velocityStagingBuffer.getMappedRange(0, c));
1326
- i.set(l), this._velocityStagingBuffer.unmap();
1342
+ await this._velocityStagingBuffer.mapAsync(GPUMapMode.READ, 0, l);
1343
+ const c = new Float32Array(this._velocityStagingBuffer.getMappedRange(0, l));
1344
+ i.set(c), this._velocityStagingBuffer.unmap();
1327
1345
  })()
1328
1346
  ]), this._stagingInUse = !1, {
1329
1347
  particleData: e,
@@ -1366,31 +1384,31 @@ class Ks {
1366
1384
  return { shouldUpdate: !1 };
1367
1385
  try {
1368
1386
  this._renderStagingInUse = !0;
1369
- const a = t * 8 * 4, o = t * 4 * 4, c = this.device.createCommandEncoder({
1387
+ const a = t * 8 * 4, o = t * 4 * 4, l = this.device.createCommandEncoder({
1370
1388
  label: "RenderReadbackEncoder"
1371
1389
  });
1372
- return c.copyBufferToBuffer(
1390
+ return l.copyBufferToBuffer(
1373
1391
  r,
1374
1392
  0,
1375
1393
  this._renderStagingParticleBuffer,
1376
1394
  0,
1377
1395
  a
1378
- ), c.copyBufferToBuffer(
1396
+ ), l.copyBufferToBuffer(
1379
1397
  n,
1380
1398
  0,
1381
1399
  this._renderStagingVelocityBuffer,
1382
1400
  0,
1383
1401
  o
1384
- ), this.device.queue.submit([c.finish()]), await Promise.all([
1402
+ ), this.device.queue.submit([l.finish()]), await Promise.all([
1385
1403
  (async () => {
1386
1404
  await this._renderStagingParticleBuffer.mapAsync(GPUMapMode.READ, 0, a);
1387
- const l = new Float32Array(this._renderStagingParticleBuffer.getMappedRange(0, a));
1388
- e.set(l), this._renderStagingParticleBuffer.unmap();
1405
+ const c = new Float32Array(this._renderStagingParticleBuffer.getMappedRange(0, a));
1406
+ e.set(c), this._renderStagingParticleBuffer.unmap();
1389
1407
  })(),
1390
1408
  (async () => {
1391
1409
  await this._renderStagingVelocityBuffer.mapAsync(GPUMapMode.READ, 0, o);
1392
- const l = new Float32Array(this._renderStagingVelocityBuffer.getMappedRange(0, o));
1393
- i.set(l), this._renderStagingVelocityBuffer.unmap();
1410
+ const c = new Float32Array(this._renderStagingVelocityBuffer.getMappedRange(0, o));
1411
+ i.set(c), this._renderStagingVelocityBuffer.unmap();
1394
1412
  })()
1395
1413
  ]), this._renderStagingInUse = !1, {
1396
1414
  particleData: e,
@@ -1419,31 +1437,31 @@ class Ks {
1419
1437
  return { shouldUpdate: !1 };
1420
1438
  try {
1421
1439
  this._scriptStagingInUse = !0;
1422
- const a = t * 8 * 4, o = t * 4 * 4, c = this.device.createCommandEncoder({
1440
+ const a = t * 8 * 4, o = t * 4 * 4, l = this.device.createCommandEncoder({
1423
1441
  label: "ScriptReadbackEncoder"
1424
1442
  });
1425
- return c.copyBufferToBuffer(
1443
+ return l.copyBufferToBuffer(
1426
1444
  r,
1427
1445
  0,
1428
1446
  this._scriptStagingParticleBuffer,
1429
1447
  0,
1430
1448
  a
1431
- ), c.copyBufferToBuffer(
1449
+ ), l.copyBufferToBuffer(
1432
1450
  n,
1433
1451
  0,
1434
1452
  this._scriptStagingVelocityBuffer,
1435
1453
  0,
1436
1454
  o
1437
- ), this.device.queue.submit([c.finish()]), await Promise.all([
1455
+ ), this.device.queue.submit([l.finish()]), await Promise.all([
1438
1456
  (async () => {
1439
1457
  await this._scriptStagingParticleBuffer.mapAsync(GPUMapMode.READ, 0, a);
1440
- const l = new Float32Array(this._scriptStagingParticleBuffer.getMappedRange(0, a));
1441
- e.set(l), this._scriptStagingParticleBuffer.unmap();
1458
+ const c = new Float32Array(this._scriptStagingParticleBuffer.getMappedRange(0, a));
1459
+ e.set(c), this._scriptStagingParticleBuffer.unmap();
1442
1460
  })(),
1443
1461
  (async () => {
1444
1462
  await this._scriptStagingVelocityBuffer.mapAsync(GPUMapMode.READ, 0, o);
1445
- const l = new Float32Array(this._scriptStagingVelocityBuffer.getMappedRange(0, o));
1446
- i.set(l), this._scriptStagingVelocityBuffer.unmap();
1463
+ const c = new Float32Array(this._scriptStagingVelocityBuffer.getMappedRange(0, o));
1464
+ i.set(c), this._scriptStagingVelocityBuffer.unmap();
1447
1465
  })()
1448
1466
  ]), this._scriptStagingInUse = !1, { shouldUpdate: !0 };
1449
1467
  } catch (a) {
@@ -1461,7 +1479,7 @@ class Ks {
1461
1479
  t.enabled !== void 0 && (e.softBoundaryEnabled = t.enabled), t.strength !== void 0 && (e.softBoundaryStrength = t.strength), t.falloff !== void 0 && (e.softBoundaryFalloff = t.falloff);
1462
1480
  }
1463
1481
  }
1464
- class Qs {
1482
+ class tr {
1465
1483
  constructor(t) {
1466
1484
  this.device = t, this.defaultTexture = null, this.createDefaultTexture();
1467
1485
  }
@@ -1500,7 +1518,7 @@ class Qs {
1500
1518
  t && t.label !== "defaultParticleTexture" && t.destroy();
1501
1519
  }
1502
1520
  }
1503
- const Hi = Object.freeze({
1521
+ const Wi = Object.freeze({
1504
1522
  sin: Math.sin,
1505
1523
  cos: Math.cos,
1506
1524
  abs: Math.abs,
@@ -1521,7 +1539,7 @@ const Hi = Object.freeze({
1521
1539
  return s + (t - s) * e;
1522
1540
  },
1523
1541
  smoothstep(s, t, e) {
1524
- const i = Hi.clamp((e - s) / (t - s), 0, 1);
1542
+ const i = Wi.clamp((e - s) / (t - s), 0, 1);
1525
1543
  return i * i * (3 - 2 * i);
1526
1544
  }
1527
1545
  }), Ct = /* @__PURE__ */ new Set([
@@ -1567,7 +1585,7 @@ const Hi = Object.freeze({
1567
1585
  "shapeStrokeFrequency",
1568
1586
  "shapeStrokeSpeed"
1569
1587
  ]);
1570
- class er {
1588
+ class ir {
1571
1589
  constructor(t) {
1572
1590
  this._collection = t, this._pd = null, this._vd = null, this._pi = 0, this._vi = 0;
1573
1591
  }
@@ -1645,9 +1663,9 @@ class er {
1645
1663
  this._vd[this._vi + 2] = t, this._collection._dirty = !0;
1646
1664
  }
1647
1665
  }
1648
- class tr {
1666
+ class sr {
1649
1667
  constructor() {
1650
- this._proxy = new er(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
1668
+ this._proxy = new ir(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
1651
1669
  }
1652
1670
  _bind(t, e, i) {
1653
1671
  this._pd = t, this._vd = e, this.count = i, this._dirty = !1;
@@ -1656,14 +1674,14 @@ class tr {
1656
1674
  return t < 0 || t >= this.count ? null : this._proxy._bind(this._pd, this._vd, t);
1657
1675
  }
1658
1676
  }
1659
- const ir = 1e6;
1660
- function sr(s) {
1677
+ const rr = 1e6;
1678
+ function nr(s) {
1661
1679
  let t = 0;
1662
1680
  return s.replace(
1663
1681
  /\b(for|while)\s*\([^)]*\)\s*\{/g,
1664
1682
  (e) => {
1665
1683
  const i = `__lc${t++}`;
1666
- return `${e} if(++${i}>${ir})throw new Error("Loop limit exceeded");`;
1684
+ return `${e} if(++${i}>${rr})throw new Error("Loop limit exceeded");`;
1667
1685
  }
1668
1686
  ).replace(
1669
1687
  /\b(for|while)\s*\([^)]*\)\s*\{/g,
@@ -1683,7 +1701,7 @@ function sr(s) {
1683
1701
  const ni = /* @__PURE__ */ new Map();
1684
1702
  for (const s of Ct)
1685
1703
  ni.set(s.toLowerCase(), s);
1686
- function rr(s) {
1704
+ function ar(s) {
1687
1705
  const t = { value: !1 }, e = /* @__PURE__ */ new Set();
1688
1706
  return new Proxy(s, {
1689
1707
  get(r, n) {
@@ -1701,9 +1719,9 @@ function rr(s) {
1701
1719
  if (typeof n != "string") return !0;
1702
1720
  let o = n;
1703
1721
  if (!Ct.has(o)) {
1704
- const c = ni.get(o.toLowerCase());
1705
- if (c)
1706
- e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${c}?`)), o = c;
1722
+ const l = ni.get(o.toLowerCase());
1723
+ if (l)
1724
+ e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${l}?`)), o = l;
1707
1725
  else
1708
1726
  return !0;
1709
1727
  }
@@ -1711,14 +1729,14 @@ function rr(s) {
1711
1729
  }
1712
1730
  });
1713
1731
  }
1714
- class Gi {
1732
+ class Fi {
1715
1733
  /**
1716
1734
  * @param {string} source - User script source code
1717
1735
  * @param {object} config - ParticleSystem config (will be proxied)
1718
1736
  * @param {number} maxParticles - Max particle count for pre-allocation
1719
1737
  */
1720
1738
  constructor(t, e, i) {
1721
- this._particles = new tr(), this._configProxy = rr(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
1739
+ this._particles = new sr(), this._configProxy = ar(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
1722
1740
  }
1723
1741
  /**
1724
1742
  * Compile script source into a sandboxed function.
@@ -1734,7 +1752,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1734
1752
  var deltaTime = __deltaTime, time = __time;
1735
1753
  var currentFrame = __currentFrame, totalFrames = __totalFrames;
1736
1754
  var particles = __particles, config = __config, math = __math;
1737
- ${sr(t)}
1755
+ ${nr(t)}
1738
1756
  };`, r = new Function(i);
1739
1757
  this._fn = r();
1740
1758
  } catch (e) {
@@ -1756,9 +1774,9 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1756
1774
  if (!this._fn || this._error) return { configDirty: !1, particlesDirty: !1 };
1757
1775
  this._particles._bind(n, a, o), this._configProxy.__resetDirty();
1758
1776
  try {
1759
- this._fn(t, e, i, r, this._particles, this._configProxy, Hi);
1760
- } catch (c) {
1761
- console.warn("[ParticleScript] Runtime error:", c.message);
1777
+ this._fn(t, e, i, r, this._particles, this._configProxy, Wi);
1778
+ } catch (l) {
1779
+ console.warn("[ParticleScript] Runtime error:", l.message);
1762
1780
  }
1763
1781
  return {
1764
1782
  configDirty: this._configProxy.__dirty,
@@ -1795,7 +1813,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1795
1813
  this._fn = null, this._particles = null, this._configProxy = null, this._configSnapshot = null;
1796
1814
  }
1797
1815
  }
1798
- async function nr(s) {
1816
+ async function or(s) {
1799
1817
  const t = new DataView(s);
1800
1818
  if (t.getUint32(0, !0) !== 1179937895)
1801
1819
  throw new Error("Invalid GLB file: incorrect magic number");
@@ -1807,8 +1825,8 @@ async function nr(s) {
1807
1825
  for (; n < r; ) {
1808
1826
  const T = t.getUint32(n, !0), F = t.getUint32(n + 4, !0), G = s.slice(n + 8, n + 8 + T);
1809
1827
  if (F === 1313821514) {
1810
- const re = new TextDecoder("utf-8").decode(G);
1811
- a = JSON.parse(re);
1828
+ const se = new TextDecoder("utf-8").decode(G);
1829
+ a = JSON.parse(se);
1812
1830
  } else F === 5130562 && (o = G);
1813
1831
  n += 8 + T;
1814
1832
  }
@@ -1816,38 +1834,38 @@ async function nr(s) {
1816
1834
  throw new Error("GLB file missing JSON chunk");
1817
1835
  if (!a.meshes || a.meshes.length === 0)
1818
1836
  throw new Error("GLB file contains no meshes");
1819
- const l = a.meshes[0].primitives[0];
1820
- if (!l)
1837
+ const c = a.meshes[0].primitives[0];
1838
+ if (!c)
1821
1839
  throw new Error("First mesh has no primitives");
1822
- const d = l.attributes.POSITION;
1840
+ const d = c.attributes.POSITION;
1823
1841
  if (d === void 0)
1824
1842
  throw new Error("Mesh primitive missing POSITION attribute");
1825
1843
  const S = ti(a, o, d, 3, 5126);
1826
1844
  let b;
1827
- if (l.attributes.NORMAL !== void 0)
1828
- b = ti(a, o, l.attributes.NORMAL, 3, 5126);
1845
+ if (c.attributes.NORMAL !== void 0)
1846
+ b = ti(a, o, c.attributes.NORMAL, 3, 5126);
1829
1847
  else {
1830
- const T = l.indices;
1848
+ const T = c.indices;
1831
1849
  if (T === void 0)
1832
1850
  throw new Error("Cannot generate normals without indices");
1833
- const F = Di(a, o, T);
1834
- b = ar(S, F);
1851
+ const F = Gi(a, o, T);
1852
+ b = lr(S, F);
1835
1853
  }
1836
- const p = l.indices;
1837
- if (p === void 0)
1854
+ const h = c.indices;
1855
+ if (h === void 0)
1838
1856
  throw new Error("Mesh primitive missing indices");
1839
- const v = Di(a, o, p), E = S.length / 3, I = v.length;
1840
- let z = null;
1841
- l.attributes.TEXCOORD_0 !== void 0 && (z = ti(a, o, l.attributes.TEXCOORD_0, 2, 5126));
1857
+ const v = Gi(a, o, h), C = S.length / 3, z = v.length;
1858
+ let D = null;
1859
+ c.attributes.TEXCOORD_0 !== void 0 && (D = ti(a, o, c.attributes.TEXCOORD_0, 2, 5126));
1842
1860
  let _ = !1;
1843
1861
  if (a.materials && a.materials.length > 0) {
1844
1862
  const T = a.materials[0];
1845
1863
  T.pbrMetallicRoughness && T.pbrMetallicRoughness.baseColorTexture !== void 0 && (_ = !0);
1846
1864
  }
1847
- let W = null;
1865
+ let Z = null;
1848
1866
  if (a.skins && a.skins.length > 0)
1849
1867
  try {
1850
- W = fr(a, o, l), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", W);
1868
+ Z = hr(a, o, c), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", Z);
1851
1869
  } catch (T) {
1852
1870
  console.warn("Failed to extract animation data:", T);
1853
1871
  }
@@ -1855,10 +1873,10 @@ async function nr(s) {
1855
1873
  positions: S,
1856
1874
  normals: b,
1857
1875
  indices: v,
1858
- texCoords: z,
1859
- vertexCount: E,
1860
- indexCount: I,
1861
- animationData: W,
1876
+ texCoords: D,
1877
+ vertexCount: C,
1878
+ indexCount: z,
1879
+ animationData: Z,
1862
1880
  hasBaseColorTexture: _
1863
1881
  };
1864
1882
  }
@@ -1873,137 +1891,137 @@ function ti(s, t, e, i, r) {
1873
1891
  throw new Error(`Attribute accessor type mismatch: expected ${i} components, got ${o}`);
1874
1892
  if (n.componentType !== r)
1875
1893
  throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
1876
- const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), d = n.count, S = new DataView(t, l, d * i * 4), b = new Float32Array(d * i);
1877
- for (let p = 0; p < d * i; p++)
1878
- b[p] = S.getFloat32(p * 4, !0);
1894
+ const c = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), d = n.count, S = new DataView(t, c, d * i * 4), b = new Float32Array(d * i);
1895
+ for (let h = 0; h < d * i; h++)
1896
+ b[h] = S.getFloat32(h * 4, !0);
1879
1897
  return b;
1880
1898
  }
1881
- function Di(s, t, e) {
1899
+ function Gi(s, t, e) {
1882
1900
  const i = s.accessors[e];
1883
1901
  if (i.type !== "SCALAR")
1884
1902
  throw new Error(`Indices accessor must be SCALAR, got ${i.type}`);
1885
1903
  const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count;
1886
1904
  if (i.componentType === 5123) {
1887
- const o = new DataView(t, n, a * 2), c = new Uint16Array(a);
1888
- for (let l = 0; l < a; l++)
1889
- c[l] = o.getUint16(l * 2, !0);
1890
- return c;
1905
+ const o = new DataView(t, n, a * 2), l = new Uint16Array(a);
1906
+ for (let c = 0; c < a; c++)
1907
+ l[c] = o.getUint16(c * 2, !0);
1908
+ return l;
1891
1909
  } else if (i.componentType === 5125) {
1892
- const o = new DataView(t, n, a * 4), c = new Uint32Array(a);
1893
- for (let l = 0; l < a; l++)
1894
- c[l] = o.getUint32(l * 4, !0);
1895
- return c;
1910
+ const o = new DataView(t, n, a * 4), l = new Uint32Array(a);
1911
+ for (let c = 0; c < a; c++)
1912
+ l[c] = o.getUint32(c * 4, !0);
1913
+ return l;
1896
1914
  } else
1897
1915
  throw new Error(`Unsupported index component type: ${i.componentType}`);
1898
1916
  }
1899
- function ar(s, t) {
1917
+ function lr(s, t) {
1900
1918
  const e = new Float32Array(s.length);
1901
1919
  for (let i = 0; i < t.length; i += 3) {
1902
- const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], c = [s[n], s[n + 1], s[n + 2]], l = [s[a], s[a + 1], s[a + 2]], d = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], S = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], b = [
1920
+ const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], l = [s[n], s[n + 1], s[n + 2]], c = [s[a], s[a + 1], s[a + 2]], d = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], S = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], b = [
1903
1921
  d[1] * S[2] - d[2] * S[1],
1904
1922
  d[2] * S[0] - d[0] * S[2],
1905
1923
  d[0] * S[1] - d[1] * S[0]
1906
- ], p = Math.sqrt(b[0] * b[0] + b[1] * b[1] + b[2] * b[2]);
1907
- p > 0 && (b[0] /= p, b[1] /= p, b[2] /= p), e[r] = e[n] = e[a] = b[0], e[r + 1] = e[n + 1] = e[a + 1] = b[1], e[r + 2] = e[n + 2] = e[a + 2] = b[2];
1924
+ ], h = Math.sqrt(b[0] * b[0] + b[1] * b[1] + b[2] * b[2]);
1925
+ h > 0 && (b[0] /= h, b[1] /= h, b[2] /= h), e[r] = e[n] = e[a] = b[0], e[r + 1] = e[n + 1] = e[a + 1] = b[1], e[r + 2] = e[n + 2] = e[a + 2] = b[2];
1908
1926
  }
1909
1927
  return e;
1910
1928
  }
1911
- function or(s, t, e) {
1929
+ function cr(s, t, e) {
1912
1930
  const i = s.accessors[e];
1913
1931
  if (i.type !== "VEC4")
1914
1932
  throw new Error(`JOINTS_0 must be VEC4, got ${i.type}`);
1915
1933
  const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count;
1916
1934
  if (i.componentType === 5121) {
1917
- const o = new DataView(t, n, a * 4), c = new Uint8Array(a * 4);
1918
- for (let l = 0; l < a * 4; l++)
1919
- c[l] = o.getUint8(l);
1920
- return c;
1935
+ const o = new DataView(t, n, a * 4), l = new Uint8Array(a * 4);
1936
+ for (let c = 0; c < a * 4; c++)
1937
+ l[c] = o.getUint8(c);
1938
+ return l;
1921
1939
  } else if (i.componentType === 5123) {
1922
- const o = new DataView(t, n, a * 8), c = new Uint8Array(a * 4);
1923
- for (let l = 0; l < a * 4; l++)
1924
- c[l] = o.getUint16(l * 2, !0);
1925
- return c;
1940
+ const o = new DataView(t, n, a * 8), l = new Uint8Array(a * 4);
1941
+ for (let c = 0; c < a * 4; c++)
1942
+ l[c] = o.getUint16(c * 2, !0);
1943
+ return l;
1926
1944
  } else
1927
1945
  throw new Error(`Unsupported JOINTS_0 component type: ${i.componentType}`);
1928
1946
  }
1929
- function lr(s, t, e) {
1947
+ function ur(s, t, e) {
1930
1948
  const i = s.accessors[e];
1931
1949
  if (i.type !== "VEC4")
1932
1950
  throw new Error(`WEIGHTS_0 must be VEC4, got ${i.type}`);
1933
1951
  const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count;
1934
1952
  if (i.componentType === 5126) {
1935
- const o = new DataView(t, n, a * 16), c = new Float32Array(a * 4);
1936
- for (let l = 0; l < a * 4; l++)
1937
- c[l] = o.getFloat32(l * 4, !0);
1938
- return c;
1953
+ const o = new DataView(t, n, a * 16), l = new Float32Array(a * 4);
1954
+ for (let c = 0; c < a * 4; c++)
1955
+ l[c] = o.getFloat32(c * 4, !0);
1956
+ return l;
1939
1957
  } else if (i.componentType === 5121) {
1940
- const o = new DataView(t, n, a * 4), c = new Float32Array(a * 4);
1941
- for (let l = 0; l < a * 4; l++)
1942
- c[l] = o.getUint8(l) / 255;
1943
- return c;
1958
+ const o = new DataView(t, n, a * 4), l = new Float32Array(a * 4);
1959
+ for (let c = 0; c < a * 4; c++)
1960
+ l[c] = o.getUint8(c) / 255;
1961
+ return l;
1944
1962
  } else
1945
1963
  throw new Error(`Unsupported WEIGHTS_0 component type: ${i.componentType}`);
1946
1964
  }
1947
- function cr(s, t, e) {
1965
+ function dr(s, t, e) {
1948
1966
  const i = s.accessors[e];
1949
1967
  if (i.type !== "MAT4")
1950
1968
  throw new Error(`Expected MAT4, got ${i.type}`);
1951
1969
  if (i.componentType !== 5126)
1952
1970
  throw new Error(`Expected FLOAT component type for MAT4, got ${i.componentType}`);
1953
- const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count, o = new DataView(t, n, a * 64), c = new Float32Array(a * 16);
1954
- for (let l = 0; l < a * 16; l++)
1955
- c[l] = o.getFloat32(l * 4, !0);
1956
- return c;
1971
+ const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count, o = new DataView(t, n, a * 64), l = new Float32Array(a * 16);
1972
+ for (let c = 0; c < a * 16; c++)
1973
+ l[c] = o.getFloat32(c * 4, !0);
1974
+ return l;
1957
1975
  }
1958
- function ur(s, t, e) {
1976
+ function fr(s, t, e) {
1959
1977
  const i = s.accessors[e];
1960
1978
  if (i.type !== "SCALAR")
1961
1979
  throw new Error(`Expected SCALAR, got ${i.type}`);
1962
1980
  if (i.componentType !== 5126)
1963
1981
  throw new Error(`Expected FLOAT component type for SCALAR, got ${i.componentType}`);
1964
- const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count, o = new DataView(t, n, a * 4), c = new Float32Array(a);
1965
- for (let l = 0; l < a; l++)
1966
- c[l] = o.getFloat32(l * 4, !0);
1967
- return c;
1982
+ const n = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), a = i.count, o = new DataView(t, n, a * 4), l = new Float32Array(a);
1983
+ for (let c = 0; c < a; c++)
1984
+ l[c] = o.getFloat32(c * 4, !0);
1985
+ return l;
1968
1986
  }
1969
- function dr(s, t, e) {
1987
+ function pr(s, t, e) {
1970
1988
  const i = s.accessors[e], n = { VEC3: 3, VEC4: 4 }[i.type];
1971
1989
  if (!n)
1972
1990
  throw new Error(`Expected VEC3 or VEC4, got ${i.type}`);
1973
1991
  if (i.componentType !== 5126)
1974
1992
  throw new Error(`Expected FLOAT component type, got ${i.componentType}`);
1975
- const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), c = i.count, l = new DataView(t, o, c * n * 4), d = new Float32Array(c * n);
1976
- for (let S = 0; S < c * n; S++)
1977
- d[S] = l.getFloat32(S * 4, !0);
1993
+ const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), l = i.count, c = new DataView(t, o, l * n * 4), d = new Float32Array(l * n);
1994
+ for (let S = 0; S < l * n; S++)
1995
+ d[S] = c.getFloat32(S * 4, !0);
1978
1996
  return d;
1979
1997
  }
1980
- function fr(s, t, e) {
1981
- const i = s.skins[0], r = i.joints, n = cr(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? or(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? lr(s, t, e.attributes.WEIGHTS_0) : null;
1998
+ function hr(s, t, e) {
1999
+ const i = s.skins[0], r = i.joints, n = dr(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? cr(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? ur(s, t, e.attributes.WEIGHTS_0) : null;
1982
2000
  if (!a || !o)
1983
2001
  throw new Error("Mesh missing JOINTS_0 or WEIGHTS_0 attributes");
1984
- const c = s.nodes.map((d) => ({
2002
+ const l = s.nodes.map((d) => ({
1985
2003
  translation: d.translation || [0, 0, 0],
1986
2004
  rotation: d.rotation || [0, 0, 0, 1],
1987
2005
  scale: d.scale || [1, 1, 1],
1988
2006
  children: d.children || [],
1989
2007
  name: d.name || ""
1990
- })), l = [];
2008
+ })), c = [];
1991
2009
  if (s.animations && s.animations.length > 0)
1992
2010
  for (const d of s.animations) {
1993
2011
  const S = [];
1994
2012
  let b = 0;
1995
- for (const p of d.channels) {
1996
- const v = d.samplers[p.sampler], E = ur(s, t, v.input), I = dr(s, t, v.output), z = E[E.length - 1];
1997
- z > b && (b = z), S.push({
1998
- targetNode: p.target.node,
1999
- targetPath: p.target.path,
2013
+ for (const h of d.channels) {
2014
+ const v = d.samplers[h.sampler], C = fr(s, t, v.input), z = pr(s, t, v.output), D = C[C.length - 1];
2015
+ D > b && (b = D), S.push({
2016
+ targetNode: h.target.node,
2017
+ targetPath: h.target.path,
2000
2018
  interpolation: v.interpolation || "LINEAR",
2001
- timestamps: E,
2002
- values: I
2019
+ timestamps: C,
2020
+ values: z
2003
2021
  });
2004
2022
  }
2005
- l.push({
2006
- name: d.name || `Animation ${l.length}`,
2023
+ c.push({
2024
+ name: d.name || `Animation ${c.length}`,
2007
2025
  duration: b,
2008
2026
  channels: S
2009
2027
  });
@@ -2013,8 +2031,8 @@ function fr(s, t, e) {
2013
2031
  inverseBindMatrices: n,
2014
2032
  jointIndices: a,
2015
2033
  jointWeights: o,
2016
- nodes: c,
2017
- animations: l
2034
+ nodes: l,
2035
+ animations: c
2018
2036
  };
2019
2037
  }
2020
2038
  async function Vi(s) {
@@ -2027,38 +2045,38 @@ async function Vi(s) {
2027
2045
  const r = t.getUint32(8, !0);
2028
2046
  let n = 12, a = null, o = null;
2029
2047
  for (; n < r; ) {
2030
- const W = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), F = s.slice(n + 8, n + 8 + W);
2048
+ const Z = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), F = s.slice(n + 8, n + 8 + Z);
2031
2049
  if (T === 1313821514) {
2032
2050
  const H = new TextDecoder("utf-8").decode(F);
2033
2051
  a = JSON.parse(H);
2034
2052
  } else T === 5130562 && (o = F);
2035
- n += 8 + W;
2053
+ n += 8 + Z;
2036
2054
  }
2037
2055
  if (!a)
2038
2056
  throw new Error("GLB file missing JSON chunk");
2039
2057
  if (!a.materials || a.materials.length === 0)
2040
2058
  return null;
2041
- const c = a.materials[0];
2042
- if (!c.pbrMetallicRoughness || c.pbrMetallicRoughness.baseColorTexture === void 0)
2059
+ const l = a.materials[0];
2060
+ if (!l.pbrMetallicRoughness || l.pbrMetallicRoughness.baseColorTexture === void 0)
2043
2061
  return null;
2044
- const l = c.pbrMetallicRoughness.baseColorTexture.index;
2045
- if (!a.textures || !a.textures[l])
2062
+ const c = l.pbrMetallicRoughness.baseColorTexture.index;
2063
+ if (!a.textures || !a.textures[c])
2046
2064
  return null;
2047
- const S = a.textures[l].source;
2065
+ const S = a.textures[c].source;
2048
2066
  if (S === void 0 || !a.images || !a.images[S])
2049
2067
  return null;
2050
- const b = a.images[S], p = b.mimeType || "image/png";
2068
+ const b = a.images[S], h = b.mimeType || "image/png";
2051
2069
  if (b.bufferView === void 0)
2052
2070
  return null;
2053
2071
  if (!o)
2054
2072
  throw new Error("GLB file missing BIN chunk (required for embedded textures)");
2055
- const v = a.bufferViews[b.bufferView], E = v.byteOffset || 0, I = v.byteLength, z = o.slice(E, E + I);
2056
- return { imageBlob: new Blob([z], { type: p }), mimeType: p };
2073
+ const v = a.bufferViews[b.bufferView], C = v.byteOffset || 0, z = v.byteLength, D = o.slice(C, C + z);
2074
+ return { imageBlob: new Blob([D], { type: h }), mimeType: h };
2057
2075
  }
2058
- function pr(s, t, e, i) {
2076
+ function mr(s, t, e, i) {
2059
2077
  return i = i || [0, 0, 0], i[0] = s[0] + (t[0] - s[0]) * e, i[1] = s[1] + (t[1] - s[1]) * e, i[2] = s[2] + (t[2] - s[2]) * e, i;
2060
2078
  }
2061
- function hr(s, t, e, i) {
2079
+ function yr(s, t, e, i) {
2062
2080
  i = i || [0, 0, 0, 0];
2063
2081
  let r = s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3], n = 1;
2064
2082
  if (r < 0 && (r = -r, n = -1), r > 0.9995) {
@@ -2066,16 +2084,16 @@ function hr(s, t, e, i) {
2066
2084
  const d = Math.sqrt(i[0] * i[0] + i[1] * i[1] + i[2] * i[2] + i[3] * i[3]);
2067
2085
  return d > 1e-4 ? (i[0] /= d, i[1] /= d, i[2] /= d, i[3] /= d) : (i[0] = 0, i[1] = 0, i[2] = 0, i[3] = 1), i;
2068
2086
  }
2069
- const a = Math.acos(r), o = Math.sin(a), c = Math.sin((1 - e) * a) / o, l = Math.sin(e * a) / o;
2070
- return i[0] = s[0] * c + n * t[0] * l, i[1] = s[1] * c + n * t[1] * l, i[2] = s[2] * c + n * t[2] * l, i[3] = s[3] * c + n * t[3] * l, i;
2087
+ const a = Math.acos(r), o = Math.sin(a), l = Math.sin((1 - e) * a) / o, c = Math.sin(e * a) / o;
2088
+ return i[0] = s[0] * l + n * t[0] * c, i[1] = s[1] * l + n * t[1] * c, i[2] = s[2] * l + n * t[2] * c, i[3] = s[3] * l + n * t[3] * c, i;
2071
2089
  }
2072
- function mr(s, t) {
2073
- const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, c = r + r, l = e * a, d = e * o, S = e * c, b = i * o, p = i * c, v = r * c, E = n * a, I = n * o, z = n * c, _ = t || new Float32Array(16);
2074
- return _[0] = 1 - (b + v), _[1] = d + z, _[2] = S - I, _[3] = 0, _[4] = d - z, _[5] = 1 - (l + v), _[6] = p + E, _[7] = 0, _[8] = S + I, _[9] = p - E, _[10] = 1 - (l + b), _[11] = 0, _[12] = 0, _[13] = 0, _[14] = 0, _[15] = 1, _;
2090
+ function gr(s, t) {
2091
+ const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, l = r + r, c = e * a, d = e * o, S = e * l, b = i * o, h = i * l, v = r * l, C = n * a, z = n * o, D = n * l, _ = t || new Float32Array(16);
2092
+ return _[0] = 1 - (b + v), _[1] = d + D, _[2] = S - z, _[3] = 0, _[4] = d - D, _[5] = 1 - (c + v), _[6] = h + C, _[7] = 0, _[8] = S + z, _[9] = h - C, _[10] = 1 - (c + b), _[11] = 0, _[12] = 0, _[13] = 0, _[14] = 0, _[15] = 1, _;
2075
2093
  }
2076
- const yr = new Float32Array(16);
2077
- function gr(s, t, e, i) {
2078
- const r = mr(t, yr), n = i || new Float32Array(16);
2094
+ const br = new Float32Array(16);
2095
+ function Sr(s, t, e, i) {
2096
+ const r = gr(t, br), n = i || new Float32Array(16);
2079
2097
  return n[0] = r[0] * e[0], n[1] = r[1] * e[0], n[2] = r[2] * e[0], n[3] = 0, n[4] = r[4] * e[1], n[5] = r[5] * e[1], n[6] = r[6] * e[1], n[7] = 0, n[8] = r[8] * e[2], n[9] = r[9] * e[2], n[10] = r[10] * e[2], n[11] = 0, n[12] = s[0], n[13] = s[1], n[14] = s[2], n[15] = 1, n;
2080
2098
  }
2081
2099
  function Oi(s, t, e) {
@@ -2085,7 +2103,7 @@ function Oi(s, t, e) {
2085
2103
  i[r * 4 + n] = s[0 + n] * t[r * 4 + 0] + s[4 + n] * t[r * 4 + 1] + s[8 + n] * t[r * 4 + 2] + s[12 + n] * t[r * 4 + 3];
2086
2104
  return i;
2087
2105
  }
2088
- class br {
2106
+ class xr {
2089
2107
  constructor(t) {
2090
2108
  this.joints = t.joints, this.inverseBindMatrices = t.inverseBindMatrices, this.jointWeights = t.jointWeights, this.jointIndices = t.jointIndices, this.nodes = t.nodes, this.animations = t.animations, this.restPositions = null, this.restNormals = null, this.currentAnimIndex = 0, this.currentTime = 0, this.playing = !0, this.speed = 1, this.loop = !0, this.jointLocalTransforms = new Array(this.nodes.length), this.jointGlobalTransforms = new Array(this.nodes.length), this.jointFinalMatrices = new Array(this.joints.length);
2091
2109
  for (let e = 0; e < this.nodes.length; e++)
@@ -2115,9 +2133,9 @@ class br {
2115
2133
  try {
2116
2134
  this._gpuDevice = t, this._gpuOutputBuffer = e;
2117
2135
  const r = this.restPositions.length / 3, n = new Float32Array(r * 8);
2118
- for (let c = 0; c < r; c++) {
2119
- const l = c * 8, d = c * 3, S = c * 2;
2120
- n[l] = this.restPositions[d], n[l + 1] = this.restPositions[d + 1], n[l + 2] = this.restPositions[d + 2], n[l + 3] = this.restNormals[d], n[l + 4] = this.restNormals[d + 1], n[l + 5] = this.restNormals[d + 2], n[l + 6] = i ? i[S] : 0, n[l + 7] = i ? i[S + 1] : 0;
2136
+ for (let l = 0; l < r; l++) {
2137
+ const c = l * 8, d = l * 3, S = l * 2;
2138
+ n[c] = this.restPositions[d], n[c + 1] = this.restPositions[d + 1], n[c + 2] = this.restPositions[d + 2], n[c + 3] = this.restNormals[d], n[c + 4] = this.restNormals[d + 1], n[c + 5] = this.restNormals[d + 2], n[c + 6] = i ? i[S] : 0, n[c + 7] = i ? i[S + 1] : 0;
2121
2139
  }
2122
2140
  this._gpuRestDataBuffer = t.createBuffer({
2123
2141
  size: n.byteLength,
@@ -2129,8 +2147,8 @@ class br {
2129
2147
  label: "skinning_jointWeights"
2130
2148
  }), t.queue.writeBuffer(this._gpuJointWeightsBuffer, 0, this.jointWeights);
2131
2149
  const a = new Uint32Array(this.jointIndices.length);
2132
- for (let c = 0; c < this.jointIndices.length; c++)
2133
- a[c] = this.jointIndices[c];
2150
+ for (let l = 0; l < this.jointIndices.length; l++)
2151
+ a[l] = this.jointIndices[l];
2134
2152
  this._gpuJointIndicesBuffer = t.createBuffer({
2135
2153
  size: a.byteLength,
2136
2154
  usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST,
@@ -2152,7 +2170,7 @@ class br {
2152
2170
  this._gpuSkinningPipeline = t.createComputePipeline({
2153
2171
  layout: t.createPipelineLayout({ bindGroupLayouts: [o] }),
2154
2172
  compute: {
2155
- module: t.createShaderModule({ code: Js }),
2173
+ module: t.createShaderModule({ code: Qs }),
2156
2174
  entryPoint: "main"
2157
2175
  }
2158
2176
  }), this._gpuSkinningBindGroup = t.createBindGroup({
@@ -2240,13 +2258,13 @@ class br {
2240
2258
  return this._extractValue(n, 0, o, i);
2241
2259
  if (e >= r[r.length - 1])
2242
2260
  return this._extractValue(n, r.length - 1, o, i);
2243
- let c = 0, l = r.length - 1;
2244
- for (; l - c > 1; ) {
2245
- const E = Math.floor((c + l) / 2);
2246
- r[E] <= e ? c = E : l = E;
2261
+ let l = 0, c = r.length - 1;
2262
+ for (; c - l > 1; ) {
2263
+ const C = Math.floor((l + c) / 2);
2264
+ r[C] <= e ? l = C : c = C;
2247
2265
  }
2248
- const d = r[c], S = r[l], b = (e - d) / (S - d), p = this._extractValue(n, c, o, this._sV0), v = this._extractValue(n, l, o, this._sV1);
2249
- return a === "STEP" ? (i[0] = p[0], i[1] = p[1], i[2] = p[2], o === "rotation" && (i[3] = p[3]), i) : o === "rotation" ? hr(p, v, b, i) : pr(p, v, b, i);
2266
+ const d = r[l], S = r[c], b = (e - d) / (S - d), h = this._extractValue(n, l, o, this._sV0), v = this._extractValue(n, c, o, this._sV1);
2267
+ return a === "STEP" ? (i[0] = h[0], i[1] = h[1], i[2] = h[2], o === "rotation" && (i[3] = h[3]), i) : o === "rotation" ? yr(h, v, b, i) : mr(h, v, b, i);
2250
2268
  }
2251
2269
  /**
2252
2270
  * Extract value from values array at the given index.
@@ -2269,9 +2287,9 @@ class br {
2269
2287
  for (let i = 0; i < this.nodes.length; i++) {
2270
2288
  const r = this.nodes[i];
2271
2289
  let n = r.translation, a = r.rotation, o = r.scale;
2272
- for (const c of e.channels)
2273
- c.targetNode === i && (c.targetPath === "translation" ? n = this._sampleChannel(c, t, this._scrT) : c.targetPath === "rotation" ? a = this._sampleChannel(c, t, this._scrR) : c.targetPath === "scale" && (o = this._sampleChannel(c, t, this._scrS)));
2274
- gr(n, a, o, this.jointLocalTransforms[i]);
2290
+ for (const l of e.channels)
2291
+ l.targetNode === i && (l.targetPath === "translation" ? n = this._sampleChannel(l, t, this._scrT) : l.targetPath === "rotation" ? a = this._sampleChannel(l, t, this._scrR) : l.targetPath === "scale" && (o = this._sampleChannel(l, t, this._scrS)));
2292
+ Sr(n, a, o, this.jointLocalTransforms[i]);
2275
2293
  }
2276
2294
  }
2277
2295
  /**
@@ -2302,22 +2320,22 @@ class br {
2302
2320
  * Inlined math, no temporary array allocations.
2303
2321
  */
2304
2322
  _applySkinning() {
2305
- const t = this.restPositions.length / 3, e = this.restPositions, i = this.restNormals, r = this.skinnedPositions, n = this.skinnedNormals, a = this.jointWeights, o = this.jointIndices, c = this.jointFinalMatrices;
2306
- for (let l = 0; l < t; l++) {
2307
- const d = l * 3, S = l * 4, b = e[d], p = e[d + 1], v = e[d + 2], E = i[d], I = i[d + 1], z = i[d + 2];
2308
- let _ = 0, W = 0, T = 0, F = 0, G = 0, H = 0;
2309
- for (let ae = 0; ae < 4; ae++) {
2310
- const ne = a[S + ae];
2311
- if (ne === 0) continue;
2312
- const q = c[o[S + ae]];
2313
- _ += (q[0] * b + q[4] * p + q[8] * v + q[12]) * ne, W += (q[1] * b + q[5] * p + q[9] * v + q[13]) * ne, T += (q[2] * b + q[6] * p + q[10] * v + q[14]) * ne, F += (q[0] * E + q[4] * I + q[8] * z) * ne, G += (q[1] * E + q[5] * I + q[9] * z) * ne, H += (q[2] * E + q[6] * I + q[10] * z) * ne;
2323
+ const t = this.restPositions.length / 3, e = this.restPositions, i = this.restNormals, r = this.skinnedPositions, n = this.skinnedNormals, a = this.jointWeights, o = this.jointIndices, l = this.jointFinalMatrices;
2324
+ for (let c = 0; c < t; c++) {
2325
+ const d = c * 3, S = c * 4, b = e[d], h = e[d + 1], v = e[d + 2], C = i[d], z = i[d + 1], D = i[d + 2];
2326
+ let _ = 0, Z = 0, T = 0, F = 0, G = 0, H = 0;
2327
+ for (let ne = 0; ne < 4; ne++) {
2328
+ const re = a[S + ne];
2329
+ if (re === 0) continue;
2330
+ const j = l[o[S + ne]];
2331
+ _ += (j[0] * b + j[4] * h + j[8] * v + j[12]) * re, Z += (j[1] * b + j[5] * h + j[9] * v + j[13]) * re, T += (j[2] * b + j[6] * h + j[10] * v + j[14]) * re, F += (j[0] * C + j[4] * z + j[8] * D) * re, G += (j[1] * C + j[5] * z + j[9] * D) * re, H += (j[2] * C + j[6] * z + j[10] * D) * re;
2314
2332
  }
2315
- const re = Math.sqrt(F * F + G * G + H * H);
2316
- re > 1e-4 && (n[d] = F / re, n[d + 1] = G / re, n[d + 2] = H / re), r[d] = _, r[d + 1] = W, r[d + 2] = T;
2333
+ const se = Math.sqrt(F * F + G * G + H * H);
2334
+ se > 1e-4 && (n[d] = F / se, n[d + 1] = G / se, n[d + 2] = H / se), r[d] = _, r[d + 1] = Z, r[d + 2] = T;
2317
2335
  }
2318
2336
  }
2319
2337
  }
2320
- class Sr {
2338
+ class vr {
2321
2339
  constructor({ duration: t = 0, loop: e = !1, playbackRate: i = 1 } = {}) {
2322
2340
  this.currentTime = 0, this.duration = t, this.loop = e, this.playbackRate = i, this.paused = !1, this._justLooped = !1;
2323
2341
  }
@@ -2357,26 +2375,26 @@ const Li = {
2357
2375
  return Math.pow(2, -10 * s) * Math.sin((s * 10 - 0.75) * t) + 1;
2358
2376
  }
2359
2377
  };
2360
- function xr(s, t, e, i) {
2361
- const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, c = 3 * (i - t) - o, l = 1 - o - c, d = (p) => ((a * p + n) * p + r) * p, S = (p) => ((l * p + c) * p + o) * p, b = (p) => (3 * a * p + 2 * n) * p + r;
2362
- return (p) => {
2363
- if (p <= 0) return 0;
2364
- if (p >= 1) return 1;
2365
- let v = p;
2366
- for (let E = 0; E < 8; E++) {
2367
- const I = d(v) - p;
2368
- if (Math.abs(I) < 1e-5) break;
2369
- const z = b(v);
2370
- if (Math.abs(z) < 1e-6) break;
2371
- v -= I / z;
2378
+ function Pr(s, t, e, i) {
2379
+ const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, l = 3 * (i - t) - o, c = 1 - o - l, d = (h) => ((a * h + n) * h + r) * h, S = (h) => ((c * h + l) * h + o) * h, b = (h) => (3 * a * h + 2 * n) * h + r;
2380
+ return (h) => {
2381
+ if (h <= 0) return 0;
2382
+ if (h >= 1) return 1;
2383
+ let v = h;
2384
+ for (let C = 0; C < 8; C++) {
2385
+ const z = d(v) - h;
2386
+ if (Math.abs(z) < 1e-5) break;
2387
+ const D = b(v);
2388
+ if (Math.abs(D) < 1e-6) break;
2389
+ v -= z / D;
2372
2390
  }
2373
2391
  return S(v);
2374
2392
  };
2375
2393
  }
2376
- function Wi(s, t) {
2377
- return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? xr(s[0], s[1], s[2], s[3])(t) : (Li[s] || Li.linear)(t);
2394
+ function $i(s, t) {
2395
+ return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? Pr(s[0], s[1], s[2], s[3])(t) : (Li[s] || Li.linear)(t);
2378
2396
  }
2379
- function vr(s, t) {
2397
+ function _r(s, t) {
2380
2398
  if (!Array.isArray(s) || s.length === 0) return;
2381
2399
  if (s.length === 1 || t <= s[0].t) return s[0].v;
2382
2400
  const e = s[s.length - 1];
@@ -2385,12 +2403,12 @@ function vr(s, t) {
2385
2403
  const r = s[i], n = s[i + 1];
2386
2404
  if (t >= r.t && t <= n.t) {
2387
2405
  const a = n.t - r.t, o = a > 0 ? (t - r.t) / a : 0;
2388
- return r.v + (n.v - r.v) * Wi(r.ease, o);
2406
+ return r.v + (n.v - r.v) * $i(r.ease, o);
2389
2407
  }
2390
2408
  }
2391
2409
  return e.v;
2392
2410
  }
2393
- function Pr(s, t, e) {
2411
+ function Mr(s, t, e) {
2394
2412
  if (!Array.isArray(s) || s.length === 0) return;
2395
2413
  const i = s.length, r = s[i - 1];
2396
2414
  let n, a, o;
@@ -2401,18 +2419,18 @@ function Pr(s, t, e) {
2401
2419
  else {
2402
2420
  n = a = r.v, o = 0;
2403
2421
  for (let S = 0; S < i - 1; S++) {
2404
- const b = s[S], p = s[S + 1];
2405
- if (t >= b.t && t <= p.t) {
2406
- const v = p.t - b.t;
2407
- n = b.v, a = p.v, o = Wi(b.ease, v > 0 ? (t - b.t) / v : 0);
2422
+ const b = s[S], h = s[S + 1];
2423
+ if (t >= b.t && t <= h.t) {
2424
+ const v = h.t - b.t;
2425
+ n = b.v, a = h.v, o = $i(b.ease, v > 0 ? (t - b.t) / v : 0);
2408
2426
  break;
2409
2427
  }
2410
2428
  }
2411
2429
  }
2412
- const c = n[0] + (a[0] - n[0]) * o, l = n[1] + (a[1] - n[1]) * o, d = n[2] + (a[2] - n[2]) * o;
2413
- return e ? (e[0] = c, e[1] = l, e[2] = d, e) : [c, l, d];
2430
+ const l = n[0] + (a[0] - n[0]) * o, c = n[1] + (a[1] - n[1]) * o, d = n[2] + (a[2] - n[2]) * o;
2431
+ return e ? (e[0] = l, e[1] = c, e[2] = d, e) : [l, c, d];
2414
2432
  }
2415
- const _r = [
2433
+ const wr = [
2416
2434
  "gravityStrength",
2417
2435
  "emissionRate",
2418
2436
  "damping",
@@ -2447,7 +2465,7 @@ const _r = [
2447
2465
  "shapeStrokeAmplitude",
2448
2466
  "shapeStrokeFrequency",
2449
2467
  "shapeStrokeSpeed"
2450
- ], Mr = { square: 0, circle: 1, triangle: 2, diamond: 3, star: 4, hexagon: 5, ring: 6, heart: 7, cross: 8, spark: 9, leaf: 10, capsule: 11, crescent: 12, line: 13, "curved-line": 14 };
2468
+ ], Rr = { square: 0, circle: 1, triangle: 2, diamond: 3, star: 4, hexagon: 5, ring: 6, heart: 7, cross: 8, spark: 9, leaf: 10, capsule: 11, crescent: 12, line: 13, "curved-line": 14 };
2451
2469
  function ki(s) {
2452
2470
  const t = atob(s), e = new Uint8Array(t.length);
2453
2471
  for (let i = 0; i < t.length; i++)
@@ -2480,7 +2498,7 @@ class ii {
2480
2498
  // intensity (f32) + padding
2481
2499
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
2482
2500
  label: "systemBloomIntensityBuffer"
2483
- }), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.attractorReverse === void 0 && (e.attractorReverse = !1), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeStrokeEnabled === void 0 && (e.shapeStrokeEnabled = !1), e.shapeStrokeWidth === void 0 && (e.shapeStrokeWidth = 0.08), e.shapeStrokeSegments === void 0 && (e.shapeStrokeSegments = 96), e.shapeStrokeShape === void 0 && (e.shapeStrokeShape = "straight"), e.shapeStrokeAmplitude === void 0 && (e.shapeStrokeAmplitude = 0.08), e.shapeStrokeFrequency === void 0 && (e.shapeStrokeFrequency = 10), e.shapeStrokeSpeed === void 0 && (e.shapeStrokeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new Ys(e), this.physics = new Ks(t, this.MAX_PARTICLES), this.textureManager = new Qs(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition, e.attractorReverse), e.confinementEnabled && this.setConfinement({
2501
+ }), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.attractorReverse === void 0 && (e.attractorReverse = !1), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeStrokeEnabled === void 0 && (e.shapeStrokeEnabled = !1), e.shapeStrokeWidth === void 0 && (e.shapeStrokeWidth = 0.08), e.shapeStrokeSegments === void 0 && (e.shapeStrokeSegments = 96), e.shapeStrokeShape === void 0 && (e.shapeStrokeShape = "straight"), e.shapeStrokeAmplitude === void 0 && (e.shapeStrokeAmplitude = 0.08), e.shapeStrokeFrequency === void 0 && (e.shapeStrokeFrequency = 10), e.shapeStrokeSpeed === void 0 && (e.shapeStrokeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new qs(e), this.physics = new er(t, this.MAX_PARTICLES), this.textureManager = new tr(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition, e.attractorReverse), e.confinementEnabled && this.setConfinement({
2484
2502
  enabled: !0,
2485
2503
  shape: e.confinementShape,
2486
2504
  mode: e.confinementMode,
@@ -2493,7 +2511,7 @@ class ii {
2493
2511
  enabled: !0,
2494
2512
  strength: e.softBoundaryStrength,
2495
2513
  falloff: e.softBoundaryFalloff
2496
- }), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new Gi(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
2514
+ }), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new Fi(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
2497
2515
  }
2498
2516
  async initComputePipeline(t) {
2499
2517
  this.computeReady = await this.physics.initComputePipeline(this.instanceBuffer, this.velocityBuffer, this.trailBuffer);
@@ -2503,7 +2521,7 @@ class ii {
2503
2521
  * @param {string|null} source - Script source code, or null to disable
2504
2522
  */
2505
2523
  setScript(t) {
2506
- this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new Gi(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
2524
+ this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new Fi(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
2507
2525
  }
2508
2526
  async setTexture(t) {
2509
2527
  this.destroyed || (this.textureManager.destroyTexture(this.particleTexture), this.particleTexture = await this.textureManager.loadTexture(t), this.config.textureEnabled = !0, this.updateAppearanceUniform(), this.updateBuffers());
@@ -2514,7 +2532,7 @@ class ii {
2514
2532
  async setGLBModel(t) {
2515
2533
  try {
2516
2534
  this.glbRawArrayBuffer = t;
2517
- const e = await nr(t);
2535
+ const e = await or(t);
2518
2536
  this.glbMeshData = e, this.config.glbHasTexture = e.hasBaseColorTexture || !1;
2519
2537
  const i = new Float32Array(e.vertexCount * 8);
2520
2538
  for (let r = 0; r < e.vertexCount; r++) {
@@ -2530,7 +2548,7 @@ class ii {
2530
2548
  usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
2531
2549
  label: "glbIndexBuffer"
2532
2550
  }), this.device.queue.writeBuffer(this.glbIndexBuffer, 0, e.indices), this.glbIndexCount = e.indexCount, this.glbIndexFormat = e.indices instanceof Uint32Array ? "uint32" : "uint16", this.config.glbModelEnabled = !0, this.config.textureType = "glb", e.animationData) {
2533
- this.glbAnimator = new br(e.animationData), this.glbAnimator.setRestPose(e.positions, e.normals), this.glbAnimated = !0, this.config.glbAnimated = !0, this.glbAnimator.loop = this.config.animationLoop, this._glbInterleavedData = new Float32Array(e.vertexCount * 8);
2551
+ this.glbAnimator = new xr(e.animationData), this.glbAnimator.setRestPose(e.positions, e.normals), this.glbAnimated = !0, this.config.glbAnimated = !0, this.glbAnimator.loop = this.config.animationLoop, this._glbInterleavedData = new Float32Array(e.vertexCount * 8);
2534
2552
  try {
2535
2553
  await this.glbAnimator.initGPUSkinning(this.device, this.glbVertexBuffer, e.texCoords);
2536
2554
  } catch (r) {
@@ -2592,7 +2610,7 @@ class ii {
2592
2610
  if (this.destroyed) return;
2593
2611
  let t = 0;
2594
2612
  this.config.rotationMode === "random" ? t = 1 : this.config.rotationMode === "velocity" ? t = 2 : this.config.rotationMode === "oriented" ? t = 3 : this.config.rotationMode === "cylindrical" && (t = 4);
2595
- const e = Mr[this.config.particleShape] ?? 0, i = this._appearanceData;
2613
+ const e = Rr[this.config.particleShape] ?? 0, i = this._appearanceData;
2596
2614
  i[0] = this.config.fadeEnabled ? 1 : 0, i[1] = this.config.randomColorEnabled ? 2 : this.config.colorTransitionEnabled ? 1 : 0, i[2] = this.config.particleSize, i[3] = this.config.textureEnabled ? 1 : 0, i[4] = this.config.particleColor[0], i[5] = this.config.particleColor[1], i[6] = this.config.particleColor[2], i[7] = this.config.rotation || 0, i[8] = this.config.startColor[0], i[9] = this.config.startColor[1], i[10] = this.config.startColor[2], i[11] = t, i[12] = this.config.endColor[0], i[13] = this.config.endColor[1], i[14] = this.config.endColor[2], i[15] = this.config.minRotation || 0, i[16] = this.config.maxRotation || 90, i[17] = this.config.aspectRatio || 1, i[18] = this.config.randomSize ? 1 : 0, i[19] = this.config.minSize || 0.1, i[20] = this.config.maxSize || 0.5, i[21] = this.config.fadeSizeEnabled ? 1 : 0, i[22] = this.config.opacity !== void 0 ? this.config.opacity : 1, i[23] = this.config.increaseSizeEnabled ? 1 : 0, i[24] = this.config.sizeLifetimeSpeed ?? 1, i[25] = e, i[26] = 0, i[27] = this.config.pulseEnabled ? 1 : 0, i[28] = this.config.pulseAmplitude ?? 0.5, i[29] = this.config.pulseFrequency ?? 1, i[30] = this.config.pulsePhaseRandom ?? 0, i[31] = this.config.pulseOpacity ? 1 : 0, i[32] = this.config.particleShapeRotationX || 0, i[33] = this.config.particleShapeRotationY || 0, i[34] = this.config.particleShapeRotationZ || 0, i[35] = 0;
2597
2615
  const r = this.config.followSystemTranslation ?? !0;
2598
2616
  i[36] = r ? this._simPosition[0] : 0, i[37] = r ? this._simPosition[1] : 0, i[38] = r ? this._simPosition[2] : 0, i[39] = 0, i[40] = this._simRotX, i[41] = this._simRotZ, i[42] = this.config.velocityStretchEnabled ? 1 : 0, i[43] = this.config.velocityStretchFactor ?? 1, i[44] = this.config.noiseDistortEnabled ? 1 : 0, i[45] = this.config.noiseTilingX ?? 3, i[46] = this.config.noiseTilingY ?? 3, i[47] = this.config.noiseSpeed ?? -1.5, i[48] = this.config.noiseAmplitude ?? 0.08, i[49] = r ? this._simVelocity[0] : 0, i[50] = r ? this._simVelocity[1] : 0, i[51] = r ? this._simVelocity[2] : 0, i[52] = this.config.orientX ?? 0, i[53] = this.config.orientY ?? 0, i[54] = this.config.orientZ ?? 0, i[55] = 0, this.device.queue.writeBuffer(this.appearanceUniformBuffer, 0, i);
@@ -2615,7 +2633,7 @@ class ii {
2615
2633
  const r = 500;
2616
2634
  for (let n = 0; n < e; n++)
2617
2635
  if (this.emitParticle(), i++, i >= r || n === e - 1) {
2618
- const a = n - i + 1, o = a * 8, c = a * 4;
2636
+ const a = n - i + 1, o = a * 8, l = a * 4;
2619
2637
  this.device.queue.writeBuffer(
2620
2638
  this.instanceBuffer,
2621
2639
  o * 4,
@@ -2625,10 +2643,10 @@ class ii {
2625
2643
  i * 8
2626
2644
  ), this.device.queue.writeBuffer(
2627
2645
  this.velocityBuffer,
2628
- c * 4,
2646
+ l * 4,
2629
2647
  // Offset in bytes
2630
2648
  this.particleVelocities,
2631
- c,
2649
+ l,
2632
2650
  i * 4
2633
2651
  ), i = 0;
2634
2652
  }
@@ -2654,8 +2672,8 @@ class ii {
2654
2672
  this._emitSimRotY = this._simRotY || 0;
2655
2673
  const e = t * 8, i = t * 4;
2656
2674
  if (this._simRotMatrix) {
2657
- const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2], c = this.particleVelocities[i], l = this.particleVelocities[i + 1], d = this.particleVelocities[i + 2];
2658
- this.particleData[e] = r[0] * n + r[1] * a + r[2] * o, this.particleData[e + 1] = r[3] * n + r[4] * a + r[5] * o, this.particleData[e + 2] = r[6] * n + r[7] * a + r[8] * o, this.particleVelocities[i] = r[0] * c + r[1] * l + r[2] * d, this.particleVelocities[i + 1] = r[3] * c + r[4] * l + r[5] * d, this.particleVelocities[i + 2] = r[6] * c + r[7] * l + r[8] * d;
2675
+ const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2], l = this.particleVelocities[i], c = this.particleVelocities[i + 1], d = this.particleVelocities[i + 2];
2676
+ this.particleData[e] = r[0] * n + r[1] * a + r[2] * o, this.particleData[e + 1] = r[3] * n + r[4] * a + r[5] * o, this.particleData[e + 2] = r[6] * n + r[7] * a + r[8] * o, this.particleVelocities[i] = r[0] * l + r[1] * c + r[2] * d, this.particleVelocities[i + 1] = r[3] * l + r[4] * c + r[5] * d, this.particleVelocities[i + 2] = r[6] * l + r[7] * c + r[8] * d;
2659
2677
  }
2660
2678
  (this.config.followSystemTranslation ?? !0) || (this.particleData[e] += this._simPosition[0], this.particleData[e + 1] += this._simPosition[1], this.particleData[e + 2] += this._simPosition[2]);
2661
2679
  }
@@ -2680,8 +2698,8 @@ class ii {
2680
2698
  if (this.activeParticles >= this.particleCount) return !1;
2681
2699
  const r = this.activeParticles * 8, n = t + (this.config.emissionPositionX || 0), a = e + (this.config.emissionPositionY || 0), o = i + (this.config.emissionPositionZ || 0);
2682
2700
  this.particleData[r] = n, this.particleData[r + 1] = a, this.particleData[r + 2] = o;
2683
- const c = this.activeParticles * 4;
2684
- return this.emitter.calculateVelocity(n, a, o, this.particleVelocities, c), this.emitter.setParticleColor(this.particleData, r), this.emitter.setParticleLifetime(this.particleData, r), this.activeParticles++, !0;
2701
+ const l = this.activeParticles * 4;
2702
+ return this.emitter.calculateVelocity(n, a, o, this.particleVelocities, l), this.emitter.setParticleColor(this.particleData, r), this.emitter.setParticleLifetime(this.particleData, r), this.activeParticles++, !0;
2685
2703
  }
2686
2704
  updateParticles(t, e, i = 0) {
2687
2705
  const r = this.config.startAt || 0, n = r > 0 && i < r;
@@ -2691,7 +2709,7 @@ class ii {
2691
2709
  if (d > 0 && this._scriptTime >= d && !this._scriptConfigRestored)
2692
2710
  this._scriptConfigRestored = !0, this._particleScript._configSnapshot && (this._particleScript.restoreConfig(this.config), this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse));
2693
2711
  else if (!this._scriptConfigRestored) {
2694
- const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty: b, particlesDirty: p } = this._particleScript.execute(
2712
+ const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty: b, particlesDirty: h } = this._particleScript.execute(
2695
2713
  t,
2696
2714
  this._scriptTime,
2697
2715
  this._scriptFrame,
@@ -2700,7 +2718,7 @@ class ii {
2700
2718
  this._scriptVelocityData,
2701
2719
  this.activeParticles
2702
2720
  );
2703
- p && this.activeParticles > 0 && (this.device.queue.writeBuffer(
2721
+ h && this.activeParticles > 0 && (this.device.queue.writeBuffer(
2704
2722
  this.instanceBuffer,
2705
2723
  0,
2706
2724
  this._scriptParticleData,
@@ -2716,7 +2734,7 @@ class ii {
2716
2734
  }
2717
2735
  }
2718
2736
  this.physics.physicsAccumulator += t;
2719
- const a = performance.now() / 1e3, c = a - this.physics.lastUpdateTime > 1 / this.physics.minUpdatesPerSecond, l = this.activeParticles;
2737
+ const a = performance.now() / 1e3, l = a - this.physics.lastUpdateTime > 1 / this.physics.minUpdatesPerSecond, c = this.activeParticles;
2720
2738
  if (!n && !this.emitting && !this.config.burstMode && !this.config.followSystemId && this.currentEmissionTime < this.effectiveEmissionDuration && (this.emitting = !0), !n && this.emitting)
2721
2739
  if (this.currentEmissionTime += t, this.currentEmissionTime < this.effectiveEmissionDuration) {
2722
2740
  const d = this.activeParticles;
@@ -2724,8 +2742,8 @@ class ii {
2724
2742
  if (this.config.followSystemId) {
2725
2743
  if (this._pendingFollowEmissions.length > 0) {
2726
2744
  const b = this._pendingFollowEmissions.length / 6;
2727
- for (let p = 0; p < b; p++) {
2728
- const v = p * 6;
2745
+ for (let h = 0; h < b; h++) {
2746
+ const v = h * 6;
2729
2747
  if (this.emitFollowerParticle(
2730
2748
  this._pendingFollowEmissions[v],
2731
2749
  this._pendingFollowEmissions[v + 1],
@@ -2738,8 +2756,8 @@ class ii {
2738
2756
  }
2739
2757
  } else {
2740
2758
  let b = 0;
2741
- const p = Math.max(0, this.config.emissionRate || 0);
2742
- this.activeParticles < this.particleCount && p > 0 ? (this.emissionAccumulator += p * t, b = Math.floor(this.emissionAccumulator + 1e-9), b > 0 && (this.emissionAccumulator -= b)) : this.activeParticles >= this.particleCount && (this.emissionAccumulator = 0);
2759
+ const h = Math.max(0, this.config.emissionRate || 0);
2760
+ this.activeParticles < this.particleCount && h > 0 ? (this.emissionAccumulator += h * t, b = Math.floor(this.emissionAccumulator + 1e-9), b > 0 && (this.emissionAccumulator -= b)) : this.activeParticles >= this.particleCount && (this.emissionAccumulator = 0);
2743
2761
  for (let v = 0; v < b; v++)
2744
2762
  if (this.emitParticle())
2745
2763
  S = !0;
@@ -2749,13 +2767,13 @@ class ii {
2749
2767
  }
2750
2768
  }
2751
2769
  if (S) {
2752
- const b = this.activeParticles - d, p = d * 8, v = d * 4;
2770
+ const b = this.activeParticles - d, h = d * 8, v = d * 4;
2753
2771
  this.device.queue.writeBuffer(
2754
2772
  this.instanceBuffer,
2755
- p * 4,
2773
+ h * 4,
2756
2774
  // Offset in bytes (float32 = 4 bytes)
2757
2775
  this.particleData,
2758
- p,
2776
+ h,
2759
2777
  b * 8
2760
2778
  ), this.device.queue.writeBuffer(
2761
2779
  this.velocityBuffer,
@@ -2771,15 +2789,15 @@ class ii {
2771
2789
  for (; this.physics.physicsAccumulator >= this.physics.fixedDeltaTime; )
2772
2790
  this.physics.updatePhysics(
2773
2791
  this.physics.fixedDeltaTime,
2774
- l,
2792
+ c,
2775
2793
  this.config,
2776
2794
  this.instanceBuffer,
2777
2795
  this.velocityBuffer,
2778
2796
  e
2779
2797
  ), this.physics.physicsAccumulator -= this.physics.fixedDeltaTime, this.physics.physicsClock += this.physics.fixedDeltaTime;
2780
- c && l > 0 && (this.physics.updatePhysics(
2798
+ l && c > 0 && (this.physics.updatePhysics(
2781
2799
  this.physics.fixedDeltaTime,
2782
- l,
2800
+ c,
2783
2801
  this.config,
2784
2802
  this.instanceBuffer,
2785
2803
  this.velocityBuffer,
@@ -2817,10 +2835,10 @@ class ii {
2817
2835
  continue;
2818
2836
  }
2819
2837
  if (e !== r) {
2820
- const o = r * 8, c = e * 8;
2821
- this.particleData.copyWithin(c, o, o + 8);
2822
- const l = r * 4, d = e * 4;
2823
- this.particleVelocities.copyWithin(d, l, l + 4), i = !0;
2838
+ const o = r * 8, l = e * 8;
2839
+ this.particleData.copyWithin(l, o, o + 8);
2840
+ const c = r * 4, d = e * 4;
2841
+ this.particleVelocities.copyWithin(d, c, c + 4), i = !0;
2824
2842
  }
2825
2843
  e++;
2826
2844
  }
@@ -2849,12 +2867,12 @@ class ii {
2849
2867
  }
2850
2868
  updateParticleVelocities() {
2851
2869
  for (let t = 0; t < this.activeParticles; t++) {
2852
- const e = t * 8, i = t * 4, r = this.particleData[e], n = this.particleData[e + 1], a = this.particleData[e + 2], o = this.particleVelocities[i], c = this.particleVelocities[i + 1], l = this.particleVelocities[i + 2], d = Math.sqrt(
2853
- o * o + c * c + l * l
2870
+ const e = t * 8, i = t * 4, r = this.particleData[e], n = this.particleData[e + 1], a = this.particleData[e + 2], o = this.particleVelocities[i], l = this.particleVelocities[i + 1], c = this.particleVelocities[i + 2], d = Math.sqrt(
2871
+ o * o + l * l + c * c
2854
2872
  );
2855
2873
  if (d > 1e-3) {
2856
2874
  const S = this.config.particleSpeed * 2;
2857
- this.particleVelocities[i] = o / d * S, this.particleVelocities[i + 1] = c / d * S, this.particleVelocities[i + 2] = l / d * S;
2875
+ this.particleVelocities[i] = o / d * S, this.particleVelocities[i + 1] = l / d * S, this.particleVelocities[i + 2] = c / d * S;
2858
2876
  } else {
2859
2877
  const S = Math.sqrt(r * r + n * n + a * a);
2860
2878
  if (S > 1e-3) {
@@ -2904,9 +2922,9 @@ class ii {
2904
2922
  this.physics.setSoftBoundary(t);
2905
2923
  }
2906
2924
  }
2907
- class wr {
2925
+ class Br {
2908
2926
  constructor(t) {
2909
- this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new Sr({ loop: !!this.loop }), this.ready = !0;
2927
+ this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new vr({ loop: !!this.loop }), this.ready = !0;
2910
2928
  }
2911
2929
  createParticleSystem(t = {}) {
2912
2930
  const e = this.systemCounter++, i = t.name || `System ${e + 1}`, r = {
@@ -2974,20 +2992,20 @@ class wr {
2974
2992
  const r = this.clock ? this.clock.currentTime : 0, n = this.clock ? this.clock.duration : 0;
2975
2993
  if (this.clock && n > 0 && isFinite(n)) {
2976
2994
  const a = Math.min(1, this.clock.currentTime / n);
2977
- for (const { system: o, config: c } of this.particleSystems)
2978
- this._applyKeyframesToSystem(o, c, a);
2995
+ for (const { system: o, config: l } of this.particleSystems)
2996
+ this._applyKeyframesToSystem(o, l, a);
2979
2997
  }
2980
2998
  for (const { system: a, config: o } of this.particleSystems) {
2981
2999
  if (o.hidden || o.followSystemId) continue;
2982
- const c = a.activeParticles > 0;
2983
- a.updateParticles(t, e, r), (c || a.activeParticles > 0) && (i = !0);
3000
+ const l = a.activeParticles > 0;
3001
+ a.updateParticles(t, e, r), (l || a.activeParticles > 0) && (i = !0);
2984
3002
  }
2985
3003
  for (const { system: a, config: o } of this.particleSystems) {
2986
3004
  if (o.hidden || !o.followSystemId) continue;
2987
- const c = this.getSystemById(o.followSystemId);
2988
- c && (a._pendingFollowEmissions = c.system._newEmissions);
2989
- const l = a.activeParticles > 0;
2990
- a.updateParticles(t, e, r), (l || a.activeParticles > 0) && (i = !0);
3005
+ const l = this.getSystemById(o.followSystemId);
3006
+ l && (a._pendingFollowEmissions = l.system._newEmissions);
3007
+ const c = a.activeParticles > 0;
3008
+ a.updateParticles(t, e, r), (c || a.activeParticles > 0) && (i = !0);
2991
3009
  }
2992
3010
  i && this.device.queue.submit([e.finish()]);
2993
3011
  for (const { system: a } of this.particleSystems)
@@ -3051,8 +3069,8 @@ class wr {
3051
3069
  try {
3052
3070
  const o = await Vi(a);
3053
3071
  if (o) {
3054
- const c = await createImageBitmap(o.imageBlob);
3055
- await r.setTexture(c), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${n.name}`);
3072
+ const l = await createImageBitmap(o.imageBlob);
3073
+ await r.setTexture(l), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${n.name}`);
3056
3074
  }
3057
3075
  } catch (o) {
3058
3076
  console.warn(`Failed to restore GLB texture for ${n.name}:`, o), n.useGlbTexture = !1;
@@ -3066,8 +3084,8 @@ class wr {
3066
3084
  if (n.textureEnabled && !n.glbModelEnabled && n.textureImageData)
3067
3085
  try {
3068
3086
  const a = new Image();
3069
- await new Promise((c, l) => {
3070
- a.onload = c, a.onerror = l, a.src = n.textureImageData;
3087
+ await new Promise((l, c) => {
3088
+ a.onload = l, a.onerror = c, a.src = n.textureImageData;
3071
3089
  });
3072
3090
  const o = await createImageBitmap(a);
3073
3091
  await r.setTexture(o);
@@ -3098,76 +3116,76 @@ class wr {
3098
3116
  const i = [];
3099
3117
  try {
3100
3118
  for (const o of t.systems) {
3101
- const c = this.systemCounter++;
3102
- i.push(c);
3103
- const l = {
3119
+ const l = this.systemCounter++;
3120
+ i.push(l);
3121
+ const c = {
3104
3122
  ...o,
3105
- id: c,
3123
+ id: l,
3106
3124
  // Apply world-space offset to emission translation
3107
3125
  emissionPositionX: (o.emissionPositionX || 0) + e[0],
3108
3126
  emissionPositionY: (o.emissionPositionY || 0) + e[1],
3109
3127
  emissionPositionZ: (o.emissionPositionZ || 0) + e[2]
3110
3128
  };
3111
- o.attractorEnabled && o.attractorPosition && (l.attractorPosition = [
3129
+ o.attractorEnabled && o.attractorPosition && (c.attractorPosition = [
3112
3130
  o.attractorPosition[0] + e[0],
3113
3131
  o.attractorPosition[1] + e[1],
3114
3132
  o.attractorPosition[2] + e[2]
3115
- ]), o.confinementEnabled && o.confinementSpace === "world" && Array.isArray(o.confinementCenter) && (l.confinementCenter = [
3133
+ ]), o.confinementEnabled && o.confinementSpace === "world" && Array.isArray(o.confinementCenter) && (c.confinementCenter = [
3116
3134
  (o.confinementCenter[0] || 0) + e[0],
3117
3135
  (o.confinementCenter[1] || 0) + e[1],
3118
3136
  (o.confinementCenter[2] || 0) + e[2]
3119
3137
  ]);
3120
- const d = new ii(this.device, l);
3138
+ const d = new ii(this.device, c);
3121
3139
  this.particleSystems.push({
3122
3140
  system: d,
3123
- config: l
3124
- }), this.onSystemCreated && typeof this.onSystemCreated == "function" && this.onSystemCreated(c, l);
3141
+ config: c
3142
+ }), this.onSystemCreated && typeof this.onSystemCreated == "function" && this.onSystemCreated(l, c);
3125
3143
  }
3126
3144
  const n = this.particleSystems.length - t.systems.length, a = {};
3127
- t.systems.forEach((o, c) => {
3128
- a[o.id] = this.particleSystems[n + c].config.id;
3145
+ t.systems.forEach((o, l) => {
3146
+ a[o.id] = this.particleSystems[n + l].config.id;
3129
3147
  });
3130
3148
  for (let o = n; o < this.particleSystems.length; o++) {
3131
- const { config: c } = this.particleSystems[o];
3132
- c.followSystemId && a[c.followSystemId] !== void 0 && (c.followSystemId = a[c.followSystemId]);
3149
+ const { config: l } = this.particleSystems[o];
3150
+ l.followSystemId && a[l.followSystemId] !== void 0 && (l.followSystemId = a[l.followSystemId]);
3133
3151
  }
3134
- for (const { system: o, config: c } of this.particleSystems)
3135
- if (c.glbModelEnabled && !o.glbMeshData)
3152
+ for (const { system: o, config: l } of this.particleSystems)
3153
+ if (l.glbModelEnabled && !o.glbMeshData)
3136
3154
  try {
3137
- let l = null;
3138
- if (c.glbModelData)
3139
- l = ki(c.glbModelData);
3140
- else if (c.glbFileName) {
3141
- const d = await fetch(`/${c.glbFileName}`);
3142
- d.ok ? l = await d.arrayBuffer() : console.warn(`GLB file not found: ${c.glbFileName}`);
3155
+ let c = null;
3156
+ if (l.glbModelData)
3157
+ c = ki(l.glbModelData);
3158
+ else if (l.glbFileName) {
3159
+ const d = await fetch(`/${l.glbFileName}`);
3160
+ d.ok ? c = await d.arrayBuffer() : console.warn(`GLB file not found: ${l.glbFileName}`);
3143
3161
  }
3144
- if (l) {
3145
- if (await o.setGLBModel(l), c.animationIndex !== void 0 && o.glbAnimator && o.glbAnimator.setAnimation(c.animationIndex), c.animationSpeed !== void 0 && o.glbAnimator && (o.glbAnimator.speed = c.animationSpeed), c.animationLoop !== void 0 && o.glbAnimator && (o.glbAnimator.loop = c.animationLoop), c.useGlbTexture && (c.textureEnabled = !0), c.useGlbTexture && ((r = o.glbMeshData) != null && r.hasBaseColorTexture))
3162
+ if (c) {
3163
+ if (await o.setGLBModel(c), l.animationIndex !== void 0 && o.glbAnimator && o.glbAnimator.setAnimation(l.animationIndex), l.animationSpeed !== void 0 && o.glbAnimator && (o.glbAnimator.speed = l.animationSpeed), l.animationLoop !== void 0 && o.glbAnimator && (o.glbAnimator.loop = l.animationLoop), l.useGlbTexture && (l.textureEnabled = !0), l.useGlbTexture && ((r = o.glbMeshData) != null && r.hasBaseColorTexture))
3146
3164
  try {
3147
- const d = await Vi(l);
3165
+ const d = await Vi(c);
3148
3166
  if (d) {
3149
3167
  const S = await createImageBitmap(d.imageBlob);
3150
- await o.setTexture(S), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${c.name}`);
3168
+ await o.setTexture(S), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${l.name}`);
3151
3169
  }
3152
3170
  } catch (d) {
3153
- console.warn(`Failed to restore GLB texture for ${c.name}:`, d), c.useGlbTexture = !1;
3171
+ console.warn(`Failed to restore GLB texture for ${l.name}:`, d), l.useGlbTexture = !1;
3154
3172
  }
3155
3173
  } else
3156
- c.glbModelEnabled = !1;
3157
- } catch (l) {
3158
- console.warn(`Failed to load GLB for ${c.name}:`, l), c.glbModelEnabled = !1;
3174
+ l.glbModelEnabled = !1;
3175
+ } catch (c) {
3176
+ console.warn(`Failed to load GLB for ${l.name}:`, c), l.glbModelEnabled = !1;
3159
3177
  }
3160
- for (const { system: o, config: c } of this.particleSystems)
3161
- if (c.textureEnabled && !c.glbModelEnabled && c.textureImageData && !o._textureRestored)
3178
+ for (const { system: o, config: l } of this.particleSystems)
3179
+ if (l.textureEnabled && !l.glbModelEnabled && l.textureImageData && !o._textureRestored)
3162
3180
  try {
3163
- const l = new Image();
3181
+ const c = new Image();
3164
3182
  await new Promise((S, b) => {
3165
- l.onload = S, l.onerror = b, l.src = c.textureImageData;
3183
+ c.onload = S, c.onerror = b, c.src = l.textureImageData;
3166
3184
  });
3167
- const d = await createImageBitmap(l);
3185
+ const d = await createImageBitmap(c);
3168
3186
  await o.setTexture(d), o._textureRestored = !0;
3169
- } catch (l) {
3170
- console.warn(`Failed to restore texture for ${c.name}:`, l), c.textureEnabled = !1;
3187
+ } catch (c) {
3188
+ console.warn(`Failed to restore texture for ${l.name}:`, c), l.textureEnabled = !1;
3171
3189
  }
3172
3190
  return i;
3173
3191
  } catch (n) {
@@ -3179,27 +3197,27 @@ class wr {
3179
3197
  _applyKeyframesToSystem(t, e, i) {
3180
3198
  const r = e.keyframes;
3181
3199
  if (!r || e.keyframesEnabled === !1) return;
3182
- let n = !1, a = !1, o = !1, c = !1, l = !1;
3183
- for (const d of _r) {
3200
+ let n = !1, a = !1, o = !1, l = !1, c = !1;
3201
+ for (const d of wr) {
3184
3202
  const S = r[d];
3185
3203
  if (!S || !S.length) continue;
3186
- const b = vr(S, i);
3204
+ const b = _r(S, i);
3187
3205
  if (b !== void 0) {
3188
3206
  if (d === "damping") {
3189
- e.dampingStrength = b, c = !0;
3207
+ e.dampingStrength = b, l = !0;
3190
3208
  continue;
3191
3209
  }
3192
- e[d] = b, (d === "particleSize" || d === "opacity") && (n = !0), d === "bloomIntensity" && (a = !0), d === "gravityStrength" && (o = !0), d === "dampingStrength" && (c = !0), (d === "attractorStrength" || d === "attractorReverse") && (l = !0);
3210
+ e[d] = b, (d === "particleSize" || d === "opacity") && (n = !0), d === "bloomIntensity" && (a = !0), d === "gravityStrength" && (o = !0), d === "dampingStrength" && (l = !0), (d === "attractorStrength" || d === "attractorReverse") && (c = !0);
3193
3211
  }
3194
3212
  }
3195
3213
  if (r.particleColor && r.particleColor.length) {
3196
- const d = e.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0, b = Pr(r.particleColor, i, S);
3214
+ const d = e.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0, b = Mr(r.particleColor, i, S);
3197
3215
  b && (e.particleColor = b, n = !0);
3198
3216
  }
3199
- n && t.updateAppearanceUniform(), a && t.updateBloomIntensity(), o && e.gravityEnabled && t.setGravity(e.gravityStrength), c && e.dampingEnabled && t.physics.setDamping(e.dampingStrength), l && e.attractorEnabled && e.attractorPosition && t.setAttractor(e.attractorStrength, e.attractorPosition, e.attractorReverse);
3217
+ n && t.updateAppearanceUniform(), a && t.updateBloomIntensity(), o && e.gravityEnabled && t.setGravity(e.gravityStrength), l && e.dampingEnabled && t.physics.setDamping(e.dampingStrength), c && e.attractorEnabled && e.attractorPosition && t.setAttractor(e.attractorStrength, e.attractorPosition, e.attractorReverse);
3200
3218
  }
3201
3219
  }
3202
- async function Br(s) {
3220
+ async function Tr(s) {
3203
3221
  if (!s)
3204
3222
  throw new Error("canvas is required for initWebGPU()");
3205
3223
  if (!navigator.gpu)
@@ -3211,30 +3229,33 @@ async function Br(s) {
3211
3229
  alphaMode: "premultiplied"
3212
3230
  }), { device: i, context: t, format: r, canvas: s };
3213
3231
  }
3214
- const ke = "rgba16float";
3215
- function Xi(s, t, e, i) {
3232
+ const Xe = "rgba16float", Xi = 0.5, Ji = (s, t) => [
3233
+ Math.max(1, Math.round(s * Xi)),
3234
+ Math.max(1, Math.round(t * Xi))
3235
+ ];
3236
+ function Ni(s, t, e, i) {
3216
3237
  const r = s.createTexture({
3217
3238
  size: [e, i],
3218
- format: ke,
3239
+ format: Xe,
3219
3240
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
3220
3241
  mipLevelCount: 1,
3221
3242
  sampleCount: 1
3222
- }), n = s.createTexture({
3223
- size: [e, i],
3224
- format: ke,
3243
+ }), [n, a] = Ji(e, i), o = s.createTexture({
3244
+ size: [n, a],
3245
+ format: Xe,
3225
3246
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
3226
3247
  mipLevelCount: 1,
3227
3248
  sampleCount: 1
3228
- }), a = s.createTexture({
3229
- size: [e, i],
3230
- format: ke,
3249
+ }), l = s.createTexture({
3250
+ size: [n, a],
3251
+ format: Xe,
3231
3252
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
3232
3253
  mipLevelCount: 1,
3233
3254
  sampleCount: 1
3234
3255
  });
3235
- return { sceneTexture: r, bloomTexA: n, bloomTexB: a };
3256
+ return { sceneTexture: r, bloomTexA: o, bloomTexB: l };
3236
3257
  }
3237
- function Ni(s, t, e) {
3258
+ function Yi(s, t, e) {
3238
3259
  return s.createTexture({
3239
3260
  size: [t, e],
3240
3261
  format: "depth24plus",
@@ -3249,7 +3270,7 @@ function St(s, t, e) {
3249
3270
  });
3250
3271
  return new t.constructor(i.getMappedRange()).set(t), i.unmap(), i;
3251
3272
  }
3252
- const Rr = `
3273
+ const Er = `
3253
3274
  struct Uniforms {
3254
3275
  transform: mat4x4<f32>,
3255
3276
  cameraPosition: vec3<f32>,
@@ -3311,7 +3332,7 @@ const Rr = `
3311
3332
 
3312
3333
  return finalColor;
3313
3334
  }
3314
- `, Tr = `
3335
+ `, Ar = `
3315
3336
  struct Uniforms {
3316
3337
  transform: mat4x4<f32>,
3317
3338
  cameraPosition: vec3<f32>,
@@ -3548,7 +3569,7 @@ const Rr = `
3548
3569
  return finalColor;
3549
3570
  }
3550
3571
  `;
3551
- function Ar(s) {
3572
+ function Cr(s) {
3552
3573
  const t = s.createBindGroupLayout({
3553
3574
  entries: [
3554
3575
  {
@@ -3634,34 +3655,34 @@ function Ar(s) {
3634
3655
  object3dBindGroupLayout: r
3635
3656
  };
3636
3657
  }
3637
- function Er(s, t, e, i = {}) {
3658
+ function Ur(s, t, e, i = {}) {
3638
3659
  const { depthCompare: r } = i, n = r || "less", {
3639
3660
  particleBindGroupLayout: a,
3640
3661
  bloomBindGroupLayout: o,
3641
- compositeBindGroupLayout: c,
3642
- object3dBindGroupLayout: l
3662
+ compositeBindGroupLayout: l,
3663
+ object3dBindGroupLayout: c
3643
3664
  } = e, d = s.createPipelineLayout({
3644
3665
  bindGroupLayouts: [a]
3645
3666
  }), S = s.createPipelineLayout({
3646
3667
  bindGroupLayouts: [o]
3647
3668
  }), b = s.createPipelineLayout({
3648
- bindGroupLayouts: [c]
3649
- }), p = s.createShaderModule({
3650
- code: js
3669
+ bindGroupLayouts: [l]
3670
+ }), h = s.createShaderModule({
3671
+ code: Hs
3651
3672
  }), v = s.createShaderModule({
3652
- code: qs
3653
- }), E = s.createShaderModule({
3654
3673
  code: Zs
3655
- }), I = s.createShaderModule({
3656
- code: Hs
3674
+ }), C = s.createShaderModule({
3675
+ code: Ws
3657
3676
  }), z = s.createShaderModule({
3658
- code: Rr
3677
+ code: $s
3678
+ }), D = s.createShaderModule({
3679
+ code: Er
3659
3680
  }), _ = s.createShaderModule({
3660
- code: Tr
3661
- }), W = (kt) => s.createRenderPipeline({
3681
+ code: Ar
3682
+ }), Z = (kt) => s.createRenderPipeline({
3662
3683
  layout: d,
3663
3684
  vertex: {
3664
- module: p,
3685
+ module: h,
3665
3686
  entryPoint: "vs_main",
3666
3687
  buffers: [
3667
3688
  {
@@ -3722,10 +3743,10 @@ function Er(s, t, e, i = {}) {
3722
3743
  ]
3723
3744
  },
3724
3745
  fragment: {
3725
- module: p,
3746
+ module: h,
3726
3747
  entryPoint: "fs_main",
3727
3748
  targets: [{
3728
- format: ke,
3749
+ format: Xe,
3729
3750
  blend: kt
3730
3751
  }]
3731
3752
  },
@@ -3738,7 +3759,7 @@ function Er(s, t, e, i = {}) {
3738
3759
  depthCompare: n,
3739
3760
  format: "depth24plus"
3740
3761
  }
3741
- }), T = W({
3762
+ }), T = Z({
3742
3763
  color: {
3743
3764
  srcFactor: "src-alpha",
3744
3765
  dstFactor: "one-minus-src-alpha",
@@ -3749,7 +3770,7 @@ function Er(s, t, e, i = {}) {
3749
3770
  dstFactor: "one-minus-src-alpha",
3750
3771
  operation: "add"
3751
3772
  }
3752
- }), F = W({
3773
+ }), F = Z({
3753
3774
  color: {
3754
3775
  srcFactor: "src-alpha",
3755
3776
  dstFactor: "one",
@@ -3763,7 +3784,7 @@ function Er(s, t, e, i = {}) {
3763
3784
  }), G = s.createRenderPipeline({
3764
3785
  layout: d,
3765
3786
  vertex: {
3766
- module: p,
3787
+ module: h,
3767
3788
  entryPoint: "vs_main",
3768
3789
  buffers: [
3769
3790
  {
@@ -3824,10 +3845,10 @@ function Er(s, t, e, i = {}) {
3824
3845
  ]
3825
3846
  },
3826
3847
  fragment: {
3827
- module: p,
3848
+ module: h,
3828
3849
  entryPoint: "fs_main",
3829
3850
  targets: [{
3830
- format: ke,
3851
+ format: Xe,
3831
3852
  writeMask: 0
3832
3853
  // No color write — depth only
3833
3854
  }]
@@ -3852,23 +3873,23 @@ function Er(s, t, e, i = {}) {
3852
3873
  module: v,
3853
3874
  entryPoint: "fs_main",
3854
3875
  targets: [{
3855
- format: ke
3876
+ format: Xe
3856
3877
  }]
3857
3878
  },
3858
3879
  primitive: {
3859
3880
  topology: "triangle-list"
3860
3881
  }
3861
- }), re = s.createRenderPipeline({
3882
+ }), se = s.createRenderPipeline({
3862
3883
  layout: b,
3863
3884
  vertex: {
3864
- module: E,
3885
+ module: C,
3865
3886
  entryPoint: "vs_main"
3866
3887
  },
3867
3888
  fragment: {
3868
- module: E,
3889
+ module: C,
3869
3890
  entryPoint: "fs_main",
3870
3891
  targets: [{
3871
- format: ke,
3892
+ format: Xe,
3872
3893
  blend: {
3873
3894
  color: {
3874
3895
  srcFactor: "one",
@@ -3886,17 +3907,17 @@ function Er(s, t, e, i = {}) {
3886
3907
  primitive: {
3887
3908
  topology: "triangle-list"
3888
3909
  }
3889
- }), ae = s.createRenderPipeline({
3910
+ }), ne = s.createRenderPipeline({
3890
3911
  layout: b,
3891
3912
  vertex: {
3892
- module: I,
3913
+ module: z,
3893
3914
  entryPoint: "vs_main"
3894
3915
  },
3895
3916
  fragment: {
3896
- module: I,
3917
+ module: z,
3897
3918
  entryPoint: "fs_main",
3898
3919
  targets: [{
3899
- format: ke,
3920
+ format: Xe,
3900
3921
  blend: {
3901
3922
  color: {
3902
3923
  srcFactor: "one",
@@ -3914,11 +3935,11 @@ function Er(s, t, e, i = {}) {
3914
3935
  primitive: {
3915
3936
  topology: "triangle-list"
3916
3937
  }
3917
- }), ne = s.createShaderModule({ code: Ws }), q = s.createRenderPipeline({
3938
+ }), re = s.createShaderModule({ code: Js }), j = s.createRenderPipeline({
3918
3939
  layout: b,
3919
- vertex: { module: ne, entryPoint: "vs_main" },
3940
+ vertex: { module: re, entryPoint: "vs_main" },
3920
3941
  fragment: {
3921
- module: ne,
3942
+ module: re,
3922
3943
  entryPoint: "fs_main",
3923
3944
  targets: [{
3924
3945
  format: t,
@@ -3930,11 +3951,11 @@ function Er(s, t, e, i = {}) {
3930
3951
  },
3931
3952
  primitive: { topology: "triangle-list" }
3932
3953
  }), tt = s.createPipelineLayout({
3933
- bindGroupLayouts: [l]
3954
+ bindGroupLayouts: [c]
3934
3955
  }), xt = s.createRenderPipeline({
3935
3956
  layout: tt,
3936
3957
  vertex: {
3937
- module: z,
3958
+ module: D,
3938
3959
  entryPoint: "vs_main",
3939
3960
  buffers: [
3940
3961
  {
@@ -3959,10 +3980,10 @@ function Er(s, t, e, i = {}) {
3959
3980
  ]
3960
3981
  },
3961
3982
  fragment: {
3962
- module: z,
3983
+ module: D,
3963
3984
  entryPoint: "fs_main",
3964
3985
  targets: [{
3965
- format: ke,
3986
+ format: Xe,
3966
3987
  blend: {
3967
3988
  color: {
3968
3989
  srcFactor: "src-alpha",
@@ -3986,7 +4007,7 @@ function Er(s, t, e, i = {}) {
3986
4007
  depthCompare: n,
3987
4008
  format: "depth24plus"
3988
4009
  }
3989
- }), Xe = s.createRenderPipeline({
4010
+ }), at = s.createRenderPipeline({
3990
4011
  layout: d,
3991
4012
  vertex: {
3992
4013
  module: _,
@@ -4064,7 +4085,7 @@ function Er(s, t, e, i = {}) {
4064
4085
  module: _,
4065
4086
  entryPoint: "fs_main",
4066
4087
  targets: [{
4067
- format: ke,
4088
+ format: Xe,
4068
4089
  blend: {
4069
4090
  color: {
4070
4091
  srcFactor: "src-alpha",
@@ -4094,11 +4115,11 @@ function Er(s, t, e, i = {}) {
4094
4115
  particleAdditivePipeline: F,
4095
4116
  particleDepthWritePipeline: G,
4096
4117
  blurPipeline: H,
4097
- compositePipeline: re,
4098
- directRenderPipeline: ae,
4099
- finalCompositePipeline: q,
4118
+ compositePipeline: se,
4119
+ directRenderPipeline: ne,
4120
+ finalCompositePipeline: j,
4100
4121
  object3dPipeline: xt,
4101
- glbMeshPipeline: Xe
4122
+ glbMeshPipeline: at
4102
4123
  };
4103
4124
  }
4104
4125
  function si(s, t, e, i) {
@@ -4107,9 +4128,9 @@ function si(s, t, e, i) {
4107
4128
  appearanceUniformBuffer: n,
4108
4129
  horizontalBlurUniformBuffer: a,
4109
4130
  verticalBlurUniformBuffer: o,
4110
- bloomIntensityBuffer: c
4131
+ bloomIntensityBuffer: l
4111
4132
  } = e, {
4112
- sceneTexture: l,
4133
+ sceneTexture: c,
4113
4134
  bloomTexA: d,
4114
4135
  bloomTexB: S
4115
4136
  } = i, b = s.createBindGroup({
@@ -4137,7 +4158,7 @@ function si(s, t, e, i) {
4137
4158
  resource: { buffer: n }
4138
4159
  }
4139
4160
  ]
4140
- }), p = s.createBindGroup({
4161
+ }), h = s.createBindGroup({
4141
4162
  layout: s.createBindGroupLayout({
4142
4163
  entries: [
4143
4164
  {
@@ -4164,7 +4185,7 @@ function si(s, t, e, i) {
4164
4185
  },
4165
4186
  {
4166
4187
  binding: 1,
4167
- resource: l.createView()
4188
+ resource: c.createView()
4168
4189
  },
4169
4190
  {
4170
4191
  binding: 2,
@@ -4205,7 +4226,7 @@ function si(s, t, e, i) {
4205
4226
  resource: { buffer: o }
4206
4227
  }
4207
4228
  ]
4208
- }), E = s.createBindGroup({
4229
+ }), C = s.createBindGroup({
4209
4230
  layout: s.createBindGroupLayout({
4210
4231
  entries: [
4211
4232
  {
@@ -4237,7 +4258,7 @@ function si(s, t, e, i) {
4237
4258
  },
4238
4259
  {
4239
4260
  binding: 1,
4240
- resource: l.createView()
4261
+ resource: c.createView()
4241
4262
  },
4242
4263
  {
4243
4264
  binding: 2,
@@ -4245,10 +4266,10 @@ function si(s, t, e, i) {
4245
4266
  },
4246
4267
  {
4247
4268
  binding: 3,
4248
- resource: { buffer: c }
4269
+ resource: { buffer: l }
4249
4270
  }
4250
4271
  ]
4251
- }), I = s.createBindGroup({
4272
+ }), z = s.createBindGroup({
4252
4273
  layout: s.createBindGroupLayout({
4253
4274
  entries: [
4254
4275
  {
@@ -4280,7 +4301,7 @@ function si(s, t, e, i) {
4280
4301
  },
4281
4302
  {
4282
4303
  binding: 1,
4283
- resource: l.createView()
4304
+ resource: c.createView()
4284
4305
  },
4285
4306
  {
4286
4307
  binding: 2,
@@ -4288,19 +4309,19 @@ function si(s, t, e, i) {
4288
4309
  },
4289
4310
  {
4290
4311
  binding: 3,
4291
- resource: { buffer: c }
4312
+ resource: { buffer: l }
4292
4313
  }
4293
4314
  ]
4294
4315
  });
4295
4316
  return {
4296
4317
  particleBindGroup: b,
4297
- horizontalBlurBindGroup: p,
4318
+ horizontalBlurBindGroup: h,
4298
4319
  verticalBlurBindGroup: v,
4299
- compositeBindGroup: E,
4300
- directRenderBindGroup: I
4320
+ compositeBindGroup: C,
4321
+ directRenderBindGroup: z
4301
4322
  };
4302
4323
  }
4303
- function Cr(s) {
4324
+ function Ir(s) {
4304
4325
  return s.createSampler({
4305
4326
  magFilter: "linear",
4306
4327
  minFilter: "linear",
@@ -4310,7 +4331,7 @@ function Cr(s) {
4310
4331
  maxAnisotropy: 16
4311
4332
  });
4312
4333
  }
4313
- function Ur() {
4334
+ function zr() {
4314
4335
  const s = new Float32Array([
4315
4336
  // Front face (z = 0.5)
4316
4337
  -0.5,
@@ -4508,13 +4529,13 @@ function Ur() {
4508
4529
  ]);
4509
4530
  return { vertices: s, indices: t };
4510
4531
  }
4511
- function Ir(s = 16, t = 16) {
4532
+ function Dr(s = 16, t = 16) {
4512
4533
  const e = [], i = [];
4513
4534
  for (let r = 0; r <= s; r++) {
4514
4535
  const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
4515
- for (let c = 0; c <= t; c++) {
4516
- const l = c * 2 * Math.PI / t, d = Math.sin(l), b = Math.cos(l) * a, p = o, v = d * a;
4517
- e.push(b * 0.5, p * 0.5, v * 0.5), e.push(b, p, v);
4536
+ for (let l = 0; l <= t; l++) {
4537
+ const c = l * 2 * Math.PI / t, d = Math.sin(c), b = Math.cos(c) * a, h = o, v = d * a;
4538
+ e.push(b * 0.5, h * 0.5, v * 0.5), e.push(b, h, v);
4518
4539
  }
4519
4540
  }
4520
4541
  for (let r = 0; r < s; r++)
@@ -4527,7 +4548,7 @@ function Ir(s = 16, t = 16) {
4527
4548
  indices: new Uint16Array(i)
4528
4549
  };
4529
4550
  }
4530
- class zr {
4551
+ class Fr {
4531
4552
  constructor(t, e, i, r, n) {
4532
4553
  this.id = t, this.type = e, this.position = i, this.scale = r, this.color = n, this.rotation = [0, 0, 0];
4533
4554
  }
@@ -4535,9 +4556,9 @@ class zr {
4535
4556
  * Get the model matrix for this object
4536
4557
  */
4537
4558
  getModelMatrix() {
4538
- const { position: t, scale: e, rotation: i } = this, r = this.createTranslationMatrix(t), n = this.createRotationMatrixX(i[0]), a = this.createRotationMatrixY(i[1]), o = this.createRotationMatrixZ(i[2]), c = this.createScaleMatrix(e);
4539
- let l = r;
4540
- return l = this.multiplyMatrices(l, o), l = this.multiplyMatrices(l, a), l = this.multiplyMatrices(l, n), l = this.multiplyMatrices(l, c), l;
4559
+ const { position: t, scale: e, rotation: i } = this, r = this.createTranslationMatrix(t), n = this.createRotationMatrixX(i[0]), a = this.createRotationMatrixY(i[1]), o = this.createRotationMatrixZ(i[2]), l = this.createScaleMatrix(e);
4560
+ let c = r;
4561
+ return c = this.multiplyMatrices(c, o), c = this.multiplyMatrices(c, a), c = this.multiplyMatrices(c, n), c = this.multiplyMatrices(c, l), c;
4541
4562
  }
4542
4563
  /**
4543
4564
  * Get the normal matrix (inverse transpose of model matrix)
@@ -4661,7 +4682,7 @@ class zr {
4661
4682
  return i;
4662
4683
  }
4663
4684
  }
4664
- class kr {
4685
+ class Nr {
4665
4686
  constructor(t) {
4666
4687
  this.device = t, this.objects = [], this.nextId = 0, this.initializeGeometry(), this.onObjectAdded = null, this.onObjectRemoved = null, this.onObjectUpdated = null;
4667
4688
  }
@@ -4669,7 +4690,7 @@ class kr {
4669
4690
  * Initialize geometry buffers for cube and sphere
4670
4691
  */
4671
4692
  initializeGeometry() {
4672
- const t = Ur(), e = Ir(16, 16);
4693
+ const t = zr(), e = Dr(16, 16);
4673
4694
  this.cubeVertexBuffer = St(
4674
4695
  this.device,
4675
4696
  t.vertices,
@@ -4697,7 +4718,7 @@ class kr {
4697
4718
  * @returns {Object3D} The created object
4698
4719
  */
4699
4720
  addObject(t, e = [0, 0, 0], i = [1, 1, 1], r = [1, 1, 1, 1]) {
4700
- const n = new zr(this.nextId++, t, e, i, r);
4721
+ const n = new Fr(this.nextId++, t, e, i, r);
4701
4722
  return n.uniformBuffer = this.device.createBuffer({
4702
4723
  size: 192,
4703
4724
  // modelMatrix (64) + normalMatrix (64) + color (16) + padding (48)
@@ -4775,32 +4796,32 @@ class kr {
4775
4796
  { binding: 1, resource: { buffer: n.uniformBuffer } }
4776
4797
  ]
4777
4798
  });
4778
- let o, c, l;
4799
+ let o, l, c;
4779
4800
  if (n.type === "cube")
4780
- o = this.cubeVertexBuffer, c = this.cubeIndexBuffer, l = this.cubeIndexCount;
4801
+ o = this.cubeVertexBuffer, l = this.cubeIndexBuffer, c = this.cubeIndexCount;
4781
4802
  else if (n.type === "sphere")
4782
- o = this.sphereVertexBuffer, c = this.sphereIndexBuffer, l = this.sphereIndexCount;
4803
+ o = this.sphereVertexBuffer, l = this.sphereIndexBuffer, c = this.sphereIndexCount;
4783
4804
  else
4784
4805
  continue;
4785
- t.setPipeline(e), t.setBindGroup(0, a), t.setVertexBuffer(0, o), t.setIndexBuffer(c, "uint16"), t.drawIndexed(l);
4806
+ t.setPipeline(e), t.setBindGroup(0, a), t.setVertexBuffer(0, o), t.setIndexBuffer(l, "uint16"), t.drawIndexed(c);
4786
4807
  }
4787
4808
  }
4788
4809
  }
4789
- function Xr(s) {
4810
+ function Yr(s) {
4790
4811
  const t = parseInt(s.slice(1, 3), 16) / 255, e = parseInt(s.slice(3, 5), 16) / 255, i = parseInt(s.slice(5, 7), 16) / 255;
4791
4812
  return [t, e, i];
4792
4813
  }
4793
- function Nr(s) {
4814
+ function jr(s) {
4794
4815
  if (!s) return "#ffffff";
4795
4816
  const t = Math.round(s[0] * 255).toString(16).padStart(2, "0"), e = Math.round(s[1] * 255).toString(16).padStart(2, "0"), i = Math.round(s[2] * 255).toString(16).padStart(2, "0");
4796
4817
  return `#${t}${e}${i}`;
4797
4818
  }
4798
- function Yr(s, t, e) {
4799
- const i = Yi([
4819
+ function qr(s, t, e) {
4820
+ const i = ji([
4800
4821
  s[0] - t[0],
4801
4822
  s[1] - t[1],
4802
4823
  s[2] - t[2]
4803
- ]), r = Yi(ji(e, i)), n = ji(i, r);
4824
+ ]), r = ji(qi(e, i)), n = qi(i, r);
4804
4825
  return new Float32Array([
4805
4826
  r[0],
4806
4827
  n[0],
@@ -4820,7 +4841,7 @@ function Yr(s, t, e) {
4820
4841
  1
4821
4842
  ]);
4822
4843
  }
4823
- function jr(s, t = Math.PI / 4) {
4844
+ function Hr(s, t = Math.PI / 4) {
4824
4845
  const r = 1 / Math.tan(t / 2);
4825
4846
  return new Float32Array([
4826
4847
  r * s,
@@ -4841,11 +4862,11 @@ function jr(s, t = Math.PI / 4) {
4841
4862
  0
4842
4863
  ]);
4843
4864
  }
4844
- function Yi(s) {
4865
+ function ji(s) {
4845
4866
  const t = Math.sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2]);
4846
4867
  return [s[0] / t, s[1] / t, s[2] / t];
4847
4868
  }
4848
- function ji(s, t) {
4869
+ function qi(s, t) {
4849
4870
  return [
4850
4871
  s[1] * t[2] - s[2] * t[1],
4851
4872
  s[2] * t[0] - s[0] * t[2],
@@ -4855,7 +4876,7 @@ function ji(s, t) {
4855
4876
  function ri(s, t) {
4856
4877
  return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
4857
4878
  }
4858
- function Fr(s, t) {
4879
+ function Gr(s, t) {
4859
4880
  const e = new Float32Array(16);
4860
4881
  for (let i = 0; i < 4; i++)
4861
4882
  for (let r = 0; r < 4; r++) {
@@ -4866,7 +4887,7 @@ function Fr(s, t) {
4866
4887
  }
4867
4888
  return e;
4868
4889
  }
4869
- const ai = 1481005640, $i = 1, Ji = 1313821514, Ki = 5130562, Et = "$hzfxAsset", Qi = (s) => typeof atob == "function" ? Uint8Array.from(atob(s), (t) => t.charCodeAt(0)) : new Uint8Array(Buffer.from(s, "base64")), qi = (s) => {
4890
+ const ai = 1481005640, Ki = 1, Qi = 1313821514, es = 5130562, At = "$hzfxAsset", ts = (s) => typeof atob == "function" ? Uint8Array.from(atob(s), (t) => t.charCodeAt(0)) : new Uint8Array(Buffer.from(s, "base64")), Hi = (s) => {
4870
4891
  if (typeof btoa == "function") {
4871
4892
  let t = "";
4872
4893
  for (let e = 0; e < s.length; e++) t += String.fromCharCode(s[e]);
@@ -4874,94 +4895,94 @@ const ai = 1481005640, $i = 1, Ji = 1313821514, Ki = 5130562, Et = "$hzfxAsset",
4874
4895
  }
4875
4896
  return Buffer.from(s).toString("base64");
4876
4897
  };
4877
- function Gr(s) {
4878
- const t = s.indexOf(","), e = s.slice(5, t), i = e.split(";")[0] || "application/octet-stream", r = s.slice(t + 1), a = /;base64/i.test(e) ? Qi(r) : new TextEncoder().encode(decodeURIComponent(r));
4898
+ function Vr(s) {
4899
+ const t = s.indexOf(","), e = s.slice(5, t), i = e.split(";")[0] || "application/octet-stream", r = s.slice(t + 1), a = /;base64/i.test(e) ? ts(r) : new TextEncoder().encode(decodeURIComponent(r));
4879
4900
  return { mime: i, bytes: a };
4880
4901
  }
4881
4902
  function Zi(s) {
4882
4903
  return (4 - s % 4) % 4;
4883
4904
  }
4884
- async function Dr(s, t = {}) {
4905
+ async function Or(s, t = {}) {
4885
4906
  const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
4886
4907
  let a = 0;
4887
4908
  const o = (F, G, H) => {
4888
- const re = a, ae = F.length;
4889
- r.push({ offset: re, length: ae, mime: G, kind: H }), n.push(F), a += ae;
4890
- const ne = Zi(ae);
4891
- return ne && (n.push(new Uint8Array(ne)), a += ne), r.length - 1;
4892
- }, c = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", l = [];
4909
+ const se = a, ne = F.length;
4910
+ r.push({ offset: se, length: ne, mime: G, kind: H }), n.push(F), a += ne;
4911
+ const re = Zi(ne);
4912
+ return re && (n.push(new Uint8Array(re)), a += re), r.length - 1;
4913
+ }, l = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", c = [];
4893
4914
  for (const F of s.systems || []) {
4894
4915
  const G = { ...F };
4895
4916
  if (typeof G.textureImageData == "string" && G.textureImageData.startsWith("data:")) {
4896
- let { mime: H, bytes: re } = Gr(G.textureImageData);
4897
- if (c && H !== "image/webp")
4917
+ let { mime: H, bytes: se } = Vr(G.textureImageData);
4918
+ if (l && H !== "image/webp")
4898
4919
  try {
4899
- const ae = await createImageBitmap(new Blob([re], { type: H })), ne = new OffscreenCanvas(ae.width, ae.height);
4900
- ne.getContext("2d").drawImage(ae, 0, 0);
4901
- const q = await ne.convertToBlob({ type: "image/webp", quality: i }), tt = new Uint8Array(await q.arrayBuffer());
4902
- tt.length < re.length && (re = tt, H = "image/webp");
4920
+ const ne = await createImageBitmap(new Blob([se], { type: H })), re = new OffscreenCanvas(ne.width, ne.height);
4921
+ re.getContext("2d").drawImage(ne, 0, 0);
4922
+ const j = await re.convertToBlob({ type: "image/webp", quality: i }), tt = new Uint8Array(await j.arrayBuffer());
4923
+ tt.length < se.length && (se = tt, H = "image/webp");
4903
4924
  } catch {
4904
4925
  }
4905
- G.textureImageData = { [Et]: o(re, H, "texture") };
4926
+ G.textureImageData = { [At]: o(se, H, "texture") };
4906
4927
  }
4907
4928
  if (typeof G.glbModelData == "string" && G.glbModelData.length > 0) {
4908
- const H = Qi(G.glbModelData);
4909
- G.glbModelData = { [Et]: o(H, "model/gltf-binary", "glb") };
4929
+ const H = ts(G.glbModelData);
4930
+ G.glbModelData = { [At]: o(H, "model/gltf-binary", "glb") };
4910
4931
  }
4911
- l.push(G);
4932
+ c.push(G);
4912
4933
  }
4913
- const d = { ...s, systems: l, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), b = Zi(S.length), p = new Uint8Array(a);
4934
+ const d = { ...s, systems: c, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), b = Zi(S.length), h = new Uint8Array(a);
4914
4935
  let v = 0;
4915
4936
  for (const F of n)
4916
- p.set(F, v), v += F.length;
4917
- const E = S.length + b, I = 20 + E + 8 + a, z = new ArrayBuffer(I), _ = new DataView(z), W = new Uint8Array(z);
4937
+ h.set(F, v), v += F.length;
4938
+ const C = S.length + b, z = 20 + C + 8 + a, D = new ArrayBuffer(z), _ = new DataView(D), Z = new Uint8Array(D);
4918
4939
  let T = 0;
4919
- _.setUint32(T, ai, !0), T += 4, _.setUint32(T, $i, !0), T += 4, _.setUint32(T, I, !0), T += 4, _.setUint32(T, E, !0), T += 4, _.setUint32(T, Ji, !0), T += 4, W.set(S, T), T += S.length;
4920
- for (let F = 0; F < b; F++) W[T++] = 32;
4921
- return _.setUint32(T, a, !0), T += 4, _.setUint32(T, Ki, !0), T += 4, W.set(p, T), T += a, z;
4940
+ _.setUint32(T, ai, !0), T += 4, _.setUint32(T, Ki, !0), T += 4, _.setUint32(T, z, !0), T += 4, _.setUint32(T, C, !0), T += 4, _.setUint32(T, Qi, !0), T += 4, Z.set(S, T), T += S.length;
4941
+ for (let F = 0; F < b; F++) Z[T++] = 32;
4942
+ return _.setUint32(T, a, !0), T += 4, _.setUint32(T, es, !0), T += 4, Z.set(h, T), T += a, D;
4922
4943
  }
4923
- function es(s) {
4944
+ function is(s) {
4924
4945
  return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === ai;
4925
4946
  }
4926
- function ts(s) {
4947
+ function ss(s) {
4927
4948
  const t = new DataView(s);
4928
4949
  if (t.getUint32(0, !0) !== ai) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
4929
4950
  const e = t.getUint32(4, !0);
4930
- if (e !== $i) throw new Error(`[unpackHZFX] unsupported version ${e}`);
4951
+ if (e !== Ki) throw new Error(`[unpackHZFX] unsupported version ${e}`);
4931
4952
  let i = 12, r = null, n = -1;
4932
4953
  const a = new Uint8Array(s);
4933
4954
  for (; i + 8 <= s.byteLength; ) {
4934
4955
  const b = t.getUint32(i, !0);
4935
4956
  i += 4;
4936
- const p = t.getUint32(i, !0);
4937
- i += 4, p === Ji ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + b))) : p === Ki && (n = i), i += b;
4957
+ const h = t.getUint32(i, !0);
4958
+ i += 4, h === Qi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + b))) : h === es && (n = i), i += b;
4938
4959
  }
4939
4960
  if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
4940
- const o = r.assets || [], c = (b) => {
4941
- const p = o[b];
4942
- return !p || n < 0 ? null : { ...p, bytes: a.subarray(n + p.offset, n + p.offset + p.length) };
4943
- }, l = (b) => b && typeof b == "object" && typeof b[Et] == "number", d = (r.systems || []).map((b) => {
4944
- const p = { ...b };
4945
- if (l(p.textureImageData)) {
4946
- const v = c(p.textureImageData[Et]);
4947
- p.textureImageData = v ? `data:${v.mime};base64,${qi(v.bytes)}` : void 0;
4961
+ const o = r.assets || [], l = (b) => {
4962
+ const h = o[b];
4963
+ return !h || n < 0 ? null : { ...h, bytes: a.subarray(n + h.offset, n + h.offset + h.length) };
4964
+ }, c = (b) => b && typeof b == "object" && typeof b[At] == "number", d = (r.systems || []).map((b) => {
4965
+ const h = { ...b };
4966
+ if (c(h.textureImageData)) {
4967
+ const v = l(h.textureImageData[At]);
4968
+ h.textureImageData = v ? `data:${v.mime};base64,${Hi(v.bytes)}` : void 0;
4948
4969
  }
4949
- if (l(p.glbModelData)) {
4950
- const v = c(p.glbModelData[Et]);
4951
- p.glbModelData = v ? qi(v.bytes) : void 0;
4970
+ if (c(h.glbModelData)) {
4971
+ const v = l(h.glbModelData[At]);
4972
+ h.glbModelData = v ? Hi(v.bytes) : void 0;
4952
4973
  }
4953
- return p;
4974
+ return h;
4954
4975
  }), S = { ...r, systems: d };
4955
4976
  return delete S.assets, S;
4956
4977
  }
4957
- function Vr(s) {
4978
+ function Lr(s) {
4958
4979
  const t = new Uint8Array(s);
4959
4980
  let e = "";
4960
4981
  for (let i = 0; i < t.byteLength; i++)
4961
4982
  e += String.fromCharCode(t[i]);
4962
4983
  return btoa(e);
4963
4984
  }
4964
- function Or(s) {
4985
+ function kr(s) {
4965
4986
  return {
4966
4987
  name: s.name,
4967
4988
  id: s.id,
@@ -5147,7 +5168,7 @@ function Or(s) {
5147
5168
  displayUnit: s.displayUnit || "m"
5148
5169
  };
5149
5170
  }
5150
- async function qr(s, t, e = "hzfx") {
5171
+ async function Zr(s, t, e = "hzfx") {
5151
5172
  if (!s || !s.particleSystems || s.particleSystems.length === 0) {
5152
5173
  alert("No particle systems to save.");
5153
5174
  return;
@@ -5157,11 +5178,11 @@ async function qr(s, t, e = "hzfx") {
5157
5178
  version: "1.0",
5158
5179
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
5159
5180
  systems: s.particleSystems.map(({ config: d, system: S }) => ({
5160
- ...Or(d),
5181
+ ...kr(d),
5161
5182
  // single source of truth for config fields
5162
5183
  // Binary assets embedded so replaceSystems() can restore them
5163
5184
  textureImageData: d.textureEnabled && !d.glbModelEnabled && d.textureImageData ? d.textureImageData : void 0,
5164
- glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ? Vr(S.glbRawArrayBuffer) : void 0
5185
+ glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ? Lr(S.glbRawArrayBuffer) : void 0
5165
5186
  })),
5166
5187
  activeSystemIndex: s.activeSystemIndex,
5167
5188
  loop: s.loop || !1
@@ -5169,7 +5190,7 @@ async function qr(s, t, e = "hzfx") {
5169
5190
  }, r = e === "json" ? "json" : "hzfx";
5170
5191
  let n;
5171
5192
  if (r === "hzfx") {
5172
- const d = await Dr(i, { textureFormat: "webp" });
5193
+ const d = await Or(i, { textureFormat: "webp" });
5173
5194
  n = new Blob([d], { type: "application/octet-stream" });
5174
5195
  } else
5175
5196
  n = new Blob([JSON.stringify(i, null, 2)], { type: "application/json" });
@@ -5180,13 +5201,13 @@ async function qr(s, t, e = "hzfx") {
5180
5201
  const d = /* @__PURE__ */ new Date();
5181
5202
  a = `particle-scene_${`${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d.getDate().toString().padStart(2, "0")}_${d.getHours().toString().padStart(2, "0")}${d.getMinutes().toString().padStart(2, "0")}`}`;
5182
5203
  }
5183
- const o = `${a}.${r}`, c = URL.createObjectURL(n), l = document.createElement("a");
5184
- l.href = c, l.download = o, document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(c);
5204
+ const o = `${a}.${r}`, l = URL.createObjectURL(n), c = document.createElement("a");
5205
+ c.href = l, c.download = o, document.body.appendChild(c), c.click(), document.body.removeChild(c), URL.revokeObjectURL(l);
5185
5206
  } catch (i) {
5186
5207
  console.error("Error saving scene:", i), alert("Error saving scene. See console for details.");
5187
5208
  }
5188
5209
  }
5189
- function Zr(s) {
5210
+ function Wr(s) {
5190
5211
  return new Promise((t, e) => {
5191
5212
  try {
5192
5213
  const i = s.target.files[0];
@@ -5199,7 +5220,7 @@ function Zr(s) {
5199
5220
  try {
5200
5221
  const a = n.target.result;
5201
5222
  let o;
5202
- if (es(a) ? o = ts(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
5223
+ if (is(a) ? o = ss(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
5203
5224
  throw new Error("No valid particle systems found in the file");
5204
5225
  t({
5205
5226
  systems: o.systems.slice(),
@@ -5217,7 +5238,7 @@ function Zr(s) {
5217
5238
  }
5218
5239
  });
5219
5240
  }
5220
- async function Hr(s) {
5241
+ async function $r(s) {
5221
5242
  if (!s || typeof s != "string")
5222
5243
  throw new Error("[fetchPreset] url must be a non-empty string");
5223
5244
  const t = await fetch(s);
@@ -5225,7 +5246,7 @@ async function Hr(s) {
5225
5246
  throw new Error(`[fetchPreset] HTTP ${t.status}: ${t.statusText}`);
5226
5247
  const e = await t.arrayBuffer();
5227
5248
  let i;
5228
- if (es(e) ? i = ts(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
5249
+ if (is(e) ? i = ss(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
5229
5250
  throw new Error('[fetchPreset] Invalid preset: "systems" must be a non-empty array');
5230
5251
  return {
5231
5252
  version: i.version,
@@ -5233,7 +5254,7 @@ async function Hr(s) {
5233
5254
  activeSystemIndex: i.activeSystemIndex ?? 0
5234
5255
  };
5235
5256
  }
5236
- const Lr = (s) => `
5257
+ const Xr = (s) => `
5237
5258
  @vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
5238
5259
  var p = array<vec2f, 3>(vec2f(-1.0, -3.0), vec2f(-1.0, 1.0), vec2f(3.0, 1.0));
5239
5260
  return vec4f(p[i], 0.0, 1.0);
@@ -5243,22 +5264,22 @@ const Lr = (s) => `
5243
5264
  return textureLoad(src, vec2i(pos.xy), 0);
5244
5265
  }
5245
5266
  `;
5246
- async function Wr(s, t = {}) {
5267
+ async function Jr(s, t = {}) {
5247
5268
  const { getSceneDepth: e = null, autoRespawn: i = !0 } = t;
5248
5269
  let r, n, a;
5249
5270
  const o = !!(s && s.device && s.context);
5250
- o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await Br(a));
5251
- const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new wr(r), d = { layouts: {}, pipelines: {} };
5271
+ o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await Tr(a));
5272
+ const l = navigator.gpu.getPreferredCanvasFormat(), c = t.manager || new Br(r), d = { layouts: {}, pipelines: {} };
5252
5273
  function S(u) {
5253
5274
  const f = u ? "ms" : "ss";
5254
5275
  if (!d.pipelines[f]) {
5255
- const m = r.createShaderModule({ code: Lr(u) }), g = r.createBindGroupLayout({
5276
+ const y = r.createShaderModule({ code: Xr(u) }), p = r.createBindGroupLayout({
5256
5277
  entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: u } }]
5257
5278
  });
5258
- d.layouts[f] = g, d.pipelines[f] = r.createRenderPipeline({
5259
- layout: r.createPipelineLayout({ bindGroupLayouts: [g] }),
5260
- vertex: { module: m, entryPoint: "vs" },
5261
- fragment: { module: m, entryPoint: "fs", targets: [] },
5279
+ d.layouts[f] = p, d.pipelines[f] = r.createRenderPipeline({
5280
+ layout: r.createPipelineLayout({ bindGroupLayouts: [p] }),
5281
+ vertex: { module: y, entryPoint: "vs" },
5282
+ fragment: { module: y, entryPoint: "fs", targets: [] },
5262
5283
  primitive: { topology: "triangle-list" },
5263
5284
  depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
5264
5285
  });
@@ -5269,21 +5290,23 @@ async function Wr(s, t = {}) {
5269
5290
  bloomSourceTextures: {},
5270
5291
  bloomCompositeTextures: {},
5271
5292
  combinedTexture: null,
5272
- getBloomSourceTexture(u, f, m) {
5273
- return this.bloomSourceTextures[u] || (this.bloomSourceTextures[u] = r.createTexture({
5274
- size: [f, m],
5293
+ getBloomSourceTexture(u, f, y) {
5294
+ const p = u;
5295
+ return this.bloomSourceTextures[p] || (this.bloomSourceTextures[p] = r.createTexture({
5296
+ size: [f, y],
5275
5297
  format: "rgba16float",
5276
5298
  // HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
5277
5299
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
5278
- })), this.bloomSourceTextures[u];
5300
+ })), this.bloomSourceTextures[p];
5279
5301
  },
5280
- getBloomCompositeTexture(u, f, m) {
5281
- return this.bloomCompositeTextures[u] || (this.bloomCompositeTextures[u] = r.createTexture({
5282
- size: [f, m],
5302
+ getBloomCompositeTexture(u, f, y) {
5303
+ const p = u;
5304
+ return this.bloomCompositeTextures[p] || (this.bloomCompositeTextures[p] = r.createTexture({
5305
+ size: [f, y],
5283
5306
  format: "rgba16float",
5284
5307
  // HDR chain
5285
5308
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
5286
- })), this.bloomCompositeTextures[u];
5309
+ })), this.bloomCompositeTextures[p];
5287
5310
  },
5288
5311
  getCombinedTexture(u, f) {
5289
5312
  return this.combinedTexture || (this.combinedTexture = r.createTexture({
@@ -5296,7 +5319,7 @@ async function Wr(s, t = {}) {
5296
5319
  resizeTextures() {
5297
5320
  Object.values(this.bloomSourceTextures).forEach((u) => u == null ? void 0 : u.destroy()), Object.values(this.bloomCompositeTextures).forEach((u) => u == null ? void 0 : u.destroy()), this.combinedTexture && this.combinedTexture.destroy(), this.bloomSourceTextures = {}, this.bloomCompositeTextures = {}, this.combinedTexture = null;
5298
5321
  }
5299
- }, p = {
5322
+ }, h = {
5300
5323
  systemBindGroups: {},
5301
5324
  systemBloomHorizontalBindGroups: {},
5302
5325
  secondHorizontalBindGroups: {},
@@ -5312,320 +5335,321 @@ async function Wr(s, t = {}) {
5312
5335
  clear() {
5313
5336
  this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
5314
5337
  }
5315
- }, v = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), E = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), I = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), z = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), _ = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), W = St(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), T = {}, F = () => St(r, new Float32Array([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0]), GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST);
5316
- l.onSystemCreated = (u) => {
5338
+ }, v = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), C = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), z = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), D = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), _ = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), Z = St(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), T = {}, F = () => St(r, new Float32Array([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0]), GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST);
5339
+ c.onSystemCreated = (u) => {
5317
5340
  T[u] || (T[u] = F());
5318
5341
  };
5319
- const G = 4e4, H = new Float32Array(G * 8), re = new Float32Array(G * 4), ae = new Float32Array(G * 4), ne = r.createBuffer({ size: G * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), q = r.createBuffer({ size: G * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), tt = r.createBuffer({ size: G * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), xt = /* @__PURE__ */ new Map(), Xe = /* @__PURE__ */ new Map(), kt = 8, _e = [];
5342
+ const G = 4e4, H = new Float32Array(G * 8), se = new Float32Array(G * 4), ne = new Float32Array(G * 4), re = r.createBuffer({ size: G * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), j = r.createBuffer({ size: G * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), tt = r.createBuffer({ size: G * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), xt = /* @__PURE__ */ new Map(), at = /* @__PURE__ */ new Map(), kt = 8, _e = [];
5320
5343
  function oi(u) {
5321
5344
  for (const f of _e) if (f.ids.has(u)) return f;
5322
5345
  return null;
5323
5346
  }
5324
- function is(u, f) {
5347
+ function rs(u, f) {
5325
5348
  if (!u.pos) return;
5326
5349
  u.hist.push({ t: f, x: u.pos[0], y: u.pos[1], z: u.pos[2] });
5327
- const m = f - kt;
5328
- for (; u.hist.length > 2 && u.hist[0].t < m; ) u.hist.shift();
5329
- }
5330
- function li(u, f, m) {
5331
- const g = u.hist;
5332
- if (g.length === 0) {
5333
- const R = u.pos;
5334
- return R && (m[0] = R[0], m[1] = R[1], m[2] = R[2]), m;
5350
+ const y = f - kt;
5351
+ for (; u.hist.length > 2 && u.hist[0].t < y; ) u.hist.shift();
5352
+ }
5353
+ function li(u, f, y) {
5354
+ const p = u.hist;
5355
+ if (p.length === 0) {
5356
+ const w = u.pos;
5357
+ return w && (y[0] = w[0], y[1] = w[1], y[2] = w[2]), y;
5335
5358
  }
5336
- let y;
5337
- if (f >= g[g.length - 1].t)
5338
- return y = g[g.length - 1], m[0] = y.x, m[1] = y.y, m[2] = y.z, m;
5339
- if (f <= g[0].t)
5340
- return y = g[0], m[0] = y.x, m[1] = y.y, m[2] = y.z, m;
5341
- for (let R = g.length - 1; R > 0; R--)
5342
- if (g[R - 1].t <= f) {
5343
- const P = g[R - 1], M = g[R], x = (f - P.t) / Math.max(1e-6, M.t - P.t);
5344
- return m[0] = P.x + (M.x - P.x) * x, m[1] = P.y + (M.y - P.y) * x, m[2] = P.z + (M.z - P.z) * x, m;
5359
+ let g;
5360
+ if (f >= p[p.length - 1].t)
5361
+ return g = p[p.length - 1], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
5362
+ if (f <= p[0].t)
5363
+ return g = p[0], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
5364
+ for (let w = p.length - 1; w > 0; w--)
5365
+ if (p[w - 1].t <= f) {
5366
+ const P = p[w - 1], R = p[w], x = (f - P.t) / Math.max(1e-6, R.t - P.t);
5367
+ return y[0] = P.x + (R.x - P.x) * x, y[1] = P.y + (R.y - P.y) * x, y[2] = P.z + (R.z - P.z) * x, y;
5345
5368
  }
5346
- return y = g[0], m[0] = y.x, m[1] = y.y, m[2] = y.z, m;
5369
+ return g = p[0], y[0] = g.x, y[1] = g.y, y[2] = g.z, y;
5347
5370
  }
5348
- const pt = Math.PI * 2, oe = new Array(257), le = new Array(257), ce = new Array(257), Xt = new Array(257), Nt = new Array(257), Yt = new Array(257);
5371
+ const pt = Math.PI * 2, ae = new Array(257), oe = new Array(257), le = new Array(257), Xt = new Array(257), Nt = new Array(257), Yt = new Array(257);
5349
5372
  new Array(257), new Array(257), new Array(257);
5350
- const Ee = [0, 0, 0];
5351
- function ss(u) {
5352
- const f = u.emissionRotationX || 0, m = u.emissionRotationY || 0, g = u.emissionRotationZ || 0;
5353
- if (!f && !m && !g) return null;
5354
- const y = f * Math.PI / 180, R = m * Math.PI / 180, P = g * Math.PI / 180, M = Math.cos(y), x = Math.sin(y), B = Math.cos(R), h = Math.sin(R), w = Math.cos(P), C = Math.sin(P);
5373
+ const Ae = [0, 0, 0];
5374
+ function ns(u) {
5375
+ const f = u.emissionRotationX || 0, y = u.emissionRotationY || 0, p = u.emissionRotationZ || 0;
5376
+ if (!f && !y && !p) return null;
5377
+ const g = f * Math.PI / 180, w = y * Math.PI / 180, P = p * Math.PI / 180, R = Math.cos(g), x = Math.sin(g), B = Math.cos(w), m = Math.sin(w), M = Math.cos(P), E = Math.sin(P);
5355
5378
  return [
5356
- B * w,
5357
- x * h * w - M * C,
5358
- M * h * w + x * C,
5359
- B * C,
5360
- x * h * C + M * w,
5361
- M * h * C - x * w,
5362
- -h,
5379
+ B * M,
5380
+ x * m * M - R * E,
5381
+ R * m * M + x * E,
5382
+ B * E,
5383
+ x * m * E + R * M,
5384
+ R * m * E - x * M,
5385
+ -m,
5363
5386
  x * B,
5364
- M * B
5387
+ R * B
5365
5388
  ];
5366
5389
  }
5367
- function Ut(u, f, m, g, y) {
5368
- return y[0] = u[0] * f + u[1] * m + u[2] * g, y[1] = u[3] * f + u[4] * m + u[5] * g, y[2] = u[6] * f + u[7] * m + u[8] * g, y;
5390
+ function Ut(u, f, y, p, g) {
5391
+ return g[0] = u[0] * f + u[1] * y + u[2] * p, g[1] = u[3] * f + u[4] * y + u[5] * p, g[2] = u[6] * f + u[7] * y + u[8] * p, g;
5369
5392
  }
5370
- function rs(u, f, m, g, y, R, P) {
5371
- let M = u, x = f, B = m;
5372
- g && (Ut(g, M, x, B, P), M = P[0], x = P[1], B = P[2]), M += R.emissionPositionX || 0, x += R.emissionPositionY || 0, B += R.emissionPositionZ || 0, y._simRotMatrix && (Ut(y._simRotMatrix, M, x, B, P), M = P[0], x = P[1], B = P[2]);
5373
- const h = y._simPosition;
5374
- return P[0] = M + (h ? h[0] : 0), P[1] = x + (h ? h[1] : 0), P[2] = B + (h ? h[2] : 0), P;
5393
+ function as(u, f, y, p, g, w, P) {
5394
+ let R = u, x = f, B = y;
5395
+ p && (Ut(p, R, x, B, P), R = P[0], x = P[1], B = P[2]), R += w.emissionPositionX || 0, x += w.emissionPositionY || 0, B += w.emissionPositionZ || 0, g._simRotMatrix && (Ut(g._simRotMatrix, R, x, B, P), R = P[0], x = P[1], B = P[2]);
5396
+ const m = g._simPosition;
5397
+ return P[0] = R + (m ? m[0] : 0), P[1] = x + (m ? m[1] : 0), P[2] = B + (m ? m[2] : 0), P;
5375
5398
  }
5376
- function ns(u, f, m, g, y, R) {
5377
- let P = u, M = f, x = m;
5378
- return g && (Ut(g, P, M, x, R), P = R[0], M = R[1], x = R[2]), y._simRotMatrix && (Ut(y._simRotMatrix, P, M, x, R), P = R[0], M = R[1], x = R[2]), R[0] = P, R[1] = M, R[2] = x, R;
5399
+ function os(u, f, y, p, g, w) {
5400
+ let P = u, R = f, x = y;
5401
+ return p && (Ut(p, P, R, x, w), P = w[0], R = w[1], x = w[2]), g._simRotMatrix && (Ut(g._simRotMatrix, P, R, x, w), P = w[0], R = w[1], x = w[2]), w[0] = P, w[1] = R, w[2] = x, w;
5379
5402
  }
5380
- function jt(u, f, m, g, y) {
5381
- const R = f * 2, P = m * 2, M = 2 * (R + P);
5382
- let x = (u % 1 + 1) % 1 * M, B = 0, h = 0;
5383
- return x < R ? (B = -f + x, h = m) : (x -= R) < P ? (B = f, h = m - x) : (x -= P) < R ? (B = f - x, h = -m) : (x -= R, B = -f, h = -m + x), g === "xz" ? (y[0] = B, y[1] = 0, y[2] = h) : (y[0] = B, y[1] = h, y[2] = 0), y;
5403
+ function jt(u, f, y, p, g) {
5404
+ const w = f * 2, P = y * 2, R = 2 * (w + P);
5405
+ let x = (u % 1 + 1) % 1 * R, B = 0, m = 0;
5406
+ return x < w ? (B = -f + x, m = y) : (x -= w) < P ? (B = f, m = y - x) : (x -= P) < w ? (B = f - x, m = -y) : (x -= w, B = -f, m = -y + x), p === "xz" ? (g[0] = B, g[1] = 0, g[2] = m) : (g[0] = B, g[1] = m, g[2] = 0), g;
5384
5407
  }
5385
- function as(u) {
5386
- const f = u.emissionShape, m = Math.max(1, Math.min(256, Math.floor(u.shapeStrokeSegments ?? 96)));
5387
- let g = 0, y = !1, R = [0, 0, 1];
5388
- const P = Ee;
5408
+ function ls(u) {
5409
+ const f = u.emissionShape, y = Math.max(1, Math.min(256, Math.floor(u.shapeStrokeSegments ?? 96)));
5410
+ let p = 0, g = !1, w = [0, 0, 1];
5411
+ const P = Ae;
5389
5412
  if (f === "circle") {
5390
- y = !0, g = Math.max(3, m), R = [0, 0, 1];
5391
- const M = u.circleOuterRadius ?? 2;
5392
- for (let x = 0; x < g; x++) {
5393
- const B = x / g * pt;
5394
- oe[x] = Math.cos(B) * M, le[x] = Math.sin(B) * M, ce[x] = 0;
5413
+ g = !0, p = Math.max(3, y), w = [0, 0, 1];
5414
+ const R = u.circleOuterRadius ?? 2;
5415
+ for (let x = 0; x < p; x++) {
5416
+ const B = x / p * pt;
5417
+ ae[x] = Math.cos(B) * R, oe[x] = Math.sin(B) * R, le[x] = 0;
5395
5418
  }
5396
5419
  } else if (f === "disc") {
5397
- y = !0, g = Math.max(3, m), R = [0, 1, 0];
5398
- const M = u.discRadius ?? 2;
5399
- for (let x = 0; x < g; x++) {
5400
- const B = x / g * pt;
5401
- oe[x] = Math.cos(B) * M, le[x] = 0, ce[x] = Math.sin(B) * M;
5420
+ g = !0, p = Math.max(3, y), w = [0, 1, 0];
5421
+ const R = u.discRadius ?? 2;
5422
+ for (let x = 0; x < p; x++) {
5423
+ const B = x / p * pt;
5424
+ ae[x] = Math.cos(B) * R, oe[x] = 0, le[x] = Math.sin(B) * R;
5402
5425
  }
5403
5426
  } else if (f === "annulus") {
5404
- y = !0, g = Math.max(3, m), R = [0, 1, 0];
5405
- const M = u.annulusInnerRadius ?? 1, x = u.annulusOuterRadius ?? 2, B = M + (x - M) * 0.5;
5406
- for (let h = 0; h < g; h++) {
5407
- const w = h / g * pt;
5408
- oe[h] = Math.cos(w) * B, le[h] = 0, ce[h] = Math.sin(w) * B;
5427
+ g = !0, p = Math.max(3, y), w = [0, 1, 0];
5428
+ const R = u.annulusInnerRadius ?? 1, x = u.annulusOuterRadius ?? 2, B = R + (x - R) * 0.5;
5429
+ for (let m = 0; m < p; m++) {
5430
+ const M = m / p * pt;
5431
+ ae[m] = Math.cos(M) * B, oe[m] = 0, le[m] = Math.sin(M) * B;
5409
5432
  }
5410
5433
  } else if (f === "arc") {
5411
- y = !1, g = Math.max(2, m + 1), R = [0, 0, 1];
5412
- const M = u.arcInnerRadius ?? 0, x = u.arcOuterRadius ?? 2, B = M > 0 ? M + (x - M) * 0.5 : x, h = (u.arcStartAngle ?? 0) * Math.PI / 180, w = (u.arcEndAngle ?? 180) * Math.PI / 180;
5413
- for (let C = 0; C < g; C++) {
5414
- const Z = g > 1 ? C / (g - 1) : 0, O = h + (w - h) * Z;
5415
- oe[C] = Math.cos(O) * B, le[C] = Math.sin(O) * B, ce[C] = 0;
5434
+ g = !1, p = Math.max(2, y + 1), w = [0, 0, 1];
5435
+ const R = u.arcInnerRadius ?? 0, x = u.arcOuterRadius ?? 2, B = R > 0 ? R + (x - R) * 0.5 : x, m = (u.arcStartAngle ?? 0) * Math.PI / 180, M = (u.arcEndAngle ?? 180) * Math.PI / 180;
5436
+ for (let E = 0; E < p; E++) {
5437
+ const q = p > 1 ? E / (p - 1) : 0, X = m + (M - m) * q;
5438
+ ae[E] = Math.cos(X) * B, oe[E] = Math.sin(X) * B, le[E] = 0;
5416
5439
  }
5417
5440
  } else if (f === "square") {
5418
- y = !0, g = Math.max(4, m), R = [0, 0, 1];
5419
- const M = u.squareSize ?? 2;
5420
- for (let x = 0; x < g; x++)
5421
- jt(x / g, M, M, "xy", P), oe[x] = P[0], le[x] = P[1], ce[x] = P[2];
5441
+ g = !0, p = Math.max(4, y), w = [0, 0, 1];
5442
+ const R = u.squareSize ?? 2;
5443
+ for (let x = 0; x < p; x++)
5444
+ jt(x / p, R, R, "xy", P), ae[x] = P[0], oe[x] = P[1], le[x] = P[2];
5422
5445
  } else if (f === "rectangle") {
5423
- y = !0, g = Math.max(4, m), R = [0, 0, 1];
5424
- const M = (u.rectangleWidth ?? 2) * 0.5, x = (u.rectangleHeight ?? 2) * 0.5;
5425
- for (let B = 0; B < g; B++)
5426
- jt(B / g, M, x, "xy", P), oe[B] = P[0], le[B] = P[1], ce[B] = P[2];
5446
+ g = !0, p = Math.max(4, y), w = [0, 0, 1];
5447
+ const R = (u.rectangleWidth ?? 2) * 0.5, x = (u.rectangleHeight ?? 2) * 0.5;
5448
+ for (let B = 0; B < p; B++)
5449
+ jt(B / p, R, x, "xy", P), ae[B] = P[0], oe[B] = P[1], le[B] = P[2];
5427
5450
  } else if (f === "plain") {
5428
- y = !0, g = Math.max(4, m), R = [0, 1, 0];
5429
- const M = (u.planeWidth ?? 2) * 0.5, x = (u.planeDepth ?? 2) * 0.5;
5430
- for (let B = 0; B < g; B++)
5431
- jt(B / g, M, x, "xz", P), oe[B] = P[0], le[B] = P[1], ce[B] = P[2];
5451
+ g = !0, p = Math.max(4, y), w = [0, 1, 0];
5452
+ const R = (u.planeWidth ?? 2) * 0.5, x = (u.planeDepth ?? 2) * 0.5;
5453
+ for (let B = 0; B < p; B++)
5454
+ jt(B / p, R, x, "xz", P), ae[B] = P[0], oe[B] = P[1], le[B] = P[2];
5432
5455
  } else if (f === "line") {
5433
- y = !1, g = Math.max(2, m + 1), R = [0, 0, 1];
5434
- const M = u.lineLength ?? 4;
5435
- for (let x = 0; x < g; x++) {
5436
- const B = g > 1 ? x / (g - 1) : 0;
5437
- oe[x] = 0, le[x] = (B - 0.5) * M, ce[x] = 0;
5456
+ g = !1, p = Math.max(2, y + 1), w = [0, 0, 1];
5457
+ const R = u.lineLength ?? 4;
5458
+ for (let x = 0; x < p; x++) {
5459
+ const B = p > 1 ? x / (p - 1) : 0;
5460
+ ae[x] = 0, oe[x] = (B - 0.5) * R, le[x] = 0;
5438
5461
  }
5439
5462
  } else if (f === "polygon") {
5440
- y = !0, g = Math.max(3, m), R = [0, 0, 1];
5441
- const M = Math.max(3, Math.floor(u.polygonSides ?? 6)), x = u.polygonRadius ?? 2;
5442
- for (let B = 0; B < g; B++) {
5443
- const h = B / g * M, w = Math.floor(h), C = h - w, Z = w / M * pt, O = (w + 1) / M * pt, L = Math.cos(Z) * x, N = Math.sin(Z) * x, V = Math.cos(O) * x, xe = Math.sin(O) * x;
5444
- oe[B] = L + (V - L) * C, le[B] = N + (xe - N) * C, ce[B] = 0;
5463
+ g = !0, p = Math.max(3, y), w = [0, 0, 1];
5464
+ const R = Math.max(3, Math.floor(u.polygonSides ?? 6)), x = u.polygonRadius ?? 2;
5465
+ for (let B = 0; B < p; B++) {
5466
+ const m = B / p * R, M = Math.floor(m), E = m - M, q = M / R * pt, X = (M + 1) / R * pt, O = Math.cos(q) * x, U = Math.sin(q) * x, be = Math.cos(X) * x, Se = Math.sin(X) * x;
5467
+ ae[B] = O + (be - O) * E, oe[B] = U + (Se - U) * E, le[B] = 0;
5445
5468
  }
5446
5469
  } else
5447
- g = 0;
5448
- return { count: g, closed: y, planeNormal: R };
5449
- }
5450
- function os(u, f, m) {
5451
- if (!m.shapeStrokeEnabled || m.hidden) return u;
5452
- const { count: g, closed: y, planeNormal: R } = as(m);
5453
- if (g < 2) return u;
5454
- const P = ss(m), M = Math.max(1e-4, m.shapeStrokeWidth ?? 0.08), x = Math.max(0, m.opacity ?? 1);
5470
+ p = 0;
5471
+ return { count: p, closed: g, planeNormal: w };
5472
+ }
5473
+ function cs(u, f, y) {
5474
+ if (!y.shapeStrokeEnabled || y.hidden) return u;
5475
+ const { count: p, closed: g, planeNormal: w } = ls(y);
5476
+ if (p < 2) return u;
5477
+ const P = ns(y), R = Math.max(1e-4, y.shapeStrokeWidth ?? 0.08), x = Math.max(0, y.opacity ?? 1);
5455
5478
  if (x <= 0) return u;
5456
- ns(R[0], R[1], R[2], P, f, Ee);
5457
- let B = Math.hypot(Ee[0], Ee[1], Ee[2]) || 1;
5458
- const h = Ee[0] / B, w = Ee[1] / B, C = Ee[2] / B;
5459
- for (let U = 0; U < g; U++)
5460
- rs(oe[U], le[U], ce[U], P, f, m, Ee), oe[U] = Ee[0], le[U] = Ee[1], ce[U] = Ee[2];
5461
- const Z = m.shapeStrokeShape ?? "straight";
5462
- if (Z !== "straight") {
5463
- const U = m.shapeStrokeAmplitude ?? 0.08, Q = m.shapeStrokeFrequency ?? 10, Ie = m.shapeStrokeSpeed ?? 0;
5464
- for (let $ = 0; $ < g; $++) {
5465
- const pe = $ === 0 ? y ? g - 1 : 0 : $ - 1, te = $ === g - 1 ? y ? 0 : g - 1 : $ + 1, ye = oe[te] - oe[pe], J = le[te] - le[pe], ee = ce[te] - ce[pe], K = w * ee - C * J, ie = C * ye - h * ee, ue = h * J - w * ye, ge = Math.hypot(K, ie, ue) || 1, ve = K / ge, de = ie / ge, Ze = ue / ge, Me = y ? $ / g : $ / Math.max(1, g - 1), be = pt * Q * Me + Ie * Ve;
5466
- let he = 0, me = 0;
5467
- Z === "zigzag" ? he = U * Math.sign(Math.sin(be) || 1) : Z === "sine" ? he = U * Math.sin(be) : Z === "spiral" && (he = U * Math.sin(be), me = U * Math.cos(be)), oe[$] += ve * he + h * me, le[$] += de * he + w * me, ce[$] += Ze * he + C * me;
5479
+ os(w[0], w[1], w[2], P, f, Ae);
5480
+ let B = Math.hypot(Ae[0], Ae[1], Ae[2]) || 1;
5481
+ const m = Ae[0] / B, M = Ae[1] / B, E = Ae[2] / B;
5482
+ for (let I = 0; I < p; I++)
5483
+ as(ae[I], oe[I], le[I], P, f, y, Ae), ae[I] = Ae[0], oe[I] = Ae[1], le[I] = Ae[2];
5484
+ const q = y.shapeStrokeShape ?? "straight";
5485
+ if (q !== "straight") {
5486
+ const I = y.shapeStrokeAmplitude ?? 0.08, K = y.shapeStrokeFrequency ?? 10, Ie = y.shapeStrokeSpeed ?? 0;
5487
+ for (let W = 0; W < p; W++) {
5488
+ const fe = W === 0 ? g ? p - 1 : 0 : W - 1, ee = W === p - 1 ? g ? 0 : p - 1 : W + 1, me = ae[ee] - ae[fe], $ = oe[ee] - oe[fe], Q = le[ee] - le[fe], J = M * Q - E * $, te = E * me - m * Q, ce = m * $ - M * me, ye = Math.hypot(J, te, ce) || 1, ve = J / ye, ue = te / ye, He = ce / ye, Me = g ? W / p : W / Math.max(1, p - 1), ge = pt * K * Me + Ie * Ve;
5489
+ let pe = 0, he = 0;
5490
+ q === "zigzag" ? pe = I * Math.sign(Math.sin(ge) || 1) : q === "sine" ? pe = I * Math.sin(ge) : q === "spiral" && (pe = I * Math.sin(ge), he = I * Math.cos(ge)), ae[W] += ve * pe + m * he, oe[W] += ue * pe + M * he, le[W] += He * pe + E * he;
5468
5491
  }
5469
5492
  }
5470
- const O = y ? g : g - 1, L = m.bloomIntensity || 1, N = m.startColor ?? m.particleColor ?? [1, 1, 1], V = m.endColor ?? N, xe = m.particleColor ?? N, ct = m.randomColorEnabled && Array.isArray(m.randomColors) && m.randomColors.length > 0 ? m.randomColors[0] : null, Se = M * 0.5, _t = Math.max(M * 4, 1e-4), je = (m.shapeStrokeSpeed ?? 0) * Ve;
5493
+ const X = g ? p : p - 1, O = y.bloomIntensity || 1, U = y.startColor ?? y.particleColor ?? [1, 1, 1], be = y.endColor ?? U, Se = y.particleColor ?? U, Oe = y.randomColorEnabled && Array.isArray(y.randomColors) && y.randomColors.length > 0 ? y.randomColors[0] : null, xe = R * 0.5, _t = Math.max(R * 4, 1e-4), je = (y.shapeStrokeSpeed ?? 0) * Ve;
5471
5494
  let it = 0;
5472
- for (let U = 0; U < O; U++) {
5473
- const Q = y ? (U + 1) % g : U + 1;
5474
- it += Math.hypot(oe[Q] - oe[U], le[Q] - le[U], ce[Q] - ce[U]);
5495
+ for (let I = 0; I < X; I++) {
5496
+ const K = g ? (I + 1) % p : I + 1;
5497
+ it += Math.hypot(ae[K] - ae[I], oe[K] - oe[I], le[K] - le[I]);
5475
5498
  }
5476
- const Qt = y ? Math.max(1, Math.round(it / _t)) : Math.max(it / _t, 1e-6), Mt = it > 1e-6 ? Qt / it : 0;
5499
+ const Qt = g ? Math.max(1, Math.round(it / _t)) : Math.max(it / _t, 1e-6), Mt = it > 1e-6 ? Qt / it : 0;
5477
5500
  let qe = 0, wt = !1, ut = 0, Ue = 0, dt = 0;
5478
- for (let U = 0; U < g; U++) {
5479
- const Q = U === 0 ? y ? g - 1 : 0 : U - 1, Ie = U === g - 1 ? y ? 0 : g - 1 : U + 1;
5480
- let $ = oe[Ie] - oe[Q], pe = le[Ie] - le[Q], te = ce[Ie] - ce[Q];
5481
- const ye = Math.hypot($, pe, te) || 1;
5482
- $ /= ye, pe /= ye, te /= ye;
5483
- let J = w * te - C * pe, ee = C * $ - h * te, K = h * pe - w * $, ie = Math.hypot(J, ee, K);
5484
- if (ie < 1e-5) {
5485
- const ue = D.right[0], ge = D.right[1], ve = D.right[2], de = ue * $ + ge * pe + ve * te;
5486
- J = ue - de * $, ee = ge - de * pe, K = ve - de * te, ie = Math.hypot(J, ee, K);
5501
+ for (let I = 0; I < p; I++) {
5502
+ const K = I === 0 ? g ? p - 1 : 0 : I - 1, Ie = I === p - 1 ? g ? 0 : p - 1 : I + 1;
5503
+ let W = ae[Ie] - ae[K], fe = oe[Ie] - oe[K], ee = le[Ie] - le[K];
5504
+ const me = Math.hypot(W, fe, ee) || 1;
5505
+ W /= me, fe /= me, ee /= me;
5506
+ let $ = M * ee - E * fe, Q = E * W - m * ee, J = m * fe - M * W, te = Math.hypot($, Q, J);
5507
+ if (te < 1e-5) {
5508
+ const ce = V.right[0], ye = V.right[1], ve = V.right[2], ue = ce * W + ye * fe + ve * ee;
5509
+ $ = ce - ue * W, Q = ye - ue * fe, J = ve - ue * ee, te = Math.hypot($, Q, J);
5487
5510
  }
5488
- if (ie < 1e-5) {
5489
- const ue = D.up[0], ge = D.up[1], ve = D.up[2], de = ue * $ + ge * pe + ve * te;
5490
- J = ue - de * $, ee = ge - de * pe, K = ve - de * te, ie = Math.hypot(J, ee, K) || 1;
5511
+ if (te < 1e-5) {
5512
+ const ce = V.up[0], ye = V.up[1], ve = V.up[2], ue = ce * W + ye * fe + ve * ee;
5513
+ $ = ce - ue * W, Q = ye - ue * fe, J = ve - ue * ee, te = Math.hypot($, Q, J) || 1;
5491
5514
  }
5492
- J /= ie, ee /= ie, K /= ie, wt && ut * J + Ue * ee + dt * K < 0 && (J = -J, ee = -ee, K = -K), Xt[U] = J, Nt[U] = ee, Yt[U] = K, ut = J, Ue = ee, dt = K, wt = !0;
5515
+ $ /= te, Q /= te, J /= te, wt && ut * $ + Ue * Q + dt * J < 0 && ($ = -$, Q = -Q, J = -J), Xt[I] = $, Nt[I] = Q, Yt[I] = J, ut = $, Ue = Q, dt = J, wt = !0;
5493
5516
  }
5494
- for (let U = 0; U < O && !(u + 54 > Ce.length); U++) {
5495
- const Q = y ? (U + 1) % g : U + 1, Ie = oe[U], $ = le[U], pe = ce[U], te = oe[Q], ye = le[Q], J = ce[Q];
5496
- let ee = te - Ie, K = ye - $, ie = J - pe;
5497
- const ue = Math.hypot(ee, K, ie) || 1;
5498
- ee /= ue, K /= ue, ie /= ue;
5499
- const ge = y ? U / g : U / Math.max(1, g - 1), ve = y ? Q / g : Q / Math.max(1, g - 1), de = qe * Mt + je, Ze = (qe + ue) * Mt + je;
5500
- let Me, be, he, me, we, Be;
5501
- ct ? (Me = me = ct[0], be = we = ct[1], he = Be = ct[2]) : m.colorTransitionEnabled ? (Me = N[0] + (V[0] - N[0]) * ge, be = N[1] + (V[1] - N[1]) * ge, he = N[2] + (V[2] - N[2]) * ge, me = N[0] + (V[0] - N[0]) * ve, we = N[1] + (V[1] - N[1]) * ve, Be = N[2] + (V[2] - N[2]) * ve) : (Me = me = xe[0], be = we = xe[1], he = Be = xe[2]), Me = Math.min(1, Me * L), be = Math.min(1, be * L), he = Math.min(1, he * L), me = Math.min(1, me * L), we = Math.min(1, we * L), Be = Math.min(1, Be * L);
5502
- const Bt = Xt[U], gt = Nt[U], Oe = Yt[U], Le = Xt[Q], ze = Nt[Q], Rt = Yt[Q], Ot = Ie + Bt * Se, Lt = $ + gt * Se, Tt = pe + Oe * Se, Re = Ie - Bt * Se, Te = $ - gt * Se, Ae = pe - Oe * Se, st = te + Le * Se, rt = ye + ze * Se, At = J + Rt * Se, He = te - Le * Se, We = ye - ze * Se, $e = J - Rt * Se, ft = (A, X, fe, Y, k, j, se, Je, Ke) => {
5503
- Ce[u++] = A, Ce[u++] = X, Ce[u++] = fe, Ce[u++] = Y, Ce[u++] = k, Ce[u++] = j, Ce[u++] = se, Ce[u++] = Je, Ce[u++] = Ke;
5517
+ for (let I = 0; I < X && !(u + 54 > Ce.length); I++) {
5518
+ const K = g ? (I + 1) % p : I + 1, Ie = ae[I], W = oe[I], fe = le[I], ee = ae[K], me = oe[K], $ = le[K];
5519
+ let Q = ee - Ie, J = me - W, te = $ - fe;
5520
+ const ce = Math.hypot(Q, J, te) || 1;
5521
+ Q /= ce, J /= ce, te /= ce;
5522
+ const ye = g ? I / p : I / Math.max(1, p - 1), ve = g ? K / p : K / Math.max(1, p - 1), ue = qe * Mt + je, He = (qe + ce) * Mt + je;
5523
+ let Me, ge, pe, he, we, Re;
5524
+ Oe ? (Me = he = Oe[0], ge = we = Oe[1], pe = Re = Oe[2]) : y.colorTransitionEnabled ? (Me = U[0] + (be[0] - U[0]) * ye, ge = U[1] + (be[1] - U[1]) * ye, pe = U[2] + (be[2] - U[2]) * ye, he = U[0] + (be[0] - U[0]) * ve, we = U[1] + (be[1] - U[1]) * ve, Re = U[2] + (be[2] - U[2]) * ve) : (Me = he = Se[0], ge = we = Se[1], pe = Re = Se[2]), Me = Math.min(1, Me * O), ge = Math.min(1, ge * O), pe = Math.min(1, pe * O), he = Math.min(1, he * O), we = Math.min(1, we * O), Re = Math.min(1, Re * O);
5525
+ const Rt = Xt[I], gt = Nt[I], Le = Yt[I], ke = Xt[K], ze = Nt[K], Bt = Yt[K], Ot = Ie + Rt * xe, Lt = W + gt * xe, Tt = fe + Le * xe, Be = Ie - Rt * xe, Te = W - gt * xe, Ee = fe - Le * xe, st = ee + ke * xe, rt = me + ze * xe, Et = $ + Bt * xe, Ze = ee - ke * xe, We = me - ze * xe, $e = $ - Bt * xe, ft = (A, k, de, N, L, Y, ie, Je, Ke) => {
5526
+ Ce[u++] = A, Ce[u++] = k, Ce[u++] = de, Ce[u++] = N, Ce[u++] = L, Ce[u++] = Y, Ce[u++] = ie, Ce[u++] = Je, Ce[u++] = Ke;
5504
5527
  };
5505
- ft(Ot, Lt, Tt, Me, be, he, x, de, 0), ft(Re, Te, Ae, Me, be, he, x, de, 1), ft(st, rt, At, me, we, Be, x, Ze, 0), ft(Re, Te, Ae, Me, be, he, x, de, 1), ft(He, We, $e, me, we, Be, x, Ze, 1), ft(st, rt, At, me, we, Be, x, Ze, 0), qe += ue;
5528
+ ft(Ot, Lt, Tt, Me, ge, pe, x, ue, 0), ft(Be, Te, Ee, Me, ge, pe, x, ue, 1), ft(st, rt, Et, he, we, Re, x, He, 0), ft(Be, Te, Ee, Me, ge, pe, x, ue, 1), ft(Ze, We, $e, he, we, Re, x, He, 1), ft(st, rt, Et, he, we, Re, x, He, 0), qe += ce;
5506
5529
  }
5507
5530
  return u;
5508
5531
  }
5509
- const ls = 0.41421356;
5510
- function cs() {
5511
- xt.clear(), Xe.clear();
5512
- let u = 0, f = 0, m = 0;
5513
- D.position[0], D.position[1], D.position[2];
5514
- for (const { system: g, config: y } of l.particleSystems) {
5515
- if (y.hidden) continue;
5516
- if (y.emissionTrailEnabled && !y.glbModelEnabled) {
5517
- g.readbackAndProcessParticles();
5518
- const P = g.particleData, M = g.particleVelocities, x = g.activeParticles;
5519
- if (P && M && x > 0) {
5520
- const B = y.emissionTrailMode === "particles", h = u, w = y.emissionTrailDuration ?? 1, C = y.opacity ?? 1, Z = y.particleSize ?? 0.5, O = y.bloomIntensity || 1, L = Math.max(1, Math.min(64, y.emissionTrailSegments ?? 8)), N = y.emissionTrailShape || "straight", V = y.followSystemTranslation ?? !0, xe = g._simPosition, ct = V && xe ? xe[0] : 0, Se = V && xe ? xe[1] : 0, _t = V && xe ? xe[2] : 0, je = g._simVelocity, it = je ? je[0] : 0, Qt = je ? je[1] : 0, Mt = je ? je[2] : 0, qe = oi(y.id), wt = !!(V && qe && qe.hist && qe.hist.length > 1);
5532
+ const us = 0.41421356;
5533
+ function ds() {
5534
+ xt.clear(), at.clear();
5535
+ let u = 0, f = 0, y = 0;
5536
+ V.position[0], V.position[1], V.position[2];
5537
+ for (const { system: p, config: g } of c.particleSystems) {
5538
+ if (g.hidden) continue;
5539
+ if (g.emissionTrailEnabled && !g.glbModelEnabled) {
5540
+ p.readbackAndProcessParticles();
5541
+ const P = p.particleData, R = p.particleVelocities, x = p.activeParticles;
5542
+ if (P && R && x > 0) {
5543
+ const B = g.emissionTrailMode === "particles", m = u, M = g.emissionTrailDuration ?? 1, E = g.opacity ?? 1, q = g.particleSize ?? 0.5, X = g.bloomIntensity || 1, O = Math.max(1, Math.min(64, g.emissionTrailSegments ?? 8)), U = g.emissionTrailShape || "straight", be = g.followSystemTranslation ?? !0, Se = p._simPosition, Oe = be && Se ? Se[0] : 0, xe = be && Se ? Se[1] : 0, _t = be && Se ? Se[2] : 0, je = p._simVelocity, it = je ? je[0] : 0, Qt = je ? je[1] : 0, Mt = je ? je[2] : 0, qe = oi(g.id), wt = !!(be && qe && qe.hist && qe.hist.length > 1);
5521
5544
  for (let ut = 0; ut < x; ut++) {
5522
- const Ue = ut * 8, dt = P[Ue], U = P[Ue + 1], Q = P[Ue + 2], Ie = dt + ct, $ = U + Se, pe = Q + _t;
5523
- let te = P[Ue + 3], ye = P[Ue + 4], J = P[Ue + 5];
5524
- const ee = P[Ue + 6], K = P[Ue + 7];
5525
- if (ee >= K || K <= 0) continue;
5526
- const ie = ee / K;
5527
- if (y.colorTransitionEnabled) {
5528
- const A = y.startColor ?? [1, 0, 0], X = y.endColor ?? [0, 0, 1];
5529
- te = A[0] + (X[0] - A[0]) * ie, ye = A[1] + (X[1] - A[1]) * ie, J = A[2] + (X[2] - A[2]) * ie;
5545
+ const Ue = ut * 8, dt = P[Ue], I = P[Ue + 1], K = P[Ue + 2], Ie = dt + Oe, W = I + xe, fe = K + _t;
5546
+ let ee = P[Ue + 3], me = P[Ue + 4], $ = P[Ue + 5];
5547
+ const Q = P[Ue + 6], J = P[Ue + 7];
5548
+ if (Q >= J || J <= 0) continue;
5549
+ const te = Q / J;
5550
+ if (g.colorTransitionEnabled) {
5551
+ const A = g.startColor ?? [1, 0, 0], k = g.endColor ?? [0, 0, 1];
5552
+ ee = A[0] + (k[0] - A[0]) * te, me = A[1] + (k[1] - A[1]) * te, $ = A[2] + (k[2] - A[2]) * te;
5530
5553
  }
5531
- te = Math.min(1, te * O), ye = Math.min(1, ye * O), J = Math.min(1, J * O);
5532
- let ue = Z;
5533
- if (y.randomSize) {
5534
- const A = Math.sin(K * 54321.67) * 43758.5453 % 1, X = A < 0 ? A + 1 : A;
5535
- ue = (y.minSize ?? 0.1) + ((y.maxSize ?? 0.5) - (y.minSize ?? 0.1)) * X;
5554
+ ee = Math.min(1, ee * X), me = Math.min(1, me * X), $ = Math.min(1, $ * X);
5555
+ let ce = q;
5556
+ if (g.randomSize) {
5557
+ const A = Math.sin(J * 54321.67) * 43758.5453 % 1, k = A < 0 ? A + 1 : A;
5558
+ ce = (g.minSize ?? 0.1) + ((g.maxSize ?? 0.5) - (g.minSize ?? 0.1)) * k;
5536
5559
  }
5537
- if (y.fadeSizeEnabled) {
5538
- const A = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
5539
- ue *= 1 - Math.pow(ie, 1 / A);
5560
+ if (g.fadeSizeEnabled) {
5561
+ const A = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
5562
+ ce *= 1 - Math.pow(te, 1 / A);
5540
5563
  }
5541
- if (y.increaseSizeEnabled) {
5542
- const A = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
5543
- ue *= 1 + Math.pow(ie, 1 / A);
5564
+ if (g.increaseSizeEnabled) {
5565
+ const A = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
5566
+ ce *= 1 + Math.pow(te, 1 / A);
5544
5567
  }
5545
- if (ue <= 0 || ie > 0.9) continue;
5546
- const ge = Math.min((0.9 - ie) * (1 / 0.2), 1), ve = 0.75 * ue * ls * ge;
5547
- let de = C;
5548
- if (y.fadeEnabled && (de *= Math.max(0, 1 - ie)), de *= ge, de < 0.01) continue;
5549
- const Ze = ut * 4, Me = M[Ze], be = M[Ze + 1], he = M[Ze + 2], me = Me + it, we = be + Qt, Be = he + Mt, Bt = Math.sqrt(me * me + we * we + Be * Be);
5550
- if (Bt < 1e-3) continue;
5551
- const gt = 1 / Bt, Oe = me * gt, Le = we * gt, ze = Be * gt, Rt = D.right[0], Ot = D.right[1], Lt = D.right[2];
5552
- let Tt = Rt * Oe + Ot * Le + Lt * ze, Re = Rt - Tt * Oe, Te = Ot - Tt * Le, Ae = Lt - Tt * ze, st = Math.sqrt(Re * Re + Te * Te + Ae * Ae);
5568
+ if (ce <= 0 || te > 0.9) continue;
5569
+ const ye = Math.min((0.9 - te) * (1 / 0.2), 1), ve = 0.75 * ce * us * ye;
5570
+ let ue = E;
5571
+ if (g.fadeEnabled && (ue *= Math.max(0, 1 - te)), ue *= ye, ue < 0.01) continue;
5572
+ const He = ut * 4, Me = R[He], ge = R[He + 1], pe = R[He + 2], he = Me + it, we = ge + Qt, Re = pe + Mt, Rt = Math.sqrt(he * he + we * we + Re * Re);
5573
+ if (Rt < 1e-3) continue;
5574
+ const gt = 1 / Rt, Le = he * gt, ke = we * gt, ze = Re * gt, Bt = V.right[0], Ot = V.right[1], Lt = V.right[2];
5575
+ let Tt = Bt * Le + Ot * ke + Lt * ze, Be = Bt - Tt * Le, Te = Ot - Tt * ke, Ee = Lt - Tt * ze, st = Math.sqrt(Be * Be + Te * Te + Ee * Ee);
5553
5576
  if (st < 0.2) {
5554
- const A = D.up[0], X = D.up[1], fe = D.up[2], Y = A * Oe + X * Le + fe * ze;
5555
- Re = A - Y * Oe, Te = X - Y * Le, Ae = fe - Y * ze, st = Math.sqrt(Re * Re + Te * Te + Ae * Ae) || 1;
5577
+ const A = V.up[0], k = V.up[1], de = V.up[2], N = A * Le + k * ke + de * ze;
5578
+ Be = A - N * Le, Te = k - N * ke, Ee = de - N * ze, st = Math.sqrt(Be * Be + Te * Te + Ee * Ee) || 1;
5556
5579
  }
5557
- Re /= st, Te /= st, Ae /= st;
5558
- const rt = Math.min(w, ee);
5580
+ Be /= st, Te /= st, Ee /= st;
5581
+ const rt = Math.min(M, Q);
5559
5582
  if (rt < 1e-3) continue;
5560
- const At = y.gravityEnabled && y.gravityStrength || 0, He = vs, We = Ps, $e = _s;
5561
- if (y.orientToDirection && y.burstMode && wt) {
5562
- const A = g._emitSimRotY || 0, X = Ms, fe = ws, Y = Bs;
5563
- for (let k = 0; k <= L; k++) {
5564
- const j = li(qe, Ve - k / L * rt, Pi);
5565
- X[k] = j[0], fe[k] = j[1], Y[k] = j[2];
5583
+ const Et = g.gravityEnabled && g.gravityStrength || 0, Ze = _s, We = Ms, $e = ws;
5584
+ if (g.orientToDirection && g.burstMode && wt) {
5585
+ const A = p._emitSimRotY || 0, k = Rs, de = Bs, N = Ts;
5586
+ for (let L = 0; L <= O; L++) {
5587
+ const Y = li(qe, Ve - L / O * rt, Pi);
5588
+ k[L] = Y[0], de[L] = Y[1], N[L] = Y[2];
5566
5589
  }
5567
- for (let k = 0; k <= L; k++) {
5568
- const j = k > 0 ? k - 1 : 0, se = k < L ? k + 1 : L;
5569
- let Je = X[j] - X[se], Ke = Y[j] - Y[se];
5570
- const nt = (Math.hypot(Je, Ke) > 1e-5 ? Math.atan2(Je, Ke) : Math.atan2(it, Mt)) - A, Fe = Math.cos(nt), Ge = Math.sin(nt), et = k / L * rt, ei = -0.5 * At * et * et;
5571
- He[k] = Fe * dt + Ge * Q + X[k], We[k] = U + ei + fe[k], $e[k] = -Ge * dt + Fe * Q + Y[k];
5590
+ for (let L = 0; L <= O; L++) {
5591
+ const Y = L > 0 ? L - 1 : 0, ie = L < O ? L + 1 : O;
5592
+ let Je = k[Y] - k[ie], Ke = N[Y] - N[ie];
5593
+ const nt = (Math.hypot(Je, Ke) > 1e-5 ? Math.atan2(Je, Ke) : Math.atan2(it, Mt)) - A, De = Math.cos(nt), Fe = Math.sin(nt), et = L / O * rt, ei = -0.5 * Et * et * et;
5594
+ Ze[L] = De * dt + Fe * K + k[L], We[L] = I + ei + de[L], $e[L] = -Fe * dt + De * K + N[L];
5572
5595
  }
5573
- } else for (let A = 0; A <= L; A++) {
5574
- const X = A / L * rt, fe = -0.5 * At * X * X;
5596
+ } else for (let A = 0; A <= O; A++) {
5597
+ const k = A / O * rt, de = -0.5 * Et * k * k;
5575
5598
  if (wt) {
5576
- const Y = li(qe, Ve - X, Pi);
5577
- He[A] = dt - Me * X + Y[0], We[A] = U - be * X + fe + Y[1], $e[A] = Q - he * X + Y[2];
5599
+ const N = li(qe, Ve - k, Pi);
5600
+ Ze[A] = dt - Me * k + N[0], We[A] = I - ge * k + de + N[1], $e[A] = K - pe * k + N[2];
5578
5601
  } else
5579
- He[A] = Ie - me * X, We[A] = $ - we * X + fe, $e[A] = pe - Be * X;
5602
+ Ze[A] = Ie - he * k, We[A] = W - we * k + de, $e[A] = fe - Re * k;
5580
5603
  }
5581
- if (N !== "straight") {
5582
- const A = y.emissionTrailShapeAmplitude ?? 0.1, X = y.emissionTrailShapeFrequency ?? 4, fe = y.emissionTrailShapeSpeed ?? 0;
5583
- let Y = -ze, k = 0, j = Oe, se = Math.sqrt(Y * Y + j * j);
5584
- se < 1e-6 && (Y = 0, k = ze, j = -Le, se = Math.sqrt(Y * Y + k * k + j * j) || 1), Y /= se, k /= se, j /= se;
5585
- const Je = Le * j - ze * k, Ke = ze * Y - Oe * j, Qe = Oe * k - Le * Y;
5586
- for (let Pe = 1; Pe <= L; Pe++) {
5587
- const nt = Pe / L * rt, Fe = 2 * Math.PI * X * (Ve - nt) + fe * Ve;
5588
- let Ge = 0, et = 0;
5589
- N === "zigzag" ? Ge = A * Math.sign(Math.sin(Fe)) : N === "sine" ? Ge = A * Math.sin(Fe) : N === "spiral" && (Ge = A * Math.sin(Fe), et = A * Math.cos(Fe)), He[Pe] += Y * Ge + Je * et, We[Pe] += k * Ge + Ke * et, $e[Pe] += j * Ge + Qe * et;
5604
+ if (U !== "straight") {
5605
+ const A = g.emissionTrailShapeAmplitude ?? 0.1, k = g.emissionTrailShapeFrequency ?? 4, de = g.emissionTrailShapeSpeed ?? 0;
5606
+ let N = -ze, L = 0, Y = Le, ie = Math.sqrt(N * N + Y * Y);
5607
+ ie < 1e-6 && (N = 0, L = ze, Y = -ke, ie = Math.sqrt(N * N + L * L + Y * Y) || 1), N /= ie, L /= ie, Y /= ie;
5608
+ const Je = ke * Y - ze * L, Ke = ze * N - Le * Y, Qe = Le * L - ke * N;
5609
+ for (let Pe = 1; Pe <= O; Pe++) {
5610
+ const nt = Pe / O * rt, De = 2 * Math.PI * k * (Ve - nt) + de * Ve;
5611
+ let Fe = 0, et = 0;
5612
+ U === "zigzag" ? Fe = A * Math.sign(Math.sin(De)) : U === "sine" ? Fe = A * Math.sin(De) : U === "spiral" && (Fe = A * Math.sin(De), et = A * Math.cos(De)), Ze[Pe] += N * Fe + Je * et, We[Pe] += L * Fe + Ke * et, $e[Pe] += Y * Fe + Qe * et;
5590
5613
  }
5591
5614
  }
5592
5615
  if (B)
5593
- for (let A = 1; A <= L && u < G; A++) {
5594
- const X = A / L, fe = He[A] - ct, Y = We[A] - Se, k = $e[A] - _t, j = u * 8, se = u * 4;
5595
- H[j] = fe, H[j + 1] = Y, H[j + 2] = k, H[j + 3] = te, H[j + 4] = ye, H[j + 5] = J, H[j + 6] = ee + (K - ee) * X, H[j + 7] = K, re[se] = 0, re[se + 1] = 0, re[se + 2] = 0, re[se + 3] = 0, ae[se] = fe, ae[se + 1] = Y, ae[se + 2] = k, ae[se + 3] = 0, u++;
5616
+ for (let A = 1; A <= O && u < G; A++) {
5617
+ const k = A / O, de = Ze[A] - Oe, N = We[A] - xe, L = $e[A] - _t, Y = u * 8, ie = u * 4;
5618
+ H[Y] = de, H[Y + 1] = N, H[Y + 2] = L, H[Y + 3] = ee, H[Y + 4] = me, H[Y + 5] = $, H[Y + 6] = Q + (J - Q) * k, H[Y + 7] = J, se[ie] = 0, se[ie + 1] = 0, se[ie + 2] = 0, se[ie + 3] = 0, ne[ie] = de, ne[ie + 1] = N, ne[ie + 2] = L, ne[ie + 3] = 0, u++;
5596
5619
  }
5597
5620
  else
5598
- for (let A = 0; A < L && !(f + 42 > Ye.length); A++) {
5599
- const X = A / L, fe = (A + 1) / L, Y = He[A], k = We[A], j = $e[A], se = He[A + 1], Je = We[A + 1], Ke = $e[A + 1], Qe = ve * (1 - X), Pe = ve * (1 - fe), nt = de * (1 - X) * (1 - X), Fe = de * (1 - fe) * (1 - fe), Ge = Y + Re * Qe, et = k + Te * Qe, ei = j + Ae * Qe, Ei = Y - Re * Qe, Ci = k - Te * Qe, Ui = j - Ae * Qe, Ii = se + Re * Pe, zi = Je + Te * Pe, Fi = Ke + Ae * Pe, Ds = se - Re * Pe, Vs = Je - Te * Pe, Os = Ke - Ae * Pe, bt = (Ls, ks, Xs, Ns) => {
5600
- Ye[f++] = Ls, Ye[f++] = ks, Ye[f++] = Xs, Ye[f++] = te, Ye[f++] = ye, Ye[f++] = J, Ye[f++] = Ns;
5621
+ for (let A = 0; A < O && !(f + 42 > Ye.length); A++) {
5622
+ const k = A / O, de = (A + 1) / O, N = Ze[A], L = We[A], Y = $e[A], ie = Ze[A + 1], Je = We[A + 1], Ke = $e[A + 1], Qe = ve * (1 - k), Pe = ve * (1 - de), nt = ue * (1 - k) * (1 - k), De = ue * (1 - de) * (1 - de), Fe = N + Be * Qe, et = L + Te * Qe, ei = Y + Ee * Qe, Ai = N - Be * Qe, Ci = L - Te * Qe, Ui = Y - Ee * Qe, Ii = ie + Be * Pe, zi = Je + Te * Pe, Di = Ke + Ee * Pe, Os = ie - Be * Pe, Ls = Je - Te * Pe, ks = Ke - Ee * Pe, bt = (Xs, Ns, Ys, js) => {
5623
+ Ye[f++] = Xs, Ye[f++] = Ns, Ye[f++] = Ys, Ye[f++] = ee, Ye[f++] = me, Ye[f++] = $, Ye[f++] = js;
5601
5624
  };
5602
- bt(Ge, et, ei, nt), bt(Ei, Ci, Ui, nt), bt(Ii, zi, Fi, Fe), bt(Ei, Ci, Ui, nt), bt(Ds, Vs, Os, Fe), bt(Ii, zi, Fi, Fe);
5625
+ bt(Fe, et, ei, nt), bt(Ai, Ci, Ui, nt), bt(Ii, zi, Di, De), bt(Ai, Ci, Ui, nt), bt(Os, Ls, ks, De), bt(Ii, zi, Di, De);
5603
5626
  }
5604
5627
  }
5605
- B && u > h && xt.set(y.id, { first: h, count: u - h });
5628
+ B && u > m && xt.set(g.id, { first: m, count: u - m });
5606
5629
  }
5607
5630
  }
5608
- const R = m;
5609
- m = os(m, g, y), m > R && Xe.set(y.id, { first: R / 9, count: (m - R) / 9 });
5631
+ const w = y;
5632
+ y = cs(y, p, g), y > w && at.set(g.id, { first: w / 9, count: (y - w) / 9 });
5610
5633
  }
5611
- u > 0 && (r.queue.writeBuffer(ne, 0, H, 0, u * 8), r.queue.writeBuffer(q, 0, re, 0, u * 4), r.queue.writeBuffer(tt, 0, ae, 0, u * 4)), vt = f / 7, vt > 0 && r.queue.writeBuffer(qt, 0, Ye, 0, f), bi = m / 9, bi > 0 && r.queue.writeBuffer(Zt, 0, Ce, 0, m);
5634
+ u > 0 && (r.queue.writeBuffer(re, 0, H, 0, u * 8), r.queue.writeBuffer(j, 0, se, 0, u * 4), r.queue.writeBuffer(tt, 0, ne, 0, u * 4)), vt = f / 7, vt > 0 && r.queue.writeBuffer(qt, 0, Ye, 0, f), bi = y / 9, bi > 0 && r.queue.writeBuffer(Ht, 0, Ce, 0, y);
5612
5635
  }
5613
5636
  const ci = () => {
5614
- r.queue.writeBuffer(I, 0, new Float32Array([1, 0, a.width, a.height, 0, 0, 0, 0])), r.queue.writeBuffer(z, 0, new Float32Array([0, 1, a.width, a.height, 0, 0, 0, 0]));
5637
+ const [u, f] = Ji(a.width, a.height);
5638
+ r.queue.writeBuffer(z, 0, new Float32Array([1, 0, u, f, 0, 0, 0, 0])), r.queue.writeBuffer(D, 0, new Float32Array([0, 1, u, f, 0, 0, 0, 0]));
5615
5639
  };
5616
5640
  ci();
5617
5641
  const ui = new Float32Array(16).fill(0);
5618
5642
  ui[0] = 1, r.queue.writeBuffer(_, 0, ui);
5619
- const De = Cr(r), Ne = Ar(r), {
5620
- particlePipeline: us,
5621
- particleAdditivePipeline: ds,
5622
- particleDepthWritePipeline: fs,
5643
+ const Ge = Ir(r), Ne = Cr(r), {
5644
+ particlePipeline: fs,
5645
+ particleAdditivePipeline: ps,
5646
+ particleDepthWritePipeline: hs,
5623
5647
  blurPipeline: It,
5624
- compositePipeline: ps,
5648
+ compositePipeline: ms,
5625
5649
  directRenderPipeline: di,
5626
- finalCompositePipeline: hs,
5627
- glbMeshPipeline: ms
5628
- } = Er(r, c, Ne), fi = r.createShaderModule({ code: `
5650
+ finalCompositePipeline: ys,
5651
+ glbMeshPipeline: gs
5652
+ } = Ur(r, l, Ne), fi = r.createShaderModule({ code: `
5629
5653
  struct U { mvp: mat4x4<f32> };
5630
5654
  @group(0) @binding(0) var<uniform> u: U;
5631
5655
  struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
@@ -5634,7 +5658,7 @@ async function Wr(s, t = {}) {
5634
5658
  @fragment fn fs(i: VOut) -> @location(0) vec4<f32> { return i.col; }
5635
5659
  ` }), pi = r.createBindGroupLayout({
5636
5660
  entries: [{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } }]
5637
- }), ys = r.createRenderPipeline({
5661
+ }), bs = r.createRenderPipeline({
5638
5662
  layout: r.createPipelineLayout({ bindGroupLayouts: [pi] }),
5639
5663
  vertex: {
5640
5664
  module: fi,
@@ -5661,7 +5685,7 @@ async function Wr(s, t = {}) {
5661
5685
  size: hi * 7 * 4,
5662
5686
  usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
5663
5687
  label: "ribbonBuffer"
5664
- }), gs = r.createBindGroup({
5688
+ }), Ss = r.createBindGroup({
5665
5689
  layout: pi,
5666
5690
  entries: [{ binding: 0, resource: { buffer: v } }]
5667
5691
  });
@@ -5744,8 +5768,20 @@ async function Wr(s, t = {}) {
5744
5768
  @location(3) noiseOffset: vec2<f32>,
5745
5769
  };
5746
5770
 
5771
+ // Hachage SANS TRANSCENDANTAL (Dave Hoskins) — jumeau de celui de modules/shaders.js.
5772
+ //
5773
+ // ⚠️ IL Y EN A DEUX EXEMPLAIRES DANS CETTE BIBLIOTHÈQUE, et je ne m'en suis aperçu qu'en cherchant
5774
+ // pourquoi le premier correctif ne changeait rien au bundle : ce shader-ci est INLINE dans
5775
+ // l'overlay, l'autre vit dans modules/shaders.js. Corriger un seul laisse le defaut entier sur le
5776
+ // chemin qui sert reellement au jeu. Toute modification de l'un doit etre portee a l'autre.
5777
+ //
5778
+ // Le fract(sin(dot(...))) remplace coutait HUIT sin par pixel couvert (2 valueNoise x 4 hash21).
5779
+ // Mesure sur la map du proprietaire : ~19 ecrans pleins de recouvrement, soit ~150 sin par pixel
5780
+ // d'ecran et par image. Il rapportait que ca ramait, et eteindre le bruit supprimait le probleme.
5747
5781
  fn hash21(p: vec2<f32>) -> f32 {
5748
- return fract(sin(dot(p, vec2<f32>(127.1, 311.7))) * 43758.5453);
5782
+ var p3 = fract(vec3<f32>(p.x, p.y, p.x) * 0.1031);
5783
+ p3 = p3 + dot(p3, vec3<f32>(p3.y, p3.z, p3.x) + 33.33);
5784
+ return fract((p3.x + p3.y) * p3.z);
5749
5785
  }
5750
5786
 
5751
5787
  fn valueNoise(p: vec2<f32>) -> f32 {
@@ -5813,26 +5849,26 @@ async function Wr(s, t = {}) {
5813
5849
  },
5814
5850
  primitive: { topology: "triangle-list" },
5815
5851
  depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
5816
- }), bs = yi({
5852
+ }), xs = yi({
5817
5853
  color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
5818
5854
  alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
5819
- }), Ss = yi({
5855
+ }), vs = yi({
5820
5856
  color: { srcFactor: "src-alpha", dstFactor: "one", operation: "add" },
5821
5857
  alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
5822
- }), gi = 256 * 256 * 6, Ce = new Float32Array(gi * 9), Zt = r.createBuffer({
5858
+ }), gi = 256 * 256 * 6, Ce = new Float32Array(gi * 9), Ht = r.createBuffer({
5823
5859
  size: gi * 9 * 4,
5824
5860
  usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
5825
5861
  label: "shapeStrokeBuffer"
5826
5862
  });
5827
- let bi = 0, { sceneTexture: at, bloomTexA: ot, bloomTexB: lt } = Xi(r, c, a.width, a.height), zt = Ni(r, a.width, a.height), ht, Si, Ft, Pt;
5863
+ let bi = 0, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct } = Ni(r, l, a.width, a.height), zt = Yi(r, a.width, a.height), ht, Si, Dt, Pt;
5828
5864
  const xi = () => {
5829
5865
  const u = (f) => f.createView();
5830
- ht = u(at), Si = u(ot), Ft = u(lt), Pt = u(zt);
5866
+ ht = u(ot), Si = u(lt), Dt = u(ct), Pt = u(zt);
5831
5867
  };
5832
5868
  xi();
5833
- const Ht = { uniformBuffer: v, appearanceUniformBuffer: E, horizontalBlurUniformBuffer: I, verticalBlurUniformBuffer: z, bloomIntensityBuffer: _ };
5834
- let Gt = si(r, De, Ht, { sceneTexture: at, bloomTexA: ot, bloomTexB: lt });
5835
- const D = {
5869
+ const Zt = { uniformBuffer: v, appearanceUniformBuffer: C, horizontalBlurUniformBuffer: z, verticalBlurUniformBuffer: D, bloomIntensityBuffer: _ };
5870
+ let Ft = si(r, Ge, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct });
5871
+ const V = {
5836
5872
  mvp: new Float32Array(16),
5837
5873
  position: new Float32Array([0, 0, 10]),
5838
5874
  right: new Float32Array([1, 0, 0]),
@@ -5840,189 +5876,195 @@ async function Wr(s, t = {}) {
5840
5876
  up: new Float32Array([0, 1, 0]),
5841
5877
  hasCamera: !1
5842
5878
  };
5843
- let Ve = 0, xs = 0;
5844
- const mt = new Float32Array(5), vi = new Float32Array(16), vs = new Array(65), Ps = new Array(65), _s = new Array(65), Ms = new Array(65), ws = new Array(65), Bs = new Array(65), Pi = [0, 0, 0], yt = { key: null, ms: !1, bindGroup: null };
5845
- let _i = !1, Wt = !0, Dt = !1, Vt = null, $t = a.width, Jt = a.height;
5879
+ let Ve = 0, Ps = 0;
5880
+ const mt = new Float32Array(5), vi = new Float32Array(16), _s = new Array(65), Ms = new Array(65), ws = new Array(65), Rs = new Array(65), Bs = new Array(65), Ts = new Array(65), Pi = [0, 0, 0], yt = { key: null, ms: !1, bindGroup: null };
5881
+ let _i = !1, Wt = !0, Gt = !1, Vt = null, $t = a.width, Jt = a.height;
5846
5882
  function Mi() {
5847
- const u = [at, ot, lt, zt], f = Xi(r, c, a.width, a.height);
5848
- at = f.sceneTexture, ot = f.bloomTexA, lt = f.bloomTexB, zt = Ni(r, a.width, a.height), xi(), ci(), p.clear(), b.resizeTextures(), Gt = si(r, De, Ht, { sceneTexture: at, bloomTexA: ot, bloomTexB: lt });
5849
- let m = !1;
5850
- const g = () => {
5851
- if (!m) {
5852
- m = !0, requestAnimationFrame(g);
5883
+ const u = [ot, lt, ct, zt], f = Ni(r, l, a.width, a.height);
5884
+ ot = f.sceneTexture, lt = f.bloomTexA, ct = f.bloomTexB, zt = Yi(r, a.width, a.height), xi(), ci(), h.clear(), b.resizeTextures(), Ft = si(r, Ge, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct });
5885
+ let y = !1;
5886
+ const p = () => {
5887
+ if (!y) {
5888
+ y = !0, requestAnimationFrame(p);
5853
5889
  return;
5854
5890
  }
5855
- u.forEach((y) => y.destroy());
5891
+ u.forEach((g) => g.destroy());
5856
5892
  };
5857
- requestAnimationFrame(g);
5893
+ requestAnimationFrame(p);
5858
5894
  }
5859
- function Rs(u, f, m) {
5860
- D.mvp.set(Fr(u, f)), f && f.length >= 10 && (D.right[0] = f[0], D.right[1] = f[4], D.right[2] = f[8], D.up[0] = f[1], D.up[1] = f[5], D.up[2] = f[9]), m && (D.position[0] = m.x ?? m[0], D.position[1] = m.y ?? m[1], D.position[2] = m.z ?? m[2]), D.hasCamera = !0;
5895
+ function Es(u, f, y) {
5896
+ V.mvp.set(Gr(u, f)), f && f.length >= 10 && (V.right[0] = f[0], V.right[1] = f[4], V.right[2] = f[8], V.up[0] = f[1], V.up[1] = f[5], V.up[2] = f[9]), y && (V.position[0] = y.x ?? y[0], V.position[1] = y.y ?? y[1], V.position[2] = y.z ?? y[2]), V.hasCamera = !0;
5861
5897
  }
5862
- function Ts(u, f) {
5863
- D.mvp.set(u), f && (D.position[0] = f.x ?? f[0], D.position[1] = f.y ?? f[1], D.position[2] = f.z ?? f[2]), D.hasCamera = !0;
5898
+ function As(u, f) {
5899
+ V.mvp.set(u), f && (V.position[0] = f.x ?? f[0], V.position[1] = f.y ?? f[1], V.position[2] = f.z ?? f[2]), V.hasCamera = !0;
5864
5900
  }
5865
5901
  async function Kt(u) {
5866
- if (Dt) {
5902
+ if (Gt) {
5867
5903
  Vt = u;
5868
5904
  return;
5869
5905
  }
5870
- Dt = !0;
5906
+ Gt = !0;
5871
5907
  try {
5872
5908
  for (const f in T) delete T[f];
5873
- p.clear(), b.resizeTextures(), Gt = si(r, De, Ht, { sceneTexture: at, bloomTexA: ot, bloomTexB: lt }), await l.replaceSystems({ systems: [], activeSystemIndex: 0 });
5909
+ h.clear(), b.resizeTextures(), Ft = si(r, Ge, Zt, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct }), await c.replaceSystems({ systems: [], activeSystemIndex: 0 });
5874
5910
  for (const f of u)
5875
- await l.addSystems(f.preset, f.position || [0, 0, 0]);
5876
- for (const { config: f } of l.particleSystems)
5911
+ await c.addSystems(f.preset, f.position || [0, 0, 0]);
5912
+ for (const { config: f } of c.particleSystems)
5877
5913
  T[f.id] || (T[f.id] = F());
5878
- Wt = !0, l.respawnAllSystems();
5914
+ Wt = !0, c.respawnAllSystems();
5879
5915
  } finally {
5880
- if (Dt = !1, Vt) {
5916
+ if (Gt = !1, Vt) {
5881
5917
  const f = Vt;
5882
5918
  Vt = null, Kt(f);
5883
5919
  }
5884
5920
  }
5885
5921
  }
5886
- async function As(u, f = [0, 0, 0]) {
5922
+ async function Cs(u, f = [0, 0, 0]) {
5887
5923
  return Kt([{ preset: u, position: f }]);
5888
5924
  }
5889
- function Es(u) {
5890
- if (_i || Dt || !l.ready || u <= 0 || l.particleSystems.length === 0) return;
5891
- const f = l.clock;
5892
- if (f && (f.loop = l.loop ?? i, f.duration = l.getTotalDuration(), u = f.tick(u)), u > 0.1 && (u = 0.1), u <= 0) return;
5925
+ function Us(u) {
5926
+ if (_i || Gt || !c.ready || u <= 0 || c.particleSystems.length === 0) return;
5927
+ const f = c.clock;
5928
+ if (f && (f.loop = c.loop ?? i, f.duration = c.getTotalDuration(), u = f.tick(u)), u > 0.1 && (u = 0.1), u <= 0) return;
5893
5929
  if ((a.width !== $t || a.height !== Jt) && ($t = a.width, Jt = a.height, Mi()), Ve += u, _e.length) {
5894
- for (const h of _e) {
5895
- if (h.getPosition) {
5896
- const w = h.getPosition();
5897
- w ? (h.pos || (h.pos = h._posBuf), Array.isArray(w) ? (h.pos[0] = w[0], h.pos[1] = w[1], h.pos[2] = w[2]) : (h.pos[0] = w.x, h.pos[1] = w.y, h.pos[2] = w.z)) : h.pos = null;
5930
+ for (const m of _e) {
5931
+ if (m.getPosition) {
5932
+ const M = m.getPosition();
5933
+ M ? (m.pos || (m.pos = m._posBuf), Array.isArray(M) ? (m.pos[0] = M[0], m.pos[1] = M[1], m.pos[2] = M[2]) : (m.pos[0] = M.x, m.pos[1] = M.y, m.pos[2] = M.z)) : m.pos = null;
5898
5934
  }
5899
- h.vel = h._velBuf, h.pos && h.prevPos && h.wasActive && u > 0 ? (h.vel[0] = (h.pos[0] - h.prevPos[0]) / u, h.vel[1] = (h.pos[1] - h.prevPos[1]) / u, h.vel[2] = (h.pos[2] - h.prevPos[2]) / u) : (h.vel[0] = 0, h.vel[1] = 0, h.vel[2] = 0), h.justResumed = !!h.pos && !h.wasActive, h.justResumed && (h.hist.length = 0);
5935
+ m.vel = m._velBuf, m.pos && m.prevPos && m.wasActive && u > 0 ? (m.vel[0] = (m.pos[0] - m.prevPos[0]) / u, m.vel[1] = (m.pos[1] - m.prevPos[1]) / u, m.vel[2] = (m.pos[2] - m.prevPos[2]) / u) : (m.vel[0] = 0, m.vel[1] = 0, m.vel[2] = 0), m.justResumed = !!m.pos && !m.wasActive, m.justResumed && (m.hist.length = 0);
5900
5936
  }
5901
- for (const { system: h, config: w } of l.particleSystems) {
5902
- const C = oi(w.id);
5903
- if (!(!C || C.historyOnly) && (w.hidden = !C.pos, C.pos)) {
5904
- let Z = null;
5905
- if (C.orientToDirection && C.vel) {
5906
- const O = C.vel[0], L = C.vel[2];
5907
- Math.hypot(O, L) > 1e-4 && (Z = [0, 0, Math.atan2(O, L)]);
5937
+ for (const { system: m, config: M } of c.particleSystems) {
5938
+ const E = oi(M.id);
5939
+ if (!(!E || E.historyOnly) && (M.hidden = !E.pos, E.pos)) {
5940
+ let q = null;
5941
+ if (E.orientToDirection && E.vel) {
5942
+ const X = E.vel[0], O = E.vel[2];
5943
+ Math.hypot(X, O) > 1e-4 && (q = [0, 0, Math.atan2(X, O)]);
5908
5944
  }
5909
- h.setSimulationTransform({ position: C.pos, velocity: C.vel, rotation: Z }), h.updateAppearanceUniform(), (C.justResumed || h.activeParticles === 0) && h.spawnParticles();
5945
+ m.setSimulationTransform({ position: E.pos, velocity: E.vel, rotation: q }), m.updateAppearanceUniform(), (E.justResumed || m.activeParticles === 0) && m.spawnParticles();
5910
5946
  }
5911
5947
  }
5912
- for (const h of _e)
5913
- h.pos ? is(h, Ve) : h.hist.length = 0, h.pos ? (h._prevPosBuf[0] = h.pos[0], h._prevPosBuf[1] = h.pos[1], h._prevPosBuf[2] = h.pos[2], h.prevPos = h._prevPosBuf) : h.prevPos = null, h.wasActive = !!h.pos;
5914
- if (globalThis.__HZFX_DEBUG && (xs++ & 63) === 0) {
5915
- const h = l.particleSystems.reduce((O, L) => O + (L.system.activeParticles | 0), 0), w = _e.find((O) => O.pos), C = w ? Math.hypot(D.position[0] - w.pos[0], D.position[1] - w.pos[1], D.position[2] - w.pos[2]).toFixed(1) : "-", Z = _e.map((O) => `{ids:[${[...O.ids]}],pos:${O.pos ? "1" : "0"},hist:${O.hist.length}}`).join(",");
5916
- console.info(`[HZFX] movingGroups(${_e.length})=[${Z}] activeParticles=${h} systems=${l.particleSystems.length} ribbonVerts=${vt} camDist=${C} t=${Ve.toFixed(1)}`);
5948
+ for (const m of _e)
5949
+ m.pos ? rs(m, Ve) : m.hist.length = 0, m.pos ? (m._prevPosBuf[0] = m.pos[0], m._prevPosBuf[1] = m.pos[1], m._prevPosBuf[2] = m.pos[2], m.prevPos = m._prevPosBuf) : m.prevPos = null, m.wasActive = !!m.pos;
5950
+ if (globalThis.__HZFX_DEBUG && (Ps++ & 63) === 0) {
5951
+ const m = c.particleSystems.reduce((X, O) => X + (O.system.activeParticles | 0), 0), M = _e.find((X) => X.pos), E = M ? Math.hypot(V.position[0] - M.pos[0], V.position[1] - M.pos[1], V.position[2] - M.pos[2]).toFixed(1) : "-", q = _e.map((X) => `{ids:[${[...X.ids]}],pos:${X.pos ? "1" : "0"},hist:${X.hist.length}}`).join(",");
5952
+ console.info(`[HZFX] movingGroups(${_e.length})=[${q}] activeParticles=${m} systems=${c.particleSystems.length} ribbonVerts=${vt} camDist=${E} t=${Ve.toFixed(1)}`);
5917
5953
  }
5918
5954
  }
5919
- if (l.updateAllSystems(u), f ? f.loop : l.loop ?? i) {
5920
- const h = l.particleSystems.length > 0 && l.particleSystems.every(({ system: w }) => w.activeParticles === 0 && !w.emitting);
5921
- (f && f.justLooped || h && Wt) && l.respawnAllSystems(), Wt = !h;
5955
+ if (c.updateAllSystems(u), f ? f.loop : c.loop ?? i) {
5956
+ const m = c.particleSystems.length > 0 && c.particleSystems.every(({ system: M }) => M.activeParticles === 0 && !M.emitting);
5957
+ (f && f.justLooped || m && Wt) && c.respawnAllSystems(), Wt = !m;
5922
5958
  }
5923
- for (const { system: h, config: w } of l.particleSystems)
5924
- w.glbModelEnabled && h.glbAnimator && (h.glbAnimator.update(u), h.updateAnimatedGLBBuffer());
5925
- r.queue.writeBuffer(v, 0, D.mvp), mt[0] = D.position[0], mt[1] = D.position[1], mt[2] = D.position[2], mt[3] = a.height / Math.max(1, a.width), mt[4] = Ve, r.queue.writeBuffer(v, 64, mt), cs();
5926
- const g = l.particleSystems.some(
5927
- ({ system: h, config: w }) => w.bloomEnabled && !w.hidden && (h.activeParticles > 0 || Xe.has(w.id))
5928
- ), y = r.createCommandEncoder();
5929
- let R = !1;
5959
+ for (const { system: m, config: M } of c.particleSystems)
5960
+ M.glbModelEnabled && m.glbAnimator && (m.glbAnimator.update(u), m.updateAnimatedGLBBuffer());
5961
+ r.queue.writeBuffer(v, 0, V.mvp), mt[0] = V.position[0], mt[1] = V.position[1], mt[2] = V.position[2], mt[3] = a.height / Math.max(1, a.width), mt[4] = Ve, r.queue.writeBuffer(v, 64, mt), ds();
5962
+ const p = r.createCommandEncoder();
5963
+ let g = !1;
5930
5964
  if (e)
5931
5965
  try {
5932
- const h = e();
5933
- if (h) {
5934
- let w = null, C = null, Z = !1;
5935
- if (h instanceof GPUTexture ? h.width === a.width && h.height === a.height && (w = h, C = () => h.createView({ aspect: "depth-only" }), Z = h.sampleCount > 1) : h.view && (w = h.view, C = () => h.view, Z = !!h.multisampled), w) {
5936
- const { pipeline: O, layout: L } = S(Z);
5937
- (yt.key !== w || yt.ms !== Z) && (yt.key = w, yt.ms = Z, yt.bindGroup = r.createBindGroup({
5938
- layout: L,
5939
- entries: [{ binding: 0, resource: C() }]
5966
+ const m = e();
5967
+ if (m) {
5968
+ let M = null, E = null, q = !1;
5969
+ if (m instanceof GPUTexture ? m.width === a.width && m.height === a.height && (M = m, E = () => m.createView({ aspect: "depth-only" }), q = m.sampleCount > 1) : m.view && (M = m.view, E = () => m.view, q = !!m.multisampled), M) {
5970
+ const { pipeline: X, layout: O } = S(q);
5971
+ (yt.key !== M || yt.ms !== q) && (yt.key = M, yt.ms = q, yt.bindGroup = r.createBindGroup({
5972
+ layout: O,
5973
+ entries: [{ binding: 0, resource: E() }]
5940
5974
  }));
5941
- const N = y.beginRenderPass({
5975
+ const U = p.beginRenderPass({
5942
5976
  colorAttachments: [],
5943
5977
  depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5944
5978
  });
5945
- N.setPipeline(O), N.setBindGroup(0, yt.bindGroup), N.draw(3), N.end(), R = !0;
5979
+ U.setPipeline(X), U.setBindGroup(0, yt.bindGroup), U.draw(3), U.end(), g = !0;
5946
5980
  }
5947
5981
  }
5948
5982
  } catch {
5949
5983
  }
5950
- const P = y.beginRenderPass({
5984
+ const w = p.beginRenderPass({
5951
5985
  colorAttachments: [{ view: ht, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
5952
- depthStencilAttachment: R ? { view: Pt, depthLoadOp: "load", depthStoreOp: "store" } : { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5986
+ depthStencilAttachment: g ? { view: Pt, depthLoadOp: "load", depthStoreOp: "store" } : { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5953
5987
  });
5954
- for (const { system: h, config: w } of l.particleSystems)
5955
- w.bloomEnabled || w.hidden || h.activeParticles === 0 && !Xe.has(w.id) || (Bi(P, h, w), Ri(P, h, w));
5956
- if (vt > 0 && (P.setPipeline(ys), P.setBindGroup(0, gs), P.setVertexBuffer(0, qt), P.draw(vt)), P.end(), g) {
5957
- const h = {
5988
+ for (const { system: m, config: M } of c.particleSystems)
5989
+ M.bloomEnabled || M.hidden || m.activeParticles === 0 && !at.has(M.id) || (Ri(w, m, M), Bi(w, m, M));
5990
+ vt > 0 && (w.setPipeline(bs), w.setBindGroup(0, Ss), w.setVertexBuffer(0, qt), w.draw(vt)), w.end();
5991
+ const P = /* @__PURE__ */ new Map();
5992
+ for (const { system: m, config: M } of c.particleSystems) {
5993
+ if (!M.bloomEnabled || M.hidden || m.activeParticles === 0 && !at.has(M.id)) continue;
5994
+ const E = M.bloomColor || [1, 1, 1], q = `b${M.bloomIntensity ?? 1}|${E[0]}|${E[1]}|${E[2]}`, X = P.get(q);
5995
+ X ? X.membres.push({ system: m, config: M }) : P.set(q, { membres: [{ system: m, config: M }], premier: m });
5996
+ }
5997
+ if (P.size > 0) {
5998
+ const m = {
5958
5999
  colorAttachments: [{ view: Si, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5959
- }, w = {
5960
- colorAttachments: [{ view: Ft, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
6000
+ }, M = {
6001
+ colorAttachments: [{ view: Dt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5961
6002
  };
5962
- for (const { system: C, config: Z } of l.particleSystems) {
5963
- if (!Z.bloomEnabled || Z.hidden || C.activeParticles === 0 && !Xe.has(Z.id)) continue;
5964
- const O = C.config.id, L = b.getBloomSourceTexture(O, a.width, a.height), N = y.beginRenderPass({
5965
- colorAttachments: [{ view: L.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
6003
+ for (const [E, q] of P) {
6004
+ const X = b.getBloomSourceTexture(E, a.width, a.height), O = p.beginRenderPass({
6005
+ colorAttachments: [{ view: X.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
5966
6006
  depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
5967
6007
  });
5968
- Bi(N, C, Z), Ri(N, C, Z), N.end(), vi[0] = Z.bloomIntensity, r.queue.writeBuffer(_, 0, vi), p.systemBloomHorizontalBindGroups[O] || (p.systemBloomHorizontalBindGroups[O] = r.createBindGroup({
6008
+ for (const { system: Se, config: Oe } of q.membres)
6009
+ Ri(O, Se, Oe), Bi(O, Se, Oe);
6010
+ O.end(), vi[0] = q.membres[0].config.bloomIntensity, r.queue.writeBuffer(_, 0, vi), h.systemBloomHorizontalBindGroups[E] || (h.systemBloomHorizontalBindGroups[E] = r.createBindGroup({
5969
6011
  layout: Ne.bloomBindGroupLayout,
5970
6012
  entries: [
5971
- { binding: 0, resource: De },
5972
- { binding: 1, resource: L.createView() },
5973
- { binding: 2, resource: { buffer: I } }
6013
+ { binding: 0, resource: Ge },
6014
+ { binding: 1, resource: X.createView() },
6015
+ { binding: 2, resource: { buffer: z } }
5974
6016
  ]
5975
6017
  }));
5976
- let V = y.beginRenderPass(h);
5977
- V.setPipeline(It), V.setBindGroup(0, p.systemBloomHorizontalBindGroups[O]), V.draw(3), V.end(), V = y.beginRenderPass(w), V.setPipeline(It), V.setBindGroup(0, Gt.verticalBlurBindGroup), V.draw(3), V.end(), p.secondHorizontalBindGroups[O] || (p.secondHorizontalBindGroups[O] = r.createBindGroup({
6018
+ let U = p.beginRenderPass(m);
6019
+ U.setPipeline(It), U.setBindGroup(0, h.systemBloomHorizontalBindGroups[E]), U.draw(3), U.end(), U = p.beginRenderPass(M), U.setPipeline(It), U.setBindGroup(0, Ft.verticalBlurBindGroup), U.draw(3), U.end(), h.secondHorizontalBindGroups[E] || (h.secondHorizontalBindGroups[E] = r.createBindGroup({
5978
6020
  layout: Ne.bloomBindGroupLayout,
5979
6021
  entries: [
5980
- { binding: 0, resource: De },
5981
- { binding: 1, resource: Ft },
5982
- { binding: 2, resource: { buffer: I } }
6022
+ { binding: 0, resource: Ge },
6023
+ { binding: 1, resource: Dt },
6024
+ { binding: 2, resource: { buffer: z } }
5983
6025
  ]
5984
- })), V = y.beginRenderPass(h), V.setPipeline(It), V.setBindGroup(0, p.secondHorizontalBindGroups[O]), V.draw(3), V.end(), V = y.beginRenderPass(w), V.setPipeline(It), V.setBindGroup(0, Gt.verticalBlurBindGroup), V.draw(3), V.end();
5985
- const xe = b.getBloomCompositeTexture(O, a.width, a.height);
5986
- V = y.beginRenderPass({
5987
- colorAttachments: [{ view: xe.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5988
- }), V.setPipeline(ps), p.systemBloomCompositeBindGroups[O] || (p.systemBloomCompositeBindGroups[O] = r.createBindGroup({
6026
+ })), U = p.beginRenderPass(m), U.setPipeline(It), U.setBindGroup(0, h.secondHorizontalBindGroups[E]), U.draw(3), U.end(), U = p.beginRenderPass(M), U.setPipeline(It), U.setBindGroup(0, Ft.verticalBlurBindGroup), U.draw(3), U.end();
6027
+ const be = b.getBloomCompositeTexture(E, a.width, a.height);
6028
+ U = p.beginRenderPass({
6029
+ colorAttachments: [{ view: be.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
6030
+ }), U.setPipeline(ms), h.systemBloomCompositeBindGroups[E] || (h.systemBloomCompositeBindGroups[E] = r.createBindGroup({
5989
6031
  layout: Ne.compositeBindGroupLayout,
5990
6032
  entries: [
5991
- { binding: 0, resource: De },
5992
- { binding: 1, resource: L.createView() },
5993
- { binding: 2, resource: Ft },
5994
- { binding: 3, resource: { buffer: C.bloomIntensityBuffer } }
6033
+ { binding: 0, resource: Ge },
6034
+ { binding: 1, resource: X.createView() },
6035
+ { binding: 2, resource: Dt },
6036
+ // ⚠️ L'uniforme du PREMIER membre : la clé de groupe garantit que tous portent la même
6037
+ // intensité et la même couleur, donc n'importe lequel convient — mais il en faut un VRAI,
6038
+ // écrit par `particleSystem`, pas le tampon partagé qui ne porte que l'intensité.
6039
+ { binding: 3, resource: { buffer: q.premier.bloomIntensityBuffer } }
5995
6040
  ]
5996
- })), V.setBindGroup(0, p.systemBloomCompositeBindGroups[O]), V.draw(3), V.end();
6041
+ })), U.setBindGroup(0, h.systemBloomCompositeBindGroups[E]), U.draw(3), U.end();
5997
6042
  }
5998
6043
  }
5999
- const M = b.getCombinedTexture(a.width, a.height), x = y.beginRenderPass({
6000
- colorAttachments: [{ view: M.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
6044
+ const R = b.getCombinedTexture(a.width, a.height), x = p.beginRenderPass({
6045
+ colorAttachments: [{ view: R.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
6001
6046
  });
6002
- x.setPipeline(di), p.combinedInitialBindGroup || (p.combinedInitialBindGroup = r.createBindGroup({
6047
+ x.setPipeline(di), h.combinedInitialBindGroup || (h.combinedInitialBindGroup = r.createBindGroup({
6003
6048
  layout: Ne.compositeBindGroupLayout,
6004
6049
  entries: [
6005
- { binding: 0, resource: De },
6050
+ { binding: 0, resource: Ge },
6006
6051
  { binding: 1, resource: ht },
6007
6052
  { binding: 2, resource: ht },
6008
6053
  { binding: 3, resource: { buffer: _ } }
6009
6054
  ]
6010
- })), x.setBindGroup(0, p.combinedInitialBindGroup), x.draw(3);
6011
- for (const { config: h, system: w } of l.particleSystems) {
6012
- if (!h.bloomEnabled || h.hidden || w.activeParticles === 0 && !Xe.has(h.id)) continue;
6013
- const C = w.config.id;
6014
- x.setPipeline(di), p.combinedBloomCompositeBindGroups[C] || (p.combinedBloomCompositeBindGroups[C] = r.createBindGroup({
6055
+ })), x.setBindGroup(0, h.combinedInitialBindGroup), x.draw(3);
6056
+ for (const m of P.keys())
6057
+ x.setPipeline(di), h.combinedBloomCompositeBindGroups[m] || (h.combinedBloomCompositeBindGroups[m] = r.createBindGroup({
6015
6058
  layout: Ne.compositeBindGroupLayout,
6016
6059
  entries: [
6017
- { binding: 0, resource: De },
6018
- { binding: 1, resource: b.getBloomCompositeTexture(C, a.width, a.height).createView() },
6060
+ { binding: 0, resource: Ge },
6061
+ { binding: 1, resource: b.getBloomCompositeTexture(m, a.width, a.height).createView() },
6019
6062
  { binding: 2, resource: ht },
6020
6063
  { binding: 3, resource: { buffer: _ } }
6021
6064
  ]
6022
- })), x.setBindGroup(0, p.combinedBloomCompositeBindGroups[C]), x.draw(3);
6023
- }
6065
+ })), x.setBindGroup(0, h.combinedBloomCompositeBindGroups[m]), x.draw(3);
6024
6066
  x.end();
6025
- const B = y.beginRenderPass({
6067
+ const B = p.beginRenderPass({
6026
6068
  colorAttachments: [{
6027
6069
  view: n.getCurrentTexture().createView(),
6028
6070
  loadOp: o ? "load" : "clear",
@@ -6030,151 +6072,151 @@ async function Wr(s, t = {}) {
6030
6072
  clearValue: { r: 0, g: 0, b: 0, a: 0 }
6031
6073
  }]
6032
6074
  });
6033
- B.setPipeline(hs), p.finalBindGroup || (p.finalBindGroup = r.createBindGroup({
6075
+ B.setPipeline(ys), h.finalBindGroup || (h.finalBindGroup = r.createBindGroup({
6034
6076
  layout: Ne.compositeBindGroupLayout,
6035
6077
  entries: [
6036
- { binding: 0, resource: De },
6037
- { binding: 1, resource: M.createView() },
6078
+ { binding: 0, resource: Ge },
6079
+ { binding: 1, resource: R.createView() },
6038
6080
  { binding: 2, resource: ht },
6039
6081
  { binding: 3, resource: { buffer: _ } }
6040
6082
  ]
6041
- })), B.setBindGroup(0, p.finalBindGroup), B.draw(3), B.end(), r.queue.submit([y.finish()]);
6083
+ })), B.setBindGroup(0, h.finalBindGroup), B.draw(3), B.end(), r.queue.submit([p.finish()]);
6042
6084
  }
6043
6085
  function wi(u, f) {
6044
- const m = u.config.id, g = !p.systemBindGroups[m] || p.textureStates[m] !== f.textureEnabled || p.textureRefs[m] !== u.particleTexture;
6045
- return p.textureStates[m] = f.textureEnabled, p.textureRefs[m] = u.particleTexture, g && (p.systemBindGroups[m] = r.createBindGroup({
6086
+ const y = u.config.id, p = !h.systemBindGroups[y] || h.textureStates[y] !== f.textureEnabled || h.textureRefs[y] !== u.particleTexture;
6087
+ return h.textureStates[y] = f.textureEnabled, h.textureRefs[y] = u.particleTexture, p && (h.systemBindGroups[y] = r.createBindGroup({
6046
6088
  layout: Ne.particleBindGroupLayout,
6047
6089
  entries: [
6048
6090
  { binding: 0, resource: { buffer: v } },
6049
6091
  { binding: 1, resource: { buffer: u.appearanceUniformBuffer } },
6050
6092
  { binding: 2, resource: u.particleTexture.createView() },
6051
- { binding: 3, resource: De }
6093
+ { binding: 3, resource: Ge }
6052
6094
  ]
6053
- })), p.systemBindGroups[m];
6095
+ })), h.systemBindGroups[y];
6054
6096
  }
6055
- function Bi(u, f, m) {
6056
- const g = f.config.id, y = m.glbModelEnabled && f.glbMeshData, R = wi(f, m), P = m.shapeDisplay !== !1;
6057
- if (y)
6058
- P && (u.setPipeline(ms), u.setBindGroup(0, R), u.setVertexBuffer(0, f.glbVertexBuffer), u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setIndexBuffer(f.glbIndexBuffer, f.glbIndexFormat), u.drawIndexed(f.glbIndexCount, f.activeParticles));
6097
+ function Ri(u, f, y) {
6098
+ const p = f.config.id, g = y.glbModelEnabled && f.glbMeshData, w = wi(f, y), P = y.shapeDisplay !== !1;
6099
+ if (g)
6100
+ P && (u.setPipeline(gs), u.setBindGroup(0, w), u.setVertexBuffer(0, f.glbVertexBuffer), u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setIndexBuffer(f.glbIndexBuffer, f.glbIndexFormat), u.drawIndexed(f.glbIndexCount, f.activeParticles));
6059
6101
  else {
6060
- u.setPipeline(m.blendMode === "additive" ? ds : us), u.setIndexBuffer(W, "uint16"), T[g] || (T[g] = F()), u.setVertexBuffer(0, T[g]), u.setBindGroup(0, R), P && (u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setVertexBuffer(3, f.trailBuffer), u.drawIndexed(6, f.activeParticles));
6061
- const M = xt.get(g);
6062
- M && (u.setVertexBuffer(1, ne), u.setVertexBuffer(2, q), u.setVertexBuffer(3, tt), u.drawIndexed(6, M.count, 0, 0, M.first)), P && m.depthWriteEnabled && (u.setPipeline(fs), u.drawIndexed(6, f.activeParticles));
6102
+ u.setPipeline(y.blendMode === "additive" ? ps : fs), u.setIndexBuffer(Z, "uint16"), T[p] || (T[p] = F()), u.setVertexBuffer(0, T[p]), u.setBindGroup(0, w), P && (u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setVertexBuffer(3, f.trailBuffer), u.drawIndexed(6, f.activeParticles));
6103
+ const R = xt.get(p);
6104
+ R && (u.setVertexBuffer(1, re), u.setVertexBuffer(2, j), u.setVertexBuffer(3, tt), u.drawIndexed(6, R.count, 0, 0, R.first)), P && y.depthWriteEnabled && (u.setPipeline(hs), u.drawIndexed(6, f.activeParticles));
6063
6105
  }
6064
6106
  }
6065
- function Ri(u, f, m) {
6066
- const g = Xe.get(m.id);
6067
- !g || g.count <= 0 || (u.setPipeline(m.blendMode === "additive" ? Ss : bs), u.setBindGroup(0, wi(f, m)), u.setVertexBuffer(0, Zt), u.draw(g.count, 1, g.first, 0));
6107
+ function Bi(u, f, y) {
6108
+ const p = at.get(y.id);
6109
+ !p || p.count <= 0 || (u.setPipeline(y.blendMode === "additive" ? vs : xs), u.setBindGroup(0, wi(f, y)), u.setVertexBuffer(0, Ht), u.draw(p.count, 1, p.first, 0));
6068
6110
  }
6069
- function Cs() {
6111
+ function Is() {
6070
6112
  $t = a.width, Jt = a.height, Mi();
6071
6113
  }
6072
- function Us() {
6073
- p.clear();
6114
+ function zs() {
6115
+ h.clear();
6074
6116
  }
6075
- function Is() {
6076
- _i = !0, l.destroy(), [at, ot, lt, zt].forEach((u) => u == null ? void 0 : u.destroy()), b.resizeTextures(), [
6117
+ function Ds() {
6118
+ _i = !0, c.destroy(), [ot, lt, ct, zt].forEach((u) => u == null ? void 0 : u.destroy()), b.resizeTextures(), [
6077
6119
  v,
6078
- E,
6079
- I,
6120
+ C,
6080
6121
  z,
6122
+ D,
6081
6123
  _,
6082
- W,
6083
- ne,
6084
- q,
6124
+ Z,
6125
+ re,
6126
+ j,
6085
6127
  tt,
6086
6128
  qt,
6087
- Zt
6129
+ Ht
6088
6130
  ].forEach((u) => u == null ? void 0 : u.destroy()), Object.values(T).forEach((u) => u == null ? void 0 : u.destroy());
6089
6131
  }
6090
6132
  async function Ti(u, f) {
6091
- const m = await l.addSystems(u, f);
6092
- for (const { config: g } of l.particleSystems)
6093
- T[g.id] || (T[g.id] = F());
6094
- return l.respawnAllSystems(), new Set(Array.isArray(m) ? m : []);
6133
+ const y = await c.addSystems(u, f);
6134
+ for (const { config: p } of c.particleSystems)
6135
+ T[p.id] || (T[p.id] = F());
6136
+ return c.respawnAllSystems(), new Set(Array.isArray(y) ? y : []);
6095
6137
  }
6096
- function Ai(u) {
6138
+ function Ei(u) {
6097
6139
  for (const f of u) {
6098
- const m = l.particleSystems.findIndex((g) => g.config.id === f);
6099
- m >= 0 && l.removeSystem(m);
6140
+ const y = c.particleSystems.findIndex((p) => p.config.id === f);
6141
+ y >= 0 && c.removeSystem(y);
6100
6142
  }
6101
6143
  }
6102
- async function zs(u, f = [0, 0, 0]) {
6103
- const m = await Ti(u, f);
6144
+ async function Fs(u, f = [0, 0, 0]) {
6145
+ const y = await Ti(u, f);
6104
6146
  return { remove() {
6105
- Ai(m);
6147
+ Ei(y);
6106
6148
  } };
6107
6149
  }
6108
- async function Fs(u, f = {}) {
6109
- const m = await Ti(u, [0, 0, 0]);
6110
- globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...m]}]`);
6111
- const g = { ids: m, pos: null, hist: [], getPosition: f.getPosition || null, orientToDirection: !!f.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
6112
- return _e.push(g), {
6113
- setPosition(y) {
6114
- y && (g.pos = Array.isArray(y) ? [y[0], y[1], y[2]] : [y.x, y.y, y.z]);
6150
+ async function Gs(u, f = {}) {
6151
+ const y = await Ti(u, [0, 0, 0]);
6152
+ globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...y]}]`);
6153
+ const p = { ids: y, pos: null, hist: [], getPosition: f.getPosition || null, orientToDirection: !!f.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
6154
+ return _e.push(p), {
6155
+ setPosition(g) {
6156
+ g && (p.pos = Array.isArray(g) ? [g[0], g[1], g[2]] : [g.x, g.y, g.z]);
6115
6157
  },
6116
- setOrientToDirection(y) {
6117
- g.orientToDirection = !!y;
6158
+ setOrientToDirection(g) {
6159
+ p.orientToDirection = !!g;
6118
6160
  },
6119
6161
  remove() {
6120
- Ai(m);
6121
- const y = _e.indexOf(g);
6122
- y >= 0 && _e.splice(y, 1);
6162
+ Ei(y);
6163
+ const g = _e.indexOf(p);
6164
+ g >= 0 && _e.splice(g, 1);
6123
6165
  }
6124
6166
  };
6125
6167
  }
6126
- function Gs(u, f) {
6127
- const g = { ids: u instanceof Set ? u : new Set(u), pos: null, hist: [], getPosition: f, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
6128
- return _e.push(g), {
6168
+ function Vs(u, f) {
6169
+ const p = { ids: u instanceof Set ? u : new Set(u), pos: null, hist: [], getPosition: f, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
6170
+ return _e.push(p), {
6129
6171
  remove() {
6130
- const y = _e.indexOf(g);
6131
- y >= 0 && _e.splice(y, 1);
6172
+ const g = _e.indexOf(p);
6173
+ g >= 0 && _e.splice(g, 1);
6132
6174
  },
6133
6175
  // Update which systems this history group covers WITHOUT losing the accumulated path
6134
6176
  // history. Needed when the scene's systems change (e.g. duplicate/add/remove) while the
6135
6177
  // group is active — otherwise a newly-added system's id isn't in the set and its trail
6136
6178
  // can't follow the recorded movement path (it falls back to straight extrapolation).
6137
- setIds(y) {
6138
- g.ids = y instanceof Set ? y : new Set(y);
6179
+ setIds(g) {
6180
+ p.ids = g instanceof Set ? g : new Set(g);
6139
6181
  }
6140
6182
  };
6141
6183
  }
6142
6184
  return {
6143
- manager: l,
6185
+ manager: c,
6144
6186
  device: r,
6145
6187
  context: n,
6146
- setCamera: Rs,
6147
- setCameraMVP: Ts,
6188
+ setCamera: Es,
6189
+ setCameraMVP: As,
6148
6190
  setEmitters: Kt,
6149
- loadPreset: As,
6150
- addEmitter: zs,
6151
- addMovingEmitter: Fs,
6152
- render: Es,
6153
- resize: Cs,
6154
- clearCaches: Us,
6155
- trackHistoryGroup: Gs,
6156
- destroy: Is
6191
+ loadPreset: Cs,
6192
+ addEmitter: Fs,
6193
+ addMovingEmitter: Gs,
6194
+ render: Us,
6195
+ resize: Is,
6196
+ clearCaches: zs,
6197
+ trackHistoryGroup: Vs,
6198
+ destroy: Ds
6157
6199
  };
6158
6200
  }
6159
- function $r(s) {
6201
+ function Kr(s) {
6160
6202
  return () => {
6161
- var t, e, i, r, n, a, o, c;
6203
+ var t, e, i, r, n, a, o, l;
6162
6204
  try {
6163
- const l = s.backend;
6164
- if (!l) return null;
6205
+ const c = s.backend;
6206
+ if (!c) return null;
6165
6207
  const d = s.domElement.width, S = s.domElement.height, b = (typeof s._getFrameBufferTarget == "function" ? s._getFrameBufferTarget() : null) || s._frameBufferTarget || null;
6166
6208
  if (s.needsFrameBufferTarget && b) {
6167
- const E = l.get(b), I = ((i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, b)) == null ? void 0 : i.depthTexture) || b.depthTexture, z = [
6168
- (r = E == null ? void 0 : E.depthTexture) == null ? void 0 : r.texture,
6169
- E == null ? void 0 : E.depthTexture,
6170
- (n = E == null ? void 0 : E.depthBuffer) == null ? void 0 : n.texture,
6171
- I ? (a = l.get(I)) == null ? void 0 : a.texture : null
6209
+ const C = c.get(b), z = ((i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, b)) == null ? void 0 : i.depthTexture) || b.depthTexture, D = [
6210
+ (r = C == null ? void 0 : C.depthTexture) == null ? void 0 : r.texture,
6211
+ C == null ? void 0 : C.depthTexture,
6212
+ (n = C == null ? void 0 : C.depthBuffer) == null ? void 0 : n.texture,
6213
+ z ? (a = c.get(z)) == null ? void 0 : a.texture : null
6172
6214
  ];
6173
- for (const _ of z)
6215
+ for (const _ of D)
6174
6216
  if (_ && typeof _.createView == "function" && _.width === d && _.height === S) return _;
6175
6217
  return null;
6176
6218
  }
6177
- const p = s.getCanvasTarget ? l.get(s.getCanvasTarget()) : null, v = ((c = (o = p == null ? void 0 : p.descriptor) == null ? void 0 : o.depthStencilAttachment) == null ? void 0 : c.view) ?? null;
6219
+ const h = s.getCanvasTarget ? c.get(s.getCanvasTarget()) : null, v = ((l = (o = h == null ? void 0 : h.descriptor) == null ? void 0 : o.depthStencilAttachment) == null ? void 0 : l.view) ?? null;
6178
6220
  return v ? { view: v, multisampled: (s.currentSamples ?? 0) > 1 } : null;
6179
6221
  } catch {
6180
6222
  return null;
@@ -6182,46 +6224,46 @@ function $r(s) {
6182
6224
  };
6183
6225
  }
6184
6226
  export {
6185
- br as GLBAnimator,
6186
- Sr as HZClock,
6187
- kr as Objects3DManager,
6188
- Ys as ParticleEmitter,
6189
- Ks as ParticlePhysics,
6190
- Gi as ParticleScript,
6227
+ xr as GLBAnimator,
6228
+ vr as HZClock,
6229
+ Nr as Objects3DManager,
6230
+ qs as ParticleEmitter,
6231
+ er as ParticlePhysics,
6232
+ Fi as ParticleScript,
6191
6233
  ii as ParticleSystem,
6192
- wr as ParticleSystemManager,
6193
- Qs as ParticleTextureManager,
6194
- qs as blurShader,
6195
- Zs as compositeShader,
6196
- Ar as createBindGroupLayouts,
6234
+ Br as ParticleSystemManager,
6235
+ tr as ParticleTextureManager,
6236
+ Zs as blurShader,
6237
+ Ws as compositeShader,
6238
+ Cr as createBindGroupLayouts,
6197
6239
  si as createBindGroups,
6198
6240
  St as createBuffer,
6199
- Ur as createCubeGeometry,
6200
- Ni as createDepthTexture,
6201
- Yr as createLookAtMatrix,
6202
- jr as createProjectionMatrix,
6203
- Er as createRenderPipelines,
6204
- Xi as createRenderTextures,
6205
- Cr as createSampler,
6206
- Ir as createSphereGeometry,
6207
- Hs as directRenderShader,
6241
+ zr as createCubeGeometry,
6242
+ Yi as createDepthTexture,
6243
+ qr as createLookAtMatrix,
6244
+ Hr as createProjectionMatrix,
6245
+ Ur as createRenderPipelines,
6246
+ Ni as createRenderTextures,
6247
+ Ir as createSampler,
6248
+ Dr as createSphereGeometry,
6249
+ $s as directRenderShader,
6208
6250
  Vi as extractGLBTexture,
6209
- Hr as fetchPreset,
6210
- Tr as glbMeshParticleShader,
6211
- Xr as hexToRgb,
6212
- Wr as initHzFxOverlay,
6213
- Br as initWebGPU,
6214
- es as isHZFX,
6215
- Zr as loadScene,
6216
- $r as makeThreeSceneDepth,
6217
- Fr as multiplyMatrices,
6218
- Rr as object3dShader,
6219
- Dr as packHZFX,
6220
- nr as parseGLB,
6221
- $s as particlePhysicsShader,
6222
- js as particleShader,
6223
- Nr as rgbToHex,
6224
- qr as saveScene,
6225
- Or as serializeSystemConfig,
6226
- ts as unpackHZFX
6251
+ $r as fetchPreset,
6252
+ Ar as glbMeshParticleShader,
6253
+ Yr as hexToRgb,
6254
+ Jr as initHzFxOverlay,
6255
+ Tr as initWebGPU,
6256
+ is as isHZFX,
6257
+ Wr as loadScene,
6258
+ Kr as makeThreeSceneDepth,
6259
+ Gr as multiplyMatrices,
6260
+ Er as object3dShader,
6261
+ Or as packHZFX,
6262
+ or as parseGLB,
6263
+ Ks as particlePhysicsShader,
6264
+ Hs as particleShader,
6265
+ jr as rgbToHex,
6266
+ Zr as saveScene,
6267
+ kr as serializeSystemConfig,
6268
+ ss as unpackHZFX
6227
6269
  };