@adatechnology/game-destruction-three 1.1.1 → 1.1.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.
@@ -11358,6 +11358,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
11358
11358
  var SWEEP_MIN_SPEED = 1;
11359
11359
  var WALL_RESTITUTION = 0.25;
11360
11360
  var WALL_GLIDE = 0.7;
11361
+ var TUMBLE_REACH = 0.1;
11362
+ var LAID_GAP = 5e-3;
11361
11363
  var STAND_RATIO = 0.6;
11362
11364
  var SETTLE_SECONDS = 0.4;
11363
11365
  var isSlow = (f) => f.vel.lengthSq() < 0.012 && f.ang.lengthSq() < 0.2;
@@ -11838,6 +11840,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
11838
11840
  const gy = Math.max(floor2, pile);
11839
11841
  const tip = pile > floor2 ? this.offEdge : null;
11840
11842
  let contact = false;
11843
+ let turning = false;
11841
11844
  if (mesh2.position.y - ext < gy) {
11842
11845
  contact = true;
11843
11846
  mesh2.position.y = gy + ext;
@@ -11846,8 +11849,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
11846
11849
  f.vel.x *= 0.7;
11847
11850
  f.vel.z *= 0.7;
11848
11851
  f.ang.multiplyScalar(0.55);
11849
- f.ang.x += (this.rng() - 0.5) * 2;
11850
- f.ang.z += (this.rng() - 0.5) * 2;
11852
+ const tumble = Math.min(1, TUMBLE_REACH / Math.max(h.x, h.y, h.z));
11853
+ f.ang.x += (this.rng() - 0.5) * 2 * tumble;
11854
+ f.ang.z += (this.rng() - 0.5) * 2 * tumble;
11851
11855
  } else {
11852
11856
  f.vel.y = 0;
11853
11857
  const sliding = Math.hypot(f.vel.x, f.vel.z);
@@ -11865,9 +11869,13 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
11865
11869
  f.vel.z += tip.z * TIP_SPEED * dt * 10;
11866
11870
  f.ang.x += tip.z * TIP_TURN * dt * 10;
11867
11871
  f.ang.z -= tip.x * TIP_TURN * dt * 10;
11868
- } else if (contact && f.vel.lengthSq() < 4) this.settle(f, dt);
11872
+ } else if (contact && f.vel.lengthSq() < 4) {
11873
+ turning = this.settle(f, dt);
11874
+ this.m.makeRotationFromQuaternion(mesh2.quaternion);
11875
+ mesh2.position.y = gy + (Math.abs(e[1]) * h.x + Math.abs(e[5]) * h.y + Math.abs(e[9]) * h.z) * sc;
11876
+ }
11869
11877
  f.contact = contact;
11870
- if (contact && isSlow(f)) {
11878
+ if (contact && !turning && isSlow(f)) {
11871
11879
  f.still += dt;
11872
11880
  if (f.still > SETTLE_SECONDS) this.sleep(f);
11873
11881
  } else {
@@ -11945,7 +11953,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
11945
11953
  f.ang.x += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt;
11946
11954
  f.ang.z += (this.rng() - 0.5) * SHEET_SWAY * 4 * dt;
11947
11955
  }
11948
- /** Tip the fragment towards lying on its flattest face. */
11956
+ /** Tip the fragment towards lying on its flattest face. True while its end is still more than `LAID_GAP` from lying. */
11949
11957
  settle(f, dt) {
11950
11958
  const mesh2 = f.mesh;
11951
11959
  this.m.makeRotationFromQuaternion(mesh2.quaternion);
@@ -11967,6 +11975,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
11967
11975
  this.dq.setFromUnitVectors(this.v, this.w);
11968
11976
  this.q.copy(this.dq).multiply(mesh2.quaternion);
11969
11977
  mesh2.quaternion.slerp(this.q, clamp6(dt * 7, 0, 1));
11978
+ return Math.sqrt(Math.max(0, 1 - this.v.y * this.v.y)) * Math.max(half[0], half[1], half[2]) > LAID_GAP;
11970
11979
  }
11971
11980
  /** Remove the fragments of one object (after `restore`). */
11972
11981
  removeHome(home) {