hz-particles 1.3.0 → 1.4.0
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 +15 -8
- package/dist-lib/hz-particles.cjs +61 -19
- package/dist-lib/hz-particles.d.ts +16 -1
- package/dist-lib/hz-particles.mjs +756 -753
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class fs {
|
|
2
2
|
constructor(t = {}) {
|
|
3
3
|
this.config = t, this._posOut = [0, 0, 0], this._rotMatrix = null, this._invRotMatrix = null, this._cachedRotX = void 0, this._cachedRotY = void 0, this._cachedRotZ = void 0;
|
|
4
4
|
}
|
|
@@ -10,14 +10,14 @@ class ds {
|
|
|
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), h = Math.cos(a), p = Math.sin(a);
|
|
14
14
|
this._rotMatrix = [
|
|
15
|
-
l *
|
|
16
|
-
c * u *
|
|
17
|
-
o * u *
|
|
15
|
+
l * h,
|
|
16
|
+
c * u * h - o * p,
|
|
17
|
+
o * u * h + c * p,
|
|
18
18
|
l * p,
|
|
19
|
-
c * u * p + o *
|
|
20
|
-
o * u * p - c *
|
|
19
|
+
c * u * p + o * h,
|
|
20
|
+
o * u * p - c * h,
|
|
21
21
|
-u,
|
|
22
22
|
c * l,
|
|
23
23
|
o * l
|
|
@@ -91,8 +91,8 @@ class ds {
|
|
|
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(), h = e + u * (i - e);
|
|
95
|
+
t[0] = o * h, t[1] = c * h, t[2] = l * h;
|
|
96
96
|
} else
|
|
97
97
|
t[0] = (Math.random() - 0.5) * i, t[1] = (Math.random() - 0.5) * i, t[2] = (Math.random() - 0.5) * i;
|
|
98
98
|
}
|
|
@@ -244,33 +244,33 @@ class ds {
|
|
|
244
244
|
e > 0 ? a = e + (i - e) * Math.random() : a = i * Math.sqrt(Math.random()), t[0] = Math.cos(n) * a, t[1] = (Math.random() - 0.5) * r, t[2] = Math.sin(n) * a;
|
|
245
245
|
}
|
|
246
246
|
calculateVelocity(t, e, i, r, n) {
|
|
247
|
-
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, u = e - o,
|
|
248
|
-
let d,
|
|
247
|
+
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, u = e - o, h = i - c, p = Math.sqrt(l * l + u * u + h * h);
|
|
248
|
+
let d, S, R;
|
|
249
249
|
if (p > 1e-4) {
|
|
250
|
-
let
|
|
250
|
+
let T = !1;
|
|
251
251
|
if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
|
|
252
|
-
const
|
|
252
|
+
const x = this.inverseRotation(l, u, h), L = Math.sqrt(x[0] * x[0] + x[1] * x[1]);
|
|
253
253
|
if (L > 1e-4) {
|
|
254
|
-
const
|
|
255
|
-
d =
|
|
254
|
+
const P = -x[1] / L, B = x[0] / L, M = this.applyRotation(P, B, 0);
|
|
255
|
+
d = M[0], S = M[1], R = M[2], T = !0;
|
|
256
256
|
}
|
|
257
257
|
} else if (this.config.emissionShape === "cylinder" && this.config.cylinderVelocityDirection === "tangential") {
|
|
258
|
-
const
|
|
258
|
+
const x = this.inverseRotation(l, u, h), L = Math.sqrt(x[0] * x[0] + x[2] * x[2]);
|
|
259
259
|
if (L > 1e-4) {
|
|
260
|
-
const
|
|
261
|
-
d =
|
|
260
|
+
const P = -x[2] / L, B = x[0] / L, M = this.applyRotation(P, 0, B);
|
|
261
|
+
d = M[0], S = M[1], R = M[2], T = !0;
|
|
262
262
|
} else {
|
|
263
|
-
const
|
|
264
|
-
d =
|
|
263
|
+
const P = Math.random() * Math.PI * 2, B = this.applyRotation(Math.cos(P), 0, Math.sin(P));
|
|
264
|
+
d = B[0], S = B[1], R = B[2], T = !0;
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
|
-
|
|
267
|
+
T || (d = l / p, S = u / p, R = h / p);
|
|
268
268
|
} else {
|
|
269
|
-
const
|
|
270
|
-
d = Math.sin(
|
|
269
|
+
const T = Math.random() * Math.PI * 2, x = Math.acos(2 * Math.random() - 1);
|
|
270
|
+
d = Math.sin(x) * Math.cos(T), S = Math.sin(x) * Math.sin(T), R = Math.cos(x);
|
|
271
271
|
}
|
|
272
|
-
let
|
|
273
|
-
this.config.randomSpeed ?
|
|
272
|
+
let E;
|
|
273
|
+
this.config.randomSpeed ? E = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : E = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : d * E, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : S * E, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : R * E, r[n + 3] = 0;
|
|
274
274
|
}
|
|
275
275
|
setParticleColor(t, e) {
|
|
276
276
|
if (this.config.randomColorEnabled && this.config.randomColors.length > 0) {
|
|
@@ -283,7 +283,7 @@ class ds {
|
|
|
283
283
|
t[e + 6] = 0, t[e + 7] = i + (Math.random() * 0.4 - 0.2) * i;
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
const
|
|
286
|
+
const ps = `
|
|
287
287
|
struct Uniforms {
|
|
288
288
|
transform: mat4x4<f32>,
|
|
289
289
|
cameraPosition: vec3<f32>,
|
|
@@ -299,7 +299,7 @@ const fs = `
|
|
|
299
299
|
singleColor: vec3<f32>,
|
|
300
300
|
rotation: f32,
|
|
301
301
|
startColor: vec3<f32>,
|
|
302
|
-
rotationMode: f32, // 0=fixed, 1=random, 2=towards velocity
|
|
302
|
+
rotationMode: f32, // 0=fixed, 1=random, 2=towards velocity, 3=oriented (world 3D plane), 4=cylindrical billboard
|
|
303
303
|
endColor: vec3<f32>,
|
|
304
304
|
minRotation: f32,
|
|
305
305
|
maxRotation: f32,
|
|
@@ -336,6 +336,10 @@ const fs = `
|
|
|
336
336
|
systemVelX: f32, // emitter/system world velocity (for velocity-aligned rotation
|
|
337
337
|
systemVelY: f32, // of trail particles that move WITH the emitter, e.g. a ball —
|
|
338
338
|
systemVelZ: f32, // their local velocity is ~0 so they need the system velocity)
|
|
339
|
+
orientX: f32, // rotationMode==3 (oriented): world-plane Euler angles (degrees)
|
|
340
|
+
orientY: f32,
|
|
341
|
+
orientZ: f32,
|
|
342
|
+
_pad2: f32, // keep struct size a multiple of 16 bytes (56 floats = 224 B)
|
|
339
343
|
}
|
|
340
344
|
|
|
341
345
|
@binding(0) @group(0) var<uniform> uniforms : Uniforms;
|
|
@@ -505,13 +509,51 @@ const fs = `
|
|
|
505
509
|
let rotatedX = scaledX * cosTheta - scaledY * sinTheta;
|
|
506
510
|
let rotatedY = scaledX * sinTheta + scaledY * cosTheta;
|
|
507
511
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
512
|
+
var finalPosition: vec4<f32>;
|
|
513
|
+
if (appearance.rotationMode == 3.0) {
|
|
514
|
+
// Oriented 3D mode: the sprite lies in a WORLD-space plane defined by Euler angles (degrees),
|
|
515
|
+
// no longer camera-facing. rotatedX/rotatedY already carry aspect + the per-particle in-plane
|
|
516
|
+
// rotation (which acts as roll within the tilted plane). Build the plane's right/up basis by
|
|
517
|
+
// rotating the world axes by Rx, then Ry, then Rz, place the quad corner in world space, and
|
|
518
|
+
// project. worldHalf matches the billboard's apparent size when the plane faces the camera.
|
|
519
|
+
let ox = appearance.orientX * 0.01745329252;
|
|
520
|
+
let oy = appearance.orientY * 0.01745329252;
|
|
521
|
+
let oz = appearance.orientZ * 0.01745329252;
|
|
522
|
+
let cx = cos(ox); let sx = sin(ox);
|
|
523
|
+
let cy = cos(oy); let sy = sin(oy);
|
|
524
|
+
let cz = cos(oz); let sz = sin(oz);
|
|
525
|
+
var rgt = vec3<f32>(1.0, 0.0, 0.0);
|
|
526
|
+
var upv = vec3<f32>(0.0, 1.0, 0.0);
|
|
527
|
+
rgt = vec3<f32>(rgt.x, rgt.y * cx - rgt.z * sx, rgt.y * sx + rgt.z * cx);
|
|
528
|
+
upv = vec3<f32>(upv.x, upv.y * cx - upv.z * sx, upv.y * sx + upv.z * cx);
|
|
529
|
+
rgt = vec3<f32>(rgt.x * cy + rgt.z * sy, rgt.y, -rgt.x * sy + rgt.z * cy);
|
|
530
|
+
upv = vec3<f32>(upv.x * cy + upv.z * sy, upv.y, -upv.x * sy + upv.z * cy);
|
|
531
|
+
rgt = vec3<f32>(rgt.x * cz - rgt.y * sz, rgt.x * sz + rgt.y * cz, rgt.z);
|
|
532
|
+
upv = vec3<f32>(upv.x * cz - upv.y * sz, upv.x * sz + upv.y * cz, upv.z);
|
|
533
|
+
let worldHalf = baseScaleFactor * 10.0;
|
|
534
|
+
let worldCorner = center + (rgt * rotatedX + upv * rotatedY) * worldHalf;
|
|
535
|
+
finalPosition = uniforms.transform * vec4<f32>(worldCorner, 1.0);
|
|
536
|
+
} else if (appearance.rotationMode == 4.0) {
|
|
537
|
+
// Cylindrical (upright) billboard: faces the camera around the world Y axis ONLY and stays
|
|
538
|
+
// vertical. From the side it looks like a normal billboard; from straight above/below you see
|
|
539
|
+
// it edge-on (like a tree/grass sprite). right = horizontal axis ⟂ to the view; up = world up.
|
|
540
|
+
let worldUp = vec3<f32>(0.0, 1.0, 0.0);
|
|
541
|
+
let toCam = uniforms.cameraPosition - center;
|
|
542
|
+
var rgt = cross(worldUp, toCam);
|
|
543
|
+
let rl = length(rgt);
|
|
544
|
+
rgt = select(vec3<f32>(1.0, 0.0, 0.0), rgt / rl, rl > 0.0001);
|
|
545
|
+
let worldHalf = baseScaleFactor * 10.0;
|
|
546
|
+
let worldCorner = center + (rgt * rotatedX + worldUp * rotatedY) * worldHalf;
|
|
547
|
+
finalPosition = uniforms.transform * vec4<f32>(worldCorner, 1.0);
|
|
548
|
+
} else {
|
|
549
|
+
finalPosition = vec4<f32>(
|
|
550
|
+
viewCenter.x + rotatedX * distanceScaleFactor * uniforms.aspectRatio * viewCenter.w,
|
|
551
|
+
viewCenter.y + rotatedY * distanceScaleFactor * viewCenter.w,
|
|
552
|
+
viewCenter.z,
|
|
553
|
+
viewCenter.w
|
|
554
|
+
);
|
|
555
|
+
}
|
|
556
|
+
|
|
515
557
|
output.position = finalPosition;
|
|
516
558
|
output.color = finalColor;
|
|
517
559
|
output.alpha = alpha;
|
|
@@ -663,7 +705,7 @@ const fs = `
|
|
|
663
705
|
return vec4<f32>(input.color, alpha);
|
|
664
706
|
}
|
|
665
707
|
}
|
|
666
|
-
`,
|
|
708
|
+
`, hs = `
|
|
667
709
|
struct BloomUniforms {
|
|
668
710
|
direction: vec2<f32>,
|
|
669
711
|
resolution: vec2<f32>,
|
|
@@ -723,7 +765,7 @@ const fs = `
|
|
|
723
765
|
|
|
724
766
|
return result / totalWeight * 1.1;
|
|
725
767
|
}
|
|
726
|
-
`,
|
|
768
|
+
`, ms = `
|
|
727
769
|
struct BloomIntensityUniforms {
|
|
728
770
|
intensity: f32,
|
|
729
771
|
color: vec3<f32>,
|
|
@@ -769,7 +811,7 @@ const fs = `
|
|
|
769
811
|
|
|
770
812
|
return vec4<f32>(originalColor.rgb + (mappedBloom * bloomUniforms.intensity), originalColor.a);
|
|
771
813
|
}
|
|
772
|
-
`,
|
|
814
|
+
`, ys = `
|
|
773
815
|
struct BloomIntensityUniforms {
|
|
774
816
|
intensity: f32,
|
|
775
817
|
color: vec3<f32>,
|
|
@@ -810,7 +852,7 @@ const fs = `
|
|
|
810
852
|
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
811
853
|
return textureSample(originalTexture, texSampler, input.texCoord);
|
|
812
854
|
}
|
|
813
|
-
`,
|
|
855
|
+
`, gs = `
|
|
814
856
|
@binding(0) @group(0) var texSampler: sampler;
|
|
815
857
|
@binding(1) @group(0) var originalTexture: texture_2d<f32>;
|
|
816
858
|
@binding(2) @group(0) var blurredTexture: texture_2d<f32>;
|
|
@@ -842,7 +884,7 @@ const fs = `
|
|
|
842
884
|
let c = textureSample(originalTexture, texSampler, input.texCoord);
|
|
843
885
|
return vec4<f32>(aces(c.rgb), c.a);
|
|
844
886
|
}
|
|
845
|
-
`,
|
|
887
|
+
`, bs = `
|
|
846
888
|
struct PhysicsUniforms {
|
|
847
889
|
deltaTime: f32,
|
|
848
890
|
particleSpeed: f32,
|
|
@@ -1052,7 +1094,7 @@ const fs = `
|
|
|
1052
1094
|
particleBuffer[baseIndex + 1u] = newPos.y;
|
|
1053
1095
|
particleBuffer[baseIndex + 2u] = newPos.z;
|
|
1054
1096
|
}
|
|
1055
|
-
`,
|
|
1097
|
+
`, Ss = `
|
|
1056
1098
|
@group(0) @binding(0) var<storage, read> restData: array<f32>;
|
|
1057
1099
|
@group(0) @binding(1) var<storage, read> jointWeightsData: array<f32>;
|
|
1058
1100
|
@group(0) @binding(2) var<storage, read> jointIndicesData: array<u32>;
|
|
@@ -1109,7 +1151,7 @@ const fs = `
|
|
|
1109
1151
|
outputData[outBase + 7u] = uv_v;
|
|
1110
1152
|
}
|
|
1111
1153
|
`;
|
|
1112
|
-
class
|
|
1154
|
+
class xs {
|
|
1113
1155
|
constructor(t, e = 1e4) {
|
|
1114
1156
|
this.device = t, this.physicsSettings = {
|
|
1115
1157
|
deltaTime: 0.016,
|
|
@@ -1198,7 +1240,7 @@ class Ss {
|
|
|
1198
1240
|
}),
|
|
1199
1241
|
compute: {
|
|
1200
1242
|
module: this.device.createShaderModule({
|
|
1201
|
-
code:
|
|
1243
|
+
code: bs
|
|
1202
1244
|
}),
|
|
1203
1245
|
entryPoint: "main"
|
|
1204
1246
|
}
|
|
@@ -1231,8 +1273,8 @@ class Ss {
|
|
|
1231
1273
|
o[0] = t, o[1] = i.particleSpeed, o[2] = c.gravity, o[3] = c.turbulence, o[4] = c.attractorStrength, o[5] = c.damping, o[6] = c.attractorPosition[0], o[7] = c.attractorPosition[1], o[8] = c.attractorPosition[2], this._physicsDataU32View[9] = e, o[10] = c.confinementEnabled ? 1 : 0, o[11] = c.confinementShape === "sphere" ? 1 : 0, o[12] = c.confinementMode === "kill" ? 1 : 0, o[13] = c.confinementSpace === "local" ? 1 : 0, o[14] = c.confinementBoxHalfSize[0], o[15] = c.confinementBoxHalfSize[1], o[16] = c.confinementBoxHalfSize[2], o[17] = c.confinementSphereRadius, o[18] = c.confinementRestitution, o[19] = c.confinementFriction, o[20] = c.confinementCenter[0], o[21] = c.confinementCenter[1], o[22] = c.confinementCenter[2], o[23] = c.softBoundaryEnabled ? 1 : 0, o[24] = c.softBoundaryStrength, o[25] = c.softBoundaryFalloff, o[26] = i.velocityStretchEnabled ? 1 : 0, o[27] = i.velocityStretchFactor ?? 1, o[28] = 0, o[29] = 0, o[30] = 0, o[31] = 0, this.device.queue.writeBuffer(this.physicsUniformBuffer, 0, o);
|
|
1232
1274
|
const l = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }), u = l.beginComputePass({ label: "ParticlePhysicsPass" });
|
|
1233
1275
|
u.setPipeline(this.computePipeline), u.setBindGroup(0, this.computeBindGroup);
|
|
1234
|
-
const
|
|
1235
|
-
u.dispatchWorkgroups(
|
|
1276
|
+
const h = Math.max(1, Math.ceil(e / 64));
|
|
1277
|
+
u.dispatchWorkgroups(h, 1, 1), u.end(), a || this.device.queue.submit([l.finish()]), this.lastUpdateTime = performance.now() / 1e3;
|
|
1236
1278
|
}
|
|
1237
1279
|
async readbackAndProcessParticles(t, e, i, r, n) {
|
|
1238
1280
|
if (t <= 0)
|
|
@@ -1404,7 +1446,7 @@ class Ss {
|
|
|
1404
1446
|
t.enabled !== void 0 && (e.softBoundaryEnabled = t.enabled), t.strength !== void 0 && (e.softBoundaryStrength = t.strength), t.falloff !== void 0 && (e.softBoundaryFalloff = t.falloff);
|
|
1405
1447
|
}
|
|
1406
1448
|
}
|
|
1407
|
-
class
|
|
1449
|
+
class vs {
|
|
1408
1450
|
constructor(t) {
|
|
1409
1451
|
this.device = t, this.defaultTexture = null, this.createDefaultTexture();
|
|
1410
1452
|
}
|
|
@@ -1443,7 +1485,7 @@ class xs {
|
|
|
1443
1485
|
t && t.label !== "defaultParticleTexture" && t.destroy();
|
|
1444
1486
|
}
|
|
1445
1487
|
}
|
|
1446
|
-
const
|
|
1488
|
+
const Si = Object.freeze({
|
|
1447
1489
|
sin: Math.sin,
|
|
1448
1490
|
cos: Math.cos,
|
|
1449
1491
|
abs: Math.abs,
|
|
@@ -1464,7 +1506,7 @@ const bi = Object.freeze({
|
|
|
1464
1506
|
return s + (t - s) * e;
|
|
1465
1507
|
},
|
|
1466
1508
|
smoothstep(s, t, e) {
|
|
1467
|
-
const i =
|
|
1509
|
+
const i = Si.clamp((e - s) / (t - s), 0, 1);
|
|
1468
1510
|
return i * i * (3 - 2 * i);
|
|
1469
1511
|
}
|
|
1470
1512
|
}), Ze = /* @__PURE__ */ new Set([
|
|
@@ -1483,7 +1525,7 @@ const bi = Object.freeze({
|
|
|
1483
1525
|
"pulseFrequency",
|
|
1484
1526
|
"bloomIntensity"
|
|
1485
1527
|
]);
|
|
1486
|
-
class
|
|
1528
|
+
class Ps {
|
|
1487
1529
|
constructor(t) {
|
|
1488
1530
|
this._collection = t, this._pd = null, this._vd = null, this._pi = 0, this._vi = 0;
|
|
1489
1531
|
}
|
|
@@ -1561,9 +1603,9 @@ class vs {
|
|
|
1561
1603
|
this._vd[this._vi + 2] = t, this._collection._dirty = !0;
|
|
1562
1604
|
}
|
|
1563
1605
|
}
|
|
1564
|
-
class
|
|
1606
|
+
class _s {
|
|
1565
1607
|
constructor() {
|
|
1566
|
-
this._proxy = new
|
|
1608
|
+
this._proxy = new Ps(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
|
|
1567
1609
|
}
|
|
1568
1610
|
_bind(t, e, i) {
|
|
1569
1611
|
this._pd = t, this._vd = e, this.count = i, this._dirty = !1;
|
|
@@ -1572,14 +1614,14 @@ class Ps {
|
|
|
1572
1614
|
return t < 0 || t >= this.count ? null : this._proxy._bind(this._pd, this._vd, t);
|
|
1573
1615
|
}
|
|
1574
1616
|
}
|
|
1575
|
-
const
|
|
1617
|
+
const ws = 1e6;
|
|
1576
1618
|
function Bs(s) {
|
|
1577
1619
|
let t = 0;
|
|
1578
1620
|
return s.replace(
|
|
1579
1621
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
1580
1622
|
(e) => {
|
|
1581
1623
|
const i = `__lc${t++}`;
|
|
1582
|
-
return `${e} if(++${i}>${
|
|
1624
|
+
return `${e} if(++${i}>${ws})throw new Error("Loop limit exceeded");`;
|
|
1583
1625
|
}
|
|
1584
1626
|
).replace(
|
|
1585
1627
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
@@ -1599,7 +1641,7 @@ function Bs(s) {
|
|
|
1599
1641
|
const vt = /* @__PURE__ */ new Map();
|
|
1600
1642
|
for (const s of Ze)
|
|
1601
1643
|
vt.set(s.toLowerCase(), s);
|
|
1602
|
-
function
|
|
1644
|
+
function Ms(s) {
|
|
1603
1645
|
const t = { value: !1 }, e = /* @__PURE__ */ new Set();
|
|
1604
1646
|
return new Proxy(s, {
|
|
1605
1647
|
get(r, n) {
|
|
@@ -1627,14 +1669,14 @@ function ws(s) {
|
|
|
1627
1669
|
}
|
|
1628
1670
|
});
|
|
1629
1671
|
}
|
|
1630
|
-
class
|
|
1672
|
+
class ni {
|
|
1631
1673
|
/**
|
|
1632
1674
|
* @param {string} source - User script source code
|
|
1633
1675
|
* @param {object} config - ParticleSystem config (will be proxied)
|
|
1634
1676
|
* @param {number} maxParticles - Max particle count for pre-allocation
|
|
1635
1677
|
*/
|
|
1636
1678
|
constructor(t, e, i) {
|
|
1637
|
-
this._particles = new
|
|
1679
|
+
this._particles = new _s(), this._configProxy = Ms(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
|
|
1638
1680
|
}
|
|
1639
1681
|
/**
|
|
1640
1682
|
* Compile script source into a sandboxed function.
|
|
@@ -1672,7 +1714,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1672
1714
|
if (!this._fn || this._error) return { configDirty: !1, particlesDirty: !1 };
|
|
1673
1715
|
this._particles._bind(n, a, o), this._configProxy.__resetDirty();
|
|
1674
1716
|
try {
|
|
1675
|
-
this._fn(t, e, i, r, this._particles, this._configProxy,
|
|
1717
|
+
this._fn(t, e, i, r, this._particles, this._configProxy, Si);
|
|
1676
1718
|
} catch (c) {
|
|
1677
1719
|
console.warn("[ParticleScript] Runtime error:", c.message);
|
|
1678
1720
|
}
|
|
@@ -1721,12 +1763,12 @@ async function Rs(s) {
|
|
|
1721
1763
|
const r = t.getUint32(8, !0);
|
|
1722
1764
|
let n = 12, a = null, o = null;
|
|
1723
1765
|
for (; n < r; ) {
|
|
1724
|
-
const
|
|
1725
|
-
if (
|
|
1726
|
-
const
|
|
1727
|
-
a = JSON.parse(
|
|
1728
|
-
} else
|
|
1729
|
-
n += 8 +
|
|
1766
|
+
const P = t.getUint32(n, !0), B = t.getUint32(n + 4, !0), M = s.slice(n + 8, n + 8 + P);
|
|
1767
|
+
if (B === 1313821514) {
|
|
1768
|
+
const N = new TextDecoder("utf-8").decode(M);
|
|
1769
|
+
a = JSON.parse(N);
|
|
1770
|
+
} else B === 5130562 && (o = M);
|
|
1771
|
+
n += 8 + P;
|
|
1730
1772
|
}
|
|
1731
1773
|
if (!a)
|
|
1732
1774
|
throw new Error("GLB file missing JSON chunk");
|
|
@@ -1738,44 +1780,44 @@ async function Rs(s) {
|
|
|
1738
1780
|
const u = l.attributes.POSITION;
|
|
1739
1781
|
if (u === void 0)
|
|
1740
1782
|
throw new Error("Mesh primitive missing POSITION attribute");
|
|
1741
|
-
const
|
|
1783
|
+
const h = gt(a, o, u, 3, 5126);
|
|
1742
1784
|
let p;
|
|
1743
1785
|
if (l.attributes.NORMAL !== void 0)
|
|
1744
1786
|
p = gt(a, o, l.attributes.NORMAL, 3, 5126);
|
|
1745
1787
|
else {
|
|
1746
|
-
const
|
|
1747
|
-
if (
|
|
1788
|
+
const P = l.indices;
|
|
1789
|
+
if (P === void 0)
|
|
1748
1790
|
throw new Error("Cannot generate normals without indices");
|
|
1749
|
-
const
|
|
1750
|
-
p =
|
|
1791
|
+
const B = ai(a, o, P);
|
|
1792
|
+
p = Ts(h, B);
|
|
1751
1793
|
}
|
|
1752
1794
|
const d = l.indices;
|
|
1753
1795
|
if (d === void 0)
|
|
1754
1796
|
throw new Error("Mesh primitive missing indices");
|
|
1755
|
-
const
|
|
1756
|
-
let
|
|
1757
|
-
l.attributes.TEXCOORD_0 !== void 0 && (
|
|
1758
|
-
let
|
|
1797
|
+
const S = ai(a, o, d), R = h.length / 3, E = S.length;
|
|
1798
|
+
let T = null;
|
|
1799
|
+
l.attributes.TEXCOORD_0 !== void 0 && (T = gt(a, o, l.attributes.TEXCOORD_0, 2, 5126));
|
|
1800
|
+
let x = !1;
|
|
1759
1801
|
if (a.materials && a.materials.length > 0) {
|
|
1760
|
-
const
|
|
1761
|
-
|
|
1802
|
+
const P = a.materials[0];
|
|
1803
|
+
P.pbrMetallicRoughness && P.pbrMetallicRoughness.baseColorTexture !== void 0 && (x = !0);
|
|
1762
1804
|
}
|
|
1763
1805
|
let L = null;
|
|
1764
1806
|
if (a.skins && a.skins.length > 0)
|
|
1765
1807
|
try {
|
|
1766
|
-
L =
|
|
1767
|
-
} catch (
|
|
1768
|
-
console.warn("Failed to extract animation data:",
|
|
1808
|
+
L = zs(a, o, l), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", L);
|
|
1809
|
+
} catch (P) {
|
|
1810
|
+
console.warn("Failed to extract animation data:", P);
|
|
1769
1811
|
}
|
|
1770
1812
|
return {
|
|
1771
|
-
positions:
|
|
1813
|
+
positions: h,
|
|
1772
1814
|
normals: p,
|
|
1773
|
-
indices:
|
|
1774
|
-
texCoords:
|
|
1775
|
-
vertexCount:
|
|
1776
|
-
indexCount:
|
|
1815
|
+
indices: S,
|
|
1816
|
+
texCoords: T,
|
|
1817
|
+
vertexCount: R,
|
|
1818
|
+
indexCount: E,
|
|
1777
1819
|
animationData: L,
|
|
1778
|
-
hasBaseColorTexture:
|
|
1820
|
+
hasBaseColorTexture: x
|
|
1779
1821
|
};
|
|
1780
1822
|
}
|
|
1781
1823
|
function gt(s, t, e, i, r) {
|
|
@@ -1789,12 +1831,12 @@ function gt(s, t, e, i, r) {
|
|
|
1789
1831
|
throw new Error(`Attribute accessor type mismatch: expected ${i} components, got ${o}`);
|
|
1790
1832
|
if (n.componentType !== r)
|
|
1791
1833
|
throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
|
|
1792
|
-
const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), u = n.count,
|
|
1834
|
+
const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), u = n.count, h = new DataView(t, l, u * i * 4), p = new Float32Array(u * i);
|
|
1793
1835
|
for (let d = 0; d < u * i; d++)
|
|
1794
|
-
p[d] =
|
|
1836
|
+
p[d] = h.getFloat32(d * 4, !0);
|
|
1795
1837
|
return p;
|
|
1796
1838
|
}
|
|
1797
|
-
function
|
|
1839
|
+
function ai(s, t, e) {
|
|
1798
1840
|
const i = s.accessors[e];
|
|
1799
1841
|
if (i.type !== "SCALAR")
|
|
1800
1842
|
throw new Error(`Indices accessor must be SCALAR, got ${i.type}`);
|
|
@@ -1812,19 +1854,19 @@ function ni(s, t, e) {
|
|
|
1812
1854
|
} else
|
|
1813
1855
|
throw new Error(`Unsupported index component type: ${i.componentType}`);
|
|
1814
1856
|
}
|
|
1815
|
-
function
|
|
1857
|
+
function Ts(s, t) {
|
|
1816
1858
|
const e = new Float32Array(s.length);
|
|
1817
1859
|
for (let i = 0; i < t.length; i += 3) {
|
|
1818
|
-
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]],
|
|
1819
|
-
u[1] *
|
|
1820
|
-
u[2] *
|
|
1821
|
-
u[0] *
|
|
1860
|
+
const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], c = [s[n], s[n + 1], s[n + 2]], l = [s[a], s[a + 1], s[a + 2]], u = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], h = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], p = [
|
|
1861
|
+
u[1] * h[2] - u[2] * h[1],
|
|
1862
|
+
u[2] * h[0] - u[0] * h[2],
|
|
1863
|
+
u[0] * h[1] - u[1] * h[0]
|
|
1822
1864
|
], d = Math.sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]);
|
|
1823
1865
|
d > 0 && (p[0] /= d, p[1] /= d, p[2] /= d), e[r] = e[n] = e[a] = p[0], e[r + 1] = e[n + 1] = e[a + 1] = p[1], e[r + 2] = e[n + 2] = e[a + 2] = p[2];
|
|
1824
1866
|
}
|
|
1825
1867
|
return e;
|
|
1826
1868
|
}
|
|
1827
|
-
function
|
|
1869
|
+
function Es(s, t, e) {
|
|
1828
1870
|
const i = s.accessors[e];
|
|
1829
1871
|
if (i.type !== "VEC4")
|
|
1830
1872
|
throw new Error(`JOINTS_0 must be VEC4, got ${i.type}`);
|
|
@@ -1842,7 +1884,7 @@ function Ts(s, t, e) {
|
|
|
1842
1884
|
} else
|
|
1843
1885
|
throw new Error(`Unsupported JOINTS_0 component type: ${i.componentType}`);
|
|
1844
1886
|
}
|
|
1845
|
-
function
|
|
1887
|
+
function Cs(s, t, e) {
|
|
1846
1888
|
const i = s.accessors[e];
|
|
1847
1889
|
if (i.type !== "VEC4")
|
|
1848
1890
|
throw new Error(`WEIGHTS_0 must be VEC4, got ${i.type}`);
|
|
@@ -1860,7 +1902,7 @@ function Es(s, t, e) {
|
|
|
1860
1902
|
} else
|
|
1861
1903
|
throw new Error(`Unsupported WEIGHTS_0 component type: ${i.componentType}`);
|
|
1862
1904
|
}
|
|
1863
|
-
function
|
|
1905
|
+
function As(s, t, e) {
|
|
1864
1906
|
const i = s.accessors[e];
|
|
1865
1907
|
if (i.type !== "MAT4")
|
|
1866
1908
|
throw new Error(`Expected MAT4, got ${i.type}`);
|
|
@@ -1871,7 +1913,7 @@ function Cs(s, t, e) {
|
|
|
1871
1913
|
c[l] = o.getFloat32(l * 4, !0);
|
|
1872
1914
|
return c;
|
|
1873
1915
|
}
|
|
1874
|
-
function
|
|
1916
|
+
function Us(s, t, e) {
|
|
1875
1917
|
const i = s.accessors[e];
|
|
1876
1918
|
if (i.type !== "SCALAR")
|
|
1877
1919
|
throw new Error(`Expected SCALAR, got ${i.type}`);
|
|
@@ -1882,19 +1924,19 @@ function As(s, t, e) {
|
|
|
1882
1924
|
c[l] = o.getFloat32(l * 4, !0);
|
|
1883
1925
|
return c;
|
|
1884
1926
|
}
|
|
1885
|
-
function
|
|
1927
|
+
function Is(s, t, e) {
|
|
1886
1928
|
const i = s.accessors[e], n = { VEC3: 3, VEC4: 4 }[i.type];
|
|
1887
1929
|
if (!n)
|
|
1888
1930
|
throw new Error(`Expected VEC3 or VEC4, got ${i.type}`);
|
|
1889
1931
|
if (i.componentType !== 5126)
|
|
1890
1932
|
throw new Error(`Expected FLOAT component type, got ${i.componentType}`);
|
|
1891
1933
|
const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), c = i.count, l = new DataView(t, o, c * n * 4), u = new Float32Array(c * n);
|
|
1892
|
-
for (let
|
|
1893
|
-
u[
|
|
1934
|
+
for (let h = 0; h < c * n; h++)
|
|
1935
|
+
u[h] = l.getFloat32(h * 4, !0);
|
|
1894
1936
|
return u;
|
|
1895
1937
|
}
|
|
1896
|
-
function
|
|
1897
|
-
const i = s.skins[0], r = i.joints, n =
|
|
1938
|
+
function zs(s, t, e) {
|
|
1939
|
+
const i = s.skins[0], r = i.joints, n = As(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? Es(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? Cs(s, t, e.attributes.WEIGHTS_0) : null;
|
|
1898
1940
|
if (!a || !o)
|
|
1899
1941
|
throw new Error("Mesh missing JOINTS_0 or WEIGHTS_0 attributes");
|
|
1900
1942
|
const c = s.nodes.map((u) => ({
|
|
@@ -1906,22 +1948,22 @@ function Is(s, t, e) {
|
|
|
1906
1948
|
})), l = [];
|
|
1907
1949
|
if (s.animations && s.animations.length > 0)
|
|
1908
1950
|
for (const u of s.animations) {
|
|
1909
|
-
const
|
|
1951
|
+
const h = [];
|
|
1910
1952
|
let p = 0;
|
|
1911
1953
|
for (const d of u.channels) {
|
|
1912
|
-
const
|
|
1913
|
-
|
|
1954
|
+
const S = u.samplers[d.sampler], R = Us(s, t, S.input), E = Is(s, t, S.output), T = R[R.length - 1];
|
|
1955
|
+
T > p && (p = T), h.push({
|
|
1914
1956
|
targetNode: d.target.node,
|
|
1915
1957
|
targetPath: d.target.path,
|
|
1916
|
-
interpolation:
|
|
1917
|
-
timestamps:
|
|
1918
|
-
values:
|
|
1958
|
+
interpolation: S.interpolation || "LINEAR",
|
|
1959
|
+
timestamps: R,
|
|
1960
|
+
values: E
|
|
1919
1961
|
});
|
|
1920
1962
|
}
|
|
1921
1963
|
l.push({
|
|
1922
1964
|
name: u.name || `Animation ${l.length}`,
|
|
1923
1965
|
duration: p,
|
|
1924
|
-
channels:
|
|
1966
|
+
channels: h
|
|
1925
1967
|
});
|
|
1926
1968
|
}
|
|
1927
1969
|
return {
|
|
@@ -1933,7 +1975,7 @@ function Is(s, t, e) {
|
|
|
1933
1975
|
animations: l
|
|
1934
1976
|
};
|
|
1935
1977
|
}
|
|
1936
|
-
async function
|
|
1978
|
+
async function oi(s) {
|
|
1937
1979
|
const t = new DataView(s);
|
|
1938
1980
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
1939
1981
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -1943,11 +1985,11 @@ async function ai(s) {
|
|
|
1943
1985
|
const r = t.getUint32(8, !0);
|
|
1944
1986
|
let n = 12, a = null, o = null;
|
|
1945
1987
|
for (; n < r; ) {
|
|
1946
|
-
const L = t.getUint32(n, !0),
|
|
1947
|
-
if (
|
|
1948
|
-
const
|
|
1949
|
-
a = JSON.parse(
|
|
1950
|
-
} else
|
|
1988
|
+
const L = t.getUint32(n, !0), P = t.getUint32(n + 4, !0), B = s.slice(n + 8, n + 8 + L);
|
|
1989
|
+
if (P === 1313821514) {
|
|
1990
|
+
const F = new TextDecoder("utf-8").decode(B);
|
|
1991
|
+
a = JSON.parse(F);
|
|
1992
|
+
} else P === 5130562 && (o = B);
|
|
1951
1993
|
n += 8 + L;
|
|
1952
1994
|
}
|
|
1953
1995
|
if (!a)
|
|
@@ -1960,25 +2002,25 @@ async function ai(s) {
|
|
|
1960
2002
|
const l = c.pbrMetallicRoughness.baseColorTexture.index;
|
|
1961
2003
|
if (!a.textures || !a.textures[l])
|
|
1962
2004
|
return null;
|
|
1963
|
-
const
|
|
1964
|
-
if (
|
|
2005
|
+
const h = a.textures[l].source;
|
|
2006
|
+
if (h === void 0 || !a.images || !a.images[h])
|
|
1965
2007
|
return null;
|
|
1966
|
-
const p = a.images[
|
|
2008
|
+
const p = a.images[h], d = p.mimeType || "image/png";
|
|
1967
2009
|
if (p.bufferView === void 0)
|
|
1968
2010
|
return null;
|
|
1969
2011
|
if (!o)
|
|
1970
2012
|
throw new Error("GLB file missing BIN chunk (required for embedded textures)");
|
|
1971
|
-
const
|
|
1972
|
-
return { imageBlob: new Blob([
|
|
2013
|
+
const S = a.bufferViews[p.bufferView], R = S.byteOffset || 0, E = S.byteLength, T = o.slice(R, R + E);
|
|
2014
|
+
return { imageBlob: new Blob([T], { type: d }), mimeType: d };
|
|
1973
2015
|
}
|
|
1974
|
-
function
|
|
2016
|
+
function li(s, t, e) {
|
|
1975
2017
|
return [
|
|
1976
2018
|
s[0] + (t[0] - s[0]) * e,
|
|
1977
2019
|
s[1] + (t[1] - s[1]) * e,
|
|
1978
2020
|
s[2] + (t[2] - s[2]) * e
|
|
1979
2021
|
];
|
|
1980
2022
|
}
|
|
1981
|
-
function
|
|
2023
|
+
function ci(s, t, e) {
|
|
1982
2024
|
let i = s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3], r = t;
|
|
1983
2025
|
if (i < 0 && (i = -i, r = [-t[0], -t[1], -t[2], -t[3]]), i > 0.9995) {
|
|
1984
2026
|
const l = [
|
|
@@ -2001,63 +2043,35 @@ function Gs(s) {
|
|
|
2001
2043
|
const t = Math.sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2] + s[3] * s[3]);
|
|
2002
2044
|
return t > 1e-4 ? [s[0] / t, s[1] / t, s[2] / t, s[3] / t] : [0, 0, 0, 1];
|
|
2003
2045
|
}
|
|
2004
|
-
function Ds(s) {
|
|
2005
|
-
const
|
|
2006
|
-
return
|
|
2007
|
-
1 - (m + d),
|
|
2008
|
-
l + T,
|
|
2009
|
-
u - M,
|
|
2010
|
-
0,
|
|
2011
|
-
l - T,
|
|
2012
|
-
1 - (c + d),
|
|
2013
|
-
p + b,
|
|
2014
|
-
0,
|
|
2015
|
-
u + M,
|
|
2016
|
-
p - b,
|
|
2017
|
-
1 - (c + m),
|
|
2018
|
-
0,
|
|
2019
|
-
0,
|
|
2020
|
-
0,
|
|
2021
|
-
0,
|
|
2022
|
-
1
|
|
2023
|
-
]);
|
|
2046
|
+
function Ds(s, t) {
|
|
2047
|
+
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, c = r + r, l = e * a, u = e * o, h = e * c, p = i * o, d = i * c, S = r * c, R = n * a, E = n * o, T = n * c, x = t || new Float32Array(16);
|
|
2048
|
+
return x[0] = 1 - (p + S), x[1] = u + T, x[2] = h - E, x[3] = 0, x[4] = u - T, x[5] = 1 - (l + S), x[6] = d + R, x[7] = 0, x[8] = h + E, x[9] = d - R, x[10] = 1 - (l + p), x[11] = 0, x[12] = 0, x[13] = 0, x[14] = 0, x[15] = 1, x;
|
|
2024
2049
|
}
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
i[1] * e[0],
|
|
2030
|
-
i[2] * e[0],
|
|
2031
|
-
0,
|
|
2032
|
-
i[4] * e[1],
|
|
2033
|
-
i[5] * e[1],
|
|
2034
|
-
i[6] * e[1],
|
|
2035
|
-
0,
|
|
2036
|
-
i[8] * e[2],
|
|
2037
|
-
i[9] * e[2],
|
|
2038
|
-
i[10] * e[2],
|
|
2039
|
-
0,
|
|
2040
|
-
s[0],
|
|
2041
|
-
s[1],
|
|
2042
|
-
s[2],
|
|
2043
|
-
1
|
|
2044
|
-
]);
|
|
2050
|
+
const Fs = new Float32Array(16);
|
|
2051
|
+
function Vs(s, t, e, i) {
|
|
2052
|
+
const r = Ds(t, Fs), n = i || new Float32Array(16);
|
|
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;
|
|
2045
2054
|
}
|
|
2046
|
-
function
|
|
2047
|
-
const
|
|
2048
|
-
for (let
|
|
2049
|
-
for (let
|
|
2050
|
-
|
|
2051
|
-
return
|
|
2055
|
+
function ui(s, t, e) {
|
|
2056
|
+
const i = e || new Float32Array(16);
|
|
2057
|
+
for (let r = 0; r < 4; r++)
|
|
2058
|
+
for (let n = 0; n < 4; n++)
|
|
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];
|
|
2060
|
+
return i;
|
|
2052
2061
|
}
|
|
2053
|
-
class
|
|
2062
|
+
class Os {
|
|
2054
2063
|
constructor(t) {
|
|
2055
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);
|
|
2056
2065
|
for (let e = 0; e < this.nodes.length; e++)
|
|
2057
2066
|
this.jointLocalTransforms[e] = new Float32Array(16), this.jointGlobalTransforms[e] = new Float32Array(16);
|
|
2058
2067
|
for (let e = 0; e < this.joints.length; e++)
|
|
2059
2068
|
this.jointFinalMatrices[e] = new Float32Array(16);
|
|
2060
|
-
this.skinnedPositions = null, this.skinnedNormals = null, this._gpuSkinningReady = !1, this._buildTopologicalOrder(),
|
|
2069
|
+
this.skinnedPositions = null, this.skinnedNormals = null, this._gpuSkinningReady = !1, this._buildTopologicalOrder(), this._parentMap = new Array(this.nodes.length).fill(-1);
|
|
2070
|
+
for (let e = 0; e < this.nodes.length; e++)
|
|
2071
|
+
for (const i of this.nodes[e].children) this._parentMap[i] = e;
|
|
2072
|
+
this._invBindViews = new Array(this.joints.length);
|
|
2073
|
+
for (let e = 0; e < this.joints.length; e++)
|
|
2074
|
+
this._invBindViews[e] = this.inverseBindMatrices.subarray(e * 16, e * 16 + 16);
|
|
2061
2075
|
}
|
|
2062
2076
|
/**
|
|
2063
2077
|
* Set the rest pose (original vertex data).
|
|
@@ -2076,8 +2090,8 @@ class Vs {
|
|
|
2076
2090
|
this._gpuDevice = t, this._gpuOutputBuffer = e;
|
|
2077
2091
|
const r = this.restPositions.length / 3, n = new Float32Array(r * 8);
|
|
2078
2092
|
for (let c = 0; c < r; c++) {
|
|
2079
|
-
const l = c * 8, u = c * 3,
|
|
2080
|
-
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, h = c * 2;
|
|
2094
|
+
n[l] = this.restPositions[u], n[l + 1] = this.restPositions[u + 1], n[l + 2] = this.restPositions[u + 2], n[l + 3] = this.restNormals[u], n[l + 4] = this.restNormals[u + 1], n[l + 5] = this.restNormals[u + 2], n[l + 6] = i ? i[h] : 0, n[l + 7] = i ? i[h + 1] : 0;
|
|
2081
2095
|
}
|
|
2082
2096
|
this._gpuRestDataBuffer = t.createBuffer({
|
|
2083
2097
|
size: n.byteLength,
|
|
@@ -2112,7 +2126,7 @@ class Vs {
|
|
|
2112
2126
|
this._gpuSkinningPipeline = t.createComputePipeline({
|
|
2113
2127
|
layout: t.createPipelineLayout({ bindGroupLayouts: [o] }),
|
|
2114
2128
|
compute: {
|
|
2115
|
-
module: t.createShaderModule({ code:
|
|
2129
|
+
module: t.createShaderModule({ code: Ss }),
|
|
2116
2130
|
entryPoint: "main"
|
|
2117
2131
|
}
|
|
2118
2132
|
}), this._gpuSkinningBindGroup = t.createBindGroup({
|
|
@@ -2124,7 +2138,7 @@ class Vs {
|
|
|
2124
2138
|
{ binding: 3, resource: { buffer: this._gpuJointMatricesBuffer } },
|
|
2125
2139
|
{ binding: 4, resource: { buffer: this._gpuOutputBuffer } }
|
|
2126
2140
|
]
|
|
2127
|
-
}), this._gpuVertexCount = r, this._gpuSkinningReady = !0, console.log(`GPU skinning initialized: ${r} vertices, ${this.joints.length} joints`);
|
|
2141
|
+
}), this._gpuVertexCount = r, this._gpuSkinningReady = !0, globalThis.__HZFX_DEBUG && console.log(`GPU skinning initialized: ${r} vertices, ${this.joints.length} joints`);
|
|
2128
2142
|
} catch (r) {
|
|
2129
2143
|
console.warn("GPU skinning init failed, using CPU fallback:", r), this._gpuSkinningReady = !1;
|
|
2130
2144
|
}
|
|
@@ -2202,11 +2216,11 @@ class Vs {
|
|
|
2202
2216
|
return this._extractValue(r, i.length - 1, a);
|
|
2203
2217
|
let o = 0, c = i.length - 1;
|
|
2204
2218
|
for (; c - o > 1; ) {
|
|
2205
|
-
const
|
|
2206
|
-
i[
|
|
2219
|
+
const S = Math.floor((o + c) / 2);
|
|
2220
|
+
i[S] <= e ? o = S : c = S;
|
|
2207
2221
|
}
|
|
2208
|
-
const l = i[o], u = i[c],
|
|
2209
|
-
return n === "STEP" ? p : a === "rotation" ?
|
|
2222
|
+
const l = i[o], u = i[c], h = (e - l) / (u - l), p = this._extractValue(r, o, a), d = this._extractValue(r, c, a);
|
|
2223
|
+
return n === "STEP" ? p : a === "rotation" ? ci(p, d, h) : li(p, d, h);
|
|
2210
2224
|
}
|
|
2211
2225
|
/**
|
|
2212
2226
|
* Extract value from values array at the given index.
|
|
@@ -2233,24 +2247,20 @@ class Vs {
|
|
|
2233
2247
|
const l = this._sampleChannel(c, t);
|
|
2234
2248
|
c.targetPath === "translation" ? n = l : c.targetPath === "rotation" ? a = l : c.targetPath === "scale" && (o = l);
|
|
2235
2249
|
}
|
|
2236
|
-
|
|
2250
|
+
Vs(n, a, o, this.jointLocalTransforms[i]);
|
|
2237
2251
|
}
|
|
2238
2252
|
}
|
|
2239
2253
|
/**
|
|
2240
2254
|
* Compute global transforms by propagating parent transforms.
|
|
2241
2255
|
*/
|
|
2242
2256
|
_computeGlobalTransforms() {
|
|
2243
|
-
const t =
|
|
2244
|
-
for (let e = 0; e < this.nodes.length; e++) {
|
|
2245
|
-
const i = this.nodes[e];
|
|
2246
|
-
for (const r of i.children)
|
|
2247
|
-
t[r] = e;
|
|
2248
|
-
}
|
|
2257
|
+
const t = this._parentMap;
|
|
2249
2258
|
for (const e of this.topologicalOrder) {
|
|
2250
2259
|
const i = t[e];
|
|
2251
|
-
i === -1 ? this.jointGlobalTransforms[e]
|
|
2260
|
+
i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) : ui(
|
|
2252
2261
|
this.jointGlobalTransforms[i],
|
|
2253
|
-
this.jointLocalTransforms[e]
|
|
2262
|
+
this.jointLocalTransforms[e],
|
|
2263
|
+
this.jointGlobalTransforms[e]
|
|
2254
2264
|
);
|
|
2255
2265
|
}
|
|
2256
2266
|
}
|
|
@@ -2259,8 +2269,8 @@ class Vs {
|
|
|
2259
2269
|
*/
|
|
2260
2270
|
_computeFinalMatrices() {
|
|
2261
2271
|
for (let t = 0; t < this.joints.length; t++) {
|
|
2262
|
-
const e = this.joints[t], i = this.jointGlobalTransforms[e]
|
|
2263
|
-
this.
|
|
2272
|
+
const e = this.joints[t], i = this.jointGlobalTransforms[e];
|
|
2273
|
+
ui(i, this._invBindViews[t], this.jointFinalMatrices[t]);
|
|
2264
2274
|
}
|
|
2265
2275
|
}
|
|
2266
2276
|
/**
|
|
@@ -2270,20 +2280,20 @@ class Vs {
|
|
|
2270
2280
|
_applySkinning() {
|
|
2271
2281
|
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;
|
|
2272
2282
|
for (let l = 0; l < t; l++) {
|
|
2273
|
-
const u = l * 3,
|
|
2274
|
-
let
|
|
2275
|
-
for (let
|
|
2276
|
-
const k = a[
|
|
2283
|
+
const u = l * 3, h = l * 4, p = e[u], d = e[u + 1], S = e[u + 2], R = i[u], E = i[u + 1], T = i[u + 2];
|
|
2284
|
+
let x = 0, L = 0, P = 0, B = 0, M = 0, F = 0;
|
|
2285
|
+
for (let Y = 0; Y < 4; Y++) {
|
|
2286
|
+
const k = a[h + Y];
|
|
2277
2287
|
if (k === 0) continue;
|
|
2278
|
-
const
|
|
2279
|
-
|
|
2288
|
+
const G = c[o[h + Y]];
|
|
2289
|
+
x += (G[0] * p + G[4] * d + G[8] * S + G[12]) * k, L += (G[1] * p + G[5] * d + G[9] * S + G[13]) * k, P += (G[2] * p + G[6] * d + G[10] * S + G[14]) * k, B += (G[0] * R + G[4] * E + G[8] * T) * k, M += (G[1] * R + G[5] * E + G[9] * T) * k, F += (G[2] * R + G[6] * E + G[10] * T) * k;
|
|
2280
2290
|
}
|
|
2281
|
-
const
|
|
2282
|
-
|
|
2291
|
+
const N = Math.sqrt(B * B + M * M + F * F);
|
|
2292
|
+
N > 1e-4 && (n[u] = B / N, n[u + 1] = M / N, n[u + 2] = F / N), r[u] = x, r[u + 1] = L, r[u + 2] = P;
|
|
2283
2293
|
}
|
|
2284
2294
|
}
|
|
2285
2295
|
}
|
|
2286
|
-
class
|
|
2296
|
+
class Ls {
|
|
2287
2297
|
constructor({ duration: t = 0, loop: e = !1, playbackRate: i = 1 } = {}) {
|
|
2288
2298
|
this.currentTime = 0, this.duration = t, this.loop = e, this.playbackRate = i, this.paused = !1, this._justLooped = !1;
|
|
2289
2299
|
}
|
|
@@ -2304,7 +2314,7 @@ class Fs {
|
|
|
2304
2314
|
this.currentTime = Math.max(0, t || 0), this._justLooped = !1;
|
|
2305
2315
|
}
|
|
2306
2316
|
}
|
|
2307
|
-
const
|
|
2317
|
+
const di = {
|
|
2308
2318
|
linear: (s) => s,
|
|
2309
2319
|
easeInQuad: (s) => s * s,
|
|
2310
2320
|
easeOutQuad: (s) => 1 - (1 - s) * (1 - s),
|
|
@@ -2323,26 +2333,26 @@ const ui = {
|
|
|
2323
2333
|
return Math.pow(2, -10 * s) * Math.sin((s * 10 - 0.75) * t) + 1;
|
|
2324
2334
|
}
|
|
2325
2335
|
};
|
|
2326
|
-
function
|
|
2327
|
-
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,
|
|
2336
|
+
function Xs(s, t, e, i) {
|
|
2337
|
+
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, c = 3 * (i - t) - o, l = 1 - o - c, u = (d) => ((a * d + n) * d + r) * d, h = (d) => ((l * d + c) * d + o) * d, p = (d) => (3 * a * d + 2 * n) * d + r;
|
|
2328
2338
|
return (d) => {
|
|
2329
2339
|
if (d <= 0) return 0;
|
|
2330
2340
|
if (d >= 1) return 1;
|
|
2331
|
-
let
|
|
2332
|
-
for (let
|
|
2333
|
-
const
|
|
2334
|
-
if (Math.abs(
|
|
2335
|
-
const
|
|
2336
|
-
if (Math.abs(
|
|
2337
|
-
|
|
2341
|
+
let S = d;
|
|
2342
|
+
for (let R = 0; R < 8; R++) {
|
|
2343
|
+
const E = u(S) - d;
|
|
2344
|
+
if (Math.abs(E) < 1e-5) break;
|
|
2345
|
+
const T = p(S);
|
|
2346
|
+
if (Math.abs(T) < 1e-6) break;
|
|
2347
|
+
S -= E / T;
|
|
2338
2348
|
}
|
|
2339
|
-
return
|
|
2349
|
+
return h(S);
|
|
2340
2350
|
};
|
|
2341
2351
|
}
|
|
2342
|
-
function
|
|
2343
|
-
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ?
|
|
2352
|
+
function xi(s, t) {
|
|
2353
|
+
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? Xs(s[0], s[1], s[2], s[3])(t) : (di[s] || di.linear)(t);
|
|
2344
2354
|
}
|
|
2345
|
-
function
|
|
2355
|
+
function Ns(s, t) {
|
|
2346
2356
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2347
2357
|
if (s.length === 1 || t <= s[0].t) return s[0].v;
|
|
2348
2358
|
const e = s[s.length - 1];
|
|
@@ -2351,12 +2361,12 @@ function Ls(s, t) {
|
|
|
2351
2361
|
const r = s[i], n = s[i + 1];
|
|
2352
2362
|
if (t >= r.t && t <= n.t) {
|
|
2353
2363
|
const a = n.t - r.t, o = a > 0 ? (t - r.t) / a : 0;
|
|
2354
|
-
return r.v + (n.v - r.v) *
|
|
2364
|
+
return r.v + (n.v - r.v) * xi(r.ease, o);
|
|
2355
2365
|
}
|
|
2356
2366
|
}
|
|
2357
2367
|
return e.v;
|
|
2358
2368
|
}
|
|
2359
|
-
function
|
|
2369
|
+
function ks(s, t) {
|
|
2360
2370
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2361
2371
|
const e = (r, n, a) => [r[0] + (n[0] - r[0]) * a, r[1] + (n[1] - r[1]) * a, r[2] + (n[2] - r[2]) * a];
|
|
2362
2372
|
if (s.length === 1 || t <= s[0].t) return s[0].v.slice();
|
|
@@ -2366,13 +2376,13 @@ function Ns(s, t) {
|
|
|
2366
2376
|
const n = s[r], a = s[r + 1];
|
|
2367
2377
|
if (t >= n.t && t <= a.t) {
|
|
2368
2378
|
const o = a.t - n.t, c = o > 0 ? (t - n.t) / o : 0;
|
|
2369
|
-
return e(n.v, a.v,
|
|
2379
|
+
return e(n.v, a.v, xi(n.ease, c));
|
|
2370
2380
|
}
|
|
2371
2381
|
}
|
|
2372
2382
|
return i.v.slice();
|
|
2373
2383
|
}
|
|
2374
|
-
const
|
|
2375
|
-
function
|
|
2384
|
+
const js = ["gravityStrength", "emissionRate", "damping", "particleSize", "particleSpeed"], Ys = { square: 0, circle: 1, triangle: 2, diamond: 3, star: 4, hexagon: 5, ring: 6, heart: 7, cross: 8, spark: 9, leaf: 10, capsule: 11, crescent: 12, line: 13, "curved-line": 14 };
|
|
2385
|
+
function fi(s) {
|
|
2376
2386
|
const t = atob(s), e = new Uint8Array(t.length);
|
|
2377
2387
|
for (let i = 0; i < t.length; i++)
|
|
2378
2388
|
e[i] = t.charCodeAt(i);
|
|
@@ -2395,8 +2405,8 @@ class bt {
|
|
|
2395
2405
|
usage: GPUBufferUsage.STORAGE | GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC,
|
|
2396
2406
|
label: "particleTrailBuffer"
|
|
2397
2407
|
}), this._trailResetData = new Float32Array(this.MAX_PARTICLES * 4), this.appearanceUniformBuffer = t.createBuffer({
|
|
2398
|
-
size:
|
|
2399
|
-
// appearance uniforms + pulse + GLB rotation + system offset + sim rotation + noise distortion
|
|
2408
|
+
size: 224,
|
|
2409
|
+
// appearance uniforms + pulse + GLB rotation + system offset + sim rotation + noise distortion + orient3d
|
|
2400
2410
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
2401
2411
|
label: "appearanceUniformBuffer"
|
|
2402
2412
|
}), this.bloomIntensityBuffer = t.createBuffer({
|
|
@@ -2404,7 +2414,7 @@ class bt {
|
|
|
2404
2414
|
// intensity (f32) + padding
|
|
2405
2415
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
2406
2416
|
label: "systemBloomIntensityBuffer"
|
|
2407
|
-
}), 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.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(52), 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 ds(e), this.physics = new Ss(t, this.MAX_PARTICLES), this.textureManager = new xs(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({
|
|
2417
|
+
}), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new fs(e), this.physics = new xs(t, this.MAX_PARTICLES), this.textureManager = new vs(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition), e.confinementEnabled && this.setConfinement({
|
|
2408
2418
|
enabled: !0,
|
|
2409
2419
|
shape: e.confinementShape,
|
|
2410
2420
|
mode: e.confinementMode,
|
|
@@ -2417,7 +2427,7 @@ class bt {
|
|
|
2417
2427
|
enabled: !0,
|
|
2418
2428
|
strength: e.softBoundaryStrength,
|
|
2419
2429
|
falloff: e.softBoundaryFalloff
|
|
2420
|
-
}), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new
|
|
2430
|
+
}), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new ni(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
|
|
2421
2431
|
}
|
|
2422
2432
|
async initComputePipeline(t) {
|
|
2423
2433
|
this.computeReady = await this.physics.initComputePipeline(this.instanceBuffer, this.velocityBuffer, this.trailBuffer);
|
|
@@ -2427,7 +2437,7 @@ class bt {
|
|
|
2427
2437
|
* @param {string|null} source - Script source code, or null to disable
|
|
2428
2438
|
*/
|
|
2429
2439
|
setScript(t) {
|
|
2430
|
-
this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new
|
|
2440
|
+
this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new ni(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
|
|
2431
2441
|
}
|
|
2432
2442
|
async setTexture(t) {
|
|
2433
2443
|
this.destroyed || (this.textureManager.destroyTexture(this.particleTexture), this.particleTexture = await this.textureManager.loadTexture(t), this.config.textureEnabled = !0, this.updateAppearanceUniform(), this.updateBuffers());
|
|
@@ -2454,16 +2464,16 @@ class bt {
|
|
|
2454
2464
|
usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
|
|
2455
2465
|
label: "glbIndexBuffer"
|
|
2456
2466
|
}), 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) {
|
|
2457
|
-
this.glbAnimator = new
|
|
2467
|
+
this.glbAnimator = new Os(e.animationData), this.glbAnimator.setRestPose(e.positions, e.normals), this.glbAnimated = !0, this.config.glbAnimated = !0, this.glbAnimator.loop = this.config.animationLoop, this._glbInterleavedData = new Float32Array(e.vertexCount * 8);
|
|
2458
2468
|
try {
|
|
2459
2469
|
await this.glbAnimator.initGPUSkinning(this.device, this.glbVertexBuffer, e.texCoords);
|
|
2460
2470
|
} catch (r) {
|
|
2461
2471
|
console.warn("GPU skinning init failed, using CPU fallback:", r);
|
|
2462
2472
|
}
|
|
2463
|
-
console.log(`GLB animated model loaded: ${e.animationData.animations.length} animations`);
|
|
2473
|
+
globalThis.__HZFX_DEBUG && console.log(`GLB animated model loaded: ${e.animationData.animations.length} animations`);
|
|
2464
2474
|
} else
|
|
2465
2475
|
this.glbAnimator = null, this.glbAnimated = !1, this.config.glbAnimated = !1, this._glbInterleavedData = null;
|
|
2466
|
-
console.log(`GLB model loaded: ${e.vertexCount} vertices, ${e.indexCount} indices`);
|
|
2476
|
+
globalThis.__HZFX_DEBUG && console.log(`GLB model loaded: ${e.vertexCount} vertices, ${e.indexCount} indices`);
|
|
2467
2477
|
} catch (e) {
|
|
2468
2478
|
throw console.error("Failed to load GLB model:", e), e;
|
|
2469
2479
|
}
|
|
@@ -2515,11 +2525,11 @@ class bt {
|
|
|
2515
2525
|
updateAppearanceUniform() {
|
|
2516
2526
|
if (this.destroyed) return;
|
|
2517
2527
|
let t = 0;
|
|
2518
|
-
this.config.rotationMode === "random" ? t = 1 : this.config.rotationMode === "velocity" && (t =
|
|
2519
|
-
const e =
|
|
2528
|
+
this.config.rotationMode === "random" ? t = 1 : this.config.rotationMode === "velocity" ? t = 2 : this.config.rotationMode === "oriented" ? t = 3 : this.config.rotationMode === "cylindrical" && (t = 4);
|
|
2529
|
+
const e = Ys[this.config.particleShape] ?? 0, i = this._appearanceData;
|
|
2520
2530
|
i[0] = this.config.fadeEnabled ? 1 : 0, i[1] = this.config.randomColorEnabled ? 2 : this.config.colorTransitionEnabled ? 1 : 0, i[2] = this.config.particleSize, i[3] = this.config.textureEnabled ? 1 : 0, i[4] = this.config.particleColor[0], i[5] = this.config.particleColor[1], i[6] = this.config.particleColor[2], i[7] = this.config.rotation || 0, i[8] = this.config.startColor[0], i[9] = this.config.startColor[1], i[10] = this.config.startColor[2], i[11] = t, i[12] = this.config.endColor[0], i[13] = this.config.endColor[1], i[14] = this.config.endColor[2], i[15] = this.config.minRotation || 0, i[16] = this.config.maxRotation || 90, i[17] = this.config.aspectRatio || 1, i[18] = this.config.randomSize ? 1 : 0, i[19] = this.config.minSize || 0.1, i[20] = this.config.maxSize || 0.5, i[21] = this.config.fadeSizeEnabled ? 1 : 0, i[22] = this.config.opacity !== void 0 ? this.config.opacity : 1, i[23] = this.config.increaseSizeEnabled ? 1 : 0, i[24] = this.config.sizeLifetimeSpeed ?? 1, i[25] = e, i[26] = 0, i[27] = this.config.pulseEnabled ? 1 : 0, i[28] = this.config.pulseAmplitude ?? 0.5, i[29] = this.config.pulseFrequency ?? 1, i[30] = this.config.pulsePhaseRandom ?? 0, i[31] = this.config.pulseOpacity ? 1 : 0, i[32] = this.config.particleShapeRotationX || 0, i[33] = this.config.particleShapeRotationY || 0, i[34] = this.config.particleShapeRotationZ || 0, i[35] = 0;
|
|
2521
2531
|
const r = this.config.followSystemTranslation ?? !0;
|
|
2522
|
-
i[36] = r ? this._simPosition[0] : 0, i[37] = r ? this._simPosition[1] : 0, i[38] = r ? this._simPosition[2] : 0, i[39] = 0, i[40] = this._simRotX, i[41] = this._simRotZ, i[42] = this.config.velocityStretchEnabled ? 1 : 0, i[43] = this.config.velocityStretchFactor ?? 1, i[44] = this.config.noiseDistortEnabled ? 1 : 0, i[45] = this.config.noiseTilingX ?? 3, i[46] = this.config.noiseTilingY ?? 3, i[47] = this.config.noiseSpeed ?? -1.5, i[48] = this.config.noiseAmplitude ?? 0.08, i[49] = r ? this._simVelocity[0] : 0, i[50] = r ? this._simVelocity[1] : 0, i[51] = r ? this._simVelocity[2] : 0, this.device.queue.writeBuffer(this.appearanceUniformBuffer, 0, i);
|
|
2532
|
+
i[36] = r ? this._simPosition[0] : 0, i[37] = r ? this._simPosition[1] : 0, i[38] = r ? this._simPosition[2] : 0, i[39] = 0, i[40] = this._simRotX, i[41] = this._simRotZ, i[42] = this.config.velocityStretchEnabled ? 1 : 0, i[43] = this.config.velocityStretchFactor ?? 1, i[44] = this.config.noiseDistortEnabled ? 1 : 0, i[45] = this.config.noiseTilingX ?? 3, i[46] = this.config.noiseTilingY ?? 3, i[47] = this.config.noiseSpeed ?? -1.5, i[48] = this.config.noiseAmplitude ?? 0.08, i[49] = r ? this._simVelocity[0] : 0, i[50] = r ? this._simVelocity[1] : 0, i[51] = r ? this._simVelocity[2] : 0, i[52] = this.config.orientX ?? 0, i[53] = this.config.orientY ?? 0, i[54] = this.config.orientZ ?? 0, i[55] = 0, this.device.queue.writeBuffer(this.appearanceUniformBuffer, 0, i);
|
|
2523
2533
|
}
|
|
2524
2534
|
updateBloomIntensity() {
|
|
2525
2535
|
const t = this._bloomIntensityData;
|
|
@@ -2615,11 +2625,11 @@ class bt {
|
|
|
2615
2625
|
if (u > 0 && this._scriptTime >= u && !this._scriptConfigRestored)
|
|
2616
2626
|
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));
|
|
2617
2627
|
else if (!this._scriptConfigRestored) {
|
|
2618
|
-
const
|
|
2628
|
+
const h = u > 0 ? Math.ceil(u / 0.016666666666666666) : 0, { configDirty: p, particlesDirty: d } = this._particleScript.execute(
|
|
2619
2629
|
t,
|
|
2620
2630
|
this._scriptTime,
|
|
2621
2631
|
this._scriptFrame,
|
|
2622
|
-
|
|
2632
|
+
h,
|
|
2623
2633
|
this._scriptParticleData,
|
|
2624
2634
|
this._scriptVelocityData,
|
|
2625
2635
|
this.activeParticles
|
|
@@ -2644,18 +2654,18 @@ class bt {
|
|
|
2644
2654
|
if (!n && !this.emitting && !this.config.burstMode && !this.config.followSystemId && this.currentEmissionTime < this.effectiveEmissionDuration && (this.emitting = !0), !n && this.emitting)
|
|
2645
2655
|
if (this.currentEmissionTime += t, this.currentEmissionTime < this.effectiveEmissionDuration) {
|
|
2646
2656
|
const u = this.activeParticles;
|
|
2647
|
-
let
|
|
2657
|
+
let h = !1;
|
|
2648
2658
|
if (this.config.followSystemId) {
|
|
2649
2659
|
if (this._pendingFollowEmissions.length > 0) {
|
|
2650
2660
|
const p = this._pendingFollowEmissions.length / 6;
|
|
2651
2661
|
for (let d = 0; d < p; d++) {
|
|
2652
|
-
const
|
|
2662
|
+
const S = d * 6;
|
|
2653
2663
|
if (this.emitFollowerParticle(
|
|
2654
|
-
this._pendingFollowEmissions[
|
|
2655
|
-
this._pendingFollowEmissions[
|
|
2656
|
-
this._pendingFollowEmissions[
|
|
2664
|
+
this._pendingFollowEmissions[S],
|
|
2665
|
+
this._pendingFollowEmissions[S + 1],
|
|
2666
|
+
this._pendingFollowEmissions[S + 2]
|
|
2657
2667
|
))
|
|
2658
|
-
|
|
2668
|
+
h = !0;
|
|
2659
2669
|
else
|
|
2660
2670
|
break;
|
|
2661
2671
|
}
|
|
@@ -2672,10 +2682,10 @@ class bt {
|
|
|
2672
2682
|
}
|
|
2673
2683
|
p === 0 && c && this.config.emissionRate > 0 && this.activeParticles < this.particleCount && (p = 1);
|
|
2674
2684
|
for (let d = 0; d < p && this.emitParticle(); d++)
|
|
2675
|
-
|
|
2685
|
+
h = !0;
|
|
2676
2686
|
}
|
|
2677
|
-
if (
|
|
2678
|
-
const p = this.activeParticles - u, d = u * 8,
|
|
2687
|
+
if (h) {
|
|
2688
|
+
const p = this.activeParticles - u, d = u * 8, S = u * 4;
|
|
2679
2689
|
this.device.queue.writeBuffer(
|
|
2680
2690
|
this.instanceBuffer,
|
|
2681
2691
|
d * 4,
|
|
@@ -2685,10 +2695,10 @@ class bt {
|
|
|
2685
2695
|
p * 8
|
|
2686
2696
|
), this.device.queue.writeBuffer(
|
|
2687
2697
|
this.velocityBuffer,
|
|
2688
|
-
|
|
2698
|
+
S * 4,
|
|
2689
2699
|
// Offset in bytes (float32 = 4 bytes)
|
|
2690
2700
|
this.particleVelocities,
|
|
2691
|
-
|
|
2701
|
+
S,
|
|
2692
2702
|
p * 4
|
|
2693
2703
|
);
|
|
2694
2704
|
}
|
|
@@ -2779,13 +2789,13 @@ class bt {
|
|
|
2779
2789
|
o * o + c * c + l * l
|
|
2780
2790
|
);
|
|
2781
2791
|
if (u > 1e-3) {
|
|
2782
|
-
const
|
|
2783
|
-
this.particleVelocities[i] = o / u *
|
|
2792
|
+
const h = this.config.particleSpeed * 2;
|
|
2793
|
+
this.particleVelocities[i] = o / u * h, this.particleVelocities[i + 1] = c / u * h, this.particleVelocities[i + 2] = l / u * h;
|
|
2784
2794
|
} else {
|
|
2785
|
-
const
|
|
2786
|
-
if (
|
|
2795
|
+
const h = Math.sqrt(r * r + n * n + a * a);
|
|
2796
|
+
if (h > 1e-3) {
|
|
2787
2797
|
const p = this.config.particleSpeed * 2;
|
|
2788
|
-
this.particleVelocities[i] = r /
|
|
2798
|
+
this.particleVelocities[i] = r / h * p, this.particleVelocities[i + 1] = n / h * p, this.particleVelocities[i + 2] = a / h * p;
|
|
2789
2799
|
} else
|
|
2790
2800
|
this.particleVelocities[i] = 0, this.particleVelocities[i + 1] = this.config.particleSpeed * 2, this.particleVelocities[i + 2] = 0;
|
|
2791
2801
|
}
|
|
@@ -2830,9 +2840,9 @@ class bt {
|
|
|
2830
2840
|
this.physics.setSoftBoundary(t);
|
|
2831
2841
|
}
|
|
2832
2842
|
}
|
|
2833
|
-
class
|
|
2843
|
+
class Hs {
|
|
2834
2844
|
constructor(t) {
|
|
2835
|
-
this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new
|
|
2845
|
+
this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new Ls({ loop: !!this.loop }), this.ready = !0;
|
|
2836
2846
|
}
|
|
2837
2847
|
createParticleSystem(t = {}) {
|
|
2838
2848
|
const e = this.systemCounter++, i = t.name || `System ${e + 1}`, r = {
|
|
@@ -2903,15 +2913,15 @@ class js {
|
|
|
2903
2913
|
for (const { system: o, config: c } of this.particleSystems) {
|
|
2904
2914
|
const l = c.keyframes;
|
|
2905
2915
|
if (!(!l || c.keyframesEnabled === !1)) {
|
|
2906
|
-
for (const u of
|
|
2907
|
-
const
|
|
2908
|
-
if (
|
|
2909
|
-
const p =
|
|
2916
|
+
for (const u of js) {
|
|
2917
|
+
const h = l[u];
|
|
2918
|
+
if (h && h.length) {
|
|
2919
|
+
const p = Ns(h, a);
|
|
2910
2920
|
p !== void 0 && (c[u] = p);
|
|
2911
2921
|
}
|
|
2912
2922
|
}
|
|
2913
2923
|
if (l.particleColor && l.particleColor.length) {
|
|
2914
|
-
const u =
|
|
2924
|
+
const u = ks(l.particleColor, a);
|
|
2915
2925
|
u && (c.particleColor = u, o.updateAppearanceUniform());
|
|
2916
2926
|
}
|
|
2917
2927
|
}
|
|
@@ -2981,7 +2991,7 @@ class js {
|
|
|
2981
2991
|
try {
|
|
2982
2992
|
let a = null;
|
|
2983
2993
|
if (n.glbModelData)
|
|
2984
|
-
a =
|
|
2994
|
+
a = fi(n.glbModelData);
|
|
2985
2995
|
else if (n.glbFileName) {
|
|
2986
2996
|
const o = await fetch(`/${n.glbFileName}`);
|
|
2987
2997
|
o.ok ? a = await o.arrayBuffer() : console.warn(`GLB file not found: ${n.glbFileName}`);
|
|
@@ -2989,10 +2999,10 @@ class js {
|
|
|
2989
2999
|
if (a) {
|
|
2990
3000
|
if (await r.setGLBModel(a), n.animationIndex !== void 0 && r.glbAnimator && r.glbAnimator.setAnimation(n.animationIndex), n.animationSpeed !== void 0 && r.glbAnimator && (r.glbAnimator.speed = n.animationSpeed), n.animationLoop !== void 0 && r.glbAnimator && (r.glbAnimator.loop = n.animationLoop), n.useGlbTexture && (n.textureEnabled = !0), n.useGlbTexture && ((e = r.glbMeshData) != null && e.hasBaseColorTexture))
|
|
2991
3001
|
try {
|
|
2992
|
-
const o = await
|
|
3002
|
+
const o = await oi(a);
|
|
2993
3003
|
if (o) {
|
|
2994
3004
|
const c = await createImageBitmap(o.imageBlob);
|
|
2995
|
-
await r.setTexture(c), console.log(`GLB embedded texture restored for ${n.name}`);
|
|
3005
|
+
await r.setTexture(c), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${n.name}`);
|
|
2996
3006
|
}
|
|
2997
3007
|
} catch (o) {
|
|
2998
3008
|
console.warn(`Failed to restore GLB texture for ${n.name}:`, o), n.useGlbTexture = !1;
|
|
@@ -3015,7 +3025,7 @@ class js {
|
|
|
3015
3025
|
console.warn(`Failed to restore texture for ${n.name}:`, a), n.textureEnabled = !1;
|
|
3016
3026
|
}
|
|
3017
3027
|
for (const { system: r, config: n } of this.particleSystems)
|
|
3018
|
-
r.updateAppearanceUniform()
|
|
3028
|
+
r.updateAppearanceUniform();
|
|
3019
3029
|
return this.respawnAllSystems(), !0;
|
|
3020
3030
|
} catch (i) {
|
|
3021
3031
|
return console.error("Error replacing systems:", i), !1;
|
|
@@ -3072,7 +3082,7 @@ class js {
|
|
|
3072
3082
|
try {
|
|
3073
3083
|
let l = null;
|
|
3074
3084
|
if (c.glbModelData)
|
|
3075
|
-
l =
|
|
3085
|
+
l = fi(c.glbModelData);
|
|
3076
3086
|
else if (c.glbFileName) {
|
|
3077
3087
|
const u = await fetch(`/${c.glbFileName}`);
|
|
3078
3088
|
u.ok ? l = await u.arrayBuffer() : console.warn(`GLB file not found: ${c.glbFileName}`);
|
|
@@ -3080,10 +3090,10 @@ class js {
|
|
|
3080
3090
|
if (l) {
|
|
3081
3091
|
if (await o.setGLBModel(l), c.animationIndex !== void 0 && o.glbAnimator && o.glbAnimator.setAnimation(c.animationIndex), c.animationSpeed !== void 0 && o.glbAnimator && (o.glbAnimator.speed = c.animationSpeed), c.animationLoop !== void 0 && o.glbAnimator && (o.glbAnimator.loop = c.animationLoop), c.useGlbTexture && (c.textureEnabled = !0), c.useGlbTexture && ((r = o.glbMeshData) != null && r.hasBaseColorTexture))
|
|
3082
3092
|
try {
|
|
3083
|
-
const u = await
|
|
3093
|
+
const u = await oi(l);
|
|
3084
3094
|
if (u) {
|
|
3085
|
-
const
|
|
3086
|
-
await o.setTexture(
|
|
3095
|
+
const h = await createImageBitmap(u.imageBlob);
|
|
3096
|
+
await o.setTexture(h), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${c.name}`);
|
|
3087
3097
|
}
|
|
3088
3098
|
} catch (u) {
|
|
3089
3099
|
console.warn(`Failed to restore GLB texture for ${c.name}:`, u), c.useGlbTexture = !1;
|
|
@@ -3097,8 +3107,8 @@ class js {
|
|
|
3097
3107
|
if (c.textureEnabled && !c.glbModelEnabled && c.textureImageData && !o._textureRestored)
|
|
3098
3108
|
try {
|
|
3099
3109
|
const l = new Image();
|
|
3100
|
-
await new Promise((
|
|
3101
|
-
l.onload =
|
|
3110
|
+
await new Promise((h, p) => {
|
|
3111
|
+
l.onload = h, l.onerror = p, l.src = c.textureImageData;
|
|
3102
3112
|
});
|
|
3103
3113
|
const u = await createImageBitmap(l);
|
|
3104
3114
|
await o.setTexture(u), o._textureRestored = !0;
|
|
@@ -3113,7 +3123,7 @@ class js {
|
|
|
3113
3123
|
}
|
|
3114
3124
|
}
|
|
3115
3125
|
}
|
|
3116
|
-
async function
|
|
3126
|
+
async function qs(s) {
|
|
3117
3127
|
if (!s)
|
|
3118
3128
|
throw new Error("canvas is required for initWebGPU()");
|
|
3119
3129
|
if (!navigator.gpu)
|
|
@@ -3125,37 +3135,37 @@ async function Ys(s) {
|
|
|
3125
3135
|
alphaMode: "premultiplied"
|
|
3126
3136
|
}), { device: i, context: t, format: r, canvas: s };
|
|
3127
3137
|
}
|
|
3128
|
-
const
|
|
3129
|
-
function
|
|
3138
|
+
const le = "rgba16float";
|
|
3139
|
+
function pi(s, t, e, i) {
|
|
3130
3140
|
const r = s.createTexture({
|
|
3131
3141
|
size: [e, i],
|
|
3132
|
-
format:
|
|
3142
|
+
format: le,
|
|
3133
3143
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3134
3144
|
mipLevelCount: 1,
|
|
3135
3145
|
sampleCount: 1
|
|
3136
3146
|
}), n = s.createTexture({
|
|
3137
3147
|
size: [e, i],
|
|
3138
|
-
format:
|
|
3148
|
+
format: le,
|
|
3139
3149
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3140
3150
|
mipLevelCount: 1,
|
|
3141
3151
|
sampleCount: 1
|
|
3142
3152
|
}), a = s.createTexture({
|
|
3143
3153
|
size: [e, i],
|
|
3144
|
-
format:
|
|
3154
|
+
format: le,
|
|
3145
3155
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3146
3156
|
mipLevelCount: 1,
|
|
3147
3157
|
sampleCount: 1
|
|
3148
3158
|
});
|
|
3149
3159
|
return { sceneTexture: r, bloomTexA: n, bloomTexB: a };
|
|
3150
3160
|
}
|
|
3151
|
-
function
|
|
3161
|
+
function hi(s, t, e) {
|
|
3152
3162
|
return s.createTexture({
|
|
3153
3163
|
size: [t, e],
|
|
3154
3164
|
format: "depth24plus",
|
|
3155
3165
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
3156
3166
|
});
|
|
3157
3167
|
}
|
|
3158
|
-
function
|
|
3168
|
+
function Ge(s, t, e) {
|
|
3159
3169
|
const i = s.createBuffer({
|
|
3160
3170
|
size: t.byteLength,
|
|
3161
3171
|
usage: e,
|
|
@@ -3163,7 +3173,7 @@ function De(s, t, e) {
|
|
|
3163
3173
|
});
|
|
3164
3174
|
return new t.constructor(i.getMappedRange()).set(t), i.unmap(), i;
|
|
3165
3175
|
}
|
|
3166
|
-
const
|
|
3176
|
+
const Zs = `
|
|
3167
3177
|
struct Uniforms {
|
|
3168
3178
|
transform: mat4x4<f32>,
|
|
3169
3179
|
cameraPosition: vec3<f32>,
|
|
@@ -3225,7 +3235,7 @@ const Hs = `
|
|
|
3225
3235
|
|
|
3226
3236
|
return finalColor;
|
|
3227
3237
|
}
|
|
3228
|
-
`,
|
|
3238
|
+
`, $s = `
|
|
3229
3239
|
struct Uniforms {
|
|
3230
3240
|
transform: mat4x4<f32>,
|
|
3231
3241
|
cameraPosition: vec3<f32>,
|
|
@@ -3461,7 +3471,7 @@ const Hs = `
|
|
|
3461
3471
|
return finalColor;
|
|
3462
3472
|
}
|
|
3463
3473
|
`;
|
|
3464
|
-
function
|
|
3474
|
+
function Ws(s) {
|
|
3465
3475
|
const t = s.createBindGroupLayout({
|
|
3466
3476
|
entries: [
|
|
3467
3477
|
{
|
|
@@ -3547,7 +3557,7 @@ function Zs(s) {
|
|
|
3547
3557
|
object3dBindGroupLayout: r
|
|
3548
3558
|
};
|
|
3549
3559
|
}
|
|
3550
|
-
function
|
|
3560
|
+
function Js(s, t, e, i = {}) {
|
|
3551
3561
|
const { depthCompare: r } = i, n = r || "less", {
|
|
3552
3562
|
particleBindGroupLayout: a,
|
|
3553
3563
|
bloomBindGroupLayout: o,
|
|
@@ -3555,23 +3565,23 @@ function $s(s, t, e, i = {}) {
|
|
|
3555
3565
|
object3dBindGroupLayout: l
|
|
3556
3566
|
} = e, u = s.createPipelineLayout({
|
|
3557
3567
|
bindGroupLayouts: [a]
|
|
3558
|
-
}),
|
|
3568
|
+
}), h = s.createPipelineLayout({
|
|
3559
3569
|
bindGroupLayouts: [o]
|
|
3560
3570
|
}), p = s.createPipelineLayout({
|
|
3561
3571
|
bindGroupLayouts: [c]
|
|
3562
3572
|
}), d = s.createShaderModule({
|
|
3563
|
-
code: fs
|
|
3564
|
-
}), b = s.createShaderModule({
|
|
3565
3573
|
code: ps
|
|
3566
|
-
}),
|
|
3574
|
+
}), S = s.createShaderModule({
|
|
3567
3575
|
code: hs
|
|
3568
|
-
}),
|
|
3576
|
+
}), R = s.createShaderModule({
|
|
3569
3577
|
code: ms
|
|
3570
|
-
}),
|
|
3571
|
-
code:
|
|
3572
|
-
}),
|
|
3573
|
-
code:
|
|
3574
|
-
}),
|
|
3578
|
+
}), E = s.createShaderModule({
|
|
3579
|
+
code: ys
|
|
3580
|
+
}), T = s.createShaderModule({
|
|
3581
|
+
code: Zs
|
|
3582
|
+
}), x = s.createShaderModule({
|
|
3583
|
+
code: $s
|
|
3584
|
+
}), L = (W) => s.createRenderPipeline({
|
|
3575
3585
|
layout: u,
|
|
3576
3586
|
vertex: {
|
|
3577
3587
|
module: d,
|
|
@@ -3638,8 +3648,8 @@ function $s(s, t, e, i = {}) {
|
|
|
3638
3648
|
module: d,
|
|
3639
3649
|
entryPoint: "fs_main",
|
|
3640
3650
|
targets: [{
|
|
3641
|
-
format:
|
|
3642
|
-
blend:
|
|
3651
|
+
format: le,
|
|
3652
|
+
blend: W
|
|
3643
3653
|
}]
|
|
3644
3654
|
},
|
|
3645
3655
|
primitive: {
|
|
@@ -3651,7 +3661,7 @@ function $s(s, t, e, i = {}) {
|
|
|
3651
3661
|
depthCompare: n,
|
|
3652
3662
|
format: "depth24plus"
|
|
3653
3663
|
}
|
|
3654
|
-
}),
|
|
3664
|
+
}), P = L({
|
|
3655
3665
|
color: {
|
|
3656
3666
|
srcFactor: "src-alpha",
|
|
3657
3667
|
dstFactor: "one-minus-src-alpha",
|
|
@@ -3662,7 +3672,7 @@ function $s(s, t, e, i = {}) {
|
|
|
3662
3672
|
dstFactor: "one-minus-src-alpha",
|
|
3663
3673
|
operation: "add"
|
|
3664
3674
|
}
|
|
3665
|
-
}),
|
|
3675
|
+
}), B = L({
|
|
3666
3676
|
color: {
|
|
3667
3677
|
srcFactor: "src-alpha",
|
|
3668
3678
|
dstFactor: "one",
|
|
@@ -3673,7 +3683,7 @@ function $s(s, t, e, i = {}) {
|
|
|
3673
3683
|
dstFactor: "one-minus-src-alpha",
|
|
3674
3684
|
operation: "add"
|
|
3675
3685
|
}
|
|
3676
|
-
}),
|
|
3686
|
+
}), M = s.createRenderPipeline({
|
|
3677
3687
|
layout: u,
|
|
3678
3688
|
vertex: {
|
|
3679
3689
|
module: d,
|
|
@@ -3740,7 +3750,7 @@ function $s(s, t, e, i = {}) {
|
|
|
3740
3750
|
module: d,
|
|
3741
3751
|
entryPoint: "fs_main",
|
|
3742
3752
|
targets: [{
|
|
3743
|
-
format:
|
|
3753
|
+
format: le,
|
|
3744
3754
|
writeMask: 0
|
|
3745
3755
|
// No color write — depth only
|
|
3746
3756
|
}]
|
|
@@ -3755,33 +3765,33 @@ function $s(s, t, e, i = {}) {
|
|
|
3755
3765
|
// Always write depth (don't self-occlude)
|
|
3756
3766
|
format: "depth24plus"
|
|
3757
3767
|
}
|
|
3758
|
-
}),
|
|
3759
|
-
layout:
|
|
3768
|
+
}), F = s.createRenderPipeline({
|
|
3769
|
+
layout: h,
|
|
3760
3770
|
vertex: {
|
|
3761
|
-
module:
|
|
3771
|
+
module: S,
|
|
3762
3772
|
entryPoint: "vs_main"
|
|
3763
3773
|
},
|
|
3764
3774
|
fragment: {
|
|
3765
|
-
module:
|
|
3775
|
+
module: S,
|
|
3766
3776
|
entryPoint: "fs_main",
|
|
3767
3777
|
targets: [{
|
|
3768
|
-
format:
|
|
3778
|
+
format: le
|
|
3769
3779
|
}]
|
|
3770
3780
|
},
|
|
3771
3781
|
primitive: {
|
|
3772
3782
|
topology: "triangle-list"
|
|
3773
3783
|
}
|
|
3774
|
-
}),
|
|
3784
|
+
}), N = s.createRenderPipeline({
|
|
3775
3785
|
layout: p,
|
|
3776
3786
|
vertex: {
|
|
3777
|
-
module:
|
|
3787
|
+
module: R,
|
|
3778
3788
|
entryPoint: "vs_main"
|
|
3779
3789
|
},
|
|
3780
3790
|
fragment: {
|
|
3781
|
-
module:
|
|
3791
|
+
module: R,
|
|
3782
3792
|
entryPoint: "fs_main",
|
|
3783
3793
|
targets: [{
|
|
3784
|
-
format:
|
|
3794
|
+
format: le,
|
|
3785
3795
|
blend: {
|
|
3786
3796
|
color: {
|
|
3787
3797
|
srcFactor: "one",
|
|
@@ -3799,17 +3809,17 @@ function $s(s, t, e, i = {}) {
|
|
|
3799
3809
|
primitive: {
|
|
3800
3810
|
topology: "triangle-list"
|
|
3801
3811
|
}
|
|
3802
|
-
}),
|
|
3812
|
+
}), Y = s.createRenderPipeline({
|
|
3803
3813
|
layout: p,
|
|
3804
3814
|
vertex: {
|
|
3805
|
-
module:
|
|
3815
|
+
module: E,
|
|
3806
3816
|
entryPoint: "vs_main"
|
|
3807
3817
|
},
|
|
3808
3818
|
fragment: {
|
|
3809
|
-
module:
|
|
3819
|
+
module: E,
|
|
3810
3820
|
entryPoint: "fs_main",
|
|
3811
3821
|
targets: [{
|
|
3812
|
-
format:
|
|
3822
|
+
format: le,
|
|
3813
3823
|
blend: {
|
|
3814
3824
|
color: {
|
|
3815
3825
|
srcFactor: "one",
|
|
@@ -3827,7 +3837,7 @@ function $s(s, t, e, i = {}) {
|
|
|
3827
3837
|
primitive: {
|
|
3828
3838
|
topology: "triangle-list"
|
|
3829
3839
|
}
|
|
3830
|
-
}), k = s.createShaderModule({ code:
|
|
3840
|
+
}), k = s.createShaderModule({ code: gs }), G = s.createRenderPipeline({
|
|
3831
3841
|
layout: p,
|
|
3832
3842
|
vertex: { module: k, entryPoint: "vs_main" },
|
|
3833
3843
|
fragment: {
|
|
@@ -3842,12 +3852,12 @@ function $s(s, t, e, i = {}) {
|
|
|
3842
3852
|
}]
|
|
3843
3853
|
},
|
|
3844
3854
|
primitive: { topology: "triangle-list" }
|
|
3845
|
-
}),
|
|
3855
|
+
}), pe = s.createPipelineLayout({
|
|
3846
3856
|
bindGroupLayouts: [l]
|
|
3847
|
-
}),
|
|
3848
|
-
layout:
|
|
3857
|
+
}), De = s.createRenderPipeline({
|
|
3858
|
+
layout: pe,
|
|
3849
3859
|
vertex: {
|
|
3850
|
-
module:
|
|
3860
|
+
module: T,
|
|
3851
3861
|
entryPoint: "vs_main",
|
|
3852
3862
|
buffers: [
|
|
3853
3863
|
{
|
|
@@ -3872,10 +3882,10 @@ function $s(s, t, e, i = {}) {
|
|
|
3872
3882
|
]
|
|
3873
3883
|
},
|
|
3874
3884
|
fragment: {
|
|
3875
|
-
module:
|
|
3885
|
+
module: T,
|
|
3876
3886
|
entryPoint: "fs_main",
|
|
3877
3887
|
targets: [{
|
|
3878
|
-
format:
|
|
3888
|
+
format: le,
|
|
3879
3889
|
blend: {
|
|
3880
3890
|
color: {
|
|
3881
3891
|
srcFactor: "src-alpha",
|
|
@@ -3902,7 +3912,7 @@ function $s(s, t, e, i = {}) {
|
|
|
3902
3912
|
}), at = s.createRenderPipeline({
|
|
3903
3913
|
layout: u,
|
|
3904
3914
|
vertex: {
|
|
3905
|
-
module:
|
|
3915
|
+
module: x,
|
|
3906
3916
|
entryPoint: "vs_main",
|
|
3907
3917
|
buffers: [
|
|
3908
3918
|
{
|
|
@@ -3974,10 +3984,10 @@ function $s(s, t, e, i = {}) {
|
|
|
3974
3984
|
]
|
|
3975
3985
|
},
|
|
3976
3986
|
fragment: {
|
|
3977
|
-
module:
|
|
3987
|
+
module: x,
|
|
3978
3988
|
entryPoint: "fs_main",
|
|
3979
3989
|
targets: [{
|
|
3980
|
-
format:
|
|
3990
|
+
format: le,
|
|
3981
3991
|
blend: {
|
|
3982
3992
|
color: {
|
|
3983
3993
|
srcFactor: "src-alpha",
|
|
@@ -4003,14 +4013,14 @@ function $s(s, t, e, i = {}) {
|
|
|
4003
4013
|
}
|
|
4004
4014
|
});
|
|
4005
4015
|
return {
|
|
4006
|
-
particlePipeline:
|
|
4007
|
-
particleAdditivePipeline:
|
|
4008
|
-
particleDepthWritePipeline:
|
|
4009
|
-
blurPipeline:
|
|
4010
|
-
compositePipeline:
|
|
4011
|
-
directRenderPipeline:
|
|
4012
|
-
finalCompositePipeline:
|
|
4013
|
-
object3dPipeline:
|
|
4016
|
+
particlePipeline: P,
|
|
4017
|
+
particleAdditivePipeline: B,
|
|
4018
|
+
particleDepthWritePipeline: M,
|
|
4019
|
+
blurPipeline: F,
|
|
4020
|
+
compositePipeline: N,
|
|
4021
|
+
directRenderPipeline: Y,
|
|
4022
|
+
finalCompositePipeline: G,
|
|
4023
|
+
object3dPipeline: De,
|
|
4014
4024
|
glbMeshPipeline: at
|
|
4015
4025
|
};
|
|
4016
4026
|
}
|
|
@@ -4024,7 +4034,7 @@ function St(s, t, e, i) {
|
|
|
4024
4034
|
} = e, {
|
|
4025
4035
|
sceneTexture: l,
|
|
4026
4036
|
bloomTexA: u,
|
|
4027
|
-
bloomTexB:
|
|
4037
|
+
bloomTexB: h
|
|
4028
4038
|
} = i, p = s.createBindGroup({
|
|
4029
4039
|
layout: s.createBindGroupLayout({
|
|
4030
4040
|
entries: [
|
|
@@ -4084,7 +4094,7 @@ function St(s, t, e, i) {
|
|
|
4084
4094
|
resource: { buffer: a }
|
|
4085
4095
|
}
|
|
4086
4096
|
]
|
|
4087
|
-
}),
|
|
4097
|
+
}), S = s.createBindGroup({
|
|
4088
4098
|
layout: s.createBindGroupLayout({
|
|
4089
4099
|
entries: [
|
|
4090
4100
|
{
|
|
@@ -4118,7 +4128,7 @@ function St(s, t, e, i) {
|
|
|
4118
4128
|
resource: { buffer: o }
|
|
4119
4129
|
}
|
|
4120
4130
|
]
|
|
4121
|
-
}),
|
|
4131
|
+
}), R = s.createBindGroup({
|
|
4122
4132
|
layout: s.createBindGroupLayout({
|
|
4123
4133
|
entries: [
|
|
4124
4134
|
{
|
|
@@ -4154,14 +4164,14 @@ function St(s, t, e, i) {
|
|
|
4154
4164
|
},
|
|
4155
4165
|
{
|
|
4156
4166
|
binding: 2,
|
|
4157
|
-
resource:
|
|
4167
|
+
resource: h.createView()
|
|
4158
4168
|
},
|
|
4159
4169
|
{
|
|
4160
4170
|
binding: 3,
|
|
4161
4171
|
resource: { buffer: c }
|
|
4162
4172
|
}
|
|
4163
4173
|
]
|
|
4164
|
-
}),
|
|
4174
|
+
}), E = s.createBindGroup({
|
|
4165
4175
|
layout: s.createBindGroupLayout({
|
|
4166
4176
|
entries: [
|
|
4167
4177
|
{
|
|
@@ -4197,7 +4207,7 @@ function St(s, t, e, i) {
|
|
|
4197
4207
|
},
|
|
4198
4208
|
{
|
|
4199
4209
|
binding: 2,
|
|
4200
|
-
resource:
|
|
4210
|
+
resource: h.createView()
|
|
4201
4211
|
},
|
|
4202
4212
|
{
|
|
4203
4213
|
binding: 3,
|
|
@@ -4208,12 +4218,12 @@ function St(s, t, e, i) {
|
|
|
4208
4218
|
return {
|
|
4209
4219
|
particleBindGroup: p,
|
|
4210
4220
|
horizontalBlurBindGroup: d,
|
|
4211
|
-
verticalBlurBindGroup:
|
|
4212
|
-
compositeBindGroup:
|
|
4213
|
-
directRenderBindGroup:
|
|
4221
|
+
verticalBlurBindGroup: S,
|
|
4222
|
+
compositeBindGroup: R,
|
|
4223
|
+
directRenderBindGroup: E
|
|
4214
4224
|
};
|
|
4215
4225
|
}
|
|
4216
|
-
function
|
|
4226
|
+
function Qs(s) {
|
|
4217
4227
|
return s.createSampler({
|
|
4218
4228
|
magFilter: "linear",
|
|
4219
4229
|
minFilter: "linear",
|
|
@@ -4223,7 +4233,7 @@ function Ws(s) {
|
|
|
4223
4233
|
maxAnisotropy: 16
|
|
4224
4234
|
});
|
|
4225
4235
|
}
|
|
4226
|
-
function
|
|
4236
|
+
function Ks() {
|
|
4227
4237
|
const s = new Float32Array([
|
|
4228
4238
|
// Front face (z = 0.5)
|
|
4229
4239
|
-0.5,
|
|
@@ -4421,13 +4431,13 @@ function Js() {
|
|
|
4421
4431
|
]);
|
|
4422
4432
|
return { vertices: s, indices: t };
|
|
4423
4433
|
}
|
|
4424
|
-
function
|
|
4434
|
+
function er(s = 16, t = 16) {
|
|
4425
4435
|
const e = [], i = [];
|
|
4426
4436
|
for (let r = 0; r <= s; r++) {
|
|
4427
4437
|
const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
|
|
4428
4438
|
for (let c = 0; c <= t; c++) {
|
|
4429
|
-
const l = c * 2 * Math.PI / t, u = Math.sin(l), p = Math.cos(l) * a, d = o,
|
|
4430
|
-
e.push(p * 0.5, d * 0.5,
|
|
4439
|
+
const l = c * 2 * Math.PI / t, u = Math.sin(l), p = Math.cos(l) * a, d = o, S = u * a;
|
|
4440
|
+
e.push(p * 0.5, d * 0.5, S * 0.5), e.push(p, d, S);
|
|
4431
4441
|
}
|
|
4432
4442
|
}
|
|
4433
4443
|
for (let r = 0; r < s; r++)
|
|
@@ -4440,7 +4450,7 @@ function Qs(s = 16, t = 16) {
|
|
|
4440
4450
|
indices: new Uint16Array(i)
|
|
4441
4451
|
};
|
|
4442
4452
|
}
|
|
4443
|
-
class
|
|
4453
|
+
class tr {
|
|
4444
4454
|
constructor(t, e, i, r, n) {
|
|
4445
4455
|
this.id = t, this.type = e, this.position = i, this.scale = r, this.color = n, this.rotation = [0, 0, 0];
|
|
4446
4456
|
}
|
|
@@ -4574,7 +4584,7 @@ class Ks {
|
|
|
4574
4584
|
return i;
|
|
4575
4585
|
}
|
|
4576
4586
|
}
|
|
4577
|
-
class
|
|
4587
|
+
class cr {
|
|
4578
4588
|
constructor(t) {
|
|
4579
4589
|
this.device = t, this.objects = [], this.nextId = 0, this.initializeGeometry(), this.onObjectAdded = null, this.onObjectRemoved = null, this.onObjectUpdated = null;
|
|
4580
4590
|
}
|
|
@@ -4582,20 +4592,20 @@ class or {
|
|
|
4582
4592
|
* Initialize geometry buffers for cube and sphere
|
|
4583
4593
|
*/
|
|
4584
4594
|
initializeGeometry() {
|
|
4585
|
-
const t =
|
|
4586
|
-
this.cubeVertexBuffer =
|
|
4595
|
+
const t = Ks(), e = er(16, 16);
|
|
4596
|
+
this.cubeVertexBuffer = Ge(
|
|
4587
4597
|
this.device,
|
|
4588
4598
|
t.vertices,
|
|
4589
4599
|
GPUBufferUsage.VERTEX
|
|
4590
|
-
), this.cubeIndexBuffer =
|
|
4600
|
+
), this.cubeIndexBuffer = Ge(
|
|
4591
4601
|
this.device,
|
|
4592
4602
|
t.indices,
|
|
4593
4603
|
GPUBufferUsage.INDEX
|
|
4594
|
-
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer =
|
|
4604
|
+
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer = Ge(
|
|
4595
4605
|
this.device,
|
|
4596
4606
|
e.vertices,
|
|
4597
4607
|
GPUBufferUsage.VERTEX
|
|
4598
|
-
), this.sphereIndexBuffer =
|
|
4608
|
+
), this.sphereIndexBuffer = Ge(
|
|
4599
4609
|
this.device,
|
|
4600
4610
|
e.indices,
|
|
4601
4611
|
GPUBufferUsage.INDEX
|
|
@@ -4610,7 +4620,7 @@ class or {
|
|
|
4610
4620
|
* @returns {Object3D} The created object
|
|
4611
4621
|
*/
|
|
4612
4622
|
addObject(t, e = [0, 0, 0], i = [1, 1, 1], r = [1, 1, 1, 1]) {
|
|
4613
|
-
const n = new
|
|
4623
|
+
const n = new tr(this.nextId++, t, e, i, r);
|
|
4614
4624
|
return n.uniformBuffer = this.device.createBuffer({
|
|
4615
4625
|
size: 192,
|
|
4616
4626
|
// modelMatrix (64) + normalMatrix (64) + color (16) + padding (48)
|
|
@@ -4699,21 +4709,21 @@ class or {
|
|
|
4699
4709
|
}
|
|
4700
4710
|
}
|
|
4701
4711
|
}
|
|
4702
|
-
function
|
|
4712
|
+
function ur(s) {
|
|
4703
4713
|
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;
|
|
4704
4714
|
return [t, e, i];
|
|
4705
4715
|
}
|
|
4706
|
-
function
|
|
4716
|
+
function dr(s) {
|
|
4707
4717
|
if (!s) return "#ffffff";
|
|
4708
4718
|
const t = Math.round(s[0] * 255).toString(16).padStart(2, "0"), e = Math.round(s[1] * 255).toString(16).padStart(2, "0"), i = Math.round(s[2] * 255).toString(16).padStart(2, "0");
|
|
4709
4719
|
return `#${t}${e}${i}`;
|
|
4710
4720
|
}
|
|
4711
|
-
function
|
|
4712
|
-
const i =
|
|
4721
|
+
function fr(s, t, e) {
|
|
4722
|
+
const i = mi([
|
|
4713
4723
|
s[0] - t[0],
|
|
4714
4724
|
s[1] - t[1],
|
|
4715
4725
|
s[2] - t[2]
|
|
4716
|
-
]), r =
|
|
4726
|
+
]), r = mi(yi(e, i)), n = yi(i, r);
|
|
4717
4727
|
return new Float32Array([
|
|
4718
4728
|
r[0],
|
|
4719
4729
|
n[0],
|
|
@@ -4733,7 +4743,7 @@ function ur(s, t, e) {
|
|
|
4733
4743
|
1
|
|
4734
4744
|
]);
|
|
4735
4745
|
}
|
|
4736
|
-
function
|
|
4746
|
+
function pr(s, t = Math.PI / 4) {
|
|
4737
4747
|
const r = 1 / Math.tan(t / 2);
|
|
4738
4748
|
return new Float32Array([
|
|
4739
4749
|
r * s,
|
|
@@ -4754,11 +4764,11 @@ function dr(s, t = Math.PI / 4) {
|
|
|
4754
4764
|
0
|
|
4755
4765
|
]);
|
|
4756
4766
|
}
|
|
4757
|
-
function
|
|
4767
|
+
function mi(s) {
|
|
4758
4768
|
const t = Math.sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2]);
|
|
4759
4769
|
return [s[0] / t, s[1] / t, s[2] / t];
|
|
4760
4770
|
}
|
|
4761
|
-
function
|
|
4771
|
+
function yi(s, t) {
|
|
4762
4772
|
return [
|
|
4763
4773
|
s[1] * t[2] - s[2] * t[1],
|
|
4764
4774
|
s[2] * t[0] - s[0] * t[2],
|
|
@@ -4768,7 +4778,7 @@ function mi(s, t) {
|
|
|
4768
4778
|
function xt(s, t) {
|
|
4769
4779
|
return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
|
|
4770
4780
|
}
|
|
4771
|
-
function
|
|
4781
|
+
function ir(s, t) {
|
|
4772
4782
|
const e = new Float32Array(16);
|
|
4773
4783
|
for (let i = 0; i < 4; i++)
|
|
4774
4784
|
for (let r = 0; r < 4; r++) {
|
|
@@ -4779,7 +4789,7 @@ function er(s, t) {
|
|
|
4779
4789
|
}
|
|
4780
4790
|
return e;
|
|
4781
4791
|
}
|
|
4782
|
-
const Pt = 1481005640,
|
|
4792
|
+
const Pt = 1481005640, vi = 1, Pi = 1313821514, _i = 5130562, qe = "$hzfxAsset", wi = (s) => typeof atob == "function" ? Uint8Array.from(atob(s), (t) => t.charCodeAt(0)) : new Uint8Array(Buffer.from(s, "base64")), gi = (s) => {
|
|
4783
4793
|
if (typeof btoa == "function") {
|
|
4784
4794
|
let t = "";
|
|
4785
4795
|
for (let e = 0; e < s.length; e++) t += String.fromCharCode(s[e]);
|
|
@@ -4787,67 +4797,67 @@ const Pt = 1481005640, xi = 1, vi = 1313821514, Pi = 5130562, qe = "$hzfxAsset",
|
|
|
4787
4797
|
}
|
|
4788
4798
|
return Buffer.from(s).toString("base64");
|
|
4789
4799
|
};
|
|
4790
|
-
function
|
|
4791
|
-
const t = s.indexOf(","), e = s.slice(5, t), i = e.split(";")[0] || "application/octet-stream", r = s.slice(t + 1), a = /;base64/i.test(e) ?
|
|
4800
|
+
function sr(s) {
|
|
4801
|
+
const t = s.indexOf(","), e = s.slice(5, t), i = e.split(";")[0] || "application/octet-stream", r = s.slice(t + 1), a = /;base64/i.test(e) ? wi(r) : new TextEncoder().encode(decodeURIComponent(r));
|
|
4792
4802
|
return { mime: i, bytes: a };
|
|
4793
4803
|
}
|
|
4794
|
-
function
|
|
4804
|
+
function bi(s) {
|
|
4795
4805
|
return (4 - s % 4) % 4;
|
|
4796
4806
|
}
|
|
4797
|
-
async function
|
|
4807
|
+
async function rr(s, t = {}) {
|
|
4798
4808
|
const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
|
|
4799
4809
|
let a = 0;
|
|
4800
|
-
const o = (
|
|
4801
|
-
const
|
|
4802
|
-
r.push({ offset:
|
|
4803
|
-
const k =
|
|
4810
|
+
const o = (B, M, F) => {
|
|
4811
|
+
const N = a, Y = B.length;
|
|
4812
|
+
r.push({ offset: N, length: Y, mime: M, kind: F }), n.push(B), a += Y;
|
|
4813
|
+
const k = bi(Y);
|
|
4804
4814
|
return k && (n.push(new Uint8Array(k)), a += k), r.length - 1;
|
|
4805
4815
|
}, c = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", l = [];
|
|
4806
|
-
for (const
|
|
4807
|
-
const
|
|
4808
|
-
if (typeof
|
|
4809
|
-
let { mime:
|
|
4810
|
-
if (c &&
|
|
4816
|
+
for (const B of s.systems || []) {
|
|
4817
|
+
const M = { ...B };
|
|
4818
|
+
if (typeof M.textureImageData == "string" && M.textureImageData.startsWith("data:")) {
|
|
4819
|
+
let { mime: F, bytes: N } = sr(M.textureImageData);
|
|
4820
|
+
if (c && F !== "image/webp")
|
|
4811
4821
|
try {
|
|
4812
|
-
const
|
|
4813
|
-
k.getContext("2d").drawImage(
|
|
4814
|
-
const
|
|
4815
|
-
|
|
4822
|
+
const Y = await createImageBitmap(new Blob([N], { type: F })), k = new OffscreenCanvas(Y.width, Y.height);
|
|
4823
|
+
k.getContext("2d").drawImage(Y, 0, 0);
|
|
4824
|
+
const G = await k.convertToBlob({ type: "image/webp", quality: i }), pe = new Uint8Array(await G.arrayBuffer());
|
|
4825
|
+
pe.length < N.length && (N = pe, F = "image/webp");
|
|
4816
4826
|
} catch {
|
|
4817
4827
|
}
|
|
4818
|
-
|
|
4828
|
+
M.textureImageData = { [qe]: o(N, F, "texture") };
|
|
4819
4829
|
}
|
|
4820
|
-
if (typeof
|
|
4821
|
-
const
|
|
4822
|
-
|
|
4830
|
+
if (typeof M.glbModelData == "string" && M.glbModelData.length > 0) {
|
|
4831
|
+
const F = wi(M.glbModelData);
|
|
4832
|
+
M.glbModelData = { [qe]: o(F, "model/gltf-binary", "glb") };
|
|
4823
4833
|
}
|
|
4824
|
-
l.push(
|
|
4825
|
-
}
|
|
4826
|
-
const u = { ...s, systems: l, assets: r },
|
|
4827
|
-
let
|
|
4828
|
-
for (const
|
|
4829
|
-
d.set(
|
|
4830
|
-
const
|
|
4831
|
-
let
|
|
4832
|
-
|
|
4833
|
-
for (let
|
|
4834
|
-
return
|
|
4834
|
+
l.push(M);
|
|
4835
|
+
}
|
|
4836
|
+
const u = { ...s, systems: l, assets: r }, h = new TextEncoder().encode(JSON.stringify(u)), p = bi(h.length), d = new Uint8Array(a);
|
|
4837
|
+
let S = 0;
|
|
4838
|
+
for (const B of n)
|
|
4839
|
+
d.set(B, S), S += B.length;
|
|
4840
|
+
const R = h.length + p, E = 20 + R + 8 + a, T = new ArrayBuffer(E), x = new DataView(T), L = new Uint8Array(T);
|
|
4841
|
+
let P = 0;
|
|
4842
|
+
x.setUint32(P, Pt, !0), P += 4, x.setUint32(P, vi, !0), P += 4, x.setUint32(P, E, !0), P += 4, x.setUint32(P, R, !0), P += 4, x.setUint32(P, Pi, !0), P += 4, L.set(h, P), P += h.length;
|
|
4843
|
+
for (let B = 0; B < p; B++) L[P++] = 32;
|
|
4844
|
+
return x.setUint32(P, a, !0), P += 4, x.setUint32(P, _i, !0), P += 4, L.set(d, P), P += a, T;
|
|
4835
4845
|
}
|
|
4836
4846
|
function Bi(s) {
|
|
4837
4847
|
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === Pt;
|
|
4838
4848
|
}
|
|
4839
|
-
function
|
|
4849
|
+
function Mi(s) {
|
|
4840
4850
|
const t = new DataView(s);
|
|
4841
4851
|
if (t.getUint32(0, !0) !== Pt) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
|
|
4842
4852
|
const e = t.getUint32(4, !0);
|
|
4843
|
-
if (e !==
|
|
4853
|
+
if (e !== vi) throw new Error(`[unpackHZFX] unsupported version ${e}`);
|
|
4844
4854
|
let i = 12, r = null, n = -1;
|
|
4845
4855
|
const a = new Uint8Array(s);
|
|
4846
4856
|
for (; i + 8 <= s.byteLength; ) {
|
|
4847
4857
|
const p = t.getUint32(i, !0);
|
|
4848
4858
|
i += 4;
|
|
4849
4859
|
const d = t.getUint32(i, !0);
|
|
4850
|
-
i += 4, d ===
|
|
4860
|
+
i += 4, d === Pi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + p))) : d === _i && (n = i), i += p;
|
|
4851
4861
|
}
|
|
4852
4862
|
if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
|
|
4853
4863
|
const o = r.assets || [], c = (p) => {
|
|
@@ -4856,25 +4866,25 @@ function wi(s) {
|
|
|
4856
4866
|
}, l = (p) => p && typeof p == "object" && typeof p[qe] == "number", u = (r.systems || []).map((p) => {
|
|
4857
4867
|
const d = { ...p };
|
|
4858
4868
|
if (l(d.textureImageData)) {
|
|
4859
|
-
const
|
|
4860
|
-
d.textureImageData =
|
|
4869
|
+
const S = c(d.textureImageData[qe]);
|
|
4870
|
+
d.textureImageData = S ? `data:${S.mime};base64,${gi(S.bytes)}` : void 0;
|
|
4861
4871
|
}
|
|
4862
4872
|
if (l(d.glbModelData)) {
|
|
4863
|
-
const
|
|
4864
|
-
d.glbModelData =
|
|
4873
|
+
const S = c(d.glbModelData[qe]);
|
|
4874
|
+
d.glbModelData = S ? gi(S.bytes) : void 0;
|
|
4865
4875
|
}
|
|
4866
4876
|
return d;
|
|
4867
|
-
}),
|
|
4868
|
-
return delete
|
|
4877
|
+
}), h = { ...r, systems: u };
|
|
4878
|
+
return delete h.assets, h;
|
|
4869
4879
|
}
|
|
4870
|
-
function
|
|
4880
|
+
function nr(s) {
|
|
4871
4881
|
const t = new Uint8Array(s);
|
|
4872
4882
|
let e = "";
|
|
4873
4883
|
for (let i = 0; i < t.byteLength; i++)
|
|
4874
4884
|
e += String.fromCharCode(t[i]);
|
|
4875
4885
|
return btoa(e);
|
|
4876
4886
|
}
|
|
4877
|
-
function
|
|
4887
|
+
function ar(s) {
|
|
4878
4888
|
return {
|
|
4879
4889
|
name: s.name,
|
|
4880
4890
|
id: s.id,
|
|
@@ -4939,6 +4949,9 @@ function rr(s) {
|
|
|
4939
4949
|
rotationMode: s.rotationMode,
|
|
4940
4950
|
minRotation: s.minRotation,
|
|
4941
4951
|
maxRotation: s.maxRotation,
|
|
4952
|
+
orientX: s.orientX,
|
|
4953
|
+
orientY: s.orientY,
|
|
4954
|
+
orientZ: s.orientZ,
|
|
4942
4955
|
overrideXVelocity: s.overrideXVelocity,
|
|
4943
4956
|
overrideYVelocity: s.overrideYVelocity,
|
|
4944
4957
|
overrideZVelocity: s.overrideZVelocity,
|
|
@@ -5049,7 +5062,7 @@ function rr(s) {
|
|
|
5049
5062
|
displayUnit: s.displayUnit || "m"
|
|
5050
5063
|
};
|
|
5051
5064
|
}
|
|
5052
|
-
async function
|
|
5065
|
+
async function hr(s, t, e = "hzfx") {
|
|
5053
5066
|
if (!s || !s.particleSystems || s.particleSystems.length === 0) {
|
|
5054
5067
|
alert("No particle systems to save.");
|
|
5055
5068
|
return;
|
|
@@ -5058,12 +5071,12 @@ async function fr(s, t, e = "hzfx") {
|
|
|
5058
5071
|
const i = {
|
|
5059
5072
|
version: "1.0",
|
|
5060
5073
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5061
|
-
systems: s.particleSystems.map(({ config: u, system:
|
|
5062
|
-
...
|
|
5074
|
+
systems: s.particleSystems.map(({ config: u, system: h }) => ({
|
|
5075
|
+
...ar(u),
|
|
5063
5076
|
// single source of truth for config fields
|
|
5064
5077
|
// Binary assets embedded so replaceSystems() can restore them
|
|
5065
5078
|
textureImageData: u.textureEnabled && !u.glbModelEnabled && u.textureImageData ? u.textureImageData : void 0,
|
|
5066
|
-
glbModelData: u.glbModelEnabled &&
|
|
5079
|
+
glbModelData: u.glbModelEnabled && h.glbRawArrayBuffer ? nr(h.glbRawArrayBuffer) : void 0
|
|
5067
5080
|
})),
|
|
5068
5081
|
activeSystemIndex: s.activeSystemIndex,
|
|
5069
5082
|
loop: s.loop || !1
|
|
@@ -5071,7 +5084,7 @@ async function fr(s, t, e = "hzfx") {
|
|
|
5071
5084
|
}, r = e === "json" ? "json" : "hzfx";
|
|
5072
5085
|
let n;
|
|
5073
5086
|
if (r === "hzfx") {
|
|
5074
|
-
const u = await
|
|
5087
|
+
const u = await rr(i, { textureFormat: "webp" });
|
|
5075
5088
|
n = new Blob([u], { type: "application/octet-stream" });
|
|
5076
5089
|
} else
|
|
5077
5090
|
n = new Blob([JSON.stringify(i, null, 2)], { type: "application/json" });
|
|
@@ -5088,7 +5101,7 @@ async function fr(s, t, e = "hzfx") {
|
|
|
5088
5101
|
console.error("Error saving scene:", i), alert("Error saving scene. See console for details.");
|
|
5089
5102
|
}
|
|
5090
5103
|
}
|
|
5091
|
-
function
|
|
5104
|
+
function mr(s) {
|
|
5092
5105
|
return new Promise((t, e) => {
|
|
5093
5106
|
try {
|
|
5094
5107
|
const i = s.target.files[0];
|
|
@@ -5101,7 +5114,7 @@ function pr(s) {
|
|
|
5101
5114
|
try {
|
|
5102
5115
|
const a = n.target.result;
|
|
5103
5116
|
let o;
|
|
5104
|
-
if (Bi(a) ? o =
|
|
5117
|
+
if (Bi(a) ? o = Mi(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
|
|
5105
5118
|
throw new Error("No valid particle systems found in the file");
|
|
5106
5119
|
t({
|
|
5107
5120
|
systems: o.systems.slice(),
|
|
@@ -5119,7 +5132,7 @@ function pr(s) {
|
|
|
5119
5132
|
}
|
|
5120
5133
|
});
|
|
5121
5134
|
}
|
|
5122
|
-
async function
|
|
5135
|
+
async function yr(s) {
|
|
5123
5136
|
if (!s || typeof s != "string")
|
|
5124
5137
|
throw new Error("[fetchPreset] url must be a non-empty string");
|
|
5125
5138
|
const t = await fetch(s);
|
|
@@ -5127,7 +5140,7 @@ async function hr(s) {
|
|
|
5127
5140
|
throw new Error(`[fetchPreset] HTTP ${t.status}: ${t.statusText}`);
|
|
5128
5141
|
const e = await t.arrayBuffer();
|
|
5129
5142
|
let i;
|
|
5130
|
-
if (Bi(e) ? i =
|
|
5143
|
+
if (Bi(e) ? i = Mi(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
|
|
5131
5144
|
throw new Error('[fetchPreset] Invalid preset: "systems" must be a non-empty array');
|
|
5132
5145
|
return {
|
|
5133
5146
|
version: i.version,
|
|
@@ -5135,7 +5148,7 @@ async function hr(s) {
|
|
|
5135
5148
|
activeSystemIndex: i.activeSystemIndex ?? 0
|
|
5136
5149
|
};
|
|
5137
5150
|
}
|
|
5138
|
-
const
|
|
5151
|
+
const or = (s) => `
|
|
5139
5152
|
@vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
|
|
5140
5153
|
var p = array<vec2f, 3>(vec2f(-1.0, -3.0), vec2f(-1.0, 1.0), vec2f(3.0, 1.0));
|
|
5141
5154
|
return vec4f(p[i], 0.0, 1.0);
|
|
@@ -5145,51 +5158,51 @@ const nr = (s) => `
|
|
|
5145
5158
|
return textureLoad(src, vec2i(pos.xy), 0);
|
|
5146
5159
|
}
|
|
5147
5160
|
`;
|
|
5148
|
-
async function
|
|
5161
|
+
async function gr(s, t = {}) {
|
|
5149
5162
|
const { getSceneDepth: e = null, autoRespawn: i = !0 } = t;
|
|
5150
5163
|
let r, n, a;
|
|
5151
5164
|
const o = !!(s && s.device && s.context);
|
|
5152
|
-
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await
|
|
5153
|
-
const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new
|
|
5154
|
-
function
|
|
5155
|
-
const
|
|
5156
|
-
if (!u.pipelines[
|
|
5157
|
-
const
|
|
5165
|
+
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await qs(a));
|
|
5166
|
+
const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new Hs(r), u = { layouts: {}, pipelines: {} };
|
|
5167
|
+
function h(f) {
|
|
5168
|
+
const m = f ? "ms" : "ss";
|
|
5169
|
+
if (!u.pipelines[m]) {
|
|
5170
|
+
const b = r.createShaderModule({ code: or(f) }), g = r.createBindGroupLayout({
|
|
5158
5171
|
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: f } }]
|
|
5159
5172
|
});
|
|
5160
|
-
u.layouts[
|
|
5173
|
+
u.layouts[m] = g, u.pipelines[m] = r.createRenderPipeline({
|
|
5161
5174
|
layout: r.createPipelineLayout({ bindGroupLayouts: [g] }),
|
|
5162
|
-
vertex: { module:
|
|
5163
|
-
fragment: { module:
|
|
5175
|
+
vertex: { module: b, entryPoint: "vs" },
|
|
5176
|
+
fragment: { module: b, entryPoint: "fs", targets: [] },
|
|
5164
5177
|
primitive: { topology: "triangle-list" },
|
|
5165
5178
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
|
|
5166
5179
|
});
|
|
5167
5180
|
}
|
|
5168
|
-
return { pipeline: u.pipelines[
|
|
5181
|
+
return { pipeline: u.pipelines[m], layout: u.layouts[m] };
|
|
5169
5182
|
}
|
|
5170
5183
|
const p = {
|
|
5171
5184
|
bloomSourceTextures: {},
|
|
5172
5185
|
bloomCompositeTextures: {},
|
|
5173
5186
|
combinedTexture: null,
|
|
5174
|
-
getBloomSourceTexture(f,
|
|
5187
|
+
getBloomSourceTexture(f, m, b) {
|
|
5175
5188
|
return this.bloomSourceTextures[f] || (this.bloomSourceTextures[f] = r.createTexture({
|
|
5176
|
-
size: [
|
|
5189
|
+
size: [m, b],
|
|
5177
5190
|
format: "rgba16float",
|
|
5178
5191
|
// HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
|
|
5179
5192
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5180
5193
|
})), this.bloomSourceTextures[f];
|
|
5181
5194
|
},
|
|
5182
|
-
getBloomCompositeTexture(f,
|
|
5195
|
+
getBloomCompositeTexture(f, m, b) {
|
|
5183
5196
|
return this.bloomCompositeTextures[f] || (this.bloomCompositeTextures[f] = r.createTexture({
|
|
5184
|
-
size: [
|
|
5197
|
+
size: [m, b],
|
|
5185
5198
|
format: "rgba16float",
|
|
5186
5199
|
// HDR chain
|
|
5187
5200
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5188
5201
|
})), this.bloomCompositeTextures[f];
|
|
5189
5202
|
},
|
|
5190
|
-
getCombinedTexture(f,
|
|
5203
|
+
getCombinedTexture(f, m) {
|
|
5191
5204
|
return this.combinedTexture || (this.combinedTexture = r.createTexture({
|
|
5192
|
-
size: [f,
|
|
5205
|
+
size: [f, m],
|
|
5193
5206
|
format: "rgba16float",
|
|
5194
5207
|
// HDR chain — tonemapped to canvas in the final pass
|
|
5195
5208
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
@@ -5214,151 +5227,154 @@ async function mr(s, t = {}) {
|
|
|
5214
5227
|
clear() {
|
|
5215
5228
|
this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
|
|
5216
5229
|
}
|
|
5217
|
-
},
|
|
5230
|
+
}, S = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), R = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), E = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), T = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), x = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), L = Ge(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), P = {}, B = () => Ge(r, new Float32Array([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0]), GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST);
|
|
5218
5231
|
l.onSystemCreated = (f) => {
|
|
5219
|
-
|
|
5232
|
+
P[f] || (P[f] = B());
|
|
5220
5233
|
};
|
|
5221
|
-
const
|
|
5234
|
+
const M = 4e4, F = new Float32Array(M * 8), N = new Float32Array(M * 4), Y = new Float32Array(M * 4), k = r.createBuffer({ size: M * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), G = r.createBuffer({ size: M * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), pe = r.createBuffer({ size: M * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), De = /* @__PURE__ */ new Map(), at = 8, W = [];
|
|
5222
5235
|
function _t(f) {
|
|
5223
|
-
for (const
|
|
5236
|
+
for (const m of W) if (m.ids.has(f)) return m;
|
|
5224
5237
|
return null;
|
|
5225
5238
|
}
|
|
5226
|
-
function Ri(f,
|
|
5239
|
+
function Ri(f, m) {
|
|
5227
5240
|
if (!f.pos) return;
|
|
5228
|
-
f.hist.push({ t:
|
|
5229
|
-
const
|
|
5230
|
-
for (; f.hist.length > 2 && f.hist[0].t <
|
|
5231
|
-
}
|
|
5232
|
-
function
|
|
5233
|
-
const
|
|
5234
|
-
if (
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
return [g.x, g.y, g.z];
|
|
5241
|
+
f.hist.push({ t: m, x: f.pos[0], y: f.pos[1], z: f.pos[2] });
|
|
5242
|
+
const b = m - at;
|
|
5243
|
+
for (; f.hist.length > 2 && f.hist[0].t < b; ) f.hist.shift();
|
|
5244
|
+
}
|
|
5245
|
+
function wt(f, m, b) {
|
|
5246
|
+
const g = f.hist;
|
|
5247
|
+
if (g.length === 0) {
|
|
5248
|
+
const H = f.pos;
|
|
5249
|
+
return H && (b[0] = H[0], b[1] = H[1], b[2] = H[2]), b;
|
|
5238
5250
|
}
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5242
|
-
|
|
5243
|
-
|
|
5251
|
+
let v;
|
|
5252
|
+
if (m >= g[g.length - 1].t)
|
|
5253
|
+
return v = g[g.length - 1], b[0] = v.x, b[1] = v.y, b[2] = v.z, b;
|
|
5254
|
+
if (m <= g[0].t)
|
|
5255
|
+
return v = g[0], b[0] = v.x, b[1] = v.y, b[2] = v.z, b;
|
|
5256
|
+
for (let H = g.length - 1; H > 0; H--)
|
|
5257
|
+
if (g[H - 1].t <= m) {
|
|
5258
|
+
const j = g[H - 1], Q = g[H], Z = (m - j.t) / Math.max(1e-6, Q.t - j.t);
|
|
5259
|
+
return b[0] = j.x + (Q.x - j.x) * Z, b[1] = j.y + (Q.y - j.y) * Z, b[2] = j.z + (Q.z - j.z) * Z, b;
|
|
5244
5260
|
}
|
|
5245
|
-
return [
|
|
5261
|
+
return v = g[0], b[0] = v.x, b[1] = v.y, b[2] = v.z, b;
|
|
5246
5262
|
}
|
|
5247
|
-
const
|
|
5248
|
-
function
|
|
5249
|
-
|
|
5250
|
-
let f = 0,
|
|
5263
|
+
const Ti = 0.41421356;
|
|
5264
|
+
function Ei() {
|
|
5265
|
+
De.clear();
|
|
5266
|
+
let f = 0, m = 0;
|
|
5251
5267
|
A.position[0], A.position[1], A.position[2];
|
|
5252
|
-
for (const { system:
|
|
5268
|
+
for (const { system: b, config: g } of l.particleSystems) {
|
|
5253
5269
|
if (!g.emissionTrailEnabled || g.hidden || g.glbModelEnabled) continue;
|
|
5254
|
-
|
|
5255
|
-
const
|
|
5256
|
-
if (!
|
|
5257
|
-
const
|
|
5258
|
-
for (let et = 0; et <
|
|
5259
|
-
const ye = et * 8, tt =
|
|
5260
|
-
let Oe =
|
|
5261
|
-
const
|
|
5262
|
-
if (
|
|
5263
|
-
const ge =
|
|
5270
|
+
b.readbackAndProcessParticles();
|
|
5271
|
+
const v = b.particleData, H = b.particleVelocities, j = b.activeParticles;
|
|
5272
|
+
if (!v || !H || j <= 0) continue;
|
|
5273
|
+
const Q = g.emissionTrailMode === "particles", Z = f, Ae = g.emissionTrailDuration ?? 1, y = g.opacity ?? 1, w = g.particleSize ?? 0.5, U = g.bloomIntensity || 1, I = Math.max(1, Math.min(64, g.emissionTrailSegments ?? 8)), D = g.emissionTrailShape || "straight", J = g.followSystemTranslation ?? !0, K = b._simPosition, X = J && K ? K[0] : 0, Ke = J && K ? K[1] : 0, Ot = J && K ? K[2] : 0, Ue = b._simVelocity, Lt = Ue ? Ue[0] : 0, ts = Ue ? Ue[1] : 0, Xt = Ue ? Ue[2] : 0, Ve = _t(g.id), Nt = !!(J && Ve && Ve.hist && Ve.hist.length > 1);
|
|
5274
|
+
for (let et = 0; et < j; et++) {
|
|
5275
|
+
const ye = et * 8, tt = v[ye], ft = v[ye + 1], it = v[ye + 2], is = tt + X, ss = ft + Ke, rs = it + Ot;
|
|
5276
|
+
let Oe = v[ye + 3], Le = v[ye + 4], Xe = v[ye + 5];
|
|
5277
|
+
const Ne = v[ye + 6], Ie = v[ye + 7];
|
|
5278
|
+
if (Ne >= Ie || Ie <= 0) continue;
|
|
5279
|
+
const ge = Ne / Ie;
|
|
5264
5280
|
if (g.colorTransitionEnabled) {
|
|
5265
|
-
const
|
|
5266
|
-
Oe =
|
|
5281
|
+
const _ = g.startColor ?? [1, 0, 0], z = g.endColor ?? [0, 0, 1];
|
|
5282
|
+
Oe = _[0] + (z[0] - _[0]) * ge, Le = _[1] + (z[1] - _[1]) * ge, Xe = _[2] + (z[2] - _[2]) * ge;
|
|
5267
5283
|
}
|
|
5268
|
-
Oe = Math.min(1, Oe * U), Le = Math.min(1, Le * U),
|
|
5269
|
-
let ke =
|
|
5284
|
+
Oe = Math.min(1, Oe * U), Le = Math.min(1, Le * U), Xe = Math.min(1, Xe * U);
|
|
5285
|
+
let ke = w;
|
|
5270
5286
|
if (g.randomSize) {
|
|
5271
|
-
const
|
|
5272
|
-
ke = (g.minSize ?? 0.1) + ((g.maxSize ?? 0.5) - (g.minSize ?? 0.1)) *
|
|
5287
|
+
const _ = Math.sin(Ie * 54321.67) * 43758.5453 % 1, z = _ < 0 ? _ + 1 : _;
|
|
5288
|
+
ke = (g.minSize ?? 0.1) + ((g.maxSize ?? 0.5) - (g.minSize ?? 0.1)) * z;
|
|
5273
5289
|
}
|
|
5274
5290
|
if (g.fadeSizeEnabled) {
|
|
5275
|
-
const
|
|
5276
|
-
ke *= 1 - Math.pow(ge, 1 /
|
|
5291
|
+
const _ = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
|
|
5292
|
+
ke *= 1 - Math.pow(ge, 1 / _);
|
|
5277
5293
|
}
|
|
5278
5294
|
if (g.increaseSizeEnabled) {
|
|
5279
|
-
const
|
|
5280
|
-
ke *= 1 + Math.pow(ge, 1 /
|
|
5295
|
+
const _ = Math.max(0.01, Math.min(10, g.sizeLifetimeSpeed ?? 1));
|
|
5296
|
+
ke *= 1 + Math.pow(ge, 1 / _);
|
|
5281
5297
|
}
|
|
5282
5298
|
if (ke <= 0 || ge > 0.9) continue;
|
|
5283
|
-
const
|
|
5299
|
+
const kt = Math.min((0.9 - ge) * (1 / 0.2), 1), jt = 0.75 * ke * Ti * kt;
|
|
5284
5300
|
let je = y;
|
|
5285
|
-
if (g.fadeEnabled && (je *= Math.max(0, 1 - ge)), je *=
|
|
5286
|
-
const pt = et * 4,
|
|
5287
|
-
if (
|
|
5288
|
-
const ht = 1 /
|
|
5289
|
-
let mt =
|
|
5301
|
+
if (g.fadeEnabled && (je *= Math.max(0, 1 - ge)), je *= kt, je < 0.01) continue;
|
|
5302
|
+
const pt = et * 4, Yt = H[pt], Ht = H[pt + 1], qt = H[pt + 2], st = Yt + Lt, rt = Ht + ts, nt = qt + Xt, Zt = Math.sqrt(st * st + rt * rt + nt * nt);
|
|
5303
|
+
if (Zt < 1e-3) continue;
|
|
5304
|
+
const ht = 1 / Zt, Pe = st * ht, _e = rt * ht, be = nt * ht, $t = A.right[0], Wt = A.right[1], Jt = A.right[2];
|
|
5305
|
+
let mt = $t * Pe + Wt * _e + Jt * be, ne = $t - mt * Pe, ae = Wt - mt * _e, oe = Jt - mt * be, Ye = Math.sqrt(ne * ne + ae * ae + oe * oe);
|
|
5290
5306
|
if (Ye < 0.2) {
|
|
5291
|
-
const
|
|
5292
|
-
|
|
5307
|
+
const _ = A.up[0], z = A.up[1], $ = A.up[2], V = _ * Pe + z * _e + $ * be;
|
|
5308
|
+
ne = _ - V * Pe, ae = z - V * _e, oe = $ - V * be, Ye = Math.sqrt(ne * ne + ae * ae + oe * oe) || 1;
|
|
5293
5309
|
}
|
|
5294
|
-
|
|
5295
|
-
const He = Math.min(Ae,
|
|
5310
|
+
ne /= Ye, ae /= Ye, oe /= Ye;
|
|
5311
|
+
const He = Math.min(Ae, Ne);
|
|
5296
5312
|
if (He < 1e-3) continue;
|
|
5297
|
-
const
|
|
5313
|
+
const Qt = g.gravityEnabled && g.gravityStrength || 0, we = Oi, Be = Li, Me = Xi;
|
|
5298
5314
|
if (g.orientToDirection && g.burstMode && Nt) {
|
|
5299
|
-
const
|
|
5300
|
-
for (let
|
|
5301
|
-
const O =
|
|
5302
|
-
|
|
5315
|
+
const _ = b._emitSimRotY || 0, z = Ni, $ = ki, V = ji;
|
|
5316
|
+
for (let C = 0; C <= I; C++) {
|
|
5317
|
+
const O = wt(Ve, me - C / I * He, It);
|
|
5318
|
+
z[C] = O[0], $[C] = O[1], V[C] = O[2];
|
|
5303
5319
|
}
|
|
5304
|
-
for (let
|
|
5305
|
-
const O =
|
|
5306
|
-
let
|
|
5307
|
-
const Se = (Math.hypot(
|
|
5308
|
-
|
|
5320
|
+
for (let C = 0; C <= I; C++) {
|
|
5321
|
+
const O = C > 0 ? C - 1 : 0, q = C < I ? C + 1 : I;
|
|
5322
|
+
let Re = z[O] - z[q], Te = V[O] - V[q];
|
|
5323
|
+
const Se = (Math.hypot(Re, Te) > 1e-5 ? Math.atan2(Re, Te) : Math.atan2(Lt, Xt)) - _, ie = Math.cos(Se), se = Math.sin(Se), fe = C / I * He, yt = -0.5 * Qt * fe * fe;
|
|
5324
|
+
we[C] = ie * tt + se * it + z[C], Be[C] = ft + yt + $[C], Me[C] = -se * tt + ie * it + V[C];
|
|
5309
5325
|
}
|
|
5310
|
-
} else for (let
|
|
5311
|
-
const
|
|
5326
|
+
} else for (let _ = 0; _ <= I; _++) {
|
|
5327
|
+
const z = _ / I * He, $ = -0.5 * Qt * z * z;
|
|
5312
5328
|
if (Nt) {
|
|
5313
|
-
const
|
|
5314
|
-
|
|
5329
|
+
const V = wt(Ve, me - z, It);
|
|
5330
|
+
we[_] = tt - Yt * z + V[0], Be[_] = ft - Ht * z + $ + V[1], Me[_] = it - qt * z + V[2];
|
|
5315
5331
|
} else
|
|
5316
|
-
|
|
5332
|
+
we[_] = is - st * z, Be[_] = ss - rt * z + $, Me[_] = rs - nt * z;
|
|
5317
5333
|
}
|
|
5318
|
-
if (
|
|
5319
|
-
const
|
|
5320
|
-
let
|
|
5321
|
-
|
|
5322
|
-
const
|
|
5323
|
-
for (let
|
|
5324
|
-
const Se =
|
|
5325
|
-
let se = 0,
|
|
5326
|
-
|
|
5334
|
+
if (D !== "straight") {
|
|
5335
|
+
const _ = g.emissionTrailShapeAmplitude ?? 0.1, z = g.emissionTrailShapeFrequency ?? 4, $ = g.emissionTrailShapeSpeed ?? 0;
|
|
5336
|
+
let V = -be, C = 0, O = Pe, q = Math.sqrt(V * V + O * O);
|
|
5337
|
+
q < 1e-6 && (V = 0, C = be, O = -_e, q = Math.sqrt(V * V + C * C + O * O) || 1), V /= q, C /= q, O /= q;
|
|
5338
|
+
const Re = _e * O - be * C, Te = be * V - Pe * O, de = Pe * C - _e * V;
|
|
5339
|
+
for (let ee = 1; ee <= I; ee++) {
|
|
5340
|
+
const Se = ee / I * He, ie = 2 * Math.PI * z * (me - Se) + $ * me;
|
|
5341
|
+
let se = 0, fe = 0;
|
|
5342
|
+
D === "zigzag" ? se = _ * Math.sign(Math.sin(ie)) : D === "sine" ? se = _ * Math.sin(ie) : D === "spiral" && (se = _ * Math.sin(ie), fe = _ * Math.cos(ie)), we[ee] += V * se + Re * fe, Be[ee] += C * se + Te * fe, Me[ee] += O * se + de * fe;
|
|
5327
5343
|
}
|
|
5328
5344
|
}
|
|
5329
|
-
if (
|
|
5330
|
-
for (let
|
|
5331
|
-
const
|
|
5332
|
-
|
|
5345
|
+
if (Q)
|
|
5346
|
+
for (let _ = 1; _ <= I && f < M; _++) {
|
|
5347
|
+
const z = _ / I, $ = we[_] - X, V = Be[_] - Ke, C = Me[_] - Ot, O = f * 8, q = f * 4;
|
|
5348
|
+
F[O] = $, F[O + 1] = V, F[O + 2] = C, F[O + 3] = Oe, F[O + 4] = Le, F[O + 5] = Xe, F[O + 6] = Ne + (Ie - Ne) * z, F[O + 7] = Ie, N[q] = 0, N[q + 1] = 0, N[q + 2] = 0, N[q + 3] = 0, Y[q] = $, Y[q + 1] = V, Y[q + 2] = C, Y[q + 3] = 0, f++;
|
|
5333
5349
|
}
|
|
5334
5350
|
else
|
|
5335
|
-
for (let
|
|
5336
|
-
const
|
|
5337
|
-
ce[
|
|
5351
|
+
for (let _ = 0; _ < I && !(m + 42 > ce.length); _++) {
|
|
5352
|
+
const z = _ / I, $ = (_ + 1) / I, V = we[_], C = Be[_], O = Me[_], q = we[_ + 1], Re = Be[_ + 1], Te = Me[_ + 1], de = jt * (1 - z), ee = jt * (1 - $), Se = je * (1 - z) * (1 - z), ie = je * (1 - $) * (1 - $), se = V + ne * de, fe = C + ae * de, yt = O + oe * de, Kt = V - ne * de, ei = C - ae * de, ti = O - oe * de, ii = q + ne * ee, si = Re + ae * ee, ri = Te + oe * ee, ns = q - ne * ee, as = Re - ae * ee, os = Te - oe * ee, ze = (ls, cs, us, ds) => {
|
|
5353
|
+
ce[m++] = ls, ce[m++] = cs, ce[m++] = us, ce[m++] = Oe, ce[m++] = Le, ce[m++] = Xe, ce[m++] = ds;
|
|
5338
5354
|
};
|
|
5339
|
-
|
|
5355
|
+
ze(se, fe, yt, Se), ze(Kt, ei, ti, Se), ze(ii, si, ri, ie), ze(Kt, ei, ti, Se), ze(ns, as, os, ie), ze(ii, si, ri, ie);
|
|
5340
5356
|
}
|
|
5341
5357
|
}
|
|
5342
|
-
|
|
5358
|
+
Q && f > Z && De.set(g.id, { first: Z, count: f - Z });
|
|
5343
5359
|
}
|
|
5344
|
-
f > 0 && (r.queue.writeBuffer(k, 0,
|
|
5360
|
+
f > 0 && (r.queue.writeBuffer(k, 0, F, 0, f * 8), r.queue.writeBuffer(G, 0, N, 0, f * 4), r.queue.writeBuffer(pe, 0, Y, 0, f * 4)), Fe = m / 7, Fe > 0 && r.queue.writeBuffer(At, 0, ce, 0, m);
|
|
5345
5361
|
}
|
|
5346
|
-
const
|
|
5347
|
-
r.queue.writeBuffer(
|
|
5362
|
+
const Bt = () => {
|
|
5363
|
+
r.queue.writeBuffer(E, 0, new Float32Array([1, 0, a.width, a.height, 0, 0, 0, 0])), r.queue.writeBuffer(T, 0, new Float32Array([0, 1, a.width, a.height, 0, 0, 0, 0]));
|
|
5348
5364
|
};
|
|
5349
|
-
|
|
5350
|
-
const
|
|
5351
|
-
|
|
5352
|
-
const
|
|
5353
|
-
particlePipeline:
|
|
5354
|
-
particleAdditivePipeline:
|
|
5355
|
-
particleDepthWritePipeline:
|
|
5365
|
+
Bt();
|
|
5366
|
+
const Mt = new Float32Array(16).fill(0);
|
|
5367
|
+
Mt[0] = 1, r.queue.writeBuffer(x, 0, Mt);
|
|
5368
|
+
const re = Qs(r), he = Ws(r), {
|
|
5369
|
+
particlePipeline: Ci,
|
|
5370
|
+
particleAdditivePipeline: Ai,
|
|
5371
|
+
particleDepthWritePipeline: Ui,
|
|
5356
5372
|
blurPipeline: $e,
|
|
5357
|
-
compositePipeline:
|
|
5358
|
-
directRenderPipeline:
|
|
5359
|
-
finalCompositePipeline:
|
|
5373
|
+
compositePipeline: Ii,
|
|
5374
|
+
directRenderPipeline: Rt,
|
|
5375
|
+
finalCompositePipeline: zi,
|
|
5360
5376
|
glbMeshPipeline: Gi
|
|
5361
|
-
} =
|
|
5377
|
+
} = Js(r, c, he), Tt = r.createShaderModule({ code: `
|
|
5362
5378
|
struct U { mvp: mat4x4<f32> };
|
|
5363
5379
|
@group(0) @binding(0) var<uniform> u: U;
|
|
5364
5380
|
struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
|
|
@@ -5394,13 +5410,13 @@ async function mr(s, t = {}) {
|
|
|
5394
5410
|
size: Ct * 7 * 4,
|
|
5395
5411
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5396
5412
|
label: "ribbonBuffer"
|
|
5397
|
-
}),
|
|
5413
|
+
}), Fi = r.createBindGroup({
|
|
5398
5414
|
layout: Et,
|
|
5399
|
-
entries: [{ binding: 0, resource: { buffer:
|
|
5415
|
+
entries: [{ binding: 0, resource: { buffer: S } }]
|
|
5400
5416
|
});
|
|
5401
|
-
let
|
|
5402
|
-
const ot = { uniformBuffer:
|
|
5403
|
-
let We = St(r,
|
|
5417
|
+
let Fe = 0, { sceneTexture: te, bloomTexA: xe, bloomTexB: ue } = pi(r, c, a.width, a.height), ve = hi(r, a.width, a.height);
|
|
5418
|
+
const ot = { uniformBuffer: S, appearanceUniformBuffer: R, horizontalBlurUniformBuffer: E, verticalBlurUniformBuffer: T, bloomIntensityBuffer: x };
|
|
5419
|
+
let We = St(r, re, ot, { sceneTexture: te, bloomTexA: xe, bloomTexB: ue });
|
|
5404
5420
|
const A = {
|
|
5405
5421
|
mvp: new Float32Array(16),
|
|
5406
5422
|
position: new Float32Array([0, 0, 10]),
|
|
@@ -5410,26 +5426,26 @@ async function mr(s, t = {}) {
|
|
|
5410
5426
|
hasCamera: !1
|
|
5411
5427
|
};
|
|
5412
5428
|
let me = 0, Vi = 0;
|
|
5413
|
-
const Ee = new Float32Array(5), Ut = new Float32Array(16),
|
|
5414
|
-
let
|
|
5429
|
+
const Ee = new Float32Array(5), Ut = new Float32Array(16), Oi = new Array(65), Li = new Array(65), Xi = new Array(65), Ni = new Array(65), ki = new Array(65), ji = new Array(65), It = [0, 0, 0], Ce = { key: null, ms: !1, bindGroup: null };
|
|
5430
|
+
let zt = !1, lt = !0, Je = !1, Qe = null, ct = a.width, ut = a.height;
|
|
5415
5431
|
function Gt() {
|
|
5416
|
-
const f = [te, xe, ue, ve],
|
|
5417
|
-
te =
|
|
5418
|
-
let
|
|
5432
|
+
const f = [te, xe, ue, ve], m = pi(r, c, a.width, a.height);
|
|
5433
|
+
te = m.sceneTexture, xe = m.bloomTexA, ue = m.bloomTexB, ve = hi(r, a.width, a.height), Bt(), d.clear(), p.resizeTextures(), We = St(r, re, ot, { sceneTexture: te, bloomTexA: xe, bloomTexB: ue });
|
|
5434
|
+
let b = !1;
|
|
5419
5435
|
const g = () => {
|
|
5420
|
-
if (!
|
|
5421
|
-
|
|
5436
|
+
if (!b) {
|
|
5437
|
+
b = !0, requestAnimationFrame(g);
|
|
5422
5438
|
return;
|
|
5423
5439
|
}
|
|
5424
|
-
f.forEach((
|
|
5440
|
+
f.forEach((v) => v.destroy());
|
|
5425
5441
|
};
|
|
5426
5442
|
requestAnimationFrame(g);
|
|
5427
5443
|
}
|
|
5428
|
-
function
|
|
5429
|
-
A.mvp.set(
|
|
5444
|
+
function Yi(f, m, b) {
|
|
5445
|
+
A.mvp.set(ir(f, m)), m && m.length >= 10 && (A.right[0] = m[0], A.right[1] = m[4], A.right[2] = m[8], A.up[0] = m[1], A.up[1] = m[5], A.up[2] = m[9]), b && (A.position[0] = b.x ?? b[0], A.position[1] = b.y ?? b[1], A.position[2] = b.z ?? b[2]), A.hasCamera = !0;
|
|
5430
5446
|
}
|
|
5431
|
-
function
|
|
5432
|
-
A.mvp.set(f),
|
|
5447
|
+
function Hi(f, m) {
|
|
5448
|
+
A.mvp.set(f), m && (A.position[0] = m.x ?? m[0], A.position[1] = m.y ?? m[1], A.position[2] = m.z ?? m[2]), A.hasCamera = !0;
|
|
5433
5449
|
}
|
|
5434
5450
|
async function dt(f) {
|
|
5435
5451
|
if (Je) {
|
|
@@ -5438,158 +5454,158 @@ async function mr(s, t = {}) {
|
|
|
5438
5454
|
}
|
|
5439
5455
|
Je = !0;
|
|
5440
5456
|
try {
|
|
5441
|
-
for (const
|
|
5442
|
-
d.clear(), p.resizeTextures(), We = St(r,
|
|
5443
|
-
for (const
|
|
5444
|
-
await l.addSystems(
|
|
5445
|
-
for (const { config:
|
|
5446
|
-
|
|
5457
|
+
for (const m in P) delete P[m];
|
|
5458
|
+
d.clear(), p.resizeTextures(), We = St(r, re, ot, { sceneTexture: te, bloomTexA: xe, bloomTexB: ue }), await l.replaceSystems({ systems: [], activeSystemIndex: 0 });
|
|
5459
|
+
for (const m of f)
|
|
5460
|
+
await l.addSystems(m.preset, m.position || [0, 0, 0]);
|
|
5461
|
+
for (const { config: m } of l.particleSystems)
|
|
5462
|
+
P[m.id] || (P[m.id] = B());
|
|
5447
5463
|
lt = !0, l.respawnAllSystems();
|
|
5448
5464
|
} finally {
|
|
5449
5465
|
if (Je = !1, Qe) {
|
|
5450
|
-
const
|
|
5451
|
-
Qe = null, dt(
|
|
5466
|
+
const m = Qe;
|
|
5467
|
+
Qe = null, dt(m);
|
|
5452
5468
|
}
|
|
5453
5469
|
}
|
|
5454
5470
|
}
|
|
5455
|
-
async function
|
|
5456
|
-
return dt([{ preset: f, position:
|
|
5471
|
+
async function qi(f, m = [0, 0, 0]) {
|
|
5472
|
+
return dt([{ preset: f, position: m }]);
|
|
5457
5473
|
}
|
|
5458
|
-
function
|
|
5459
|
-
if (
|
|
5460
|
-
const
|
|
5461
|
-
if (
|
|
5462
|
-
if ((a.width !== ct || a.height !== ut) && (ct = a.width, ut = a.height, Gt()), me += f,
|
|
5463
|
-
for (const y of
|
|
5474
|
+
function Zi(f) {
|
|
5475
|
+
if (zt || Je || !l.ready || f <= 0 || l.particleSystems.length === 0) return;
|
|
5476
|
+
const m = l.clock;
|
|
5477
|
+
if (m && (m.loop = l.loop ?? i, m.duration = l.getTotalDuration(), f = m.tick(f)), f > 0.1 && (f = 0.1), f <= 0) return;
|
|
5478
|
+
if ((a.width !== ct || a.height !== ut) && (ct = a.width, ut = a.height, Gt()), me += f, W.length) {
|
|
5479
|
+
for (const y of W) {
|
|
5464
5480
|
if (y.getPosition) {
|
|
5465
|
-
const
|
|
5466
|
-
|
|
5481
|
+
const w = y.getPosition();
|
|
5482
|
+
w ? (y.pos || (y.pos = y._posBuf), Array.isArray(w) ? (y.pos[0] = w[0], y.pos[1] = w[1], y.pos[2] = w[2]) : (y.pos[0] = w.x, y.pos[1] = w.y, y.pos[2] = w.z)) : y.pos = null;
|
|
5467
5483
|
}
|
|
5468
5484
|
y.vel = y._velBuf, y.pos && y.prevPos && y.wasActive && f > 0 ? (y.vel[0] = (y.pos[0] - y.prevPos[0]) / f, y.vel[1] = (y.pos[1] - y.prevPos[1]) / f, y.vel[2] = (y.pos[2] - y.prevPos[2]) / f) : (y.vel[0] = 0, y.vel[1] = 0, y.vel[2] = 0), y.justResumed = !!y.pos && !y.wasActive, y.justResumed && (y.hist.length = 0);
|
|
5469
5485
|
}
|
|
5470
|
-
for (const { system: y, config:
|
|
5471
|
-
const U = _t(
|
|
5472
|
-
if (!(!U || U.historyOnly) && (
|
|
5486
|
+
for (const { system: y, config: w } of l.particleSystems) {
|
|
5487
|
+
const U = _t(w.id);
|
|
5488
|
+
if (!(!U || U.historyOnly) && (w.hidden = !U.pos, U.pos)) {
|
|
5473
5489
|
let I = null;
|
|
5474
5490
|
if (U.orientToDirection && U.vel) {
|
|
5475
|
-
const
|
|
5476
|
-
Math.hypot(
|
|
5491
|
+
const D = U.vel[0], J = U.vel[2];
|
|
5492
|
+
Math.hypot(D, J) > 1e-4 && (I = [0, 0, Math.atan2(D, J)]);
|
|
5477
5493
|
}
|
|
5478
5494
|
y.setSimulationTransform({ position: U.pos, velocity: U.vel, rotation: I }), y.updateAppearanceUniform(), (U.justResumed || y.activeParticles === 0) && y.spawnParticles();
|
|
5479
5495
|
}
|
|
5480
5496
|
}
|
|
5481
|
-
for (const y of
|
|
5497
|
+
for (const y of W)
|
|
5482
5498
|
y.pos ? Ri(y, me) : y.hist.length = 0, y.prevPos = y.pos ? y.pos.slice() : null, y.wasActive = !!y.pos;
|
|
5483
5499
|
if (globalThis.__HZFX_DEBUG && (Vi++ & 63) === 0) {
|
|
5484
|
-
const y = l.particleSystems.reduce((
|
|
5485
|
-
console.info(`[HZFX] movingGroups(${
|
|
5500
|
+
const y = l.particleSystems.reduce((D, J) => D + (J.system.activeParticles | 0), 0), w = W.find((D) => D.pos), U = w ? Math.hypot(A.position[0] - w.pos[0], A.position[1] - w.pos[1], A.position[2] - w.pos[2]).toFixed(1) : "-", I = W.map((D) => `{ids:[${[...D.ids]}],pos:${D.pos ? "1" : "0"},hist:${D.hist.length}}`).join(",");
|
|
5501
|
+
console.info(`[HZFX] movingGroups(${W.length})=[${I}] activeParticles=${y} systems=${l.particleSystems.length} ribbonVerts=${Fe} camDist=${U} t=${me.toFixed(1)}`);
|
|
5486
5502
|
}
|
|
5487
5503
|
}
|
|
5488
|
-
if (l.updateAllSystems(f),
|
|
5489
|
-
const y = l.particleSystems.length > 0 && l.particleSystems.every(({ system:
|
|
5490
|
-
(
|
|
5504
|
+
if (l.updateAllSystems(f), m ? m.loop : l.loop ?? i) {
|
|
5505
|
+
const y = l.particleSystems.length > 0 && l.particleSystems.every(({ system: w }) => w.activeParticles === 0 && !w.emitting);
|
|
5506
|
+
(m && m.justLooped || y && lt) && l.respawnAllSystems(), lt = !y;
|
|
5491
5507
|
}
|
|
5492
|
-
for (const { system: y, config:
|
|
5493
|
-
|
|
5494
|
-
r.queue.writeBuffer(
|
|
5495
|
-
const g = l.particleSystems.some(({ config: y }) => y.bloomEnabled),
|
|
5496
|
-
let
|
|
5508
|
+
for (const { system: y, config: w } of l.particleSystems)
|
|
5509
|
+
w.glbModelEnabled && y.glbAnimator && (y.glbAnimator.update(f), y.updateAnimatedGLBBuffer());
|
|
5510
|
+
r.queue.writeBuffer(S, 0, A.mvp), Ee[0] = A.position[0], Ee[1] = A.position[1], Ee[2] = A.position[2], Ee[3] = a.height / Math.max(1, a.width), Ee[4] = me, r.queue.writeBuffer(S, 64, Ee), Ei();
|
|
5511
|
+
const g = l.particleSystems.some(({ config: y }) => y.bloomEnabled), v = r.createCommandEncoder();
|
|
5512
|
+
let H = !1;
|
|
5497
5513
|
if (e)
|
|
5498
5514
|
try {
|
|
5499
5515
|
const y = e();
|
|
5500
5516
|
if (y) {
|
|
5501
|
-
let
|
|
5502
|
-
if (y instanceof GPUTexture ? y.width === a.width && y.height === a.height && (
|
|
5503
|
-
const { pipeline:
|
|
5504
|
-
(Ce.key !==
|
|
5505
|
-
layout:
|
|
5517
|
+
let w = null, U = null, I = !1;
|
|
5518
|
+
if (y instanceof GPUTexture ? y.width === a.width && y.height === a.height && (w = y, U = () => y.createView({ aspect: "depth-only" }), I = y.sampleCount > 1) : y.view && (w = y.view, U = () => y.view, I = !!y.multisampled), w) {
|
|
5519
|
+
const { pipeline: D, layout: J } = h(I);
|
|
5520
|
+
(Ce.key !== w || Ce.ms !== I) && (Ce.key = w, Ce.ms = I, Ce.bindGroup = r.createBindGroup({
|
|
5521
|
+
layout: J,
|
|
5506
5522
|
entries: [{ binding: 0, resource: U() }]
|
|
5507
5523
|
}));
|
|
5508
|
-
const
|
|
5524
|
+
const K = v.beginRenderPass({
|
|
5509
5525
|
colorAttachments: [],
|
|
5510
5526
|
depthStencilAttachment: { view: ve.createView(), depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5511
5527
|
});
|
|
5512
|
-
|
|
5528
|
+
K.setPipeline(D), K.setBindGroup(0, Ce.bindGroup), K.draw(3), K.end(), H = !0;
|
|
5513
5529
|
}
|
|
5514
5530
|
}
|
|
5515
5531
|
} catch {
|
|
5516
5532
|
}
|
|
5517
|
-
const
|
|
5533
|
+
const j = v.beginRenderPass({
|
|
5518
5534
|
colorAttachments: [{ view: te.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5519
|
-
depthStencilAttachment:
|
|
5535
|
+
depthStencilAttachment: H ? { view: ve.createView(), depthLoadOp: "load", depthStoreOp: "store" } : { view: ve.createView(), depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5520
5536
|
});
|
|
5521
|
-
for (const { system: y, config:
|
|
5522
|
-
|
|
5523
|
-
if (
|
|
5537
|
+
for (const { system: y, config: w } of l.particleSystems)
|
|
5538
|
+
w.bloomEnabled || w.hidden || y.activeParticles === 0 || Dt(j, y, w);
|
|
5539
|
+
if (Fe > 0 && (j.setPipeline(Di), j.setBindGroup(0, Fi), j.setVertexBuffer(0, At), j.draw(Fe)), j.end(), g) {
|
|
5524
5540
|
const y = {
|
|
5525
5541
|
colorAttachments: [{ view: xe.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5526
|
-
},
|
|
5542
|
+
}, w = {
|
|
5527
5543
|
colorAttachments: [{ view: ue.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5528
5544
|
};
|
|
5529
5545
|
for (const { system: U, config: I } of l.particleSystems) {
|
|
5530
5546
|
if (!I.bloomEnabled || I.hidden || U.activeParticles === 0) continue;
|
|
5531
|
-
const
|
|
5532
|
-
colorAttachments: [{ view:
|
|
5547
|
+
const D = U.config.id, J = p.getBloomSourceTexture(D, a.width, a.height), K = v.beginRenderPass({
|
|
5548
|
+
colorAttachments: [{ view: J.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5533
5549
|
depthStencilAttachment: { view: ve.createView(), depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
5534
5550
|
});
|
|
5535
|
-
Dt(
|
|
5536
|
-
layout:
|
|
5551
|
+
Dt(K, U, I), K.end(), Ut[0] = I.bloomIntensity, r.queue.writeBuffer(x, 0, Ut), d.systemBloomHorizontalBindGroups[D] || (d.systemBloomHorizontalBindGroups[D] = r.createBindGroup({
|
|
5552
|
+
layout: he.bloomBindGroupLayout,
|
|
5537
5553
|
entries: [
|
|
5538
|
-
{ binding: 0, resource:
|
|
5539
|
-
{ binding: 1, resource:
|
|
5540
|
-
{ binding: 2, resource: { buffer:
|
|
5554
|
+
{ binding: 0, resource: re },
|
|
5555
|
+
{ binding: 1, resource: J.createView() },
|
|
5556
|
+
{ binding: 2, resource: { buffer: E } }
|
|
5541
5557
|
]
|
|
5542
5558
|
}));
|
|
5543
|
-
let
|
|
5544
|
-
|
|
5545
|
-
layout:
|
|
5559
|
+
let X = v.beginRenderPass(y);
|
|
5560
|
+
X.setPipeline($e), X.setBindGroup(0, d.systemBloomHorizontalBindGroups[D]), X.draw(3), X.end(), X = v.beginRenderPass(w), X.setPipeline($e), X.setBindGroup(0, We.verticalBlurBindGroup), X.draw(3), X.end(), d.secondHorizontalBindGroups[D] || (d.secondHorizontalBindGroups[D] = r.createBindGroup({
|
|
5561
|
+
layout: he.bloomBindGroupLayout,
|
|
5546
5562
|
entries: [
|
|
5547
|
-
{ binding: 0, resource:
|
|
5563
|
+
{ binding: 0, resource: re },
|
|
5548
5564
|
{ binding: 1, resource: ue.createView() },
|
|
5549
|
-
{ binding: 2, resource: { buffer:
|
|
5565
|
+
{ binding: 2, resource: { buffer: E } }
|
|
5550
5566
|
]
|
|
5551
|
-
})),
|
|
5552
|
-
const Ke = p.getBloomCompositeTexture(
|
|
5553
|
-
|
|
5567
|
+
})), X = v.beginRenderPass(y), X.setPipeline($e), X.setBindGroup(0, d.secondHorizontalBindGroups[D]), X.draw(3), X.end(), X = v.beginRenderPass(w), X.setPipeline($e), X.setBindGroup(0, We.verticalBlurBindGroup), X.draw(3), X.end();
|
|
5568
|
+
const Ke = p.getBloomCompositeTexture(D, a.width, a.height);
|
|
5569
|
+
X = v.beginRenderPass({
|
|
5554
5570
|
colorAttachments: [{ view: Ke.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5555
|
-
}),
|
|
5556
|
-
layout:
|
|
5571
|
+
}), X.setPipeline(Ii), d.systemBloomCompositeBindGroups[D] || (d.systemBloomCompositeBindGroups[D] = r.createBindGroup({
|
|
5572
|
+
layout: he.compositeBindGroupLayout,
|
|
5557
5573
|
entries: [
|
|
5558
|
-
{ binding: 0, resource:
|
|
5559
|
-
{ binding: 1, resource:
|
|
5574
|
+
{ binding: 0, resource: re },
|
|
5575
|
+
{ binding: 1, resource: J.createView() },
|
|
5560
5576
|
{ binding: 2, resource: ue.createView() },
|
|
5561
5577
|
{ binding: 3, resource: { buffer: U.bloomIntensityBuffer } }
|
|
5562
5578
|
]
|
|
5563
|
-
})),
|
|
5579
|
+
})), X.setBindGroup(0, d.systemBloomCompositeBindGroups[D]), X.draw(3), X.end();
|
|
5564
5580
|
}
|
|
5565
5581
|
}
|
|
5566
|
-
const
|
|
5567
|
-
colorAttachments: [{ view:
|
|
5582
|
+
const Q = p.getCombinedTexture(a.width, a.height), Z = v.beginRenderPass({
|
|
5583
|
+
colorAttachments: [{ view: Q.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5568
5584
|
});
|
|
5569
|
-
|
|
5570
|
-
layout:
|
|
5585
|
+
Z.setPipeline(Rt), d.combinedInitialBindGroup || (d.combinedInitialBindGroup = r.createBindGroup({
|
|
5586
|
+
layout: he.compositeBindGroupLayout,
|
|
5571
5587
|
entries: [
|
|
5572
|
-
{ binding: 0, resource:
|
|
5588
|
+
{ binding: 0, resource: re },
|
|
5573
5589
|
{ binding: 1, resource: te.createView() },
|
|
5574
5590
|
{ binding: 2, resource: te.createView() },
|
|
5575
|
-
{ binding: 3, resource: { buffer:
|
|
5591
|
+
{ binding: 3, resource: { buffer: x } }
|
|
5576
5592
|
]
|
|
5577
|
-
})),
|
|
5578
|
-
for (const { config: y, system:
|
|
5579
|
-
if (!y.bloomEnabled || y.hidden ||
|
|
5580
|
-
const U =
|
|
5581
|
-
|
|
5582
|
-
layout:
|
|
5593
|
+
})), Z.setBindGroup(0, d.combinedInitialBindGroup), Z.draw(3);
|
|
5594
|
+
for (const { config: y, system: w } of l.particleSystems) {
|
|
5595
|
+
if (!y.bloomEnabled || y.hidden || w.activeParticles === 0) continue;
|
|
5596
|
+
const U = w.config.id;
|
|
5597
|
+
Z.setPipeline(Rt), d.combinedBloomCompositeBindGroups[U] || (d.combinedBloomCompositeBindGroups[U] = r.createBindGroup({
|
|
5598
|
+
layout: he.compositeBindGroupLayout,
|
|
5583
5599
|
entries: [
|
|
5584
|
-
{ binding: 0, resource:
|
|
5600
|
+
{ binding: 0, resource: re },
|
|
5585
5601
|
{ binding: 1, resource: p.getBloomCompositeTexture(U, a.width, a.height).createView() },
|
|
5586
5602
|
{ binding: 2, resource: te.createView() },
|
|
5587
|
-
{ binding: 3, resource: { buffer:
|
|
5603
|
+
{ binding: 3, resource: { buffer: x } }
|
|
5588
5604
|
]
|
|
5589
|
-
})),
|
|
5605
|
+
})), Z.setBindGroup(0, d.combinedBloomCompositeBindGroups[U]), Z.draw(3);
|
|
5590
5606
|
}
|
|
5591
|
-
|
|
5592
|
-
const Ae =
|
|
5607
|
+
Z.end();
|
|
5608
|
+
const Ae = v.beginRenderPass({
|
|
5593
5609
|
colorAttachments: [{
|
|
5594
5610
|
view: n.getCurrentTexture().createView(),
|
|
5595
5611
|
loadOp: o ? "load" : "clear",
|
|
@@ -5597,117 +5613,104 @@ async function mr(s, t = {}) {
|
|
|
5597
5613
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
5598
5614
|
}]
|
|
5599
5615
|
});
|
|
5600
|
-
Ae.setPipeline(
|
|
5601
|
-
layout:
|
|
5616
|
+
Ae.setPipeline(zi), d.finalBindGroup || (d.finalBindGroup = r.createBindGroup({
|
|
5617
|
+
layout: he.compositeBindGroupLayout,
|
|
5602
5618
|
entries: [
|
|
5603
|
-
{ binding: 0, resource:
|
|
5604
|
-
{ binding: 1, resource:
|
|
5619
|
+
{ binding: 0, resource: re },
|
|
5620
|
+
{ binding: 1, resource: Q.createView() },
|
|
5605
5621
|
{ binding: 2, resource: te.createView() },
|
|
5606
|
-
{ binding: 3, resource: { buffer:
|
|
5622
|
+
{ binding: 3, resource: { buffer: x } }
|
|
5607
5623
|
]
|
|
5608
|
-
})), Ae.setBindGroup(0, d.finalBindGroup), Ae.draw(3), Ae.end(), r.queue.submit([
|
|
5609
|
-
}
|
|
5610
|
-
function Dt(f,
|
|
5611
|
-
const
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
|
|
5619
|
-
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
} else
|
|
5625
|
-
H = r.createBindGroup({
|
|
5626
|
-
layout: le.particleBindGroupLayout,
|
|
5627
|
-
entries: [
|
|
5628
|
-
{ binding: 0, resource: { buffer: b } },
|
|
5629
|
-
{ binding: 1, resource: { buffer: h.appearanceUniformBuffer } },
|
|
5630
|
-
{ binding: 2, resource: h.particleTexture.createView() },
|
|
5631
|
-
{ binding: 3, resource: ee }
|
|
5632
|
-
]
|
|
5633
|
-
});
|
|
5634
|
-
const de = S.shapeDisplay !== !1;
|
|
5635
|
-
if (J)
|
|
5636
|
-
de && (f.setPipeline(Gi), f.setBindGroup(0, H), f.setVertexBuffer(0, h.glbVertexBuffer), f.setVertexBuffer(1, h.instanceBuffer), f.setVertexBuffer(2, h.velocityBuffer), f.setIndexBuffer(h.glbIndexBuffer, h.glbIndexFormat), f.drawIndexed(h.glbIndexCount, h.activeParticles));
|
|
5624
|
+
})), Ae.setBindGroup(0, d.finalBindGroup), Ae.draw(3), Ae.end(), r.queue.submit([v.finish()]);
|
|
5625
|
+
}
|
|
5626
|
+
function Dt(f, m, b) {
|
|
5627
|
+
const g = m.config.id, v = b.glbModelEnabled && m.glbMeshData, H = !d.systemBindGroups[g] || d.textureStates[g] !== b.textureEnabled || d.textureRefs[g] !== m.particleTexture;
|
|
5628
|
+
d.textureStates[g] = b.textureEnabled, d.textureRefs[g] = m.particleTexture, H && (d.systemBindGroups[g] = r.createBindGroup({
|
|
5629
|
+
layout: he.particleBindGroupLayout,
|
|
5630
|
+
entries: [
|
|
5631
|
+
{ binding: 0, resource: { buffer: S } },
|
|
5632
|
+
{ binding: 1, resource: { buffer: m.appearanceUniformBuffer } },
|
|
5633
|
+
{ binding: 2, resource: m.particleTexture.createView() },
|
|
5634
|
+
{ binding: 3, resource: re }
|
|
5635
|
+
]
|
|
5636
|
+
}));
|
|
5637
|
+
const j = d.systemBindGroups[g], Q = b.shapeDisplay !== !1;
|
|
5638
|
+
if (v)
|
|
5639
|
+
Q && (f.setPipeline(Gi), f.setBindGroup(0, j), f.setVertexBuffer(0, m.glbVertexBuffer), f.setVertexBuffer(1, m.instanceBuffer), f.setVertexBuffer(2, m.velocityBuffer), f.setIndexBuffer(m.glbIndexBuffer, m.glbIndexFormat), f.drawIndexed(m.glbIndexCount, m.activeParticles));
|
|
5637
5640
|
else {
|
|
5638
|
-
f.setPipeline(
|
|
5639
|
-
const
|
|
5640
|
-
|
|
5641
|
+
f.setPipeline(b.blendMode === "additive" ? Ai : Ci), f.setIndexBuffer(L, "uint16"), P[g] || (P[g] = B()), f.setVertexBuffer(0, P[g]), f.setBindGroup(0, j), Q && (f.setVertexBuffer(1, m.instanceBuffer), f.setVertexBuffer(2, m.velocityBuffer), f.setVertexBuffer(3, m.trailBuffer), f.drawIndexed(6, m.activeParticles));
|
|
5642
|
+
const Z = De.get(g);
|
|
5643
|
+
Z && (f.setVertexBuffer(1, k), f.setVertexBuffer(2, G), f.setVertexBuffer(3, pe), f.drawIndexed(6, Z.count, 0, 0, Z.first)), Q && b.depthWriteEnabled && (f.setPipeline(Ui), f.drawIndexed(6, m.activeParticles));
|
|
5641
5644
|
}
|
|
5642
5645
|
}
|
|
5643
|
-
function
|
|
5646
|
+
function $i() {
|
|
5644
5647
|
ct = a.width, ut = a.height, Gt();
|
|
5645
5648
|
}
|
|
5646
|
-
function
|
|
5649
|
+
function Wi() {
|
|
5647
5650
|
d.clear();
|
|
5648
5651
|
}
|
|
5649
|
-
function
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5652
|
+
function Ji() {
|
|
5653
|
+
zt = !0, l.destroy(), [te, xe, ue, ve].forEach((f) => f == null ? void 0 : f.destroy()), p.resizeTextures(), [
|
|
5654
|
+
S,
|
|
5655
|
+
R,
|
|
5656
|
+
E,
|
|
5653
5657
|
T,
|
|
5654
|
-
|
|
5655
|
-
_,
|
|
5658
|
+
x,
|
|
5656
5659
|
L,
|
|
5657
5660
|
k,
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
].forEach((f) => f == null ? void 0 : f.destroy()), Object.values(
|
|
5661
|
+
G,
|
|
5662
|
+
pe
|
|
5663
|
+
].forEach((f) => f == null ? void 0 : f.destroy()), Object.values(P).forEach((f) => f == null ? void 0 : f.destroy());
|
|
5661
5664
|
}
|
|
5662
|
-
async function
|
|
5663
|
-
const
|
|
5665
|
+
async function Ft(f, m) {
|
|
5666
|
+
const b = await l.addSystems(f, m);
|
|
5664
5667
|
for (const { config: g } of l.particleSystems)
|
|
5665
|
-
|
|
5666
|
-
return l.respawnAllSystems(), new Set(Array.isArray(
|
|
5668
|
+
P[g.id] || (P[g.id] = B());
|
|
5669
|
+
return l.respawnAllSystems(), new Set(Array.isArray(b) ? b : []);
|
|
5667
5670
|
}
|
|
5668
5671
|
function Vt(f) {
|
|
5669
|
-
for (const
|
|
5670
|
-
const
|
|
5671
|
-
|
|
5672
|
+
for (const m of f) {
|
|
5673
|
+
const b = l.particleSystems.findIndex((g) => g.config.id === m);
|
|
5674
|
+
b >= 0 && l.removeSystem(b);
|
|
5672
5675
|
}
|
|
5673
5676
|
}
|
|
5674
|
-
async function
|
|
5675
|
-
const
|
|
5677
|
+
async function Qi(f, m = [0, 0, 0]) {
|
|
5678
|
+
const b = await Ft(f, m);
|
|
5676
5679
|
return { remove() {
|
|
5677
|
-
Vt(
|
|
5680
|
+
Vt(b);
|
|
5678
5681
|
} };
|
|
5679
5682
|
}
|
|
5680
|
-
async function
|
|
5681
|
-
const
|
|
5682
|
-
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(f && f.systems || []).length} newIds=[${[...
|
|
5683
|
-
const g = { ids:
|
|
5684
|
-
return
|
|
5685
|
-
setPosition(
|
|
5686
|
-
|
|
5683
|
+
async function Ki(f, m = {}) {
|
|
5684
|
+
const b = await Ft(f, [0, 0, 0]);
|
|
5685
|
+
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(f && f.systems || []).length} newIds=[${[...b]}]`);
|
|
5686
|
+
const g = { ids: b, pos: null, hist: [], getPosition: m.getPosition || null, orientToDirection: !!m.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0] };
|
|
5687
|
+
return W.push(g), {
|
|
5688
|
+
setPosition(v) {
|
|
5689
|
+
v && (g.pos = Array.isArray(v) ? [v[0], v[1], v[2]] : [v.x, v.y, v.z]);
|
|
5687
5690
|
},
|
|
5688
|
-
setOrientToDirection(
|
|
5689
|
-
g.orientToDirection = !!
|
|
5691
|
+
setOrientToDirection(v) {
|
|
5692
|
+
g.orientToDirection = !!v;
|
|
5690
5693
|
},
|
|
5691
5694
|
remove() {
|
|
5692
|
-
Vt(
|
|
5693
|
-
const
|
|
5694
|
-
|
|
5695
|
+
Vt(b);
|
|
5696
|
+
const v = W.indexOf(g);
|
|
5697
|
+
v >= 0 && W.splice(v, 1);
|
|
5695
5698
|
}
|
|
5696
5699
|
};
|
|
5697
5700
|
}
|
|
5698
|
-
function
|
|
5699
|
-
const g = { ids: f instanceof Set ? f : new Set(f), pos: null, hist: [], getPosition:
|
|
5700
|
-
return
|
|
5701
|
+
function es(f, m) {
|
|
5702
|
+
const g = { ids: f instanceof Set ? f : new Set(f), pos: null, hist: [], getPosition: m, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0] };
|
|
5703
|
+
return W.push(g), {
|
|
5701
5704
|
remove() {
|
|
5702
|
-
const
|
|
5703
|
-
|
|
5705
|
+
const v = W.indexOf(g);
|
|
5706
|
+
v >= 0 && W.splice(v, 1);
|
|
5704
5707
|
},
|
|
5705
5708
|
// Update which systems this history group covers WITHOUT losing the accumulated path
|
|
5706
5709
|
// history. Needed when the scene's systems change (e.g. duplicate/add/remove) while the
|
|
5707
5710
|
// group is active — otherwise a newly-added system's id isn't in the set and its trail
|
|
5708
5711
|
// can't follow the recorded movement path (it falls back to straight extrapolation).
|
|
5709
|
-
setIds(
|
|
5710
|
-
g.ids =
|
|
5712
|
+
setIds(v) {
|
|
5713
|
+
g.ids = v instanceof Set ? v : new Set(v);
|
|
5711
5714
|
}
|
|
5712
5715
|
};
|
|
5713
5716
|
}
|
|
@@ -5715,28 +5718,28 @@ async function mr(s, t = {}) {
|
|
|
5715
5718
|
manager: l,
|
|
5716
5719
|
device: r,
|
|
5717
5720
|
context: n,
|
|
5718
|
-
setCamera:
|
|
5719
|
-
setCameraMVP:
|
|
5721
|
+
setCamera: Yi,
|
|
5722
|
+
setCameraMVP: Hi,
|
|
5720
5723
|
setEmitters: dt,
|
|
5721
|
-
loadPreset:
|
|
5722
|
-
addEmitter:
|
|
5723
|
-
addMovingEmitter:
|
|
5724
|
-
render:
|
|
5725
|
-
resize:
|
|
5726
|
-
clearCaches:
|
|
5727
|
-
trackHistoryGroup:
|
|
5728
|
-
destroy:
|
|
5724
|
+
loadPreset: qi,
|
|
5725
|
+
addEmitter: Qi,
|
|
5726
|
+
addMovingEmitter: Ki,
|
|
5727
|
+
render: Zi,
|
|
5728
|
+
resize: $i,
|
|
5729
|
+
clearCaches: Wi,
|
|
5730
|
+
trackHistoryGroup: es,
|
|
5731
|
+
destroy: Ji
|
|
5729
5732
|
};
|
|
5730
5733
|
}
|
|
5731
|
-
function
|
|
5734
|
+
function br(s) {
|
|
5732
5735
|
return () => {
|
|
5733
5736
|
var t, e, i, r, n, a;
|
|
5734
5737
|
try {
|
|
5735
5738
|
const o = s.backend;
|
|
5736
5739
|
if (!o) return null;
|
|
5737
5740
|
if (s.needsFrameBufferTarget && s._frameBufferTarget) {
|
|
5738
|
-
const u = (i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, s._frameBufferTarget)) == null ? void 0 : i.depthTexture,
|
|
5739
|
-
if (
|
|
5741
|
+
const u = (i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, s._frameBufferTarget)) == null ? void 0 : i.depthTexture, h = u ? (r = o.get(u)) == null ? void 0 : r.texture : null;
|
|
5742
|
+
if (h && h.width === s.domElement.width && h.height === s.domElement.height) return h;
|
|
5740
5743
|
}
|
|
5741
5744
|
const c = s.getCanvasTarget ? o.get(s.getCanvasTarget()) : null, l = ((a = (n = c == null ? void 0 : c.descriptor) == null ? void 0 : n.depthStencilAttachment) == null ? void 0 : a.view) ?? null;
|
|
5742
5745
|
return l ? { view: l, multisampled: (s.currentSamples ?? 0) > 1 } : null;
|
|
@@ -5746,46 +5749,46 @@ function yr(s) {
|
|
|
5746
5749
|
};
|
|
5747
5750
|
}
|
|
5748
5751
|
export {
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
|
|
5752
|
+
Os as GLBAnimator,
|
|
5753
|
+
Ls as HZClock,
|
|
5754
|
+
cr as Objects3DManager,
|
|
5755
|
+
fs as ParticleEmitter,
|
|
5756
|
+
xs as ParticlePhysics,
|
|
5757
|
+
ni as ParticleScript,
|
|
5755
5758
|
bt as ParticleSystem,
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5759
|
+
Hs as ParticleSystemManager,
|
|
5760
|
+
vs as ParticleTextureManager,
|
|
5761
|
+
hs as blurShader,
|
|
5762
|
+
ms as compositeShader,
|
|
5763
|
+
Ws as createBindGroupLayouts,
|
|
5761
5764
|
St as createBindGroups,
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5765
|
+
Ge as createBuffer,
|
|
5766
|
+
Ks as createCubeGeometry,
|
|
5767
|
+
hi as createDepthTexture,
|
|
5768
|
+
fr as createLookAtMatrix,
|
|
5769
|
+
pr as createProjectionMatrix,
|
|
5770
|
+
Js as createRenderPipelines,
|
|
5771
|
+
pi as createRenderTextures,
|
|
5772
|
+
Qs as createSampler,
|
|
5773
|
+
er as createSphereGeometry,
|
|
5774
|
+
ys as directRenderShader,
|
|
5775
|
+
oi as extractGLBTexture,
|
|
5776
|
+
yr as fetchPreset,
|
|
5777
|
+
$s as glbMeshParticleShader,
|
|
5778
|
+
ur as hexToRgb,
|
|
5779
|
+
gr as initHzFxOverlay,
|
|
5780
|
+
qs as initWebGPU,
|
|
5778
5781
|
Bi as isHZFX,
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5782
|
+
mr as loadScene,
|
|
5783
|
+
br as makeThreeSceneDepth,
|
|
5784
|
+
ir as multiplyMatrices,
|
|
5785
|
+
Zs as object3dShader,
|
|
5786
|
+
rr as packHZFX,
|
|
5784
5787
|
Rs as parseGLB,
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5788
|
+
bs as particlePhysicsShader,
|
|
5789
|
+
ps as particleShader,
|
|
5790
|
+
dr as rgbToHex,
|
|
5791
|
+
hr as saveScene,
|
|
5792
|
+
ar as serializeSystemConfig,
|
|
5793
|
+
Mi as unpackHZFX
|
|
5791
5794
|
};
|