@adatechnology/game-destruction-three 0.23.0 → 0.23.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/dist/index.global.js +36 -5
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +36 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -9502,6 +9502,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9502
9502
|
board: buildBrokenBoardGeometry,
|
|
9503
9503
|
rubble: buildRubbleGeometry
|
|
9504
9504
|
};
|
|
9505
|
+
var FLOOR_REMEASURE = 0.5;
|
|
9505
9506
|
var SHEET_MAX = 4e-3;
|
|
9506
9507
|
var SHEET_AIR = 2.5;
|
|
9507
9508
|
var SHEET_SWAY = 3;
|
|
@@ -9691,6 +9692,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9691
9692
|
this.o.scene.add(mesh2);
|
|
9692
9693
|
const live = {
|
|
9693
9694
|
mesh: mesh2,
|
|
9695
|
+
floor: null,
|
|
9694
9696
|
home,
|
|
9695
9697
|
vel: new this.THREE.Vector3(f.velocity[0], f.velocity[1], f.velocity[2]),
|
|
9696
9698
|
ang: new this.THREE.Vector3(f.angularVelocity[0], f.angularVelocity[1], f.angularVelocity[2]),
|
|
@@ -9707,7 +9709,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9707
9709
|
born: this.tick,
|
|
9708
9710
|
life: lasting ? 0 : Math.max(0, typeof this.o.life === "function" ? this.o.life(f, home) : this.o.life)
|
|
9709
9711
|
};
|
|
9710
|
-
if (lasting ||
|
|
9712
|
+
if (lasting || isBig(f.size)) {
|
|
9711
9713
|
live.body = {
|
|
9712
9714
|
mass: f.mass,
|
|
9713
9715
|
push: (x, z) => {
|
|
@@ -9801,9 +9803,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9801
9803
|
if (!f.asleep || f.dying) continue;
|
|
9802
9804
|
const e = this.m.makeRotationFromQuaternion(f.mesh.quaternion).elements;
|
|
9803
9805
|
const ext = Math.abs(e[1]) * f.half.x + Math.abs(e[5]) * f.half.y + Math.abs(e[9]) * f.half.z;
|
|
9804
|
-
if (f.mesh.position.y - ext > this.
|
|
9806
|
+
if (f.mesh.position.y - ext > this.floorUnder(f) + SUPPORT_GAP) this.rouse(f);
|
|
9805
9807
|
}
|
|
9806
9808
|
}
|
|
9809
|
+
/** What a fragment lands on: measured where it is, and again only once it moved `FLOOR_REMEASURE` m off that spot (a ray down is not free). */
|
|
9810
|
+
floorUnder(f) {
|
|
9811
|
+
const p = f.mesh.position;
|
|
9812
|
+
if (!this.o.surfaceAt) return this.o.groundAt(p.x, p.z);
|
|
9813
|
+
const at3 = f.floor;
|
|
9814
|
+
if (!at3 || Math.abs(at3.x - p.x) > FLOOR_REMEASURE || Math.abs(at3.z - p.z) > FLOOR_REMEASURE || p.y < at3.y - FLOOR_REMEASURE) {
|
|
9815
|
+
f.floor = { x: p.x, z: p.z, y: this.o.surfaceAt(p.x, p.y, p.z) };
|
|
9816
|
+
}
|
|
9817
|
+
return f.floor.y;
|
|
9818
|
+
}
|
|
9807
9819
|
step(f, dt, g) {
|
|
9808
9820
|
const mesh2 = f.mesh;
|
|
9809
9821
|
f.vel.y -= g * dt;
|
|
@@ -9818,7 +9830,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
9818
9830
|
const h = f.half;
|
|
9819
9831
|
const sc = f.dying ? f.fade : 1;
|
|
9820
9832
|
const ext = (Math.abs(e[1]) * h.x + Math.abs(e[5]) * h.y + Math.abs(e[9]) * h.z) * sc;
|
|
9821
|
-
const gy = this.
|
|
9833
|
+
const gy = this.floorUnder(f);
|
|
9822
9834
|
let contact = false;
|
|
9823
9835
|
if (mesh2.position.y - ext < gy) {
|
|
9824
9836
|
contact = true;
|
|
@@ -14335,6 +14347,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
14335
14347
|
var MIN_FRAGMENTS_PER_SLICE = 8;
|
|
14336
14348
|
var STATIC_REFRESH = 0.5;
|
|
14337
14349
|
var STATIC_REFRESH_SLICE_MS = 1;
|
|
14350
|
+
var SURFACE_RAYS = 4;
|
|
14351
|
+
var SURFACE_INSIDE = 5e-3;
|
|
14352
|
+
var SURFACE_STEP = 0.15;
|
|
14338
14353
|
var STATIC_SPAN = 3;
|
|
14339
14354
|
var FEET_BAND = 0.03;
|
|
14340
14355
|
var TIP_MIN_HEIGHT = 0.3;
|
|
@@ -14593,7 +14608,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
14593
14608
|
max: this.maxFragments,
|
|
14594
14609
|
life: o.fragmentLife ?? 12,
|
|
14595
14610
|
formOf: (id) => this.world.materials.get(id)?.splitForm,
|
|
14596
|
-
crumbles: (id) => this.world.materials.get(id)?.fracture === "crumble"
|
|
14611
|
+
crumbles: (id) => this.world.materials.get(id)?.fracture === "crumble",
|
|
14612
|
+
// rubble lands on what is still built (a slab, a wall's top, a floor), not only on the terrain under it
|
|
14613
|
+
surfaceAt: (x, y, z) => this.surfaceAt(x, y, z)
|
|
14597
14614
|
});
|
|
14598
14615
|
this.cages = new RebarCages(THREE, o.scene);
|
|
14599
14616
|
this.pieceSys = new PieceSystem(THREE, {
|
|
@@ -15405,7 +15422,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15405
15422
|
}
|
|
15406
15423
|
/** Current colour of the part's first mesh (char included), or null. */
|
|
15407
15424
|
partColor(pv, def) {
|
|
15408
|
-
const
|
|
15425
|
+
const size = (m) => m.range ? m.range[1] - m.range[0] : m.mesh.geometry.getAttribute("position")?.count ?? 0;
|
|
15426
|
+
const mv = pv.meshes.reduce((best, m) => !best || size(m) > size(best) ? m : best, void 0);
|
|
15409
15427
|
if (!mv) return null;
|
|
15410
15428
|
const mat = materialsOf2(mv.mesh.material)[0];
|
|
15411
15429
|
const c = mat?.color;
|
|
@@ -15925,6 +15943,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
|
|
|
15925
15943
|
}
|
|
15926
15944
|
return "";
|
|
15927
15945
|
}
|
|
15946
|
+
/** The top of the ground or of a standing part of the world under (x, z), below height y: a ray straight down through the destruction world. */
|
|
15947
|
+
surfaceAt(x, y, z) {
|
|
15948
|
+
const ground = this.groundAt(x, z);
|
|
15949
|
+
if (y <= ground || typeof this.world.raycast !== "function") return ground;
|
|
15950
|
+
let from = y;
|
|
15951
|
+
for (let k = 0; k < SURFACE_RAYS && from > ground; k++) {
|
|
15952
|
+
const hit = this.world.raycast([x, from, z], [0, -1, 0], from - ground);
|
|
15953
|
+
if (!hit) return ground;
|
|
15954
|
+
if (hit.distance > SURFACE_INSIDE) return Math.max(ground, hit.point[1]);
|
|
15955
|
+
from -= SURFACE_STEP;
|
|
15956
|
+
}
|
|
15957
|
+
return ground;
|
|
15958
|
+
}
|
|
15928
15959
|
/** `staticTopAt` without the boxes of `objectId` itself. */
|
|
15929
15960
|
staticTopAtBut(objectId, x, z, y, step) {
|
|
15930
15961
|
let top = -Infinity;
|