hz-particles 1.4.2 → 1.4.3
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/README.md +1 -1
- package/dist-lib/hz-particles-r3f.cjs +2 -2
- package/dist-lib/hz-particles-r3f.mjs +173 -146
- package/dist-lib/hz-particles.cjs +23 -20
- package/dist-lib/hz-particles.d.ts +4 -3
- package/dist-lib/hz-particles.mjs +423 -407
- package/package.json +1 -1
|
@@ -10,14 +10,14 @@ class ms {
|
|
|
10
10
|
if (t === this._cachedRotX && e === this._cachedRotY && i === this._cachedRotZ)
|
|
11
11
|
return;
|
|
12
12
|
this._cachedRotX = t, this._cachedRotY = e, this._cachedRotZ = i;
|
|
13
|
-
const r = t * Math.PI / 180, n = e * Math.PI / 180, a = i * Math.PI / 180, o = Math.cos(r), c = Math.sin(r), l = Math.cos(n), u = Math.sin(n),
|
|
13
|
+
const r = t * Math.PI / 180, n = e * Math.PI / 180, a = i * Math.PI / 180, o = Math.cos(r), c = Math.sin(r), l = Math.cos(n), u = Math.sin(n), p = Math.cos(a), h = Math.sin(a);
|
|
14
14
|
this._rotMatrix = [
|
|
15
|
-
l * m,
|
|
16
|
-
c * u * m - o * p,
|
|
17
|
-
o * u * m + c * p,
|
|
18
15
|
l * p,
|
|
19
|
-
c * u * p
|
|
20
|
-
o * u * p
|
|
16
|
+
c * u * p - o * h,
|
|
17
|
+
o * u * p + c * h,
|
|
18
|
+
l * h,
|
|
19
|
+
c * u * h + o * p,
|
|
20
|
+
o * u * h - c * p,
|
|
21
21
|
-u,
|
|
22
22
|
c * l,
|
|
23
23
|
o * l
|
|
@@ -35,7 +35,7 @@ class ms {
|
|
|
35
35
|
}
|
|
36
36
|
emitParticle(t, e, i) {
|
|
37
37
|
const r = this._posOut;
|
|
38
|
-
if (this.config.emissionShape === "cube" || this.config.emissionShape === "box" ? this._emitFromCube(r) : this.config.emissionShape === "sphere" ? this._emitFromSphere(r) : this.config.emissionShape === "square" ? this._emitFromSquare(r) : this.config.emissionShape === "circle" ? this._emitFromCircle(r) : this.config.emissionShape === "cylinder" ? this._emitFromCylinder(r) : this.config.emissionShape === "plain" ? this._emitFromPlain(r) : this.config.emissionShape === "cone" ? this._emitFromCone(r) : this.config.emissionShape === "torus" ? this._emitFromTorus(r) : this.config.emissionShape === "line" ? this._emitFromLine(r) : this.config.emissionShape === "hemisphere" ? this._emitFromHemisphere(r) : this.config.emissionShape === "disc" ? this._emitFromDisc(r) : this.config.emissionShape === "annulus" ? this._emitFromAnnulus(r) : this.config.emissionShape === "capsule" ? this._emitFromCapsule(r) : this.config.emissionShape === "arc" ? this._emitFromArc(r) : this.config.emissionShape === "spiral" ? this._emitFromSpiral(r) : this.config.emissionShape === "frustum" ? this._emitFromFrustum(r) : this.config.emissionShape === "cubeSurface" ? this._emitFromCubeSurface(r) : this.config.emissionShape === "sphereSurface" ? this._emitFromSphereSurface(r) : this.config.emissionShape === "boxFrame" ? this._emitFromBoxFrame(r) : this.config.emissionShape === "polygon" ? this._emitFromPolygon(r) : this.config.emissionShape === "rectangle" ? this._emitFromRectangle(r) : (r[0] = 0, r[1] = 0, r[2] = 0), this.config.emissionRotationX || this.config.emissionRotationY || this.config.emissionRotationZ) {
|
|
38
|
+
if (this.config.emissionShape === "cube" || this.config.emissionShape === "box" ? this._emitFromCube(r) : this.config.emissionShape === "sphere" ? this._emitFromSphere(r) : this.config.emissionShape === "square" ? this._emitFromSquare(r) : this.config.emissionShape === "circle" ? this._emitFromCircle(r) : this.config.emissionShape === "cylinder" ? this._emitFromCylinder(r) : this.config.emissionShape === "plain" ? this._emitFromPlain(r) : this.config.emissionShape === "cone" ? this._emitFromCone(r) : this.config.emissionShape === "torus" ? this._emitFromTorus(r) : this.config.emissionShape === "line" ? this._emitFromLine(r) : this.config.emissionShape === "hemisphere" ? this._emitFromHemisphere(r) : this.config.emissionShape === "disc" ? this._emitFromDisc(r) : this.config.emissionShape === "annulus" ? this._emitFromAnnulus(r) : this.config.emissionShape === "capsule" ? this._emitFromCapsule(r) : this.config.emissionShape === "arc" ? this._emitFromArc(r) : this.config.emissionShape === "spiral" ? this._emitFromSpiral(r) : this.config.emissionShape === "frustum" ? this._emitFromFrustum(r) : this.config.emissionShape === "frustumSurface" ? this._emitFromFrustumSurface(r) : this.config.emissionShape === "cubeSurface" ? this._emitFromCubeSurface(r) : this.config.emissionShape === "sphereSurface" ? this._emitFromSphereSurface(r) : this.config.emissionShape === "boxFrame" ? this._emitFromBoxFrame(r) : this.config.emissionShape === "polygon" ? this._emitFromPolygon(r) : this.config.emissionShape === "rectangle" ? this._emitFromRectangle(r) : (r[0] = 0, r[1] = 0, r[2] = 0), this.config.emissionRotationX || this.config.emissionRotationY || this.config.emissionRotationZ) {
|
|
39
39
|
this._updateRotationMatrix();
|
|
40
40
|
const o = this._rotMatrix, c = r[0], l = r[1], u = r[2];
|
|
41
41
|
r[0] = o[0] * c + o[1] * l + o[2] * u, r[1] = o[3] * c + o[4] * l + o[5] * u, r[2] = o[6] * c + o[7] * l + o[8] * u;
|
|
@@ -91,8 +91,8 @@ class ms {
|
|
|
91
91
|
o = n, c = -0.5, l = a;
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
|
-
const u = Math.random(),
|
|
95
|
-
t[0] = o *
|
|
94
|
+
const u = Math.random(), p = e + u * (i - e);
|
|
95
|
+
t[0] = o * p, t[1] = c * p, t[2] = l * p;
|
|
96
96
|
} else
|
|
97
97
|
t[0] = (Math.random() - 0.5) * i, t[1] = (Math.random() - 0.5) * i, t[2] = (Math.random() - 0.5) * i;
|
|
98
98
|
}
|
|
@@ -187,6 +187,18 @@ class ms {
|
|
|
187
187
|
const e = this.config.frustumRadiusNear || 0.5, i = this.config.frustumRadiusFar || 2, r = this.config.frustumHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r, l = (e + (i - e) * a) * Math.sqrt(Math.random());
|
|
188
188
|
t[0] = Math.cos(n) * l, t[1] = o, t[2] = Math.sin(n) * l;
|
|
189
189
|
}
|
|
190
|
+
_emitFromFrustumSurface(t) {
|
|
191
|
+
const e = this.config.frustumRadiusNear ?? 0.5, i = this.config.frustumRadiusFar ?? 2, r = this.config.frustumHeight ?? 4, n = Math.random() * Math.PI * 2, a = i - e, o = e + a * 0.5;
|
|
192
|
+
let c;
|
|
193
|
+
if (Math.abs(a) < 1e-6 || o <= 1e-6)
|
|
194
|
+
c = Math.random();
|
|
195
|
+
else {
|
|
196
|
+
const p = Math.random(), h = 0.5 * a, d = e, b = -p * o, _ = Math.max(0, d * d - 4 * h * b);
|
|
197
|
+
c = (-d + Math.sqrt(_)) / (2 * h), Number.isFinite(c) || (c = Math.random()), c = Math.min(1, Math.max(0, c));
|
|
198
|
+
}
|
|
199
|
+
const l = c * r, u = e + a * c;
|
|
200
|
+
t[0] = Math.cos(n) * u, t[1] = l, t[2] = Math.sin(n) * u;
|
|
201
|
+
}
|
|
190
202
|
_emitFromCubeSurface(t) {
|
|
191
203
|
const e = this.config.cubeSurfaceSize || 2, i = e * 0.5, r = Math.floor(Math.random() * 6), n = (Math.random() - 0.5) * e, a = (Math.random() - 0.5) * e;
|
|
192
204
|
switch (r) {
|
|
@@ -244,33 +256,33 @@ class ms {
|
|
|
244
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;
|
|
245
257
|
}
|
|
246
258
|
calculateVelocity(t, e, i, r, n) {
|
|
247
|
-
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, u = e - o,
|
|
248
|
-
let d, b,
|
|
249
|
-
if (
|
|
259
|
+
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, u = e - o, p = i - c, h = Math.sqrt(l * l + u * u + p * p);
|
|
260
|
+
let d, b, _;
|
|
261
|
+
if (h > 1e-4) {
|
|
250
262
|
let R = !1;
|
|
251
263
|
if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
|
|
252
|
-
const x = this.inverseRotation(l, u,
|
|
264
|
+
const x = this.inverseRotation(l, u, p), L = Math.sqrt(x[0] * x[0] + x[1] * x[1]);
|
|
253
265
|
if (L > 1e-4) {
|
|
254
266
|
const P = -x[1] / L, T = x[0] / L, E = this.applyRotation(P, T, 0);
|
|
255
|
-
d = E[0], b = E[1],
|
|
267
|
+
d = E[0], b = E[1], _ = E[2], R = !0;
|
|
256
268
|
}
|
|
257
269
|
} else if (this.config.emissionShape === "cylinder" && this.config.cylinderVelocityDirection === "tangential") {
|
|
258
|
-
const x = this.inverseRotation(l, u,
|
|
270
|
+
const x = this.inverseRotation(l, u, p), L = Math.sqrt(x[0] * x[0] + x[2] * x[2]);
|
|
259
271
|
if (L > 1e-4) {
|
|
260
272
|
const P = -x[2] / L, T = x[0] / L, E = this.applyRotation(P, 0, T);
|
|
261
|
-
d = E[0], b = E[1],
|
|
273
|
+
d = E[0], b = E[1], _ = E[2], R = !0;
|
|
262
274
|
} else {
|
|
263
275
|
const P = Math.random() * Math.PI * 2, T = this.applyRotation(Math.cos(P), 0, Math.sin(P));
|
|
264
|
-
d = T[0], b = T[1],
|
|
276
|
+
d = T[0], b = T[1], _ = T[2], R = !0;
|
|
265
277
|
}
|
|
266
278
|
}
|
|
267
|
-
R || (d = l /
|
|
279
|
+
R || (d = l / h, b = u / h, _ = p / h);
|
|
268
280
|
} else {
|
|
269
281
|
const R = Math.random() * Math.PI * 2, x = Math.acos(2 * Math.random() - 1);
|
|
270
|
-
d = Math.sin(x) * Math.cos(R), b = Math.sin(x) * Math.sin(R),
|
|
282
|
+
d = Math.sin(x) * Math.cos(R), b = Math.sin(x) * Math.sin(R), _ = Math.cos(x);
|
|
271
283
|
}
|
|
272
284
|
let M;
|
|
273
|
-
this.config.randomSpeed ? M = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : M = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : d * M, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : b * M, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity :
|
|
285
|
+
this.config.randomSpeed ? M = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : M = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : d * M, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : b * M, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : _ * M, r[n + 3] = 0;
|
|
274
286
|
}
|
|
275
287
|
setParticleColor(t, e) {
|
|
276
288
|
if (this.config.randomColorEnabled && this.config.randomColors.length > 0) {
|
|
@@ -380,7 +392,7 @@ const ys = `
|
|
|
380
392
|
}
|
|
381
393
|
|
|
382
394
|
@vertex
|
|
383
|
-
fn vs_main(input: VertexInput) -> VertexOutput {
|
|
395
|
+
fn vs_main(input: VertexInput, @builtin(instance_index) instanceIdx: u32) -> VertexOutput {
|
|
384
396
|
var output : VertexOutput;
|
|
385
397
|
|
|
386
398
|
let center = input.particlePosition + appearance.systemOffset;
|
|
@@ -412,10 +424,11 @@ const ys = `
|
|
|
412
424
|
// Determine particle size - use random size if enabled
|
|
413
425
|
var particleSizeFactor = appearance.particleSize;
|
|
414
426
|
if (appearance.randomSize > 0.5) {
|
|
415
|
-
//
|
|
416
|
-
//
|
|
417
|
-
|
|
418
|
-
|
|
427
|
+
// Seed from the PARTICLE INDEX (stable per slot, unique per particle) so each particle in an
|
|
428
|
+
// emission gets its own size. The old seed used lifetime, which is identical for every
|
|
429
|
+
// particle of an emission, so they all came out the SAME size (most visible in burst mode).
|
|
430
|
+
particleSizeFactor = appearance.minSize +
|
|
431
|
+
fract(sin(f32(instanceIdx) * 12.9898 + 78.233) * 43758.5453) *
|
|
419
432
|
(appearance.maxSize - appearance.minSize);
|
|
420
433
|
}
|
|
421
434
|
|
|
@@ -448,10 +461,11 @@ const ys = `
|
|
|
448
461
|
// Create a unique rotation value for each particle
|
|
449
462
|
var particleRotation = appearance.rotation;
|
|
450
463
|
if (appearance.rotationMode == 1.0) {
|
|
451
|
-
//
|
|
452
|
-
//
|
|
453
|
-
|
|
454
|
-
|
|
464
|
+
// Per-particle seed (particle index) — same fix as random size (was seeded on lifetime,
|
|
465
|
+
// identical across an emission, so every particle shared one rotation). Distinct hash constants
|
|
466
|
+
// from size so a particle's size and rotation aren't correlated.
|
|
467
|
+
particleRotation = appearance.minRotation +
|
|
468
|
+
fract(sin(f32(instanceIdx) * 63.746 + 11.135) * 43758.5453) *
|
|
455
469
|
(appearance.maxRotation - appearance.minRotation);
|
|
456
470
|
} else if (appearance.rotationMode == 2.0) {
|
|
457
471
|
// Calculate rotation based on velocity direction in screen space. Use the COMBINED velocity
|
|
@@ -975,7 +989,7 @@ const ys = `
|
|
|
975
989
|
}
|
|
976
990
|
|
|
977
991
|
// 2. Attractor
|
|
978
|
-
if (physics.attractorStrength
|
|
992
|
+
if (physics.attractorStrength != 0.0) {
|
|
979
993
|
let attractorPos = vec3<f32>(physics.attractorPositionX, physics.attractorPositionY, physics.attractorPositionZ);
|
|
980
994
|
let toAttractor = attractorPos - vec3<f32>(posX, posY, posZ);
|
|
981
995
|
let dist = length(toAttractor);
|
|
@@ -1273,8 +1287,8 @@ class _s {
|
|
|
1273
1287
|
o[0] = t, o[1] = i.particleSpeed, o[2] = c.gravity, o[3] = c.turbulence, o[4] = c.attractorStrength, o[5] = c.damping, o[6] = c.attractorPosition[0], o[7] = c.attractorPosition[1], o[8] = c.attractorPosition[2], this._physicsDataU32View[9] = e, o[10] = c.confinementEnabled ? 1 : 0, o[11] = c.confinementShape === "sphere" ? 1 : 0, o[12] = c.confinementMode === "kill" ? 1 : 0, o[13] = c.confinementSpace === "local" ? 1 : 0, o[14] = c.confinementBoxHalfSize[0], o[15] = c.confinementBoxHalfSize[1], o[16] = c.confinementBoxHalfSize[2], o[17] = c.confinementSphereRadius, o[18] = c.confinementRestitution, o[19] = c.confinementFriction, o[20] = c.confinementCenter[0], o[21] = c.confinementCenter[1], o[22] = c.confinementCenter[2], o[23] = c.softBoundaryEnabled ? 1 : 0, o[24] = c.softBoundaryStrength, o[25] = c.softBoundaryFalloff, o[26] = i.velocityStretchEnabled ? 1 : 0, o[27] = i.velocityStretchFactor ?? 1, o[28] = 0, o[29] = 0, o[30] = 0, o[31] = 0, this.device.queue.writeBuffer(this.physicsUniformBuffer, 0, o);
|
|
1274
1288
|
const l = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }), u = l.beginComputePass({ label: "ParticlePhysicsPass" });
|
|
1275
1289
|
u.setPipeline(this.computePipeline), u.setBindGroup(0, this.computeBindGroup);
|
|
1276
|
-
const
|
|
1277
|
-
u.dispatchWorkgroups(
|
|
1290
|
+
const p = Math.max(1, Math.ceil(e / 64));
|
|
1291
|
+
u.dispatchWorkgroups(p, 1, 1), u.end(), a || this.device.queue.submit([l.finish()]), this.lastUpdateTime = performance.now() / 1e3;
|
|
1278
1292
|
}
|
|
1279
1293
|
async readbackAndProcessParticles(t, e, i, r, n) {
|
|
1280
1294
|
if (t <= 0)
|
|
@@ -1326,8 +1340,9 @@ class _s {
|
|
|
1326
1340
|
setGravity(t) {
|
|
1327
1341
|
this.physicsSettings.gravity = t;
|
|
1328
1342
|
}
|
|
1329
|
-
setAttractor(t, e) {
|
|
1330
|
-
|
|
1343
|
+
setAttractor(t, e, i = !1) {
|
|
1344
|
+
const r = Math.abs(t || 0);
|
|
1345
|
+
this.physicsSettings.attractorStrength = i ? -r : r, this.physicsSettings.attractorPosition = e;
|
|
1331
1346
|
}
|
|
1332
1347
|
setConfinement(t) {
|
|
1333
1348
|
const e = this.physicsSettings;
|
|
@@ -1520,6 +1535,7 @@ const Pi = Object.freeze({
|
|
|
1520
1535
|
"gravityStrength",
|
|
1521
1536
|
"dampingStrength",
|
|
1522
1537
|
"attractorStrength",
|
|
1538
|
+
"attractorReverse",
|
|
1523
1539
|
"attractorPosition",
|
|
1524
1540
|
"pulseAmplitude",
|
|
1525
1541
|
"pulseFrequency",
|
|
@@ -1753,7 +1769,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1753
1769
|
this._fn = null, this._particles = null, this._configProxy = null, this._configSnapshot = null;
|
|
1754
1770
|
}
|
|
1755
1771
|
}
|
|
1756
|
-
async function
|
|
1772
|
+
async function As(s) {
|
|
1757
1773
|
const t = new DataView(s);
|
|
1758
1774
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
1759
1775
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -1765,8 +1781,8 @@ async function Cs(s) {
|
|
|
1765
1781
|
for (; n < r; ) {
|
|
1766
1782
|
const P = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), E = s.slice(n + 8, n + 8 + P);
|
|
1767
1783
|
if (T === 1313821514) {
|
|
1768
|
-
const
|
|
1769
|
-
a = JSON.parse(
|
|
1784
|
+
const N = new TextDecoder("utf-8").decode(E);
|
|
1785
|
+
a = JSON.parse(N);
|
|
1770
1786
|
} else T === 5130562 && (o = E);
|
|
1771
1787
|
n += 8 + P;
|
|
1772
1788
|
}
|
|
@@ -1780,21 +1796,21 @@ async function Cs(s) {
|
|
|
1780
1796
|
const u = l.attributes.POSITION;
|
|
1781
1797
|
if (u === void 0)
|
|
1782
1798
|
throw new Error("Mesh primitive missing POSITION attribute");
|
|
1783
|
-
const
|
|
1784
|
-
let
|
|
1799
|
+
const p = xt(a, o, u, 3, 5126);
|
|
1800
|
+
let h;
|
|
1785
1801
|
if (l.attributes.NORMAL !== void 0)
|
|
1786
|
-
|
|
1802
|
+
h = xt(a, o, l.attributes.NORMAL, 3, 5126);
|
|
1787
1803
|
else {
|
|
1788
1804
|
const P = l.indices;
|
|
1789
1805
|
if (P === void 0)
|
|
1790
1806
|
throw new Error("Cannot generate normals without indices");
|
|
1791
1807
|
const T = di(a, o, P);
|
|
1792
|
-
|
|
1808
|
+
h = Cs(p, T);
|
|
1793
1809
|
}
|
|
1794
1810
|
const d = l.indices;
|
|
1795
1811
|
if (d === void 0)
|
|
1796
1812
|
throw new Error("Mesh primitive missing indices");
|
|
1797
|
-
const b = di(a, o, d),
|
|
1813
|
+
const b = di(a, o, d), _ = p.length / 3, M = b.length;
|
|
1798
1814
|
let R = null;
|
|
1799
1815
|
l.attributes.TEXCOORD_0 !== void 0 && (R = xt(a, o, l.attributes.TEXCOORD_0, 2, 5126));
|
|
1800
1816
|
let x = !1;
|
|
@@ -1805,16 +1821,16 @@ async function Cs(s) {
|
|
|
1805
1821
|
let L = null;
|
|
1806
1822
|
if (a.skins && a.skins.length > 0)
|
|
1807
1823
|
try {
|
|
1808
|
-
L =
|
|
1824
|
+
L = Ds(a, o, l), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", L);
|
|
1809
1825
|
} catch (P) {
|
|
1810
1826
|
console.warn("Failed to extract animation data:", P);
|
|
1811
1827
|
}
|
|
1812
1828
|
return {
|
|
1813
|
-
positions:
|
|
1814
|
-
normals:
|
|
1829
|
+
positions: p,
|
|
1830
|
+
normals: h,
|
|
1815
1831
|
indices: b,
|
|
1816
1832
|
texCoords: R,
|
|
1817
|
-
vertexCount:
|
|
1833
|
+
vertexCount: _,
|
|
1818
1834
|
indexCount: M,
|
|
1819
1835
|
animationData: L,
|
|
1820
1836
|
hasBaseColorTexture: x
|
|
@@ -1831,10 +1847,10 @@ function xt(s, t, e, i, r) {
|
|
|
1831
1847
|
throw new Error(`Attribute accessor type mismatch: expected ${i} components, got ${o}`);
|
|
1832
1848
|
if (n.componentType !== r)
|
|
1833
1849
|
throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
|
|
1834
|
-
const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), u = n.count,
|
|
1850
|
+
const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), u = n.count, p = new DataView(t, l, u * i * 4), h = new Float32Array(u * i);
|
|
1835
1851
|
for (let d = 0; d < u * i; d++)
|
|
1836
|
-
|
|
1837
|
-
return
|
|
1852
|
+
h[d] = p.getFloat32(d * 4, !0);
|
|
1853
|
+
return h;
|
|
1838
1854
|
}
|
|
1839
1855
|
function di(s, t, e) {
|
|
1840
1856
|
const i = s.accessors[e];
|
|
@@ -1854,15 +1870,15 @@ function di(s, t, e) {
|
|
|
1854
1870
|
} else
|
|
1855
1871
|
throw new Error(`Unsupported index component type: ${i.componentType}`);
|
|
1856
1872
|
}
|
|
1857
|
-
function
|
|
1873
|
+
function Cs(s, t) {
|
|
1858
1874
|
const e = new Float32Array(s.length);
|
|
1859
1875
|
for (let i = 0; i < t.length; i += 3) {
|
|
1860
|
-
const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], c = [s[n], s[n + 1], s[n + 2]], l = [s[a], s[a + 1], s[a + 2]], u = [c[0] - o[0], c[1] - o[1], c[2] - o[2]],
|
|
1861
|
-
u[1] *
|
|
1862
|
-
u[2] *
|
|
1863
|
-
u[0] *
|
|
1864
|
-
], d = Math.sqrt(
|
|
1865
|
-
d > 0 && (
|
|
1876
|
+
const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], c = [s[n], s[n + 1], s[n + 2]], l = [s[a], s[a + 1], s[a + 2]], u = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], p = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], h = [
|
|
1877
|
+
u[1] * p[2] - u[2] * p[1],
|
|
1878
|
+
u[2] * p[0] - u[0] * p[2],
|
|
1879
|
+
u[0] * p[1] - u[1] * p[0]
|
|
1880
|
+
], d = Math.sqrt(h[0] * h[0] + h[1] * h[1] + h[2] * h[2]);
|
|
1881
|
+
d > 0 && (h[0] /= d, h[1] /= d, h[2] /= d), e[r] = e[n] = e[a] = h[0], e[r + 1] = e[n + 1] = e[a + 1] = h[1], e[r + 2] = e[n + 2] = e[a + 2] = h[2];
|
|
1866
1882
|
}
|
|
1867
1883
|
return e;
|
|
1868
1884
|
}
|
|
@@ -1924,18 +1940,18 @@ function Gs(s, t, e) {
|
|
|
1924
1940
|
c[l] = o.getFloat32(l * 4, !0);
|
|
1925
1941
|
return c;
|
|
1926
1942
|
}
|
|
1927
|
-
function
|
|
1943
|
+
function Fs(s, t, e) {
|
|
1928
1944
|
const i = s.accessors[e], n = { VEC3: 3, VEC4: 4 }[i.type];
|
|
1929
1945
|
if (!n)
|
|
1930
1946
|
throw new Error(`Expected VEC3 or VEC4, got ${i.type}`);
|
|
1931
1947
|
if (i.componentType !== 5126)
|
|
1932
1948
|
throw new Error(`Expected FLOAT component type, got ${i.componentType}`);
|
|
1933
1949
|
const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), c = i.count, l = new DataView(t, o, c * n * 4), u = new Float32Array(c * n);
|
|
1934
|
-
for (let
|
|
1935
|
-
u[
|
|
1950
|
+
for (let p = 0; p < c * n; p++)
|
|
1951
|
+
u[p] = l.getFloat32(p * 4, !0);
|
|
1936
1952
|
return u;
|
|
1937
1953
|
}
|
|
1938
|
-
function
|
|
1954
|
+
function Ds(s, t, e) {
|
|
1939
1955
|
const i = s.skins[0], r = i.joints, n = zs(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? Us(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? Is(s, t, e.attributes.WEIGHTS_0) : null;
|
|
1940
1956
|
if (!a || !o)
|
|
1941
1957
|
throw new Error("Mesh missing JOINTS_0 or WEIGHTS_0 attributes");
|
|
@@ -1948,22 +1964,22 @@ function Fs(s, t, e) {
|
|
|
1948
1964
|
})), l = [];
|
|
1949
1965
|
if (s.animations && s.animations.length > 0)
|
|
1950
1966
|
for (const u of s.animations) {
|
|
1951
|
-
const
|
|
1952
|
-
let
|
|
1967
|
+
const p = [];
|
|
1968
|
+
let h = 0;
|
|
1953
1969
|
for (const d of u.channels) {
|
|
1954
|
-
const b = u.samplers[d.sampler],
|
|
1955
|
-
R >
|
|
1970
|
+
const b = u.samplers[d.sampler], _ = Gs(s, t, b.input), M = Fs(s, t, b.output), R = _[_.length - 1];
|
|
1971
|
+
R > h && (h = R), p.push({
|
|
1956
1972
|
targetNode: d.target.node,
|
|
1957
1973
|
targetPath: d.target.path,
|
|
1958
1974
|
interpolation: b.interpolation || "LINEAR",
|
|
1959
|
-
timestamps:
|
|
1975
|
+
timestamps: _,
|
|
1960
1976
|
values: M
|
|
1961
1977
|
});
|
|
1962
1978
|
}
|
|
1963
1979
|
l.push({
|
|
1964
1980
|
name: u.name || `Animation ${l.length}`,
|
|
1965
|
-
duration:
|
|
1966
|
-
channels:
|
|
1981
|
+
duration: h,
|
|
1982
|
+
channels: p
|
|
1967
1983
|
});
|
|
1968
1984
|
}
|
|
1969
1985
|
return {
|
|
@@ -1987,8 +2003,8 @@ async function fi(s) {
|
|
|
1987
2003
|
for (; n < r; ) {
|
|
1988
2004
|
const L = t.getUint32(n, !0), P = t.getUint32(n + 4, !0), T = s.slice(n + 8, n + 8 + L);
|
|
1989
2005
|
if (P === 1313821514) {
|
|
1990
|
-
const
|
|
1991
|
-
a = JSON.parse(
|
|
2006
|
+
const D = new TextDecoder("utf-8").decode(T);
|
|
2007
|
+
a = JSON.parse(D);
|
|
1992
2008
|
} else P === 5130562 && (o = T);
|
|
1993
2009
|
n += 8 + L;
|
|
1994
2010
|
}
|
|
@@ -2002,15 +2018,15 @@ async function fi(s) {
|
|
|
2002
2018
|
const l = c.pbrMetallicRoughness.baseColorTexture.index;
|
|
2003
2019
|
if (!a.textures || !a.textures[l])
|
|
2004
2020
|
return null;
|
|
2005
|
-
const
|
|
2006
|
-
if (
|
|
2021
|
+
const p = a.textures[l].source;
|
|
2022
|
+
if (p === void 0 || !a.images || !a.images[p])
|
|
2007
2023
|
return null;
|
|
2008
|
-
const
|
|
2009
|
-
if (
|
|
2024
|
+
const h = a.images[p], d = h.mimeType || "image/png";
|
|
2025
|
+
if (h.bufferView === void 0)
|
|
2010
2026
|
return null;
|
|
2011
2027
|
if (!o)
|
|
2012
2028
|
throw new Error("GLB file missing BIN chunk (required for embedded textures)");
|
|
2013
|
-
const b = a.bufferViews[
|
|
2029
|
+
const b = a.bufferViews[h.bufferView], _ = b.byteOffset || 0, M = b.byteLength, R = o.slice(_, _ + M);
|
|
2014
2030
|
return { imageBlob: new Blob([R], { type: d }), mimeType: d };
|
|
2015
2031
|
}
|
|
2016
2032
|
function Vs(s, t, e, i) {
|
|
@@ -2028,22 +2044,22 @@ function Os(s, t, e, i) {
|
|
|
2028
2044
|
return i[0] = s[0] * c + n * t[0] * l, i[1] = s[1] * c + n * t[1] * l, i[2] = s[2] * c + n * t[2] * l, i[3] = s[3] * c + n * t[3] * l, i;
|
|
2029
2045
|
}
|
|
2030
2046
|
function Ls(s, t) {
|
|
2031
|
-
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, c = r + r, l = e * a, u = e * o,
|
|
2032
|
-
return x[0] = 1 - (
|
|
2047
|
+
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, c = r + r, l = e * a, u = e * o, p = e * c, h = i * o, d = i * c, b = r * c, _ = n * a, M = n * o, R = n * c, x = t || new Float32Array(16);
|
|
2048
|
+
return x[0] = 1 - (h + b), x[1] = u + R, x[2] = p - M, x[3] = 0, x[4] = u - R, x[5] = 1 - (l + b), x[6] = d + _, x[7] = 0, x[8] = p + M, x[9] = d - _, x[10] = 1 - (l + h), x[11] = 0, x[12] = 0, x[13] = 0, x[14] = 0, x[15] = 1, x;
|
|
2033
2049
|
}
|
|
2034
2050
|
const Xs = new Float32Array(16);
|
|
2035
|
-
function
|
|
2051
|
+
function Ns(s, t, e, i) {
|
|
2036
2052
|
const r = Ls(t, Xs), n = i || new Float32Array(16);
|
|
2037
2053
|
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;
|
|
2038
2054
|
}
|
|
2039
|
-
function
|
|
2055
|
+
function hi(s, t, e) {
|
|
2040
2056
|
const i = e || new Float32Array(16);
|
|
2041
2057
|
for (let r = 0; r < 4; r++)
|
|
2042
2058
|
for (let n = 0; n < 4; n++)
|
|
2043
2059
|
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];
|
|
2044
2060
|
return i;
|
|
2045
2061
|
}
|
|
2046
|
-
class
|
|
2062
|
+
class ks {
|
|
2047
2063
|
constructor(t) {
|
|
2048
2064
|
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);
|
|
2049
2065
|
for (let e = 0; e < this.nodes.length; e++)
|
|
@@ -2074,8 +2090,8 @@ class Ns {
|
|
|
2074
2090
|
this._gpuDevice = t, this._gpuOutputBuffer = e;
|
|
2075
2091
|
const r = this.restPositions.length / 3, n = new Float32Array(r * 8);
|
|
2076
2092
|
for (let c = 0; c < r; c++) {
|
|
2077
|
-
const l = c * 8, u = c * 3,
|
|
2078
|
-
n[l] = this.restPositions[u], n[l + 1] = this.restPositions[u + 1], n[l + 2] = this.restPositions[u + 2], n[l + 3] = this.restNormals[u], n[l + 4] = this.restNormals[u + 1], n[l + 5] = this.restNormals[u + 2], n[l + 6] = i ? i[
|
|
2093
|
+
const l = c * 8, u = c * 3, p = c * 2;
|
|
2094
|
+
n[l] = this.restPositions[u], n[l + 1] = this.restPositions[u + 1], n[l + 2] = this.restPositions[u + 2], n[l + 3] = this.restNormals[u], n[l + 4] = this.restNormals[u + 1], n[l + 5] = this.restNormals[u + 2], n[l + 6] = i ? i[p] : 0, n[l + 7] = i ? i[p + 1] : 0;
|
|
2079
2095
|
}
|
|
2080
2096
|
this._gpuRestDataBuffer = t.createBuffer({
|
|
2081
2097
|
size: n.byteLength,
|
|
@@ -2200,11 +2216,11 @@ class Ns {
|
|
|
2200
2216
|
return this._extractValue(n, r.length - 1, o, i);
|
|
2201
2217
|
let c = 0, l = r.length - 1;
|
|
2202
2218
|
for (; l - c > 1; ) {
|
|
2203
|
-
const
|
|
2204
|
-
r[
|
|
2219
|
+
const _ = Math.floor((c + l) / 2);
|
|
2220
|
+
r[_] <= e ? c = _ : l = _;
|
|
2205
2221
|
}
|
|
2206
|
-
const u = r[c],
|
|
2207
|
-
return a === "STEP" ? (i[0] = d[0], i[1] = d[1], i[2] = d[2], o === "rotation" && (i[3] = d[3]), i) : o === "rotation" ? Os(d, b,
|
|
2222
|
+
const u = r[c], p = r[l], h = (e - u) / (p - u), d = this._extractValue(n, c, o, this._sV0), b = this._extractValue(n, l, o, this._sV1);
|
|
2223
|
+
return a === "STEP" ? (i[0] = d[0], i[1] = d[1], i[2] = d[2], o === "rotation" && (i[3] = d[3]), i) : o === "rotation" ? Os(d, b, h, i) : Vs(d, b, h, i);
|
|
2208
2224
|
}
|
|
2209
2225
|
/**
|
|
2210
2226
|
* Extract value from values array at the given index.
|
|
@@ -2229,7 +2245,7 @@ class Ns {
|
|
|
2229
2245
|
let n = r.translation, a = r.rotation, o = r.scale;
|
|
2230
2246
|
for (const c of e.channels)
|
|
2231
2247
|
c.targetNode === i && (c.targetPath === "translation" ? n = this._sampleChannel(c, t, this._scrT) : c.targetPath === "rotation" ? a = this._sampleChannel(c, t, this._scrR) : c.targetPath === "scale" && (o = this._sampleChannel(c, t, this._scrS)));
|
|
2232
|
-
|
|
2248
|
+
Ns(n, a, o, this.jointLocalTransforms[i]);
|
|
2233
2249
|
}
|
|
2234
2250
|
}
|
|
2235
2251
|
/**
|
|
@@ -2239,7 +2255,7 @@ class Ns {
|
|
|
2239
2255
|
const t = this._parentMap;
|
|
2240
2256
|
for (const e of this.topologicalOrder) {
|
|
2241
2257
|
const i = t[e];
|
|
2242
|
-
i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) :
|
|
2258
|
+
i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) : hi(
|
|
2243
2259
|
this.jointGlobalTransforms[i],
|
|
2244
2260
|
this.jointLocalTransforms[e],
|
|
2245
2261
|
this.jointGlobalTransforms[e]
|
|
@@ -2252,7 +2268,7 @@ class Ns {
|
|
|
2252
2268
|
_computeFinalMatrices() {
|
|
2253
2269
|
for (let t = 0; t < this.joints.length; t++) {
|
|
2254
2270
|
const e = this.joints[t], i = this.jointGlobalTransforms[e];
|
|
2255
|
-
|
|
2271
|
+
hi(i, this._invBindViews[t], this.jointFinalMatrices[t]);
|
|
2256
2272
|
}
|
|
2257
2273
|
}
|
|
2258
2274
|
/**
|
|
@@ -2262,16 +2278,16 @@ class Ns {
|
|
|
2262
2278
|
_applySkinning() {
|
|
2263
2279
|
const t = this.restPositions.length / 3, e = this.restPositions, i = this.restNormals, r = this.skinnedPositions, n = this.skinnedNormals, a = this.jointWeights, o = this.jointIndices, c = this.jointFinalMatrices;
|
|
2264
2280
|
for (let l = 0; l < t; l++) {
|
|
2265
|
-
const u = l * 3,
|
|
2266
|
-
let x = 0, L = 0, P = 0, T = 0, E = 0,
|
|
2281
|
+
const u = l * 3, p = l * 4, h = e[u], d = e[u + 1], b = e[u + 2], _ = i[u], M = i[u + 1], R = i[u + 2];
|
|
2282
|
+
let x = 0, L = 0, P = 0, T = 0, E = 0, D = 0;
|
|
2267
2283
|
for (let Y = 0; Y < 4; Y++) {
|
|
2268
|
-
const
|
|
2269
|
-
if (
|
|
2270
|
-
const G = c[o[
|
|
2271
|
-
x += (G[0] *
|
|
2284
|
+
const k = a[p + Y];
|
|
2285
|
+
if (k === 0) continue;
|
|
2286
|
+
const G = c[o[p + Y]];
|
|
2287
|
+
x += (G[0] * h + G[4] * d + G[8] * b + G[12]) * k, L += (G[1] * h + G[5] * d + G[9] * b + G[13]) * k, P += (G[2] * h + G[6] * d + G[10] * b + G[14]) * k, T += (G[0] * _ + G[4] * M + G[8] * R) * k, E += (G[1] * _ + G[5] * M + G[9] * R) * k, D += (G[2] * _ + G[6] * M + G[10] * R) * k;
|
|
2272
2288
|
}
|
|
2273
|
-
const
|
|
2274
|
-
|
|
2289
|
+
const N = Math.sqrt(T * T + E * E + D * D);
|
|
2290
|
+
N > 1e-4 && (n[u] = T / N, n[u + 1] = E / N, n[u + 2] = D / N), r[u] = x, r[u + 1] = L, r[u + 2] = P;
|
|
2275
2291
|
}
|
|
2276
2292
|
}
|
|
2277
2293
|
}
|
|
@@ -2296,7 +2312,7 @@ class js {
|
|
|
2296
2312
|
this.currentTime = Math.max(0, t || 0), this._justLooped = !1;
|
|
2297
2313
|
}
|
|
2298
2314
|
}
|
|
2299
|
-
const
|
|
2315
|
+
const pi = {
|
|
2300
2316
|
linear: (s) => s,
|
|
2301
2317
|
easeInQuad: (s) => s * s,
|
|
2302
2318
|
easeOutQuad: (s) => 1 - (1 - s) * (1 - s),
|
|
@@ -2316,25 +2332,25 @@ const hi = {
|
|
|
2316
2332
|
}
|
|
2317
2333
|
};
|
|
2318
2334
|
function Ys(s, t, e, i) {
|
|
2319
|
-
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, c = 3 * (i - t) - o, l = 1 - o - c, u = (d) => ((a * d + n) * d + r) * d,
|
|
2335
|
+
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, c = 3 * (i - t) - o, l = 1 - o - c, u = (d) => ((a * d + n) * d + r) * d, p = (d) => ((l * d + c) * d + o) * d, h = (d) => (3 * a * d + 2 * n) * d + r;
|
|
2320
2336
|
return (d) => {
|
|
2321
2337
|
if (d <= 0) return 0;
|
|
2322
2338
|
if (d >= 1) return 1;
|
|
2323
2339
|
let b = d;
|
|
2324
|
-
for (let
|
|
2340
|
+
for (let _ = 0; _ < 8; _++) {
|
|
2325
2341
|
const M = u(b) - d;
|
|
2326
2342
|
if (Math.abs(M) < 1e-5) break;
|
|
2327
|
-
const R =
|
|
2343
|
+
const R = h(b);
|
|
2328
2344
|
if (Math.abs(R) < 1e-6) break;
|
|
2329
2345
|
b -= M / R;
|
|
2330
2346
|
}
|
|
2331
|
-
return
|
|
2347
|
+
return p(b);
|
|
2332
2348
|
};
|
|
2333
2349
|
}
|
|
2334
2350
|
function _i(s, t) {
|
|
2335
|
-
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? Ys(s[0], s[1], s[2], s[3])(t) : (
|
|
2351
|
+
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? Ys(s[0], s[1], s[2], s[3])(t) : (pi[s] || pi.linear)(t);
|
|
2336
2352
|
}
|
|
2337
|
-
function
|
|
2353
|
+
function qs(s, t) {
|
|
2338
2354
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2339
2355
|
if (s.length === 1 || t <= s[0].t) return s[0].v;
|
|
2340
2356
|
const e = s[s.length - 1];
|
|
@@ -2348,7 +2364,7 @@ function Hs(s, t) {
|
|
|
2348
2364
|
}
|
|
2349
2365
|
return e.v;
|
|
2350
2366
|
}
|
|
2351
|
-
function
|
|
2367
|
+
function Hs(s, t, e) {
|
|
2352
2368
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2353
2369
|
const i = s.length, r = s[i - 1];
|
|
2354
2370
|
let n, a, o;
|
|
@@ -2358,11 +2374,11 @@ function qs(s, t, e) {
|
|
|
2358
2374
|
n = a = r.v, o = 0;
|
|
2359
2375
|
else {
|
|
2360
2376
|
n = a = r.v, o = 0;
|
|
2361
|
-
for (let
|
|
2362
|
-
const
|
|
2363
|
-
if (t >=
|
|
2364
|
-
const b = d.t -
|
|
2365
|
-
n =
|
|
2377
|
+
for (let p = 0; p < i - 1; p++) {
|
|
2378
|
+
const h = s[p], d = s[p + 1];
|
|
2379
|
+
if (t >= h.t && t <= d.t) {
|
|
2380
|
+
const b = d.t - h.t;
|
|
2381
|
+
n = h.v, a = d.v, o = _i(h.ease, b > 0 ? (t - h.t) / b : 0);
|
|
2366
2382
|
break;
|
|
2367
2383
|
}
|
|
2368
2384
|
}
|
|
@@ -2379,7 +2395,7 @@ function mi(s) {
|
|
|
2379
2395
|
}
|
|
2380
2396
|
class vt {
|
|
2381
2397
|
constructor(t, e) {
|
|
2382
|
-
this.device = t, this.config = e, this.MAX_PARTICLES = e.maxParticles || 1e4, this.particleCount = e.particleCount || 100, this.activeParticles = 0, this.emitting = !1, this.currentEmissionTime = 0, this.destroyed = !1, this.particleData = new Float32Array(this.MAX_PARTICLES * 8), this.particleVelocities = new Float32Array(this.MAX_PARTICLES * 4), this.instanceBuffer = t.createBuffer({
|
|
2398
|
+
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({
|
|
2383
2399
|
size: this.MAX_PARTICLES * 8 * 4,
|
|
2384
2400
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST | GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
|
|
2385
2401
|
label: "particleInstanceBuffer"
|
|
@@ -2403,7 +2419,7 @@ class vt {
|
|
|
2403
2419
|
// intensity (f32) + padding
|
|
2404
2420
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
2405
2421
|
label: "systemBloomIntensityBuffer"
|
|
2406
|
-
}), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new ms(e), this.physics = new _s(t, this.MAX_PARTICLES), this.textureManager = new ws(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition), e.confinementEnabled && this.setConfinement({
|
|
2422
|
+
}), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.attractorReverse === void 0 && (e.attractorReverse = !1), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new ms(e), this.physics = new _s(t, this.MAX_PARTICLES), this.textureManager = new ws(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition, e.attractorReverse), e.confinementEnabled && this.setConfinement({
|
|
2407
2423
|
enabled: !0,
|
|
2408
2424
|
shape: e.confinementShape,
|
|
2409
2425
|
mode: e.confinementMode,
|
|
@@ -2437,7 +2453,7 @@ class vt {
|
|
|
2437
2453
|
async setGLBModel(t) {
|
|
2438
2454
|
try {
|
|
2439
2455
|
this.glbRawArrayBuffer = t;
|
|
2440
|
-
const e = await
|
|
2456
|
+
const e = await As(t);
|
|
2441
2457
|
this.glbMeshData = e, this.config.glbHasTexture = e.hasBaseColorTexture || !1;
|
|
2442
2458
|
const i = new Float32Array(e.vertexCount * 8);
|
|
2443
2459
|
for (let r = 0; r < e.vertexCount; r++) {
|
|
@@ -2453,7 +2469,7 @@ class vt {
|
|
|
2453
2469
|
usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
|
|
2454
2470
|
label: "glbIndexBuffer"
|
|
2455
2471
|
}), 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) {
|
|
2456
|
-
this.glbAnimator = new
|
|
2472
|
+
this.glbAnimator = new ks(e.animationData), this.glbAnimator.setRestPose(e.positions, e.normals), this.glbAnimated = !0, this.config.glbAnimated = !0, this.glbAnimator.loop = this.config.animationLoop, this._glbInterleavedData = new Float32Array(e.vertexCount * 8);
|
|
2457
2473
|
try {
|
|
2458
2474
|
await this.glbAnimator.initGPUSkinning(this.device, this.glbVertexBuffer, e.texCoords);
|
|
2459
2475
|
} catch (r) {
|
|
@@ -2527,7 +2543,7 @@ class vt {
|
|
|
2527
2543
|
t[4] = e[0], t[5] = e[1], t[6] = e[2], this.device.queue.writeBuffer(this.bloomIntensityBuffer, 0, t);
|
|
2528
2544
|
}
|
|
2529
2545
|
spawnParticles() {
|
|
2530
|
-
if (this.activeParticles = 0, this.currentEmissionTime = 0, this._newEmissions.length = 0, this._pendingFollowEmissions = this._emptyEmissions, this._scriptFrame = 0, this._scriptTime = 0, this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptConfigRestored = !1, this._particleScript && (this._particleScript._configSnapshot ? (this._particleScript.restoreConfig(this.config), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition), this.updateAppearanceUniform(), this.updateBloomIntensity()) : this._particleScript.snapshotConfig(this.config)), this.device.queue.writeBuffer(this.trailBuffer, 0, this._trailResetData, 0, this.MAX_PARTICLES * 4), this.glbAnimator && (this.glbAnimator.currentTime = 0, this.glbAnimator.playing = !0), this.config.followSystemId) {
|
|
2546
|
+
if (this.activeParticles = 0, this.currentEmissionTime = 0, this.emissionAccumulator = 0, this._newEmissions.length = 0, this._pendingFollowEmissions = this._emptyEmissions, this._scriptFrame = 0, this._scriptTime = 0, this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptConfigRestored = !1, this._particleScript && (this._particleScript._configSnapshot ? (this._particleScript.restoreConfig(this.config), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse), this.updateAppearanceUniform(), this.updateBloomIntensity()) : this._particleScript.snapshotConfig(this.config)), this.device.queue.writeBuffer(this.trailBuffer, 0, this._trailResetData, 0, this.MAX_PARTICLES * 4), this.glbAnimator && (this.glbAnimator.currentTime = 0, this.glbAnimator.playing = !0), this.config.followSystemId) {
|
|
2531
2547
|
this.emitting = !0, this.particleCount = this.MAX_PARTICLES;
|
|
2532
2548
|
return;
|
|
2533
2549
|
}
|
|
@@ -2612,13 +2628,13 @@ class vt {
|
|
|
2612
2628
|
this._scriptReadbackReady = !1, this._scriptTime += t, this._scriptFrame++;
|
|
2613
2629
|
const u = this.config.emissionDurationInfinite ? 1 / 0 : (this.config.emissionDuration || 0) + (this.config.lifetime || 0);
|
|
2614
2630
|
if (u > 0 && this._scriptTime >= u && !this._scriptConfigRestored)
|
|
2615
|
-
this._scriptConfigRestored = !0, this._particleScript._configSnapshot && (this._particleScript.restoreConfig(this.config), this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition));
|
|
2631
|
+
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));
|
|
2616
2632
|
else if (!this._scriptConfigRestored) {
|
|
2617
|
-
const
|
|
2633
|
+
const p = u > 0 ? Math.ceil(u / 0.016666666666666666) : 0, { configDirty: h, particlesDirty: d } = this._particleScript.execute(
|
|
2618
2634
|
t,
|
|
2619
2635
|
this._scriptTime,
|
|
2620
2636
|
this._scriptFrame,
|
|
2621
|
-
|
|
2637
|
+
p,
|
|
2622
2638
|
this._scriptParticleData,
|
|
2623
2639
|
this._scriptVelocityData,
|
|
2624
2640
|
this.activeParticles
|
|
@@ -2635,7 +2651,7 @@ class vt {
|
|
|
2635
2651
|
this._scriptVelocityData,
|
|
2636
2652
|
0,
|
|
2637
2653
|
this.activeParticles * 4
|
|
2638
|
-
)),
|
|
2654
|
+
)), h && (this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse));
|
|
2639
2655
|
}
|
|
2640
2656
|
}
|
|
2641
2657
|
this.physics.physicsAccumulator += t;
|
|
@@ -2643,52 +2659,50 @@ class vt {
|
|
|
2643
2659
|
if (!n && !this.emitting && !this.config.burstMode && !this.config.followSystemId && this.currentEmissionTime < this.effectiveEmissionDuration && (this.emitting = !0), !n && this.emitting)
|
|
2644
2660
|
if (this.currentEmissionTime += t, this.currentEmissionTime < this.effectiveEmissionDuration) {
|
|
2645
2661
|
const u = this.activeParticles;
|
|
2646
|
-
let
|
|
2662
|
+
let p = !1;
|
|
2647
2663
|
if (this.config.followSystemId) {
|
|
2648
2664
|
if (this._pendingFollowEmissions.length > 0) {
|
|
2649
|
-
const
|
|
2650
|
-
for (let d = 0; d <
|
|
2665
|
+
const h = this._pendingFollowEmissions.length / 6;
|
|
2666
|
+
for (let d = 0; d < h; d++) {
|
|
2651
2667
|
const b = d * 6;
|
|
2652
2668
|
if (this.emitFollowerParticle(
|
|
2653
2669
|
this._pendingFollowEmissions[b],
|
|
2654
2670
|
this._pendingFollowEmissions[b + 1],
|
|
2655
2671
|
this._pendingFollowEmissions[b + 2]
|
|
2656
2672
|
))
|
|
2657
|
-
|
|
2673
|
+
p = !0;
|
|
2658
2674
|
else
|
|
2659
2675
|
break;
|
|
2660
2676
|
}
|
|
2661
2677
|
}
|
|
2662
2678
|
} else {
|
|
2663
|
-
let
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
for (let d = 0; d < p && this.emitParticle(); d++)
|
|
2674
|
-
m = !0;
|
|
2679
|
+
let h = 0;
|
|
2680
|
+
const d = Math.max(0, this.config.emissionRate || 0);
|
|
2681
|
+
this.activeParticles < this.particleCount && d > 0 ? (this.emissionAccumulator += d * t, h = Math.floor(this.emissionAccumulator + 1e-9), h > 0 && (this.emissionAccumulator -= h)) : this.activeParticles >= this.particleCount && (this.emissionAccumulator = 0);
|
|
2682
|
+
for (let b = 0; b < h; b++)
|
|
2683
|
+
if (this.emitParticle())
|
|
2684
|
+
p = !0;
|
|
2685
|
+
else {
|
|
2686
|
+
this.emissionAccumulator = 0;
|
|
2687
|
+
break;
|
|
2688
|
+
}
|
|
2675
2689
|
}
|
|
2676
|
-
if (
|
|
2677
|
-
const
|
|
2690
|
+
if (p) {
|
|
2691
|
+
const h = this.activeParticles - u, d = u * 8, b = u * 4;
|
|
2678
2692
|
this.device.queue.writeBuffer(
|
|
2679
2693
|
this.instanceBuffer,
|
|
2680
2694
|
d * 4,
|
|
2681
2695
|
// Offset in bytes (float32 = 4 bytes)
|
|
2682
2696
|
this.particleData,
|
|
2683
2697
|
d,
|
|
2684
|
-
|
|
2698
|
+
h * 8
|
|
2685
2699
|
), this.device.queue.writeBuffer(
|
|
2686
2700
|
this.velocityBuffer,
|
|
2687
2701
|
b * 4,
|
|
2688
2702
|
// Offset in bytes (float32 = 4 bytes)
|
|
2689
2703
|
this.particleVelocities,
|
|
2690
2704
|
b,
|
|
2691
|
-
|
|
2705
|
+
h * 4
|
|
2692
2706
|
);
|
|
2693
2707
|
}
|
|
2694
2708
|
} else
|
|
@@ -2778,13 +2792,13 @@ class vt {
|
|
|
2778
2792
|
o * o + c * c + l * l
|
|
2779
2793
|
);
|
|
2780
2794
|
if (u > 1e-3) {
|
|
2781
|
-
const
|
|
2782
|
-
this.particleVelocities[i] = o / u *
|
|
2795
|
+
const p = this.config.particleSpeed * 2;
|
|
2796
|
+
this.particleVelocities[i] = o / u * p, this.particleVelocities[i + 1] = c / u * p, this.particleVelocities[i + 2] = l / u * p;
|
|
2783
2797
|
} else {
|
|
2784
|
-
const
|
|
2785
|
-
if (
|
|
2786
|
-
const
|
|
2787
|
-
this.particleVelocities[i] = r /
|
|
2798
|
+
const p = Math.sqrt(r * r + n * n + a * a);
|
|
2799
|
+
if (p > 1e-3) {
|
|
2800
|
+
const h = this.config.particleSpeed * 2;
|
|
2801
|
+
this.particleVelocities[i] = r / p * h, this.particleVelocities[i + 1] = n / p * h, this.particleVelocities[i + 2] = a / p * h;
|
|
2788
2802
|
} else
|
|
2789
2803
|
this.particleVelocities[i] = 0, this.particleVelocities[i + 1] = this.config.particleSpeed * 2, this.particleVelocities[i + 2] = 0;
|
|
2790
2804
|
}
|
|
@@ -2818,8 +2832,8 @@ class vt {
|
|
|
2818
2832
|
setGravity(t) {
|
|
2819
2833
|
this.physics.setGravity(t);
|
|
2820
2834
|
}
|
|
2821
|
-
setAttractor(t, e) {
|
|
2822
|
-
this.physics.setAttractor(t, e);
|
|
2835
|
+
setAttractor(t, e, i = this.config.attractorReverse) {
|
|
2836
|
+
this.config.attractorStrength = t, this.config.attractorPosition = e, this.config.attractorReverse = !!i, this.physics.setAttractor(t, e, i);
|
|
2823
2837
|
}
|
|
2824
2838
|
setConfinement(t) {
|
|
2825
2839
|
const e = t.center || this.config.confinementCenter || [0, 0, 0], i = t.space === "local" ? [this.config.emissionPositionX || 0, this.config.emissionPositionY || 0, this.config.emissionPositionZ || 0] : [0, 0, 0], r = [i[0] + (e[0] || 0), i[1] + (e[1] || 0), i[2] + (e[2] || 0)];
|
|
@@ -2903,15 +2917,15 @@ class Ws {
|
|
|
2903
2917
|
const l = c.keyframes;
|
|
2904
2918
|
if (!(!l || c.keyframesEnabled === !1)) {
|
|
2905
2919
|
for (const u of Zs) {
|
|
2906
|
-
const
|
|
2907
|
-
if (
|
|
2908
|
-
const
|
|
2909
|
-
|
|
2920
|
+
const p = l[u];
|
|
2921
|
+
if (p && p.length) {
|
|
2922
|
+
const h = qs(p, a);
|
|
2923
|
+
h !== void 0 && (c[u] = h);
|
|
2910
2924
|
}
|
|
2911
2925
|
}
|
|
2912
2926
|
if (l.particleColor && l.particleColor.length) {
|
|
2913
|
-
const u = c.particleColor,
|
|
2914
|
-
|
|
2927
|
+
const u = c.particleColor, p = u && typeof u.length == "number" && u.length >= 3 ? u : void 0, h = Hs(l.particleColor, a, p);
|
|
2928
|
+
h && (c.particleColor = h, o.updateAppearanceUniform());
|
|
2915
2929
|
}
|
|
2916
2930
|
}
|
|
2917
2931
|
}
|
|
@@ -3085,8 +3099,8 @@ class Ws {
|
|
|
3085
3099
|
try {
|
|
3086
3100
|
const u = await fi(l);
|
|
3087
3101
|
if (u) {
|
|
3088
|
-
const
|
|
3089
|
-
await o.setTexture(
|
|
3102
|
+
const p = await createImageBitmap(u.imageBlob);
|
|
3103
|
+
await o.setTexture(p), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${c.name}`);
|
|
3090
3104
|
}
|
|
3091
3105
|
} catch (u) {
|
|
3092
3106
|
console.warn(`Failed to restore GLB texture for ${c.name}:`, u), c.useGlbTexture = !1;
|
|
@@ -3100,8 +3114,8 @@ class Ws {
|
|
|
3100
3114
|
if (c.textureEnabled && !c.glbModelEnabled && c.textureImageData && !o._textureRestored)
|
|
3101
3115
|
try {
|
|
3102
3116
|
const l = new Image();
|
|
3103
|
-
await new Promise((
|
|
3104
|
-
l.onload =
|
|
3117
|
+
await new Promise((p, h) => {
|
|
3118
|
+
l.onload = p, l.onerror = h, l.src = c.textureImageData;
|
|
3105
3119
|
});
|
|
3106
3120
|
const u = await createImageBitmap(l);
|
|
3107
3121
|
await o.setTexture(u), o._textureRestored = !0;
|
|
@@ -3304,7 +3318,7 @@ const Qs = `
|
|
|
3304
3318
|
}
|
|
3305
3319
|
|
|
3306
3320
|
@vertex
|
|
3307
|
-
fn vs_main(input: VertexInput) -> VertexOutput {
|
|
3321
|
+
fn vs_main(input: VertexInput, @builtin(instance_index) instanceIdx: u32) -> VertexOutput {
|
|
3308
3322
|
var output : VertexOutput;
|
|
3309
3323
|
|
|
3310
3324
|
let age = input.particleAgeAndLife.x;
|
|
@@ -3335,9 +3349,10 @@ const Qs = `
|
|
|
3335
3349
|
// Determine particle size
|
|
3336
3350
|
var particleSizeFactor = appearance.particleSize;
|
|
3337
3351
|
if (appearance.randomSize > 0.5) {
|
|
3338
|
-
//
|
|
3352
|
+
// Per-particle seed (particle index), not lifetime — otherwise every particle of an emission
|
|
3353
|
+
// gets the SAME size (see the quad shader for the full explanation).
|
|
3339
3354
|
particleSizeFactor = appearance.minSize +
|
|
3340
|
-
fract(sin(
|
|
3355
|
+
fract(sin(f32(instanceIdx) * 12.9898 + 78.233) * 43758.5453) *
|
|
3341
3356
|
(appearance.maxSize - appearance.minSize);
|
|
3342
3357
|
}
|
|
3343
3358
|
|
|
@@ -3360,7 +3375,7 @@ const Qs = `
|
|
|
3360
3375
|
var particleRotation = appearance.rotation;
|
|
3361
3376
|
if (appearance.rotationMode == 1.0) {
|
|
3362
3377
|
particleRotation = appearance.minRotation +
|
|
3363
|
-
fract(sin(
|
|
3378
|
+
fract(sin(f32(instanceIdx) * 63.746 + 11.135) * 43758.5453) *
|
|
3364
3379
|
(appearance.maxRotation - appearance.minRotation);
|
|
3365
3380
|
} else if (appearance.rotationMode == 2.0) {
|
|
3366
3381
|
let viewVelocity = (uniforms.transform * vec4<f32>(input.particleVelocity, 0.0)).xyz;
|
|
@@ -3558,15 +3573,15 @@ function tr(s, t, e, i = {}) {
|
|
|
3558
3573
|
object3dBindGroupLayout: l
|
|
3559
3574
|
} = e, u = s.createPipelineLayout({
|
|
3560
3575
|
bindGroupLayouts: [a]
|
|
3561
|
-
}), m = s.createPipelineLayout({
|
|
3562
|
-
bindGroupLayouts: [o]
|
|
3563
3576
|
}), p = s.createPipelineLayout({
|
|
3577
|
+
bindGroupLayouts: [o]
|
|
3578
|
+
}), h = s.createPipelineLayout({
|
|
3564
3579
|
bindGroupLayouts: [c]
|
|
3565
3580
|
}), d = s.createShaderModule({
|
|
3566
3581
|
code: ys
|
|
3567
3582
|
}), b = s.createShaderModule({
|
|
3568
3583
|
code: gs
|
|
3569
|
-
}),
|
|
3584
|
+
}), _ = s.createShaderModule({
|
|
3570
3585
|
code: bs
|
|
3571
3586
|
}), M = s.createShaderModule({
|
|
3572
3587
|
code: Ss
|
|
@@ -3758,8 +3773,8 @@ function tr(s, t, e, i = {}) {
|
|
|
3758
3773
|
// Always write depth (don't self-occlude)
|
|
3759
3774
|
format: "depth24plus"
|
|
3760
3775
|
}
|
|
3761
|
-
}),
|
|
3762
|
-
layout:
|
|
3776
|
+
}), D = s.createRenderPipeline({
|
|
3777
|
+
layout: p,
|
|
3763
3778
|
vertex: {
|
|
3764
3779
|
module: b,
|
|
3765
3780
|
entryPoint: "vs_main"
|
|
@@ -3774,14 +3789,14 @@ function tr(s, t, e, i = {}) {
|
|
|
3774
3789
|
primitive: {
|
|
3775
3790
|
topology: "triangle-list"
|
|
3776
3791
|
}
|
|
3777
|
-
}),
|
|
3778
|
-
layout:
|
|
3792
|
+
}), N = s.createRenderPipeline({
|
|
3793
|
+
layout: h,
|
|
3779
3794
|
vertex: {
|
|
3780
|
-
module:
|
|
3795
|
+
module: _,
|
|
3781
3796
|
entryPoint: "vs_main"
|
|
3782
3797
|
},
|
|
3783
3798
|
fragment: {
|
|
3784
|
-
module:
|
|
3799
|
+
module: _,
|
|
3785
3800
|
entryPoint: "fs_main",
|
|
3786
3801
|
targets: [{
|
|
3787
3802
|
format: oe,
|
|
@@ -3803,7 +3818,7 @@ function tr(s, t, e, i = {}) {
|
|
|
3803
3818
|
topology: "triangle-list"
|
|
3804
3819
|
}
|
|
3805
3820
|
}), Y = s.createRenderPipeline({
|
|
3806
|
-
layout:
|
|
3821
|
+
layout: h,
|
|
3807
3822
|
vertex: {
|
|
3808
3823
|
module: M,
|
|
3809
3824
|
entryPoint: "vs_main"
|
|
@@ -3830,11 +3845,11 @@ function tr(s, t, e, i = {}) {
|
|
|
3830
3845
|
primitive: {
|
|
3831
3846
|
topology: "triangle-list"
|
|
3832
3847
|
}
|
|
3833
|
-
}),
|
|
3834
|
-
layout:
|
|
3835
|
-
vertex: { module:
|
|
3848
|
+
}), k = s.createShaderModule({ code: xs }), G = s.createRenderPipeline({
|
|
3849
|
+
layout: h,
|
|
3850
|
+
vertex: { module: k, entryPoint: "vs_main" },
|
|
3836
3851
|
fragment: {
|
|
3837
|
-
module:
|
|
3852
|
+
module: k,
|
|
3838
3853
|
entryPoint: "fs_main",
|
|
3839
3854
|
targets: [{
|
|
3840
3855
|
format: t,
|
|
@@ -3847,7 +3862,7 @@ function tr(s, t, e, i = {}) {
|
|
|
3847
3862
|
primitive: { topology: "triangle-list" }
|
|
3848
3863
|
}), de = s.createPipelineLayout({
|
|
3849
3864
|
bindGroupLayouts: [l]
|
|
3850
|
-
}),
|
|
3865
|
+
}), Fe = s.createRenderPipeline({
|
|
3851
3866
|
layout: de,
|
|
3852
3867
|
vertex: {
|
|
3853
3868
|
module: R,
|
|
@@ -4009,11 +4024,11 @@ function tr(s, t, e, i = {}) {
|
|
|
4009
4024
|
particlePipeline: P,
|
|
4010
4025
|
particleAdditivePipeline: T,
|
|
4011
4026
|
particleDepthWritePipeline: E,
|
|
4012
|
-
blurPipeline:
|
|
4013
|
-
compositePipeline:
|
|
4027
|
+
blurPipeline: D,
|
|
4028
|
+
compositePipeline: N,
|
|
4014
4029
|
directRenderPipeline: Y,
|
|
4015
4030
|
finalCompositePipeline: G,
|
|
4016
|
-
object3dPipeline:
|
|
4031
|
+
object3dPipeline: Fe,
|
|
4017
4032
|
glbMeshPipeline: ct
|
|
4018
4033
|
};
|
|
4019
4034
|
}
|
|
@@ -4027,8 +4042,8 @@ function Pt(s, t, e, i) {
|
|
|
4027
4042
|
} = e, {
|
|
4028
4043
|
sceneTexture: l,
|
|
4029
4044
|
bloomTexA: u,
|
|
4030
|
-
bloomTexB:
|
|
4031
|
-
} = i,
|
|
4045
|
+
bloomTexB: p
|
|
4046
|
+
} = i, h = s.createBindGroup({
|
|
4032
4047
|
layout: s.createBindGroupLayout({
|
|
4033
4048
|
entries: [
|
|
4034
4049
|
{
|
|
@@ -4121,7 +4136,7 @@ function Pt(s, t, e, i) {
|
|
|
4121
4136
|
resource: { buffer: o }
|
|
4122
4137
|
}
|
|
4123
4138
|
]
|
|
4124
|
-
}),
|
|
4139
|
+
}), _ = s.createBindGroup({
|
|
4125
4140
|
layout: s.createBindGroupLayout({
|
|
4126
4141
|
entries: [
|
|
4127
4142
|
{
|
|
@@ -4157,7 +4172,7 @@ function Pt(s, t, e, i) {
|
|
|
4157
4172
|
},
|
|
4158
4173
|
{
|
|
4159
4174
|
binding: 2,
|
|
4160
|
-
resource:
|
|
4175
|
+
resource: p.createView()
|
|
4161
4176
|
},
|
|
4162
4177
|
{
|
|
4163
4178
|
binding: 3,
|
|
@@ -4200,7 +4215,7 @@ function Pt(s, t, e, i) {
|
|
|
4200
4215
|
},
|
|
4201
4216
|
{
|
|
4202
4217
|
binding: 2,
|
|
4203
|
-
resource:
|
|
4218
|
+
resource: p.createView()
|
|
4204
4219
|
},
|
|
4205
4220
|
{
|
|
4206
4221
|
binding: 3,
|
|
@@ -4209,10 +4224,10 @@ function Pt(s, t, e, i) {
|
|
|
4209
4224
|
]
|
|
4210
4225
|
});
|
|
4211
4226
|
return {
|
|
4212
|
-
particleBindGroup:
|
|
4227
|
+
particleBindGroup: h,
|
|
4213
4228
|
horizontalBlurBindGroup: d,
|
|
4214
4229
|
verticalBlurBindGroup: b,
|
|
4215
|
-
compositeBindGroup:
|
|
4230
|
+
compositeBindGroup: _,
|
|
4216
4231
|
directRenderBindGroup: M
|
|
4217
4232
|
};
|
|
4218
4233
|
}
|
|
@@ -4429,8 +4444,8 @@ function rr(s = 16, t = 16) {
|
|
|
4429
4444
|
for (let r = 0; r <= s; r++) {
|
|
4430
4445
|
const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
|
|
4431
4446
|
for (let c = 0; c <= t; c++) {
|
|
4432
|
-
const l = c * 2 * Math.PI / t, u = Math.sin(l),
|
|
4433
|
-
e.push(
|
|
4447
|
+
const l = c * 2 * Math.PI / t, u = Math.sin(l), h = Math.cos(l) * a, d = o, b = u * a;
|
|
4448
|
+
e.push(h * 0.5, d * 0.5, b * 0.5), e.push(h, d, b);
|
|
4434
4449
|
}
|
|
4435
4450
|
}
|
|
4436
4451
|
for (let r = 0; r < s; r++)
|
|
@@ -4577,7 +4592,7 @@ class nr {
|
|
|
4577
4592
|
return i;
|
|
4578
4593
|
}
|
|
4579
4594
|
}
|
|
4580
|
-
class
|
|
4595
|
+
class hr {
|
|
4581
4596
|
constructor(t) {
|
|
4582
4597
|
this.device = t, this.objects = [], this.nextId = 0, this.initializeGeometry(), this.onObjectAdded = null, this.onObjectRemoved = null, this.onObjectUpdated = null;
|
|
4583
4598
|
}
|
|
@@ -4702,7 +4717,7 @@ class pr {
|
|
|
4702
4717
|
}
|
|
4703
4718
|
}
|
|
4704
4719
|
}
|
|
4705
|
-
function
|
|
4720
|
+
function pr(s) {
|
|
4706
4721
|
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;
|
|
4707
4722
|
return [t, e, i];
|
|
4708
4723
|
}
|
|
@@ -4800,40 +4815,40 @@ function vi(s) {
|
|
|
4800
4815
|
async function lr(s, t = {}) {
|
|
4801
4816
|
const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
|
|
4802
4817
|
let a = 0;
|
|
4803
|
-
const o = (T, E,
|
|
4804
|
-
const
|
|
4805
|
-
r.push({ offset:
|
|
4806
|
-
const
|
|
4807
|
-
return
|
|
4818
|
+
const o = (T, E, D) => {
|
|
4819
|
+
const N = a, Y = T.length;
|
|
4820
|
+
r.push({ offset: N, length: Y, mime: E, kind: D }), n.push(T), a += Y;
|
|
4821
|
+
const k = vi(Y);
|
|
4822
|
+
return k && (n.push(new Uint8Array(k)), a += k), r.length - 1;
|
|
4808
4823
|
}, c = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", l = [];
|
|
4809
4824
|
for (const T of s.systems || []) {
|
|
4810
4825
|
const E = { ...T };
|
|
4811
4826
|
if (typeof E.textureImageData == "string" && E.textureImageData.startsWith("data:")) {
|
|
4812
|
-
let { mime:
|
|
4813
|
-
if (c &&
|
|
4827
|
+
let { mime: D, bytes: N } = or(E.textureImageData);
|
|
4828
|
+
if (c && D !== "image/webp")
|
|
4814
4829
|
try {
|
|
4815
|
-
const Y = await createImageBitmap(new Blob([
|
|
4816
|
-
|
|
4817
|
-
const G = await
|
|
4818
|
-
de.length <
|
|
4830
|
+
const Y = await createImageBitmap(new Blob([N], { type: D })), k = new OffscreenCanvas(Y.width, Y.height);
|
|
4831
|
+
k.getContext("2d").drawImage(Y, 0, 0);
|
|
4832
|
+
const G = await k.convertToBlob({ type: "image/webp", quality: i }), de = new Uint8Array(await G.arrayBuffer());
|
|
4833
|
+
de.length < N.length && (N = de, D = "image/webp");
|
|
4819
4834
|
} catch {
|
|
4820
4835
|
}
|
|
4821
|
-
E.textureImageData = { [Ze]: o(
|
|
4836
|
+
E.textureImageData = { [Ze]: o(N, D, "texture") };
|
|
4822
4837
|
}
|
|
4823
4838
|
if (typeof E.glbModelData == "string" && E.glbModelData.length > 0) {
|
|
4824
|
-
const
|
|
4825
|
-
E.glbModelData = { [Ze]: o(
|
|
4839
|
+
const D = Ri(E.glbModelData);
|
|
4840
|
+
E.glbModelData = { [Ze]: o(D, "model/gltf-binary", "glb") };
|
|
4826
4841
|
}
|
|
4827
4842
|
l.push(E);
|
|
4828
4843
|
}
|
|
4829
|
-
const u = { ...s, systems: l, assets: r },
|
|
4844
|
+
const u = { ...s, systems: l, assets: r }, p = new TextEncoder().encode(JSON.stringify(u)), h = vi(p.length), d = new Uint8Array(a);
|
|
4830
4845
|
let b = 0;
|
|
4831
4846
|
for (const T of n)
|
|
4832
4847
|
d.set(T, b), b += T.length;
|
|
4833
|
-
const
|
|
4848
|
+
const _ = p.length + h, M = 20 + _ + 8 + a, R = new ArrayBuffer(M), x = new DataView(R), L = new Uint8Array(R);
|
|
4834
4849
|
let P = 0;
|
|
4835
|
-
x.setUint32(P, Bt, !0), P += 4, x.setUint32(P, wi, !0), P += 4, x.setUint32(P, M, !0), P += 4, x.setUint32(P,
|
|
4836
|
-
for (let T = 0; T <
|
|
4850
|
+
x.setUint32(P, Bt, !0), P += 4, x.setUint32(P, wi, !0), P += 4, x.setUint32(P, M, !0), P += 4, x.setUint32(P, _, !0), P += 4, x.setUint32(P, Bi, !0), P += 4, L.set(p, P), P += p.length;
|
|
4851
|
+
for (let T = 0; T < h; T++) L[P++] = 32;
|
|
4837
4852
|
return x.setUint32(P, a, !0), P += 4, x.setUint32(P, Mi, !0), P += 4, L.set(d, P), P += a, R;
|
|
4838
4853
|
}
|
|
4839
4854
|
function Ti(s) {
|
|
@@ -4847,17 +4862,17 @@ function Ei(s) {
|
|
|
4847
4862
|
let i = 12, r = null, n = -1;
|
|
4848
4863
|
const a = new Uint8Array(s);
|
|
4849
4864
|
for (; i + 8 <= s.byteLength; ) {
|
|
4850
|
-
const
|
|
4865
|
+
const h = t.getUint32(i, !0);
|
|
4851
4866
|
i += 4;
|
|
4852
4867
|
const d = t.getUint32(i, !0);
|
|
4853
|
-
i += 4, d === Bi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i +
|
|
4868
|
+
i += 4, d === Bi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + h))) : d === Mi && (n = i), i += h;
|
|
4854
4869
|
}
|
|
4855
4870
|
if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
|
|
4856
|
-
const o = r.assets || [], c = (
|
|
4857
|
-
const d = o[
|
|
4871
|
+
const o = r.assets || [], c = (h) => {
|
|
4872
|
+
const d = o[h];
|
|
4858
4873
|
return !d || n < 0 ? null : { ...d, bytes: a.subarray(n + d.offset, n + d.offset + d.length) };
|
|
4859
|
-
}, l = (
|
|
4860
|
-
const d = { ...
|
|
4874
|
+
}, l = (h) => h && typeof h == "object" && typeof h[Ze] == "number", u = (r.systems || []).map((h) => {
|
|
4875
|
+
const d = { ...h };
|
|
4861
4876
|
if (l(d.textureImageData)) {
|
|
4862
4877
|
const b = c(d.textureImageData[Ze]);
|
|
4863
4878
|
d.textureImageData = b ? `data:${b.mime};base64,${xi(b.bytes)}` : void 0;
|
|
@@ -4867,8 +4882,8 @@ function Ei(s) {
|
|
|
4867
4882
|
d.glbModelData = b ? xi(b.bytes) : void 0;
|
|
4868
4883
|
}
|
|
4869
4884
|
return d;
|
|
4870
|
-
}),
|
|
4871
|
-
return delete
|
|
4885
|
+
}), p = { ...r, systems: u };
|
|
4886
|
+
return delete p.assets, p;
|
|
4872
4887
|
}
|
|
4873
4888
|
function cr(s) {
|
|
4874
4889
|
const t = new Uint8Array(s);
|
|
@@ -4930,6 +4945,7 @@ function ur(s) {
|
|
|
4930
4945
|
dampingStrength: s.dampingStrength,
|
|
4931
4946
|
attractorEnabled: s.attractorEnabled,
|
|
4932
4947
|
attractorStrength: s.attractorStrength,
|
|
4948
|
+
attractorReverse: s.attractorReverse ?? !1,
|
|
4933
4949
|
attractorPosition: s.attractorPosition,
|
|
4934
4950
|
emissionRotationX: s.emissionRotationX,
|
|
4935
4951
|
emissionRotationY: s.emissionRotationY,
|
|
@@ -5064,12 +5080,12 @@ async function br(s, t, e = "hzfx") {
|
|
|
5064
5080
|
const i = {
|
|
5065
5081
|
version: "1.0",
|
|
5066
5082
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5067
|
-
systems: s.particleSystems.map(({ config: u, system:
|
|
5083
|
+
systems: s.particleSystems.map(({ config: u, system: p }) => ({
|
|
5068
5084
|
...ur(u),
|
|
5069
5085
|
// single source of truth for config fields
|
|
5070
5086
|
// Binary assets embedded so replaceSystems() can restore them
|
|
5071
5087
|
textureImageData: u.textureEnabled && !u.glbModelEnabled && u.textureImageData ? u.textureImageData : void 0,
|
|
5072
|
-
glbModelData: u.glbModelEnabled &&
|
|
5088
|
+
glbModelData: u.glbModelEnabled && p.glbRawArrayBuffer ? cr(p.glbRawArrayBuffer) : void 0
|
|
5073
5089
|
})),
|
|
5074
5090
|
activeSystemIndex: s.activeSystemIndex,
|
|
5075
5091
|
loop: s.loop || !1
|
|
@@ -5157,13 +5173,13 @@ async function vr(s, t = {}) {
|
|
|
5157
5173
|
const o = !!(s && s.device && s.context);
|
|
5158
5174
|
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await Js(a));
|
|
5159
5175
|
const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new Ws(r), u = { layouts: {}, pipelines: {} };
|
|
5160
|
-
function
|
|
5161
|
-
const
|
|
5162
|
-
if (!u.pipelines[
|
|
5176
|
+
function p(f) {
|
|
5177
|
+
const m = f ? "ms" : "ss";
|
|
5178
|
+
if (!u.pipelines[m]) {
|
|
5163
5179
|
const S = r.createShaderModule({ code: dr(f) }), g = r.createBindGroupLayout({
|
|
5164
5180
|
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: f } }]
|
|
5165
5181
|
});
|
|
5166
|
-
u.layouts[
|
|
5182
|
+
u.layouts[m] = g, u.pipelines[m] = r.createRenderPipeline({
|
|
5167
5183
|
layout: r.createPipelineLayout({ bindGroupLayouts: [g] }),
|
|
5168
5184
|
vertex: { module: S, entryPoint: "vs" },
|
|
5169
5185
|
fragment: { module: S, entryPoint: "fs", targets: [] },
|
|
@@ -5171,31 +5187,31 @@ async function vr(s, t = {}) {
|
|
|
5171
5187
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
|
|
5172
5188
|
});
|
|
5173
5189
|
}
|
|
5174
|
-
return { pipeline: u.pipelines[
|
|
5190
|
+
return { pipeline: u.pipelines[m], layout: u.layouts[m] };
|
|
5175
5191
|
}
|
|
5176
|
-
const
|
|
5192
|
+
const h = {
|
|
5177
5193
|
bloomSourceTextures: {},
|
|
5178
5194
|
bloomCompositeTextures: {},
|
|
5179
5195
|
combinedTexture: null,
|
|
5180
|
-
getBloomSourceTexture(f,
|
|
5196
|
+
getBloomSourceTexture(f, m, S) {
|
|
5181
5197
|
return this.bloomSourceTextures[f] || (this.bloomSourceTextures[f] = r.createTexture({
|
|
5182
|
-
size: [
|
|
5198
|
+
size: [m, S],
|
|
5183
5199
|
format: "rgba16float",
|
|
5184
5200
|
// HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
|
|
5185
5201
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5186
5202
|
})), this.bloomSourceTextures[f];
|
|
5187
5203
|
},
|
|
5188
|
-
getBloomCompositeTexture(f,
|
|
5204
|
+
getBloomCompositeTexture(f, m, S) {
|
|
5189
5205
|
return this.bloomCompositeTextures[f] || (this.bloomCompositeTextures[f] = r.createTexture({
|
|
5190
|
-
size: [
|
|
5206
|
+
size: [m, S],
|
|
5191
5207
|
format: "rgba16float",
|
|
5192
5208
|
// HDR chain
|
|
5193
5209
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5194
5210
|
})), this.bloomCompositeTextures[f];
|
|
5195
5211
|
},
|
|
5196
|
-
getCombinedTexture(f,
|
|
5212
|
+
getCombinedTexture(f, m) {
|
|
5197
5213
|
return this.combinedTexture || (this.combinedTexture = r.createTexture({
|
|
5198
|
-
size: [f,
|
|
5214
|
+
size: [f, m],
|
|
5199
5215
|
format: "rgba16float",
|
|
5200
5216
|
// HDR chain — tonemapped to canvas in the final pass
|
|
5201
5217
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
@@ -5220,137 +5236,137 @@ async function vr(s, t = {}) {
|
|
|
5220
5236
|
clear() {
|
|
5221
5237
|
this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
|
|
5222
5238
|
}
|
|
5223
|
-
}, b = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }),
|
|
5239
|
+
}, b = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), _ = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), M = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), R = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), x = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), L = Ge(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), P = {}, T = () => Ge(r, new Float32Array([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0]), GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST);
|
|
5224
5240
|
l.onSystemCreated = (f) => {
|
|
5225
5241
|
P[f] || (P[f] = T());
|
|
5226
5242
|
};
|
|
5227
|
-
const E = 4e4,
|
|
5243
|
+
const E = 4e4, D = new Float32Array(E * 8), N = new Float32Array(E * 4), Y = new Float32Array(E * 4), k = r.createBuffer({ size: E * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), G = r.createBuffer({ size: E * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), de = r.createBuffer({ size: E * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), Fe = /* @__PURE__ */ new Map(), ct = 8, W = [];
|
|
5228
5244
|
function Mt(f) {
|
|
5229
|
-
for (const
|
|
5245
|
+
for (const m of W) if (m.ids.has(f)) return m;
|
|
5230
5246
|
return null;
|
|
5231
5247
|
}
|
|
5232
|
-
function
|
|
5248
|
+
function Ai(f, m) {
|
|
5233
5249
|
if (!f.pos) return;
|
|
5234
|
-
f.hist.push({ t:
|
|
5235
|
-
const S =
|
|
5250
|
+
f.hist.push({ t: m, x: f.pos[0], y: f.pos[1], z: f.pos[2] });
|
|
5251
|
+
const S = m - ct;
|
|
5236
5252
|
for (; f.hist.length > 2 && f.hist[0].t < S; ) f.hist.shift();
|
|
5237
5253
|
}
|
|
5238
|
-
function Rt(f,
|
|
5254
|
+
function Rt(f, m, S) {
|
|
5239
5255
|
const g = f.hist;
|
|
5240
5256
|
if (g.length === 0) {
|
|
5241
|
-
const
|
|
5242
|
-
return
|
|
5257
|
+
const q = f.pos;
|
|
5258
|
+
return q && (S[0] = q[0], S[1] = q[1], S[2] = q[2]), S;
|
|
5243
5259
|
}
|
|
5244
5260
|
let v;
|
|
5245
|
-
if (
|
|
5261
|
+
if (m >= g[g.length - 1].t)
|
|
5246
5262
|
return v = g[g.length - 1], S[0] = v.x, S[1] = v.y, S[2] = v.z, S;
|
|
5247
|
-
if (
|
|
5263
|
+
if (m <= g[0].t)
|
|
5248
5264
|
return v = g[0], S[0] = v.x, S[1] = v.y, S[2] = v.z, S;
|
|
5249
|
-
for (let
|
|
5250
|
-
if (g[
|
|
5251
|
-
const j = g[
|
|
5265
|
+
for (let q = g.length - 1; q > 0; q--)
|
|
5266
|
+
if (g[q - 1].t <= m) {
|
|
5267
|
+
const j = g[q - 1], Q = g[q], Z = (m - j.t) / Math.max(1e-6, Q.t - j.t);
|
|
5252
5268
|
return S[0] = j.x + (Q.x - j.x) * Z, S[1] = j.y + (Q.y - j.y) * Z, S[2] = j.z + (Q.z - j.z) * Z, S;
|
|
5253
5269
|
}
|
|
5254
5270
|
return v = g[0], S[0] = v.x, S[1] = v.y, S[2] = v.z, S;
|
|
5255
5271
|
}
|
|
5256
|
-
const
|
|
5272
|
+
const Ci = 0.41421356;
|
|
5257
5273
|
function Ui() {
|
|
5258
|
-
|
|
5259
|
-
let f = 0,
|
|
5260
|
-
|
|
5274
|
+
Fe.clear();
|
|
5275
|
+
let f = 0, m = 0;
|
|
5276
|
+
C.position[0], C.position[1], C.position[2];
|
|
5261
5277
|
for (const { system: S, config: g } of l.particleSystems) {
|
|
5262
5278
|
if (!g.emissionTrailEnabled || g.hidden || g.glbModelEnabled) continue;
|
|
5263
5279
|
S.readbackAndProcessParticles();
|
|
5264
|
-
const v = S.particleData,
|
|
5265
|
-
if (!v || !
|
|
5266
|
-
const Q = g.emissionTrailMode === "particles", Z = f,
|
|
5280
|
+
const v = S.particleData, q = S.particleVelocities, j = S.activeParticles;
|
|
5281
|
+
if (!v || !q || j <= 0) continue;
|
|
5282
|
+
const Q = g.emissionTrailMode === "particles", Z = f, Ce = g.emissionTrailDuration ?? 1, y = g.opacity ?? 1, B = g.particleSize ?? 0.5, U = g.bloomIntensity || 1, I = Math.max(1, Math.min(64, g.emissionTrailSegments ?? 8)), F = g.emissionTrailShape || "straight", J = g.followSystemTranslation ?? !0, K = S._simPosition, X = J && K ? K[0] : 0, it = J && K ? K[1] : 0, jt = J && K ? K[2] : 0, Ue = S._simVelocity, Yt = Ue ? Ue[0] : 0, rs = Ue ? Ue[1] : 0, qt = Ue ? Ue[2] : 0, Oe = Mt(g.id), Ht = !!(J && Oe && Oe.hist && Oe.hist.length > 1);
|
|
5267
5283
|
for (let st = 0; st < j; st++) {
|
|
5268
|
-
const
|
|
5269
|
-
let Le = v[
|
|
5270
|
-
const
|
|
5271
|
-
if (
|
|
5272
|
-
const me =
|
|
5284
|
+
const pe = st * 8, rt = v[pe], mt = v[pe + 1], nt = v[pe + 2], ns = rt + X, as = mt + it, os = nt + jt;
|
|
5285
|
+
let Le = v[pe + 3], Xe = v[pe + 4], Ne = v[pe + 5];
|
|
5286
|
+
const ke = v[pe + 6], Ie = v[pe + 7];
|
|
5287
|
+
if (ke >= Ie || Ie <= 0) continue;
|
|
5288
|
+
const me = ke / Ie;
|
|
5273
5289
|
if (g.colorTransitionEnabled) {
|
|
5274
|
-
const
|
|
5275
|
-
Le =
|
|
5290
|
+
const w = g.startColor ?? [1, 0, 0], z = g.endColor ?? [0, 0, 1];
|
|
5291
|
+
Le = w[0] + (z[0] - w[0]) * me, Xe = w[1] + (z[1] - w[1]) * me, Ne = w[2] + (z[2] - w[2]) * me;
|
|
5276
5292
|
}
|
|
5277
|
-
Le = Math.min(1, Le * U), Xe = Math.min(1, Xe * U),
|
|
5293
|
+
Le = Math.min(1, Le * U), Xe = Math.min(1, Xe * U), Ne = Math.min(1, Ne * U);
|
|
5278
5294
|
let je = B;
|
|
5279
5295
|
if (g.randomSize) {
|
|
5280
|
-
const
|
|
5296
|
+
const w = Math.sin(Ie * 54321.67) * 43758.5453 % 1, z = w < 0 ? w + 1 : w;
|
|
5281
5297
|
je = (g.minSize ?? 0.1) + ((g.maxSize ?? 0.5) - (g.minSize ?? 0.1)) * z;
|
|
5282
5298
|
}
|
|
5283
5299
|
if (g.fadeSizeEnabled) {
|
|
5284
|
-
const
|
|
5285
|
-
je *= 1 - Math.pow(me, 1 /
|
|
5300
|
+
const w = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
|
|
5301
|
+
je *= 1 - Math.pow(me, 1 / w);
|
|
5286
5302
|
}
|
|
5287
5303
|
if (g.increaseSizeEnabled) {
|
|
5288
|
-
const
|
|
5289
|
-
je *= 1 + Math.pow(me, 1 /
|
|
5304
|
+
const w = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
|
|
5305
|
+
je *= 1 + Math.pow(me, 1 / w);
|
|
5290
5306
|
}
|
|
5291
5307
|
if (je <= 0 || me > 0.9) continue;
|
|
5292
|
-
const Zt = Math.min((0.9 - me) * (1 / 0.2), 1), $t = 0.75 * je *
|
|
5308
|
+
const Zt = Math.min((0.9 - me) * (1 / 0.2), 1), $t = 0.75 * je * Ci * Zt;
|
|
5293
5309
|
let Ye = y;
|
|
5294
5310
|
if (g.fadeEnabled && (Ye *= Math.max(0, 1 - me)), Ye *= Zt, Ye < 0.01) continue;
|
|
5295
|
-
const yt = st * 4, Wt =
|
|
5311
|
+
const yt = st * 4, Wt = q[yt], Jt = q[yt + 1], Qt = q[yt + 2], at = Wt + Yt, ot = Jt + rs, lt = Qt + qt, Kt = Math.sqrt(at * at + ot * ot + lt * lt);
|
|
5296
5312
|
if (Kt < 1e-3) continue;
|
|
5297
|
-
const gt = 1 / Kt, ve = at * gt, Pe = ot * gt, ye = lt * gt, ei =
|
|
5298
|
-
let bt = ei * ve + ti * Pe + ii * ye, re = ei - bt * ve, ne = ti - bt * Pe, ae = ii - bt * ye,
|
|
5299
|
-
if (
|
|
5300
|
-
const
|
|
5301
|
-
re =
|
|
5313
|
+
const gt = 1 / Kt, ve = at * gt, Pe = ot * gt, ye = lt * gt, ei = C.right[0], ti = C.right[1], ii = C.right[2];
|
|
5314
|
+
let bt = ei * ve + ti * Pe + ii * ye, re = ei - bt * ve, ne = ti - bt * Pe, ae = ii - bt * ye, qe = Math.sqrt(re * re + ne * ne + ae * ae);
|
|
5315
|
+
if (qe < 0.2) {
|
|
5316
|
+
const w = C.up[0], z = C.up[1], $ = C.up[2], V = w * ve + z * Pe + $ * ye;
|
|
5317
|
+
re = w - V * ve, ne = z - V * Pe, ae = $ - V * ye, qe = Math.sqrt(re * re + ne * ne + ae * ae) || 1;
|
|
5302
5318
|
}
|
|
5303
|
-
re /=
|
|
5304
|
-
const
|
|
5305
|
-
if (
|
|
5306
|
-
const si = g.gravityEnabled && g.gravityStrength || 0, _e =
|
|
5307
|
-
if (g.orientToDirection && g.burstMode &&
|
|
5308
|
-
const
|
|
5309
|
-
for (let
|
|
5310
|
-
const O = Rt(Oe,
|
|
5311
|
-
z[
|
|
5319
|
+
re /= qe, ne /= qe, ae /= qe;
|
|
5320
|
+
const He = Math.min(Ce, ke);
|
|
5321
|
+
if (He < 1e-3) continue;
|
|
5322
|
+
const si = g.gravityEnabled && g.gravityStrength || 0, _e = Ni, we = ki, Be = ji;
|
|
5323
|
+
if (g.orientToDirection && g.burstMode && Ht) {
|
|
5324
|
+
const w = S._emitSimRotY || 0, z = Yi, $ = qi, V = Hi;
|
|
5325
|
+
for (let A = 0; A <= I; A++) {
|
|
5326
|
+
const O = Rt(Oe, he - A / I * He, Vt);
|
|
5327
|
+
z[A] = O[0], $[A] = O[1], V[A] = O[2];
|
|
5312
5328
|
}
|
|
5313
|
-
for (let
|
|
5314
|
-
const O =
|
|
5315
|
-
let Me = z[O] - z[
|
|
5316
|
-
const ge = (Math.hypot(Me, Re) > 1e-5 ? Math.atan2(Me, Re) : Math.atan2(Yt,
|
|
5317
|
-
_e[
|
|
5329
|
+
for (let A = 0; A <= I; A++) {
|
|
5330
|
+
const O = A > 0 ? A - 1 : 0, H = A < I ? A + 1 : I;
|
|
5331
|
+
let Me = z[O] - z[H], Re = V[O] - V[H];
|
|
5332
|
+
const ge = (Math.hypot(Me, Re) > 1e-5 ? Math.atan2(Me, Re) : Math.atan2(Yt, qt)) - w, te = Math.cos(ge), ie = Math.sin(ge), ue = A / I * He, St = -0.5 * si * ue * ue;
|
|
5333
|
+
_e[A] = te * rt + ie * nt + z[A], we[A] = mt + St + $[A], Be[A] = -ie * rt + te * nt + V[A];
|
|
5318
5334
|
}
|
|
5319
|
-
} else for (let
|
|
5320
|
-
const z =
|
|
5321
|
-
if (
|
|
5322
|
-
const V = Rt(Oe,
|
|
5323
|
-
_e[
|
|
5335
|
+
} else for (let w = 0; w <= I; w++) {
|
|
5336
|
+
const z = w / I * He, $ = -0.5 * si * z * z;
|
|
5337
|
+
if (Ht) {
|
|
5338
|
+
const V = Rt(Oe, he - z, Vt);
|
|
5339
|
+
_e[w] = rt - Wt * z + V[0], we[w] = mt - Jt * z + $ + V[1], Be[w] = nt - Qt * z + V[2];
|
|
5324
5340
|
} else
|
|
5325
|
-
_e[
|
|
5341
|
+
_e[w] = ns - at * z, we[w] = as - ot * z + $, Be[w] = os - lt * z;
|
|
5326
5342
|
}
|
|
5327
|
-
if (
|
|
5328
|
-
const
|
|
5329
|
-
let V = -ye,
|
|
5330
|
-
|
|
5331
|
-
const Me = Pe * O - ye *
|
|
5343
|
+
if (F !== "straight") {
|
|
5344
|
+
const w = g.emissionTrailShapeAmplitude ?? 0.1, z = g.emissionTrailShapeFrequency ?? 4, $ = g.emissionTrailShapeSpeed ?? 0;
|
|
5345
|
+
let V = -ye, A = 0, O = ve, H = Math.sqrt(V * V + O * O);
|
|
5346
|
+
H < 1e-6 && (V = 0, A = ye, O = -Pe, H = Math.sqrt(V * V + A * A + O * O) || 1), V /= H, A /= H, O /= H;
|
|
5347
|
+
const Me = Pe * O - ye * A, Re = ye * V - ve * O, ce = ve * A - Pe * V;
|
|
5332
5348
|
for (let ee = 1; ee <= I; ee++) {
|
|
5333
|
-
const ge = ee / I *
|
|
5349
|
+
const ge = ee / I * He, te = 2 * Math.PI * z * (he - ge) + $ * he;
|
|
5334
5350
|
let ie = 0, ue = 0;
|
|
5335
|
-
|
|
5351
|
+
F === "zigzag" ? ie = w * Math.sign(Math.sin(te)) : F === "sine" ? ie = w * Math.sin(te) : F === "spiral" && (ie = w * Math.sin(te), ue = w * Math.cos(te)), _e[ee] += V * ie + Me * ue, we[ee] += A * ie + Re * ue, Be[ee] += O * ie + ce * ue;
|
|
5336
5352
|
}
|
|
5337
5353
|
}
|
|
5338
5354
|
if (Q)
|
|
5339
|
-
for (let
|
|
5340
|
-
const z =
|
|
5341
|
-
|
|
5355
|
+
for (let w = 1; w <= I && f < E; w++) {
|
|
5356
|
+
const z = w / I, $ = _e[w] - X, V = we[w] - it, A = Be[w] - jt, O = f * 8, H = f * 4;
|
|
5357
|
+
D[O] = $, D[O + 1] = V, D[O + 2] = A, D[O + 3] = Le, D[O + 4] = Xe, D[O + 5] = Ne, D[O + 6] = ke + (Ie - ke) * z, D[O + 7] = Ie, N[H] = 0, N[H + 1] = 0, N[H + 2] = 0, N[H + 3] = 0, Y[H] = $, Y[H + 1] = V, Y[H + 2] = A, Y[H + 3] = 0, f++;
|
|
5342
5358
|
}
|
|
5343
5359
|
else
|
|
5344
|
-
for (let
|
|
5345
|
-
const z =
|
|
5346
|
-
le[
|
|
5360
|
+
for (let w = 0; w < I && !(m + 42 > le.length); w++) {
|
|
5361
|
+
const z = w / I, $ = (w + 1) / I, V = _e[w], A = we[w], O = Be[w], H = _e[w + 1], Me = we[w + 1], Re = Be[w + 1], ce = $t * (1 - z), ee = $t * (1 - $), ge = Ye * (1 - z) * (1 - z), te = Ye * (1 - $) * (1 - $), ie = V + re * ce, ue = A + ne * ce, St = O + ae * ce, ri = V - re * ce, ni = A - ne * ce, ai = O - ae * ce, oi = H + re * ee, li = Me + ne * ee, ci = Re + ae * ee, ls = H - re * ee, cs = Me - ne * ee, us = Re - ae * ee, ze = (ds, fs, hs, ps) => {
|
|
5362
|
+
le[m++] = ds, le[m++] = fs, le[m++] = hs, le[m++] = Le, le[m++] = Xe, le[m++] = Ne, le[m++] = ps;
|
|
5347
5363
|
};
|
|
5348
5364
|
ze(ie, ue, St, ge), ze(ri, ni, ai, ge), ze(oi, li, ci, te), ze(ri, ni, ai, ge), ze(ls, cs, us, te), ze(oi, li, ci, te);
|
|
5349
5365
|
}
|
|
5350
5366
|
}
|
|
5351
|
-
Q && f > Z &&
|
|
5367
|
+
Q && f > Z && Fe.set(g.id, { first: Z, count: f - Z });
|
|
5352
5368
|
}
|
|
5353
|
-
f > 0 && (r.queue.writeBuffer(
|
|
5369
|
+
f > 0 && (r.queue.writeBuffer(k, 0, D, 0, f * 8), r.queue.writeBuffer(G, 0, N, 0, f * 4), r.queue.writeBuffer(de, 0, Y, 0, f * 4)), De = m / 7, De > 0 && r.queue.writeBuffer(zt, 0, le, 0, m);
|
|
5354
5370
|
}
|
|
5355
5371
|
const Tt = () => {
|
|
5356
5372
|
r.queue.writeBuffer(M, 0, new Float32Array([1, 0, a.width, a.height, 0, 0, 0, 0])), r.queue.writeBuffer(R, 0, new Float32Array([0, 1, a.width, a.height, 0, 0, 0, 0]));
|
|
@@ -5363,11 +5379,11 @@ async function vr(s, t = {}) {
|
|
|
5363
5379
|
particleAdditivePipeline: zi,
|
|
5364
5380
|
particleDepthWritePipeline: Gi,
|
|
5365
5381
|
blurPipeline: We,
|
|
5366
|
-
compositePipeline:
|
|
5367
|
-
directRenderPipeline:
|
|
5368
|
-
finalCompositePipeline:
|
|
5382
|
+
compositePipeline: Fi,
|
|
5383
|
+
directRenderPipeline: At,
|
|
5384
|
+
finalCompositePipeline: Di,
|
|
5369
5385
|
glbMeshPipeline: Vi
|
|
5370
|
-
} = tr(r, c, fe),
|
|
5386
|
+
} = tr(r, c, fe), Ct = r.createShaderModule({ code: `
|
|
5371
5387
|
struct U { mvp: mat4x4<f32> };
|
|
5372
5388
|
@group(0) @binding(0) var<uniform> u: U;
|
|
5373
5389
|
struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
|
|
@@ -5379,7 +5395,7 @@ async function vr(s, t = {}) {
|
|
|
5379
5395
|
}), Oi = r.createRenderPipeline({
|
|
5380
5396
|
layout: r.createPipelineLayout({ bindGroupLayouts: [Ut] }),
|
|
5381
5397
|
vertex: {
|
|
5382
|
-
module:
|
|
5398
|
+
module: Ct,
|
|
5383
5399
|
entryPoint: "vs",
|
|
5384
5400
|
buffers: [{ arrayStride: 28, attributes: [
|
|
5385
5401
|
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
@@ -5387,7 +5403,7 @@ async function vr(s, t = {}) {
|
|
|
5387
5403
|
] }]
|
|
5388
5404
|
},
|
|
5389
5405
|
fragment: {
|
|
5390
|
-
module:
|
|
5406
|
+
module: Ct,
|
|
5391
5407
|
entryPoint: "fs",
|
|
5392
5408
|
targets: [{ format: "rgba16float", blend: {
|
|
5393
5409
|
// renders into the HDR sceneTexture
|
|
@@ -5407,15 +5423,15 @@ async function vr(s, t = {}) {
|
|
|
5407
5423
|
layout: Ut,
|
|
5408
5424
|
entries: [{ binding: 0, resource: { buffer: b } }]
|
|
5409
5425
|
});
|
|
5410
|
-
let
|
|
5411
|
-
const
|
|
5412
|
-
const f = (
|
|
5426
|
+
let De = 0, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe } = yi(r, c, a.width, a.height), Je = gi(r, a.width, a.height), Te, Gt, Qe, Ve;
|
|
5427
|
+
const Ft = () => {
|
|
5428
|
+
const f = (m) => m.createView();
|
|
5413
5429
|
Te = f(be), Gt = f(Se), Qe = f(xe), Ve = f(Je);
|
|
5414
5430
|
};
|
|
5415
|
-
|
|
5416
|
-
const ut = { uniformBuffer: b, appearanceUniformBuffer:
|
|
5431
|
+
Ft();
|
|
5432
|
+
const ut = { uniformBuffer: b, appearanceUniformBuffer: _, horizontalBlurUniformBuffer: M, verticalBlurUniformBuffer: R, bloomIntensityBuffer: x };
|
|
5417
5433
|
let Ke = Pt(r, se, ut, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe });
|
|
5418
|
-
const
|
|
5434
|
+
const C = {
|
|
5419
5435
|
mvp: new Float32Array(16),
|
|
5420
5436
|
position: new Float32Array([0, 0, 10]),
|
|
5421
5437
|
right: new Float32Array([1, 0, 0]),
|
|
@@ -5423,12 +5439,12 @@ async function vr(s, t = {}) {
|
|
|
5423
5439
|
up: new Float32Array([0, 1, 0]),
|
|
5424
5440
|
hasCamera: !1
|
|
5425
5441
|
};
|
|
5426
|
-
let
|
|
5427
|
-
const Ee = new Float32Array(5),
|
|
5428
|
-
let Ot = !1, dt = !0, et = !1, tt = null, ft = a.width,
|
|
5442
|
+
let he = 0, Xi = 0;
|
|
5443
|
+
const Ee = new Float32Array(5), Dt = new Float32Array(16), Ni = new Array(65), ki = new Array(65), ji = new Array(65), Yi = new Array(65), qi = new Array(65), Hi = new Array(65), Vt = [0, 0, 0], Ae = { key: null, ms: !1, bindGroup: null };
|
|
5444
|
+
let Ot = !1, dt = !0, et = !1, tt = null, ft = a.width, ht = a.height;
|
|
5429
5445
|
function Lt() {
|
|
5430
|
-
const f = [be, Se, xe, Je],
|
|
5431
|
-
be =
|
|
5446
|
+
const f = [be, Se, xe, Je], m = yi(r, c, a.width, a.height);
|
|
5447
|
+
be = m.sceneTexture, Se = m.bloomTexA, xe = m.bloomTexB, Je = gi(r, a.width, a.height), Ft(), Tt(), d.clear(), h.resizeTextures(), Ke = Pt(r, se, ut, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe });
|
|
5432
5448
|
let S = !1;
|
|
5433
5449
|
const g = () => {
|
|
5434
5450
|
if (!S) {
|
|
@@ -5439,41 +5455,41 @@ async function vr(s, t = {}) {
|
|
|
5439
5455
|
};
|
|
5440
5456
|
requestAnimationFrame(g);
|
|
5441
5457
|
}
|
|
5442
|
-
function Zi(f,
|
|
5443
|
-
|
|
5458
|
+
function Zi(f, m, S) {
|
|
5459
|
+
C.mvp.set(ar(f, m)), m && m.length >= 10 && (C.right[0] = m[0], C.right[1] = m[4], C.right[2] = m[8], C.up[0] = m[1], C.up[1] = m[5], C.up[2] = m[9]), S && (C.position[0] = S.x ?? S[0], C.position[1] = S.y ?? S[1], C.position[2] = S.z ?? S[2]), C.hasCamera = !0;
|
|
5444
5460
|
}
|
|
5445
|
-
function $i(f,
|
|
5446
|
-
|
|
5461
|
+
function $i(f, m) {
|
|
5462
|
+
C.mvp.set(f), m && (C.position[0] = m.x ?? m[0], C.position[1] = m.y ?? m[1], C.position[2] = m.z ?? m[2]), C.hasCamera = !0;
|
|
5447
5463
|
}
|
|
5448
|
-
async function
|
|
5464
|
+
async function pt(f) {
|
|
5449
5465
|
if (et) {
|
|
5450
5466
|
tt = f;
|
|
5451
5467
|
return;
|
|
5452
5468
|
}
|
|
5453
5469
|
et = !0;
|
|
5454
5470
|
try {
|
|
5455
|
-
for (const
|
|
5456
|
-
d.clear(),
|
|
5457
|
-
for (const
|
|
5458
|
-
await l.addSystems(
|
|
5459
|
-
for (const { config:
|
|
5460
|
-
P[
|
|
5471
|
+
for (const m in P) delete P[m];
|
|
5472
|
+
d.clear(), h.resizeTextures(), Ke = Pt(r, se, ut, { sceneTexture: be, bloomTexA: Se, bloomTexB: xe }), await l.replaceSystems({ systems: [], activeSystemIndex: 0 });
|
|
5473
|
+
for (const m of f)
|
|
5474
|
+
await l.addSystems(m.preset, m.position || [0, 0, 0]);
|
|
5475
|
+
for (const { config: m } of l.particleSystems)
|
|
5476
|
+
P[m.id] || (P[m.id] = T());
|
|
5461
5477
|
dt = !0, l.respawnAllSystems();
|
|
5462
5478
|
} finally {
|
|
5463
5479
|
if (et = !1, tt) {
|
|
5464
|
-
const
|
|
5465
|
-
tt = null,
|
|
5480
|
+
const m = tt;
|
|
5481
|
+
tt = null, pt(m);
|
|
5466
5482
|
}
|
|
5467
5483
|
}
|
|
5468
5484
|
}
|
|
5469
|
-
async function Wi(f,
|
|
5470
|
-
return
|
|
5485
|
+
async function Wi(f, m = [0, 0, 0]) {
|
|
5486
|
+
return pt([{ preset: f, position: m }]);
|
|
5471
5487
|
}
|
|
5472
5488
|
function Ji(f) {
|
|
5473
5489
|
if (Ot || et || !l.ready || f <= 0 || l.particleSystems.length === 0) return;
|
|
5474
|
-
const
|
|
5475
|
-
if (
|
|
5476
|
-
if ((a.width !== ft || a.height !==
|
|
5490
|
+
const m = l.clock;
|
|
5491
|
+
if (m && (m.loop = l.loop ?? i, m.duration = l.getTotalDuration(), f = m.tick(f)), f > 0.1 && (f = 0.1), f <= 0) return;
|
|
5492
|
+
if ((a.width !== ft || a.height !== ht) && (ft = a.width, ht = a.height, Lt()), he += f, W.length) {
|
|
5477
5493
|
for (const y of W) {
|
|
5478
5494
|
if (y.getPosition) {
|
|
5479
5495
|
const B = y.getPosition();
|
|
@@ -5486,36 +5502,36 @@ async function vr(s, t = {}) {
|
|
|
5486
5502
|
if (!(!U || U.historyOnly) && (B.hidden = !U.pos, U.pos)) {
|
|
5487
5503
|
let I = null;
|
|
5488
5504
|
if (U.orientToDirection && U.vel) {
|
|
5489
|
-
const
|
|
5490
|
-
Math.hypot(
|
|
5505
|
+
const F = U.vel[0], J = U.vel[2];
|
|
5506
|
+
Math.hypot(F, J) > 1e-4 && (I = [0, 0, Math.atan2(F, J)]);
|
|
5491
5507
|
}
|
|
5492
5508
|
y.setSimulationTransform({ position: U.pos, velocity: U.vel, rotation: I }), y.updateAppearanceUniform(), (U.justResumed || y.activeParticles === 0) && y.spawnParticles();
|
|
5493
5509
|
}
|
|
5494
5510
|
}
|
|
5495
5511
|
for (const y of W)
|
|
5496
|
-
y.pos ?
|
|
5512
|
+
y.pos ? Ai(y, he) : y.hist.length = 0, y.pos ? (y._prevPosBuf[0] = y.pos[0], y._prevPosBuf[1] = y.pos[1], y._prevPosBuf[2] = y.pos[2], y.prevPos = y._prevPosBuf) : y.prevPos = null, y.wasActive = !!y.pos;
|
|
5497
5513
|
if (globalThis.__HZFX_DEBUG && (Xi++ & 63) === 0) {
|
|
5498
|
-
const y = l.particleSystems.reduce((
|
|
5499
|
-
console.info(`[HZFX] movingGroups(${W.length})=[${I}] activeParticles=${y} systems=${l.particleSystems.length} ribbonVerts=${
|
|
5514
|
+
const y = l.particleSystems.reduce((F, J) => F + (J.system.activeParticles | 0), 0), B = W.find((F) => F.pos), U = B ? Math.hypot(C.position[0] - B.pos[0], C.position[1] - B.pos[1], C.position[2] - B.pos[2]).toFixed(1) : "-", I = W.map((F) => `{ids:[${[...F.ids]}],pos:${F.pos ? "1" : "0"},hist:${F.hist.length}}`).join(",");
|
|
5515
|
+
console.info(`[HZFX] movingGroups(${W.length})=[${I}] activeParticles=${y} systems=${l.particleSystems.length} ribbonVerts=${De} camDist=${U} t=${he.toFixed(1)}`);
|
|
5500
5516
|
}
|
|
5501
5517
|
}
|
|
5502
|
-
if (l.updateAllSystems(f),
|
|
5518
|
+
if (l.updateAllSystems(f), m ? m.loop : l.loop ?? i) {
|
|
5503
5519
|
const y = l.particleSystems.length > 0 && l.particleSystems.every(({ system: B }) => B.activeParticles === 0 && !B.emitting);
|
|
5504
|
-
(
|
|
5520
|
+
(m && m.justLooped || y && dt) && l.respawnAllSystems(), dt = !y;
|
|
5505
5521
|
}
|
|
5506
5522
|
for (const { system: y, config: B } of l.particleSystems)
|
|
5507
5523
|
B.glbModelEnabled && y.glbAnimator && (y.glbAnimator.update(f), y.updateAnimatedGLBBuffer());
|
|
5508
|
-
r.queue.writeBuffer(b, 0,
|
|
5524
|
+
r.queue.writeBuffer(b, 0, C.mvp), Ee[0] = C.position[0], Ee[1] = C.position[1], Ee[2] = C.position[2], Ee[3] = a.height / Math.max(1, a.width), Ee[4] = he, r.queue.writeBuffer(b, 64, Ee), Ui();
|
|
5509
5525
|
const g = l.particleSystems.some(({ config: y }) => y.bloomEnabled), v = r.createCommandEncoder();
|
|
5510
|
-
let
|
|
5526
|
+
let q = !1;
|
|
5511
5527
|
if (e)
|
|
5512
5528
|
try {
|
|
5513
5529
|
const y = e();
|
|
5514
5530
|
if (y) {
|
|
5515
5531
|
let B = null, U = null, I = !1;
|
|
5516
5532
|
if (y instanceof GPUTexture ? y.width === a.width && y.height === a.height && (B = y, U = () => y.createView({ aspect: "depth-only" }), I = y.sampleCount > 1) : y.view && (B = y.view, U = () => y.view, I = !!y.multisampled), B) {
|
|
5517
|
-
const { pipeline:
|
|
5518
|
-
(
|
|
5533
|
+
const { pipeline: F, layout: J } = p(I);
|
|
5534
|
+
(Ae.key !== B || Ae.ms !== I) && (Ae.key = B, Ae.ms = I, Ae.bindGroup = r.createBindGroup({
|
|
5519
5535
|
layout: J,
|
|
5520
5536
|
entries: [{ binding: 0, resource: U() }]
|
|
5521
5537
|
}));
|
|
@@ -5523,18 +5539,18 @@ async function vr(s, t = {}) {
|
|
|
5523
5539
|
colorAttachments: [],
|
|
5524
5540
|
depthStencilAttachment: { view: Ve, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5525
5541
|
});
|
|
5526
|
-
K.setPipeline(
|
|
5542
|
+
K.setPipeline(F), K.setBindGroup(0, Ae.bindGroup), K.draw(3), K.end(), q = !0;
|
|
5527
5543
|
}
|
|
5528
5544
|
}
|
|
5529
5545
|
} catch {
|
|
5530
5546
|
}
|
|
5531
5547
|
const j = v.beginRenderPass({
|
|
5532
5548
|
colorAttachments: [{ view: Te, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5533
|
-
depthStencilAttachment:
|
|
5549
|
+
depthStencilAttachment: q ? { view: Ve, depthLoadOp: "load", depthStoreOp: "store" } : { view: Ve, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5534
5550
|
});
|
|
5535
5551
|
for (const { system: y, config: B } of l.particleSystems)
|
|
5536
5552
|
B.bloomEnabled || B.hidden || y.activeParticles === 0 || Xt(j, y, B);
|
|
5537
|
-
if (
|
|
5553
|
+
if (De > 0 && (j.setPipeline(Oi), j.setBindGroup(0, Li), j.setVertexBuffer(0, zt), j.draw(De)), j.end(), g) {
|
|
5538
5554
|
const y = {
|
|
5539
5555
|
colorAttachments: [{ view: Gt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5540
5556
|
}, B = {
|
|
@@ -5542,11 +5558,11 @@ async function vr(s, t = {}) {
|
|
|
5542
5558
|
};
|
|
5543
5559
|
for (const { system: U, config: I } of l.particleSystems) {
|
|
5544
5560
|
if (!I.bloomEnabled || I.hidden || U.activeParticles === 0) continue;
|
|
5545
|
-
const
|
|
5561
|
+
const F = U.config.id, J = h.getBloomSourceTexture(F, a.width, a.height), K = v.beginRenderPass({
|
|
5546
5562
|
colorAttachments: [{ view: J.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5547
5563
|
depthStencilAttachment: { view: Ve, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
5548
5564
|
});
|
|
5549
|
-
Xt(K, U, I), K.end(),
|
|
5565
|
+
Xt(K, U, I), K.end(), Dt[0] = I.bloomIntensity, r.queue.writeBuffer(x, 0, Dt), d.systemBloomHorizontalBindGroups[F] || (d.systemBloomHorizontalBindGroups[F] = r.createBindGroup({
|
|
5550
5566
|
layout: fe.bloomBindGroupLayout,
|
|
5551
5567
|
entries: [
|
|
5552
5568
|
{ binding: 0, resource: se },
|
|
@@ -5555,18 +5571,18 @@ async function vr(s, t = {}) {
|
|
|
5555
5571
|
]
|
|
5556
5572
|
}));
|
|
5557
5573
|
let X = v.beginRenderPass(y);
|
|
5558
|
-
X.setPipeline(We), X.setBindGroup(0, d.systemBloomHorizontalBindGroups[
|
|
5574
|
+
X.setPipeline(We), X.setBindGroup(0, d.systemBloomHorizontalBindGroups[F]), X.draw(3), X.end(), X = v.beginRenderPass(B), X.setPipeline(We), X.setBindGroup(0, Ke.verticalBlurBindGroup), X.draw(3), X.end(), d.secondHorizontalBindGroups[F] || (d.secondHorizontalBindGroups[F] = r.createBindGroup({
|
|
5559
5575
|
layout: fe.bloomBindGroupLayout,
|
|
5560
5576
|
entries: [
|
|
5561
5577
|
{ binding: 0, resource: se },
|
|
5562
5578
|
{ binding: 1, resource: Qe },
|
|
5563
5579
|
{ binding: 2, resource: { buffer: M } }
|
|
5564
5580
|
]
|
|
5565
|
-
})), X = v.beginRenderPass(y), X.setPipeline(We), X.setBindGroup(0, d.secondHorizontalBindGroups[
|
|
5566
|
-
const it =
|
|
5581
|
+
})), X = v.beginRenderPass(y), X.setPipeline(We), X.setBindGroup(0, d.secondHorizontalBindGroups[F]), X.draw(3), X.end(), X = v.beginRenderPass(B), X.setPipeline(We), X.setBindGroup(0, Ke.verticalBlurBindGroup), X.draw(3), X.end();
|
|
5582
|
+
const it = h.getBloomCompositeTexture(F, a.width, a.height);
|
|
5567
5583
|
X = v.beginRenderPass({
|
|
5568
5584
|
colorAttachments: [{ view: it.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5569
|
-
}), X.setPipeline(
|
|
5585
|
+
}), X.setPipeline(Fi), d.systemBloomCompositeBindGroups[F] || (d.systemBloomCompositeBindGroups[F] = r.createBindGroup({
|
|
5570
5586
|
layout: fe.compositeBindGroupLayout,
|
|
5571
5587
|
entries: [
|
|
5572
5588
|
{ binding: 0, resource: se },
|
|
@@ -5574,13 +5590,13 @@ async function vr(s, t = {}) {
|
|
|
5574
5590
|
{ binding: 2, resource: Qe },
|
|
5575
5591
|
{ binding: 3, resource: { buffer: U.bloomIntensityBuffer } }
|
|
5576
5592
|
]
|
|
5577
|
-
})), X.setBindGroup(0, d.systemBloomCompositeBindGroups[
|
|
5593
|
+
})), X.setBindGroup(0, d.systemBloomCompositeBindGroups[F]), X.draw(3), X.end();
|
|
5578
5594
|
}
|
|
5579
5595
|
}
|
|
5580
|
-
const Q =
|
|
5596
|
+
const Q = h.getCombinedTexture(a.width, a.height), Z = v.beginRenderPass({
|
|
5581
5597
|
colorAttachments: [{ view: Q.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5582
5598
|
});
|
|
5583
|
-
Z.setPipeline(
|
|
5599
|
+
Z.setPipeline(At), d.combinedInitialBindGroup || (d.combinedInitialBindGroup = r.createBindGroup({
|
|
5584
5600
|
layout: fe.compositeBindGroupLayout,
|
|
5585
5601
|
entries: [
|
|
5586
5602
|
{ binding: 0, resource: se },
|
|
@@ -5592,18 +5608,18 @@ async function vr(s, t = {}) {
|
|
|
5592
5608
|
for (const { config: y, system: B } of l.particleSystems) {
|
|
5593
5609
|
if (!y.bloomEnabled || y.hidden || B.activeParticles === 0) continue;
|
|
5594
5610
|
const U = B.config.id;
|
|
5595
|
-
Z.setPipeline(
|
|
5611
|
+
Z.setPipeline(At), d.combinedBloomCompositeBindGroups[U] || (d.combinedBloomCompositeBindGroups[U] = r.createBindGroup({
|
|
5596
5612
|
layout: fe.compositeBindGroupLayout,
|
|
5597
5613
|
entries: [
|
|
5598
5614
|
{ binding: 0, resource: se },
|
|
5599
|
-
{ binding: 1, resource:
|
|
5615
|
+
{ binding: 1, resource: h.getBloomCompositeTexture(U, a.width, a.height).createView() },
|
|
5600
5616
|
{ binding: 2, resource: Te },
|
|
5601
5617
|
{ binding: 3, resource: { buffer: x } }
|
|
5602
5618
|
]
|
|
5603
5619
|
})), Z.setBindGroup(0, d.combinedBloomCompositeBindGroups[U]), Z.draw(3);
|
|
5604
5620
|
}
|
|
5605
5621
|
Z.end();
|
|
5606
|
-
const
|
|
5622
|
+
const Ce = v.beginRenderPass({
|
|
5607
5623
|
colorAttachments: [{
|
|
5608
5624
|
view: n.getCurrentTexture().createView(),
|
|
5609
5625
|
loadOp: o ? "load" : "clear",
|
|
@@ -5611,7 +5627,7 @@ async function vr(s, t = {}) {
|
|
|
5611
5627
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
5612
5628
|
}]
|
|
5613
5629
|
});
|
|
5614
|
-
|
|
5630
|
+
Ce.setPipeline(Di), d.finalBindGroup || (d.finalBindGroup = r.createBindGroup({
|
|
5615
5631
|
layout: fe.compositeBindGroupLayout,
|
|
5616
5632
|
entries: [
|
|
5617
5633
|
{ binding: 0, resource: se },
|
|
@@ -5619,69 +5635,69 @@ async function vr(s, t = {}) {
|
|
|
5619
5635
|
{ binding: 2, resource: Te },
|
|
5620
5636
|
{ binding: 3, resource: { buffer: x } }
|
|
5621
5637
|
]
|
|
5622
|
-
})),
|
|
5638
|
+
})), Ce.setBindGroup(0, d.finalBindGroup), Ce.draw(3), Ce.end(), r.queue.submit([v.finish()]);
|
|
5623
5639
|
}
|
|
5624
|
-
function Xt(f,
|
|
5625
|
-
const g =
|
|
5626
|
-
d.textureStates[g] = S.textureEnabled, d.textureRefs[g] =
|
|
5640
|
+
function Xt(f, m, S) {
|
|
5641
|
+
const g = m.config.id, v = S.glbModelEnabled && m.glbMeshData, q = !d.systemBindGroups[g] || d.textureStates[g] !== S.textureEnabled || d.textureRefs[g] !== m.particleTexture;
|
|
5642
|
+
d.textureStates[g] = S.textureEnabled, d.textureRefs[g] = m.particleTexture, q && (d.systemBindGroups[g] = r.createBindGroup({
|
|
5627
5643
|
layout: fe.particleBindGroupLayout,
|
|
5628
5644
|
entries: [
|
|
5629
5645
|
{ binding: 0, resource: { buffer: b } },
|
|
5630
|
-
{ binding: 1, resource: { buffer:
|
|
5631
|
-
{ binding: 2, resource:
|
|
5646
|
+
{ binding: 1, resource: { buffer: m.appearanceUniformBuffer } },
|
|
5647
|
+
{ binding: 2, resource: m.particleTexture.createView() },
|
|
5632
5648
|
{ binding: 3, resource: se }
|
|
5633
5649
|
]
|
|
5634
5650
|
}));
|
|
5635
5651
|
const j = d.systemBindGroups[g], Q = S.shapeDisplay !== !1;
|
|
5636
5652
|
if (v)
|
|
5637
|
-
Q && (f.setPipeline(Vi), f.setBindGroup(0, j), f.setVertexBuffer(0,
|
|
5653
|
+
Q && (f.setPipeline(Vi), f.setBindGroup(0, j), f.setVertexBuffer(0, m.glbVertexBuffer), f.setVertexBuffer(1, m.instanceBuffer), f.setVertexBuffer(2, m.velocityBuffer), f.setIndexBuffer(m.glbIndexBuffer, m.glbIndexFormat), f.drawIndexed(m.glbIndexCount, m.activeParticles));
|
|
5638
5654
|
else {
|
|
5639
|
-
f.setPipeline(S.blendMode === "additive" ? zi : Ii), f.setIndexBuffer(L, "uint16"), P[g] || (P[g] = T()), f.setVertexBuffer(0, P[g]), f.setBindGroup(0, j), Q && (f.setVertexBuffer(1,
|
|
5640
|
-
const Z =
|
|
5641
|
-
Z && (f.setVertexBuffer(1,
|
|
5655
|
+
f.setPipeline(S.blendMode === "additive" ? zi : Ii), f.setIndexBuffer(L, "uint16"), P[g] || (P[g] = T()), f.setVertexBuffer(0, P[g]), f.setBindGroup(0, j), Q && (f.setVertexBuffer(1, m.instanceBuffer), f.setVertexBuffer(2, m.velocityBuffer), f.setVertexBuffer(3, m.trailBuffer), f.drawIndexed(6, m.activeParticles));
|
|
5656
|
+
const Z = Fe.get(g);
|
|
5657
|
+
Z && (f.setVertexBuffer(1, k), f.setVertexBuffer(2, G), f.setVertexBuffer(3, de), f.drawIndexed(6, Z.count, 0, 0, Z.first)), Q && S.depthWriteEnabled && (f.setPipeline(Gi), f.drawIndexed(6, m.activeParticles));
|
|
5642
5658
|
}
|
|
5643
5659
|
}
|
|
5644
5660
|
function Qi() {
|
|
5645
|
-
ft = a.width,
|
|
5661
|
+
ft = a.width, ht = a.height, Lt();
|
|
5646
5662
|
}
|
|
5647
5663
|
function Ki() {
|
|
5648
5664
|
d.clear();
|
|
5649
5665
|
}
|
|
5650
5666
|
function es() {
|
|
5651
|
-
Ot = !0, l.destroy(), [be, Se, xe, Je].forEach((f) => f == null ? void 0 : f.destroy()),
|
|
5667
|
+
Ot = !0, l.destroy(), [be, Se, xe, Je].forEach((f) => f == null ? void 0 : f.destroy()), h.resizeTextures(), [
|
|
5652
5668
|
b,
|
|
5653
|
-
|
|
5669
|
+
_,
|
|
5654
5670
|
M,
|
|
5655
5671
|
R,
|
|
5656
5672
|
x,
|
|
5657
5673
|
L,
|
|
5658
|
-
|
|
5674
|
+
k,
|
|
5659
5675
|
G,
|
|
5660
5676
|
de
|
|
5661
5677
|
].forEach((f) => f == null ? void 0 : f.destroy()), Object.values(P).forEach((f) => f == null ? void 0 : f.destroy());
|
|
5662
5678
|
}
|
|
5663
|
-
async function
|
|
5664
|
-
const S = await l.addSystems(f,
|
|
5679
|
+
async function Nt(f, m) {
|
|
5680
|
+
const S = await l.addSystems(f, m);
|
|
5665
5681
|
for (const { config: g } of l.particleSystems)
|
|
5666
5682
|
P[g.id] || (P[g.id] = T());
|
|
5667
5683
|
return l.respawnAllSystems(), new Set(Array.isArray(S) ? S : []);
|
|
5668
5684
|
}
|
|
5669
|
-
function
|
|
5670
|
-
for (const
|
|
5671
|
-
const S = l.particleSystems.findIndex((g) => g.config.id ===
|
|
5685
|
+
function kt(f) {
|
|
5686
|
+
for (const m of f) {
|
|
5687
|
+
const S = l.particleSystems.findIndex((g) => g.config.id === m);
|
|
5672
5688
|
S >= 0 && l.removeSystem(S);
|
|
5673
5689
|
}
|
|
5674
5690
|
}
|
|
5675
|
-
async function ts(f,
|
|
5676
|
-
const S = await
|
|
5691
|
+
async function ts(f, m = [0, 0, 0]) {
|
|
5692
|
+
const S = await Nt(f, m);
|
|
5677
5693
|
return { remove() {
|
|
5678
|
-
|
|
5694
|
+
kt(S);
|
|
5679
5695
|
} };
|
|
5680
5696
|
}
|
|
5681
|
-
async function is(f,
|
|
5682
|
-
const S = await
|
|
5697
|
+
async function is(f, m = {}) {
|
|
5698
|
+
const S = await Nt(f, [0, 0, 0]);
|
|
5683
5699
|
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(f && f.systems || []).length} newIds=[${[...S]}]`);
|
|
5684
|
-
const g = { ids: S, pos: null, hist: [], getPosition:
|
|
5700
|
+
const g = { ids: S, pos: null, hist: [], getPosition: m.getPosition || null, orientToDirection: !!m.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
5685
5701
|
return W.push(g), {
|
|
5686
5702
|
setPosition(v) {
|
|
5687
5703
|
v && (g.pos = Array.isArray(v) ? [v[0], v[1], v[2]] : [v.x, v.y, v.z]);
|
|
@@ -5690,14 +5706,14 @@ async function vr(s, t = {}) {
|
|
|
5690
5706
|
g.orientToDirection = !!v;
|
|
5691
5707
|
},
|
|
5692
5708
|
remove() {
|
|
5693
|
-
|
|
5709
|
+
kt(S);
|
|
5694
5710
|
const v = W.indexOf(g);
|
|
5695
5711
|
v >= 0 && W.splice(v, 1);
|
|
5696
5712
|
}
|
|
5697
5713
|
};
|
|
5698
5714
|
}
|
|
5699
|
-
function ss(f,
|
|
5700
|
-
const g = { ids: f instanceof Set ? f : new Set(f), pos: null, hist: [], getPosition:
|
|
5715
|
+
function ss(f, m) {
|
|
5716
|
+
const g = { ids: f instanceof Set ? f : new Set(f), pos: null, hist: [], getPosition: m, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
5701
5717
|
return W.push(g), {
|
|
5702
5718
|
remove() {
|
|
5703
5719
|
const v = W.indexOf(g);
|
|
@@ -5718,7 +5734,7 @@ async function vr(s, t = {}) {
|
|
|
5718
5734
|
context: n,
|
|
5719
5735
|
setCamera: Zi,
|
|
5720
5736
|
setCameraMVP: $i,
|
|
5721
|
-
setEmitters:
|
|
5737
|
+
setEmitters: pt,
|
|
5722
5738
|
loadPreset: Wi,
|
|
5723
5739
|
addEmitter: ts,
|
|
5724
5740
|
addMovingEmitter: is,
|
|
@@ -5735,16 +5751,16 @@ function Pr(s) {
|
|
|
5735
5751
|
try {
|
|
5736
5752
|
const l = s.backend;
|
|
5737
5753
|
if (!l) return null;
|
|
5738
|
-
const u = s.domElement.width,
|
|
5739
|
-
if (s.needsFrameBufferTarget &&
|
|
5740
|
-
const
|
|
5741
|
-
(r =
|
|
5742
|
-
|
|
5743
|
-
(n =
|
|
5754
|
+
const u = s.domElement.width, p = s.domElement.height, h = (typeof s._getFrameBufferTarget == "function" ? s._getFrameBufferTarget() : null) || s._frameBufferTarget || null;
|
|
5755
|
+
if (s.needsFrameBufferTarget && h) {
|
|
5756
|
+
const _ = l.get(h), M = ((i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, h)) == null ? void 0 : i.depthTexture) || h.depthTexture, R = [
|
|
5757
|
+
(r = _ == null ? void 0 : _.depthTexture) == null ? void 0 : r.texture,
|
|
5758
|
+
_ == null ? void 0 : _.depthTexture,
|
|
5759
|
+
(n = _ == null ? void 0 : _.depthBuffer) == null ? void 0 : n.texture,
|
|
5744
5760
|
M ? (a = l.get(M)) == null ? void 0 : a.texture : null
|
|
5745
5761
|
];
|
|
5746
5762
|
for (const x of R)
|
|
5747
|
-
if (x && typeof x.createView == "function" && x.width === u && x.height ===
|
|
5763
|
+
if (x && typeof x.createView == "function" && x.width === u && x.height === p) return x;
|
|
5748
5764
|
return null;
|
|
5749
5765
|
}
|
|
5750
5766
|
const d = s.getCanvasTarget ? l.get(s.getCanvasTarget()) : null, b = ((c = (o = d == null ? void 0 : d.descriptor) == null ? void 0 : o.depthStencilAttachment) == null ? void 0 : c.view) ?? null;
|
|
@@ -5755,9 +5771,9 @@ function Pr(s) {
|
|
|
5755
5771
|
};
|
|
5756
5772
|
}
|
|
5757
5773
|
export {
|
|
5758
|
-
|
|
5774
|
+
ks as GLBAnimator,
|
|
5759
5775
|
js as HZClock,
|
|
5760
|
-
|
|
5776
|
+
hr as Objects3DManager,
|
|
5761
5777
|
ms as ParticleEmitter,
|
|
5762
5778
|
_s as ParticlePhysics,
|
|
5763
5779
|
ui as ParticleScript,
|
|
@@ -5781,7 +5797,7 @@ export {
|
|
|
5781
5797
|
fi as extractGLBTexture,
|
|
5782
5798
|
xr as fetchPreset,
|
|
5783
5799
|
Ks as glbMeshParticleShader,
|
|
5784
|
-
|
|
5800
|
+
pr as hexToRgb,
|
|
5785
5801
|
vr as initHzFxOverlay,
|
|
5786
5802
|
Js as initWebGPU,
|
|
5787
5803
|
Ti as isHZFX,
|
|
@@ -5790,7 +5806,7 @@ export {
|
|
|
5790
5806
|
ar as multiplyMatrices,
|
|
5791
5807
|
Qs as object3dShader,
|
|
5792
5808
|
lr as packHZFX,
|
|
5793
|
-
|
|
5809
|
+
As as parseGLB,
|
|
5794
5810
|
vs as particlePhysicsShader,
|
|
5795
5811
|
ys as particleShader,
|
|
5796
5812
|
mr as rgbToHex,
|