hz-particles 1.4.2 → 1.5.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 +12 -4
- package/dist-lib/hz-particles-r3f.cjs +2 -2
- package/dist-lib/hz-particles-r3f.mjs +203 -174
- package/dist-lib/hz-particles.cjs +160 -28
- package/dist-lib/hz-particles.d.ts +11 -3
- package/dist-lib/hz-particles.mjs +1327 -978
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class ks {
|
|
2
2
|
constructor(t = {}) {
|
|
3
3
|
this.config = t, this._posOut = [0, 0, 0], this._rotMatrix = null, this._invRotMatrix = null, this._cachedRotX = void 0, this._cachedRotY = void 0, this._cachedRotZ = void 0;
|
|
4
4
|
}
|
|
@@ -10,15 +10,15 @@ class ms {
|
|
|
10
10
|
if (t === this._cachedRotX && e === this._cachedRotY && i === this._cachedRotZ)
|
|
11
11
|
return;
|
|
12
12
|
this._cachedRotX = t, this._cachedRotY = e, this._cachedRotZ = i;
|
|
13
|
-
const r = t * Math.PI / 180, n = e * Math.PI / 180, a = i * Math.PI / 180, o = Math.cos(r), c = Math.sin(r), l = Math.cos(n),
|
|
13
|
+
const r = t * Math.PI / 180, n = e * Math.PI / 180, a = i * Math.PI / 180, o = Math.cos(r), c = Math.sin(r), l = Math.cos(n), d = Math.sin(n), S = Math.cos(a), g = Math.sin(a);
|
|
14
14
|
this._rotMatrix = [
|
|
15
|
-
l *
|
|
16
|
-
c *
|
|
17
|
-
o *
|
|
18
|
-
l *
|
|
19
|
-
c *
|
|
20
|
-
o *
|
|
21
|
-
-
|
|
15
|
+
l * S,
|
|
16
|
+
c * d * S - o * g,
|
|
17
|
+
o * d * S + c * g,
|
|
18
|
+
l * g,
|
|
19
|
+
c * d * g + o * S,
|
|
20
|
+
o * d * g - c * S,
|
|
21
|
+
-d,
|
|
22
22
|
c * l,
|
|
23
23
|
o * l
|
|
24
24
|
], this._invRotMatrix = [
|
|
@@ -35,10 +35,10 @@ class ms {
|
|
|
35
35
|
}
|
|
36
36
|
emitParticle(t, e, i) {
|
|
37
37
|
const r = this._posOut;
|
|
38
|
-
if (this.config.emissionShape === "cube" || this.config.emissionShape === "box" ? this._emitFromCube(r) : this.config.emissionShape === "sphere" ? this._emitFromSphere(r) : this.config.emissionShape === "square" ? this._emitFromSquare(r) : this.config.emissionShape === "circle" ? this._emitFromCircle(r) : this.config.emissionShape === "cylinder" ? this._emitFromCylinder(r) : this.config.emissionShape === "plain" ? this._emitFromPlain(r) : this.config.emissionShape === "cone" ? this._emitFromCone(r) : this.config.emissionShape === "torus" ? this._emitFromTorus(r) : this.config.emissionShape === "line" ? this._emitFromLine(r) : this.config.emissionShape === "hemisphere" ? this._emitFromHemisphere(r) : this.config.emissionShape === "disc" ? this._emitFromDisc(r) : this.config.emissionShape === "annulus" ? this._emitFromAnnulus(r) : this.config.emissionShape === "capsule" ? this._emitFromCapsule(r) : this.config.emissionShape === "arc" ? this._emitFromArc(r) : this.config.emissionShape === "spiral" ? this._emitFromSpiral(r) : this.config.emissionShape === "frustum" ? this._emitFromFrustum(r) : this.config.emissionShape === "cubeSurface" ? this._emitFromCubeSurface(r) : this.config.emissionShape === "sphereSurface" ? this._emitFromSphereSurface(r) : this.config.emissionShape === "boxFrame" ? this._emitFromBoxFrame(r) : this.config.emissionShape === "polygon" ? this._emitFromPolygon(r) : this.config.emissionShape === "rectangle" ? this._emitFromRectangle(r) : (r[0] = 0, r[1] = 0, r[2] = 0), this.config.emissionRotationX || this.config.emissionRotationY || this.config.emissionRotationZ) {
|
|
38
|
+
if (this.config.emissionShape === "cube" || this.config.emissionShape === "box" ? this._emitFromCube(r) : this.config.emissionShape === "sphere" ? this._emitFromSphere(r) : this.config.emissionShape === "square" ? this._emitFromSquare(r) : this.config.emissionShape === "circle" ? this._emitFromCircle(r) : this.config.emissionShape === "cylinder" ? this._emitFromCylinder(r) : this.config.emissionShape === "plain" ? this._emitFromPlain(r) : this.config.emissionShape === "cone" ? this._emitFromCone(r) : this.config.emissionShape === "torus" ? this._emitFromTorus(r) : this.config.emissionShape === "line" ? this._emitFromLine(r) : this.config.emissionShape === "hemisphere" ? this._emitFromHemisphere(r) : this.config.emissionShape === "disc" ? this._emitFromDisc(r) : this.config.emissionShape === "annulus" ? this._emitFromAnnulus(r) : this.config.emissionShape === "capsule" ? this._emitFromCapsule(r) : this.config.emissionShape === "arc" ? this._emitFromArc(r) : this.config.emissionShape === "spiral" ? this._emitFromSpiral(r) : this.config.emissionShape === "frustum" ? this._emitFromFrustum(r) : this.config.emissionShape === "frustumSurface" ? this._emitFromFrustumSurface(r) : this.config.emissionShape === "cubeSurface" ? this._emitFromCubeSurface(r) : this.config.emissionShape === "sphereSurface" ? this._emitFromSphereSurface(r) : this.config.emissionShape === "boxFrame" ? this._emitFromBoxFrame(r) : this.config.emissionShape === "polygon" ? this._emitFromPolygon(r) : this.config.emissionShape === "rectangle" ? this._emitFromRectangle(r) : (r[0] = 0, r[1] = 0, r[2] = 0), this.config.emissionRotationX || this.config.emissionRotationY || this.config.emissionRotationZ) {
|
|
39
39
|
this._updateRotationMatrix();
|
|
40
|
-
const o = this._rotMatrix, c = r[0], l = r[1],
|
|
41
|
-
r[0] = o[0] * c + o[1] * l + o[2] *
|
|
40
|
+
const o = this._rotMatrix, c = r[0], l = r[1], d = r[2];
|
|
41
|
+
r[0] = o[0] * c + o[1] * l + o[2] * d, r[1] = o[3] * c + o[4] * l + o[5] * d, r[2] = o[6] * c + o[7] * l + o[8] * d;
|
|
42
42
|
}
|
|
43
43
|
(this.config.emissionPositionX || this.config.emissionPositionY || this.config.emissionPositionZ) && (r[0] += this.config.emissionPositionX || 0, r[1] += this.config.emissionPositionY || 0, r[2] += this.config.emissionPositionZ || 0);
|
|
44
44
|
const n = e * 8;
|
|
@@ -91,8 +91,8 @@ class ms {
|
|
|
91
91
|
o = n, c = -0.5, l = a;
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
|
-
const
|
|
95
|
-
t[0] = o *
|
|
94
|
+
const d = Math.random(), S = e + d * (i - e);
|
|
95
|
+
t[0] = o * S, t[1] = c * S, t[2] = l * S;
|
|
96
96
|
} else
|
|
97
97
|
t[0] = (Math.random() - 0.5) * i, t[1] = (Math.random() - 0.5) * i, t[2] = (Math.random() - 0.5) * i;
|
|
98
98
|
}
|
|
@@ -137,8 +137,8 @@ class ms {
|
|
|
137
137
|
const e = this.config.coneInnerRadius || 0, i = this.config.coneOuterRadius || 2, r = this.config.coneHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r, c = i * (1 - a);
|
|
138
138
|
let l;
|
|
139
139
|
if (e > 0) {
|
|
140
|
-
const
|
|
141
|
-
l =
|
|
140
|
+
const d = e * (1 - a);
|
|
141
|
+
l = d + (c - d) * Math.random();
|
|
142
142
|
} else
|
|
143
143
|
l = c * Math.sqrt(Math.random());
|
|
144
144
|
t[0] = Math.cos(n) * l, t[1] = o, t[2] = Math.sin(n) * l;
|
|
@@ -170,8 +170,8 @@ class ms {
|
|
|
170
170
|
const c = Math.random() * Math.PI * 2, l = e * Math.sqrt(Math.random());
|
|
171
171
|
t[0] = Math.cos(c) * l, t[1] = (Math.random() - 0.5) * i, t[2] = Math.sin(c) * l;
|
|
172
172
|
} else {
|
|
173
|
-
const c = Math.random() * Math.PI * 2, l = Math.acos(2 * Math.random() - 1),
|
|
174
|
-
t[0] =
|
|
173
|
+
const c = Math.random() * Math.PI * 2, l = Math.acos(2 * Math.random() - 1), d = e * Math.cbrt(Math.random());
|
|
174
|
+
t[0] = d * Math.sin(l) * Math.cos(c), t[1] = d * Math.cos(l), t[2] = d * Math.sin(l) * Math.sin(c), t[1] += t[1] >= 0 ? r : -r;
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
_emitFromArc(t) {
|
|
@@ -187,6 +187,18 @@ class ms {
|
|
|
187
187
|
const e = this.config.frustumRadiusNear || 0.5, i = this.config.frustumRadiusFar || 2, r = this.config.frustumHeight || 4, n = Math.random() * Math.PI * 2, a = Math.random(), o = a * r, l = (e + (i - e) * a) * Math.sqrt(Math.random());
|
|
188
188
|
t[0] = Math.cos(n) * l, t[1] = o, t[2] = Math.sin(n) * l;
|
|
189
189
|
}
|
|
190
|
+
_emitFromFrustumSurface(t) {
|
|
191
|
+
const e = this.config.frustumRadiusNear ?? 0.5, i = this.config.frustumRadiusFar ?? 2, r = this.config.frustumHeight ?? 4, n = Math.random() * Math.PI * 2, a = i - e, o = e + a * 0.5;
|
|
192
|
+
let c;
|
|
193
|
+
if (Math.abs(a) < 1e-6 || o <= 1e-6)
|
|
194
|
+
c = Math.random();
|
|
195
|
+
else {
|
|
196
|
+
const S = Math.random(), g = 0.5 * a, p = e, v = -S * o, A = Math.max(0, p * p - 4 * g * v);
|
|
197
|
+
c = (-p + Math.sqrt(A)) / (2 * g), Number.isFinite(c) || (c = Math.random()), c = Math.min(1, Math.max(0, c));
|
|
198
|
+
}
|
|
199
|
+
const l = c * r, d = e + a * c;
|
|
200
|
+
t[0] = Math.cos(n) * d, t[1] = l, t[2] = Math.sin(n) * d;
|
|
201
|
+
}
|
|
190
202
|
_emitFromCubeSurface(t) {
|
|
191
203
|
const e = this.config.cubeSurfaceSize || 2, i = e * 0.5, r = Math.floor(Math.random() * 6), n = (Math.random() - 0.5) * e, a = (Math.random() - 0.5) * e;
|
|
192
204
|
switch (r) {
|
|
@@ -231,8 +243,8 @@ class ms {
|
|
|
231
243
|
const e = Math.max(3, Math.floor(this.config.polygonSides || 6)), i = this.config.polygonRadius || 2, r = Math.floor(Math.random() * e), n = r / e * Math.PI * 2, a = (r + 1) / e * Math.PI * 2;
|
|
232
244
|
let o = Math.random(), c = Math.random();
|
|
233
245
|
o + c > 1 && (o = 1 - o, c = 1 - c);
|
|
234
|
-
const l = o * Math.cos(n) + c * Math.cos(a),
|
|
235
|
-
t[0] = l * i, t[1] =
|
|
246
|
+
const l = o * Math.cos(n) + c * Math.cos(a), d = o * Math.sin(n) + c * Math.sin(a);
|
|
247
|
+
t[0] = l * i, t[1] = d * i, t[2] = 0;
|
|
236
248
|
}
|
|
237
249
|
_emitFromRectangle(t) {
|
|
238
250
|
const e = this.config.rectangleWidth || 2, i = this.config.rectangleHeight || 2;
|
|
@@ -244,33 +256,33 @@ class ms {
|
|
|
244
256
|
e > 0 ? a = e + (i - e) * Math.random() : a = i * Math.sqrt(Math.random()), t[0] = Math.cos(n) * a, t[1] = (Math.random() - 0.5) * r, t[2] = Math.sin(n) * a;
|
|
245
257
|
}
|
|
246
258
|
calculateVelocity(t, e, i, r, n) {
|
|
247
|
-
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a,
|
|
248
|
-
let
|
|
249
|
-
if (
|
|
250
|
-
let
|
|
259
|
+
const a = this.config.emissionPositionX || 0, o = this.config.emissionPositionY || 0, c = this.config.emissionPositionZ || 0, l = t - a, d = e - o, S = i - c, g = Math.sqrt(l * l + d * d + S * S);
|
|
260
|
+
let p, v, A;
|
|
261
|
+
if (g > 1e-4) {
|
|
262
|
+
let I = !1;
|
|
251
263
|
if (this.config.emissionShape === "circle" && this.config.circleVelocityDirection === "tangential") {
|
|
252
|
-
const
|
|
253
|
-
if (
|
|
254
|
-
const
|
|
255
|
-
|
|
264
|
+
const _ = this.inverseRotation(l, d, S), $ = Math.sqrt(_[0] * _[0] + _[1] * _[1]);
|
|
265
|
+
if ($ > 1e-4) {
|
|
266
|
+
const T = -_[1] / $, z = _[0] / $, F = this.applyRotation(T, z, 0);
|
|
267
|
+
p = F[0], v = F[1], A = F[2], I = !0;
|
|
256
268
|
}
|
|
257
269
|
} else if (this.config.emissionShape === "cylinder" && this.config.cylinderVelocityDirection === "tangential") {
|
|
258
|
-
const
|
|
259
|
-
if (
|
|
260
|
-
const
|
|
261
|
-
|
|
270
|
+
const _ = this.inverseRotation(l, d, S), $ = Math.sqrt(_[0] * _[0] + _[2] * _[2]);
|
|
271
|
+
if ($ > 1e-4) {
|
|
272
|
+
const T = -_[2] / $, z = _[0] / $, F = this.applyRotation(T, 0, z);
|
|
273
|
+
p = F[0], v = F[1], A = F[2], I = !0;
|
|
262
274
|
} else {
|
|
263
|
-
const
|
|
264
|
-
|
|
275
|
+
const T = Math.random() * Math.PI * 2, z = this.applyRotation(Math.cos(T), 0, Math.sin(T));
|
|
276
|
+
p = z[0], v = z[1], A = z[2], I = !0;
|
|
265
277
|
}
|
|
266
278
|
}
|
|
267
|
-
|
|
279
|
+
I || (p = l / g, v = d / g, A = S / g);
|
|
268
280
|
} else {
|
|
269
|
-
const
|
|
270
|
-
|
|
281
|
+
const I = Math.random() * Math.PI * 2, _ = Math.acos(2 * Math.random() - 1);
|
|
282
|
+
p = Math.sin(_) * Math.cos(I), v = Math.sin(_) * Math.sin(I), A = Math.cos(_);
|
|
271
283
|
}
|
|
272
|
-
let
|
|
273
|
-
this.config.randomSpeed ?
|
|
284
|
+
let U;
|
|
285
|
+
this.config.randomSpeed ? U = (this.config.minSpeed || 0) + Math.random() * ((this.config.maxSpeed || 1) - (this.config.minSpeed || 0)) : U = this.config.particleSpeed, r[n] = this.config.overrideXVelocity ? this.config.xVelocity : p * U, r[n + 1] = this.config.overrideYVelocity ? this.config.yVelocity : v * U, r[n + 2] = this.config.overrideZVelocity ? this.config.zVelocity : A * U, r[n + 3] = 0;
|
|
274
286
|
}
|
|
275
287
|
setParticleColor(t, e) {
|
|
276
288
|
if (this.config.randomColorEnabled && this.config.randomColors.length > 0) {
|
|
@@ -283,7 +295,7 @@ class ms {
|
|
|
283
295
|
t[e + 6] = 0, t[e + 7] = i + (Math.random() * 0.4 - 0.2) * i;
|
|
284
296
|
}
|
|
285
297
|
}
|
|
286
|
-
const
|
|
298
|
+
const Xs = `
|
|
287
299
|
struct Uniforms {
|
|
288
300
|
transform: mat4x4<f32>,
|
|
289
301
|
cameraPosition: vec3<f32>,
|
|
@@ -380,7 +392,7 @@ const ys = `
|
|
|
380
392
|
}
|
|
381
393
|
|
|
382
394
|
@vertex
|
|
383
|
-
fn vs_main(input: VertexInput) -> VertexOutput {
|
|
395
|
+
fn vs_main(input: VertexInput, @builtin(instance_index) instanceIdx: u32) -> VertexOutput {
|
|
384
396
|
var output : VertexOutput;
|
|
385
397
|
|
|
386
398
|
let center = input.particlePosition + appearance.systemOffset;
|
|
@@ -412,10 +424,11 @@ const ys = `
|
|
|
412
424
|
// Determine particle size - use random size if enabled
|
|
413
425
|
var particleSizeFactor = appearance.particleSize;
|
|
414
426
|
if (appearance.randomSize > 0.5) {
|
|
415
|
-
//
|
|
416
|
-
//
|
|
417
|
-
|
|
418
|
-
|
|
427
|
+
// Seed from the PARTICLE INDEX (stable per slot, unique per particle) so each particle in an
|
|
428
|
+
// emission gets its own size. The old seed used lifetime, which is identical for every
|
|
429
|
+
// particle of an emission, so they all came out the SAME size (most visible in burst mode).
|
|
430
|
+
particleSizeFactor = appearance.minSize +
|
|
431
|
+
fract(sin(f32(instanceIdx) * 12.9898 + 78.233) * 43758.5453) *
|
|
419
432
|
(appearance.maxSize - appearance.minSize);
|
|
420
433
|
}
|
|
421
434
|
|
|
@@ -448,10 +461,11 @@ const ys = `
|
|
|
448
461
|
// Create a unique rotation value for each particle
|
|
449
462
|
var particleRotation = appearance.rotation;
|
|
450
463
|
if (appearance.rotationMode == 1.0) {
|
|
451
|
-
//
|
|
452
|
-
//
|
|
453
|
-
|
|
454
|
-
|
|
464
|
+
// Per-particle seed (particle index) — same fix as random size (was seeded on lifetime,
|
|
465
|
+
// identical across an emission, so every particle shared one rotation). Distinct hash constants
|
|
466
|
+
// from size so a particle's size and rotation aren't correlated.
|
|
467
|
+
particleRotation = appearance.minRotation +
|
|
468
|
+
fract(sin(f32(instanceIdx) * 63.746 + 11.135) * 43758.5453) *
|
|
455
469
|
(appearance.maxRotation - appearance.minRotation);
|
|
456
470
|
} else if (appearance.rotationMode == 2.0) {
|
|
457
471
|
// Calculate rotation based on velocity direction in screen space. Use the COMBINED velocity
|
|
@@ -705,7 +719,7 @@ const ys = `
|
|
|
705
719
|
return vec4<f32>(input.color, alpha);
|
|
706
720
|
}
|
|
707
721
|
}
|
|
708
|
-
`,
|
|
722
|
+
`, Ns = `
|
|
709
723
|
struct BloomUniforms {
|
|
710
724
|
direction: vec2<f32>,
|
|
711
725
|
resolution: vec2<f32>,
|
|
@@ -765,7 +779,7 @@ const ys = `
|
|
|
765
779
|
|
|
766
780
|
return result / totalWeight * 1.1;
|
|
767
781
|
}
|
|
768
|
-
`,
|
|
782
|
+
`, Ys = `
|
|
769
783
|
struct BloomIntensityUniforms {
|
|
770
784
|
intensity: f32,
|
|
771
785
|
color: vec3<f32>,
|
|
@@ -811,7 +825,7 @@ const ys = `
|
|
|
811
825
|
|
|
812
826
|
return vec4<f32>(originalColor.rgb + (mappedBloom * bloomUniforms.intensity), originalColor.a);
|
|
813
827
|
}
|
|
814
|
-
`,
|
|
828
|
+
`, js = `
|
|
815
829
|
struct BloomIntensityUniforms {
|
|
816
830
|
intensity: f32,
|
|
817
831
|
color: vec3<f32>,
|
|
@@ -852,7 +866,7 @@ const ys = `
|
|
|
852
866
|
fn fs_main(input: VertexOutput) -> @location(0) vec4<f32> {
|
|
853
867
|
return textureSample(originalTexture, texSampler, input.texCoord);
|
|
854
868
|
}
|
|
855
|
-
`,
|
|
869
|
+
`, qs = `
|
|
856
870
|
@binding(0) @group(0) var texSampler: sampler;
|
|
857
871
|
@binding(1) @group(0) var originalTexture: texture_2d<f32>;
|
|
858
872
|
@binding(2) @group(0) var blurredTexture: texture_2d<f32>;
|
|
@@ -884,7 +898,7 @@ const ys = `
|
|
|
884
898
|
let c = textureSample(originalTexture, texSampler, input.texCoord);
|
|
885
899
|
return vec4<f32>(aces(c.rgb), c.a);
|
|
886
900
|
}
|
|
887
|
-
`,
|
|
901
|
+
`, Hs = `
|
|
888
902
|
struct PhysicsUniforms {
|
|
889
903
|
deltaTime: f32,
|
|
890
904
|
particleSpeed: f32,
|
|
@@ -975,7 +989,7 @@ const ys = `
|
|
|
975
989
|
}
|
|
976
990
|
|
|
977
991
|
// 2. Attractor
|
|
978
|
-
if (physics.attractorStrength
|
|
992
|
+
if (physics.attractorStrength != 0.0) {
|
|
979
993
|
let attractorPos = vec3<f32>(physics.attractorPositionX, physics.attractorPositionY, physics.attractorPositionZ);
|
|
980
994
|
let toAttractor = attractorPos - vec3<f32>(posX, posY, posZ);
|
|
981
995
|
let dist = length(toAttractor);
|
|
@@ -1094,7 +1108,7 @@ const ys = `
|
|
|
1094
1108
|
particleBuffer[baseIndex + 1u] = newPos.y;
|
|
1095
1109
|
particleBuffer[baseIndex + 2u] = newPos.z;
|
|
1096
1110
|
}
|
|
1097
|
-
`,
|
|
1111
|
+
`, Zs = `
|
|
1098
1112
|
@group(0) @binding(0) var<storage, read> restData: array<f32>;
|
|
1099
1113
|
@group(0) @binding(1) var<storage, read> jointWeightsData: array<f32>;
|
|
1100
1114
|
@group(0) @binding(2) var<storage, read> jointIndicesData: array<u32>;
|
|
@@ -1151,7 +1165,7 @@ const ys = `
|
|
|
1151
1165
|
outputData[outBase + 7u] = uv_v;
|
|
1152
1166
|
}
|
|
1153
1167
|
`;
|
|
1154
|
-
class
|
|
1168
|
+
class $s {
|
|
1155
1169
|
constructor(t, e = 1e4) {
|
|
1156
1170
|
this.device = t, this.physicsSettings = {
|
|
1157
1171
|
deltaTime: 0.016,
|
|
@@ -1240,7 +1254,7 @@ class _s {
|
|
|
1240
1254
|
}),
|
|
1241
1255
|
compute: {
|
|
1242
1256
|
module: this.device.createShaderModule({
|
|
1243
|
-
code:
|
|
1257
|
+
code: Hs
|
|
1244
1258
|
}),
|
|
1245
1259
|
entryPoint: "main"
|
|
1246
1260
|
}
|
|
@@ -1271,10 +1285,10 @@ class _s {
|
|
|
1271
1285
|
return;
|
|
1272
1286
|
const o = this._physicsData, c = this.physicsSettings;
|
|
1273
1287
|
o[0] = t, o[1] = i.particleSpeed, o[2] = c.gravity, o[3] = c.turbulence, o[4] = c.attractorStrength, o[5] = c.damping, o[6] = c.attractorPosition[0], o[7] = c.attractorPosition[1], o[8] = c.attractorPosition[2], this._physicsDataU32View[9] = e, o[10] = c.confinementEnabled ? 1 : 0, o[11] = c.confinementShape === "sphere" ? 1 : 0, o[12] = c.confinementMode === "kill" ? 1 : 0, o[13] = c.confinementSpace === "local" ? 1 : 0, o[14] = c.confinementBoxHalfSize[0], o[15] = c.confinementBoxHalfSize[1], o[16] = c.confinementBoxHalfSize[2], o[17] = c.confinementSphereRadius, o[18] = c.confinementRestitution, o[19] = c.confinementFriction, o[20] = c.confinementCenter[0], o[21] = c.confinementCenter[1], o[22] = c.confinementCenter[2], o[23] = c.softBoundaryEnabled ? 1 : 0, o[24] = c.softBoundaryStrength, o[25] = c.softBoundaryFalloff, o[26] = i.velocityStretchEnabled ? 1 : 0, o[27] = i.velocityStretchFactor ?? 1, o[28] = 0, o[29] = 0, o[30] = 0, o[31] = 0, this.device.queue.writeBuffer(this.physicsUniformBuffer, 0, o);
|
|
1274
|
-
const l = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }),
|
|
1275
|
-
|
|
1276
|
-
const
|
|
1277
|
-
|
|
1288
|
+
const l = a || this.device.createCommandEncoder({ label: "ParticlePhysicsEncoder" }), d = l.beginComputePass({ label: "ParticlePhysicsPass" });
|
|
1289
|
+
d.setPipeline(this.computePipeline), d.setBindGroup(0, this.computeBindGroup);
|
|
1290
|
+
const S = Math.max(1, Math.ceil(e / 64));
|
|
1291
|
+
d.dispatchWorkgroups(S, 1, 1), d.end(), a || this.device.queue.submit([l.finish()]), this.lastUpdateTime = performance.now() / 1e3;
|
|
1278
1292
|
}
|
|
1279
1293
|
async readbackAndProcessParticles(t, e, i, r, n) {
|
|
1280
1294
|
if (t <= 0)
|
|
@@ -1326,8 +1340,9 @@ class _s {
|
|
|
1326
1340
|
setGravity(t) {
|
|
1327
1341
|
this.physicsSettings.gravity = t;
|
|
1328
1342
|
}
|
|
1329
|
-
setAttractor(t, e) {
|
|
1330
|
-
|
|
1343
|
+
setAttractor(t, e, i = !1) {
|
|
1344
|
+
const r = Math.abs(t || 0);
|
|
1345
|
+
this.physicsSettings.attractorStrength = i ? -r : r, this.physicsSettings.attractorPosition = e;
|
|
1331
1346
|
}
|
|
1332
1347
|
setConfinement(t) {
|
|
1333
1348
|
const e = this.physicsSettings;
|
|
@@ -1446,7 +1461,7 @@ class _s {
|
|
|
1446
1461
|
t.enabled !== void 0 && (e.softBoundaryEnabled = t.enabled), t.strength !== void 0 && (e.softBoundaryStrength = t.strength), t.falloff !== void 0 && (e.softBoundaryFalloff = t.falloff);
|
|
1447
1462
|
}
|
|
1448
1463
|
}
|
|
1449
|
-
class
|
|
1464
|
+
class Ws {
|
|
1450
1465
|
constructor(t) {
|
|
1451
1466
|
this.device = t, this.defaultTexture = null, this.createDefaultTexture();
|
|
1452
1467
|
}
|
|
@@ -1485,7 +1500,7 @@ class ws {
|
|
|
1485
1500
|
t && t.label !== "defaultParticleTexture" && t.destroy();
|
|
1486
1501
|
}
|
|
1487
1502
|
}
|
|
1488
|
-
const
|
|
1503
|
+
const ji = Object.freeze({
|
|
1489
1504
|
sin: Math.sin,
|
|
1490
1505
|
cos: Math.cos,
|
|
1491
1506
|
abs: Math.abs,
|
|
@@ -1506,10 +1521,10 @@ const Pi = Object.freeze({
|
|
|
1506
1521
|
return s + (t - s) * e;
|
|
1507
1522
|
},
|
|
1508
1523
|
smoothstep(s, t, e) {
|
|
1509
|
-
const i =
|
|
1524
|
+
const i = ji.clamp((e - s) / (t - s), 0, 1);
|
|
1510
1525
|
return i * i * (3 - 2 * i);
|
|
1511
1526
|
}
|
|
1512
|
-
}),
|
|
1527
|
+
}), At = /* @__PURE__ */ new Set([
|
|
1513
1528
|
"particleSize",
|
|
1514
1529
|
"particleSpeed",
|
|
1515
1530
|
"particleColor",
|
|
@@ -1520,12 +1535,13 @@ const Pi = Object.freeze({
|
|
|
1520
1535
|
"gravityStrength",
|
|
1521
1536
|
"dampingStrength",
|
|
1522
1537
|
"attractorStrength",
|
|
1538
|
+
"attractorReverse",
|
|
1523
1539
|
"attractorPosition",
|
|
1524
1540
|
"pulseAmplitude",
|
|
1525
1541
|
"pulseFrequency",
|
|
1526
1542
|
"bloomIntensity"
|
|
1527
1543
|
]);
|
|
1528
|
-
class
|
|
1544
|
+
class Js {
|
|
1529
1545
|
constructor(t) {
|
|
1530
1546
|
this._collection = t, this._pd = null, this._vd = null, this._pi = 0, this._vi = 0;
|
|
1531
1547
|
}
|
|
@@ -1603,9 +1619,9 @@ class Bs {
|
|
|
1603
1619
|
this._vd[this._vi + 2] = t, this._collection._dirty = !0;
|
|
1604
1620
|
}
|
|
1605
1621
|
}
|
|
1606
|
-
class
|
|
1622
|
+
class Ks {
|
|
1607
1623
|
constructor() {
|
|
1608
|
-
this._proxy = new
|
|
1624
|
+
this._proxy = new Js(this), this._pd = null, this._vd = null, this.count = 0, this._dirty = !1;
|
|
1609
1625
|
}
|
|
1610
1626
|
_bind(t, e, i) {
|
|
1611
1627
|
this._pd = t, this._vd = e, this.count = i, this._dirty = !1;
|
|
@@ -1614,14 +1630,14 @@ class Ms {
|
|
|
1614
1630
|
return t < 0 || t >= this.count ? null : this._proxy._bind(this._pd, this._vd, t);
|
|
1615
1631
|
}
|
|
1616
1632
|
}
|
|
1617
|
-
const
|
|
1618
|
-
function
|
|
1633
|
+
const Qs = 1e6;
|
|
1634
|
+
function er(s) {
|
|
1619
1635
|
let t = 0;
|
|
1620
1636
|
return s.replace(
|
|
1621
1637
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
1622
1638
|
(e) => {
|
|
1623
1639
|
const i = `__lc${t++}`;
|
|
1624
|
-
return `${e} if(++${i}>${
|
|
1640
|
+
return `${e} if(++${i}>${Qs})throw new Error("Loop limit exceeded");`;
|
|
1625
1641
|
}
|
|
1626
1642
|
).replace(
|
|
1627
1643
|
/\b(for|while)\s*\([^)]*\)\s*\{/g,
|
|
@@ -1638,10 +1654,10 @@ function Ts(s) {
|
|
|
1638
1654
|
}
|
|
1639
1655
|
);
|
|
1640
1656
|
}
|
|
1641
|
-
const
|
|
1642
|
-
for (const s of
|
|
1643
|
-
|
|
1644
|
-
function
|
|
1657
|
+
const ii = /* @__PURE__ */ new Map();
|
|
1658
|
+
for (const s of At)
|
|
1659
|
+
ii.set(s.toLowerCase(), s);
|
|
1660
|
+
function tr(s) {
|
|
1645
1661
|
const t = { value: !1 }, e = /* @__PURE__ */ new Set();
|
|
1646
1662
|
return new Proxy(s, {
|
|
1647
1663
|
get(r, n) {
|
|
@@ -1650,16 +1666,16 @@ function Es(s) {
|
|
|
1650
1666
|
t.value = !1;
|
|
1651
1667
|
};
|
|
1652
1668
|
if (typeof n != "string") return;
|
|
1653
|
-
if (
|
|
1654
|
-
const a =
|
|
1669
|
+
if (At.has(n)) return r[n];
|
|
1670
|
+
const a = ii.get(n.toLowerCase());
|
|
1655
1671
|
if (a)
|
|
1656
1672
|
return e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${a}?`)), r[a];
|
|
1657
1673
|
},
|
|
1658
1674
|
set(r, n, a) {
|
|
1659
1675
|
if (typeof n != "string") return !0;
|
|
1660
1676
|
let o = n;
|
|
1661
|
-
if (
|
|
1662
|
-
const c =
|
|
1677
|
+
if (!At.has(o)) {
|
|
1678
|
+
const c = ii.get(o.toLowerCase());
|
|
1663
1679
|
if (c)
|
|
1664
1680
|
e.has(n) || (e.add(n), console.warn(`[ParticleScript] config.${n} → did you mean config.${c}?`)), o = c;
|
|
1665
1681
|
else
|
|
@@ -1669,14 +1685,14 @@ function Es(s) {
|
|
|
1669
1685
|
}
|
|
1670
1686
|
});
|
|
1671
1687
|
}
|
|
1672
|
-
class
|
|
1688
|
+
class Ii {
|
|
1673
1689
|
/**
|
|
1674
1690
|
* @param {string} source - User script source code
|
|
1675
1691
|
* @param {object} config - ParticleSystem config (will be proxied)
|
|
1676
1692
|
* @param {number} maxParticles - Max particle count for pre-allocation
|
|
1677
1693
|
*/
|
|
1678
1694
|
constructor(t, e, i) {
|
|
1679
|
-
this._particles = new
|
|
1695
|
+
this._particles = new Ks(), this._configProxy = tr(e), this._configSnapshot = null, this._fn = null, this._error = !1, this.compile(t);
|
|
1680
1696
|
}
|
|
1681
1697
|
/**
|
|
1682
1698
|
* Compile script source into a sandboxed function.
|
|
@@ -1692,7 +1708,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1692
1708
|
var deltaTime = __deltaTime, time = __time;
|
|
1693
1709
|
var currentFrame = __currentFrame, totalFrames = __totalFrames;
|
|
1694
1710
|
var particles = __particles, config = __config, math = __math;
|
|
1695
|
-
${
|
|
1711
|
+
${er(t)}
|
|
1696
1712
|
};`, r = new Function(i);
|
|
1697
1713
|
this._fn = r();
|
|
1698
1714
|
} catch (e) {
|
|
@@ -1714,7 +1730,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1714
1730
|
if (!this._fn || this._error) return { configDirty: !1, particlesDirty: !1 };
|
|
1715
1731
|
this._particles._bind(n, a, o), this._configProxy.__resetDirty();
|
|
1716
1732
|
try {
|
|
1717
|
-
this._fn(t, e, i, r, this._particles, this._configProxy,
|
|
1733
|
+
this._fn(t, e, i, r, this._particles, this._configProxy, ji);
|
|
1718
1734
|
} catch (c) {
|
|
1719
1735
|
console.warn("[ParticleScript] Runtime error:", c.message);
|
|
1720
1736
|
}
|
|
@@ -1728,7 +1744,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1728
1744
|
*/
|
|
1729
1745
|
snapshotConfig(t) {
|
|
1730
1746
|
const e = {};
|
|
1731
|
-
for (const i of
|
|
1747
|
+
for (const i of At) {
|
|
1732
1748
|
const r = t[i];
|
|
1733
1749
|
r !== void 0 && (e[i] = Array.isArray(r) ? [...r] : r);
|
|
1734
1750
|
}
|
|
@@ -1739,7 +1755,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1739
1755
|
*/
|
|
1740
1756
|
restoreConfig(t) {
|
|
1741
1757
|
if (this._configSnapshot) {
|
|
1742
|
-
for (const e of
|
|
1758
|
+
for (const e of At)
|
|
1743
1759
|
if (e in this._configSnapshot) {
|
|
1744
1760
|
const i = this._configSnapshot[e];
|
|
1745
1761
|
t[e] = Array.isArray(i) ? [...i] : i;
|
|
@@ -1753,7 +1769,7 @@ return function(__deltaTime, __time, __currentFrame, __totalFrames, __particles,
|
|
|
1753
1769
|
this._fn = null, this._particles = null, this._configProxy = null, this._configSnapshot = null;
|
|
1754
1770
|
}
|
|
1755
1771
|
}
|
|
1756
|
-
async function
|
|
1772
|
+
async function ir(s) {
|
|
1757
1773
|
const t = new DataView(s);
|
|
1758
1774
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
1759
1775
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -1763,12 +1779,12 @@ async function Cs(s) {
|
|
|
1763
1779
|
const r = t.getUint32(8, !0);
|
|
1764
1780
|
let n = 12, a = null, o = null;
|
|
1765
1781
|
for (; n < r; ) {
|
|
1766
|
-
const
|
|
1767
|
-
if (
|
|
1768
|
-
const
|
|
1769
|
-
a = JSON.parse(
|
|
1770
|
-
} else
|
|
1771
|
-
n += 8 +
|
|
1782
|
+
const T = t.getUint32(n, !0), z = t.getUint32(n + 4, !0), F = s.slice(n + 8, n + 8 + T);
|
|
1783
|
+
if (z === 1313821514) {
|
|
1784
|
+
const J = new TextDecoder("utf-8").decode(F);
|
|
1785
|
+
a = JSON.parse(J);
|
|
1786
|
+
} else z === 5130562 && (o = F);
|
|
1787
|
+
n += 8 + T;
|
|
1772
1788
|
}
|
|
1773
1789
|
if (!a)
|
|
1774
1790
|
throw new Error("GLB file missing JSON chunk");
|
|
@@ -1777,50 +1793,50 @@ async function Cs(s) {
|
|
|
1777
1793
|
const l = a.meshes[0].primitives[0];
|
|
1778
1794
|
if (!l)
|
|
1779
1795
|
throw new Error("First mesh has no primitives");
|
|
1780
|
-
const
|
|
1781
|
-
if (
|
|
1796
|
+
const d = l.attributes.POSITION;
|
|
1797
|
+
if (d === void 0)
|
|
1782
1798
|
throw new Error("Mesh primitive missing POSITION attribute");
|
|
1783
|
-
const
|
|
1784
|
-
let
|
|
1799
|
+
const S = Kt(a, o, d, 3, 5126);
|
|
1800
|
+
let g;
|
|
1785
1801
|
if (l.attributes.NORMAL !== void 0)
|
|
1786
|
-
|
|
1802
|
+
g = Kt(a, o, l.attributes.NORMAL, 3, 5126);
|
|
1787
1803
|
else {
|
|
1788
|
-
const
|
|
1789
|
-
if (
|
|
1804
|
+
const T = l.indices;
|
|
1805
|
+
if (T === void 0)
|
|
1790
1806
|
throw new Error("Cannot generate normals without indices");
|
|
1791
|
-
const
|
|
1792
|
-
|
|
1807
|
+
const z = zi(a, o, T);
|
|
1808
|
+
g = sr(S, z);
|
|
1793
1809
|
}
|
|
1794
|
-
const
|
|
1795
|
-
if (
|
|
1810
|
+
const p = l.indices;
|
|
1811
|
+
if (p === void 0)
|
|
1796
1812
|
throw new Error("Mesh primitive missing indices");
|
|
1797
|
-
const
|
|
1798
|
-
let
|
|
1799
|
-
l.attributes.TEXCOORD_0 !== void 0 && (
|
|
1800
|
-
let
|
|
1813
|
+
const v = zi(a, o, p), A = S.length / 3, U = v.length;
|
|
1814
|
+
let I = null;
|
|
1815
|
+
l.attributes.TEXCOORD_0 !== void 0 && (I = Kt(a, o, l.attributes.TEXCOORD_0, 2, 5126));
|
|
1816
|
+
let _ = !1;
|
|
1801
1817
|
if (a.materials && a.materials.length > 0) {
|
|
1802
|
-
const
|
|
1803
|
-
|
|
1818
|
+
const T = a.materials[0];
|
|
1819
|
+
T.pbrMetallicRoughness && T.pbrMetallicRoughness.baseColorTexture !== void 0 && (_ = !0);
|
|
1804
1820
|
}
|
|
1805
|
-
let
|
|
1821
|
+
let $ = null;
|
|
1806
1822
|
if (a.skins && a.skins.length > 0)
|
|
1807
1823
|
try {
|
|
1808
|
-
|
|
1809
|
-
} catch (
|
|
1810
|
-
console.warn("Failed to extract animation data:",
|
|
1824
|
+
$ = cr(a, o, l), globalThis.__HZFX_DEBUG && console.log("Animation data extracted:", $);
|
|
1825
|
+
} catch (T) {
|
|
1826
|
+
console.warn("Failed to extract animation data:", T);
|
|
1811
1827
|
}
|
|
1812
1828
|
return {
|
|
1813
|
-
positions:
|
|
1814
|
-
normals:
|
|
1815
|
-
indices:
|
|
1816
|
-
texCoords:
|
|
1817
|
-
vertexCount:
|
|
1818
|
-
indexCount:
|
|
1819
|
-
animationData:
|
|
1820
|
-
hasBaseColorTexture:
|
|
1829
|
+
positions: S,
|
|
1830
|
+
normals: g,
|
|
1831
|
+
indices: v,
|
|
1832
|
+
texCoords: I,
|
|
1833
|
+
vertexCount: A,
|
|
1834
|
+
indexCount: U,
|
|
1835
|
+
animationData: $,
|
|
1836
|
+
hasBaseColorTexture: _
|
|
1821
1837
|
};
|
|
1822
1838
|
}
|
|
1823
|
-
function
|
|
1839
|
+
function Kt(s, t, e, i, r) {
|
|
1824
1840
|
const n = s.accessors[e], o = {
|
|
1825
1841
|
SCALAR: 1,
|
|
1826
1842
|
VEC2: 2,
|
|
@@ -1831,12 +1847,12 @@ function xt(s, t, e, i, r) {
|
|
|
1831
1847
|
throw new Error(`Attribute accessor type mismatch: expected ${i} components, got ${o}`);
|
|
1832
1848
|
if (n.componentType !== r)
|
|
1833
1849
|
throw new Error(`Attribute component type mismatch: expected ${r}, got ${n.componentType}`);
|
|
1834
|
-
const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0),
|
|
1835
|
-
for (let
|
|
1836
|
-
p
|
|
1837
|
-
return
|
|
1850
|
+
const l = (s.bufferViews[n.bufferView].byteOffset || 0) + (n.byteOffset || 0), d = n.count, S = new DataView(t, l, d * i * 4), g = new Float32Array(d * i);
|
|
1851
|
+
for (let p = 0; p < d * i; p++)
|
|
1852
|
+
g[p] = S.getFloat32(p * 4, !0);
|
|
1853
|
+
return g;
|
|
1838
1854
|
}
|
|
1839
|
-
function
|
|
1855
|
+
function zi(s, t, e) {
|
|
1840
1856
|
const i = s.accessors[e];
|
|
1841
1857
|
if (i.type !== "SCALAR")
|
|
1842
1858
|
throw new Error(`Indices accessor must be SCALAR, got ${i.type}`);
|
|
@@ -1854,19 +1870,19 @@ function di(s, t, e) {
|
|
|
1854
1870
|
} else
|
|
1855
1871
|
throw new Error(`Unsupported index component type: ${i.componentType}`);
|
|
1856
1872
|
}
|
|
1857
|
-
function
|
|
1873
|
+
function sr(s, t) {
|
|
1858
1874
|
const e = new Float32Array(s.length);
|
|
1859
1875
|
for (let i = 0; i < t.length; i += 3) {
|
|
1860
|
-
const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], c = [s[n], s[n + 1], s[n + 2]], l = [s[a], s[a + 1], s[a + 2]],
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
],
|
|
1865
|
-
|
|
1876
|
+
const r = t[i] * 3, n = t[i + 1] * 3, a = t[i + 2] * 3, o = [s[r], s[r + 1], s[r + 2]], c = [s[n], s[n + 1], s[n + 2]], l = [s[a], s[a + 1], s[a + 2]], d = [c[0] - o[0], c[1] - o[1], c[2] - o[2]], S = [l[0] - o[0], l[1] - o[1], l[2] - o[2]], g = [
|
|
1877
|
+
d[1] * S[2] - d[2] * S[1],
|
|
1878
|
+
d[2] * S[0] - d[0] * S[2],
|
|
1879
|
+
d[0] * S[1] - d[1] * S[0]
|
|
1880
|
+
], p = Math.sqrt(g[0] * g[0] + g[1] * g[1] + g[2] * g[2]);
|
|
1881
|
+
p > 0 && (g[0] /= p, g[1] /= p, g[2] /= p), e[r] = e[n] = e[a] = g[0], e[r + 1] = e[n + 1] = e[a + 1] = g[1], e[r + 2] = e[n + 2] = e[a + 2] = g[2];
|
|
1866
1882
|
}
|
|
1867
1883
|
return e;
|
|
1868
1884
|
}
|
|
1869
|
-
function
|
|
1885
|
+
function rr(s, t, e) {
|
|
1870
1886
|
const i = s.accessors[e];
|
|
1871
1887
|
if (i.type !== "VEC4")
|
|
1872
1888
|
throw new Error(`JOINTS_0 must be VEC4, got ${i.type}`);
|
|
@@ -1884,7 +1900,7 @@ function Us(s, t, e) {
|
|
|
1884
1900
|
} else
|
|
1885
1901
|
throw new Error(`Unsupported JOINTS_0 component type: ${i.componentType}`);
|
|
1886
1902
|
}
|
|
1887
|
-
function
|
|
1903
|
+
function nr(s, t, e) {
|
|
1888
1904
|
const i = s.accessors[e];
|
|
1889
1905
|
if (i.type !== "VEC4")
|
|
1890
1906
|
throw new Error(`WEIGHTS_0 must be VEC4, got ${i.type}`);
|
|
@@ -1902,7 +1918,7 @@ function Is(s, t, e) {
|
|
|
1902
1918
|
} else
|
|
1903
1919
|
throw new Error(`Unsupported WEIGHTS_0 component type: ${i.componentType}`);
|
|
1904
1920
|
}
|
|
1905
|
-
function
|
|
1921
|
+
function ar(s, t, e) {
|
|
1906
1922
|
const i = s.accessors[e];
|
|
1907
1923
|
if (i.type !== "MAT4")
|
|
1908
1924
|
throw new Error(`Expected MAT4, got ${i.type}`);
|
|
@@ -1913,7 +1929,7 @@ function zs(s, t, e) {
|
|
|
1913
1929
|
c[l] = o.getFloat32(l * 4, !0);
|
|
1914
1930
|
return c;
|
|
1915
1931
|
}
|
|
1916
|
-
function
|
|
1932
|
+
function or(s, t, e) {
|
|
1917
1933
|
const i = s.accessors[e];
|
|
1918
1934
|
if (i.type !== "SCALAR")
|
|
1919
1935
|
throw new Error(`Expected SCALAR, got ${i.type}`);
|
|
@@ -1924,46 +1940,46 @@ function Gs(s, t, e) {
|
|
|
1924
1940
|
c[l] = o.getFloat32(l * 4, !0);
|
|
1925
1941
|
return c;
|
|
1926
1942
|
}
|
|
1927
|
-
function
|
|
1943
|
+
function lr(s, t, e) {
|
|
1928
1944
|
const i = s.accessors[e], n = { VEC3: 3, VEC4: 4 }[i.type];
|
|
1929
1945
|
if (!n)
|
|
1930
1946
|
throw new Error(`Expected VEC3 or VEC4, got ${i.type}`);
|
|
1931
1947
|
if (i.componentType !== 5126)
|
|
1932
1948
|
throw new Error(`Expected FLOAT component type, got ${i.componentType}`);
|
|
1933
|
-
const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), c = i.count, l = new DataView(t, o, c * n * 4),
|
|
1934
|
-
for (let
|
|
1935
|
-
|
|
1936
|
-
return
|
|
1949
|
+
const o = (s.bufferViews[i.bufferView].byteOffset || 0) + (i.byteOffset || 0), c = i.count, l = new DataView(t, o, c * n * 4), d = new Float32Array(c * n);
|
|
1950
|
+
for (let S = 0; S < c * n; S++)
|
|
1951
|
+
d[S] = l.getFloat32(S * 4, !0);
|
|
1952
|
+
return d;
|
|
1937
1953
|
}
|
|
1938
|
-
function
|
|
1939
|
-
const i = s.skins[0], r = i.joints, n =
|
|
1954
|
+
function cr(s, t, e) {
|
|
1955
|
+
const i = s.skins[0], r = i.joints, n = ar(s, t, i.inverseBindMatrices), a = e.attributes.JOINTS_0 !== void 0 ? rr(s, t, e.attributes.JOINTS_0) : null, o = e.attributes.WEIGHTS_0 !== void 0 ? nr(s, t, e.attributes.WEIGHTS_0) : null;
|
|
1940
1956
|
if (!a || !o)
|
|
1941
1957
|
throw new Error("Mesh missing JOINTS_0 or WEIGHTS_0 attributes");
|
|
1942
|
-
const c = s.nodes.map((
|
|
1943
|
-
translation:
|
|
1944
|
-
rotation:
|
|
1945
|
-
scale:
|
|
1946
|
-
children:
|
|
1947
|
-
name:
|
|
1958
|
+
const c = s.nodes.map((d) => ({
|
|
1959
|
+
translation: d.translation || [0, 0, 0],
|
|
1960
|
+
rotation: d.rotation || [0, 0, 0, 1],
|
|
1961
|
+
scale: d.scale || [1, 1, 1],
|
|
1962
|
+
children: d.children || [],
|
|
1963
|
+
name: d.name || ""
|
|
1948
1964
|
})), l = [];
|
|
1949
1965
|
if (s.animations && s.animations.length > 0)
|
|
1950
|
-
for (const
|
|
1951
|
-
const
|
|
1952
|
-
let
|
|
1953
|
-
for (const
|
|
1954
|
-
const
|
|
1955
|
-
|
|
1956
|
-
targetNode:
|
|
1957
|
-
targetPath:
|
|
1958
|
-
interpolation:
|
|
1959
|
-
timestamps:
|
|
1960
|
-
values:
|
|
1966
|
+
for (const d of s.animations) {
|
|
1967
|
+
const S = [];
|
|
1968
|
+
let g = 0;
|
|
1969
|
+
for (const p of d.channels) {
|
|
1970
|
+
const v = d.samplers[p.sampler], A = or(s, t, v.input), U = lr(s, t, v.output), I = A[A.length - 1];
|
|
1971
|
+
I > g && (g = I), S.push({
|
|
1972
|
+
targetNode: p.target.node,
|
|
1973
|
+
targetPath: p.target.path,
|
|
1974
|
+
interpolation: v.interpolation || "LINEAR",
|
|
1975
|
+
timestamps: A,
|
|
1976
|
+
values: U
|
|
1961
1977
|
});
|
|
1962
1978
|
}
|
|
1963
1979
|
l.push({
|
|
1964
|
-
name:
|
|
1965
|
-
duration:
|
|
1966
|
-
channels:
|
|
1980
|
+
name: d.name || `Animation ${l.length}`,
|
|
1981
|
+
duration: g,
|
|
1982
|
+
channels: S
|
|
1967
1983
|
});
|
|
1968
1984
|
}
|
|
1969
1985
|
return {
|
|
@@ -1975,7 +1991,7 @@ function Fs(s, t, e) {
|
|
|
1975
1991
|
animations: l
|
|
1976
1992
|
};
|
|
1977
1993
|
}
|
|
1978
|
-
async function
|
|
1994
|
+
async function Fi(s) {
|
|
1979
1995
|
const t = new DataView(s);
|
|
1980
1996
|
if (t.getUint32(0, !0) !== 1179937895)
|
|
1981
1997
|
throw new Error("Invalid GLB file: incorrect magic number");
|
|
@@ -1985,12 +2001,12 @@ async function fi(s) {
|
|
|
1985
2001
|
const r = t.getUint32(8, !0);
|
|
1986
2002
|
let n = 12, a = null, o = null;
|
|
1987
2003
|
for (; n < r; ) {
|
|
1988
|
-
const
|
|
1989
|
-
if (
|
|
1990
|
-
const
|
|
1991
|
-
a = JSON.parse(
|
|
1992
|
-
} else
|
|
1993
|
-
n += 8 +
|
|
2004
|
+
const $ = t.getUint32(n, !0), T = t.getUint32(n + 4, !0), z = s.slice(n + 8, n + 8 + $);
|
|
2005
|
+
if (T === 1313821514) {
|
|
2006
|
+
const Z = new TextDecoder("utf-8").decode(z);
|
|
2007
|
+
a = JSON.parse(Z);
|
|
2008
|
+
} else T === 5130562 && (o = z);
|
|
2009
|
+
n += 8 + $;
|
|
1994
2010
|
}
|
|
1995
2011
|
if (!a)
|
|
1996
2012
|
throw new Error("GLB file missing JSON chunk");
|
|
@@ -2002,48 +2018,48 @@ async function fi(s) {
|
|
|
2002
2018
|
const l = c.pbrMetallicRoughness.baseColorTexture.index;
|
|
2003
2019
|
if (!a.textures || !a.textures[l])
|
|
2004
2020
|
return null;
|
|
2005
|
-
const
|
|
2006
|
-
if (
|
|
2021
|
+
const S = a.textures[l].source;
|
|
2022
|
+
if (S === void 0 || !a.images || !a.images[S])
|
|
2007
2023
|
return null;
|
|
2008
|
-
const
|
|
2009
|
-
if (
|
|
2024
|
+
const g = a.images[S], p = g.mimeType || "image/png";
|
|
2025
|
+
if (g.bufferView === void 0)
|
|
2010
2026
|
return null;
|
|
2011
2027
|
if (!o)
|
|
2012
2028
|
throw new Error("GLB file missing BIN chunk (required for embedded textures)");
|
|
2013
|
-
const
|
|
2014
|
-
return { imageBlob: new Blob([
|
|
2029
|
+
const v = a.bufferViews[g.bufferView], A = v.byteOffset || 0, U = v.byteLength, I = o.slice(A, A + U);
|
|
2030
|
+
return { imageBlob: new Blob([I], { type: p }), mimeType: p };
|
|
2015
2031
|
}
|
|
2016
|
-
function
|
|
2032
|
+
function ur(s, t, e, i) {
|
|
2017
2033
|
return i = i || [0, 0, 0], i[0] = s[0] + (t[0] - s[0]) * e, i[1] = s[1] + (t[1] - s[1]) * e, i[2] = s[2] + (t[2] - s[2]) * e, i;
|
|
2018
2034
|
}
|
|
2019
|
-
function
|
|
2035
|
+
function dr(s, t, e, i) {
|
|
2020
2036
|
i = i || [0, 0, 0, 0];
|
|
2021
2037
|
let r = s[0] * t[0] + s[1] * t[1] + s[2] * t[2] + s[3] * t[3], n = 1;
|
|
2022
2038
|
if (r < 0 && (r = -r, n = -1), r > 0.9995) {
|
|
2023
2039
|
i[0] = s[0] + (n * t[0] - s[0]) * e, i[1] = s[1] + (n * t[1] - s[1]) * e, i[2] = s[2] + (n * t[2] - s[2]) * e, i[3] = s[3] + (n * t[3] - s[3]) * e;
|
|
2024
|
-
const
|
|
2025
|
-
return
|
|
2040
|
+
const d = Math.sqrt(i[0] * i[0] + i[1] * i[1] + i[2] * i[2] + i[3] * i[3]);
|
|
2041
|
+
return d > 1e-4 ? (i[0] /= d, i[1] /= d, i[2] /= d, i[3] /= d) : (i[0] = 0, i[1] = 0, i[2] = 0, i[3] = 1), i;
|
|
2026
2042
|
}
|
|
2027
2043
|
const a = Math.acos(r), o = Math.sin(a), c = Math.sin((1 - e) * a) / o, l = Math.sin(e * a) / o;
|
|
2028
2044
|
return i[0] = s[0] * c + n * t[0] * l, i[1] = s[1] * c + n * t[1] * l, i[2] = s[2] * c + n * t[2] * l, i[3] = s[3] * c + n * t[3] * l, i;
|
|
2029
2045
|
}
|
|
2030
|
-
function
|
|
2031
|
-
const e = s[0], i = s[1], r = s[2], n = s[3], a = e + e, o = i + i, c = r + r, l = e * a,
|
|
2032
|
-
return
|
|
2046
|
+
function fr(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, d = e * o, S = e * c, g = i * o, p = i * c, v = r * c, A = n * a, U = n * o, I = n * c, _ = t || new Float32Array(16);
|
|
2048
|
+
return _[0] = 1 - (g + v), _[1] = d + I, _[2] = S - U, _[3] = 0, _[4] = d - I, _[5] = 1 - (l + v), _[6] = p + A, _[7] = 0, _[8] = S + U, _[9] = p - A, _[10] = 1 - (l + g), _[11] = 0, _[12] = 0, _[13] = 0, _[14] = 0, _[15] = 1, _;
|
|
2033
2049
|
}
|
|
2034
|
-
const
|
|
2035
|
-
function
|
|
2036
|
-
const r =
|
|
2050
|
+
const pr = new Float32Array(16);
|
|
2051
|
+
function hr(s, t, e, i) {
|
|
2052
|
+
const r = fr(t, pr), n = i || new Float32Array(16);
|
|
2037
2053
|
return n[0] = r[0] * e[0], n[1] = r[1] * e[0], n[2] = r[2] * e[0], n[3] = 0, n[4] = r[4] * e[1], n[5] = r[5] * e[1], n[6] = r[6] * e[1], n[7] = 0, n[8] = r[8] * e[2], n[9] = r[9] * e[2], n[10] = r[10] * e[2], n[11] = 0, n[12] = s[0], n[13] = s[1], n[14] = s[2], n[15] = 1, n;
|
|
2038
2054
|
}
|
|
2039
|
-
function
|
|
2055
|
+
function Gi(s, t, e) {
|
|
2040
2056
|
const i = e || new Float32Array(16);
|
|
2041
2057
|
for (let r = 0; r < 4; r++)
|
|
2042
2058
|
for (let n = 0; n < 4; n++)
|
|
2043
2059
|
i[r * 4 + n] = s[0 + n] * t[r * 4 + 0] + s[4 + n] * t[r * 4 + 1] + s[8 + n] * t[r * 4 + 2] + s[12 + n] * t[r * 4 + 3];
|
|
2044
2060
|
return i;
|
|
2045
2061
|
}
|
|
2046
|
-
class
|
|
2062
|
+
class mr {
|
|
2047
2063
|
constructor(t) {
|
|
2048
2064
|
this.joints = t.joints, this.inverseBindMatrices = t.inverseBindMatrices, this.jointWeights = t.jointWeights, this.jointIndices = t.jointIndices, this.nodes = t.nodes, this.animations = t.animations, this.restPositions = null, this.restNormals = null, this.currentAnimIndex = 0, this.currentTime = 0, this.playing = !0, this.speed = 1, this.loop = !0, this.jointLocalTransforms = new Array(this.nodes.length), this.jointGlobalTransforms = new Array(this.nodes.length), this.jointFinalMatrices = new Array(this.joints.length);
|
|
2049
2065
|
for (let e = 0; e < this.nodes.length; e++)
|
|
@@ -2074,8 +2090,8 @@ class Ns {
|
|
|
2074
2090
|
this._gpuDevice = t, this._gpuOutputBuffer = e;
|
|
2075
2091
|
const r = this.restPositions.length / 3, n = new Float32Array(r * 8);
|
|
2076
2092
|
for (let c = 0; c < r; c++) {
|
|
2077
|
-
const l = c * 8,
|
|
2078
|
-
n[l] = this.restPositions[
|
|
2093
|
+
const l = c * 8, d = c * 3, S = c * 2;
|
|
2094
|
+
n[l] = this.restPositions[d], n[l + 1] = this.restPositions[d + 1], n[l + 2] = this.restPositions[d + 2], n[l + 3] = this.restNormals[d], n[l + 4] = this.restNormals[d + 1], n[l + 5] = this.restNormals[d + 2], n[l + 6] = i ? i[S] : 0, n[l + 7] = i ? i[S + 1] : 0;
|
|
2079
2095
|
}
|
|
2080
2096
|
this._gpuRestDataBuffer = t.createBuffer({
|
|
2081
2097
|
size: n.byteLength,
|
|
@@ -2110,7 +2126,7 @@ class Ns {
|
|
|
2110
2126
|
this._gpuSkinningPipeline = t.createComputePipeline({
|
|
2111
2127
|
layout: t.createPipelineLayout({ bindGroupLayouts: [o] }),
|
|
2112
2128
|
compute: {
|
|
2113
|
-
module: t.createShaderModule({ code:
|
|
2129
|
+
module: t.createShaderModule({ code: Zs }),
|
|
2114
2130
|
entryPoint: "main"
|
|
2115
2131
|
}
|
|
2116
2132
|
}), this._gpuSkinningBindGroup = t.createBindGroup({
|
|
@@ -2200,11 +2216,11 @@ class Ns {
|
|
|
2200
2216
|
return this._extractValue(n, r.length - 1, o, i);
|
|
2201
2217
|
let c = 0, l = r.length - 1;
|
|
2202
2218
|
for (; l - c > 1; ) {
|
|
2203
|
-
const
|
|
2204
|
-
r[
|
|
2219
|
+
const A = Math.floor((c + l) / 2);
|
|
2220
|
+
r[A] <= e ? c = A : l = A;
|
|
2205
2221
|
}
|
|
2206
|
-
const
|
|
2207
|
-
return a === "STEP" ? (i[0] =
|
|
2222
|
+
const d = r[c], S = r[l], g = (e - d) / (S - d), p = this._extractValue(n, c, o, this._sV0), v = this._extractValue(n, l, o, this._sV1);
|
|
2223
|
+
return a === "STEP" ? (i[0] = p[0], i[1] = p[1], i[2] = p[2], o === "rotation" && (i[3] = p[3]), i) : o === "rotation" ? dr(p, v, g, i) : ur(p, v, g, i);
|
|
2208
2224
|
}
|
|
2209
2225
|
/**
|
|
2210
2226
|
* Extract value from values array at the given index.
|
|
@@ -2229,7 +2245,7 @@ class Ns {
|
|
|
2229
2245
|
let n = r.translation, a = r.rotation, o = r.scale;
|
|
2230
2246
|
for (const c of e.channels)
|
|
2231
2247
|
c.targetNode === i && (c.targetPath === "translation" ? n = this._sampleChannel(c, t, this._scrT) : c.targetPath === "rotation" ? a = this._sampleChannel(c, t, this._scrR) : c.targetPath === "scale" && (o = this._sampleChannel(c, t, this._scrS)));
|
|
2232
|
-
|
|
2248
|
+
hr(n, a, o, this.jointLocalTransforms[i]);
|
|
2233
2249
|
}
|
|
2234
2250
|
}
|
|
2235
2251
|
/**
|
|
@@ -2239,7 +2255,7 @@ class Ns {
|
|
|
2239
2255
|
const t = this._parentMap;
|
|
2240
2256
|
for (const e of this.topologicalOrder) {
|
|
2241
2257
|
const i = t[e];
|
|
2242
|
-
i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) :
|
|
2258
|
+
i === -1 ? this.jointGlobalTransforms[e].set(this.jointLocalTransforms[e]) : Gi(
|
|
2243
2259
|
this.jointGlobalTransforms[i],
|
|
2244
2260
|
this.jointLocalTransforms[e],
|
|
2245
2261
|
this.jointGlobalTransforms[e]
|
|
@@ -2252,7 +2268,7 @@ class Ns {
|
|
|
2252
2268
|
_computeFinalMatrices() {
|
|
2253
2269
|
for (let t = 0; t < this.joints.length; t++) {
|
|
2254
2270
|
const e = this.joints[t], i = this.jointGlobalTransforms[e];
|
|
2255
|
-
|
|
2271
|
+
Gi(i, this._invBindViews[t], this.jointFinalMatrices[t]);
|
|
2256
2272
|
}
|
|
2257
2273
|
}
|
|
2258
2274
|
/**
|
|
@@ -2262,20 +2278,20 @@ class Ns {
|
|
|
2262
2278
|
_applySkinning() {
|
|
2263
2279
|
const t = this.restPositions.length / 3, e = this.restPositions, i = this.restNormals, r = this.skinnedPositions, n = this.skinnedNormals, a = this.jointWeights, o = this.jointIndices, c = this.jointFinalMatrices;
|
|
2264
2280
|
for (let l = 0; l < t; l++) {
|
|
2265
|
-
const
|
|
2266
|
-
let
|
|
2267
|
-
for (let
|
|
2268
|
-
const
|
|
2269
|
-
if (
|
|
2270
|
-
const
|
|
2271
|
-
|
|
2281
|
+
const d = l * 3, S = l * 4, g = e[d], p = e[d + 1], v = e[d + 2], A = i[d], U = i[d + 1], I = i[d + 2];
|
|
2282
|
+
let _ = 0, $ = 0, T = 0, z = 0, F = 0, Z = 0;
|
|
2283
|
+
for (let ee = 0; ee < 4; ee++) {
|
|
2284
|
+
const K = a[S + ee];
|
|
2285
|
+
if (K === 0) continue;
|
|
2286
|
+
const q = c[o[S + ee]];
|
|
2287
|
+
_ += (q[0] * g + q[4] * p + q[8] * v + q[12]) * K, $ += (q[1] * g + q[5] * p + q[9] * v + q[13]) * K, T += (q[2] * g + q[6] * p + q[10] * v + q[14]) * K, z += (q[0] * A + q[4] * U + q[8] * I) * K, F += (q[1] * A + q[5] * U + q[9] * I) * K, Z += (q[2] * A + q[6] * U + q[10] * I) * K;
|
|
2272
2288
|
}
|
|
2273
|
-
const
|
|
2274
|
-
|
|
2289
|
+
const J = Math.sqrt(z * z + F * F + Z * Z);
|
|
2290
|
+
J > 1e-4 && (n[d] = z / J, n[d + 1] = F / J, n[d + 2] = Z / J), r[d] = _, r[d + 1] = $, r[d + 2] = T;
|
|
2275
2291
|
}
|
|
2276
2292
|
}
|
|
2277
2293
|
}
|
|
2278
|
-
class
|
|
2294
|
+
class yr {
|
|
2279
2295
|
constructor({ duration: t = 0, loop: e = !1, playbackRate: i = 1 } = {}) {
|
|
2280
2296
|
this.currentTime = 0, this.duration = t, this.loop = e, this.playbackRate = i, this.paused = !1, this._justLooped = !1;
|
|
2281
2297
|
}
|
|
@@ -2296,7 +2312,7 @@ class js {
|
|
|
2296
2312
|
this.currentTime = Math.max(0, t || 0), this._justLooped = !1;
|
|
2297
2313
|
}
|
|
2298
2314
|
}
|
|
2299
|
-
const
|
|
2315
|
+
const Di = {
|
|
2300
2316
|
linear: (s) => s,
|
|
2301
2317
|
easeInQuad: (s) => s * s,
|
|
2302
2318
|
easeOutQuad: (s) => 1 - (1 - s) * (1 - s),
|
|
@@ -2315,26 +2331,26 @@ const hi = {
|
|
|
2315
2331
|
return Math.pow(2, -10 * s) * Math.sin((s * 10 - 0.75) * t) + 1;
|
|
2316
2332
|
}
|
|
2317
2333
|
};
|
|
2318
|
-
function
|
|
2319
|
-
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, c = 3 * (i - t) - o, l = 1 - o - c,
|
|
2320
|
-
return (
|
|
2321
|
-
if (
|
|
2322
|
-
if (
|
|
2323
|
-
let
|
|
2324
|
-
for (let
|
|
2325
|
-
const
|
|
2326
|
-
if (Math.abs(
|
|
2327
|
-
const
|
|
2328
|
-
if (Math.abs(
|
|
2329
|
-
|
|
2334
|
+
function gr(s, t, e, i) {
|
|
2335
|
+
const r = 3 * s, n = 3 * (e - s) - r, a = 1 - r - n, o = 3 * t, c = 3 * (i - t) - o, l = 1 - o - c, d = (p) => ((a * p + n) * p + r) * p, S = (p) => ((l * p + c) * p + o) * p, g = (p) => (3 * a * p + 2 * n) * p + r;
|
|
2336
|
+
return (p) => {
|
|
2337
|
+
if (p <= 0) return 0;
|
|
2338
|
+
if (p >= 1) return 1;
|
|
2339
|
+
let v = p;
|
|
2340
|
+
for (let A = 0; A < 8; A++) {
|
|
2341
|
+
const U = d(v) - p;
|
|
2342
|
+
if (Math.abs(U) < 1e-5) break;
|
|
2343
|
+
const I = g(v);
|
|
2344
|
+
if (Math.abs(I) < 1e-6) break;
|
|
2345
|
+
v -= U / I;
|
|
2330
2346
|
}
|
|
2331
|
-
return
|
|
2347
|
+
return S(v);
|
|
2332
2348
|
};
|
|
2333
2349
|
}
|
|
2334
|
-
function
|
|
2335
|
-
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ?
|
|
2350
|
+
function qi(s, t) {
|
|
2351
|
+
return typeof s == "function" ? s(t) : Array.isArray(s) && s.length === 4 ? gr(s[0], s[1], s[2], s[3])(t) : (Di[s] || Di.linear)(t);
|
|
2336
2352
|
}
|
|
2337
|
-
function
|
|
2353
|
+
function br(s, t) {
|
|
2338
2354
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2339
2355
|
if (s.length === 1 || t <= s[0].t) return s[0].v;
|
|
2340
2356
|
const e = s[s.length - 1];
|
|
@@ -2343,12 +2359,12 @@ function Hs(s, t) {
|
|
|
2343
2359
|
const r = s[i], n = s[i + 1];
|
|
2344
2360
|
if (t >= r.t && t <= n.t) {
|
|
2345
2361
|
const a = n.t - r.t, o = a > 0 ? (t - r.t) / a : 0;
|
|
2346
|
-
return r.v + (n.v - r.v) *
|
|
2362
|
+
return r.v + (n.v - r.v) * qi(r.ease, o);
|
|
2347
2363
|
}
|
|
2348
2364
|
}
|
|
2349
2365
|
return e.v;
|
|
2350
2366
|
}
|
|
2351
|
-
function
|
|
2367
|
+
function Sr(s, t, e) {
|
|
2352
2368
|
if (!Array.isArray(s) || s.length === 0) return;
|
|
2353
2369
|
const i = s.length, r = s[i - 1];
|
|
2354
2370
|
let n, a, o;
|
|
@@ -2358,28 +2374,28 @@ function qs(s, t, e) {
|
|
|
2358
2374
|
n = a = r.v, o = 0;
|
|
2359
2375
|
else {
|
|
2360
2376
|
n = a = r.v, o = 0;
|
|
2361
|
-
for (let
|
|
2362
|
-
const
|
|
2363
|
-
if (t >=
|
|
2364
|
-
const
|
|
2365
|
-
n =
|
|
2377
|
+
for (let S = 0; S < i - 1; S++) {
|
|
2378
|
+
const g = s[S], p = s[S + 1];
|
|
2379
|
+
if (t >= g.t && t <= p.t) {
|
|
2380
|
+
const v = p.t - g.t;
|
|
2381
|
+
n = g.v, a = p.v, o = qi(g.ease, v > 0 ? (t - g.t) / v : 0);
|
|
2366
2382
|
break;
|
|
2367
2383
|
}
|
|
2368
2384
|
}
|
|
2369
2385
|
}
|
|
2370
|
-
const c = n[0] + (a[0] - n[0]) * o, l = n[1] + (a[1] - n[1]) * o,
|
|
2371
|
-
return e ? (e[0] = c, e[1] = l, e[2] =
|
|
2386
|
+
const c = n[0] + (a[0] - n[0]) * o, l = n[1] + (a[1] - n[1]) * o, d = n[2] + (a[2] - n[2]) * o;
|
|
2387
|
+
return e ? (e[0] = c, e[1] = l, e[2] = d, e) : [c, l, d];
|
|
2372
2388
|
}
|
|
2373
|
-
const
|
|
2374
|
-
function
|
|
2389
|
+
const xr = ["gravityStrength", "emissionRate", "damping", "particleSize", "particleSpeed"], vr = { square: 0, circle: 1, triangle: 2, diamond: 3, star: 4, hexagon: 5, ring: 6, heart: 7, cross: 8, spark: 9, leaf: 10, capsule: 11, crescent: 12, line: 13, "curved-line": 14 };
|
|
2390
|
+
function Vi(s) {
|
|
2375
2391
|
const t = atob(s), e = new Uint8Array(t.length);
|
|
2376
2392
|
for (let i = 0; i < t.length; i++)
|
|
2377
2393
|
e[i] = t.charCodeAt(i);
|
|
2378
2394
|
return e.buffer;
|
|
2379
2395
|
}
|
|
2380
|
-
class
|
|
2396
|
+
class Qt {
|
|
2381
2397
|
constructor(t, e) {
|
|
2382
|
-
this.device = t, this.config = e, this.MAX_PARTICLES = e.maxParticles || 1e4, this.particleCount = e.particleCount || 100, this.activeParticles = 0, this.emitting = !1, this.currentEmissionTime = 0, this.destroyed = !1, this.particleData = new Float32Array(this.MAX_PARTICLES * 8), this.particleVelocities = new Float32Array(this.MAX_PARTICLES * 4), this.instanceBuffer = t.createBuffer({
|
|
2398
|
+
this.device = t, this.config = e, this.MAX_PARTICLES = e.maxParticles || 1e4, this.particleCount = e.particleCount || 100, this.activeParticles = 0, this.emitting = !1, this.currentEmissionTime = 0, this.emissionAccumulator = 0, this.destroyed = !1, this.particleData = new Float32Array(this.MAX_PARTICLES * 8), this.particleVelocities = new Float32Array(this.MAX_PARTICLES * 4), this.instanceBuffer = t.createBuffer({
|
|
2383
2399
|
size: this.MAX_PARTICLES * 8 * 4,
|
|
2384
2400
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST | GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_SRC,
|
|
2385
2401
|
label: "particleInstanceBuffer"
|
|
@@ -2403,7 +2419,7 @@ class vt {
|
|
|
2403
2419
|
// intensity (f32) + padding
|
|
2404
2420
|
usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST,
|
|
2405
2421
|
label: "systemBloomIntensityBuffer"
|
|
2406
|
-
}), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new ms(e), this.physics = new _s(t, this.MAX_PARTICLES), this.textureManager = new ws(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition), e.confinementEnabled && this.setConfinement({
|
|
2422
|
+
}), e.overrideXVelocity === void 0 && (e.overrideXVelocity = !1), e.overrideYVelocity === void 0 && (e.overrideYVelocity = !1), e.overrideZVelocity === void 0 && (e.overrideZVelocity = !1), e.xVelocity === void 0 && (e.xVelocity = 0), e.yVelocity === void 0 && (e.yVelocity = 0), e.zVelocity === void 0 && (e.zVelocity = 0), e.textureEnabled === void 0 && (e.textureEnabled = !1), e.glbModelEnabled === void 0 && (e.glbModelEnabled = !1), e.textureType === void 0 && (e.textureType = "image"), e.glbFileName === void 0 && (e.glbFileName = null), e.animationIndex === void 0 && (e.animationIndex = 0), e.animationSpeed === void 0 && (e.animationSpeed = 1), e.animationLoop === void 0 && (e.animationLoop = !0), e.useGlbTexture === void 0 && (e.useGlbTexture = !1), e.glbHasTexture === void 0 && (e.glbHasTexture = !1), e.particleShape === void 0 && (e.particleShape = "square"), e.particleShapeRotation !== void 0 && (e.rotation = (e.rotation || 0) + e.particleShapeRotation, delete e.particleShapeRotation), e.particleShapeRotationX === void 0 && (e.particleShapeRotationX = 0), e.particleShapeRotationY === void 0 && (e.particleShapeRotationY = 0), e.particleShapeRotationZ === void 0 && (e.particleShapeRotationZ = 0), e.particleColor === void 0 && (e.particleColor = [1, 1, 1]), e.startColor === void 0 && (e.startColor = [1, 0, 0]), e.endColor === void 0 && (e.endColor = [0, 0, 1]), e.fadeEnabled === void 0 && (e.fadeEnabled = !0), e.colorTransitionEnabled === void 0 && (e.colorTransitionEnabled = !1), e.randomColorEnabled === void 0 && (e.randomColorEnabled = !1), e.randomColors === void 0 && (e.randomColors = []), e.particleSize === void 0 && (e.particleSize = 0.1), e.particleSpeed === void 0 && (e.particleSpeed = 1), e.opacity === void 0 && (e.opacity = 1), e.aspectRatio === void 0 && (e.aspectRatio = 1), e.rotation === void 0 && (e.rotation = 0), e.rotationMode === void 0 && (e.rotationMode = "fixed"), e.minRotation === void 0 && (e.minRotation = 0), e.maxRotation === void 0 && (e.maxRotation = 90), e.orientX === void 0 && (e.orientX = 0), e.orientY === void 0 && (e.orientY = 0), e.orientZ === void 0 && (e.orientZ = 0), e.randomSize === void 0 && (e.randomSize = !1), e.minSize === void 0 && (e.minSize = 0.05), e.maxSize === void 0 && (e.maxSize = 0.15), e.randomSpeed === void 0 && (e.randomSpeed = !1), e.minSpeed === void 0 && (e.minSpeed = 0.1), e.maxSpeed === void 0 && (e.maxSpeed = 1), e.fadeSizeEnabled === void 0 && (e.fadeSizeEnabled = !1), e.increaseSizeEnabled === void 0 && (e.increaseSizeEnabled = !1), e.sizeLifetimeSpeed === void 0 && (e.sizeLifetimeSpeed = 1), e.bloomEnabled === void 0 && (e.bloomEnabled = !0), e.bloomIntensity === void 0 && (e.bloomIntensity = 1), e.bloomColor === void 0 && (e.bloomColor = [1, 1, 1]), e.gravityEnabled === void 0 && (e.gravityEnabled = !1), e.gravityStrength === void 0 && (e.gravityStrength = 2), e.dampingEnabled === void 0 && (e.dampingEnabled = !1), e.dampingStrength === void 0 && (e.dampingStrength = 1), e.attractorEnabled === void 0 && (e.attractorEnabled = !1), e.attractorStrength === void 0 && (e.attractorStrength = 1), e.attractorPosition === void 0 && (e.attractorPosition = [0, 0, 0]), e.attractorReverse === void 0 && (e.attractorReverse = !1), e.burstMode === void 0 && (e.burstMode = !1), e.emissionShape === void 0 && (e.emissionShape = "cube"), e.lifetime === void 0 && (e.lifetime = 5), e.emissionRate === void 0 && (e.emissionRate = 10), e.startAt === void 0 && (e.startAt = 0), e.emissionDuration === void 0 && (e.emissionDuration = 10), e.emissionDurationInfinite === void 0 && (e.emissionDurationInfinite = !1), e.emissionDuration > 300 && (e.emissionDurationInfinite = !0, e.emissionDuration = 10), e.outerLength === void 0 && (e.outerLength = e.cubeLength ?? 2), e.innerLength === void 0 && (e.innerLength = 0), e.outerRadius === void 0 && (e.outerRadius = 2), e.innerRadius === void 0 && (e.innerRadius = 0), e.squareSize === void 0 && (e.squareSize = 2), e.squareInnerSize === void 0 && (e.squareInnerSize = 0), e.circleInnerRadius === void 0 && (e.circleInnerRadius = 0), e.circleOuterRadius === void 0 && (e.circleOuterRadius = 2), e.circleVelocityDirection === void 0 && (e.circleVelocityDirection = "outward"), e.cylinderInnerRadius === void 0 && (e.cylinderInnerRadius = 0), e.cylinderOuterRadius === void 0 && (e.cylinderOuterRadius = 2), e.cylinderHeight === void 0 && (e.cylinderHeight = 4), e.cylinderVelocityDirection === void 0 && (e.cylinderVelocityDirection = "outward"), e.planeWidth === void 0 && (e.planeWidth = 2), e.planeDepth === void 0 && (e.planeDepth = 2), e.coneOuterRadius === void 0 && (e.coneOuterRadius = 2), e.coneInnerRadius === void 0 && (e.coneInnerRadius = 0), e.coneHeight === void 0 && (e.coneHeight = 4), e.torusMajorRadius === void 0 && (e.torusMajorRadius = 2), e.torusMinorRadius === void 0 && (e.torusMinorRadius = 0.5), e.lineLength === void 0 && (e.lineLength = 4), e.hemisphereOuterRadius === void 0 && (e.hemisphereOuterRadius = 2), e.hemisphereInnerRadius === void 0 && (e.hemisphereInnerRadius = 0), e.discRadius === void 0 && (e.discRadius = 2), e.annulusInnerRadius === void 0 && (e.annulusInnerRadius = 1), e.annulusOuterRadius === void 0 && (e.annulusOuterRadius = 2), e.capsuleRadius === void 0 && (e.capsuleRadius = 0.5), e.capsuleHeight === void 0 && (e.capsuleHeight = 4), e.arcStartAngle === void 0 && (e.arcStartAngle = 0), e.arcEndAngle === void 0 && (e.arcEndAngle = 180), e.arcInnerRadius === void 0 && (e.arcInnerRadius = 0), e.arcOuterRadius === void 0 && (e.arcOuterRadius = 2), e.spiralTurns === void 0 && (e.spiralTurns = 3), e.spiralRadiusStart === void 0 && (e.spiralRadiusStart = 0.5), e.spiralRadiusEnd === void 0 && (e.spiralRadiusEnd = 2), e.spiralHeight === void 0 && (e.spiralHeight = 4), e.frustumRadiusNear === void 0 && (e.frustumRadiusNear = 0.5), e.frustumRadiusFar === void 0 && (e.frustumRadiusFar = 2), e.frustumHeight === void 0 && (e.frustumHeight = 4), e.cubeSurfaceSize === void 0 && (e.cubeSurfaceSize = 2), e.sphereSurfaceRadius === void 0 && (e.sphereSurfaceRadius = 2), e.boxFrameSize === void 0 && (e.boxFrameSize = 2), e.polygonSides === void 0 && (e.polygonSides = 6), e.polygonRadius === void 0 && (e.polygonRadius = 2), e.emissionRotationX === void 0 && (e.emissionRotationX = 0), e.emissionRotationY === void 0 && (e.emissionRotationY = 0), e.emissionRotationZ === void 0 && (e.emissionRotationZ = 0), e.emissionPositionX === void 0 && (e.emissionPositionX = e.emissionTranslationX ?? 0), e.emissionPositionY === void 0 && (e.emissionPositionY = e.emissionTranslationY ?? 0), e.emissionPositionZ === void 0 && (e.emissionPositionZ = e.emissionTranslationZ ?? 0), e.pulseEnabled === void 0 && (e.pulseEnabled = !1), e.pulseAmplitude === void 0 && (e.pulseAmplitude = 0.5), e.pulseFrequency === void 0 && (e.pulseFrequency = 1), e.pulsePhaseRandom === void 0 && (e.pulsePhaseRandom = 0), e.pulseOpacity === void 0 && (e.pulseOpacity = !1), e.confinementEnabled === void 0 && (e.confinementEnabled = !1), e.confinementShape === void 0 && (e.confinementShape = "box"), e.confinementMode === void 0 && (e.confinementMode = "bounce"), e.confinementSpace === void 0 && (e.confinementSpace = "world"), e.confinementBoxHalfSize === void 0 && (e.confinementBoxHalfSize = [2, 2, 2]), e.confinementSphereRadius === void 0 && (e.confinementSphereRadius = 3), e.confinementRestitution === void 0 && (e.confinementRestitution = 0.8), e.confinementFriction === void 0 && (e.confinementFriction = 0.1), e.softBoundaryEnabled === void 0 && (e.softBoundaryEnabled = !1), e.softBoundaryStrength === void 0 && (e.softBoundaryStrength = 5), e.softBoundaryFalloff === void 0 && (e.softBoundaryFalloff = 0.5), e.depthWriteEnabled === void 0 && (e.depthWriteEnabled = !1), e.velocityStretchEnabled === void 0 && (e.velocityStretchEnabled = !1), e.velocityStretchFactor === void 0 && (e.velocityStretchFactor = 1), e.blendMode === void 0 && (e.blendMode = "normal"), e.noiseDistortEnabled === void 0 && (e.noiseDistortEnabled = !1), e.noiseTilingX === void 0 && (e.noiseTilingX = 3), e.noiseTilingY === void 0 && (e.noiseTilingY = 3), e.noiseSpeed === void 0 && (e.noiseSpeed = -1.5), e.noiseAmplitude === void 0 && (e.noiseAmplitude = 0.08), e.emissionTrailEnabled === void 0 && (e.emissionTrailEnabled = !1), e.emissionTrailDuration === void 0 && (e.emissionTrailDuration = 1), e.emissionTrailWidth === void 0 && (e.emissionTrailWidth = 0.3), e.emissionTrailMinDistance === void 0 && (e.emissionTrailMinDistance = 0.05), e.emissionTrailMaxPoints === void 0 && (e.emissionTrailMaxPoints = 256), e.emissionTrailSegments === void 0 && (e.emissionTrailSegments = 8), e.emissionTrailMode === void 0 && (e.emissionTrailMode = "ribbon"), e.emissionTrailShape === void 0 && (e.emissionTrailShape = "straight"), e.emissionTrailShapeAmplitude === void 0 && (e.emissionTrailShapeAmplitude = 0.1), e.emissionTrailShapeFrequency === void 0 && (e.emissionTrailShapeFrequency = 4), e.emissionTrailShapeSpeed === void 0 && (e.emissionTrailShapeSpeed = 0), e.shapeStrokeEnabled === void 0 && (e.shapeStrokeEnabled = !1), e.shapeStrokeWidth === void 0 && (e.shapeStrokeWidth = 0.08), e.shapeStrokeSegments === void 0 && (e.shapeStrokeSegments = 96), e.shapeStrokeShape === void 0 && (e.shapeStrokeShape = "straight"), e.shapeStrokeAmplitude === void 0 && (e.shapeStrokeAmplitude = 0.08), e.shapeStrokeFrequency === void 0 && (e.shapeStrokeFrequency = 10), e.shapeStrokeSpeed === void 0 && (e.shapeStrokeSpeed = 0), e.shapeDisplay === void 0 && (e.shapeDisplay = !0), e.followSystemTranslation === void 0 && (e.followSystemTranslation = !0), e.followSystemId === void 0 && (e.followSystemId = null), this._newEmissions = [], this._emptyEmissions = [], this._pendingFollowEmissions = this._emptyEmissions, this.glbVertexBuffer = null, this.glbIndexBuffer = null, this.glbIndexCount = 0, this.glbIndexFormat = "uint16", this.glbMeshData = null, this.glbRawArrayBuffer = null, this.glbAnimator = null, this.glbAnimated = !1, this._glbInterleavedData = null, this._appearanceData = new Float32Array(56), this._bloomIntensityData = new Float32Array(16), this._simPosition = [0, 0, 0], this._simVelocity = [0, 0, 0], this._simRotMatrix = null, this._simRotX = 0, this._simRotZ = 0, this._emitSimRotY = 0, this.emitter = new ks(e), this.physics = new $s(t, this.MAX_PARTICLES), this.textureManager = new Ws(t), e.gravityEnabled && this.setGravity(e.gravityStrength || 0), e.dampingEnabled && this.physics.setDamping(e.dampingStrength || 0), e.attractorEnabled && e.attractorPosition && this.setAttractor(e.attractorStrength || 0, e.attractorPosition, e.attractorReverse), e.confinementEnabled && this.setConfinement({
|
|
2407
2423
|
enabled: !0,
|
|
2408
2424
|
shape: e.confinementShape,
|
|
2409
2425
|
mode: e.confinementMode,
|
|
@@ -2416,7 +2432,7 @@ class vt {
|
|
|
2416
2432
|
enabled: !0,
|
|
2417
2433
|
strength: e.softBoundaryStrength,
|
|
2418
2434
|
falloff: e.softBoundaryFalloff
|
|
2419
|
-
}), 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
|
|
2435
|
+
}), this.particleTexture = this.textureManager.getDefaultTexture(), this.updateBloomIntensity(), this.updateAppearanceUniform(), this.frameCount = 0, this.shouldReset = !1, this._scriptParticleData = new Float32Array(this.MAX_PARTICLES * 8), this._scriptVelocityData = new Float32Array(this.MAX_PARTICLES * 4), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, this._particleScript = null, e.script && (this._particleScript = new Ii(e.script, e, this.MAX_PARTICLES)), this.initComputePipeline(t);
|
|
2420
2436
|
}
|
|
2421
2437
|
async initComputePipeline(t) {
|
|
2422
2438
|
this.computeReady = await this.physics.initComputePipeline(this.instanceBuffer, this.velocityBuffer, this.trailBuffer);
|
|
@@ -2426,7 +2442,7 @@ class vt {
|
|
|
2426
2442
|
* @param {string|null} source - Script source code, or null to disable
|
|
2427
2443
|
*/
|
|
2428
2444
|
setScript(t) {
|
|
2429
|
-
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
|
|
2445
|
+
this._particleScript && (this._particleScript.destroy(), this._particleScript = null), this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptFrame = 0, this._scriptTime = 0, this._scriptConfigRestored = !1, t ? (this.config.script = t, this._particleScript = new Ii(t, this.config, this.MAX_PARTICLES), this._particleScript.snapshotConfig(this.config)) : delete this.config.script;
|
|
2430
2446
|
}
|
|
2431
2447
|
async setTexture(t) {
|
|
2432
2448
|
this.destroyed || (this.textureManager.destroyTexture(this.particleTexture), this.particleTexture = await this.textureManager.loadTexture(t), this.config.textureEnabled = !0, this.updateAppearanceUniform(), this.updateBuffers());
|
|
@@ -2437,7 +2453,7 @@ class vt {
|
|
|
2437
2453
|
async setGLBModel(t) {
|
|
2438
2454
|
try {
|
|
2439
2455
|
this.glbRawArrayBuffer = t;
|
|
2440
|
-
const e = await
|
|
2456
|
+
const e = await ir(t);
|
|
2441
2457
|
this.glbMeshData = e, this.config.glbHasTexture = e.hasBaseColorTexture || !1;
|
|
2442
2458
|
const i = new Float32Array(e.vertexCount * 8);
|
|
2443
2459
|
for (let r = 0; r < e.vertexCount; r++) {
|
|
@@ -2453,7 +2469,7 @@ class vt {
|
|
|
2453
2469
|
usage: GPUBufferUsage.INDEX | GPUBufferUsage.COPY_DST,
|
|
2454
2470
|
label: "glbIndexBuffer"
|
|
2455
2471
|
}), this.device.queue.writeBuffer(this.glbIndexBuffer, 0, e.indices), this.glbIndexCount = e.indexCount, this.glbIndexFormat = e.indices instanceof Uint32Array ? "uint32" : "uint16", this.config.glbModelEnabled = !0, this.config.textureType = "glb", e.animationData) {
|
|
2456
|
-
this.glbAnimator = new
|
|
2472
|
+
this.glbAnimator = new mr(e.animationData), this.glbAnimator.setRestPose(e.positions, e.normals), this.glbAnimated = !0, this.config.glbAnimated = !0, this.glbAnimator.loop = this.config.animationLoop, this._glbInterleavedData = new Float32Array(e.vertexCount * 8);
|
|
2457
2473
|
try {
|
|
2458
2474
|
await this.glbAnimator.initGPUSkinning(this.device, this.glbVertexBuffer, e.texCoords);
|
|
2459
2475
|
} catch (r) {
|
|
@@ -2515,7 +2531,7 @@ class vt {
|
|
|
2515
2531
|
if (this.destroyed) return;
|
|
2516
2532
|
let t = 0;
|
|
2517
2533
|
this.config.rotationMode === "random" ? t = 1 : this.config.rotationMode === "velocity" ? t = 2 : this.config.rotationMode === "oriented" ? t = 3 : this.config.rotationMode === "cylindrical" && (t = 4);
|
|
2518
|
-
const e =
|
|
2534
|
+
const e = vr[this.config.particleShape] ?? 0, i = this._appearanceData;
|
|
2519
2535
|
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;
|
|
2520
2536
|
const r = this.config.followSystemTranslation ?? !0;
|
|
2521
2537
|
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);
|
|
@@ -2527,7 +2543,7 @@ class vt {
|
|
|
2527
2543
|
t[4] = e[0], t[5] = e[1], t[6] = e[2], this.device.queue.writeBuffer(this.bloomIntensityBuffer, 0, t);
|
|
2528
2544
|
}
|
|
2529
2545
|
spawnParticles() {
|
|
2530
|
-
if (this.activeParticles = 0, this.currentEmissionTime = 0, this._newEmissions.length = 0, this._pendingFollowEmissions = this._emptyEmissions, this._scriptFrame = 0, this._scriptTime = 0, this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptConfigRestored = !1, this._particleScript && (this._particleScript._configSnapshot ? (this._particleScript.restoreConfig(this.config), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition), this.updateAppearanceUniform(), this.updateBloomIntensity()) : this._particleScript.snapshotConfig(this.config)), this.device.queue.writeBuffer(this.trailBuffer, 0, this._trailResetData, 0, this.MAX_PARTICLES * 4), this.glbAnimator && (this.glbAnimator.currentTime = 0, this.glbAnimator.playing = !0), this.config.followSystemId) {
|
|
2546
|
+
if (this.activeParticles = 0, this.currentEmissionTime = 0, this.emissionAccumulator = 0, this._newEmissions.length = 0, this._pendingFollowEmissions = this._emptyEmissions, this._scriptFrame = 0, this._scriptTime = 0, this._scriptReadbackPending = !1, this._scriptReadbackReady = !1, this._scriptConfigRestored = !1, this._particleScript && (this._particleScript._configSnapshot ? (this._particleScript.restoreConfig(this.config), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse), this.updateAppearanceUniform(), this.updateBloomIntensity()) : this._particleScript.snapshotConfig(this.config)), this.device.queue.writeBuffer(this.trailBuffer, 0, this._trailResetData, 0, this.MAX_PARTICLES * 4), this.glbAnimator && (this.glbAnimator.currentTime = 0, this.glbAnimator.playing = !0), this.config.followSystemId) {
|
|
2531
2547
|
this.emitting = !0, this.particleCount = this.MAX_PARTICLES;
|
|
2532
2548
|
return;
|
|
2533
2549
|
}
|
|
@@ -2577,8 +2593,8 @@ class vt {
|
|
|
2577
2593
|
this._emitSimRotY = this._simRotY || 0;
|
|
2578
2594
|
const e = t * 8, i = t * 4;
|
|
2579
2595
|
if (this._simRotMatrix) {
|
|
2580
|
-
const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2], c = this.particleVelocities[i], l = this.particleVelocities[i + 1],
|
|
2581
|
-
this.particleData[e] = r[0] * n + r[1] * a + r[2] * o, this.particleData[e + 1] = r[3] * n + r[4] * a + r[5] * o, this.particleData[e + 2] = r[6] * n + r[7] * a + r[8] * o, this.particleVelocities[i] = r[0] * c + r[1] * l + r[2] *
|
|
2596
|
+
const r = this._simRotMatrix, n = this.particleData[e], a = this.particleData[e + 1], o = this.particleData[e + 2], c = this.particleVelocities[i], l = this.particleVelocities[i + 1], d = this.particleVelocities[i + 2];
|
|
2597
|
+
this.particleData[e] = r[0] * n + r[1] * a + r[2] * o, this.particleData[e + 1] = r[3] * n + r[4] * a + r[5] * o, this.particleData[e + 2] = r[6] * n + r[7] * a + r[8] * o, this.particleVelocities[i] = r[0] * c + r[1] * l + r[2] * d, this.particleVelocities[i + 1] = r[3] * c + r[4] * l + r[5] * d, this.particleVelocities[i + 2] = r[6] * c + r[7] * l + r[8] * d;
|
|
2582
2598
|
}
|
|
2583
2599
|
(this.config.followSystemTranslation ?? !0) || (this.particleData[e] += this._simPosition[0], this.particleData[e + 1] += this._simPosition[1], this.particleData[e + 2] += this._simPosition[2]);
|
|
2584
2600
|
}
|
|
@@ -2610,20 +2626,20 @@ class vt {
|
|
|
2610
2626
|
const r = this.config.startAt || 0, n = r > 0 && i < r;
|
|
2611
2627
|
if (this._particleScript && this._scriptReadbackReady) {
|
|
2612
2628
|
this._scriptReadbackReady = !1, this._scriptTime += t, this._scriptFrame++;
|
|
2613
|
-
const
|
|
2614
|
-
if (
|
|
2615
|
-
this._scriptConfigRestored = !0, this._particleScript._configSnapshot && (this._particleScript.restoreConfig(this.config), this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition));
|
|
2629
|
+
const d = this.config.emissionDurationInfinite ? 1 / 0 : (this.config.emissionDuration || 0) + (this.config.lifetime || 0);
|
|
2630
|
+
if (d > 0 && this._scriptTime >= d && !this._scriptConfigRestored)
|
|
2631
|
+
this._scriptConfigRestored = !0, this._particleScript._configSnapshot && (this._particleScript.restoreConfig(this.config), this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse));
|
|
2616
2632
|
else if (!this._scriptConfigRestored) {
|
|
2617
|
-
const
|
|
2633
|
+
const S = d > 0 ? Math.ceil(d / 0.016666666666666666) : 0, { configDirty: g, particlesDirty: p } = this._particleScript.execute(
|
|
2618
2634
|
t,
|
|
2619
2635
|
this._scriptTime,
|
|
2620
2636
|
this._scriptFrame,
|
|
2621
|
-
|
|
2637
|
+
S,
|
|
2622
2638
|
this._scriptParticleData,
|
|
2623
2639
|
this._scriptVelocityData,
|
|
2624
2640
|
this.activeParticles
|
|
2625
2641
|
);
|
|
2626
|
-
|
|
2642
|
+
p && this.activeParticles > 0 && (this.device.queue.writeBuffer(
|
|
2627
2643
|
this.instanceBuffer,
|
|
2628
2644
|
0,
|
|
2629
2645
|
this._scriptParticleData,
|
|
@@ -2635,60 +2651,58 @@ class vt {
|
|
|
2635
2651
|
this._scriptVelocityData,
|
|
2636
2652
|
0,
|
|
2637
2653
|
this.activeParticles * 4
|
|
2638
|
-
)),
|
|
2654
|
+
)), g && (this.updateAppearanceUniform(), this.updateBloomIntensity(), this.config.gravityEnabled && this.setGravity(this.config.gravityStrength), this.config.dampingEnabled && this.physics.setDamping(this.config.dampingStrength), this.config.attractorEnabled && this.setAttractor(this.config.attractorStrength, this.config.attractorPosition, this.config.attractorReverse));
|
|
2639
2655
|
}
|
|
2640
2656
|
}
|
|
2641
2657
|
this.physics.physicsAccumulator += t;
|
|
2642
2658
|
const a = performance.now() / 1e3, c = a - this.physics.lastUpdateTime > 1 / this.physics.minUpdatesPerSecond, l = this.activeParticles;
|
|
2643
2659
|
if (!n && !this.emitting && !this.config.burstMode && !this.config.followSystemId && this.currentEmissionTime < this.effectiveEmissionDuration && (this.emitting = !0), !n && this.emitting)
|
|
2644
2660
|
if (this.currentEmissionTime += t, this.currentEmissionTime < this.effectiveEmissionDuration) {
|
|
2645
|
-
const
|
|
2646
|
-
let
|
|
2661
|
+
const d = this.activeParticles;
|
|
2662
|
+
let S = !1;
|
|
2647
2663
|
if (this.config.followSystemId) {
|
|
2648
2664
|
if (this._pendingFollowEmissions.length > 0) {
|
|
2649
|
-
const
|
|
2650
|
-
for (let
|
|
2651
|
-
const
|
|
2665
|
+
const g = this._pendingFollowEmissions.length / 6;
|
|
2666
|
+
for (let p = 0; p < g; p++) {
|
|
2667
|
+
const v = p * 6;
|
|
2652
2668
|
if (this.emitFollowerParticle(
|
|
2653
|
-
this._pendingFollowEmissions[
|
|
2654
|
-
this._pendingFollowEmissions[
|
|
2655
|
-
this._pendingFollowEmissions[
|
|
2669
|
+
this._pendingFollowEmissions[v],
|
|
2670
|
+
this._pendingFollowEmissions[v + 1],
|
|
2671
|
+
this._pendingFollowEmissions[v + 2]
|
|
2656
2672
|
))
|
|
2657
|
-
|
|
2673
|
+
S = !0;
|
|
2658
2674
|
else
|
|
2659
2675
|
break;
|
|
2660
2676
|
}
|
|
2661
2677
|
}
|
|
2662
2678
|
} else {
|
|
2663
|
-
let
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
for (let d = 0; d < p && this.emitParticle(); d++)
|
|
2674
|
-
m = !0;
|
|
2679
|
+
let g = 0;
|
|
2680
|
+
const p = Math.max(0, this.config.emissionRate || 0);
|
|
2681
|
+
this.activeParticles < this.particleCount && p > 0 ? (this.emissionAccumulator += p * t, g = Math.floor(this.emissionAccumulator + 1e-9), g > 0 && (this.emissionAccumulator -= g)) : this.activeParticles >= this.particleCount && (this.emissionAccumulator = 0);
|
|
2682
|
+
for (let v = 0; v < g; v++)
|
|
2683
|
+
if (this.emitParticle())
|
|
2684
|
+
S = !0;
|
|
2685
|
+
else {
|
|
2686
|
+
this.emissionAccumulator = 0;
|
|
2687
|
+
break;
|
|
2688
|
+
}
|
|
2675
2689
|
}
|
|
2676
|
-
if (
|
|
2677
|
-
const
|
|
2690
|
+
if (S) {
|
|
2691
|
+
const g = this.activeParticles - d, p = d * 8, v = d * 4;
|
|
2678
2692
|
this.device.queue.writeBuffer(
|
|
2679
2693
|
this.instanceBuffer,
|
|
2680
|
-
|
|
2694
|
+
p * 4,
|
|
2681
2695
|
// Offset in bytes (float32 = 4 bytes)
|
|
2682
2696
|
this.particleData,
|
|
2683
|
-
|
|
2684
|
-
|
|
2697
|
+
p,
|
|
2698
|
+
g * 8
|
|
2685
2699
|
), this.device.queue.writeBuffer(
|
|
2686
2700
|
this.velocityBuffer,
|
|
2687
|
-
|
|
2701
|
+
v * 4,
|
|
2688
2702
|
// Offset in bytes (float32 = 4 bytes)
|
|
2689
2703
|
this.particleVelocities,
|
|
2690
|
-
|
|
2691
|
-
|
|
2704
|
+
v,
|
|
2705
|
+
g * 4
|
|
2692
2706
|
);
|
|
2693
2707
|
}
|
|
2694
2708
|
} else
|
|
@@ -2715,8 +2729,8 @@ class vt {
|
|
|
2715
2729
|
this._scriptVelocityData,
|
|
2716
2730
|
this.instanceBuffer,
|
|
2717
2731
|
this.velocityBuffer
|
|
2718
|
-
).then((
|
|
2719
|
-
this._scriptReadbackPending = !1,
|
|
2732
|
+
).then((d) => {
|
|
2733
|
+
this._scriptReadbackPending = !1, d.shouldUpdate && (this._scriptReadbackReady = !0);
|
|
2720
2734
|
}).catch(() => {
|
|
2721
2735
|
this._scriptReadbackPending = !1;
|
|
2722
2736
|
}));
|
|
@@ -2744,8 +2758,8 @@ class vt {
|
|
|
2744
2758
|
if (e !== r) {
|
|
2745
2759
|
const o = r * 8, c = e * 8;
|
|
2746
2760
|
this.particleData.copyWithin(c, o, o + 8);
|
|
2747
|
-
const l = r * 4,
|
|
2748
|
-
this.particleVelocities.copyWithin(
|
|
2761
|
+
const l = r * 4, d = e * 4;
|
|
2762
|
+
this.particleVelocities.copyWithin(d, l, l + 4), i = !0;
|
|
2749
2763
|
}
|
|
2750
2764
|
e++;
|
|
2751
2765
|
}
|
|
@@ -2774,17 +2788,17 @@ class vt {
|
|
|
2774
2788
|
}
|
|
2775
2789
|
updateParticleVelocities() {
|
|
2776
2790
|
for (let t = 0; t < this.activeParticles; t++) {
|
|
2777
|
-
const e = t * 8, i = t * 4, r = this.particleData[e], n = this.particleData[e + 1], a = this.particleData[e + 2], o = this.particleVelocities[i], c = this.particleVelocities[i + 1], l = this.particleVelocities[i + 2],
|
|
2791
|
+
const e = t * 8, i = t * 4, r = this.particleData[e], n = this.particleData[e + 1], a = this.particleData[e + 2], o = this.particleVelocities[i], c = this.particleVelocities[i + 1], l = this.particleVelocities[i + 2], d = Math.sqrt(
|
|
2778
2792
|
o * o + c * c + l * l
|
|
2779
2793
|
);
|
|
2780
|
-
if (
|
|
2781
|
-
const
|
|
2782
|
-
this.particleVelocities[i] = o /
|
|
2794
|
+
if (d > 1e-3) {
|
|
2795
|
+
const S = this.config.particleSpeed * 2;
|
|
2796
|
+
this.particleVelocities[i] = o / d * S, this.particleVelocities[i + 1] = c / d * S, this.particleVelocities[i + 2] = l / d * S;
|
|
2783
2797
|
} else {
|
|
2784
|
-
const
|
|
2785
|
-
if (
|
|
2786
|
-
const
|
|
2787
|
-
this.particleVelocities[i] = r /
|
|
2798
|
+
const S = Math.sqrt(r * r + n * n + a * a);
|
|
2799
|
+
if (S > 1e-3) {
|
|
2800
|
+
const g = this.config.particleSpeed * 2;
|
|
2801
|
+
this.particleVelocities[i] = r / S * g, this.particleVelocities[i + 1] = n / S * g, this.particleVelocities[i + 2] = a / S * g;
|
|
2788
2802
|
} else
|
|
2789
2803
|
this.particleVelocities[i] = 0, this.particleVelocities[i + 1] = this.config.particleSpeed * 2, this.particleVelocities[i + 2] = 0;
|
|
2790
2804
|
}
|
|
@@ -2818,8 +2832,8 @@ class vt {
|
|
|
2818
2832
|
setGravity(t) {
|
|
2819
2833
|
this.physics.setGravity(t);
|
|
2820
2834
|
}
|
|
2821
|
-
setAttractor(t, e) {
|
|
2822
|
-
this.physics.setAttractor(t, e);
|
|
2835
|
+
setAttractor(t, e, i = this.config.attractorReverse) {
|
|
2836
|
+
this.config.attractorStrength = t, this.config.attractorPosition = e, this.config.attractorReverse = !!i, this.physics.setAttractor(t, e, i);
|
|
2823
2837
|
}
|
|
2824
2838
|
setConfinement(t) {
|
|
2825
2839
|
const e = t.center || this.config.confinementCenter || [0, 0, 0], i = t.space === "local" ? [this.config.emissionPositionX || 0, this.config.emissionPositionY || 0, this.config.emissionPositionZ || 0] : [0, 0, 0], r = [i[0] + (e[0] || 0), i[1] + (e[1] || 0), i[2] + (e[2] || 0)];
|
|
@@ -2829,16 +2843,16 @@ class vt {
|
|
|
2829
2843
|
this.physics.setSoftBoundary(t);
|
|
2830
2844
|
}
|
|
2831
2845
|
}
|
|
2832
|
-
class
|
|
2846
|
+
class Pr {
|
|
2833
2847
|
constructor(t) {
|
|
2834
|
-
this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new
|
|
2848
|
+
this.device = t, this.particleSystems = [], this.activeSystemIndex = 0, this.systemCounter = 1, this.onSystemCreated = null, this.loop = void 0, this.clock = new yr({ loop: !!this.loop }), this.ready = !0;
|
|
2835
2849
|
}
|
|
2836
2850
|
createParticleSystem(t = {}) {
|
|
2837
2851
|
const e = this.systemCounter++, i = t.name || `System ${e + 1}`, r = {
|
|
2838
2852
|
...t,
|
|
2839
2853
|
name: i,
|
|
2840
2854
|
id: e
|
|
2841
|
-
}, n = new
|
|
2855
|
+
}, n = new Qt(this.device, r);
|
|
2842
2856
|
return this.particleSystems.push({
|
|
2843
2857
|
system: n,
|
|
2844
2858
|
config: r
|
|
@@ -2902,16 +2916,16 @@ class Ws {
|
|
|
2902
2916
|
for (const { system: o, config: c } of this.particleSystems) {
|
|
2903
2917
|
const l = c.keyframes;
|
|
2904
2918
|
if (!(!l || c.keyframesEnabled === !1)) {
|
|
2905
|
-
for (const
|
|
2906
|
-
const
|
|
2907
|
-
if (
|
|
2908
|
-
const
|
|
2909
|
-
|
|
2919
|
+
for (const d of xr) {
|
|
2920
|
+
const S = l[d];
|
|
2921
|
+
if (S && S.length) {
|
|
2922
|
+
const g = br(S, a);
|
|
2923
|
+
g !== void 0 && (c[d] = g);
|
|
2910
2924
|
}
|
|
2911
2925
|
}
|
|
2912
2926
|
if (l.particleColor && l.particleColor.length) {
|
|
2913
|
-
const
|
|
2914
|
-
|
|
2927
|
+
const d = c.particleColor, S = d && typeof d.length == "number" && d.length >= 3 ? d : void 0, g = Sr(l.particleColor, a, S);
|
|
2928
|
+
g && (c.particleColor = g, o.updateAppearanceUniform());
|
|
2915
2929
|
}
|
|
2916
2930
|
}
|
|
2917
2931
|
}
|
|
@@ -2962,7 +2976,7 @@ class Ws {
|
|
|
2962
2976
|
const n = this.systemCounter++, a = {
|
|
2963
2977
|
...r,
|
|
2964
2978
|
id: n
|
|
2965
|
-
}, o = new
|
|
2979
|
+
}, o = new Qt(this.device, a);
|
|
2966
2980
|
this.particleSystems.push({
|
|
2967
2981
|
system: o,
|
|
2968
2982
|
config: a
|
|
@@ -2980,7 +2994,7 @@ class Ws {
|
|
|
2980
2994
|
try {
|
|
2981
2995
|
let a = null;
|
|
2982
2996
|
if (n.glbModelData)
|
|
2983
|
-
a =
|
|
2997
|
+
a = Vi(n.glbModelData);
|
|
2984
2998
|
else if (n.glbFileName) {
|
|
2985
2999
|
const o = await fetch(`/${n.glbFileName}`);
|
|
2986
3000
|
o.ok ? a = await o.arrayBuffer() : console.warn(`GLB file not found: ${n.glbFileName}`);
|
|
@@ -2988,7 +3002,7 @@ class Ws {
|
|
|
2988
3002
|
if (a) {
|
|
2989
3003
|
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))
|
|
2990
3004
|
try {
|
|
2991
|
-
const o = await
|
|
3005
|
+
const o = await Fi(a);
|
|
2992
3006
|
if (o) {
|
|
2993
3007
|
const c = await createImageBitmap(o.imageBlob);
|
|
2994
3008
|
await r.setTexture(c), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${n.name}`);
|
|
@@ -3056,9 +3070,9 @@ class Ws {
|
|
|
3056
3070
|
(o.confinementCenter[1] || 0) + e[1],
|
|
3057
3071
|
(o.confinementCenter[2] || 0) + e[2]
|
|
3058
3072
|
]);
|
|
3059
|
-
const
|
|
3073
|
+
const d = new Qt(this.device, l);
|
|
3060
3074
|
this.particleSystems.push({
|
|
3061
|
-
system:
|
|
3075
|
+
system: d,
|
|
3062
3076
|
config: l
|
|
3063
3077
|
}), this.onSystemCreated && typeof this.onSystemCreated == "function" && this.onSystemCreated(c, l);
|
|
3064
3078
|
}
|
|
@@ -3075,21 +3089,21 @@ class Ws {
|
|
|
3075
3089
|
try {
|
|
3076
3090
|
let l = null;
|
|
3077
3091
|
if (c.glbModelData)
|
|
3078
|
-
l =
|
|
3092
|
+
l = Vi(c.glbModelData);
|
|
3079
3093
|
else if (c.glbFileName) {
|
|
3080
|
-
const
|
|
3081
|
-
|
|
3094
|
+
const d = await fetch(`/${c.glbFileName}`);
|
|
3095
|
+
d.ok ? l = await d.arrayBuffer() : console.warn(`GLB file not found: ${c.glbFileName}`);
|
|
3082
3096
|
}
|
|
3083
3097
|
if (l) {
|
|
3084
3098
|
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))
|
|
3085
3099
|
try {
|
|
3086
|
-
const
|
|
3087
|
-
if (
|
|
3088
|
-
const
|
|
3089
|
-
await o.setTexture(
|
|
3100
|
+
const d = await Fi(l);
|
|
3101
|
+
if (d) {
|
|
3102
|
+
const S = await createImageBitmap(d.imageBlob);
|
|
3103
|
+
await o.setTexture(S), globalThis.__HZFX_DEBUG && console.log(`GLB embedded texture restored for ${c.name}`);
|
|
3090
3104
|
}
|
|
3091
|
-
} catch (
|
|
3092
|
-
console.warn(`Failed to restore GLB texture for ${c.name}:`,
|
|
3105
|
+
} catch (d) {
|
|
3106
|
+
console.warn(`Failed to restore GLB texture for ${c.name}:`, d), c.useGlbTexture = !1;
|
|
3093
3107
|
}
|
|
3094
3108
|
} else
|
|
3095
3109
|
c.glbModelEnabled = !1;
|
|
@@ -3100,11 +3114,11 @@ class Ws {
|
|
|
3100
3114
|
if (c.textureEnabled && !c.glbModelEnabled && c.textureImageData && !o._textureRestored)
|
|
3101
3115
|
try {
|
|
3102
3116
|
const l = new Image();
|
|
3103
|
-
await new Promise((
|
|
3104
|
-
l.onload =
|
|
3117
|
+
await new Promise((S, g) => {
|
|
3118
|
+
l.onload = S, l.onerror = g, l.src = c.textureImageData;
|
|
3105
3119
|
});
|
|
3106
|
-
const
|
|
3107
|
-
await o.setTexture(
|
|
3120
|
+
const d = await createImageBitmap(l);
|
|
3121
|
+
await o.setTexture(d), o._textureRestored = !0;
|
|
3108
3122
|
} catch (l) {
|
|
3109
3123
|
console.warn(`Failed to restore texture for ${c.name}:`, l), c.textureEnabled = !1;
|
|
3110
3124
|
}
|
|
@@ -3116,7 +3130,7 @@ class Ws {
|
|
|
3116
3130
|
}
|
|
3117
3131
|
}
|
|
3118
3132
|
}
|
|
3119
|
-
async function
|
|
3133
|
+
async function _r(s) {
|
|
3120
3134
|
if (!s)
|
|
3121
3135
|
throw new Error("canvas is required for initWebGPU()");
|
|
3122
3136
|
if (!navigator.gpu)
|
|
@@ -3128,37 +3142,37 @@ async function Js(s) {
|
|
|
3128
3142
|
alphaMode: "premultiplied"
|
|
3129
3143
|
}), { device: i, context: t, format: r, canvas: s };
|
|
3130
3144
|
}
|
|
3131
|
-
const
|
|
3132
|
-
function
|
|
3145
|
+
const Ne = "rgba16float";
|
|
3146
|
+
function Oi(s, t, e, i) {
|
|
3133
3147
|
const r = s.createTexture({
|
|
3134
3148
|
size: [e, i],
|
|
3135
|
-
format:
|
|
3149
|
+
format: Ne,
|
|
3136
3150
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3137
3151
|
mipLevelCount: 1,
|
|
3138
3152
|
sampleCount: 1
|
|
3139
3153
|
}), n = s.createTexture({
|
|
3140
3154
|
size: [e, i],
|
|
3141
|
-
format:
|
|
3155
|
+
format: Ne,
|
|
3142
3156
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3143
3157
|
mipLevelCount: 1,
|
|
3144
3158
|
sampleCount: 1
|
|
3145
3159
|
}), a = s.createTexture({
|
|
3146
3160
|
size: [e, i],
|
|
3147
|
-
format:
|
|
3161
|
+
format: Ne,
|
|
3148
3162
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
|
|
3149
3163
|
mipLevelCount: 1,
|
|
3150
3164
|
sampleCount: 1
|
|
3151
3165
|
});
|
|
3152
3166
|
return { sceneTexture: r, bloomTexA: n, bloomTexB: a };
|
|
3153
3167
|
}
|
|
3154
|
-
function
|
|
3168
|
+
function Li(s, t, e) {
|
|
3155
3169
|
return s.createTexture({
|
|
3156
3170
|
size: [t, e],
|
|
3157
3171
|
format: "depth24plus",
|
|
3158
3172
|
usage: GPUTextureUsage.RENDER_ATTACHMENT
|
|
3159
3173
|
});
|
|
3160
3174
|
}
|
|
3161
|
-
function
|
|
3175
|
+
function vt(s, t, e) {
|
|
3162
3176
|
const i = s.createBuffer({
|
|
3163
3177
|
size: t.byteLength,
|
|
3164
3178
|
usage: e,
|
|
@@ -3166,7 +3180,7 @@ function Ge(s, t, e) {
|
|
|
3166
3180
|
});
|
|
3167
3181
|
return new t.constructor(i.getMappedRange()).set(t), i.unmap(), i;
|
|
3168
3182
|
}
|
|
3169
|
-
const
|
|
3183
|
+
const Mr = `
|
|
3170
3184
|
struct Uniforms {
|
|
3171
3185
|
transform: mat4x4<f32>,
|
|
3172
3186
|
cameraPosition: vec3<f32>,
|
|
@@ -3228,7 +3242,7 @@ const Qs = `
|
|
|
3228
3242
|
|
|
3229
3243
|
return finalColor;
|
|
3230
3244
|
}
|
|
3231
|
-
`,
|
|
3245
|
+
`, wr = `
|
|
3232
3246
|
struct Uniforms {
|
|
3233
3247
|
transform: mat4x4<f32>,
|
|
3234
3248
|
cameraPosition: vec3<f32>,
|
|
@@ -3304,7 +3318,7 @@ const Qs = `
|
|
|
3304
3318
|
}
|
|
3305
3319
|
|
|
3306
3320
|
@vertex
|
|
3307
|
-
fn vs_main(input: VertexInput) -> VertexOutput {
|
|
3321
|
+
fn vs_main(input: VertexInput, @builtin(instance_index) instanceIdx: u32) -> VertexOutput {
|
|
3308
3322
|
var output : VertexOutput;
|
|
3309
3323
|
|
|
3310
3324
|
let age = input.particleAgeAndLife.x;
|
|
@@ -3335,9 +3349,10 @@ const Qs = `
|
|
|
3335
3349
|
// Determine particle size
|
|
3336
3350
|
var particleSizeFactor = appearance.particleSize;
|
|
3337
3351
|
if (appearance.randomSize > 0.5) {
|
|
3338
|
-
//
|
|
3352
|
+
// Per-particle seed (particle index), not lifetime — otherwise every particle of an emission
|
|
3353
|
+
// gets the SAME size (see the quad shader for the full explanation).
|
|
3339
3354
|
particleSizeFactor = appearance.minSize +
|
|
3340
|
-
fract(sin(
|
|
3355
|
+
fract(sin(f32(instanceIdx) * 12.9898 + 78.233) * 43758.5453) *
|
|
3341
3356
|
(appearance.maxSize - appearance.minSize);
|
|
3342
3357
|
}
|
|
3343
3358
|
|
|
@@ -3360,7 +3375,7 @@ const Qs = `
|
|
|
3360
3375
|
var particleRotation = appearance.rotation;
|
|
3361
3376
|
if (appearance.rotationMode == 1.0) {
|
|
3362
3377
|
particleRotation = appearance.minRotation +
|
|
3363
|
-
fract(sin(
|
|
3378
|
+
fract(sin(f32(instanceIdx) * 63.746 + 11.135) * 43758.5453) *
|
|
3364
3379
|
(appearance.maxRotation - appearance.minRotation);
|
|
3365
3380
|
} else if (appearance.rotationMode == 2.0) {
|
|
3366
3381
|
let viewVelocity = (uniforms.transform * vec4<f32>(input.particleVelocity, 0.0)).xyz;
|
|
@@ -3464,7 +3479,7 @@ const Qs = `
|
|
|
3464
3479
|
return finalColor;
|
|
3465
3480
|
}
|
|
3466
3481
|
`;
|
|
3467
|
-
function
|
|
3482
|
+
function Br(s) {
|
|
3468
3483
|
const t = s.createBindGroupLayout({
|
|
3469
3484
|
entries: [
|
|
3470
3485
|
{
|
|
@@ -3550,34 +3565,34 @@ function er(s) {
|
|
|
3550
3565
|
object3dBindGroupLayout: r
|
|
3551
3566
|
};
|
|
3552
3567
|
}
|
|
3553
|
-
function
|
|
3568
|
+
function Rr(s, t, e, i = {}) {
|
|
3554
3569
|
const { depthCompare: r } = i, n = r || "less", {
|
|
3555
3570
|
particleBindGroupLayout: a,
|
|
3556
3571
|
bloomBindGroupLayout: o,
|
|
3557
3572
|
compositeBindGroupLayout: c,
|
|
3558
3573
|
object3dBindGroupLayout: l
|
|
3559
|
-
} = e,
|
|
3574
|
+
} = e, d = s.createPipelineLayout({
|
|
3560
3575
|
bindGroupLayouts: [a]
|
|
3561
|
-
}),
|
|
3576
|
+
}), S = s.createPipelineLayout({
|
|
3562
3577
|
bindGroupLayouts: [o]
|
|
3563
|
-
}),
|
|
3578
|
+
}), g = s.createPipelineLayout({
|
|
3564
3579
|
bindGroupLayouts: [c]
|
|
3565
|
-
}),
|
|
3566
|
-
code:
|
|
3567
|
-
}),
|
|
3568
|
-
code:
|
|
3569
|
-
}),
|
|
3570
|
-
code:
|
|
3571
|
-
}),
|
|
3572
|
-
code:
|
|
3573
|
-
}),
|
|
3574
|
-
code:
|
|
3575
|
-
}),
|
|
3576
|
-
code:
|
|
3577
|
-
}),
|
|
3578
|
-
layout:
|
|
3580
|
+
}), p = s.createShaderModule({
|
|
3581
|
+
code: Xs
|
|
3582
|
+
}), v = s.createShaderModule({
|
|
3583
|
+
code: Ns
|
|
3584
|
+
}), A = s.createShaderModule({
|
|
3585
|
+
code: Ys
|
|
3586
|
+
}), U = s.createShaderModule({
|
|
3587
|
+
code: js
|
|
3588
|
+
}), I = s.createShaderModule({
|
|
3589
|
+
code: Mr
|
|
3590
|
+
}), _ = s.createShaderModule({
|
|
3591
|
+
code: wr
|
|
3592
|
+
}), $ = (kt) => s.createRenderPipeline({
|
|
3593
|
+
layout: d,
|
|
3579
3594
|
vertex: {
|
|
3580
|
-
module:
|
|
3595
|
+
module: p,
|
|
3581
3596
|
entryPoint: "vs_main",
|
|
3582
3597
|
buffers: [
|
|
3583
3598
|
{
|
|
@@ -3638,11 +3653,11 @@ function tr(s, t, e, i = {}) {
|
|
|
3638
3653
|
]
|
|
3639
3654
|
},
|
|
3640
3655
|
fragment: {
|
|
3641
|
-
module:
|
|
3656
|
+
module: p,
|
|
3642
3657
|
entryPoint: "fs_main",
|
|
3643
3658
|
targets: [{
|
|
3644
|
-
format:
|
|
3645
|
-
blend:
|
|
3659
|
+
format: Ne,
|
|
3660
|
+
blend: kt
|
|
3646
3661
|
}]
|
|
3647
3662
|
},
|
|
3648
3663
|
primitive: {
|
|
@@ -3654,7 +3669,7 @@ function tr(s, t, e, i = {}) {
|
|
|
3654
3669
|
depthCompare: n,
|
|
3655
3670
|
format: "depth24plus"
|
|
3656
3671
|
}
|
|
3657
|
-
}),
|
|
3672
|
+
}), T = $({
|
|
3658
3673
|
color: {
|
|
3659
3674
|
srcFactor: "src-alpha",
|
|
3660
3675
|
dstFactor: "one-minus-src-alpha",
|
|
@@ -3665,7 +3680,7 @@ function tr(s, t, e, i = {}) {
|
|
|
3665
3680
|
dstFactor: "one-minus-src-alpha",
|
|
3666
3681
|
operation: "add"
|
|
3667
3682
|
}
|
|
3668
|
-
}),
|
|
3683
|
+
}), z = $({
|
|
3669
3684
|
color: {
|
|
3670
3685
|
srcFactor: "src-alpha",
|
|
3671
3686
|
dstFactor: "one",
|
|
@@ -3676,10 +3691,10 @@ function tr(s, t, e, i = {}) {
|
|
|
3676
3691
|
dstFactor: "one-minus-src-alpha",
|
|
3677
3692
|
operation: "add"
|
|
3678
3693
|
}
|
|
3679
|
-
}),
|
|
3680
|
-
layout:
|
|
3694
|
+
}), F = s.createRenderPipeline({
|
|
3695
|
+
layout: d,
|
|
3681
3696
|
vertex: {
|
|
3682
|
-
module:
|
|
3697
|
+
module: p,
|
|
3683
3698
|
entryPoint: "vs_main",
|
|
3684
3699
|
buffers: [
|
|
3685
3700
|
{
|
|
@@ -3740,10 +3755,10 @@ function tr(s, t, e, i = {}) {
|
|
|
3740
3755
|
]
|
|
3741
3756
|
},
|
|
3742
3757
|
fragment: {
|
|
3743
|
-
module:
|
|
3758
|
+
module: p,
|
|
3744
3759
|
entryPoint: "fs_main",
|
|
3745
3760
|
targets: [{
|
|
3746
|
-
format:
|
|
3761
|
+
format: Ne,
|
|
3747
3762
|
writeMask: 0
|
|
3748
3763
|
// No color write — depth only
|
|
3749
3764
|
}]
|
|
@@ -3758,33 +3773,33 @@ function tr(s, t, e, i = {}) {
|
|
|
3758
3773
|
// Always write depth (don't self-occlude)
|
|
3759
3774
|
format: "depth24plus"
|
|
3760
3775
|
}
|
|
3761
|
-
}),
|
|
3762
|
-
layout:
|
|
3776
|
+
}), Z = s.createRenderPipeline({
|
|
3777
|
+
layout: S,
|
|
3763
3778
|
vertex: {
|
|
3764
|
-
module:
|
|
3779
|
+
module: v,
|
|
3765
3780
|
entryPoint: "vs_main"
|
|
3766
3781
|
},
|
|
3767
3782
|
fragment: {
|
|
3768
|
-
module:
|
|
3783
|
+
module: v,
|
|
3769
3784
|
entryPoint: "fs_main",
|
|
3770
3785
|
targets: [{
|
|
3771
|
-
format:
|
|
3786
|
+
format: Ne
|
|
3772
3787
|
}]
|
|
3773
3788
|
},
|
|
3774
3789
|
primitive: {
|
|
3775
3790
|
topology: "triangle-list"
|
|
3776
3791
|
}
|
|
3777
|
-
}),
|
|
3778
|
-
layout:
|
|
3792
|
+
}), J = s.createRenderPipeline({
|
|
3793
|
+
layout: g,
|
|
3779
3794
|
vertex: {
|
|
3780
|
-
module:
|
|
3795
|
+
module: A,
|
|
3781
3796
|
entryPoint: "vs_main"
|
|
3782
3797
|
},
|
|
3783
3798
|
fragment: {
|
|
3784
|
-
module:
|
|
3799
|
+
module: A,
|
|
3785
3800
|
entryPoint: "fs_main",
|
|
3786
3801
|
targets: [{
|
|
3787
|
-
format:
|
|
3802
|
+
format: Ne,
|
|
3788
3803
|
blend: {
|
|
3789
3804
|
color: {
|
|
3790
3805
|
srcFactor: "one",
|
|
@@ -3802,17 +3817,17 @@ function tr(s, t, e, i = {}) {
|
|
|
3802
3817
|
primitive: {
|
|
3803
3818
|
topology: "triangle-list"
|
|
3804
3819
|
}
|
|
3805
|
-
}),
|
|
3806
|
-
layout:
|
|
3820
|
+
}), ee = s.createRenderPipeline({
|
|
3821
|
+
layout: g,
|
|
3807
3822
|
vertex: {
|
|
3808
|
-
module:
|
|
3823
|
+
module: U,
|
|
3809
3824
|
entryPoint: "vs_main"
|
|
3810
3825
|
},
|
|
3811
3826
|
fragment: {
|
|
3812
|
-
module:
|
|
3827
|
+
module: U,
|
|
3813
3828
|
entryPoint: "fs_main",
|
|
3814
3829
|
targets: [{
|
|
3815
|
-
format:
|
|
3830
|
+
format: Ne,
|
|
3816
3831
|
blend: {
|
|
3817
3832
|
color: {
|
|
3818
3833
|
srcFactor: "one",
|
|
@@ -3830,11 +3845,11 @@ function tr(s, t, e, i = {}) {
|
|
|
3830
3845
|
primitive: {
|
|
3831
3846
|
topology: "triangle-list"
|
|
3832
3847
|
}
|
|
3833
|
-
}),
|
|
3834
|
-
layout:
|
|
3835
|
-
vertex: { module:
|
|
3848
|
+
}), K = s.createShaderModule({ code: qs }), q = s.createRenderPipeline({
|
|
3849
|
+
layout: g,
|
|
3850
|
+
vertex: { module: K, entryPoint: "vs_main" },
|
|
3836
3851
|
fragment: {
|
|
3837
|
-
module:
|
|
3852
|
+
module: K,
|
|
3838
3853
|
entryPoint: "fs_main",
|
|
3839
3854
|
targets: [{
|
|
3840
3855
|
format: t,
|
|
@@ -3845,12 +3860,12 @@ function tr(s, t, e, i = {}) {
|
|
|
3845
3860
|
}]
|
|
3846
3861
|
},
|
|
3847
3862
|
primitive: { topology: "triangle-list" }
|
|
3848
|
-
}),
|
|
3863
|
+
}), Ke = s.createPipelineLayout({
|
|
3849
3864
|
bindGroupLayouts: [l]
|
|
3850
|
-
}),
|
|
3851
|
-
layout:
|
|
3865
|
+
}), Pt = s.createRenderPipeline({
|
|
3866
|
+
layout: Ke,
|
|
3852
3867
|
vertex: {
|
|
3853
|
-
module:
|
|
3868
|
+
module: I,
|
|
3854
3869
|
entryPoint: "vs_main",
|
|
3855
3870
|
buffers: [
|
|
3856
3871
|
{
|
|
@@ -3875,10 +3890,10 @@ function tr(s, t, e, i = {}) {
|
|
|
3875
3890
|
]
|
|
3876
3891
|
},
|
|
3877
3892
|
fragment: {
|
|
3878
|
-
module:
|
|
3893
|
+
module: I,
|
|
3879
3894
|
entryPoint: "fs_main",
|
|
3880
3895
|
targets: [{
|
|
3881
|
-
format:
|
|
3896
|
+
format: Ne,
|
|
3882
3897
|
blend: {
|
|
3883
3898
|
color: {
|
|
3884
3899
|
srcFactor: "src-alpha",
|
|
@@ -3902,10 +3917,10 @@ function tr(s, t, e, i = {}) {
|
|
|
3902
3917
|
depthCompare: n,
|
|
3903
3918
|
format: "depth24plus"
|
|
3904
3919
|
}
|
|
3905
|
-
}),
|
|
3906
|
-
layout:
|
|
3920
|
+
}), Ye = s.createRenderPipeline({
|
|
3921
|
+
layout: d,
|
|
3907
3922
|
vertex: {
|
|
3908
|
-
module:
|
|
3923
|
+
module: _,
|
|
3909
3924
|
entryPoint: "vs_main",
|
|
3910
3925
|
buffers: [
|
|
3911
3926
|
{
|
|
@@ -3977,10 +3992,10 @@ function tr(s, t, e, i = {}) {
|
|
|
3977
3992
|
]
|
|
3978
3993
|
},
|
|
3979
3994
|
fragment: {
|
|
3980
|
-
module:
|
|
3995
|
+
module: _,
|
|
3981
3996
|
entryPoint: "fs_main",
|
|
3982
3997
|
targets: [{
|
|
3983
|
-
format:
|
|
3998
|
+
format: Ne,
|
|
3984
3999
|
blend: {
|
|
3985
4000
|
color: {
|
|
3986
4001
|
srcFactor: "src-alpha",
|
|
@@ -4006,18 +4021,18 @@ function tr(s, t, e, i = {}) {
|
|
|
4006
4021
|
}
|
|
4007
4022
|
});
|
|
4008
4023
|
return {
|
|
4009
|
-
particlePipeline:
|
|
4010
|
-
particleAdditivePipeline:
|
|
4011
|
-
particleDepthWritePipeline:
|
|
4012
|
-
blurPipeline:
|
|
4013
|
-
compositePipeline:
|
|
4014
|
-
directRenderPipeline:
|
|
4015
|
-
finalCompositePipeline:
|
|
4016
|
-
object3dPipeline:
|
|
4017
|
-
glbMeshPipeline:
|
|
4024
|
+
particlePipeline: T,
|
|
4025
|
+
particleAdditivePipeline: z,
|
|
4026
|
+
particleDepthWritePipeline: F,
|
|
4027
|
+
blurPipeline: Z,
|
|
4028
|
+
compositePipeline: J,
|
|
4029
|
+
directRenderPipeline: ee,
|
|
4030
|
+
finalCompositePipeline: q,
|
|
4031
|
+
object3dPipeline: Pt,
|
|
4032
|
+
glbMeshPipeline: Ye
|
|
4018
4033
|
};
|
|
4019
4034
|
}
|
|
4020
|
-
function
|
|
4035
|
+
function ei(s, t, e, i) {
|
|
4021
4036
|
const {
|
|
4022
4037
|
uniformBuffer: r,
|
|
4023
4038
|
appearanceUniformBuffer: n,
|
|
@@ -4026,9 +4041,9 @@ function Pt(s, t, e, i) {
|
|
|
4026
4041
|
bloomIntensityBuffer: c
|
|
4027
4042
|
} = e, {
|
|
4028
4043
|
sceneTexture: l,
|
|
4029
|
-
bloomTexA:
|
|
4030
|
-
bloomTexB:
|
|
4031
|
-
} = i,
|
|
4044
|
+
bloomTexA: d,
|
|
4045
|
+
bloomTexB: S
|
|
4046
|
+
} = i, g = s.createBindGroup({
|
|
4032
4047
|
layout: s.createBindGroupLayout({
|
|
4033
4048
|
entries: [
|
|
4034
4049
|
{
|
|
@@ -4053,7 +4068,7 @@ function Pt(s, t, e, i) {
|
|
|
4053
4068
|
resource: { buffer: n }
|
|
4054
4069
|
}
|
|
4055
4070
|
]
|
|
4056
|
-
}),
|
|
4071
|
+
}), p = s.createBindGroup({
|
|
4057
4072
|
layout: s.createBindGroupLayout({
|
|
4058
4073
|
entries: [
|
|
4059
4074
|
{
|
|
@@ -4087,7 +4102,7 @@ function Pt(s, t, e, i) {
|
|
|
4087
4102
|
resource: { buffer: a }
|
|
4088
4103
|
}
|
|
4089
4104
|
]
|
|
4090
|
-
}),
|
|
4105
|
+
}), v = s.createBindGroup({
|
|
4091
4106
|
layout: s.createBindGroupLayout({
|
|
4092
4107
|
entries: [
|
|
4093
4108
|
{
|
|
@@ -4114,14 +4129,14 @@ function Pt(s, t, e, i) {
|
|
|
4114
4129
|
},
|
|
4115
4130
|
{
|
|
4116
4131
|
binding: 1,
|
|
4117
|
-
resource:
|
|
4132
|
+
resource: d.createView()
|
|
4118
4133
|
},
|
|
4119
4134
|
{
|
|
4120
4135
|
binding: 2,
|
|
4121
4136
|
resource: { buffer: o }
|
|
4122
4137
|
}
|
|
4123
4138
|
]
|
|
4124
|
-
}),
|
|
4139
|
+
}), A = s.createBindGroup({
|
|
4125
4140
|
layout: s.createBindGroupLayout({
|
|
4126
4141
|
entries: [
|
|
4127
4142
|
{
|
|
@@ -4157,14 +4172,14 @@ function Pt(s, t, e, i) {
|
|
|
4157
4172
|
},
|
|
4158
4173
|
{
|
|
4159
4174
|
binding: 2,
|
|
4160
|
-
resource:
|
|
4175
|
+
resource: S.createView()
|
|
4161
4176
|
},
|
|
4162
4177
|
{
|
|
4163
4178
|
binding: 3,
|
|
4164
4179
|
resource: { buffer: c }
|
|
4165
4180
|
}
|
|
4166
4181
|
]
|
|
4167
|
-
}),
|
|
4182
|
+
}), U = s.createBindGroup({
|
|
4168
4183
|
layout: s.createBindGroupLayout({
|
|
4169
4184
|
entries: [
|
|
4170
4185
|
{
|
|
@@ -4200,7 +4215,7 @@ function Pt(s, t, e, i) {
|
|
|
4200
4215
|
},
|
|
4201
4216
|
{
|
|
4202
4217
|
binding: 2,
|
|
4203
|
-
resource:
|
|
4218
|
+
resource: S.createView()
|
|
4204
4219
|
},
|
|
4205
4220
|
{
|
|
4206
4221
|
binding: 3,
|
|
@@ -4209,14 +4224,14 @@ function Pt(s, t, e, i) {
|
|
|
4209
4224
|
]
|
|
4210
4225
|
});
|
|
4211
4226
|
return {
|
|
4212
|
-
particleBindGroup:
|
|
4213
|
-
horizontalBlurBindGroup:
|
|
4214
|
-
verticalBlurBindGroup:
|
|
4215
|
-
compositeBindGroup:
|
|
4216
|
-
directRenderBindGroup:
|
|
4227
|
+
particleBindGroup: g,
|
|
4228
|
+
horizontalBlurBindGroup: p,
|
|
4229
|
+
verticalBlurBindGroup: v,
|
|
4230
|
+
compositeBindGroup: A,
|
|
4231
|
+
directRenderBindGroup: U
|
|
4217
4232
|
};
|
|
4218
4233
|
}
|
|
4219
|
-
function
|
|
4234
|
+
function Tr(s) {
|
|
4220
4235
|
return s.createSampler({
|
|
4221
4236
|
magFilter: "linear",
|
|
4222
4237
|
minFilter: "linear",
|
|
@@ -4226,7 +4241,7 @@ function ir(s) {
|
|
|
4226
4241
|
maxAnisotropy: 16
|
|
4227
4242
|
});
|
|
4228
4243
|
}
|
|
4229
|
-
function
|
|
4244
|
+
function Er() {
|
|
4230
4245
|
const s = new Float32Array([
|
|
4231
4246
|
// Front face (z = 0.5)
|
|
4232
4247
|
-0.5,
|
|
@@ -4424,13 +4439,13 @@ function sr() {
|
|
|
4424
4439
|
]);
|
|
4425
4440
|
return { vertices: s, indices: t };
|
|
4426
4441
|
}
|
|
4427
|
-
function
|
|
4442
|
+
function Ar(s = 16, t = 16) {
|
|
4428
4443
|
const e = [], i = [];
|
|
4429
4444
|
for (let r = 0; r <= s; r++) {
|
|
4430
4445
|
const n = r * Math.PI / s, a = Math.sin(n), o = Math.cos(n);
|
|
4431
4446
|
for (let c = 0; c <= t; c++) {
|
|
4432
|
-
const l = c * 2 * Math.PI / t,
|
|
4433
|
-
e.push(
|
|
4447
|
+
const l = c * 2 * Math.PI / t, d = Math.sin(l), g = Math.cos(l) * a, p = o, v = d * a;
|
|
4448
|
+
e.push(g * 0.5, p * 0.5, v * 0.5), e.push(g, p, v);
|
|
4434
4449
|
}
|
|
4435
4450
|
}
|
|
4436
4451
|
for (let r = 0; r < s; r++)
|
|
@@ -4443,7 +4458,7 @@ function rr(s = 16, t = 16) {
|
|
|
4443
4458
|
indices: new Uint16Array(i)
|
|
4444
4459
|
};
|
|
4445
4460
|
}
|
|
4446
|
-
class
|
|
4461
|
+
class Cr {
|
|
4447
4462
|
constructor(t, e, i, r, n) {
|
|
4448
4463
|
this.id = t, this.type = e, this.position = i, this.scale = r, this.color = n, this.rotation = [0, 0, 0];
|
|
4449
4464
|
}
|
|
@@ -4577,7 +4592,7 @@ class nr {
|
|
|
4577
4592
|
return i;
|
|
4578
4593
|
}
|
|
4579
4594
|
}
|
|
4580
|
-
class
|
|
4595
|
+
class Vr {
|
|
4581
4596
|
constructor(t) {
|
|
4582
4597
|
this.device = t, this.objects = [], this.nextId = 0, this.initializeGeometry(), this.onObjectAdded = null, this.onObjectRemoved = null, this.onObjectUpdated = null;
|
|
4583
4598
|
}
|
|
@@ -4585,20 +4600,20 @@ class pr {
|
|
|
4585
4600
|
* Initialize geometry buffers for cube and sphere
|
|
4586
4601
|
*/
|
|
4587
4602
|
initializeGeometry() {
|
|
4588
|
-
const t =
|
|
4589
|
-
this.cubeVertexBuffer =
|
|
4603
|
+
const t = Er(), e = Ar(16, 16);
|
|
4604
|
+
this.cubeVertexBuffer = vt(
|
|
4590
4605
|
this.device,
|
|
4591
4606
|
t.vertices,
|
|
4592
4607
|
GPUBufferUsage.VERTEX
|
|
4593
|
-
), this.cubeIndexBuffer =
|
|
4608
|
+
), this.cubeIndexBuffer = vt(
|
|
4594
4609
|
this.device,
|
|
4595
4610
|
t.indices,
|
|
4596
4611
|
GPUBufferUsage.INDEX
|
|
4597
|
-
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer =
|
|
4612
|
+
), this.cubeIndexCount = t.indices.length, this.sphereVertexBuffer = vt(
|
|
4598
4613
|
this.device,
|
|
4599
4614
|
e.vertices,
|
|
4600
4615
|
GPUBufferUsage.VERTEX
|
|
4601
|
-
), this.sphereIndexBuffer =
|
|
4616
|
+
), this.sphereIndexBuffer = vt(
|
|
4602
4617
|
this.device,
|
|
4603
4618
|
e.indices,
|
|
4604
4619
|
GPUBufferUsage.INDEX
|
|
@@ -4613,7 +4628,7 @@ class pr {
|
|
|
4613
4628
|
* @returns {Object3D} The created object
|
|
4614
4629
|
*/
|
|
4615
4630
|
addObject(t, e = [0, 0, 0], i = [1, 1, 1], r = [1, 1, 1, 1]) {
|
|
4616
|
-
const n = new
|
|
4631
|
+
const n = new Cr(this.nextId++, t, e, i, r);
|
|
4617
4632
|
return n.uniformBuffer = this.device.createBuffer({
|
|
4618
4633
|
size: 192,
|
|
4619
4634
|
// modelMatrix (64) + normalMatrix (64) + color (16) + padding (48)
|
|
@@ -4702,21 +4717,21 @@ class pr {
|
|
|
4702
4717
|
}
|
|
4703
4718
|
}
|
|
4704
4719
|
}
|
|
4705
|
-
function
|
|
4720
|
+
function Or(s) {
|
|
4706
4721
|
const t = parseInt(s.slice(1, 3), 16) / 255, e = parseInt(s.slice(3, 5), 16) / 255, i = parseInt(s.slice(5, 7), 16) / 255;
|
|
4707
4722
|
return [t, e, i];
|
|
4708
4723
|
}
|
|
4709
|
-
function
|
|
4724
|
+
function Lr(s) {
|
|
4710
4725
|
if (!s) return "#ffffff";
|
|
4711
4726
|
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");
|
|
4712
4727
|
return `#${t}${e}${i}`;
|
|
4713
4728
|
}
|
|
4714
|
-
function
|
|
4715
|
-
const i =
|
|
4729
|
+
function kr(s, t, e) {
|
|
4730
|
+
const i = ki([
|
|
4716
4731
|
s[0] - t[0],
|
|
4717
4732
|
s[1] - t[1],
|
|
4718
4733
|
s[2] - t[2]
|
|
4719
|
-
]), r =
|
|
4734
|
+
]), r = ki(Xi(e, i)), n = Xi(i, r);
|
|
4720
4735
|
return new Float32Array([
|
|
4721
4736
|
r[0],
|
|
4722
4737
|
n[0],
|
|
@@ -4730,13 +4745,13 @@ function yr(s, t, e) {
|
|
|
4730
4745
|
n[2],
|
|
4731
4746
|
i[2],
|
|
4732
4747
|
0,
|
|
4733
|
-
-
|
|
4734
|
-
-
|
|
4735
|
-
-
|
|
4748
|
+
-ti(r, s),
|
|
4749
|
+
-ti(n, s),
|
|
4750
|
+
-ti(i, s),
|
|
4736
4751
|
1
|
|
4737
4752
|
]);
|
|
4738
4753
|
}
|
|
4739
|
-
function
|
|
4754
|
+
function Xr(s, t = Math.PI / 4) {
|
|
4740
4755
|
const r = 1 / Math.tan(t / 2);
|
|
4741
4756
|
return new Float32Array([
|
|
4742
4757
|
r * s,
|
|
@@ -4757,21 +4772,21 @@ function gr(s, t = Math.PI / 4) {
|
|
|
4757
4772
|
0
|
|
4758
4773
|
]);
|
|
4759
4774
|
}
|
|
4760
|
-
function
|
|
4775
|
+
function ki(s) {
|
|
4761
4776
|
const t = Math.sqrt(s[0] * s[0] + s[1] * s[1] + s[2] * s[2]);
|
|
4762
4777
|
return [s[0] / t, s[1] / t, s[2] / t];
|
|
4763
4778
|
}
|
|
4764
|
-
function
|
|
4779
|
+
function Xi(s, t) {
|
|
4765
4780
|
return [
|
|
4766
4781
|
s[1] * t[2] - s[2] * t[1],
|
|
4767
4782
|
s[2] * t[0] - s[0] * t[2],
|
|
4768
4783
|
s[0] * t[1] - s[1] * t[0]
|
|
4769
4784
|
];
|
|
4770
4785
|
}
|
|
4771
|
-
function
|
|
4786
|
+
function ti(s, t) {
|
|
4772
4787
|
return s[0] * t[0] + s[1] * t[1] + s[2] * t[2];
|
|
4773
4788
|
}
|
|
4774
|
-
function
|
|
4789
|
+
function Ur(s, t) {
|
|
4775
4790
|
const e = new Float32Array(16);
|
|
4776
4791
|
for (let i = 0; i < 4; i++)
|
|
4777
4792
|
for (let r = 0; r < 4; r++) {
|
|
@@ -4782,7 +4797,7 @@ function ar(s, t) {
|
|
|
4782
4797
|
}
|
|
4783
4798
|
return e;
|
|
4784
4799
|
}
|
|
4785
|
-
const
|
|
4800
|
+
const si = 1481005640, Hi = 1, Zi = 1313821514, $i = 5130562, Et = "$hzfxAsset", Wi = (s) => typeof atob == "function" ? Uint8Array.from(atob(s), (t) => t.charCodeAt(0)) : new Uint8Array(Buffer.from(s, "base64")), Ni = (s) => {
|
|
4786
4801
|
if (typeof btoa == "function") {
|
|
4787
4802
|
let t = "";
|
|
4788
4803
|
for (let e = 0; e < s.length; e++) t += String.fromCharCode(s[e]);
|
|
@@ -4790,94 +4805,94 @@ const Bt = 1481005640, wi = 1, Bi = 1313821514, Mi = 5130562, Ze = "$hzfxAsset",
|
|
|
4790
4805
|
}
|
|
4791
4806
|
return Buffer.from(s).toString("base64");
|
|
4792
4807
|
};
|
|
4793
|
-
function
|
|
4794
|
-
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) ?
|
|
4808
|
+
function Ir(s) {
|
|
4809
|
+
const t = s.indexOf(","), e = s.slice(5, t), i = e.split(";")[0] || "application/octet-stream", r = s.slice(t + 1), a = /;base64/i.test(e) ? Wi(r) : new TextEncoder().encode(decodeURIComponent(r));
|
|
4795
4810
|
return { mime: i, bytes: a };
|
|
4796
4811
|
}
|
|
4797
|
-
function
|
|
4812
|
+
function Yi(s) {
|
|
4798
4813
|
return (4 - s % 4) % 4;
|
|
4799
4814
|
}
|
|
4800
|
-
async function
|
|
4815
|
+
async function zr(s, t = {}) {
|
|
4801
4816
|
const { textureFormat: e = "keep", quality: i = 0.85 } = t, r = [], n = [];
|
|
4802
4817
|
let a = 0;
|
|
4803
|
-
const o = (
|
|
4804
|
-
const
|
|
4805
|
-
r.push({ offset:
|
|
4806
|
-
const
|
|
4807
|
-
return
|
|
4818
|
+
const o = (z, F, Z) => {
|
|
4819
|
+
const J = a, ee = z.length;
|
|
4820
|
+
r.push({ offset: J, length: ee, mime: F, kind: Z }), n.push(z), a += ee;
|
|
4821
|
+
const K = Yi(ee);
|
|
4822
|
+
return K && (n.push(new Uint8Array(K)), a += K), r.length - 1;
|
|
4808
4823
|
}, c = e === "webp" && typeof OffscreenCanvas < "u" && typeof createImageBitmap == "function", l = [];
|
|
4809
|
-
for (const
|
|
4810
|
-
const
|
|
4811
|
-
if (typeof
|
|
4812
|
-
let { mime:
|
|
4813
|
-
if (c &&
|
|
4824
|
+
for (const z of s.systems || []) {
|
|
4825
|
+
const F = { ...z };
|
|
4826
|
+
if (typeof F.textureImageData == "string" && F.textureImageData.startsWith("data:")) {
|
|
4827
|
+
let { mime: Z, bytes: J } = Ir(F.textureImageData);
|
|
4828
|
+
if (c && Z !== "image/webp")
|
|
4814
4829
|
try {
|
|
4815
|
-
const
|
|
4816
|
-
|
|
4817
|
-
const
|
|
4818
|
-
|
|
4830
|
+
const ee = await createImageBitmap(new Blob([J], { type: Z })), K = new OffscreenCanvas(ee.width, ee.height);
|
|
4831
|
+
K.getContext("2d").drawImage(ee, 0, 0);
|
|
4832
|
+
const q = await K.convertToBlob({ type: "image/webp", quality: i }), Ke = new Uint8Array(await q.arrayBuffer());
|
|
4833
|
+
Ke.length < J.length && (J = Ke, Z = "image/webp");
|
|
4819
4834
|
} catch {
|
|
4820
4835
|
}
|
|
4821
|
-
|
|
4836
|
+
F.textureImageData = { [Et]: o(J, Z, "texture") };
|
|
4822
4837
|
}
|
|
4823
|
-
if (typeof
|
|
4824
|
-
const
|
|
4825
|
-
|
|
4838
|
+
if (typeof F.glbModelData == "string" && F.glbModelData.length > 0) {
|
|
4839
|
+
const Z = Wi(F.glbModelData);
|
|
4840
|
+
F.glbModelData = { [Et]: o(Z, "model/gltf-binary", "glb") };
|
|
4826
4841
|
}
|
|
4827
|
-
l.push(
|
|
4828
|
-
}
|
|
4829
|
-
const
|
|
4830
|
-
let
|
|
4831
|
-
for (const
|
|
4832
|
-
|
|
4833
|
-
const
|
|
4834
|
-
let
|
|
4835
|
-
|
|
4836
|
-
for (let
|
|
4837
|
-
return
|
|
4842
|
+
l.push(F);
|
|
4843
|
+
}
|
|
4844
|
+
const d = { ...s, systems: l, assets: r }, S = new TextEncoder().encode(JSON.stringify(d)), g = Yi(S.length), p = new Uint8Array(a);
|
|
4845
|
+
let v = 0;
|
|
4846
|
+
for (const z of n)
|
|
4847
|
+
p.set(z, v), v += z.length;
|
|
4848
|
+
const A = S.length + g, U = 20 + A + 8 + a, I = new ArrayBuffer(U), _ = new DataView(I), $ = new Uint8Array(I);
|
|
4849
|
+
let T = 0;
|
|
4850
|
+
_.setUint32(T, si, !0), T += 4, _.setUint32(T, Hi, !0), T += 4, _.setUint32(T, U, !0), T += 4, _.setUint32(T, A, !0), T += 4, _.setUint32(T, Zi, !0), T += 4, $.set(S, T), T += S.length;
|
|
4851
|
+
for (let z = 0; z < g; z++) $[T++] = 32;
|
|
4852
|
+
return _.setUint32(T, a, !0), T += 4, _.setUint32(T, $i, !0), T += 4, $.set(p, T), T += a, I;
|
|
4838
4853
|
}
|
|
4839
|
-
function
|
|
4840
|
-
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) ===
|
|
4854
|
+
function Ji(s) {
|
|
4855
|
+
return !s || s.byteLength < 12 ? !1 : new DataView(s).getUint32(0, !0) === si;
|
|
4841
4856
|
}
|
|
4842
|
-
function
|
|
4857
|
+
function Ki(s) {
|
|
4843
4858
|
const t = new DataView(s);
|
|
4844
|
-
if (t.getUint32(0, !0) !==
|
|
4859
|
+
if (t.getUint32(0, !0) !== si) throw new Error("[unpackHZFX] bad magic — not an .hzfx file");
|
|
4845
4860
|
const e = t.getUint32(4, !0);
|
|
4846
|
-
if (e !==
|
|
4861
|
+
if (e !== Hi) throw new Error(`[unpackHZFX] unsupported version ${e}`);
|
|
4847
4862
|
let i = 12, r = null, n = -1;
|
|
4848
4863
|
const a = new Uint8Array(s);
|
|
4849
4864
|
for (; i + 8 <= s.byteLength; ) {
|
|
4850
|
-
const
|
|
4865
|
+
const g = t.getUint32(i, !0);
|
|
4851
4866
|
i += 4;
|
|
4852
|
-
const
|
|
4853
|
-
i += 4,
|
|
4867
|
+
const p = t.getUint32(i, !0);
|
|
4868
|
+
i += 4, p === Zi ? r = JSON.parse(new TextDecoder().decode(a.subarray(i, i + g))) : p === $i && (n = i), i += g;
|
|
4854
4869
|
}
|
|
4855
4870
|
if (!r) throw new Error("[unpackHZFX] missing JSON chunk");
|
|
4856
|
-
const o = r.assets || [], c = (
|
|
4857
|
-
const
|
|
4858
|
-
return !
|
|
4859
|
-
}, l = (
|
|
4860
|
-
const
|
|
4861
|
-
if (l(
|
|
4862
|
-
const
|
|
4863
|
-
|
|
4871
|
+
const o = r.assets || [], c = (g) => {
|
|
4872
|
+
const p = o[g];
|
|
4873
|
+
return !p || n < 0 ? null : { ...p, bytes: a.subarray(n + p.offset, n + p.offset + p.length) };
|
|
4874
|
+
}, l = (g) => g && typeof g == "object" && typeof g[Et] == "number", d = (r.systems || []).map((g) => {
|
|
4875
|
+
const p = { ...g };
|
|
4876
|
+
if (l(p.textureImageData)) {
|
|
4877
|
+
const v = c(p.textureImageData[Et]);
|
|
4878
|
+
p.textureImageData = v ? `data:${v.mime};base64,${Ni(v.bytes)}` : void 0;
|
|
4864
4879
|
}
|
|
4865
|
-
if (l(
|
|
4866
|
-
const
|
|
4867
|
-
|
|
4880
|
+
if (l(p.glbModelData)) {
|
|
4881
|
+
const v = c(p.glbModelData[Et]);
|
|
4882
|
+
p.glbModelData = v ? Ni(v.bytes) : void 0;
|
|
4868
4883
|
}
|
|
4869
|
-
return
|
|
4870
|
-
}),
|
|
4871
|
-
return delete
|
|
4884
|
+
return p;
|
|
4885
|
+
}), S = { ...r, systems: d };
|
|
4886
|
+
return delete S.assets, S;
|
|
4872
4887
|
}
|
|
4873
|
-
function
|
|
4888
|
+
function Fr(s) {
|
|
4874
4889
|
const t = new Uint8Array(s);
|
|
4875
4890
|
let e = "";
|
|
4876
4891
|
for (let i = 0; i < t.byteLength; i++)
|
|
4877
4892
|
e += String.fromCharCode(t[i]);
|
|
4878
4893
|
return btoa(e);
|
|
4879
4894
|
}
|
|
4880
|
-
function
|
|
4895
|
+
function Gr(s) {
|
|
4881
4896
|
return {
|
|
4882
4897
|
name: s.name,
|
|
4883
4898
|
id: s.id,
|
|
@@ -4930,6 +4945,7 @@ function ur(s) {
|
|
|
4930
4945
|
dampingStrength: s.dampingStrength,
|
|
4931
4946
|
attractorEnabled: s.attractorEnabled,
|
|
4932
4947
|
attractorStrength: s.attractorStrength,
|
|
4948
|
+
attractorReverse: s.attractorReverse ?? !1,
|
|
4933
4949
|
attractorPosition: s.attractorPosition,
|
|
4934
4950
|
emissionRotationX: s.emissionRotationX,
|
|
4935
4951
|
emissionRotationY: s.emissionRotationY,
|
|
@@ -5027,6 +5043,13 @@ function ur(s) {
|
|
|
5027
5043
|
emissionTrailShapeAmplitude: s.emissionTrailShapeAmplitude ?? 0.1,
|
|
5028
5044
|
emissionTrailShapeFrequency: s.emissionTrailShapeFrequency ?? 4,
|
|
5029
5045
|
emissionTrailShapeSpeed: s.emissionTrailShapeSpeed ?? 0,
|
|
5046
|
+
shapeStrokeEnabled: s.shapeStrokeEnabled || !1,
|
|
5047
|
+
shapeStrokeWidth: s.shapeStrokeWidth ?? 0.08,
|
|
5048
|
+
shapeStrokeSegments: s.shapeStrokeSegments ?? 96,
|
|
5049
|
+
shapeStrokeShape: s.shapeStrokeShape ?? "straight",
|
|
5050
|
+
shapeStrokeAmplitude: s.shapeStrokeAmplitude ?? 0.08,
|
|
5051
|
+
shapeStrokeFrequency: s.shapeStrokeFrequency ?? 10,
|
|
5052
|
+
shapeStrokeSpeed: s.shapeStrokeSpeed ?? 0,
|
|
5030
5053
|
shapeDisplay: s.shapeDisplay ?? !0,
|
|
5031
5054
|
blendMode: s.blendMode ?? "normal",
|
|
5032
5055
|
noiseDistortEnabled: s.noiseDistortEnabled || !1,
|
|
@@ -5055,7 +5078,7 @@ function ur(s) {
|
|
|
5055
5078
|
displayUnit: s.displayUnit || "m"
|
|
5056
5079
|
};
|
|
5057
5080
|
}
|
|
5058
|
-
async function
|
|
5081
|
+
async function Nr(s, t, e = "hzfx") {
|
|
5059
5082
|
if (!s || !s.particleSystems || s.particleSystems.length === 0) {
|
|
5060
5083
|
alert("No particle systems to save.");
|
|
5061
5084
|
return;
|
|
@@ -5064,12 +5087,12 @@ async function br(s, t, e = "hzfx") {
|
|
|
5064
5087
|
const i = {
|
|
5065
5088
|
version: "1.0",
|
|
5066
5089
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5067
|
-
systems: s.particleSystems.map(({ config:
|
|
5068
|
-
...
|
|
5090
|
+
systems: s.particleSystems.map(({ config: d, system: S }) => ({
|
|
5091
|
+
...Gr(d),
|
|
5069
5092
|
// single source of truth for config fields
|
|
5070
5093
|
// Binary assets embedded so replaceSystems() can restore them
|
|
5071
|
-
textureImageData:
|
|
5072
|
-
glbModelData:
|
|
5094
|
+
textureImageData: d.textureEnabled && !d.glbModelEnabled && d.textureImageData ? d.textureImageData : void 0,
|
|
5095
|
+
glbModelData: d.glbModelEnabled && S.glbRawArrayBuffer ? Fr(S.glbRawArrayBuffer) : void 0
|
|
5073
5096
|
})),
|
|
5074
5097
|
activeSystemIndex: s.activeSystemIndex,
|
|
5075
5098
|
loop: s.loop || !1
|
|
@@ -5077,16 +5100,16 @@ async function br(s, t, e = "hzfx") {
|
|
|
5077
5100
|
}, r = e === "json" ? "json" : "hzfx";
|
|
5078
5101
|
let n;
|
|
5079
5102
|
if (r === "hzfx") {
|
|
5080
|
-
const
|
|
5081
|
-
n = new Blob([
|
|
5103
|
+
const d = await zr(i, { textureFormat: "webp" });
|
|
5104
|
+
n = new Blob([d], { type: "application/octet-stream" });
|
|
5082
5105
|
} else
|
|
5083
5106
|
n = new Blob([JSON.stringify(i, null, 2)], { type: "application/json" });
|
|
5084
5107
|
let a;
|
|
5085
5108
|
if (t)
|
|
5086
5109
|
a = t;
|
|
5087
5110
|
else {
|
|
5088
|
-
const
|
|
5089
|
-
a = `particle-scene_${`${
|
|
5111
|
+
const d = /* @__PURE__ */ new Date();
|
|
5112
|
+
a = `particle-scene_${`${d.getFullYear()}-${(d.getMonth() + 1).toString().padStart(2, "0")}-${d.getDate().toString().padStart(2, "0")}_${d.getHours().toString().padStart(2, "0")}${d.getMinutes().toString().padStart(2, "0")}`}`;
|
|
5090
5113
|
}
|
|
5091
5114
|
const o = `${a}.${r}`, c = URL.createObjectURL(n), l = document.createElement("a");
|
|
5092
5115
|
l.href = c, l.download = o, document.body.appendChild(l), l.click(), document.body.removeChild(l), URL.revokeObjectURL(c);
|
|
@@ -5094,7 +5117,7 @@ async function br(s, t, e = "hzfx") {
|
|
|
5094
5117
|
console.error("Error saving scene:", i), alert("Error saving scene. See console for details.");
|
|
5095
5118
|
}
|
|
5096
5119
|
}
|
|
5097
|
-
function
|
|
5120
|
+
function Yr(s) {
|
|
5098
5121
|
return new Promise((t, e) => {
|
|
5099
5122
|
try {
|
|
5100
5123
|
const i = s.target.files[0];
|
|
@@ -5107,7 +5130,7 @@ function Sr(s) {
|
|
|
5107
5130
|
try {
|
|
5108
5131
|
const a = n.target.result;
|
|
5109
5132
|
let o;
|
|
5110
|
-
if (
|
|
5133
|
+
if (Ji(a) ? o = Ki(a) : o = JSON.parse(new TextDecoder().decode(a)), !Array.isArray(o.systems) || o.systems.length === 0)
|
|
5111
5134
|
throw new Error("No valid particle systems found in the file");
|
|
5112
5135
|
t({
|
|
5113
5136
|
systems: o.systems.slice(),
|
|
@@ -5125,7 +5148,7 @@ function Sr(s) {
|
|
|
5125
5148
|
}
|
|
5126
5149
|
});
|
|
5127
5150
|
}
|
|
5128
|
-
async function
|
|
5151
|
+
async function jr(s) {
|
|
5129
5152
|
if (!s || typeof s != "string")
|
|
5130
5153
|
throw new Error("[fetchPreset] url must be a non-empty string");
|
|
5131
5154
|
const t = await fetch(s);
|
|
@@ -5133,7 +5156,7 @@ async function xr(s) {
|
|
|
5133
5156
|
throw new Error(`[fetchPreset] HTTP ${t.status}: ${t.statusText}`);
|
|
5134
5157
|
const e = await t.arrayBuffer();
|
|
5135
5158
|
let i;
|
|
5136
|
-
if (
|
|
5159
|
+
if (Ji(e) ? i = Ki(e) : i = JSON.parse(new TextDecoder().decode(e)), !Array.isArray(i.systems) || i.systems.length === 0)
|
|
5137
5160
|
throw new Error('[fetchPreset] Invalid preset: "systems" must be a non-empty array');
|
|
5138
5161
|
return {
|
|
5139
5162
|
version: i.version,
|
|
@@ -5141,7 +5164,7 @@ async function xr(s) {
|
|
|
5141
5164
|
activeSystemIndex: i.activeSystemIndex ?? 0
|
|
5142
5165
|
};
|
|
5143
5166
|
}
|
|
5144
|
-
const
|
|
5167
|
+
const Dr = (s) => `
|
|
5145
5168
|
@vertex fn vs(@builtin(vertex_index) i: u32) -> @builtin(position) vec4f {
|
|
5146
5169
|
var p = array<vec2f, 3>(vec2f(-1.0, -3.0), vec2f(-1.0, 1.0), vec2f(3.0, 1.0));
|
|
5147
5170
|
return vec4f(p[i], 0.0, 1.0);
|
|
@@ -5151,60 +5174,60 @@ const dr = (s) => `
|
|
|
5151
5174
|
return textureLoad(src, vec2i(pos.xy), 0);
|
|
5152
5175
|
}
|
|
5153
5176
|
`;
|
|
5154
|
-
async function
|
|
5177
|
+
async function qr(s, t = {}) {
|
|
5155
5178
|
const { getSceneDepth: e = null, autoRespawn: i = !0 } = t;
|
|
5156
5179
|
let r, n, a;
|
|
5157
5180
|
const o = !!(s && s.device && s.context);
|
|
5158
|
-
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await
|
|
5159
|
-
const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new
|
|
5160
|
-
function
|
|
5161
|
-
const
|
|
5162
|
-
if (!
|
|
5163
|
-
const
|
|
5164
|
-
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled:
|
|
5181
|
+
o ? ({ device: r, context: n, canvas: a } = s, a || (a = n.canvas)) : (a = s, { device: r, context: n } = await _r(a));
|
|
5182
|
+
const c = navigator.gpu.getPreferredCanvasFormat(), l = t.manager || new Pr(r), d = { layouts: {}, pipelines: {} };
|
|
5183
|
+
function S(u) {
|
|
5184
|
+
const f = u ? "ms" : "ss";
|
|
5185
|
+
if (!d.pipelines[f]) {
|
|
5186
|
+
const h = r.createShaderModule({ code: Dr(u) }), b = r.createBindGroupLayout({
|
|
5187
|
+
entries: [{ binding: 0, visibility: GPUShaderStage.FRAGMENT, texture: { sampleType: "depth", multisampled: u } }]
|
|
5165
5188
|
});
|
|
5166
|
-
|
|
5167
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5168
|
-
vertex: { module:
|
|
5169
|
-
fragment: { module:
|
|
5189
|
+
d.layouts[f] = b, d.pipelines[f] = r.createRenderPipeline({
|
|
5190
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [b] }),
|
|
5191
|
+
vertex: { module: h, entryPoint: "vs" },
|
|
5192
|
+
fragment: { module: h, entryPoint: "fs", targets: [] },
|
|
5170
5193
|
primitive: { topology: "triangle-list" },
|
|
5171
5194
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !0, depthCompare: "always" }
|
|
5172
5195
|
});
|
|
5173
5196
|
}
|
|
5174
|
-
return { pipeline:
|
|
5197
|
+
return { pipeline: d.pipelines[f], layout: d.layouts[f] };
|
|
5175
5198
|
}
|
|
5176
|
-
const
|
|
5199
|
+
const g = {
|
|
5177
5200
|
bloomSourceTextures: {},
|
|
5178
5201
|
bloomCompositeTextures: {},
|
|
5179
5202
|
combinedTexture: null,
|
|
5180
|
-
getBloomSourceTexture(f, h
|
|
5181
|
-
return this.bloomSourceTextures[
|
|
5182
|
-
size: [
|
|
5203
|
+
getBloomSourceTexture(u, f, h) {
|
|
5204
|
+
return this.bloomSourceTextures[u] || (this.bloomSourceTextures[u] = r.createTexture({
|
|
5205
|
+
size: [f, h],
|
|
5183
5206
|
format: "rgba16float",
|
|
5184
5207
|
// HDR chain (see webgpu.js HDR_FORMAT) — avoids additive clip
|
|
5185
5208
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5186
|
-
})), this.bloomSourceTextures[
|
|
5209
|
+
})), this.bloomSourceTextures[u];
|
|
5187
5210
|
},
|
|
5188
|
-
getBloomCompositeTexture(f, h
|
|
5189
|
-
return this.bloomCompositeTextures[
|
|
5190
|
-
size: [
|
|
5211
|
+
getBloomCompositeTexture(u, f, h) {
|
|
5212
|
+
return this.bloomCompositeTextures[u] || (this.bloomCompositeTextures[u] = r.createTexture({
|
|
5213
|
+
size: [f, h],
|
|
5191
5214
|
format: "rgba16float",
|
|
5192
5215
|
// HDR chain
|
|
5193
5216
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5194
|
-
})), this.bloomCompositeTextures[
|
|
5217
|
+
})), this.bloomCompositeTextures[u];
|
|
5195
5218
|
},
|
|
5196
|
-
getCombinedTexture(
|
|
5219
|
+
getCombinedTexture(u, f) {
|
|
5197
5220
|
return this.combinedTexture || (this.combinedTexture = r.createTexture({
|
|
5198
|
-
size: [
|
|
5221
|
+
size: [u, f],
|
|
5199
5222
|
format: "rgba16float",
|
|
5200
5223
|
// HDR chain — tonemapped to canvas in the final pass
|
|
5201
5224
|
usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING
|
|
5202
5225
|
})), this.combinedTexture;
|
|
5203
5226
|
},
|
|
5204
5227
|
resizeTextures() {
|
|
5205
|
-
Object.values(this.bloomSourceTextures).forEach((
|
|
5228
|
+
Object.values(this.bloomSourceTextures).forEach((u) => u == null ? void 0 : u.destroy()), Object.values(this.bloomCompositeTextures).forEach((u) => u == null ? void 0 : u.destroy()), this.combinedTexture && this.combinedTexture.destroy(), this.bloomSourceTextures = {}, this.bloomCompositeTextures = {}, this.combinedTexture = null;
|
|
5206
5229
|
}
|
|
5207
|
-
},
|
|
5230
|
+
}, p = {
|
|
5208
5231
|
systemBindGroups: {},
|
|
5209
5232
|
systemBloomHorizontalBindGroups: {},
|
|
5210
5233
|
secondHorizontalBindGroups: {},
|
|
@@ -5220,166 +5243,323 @@ async function vr(s, t = {}) {
|
|
|
5220
5243
|
clear() {
|
|
5221
5244
|
this.systemBindGroups = {}, this.systemBloomHorizontalBindGroups = {}, this.secondHorizontalBindGroups = {}, this.systemBloomCompositeBindGroups = {}, this.combinedBloomCompositeBindGroups = {}, this.combinedInitialBindGroup = null, this.finalBindGroup = null, this.textureStates = {}, this.textureRefs = {};
|
|
5222
5245
|
}
|
|
5223
|
-
},
|
|
5224
|
-
l.onSystemCreated = (
|
|
5225
|
-
|
|
5246
|
+
}, v = r.createBuffer({ size: 96, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), A = r.createBuffer({ size: 208, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), U = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), I = r.createBuffer({ size: 32, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), _ = r.createBuffer({ size: 64, usage: GPUBufferUsage.UNIFORM | GPUBufferUsage.COPY_DST }), $ = vt(r, new Uint16Array([0, 1, 2, 0, 2, 3]), GPUBufferUsage.INDEX), T = {}, z = () => vt(r, new Float32Array([-0.5, -0.5, 0, 0.5, -0.5, 0, 0.5, 0.5, 0, -0.5, 0.5, 0]), GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST);
|
|
5247
|
+
l.onSystemCreated = (u) => {
|
|
5248
|
+
T[u] || (T[u] = z());
|
|
5226
5249
|
};
|
|
5227
|
-
const
|
|
5228
|
-
function
|
|
5229
|
-
for (const
|
|
5250
|
+
const F = 4e4, Z = new Float32Array(F * 8), J = new Float32Array(F * 4), ee = new Float32Array(F * 4), K = r.createBuffer({ size: F * 8 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), q = r.createBuffer({ size: F * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), Ke = r.createBuffer({ size: F * 4 * 4, usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST }), Pt = /* @__PURE__ */ new Map(), Ye = /* @__PURE__ */ new Map(), kt = 8, Se = [];
|
|
5251
|
+
function ri(u) {
|
|
5252
|
+
for (const f of Se) if (f.ids.has(u)) return f;
|
|
5230
5253
|
return null;
|
|
5231
5254
|
}
|
|
5232
|
-
function
|
|
5233
|
-
if (!
|
|
5234
|
-
|
|
5235
|
-
const
|
|
5236
|
-
for (;
|
|
5237
|
-
}
|
|
5238
|
-
function
|
|
5239
|
-
const
|
|
5240
|
-
if (
|
|
5241
|
-
const
|
|
5242
|
-
return
|
|
5255
|
+
function Qi(u, f) {
|
|
5256
|
+
if (!u.pos) return;
|
|
5257
|
+
u.hist.push({ t: f, x: u.pos[0], y: u.pos[1], z: u.pos[2] });
|
|
5258
|
+
const h = f - kt;
|
|
5259
|
+
for (; u.hist.length > 2 && u.hist[0].t < h; ) u.hist.shift();
|
|
5260
|
+
}
|
|
5261
|
+
function ni(u, f, h) {
|
|
5262
|
+
const b = u.hist;
|
|
5263
|
+
if (b.length === 0) {
|
|
5264
|
+
const R = u.pos;
|
|
5265
|
+
return R && (h[0] = R[0], h[1] = R[1], h[2] = R[2]), h;
|
|
5243
5266
|
}
|
|
5244
|
-
let
|
|
5245
|
-
if (
|
|
5246
|
-
return
|
|
5247
|
-
if (
|
|
5248
|
-
return
|
|
5249
|
-
for (let
|
|
5250
|
-
if (
|
|
5251
|
-
const
|
|
5252
|
-
return
|
|
5267
|
+
let y;
|
|
5268
|
+
if (f >= b[b.length - 1].t)
|
|
5269
|
+
return y = b[b.length - 1], h[0] = y.x, h[1] = y.y, h[2] = y.z, h;
|
|
5270
|
+
if (f <= b[0].t)
|
|
5271
|
+
return y = b[0], h[0] = y.x, h[1] = y.y, h[2] = y.z, h;
|
|
5272
|
+
for (let R = b.length - 1; R > 0; R--)
|
|
5273
|
+
if (b[R - 1].t <= f) {
|
|
5274
|
+
const P = b[R - 1], M = b[R], x = (f - P.t) / Math.max(1e-6, M.t - P.t);
|
|
5275
|
+
return h[0] = P.x + (M.x - P.x) * x, h[1] = P.y + (M.y - P.y) * x, h[2] = P.z + (M.z - P.z) * x, h;
|
|
5253
5276
|
}
|
|
5254
|
-
return
|
|
5255
|
-
}
|
|
5256
|
-
const
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5284
|
-
|
|
5285
|
-
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
|
|
5314
|
-
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5277
|
+
return y = b[0], h[0] = y.x, h[1] = y.y, h[2] = y.z, h;
|
|
5278
|
+
}
|
|
5279
|
+
const ft = Math.PI * 2, se = new Array(257), re = new Array(257), ne = new Array(257);
|
|
5280
|
+
new Array(257), new Array(257), new Array(257);
|
|
5281
|
+
const Re = [0, 0, 0];
|
|
5282
|
+
function es(u) {
|
|
5283
|
+
const f = u.emissionRotationX || 0, h = u.emissionRotationY || 0, b = u.emissionRotationZ || 0;
|
|
5284
|
+
if (!f && !h && !b) return null;
|
|
5285
|
+
const y = f * Math.PI / 180, R = h * Math.PI / 180, P = b * Math.PI / 180, M = Math.cos(y), x = Math.sin(y), w = Math.cos(R), m = Math.sin(R), B = Math.cos(P), C = Math.sin(P);
|
|
5286
|
+
return [
|
|
5287
|
+
w * B,
|
|
5288
|
+
x * m * B - M * C,
|
|
5289
|
+
M * m * B + x * C,
|
|
5290
|
+
w * C,
|
|
5291
|
+
x * m * C + M * B,
|
|
5292
|
+
M * m * C - x * B,
|
|
5293
|
+
-m,
|
|
5294
|
+
x * w,
|
|
5295
|
+
M * w
|
|
5296
|
+
];
|
|
5297
|
+
}
|
|
5298
|
+
function Ct(u, f, h, b, y) {
|
|
5299
|
+
return y[0] = u[0] * f + u[1] * h + u[2] * b, y[1] = u[3] * f + u[4] * h + u[5] * b, y[2] = u[6] * f + u[7] * h + u[8] * b, y;
|
|
5300
|
+
}
|
|
5301
|
+
function ts(u, f, h, b, y, R, P) {
|
|
5302
|
+
let M = u, x = f, w = h;
|
|
5303
|
+
b && (Ct(b, M, x, w, P), M = P[0], x = P[1], w = P[2]), M += R.emissionPositionX || 0, x += R.emissionPositionY || 0, w += R.emissionPositionZ || 0, y._simRotMatrix && (Ct(y._simRotMatrix, M, x, w, P), M = P[0], x = P[1], w = P[2]);
|
|
5304
|
+
const m = y._simPosition;
|
|
5305
|
+
return P[0] = M + (m ? m[0] : 0), P[1] = x + (m ? m[1] : 0), P[2] = w + (m ? m[2] : 0), P;
|
|
5306
|
+
}
|
|
5307
|
+
function is(u, f, h, b, y, R) {
|
|
5308
|
+
let P = u, M = f, x = h;
|
|
5309
|
+
return b && (Ct(b, P, M, x, R), P = R[0], M = R[1], x = R[2]), y._simRotMatrix && (Ct(y._simRotMatrix, P, M, x, R), P = R[0], M = R[1], x = R[2]), R[0] = P, R[1] = M, R[2] = x, R;
|
|
5310
|
+
}
|
|
5311
|
+
function Xt(u, f, h, b, y) {
|
|
5312
|
+
const R = f * 2, P = h * 2, M = 2 * (R + P);
|
|
5313
|
+
let x = (u % 1 + 1) % 1 * M, w = 0, m = 0;
|
|
5314
|
+
return x < R ? (w = -f + x, m = h) : (x -= R) < P ? (w = f, m = h - x) : (x -= P) < R ? (w = f - x, m = -h) : (x -= R, w = -f, m = -h + x), b === "xz" ? (y[0] = w, y[1] = 0, y[2] = m) : (y[0] = w, y[1] = m, y[2] = 0), y;
|
|
5315
|
+
}
|
|
5316
|
+
function ss(u) {
|
|
5317
|
+
const f = u.emissionShape, h = Math.max(1, Math.min(256, Math.floor(u.shapeStrokeSegments ?? 96)));
|
|
5318
|
+
let b = 0, y = !1, R = [0, 0, 1];
|
|
5319
|
+
const P = Re;
|
|
5320
|
+
if (f === "circle") {
|
|
5321
|
+
y = !0, b = Math.max(3, h), R = [0, 0, 1];
|
|
5322
|
+
const M = u.circleOuterRadius ?? 2;
|
|
5323
|
+
for (let x = 0; x < b; x++) {
|
|
5324
|
+
const w = x / b * ft;
|
|
5325
|
+
se[x] = Math.cos(w) * M, re[x] = Math.sin(w) * M, ne[x] = 0;
|
|
5326
|
+
}
|
|
5327
|
+
} else if (f === "disc") {
|
|
5328
|
+
y = !0, b = Math.max(3, h), R = [0, 1, 0];
|
|
5329
|
+
const M = u.discRadius ?? 2;
|
|
5330
|
+
for (let x = 0; x < b; x++) {
|
|
5331
|
+
const w = x / b * ft;
|
|
5332
|
+
se[x] = Math.cos(w) * M, re[x] = 0, ne[x] = Math.sin(w) * M;
|
|
5333
|
+
}
|
|
5334
|
+
} else if (f === "annulus") {
|
|
5335
|
+
y = !0, b = Math.max(3, h), R = [0, 1, 0];
|
|
5336
|
+
const M = u.annulusInnerRadius ?? 1, x = u.annulusOuterRadius ?? 2, w = M + (x - M) * 0.5;
|
|
5337
|
+
for (let m = 0; m < b; m++) {
|
|
5338
|
+
const B = m / b * ft;
|
|
5339
|
+
se[m] = Math.cos(B) * w, re[m] = 0, ne[m] = Math.sin(B) * w;
|
|
5340
|
+
}
|
|
5341
|
+
} else if (f === "arc") {
|
|
5342
|
+
y = !1, b = Math.max(2, h + 1), R = [0, 0, 1];
|
|
5343
|
+
const M = u.arcInnerRadius ?? 0, x = u.arcOuterRadius ?? 2, w = M > 0 ? M + (x - M) * 0.5 : x, m = (u.arcStartAngle ?? 0) * Math.PI / 180, B = (u.arcEndAngle ?? 180) * Math.PI / 180;
|
|
5344
|
+
for (let C = 0; C < b; C++) {
|
|
5345
|
+
const H = b > 1 ? C / (b - 1) : 0, V = m + (B - m) * H;
|
|
5346
|
+
se[C] = Math.cos(V) * w, re[C] = Math.sin(V) * w, ne[C] = 0;
|
|
5347
|
+
}
|
|
5348
|
+
} else if (f === "square") {
|
|
5349
|
+
y = !0, b = Math.max(4, h), R = [0, 0, 1];
|
|
5350
|
+
const M = u.squareSize ?? 2;
|
|
5351
|
+
for (let x = 0; x < b; x++)
|
|
5352
|
+
Xt(x / b, M, M, "xy", P), se[x] = P[0], re[x] = P[1], ne[x] = P[2];
|
|
5353
|
+
} else if (f === "rectangle") {
|
|
5354
|
+
y = !0, b = Math.max(4, h), R = [0, 0, 1];
|
|
5355
|
+
const M = (u.rectangleWidth ?? 2) * 0.5, x = (u.rectangleHeight ?? 2) * 0.5;
|
|
5356
|
+
for (let w = 0; w < b; w++)
|
|
5357
|
+
Xt(w / b, M, x, "xy", P), se[w] = P[0], re[w] = P[1], ne[w] = P[2];
|
|
5358
|
+
} else if (f === "plain") {
|
|
5359
|
+
y = !0, b = Math.max(4, h), R = [0, 1, 0];
|
|
5360
|
+
const M = (u.planeWidth ?? 2) * 0.5, x = (u.planeDepth ?? 2) * 0.5;
|
|
5361
|
+
for (let w = 0; w < b; w++)
|
|
5362
|
+
Xt(w / b, M, x, "xz", P), se[w] = P[0], re[w] = P[1], ne[w] = P[2];
|
|
5363
|
+
} else if (f === "line") {
|
|
5364
|
+
y = !1, b = Math.max(2, h + 1), R = [0, 0, 1];
|
|
5365
|
+
const M = u.lineLength ?? 4;
|
|
5366
|
+
for (let x = 0; x < b; x++) {
|
|
5367
|
+
const w = b > 1 ? x / (b - 1) : 0;
|
|
5368
|
+
se[x] = 0, re[x] = (w - 0.5) * M, ne[x] = 0;
|
|
5369
|
+
}
|
|
5370
|
+
} else if (f === "polygon") {
|
|
5371
|
+
y = !0, b = Math.max(3, h), R = [0, 0, 1];
|
|
5372
|
+
const M = Math.max(3, Math.floor(u.polygonSides ?? 6)), x = u.polygonRadius ?? 2;
|
|
5373
|
+
for (let w = 0; w < b; w++) {
|
|
5374
|
+
const m = w / b * M, B = Math.floor(m), C = m - B, H = B / M * ft, V = (B + 1) / M * ft, L = Math.cos(H) * x, N = Math.sin(H) * x, D = Math.cos(V) * x, pe = Math.sin(V) * x;
|
|
5375
|
+
se[w] = L + (D - L) * C, re[w] = N + (pe - N) * C, ne[w] = 0;
|
|
5376
|
+
}
|
|
5377
|
+
} else
|
|
5378
|
+
b = 0;
|
|
5379
|
+
return { count: b, closed: y, planeNormal: R };
|
|
5380
|
+
}
|
|
5381
|
+
function rs(u, f, h) {
|
|
5382
|
+
if (!h.shapeStrokeEnabled || h.hidden) return u;
|
|
5383
|
+
const { count: b, closed: y, planeNormal: R } = ss(h);
|
|
5384
|
+
if (b < 2) return u;
|
|
5385
|
+
const P = es(h), M = Math.max(1e-4, h.shapeStrokeWidth ?? 0.08), x = Math.max(0, h.opacity ?? 1);
|
|
5386
|
+
if (x <= 0) return u;
|
|
5387
|
+
is(R[0], R[1], R[2], P, f, Re);
|
|
5388
|
+
let w = Math.hypot(Re[0], Re[1], Re[2]) || 1;
|
|
5389
|
+
const m = Re[0] / w, B = Re[1] / w, C = Re[2] / w;
|
|
5390
|
+
for (let X = 0; X < b; X++)
|
|
5391
|
+
ts(se[X], re[X], ne[X], P, f, h, Re), se[X] = Re[0], re[X] = Re[1], ne[X] = Re[2];
|
|
5392
|
+
const H = h.shapeStrokeShape ?? "straight";
|
|
5393
|
+
if (H !== "straight") {
|
|
5394
|
+
const X = h.shapeStrokeAmplitude ?? 0.08, ae = h.shapeStrokeFrequency ?? 10, he = h.shapeStrokeSpeed ?? 0;
|
|
5395
|
+
for (let te = 0; te < b; te++) {
|
|
5396
|
+
const Ie = te === 0 ? y ? b - 1 : 0 : te - 1, Te = te === b - 1 ? y ? 0 : b - 1 : te + 1, et = se[Te] - se[Ie], tt = re[Te] - re[Ie], ze = ne[Te] - ne[Ie], de = B * ze - C * tt, fe = C * et - m * ze, me = m * tt - B * et, Ee = Math.hypot(de, fe, me) || 1, Fe = de / Ee, xe = fe / Ee, Ge = me / Ee, ve = y ? te / b : te / Math.max(1, b - 1), oe = ft * ae * ve + he * ke;
|
|
5397
|
+
let Q = 0, ye = 0;
|
|
5398
|
+
H === "zigzag" ? Q = X * Math.sign(Math.sin(oe) || 1) : H === "sine" ? Q = X * Math.sin(oe) : H === "spiral" && (Q = X * Math.sin(oe), ye = X * Math.cos(oe)), se[te] += Fe * Q + m * ye, re[te] += xe * Q + B * ye, ne[te] += Ge * Q + C * ye;
|
|
5399
|
+
}
|
|
5400
|
+
}
|
|
5401
|
+
const V = y ? b : b - 1, L = h.bloomIntensity || 1, N = h.startColor ?? h.particleColor ?? [1, 1, 1], D = h.endColor ?? N, pe = h.particleColor ?? N, lt = h.randomColorEnabled && Array.isArray(h.randomColors) && h.randomColors.length > 0 ? h.randomColors[0] : null, ue = M * 0.5, wt = Math.max(M * 4, 1e-4), He = (h.shapeStrokeSpeed ?? 0) * ke;
|
|
5402
|
+
let Qe = 0;
|
|
5403
|
+
for (let X = 0; X < V; X++) {
|
|
5404
|
+
const ae = y ? (X + 1) % b : X + 1;
|
|
5405
|
+
Qe += Math.hypot(se[ae] - se[X], re[ae] - re[X], ne[ae] - ne[X]);
|
|
5406
|
+
}
|
|
5407
|
+
const Wt = y ? Math.max(1, Math.round(Qe / wt)) : Math.max(Qe / wt, 1e-6), Bt = Qe > 1e-6 ? Wt / Qe : 0;
|
|
5408
|
+
let Ze = 0;
|
|
5409
|
+
for (let X = 0; X < V && !(u + 54 > Ue.length); X++) {
|
|
5410
|
+
const ae = y ? (X + 1) % b : X + 1, he = se[X], te = re[X], Ie = ne[X], Te = se[ae], et = re[ae], tt = ne[ae];
|
|
5411
|
+
let ze = Te - he, de = et - te, fe = tt - Ie;
|
|
5412
|
+
const me = Math.hypot(ze, de, fe) || 1;
|
|
5413
|
+
ze /= me, de /= me, fe /= me;
|
|
5414
|
+
const Ee = G.right[0], Fe = G.right[1], xe = G.right[2];
|
|
5415
|
+
let Ge = Ee * ze + Fe * de + xe * fe, ve = Ee - Ge * ze, oe = Fe - Ge * de, Q = xe - Ge * fe, ye = Math.hypot(ve, oe, Q);
|
|
5416
|
+
if (ye < 0.2) {
|
|
5417
|
+
const Ce = G.up[0], Tt = G.up[1], E = G.up[2], O = Ce * ze + Tt * de + E * fe;
|
|
5418
|
+
ve = Ce - O * ze, oe = Tt - O * de, Q = E - O * fe, ye = Math.hypot(ve, oe, Q) || 1;
|
|
5419
|
+
}
|
|
5420
|
+
ve /= ye, oe /= ye, Q /= ye;
|
|
5421
|
+
const yt = y ? X / b : X / Math.max(1, b - 1), gt = y ? ae / b : ae / Math.max(1, b - 1), bt = Ze * Bt + He, it = (Ze + me) * Bt + He;
|
|
5422
|
+
let Pe, _e, De, Ae, le, ce;
|
|
5423
|
+
lt ? (Pe = Ae = lt[0], _e = le = lt[1], De = ce = lt[2]) : h.colorTransitionEnabled ? (Pe = N[0] + (D[0] - N[0]) * yt, _e = N[1] + (D[1] - N[1]) * yt, De = N[2] + (D[2] - N[2]) * yt, Ae = N[0] + (D[0] - N[0]) * gt, le = N[1] + (D[1] - N[1]) * gt, ce = N[2] + (D[2] - N[2]) * gt) : (Pe = Ae = pe[0], _e = le = pe[1], De = ce = pe[2]), Pe = Math.min(1, Pe * L), _e = Math.min(1, _e * L), De = Math.min(1, De * L), Ae = Math.min(1, Ae * L), le = Math.min(1, le * L), ce = Math.min(1, ce * L);
|
|
5424
|
+
const Xe = he + ve * ue, Vt = te + oe * ue, Ot = Ie + Q * ue, Rt = he - ve * ue, St = te - oe * ue, Me = Ie - Q * ue, we = Te + ve * ue, Be = et + oe * ue, st = tt + Q * ue, ct = Te - ve * ue, Lt = et - oe * ue, $e = tt - Q * ue, ge = (Ce, Tt, E, O, ie, Y, k, j, W) => {
|
|
5425
|
+
Ue[u++] = Ce, Ue[u++] = Tt, Ue[u++] = E, Ue[u++] = O, Ue[u++] = ie, Ue[u++] = Y, Ue[u++] = k, Ue[u++] = j, Ue[u++] = W;
|
|
5426
|
+
};
|
|
5427
|
+
ge(Xe, Vt, Ot, Pe, _e, De, x, bt, 0), ge(Rt, St, Me, Pe, _e, De, x, bt, 1), ge(we, Be, st, Ae, le, ce, x, it, 0), ge(Rt, St, Me, Pe, _e, De, x, bt, 1), ge(ct, Lt, $e, Ae, le, ce, x, it, 1), ge(we, Be, st, Ae, le, ce, x, it, 0), Ze += me;
|
|
5428
|
+
}
|
|
5429
|
+
return u;
|
|
5430
|
+
}
|
|
5431
|
+
const ns = 0.41421356;
|
|
5432
|
+
function as() {
|
|
5433
|
+
Pt.clear(), Ye.clear();
|
|
5434
|
+
let u = 0, f = 0, h = 0;
|
|
5435
|
+
G.position[0], G.position[1], G.position[2];
|
|
5436
|
+
for (const { system: b, config: y } of l.particleSystems) {
|
|
5437
|
+
if (y.hidden) continue;
|
|
5438
|
+
if (y.emissionTrailEnabled && !y.glbModelEnabled) {
|
|
5439
|
+
b.readbackAndProcessParticles();
|
|
5440
|
+
const P = b.particleData, M = b.particleVelocities, x = b.activeParticles;
|
|
5441
|
+
if (P && M && x > 0) {
|
|
5442
|
+
const w = y.emissionTrailMode === "particles", m = u, B = y.emissionTrailDuration ?? 1, C = y.opacity ?? 1, H = y.particleSize ?? 0.5, V = y.bloomIntensity || 1, L = Math.max(1, Math.min(64, y.emissionTrailSegments ?? 8)), N = y.emissionTrailShape || "straight", D = y.followSystemTranslation ?? !0, pe = b._simPosition, lt = D && pe ? pe[0] : 0, ue = D && pe ? pe[1] : 0, wt = D && pe ? pe[2] : 0, He = b._simVelocity, Qe = He ? He[0] : 0, Wt = He ? He[1] : 0, Bt = He ? He[2] : 0, Ze = ri(y.id), X = !!(D && Ze && Ze.hist && Ze.hist.length > 1);
|
|
5443
|
+
for (let ae = 0; ae < x; ae++) {
|
|
5444
|
+
const he = ae * 8, te = P[he], Ie = P[he + 1], Te = P[he + 2], et = te + lt, tt = Ie + ue, ze = Te + wt;
|
|
5445
|
+
let de = P[he + 3], fe = P[he + 4], me = P[he + 5];
|
|
5446
|
+
const Ee = P[he + 6], Fe = P[he + 7];
|
|
5447
|
+
if (Ee >= Fe || Fe <= 0) continue;
|
|
5448
|
+
const xe = Ee / Fe;
|
|
5449
|
+
if (y.colorTransitionEnabled) {
|
|
5450
|
+
const E = y.startColor ?? [1, 0, 0], O = y.endColor ?? [0, 0, 1];
|
|
5451
|
+
de = E[0] + (O[0] - E[0]) * xe, fe = E[1] + (O[1] - E[1]) * xe, me = E[2] + (O[2] - E[2]) * xe;
|
|
5452
|
+
}
|
|
5453
|
+
de = Math.min(1, de * V), fe = Math.min(1, fe * V), me = Math.min(1, me * V);
|
|
5454
|
+
let Ge = H;
|
|
5455
|
+
if (y.randomSize) {
|
|
5456
|
+
const E = Math.sin(Fe * 54321.67) * 43758.5453 % 1, O = E < 0 ? E + 1 : E;
|
|
5457
|
+
Ge = (y.minSize ?? 0.1) + ((y.maxSize ?? 0.5) - (y.minSize ?? 0.1)) * O;
|
|
5458
|
+
}
|
|
5459
|
+
if (y.fadeSizeEnabled) {
|
|
5460
|
+
const E = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
|
|
5461
|
+
Ge *= 1 - Math.pow(xe, 1 / E);
|
|
5462
|
+
}
|
|
5463
|
+
if (y.increaseSizeEnabled) {
|
|
5464
|
+
const E = Math.max(0.01, Math.min(10, y.sizeLifetimeSpeed ?? 1));
|
|
5465
|
+
Ge *= 1 + Math.pow(xe, 1 / E);
|
|
5466
|
+
}
|
|
5467
|
+
if (Ge <= 0 || xe > 0.9) continue;
|
|
5468
|
+
const ve = Math.min((0.9 - xe) * (1 / 0.2), 1), oe = 0.75 * Ge * ns * ve;
|
|
5469
|
+
let Q = C;
|
|
5470
|
+
if (y.fadeEnabled && (Q *= Math.max(0, 1 - xe)), Q *= ve, Q < 0.01) continue;
|
|
5471
|
+
const ye = ae * 4, yt = M[ye], gt = M[ye + 1], bt = M[ye + 2], it = yt + Qe, Pe = gt + Wt, _e = bt + Bt, De = Math.sqrt(it * it + Pe * Pe + _e * _e);
|
|
5472
|
+
if (De < 1e-3) continue;
|
|
5473
|
+
const Ae = 1 / De, le = it * Ae, ce = Pe * Ae, Xe = _e * Ae, Vt = G.right[0], Ot = G.right[1], Rt = G.right[2];
|
|
5474
|
+
let St = Vt * le + Ot * ce + Rt * Xe, Me = Vt - St * le, we = Ot - St * ce, Be = Rt - St * Xe, st = Math.sqrt(Me * Me + we * we + Be * Be);
|
|
5475
|
+
if (st < 0.2) {
|
|
5476
|
+
const E = G.up[0], O = G.up[1], ie = G.up[2], Y = E * le + O * ce + ie * Xe;
|
|
5477
|
+
Me = E - Y * le, we = O - Y * ce, Be = ie - Y * Xe, st = Math.sqrt(Me * Me + we * we + Be * Be) || 1;
|
|
5478
|
+
}
|
|
5479
|
+
Me /= st, we /= st, Be /= st;
|
|
5480
|
+
const ct = Math.min(B, Ee);
|
|
5481
|
+
if (ct < 1e-3) continue;
|
|
5482
|
+
const Lt = y.gravityEnabled && y.gravityStrength || 0, $e = bs, ge = Ss, Ce = xs;
|
|
5483
|
+
if (y.orientToDirection && y.burstMode && X) {
|
|
5484
|
+
const E = b._emitSimRotY || 0, O = vs, ie = Ps, Y = _s;
|
|
5485
|
+
for (let k = 0; k <= L; k++) {
|
|
5486
|
+
const j = ni(Ze, ke - k / L * ct, Si);
|
|
5487
|
+
O[k] = j[0], ie[k] = j[1], Y[k] = j[2];
|
|
5488
|
+
}
|
|
5489
|
+
for (let k = 0; k <= L; k++) {
|
|
5490
|
+
const j = k > 0 ? k - 1 : 0, W = k < L ? k + 1 : L;
|
|
5491
|
+
let ut = O[j] - O[W], dt = Y[j] - Y[W];
|
|
5492
|
+
const rt = (Math.hypot(ut, dt) > 1e-5 ? Math.atan2(ut, dt) : Math.atan2(Qe, Bt)) - E, Ve = Math.cos(rt), Oe = Math.sin(rt), Je = k / L * ct, Jt = -0.5 * Lt * Je * Je;
|
|
5493
|
+
$e[k] = Ve * te + Oe * Te + O[k], ge[k] = Ie + Jt + ie[k], Ce[k] = -Oe * te + Ve * Te + Y[k];
|
|
5494
|
+
}
|
|
5495
|
+
} else for (let E = 0; E <= L; E++) {
|
|
5496
|
+
const O = E / L * ct, ie = -0.5 * Lt * O * O;
|
|
5497
|
+
if (X) {
|
|
5498
|
+
const Y = ni(Ze, ke - O, Si);
|
|
5499
|
+
$e[E] = te - yt * O + Y[0], ge[E] = Ie - gt * O + ie + Y[1], Ce[E] = Te - bt * O + Y[2];
|
|
5500
|
+
} else
|
|
5501
|
+
$e[E] = et - it * O, ge[E] = tt - Pe * O + ie, Ce[E] = ze - _e * O;
|
|
5502
|
+
}
|
|
5503
|
+
if (N !== "straight") {
|
|
5504
|
+
const E = y.emissionTrailShapeAmplitude ?? 0.1, O = y.emissionTrailShapeFrequency ?? 4, ie = y.emissionTrailShapeSpeed ?? 0;
|
|
5505
|
+
let Y = -Xe, k = 0, j = le, W = Math.sqrt(Y * Y + j * j);
|
|
5506
|
+
W < 1e-6 && (Y = 0, k = Xe, j = -ce, W = Math.sqrt(Y * Y + k * k + j * j) || 1), Y /= W, k /= W, j /= W;
|
|
5507
|
+
const ut = ce * j - Xe * k, dt = Xe * Y - le * j, We = le * k - ce * Y;
|
|
5508
|
+
for (let be = 1; be <= L; be++) {
|
|
5509
|
+
const rt = be / L * ct, Ve = 2 * Math.PI * O * (ke - rt) + ie * ke;
|
|
5510
|
+
let Oe = 0, Je = 0;
|
|
5511
|
+
N === "zigzag" ? Oe = E * Math.sign(Math.sin(Ve)) : N === "sine" ? Oe = E * Math.sin(Ve) : N === "spiral" && (Oe = E * Math.sin(Ve), Je = E * Math.cos(Ve)), $e[be] += Y * Oe + ut * Je, ge[be] += k * Oe + dt * Je, Ce[be] += j * Oe + We * Je;
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5514
|
+
if (w)
|
|
5515
|
+
for (let E = 1; E <= L && u < F; E++) {
|
|
5516
|
+
const O = E / L, ie = $e[E] - lt, Y = ge[E] - ue, k = Ce[E] - wt, j = u * 8, W = u * 4;
|
|
5517
|
+
Z[j] = ie, Z[j + 1] = Y, Z[j + 2] = k, Z[j + 3] = de, Z[j + 4] = fe, Z[j + 5] = me, Z[j + 6] = Ee + (Fe - Ee) * O, Z[j + 7] = Fe, J[W] = 0, J[W + 1] = 0, J[W + 2] = 0, J[W + 3] = 0, ee[W] = ie, ee[W + 1] = Y, ee[W + 2] = k, ee[W + 3] = 0, u++;
|
|
5518
|
+
}
|
|
5519
|
+
else
|
|
5520
|
+
for (let E = 0; E < L && !(f + 42 > qe.length); E++) {
|
|
5521
|
+
const O = E / L, ie = (E + 1) / L, Y = $e[E], k = ge[E], j = Ce[E], W = $e[E + 1], ut = ge[E + 1], dt = Ce[E + 1], We = oe * (1 - O), be = oe * (1 - ie), rt = Q * (1 - O) * (1 - O), Ve = Q * (1 - ie) * (1 - ie), Oe = Y + Me * We, Je = k + we * We, Jt = j + Be * We, Ri = Y - Me * We, Ti = k - we * We, Ei = j - Be * We, Ai = W + Me * be, Ci = ut + we * be, Ui = dt + Be * be, zs = W - Me * be, Fs = ut - we * be, Gs = dt - Be * be, xt = (Ds, Vs, Os, Ls) => {
|
|
5522
|
+
qe[f++] = Ds, qe[f++] = Vs, qe[f++] = Os, qe[f++] = de, qe[f++] = fe, qe[f++] = me, qe[f++] = Ls;
|
|
5523
|
+
};
|
|
5524
|
+
xt(Oe, Je, Jt, rt), xt(Ri, Ti, Ei, rt), xt(Ai, Ci, Ui, Ve), xt(Ri, Ti, Ei, rt), xt(zs, Fs, Gs, Ve), xt(Ai, Ci, Ui, Ve);
|
|
5525
|
+
}
|
|
5336
5526
|
}
|
|
5527
|
+
w && u > m && Pt.set(y.id, { first: m, count: u - m });
|
|
5337
5528
|
}
|
|
5338
|
-
if (Q)
|
|
5339
|
-
for (let _ = 1; _ <= I && f < E; _++) {
|
|
5340
|
-
const z = _ / I, $ = _e[_] - X, V = we[_] - it, C = Be[_] - jt, O = f * 8, q = f * 4;
|
|
5341
|
-
F[O] = $, F[O + 1] = V, F[O + 2] = C, F[O + 3] = Le, F[O + 4] = Xe, F[O + 5] = ke, F[O + 6] = Ne + (Ie - Ne) * z, F[O + 7] = Ie, k[q] = 0, k[q + 1] = 0, k[q + 2] = 0, k[q + 3] = 0, Y[q] = $, Y[q + 1] = V, Y[q + 2] = C, Y[q + 3] = 0, f++;
|
|
5342
|
-
}
|
|
5343
|
-
else
|
|
5344
|
-
for (let _ = 0; _ < I && !(h + 42 > le.length); _++) {
|
|
5345
|
-
const z = _ / I, $ = (_ + 1) / I, V = _e[_], C = we[_], O = Be[_], q = _e[_ + 1], Me = we[_ + 1], Re = Be[_ + 1], ce = $t * (1 - z), ee = $t * (1 - $), ge = Ye * (1 - z) * (1 - z), te = Ye * (1 - $) * (1 - $), ie = V + re * ce, ue = C + ne * ce, St = O + ae * ce, ri = V - re * ce, ni = C - ne * ce, ai = O - ae * ce, oi = q + re * ee, li = Me + ne * ee, ci = Re + ae * ee, ls = q - re * ee, cs = Me - ne * ee, us = Re - ae * ee, ze = (ds, fs, ps, hs) => {
|
|
5346
|
-
le[h++] = ds, le[h++] = fs, le[h++] = ps, le[h++] = Le, le[h++] = Xe, le[h++] = ke, le[h++] = hs;
|
|
5347
|
-
};
|
|
5348
|
-
ze(ie, ue, St, ge), ze(ri, ni, ai, ge), ze(oi, li, ci, te), ze(ri, ni, ai, ge), ze(ls, cs, us, te), ze(oi, li, ci, te);
|
|
5349
|
-
}
|
|
5350
5529
|
}
|
|
5351
|
-
|
|
5530
|
+
const R = h;
|
|
5531
|
+
h = rs(h, b, y), h > R && Ye.set(y.id, { first: R / 9, count: (h - R) / 9 });
|
|
5352
5532
|
}
|
|
5353
|
-
|
|
5533
|
+
u > 0 && (r.queue.writeBuffer(K, 0, Z, 0, u * 8), r.queue.writeBuffer(q, 0, J, 0, u * 4), r.queue.writeBuffer(Ke, 0, ee, 0, u * 4)), _t = f / 7, _t > 0 && r.queue.writeBuffer(Nt, 0, qe, 0, f), mi = h / 9, mi > 0 && r.queue.writeBuffer(Yt, 0, Ue, 0, h);
|
|
5354
5534
|
}
|
|
5355
|
-
const
|
|
5356
|
-
r.queue.writeBuffer(
|
|
5535
|
+
const ai = () => {
|
|
5536
|
+
r.queue.writeBuffer(U, 0, new Float32Array([1, 0, a.width, a.height, 0, 0, 0, 0])), r.queue.writeBuffer(I, 0, new Float32Array([0, 1, a.width, a.height, 0, 0, 0, 0]));
|
|
5357
5537
|
};
|
|
5358
|
-
|
|
5359
|
-
const
|
|
5360
|
-
|
|
5361
|
-
const
|
|
5362
|
-
particlePipeline:
|
|
5363
|
-
particleAdditivePipeline:
|
|
5364
|
-
particleDepthWritePipeline:
|
|
5365
|
-
blurPipeline:
|
|
5366
|
-
compositePipeline:
|
|
5367
|
-
directRenderPipeline:
|
|
5368
|
-
finalCompositePipeline:
|
|
5369
|
-
glbMeshPipeline:
|
|
5370
|
-
} =
|
|
5538
|
+
ai();
|
|
5539
|
+
const oi = new Float32Array(16).fill(0);
|
|
5540
|
+
oi[0] = 1, r.queue.writeBuffer(_, 0, oi);
|
|
5541
|
+
const Le = Tr(r), je = Br(r), {
|
|
5542
|
+
particlePipeline: os,
|
|
5543
|
+
particleAdditivePipeline: ls,
|
|
5544
|
+
particleDepthWritePipeline: cs,
|
|
5545
|
+
blurPipeline: Ut,
|
|
5546
|
+
compositePipeline: us,
|
|
5547
|
+
directRenderPipeline: li,
|
|
5548
|
+
finalCompositePipeline: ds,
|
|
5549
|
+
glbMeshPipeline: fs
|
|
5550
|
+
} = Rr(r, c, je), ci = r.createShaderModule({ code: `
|
|
5371
5551
|
struct U { mvp: mat4x4<f32> };
|
|
5372
5552
|
@group(0) @binding(0) var<uniform> u: U;
|
|
5373
5553
|
struct VIn { @location(0) pos: vec3<f32>, @location(1) col: vec4<f32> };
|
|
5374
5554
|
struct VOut { @builtin(position) pos: vec4<f32>, @location(0) col: vec4<f32> };
|
|
5375
5555
|
@vertex fn vs(v: VIn) -> VOut { var o: VOut; o.pos = u.mvp * vec4<f32>(v.pos, 1.0); o.col = v.col; return o; }
|
|
5376
5556
|
@fragment fn fs(i: VOut) -> @location(0) vec4<f32> { return i.col; }
|
|
5377
|
-
` }),
|
|
5557
|
+
` }), ui = r.createBindGroupLayout({
|
|
5378
5558
|
entries: [{ binding: 0, visibility: GPUShaderStage.VERTEX, buffer: { type: "uniform" } }]
|
|
5379
|
-
}),
|
|
5380
|
-
layout: r.createPipelineLayout({ bindGroupLayouts: [
|
|
5559
|
+
}), ps = r.createRenderPipeline({
|
|
5560
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [ui] }),
|
|
5381
5561
|
vertex: {
|
|
5382
|
-
module:
|
|
5562
|
+
module: ci,
|
|
5383
5563
|
entryPoint: "vs",
|
|
5384
5564
|
buffers: [{ arrayStride: 28, attributes: [
|
|
5385
5565
|
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
@@ -5387,7 +5567,7 @@ async function vr(s, t = {}) {
|
|
|
5387
5567
|
] }]
|
|
5388
5568
|
},
|
|
5389
5569
|
fragment: {
|
|
5390
|
-
module:
|
|
5570
|
+
module: ci,
|
|
5391
5571
|
entryPoint: "fs",
|
|
5392
5572
|
targets: [{ format: "rgba16float", blend: {
|
|
5393
5573
|
// renders into the HDR sceneTexture
|
|
@@ -5399,23 +5579,182 @@ async function vr(s, t = {}) {
|
|
|
5399
5579
|
// depth24plus to match the non-bloom pass; test against the resolved scene depth
|
|
5400
5580
|
// (occlusion) but don't write (transparent ribbon).
|
|
5401
5581
|
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5402
|
-
}),
|
|
5403
|
-
size:
|
|
5582
|
+
}), di = 512 * 64 * 6, qe = new Float32Array(di * 7), Nt = r.createBuffer({
|
|
5583
|
+
size: di * 7 * 4,
|
|
5404
5584
|
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5405
5585
|
label: "ribbonBuffer"
|
|
5406
|
-
}),
|
|
5407
|
-
layout:
|
|
5408
|
-
entries: [{ binding: 0, resource: { buffer:
|
|
5586
|
+
}), hs = r.createBindGroup({
|
|
5587
|
+
layout: ui,
|
|
5588
|
+
entries: [{ binding: 0, resource: { buffer: v } }]
|
|
5409
5589
|
});
|
|
5410
|
-
let
|
|
5411
|
-
const
|
|
5412
|
-
|
|
5413
|
-
|
|
5590
|
+
let _t = 0;
|
|
5591
|
+
const fi = r.createShaderModule({ code: `
|
|
5592
|
+
struct Uniforms {
|
|
5593
|
+
transform: mat4x4<f32>,
|
|
5594
|
+
cameraPosition: vec3<f32>,
|
|
5595
|
+
aspectRatio: f32,
|
|
5596
|
+
elapsedTime: f32,
|
|
5597
|
+
}
|
|
5598
|
+
|
|
5599
|
+
struct AppearanceUniforms {
|
|
5600
|
+
fadeEnabled: f32,
|
|
5601
|
+
colorTransitionEnabled: f32,
|
|
5602
|
+
particleSize: f32,
|
|
5603
|
+
textureEnabled: f32,
|
|
5604
|
+
singleColor: vec3<f32>,
|
|
5605
|
+
rotation: f32,
|
|
5606
|
+
startColor: vec3<f32>,
|
|
5607
|
+
rotationMode: f32,
|
|
5608
|
+
endColor: vec3<f32>,
|
|
5609
|
+
minRotation: f32,
|
|
5610
|
+
maxRotation: f32,
|
|
5611
|
+
aspectRatio: f32,
|
|
5612
|
+
randomSize: f32,
|
|
5613
|
+
minSize: f32,
|
|
5614
|
+
maxSize: f32,
|
|
5615
|
+
fadeSizeEnabled: f32,
|
|
5616
|
+
opacity: f32,
|
|
5617
|
+
increaseSizeEnabled: f32,
|
|
5618
|
+
sizeLifetimeSpeed: f32,
|
|
5619
|
+
particleShape: f32,
|
|
5620
|
+
particleShapeRotation: f32,
|
|
5621
|
+
pulseEnabled: f32,
|
|
5622
|
+
pulseAmplitude: f32,
|
|
5623
|
+
pulseFrequency: f32,
|
|
5624
|
+
pulsePhaseRandom: f32,
|
|
5625
|
+
pulseOpacity: f32,
|
|
5626
|
+
glbRotationX: f32,
|
|
5627
|
+
glbRotationY: f32,
|
|
5628
|
+
glbRotationZ: f32,
|
|
5629
|
+
_pad0: f32,
|
|
5630
|
+
systemOffset: vec3<f32>,
|
|
5631
|
+
_pad1: f32,
|
|
5632
|
+
simRotX: f32,
|
|
5633
|
+
simRotZ: f32,
|
|
5634
|
+
velocityStretchEnabled: f32,
|
|
5635
|
+
velocityStretchFactor: f32,
|
|
5636
|
+
noiseDistortEnabled: f32,
|
|
5637
|
+
noiseTilingX: f32,
|
|
5638
|
+
noiseTilingY: f32,
|
|
5639
|
+
noiseSpeed: f32,
|
|
5640
|
+
noiseAmplitude: f32,
|
|
5641
|
+
systemVelX: f32,
|
|
5642
|
+
systemVelY: f32,
|
|
5643
|
+
systemVelZ: f32,
|
|
5644
|
+
orientX: f32,
|
|
5645
|
+
orientY: f32,
|
|
5646
|
+
orientZ: f32,
|
|
5647
|
+
_pad2: f32,
|
|
5648
|
+
}
|
|
5649
|
+
|
|
5650
|
+
@group(0) @binding(0) var<uniform> uniforms : Uniforms;
|
|
5651
|
+
@group(0) @binding(1) var<uniform> appearance : AppearanceUniforms;
|
|
5652
|
+
@group(0) @binding(2) var particleTexture: texture_2d<f32>;
|
|
5653
|
+
@group(0) @binding(3) var particleSampler: sampler;
|
|
5654
|
+
|
|
5655
|
+
struct VIn {
|
|
5656
|
+
@location(0) pos: vec3<f32>,
|
|
5657
|
+
@location(1) col: vec4<f32>,
|
|
5658
|
+
@location(2) uv: vec2<f32>,
|
|
5659
|
+
};
|
|
5660
|
+
|
|
5661
|
+
struct VOut {
|
|
5662
|
+
@builtin(position) pos: vec4<f32>,
|
|
5663
|
+
@location(0) col: vec3<f32>,
|
|
5664
|
+
@location(1) alpha: f32,
|
|
5665
|
+
@location(2) uv: vec2<f32>,
|
|
5666
|
+
@location(3) noiseOffset: vec2<f32>,
|
|
5667
|
+
};
|
|
5668
|
+
|
|
5669
|
+
fn hash21(p: vec2<f32>) -> f32 {
|
|
5670
|
+
return fract(sin(dot(p, vec2<f32>(127.1, 311.7))) * 43758.5453);
|
|
5671
|
+
}
|
|
5672
|
+
|
|
5673
|
+
fn valueNoise(p: vec2<f32>) -> f32 {
|
|
5674
|
+
let i = floor(p);
|
|
5675
|
+
let f = fract(p);
|
|
5676
|
+
let u = f * f * (3.0 - 2.0 * f);
|
|
5677
|
+
let a = hash21(i);
|
|
5678
|
+
let b = hash21(i + vec2<f32>(1.0, 0.0));
|
|
5679
|
+
let c = hash21(i + vec2<f32>(0.0, 1.0));
|
|
5680
|
+
let d = hash21(i + vec2<f32>(1.0, 1.0));
|
|
5681
|
+
return mix(mix(a, b, u.x), mix(c, d, u.x), u.y);
|
|
5682
|
+
}
|
|
5683
|
+
|
|
5684
|
+
@vertex
|
|
5685
|
+
fn vs(v: VIn) -> VOut {
|
|
5686
|
+
var o: VOut;
|
|
5687
|
+
o.pos = uniforms.transform * vec4<f32>(v.pos, 1.0);
|
|
5688
|
+
o.col = v.col.rgb;
|
|
5689
|
+
o.alpha = v.col.a;
|
|
5690
|
+
o.uv = v.uv;
|
|
5691
|
+
o.noiseOffset = vec2<f32>(
|
|
5692
|
+
uniforms.elapsedTime * appearance.noiseSpeed,
|
|
5693
|
+
uniforms.elapsedTime * appearance.noiseSpeed * 0.5
|
|
5694
|
+
);
|
|
5695
|
+
return o;
|
|
5696
|
+
}
|
|
5697
|
+
|
|
5698
|
+
@fragment
|
|
5699
|
+
fn fs(i: VOut) -> @location(0) vec4<f32> {
|
|
5700
|
+
let baseUV = vec2<f32>(fract(i.uv.x), clamp(i.uv.y, 0.001, 0.999));
|
|
5701
|
+
var sampleUV = baseUV;
|
|
5702
|
+
if (appearance.textureEnabled > 0.5) {
|
|
5703
|
+
if (appearance.noiseDistortEnabled > 0.5) {
|
|
5704
|
+
let nUV = baseUV * vec2<f32>(
|
|
5705
|
+
max(appearance.noiseTilingX, 0.0001),
|
|
5706
|
+
max(appearance.noiseTilingY, 0.0001)
|
|
5707
|
+
) + i.noiseOffset;
|
|
5708
|
+
let n1 = valueNoise(nUV) - 0.5;
|
|
5709
|
+
let n2 = valueNoise(nUV + vec2<f32>(13.7, 7.3)) - 0.5;
|
|
5710
|
+
sampleUV = vec2<f32>(
|
|
5711
|
+
fract(sampleUV.x + n1 * appearance.noiseAmplitude),
|
|
5712
|
+
clamp(sampleUV.y + n2 * appearance.noiseAmplitude, 0.001, 0.999)
|
|
5713
|
+
);
|
|
5714
|
+
}
|
|
5715
|
+
let texColor = textureSample(particleTexture, particleSampler, sampleUV);
|
|
5716
|
+
return vec4<f32>(i.col * texColor.rgb, i.alpha * texColor.a);
|
|
5717
|
+
}
|
|
5718
|
+
return vec4<f32>(i.col, i.alpha);
|
|
5719
|
+
}
|
|
5720
|
+
` }), pi = (u) => r.createRenderPipeline({
|
|
5721
|
+
layout: r.createPipelineLayout({ bindGroupLayouts: [je.particleBindGroupLayout] }),
|
|
5722
|
+
vertex: {
|
|
5723
|
+
module: fi,
|
|
5724
|
+
entryPoint: "vs",
|
|
5725
|
+
buffers: [{ arrayStride: 36, attributes: [
|
|
5726
|
+
{ shaderLocation: 0, offset: 0, format: "float32x3" },
|
|
5727
|
+
{ shaderLocation: 1, offset: 12, format: "float32x4" },
|
|
5728
|
+
{ shaderLocation: 2, offset: 28, format: "float32x2" }
|
|
5729
|
+
] }]
|
|
5730
|
+
},
|
|
5731
|
+
fragment: {
|
|
5732
|
+
module: fi,
|
|
5733
|
+
entryPoint: "fs",
|
|
5734
|
+
targets: [{ format: "rgba16float", blend: u }]
|
|
5735
|
+
},
|
|
5736
|
+
primitive: { topology: "triangle-list" },
|
|
5737
|
+
depthStencil: { format: "depth24plus", depthWriteEnabled: !1, depthCompare: "less-equal" }
|
|
5738
|
+
}), ms = pi({
|
|
5739
|
+
color: { srcFactor: "src-alpha", dstFactor: "one-minus-src-alpha", operation: "add" },
|
|
5740
|
+
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5741
|
+
}), ys = pi({
|
|
5742
|
+
color: { srcFactor: "src-alpha", dstFactor: "one", operation: "add" },
|
|
5743
|
+
alpha: { srcFactor: "one", dstFactor: "one-minus-src-alpha", operation: "add" }
|
|
5744
|
+
}), hi = 256 * 256 * 6, Ue = new Float32Array(hi * 9), Yt = r.createBuffer({
|
|
5745
|
+
size: hi * 9 * 4,
|
|
5746
|
+
usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
5747
|
+
label: "shapeStrokeBuffer"
|
|
5748
|
+
});
|
|
5749
|
+
let mi = 0, { sceneTexture: nt, bloomTexA: at, bloomTexB: ot } = Oi(r, c, a.width, a.height), It = Li(r, a.width, a.height), pt, yi, zt, Mt;
|
|
5750
|
+
const gi = () => {
|
|
5751
|
+
const u = (f) => f.createView();
|
|
5752
|
+
pt = u(nt), yi = u(at), zt = u(ot), Mt = u(It);
|
|
5414
5753
|
};
|
|
5415
|
-
|
|
5416
|
-
const
|
|
5417
|
-
let
|
|
5418
|
-
const
|
|
5754
|
+
gi();
|
|
5755
|
+
const jt = { uniformBuffer: v, appearanceUniformBuffer: A, horizontalBlurUniformBuffer: U, verticalBlurUniformBuffer: I, bloomIntensityBuffer: _ };
|
|
5756
|
+
let Ft = ei(r, Le, jt, { sceneTexture: nt, bloomTexA: at, bloomTexB: ot });
|
|
5757
|
+
const G = {
|
|
5419
5758
|
mvp: new Float32Array(16),
|
|
5420
5759
|
position: new Float32Array([0, 0, 10]),
|
|
5421
5760
|
right: new Float32Array([1, 0, 0]),
|
|
@@ -5423,187 +5762,189 @@ async function vr(s, t = {}) {
|
|
|
5423
5762
|
up: new Float32Array([0, 1, 0]),
|
|
5424
5763
|
hasCamera: !1
|
|
5425
5764
|
};
|
|
5426
|
-
let
|
|
5427
|
-
const
|
|
5428
|
-
let
|
|
5429
|
-
function
|
|
5430
|
-
const
|
|
5431
|
-
|
|
5432
|
-
let
|
|
5433
|
-
const
|
|
5434
|
-
if (!
|
|
5435
|
-
|
|
5765
|
+
let ke = 0, gs = 0;
|
|
5766
|
+
const ht = new Float32Array(5), bi = new Float32Array(16), bs = new Array(65), Ss = new Array(65), xs = new Array(65), vs = new Array(65), Ps = new Array(65), _s = new Array(65), Si = [0, 0, 0], mt = { key: null, ms: !1, bindGroup: null };
|
|
5767
|
+
let xi = !1, qt = !0, Gt = !1, Dt = null, Ht = a.width, Zt = a.height;
|
|
5768
|
+
function vi() {
|
|
5769
|
+
const u = [nt, at, ot, It], f = Oi(r, c, a.width, a.height);
|
|
5770
|
+
nt = f.sceneTexture, at = f.bloomTexA, ot = f.bloomTexB, It = Li(r, a.width, a.height), gi(), ai(), p.clear(), g.resizeTextures(), Ft = ei(r, Le, jt, { sceneTexture: nt, bloomTexA: at, bloomTexB: ot });
|
|
5771
|
+
let h = !1;
|
|
5772
|
+
const b = () => {
|
|
5773
|
+
if (!h) {
|
|
5774
|
+
h = !0, requestAnimationFrame(b);
|
|
5436
5775
|
return;
|
|
5437
5776
|
}
|
|
5438
|
-
|
|
5777
|
+
u.forEach((y) => y.destroy());
|
|
5439
5778
|
};
|
|
5440
|
-
requestAnimationFrame(
|
|
5779
|
+
requestAnimationFrame(b);
|
|
5441
5780
|
}
|
|
5442
|
-
function
|
|
5443
|
-
|
|
5781
|
+
function Ms(u, f, h) {
|
|
5782
|
+
G.mvp.set(Ur(u, f)), f && f.length >= 10 && (G.right[0] = f[0], G.right[1] = f[4], G.right[2] = f[8], G.up[0] = f[1], G.up[1] = f[5], G.up[2] = f[9]), h && (G.position[0] = h.x ?? h[0], G.position[1] = h.y ?? h[1], G.position[2] = h.z ?? h[2]), G.hasCamera = !0;
|
|
5444
5783
|
}
|
|
5445
|
-
function
|
|
5446
|
-
|
|
5784
|
+
function ws(u, f) {
|
|
5785
|
+
G.mvp.set(u), f && (G.position[0] = f.x ?? f[0], G.position[1] = f.y ?? f[1], G.position[2] = f.z ?? f[2]), G.hasCamera = !0;
|
|
5447
5786
|
}
|
|
5448
|
-
async function
|
|
5449
|
-
if (
|
|
5450
|
-
|
|
5787
|
+
async function $t(u) {
|
|
5788
|
+
if (Gt) {
|
|
5789
|
+
Dt = u;
|
|
5451
5790
|
return;
|
|
5452
5791
|
}
|
|
5453
|
-
|
|
5792
|
+
Gt = !0;
|
|
5454
5793
|
try {
|
|
5455
|
-
for (const
|
|
5456
|
-
|
|
5457
|
-
for (const
|
|
5458
|
-
await l.addSystems(
|
|
5459
|
-
for (const { config:
|
|
5460
|
-
|
|
5461
|
-
|
|
5794
|
+
for (const f in T) delete T[f];
|
|
5795
|
+
p.clear(), g.resizeTextures(), Ft = ei(r, Le, jt, { sceneTexture: nt, bloomTexA: at, bloomTexB: ot }), await l.replaceSystems({ systems: [], activeSystemIndex: 0 });
|
|
5796
|
+
for (const f of u)
|
|
5797
|
+
await l.addSystems(f.preset, f.position || [0, 0, 0]);
|
|
5798
|
+
for (const { config: f } of l.particleSystems)
|
|
5799
|
+
T[f.id] || (T[f.id] = z());
|
|
5800
|
+
qt = !0, l.respawnAllSystems();
|
|
5462
5801
|
} finally {
|
|
5463
|
-
if (
|
|
5464
|
-
const
|
|
5465
|
-
|
|
5802
|
+
if (Gt = !1, Dt) {
|
|
5803
|
+
const f = Dt;
|
|
5804
|
+
Dt = null, $t(f);
|
|
5466
5805
|
}
|
|
5467
5806
|
}
|
|
5468
5807
|
}
|
|
5469
|
-
async function
|
|
5470
|
-
return
|
|
5471
|
-
}
|
|
5472
|
-
function
|
|
5473
|
-
if (
|
|
5474
|
-
const
|
|
5475
|
-
if (
|
|
5476
|
-
if ((a.width !==
|
|
5477
|
-
for (const
|
|
5478
|
-
if (
|
|
5479
|
-
const B =
|
|
5480
|
-
B ? (
|
|
5808
|
+
async function Bs(u, f = [0, 0, 0]) {
|
|
5809
|
+
return $t([{ preset: u, position: f }]);
|
|
5810
|
+
}
|
|
5811
|
+
function Rs(u) {
|
|
5812
|
+
if (xi || Gt || !l.ready || u <= 0 || l.particleSystems.length === 0) return;
|
|
5813
|
+
const f = l.clock;
|
|
5814
|
+
if (f && (f.loop = l.loop ?? i, f.duration = l.getTotalDuration(), u = f.tick(u)), u > 0.1 && (u = 0.1), u <= 0) return;
|
|
5815
|
+
if ((a.width !== Ht || a.height !== Zt) && (Ht = a.width, Zt = a.height, vi()), ke += u, Se.length) {
|
|
5816
|
+
for (const m of Se) {
|
|
5817
|
+
if (m.getPosition) {
|
|
5818
|
+
const B = m.getPosition();
|
|
5819
|
+
B ? (m.pos || (m.pos = m._posBuf), Array.isArray(B) ? (m.pos[0] = B[0], m.pos[1] = B[1], m.pos[2] = B[2]) : (m.pos[0] = B.x, m.pos[1] = B.y, m.pos[2] = B.z)) : m.pos = null;
|
|
5481
5820
|
}
|
|
5482
|
-
|
|
5821
|
+
m.vel = m._velBuf, m.pos && m.prevPos && m.wasActive && u > 0 ? (m.vel[0] = (m.pos[0] - m.prevPos[0]) / u, m.vel[1] = (m.pos[1] - m.prevPos[1]) / u, m.vel[2] = (m.pos[2] - m.prevPos[2]) / u) : (m.vel[0] = 0, m.vel[1] = 0, m.vel[2] = 0), m.justResumed = !!m.pos && !m.wasActive, m.justResumed && (m.hist.length = 0);
|
|
5483
5822
|
}
|
|
5484
|
-
for (const { system:
|
|
5485
|
-
const
|
|
5486
|
-
if (!(!
|
|
5487
|
-
let
|
|
5488
|
-
if (
|
|
5489
|
-
const
|
|
5490
|
-
Math.hypot(
|
|
5823
|
+
for (const { system: m, config: B } of l.particleSystems) {
|
|
5824
|
+
const C = ri(B.id);
|
|
5825
|
+
if (!(!C || C.historyOnly) && (B.hidden = !C.pos, C.pos)) {
|
|
5826
|
+
let H = null;
|
|
5827
|
+
if (C.orientToDirection && C.vel) {
|
|
5828
|
+
const V = C.vel[0], L = C.vel[2];
|
|
5829
|
+
Math.hypot(V, L) > 1e-4 && (H = [0, 0, Math.atan2(V, L)]);
|
|
5491
5830
|
}
|
|
5492
|
-
|
|
5831
|
+
m.setSimulationTransform({ position: C.pos, velocity: C.vel, rotation: H }), m.updateAppearanceUniform(), (C.justResumed || m.activeParticles === 0) && m.spawnParticles();
|
|
5493
5832
|
}
|
|
5494
5833
|
}
|
|
5495
|
-
for (const
|
|
5496
|
-
|
|
5497
|
-
if (globalThis.__HZFX_DEBUG && (
|
|
5498
|
-
const
|
|
5499
|
-
console.info(`[HZFX] movingGroups(${
|
|
5834
|
+
for (const m of Se)
|
|
5835
|
+
m.pos ? Qi(m, ke) : m.hist.length = 0, m.pos ? (m._prevPosBuf[0] = m.pos[0], m._prevPosBuf[1] = m.pos[1], m._prevPosBuf[2] = m.pos[2], m.prevPos = m._prevPosBuf) : m.prevPos = null, m.wasActive = !!m.pos;
|
|
5836
|
+
if (globalThis.__HZFX_DEBUG && (gs++ & 63) === 0) {
|
|
5837
|
+
const m = l.particleSystems.reduce((V, L) => V + (L.system.activeParticles | 0), 0), B = Se.find((V) => V.pos), C = B ? Math.hypot(G.position[0] - B.pos[0], G.position[1] - B.pos[1], G.position[2] - B.pos[2]).toFixed(1) : "-", H = Se.map((V) => `{ids:[${[...V.ids]}],pos:${V.pos ? "1" : "0"},hist:${V.hist.length}}`).join(",");
|
|
5838
|
+
console.info(`[HZFX] movingGroups(${Se.length})=[${H}] activeParticles=${m} systems=${l.particleSystems.length} ribbonVerts=${_t} camDist=${C} t=${ke.toFixed(1)}`);
|
|
5500
5839
|
}
|
|
5501
5840
|
}
|
|
5502
|
-
if (l.updateAllSystems(
|
|
5503
|
-
const
|
|
5504
|
-
(
|
|
5841
|
+
if (l.updateAllSystems(u), f ? f.loop : l.loop ?? i) {
|
|
5842
|
+
const m = l.particleSystems.length > 0 && l.particleSystems.every(({ system: B }) => B.activeParticles === 0 && !B.emitting);
|
|
5843
|
+
(f && f.justLooped || m && qt) && l.respawnAllSystems(), qt = !m;
|
|
5505
5844
|
}
|
|
5506
|
-
for (const { system:
|
|
5507
|
-
B.glbModelEnabled &&
|
|
5508
|
-
r.queue.writeBuffer(
|
|
5509
|
-
const
|
|
5510
|
-
|
|
5845
|
+
for (const { system: m, config: B } of l.particleSystems)
|
|
5846
|
+
B.glbModelEnabled && m.glbAnimator && (m.glbAnimator.update(u), m.updateAnimatedGLBBuffer());
|
|
5847
|
+
r.queue.writeBuffer(v, 0, G.mvp), ht[0] = G.position[0], ht[1] = G.position[1], ht[2] = G.position[2], ht[3] = a.height / Math.max(1, a.width), ht[4] = ke, r.queue.writeBuffer(v, 64, ht), as();
|
|
5848
|
+
const b = l.particleSystems.some(
|
|
5849
|
+
({ system: m, config: B }) => B.bloomEnabled && !B.hidden && (m.activeParticles > 0 || Ye.has(B.id))
|
|
5850
|
+
), y = r.createCommandEncoder();
|
|
5851
|
+
let R = !1;
|
|
5511
5852
|
if (e)
|
|
5512
5853
|
try {
|
|
5513
|
-
const
|
|
5514
|
-
if (
|
|
5515
|
-
let B = null,
|
|
5516
|
-
if (
|
|
5517
|
-
const { pipeline:
|
|
5518
|
-
(
|
|
5519
|
-
layout:
|
|
5520
|
-
entries: [{ binding: 0, resource:
|
|
5854
|
+
const m = e();
|
|
5855
|
+
if (m) {
|
|
5856
|
+
let B = null, C = null, H = !1;
|
|
5857
|
+
if (m instanceof GPUTexture ? m.width === a.width && m.height === a.height && (B = m, C = () => m.createView({ aspect: "depth-only" }), H = m.sampleCount > 1) : m.view && (B = m.view, C = () => m.view, H = !!m.multisampled), B) {
|
|
5858
|
+
const { pipeline: V, layout: L } = S(H);
|
|
5859
|
+
(mt.key !== B || mt.ms !== H) && (mt.key = B, mt.ms = H, mt.bindGroup = r.createBindGroup({
|
|
5860
|
+
layout: L,
|
|
5861
|
+
entries: [{ binding: 0, resource: C() }]
|
|
5521
5862
|
}));
|
|
5522
|
-
const
|
|
5863
|
+
const N = y.beginRenderPass({
|
|
5523
5864
|
colorAttachments: [],
|
|
5524
|
-
depthStencilAttachment: { view:
|
|
5865
|
+
depthStencilAttachment: { view: Mt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5525
5866
|
});
|
|
5526
|
-
|
|
5867
|
+
N.setPipeline(V), N.setBindGroup(0, mt.bindGroup), N.draw(3), N.end(), R = !0;
|
|
5527
5868
|
}
|
|
5528
5869
|
}
|
|
5529
5870
|
} catch {
|
|
5530
5871
|
}
|
|
5531
|
-
const
|
|
5532
|
-
colorAttachments: [{ view:
|
|
5533
|
-
depthStencilAttachment:
|
|
5872
|
+
const P = y.beginRenderPass({
|
|
5873
|
+
colorAttachments: [{ view: pt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5874
|
+
depthStencilAttachment: R ? { view: Mt, depthLoadOp: "load", depthStoreOp: "store" } : { view: Mt, depthClearValue: 1, depthLoadOp: "clear", depthStoreOp: "store" }
|
|
5534
5875
|
});
|
|
5535
|
-
for (const { system:
|
|
5536
|
-
B.bloomEnabled || B.hidden ||
|
|
5537
|
-
if (
|
|
5538
|
-
const
|
|
5539
|
-
colorAttachments: [{ view:
|
|
5876
|
+
for (const { system: m, config: B } of l.particleSystems)
|
|
5877
|
+
B.bloomEnabled || B.hidden || m.activeParticles === 0 && !Ye.has(B.id) || (_i(P, m, B), Mi(P, m, B));
|
|
5878
|
+
if (_t > 0 && (P.setPipeline(ps), P.setBindGroup(0, hs), P.setVertexBuffer(0, Nt), P.draw(_t)), P.end(), b) {
|
|
5879
|
+
const m = {
|
|
5880
|
+
colorAttachments: [{ view: yi, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5540
5881
|
}, B = {
|
|
5541
|
-
colorAttachments: [{ view:
|
|
5882
|
+
colorAttachments: [{ view: zt, loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5542
5883
|
};
|
|
5543
|
-
for (const { system:
|
|
5544
|
-
if (!
|
|
5545
|
-
const
|
|
5546
|
-
colorAttachments: [{ view:
|
|
5547
|
-
depthStencilAttachment: { view:
|
|
5884
|
+
for (const { system: C, config: H } of l.particleSystems) {
|
|
5885
|
+
if (!H.bloomEnabled || H.hidden || C.activeParticles === 0 && !Ye.has(H.id)) continue;
|
|
5886
|
+
const V = C.config.id, L = g.getBloomSourceTexture(V, a.width, a.height), N = y.beginRenderPass({
|
|
5887
|
+
colorAttachments: [{ view: L.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }],
|
|
5888
|
+
depthStencilAttachment: { view: Mt, depthClearValue: 1, depthLoadOp: "load", depthStoreOp: "store" }
|
|
5548
5889
|
});
|
|
5549
|
-
|
|
5550
|
-
layout:
|
|
5890
|
+
_i(N, C, H), Mi(N, C, H), N.end(), bi[0] = H.bloomIntensity, r.queue.writeBuffer(_, 0, bi), p.systemBloomHorizontalBindGroups[V] || (p.systemBloomHorizontalBindGroups[V] = r.createBindGroup({
|
|
5891
|
+
layout: je.bloomBindGroupLayout,
|
|
5551
5892
|
entries: [
|
|
5552
|
-
{ binding: 0, resource:
|
|
5553
|
-
{ binding: 1, resource:
|
|
5554
|
-
{ binding: 2, resource: { buffer:
|
|
5893
|
+
{ binding: 0, resource: Le },
|
|
5894
|
+
{ binding: 1, resource: L.createView() },
|
|
5895
|
+
{ binding: 2, resource: { buffer: U } }
|
|
5555
5896
|
]
|
|
5556
5897
|
}));
|
|
5557
|
-
let
|
|
5558
|
-
|
|
5559
|
-
layout:
|
|
5898
|
+
let D = y.beginRenderPass(m);
|
|
5899
|
+
D.setPipeline(Ut), D.setBindGroup(0, p.systemBloomHorizontalBindGroups[V]), D.draw(3), D.end(), D = y.beginRenderPass(B), D.setPipeline(Ut), D.setBindGroup(0, Ft.verticalBlurBindGroup), D.draw(3), D.end(), p.secondHorizontalBindGroups[V] || (p.secondHorizontalBindGroups[V] = r.createBindGroup({
|
|
5900
|
+
layout: je.bloomBindGroupLayout,
|
|
5560
5901
|
entries: [
|
|
5561
|
-
{ binding: 0, resource:
|
|
5562
|
-
{ binding: 1, resource:
|
|
5563
|
-
{ binding: 2, resource: { buffer:
|
|
5902
|
+
{ binding: 0, resource: Le },
|
|
5903
|
+
{ binding: 1, resource: zt },
|
|
5904
|
+
{ binding: 2, resource: { buffer: U } }
|
|
5564
5905
|
]
|
|
5565
|
-
})),
|
|
5566
|
-
const
|
|
5567
|
-
|
|
5568
|
-
colorAttachments: [{ view:
|
|
5569
|
-
}),
|
|
5570
|
-
layout:
|
|
5906
|
+
})), D = y.beginRenderPass(m), D.setPipeline(Ut), D.setBindGroup(0, p.secondHorizontalBindGroups[V]), D.draw(3), D.end(), D = y.beginRenderPass(B), D.setPipeline(Ut), D.setBindGroup(0, Ft.verticalBlurBindGroup), D.draw(3), D.end();
|
|
5907
|
+
const pe = g.getBloomCompositeTexture(V, a.width, a.height);
|
|
5908
|
+
D = y.beginRenderPass({
|
|
5909
|
+
colorAttachments: [{ view: pe.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5910
|
+
}), D.setPipeline(us), p.systemBloomCompositeBindGroups[V] || (p.systemBloomCompositeBindGroups[V] = r.createBindGroup({
|
|
5911
|
+
layout: je.compositeBindGroupLayout,
|
|
5571
5912
|
entries: [
|
|
5572
|
-
{ binding: 0, resource:
|
|
5573
|
-
{ binding: 1, resource:
|
|
5574
|
-
{ binding: 2, resource:
|
|
5575
|
-
{ binding: 3, resource: { buffer:
|
|
5913
|
+
{ binding: 0, resource: Le },
|
|
5914
|
+
{ binding: 1, resource: L.createView() },
|
|
5915
|
+
{ binding: 2, resource: zt },
|
|
5916
|
+
{ binding: 3, resource: { buffer: C.bloomIntensityBuffer } }
|
|
5576
5917
|
]
|
|
5577
|
-
})),
|
|
5918
|
+
})), D.setBindGroup(0, p.systemBloomCompositeBindGroups[V]), D.draw(3), D.end();
|
|
5578
5919
|
}
|
|
5579
5920
|
}
|
|
5580
|
-
const
|
|
5581
|
-
colorAttachments: [{ view:
|
|
5921
|
+
const M = g.getCombinedTexture(a.width, a.height), x = y.beginRenderPass({
|
|
5922
|
+
colorAttachments: [{ view: M.createView(), loadOp: "clear", storeOp: "store", clearValue: { r: 0, g: 0, b: 0, a: 0 } }]
|
|
5582
5923
|
});
|
|
5583
|
-
|
|
5584
|
-
layout:
|
|
5924
|
+
x.setPipeline(li), p.combinedInitialBindGroup || (p.combinedInitialBindGroup = r.createBindGroup({
|
|
5925
|
+
layout: je.compositeBindGroupLayout,
|
|
5585
5926
|
entries: [
|
|
5586
|
-
{ binding: 0, resource:
|
|
5587
|
-
{ binding: 1, resource:
|
|
5588
|
-
{ binding: 2, resource:
|
|
5589
|
-
{ binding: 3, resource: { buffer:
|
|
5927
|
+
{ binding: 0, resource: Le },
|
|
5928
|
+
{ binding: 1, resource: pt },
|
|
5929
|
+
{ binding: 2, resource: pt },
|
|
5930
|
+
{ binding: 3, resource: { buffer: _ } }
|
|
5590
5931
|
]
|
|
5591
|
-
})),
|
|
5592
|
-
for (const { config:
|
|
5593
|
-
if (!
|
|
5594
|
-
const
|
|
5595
|
-
|
|
5596
|
-
layout:
|
|
5932
|
+
})), x.setBindGroup(0, p.combinedInitialBindGroup), x.draw(3);
|
|
5933
|
+
for (const { config: m, system: B } of l.particleSystems) {
|
|
5934
|
+
if (!m.bloomEnabled || m.hidden || B.activeParticles === 0 && !Ye.has(m.id)) continue;
|
|
5935
|
+
const C = B.config.id;
|
|
5936
|
+
x.setPipeline(li), p.combinedBloomCompositeBindGroups[C] || (p.combinedBloomCompositeBindGroups[C] = r.createBindGroup({
|
|
5937
|
+
layout: je.compositeBindGroupLayout,
|
|
5597
5938
|
entries: [
|
|
5598
|
-
{ binding: 0, resource:
|
|
5599
|
-
{ binding: 1, resource:
|
|
5600
|
-
{ binding: 2, resource:
|
|
5601
|
-
{ binding: 3, resource: { buffer:
|
|
5939
|
+
{ binding: 0, resource: Le },
|
|
5940
|
+
{ binding: 1, resource: g.getBloomCompositeTexture(C, a.width, a.height).createView() },
|
|
5941
|
+
{ binding: 2, resource: pt },
|
|
5942
|
+
{ binding: 3, resource: { buffer: _ } }
|
|
5602
5943
|
]
|
|
5603
|
-
})),
|
|
5944
|
+
})), x.setBindGroup(0, p.combinedBloomCompositeBindGroups[C]), x.draw(3);
|
|
5604
5945
|
}
|
|
5605
|
-
|
|
5606
|
-
const
|
|
5946
|
+
x.end();
|
|
5947
|
+
const w = y.beginRenderPass({
|
|
5607
5948
|
colorAttachments: [{
|
|
5608
5949
|
view: n.getCurrentTexture().createView(),
|
|
5609
5950
|
loadOp: o ? "load" : "clear",
|
|
@@ -5611,104 +5952,112 @@ async function vr(s, t = {}) {
|
|
|
5611
5952
|
clearValue: { r: 0, g: 0, b: 0, a: 0 }
|
|
5612
5953
|
}]
|
|
5613
5954
|
});
|
|
5614
|
-
|
|
5615
|
-
layout:
|
|
5955
|
+
w.setPipeline(ds), p.finalBindGroup || (p.finalBindGroup = r.createBindGroup({
|
|
5956
|
+
layout: je.compositeBindGroupLayout,
|
|
5616
5957
|
entries: [
|
|
5617
|
-
{ binding: 0, resource:
|
|
5618
|
-
{ binding: 1, resource:
|
|
5619
|
-
{ binding: 2, resource:
|
|
5620
|
-
{ binding: 3, resource: { buffer:
|
|
5958
|
+
{ binding: 0, resource: Le },
|
|
5959
|
+
{ binding: 1, resource: M.createView() },
|
|
5960
|
+
{ binding: 2, resource: pt },
|
|
5961
|
+
{ binding: 3, resource: { buffer: _ } }
|
|
5621
5962
|
]
|
|
5622
|
-
})),
|
|
5963
|
+
})), w.setBindGroup(0, p.finalBindGroup), w.draw(3), w.end(), r.queue.submit([y.finish()]);
|
|
5623
5964
|
}
|
|
5624
|
-
function
|
|
5625
|
-
const
|
|
5626
|
-
|
|
5627
|
-
layout:
|
|
5965
|
+
function Pi(u, f) {
|
|
5966
|
+
const h = u.config.id, b = !p.systemBindGroups[h] || p.textureStates[h] !== f.textureEnabled || p.textureRefs[h] !== u.particleTexture;
|
|
5967
|
+
return p.textureStates[h] = f.textureEnabled, p.textureRefs[h] = u.particleTexture, b && (p.systemBindGroups[h] = r.createBindGroup({
|
|
5968
|
+
layout: je.particleBindGroupLayout,
|
|
5628
5969
|
entries: [
|
|
5629
|
-
{ binding: 0, resource: { buffer:
|
|
5630
|
-
{ binding: 1, resource: { buffer:
|
|
5631
|
-
{ binding: 2, resource:
|
|
5632
|
-
{ binding: 3, resource:
|
|
5970
|
+
{ binding: 0, resource: { buffer: v } },
|
|
5971
|
+
{ binding: 1, resource: { buffer: u.appearanceUniformBuffer } },
|
|
5972
|
+
{ binding: 2, resource: u.particleTexture.createView() },
|
|
5973
|
+
{ binding: 3, resource: Le }
|
|
5633
5974
|
]
|
|
5634
|
-
}));
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5975
|
+
})), p.systemBindGroups[h];
|
|
5976
|
+
}
|
|
5977
|
+
function _i(u, f, h) {
|
|
5978
|
+
const b = f.config.id, y = h.glbModelEnabled && f.glbMeshData, R = Pi(f, h), P = h.shapeDisplay !== !1;
|
|
5979
|
+
if (y)
|
|
5980
|
+
P && (u.setPipeline(fs), u.setBindGroup(0, R), u.setVertexBuffer(0, f.glbVertexBuffer), u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setIndexBuffer(f.glbIndexBuffer, f.glbIndexFormat), u.drawIndexed(f.glbIndexCount, f.activeParticles));
|
|
5638
5981
|
else {
|
|
5639
|
-
|
|
5640
|
-
const
|
|
5641
|
-
|
|
5982
|
+
u.setPipeline(h.blendMode === "additive" ? ls : os), u.setIndexBuffer($, "uint16"), T[b] || (T[b] = z()), u.setVertexBuffer(0, T[b]), u.setBindGroup(0, R), P && (u.setVertexBuffer(1, f.instanceBuffer), u.setVertexBuffer(2, f.velocityBuffer), u.setVertexBuffer(3, f.trailBuffer), u.drawIndexed(6, f.activeParticles));
|
|
5983
|
+
const M = Pt.get(b);
|
|
5984
|
+
M && (u.setVertexBuffer(1, K), u.setVertexBuffer(2, q), u.setVertexBuffer(3, Ke), u.drawIndexed(6, M.count, 0, 0, M.first)), P && h.depthWriteEnabled && (u.setPipeline(cs), u.drawIndexed(6, f.activeParticles));
|
|
5642
5985
|
}
|
|
5643
5986
|
}
|
|
5644
|
-
function
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
|
|
5665
|
-
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
}
|
|
5669
|
-
function
|
|
5670
|
-
|
|
5671
|
-
|
|
5672
|
-
|
|
5987
|
+
function Mi(u, f, h) {
|
|
5988
|
+
const b = Ye.get(h.id);
|
|
5989
|
+
!b || b.count <= 0 || (u.setPipeline(h.blendMode === "additive" ? ys : ms), u.setBindGroup(0, Pi(f, h)), u.setVertexBuffer(0, Yt), u.draw(b.count, 1, b.first, 0));
|
|
5990
|
+
}
|
|
5991
|
+
function Ts() {
|
|
5992
|
+
Ht = a.width, Zt = a.height, vi();
|
|
5993
|
+
}
|
|
5994
|
+
function Es() {
|
|
5995
|
+
p.clear();
|
|
5996
|
+
}
|
|
5997
|
+
function As() {
|
|
5998
|
+
xi = !0, l.destroy(), [nt, at, ot, It].forEach((u) => u == null ? void 0 : u.destroy()), g.resizeTextures(), [
|
|
5999
|
+
v,
|
|
6000
|
+
A,
|
|
6001
|
+
U,
|
|
6002
|
+
I,
|
|
6003
|
+
_,
|
|
6004
|
+
$,
|
|
6005
|
+
K,
|
|
6006
|
+
q,
|
|
6007
|
+
Ke,
|
|
6008
|
+
Nt,
|
|
6009
|
+
Yt
|
|
6010
|
+
].forEach((u) => u == null ? void 0 : u.destroy()), Object.values(T).forEach((u) => u == null ? void 0 : u.destroy());
|
|
6011
|
+
}
|
|
6012
|
+
async function wi(u, f) {
|
|
6013
|
+
const h = await l.addSystems(u, f);
|
|
6014
|
+
for (const { config: b } of l.particleSystems)
|
|
6015
|
+
T[b.id] || (T[b.id] = z());
|
|
6016
|
+
return l.respawnAllSystems(), new Set(Array.isArray(h) ? h : []);
|
|
6017
|
+
}
|
|
6018
|
+
function Bi(u) {
|
|
6019
|
+
for (const f of u) {
|
|
6020
|
+
const h = l.particleSystems.findIndex((b) => b.config.id === f);
|
|
6021
|
+
h >= 0 && l.removeSystem(h);
|
|
5673
6022
|
}
|
|
5674
6023
|
}
|
|
5675
|
-
async function
|
|
5676
|
-
const
|
|
6024
|
+
async function Cs(u, f = [0, 0, 0]) {
|
|
6025
|
+
const h = await wi(u, f);
|
|
5677
6026
|
return { remove() {
|
|
5678
|
-
|
|
6027
|
+
Bi(h);
|
|
5679
6028
|
} };
|
|
5680
6029
|
}
|
|
5681
|
-
async function
|
|
5682
|
-
const
|
|
5683
|
-
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(
|
|
5684
|
-
const
|
|
5685
|
-
return
|
|
5686
|
-
setPosition(
|
|
5687
|
-
|
|
6030
|
+
async function Us(u, f = {}) {
|
|
6031
|
+
const h = await wi(u, [0, 0, 0]);
|
|
6032
|
+
globalThis.__HZFX_DEBUG && console.info(`[HZFX] addMovingEmitter: presetSystems=${(u && u.systems || []).length} newIds=[${[...h]}]`);
|
|
6033
|
+
const b = { ids: h, pos: null, hist: [], getPosition: f.getPosition || null, orientToDirection: !!f.orientToDirection, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
6034
|
+
return Se.push(b), {
|
|
6035
|
+
setPosition(y) {
|
|
6036
|
+
y && (b.pos = Array.isArray(y) ? [y[0], y[1], y[2]] : [y.x, y.y, y.z]);
|
|
5688
6037
|
},
|
|
5689
|
-
setOrientToDirection(
|
|
5690
|
-
|
|
6038
|
+
setOrientToDirection(y) {
|
|
6039
|
+
b.orientToDirection = !!y;
|
|
5691
6040
|
},
|
|
5692
6041
|
remove() {
|
|
5693
|
-
|
|
5694
|
-
const
|
|
5695
|
-
|
|
6042
|
+
Bi(h);
|
|
6043
|
+
const y = Se.indexOf(b);
|
|
6044
|
+
y >= 0 && Se.splice(y, 1);
|
|
5696
6045
|
}
|
|
5697
6046
|
};
|
|
5698
6047
|
}
|
|
5699
|
-
function
|
|
5700
|
-
const
|
|
5701
|
-
return
|
|
6048
|
+
function Is(u, f) {
|
|
6049
|
+
const b = { ids: u instanceof Set ? u : new Set(u), pos: null, hist: [], getPosition: f, historyOnly: !0, _posBuf: [0, 0, 0], _velBuf: [0, 0, 0], _prevPosBuf: [0, 0, 0] };
|
|
6050
|
+
return Se.push(b), {
|
|
5702
6051
|
remove() {
|
|
5703
|
-
const
|
|
5704
|
-
|
|
6052
|
+
const y = Se.indexOf(b);
|
|
6053
|
+
y >= 0 && Se.splice(y, 1);
|
|
5705
6054
|
},
|
|
5706
6055
|
// Update which systems this history group covers WITHOUT losing the accumulated path
|
|
5707
6056
|
// history. Needed when the scene's systems change (e.g. duplicate/add/remove) while the
|
|
5708
6057
|
// group is active — otherwise a newly-added system's id isn't in the set and its trail
|
|
5709
6058
|
// can't follow the recorded movement path (it falls back to straight extrapolation).
|
|
5710
|
-
setIds(
|
|
5711
|
-
|
|
6059
|
+
setIds(y) {
|
|
6060
|
+
b.ids = y instanceof Set ? y : new Set(y);
|
|
5712
6061
|
}
|
|
5713
6062
|
};
|
|
5714
6063
|
}
|
|
@@ -5716,85 +6065,85 @@ async function vr(s, t = {}) {
|
|
|
5716
6065
|
manager: l,
|
|
5717
6066
|
device: r,
|
|
5718
6067
|
context: n,
|
|
5719
|
-
setCamera:
|
|
5720
|
-
setCameraMVP:
|
|
5721
|
-
setEmitters:
|
|
5722
|
-
loadPreset:
|
|
5723
|
-
addEmitter:
|
|
5724
|
-
addMovingEmitter:
|
|
5725
|
-
render:
|
|
5726
|
-
resize:
|
|
5727
|
-
clearCaches:
|
|
5728
|
-
trackHistoryGroup:
|
|
5729
|
-
destroy:
|
|
6068
|
+
setCamera: Ms,
|
|
6069
|
+
setCameraMVP: ws,
|
|
6070
|
+
setEmitters: $t,
|
|
6071
|
+
loadPreset: Bs,
|
|
6072
|
+
addEmitter: Cs,
|
|
6073
|
+
addMovingEmitter: Us,
|
|
6074
|
+
render: Rs,
|
|
6075
|
+
resize: Ts,
|
|
6076
|
+
clearCaches: Es,
|
|
6077
|
+
trackHistoryGroup: Is,
|
|
6078
|
+
destroy: As
|
|
5730
6079
|
};
|
|
5731
6080
|
}
|
|
5732
|
-
function
|
|
6081
|
+
function Hr(s) {
|
|
5733
6082
|
return () => {
|
|
5734
6083
|
var t, e, i, r, n, a, o, c;
|
|
5735
6084
|
try {
|
|
5736
6085
|
const l = s.backend;
|
|
5737
6086
|
if (!l) return null;
|
|
5738
|
-
const
|
|
5739
|
-
if (s.needsFrameBufferTarget &&
|
|
5740
|
-
const
|
|
5741
|
-
(r =
|
|
5742
|
-
|
|
5743
|
-
(n =
|
|
5744
|
-
|
|
6087
|
+
const d = s.domElement.width, S = s.domElement.height, g = (typeof s._getFrameBufferTarget == "function" ? s._getFrameBufferTarget() : null) || s._frameBufferTarget || null;
|
|
6088
|
+
if (s.needsFrameBufferTarget && g) {
|
|
6089
|
+
const A = l.get(g), U = ((i = (e = (t = s._textures) == null ? void 0 : t.get) == null ? void 0 : e.call(t, g)) == null ? void 0 : i.depthTexture) || g.depthTexture, I = [
|
|
6090
|
+
(r = A == null ? void 0 : A.depthTexture) == null ? void 0 : r.texture,
|
|
6091
|
+
A == null ? void 0 : A.depthTexture,
|
|
6092
|
+
(n = A == null ? void 0 : A.depthBuffer) == null ? void 0 : n.texture,
|
|
6093
|
+
U ? (a = l.get(U)) == null ? void 0 : a.texture : null
|
|
5745
6094
|
];
|
|
5746
|
-
for (const
|
|
5747
|
-
if (
|
|
6095
|
+
for (const _ of I)
|
|
6096
|
+
if (_ && typeof _.createView == "function" && _.width === d && _.height === S) return _;
|
|
5748
6097
|
return null;
|
|
5749
6098
|
}
|
|
5750
|
-
const
|
|
5751
|
-
return
|
|
6099
|
+
const p = s.getCanvasTarget ? l.get(s.getCanvasTarget()) : null, v = ((c = (o = p == null ? void 0 : p.descriptor) == null ? void 0 : o.depthStencilAttachment) == null ? void 0 : c.view) ?? null;
|
|
6100
|
+
return v ? { view: v, multisampled: (s.currentSamples ?? 0) > 1 } : null;
|
|
5752
6101
|
} catch {
|
|
5753
6102
|
return null;
|
|
5754
6103
|
}
|
|
5755
6104
|
};
|
|
5756
6105
|
}
|
|
5757
6106
|
export {
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
6107
|
+
mr as GLBAnimator,
|
|
6108
|
+
yr as HZClock,
|
|
6109
|
+
Vr as Objects3DManager,
|
|
6110
|
+
ks as ParticleEmitter,
|
|
6111
|
+
$s as ParticlePhysics,
|
|
6112
|
+
Ii as ParticleScript,
|
|
6113
|
+
Qt as ParticleSystem,
|
|
6114
|
+
Pr as ParticleSystemManager,
|
|
6115
|
+
Ws as ParticleTextureManager,
|
|
6116
|
+
Ns as blurShader,
|
|
6117
|
+
Ys as compositeShader,
|
|
6118
|
+
Br as createBindGroupLayouts,
|
|
6119
|
+
ei as createBindGroups,
|
|
6120
|
+
vt as createBuffer,
|
|
6121
|
+
Er as createCubeGeometry,
|
|
6122
|
+
Li as createDepthTexture,
|
|
6123
|
+
kr as createLookAtMatrix,
|
|
6124
|
+
Xr as createProjectionMatrix,
|
|
6125
|
+
Rr as createRenderPipelines,
|
|
6126
|
+
Oi as createRenderTextures,
|
|
6127
|
+
Tr as createSampler,
|
|
6128
|
+
Ar as createSphereGeometry,
|
|
6129
|
+
js as directRenderShader,
|
|
6130
|
+
Fi as extractGLBTexture,
|
|
6131
|
+
jr as fetchPreset,
|
|
6132
|
+
wr as glbMeshParticleShader,
|
|
6133
|
+
Or as hexToRgb,
|
|
6134
|
+
qr as initHzFxOverlay,
|
|
6135
|
+
_r as initWebGPU,
|
|
6136
|
+
Ji as isHZFX,
|
|
6137
|
+
Yr as loadScene,
|
|
6138
|
+
Hr as makeThreeSceneDepth,
|
|
6139
|
+
Ur as multiplyMatrices,
|
|
6140
|
+
Mr as object3dShader,
|
|
6141
|
+
zr as packHZFX,
|
|
6142
|
+
ir as parseGLB,
|
|
6143
|
+
Hs as particlePhysicsShader,
|
|
6144
|
+
Xs as particleShader,
|
|
6145
|
+
Lr as rgbToHex,
|
|
6146
|
+
Nr as saveScene,
|
|
6147
|
+
Gr as serializeSystemConfig,
|
|
6148
|
+
Ki as unpackHZFX
|
|
5800
6149
|
};
|