@adatechnology/game-test-room 0.28.0 → 0.28.2

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
@@ -3576,6 +3576,7 @@ var en = {
3576
3576
  "act.throw": "Threw {name} at {speed} m/s",
3577
3577
  "ground.name": "Ground",
3578
3578
  "act.landing": "{name} landed at {speed} m/s: {energy} J",
3579
+ "act.ground_gave_way": "the bare bars could not hold the weight on them: the slab gave way",
3579
3580
  "act.player_land": "You landed at {speed} m/s",
3580
3581
  "act.bench_failed": "{name} failed: {error}",
3581
3582
  "loading.working": "Working\u2026",
@@ -3945,6 +3946,7 @@ var ptBR = {
3945
3946
  "act.throw": "Arremessou {name} a {speed} m/s",
3946
3947
  "ground.name": "Ch\xE3o",
3947
3948
  "act.landing": "{name} caiu a {speed} m/s: {energy} J",
3949
+ "act.ground_gave_way": "os vergalh\xF5es expostos n\xE3o aguentaram o peso: a laje cedeu",
3948
3950
  "act.player_land": "Voc\xEA aterrissou a {speed} m/s",
3949
3951
  "act.bench_failed": "{name} falhou: {error}",
3950
3952
  "loading.working": "Trabalhando\u2026",
@@ -5465,6 +5467,11 @@ var GROUND_ID = "room_ground";
5465
5467
  var TERRAIN_CELL = 0.1;
5466
5468
  var GROUND_SPLASH_MAX_LITRES = 3;
5467
5469
  var WATER_ENTRY_SPEED = 1.5;
5470
+ var LOAD_EVERY = 0.2;
5471
+ var RESTING_GAP = 0.06;
5472
+ var PLAYER_FOOTPRINT = 0.25;
5473
+ var RESTING_SPEED = 0.3;
5474
+ var GRAVITY_EARTH = 9.81;
5468
5475
  var TERRAIN_MAX_CELLS = 1e3;
5469
5476
  var GROUND_BURST_MAX = 28;
5470
5477
  var GROUND_BURST_PER_METRE = 30;
@@ -5627,7 +5634,9 @@ function createTestRoom(options) {
5627
5634
  profile: quality,
5628
5635
  ...options.debris?.particles ? { sprites: { kinds: patchSpriteKinds(SPRITE_KINDS, options.debris.particles) } } : {},
5629
5636
  groundAt,
5630
- marklessAt: (x, z) => terrain.waterAt(x, z) !== null
5637
+ marklessAt: (x, z) => terrain.waterAt(x, z) !== null,
5638
+ // the dirt crater of the effects only where the ground is loose; rock, asphalt and a slab keep the soot and the bowl the terrain itself dug
5639
+ cratersAt: (x, z) => terrain.material(terrain.columnAt(x, z).material).reposeDegrees !== void 0
5631
5640
  })
5632
5641
  });
5633
5642
  const renderer = createDestructionRenderer(THREE, {
@@ -7903,6 +7912,30 @@ function createTestRoom(options) {
7903
7912
  for (const p of loose) floatPiece(p, dt);
7904
7913
  };
7905
7914
  const footprints = createFootprints(terrain);
7915
+ let loadClock = 0;
7916
+ const restingLoad = (piece) => {
7917
+ if (piece.held || Math.hypot(piece.velocity[0], piece.velocity[1], piece.velocity[2]) > RESTING_SPEED) return null;
7918
+ const box2 = tmpBox.setFromObject(piece.root);
7919
+ const centre = box2.getCenter(tmpV);
7920
+ return { x: centre.x, z: centre.z, radius: Math.max(piece.halfExtents[0], piece.halfExtents[2]), newtons: piece.mass * GRAVITY_EARTH };
7921
+ };
7922
+ const updateLoads = (dt) => {
7923
+ loadClock += dt;
7924
+ if (loadClock < LOAD_EVERY) return;
7925
+ loadClock = 0;
7926
+ const loads = [];
7927
+ const [px, py, pz] = player.position;
7928
+ if (py - terrain.heightAt(px, pz) <= RESTING_GAP) loads.push({ x: px, z: pz, radius: PLAYER_FOOTPRINT, newtons: playerMass * GRAVITY_EARTH });
7929
+ for (const e of entries.values()) {
7930
+ const load = e.piece ? restingLoad(e.piece) : null;
7931
+ if (load) loads.push(load);
7932
+ }
7933
+ for (const p of loose) {
7934
+ const load = restingLoad(p);
7935
+ if (load) loads.push(load);
7936
+ }
7937
+ if (loads.length > 0 && terrain.bear(loads)) action("ground_gave_way", t("act.ground_gave_way"));
7938
+ };
7906
7939
  const prevVy = /* @__PURE__ */ new Map();
7907
7940
  const tmpBox = new THREE.Box3();
7908
7941
  const onKey = (code, down, e) => {
@@ -8201,6 +8234,7 @@ function createTestRoom(options) {
8201
8234
  vfx.update(dt);
8202
8235
  updateImpacts();
8203
8236
  updateWater(dt);
8237
+ updateLoads(dt);
8204
8238
  if (player.position[1] <= terrain.footAt(player.position[0], player.position[2]) + 0.15) footprints.update(player.position[0], player.position[2]);
8205
8239
  fluidView.update(dt);
8206
8240
  filmBridge.update(dt);