hz-particles 1.5.0 → 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.
- package/dist-lib/hz-particles.cjs +15 -15
- package/dist-lib/hz-particles.mjs +943 -865
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
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,14 +10,14 @@ class ks {
|
|
|
10
10
|
if (t === this._cachedRotX && e === this._cachedRotY && i === this._cachedRotZ)
|
|
11
11
|
return;
|
|
12
12
|
this._cachedRotX = t, this._cachedRotY = e, this._cachedRotZ = i;
|
|
13
|
-
const r = t * Math.PI / 180, n = e * Math.PI / 180, a = i * Math.PI / 180, o = Math.cos(r), c = Math.sin(r), l = Math.cos(n), d = Math.sin(n), S = Math.cos(a),
|
|
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
15
|
l * S,
|
|
16
|
-
c * d * S - o *
|
|
17
|
-
o * d * S + c *
|
|
18
|
-
l *
|
|
19
|
-
c * d *
|
|
20
|
-
o * d *
|
|
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
21
|
-d,
|
|
22
22
|
c * l,
|
|
23
23
|
o * l
|
|
@@ -193,8 +193,8 @@ class ks {
|
|
|
193
193
|
if (Math.abs(a) < 1e-6 || o <= 1e-6)
|
|
194
194
|
c = Math.random();
|
|
195
195
|
else {
|
|
196
|
-
const S = Math.random(),
|
|
197
|
-
c = (-p + Math.sqrt(
|
|
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
199
|
const l = c * r, d = e + a * c;
|
|
200
200
|
t[0] = Math.cos(n) * d, t[1] = l, t[2] = Math.sin(n) * d;
|
|
@@ -256,33 +256,33 @@ class ks {
|
|
|
256
256
|
e > 0 ? a = e + (i - e) * Math.random() : a = i * Math.sqrt(Math.random()), t[0] = Math.cos(n) * a, t[1] = (Math.random() - 0.5) * r, t[2] = Math.sin(n) * a;
|
|
257
257
|
}
|
|
258
258
|
calculateVelocity(t, e, i, r, n) {
|
|
259
|
-
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, d = e - o, S = i - c,
|
|
260
|
-
let p, v,
|
|
261
|
-
if (
|
|
262
|
-
let
|
|
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 _ = this.inverseRotation(l, d, S),
|
|
265
|
-
if (
|
|
266
|
-
const T = -_[1] /
|
|
267
|
-
p =
|
|
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 _ = this.inverseRotation(l, d, S),
|
|
271
|
-
if (
|
|
272
|
-
const T = -_[2] /
|
|
273
|
-
p =
|
|
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 T = Math.random() * Math.PI * 2,
|
|
276
|
-
p =
|
|
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
|
-
|
|
279
|
+
z || (p = l / b, v = d / b, E = S / b);
|
|
280
280
|
} else {
|
|
281
|
-
const
|
|
282
|
-
p = Math.sin(_) * Math.cos(
|
|
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
|
|
285
|
-
this.config.randomSpeed ?
|
|
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 ks {
|
|
|
295
295
|
t[e + 6] = 0, t[e + 7] = i + (Math.random() * 0.4 - 0.2) * i;
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
const
|
|
298
|
+
const js = `
|
|
299
299
|
struct Uniforms {
|
|
300
300
|
transform: mat4x4<f32>,
|
|
301
301
|
cameraPosition: vec3<f32>,
|
|
@@ -719,7 +719,7 @@ const Xs = `
|
|
|
719
719
|
return vec4<f32>(input.color, alpha);
|
|
720
720
|
}
|
|
721
721
|
}
|
|
722
|
-
`,
|
|
722
|
+
`, qs = `
|
|
723
723
|
struct BloomUniforms {
|
|
724
724
|
direction: vec2<f32>,
|
|
725
725
|
resolution: vec2<f32>,
|
|
@@ -779,7 +779,7 @@ const Xs = `
|
|
|
779
779
|
|
|
780
780
|
return result / totalWeight * 1.1;
|
|
781
781
|
}
|
|
782
|
-
`,
|
|
782
|
+
`, Zs = `
|
|
783
783
|
struct BloomIntensityUniforms {
|
|
784
784
|
intensity: f32,
|
|
785
785
|
color: vec3<f32>,
|
|
@@ -825,7 +825,7 @@ const Xs = `
|
|
|
825
825
|
|
|
826
826
|
return vec4<f32>(originalColor.rgb + (mappedBloom * bloomUniforms.intensity), originalColor.a);
|
|
827
827
|
}
|
|
828
|
-
`,
|
|
828
|
+
`, Hs = `
|
|
829
829
|
struct BloomIntensityUniforms {
|
|
830
830
|
intensity: f32,
|
|
831
831
|
color: vec3<f32>,
|
|
@@ -866,7 +866,7 @@ const Xs = `
|
|
|
866
866
|
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
867
867
|
return textureSample(originalTexture, texSampler, input.texCoord);
|
|
868
868
|
}
|
|
869
|
-
`,
|
|
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 Xs = `
|
|
|
898
898
|
let c = textureSample(originalTexture, texSampler, input.texCoord);
|
|
899
899
|
return vec4<f32>(aces(c.rgb), c.a);
|
|
900
900
|
}
|
|
901
|
-
`,
|
|
901
|
+
`, $s = `
|
|
902
902
|
struct PhysicsUniforms {
|
|
903
903
|
deltaTime: f32,
|
|
904
904
|
particleSpeed: f32,
|
|
@@ -1108,7 +1108,7 @@ const Xs = `
|
|
|
1108
1108
|
particleBuffer[baseIndex + 1u] = newPos.y;
|
|
1109
1109
|
particleBuffer[baseIndex + 2u] = newPos.z;
|
|
1110
1110
|
}
|
|
1111
|
-
`,
|
|
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 Xs = `
|
|
|
1165
1165
|
outputData[outBase + 7u] = uv_v;
|
|
1166
1166
|
}
|
|
1167
1167
|
`;
|
|
1168
|
-
class
|
|
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:
|
|
1257
|
+
code: $s
|
|
1258
1258
|
}),
|
|
1259
1259
|
entryPoint: "main"
|
|
1260
1260
|
}
|
|
@@ -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
|
|
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
|
|
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 ji = Object.freeze({
|
|
|
1521
1521
|
return s + (t - s) * e;
|
|
1522
1522
|
},
|
|
1523
1523
|
smoothstep(s, t, e) {
|
|
1524
|
-
const i =
|
|
1524
|
+
const i = Hi.clamp((e - s) / (t - s), 0, 1);
|
|
1525
1525
|
return i * i * (3 - 2 * i);
|
|
1526
1526
|
}
|
|
1527
|
-
}),
|
|
1527
|
+
}), Ct = /* @__PURE__ */ new Set([
|
|
1528
1528
|
"particleSize",
|
|
1529
1529
|
"particleSpeed",
|
|
1530
1530
|
"particleColor",
|
|
@@ -1539,9 +1539,35 @@ const ji = 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
|
|
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 Js {
|
|
|
1619
1645
|
this._vd[this._vi + 2] = t, this._collection._dirty = !0;
|
|
1620
1646
|
}
|
|
1621
1647
|
}
|
|
1622
|
-
class
|
|
1648
|
+
class tr {
|
|
1623
1649
|
constructor() {
|
|
1624
|
-
this._proxy = new
|
|
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 Ks {
|
|
|
1630
1656
|
return t < 0 || t >= this.count ? null : this._proxy._bind(this._pd, this._vd, t);
|
|
1631
1657
|
}
|
|
1632
1658
|
}
|
|
1633
|
-
const
|
|
1634
|
-
function
|
|
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}>${
|
|
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 er(s) {
|
|
|
1654
1680
|
}
|
|
1655
1681
|
);
|
|
1656
1682
|
}
|
|
1657
|
-
const
|
|
1658
|
-
for (const s of
|
|
1659
|
-
|
|
1660
|
-
function
|
|
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 tr(s) {
|
|
|
1666
1692
|
t.value = !1;
|
|
1667
1693
|
};
|
|
1668
1694
|
if (typeof n != "string") return;
|
|
1669
|
-
if (
|
|
1670
|
-
const a =
|
|
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 (!
|
|
1678
|
-
const c =
|
|
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 tr(s) {
|
|
|
1685
1711
|
}
|
|
1686
1712
|
});
|
|
1687
1713
|
}
|
|
1688
|
-
class
|
|
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
|
|
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
|
-
${
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
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,11 +1805,11 @@ async function ir(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 T = t.getUint32(n, !0),
|
|
1783
|
-
if (
|
|
1784
|
-
const
|
|
1785
|
-
a = JSON.parse(
|
|
1786
|
-
} else
|
|
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);
|
|
1787
1813
|
n += 8 + T;
|
|
1788
1814
|
}
|
|
1789
1815
|
if (!a)
|
|
@@ -1796,47 +1822,47 @@ async function ir(s) {
|
|
|
1796
1822
|
const d = l.attributes.POSITION;
|
|
1797
1823
|
if (d === void 0)
|
|
1798
1824
|
throw new Error("Mesh primitive missing POSITION attribute");
|
|
1799
|
-
const S =
|
|
1800
|
-
let
|
|
1825
|
+
const S = ti(a, o, d, 3, 5126);
|
|
1826
|
+
let b;
|
|
1801
1827
|
if (l.attributes.NORMAL !== void 0)
|
|
1802
|
-
|
|
1828
|
+
b = ti(a, o, l.attributes.NORMAL, 3, 5126);
|
|
1803
1829
|
else {
|
|
1804
1830
|
const T = l.indices;
|
|
1805
1831
|
if (T === void 0)
|
|
1806
1832
|
throw new Error("Cannot generate normals without indices");
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1833
|
+
const F = Di(a, o, T);
|
|
1834
|
+
b = ar(S, F);
|
|
1809
1835
|
}
|
|
1810
1836
|
const p = l.indices;
|
|
1811
1837
|
if (p === void 0)
|
|
1812
1838
|
throw new Error("Mesh primitive missing indices");
|
|
1813
|
-
const v =
|
|
1814
|
-
let
|
|
1815
|
-
l.attributes.TEXCOORD_0 !== void 0 && (
|
|
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));
|
|
1816
1842
|
let _ = !1;
|
|
1817
1843
|
if (a.materials && a.materials.length > 0) {
|
|
1818
1844
|
const T = a.materials[0];
|
|
1819
1845
|
T.pbrMetallicRoughness && T.pbrMetallicRoughness.baseColorTexture !== void 0 && (_ = !0);
|
|
1820
1846
|
}
|
|
1821
|
-
let
|
|
1847
|
+
let W = null;
|
|
1822
1848
|
if (a.skins && a.skins.length > 0)
|
|
1823
1849
|
try {
|
|
1824
|
-
|
|
1850
|
+
W = fr(a, o, l), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", W);
|
|
1825
1851
|
} catch (T) {
|
|
1826
1852
|
console.warn("Failed to extract animation data:", T);
|
|
1827
1853
|
}
|
|
1828
1854
|
return {
|
|
1829
1855
|
positions: S,
|
|
1830
|
-
normals:
|
|
1856
|
+
normals: b,
|
|
1831
1857
|
indices: v,
|
|
1832
|
-
texCoords:
|
|
1833
|
-
vertexCount:
|
|
1834
|
-
indexCount:
|
|
1835
|
-
animationData:
|
|
1858
|
+
texCoords: z,
|
|
1859
|
+
vertexCount: E,
|
|
1860
|
+
indexCount: I,
|
|
1861
|
+
animationData: W,
|
|
1836
1862
|
hasBaseColorTexture: _
|
|
1837
1863
|
};
|
|
1838
1864
|
}
|
|
1839
|
-
function
|
|
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 Kt(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), d = n.count, S = new DataView(t, l, d * i * 4),
|
|
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);
|
|
1851
1877
|
for (let p = 0; p < d * i; p++)
|
|
1852
|
-
|
|
1853
|
-
return
|
|
1878
|
+
b[p] = S.getFloat32(p * 4, !0);
|
|
1879
|
+
return b;
|
|
1854
1880
|
}
|
|
1855
|
-
function
|
|
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 zi(s, t, e) {
|
|
|
1870
1896
|
} else
|
|
1871
1897
|
throw new Error(`Unsupported index component type: ${i.componentType}`);
|
|
1872
1898
|
}
|
|
1873
|
-
function
|
|
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]], 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]],
|
|
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 = [
|
|
1877
1903
|
d[1] * S[2] - d[2] * S[1],
|
|
1878
1904
|
d[2] * S[0] - d[0] * S[2],
|
|
1879
1905
|
d[0] * S[1] - d[1] * S[0]
|
|
1880
|
-
], p = Math.sqrt(
|
|
1881
|
-
p > 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
|
|
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 rr(s, t, e) {
|
|
|
1900
1926
|
} else
|
|
1901
1927
|
throw new Error(`Unsupported JOINTS_0 component type: ${i.componentType}`);
|
|
1902
1928
|
}
|
|
1903
|
-
function
|
|
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 nr(s, t, e) {
|
|
|
1918
1944
|
} else
|
|
1919
1945
|
throw new Error(`Unsupported WEIGHTS_0 component type: ${i.componentType}`);
|
|
1920
1946
|
}
|
|
1921
|
-
function
|
|
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 ar(s, t, e) {
|
|
|
1929
1955
|
c[l] = o.getFloat32(l * 4, !0);
|
|
1930
1956
|
return c;
|
|
1931
1957
|
}
|
|
1932
|
-
function
|
|
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,7 +1966,7 @@ function or(s, t, e) {
|
|
|
1940
1966
|
c[l] = o.getFloat32(l * 4, !0);
|
|
1941
1967
|
return c;
|
|
1942
1968
|
}
|
|
1943
|
-
function
|
|
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}`);
|
|
@@ -1951,8 +1977,8 @@ function lr(s, t, e) {
|
|
|
1951
1977
|
d[S] = l.getFloat32(S * 4, !0);
|
|
1952
1978
|
return d;
|
|
1953
1979
|
}
|
|
1954
|
-
function
|
|
1955
|
-
const i = s.skins[0], r = i.joints, n =
|
|
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
1984
|
const c = s.nodes.map((d) => ({
|
|
@@ -1965,20 +1991,20 @@ function cr(s, t, e) {
|
|
|
1965
1991
|
if (s.animations && s.animations.length > 0)
|
|
1966
1992
|
for (const d of s.animations) {
|
|
1967
1993
|
const S = [];
|
|
1968
|
-
let
|
|
1994
|
+
let b = 0;
|
|
1969
1995
|
for (const p of d.channels) {
|
|
1970
|
-
const v = d.samplers[p.sampler],
|
|
1971
|
-
|
|
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({
|
|
1972
1998
|
targetNode: p.target.node,
|
|
1973
1999
|
targetPath: p.target.path,
|
|
1974
2000
|
interpolation: v.interpolation || "LINEAR",
|
|
1975
|
-
timestamps:
|
|
1976
|
-
values:
|
|
2001
|
+
timestamps: E,
|
|
2002
|
+
values: I
|
|
1977
2003
|
});
|
|
1978
2004
|
}
|
|
1979
2005
|
l.push({
|
|
1980
2006
|
name: d.name || `Animation ${l.length}`,
|
|
1981
|
-
duration:
|
|
2007
|
+
duration: b,
|
|
1982
2008
|
channels: S
|
|
1983
2009
|
});
|
|
1984
2010
|
}
|
|
@@ -1991,7 +2017,7 @@ function cr(s, t, e) {
|
|
|
1991
2017
|
animations: l
|
|
1992
2018
|
};
|
|
1993
2019
|
}
|
|
1994
|
-
async function
|
|
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
|
|
2030
|
+
const W = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), F = s.slice(n + 8, n + 8 + W);
|
|
2005
2031
|
if (T === 1313821514) {
|
|
2006
|
-
const
|
|
2007
|
-
a = JSON.parse(
|
|
2008
|
-
} else T === 5130562 && (o =
|
|
2009
|
-
n += 8 +
|
|
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");
|
|
@@ -2021,18 +2047,18 @@ async function Fi(s) {
|
|
|
2021
2047
|
const S = a.textures[l].source;
|
|
2022
2048
|
if (S === void 0 || !a.images || !a.images[S])
|
|
2023
2049
|
return null;
|
|
2024
|
-
const
|
|
2025
|
-
if (
|
|
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 v = a.bufferViews[
|
|
2030
|
-
return { imageBlob: new Blob([
|
|
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
|
|
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
|
|
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) {
|
|
@@ -2043,23 +2069,23 @@ function dr(s, t, e, i) {
|
|
|
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
|
|
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, d = e * o, S = e * c,
|
|
2048
|
-
return _[0] = 1 - (
|
|
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
|
|
2051
|
-
function
|
|
2052
|
-
const r =
|
|
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
|
|
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
|
|
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++)
|
|
@@ -2126,7 +2152,7 @@ class mr {
|
|
|
2126
2152
|
this._gpuSkinningPipeline = t.createComputePipeline({
|
|
2127
2153
|
layout: t.createPipelineLayout({ bindGroupLayouts: [o] }),
|
|
2128
2154
|
compute: {
|
|
2129
|
-
module: t.createShaderModule({ code:
|
|
2155
|
+
module: t.createShaderModule({ code: Js }),
|
|
2130
2156
|
entryPoint: "main"
|
|
2131
2157
|
}
|
|
2132
2158
|
}), this._gpuSkinningBindGroup = t.createBindGroup({
|
|
@@ -2216,11 +2242,11 @@ class mr {
|
|
|
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
|
|
2220
|
-
r[
|
|
2245
|
+
const E = Math.floor((c + l) / 2);
|
|
2246
|
+
r[E] <= e ? c = E : l = E;
|
|
2221
2247
|
}
|
|
2222
|
-
const d = r[c], S = r[l],
|
|
2223
|
-
return a === "STEP" ? (i[0] = p[0], i[1] = p[1], i[2] = p[2], o === "rotation" && (i[3] = p[3]), i) : o === "rotation" ?
|
|
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 mr {
|
|
|
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
|
-
|
|
2274
|
+
gr(n, a, o, this.jointLocalTransforms[i]);
|
|
2249
2275
|
}
|
|
2250
2276
|
}
|
|
2251
2277
|
/**
|
|
@@ -2255,7 +2281,7 @@ class mr {
|
|
|
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]) :
|
|
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 mr {
|
|
|
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
|
-
|
|
2297
|
+
Oi(i, this._invBindViews[t], this.jointFinalMatrices[t]);
|
|
2272
2298
|
}
|
|
2273
2299
|
}
|
|
2274
2300
|
/**
|
|
@@ -2278,20 +2304,20 @@ class mr {
|
|
|
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 d = l * 3, S = l * 4,
|
|
2282
|
-
let _ = 0,
|
|
2283
|
-
for (let
|
|
2284
|
-
const
|
|
2285
|
-
if (
|
|
2286
|
-
const q = c[o[S +
|
|
2287
|
-
_ += (q[0] *
|
|
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
|
|
2290
|
-
|
|
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
|
|
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 yr {
|
|
|
2312
2338
|
this.currentTime = Math.max(0, t || 0), this._justLooped = !1;
|
|
2313
2339
|
}
|
|
2314
2340
|
}
|
|
2315
|
-
const
|
|
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 Di = {
|
|
|
2331
2357
|
return Math.pow(2, -10 * s) * Math.sin((s * 10 - 0.75) * t) + 1;
|
|
2332
2358
|
}
|
|
2333
2359
|
};
|
|
2334
|
-
function
|
|
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, d = (p) => ((a * p + n) * p + r) * p, S = (p) => ((l * p + c) * p + o) * p,
|
|
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;
|
|
2336
2362
|
return (p) => {
|
|
2337
2363
|
if (p <= 0) return 0;
|
|
2338
2364
|
if (p >= 1) return 1;
|
|
2339
2365
|
let v = p;
|
|
2340
|
-
for (let
|
|
2341
|
-
const
|
|
2342
|
-
if (Math.abs(
|
|
2343
|
-
const
|
|
2344
|
-
if (Math.abs(
|
|
2345
|
-
v -=
|
|
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
2373
|
return S(v);
|
|
2348
2374
|
};
|
|
2349
2375
|
}
|
|
2350
|
-
function
|
|
2351
|
-
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ?
|
|
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
|
|
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 br(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) *
|
|
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
|
|
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;
|
|
@@ -2375,10 +2401,10 @@ function Sr(s, t, e) {
|
|
|
2375
2401
|
else {
|
|
2376
2402
|
n = a = r.v, o = 0;
|
|
2377
2403
|
for (let S = 0; S < i - 1; S++) {
|
|
2378
|
-
const
|
|
2379
|
-
if (t >=
|
|
2380
|
-
const v = p.t -
|
|
2381
|
-
n =
|
|
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
|
}
|
|
@@ -2386,14 +2412,49 @@ function Sr(s, t, e) {
|
|
|
2386
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;
|
|
2387
2413
|
return e ? (e[0] = c, e[1] = l, e[2] = d, e) : [c, l, d];
|
|
2388
2414
|
}
|
|
2389
|
-
const
|
|
2390
|
-
|
|
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
|
|
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 Qt {
|
|
|
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.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 ks(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 Qt {
|
|
|
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
|
|
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 Qt {
|
|
|
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
|
|
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 Qt {
|
|
|
2453
2514
|
async setGLBModel(t) {
|
|
2454
2515
|
try {
|
|
2455
2516
|
this.glbRawArrayBuffer = t;
|
|
2456
|
-
const e = await
|
|
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 Qt {
|
|
|
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
|
|
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 Qt {
|
|
|
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 =
|
|
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 Qt {
|
|
|
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
|
|
2552
|
-
this.particleCount =
|
|
2553
|
-
let
|
|
2554
|
-
const
|
|
2555
|
-
for (let
|
|
2556
|
-
if (this.emitParticle(),
|
|
2557
|
-
const
|
|
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
|
-
|
|
2621
|
+
o * 4,
|
|
2561
2622
|
// Offset in bytes
|
|
2562
2623
|
this.particleData,
|
|
2563
|
-
|
|
2564
|
-
|
|
2624
|
+
o,
|
|
2625
|
+
i * 8
|
|
2565
2626
|
), this.device.queue.writeBuffer(
|
|
2566
2627
|
this.velocityBuffer,
|
|
2567
|
-
|
|
2628
|
+
c * 4,
|
|
2568
2629
|
// Offset in bytes
|
|
2569
2630
|
this.particleVelocities,
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
),
|
|
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
|
|
2578
|
-
this.particleCount = Math.min(Math.ceil((this.config.emissionRate || 10) *
|
|
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).
|
|
@@ -2630,7 +2691,7 @@ class Qt {
|
|
|
2630
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 S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty:
|
|
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,
|
|
@@ -2651,7 +2712,7 @@ class Qt {
|
|
|
2651
2712
|
this._scriptVelocityData,
|
|
2652
2713
|
0,
|
|
2653
2714
|
this.activeParticles * 4
|
|
2654
|
-
)),
|
|
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;
|
|
@@ -2662,8 +2723,8 @@ class Qt {
|
|
|
2662
2723
|
let S = !1;
|
|
2663
2724
|
if (this.config.followSystemId) {
|
|
2664
2725
|
if (this._pendingFollowEmissions.length > 0) {
|
|
2665
|
-
const
|
|
2666
|
-
for (let p = 0; p <
|
|
2726
|
+
const b = this._pendingFollowEmissions.length / 6;
|
|
2727
|
+
for (let p = 0; p < b; p++) {
|
|
2667
2728
|
const v = p * 6;
|
|
2668
2729
|
if (this.emitFollowerParticle(
|
|
2669
2730
|
this._pendingFollowEmissions[v],
|
|
@@ -2676,10 +2737,10 @@ class Qt {
|
|
|
2676
2737
|
}
|
|
2677
2738
|
}
|
|
2678
2739
|
} else {
|
|
2679
|
-
let
|
|
2740
|
+
let b = 0;
|
|
2680
2741
|
const p = Math.max(0, this.config.emissionRate || 0);
|
|
2681
|
-
this.activeParticles < this.particleCount && p > 0 ? (this.emissionAccumulator += p * t,
|
|
2682
|
-
for (let v = 0; v <
|
|
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
2745
|
S = !0;
|
|
2685
2746
|
else {
|
|
@@ -2688,21 +2749,21 @@ class Qt {
|
|
|
2688
2749
|
}
|
|
2689
2750
|
}
|
|
2690
2751
|
if (S) {
|
|
2691
|
-
const
|
|
2752
|
+
const b = this.activeParticles - d, p = d * 8, v = d * 4;
|
|
2692
2753
|
this.device.queue.writeBuffer(
|
|
2693
2754
|
this.instanceBuffer,
|
|
2694
2755
|
p * 4,
|
|
2695
2756
|
// Offset in bytes (float32 = 4 bytes)
|
|
2696
2757
|
this.particleData,
|
|
2697
2758
|
p,
|
|
2698
|
-
|
|
2759
|
+
b * 8
|
|
2699
2760
|
), this.device.queue.writeBuffer(
|
|
2700
2761
|
this.velocityBuffer,
|
|
2701
2762
|
v * 4,
|
|
2702
2763
|
// Offset in bytes (float32 = 4 bytes)
|
|
2703
2764
|
this.particleVelocities,
|
|
2704
2765
|
v,
|
|
2705
|
-
|
|
2766
|
+
b * 4
|
|
2706
2767
|
);
|
|
2707
2768
|
}
|
|
2708
2769
|
} else
|
|
@@ -2797,8 +2858,8 @@ class Qt {
|
|
|
2797
2858
|
} else {
|
|
2798
2859
|
const S = Math.sqrt(r * r + n * n + a * a);
|
|
2799
2860
|
if (S > 1e-3) {
|
|
2800
|
-
const
|
|
2801
|
-
this.particleVelocities[i] = r / S *
|
|
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 Qt {
|
|
|
2843
2904
|
this.physics.setSoftBoundary(t);
|
|
2844
2905
|
}
|
|
2845
2906
|
}
|
|
2846
|
-
class
|
|
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
|
|
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
|
|
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 Pr {
|
|
|
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 Pr {
|
|
|
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
|
-
|
|
2918
|
-
if (!(!l || c.keyframesEnabled === !1)) {
|
|
2919
|
-
for (const d of xr) {
|
|
2920
|
-
const S = l[d];
|
|
2921
|
-
if (S && S.length) {
|
|
2922
|
-
const g = br(S, a);
|
|
2923
|
-
g !== void 0 && (c[d] = g);
|
|
2924
|
-
}
|
|
2925
|
-
}
|
|
2926
|
-
if (l.particleColor && l.particleColor.length) {
|
|
2927
|
-
const d = c.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0, g = Sr(l.particleColor, a, S);
|
|
2928
|
-
g && (c.particleColor = g, 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 Pr {
|
|
|
2976
3023
|
const n = this.systemCounter++, a = {
|
|
2977
3024
|
...r,
|
|
2978
3025
|
id: n
|
|
2979
|
-
}, o = new
|
|
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 Pr {
|
|
|
2994
3041
|
try {
|
|
2995
3042
|
let a = null;
|
|
2996
3043
|
if (n.glbModelData)
|
|
2997
|
-
a =
|
|
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 Pr {
|
|
|
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
|
|
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,7 +3117,7 @@ class Pr {
|
|
|
3070
3117
|
(o.confinementCenter[1] || 0) + e[1],
|
|
3071
3118
|
(o.confinementCenter[2] || 0) + e[2]
|
|
3072
3119
|
]);
|
|
3073
|
-
const d = new
|
|
3120
|
+
const d = new ii(this.device, l);
|
|
3074
3121
|
this.particleSystems.push({
|
|
3075
3122
|
system: d,
|
|
3076
3123
|
config: l
|
|
@@ -3089,7 +3136,7 @@ class Pr {
|
|
|
3089
3136
|
try {
|
|
3090
3137
|
let l = null;
|
|
3091
3138
|
if (c.glbModelData)
|
|
3092
|
-
l =
|
|
3139
|
+
l = ki(c.glbModelData);
|
|
3093
3140
|
else if (c.glbFileName) {
|
|
3094
3141
|
const d = await fetch(`/${c.glbFileName}`);
|
|
3095
3142
|
d.ok ? l = await d.arrayBuffer() : console.warn(`GLB file not found: ${c.glbFileName}`);
|
|
@@ -3097,7 +3144,7 @@ class Pr {
|
|
|
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 d = await
|
|
3147
|
+
const d = await Vi(l);
|
|
3101
3148
|
if (d) {
|
|
3102
3149
|
const S = await createImageBitmap(d.imageBlob);
|
|
3103
3150
|
await o.setTexture(S), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${c.name}`);
|
|
@@ -3114,8 +3161,8 @@ class Pr {
|
|
|
3114
3161
|
if (c.textureEnabled && !c.glbModelEnabled && c.textureImageData && !o._textureRestored)
|
|
3115
3162
|
try {
|
|
3116
3163
|
const l = new Image();
|
|
3117
|
-
await new Promise((S,
|
|
3118
|
-
l.onload = S, l.onerror =
|
|
3164
|
+
await new Promise((S, b) => {
|
|
3165
|
+
l.onload = S, l.onerror = b, l.src = c.textureImageData;
|
|
3119
3166
|
});
|
|
3120
3167
|
const d = await createImageBitmap(l);
|
|
3121
3168
|
await o.setTexture(d), o._textureRestored = !0;
|
|
@@ -3129,8 +3176,30 @@ class Pr {
|
|
|
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
|
|
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 _r(s) {
|
|
|
3142
3211
|
alphaMode: "premultiplied"
|
|
3143
3212
|
}), { device: i, context: t, format: r, canvas: s };
|
|
3144
3213
|
}
|
|
3145
|
-
const
|
|
3146
|
-
function
|
|
3214
|
+
const ke = "rgba16float";
|
|
3215
|
+
function Xi(s, t, e, i) {
|
|
3147
3216
|
const r = s.createTexture({
|
|
3148
3217
|
size: [e, i],
|
|
3149
|
-
format:
|
|
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:
|
|
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:
|
|
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
|
|
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
|
|
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 vt(s, t, e) {
|
|
|
3180
3249
|
});
|
|
3181
3250
|
return new t.constructor(i.getMappedRange()).set(t), i.unmap(), i;
|
|
3182
3251
|
}
|
|
3183
|
-
const
|
|
3252
|
+
const Rr = `
|
|
3184
3253
|
struct Uniforms {
|
|
3185
3254
|
transform: mat4x4<f32>,
|
|
3186
3255
|
cameraPosition: vec3<f32>,
|
|
@@ -3242,7 +3311,7 @@ const Mr = `
|
|
|
3242
3311
|
|
|
3243
3312
|
return finalColor;
|
|
3244
3313
|
}
|
|
3245
|
-
`,
|
|
3314
|
+
`, Tr = `
|
|
3246
3315
|
struct Uniforms {
|
|
3247
3316
|
transform: mat4x4<f32>,
|
|
3248
3317
|
cameraPosition: vec3<f32>,
|
|
@@ -3479,7 +3548,7 @@ const Mr = `
|
|
|
3479
3548
|
return finalColor;
|
|
3480
3549
|
}
|
|
3481
3550
|
`;
|
|
3482
|
-
function
|
|
3551
|
+
function Ar(s) {
|
|
3483
3552
|
const t = s.createBindGroupLayout({
|
|
3484
3553
|
entries: [
|
|
3485
3554
|
{
|
|
@@ -3565,7 +3634,7 @@ function Br(s) {
|
|
|
3565
3634
|
object3dBindGroupLayout: r
|
|
3566
3635
|
};
|
|
3567
3636
|
}
|
|
3568
|
-
function
|
|
3637
|
+
function Er(s, t, e, i = {}) {
|
|
3569
3638
|
const { depthCompare: r } = i, n = r || "less", {
|
|
3570
3639
|
particleBindGroupLayout: a,
|
|
3571
3640
|
bloomBindGroupLayout: o,
|
|
@@ -3575,21 +3644,21 @@ function Rr(s, t, e, i = {}) {
|
|
|
3575
3644
|
bindGroupLayouts: [a]
|
|
3576
3645
|
}), S = s.createPipelineLayout({
|
|
3577
3646
|
bindGroupLayouts: [o]
|
|
3578
|
-
}),
|
|
3647
|
+
}), b = s.createPipelineLayout({
|
|
3579
3648
|
bindGroupLayouts: [c]
|
|
3580
3649
|
}), p = s.createShaderModule({
|
|
3581
|
-
code: Xs
|
|
3582
|
-
}), v = s.createShaderModule({
|
|
3583
|
-
code: Ns
|
|
3584
|
-
}), A = s.createShaderModule({
|
|
3585
|
-
code: Ys
|
|
3586
|
-
}), U = s.createShaderModule({
|
|
3587
3650
|
code: js
|
|
3651
|
+
}), v = s.createShaderModule({
|
|
3652
|
+
code: qs
|
|
3653
|
+
}), E = s.createShaderModule({
|
|
3654
|
+
code: Zs
|
|
3588
3655
|
}), I = s.createShaderModule({
|
|
3589
|
-
code:
|
|
3656
|
+
code: Hs
|
|
3657
|
+
}), z = s.createShaderModule({
|
|
3658
|
+
code: Rr
|
|
3590
3659
|
}), _ = s.createShaderModule({
|
|
3591
|
-
code:
|
|
3592
|
-
}),
|
|
3660
|
+
code: Tr
|
|
3661
|
+
}), W = (kt) => s.createRenderPipeline({
|
|
3593
3662
|
layout: d,
|
|
3594
3663
|
vertex: {
|
|
3595
3664
|
module: p,
|
|
@@ -3656,7 +3725,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3656
3725
|
module: p,
|
|
3657
3726
|
entryPoint: "fs_main",
|
|
3658
3727
|
targets: [{
|
|
3659
|
-
format:
|
|
3728
|
+
format: ke,
|
|
3660
3729
|
blend: kt
|
|
3661
3730
|
}]
|
|
3662
3731
|
},
|
|
@@ -3669,7 +3738,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3669
3738
|
depthCompare: n,
|
|
3670
3739
|
format: "depth24plus"
|
|
3671
3740
|
}
|
|
3672
|
-
}), T =
|
|
3741
|
+
}), T = W({
|
|
3673
3742
|
color: {
|
|
3674
3743
|
srcFactor: "src-alpha",
|
|
3675
3744
|
dstFactor: "one-minus-src-alpha",
|
|
@@ -3680,7 +3749,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3680
3749
|
dstFactor: "one-minus-src-alpha",
|
|
3681
3750
|
operation: "add"
|
|
3682
3751
|
}
|
|
3683
|
-
}),
|
|
3752
|
+
}), F = W({
|
|
3684
3753
|
color: {
|
|
3685
3754
|
srcFactor: "src-alpha",
|
|
3686
3755
|
dstFactor: "one",
|
|
@@ -3691,7 +3760,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3691
3760
|
dstFactor: "one-minus-src-alpha",
|
|
3692
3761
|
operation: "add"
|
|
3693
3762
|
}
|
|
3694
|
-
}),
|
|
3763
|
+
}), G = s.createRenderPipeline({
|
|
3695
3764
|
layout: d,
|
|
3696
3765
|
vertex: {
|
|
3697
3766
|
module: p,
|
|
@@ -3758,7 +3827,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3758
3827
|
module: p,
|
|
3759
3828
|
entryPoint: "fs_main",
|
|
3760
3829
|
targets: [{
|
|
3761
|
-
format:
|
|
3830
|
+
format: ke,
|
|
3762
3831
|
writeMask: 0
|
|
3763
3832
|
// No color write — depth only
|
|
3764
3833
|
}]
|
|
@@ -3773,7 +3842,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3773
3842
|
// Always write depth (don't self-occlude)
|
|
3774
3843
|
format: "depth24plus"
|
|
3775
3844
|
}
|
|
3776
|
-
}),
|
|
3845
|
+
}), H = s.createRenderPipeline({
|
|
3777
3846
|
layout: S,
|
|
3778
3847
|
vertex: {
|
|
3779
3848
|
module: v,
|
|
@@ -3783,23 +3852,23 @@ function Rr(s, t, e, i = {}) {
|
|
|
3783
3852
|
module: v,
|
|
3784
3853
|
entryPoint: "fs_main",
|
|
3785
3854
|
targets: [{
|
|
3786
|
-
format:
|
|
3855
|
+
format: ke
|
|
3787
3856
|
}]
|
|
3788
3857
|
},
|
|
3789
3858
|
primitive: {
|
|
3790
3859
|
topology: "triangle-list"
|
|
3791
3860
|
}
|
|
3792
|
-
}),
|
|
3793
|
-
layout:
|
|
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:
|
|
3871
|
+
format: ke,
|
|
3803
3872
|
blend: {
|
|
3804
3873
|
color: {
|
|
3805
3874
|
srcFactor: "one",
|
|
@@ -3817,17 +3886,17 @@ function Rr(s, t, e, i = {}) {
|
|
|
3817
3886
|
primitive: {
|
|
3818
3887
|
topology: "triangle-list"
|
|
3819
3888
|
}
|
|
3820
|
-
}),
|
|
3821
|
-
layout:
|
|
3889
|
+
}), ae = s.createRenderPipeline({
|
|
3890
|
+
layout: b,
|
|
3822
3891
|
vertex: {
|
|
3823
|
-
module:
|
|
3892
|
+
module: I,
|
|
3824
3893
|
entryPoint: "vs_main"
|
|
3825
3894
|
},
|
|
3826
3895
|
fragment: {
|
|
3827
|
-
module:
|
|
3896
|
+
module: I,
|
|
3828
3897
|
entryPoint: "fs_main",
|
|
3829
3898
|
targets: [{
|
|
3830
|
-
format:
|
|
3899
|
+
format: ke,
|
|
3831
3900
|
blend: {
|
|
3832
3901
|
color: {
|
|
3833
3902
|
srcFactor: "one",
|
|
@@ -3845,11 +3914,11 @@ function Rr(s, t, e, i = {}) {
|
|
|
3845
3914
|
primitive: {
|
|
3846
3915
|
topology: "triangle-list"
|
|
3847
3916
|
}
|
|
3848
|
-
}),
|
|
3849
|
-
layout:
|
|
3850
|
-
vertex: { module:
|
|
3917
|
+
}), ne = s.createShaderModule({ code: Ws }), q = s.createRenderPipeline({
|
|
3918
|
+
layout: b,
|
|
3919
|
+
vertex: { module: ne, entryPoint: "vs_main" },
|
|
3851
3920
|
fragment: {
|
|
3852
|
-
module:
|
|
3921
|
+
module: ne,
|
|
3853
3922
|
entryPoint: "fs_main",
|
|
3854
3923
|
targets: [{
|
|
3855
3924
|
format: t,
|
|
@@ -3860,12 +3929,12 @@ function Rr(s, t, e, i = {}) {
|
|
|
3860
3929
|
}]
|
|
3861
3930
|
},
|
|
3862
3931
|
primitive: { topology: "triangle-list" }
|
|
3863
|
-
}),
|
|
3932
|
+
}), tt = s.createPipelineLayout({
|
|
3864
3933
|
bindGroupLayouts: [l]
|
|
3865
|
-
}),
|
|
3866
|
-
layout:
|
|
3934
|
+
}), xt = s.createRenderPipeline({
|
|
3935
|
+
layout: tt,
|
|
3867
3936
|
vertex: {
|
|
3868
|
-
module:
|
|
3937
|
+
module: z,
|
|
3869
3938
|
entryPoint: "vs_main",
|
|
3870
3939
|
buffers: [
|
|
3871
3940
|
{
|
|
@@ -3890,10 +3959,10 @@ function Rr(s, t, e, i = {}) {
|
|
|
3890
3959
|
]
|
|
3891
3960
|
},
|
|
3892
3961
|
fragment: {
|
|
3893
|
-
module:
|
|
3962
|
+
module: z,
|
|
3894
3963
|
entryPoint: "fs_main",
|
|
3895
3964
|
targets: [{
|
|
3896
|
-
format:
|
|
3965
|
+
format: ke,
|
|
3897
3966
|
blend: {
|
|
3898
3967
|
color: {
|
|
3899
3968
|
srcFactor: "src-alpha",
|
|
@@ -3917,7 +3986,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3917
3986
|
depthCompare: n,
|
|
3918
3987
|
format: "depth24plus"
|
|
3919
3988
|
}
|
|
3920
|
-
}),
|
|
3989
|
+
}), Xe = s.createRenderPipeline({
|
|
3921
3990
|
layout: d,
|
|
3922
3991
|
vertex: {
|
|
3923
3992
|
module: _,
|
|
@@ -3995,7 +4064,7 @@ function Rr(s, t, e, i = {}) {
|
|
|
3995
4064
|
module: _,
|
|
3996
4065
|
entryPoint: "fs_main",
|
|
3997
4066
|
targets: [{
|
|
3998
|
-
format:
|
|
4067
|
+
format: ke,
|
|
3999
4068
|
blend: {
|
|
4000
4069
|
color: {
|
|
4001
4070
|
srcFactor: "src-alpha",
|
|
@@ -4022,17 +4091,17 @@ function Rr(s, t, e, i = {}) {
|
|
|
4022
4091
|
});
|
|
4023
4092
|
return {
|
|
4024
4093
|
particlePipeline: T,
|
|
4025
|
-
particleAdditivePipeline:
|
|
4026
|
-
particleDepthWritePipeline:
|
|
4027
|
-
blurPipeline:
|
|
4028
|
-
compositePipeline:
|
|
4029
|
-
directRenderPipeline:
|
|
4094
|
+
particleAdditivePipeline: F,
|
|
4095
|
+
particleDepthWritePipeline: G,
|
|
4096
|
+
blurPipeline: H,
|
|
4097
|
+
compositePipeline: re,
|
|
4098
|
+
directRenderPipeline: ae,
|
|
4030
4099
|
finalCompositePipeline: q,
|
|
4031
|
-
object3dPipeline:
|
|
4032
|
-
glbMeshPipeline:
|
|
4100
|
+
object3dPipeline: xt,
|
|
4101
|
+
glbMeshPipeline: Xe
|
|
4033
4102
|
};
|
|
4034
4103
|
}
|
|
4035
|
-
function
|
|
4104
|
+
function si(s, t, e, i) {
|
|
4036
4105
|
const {
|
|
4037
4106
|
uniformBuffer: r,
|
|
4038
4107
|
appearanceUniformBuffer: n,
|
|
@@ -4043,7 +4112,7 @@ function ei(s, t, e, i) {
|
|
|
4043
4112
|
sceneTexture: l,
|
|
4044
4113
|
bloomTexA: d,
|
|
4045
4114
|
bloomTexB: S
|
|
4046
|
-
} = i,
|
|
4115
|
+
} = i, b = s.createBindGroup({
|
|
4047
4116
|
layout: s.createBindGroupLayout({
|
|
4048
4117
|
entries: [
|
|
4049
4118
|
{
|
|
@@ -4136,7 +4205,7 @@ function ei(s, t, e, i) {
|
|
|
4136
4205
|
resource: { buffer: o }
|
|
4137
4206
|
}
|
|
4138
4207
|
]
|
|
4139
|
-
}),
|
|
4208
|
+
}), E = s.createBindGroup({
|
|
4140
4209
|
layout: s.createBindGroupLayout({
|
|
4141
4210
|
entries: [
|
|
4142
4211
|
{
|
|
@@ -4179,7 +4248,7 @@ function ei(s, t, e, i) {
|
|
|
4179
4248
|
resource: { buffer: c }
|
|
4180
4249
|
}
|
|
4181
4250
|
]
|
|
4182
|
-
}),
|
|
4251
|
+
}), I = s.createBindGroup({
|
|
4183
4252
|
layout: s.createBindGroupLayout({
|
|
4184
4253
|
entries: [
|
|
4185
4254
|
{
|
|
@@ -4224,14 +4293,14 @@ function ei(s, t, e, i) {
|
|
|
4224
4293
|
]
|
|
4225
4294
|
});
|
|
4226
4295
|
return {
|
|
4227
|
-
particleBindGroup:
|
|
4296
|
+
particleBindGroup: b,
|
|
4228
4297
|
horizontalBlurBindGroup: p,
|
|
4229
4298
|
verticalBlurBindGroup: v,
|
|
4230
|
-
compositeBindGroup:
|
|
4231
|
-
directRenderBindGroup:
|
|
4299
|
+
compositeBindGroup: E,
|
|
4300
|
+
directRenderBindGroup: I
|
|
4232
4301
|
};
|
|
4233
4302
|
}
|
|
4234
|
-
function
|
|
4303
|
+
function Cr(s) {
|
|
4235
4304
|
return s.createSampler({
|
|
4236
4305
|
magFilter: "linear",
|
|
4237
4306
|
minFilter: "linear",
|
|
@@ -4241,7 +4310,7 @@ function Tr(s) {
|
|
|
4241
4310
|
maxAnisotropy: 16
|
|
4242
4311
|
});
|
|
4243
4312
|
}
|
|
4244
|
-
function
|
|
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 Er() {
|
|
|
4439
4508
|
]);
|
|
4440
4509
|
return { vertices: s, indices: t };
|
|
4441
4510
|
}
|
|
4442
|
-
function
|
|
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, d = Math.sin(l),
|
|
4448
|
-
e.push(
|
|
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 Ar(s = 16, t = 16) {
|
|
|
4458
4527
|
indices: new Uint16Array(i)
|
|
4459
4528
|
};
|
|
4460
4529
|
}
|
|
4461
|
-
class
|
|
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 Cr {
|
|
|
4592
4661
|
return i;
|
|
4593
4662
|
}
|
|
4594
4663
|
}
|
|
4595
|
-
class
|
|
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 Vr {
|
|
|
4600
4669
|
* Initialize geometry buffers for cube and sphere
|
|
4601
4670
|
*/
|
|
4602
4671
|
initializeGeometry() {
|
|
4603
|
-
const t =
|
|
4604
|
-
this.cubeVertexBuffer =
|
|
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 =
|
|
4677
|
+
), this.cubeIndexBuffer = St(
|
|
4609
4678
|
this.device,
|
|
4610
4679
|
t.indices,
|
|
4611
4680
|
GPUBufferUsage.INDEX
|
|
4612
|
-
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer =
|
|
4681
|
+
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer = St(
|
|
4613
4682
|
this.device,
|
|
4614
4683
|
e.vertices,
|
|
4615
4684
|
GPUBufferUsage.VERTEX
|
|
4616
|
-
), this.sphereIndexBuffer =
|
|
4685
|
+
), this.sphereIndexBuffer = St(
|
|
4617
4686
|
this.device,
|
|
4618
4687
|
e.indices,
|
|
4619
4688
|
GPUBufferUsage.INDEX
|
|
@@ -4628,7 +4697,7 @@ class Vr {
|
|
|
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
|
|
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 Vr {
|
|
|
4717
4786
|
}
|
|
4718
4787
|
}
|
|
4719
4788
|
}
|
|
4720
|
-
function
|
|
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
|
|
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
|
|
4730
|
-
const i =
|
|
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 =
|
|
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 kr(s, t, e) {
|
|
|
4745
4814
|
n[2],
|
|
4746
4815
|
i[2],
|
|
4747
4816
|
0,
|
|
4748
|
-
-
|
|
4749
|
-
-
|
|
4750
|
-
-
|
|
4817
|
+
-ri(r, s),
|
|
4818
|
+
-ri(n, s),
|
|
4819
|
+
-ri(i, s),
|
|
4751
4820
|
1
|
|
4752
4821
|
]);
|
|
4753
4822
|
}
|
|
4754
|
-
function
|
|
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 Xr(s, t = Math.PI / 4) {
|
|
|
4772
4841
|
0
|
|
4773
4842
|
]);
|
|
4774
4843
|
}
|
|
4775
|
-
function
|
|
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
|
|
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
|
|
4855
|
+
function ri(s, t) {
|
|
4787
4856
|
return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
|
|
4788
4857
|
}
|
|
4789
|
-
function
|
|
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 Ur(s, t) {
|
|
|
4797
4866
|
}
|
|
4798
4867
|
return e;
|
|
4799
4868
|
}
|
|
4800
|
-
const
|
|
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 si = 1481005640, Hi = 1, Zi = 1313821514, $i = 5130562, Et = "$hzfxAsset",
|
|
|
4805
4874
|
}
|
|
4806
4875
|
return Buffer.from(s).toString("base64");
|
|
4807
4876
|
};
|
|
4808
|
-
function
|
|
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) ?
|
|
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
|
|
4881
|
+
function Zi(s) {
|
|
4813
4882
|
return (4 - s % 4) % 4;
|
|
4814
4883
|
}
|
|
4815
|
-
async function
|
|
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 = (
|
|
4819
|
-
const
|
|
4820
|
-
r.push({ offset:
|
|
4821
|
-
const
|
|
4822
|
-
return
|
|
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
|
|
4825
|
-
const
|
|
4826
|
-
if (typeof
|
|
4827
|
-
let { mime:
|
|
4828
|
-
if (c &&
|
|
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
|
|
4831
|
-
|
|
4832
|
-
const q = await
|
|
4833
|
-
|
|
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
|
-
|
|
4905
|
+
G.textureImageData = { [Et]: o(re, H, "texture") };
|
|
4837
4906
|
}
|
|
4838
|
-
if (typeof
|
|
4839
|
-
const
|
|
4840
|
-
|
|
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(
|
|
4911
|
+
l.push(G);
|
|
4843
4912
|
}
|
|
4844
|
-
const d = { ...s, systems: l, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)),
|
|
4913
|
+
const d = { ...s, systems: l, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), b = Zi(S.length), p = new Uint8Array(a);
|
|
4845
4914
|
let v = 0;
|
|
4846
|
-
for (const
|
|
4847
|
-
p.set(
|
|
4848
|
-
const
|
|
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);
|
|
4849
4918
|
let T = 0;
|
|
4850
|
-
_.setUint32(T,
|
|
4851
|
-
for (let
|
|
4852
|
-
return _.setUint32(T, a, !0), T += 4, _.setUint32(T,
|
|
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
|
|
4855
|
-
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) ===
|
|
4923
|
+
function es(s) {
|
|
4924
|
+
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === ai;
|
|
4856
4925
|
}
|
|
4857
|
-
function
|
|
4926
|
+
function ts(s) {
|
|
4858
4927
|
const t = new DataView(s);
|
|
4859
|
-
if (t.getUint32(0, !0) !==
|
|
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 !==
|
|
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
|
|
4934
|
+
const b = t.getUint32(i, !0);
|
|
4866
4935
|
i += 4;
|
|
4867
4936
|
const p = t.getUint32(i, !0);
|
|
4868
|
-
i += 4, p ===
|
|
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 = (
|
|
4872
|
-
const p = o[
|
|
4940
|
+
const o = r.assets || [], c = (b) => {
|
|
4941
|
+
const p = o[b];
|
|
4873
4942
|
return !p || n < 0 ? null : { ...p, bytes: a.subarray(n + p.offset, n + p.offset + p.length) };
|
|
4874
|
-
}, l = (
|
|
4875
|
-
const p = { ...
|
|
4943
|
+
}, l = (b) => b && typeof b == "object" && typeof b[Et] == "number", d = (r.systems || []).map((b) => {
|
|
4944
|
+
const p = { ...b };
|
|
4876
4945
|
if (l(p.textureImageData)) {
|
|
4877
4946
|
const v = c(p.textureImageData[Et]);
|
|
4878
|
-
p.textureImageData = v ? `data:${v.mime};base64,${
|
|
4947
|
+
p.textureImageData = v ? `data:${v.mime};base64,${qi(v.bytes)}` : void 0;
|
|
4879
4948
|
}
|
|
4880
4949
|
if (l(p.glbModelData)) {
|
|
4881
4950
|
const v = c(p.glbModelData[Et]);
|
|
4882
|
-
p.glbModelData = v ?
|
|
4951
|
+
p.glbModelData = v ? qi(v.bytes) : void 0;
|
|
4883
4952
|
}
|
|
4884
4953
|
return p;
|
|
4885
4954
|
}), S = { ...r, systems: d };
|
|
4886
4955
|
return delete S.assets, S;
|
|
4887
4956
|
}
|
|
4888
|
-
function
|
|
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
|
|
4964
|
+
function Or(s) {
|
|
4896
4965
|
return {
|
|
4897
4966
|
name: s.name,
|
|
4898
4967
|
id: s.id,
|
|
@@ -5078,7 +5147,7 @@ function Gr(s) {
|
|
|
5078
5147
|
displayUnit: s.displayUnit || "m"
|
|
5079
5148
|
};
|
|
5080
5149
|
}
|
|
5081
|
-
async function
|
|
5150
|
+
async function qr(s, t, e = "hzfx") {
|
|
5082
5151
|
if (!s || !s.particleSystems || s.particleSystems.length === 0) {
|
|
5083
5152
|
alert("No particle systems to save.");
|
|
5084
5153
|
return;
|
|
@@ -5088,11 +5157,11 @@ async function Nr(s, t, e = "hzfx") {
|
|
|
5088
5157
|
version: "1.0",
|
|
5089
5158
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5090
5159
|
systems: s.particleSystems.map(({ config: d, system: S }) => ({
|
|
5091
|
-
...
|
|
5160
|
+
...Or(d),
|
|
5092
5161
|
// single source of truth for config fields
|
|
5093
5162
|
// Binary assets embedded so replaceSystems() can restore them
|
|
5094
5163
|
textureImageData: d.textureEnabled && !d.glbModelEnabled && d.textureImageData ? d.textureImageData : void 0,
|
|
5095
|
-
glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ?
|
|
5164
|
+
glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ? Vr(S.glbRawArrayBuffer) : void 0
|
|
5096
5165
|
})),
|
|
5097
5166
|
activeSystemIndex: s.activeSystemIndex,
|
|
5098
5167
|
loop: s.loop || !1
|
|
@@ -5100,7 +5169,7 @@ async function Nr(s, t, e = "hzfx") {
|
|
|
5100
5169
|
}, r = e === "json" ? "json" : "hzfx";
|
|
5101
5170
|
let n;
|
|
5102
5171
|
if (r === "hzfx") {
|
|
5103
|
-
const d = await
|
|
5172
|
+
const d = await Dr(i, { textureFormat: "webp" });
|
|
5104
5173
|
n = new Blob([d], { type: "application/octet-stream" });
|
|
5105
5174
|
} else
|
|
5106
5175
|
n = new Blob([JSON.stringify(i, null, 2)], { type: "application/json" });
|
|
@@ -5117,7 +5186,7 @@ async function Nr(s, t, e = "hzfx") {
|
|
|
5117
5186
|
console.error("Error saving scene:", i), alert("Error saving scene. See console for details.");
|
|
5118
5187
|
}
|
|
5119
5188
|
}
|
|
5120
|
-
function
|
|
5189
|
+
function Zr(s) {
|
|
5121
5190
|
return new Promise((t, e) => {
|
|
5122
5191
|
try {
|
|
5123
5192
|
const i = s.target.files[0];
|
|
@@ -5130,7 +5199,7 @@ function Yr(s) {
|
|
|
5130
5199
|
try {
|
|
5131
5200
|
const a = n.target.result;
|
|
5132
5201
|
let o;
|
|
5133
|
-
if (
|
|
5202
|
+
if (es(a) ? o = ts(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
|
|
5134
5203
|
throw new Error("No valid particle systems found in the file");
|
|
5135
5204
|
t({
|
|
5136
5205
|
systems: o.systems.slice(),
|
|
@@ -5148,7 +5217,7 @@ function Yr(s) {
|
|
|
5148
5217
|
}
|
|
5149
5218
|
});
|
|
5150
5219
|
}
|
|
5151
|
-
async function
|
|
5220
|
+
async function Hr(s) {
|
|
5152
5221
|
if (!s || typeof s != "string")
|
|
5153
5222
|
throw new Error("[fetchPreset] url must be a non-empty string");
|
|
5154
5223
|
const t = await fetch(s);
|
|
@@ -5156,7 +5225,7 @@ async function jr(s) {
|
|
|
5156
5225
|
throw new Error(`[fetchPreset] HTTP ${t.status}: ${t.statusText}`);
|
|
5157
5226
|
const e = await t.arrayBuffer();
|
|
5158
5227
|
let i;
|
|
5159
|
-
if (
|
|
5228
|
+
if (es(e) ? i = ts(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
|
|
5160
5229
|
throw new Error('[fetchPreset] Invalid preset: "systems" must be a non-empty array');
|
|
5161
5230
|
return {
|
|
5162
5231
|
version: i.version,
|
|
@@ -5164,7 +5233,7 @@ async function jr(s) {
|
|
|
5164
5233
|
activeSystemIndex: i.activeSystemIndex ?? 0
|
|
5165
5234
|
};
|
|
5166
5235
|
}
|
|
5167
|
-
const
|
|
5236
|
+
const Lr = (s) => `
|
|
5168
5237
|
@vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
|
|
5169
5238
|
var p = array<vec2f, 3>(vec2f(-1.0, -3.0), vec2f(-1.0, 1.0), vec2f(3.0, 1.0));
|
|
5170
5239
|
return vec4f(p[i], 0.0, 1.0);
|
|
@@ -5174,43 +5243,43 @@ const Dr = (s) => `
|
|
|
5174
5243
|
return textureLoad(src, vec2i(pos.xy), 0);
|
|
5175
5244
|
}
|
|
5176
5245
|
`;
|
|
5177
|
-
async function
|
|
5246
|
+
async function Wr(s, t = {}) {
|
|
5178
5247
|
const { getSceneDepth: e = null, autoRespawn: i = !0 } = t;
|
|
5179
5248
|
let r, n, a;
|
|
5180
5249
|
const o = !!(s && s.device && s.context);
|
|
5181
|
-
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await
|
|
5182
|
-
const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new
|
|
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: {} };
|
|
5183
5252
|
function S(u) {
|
|
5184
5253
|
const f = u ? "ms" : "ss";
|
|
5185
5254
|
if (!d.pipelines[f]) {
|
|
5186
|
-
const
|
|
5255
|
+
const m = r.createShaderModule({ code: Lr(u) }), g = r.createBindGroupLayout({
|
|
5187
5256
|
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: u } }]
|
|
5188
5257
|
});
|
|
5189
|
-
d.layouts[f] =
|
|
5190
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5191
|
-
vertex: { module:
|
|
5192
|
-
fragment: { module:
|
|
5258
|
+
d.layouts[f] = g, d.pipelines[f] = r.createRenderPipeline({
|
|
5259
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [g] }),
|
|
5260
|
+
vertex: { module: m, entryPoint: "vs" },
|
|
5261
|
+
fragment: { module: m, entryPoint: "fs", targets: [] },
|
|
5193
5262
|
primitive: { topology: "triangle-list" },
|
|
5194
5263
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
|
|
5195
5264
|
});
|
|
5196
5265
|
}
|
|
5197
5266
|
return { pipeline: d.pipelines[f], layout: d.layouts[f] };
|
|
5198
5267
|
}
|
|
5199
|
-
const
|
|
5268
|
+
const b = {
|
|
5200
5269
|
bloomSourceTextures: {},
|
|
5201
5270
|
bloomCompositeTextures: {},
|
|
5202
5271
|
combinedTexture: null,
|
|
5203
|
-
getBloomSourceTexture(u, f,
|
|
5272
|
+
getBloomSourceTexture(u, f, m) {
|
|
5204
5273
|
return this.bloomSourceTextures[u] || (this.bloomSourceTextures[u] = r.createTexture({
|
|
5205
|
-
size: [f,
|
|
5274
|
+
size: [f, m],
|
|
5206
5275
|
format: "rgba16float",
|
|
5207
5276
|
// HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
|
|
5208
5277
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5209
5278
|
})), this.bloomSourceTextures[u];
|
|
5210
5279
|
},
|
|
5211
|
-
getBloomCompositeTexture(u, f,
|
|
5280
|
+
getBloomCompositeTexture(u, f, m) {
|
|
5212
5281
|
return this.bloomCompositeTextures[u] || (this.bloomCompositeTextures[u] = r.createTexture({
|
|
5213
|
-
size: [f,
|
|
5282
|
+
size: [f, m],
|
|
5214
5283
|
format: "rgba16float",
|
|
5215
5284
|
// HDR chain
|
|
5216
5285
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
@@ -5243,323 +5312,332 @@ async function qr(s, t = {}) {
|
|
|
5243
5312
|
clear() {
|
|
5244
5313
|
this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
|
|
5245
5314
|
}
|
|
5246
|
-
}, v = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }),
|
|
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);
|
|
5247
5316
|
l.onSystemCreated = (u) => {
|
|
5248
|
-
T[u] || (T[u] =
|
|
5317
|
+
T[u] || (T[u] = F());
|
|
5249
5318
|
};
|
|
5250
|
-
const
|
|
5251
|
-
function
|
|
5252
|
-
for (const f of
|
|
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;
|
|
5253
5322
|
return null;
|
|
5254
5323
|
}
|
|
5255
|
-
function
|
|
5324
|
+
function is(u, f) {
|
|
5256
5325
|
if (!u.pos) return;
|
|
5257
5326
|
u.hist.push({ t: f, x: u.pos[0], y: u.pos[1], z: u.pos[2] });
|
|
5258
|
-
const
|
|
5259
|
-
for (; u.hist.length > 2 && u.hist[0].t <
|
|
5327
|
+
const m = f - kt;
|
|
5328
|
+
for (; u.hist.length > 2 && u.hist[0].t < m; ) u.hist.shift();
|
|
5260
5329
|
}
|
|
5261
|
-
function
|
|
5262
|
-
const
|
|
5263
|
-
if (
|
|
5330
|
+
function li(u, f, m) {
|
|
5331
|
+
const g = u.hist;
|
|
5332
|
+
if (g.length === 0) {
|
|
5264
5333
|
const R = u.pos;
|
|
5265
|
-
return R && (
|
|
5334
|
+
return R && (m[0] = R[0], m[1] = R[1], m[2] = R[2]), m;
|
|
5266
5335
|
}
|
|
5267
5336
|
let y;
|
|
5268
|
-
if (f >=
|
|
5269
|
-
return y =
|
|
5270
|
-
if (f <=
|
|
5271
|
-
return y =
|
|
5272
|
-
for (let R =
|
|
5273
|
-
if (
|
|
5274
|
-
const P =
|
|
5275
|
-
return
|
|
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;
|
|
5276
5345
|
}
|
|
5277
|
-
return y =
|
|
5346
|
+
return y = g[0], m[0] = y.x, m[1] = y.y, m[2] = y.z, m;
|
|
5278
5347
|
}
|
|
5279
|
-
const
|
|
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);
|
|
5280
5349
|
new Array(257), new Array(257), new Array(257);
|
|
5281
|
-
const
|
|
5282
|
-
function
|
|
5283
|
-
const f = u.emissionRotationX || 0,
|
|
5284
|
-
if (!f && !
|
|
5285
|
-
const y = f * Math.PI / 180, R =
|
|
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);
|
|
5286
5355
|
return [
|
|
5287
|
-
|
|
5288
|
-
x *
|
|
5289
|
-
M *
|
|
5290
|
-
|
|
5291
|
-
x *
|
|
5292
|
-
M *
|
|
5293
|
-
-
|
|
5294
|
-
x *
|
|
5295
|
-
M *
|
|
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
|
|
5296
5365
|
];
|
|
5297
5366
|
}
|
|
5298
|
-
function
|
|
5299
|
-
return y[0] = u[0] * f + u[1] *
|
|
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;
|
|
5300
5369
|
}
|
|
5301
|
-
function
|
|
5302
|
-
let M = u, x = f,
|
|
5303
|
-
|
|
5304
|
-
const
|
|
5305
|
-
return P[0] = M + (
|
|
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;
|
|
5306
5375
|
}
|
|
5307
|
-
function
|
|
5308
|
-
let P = u, M = f, x =
|
|
5309
|
-
return
|
|
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;
|
|
5310
5379
|
}
|
|
5311
|
-
function
|
|
5312
|
-
const R = f * 2, P =
|
|
5313
|
-
let x = (u % 1 + 1) % 1 * M,
|
|
5314
|
-
return x < R ? (
|
|
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;
|
|
5315
5384
|
}
|
|
5316
|
-
function
|
|
5317
|
-
const f = u.emissionShape,
|
|
5318
|
-
let
|
|
5319
|
-
const P =
|
|
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;
|
|
5320
5389
|
if (f === "circle") {
|
|
5321
|
-
y = !0,
|
|
5390
|
+
y = !0, g = Math.max(3, m), R = [0, 0, 1];
|
|
5322
5391
|
const M = u.circleOuterRadius ?? 2;
|
|
5323
|
-
for (let x = 0; x <
|
|
5324
|
-
const
|
|
5325
|
-
|
|
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;
|
|
5326
5395
|
}
|
|
5327
5396
|
} else if (f === "disc") {
|
|
5328
|
-
y = !0,
|
|
5397
|
+
y = !0, g = Math.max(3, m), R = [0, 1, 0];
|
|
5329
5398
|
const M = u.discRadius ?? 2;
|
|
5330
|
-
for (let x = 0; x <
|
|
5331
|
-
const
|
|
5332
|
-
|
|
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;
|
|
5333
5402
|
}
|
|
5334
5403
|
} else if (f === "annulus") {
|
|
5335
|
-
y = !0,
|
|
5336
|
-
const M = u.annulusInnerRadius ?? 1, x = u.annulusOuterRadius ?? 2,
|
|
5337
|
-
for (let
|
|
5338
|
-
const
|
|
5339
|
-
|
|
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;
|
|
5340
5409
|
}
|
|
5341
5410
|
} else if (f === "arc") {
|
|
5342
|
-
y = !1,
|
|
5343
|
-
const M = u.arcInnerRadius ?? 0, x = u.arcOuterRadius ?? 2,
|
|
5344
|
-
for (let C = 0; C <
|
|
5345
|
-
const
|
|
5346
|
-
|
|
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;
|
|
5347
5416
|
}
|
|
5348
5417
|
} else if (f === "square") {
|
|
5349
|
-
y = !0,
|
|
5418
|
+
y = !0, g = Math.max(4, m), R = [0, 0, 1];
|
|
5350
5419
|
const M = u.squareSize ?? 2;
|
|
5351
|
-
for (let x = 0; x <
|
|
5352
|
-
|
|
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];
|
|
5353
5422
|
} else if (f === "rectangle") {
|
|
5354
|
-
y = !0,
|
|
5423
|
+
y = !0, g = Math.max(4, m), R = [0, 0, 1];
|
|
5355
5424
|
const M = (u.rectangleWidth ?? 2) * 0.5, x = (u.rectangleHeight ?? 2) * 0.5;
|
|
5356
|
-
for (let
|
|
5357
|
-
|
|
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];
|
|
5358
5427
|
} else if (f === "plain") {
|
|
5359
|
-
y = !0,
|
|
5428
|
+
y = !0, g = Math.max(4, m), R = [0, 1, 0];
|
|
5360
5429
|
const M = (u.planeWidth ?? 2) * 0.5, x = (u.planeDepth ?? 2) * 0.5;
|
|
5361
|
-
for (let
|
|
5362
|
-
|
|
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];
|
|
5363
5432
|
} else if (f === "line") {
|
|
5364
|
-
y = !1,
|
|
5433
|
+
y = !1, g = Math.max(2, m + 1), R = [0, 0, 1];
|
|
5365
5434
|
const M = u.lineLength ?? 4;
|
|
5366
|
-
for (let x = 0; x <
|
|
5367
|
-
const
|
|
5368
|
-
|
|
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;
|
|
5369
5438
|
}
|
|
5370
5439
|
} else if (f === "polygon") {
|
|
5371
|
-
y = !0,
|
|
5440
|
+
y = !0, g = Math.max(3, m), R = [0, 0, 1];
|
|
5372
5441
|
const M = Math.max(3, Math.floor(u.polygonSides ?? 6)), x = u.polygonRadius ?? 2;
|
|
5373
|
-
for (let
|
|
5374
|
-
const
|
|
5375
|
-
|
|
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;
|
|
5376
5445
|
}
|
|
5377
5446
|
} else
|
|
5378
|
-
|
|
5379
|
-
return { count:
|
|
5380
|
-
}
|
|
5381
|
-
function
|
|
5382
|
-
if (!
|
|
5383
|
-
const { count:
|
|
5384
|
-
if (
|
|
5385
|
-
const P =
|
|
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);
|
|
5386
5455
|
if (x <= 0) return u;
|
|
5387
|
-
|
|
5388
|
-
let
|
|
5389
|
-
const
|
|
5390
|
-
for (let
|
|
5391
|
-
|
|
5392
|
-
const
|
|
5393
|
-
if (
|
|
5394
|
-
const
|
|
5395
|
-
for (let
|
|
5396
|
-
const
|
|
5397
|
-
let
|
|
5398
|
-
|
|
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;
|
|
5399
5468
|
}
|
|
5400
5469
|
}
|
|
5401
|
-
const
|
|
5402
|
-
let
|
|
5403
|
-
for (let
|
|
5404
|
-
const
|
|
5405
|
-
|
|
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]);
|
|
5406
5475
|
}
|
|
5407
|
-
const
|
|
5408
|
-
let
|
|
5409
|
-
for (let
|
|
5410
|
-
const
|
|
5411
|
-
let
|
|
5412
|
-
const
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
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;
|
|
5419
5491
|
}
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
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;
|
|
5426
5504
|
};
|
|
5427
|
-
|
|
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;
|
|
5428
5506
|
}
|
|
5429
5507
|
return u;
|
|
5430
5508
|
}
|
|
5431
|
-
const
|
|
5432
|
-
function
|
|
5433
|
-
|
|
5434
|
-
let u = 0, f = 0,
|
|
5435
|
-
|
|
5436
|
-
for (const { system:
|
|
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) {
|
|
5437
5515
|
if (y.hidden) continue;
|
|
5438
5516
|
if (y.emissionTrailEnabled && !y.glbModelEnabled) {
|
|
5439
|
-
|
|
5440
|
-
const P =
|
|
5517
|
+
g.readbackAndProcessParticles();
|
|
5518
|
+
const P = g.particleData, M = g.particleVelocities, x = g.activeParticles;
|
|
5441
5519
|
if (P && M && x > 0) {
|
|
5442
|
-
const
|
|
5443
|
-
for (let
|
|
5444
|
-
const
|
|
5445
|
-
let
|
|
5446
|
-
const
|
|
5447
|
-
if (
|
|
5448
|
-
const
|
|
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;
|
|
5449
5527
|
if (y.colorTransitionEnabled) {
|
|
5450
|
-
const
|
|
5451
|
-
|
|
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;
|
|
5452
5530
|
}
|
|
5453
|
-
|
|
5454
|
-
let
|
|
5531
|
+
te = Math.min(1, te * O), ye = Math.min(1, ye * O), J = Math.min(1, J * O);
|
|
5532
|
+
let ue = Z;
|
|
5455
5533
|
if (y.randomSize) {
|
|
5456
|
-
const
|
|
5457
|
-
|
|
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;
|
|
5458
5536
|
}
|
|
5459
5537
|
if (y.fadeSizeEnabled) {
|
|
5460
|
-
const
|
|
5461
|
-
|
|
5538
|
+
const A = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
|
|
5539
|
+
ue *= 1 - Math.pow(ie, 1 / A);
|
|
5462
5540
|
}
|
|
5463
5541
|
if (y.increaseSizeEnabled) {
|
|
5464
|
-
const
|
|
5465
|
-
|
|
5542
|
+
const A = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
|
|
5543
|
+
ue *= 1 + Math.pow(ie, 1 / A);
|
|
5466
5544
|
}
|
|
5467
|
-
if (
|
|
5468
|
-
const
|
|
5469
|
-
let
|
|
5470
|
-
if (y.fadeEnabled && (
|
|
5471
|
-
const
|
|
5472
|
-
if (
|
|
5473
|
-
const
|
|
5474
|
-
let
|
|
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);
|
|
5475
5553
|
if (st < 0.2) {
|
|
5476
|
-
const
|
|
5477
|
-
|
|
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;
|
|
5478
5556
|
}
|
|
5479
|
-
|
|
5480
|
-
const
|
|
5481
|
-
if (
|
|
5482
|
-
const
|
|
5483
|
-
if (y.orientToDirection && y.burstMode &&
|
|
5484
|
-
const
|
|
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;
|
|
5485
5563
|
for (let k = 0; k <= L; k++) {
|
|
5486
|
-
const j =
|
|
5487
|
-
|
|
5564
|
+
const j = li(qe, Ve - k / L * rt, Pi);
|
|
5565
|
+
X[k] = j[0], fe[k] = j[1], Y[k] = j[2];
|
|
5488
5566
|
}
|
|
5489
5567
|
for (let k = 0; k <= L; k++) {
|
|
5490
|
-
const j = k > 0 ? k - 1 : 0,
|
|
5491
|
-
let
|
|
5492
|
-
const
|
|
5493
|
-
|
|
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];
|
|
5494
5572
|
}
|
|
5495
|
-
} else for (let
|
|
5496
|
-
const
|
|
5497
|
-
if (
|
|
5498
|
-
const Y =
|
|
5499
|
-
|
|
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];
|
|
5500
5578
|
} else
|
|
5501
|
-
|
|
5579
|
+
He[A] = Ie - me * X, We[A] = $ - we * X + fe, $e[A] = pe - Be * X;
|
|
5502
5580
|
}
|
|
5503
5581
|
if (N !== "straight") {
|
|
5504
|
-
const
|
|
5505
|
-
let Y = -
|
|
5506
|
-
|
|
5507
|
-
const
|
|
5508
|
-
for (let
|
|
5509
|
-
const
|
|
5510
|
-
let
|
|
5511
|
-
N === "zigzag" ?
|
|
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;
|
|
5512
5590
|
}
|
|
5513
5591
|
}
|
|
5514
|
-
if (
|
|
5515
|
-
for (let
|
|
5516
|
-
const
|
|
5517
|
-
|
|
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++;
|
|
5518
5596
|
}
|
|
5519
5597
|
else
|
|
5520
|
-
for (let
|
|
5521
|
-
const
|
|
5522
|
-
|
|
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;
|
|
5523
5601
|
};
|
|
5524
|
-
|
|
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);
|
|
5525
5603
|
}
|
|
5526
5604
|
}
|
|
5527
|
-
|
|
5605
|
+
B && u > h && xt.set(y.id, { first: h, count: u - h });
|
|
5528
5606
|
}
|
|
5529
5607
|
}
|
|
5530
|
-
const R =
|
|
5531
|
-
|
|
5608
|
+
const R = m;
|
|
5609
|
+
m = os(m, g, y), m > R && Xe.set(y.id, { first: R / 9, count: (m - R) / 9 });
|
|
5532
5610
|
}
|
|
5533
|
-
u > 0 && (r.queue.writeBuffer(
|
|
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);
|
|
5534
5612
|
}
|
|
5535
|
-
const
|
|
5536
|
-
r.queue.writeBuffer(
|
|
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]));
|
|
5537
5615
|
};
|
|
5538
|
-
|
|
5539
|
-
const
|
|
5540
|
-
|
|
5541
|
-
const
|
|
5542
|
-
particlePipeline:
|
|
5543
|
-
particleAdditivePipeline:
|
|
5544
|
-
particleDepthWritePipeline:
|
|
5545
|
-
blurPipeline:
|
|
5546
|
-
compositePipeline:
|
|
5547
|
-
directRenderPipeline:
|
|
5548
|
-
finalCompositePipeline:
|
|
5549
|
-
glbMeshPipeline:
|
|
5550
|
-
} =
|
|
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: `
|
|
5551
5629
|
struct U { mvp: mat4x4<f32> };
|
|
5552
5630
|
@group(0) @binding(0) var<uniform> u: U;
|
|
5553
5631
|
struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
|
|
5554
5632
|
struct VOut { @builtin(position) pos: vec4<f32>, @location(0) col: vec4<f32> };
|
|
5555
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; }
|
|
5556
5634
|
@fragment fn fs(i: VOut) -> @location(0) vec4<f32> { return i.col; }
|
|
5557
|
-
` }),
|
|
5635
|
+
` }), pi = r.createBindGroupLayout({
|
|
5558
5636
|
entries: [{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } }]
|
|
5559
|
-
}),
|
|
5560
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5637
|
+
}), ys = r.createRenderPipeline({
|
|
5638
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [pi] }),
|
|
5561
5639
|
vertex: {
|
|
5562
|
-
module:
|
|
5640
|
+
module: fi,
|
|
5563
5641
|
entryPoint: "vs",
|
|
5564
5642
|
buffers: [{ arrayStride: 28, attributes: [
|
|
5565
5643
|
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
@@ -5567,7 +5645,7 @@ async function qr(s, t = {}) {
|
|
|
5567
5645
|
] }]
|
|
5568
5646
|
},
|
|
5569
5647
|
fragment: {
|
|
5570
|
-
module:
|
|
5648
|
+
module: fi,
|
|
5571
5649
|
entryPoint: "fs",
|
|
5572
5650
|
targets: [{ format: "rgba16float", blend: {
|
|
5573
5651
|
// renders into the HDR sceneTexture
|
|
@@ -5579,16 +5657,16 @@ async function qr(s, t = {}) {
|
|
|
5579
5657
|
// depth24plus to match the non-bloom pass; test against the resolved scene depth
|
|
5580
5658
|
// (occlusion) but don't write (transparent ribbon).
|
|
5581
5659
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5582
|
-
}),
|
|
5583
|
-
size:
|
|
5660
|
+
}), hi = 512 * 64 * 6, Ye = new Float32Array(hi * 7), qt = r.createBuffer({
|
|
5661
|
+
size: hi * 7 * 4,
|
|
5584
5662
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5585
5663
|
label: "ribbonBuffer"
|
|
5586
|
-
}),
|
|
5587
|
-
layout:
|
|
5664
|
+
}), gs = r.createBindGroup({
|
|
5665
|
+
layout: pi,
|
|
5588
5666
|
entries: [{ binding: 0, resource: { buffer: v } }]
|
|
5589
5667
|
});
|
|
5590
|
-
let
|
|
5591
|
-
const
|
|
5668
|
+
let vt = 0;
|
|
5669
|
+
const mi = r.createShaderModule({ code: `
|
|
5592
5670
|
struct Uniforms {
|
|
5593
5671
|
transform: mat4x4<f32>,
|
|
5594
5672
|
cameraPosition: vec3<f32>,
|
|
@@ -5717,10 +5795,10 @@ async function qr(s, t = {}) {
|
|
|
5717
5795
|
}
|
|
5718
5796
|
return vec4<f32>(i.col, i.alpha);
|
|
5719
5797
|
}
|
|
5720
|
-
` }),
|
|
5721
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5798
|
+
` }), yi = (u) => r.createRenderPipeline({
|
|
5799
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [Ne.particleBindGroupLayout] }),
|
|
5722
5800
|
vertex: {
|
|
5723
|
-
module:
|
|
5801
|
+
module: mi,
|
|
5724
5802
|
entryPoint: "vs",
|
|
5725
5803
|
buffers: [{ arrayStride: 36, attributes: [
|
|
5726
5804
|
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
@@ -5729,32 +5807,32 @@ async function qr(s, t = {}) {
|
|
|
5729
5807
|
] }]
|
|
5730
5808
|
},
|
|
5731
5809
|
fragment: {
|
|
5732
|
-
module:
|
|
5810
|
+
module: mi,
|
|
5733
5811
|
entryPoint: "fs",
|
|
5734
5812
|
targets: [{ format: "rgba16float", blend: u }]
|
|
5735
5813
|
},
|
|
5736
5814
|
primitive: { topology: "triangle-list" },
|
|
5737
5815
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5738
|
-
}),
|
|
5816
|
+
}), bs = yi({
|
|
5739
5817
|
color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
5740
5818
|
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5741
|
-
}),
|
|
5819
|
+
}), Ss = yi({
|
|
5742
5820
|
color: { srcFactor: "src-alpha", dstFactor: "one", operation: "add" },
|
|
5743
5821
|
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5744
|
-
}),
|
|
5745
|
-
size:
|
|
5822
|
+
}), gi = 256 * 256 * 6, Ce = new Float32Array(gi * 9), Zt = r.createBuffer({
|
|
5823
|
+
size: gi * 9 * 4,
|
|
5746
5824
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5747
5825
|
label: "shapeStrokeBuffer"
|
|
5748
5826
|
});
|
|
5749
|
-
let
|
|
5750
|
-
const
|
|
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 = () => {
|
|
5751
5829
|
const u = (f) => f.createView();
|
|
5752
|
-
|
|
5830
|
+
ht = u(at), Si = u(ot), Ft = u(lt), Pt = u(zt);
|
|
5753
5831
|
};
|
|
5754
|
-
|
|
5755
|
-
const
|
|
5756
|
-
let
|
|
5757
|
-
const
|
|
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 = {
|
|
5758
5836
|
mvp: new Float32Array(16),
|
|
5759
5837
|
position: new Float32Array([0, 0, 10]),
|
|
5760
5838
|
right: new Float32Array([1, 0, 0]),
|
|
@@ -5762,189 +5840,189 @@ async function qr(s, t = {}) {
|
|
|
5762
5840
|
up: new Float32Array([0, 1, 0]),
|
|
5763
5841
|
hasCamera: !1
|
|
5764
5842
|
};
|
|
5765
|
-
let
|
|
5766
|
-
const
|
|
5767
|
-
let
|
|
5768
|
-
function
|
|
5769
|
-
const u = [
|
|
5770
|
-
|
|
5771
|
-
let
|
|
5772
|
-
const
|
|
5773
|
-
if (!
|
|
5774
|
-
|
|
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;
|
|
5850
|
+
const g = () => {
|
|
5851
|
+
if (!m) {
|
|
5852
|
+
m = !0, requestAnimationFrame(g);
|
|
5775
5853
|
return;
|
|
5776
5854
|
}
|
|
5777
5855
|
u.forEach((y) => y.destroy());
|
|
5778
5856
|
};
|
|
5779
|
-
requestAnimationFrame(
|
|
5857
|
+
requestAnimationFrame(g);
|
|
5780
5858
|
}
|
|
5781
|
-
function
|
|
5782
|
-
|
|
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;
|
|
5783
5861
|
}
|
|
5784
|
-
function
|
|
5785
|
-
|
|
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;
|
|
5786
5864
|
}
|
|
5787
|
-
async function
|
|
5788
|
-
if (
|
|
5789
|
-
|
|
5865
|
+
async function Kt(u) {
|
|
5866
|
+
if (Dt) {
|
|
5867
|
+
Vt = u;
|
|
5790
5868
|
return;
|
|
5791
5869
|
}
|
|
5792
|
-
|
|
5870
|
+
Dt = !0;
|
|
5793
5871
|
try {
|
|
5794
5872
|
for (const f in T) delete T[f];
|
|
5795
|
-
p.clear(),
|
|
5873
|
+
p.clear(), b.resizeTextures(), Gt = si(r, De, Ht, { sceneTexture: at, bloomTexA: ot, bloomTexB: lt }), await l.replaceSystems({ systems: [], activeSystemIndex: 0 });
|
|
5796
5874
|
for (const f of u)
|
|
5797
5875
|
await l.addSystems(f.preset, f.position || [0, 0, 0]);
|
|
5798
5876
|
for (const { config: f } of l.particleSystems)
|
|
5799
|
-
T[f.id] || (T[f.id] =
|
|
5800
|
-
|
|
5877
|
+
T[f.id] || (T[f.id] = F());
|
|
5878
|
+
Wt = !0, l.respawnAllSystems();
|
|
5801
5879
|
} finally {
|
|
5802
|
-
if (
|
|
5803
|
-
const f =
|
|
5804
|
-
|
|
5880
|
+
if (Dt = !1, Vt) {
|
|
5881
|
+
const f = Vt;
|
|
5882
|
+
Vt = null, Kt(f);
|
|
5805
5883
|
}
|
|
5806
5884
|
}
|
|
5807
5885
|
}
|
|
5808
|
-
async function
|
|
5809
|
-
return
|
|
5886
|
+
async function As(u, f = [0, 0, 0]) {
|
|
5887
|
+
return Kt([{ preset: u, position: f }]);
|
|
5810
5888
|
}
|
|
5811
|
-
function
|
|
5812
|
-
if (
|
|
5889
|
+
function Es(u) {
|
|
5890
|
+
if (_i || Dt || !l.ready || u <= 0 || l.particleSystems.length === 0) return;
|
|
5813
5891
|
const f = l.clock;
|
|
5814
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;
|
|
5815
|
-
if ((a.width !==
|
|
5816
|
-
for (const
|
|
5817
|
-
if (
|
|
5818
|
-
const
|
|
5819
|
-
|
|
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;
|
|
5820
5898
|
}
|
|
5821
|
-
|
|
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);
|
|
5822
5900
|
}
|
|
5823
|
-
for (const { system:
|
|
5824
|
-
const C =
|
|
5825
|
-
if (!(!C || C.historyOnly) && (
|
|
5826
|
-
let
|
|
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;
|
|
5827
5905
|
if (C.orientToDirection && C.vel) {
|
|
5828
|
-
const
|
|
5829
|
-
Math.hypot(
|
|
5906
|
+
const O = C.vel[0], L = C.vel[2];
|
|
5907
|
+
Math.hypot(O, L) > 1e-4 && (Z = [0, 0, Math.atan2(O, L)]);
|
|
5830
5908
|
}
|
|
5831
|
-
|
|
5909
|
+
h.setSimulationTransform({ position: C.pos, velocity: C.vel, rotation: Z }), h.updateAppearanceUniform(), (C.justResumed || h.activeParticles === 0) && h.spawnParticles();
|
|
5832
5910
|
}
|
|
5833
5911
|
}
|
|
5834
|
-
for (const
|
|
5835
|
-
|
|
5836
|
-
if (globalThis.__HZFX_DEBUG && (
|
|
5837
|
-
const
|
|
5838
|
-
console.info(`[HZFX] movingGroups(${
|
|
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)}`);
|
|
5839
5917
|
}
|
|
5840
5918
|
}
|
|
5841
5919
|
if (l.updateAllSystems(u), f ? f.loop : l.loop ?? i) {
|
|
5842
|
-
const
|
|
5843
|
-
(f && f.justLooped ||
|
|
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;
|
|
5844
5922
|
}
|
|
5845
|
-
for (const { system:
|
|
5846
|
-
|
|
5847
|
-
r.queue.writeBuffer(v, 0,
|
|
5848
|
-
const
|
|
5849
|
-
({ system:
|
|
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))
|
|
5850
5928
|
), y = r.createCommandEncoder();
|
|
5851
5929
|
let R = !1;
|
|
5852
5930
|
if (e)
|
|
5853
5931
|
try {
|
|
5854
|
-
const
|
|
5855
|
-
if (
|
|
5856
|
-
let
|
|
5857
|
-
if (
|
|
5858
|
-
const { pipeline:
|
|
5859
|
-
(
|
|
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({
|
|
5860
5938
|
layout: L,
|
|
5861
5939
|
entries: [{ binding: 0, resource: C() }]
|
|
5862
5940
|
}));
|
|
5863
5941
|
const N = y.beginRenderPass({
|
|
5864
5942
|
colorAttachments: [],
|
|
5865
|
-
depthStencilAttachment: { view:
|
|
5943
|
+
depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5866
5944
|
});
|
|
5867
|
-
N.setPipeline(
|
|
5945
|
+
N.setPipeline(O), N.setBindGroup(0, yt.bindGroup), N.draw(3), N.end(), R = !0;
|
|
5868
5946
|
}
|
|
5869
5947
|
}
|
|
5870
5948
|
} catch {
|
|
5871
5949
|
}
|
|
5872
5950
|
const P = y.beginRenderPass({
|
|
5873
|
-
colorAttachments: [{ view:
|
|
5874
|
-
depthStencilAttachment: R ? { view:
|
|
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" }
|
|
5875
5953
|
});
|
|
5876
|
-
for (const { system:
|
|
5877
|
-
|
|
5878
|
-
if (
|
|
5879
|
-
const
|
|
5880
|
-
colorAttachments: [{ view:
|
|
5881
|
-
},
|
|
5882
|
-
colorAttachments: [{ view:
|
|
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 } }]
|
|
5883
5961
|
};
|
|
5884
|
-
for (const { system: C, config:
|
|
5885
|
-
if (!
|
|
5886
|
-
const
|
|
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({
|
|
5887
5965
|
colorAttachments: [{ view: L.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5888
|
-
depthStencilAttachment: { view:
|
|
5966
|
+
depthStencilAttachment: { view: Pt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
5889
5967
|
});
|
|
5890
|
-
|
|
5891
|
-
layout:
|
|
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,
|
|
5892
5970
|
entries: [
|
|
5893
|
-
{ binding: 0, resource:
|
|
5971
|
+
{ binding: 0, resource: De },
|
|
5894
5972
|
{ binding: 1, resource: L.createView() },
|
|
5895
|
-
{ binding: 2, resource: { buffer:
|
|
5973
|
+
{ binding: 2, resource: { buffer: I } }
|
|
5896
5974
|
]
|
|
5897
5975
|
}));
|
|
5898
|
-
let
|
|
5899
|
-
|
|
5900
|
-
layout:
|
|
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,
|
|
5901
5979
|
entries: [
|
|
5902
|
-
{ binding: 0, resource:
|
|
5903
|
-
{ binding: 1, resource:
|
|
5904
|
-
{ binding: 2, resource: { buffer:
|
|
5980
|
+
{ binding: 0, resource: De },
|
|
5981
|
+
{ binding: 1, resource: Ft },
|
|
5982
|
+
{ binding: 2, resource: { buffer: I } }
|
|
5905
5983
|
]
|
|
5906
|
-
})),
|
|
5907
|
-
const
|
|
5908
|
-
|
|
5909
|
-
colorAttachments: [{ view:
|
|
5910
|
-
}),
|
|
5911
|
-
layout:
|
|
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,
|
|
5912
5990
|
entries: [
|
|
5913
|
-
{ binding: 0, resource:
|
|
5991
|
+
{ binding: 0, resource: De },
|
|
5914
5992
|
{ binding: 1, resource: L.createView() },
|
|
5915
|
-
{ binding: 2, resource:
|
|
5993
|
+
{ binding: 2, resource: Ft },
|
|
5916
5994
|
{ binding: 3, resource: { buffer: C.bloomIntensityBuffer } }
|
|
5917
5995
|
]
|
|
5918
|
-
})),
|
|
5996
|
+
})), V.setBindGroup(0, p.systemBloomCompositeBindGroups[O]), V.draw(3), V.end();
|
|
5919
5997
|
}
|
|
5920
5998
|
}
|
|
5921
|
-
const M =
|
|
5999
|
+
const M = b.getCombinedTexture(a.width, a.height), x = y.beginRenderPass({
|
|
5922
6000
|
colorAttachments: [{ view: M.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5923
6001
|
});
|
|
5924
|
-
x.setPipeline(
|
|
5925
|
-
layout:
|
|
6002
|
+
x.setPipeline(di), p.combinedInitialBindGroup || (p.combinedInitialBindGroup = r.createBindGroup({
|
|
6003
|
+
layout: Ne.compositeBindGroupLayout,
|
|
5926
6004
|
entries: [
|
|
5927
|
-
{ binding: 0, resource:
|
|
5928
|
-
{ binding: 1, resource:
|
|
5929
|
-
{ binding: 2, resource:
|
|
6005
|
+
{ binding: 0, resource: De },
|
|
6006
|
+
{ binding: 1, resource: ht },
|
|
6007
|
+
{ binding: 2, resource: ht },
|
|
5930
6008
|
{ binding: 3, resource: { buffer: _ } }
|
|
5931
6009
|
]
|
|
5932
6010
|
})), x.setBindGroup(0, p.combinedInitialBindGroup), x.draw(3);
|
|
5933
|
-
for (const { config:
|
|
5934
|
-
if (!
|
|
5935
|
-
const C =
|
|
5936
|
-
x.setPipeline(
|
|
5937
|
-
layout:
|
|
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,
|
|
5938
6016
|
entries: [
|
|
5939
|
-
{ binding: 0, resource:
|
|
5940
|
-
{ binding: 1, resource:
|
|
5941
|
-
{ binding: 2, resource:
|
|
6017
|
+
{ binding: 0, resource: De },
|
|
6018
|
+
{ binding: 1, resource: b.getBloomCompositeTexture(C, a.width, a.height).createView() },
|
|
6019
|
+
{ binding: 2, resource: ht },
|
|
5942
6020
|
{ binding: 3, resource: { buffer: _ } }
|
|
5943
6021
|
]
|
|
5944
6022
|
})), x.setBindGroup(0, p.combinedBloomCompositeBindGroups[C]), x.draw(3);
|
|
5945
6023
|
}
|
|
5946
6024
|
x.end();
|
|
5947
|
-
const
|
|
6025
|
+
const B = y.beginRenderPass({
|
|
5948
6026
|
colorAttachments: [{
|
|
5949
6027
|
view: n.getCurrentTexture().createView(),
|
|
5950
6028
|
loadOp: o ? "load" : "clear",
|
|
@@ -5952,112 +6030,112 @@ async function qr(s, t = {}) {
|
|
|
5952
6030
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
5953
6031
|
}]
|
|
5954
6032
|
});
|
|
5955
|
-
|
|
5956
|
-
layout:
|
|
6033
|
+
B.setPipeline(hs), p.finalBindGroup || (p.finalBindGroup = r.createBindGroup({
|
|
6034
|
+
layout: Ne.compositeBindGroupLayout,
|
|
5957
6035
|
entries: [
|
|
5958
|
-
{ binding: 0, resource:
|
|
6036
|
+
{ binding: 0, resource: De },
|
|
5959
6037
|
{ binding: 1, resource: M.createView() },
|
|
5960
|
-
{ binding: 2, resource:
|
|
6038
|
+
{ binding: 2, resource: ht },
|
|
5961
6039
|
{ binding: 3, resource: { buffer: _ } }
|
|
5962
6040
|
]
|
|
5963
|
-
})),
|
|
6041
|
+
})), B.setBindGroup(0, p.finalBindGroup), B.draw(3), B.end(), r.queue.submit([y.finish()]);
|
|
5964
6042
|
}
|
|
5965
|
-
function
|
|
5966
|
-
const
|
|
5967
|
-
return p.textureStates[
|
|
5968
|
-
layout:
|
|
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,
|
|
5969
6047
|
entries: [
|
|
5970
6048
|
{ binding: 0, resource: { buffer: v } },
|
|
5971
6049
|
{ binding: 1, resource: { buffer: u.appearanceUniformBuffer } },
|
|
5972
6050
|
{ binding: 2, resource: u.particleTexture.createView() },
|
|
5973
|
-
{ binding: 3, resource:
|
|
6051
|
+
{ binding: 3, resource: De }
|
|
5974
6052
|
]
|
|
5975
|
-
})), p.systemBindGroups[
|
|
6053
|
+
})), p.systemBindGroups[m];
|
|
5976
6054
|
}
|
|
5977
|
-
function
|
|
5978
|
-
const
|
|
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;
|
|
5979
6057
|
if (y)
|
|
5980
|
-
P && (u.setPipeline(
|
|
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));
|
|
5981
6059
|
else {
|
|
5982
|
-
u.setPipeline(
|
|
5983
|
-
const M =
|
|
5984
|
-
M && (u.setVertexBuffer(1,
|
|
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));
|
|
5985
6063
|
}
|
|
5986
6064
|
}
|
|
5987
|
-
function
|
|
5988
|
-
const
|
|
5989
|
-
!
|
|
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));
|
|
5990
6068
|
}
|
|
5991
|
-
function
|
|
5992
|
-
|
|
6069
|
+
function Cs() {
|
|
6070
|
+
$t = a.width, Jt = a.height, Mi();
|
|
5993
6071
|
}
|
|
5994
|
-
function
|
|
6072
|
+
function Us() {
|
|
5995
6073
|
p.clear();
|
|
5996
6074
|
}
|
|
5997
|
-
function
|
|
5998
|
-
|
|
6075
|
+
function Is() {
|
|
6076
|
+
_i = !0, l.destroy(), [at, ot, lt, zt].forEach((u) => u == null ? void 0 : u.destroy()), b.resizeTextures(), [
|
|
5999
6077
|
v,
|
|
6000
|
-
|
|
6001
|
-
U,
|
|
6078
|
+
E,
|
|
6002
6079
|
I,
|
|
6080
|
+
z,
|
|
6003
6081
|
_,
|
|
6004
|
-
|
|
6005
|
-
|
|
6082
|
+
W,
|
|
6083
|
+
ne,
|
|
6006
6084
|
q,
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6085
|
+
tt,
|
|
6086
|
+
qt,
|
|
6087
|
+
Zt
|
|
6010
6088
|
].forEach((u) => u == null ? void 0 : u.destroy()), Object.values(T).forEach((u) => u == null ? void 0 : u.destroy());
|
|
6011
6089
|
}
|
|
6012
|
-
async function
|
|
6013
|
-
const
|
|
6014
|
-
for (const { config:
|
|
6015
|
-
T[
|
|
6016
|
-
return l.respawnAllSystems(), new Set(Array.isArray(
|
|
6090
|
+
async function Ti(u, f) {
|
|
6091
|
+
const m = await l.addSystems(u, f);
|
|
6092
|
+
for (const { config: g } of l.particleSystems)
|
|
6093
|
+
T[g.id] || (T[g.id] = F());
|
|
6094
|
+
return l.respawnAllSystems(), new Set(Array.isArray(m) ? m : []);
|
|
6017
6095
|
}
|
|
6018
|
-
function
|
|
6096
|
+
function Ai(u) {
|
|
6019
6097
|
for (const f of u) {
|
|
6020
|
-
const
|
|
6021
|
-
|
|
6098
|
+
const m = l.particleSystems.findIndex((g) => g.config.id === f);
|
|
6099
|
+
m >= 0 && l.removeSystem(m);
|
|
6022
6100
|
}
|
|
6023
6101
|
}
|
|
6024
|
-
async function
|
|
6025
|
-
const
|
|
6102
|
+
async function zs(u, f = [0, 0, 0]) {
|
|
6103
|
+
const m = await Ti(u, f);
|
|
6026
6104
|
return { remove() {
|
|
6027
|
-
|
|
6105
|
+
Ai(m);
|
|
6028
6106
|
} };
|
|
6029
6107
|
}
|
|
6030
|
-
async function
|
|
6031
|
-
const
|
|
6032
|
-
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...
|
|
6033
|
-
const
|
|
6034
|
-
return
|
|
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), {
|
|
6035
6113
|
setPosition(y) {
|
|
6036
|
-
y && (
|
|
6114
|
+
y && (g.pos = Array.isArray(y) ? [y[0], y[1], y[2]] : [y.x, y.y, y.z]);
|
|
6037
6115
|
},
|
|
6038
6116
|
setOrientToDirection(y) {
|
|
6039
|
-
|
|
6117
|
+
g.orientToDirection = !!y;
|
|
6040
6118
|
},
|
|
6041
6119
|
remove() {
|
|
6042
|
-
|
|
6043
|
-
const y =
|
|
6044
|
-
y >= 0 &&
|
|
6120
|
+
Ai(m);
|
|
6121
|
+
const y = _e.indexOf(g);
|
|
6122
|
+
y >= 0 && _e.splice(y, 1);
|
|
6045
6123
|
}
|
|
6046
6124
|
};
|
|
6047
6125
|
}
|
|
6048
|
-
function
|
|
6049
|
-
const
|
|
6050
|
-
return
|
|
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), {
|
|
6051
6129
|
remove() {
|
|
6052
|
-
const y =
|
|
6053
|
-
y >= 0 &&
|
|
6130
|
+
const y = _e.indexOf(g);
|
|
6131
|
+
y >= 0 && _e.splice(y, 1);
|
|
6054
6132
|
},
|
|
6055
6133
|
// Update which systems this history group covers WITHOUT losing the accumulated path
|
|
6056
6134
|
// history. Needed when the scene's systems change (e.g. duplicate/add/remove) while the
|
|
6057
6135
|
// group is active — otherwise a newly-added system's id isn't in the set and its trail
|
|
6058
6136
|
// can't follow the recorded movement path (it falls back to straight extrapolation).
|
|
6059
6137
|
setIds(y) {
|
|
6060
|
-
|
|
6138
|
+
g.ids = y instanceof Set ? y : new Set(y);
|
|
6061
6139
|
}
|
|
6062
6140
|
};
|
|
6063
6141
|
}
|
|
@@ -6065,34 +6143,34 @@ async function qr(s, t = {}) {
|
|
|
6065
6143
|
manager: l,
|
|
6066
6144
|
device: r,
|
|
6067
6145
|
context: n,
|
|
6068
|
-
setCamera:
|
|
6069
|
-
setCameraMVP:
|
|
6070
|
-
setEmitters:
|
|
6071
|
-
loadPreset:
|
|
6072
|
-
addEmitter:
|
|
6073
|
-
addMovingEmitter:
|
|
6074
|
-
render:
|
|
6075
|
-
resize:
|
|
6076
|
-
clearCaches:
|
|
6077
|
-
trackHistoryGroup:
|
|
6078
|
-
destroy:
|
|
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
|
|
6079
6157
|
};
|
|
6080
6158
|
}
|
|
6081
|
-
function
|
|
6159
|
+
function $r(s) {
|
|
6082
6160
|
return () => {
|
|
6083
6161
|
var t, e, i, r, n, a, o, c;
|
|
6084
6162
|
try {
|
|
6085
6163
|
const l = s.backend;
|
|
6086
6164
|
if (!l) return null;
|
|
6087
|
-
const d = s.domElement.width, S = s.domElement.height,
|
|
6088
|
-
if (s.needsFrameBufferTarget &&
|
|
6089
|
-
const
|
|
6090
|
-
(r =
|
|
6091
|
-
|
|
6092
|
-
(n =
|
|
6093
|
-
|
|
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
|
|
6094
6172
|
];
|
|
6095
|
-
for (const _ of
|
|
6173
|
+
for (const _ of z)
|
|
6096
6174
|
if (_ && typeof _.createView == "function" && _.width === d && _.height === S) return _;
|
|
6097
6175
|
return null;
|
|
6098
6176
|
}
|
|
@@ -6104,46 +6182,46 @@ function Hr(s) {
|
|
|
6104
6182
|
};
|
|
6105
6183
|
}
|
|
6106
6184
|
export {
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
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
|
|
6149
6227
|
};
|