@adatechnology/game-destruction-three 0.8.2 → 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 +51 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +44 -5
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.global.js
CHANGED
|
@@ -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;
|
|
@@ -8620,6 +8627,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8620
8627
|
}
|
|
8621
8628
|
|
|
8622
8629
|
// src/fragments.ts
|
|
8630
|
+
var SHEET_MAX = 4e-3;
|
|
8631
|
+
var SHEET_AIR = 2.5;
|
|
8632
|
+
var SHEET_SWAY = 3;
|
|
8623
8633
|
var FragmentSystem = class {
|
|
8624
8634
|
constructor(THREE, o) {
|
|
8625
8635
|
__publicField(this, "THREE", THREE);
|
|
@@ -8725,7 +8735,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8725
8735
|
asleep: false,
|
|
8726
8736
|
rest: 0,
|
|
8727
8737
|
fade: 1,
|
|
8728
|
-
dying: false
|
|
8738
|
+
dying: false,
|
|
8739
|
+
air: f.shape === "scrap" && sz[2] <= SHEET_MAX ? SHEET_AIR : 0
|
|
8729
8740
|
};
|
|
8730
8741
|
this.list.push(live);
|
|
8731
8742
|
let alive = this.list.reduce((n, l) => n + (l.dying ? 0 : 1), 0);
|
|
@@ -8809,6 +8820,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8809
8820
|
}
|
|
8810
8821
|
} else {
|
|
8811
8822
|
f.ang.multiplyScalar(Math.exp(-0.15 * dt));
|
|
8823
|
+
if (f.air > 0) this.flutter(f, dt);
|
|
8812
8824
|
}
|
|
8813
8825
|
if (contact && f.vel.lengthSq() < 4) this.settle(f, dt);
|
|
8814
8826
|
const slow = f.vel.lengthSq() < 0.012 && f.ang.lengthSq() < 0.2;
|
|
@@ -8823,6 +8835,14 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
8823
8835
|
f.still = 0;
|
|
8824
8836
|
}
|
|
8825
8837
|
}
|
|
8838
|
+
/** A sheet in the air: drag slows it to a slow fall, and it sways and turns over as it goes. */
|
|
8839
|
+
flutter(f, dt) {
|
|
8840
|
+
f.vel.multiplyScalar(Math.exp(-f.air * dt));
|
|
8841
|
+
f.vel.x += (this.rng() - 0.5) * SHEET_SWAY * dt;
|
|
8842
|
+
f.vel.z += (this.rng() - 0.5) * SHEET_SWAY * dt;
|
|
8843
|
+
f.ang.x += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt;
|
|
8844
|
+
f.ang.z += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt;
|
|
8845
|
+
}
|
|
8826
8846
|
/** Tip the fragment towards lying on its flattest face. */
|
|
8827
8847
|
settle(f, dt) {
|
|
8828
8848
|
const mesh2 = f.mesh;
|
|
@@ -10147,6 +10167,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
10147
10167
|
0.03,
|
|
10148
10168
|
0.15
|
|
10149
10169
|
],
|
|
10170
|
+
sheet: 1e-3,
|
|
10150
10171
|
damageScale: {
|
|
10151
10172
|
slash: 3
|
|
10152
10173
|
},
|
|
@@ -10162,7 +10183,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
10162
10183
|
smoke: "grey"
|
|
10163
10184
|
},
|
|
10164
10185
|
visual: {
|
|
10165
|
-
charColor: 1709072
|
|
10186
|
+
charColor: 1709072,
|
|
10187
|
+
innerColor: 15524048
|
|
10166
10188
|
},
|
|
10167
10189
|
tags: [
|
|
10168
10190
|
"fabric",
|
|
@@ -11650,6 +11672,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
11650
11672
|
|
|
11651
11673
|
// src/renderer.ts
|
|
11652
11674
|
var rendererCount = 0;
|
|
11675
|
+
var COLLAPSE_CLOUD_KG = 1e3;
|
|
11653
11676
|
var IMPACT_TAGS = ["metal", "glass", "wood"];
|
|
11654
11677
|
var GLOW_FROM_C = 430;
|
|
11655
11678
|
var QUEUE_CAP = 4e3;
|
|
@@ -12113,10 +12136,14 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12113
12136
|
case "settle":
|
|
12114
12137
|
this.onSettle(ev.object);
|
|
12115
12138
|
break;
|
|
12116
|
-
case "collapse":
|
|
12139
|
+
case "collapse": {
|
|
12140
|
+
const root = this.bounds.get(ev.object)?.root;
|
|
12141
|
+
const furniture = !!root && kitOriginOf(root)?.kind === "furniture";
|
|
12117
12142
|
this.splitLoose(ev.object);
|
|
12118
|
-
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);
|
|
12119
12145
|
break;
|
|
12146
|
+
}
|
|
12120
12147
|
case "disassemble_progress": {
|
|
12121
12148
|
const k = `unscrew:${ev.joint}`;
|
|
12122
12149
|
if (this.time - (this.throttles.get(k) ?? -1) > 0.25) {
|
|
@@ -12146,6 +12173,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12146
12173
|
case "stage":
|
|
12147
12174
|
this.onStage(ev);
|
|
12148
12175
|
break;
|
|
12176
|
+
case "chip":
|
|
12177
|
+
this.onChip(ev);
|
|
12178
|
+
break;
|
|
12149
12179
|
case "expose":
|
|
12150
12180
|
this.cages.set(`${ev.object}|${ev.part}`, ev.bars);
|
|
12151
12181
|
if (ev.bars.length > 0) {
|
|
@@ -12273,6 +12303,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12273
12303
|
const def = pv ? this.world.materials.get(pv.material) : void 0;
|
|
12274
12304
|
if (kind === "smoke") return { color: SMOKE_TONES[def?.thermal.smoke ?? "grey"] };
|
|
12275
12305
|
if (kind === "fibers" || kind === "leaves") {
|
|
12306
|
+
if (def?.visual?.innerColor !== void 0) return { color: def.visual.innerColor };
|
|
12276
12307
|
const c = pv ? this.visuals.baseColorHex(pv.meshes[0] ?? {}) : -1;
|
|
12277
12308
|
return c >= 0 ? { color: c } : void 0;
|
|
12278
12309
|
}
|
|
@@ -12401,6 +12432,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12401
12432
|
if (!played) this.vfx.burst("dust", ev.opening.center, [0, 1, 0], 14, 1.2, { color });
|
|
12402
12433
|
this.sound(impactKey(def), ev.opening.center, 0.8);
|
|
12403
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
|
+
}
|
|
12404
12448
|
onFracture(ev) {
|
|
12405
12449
|
const b = this.bounds.get(ev.object);
|
|
12406
12450
|
const pv = b?.parts.get(ev.part);
|
|
@@ -12421,7 +12465,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12421
12465
|
for (let i = 0; i < ev.fragments.length; i += step) {
|
|
12422
12466
|
const fr = ev.fragments[i];
|
|
12423
12467
|
const fdef = this.world.materials.get(fr.material);
|
|
12424
|
-
const
|
|
12468
|
+
const tone = fr.inner && fdef?.visual?.innerColor !== void 0 ? fdef.visual.innerColor : fdef === def || !fdef ? color : fallbackColor(fr.material, fdef);
|
|
12469
|
+
const mat = this.fragments.materialFor(fr.material, tone, transparent || fdef?.visual?.transparent === true, opacity);
|
|
12425
12470
|
this.fragments.spawn(fr, mat, ev.object, maxAlive);
|
|
12426
12471
|
}
|
|
12427
12472
|
const up = [0, 1, 0];
|
|
@@ -12439,7 +12484,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
12439
12484
|
this.vfx.burst("dust", ev.point, up, 5, 0.8, { color: 11901556 });
|
|
12440
12485
|
break;
|
|
12441
12486
|
case "tear":
|
|
12442
|
-
this.vfx.burst("fibers", ev.point, up, 12 * sizeK, 1.6, { color });
|
|
12487
|
+
this.vfx.burst("fibers", ev.point, up, 12 * sizeK, 1.6, { color: def?.visual?.innerColor ?? color });
|
|
12443
12488
|
break;
|
|
12444
12489
|
case "snap":
|
|
12445
12490
|
this.vfx.burst("chips", ev.point, up, 8 * sizeK, 3);
|