@adatechnology/game-destruction-three 0.9.0 → 0.10.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.
@@ -59,6 +59,13 @@ var GameDestructionThree = (() => {
59
59
  node.userData[KIT_ORIGIN_KEY] = { ...origin };
60
60
  return object;
61
61
  }
62
+ function kitOriginOf(object) {
63
+ for (let node = object; node; node = node.parent) {
64
+ const origin = node.userData?.[KIT_ORIGIN_KEY];
65
+ if (origin && typeof origin.owner === "string") return origin;
66
+ }
67
+ return null;
68
+ }
62
69
 
63
70
  // ../game-vfx/dist/index.js
64
71
  var __defProp2 = Object.defineProperty;
@@ -11665,6 +11672,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
11665
11672
 
11666
11673
  // src/renderer.ts
11667
11674
  var rendererCount = 0;
11675
+ var COLLAPSE_CLOUD_KG = 1e3;
11668
11676
  var IMPACT_TAGS = ["metal", "glass", "wood"];
11669
11677
  var GLOW_FROM_C = 430;
11670
11678
  var QUEUE_CAP = 4e3;
@@ -12128,10 +12136,14 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
12128
12136
  case "settle":
12129
12137
  this.onSettle(ev.object);
12130
12138
  break;
12131
- case "collapse":
12139
+ case "collapse": {
12140
+ const root = this.bounds.get(ev.object)?.root;
12141
+ const furniture = !!root && kitOriginOf(root)?.kind === "furniture";
12132
12142
  this.splitLoose(ev.object);
12133
- this.playEvent({ kind: "collapse" }, this.rootPoint(ev.object));
12143
+ if (!furniture || ev.mass >= COLLAPSE_CLOUD_KG) this.playEvent({ kind: "collapse" }, this.rootPoint(ev.object));
12144
+ else this.vfx.burst("dust", this.rootPoint(ev.object), [0, 1, 0], clamp6(Math.round(ev.mass / 4), 4, 24), 0.8);
12134
12145
  break;
12146
+ }
12135
12147
  case "disassemble_progress": {
12136
12148
  const k = `unscrew:${ev.joint}`;
12137
12149
  if (this.time - (this.throttles.get(k) ?? -1) > 0.25) {
@@ -12161,6 +12173,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
12161
12173
  case "stage":
12162
12174
  this.onStage(ev);
12163
12175
  break;
12176
+ case "chip":
12177
+ this.onChip(ev);
12178
+ break;
12164
12179
  case "expose":
12165
12180
  this.cages.set(`${ev.object}|${ev.part}`, ev.bars);
12166
12181
  if (ev.bars.length > 0) {
@@ -12417,6 +12432,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
12417
12432
  if (!played) this.vfx.burst("dust", ev.opening.center, [0, 1, 0], 14, 1.2, { color });
12418
12433
  this.sound(impactKey(def), ev.opening.center, 0.8);
12419
12434
  }
12435
+ /**
12436
+ * A unit came out of a wall of units: the unit flies as a fragment with a puff of its dust. The gap itself is the drawing's (the house renderer redraws
12437
+ * the wall as its courses without that unit); a part drawn as one box keeps its box.
12438
+ */
12439
+ onChip(ev) {
12440
+ const pv = this.partVis(ev.object, ev.part);
12441
+ const def = pv ? this.world.materials.get(pv.material) : void 0;
12442
+ const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(pv?.material ?? "", def);
12443
+ const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments;
12444
+ for (const fr of ev.fragments) this.fragments.spawn(fr, this.fragments.materialFor(fr.material, fallbackColor(fr.material, def), false), ev.object, maxAlive);
12445
+ if (!this.playEvent({ kind: "spall", material: this.impactMaterial(def) }, ev.center)) this.vfx.burst("dust", ev.center, [0, 1, 0], 6, 0.8, { color });
12446
+ this.sound(impactKey(def), ev.center, 0.7);
12447
+ }
12420
12448
  onFracture(ev) {
12421
12449
  const b = this.bounds.get(ev.object);
12422
12450
  const pv = b?.parts.get(ev.part);