@adatechnology/game-destruction-three 0.2.1 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.global.js +20 -7
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +20 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -414,6 +414,8 @@ var Pool = class {
|
|
|
414
414
|
__publicField(this, "alphaMul");
|
|
415
415
|
__publicField(this, "tag");
|
|
416
416
|
__publicField(this, "colorHex");
|
|
417
|
+
__publicField(this, "rgbStart");
|
|
418
|
+
__publicField(this, "rgbEnd");
|
|
417
419
|
__publicField(this, "bounced");
|
|
418
420
|
const n = Math.max(1, capacity);
|
|
419
421
|
this.pos = new Float32Array(n * 3);
|
|
@@ -430,6 +432,8 @@ var Pool = class {
|
|
|
430
432
|
this.alphaMul = new Float32Array(n);
|
|
431
433
|
this.tag = new Int32Array(n);
|
|
432
434
|
this.colorHex = new Int32Array(n);
|
|
435
|
+
this.rgbStart = new Float32Array(n * 3);
|
|
436
|
+
this.rgbEnd = new Float32Array(n * 3);
|
|
433
437
|
this.bounced = new Uint8Array(n);
|
|
434
438
|
this.geometry = new THREE.BufferGeometry();
|
|
435
439
|
const attr = (a, size) => {
|
|
@@ -477,6 +481,8 @@ var Pool = class {
|
|
|
477
481
|
this.alphaMul[i] = o?.alpha ?? 1;
|
|
478
482
|
this.tag[i] = o?.tag ?? 0;
|
|
479
483
|
this.colorHex[i] = o?.color ?? -1;
|
|
484
|
+
this.rgbStart.set(hexToRgb(o?.color ?? def.c0), i * 3);
|
|
485
|
+
this.rgbEnd.set(hexToRgb(o?.color ?? def.c1), i * 3);
|
|
480
486
|
this.bounced[i] = 0;
|
|
481
487
|
this.siz[i] = this.size0[i];
|
|
482
488
|
this.alp[i] = 0;
|
|
@@ -570,13 +576,9 @@ var Pool = class {
|
|
|
570
576
|
this.pos[i3 + 1] = y;
|
|
571
577
|
this.pos[i3 + 2] = z;
|
|
572
578
|
this.siz[i] = this.size0[i] * lerp(1, def.grow, t);
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
const b = hexToRgb(c1);
|
|
577
|
-
this.col[i3] = lerp(a[0], b[0], t);
|
|
578
|
-
this.col[i3 + 1] = lerp(a[1], b[1], t);
|
|
579
|
-
this.col[i3 + 2] = lerp(a[2], b[2], t);
|
|
579
|
+
this.col[i3] = lerp(this.rgbStart[i3], this.rgbEnd[i3], t);
|
|
580
|
+
this.col[i3 + 1] = lerp(this.rgbStart[i3 + 1], this.rgbEnd[i3 + 1], t);
|
|
581
|
+
this.col[i3 + 2] = lerp(this.rgbStart[i3 + 2], this.rgbEnd[i3 + 2], t);
|
|
580
582
|
let env = t < def.fadeIn ? t / def.fadeIn : 1 - (t - def.fadeIn) / (1 - def.fadeIn);
|
|
581
583
|
if (def.flicker) env *= 1 - def.flicker * (0.5 + 0.5 * Math.sin(age * 38 + this.seed[i] * 50));
|
|
582
584
|
this.alp[i] = clamp(env, 0, 1) * def.alpha * this.alphaMul[i];
|
|
@@ -2399,6 +2401,14 @@ var Renderer = class {
|
|
|
2399
2401
|
this.sound("ignite", ev.point, 0.7);
|
|
2400
2402
|
this.sound("burn_loop", ev.point, 0.5);
|
|
2401
2403
|
break;
|
|
2404
|
+
case "primed":
|
|
2405
|
+
if (ev.trigger !== "explosion") {
|
|
2406
|
+
this.fires.set(`${ev.object}|${ev.part}`, { object: ev.object, part: ev.part, point: ev.point, accFire: 0, accSmoke: 0 });
|
|
2407
|
+
this.activate(ev.object, ev.part);
|
|
2408
|
+
this.particles.burst("fire", ev.point, [0, 1, 0], 6, 1);
|
|
2409
|
+
this.sound("ignite", ev.point, 0.7);
|
|
2410
|
+
}
|
|
2411
|
+
break;
|
|
2402
2412
|
case "extinguish": {
|
|
2403
2413
|
const f = this.fires.get(`${ev.object}|${ev.part}`);
|
|
2404
2414
|
if (f) {
|
|
@@ -2860,6 +2870,9 @@ var Renderer = class {
|
|
|
2860
2870
|
emit(kind, point, normal, count, speed) {
|
|
2861
2871
|
this.particles.burst(kind, point, normal, count, speed ?? DEFAULT_SPEED[kind] ?? 1, kind === "smoke" ? { color: SMOKE_TONES.grey } : void 0);
|
|
2862
2872
|
}
|
|
2873
|
+
explode(point, energy, radius) {
|
|
2874
|
+
this.onExplode({ type: "explode", object: "", part: "", time: this.time, point, energy, radius });
|
|
2875
|
+
}
|
|
2863
2876
|
restore(objectId) {
|
|
2864
2877
|
const homes = /* @__PURE__ */ new Set([objectId]);
|
|
2865
2878
|
const self = this.bounds.get(objectId);
|