@adatechnology/game-test-room 0.28.1 → 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;
@@ -7905,6 +7912,30 @@ function createTestRoom(options) {
7905
7912
  for (const p of loose) floatPiece(p, dt);
7906
7913
  };
7907
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
+ };
7908
7939
  const prevVy = /* @__PURE__ */ new Map();
7909
7940
  const tmpBox = new THREE.Box3();
7910
7941
  const onKey = (code, down, e) => {
@@ -8203,6 +8234,7 @@ function createTestRoom(options) {
8203
8234
  vfx.update(dt);
8204
8235
  updateImpacts();
8205
8236
  updateWater(dt);
8237
+ updateLoads(dt);
8206
8238
  if (player.position[1] <= terrain.footAt(player.position[0], player.position[2]) + 0.15) footprints.update(player.position[0], player.position[2]);
8207
8239
  fluidView.update(dt);
8208
8240
  filmBridge.update(dt);