@adatechnology/game-destruction-three 0.23.0 → 0.23.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.
@@ -5144,9 +5144,17 @@ var GameDestructionThree = (() => {
5144
5144
  });
5145
5145
  }
5146
5146
  function placementOf(entry) {
5147
+ const carrier = entry.carrier;
5148
+ if (carrier) return { origin: carrier.origin, anchor: entry.anchor, yaw: entry.yaw, carrier, ...carrier.orientation ? { orientation: carrier.orientation } : {} };
5147
5149
  const origin = entry.follow ? [entry.origin[0] + positionOf2(entry.follow)[0], entry.origin[1] + positionOf2(entry.follow)[1], entry.origin[2] + positionOf2(entry.follow)[2]] : entry.origin;
5148
5150
  return { origin, anchor: entry.anchor, yaw: entry.yaw, ...entry.orientation ? { orientation: entry.orientation } : {} };
5149
5151
  }
5152
+ function moveCarrier(entry) {
5153
+ const pose = entry.track?.();
5154
+ if (!pose || !entry.carrier) return;
5155
+ entry.carrier.origin = [pose.point[0], pose.point[1], pose.point[2]];
5156
+ if (pose.orientation) entry.carrier.orientation = pose.orientation;
5157
+ }
5150
5158
  function drawing(entry, action) {
5151
5159
  const context = engine.context;
5152
5160
  const shared = context.random;
@@ -5172,7 +5180,9 @@ var GameDestructionThree = (() => {
5172
5180
  anchor: def.anchor ?? ORIGIN5,
5173
5181
  yaw: yawOf(heading, playOptions.direction),
5174
5182
  orientation: playOptions.orientation,
5175
- seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS)
5183
+ seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS),
5184
+ track: playOptions.track,
5185
+ carrier: playOptions.track ? { origin: point, orientation: playOptions.orientation } : void 0
5176
5186
  };
5177
5187
  playing.push(entry);
5178
5188
  drawing(
@@ -5194,11 +5204,21 @@ var GameDestructionThree = (() => {
5194
5204
  for (let index = playing.length - 1; index >= 0; index--) {
5195
5205
  const entry = playing[index];
5196
5206
  const instance = entry.instance;
5207
+ moveCarrier(entry);
5197
5208
  instance.setup = { ...instance.setup, placement: placementOf(entry) };
5198
5209
  drawing(entry, () => instance.step(dt));
5199
5210
  if (instance.time >= entry.seconds) playing.splice(index, 1);
5200
5211
  }
5201
5212
  },
5213
+ retrack() {
5214
+ let tracked = false;
5215
+ for (const entry of playing) {
5216
+ if (!entry.carrier) continue;
5217
+ moveCarrier(entry);
5218
+ tracked = true;
5219
+ }
5220
+ return tracked;
5221
+ },
5202
5222
  clear() {
5203
5223
  playing.length = 0;
5204
5224
  },
@@ -6810,6 +6830,19 @@ var GameDestructionThree = (() => {
6810
6830
  }
6811
6831
  }
6812
6832
  };
6833
+ function rotate(q, v) {
6834
+ const [qx, qy, qz, qw] = q;
6835
+ const ix = qw * v[0] + qy * v[2] - qz * v[1];
6836
+ const iy = qw * v[1] + qz * v[0] - qx * v[2];
6837
+ const iz = qw * v[2] + qx * v[1] - qy * v[0];
6838
+ const iw = -qx * v[0] - qy * v[1] - qz * v[2];
6839
+ return [ix * qw + iw * -qx + iy * -qz - iz * -qy, iy * qw + iw * -qy + iz * -qx - ix * -qz, iz * qw + iw * -qz + ix * -qy - iy * -qx];
6840
+ }
6841
+ function carriedPoint(carried) {
6842
+ const { carrier, local: local2 } = carried;
6843
+ const turned = carrier.orientation ? rotate(carrier.orientation, local2) : local2;
6844
+ return [carrier.origin[0] + turned[0], carrier.origin[1] + turned[1], carrier.origin[2] + turned[2]];
6845
+ }
6813
6846
  var CAPACITY3 = 400;
6814
6847
  var IDENTITY = [0, 0, 0, 1];
6815
6848
  function multiply(a, b) {
@@ -6827,7 +6860,7 @@ var GameDestructionThree = (() => {
6827
6860
  get count() {
6828
6861
  return this.particles.length;
6829
6862
  }
6830
- spawn(options, frame = IDENTITY) {
6863
+ spawn(options, frame = IDENTITY, carried) {
6831
6864
  const velocity = options.v ?? [0, 0, 0];
6832
6865
  const world = options.wv ?? [0, 0, 0];
6833
6866
  const particle = {
@@ -6844,6 +6877,9 @@ var GameDestructionThree = (() => {
6844
6877
  y: options.p[1],
6845
6878
  z: options.p[2],
6846
6879
  frame: options.roll ? multiply(frame, aboutX(options.roll)) : frame,
6880
+ roll: options.roll ? aboutX(options.roll) : void 0,
6881
+ carried,
6882
+ drift: [0, 0, 0],
6847
6883
  at: options.at ?? [0, 0, 0],
6848
6884
  rx: options.rot?.[0] ?? 0,
6849
6885
  ry: options.rot?.[1] ?? 0,
@@ -6884,9 +6920,12 @@ var GameDestructionThree = (() => {
6884
6920
  particle.vy *= keep;
6885
6921
  particle.vz *= keep;
6886
6922
  }
6887
- particle.x += particle.vx * dt;
6888
- particle.y += particle.vy * dt;
6889
- particle.z += particle.vz * dt;
6923
+ if (particle.carried) this.ride(particle, dt);
6924
+ else {
6925
+ particle.x += particle.vx * dt;
6926
+ particle.y += particle.vy * dt;
6927
+ particle.z += particle.vz * dt;
6928
+ }
6890
6929
  particle.rx += particle.spin[0] * dt;
6891
6930
  particle.ry += particle.spin[1] * dt;
6892
6931
  particle.rz += particle.spin[2] * dt;
@@ -6897,6 +6936,30 @@ var GameDestructionThree = (() => {
6897
6936
  clear() {
6898
6937
  this.particles.length = 0;
6899
6938
  }
6939
+ /** Puts every carried piece where its carrier is now (after the frame moved the thing it belongs to). */
6940
+ follow() {
6941
+ for (const particle of this.particles) if (particle.carried) this.place(particle);
6942
+ }
6943
+ /** A carried piece: how far its own velocity took it, then its place on the carrier. */
6944
+ ride(particle, dt) {
6945
+ const drift = particle.drift;
6946
+ drift[0] += particle.vx * dt;
6947
+ drift[1] += particle.vy * dt;
6948
+ drift[2] += particle.vz * dt;
6949
+ this.place(particle);
6950
+ }
6951
+ /** A carried piece's place on the carrier now plus its drift, turned with the carrier. */
6952
+ place(particle) {
6953
+ const carried = particle.carried;
6954
+ if (!carried) return;
6955
+ const drift = particle.drift;
6956
+ const [x, y, z] = carriedPoint(carried);
6957
+ particle.x = x + drift[0];
6958
+ particle.y = y + drift[1];
6959
+ particle.z = z + drift[2];
6960
+ const turn = carried.carrier.orientation;
6961
+ if (turn) particle.frame = particle.roll ? multiply(turn, particle.roll) : turn;
6962
+ }
6900
6963
  };
6901
6964
  var DEFAULT_FADE_IN = 0.1;
6902
6965
  var FLOATS_PER_VECTOR = 3;
@@ -7257,8 +7320,8 @@ var GameDestructionThree = (() => {
7257
7320
  }
7258
7321
  flash(point, color, intensity, duration, distance, force, steady) {
7259
7322
  const { level } = this.context.quality;
7260
- if (level >= 1 && !force) return;
7261
- if (level >= 2 && force !== "boom") return;
7323
+ if (level >= 1 && !force) return void 0;
7324
+ if (level >= 2 && force !== "boom") return void 0;
7262
7325
  const light = this.lights[this.next++ % LIGHT_CAPACITY];
7263
7326
  light.x = point[0];
7264
7327
  light.y = point[1];
@@ -7270,17 +7333,24 @@ var GameDestructionThree = (() => {
7270
7333
  light.t = 0;
7271
7334
  light.steady = steady === true;
7272
7335
  light.intensity = intensity;
7336
+ light.carried = void 0;
7337
+ return light;
7273
7338
  }
7274
7339
  clear() {
7275
7340
  for (const light of this.lights) light.intensity = 0;
7276
7341
  for (const light of this.fire) light.intensity = 0;
7277
7342
  }
7343
+ /** Puts every carried light that burns where its carrier is now. */
7344
+ follow() {
7345
+ for (const light of this.lights) if (light.intensity > 0 && light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
7346
+ }
7278
7347
  update(dt) {
7279
7348
  for (const light of this.lights) {
7280
7349
  if (light.intensity <= 0) continue;
7281
7350
  light.t += dt;
7282
7351
  const age = light.t / light.duration;
7283
7352
  light.intensity = age >= 1 ? 0 : light.steady ? light.peak : light.peak * (1 - age) * (1 - age);
7353
+ if (light.carried) [light.x, light.y, light.z] = carriedPoint(light.carried);
7284
7354
  }
7285
7355
  }
7286
7356
  };
@@ -7288,7 +7358,7 @@ var GameDestructionThree = (() => {
7288
7358
  var FIRE_FLICKER_SWAY = 0.25;
7289
7359
  var FIRE_FLICKER_JITTER = 0.08;
7290
7360
  var LENS_FADE = 0.16;
7291
- function rotate(q, v) {
7361
+ function rotate2(q, v) {
7292
7362
  const [qx, qy, qz, qw] = q;
7293
7363
  const ix = qw * v[0] + qy * v[2] - qz * v[1];
7294
7364
  const iy = qw * v[1] + qz * v[0] - qx * v[2];
@@ -7345,7 +7415,7 @@ var GameDestructionThree = (() => {
7345
7415
  if (!placement) return point;
7346
7416
  const { anchor, origin, yaw, orientation } = placement;
7347
7417
  if (orientation) {
7348
- const turned = rotate(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
7418
+ const turned = rotate2(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
7349
7419
  return [origin[0] + turned[0], origin[1] + turned[1], origin[2] + turned[2]];
7350
7420
  }
7351
7421
  const x = point[0] - anchor[0];
@@ -7354,11 +7424,20 @@ var GameDestructionThree = (() => {
7354
7424
  const sin2 = Math.sin(yaw);
7355
7425
  return [origin[0] + cos2 * x + sin2 * z, origin[1] + point[1] - anchor[1], origin[2] - sin2 * x + cos2 * z];
7356
7426
  }
7427
+ /** A point of the recipe's space from the anchor, turned by the placement's yaw when it has no orientation (the carrier turns the rest). */
7428
+ local(point) {
7429
+ const placement = this.placement;
7430
+ if (!placement) return point;
7431
+ const offset = [point[0] - placement.anchor[0], point[1] - placement.anchor[1], point[2] - placement.anchor[2]];
7432
+ if (placement.carrier?.orientation) return offset;
7433
+ const turned = this.place(point);
7434
+ return [turned[0] - placement.origin[0], turned[1] - placement.origin[1], turned[2] - placement.origin[2]];
7435
+ }
7357
7436
  /** A direction or velocity of the recipe's space in the world. */
7358
7437
  turn(vector2) {
7359
7438
  const placement = this.placement;
7360
7439
  if (!placement) return vector2;
7361
- if (placement.orientation) return rotate(placement.orientation, vector2);
7440
+ if (placement.orientation) return rotate2(placement.orientation, vector2);
7362
7441
  const cos2 = Math.cos(placement.yaw);
7363
7442
  const sin2 = Math.sin(placement.yaw);
7364
7443
  return [cos2 * vector2[0] + sin2 * vector2[2], vector2[1], -sin2 * vector2[0] + cos2 * vector2[2]];
@@ -7393,7 +7472,8 @@ var GameDestructionThree = (() => {
7393
7472
  const options = placement ? { ...recipe2, p: this.place(recipe2.p), ...recipe2.v ? { v: this.turn(recipe2.v) } : {} } : recipe2;
7394
7473
  this.context.trace?.("mesh", [options]);
7395
7474
  const grouped = recipe2.at !== void 0 || recipe2.roll !== void 0;
7396
- return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0);
7475
+ const carried = placement?.carrier && grouped ? { carrier: placement.carrier, local: this.local(recipe2.p) } : void 0;
7476
+ return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0, carried);
7397
7477
  }
7398
7478
  debrisPiece(recipe2) {
7399
7479
  const options = this.placed(recipe2);
@@ -7417,9 +7497,11 @@ var GameDestructionThree = (() => {
7417
7497
  }
7418
7498
  /** `steady` (a seventh number): the light holds its intensity for its duration and goes out, where the Workshop's fades with the square of its age. */
7419
7499
  flash(recipe2) {
7420
- const args = this.placement ? [this.place(recipe2[0]), recipe2[1], recipe2[2], recipe2[3], recipe2[4], recipe2[5], recipe2[6]] : recipe2;
7500
+ const placement = this.placement;
7501
+ const args = placement ? [this.place(recipe2[0]), recipe2[1], recipe2[2], recipe2[3], recipe2[4], recipe2[5], recipe2[6]] : recipe2;
7421
7502
  this.context.trace?.("flash", args.slice(0, 6));
7422
- this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
7503
+ const light = this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
7504
+ if (light && placement?.carrier) light.carried = { carrier: placement.carrier, local: this.local(recipe2[0]) };
7423
7505
  }
7424
7506
  /** `fireLight` (W400): sways with the clock and flickers with one draw. */
7425
7507
  fireLight(slot, recipe2, intensity, time) {
@@ -7578,6 +7660,12 @@ var GameDestructionThree = (() => {
7578
7660
  const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
7579
7661
  return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
7580
7662
  },
7663
+ follow() {
7664
+ if (!engine || !player?.retrack()) return false;
7665
+ engine.meshes.follow();
7666
+ engine.lights.follow();
7667
+ return true;
7668
+ },
7581
7669
  burst: (kind, point, normal, count, speed, spriteOptions) => spriteSystem.burst(kind, point, normal, count, speed, spriteOptions),
7582
7670
  spawn: (kind, point, velocity, spriteOptions) => spriteSystem.spawn(kind, point, velocity, spriteOptions),
7583
7671
  onLand: (owner, listener) => spriteSystem.onLand(owner, listener),
@@ -7757,7 +7845,7 @@ var GameDestructionThree = (() => {
7757
7845
  };
7758
7846
  var EFFECT_STEP_SECONDS = 1 / 50;
7759
7847
 
7760
- // ../game-vfx-three/dist/chunk-PZ6IVOLZ.js
7848
+ // ../game-vfx-three/dist/chunk-HJXLYDNY.js
7761
7849
  var GLOW_VERTEX = `attribute vec4 aP;attribute vec4 aC;varying vec2 vU;varying vec4 vC;
7762
7850
  void main(){vec3 R=vec3(viewMatrix[0][0],viewMatrix[1][0],viewMatrix[2][0]);vec3 Up=vec3(viewMatrix[0][1],viewMatrix[1][1],viewMatrix[2][1]);
7763
7851
  vec3 wp=aP.xyz+(R*position.x+Up*position.y)*aP.w;vU=position.xy;vC=aC;gl_Position=projectionMatrix*viewMatrix*vec4(wp,1.);}`;
@@ -9192,7 +9280,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
9192
9280
  ...request.orientation ? { orientation: request.orientation } : {},
9193
9281
  ...request.seed !== void 0 ? { seed: request.seed } : {},
9194
9282
  ...request.param !== void 0 ? { param: request.param } : {},
9195
- ...request.values ? { values: request.values } : {}
9283
+ ...request.values ? { values: request.values } : {},
9284
+ ...request.track ? { track: request.track } : {}
9196
9285
  });
9197
9286
  },
9198
9287
  stop: (handle) => world.stop(handle),
@@ -9221,6 +9310,11 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
9221
9310
  syncAll();
9222
9311
  overlay?.update(screenNow());
9223
9312
  },
9313
+ present() {
9314
+ if (!world.follow()) return;
9315
+ lights.sync();
9316
+ workshopLayers?.sync();
9317
+ },
9224
9318
  warmUpProbes() {
9225
9319
  releaseAnchors();
9226
9320
  marks.prepare();
@@ -9502,6 +9596,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
9502
9596
  board: buildBrokenBoardGeometry,
9503
9597
  rubble: buildRubbleGeometry
9504
9598
  };
9599
+ var FLOOR_REMEASURE = 0.5;
9505
9600
  var SHEET_MAX = 4e-3;
9506
9601
  var SHEET_AIR = 2.5;
9507
9602
  var SHEET_SWAY = 3;
@@ -9691,6 +9786,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
9691
9786
  this.o.scene.add(mesh2);
9692
9787
  const live = {
9693
9788
  mesh: mesh2,
9789
+ floor: null,
9694
9790
  home,
9695
9791
  vel: new this.THREE.Vector3(f.velocity[0], f.velocity[1], f.velocity[2]),
9696
9792
  ang: new this.THREE.Vector3(f.angularVelocity[0], f.angularVelocity[1], f.angularVelocity[2]),
@@ -9707,7 +9803,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
9707
9803
  born: this.tick,
9708
9804
  life: lasting ? 0 : Math.max(0, typeof this.o.life === "function" ? this.o.life(f, home) : this.o.life)
9709
9805
  };
9710
- if (lasting || f.shape !== "shard" && isBig(f.size)) {
9806
+ if (lasting || isBig(f.size)) {
9711
9807
  live.body = {
9712
9808
  mass: f.mass,
9713
9809
  push: (x, z) => {
@@ -9801,9 +9897,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
9801
9897
  if (!f.asleep || f.dying) continue;
9802
9898
  const e = this.m.makeRotationFromQuaternion(f.mesh.quaternion).elements;
9803
9899
  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.o.groundAt(f.mesh.position.x, f.mesh.position.z) + SUPPORT_GAP) this.rouse(f);
9900
+ if (f.mesh.position.y - ext > this.floorUnder(f) + SUPPORT_GAP) this.rouse(f);
9805
9901
  }
9806
9902
  }
9903
+ /** 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). */
9904
+ floorUnder(f) {
9905
+ const p = f.mesh.position;
9906
+ if (!this.o.surfaceAt) return this.o.groundAt(p.x, p.z);
9907
+ const at3 = f.floor;
9908
+ if (!at3 || Math.abs(at3.x - p.x) > FLOOR_REMEASURE || Math.abs(at3.z - p.z) > FLOOR_REMEASURE || p.y < at3.y - FLOOR_REMEASURE) {
9909
+ f.floor = { x: p.x, z: p.z, y: this.o.surfaceAt(p.x, p.y, p.z) };
9910
+ }
9911
+ return f.floor.y;
9912
+ }
9807
9913
  step(f, dt, g) {
9808
9914
  const mesh2 = f.mesh;
9809
9915
  f.vel.y -= g * dt;
@@ -9818,7 +9924,7 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
9818
9924
  const h = f.half;
9819
9925
  const sc = f.dying ? f.fade : 1;
9820
9926
  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.o.groundAt(mesh2.position.x, mesh2.position.z);
9927
+ const gy = this.floorUnder(f);
9822
9928
  let contact = false;
9823
9929
  if (mesh2.position.y - ext < gy) {
9824
9930
  contact = true;
@@ -14335,6 +14441,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
14335
14441
  var MIN_FRAGMENTS_PER_SLICE = 8;
14336
14442
  var STATIC_REFRESH = 0.5;
14337
14443
  var STATIC_REFRESH_SLICE_MS = 1;
14444
+ var SURFACE_RAYS = 4;
14445
+ var SURFACE_INSIDE = 5e-3;
14446
+ var SURFACE_STEP = 0.15;
14338
14447
  var STATIC_SPAN = 3;
14339
14448
  var FEET_BAND = 0.03;
14340
14449
  var TIP_MIN_HEIGHT = 0.3;
@@ -14593,7 +14702,9 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
14593
14702
  max: this.maxFragments,
14594
14703
  life: o.fragmentLife ?? 12,
14595
14704
  formOf: (id) => this.world.materials.get(id)?.splitForm,
14596
- crumbles: (id) => this.world.materials.get(id)?.fracture === "crumble"
14705
+ crumbles: (id) => this.world.materials.get(id)?.fracture === "crumble",
14706
+ // rubble lands on what is still built (a slab, a wall's top, a floor), not only on the terrain under it
14707
+ surfaceAt: (x, y, z) => this.surfaceAt(x, y, z)
14597
14708
  });
14598
14709
  this.cages = new RebarCages(THREE, o.scene);
14599
14710
  this.pieceSys = new PieceSystem(THREE, {
@@ -15405,7 +15516,8 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
15405
15516
  }
15406
15517
  /** Current colour of the part's first mesh (char included), or null. */
15407
15518
  partColor(pv, def) {
15408
- const mv = pv.meshes[0];
15519
+ const size = (m) => m.range ? m.range[1] - m.range[0] : m.mesh.geometry.getAttribute("position")?.count ?? 0;
15520
+ const mv = pv.meshes.reduce((best, m) => !best || size(m) > size(best) ? m : best, void 0);
15409
15521
  if (!mv) return null;
15410
15522
  const mat = materialsOf2(mv.mesh.material)[0];
15411
15523
  const c = mat?.color;
@@ -15925,6 +16037,19 @@ void main(){vec2 d=gl_PointCoord-.5;float r=length(d)*2.;if(r>1.)discard;float a
15925
16037
  }
15926
16038
  return "";
15927
16039
  }
16040
+ /** 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. */
16041
+ surfaceAt(x, y, z) {
16042
+ const ground = this.groundAt(x, z);
16043
+ if (y <= ground || typeof this.world.raycast !== "function") return ground;
16044
+ let from = y;
16045
+ for (let k = 0; k < SURFACE_RAYS && from > ground; k++) {
16046
+ const hit = this.world.raycast([x, from, z], [0, -1, 0], from - ground);
16047
+ if (!hit) return ground;
16048
+ if (hit.distance > SURFACE_INSIDE) return Math.max(ground, hit.point[1]);
16049
+ from -= SURFACE_STEP;
16050
+ }
16051
+ return ground;
16052
+ }
15928
16053
  /** `staticTopAt` without the boxes of `objectId` itself. */
15929
16054
  staticTopAtBut(objectId, x, z, y, step) {
15930
16055
  let top = -Infinity;