hz-particles 1.4.0 → 1.4.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 fs {
1
+ class ms {
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,14 +10,14 @@ class fs {
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), u = Math.sin(n), h = Math.cos(a), p = Math.sin(a);
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), u = Math.sin(n), m = Math.cos(a), p = Math.sin(a);
14
14
  this._rotMatrix = [
15
- l * h,
16
- c * u * h - o * p,
17
- o * u * h + c * p,
15
+ l * m,
16
+ c * u * m - o * p,
17
+ o * u * m + c * p,
18
18
  l * p,
19
- c * u * p + o * h,
20
- o * u * p - c * h,
19
+ c * u * p + o * m,
20
+ o * u * p - c * m,
21
21
  -u,
22
22
  c * l,
23
23
  o * l
@@ -91,8 +91,8 @@ class fs {
91
91
  o = n, c = -0.5, l = a;
92
92
  break;
93
93
  }
94
- const u = Math.random(), h = e + u * (i - e);
95
- t[0] = o * h, t[1] = c * h, t[2] = l * h;
94
+ const u = Math.random(), m = e + u * (i - e);
95
+ t[0] = o * m, t[1] = c * m, t[2] = l * m;
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
  }
@@ -244,33 +244,33 @@ class fs {
244
244
  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;
245
245
  }
246
246
  calculateVelocity(t, e, i, r, n) {
247
- const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, u = e - o, h = i - c, p = Math.sqrt(l * l + u * u + h * h);
248
- let d, S, R;
247
+ const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, u = e - o, m = i - c, p = Math.sqrt(l * l + u * u + m * m);
248
+ let d, b, w;
249
249
  if (p > 1e-4) {
250
- let T = !1;
250
+ let R = !1;
251
251
  if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
252
- const x = this.inverseRotation(l, u, h), L = Math.sqrt(x[0] * x[0] + x[1] * x[1]);
252
+ const x = this.inverseRotation(l, u, m), L = Math.sqrt(x[0] * x[0] + x[1] * x[1]);
253
253
  if (L > 1e-4) {
254
- const P = -x[1] / L, B = x[0] / L, M = this.applyRotation(P, B, 0);
255
- d = M[0], S = M[1], R = M[2], T = !0;
254
+ const P = -x[1] / L, T = x[0] / L, E = this.applyRotation(P, T, 0);
255
+ d = E[0], b = E[1], w = E[2], R = !0;
256
256
  }
257
257
  } else if (this.config.emissionShape === "cylinder" && this.config.cylinderVelocityDirection === "tangential") {
258
- const x = this.inverseRotation(l, u, h), L = Math.sqrt(x[0] * x[0] + x[2] * x[2]);
258
+ const x = this.inverseRotation(l, u, m), L = Math.sqrt(x[0] * x[0] + x[2] * x[2]);
259
259
  if (L > 1e-4) {
260
- const P = -x[2] / L, B = x[0] / L, M = this.applyRotation(P, 0, B);
261
- d = M[0], S = M[1], R = M[2], T = !0;
260
+ const P = -x[2] / L, T = x[0] / L, E = this.applyRotation(P, 0, T);
261
+ d = E[0], b = E[1], w = E[2], R = !0;
262
262
  } else {
263
- const P = Math.random() * Math.PI * 2, B = this.applyRotation(Math.cos(P), 0, Math.sin(P));
264
- d = B[0], S = B[1], R = B[2], T = !0;
263
+ const P = Math.random() * Math.PI * 2, T = this.applyRotation(Math.cos(P), 0, Math.sin(P));
264
+ d = T[0], b = T[1], w = T[2], R = !0;
265
265
  }
266
266
  }
267
- T || (d = l / p, S = u / p, R = h / p);
267
+ R || (d = l / p, b = u / p, w = m / p);
268
268
  } else {
269
- const T = Math.random() * Math.PI * 2, x = Math.acos(2 * Math.random() - 1);
270
- d = Math.sin(x) * Math.cos(T), S = Math.sin(x) * Math.sin(T), R = Math.cos(x);
269
+ const R = Math.random() * Math.PI * 2, x = Math.acos(2 * Math.random() - 1);
270
+ d = Math.sin(x) * Math.cos(R), b = Math.sin(x) * Math.sin(R), w = Math.cos(x);
271
271
  }
272
- let E;
273
- this.config.randomSpeed ? E = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : E = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : d * E, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : S * E, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : R * E, r[n + 3] = 0;
272
+ let M;
273
+ this.config.randomSpeed ? M = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : M = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : d * M, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : b * M, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : w * M, r[n + 3] = 0;
274
274
  }
275
275
  setParticleColor(t, e) {
276
276
  if (this.config.randomColorEnabled && this.config.randomColors.length > 0) {
@@ -283,7 +283,7 @@ class fs {
283
283
  t[e + 6] = 0, t[e + 7] = i + (Math.random() * 0.4 - 0.2) * i;
284
284
  }
285
285
  }
286
- const ps = `
286
+ const ys = `
287
287
  struct Uniforms {
288
288
  transform: mat4x4<f32>,
289
289
  cameraPosition: vec3<f32>,
@@ -705,7 +705,7 @@ const ps = `
705
705
  return vec4<f32>(input.color, alpha);
706
706
  }
707
707
  }
708
- `, hs = `
708
+ `, gs = `
709
709
  struct BloomUniforms {
710
710
  direction: vec2<f32>,
711
711
  resolution: vec2<f32>,
@@ -765,7 +765,7 @@ const ps = `
765
765
 
766
766
  return result / totalWeight * 1.1;
767
767
  }
768
- `, ms = `
768
+ `, bs = `
769
769
  struct BloomIntensityUniforms {
770
770
  intensity: f32,
771
771
  color: vec3<f32>,
@@ -811,7 +811,7 @@ const ps = `
811
811
 
812
812
  return vec4<f32>(originalColor.rgb + (mappedBloom * bloomUniforms.intensity), originalColor.a);
813
813
  }
814
- `, ys = `
814
+ `, Ss = `
815
815
  struct BloomIntensityUniforms {
816
816
  intensity: f32,
817
817
  color: vec3<f32>,
@@ -852,7 +852,7 @@ const ps = `
852
852
  fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
853
853
  return textureSample(originalTexture, texSampler, input.texCoord);
854
854
  }
855
- `, gs = `
855
+ `, xs = `
856
856
  @binding(0) @group(0) var texSampler: sampler;
857
857
  @binding(1) @group(0) var originalTexture: texture_2d<f32>;
858
858
  @binding(2) @group(0) var blurredTexture: texture_2d<f32>;
@@ -884,7 +884,7 @@ const ps = `
884
884
  let c = textureSample(originalTexture, texSampler, input.texCoord);
885
885
  return vec4<f32>(aces(c.rgb), c.a);
886
886
  }
887
- `, bs = `
887
+ `, vs = `
888
888
  struct PhysicsUniforms {
889
889
  deltaTime: f32,
890
890
  particleSpeed: f32,
@@ -1094,7 +1094,7 @@ const ps = `
1094
1094
  particleBuffer[baseIndex + 1u] = newPos.y;
1095
1095
  particleBuffer[baseIndex + 2u] = newPos.z;
1096
1096
  }
1097
- `, Ss = `
1097
+ `, Ps = `
1098
1098
  @group(0) @binding(0) var<storage, read> restData: array<f32>;
1099
1099
  @group(0) @binding(1) var<storage, read> jointWeightsData: array<f32>;
1100
1100
  @group(0) @binding(2) var<storage, read> jointIndicesData: array<u32>;
@@ -1151,7 +1151,7 @@ const ps = `
1151
1151
  outputData[outBase + 7u] = uv_v;
1152
1152
  }
1153
1153
  `;
1154
- class xs {
1154
+ class _s {
1155
1155
  constructor(t, e = 1e4) {
1156
1156
  this.device = t, this.physicsSettings = {
1157
1157
  deltaTime: 0.016,
@@ -1240,7 +1240,7 @@ class xs {
1240
1240
  }),
1241
1241
  compute: {
1242
1242
  module: this.device.createShaderModule({
1243
- code: bs
1243
+ code: vs
1244
1244
  }),
1245
1245
  entryPoint: "main"
1246
1246
  }
@@ -1273,8 +1273,8 @@ class xs {
1273
1273
  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);
1274
1274
  const l = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }), u = l.beginComputePass({ label: "ParticlePhysicsPass" });
1275
1275
  u.setPipeline(this.computePipeline), u.setBindGroup(0, this.computeBindGroup);
1276
- const h = Math.max(1, Math.ceil(e / 64));
1277
- u.dispatchWorkgroups(h, 1, 1), u.end(), a || this.device.queue.submit([l.finish()]), this.lastUpdateTime = performance.now() / 1e3;
1276
+ const m = Math.max(1, Math.ceil(e / 64));
1277
+ u.dispatchWorkgroups(m, 1, 1), u.end(), a || this.device.queue.submit([l.finish()]), this.lastUpdateTime = performance.now() / 1e3;
1278
1278
  }
1279
1279
  async readbackAndProcessParticles(t, e, i, r, n) {
1280
1280
  if (t <= 0)
@@ -1446,7 +1446,7 @@ class xs {
1446
1446
  t.enabled !== void 0 && (e.softBoundaryEnabled = t.enabled), t.strength !== void 0 && (e.softBoundaryStrength = t.strength), t.falloff !== void 0 && (e.softBoundaryFalloff = t.falloff);
1447
1447
  }
1448
1448
  }
1449
- class vs {
1449
+ class ws {
1450
1450
  constructor(t) {
1451
1451
  this.device = t, this.defaultTexture = null, this.createDefaultTexture();
1452
1452
  }
@@ -1485,7 +1485,7 @@ class vs {
1485
1485
  t && t.label !== "defaultParticleTexture" && t.destroy();
1486
1486
  }
1487
1487
  }
1488
- const Si = Object.freeze({
1488
+ const Pi = Object.freeze({
1489
1489
  sin: Math.sin,
1490
1490
  cos: Math.cos,
1491
1491
  abs: Math.abs,
@@ -1506,10 +1506,10 @@ const Si = Object.freeze({
1506
1506
  return s + (t - s) * e;
1507
1507
  },
1508
1508
  smoothstep(s, t, e) {
1509
- const i = Si.clamp((e - s) / (t - s), 0, 1);
1509
+ const i = Pi.clamp((e - s) / (t - s), 0, 1);
1510
1510
  return i * i * (3 - 2 * i);
1511
1511
  }
1512
- }), Ze = /* @__PURE__ */ new Set([
1512
+ }), $e = /* @__PURE__ */ new Set([
1513
1513
  "particleSize",
1514
1514
  "particleSpeed",
1515
1515
  "particleColor",
@@ -1525,7 +1525,7 @@ const Si = Object.freeze({
1525
1525
  "pulseFrequency",
1526
1526
  "bloomIntensity"
1527
1527
  ]);
1528
- class Ps {
1528
+ class Bs {
1529
1529
  constructor(t) {
1530
1530
  this._collection = t, this._pd = null, this._vd = null, this._pi = 0, this._vi = 0;
1531
1531
  }
@@ -1603,9 +1603,9 @@ class Ps {
1603
1603
  this._vd[this._vi + 2] = t, this._collection._dirty = !0;
1604
1604
  }
1605
1605
  }
1606
- class _s {
1606
+ class Ms {
1607
1607
  constructor() {
1608
- this._proxy = new Ps(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
1608
+ this._proxy = new Bs(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
1609
1609
  }
1610
1610
  _bind(t, e, i) {
1611
1611
  this._pd = t, this._vd = e, this.count = i, this._dirty = !1;
@@ -1614,14 +1614,14 @@ class _s {
1614
1614
  return t < 0 || t >= this.count ? null : this._proxy._bind(this._pd, this._vd, t);
1615
1615
  }
1616
1616
  }
1617
- const ws = 1e6;
1618
- function Bs(s) {
1617
+ const Rs = 1e6;
1618
+ function Ts(s) {
1619
1619
  let t = 0;
1620
1620
  return s.replace(
1621
1621
  /\b(for|while)\s*\([^)]*\)\s*\{/g,
1622
1622
  (e) => {
1623
1623
  const i = `__lc${t++}`;
1624
- return `${e} if(++${i}>${ws})throw new Error("Loop limit exceeded");`;
1624
+ return `${e} if(++${i}>${Rs})throw new Error("Loop limit exceeded");`;
1625
1625
  }
1626
1626
  ).replace(
1627
1627
  /\b(for|while)\s*\([^)]*\)\s*\{/g,
@@ -1638,10 +1638,10 @@ function Bs(s) {
1638
1638
  }
1639
1639
  );
1640
1640
  }
1641
- const vt = /* @__PURE__ */ new Map();
1642
- for (const s of Ze)
1643
- vt.set(s.toLowerCase(), s);
1644
- function Ms(s) {
1641
+ const wt = /* @__PURE__ */ new Map();
1642
+ for (const s of $e)
1643
+ wt.set(s.toLowerCase(), s);
1644
+ function Es(s) {
1645
1645
  const t = { value: !1 }, e = /* @__PURE__ */ new Set();
1646
1646
  return new Proxy(s, {
1647
1647
  get(r, n) {
@@ -1650,16 +1650,16 @@ function Ms(s) {
1650
1650
  t.value = !1;
1651
1651
  };
1652
1652
  if (typeof n != "string") return;
1653
- if (Ze.has(n)) return r[n];
1654
- const a = vt.get(n.toLowerCase());
1653
+ if ($e.has(n)) return r[n];
1654
+ const a = wt.get(n.toLowerCase());
1655
1655
  if (a)
1656
1656
  return e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${a}?`)), r[a];
1657
1657
  },
1658
1658
  set(r, n, a) {
1659
1659
  if (typeof n != "string") return !0;
1660
1660
  let o = n;
1661
- if (!Ze.has(o)) {
1662
- const c = vt.get(o.toLowerCase());
1661
+ if (!$e.has(o)) {
1662
+ const c = wt.get(o.toLowerCase());
1663
1663
  if (c)
1664
1664
  e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${c}?`)), o = c;
1665
1665
  else
@@ -1669,14 +1669,14 @@ function Ms(s) {
1669
1669
  }
1670
1670
  });
1671
1671
  }
1672
- class ni {
1672
+ class ui {
1673
1673
  /**
1674
1674
  * @param {string} source - User script source code
1675
1675
  * @param {object} config - ParticleSystem config (will be proxied)
1676
1676
  * @param {number} maxParticles - Max particle count for pre-allocation
1677
1677
  */
1678
1678
  constructor(t, e, i) {
1679
- this._particles = new _s(), this._configProxy = Ms(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
1679
+ this._particles = new Ms(), this._configProxy = Es(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
1680
1680
  }
1681
1681
  /**
1682
1682
  * Compile script source into a sandboxed function.
@@ -1692,7 +1692,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1692
1692
  var deltaTime = __deltaTime, time = __time;
1693
1693
  var currentFrame = __currentFrame, totalFrames = __totalFrames;
1694
1694
  var particles = __particles, config = __config, math = __math;
1695
- ${Bs(t)}
1695
+ ${Ts(t)}
1696
1696
  };`, r = new Function(i);
1697
1697
  this._fn = r();
1698
1698
  } catch (e) {
@@ -1714,7 +1714,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1714
1714
  if (!this._fn || this._error) return { configDirty: !1, particlesDirty: !1 };
1715
1715
  this._particles._bind(n, a, o), this._configProxy.__resetDirty();
1716
1716
  try {
1717
- this._fn(t, e, i, r, this._particles, this._configProxy, Si);
1717
+ this._fn(t, e, i, r, this._particles, this._configProxy, Pi);
1718
1718
  } catch (c) {
1719
1719
  console.warn("[ParticleScript] Runtime error:", c.message);
1720
1720
  }
@@ -1728,7 +1728,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1728
1728
  */
1729
1729
  snapshotConfig(t) {
1730
1730
  const e = {};
1731
- for (const i of Ze) {
1731
+ for (const i of $e) {
1732
1732
  const r = t[i];
1733
1733
  r !== void 0 && (e[i] = Array.isArray(r) ? [...r] : r);
1734
1734
  }
@@ -1739,7 +1739,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1739
1739
  */
1740
1740
  restoreConfig(t) {
1741
1741
  if (this._configSnapshot) {
1742
- for (const e of Ze)
1742
+ for (const e of $e)
1743
1743
  if (e in this._configSnapshot) {
1744
1744
  const i = this._configSnapshot[e];
1745
1745
  t[e] = Array.isArray(i) ? [...i] : i;
@@ -1753,7 +1753,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1753
1753
  this._fn = null, this._particles = null, this._configProxy = null, this._configSnapshot = null;
1754
1754
  }
1755
1755
  }
1756
- async function Rs(s) {
1756
+ async function Cs(s) {
1757
1757
  const t = new DataView(s);
1758
1758
  if (t.getUint32(0, !0) !== 1179937895)
1759
1759
  throw new Error("Invalid GLB file: incorrect magic number");
@@ -1763,11 +1763,11 @@ async function Rs(s) {
1763
1763
  const r = t.getUint32(8, !0);
1764
1764
  let n = 12, a = null, o = null;
1765
1765
  for (; n < r; ) {
1766
- const P = t.getUint32(n, !0), B = t.getUint32(n + 4, !0), M = s.slice(n + 8, n + 8 + P);
1767
- if (B === 1313821514) {
1768
- const N = new TextDecoder("utf-8").decode(M);
1769
- a = JSON.parse(N);
1770
- } else B === 5130562 && (o = M);
1766
+ const P = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), E = s.slice(n + 8, n + 8 + P);
1767
+ if (T === 1313821514) {
1768
+ const k = new TextDecoder("utf-8").decode(E);
1769
+ a = JSON.parse(k);
1770
+ } else T === 5130562 && (o = E);
1771
1771
  n += 8 + P;
1772
1772
  }
1773
1773
  if (!a)
@@ -1780,23 +1780,23 @@ async function Rs(s) {
1780
1780
  const u = l.attributes.POSITION;
1781
1781
  if (u === void 0)
1782
1782
  throw new Error("Mesh primitive missing POSITION attribute");
1783
- const h = gt(a, o, u, 3, 5126);
1783
+ const m = xt(a, o, u, 3, 5126);
1784
1784
  let p;
1785
1785
  if (l.attributes.NORMAL !== void 0)
1786
- p = gt(a, o, l.attributes.NORMAL, 3, 5126);
1786
+ p = xt(a, o, l.attributes.NORMAL, 3, 5126);
1787
1787
  else {
1788
1788
  const P = l.indices;
1789
1789
  if (P === void 0)
1790
1790
  throw new Error("Cannot generate normals without indices");
1791
- const B = ai(a, o, P);
1792
- p = Ts(h, B);
1791
+ const T = di(a, o, P);
1792
+ p = As(m, T);
1793
1793
  }
1794
1794
  const d = l.indices;
1795
1795
  if (d === void 0)
1796
1796
  throw new Error("Mesh primitive missing indices");
1797
- const S = ai(a, o, d), R = h.length / 3, E = S.length;
1798
- let T = null;
1799
- l.attributes.TEXCOORD_0 !== void 0 && (T = gt(a, o, l.attributes.TEXCOORD_0, 2, 5126));
1797
+ const b = di(a, o, d), w = m.length / 3, M = b.length;
1798
+ let R = null;
1799
+ l.attributes.TEXCOORD_0 !== void 0 && (R = xt(a, o, l.attributes.TEXCOORD_0, 2, 5126));
1800
1800
  let x = !1;
1801
1801
  if (a.materials && a.materials.length > 0) {
1802
1802
  const P = a.materials[0];
@@ -1805,22 +1805,22 @@ async function Rs(s) {
1805
1805
  let L = null;
1806
1806
  if (a.skins && a.skins.length > 0)
1807
1807
  try {
1808
- L = zs(a, o, l), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", L);
1808
+ L = Fs(a, o, l), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", L);
1809
1809
  } catch (P) {
1810
1810
  console.warn("Failed to extract animation data:", P);
1811
1811
  }
1812
1812
  return {
1813
- positions: h,
1813
+ positions: m,
1814
1814
  normals: p,
1815
- indices: S,
1816
- texCoords: T,
1817
- vertexCount: R,
1818
- indexCount: E,
1815
+ indices: b,
1816
+ texCoords: R,
1817
+ vertexCount: w,
1818
+ indexCount: M,
1819
1819
  animationData: L,
1820
1820
  hasBaseColorTexture: x
1821
1821
  };
1822
1822
  }
1823
- function gt(s, t, e, i, r) {
1823
+ function xt(s, t, e, i, r) {
1824
1824
  const n = s.accessors[e], o = {
1825
1825
  SCALAR: 1,
1826
1826
  VEC2: 2,
@@ -1831,12 +1831,12 @@ function gt(s, t, e, i, r) {
1831
1831
  throw new Error(`Attribute accessor type mismatch: expected ${i} components, got ${o}`);
1832
1832
  if (n.componentType !== r)
1833
1833
  throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
1834
- const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), u = n.count, h = new DataView(t, l, u * i * 4), p = new Float32Array(u * i);
1834
+ const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), u = n.count, m = new DataView(t, l, u * i * 4), p = new Float32Array(u * i);
1835
1835
  for (let d = 0; d < u * i; d++)
1836
- p[d] = h.getFloat32(d * 4, !0);
1836
+ p[d] = m.getFloat32(d * 4, !0);
1837
1837
  return p;
1838
1838
  }
1839
- function ai(s, t, e) {
1839
+ function di(s, t, e) {
1840
1840
  const i = s.accessors[e];
1841
1841
  if (i.type !== "SCALAR")
1842
1842
  throw new Error(`Indices accessor must be SCALAR, got ${i.type}`);
@@ -1854,19 +1854,19 @@ function ai(s, t, e) {
1854
1854
  } else
1855
1855
  throw new Error(`Unsupported index component type: ${i.componentType}`);
1856
1856
  }
1857
- function Ts(s, t) {
1857
+ function As(s, t) {
1858
1858
  const e = new Float32Array(s.length);
1859
1859
  for (let i = 0; i < t.length; i += 3) {
1860
- 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]], u = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], h = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], p = [
1861
- u[1] * h[2] - u[2] * h[1],
1862
- u[2] * h[0] - u[0] * h[2],
1863
- u[0] * h[1] - u[1] * h[0]
1860
+ 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]], u = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], m = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], p = [
1861
+ u[1] * m[2] - u[2] * m[1],
1862
+ u[2] * m[0] - u[0] * m[2],
1863
+ u[0] * m[1] - u[1] * m[0]
1864
1864
  ], d = Math.sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]);
1865
1865
  d > 0 && (p[0] /= d, p[1] /= d, p[2] /= d), e[r] = e[n] = e[a] = p[0], e[r + 1] = e[n + 1] = e[a + 1] = p[1], e[r + 2] = e[n + 2] = e[a + 2] = p[2];
1866
1866
  }
1867
1867
  return e;
1868
1868
  }
1869
- function Es(s, t, e) {
1869
+ function Us(s, t, e) {
1870
1870
  const i = s.accessors[e];
1871
1871
  if (i.type !== "VEC4")
1872
1872
  throw new Error(`JOINTS_0 must be VEC4, got ${i.type}`);
@@ -1884,7 +1884,7 @@ function Es(s, t, e) {
1884
1884
  } else
1885
1885
  throw new Error(`Unsupported JOINTS_0 component type: ${i.componentType}`);
1886
1886
  }
1887
- function Cs(s, t, e) {
1887
+ function Is(s, t, e) {
1888
1888
  const i = s.accessors[e];
1889
1889
  if (i.type !== "VEC4")
1890
1890
  throw new Error(`WEIGHTS_0 must be VEC4, got ${i.type}`);
@@ -1902,7 +1902,7 @@ function Cs(s, t, e) {
1902
1902
  } else
1903
1903
  throw new Error(`Unsupported WEIGHTS_0 component type: ${i.componentType}`);
1904
1904
  }
1905
- function As(s, t, e) {
1905
+ function zs(s, t, e) {
1906
1906
  const i = s.accessors[e];
1907
1907
  if (i.type !== "MAT4")
1908
1908
  throw new Error(`Expected MAT4, got ${i.type}`);
@@ -1913,7 +1913,7 @@ function As(s, t, e) {
1913
1913
  c[l] = o.getFloat32(l * 4, !0);
1914
1914
  return c;
1915
1915
  }
1916
- function Us(s, t, e) {
1916
+ function Gs(s, t, e) {
1917
1917
  const i = s.accessors[e];
1918
1918
  if (i.type !== "SCALAR")
1919
1919
  throw new Error(`Expected SCALAR, got ${i.type}`);
@@ -1924,19 +1924,19 @@ function Us(s, t, e) {
1924
1924
  c[l] = o.getFloat32(l * 4, !0);
1925
1925
  return c;
1926
1926
  }
1927
- function Is(s, t, e) {
1927
+ function Ds(s, t, e) {
1928
1928
  const i = s.accessors[e], n = { VEC3: 3, VEC4: 4 }[i.type];
1929
1929
  if (!n)
1930
1930
  throw new Error(`Expected VEC3 or VEC4, got ${i.type}`);
1931
1931
  if (i.componentType !== 5126)
1932
1932
  throw new Error(`Expected FLOAT component type, got ${i.componentType}`);
1933
1933
  const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), c = i.count, l = new DataView(t, o, c * n * 4), u = new Float32Array(c * n);
1934
- for (let h = 0; h < c * n; h++)
1935
- u[h] = l.getFloat32(h * 4, !0);
1934
+ for (let m = 0; m < c * n; m++)
1935
+ u[m] = l.getFloat32(m * 4, !0);
1936
1936
  return u;
1937
1937
  }
1938
- function zs(s, t, e) {
1939
- const i = s.skins[0], r = i.joints, n = As(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? Es(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? Cs(s, t, e.attributes.WEIGHTS_0) : null;
1938
+ function Fs(s, t, e) {
1939
+ const i = s.skins[0], r = i.joints, n = zs(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? Us(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? Is(s, t, e.attributes.WEIGHTS_0) : null;
1940
1940
  if (!a || !o)
1941
1941
  throw new Error("Mesh missing JOINTS_0 or WEIGHTS_0 attributes");
1942
1942
  const c = s.nodes.map((u) => ({
@@ -1948,22 +1948,22 @@ function zs(s, t, e) {
1948
1948
  })), l = [];
1949
1949
  if (s.animations && s.animations.length > 0)
1950
1950
  for (const u of s.animations) {
1951
- const h = [];
1951
+ const m = [];
1952
1952
  let p = 0;
1953
1953
  for (const d of u.channels) {
1954
- const S = u.samplers[d.sampler], R = Us(s, t, S.input), E = Is(s, t, S.output), T = R[R.length - 1];
1955
- T > p && (p = T), h.push({
1954
+ const b = u.samplers[d.sampler], w = Gs(s, t, b.input), M = Ds(s, t, b.output), R = w[w.length - 1];
1955
+ R > p && (p = R), m.push({
1956
1956
  targetNode: d.target.node,
1957
1957
  targetPath: d.target.path,
1958
- interpolation: S.interpolation || "LINEAR",
1959
- timestamps: R,
1960
- values: E
1958
+ interpolation: b.interpolation || "LINEAR",
1959
+ timestamps: w,
1960
+ values: M
1961
1961
  });
1962
1962
  }
1963
1963
  l.push({
1964
1964
  name: u.name || `Animation ${l.length}`,
1965
1965
  duration: p,
1966
- channels: h
1966
+ channels: m
1967
1967
  });
1968
1968
  }
1969
1969
  return {
@@ -1975,7 +1975,7 @@ function zs(s, t, e) {
1975
1975
  animations: l
1976
1976
  };
1977
1977
  }
1978
- async function oi(s) {
1978
+ async function fi(s) {
1979
1979
  const t = new DataView(s);
1980
1980
  if (t.getUint32(0, !0) !== 1179937895)
1981
1981
  throw new Error("Invalid GLB file: incorrect magic number");
@@ -1985,11 +1985,11 @@ async function oi(s) {
1985
1985
  const r = t.getUint32(8, !0);
1986
1986
  let n = 12, a = null, o = null;
1987
1987
  for (; n < r; ) {
1988
- const L = t.getUint32(n, !0), P = t.getUint32(n + 4, !0), B = s.slice(n + 8, n + 8 + L);
1988
+ const L = t.getUint32(n, !0), P = t.getUint32(n + 4, !0), T = s.slice(n + 8, n + 8 + L);
1989
1989
  if (P === 1313821514) {
1990
- const F = new TextDecoder("utf-8").decode(B);
1990
+ const F = new TextDecoder("utf-8").decode(T);
1991
1991
  a = JSON.parse(F);
1992
- } else P === 5130562 && (o = B);
1992
+ } else P === 5130562 && (o = T);
1993
1993
  n += 8 + L;
1994
1994
  }
1995
1995
  if (!a)
@@ -2002,71 +2002,55 @@ async function oi(s) {
2002
2002
  const l = c.pbrMetallicRoughness.baseColorTexture.index;
2003
2003
  if (!a.textures || !a.textures[l])
2004
2004
  return null;
2005
- const h = a.textures[l].source;
2006
- if (h === void 0 || !a.images || !a.images[h])
2005
+ const m = a.textures[l].source;
2006
+ if (m === void 0 || !a.images || !a.images[m])
2007
2007
  return null;
2008
- const p = a.images[h], d = p.mimeType || "image/png";
2008
+ const p = a.images[m], d = p.mimeType || "image/png";
2009
2009
  if (p.bufferView === void 0)
2010
2010
  return null;
2011
2011
  if (!o)
2012
2012
  throw new Error("GLB file missing BIN chunk (required for embedded textures)");
2013
- const S = a.bufferViews[p.bufferView], R = S.byteOffset || 0, E = S.byteLength, T = o.slice(R, R + E);
2014
- return { imageBlob: new Blob([T], { type: d }), mimeType: d };
2015
- }
2016
- function li(s, t, e) {
2017
- return [
2018
- s[0] + (t[0] - s[0]) * e,
2019
- s[1] + (t[1] - s[1]) * e,
2020
- s[2] + (t[2] - s[2]) * e
2021
- ];
2013
+ const b = a.bufferViews[p.bufferView], w = b.byteOffset || 0, M = b.byteLength, R = o.slice(w, w + M);
2014
+ return { imageBlob: new Blob([R], { type: d }), mimeType: d };
2022
2015
  }
2023
- function ci(s, t, e) {
2024
- let i = s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3], r = t;
2025
- if (i < 0 && (i = -i, r = [-t[0], -t[1], -t[2], -t[3]]), i > 0.9995) {
2026
- const l = [
2027
- s[0] + (r[0] - s[0]) * e,
2028
- s[1] + (r[1] - s[1]) * e,
2029
- s[2] + (r[2] - s[2]) * e,
2030
- s[3] + (r[3] - s[3]) * e
2031
- ];
2032
- return Gs(l);
2033
- }
2034
- const n = Math.acos(i), a = Math.sin(n), o = Math.sin((1 - e) * n) / a, c = Math.sin(e * n) / a;
2035
- return [
2036
- s[0] * o + r[0] * c,
2037
- s[1] * o + r[1] * c,
2038
- s[2] * o + r[2] * c,
2039
- s[3] * o + r[3] * c
2040
- ];
2016
+ function Vs(s, t, e, i) {
2017
+ 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;
2041
2018
  }
2042
- function Gs(s) {
2043
- const t = Math.sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2] + s[3] * s[3]);
2044
- return t > 1e-4 ? [s[0] / t, s[1] / t, s[2] / t, s[3] / t] : [0, 0, 0, 1];
2019
+ function Os(s, t, e, i) {
2020
+ i = i || [0, 0, 0, 0];
2021
+ let r = s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3], n = 1;
2022
+ if (r < 0 && (r = -r, n = -1), r > 0.9995) {
2023
+ i[0] = s[0] + (n * t[0] - s[0]) * e, i[1] = s[1] + (n * t[1] - s[1]) * e, i[2] = s[2] + (n * t[2] - s[2]) * e, i[3] = s[3] + (n * t[3] - s[3]) * e;
2024
+ const u = Math.sqrt(i[0] * i[0] + i[1] * i[1] + i[2] * i[2] + i[3] * i[3]);
2025
+ return u > 1e-4 ? (i[0] /= u, i[1] /= u, i[2] /= u, i[3] /= u) : (i[0] = 0, i[1] = 0, i[2] = 0, i[3] = 1), i;
2026
+ }
2027
+ const a = Math.acos(r), o = Math.sin(a), c = Math.sin((1 - e) * a) / o, l = Math.sin(e * a) / o;
2028
+ 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;
2045
2029
  }
2046
- function Ds(s, t) {
2047
- 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, u = e * o, h = e * c, p = i * o, d = i * c, S = r * c, R = n * a, E = n * o, T = n * c, x = t || new Float32Array(16);
2048
- return x[0] = 1 - (p + S), x[1] = u + T, x[2] = h - E, x[3] = 0, x[4] = u - T, x[5] = 1 - (l + S), x[6] = d + R, x[7] = 0, x[8] = h + E, x[9] = d - R, x[10] = 1 - (l + p), x[11] = 0, x[12] = 0, x[13] = 0, x[14] = 0, x[15] = 1, x;
2030
+ function Ls(s, t) {
2031
+ 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, u = e * o, m = e * c, p = i * o, d = i * c, b = r * c, w = n * a, M = n * o, R = n * c, x = t || new Float32Array(16);
2032
+ return x[0] = 1 - (p + b), x[1] = u + R, x[2] = m - M, x[3] = 0, x[4] = u - R, x[5] = 1 - (l + b), x[6] = d + w, x[7] = 0, x[8] = m + M, x[9] = d - w, x[10] = 1 - (l + p), x[11] = 0, x[12] = 0, x[13] = 0, x[14] = 0, x[15] = 1, x;
2049
2033
  }
2050
- const Fs = new Float32Array(16);
2051
- function Vs(s, t, e, i) {
2052
- const r = Ds(t, Fs), n = i || new Float32Array(16);
2034
+ const Xs = new Float32Array(16);
2035
+ function ks(s, t, e, i) {
2036
+ const r = Ls(t, Xs), n = i || new Float32Array(16);
2053
2037
  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;
2054
2038
  }
2055
- function ui(s, t, e) {
2039
+ function pi(s, t, e) {
2056
2040
  const i = e || new Float32Array(16);
2057
2041
  for (let r = 0; r < 4; r++)
2058
2042
  for (let n = 0; n < 4; n++)
2059
2043
  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];
2060
2044
  return i;
2061
2045
  }
2062
- class Os {
2046
+ class Ns {
2063
2047
  constructor(t) {
2064
2048
  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);
2065
2049
  for (let e = 0; e < this.nodes.length; e++)
2066
2050
  this.jointLocalTransforms[e] = new Float32Array(16), this.jointGlobalTransforms[e] = new Float32Array(16);
2067
2051
  for (let e = 0; e < this.joints.length; e++)
2068
2052
  this.jointFinalMatrices[e] = new Float32Array(16);
2069
- this.skinnedPositions = null, this.skinnedNormals = null, this._gpuSkinningReady = !1, this._buildTopologicalOrder(), this._parentMap = new Array(this.nodes.length).fill(-1);
2053
+ this.skinnedPositions = null, this.skinnedNormals = null, this._gpuSkinningReady = !1, this._sV0 = new Float64Array(4), this._sV1 = new Float64Array(4), this._scrT = new Float64Array(3), this._scrR = new Float64Array(4), this._scrS = new Float64Array(3), this._buildTopologicalOrder(), this._parentMap = new Array(this.nodes.length).fill(-1);
2070
2054
  for (let e = 0; e < this.nodes.length; e++)
2071
2055
  for (const i of this.nodes[e].children) this._parentMap[i] = e;
2072
2056
  this._invBindViews = new Array(this.joints.length);
@@ -2090,8 +2074,8 @@ class Os {
2090
2074
  this._gpuDevice = t, this._gpuOutputBuffer = e;
2091
2075
  const r = this.restPositions.length / 3, n = new Float32Array(r * 8);
2092
2076
  for (let c = 0; c < r; c++) {
2093
- const l = c * 8, u = c * 3, h = c * 2;
2094
- n[l] = this.restPositions[u], n[l + 1] = this.restPositions[u + 1], n[l + 2] = this.restPositions[u + 2], n[l + 3] = this.restNormals[u], n[l + 4] = this.restNormals[u + 1], n[l + 5] = this.restNormals[u + 2], n[l + 6] = i ? i[h] : 0, n[l + 7] = i ? i[h + 1] : 0;
2077
+ const l = c * 8, u = c * 3, m = c * 2;
2078
+ n[l] = this.restPositions[u], n[l + 1] = this.restPositions[u + 1], n[l + 2] = this.restPositions[u + 2], n[l + 3] = this.restNormals[u], n[l + 4] = this.restNormals[u + 1], n[l + 5] = this.restNormals[u + 2], n[l + 6] = i ? i[m] : 0, n[l + 7] = i ? i[m + 1] : 0;
2095
2079
  }
2096
2080
  this._gpuRestDataBuffer = t.createBuffer({
2097
2081
  size: n.byteLength,
@@ -2126,7 +2110,7 @@ class Os {
2126
2110
  this._gpuSkinningPipeline = t.createComputePipeline({
2127
2111
  layout: t.createPipelineLayout({ bindGroupLayouts: [o] }),
2128
2112
  compute: {
2129
- module: t.createShaderModule({ code: Ss }),
2113
+ module: t.createShaderModule({ code: Ps }),
2130
2114
  entryPoint: "main"
2131
2115
  }
2132
2116
  }), this._gpuSkinningBindGroup = t.createBindGroup({
@@ -2208,31 +2192,32 @@ class Os {
2208
2192
  /**
2209
2193
  * Sample a single channel at the given time.
2210
2194
  */
2211
- _sampleChannel(t, e) {
2212
- const { timestamps: i, values: r, interpolation: n, targetPath: a } = t;
2213
- if (e <= i[0])
2214
- return this._extractValue(r, 0, a);
2215
- if (e >= i[i.length - 1])
2216
- return this._extractValue(r, i.length - 1, a);
2217
- let o = 0, c = i.length - 1;
2218
- for (; c - o > 1; ) {
2219
- const S = Math.floor((o + c) / 2);
2220
- i[S] <= e ? o = S : c = S;
2195
+ _sampleChannel(t, e, i) {
2196
+ const { timestamps: r, values: n, interpolation: a, targetPath: o } = t;
2197
+ if (e <= r[0])
2198
+ return this._extractValue(n, 0, o, i);
2199
+ if (e >= r[r.length - 1])
2200
+ return this._extractValue(n, r.length - 1, o, i);
2201
+ let c = 0, l = r.length - 1;
2202
+ for (; l - c > 1; ) {
2203
+ const w = Math.floor((c + l) / 2);
2204
+ r[w] <= e ? c = w : l = w;
2221
2205
  }
2222
- const l = i[o], u = i[c], h = (e - l) / (u - l), p = this._extractValue(r, o, a), d = this._extractValue(r, c, a);
2223
- return n === "STEP" ? p : a === "rotation" ? ci(p, d, h) : li(p, d, h);
2206
+ const u = r[c], m = r[l], p = (e - u) / (m - u), d = this._extractValue(n, c, o, this._sV0), b = this._extractValue(n, l, o, this._sV1);
2207
+ return a === "STEP" ? (i[0] = d[0], i[1] = d[1], i[2] = d[2], o === "rotation" && (i[3] = d[3]), i) : o === "rotation" ? Os(d, b, p, i) : Vs(d, b, p, i);
2224
2208
  }
2225
2209
  /**
2226
2210
  * Extract value from values array at the given index.
2227
2211
  */
2228
- _extractValue(t, e, i) {
2212
+ _extractValue(t, e, i, r) {
2229
2213
  if (i === "rotation") {
2230
- const r = e * 4;
2231
- return [t[r], t[r + 1], t[r + 2], t[r + 3]];
2214
+ const n = e * 4;
2215
+ r[0] = t[n], r[1] = t[n + 1], r[2] = t[n + 2], r[3] = t[n + 3];
2232
2216
  } else {
2233
- const r = e * 3;
2234
- return [t[r], t[r + 1], t[r + 2]];
2217
+ const n = e * 3;
2218
+ r[0] = t[n], r[1] = t[n + 1], r[2] = t[n + 2];
2235
2219
  }
2220
+ return r;
2236
2221
  }
2237
2222
  /**
2238
2223
  * Compute local transforms for all nodes at the given time.
@@ -2243,11 +2228,8 @@ class Os {
2243
2228
  const r = this.nodes[i];
2244
2229
  let n = r.translation, a = r.rotation, o = r.scale;
2245
2230
  for (const c of e.channels)
2246
- if (c.targetNode === i) {
2247
- const l = this._sampleChannel(c, t);
2248
- c.targetPath === "translation" ? n = l : c.targetPath === "rotation" ? a = l : c.targetPath === "scale" && (o = l);
2249
- }
2250
- Vs(n, a, o, this.jointLocalTransforms[i]);
2231
+ 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)));
2232
+ ks(n, a, o, this.jointLocalTransforms[i]);
2251
2233
  }
2252
2234
  }
2253
2235
  /**
@@ -2257,7 +2239,7 @@ class Os {
2257
2239
  const t = this._parentMap;
2258
2240
  for (const e of this.topologicalOrder) {
2259
2241
  const i = t[e];
2260
- i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) : ui(
2242
+ i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) : pi(
2261
2243
  this.jointGlobalTransforms[i],
2262
2244
  this.jointLocalTransforms[e],
2263
2245
  this.jointGlobalTransforms[e]
@@ -2270,7 +2252,7 @@ class Os {
2270
2252
  _computeFinalMatrices() {
2271
2253
  for (let t = 0; t < this.joints.length; t++) {
2272
2254
  const e = this.joints[t], i = this.jointGlobalTransforms[e];
2273
- ui(i, this._invBindViews[t], this.jointFinalMatrices[t]);
2255
+ pi(i, this._invBindViews[t], this.jointFinalMatrices[t]);
2274
2256
  }
2275
2257
  }
2276
2258
  /**
@@ -2280,20 +2262,20 @@ class Os {
2280
2262
  _applySkinning() {
2281
2263
  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;
2282
2264
  for (let l = 0; l < t; l++) {
2283
- const u = l * 3, h = l * 4, p = e[u], d = e[u + 1], S = e[u + 2], R = i[u], E = i[u + 1], T = i[u + 2];
2284
- let x = 0, L = 0, P = 0, B = 0, M = 0, F = 0;
2265
+ const u = l * 3, m = l * 4, p = e[u], d = e[u + 1], b = e[u + 2], w = i[u], M = i[u + 1], R = i[u + 2];
2266
+ let x = 0, L = 0, P = 0, T = 0, E = 0, F = 0;
2285
2267
  for (let Y = 0; Y < 4; Y++) {
2286
- const k = a[h + Y];
2287
- if (k === 0) continue;
2288
- const G = c[o[h + Y]];
2289
- x += (G[0] * p + G[4] * d + G[8] * S + G[12]) * k, L += (G[1] * p + G[5] * d + G[9] * S + G[13]) * k, P += (G[2] * p + G[6] * d + G[10] * S + G[14]) * k, B += (G[0] * R + G[4] * E + G[8] * T) * k, M += (G[1] * R + G[5] * E + G[9] * T) * k, F += (G[2] * R + G[6] * E + G[10] * T) * k;
2268
+ const N = a[m + Y];
2269
+ if (N === 0) continue;
2270
+ const G = c[o[m + Y]];
2271
+ x += (G[0] * p + G[4] * d + G[8] * b + G[12]) * N, L += (G[1] * p + G[5] * d + G[9] * b + G[13]) * N, P += (G[2] * p + G[6] * d + G[10] * b + G[14]) * N, T += (G[0] * w + G[4] * M + G[8] * R) * N, E += (G[1] * w + G[5] * M + G[9] * R) * N, F += (G[2] * w + G[6] * M + G[10] * R) * N;
2290
2272
  }
2291
- const N = Math.sqrt(B * B + M * M + F * F);
2292
- N > 1e-4 && (n[u] = B / N, n[u + 1] = M / N, n[u + 2] = F / N), r[u] = x, r[u + 1] = L, r[u + 2] = P;
2273
+ const k = Math.sqrt(T * T + E * E + F * F);
2274
+ k > 1e-4 && (n[u] = T / k, n[u + 1] = E / k, n[u + 2] = F / k), r[u] = x, r[u + 1] = L, r[u + 2] = P;
2293
2275
  }
2294
2276
  }
2295
2277
  }
2296
- class Ls {
2278
+ class js {
2297
2279
  constructor({ duration: t = 0, loop: e = !1, playbackRate: i = 1 } = {}) {
2298
2280
  this.currentTime = 0, this.duration = t, this.loop = e, this.playbackRate = i, this.paused = !1, this._justLooped = !1;
2299
2281
  }
@@ -2314,7 +2296,7 @@ class Ls {
2314
2296
  this.currentTime = Math.max(0, t || 0), this._justLooped = !1;
2315
2297
  }
2316
2298
  }
2317
- const di = {
2299
+ const hi = {
2318
2300
  linear: (s) => s,
2319
2301
  easeInQuad: (s) => s * s,
2320
2302
  easeOutQuad: (s) => 1 - (1 - s) * (1 - s),
@@ -2333,26 +2315,26 @@ const di = {
2333
2315
  return Math.pow(2, -10 * s) * Math.sin((s * 10 - 0.75) * t) + 1;
2334
2316
  }
2335
2317
  };
2336
- function Xs(s, t, e, i) {
2337
- 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, u = (d) => ((a * d + n) * d + r) * d, h = (d) => ((l * d + c) * d + o) * d, p = (d) => (3 * a * d + 2 * n) * d + r;
2318
+ function Ys(s, t, e, i) {
2319
+ 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, u = (d) => ((a * d + n) * d + r) * d, m = (d) => ((l * d + c) * d + o) * d, p = (d) => (3 * a * d + 2 * n) * d + r;
2338
2320
  return (d) => {
2339
2321
  if (d <= 0) return 0;
2340
2322
  if (d >= 1) return 1;
2341
- let S = d;
2342
- for (let R = 0; R < 8; R++) {
2343
- const E = u(S) - d;
2344
- if (Math.abs(E) < 1e-5) break;
2345
- const T = p(S);
2346
- if (Math.abs(T) < 1e-6) break;
2347
- S -= E / T;
2323
+ let b = d;
2324
+ for (let w = 0; w < 8; w++) {
2325
+ const M = u(b) - d;
2326
+ if (Math.abs(M) < 1e-5) break;
2327
+ const R = p(b);
2328
+ if (Math.abs(R) < 1e-6) break;
2329
+ b -= M / R;
2348
2330
  }
2349
- return h(S);
2331
+ return m(b);
2350
2332
  };
2351
2333
  }
2352
- function xi(s, t) {
2353
- return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? Xs(s[0], s[1], s[2], s[3])(t) : (di[s] || di.linear)(t);
2334
+ function _i(s, t) {
2335
+ return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? Ys(s[0], s[1], s[2], s[3])(t) : (hi[s] || hi.linear)(t);
2354
2336
  }
2355
- function Ns(s, t) {
2337
+ function Hs(s, t) {
2356
2338
  if (!Array.isArray(s) || s.length === 0) return;
2357
2339
  if (s.length === 1 || t <= s[0].t) return s[0].v;
2358
2340
  const e = s[s.length - 1];
@@ -2361,34 +2343,41 @@ function Ns(s, t) {
2361
2343
  const r = s[i], n = s[i + 1];
2362
2344
  if (t >= r.t && t <= n.t) {
2363
2345
  const a = n.t - r.t, o = a > 0 ? (t - r.t) / a : 0;
2364
- return r.v + (n.v - r.v) * xi(r.ease, o);
2346
+ return r.v + (n.v - r.v) * _i(r.ease, o);
2365
2347
  }
2366
2348
  }
2367
2349
  return e.v;
2368
2350
  }
2369
- function ks(s, t) {
2351
+ function qs(s, t, e) {
2370
2352
  if (!Array.isArray(s) || s.length === 0) return;
2371
- const e = (r, n, a) => [r[0] + (n[0] - r[0]) * a, r[1] + (n[1] - r[1]) * a, r[2] + (n[2] - r[2]) * a];
2372
- if (s.length === 1 || t <= s[0].t) return s[0].v.slice();
2373
- const i = s[s.length - 1];
2374
- if (t >= i.t) return i.v.slice();
2375
- for (let r = 0; r < s.length - 1; r++) {
2376
- const n = s[r], a = s[r + 1];
2377
- if (t >= n.t && t <= a.t) {
2378
- const o = a.t - n.t, c = o > 0 ? (t - n.t) / o : 0;
2379
- return e(n.v, a.v, xi(n.ease, c));
2353
+ const i = s.length, r = s[i - 1];
2354
+ let n, a, o;
2355
+ if (i === 1 || t <= s[0].t)
2356
+ n = a = s[0].v, o = 0;
2357
+ else if (t >= r.t)
2358
+ n = a = r.v, o = 0;
2359
+ else {
2360
+ n = a = r.v, o = 0;
2361
+ for (let m = 0; m < i - 1; m++) {
2362
+ const p = s[m], d = s[m + 1];
2363
+ if (t >= p.t && t <= d.t) {
2364
+ const b = d.t - p.t;
2365
+ n = p.v, a = d.v, o = _i(p.ease, b > 0 ? (t - p.t) / b : 0);
2366
+ break;
2367
+ }
2380
2368
  }
2381
2369
  }
2382
- return i.v.slice();
2370
+ const c = n[0] + (a[0] - n[0]) * o, l = n[1] + (a[1] - n[1]) * o, u = n[2] + (a[2] - n[2]) * o;
2371
+ return e ? (e[0] = c, e[1] = l, e[2] = u, e) : [c, l, u];
2383
2372
  }
2384
- const js = ["gravityStrength", "emissionRate", "damping", "particleSize", "particleSpeed"], Ys = { 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 };
2385
- function fi(s) {
2373
+ const Zs = ["gravityStrength", "emissionRate", "damping", "particleSize", "particleSpeed"], $s = { 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 };
2374
+ function mi(s) {
2386
2375
  const t = atob(s), e = new Uint8Array(t.length);
2387
2376
  for (let i = 0; i < t.length; i++)
2388
2377
  e[i] = t.charCodeAt(i);
2389
2378
  return e.buffer;
2390
2379
  }
2391
- class bt {
2380
+ class vt {
2392
2381
  constructor(t, e) {
2393
2382
  this.device = t, this.config = e, this.MAX_PARTICLES = e.maxParticles || 1e4, this.particleCount = e.particleCount || 100, this.activeParticles = 0, this.emitting = !1, this.currentEmissionTime = 0, this.destroyed = !1, this.particleData = new Float32Array(this.MAX_PARTICLES * 8), this.particleVelocities = new Float32Array(this.MAX_PARTICLES * 4), this.instanceBuffer = t.createBuffer({
2394
2383
  size: this.MAX_PARTICLES * 8 * 4,
@@ -2414,7 +2403,7 @@ class bt {
2414
2403
  // intensity (f32) + padding
2415
2404
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
2416
2405
  label: "systemBloomIntensityBuffer"
2417
- }), 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.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.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 fs(e), this.physics = new xs(t, this.MAX_PARTICLES), this.textureManager = new vs(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.confinementEnabled && this.setConfinement({
2406
+ }), 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.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.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 ms(e), this.physics = new _s(t, this.MAX_PARTICLES), this.textureManager = new ws(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.confinementEnabled && this.setConfinement({
2418
2407
  enabled: !0,
2419
2408
  shape: e.confinementShape,
2420
2409
  mode: e.confinementMode,
@@ -2427,7 +2416,7 @@ class bt {
2427
2416
  enabled: !0,
2428
2417
  strength: e.softBoundaryStrength,
2429
2418
  falloff: e.softBoundaryFalloff
2430
- }), 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 ni(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
2419
+ }), 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 ui(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
2431
2420
  }
2432
2421
  async initComputePipeline(t) {
2433
2422
  this.computeReady = await this.physics.initComputePipeline(this.instanceBuffer, this.velocityBuffer, this.trailBuffer);
@@ -2437,7 +2426,7 @@ class bt {
2437
2426
  * @param {string|null} source - Script source code, or null to disable
2438
2427
  */
2439
2428
  setScript(t) {
2440
- 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 ni(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
2429
+ 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 ui(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
2441
2430
  }
2442
2431
  async setTexture(t) {
2443
2432
  this.destroyed || (this.textureManager.destroyTexture(this.particleTexture), this.particleTexture = await this.textureManager.loadTexture(t), this.config.textureEnabled = !0, this.updateAppearanceUniform(), this.updateBuffers());
@@ -2448,7 +2437,7 @@ class bt {
2448
2437
  async setGLBModel(t) {
2449
2438
  try {
2450
2439
  this.glbRawArrayBuffer = t;
2451
- const e = await Rs(t);
2440
+ const e = await Cs(t);
2452
2441
  this.glbMeshData = e, this.config.glbHasTexture = e.hasBaseColorTexture || !1;
2453
2442
  const i = new Float32Array(e.vertexCount * 8);
2454
2443
  for (let r = 0; r < e.vertexCount; r++) {
@@ -2464,7 +2453,7 @@ class bt {
2464
2453
  usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
2465
2454
  label: "glbIndexBuffer"
2466
2455
  }), 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) {
2467
- this.glbAnimator = new Os(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);
2456
+ this.glbAnimator = new Ns(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);
2468
2457
  try {
2469
2458
  await this.glbAnimator.initGPUSkinning(this.device, this.glbVertexBuffer, e.texCoords);
2470
2459
  } catch (r) {
@@ -2526,7 +2515,7 @@ class bt {
2526
2515
  if (this.destroyed) return;
2527
2516
  let t = 0;
2528
2517
  this.config.rotationMode === "random" ? t = 1 : this.config.rotationMode === "velocity" ? t = 2 : this.config.rotationMode === "oriented" ? t = 3 : this.config.rotationMode === "cylindrical" && (t = 4);
2529
- const e = Ys[this.config.particleShape] ?? 0, i = this._appearanceData;
2518
+ const e = $s[this.config.particleShape] ?? 0, i = this._appearanceData;
2530
2519
  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;
2531
2520
  const r = this.config.followSystemTranslation ?? !0;
2532
2521
  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);
@@ -2625,11 +2614,11 @@ class bt {
2625
2614
  if (u > 0 && this._scriptTime >= u && !this._scriptConfigRestored)
2626
2615
  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));
2627
2616
  else if (!this._scriptConfigRestored) {
2628
- const h = u > 0 ? Math.ceil(u / 0.016666666666666666) : 0, { configDirty: p, particlesDirty: d } = this._particleScript.execute(
2617
+ const m = u > 0 ? Math.ceil(u / 0.016666666666666666) : 0, { configDirty: p, particlesDirty: d } = this._particleScript.execute(
2629
2618
  t,
2630
2619
  this._scriptTime,
2631
2620
  this._scriptFrame,
2632
- h,
2621
+ m,
2633
2622
  this._scriptParticleData,
2634
2623
  this._scriptVelocityData,
2635
2624
  this.activeParticles
@@ -2654,18 +2643,18 @@ class bt {
2654
2643
  if (!n && !this.emitting && !this.config.burstMode && !this.config.followSystemId && this.currentEmissionTime < this.effectiveEmissionDuration && (this.emitting = !0), !n && this.emitting)
2655
2644
  if (this.currentEmissionTime += t, this.currentEmissionTime < this.effectiveEmissionDuration) {
2656
2645
  const u = this.activeParticles;
2657
- let h = !1;
2646
+ let m = !1;
2658
2647
  if (this.config.followSystemId) {
2659
2648
  if (this._pendingFollowEmissions.length > 0) {
2660
2649
  const p = this._pendingFollowEmissions.length / 6;
2661
2650
  for (let d = 0; d < p; d++) {
2662
- const S = d * 6;
2651
+ const b = d * 6;
2663
2652
  if (this.emitFollowerParticle(
2664
- this._pendingFollowEmissions[S],
2665
- this._pendingFollowEmissions[S + 1],
2666
- this._pendingFollowEmissions[S + 2]
2653
+ this._pendingFollowEmissions[b],
2654
+ this._pendingFollowEmissions[b + 1],
2655
+ this._pendingFollowEmissions[b + 2]
2667
2656
  ))
2668
- h = !0;
2657
+ m = !0;
2669
2658
  else
2670
2659
  break;
2671
2660
  }
@@ -2682,10 +2671,10 @@ class bt {
2682
2671
  }
2683
2672
  p === 0 && c && this.config.emissionRate > 0 && this.activeParticles < this.particleCount && (p = 1);
2684
2673
  for (let d = 0; d < p && this.emitParticle(); d++)
2685
- h = !0;
2674
+ m = !0;
2686
2675
  }
2687
- if (h) {
2688
- const p = this.activeParticles - u, d = u * 8, S = u * 4;
2676
+ if (m) {
2677
+ const p = this.activeParticles - u, d = u * 8, b = u * 4;
2689
2678
  this.device.queue.writeBuffer(
2690
2679
  this.instanceBuffer,
2691
2680
  d * 4,
@@ -2695,10 +2684,10 @@ class bt {
2695
2684
  p * 8
2696
2685
  ), this.device.queue.writeBuffer(
2697
2686
  this.velocityBuffer,
2698
- S * 4,
2687
+ b * 4,
2699
2688
  // Offset in bytes (float32 = 4 bytes)
2700
2689
  this.particleVelocities,
2701
- S,
2690
+ b,
2702
2691
  p * 4
2703
2692
  );
2704
2693
  }
@@ -2789,13 +2778,13 @@ class bt {
2789
2778
  o * o + c * c + l * l
2790
2779
  );
2791
2780
  if (u > 1e-3) {
2792
- const h = this.config.particleSpeed * 2;
2793
- this.particleVelocities[i] = o / u * h, this.particleVelocities[i + 1] = c / u * h, this.particleVelocities[i + 2] = l / u * h;
2781
+ const m = this.config.particleSpeed * 2;
2782
+ this.particleVelocities[i] = o / u * m, this.particleVelocities[i + 1] = c / u * m, this.particleVelocities[i + 2] = l / u * m;
2794
2783
  } else {
2795
- const h = Math.sqrt(r * r + n * n + a * a);
2796
- if (h > 1e-3) {
2784
+ const m = Math.sqrt(r * r + n * n + a * a);
2785
+ if (m > 1e-3) {
2797
2786
  const p = this.config.particleSpeed * 2;
2798
- this.particleVelocities[i] = r / h * p, this.particleVelocities[i + 1] = n / h * p, this.particleVelocities[i + 2] = a / h * p;
2787
+ this.particleVelocities[i] = r / m * p, this.particleVelocities[i + 1] = n / m * p, this.particleVelocities[i + 2] = a / m * p;
2799
2788
  } else
2800
2789
  this.particleVelocities[i] = 0, this.particleVelocities[i + 1] = this.config.particleSpeed * 2, this.particleVelocities[i + 2] = 0;
2801
2790
  }
@@ -2840,16 +2829,16 @@ class bt {
2840
2829
  this.physics.setSoftBoundary(t);
2841
2830
  }
2842
2831
  }
2843
- class Hs {
2832
+ class Ws {
2844
2833
  constructor(t) {
2845
- this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new Ls({ loop: !!this.loop }), this.ready = !0;
2834
+ this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new js({ loop: !!this.loop }), this.ready = !0;
2846
2835
  }
2847
2836
  createParticleSystem(t = {}) {
2848
2837
  const e = this.systemCounter++, i = t.name || `System ${e + 1}`, r = {
2849
2838
  ...t,
2850
2839
  name: i,
2851
2840
  id: e
2852
- }, n = new bt(this.device, r);
2841
+ }, n = new vt(this.device, r);
2853
2842
  return this.particleSystems.push({
2854
2843
  system: n,
2855
2844
  config: r
@@ -2913,16 +2902,16 @@ class Hs {
2913
2902
  for (const { system: o, config: c } of this.particleSystems) {
2914
2903
  const l = c.keyframes;
2915
2904
  if (!(!l || c.keyframesEnabled === !1)) {
2916
- for (const u of js) {
2917
- const h = l[u];
2918
- if (h && h.length) {
2919
- const p = Ns(h, a);
2905
+ for (const u of Zs) {
2906
+ const m = l[u];
2907
+ if (m && m.length) {
2908
+ const p = Hs(m, a);
2920
2909
  p !== void 0 && (c[u] = p);
2921
2910
  }
2922
2911
  }
2923
2912
  if (l.particleColor && l.particleColor.length) {
2924
- const u = ks(l.particleColor, a);
2925
- u && (c.particleColor = u, o.updateAppearanceUniform());
2913
+ const u = c.particleColor, m = u && typeof u.length == "number" && u.length >= 3 ? u : void 0, p = qs(l.particleColor, a, m);
2914
+ p && (c.particleColor = p, o.updateAppearanceUniform());
2926
2915
  }
2927
2916
  }
2928
2917
  }
@@ -2973,7 +2962,7 @@ class Hs {
2973
2962
  const n = this.systemCounter++, a = {
2974
2963
  ...r,
2975
2964
  id: n
2976
- }, o = new bt(this.device, a);
2965
+ }, o = new vt(this.device, a);
2977
2966
  this.particleSystems.push({
2978
2967
  system: o,
2979
2968
  config: a
@@ -2991,7 +2980,7 @@ class Hs {
2991
2980
  try {
2992
2981
  let a = null;
2993
2982
  if (n.glbModelData)
2994
- a = fi(n.glbModelData);
2983
+ a = mi(n.glbModelData);
2995
2984
  else if (n.glbFileName) {
2996
2985
  const o = await fetch(`/${n.glbFileName}`);
2997
2986
  o.ok ? a = await o.arrayBuffer() : console.warn(`GLB file not found: ${n.glbFileName}`);
@@ -2999,7 +2988,7 @@ class Hs {
2999
2988
  if (a) {
3000
2989
  if (await r.setGLBModel(a), n.animationIndex !== void 0 && r.glbAnimator && r.glbAnimator.setAnimation(n.animationIndex), n.animationSpeed !== void 0 && r.glbAnimator && (r.glbAnimator.speed = n.animationSpeed), n.animationLoop !== void 0 && r.glbAnimator && (r.glbAnimator.loop = n.animationLoop), n.useGlbTexture && (n.textureEnabled = !0), n.useGlbTexture && ((e = r.glbMeshData) != null && e.hasBaseColorTexture))
3001
2990
  try {
3002
- const o = await oi(a);
2991
+ const o = await fi(a);
3003
2992
  if (o) {
3004
2993
  const c = await createImageBitmap(o.imageBlob);
3005
2994
  await r.setTexture(c), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${n.name}`);
@@ -3062,8 +3051,12 @@ class Hs {
3062
3051
  o.attractorPosition[0] + e[0],
3063
3052
  o.attractorPosition[1] + e[1],
3064
3053
  o.attractorPosition[2] + e[2]
3054
+ ]), o.confinementEnabled && o.confinementSpace === "world" && Array.isArray(o.confinementCenter) && (l.confinementCenter = [
3055
+ (o.confinementCenter[0] || 0) + e[0],
3056
+ (o.confinementCenter[1] || 0) + e[1],
3057
+ (o.confinementCenter[2] || 0) + e[2]
3065
3058
  ]);
3066
- const u = new bt(this.device, l);
3059
+ const u = new vt(this.device, l);
3067
3060
  this.particleSystems.push({
3068
3061
  system: u,
3069
3062
  config: l
@@ -3082,7 +3075,7 @@ class Hs {
3082
3075
  try {
3083
3076
  let l = null;
3084
3077
  if (c.glbModelData)
3085
- l = fi(c.glbModelData);
3078
+ l = mi(c.glbModelData);
3086
3079
  else if (c.glbFileName) {
3087
3080
  const u = await fetch(`/${c.glbFileName}`);
3088
3081
  u.ok ? l = await u.arrayBuffer() : console.warn(`GLB file not found: ${c.glbFileName}`);
@@ -3090,10 +3083,10 @@ class Hs {
3090
3083
  if (l) {
3091
3084
  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))
3092
3085
  try {
3093
- const u = await oi(l);
3086
+ const u = await fi(l);
3094
3087
  if (u) {
3095
- const h = await createImageBitmap(u.imageBlob);
3096
- await o.setTexture(h), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${c.name}`);
3088
+ const m = await createImageBitmap(u.imageBlob);
3089
+ await o.setTexture(m), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${c.name}`);
3097
3090
  }
3098
3091
  } catch (u) {
3099
3092
  console.warn(`Failed to restore GLB texture for ${c.name}:`, u), c.useGlbTexture = !1;
@@ -3107,8 +3100,8 @@ class Hs {
3107
3100
  if (c.textureEnabled && !c.glbModelEnabled && c.textureImageData && !o._textureRestored)
3108
3101
  try {
3109
3102
  const l = new Image();
3110
- await new Promise((h, p) => {
3111
- l.onload = h, l.onerror = p, l.src = c.textureImageData;
3103
+ await new Promise((m, p) => {
3104
+ l.onload = m, l.onerror = p, l.src = c.textureImageData;
3112
3105
  });
3113
3106
  const u = await createImageBitmap(l);
3114
3107
  await o.setTexture(u), o._textureRestored = !0;
@@ -3123,7 +3116,7 @@ class Hs {
3123
3116
  }
3124
3117
  }
3125
3118
  }
3126
- async function qs(s) {
3119
+ async function Js(s) {
3127
3120
  if (!s)
3128
3121
  throw new Error("canvas is required for initWebGPU()");
3129
3122
  if (!navigator.gpu)
@@ -3135,30 +3128,30 @@ async function qs(s) {
3135
3128
  alphaMode: "premultiplied"
3136
3129
  }), { device: i, context: t, format: r, canvas: s };
3137
3130
  }
3138
- const le = "rgba16float";
3139
- function pi(s, t, e, i) {
3131
+ const oe = "rgba16float";
3132
+ function yi(s, t, e, i) {
3140
3133
  const r = s.createTexture({
3141
3134
  size: [e, i],
3142
- format: le,
3135
+ format: oe,
3143
3136
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
3144
3137
  mipLevelCount: 1,
3145
3138
  sampleCount: 1
3146
3139
  }), n = s.createTexture({
3147
3140
  size: [e, i],
3148
- format: le,
3141
+ format: oe,
3149
3142
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
3150
3143
  mipLevelCount: 1,
3151
3144
  sampleCount: 1
3152
3145
  }), a = s.createTexture({
3153
3146
  size: [e, i],
3154
- format: le,
3147
+ format: oe,
3155
3148
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
3156
3149
  mipLevelCount: 1,
3157
3150
  sampleCount: 1
3158
3151
  });
3159
3152
  return { sceneTexture: r, bloomTexA: n, bloomTexB: a };
3160
3153
  }
3161
- function hi(s, t, e) {
3154
+ function gi(s, t, e) {
3162
3155
  return s.createTexture({
3163
3156
  size: [t, e],
3164
3157
  format: "depth24plus",
@@ -3173,7 +3166,7 @@ function Ge(s, t, e) {
3173
3166
  });
3174
3167
  return new t.constructor(i.getMappedRange()).set(t), i.unmap(), i;
3175
3168
  }
3176
- const Zs = `
3169
+ const Qs = `
3177
3170
  struct Uniforms {
3178
3171
  transform: mat4x4<f32>,
3179
3172
  cameraPosition: vec3<f32>,
@@ -3235,7 +3228,7 @@ const Zs = `
3235
3228
 
3236
3229
  return finalColor;
3237
3230
  }
3238
- `, $s = `
3231
+ `, Ks = `
3239
3232
  struct Uniforms {
3240
3233
  transform: mat4x4<f32>,
3241
3234
  cameraPosition: vec3<f32>,
@@ -3471,7 +3464,7 @@ const Zs = `
3471
3464
  return finalColor;
3472
3465
  }
3473
3466
  `;
3474
- function Ws(s) {
3467
+ function er(s) {
3475
3468
  const t = s.createBindGroupLayout({
3476
3469
  entries: [
3477
3470
  {
@@ -3557,7 +3550,7 @@ function Ws(s) {
3557
3550
  object3dBindGroupLayout: r
3558
3551
  };
3559
3552
  }
3560
- function Js(s, t, e, i = {}) {
3553
+ function tr(s, t, e, i = {}) {
3561
3554
  const { depthCompare: r } = i, n = r || "less", {
3562
3555
  particleBindGroupLayout: a,
3563
3556
  bloomBindGroupLayout: o,
@@ -3565,22 +3558,22 @@ function Js(s, t, e, i = {}) {
3565
3558
  object3dBindGroupLayout: l
3566
3559
  } = e, u = s.createPipelineLayout({
3567
3560
  bindGroupLayouts: [a]
3568
- }), h = s.createPipelineLayout({
3561
+ }), m = s.createPipelineLayout({
3569
3562
  bindGroupLayouts: [o]
3570
3563
  }), p = s.createPipelineLayout({
3571
3564
  bindGroupLayouts: [c]
3572
3565
  }), d = s.createShaderModule({
3573
- code: ps
3574
- }), S = s.createShaderModule({
3575
- code: hs
3576
- }), R = s.createShaderModule({
3577
- code: ms
3578
- }), E = s.createShaderModule({
3579
3566
  code: ys
3580
- }), T = s.createShaderModule({
3581
- code: Zs
3567
+ }), b = s.createShaderModule({
3568
+ code: gs
3569
+ }), w = s.createShaderModule({
3570
+ code: bs
3571
+ }), M = s.createShaderModule({
3572
+ code: Ss
3573
+ }), R = s.createShaderModule({
3574
+ code: Qs
3582
3575
  }), x = s.createShaderModule({
3583
- code: $s
3576
+ code: Ks
3584
3577
  }), L = (W) => s.createRenderPipeline({
3585
3578
  layout: u,
3586
3579
  vertex: {
@@ -3648,7 +3641,7 @@ function Js(s, t, e, i = {}) {
3648
3641
  module: d,
3649
3642
  entryPoint: "fs_main",
3650
3643
  targets: [{
3651
- format: le,
3644
+ format: oe,
3652
3645
  blend: W
3653
3646
  }]
3654
3647
  },
@@ -3672,7 +3665,7 @@ function Js(s, t, e, i = {}) {
3672
3665
  dstFactor: "one-minus-src-alpha",
3673
3666
  operation: "add"
3674
3667
  }
3675
- }), B = L({
3668
+ }), T = L({
3676
3669
  color: {
3677
3670
  srcFactor: "src-alpha",
3678
3671
  dstFactor: "one",
@@ -3683,7 +3676,7 @@ function Js(s, t, e, i = {}) {
3683
3676
  dstFactor: "one-minus-src-alpha",
3684
3677
  operation: "add"
3685
3678
  }
3686
- }), M = s.createRenderPipeline({
3679
+ }), E = s.createRenderPipeline({
3687
3680
  layout: u,
3688
3681
  vertex: {
3689
3682
  module: d,
@@ -3750,7 +3743,7 @@ function Js(s, t, e, i = {}) {
3750
3743
  module: d,
3751
3744
  entryPoint: "fs_main",
3752
3745
  targets: [{
3753
- format: le,
3746
+ format: oe,
3754
3747
  writeMask: 0
3755
3748
  // No color write — depth only
3756
3749
  }]
@@ -3766,32 +3759,32 @@ function Js(s, t, e, i = {}) {
3766
3759
  format: "depth24plus"
3767
3760
  }
3768
3761
  }), F = s.createRenderPipeline({
3769
- layout: h,
3762
+ layout: m,
3770
3763
  vertex: {
3771
- module: S,
3764
+ module: b,
3772
3765
  entryPoint: "vs_main"
3773
3766
  },
3774
3767
  fragment: {
3775
- module: S,
3768
+ module: b,
3776
3769
  entryPoint: "fs_main",
3777
3770
  targets: [{
3778
- format: le
3771
+ format: oe
3779
3772
  }]
3780
3773
  },
3781
3774
  primitive: {
3782
3775
  topology: "triangle-list"
3783
3776
  }
3784
- }), N = s.createRenderPipeline({
3777
+ }), k = s.createRenderPipeline({
3785
3778
  layout: p,
3786
3779
  vertex: {
3787
- module: R,
3780
+ module: w,
3788
3781
  entryPoint: "vs_main"
3789
3782
  },
3790
3783
  fragment: {
3791
- module: R,
3784
+ module: w,
3792
3785
  entryPoint: "fs_main",
3793
3786
  targets: [{
3794
- format: le,
3787
+ format: oe,
3795
3788
  blend: {
3796
3789
  color: {
3797
3790
  srcFactor: "one",
@@ -3812,14 +3805,14 @@ function Js(s, t, e, i = {}) {
3812
3805
  }), Y = s.createRenderPipeline({
3813
3806
  layout: p,
3814
3807
  vertex: {
3815
- module: E,
3808
+ module: M,
3816
3809
  entryPoint: "vs_main"
3817
3810
  },
3818
3811
  fragment: {
3819
- module: E,
3812
+ module: M,
3820
3813
  entryPoint: "fs_main",
3821
3814
  targets: [{
3822
- format: le,
3815
+ format: oe,
3823
3816
  blend: {
3824
3817
  color: {
3825
3818
  srcFactor: "one",
@@ -3837,11 +3830,11 @@ function Js(s, t, e, i = {}) {
3837
3830
  primitive: {
3838
3831
  topology: "triangle-list"
3839
3832
  }
3840
- }), k = s.createShaderModule({ code: gs }), G = s.createRenderPipeline({
3833
+ }), N = s.createShaderModule({ code: xs }), G = s.createRenderPipeline({
3841
3834
  layout: p,
3842
- vertex: { module: k, entryPoint: "vs_main" },
3835
+ vertex: { module: N, entryPoint: "vs_main" },
3843
3836
  fragment: {
3844
- module: k,
3837
+ module: N,
3845
3838
  entryPoint: "fs_main",
3846
3839
  targets: [{
3847
3840
  format: t,
@@ -3852,12 +3845,12 @@ function Js(s, t, e, i = {}) {
3852
3845
  }]
3853
3846
  },
3854
3847
  primitive: { topology: "triangle-list" }
3855
- }), pe = s.createPipelineLayout({
3848
+ }), de = s.createPipelineLayout({
3856
3849
  bindGroupLayouts: [l]
3857
3850
  }), De = s.createRenderPipeline({
3858
- layout: pe,
3851
+ layout: de,
3859
3852
  vertex: {
3860
- module: T,
3853
+ module: R,
3861
3854
  entryPoint: "vs_main",
3862
3855
  buffers: [
3863
3856
  {
@@ -3882,10 +3875,10 @@ function Js(s, t, e, i = {}) {
3882
3875
  ]
3883
3876
  },
3884
3877
  fragment: {
3885
- module: T,
3878
+ module: R,
3886
3879
  entryPoint: "fs_main",
3887
3880
  targets: [{
3888
- format: le,
3881
+ format: oe,
3889
3882
  blend: {
3890
3883
  color: {
3891
3884
  srcFactor: "src-alpha",
@@ -3909,7 +3902,7 @@ function Js(s, t, e, i = {}) {
3909
3902
  depthCompare: n,
3910
3903
  format: "depth24plus"
3911
3904
  }
3912
- }), at = s.createRenderPipeline({
3905
+ }), ct = s.createRenderPipeline({
3913
3906
  layout: u,
3914
3907
  vertex: {
3915
3908
  module: x,
@@ -3987,7 +3980,7 @@ function Js(s, t, e, i = {}) {
3987
3980
  module: x,
3988
3981
  entryPoint: "fs_main",
3989
3982
  targets: [{
3990
- format: le,
3983
+ format: oe,
3991
3984
  blend: {
3992
3985
  color: {
3993
3986
  srcFactor: "src-alpha",
@@ -4014,17 +4007,17 @@ function Js(s, t, e, i = {}) {
4014
4007
  });
4015
4008
  return {
4016
4009
  particlePipeline: P,
4017
- particleAdditivePipeline: B,
4018
- particleDepthWritePipeline: M,
4010
+ particleAdditivePipeline: T,
4011
+ particleDepthWritePipeline: E,
4019
4012
  blurPipeline: F,
4020
- compositePipeline: N,
4013
+ compositePipeline: k,
4021
4014
  directRenderPipeline: Y,
4022
4015
  finalCompositePipeline: G,
4023
4016
  object3dPipeline: De,
4024
- glbMeshPipeline: at
4017
+ glbMeshPipeline: ct
4025
4018
  };
4026
4019
  }
4027
- function St(s, t, e, i) {
4020
+ function Pt(s, t, e, i) {
4028
4021
  const {
4029
4022
  uniformBuffer: r,
4030
4023
  appearanceUniformBuffer: n,
@@ -4034,7 +4027,7 @@ function St(s, t, e, i) {
4034
4027
  } = e, {
4035
4028
  sceneTexture: l,
4036
4029
  bloomTexA: u,
4037
- bloomTexB: h
4030
+ bloomTexB: m
4038
4031
  } = i, p = s.createBindGroup({
4039
4032
  layout: s.createBindGroupLayout({
4040
4033
  entries: [
@@ -4094,7 +4087,7 @@ function St(s, t, e, i) {
4094
4087
  resource: { buffer: a }
4095
4088
  }
4096
4089
  ]
4097
- }), S = s.createBindGroup({
4090
+ }), b = s.createBindGroup({
4098
4091
  layout: s.createBindGroupLayout({
4099
4092
  entries: [
4100
4093
  {
@@ -4128,7 +4121,7 @@ function St(s, t, e, i) {
4128
4121
  resource: { buffer: o }
4129
4122
  }
4130
4123
  ]
4131
- }), R = s.createBindGroup({
4124
+ }), w = s.createBindGroup({
4132
4125
  layout: s.createBindGroupLayout({
4133
4126
  entries: [
4134
4127
  {
@@ -4164,14 +4157,14 @@ function St(s, t, e, i) {
4164
4157
  },
4165
4158
  {
4166
4159
  binding: 2,
4167
- resource: h.createView()
4160
+ resource: m.createView()
4168
4161
  },
4169
4162
  {
4170
4163
  binding: 3,
4171
4164
  resource: { buffer: c }
4172
4165
  }
4173
4166
  ]
4174
- }), E = s.createBindGroup({
4167
+ }), M = s.createBindGroup({
4175
4168
  layout: s.createBindGroupLayout({
4176
4169
  entries: [
4177
4170
  {
@@ -4207,7 +4200,7 @@ function St(s, t, e, i) {
4207
4200
  },
4208
4201
  {
4209
4202
  binding: 2,
4210
- resource: h.createView()
4203
+ resource: m.createView()
4211
4204
  },
4212
4205
  {
4213
4206
  binding: 3,
@@ -4218,12 +4211,12 @@ function St(s, t, e, i) {
4218
4211
  return {
4219
4212
  particleBindGroup: p,
4220
4213
  horizontalBlurBindGroup: d,
4221
- verticalBlurBindGroup: S,
4222
- compositeBindGroup: R,
4223
- directRenderBindGroup: E
4214
+ verticalBlurBindGroup: b,
4215
+ compositeBindGroup: w,
4216
+ directRenderBindGroup: M
4224
4217
  };
4225
4218
  }
4226
- function Qs(s) {
4219
+ function ir(s) {
4227
4220
  return s.createSampler({
4228
4221
  magFilter: "linear",
4229
4222
  minFilter: "linear",
@@ -4233,7 +4226,7 @@ function Qs(s) {
4233
4226
  maxAnisotropy: 16
4234
4227
  });
4235
4228
  }
4236
- function Ks() {
4229
+ function sr() {
4237
4230
  const s = new Float32Array([
4238
4231
  // Front face (z = 0.5)
4239
4232
  -0.5,
@@ -4431,13 +4424,13 @@ function Ks() {
4431
4424
  ]);
4432
4425
  return { vertices: s, indices: t };
4433
4426
  }
4434
- function er(s = 16, t = 16) {
4427
+ function rr(s = 16, t = 16) {
4435
4428
  const e = [], i = [];
4436
4429
  for (let r = 0; r <= s; r++) {
4437
4430
  const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
4438
4431
  for (let c = 0; c <= t; c++) {
4439
- const l = c * 2 * Math.PI / t, u = Math.sin(l), p = Math.cos(l) * a, d = o, S = u * a;
4440
- e.push(p * 0.5, d * 0.5, S * 0.5), e.push(p, d, S);
4432
+ const l = c * 2 * Math.PI / t, u = Math.sin(l), p = Math.cos(l) * a, d = o, b = u * a;
4433
+ e.push(p * 0.5, d * 0.5, b * 0.5), e.push(p, d, b);
4441
4434
  }
4442
4435
  }
4443
4436
  for (let r = 0; r < s; r++)
@@ -4450,7 +4443,7 @@ function er(s = 16, t = 16) {
4450
4443
  indices: new Uint16Array(i)
4451
4444
  };
4452
4445
  }
4453
- class tr {
4446
+ class nr {
4454
4447
  constructor(t, e, i, r, n) {
4455
4448
  this.id = t, this.type = e, this.position = i, this.scale = r, this.color = n, this.rotation = [0, 0, 0];
4456
4449
  }
@@ -4584,7 +4577,7 @@ class tr {
4584
4577
  return i;
4585
4578
  }
4586
4579
  }
4587
- class cr {
4580
+ class pr {
4588
4581
  constructor(t) {
4589
4582
  this.device = t, this.objects = [], this.nextId = 0, this.initializeGeometry(), this.onObjectAdded = null, this.onObjectRemoved = null, this.onObjectUpdated = null;
4590
4583
  }
@@ -4592,7 +4585,7 @@ class cr {
4592
4585
  * Initialize geometry buffers for cube and sphere
4593
4586
  */
4594
4587
  initializeGeometry() {
4595
- const t = Ks(), e = er(16, 16);
4588
+ const t = sr(), e = rr(16, 16);
4596
4589
  this.cubeVertexBuffer = Ge(
4597
4590
  this.device,
4598
4591
  t.vertices,
@@ -4620,7 +4613,7 @@ class cr {
4620
4613
  * @returns {Object3D} The created object
4621
4614
  */
4622
4615
  addObject(t, e = [0, 0, 0], i = [1, 1, 1], r = [1, 1, 1, 1]) {
4623
- const n = new tr(this.nextId++, t, e, i, r);
4616
+ const n = new nr(this.nextId++, t, e, i, r);
4624
4617
  return n.uniformBuffer = this.device.createBuffer({
4625
4618
  size: 192,
4626
4619
  // modelMatrix (64) + normalMatrix (64) + color (16) + padding (48)
@@ -4709,21 +4702,21 @@ class cr {
4709
4702
  }
4710
4703
  }
4711
4704
  }
4712
- function ur(s) {
4705
+ function hr(s) {
4713
4706
  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;
4714
4707
  return [t, e, i];
4715
4708
  }
4716
- function dr(s) {
4709
+ function mr(s) {
4717
4710
  if (!s) return "#ffffff";
4718
4711
  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");
4719
4712
  return `#${t}${e}${i}`;
4720
4713
  }
4721
- function fr(s, t, e) {
4722
- const i = mi([
4714
+ function yr(s, t, e) {
4715
+ const i = bi([
4723
4716
  s[0] - t[0],
4724
4717
  s[1] - t[1],
4725
4718
  s[2] - t[2]
4726
- ]), r = mi(yi(e, i)), n = yi(i, r);
4719
+ ]), r = bi(Si(e, i)), n = Si(i, r);
4727
4720
  return new Float32Array([
4728
4721
  r[0],
4729
4722
  n[0],
@@ -4737,13 +4730,13 @@ function fr(s, t, e) {
4737
4730
  n[2],
4738
4731
  i[2],
4739
4732
  0,
4740
- -xt(r, s),
4741
- -xt(n, s),
4742
- -xt(i, s),
4733
+ -_t(r, s),
4734
+ -_t(n, s),
4735
+ -_t(i, s),
4743
4736
  1
4744
4737
  ]);
4745
4738
  }
4746
- function pr(s, t = Math.PI / 4) {
4739
+ function gr(s, t = Math.PI / 4) {
4747
4740
  const r = 1 / Math.tan(t / 2);
4748
4741
  return new Float32Array([
4749
4742
  r * s,
@@ -4764,21 +4757,21 @@ function pr(s, t = Math.PI / 4) {
4764
4757
  0
4765
4758
  ]);
4766
4759
  }
4767
- function mi(s) {
4760
+ function bi(s) {
4768
4761
  const t = Math.sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2]);
4769
4762
  return [s[0] / t, s[1] / t, s[2] / t];
4770
4763
  }
4771
- function yi(s, t) {
4764
+ function Si(s, t) {
4772
4765
  return [
4773
4766
  s[1] * t[2] - s[2] * t[1],
4774
4767
  s[2] * t[0] - s[0] * t[2],
4775
4768
  s[0] * t[1] - s[1] * t[0]
4776
4769
  ];
4777
4770
  }
4778
- function xt(s, t) {
4771
+ function _t(s, t) {
4779
4772
  return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
4780
4773
  }
4781
- function ir(s, t) {
4774
+ function ar(s, t) {
4782
4775
  const e = new Float32Array(16);
4783
4776
  for (let i = 0; i < 4; i++)
4784
4777
  for (let r = 0; r < 4; r++) {
@@ -4789,7 +4782,7 @@ function ir(s, t) {
4789
4782
  }
4790
4783
  return e;
4791
4784
  }
4792
- const Pt = 1481005640, vi = 1, Pi = 1313821514, _i = 5130562, qe = "$hzfxAsset", wi = (s) => typeof atob == "function" ? Uint8Array.from(atob(s), (t) => t.charCodeAt(0)) : new Uint8Array(Buffer.from(s, "base64")), gi = (s) => {
4785
+ const Bt = 1481005640, wi = 1, Bi = 1313821514, Mi = 5130562, Ze = "$hzfxAsset", Ri = (s) => typeof atob == "function" ? Uint8Array.from(atob(s), (t) => t.charCodeAt(0)) : new Uint8Array(Buffer.from(s, "base64")), xi = (s) => {
4793
4786
  if (typeof btoa == "function") {
4794
4787
  let t = "";
4795
4788
  for (let e = 0; e < s.length; e++) t += String.fromCharCode(s[e]);
@@ -4797,94 +4790,94 @@ const Pt = 1481005640, vi = 1, Pi = 1313821514, _i = 5130562, qe = "$hzfxAsset",
4797
4790
  }
4798
4791
  return Buffer.from(s).toString("base64");
4799
4792
  };
4800
- function sr(s) {
4801
- 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) ? wi(r) : new TextEncoder().encode(decodeURIComponent(r));
4793
+ function or(s) {
4794
+ 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) ? Ri(r) : new TextEncoder().encode(decodeURIComponent(r));
4802
4795
  return { mime: i, bytes: a };
4803
4796
  }
4804
- function bi(s) {
4797
+ function vi(s) {
4805
4798
  return (4 - s % 4) % 4;
4806
4799
  }
4807
- async function rr(s, t = {}) {
4800
+ async function lr(s, t = {}) {
4808
4801
  const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
4809
4802
  let a = 0;
4810
- const o = (B, M, F) => {
4811
- const N = a, Y = B.length;
4812
- r.push({ offset: N, length: Y, mime: M, kind: F }), n.push(B), a += Y;
4813
- const k = bi(Y);
4814
- return k && (n.push(new Uint8Array(k)), a += k), r.length - 1;
4803
+ const o = (T, E, F) => {
4804
+ const k = a, Y = T.length;
4805
+ r.push({ offset: k, length: Y, mime: E, kind: F }), n.push(T), a += Y;
4806
+ const N = vi(Y);
4807
+ return N && (n.push(new Uint8Array(N)), a += N), r.length - 1;
4815
4808
  }, c = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", l = [];
4816
- for (const B of s.systems || []) {
4817
- const M = { ...B };
4818
- if (typeof M.textureImageData == "string" && M.textureImageData.startsWith("data:")) {
4819
- let { mime: F, bytes: N } = sr(M.textureImageData);
4809
+ for (const T of s.systems || []) {
4810
+ const E = { ...T };
4811
+ if (typeof E.textureImageData == "string" && E.textureImageData.startsWith("data:")) {
4812
+ let { mime: F, bytes: k } = or(E.textureImageData);
4820
4813
  if (c && F !== "image/webp")
4821
4814
  try {
4822
- const Y = await createImageBitmap(new Blob([N], { type: F })), k = new OffscreenCanvas(Y.width, Y.height);
4823
- k.getContext("2d").drawImage(Y, 0, 0);
4824
- const G = await k.convertToBlob({ type: "image/webp", quality: i }), pe = new Uint8Array(await G.arrayBuffer());
4825
- pe.length < N.length && (N = pe, F = "image/webp");
4815
+ const Y = await createImageBitmap(new Blob([k], { type: F })), N = new OffscreenCanvas(Y.width, Y.height);
4816
+ N.getContext("2d").drawImage(Y, 0, 0);
4817
+ const G = await N.convertToBlob({ type: "image/webp", quality: i }), de = new Uint8Array(await G.arrayBuffer());
4818
+ de.length < k.length && (k = de, F = "image/webp");
4826
4819
  } catch {
4827
4820
  }
4828
- M.textureImageData = { [qe]: o(N, F, "texture") };
4821
+ E.textureImageData = { [Ze]: o(k, F, "texture") };
4829
4822
  }
4830
- if (typeof M.glbModelData == "string" && M.glbModelData.length > 0) {
4831
- const F = wi(M.glbModelData);
4832
- M.glbModelData = { [qe]: o(F, "model/gltf-binary", "glb") };
4823
+ if (typeof E.glbModelData == "string" && E.glbModelData.length > 0) {
4824
+ const F = Ri(E.glbModelData);
4825
+ E.glbModelData = { [Ze]: o(F, "model/gltf-binary", "glb") };
4833
4826
  }
4834
- l.push(M);
4827
+ l.push(E);
4835
4828
  }
4836
- const u = { ...s, systems: l, assets: r }, h = new TextEncoder().encode(JSON.stringify(u)), p = bi(h.length), d = new Uint8Array(a);
4837
- let S = 0;
4838
- for (const B of n)
4839
- d.set(B, S), S += B.length;
4840
- const R = h.length + p, E = 20 + R + 8 + a, T = new ArrayBuffer(E), x = new DataView(T), L = new Uint8Array(T);
4829
+ const u = { ...s, systems: l, assets: r }, m = new TextEncoder().encode(JSON.stringify(u)), p = vi(m.length), d = new Uint8Array(a);
4830
+ let b = 0;
4831
+ for (const T of n)
4832
+ d.set(T, b), b += T.length;
4833
+ const w = m.length + p, M = 20 + w + 8 + a, R = new ArrayBuffer(M), x = new DataView(R), L = new Uint8Array(R);
4841
4834
  let P = 0;
4842
- x.setUint32(P, Pt, !0), P += 4, x.setUint32(P, vi, !0), P += 4, x.setUint32(P, E, !0), P += 4, x.setUint32(P, R, !0), P += 4, x.setUint32(P, Pi, !0), P += 4, L.set(h, P), P += h.length;
4843
- for (let B = 0; B < p; B++) L[P++] = 32;
4844
- return x.setUint32(P, a, !0), P += 4, x.setUint32(P, _i, !0), P += 4, L.set(d, P), P += a, T;
4835
+ x.setUint32(P, Bt, !0), P += 4, x.setUint32(P, wi, !0), P += 4, x.setUint32(P, M, !0), P += 4, x.setUint32(P, w, !0), P += 4, x.setUint32(P, Bi, !0), P += 4, L.set(m, P), P += m.length;
4836
+ for (let T = 0; T < p; T++) L[P++] = 32;
4837
+ return x.setUint32(P, a, !0), P += 4, x.setUint32(P, Mi, !0), P += 4, L.set(d, P), P += a, R;
4845
4838
  }
4846
- function Bi(s) {
4847
- return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === Pt;
4839
+ function Ti(s) {
4840
+ return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === Bt;
4848
4841
  }
4849
- function Mi(s) {
4842
+ function Ei(s) {
4850
4843
  const t = new DataView(s);
4851
- if (t.getUint32(0, !0) !== Pt) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
4844
+ if (t.getUint32(0, !0) !== Bt) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
4852
4845
  const e = t.getUint32(4, !0);
4853
- if (e !== vi) throw new Error(`[unpackHZFX] unsupported version ${e}`);
4846
+ if (e !== wi) throw new Error(`[unpackHZFX] unsupported version ${e}`);
4854
4847
  let i = 12, r = null, n = -1;
4855
4848
  const a = new Uint8Array(s);
4856
4849
  for (; i + 8 <= s.byteLength; ) {
4857
4850
  const p = t.getUint32(i, !0);
4858
4851
  i += 4;
4859
4852
  const d = t.getUint32(i, !0);
4860
- i += 4, d === Pi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + p))) : d === _i && (n = i), i += p;
4853
+ i += 4, d === Bi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + p))) : d === Mi && (n = i), i += p;
4861
4854
  }
4862
4855
  if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
4863
4856
  const o = r.assets || [], c = (p) => {
4864
4857
  const d = o[p];
4865
4858
  return !d || n < 0 ? null : { ...d, bytes: a.subarray(n + d.offset, n + d.offset + d.length) };
4866
- }, l = (p) => p && typeof p == "object" && typeof p[qe] == "number", u = (r.systems || []).map((p) => {
4859
+ }, l = (p) => p && typeof p == "object" && typeof p[Ze] == "number", u = (r.systems || []).map((p) => {
4867
4860
  const d = { ...p };
4868
4861
  if (l(d.textureImageData)) {
4869
- const S = c(d.textureImageData[qe]);
4870
- d.textureImageData = S ? `data:${S.mime};base64,${gi(S.bytes)}` : void 0;
4862
+ const b = c(d.textureImageData[Ze]);
4863
+ d.textureImageData = b ? `data:${b.mime};base64,${xi(b.bytes)}` : void 0;
4871
4864
  }
4872
4865
  if (l(d.glbModelData)) {
4873
- const S = c(d.glbModelData[qe]);
4874
- d.glbModelData = S ? gi(S.bytes) : void 0;
4866
+ const b = c(d.glbModelData[Ze]);
4867
+ d.glbModelData = b ? xi(b.bytes) : void 0;
4875
4868
  }
4876
4869
  return d;
4877
- }), h = { ...r, systems: u };
4878
- return delete h.assets, h;
4870
+ }), m = { ...r, systems: u };
4871
+ return delete m.assets, m;
4879
4872
  }
4880
- function nr(s) {
4873
+ function cr(s) {
4881
4874
  const t = new Uint8Array(s);
4882
4875
  let e = "";
4883
4876
  for (let i = 0; i < t.byteLength; i++)
4884
4877
  e += String.fromCharCode(t[i]);
4885
4878
  return btoa(e);
4886
4879
  }
4887
- function ar(s) {
4880
+ function ur(s) {
4888
4881
  return {
4889
4882
  name: s.name,
4890
4883
  id: s.id,
@@ -5062,7 +5055,7 @@ function ar(s) {
5062
5055
  displayUnit: s.displayUnit || "m"
5063
5056
  };
5064
5057
  }
5065
- async function hr(s, t, e = "hzfx") {
5058
+ async function br(s, t, e = "hzfx") {
5066
5059
  if (!s || !s.particleSystems || s.particleSystems.length === 0) {
5067
5060
  alert("No particle systems to save.");
5068
5061
  return;
@@ -5071,12 +5064,12 @@ async function hr(s, t, e = "hzfx") {
5071
5064
  const i = {
5072
5065
  version: "1.0",
5073
5066
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
5074
- systems: s.particleSystems.map(({ config: u, system: h }) => ({
5075
- ...ar(u),
5067
+ systems: s.particleSystems.map(({ config: u, system: m }) => ({
5068
+ ...ur(u),
5076
5069
  // single source of truth for config fields
5077
5070
  // Binary assets embedded so replaceSystems() can restore them
5078
5071
  textureImageData: u.textureEnabled && !u.glbModelEnabled && u.textureImageData ? u.textureImageData : void 0,
5079
- glbModelData: u.glbModelEnabled && h.glbRawArrayBuffer ? nr(h.glbRawArrayBuffer) : void 0
5072
+ glbModelData: u.glbModelEnabled && m.glbRawArrayBuffer ? cr(m.glbRawArrayBuffer) : void 0
5080
5073
  })),
5081
5074
  activeSystemIndex: s.activeSystemIndex,
5082
5075
  loop: s.loop || !1
@@ -5084,7 +5077,7 @@ async function hr(s, t, e = "hzfx") {
5084
5077
  }, r = e === "json" ? "json" : "hzfx";
5085
5078
  let n;
5086
5079
  if (r === "hzfx") {
5087
- const u = await rr(i, { textureFormat: "webp" });
5080
+ const u = await lr(i, { textureFormat: "webp" });
5088
5081
  n = new Blob([u], { type: "application/octet-stream" });
5089
5082
  } else
5090
5083
  n = new Blob([JSON.stringify(i, null, 2)], { type: "application/json" });
@@ -5101,7 +5094,7 @@ async function hr(s, t, e = "hzfx") {
5101
5094
  console.error("Error saving scene:", i), alert("Error saving scene. See console for details.");
5102
5095
  }
5103
5096
  }
5104
- function mr(s) {
5097
+ function Sr(s) {
5105
5098
  return new Promise((t, e) => {
5106
5099
  try {
5107
5100
  const i = s.target.files[0];
@@ -5114,7 +5107,7 @@ function mr(s) {
5114
5107
  try {
5115
5108
  const a = n.target.result;
5116
5109
  let o;
5117
- if (Bi(a) ? o = Mi(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
5110
+ if (Ti(a) ? o = Ei(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
5118
5111
  throw new Error("No valid particle systems found in the file");
5119
5112
  t({
5120
5113
  systems: o.systems.slice(),
@@ -5132,7 +5125,7 @@ function mr(s) {
5132
5125
  }
5133
5126
  });
5134
5127
  }
5135
- async function yr(s) {
5128
+ async function xr(s) {
5136
5129
  if (!s || typeof s != "string")
5137
5130
  throw new Error("[fetchPreset] url must be a non-empty string");
5138
5131
  const t = await fetch(s);
@@ -5140,7 +5133,7 @@ async function yr(s) {
5140
5133
  throw new Error(`[fetchPreset] HTTP ${t.status}: ${t.statusText}`);
5141
5134
  const e = await t.arrayBuffer();
5142
5135
  let i;
5143
- if (Bi(e) ? i = Mi(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
5136
+ if (Ti(e) ? i = Ei(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
5144
5137
  throw new Error('[fetchPreset] Invalid preset: "systems" must be a non-empty array');
5145
5138
  return {
5146
5139
  version: i.version,
@@ -5148,7 +5141,7 @@ async function yr(s) {
5148
5141
  activeSystemIndex: i.activeSystemIndex ?? 0
5149
5142
  };
5150
5143
  }
5151
- const or = (s) => `
5144
+ const dr = (s) => `
5152
5145
  @vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
5153
5146
  var p = array<vec2f, 3>(vec2f(-1.0, -3.0), vec2f(-1.0, 1.0), vec2f(3.0, 1.0));
5154
5147
  return vec4f(p[i], 0.0, 1.0);
@@ -5158,51 +5151,51 @@ const or = (s) => `
5158
5151
  return textureLoad(src, vec2i(pos.xy), 0);
5159
5152
  }
5160
5153
  `;
5161
- async function gr(s, t = {}) {
5154
+ async function vr(s, t = {}) {
5162
5155
  const { getSceneDepth: e = null, autoRespawn: i = !0 } = t;
5163
5156
  let r, n, a;
5164
5157
  const o = !!(s && s.device && s.context);
5165
- o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await qs(a));
5166
- const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new Hs(r), u = { layouts: {}, pipelines: {} };
5167
- function h(f) {
5168
- const m = f ? "ms" : "ss";
5169
- if (!u.pipelines[m]) {
5170
- const b = r.createShaderModule({ code: or(f) }), g = r.createBindGroupLayout({
5158
+ o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await Js(a));
5159
+ const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new Ws(r), u = { layouts: {}, pipelines: {} };
5160
+ function m(f) {
5161
+ const h = f ? "ms" : "ss";
5162
+ if (!u.pipelines[h]) {
5163
+ const S = r.createShaderModule({ code: dr(f) }), g = r.createBindGroupLayout({
5171
5164
  entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: f } }]
5172
5165
  });
5173
- u.layouts[m] = g, u.pipelines[m] = r.createRenderPipeline({
5166
+ u.layouts[h] = g, u.pipelines[h] = r.createRenderPipeline({
5174
5167
  layout: r.createPipelineLayout({ bindGroupLayouts: [g] }),
5175
- vertex: { module: b, entryPoint: "vs" },
5176
- fragment: { module: b, entryPoint: "fs", targets: [] },
5168
+ vertex: { module: S, entryPoint: "vs" },
5169
+ fragment: { module: S, entryPoint: "fs", targets: [] },
5177
5170
  primitive: { topology: "triangle-list" },
5178
5171
  depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
5179
5172
  });
5180
5173
  }
5181
- return { pipeline: u.pipelines[m], layout: u.layouts[m] };
5174
+ return { pipeline: u.pipelines[h], layout: u.layouts[h] };
5182
5175
  }
5183
5176
  const p = {
5184
5177
  bloomSourceTextures: {},
5185
5178
  bloomCompositeTextures: {},
5186
5179
  combinedTexture: null,
5187
- getBloomSourceTexture(f, m, b) {
5180
+ getBloomSourceTexture(f, h, S) {
5188
5181
  return this.bloomSourceTextures[f] || (this.bloomSourceTextures[f] = r.createTexture({
5189
- size: [m, b],
5182
+ size: [h, S],
5190
5183
  format: "rgba16float",
5191
5184
  // HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
5192
5185
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
5193
5186
  })), this.bloomSourceTextures[f];
5194
5187
  },
5195
- getBloomCompositeTexture(f, m, b) {
5188
+ getBloomCompositeTexture(f, h, S) {
5196
5189
  return this.bloomCompositeTextures[f] || (this.bloomCompositeTextures[f] = r.createTexture({
5197
- size: [m, b],
5190
+ size: [h, S],
5198
5191
  format: "rgba16float",
5199
5192
  // HDR chain
5200
5193
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
5201
5194
  })), this.bloomCompositeTextures[f];
5202
5195
  },
5203
- getCombinedTexture(f, m) {
5196
+ getCombinedTexture(f, h) {
5204
5197
  return this.combinedTexture || (this.combinedTexture = r.createTexture({
5205
- size: [f, m],
5198
+ size: [f, h],
5206
5199
  format: "rgba16float",
5207
5200
  // HDR chain — tonemapped to canvas in the final pass
5208
5201
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
@@ -5227,166 +5220,166 @@ async function gr(s, t = {}) {
5227
5220
  clear() {
5228
5221
  this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
5229
5222
  }
5230
- }, S = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), R = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), E = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), T = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), x = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), L = Ge(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), P = {}, B = () => Ge(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);
5223
+ }, b = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), w = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), M = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), R = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), x = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), L = Ge(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), P = {}, T = () => Ge(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);
5231
5224
  l.onSystemCreated = (f) => {
5232
- P[f] || (P[f] = B());
5225
+ P[f] || (P[f] = T());
5233
5226
  };
5234
- const M = 4e4, F = new Float32Array(M * 8), N = new Float32Array(M * 4), Y = new Float32Array(M * 4), k = r.createBuffer({ size: M * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), G = r.createBuffer({ size: M * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), pe = r.createBuffer({ size: M * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), De = /* @__PURE__ */ new Map(), at = 8, W = [];
5235
- function _t(f) {
5236
- for (const m of W) if (m.ids.has(f)) return m;
5227
+ const E = 4e4, F = new Float32Array(E * 8), k = new Float32Array(E * 4), Y = new Float32Array(E * 4), N = r.createBuffer({ size: E * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), G = r.createBuffer({ size: E * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), de = r.createBuffer({ size: E * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), De = /* @__PURE__ */ new Map(), ct = 8, W = [];
5228
+ function Mt(f) {
5229
+ for (const h of W) if (h.ids.has(f)) return h;
5237
5230
  return null;
5238
5231
  }
5239
- function Ri(f, m) {
5232
+ function Ci(f, h) {
5240
5233
  if (!f.pos) return;
5241
- f.hist.push({ t: m, x: f.pos[0], y: f.pos[1], z: f.pos[2] });
5242
- const b = m - at;
5243
- for (; f.hist.length > 2 && f.hist[0].t < b; ) f.hist.shift();
5234
+ f.hist.push({ t: h, x: f.pos[0], y: f.pos[1], z: f.pos[2] });
5235
+ const S = h - ct;
5236
+ for (; f.hist.length > 2 && f.hist[0].t < S; ) f.hist.shift();
5244
5237
  }
5245
- function wt(f, m, b) {
5238
+ function Rt(f, h, S) {
5246
5239
  const g = f.hist;
5247
5240
  if (g.length === 0) {
5248
5241
  const H = f.pos;
5249
- return H && (b[0] = H[0], b[1] = H[1], b[2] = H[2]), b;
5242
+ return H && (S[0] = H[0], S[1] = H[1], S[2] = H[2]), S;
5250
5243
  }
5251
5244
  let v;
5252
- if (m >= g[g.length - 1].t)
5253
- return v = g[g.length - 1], b[0] = v.x, b[1] = v.y, b[2] = v.z, b;
5254
- if (m <= g[0].t)
5255
- return v = g[0], b[0] = v.x, b[1] = v.y, b[2] = v.z, b;
5245
+ if (h >= g[g.length - 1].t)
5246
+ return v = g[g.length - 1], S[0] = v.x, S[1] = v.y, S[2] = v.z, S;
5247
+ if (h <= g[0].t)
5248
+ return v = g[0], S[0] = v.x, S[1] = v.y, S[2] = v.z, S;
5256
5249
  for (let H = g.length - 1; H > 0; H--)
5257
- if (g[H - 1].t <= m) {
5258
- const j = g[H - 1], Q = g[H], Z = (m - j.t) / Math.max(1e-6, Q.t - j.t);
5259
- return b[0] = j.x + (Q.x - j.x) * Z, b[1] = j.y + (Q.y - j.y) * Z, b[2] = j.z + (Q.z - j.z) * Z, b;
5250
+ if (g[H - 1].t <= h) {
5251
+ const j = g[H - 1], Q = g[H], Z = (h - j.t) / Math.max(1e-6, Q.t - j.t);
5252
+ return S[0] = j.x + (Q.x - j.x) * Z, S[1] = j.y + (Q.y - j.y) * Z, S[2] = j.z + (Q.z - j.z) * Z, S;
5260
5253
  }
5261
- return v = g[0], b[0] = v.x, b[1] = v.y, b[2] = v.z, b;
5254
+ return v = g[0], S[0] = v.x, S[1] = v.y, S[2] = v.z, S;
5262
5255
  }
5263
- const Ti = 0.41421356;
5264
- function Ei() {
5256
+ const Ai = 0.41421356;
5257
+ function Ui() {
5265
5258
  De.clear();
5266
- let f = 0, m = 0;
5259
+ let f = 0, h = 0;
5267
5260
  A.position[0], A.position[1], A.position[2];
5268
- for (const { system: b, config: g } of l.particleSystems) {
5261
+ for (const { system: S, config: g } of l.particleSystems) {
5269
5262
  if (!g.emissionTrailEnabled || g.hidden || g.glbModelEnabled) continue;
5270
- b.readbackAndProcessParticles();
5271
- const v = b.particleData, H = b.particleVelocities, j = b.activeParticles;
5263
+ S.readbackAndProcessParticles();
5264
+ const v = S.particleData, H = S.particleVelocities, j = S.activeParticles;
5272
5265
  if (!v || !H || j <= 0) continue;
5273
- const Q = g.emissionTrailMode === "particles", Z = f, Ae = g.emissionTrailDuration ?? 1, y = g.opacity ?? 1, w = g.particleSize ?? 0.5, U = g.bloomIntensity || 1, I = Math.max(1, Math.min(64, g.emissionTrailSegments ?? 8)), D = g.emissionTrailShape || "straight", J = g.followSystemTranslation ?? !0, K = b._simPosition, X = J && K ? K[0] : 0, Ke = J && K ? K[1] : 0, Ot = J && K ? K[2] : 0, Ue = b._simVelocity, Lt = Ue ? Ue[0] : 0, ts = Ue ? Ue[1] : 0, Xt = Ue ? Ue[2] : 0, Ve = _t(g.id), Nt = !!(J && Ve && Ve.hist && Ve.hist.length > 1);
5274
- for (let et = 0; et < j; et++) {
5275
- const ye = et * 8, tt = v[ye], ft = v[ye + 1], it = v[ye + 2], is = tt + X, ss = ft + Ke, rs = it + Ot;
5276
- let Oe = v[ye + 3], Le = v[ye + 4], Xe = v[ye + 5];
5277
- const Ne = v[ye + 6], Ie = v[ye + 7];
5266
+ const Q = g.emissionTrailMode === "particles", Z = f, Ae = g.emissionTrailDuration ?? 1, y = g.opacity ?? 1, B = g.particleSize ?? 0.5, U = g.bloomIntensity || 1, I = Math.max(1, Math.min(64, g.emissionTrailSegments ?? 8)), D = g.emissionTrailShape || "straight", J = g.followSystemTranslation ?? !0, K = S._simPosition, X = J && K ? K[0] : 0, it = J && K ? K[1] : 0, jt = J && K ? K[2] : 0, Ue = S._simVelocity, Yt = Ue ? Ue[0] : 0, rs = Ue ? Ue[1] : 0, Ht = Ue ? Ue[2] : 0, Oe = Mt(g.id), qt = !!(J && Oe && Oe.hist && Oe.hist.length > 1);
5267
+ for (let st = 0; st < j; st++) {
5268
+ const he = st * 8, rt = v[he], mt = v[he + 1], nt = v[he + 2], ns = rt + X, as = mt + it, os = nt + jt;
5269
+ let Le = v[he + 3], Xe = v[he + 4], ke = v[he + 5];
5270
+ const Ne = v[he + 6], Ie = v[he + 7];
5278
5271
  if (Ne >= Ie || Ie <= 0) continue;
5279
- const ge = Ne / Ie;
5272
+ const me = Ne / Ie;
5280
5273
  if (g.colorTransitionEnabled) {
5281
5274
  const _ = g.startColor ?? [1, 0, 0], z = g.endColor ?? [0, 0, 1];
5282
- Oe = _[0] + (z[0] - _[0]) * ge, Le = _[1] + (z[1] - _[1]) * ge, Xe = _[2] + (z[2] - _[2]) * ge;
5275
+ Le = _[0] + (z[0] - _[0]) * me, Xe = _[1] + (z[1] - _[1]) * me, ke = _[2] + (z[2] - _[2]) * me;
5283
5276
  }
5284
- Oe = Math.min(1, Oe * U), Le = Math.min(1, Le * U), Xe = Math.min(1, Xe * U);
5285
- let ke = w;
5277
+ Le = Math.min(1, Le * U), Xe = Math.min(1, Xe * U), ke = Math.min(1, ke * U);
5278
+ let je = B;
5286
5279
  if (g.randomSize) {
5287
5280
  const _ = Math.sin(Ie * 54321.67) * 43758.5453 % 1, z = _ < 0 ? _ + 1 : _;
5288
- ke = (g.minSize ?? 0.1) + ((g.maxSize ?? 0.5) - (g.minSize ?? 0.1)) * z;
5281
+ je = (g.minSize ?? 0.1) + ((g.maxSize ?? 0.5) - (g.minSize ?? 0.1)) * z;
5289
5282
  }
5290
5283
  if (g.fadeSizeEnabled) {
5291
5284
  const _ = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
5292
- ke *= 1 - Math.pow(ge, 1 / _);
5285
+ je *= 1 - Math.pow(me, 1 / _);
5293
5286
  }
5294
5287
  if (g.increaseSizeEnabled) {
5295
5288
  const _ = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
5296
- ke *= 1 + Math.pow(ge, 1 / _);
5289
+ je *= 1 + Math.pow(me, 1 / _);
5297
5290
  }
5298
- if (ke <= 0 || ge > 0.9) continue;
5299
- const kt = Math.min((0.9 - ge) * (1 / 0.2), 1), jt = 0.75 * ke * Ti * kt;
5300
- let je = y;
5301
- if (g.fadeEnabled && (je *= Math.max(0, 1 - ge)), je *= kt, je < 0.01) continue;
5302
- const pt = et * 4, Yt = H[pt], Ht = H[pt + 1], qt = H[pt + 2], st = Yt + Lt, rt = Ht + ts, nt = qt + Xt, Zt = Math.sqrt(st * st + rt * rt + nt * nt);
5303
- if (Zt < 1e-3) continue;
5304
- const ht = 1 / Zt, Pe = st * ht, _e = rt * ht, be = nt * ht, $t = A.right[0], Wt = A.right[1], Jt = A.right[2];
5305
- let mt = $t * Pe + Wt * _e + Jt * be, ne = $t - mt * Pe, ae = Wt - mt * _e, oe = Jt - mt * be, Ye = Math.sqrt(ne * ne + ae * ae + oe * oe);
5306
- if (Ye < 0.2) {
5307
- const _ = A.up[0], z = A.up[1], $ = A.up[2], V = _ * Pe + z * _e + $ * be;
5308
- ne = _ - V * Pe, ae = z - V * _e, oe = $ - V * be, Ye = Math.sqrt(ne * ne + ae * ae + oe * oe) || 1;
5291
+ if (je <= 0 || me > 0.9) continue;
5292
+ const Zt = Math.min((0.9 - me) * (1 / 0.2), 1), $t = 0.75 * je * Ai * Zt;
5293
+ let Ye = y;
5294
+ if (g.fadeEnabled && (Ye *= Math.max(0, 1 - me)), Ye *= Zt, Ye < 0.01) continue;
5295
+ const yt = st * 4, Wt = H[yt], Jt = H[yt + 1], Qt = H[yt + 2], at = Wt + Yt, ot = Jt + rs, lt = Qt + Ht, Kt = Math.sqrt(at * at + ot * ot + lt * lt);
5296
+ if (Kt < 1e-3) continue;
5297
+ const gt = 1 / Kt, ve = at * gt, Pe = ot * gt, ye = lt * gt, ei = A.right[0], ti = A.right[1], ii = A.right[2];
5298
+ let bt = ei * ve + ti * Pe + ii * ye, re = ei - bt * ve, ne = ti - bt * Pe, ae = ii - bt * ye, He = Math.sqrt(re * re + ne * ne + ae * ae);
5299
+ if (He < 0.2) {
5300
+ const _ = A.up[0], z = A.up[1], $ = A.up[2], V = _ * ve + z * Pe + $ * ye;
5301
+ re = _ - V * ve, ne = z - V * Pe, ae = $ - V * ye, He = Math.sqrt(re * re + ne * ne + ae * ae) || 1;
5309
5302
  }
5310
- ne /= Ye, ae /= Ye, oe /= Ye;
5311
- const He = Math.min(Ae, Ne);
5312
- if (He < 1e-3) continue;
5313
- const Qt = g.gravityEnabled && g.gravityStrength || 0, we = Oi, Be = Li, Me = Xi;
5314
- if (g.orientToDirection && g.burstMode && Nt) {
5315
- const _ = b._emitSimRotY || 0, z = Ni, $ = ki, V = ji;
5303
+ re /= He, ne /= He, ae /= He;
5304
+ const qe = Math.min(Ae, Ne);
5305
+ if (qe < 1e-3) continue;
5306
+ const si = g.gravityEnabled && g.gravityStrength || 0, _e = ki, we = Ni, Be = ji;
5307
+ if (g.orientToDirection && g.burstMode && qt) {
5308
+ const _ = S._emitSimRotY || 0, z = Yi, $ = Hi, V = qi;
5316
5309
  for (let C = 0; C <= I; C++) {
5317
- const O = wt(Ve, me - C / I * He, It);
5310
+ const O = Rt(Oe, pe - C / I * qe, Vt);
5318
5311
  z[C] = O[0], $[C] = O[1], V[C] = O[2];
5319
5312
  }
5320
5313
  for (let C = 0; C <= I; C++) {
5321
5314
  const O = C > 0 ? C - 1 : 0, q = C < I ? C + 1 : I;
5322
- let Re = z[O] - z[q], Te = V[O] - V[q];
5323
- const Se = (Math.hypot(Re, Te) > 1e-5 ? Math.atan2(Re, Te) : Math.atan2(Lt, Xt)) - _, ie = Math.cos(Se), se = Math.sin(Se), fe = C / I * He, yt = -0.5 * Qt * fe * fe;
5324
- we[C] = ie * tt + se * it + z[C], Be[C] = ft + yt + $[C], Me[C] = -se * tt + ie * it + V[C];
5315
+ let Me = z[O] - z[q], Re = V[O] - V[q];
5316
+ const ge = (Math.hypot(Me, Re) > 1e-5 ? Math.atan2(Me, Re) : Math.atan2(Yt, Ht)) - _, te = Math.cos(ge), ie = Math.sin(ge), ue = C / I * qe, St = -0.5 * si * ue * ue;
5317
+ _e[C] = te * rt + ie * nt + z[C], we[C] = mt + St + $[C], Be[C] = -ie * rt + te * nt + V[C];
5325
5318
  }
5326
5319
  } else for (let _ = 0; _ <= I; _++) {
5327
- const z = _ / I * He, $ = -0.5 * Qt * z * z;
5328
- if (Nt) {
5329
- const V = wt(Ve, me - z, It);
5330
- we[_] = tt - Yt * z + V[0], Be[_] = ft - Ht * z + $ + V[1], Me[_] = it - qt * z + V[2];
5320
+ const z = _ / I * qe, $ = -0.5 * si * z * z;
5321
+ if (qt) {
5322
+ const V = Rt(Oe, pe - z, Vt);
5323
+ _e[_] = rt - Wt * z + V[0], we[_] = mt - Jt * z + $ + V[1], Be[_] = nt - Qt * z + V[2];
5331
5324
  } else
5332
- we[_] = is - st * z, Be[_] = ss - rt * z + $, Me[_] = rs - nt * z;
5325
+ _e[_] = ns - at * z, we[_] = as - ot * z + $, Be[_] = os - lt * z;
5333
5326
  }
5334
5327
  if (D !== "straight") {
5335
5328
  const _ = g.emissionTrailShapeAmplitude ?? 0.1, z = g.emissionTrailShapeFrequency ?? 4, $ = g.emissionTrailShapeSpeed ?? 0;
5336
- let V = -be, C = 0, O = Pe, q = Math.sqrt(V * V + O * O);
5337
- q < 1e-6 && (V = 0, C = be, O = -_e, q = Math.sqrt(V * V + C * C + O * O) || 1), V /= q, C /= q, O /= q;
5338
- const Re = _e * O - be * C, Te = be * V - Pe * O, de = Pe * C - _e * V;
5329
+ let V = -ye, C = 0, O = ve, q = Math.sqrt(V * V + O * O);
5330
+ q < 1e-6 && (V = 0, C = ye, O = -Pe, q = Math.sqrt(V * V + C * C + O * O) || 1), V /= q, C /= q, O /= q;
5331
+ const Me = Pe * O - ye * C, Re = ye * V - ve * O, ce = ve * C - Pe * V;
5339
5332
  for (let ee = 1; ee <= I; ee++) {
5340
- const Se = ee / I * He, ie = 2 * Math.PI * z * (me - Se) + $ * me;
5341
- let se = 0, fe = 0;
5342
- D === "zigzag" ? se = _ * Math.sign(Math.sin(ie)) : D === "sine" ? se = _ * Math.sin(ie) : D === "spiral" && (se = _ * Math.sin(ie), fe = _ * Math.cos(ie)), we[ee] += V * se + Re * fe, Be[ee] += C * se + Te * fe, Me[ee] += O * se + de * fe;
5333
+ const ge = ee / I * qe, te = 2 * Math.PI * z * (pe - ge) + $ * pe;
5334
+ let ie = 0, ue = 0;
5335
+ D === "zigzag" ? ie = _ * Math.sign(Math.sin(te)) : D === "sine" ? ie = _ * Math.sin(te) : D === "spiral" && (ie = _ * Math.sin(te), ue = _ * Math.cos(te)), _e[ee] += V * ie + Me * ue, we[ee] += C * ie + Re * ue, Be[ee] += O * ie + ce * ue;
5343
5336
  }
5344
5337
  }
5345
5338
  if (Q)
5346
- for (let _ = 1; _ <= I && f < M; _++) {
5347
- const z = _ / I, $ = we[_] - X, V = Be[_] - Ke, C = Me[_] - Ot, O = f * 8, q = f * 4;
5348
- F[O] = $, F[O + 1] = V, F[O + 2] = C, F[O + 3] = Oe, F[O + 4] = Le, F[O + 5] = Xe, F[O + 6] = Ne + (Ie - Ne) * z, F[O + 7] = Ie, N[q] = 0, N[q + 1] = 0, N[q + 2] = 0, N[q + 3] = 0, Y[q] = $, Y[q + 1] = V, Y[q + 2] = C, Y[q + 3] = 0, f++;
5339
+ for (let _ = 1; _ <= I && f < E; _++) {
5340
+ const z = _ / I, $ = _e[_] - X, V = we[_] - it, C = Be[_] - jt, O = f * 8, q = f * 4;
5341
+ F[O] = $, F[O + 1] = V, F[O + 2] = C, F[O + 3] = Le, F[O + 4] = Xe, F[O + 5] = ke, F[O + 6] = Ne + (Ie - Ne) * z, F[O + 7] = Ie, k[q] = 0, k[q + 1] = 0, k[q + 2] = 0, k[q + 3] = 0, Y[q] = $, Y[q + 1] = V, Y[q + 2] = C, Y[q + 3] = 0, f++;
5349
5342
  }
5350
5343
  else
5351
- for (let _ = 0; _ < I && !(m + 42 > ce.length); _++) {
5352
- const z = _ / I, $ = (_ + 1) / I, V = we[_], C = Be[_], O = Me[_], q = we[_ + 1], Re = Be[_ + 1], Te = Me[_ + 1], de = jt * (1 - z), ee = jt * (1 - $), Se = je * (1 - z) * (1 - z), ie = je * (1 - $) * (1 - $), se = V + ne * de, fe = C + ae * de, yt = O + oe * de, Kt = V - ne * de, ei = C - ae * de, ti = O - oe * de, ii = q + ne * ee, si = Re + ae * ee, ri = Te + oe * ee, ns = q - ne * ee, as = Re - ae * ee, os = Te - oe * ee, ze = (ls, cs, us, ds) => {
5353
- ce[m++] = ls, ce[m++] = cs, ce[m++] = us, ce[m++] = Oe, ce[m++] = Le, ce[m++] = Xe, ce[m++] = ds;
5344
+ for (let _ = 0; _ < I && !(h + 42 > le.length); _++) {
5345
+ const z = _ / I, $ = (_ + 1) / I, V = _e[_], C = we[_], O = Be[_], q = _e[_ + 1], Me = we[_ + 1], Re = Be[_ + 1], ce = $t * (1 - z), ee = $t * (1 - $), ge = Ye * (1 - z) * (1 - z), te = Ye * (1 - $) * (1 - $), ie = V + re * ce, ue = C + ne * ce, St = O + ae * ce, ri = V - re * ce, ni = C - ne * ce, ai = O - ae * ce, oi = q + re * ee, li = Me + ne * ee, ci = Re + ae * ee, ls = q - re * ee, cs = Me - ne * ee, us = Re - ae * ee, ze = (ds, fs, ps, hs) => {
5346
+ le[h++] = ds, le[h++] = fs, le[h++] = ps, le[h++] = Le, le[h++] = Xe, le[h++] = ke, le[h++] = hs;
5354
5347
  };
5355
- ze(se, fe, yt, Se), ze(Kt, ei, ti, Se), ze(ii, si, ri, ie), ze(Kt, ei, ti, Se), ze(ns, as, os, ie), ze(ii, si, ri, ie);
5348
+ ze(ie, ue, St, ge), ze(ri, ni, ai, ge), ze(oi, li, ci, te), ze(ri, ni, ai, ge), ze(ls, cs, us, te), ze(oi, li, ci, te);
5356
5349
  }
5357
5350
  }
5358
5351
  Q && f > Z && De.set(g.id, { first: Z, count: f - Z });
5359
5352
  }
5360
- f > 0 && (r.queue.writeBuffer(k, 0, F, 0, f * 8), r.queue.writeBuffer(G, 0, N, 0, f * 4), r.queue.writeBuffer(pe, 0, Y, 0, f * 4)), Fe = m / 7, Fe > 0 && r.queue.writeBuffer(At, 0, ce, 0, m);
5353
+ f > 0 && (r.queue.writeBuffer(N, 0, F, 0, f * 8), r.queue.writeBuffer(G, 0, k, 0, f * 4), r.queue.writeBuffer(de, 0, Y, 0, f * 4)), Fe = h / 7, Fe > 0 && r.queue.writeBuffer(zt, 0, le, 0, h);
5361
5354
  }
5362
- const Bt = () => {
5363
- r.queue.writeBuffer(E, 0, new Float32Array([1, 0, a.width, a.height, 0, 0, 0, 0])), r.queue.writeBuffer(T, 0, new Float32Array([0, 1, a.width, a.height, 0, 0, 0, 0]));
5355
+ const Tt = () => {
5356
+ r.queue.writeBuffer(M, 0, new Float32Array([1, 0, a.width, a.height, 0, 0, 0, 0])), r.queue.writeBuffer(R, 0, new Float32Array([0, 1, a.width, a.height, 0, 0, 0, 0]));
5364
5357
  };
5365
- Bt();
5366
- const Mt = new Float32Array(16).fill(0);
5367
- Mt[0] = 1, r.queue.writeBuffer(x, 0, Mt);
5368
- const re = Qs(r), he = Ws(r), {
5369
- particlePipeline: Ci,
5370
- particleAdditivePipeline: Ai,
5371
- particleDepthWritePipeline: Ui,
5372
- blurPipeline: $e,
5373
- compositePipeline: Ii,
5374
- directRenderPipeline: Rt,
5375
- finalCompositePipeline: zi,
5376
- glbMeshPipeline: Gi
5377
- } = Js(r, c, he), Tt = r.createShaderModule({ code: `
5358
+ Tt();
5359
+ const Et = new Float32Array(16).fill(0);
5360
+ Et[0] = 1, r.queue.writeBuffer(x, 0, Et);
5361
+ const se = ir(r), fe = er(r), {
5362
+ particlePipeline: Ii,
5363
+ particleAdditivePipeline: zi,
5364
+ particleDepthWritePipeline: Gi,
5365
+ blurPipeline: We,
5366
+ compositePipeline: Di,
5367
+ directRenderPipeline: Ct,
5368
+ finalCompositePipeline: Fi,
5369
+ glbMeshPipeline: Vi
5370
+ } = tr(r, c, fe), At = r.createShaderModule({ code: `
5378
5371
  struct U { mvp: mat4x4<f32> };
5379
5372
  @group(0) @binding(0) var<uniform> u: U;
5380
5373
  struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
5381
5374
  struct VOut { @builtin(position) pos: vec4<f32>, @location(0) col: vec4<f32> };
5382
5375
  @vertex fn vs(v: VIn) -> VOut { var o: VOut; o.pos = u.mvp * vec4<f32>(v.pos, 1.0); o.col = v.col; return o; }
5383
5376
  @fragment fn fs(i: VOut) -> @location(0) vec4<f32> { return i.col; }
5384
- ` }), Et = r.createBindGroupLayout({
5377
+ ` }), Ut = r.createBindGroupLayout({
5385
5378
  entries: [{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } }]
5386
- }), Di = r.createRenderPipeline({
5387
- layout: r.createPipelineLayout({ bindGroupLayouts: [Et] }),
5379
+ }), Oi = r.createRenderPipeline({
5380
+ layout: r.createPipelineLayout({ bindGroupLayouts: [Ut] }),
5388
5381
  vertex: {
5389
- module: Tt,
5382
+ module: At,
5390
5383
  entryPoint: "vs",
5391
5384
  buffers: [{ arrayStride: 28, attributes: [
5392
5385
  { shaderLocation: 0, offset: 0, format: "float32x3" },
@@ -5394,7 +5387,7 @@ async function gr(s, t = {}) {
5394
5387
  ] }]
5395
5388
  },
5396
5389
  fragment: {
5397
- module: Tt,
5390
+ module: At,
5398
5391
  entryPoint: "fs",
5399
5392
  targets: [{ format: "rgba16float", blend: {
5400
5393
  // renders into the HDR sceneTexture
@@ -5406,17 +5399,22 @@ async function gr(s, t = {}) {
5406
5399
  // depth24plus to match the non-bloom pass; test against the resolved scene depth
5407
5400
  // (occlusion) but don't write (transparent ribbon).
5408
5401
  depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
5409
- }), Ct = 512 * 64 * 6, ce = new Float32Array(Ct * 7), At = r.createBuffer({
5410
- size: Ct * 7 * 4,
5402
+ }), It = 512 * 64 * 6, le = new Float32Array(It * 7), zt = r.createBuffer({
5403
+ size: It * 7 * 4,
5411
5404
  usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
5412
5405
  label: "ribbonBuffer"
5413
- }), Fi = r.createBindGroup({
5414
- layout: Et,
5415
- entries: [{ binding: 0, resource: { buffer: S } }]
5406
+ }), Li = r.createBindGroup({
5407
+ layout: Ut,
5408
+ entries: [{ binding: 0, resource: { buffer: b } }]
5416
5409
  });
5417
- let Fe = 0, { sceneTexture: te, bloomTexA: xe, bloomTexB: ue } = pi(r, c, a.width, a.height), ve = hi(r, a.width, a.height);
5418
- const ot = { uniformBuffer: S, appearanceUniformBuffer: R, horizontalBlurUniformBuffer: E, verticalBlurUniformBuffer: T, bloomIntensityBuffer: x };
5419
- let We = St(r, re, ot, { sceneTexture: te, bloomTexA: xe, bloomTexB: ue });
5410
+ let Fe = 0, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe } = yi(r, c, a.width, a.height), Je = gi(r, a.width, a.height), Te, Gt, Qe, Ve;
5411
+ const Dt = () => {
5412
+ const f = (h) => h.createView();
5413
+ Te = f(be), Gt = f(Se), Qe = f(xe), Ve = f(Je);
5414
+ };
5415
+ Dt();
5416
+ const ut = { uniformBuffer: b, appearanceUniformBuffer: w, horizontalBlurUniformBuffer: M, verticalBlurUniformBuffer: R, bloomIntensityBuffer: x };
5417
+ let Ke = Pt(r, se, ut, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe });
5420
5418
  const A = {
5421
5419
  mvp: new Float32Array(16),
5422
5420
  position: new Float32Array([0, 0, 10]),
@@ -5425,67 +5423,67 @@ async function gr(s, t = {}) {
5425
5423
  up: new Float32Array([0, 1, 0]),
5426
5424
  hasCamera: !1
5427
5425
  };
5428
- let me = 0, Vi = 0;
5429
- const Ee = new Float32Array(5), Ut = new Float32Array(16), Oi = new Array(65), Li = new Array(65), Xi = new Array(65), Ni = new Array(65), ki = new Array(65), ji = new Array(65), It = [0, 0, 0], Ce = { key: null, ms: !1, bindGroup: null };
5430
- let zt = !1, lt = !0, Je = !1, Qe = null, ct = a.width, ut = a.height;
5431
- function Gt() {
5432
- const f = [te, xe, ue, ve], m = pi(r, c, a.width, a.height);
5433
- te = m.sceneTexture, xe = m.bloomTexA, ue = m.bloomTexB, ve = hi(r, a.width, a.height), Bt(), d.clear(), p.resizeTextures(), We = St(r, re, ot, { sceneTexture: te, bloomTexA: xe, bloomTexB: ue });
5434
- let b = !1;
5426
+ let pe = 0, Xi = 0;
5427
+ const Ee = new Float32Array(5), Ft = new Float32Array(16), ki = new Array(65), Ni = new Array(65), ji = new Array(65), Yi = new Array(65), Hi = new Array(65), qi = new Array(65), Vt = [0, 0, 0], Ce = { key: null, ms: !1, bindGroup: null };
5428
+ let Ot = !1, dt = !0, et = !1, tt = null, ft = a.width, pt = a.height;
5429
+ function Lt() {
5430
+ const f = [be, Se, xe, Je], h = yi(r, c, a.width, a.height);
5431
+ be = h.sceneTexture, Se = h.bloomTexA, xe = h.bloomTexB, Je = gi(r, a.width, a.height), Dt(), Tt(), d.clear(), p.resizeTextures(), Ke = Pt(r, se, ut, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe });
5432
+ let S = !1;
5435
5433
  const g = () => {
5436
- if (!b) {
5437
- b = !0, requestAnimationFrame(g);
5434
+ if (!S) {
5435
+ S = !0, requestAnimationFrame(g);
5438
5436
  return;
5439
5437
  }
5440
5438
  f.forEach((v) => v.destroy());
5441
5439
  };
5442
5440
  requestAnimationFrame(g);
5443
5441
  }
5444
- function Yi(f, m, b) {
5445
- A.mvp.set(ir(f, m)), m && m.length >= 10 && (A.right[0] = m[0], A.right[1] = m[4], A.right[2] = m[8], A.up[0] = m[1], A.up[1] = m[5], A.up[2] = m[9]), b && (A.position[0] = b.x ?? b[0], A.position[1] = b.y ?? b[1], A.position[2] = b.z ?? b[2]), A.hasCamera = !0;
5442
+ function Zi(f, h, S) {
5443
+ A.mvp.set(ar(f, h)), h && h.length >= 10 && (A.right[0] = h[0], A.right[1] = h[4], A.right[2] = h[8], A.up[0] = h[1], A.up[1] = h[5], A.up[2] = h[9]), S && (A.position[0] = S.x ?? S[0], A.position[1] = S.y ?? S[1], A.position[2] = S.z ?? S[2]), A.hasCamera = !0;
5446
5444
  }
5447
- function Hi(f, m) {
5448
- A.mvp.set(f), m && (A.position[0] = m.x ?? m[0], A.position[1] = m.y ?? m[1], A.position[2] = m.z ?? m[2]), A.hasCamera = !0;
5445
+ function $i(f, h) {
5446
+ A.mvp.set(f), h && (A.position[0] = h.x ?? h[0], A.position[1] = h.y ?? h[1], A.position[2] = h.z ?? h[2]), A.hasCamera = !0;
5449
5447
  }
5450
- async function dt(f) {
5451
- if (Je) {
5452
- Qe = f;
5448
+ async function ht(f) {
5449
+ if (et) {
5450
+ tt = f;
5453
5451
  return;
5454
5452
  }
5455
- Je = !0;
5453
+ et = !0;
5456
5454
  try {
5457
- for (const m in P) delete P[m];
5458
- d.clear(), p.resizeTextures(), We = St(r, re, ot, { sceneTexture: te, bloomTexA: xe, bloomTexB: ue }), await l.replaceSystems({ systems: [], activeSystemIndex: 0 });
5459
- for (const m of f)
5460
- await l.addSystems(m.preset, m.position || [0, 0, 0]);
5461
- for (const { config: m } of l.particleSystems)
5462
- P[m.id] || (P[m.id] = B());
5463
- lt = !0, l.respawnAllSystems();
5455
+ for (const h in P) delete P[h];
5456
+ d.clear(), p.resizeTextures(), Ke = Pt(r, se, ut, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe }), await l.replaceSystems({ systems: [], activeSystemIndex: 0 });
5457
+ for (const h of f)
5458
+ await l.addSystems(h.preset, h.position || [0, 0, 0]);
5459
+ for (const { config: h } of l.particleSystems)
5460
+ P[h.id] || (P[h.id] = T());
5461
+ dt = !0, l.respawnAllSystems();
5464
5462
  } finally {
5465
- if (Je = !1, Qe) {
5466
- const m = Qe;
5467
- Qe = null, dt(m);
5463
+ if (et = !1, tt) {
5464
+ const h = tt;
5465
+ tt = null, ht(h);
5468
5466
  }
5469
5467
  }
5470
5468
  }
5471
- async function qi(f, m = [0, 0, 0]) {
5472
- return dt([{ preset: f, position: m }]);
5469
+ async function Wi(f, h = [0, 0, 0]) {
5470
+ return ht([{ preset: f, position: h }]);
5473
5471
  }
5474
- function Zi(f) {
5475
- if (zt || Je || !l.ready || f <= 0 || l.particleSystems.length === 0) return;
5476
- const m = l.clock;
5477
- if (m && (m.loop = l.loop ?? i, m.duration = l.getTotalDuration(), f = m.tick(f)), f > 0.1 && (f = 0.1), f <= 0) return;
5478
- if ((a.width !== ct || a.height !== ut) && (ct = a.width, ut = a.height, Gt()), me += f, W.length) {
5472
+ function Ji(f) {
5473
+ if (Ot || et || !l.ready || f <= 0 || l.particleSystems.length === 0) return;
5474
+ const h = l.clock;
5475
+ if (h && (h.loop = l.loop ?? i, h.duration = l.getTotalDuration(), f = h.tick(f)), f > 0.1 && (f = 0.1), f <= 0) return;
5476
+ if ((a.width !== ft || a.height !== pt) && (ft = a.width, pt = a.height, Lt()), pe += f, W.length) {
5479
5477
  for (const y of W) {
5480
5478
  if (y.getPosition) {
5481
- const w = y.getPosition();
5482
- w ? (y.pos || (y.pos = y._posBuf), Array.isArray(w) ? (y.pos[0] = w[0], y.pos[1] = w[1], y.pos[2] = w[2]) : (y.pos[0] = w.x, y.pos[1] = w.y, y.pos[2] = w.z)) : y.pos = null;
5479
+ const B = y.getPosition();
5480
+ B ? (y.pos || (y.pos = y._posBuf), Array.isArray(B) ? (y.pos[0] = B[0], y.pos[1] = B[1], y.pos[2] = B[2]) : (y.pos[0] = B.x, y.pos[1] = B.y, y.pos[2] = B.z)) : y.pos = null;
5483
5481
  }
5484
5482
  y.vel = y._velBuf, y.pos && y.prevPos && y.wasActive && f > 0 ? (y.vel[0] = (y.pos[0] - y.prevPos[0]) / f, y.vel[1] = (y.pos[1] - y.prevPos[1]) / f, y.vel[2] = (y.pos[2] - y.prevPos[2]) / f) : (y.vel[0] = 0, y.vel[1] = 0, y.vel[2] = 0), y.justResumed = !!y.pos && !y.wasActive, y.justResumed && (y.hist.length = 0);
5485
5483
  }
5486
- for (const { system: y, config: w } of l.particleSystems) {
5487
- const U = _t(w.id);
5488
- if (!(!U || U.historyOnly) && (w.hidden = !U.pos, U.pos)) {
5484
+ for (const { system: y, config: B } of l.particleSystems) {
5485
+ const U = Mt(B.id);
5486
+ if (!(!U || U.historyOnly) && (B.hidden = !U.pos, U.pos)) {
5489
5487
  let I = null;
5490
5488
  if (U.orientToDirection && U.vel) {
5491
5489
  const D = U.vel[0], J = U.vel[2];
@@ -5495,35 +5493,35 @@ async function gr(s, t = {}) {
5495
5493
  }
5496
5494
  }
5497
5495
  for (const y of W)
5498
- y.pos ? Ri(y, me) : y.hist.length = 0, y.prevPos = y.pos ? y.pos.slice() : null, y.wasActive = !!y.pos;
5499
- if (globalThis.__HZFX_DEBUG && (Vi++ & 63) === 0) {
5500
- const y = l.particleSystems.reduce((D, J) => D + (J.system.activeParticles | 0), 0), w = W.find((D) => D.pos), U = w ? Math.hypot(A.position[0] - w.pos[0], A.position[1] - w.pos[1], A.position[2] - w.pos[2]).toFixed(1) : "-", I = W.map((D) => `{ids:[${[...D.ids]}],pos:${D.pos ? "1" : "0"},hist:${D.hist.length}}`).join(",");
5501
- console.info(`[HZFX] movingGroups(${W.length})=[${I}] activeParticles=${y} systems=${l.particleSystems.length} ribbonVerts=${Fe} camDist=${U} t=${me.toFixed(1)}`);
5496
+ y.pos ? Ci(y, pe) : y.hist.length = 0, y.pos ? (y._prevPosBuf[0] = y.pos[0], y._prevPosBuf[1] = y.pos[1], y._prevPosBuf[2] = y.pos[2], y.prevPos = y._prevPosBuf) : y.prevPos = null, y.wasActive = !!y.pos;
5497
+ if (globalThis.__HZFX_DEBUG && (Xi++ & 63) === 0) {
5498
+ const y = l.particleSystems.reduce((D, J) => D + (J.system.activeParticles | 0), 0), B = W.find((D) => D.pos), U = B ? Math.hypot(A.position[0] - B.pos[0], A.position[1] - B.pos[1], A.position[2] - B.pos[2]).toFixed(1) : "-", I = W.map((D) => `{ids:[${[...D.ids]}],pos:${D.pos ? "1" : "0"},hist:${D.hist.length}}`).join(",");
5499
+ console.info(`[HZFX] movingGroups(${W.length})=[${I}] activeParticles=${y} systems=${l.particleSystems.length} ribbonVerts=${Fe} camDist=${U} t=${pe.toFixed(1)}`);
5502
5500
  }
5503
5501
  }
5504
- if (l.updateAllSystems(f), m ? m.loop : l.loop ?? i) {
5505
- const y = l.particleSystems.length > 0 && l.particleSystems.every(({ system: w }) => w.activeParticles === 0 && !w.emitting);
5506
- (m && m.justLooped || y && lt) && l.respawnAllSystems(), lt = !y;
5502
+ if (l.updateAllSystems(f), h ? h.loop : l.loop ?? i) {
5503
+ const y = l.particleSystems.length > 0 && l.particleSystems.every(({ system: B }) => B.activeParticles === 0 && !B.emitting);
5504
+ (h && h.justLooped || y && dt) && l.respawnAllSystems(), dt = !y;
5507
5505
  }
5508
- for (const { system: y, config: w } of l.particleSystems)
5509
- w.glbModelEnabled && y.glbAnimator && (y.glbAnimator.update(f), y.updateAnimatedGLBBuffer());
5510
- r.queue.writeBuffer(S, 0, A.mvp), Ee[0] = A.position[0], Ee[1] = A.position[1], Ee[2] = A.position[2], Ee[3] = a.height / Math.max(1, a.width), Ee[4] = me, r.queue.writeBuffer(S, 64, Ee), Ei();
5506
+ for (const { system: y, config: B } of l.particleSystems)
5507
+ B.glbModelEnabled && y.glbAnimator && (y.glbAnimator.update(f), y.updateAnimatedGLBBuffer());
5508
+ r.queue.writeBuffer(b, 0, A.mvp), Ee[0] = A.position[0], Ee[1] = A.position[1], Ee[2] = A.position[2], Ee[3] = a.height / Math.max(1, a.width), Ee[4] = pe, r.queue.writeBuffer(b, 64, Ee), Ui();
5511
5509
  const g = l.particleSystems.some(({ config: y }) => y.bloomEnabled), v = r.createCommandEncoder();
5512
5510
  let H = !1;
5513
5511
  if (e)
5514
5512
  try {
5515
5513
  const y = e();
5516
5514
  if (y) {
5517
- let w = null, U = null, I = !1;
5518
- if (y instanceof GPUTexture ? y.width === a.width && y.height === a.height && (w = y, U = () => y.createView({ aspect: "depth-only" }), I = y.sampleCount > 1) : y.view && (w = y.view, U = () => y.view, I = !!y.multisampled), w) {
5519
- const { pipeline: D, layout: J } = h(I);
5520
- (Ce.key !== w || Ce.ms !== I) && (Ce.key = w, Ce.ms = I, Ce.bindGroup = r.createBindGroup({
5515
+ let B = null, U = null, I = !1;
5516
+ if (y instanceof GPUTexture ? y.width === a.width && y.height === a.height && (B = y, U = () => y.createView({ aspect: "depth-only" }), I = y.sampleCount > 1) : y.view && (B = y.view, U = () => y.view, I = !!y.multisampled), B) {
5517
+ const { pipeline: D, layout: J } = m(I);
5518
+ (Ce.key !== B || Ce.ms !== I) && (Ce.key = B, Ce.ms = I, Ce.bindGroup = r.createBindGroup({
5521
5519
  layout: J,
5522
5520
  entries: [{ binding: 0, resource: U() }]
5523
5521
  }));
5524
5522
  const K = v.beginRenderPass({
5525
5523
  colorAttachments: [],
5526
- depthStencilAttachment: { view: ve.createView(), depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5524
+ depthStencilAttachment: { view: Ve, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5527
5525
  });
5528
5526
  K.setPipeline(D), K.setBindGroup(0, Ce.bindGroup), K.draw(3), K.end(), H = !0;
5529
5527
  }
@@ -5531,49 +5529,49 @@ async function gr(s, t = {}) {
5531
5529
  } catch {
5532
5530
  }
5533
5531
  const j = v.beginRenderPass({
5534
- colorAttachments: [{ view: te.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
5535
- depthStencilAttachment: H ? { view: ve.createView(), depthLoadOp: "load", depthStoreOp: "store" } : { view: ve.createView(), depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5532
+ colorAttachments: [{ view: Te, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
5533
+ depthStencilAttachment: H ? { view: Ve, depthLoadOp: "load", depthStoreOp: "store" } : { view: Ve, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5536
5534
  });
5537
- for (const { system: y, config: w } of l.particleSystems)
5538
- w.bloomEnabled || w.hidden || y.activeParticles === 0 || Dt(j, y, w);
5539
- if (Fe > 0 && (j.setPipeline(Di), j.setBindGroup(0, Fi), j.setVertexBuffer(0, At), j.draw(Fe)), j.end(), g) {
5535
+ for (const { system: y, config: B } of l.particleSystems)
5536
+ B.bloomEnabled || B.hidden || y.activeParticles === 0 || Xt(j, y, B);
5537
+ if (Fe > 0 && (j.setPipeline(Oi), j.setBindGroup(0, Li), j.setVertexBuffer(0, zt), j.draw(Fe)), j.end(), g) {
5540
5538
  const y = {
5541
- colorAttachments: [{ view: xe.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5542
- }, w = {
5543
- colorAttachments: [{ view: ue.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5539
+ colorAttachments: [{ view: Gt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5540
+ }, B = {
5541
+ colorAttachments: [{ view: Qe, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5544
5542
  };
5545
5543
  for (const { system: U, config: I } of l.particleSystems) {
5546
5544
  if (!I.bloomEnabled || I.hidden || U.activeParticles === 0) continue;
5547
5545
  const D = U.config.id, J = p.getBloomSourceTexture(D, a.width, a.height), K = v.beginRenderPass({
5548
5546
  colorAttachments: [{ view: J.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
5549
- depthStencilAttachment: { view: ve.createView(), depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
5547
+ depthStencilAttachment: { view: Ve, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
5550
5548
  });
5551
- Dt(K, U, I), K.end(), Ut[0] = I.bloomIntensity, r.queue.writeBuffer(x, 0, Ut), d.systemBloomHorizontalBindGroups[D] || (d.systemBloomHorizontalBindGroups[D] = r.createBindGroup({
5552
- layout: he.bloomBindGroupLayout,
5549
+ Xt(K, U, I), K.end(), Ft[0] = I.bloomIntensity, r.queue.writeBuffer(x, 0, Ft), d.systemBloomHorizontalBindGroups[D] || (d.systemBloomHorizontalBindGroups[D] = r.createBindGroup({
5550
+ layout: fe.bloomBindGroupLayout,
5553
5551
  entries: [
5554
- { binding: 0, resource: re },
5552
+ { binding: 0, resource: se },
5555
5553
  { binding: 1, resource: J.createView() },
5556
- { binding: 2, resource: { buffer: E } }
5554
+ { binding: 2, resource: { buffer: M } }
5557
5555
  ]
5558
5556
  }));
5559
5557
  let X = v.beginRenderPass(y);
5560
- X.setPipeline($e), X.setBindGroup(0, d.systemBloomHorizontalBindGroups[D]), X.draw(3), X.end(), X = v.beginRenderPass(w), X.setPipeline($e), X.setBindGroup(0, We.verticalBlurBindGroup), X.draw(3), X.end(), d.secondHorizontalBindGroups[D] || (d.secondHorizontalBindGroups[D] = r.createBindGroup({
5561
- layout: he.bloomBindGroupLayout,
5558
+ X.setPipeline(We), X.setBindGroup(0, d.systemBloomHorizontalBindGroups[D]), X.draw(3), X.end(), X = v.beginRenderPass(B), X.setPipeline(We), X.setBindGroup(0, Ke.verticalBlurBindGroup), X.draw(3), X.end(), d.secondHorizontalBindGroups[D] || (d.secondHorizontalBindGroups[D] = r.createBindGroup({
5559
+ layout: fe.bloomBindGroupLayout,
5562
5560
  entries: [
5563
- { binding: 0, resource: re },
5564
- { binding: 1, resource: ue.createView() },
5565
- { binding: 2, resource: { buffer: E } }
5561
+ { binding: 0, resource: se },
5562
+ { binding: 1, resource: Qe },
5563
+ { binding: 2, resource: { buffer: M } }
5566
5564
  ]
5567
- })), X = v.beginRenderPass(y), X.setPipeline($e), X.setBindGroup(0, d.secondHorizontalBindGroups[D]), X.draw(3), X.end(), X = v.beginRenderPass(w), X.setPipeline($e), X.setBindGroup(0, We.verticalBlurBindGroup), X.draw(3), X.end();
5568
- const Ke = p.getBloomCompositeTexture(D, a.width, a.height);
5565
+ })), X = v.beginRenderPass(y), X.setPipeline(We), X.setBindGroup(0, d.secondHorizontalBindGroups[D]), X.draw(3), X.end(), X = v.beginRenderPass(B), X.setPipeline(We), X.setBindGroup(0, Ke.verticalBlurBindGroup), X.draw(3), X.end();
5566
+ const it = p.getBloomCompositeTexture(D, a.width, a.height);
5569
5567
  X = v.beginRenderPass({
5570
- colorAttachments: [{ view: Ke.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5571
- }), X.setPipeline(Ii), d.systemBloomCompositeBindGroups[D] || (d.systemBloomCompositeBindGroups[D] = r.createBindGroup({
5572
- layout: he.compositeBindGroupLayout,
5568
+ colorAttachments: [{ view: it.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5569
+ }), X.setPipeline(Di), d.systemBloomCompositeBindGroups[D] || (d.systemBloomCompositeBindGroups[D] = r.createBindGroup({
5570
+ layout: fe.compositeBindGroupLayout,
5573
5571
  entries: [
5574
- { binding: 0, resource: re },
5572
+ { binding: 0, resource: se },
5575
5573
  { binding: 1, resource: J.createView() },
5576
- { binding: 2, resource: ue.createView() },
5574
+ { binding: 2, resource: Qe },
5577
5575
  { binding: 3, resource: { buffer: U.bloomIntensityBuffer } }
5578
5576
  ]
5579
5577
  })), X.setBindGroup(0, d.systemBloomCompositeBindGroups[D]), X.draw(3), X.end();
@@ -5582,24 +5580,24 @@ async function gr(s, t = {}) {
5582
5580
  const Q = p.getCombinedTexture(a.width, a.height), Z = v.beginRenderPass({
5583
5581
  colorAttachments: [{ view: Q.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5584
5582
  });
5585
- Z.setPipeline(Rt), d.combinedInitialBindGroup || (d.combinedInitialBindGroup = r.createBindGroup({
5586
- layout: he.compositeBindGroupLayout,
5583
+ Z.setPipeline(Ct), d.combinedInitialBindGroup || (d.combinedInitialBindGroup = r.createBindGroup({
5584
+ layout: fe.compositeBindGroupLayout,
5587
5585
  entries: [
5588
- { binding: 0, resource: re },
5589
- { binding: 1, resource: te.createView() },
5590
- { binding: 2, resource: te.createView() },
5586
+ { binding: 0, resource: se },
5587
+ { binding: 1, resource: Te },
5588
+ { binding: 2, resource: Te },
5591
5589
  { binding: 3, resource: { buffer: x } }
5592
5590
  ]
5593
5591
  })), Z.setBindGroup(0, d.combinedInitialBindGroup), Z.draw(3);
5594
- for (const { config: y, system: w } of l.particleSystems) {
5595
- if (!y.bloomEnabled || y.hidden || w.activeParticles === 0) continue;
5596
- const U = w.config.id;
5597
- Z.setPipeline(Rt), d.combinedBloomCompositeBindGroups[U] || (d.combinedBloomCompositeBindGroups[U] = r.createBindGroup({
5598
- layout: he.compositeBindGroupLayout,
5592
+ for (const { config: y, system: B } of l.particleSystems) {
5593
+ if (!y.bloomEnabled || y.hidden || B.activeParticles === 0) continue;
5594
+ const U = B.config.id;
5595
+ Z.setPipeline(Ct), d.combinedBloomCompositeBindGroups[U] || (d.combinedBloomCompositeBindGroups[U] = r.createBindGroup({
5596
+ layout: fe.compositeBindGroupLayout,
5599
5597
  entries: [
5600
- { binding: 0, resource: re },
5598
+ { binding: 0, resource: se },
5601
5599
  { binding: 1, resource: p.getBloomCompositeTexture(U, a.width, a.height).createView() },
5602
- { binding: 2, resource: te.createView() },
5600
+ { binding: 2, resource: Te },
5603
5601
  { binding: 3, resource: { buffer: x } }
5604
5602
  ]
5605
5603
  })), Z.setBindGroup(0, d.combinedBloomCompositeBindGroups[U]), Z.draw(3);
@@ -5613,77 +5611,77 @@ async function gr(s, t = {}) {
5613
5611
  clearValue: { r: 0, g: 0, b: 0, a: 0 }
5614
5612
  }]
5615
5613
  });
5616
- Ae.setPipeline(zi), d.finalBindGroup || (d.finalBindGroup = r.createBindGroup({
5617
- layout: he.compositeBindGroupLayout,
5614
+ Ae.setPipeline(Fi), d.finalBindGroup || (d.finalBindGroup = r.createBindGroup({
5615
+ layout: fe.compositeBindGroupLayout,
5618
5616
  entries: [
5619
- { binding: 0, resource: re },
5617
+ { binding: 0, resource: se },
5620
5618
  { binding: 1, resource: Q.createView() },
5621
- { binding: 2, resource: te.createView() },
5619
+ { binding: 2, resource: Te },
5622
5620
  { binding: 3, resource: { buffer: x } }
5623
5621
  ]
5624
5622
  })), Ae.setBindGroup(0, d.finalBindGroup), Ae.draw(3), Ae.end(), r.queue.submit([v.finish()]);
5625
5623
  }
5626
- function Dt(f, m, b) {
5627
- const g = m.config.id, v = b.glbModelEnabled && m.glbMeshData, H = !d.systemBindGroups[g] || d.textureStates[g] !== b.textureEnabled || d.textureRefs[g] !== m.particleTexture;
5628
- d.textureStates[g] = b.textureEnabled, d.textureRefs[g] = m.particleTexture, H && (d.systemBindGroups[g] = r.createBindGroup({
5629
- layout: he.particleBindGroupLayout,
5624
+ function Xt(f, h, S) {
5625
+ const g = h.config.id, v = S.glbModelEnabled && h.glbMeshData, H = !d.systemBindGroups[g] || d.textureStates[g] !== S.textureEnabled || d.textureRefs[g] !== h.particleTexture;
5626
+ d.textureStates[g] = S.textureEnabled, d.textureRefs[g] = h.particleTexture, H && (d.systemBindGroups[g] = r.createBindGroup({
5627
+ layout: fe.particleBindGroupLayout,
5630
5628
  entries: [
5631
- { binding: 0, resource: { buffer: S } },
5632
- { binding: 1, resource: { buffer: m.appearanceUniformBuffer } },
5633
- { binding: 2, resource: m.particleTexture.createView() },
5634
- { binding: 3, resource: re }
5629
+ { binding: 0, resource: { buffer: b } },
5630
+ { binding: 1, resource: { buffer: h.appearanceUniformBuffer } },
5631
+ { binding: 2, resource: h.particleTexture.createView() },
5632
+ { binding: 3, resource: se }
5635
5633
  ]
5636
5634
  }));
5637
- const j = d.systemBindGroups[g], Q = b.shapeDisplay !== !1;
5635
+ const j = d.systemBindGroups[g], Q = S.shapeDisplay !== !1;
5638
5636
  if (v)
5639
- Q && (f.setPipeline(Gi), f.setBindGroup(0, j), f.setVertexBuffer(0, m.glbVertexBuffer), f.setVertexBuffer(1, m.instanceBuffer), f.setVertexBuffer(2, m.velocityBuffer), f.setIndexBuffer(m.glbIndexBuffer, m.glbIndexFormat), f.drawIndexed(m.glbIndexCount, m.activeParticles));
5637
+ Q && (f.setPipeline(Vi), f.setBindGroup(0, j), f.setVertexBuffer(0, h.glbVertexBuffer), f.setVertexBuffer(1, h.instanceBuffer), f.setVertexBuffer(2, h.velocityBuffer), f.setIndexBuffer(h.glbIndexBuffer, h.glbIndexFormat), f.drawIndexed(h.glbIndexCount, h.activeParticles));
5640
5638
  else {
5641
- f.setPipeline(b.blendMode === "additive" ? Ai : Ci), f.setIndexBuffer(L, "uint16"), P[g] || (P[g] = B()), f.setVertexBuffer(0, P[g]), f.setBindGroup(0, j), Q && (f.setVertexBuffer(1, m.instanceBuffer), f.setVertexBuffer(2, m.velocityBuffer), f.setVertexBuffer(3, m.trailBuffer), f.drawIndexed(6, m.activeParticles));
5639
+ f.setPipeline(S.blendMode === "additive" ? zi : Ii), f.setIndexBuffer(L, "uint16"), P[g] || (P[g] = T()), f.setVertexBuffer(0, P[g]), f.setBindGroup(0, j), Q && (f.setVertexBuffer(1, h.instanceBuffer), f.setVertexBuffer(2, h.velocityBuffer), f.setVertexBuffer(3, h.trailBuffer), f.drawIndexed(6, h.activeParticles));
5642
5640
  const Z = De.get(g);
5643
- Z && (f.setVertexBuffer(1, k), f.setVertexBuffer(2, G), f.setVertexBuffer(3, pe), f.drawIndexed(6, Z.count, 0, 0, Z.first)), Q && b.depthWriteEnabled && (f.setPipeline(Ui), f.drawIndexed(6, m.activeParticles));
5641
+ Z && (f.setVertexBuffer(1, N), f.setVertexBuffer(2, G), f.setVertexBuffer(3, de), f.drawIndexed(6, Z.count, 0, 0, Z.first)), Q && S.depthWriteEnabled && (f.setPipeline(Gi), f.drawIndexed(6, h.activeParticles));
5644
5642
  }
5645
5643
  }
5646
- function $i() {
5647
- ct = a.width, ut = a.height, Gt();
5644
+ function Qi() {
5645
+ ft = a.width, pt = a.height, Lt();
5648
5646
  }
5649
- function Wi() {
5647
+ function Ki() {
5650
5648
  d.clear();
5651
5649
  }
5652
- function Ji() {
5653
- zt = !0, l.destroy(), [te, xe, ue, ve].forEach((f) => f == null ? void 0 : f.destroy()), p.resizeTextures(), [
5654
- S,
5650
+ function es() {
5651
+ Ot = !0, l.destroy(), [be, Se, xe, Je].forEach((f) => f == null ? void 0 : f.destroy()), p.resizeTextures(), [
5652
+ b,
5653
+ w,
5654
+ M,
5655
5655
  R,
5656
- E,
5657
- T,
5658
5656
  x,
5659
5657
  L,
5660
- k,
5658
+ N,
5661
5659
  G,
5662
- pe
5660
+ de
5663
5661
  ].forEach((f) => f == null ? void 0 : f.destroy()), Object.values(P).forEach((f) => f == null ? void 0 : f.destroy());
5664
5662
  }
5665
- async function Ft(f, m) {
5666
- const b = await l.addSystems(f, m);
5663
+ async function kt(f, h) {
5664
+ const S = await l.addSystems(f, h);
5667
5665
  for (const { config: g } of l.particleSystems)
5668
- P[g.id] || (P[g.id] = B());
5669
- return l.respawnAllSystems(), new Set(Array.isArray(b) ? b : []);
5666
+ P[g.id] || (P[g.id] = T());
5667
+ return l.respawnAllSystems(), new Set(Array.isArray(S) ? S : []);
5670
5668
  }
5671
- function Vt(f) {
5672
- for (const m of f) {
5673
- const b = l.particleSystems.findIndex((g) => g.config.id === m);
5674
- b >= 0 && l.removeSystem(b);
5669
+ function Nt(f) {
5670
+ for (const h of f) {
5671
+ const S = l.particleSystems.findIndex((g) => g.config.id === h);
5672
+ S >= 0 && l.removeSystem(S);
5675
5673
  }
5676
5674
  }
5677
- async function Qi(f, m = [0, 0, 0]) {
5678
- const b = await Ft(f, m);
5675
+ async function ts(f, h = [0, 0, 0]) {
5676
+ const S = await kt(f, h);
5679
5677
  return { remove() {
5680
- Vt(b);
5678
+ Nt(S);
5681
5679
  } };
5682
5680
  }
5683
- async function Ki(f, m = {}) {
5684
- const b = await Ft(f, [0, 0, 0]);
5685
- globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(f && f.systems || []).length} newIds=[${[...b]}]`);
5686
- const g = { ids: b, pos: null, hist: [], getPosition: m.getPosition || null, orientToDirection: !!m.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0] };
5681
+ async function is(f, h = {}) {
5682
+ const S = await kt(f, [0, 0, 0]);
5683
+ globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(f && f.systems || []).length} newIds=[${[...S]}]`);
5684
+ const g = { ids: S, pos: null, hist: [], getPosition: h.getPosition || null, orientToDirection: !!h.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
5687
5685
  return W.push(g), {
5688
5686
  setPosition(v) {
5689
5687
  v && (g.pos = Array.isArray(v) ? [v[0], v[1], v[2]] : [v.x, v.y, v.z]);
@@ -5692,14 +5690,14 @@ async function gr(s, t = {}) {
5692
5690
  g.orientToDirection = !!v;
5693
5691
  },
5694
5692
  remove() {
5695
- Vt(b);
5693
+ Nt(S);
5696
5694
  const v = W.indexOf(g);
5697
5695
  v >= 0 && W.splice(v, 1);
5698
5696
  }
5699
5697
  };
5700
5698
  }
5701
- function es(f, m) {
5702
- const g = { ids: f instanceof Set ? f : new Set(f), pos: null, hist: [], getPosition: m, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0] };
5699
+ function ss(f, h) {
5700
+ const g = { ids: f instanceof Set ? f : new Set(f), pos: null, hist: [], getPosition: h, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
5703
5701
  return W.push(g), {
5704
5702
  remove() {
5705
5703
  const v = W.indexOf(g);
@@ -5718,77 +5716,85 @@ async function gr(s, t = {}) {
5718
5716
  manager: l,
5719
5717
  device: r,
5720
5718
  context: n,
5721
- setCamera: Yi,
5722
- setCameraMVP: Hi,
5723
- setEmitters: dt,
5724
- loadPreset: qi,
5725
- addEmitter: Qi,
5726
- addMovingEmitter: Ki,
5727
- render: Zi,
5728
- resize: $i,
5729
- clearCaches: Wi,
5730
- trackHistoryGroup: es,
5731
- destroy: Ji
5719
+ setCamera: Zi,
5720
+ setCameraMVP: $i,
5721
+ setEmitters: ht,
5722
+ loadPreset: Wi,
5723
+ addEmitter: ts,
5724
+ addMovingEmitter: is,
5725
+ render: Ji,
5726
+ resize: Qi,
5727
+ clearCaches: Ki,
5728
+ trackHistoryGroup: ss,
5729
+ destroy: es
5732
5730
  };
5733
5731
  }
5734
- function br(s) {
5732
+ function Pr(s) {
5735
5733
  return () => {
5736
- var t, e, i, r, n, a;
5734
+ var t, e, i, r, n, a, o, c;
5737
5735
  try {
5738
- const o = s.backend;
5739
- if (!o) return null;
5740
- if (s.needsFrameBufferTarget && s._frameBufferTarget) {
5741
- const u = (i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, s._frameBufferTarget)) == null ? void 0 : i.depthTexture, h = u ? (r = o.get(u)) == null ? void 0 : r.texture : null;
5742
- if (h && h.width === s.domElement.width && h.height === s.domElement.height) return h;
5736
+ const l = s.backend;
5737
+ if (!l) return null;
5738
+ const u = s.domElement.width, m = s.domElement.height, p = (typeof s._getFrameBufferTarget == "function" ? s._getFrameBufferTarget() : null) || s._frameBufferTarget || null;
5739
+ if (s.needsFrameBufferTarget && p) {
5740
+ const w = l.get(p), M = ((i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, p)) == null ? void 0 : i.depthTexture) || p.depthTexture, R = [
5741
+ (r = w == null ? void 0 : w.depthTexture) == null ? void 0 : r.texture,
5742
+ w == null ? void 0 : w.depthTexture,
5743
+ (n = w == null ? void 0 : w.depthBuffer) == null ? void 0 : n.texture,
5744
+ M ? (a = l.get(M)) == null ? void 0 : a.texture : null
5745
+ ];
5746
+ for (const x of R)
5747
+ if (x && typeof x.createView == "function" && x.width === u && x.height === m) return x;
5748
+ return null;
5743
5749
  }
5744
- const c = s.getCanvasTarget ? o.get(s.getCanvasTarget()) : null, l = ((a = (n = c == null ? void 0 : c.descriptor) == null ? void 0 : n.depthStencilAttachment) == null ? void 0 : a.view) ?? null;
5745
- return l ? { view: l, multisampled: (s.currentSamples ?? 0) > 1 } : null;
5750
+ const d = s.getCanvasTarget ? l.get(s.getCanvasTarget()) : null, b = ((c = (o = d == null ? void 0 : d.descriptor) == null ? void 0 : o.depthStencilAttachment) == null ? void 0 : c.view) ?? null;
5751
+ return b ? { view: b, multisampled: (s.currentSamples ?? 0) > 1 } : null;
5746
5752
  } catch {
5747
5753
  return null;
5748
5754
  }
5749
5755
  };
5750
5756
  }
5751
5757
  export {
5752
- Os as GLBAnimator,
5753
- Ls as HZClock,
5754
- cr as Objects3DManager,
5755
- fs as ParticleEmitter,
5756
- xs as ParticlePhysics,
5757
- ni as ParticleScript,
5758
- bt as ParticleSystem,
5759
- Hs as ParticleSystemManager,
5760
- vs as ParticleTextureManager,
5761
- hs as blurShader,
5762
- ms as compositeShader,
5763
- Ws as createBindGroupLayouts,
5764
- St as createBindGroups,
5758
+ Ns as GLBAnimator,
5759
+ js as HZClock,
5760
+ pr as Objects3DManager,
5761
+ ms as ParticleEmitter,
5762
+ _s as ParticlePhysics,
5763
+ ui as ParticleScript,
5764
+ vt as ParticleSystem,
5765
+ Ws as ParticleSystemManager,
5766
+ ws as ParticleTextureManager,
5767
+ gs as blurShader,
5768
+ bs as compositeShader,
5769
+ er as createBindGroupLayouts,
5770
+ Pt as createBindGroups,
5765
5771
  Ge as createBuffer,
5766
- Ks as createCubeGeometry,
5767
- hi as createDepthTexture,
5768
- fr as createLookAtMatrix,
5769
- pr as createProjectionMatrix,
5770
- Js as createRenderPipelines,
5771
- pi as createRenderTextures,
5772
- Qs as createSampler,
5773
- er as createSphereGeometry,
5774
- ys as directRenderShader,
5775
- oi as extractGLBTexture,
5776
- yr as fetchPreset,
5777
- $s as glbMeshParticleShader,
5778
- ur as hexToRgb,
5779
- gr as initHzFxOverlay,
5780
- qs as initWebGPU,
5781
- Bi as isHZFX,
5782
- mr as loadScene,
5783
- br as makeThreeSceneDepth,
5784
- ir as multiplyMatrices,
5785
- Zs as object3dShader,
5786
- rr as packHZFX,
5787
- Rs as parseGLB,
5788
- bs as particlePhysicsShader,
5789
- ps as particleShader,
5790
- dr as rgbToHex,
5791
- hr as saveScene,
5792
- ar as serializeSystemConfig,
5793
- Mi as unpackHZFX
5772
+ sr as createCubeGeometry,
5773
+ gi as createDepthTexture,
5774
+ yr as createLookAtMatrix,
5775
+ gr as createProjectionMatrix,
5776
+ tr as createRenderPipelines,
5777
+ yi as createRenderTextures,
5778
+ ir as createSampler,
5779
+ rr as createSphereGeometry,
5780
+ Ss as directRenderShader,
5781
+ fi as extractGLBTexture,
5782
+ xr as fetchPreset,
5783
+ Ks as glbMeshParticleShader,
5784
+ hr as hexToRgb,
5785
+ vr as initHzFxOverlay,
5786
+ Js as initWebGPU,
5787
+ Ti as isHZFX,
5788
+ Sr as loadScene,
5789
+ Pr as makeThreeSceneDepth,
5790
+ ar as multiplyMatrices,
5791
+ Qs as object3dShader,
5792
+ lr as packHZFX,
5793
+ Cs as parseGLB,
5794
+ vs as particlePhysicsShader,
5795
+ ys as particleShader,
5796
+ mr as rgbToHex,
5797
+ br as saveScene,
5798
+ ur as serializeSystemConfig,
5799
+ Ei as unpackHZFX
5794
5800
  };