hz-particles 1.5.6 → 1.5.7
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 +10 -10
- package/dist-lib/hz-particles.mjs +933 -952
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class Hs {
|
|
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 qs {
|
|
|
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), l = Math.sin(r), c = 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), l = Math.sin(r), c = Math.cos(n), d = Math.sin(n), S = Math.cos(a), g = Math.sin(a);
|
|
14
14
|
this._rotMatrix = [
|
|
15
15
|
c * S,
|
|
16
|
-
l * d * S - o *
|
|
17
|
-
o * d * S + l *
|
|
18
|
-
c *
|
|
19
|
-
l * d *
|
|
20
|
-
o * d *
|
|
16
|
+
l * d * S - o * g,
|
|
17
|
+
o * d * S + l * g,
|
|
18
|
+
c * g,
|
|
19
|
+
l * d * g + o * S,
|
|
20
|
+
o * d * g - l * S,
|
|
21
21
|
-d,
|
|
22
22
|
l * c,
|
|
23
23
|
o * c
|
|
@@ -193,8 +193,8 @@ class qs {
|
|
|
193
193
|
if (Math.abs(a) < 1e-6 || o <= 1e-6)
|
|
194
194
|
l = Math.random();
|
|
195
195
|
else {
|
|
196
|
-
const S = Math.random(),
|
|
197
|
-
l = (-
|
|
196
|
+
const S = Math.random(), g = 0.5 * a, b = e, P = -S * o, B = Math.max(0, b * b - 4 * g * P);
|
|
197
|
+
l = (-b + Math.sqrt(B)) / (2 * g), Number.isFinite(l) || (l = Math.random()), l = Math.min(1, Math.max(0, l));
|
|
198
198
|
}
|
|
199
199
|
const c = l * r, d = e + a * l;
|
|
200
200
|
t[0] = Math.cos(n) * d, t[1] = c, t[2] = Math.sin(n) * d;
|
|
@@ -256,33 +256,33 @@ class qs {
|
|
|
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, l = this.config.emissionPositionZ || 0, c = t - a, d = e - o, S = i - l,
|
|
260
|
-
let
|
|
261
|
-
if (
|
|
262
|
-
let
|
|
259
|
+
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, l = this.config.emissionPositionZ || 0, c = t - a, d = e - o, S = i - l, g = Math.sqrt(c * c + d * d + S * S);
|
|
260
|
+
let b, P, B;
|
|
261
|
+
if (g > 1e-4) {
|
|
262
|
+
let V = !1;
|
|
263
263
|
if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
266
|
-
const
|
|
267
|
-
|
|
264
|
+
const R = this.inverseRotation(c, d, S), q = Math.sqrt(R[0] * R[0] + R[1] * R[1]);
|
|
265
|
+
if (q > 1e-4) {
|
|
266
|
+
const A = -R[1] / q, O = R[0] / q, I = this.applyRotation(A, O, 0);
|
|
267
|
+
b = I[0], P = I[1], B = I[2], V = !0;
|
|
268
268
|
}
|
|
269
269
|
} else if (this.config.emissionShape === "cylinder" && this.config.cylinderVelocityDirection === "tangential") {
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
const
|
|
273
|
-
|
|
270
|
+
const R = this.inverseRotation(c, d, S), q = Math.sqrt(R[0] * R[0] + R[2] * R[2]);
|
|
271
|
+
if (q > 1e-4) {
|
|
272
|
+
const A = -R[2] / q, O = R[0] / q, I = this.applyRotation(A, 0, O);
|
|
273
|
+
b = I[0], P = I[1], B = I[2], V = !0;
|
|
274
274
|
} else {
|
|
275
|
-
const
|
|
276
|
-
|
|
275
|
+
const A = Math.random() * Math.PI * 2, O = this.applyRotation(Math.cos(A), 0, Math.sin(A));
|
|
276
|
+
b = O[0], P = O[1], B = O[2], V = !0;
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
|
-
|
|
279
|
+
V || (b = c / g, P = d / g, B = S / g);
|
|
280
280
|
} else {
|
|
281
|
-
const
|
|
282
|
-
|
|
281
|
+
const V = Math.random() * Math.PI * 2, R = Math.acos(2 * Math.random() - 1);
|
|
282
|
+
b = Math.sin(R) * Math.cos(V), P = Math.sin(R) * Math.sin(V), B = Math.cos(R);
|
|
283
283
|
}
|
|
284
284
|
let z;
|
|
285
|
-
this.config.randomSpeed ? z = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : z = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity :
|
|
285
|
+
this.config.randomSpeed ? z = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : z = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : b * z, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : P * z, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : B * z, r[n + 3] = 0;
|
|
286
286
|
}
|
|
287
287
|
setParticleColor(t, e) {
|
|
288
288
|
if (this.config.randomColorEnabled && this.config.randomColors.length > 0) {
|
|
@@ -295,7 +295,7 @@ class qs {
|
|
|
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 Ws = `
|
|
299
299
|
struct Uniforms {
|
|
300
300
|
transform: mat4x4<f32>,
|
|
301
301
|
cameraPosition: vec3<f32>,
|
|
@@ -737,7 +737,7 @@ const Hs = `
|
|
|
737
737
|
return vec4<f32>(input.color, alpha);
|
|
738
738
|
}
|
|
739
739
|
}
|
|
740
|
-
`,
|
|
740
|
+
`, $s = `
|
|
741
741
|
struct BloomUniforms {
|
|
742
742
|
direction: vec2<f32>,
|
|
743
743
|
resolution: vec2<f32>,
|
|
@@ -797,7 +797,7 @@ const Hs = `
|
|
|
797
797
|
|
|
798
798
|
return result / totalWeight * 1.1;
|
|
799
799
|
}
|
|
800
|
-
`,
|
|
800
|
+
`, Js = `
|
|
801
801
|
struct BloomIntensityUniforms {
|
|
802
802
|
intensity: f32,
|
|
803
803
|
color: vec3<f32>,
|
|
@@ -843,7 +843,7 @@ const Hs = `
|
|
|
843
843
|
|
|
844
844
|
return vec4<f32>(originalColor.rgb + (mappedBloom * bloomUniforms.intensity), originalColor.a);
|
|
845
845
|
}
|
|
846
|
-
`,
|
|
846
|
+
`, Ks = `
|
|
847
847
|
struct BloomIntensityUniforms {
|
|
848
848
|
intensity: f32,
|
|
849
849
|
color: vec3<f32>,
|
|
@@ -884,7 +884,7 @@ const Hs = `
|
|
|
884
884
|
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
885
885
|
return textureSample(originalTexture, texSampler, input.texCoord);
|
|
886
886
|
}
|
|
887
|
-
`,
|
|
887
|
+
`, Qs = `
|
|
888
888
|
@binding(0) @group(0) var texSampler: sampler;
|
|
889
889
|
@binding(1) @group(0) var originalTexture: texture_2d<f32>;
|
|
890
890
|
@binding(2) @group(0) var blurredTexture: texture_2d<f32>;
|
|
@@ -916,7 +916,7 @@ const Hs = `
|
|
|
916
916
|
let c = textureSample(originalTexture, texSampler, input.texCoord);
|
|
917
917
|
return vec4<f32>(aces(c.rgb), c.a);
|
|
918
918
|
}
|
|
919
|
-
`,
|
|
919
|
+
`, er = `
|
|
920
920
|
struct PhysicsUniforms {
|
|
921
921
|
deltaTime: f32,
|
|
922
922
|
particleSpeed: f32,
|
|
@@ -1126,7 +1126,7 @@ const Hs = `
|
|
|
1126
1126
|
particleBuffer[baseIndex + 1u] = newPos.y;
|
|
1127
1127
|
particleBuffer[baseIndex + 2u] = newPos.z;
|
|
1128
1128
|
}
|
|
1129
|
-
`,
|
|
1129
|
+
`, tr = `
|
|
1130
1130
|
@group(0) @binding(0) var<storage, read> restData: array<f32>;
|
|
1131
1131
|
@group(0) @binding(1) var<storage, read> jointWeightsData: array<f32>;
|
|
1132
1132
|
@group(0) @binding(2) var<storage, read> jointIndicesData: array<u32>;
|
|
@@ -1183,7 +1183,7 @@ const Hs = `
|
|
|
1183
1183
|
outputData[outBase + 7u] = uv_v;
|
|
1184
1184
|
}
|
|
1185
1185
|
`;
|
|
1186
|
-
class
|
|
1186
|
+
class ir {
|
|
1187
1187
|
constructor(t, e = 1e4) {
|
|
1188
1188
|
this.device = t, this.physicsSettings = {
|
|
1189
1189
|
deltaTime: 0.016,
|
|
@@ -1272,7 +1272,7 @@ class er {
|
|
|
1272
1272
|
}),
|
|
1273
1273
|
compute: {
|
|
1274
1274
|
module: this.device.createShaderModule({
|
|
1275
|
-
code:
|
|
1275
|
+
code: er
|
|
1276
1276
|
}),
|
|
1277
1277
|
entryPoint: "main"
|
|
1278
1278
|
}
|
|
@@ -1479,7 +1479,7 @@ class er {
|
|
|
1479
1479
|
t.enabled !== void 0 && (e.softBoundaryEnabled = t.enabled), t.strength !== void 0 && (e.softBoundaryStrength = t.strength), t.falloff !== void 0 && (e.softBoundaryFalloff = t.falloff);
|
|
1480
1480
|
}
|
|
1481
1481
|
}
|
|
1482
|
-
class
|
|
1482
|
+
class sr {
|
|
1483
1483
|
constructor(t) {
|
|
1484
1484
|
this.device = t, this.defaultTexture = null, this.createDefaultTexture();
|
|
1485
1485
|
}
|
|
@@ -1542,7 +1542,7 @@ const Wi = Object.freeze({
|
|
|
1542
1542
|
const i = Wi.clamp((e - s) / (t - s), 0, 1);
|
|
1543
1543
|
return i * i * (3 - 2 * i);
|
|
1544
1544
|
}
|
|
1545
|
-
}),
|
|
1545
|
+
}), zt = /* @__PURE__ */ new Set([
|
|
1546
1546
|
"particleSize",
|
|
1547
1547
|
"particleSpeed",
|
|
1548
1548
|
"particleColor",
|
|
@@ -1585,7 +1585,7 @@ const Wi = Object.freeze({
|
|
|
1585
1585
|
"shapeStrokeFrequency",
|
|
1586
1586
|
"shapeStrokeSpeed"
|
|
1587
1587
|
]);
|
|
1588
|
-
class
|
|
1588
|
+
class rr {
|
|
1589
1589
|
constructor(t) {
|
|
1590
1590
|
this._collection = t, this._pd = null, this._vd = null, this._pi = 0, this._vi = 0;
|
|
1591
1591
|
}
|
|
@@ -1663,9 +1663,9 @@ class ir {
|
|
|
1663
1663
|
this._vd[this._vi + 2] = t, this._collection._dirty = !0;
|
|
1664
1664
|
}
|
|
1665
1665
|
}
|
|
1666
|
-
class
|
|
1666
|
+
class nr {
|
|
1667
1667
|
constructor() {
|
|
1668
|
-
this._proxy = new
|
|
1668
|
+
this._proxy = new rr(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
|
|
1669
1669
|
}
|
|
1670
1670
|
_bind(t, e, i) {
|
|
1671
1671
|
this._pd = t, this._vd = e, this.count = i, this._dirty = !1;
|
|
@@ -1674,14 +1674,14 @@ class sr {
|
|
|
1674
1674
|
return t < 0 || t >= this.count ? null : this._proxy._bind(this._pd, this._vd, t);
|
|
1675
1675
|
}
|
|
1676
1676
|
}
|
|
1677
|
-
const
|
|
1678
|
-
function
|
|
1677
|
+
const ar = 1e6;
|
|
1678
|
+
function or(s) {
|
|
1679
1679
|
let t = 0;
|
|
1680
1680
|
return s.replace(
|
|
1681
1681
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
1682
1682
|
(e) => {
|
|
1683
1683
|
const i = `__lc${t++}`;
|
|
1684
|
-
return `${e} if(++${i}>${
|
|
1684
|
+
return `${e} if(++${i}>${ar})throw new Error("Loop limit exceeded");`;
|
|
1685
1685
|
}
|
|
1686
1686
|
).replace(
|
|
1687
1687
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
@@ -1698,10 +1698,10 @@ function nr(s) {
|
|
|
1698
1698
|
}
|
|
1699
1699
|
);
|
|
1700
1700
|
}
|
|
1701
|
-
const
|
|
1702
|
-
for (const s of
|
|
1703
|
-
|
|
1704
|
-
function
|
|
1701
|
+
const oi = /* @__PURE__ */ new Map();
|
|
1702
|
+
for (const s of zt)
|
|
1703
|
+
oi.set(s.toLowerCase(), s);
|
|
1704
|
+
function lr(s) {
|
|
1705
1705
|
const t = { value: !1 }, e = /* @__PURE__ */ new Set();
|
|
1706
1706
|
return new Proxy(s, {
|
|
1707
1707
|
get(r, n) {
|
|
@@ -1710,16 +1710,16 @@ function ar(s) {
|
|
|
1710
1710
|
t.value = !1;
|
|
1711
1711
|
};
|
|
1712
1712
|
if (typeof n != "string") return;
|
|
1713
|
-
if (
|
|
1714
|
-
const a =
|
|
1713
|
+
if (zt.has(n)) return r[n];
|
|
1714
|
+
const a = oi.get(n.toLowerCase());
|
|
1715
1715
|
if (a)
|
|
1716
1716
|
return e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${a}?`)), r[a];
|
|
1717
1717
|
},
|
|
1718
1718
|
set(r, n, a) {
|
|
1719
1719
|
if (typeof n != "string") return !0;
|
|
1720
1720
|
let o = n;
|
|
1721
|
-
if (!
|
|
1722
|
-
const l =
|
|
1721
|
+
if (!zt.has(o)) {
|
|
1722
|
+
const l = oi.get(o.toLowerCase());
|
|
1723
1723
|
if (l)
|
|
1724
1724
|
e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${l}?`)), o = l;
|
|
1725
1725
|
else
|
|
@@ -1729,14 +1729,14 @@ function ar(s) {
|
|
|
1729
1729
|
}
|
|
1730
1730
|
});
|
|
1731
1731
|
}
|
|
1732
|
-
class
|
|
1732
|
+
class Fi {
|
|
1733
1733
|
/**
|
|
1734
1734
|
* @param {string} source - User script source code
|
|
1735
1735
|
* @param {object} config - ParticleSystem config (will be proxied)
|
|
1736
1736
|
* @param {number} maxParticles - Max particle count for pre-allocation
|
|
1737
1737
|
*/
|
|
1738
1738
|
constructor(t, e, i) {
|
|
1739
|
-
this._particles = new
|
|
1739
|
+
this._particles = new nr(), this._configProxy = lr(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
|
|
1740
1740
|
}
|
|
1741
1741
|
/**
|
|
1742
1742
|
* Compile script source into a sandboxed function.
|
|
@@ -1752,7 +1752,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1752
1752
|
var deltaTime = __deltaTime, time = __time;
|
|
1753
1753
|
var currentFrame = __currentFrame, totalFrames = __totalFrames;
|
|
1754
1754
|
var particles = __particles, config = __config, math = __math;
|
|
1755
|
-
${
|
|
1755
|
+
${or(t)}
|
|
1756
1756
|
};`, r = new Function(i);
|
|
1757
1757
|
this._fn = r();
|
|
1758
1758
|
} catch (e) {
|
|
@@ -1788,7 +1788,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1788
1788
|
*/
|
|
1789
1789
|
snapshotConfig(t) {
|
|
1790
1790
|
const e = {};
|
|
1791
|
-
for (const i of
|
|
1791
|
+
for (const i of zt) {
|
|
1792
1792
|
const r = t[i];
|
|
1793
1793
|
r !== void 0 && (e[i] = Array.isArray(r) ? [...r] : r);
|
|
1794
1794
|
}
|
|
@@ -1799,7 +1799,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1799
1799
|
*/
|
|
1800
1800
|
restoreConfig(t) {
|
|
1801
1801
|
if (this._configSnapshot) {
|
|
1802
|
-
for (const e of
|
|
1802
|
+
for (const e of zt)
|
|
1803
1803
|
if (e in this._configSnapshot) {
|
|
1804
1804
|
const i = this._configSnapshot[e];
|
|
1805
1805
|
t[e] = Array.isArray(i) ? [...i] : i;
|
|
@@ -1813,7 +1813,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1813
1813
|
this._fn = null, this._particles = null, this._configProxy = null, this._configSnapshot = null;
|
|
1814
1814
|
}
|
|
1815
1815
|
}
|
|
1816
|
-
async function
|
|
1816
|
+
async function cr(s) {
|
|
1817
1817
|
const t = new DataView(s);
|
|
1818
1818
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
1819
1819
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -1823,12 +1823,12 @@ async function or(s) {
|
|
|
1823
1823
|
const r = t.getUint32(8, !0);
|
|
1824
1824
|
let n = 12, a = null, o = null;
|
|
1825
1825
|
for (; n < r; ) {
|
|
1826
|
-
const
|
|
1827
|
-
if (
|
|
1828
|
-
const
|
|
1829
|
-
a = JSON.parse(
|
|
1830
|
-
} else
|
|
1831
|
-
n += 8 +
|
|
1826
|
+
const A = t.getUint32(n, !0), O = t.getUint32(n + 4, !0), I = s.slice(n + 8, n + 8 + A);
|
|
1827
|
+
if (O === 1313821514) {
|
|
1828
|
+
const K = new TextDecoder("utf-8").decode(I);
|
|
1829
|
+
a = JSON.parse(K);
|
|
1830
|
+
} else O === 5130562 && (o = I);
|
|
1831
|
+
n += 8 + A;
|
|
1832
1832
|
}
|
|
1833
1833
|
if (!a)
|
|
1834
1834
|
throw new Error("GLB file missing JSON chunk");
|
|
@@ -1840,47 +1840,47 @@ async function or(s) {
|
|
|
1840
1840
|
const d = c.attributes.POSITION;
|
|
1841
1841
|
if (d === void 0)
|
|
1842
1842
|
throw new Error("Mesh primitive missing POSITION attribute");
|
|
1843
|
-
const S =
|
|
1844
|
-
let
|
|
1843
|
+
const S = si(a, o, d, 3, 5126);
|
|
1844
|
+
let g;
|
|
1845
1845
|
if (c.attributes.NORMAL !== void 0)
|
|
1846
|
-
|
|
1846
|
+
g = si(a, o, c.attributes.NORMAL, 3, 5126);
|
|
1847
1847
|
else {
|
|
1848
|
-
const
|
|
1849
|
-
if (
|
|
1848
|
+
const A = c.indices;
|
|
1849
|
+
if (A === void 0)
|
|
1850
1850
|
throw new Error("Cannot generate normals without indices");
|
|
1851
|
-
const
|
|
1852
|
-
|
|
1851
|
+
const O = Vi(a, o, A);
|
|
1852
|
+
g = ur(S, O);
|
|
1853
1853
|
}
|
|
1854
|
-
const
|
|
1855
|
-
if (
|
|
1854
|
+
const b = c.indices;
|
|
1855
|
+
if (b === void 0)
|
|
1856
1856
|
throw new Error("Mesh primitive missing indices");
|
|
1857
|
-
const
|
|
1858
|
-
let
|
|
1859
|
-
c.attributes.TEXCOORD_0 !== void 0 && (
|
|
1860
|
-
let
|
|
1857
|
+
const P = Vi(a, o, b), B = S.length / 3, z = P.length;
|
|
1858
|
+
let V = null;
|
|
1859
|
+
c.attributes.TEXCOORD_0 !== void 0 && (V = si(a, o, c.attributes.TEXCOORD_0, 2, 5126));
|
|
1860
|
+
let R = !1;
|
|
1861
1861
|
if (a.materials && a.materials.length > 0) {
|
|
1862
|
-
const
|
|
1863
|
-
|
|
1862
|
+
const A = a.materials[0];
|
|
1863
|
+
A.pbrMetallicRoughness && A.pbrMetallicRoughness.baseColorTexture !== void 0 && (R = !0);
|
|
1864
1864
|
}
|
|
1865
|
-
let
|
|
1865
|
+
let q = null;
|
|
1866
1866
|
if (a.skins && a.skins.length > 0)
|
|
1867
1867
|
try {
|
|
1868
|
-
|
|
1869
|
-
} catch (
|
|
1870
|
-
console.warn("Failed to extract animation data:",
|
|
1868
|
+
q = yr(a, o, c), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", q);
|
|
1869
|
+
} catch (A) {
|
|
1870
|
+
console.warn("Failed to extract animation data:", A);
|
|
1871
1871
|
}
|
|
1872
1872
|
return {
|
|
1873
1873
|
positions: S,
|
|
1874
|
-
normals:
|
|
1875
|
-
indices:
|
|
1876
|
-
texCoords:
|
|
1877
|
-
vertexCount:
|
|
1874
|
+
normals: g,
|
|
1875
|
+
indices: P,
|
|
1876
|
+
texCoords: V,
|
|
1877
|
+
vertexCount: B,
|
|
1878
1878
|
indexCount: z,
|
|
1879
|
-
animationData:
|
|
1880
|
-
hasBaseColorTexture:
|
|
1879
|
+
animationData: q,
|
|
1880
|
+
hasBaseColorTexture: R
|
|
1881
1881
|
};
|
|
1882
1882
|
}
|
|
1883
|
-
function
|
|
1883
|
+
function si(s, t, e, i, r) {
|
|
1884
1884
|
const n = s.accessors[e], o = {
|
|
1885
1885
|
SCALAR: 1,
|
|
1886
1886
|
VEC2: 2,
|
|
@@ -1891,12 +1891,12 @@ function ti(s, t, e, i, r) {
|
|
|
1891
1891
|
throw new Error(`Attribute accessor type mismatch: expected ${i} components, got ${o}`);
|
|
1892
1892
|
if (n.componentType !== r)
|
|
1893
1893
|
throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
|
|
1894
|
-
const c = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), d = n.count, S = new DataView(t, c, d * i * 4),
|
|
1895
|
-
for (let
|
|
1896
|
-
b
|
|
1897
|
-
return
|
|
1894
|
+
const c = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), d = n.count, S = new DataView(t, c, d * i * 4), g = new Float32Array(d * i);
|
|
1895
|
+
for (let b = 0; b < d * i; b++)
|
|
1896
|
+
g[b] = S.getFloat32(b * 4, !0);
|
|
1897
|
+
return g;
|
|
1898
1898
|
}
|
|
1899
|
-
function
|
|
1899
|
+
function Vi(s, t, e) {
|
|
1900
1900
|
const i = s.accessors[e];
|
|
1901
1901
|
if (i.type !== "SCALAR")
|
|
1902
1902
|
throw new Error(`Indices accessor must be SCALAR, got ${i.type}`);
|
|
@@ -1914,19 +1914,19 @@ function Fi(s, t, e) {
|
|
|
1914
1914
|
} else
|
|
1915
1915
|
throw new Error(`Unsupported index component type: ${i.componentType}`);
|
|
1916
1916
|
}
|
|
1917
|
-
function
|
|
1917
|
+
function ur(s, t) {
|
|
1918
1918
|
const e = new Float32Array(s.length);
|
|
1919
1919
|
for (let i = 0; i < t.length; i += 3) {
|
|
1920
|
-
const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], l = [s[n], s[n + 1], s[n + 2]], c = [s[a], s[a + 1], s[a + 2]], d = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], S = [c[0] - o[0], c[1] - o[1], c[2] - o[2]],
|
|
1920
|
+
const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], l = [s[n], s[n + 1], s[n + 2]], c = [s[a], s[a + 1], s[a + 2]], d = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], S = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], g = [
|
|
1921
1921
|
d[1] * S[2] - d[2] * S[1],
|
|
1922
1922
|
d[2] * S[0] - d[0] * S[2],
|
|
1923
1923
|
d[0] * S[1] - d[1] * S[0]
|
|
1924
|
-
],
|
|
1925
|
-
|
|
1924
|
+
], b = Math.sqrt(g[0] * g[0] + g[1] * g[1] + g[2] * g[2]);
|
|
1925
|
+
b > 0 && (g[0] /= b, g[1] /= b, g[2] /= b), e[r] = e[n] = e[a] = g[0], e[r + 1] = e[n + 1] = e[a + 1] = g[1], e[r + 2] = e[n + 2] = e[a + 2] = g[2];
|
|
1926
1926
|
}
|
|
1927
1927
|
return e;
|
|
1928
1928
|
}
|
|
1929
|
-
function
|
|
1929
|
+
function dr(s, t, e) {
|
|
1930
1930
|
const i = s.accessors[e];
|
|
1931
1931
|
if (i.type !== "VEC4")
|
|
1932
1932
|
throw new Error(`JOINTS_0 must be VEC4, got ${i.type}`);
|
|
@@ -1944,7 +1944,7 @@ function cr(s, t, e) {
|
|
|
1944
1944
|
} else
|
|
1945
1945
|
throw new Error(`Unsupported JOINTS_0 component type: ${i.componentType}`);
|
|
1946
1946
|
}
|
|
1947
|
-
function
|
|
1947
|
+
function fr(s, t, e) {
|
|
1948
1948
|
const i = s.accessors[e];
|
|
1949
1949
|
if (i.type !== "VEC4")
|
|
1950
1950
|
throw new Error(`WEIGHTS_0 must be VEC4, got ${i.type}`);
|
|
@@ -1962,7 +1962,7 @@ function ur(s, t, e) {
|
|
|
1962
1962
|
} else
|
|
1963
1963
|
throw new Error(`Unsupported WEIGHTS_0 component type: ${i.componentType}`);
|
|
1964
1964
|
}
|
|
1965
|
-
function
|
|
1965
|
+
function pr(s, t, e) {
|
|
1966
1966
|
const i = s.accessors[e];
|
|
1967
1967
|
if (i.type !== "MAT4")
|
|
1968
1968
|
throw new Error(`Expected MAT4, got ${i.type}`);
|
|
@@ -1973,7 +1973,7 @@ function dr(s, t, e) {
|
|
|
1973
1973
|
l[c] = o.getFloat32(c * 4, !0);
|
|
1974
1974
|
return l;
|
|
1975
1975
|
}
|
|
1976
|
-
function
|
|
1976
|
+
function hr(s, t, e) {
|
|
1977
1977
|
const i = s.accessors[e];
|
|
1978
1978
|
if (i.type !== "SCALAR")
|
|
1979
1979
|
throw new Error(`Expected SCALAR, got ${i.type}`);
|
|
@@ -1984,7 +1984,7 @@ function fr(s, t, e) {
|
|
|
1984
1984
|
l[c] = o.getFloat32(c * 4, !0);
|
|
1985
1985
|
return l;
|
|
1986
1986
|
}
|
|
1987
|
-
function
|
|
1987
|
+
function mr(s, t, e) {
|
|
1988
1988
|
const i = s.accessors[e], n = { VEC3: 3, VEC4: 4 }[i.type];
|
|
1989
1989
|
if (!n)
|
|
1990
1990
|
throw new Error(`Expected VEC3 or VEC4, got ${i.type}`);
|
|
@@ -1995,8 +1995,8 @@ function pr(s, t, e) {
|
|
|
1995
1995
|
d[S] = c.getFloat32(S * 4, !0);
|
|
1996
1996
|
return d;
|
|
1997
1997
|
}
|
|
1998
|
-
function
|
|
1999
|
-
const i = s.skins[0], r = i.joints, n =
|
|
1998
|
+
function yr(s, t, e) {
|
|
1999
|
+
const i = s.skins[0], r = i.joints, n = pr(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? dr(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? fr(s, t, e.attributes.WEIGHTS_0) : null;
|
|
2000
2000
|
if (!a || !o)
|
|
2001
2001
|
throw new Error("Mesh missing JOINTS_0 or WEIGHTS_0 attributes");
|
|
2002
2002
|
const l = s.nodes.map((d) => ({
|
|
@@ -2009,20 +2009,20 @@ function hr(s, t, e) {
|
|
|
2009
2009
|
if (s.animations && s.animations.length > 0)
|
|
2010
2010
|
for (const d of s.animations) {
|
|
2011
2011
|
const S = [];
|
|
2012
|
-
let
|
|
2013
|
-
for (const
|
|
2014
|
-
const
|
|
2015
|
-
|
|
2016
|
-
targetNode:
|
|
2017
|
-
targetPath:
|
|
2018
|
-
interpolation:
|
|
2019
|
-
timestamps:
|
|
2012
|
+
let g = 0;
|
|
2013
|
+
for (const b of d.channels) {
|
|
2014
|
+
const P = d.samplers[b.sampler], B = hr(s, t, P.input), z = mr(s, t, P.output), V = B[B.length - 1];
|
|
2015
|
+
V > g && (g = V), S.push({
|
|
2016
|
+
targetNode: b.target.node,
|
|
2017
|
+
targetPath: b.target.path,
|
|
2018
|
+
interpolation: P.interpolation || "LINEAR",
|
|
2019
|
+
timestamps: B,
|
|
2020
2020
|
values: z
|
|
2021
2021
|
});
|
|
2022
2022
|
}
|
|
2023
2023
|
c.push({
|
|
2024
2024
|
name: d.name || `Animation ${c.length}`,
|
|
2025
|
-
duration:
|
|
2025
|
+
duration: g,
|
|
2026
2026
|
channels: S
|
|
2027
2027
|
});
|
|
2028
2028
|
}
|
|
@@ -2035,7 +2035,7 @@ function hr(s, t, e) {
|
|
|
2035
2035
|
animations: c
|
|
2036
2036
|
};
|
|
2037
2037
|
}
|
|
2038
|
-
async function
|
|
2038
|
+
async function Gi(s) {
|
|
2039
2039
|
const t = new DataView(s);
|
|
2040
2040
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
2041
2041
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -2045,12 +2045,12 @@ async function Vi(s) {
|
|
|
2045
2045
|
const r = t.getUint32(8, !0);
|
|
2046
2046
|
let n = 12, a = null, o = null;
|
|
2047
2047
|
for (; n < r; ) {
|
|
2048
|
-
const
|
|
2049
|
-
if (
|
|
2050
|
-
const
|
|
2051
|
-
a = JSON.parse(
|
|
2052
|
-
} else
|
|
2053
|
-
n += 8 +
|
|
2048
|
+
const q = t.getUint32(n, !0), A = t.getUint32(n + 4, !0), O = s.slice(n + 8, n + 8 + q);
|
|
2049
|
+
if (A === 1313821514) {
|
|
2050
|
+
const J = new TextDecoder("utf-8").decode(O);
|
|
2051
|
+
a = JSON.parse(J);
|
|
2052
|
+
} else A === 5130562 && (o = O);
|
|
2053
|
+
n += 8 + q;
|
|
2054
2054
|
}
|
|
2055
2055
|
if (!a)
|
|
2056
2056
|
throw new Error("GLB file missing JSON chunk");
|
|
@@ -2065,18 +2065,18 @@ async function Vi(s) {
|
|
|
2065
2065
|
const S = a.textures[c].source;
|
|
2066
2066
|
if (S === void 0 || !a.images || !a.images[S])
|
|
2067
2067
|
return null;
|
|
2068
|
-
const
|
|
2069
|
-
if (
|
|
2068
|
+
const g = a.images[S], b = g.mimeType || "image/png";
|
|
2069
|
+
if (g.bufferView === void 0)
|
|
2070
2070
|
return null;
|
|
2071
2071
|
if (!o)
|
|
2072
2072
|
throw new Error("GLB file missing BIN chunk (required for embedded textures)");
|
|
2073
|
-
const
|
|
2074
|
-
return { imageBlob: new Blob([
|
|
2073
|
+
const P = a.bufferViews[g.bufferView], B = P.byteOffset || 0, z = P.byteLength, V = o.slice(B, B + z);
|
|
2074
|
+
return { imageBlob: new Blob([V], { type: b }), mimeType: b };
|
|
2075
2075
|
}
|
|
2076
|
-
function
|
|
2076
|
+
function gr(s, t, e, i) {
|
|
2077
2077
|
return i = i || [0, 0, 0], i[0] = s[0] + (t[0] - s[0]) * e, i[1] = s[1] + (t[1] - s[1]) * e, i[2] = s[2] + (t[2] - s[2]) * e, i;
|
|
2078
2078
|
}
|
|
2079
|
-
function
|
|
2079
|
+
function br(s, t, e, i) {
|
|
2080
2080
|
i = i || [0, 0, 0, 0];
|
|
2081
2081
|
let r = s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3], n = 1;
|
|
2082
2082
|
if (r < 0 && (r = -r, n = -1), r > 0.9995) {
|
|
@@ -2087,13 +2087,13 @@ function yr(s, t, e, i) {
|
|
|
2087
2087
|
const a = Math.acos(r), o = Math.sin(a), l = Math.sin((1 - e) * a) / o, c = Math.sin(e * a) / o;
|
|
2088
2088
|
return i[0] = s[0] * l + n * t[0] * c, i[1] = s[1] * l + n * t[1] * c, i[2] = s[2] * l + n * t[2] * c, i[3] = s[3] * l + n * t[3] * c, i;
|
|
2089
2089
|
}
|
|
2090
|
-
function
|
|
2091
|
-
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, l = r + r, c = e * a, d = e * o, S = e * l,
|
|
2092
|
-
return
|
|
2090
|
+
function Sr(s, t) {
|
|
2091
|
+
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, l = r + r, c = e * a, d = e * o, S = e * l, g = i * o, b = i * l, P = r * l, B = n * a, z = n * o, V = n * l, R = t || new Float32Array(16);
|
|
2092
|
+
return R[0] = 1 - (g + P), R[1] = d + V, R[2] = S - z, R[3] = 0, R[4] = d - V, R[5] = 1 - (c + P), R[6] = b + B, R[7] = 0, R[8] = S + z, R[9] = b - B, R[10] = 1 - (c + g), R[11] = 0, R[12] = 0, R[13] = 0, R[14] = 0, R[15] = 1, R;
|
|
2093
2093
|
}
|
|
2094
|
-
const
|
|
2095
|
-
function
|
|
2096
|
-
const r =
|
|
2094
|
+
const vr = new Float32Array(16);
|
|
2095
|
+
function xr(s, t, e, i) {
|
|
2096
|
+
const r = Sr(t, vr), n = i || new Float32Array(16);
|
|
2097
2097
|
return n[0] = r[0] * e[0], n[1] = r[1] * e[0], n[2] = r[2] * e[0], n[3] = 0, n[4] = r[4] * e[1], n[5] = r[5] * e[1], n[6] = r[6] * e[1], n[7] = 0, n[8] = r[8] * e[2], n[9] = r[9] * e[2], n[10] = r[10] * e[2], n[11] = 0, n[12] = s[0], n[13] = s[1], n[14] = s[2], n[15] = 1, n;
|
|
2098
2098
|
}
|
|
2099
2099
|
function Oi(s, t, e) {
|
|
@@ -2103,7 +2103,7 @@ function Oi(s, t, e) {
|
|
|
2103
2103
|
i[r * 4 + n] = s[0 + n] * t[r * 4 + 0] + s[4 + n] * t[r * 4 + 1] + s[8 + n] * t[r * 4 + 2] + s[12 + n] * t[r * 4 + 3];
|
|
2104
2104
|
return i;
|
|
2105
2105
|
}
|
|
2106
|
-
class
|
|
2106
|
+
class Pr {
|
|
2107
2107
|
constructor(t) {
|
|
2108
2108
|
this.joints = t.joints, this.inverseBindMatrices = t.inverseBindMatrices, this.jointWeights = t.jointWeights, this.jointIndices = t.jointIndices, this.nodes = t.nodes, this.animations = t.animations, this.restPositions = null, this.restNormals = null, this.currentAnimIndex = 0, this.currentTime = 0, this.playing = !0, this.speed = 1, this.loop = !0, this.jointLocalTransforms = new Array(this.nodes.length), this.jointGlobalTransforms = new Array(this.nodes.length), this.jointFinalMatrices = new Array(this.joints.length);
|
|
2109
2109
|
for (let e = 0; e < this.nodes.length; e++)
|
|
@@ -2170,7 +2170,7 @@ class xr {
|
|
|
2170
2170
|
this._gpuSkinningPipeline = t.createComputePipeline({
|
|
2171
2171
|
layout: t.createPipelineLayout({ bindGroupLayouts: [o] }),
|
|
2172
2172
|
compute: {
|
|
2173
|
-
module: t.createShaderModule({ code:
|
|
2173
|
+
module: t.createShaderModule({ code: tr }),
|
|
2174
2174
|
entryPoint: "main"
|
|
2175
2175
|
}
|
|
2176
2176
|
}), this._gpuSkinningBindGroup = t.createBindGroup({
|
|
@@ -2260,11 +2260,11 @@ class xr {
|
|
|
2260
2260
|
return this._extractValue(n, r.length - 1, o, i);
|
|
2261
2261
|
let l = 0, c = r.length - 1;
|
|
2262
2262
|
for (; c - l > 1; ) {
|
|
2263
|
-
const
|
|
2264
|
-
r[
|
|
2263
|
+
const B = Math.floor((l + c) / 2);
|
|
2264
|
+
r[B] <= e ? l = B : c = B;
|
|
2265
2265
|
}
|
|
2266
|
-
const d = r[l], S = r[c],
|
|
2267
|
-
return a === "STEP" ? (i[0] =
|
|
2266
|
+
const d = r[l], S = r[c], g = (e - d) / (S - d), b = this._extractValue(n, l, o, this._sV0), P = this._extractValue(n, c, o, this._sV1);
|
|
2267
|
+
return a === "STEP" ? (i[0] = b[0], i[1] = b[1], i[2] = b[2], o === "rotation" && (i[3] = b[3]), i) : o === "rotation" ? br(b, P, g, i) : gr(b, P, g, i);
|
|
2268
2268
|
}
|
|
2269
2269
|
/**
|
|
2270
2270
|
* Extract value from values array at the given index.
|
|
@@ -2289,7 +2289,7 @@ class xr {
|
|
|
2289
2289
|
let n = r.translation, a = r.rotation, o = r.scale;
|
|
2290
2290
|
for (const l of e.channels)
|
|
2291
2291
|
l.targetNode === i && (l.targetPath === "translation" ? n = this._sampleChannel(l, t, this._scrT) : l.targetPath === "rotation" ? a = this._sampleChannel(l, t, this._scrR) : l.targetPath === "scale" && (o = this._sampleChannel(l, t, this._scrS)));
|
|
2292
|
-
|
|
2292
|
+
xr(n, a, o, this.jointLocalTransforms[i]);
|
|
2293
2293
|
}
|
|
2294
2294
|
}
|
|
2295
2295
|
/**
|
|
@@ -2322,20 +2322,20 @@ class xr {
|
|
|
2322
2322
|
_applySkinning() {
|
|
2323
2323
|
const t = this.restPositions.length / 3, e = this.restPositions, i = this.restNormals, r = this.skinnedPositions, n = this.skinnedNormals, a = this.jointWeights, o = this.jointIndices, l = this.jointFinalMatrices;
|
|
2324
2324
|
for (let c = 0; c < t; c++) {
|
|
2325
|
-
const d = c * 3, S = c * 4,
|
|
2326
|
-
let
|
|
2327
|
-
for (let
|
|
2328
|
-
const
|
|
2329
|
-
if (
|
|
2330
|
-
const
|
|
2331
|
-
|
|
2325
|
+
const d = c * 3, S = c * 4, g = e[d], b = e[d + 1], P = e[d + 2], B = i[d], z = i[d + 1], V = i[d + 2];
|
|
2326
|
+
let R = 0, q = 0, A = 0, O = 0, I = 0, J = 0;
|
|
2327
|
+
for (let H = 0; H < 4; H++) {
|
|
2328
|
+
const Q = a[S + H];
|
|
2329
|
+
if (Q === 0) continue;
|
|
2330
|
+
const X = l[o[S + H]];
|
|
2331
|
+
R += (X[0] * g + X[4] * b + X[8] * P + X[12]) * Q, q += (X[1] * g + X[5] * b + X[9] * P + X[13]) * Q, A += (X[2] * g + X[6] * b + X[10] * P + X[14]) * Q, O += (X[0] * B + X[4] * z + X[8] * V) * Q, I += (X[1] * B + X[5] * z + X[9] * V) * Q, J += (X[2] * B + X[6] * z + X[10] * V) * Q;
|
|
2332
2332
|
}
|
|
2333
|
-
const
|
|
2334
|
-
|
|
2333
|
+
const K = Math.sqrt(O * O + I * I + J * J);
|
|
2334
|
+
K > 1e-4 && (n[d] = O / K, n[d + 1] = I / K, n[d + 2] = J / K), r[d] = R, r[d + 1] = q, r[d + 2] = A;
|
|
2335
2335
|
}
|
|
2336
2336
|
}
|
|
2337
2337
|
}
|
|
2338
|
-
class
|
|
2338
|
+
class _r {
|
|
2339
2339
|
constructor({ duration: t = 0, loop: e = !1, playbackRate: i = 1 } = {}) {
|
|
2340
2340
|
this.currentTime = 0, this.duration = t, this.loop = e, this.playbackRate = i, this.paused = !1, this._justLooped = !1;
|
|
2341
2341
|
}
|
|
@@ -2375,26 +2375,26 @@ const Li = {
|
|
|
2375
2375
|
return Math.pow(2, -10 * s) * Math.sin((s * 10 - 0.75) * t) + 1;
|
|
2376
2376
|
}
|
|
2377
2377
|
};
|
|
2378
|
-
function
|
|
2379
|
-
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, l = 3 * (i - t) - o, c = 1 - o - l, d = (
|
|
2380
|
-
return (
|
|
2381
|
-
if (
|
|
2382
|
-
if (
|
|
2383
|
-
let
|
|
2384
|
-
for (let
|
|
2385
|
-
const z = d(
|
|
2378
|
+
function Mr(s, t, e, i) {
|
|
2379
|
+
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, l = 3 * (i - t) - o, c = 1 - o - l, d = (b) => ((a * b + n) * b + r) * b, S = (b) => ((c * b + l) * b + o) * b, g = (b) => (3 * a * b + 2 * n) * b + r;
|
|
2380
|
+
return (b) => {
|
|
2381
|
+
if (b <= 0) return 0;
|
|
2382
|
+
if (b >= 1) return 1;
|
|
2383
|
+
let P = b;
|
|
2384
|
+
for (let B = 0; B < 8; B++) {
|
|
2385
|
+
const z = d(P) - b;
|
|
2386
2386
|
if (Math.abs(z) < 1e-5) break;
|
|
2387
|
-
const
|
|
2388
|
-
if (Math.abs(
|
|
2389
|
-
|
|
2387
|
+
const V = g(P);
|
|
2388
|
+
if (Math.abs(V) < 1e-6) break;
|
|
2389
|
+
P -= z / V;
|
|
2390
2390
|
}
|
|
2391
|
-
return S(
|
|
2391
|
+
return S(P);
|
|
2392
2392
|
};
|
|
2393
2393
|
}
|
|
2394
2394
|
function $i(s, t) {
|
|
2395
|
-
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ?
|
|
2395
|
+
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? Mr(s[0], s[1], s[2], s[3])(t) : (Li[s] || Li.linear)(t);
|
|
2396
2396
|
}
|
|
2397
|
-
function
|
|
2397
|
+
function wr(s, t) {
|
|
2398
2398
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2399
2399
|
if (s.length === 1 || t <= s[0].t) return s[0].v;
|
|
2400
2400
|
const e = s[s.length - 1];
|
|
@@ -2408,7 +2408,7 @@ function _r(s, t) {
|
|
|
2408
2408
|
}
|
|
2409
2409
|
return e.v;
|
|
2410
2410
|
}
|
|
2411
|
-
function
|
|
2411
|
+
function Rr(s, t, e) {
|
|
2412
2412
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2413
2413
|
const i = s.length, r = s[i - 1];
|
|
2414
2414
|
let n, a, o;
|
|
@@ -2419,10 +2419,10 @@ function Mr(s, t, e) {
|
|
|
2419
2419
|
else {
|
|
2420
2420
|
n = a = r.v, o = 0;
|
|
2421
2421
|
for (let S = 0; S < i - 1; S++) {
|
|
2422
|
-
const
|
|
2423
|
-
if (t >=
|
|
2424
|
-
const
|
|
2425
|
-
n =
|
|
2422
|
+
const g = s[S], b = s[S + 1];
|
|
2423
|
+
if (t >= g.t && t <= b.t) {
|
|
2424
|
+
const P = b.t - g.t;
|
|
2425
|
+
n = g.v, a = b.v, o = $i(g.ease, P > 0 ? (t - g.t) / P : 0);
|
|
2426
2426
|
break;
|
|
2427
2427
|
}
|
|
2428
2428
|
}
|
|
@@ -2430,7 +2430,7 @@ function Mr(s, t, e) {
|
|
|
2430
2430
|
const l = n[0] + (a[0] - n[0]) * o, c = n[1] + (a[1] - n[1]) * o, d = n[2] + (a[2] - n[2]) * o;
|
|
2431
2431
|
return e ? (e[0] = l, e[1] = c, e[2] = d, e) : [l, c, d];
|
|
2432
2432
|
}
|
|
2433
|
-
const
|
|
2433
|
+
const Br = [
|
|
2434
2434
|
"gravityStrength",
|
|
2435
2435
|
"emissionRate",
|
|
2436
2436
|
"damping",
|
|
@@ -2465,14 +2465,14 @@ const wr = [
|
|
|
2465
2465
|
"shapeStrokeAmplitude",
|
|
2466
2466
|
"shapeStrokeFrequency",
|
|
2467
2467
|
"shapeStrokeSpeed"
|
|
2468
|
-
],
|
|
2468
|
+
], Tr = { 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 };
|
|
2469
2469
|
function ki(s) {
|
|
2470
2470
|
const t = atob(s), e = new Uint8Array(t.length);
|
|
2471
2471
|
for (let i = 0; i < t.length; i++)
|
|
2472
2472
|
e[i] = t.charCodeAt(i);
|
|
2473
2473
|
return e.buffer;
|
|
2474
2474
|
}
|
|
2475
|
-
class
|
|
2475
|
+
class ri {
|
|
2476
2476
|
constructor(t, e) {
|
|
2477
2477
|
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({
|
|
2478
2478
|
size: this.MAX_PARTICLES * 8 * 4,
|
|
@@ -2498,7 +2498,7 @@ class ii {
|
|
|
2498
2498
|
// intensity (f32) + padding
|
|
2499
2499
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
2500
2500
|
label: "systemBloomIntensityBuffer"
|
|
2501
|
-
}), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.attractorReverse === void 0 && (e.attractorReverse = !1), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeStrokeEnabled === void 0 && (e.shapeStrokeEnabled = !1), e.shapeStrokeWidth === void 0 && (e.shapeStrokeWidth = 0.08), e.shapeStrokeSegments === void 0 && (e.shapeStrokeSegments = 96), e.shapeStrokeShape === void 0 && (e.shapeStrokeShape = "straight"), e.shapeStrokeAmplitude === void 0 && (e.shapeStrokeAmplitude = 0.08), e.shapeStrokeFrequency === void 0 && (e.shapeStrokeFrequency = 10), e.shapeStrokeSpeed === void 0 && (e.shapeStrokeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new qs(e), this.physics = new er(t, this.MAX_PARTICLES), this.textureManager = new tr(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition, e.attractorReverse), e.confinementEnabled && this.setConfinement({
|
|
2501
|
+
}), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.attractorReverse === void 0 && (e.attractorReverse = !1), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeStrokeEnabled === void 0 && (e.shapeStrokeEnabled = !1), e.shapeStrokeWidth === void 0 && (e.shapeStrokeWidth = 0.08), e.shapeStrokeSegments === void 0 && (e.shapeStrokeSegments = 96), e.shapeStrokeShape === void 0 && (e.shapeStrokeShape = "straight"), e.shapeStrokeAmplitude === void 0 && (e.shapeStrokeAmplitude = 0.08), e.shapeStrokeFrequency === void 0 && (e.shapeStrokeFrequency = 10), e.shapeStrokeSpeed === void 0 && (e.shapeStrokeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new Hs(e), this.physics = new ir(t, this.MAX_PARTICLES), this.textureManager = new sr(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({
|
|
2502
2502
|
enabled: !0,
|
|
2503
2503
|
shape: e.confinementShape,
|
|
2504
2504
|
mode: e.confinementMode,
|
|
@@ -2511,7 +2511,7 @@ class ii {
|
|
|
2511
2511
|
enabled: !0,
|
|
2512
2512
|
strength: e.softBoundaryStrength,
|
|
2513
2513
|
falloff: e.softBoundaryFalloff
|
|
2514
|
-
}), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new
|
|
2514
|
+
}), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new Fi(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
|
|
2515
2515
|
}
|
|
2516
2516
|
async initComputePipeline(t) {
|
|
2517
2517
|
this.computeReady = await this.physics.initComputePipeline(this.instanceBuffer, this.velocityBuffer, this.trailBuffer);
|
|
@@ -2521,7 +2521,7 @@ class ii {
|
|
|
2521
2521
|
* @param {string|null} source - Script source code, or null to disable
|
|
2522
2522
|
*/
|
|
2523
2523
|
setScript(t) {
|
|
2524
|
-
this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new
|
|
2524
|
+
this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new Fi(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
|
|
2525
2525
|
}
|
|
2526
2526
|
async setTexture(t) {
|
|
2527
2527
|
this.destroyed || (this.textureManager.destroyTexture(this.particleTexture), this.particleTexture = await this.textureManager.loadTexture(t), this.config.textureEnabled = !0, this.updateAppearanceUniform(), this.updateBuffers());
|
|
@@ -2532,7 +2532,7 @@ class ii {
|
|
|
2532
2532
|
async setGLBModel(t) {
|
|
2533
2533
|
try {
|
|
2534
2534
|
this.glbRawArrayBuffer = t;
|
|
2535
|
-
const e = await
|
|
2535
|
+
const e = await cr(t);
|
|
2536
2536
|
this.glbMeshData = e, this.config.glbHasTexture = e.hasBaseColorTexture || !1;
|
|
2537
2537
|
const i = new Float32Array(e.vertexCount * 8);
|
|
2538
2538
|
for (let r = 0; r < e.vertexCount; r++) {
|
|
@@ -2548,7 +2548,7 @@ class ii {
|
|
|
2548
2548
|
usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
|
|
2549
2549
|
label: "glbIndexBuffer"
|
|
2550
2550
|
}), this.device.queue.writeBuffer(this.glbIndexBuffer, 0, e.indices), this.glbIndexCount = e.indexCount, this.glbIndexFormat = e.indices instanceof Uint32Array ? "uint32" : "uint16", this.config.glbModelEnabled = !0, this.config.textureType = "glb", e.animationData) {
|
|
2551
|
-
this.glbAnimator = new
|
|
2551
|
+
this.glbAnimator = new Pr(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);
|
|
2552
2552
|
try {
|
|
2553
2553
|
await this.glbAnimator.initGPUSkinning(this.device, this.glbVertexBuffer, e.texCoords);
|
|
2554
2554
|
} catch (r) {
|
|
@@ -2610,7 +2610,7 @@ class ii {
|
|
|
2610
2610
|
if (this.destroyed) return;
|
|
2611
2611
|
let t = 0;
|
|
2612
2612
|
this.config.rotationMode === "random" ? t = 1 : this.config.rotationMode === "velocity" ? t = 2 : this.config.rotationMode === "oriented" ? t = 3 : this.config.rotationMode === "cylindrical" && (t = 4);
|
|
2613
|
-
const e =
|
|
2613
|
+
const e = Tr[this.config.particleShape] ?? 0, i = this._appearanceData;
|
|
2614
2614
|
i[0] = this.config.fadeEnabled ? 1 : 0, i[1] = this.config.randomColorEnabled ? 2 : this.config.colorTransitionEnabled ? 1 : 0, i[2] = this.config.particleSize, i[3] = this.config.textureEnabled ? 1 : 0, i[4] = this.config.particleColor[0], i[5] = this.config.particleColor[1], i[6] = this.config.particleColor[2], i[7] = this.config.rotation || 0, i[8] = this.config.startColor[0], i[9] = this.config.startColor[1], i[10] = this.config.startColor[2], i[11] = t, i[12] = this.config.endColor[0], i[13] = this.config.endColor[1], i[14] = this.config.endColor[2], i[15] = this.config.minRotation || 0, i[16] = this.config.maxRotation || 90, i[17] = this.config.aspectRatio || 1, i[18] = this.config.randomSize ? 1 : 0, i[19] = this.config.minSize || 0.1, i[20] = this.config.maxSize || 0.5, i[21] = this.config.fadeSizeEnabled ? 1 : 0, i[22] = this.config.opacity !== void 0 ? this.config.opacity : 1, i[23] = this.config.increaseSizeEnabled ? 1 : 0, i[24] = this.config.sizeLifetimeSpeed ?? 1, i[25] = e, i[26] = 0, i[27] = this.config.pulseEnabled ? 1 : 0, i[28] = this.config.pulseAmplitude ?? 0.5, i[29] = this.config.pulseFrequency ?? 1, i[30] = this.config.pulsePhaseRandom ?? 0, i[31] = this.config.pulseOpacity ? 1 : 0, i[32] = this.config.particleShapeRotationX || 0, i[33] = this.config.particleShapeRotationY || 0, i[34] = this.config.particleShapeRotationZ || 0, i[35] = 0;
|
|
2615
2615
|
const r = this.config.followSystemTranslation ?? !0;
|
|
2616
2616
|
i[36] = r ? this._simPosition[0] : 0, i[37] = r ? this._simPosition[1] : 0, i[38] = r ? this._simPosition[2] : 0, i[39] = 0, i[40] = this._simRotX, i[41] = this._simRotZ, i[42] = this.config.velocityStretchEnabled ? 1 : 0, i[43] = this.config.velocityStretchFactor ?? 1, i[44] = this.config.noiseDistortEnabled ? 1 : 0, i[45] = this.config.noiseTilingX ?? 3, i[46] = this.config.noiseTilingY ?? 3, i[47] = this.config.noiseSpeed ?? -1.5, i[48] = this.config.noiseAmplitude ?? 0.08, i[49] = r ? this._simVelocity[0] : 0, i[50] = r ? this._simVelocity[1] : 0, i[51] = r ? this._simVelocity[2] : 0, i[52] = this.config.orientX ?? 0, i[53] = this.config.orientY ?? 0, i[54] = this.config.orientZ ?? 0, i[55] = 0, this.device.queue.writeBuffer(this.appearanceUniformBuffer, 0, i);
|
|
@@ -2709,7 +2709,7 @@ class ii {
|
|
|
2709
2709
|
if (d > 0 && this._scriptTime >= d && !this._scriptConfigRestored)
|
|
2710
2710
|
this._scriptConfigRestored = !0, this._particleScript._configSnapshot && (this._particleScript.restoreConfig(this.config), this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse));
|
|
2711
2711
|
else if (!this._scriptConfigRestored) {
|
|
2712
|
-
const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty:
|
|
2712
|
+
const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty: g, particlesDirty: b } = this._particleScript.execute(
|
|
2713
2713
|
t,
|
|
2714
2714
|
this._scriptTime,
|
|
2715
2715
|
this._scriptFrame,
|
|
@@ -2718,7 +2718,7 @@ class ii {
|
|
|
2718
2718
|
this._scriptVelocityData,
|
|
2719
2719
|
this.activeParticles
|
|
2720
2720
|
);
|
|
2721
|
-
|
|
2721
|
+
b && this.activeParticles > 0 && (this.device.queue.writeBuffer(
|
|
2722
2722
|
this.instanceBuffer,
|
|
2723
2723
|
0,
|
|
2724
2724
|
this._scriptParticleData,
|
|
@@ -2730,7 +2730,7 @@ class ii {
|
|
|
2730
2730
|
this._scriptVelocityData,
|
|
2731
2731
|
0,
|
|
2732
2732
|
this.activeParticles * 4
|
|
2733
|
-
)),
|
|
2733
|
+
)), g && (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));
|
|
2734
2734
|
}
|
|
2735
2735
|
}
|
|
2736
2736
|
this.physics.physicsAccumulator += t;
|
|
@@ -2741,13 +2741,13 @@ class ii {
|
|
|
2741
2741
|
let S = !1;
|
|
2742
2742
|
if (this.config.followSystemId) {
|
|
2743
2743
|
if (this._pendingFollowEmissions.length > 0) {
|
|
2744
|
-
const
|
|
2745
|
-
for (let
|
|
2746
|
-
const
|
|
2744
|
+
const g = this._pendingFollowEmissions.length / 6;
|
|
2745
|
+
for (let b = 0; b < g; b++) {
|
|
2746
|
+
const P = b * 6;
|
|
2747
2747
|
if (this.emitFollowerParticle(
|
|
2748
|
-
this._pendingFollowEmissions[
|
|
2749
|
-
this._pendingFollowEmissions[
|
|
2750
|
-
this._pendingFollowEmissions[
|
|
2748
|
+
this._pendingFollowEmissions[P],
|
|
2749
|
+
this._pendingFollowEmissions[P + 1],
|
|
2750
|
+
this._pendingFollowEmissions[P + 2]
|
|
2751
2751
|
))
|
|
2752
2752
|
S = !0;
|
|
2753
2753
|
else
|
|
@@ -2755,10 +2755,10 @@ class ii {
|
|
|
2755
2755
|
}
|
|
2756
2756
|
}
|
|
2757
2757
|
} else {
|
|
2758
|
-
let
|
|
2759
|
-
const
|
|
2760
|
-
this.activeParticles < this.particleCount &&
|
|
2761
|
-
for (let
|
|
2758
|
+
let g = 0;
|
|
2759
|
+
const b = Math.max(0, this.config.emissionRate || 0);
|
|
2760
|
+
this.activeParticles < this.particleCount && b > 0 ? (this.emissionAccumulator += b * t, g = Math.floor(this.emissionAccumulator + 1e-9), g > 0 && (this.emissionAccumulator -= g)) : this.activeParticles >= this.particleCount && (this.emissionAccumulator = 0);
|
|
2761
|
+
for (let P = 0; P < g; P++)
|
|
2762
2762
|
if (this.emitParticle())
|
|
2763
2763
|
S = !0;
|
|
2764
2764
|
else {
|
|
@@ -2767,21 +2767,21 @@ class ii {
|
|
|
2767
2767
|
}
|
|
2768
2768
|
}
|
|
2769
2769
|
if (S) {
|
|
2770
|
-
const
|
|
2770
|
+
const g = this.activeParticles - d, b = d * 8, P = d * 4;
|
|
2771
2771
|
this.device.queue.writeBuffer(
|
|
2772
2772
|
this.instanceBuffer,
|
|
2773
|
-
|
|
2773
|
+
b * 4,
|
|
2774
2774
|
// Offset in bytes (float32 = 4 bytes)
|
|
2775
2775
|
this.particleData,
|
|
2776
|
-
|
|
2777
|
-
|
|
2776
|
+
b,
|
|
2777
|
+
g * 8
|
|
2778
2778
|
), this.device.queue.writeBuffer(
|
|
2779
2779
|
this.velocityBuffer,
|
|
2780
|
-
|
|
2780
|
+
P * 4,
|
|
2781
2781
|
// Offset in bytes (float32 = 4 bytes)
|
|
2782
2782
|
this.particleVelocities,
|
|
2783
|
-
|
|
2784
|
-
|
|
2783
|
+
P,
|
|
2784
|
+
g * 4
|
|
2785
2785
|
);
|
|
2786
2786
|
}
|
|
2787
2787
|
} else
|
|
@@ -2877,8 +2877,8 @@ class ii {
|
|
|
2877
2877
|
} else {
|
|
2878
2878
|
const S = Math.sqrt(r * r + n * n + a * a);
|
|
2879
2879
|
if (S > 1e-3) {
|
|
2880
|
-
const
|
|
2881
|
-
this.particleVelocities[i] = r / S *
|
|
2880
|
+
const g = this.config.particleSpeed * 2;
|
|
2881
|
+
this.particleVelocities[i] = r / S * g, this.particleVelocities[i + 1] = n / S * g, this.particleVelocities[i + 2] = a / S * g;
|
|
2882
2882
|
} else
|
|
2883
2883
|
this.particleVelocities[i] = 0, this.particleVelocities[i + 1] = this.config.particleSpeed * 2, this.particleVelocities[i + 2] = 0;
|
|
2884
2884
|
}
|
|
@@ -2923,16 +2923,16 @@ class ii {
|
|
|
2923
2923
|
this.physics.setSoftBoundary(t);
|
|
2924
2924
|
}
|
|
2925
2925
|
}
|
|
2926
|
-
class
|
|
2926
|
+
class Ar {
|
|
2927
2927
|
constructor(t) {
|
|
2928
|
-
this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new
|
|
2928
|
+
this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new _r({ loop: !!this.loop }), this.ready = !0;
|
|
2929
2929
|
}
|
|
2930
2930
|
createParticleSystem(t = {}) {
|
|
2931
2931
|
const e = this.systemCounter++, i = t.name || `System ${e + 1}`, r = {
|
|
2932
2932
|
...t,
|
|
2933
2933
|
name: i,
|
|
2934
2934
|
id: e
|
|
2935
|
-
}, n = new
|
|
2935
|
+
}, n = new ri(this.device, r);
|
|
2936
2936
|
return this.particleSystems.push({
|
|
2937
2937
|
system: n,
|
|
2938
2938
|
config: r,
|
|
@@ -3078,7 +3078,7 @@ class Rr {
|
|
|
3078
3078
|
const n = this.systemCounter++, a = {
|
|
3079
3079
|
...r,
|
|
3080
3080
|
id: n
|
|
3081
|
-
}, o = new
|
|
3081
|
+
}, o = new ri(this.device, a);
|
|
3082
3082
|
this.particleSystems.push({
|
|
3083
3083
|
system: o,
|
|
3084
3084
|
config: a,
|
|
@@ -3106,7 +3106,7 @@ class Rr {
|
|
|
3106
3106
|
if (a) {
|
|
3107
3107
|
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))
|
|
3108
3108
|
try {
|
|
3109
|
-
const o = await
|
|
3109
|
+
const o = await Gi(a);
|
|
3110
3110
|
if (o) {
|
|
3111
3111
|
const l = await createImageBitmap(o.imageBlob);
|
|
3112
3112
|
await r.setTexture(l), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${n.name}`);
|
|
@@ -3174,7 +3174,7 @@ class Rr {
|
|
|
3174
3174
|
(o.confinementCenter[1] || 0) + e[1],
|
|
3175
3175
|
(o.confinementCenter[2] || 0) + e[2]
|
|
3176
3176
|
]);
|
|
3177
|
-
const d = new
|
|
3177
|
+
const d = new ri(this.device, c);
|
|
3178
3178
|
this.particleSystems.push({
|
|
3179
3179
|
system: d,
|
|
3180
3180
|
config: c,
|
|
@@ -3203,7 +3203,7 @@ class Rr {
|
|
|
3203
3203
|
if (c) {
|
|
3204
3204
|
if (await o.setGLBModel(c), l.animationIndex !== void 0 && o.glbAnimator && o.glbAnimator.setAnimation(l.animationIndex), l.animationSpeed !== void 0 && o.glbAnimator && (o.glbAnimator.speed = l.animationSpeed), l.animationLoop !== void 0 && o.glbAnimator && (o.glbAnimator.loop = l.animationLoop), l.useGlbTexture && (l.textureEnabled = !0), l.useGlbTexture && ((r = o.glbMeshData) != null && r.hasBaseColorTexture))
|
|
3205
3205
|
try {
|
|
3206
|
-
const d = await
|
|
3206
|
+
const d = await Gi(c);
|
|
3207
3207
|
if (d) {
|
|
3208
3208
|
const S = await createImageBitmap(d.imageBlob);
|
|
3209
3209
|
await o.setTexture(S), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${l.name}`);
|
|
@@ -3220,8 +3220,8 @@ class Rr {
|
|
|
3220
3220
|
if (l.textureEnabled && !l.glbModelEnabled && l.textureImageData && !o._textureRestored)
|
|
3221
3221
|
try {
|
|
3222
3222
|
const c = new Image();
|
|
3223
|
-
await new Promise((S,
|
|
3224
|
-
c.onload = S, c.onerror =
|
|
3223
|
+
await new Promise((S, g) => {
|
|
3224
|
+
c.onload = S, c.onerror = g, c.src = l.textureImageData;
|
|
3225
3225
|
});
|
|
3226
3226
|
const d = await createImageBitmap(c);
|
|
3227
3227
|
await o.setTexture(d), o._textureRestored = !0;
|
|
@@ -3239,26 +3239,26 @@ class Rr {
|
|
|
3239
3239
|
const r = e.keyframes;
|
|
3240
3240
|
if (!r || e.keyframesEnabled === !1) return;
|
|
3241
3241
|
let n = !1, a = !1, o = !1, l = !1, c = !1;
|
|
3242
|
-
for (const d of
|
|
3242
|
+
for (const d of Br) {
|
|
3243
3243
|
const S = r[d];
|
|
3244
3244
|
if (!S || !S.length) continue;
|
|
3245
|
-
const
|
|
3246
|
-
if (
|
|
3245
|
+
const g = wr(S, i);
|
|
3246
|
+
if (g !== void 0) {
|
|
3247
3247
|
if (d === "damping") {
|
|
3248
|
-
e.dampingStrength =
|
|
3248
|
+
e.dampingStrength = g, l = !0;
|
|
3249
3249
|
continue;
|
|
3250
3250
|
}
|
|
3251
|
-
e[d] =
|
|
3251
|
+
e[d] = g, (d === "particleSize" || d === "opacity") && (n = !0), d === "bloomIntensity" && (a = !0), d === "gravityStrength" && (o = !0), d === "dampingStrength" && (l = !0), (d === "attractorStrength" || d === "attractorReverse") && (c = !0);
|
|
3252
3252
|
}
|
|
3253
3253
|
}
|
|
3254
3254
|
if (r.particleColor && r.particleColor.length) {
|
|
3255
|
-
const d = e.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0,
|
|
3256
|
-
|
|
3255
|
+
const d = e.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0, g = Rr(r.particleColor, i, S);
|
|
3256
|
+
g && (e.particleColor = g, n = !0);
|
|
3257
3257
|
}
|
|
3258
3258
|
n && t.updateAppearanceUniform(), a && t.updateBloomIntensity(), o && e.gravityEnabled && t.setGravity(e.gravityStrength), l && e.dampingEnabled && t.physics.setDamping(e.dampingStrength), c && e.attractorEnabled && e.attractorPosition && t.setAttractor(e.attractorStrength, e.attractorPosition, e.attractorReverse);
|
|
3259
3259
|
}
|
|
3260
3260
|
}
|
|
3261
|
-
async function
|
|
3261
|
+
async function Er(s) {
|
|
3262
3262
|
if (!s)
|
|
3263
3263
|
throw new Error("canvas is required for initWebGPU()");
|
|
3264
3264
|
if (!navigator.gpu)
|
|
@@ -3270,26 +3270,26 @@ async function Tr(s) {
|
|
|
3270
3270
|
alphaMode: "premultiplied"
|
|
3271
3271
|
}), { device: i, context: t, format: r, canvas: s };
|
|
3272
3272
|
}
|
|
3273
|
-
const
|
|
3273
|
+
const ke = "rgba16float", Xi = 0.5, Ji = (s, t) => [
|
|
3274
3274
|
Math.max(1, Math.round(s * Xi)),
|
|
3275
3275
|
Math.max(1, Math.round(t * Xi))
|
|
3276
3276
|
];
|
|
3277
3277
|
function Ni(s, t, e, i) {
|
|
3278
3278
|
const r = s.createTexture({
|
|
3279
3279
|
size: [e, i],
|
|
3280
|
-
format:
|
|
3280
|
+
format: ke,
|
|
3281
3281
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3282
3282
|
mipLevelCount: 1,
|
|
3283
3283
|
sampleCount: 1
|
|
3284
3284
|
}), [n, a] = Ji(e, i), o = s.createTexture({
|
|
3285
3285
|
size: [n, a],
|
|
3286
|
-
format:
|
|
3286
|
+
format: ke,
|
|
3287
3287
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3288
3288
|
mipLevelCount: 1,
|
|
3289
3289
|
sampleCount: 1
|
|
3290
3290
|
}), l = s.createTexture({
|
|
3291
3291
|
size: [n, a],
|
|
3292
|
-
format:
|
|
3292
|
+
format: ke,
|
|
3293
3293
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3294
3294
|
mipLevelCount: 1,
|
|
3295
3295
|
sampleCount: 1
|
|
@@ -3303,7 +3303,7 @@ function Yi(s, t, e) {
|
|
|
3303
3303
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
3304
3304
|
});
|
|
3305
3305
|
}
|
|
3306
|
-
function
|
|
3306
|
+
function bt(s, t, e) {
|
|
3307
3307
|
const i = s.createBuffer({
|
|
3308
3308
|
size: t.byteLength,
|
|
3309
3309
|
usage: e,
|
|
@@ -3311,7 +3311,7 @@ function St(s, t, e) {
|
|
|
3311
3311
|
});
|
|
3312
3312
|
return new t.constructor(i.getMappedRange()).set(t), i.unmap(), i;
|
|
3313
3313
|
}
|
|
3314
|
-
const
|
|
3314
|
+
const Cr = `
|
|
3315
3315
|
struct Uniforms {
|
|
3316
3316
|
transform: mat4x4<f32>,
|
|
3317
3317
|
cameraPosition: vec3<f32>,
|
|
@@ -3373,7 +3373,7 @@ const Er = `
|
|
|
3373
3373
|
|
|
3374
3374
|
return finalColor;
|
|
3375
3375
|
}
|
|
3376
|
-
`,
|
|
3376
|
+
`, Ur = `
|
|
3377
3377
|
struct Uniforms {
|
|
3378
3378
|
transform: mat4x4<f32>,
|
|
3379
3379
|
cameraPosition: vec3<f32>,
|
|
@@ -3610,7 +3610,7 @@ const Er = `
|
|
|
3610
3610
|
return finalColor;
|
|
3611
3611
|
}
|
|
3612
3612
|
`;
|
|
3613
|
-
function
|
|
3613
|
+
function Ir(s) {
|
|
3614
3614
|
const t = s.createBindGroupLayout({
|
|
3615
3615
|
entries: [
|
|
3616
3616
|
{
|
|
@@ -3696,7 +3696,7 @@ function Cr(s) {
|
|
|
3696
3696
|
object3dBindGroupLayout: r
|
|
3697
3697
|
};
|
|
3698
3698
|
}
|
|
3699
|
-
function
|
|
3699
|
+
function zr(s, t, e, i = {}) {
|
|
3700
3700
|
const { depthCompare: r } = i, n = r || "less", {
|
|
3701
3701
|
particleBindGroupLayout: a,
|
|
3702
3702
|
bloomBindGroupLayout: o,
|
|
@@ -3706,24 +3706,24 @@ function Ur(s, t, e, i = {}) {
|
|
|
3706
3706
|
bindGroupLayouts: [a]
|
|
3707
3707
|
}), S = s.createPipelineLayout({
|
|
3708
3708
|
bindGroupLayouts: [o]
|
|
3709
|
-
}),
|
|
3709
|
+
}), g = s.createPipelineLayout({
|
|
3710
3710
|
bindGroupLayouts: [l]
|
|
3711
|
-
}),
|
|
3712
|
-
code: Hs
|
|
3713
|
-
}), v = s.createShaderModule({
|
|
3714
|
-
code: Zs
|
|
3715
|
-
}), U = s.createShaderModule({
|
|
3711
|
+
}), b = s.createShaderModule({
|
|
3716
3712
|
code: Ws
|
|
3717
|
-
}),
|
|
3713
|
+
}), P = s.createShaderModule({
|
|
3718
3714
|
code: $s
|
|
3719
|
-
}),
|
|
3720
|
-
code:
|
|
3721
|
-
}),
|
|
3722
|
-
code:
|
|
3723
|
-
}),
|
|
3715
|
+
}), B = s.createShaderModule({
|
|
3716
|
+
code: Js
|
|
3717
|
+
}), z = s.createShaderModule({
|
|
3718
|
+
code: Ks
|
|
3719
|
+
}), V = s.createShaderModule({
|
|
3720
|
+
code: Cr
|
|
3721
|
+
}), R = s.createShaderModule({
|
|
3722
|
+
code: Ur
|
|
3723
|
+
}), q = (xt) => s.createRenderPipeline({
|
|
3724
3724
|
layout: d,
|
|
3725
3725
|
vertex: {
|
|
3726
|
-
module:
|
|
3726
|
+
module: b,
|
|
3727
3727
|
entryPoint: "vs_main",
|
|
3728
3728
|
buffers: [
|
|
3729
3729
|
{
|
|
@@ -3784,11 +3784,11 @@ function Ur(s, t, e, i = {}) {
|
|
|
3784
3784
|
]
|
|
3785
3785
|
},
|
|
3786
3786
|
fragment: {
|
|
3787
|
-
module:
|
|
3787
|
+
module: b,
|
|
3788
3788
|
entryPoint: "fs_main",
|
|
3789
3789
|
targets: [{
|
|
3790
|
-
format:
|
|
3791
|
-
blend:
|
|
3790
|
+
format: ke,
|
|
3791
|
+
blend: xt
|
|
3792
3792
|
}]
|
|
3793
3793
|
},
|
|
3794
3794
|
primitive: {
|
|
@@ -3800,7 +3800,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3800
3800
|
depthCompare: n,
|
|
3801
3801
|
format: "depth24plus"
|
|
3802
3802
|
}
|
|
3803
|
-
}),
|
|
3803
|
+
}), A = q({
|
|
3804
3804
|
color: {
|
|
3805
3805
|
srcFactor: "src-alpha",
|
|
3806
3806
|
dstFactor: "one-minus-src-alpha",
|
|
@@ -3811,7 +3811,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3811
3811
|
dstFactor: "one-minus-src-alpha",
|
|
3812
3812
|
operation: "add"
|
|
3813
3813
|
}
|
|
3814
|
-
}),
|
|
3814
|
+
}), O = q({
|
|
3815
3815
|
color: {
|
|
3816
3816
|
srcFactor: "src-alpha",
|
|
3817
3817
|
dstFactor: "one",
|
|
@@ -3822,10 +3822,10 @@ function Ur(s, t, e, i = {}) {
|
|
|
3822
3822
|
dstFactor: "one-minus-src-alpha",
|
|
3823
3823
|
operation: "add"
|
|
3824
3824
|
}
|
|
3825
|
-
}),
|
|
3825
|
+
}), I = s.createRenderPipeline({
|
|
3826
3826
|
layout: d,
|
|
3827
3827
|
vertex: {
|
|
3828
|
-
module:
|
|
3828
|
+
module: b,
|
|
3829
3829
|
entryPoint: "vs_main",
|
|
3830
3830
|
buffers: [
|
|
3831
3831
|
{
|
|
@@ -3886,10 +3886,10 @@ function Ur(s, t, e, i = {}) {
|
|
|
3886
3886
|
]
|
|
3887
3887
|
},
|
|
3888
3888
|
fragment: {
|
|
3889
|
-
module:
|
|
3889
|
+
module: b,
|
|
3890
3890
|
entryPoint: "fs_main",
|
|
3891
3891
|
targets: [{
|
|
3892
|
-
format:
|
|
3892
|
+
format: ke,
|
|
3893
3893
|
writeMask: 0
|
|
3894
3894
|
// No color write — depth only
|
|
3895
3895
|
}]
|
|
@@ -3904,33 +3904,33 @@ function Ur(s, t, e, i = {}) {
|
|
|
3904
3904
|
// Always write depth (don't self-occlude)
|
|
3905
3905
|
format: "depth24plus"
|
|
3906
3906
|
}
|
|
3907
|
-
}),
|
|
3907
|
+
}), J = s.createRenderPipeline({
|
|
3908
3908
|
layout: S,
|
|
3909
3909
|
vertex: {
|
|
3910
|
-
module:
|
|
3910
|
+
module: P,
|
|
3911
3911
|
entryPoint: "vs_main"
|
|
3912
3912
|
},
|
|
3913
3913
|
fragment: {
|
|
3914
|
-
module:
|
|
3914
|
+
module: P,
|
|
3915
3915
|
entryPoint: "fs_main",
|
|
3916
3916
|
targets: [{
|
|
3917
|
-
format:
|
|
3917
|
+
format: ke
|
|
3918
3918
|
}]
|
|
3919
3919
|
},
|
|
3920
3920
|
primitive: {
|
|
3921
3921
|
topology: "triangle-list"
|
|
3922
3922
|
}
|
|
3923
|
-
}),
|
|
3924
|
-
layout:
|
|
3923
|
+
}), K = s.createRenderPipeline({
|
|
3924
|
+
layout: g,
|
|
3925
3925
|
vertex: {
|
|
3926
|
-
module:
|
|
3926
|
+
module: B,
|
|
3927
3927
|
entryPoint: "vs_main"
|
|
3928
3928
|
},
|
|
3929
3929
|
fragment: {
|
|
3930
|
-
module:
|
|
3930
|
+
module: B,
|
|
3931
3931
|
entryPoint: "fs_main",
|
|
3932
3932
|
targets: [{
|
|
3933
|
-
format:
|
|
3933
|
+
format: ke,
|
|
3934
3934
|
blend: {
|
|
3935
3935
|
color: {
|
|
3936
3936
|
srcFactor: "one",
|
|
@@ -3948,8 +3948,8 @@ function Ur(s, t, e, i = {}) {
|
|
|
3948
3948
|
primitive: {
|
|
3949
3949
|
topology: "triangle-list"
|
|
3950
3950
|
}
|
|
3951
|
-
}),
|
|
3952
|
-
layout:
|
|
3951
|
+
}), H = s.createRenderPipeline({
|
|
3952
|
+
layout: g,
|
|
3953
3953
|
vertex: {
|
|
3954
3954
|
module: z,
|
|
3955
3955
|
entryPoint: "vs_main"
|
|
@@ -3958,7 +3958,7 @@ function Ur(s, t, e, i = {}) {
|
|
|
3958
3958
|
module: z,
|
|
3959
3959
|
entryPoint: "fs_main",
|
|
3960
3960
|
targets: [{
|
|
3961
|
-
format:
|
|
3961
|
+
format: ke,
|
|
3962
3962
|
blend: {
|
|
3963
3963
|
color: {
|
|
3964
3964
|
srcFactor: "one",
|
|
@@ -3976,11 +3976,11 @@ function Ur(s, t, e, i = {}) {
|
|
|
3976
3976
|
primitive: {
|
|
3977
3977
|
topology: "triangle-list"
|
|
3978
3978
|
}
|
|
3979
|
-
}),
|
|
3980
|
-
layout:
|
|
3981
|
-
vertex: { module:
|
|
3979
|
+
}), Q = s.createShaderModule({ code: Qs }), X = s.createRenderPipeline({
|
|
3980
|
+
layout: g,
|
|
3981
|
+
vertex: { module: Q, entryPoint: "vs_main" },
|
|
3982
3982
|
fragment: {
|
|
3983
|
-
module:
|
|
3983
|
+
module: Q,
|
|
3984
3984
|
entryPoint: "fs_main",
|
|
3985
3985
|
targets: [{
|
|
3986
3986
|
format: t,
|
|
@@ -3991,12 +3991,12 @@ function Ur(s, t, e, i = {}) {
|
|
|
3991
3991
|
}]
|
|
3992
3992
|
},
|
|
3993
3993
|
primitive: { topology: "triangle-list" }
|
|
3994
|
-
}),
|
|
3994
|
+
}), et = s.createPipelineLayout({
|
|
3995
3995
|
bindGroupLayouts: [c]
|
|
3996
|
-
}),
|
|
3997
|
-
layout:
|
|
3996
|
+
}), St = s.createRenderPipeline({
|
|
3997
|
+
layout: et,
|
|
3998
3998
|
vertex: {
|
|
3999
|
-
module:
|
|
3999
|
+
module: V,
|
|
4000
4000
|
entryPoint: "vs_main",
|
|
4001
4001
|
buffers: [
|
|
4002
4002
|
{
|
|
@@ -4021,10 +4021,10 @@ function Ur(s, t, e, i = {}) {
|
|
|
4021
4021
|
]
|
|
4022
4022
|
},
|
|
4023
4023
|
fragment: {
|
|
4024
|
-
module:
|
|
4024
|
+
module: V,
|
|
4025
4025
|
entryPoint: "fs_main",
|
|
4026
4026
|
targets: [{
|
|
4027
|
-
format:
|
|
4027
|
+
format: ke,
|
|
4028
4028
|
blend: {
|
|
4029
4029
|
color: {
|
|
4030
4030
|
srcFactor: "src-alpha",
|
|
@@ -4048,10 +4048,10 @@ function Ur(s, t, e, i = {}) {
|
|
|
4048
4048
|
depthCompare: n,
|
|
4049
4049
|
format: "depth24plus"
|
|
4050
4050
|
}
|
|
4051
|
-
}),
|
|
4051
|
+
}), vt = s.createRenderPipeline({
|
|
4052
4052
|
layout: d,
|
|
4053
4053
|
vertex: {
|
|
4054
|
-
module:
|
|
4054
|
+
module: R,
|
|
4055
4055
|
entryPoint: "vs_main",
|
|
4056
4056
|
buffers: [
|
|
4057
4057
|
{
|
|
@@ -4123,10 +4123,10 @@ function Ur(s, t, e, i = {}) {
|
|
|
4123
4123
|
]
|
|
4124
4124
|
},
|
|
4125
4125
|
fragment: {
|
|
4126
|
-
module:
|
|
4126
|
+
module: R,
|
|
4127
4127
|
entryPoint: "fs_main",
|
|
4128
4128
|
targets: [{
|
|
4129
|
-
format:
|
|
4129
|
+
format: ke,
|
|
4130
4130
|
blend: {
|
|
4131
4131
|
color: {
|
|
4132
4132
|
srcFactor: "src-alpha",
|
|
@@ -4152,18 +4152,18 @@ function Ur(s, t, e, i = {}) {
|
|
|
4152
4152
|
}
|
|
4153
4153
|
});
|
|
4154
4154
|
return {
|
|
4155
|
-
particlePipeline:
|
|
4156
|
-
particleAdditivePipeline:
|
|
4157
|
-
particleDepthWritePipeline:
|
|
4158
|
-
blurPipeline:
|
|
4159
|
-
compositePipeline:
|
|
4160
|
-
directRenderPipeline:
|
|
4161
|
-
finalCompositePipeline:
|
|
4162
|
-
object3dPipeline:
|
|
4163
|
-
glbMeshPipeline:
|
|
4155
|
+
particlePipeline: A,
|
|
4156
|
+
particleAdditivePipeline: O,
|
|
4157
|
+
particleDepthWritePipeline: I,
|
|
4158
|
+
blurPipeline: J,
|
|
4159
|
+
compositePipeline: K,
|
|
4160
|
+
directRenderPipeline: H,
|
|
4161
|
+
finalCompositePipeline: X,
|
|
4162
|
+
object3dPipeline: St,
|
|
4163
|
+
glbMeshPipeline: vt
|
|
4164
4164
|
};
|
|
4165
4165
|
}
|
|
4166
|
-
function
|
|
4166
|
+
function ni(s, t, e, i) {
|
|
4167
4167
|
const {
|
|
4168
4168
|
uniformBuffer: r,
|
|
4169
4169
|
appearanceUniformBuffer: n,
|
|
@@ -4174,7 +4174,7 @@ function si(s, t, e, i) {
|
|
|
4174
4174
|
sceneTexture: c,
|
|
4175
4175
|
bloomTexA: d,
|
|
4176
4176
|
bloomTexB: S
|
|
4177
|
-
} = i,
|
|
4177
|
+
} = i, g = s.createBindGroup({
|
|
4178
4178
|
layout: s.createBindGroupLayout({
|
|
4179
4179
|
entries: [
|
|
4180
4180
|
{
|
|
@@ -4199,7 +4199,7 @@ function si(s, t, e, i) {
|
|
|
4199
4199
|
resource: { buffer: n }
|
|
4200
4200
|
}
|
|
4201
4201
|
]
|
|
4202
|
-
}),
|
|
4202
|
+
}), b = s.createBindGroup({
|
|
4203
4203
|
layout: s.createBindGroupLayout({
|
|
4204
4204
|
entries: [
|
|
4205
4205
|
{
|
|
@@ -4233,7 +4233,7 @@ function si(s, t, e, i) {
|
|
|
4233
4233
|
resource: { buffer: a }
|
|
4234
4234
|
}
|
|
4235
4235
|
]
|
|
4236
|
-
}),
|
|
4236
|
+
}), P = s.createBindGroup({
|
|
4237
4237
|
layout: s.createBindGroupLayout({
|
|
4238
4238
|
entries: [
|
|
4239
4239
|
{
|
|
@@ -4267,7 +4267,7 @@ function si(s, t, e, i) {
|
|
|
4267
4267
|
resource: { buffer: o }
|
|
4268
4268
|
}
|
|
4269
4269
|
]
|
|
4270
|
-
}),
|
|
4270
|
+
}), B = s.createBindGroup({
|
|
4271
4271
|
layout: s.createBindGroupLayout({
|
|
4272
4272
|
entries: [
|
|
4273
4273
|
{
|
|
@@ -4355,14 +4355,14 @@ function si(s, t, e, i) {
|
|
|
4355
4355
|
]
|
|
4356
4356
|
});
|
|
4357
4357
|
return {
|
|
4358
|
-
particleBindGroup:
|
|
4359
|
-
horizontalBlurBindGroup:
|
|
4360
|
-
verticalBlurBindGroup:
|
|
4361
|
-
compositeBindGroup:
|
|
4358
|
+
particleBindGroup: g,
|
|
4359
|
+
horizontalBlurBindGroup: b,
|
|
4360
|
+
verticalBlurBindGroup: P,
|
|
4361
|
+
compositeBindGroup: B,
|
|
4362
4362
|
directRenderBindGroup: z
|
|
4363
4363
|
};
|
|
4364
4364
|
}
|
|
4365
|
-
function
|
|
4365
|
+
function Dr(s) {
|
|
4366
4366
|
return s.createSampler({
|
|
4367
4367
|
magFilter: "linear",
|
|
4368
4368
|
minFilter: "linear",
|
|
@@ -4372,7 +4372,7 @@ function Ir(s) {
|
|
|
4372
4372
|
maxAnisotropy: 16
|
|
4373
4373
|
});
|
|
4374
4374
|
}
|
|
4375
|
-
function
|
|
4375
|
+
function Fr() {
|
|
4376
4376
|
const s = new Float32Array([
|
|
4377
4377
|
// Front face (z = 0.5)
|
|
4378
4378
|
-0.5,
|
|
@@ -4570,13 +4570,13 @@ function zr() {
|
|
|
4570
4570
|
]);
|
|
4571
4571
|
return { vertices: s, indices: t };
|
|
4572
4572
|
}
|
|
4573
|
-
function
|
|
4573
|
+
function Vr(s = 16, t = 16) {
|
|
4574
4574
|
const e = [], i = [];
|
|
4575
4575
|
for (let r = 0; r <= s; r++) {
|
|
4576
4576
|
const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
|
|
4577
4577
|
for (let l = 0; l <= t; l++) {
|
|
4578
|
-
const c = l * 2 * Math.PI / t, d = Math.sin(c),
|
|
4579
|
-
e.push(
|
|
4578
|
+
const c = l * 2 * Math.PI / t, d = Math.sin(c), g = Math.cos(c) * a, b = o, P = d * a;
|
|
4579
|
+
e.push(g * 0.5, b * 0.5, P * 0.5), e.push(g, b, P);
|
|
4580
4580
|
}
|
|
4581
4581
|
}
|
|
4582
4582
|
for (let r = 0; r < s; r++)
|
|
@@ -4723,7 +4723,7 @@ class Gr {
|
|
|
4723
4723
|
return i;
|
|
4724
4724
|
}
|
|
4725
4725
|
}
|
|
4726
|
-
class
|
|
4726
|
+
class jr {
|
|
4727
4727
|
constructor(t) {
|
|
4728
4728
|
this.device = t, this.objects = [], this.nextId = 0, this.initializeGeometry(), this.onObjectAdded = null, this.onObjectRemoved = null, this.onObjectUpdated = null;
|
|
4729
4729
|
}
|
|
@@ -4731,20 +4731,20 @@ class Nr {
|
|
|
4731
4731
|
* Initialize geometry buffers for cube and sphere
|
|
4732
4732
|
*/
|
|
4733
4733
|
initializeGeometry() {
|
|
4734
|
-
const t =
|
|
4735
|
-
this.cubeVertexBuffer =
|
|
4734
|
+
const t = Fr(), e = Vr(16, 16);
|
|
4735
|
+
this.cubeVertexBuffer = bt(
|
|
4736
4736
|
this.device,
|
|
4737
4737
|
t.vertices,
|
|
4738
4738
|
GPUBufferUsage.VERTEX
|
|
4739
|
-
), this.cubeIndexBuffer =
|
|
4739
|
+
), this.cubeIndexBuffer = bt(
|
|
4740
4740
|
this.device,
|
|
4741
4741
|
t.indices,
|
|
4742
4742
|
GPUBufferUsage.INDEX
|
|
4743
|
-
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer =
|
|
4743
|
+
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer = bt(
|
|
4744
4744
|
this.device,
|
|
4745
4745
|
e.vertices,
|
|
4746
4746
|
GPUBufferUsage.VERTEX
|
|
4747
|
-
), this.sphereIndexBuffer =
|
|
4747
|
+
), this.sphereIndexBuffer = bt(
|
|
4748
4748
|
this.device,
|
|
4749
4749
|
e.indices,
|
|
4750
4750
|
GPUBufferUsage.INDEX
|
|
@@ -4848,16 +4848,16 @@ class Nr {
|
|
|
4848
4848
|
}
|
|
4849
4849
|
}
|
|
4850
4850
|
}
|
|
4851
|
-
function
|
|
4851
|
+
function qr(s) {
|
|
4852
4852
|
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;
|
|
4853
4853
|
return [t, e, i];
|
|
4854
4854
|
}
|
|
4855
|
-
function
|
|
4855
|
+
function Zr(s) {
|
|
4856
4856
|
if (!s) return "#ffffff";
|
|
4857
4857
|
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");
|
|
4858
4858
|
return `#${t}${e}${i}`;
|
|
4859
4859
|
}
|
|
4860
|
-
function
|
|
4860
|
+
function Hr(s, t, e) {
|
|
4861
4861
|
const i = ji([
|
|
4862
4862
|
s[0] - t[0],
|
|
4863
4863
|
s[1] - t[1],
|
|
@@ -4876,13 +4876,13 @@ function qr(s, t, e) {
|
|
|
4876
4876
|
n[2],
|
|
4877
4877
|
i[2],
|
|
4878
4878
|
0,
|
|
4879
|
-
-
|
|
4880
|
-
-
|
|
4881
|
-
-
|
|
4879
|
+
-ai(r, s),
|
|
4880
|
+
-ai(n, s),
|
|
4881
|
+
-ai(i, s),
|
|
4882
4882
|
1
|
|
4883
4883
|
]);
|
|
4884
4884
|
}
|
|
4885
|
-
function
|
|
4885
|
+
function Wr(s, t = Math.PI / 4) {
|
|
4886
4886
|
const r = 1 / Math.tan(t / 2);
|
|
4887
4887
|
return new Float32Array([
|
|
4888
4888
|
r * s,
|
|
@@ -4914,10 +4914,10 @@ function qi(s, t) {
|
|
|
4914
4914
|
s[0] * t[1] - s[1] * t[0]
|
|
4915
4915
|
];
|
|
4916
4916
|
}
|
|
4917
|
-
function
|
|
4917
|
+
function ai(s, t) {
|
|
4918
4918
|
return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
|
|
4919
4919
|
}
|
|
4920
|
-
function
|
|
4920
|
+
function Or(s, t) {
|
|
4921
4921
|
const e = new Float32Array(16);
|
|
4922
4922
|
for (let i = 0; i < 4; i++)
|
|
4923
4923
|
for (let r = 0; r < 4; r++) {
|
|
@@ -4928,7 +4928,7 @@ function Fr(s, t) {
|
|
|
4928
4928
|
}
|
|
4929
4929
|
return e;
|
|
4930
4930
|
}
|
|
4931
|
-
const
|
|
4931
|
+
const li = 1481005640, Ki = 1, Qi = 1313821514, es = 5130562, It = "$hzfxAsset", ts = (s) => typeof atob == "function" ? Uint8Array.from(atob(s), (t) => t.charCodeAt(0)) : new Uint8Array(Buffer.from(s, "base64")), Zi = (s) => {
|
|
4932
4932
|
if (typeof btoa == "function") {
|
|
4933
4933
|
let t = "";
|
|
4934
4934
|
for (let e = 0; e < s.length; e++) t += String.fromCharCode(s[e]);
|
|
@@ -4936,94 +4936,94 @@ const ai = 1481005640, Ki = 1, Qi = 1313821514, es = 5130562, At = "$hzfxAsset",
|
|
|
4936
4936
|
}
|
|
4937
4937
|
return Buffer.from(s).toString("base64");
|
|
4938
4938
|
};
|
|
4939
|
-
function
|
|
4939
|
+
function Lr(s) {
|
|
4940
4940
|
const t = s.indexOf(","), e = s.slice(5, t), i = e.split(";")[0] || "application/octet-stream", r = s.slice(t + 1), a = /;base64/i.test(e) ? ts(r) : new TextEncoder().encode(decodeURIComponent(r));
|
|
4941
4941
|
return { mime: i, bytes: a };
|
|
4942
4942
|
}
|
|
4943
|
-
function
|
|
4943
|
+
function Hi(s) {
|
|
4944
4944
|
return (4 - s % 4) % 4;
|
|
4945
4945
|
}
|
|
4946
|
-
async function
|
|
4946
|
+
async function kr(s, t = {}) {
|
|
4947
4947
|
const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
|
|
4948
4948
|
let a = 0;
|
|
4949
|
-
const o = (
|
|
4950
|
-
const
|
|
4951
|
-
r.push({ offset:
|
|
4952
|
-
const
|
|
4953
|
-
return
|
|
4949
|
+
const o = (O, I, J) => {
|
|
4950
|
+
const K = a, H = O.length;
|
|
4951
|
+
r.push({ offset: K, length: H, mime: I, kind: J }), n.push(O), a += H;
|
|
4952
|
+
const Q = Hi(H);
|
|
4953
|
+
return Q && (n.push(new Uint8Array(Q)), a += Q), r.length - 1;
|
|
4954
4954
|
}, l = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", c = [];
|
|
4955
|
-
for (const
|
|
4956
|
-
const
|
|
4957
|
-
if (typeof
|
|
4958
|
-
let { mime:
|
|
4959
|
-
if (l &&
|
|
4955
|
+
for (const O of s.systems || []) {
|
|
4956
|
+
const I = { ...O };
|
|
4957
|
+
if (typeof I.textureImageData == "string" && I.textureImageData.startsWith("data:")) {
|
|
4958
|
+
let { mime: J, bytes: K } = Lr(I.textureImageData);
|
|
4959
|
+
if (l && J !== "image/webp")
|
|
4960
4960
|
try {
|
|
4961
|
-
const
|
|
4962
|
-
|
|
4963
|
-
const
|
|
4964
|
-
|
|
4961
|
+
const H = await createImageBitmap(new Blob([K], { type: J })), Q = new OffscreenCanvas(H.width, H.height);
|
|
4962
|
+
Q.getContext("2d").drawImage(H, 0, 0);
|
|
4963
|
+
const X = await Q.convertToBlob({ type: "image/webp", quality: i }), et = new Uint8Array(await X.arrayBuffer());
|
|
4964
|
+
et.length < K.length && (K = et, J = "image/webp");
|
|
4965
4965
|
} catch {
|
|
4966
4966
|
}
|
|
4967
|
-
|
|
4967
|
+
I.textureImageData = { [It]: o(K, J, "texture") };
|
|
4968
4968
|
}
|
|
4969
|
-
if (typeof
|
|
4970
|
-
const
|
|
4971
|
-
|
|
4969
|
+
if (typeof I.glbModelData == "string" && I.glbModelData.length > 0) {
|
|
4970
|
+
const J = ts(I.glbModelData);
|
|
4971
|
+
I.glbModelData = { [It]: o(J, "model/gltf-binary", "glb") };
|
|
4972
4972
|
}
|
|
4973
|
-
c.push(
|
|
4974
|
-
}
|
|
4975
|
-
const d = { ...s, systems: c, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)),
|
|
4976
|
-
let
|
|
4977
|
-
for (const
|
|
4978
|
-
|
|
4979
|
-
const
|
|
4980
|
-
let
|
|
4981
|
-
|
|
4982
|
-
for (let
|
|
4983
|
-
return
|
|
4973
|
+
c.push(I);
|
|
4974
|
+
}
|
|
4975
|
+
const d = { ...s, systems: c, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), g = Hi(S.length), b = new Uint8Array(a);
|
|
4976
|
+
let P = 0;
|
|
4977
|
+
for (const O of n)
|
|
4978
|
+
b.set(O, P), P += O.length;
|
|
4979
|
+
const B = S.length + g, z = 20 + B + 8 + a, V = new ArrayBuffer(z), R = new DataView(V), q = new Uint8Array(V);
|
|
4980
|
+
let A = 0;
|
|
4981
|
+
R.setUint32(A, li, !0), A += 4, R.setUint32(A, Ki, !0), A += 4, R.setUint32(A, z, !0), A += 4, R.setUint32(A, B, !0), A += 4, R.setUint32(A, Qi, !0), A += 4, q.set(S, A), A += S.length;
|
|
4982
|
+
for (let O = 0; O < g; O++) q[A++] = 32;
|
|
4983
|
+
return R.setUint32(A, a, !0), A += 4, R.setUint32(A, es, !0), A += 4, q.set(b, A), A += a, V;
|
|
4984
4984
|
}
|
|
4985
4985
|
function is(s) {
|
|
4986
|
-
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) ===
|
|
4986
|
+
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === li;
|
|
4987
4987
|
}
|
|
4988
4988
|
function ss(s) {
|
|
4989
4989
|
const t = new DataView(s);
|
|
4990
|
-
if (t.getUint32(0, !0) !==
|
|
4990
|
+
if (t.getUint32(0, !0) !== li) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
|
|
4991
4991
|
const e = t.getUint32(4, !0);
|
|
4992
4992
|
if (e !== Ki) throw new Error(`[unpackHZFX] unsupported version ${e}`);
|
|
4993
4993
|
let i = 12, r = null, n = -1;
|
|
4994
4994
|
const a = new Uint8Array(s);
|
|
4995
4995
|
for (; i + 8 <= s.byteLength; ) {
|
|
4996
|
-
const
|
|
4996
|
+
const g = t.getUint32(i, !0);
|
|
4997
4997
|
i += 4;
|
|
4998
|
-
const
|
|
4999
|
-
i += 4,
|
|
4998
|
+
const b = t.getUint32(i, !0);
|
|
4999
|
+
i += 4, b === Qi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + g))) : b === es && (n = i), i += g;
|
|
5000
5000
|
}
|
|
5001
5001
|
if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
|
|
5002
|
-
const o = r.assets || [], l = (
|
|
5003
|
-
const
|
|
5004
|
-
return !
|
|
5005
|
-
}, c = (
|
|
5006
|
-
const
|
|
5007
|
-
if (c(
|
|
5008
|
-
const
|
|
5009
|
-
|
|
5002
|
+
const o = r.assets || [], l = (g) => {
|
|
5003
|
+
const b = o[g];
|
|
5004
|
+
return !b || n < 0 ? null : { ...b, bytes: a.subarray(n + b.offset, n + b.offset + b.length) };
|
|
5005
|
+
}, c = (g) => g && typeof g == "object" && typeof g[It] == "number", d = (r.systems || []).map((g) => {
|
|
5006
|
+
const b = { ...g };
|
|
5007
|
+
if (c(b.textureImageData)) {
|
|
5008
|
+
const P = l(b.textureImageData[It]);
|
|
5009
|
+
b.textureImageData = P ? `data:${P.mime};base64,${Zi(P.bytes)}` : void 0;
|
|
5010
5010
|
}
|
|
5011
|
-
if (c(
|
|
5012
|
-
const
|
|
5013
|
-
|
|
5011
|
+
if (c(b.glbModelData)) {
|
|
5012
|
+
const P = l(b.glbModelData[It]);
|
|
5013
|
+
b.glbModelData = P ? Zi(P.bytes) : void 0;
|
|
5014
5014
|
}
|
|
5015
|
-
return
|
|
5015
|
+
return b;
|
|
5016
5016
|
}), S = { ...r, systems: d };
|
|
5017
5017
|
return delete S.assets, S;
|
|
5018
5018
|
}
|
|
5019
|
-
function
|
|
5019
|
+
function Xr(s) {
|
|
5020
5020
|
const t = new Uint8Array(s);
|
|
5021
5021
|
let e = "";
|
|
5022
5022
|
for (let i = 0; i < t.byteLength; i++)
|
|
5023
5023
|
e += String.fromCharCode(t[i]);
|
|
5024
5024
|
return btoa(e);
|
|
5025
5025
|
}
|
|
5026
|
-
function
|
|
5026
|
+
function Nr(s) {
|
|
5027
5027
|
return {
|
|
5028
5028
|
name: s.name,
|
|
5029
5029
|
id: s.id,
|
|
@@ -5209,7 +5209,7 @@ function kr(s) {
|
|
|
5209
5209
|
displayUnit: s.displayUnit || "m"
|
|
5210
5210
|
};
|
|
5211
5211
|
}
|
|
5212
|
-
async function
|
|
5212
|
+
async function $r(s, t, e = "hzfx") {
|
|
5213
5213
|
if (!s || !s.particleSystems || s.particleSystems.length === 0) {
|
|
5214
5214
|
alert("No particle systems to save.");
|
|
5215
5215
|
return;
|
|
@@ -5219,11 +5219,11 @@ async function Zr(s, t, e = "hzfx") {
|
|
|
5219
5219
|
version: "1.0",
|
|
5220
5220
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5221
5221
|
systems: s.particleSystems.map(({ config: d, system: S }) => ({
|
|
5222
|
-
...
|
|
5222
|
+
...Nr(d),
|
|
5223
5223
|
// single source of truth for config fields
|
|
5224
5224
|
// Binary assets embedded so replaceSystems() can restore them
|
|
5225
5225
|
textureImageData: d.textureEnabled && !d.glbModelEnabled && d.textureImageData ? d.textureImageData : void 0,
|
|
5226
|
-
glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ?
|
|
5226
|
+
glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ? Xr(S.glbRawArrayBuffer) : void 0
|
|
5227
5227
|
})),
|
|
5228
5228
|
activeSystemIndex: s.activeSystemIndex,
|
|
5229
5229
|
loop: s.loop || !1
|
|
@@ -5231,7 +5231,7 @@ async function Zr(s, t, e = "hzfx") {
|
|
|
5231
5231
|
}, r = e === "json" ? "json" : "hzfx";
|
|
5232
5232
|
let n;
|
|
5233
5233
|
if (r === "hzfx") {
|
|
5234
|
-
const d = await
|
|
5234
|
+
const d = await kr(i, { textureFormat: "webp" });
|
|
5235
5235
|
n = new Blob([d], { type: "application/octet-stream" });
|
|
5236
5236
|
} else
|
|
5237
5237
|
n = new Blob([JSON.stringify(i, null, 2)], { type: "application/json" });
|
|
@@ -5248,7 +5248,7 @@ async function Zr(s, t, e = "hzfx") {
|
|
|
5248
5248
|
console.error("Error saving scene:", i), alert("Error saving scene. See console for details.");
|
|
5249
5249
|
}
|
|
5250
5250
|
}
|
|
5251
|
-
function
|
|
5251
|
+
function Jr(s) {
|
|
5252
5252
|
return new Promise((t, e) => {
|
|
5253
5253
|
try {
|
|
5254
5254
|
const i = s.target.files[0];
|
|
@@ -5279,7 +5279,7 @@ function Wr(s) {
|
|
|
5279
5279
|
}
|
|
5280
5280
|
});
|
|
5281
5281
|
}
|
|
5282
|
-
async function
|
|
5282
|
+
async function Kr(s) {
|
|
5283
5283
|
if (!s || typeof s != "string")
|
|
5284
5284
|
throw new Error("[fetchPreset] url must be a non-empty string");
|
|
5285
5285
|
const t = await fetch(s);
|
|
@@ -5295,7 +5295,7 @@ async function $r(s) {
|
|
|
5295
5295
|
activeSystemIndex: i.activeSystemIndex ?? 0
|
|
5296
5296
|
};
|
|
5297
5297
|
}
|
|
5298
|
-
const
|
|
5298
|
+
const Yr = (s) => `
|
|
5299
5299
|
@vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
|
|
5300
5300
|
var p = array<vec2f, 3>(vec2f(-1.0, -3.0), vec2f(-1.0, 1.0), vec2f(3.0, 1.0));
|
|
5301
5301
|
return vec4f(p[i], 0.0, 1.0);
|
|
@@ -5305,404 +5305,438 @@ const Xr = (s) => `
|
|
|
5305
5305
|
return textureLoad(src, vec2i(pos.xy), 0);
|
|
5306
5306
|
}
|
|
5307
5307
|
`;
|
|
5308
|
-
async function
|
|
5308
|
+
async function Qr(s, t = {}) {
|
|
5309
5309
|
const { getSceneDepth: e = null, autoRespawn: i = !0 } = t;
|
|
5310
5310
|
let r, n, a;
|
|
5311
5311
|
const o = !!(s && s.device && s.context);
|
|
5312
|
-
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await
|
|
5313
|
-
const l = navigator.gpu.getPreferredCanvasFormat(), c = t.manager || new
|
|
5312
|
+
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await Er(a));
|
|
5313
|
+
const l = navigator.gpu.getPreferredCanvasFormat(), c = t.manager || new Ar(r), d = { layouts: {}, pipelines: {} };
|
|
5314
5314
|
function S(u) {
|
|
5315
5315
|
const p = u ? "ms" : "ss";
|
|
5316
5316
|
if (!d.pipelines[p]) {
|
|
5317
|
-
const
|
|
5317
|
+
const m = r.createShaderModule({ code: Yr(u) }), h = r.createBindGroupLayout({
|
|
5318
5318
|
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: u } }]
|
|
5319
5319
|
});
|
|
5320
5320
|
d.layouts[p] = h, d.pipelines[p] = r.createRenderPipeline({
|
|
5321
5321
|
layout: r.createPipelineLayout({ bindGroupLayouts: [h] }),
|
|
5322
|
-
vertex: { module:
|
|
5323
|
-
fragment: { module:
|
|
5322
|
+
vertex: { module: m, entryPoint: "vs" },
|
|
5323
|
+
fragment: { module: m, entryPoint: "fs", targets: [] },
|
|
5324
5324
|
primitive: { topology: "triangle-list" },
|
|
5325
5325
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
|
|
5326
5326
|
});
|
|
5327
5327
|
}
|
|
5328
5328
|
return { pipeline: d.pipelines[p], layout: d.layouts[p] };
|
|
5329
5329
|
}
|
|
5330
|
-
const b = {
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
|
|
5339
|
-
|
|
5330
|
+
const g = "rgba16float", b = 16, P = {
|
|
5331
|
+
source: null,
|
|
5332
|
+
// full-res: a look's systems are drawn here (also the sharp layer of the composite)
|
|
5333
|
+
combined: null,
|
|
5334
|
+
// full-res: scene + every look, tonemapped by the final pass
|
|
5335
|
+
sourceView: null,
|
|
5336
|
+
combinedView: null,
|
|
5337
|
+
blurFromSourceBindGroup: null,
|
|
5338
|
+
// H pass 1: source -> bloomTexA
|
|
5339
|
+
blurFromBBindGroup: null,
|
|
5340
|
+
// H pass 2: bloomTexB -> bloomTexA
|
|
5341
|
+
combinedInitialBindGroup: null,
|
|
5342
|
+
finalBindGroup: null,
|
|
5343
|
+
slots: [],
|
|
5344
|
+
// { buffer, bindGroup }
|
|
5345
|
+
build(u, p) {
|
|
5346
|
+
const m = () => r.createTexture({
|
|
5347
|
+
size: [u, p],
|
|
5348
|
+
format: g,
|
|
5340
5349
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5341
|
-
})
|
|
5350
|
+
});
|
|
5351
|
+
this.source = m(), this.combined = m(), this.sourceView = this.source.createView(), this.combinedView = this.combined.createView(), this.blurFromSourceBindGroup = r.createBindGroup({
|
|
5352
|
+
layout: tt.bloomBindGroupLayout,
|
|
5353
|
+
entries: [
|
|
5354
|
+
{ binding: 0, resource: Xe },
|
|
5355
|
+
{ binding: 1, resource: this.sourceView },
|
|
5356
|
+
{ binding: 2, resource: { buffer: R } }
|
|
5357
|
+
]
|
|
5358
|
+
}), this.blurFromBBindGroup = r.createBindGroup({
|
|
5359
|
+
layout: tt.bloomBindGroupLayout,
|
|
5360
|
+
entries: [
|
|
5361
|
+
{ binding: 0, resource: Xe },
|
|
5362
|
+
{ binding: 1, resource: Gt },
|
|
5363
|
+
{ binding: 2, resource: { buffer: R } }
|
|
5364
|
+
]
|
|
5365
|
+
}), this.combinedInitialBindGroup = r.createBindGroup({
|
|
5366
|
+
layout: tt.compositeBindGroupLayout,
|
|
5367
|
+
entries: [
|
|
5368
|
+
{ binding: 0, resource: Xe },
|
|
5369
|
+
{ binding: 1, resource: Mt },
|
|
5370
|
+
{ binding: 2, resource: Mt },
|
|
5371
|
+
{ binding: 3, resource: { buffer: A } }
|
|
5372
|
+
]
|
|
5373
|
+
}), this.finalBindGroup = r.createBindGroup({
|
|
5374
|
+
layout: tt.compositeBindGroupLayout,
|
|
5375
|
+
entries: [
|
|
5376
|
+
{ binding: 0, resource: Xe },
|
|
5377
|
+
{ binding: 1, resource: this.combinedView },
|
|
5378
|
+
{ binding: 2, resource: Mt },
|
|
5379
|
+
{ binding: 3, resource: { buffer: A } }
|
|
5380
|
+
]
|
|
5381
|
+
});
|
|
5382
|
+
const h = Math.max(this.slots.length, b);
|
|
5383
|
+
for (let y = 0; y < h; y++) this.ensureSlot(y);
|
|
5342
5384
|
},
|
|
5343
|
-
|
|
5344
|
-
|
|
5345
|
-
return
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5385
|
+
ensureSlot(u) {
|
|
5386
|
+
let p = this.slots[u];
|
|
5387
|
+
return p || (p = { buffer: r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST, label: "bloomLookSlot" }), bindGroup: null }, this.slots[u] = p), p.bindGroup = r.createBindGroup({
|
|
5388
|
+
layout: tt.compositeBindGroupLayout,
|
|
5389
|
+
entries: [
|
|
5390
|
+
{ binding: 0, resource: Xe },
|
|
5391
|
+
{ binding: 1, resource: this.sourceView },
|
|
5392
|
+
{ binding: 2, resource: Gt },
|
|
5393
|
+
{ binding: 3, resource: { buffer: p.buffer } }
|
|
5394
|
+
]
|
|
5395
|
+
}), p;
|
|
5351
5396
|
},
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5358
|
-
})), this.combinedTexture;
|
|
5397
|
+
// Detaches the two full-res targets and returns them (resize destroys them one frame later,
|
|
5398
|
+
// an in-flight frame may still reference them).
|
|
5399
|
+
releaseTargets() {
|
|
5400
|
+
const u = [this.source, this.combined];
|
|
5401
|
+
return this.source = this.combined = null, u;
|
|
5359
5402
|
},
|
|
5360
|
-
|
|
5361
|
-
|
|
5403
|
+
destroy() {
|
|
5404
|
+
this.releaseTargets().forEach((u) => u == null ? void 0 : u.destroy()), this.slots.forEach((u) => u.buffer.destroy()), this.slots = [];
|
|
5362
5405
|
}
|
|
5363
|
-
},
|
|
5406
|
+
}, B = {
|
|
5364
5407
|
systemBindGroups: {},
|
|
5365
|
-
systemBloomHorizontalBindGroups: {},
|
|
5366
|
-
secondHorizontalBindGroups: {},
|
|
5367
|
-
systemBloomCompositeBindGroups: {},
|
|
5368
|
-
// Pass 2 per-system bloom composite (cached, was per-frame)
|
|
5369
|
-
combinedBloomCompositeBindGroups: {},
|
|
5370
|
-
// Pass 3 per-system combine (cached, was per-frame)
|
|
5371
|
-
combinedInitialBindGroup: null,
|
|
5372
|
-
// Pass 3 initial non-bloom composite (cached, was per-frame)
|
|
5373
|
-
finalBindGroup: null,
|
|
5374
5408
|
textureStates: {},
|
|
5375
5409
|
textureRefs: {},
|
|
5376
5410
|
clear() {
|
|
5377
|
-
this.systemBindGroups = {}, this.
|
|
5411
|
+
this.systemBindGroups = {}, this.textureStates = {}, this.textureRefs = {};
|
|
5378
5412
|
}
|
|
5379
|
-
},
|
|
5413
|
+
}, z = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), V = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), R = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), q = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), A = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), O = bt(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), I = {}, J = () => bt(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);
|
|
5380
5414
|
c.onSystemCreated = (u) => {
|
|
5381
|
-
|
|
5415
|
+
I[u] || (I[u] = J());
|
|
5382
5416
|
};
|
|
5383
|
-
const
|
|
5384
|
-
function
|
|
5417
|
+
const K = 4e4, H = new Float32Array(K * 8), Q = new Float32Array(K * 4), X = new Float32Array(K * 4), et = r.createBuffer({ size: K * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), St = r.createBuffer({ size: K * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), vt = r.createBuffer({ size: K * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), xt = /* @__PURE__ */ new Map(), Pt = /* @__PURE__ */ new Map(), rs = 8, _e = [];
|
|
5418
|
+
function ci(u) {
|
|
5385
5419
|
for (const p of _e) if (p.ids.has(u)) return p;
|
|
5386
5420
|
return null;
|
|
5387
5421
|
}
|
|
5388
|
-
function
|
|
5422
|
+
function ns(u, p) {
|
|
5389
5423
|
if (!u.pos) return;
|
|
5390
5424
|
u.hist.push({ t: p, x: u.pos[0], y: u.pos[1], z: u.pos[2] });
|
|
5391
|
-
const
|
|
5392
|
-
for (; u.hist.length > 2 && u.hist[0].t <
|
|
5425
|
+
const m = p - rs;
|
|
5426
|
+
for (; u.hist.length > 2 && u.hist[0].t < m; ) u.hist.shift();
|
|
5393
5427
|
}
|
|
5394
|
-
function
|
|
5428
|
+
function ui(u, p, m) {
|
|
5395
5429
|
const h = u.hist;
|
|
5396
5430
|
if (h.length === 0) {
|
|
5397
|
-
const
|
|
5398
|
-
return
|
|
5431
|
+
const w = u.pos;
|
|
5432
|
+
return w && (m[0] = w[0], m[1] = w[1], m[2] = w[2]), m;
|
|
5399
5433
|
}
|
|
5400
|
-
let
|
|
5434
|
+
let y;
|
|
5401
5435
|
if (p >= h[h.length - 1].t)
|
|
5402
|
-
return
|
|
5436
|
+
return y = h[h.length - 1], m[0] = y.x, m[1] = y.y, m[2] = y.z, m;
|
|
5403
5437
|
if (p <= h[0].t)
|
|
5404
|
-
return
|
|
5405
|
-
for (let
|
|
5406
|
-
if (h[
|
|
5407
|
-
const _ = h[
|
|
5408
|
-
return
|
|
5438
|
+
return y = h[0], m[0] = y.x, m[1] = y.y, m[2] = y.z, m;
|
|
5439
|
+
for (let w = h.length - 1; w > 0; w--)
|
|
5440
|
+
if (h[w - 1].t <= p) {
|
|
5441
|
+
const _ = h[w - 1], M = h[w], v = (p - _.t) / Math.max(1e-6, M.t - _.t);
|
|
5442
|
+
return m[0] = _.x + (M.x - _.x) * v, m[1] = _.y + (M.y - _.y) * v, m[2] = _.z + (M.z - _.z) * v, m;
|
|
5409
5443
|
}
|
|
5410
|
-
return
|
|
5444
|
+
return y = h[0], m[0] = y.x, m[1] = y.y, m[2] = y.z, m;
|
|
5411
5445
|
}
|
|
5412
|
-
const pt = Math.PI * 2, ae = new Array(257), oe = new Array(257), le = new Array(257),
|
|
5446
|
+
const pt = Math.PI * 2, ae = new Array(257), oe = new Array(257), le = new Array(257), Yt = new Array(257), jt = new Array(257), qt = new Array(257);
|
|
5413
5447
|
new Array(257), new Array(257), new Array(257);
|
|
5414
|
-
const
|
|
5415
|
-
function
|
|
5416
|
-
const p = u.emissionRotationX || 0,
|
|
5417
|
-
if (!p && !
|
|
5418
|
-
const
|
|
5448
|
+
const Ee = [0, 0, 0];
|
|
5449
|
+
function as(u) {
|
|
5450
|
+
const p = u.emissionRotationX || 0, m = u.emissionRotationY || 0, h = u.emissionRotationZ || 0;
|
|
5451
|
+
if (!p && !m && !h) return null;
|
|
5452
|
+
const y = p * Math.PI / 180, w = m * Math.PI / 180, _ = h * Math.PI / 180, M = Math.cos(y), v = Math.sin(y), f = Math.cos(w), x = Math.sin(w), U = Math.cos(_), D = Math.sin(_);
|
|
5419
5453
|
return [
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
|
|
5425
|
-
|
|
5426
|
-
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5454
|
+
f * U,
|
|
5455
|
+
v * x * U - M * D,
|
|
5456
|
+
M * x * U + v * D,
|
|
5457
|
+
f * D,
|
|
5458
|
+
v * x * D + M * U,
|
|
5459
|
+
M * x * D - v * U,
|
|
5460
|
+
-x,
|
|
5461
|
+
v * f,
|
|
5462
|
+
M * f
|
|
5429
5463
|
];
|
|
5430
5464
|
}
|
|
5431
|
-
function
|
|
5432
|
-
return
|
|
5465
|
+
function Dt(u, p, m, h, y) {
|
|
5466
|
+
return y[0] = u[0] * p + u[1] * m + u[2] * h, y[1] = u[3] * p + u[4] * m + u[5] * h, y[2] = u[6] * p + u[7] * m + u[8] * h, y;
|
|
5433
5467
|
}
|
|
5434
|
-
function
|
|
5435
|
-
let
|
|
5436
|
-
h && (
|
|
5437
|
-
const
|
|
5438
|
-
return _[0] =
|
|
5468
|
+
function os(u, p, m, h, y, w, _) {
|
|
5469
|
+
let M = u, v = p, f = m;
|
|
5470
|
+
h && (Dt(h, M, v, f, _), M = _[0], v = _[1], f = _[2]), M += w.emissionPositionX || 0, v += w.emissionPositionY || 0, f += w.emissionPositionZ || 0, y._simRotMatrix && (Dt(y._simRotMatrix, M, v, f, _), M = _[0], v = _[1], f = _[2]);
|
|
5471
|
+
const x = y._simPosition;
|
|
5472
|
+
return _[0] = M + (x ? x[0] : 0), _[1] = v + (x ? x[1] : 0), _[2] = f + (x ? x[2] : 0), _;
|
|
5439
5473
|
}
|
|
5440
|
-
function
|
|
5441
|
-
let _ = u,
|
|
5442
|
-
return h && (
|
|
5474
|
+
function ls(u, p, m, h, y, w) {
|
|
5475
|
+
let _ = u, M = p, v = m;
|
|
5476
|
+
return h && (Dt(h, _, M, v, w), _ = w[0], M = w[1], v = w[2]), y._simRotMatrix && (Dt(y._simRotMatrix, _, M, v, w), _ = w[0], M = w[1], v = w[2]), w[0] = _, w[1] = M, w[2] = v, w;
|
|
5443
5477
|
}
|
|
5444
|
-
function
|
|
5445
|
-
const
|
|
5446
|
-
let
|
|
5447
|
-
return
|
|
5478
|
+
function Zt(u, p, m, h, y) {
|
|
5479
|
+
const w = p * 2, _ = m * 2, M = 2 * (w + _);
|
|
5480
|
+
let v = (u % 1 + 1) % 1 * M, f = 0, x = 0;
|
|
5481
|
+
return v < w ? (f = -p + v, x = m) : (v -= w) < _ ? (f = p, x = m - v) : (v -= _) < w ? (f = p - v, x = -m) : (v -= w, f = -p, x = -m + v), h === "xz" ? (y[0] = f, y[1] = 0, y[2] = x) : (y[0] = f, y[1] = x, y[2] = 0), y;
|
|
5448
5482
|
}
|
|
5449
|
-
function
|
|
5450
|
-
const p = u.emissionShape,
|
|
5451
|
-
let h = 0,
|
|
5452
|
-
const _ =
|
|
5483
|
+
function cs(u) {
|
|
5484
|
+
const p = u.emissionShape, m = Math.max(1, Math.min(256, Math.floor(u.shapeStrokeSegments ?? 96)));
|
|
5485
|
+
let h = 0, y = !1, w = [0, 0, 1];
|
|
5486
|
+
const _ = Ee;
|
|
5453
5487
|
if (p === "circle") {
|
|
5454
|
-
|
|
5455
|
-
const
|
|
5456
|
-
for (let
|
|
5457
|
-
const
|
|
5458
|
-
ae[
|
|
5488
|
+
y = !0, h = Math.max(3, m), w = [0, 0, 1];
|
|
5489
|
+
const M = u.circleOuterRadius ?? 2;
|
|
5490
|
+
for (let v = 0; v < h; v++) {
|
|
5491
|
+
const f = v / h * pt;
|
|
5492
|
+
ae[v] = Math.cos(f) * M, oe[v] = Math.sin(f) * M, le[v] = 0;
|
|
5459
5493
|
}
|
|
5460
5494
|
} else if (p === "disc") {
|
|
5461
|
-
|
|
5462
|
-
const
|
|
5463
|
-
for (let
|
|
5464
|
-
const
|
|
5465
|
-
ae[
|
|
5495
|
+
y = !0, h = Math.max(3, m), w = [0, 1, 0];
|
|
5496
|
+
const M = u.discRadius ?? 2;
|
|
5497
|
+
for (let v = 0; v < h; v++) {
|
|
5498
|
+
const f = v / h * pt;
|
|
5499
|
+
ae[v] = Math.cos(f) * M, oe[v] = 0, le[v] = Math.sin(f) * M;
|
|
5466
5500
|
}
|
|
5467
5501
|
} else if (p === "annulus") {
|
|
5468
|
-
|
|
5469
|
-
const
|
|
5470
|
-
for (let
|
|
5471
|
-
const
|
|
5472
|
-
ae[
|
|
5502
|
+
y = !0, h = Math.max(3, m), w = [0, 1, 0];
|
|
5503
|
+
const M = u.annulusInnerRadius ?? 1, v = u.annulusOuterRadius ?? 2, f = M + (v - M) * 0.5;
|
|
5504
|
+
for (let x = 0; x < h; x++) {
|
|
5505
|
+
const U = x / h * pt;
|
|
5506
|
+
ae[x] = Math.cos(U) * f, oe[x] = 0, le[x] = Math.sin(U) * f;
|
|
5473
5507
|
}
|
|
5474
5508
|
} else if (p === "arc") {
|
|
5475
|
-
|
|
5476
|
-
const
|
|
5477
|
-
for (let
|
|
5478
|
-
const N = h > 1 ?
|
|
5479
|
-
ae[
|
|
5509
|
+
y = !1, h = Math.max(2, m + 1), w = [0, 0, 1];
|
|
5510
|
+
const M = u.arcInnerRadius ?? 0, v = u.arcOuterRadius ?? 2, f = M > 0 ? M + (v - M) * 0.5 : v, x = (u.arcStartAngle ?? 0) * Math.PI / 180, U = (u.arcEndAngle ?? 180) * Math.PI / 180;
|
|
5511
|
+
for (let D = 0; D < h; D++) {
|
|
5512
|
+
const N = h > 1 ? D / (h - 1) : 0, ie = x + (U - x) * N;
|
|
5513
|
+
ae[D] = Math.cos(ie) * f, oe[D] = Math.sin(ie) * f, le[D] = 0;
|
|
5480
5514
|
}
|
|
5481
5515
|
} else if (p === "square") {
|
|
5482
|
-
|
|
5483
|
-
const
|
|
5484
|
-
for (let
|
|
5485
|
-
|
|
5516
|
+
y = !0, h = Math.max(4, m), w = [0, 0, 1];
|
|
5517
|
+
const M = u.squareSize ?? 2;
|
|
5518
|
+
for (let v = 0; v < h; v++)
|
|
5519
|
+
Zt(v / h, M, M, "xy", _), ae[v] = _[0], oe[v] = _[1], le[v] = _[2];
|
|
5486
5520
|
} else if (p === "rectangle") {
|
|
5487
|
-
|
|
5488
|
-
const
|
|
5489
|
-
for (let
|
|
5490
|
-
|
|
5521
|
+
y = !0, h = Math.max(4, m), w = [0, 0, 1];
|
|
5522
|
+
const M = (u.rectangleWidth ?? 2) * 0.5, v = (u.rectangleHeight ?? 2) * 0.5;
|
|
5523
|
+
for (let f = 0; f < h; f++)
|
|
5524
|
+
Zt(f / h, M, v, "xy", _), ae[f] = _[0], oe[f] = _[1], le[f] = _[2];
|
|
5491
5525
|
} else if (p === "plain") {
|
|
5492
|
-
|
|
5493
|
-
const
|
|
5494
|
-
for (let
|
|
5495
|
-
|
|
5526
|
+
y = !0, h = Math.max(4, m), w = [0, 1, 0];
|
|
5527
|
+
const M = (u.planeWidth ?? 2) * 0.5, v = (u.planeDepth ?? 2) * 0.5;
|
|
5528
|
+
for (let f = 0; f < h; f++)
|
|
5529
|
+
Zt(f / h, M, v, "xz", _), ae[f] = _[0], oe[f] = _[1], le[f] = _[2];
|
|
5496
5530
|
} else if (p === "line") {
|
|
5497
|
-
|
|
5498
|
-
const
|
|
5499
|
-
for (let
|
|
5500
|
-
const
|
|
5501
|
-
ae[
|
|
5531
|
+
y = !1, h = Math.max(2, m + 1), w = [0, 0, 1];
|
|
5532
|
+
const M = u.lineLength ?? 4;
|
|
5533
|
+
for (let v = 0; v < h; v++) {
|
|
5534
|
+
const f = h > 1 ? v / (h - 1) : 0;
|
|
5535
|
+
ae[v] = 0, oe[v] = (f - 0.5) * M, le[v] = 0;
|
|
5502
5536
|
}
|
|
5503
5537
|
} else if (p === "polygon") {
|
|
5504
|
-
|
|
5505
|
-
const
|
|
5506
|
-
for (let
|
|
5507
|
-
const
|
|
5508
|
-
ae[
|
|
5538
|
+
y = !0, h = Math.max(3, m), w = [0, 0, 1];
|
|
5539
|
+
const M = Math.max(3, Math.floor(u.polygonSides ?? 6)), v = u.polygonRadius ?? 2;
|
|
5540
|
+
for (let f = 0; f < h; f++) {
|
|
5541
|
+
const x = f / h * M, U = Math.floor(x), D = x - U, N = U / M * pt, ie = (U + 1) / M * pt, G = Math.cos(N) * v, C = Math.sin(N) * v, ye = Math.cos(ie) * v, ge = Math.sin(ie) * v;
|
|
5542
|
+
ae[f] = G + (ye - G) * D, oe[f] = C + (ge - C) * D, le[f] = 0;
|
|
5509
5543
|
}
|
|
5510
5544
|
} else
|
|
5511
5545
|
h = 0;
|
|
5512
|
-
return { count: h, closed:
|
|
5546
|
+
return { count: h, closed: y, planeNormal: w };
|
|
5513
5547
|
}
|
|
5514
|
-
function
|
|
5515
|
-
if (!
|
|
5516
|
-
const { count: h, closed:
|
|
5548
|
+
function us(u, p, m) {
|
|
5549
|
+
if (!m.shapeStrokeEnabled || m.hidden) return u;
|
|
5550
|
+
const { count: h, closed: y, planeNormal: w } = cs(m);
|
|
5517
5551
|
if (h < 2) return u;
|
|
5518
|
-
const _ =
|
|
5519
|
-
if (
|
|
5520
|
-
|
|
5521
|
-
let
|
|
5522
|
-
const
|
|
5523
|
-
for (let
|
|
5524
|
-
|
|
5525
|
-
const N =
|
|
5552
|
+
const _ = as(m), M = Math.max(1e-4, m.shapeStrokeWidth ?? 0.08), v = Math.max(0, m.opacity ?? 1);
|
|
5553
|
+
if (v <= 0) return u;
|
|
5554
|
+
ls(w[0], w[1], w[2], _, p, Ee);
|
|
5555
|
+
let f = Math.hypot(Ee[0], Ee[1], Ee[2]) || 1;
|
|
5556
|
+
const x = Ee[0] / f, U = Ee[1] / f, D = Ee[2] / f;
|
|
5557
|
+
for (let E = 0; E < h; E++)
|
|
5558
|
+
os(ae[E], oe[E], le[E], _, p, m, Ee), ae[E] = Ee[0], oe[E] = Ee[1], le[E] = Ee[2];
|
|
5559
|
+
const N = m.shapeStrokeShape ?? "straight";
|
|
5526
5560
|
if (N !== "straight") {
|
|
5527
|
-
const
|
|
5528
|
-
for (let
|
|
5529
|
-
const pe =
|
|
5561
|
+
const E = m.shapeStrokeAmplitude ?? 0.08, ee = m.shapeStrokeFrequency ?? 10, Ie = m.shapeStrokeSpeed ?? 0;
|
|
5562
|
+
for (let Z = 0; Z < h; Z++) {
|
|
5563
|
+
const pe = Z === 0 ? y ? h - 1 : 0 : Z - 1, se = Z === h - 1 ? y ? 0 : h - 1 : Z + 1, be = ae[se] - ae[pe], W = oe[se] - oe[pe], te = le[se] - le[pe], $ = U * te - D * W, re = D * be - x * te, ce = x * W - U * be, Se = Math.hypot($, re, ce) || 1, xe = $ / Se, ue = re / Se, qe = ce / Se, Me = y ? Z / h : Z / Math.max(1, h - 1), ve = pt * ee * Me + Ie * Ve;
|
|
5530
5564
|
let he = 0, me = 0;
|
|
5531
|
-
N === "zigzag" ? he =
|
|
5565
|
+
N === "zigzag" ? he = E * Math.sign(Math.sin(ve) || 1) : N === "sine" ? he = E * Math.sin(ve) : N === "spiral" && (he = E * Math.sin(ve), me = E * Math.cos(ve)), ae[Z] += xe * he + x * me, oe[Z] += ue * he + U * me, le[Z] += qe * he + D * me;
|
|
5532
5566
|
}
|
|
5533
5567
|
}
|
|
5534
|
-
const
|
|
5535
|
-
let
|
|
5536
|
-
for (let
|
|
5537
|
-
const
|
|
5538
|
-
|
|
5568
|
+
const ie = y ? h : h - 1, G = m.bloomIntensity || 1, C = m.startColor ?? m.particleColor ?? [1, 1, 1], ye = m.endColor ?? C, ge = m.particleColor ?? C, Ge = m.randomColorEnabled && Array.isArray(m.randomColors) && m.randomColors.length > 0 ? m.randomColors[0] : null, fe = M * 0.5, it = Math.max(M * 4, 1e-4), Ye = (m.shapeStrokeSpeed ?? 0) * Ve;
|
|
5569
|
+
let st = 0;
|
|
5570
|
+
for (let E = 0; E < ie; E++) {
|
|
5571
|
+
const ee = y ? (E + 1) % h : E + 1;
|
|
5572
|
+
st += Math.hypot(ae[ee] - ae[E], oe[ee] - oe[E], le[ee] - le[E]);
|
|
5539
5573
|
}
|
|
5540
|
-
const
|
|
5541
|
-
let
|
|
5542
|
-
for (let
|
|
5543
|
-
const
|
|
5544
|
-
let
|
|
5545
|
-
const
|
|
5546
|
-
|
|
5547
|
-
let
|
|
5548
|
-
if (
|
|
5549
|
-
const ce =
|
|
5550
|
-
|
|
5574
|
+
const ti = y ? Math.max(1, Math.round(st / it)) : Math.max(st / it, 1e-6), Bt = st > 1e-6 ? ti / st : 0;
|
|
5575
|
+
let je = 0, Tt = !1, ut = 0, Ue = 0, dt = 0;
|
|
5576
|
+
for (let E = 0; E < h; E++) {
|
|
5577
|
+
const ee = E === 0 ? y ? h - 1 : 0 : E - 1, Ie = E === h - 1 ? y ? 0 : h - 1 : E + 1;
|
|
5578
|
+
let Z = ae[Ie] - ae[ee], pe = oe[Ie] - oe[ee], se = le[Ie] - le[ee];
|
|
5579
|
+
const be = Math.hypot(Z, pe, se) || 1;
|
|
5580
|
+
Z /= be, pe /= be, se /= be;
|
|
5581
|
+
let W = U * se - D * pe, te = D * Z - x * se, $ = x * pe - U * Z, re = Math.hypot(W, te, $);
|
|
5582
|
+
if (re < 1e-5) {
|
|
5583
|
+
const ce = F.right[0], Se = F.right[1], xe = F.right[2], ue = ce * Z + Se * pe + xe * se;
|
|
5584
|
+
W = ce - ue * Z, te = Se - ue * pe, $ = xe - ue * se, re = Math.hypot(W, te, $);
|
|
5551
5585
|
}
|
|
5552
|
-
if (
|
|
5553
|
-
const ce =
|
|
5554
|
-
|
|
5586
|
+
if (re < 1e-5) {
|
|
5587
|
+
const ce = F.up[0], Se = F.up[1], xe = F.up[2], ue = ce * Z + Se * pe + xe * se;
|
|
5588
|
+
W = ce - ue * Z, te = Se - ue * pe, $ = xe - ue * se, re = Math.hypot(W, te, $) || 1;
|
|
5555
5589
|
}
|
|
5556
|
-
|
|
5590
|
+
W /= re, te /= re, $ /= re, Tt && ut * W + Ue * te + dt * $ < 0 && (W = -W, te = -te, $ = -$), Yt[E] = W, jt[E] = te, qt[E] = $, ut = W, Ue = te, dt = $, Tt = !0;
|
|
5557
5591
|
}
|
|
5558
|
-
for (let
|
|
5559
|
-
const
|
|
5560
|
-
let
|
|
5561
|
-
const ce = Math.hypot(
|
|
5562
|
-
|
|
5563
|
-
const
|
|
5564
|
-
let Me,
|
|
5565
|
-
|
|
5566
|
-
const
|
|
5567
|
-
Ce[u++] =
|
|
5592
|
+
for (let E = 0; E < ie && !(u + 54 > Ce.length); E++) {
|
|
5593
|
+
const ee = y ? (E + 1) % h : E + 1, Ie = ae[E], Z = oe[E], pe = le[E], se = ae[ee], be = oe[ee], W = le[ee];
|
|
5594
|
+
let te = se - Ie, $ = be - Z, re = W - pe;
|
|
5595
|
+
const ce = Math.hypot(te, $, re) || 1;
|
|
5596
|
+
te /= ce, $ /= ce, re /= ce;
|
|
5597
|
+
const Se = y ? E / h : E / Math.max(1, h - 1), xe = y ? ee / h : ee / Math.max(1, h - 1), ue = je * Bt + Ye, qe = (je + ce) * Bt + Ye;
|
|
5598
|
+
let Me, ve, he, me, we, Re;
|
|
5599
|
+
Ge ? (Me = me = Ge[0], ve = we = Ge[1], he = Re = Ge[2]) : m.colorTransitionEnabled ? (Me = C[0] + (ye[0] - C[0]) * Se, ve = C[1] + (ye[1] - C[1]) * Se, he = C[2] + (ye[2] - C[2]) * Se, me = C[0] + (ye[0] - C[0]) * xe, we = C[1] + (ye[1] - C[1]) * xe, Re = C[2] + (ye[2] - C[2]) * xe) : (Me = me = ge[0], ve = we = ge[1], he = Re = ge[2]), Me = Math.min(1, Me * G), ve = Math.min(1, ve * G), he = Math.min(1, he * G), me = Math.min(1, me * G), we = Math.min(1, we * G), Re = Math.min(1, Re * G);
|
|
5600
|
+
const At = Yt[E], yt = jt[E], Oe = qt[E], Le = Yt[ee], ze = jt[ee], Et = qt[ee], Xt = Ie + At * fe, Nt = Z + yt * fe, Ct = pe + Oe * fe, Be = Ie - At * fe, Te = Z - yt * fe, Ae = pe - Oe * fe, rt = se + Le * fe, nt = be + ze * fe, Ut = W + Et * fe, Ze = se - Le * fe, He = be - ze * fe, We = W - Et * fe, ft = (T, k, de, Y, L, j, ne, $e, Je) => {
|
|
5601
|
+
Ce[u++] = T, Ce[u++] = k, Ce[u++] = de, Ce[u++] = Y, Ce[u++] = L, Ce[u++] = j, Ce[u++] = ne, Ce[u++] = $e, Ce[u++] = Je;
|
|
5568
5602
|
};
|
|
5569
|
-
ft(
|
|
5603
|
+
ft(Xt, Nt, Ct, Me, ve, he, v, ue, 0), ft(Be, Te, Ae, Me, ve, he, v, ue, 1), ft(rt, nt, Ut, me, we, Re, v, qe, 0), ft(Be, Te, Ae, Me, ve, he, v, ue, 1), ft(Ze, He, We, me, we, Re, v, qe, 1), ft(rt, nt, Ut, me, we, Re, v, qe, 0), je += ce;
|
|
5570
5604
|
}
|
|
5571
5605
|
return u;
|
|
5572
5606
|
}
|
|
5573
|
-
const
|
|
5574
|
-
function
|
|
5575
|
-
xt.clear(),
|
|
5576
|
-
let u = 0, p = 0,
|
|
5577
|
-
|
|
5578
|
-
for (const { system: h, config:
|
|
5579
|
-
if (
|
|
5580
|
-
if (
|
|
5607
|
+
const ds = 0.41421356;
|
|
5608
|
+
function fs() {
|
|
5609
|
+
xt.clear(), Pt.clear();
|
|
5610
|
+
let u = 0, p = 0, m = 0;
|
|
5611
|
+
F.position[0], F.position[1], F.position[2];
|
|
5612
|
+
for (const { system: h, config: y } of c.particleSystems) {
|
|
5613
|
+
if (y.hidden) continue;
|
|
5614
|
+
if (y.emissionTrailEnabled && !y.glbModelEnabled) {
|
|
5581
5615
|
h.readbackAndProcessParticles();
|
|
5582
|
-
const _ = h.particleData,
|
|
5583
|
-
if (_ &&
|
|
5584
|
-
const
|
|
5585
|
-
for (let ut = 0; ut <
|
|
5586
|
-
const Ue = ut * 8, dt = _[Ue],
|
|
5587
|
-
let
|
|
5588
|
-
const
|
|
5589
|
-
if (
|
|
5590
|
-
const
|
|
5591
|
-
if (
|
|
5592
|
-
const
|
|
5593
|
-
|
|
5616
|
+
const _ = h.particleData, M = h.particleVelocities, v = h.activeParticles;
|
|
5617
|
+
if (_ && M && v > 0) {
|
|
5618
|
+
const f = y.emissionTrailMode === "particles", x = u, U = y.emissionTrailDuration ?? 1, D = y.opacity ?? 1, N = y.particleSize ?? 0.5, ie = y.bloomIntensity || 1, G = Math.max(1, Math.min(64, y.emissionTrailSegments ?? 8)), C = y.emissionTrailShape || "straight", ye = y.followSystemTranslation ?? !0, ge = h._simPosition, Ge = ye && ge ? ge[0] : 0, fe = ye && ge ? ge[1] : 0, it = ye && ge ? ge[2] : 0, Ye = h._simVelocity, st = Ye ? Ye[0] : 0, ti = Ye ? Ye[1] : 0, Bt = Ye ? Ye[2] : 0, je = ci(y.id), Tt = !!(ye && je && je.hist && je.hist.length > 1);
|
|
5619
|
+
for (let ut = 0; ut < v; ut++) {
|
|
5620
|
+
const Ue = ut * 8, dt = _[Ue], E = _[Ue + 1], ee = _[Ue + 2], Ie = dt + Ge, Z = E + fe, pe = ee + it;
|
|
5621
|
+
let se = _[Ue + 3], be = _[Ue + 4], W = _[Ue + 5];
|
|
5622
|
+
const te = _[Ue + 6], $ = _[Ue + 7];
|
|
5623
|
+
if (te >= $ || $ <= 0) continue;
|
|
5624
|
+
const re = te / $;
|
|
5625
|
+
if (y.colorTransitionEnabled) {
|
|
5626
|
+
const T = y.startColor ?? [1, 0, 0], k = y.endColor ?? [0, 0, 1];
|
|
5627
|
+
se = T[0] + (k[0] - T[0]) * re, be = T[1] + (k[1] - T[1]) * re, W = T[2] + (k[2] - T[2]) * re;
|
|
5594
5628
|
}
|
|
5595
|
-
|
|
5629
|
+
se = Math.min(1, se * ie), be = Math.min(1, be * ie), W = Math.min(1, W * ie);
|
|
5596
5630
|
let ce = N;
|
|
5597
|
-
if (
|
|
5598
|
-
const
|
|
5599
|
-
ce = (
|
|
5631
|
+
if (y.randomSize) {
|
|
5632
|
+
const T = Math.sin($ * 54321.67) * 43758.5453 % 1, k = T < 0 ? T + 1 : T;
|
|
5633
|
+
ce = (y.minSize ?? 0.1) + ((y.maxSize ?? 0.5) - (y.minSize ?? 0.1)) * k;
|
|
5600
5634
|
}
|
|
5601
|
-
if (
|
|
5602
|
-
const
|
|
5603
|
-
ce *= 1 - Math.pow(
|
|
5635
|
+
if (y.fadeSizeEnabled) {
|
|
5636
|
+
const T = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
|
|
5637
|
+
ce *= 1 - Math.pow(re, 1 / T);
|
|
5604
5638
|
}
|
|
5605
|
-
if (
|
|
5606
|
-
const
|
|
5607
|
-
ce *= 1 + Math.pow(
|
|
5639
|
+
if (y.increaseSizeEnabled) {
|
|
5640
|
+
const T = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
|
|
5641
|
+
ce *= 1 + Math.pow(re, 1 / T);
|
|
5608
5642
|
}
|
|
5609
|
-
if (ce <= 0 ||
|
|
5610
|
-
const
|
|
5611
|
-
let ue =
|
|
5612
|
-
if (
|
|
5613
|
-
const
|
|
5614
|
-
if (
|
|
5615
|
-
const
|
|
5616
|
-
let
|
|
5617
|
-
if (
|
|
5618
|
-
const
|
|
5619
|
-
|
|
5643
|
+
if (ce <= 0 || re > 0.9) continue;
|
|
5644
|
+
const Se = Math.min((0.9 - re) * (1 / 0.2), 1), xe = 0.75 * ce * ds * Se;
|
|
5645
|
+
let ue = D;
|
|
5646
|
+
if (y.fadeEnabled && (ue *= Math.max(0, 1 - re)), ue *= Se, ue < 0.01) continue;
|
|
5647
|
+
const qe = ut * 4, Me = M[qe], ve = M[qe + 1], he = M[qe + 2], me = Me + st, we = ve + ti, Re = he + Bt, At = Math.sqrt(me * me + we * we + Re * Re);
|
|
5648
|
+
if (At < 1e-3) continue;
|
|
5649
|
+
const yt = 1 / At, Oe = me * yt, Le = we * yt, ze = Re * yt, Et = F.right[0], Xt = F.right[1], Nt = F.right[2];
|
|
5650
|
+
let Ct = Et * Oe + Xt * Le + Nt * ze, Be = Et - Ct * Oe, Te = Xt - Ct * Le, Ae = Nt - Ct * ze, rt = Math.sqrt(Be * Be + Te * Te + Ae * Ae);
|
|
5651
|
+
if (rt < 0.2) {
|
|
5652
|
+
const T = F.up[0], k = F.up[1], de = F.up[2], Y = T * Oe + k * Le + de * ze;
|
|
5653
|
+
Be = T - Y * Oe, Te = k - Y * Le, Ae = de - Y * ze, rt = Math.sqrt(Be * Be + Te * Te + Ae * Ae) || 1;
|
|
5620
5654
|
}
|
|
5621
|
-
|
|
5622
|
-
const
|
|
5623
|
-
if (
|
|
5624
|
-
const
|
|
5625
|
-
if (
|
|
5626
|
-
const
|
|
5627
|
-
for (let L = 0; L <=
|
|
5628
|
-
const j =
|
|
5655
|
+
Be /= rt, Te /= rt, Ae /= rt;
|
|
5656
|
+
const nt = Math.min(U, te);
|
|
5657
|
+
if (nt < 1e-3) continue;
|
|
5658
|
+
const Ut = y.gravityEnabled && y.gravityStrength || 0, Ze = ws, He = Rs, We = Bs;
|
|
5659
|
+
if (y.orientToDirection && y.burstMode && Tt) {
|
|
5660
|
+
const T = h._emitSimRotY || 0, k = Ts, de = As, Y = Es;
|
|
5661
|
+
for (let L = 0; L <= G; L++) {
|
|
5662
|
+
const j = ui(je, Ve - L / G * nt, Pi);
|
|
5629
5663
|
k[L] = j[0], de[L] = j[1], Y[L] = j[2];
|
|
5630
5664
|
}
|
|
5631
|
-
for (let L = 0; L <=
|
|
5632
|
-
const j = L > 0 ? L - 1 : 0,
|
|
5633
|
-
let
|
|
5634
|
-
const
|
|
5635
|
-
Ze[L] = De * dt +
|
|
5665
|
+
for (let L = 0; L <= G; L++) {
|
|
5666
|
+
const j = L > 0 ? L - 1 : 0, ne = L < G ? L + 1 : G;
|
|
5667
|
+
let $e = k[j] - k[ne], Je = Y[j] - Y[ne];
|
|
5668
|
+
const at = (Math.hypot($e, Je) > 1e-5 ? Math.atan2($e, Je) : Math.atan2(st, Bt)) - T, De = Math.cos(at), Fe = Math.sin(at), Qe = L / G * nt, ii = -0.5 * Ut * Qe * Qe;
|
|
5669
|
+
Ze[L] = De * dt + Fe * ee + k[L], He[L] = E + ii + de[L], We[L] = -Fe * dt + De * ee + Y[L];
|
|
5636
5670
|
}
|
|
5637
|
-
} else for (let
|
|
5638
|
-
const k =
|
|
5639
|
-
if (
|
|
5640
|
-
const Y =
|
|
5641
|
-
Ze[
|
|
5671
|
+
} else for (let T = 0; T <= G; T++) {
|
|
5672
|
+
const k = T / G * nt, de = -0.5 * Ut * k * k;
|
|
5673
|
+
if (Tt) {
|
|
5674
|
+
const Y = ui(je, Ve - k, Pi);
|
|
5675
|
+
Ze[T] = dt - Me * k + Y[0], He[T] = E - ve * k + de + Y[1], We[T] = ee - he * k + Y[2];
|
|
5642
5676
|
} else
|
|
5643
|
-
Ze[
|
|
5677
|
+
Ze[T] = Ie - me * k, He[T] = Z - we * k + de, We[T] = pe - Re * k;
|
|
5644
5678
|
}
|
|
5645
|
-
if (
|
|
5646
|
-
const
|
|
5647
|
-
let Y = -ze, L = 0, j =
|
|
5648
|
-
|
|
5649
|
-
const
|
|
5650
|
-
for (let Pe = 1; Pe <=
|
|
5651
|
-
const
|
|
5652
|
-
let
|
|
5653
|
-
|
|
5679
|
+
if (C !== "straight") {
|
|
5680
|
+
const T = y.emissionTrailShapeAmplitude ?? 0.1, k = y.emissionTrailShapeFrequency ?? 4, de = y.emissionTrailShapeSpeed ?? 0;
|
|
5681
|
+
let Y = -ze, L = 0, j = Oe, ne = Math.sqrt(Y * Y + j * j);
|
|
5682
|
+
ne < 1e-6 && (Y = 0, L = ze, j = -Le, ne = Math.sqrt(Y * Y + L * L + j * j) || 1), Y /= ne, L /= ne, j /= ne;
|
|
5683
|
+
const $e = Le * j - ze * L, Je = ze * Y - Oe * j, Ke = Oe * L - Le * Y;
|
|
5684
|
+
for (let Pe = 1; Pe <= G; Pe++) {
|
|
5685
|
+
const at = Pe / G * nt, De = 2 * Math.PI * k * (Ve - at) + de * Ve;
|
|
5686
|
+
let Fe = 0, Qe = 0;
|
|
5687
|
+
C === "zigzag" ? Fe = T * Math.sign(Math.sin(De)) : C === "sine" ? Fe = T * Math.sin(De) : C === "spiral" && (Fe = T * Math.sin(De), Qe = T * Math.cos(De)), Ze[Pe] += Y * Fe + $e * Qe, He[Pe] += L * Fe + Je * Qe, We[Pe] += j * Fe + Ke * Qe;
|
|
5654
5688
|
}
|
|
5655
5689
|
}
|
|
5656
|
-
if (
|
|
5657
|
-
for (let
|
|
5658
|
-
const k =
|
|
5659
|
-
H[j] = de, H[j + 1] = Y, H[j + 2] = L, H[j + 3] =
|
|
5690
|
+
if (f)
|
|
5691
|
+
for (let T = 1; T <= G && u < K; T++) {
|
|
5692
|
+
const k = T / G, de = Ze[T] - Ge, Y = He[T] - fe, L = We[T] - it, j = u * 8, ne = u * 4;
|
|
5693
|
+
H[j] = de, H[j + 1] = Y, H[j + 2] = L, H[j + 3] = se, H[j + 4] = be, H[j + 5] = W, H[j + 6] = te + ($ - te) * k, H[j + 7] = $, Q[ne] = 0, Q[ne + 1] = 0, Q[ne + 2] = 0, Q[ne + 3] = 0, X[ne] = de, X[ne + 1] = Y, X[ne + 2] = L, X[ne + 3] = 0, u++;
|
|
5660
5694
|
}
|
|
5661
5695
|
else
|
|
5662
|
-
for (let
|
|
5663
|
-
const k =
|
|
5664
|
-
|
|
5696
|
+
for (let T = 0; T < G && !(p + 42 > Ne.length); T++) {
|
|
5697
|
+
const k = T / G, de = (T + 1) / G, Y = Ze[T], L = He[T], j = We[T], ne = Ze[T + 1], $e = He[T + 1], Je = We[T + 1], Ke = xe * (1 - k), Pe = xe * (1 - de), at = ue * (1 - k) * (1 - k), De = ue * (1 - de) * (1 - de), Fe = Y + Be * Ke, Qe = L + Te * Ke, ii = j + Ae * Ke, Ei = Y - Be * Ke, Ci = L - Te * Ke, Ui = j - Ae * Ke, Ii = ne + Be * Pe, zi = $e + Te * Pe, Di = Je + Ae * Pe, ks = ne - Be * Pe, Xs = $e - Te * Pe, Ns = Je - Ae * Pe, gt = (Ys, js, qs, Zs) => {
|
|
5698
|
+
Ne[p++] = Ys, Ne[p++] = js, Ne[p++] = qs, Ne[p++] = se, Ne[p++] = be, Ne[p++] = W, Ne[p++] = Zs;
|
|
5665
5699
|
};
|
|
5666
|
-
|
|
5700
|
+
gt(Fe, Qe, ii, at), gt(Ei, Ci, Ui, at), gt(Ii, zi, Di, De), gt(Ei, Ci, Ui, at), gt(ks, Xs, Ns, De), gt(Ii, zi, Di, De);
|
|
5667
5701
|
}
|
|
5668
5702
|
}
|
|
5669
|
-
|
|
5703
|
+
f && u > x && xt.set(y.id, { first: x, count: u - x });
|
|
5670
5704
|
}
|
|
5671
5705
|
}
|
|
5672
|
-
const
|
|
5673
|
-
|
|
5706
|
+
const w = m;
|
|
5707
|
+
m = us(m, h, y), m > w && Pt.set(y.id, { first: w / 9, count: (m - w) / 9 });
|
|
5674
5708
|
}
|
|
5675
|
-
u > 0 && (r.queue.writeBuffer(
|
|
5709
|
+
u > 0 && (r.queue.writeBuffer(et, 0, H, 0, u * 8), r.queue.writeBuffer(St, 0, Q, 0, u * 4), r.queue.writeBuffer(vt, 0, X, 0, u * 4)), _t = p / 7, _t > 0 && r.queue.writeBuffer(Ht, 0, Ne, 0, p), Si = m / 9, Si > 0 && r.queue.writeBuffer(Wt, 0, Ce, 0, m);
|
|
5676
5710
|
}
|
|
5677
|
-
const
|
|
5711
|
+
const di = () => {
|
|
5678
5712
|
const [u, p] = Ji(a.width, a.height);
|
|
5679
|
-
r.queue.writeBuffer(
|
|
5713
|
+
r.queue.writeBuffer(R, 0, new Float32Array([1, 0, u, p, 0, 0, 0, 0])), r.queue.writeBuffer(q, 0, new Float32Array([0, 1, u, p, 0, 0, 0, 0]));
|
|
5680
5714
|
};
|
|
5681
|
-
|
|
5682
|
-
const
|
|
5683
|
-
|
|
5684
|
-
const
|
|
5685
|
-
particlePipeline:
|
|
5686
|
-
particleAdditivePipeline:
|
|
5687
|
-
particleDepthWritePipeline:
|
|
5688
|
-
blurPipeline:
|
|
5689
|
-
compositePipeline:
|
|
5690
|
-
directRenderPipeline:
|
|
5691
|
-
finalCompositePipeline:
|
|
5692
|
-
glbMeshPipeline:
|
|
5693
|
-
} =
|
|
5715
|
+
di();
|
|
5716
|
+
const fi = new Float32Array(16).fill(0);
|
|
5717
|
+
fi[0] = 1, r.queue.writeBuffer(A, 0, fi);
|
|
5718
|
+
const Xe = Dr(r), tt = Ir(r), {
|
|
5719
|
+
particlePipeline: ps,
|
|
5720
|
+
particleAdditivePipeline: hs,
|
|
5721
|
+
particleDepthWritePipeline: ms,
|
|
5722
|
+
blurPipeline: Ft,
|
|
5723
|
+
compositePipeline: ys,
|
|
5724
|
+
directRenderPipeline: gs,
|
|
5725
|
+
finalCompositePipeline: bs,
|
|
5726
|
+
glbMeshPipeline: Ss
|
|
5727
|
+
} = zr(r, l, tt), pi = r.createShaderModule({ code: `
|
|
5694
5728
|
struct U { mvp: mat4x4<f32> };
|
|
5695
5729
|
@group(0) @binding(0) var<uniform> u: U;
|
|
5696
5730
|
struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
|
|
5697
5731
|
struct VOut { @builtin(position) pos: vec4<f32>, @location(0) col: vec4<f32> };
|
|
5698
5732
|
@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; }
|
|
5699
5733
|
@fragment fn fs(i: VOut) -> @location(0) vec4<f32> { return i.col; }
|
|
5700
|
-
` }),
|
|
5734
|
+
` }), hi = r.createBindGroupLayout({
|
|
5701
5735
|
entries: [{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } }]
|
|
5702
|
-
}),
|
|
5703
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5736
|
+
}), vs = r.createRenderPipeline({
|
|
5737
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [hi] }),
|
|
5704
5738
|
vertex: {
|
|
5705
|
-
module:
|
|
5739
|
+
module: pi,
|
|
5706
5740
|
entryPoint: "vs",
|
|
5707
5741
|
buffers: [{ arrayStride: 28, attributes: [
|
|
5708
5742
|
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
@@ -5710,7 +5744,7 @@ async function Jr(s, t = {}) {
|
|
|
5710
5744
|
] }]
|
|
5711
5745
|
},
|
|
5712
5746
|
fragment: {
|
|
5713
|
-
module:
|
|
5747
|
+
module: pi,
|
|
5714
5748
|
entryPoint: "fs",
|
|
5715
5749
|
targets: [{ format: "rgba16float", blend: {
|
|
5716
5750
|
// renders into the HDR sceneTexture
|
|
@@ -5722,16 +5756,16 @@ async function Jr(s, t = {}) {
|
|
|
5722
5756
|
// depth24plus to match the non-bloom pass; test against the resolved scene depth
|
|
5723
5757
|
// (occlusion) but don't write (transparent ribbon).
|
|
5724
5758
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5725
|
-
}),
|
|
5726
|
-
size:
|
|
5759
|
+
}), mi = 512 * 64 * 6, Ne = new Float32Array(mi * 7), Ht = r.createBuffer({
|
|
5760
|
+
size: mi * 7 * 4,
|
|
5727
5761
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5728
5762
|
label: "ribbonBuffer"
|
|
5729
|
-
}),
|
|
5730
|
-
layout:
|
|
5731
|
-
entries: [{ binding: 0, resource: { buffer:
|
|
5763
|
+
}), xs = r.createBindGroup({
|
|
5764
|
+
layout: hi,
|
|
5765
|
+
entries: [{ binding: 0, resource: { buffer: z } }]
|
|
5732
5766
|
});
|
|
5733
|
-
let
|
|
5734
|
-
const
|
|
5767
|
+
let _t = 0;
|
|
5768
|
+
const yi = r.createShaderModule({ code: `
|
|
5735
5769
|
struct Uniforms {
|
|
5736
5770
|
transform: mat4x4<f32>,
|
|
5737
5771
|
cameraPosition: vec3<f32>,
|
|
@@ -5872,10 +5906,10 @@ async function Jr(s, t = {}) {
|
|
|
5872
5906
|
}
|
|
5873
5907
|
return vec4<f32>(i.col, i.alpha);
|
|
5874
5908
|
}
|
|
5875
|
-
` }),
|
|
5876
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5909
|
+
` }), gi = (u) => r.createRenderPipeline({
|
|
5910
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [tt.particleBindGroupLayout] }),
|
|
5877
5911
|
vertex: {
|
|
5878
|
-
module:
|
|
5912
|
+
module: yi,
|
|
5879
5913
|
entryPoint: "vs",
|
|
5880
5914
|
buffers: [{ arrayStride: 36, attributes: [
|
|
5881
5915
|
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
@@ -5884,32 +5918,33 @@ async function Jr(s, t = {}) {
|
|
|
5884
5918
|
] }]
|
|
5885
5919
|
},
|
|
5886
5920
|
fragment: {
|
|
5887
|
-
module:
|
|
5921
|
+
module: yi,
|
|
5888
5922
|
entryPoint: "fs",
|
|
5889
5923
|
targets: [{ format: "rgba16float", blend: u }]
|
|
5890
5924
|
},
|
|
5891
5925
|
primitive: { topology: "triangle-list" },
|
|
5892
5926
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5893
|
-
}),
|
|
5927
|
+
}), Ps = gi({
|
|
5894
5928
|
color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
5895
5929
|
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5896
|
-
}),
|
|
5930
|
+
}), _s = gi({
|
|
5897
5931
|
color: { srcFactor: "src-alpha", dstFactor: "one", operation: "add" },
|
|
5898
5932
|
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5899
|
-
}),
|
|
5900
|
-
size:
|
|
5933
|
+
}), bi = 256 * 256 * 6, Ce = new Float32Array(bi * 9), Wt = r.createBuffer({
|
|
5934
|
+
size: bi * 9 * 4,
|
|
5901
5935
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5902
5936
|
label: "shapeStrokeBuffer"
|
|
5903
5937
|
});
|
|
5904
|
-
let
|
|
5938
|
+
let Si = 0, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct } = Ni(r, l, a.width, a.height), Vt = Yi(r, a.width, a.height), Mt, vi, Gt, wt;
|
|
5905
5939
|
const xi = () => {
|
|
5906
5940
|
const u = (p) => p.createView();
|
|
5907
|
-
|
|
5941
|
+
Mt = u(ot), vi = u(lt), Gt = u(ct), wt = u(Vt);
|
|
5908
5942
|
};
|
|
5909
5943
|
xi();
|
|
5910
|
-
const
|
|
5911
|
-
let
|
|
5912
|
-
|
|
5944
|
+
const $t = { uniformBuffer: z, appearanceUniformBuffer: V, horizontalBlurUniformBuffer: R, verticalBlurUniformBuffer: q, bloomIntensityBuffer: A };
|
|
5945
|
+
let Ot = ni(r, Xe, $t, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct });
|
|
5946
|
+
P.build(a.width, a.height);
|
|
5947
|
+
const F = {
|
|
5913
5948
|
mvp: new Float32Array(16),
|
|
5914
5949
|
position: new Float32Array([0, 0, 10]),
|
|
5915
5950
|
right: new Float32Array([1, 0, 0]),
|
|
@@ -5917,197 +5952,155 @@ async function Jr(s, t = {}) {
|
|
|
5917
5952
|
up: new Float32Array([0, 1, 0]),
|
|
5918
5953
|
hasCamera: !1
|
|
5919
5954
|
};
|
|
5920
|
-
let Ve = 0,
|
|
5921
|
-
const
|
|
5922
|
-
let _i = !1,
|
|
5955
|
+
let Ve = 0, Ms = 0;
|
|
5956
|
+
const ht = new Float32Array(5), Rt = new Float32Array(8), ws = new Array(65), Rs = new Array(65), Bs = new Array(65), Ts = new Array(65), As = new Array(65), Es = new Array(65), Pi = [0, 0, 0], mt = { key: null, ms: !1, bindGroup: null };
|
|
5957
|
+
let _i = !1, Jt = !0, Lt = !1, kt = null, Kt = a.width, Qt = a.height;
|
|
5923
5958
|
function Mi() {
|
|
5924
|
-
const u = [ot, lt, ct,
|
|
5925
|
-
ot = p.sceneTexture, lt = p.bloomTexA, ct = p.bloomTexB,
|
|
5926
|
-
let
|
|
5959
|
+
const u = [ot, lt, ct, Vt, ...P.releaseTargets()], p = Ni(r, l, a.width, a.height);
|
|
5960
|
+
ot = p.sceneTexture, lt = p.bloomTexA, ct = p.bloomTexB, Vt = Yi(r, a.width, a.height), xi(), di(), B.clear(), Ot = ni(r, Xe, $t, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct }), P.build(a.width, a.height);
|
|
5961
|
+
let m = !1;
|
|
5927
5962
|
const h = () => {
|
|
5928
|
-
if (!
|
|
5929
|
-
|
|
5963
|
+
if (!m) {
|
|
5964
|
+
m = !0, requestAnimationFrame(h);
|
|
5930
5965
|
return;
|
|
5931
5966
|
}
|
|
5932
|
-
u.forEach((
|
|
5967
|
+
u.forEach((y) => y == null ? void 0 : y.destroy());
|
|
5933
5968
|
};
|
|
5934
5969
|
requestAnimationFrame(h);
|
|
5935
5970
|
}
|
|
5936
|
-
function
|
|
5937
|
-
|
|
5971
|
+
function Cs(u, p, m) {
|
|
5972
|
+
F.mvp.set(Or(u, p)), p && p.length >= 10 && (F.right[0] = p[0], F.right[1] = p[4], F.right[2] = p[8], F.up[0] = p[1], F.up[1] = p[5], F.up[2] = p[9]), m && (F.position[0] = m.x ?? m[0], F.position[1] = m.y ?? m[1], F.position[2] = m.z ?? m[2]), F.hasCamera = !0;
|
|
5938
5973
|
}
|
|
5939
|
-
function
|
|
5940
|
-
|
|
5974
|
+
function Us(u, p) {
|
|
5975
|
+
F.mvp.set(u), p && (F.position[0] = p.x ?? p[0], F.position[1] = p.y ?? p[1], F.position[2] = p.z ?? p[2]), F.hasCamera = !0;
|
|
5941
5976
|
}
|
|
5942
|
-
async function
|
|
5943
|
-
if (
|
|
5944
|
-
|
|
5977
|
+
async function ei(u) {
|
|
5978
|
+
if (Lt) {
|
|
5979
|
+
kt = u;
|
|
5945
5980
|
return;
|
|
5946
5981
|
}
|
|
5947
|
-
|
|
5982
|
+
Lt = !0;
|
|
5948
5983
|
try {
|
|
5949
|
-
for (const p in
|
|
5950
|
-
|
|
5984
|
+
for (const p in I) delete I[p];
|
|
5985
|
+
B.clear(), Ot = ni(r, Xe, $t, { sceneTexture: ot, bloomTexA: lt, bloomTexB: ct }), await c.replaceSystems({ systems: [], activeSystemIndex: 0 });
|
|
5951
5986
|
for (const p of u)
|
|
5952
5987
|
await c.addSystems(p.preset, p.position || [0, 0, 0]);
|
|
5953
5988
|
for (const { config: p } of c.particleSystems)
|
|
5954
|
-
|
|
5955
|
-
|
|
5989
|
+
I[p.id] || (I[p.id] = J());
|
|
5990
|
+
Jt = !0, c.respawnAllSystems();
|
|
5956
5991
|
} finally {
|
|
5957
|
-
if (
|
|
5958
|
-
const p =
|
|
5959
|
-
|
|
5992
|
+
if (Lt = !1, kt) {
|
|
5993
|
+
const p = kt;
|
|
5994
|
+
kt = null, ei(p);
|
|
5960
5995
|
}
|
|
5961
5996
|
}
|
|
5962
5997
|
}
|
|
5963
|
-
async function
|
|
5964
|
-
return
|
|
5998
|
+
async function Is(u, p = [0, 0, 0]) {
|
|
5999
|
+
return ei([{ preset: u, position: p }]);
|
|
5965
6000
|
}
|
|
5966
|
-
function
|
|
5967
|
-
if (_i ||
|
|
6001
|
+
function zs(u) {
|
|
6002
|
+
if (_i || Lt || !c.ready || u <= 0 || c.particleSystems.length === 0) return;
|
|
5968
6003
|
const p = c.clock;
|
|
5969
6004
|
if (p && (p.loop = c.loop ?? i, p.duration = c.getTotalDuration(), u = p.tick(u)), u > 0.1 && (u = 0.1), u <= 0) return;
|
|
5970
|
-
if ((a.width !==
|
|
5971
|
-
for (const
|
|
5972
|
-
if (
|
|
5973
|
-
const
|
|
5974
|
-
|
|
6005
|
+
if ((a.width !== Kt || a.height !== Qt) && (Kt = a.width, Qt = a.height, Mi()), Ve += u, _e.length) {
|
|
6006
|
+
for (const f of _e) {
|
|
6007
|
+
if (f.getPosition) {
|
|
6008
|
+
const x = f.getPosition();
|
|
6009
|
+
x ? (f.pos || (f.pos = f._posBuf), Array.isArray(x) ? (f.pos[0] = x[0], f.pos[1] = x[1], f.pos[2] = x[2]) : (f.pos[0] = x.x, f.pos[1] = x.y, f.pos[2] = x.z)) : f.pos = null;
|
|
5975
6010
|
}
|
|
5976
|
-
|
|
6011
|
+
f.vel = f._velBuf, f.pos && f.prevPos && f.wasActive && u > 0 ? (f.vel[0] = (f.pos[0] - f.prevPos[0]) / u, f.vel[1] = (f.pos[1] - f.prevPos[1]) / u, f.vel[2] = (f.pos[2] - f.prevPos[2]) / u) : (f.vel[0] = 0, f.vel[1] = 0, f.vel[2] = 0), f.justResumed = !!f.pos && !f.wasActive, f.justResumed && (f.hist.length = 0);
|
|
5977
6012
|
}
|
|
5978
|
-
for (const { system:
|
|
5979
|
-
const
|
|
5980
|
-
if (!(!
|
|
5981
|
-
let
|
|
5982
|
-
if (
|
|
5983
|
-
const
|
|
5984
|
-
Math.hypot(
|
|
6013
|
+
for (const { system: f, config: x } of c.particleSystems) {
|
|
6014
|
+
const U = ci(x.id);
|
|
6015
|
+
if (!(!U || U.historyOnly) && (x.hidden = !U.pos, U.pos)) {
|
|
6016
|
+
let D = null;
|
|
6017
|
+
if (U.orientToDirection && U.vel) {
|
|
6018
|
+
const ie = U.vel[0], G = U.vel[2];
|
|
6019
|
+
Math.hypot(ie, G) > 1e-4 && (D = [0, 0, Math.atan2(ie, G)]);
|
|
5985
6020
|
}
|
|
5986
|
-
|
|
5987
|
-
const
|
|
5988
|
-
(
|
|
6021
|
+
f.setSimulationTransform({ position: U.pos, velocity: U.vel, rotation: D }), f.updateAppearanceUniform();
|
|
6022
|
+
const N = f.activeParticles === 0 && !f.emitting;
|
|
6023
|
+
(U.justResumed || N) && f.spawnParticles();
|
|
5989
6024
|
}
|
|
5990
6025
|
}
|
|
5991
|
-
for (const
|
|
5992
|
-
|
|
5993
|
-
if (globalThis.__HZFX_DEBUG && (
|
|
5994
|
-
const
|
|
5995
|
-
console.info(`[HZFX] movingGroups(${_e.length})=[${
|
|
6026
|
+
for (const f of _e)
|
|
6027
|
+
f.pos ? ns(f, Ve) : f.hist.length = 0, f.pos ? (f._prevPosBuf[0] = f.pos[0], f._prevPosBuf[1] = f.pos[1], f._prevPosBuf[2] = f.pos[2], f.prevPos = f._prevPosBuf) : f.prevPos = null, f.wasActive = !!f.pos;
|
|
6028
|
+
if (globalThis.__HZFX_DEBUG && (Ms++ & 63) === 0) {
|
|
6029
|
+
const f = c.particleSystems.reduce((N, ie) => N + (ie.system.activeParticles | 0), 0), x = _e.find((N) => N.pos), U = x ? Math.hypot(F.position[0] - x.pos[0], F.position[1] - x.pos[1], F.position[2] - x.pos[2]).toFixed(1) : "-", D = _e.map((N) => `{ids:[${[...N.ids]}],pos:${N.pos ? "1" : "0"},hist:${N.hist.length}}`).join(",");
|
|
6030
|
+
console.info(`[HZFX] movingGroups(${_e.length})=[${D}] activeParticles=${f} systems=${c.particleSystems.length} ribbonVerts=${_t} camDist=${U} t=${Ve.toFixed(1)}`);
|
|
5996
6031
|
}
|
|
5997
6032
|
}
|
|
5998
6033
|
if (c.updateAllSystems(u), p ? p.loop : c.loop ?? i) {
|
|
5999
|
-
const
|
|
6000
|
-
(p && p.justLooped ||
|
|
6034
|
+
const f = c.particleSystems.length > 0 && c.particleSystems.every(({ system: x }) => x.activeParticles === 0 && !x.emitting);
|
|
6035
|
+
(p && p.justLooped || f && Jt) && c.respawnAllSystems(), Jt = !f;
|
|
6001
6036
|
}
|
|
6002
|
-
for (const { system:
|
|
6003
|
-
|
|
6004
|
-
r.queue.writeBuffer(
|
|
6037
|
+
for (const { system: f, config: x } of c.particleSystems)
|
|
6038
|
+
x.glbModelEnabled && f.glbAnimator && (f.glbAnimator.update(u), f.updateAnimatedGLBBuffer());
|
|
6039
|
+
r.queue.writeBuffer(z, 0, F.mvp), ht[0] = F.position[0], ht[1] = F.position[1], ht[2] = F.position[2], ht[3] = a.height / Math.max(1, a.width), ht[4] = Ve, r.queue.writeBuffer(z, 64, ht), fs();
|
|
6005
6040
|
const h = r.createCommandEncoder();
|
|
6006
|
-
let
|
|
6041
|
+
let y = !1;
|
|
6007
6042
|
if (e)
|
|
6008
6043
|
try {
|
|
6009
|
-
const
|
|
6010
|
-
if (
|
|
6011
|
-
let
|
|
6012
|
-
if (
|
|
6013
|
-
const { pipeline:
|
|
6014
|
-
(
|
|
6015
|
-
layout:
|
|
6016
|
-
entries: [{ binding: 0, resource:
|
|
6044
|
+
const f = e();
|
|
6045
|
+
if (f) {
|
|
6046
|
+
let x = null, U = null, D = !1;
|
|
6047
|
+
if (f instanceof GPUTexture ? f.width === a.width && f.height === a.height && (x = f, U = () => f.createView({ aspect: "depth-only" }), D = f.sampleCount > 1) : f.view && (x = f.view, U = () => f.view, D = !!f.multisampled), x) {
|
|
6048
|
+
const { pipeline: N, layout: ie } = S(D);
|
|
6049
|
+
(mt.key !== x || mt.ms !== D) && (mt.key = x, mt.ms = D, mt.bindGroup = r.createBindGroup({
|
|
6050
|
+
layout: ie,
|
|
6051
|
+
entries: [{ binding: 0, resource: U() }]
|
|
6017
6052
|
}));
|
|
6018
|
-
const
|
|
6053
|
+
const G = h.beginRenderPass({
|
|
6019
6054
|
colorAttachments: [],
|
|
6020
|
-
depthStencilAttachment: { view:
|
|
6055
|
+
depthStencilAttachment: { view: wt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
6021
6056
|
});
|
|
6022
|
-
|
|
6057
|
+
G.setPipeline(N), G.setBindGroup(0, mt.bindGroup), G.draw(3), G.end(), y = !0;
|
|
6023
6058
|
}
|
|
6024
6059
|
}
|
|
6025
6060
|
} catch {
|
|
6026
6061
|
}
|
|
6027
|
-
const
|
|
6028
|
-
colorAttachments: [{ view:
|
|
6029
|
-
depthStencilAttachment:
|
|
6062
|
+
const w = h.beginRenderPass({
|
|
6063
|
+
colorAttachments: [{ view: Mt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
6064
|
+
depthStencilAttachment: y ? { view: wt, depthLoadOp: "load", depthStoreOp: "store" } : { view: wt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
6030
6065
|
});
|
|
6031
|
-
for (const { system:
|
|
6032
|
-
|
|
6033
|
-
|
|
6066
|
+
for (const { system: f, config: x } of c.particleSystems)
|
|
6067
|
+
x.bloomEnabled || x.hidden || f.activeParticles === 0 && !Pt.has(x.id) || (Ri(w, f, x), Bi(w, f, x));
|
|
6068
|
+
_t > 0 && (w.setPipeline(vs), w.setBindGroup(0, xs), w.setVertexBuffer(0, Ht), w.draw(_t)), w.end();
|
|
6034
6069
|
const _ = /* @__PURE__ */ new Map();
|
|
6035
|
-
for (const { system:
|
|
6036
|
-
if (!
|
|
6037
|
-
const
|
|
6038
|
-
|
|
6070
|
+
for (const { system: f, config: x } of c.particleSystems) {
|
|
6071
|
+
if (!x.bloomEnabled || x.hidden || f.activeParticles === 0 && !Pt.has(x.id)) continue;
|
|
6072
|
+
const U = x.bloomColor || [1, 1, 1], D = `b${x.bloomIntensity ?? 1}|${U[0]}|${U[1]}|${U[2]}`, N = _.get(D);
|
|
6073
|
+
N ? N.membres.push({ system: f, config: x }) : _.set(D, { membres: [{ system: f, config: x }] });
|
|
6039
6074
|
}
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6075
|
+
const M = h.beginRenderPass({
|
|
6076
|
+
colorAttachments: [{ view: P.combinedView, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6077
|
+
});
|
|
6078
|
+
if (M.setPipeline(gs), M.setBindGroup(0, P.combinedInitialBindGroup), M.draw(3), M.end(), _.size > 0) {
|
|
6079
|
+
const f = {
|
|
6080
|
+
colorAttachments: [{ view: vi, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6081
|
+
}, x = {
|
|
6082
|
+
colorAttachments: [{ view: Gt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6083
|
+
}, U = {
|
|
6084
|
+
colorAttachments: [{ view: P.sourceView, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
6085
|
+
depthStencilAttachment: { view: wt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
6086
|
+
}, D = {
|
|
6087
|
+
colorAttachments: [{ view: P.combinedView, loadOp: "load", storeOp: "store" }]
|
|
6045
6088
|
};
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
{ binding: 2, resource: { buffer: z } }
|
|
6059
|
-
]
|
|
6060
|
-
}));
|
|
6061
|
-
let A = h.beginRenderPass(m);
|
|
6062
|
-
A.setPipeline(It), A.setBindGroup(0, f.systemBloomHorizontalBindGroups[E]), A.draw(3), A.end(), A = h.beginRenderPass(w), A.setPipeline(It), A.setBindGroup(0, Gt.verticalBlurBindGroup), A.draw(3), A.end(), f.secondHorizontalBindGroups[E] || (f.secondHorizontalBindGroups[E] = r.createBindGroup({
|
|
6063
|
-
layout: Ne.bloomBindGroupLayout,
|
|
6064
|
-
entries: [
|
|
6065
|
-
{ binding: 0, resource: Fe },
|
|
6066
|
-
{ binding: 1, resource: Dt },
|
|
6067
|
-
{ binding: 2, resource: { buffer: z } }
|
|
6068
|
-
]
|
|
6069
|
-
})), A = h.beginRenderPass(m), A.setPipeline(It), A.setBindGroup(0, f.secondHorizontalBindGroups[E]), A.draw(3), A.end(), A = h.beginRenderPass(w), A.setPipeline(It), A.setBindGroup(0, Gt.verticalBlurBindGroup), A.draw(3), A.end();
|
|
6070
|
-
const ye = `${E}#${N.premier.config.id}`, xe = b.getBloomCompositeTexture(E, a.width, a.height);
|
|
6071
|
-
A = h.beginRenderPass({
|
|
6072
|
-
colorAttachments: [{ view: xe.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6073
|
-
}), A.setPipeline(ms), f.systemBloomCompositeBindGroups[ye] || (f.systemBloomCompositeBindGroups[ye] = r.createBindGroup({
|
|
6074
|
-
layout: Ne.compositeBindGroupLayout,
|
|
6075
|
-
entries: [
|
|
6076
|
-
{ binding: 0, resource: Fe },
|
|
6077
|
-
{ binding: 1, resource: X.createView() },
|
|
6078
|
-
{ binding: 2, resource: Dt },
|
|
6079
|
-
// ⚠️ L'uniforme du PREMIER membre : la clé de groupe garantit que tous portent la même
|
|
6080
|
-
// intensité et la même couleur, donc n'importe lequel convient — mais il en faut un VRAI,
|
|
6081
|
-
// écrit par `particleSystem`, pas le tampon partagé qui ne porte que l'intensité.
|
|
6082
|
-
{ binding: 3, resource: { buffer: N.premier.bloomIntensityBuffer } }
|
|
6083
|
-
]
|
|
6084
|
-
})), A.setBindGroup(0, f.systemBloomCompositeBindGroups[ye]), A.draw(3), A.end();
|
|
6089
|
+
let N = 0;
|
|
6090
|
+
for (const ie of _.values()) {
|
|
6091
|
+
const G = h.beginRenderPass(U);
|
|
6092
|
+
for (const { system: fe, config: it } of ie.membres)
|
|
6093
|
+
Ri(G, fe, it), Bi(G, fe, it);
|
|
6094
|
+
G.end();
|
|
6095
|
+
let C = h.beginRenderPass(f);
|
|
6096
|
+
C.setPipeline(Ft), C.setBindGroup(0, P.blurFromSourceBindGroup), C.draw(3), C.end(), C = h.beginRenderPass(x), C.setPipeline(Ft), C.setBindGroup(0, Ot.verticalBlurBindGroup), C.draw(3), C.end(), C = h.beginRenderPass(f), C.setPipeline(Ft), C.setBindGroup(0, P.blurFromBBindGroup), C.draw(3), C.end(), C = h.beginRenderPass(x), C.setPipeline(Ft), C.setBindGroup(0, Ot.verticalBlurBindGroup), C.draw(3), C.end();
|
|
6097
|
+
const ye = ie.membres[0].config, ge = ye.bloomColor || [1, 1, 1];
|
|
6098
|
+
Rt[0] = ye.bloomIntensity || 1, Rt[4] = ge[0], Rt[5] = ge[1], Rt[6] = ge[2];
|
|
6099
|
+
const Ge = P.slots[N] || P.ensureSlot(N);
|
|
6100
|
+
N++, r.queue.writeBuffer(Ge.buffer, 0, Rt), C = h.beginRenderPass(D), C.setPipeline(ys), C.setBindGroup(0, Ge.bindGroup), C.draw(3), C.end();
|
|
6085
6101
|
}
|
|
6086
6102
|
}
|
|
6087
|
-
const
|
|
6088
|
-
colorAttachments: [{ view: B.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
6089
|
-
});
|
|
6090
|
-
x.setPipeline(di), f.combinedInitialBindGroup || (f.combinedInitialBindGroup = r.createBindGroup({
|
|
6091
|
-
layout: Ne.compositeBindGroupLayout,
|
|
6092
|
-
entries: [
|
|
6093
|
-
{ binding: 0, resource: Fe },
|
|
6094
|
-
{ binding: 1, resource: ht },
|
|
6095
|
-
{ binding: 2, resource: ht },
|
|
6096
|
-
{ binding: 3, resource: { buffer: M } }
|
|
6097
|
-
]
|
|
6098
|
-
})), x.setBindGroup(0, f.combinedInitialBindGroup), x.draw(3);
|
|
6099
|
-
for (const m of _.keys())
|
|
6100
|
-
x.setPipeline(di), f.combinedBloomCompositeBindGroups[m] || (f.combinedBloomCompositeBindGroups[m] = r.createBindGroup({
|
|
6101
|
-
layout: Ne.compositeBindGroupLayout,
|
|
6102
|
-
entries: [
|
|
6103
|
-
{ binding: 0, resource: Fe },
|
|
6104
|
-
{ binding: 1, resource: b.getBloomCompositeTexture(m, a.width, a.height).createView() },
|
|
6105
|
-
{ binding: 2, resource: ht },
|
|
6106
|
-
{ binding: 3, resource: { buffer: M } }
|
|
6107
|
-
]
|
|
6108
|
-
})), x.setBindGroup(0, f.combinedBloomCompositeBindGroups[m]), x.draw(3);
|
|
6109
|
-
x.end();
|
|
6110
|
-
const R = h.beginRenderPass({
|
|
6103
|
+
const v = h.beginRenderPass({
|
|
6111
6104
|
colorAttachments: [{
|
|
6112
6105
|
view: n.getCurrentTexture().createView(),
|
|
6113
6106
|
loadOp: o ? "load" : "clear",
|
|
@@ -6115,118 +6108,106 @@ async function Jr(s, t = {}) {
|
|
|
6115
6108
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
6116
6109
|
}]
|
|
6117
6110
|
});
|
|
6118
|
-
|
|
6119
|
-
layout: Ne.compositeBindGroupLayout,
|
|
6120
|
-
entries: [
|
|
6121
|
-
{ binding: 0, resource: Fe },
|
|
6122
|
-
{ binding: 1, resource: B.createView() },
|
|
6123
|
-
{ binding: 2, resource: ht },
|
|
6124
|
-
{ binding: 3, resource: { buffer: M } }
|
|
6125
|
-
]
|
|
6126
|
-
})), R.setBindGroup(0, f.finalBindGroup), R.draw(3), R.end(), r.queue.submit([h.finish()]);
|
|
6111
|
+
v.setPipeline(bs), v.setBindGroup(0, P.finalBindGroup), v.draw(3), v.end(), r.queue.submit([h.finish()]);
|
|
6127
6112
|
}
|
|
6128
6113
|
function wi(u, p) {
|
|
6129
|
-
const
|
|
6130
|
-
return
|
|
6131
|
-
layout:
|
|
6114
|
+
const m = u.config.id, h = !B.systemBindGroups[m] || B.textureStates[m] !== p.textureEnabled || B.textureRefs[m] !== u.particleTexture;
|
|
6115
|
+
return B.textureStates[m] = p.textureEnabled, B.textureRefs[m] = u.particleTexture, h && (B.systemBindGroups[m] = r.createBindGroup({
|
|
6116
|
+
layout: tt.particleBindGroupLayout,
|
|
6132
6117
|
entries: [
|
|
6133
|
-
{ binding: 0, resource: { buffer:
|
|
6118
|
+
{ binding: 0, resource: { buffer: z } },
|
|
6134
6119
|
{ binding: 1, resource: { buffer: u.appearanceUniformBuffer } },
|
|
6135
6120
|
{ binding: 2, resource: u.particleTexture.createView() },
|
|
6136
|
-
{ binding: 3, resource:
|
|
6121
|
+
{ binding: 3, resource: Xe }
|
|
6137
6122
|
]
|
|
6138
|
-
})),
|
|
6123
|
+
})), B.systemBindGroups[m];
|
|
6139
6124
|
}
|
|
6140
|
-
function
|
|
6141
|
-
const h = p.config.id,
|
|
6142
|
-
if (
|
|
6143
|
-
_ && (u.setPipeline(
|
|
6125
|
+
function Ri(u, p, m) {
|
|
6126
|
+
const h = p.config.id, y = m.glbModelEnabled && p.glbMeshData, w = wi(p, m), _ = m.shapeDisplay !== !1;
|
|
6127
|
+
if (y)
|
|
6128
|
+
_ && (u.setPipeline(Ss), u.setBindGroup(0, w), u.setVertexBuffer(0, p.glbVertexBuffer), u.setVertexBuffer(1, p.instanceBuffer), u.setVertexBuffer(2, p.velocityBuffer), u.setIndexBuffer(p.glbIndexBuffer, p.glbIndexFormat), u.drawIndexed(p.glbIndexCount, p.activeParticles));
|
|
6144
6129
|
else {
|
|
6145
|
-
u.setPipeline(
|
|
6146
|
-
const
|
|
6147
|
-
|
|
6130
|
+
u.setPipeline(m.blendMode === "additive" ? hs : ps), u.setIndexBuffer(O, "uint16"), I[h] || (I[h] = J()), u.setVertexBuffer(0, I[h]), u.setBindGroup(0, w), _ && (u.setVertexBuffer(1, p.instanceBuffer), u.setVertexBuffer(2, p.velocityBuffer), u.setVertexBuffer(3, p.trailBuffer), u.drawIndexed(6, p.activeParticles));
|
|
6131
|
+
const M = xt.get(h);
|
|
6132
|
+
M && (u.setVertexBuffer(1, et), u.setVertexBuffer(2, St), u.setVertexBuffer(3, vt), u.drawIndexed(6, M.count, 0, 0, M.first)), _ && m.depthWriteEnabled && (u.setPipeline(ms), u.drawIndexed(6, p.activeParticles));
|
|
6148
6133
|
}
|
|
6149
6134
|
}
|
|
6150
|
-
function
|
|
6151
|
-
const h =
|
|
6152
|
-
!h || h.count <= 0 || (u.setPipeline(
|
|
6135
|
+
function Bi(u, p, m) {
|
|
6136
|
+
const h = Pt.get(m.id);
|
|
6137
|
+
!h || h.count <= 0 || (u.setPipeline(m.blendMode === "additive" ? _s : Ps), u.setBindGroup(0, wi(p, m)), u.setVertexBuffer(0, Wt), u.draw(h.count, 1, h.first, 0));
|
|
6153
6138
|
}
|
|
6154
|
-
function
|
|
6155
|
-
|
|
6139
|
+
function Ds() {
|
|
6140
|
+
Kt = a.width, Qt = a.height, Mi();
|
|
6156
6141
|
}
|
|
6157
|
-
function
|
|
6158
|
-
|
|
6142
|
+
function Fs() {
|
|
6143
|
+
B.clear();
|
|
6159
6144
|
}
|
|
6160
|
-
function
|
|
6161
|
-
_i = !0, c.destroy(), [ot, lt, ct,
|
|
6162
|
-
v,
|
|
6163
|
-
U,
|
|
6145
|
+
function Vs() {
|
|
6146
|
+
_i = !0, c.destroy(), [ot, lt, ct, Vt].forEach((u) => u == null ? void 0 : u.destroy()), P.destroy(), [
|
|
6164
6147
|
z,
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
Z,
|
|
6168
|
-
re,
|
|
6148
|
+
V,
|
|
6149
|
+
R,
|
|
6169
6150
|
q,
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6173
|
-
|
|
6151
|
+
A,
|
|
6152
|
+
O,
|
|
6153
|
+
et,
|
|
6154
|
+
St,
|
|
6155
|
+
vt,
|
|
6156
|
+
Ht,
|
|
6157
|
+
Wt
|
|
6158
|
+
].forEach((u) => u == null ? void 0 : u.destroy()), Object.values(I).forEach((u) => u == null ? void 0 : u.destroy());
|
|
6174
6159
|
}
|
|
6175
6160
|
async function Ti(u, p) {
|
|
6176
|
-
const
|
|
6177
|
-
for (const { config:
|
|
6178
|
-
|
|
6179
|
-
const h = new Set(Array.isArray(
|
|
6161
|
+
const m = await c.addSystems(u, p);
|
|
6162
|
+
for (const { config: y } of c.particleSystems)
|
|
6163
|
+
I[y.id] || (I[y.id] = J());
|
|
6164
|
+
const h = new Set(Array.isArray(m) ? m : []);
|
|
6180
6165
|
return c.respawnSystems(h), h;
|
|
6181
6166
|
}
|
|
6182
|
-
function
|
|
6167
|
+
function Ai(u) {
|
|
6183
6168
|
var p;
|
|
6184
|
-
for (const
|
|
6185
|
-
const h = c.particleSystems.findIndex((
|
|
6186
|
-
|
|
6187
|
-
c.removeSystem(h), (p = T[y]) == null || p.destroy(), delete T[y], delete f.systemBindGroups[y], delete f.textureStates[y], delete f.textureRefs[y];
|
|
6188
|
-
const g = `#${y}`;
|
|
6189
|
-
for (const P in f.systemBloomCompositeBindGroups)
|
|
6190
|
-
P.endsWith(g) && delete f.systemBloomCompositeBindGroups[P];
|
|
6169
|
+
for (const m of u) {
|
|
6170
|
+
const h = c.particleSystems.findIndex((y) => y.config.id === m);
|
|
6171
|
+
h < 0 || (c.removeSystem(h), (p = I[m]) == null || p.destroy(), delete I[m], delete B.systemBindGroups[m], delete B.textureStates[m], delete B.textureRefs[m]);
|
|
6191
6172
|
}
|
|
6192
6173
|
}
|
|
6193
6174
|
async function Gs(u, p = [0, 0, 0]) {
|
|
6194
|
-
const
|
|
6175
|
+
const m = await Ti(u, p);
|
|
6195
6176
|
return { remove() {
|
|
6196
|
-
|
|
6177
|
+
Ai(m);
|
|
6197
6178
|
} };
|
|
6198
6179
|
}
|
|
6199
|
-
async function
|
|
6200
|
-
const
|
|
6201
|
-
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...
|
|
6202
|
-
const h = { ids:
|
|
6180
|
+
async function Os(u, p = {}) {
|
|
6181
|
+
const m = await Ti(u, [0, 0, 0]);
|
|
6182
|
+
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...m]}]`);
|
|
6183
|
+
const h = { ids: m, pos: null, hist: [], getPosition: p.getPosition || null, orientToDirection: !!p.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
6203
6184
|
return _e.push(h), {
|
|
6204
|
-
setPosition(
|
|
6205
|
-
|
|
6185
|
+
setPosition(y) {
|
|
6186
|
+
y && (h.pos = Array.isArray(y) ? [y[0], y[1], y[2]] : [y.x, y.y, y.z]);
|
|
6206
6187
|
},
|
|
6207
|
-
setOrientToDirection(
|
|
6208
|
-
h.orientToDirection = !!
|
|
6188
|
+
setOrientToDirection(y) {
|
|
6189
|
+
h.orientToDirection = !!y;
|
|
6209
6190
|
},
|
|
6210
6191
|
remove() {
|
|
6211
|
-
|
|
6212
|
-
const
|
|
6213
|
-
|
|
6192
|
+
Ai(m);
|
|
6193
|
+
const y = _e.indexOf(h);
|
|
6194
|
+
y >= 0 && _e.splice(y, 1);
|
|
6214
6195
|
}
|
|
6215
6196
|
};
|
|
6216
6197
|
}
|
|
6217
|
-
function
|
|
6198
|
+
function Ls(u, p) {
|
|
6218
6199
|
const h = { ids: u instanceof Set ? u : new Set(u), pos: null, hist: [], getPosition: p, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
6219
6200
|
return _e.push(h), {
|
|
6220
6201
|
remove() {
|
|
6221
|
-
const
|
|
6222
|
-
|
|
6202
|
+
const y = _e.indexOf(h);
|
|
6203
|
+
y >= 0 && _e.splice(y, 1);
|
|
6223
6204
|
},
|
|
6224
6205
|
// Update which systems this history group covers WITHOUT losing the accumulated path
|
|
6225
6206
|
// history. Needed when the scene's systems change (e.g. duplicate/add/remove) while the
|
|
6226
6207
|
// group is active — otherwise a newly-added system's id isn't in the set and its trail
|
|
6227
6208
|
// can't follow the recorded movement path (it falls back to straight extrapolation).
|
|
6228
|
-
setIds(
|
|
6229
|
-
h.ids =
|
|
6209
|
+
setIds(y) {
|
|
6210
|
+
h.ids = y instanceof Set ? y : new Set(y);
|
|
6230
6211
|
}
|
|
6231
6212
|
};
|
|
6232
6213
|
}
|
|
@@ -6234,85 +6215,85 @@ async function Jr(s, t = {}) {
|
|
|
6234
6215
|
manager: c,
|
|
6235
6216
|
device: r,
|
|
6236
6217
|
context: n,
|
|
6237
|
-
setCamera:
|
|
6238
|
-
setCameraMVP:
|
|
6239
|
-
setEmitters:
|
|
6240
|
-
loadPreset:
|
|
6218
|
+
setCamera: Cs,
|
|
6219
|
+
setCameraMVP: Us,
|
|
6220
|
+
setEmitters: ei,
|
|
6221
|
+
loadPreset: Is,
|
|
6241
6222
|
addEmitter: Gs,
|
|
6242
|
-
addMovingEmitter:
|
|
6243
|
-
render:
|
|
6244
|
-
resize:
|
|
6245
|
-
clearCaches:
|
|
6246
|
-
trackHistoryGroup:
|
|
6247
|
-
destroy:
|
|
6223
|
+
addMovingEmitter: Os,
|
|
6224
|
+
render: zs,
|
|
6225
|
+
resize: Ds,
|
|
6226
|
+
clearCaches: Fs,
|
|
6227
|
+
trackHistoryGroup: Ls,
|
|
6228
|
+
destroy: Vs
|
|
6248
6229
|
};
|
|
6249
6230
|
}
|
|
6250
|
-
function
|
|
6231
|
+
function en(s) {
|
|
6251
6232
|
return () => {
|
|
6252
6233
|
var t, e, i, r, n, a, o, l;
|
|
6253
6234
|
try {
|
|
6254
6235
|
const c = s.backend;
|
|
6255
6236
|
if (!c) return null;
|
|
6256
|
-
const d = s.domElement.width, S = s.domElement.height,
|
|
6257
|
-
if (s.needsFrameBufferTarget &&
|
|
6258
|
-
const
|
|
6259
|
-
(r =
|
|
6260
|
-
|
|
6261
|
-
(n =
|
|
6237
|
+
const d = s.domElement.width, S = s.domElement.height, g = (typeof s._getFrameBufferTarget == "function" ? s._getFrameBufferTarget() : null) || s._frameBufferTarget || null;
|
|
6238
|
+
if (s.needsFrameBufferTarget && g) {
|
|
6239
|
+
const B = c.get(g), z = ((i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, g)) == null ? void 0 : i.depthTexture) || g.depthTexture, V = [
|
|
6240
|
+
(r = B == null ? void 0 : B.depthTexture) == null ? void 0 : r.texture,
|
|
6241
|
+
B == null ? void 0 : B.depthTexture,
|
|
6242
|
+
(n = B == null ? void 0 : B.depthBuffer) == null ? void 0 : n.texture,
|
|
6262
6243
|
z ? (a = c.get(z)) == null ? void 0 : a.texture : null
|
|
6263
6244
|
];
|
|
6264
|
-
for (const
|
|
6265
|
-
if (
|
|
6245
|
+
for (const R of V)
|
|
6246
|
+
if (R && typeof R.createView == "function" && R.width === d && R.height === S) return R;
|
|
6266
6247
|
return null;
|
|
6267
6248
|
}
|
|
6268
|
-
const
|
|
6269
|
-
return
|
|
6249
|
+
const b = s.getCanvasTarget ? c.get(s.getCanvasTarget()) : null, P = ((l = (o = b == null ? void 0 : b.descriptor) == null ? void 0 : o.depthStencilAttachment) == null ? void 0 : l.view) ?? null;
|
|
6250
|
+
return P ? { view: P, multisampled: (s.currentSamples ?? 0) > 1 } : null;
|
|
6270
6251
|
} catch {
|
|
6271
6252
|
return null;
|
|
6272
6253
|
}
|
|
6273
6254
|
};
|
|
6274
6255
|
}
|
|
6275
6256
|
export {
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6283
|
-
|
|
6284
|
-
|
|
6285
|
-
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6257
|
+
Pr as GLBAnimator,
|
|
6258
|
+
_r as HZClock,
|
|
6259
|
+
jr as Objects3DManager,
|
|
6260
|
+
Hs as ParticleEmitter,
|
|
6261
|
+
ir as ParticlePhysics,
|
|
6262
|
+
Fi as ParticleScript,
|
|
6263
|
+
ri as ParticleSystem,
|
|
6264
|
+
Ar as ParticleSystemManager,
|
|
6265
|
+
sr as ParticleTextureManager,
|
|
6266
|
+
$s as blurShader,
|
|
6267
|
+
Js as compositeShader,
|
|
6268
|
+
Ir as createBindGroupLayouts,
|
|
6269
|
+
ni as createBindGroups,
|
|
6270
|
+
bt as createBuffer,
|
|
6271
|
+
Fr as createCubeGeometry,
|
|
6291
6272
|
Yi as createDepthTexture,
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6273
|
+
Hr as createLookAtMatrix,
|
|
6274
|
+
Wr as createProjectionMatrix,
|
|
6275
|
+
zr as createRenderPipelines,
|
|
6295
6276
|
Ni as createRenderTextures,
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6277
|
+
Dr as createSampler,
|
|
6278
|
+
Vr as createSphereGeometry,
|
|
6279
|
+
Ks as directRenderShader,
|
|
6280
|
+
Gi as extractGLBTexture,
|
|
6281
|
+
Kr as fetchPreset,
|
|
6282
|
+
Ur as glbMeshParticleShader,
|
|
6283
|
+
qr as hexToRgb,
|
|
6284
|
+
Qr as initHzFxOverlay,
|
|
6285
|
+
Er as initWebGPU,
|
|
6305
6286
|
is as isHZFX,
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6287
|
+
Jr as loadScene,
|
|
6288
|
+
en as makeThreeSceneDepth,
|
|
6289
|
+
Or as multiplyMatrices,
|
|
6290
|
+
Cr as object3dShader,
|
|
6291
|
+
kr as packHZFX,
|
|
6292
|
+
cr as parseGLB,
|
|
6293
|
+
er as particlePhysicsShader,
|
|
6294
|
+
Ws as particleShader,
|
|
6295
|
+
Zr as rgbToHex,
|
|
6296
|
+
$r as saveScene,
|
|
6297
|
+
Nr as serializeSystemConfig,
|
|
6317
6298
|
ss as unpackHZFX
|
|
6318
6299
|
};
|