@adatechnology/game-destruction-three 0.2.0 → 0.3.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/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
- const c0 = this.colorHex[i] >= 0 ? this.colorHex[i] : def.c0;
574
- const c1 = this.colorHex[i] >= 0 ? this.colorHex[i] : def.c1;
575
- const a = hexToRgb(c0);
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];
@@ -2860,6 +2862,9 @@ var Renderer = class {
2860
2862
  emit(kind, point, normal, count, speed) {
2861
2863
  this.particles.burst(kind, point, normal, count, speed ?? DEFAULT_SPEED[kind] ?? 1, kind === "smoke" ? { color: SMOKE_TONES.grey } : void 0);
2862
2864
  }
2865
+ explode(point, energy, radius) {
2866
+ this.onExplode({ type: "explode", object: "", part: "", time: this.time, point, energy, radius });
2867
+ }
2863
2868
  restore(objectId) {
2864
2869
  const homes = /* @__PURE__ */ new Set([objectId]);
2865
2870
  const self = this.bounds.get(objectId);