@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.
- package/dist/index.global.js +30 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +26 -2
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -970,6 +970,9 @@ function specFromObject3D(THREE, root, options = {}) {
|
|
|
970
970
|
return { spec, parts: meshesOf };
|
|
971
971
|
}
|
|
972
972
|
|
|
973
|
+
// src/renderer.ts
|
|
974
|
+
import { kitOriginOf } from "@adatechnology/game-contracts";
|
|
975
|
+
|
|
973
976
|
// src/heat.ts
|
|
974
977
|
var STOPS = [
|
|
975
978
|
[450, 0],
|
|
@@ -1940,6 +1943,7 @@ var Visuals = class {
|
|
|
1940
1943
|
|
|
1941
1944
|
// src/renderer.ts
|
|
1942
1945
|
var rendererCount = 0;
|
|
1946
|
+
var COLLAPSE_CLOUD_KG = 1e3;
|
|
1943
1947
|
var IMPACT_TAGS = ["metal", "glass", "wood"];
|
|
1944
1948
|
var GLOW_FROM_C = 430;
|
|
1945
1949
|
var QUEUE_CAP = 4e3;
|
|
@@ -2403,10 +2407,14 @@ var Renderer = class {
|
|
|
2403
2407
|
case "settle":
|
|
2404
2408
|
this.onSettle(ev.object);
|
|
2405
2409
|
break;
|
|
2406
|
-
case "collapse":
|
|
2410
|
+
case "collapse": {
|
|
2411
|
+
const root = this.bounds.get(ev.object)?.root;
|
|
2412
|
+
const furniture = !!root && kitOriginOf(root)?.kind === "furniture";
|
|
2407
2413
|
this.splitLoose(ev.object);
|
|
2408
|
-
this.playEvent({ kind: "collapse" }, this.rootPoint(ev.object));
|
|
2414
|
+
if (!furniture || ev.mass >= COLLAPSE_CLOUD_KG) this.playEvent({ kind: "collapse" }, this.rootPoint(ev.object));
|
|
2415
|
+
else this.vfx.burst("dust", this.rootPoint(ev.object), [0, 1, 0], clamp(Math.round(ev.mass / 4), 4, 24), 0.8);
|
|
2409
2416
|
break;
|
|
2417
|
+
}
|
|
2410
2418
|
case "disassemble_progress": {
|
|
2411
2419
|
const k = `unscrew:${ev.joint}`;
|
|
2412
2420
|
if (this.time - (this.throttles.get(k) ?? -1) > 0.25) {
|
|
@@ -2436,6 +2444,9 @@ var Renderer = class {
|
|
|
2436
2444
|
case "stage":
|
|
2437
2445
|
this.onStage(ev);
|
|
2438
2446
|
break;
|
|
2447
|
+
case "chip":
|
|
2448
|
+
this.onChip(ev);
|
|
2449
|
+
break;
|
|
2439
2450
|
case "expose":
|
|
2440
2451
|
this.cages.set(`${ev.object}|${ev.part}`, ev.bars);
|
|
2441
2452
|
if (ev.bars.length > 0) {
|
|
@@ -2692,6 +2703,19 @@ var Renderer = class {
|
|
|
2692
2703
|
if (!played) this.vfx.burst("dust", ev.opening.center, [0, 1, 0], 14, 1.2, { color });
|
|
2693
2704
|
this.sound(impactKey(def), ev.opening.center, 0.8);
|
|
2694
2705
|
}
|
|
2706
|
+
/**
|
|
2707
|
+
* 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
|
|
2708
|
+
* the wall as its courses without that unit); a part drawn as one box keeps its box.
|
|
2709
|
+
*/
|
|
2710
|
+
onChip(ev) {
|
|
2711
|
+
const pv = this.partVis(ev.object, ev.part);
|
|
2712
|
+
const def = pv ? this.world.materials.get(pv.material) : void 0;
|
|
2713
|
+
const color = (pv ? this.partColor(pv, def) : null) ?? fallbackColor(pv?.material ?? "", def);
|
|
2714
|
+
const maxAlive = this.low ? Math.floor(this.maxFragments / 2) : this.maxFragments;
|
|
2715
|
+
for (const fr of ev.fragments) this.fragments.spawn(fr, this.fragments.materialFor(fr.material, fallbackColor(fr.material, def), false), ev.object, maxAlive);
|
|
2716
|
+
if (!this.playEvent({ kind: "spall", material: this.impactMaterial(def) }, ev.center)) this.vfx.burst("dust", ev.center, [0, 1, 0], 6, 0.8, { color });
|
|
2717
|
+
this.sound(impactKey(def), ev.center, 0.7);
|
|
2718
|
+
}
|
|
2695
2719
|
onFracture(ev) {
|
|
2696
2720
|
const b = this.bounds.get(ev.object);
|
|
2697
2721
|
const pv = b?.parts.get(ev.part);
|