hz-particles 1.4.3 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- class ms {
1
+ class Ys {
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,15 +10,15 @@ class ms {
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), p = Math.cos(a), h = 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), d = Math.sin(n), S = Math.cos(a), b = Math.sin(a);
14
14
  this._rotMatrix = [
15
- l * p,
16
- c * u * p - o * h,
17
- o * u * p + c * h,
18
- l * h,
19
- c * u * h + o * p,
20
- o * u * h - c * p,
21
- -u,
15
+ l * S,
16
+ c * d * S - o * b,
17
+ o * d * S + c * b,
18
+ l * b,
19
+ c * d * b + o * S,
20
+ o * d * b - c * S,
21
+ -d,
22
22
  c * l,
23
23
  o * l
24
24
  ], this._invRotMatrix = [
@@ -37,8 +37,8 @@ class ms {
37
37
  const r = this._posOut;
38
38
  if (this.config.emissionShape === "cube" || this.config.emissionShape === "box" ? this._emitFromCube(r) : this.config.emissionShape === "sphere" ? this._emitFromSphere(r) : this.config.emissionShape === "square" ? this._emitFromSquare(r) : this.config.emissionShape === "circle" ? this._emitFromCircle(r) : this.config.emissionShape === "cylinder" ? this._emitFromCylinder(r) : this.config.emissionShape === "plain" ? this._emitFromPlain(r) : this.config.emissionShape === "cone" ? this._emitFromCone(r) : this.config.emissionShape === "torus" ? this._emitFromTorus(r) : this.config.emissionShape === "line" ? this._emitFromLine(r) : this.config.emissionShape === "hemisphere" ? this._emitFromHemisphere(r) : this.config.emissionShape === "disc" ? this._emitFromDisc(r) : this.config.emissionShape === "annulus" ? this._emitFromAnnulus(r) : this.config.emissionShape === "capsule" ? this._emitFromCapsule(r) : this.config.emissionShape === "arc" ? this._emitFromArc(r) : this.config.emissionShape === "spiral" ? this._emitFromSpiral(r) : this.config.emissionShape === "frustum" ? this._emitFromFrustum(r) : this.config.emissionShape === "frustumSurface" ? this._emitFromFrustumSurface(r) : this.config.emissionShape === "cubeSurface" ? this._emitFromCubeSurface(r) : this.config.emissionShape === "sphereSurface" ? this._emitFromSphereSurface(r) : this.config.emissionShape === "boxFrame" ? this._emitFromBoxFrame(r) : this.config.emissionShape === "polygon" ? this._emitFromPolygon(r) : this.config.emissionShape === "rectangle" ? this._emitFromRectangle(r) : (r[0] = 0, r[1] = 0, r[2] = 0), this.config.emissionRotationX || this.config.emissionRotationY || this.config.emissionRotationZ) {
39
39
  this._updateRotationMatrix();
40
- const o = this._rotMatrix, c = r[0], l = r[1], u = r[2];
41
- r[0] = o[0] * c + o[1] * l + o[2] * u, r[1] = o[3] * c + o[4] * l + o[5] * u, r[2] = o[6] * c + o[7] * l + o[8] * u;
40
+ const o = this._rotMatrix, c = r[0], l = r[1], d = r[2];
41
+ r[0] = o[0] * c + o[1] * l + o[2] * d, r[1] = o[3] * c + o[4] * l + o[5] * d, r[2] = o[6] * c + o[7] * l + o[8] * d;
42
42
  }
43
43
  (this.config.emissionPositionX || this.config.emissionPositionY || this.config.emissionPositionZ) && (r[0] += this.config.emissionPositionX || 0, r[1] += this.config.emissionPositionY || 0, r[2] += this.config.emissionPositionZ || 0);
44
44
  const n = e * 8;
@@ -91,8 +91,8 @@ class ms {
91
91
  o = n, c = -0.5, l = a;
92
92
  break;
93
93
  }
94
- const u = Math.random(), p = e + u * (i - e);
95
- t[0] = o * p, t[1] = c * p, t[2] = l * p;
94
+ const d = Math.random(), S = e + d * (i - e);
95
+ t[0] = o * S, t[1] = c * S, t[2] = l * S;
96
96
  } else
97
97
  t[0] = (Math.random() - 0.5) * i, t[1] = (Math.random() - 0.5) * i, t[2] = (Math.random() - 0.5) * i;
98
98
  }
@@ -137,8 +137,8 @@ class ms {
137
137
  const e = this.config.coneInnerRadius || 0, i = this.config.coneOuterRadius || 2, r = this.config.coneHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r, c = i * (1 - a);
138
138
  let l;
139
139
  if (e > 0) {
140
- const u = e * (1 - a);
141
- l = u + (c - u) * Math.random();
140
+ const d = e * (1 - a);
141
+ l = d + (c - d) * Math.random();
142
142
  } else
143
143
  l = c * Math.sqrt(Math.random());
144
144
  t[0] = Math.cos(n) * l, t[1] = o, t[2] = Math.sin(n) * l;
@@ -170,8 +170,8 @@ class ms {
170
170
  const c = Math.random() * Math.PI * 2, l = e * Math.sqrt(Math.random());
171
171
  t[0] = Math.cos(c) * l, t[1] = (Math.random() - 0.5) * i, t[2] = Math.sin(c) * l;
172
172
  } else {
173
- const c = Math.random() * Math.PI * 2, l = Math.acos(2 * Math.random() - 1), u = e * Math.cbrt(Math.random());
174
- t[0] = u * Math.sin(l) * Math.cos(c), t[1] = u * Math.cos(l), t[2] = u * Math.sin(l) * Math.sin(c), t[1] += t[1] >= 0 ? r : -r;
173
+ const c = Math.random() * Math.PI * 2, l = Math.acos(2 * Math.random() - 1), d = e * Math.cbrt(Math.random());
174
+ t[0] = d * Math.sin(l) * Math.cos(c), t[1] = d * Math.cos(l), t[2] = d * Math.sin(l) * Math.sin(c), t[1] += t[1] >= 0 ? r : -r;
175
175
  }
176
176
  }
177
177
  _emitFromArc(t) {
@@ -193,11 +193,11 @@ class ms {
193
193
  if (Math.abs(a) < 1e-6 || o <= 1e-6)
194
194
  c = Math.random();
195
195
  else {
196
- const p = Math.random(), h = 0.5 * a, d = e, b = -p * o, _ = Math.max(0, d * d - 4 * h * b);
197
- c = (-d + Math.sqrt(_)) / (2 * h), Number.isFinite(c) || (c = Math.random()), c = Math.min(1, Math.max(0, c));
196
+ const S = Math.random(), b = 0.5 * a, p = e, v = -S * o, E = Math.max(0, p * p - 4 * b * v);
197
+ c = (-p + Math.sqrt(E)) / (2 * b), Number.isFinite(c) || (c = Math.random()), c = Math.min(1, Math.max(0, c));
198
198
  }
199
- const l = c * r, u = e + a * c;
200
- t[0] = Math.cos(n) * u, t[1] = l, t[2] = Math.sin(n) * u;
199
+ const l = c * r, d = e + a * c;
200
+ t[0] = Math.cos(n) * d, t[1] = l, t[2] = Math.sin(n) * d;
201
201
  }
202
202
  _emitFromCubeSurface(t) {
203
203
  const e = this.config.cubeSurfaceSize || 2, i = e * 0.5, r = Math.floor(Math.random() * 6), n = (Math.random() - 0.5) * e, a = (Math.random() - 0.5) * e;
@@ -243,8 +243,8 @@ class ms {
243
243
  const e = Math.max(3, Math.floor(this.config.polygonSides || 6)), i = this.config.polygonRadius || 2, r = Math.floor(Math.random() * e), n = r / e * Math.PI * 2, a = (r + 1) / e * Math.PI * 2;
244
244
  let o = Math.random(), c = Math.random();
245
245
  o + c > 1 && (o = 1 - o, c = 1 - c);
246
- const l = o * Math.cos(n) + c * Math.cos(a), u = o * Math.sin(n) + c * Math.sin(a);
247
- t[0] = l * i, t[1] = u * i, t[2] = 0;
246
+ const l = o * Math.cos(n) + c * Math.cos(a), d = o * Math.sin(n) + c * Math.sin(a);
247
+ t[0] = l * i, t[1] = d * i, t[2] = 0;
248
248
  }
249
249
  _emitFromRectangle(t) {
250
250
  const e = this.config.rectangleWidth || 2, i = this.config.rectangleHeight || 2;
@@ -256,33 +256,33 @@ class ms {
256
256
  e > 0 ? a = e + (i - e) * Math.random() : a = i * Math.sqrt(Math.random()), t[0] = Math.cos(n) * a, t[1] = (Math.random() - 0.5) * r, t[2] = Math.sin(n) * a;
257
257
  }
258
258
  calculateVelocity(t, e, i, r, n) {
259
- const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, u = e - o, p = i - c, h = Math.sqrt(l * l + u * u + p * p);
260
- let d, b, _;
261
- if (h > 1e-4) {
262
- let R = !1;
259
+ const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, d = e - o, S = i - c, b = Math.sqrt(l * l + d * d + S * S);
260
+ let p, v, E;
261
+ if (b > 1e-4) {
262
+ let z = !1;
263
263
  if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
264
- const x = this.inverseRotation(l, u, p), L = Math.sqrt(x[0] * x[0] + x[1] * x[1]);
265
- if (L > 1e-4) {
266
- const P = -x[1] / L, T = x[0] / L, E = this.applyRotation(P, T, 0);
267
- d = E[0], b = E[1], _ = E[2], R = !0;
264
+ const _ = this.inverseRotation(l, d, S), W = Math.sqrt(_[0] * _[0] + _[1] * _[1]);
265
+ if (W > 1e-4) {
266
+ const T = -_[1] / W, F = _[0] / W, G = this.applyRotation(T, F, 0);
267
+ p = G[0], v = G[1], E = G[2], z = !0;
268
268
  }
269
269
  } else if (this.config.emissionShape === "cylinder" && this.config.cylinderVelocityDirection === "tangential") {
270
- const x = this.inverseRotation(l, u, p), L = Math.sqrt(x[0] * x[0] + x[2] * x[2]);
271
- if (L > 1e-4) {
272
- const P = -x[2] / L, T = x[0] / L, E = this.applyRotation(P, 0, T);
273
- d = E[0], b = E[1], _ = E[2], R = !0;
270
+ const _ = this.inverseRotation(l, d, S), W = Math.sqrt(_[0] * _[0] + _[2] * _[2]);
271
+ if (W > 1e-4) {
272
+ const T = -_[2] / W, F = _[0] / W, G = this.applyRotation(T, 0, F);
273
+ p = G[0], v = G[1], E = G[2], z = !0;
274
274
  } else {
275
- const P = Math.random() * Math.PI * 2, T = this.applyRotation(Math.cos(P), 0, Math.sin(P));
276
- d = T[0], b = T[1], _ = T[2], R = !0;
275
+ const T = Math.random() * Math.PI * 2, F = this.applyRotation(Math.cos(T), 0, Math.sin(T));
276
+ p = F[0], v = F[1], E = F[2], z = !0;
277
277
  }
278
278
  }
279
- R || (d = l / h, b = u / h, _ = p / h);
279
+ z || (p = l / b, v = d / b, E = S / b);
280
280
  } else {
281
- const R = Math.random() * Math.PI * 2, x = Math.acos(2 * Math.random() - 1);
282
- d = Math.sin(x) * Math.cos(R), b = Math.sin(x) * Math.sin(R), _ = Math.cos(x);
281
+ const z = Math.random() * Math.PI * 2, _ = Math.acos(2 * Math.random() - 1);
282
+ p = Math.sin(_) * Math.cos(z), v = Math.sin(_) * Math.sin(z), E = Math.cos(_);
283
283
  }
284
- let M;
285
- 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 : _ * M, r[n + 3] = 0;
284
+ let I;
285
+ this.config.randomSpeed ? I = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : I = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : p * I, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : v * I, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : E * I, r[n + 3] = 0;
286
286
  }
287
287
  setParticleColor(t, e) {
288
288
  if (this.config.randomColorEnabled && this.config.randomColors.length > 0) {
@@ -295,7 +295,7 @@ class ms {
295
295
  t[e + 6] = 0, t[e + 7] = i + (Math.random() * 0.4 - 0.2) * i;
296
296
  }
297
297
  }
298
- const ys = `
298
+ const js = `
299
299
  struct Uniforms {
300
300
  transform: mat4x4<f32>,
301
301
  cameraPosition: vec3<f32>,
@@ -719,7 +719,7 @@ const ys = `
719
719
  return vec4<f32>(input.color, alpha);
720
720
  }
721
721
  }
722
- `, gs = `
722
+ `, qs = `
723
723
  struct BloomUniforms {
724
724
  direction: vec2<f32>,
725
725
  resolution: vec2<f32>,
@@ -779,7 +779,7 @@ const ys = `
779
779
 
780
780
  return result / totalWeight * 1.1;
781
781
  }
782
- `, bs = `
782
+ `, Zs = `
783
783
  struct BloomIntensityUniforms {
784
784
  intensity: f32,
785
785
  color: vec3<f32>,
@@ -825,7 +825,7 @@ const ys = `
825
825
 
826
826
  return vec4<f32>(originalColor.rgb + (mappedBloom * bloomUniforms.intensity), originalColor.a);
827
827
  }
828
- `, Ss = `
828
+ `, Hs = `
829
829
  struct BloomIntensityUniforms {
830
830
  intensity: f32,
831
831
  color: vec3<f32>,
@@ -866,7 +866,7 @@ const ys = `
866
866
  fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
867
867
  return textureSample(originalTexture, texSampler, input.texCoord);
868
868
  }
869
- `, xs = `
869
+ `, Ws = `
870
870
  @binding(0) @group(0) var texSampler: sampler;
871
871
  @binding(1) @group(0) var originalTexture: texture_2d<f32>;
872
872
  @binding(2) @group(0) var blurredTexture: texture_2d<f32>;
@@ -898,7 +898,7 @@ const ys = `
898
898
  let c = textureSample(originalTexture, texSampler, input.texCoord);
899
899
  return vec4<f32>(aces(c.rgb), c.a);
900
900
  }
901
- `, vs = `
901
+ `, $s = `
902
902
  struct PhysicsUniforms {
903
903
  deltaTime: f32,
904
904
  particleSpeed: f32,
@@ -1108,7 +1108,7 @@ const ys = `
1108
1108
  particleBuffer[baseIndex + 1u] = newPos.y;
1109
1109
  particleBuffer[baseIndex + 2u] = newPos.z;
1110
1110
  }
1111
- `, Ps = `
1111
+ `, Js = `
1112
1112
  @group(0) @binding(0) var<storage, read> restData: array<f32>;
1113
1113
  @group(0) @binding(1) var<storage, read> jointWeightsData: array<f32>;
1114
1114
  @group(0) @binding(2) var<storage, read> jointIndicesData: array<u32>;
@@ -1165,7 +1165,7 @@ const ys = `
1165
1165
  outputData[outBase + 7u] = uv_v;
1166
1166
  }
1167
1167
  `;
1168
- class _s {
1168
+ class Ks {
1169
1169
  constructor(t, e = 1e4) {
1170
1170
  this.device = t, this.physicsSettings = {
1171
1171
  deltaTime: 0.016,
@@ -1254,7 +1254,7 @@ class _s {
1254
1254
  }),
1255
1255
  compute: {
1256
1256
  module: this.device.createShaderModule({
1257
- code: vs
1257
+ code: $s
1258
1258
  }),
1259
1259
  entryPoint: "main"
1260
1260
  }
@@ -1285,10 +1285,10 @@ class _s {
1285
1285
  return;
1286
1286
  const o = this._physicsData, c = this.physicsSettings;
1287
1287
  o[0] = t, o[1] = i.particleSpeed, o[2] = c.gravity, o[3] = c.turbulence, o[4] = c.attractorStrength, o[5] = c.damping, o[6] = c.attractorPosition[0], o[7] = c.attractorPosition[1], o[8] = c.attractorPosition[2], this._physicsDataU32View[9] = e, o[10] = c.confinementEnabled ? 1 : 0, o[11] = c.confinementShape === "sphere" ? 1 : 0, o[12] = c.confinementMode === "kill" ? 1 : 0, o[13] = c.confinementSpace === "local" ? 1 : 0, o[14] = c.confinementBoxHalfSize[0], o[15] = c.confinementBoxHalfSize[1], o[16] = c.confinementBoxHalfSize[2], o[17] = c.confinementSphereRadius, o[18] = c.confinementRestitution, o[19] = c.confinementFriction, o[20] = c.confinementCenter[0], o[21] = c.confinementCenter[1], o[22] = c.confinementCenter[2], o[23] = c.softBoundaryEnabled ? 1 : 0, o[24] = c.softBoundaryStrength, o[25] = c.softBoundaryFalloff, o[26] = i.velocityStretchEnabled ? 1 : 0, o[27] = i.velocityStretchFactor ?? 1, o[28] = 0, o[29] = 0, o[30] = 0, o[31] = 0, this.device.queue.writeBuffer(this.physicsUniformBuffer, 0, o);
1288
- const l = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }), u = l.beginComputePass({ label: "ParticlePhysicsPass" });
1289
- u.setPipeline(this.computePipeline), u.setBindGroup(0, this.computeBindGroup);
1290
- const p = Math.max(1, Math.ceil(e / 64));
1291
- u.dispatchWorkgroups(p, 1, 1), u.end(), a || this.device.queue.submit([l.finish()]), this.lastUpdateTime = performance.now() / 1e3;
1288
+ const l = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }), d = l.beginComputePass({ label: "ParticlePhysicsPass" });
1289
+ d.setPipeline(this.computePipeline), d.setBindGroup(0, this.computeBindGroup);
1290
+ const S = Math.max(1, Math.ceil(e / 64));
1291
+ d.dispatchWorkgroups(S, 1, 1), d.end(), a || this.device.queue.submit([l.finish()]), this.lastUpdateTime = performance.now() / 1e3;
1292
1292
  }
1293
1293
  async readbackAndProcessParticles(t, e, i, r, n) {
1294
1294
  if (t <= 0)
@@ -1461,7 +1461,7 @@ class _s {
1461
1461
  t.enabled !== void 0 && (e.softBoundaryEnabled = t.enabled), t.strength !== void 0 && (e.softBoundaryStrength = t.strength), t.falloff !== void 0 && (e.softBoundaryFalloff = t.falloff);
1462
1462
  }
1463
1463
  }
1464
- class ws {
1464
+ class Qs {
1465
1465
  constructor(t) {
1466
1466
  this.device = t, this.defaultTexture = null, this.createDefaultTexture();
1467
1467
  }
@@ -1500,7 +1500,7 @@ class ws {
1500
1500
  t && t.label !== "defaultParticleTexture" && t.destroy();
1501
1501
  }
1502
1502
  }
1503
- const Pi = Object.freeze({
1503
+ const Hi = Object.freeze({
1504
1504
  sin: Math.sin,
1505
1505
  cos: Math.cos,
1506
1506
  abs: Math.abs,
@@ -1521,10 +1521,10 @@ const Pi = Object.freeze({
1521
1521
  return s + (t - s) * e;
1522
1522
  },
1523
1523
  smoothstep(s, t, e) {
1524
- const i = Pi.clamp((e - s) / (t - s), 0, 1);
1524
+ const i = Hi.clamp((e - s) / (t - s), 0, 1);
1525
1525
  return i * i * (3 - 2 * i);
1526
1526
  }
1527
- }), $e = /* @__PURE__ */ new Set([
1527
+ }), Ct = /* @__PURE__ */ new Set([
1528
1528
  "particleSize",
1529
1529
  "particleSpeed",
1530
1530
  "particleColor",
@@ -1539,9 +1539,35 @@ const Pi = Object.freeze({
1539
1539
  "attractorPosition",
1540
1540
  "pulseAmplitude",
1541
1541
  "pulseFrequency",
1542
- "bloomIntensity"
1542
+ "bloomIntensity",
1543
+ "emissionPositionX",
1544
+ "emissionPositionY",
1545
+ "emissionPositionZ",
1546
+ "emissionRotationX",
1547
+ "emissionRotationY",
1548
+ "emissionRotationZ",
1549
+ "circleInnerRadius",
1550
+ "circleOuterRadius",
1551
+ "discRadius",
1552
+ "annulusInnerRadius",
1553
+ "annulusOuterRadius",
1554
+ "arcStartAngle",
1555
+ "arcEndAngle",
1556
+ "arcInnerRadius",
1557
+ "arcOuterRadius",
1558
+ "squareSize",
1559
+ "rectangleWidth",
1560
+ "rectangleHeight",
1561
+ "planeWidth",
1562
+ "planeDepth",
1563
+ "lineLength",
1564
+ "polygonRadius",
1565
+ "shapeStrokeWidth",
1566
+ "shapeStrokeAmplitude",
1567
+ "shapeStrokeFrequency",
1568
+ "shapeStrokeSpeed"
1543
1569
  ]);
1544
- class Bs {
1570
+ class er {
1545
1571
  constructor(t) {
1546
1572
  this._collection = t, this._pd = null, this._vd = null, this._pi = 0, this._vi = 0;
1547
1573
  }
@@ -1619,9 +1645,9 @@ class Bs {
1619
1645
  this._vd[this._vi + 2] = t, this._collection._dirty = !0;
1620
1646
  }
1621
1647
  }
1622
- class Ms {
1648
+ class tr {
1623
1649
  constructor() {
1624
- this._proxy = new Bs(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
1650
+ this._proxy = new er(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
1625
1651
  }
1626
1652
  _bind(t, e, i) {
1627
1653
  this._pd = t, this._vd = e, this.count = i, this._dirty = !1;
@@ -1630,14 +1656,14 @@ class Ms {
1630
1656
  return t < 0 || t >= this.count ? null : this._proxy._bind(this._pd, this._vd, t);
1631
1657
  }
1632
1658
  }
1633
- const Rs = 1e6;
1634
- function Ts(s) {
1659
+ const ir = 1e6;
1660
+ function sr(s) {
1635
1661
  let t = 0;
1636
1662
  return s.replace(
1637
1663
  /\b(for|while)\s*\([^)]*\)\s*\{/g,
1638
1664
  (e) => {
1639
1665
  const i = `__lc${t++}`;
1640
- return `${e} if(++${i}>${Rs})throw new Error("Loop limit exceeded");`;
1666
+ return `${e} if(++${i}>${ir})throw new Error("Loop limit exceeded");`;
1641
1667
  }
1642
1668
  ).replace(
1643
1669
  /\b(for|while)\s*\([^)]*\)\s*\{/g,
@@ -1654,10 +1680,10 @@ function Ts(s) {
1654
1680
  }
1655
1681
  );
1656
1682
  }
1657
- const wt = /* @__PURE__ */ new Map();
1658
- for (const s of $e)
1659
- wt.set(s.toLowerCase(), s);
1660
- function Es(s) {
1683
+ const ni = /* @__PURE__ */ new Map();
1684
+ for (const s of Ct)
1685
+ ni.set(s.toLowerCase(), s);
1686
+ function rr(s) {
1661
1687
  const t = { value: !1 }, e = /* @__PURE__ */ new Set();
1662
1688
  return new Proxy(s, {
1663
1689
  get(r, n) {
@@ -1666,16 +1692,16 @@ function Es(s) {
1666
1692
  t.value = !1;
1667
1693
  };
1668
1694
  if (typeof n != "string") return;
1669
- if ($e.has(n)) return r[n];
1670
- const a = wt.get(n.toLowerCase());
1695
+ if (Ct.has(n)) return r[n];
1696
+ const a = ni.get(n.toLowerCase());
1671
1697
  if (a)
1672
1698
  return e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${a}?`)), r[a];
1673
1699
  },
1674
1700
  set(r, n, a) {
1675
1701
  if (typeof n != "string") return !0;
1676
1702
  let o = n;
1677
- if (!$e.has(o)) {
1678
- const c = wt.get(o.toLowerCase());
1703
+ if (!Ct.has(o)) {
1704
+ const c = ni.get(o.toLowerCase());
1679
1705
  if (c)
1680
1706
  e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${c}?`)), o = c;
1681
1707
  else
@@ -1685,14 +1711,14 @@ function Es(s) {
1685
1711
  }
1686
1712
  });
1687
1713
  }
1688
- class ui {
1714
+ class Gi {
1689
1715
  /**
1690
1716
  * @param {string} source - User script source code
1691
1717
  * @param {object} config - ParticleSystem config (will be proxied)
1692
1718
  * @param {number} maxParticles - Max particle count for pre-allocation
1693
1719
  */
1694
1720
  constructor(t, e, i) {
1695
- this._particles = new Ms(), this._configProxy = Es(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
1721
+ this._particles = new tr(), this._configProxy = rr(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
1696
1722
  }
1697
1723
  /**
1698
1724
  * Compile script source into a sandboxed function.
@@ -1708,7 +1734,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1708
1734
  var deltaTime = __deltaTime, time = __time;
1709
1735
  var currentFrame = __currentFrame, totalFrames = __totalFrames;
1710
1736
  var particles = __particles, config = __config, math = __math;
1711
- ${Ts(t)}
1737
+ ${sr(t)}
1712
1738
  };`, r = new Function(i);
1713
1739
  this._fn = r();
1714
1740
  } catch (e) {
@@ -1730,7 +1756,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1730
1756
  if (!this._fn || this._error) return { configDirty: !1, particlesDirty: !1 };
1731
1757
  this._particles._bind(n, a, o), this._configProxy.__resetDirty();
1732
1758
  try {
1733
- this._fn(t, e, i, r, this._particles, this._configProxy, Pi);
1759
+ this._fn(t, e, i, r, this._particles, this._configProxy, Hi);
1734
1760
  } catch (c) {
1735
1761
  console.warn("[ParticleScript] Runtime error:", c.message);
1736
1762
  }
@@ -1744,7 +1770,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1744
1770
  */
1745
1771
  snapshotConfig(t) {
1746
1772
  const e = {};
1747
- for (const i of $e) {
1773
+ for (const i of Ct) {
1748
1774
  const r = t[i];
1749
1775
  r !== void 0 && (e[i] = Array.isArray(r) ? [...r] : r);
1750
1776
  }
@@ -1755,7 +1781,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1755
1781
  */
1756
1782
  restoreConfig(t) {
1757
1783
  if (this._configSnapshot) {
1758
- for (const e of $e)
1784
+ for (const e of Ct)
1759
1785
  if (e in this._configSnapshot) {
1760
1786
  const i = this._configSnapshot[e];
1761
1787
  t[e] = Array.isArray(i) ? [...i] : i;
@@ -1769,7 +1795,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
1769
1795
  this._fn = null, this._particles = null, this._configProxy = null, this._configSnapshot = null;
1770
1796
  }
1771
1797
  }
1772
- async function As(s) {
1798
+ async function nr(s) {
1773
1799
  const t = new DataView(s);
1774
1800
  if (t.getUint32(0, !0) !== 1179937895)
1775
1801
  throw new Error("Invalid GLB file: incorrect magic number");
@@ -1779,12 +1805,12 @@ async function As(s) {
1779
1805
  const r = t.getUint32(8, !0);
1780
1806
  let n = 12, a = null, o = null;
1781
1807
  for (; n < r; ) {
1782
- const P = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), E = s.slice(n + 8, n + 8 + P);
1783
- if (T === 1313821514) {
1784
- const N = new TextDecoder("utf-8").decode(E);
1785
- a = JSON.parse(N);
1786
- } else T === 5130562 && (o = E);
1787
- n += 8 + P;
1808
+ const T = t.getUint32(n, !0), F = t.getUint32(n + 4, !0), G = s.slice(n + 8, n + 8 + T);
1809
+ if (F === 1313821514) {
1810
+ const re = new TextDecoder("utf-8").decode(G);
1811
+ a = JSON.parse(re);
1812
+ } else F === 5130562 && (o = G);
1813
+ n += 8 + T;
1788
1814
  }
1789
1815
  if (!a)
1790
1816
  throw new Error("GLB file missing JSON chunk");
@@ -1793,50 +1819,50 @@ async function As(s) {
1793
1819
  const l = a.meshes[0].primitives[0];
1794
1820
  if (!l)
1795
1821
  throw new Error("First mesh has no primitives");
1796
- const u = l.attributes.POSITION;
1797
- if (u === void 0)
1822
+ const d = l.attributes.POSITION;
1823
+ if (d === void 0)
1798
1824
  throw new Error("Mesh primitive missing POSITION attribute");
1799
- const p = xt(a, o, u, 3, 5126);
1800
- let h;
1825
+ const S = ti(a, o, d, 3, 5126);
1826
+ let b;
1801
1827
  if (l.attributes.NORMAL !== void 0)
1802
- h = xt(a, o, l.attributes.NORMAL, 3, 5126);
1828
+ b = ti(a, o, l.attributes.NORMAL, 3, 5126);
1803
1829
  else {
1804
- const P = l.indices;
1805
- if (P === void 0)
1830
+ const T = l.indices;
1831
+ if (T === void 0)
1806
1832
  throw new Error("Cannot generate normals without indices");
1807
- const T = di(a, o, P);
1808
- h = Cs(p, T);
1833
+ const F = Di(a, o, T);
1834
+ b = ar(S, F);
1809
1835
  }
1810
- const d = l.indices;
1811
- if (d === void 0)
1836
+ const p = l.indices;
1837
+ if (p === void 0)
1812
1838
  throw new Error("Mesh primitive missing indices");
1813
- const b = di(a, o, d), _ = p.length / 3, M = b.length;
1814
- let R = null;
1815
- l.attributes.TEXCOORD_0 !== void 0 && (R = xt(a, o, l.attributes.TEXCOORD_0, 2, 5126));
1816
- let x = !1;
1839
+ const v = Di(a, o, p), E = S.length / 3, I = v.length;
1840
+ let z = null;
1841
+ l.attributes.TEXCOORD_0 !== void 0 && (z = ti(a, o, l.attributes.TEXCOORD_0, 2, 5126));
1842
+ let _ = !1;
1817
1843
  if (a.materials && a.materials.length > 0) {
1818
- const P = a.materials[0];
1819
- P.pbrMetallicRoughness && P.pbrMetallicRoughness.baseColorTexture !== void 0 && (x = !0);
1844
+ const T = a.materials[0];
1845
+ T.pbrMetallicRoughness && T.pbrMetallicRoughness.baseColorTexture !== void 0 && (_ = !0);
1820
1846
  }
1821
- let L = null;
1847
+ let W = null;
1822
1848
  if (a.skins && a.skins.length > 0)
1823
1849
  try {
1824
- L = Ds(a, o, l), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", L);
1825
- } catch (P) {
1826
- console.warn("Failed to extract animation data:", P);
1850
+ W = fr(a, o, l), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", W);
1851
+ } catch (T) {
1852
+ console.warn("Failed to extract animation data:", T);
1827
1853
  }
1828
1854
  return {
1829
- positions: p,
1830
- normals: h,
1831
- indices: b,
1832
- texCoords: R,
1833
- vertexCount: _,
1834
- indexCount: M,
1835
- animationData: L,
1836
- hasBaseColorTexture: x
1855
+ positions: S,
1856
+ normals: b,
1857
+ indices: v,
1858
+ texCoords: z,
1859
+ vertexCount: E,
1860
+ indexCount: I,
1861
+ animationData: W,
1862
+ hasBaseColorTexture: _
1837
1863
  };
1838
1864
  }
1839
- function xt(s, t, e, i, r) {
1865
+ function ti(s, t, e, i, r) {
1840
1866
  const n = s.accessors[e], o = {
1841
1867
  SCALAR: 1,
1842
1868
  VEC2: 2,
@@ -1847,12 +1873,12 @@ function xt(s, t, e, i, r) {
1847
1873
  throw new Error(`Attribute accessor type mismatch: expected ${i} components, got ${o}`);
1848
1874
  if (n.componentType !== r)
1849
1875
  throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
1850
- const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), u = n.count, p = new DataView(t, l, u * i * 4), h = new Float32Array(u * i);
1851
- for (let d = 0; d < u * i; d++)
1852
- h[d] = p.getFloat32(d * 4, !0);
1853
- return h;
1876
+ const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), d = n.count, S = new DataView(t, l, d * i * 4), b = new Float32Array(d * i);
1877
+ for (let p = 0; p < d * i; p++)
1878
+ b[p] = S.getFloat32(p * 4, !0);
1879
+ return b;
1854
1880
  }
1855
- function di(s, t, e) {
1881
+ function Di(s, t, e) {
1856
1882
  const i = s.accessors[e];
1857
1883
  if (i.type !== "SCALAR")
1858
1884
  throw new Error(`Indices accessor must be SCALAR, got ${i.type}`);
@@ -1870,19 +1896,19 @@ function di(s, t, e) {
1870
1896
  } else
1871
1897
  throw new Error(`Unsupported index component type: ${i.componentType}`);
1872
1898
  }
1873
- function Cs(s, t) {
1899
+ function ar(s, t) {
1874
1900
  const e = new Float32Array(s.length);
1875
1901
  for (let i = 0; i < t.length; i += 3) {
1876
- 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]], p = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], h = [
1877
- u[1] * p[2] - u[2] * p[1],
1878
- u[2] * p[0] - u[0] * p[2],
1879
- u[0] * p[1] - u[1] * p[0]
1880
- ], d = Math.sqrt(h[0] * h[0] + h[1] * h[1] + h[2] * h[2]);
1881
- d > 0 && (h[0] /= d, h[1] /= d, h[2] /= d), e[r] = e[n] = e[a] = h[0], e[r + 1] = e[n + 1] = e[a + 1] = h[1], e[r + 2] = e[n + 2] = e[a + 2] = h[2];
1902
+ const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], c = [s[n], s[n + 1], s[n + 2]], l = [s[a], s[a + 1], s[a + 2]], d = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], S = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], b = [
1903
+ d[1] * S[2] - d[2] * S[1],
1904
+ d[2] * S[0] - d[0] * S[2],
1905
+ d[0] * S[1] - d[1] * S[0]
1906
+ ], p = Math.sqrt(b[0] * b[0] + b[1] * b[1] + b[2] * b[2]);
1907
+ p > 0 && (b[0] /= p, b[1] /= p, b[2] /= p), e[r] = e[n] = e[a] = b[0], e[r + 1] = e[n + 1] = e[a + 1] = b[1], e[r + 2] = e[n + 2] = e[a + 2] = b[2];
1882
1908
  }
1883
1909
  return e;
1884
1910
  }
1885
- function Us(s, t, e) {
1911
+ function or(s, t, e) {
1886
1912
  const i = s.accessors[e];
1887
1913
  if (i.type !== "VEC4")
1888
1914
  throw new Error(`JOINTS_0 must be VEC4, got ${i.type}`);
@@ -1900,7 +1926,7 @@ function Us(s, t, e) {
1900
1926
  } else
1901
1927
  throw new Error(`Unsupported JOINTS_0 component type: ${i.componentType}`);
1902
1928
  }
1903
- function Is(s, t, e) {
1929
+ function lr(s, t, e) {
1904
1930
  const i = s.accessors[e];
1905
1931
  if (i.type !== "VEC4")
1906
1932
  throw new Error(`WEIGHTS_0 must be VEC4, got ${i.type}`);
@@ -1918,7 +1944,7 @@ function Is(s, t, e) {
1918
1944
  } else
1919
1945
  throw new Error(`Unsupported WEIGHTS_0 component type: ${i.componentType}`);
1920
1946
  }
1921
- function zs(s, t, e) {
1947
+ function cr(s, t, e) {
1922
1948
  const i = s.accessors[e];
1923
1949
  if (i.type !== "MAT4")
1924
1950
  throw new Error(`Expected MAT4, got ${i.type}`);
@@ -1929,7 +1955,7 @@ function zs(s, t, e) {
1929
1955
  c[l] = o.getFloat32(l * 4, !0);
1930
1956
  return c;
1931
1957
  }
1932
- function Gs(s, t, e) {
1958
+ function ur(s, t, e) {
1933
1959
  const i = s.accessors[e];
1934
1960
  if (i.type !== "SCALAR")
1935
1961
  throw new Error(`Expected SCALAR, got ${i.type}`);
@@ -1940,46 +1966,46 @@ function Gs(s, t, e) {
1940
1966
  c[l] = o.getFloat32(l * 4, !0);
1941
1967
  return c;
1942
1968
  }
1943
- function Fs(s, t, e) {
1969
+ function dr(s, t, e) {
1944
1970
  const i = s.accessors[e], n = { VEC3: 3, VEC4: 4 }[i.type];
1945
1971
  if (!n)
1946
1972
  throw new Error(`Expected VEC3 or VEC4, got ${i.type}`);
1947
1973
  if (i.componentType !== 5126)
1948
1974
  throw new Error(`Expected FLOAT component type, got ${i.componentType}`);
1949
- 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);
1950
- for (let p = 0; p < c * n; p++)
1951
- u[p] = l.getFloat32(p * 4, !0);
1952
- return u;
1975
+ const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), c = i.count, l = new DataView(t, o, c * n * 4), d = new Float32Array(c * n);
1976
+ for (let S = 0; S < c * n; S++)
1977
+ d[S] = l.getFloat32(S * 4, !0);
1978
+ return d;
1953
1979
  }
1954
- function Ds(s, t, e) {
1955
- 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;
1980
+ function fr(s, t, e) {
1981
+ const i = s.skins[0], r = i.joints, n = cr(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? or(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? lr(s, t, e.attributes.WEIGHTS_0) : null;
1956
1982
  if (!a || !o)
1957
1983
  throw new Error("Mesh missing JOINTS_0 or WEIGHTS_0 attributes");
1958
- const c = s.nodes.map((u) => ({
1959
- translation: u.translation || [0, 0, 0],
1960
- rotation: u.rotation || [0, 0, 0, 1],
1961
- scale: u.scale || [1, 1, 1],
1962
- children: u.children || [],
1963
- name: u.name || ""
1984
+ const c = s.nodes.map((d) => ({
1985
+ translation: d.translation || [0, 0, 0],
1986
+ rotation: d.rotation || [0, 0, 0, 1],
1987
+ scale: d.scale || [1, 1, 1],
1988
+ children: d.children || [],
1989
+ name: d.name || ""
1964
1990
  })), l = [];
1965
1991
  if (s.animations && s.animations.length > 0)
1966
- for (const u of s.animations) {
1967
- const p = [];
1968
- let h = 0;
1969
- for (const d of u.channels) {
1970
- const b = u.samplers[d.sampler], _ = Gs(s, t, b.input), M = Fs(s, t, b.output), R = _[_.length - 1];
1971
- R > h && (h = R), p.push({
1972
- targetNode: d.target.node,
1973
- targetPath: d.target.path,
1974
- interpolation: b.interpolation || "LINEAR",
1975
- timestamps: _,
1976
- values: M
1992
+ for (const d of s.animations) {
1993
+ const S = [];
1994
+ let b = 0;
1995
+ for (const p of d.channels) {
1996
+ const v = d.samplers[p.sampler], E = ur(s, t, v.input), I = dr(s, t, v.output), z = E[E.length - 1];
1997
+ z > b && (b = z), S.push({
1998
+ targetNode: p.target.node,
1999
+ targetPath: p.target.path,
2000
+ interpolation: v.interpolation || "LINEAR",
2001
+ timestamps: E,
2002
+ values: I
1977
2003
  });
1978
2004
  }
1979
2005
  l.push({
1980
- name: u.name || `Animation ${l.length}`,
1981
- duration: h,
1982
- channels: p
2006
+ name: d.name || `Animation ${l.length}`,
2007
+ duration: b,
2008
+ channels: S
1983
2009
  });
1984
2010
  }
1985
2011
  return {
@@ -1991,7 +2017,7 @@ function Ds(s, t, e) {
1991
2017
  animations: l
1992
2018
  };
1993
2019
  }
1994
- async function fi(s) {
2020
+ async function Vi(s) {
1995
2021
  const t = new DataView(s);
1996
2022
  if (t.getUint32(0, !0) !== 1179937895)
1997
2023
  throw new Error("Invalid GLB file: incorrect magic number");
@@ -2001,12 +2027,12 @@ async function fi(s) {
2001
2027
  const r = t.getUint32(8, !0);
2002
2028
  let n = 12, a = null, o = null;
2003
2029
  for (; n < r; ) {
2004
- const L = t.getUint32(n, !0), P = t.getUint32(n + 4, !0), T = s.slice(n + 8, n + 8 + L);
2005
- if (P === 1313821514) {
2006
- const D = new TextDecoder("utf-8").decode(T);
2007
- a = JSON.parse(D);
2008
- } else P === 5130562 && (o = T);
2009
- n += 8 + L;
2030
+ const W = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), F = s.slice(n + 8, n + 8 + W);
2031
+ if (T === 1313821514) {
2032
+ const H = new TextDecoder("utf-8").decode(F);
2033
+ a = JSON.parse(H);
2034
+ } else T === 5130562 && (o = F);
2035
+ n += 8 + W;
2010
2036
  }
2011
2037
  if (!a)
2012
2038
  throw new Error("GLB file missing JSON chunk");
@@ -2018,48 +2044,48 @@ async function fi(s) {
2018
2044
  const l = c.pbrMetallicRoughness.baseColorTexture.index;
2019
2045
  if (!a.textures || !a.textures[l])
2020
2046
  return null;
2021
- const p = a.textures[l].source;
2022
- if (p === void 0 || !a.images || !a.images[p])
2047
+ const S = a.textures[l].source;
2048
+ if (S === void 0 || !a.images || !a.images[S])
2023
2049
  return null;
2024
- const h = a.images[p], d = h.mimeType || "image/png";
2025
- if (h.bufferView === void 0)
2050
+ const b = a.images[S], p = b.mimeType || "image/png";
2051
+ if (b.bufferView === void 0)
2026
2052
  return null;
2027
2053
  if (!o)
2028
2054
  throw new Error("GLB file missing BIN chunk (required for embedded textures)");
2029
- const b = a.bufferViews[h.bufferView], _ = b.byteOffset || 0, M = b.byteLength, R = o.slice(_, _ + M);
2030
- return { imageBlob: new Blob([R], { type: d }), mimeType: d };
2055
+ const v = a.bufferViews[b.bufferView], E = v.byteOffset || 0, I = v.byteLength, z = o.slice(E, E + I);
2056
+ return { imageBlob: new Blob([z], { type: p }), mimeType: p };
2031
2057
  }
2032
- function Vs(s, t, e, i) {
2058
+ function pr(s, t, e, i) {
2033
2059
  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;
2034
2060
  }
2035
- function Os(s, t, e, i) {
2061
+ function hr(s, t, e, i) {
2036
2062
  i = i || [0, 0, 0, 0];
2037
2063
  let r = s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3], n = 1;
2038
2064
  if (r < 0 && (r = -r, n = -1), r > 0.9995) {
2039
2065
  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;
2040
- const u = Math.sqrt(i[0] * i[0] + i[1] * i[1] + i[2] * i[2] + i[3] * i[3]);
2041
- 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;
2066
+ const d = Math.sqrt(i[0] * i[0] + i[1] * i[1] + i[2] * i[2] + i[3] * i[3]);
2067
+ return d > 1e-4 ? (i[0] /= d, i[1] /= d, i[2] /= d, i[3] /= d) : (i[0] = 0, i[1] = 0, i[2] = 0, i[3] = 1), i;
2042
2068
  }
2043
2069
  const a = Math.acos(r), o = Math.sin(a), c = Math.sin((1 - e) * a) / o, l = Math.sin(e * a) / o;
2044
2070
  return i[0] = s[0] * c + n * t[0] * l, i[1] = s[1] * c + n * t[1] * l, i[2] = s[2] * c + n * t[2] * l, i[3] = s[3] * c + n * t[3] * l, i;
2045
2071
  }
2046
- function Ls(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, p = e * c, h = i * o, d = i * c, b = r * c, _ = n * a, M = n * o, R = n * c, x = t || new Float32Array(16);
2048
- return x[0] = 1 - (h + b), x[1] = u + R, x[2] = p - M, x[3] = 0, x[4] = u - R, x[5] = 1 - (l + b), x[6] = d + _, x[7] = 0, x[8] = p + M, x[9] = d - _, x[10] = 1 - (l + h), x[11] = 0, x[12] = 0, x[13] = 0, x[14] = 0, x[15] = 1, x;
2072
+ function mr(s, t) {
2073
+ const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, c = r + r, l = e * a, d = e * o, S = e * c, b = i * o, p = i * c, v = r * c, E = n * a, I = n * o, z = n * c, _ = t || new Float32Array(16);
2074
+ return _[0] = 1 - (b + v), _[1] = d + z, _[2] = S - I, _[3] = 0, _[4] = d - z, _[5] = 1 - (l + v), _[6] = p + E, _[7] = 0, _[8] = S + I, _[9] = p - E, _[10] = 1 - (l + b), _[11] = 0, _[12] = 0, _[13] = 0, _[14] = 0, _[15] = 1, _;
2049
2075
  }
2050
- const Xs = new Float32Array(16);
2051
- function Ns(s, t, e, i) {
2052
- const r = Ls(t, Xs), n = i || new Float32Array(16);
2076
+ const yr = new Float32Array(16);
2077
+ function gr(s, t, e, i) {
2078
+ const r = mr(t, yr), n = i || new Float32Array(16);
2053
2079
  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
2080
  }
2055
- function hi(s, t, e) {
2081
+ function Oi(s, t, e) {
2056
2082
  const i = e || new Float32Array(16);
2057
2083
  for (let r = 0; r < 4; r++)
2058
2084
  for (let n = 0; n < 4; n++)
2059
2085
  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
2086
  return i;
2061
2087
  }
2062
- class ks {
2088
+ class br {
2063
2089
  constructor(t) {
2064
2090
  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
2091
  for (let e = 0; e < this.nodes.length; e++)
@@ -2090,8 +2116,8 @@ class ks {
2090
2116
  this._gpuDevice = t, this._gpuOutputBuffer = e;
2091
2117
  const r = this.restPositions.length / 3, n = new Float32Array(r * 8);
2092
2118
  for (let c = 0; c < r; c++) {
2093
- const l = c * 8, u = c * 3, p = 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[p] : 0, n[l + 7] = i ? i[p + 1] : 0;
2119
+ const l = c * 8, d = c * 3, S = c * 2;
2120
+ n[l] = this.restPositions[d], n[l + 1] = this.restPositions[d + 1], n[l + 2] = this.restPositions[d + 2], n[l + 3] = this.restNormals[d], n[l + 4] = this.restNormals[d + 1], n[l + 5] = this.restNormals[d + 2], n[l + 6] = i ? i[S] : 0, n[l + 7] = i ? i[S + 1] : 0;
2095
2121
  }
2096
2122
  this._gpuRestDataBuffer = t.createBuffer({
2097
2123
  size: n.byteLength,
@@ -2126,7 +2152,7 @@ class ks {
2126
2152
  this._gpuSkinningPipeline = t.createComputePipeline({
2127
2153
  layout: t.createPipelineLayout({ bindGroupLayouts: [o] }),
2128
2154
  compute: {
2129
- module: t.createShaderModule({ code: Ps }),
2155
+ module: t.createShaderModule({ code: Js }),
2130
2156
  entryPoint: "main"
2131
2157
  }
2132
2158
  }), this._gpuSkinningBindGroup = t.createBindGroup({
@@ -2216,11 +2242,11 @@ class ks {
2216
2242
  return this._extractValue(n, r.length - 1, o, i);
2217
2243
  let c = 0, l = r.length - 1;
2218
2244
  for (; l - c > 1; ) {
2219
- const _ = Math.floor((c + l) / 2);
2220
- r[_] <= e ? c = _ : l = _;
2245
+ const E = Math.floor((c + l) / 2);
2246
+ r[E] <= e ? c = E : l = E;
2221
2247
  }
2222
- const u = r[c], p = r[l], h = (e - u) / (p - u), d = this._extractValue(n, c, o, this._sV0), b = this._extractValue(n, l, o, this._sV1);
2223
- 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, h, i) : Vs(d, b, h, i);
2248
+ const d = r[c], S = r[l], b = (e - d) / (S - d), p = this._extractValue(n, c, o, this._sV0), v = this._extractValue(n, l, o, this._sV1);
2249
+ return a === "STEP" ? (i[0] = p[0], i[1] = p[1], i[2] = p[2], o === "rotation" && (i[3] = p[3]), i) : o === "rotation" ? hr(p, v, b, i) : pr(p, v, b, i);
2224
2250
  }
2225
2251
  /**
2226
2252
  * Extract value from values array at the given index.
@@ -2245,7 +2271,7 @@ class ks {
2245
2271
  let n = r.translation, a = r.rotation, o = r.scale;
2246
2272
  for (const c of e.channels)
2247
2273
  c.targetNode === i && (c.targetPath === "translation" ? n = this._sampleChannel(c, t, this._scrT) : c.targetPath === "rotation" ? a = this._sampleChannel(c, t, this._scrR) : c.targetPath === "scale" && (o = this._sampleChannel(c, t, this._scrS)));
2248
- Ns(n, a, o, this.jointLocalTransforms[i]);
2274
+ gr(n, a, o, this.jointLocalTransforms[i]);
2249
2275
  }
2250
2276
  }
2251
2277
  /**
@@ -2255,7 +2281,7 @@ class ks {
2255
2281
  const t = this._parentMap;
2256
2282
  for (const e of this.topologicalOrder) {
2257
2283
  const i = t[e];
2258
- i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) : hi(
2284
+ i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) : Oi(
2259
2285
  this.jointGlobalTransforms[i],
2260
2286
  this.jointLocalTransforms[e],
2261
2287
  this.jointGlobalTransforms[e]
@@ -2268,7 +2294,7 @@ class ks {
2268
2294
  _computeFinalMatrices() {
2269
2295
  for (let t = 0; t < this.joints.length; t++) {
2270
2296
  const e = this.joints[t], i = this.jointGlobalTransforms[e];
2271
- hi(i, this._invBindViews[t], this.jointFinalMatrices[t]);
2297
+ Oi(i, this._invBindViews[t], this.jointFinalMatrices[t]);
2272
2298
  }
2273
2299
  }
2274
2300
  /**
@@ -2278,20 +2304,20 @@ class ks {
2278
2304
  _applySkinning() {
2279
2305
  const t = this.restPositions.length / 3, e = this.restPositions, i = this.restNormals, r = this.skinnedPositions, n = this.skinnedNormals, a = this.jointWeights, o = this.jointIndices, c = this.jointFinalMatrices;
2280
2306
  for (let l = 0; l < t; l++) {
2281
- const u = l * 3, p = l * 4, h = e[u], d = e[u + 1], b = e[u + 2], _ = i[u], M = i[u + 1], R = i[u + 2];
2282
- let x = 0, L = 0, P = 0, T = 0, E = 0, D = 0;
2283
- for (let Y = 0; Y < 4; Y++) {
2284
- const k = a[p + Y];
2285
- if (k === 0) continue;
2286
- const G = c[o[p + Y]];
2287
- x += (G[0] * h + G[4] * d + G[8] * b + G[12]) * k, L += (G[1] * h + G[5] * d + G[9] * b + G[13]) * k, P += (G[2] * h + G[6] * d + G[10] * b + G[14]) * k, T += (G[0] * _ + G[4] * M + G[8] * R) * k, E += (G[1] * _ + G[5] * M + G[9] * R) * k, D += (G[2] * _ + G[6] * M + G[10] * R) * k;
2307
+ const d = l * 3, S = l * 4, b = e[d], p = e[d + 1], v = e[d + 2], E = i[d], I = i[d + 1], z = i[d + 2];
2308
+ let _ = 0, W = 0, T = 0, F = 0, G = 0, H = 0;
2309
+ for (let ae = 0; ae < 4; ae++) {
2310
+ const ne = a[S + ae];
2311
+ if (ne === 0) continue;
2312
+ const q = c[o[S + ae]];
2313
+ _ += (q[0] * b + q[4] * p + q[8] * v + q[12]) * ne, W += (q[1] * b + q[5] * p + q[9] * v + q[13]) * ne, T += (q[2] * b + q[6] * p + q[10] * v + q[14]) * ne, F += (q[0] * E + q[4] * I + q[8] * z) * ne, G += (q[1] * E + q[5] * I + q[9] * z) * ne, H += (q[2] * E + q[6] * I + q[10] * z) * ne;
2288
2314
  }
2289
- const N = Math.sqrt(T * T + E * E + D * D);
2290
- N > 1e-4 && (n[u] = T / N, n[u + 1] = E / N, n[u + 2] = D / N), r[u] = x, r[u + 1] = L, r[u + 2] = P;
2315
+ const re = Math.sqrt(F * F + G * G + H * H);
2316
+ re > 1e-4 && (n[d] = F / re, n[d + 1] = G / re, n[d + 2] = H / re), r[d] = _, r[d + 1] = W, r[d + 2] = T;
2291
2317
  }
2292
2318
  }
2293
2319
  }
2294
- class js {
2320
+ class Sr {
2295
2321
  constructor({ duration: t = 0, loop: e = !1, playbackRate: i = 1 } = {}) {
2296
2322
  this.currentTime = 0, this.duration = t, this.loop = e, this.playbackRate = i, this.paused = !1, this._justLooped = !1;
2297
2323
  }
@@ -2312,7 +2338,7 @@ class js {
2312
2338
  this.currentTime = Math.max(0, t || 0), this._justLooped = !1;
2313
2339
  }
2314
2340
  }
2315
- const pi = {
2341
+ const Li = {
2316
2342
  linear: (s) => s,
2317
2343
  easeInQuad: (s) => s * s,
2318
2344
  easeOutQuad: (s) => 1 - (1 - s) * (1 - s),
@@ -2331,26 +2357,26 @@ const pi = {
2331
2357
  return Math.pow(2, -10 * s) * Math.sin((s * 10 - 0.75) * t) + 1;
2332
2358
  }
2333
2359
  };
2334
- function Ys(s, t, e, i) {
2335
- 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, p = (d) => ((l * d + c) * d + o) * d, h = (d) => (3 * a * d + 2 * n) * d + r;
2336
- return (d) => {
2337
- if (d <= 0) return 0;
2338
- if (d >= 1) return 1;
2339
- let b = d;
2340
- for (let _ = 0; _ < 8; _++) {
2341
- const M = u(b) - d;
2342
- if (Math.abs(M) < 1e-5) break;
2343
- const R = h(b);
2344
- if (Math.abs(R) < 1e-6) break;
2345
- b -= M / R;
2360
+ function xr(s, t, e, i) {
2361
+ const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, c = 3 * (i - t) - o, l = 1 - o - c, d = (p) => ((a * p + n) * p + r) * p, S = (p) => ((l * p + c) * p + o) * p, b = (p) => (3 * a * p + 2 * n) * p + r;
2362
+ return (p) => {
2363
+ if (p <= 0) return 0;
2364
+ if (p >= 1) return 1;
2365
+ let v = p;
2366
+ for (let E = 0; E < 8; E++) {
2367
+ const I = d(v) - p;
2368
+ if (Math.abs(I) < 1e-5) break;
2369
+ const z = b(v);
2370
+ if (Math.abs(z) < 1e-6) break;
2371
+ v -= I / z;
2346
2372
  }
2347
- return p(b);
2373
+ return S(v);
2348
2374
  };
2349
2375
  }
2350
- function _i(s, t) {
2351
- return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? Ys(s[0], s[1], s[2], s[3])(t) : (pi[s] || pi.linear)(t);
2376
+ function Wi(s, t) {
2377
+ return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? xr(s[0], s[1], s[2], s[3])(t) : (Li[s] || Li.linear)(t);
2352
2378
  }
2353
- function qs(s, t) {
2379
+ function vr(s, t) {
2354
2380
  if (!Array.isArray(s) || s.length === 0) return;
2355
2381
  if (s.length === 1 || t <= s[0].t) return s[0].v;
2356
2382
  const e = s[s.length - 1];
@@ -2359,12 +2385,12 @@ function qs(s, t) {
2359
2385
  const r = s[i], n = s[i + 1];
2360
2386
  if (t >= r.t && t <= n.t) {
2361
2387
  const a = n.t - r.t, o = a > 0 ? (t - r.t) / a : 0;
2362
- return r.v + (n.v - r.v) * _i(r.ease, o);
2388
+ return r.v + (n.v - r.v) * Wi(r.ease, o);
2363
2389
  }
2364
2390
  }
2365
2391
  return e.v;
2366
2392
  }
2367
- function Hs(s, t, e) {
2393
+ function Pr(s, t, e) {
2368
2394
  if (!Array.isArray(s) || s.length === 0) return;
2369
2395
  const i = s.length, r = s[i - 1];
2370
2396
  let n, a, o;
@@ -2374,26 +2400,61 @@ function Hs(s, t, e) {
2374
2400
  n = a = r.v, o = 0;
2375
2401
  else {
2376
2402
  n = a = r.v, o = 0;
2377
- for (let p = 0; p < i - 1; p++) {
2378
- const h = s[p], d = s[p + 1];
2379
- if (t >= h.t && t <= d.t) {
2380
- const b = d.t - h.t;
2381
- n = h.v, a = d.v, o = _i(h.ease, b > 0 ? (t - h.t) / b : 0);
2403
+ for (let S = 0; S < i - 1; S++) {
2404
+ const b = s[S], p = s[S + 1];
2405
+ if (t >= b.t && t <= p.t) {
2406
+ const v = p.t - b.t;
2407
+ n = b.v, a = p.v, o = Wi(b.ease, v > 0 ? (t - b.t) / v : 0);
2382
2408
  break;
2383
2409
  }
2384
2410
  }
2385
2411
  }
2386
- 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;
2387
- return e ? (e[0] = c, e[1] = l, e[2] = u, e) : [c, l, u];
2412
+ const c = n[0] + (a[0] - n[0]) * o, l = n[1] + (a[1] - n[1]) * o, d = n[2] + (a[2] - n[2]) * o;
2413
+ return e ? (e[0] = c, e[1] = l, e[2] = d, e) : [c, l, d];
2388
2414
  }
2389
- 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 };
2390
- function mi(s) {
2415
+ const _r = [
2416
+ "gravityStrength",
2417
+ "emissionRate",
2418
+ "damping",
2419
+ "dampingStrength",
2420
+ "particleSize",
2421
+ "particleSpeed",
2422
+ "opacity",
2423
+ "bloomIntensity",
2424
+ "emissionPositionX",
2425
+ "emissionPositionY",
2426
+ "emissionPositionZ",
2427
+ "emissionRotationX",
2428
+ "emissionRotationY",
2429
+ "emissionRotationZ",
2430
+ "circleInnerRadius",
2431
+ "circleOuterRadius",
2432
+ "discRadius",
2433
+ "annulusInnerRadius",
2434
+ "annulusOuterRadius",
2435
+ "arcStartAngle",
2436
+ "arcEndAngle",
2437
+ "arcInnerRadius",
2438
+ "arcOuterRadius",
2439
+ "squareSize",
2440
+ "rectangleWidth",
2441
+ "rectangleHeight",
2442
+ "planeWidth",
2443
+ "planeDepth",
2444
+ "lineLength",
2445
+ "polygonRadius",
2446
+ "shapeStrokeWidth",
2447
+ "shapeStrokeAmplitude",
2448
+ "shapeStrokeFrequency",
2449
+ "shapeStrokeSpeed"
2450
+ ], Mr = { square: 0, circle: 1, triangle: 2, diamond: 3, star: 4, hexagon: 5, ring: 6, heart: 7, cross: 8, spark: 9, leaf: 10, capsule: 11, crescent: 12, line: 13, "curved-line": 14 };
2451
+ function ki(s) {
2391
2452
  const t = atob(s), e = new Uint8Array(t.length);
2392
2453
  for (let i = 0; i < t.length; i++)
2393
2454
  e[i] = t.charCodeAt(i);
2394
2455
  return e.buffer;
2395
2456
  }
2396
- class vt {
2457
+ class ii {
2397
2458
  constructor(t, e) {
2398
2459
  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.emissionAccumulator = 0, this.destroyed = !1, this.particleData = new Float32Array(this.MAX_PARTICLES * 8), this.particleVelocities = new Float32Array(this.MAX_PARTICLES * 4), this.instanceBuffer = t.createBuffer({
2399
2460
  size: this.MAX_PARTICLES * 8 * 4,
@@ -2419,7 +2480,7 @@ class vt {
2419
2480
  // intensity (f32) + padding
2420
2481
  usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
2421
2482
  label: "systemBloomIntensityBuffer"
2422
- }), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.attractorReverse === void 0 && (e.attractorReverse = !1), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.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.attractorReverse), e.confinementEnabled && this.setConfinement({
2483
+ }), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.attractorReverse === void 0 && (e.attractorReverse = !1), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeStrokeEnabled === void 0 && (e.shapeStrokeEnabled = !1), e.shapeStrokeWidth === void 0 && (e.shapeStrokeWidth = 0.08), e.shapeStrokeSegments === void 0 && (e.shapeStrokeSegments = 96), e.shapeStrokeShape === void 0 && (e.shapeStrokeShape = "straight"), e.shapeStrokeAmplitude === void 0 && (e.shapeStrokeAmplitude = 0.08), e.shapeStrokeFrequency === void 0 && (e.shapeStrokeFrequency = 10), e.shapeStrokeSpeed === void 0 && (e.shapeStrokeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new Ys(e), this.physics = new Ks(t, this.MAX_PARTICLES), this.textureManager = new Qs(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition, e.attractorReverse), e.confinementEnabled && this.setConfinement({
2423
2484
  enabled: !0,
2424
2485
  shape: e.confinementShape,
2425
2486
  mode: e.confinementMode,
@@ -2432,7 +2493,7 @@ class vt {
2432
2493
  enabled: !0,
2433
2494
  strength: e.softBoundaryStrength,
2434
2495
  falloff: e.softBoundaryFalloff
2435
- }), 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);
2496
+ }), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new Gi(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
2436
2497
  }
2437
2498
  async initComputePipeline(t) {
2438
2499
  this.computeReady = await this.physics.initComputePipeline(this.instanceBuffer, this.velocityBuffer, this.trailBuffer);
@@ -2442,7 +2503,7 @@ class vt {
2442
2503
  * @param {string|null} source - Script source code, or null to disable
2443
2504
  */
2444
2505
  setScript(t) {
2445
- 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;
2506
+ this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new Gi(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
2446
2507
  }
2447
2508
  async setTexture(t) {
2448
2509
  this.destroyed || (this.textureManager.destroyTexture(this.particleTexture), this.particleTexture = await this.textureManager.loadTexture(t), this.config.textureEnabled = !0, this.updateAppearanceUniform(), this.updateBuffers());
@@ -2453,7 +2514,7 @@ class vt {
2453
2514
  async setGLBModel(t) {
2454
2515
  try {
2455
2516
  this.glbRawArrayBuffer = t;
2456
- const e = await As(t);
2517
+ const e = await nr(t);
2457
2518
  this.glbMeshData = e, this.config.glbHasTexture = e.hasBaseColorTexture || !1;
2458
2519
  const i = new Float32Array(e.vertexCount * 8);
2459
2520
  for (let r = 0; r < e.vertexCount; r++) {
@@ -2469,7 +2530,7 @@ class vt {
2469
2530
  usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
2470
2531
  label: "glbIndexBuffer"
2471
2532
  }), 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) {
2472
- this.glbAnimator = new ks(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);
2533
+ this.glbAnimator = new br(e.animationData), this.glbAnimator.setRestPose(e.positions, e.normals), this.glbAnimated = !0, this.config.glbAnimated = !0, this.glbAnimator.loop = this.config.animationLoop, this._glbInterleavedData = new Float32Array(e.vertexCount * 8);
2473
2534
  try {
2474
2535
  await this.glbAnimator.initGPUSkinning(this.device, this.glbVertexBuffer, e.texCoords);
2475
2536
  } catch (r) {
@@ -2531,7 +2592,7 @@ class vt {
2531
2592
  if (this.destroyed) return;
2532
2593
  let t = 0;
2533
2594
  this.config.rotationMode === "random" ? t = 1 : this.config.rotationMode === "velocity" ? t = 2 : this.config.rotationMode === "oriented" ? t = 3 : this.config.rotationMode === "cylindrical" && (t = 4);
2534
- const e = $s[this.config.particleShape] ?? 0, i = this._appearanceData;
2595
+ const e = Mr[this.config.particleShape] ?? 0, i = this._appearanceData;
2535
2596
  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;
2536
2597
  const r = this.config.followSystemTranslation ?? !0;
2537
2598
  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);
@@ -2542,40 +2603,40 @@ class vt {
2542
2603
  const e = this.config.bloomColor || [1, 1, 1];
2543
2604
  t[4] = e[0], t[5] = e[1], t[6] = e[2], this.device.queue.writeBuffer(this.bloomIntensityBuffer, 0, t);
2544
2605
  }
2545
- spawnParticles() {
2546
- if (this.activeParticles = 0, this.currentEmissionTime = 0, this.emissionAccumulator = 0, this._newEmissions.length = 0, this._pendingFollowEmissions = this._emptyEmissions, this._scriptFrame = 0, this._scriptTime = 0, this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptConfigRestored = !1, this._particleScript && (this._particleScript._configSnapshot ? (this._particleScript.restoreConfig(this.config), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse), this.updateAppearanceUniform(), this.updateBloomIntensity()) : this._particleScript.snapshotConfig(this.config)), this.device.queue.writeBuffer(this.trailBuffer, 0, this._trailResetData, 0, this.MAX_PARTICLES * 4), this.glbAnimator && (this.glbAnimator.currentTime = 0, this.glbAnimator.playing = !0), this.config.followSystemId) {
2606
+ spawnParticles(t) {
2607
+ if (this.activeParticles = 0, this.currentEmissionTime = 0, this.emissionAccumulator = 0, this._newEmissions.length = 0, this._pendingFollowEmissions = this._emptyEmissions, this._scriptFrame = 0, this._scriptTime = 0, this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptConfigRestored = !1, this._particleScript && (this._particleScript._configSnapshot ? (this._particleScript.restoreConfig(this.config), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse), this.updateAppearanceUniform(), this.updateBloomIntensity()) : this._particleScript.snapshotConfig(this.config)), typeof t == "function" && t(this), this.device.queue.writeBuffer(this.trailBuffer, 0, this._trailResetData, 0, this.MAX_PARTICLES * 4), this.glbAnimator && (this.glbAnimator.currentTime = 0, this.glbAnimator.playing = !0), this.config.followSystemId) {
2547
2608
  this.emitting = !0, this.particleCount = this.MAX_PARTICLES;
2548
2609
  return;
2549
2610
  }
2550
2611
  if (this.config.burstMode) {
2551
- const t = this.config.particleCount;
2552
- this.particleCount = t;
2553
- let e = 0;
2554
- const i = 500;
2555
- for (let r = 0; r < t; r++)
2556
- if (this.emitParticle(), e++, e >= i || r === t - 1) {
2557
- const n = r - e + 1, a = n * 8, o = n * 4;
2612
+ const e = this.config.particleCount;
2613
+ this.particleCount = e;
2614
+ let i = 0;
2615
+ const r = 500;
2616
+ for (let n = 0; n < e; n++)
2617
+ if (this.emitParticle(), i++, i >= r || n === e - 1) {
2618
+ const a = n - i + 1, o = a * 8, c = a * 4;
2558
2619
  this.device.queue.writeBuffer(
2559
2620
  this.instanceBuffer,
2560
- a * 4,
2621
+ o * 4,
2561
2622
  // Offset in bytes
2562
2623
  this.particleData,
2563
- a,
2564
- e * 8
2624
+ o,
2625
+ i * 8
2565
2626
  ), this.device.queue.writeBuffer(
2566
2627
  this.velocityBuffer,
2567
- o * 4,
2628
+ c * 4,
2568
2629
  // Offset in bytes
2569
2630
  this.particleVelocities,
2570
- o,
2571
- e * 4
2572
- ), e = 0;
2631
+ c,
2632
+ i * 4
2633
+ ), i = 0;
2573
2634
  }
2574
2635
  this.emitting = !1;
2575
2636
  } else {
2576
2637
  this.emitting = !0;
2577
- const t = this.config.lifetime || 5, e = this.config.emissionDurationInfinite ? t : Math.min(this.config.emissionDuration || 10, t);
2578
- this.particleCount = Math.min(Math.ceil((this.config.emissionRate || 10) * e), this.MAX_PARTICLES);
2638
+ const e = this.config.lifetime || 5, i = this.config.emissionDurationInfinite ? e : Math.min(this.config.emissionDuration || 10, e);
2639
+ this.particleCount = Math.min(Math.ceil((this.config.emissionRate || 10) * i), this.MAX_PARTICLES);
2579
2640
  }
2580
2641
  }
2581
2642
  // Effective emission window: Infinity when "Infinite Duration" is on (emits forever).
@@ -2593,8 +2654,8 @@ class vt {
2593
2654
  this._emitSimRotY = this._simRotY || 0;
2594
2655
  const e = t * 8, i = t * 4;
2595
2656
  if (this._simRotMatrix) {
2596
- const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2], c = this.particleVelocities[i], l = this.particleVelocities[i + 1], u = this.particleVelocities[i + 2];
2597
- this.particleData[e] = r[0] * n + r[1] * a + r[2] * o, this.particleData[e + 1] = r[3] * n + r[4] * a + r[5] * o, this.particleData[e + 2] = r[6] * n + r[7] * a + r[8] * o, this.particleVelocities[i] = r[0] * c + r[1] * l + r[2] * u, this.particleVelocities[i + 1] = r[3] * c + r[4] * l + r[5] * u, this.particleVelocities[i + 2] = r[6] * c + r[7] * l + r[8] * u;
2657
+ const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2], c = this.particleVelocities[i], l = this.particleVelocities[i + 1], d = this.particleVelocities[i + 2];
2658
+ this.particleData[e] = r[0] * n + r[1] * a + r[2] * o, this.particleData[e + 1] = r[3] * n + r[4] * a + r[5] * o, this.particleData[e + 2] = r[6] * n + r[7] * a + r[8] * o, this.particleVelocities[i] = r[0] * c + r[1] * l + r[2] * d, this.particleVelocities[i + 1] = r[3] * c + r[4] * l + r[5] * d, this.particleVelocities[i + 2] = r[6] * c + r[7] * l + r[8] * d;
2598
2659
  }
2599
2660
  (this.config.followSystemTranslation ?? !0) || (this.particleData[e] += this._simPosition[0], this.particleData[e + 1] += this._simPosition[1], this.particleData[e + 2] += this._simPosition[2]);
2600
2661
  }
@@ -2626,20 +2687,20 @@ class vt {
2626
2687
  const r = this.config.startAt || 0, n = r > 0 && i < r;
2627
2688
  if (this._particleScript && this._scriptReadbackReady) {
2628
2689
  this._scriptReadbackReady = !1, this._scriptTime += t, this._scriptFrame++;
2629
- const u = this.config.emissionDurationInfinite ? 1 / 0 : (this.config.emissionDuration || 0) + (this.config.lifetime || 0);
2630
- if (u > 0 && this._scriptTime >= u && !this._scriptConfigRestored)
2690
+ const d = this.config.emissionDurationInfinite ? 1 / 0 : (this.config.emissionDuration || 0) + (this.config.lifetime || 0);
2691
+ if (d > 0 && this._scriptTime >= d && !this._scriptConfigRestored)
2631
2692
  this._scriptConfigRestored = !0, this._particleScript._configSnapshot && (this._particleScript.restoreConfig(this.config), this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse));
2632
2693
  else if (!this._scriptConfigRestored) {
2633
- const p = u > 0 ? Math.ceil(u / 0.016666666666666666) : 0, { configDirty: h, particlesDirty: d } = this._particleScript.execute(
2694
+ const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty: b, particlesDirty: p } = this._particleScript.execute(
2634
2695
  t,
2635
2696
  this._scriptTime,
2636
2697
  this._scriptFrame,
2637
- p,
2698
+ S,
2638
2699
  this._scriptParticleData,
2639
2700
  this._scriptVelocityData,
2640
2701
  this.activeParticles
2641
2702
  );
2642
- d && this.activeParticles > 0 && (this.device.queue.writeBuffer(
2703
+ p && this.activeParticles > 0 && (this.device.queue.writeBuffer(
2643
2704
  this.instanceBuffer,
2644
2705
  0,
2645
2706
  this._scriptParticleData,
@@ -2651,58 +2712,58 @@ class vt {
2651
2712
  this._scriptVelocityData,
2652
2713
  0,
2653
2714
  this.activeParticles * 4
2654
- )), h && (this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse));
2715
+ )), b && (this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse));
2655
2716
  }
2656
2717
  }
2657
2718
  this.physics.physicsAccumulator += t;
2658
2719
  const a = performance.now() / 1e3, c = a - this.physics.lastUpdateTime > 1 / this.physics.minUpdatesPerSecond, l = this.activeParticles;
2659
2720
  if (!n && !this.emitting && !this.config.burstMode && !this.config.followSystemId && this.currentEmissionTime < this.effectiveEmissionDuration && (this.emitting = !0), !n && this.emitting)
2660
2721
  if (this.currentEmissionTime += t, this.currentEmissionTime < this.effectiveEmissionDuration) {
2661
- const u = this.activeParticles;
2662
- let p = !1;
2722
+ const d = this.activeParticles;
2723
+ let S = !1;
2663
2724
  if (this.config.followSystemId) {
2664
2725
  if (this._pendingFollowEmissions.length > 0) {
2665
- const h = this._pendingFollowEmissions.length / 6;
2666
- for (let d = 0; d < h; d++) {
2667
- const b = d * 6;
2726
+ const b = this._pendingFollowEmissions.length / 6;
2727
+ for (let p = 0; p < b; p++) {
2728
+ const v = p * 6;
2668
2729
  if (this.emitFollowerParticle(
2669
- this._pendingFollowEmissions[b],
2670
- this._pendingFollowEmissions[b + 1],
2671
- this._pendingFollowEmissions[b + 2]
2730
+ this._pendingFollowEmissions[v],
2731
+ this._pendingFollowEmissions[v + 1],
2732
+ this._pendingFollowEmissions[v + 2]
2672
2733
  ))
2673
- p = !0;
2734
+ S = !0;
2674
2735
  else
2675
2736
  break;
2676
2737
  }
2677
2738
  }
2678
2739
  } else {
2679
- let h = 0;
2680
- const d = Math.max(0, this.config.emissionRate || 0);
2681
- this.activeParticles < this.particleCount && d > 0 ? (this.emissionAccumulator += d * t, h = Math.floor(this.emissionAccumulator + 1e-9), h > 0 && (this.emissionAccumulator -= h)) : this.activeParticles >= this.particleCount && (this.emissionAccumulator = 0);
2682
- for (let b = 0; b < h; b++)
2740
+ let b = 0;
2741
+ const p = Math.max(0, this.config.emissionRate || 0);
2742
+ this.activeParticles < this.particleCount && p > 0 ? (this.emissionAccumulator += p * t, b = Math.floor(this.emissionAccumulator + 1e-9), b > 0 && (this.emissionAccumulator -= b)) : this.activeParticles >= this.particleCount && (this.emissionAccumulator = 0);
2743
+ for (let v = 0; v < b; v++)
2683
2744
  if (this.emitParticle())
2684
- p = !0;
2745
+ S = !0;
2685
2746
  else {
2686
2747
  this.emissionAccumulator = 0;
2687
2748
  break;
2688
2749
  }
2689
2750
  }
2690
- if (p) {
2691
- const h = this.activeParticles - u, d = u * 8, b = u * 4;
2751
+ if (S) {
2752
+ const b = this.activeParticles - d, p = d * 8, v = d * 4;
2692
2753
  this.device.queue.writeBuffer(
2693
2754
  this.instanceBuffer,
2694
- d * 4,
2755
+ p * 4,
2695
2756
  // Offset in bytes (float32 = 4 bytes)
2696
2757
  this.particleData,
2697
- d,
2698
- h * 8
2758
+ p,
2759
+ b * 8
2699
2760
  ), this.device.queue.writeBuffer(
2700
2761
  this.velocityBuffer,
2701
- b * 4,
2762
+ v * 4,
2702
2763
  // Offset in bytes (float32 = 4 bytes)
2703
2764
  this.particleVelocities,
2704
- b,
2705
- h * 4
2765
+ v,
2766
+ b * 4
2706
2767
  );
2707
2768
  }
2708
2769
  } else
@@ -2729,8 +2790,8 @@ class vt {
2729
2790
  this._scriptVelocityData,
2730
2791
  this.instanceBuffer,
2731
2792
  this.velocityBuffer
2732
- ).then((u) => {
2733
- this._scriptReadbackPending = !1, u.shouldUpdate && (this._scriptReadbackReady = !0);
2793
+ ).then((d) => {
2794
+ this._scriptReadbackPending = !1, d.shouldUpdate && (this._scriptReadbackReady = !0);
2734
2795
  }).catch(() => {
2735
2796
  this._scriptReadbackPending = !1;
2736
2797
  }));
@@ -2758,8 +2819,8 @@ class vt {
2758
2819
  if (e !== r) {
2759
2820
  const o = r * 8, c = e * 8;
2760
2821
  this.particleData.copyWithin(c, o, o + 8);
2761
- const l = r * 4, u = e * 4;
2762
- this.particleVelocities.copyWithin(u, l, l + 4), i = !0;
2822
+ const l = r * 4, d = e * 4;
2823
+ this.particleVelocities.copyWithin(d, l, l + 4), i = !0;
2763
2824
  }
2764
2825
  e++;
2765
2826
  }
@@ -2788,17 +2849,17 @@ class vt {
2788
2849
  }
2789
2850
  updateParticleVelocities() {
2790
2851
  for (let t = 0; t < this.activeParticles; t++) {
2791
- const e = t * 8, i = t * 4, r = this.particleData[e], n = this.particleData[e + 1], a = this.particleData[e + 2], o = this.particleVelocities[i], c = this.particleVelocities[i + 1], l = this.particleVelocities[i + 2], u = Math.sqrt(
2852
+ const e = t * 8, i = t * 4, r = this.particleData[e], n = this.particleData[e + 1], a = this.particleData[e + 2], o = this.particleVelocities[i], c = this.particleVelocities[i + 1], l = this.particleVelocities[i + 2], d = Math.sqrt(
2792
2853
  o * o + c * c + l * l
2793
2854
  );
2794
- if (u > 1e-3) {
2795
- const p = this.config.particleSpeed * 2;
2796
- this.particleVelocities[i] = o / u * p, this.particleVelocities[i + 1] = c / u * p, this.particleVelocities[i + 2] = l / u * p;
2855
+ if (d > 1e-3) {
2856
+ const S = this.config.particleSpeed * 2;
2857
+ this.particleVelocities[i] = o / d * S, this.particleVelocities[i + 1] = c / d * S, this.particleVelocities[i + 2] = l / d * S;
2797
2858
  } else {
2798
- const p = Math.sqrt(r * r + n * n + a * a);
2799
- if (p > 1e-3) {
2800
- const h = this.config.particleSpeed * 2;
2801
- this.particleVelocities[i] = r / p * h, this.particleVelocities[i + 1] = n / p * h, this.particleVelocities[i + 2] = a / p * h;
2859
+ const S = Math.sqrt(r * r + n * n + a * a);
2860
+ if (S > 1e-3) {
2861
+ const b = this.config.particleSpeed * 2;
2862
+ this.particleVelocities[i] = r / S * b, this.particleVelocities[i + 1] = n / S * b, this.particleVelocities[i + 2] = a / S * b;
2802
2863
  } else
2803
2864
  this.particleVelocities[i] = 0, this.particleVelocities[i + 1] = this.config.particleSpeed * 2, this.particleVelocities[i + 2] = 0;
2804
2865
  }
@@ -2843,16 +2904,16 @@ class vt {
2843
2904
  this.physics.setSoftBoundary(t);
2844
2905
  }
2845
2906
  }
2846
- class Ws {
2907
+ class wr {
2847
2908
  constructor(t) {
2848
- 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;
2909
+ this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new Sr({ loop: !!this.loop }), this.ready = !0;
2849
2910
  }
2850
2911
  createParticleSystem(t = {}) {
2851
2912
  const e = this.systemCounter++, i = t.name || `System ${e + 1}`, r = {
2852
2913
  ...t,
2853
2914
  name: i,
2854
2915
  id: e
2855
- }, n = new vt(this.device, r);
2916
+ }, n = new ii(this.device, r);
2856
2917
  return this.particleSystems.push({
2857
2918
  system: n,
2858
2919
  config: r
@@ -2891,9 +2952,9 @@ class Ws {
2891
2952
  }
2892
2953
  respawnAllSystems() {
2893
2954
  var t;
2894
- for (const { system: e } of this.particleSystems)
2895
- e.spawnParticles();
2896
2955
  (t = this.clock) == null || t.reset();
2956
+ for (const { system: e, config: i } of this.particleSystems)
2957
+ e.spawnParticles(() => this._applyKeyframesToSystem(e, i, 0));
2897
2958
  }
2898
2959
  // Total effect duration in seconds for the timeline/loop (Infinity if any system emits
2899
2960
  // forever). Burst/one-only systems last only their lifetime (they emit at t=0). This is the
@@ -2913,22 +2974,8 @@ class Ws {
2913
2974
  const r = this.clock ? this.clock.currentTime : 0, n = this.clock ? this.clock.duration : 0;
2914
2975
  if (this.clock && n > 0 && isFinite(n)) {
2915
2976
  const a = Math.min(1, this.clock.currentTime / n);
2916
- for (const { system: o, config: c } of this.particleSystems) {
2917
- const l = c.keyframes;
2918
- if (!(!l || c.keyframesEnabled === !1)) {
2919
- for (const u of Zs) {
2920
- const p = l[u];
2921
- if (p && p.length) {
2922
- const h = qs(p, a);
2923
- h !== void 0 && (c[u] = h);
2924
- }
2925
- }
2926
- if (l.particleColor && l.particleColor.length) {
2927
- const u = c.particleColor, p = u && typeof u.length == "number" && u.length >= 3 ? u : void 0, h = Hs(l.particleColor, a, p);
2928
- h && (c.particleColor = h, o.updateAppearanceUniform());
2929
- }
2930
- }
2931
- }
2977
+ for (const { system: o, config: c } of this.particleSystems)
2978
+ this._applyKeyframesToSystem(o, c, a);
2932
2979
  }
2933
2980
  for (const { system: a, config: o } of this.particleSystems) {
2934
2981
  if (o.hidden || o.followSystemId) continue;
@@ -2976,7 +3023,7 @@ class Ws {
2976
3023
  const n = this.systemCounter++, a = {
2977
3024
  ...r,
2978
3025
  id: n
2979
- }, o = new vt(this.device, a);
3026
+ }, o = new ii(this.device, a);
2980
3027
  this.particleSystems.push({
2981
3028
  system: o,
2982
3029
  config: a
@@ -2994,7 +3041,7 @@ class Ws {
2994
3041
  try {
2995
3042
  let a = null;
2996
3043
  if (n.glbModelData)
2997
- a = mi(n.glbModelData);
3044
+ a = ki(n.glbModelData);
2998
3045
  else if (n.glbFileName) {
2999
3046
  const o = await fetch(`/${n.glbFileName}`);
3000
3047
  o.ok ? a = await o.arrayBuffer() : console.warn(`GLB file not found: ${n.glbFileName}`);
@@ -3002,7 +3049,7 @@ class Ws {
3002
3049
  if (a) {
3003
3050
  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))
3004
3051
  try {
3005
- const o = await fi(a);
3052
+ const o = await Vi(a);
3006
3053
  if (o) {
3007
3054
  const c = await createImageBitmap(o.imageBlob);
3008
3055
  await r.setTexture(c), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${n.name}`);
@@ -3070,9 +3117,9 @@ class Ws {
3070
3117
  (o.confinementCenter[1] || 0) + e[1],
3071
3118
  (o.confinementCenter[2] || 0) + e[2]
3072
3119
  ]);
3073
- const u = new vt(this.device, l);
3120
+ const d = new ii(this.device, l);
3074
3121
  this.particleSystems.push({
3075
- system: u,
3122
+ system: d,
3076
3123
  config: l
3077
3124
  }), this.onSystemCreated && typeof this.onSystemCreated == "function" && this.onSystemCreated(c, l);
3078
3125
  }
@@ -3089,21 +3136,21 @@ class Ws {
3089
3136
  try {
3090
3137
  let l = null;
3091
3138
  if (c.glbModelData)
3092
- l = mi(c.glbModelData);
3139
+ l = ki(c.glbModelData);
3093
3140
  else if (c.glbFileName) {
3094
- const u = await fetch(`/${c.glbFileName}`);
3095
- u.ok ? l = await u.arrayBuffer() : console.warn(`GLB file not found: ${c.glbFileName}`);
3141
+ const d = await fetch(`/${c.glbFileName}`);
3142
+ d.ok ? l = await d.arrayBuffer() : console.warn(`GLB file not found: ${c.glbFileName}`);
3096
3143
  }
3097
3144
  if (l) {
3098
3145
  if (await o.setGLBModel(l), c.animationIndex !== void 0 && o.glbAnimator && o.glbAnimator.setAnimation(c.animationIndex), c.animationSpeed !== void 0 && o.glbAnimator && (o.glbAnimator.speed = c.animationSpeed), c.animationLoop !== void 0 && o.glbAnimator && (o.glbAnimator.loop = c.animationLoop), c.useGlbTexture && (c.textureEnabled = !0), c.useGlbTexture && ((r = o.glbMeshData) != null && r.hasBaseColorTexture))
3099
3146
  try {
3100
- const u = await fi(l);
3101
- if (u) {
3102
- const p = await createImageBitmap(u.imageBlob);
3103
- await o.setTexture(p), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${c.name}`);
3147
+ const d = await Vi(l);
3148
+ if (d) {
3149
+ const S = await createImageBitmap(d.imageBlob);
3150
+ await o.setTexture(S), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${c.name}`);
3104
3151
  }
3105
- } catch (u) {
3106
- console.warn(`Failed to restore GLB texture for ${c.name}:`, u), c.useGlbTexture = !1;
3152
+ } catch (d) {
3153
+ console.warn(`Failed to restore GLB texture for ${c.name}:`, d), c.useGlbTexture = !1;
3107
3154
  }
3108
3155
  } else
3109
3156
  c.glbModelEnabled = !1;
@@ -3114,11 +3161,11 @@ class Ws {
3114
3161
  if (c.textureEnabled && !c.glbModelEnabled && c.textureImageData && !o._textureRestored)
3115
3162
  try {
3116
3163
  const l = new Image();
3117
- await new Promise((p, h) => {
3118
- l.onload = p, l.onerror = h, l.src = c.textureImageData;
3164
+ await new Promise((S, b) => {
3165
+ l.onload = S, l.onerror = b, l.src = c.textureImageData;
3119
3166
  });
3120
- const u = await createImageBitmap(l);
3121
- await o.setTexture(u), o._textureRestored = !0;
3167
+ const d = await createImageBitmap(l);
3168
+ await o.setTexture(d), o._textureRestored = !0;
3122
3169
  } catch (l) {
3123
3170
  console.warn(`Failed to restore texture for ${c.name}:`, l), c.textureEnabled = !1;
3124
3171
  }
@@ -3129,8 +3176,30 @@ class Ws {
3129
3176
  this.ready = !0;
3130
3177
  }
3131
3178
  }
3179
+ _applyKeyframesToSystem(t, e, i) {
3180
+ const r = e.keyframes;
3181
+ if (!r || e.keyframesEnabled === !1) return;
3182
+ let n = !1, a = !1, o = !1, c = !1, l = !1;
3183
+ for (const d of _r) {
3184
+ const S = r[d];
3185
+ if (!S || !S.length) continue;
3186
+ const b = vr(S, i);
3187
+ if (b !== void 0) {
3188
+ if (d === "damping") {
3189
+ e.dampingStrength = b, c = !0;
3190
+ continue;
3191
+ }
3192
+ e[d] = b, (d === "particleSize" || d === "opacity") && (n = !0), d === "bloomIntensity" && (a = !0), d === "gravityStrength" && (o = !0), d === "dampingStrength" && (c = !0), (d === "attractorStrength" || d === "attractorReverse") && (l = !0);
3193
+ }
3194
+ }
3195
+ if (r.particleColor && r.particleColor.length) {
3196
+ const d = e.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0, b = Pr(r.particleColor, i, S);
3197
+ b && (e.particleColor = b, n = !0);
3198
+ }
3199
+ n && t.updateAppearanceUniform(), a && t.updateBloomIntensity(), o && e.gravityEnabled && t.setGravity(e.gravityStrength), c && e.dampingEnabled && t.physics.setDamping(e.dampingStrength), l && e.attractorEnabled && e.attractorPosition && t.setAttractor(e.attractorStrength, e.attractorPosition, e.attractorReverse);
3200
+ }
3132
3201
  }
3133
- async function Js(s) {
3202
+ async function Br(s) {
3134
3203
  if (!s)
3135
3204
  throw new Error("canvas is required for initWebGPU()");
3136
3205
  if (!navigator.gpu)
@@ -3142,37 +3211,37 @@ async function Js(s) {
3142
3211
  alphaMode: "premultiplied"
3143
3212
  }), { device: i, context: t, format: r, canvas: s };
3144
3213
  }
3145
- const oe = "rgba16float";
3146
- function yi(s, t, e, i) {
3214
+ const ke = "rgba16float";
3215
+ function Xi(s, t, e, i) {
3147
3216
  const r = s.createTexture({
3148
3217
  size: [e, i],
3149
- format: oe,
3218
+ format: ke,
3150
3219
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
3151
3220
  mipLevelCount: 1,
3152
3221
  sampleCount: 1
3153
3222
  }), n = s.createTexture({
3154
3223
  size: [e, i],
3155
- format: oe,
3224
+ format: ke,
3156
3225
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
3157
3226
  mipLevelCount: 1,
3158
3227
  sampleCount: 1
3159
3228
  }), a = s.createTexture({
3160
3229
  size: [e, i],
3161
- format: oe,
3230
+ format: ke,
3162
3231
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
3163
3232
  mipLevelCount: 1,
3164
3233
  sampleCount: 1
3165
3234
  });
3166
3235
  return { sceneTexture: r, bloomTexA: n, bloomTexB: a };
3167
3236
  }
3168
- function gi(s, t, e) {
3237
+ function Ni(s, t, e) {
3169
3238
  return s.createTexture({
3170
3239
  size: [t, e],
3171
3240
  format: "depth24plus",
3172
3241
  usage: GPUTextureUsage.RENDER_ATTACHMENT
3173
3242
  });
3174
3243
  }
3175
- function Ge(s, t, e) {
3244
+ function St(s, t, e) {
3176
3245
  const i = s.createBuffer({
3177
3246
  size: t.byteLength,
3178
3247
  usage: e,
@@ -3180,7 +3249,7 @@ function Ge(s, t, e) {
3180
3249
  });
3181
3250
  return new t.constructor(i.getMappedRange()).set(t), i.unmap(), i;
3182
3251
  }
3183
- const Qs = `
3252
+ const Rr = `
3184
3253
  struct Uniforms {
3185
3254
  transform: mat4x4<f32>,
3186
3255
  cameraPosition: vec3<f32>,
@@ -3242,7 +3311,7 @@ const Qs = `
3242
3311
 
3243
3312
  return finalColor;
3244
3313
  }
3245
- `, Ks = `
3314
+ `, Tr = `
3246
3315
  struct Uniforms {
3247
3316
  transform: mat4x4<f32>,
3248
3317
  cameraPosition: vec3<f32>,
@@ -3479,7 +3548,7 @@ const Qs = `
3479
3548
  return finalColor;
3480
3549
  }
3481
3550
  `;
3482
- function er(s) {
3551
+ function Ar(s) {
3483
3552
  const t = s.createBindGroupLayout({
3484
3553
  entries: [
3485
3554
  {
@@ -3565,34 +3634,34 @@ function er(s) {
3565
3634
  object3dBindGroupLayout: r
3566
3635
  };
3567
3636
  }
3568
- function tr(s, t, e, i = {}) {
3637
+ function Er(s, t, e, i = {}) {
3569
3638
  const { depthCompare: r } = i, n = r || "less", {
3570
3639
  particleBindGroupLayout: a,
3571
3640
  bloomBindGroupLayout: o,
3572
3641
  compositeBindGroupLayout: c,
3573
3642
  object3dBindGroupLayout: l
3574
- } = e, u = s.createPipelineLayout({
3643
+ } = e, d = s.createPipelineLayout({
3575
3644
  bindGroupLayouts: [a]
3576
- }), p = s.createPipelineLayout({
3645
+ }), S = s.createPipelineLayout({
3577
3646
  bindGroupLayouts: [o]
3578
- }), h = s.createPipelineLayout({
3647
+ }), b = s.createPipelineLayout({
3579
3648
  bindGroupLayouts: [c]
3580
- }), d = s.createShaderModule({
3581
- code: ys
3582
- }), b = s.createShaderModule({
3583
- code: gs
3649
+ }), p = s.createShaderModule({
3650
+ code: js
3651
+ }), v = s.createShaderModule({
3652
+ code: qs
3653
+ }), E = s.createShaderModule({
3654
+ code: Zs
3655
+ }), I = s.createShaderModule({
3656
+ code: Hs
3657
+ }), z = s.createShaderModule({
3658
+ code: Rr
3584
3659
  }), _ = s.createShaderModule({
3585
- code: bs
3586
- }), M = s.createShaderModule({
3587
- code: Ss
3588
- }), R = s.createShaderModule({
3589
- code: Qs
3590
- }), x = s.createShaderModule({
3591
- code: Ks
3592
- }), L = (W) => s.createRenderPipeline({
3593
- layout: u,
3660
+ code: Tr
3661
+ }), W = (kt) => s.createRenderPipeline({
3662
+ layout: d,
3594
3663
  vertex: {
3595
- module: d,
3664
+ module: p,
3596
3665
  entryPoint: "vs_main",
3597
3666
  buffers: [
3598
3667
  {
@@ -3653,11 +3722,11 @@ function tr(s, t, e, i = {}) {
3653
3722
  ]
3654
3723
  },
3655
3724
  fragment: {
3656
- module: d,
3725
+ module: p,
3657
3726
  entryPoint: "fs_main",
3658
3727
  targets: [{
3659
- format: oe,
3660
- blend: W
3728
+ format: ke,
3729
+ blend: kt
3661
3730
  }]
3662
3731
  },
3663
3732
  primitive: {
@@ -3669,7 +3738,7 @@ function tr(s, t, e, i = {}) {
3669
3738
  depthCompare: n,
3670
3739
  format: "depth24plus"
3671
3740
  }
3672
- }), P = L({
3741
+ }), T = W({
3673
3742
  color: {
3674
3743
  srcFactor: "src-alpha",
3675
3744
  dstFactor: "one-minus-src-alpha",
@@ -3680,7 +3749,7 @@ function tr(s, t, e, i = {}) {
3680
3749
  dstFactor: "one-minus-src-alpha",
3681
3750
  operation: "add"
3682
3751
  }
3683
- }), T = L({
3752
+ }), F = W({
3684
3753
  color: {
3685
3754
  srcFactor: "src-alpha",
3686
3755
  dstFactor: "one",
@@ -3691,10 +3760,10 @@ function tr(s, t, e, i = {}) {
3691
3760
  dstFactor: "one-minus-src-alpha",
3692
3761
  operation: "add"
3693
3762
  }
3694
- }), E = s.createRenderPipeline({
3695
- layout: u,
3763
+ }), G = s.createRenderPipeline({
3764
+ layout: d,
3696
3765
  vertex: {
3697
- module: d,
3766
+ module: p,
3698
3767
  entryPoint: "vs_main",
3699
3768
  buffers: [
3700
3769
  {
@@ -3755,10 +3824,10 @@ function tr(s, t, e, i = {}) {
3755
3824
  ]
3756
3825
  },
3757
3826
  fragment: {
3758
- module: d,
3827
+ module: p,
3759
3828
  entryPoint: "fs_main",
3760
3829
  targets: [{
3761
- format: oe,
3830
+ format: ke,
3762
3831
  writeMask: 0
3763
3832
  // No color write — depth only
3764
3833
  }]
@@ -3773,33 +3842,33 @@ function tr(s, t, e, i = {}) {
3773
3842
  // Always write depth (don't self-occlude)
3774
3843
  format: "depth24plus"
3775
3844
  }
3776
- }), D = s.createRenderPipeline({
3777
- layout: p,
3845
+ }), H = s.createRenderPipeline({
3846
+ layout: S,
3778
3847
  vertex: {
3779
- module: b,
3848
+ module: v,
3780
3849
  entryPoint: "vs_main"
3781
3850
  },
3782
3851
  fragment: {
3783
- module: b,
3852
+ module: v,
3784
3853
  entryPoint: "fs_main",
3785
3854
  targets: [{
3786
- format: oe
3855
+ format: ke
3787
3856
  }]
3788
3857
  },
3789
3858
  primitive: {
3790
3859
  topology: "triangle-list"
3791
3860
  }
3792
- }), N = s.createRenderPipeline({
3793
- layout: h,
3861
+ }), re = s.createRenderPipeline({
3862
+ layout: b,
3794
3863
  vertex: {
3795
- module: _,
3864
+ module: E,
3796
3865
  entryPoint: "vs_main"
3797
3866
  },
3798
3867
  fragment: {
3799
- module: _,
3868
+ module: E,
3800
3869
  entryPoint: "fs_main",
3801
3870
  targets: [{
3802
- format: oe,
3871
+ format: ke,
3803
3872
  blend: {
3804
3873
  color: {
3805
3874
  srcFactor: "one",
@@ -3817,17 +3886,17 @@ function tr(s, t, e, i = {}) {
3817
3886
  primitive: {
3818
3887
  topology: "triangle-list"
3819
3888
  }
3820
- }), Y = s.createRenderPipeline({
3821
- layout: h,
3889
+ }), ae = s.createRenderPipeline({
3890
+ layout: b,
3822
3891
  vertex: {
3823
- module: M,
3892
+ module: I,
3824
3893
  entryPoint: "vs_main"
3825
3894
  },
3826
3895
  fragment: {
3827
- module: M,
3896
+ module: I,
3828
3897
  entryPoint: "fs_main",
3829
3898
  targets: [{
3830
- format: oe,
3899
+ format: ke,
3831
3900
  blend: {
3832
3901
  color: {
3833
3902
  srcFactor: "one",
@@ -3845,11 +3914,11 @@ function tr(s, t, e, i = {}) {
3845
3914
  primitive: {
3846
3915
  topology: "triangle-list"
3847
3916
  }
3848
- }), k = s.createShaderModule({ code: xs }), G = s.createRenderPipeline({
3849
- layout: h,
3850
- vertex: { module: k, entryPoint: "vs_main" },
3917
+ }), ne = s.createShaderModule({ code: Ws }), q = s.createRenderPipeline({
3918
+ layout: b,
3919
+ vertex: { module: ne, entryPoint: "vs_main" },
3851
3920
  fragment: {
3852
- module: k,
3921
+ module: ne,
3853
3922
  entryPoint: "fs_main",
3854
3923
  targets: [{
3855
3924
  format: t,
@@ -3860,12 +3929,12 @@ function tr(s, t, e, i = {}) {
3860
3929
  }]
3861
3930
  },
3862
3931
  primitive: { topology: "triangle-list" }
3863
- }), de = s.createPipelineLayout({
3932
+ }), tt = s.createPipelineLayout({
3864
3933
  bindGroupLayouts: [l]
3865
- }), Fe = s.createRenderPipeline({
3866
- layout: de,
3934
+ }), xt = s.createRenderPipeline({
3935
+ layout: tt,
3867
3936
  vertex: {
3868
- module: R,
3937
+ module: z,
3869
3938
  entryPoint: "vs_main",
3870
3939
  buffers: [
3871
3940
  {
@@ -3890,10 +3959,10 @@ function tr(s, t, e, i = {}) {
3890
3959
  ]
3891
3960
  },
3892
3961
  fragment: {
3893
- module: R,
3962
+ module: z,
3894
3963
  entryPoint: "fs_main",
3895
3964
  targets: [{
3896
- format: oe,
3965
+ format: ke,
3897
3966
  blend: {
3898
3967
  color: {
3899
3968
  srcFactor: "src-alpha",
@@ -3917,10 +3986,10 @@ function tr(s, t, e, i = {}) {
3917
3986
  depthCompare: n,
3918
3987
  format: "depth24plus"
3919
3988
  }
3920
- }), ct = s.createRenderPipeline({
3921
- layout: u,
3989
+ }), Xe = s.createRenderPipeline({
3990
+ layout: d,
3922
3991
  vertex: {
3923
- module: x,
3992
+ module: _,
3924
3993
  entryPoint: "vs_main",
3925
3994
  buffers: [
3926
3995
  {
@@ -3992,10 +4061,10 @@ function tr(s, t, e, i = {}) {
3992
4061
  ]
3993
4062
  },
3994
4063
  fragment: {
3995
- module: x,
4064
+ module: _,
3996
4065
  entryPoint: "fs_main",
3997
4066
  targets: [{
3998
- format: oe,
4067
+ format: ke,
3999
4068
  blend: {
4000
4069
  color: {
4001
4070
  srcFactor: "src-alpha",
@@ -4021,18 +4090,18 @@ function tr(s, t, e, i = {}) {
4021
4090
  }
4022
4091
  });
4023
4092
  return {
4024
- particlePipeline: P,
4025
- particleAdditivePipeline: T,
4026
- particleDepthWritePipeline: E,
4027
- blurPipeline: D,
4028
- compositePipeline: N,
4029
- directRenderPipeline: Y,
4030
- finalCompositePipeline: G,
4031
- object3dPipeline: Fe,
4032
- glbMeshPipeline: ct
4093
+ particlePipeline: T,
4094
+ particleAdditivePipeline: F,
4095
+ particleDepthWritePipeline: G,
4096
+ blurPipeline: H,
4097
+ compositePipeline: re,
4098
+ directRenderPipeline: ae,
4099
+ finalCompositePipeline: q,
4100
+ object3dPipeline: xt,
4101
+ glbMeshPipeline: Xe
4033
4102
  };
4034
4103
  }
4035
- function Pt(s, t, e, i) {
4104
+ function si(s, t, e, i) {
4036
4105
  const {
4037
4106
  uniformBuffer: r,
4038
4107
  appearanceUniformBuffer: n,
@@ -4041,9 +4110,9 @@ function Pt(s, t, e, i) {
4041
4110
  bloomIntensityBuffer: c
4042
4111
  } = e, {
4043
4112
  sceneTexture: l,
4044
- bloomTexA: u,
4045
- bloomTexB: p
4046
- } = i, h = s.createBindGroup({
4113
+ bloomTexA: d,
4114
+ bloomTexB: S
4115
+ } = i, b = s.createBindGroup({
4047
4116
  layout: s.createBindGroupLayout({
4048
4117
  entries: [
4049
4118
  {
@@ -4068,7 +4137,7 @@ function Pt(s, t, e, i) {
4068
4137
  resource: { buffer: n }
4069
4138
  }
4070
4139
  ]
4071
- }), d = s.createBindGroup({
4140
+ }), p = s.createBindGroup({
4072
4141
  layout: s.createBindGroupLayout({
4073
4142
  entries: [
4074
4143
  {
@@ -4102,7 +4171,7 @@ function Pt(s, t, e, i) {
4102
4171
  resource: { buffer: a }
4103
4172
  }
4104
4173
  ]
4105
- }), b = s.createBindGroup({
4174
+ }), v = s.createBindGroup({
4106
4175
  layout: s.createBindGroupLayout({
4107
4176
  entries: [
4108
4177
  {
@@ -4129,14 +4198,14 @@ function Pt(s, t, e, i) {
4129
4198
  },
4130
4199
  {
4131
4200
  binding: 1,
4132
- resource: u.createView()
4201
+ resource: d.createView()
4133
4202
  },
4134
4203
  {
4135
4204
  binding: 2,
4136
4205
  resource: { buffer: o }
4137
4206
  }
4138
4207
  ]
4139
- }), _ = s.createBindGroup({
4208
+ }), E = s.createBindGroup({
4140
4209
  layout: s.createBindGroupLayout({
4141
4210
  entries: [
4142
4211
  {
@@ -4172,14 +4241,14 @@ function Pt(s, t, e, i) {
4172
4241
  },
4173
4242
  {
4174
4243
  binding: 2,
4175
- resource: p.createView()
4244
+ resource: S.createView()
4176
4245
  },
4177
4246
  {
4178
4247
  binding: 3,
4179
4248
  resource: { buffer: c }
4180
4249
  }
4181
4250
  ]
4182
- }), M = s.createBindGroup({
4251
+ }), I = s.createBindGroup({
4183
4252
  layout: s.createBindGroupLayout({
4184
4253
  entries: [
4185
4254
  {
@@ -4215,7 +4284,7 @@ function Pt(s, t, e, i) {
4215
4284
  },
4216
4285
  {
4217
4286
  binding: 2,
4218
- resource: p.createView()
4287
+ resource: S.createView()
4219
4288
  },
4220
4289
  {
4221
4290
  binding: 3,
@@ -4224,14 +4293,14 @@ function Pt(s, t, e, i) {
4224
4293
  ]
4225
4294
  });
4226
4295
  return {
4227
- particleBindGroup: h,
4228
- horizontalBlurBindGroup: d,
4229
- verticalBlurBindGroup: b,
4230
- compositeBindGroup: _,
4231
- directRenderBindGroup: M
4296
+ particleBindGroup: b,
4297
+ horizontalBlurBindGroup: p,
4298
+ verticalBlurBindGroup: v,
4299
+ compositeBindGroup: E,
4300
+ directRenderBindGroup: I
4232
4301
  };
4233
4302
  }
4234
- function ir(s) {
4303
+ function Cr(s) {
4235
4304
  return s.createSampler({
4236
4305
  magFilter: "linear",
4237
4306
  minFilter: "linear",
@@ -4241,7 +4310,7 @@ function ir(s) {
4241
4310
  maxAnisotropy: 16
4242
4311
  });
4243
4312
  }
4244
- function sr() {
4313
+ function Ur() {
4245
4314
  const s = new Float32Array([
4246
4315
  // Front face (z = 0.5)
4247
4316
  -0.5,
@@ -4439,13 +4508,13 @@ function sr() {
4439
4508
  ]);
4440
4509
  return { vertices: s, indices: t };
4441
4510
  }
4442
- function rr(s = 16, t = 16) {
4511
+ function Ir(s = 16, t = 16) {
4443
4512
  const e = [], i = [];
4444
4513
  for (let r = 0; r <= s; r++) {
4445
4514
  const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
4446
4515
  for (let c = 0; c <= t; c++) {
4447
- const l = c * 2 * Math.PI / t, u = Math.sin(l), h = Math.cos(l) * a, d = o, b = u * a;
4448
- e.push(h * 0.5, d * 0.5, b * 0.5), e.push(h, d, b);
4516
+ const l = c * 2 * Math.PI / t, d = Math.sin(l), b = Math.cos(l) * a, p = o, v = d * a;
4517
+ e.push(b * 0.5, p * 0.5, v * 0.5), e.push(b, p, v);
4449
4518
  }
4450
4519
  }
4451
4520
  for (let r = 0; r < s; r++)
@@ -4458,7 +4527,7 @@ function rr(s = 16, t = 16) {
4458
4527
  indices: new Uint16Array(i)
4459
4528
  };
4460
4529
  }
4461
- class nr {
4530
+ class zr {
4462
4531
  constructor(t, e, i, r, n) {
4463
4532
  this.id = t, this.type = e, this.position = i, this.scale = r, this.color = n, this.rotation = [0, 0, 0];
4464
4533
  }
@@ -4592,7 +4661,7 @@ class nr {
4592
4661
  return i;
4593
4662
  }
4594
4663
  }
4595
- class hr {
4664
+ class kr {
4596
4665
  constructor(t) {
4597
4666
  this.device = t, this.objects = [], this.nextId = 0, this.initializeGeometry(), this.onObjectAdded = null, this.onObjectRemoved = null, this.onObjectUpdated = null;
4598
4667
  }
@@ -4600,20 +4669,20 @@ class hr {
4600
4669
  * Initialize geometry buffers for cube and sphere
4601
4670
  */
4602
4671
  initializeGeometry() {
4603
- const t = sr(), e = rr(16, 16);
4604
- this.cubeVertexBuffer = Ge(
4672
+ const t = Ur(), e = Ir(16, 16);
4673
+ this.cubeVertexBuffer = St(
4605
4674
  this.device,
4606
4675
  t.vertices,
4607
4676
  GPUBufferUsage.VERTEX
4608
- ), this.cubeIndexBuffer = Ge(
4677
+ ), this.cubeIndexBuffer = St(
4609
4678
  this.device,
4610
4679
  t.indices,
4611
4680
  GPUBufferUsage.INDEX
4612
- ), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer = Ge(
4681
+ ), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer = St(
4613
4682
  this.device,
4614
4683
  e.vertices,
4615
4684
  GPUBufferUsage.VERTEX
4616
- ), this.sphereIndexBuffer = Ge(
4685
+ ), this.sphereIndexBuffer = St(
4617
4686
  this.device,
4618
4687
  e.indices,
4619
4688
  GPUBufferUsage.INDEX
@@ -4628,7 +4697,7 @@ class hr {
4628
4697
  * @returns {Object3D} The created object
4629
4698
  */
4630
4699
  addObject(t, e = [0, 0, 0], i = [1, 1, 1], r = [1, 1, 1, 1]) {
4631
- const n = new nr(this.nextId++, t, e, i, r);
4700
+ const n = new zr(this.nextId++, t, e, i, r);
4632
4701
  return n.uniformBuffer = this.device.createBuffer({
4633
4702
  size: 192,
4634
4703
  // modelMatrix (64) + normalMatrix (64) + color (16) + padding (48)
@@ -4717,21 +4786,21 @@ class hr {
4717
4786
  }
4718
4787
  }
4719
4788
  }
4720
- function pr(s) {
4789
+ function Xr(s) {
4721
4790
  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;
4722
4791
  return [t, e, i];
4723
4792
  }
4724
- function mr(s) {
4793
+ function Nr(s) {
4725
4794
  if (!s) return "#ffffff";
4726
4795
  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");
4727
4796
  return `#${t}${e}${i}`;
4728
4797
  }
4729
- function yr(s, t, e) {
4730
- const i = bi([
4798
+ function Yr(s, t, e) {
4799
+ const i = Yi([
4731
4800
  s[0] - t[0],
4732
4801
  s[1] - t[1],
4733
4802
  s[2] - t[2]
4734
- ]), r = bi(Si(e, i)), n = Si(i, r);
4803
+ ]), r = Yi(ji(e, i)), n = ji(i, r);
4735
4804
  return new Float32Array([
4736
4805
  r[0],
4737
4806
  n[0],
@@ -4745,13 +4814,13 @@ function yr(s, t, e) {
4745
4814
  n[2],
4746
4815
  i[2],
4747
4816
  0,
4748
- -_t(r, s),
4749
- -_t(n, s),
4750
- -_t(i, s),
4817
+ -ri(r, s),
4818
+ -ri(n, s),
4819
+ -ri(i, s),
4751
4820
  1
4752
4821
  ]);
4753
4822
  }
4754
- function gr(s, t = Math.PI / 4) {
4823
+ function jr(s, t = Math.PI / 4) {
4755
4824
  const r = 1 / Math.tan(t / 2);
4756
4825
  return new Float32Array([
4757
4826
  r * s,
@@ -4772,21 +4841,21 @@ function gr(s, t = Math.PI / 4) {
4772
4841
  0
4773
4842
  ]);
4774
4843
  }
4775
- function bi(s) {
4844
+ function Yi(s) {
4776
4845
  const t = Math.sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2]);
4777
4846
  return [s[0] / t, s[1] / t, s[2] / t];
4778
4847
  }
4779
- function Si(s, t) {
4848
+ function ji(s, t) {
4780
4849
  return [
4781
4850
  s[1] * t[2] - s[2] * t[1],
4782
4851
  s[2] * t[0] - s[0] * t[2],
4783
4852
  s[0] * t[1] - s[1] * t[0]
4784
4853
  ];
4785
4854
  }
4786
- function _t(s, t) {
4855
+ function ri(s, t) {
4787
4856
  return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
4788
4857
  }
4789
- function ar(s, t) {
4858
+ function Fr(s, t) {
4790
4859
  const e = new Float32Array(16);
4791
4860
  for (let i = 0; i < 4; i++)
4792
4861
  for (let r = 0; r < 4; r++) {
@@ -4797,7 +4866,7 @@ function ar(s, t) {
4797
4866
  }
4798
4867
  return e;
4799
4868
  }
4800
- 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) => {
4869
+ const ai = 1481005640, $i = 1, Ji = 1313821514, Ki = 5130562, Et = "$hzfxAsset", Qi = (s) => typeof atob == "function" ? Uint8Array.from(atob(s), (t) => t.charCodeAt(0)) : new Uint8Array(Buffer.from(s, "base64")), qi = (s) => {
4801
4870
  if (typeof btoa == "function") {
4802
4871
  let t = "";
4803
4872
  for (let e = 0; e < s.length; e++) t += String.fromCharCode(s[e]);
@@ -4805,94 +4874,94 @@ const Bt = 1481005640, wi = 1, Bi = 1313821514, Mi = 5130562, Ze = "$hzfxAsset",
4805
4874
  }
4806
4875
  return Buffer.from(s).toString("base64");
4807
4876
  };
4808
- function or(s) {
4809
- 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));
4877
+ function Gr(s) {
4878
+ const t = s.indexOf(","), e = s.slice(5, t), i = e.split(";")[0] || "application/octet-stream", r = s.slice(t + 1), a = /;base64/i.test(e) ? Qi(r) : new TextEncoder().encode(decodeURIComponent(r));
4810
4879
  return { mime: i, bytes: a };
4811
4880
  }
4812
- function vi(s) {
4881
+ function Zi(s) {
4813
4882
  return (4 - s % 4) % 4;
4814
4883
  }
4815
- async function lr(s, t = {}) {
4884
+ async function Dr(s, t = {}) {
4816
4885
  const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
4817
4886
  let a = 0;
4818
- const o = (T, E, D) => {
4819
- const N = a, Y = T.length;
4820
- r.push({ offset: N, length: Y, mime: E, kind: D }), n.push(T), a += Y;
4821
- const k = vi(Y);
4822
- return k && (n.push(new Uint8Array(k)), a += k), r.length - 1;
4887
+ const o = (F, G, H) => {
4888
+ const re = a, ae = F.length;
4889
+ r.push({ offset: re, length: ae, mime: G, kind: H }), n.push(F), a += ae;
4890
+ const ne = Zi(ae);
4891
+ return ne && (n.push(new Uint8Array(ne)), a += ne), r.length - 1;
4823
4892
  }, c = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", l = [];
4824
- for (const T of s.systems || []) {
4825
- const E = { ...T };
4826
- if (typeof E.textureImageData == "string" && E.textureImageData.startsWith("data:")) {
4827
- let { mime: D, bytes: N } = or(E.textureImageData);
4828
- if (c && D !== "image/webp")
4893
+ for (const F of s.systems || []) {
4894
+ const G = { ...F };
4895
+ if (typeof G.textureImageData == "string" && G.textureImageData.startsWith("data:")) {
4896
+ let { mime: H, bytes: re } = Gr(G.textureImageData);
4897
+ if (c && H !== "image/webp")
4829
4898
  try {
4830
- const Y = await createImageBitmap(new Blob([N], { type: D })), k = new OffscreenCanvas(Y.width, Y.height);
4831
- k.getContext("2d").drawImage(Y, 0, 0);
4832
- const G = await k.convertToBlob({ type: "image/webp", quality: i }), de = new Uint8Array(await G.arrayBuffer());
4833
- de.length < N.length && (N = de, D = "image/webp");
4899
+ const ae = await createImageBitmap(new Blob([re], { type: H })), ne = new OffscreenCanvas(ae.width, ae.height);
4900
+ ne.getContext("2d").drawImage(ae, 0, 0);
4901
+ const q = await ne.convertToBlob({ type: "image/webp", quality: i }), tt = new Uint8Array(await q.arrayBuffer());
4902
+ tt.length < re.length && (re = tt, H = "image/webp");
4834
4903
  } catch {
4835
4904
  }
4836
- E.textureImageData = { [Ze]: o(N, D, "texture") };
4905
+ G.textureImageData = { [Et]: o(re, H, "texture") };
4837
4906
  }
4838
- if (typeof E.glbModelData == "string" && E.glbModelData.length > 0) {
4839
- const D = Ri(E.glbModelData);
4840
- E.glbModelData = { [Ze]: o(D, "model/gltf-binary", "glb") };
4907
+ if (typeof G.glbModelData == "string" && G.glbModelData.length > 0) {
4908
+ const H = Qi(G.glbModelData);
4909
+ G.glbModelData = { [Et]: o(H, "model/gltf-binary", "glb") };
4841
4910
  }
4842
- l.push(E);
4843
- }
4844
- const u = { ...s, systems: l, assets: r }, p = new TextEncoder().encode(JSON.stringify(u)), h = vi(p.length), d = new Uint8Array(a);
4845
- let b = 0;
4846
- for (const T of n)
4847
- d.set(T, b), b += T.length;
4848
- const _ = p.length + h, M = 20 + _ + 8 + a, R = new ArrayBuffer(M), x = new DataView(R), L = new Uint8Array(R);
4849
- let P = 0;
4850
- x.setUint32(P, Bt, !0), P += 4, x.setUint32(P, wi, !0), P += 4, x.setUint32(P, M, !0), P += 4, x.setUint32(P, _, !0), P += 4, x.setUint32(P, Bi, !0), P += 4, L.set(p, P), P += p.length;
4851
- for (let T = 0; T < h; T++) L[P++] = 32;
4852
- return x.setUint32(P, a, !0), P += 4, x.setUint32(P, Mi, !0), P += 4, L.set(d, P), P += a, R;
4911
+ l.push(G);
4912
+ }
4913
+ const d = { ...s, systems: l, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), b = Zi(S.length), p = new Uint8Array(a);
4914
+ let v = 0;
4915
+ for (const F of n)
4916
+ p.set(F, v), v += F.length;
4917
+ const E = S.length + b, I = 20 + E + 8 + a, z = new ArrayBuffer(I), _ = new DataView(z), W = new Uint8Array(z);
4918
+ let T = 0;
4919
+ _.setUint32(T, ai, !0), T += 4, _.setUint32(T, $i, !0), T += 4, _.setUint32(T, I, !0), T += 4, _.setUint32(T, E, !0), T += 4, _.setUint32(T, Ji, !0), T += 4, W.set(S, T), T += S.length;
4920
+ for (let F = 0; F < b; F++) W[T++] = 32;
4921
+ return _.setUint32(T, a, !0), T += 4, _.setUint32(T, Ki, !0), T += 4, W.set(p, T), T += a, z;
4853
4922
  }
4854
- function Ti(s) {
4855
- return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === Bt;
4923
+ function es(s) {
4924
+ return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === ai;
4856
4925
  }
4857
- function Ei(s) {
4926
+ function ts(s) {
4858
4927
  const t = new DataView(s);
4859
- if (t.getUint32(0, !0) !== Bt) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
4928
+ if (t.getUint32(0, !0) !== ai) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
4860
4929
  const e = t.getUint32(4, !0);
4861
- if (e !== wi) throw new Error(`[unpackHZFX] unsupported version ${e}`);
4930
+ if (e !== $i) throw new Error(`[unpackHZFX] unsupported version ${e}`);
4862
4931
  let i = 12, r = null, n = -1;
4863
4932
  const a = new Uint8Array(s);
4864
4933
  for (; i + 8 <= s.byteLength; ) {
4865
- const h = t.getUint32(i, !0);
4934
+ const b = t.getUint32(i, !0);
4866
4935
  i += 4;
4867
- const d = t.getUint32(i, !0);
4868
- i += 4, d === Bi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + h))) : d === Mi && (n = i), i += h;
4936
+ const p = t.getUint32(i, !0);
4937
+ i += 4, p === Ji ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + b))) : p === Ki && (n = i), i += b;
4869
4938
  }
4870
4939
  if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
4871
- const o = r.assets || [], c = (h) => {
4872
- const d = o[h];
4873
- return !d || n < 0 ? null : { ...d, bytes: a.subarray(n + d.offset, n + d.offset + d.length) };
4874
- }, l = (h) => h && typeof h == "object" && typeof h[Ze] == "number", u = (r.systems || []).map((h) => {
4875
- const d = { ...h };
4876
- if (l(d.textureImageData)) {
4877
- const b = c(d.textureImageData[Ze]);
4878
- d.textureImageData = b ? `data:${b.mime};base64,${xi(b.bytes)}` : void 0;
4940
+ const o = r.assets || [], c = (b) => {
4941
+ const p = o[b];
4942
+ return !p || n < 0 ? null : { ...p, bytes: a.subarray(n + p.offset, n + p.offset + p.length) };
4943
+ }, l = (b) => b && typeof b == "object" && typeof b[Et] == "number", d = (r.systems || []).map((b) => {
4944
+ const p = { ...b };
4945
+ if (l(p.textureImageData)) {
4946
+ const v = c(p.textureImageData[Et]);
4947
+ p.textureImageData = v ? `data:${v.mime};base64,${qi(v.bytes)}` : void 0;
4879
4948
  }
4880
- if (l(d.glbModelData)) {
4881
- const b = c(d.glbModelData[Ze]);
4882
- d.glbModelData = b ? xi(b.bytes) : void 0;
4949
+ if (l(p.glbModelData)) {
4950
+ const v = c(p.glbModelData[Et]);
4951
+ p.glbModelData = v ? qi(v.bytes) : void 0;
4883
4952
  }
4884
- return d;
4885
- }), p = { ...r, systems: u };
4886
- return delete p.assets, p;
4953
+ return p;
4954
+ }), S = { ...r, systems: d };
4955
+ return delete S.assets, S;
4887
4956
  }
4888
- function cr(s) {
4957
+ function Vr(s) {
4889
4958
  const t = new Uint8Array(s);
4890
4959
  let e = "";
4891
4960
  for (let i = 0; i < t.byteLength; i++)
4892
4961
  e += String.fromCharCode(t[i]);
4893
4962
  return btoa(e);
4894
4963
  }
4895
- function ur(s) {
4964
+ function Or(s) {
4896
4965
  return {
4897
4966
  name: s.name,
4898
4967
  id: s.id,
@@ -5043,6 +5112,13 @@ function ur(s) {
5043
5112
  emissionTrailShapeAmplitude: s.emissionTrailShapeAmplitude ?? 0.1,
5044
5113
  emissionTrailShapeFrequency: s.emissionTrailShapeFrequency ?? 4,
5045
5114
  emissionTrailShapeSpeed: s.emissionTrailShapeSpeed ?? 0,
5115
+ shapeStrokeEnabled: s.shapeStrokeEnabled || !1,
5116
+ shapeStrokeWidth: s.shapeStrokeWidth ?? 0.08,
5117
+ shapeStrokeSegments: s.shapeStrokeSegments ?? 96,
5118
+ shapeStrokeShape: s.shapeStrokeShape ?? "straight",
5119
+ shapeStrokeAmplitude: s.shapeStrokeAmplitude ?? 0.08,
5120
+ shapeStrokeFrequency: s.shapeStrokeFrequency ?? 10,
5121
+ shapeStrokeSpeed: s.shapeStrokeSpeed ?? 0,
5046
5122
  shapeDisplay: s.shapeDisplay ?? !0,
5047
5123
  blendMode: s.blendMode ?? "normal",
5048
5124
  noiseDistortEnabled: s.noiseDistortEnabled || !1,
@@ -5071,7 +5147,7 @@ function ur(s) {
5071
5147
  displayUnit: s.displayUnit || "m"
5072
5148
  };
5073
5149
  }
5074
- async function br(s, t, e = "hzfx") {
5150
+ async function qr(s, t, e = "hzfx") {
5075
5151
  if (!s || !s.particleSystems || s.particleSystems.length === 0) {
5076
5152
  alert("No particle systems to save.");
5077
5153
  return;
@@ -5080,12 +5156,12 @@ async function br(s, t, e = "hzfx") {
5080
5156
  const i = {
5081
5157
  version: "1.0",
5082
5158
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
5083
- systems: s.particleSystems.map(({ config: u, system: p }) => ({
5084
- ...ur(u),
5159
+ systems: s.particleSystems.map(({ config: d, system: S }) => ({
5160
+ ...Or(d),
5085
5161
  // single source of truth for config fields
5086
5162
  // Binary assets embedded so replaceSystems() can restore them
5087
- textureImageData: u.textureEnabled && !u.glbModelEnabled && u.textureImageData ? u.textureImageData : void 0,
5088
- glbModelData: u.glbModelEnabled && p.glbRawArrayBuffer ? cr(p.glbRawArrayBuffer) : void 0
5163
+ textureImageData: d.textureEnabled && !d.glbModelEnabled && d.textureImageData ? d.textureImageData : void 0,
5164
+ glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ? Vr(S.glbRawArrayBuffer) : void 0
5089
5165
  })),
5090
5166
  activeSystemIndex: s.activeSystemIndex,
5091
5167
  loop: s.loop || !1
@@ -5093,16 +5169,16 @@ async function br(s, t, e = "hzfx") {
5093
5169
  }, r = e === "json" ? "json" : "hzfx";
5094
5170
  let n;
5095
5171
  if (r === "hzfx") {
5096
- const u = await lr(i, { textureFormat: "webp" });
5097
- n = new Blob([u], { type: "application/octet-stream" });
5172
+ const d = await Dr(i, { textureFormat: "webp" });
5173
+ n = new Blob([d], { type: "application/octet-stream" });
5098
5174
  } else
5099
5175
  n = new Blob([JSON.stringify(i, null, 2)], { type: "application/json" });
5100
5176
  let a;
5101
5177
  if (t)
5102
5178
  a = t;
5103
5179
  else {
5104
- const u = /* @__PURE__ */ new Date();
5105
- a = `particle-scene_${`${u.getFullYear()}-${(u.getMonth() + 1).toString().padStart(2, "0")}-${u.getDate().toString().padStart(2, "0")}_${u.getHours().toString().padStart(2, "0")}${u.getMinutes().toString().padStart(2, "0")}`}`;
5180
+ const d = /* @__PURE__ */ new Date();
5181
+ a = `particle-scene_${`${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d.getDate().toString().padStart(2, "0")}_${d.getHours().toString().padStart(2, "0")}${d.getMinutes().toString().padStart(2, "0")}`}`;
5106
5182
  }
5107
5183
  const o = `${a}.${r}`, c = URL.createObjectURL(n), l = document.createElement("a");
5108
5184
  l.href = c, l.download = o, document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(c);
@@ -5110,7 +5186,7 @@ async function br(s, t, e = "hzfx") {
5110
5186
  console.error("Error saving scene:", i), alert("Error saving scene. See console for details.");
5111
5187
  }
5112
5188
  }
5113
- function Sr(s) {
5189
+ function Zr(s) {
5114
5190
  return new Promise((t, e) => {
5115
5191
  try {
5116
5192
  const i = s.target.files[0];
@@ -5123,7 +5199,7 @@ function Sr(s) {
5123
5199
  try {
5124
5200
  const a = n.target.result;
5125
5201
  let o;
5126
- if (Ti(a) ? o = Ei(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
5202
+ if (es(a) ? o = ts(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
5127
5203
  throw new Error("No valid particle systems found in the file");
5128
5204
  t({
5129
5205
  systems: o.systems.slice(),
@@ -5141,7 +5217,7 @@ function Sr(s) {
5141
5217
  }
5142
5218
  });
5143
5219
  }
5144
- async function xr(s) {
5220
+ async function Hr(s) {
5145
5221
  if (!s || typeof s != "string")
5146
5222
  throw new Error("[fetchPreset] url must be a non-empty string");
5147
5223
  const t = await fetch(s);
@@ -5149,7 +5225,7 @@ async function xr(s) {
5149
5225
  throw new Error(`[fetchPreset] HTTP ${t.status}: ${t.statusText}`);
5150
5226
  const e = await t.arrayBuffer();
5151
5227
  let i;
5152
- if (Ti(e) ? i = Ei(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
5228
+ if (es(e) ? i = ts(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
5153
5229
  throw new Error('[fetchPreset] Invalid preset: "systems" must be a non-empty array');
5154
5230
  return {
5155
5231
  version: i.version,
@@ -5157,7 +5233,7 @@ async function xr(s) {
5157
5233
  activeSystemIndex: i.activeSystemIndex ?? 0
5158
5234
  };
5159
5235
  }
5160
- const dr = (s) => `
5236
+ const Lr = (s) => `
5161
5237
  @vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
5162
5238
  var p = array<vec2f, 3>(vec2f(-1.0, -3.0), vec2f(-1.0, 1.0), vec2f(3.0, 1.0));
5163
5239
  return vec4f(p[i], 0.0, 1.0);
@@ -5167,60 +5243,60 @@ const dr = (s) => `
5167
5243
  return textureLoad(src, vec2i(pos.xy), 0);
5168
5244
  }
5169
5245
  `;
5170
- async function vr(s, t = {}) {
5246
+ async function Wr(s, t = {}) {
5171
5247
  const { getSceneDepth: e = null, autoRespawn: i = !0 } = t;
5172
5248
  let r, n, a;
5173
5249
  const o = !!(s && s.device && s.context);
5174
- o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await Js(a));
5175
- const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new Ws(r), u = { layouts: {}, pipelines: {} };
5176
- function p(f) {
5177
- const m = f ? "ms" : "ss";
5178
- if (!u.pipelines[m]) {
5179
- const S = r.createShaderModule({ code: dr(f) }), g = r.createBindGroupLayout({
5180
- entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: f } }]
5250
+ o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await Br(a));
5251
+ const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new wr(r), d = { layouts: {}, pipelines: {} };
5252
+ function S(u) {
5253
+ const f = u ? "ms" : "ss";
5254
+ if (!d.pipelines[f]) {
5255
+ const m = r.createShaderModule({ code: Lr(u) }), g = r.createBindGroupLayout({
5256
+ entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: u } }]
5181
5257
  });
5182
- u.layouts[m] = g, u.pipelines[m] = r.createRenderPipeline({
5258
+ d.layouts[f] = g, d.pipelines[f] = r.createRenderPipeline({
5183
5259
  layout: r.createPipelineLayout({ bindGroupLayouts: [g] }),
5184
- vertex: { module: S, entryPoint: "vs" },
5185
- fragment: { module: S, entryPoint: "fs", targets: [] },
5260
+ vertex: { module: m, entryPoint: "vs" },
5261
+ fragment: { module: m, entryPoint: "fs", targets: [] },
5186
5262
  primitive: { topology: "triangle-list" },
5187
5263
  depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
5188
5264
  });
5189
5265
  }
5190
- return { pipeline: u.pipelines[m], layout: u.layouts[m] };
5266
+ return { pipeline: d.pipelines[f], layout: d.layouts[f] };
5191
5267
  }
5192
- const h = {
5268
+ const b = {
5193
5269
  bloomSourceTextures: {},
5194
5270
  bloomCompositeTextures: {},
5195
5271
  combinedTexture: null,
5196
- getBloomSourceTexture(f, m, S) {
5197
- return this.bloomSourceTextures[f] || (this.bloomSourceTextures[f] = r.createTexture({
5198
- size: [m, S],
5272
+ getBloomSourceTexture(u, f, m) {
5273
+ return this.bloomSourceTextures[u] || (this.bloomSourceTextures[u] = r.createTexture({
5274
+ size: [f, m],
5199
5275
  format: "rgba16float",
5200
5276
  // HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
5201
5277
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
5202
- })), this.bloomSourceTextures[f];
5278
+ })), this.bloomSourceTextures[u];
5203
5279
  },
5204
- getBloomCompositeTexture(f, m, S) {
5205
- return this.bloomCompositeTextures[f] || (this.bloomCompositeTextures[f] = r.createTexture({
5206
- size: [m, S],
5280
+ getBloomCompositeTexture(u, f, m) {
5281
+ return this.bloomCompositeTextures[u] || (this.bloomCompositeTextures[u] = r.createTexture({
5282
+ size: [f, m],
5207
5283
  format: "rgba16float",
5208
5284
  // HDR chain
5209
5285
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
5210
- })), this.bloomCompositeTextures[f];
5286
+ })), this.bloomCompositeTextures[u];
5211
5287
  },
5212
- getCombinedTexture(f, m) {
5288
+ getCombinedTexture(u, f) {
5213
5289
  return this.combinedTexture || (this.combinedTexture = r.createTexture({
5214
- size: [f, m],
5290
+ size: [u, f],
5215
5291
  format: "rgba16float",
5216
5292
  // HDR chain — tonemapped to canvas in the final pass
5217
5293
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
5218
5294
  })), this.combinedTexture;
5219
5295
  },
5220
5296
  resizeTextures() {
5221
- Object.values(this.bloomSourceTextures).forEach((f) => f == null ? void 0 : f.destroy()), Object.values(this.bloomCompositeTextures).forEach((f) => f == null ? void 0 : f.destroy()), this.combinedTexture && this.combinedTexture.destroy(), this.bloomSourceTextures = {}, this.bloomCompositeTextures = {}, this.combinedTexture = null;
5297
+ Object.values(this.bloomSourceTextures).forEach((u) => u == null ? void 0 : u.destroy()), Object.values(this.bloomCompositeTextures).forEach((u) => u == null ? void 0 : u.destroy()), this.combinedTexture && this.combinedTexture.destroy(), this.bloomSourceTextures = {}, this.bloomCompositeTextures = {}, this.combinedTexture = null;
5222
5298
  }
5223
- }, d = {
5299
+ }, p = {
5224
5300
  systemBindGroups: {},
5225
5301
  systemBloomHorizontalBindGroups: {},
5226
5302
  secondHorizontalBindGroups: {},
@@ -5236,166 +5312,332 @@ async function vr(s, t = {}) {
5236
5312
  clear() {
5237
5313
  this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
5238
5314
  }
5239
- }, b = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), _ = 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);
5240
- l.onSystemCreated = (f) => {
5241
- P[f] || (P[f] = T());
5315
+ }, v = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), E = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), I = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), z = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), _ = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), W = St(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), T = {}, F = () => St(r, new Float32Array([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0]), GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST);
5316
+ l.onSystemCreated = (u) => {
5317
+ T[u] || (T[u] = F());
5242
5318
  };
5243
- const E = 4e4, D = new Float32Array(E * 8), N = new Float32Array(E * 4), Y = new Float32Array(E * 4), k = 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 }), Fe = /* @__PURE__ */ new Map(), ct = 8, W = [];
5244
- function Mt(f) {
5245
- for (const m of W) if (m.ids.has(f)) return m;
5319
+ const G = 4e4, H = new Float32Array(G * 8), re = new Float32Array(G * 4), ae = new Float32Array(G * 4), ne = r.createBuffer({ size: G * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), q = r.createBuffer({ size: G * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), tt = r.createBuffer({ size: G * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), xt = /* @__PURE__ */ new Map(), Xe = /* @__PURE__ */ new Map(), kt = 8, _e = [];
5320
+ function oi(u) {
5321
+ for (const f of _e) if (f.ids.has(u)) return f;
5246
5322
  return null;
5247
5323
  }
5248
- function Ai(f, m) {
5249
- if (!f.pos) return;
5250
- f.hist.push({ t: m, x: f.pos[0], y: f.pos[1], z: f.pos[2] });
5251
- const S = m - ct;
5252
- for (; f.hist.length > 2 && f.hist[0].t < S; ) f.hist.shift();
5324
+ function is(u, f) {
5325
+ if (!u.pos) return;
5326
+ u.hist.push({ t: f, x: u.pos[0], y: u.pos[1], z: u.pos[2] });
5327
+ const m = f - kt;
5328
+ for (; u.hist.length > 2 && u.hist[0].t < m; ) u.hist.shift();
5253
5329
  }
5254
- function Rt(f, m, S) {
5255
- const g = f.hist;
5330
+ function li(u, f, m) {
5331
+ const g = u.hist;
5256
5332
  if (g.length === 0) {
5257
- const q = f.pos;
5258
- return q && (S[0] = q[0], S[1] = q[1], S[2] = q[2]), S;
5333
+ const R = u.pos;
5334
+ return R && (m[0] = R[0], m[1] = R[1], m[2] = R[2]), m;
5259
5335
  }
5260
- let v;
5261
- if (m >= g[g.length - 1].t)
5262
- return v = g[g.length - 1], S[0] = v.x, S[1] = v.y, S[2] = v.z, S;
5263
- if (m <= g[0].t)
5264
- return v = g[0], S[0] = v.x, S[1] = v.y, S[2] = v.z, S;
5265
- for (let q = g.length - 1; q > 0; q--)
5266
- if (g[q - 1].t <= m) {
5267
- const j = g[q - 1], Q = g[q], Z = (m - j.t) / Math.max(1e-6, Q.t - j.t);
5268
- 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;
5336
+ let y;
5337
+ if (f >= g[g.length - 1].t)
5338
+ return y = g[g.length - 1], m[0] = y.x, m[1] = y.y, m[2] = y.z, m;
5339
+ if (f <= g[0].t)
5340
+ return y = g[0], m[0] = y.x, m[1] = y.y, m[2] = y.z, m;
5341
+ for (let R = g.length - 1; R > 0; R--)
5342
+ if (g[R - 1].t <= f) {
5343
+ const P = g[R - 1], M = g[R], x = (f - P.t) / Math.max(1e-6, M.t - P.t);
5344
+ return m[0] = P.x + (M.x - P.x) * x, m[1] = P.y + (M.y - P.y) * x, m[2] = P.z + (M.z - P.z) * x, m;
5269
5345
  }
5270
- return v = g[0], S[0] = v.x, S[1] = v.y, S[2] = v.z, S;
5271
- }
5272
- const Ci = 0.41421356;
5273
- function Ui() {
5274
- Fe.clear();
5275
- let f = 0, m = 0;
5276
- C.position[0], C.position[1], C.position[2];
5277
- for (const { system: S, config: g } of l.particleSystems) {
5278
- if (!g.emissionTrailEnabled || g.hidden || g.glbModelEnabled) continue;
5279
- S.readbackAndProcessParticles();
5280
- const v = S.particleData, q = S.particleVelocities, j = S.activeParticles;
5281
- if (!v || !q || j <= 0) continue;
5282
- const Q = g.emissionTrailMode === "particles", Z = f, Ce = 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)), F = 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, qt = Ue ? Ue[2] : 0, Oe = Mt(g.id), Ht = !!(J && Oe && Oe.hist && Oe.hist.length > 1);
5283
- for (let st = 0; st < j; st++) {
5284
- const pe = st * 8, rt = v[pe], mt = v[pe + 1], nt = v[pe + 2], ns = rt + X, as = mt + it, os = nt + jt;
5285
- let Le = v[pe + 3], Xe = v[pe + 4], Ne = v[pe + 5];
5286
- const ke = v[pe + 6], Ie = v[pe + 7];
5287
- if (ke >= Ie || Ie <= 0) continue;
5288
- const me = ke / Ie;
5289
- if (g.colorTransitionEnabled) {
5290
- const w = g.startColor ?? [1, 0, 0], z = g.endColor ?? [0, 0, 1];
5291
- Le = w[0] + (z[0] - w[0]) * me, Xe = w[1] + (z[1] - w[1]) * me, Ne = w[2] + (z[2] - w[2]) * me;
5292
- }
5293
- Le = Math.min(1, Le * U), Xe = Math.min(1, Xe * U), Ne = Math.min(1, Ne * U);
5294
- let je = B;
5295
- if (g.randomSize) {
5296
- const w = Math.sin(Ie * 54321.67) * 43758.5453 % 1, z = w < 0 ? w + 1 : w;
5297
- je = (g.minSize ?? 0.1) + ((g.maxSize ?? 0.5) - (g.minSize ?? 0.1)) * z;
5298
- }
5299
- if (g.fadeSizeEnabled) {
5300
- const w = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
5301
- je *= 1 - Math.pow(me, 1 / w);
5302
- }
5303
- if (g.increaseSizeEnabled) {
5304
- const w = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
5305
- je *= 1 + Math.pow(me, 1 / w);
5306
- }
5307
- if (je <= 0 || me > 0.9) continue;
5308
- const Zt = Math.min((0.9 - me) * (1 / 0.2), 1), $t = 0.75 * je * Ci * Zt;
5309
- let Ye = y;
5310
- if (g.fadeEnabled && (Ye *= Math.max(0, 1 - me)), Ye *= Zt, Ye < 0.01) continue;
5311
- const yt = st * 4, Wt = q[yt], Jt = q[yt + 1], Qt = q[yt + 2], at = Wt + Yt, ot = Jt + rs, lt = Qt + qt, Kt = Math.sqrt(at * at + ot * ot + lt * lt);
5312
- if (Kt < 1e-3) continue;
5313
- const gt = 1 / Kt, ve = at * gt, Pe = ot * gt, ye = lt * gt, ei = C.right[0], ti = C.right[1], ii = C.right[2];
5314
- let bt = ei * ve + ti * Pe + ii * ye, re = ei - bt * ve, ne = ti - bt * Pe, ae = ii - bt * ye, qe = Math.sqrt(re * re + ne * ne + ae * ae);
5315
- if (qe < 0.2) {
5316
- const w = C.up[0], z = C.up[1], $ = C.up[2], V = w * ve + z * Pe + $ * ye;
5317
- re = w - V * ve, ne = z - V * Pe, ae = $ - V * ye, qe = Math.sqrt(re * re + ne * ne + ae * ae) || 1;
5318
- }
5319
- re /= qe, ne /= qe, ae /= qe;
5320
- const He = Math.min(Ce, ke);
5321
- if (He < 1e-3) continue;
5322
- const si = g.gravityEnabled && g.gravityStrength || 0, _e = Ni, we = ki, Be = ji;
5323
- if (g.orientToDirection && g.burstMode && Ht) {
5324
- const w = S._emitSimRotY || 0, z = Yi, $ = qi, V = Hi;
5325
- for (let A = 0; A <= I; A++) {
5326
- const O = Rt(Oe, he - A / I * He, Vt);
5327
- z[A] = O[0], $[A] = O[1], V[A] = O[2];
5328
- }
5329
- for (let A = 0; A <= I; A++) {
5330
- const O = A > 0 ? A - 1 : 0, H = A < I ? A + 1 : I;
5331
- let Me = z[O] - z[H], Re = V[O] - V[H];
5332
- const ge = (Math.hypot(Me, Re) > 1e-5 ? Math.atan2(Me, Re) : Math.atan2(Yt, qt)) - w, te = Math.cos(ge), ie = Math.sin(ge), ue = A / I * He, St = -0.5 * si * ue * ue;
5333
- _e[A] = te * rt + ie * nt + z[A], we[A] = mt + St + $[A], Be[A] = -ie * rt + te * nt + V[A];
5334
- }
5335
- } else for (let w = 0; w <= I; w++) {
5336
- const z = w / I * He, $ = -0.5 * si * z * z;
5337
- if (Ht) {
5338
- const V = Rt(Oe, he - z, Vt);
5339
- _e[w] = rt - Wt * z + V[0], we[w] = mt - Jt * z + $ + V[1], Be[w] = nt - Qt * z + V[2];
5340
- } else
5341
- _e[w] = ns - at * z, we[w] = as - ot * z + $, Be[w] = os - lt * z;
5342
- }
5343
- if (F !== "straight") {
5344
- const w = g.emissionTrailShapeAmplitude ?? 0.1, z = g.emissionTrailShapeFrequency ?? 4, $ = g.emissionTrailShapeSpeed ?? 0;
5345
- let V = -ye, A = 0, O = ve, H = Math.sqrt(V * V + O * O);
5346
- H < 1e-6 && (V = 0, A = ye, O = -Pe, H = Math.sqrt(V * V + A * A + O * O) || 1), V /= H, A /= H, O /= H;
5347
- const Me = Pe * O - ye * A, Re = ye * V - ve * O, ce = ve * A - Pe * V;
5348
- for (let ee = 1; ee <= I; ee++) {
5349
- const ge = ee / I * He, te = 2 * Math.PI * z * (he - ge) + $ * he;
5350
- let ie = 0, ue = 0;
5351
- F === "zigzag" ? ie = w * Math.sign(Math.sin(te)) : F === "sine" ? ie = w * Math.sin(te) : F === "spiral" && (ie = w * Math.sin(te), ue = w * Math.cos(te)), _e[ee] += V * ie + Me * ue, we[ee] += A * ie + Re * ue, Be[ee] += O * ie + ce * ue;
5346
+ return y = g[0], m[0] = y.x, m[1] = y.y, m[2] = y.z, m;
5347
+ }
5348
+ const pt = Math.PI * 2, oe = new Array(257), le = new Array(257), ce = new Array(257), Xt = new Array(257), Nt = new Array(257), Yt = new Array(257);
5349
+ new Array(257), new Array(257), new Array(257);
5350
+ const Ee = [0, 0, 0];
5351
+ function ss(u) {
5352
+ const f = u.emissionRotationX || 0, m = u.emissionRotationY || 0, g = u.emissionRotationZ || 0;
5353
+ if (!f && !m && !g) return null;
5354
+ const y = f * Math.PI / 180, R = m * Math.PI / 180, P = g * Math.PI / 180, M = Math.cos(y), x = Math.sin(y), B = Math.cos(R), h = Math.sin(R), w = Math.cos(P), C = Math.sin(P);
5355
+ return [
5356
+ B * w,
5357
+ x * h * w - M * C,
5358
+ M * h * w + x * C,
5359
+ B * C,
5360
+ x * h * C + M * w,
5361
+ M * h * C - x * w,
5362
+ -h,
5363
+ x * B,
5364
+ M * B
5365
+ ];
5366
+ }
5367
+ function Ut(u, f, m, g, y) {
5368
+ return y[0] = u[0] * f + u[1] * m + u[2] * g, y[1] = u[3] * f + u[4] * m + u[5] * g, y[2] = u[6] * f + u[7] * m + u[8] * g, y;
5369
+ }
5370
+ function rs(u, f, m, g, y, R, P) {
5371
+ let M = u, x = f, B = m;
5372
+ g && (Ut(g, M, x, B, P), M = P[0], x = P[1], B = P[2]), M += R.emissionPositionX || 0, x += R.emissionPositionY || 0, B += R.emissionPositionZ || 0, y._simRotMatrix && (Ut(y._simRotMatrix, M, x, B, P), M = P[0], x = P[1], B = P[2]);
5373
+ const h = y._simPosition;
5374
+ return P[0] = M + (h ? h[0] : 0), P[1] = x + (h ? h[1] : 0), P[2] = B + (h ? h[2] : 0), P;
5375
+ }
5376
+ function ns(u, f, m, g, y, R) {
5377
+ let P = u, M = f, x = m;
5378
+ return g && (Ut(g, P, M, x, R), P = R[0], M = R[1], x = R[2]), y._simRotMatrix && (Ut(y._simRotMatrix, P, M, x, R), P = R[0], M = R[1], x = R[2]), R[0] = P, R[1] = M, R[2] = x, R;
5379
+ }
5380
+ function jt(u, f, m, g, y) {
5381
+ const R = f * 2, P = m * 2, M = 2 * (R + P);
5382
+ let x = (u % 1 + 1) % 1 * M, B = 0, h = 0;
5383
+ return x < R ? (B = -f + x, h = m) : (x -= R) < P ? (B = f, h = m - x) : (x -= P) < R ? (B = f - x, h = -m) : (x -= R, B = -f, h = -m + x), g === "xz" ? (y[0] = B, y[1] = 0, y[2] = h) : (y[0] = B, y[1] = h, y[2] = 0), y;
5384
+ }
5385
+ function as(u) {
5386
+ const f = u.emissionShape, m = Math.max(1, Math.min(256, Math.floor(u.shapeStrokeSegments ?? 96)));
5387
+ let g = 0, y = !1, R = [0, 0, 1];
5388
+ const P = Ee;
5389
+ if (f === "circle") {
5390
+ y = !0, g = Math.max(3, m), R = [0, 0, 1];
5391
+ const M = u.circleOuterRadius ?? 2;
5392
+ for (let x = 0; x < g; x++) {
5393
+ const B = x / g * pt;
5394
+ oe[x] = Math.cos(B) * M, le[x] = Math.sin(B) * M, ce[x] = 0;
5395
+ }
5396
+ } else if (f === "disc") {
5397
+ y = !0, g = Math.max(3, m), R = [0, 1, 0];
5398
+ const M = u.discRadius ?? 2;
5399
+ for (let x = 0; x < g; x++) {
5400
+ const B = x / g * pt;
5401
+ oe[x] = Math.cos(B) * M, le[x] = 0, ce[x] = Math.sin(B) * M;
5402
+ }
5403
+ } else if (f === "annulus") {
5404
+ y = !0, g = Math.max(3, m), R = [0, 1, 0];
5405
+ const M = u.annulusInnerRadius ?? 1, x = u.annulusOuterRadius ?? 2, B = M + (x - M) * 0.5;
5406
+ for (let h = 0; h < g; h++) {
5407
+ const w = h / g * pt;
5408
+ oe[h] = Math.cos(w) * B, le[h] = 0, ce[h] = Math.sin(w) * B;
5409
+ }
5410
+ } else if (f === "arc") {
5411
+ y = !1, g = Math.max(2, m + 1), R = [0, 0, 1];
5412
+ const M = u.arcInnerRadius ?? 0, x = u.arcOuterRadius ?? 2, B = M > 0 ? M + (x - M) * 0.5 : x, h = (u.arcStartAngle ?? 0) * Math.PI / 180, w = (u.arcEndAngle ?? 180) * Math.PI / 180;
5413
+ for (let C = 0; C < g; C++) {
5414
+ const Z = g > 1 ? C / (g - 1) : 0, O = h + (w - h) * Z;
5415
+ oe[C] = Math.cos(O) * B, le[C] = Math.sin(O) * B, ce[C] = 0;
5416
+ }
5417
+ } else if (f === "square") {
5418
+ y = !0, g = Math.max(4, m), R = [0, 0, 1];
5419
+ const M = u.squareSize ?? 2;
5420
+ for (let x = 0; x < g; x++)
5421
+ jt(x / g, M, M, "xy", P), oe[x] = P[0], le[x] = P[1], ce[x] = P[2];
5422
+ } else if (f === "rectangle") {
5423
+ y = !0, g = Math.max(4, m), R = [0, 0, 1];
5424
+ const M = (u.rectangleWidth ?? 2) * 0.5, x = (u.rectangleHeight ?? 2) * 0.5;
5425
+ for (let B = 0; B < g; B++)
5426
+ jt(B / g, M, x, "xy", P), oe[B] = P[0], le[B] = P[1], ce[B] = P[2];
5427
+ } else if (f === "plain") {
5428
+ y = !0, g = Math.max(4, m), R = [0, 1, 0];
5429
+ const M = (u.planeWidth ?? 2) * 0.5, x = (u.planeDepth ?? 2) * 0.5;
5430
+ for (let B = 0; B < g; B++)
5431
+ jt(B / g, M, x, "xz", P), oe[B] = P[0], le[B] = P[1], ce[B] = P[2];
5432
+ } else if (f === "line") {
5433
+ y = !1, g = Math.max(2, m + 1), R = [0, 0, 1];
5434
+ const M = u.lineLength ?? 4;
5435
+ for (let x = 0; x < g; x++) {
5436
+ const B = g > 1 ? x / (g - 1) : 0;
5437
+ oe[x] = 0, le[x] = (B - 0.5) * M, ce[x] = 0;
5438
+ }
5439
+ } else if (f === "polygon") {
5440
+ y = !0, g = Math.max(3, m), R = [0, 0, 1];
5441
+ const M = Math.max(3, Math.floor(u.polygonSides ?? 6)), x = u.polygonRadius ?? 2;
5442
+ for (let B = 0; B < g; B++) {
5443
+ const h = B / g * M, w = Math.floor(h), C = h - w, Z = w / M * pt, O = (w + 1) / M * pt, L = Math.cos(Z) * x, N = Math.sin(Z) * x, V = Math.cos(O) * x, xe = Math.sin(O) * x;
5444
+ oe[B] = L + (V - L) * C, le[B] = N + (xe - N) * C, ce[B] = 0;
5445
+ }
5446
+ } else
5447
+ g = 0;
5448
+ return { count: g, closed: y, planeNormal: R };
5449
+ }
5450
+ function os(u, f, m) {
5451
+ if (!m.shapeStrokeEnabled || m.hidden) return u;
5452
+ const { count: g, closed: y, planeNormal: R } = as(m);
5453
+ if (g < 2) return u;
5454
+ const P = ss(m), M = Math.max(1e-4, m.shapeStrokeWidth ?? 0.08), x = Math.max(0, m.opacity ?? 1);
5455
+ if (x <= 0) return u;
5456
+ ns(R[0], R[1], R[2], P, f, Ee);
5457
+ let B = Math.hypot(Ee[0], Ee[1], Ee[2]) || 1;
5458
+ const h = Ee[0] / B, w = Ee[1] / B, C = Ee[2] / B;
5459
+ for (let U = 0; U < g; U++)
5460
+ rs(oe[U], le[U], ce[U], P, f, m, Ee), oe[U] = Ee[0], le[U] = Ee[1], ce[U] = Ee[2];
5461
+ const Z = m.shapeStrokeShape ?? "straight";
5462
+ if (Z !== "straight") {
5463
+ const U = m.shapeStrokeAmplitude ?? 0.08, Q = m.shapeStrokeFrequency ?? 10, Ie = m.shapeStrokeSpeed ?? 0;
5464
+ for (let $ = 0; $ < g; $++) {
5465
+ const pe = $ === 0 ? y ? g - 1 : 0 : $ - 1, te = $ === g - 1 ? y ? 0 : g - 1 : $ + 1, ye = oe[te] - oe[pe], J = le[te] - le[pe], ee = ce[te] - ce[pe], K = w * ee - C * J, ie = C * ye - h * ee, ue = h * J - w * ye, ge = Math.hypot(K, ie, ue) || 1, ve = K / ge, de = ie / ge, Ze = ue / ge, Me = y ? $ / g : $ / Math.max(1, g - 1), be = pt * Q * Me + Ie * Ve;
5466
+ let he = 0, me = 0;
5467
+ Z === "zigzag" ? he = U * Math.sign(Math.sin(be) || 1) : Z === "sine" ? he = U * Math.sin(be) : Z === "spiral" && (he = U * Math.sin(be), me = U * Math.cos(be)), oe[$] += ve * he + h * me, le[$] += de * he + w * me, ce[$] += Ze * he + C * me;
5468
+ }
5469
+ }
5470
+ const O = y ? g : g - 1, L = m.bloomIntensity || 1, N = m.startColor ?? m.particleColor ?? [1, 1, 1], V = m.endColor ?? N, xe = m.particleColor ?? N, ct = m.randomColorEnabled && Array.isArray(m.randomColors) && m.randomColors.length > 0 ? m.randomColors[0] : null, Se = M * 0.5, _t = Math.max(M * 4, 1e-4), je = (m.shapeStrokeSpeed ?? 0) * Ve;
5471
+ let it = 0;
5472
+ for (let U = 0; U < O; U++) {
5473
+ const Q = y ? (U + 1) % g : U + 1;
5474
+ it += Math.hypot(oe[Q] - oe[U], le[Q] - le[U], ce[Q] - ce[U]);
5475
+ }
5476
+ const Qt = y ? Math.max(1, Math.round(it / _t)) : Math.max(it / _t, 1e-6), Mt = it > 1e-6 ? Qt / it : 0;
5477
+ let qe = 0, wt = !1, ut = 0, Ue = 0, dt = 0;
5478
+ for (let U = 0; U < g; U++) {
5479
+ const Q = U === 0 ? y ? g - 1 : 0 : U - 1, Ie = U === g - 1 ? y ? 0 : g - 1 : U + 1;
5480
+ let $ = oe[Ie] - oe[Q], pe = le[Ie] - le[Q], te = ce[Ie] - ce[Q];
5481
+ const ye = Math.hypot($, pe, te) || 1;
5482
+ $ /= ye, pe /= ye, te /= ye;
5483
+ let J = w * te - C * pe, ee = C * $ - h * te, K = h * pe - w * $, ie = Math.hypot(J, ee, K);
5484
+ if (ie < 1e-5) {
5485
+ const ue = D.right[0], ge = D.right[1], ve = D.right[2], de = ue * $ + ge * pe + ve * te;
5486
+ J = ue - de * $, ee = ge - de * pe, K = ve - de * te, ie = Math.hypot(J, ee, K);
5487
+ }
5488
+ if (ie < 1e-5) {
5489
+ const ue = D.up[0], ge = D.up[1], ve = D.up[2], de = ue * $ + ge * pe + ve * te;
5490
+ J = ue - de * $, ee = ge - de * pe, K = ve - de * te, ie = Math.hypot(J, ee, K) || 1;
5491
+ }
5492
+ J /= ie, ee /= ie, K /= ie, wt && ut * J + Ue * ee + dt * K < 0 && (J = -J, ee = -ee, K = -K), Xt[U] = J, Nt[U] = ee, Yt[U] = K, ut = J, Ue = ee, dt = K, wt = !0;
5493
+ }
5494
+ for (let U = 0; U < O && !(u + 54 > Ce.length); U++) {
5495
+ const Q = y ? (U + 1) % g : U + 1, Ie = oe[U], $ = le[U], pe = ce[U], te = oe[Q], ye = le[Q], J = ce[Q];
5496
+ let ee = te - Ie, K = ye - $, ie = J - pe;
5497
+ const ue = Math.hypot(ee, K, ie) || 1;
5498
+ ee /= ue, K /= ue, ie /= ue;
5499
+ const ge = y ? U / g : U / Math.max(1, g - 1), ve = y ? Q / g : Q / Math.max(1, g - 1), de = qe * Mt + je, Ze = (qe + ue) * Mt + je;
5500
+ let Me, be, he, me, we, Be;
5501
+ ct ? (Me = me = ct[0], be = we = ct[1], he = Be = ct[2]) : m.colorTransitionEnabled ? (Me = N[0] + (V[0] - N[0]) * ge, be = N[1] + (V[1] - N[1]) * ge, he = N[2] + (V[2] - N[2]) * ge, me = N[0] + (V[0] - N[0]) * ve, we = N[1] + (V[1] - N[1]) * ve, Be = N[2] + (V[2] - N[2]) * ve) : (Me = me = xe[0], be = we = xe[1], he = Be = xe[2]), Me = Math.min(1, Me * L), be = Math.min(1, be * L), he = Math.min(1, he * L), me = Math.min(1, me * L), we = Math.min(1, we * L), Be = Math.min(1, Be * L);
5502
+ const Bt = Xt[U], gt = Nt[U], Oe = Yt[U], Le = Xt[Q], ze = Nt[Q], Rt = Yt[Q], Ot = Ie + Bt * Se, Lt = $ + gt * Se, Tt = pe + Oe * Se, Re = Ie - Bt * Se, Te = $ - gt * Se, Ae = pe - Oe * Se, st = te + Le * Se, rt = ye + ze * Se, At = J + Rt * Se, He = te - Le * Se, We = ye - ze * Se, $e = J - Rt * Se, ft = (A, X, fe, Y, k, j, se, Je, Ke) => {
5503
+ Ce[u++] = A, Ce[u++] = X, Ce[u++] = fe, Ce[u++] = Y, Ce[u++] = k, Ce[u++] = j, Ce[u++] = se, Ce[u++] = Je, Ce[u++] = Ke;
5504
+ };
5505
+ ft(Ot, Lt, Tt, Me, be, he, x, de, 0), ft(Re, Te, Ae, Me, be, he, x, de, 1), ft(st, rt, At, me, we, Be, x, Ze, 0), ft(Re, Te, Ae, Me, be, he, x, de, 1), ft(He, We, $e, me, we, Be, x, Ze, 1), ft(st, rt, At, me, we, Be, x, Ze, 0), qe += ue;
5506
+ }
5507
+ return u;
5508
+ }
5509
+ const ls = 0.41421356;
5510
+ function cs() {
5511
+ xt.clear(), Xe.clear();
5512
+ let u = 0, f = 0, m = 0;
5513
+ D.position[0], D.position[1], D.position[2];
5514
+ for (const { system: g, config: y } of l.particleSystems) {
5515
+ if (y.hidden) continue;
5516
+ if (y.emissionTrailEnabled && !y.glbModelEnabled) {
5517
+ g.readbackAndProcessParticles();
5518
+ const P = g.particleData, M = g.particleVelocities, x = g.activeParticles;
5519
+ if (P && M && x > 0) {
5520
+ const B = y.emissionTrailMode === "particles", h = u, w = y.emissionTrailDuration ?? 1, C = y.opacity ?? 1, Z = y.particleSize ?? 0.5, O = y.bloomIntensity || 1, L = Math.max(1, Math.min(64, y.emissionTrailSegments ?? 8)), N = y.emissionTrailShape || "straight", V = y.followSystemTranslation ?? !0, xe = g._simPosition, ct = V && xe ? xe[0] : 0, Se = V && xe ? xe[1] : 0, _t = V && xe ? xe[2] : 0, je = g._simVelocity, it = je ? je[0] : 0, Qt = je ? je[1] : 0, Mt = je ? je[2] : 0, qe = oi(y.id), wt = !!(V && qe && qe.hist && qe.hist.length > 1);
5521
+ for (let ut = 0; ut < x; ut++) {
5522
+ const Ue = ut * 8, dt = P[Ue], U = P[Ue + 1], Q = P[Ue + 2], Ie = dt + ct, $ = U + Se, pe = Q + _t;
5523
+ let te = P[Ue + 3], ye = P[Ue + 4], J = P[Ue + 5];
5524
+ const ee = P[Ue + 6], K = P[Ue + 7];
5525
+ if (ee >= K || K <= 0) continue;
5526
+ const ie = ee / K;
5527
+ if (y.colorTransitionEnabled) {
5528
+ const A = y.startColor ?? [1, 0, 0], X = y.endColor ?? [0, 0, 1];
5529
+ te = A[0] + (X[0] - A[0]) * ie, ye = A[1] + (X[1] - A[1]) * ie, J = A[2] + (X[2] - A[2]) * ie;
5530
+ }
5531
+ te = Math.min(1, te * O), ye = Math.min(1, ye * O), J = Math.min(1, J * O);
5532
+ let ue = Z;
5533
+ if (y.randomSize) {
5534
+ const A = Math.sin(K * 54321.67) * 43758.5453 % 1, X = A < 0 ? A + 1 : A;
5535
+ ue = (y.minSize ?? 0.1) + ((y.maxSize ?? 0.5) - (y.minSize ?? 0.1)) * X;
5536
+ }
5537
+ if (y.fadeSizeEnabled) {
5538
+ const A = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
5539
+ ue *= 1 - Math.pow(ie, 1 / A);
5540
+ }
5541
+ if (y.increaseSizeEnabled) {
5542
+ const A = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
5543
+ ue *= 1 + Math.pow(ie, 1 / A);
5544
+ }
5545
+ if (ue <= 0 || ie > 0.9) continue;
5546
+ const ge = Math.min((0.9 - ie) * (1 / 0.2), 1), ve = 0.75 * ue * ls * ge;
5547
+ let de = C;
5548
+ if (y.fadeEnabled && (de *= Math.max(0, 1 - ie)), de *= ge, de < 0.01) continue;
5549
+ const Ze = ut * 4, Me = M[Ze], be = M[Ze + 1], he = M[Ze + 2], me = Me + it, we = be + Qt, Be = he + Mt, Bt = Math.sqrt(me * me + we * we + Be * Be);
5550
+ if (Bt < 1e-3) continue;
5551
+ const gt = 1 / Bt, Oe = me * gt, Le = we * gt, ze = Be * gt, Rt = D.right[0], Ot = D.right[1], Lt = D.right[2];
5552
+ let Tt = Rt * Oe + Ot * Le + Lt * ze, Re = Rt - Tt * Oe, Te = Ot - Tt * Le, Ae = Lt - Tt * ze, st = Math.sqrt(Re * Re + Te * Te + Ae * Ae);
5553
+ if (st < 0.2) {
5554
+ const A = D.up[0], X = D.up[1], fe = D.up[2], Y = A * Oe + X * Le + fe * ze;
5555
+ Re = A - Y * Oe, Te = X - Y * Le, Ae = fe - Y * ze, st = Math.sqrt(Re * Re + Te * Te + Ae * Ae) || 1;
5556
+ }
5557
+ Re /= st, Te /= st, Ae /= st;
5558
+ const rt = Math.min(w, ee);
5559
+ if (rt < 1e-3) continue;
5560
+ const At = y.gravityEnabled && y.gravityStrength || 0, He = vs, We = Ps, $e = _s;
5561
+ if (y.orientToDirection && y.burstMode && wt) {
5562
+ const A = g._emitSimRotY || 0, X = Ms, fe = ws, Y = Bs;
5563
+ for (let k = 0; k <= L; k++) {
5564
+ const j = li(qe, Ve - k / L * rt, Pi);
5565
+ X[k] = j[0], fe[k] = j[1], Y[k] = j[2];
5566
+ }
5567
+ for (let k = 0; k <= L; k++) {
5568
+ const j = k > 0 ? k - 1 : 0, se = k < L ? k + 1 : L;
5569
+ let Je = X[j] - X[se], Ke = Y[j] - Y[se];
5570
+ const nt = (Math.hypot(Je, Ke) > 1e-5 ? Math.atan2(Je, Ke) : Math.atan2(it, Mt)) - A, Fe = Math.cos(nt), Ge = Math.sin(nt), et = k / L * rt, ei = -0.5 * At * et * et;
5571
+ He[k] = Fe * dt + Ge * Q + X[k], We[k] = U + ei + fe[k], $e[k] = -Ge * dt + Fe * Q + Y[k];
5572
+ }
5573
+ } else for (let A = 0; A <= L; A++) {
5574
+ const X = A / L * rt, fe = -0.5 * At * X * X;
5575
+ if (wt) {
5576
+ const Y = li(qe, Ve - X, Pi);
5577
+ He[A] = dt - Me * X + Y[0], We[A] = U - be * X + fe + Y[1], $e[A] = Q - he * X + Y[2];
5578
+ } else
5579
+ He[A] = Ie - me * X, We[A] = $ - we * X + fe, $e[A] = pe - Be * X;
5580
+ }
5581
+ if (N !== "straight") {
5582
+ const A = y.emissionTrailShapeAmplitude ?? 0.1, X = y.emissionTrailShapeFrequency ?? 4, fe = y.emissionTrailShapeSpeed ?? 0;
5583
+ let Y = -ze, k = 0, j = Oe, se = Math.sqrt(Y * Y + j * j);
5584
+ se < 1e-6 && (Y = 0, k = ze, j = -Le, se = Math.sqrt(Y * Y + k * k + j * j) || 1), Y /= se, k /= se, j /= se;
5585
+ const Je = Le * j - ze * k, Ke = ze * Y - Oe * j, Qe = Oe * k - Le * Y;
5586
+ for (let Pe = 1; Pe <= L; Pe++) {
5587
+ const nt = Pe / L * rt, Fe = 2 * Math.PI * X * (Ve - nt) + fe * Ve;
5588
+ let Ge = 0, et = 0;
5589
+ N === "zigzag" ? Ge = A * Math.sign(Math.sin(Fe)) : N === "sine" ? Ge = A * Math.sin(Fe) : N === "spiral" && (Ge = A * Math.sin(Fe), et = A * Math.cos(Fe)), He[Pe] += Y * Ge + Je * et, We[Pe] += k * Ge + Ke * et, $e[Pe] += j * Ge + Qe * et;
5590
+ }
5591
+ }
5592
+ if (B)
5593
+ for (let A = 1; A <= L && u < G; A++) {
5594
+ const X = A / L, fe = He[A] - ct, Y = We[A] - Se, k = $e[A] - _t, j = u * 8, se = u * 4;
5595
+ H[j] = fe, H[j + 1] = Y, H[j + 2] = k, H[j + 3] = te, H[j + 4] = ye, H[j + 5] = J, H[j + 6] = ee + (K - ee) * X, H[j + 7] = K, re[se] = 0, re[se + 1] = 0, re[se + 2] = 0, re[se + 3] = 0, ae[se] = fe, ae[se + 1] = Y, ae[se + 2] = k, ae[se + 3] = 0, u++;
5596
+ }
5597
+ else
5598
+ for (let A = 0; A < L && !(f + 42 > Ye.length); A++) {
5599
+ const X = A / L, fe = (A + 1) / L, Y = He[A], k = We[A], j = $e[A], se = He[A + 1], Je = We[A + 1], Ke = $e[A + 1], Qe = ve * (1 - X), Pe = ve * (1 - fe), nt = de * (1 - X) * (1 - X), Fe = de * (1 - fe) * (1 - fe), Ge = Y + Re * Qe, et = k + Te * Qe, ei = j + Ae * Qe, Ei = Y - Re * Qe, Ci = k - Te * Qe, Ui = j - Ae * Qe, Ii = se + Re * Pe, zi = Je + Te * Pe, Fi = Ke + Ae * Pe, Ds = se - Re * Pe, Vs = Je - Te * Pe, Os = Ke - Ae * Pe, bt = (Ls, ks, Xs, Ns) => {
5600
+ Ye[f++] = Ls, Ye[f++] = ks, Ye[f++] = Xs, Ye[f++] = te, Ye[f++] = ye, Ye[f++] = J, Ye[f++] = Ns;
5601
+ };
5602
+ bt(Ge, et, ei, nt), bt(Ei, Ci, Ui, nt), bt(Ii, zi, Fi, Fe), bt(Ei, Ci, Ui, nt), bt(Ds, Vs, Os, Fe), bt(Ii, zi, Fi, Fe);
5603
+ }
5352
5604
  }
5605
+ B && u > h && xt.set(y.id, { first: h, count: u - h });
5353
5606
  }
5354
- if (Q)
5355
- for (let w = 1; w <= I && f < E; w++) {
5356
- const z = w / I, $ = _e[w] - X, V = we[w] - it, A = Be[w] - jt, O = f * 8, H = f * 4;
5357
- D[O] = $, D[O + 1] = V, D[O + 2] = A, D[O + 3] = Le, D[O + 4] = Xe, D[O + 5] = Ne, D[O + 6] = ke + (Ie - ke) * z, D[O + 7] = Ie, N[H] = 0, N[H + 1] = 0, N[H + 2] = 0, N[H + 3] = 0, Y[H] = $, Y[H + 1] = V, Y[H + 2] = A, Y[H + 3] = 0, f++;
5358
- }
5359
- else
5360
- for (let w = 0; w < I && !(m + 42 > le.length); w++) {
5361
- const z = w / I, $ = (w + 1) / I, V = _e[w], A = we[w], O = Be[w], H = _e[w + 1], Me = we[w + 1], Re = Be[w + 1], ce = $t * (1 - z), ee = $t * (1 - $), ge = Ye * (1 - z) * (1 - z), te = Ye * (1 - $) * (1 - $), ie = V + re * ce, ue = A + ne * ce, St = O + ae * ce, ri = V - re * ce, ni = A - ne * ce, ai = O - ae * ce, oi = H + re * ee, li = Me + ne * ee, ci = Re + ae * ee, ls = H - re * ee, cs = Me - ne * ee, us = Re - ae * ee, ze = (ds, fs, hs, ps) => {
5362
- le[m++] = ds, le[m++] = fs, le[m++] = hs, le[m++] = Le, le[m++] = Xe, le[m++] = Ne, le[m++] = ps;
5363
- };
5364
- 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);
5365
- }
5366
5607
  }
5367
- Q && f > Z && Fe.set(g.id, { first: Z, count: f - Z });
5608
+ const R = m;
5609
+ m = os(m, g, y), m > R && Xe.set(y.id, { first: R / 9, count: (m - R) / 9 });
5368
5610
  }
5369
- f > 0 && (r.queue.writeBuffer(k, 0, D, 0, f * 8), r.queue.writeBuffer(G, 0, N, 0, f * 4), r.queue.writeBuffer(de, 0, Y, 0, f * 4)), De = m / 7, De > 0 && r.queue.writeBuffer(zt, 0, le, 0, m);
5611
+ u > 0 && (r.queue.writeBuffer(ne, 0, H, 0, u * 8), r.queue.writeBuffer(q, 0, re, 0, u * 4), r.queue.writeBuffer(tt, 0, ae, 0, u * 4)), vt = f / 7, vt > 0 && r.queue.writeBuffer(qt, 0, Ye, 0, f), bi = m / 9, bi > 0 && r.queue.writeBuffer(Zt, 0, Ce, 0, m);
5370
5612
  }
5371
- const Tt = () => {
5372
- 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]));
5613
+ const ci = () => {
5614
+ r.queue.writeBuffer(I, 0, new Float32Array([1, 0, a.width, a.height, 0, 0, 0, 0])), r.queue.writeBuffer(z, 0, new Float32Array([0, 1, a.width, a.height, 0, 0, 0, 0]));
5373
5615
  };
5374
- Tt();
5375
- const Et = new Float32Array(16).fill(0);
5376
- Et[0] = 1, r.queue.writeBuffer(x, 0, Et);
5377
- const se = ir(r), fe = er(r), {
5378
- particlePipeline: Ii,
5379
- particleAdditivePipeline: zi,
5380
- particleDepthWritePipeline: Gi,
5381
- blurPipeline: We,
5382
- compositePipeline: Fi,
5383
- directRenderPipeline: At,
5384
- finalCompositePipeline: Di,
5385
- glbMeshPipeline: Vi
5386
- } = tr(r, c, fe), Ct = r.createShaderModule({ code: `
5616
+ ci();
5617
+ const ui = new Float32Array(16).fill(0);
5618
+ ui[0] = 1, r.queue.writeBuffer(_, 0, ui);
5619
+ const De = Cr(r), Ne = Ar(r), {
5620
+ particlePipeline: us,
5621
+ particleAdditivePipeline: ds,
5622
+ particleDepthWritePipeline: fs,
5623
+ blurPipeline: It,
5624
+ compositePipeline: ps,
5625
+ directRenderPipeline: di,
5626
+ finalCompositePipeline: hs,
5627
+ glbMeshPipeline: ms
5628
+ } = Er(r, c, Ne), fi = r.createShaderModule({ code: `
5387
5629
  struct U { mvp: mat4x4<f32> };
5388
5630
  @group(0) @binding(0) var<uniform> u: U;
5389
5631
  struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
5390
5632
  struct VOut { @builtin(position) pos: vec4<f32>, @location(0) col: vec4<f32> };
5391
5633
  @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; }
5392
5634
  @fragment fn fs(i: VOut) -> @location(0) vec4<f32> { return i.col; }
5393
- ` }), Ut = r.createBindGroupLayout({
5635
+ ` }), pi = r.createBindGroupLayout({
5394
5636
  entries: [{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } }]
5395
- }), Oi = r.createRenderPipeline({
5396
- layout: r.createPipelineLayout({ bindGroupLayouts: [Ut] }),
5637
+ }), ys = r.createRenderPipeline({
5638
+ layout: r.createPipelineLayout({ bindGroupLayouts: [pi] }),
5397
5639
  vertex: {
5398
- module: Ct,
5640
+ module: fi,
5399
5641
  entryPoint: "vs",
5400
5642
  buffers: [{ arrayStride: 28, attributes: [
5401
5643
  { shaderLocation: 0, offset: 0, format: "float32x3" },
@@ -5403,7 +5645,7 @@ async function vr(s, t = {}) {
5403
5645
  ] }]
5404
5646
  },
5405
5647
  fragment: {
5406
- module: Ct,
5648
+ module: fi,
5407
5649
  entryPoint: "fs",
5408
5650
  targets: [{ format: "rgba16float", blend: {
5409
5651
  // renders into the HDR sceneTexture
@@ -5415,23 +5657,182 @@ async function vr(s, t = {}) {
5415
5657
  // depth24plus to match the non-bloom pass; test against the resolved scene depth
5416
5658
  // (occlusion) but don't write (transparent ribbon).
5417
5659
  depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
5418
- }), It = 512 * 64 * 6, le = new Float32Array(It * 7), zt = r.createBuffer({
5419
- size: It * 7 * 4,
5660
+ }), hi = 512 * 64 * 6, Ye = new Float32Array(hi * 7), qt = r.createBuffer({
5661
+ size: hi * 7 * 4,
5420
5662
  usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
5421
5663
  label: "ribbonBuffer"
5422
- }), Li = r.createBindGroup({
5423
- layout: Ut,
5424
- entries: [{ binding: 0, resource: { buffer: b } }]
5664
+ }), gs = r.createBindGroup({
5665
+ layout: pi,
5666
+ entries: [{ binding: 0, resource: { buffer: v } }]
5667
+ });
5668
+ let vt = 0;
5669
+ const mi = r.createShaderModule({ code: `
5670
+ struct Uniforms {
5671
+ transform: mat4x4<f32>,
5672
+ cameraPosition: vec3<f32>,
5673
+ aspectRatio: f32,
5674
+ elapsedTime: f32,
5675
+ }
5676
+
5677
+ struct AppearanceUniforms {
5678
+ fadeEnabled: f32,
5679
+ colorTransitionEnabled: f32,
5680
+ particleSize: f32,
5681
+ textureEnabled: f32,
5682
+ singleColor: vec3<f32>,
5683
+ rotation: f32,
5684
+ startColor: vec3<f32>,
5685
+ rotationMode: f32,
5686
+ endColor: vec3<f32>,
5687
+ minRotation: f32,
5688
+ maxRotation: f32,
5689
+ aspectRatio: f32,
5690
+ randomSize: f32,
5691
+ minSize: f32,
5692
+ maxSize: f32,
5693
+ fadeSizeEnabled: f32,
5694
+ opacity: f32,
5695
+ increaseSizeEnabled: f32,
5696
+ sizeLifetimeSpeed: f32,
5697
+ particleShape: f32,
5698
+ particleShapeRotation: f32,
5699
+ pulseEnabled: f32,
5700
+ pulseAmplitude: f32,
5701
+ pulseFrequency: f32,
5702
+ pulsePhaseRandom: f32,
5703
+ pulseOpacity: f32,
5704
+ glbRotationX: f32,
5705
+ glbRotationY: f32,
5706
+ glbRotationZ: f32,
5707
+ _pad0: f32,
5708
+ systemOffset: vec3<f32>,
5709
+ _pad1: f32,
5710
+ simRotX: f32,
5711
+ simRotZ: f32,
5712
+ velocityStretchEnabled: f32,
5713
+ velocityStretchFactor: f32,
5714
+ noiseDistortEnabled: f32,
5715
+ noiseTilingX: f32,
5716
+ noiseTilingY: f32,
5717
+ noiseSpeed: f32,
5718
+ noiseAmplitude: f32,
5719
+ systemVelX: f32,
5720
+ systemVelY: f32,
5721
+ systemVelZ: f32,
5722
+ orientX: f32,
5723
+ orientY: f32,
5724
+ orientZ: f32,
5725
+ _pad2: f32,
5726
+ }
5727
+
5728
+ @group(0) @binding(0) var<uniform> uniforms : Uniforms;
5729
+ @group(0) @binding(1) var<uniform> appearance : AppearanceUniforms;
5730
+ @group(0) @binding(2) var particleTexture: texture_2d<f32>;
5731
+ @group(0) @binding(3) var particleSampler: sampler;
5732
+
5733
+ struct VIn {
5734
+ @location(0) pos: vec3<f32>,
5735
+ @location(1) col: vec4<f32>,
5736
+ @location(2) uv: vec2<f32>,
5737
+ };
5738
+
5739
+ struct VOut {
5740
+ @builtin(position) pos: vec4<f32>,
5741
+ @location(0) col: vec3<f32>,
5742
+ @location(1) alpha: f32,
5743
+ @location(2) uv: vec2<f32>,
5744
+ @location(3) noiseOffset: vec2<f32>,
5745
+ };
5746
+
5747
+ fn hash21(p: vec2<f32>) -> f32 {
5748
+ return fract(sin(dot(p, vec2<f32>(127.1, 311.7))) * 43758.5453);
5749
+ }
5750
+
5751
+ fn valueNoise(p: vec2<f32>) -> f32 {
5752
+ let i = floor(p);
5753
+ let f = fract(p);
5754
+ let u = f * f * (3.0 - 2.0 * f);
5755
+ let a = hash21(i);
5756
+ let b = hash21(i + vec2<f32>(1.0, 0.0));
5757
+ let c = hash21(i + vec2<f32>(0.0, 1.0));
5758
+ let d = hash21(i + vec2<f32>(1.0, 1.0));
5759
+ return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
5760
+ }
5761
+
5762
+ @vertex
5763
+ fn vs(v: VIn) -> VOut {
5764
+ var o: VOut;
5765
+ o.pos = uniforms.transform * vec4<f32>(v.pos, 1.0);
5766
+ o.col = v.col.rgb;
5767
+ o.alpha = v.col.a;
5768
+ o.uv = v.uv;
5769
+ o.noiseOffset = vec2<f32>(
5770
+ uniforms.elapsedTime * appearance.noiseSpeed,
5771
+ uniforms.elapsedTime * appearance.noiseSpeed * 0.5
5772
+ );
5773
+ return o;
5774
+ }
5775
+
5776
+ @fragment
5777
+ fn fs(i: VOut) -> @location(0) vec4<f32> {
5778
+ let baseUV = vec2<f32>(fract(i.uv.x), clamp(i.uv.y, 0.001, 0.999));
5779
+ var sampleUV = baseUV;
5780
+ if (appearance.textureEnabled > 0.5) {
5781
+ if (appearance.noiseDistortEnabled > 0.5) {
5782
+ let nUV = baseUV * vec2<f32>(
5783
+ max(appearance.noiseTilingX, 0.0001),
5784
+ max(appearance.noiseTilingY, 0.0001)
5785
+ ) + i.noiseOffset;
5786
+ let n1 = valueNoise(nUV) - 0.5;
5787
+ let n2 = valueNoise(nUV + vec2<f32>(13.7, 7.3)) - 0.5;
5788
+ sampleUV = vec2<f32>(
5789
+ fract(sampleUV.x + n1 * appearance.noiseAmplitude),
5790
+ clamp(sampleUV.y + n2 * appearance.noiseAmplitude, 0.001, 0.999)
5791
+ );
5792
+ }
5793
+ let texColor = textureSample(particleTexture, particleSampler, sampleUV);
5794
+ return vec4<f32>(i.col * texColor.rgb, i.alpha * texColor.a);
5795
+ }
5796
+ return vec4<f32>(i.col, i.alpha);
5797
+ }
5798
+ ` }), yi = (u) => r.createRenderPipeline({
5799
+ layout: r.createPipelineLayout({ bindGroupLayouts: [Ne.particleBindGroupLayout] }),
5800
+ vertex: {
5801
+ module: mi,
5802
+ entryPoint: "vs",
5803
+ buffers: [{ arrayStride: 36, attributes: [
5804
+ { shaderLocation: 0, offset: 0, format: "float32x3" },
5805
+ { shaderLocation: 1, offset: 12, format: "float32x4" },
5806
+ { shaderLocation: 2, offset: 28, format: "float32x2" }
5807
+ ] }]
5808
+ },
5809
+ fragment: {
5810
+ module: mi,
5811
+ entryPoint: "fs",
5812
+ targets: [{ format: "rgba16float", blend: u }]
5813
+ },
5814
+ primitive: { topology: "triangle-list" },
5815
+ depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
5816
+ }), bs = yi({
5817
+ color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
5818
+ alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
5819
+ }), Ss = yi({
5820
+ color: { srcFactor: "src-alpha", dstFactor: "one", operation: "add" },
5821
+ alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
5822
+ }), gi = 256 * 256 * 6, Ce = new Float32Array(gi * 9), Zt = r.createBuffer({
5823
+ size: gi * 9 * 4,
5824
+ usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
5825
+ label: "shapeStrokeBuffer"
5425
5826
  });
5426
- let De = 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;
5427
- const Ft = () => {
5428
- const f = (m) => m.createView();
5429
- Te = f(be), Gt = f(Se), Qe = f(xe), Ve = f(Je);
5827
+ let bi = 0, { sceneTexture: at, bloomTexA: ot, bloomTexB: lt } = Xi(r, c, a.width, a.height), zt = Ni(r, a.width, a.height), ht, Si, Ft, Pt;
5828
+ const xi = () => {
5829
+ const u = (f) => f.createView();
5830
+ ht = u(at), Si = u(ot), Ft = u(lt), Pt = u(zt);
5430
5831
  };
5431
- Ft();
5432
- const ut = { uniformBuffer: b, appearanceUniformBuffer: _, horizontalBlurUniformBuffer: M, verticalBlurUniformBuffer: R, bloomIntensityBuffer: x };
5433
- let Ke = Pt(r, se, ut, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe });
5434
- const C = {
5832
+ xi();
5833
+ const Ht = { uniformBuffer: v, appearanceUniformBuffer: E, horizontalBlurUniformBuffer: I, verticalBlurUniformBuffer: z, bloomIntensityBuffer: _ };
5834
+ let Gt = si(r, De, Ht, { sceneTexture: at, bloomTexA: ot, bloomTexB: lt });
5835
+ const D = {
5435
5836
  mvp: new Float32Array(16),
5436
5837
  position: new Float32Array([0, 0, 10]),
5437
5838
  right: new Float32Array([1, 0, 0]),
@@ -5439,187 +5840,189 @@ async function vr(s, t = {}) {
5439
5840
  up: new Float32Array([0, 1, 0]),
5440
5841
  hasCamera: !1
5441
5842
  };
5442
- let he = 0, Xi = 0;
5443
- const Ee = new Float32Array(5), Dt = new Float32Array(16), Ni = new Array(65), ki = new Array(65), ji = new Array(65), Yi = new Array(65), qi = new Array(65), Hi = new Array(65), Vt = [0, 0, 0], Ae = { key: null, ms: !1, bindGroup: null };
5444
- let Ot = !1, dt = !0, et = !1, tt = null, ft = a.width, ht = a.height;
5445
- function Lt() {
5446
- const f = [be, Se, xe, Je], m = yi(r, c, a.width, a.height);
5447
- be = m.sceneTexture, Se = m.bloomTexA, xe = m.bloomTexB, Je = gi(r, a.width, a.height), Ft(), Tt(), d.clear(), h.resizeTextures(), Ke = Pt(r, se, ut, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe });
5448
- let S = !1;
5843
+ let Ve = 0, xs = 0;
5844
+ const mt = new Float32Array(5), vi = new Float32Array(16), vs = new Array(65), Ps = new Array(65), _s = new Array(65), Ms = new Array(65), ws = new Array(65), Bs = new Array(65), Pi = [0, 0, 0], yt = { key: null, ms: !1, bindGroup: null };
5845
+ let _i = !1, Wt = !0, Dt = !1, Vt = null, $t = a.width, Jt = a.height;
5846
+ function Mi() {
5847
+ const u = [at, ot, lt, zt], f = Xi(r, c, a.width, a.height);
5848
+ at = f.sceneTexture, ot = f.bloomTexA, lt = f.bloomTexB, zt = Ni(r, a.width, a.height), xi(), ci(), p.clear(), b.resizeTextures(), Gt = si(r, De, Ht, { sceneTexture: at, bloomTexA: ot, bloomTexB: lt });
5849
+ let m = !1;
5449
5850
  const g = () => {
5450
- if (!S) {
5451
- S = !0, requestAnimationFrame(g);
5851
+ if (!m) {
5852
+ m = !0, requestAnimationFrame(g);
5452
5853
  return;
5453
5854
  }
5454
- f.forEach((v) => v.destroy());
5855
+ u.forEach((y) => y.destroy());
5455
5856
  };
5456
5857
  requestAnimationFrame(g);
5457
5858
  }
5458
- function Zi(f, m, S) {
5459
- C.mvp.set(ar(f, m)), m && m.length >= 10 && (C.right[0] = m[0], C.right[1] = m[4], C.right[2] = m[8], C.up[0] = m[1], C.up[1] = m[5], C.up[2] = m[9]), S && (C.position[0] = S.x ?? S[0], C.position[1] = S.y ?? S[1], C.position[2] = S.z ?? S[2]), C.hasCamera = !0;
5859
+ function Rs(u, f, m) {
5860
+ D.mvp.set(Fr(u, f)), f && f.length >= 10 && (D.right[0] = f[0], D.right[1] = f[4], D.right[2] = f[8], D.up[0] = f[1], D.up[1] = f[5], D.up[2] = f[9]), m && (D.position[0] = m.x ?? m[0], D.position[1] = m.y ?? m[1], D.position[2] = m.z ?? m[2]), D.hasCamera = !0;
5460
5861
  }
5461
- function $i(f, m) {
5462
- C.mvp.set(f), m && (C.position[0] = m.x ?? m[0], C.position[1] = m.y ?? m[1], C.position[2] = m.z ?? m[2]), C.hasCamera = !0;
5862
+ function Ts(u, f) {
5863
+ D.mvp.set(u), f && (D.position[0] = f.x ?? f[0], D.position[1] = f.y ?? f[1], D.position[2] = f.z ?? f[2]), D.hasCamera = !0;
5463
5864
  }
5464
- async function pt(f) {
5465
- if (et) {
5466
- tt = f;
5865
+ async function Kt(u) {
5866
+ if (Dt) {
5867
+ Vt = u;
5467
5868
  return;
5468
5869
  }
5469
- et = !0;
5870
+ Dt = !0;
5470
5871
  try {
5471
- for (const m in P) delete P[m];
5472
- d.clear(), h.resizeTextures(), Ke = Pt(r, se, ut, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe }), await l.replaceSystems({ systems: [], activeSystemIndex: 0 });
5473
- for (const m of f)
5474
- await l.addSystems(m.preset, m.position || [0, 0, 0]);
5475
- for (const { config: m } of l.particleSystems)
5476
- P[m.id] || (P[m.id] = T());
5477
- dt = !0, l.respawnAllSystems();
5872
+ for (const f in T) delete T[f];
5873
+ p.clear(), b.resizeTextures(), Gt = si(r, De, Ht, { sceneTexture: at, bloomTexA: ot, bloomTexB: lt }), await l.replaceSystems({ systems: [], activeSystemIndex: 0 });
5874
+ for (const f of u)
5875
+ await l.addSystems(f.preset, f.position || [0, 0, 0]);
5876
+ for (const { config: f } of l.particleSystems)
5877
+ T[f.id] || (T[f.id] = F());
5878
+ Wt = !0, l.respawnAllSystems();
5478
5879
  } finally {
5479
- if (et = !1, tt) {
5480
- const m = tt;
5481
- tt = null, pt(m);
5880
+ if (Dt = !1, Vt) {
5881
+ const f = Vt;
5882
+ Vt = null, Kt(f);
5482
5883
  }
5483
5884
  }
5484
5885
  }
5485
- async function Wi(f, m = [0, 0, 0]) {
5486
- return pt([{ preset: f, position: m }]);
5487
- }
5488
- function Ji(f) {
5489
- if (Ot || et || !l.ready || f <= 0 || l.particleSystems.length === 0) return;
5490
- const m = l.clock;
5491
- if (m && (m.loop = l.loop ?? i, m.duration = l.getTotalDuration(), f = m.tick(f)), f > 0.1 && (f = 0.1), f <= 0) return;
5492
- if ((a.width !== ft || a.height !== ht) && (ft = a.width, ht = a.height, Lt()), he += f, W.length) {
5493
- for (const y of W) {
5494
- if (y.getPosition) {
5495
- const B = y.getPosition();
5496
- 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;
5886
+ async function As(u, f = [0, 0, 0]) {
5887
+ return Kt([{ preset: u, position: f }]);
5888
+ }
5889
+ function Es(u) {
5890
+ if (_i || Dt || !l.ready || u <= 0 || l.particleSystems.length === 0) return;
5891
+ const f = l.clock;
5892
+ if (f && (f.loop = l.loop ?? i, f.duration = l.getTotalDuration(), u = f.tick(u)), u > 0.1 && (u = 0.1), u <= 0) return;
5893
+ if ((a.width !== $t || a.height !== Jt) && ($t = a.width, Jt = a.height, Mi()), Ve += u, _e.length) {
5894
+ for (const h of _e) {
5895
+ if (h.getPosition) {
5896
+ const w = h.getPosition();
5897
+ w ? (h.pos || (h.pos = h._posBuf), Array.isArray(w) ? (h.pos[0] = w[0], h.pos[1] = w[1], h.pos[2] = w[2]) : (h.pos[0] = w.x, h.pos[1] = w.y, h.pos[2] = w.z)) : h.pos = null;
5497
5898
  }
5498
- 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);
5899
+ h.vel = h._velBuf, h.pos && h.prevPos && h.wasActive && u > 0 ? (h.vel[0] = (h.pos[0] - h.prevPos[0]) / u, h.vel[1] = (h.pos[1] - h.prevPos[1]) / u, h.vel[2] = (h.pos[2] - h.prevPos[2]) / u) : (h.vel[0] = 0, h.vel[1] = 0, h.vel[2] = 0), h.justResumed = !!h.pos && !h.wasActive, h.justResumed && (h.hist.length = 0);
5499
5900
  }
5500
- for (const { system: y, config: B } of l.particleSystems) {
5501
- const U = Mt(B.id);
5502
- if (!(!U || U.historyOnly) && (B.hidden = !U.pos, U.pos)) {
5503
- let I = null;
5504
- if (U.orientToDirection && U.vel) {
5505
- const F = U.vel[0], J = U.vel[2];
5506
- Math.hypot(F, J) > 1e-4 && (I = [0, 0, Math.atan2(F, J)]);
5901
+ for (const { system: h, config: w } of l.particleSystems) {
5902
+ const C = oi(w.id);
5903
+ if (!(!C || C.historyOnly) && (w.hidden = !C.pos, C.pos)) {
5904
+ let Z = null;
5905
+ if (C.orientToDirection && C.vel) {
5906
+ const O = C.vel[0], L = C.vel[2];
5907
+ Math.hypot(O, L) > 1e-4 && (Z = [0, 0, Math.atan2(O, L)]);
5507
5908
  }
5508
- y.setSimulationTransform({ position: U.pos, velocity: U.vel, rotation: I }), y.updateAppearanceUniform(), (U.justResumed || y.activeParticles === 0) && y.spawnParticles();
5909
+ h.setSimulationTransform({ position: C.pos, velocity: C.vel, rotation: Z }), h.updateAppearanceUniform(), (C.justResumed || h.activeParticles === 0) && h.spawnParticles();
5509
5910
  }
5510
5911
  }
5511
- for (const y of W)
5512
- y.pos ? Ai(y, he) : 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;
5513
- if (globalThis.__HZFX_DEBUG && (Xi++ & 63) === 0) {
5514
- const y = l.particleSystems.reduce((F, J) => F + (J.system.activeParticles | 0), 0), B = W.find((F) => F.pos), U = B ? Math.hypot(C.position[0] - B.pos[0], C.position[1] - B.pos[1], C.position[2] - B.pos[2]).toFixed(1) : "-", I = W.map((F) => `{ids:[${[...F.ids]}],pos:${F.pos ? "1" : "0"},hist:${F.hist.length}}`).join(",");
5515
- console.info(`[HZFX] movingGroups(${W.length})=[${I}] activeParticles=${y} systems=${l.particleSystems.length} ribbonVerts=${De} camDist=${U} t=${he.toFixed(1)}`);
5912
+ for (const h of _e)
5913
+ h.pos ? is(h, Ve) : h.hist.length = 0, h.pos ? (h._prevPosBuf[0] = h.pos[0], h._prevPosBuf[1] = h.pos[1], h._prevPosBuf[2] = h.pos[2], h.prevPos = h._prevPosBuf) : h.prevPos = null, h.wasActive = !!h.pos;
5914
+ if (globalThis.__HZFX_DEBUG && (xs++ & 63) === 0) {
5915
+ const h = l.particleSystems.reduce((O, L) => O + (L.system.activeParticles | 0), 0), w = _e.find((O) => O.pos), C = w ? Math.hypot(D.position[0] - w.pos[0], D.position[1] - w.pos[1], D.position[2] - w.pos[2]).toFixed(1) : "-", Z = _e.map((O) => `{ids:[${[...O.ids]}],pos:${O.pos ? "1" : "0"},hist:${O.hist.length}}`).join(",");
5916
+ console.info(`[HZFX] movingGroups(${_e.length})=[${Z}] activeParticles=${h} systems=${l.particleSystems.length} ribbonVerts=${vt} camDist=${C} t=${Ve.toFixed(1)}`);
5516
5917
  }
5517
5918
  }
5518
- if (l.updateAllSystems(f), m ? m.loop : l.loop ?? i) {
5519
- const y = l.particleSystems.length > 0 && l.particleSystems.every(({ system: B }) => B.activeParticles === 0 && !B.emitting);
5520
- (m && m.justLooped || y && dt) && l.respawnAllSystems(), dt = !y;
5919
+ if (l.updateAllSystems(u), f ? f.loop : l.loop ?? i) {
5920
+ const h = l.particleSystems.length > 0 && l.particleSystems.every(({ system: w }) => w.activeParticles === 0 && !w.emitting);
5921
+ (f && f.justLooped || h && Wt) && l.respawnAllSystems(), Wt = !h;
5521
5922
  }
5522
- for (const { system: y, config: B } of l.particleSystems)
5523
- B.glbModelEnabled && y.glbAnimator && (y.glbAnimator.update(f), y.updateAnimatedGLBBuffer());
5524
- r.queue.writeBuffer(b, 0, C.mvp), Ee[0] = C.position[0], Ee[1] = C.position[1], Ee[2] = C.position[2], Ee[3] = a.height / Math.max(1, a.width), Ee[4] = he, r.queue.writeBuffer(b, 64, Ee), Ui();
5525
- const g = l.particleSystems.some(({ config: y }) => y.bloomEnabled), v = r.createCommandEncoder();
5526
- let q = !1;
5923
+ for (const { system: h, config: w } of l.particleSystems)
5924
+ w.glbModelEnabled && h.glbAnimator && (h.glbAnimator.update(u), h.updateAnimatedGLBBuffer());
5925
+ r.queue.writeBuffer(v, 0, D.mvp), mt[0] = D.position[0], mt[1] = D.position[1], mt[2] = D.position[2], mt[3] = a.height / Math.max(1, a.width), mt[4] = Ve, r.queue.writeBuffer(v, 64, mt), cs();
5926
+ const g = l.particleSystems.some(
5927
+ ({ system: h, config: w }) => w.bloomEnabled && !w.hidden && (h.activeParticles > 0 || Xe.has(w.id))
5928
+ ), y = r.createCommandEncoder();
5929
+ let R = !1;
5527
5930
  if (e)
5528
5931
  try {
5529
- const y = e();
5530
- if (y) {
5531
- let B = null, U = null, I = !1;
5532
- 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) {
5533
- const { pipeline: F, layout: J } = p(I);
5534
- (Ae.key !== B || Ae.ms !== I) && (Ae.key = B, Ae.ms = I, Ae.bindGroup = r.createBindGroup({
5535
- layout: J,
5536
- entries: [{ binding: 0, resource: U() }]
5932
+ const h = e();
5933
+ if (h) {
5934
+ let w = null, C = null, Z = !1;
5935
+ if (h instanceof GPUTexture ? h.width === a.width && h.height === a.height && (w = h, C = () => h.createView({ aspect: "depth-only" }), Z = h.sampleCount > 1) : h.view && (w = h.view, C = () => h.view, Z = !!h.multisampled), w) {
5936
+ const { pipeline: O, layout: L } = S(Z);
5937
+ (yt.key !== w || yt.ms !== Z) && (yt.key = w, yt.ms = Z, yt.bindGroup = r.createBindGroup({
5938
+ layout: L,
5939
+ entries: [{ binding: 0, resource: C() }]
5537
5940
  }));
5538
- const K = v.beginRenderPass({
5941
+ const N = y.beginRenderPass({
5539
5942
  colorAttachments: [],
5540
- depthStencilAttachment: { view: Ve, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5943
+ depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5541
5944
  });
5542
- K.setPipeline(F), K.setBindGroup(0, Ae.bindGroup), K.draw(3), K.end(), q = !0;
5945
+ N.setPipeline(O), N.setBindGroup(0, yt.bindGroup), N.draw(3), N.end(), R = !0;
5543
5946
  }
5544
5947
  }
5545
5948
  } catch {
5546
5949
  }
5547
- const j = v.beginRenderPass({
5548
- colorAttachments: [{ view: Te, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
5549
- depthStencilAttachment: q ? { view: Ve, depthLoadOp: "load", depthStoreOp: "store" } : { view: Ve, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5950
+ const P = y.beginRenderPass({
5951
+ colorAttachments: [{ view: ht, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
5952
+ depthStencilAttachment: R ? { view: Pt, depthLoadOp: "load", depthStoreOp: "store" } : { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
5550
5953
  });
5551
- for (const { system: y, config: B } of l.particleSystems)
5552
- B.bloomEnabled || B.hidden || y.activeParticles === 0 || Xt(j, y, B);
5553
- if (De > 0 && (j.setPipeline(Oi), j.setBindGroup(0, Li), j.setVertexBuffer(0, zt), j.draw(De)), j.end(), g) {
5554
- const y = {
5555
- colorAttachments: [{ view: Gt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5556
- }, B = {
5557
- colorAttachments: [{ view: Qe, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5954
+ for (const { system: h, config: w } of l.particleSystems)
5955
+ w.bloomEnabled || w.hidden || h.activeParticles === 0 && !Xe.has(w.id) || (Bi(P, h, w), Ri(P, h, w));
5956
+ if (vt > 0 && (P.setPipeline(ys), P.setBindGroup(0, gs), P.setVertexBuffer(0, qt), P.draw(vt)), P.end(), g) {
5957
+ const h = {
5958
+ colorAttachments: [{ view: Si, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5959
+ }, w = {
5960
+ colorAttachments: [{ view: Ft, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5558
5961
  };
5559
- for (const { system: U, config: I } of l.particleSystems) {
5560
- if (!I.bloomEnabled || I.hidden || U.activeParticles === 0) continue;
5561
- const F = U.config.id, J = h.getBloomSourceTexture(F, a.width, a.height), K = v.beginRenderPass({
5562
- colorAttachments: [{ view: J.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
5563
- depthStencilAttachment: { view: Ve, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
5962
+ for (const { system: C, config: Z } of l.particleSystems) {
5963
+ if (!Z.bloomEnabled || Z.hidden || C.activeParticles === 0 && !Xe.has(Z.id)) continue;
5964
+ const O = C.config.id, L = b.getBloomSourceTexture(O, a.width, a.height), N = y.beginRenderPass({
5965
+ colorAttachments: [{ view: L.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
5966
+ depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
5564
5967
  });
5565
- Xt(K, U, I), K.end(), Dt[0] = I.bloomIntensity, r.queue.writeBuffer(x, 0, Dt), d.systemBloomHorizontalBindGroups[F] || (d.systemBloomHorizontalBindGroups[F] = r.createBindGroup({
5566
- layout: fe.bloomBindGroupLayout,
5968
+ Bi(N, C, Z), Ri(N, C, Z), N.end(), vi[0] = Z.bloomIntensity, r.queue.writeBuffer(_, 0, vi), p.systemBloomHorizontalBindGroups[O] || (p.systemBloomHorizontalBindGroups[O] = r.createBindGroup({
5969
+ layout: Ne.bloomBindGroupLayout,
5567
5970
  entries: [
5568
- { binding: 0, resource: se },
5569
- { binding: 1, resource: J.createView() },
5570
- { binding: 2, resource: { buffer: M } }
5971
+ { binding: 0, resource: De },
5972
+ { binding: 1, resource: L.createView() },
5973
+ { binding: 2, resource: { buffer: I } }
5571
5974
  ]
5572
5975
  }));
5573
- let X = v.beginRenderPass(y);
5574
- X.setPipeline(We), X.setBindGroup(0, d.systemBloomHorizontalBindGroups[F]), X.draw(3), X.end(), X = v.beginRenderPass(B), X.setPipeline(We), X.setBindGroup(0, Ke.verticalBlurBindGroup), X.draw(3), X.end(), d.secondHorizontalBindGroups[F] || (d.secondHorizontalBindGroups[F] = r.createBindGroup({
5575
- layout: fe.bloomBindGroupLayout,
5976
+ let V = y.beginRenderPass(h);
5977
+ V.setPipeline(It), V.setBindGroup(0, p.systemBloomHorizontalBindGroups[O]), V.draw(3), V.end(), V = y.beginRenderPass(w), V.setPipeline(It), V.setBindGroup(0, Gt.verticalBlurBindGroup), V.draw(3), V.end(), p.secondHorizontalBindGroups[O] || (p.secondHorizontalBindGroups[O] = r.createBindGroup({
5978
+ layout: Ne.bloomBindGroupLayout,
5576
5979
  entries: [
5577
- { binding: 0, resource: se },
5578
- { binding: 1, resource: Qe },
5579
- { binding: 2, resource: { buffer: M } }
5980
+ { binding: 0, resource: De },
5981
+ { binding: 1, resource: Ft },
5982
+ { binding: 2, resource: { buffer: I } }
5580
5983
  ]
5581
- })), X = v.beginRenderPass(y), X.setPipeline(We), X.setBindGroup(0, d.secondHorizontalBindGroups[F]), X.draw(3), X.end(), X = v.beginRenderPass(B), X.setPipeline(We), X.setBindGroup(0, Ke.verticalBlurBindGroup), X.draw(3), X.end();
5582
- const it = h.getBloomCompositeTexture(F, a.width, a.height);
5583
- X = v.beginRenderPass({
5584
- colorAttachments: [{ view: it.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5585
- }), X.setPipeline(Fi), d.systemBloomCompositeBindGroups[F] || (d.systemBloomCompositeBindGroups[F] = r.createBindGroup({
5586
- layout: fe.compositeBindGroupLayout,
5984
+ })), V = y.beginRenderPass(h), V.setPipeline(It), V.setBindGroup(0, p.secondHorizontalBindGroups[O]), V.draw(3), V.end(), V = y.beginRenderPass(w), V.setPipeline(It), V.setBindGroup(0, Gt.verticalBlurBindGroup), V.draw(3), V.end();
5985
+ const xe = b.getBloomCompositeTexture(O, a.width, a.height);
5986
+ V = y.beginRenderPass({
5987
+ colorAttachments: [{ view: xe.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5988
+ }), V.setPipeline(ps), p.systemBloomCompositeBindGroups[O] || (p.systemBloomCompositeBindGroups[O] = r.createBindGroup({
5989
+ layout: Ne.compositeBindGroupLayout,
5587
5990
  entries: [
5588
- { binding: 0, resource: se },
5589
- { binding: 1, resource: J.createView() },
5590
- { binding: 2, resource: Qe },
5591
- { binding: 3, resource: { buffer: U.bloomIntensityBuffer } }
5991
+ { binding: 0, resource: De },
5992
+ { binding: 1, resource: L.createView() },
5993
+ { binding: 2, resource: Ft },
5994
+ { binding: 3, resource: { buffer: C.bloomIntensityBuffer } }
5592
5995
  ]
5593
- })), X.setBindGroup(0, d.systemBloomCompositeBindGroups[F]), X.draw(3), X.end();
5996
+ })), V.setBindGroup(0, p.systemBloomCompositeBindGroups[O]), V.draw(3), V.end();
5594
5997
  }
5595
5998
  }
5596
- const Q = h.getCombinedTexture(a.width, a.height), Z = v.beginRenderPass({
5597
- colorAttachments: [{ view: Q.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5999
+ const M = b.getCombinedTexture(a.width, a.height), x = y.beginRenderPass({
6000
+ colorAttachments: [{ view: M.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
5598
6001
  });
5599
- Z.setPipeline(At), d.combinedInitialBindGroup || (d.combinedInitialBindGroup = r.createBindGroup({
5600
- layout: fe.compositeBindGroupLayout,
6002
+ x.setPipeline(di), p.combinedInitialBindGroup || (p.combinedInitialBindGroup = r.createBindGroup({
6003
+ layout: Ne.compositeBindGroupLayout,
5601
6004
  entries: [
5602
- { binding: 0, resource: se },
5603
- { binding: 1, resource: Te },
5604
- { binding: 2, resource: Te },
5605
- { binding: 3, resource: { buffer: x } }
6005
+ { binding: 0, resource: De },
6006
+ { binding: 1, resource: ht },
6007
+ { binding: 2, resource: ht },
6008
+ { binding: 3, resource: { buffer: _ } }
5606
6009
  ]
5607
- })), Z.setBindGroup(0, d.combinedInitialBindGroup), Z.draw(3);
5608
- for (const { config: y, system: B } of l.particleSystems) {
5609
- if (!y.bloomEnabled || y.hidden || B.activeParticles === 0) continue;
5610
- const U = B.config.id;
5611
- Z.setPipeline(At), d.combinedBloomCompositeBindGroups[U] || (d.combinedBloomCompositeBindGroups[U] = r.createBindGroup({
5612
- layout: fe.compositeBindGroupLayout,
6010
+ })), x.setBindGroup(0, p.combinedInitialBindGroup), x.draw(3);
6011
+ for (const { config: h, system: w } of l.particleSystems) {
6012
+ if (!h.bloomEnabled || h.hidden || w.activeParticles === 0 && !Xe.has(h.id)) continue;
6013
+ const C = w.config.id;
6014
+ x.setPipeline(di), p.combinedBloomCompositeBindGroups[C] || (p.combinedBloomCompositeBindGroups[C] = r.createBindGroup({
6015
+ layout: Ne.compositeBindGroupLayout,
5613
6016
  entries: [
5614
- { binding: 0, resource: se },
5615
- { binding: 1, resource: h.getBloomCompositeTexture(U, a.width, a.height).createView() },
5616
- { binding: 2, resource: Te },
5617
- { binding: 3, resource: { buffer: x } }
6017
+ { binding: 0, resource: De },
6018
+ { binding: 1, resource: b.getBloomCompositeTexture(C, a.width, a.height).createView() },
6019
+ { binding: 2, resource: ht },
6020
+ { binding: 3, resource: { buffer: _ } }
5618
6021
  ]
5619
- })), Z.setBindGroup(0, d.combinedBloomCompositeBindGroups[U]), Z.draw(3);
6022
+ })), x.setBindGroup(0, p.combinedBloomCompositeBindGroups[C]), x.draw(3);
5620
6023
  }
5621
- Z.end();
5622
- const Ce = v.beginRenderPass({
6024
+ x.end();
6025
+ const B = y.beginRenderPass({
5623
6026
  colorAttachments: [{
5624
6027
  view: n.getCurrentTexture().createView(),
5625
6028
  loadOp: o ? "load" : "clear",
@@ -5627,104 +6030,112 @@ async function vr(s, t = {}) {
5627
6030
  clearValue: { r: 0, g: 0, b: 0, a: 0 }
5628
6031
  }]
5629
6032
  });
5630
- Ce.setPipeline(Di), d.finalBindGroup || (d.finalBindGroup = r.createBindGroup({
5631
- layout: fe.compositeBindGroupLayout,
6033
+ B.setPipeline(hs), p.finalBindGroup || (p.finalBindGroup = r.createBindGroup({
6034
+ layout: Ne.compositeBindGroupLayout,
5632
6035
  entries: [
5633
- { binding: 0, resource: se },
5634
- { binding: 1, resource: Q.createView() },
5635
- { binding: 2, resource: Te },
5636
- { binding: 3, resource: { buffer: x } }
6036
+ { binding: 0, resource: De },
6037
+ { binding: 1, resource: M.createView() },
6038
+ { binding: 2, resource: ht },
6039
+ { binding: 3, resource: { buffer: _ } }
5637
6040
  ]
5638
- })), Ce.setBindGroup(0, d.finalBindGroup), Ce.draw(3), Ce.end(), r.queue.submit([v.finish()]);
6041
+ })), B.setBindGroup(0, p.finalBindGroup), B.draw(3), B.end(), r.queue.submit([y.finish()]);
5639
6042
  }
5640
- function Xt(f, m, S) {
5641
- const g = m.config.id, v = S.glbModelEnabled && m.glbMeshData, q = !d.systemBindGroups[g] || d.textureStates[g] !== S.textureEnabled || d.textureRefs[g] !== m.particleTexture;
5642
- d.textureStates[g] = S.textureEnabled, d.textureRefs[g] = m.particleTexture, q && (d.systemBindGroups[g] = r.createBindGroup({
5643
- layout: fe.particleBindGroupLayout,
6043
+ function wi(u, f) {
6044
+ const m = u.config.id, g = !p.systemBindGroups[m] || p.textureStates[m] !== f.textureEnabled || p.textureRefs[m] !== u.particleTexture;
6045
+ return p.textureStates[m] = f.textureEnabled, p.textureRefs[m] = u.particleTexture, g && (p.systemBindGroups[m] = r.createBindGroup({
6046
+ layout: Ne.particleBindGroupLayout,
5644
6047
  entries: [
5645
- { binding: 0, resource: { buffer: b } },
5646
- { binding: 1, resource: { buffer: m.appearanceUniformBuffer } },
5647
- { binding: 2, resource: m.particleTexture.createView() },
5648
- { binding: 3, resource: se }
6048
+ { binding: 0, resource: { buffer: v } },
6049
+ { binding: 1, resource: { buffer: u.appearanceUniformBuffer } },
6050
+ { binding: 2, resource: u.particleTexture.createView() },
6051
+ { binding: 3, resource: De }
5649
6052
  ]
5650
- }));
5651
- const j = d.systemBindGroups[g], Q = S.shapeDisplay !== !1;
5652
- if (v)
5653
- Q && (f.setPipeline(Vi), 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));
6053
+ })), p.systemBindGroups[m];
6054
+ }
6055
+ function Bi(u, f, m) {
6056
+ const g = f.config.id, y = m.glbModelEnabled && f.glbMeshData, R = wi(f, m), P = m.shapeDisplay !== !1;
6057
+ if (y)
6058
+ P && (u.setPipeline(ms), u.setBindGroup(0, R), u.setVertexBuffer(0, f.glbVertexBuffer), u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setIndexBuffer(f.glbIndexBuffer, f.glbIndexFormat), u.drawIndexed(f.glbIndexCount, f.activeParticles));
5654
6059
  else {
5655
- 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, m.instanceBuffer), f.setVertexBuffer(2, m.velocityBuffer), f.setVertexBuffer(3, m.trailBuffer), f.drawIndexed(6, m.activeParticles));
5656
- const Z = Fe.get(g);
5657
- Z && (f.setVertexBuffer(1, k), 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, m.activeParticles));
6060
+ u.setPipeline(m.blendMode === "additive" ? ds : us), u.setIndexBuffer(W, "uint16"), T[g] || (T[g] = F()), u.setVertexBuffer(0, T[g]), u.setBindGroup(0, R), P && (u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setVertexBuffer(3, f.trailBuffer), u.drawIndexed(6, f.activeParticles));
6061
+ const M = xt.get(g);
6062
+ M && (u.setVertexBuffer(1, ne), u.setVertexBuffer(2, q), u.setVertexBuffer(3, tt), u.drawIndexed(6, M.count, 0, 0, M.first)), P && m.depthWriteEnabled && (u.setPipeline(fs), u.drawIndexed(6, f.activeParticles));
5658
6063
  }
5659
6064
  }
5660
- function Qi() {
5661
- ft = a.width, ht = a.height, Lt();
6065
+ function Ri(u, f, m) {
6066
+ const g = Xe.get(m.id);
6067
+ !g || g.count <= 0 || (u.setPipeline(m.blendMode === "additive" ? Ss : bs), u.setBindGroup(0, wi(f, m)), u.setVertexBuffer(0, Zt), u.draw(g.count, 1, g.first, 0));
6068
+ }
6069
+ function Cs() {
6070
+ $t = a.width, Jt = a.height, Mi();
5662
6071
  }
5663
- function Ki() {
5664
- d.clear();
6072
+ function Us() {
6073
+ p.clear();
5665
6074
  }
5666
- function es() {
5667
- Ot = !0, l.destroy(), [be, Se, xe, Je].forEach((f) => f == null ? void 0 : f.destroy()), h.resizeTextures(), [
5668
- b,
6075
+ function Is() {
6076
+ _i = !0, l.destroy(), [at, ot, lt, zt].forEach((u) => u == null ? void 0 : u.destroy()), b.resizeTextures(), [
6077
+ v,
6078
+ E,
6079
+ I,
6080
+ z,
5669
6081
  _,
5670
- M,
5671
- R,
5672
- x,
5673
- L,
5674
- k,
5675
- G,
5676
- de
5677
- ].forEach((f) => f == null ? void 0 : f.destroy()), Object.values(P).forEach((f) => f == null ? void 0 : f.destroy());
5678
- }
5679
- async function Nt(f, m) {
5680
- const S = await l.addSystems(f, m);
6082
+ W,
6083
+ ne,
6084
+ q,
6085
+ tt,
6086
+ qt,
6087
+ Zt
6088
+ ].forEach((u) => u == null ? void 0 : u.destroy()), Object.values(T).forEach((u) => u == null ? void 0 : u.destroy());
6089
+ }
6090
+ async function Ti(u, f) {
6091
+ const m = await l.addSystems(u, f);
5681
6092
  for (const { config: g } of l.particleSystems)
5682
- P[g.id] || (P[g.id] = T());
5683
- return l.respawnAllSystems(), new Set(Array.isArray(S) ? S : []);
6093
+ T[g.id] || (T[g.id] = F());
6094
+ return l.respawnAllSystems(), new Set(Array.isArray(m) ? m : []);
5684
6095
  }
5685
- function kt(f) {
5686
- for (const m of f) {
5687
- const S = l.particleSystems.findIndex((g) => g.config.id === m);
5688
- S >= 0 && l.removeSystem(S);
6096
+ function Ai(u) {
6097
+ for (const f of u) {
6098
+ const m = l.particleSystems.findIndex((g) => g.config.id === f);
6099
+ m >= 0 && l.removeSystem(m);
5689
6100
  }
5690
6101
  }
5691
- async function ts(f, m = [0, 0, 0]) {
5692
- const S = await Nt(f, m);
6102
+ async function zs(u, f = [0, 0, 0]) {
6103
+ const m = await Ti(u, f);
5693
6104
  return { remove() {
5694
- kt(S);
6105
+ Ai(m);
5695
6106
  } };
5696
6107
  }
5697
- async function is(f, m = {}) {
5698
- const S = await Nt(f, [0, 0, 0]);
5699
- globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(f && f.systems || []).length} newIds=[${[...S]}]`);
5700
- const g = { ids: S, pos: null, hist: [], getPosition: m.getPosition || null, orientToDirection: !!m.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
5701
- return W.push(g), {
5702
- setPosition(v) {
5703
- v && (g.pos = Array.isArray(v) ? [v[0], v[1], v[2]] : [v.x, v.y, v.z]);
6108
+ async function Fs(u, f = {}) {
6109
+ const m = await Ti(u, [0, 0, 0]);
6110
+ globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...m]}]`);
6111
+ const g = { ids: m, pos: null, hist: [], getPosition: f.getPosition || null, orientToDirection: !!f.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
6112
+ return _e.push(g), {
6113
+ setPosition(y) {
6114
+ y && (g.pos = Array.isArray(y) ? [y[0], y[1], y[2]] : [y.x, y.y, y.z]);
5704
6115
  },
5705
- setOrientToDirection(v) {
5706
- g.orientToDirection = !!v;
6116
+ setOrientToDirection(y) {
6117
+ g.orientToDirection = !!y;
5707
6118
  },
5708
6119
  remove() {
5709
- kt(S);
5710
- const v = W.indexOf(g);
5711
- v >= 0 && W.splice(v, 1);
6120
+ Ai(m);
6121
+ const y = _e.indexOf(g);
6122
+ y >= 0 && _e.splice(y, 1);
5712
6123
  }
5713
6124
  };
5714
6125
  }
5715
- function ss(f, m) {
5716
- 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], _prevPosBuf: [0, 0, 0] };
5717
- return W.push(g), {
6126
+ function Gs(u, f) {
6127
+ const g = { ids: u instanceof Set ? u : new Set(u), pos: null, hist: [], getPosition: f, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
6128
+ return _e.push(g), {
5718
6129
  remove() {
5719
- const v = W.indexOf(g);
5720
- v >= 0 && W.splice(v, 1);
6130
+ const y = _e.indexOf(g);
6131
+ y >= 0 && _e.splice(y, 1);
5721
6132
  },
5722
6133
  // Update which systems this history group covers WITHOUT losing the accumulated path
5723
6134
  // history. Needed when the scene's systems change (e.g. duplicate/add/remove) while the
5724
6135
  // group is active — otherwise a newly-added system's id isn't in the set and its trail
5725
6136
  // can't follow the recorded movement path (it falls back to straight extrapolation).
5726
- setIds(v) {
5727
- g.ids = v instanceof Set ? v : new Set(v);
6137
+ setIds(y) {
6138
+ g.ids = y instanceof Set ? y : new Set(y);
5728
6139
  }
5729
6140
  };
5730
6141
  }
@@ -5732,85 +6143,85 @@ async function vr(s, t = {}) {
5732
6143
  manager: l,
5733
6144
  device: r,
5734
6145
  context: n,
5735
- setCamera: Zi,
5736
- setCameraMVP: $i,
5737
- setEmitters: pt,
5738
- loadPreset: Wi,
5739
- addEmitter: ts,
5740
- addMovingEmitter: is,
5741
- render: Ji,
5742
- resize: Qi,
5743
- clearCaches: Ki,
5744
- trackHistoryGroup: ss,
5745
- destroy: es
6146
+ setCamera: Rs,
6147
+ setCameraMVP: Ts,
6148
+ setEmitters: Kt,
6149
+ loadPreset: As,
6150
+ addEmitter: zs,
6151
+ addMovingEmitter: Fs,
6152
+ render: Es,
6153
+ resize: Cs,
6154
+ clearCaches: Us,
6155
+ trackHistoryGroup: Gs,
6156
+ destroy: Is
5746
6157
  };
5747
6158
  }
5748
- function Pr(s) {
6159
+ function $r(s) {
5749
6160
  return () => {
5750
6161
  var t, e, i, r, n, a, o, c;
5751
6162
  try {
5752
6163
  const l = s.backend;
5753
6164
  if (!l) return null;
5754
- const u = s.domElement.width, p = s.domElement.height, h = (typeof s._getFrameBufferTarget == "function" ? s._getFrameBufferTarget() : null) || s._frameBufferTarget || null;
5755
- if (s.needsFrameBufferTarget && h) {
5756
- const _ = l.get(h), M = ((i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, h)) == null ? void 0 : i.depthTexture) || h.depthTexture, R = [
5757
- (r = _ == null ? void 0 : _.depthTexture) == null ? void 0 : r.texture,
5758
- _ == null ? void 0 : _.depthTexture,
5759
- (n = _ == null ? void 0 : _.depthBuffer) == null ? void 0 : n.texture,
5760
- M ? (a = l.get(M)) == null ? void 0 : a.texture : null
6165
+ const d = s.domElement.width, S = s.domElement.height, b = (typeof s._getFrameBufferTarget == "function" ? s._getFrameBufferTarget() : null) || s._frameBufferTarget || null;
6166
+ if (s.needsFrameBufferTarget && b) {
6167
+ const E = l.get(b), I = ((i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, b)) == null ? void 0 : i.depthTexture) || b.depthTexture, z = [
6168
+ (r = E == null ? void 0 : E.depthTexture) == null ? void 0 : r.texture,
6169
+ E == null ? void 0 : E.depthTexture,
6170
+ (n = E == null ? void 0 : E.depthBuffer) == null ? void 0 : n.texture,
6171
+ I ? (a = l.get(I)) == null ? void 0 : a.texture : null
5761
6172
  ];
5762
- for (const x of R)
5763
- if (x && typeof x.createView == "function" && x.width === u && x.height === p) return x;
6173
+ for (const _ of z)
6174
+ if (_ && typeof _.createView == "function" && _.width === d && _.height === S) return _;
5764
6175
  return null;
5765
6176
  }
5766
- 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;
5767
- return b ? { view: b, multisampled: (s.currentSamples ?? 0) > 1 } : null;
6177
+ const p = s.getCanvasTarget ? l.get(s.getCanvasTarget()) : null, v = ((c = (o = p == null ? void 0 : p.descriptor) == null ? void 0 : o.depthStencilAttachment) == null ? void 0 : c.view) ?? null;
6178
+ return v ? { view: v, multisampled: (s.currentSamples ?? 0) > 1 } : null;
5768
6179
  } catch {
5769
6180
  return null;
5770
6181
  }
5771
6182
  };
5772
6183
  }
5773
6184
  export {
5774
- ks as GLBAnimator,
5775
- js as HZClock,
5776
- hr as Objects3DManager,
5777
- ms as ParticleEmitter,
5778
- _s as ParticlePhysics,
5779
- ui as ParticleScript,
5780
- vt as ParticleSystem,
5781
- Ws as ParticleSystemManager,
5782
- ws as ParticleTextureManager,
5783
- gs as blurShader,
5784
- bs as compositeShader,
5785
- er as createBindGroupLayouts,
5786
- Pt as createBindGroups,
5787
- Ge as createBuffer,
5788
- sr as createCubeGeometry,
5789
- gi as createDepthTexture,
5790
- yr as createLookAtMatrix,
5791
- gr as createProjectionMatrix,
5792
- tr as createRenderPipelines,
5793
- yi as createRenderTextures,
5794
- ir as createSampler,
5795
- rr as createSphereGeometry,
5796
- Ss as directRenderShader,
5797
- fi as extractGLBTexture,
5798
- xr as fetchPreset,
5799
- Ks as glbMeshParticleShader,
5800
- pr as hexToRgb,
5801
- vr as initHzFxOverlay,
5802
- Js as initWebGPU,
5803
- Ti as isHZFX,
5804
- Sr as loadScene,
5805
- Pr as makeThreeSceneDepth,
5806
- ar as multiplyMatrices,
5807
- Qs as object3dShader,
5808
- lr as packHZFX,
5809
- As as parseGLB,
5810
- vs as particlePhysicsShader,
5811
- ys as particleShader,
5812
- mr as rgbToHex,
5813
- br as saveScene,
5814
- ur as serializeSystemConfig,
5815
- Ei as unpackHZFX
6185
+ br as GLBAnimator,
6186
+ Sr as HZClock,
6187
+ kr as Objects3DManager,
6188
+ Ys as ParticleEmitter,
6189
+ Ks as ParticlePhysics,
6190
+ Gi as ParticleScript,
6191
+ ii as ParticleSystem,
6192
+ wr as ParticleSystemManager,
6193
+ Qs as ParticleTextureManager,
6194
+ qs as blurShader,
6195
+ Zs as compositeShader,
6196
+ Ar as createBindGroupLayouts,
6197
+ si as createBindGroups,
6198
+ St as createBuffer,
6199
+ Ur as createCubeGeometry,
6200
+ Ni as createDepthTexture,
6201
+ Yr as createLookAtMatrix,
6202
+ jr as createProjectionMatrix,
6203
+ Er as createRenderPipelines,
6204
+ Xi as createRenderTextures,
6205
+ Cr as createSampler,
6206
+ Ir as createSphereGeometry,
6207
+ Hs as directRenderShader,
6208
+ Vi as extractGLBTexture,
6209
+ Hr as fetchPreset,
6210
+ Tr as glbMeshParticleShader,
6211
+ Xr as hexToRgb,
6212
+ Wr as initHzFxOverlay,
6213
+ Br as initWebGPU,
6214
+ es as isHZFX,
6215
+ Zr as loadScene,
6216
+ $r as makeThreeSceneDepth,
6217
+ Fr as multiplyMatrices,
6218
+ Rr as object3dShader,
6219
+ Dr as packHZFX,
6220
+ nr as parseGLB,
6221
+ $s as particlePhysicsShader,
6222
+ js as particleShader,
6223
+ Nr as rgbToHex,
6224
+ qr as saveScene,
6225
+ Or as serializeSystemConfig,
6226
+ ts as unpackHZFX
5816
6227
  };