@threenative/physics 0.3.11 → 0.3.13

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
@@ -1,9 +1,7 @@
1
- import * as rapier from '@dimforge/rapier3d-compat';
2
- import { Matrix4, Vector3, Quaternion, Box3, Object3D, Mesh, InstancedMesh } from 'three';
1
+ import { Matrix4, Vector3, Quaternion, Object3D, Mesh, InstancedMesh, Matrix3 } from 'three';
2
+ import { isStreamedGeometry } from '@threenative/core';
3
3
  import { snowDiscFootprint } from '@threenative/core/world';
4
4
 
5
- // src/web.ts
6
-
7
5
  // src/collision.ts
8
6
  function interactionGroups(layer, mask) {
9
7
  if (!Number.isInteger(layer) || layer < 0 || layer > 65535)
@@ -287,57 +285,57 @@ function requirePhysicsPointQuery(value) {
287
285
  position: queryVector(query.position, "point position")
288
286
  };
289
287
  }
290
- function createWebPhysicsShape(rapier3, shape, sensor = shape.sensor) {
288
+ function createWebPhysicsShape(rapier2, shape, sensor = shape.sensor) {
291
289
  let descriptor;
292
- if (shape.kind === "box") descriptor = rapier3.ColliderDesc.cuboid(shape.x, shape.y, shape.z);
293
- else if (shape.kind === "sphere") descriptor = rapier3.ColliderDesc.ball(shape.x);
294
- else if (shape.kind === "capsule") descriptor = rapier3.ColliderDesc.capsule(shape.x, shape.y);
290
+ if (shape.kind === "box") descriptor = rapier2.ColliderDesc.cuboid(shape.x, shape.y, shape.z);
291
+ else if (shape.kind === "sphere") descriptor = rapier2.ColliderDesc.ball(shape.x);
292
+ else if (shape.kind === "capsule") descriptor = rapier2.ColliderDesc.capsule(shape.x, shape.y);
295
293
  else if (shape.kind === "trimesh") {
296
294
  if (shape.vertices === void 0 || shape.indices === void 0)
297
295
  throw new Error("CollisionShape3D.trimesh is missing mesh data.");
298
- descriptor = rapier3.ColliderDesc.trimesh(
296
+ descriptor = rapier2.ColliderDesc.trimesh(
299
297
  shape.vertices,
300
298
  shape.indices,
301
- rapier3.TriMeshFlags.FIX_INTERNAL_EDGES
299
+ rapier2.TriMeshFlags.FIX_INTERNAL_EDGES
302
300
  );
303
301
  } else if (shape.kind === "convexHull") {
304
302
  if (shape.vertices === void 0)
305
303
  throw new Error("CollisionShape3D.convexHull is missing vertices.");
306
- descriptor = rapier3.ColliderDesc.convexHull(shape.vertices);
304
+ descriptor = rapier2.ColliderDesc.convexHull(shape.vertices);
307
305
  if (descriptor === null) throw new Error("CollisionShape3D could not build a convex hull.");
308
306
  } else {
309
307
  if (shape.rows === void 0 || shape.columns === void 0 || shape.heights === void 0 || shape.scale === void 0)
310
308
  throw new Error("CollisionShape3D.heightfield is missing height data.");
311
- descriptor = rapier3.ColliderDesc.heightfield(
309
+ descriptor = rapier2.ColliderDesc.heightfield(
312
310
  shape.rows - 1,
313
311
  shape.columns - 1,
314
312
  shape.heights,
315
313
  shape.scale,
316
- rapier3.HeightFieldFlags.FIX_INTERNAL_EDGES
314
+ rapier2.HeightFieldFlags.FIX_INTERNAL_EDGES
317
315
  );
318
316
  }
319
317
  descriptor.setCollisionGroups(interactionGroups(shape.collisionLayer, shape.collisionMask));
320
318
  descriptor.setSensor(sensor);
321
- descriptor.setActiveEvents(rapier3.ActiveEvents.COLLISION_EVENTS);
319
+ descriptor.setActiveEvents(rapier2.ActiveEvents.COLLISION_EVENTS);
322
320
  return descriptor;
323
321
  }
324
- function bodyDescription(rapier3, type, position, rotation, continuousCollision) {
325
- const description = type === "fixed" ? rapier3.RigidBodyDesc.fixed() : type === "kinematic" || type === "character" ? rapier3.RigidBodyDesc.kinematicPositionBased() : rapier3.RigidBodyDesc.dynamic();
322
+ function bodyDescription(rapier2, type, position, rotation, continuousCollision) {
323
+ const description = type === "fixed" ? rapier2.RigidBodyDesc.fixed() : type === "kinematic" || type === "character" ? rapier2.RigidBodyDesc.kinematicPositionBased() : rapier2.RigidBodyDesc.dynamic();
326
324
  description.setTranslation(position.x, position.y, position.z).setRotation({ x: rotation.x, y: rotation.y, z: rotation.z, w: rotation.w });
327
325
  if (type === "dynamic") description.setCcdEnabled(continuousCollision);
328
326
  return description;
329
327
  }
330
- function jointDescription(rapier3, jointOptions) {
328
+ function jointDescription(rapier2, jointOptions) {
331
329
  if (jointOptions.type === "pin")
332
- return rapier3.JointData.spherical(jointOptions.anchorA, jointOptions.anchorB);
330
+ return rapier2.JointData.spherical(jointOptions.anchorA, jointOptions.anchorB);
333
331
  if (jointOptions.type === "hinge") {
334
- return rapier3.JointData.revolute(
332
+ return rapier2.JointData.revolute(
335
333
  jointOptions.anchorA,
336
334
  jointOptions.anchorB,
337
335
  jointOptions.axis
338
336
  );
339
337
  }
340
- return rapier3.JointData.fixed(
338
+ return rapier2.JointData.fixed(
341
339
  jointOptions.anchorA,
342
340
  jointOptions.frameA ?? { x: 0, y: 0, z: 0, w: 1 },
343
341
  jointOptions.anchorB,
@@ -1145,6 +1143,10 @@ function requirePhysicsSimulation(physics, world) {
1145
1143
  );
1146
1144
  }
1147
1145
  if (physics?.simulation !== void 0) return physics.simulation;
1146
+ if (physics === void 0 && world === void 0)
1147
+ throw new Error(
1148
+ "TN_PHYSICS_NOT_READY: `physics` is undefined. ctx.physics is set before Scene.enter(), not during load(), because Rapier initializes while the scene loads: create physics nodes in enter() or later."
1149
+ );
1148
1150
  const candidate = typeof world === "object" && world !== null && "simulation" in world ? world.simulation : world;
1149
1151
  if (typeof candidate === "object" && candidate !== null && "createBody" in candidate && typeof candidate.createBody === "function" && "step" in candidate && typeof candidate.step === "function")
1150
1152
  return candidate;
@@ -1157,17 +1159,28 @@ function requirePhysicsSimulation(physics, world) {
1157
1159
  }
1158
1160
 
1159
1161
  // src/web.ts
1162
+ var loaded;
1163
+ var rapierModule = import('@dimforge/rapier3d-compat').then((module) => {
1164
+ loaded = module;
1165
+ return module;
1166
+ });
1167
+ rapierModule.catch(() => void 0);
1168
+ var rapierReady = () => {
1169
+ if (loaded === void 0) throw new Error("Rapier used before the physics backend initialized.");
1170
+ return loaded;
1171
+ };
1160
1172
  var initialized;
1161
1173
  var simulations = /* @__PURE__ */ new WeakMap();
1162
1174
  var RAPIER_INIT_WARNING = "using deprecated parameters for the initialization function; pass a single object instead";
1163
- function initializeRapier() {
1175
+ async function initializeRapier() {
1176
+ const rapier2 = await rapierModule;
1164
1177
  const previousWarn = console.warn;
1165
1178
  console.warn = (...args) => {
1166
1179
  if (args[0] === RAPIER_INIT_WARNING) return;
1167
1180
  previousWarn(...args);
1168
1181
  };
1169
1182
  try {
1170
- return rapier.init().finally(() => {
1183
+ await rapier2.init().finally(() => {
1171
1184
  console.warn = previousWarn;
1172
1185
  });
1173
1186
  } catch (error) {
@@ -1181,11 +1194,12 @@ installPhysicsSimulationBackend({
1181
1194
  return initialized;
1182
1195
  },
1183
1196
  createSimulation: (options = {}) => {
1184
- const world = new rapier.World(options.gravity ?? { x: 0, y: -9.81, z: 0 });
1197
+ const rapier2 = rapierReady();
1198
+ const world = new rapier2.World(options.gravity ?? { x: 0, y: -9.81, z: 0 });
1185
1199
  const simulation = createWebPhysicsSimulation({
1186
- eventQueue: new rapier.EventQueue(true),
1187
- rapier,
1188
- version: rapier.version(),
1200
+ eventQueue: new rapier2.EventQueue(true),
1201
+ rapier: rapier2,
1202
+ version: rapier2.version(),
1189
1203
  world
1190
1204
  });
1191
1205
  simulations.set(world, simulation);
@@ -1196,16 +1210,17 @@ installPhysicsSimulationBackend({
1196
1210
  throw new Error("Physics nodes expected a Rapier World.");
1197
1211
  const simulation = simulations.get(world);
1198
1212
  if (simulation !== void 0) return simulation;
1213
+ const rapier2 = rapierReady();
1199
1214
  const created = createWebPhysicsSimulation({
1200
- eventQueue: new rapier.EventQueue(true),
1201
- rapier,
1202
- version: rapier.version(),
1215
+ eventQueue: new rapier2.EventQueue(true),
1216
+ rapier: rapier2,
1217
+ version: rapier2.version(),
1203
1218
  world
1204
1219
  });
1205
1220
  simulations.set(world, created);
1206
1221
  return created;
1207
1222
  },
1208
- createShape: (shape) => createWebPhysicsShape(rapier, shape)
1223
+ createShape: (shape) => createWebPhysicsShape(rapierReady(), shape)
1209
1224
  });
1210
1225
 
1211
1226
  // src/transformRecord.ts
@@ -1357,6 +1372,15 @@ var Area3D = class {
1357
1372
  this.#listeners.bodyExited.clear();
1358
1373
  }
1359
1374
  };
1375
+ var SEAT_LIFT = 1e-3;
1376
+ var SEAT_BAND = 2e-4;
1377
+ var SEAT_STOPPED = 5e-5;
1378
+ var SEAT_LIFTS = 16;
1379
+ var SEAT_GROUND_Y = Math.cos(Math.PI / 4 - Math.PI / 18);
1380
+ function halfHeightOf(shape) {
1381
+ const { kind, x, y } = shape.descriptor;
1382
+ return kind === "capsule" ? x + y : kind === "box" ? y : kind === "sphere" ? x : void 0;
1383
+ }
1360
1384
  var CharacterBody3D = class {
1361
1385
  body;
1362
1386
  collider;
@@ -1374,6 +1398,26 @@ var CharacterBody3D = class {
1374
1398
  groundBody;
1375
1399
  /** Radians between `groundNormal` and world up (+Y). */
1376
1400
  slopeAngle = 0;
1401
+ /** See `ICharacterBody3DOptions.water`; assign it once the water exists. */
1402
+ water;
1403
+ /** See `ICharacterBody3DOptions.waterCurrent`; assign it once the water exists. */
1404
+ waterCurrent;
1405
+ /**
1406
+ * The water's own velocity the last `moveAndSlide` applied, in m/s: the full current while
1407
+ * swimming, a depth-weighted share of it while wading, `(0, 0)` out of water. Read it to tell a
1408
+ * drift from a step.
1409
+ */
1410
+ currentVelocity = { x: 0, z: 0 };
1411
+ buoyancy;
1412
+ maxSwimSpeed;
1413
+ fluidFriction;
1414
+ /** True while the body's centre is under the water surface (Unreal's MOVE_Swimming). */
1415
+ swimming = false;
1416
+ /** Unreal's `ImmersionDepth`: the share of the collider's height under water, 0 to 1. */
1417
+ immersionDepth = 0;
1418
+ /** The water surface height the last `moveAndSlide` read, or `undefined` out of water. */
1419
+ waterSurface;
1420
+ #halfHeight;
1377
1421
  #simulation;
1378
1422
  #physics;
1379
1423
  #desired = { x: 0, y: 0, z: 0 };
@@ -1381,6 +1425,13 @@ var CharacterBody3D = class {
1381
1425
  #groundCollider;
1382
1426
  #beforeY = 0;
1383
1427
  #desiredY = 0;
1428
+ #still = false;
1429
+ #seat = 0 /* Step */;
1430
+ #lifts = 0;
1431
+ /** Where the last step started, and the solver's pose after it with the pose the object was given. */
1432
+ #from = { x: 0, y: 0, z: 0 };
1433
+ #solved = { x: 0, y: 0, z: 0 };
1434
+ #shown = { x: 0, y: 0, z: 0 };
1384
1435
  #disposed = false;
1385
1436
  #interpolate = true;
1386
1437
  /** Draw between solved ticks; false presents this body at its true tick pose. */
@@ -1403,6 +1454,16 @@ var CharacterBody3D = class {
1403
1454
  this.gravity = options.gravity ?? -9.81;
1404
1455
  this.maxFallSpeed = options.maxFallSpeed ?? 50;
1405
1456
  this.oneWayLayers = options.oneWayLayers ?? 0;
1457
+ this.water = options.water;
1458
+ this.waterCurrent = options.waterCurrent;
1459
+ this.buoyancy = options.buoyancy ?? 1.6;
1460
+ this.maxSwimSpeed = options.maxSwimSpeed ?? 3;
1461
+ this.fluidFriction = options.fluidFriction ?? 12;
1462
+ if (!(this.buoyancy >= 0 && this.maxSwimSpeed > 0 && this.fluidFriction >= 0))
1463
+ throw new Error(
1464
+ "CharacterBody3D needs buoyancy >= 0, maxSwimSpeed > 0 and fluidFriction >= 0."
1465
+ );
1466
+ this.#halfHeight = halfHeightOf(options.shape);
1406
1467
  const shape = options.shape.descriptor;
1407
1468
  if (options.collisionLayer !== void 0 || options.collisionMask !== void 0) {
1408
1469
  const layer = options.collisionLayer ?? shape.collisionLayer;
@@ -1466,30 +1527,69 @@ var CharacterBody3D = class {
1466
1527
  moveAndSlide(dt) {
1467
1528
  if (!Number.isFinite(dt) || dt < 0)
1468
1529
  throw new Error("CharacterBody3D.moveAndSlide requires a finite non-negative dt.");
1469
- this.velocity.y = Math.max(this.velocity.y + this.gravity * dt, -this.maxFallSpeed);
1470
- this.#desired.x = this.velocity.x * dt;
1530
+ const depth = this.#immerse();
1531
+ let fall = this.gravity;
1532
+ if (this.swimming) {
1533
+ const rise = 0.33 * this.maxSwimSpeed;
1534
+ if (this.velocity.y > rise) this.velocity.y = Math.max(rise, this.velocity.y * depth * depth);
1535
+ this.velocity.y *= 1 - Math.min(0.5 * this.fluidFriction * depth * dt, 1);
1536
+ fall *= 1 - this.buoyancy * depth;
1537
+ }
1538
+ this.velocity.y = Math.max(this.velocity.y + fall * dt, -this.maxFallSpeed);
1539
+ if (depth > 0) {
1540
+ const cap = this.maxSwimSpeed / Math.min(1, 2 * depth);
1541
+ const speed = Math.hypot(this.velocity.x, this.velocity.z);
1542
+ if (speed > cap) {
1543
+ this.velocity.x *= cap / speed;
1544
+ this.velocity.z *= cap / speed;
1545
+ }
1546
+ }
1547
+ this.#carry(depth);
1548
+ this.#desired.x = (this.velocity.x + this.currentVelocity.x) * dt;
1471
1549
  this.#desired.y = this.velocity.y * dt;
1472
- this.#desired.z = this.velocity.z * dt;
1550
+ this.#desired.z = (this.velocity.z + this.currentVelocity.z) * dt;
1473
1551
  this.#sliding = true;
1474
1552
  }
1475
1553
  /** Called by the shared plugin before a bulk step. */
1476
1554
  writeKinematic(buffer, offset) {
1477
1555
  if (this.#disposed) return;
1478
- this.#beforeY = this.object.position.y;
1479
1556
  this.#desiredY = this.#desired.y;
1480
1557
  const carry = this.#sliding && this.grounded && this.velocity.y <= 0 && this.#groundCollider !== void 0 ? this.#physics?.kinematicMotion?.(this.#groundCollider) : void 0;
1481
1558
  const carryX = carry?.x ?? 0;
1482
1559
  const carryY = carry?.y ?? 0;
1483
1560
  const carryZ = carry?.z ?? 0;
1561
+ this.#still = this.#sliding && this.grounded && this.#desired.x === 0 && this.#desired.z === 0 && // Seating lets the gravity step land a lifted body: with no gravity step there is nothing to
1562
+ // seat, and a lift would never come back down.
1563
+ this.#desired.y < 0 && carryX === 0 && carryY === 0 && carryZ === 0 && (this.groundBody === void 0 || this.#physics?.groundHolds?.(this.groundBody.id) !== false);
1564
+ const from = this.#startPose();
1565
+ this.#from.x = from.x;
1566
+ this.#from.y = from.y;
1567
+ this.#from.z = from.z;
1568
+ this.#beforeY = from.y;
1569
+ if (!this.#still) this.#seat = 0 /* Step */;
1570
+ const travelY = this.#seat === 3 /* Rest */ ? 0 : this.#seat === 1 /* Lift */ ? Math.min(SEAT_LIFT, -this.#desired.y) : this.#desired.y;
1484
1571
  buffer[offset] = this.body.id;
1485
- buffer[offset + 1] = this.object.position.x + this.#desired.x + carryX;
1486
- buffer[offset + 2] = this.object.position.y + this.#desired.y + carryY;
1487
- buffer[offset + 3] = this.object.position.z + this.#desired.z + carryZ;
1572
+ buffer[offset + 1] = from.x + this.#desired.x + carryX;
1573
+ buffer[offset + 2] = from.y + travelY + carryY;
1574
+ buffer[offset + 3] = from.z + this.#desired.z + carryZ;
1488
1575
  buffer[offset + 4] = this.object.quaternion.x;
1489
1576
  buffer[offset + 5] = this.object.quaternion.y;
1490
1577
  buffer[offset + 6] = this.object.quaternion.z;
1491
1578
  buffer[offset + 7] = this.object.quaternion.w;
1492
1579
  }
1580
+ /**
1581
+ * Where this step starts. A lift is not shown, so the object can trail the body by one step and
1582
+ * the step then starts from the solver's pose. A body that moves from the middle of a seating
1583
+ * cycle leaves the unshown lift behind and starts from the pose the player sees, so a jump rises
1584
+ * the same height on every step of the cycle. An object the game moved itself starts from where
1585
+ * the game put it.
1586
+ */
1587
+ #startPose() {
1588
+ const at = this.object.position;
1589
+ const shown = this.#shown;
1590
+ const trailing = at.x === shown.x && at.y === shown.y && at.z === shown.z;
1591
+ return trailing && (this.#still || this.#seat !== 2 /* Check */) ? this.#solved : at;
1592
+ }
1493
1593
  syncToPhysics() {
1494
1594
  }
1495
1595
  step() {
@@ -1525,7 +1625,15 @@ var CharacterBody3D = class {
1525
1625
  this.#clearGroundState();
1526
1626
  }
1527
1627
  if (this.#sliding && this.grounded && this.velocity.y < 0) this.velocity.y = 0;
1528
- this.object.position.set(x, y, z);
1628
+ const lifted = this.#seat === 1 /* Lift */;
1629
+ this.#seated(x - this.#from.x, y - this.#from.y, z - this.#from.z);
1630
+ this.#solved.x = x;
1631
+ this.#solved.y = y;
1632
+ this.#solved.z = z;
1633
+ if (!lifted) this.object.position.set(x, y, z);
1634
+ this.#shown.x = this.object.position.x;
1635
+ this.#shown.y = this.object.position.y;
1636
+ this.#shown.z = this.object.position.z;
1529
1637
  setRotationIfChanged(this.object.quaternion, qx, qy, qz, qw);
1530
1638
  this.#desired.x = 0;
1531
1639
  this.#desired.y = 0;
@@ -1555,6 +1663,55 @@ var CharacterBody3D = class {
1555
1663
  this.#simulation.removeBody(this.body.id);
1556
1664
  this.#clearGroundState();
1557
1665
  }
1666
+ /**
1667
+ * UE 5.8.3 river forces settle a floating body at the water's own speed, so a swimmer (centre
1668
+ * under, `immersionDepth > 0.5`) takes the whole current. A wader's feet hold the bed: it takes
1669
+ * `(2 * depth)^2` of it, drag on the wetted height, which reaches the whole current exactly where
1670
+ * swimming starts, so stepping off the bed is not a jolt. A lake's current is zero.
1671
+ */
1672
+ #carry(depth) {
1673
+ const query = this.waterCurrent;
1674
+ const current = depth > 0 && query !== void 0 ? query(this.object.position.x, this.object.position.z) : void 0;
1675
+ if (current !== void 0 && (!Number.isFinite(current.x) || !Number.isFinite(current.z)))
1676
+ throw new Error(
1677
+ "CharacterBody3D.waterCurrent must return finite x and z in m/s, or undefined."
1678
+ );
1679
+ const share = Math.min(1, 2 * depth) ** 2;
1680
+ this.currentVelocity.x = current === void 0 ? 0 : current.x * share;
1681
+ this.currentVelocity.z = current === void 0 ? 0 : current.z * share;
1682
+ }
1683
+ /** UE 5.8.3 ImmersionDepth: the share of the collider below the surface, from top to bottom. */
1684
+ #immerse() {
1685
+ const { x, y, z } = this.object.position;
1686
+ const surface = this.water?.(x, z);
1687
+ if (surface !== void 0 && !Number.isFinite(surface))
1688
+ throw new Error("CharacterBody3D.water must return a finite surface height or undefined.");
1689
+ const half = this.#halfHeight;
1690
+ if (surface !== void 0 && half === void 0)
1691
+ throw new Error("CharacterBody3D.water needs a capsule, box or sphere shape to measure.");
1692
+ this.waterSurface = surface;
1693
+ this.immersionDepth = surface === void 0 || half === void 0 ? 0 : Math.min(1, Math.max(0, (surface - y + half) / (2 * half)));
1694
+ this.swimming = this.immersionDepth > 0.5;
1695
+ return this.immersionDepth;
1696
+ }
1697
+ /** Advances the seat from the solver's answer to the step that just ran. */
1698
+ #seated(dx, dy, dz) {
1699
+ if (this.#seat === 3 /* Rest */ && this.#still && this.grounded) return;
1700
+ const band = Math.max(SEAT_BAND, -0.25 * this.#desiredY);
1701
+ if (!this.#still || !this.grounded || this.groundNormal.y < SEAT_GROUND_Y || Math.abs(dx) >= band || Math.abs(dz) >= band) {
1702
+ this.#seat = 0 /* Step */;
1703
+ this.#lifts = 0;
1704
+ } else if (this.#seat === 0 /* Step */) {
1705
+ if (Math.abs(dy) < band) this.#seat = 1 /* Lift */;
1706
+ } else if (this.#seat === 1 /* Lift */) {
1707
+ this.#seat = 2 /* Check */;
1708
+ } else if (dy >= 0) {
1709
+ this.#lifts += 1;
1710
+ this.#seat = this.#lifts < SEAT_LIFTS ? 1 /* Lift */ : 3 /* Rest */;
1711
+ } else if (dy > this.#desiredY + SEAT_STOPPED) {
1712
+ this.#seat = 3 /* Rest */;
1713
+ }
1714
+ }
1558
1715
  #clearGroundState() {
1559
1716
  this.grounded = false;
1560
1717
  this.#groundCollider = void 0;
@@ -1563,24 +1720,39 @@ var CharacterBody3D = class {
1563
1720
  this.slopeAngle = 0;
1564
1721
  }
1565
1722
  };
1566
-
1567
- // src/CollisionShape3D.ts
1723
+ function attributeStorage(attribute, itemSize) {
1724
+ if (attribute.isInterleavedBufferAttribute === true) return void 0;
1725
+ if (attribute.normalized || attribute.itemSize !== itemSize) return void 0;
1726
+ return attribute.array.length === attribute.count * itemSize ? attribute.array : void 0;
1727
+ }
1568
1728
  function geometryVertices(mesh) {
1569
1729
  const position = mesh.geometry.getAttribute("position");
1570
1730
  if (position === void 0)
1571
1731
  throw new Error("CollisionShape3D.fromMesh requires vertex positions.");
1572
1732
  const vertices = new Float32Array(position.count * 3);
1573
- for (let index = 0; index < position.count; index++) {
1574
- vertices[index * 3] = position.getX(index) * mesh.scale.x;
1575
- vertices[index * 3 + 1] = position.getY(index) * mesh.scale.y;
1576
- vertices[index * 3 + 2] = position.getZ(index) * mesh.scale.z;
1733
+ const storage = attributeStorage(position, 3);
1734
+ if (storage === void 0)
1735
+ for (let index = 0; index < position.count; index++) {
1736
+ vertices[index * 3] = position.getX(index);
1737
+ vertices[index * 3 + 1] = position.getY(index);
1738
+ vertices[index * 3 + 2] = position.getZ(index);
1739
+ }
1740
+ else vertices.set(storage);
1741
+ const { x, y, z } = mesh.scale;
1742
+ if (x === 1 && y === 1 && z === 1) return vertices;
1743
+ for (let index = 0; index < vertices.length; index += 3) {
1744
+ vertices[index] = vertices[index] * x;
1745
+ vertices[index + 1] = vertices[index + 1] * y;
1746
+ vertices[index + 2] = vertices[index + 2] * z;
1577
1747
  }
1578
1748
  return vertices;
1579
1749
  }
1580
1750
  function geometryIndices(mesh) {
1581
1751
  const index = mesh.geometry.getIndex();
1582
- if (index !== null)
1583
- return Uint32Array.from({ length: index.count }, (_, offset) => index.getX(offset));
1752
+ if (index !== null) {
1753
+ const storage = attributeStorage(index, 1);
1754
+ return storage === void 0 ? Uint32Array.from({ length: index.count }, (_, offset) => index.getX(offset)) : Uint32Array.from(storage);
1755
+ }
1584
1756
  const count = mesh.geometry.getAttribute("position")?.count ?? 0;
1585
1757
  if (count === 0 || count % 3 !== 0)
1586
1758
  throw new Error("CollisionShape3D.fromMesh requires triangle indices.");
@@ -1700,8 +1872,28 @@ var CollisionShape3D = class _CollisionShape3D {
1700
1872
  scale
1701
1873
  });
1702
1874
  }
1875
+ /** Godot's ConcavePolygonShape3D: x, y, z vertex triples in body-local metres and triangle indices. */
1876
+ static trimesh(vertices, indices) {
1877
+ if (vertices.length < 9 || vertices.length % 3 !== 0 || indices.length < 3 || indices.length % 3 !== 0)
1878
+ throw new Error("CollisionShape3D.trimesh requires vertex triples and triangle indices.");
1879
+ return new _CollisionShape3D({
1880
+ collisionLayer: 1,
1881
+ collisionMask: 65535,
1882
+ kind: "trimesh",
1883
+ sensor: false,
1884
+ x: 0,
1885
+ y: 0,
1886
+ z: 0,
1887
+ vertices,
1888
+ indices
1889
+ });
1890
+ }
1703
1891
  static fromMesh(mesh, kind) {
1704
1892
  const geometry = mesh.geometry;
1893
+ if ((kind === "trimesh" || kind === "convexHull") && isStreamedGeometry(geometry))
1894
+ console.warn(
1895
+ `TN_COLLIDER_COARSE: CollisionShape3D.fromMesh(${JSON.stringify(mesh.name)}, "${kind}") copies the streamed coarse model's vertices; load it with ctx.assets.model(path, { whole: true }) to collide with the full one.`
1896
+ );
1705
1897
  const inferred = kind ?? (geometry.type.toLowerCase().includes("sphere") ? "sphere" : geometry.type.toLowerCase().includes("capsule") ? "capsule" : "box");
1706
1898
  if (inferred === "trimesh")
1707
1899
  return new _CollisionShape3D({
@@ -2239,7 +2431,6 @@ var scratchWorld = new Matrix4();
2239
2431
  var scratchPosition = new Vector3();
2240
2432
  var scratchScale = new Vector3();
2241
2433
  var scratchRotation = new Quaternion();
2242
- var scratchBounds = new Box3();
2243
2434
  function optionsFor(filter) {
2244
2435
  return typeof filter === "function" ? { predicate: filter } : filter ?? {};
2245
2436
  }
@@ -2267,8 +2458,14 @@ function configureCarrier(carrier, transform, scale) {
2267
2458
  carrier.updateMatrixWorld(true);
2268
2459
  }
2269
2460
  function isReachable(carrier, ceiling) {
2270
- scratchBounds.setFromObject(carrier, true);
2271
- return !scratchBounds.isEmpty() && scratchBounds.min.y < ceiling;
2461
+ const position = carrier.geometry.getAttribute("position");
2462
+ if (position === void 0 || position.count === 0) return false;
2463
+ const e = carrier.matrixWorld.elements;
2464
+ const [m1, m5, m9, m13] = [e[1] ?? 0, e[5] ?? 0, e[9] ?? 0, e[13] ?? 0];
2465
+ for (let i = 0; i < position.count; i++)
2466
+ if (m1 * position.getX(i) + m5 * position.getY(i) + m9 * position.getZ(i) + m13 < ceiling)
2467
+ return true;
2468
+ return false;
2272
2469
  }
2273
2470
  function addCollider(context, source, transform, options) {
2274
2471
  const carrier = new Mesh(source.geometry);
@@ -2326,6 +2523,233 @@ function buildStaticColliders(context, root, filter) {
2326
2523
  throw new Error("buildStaticColliders produced zero colliders; check the scene and predicate.");
2327
2524
  return bodies;
2328
2525
  }
2526
+ var MIN_HEIGHT = 0.25;
2527
+ var MIN_TRUNK_RADIUS = 0.05;
2528
+ var TRUNK_BAND = 0.1;
2529
+ var SLENDER = 0.15;
2530
+ var NONE = 0;
2531
+ var HULL = 1;
2532
+ var TRUNK = 2;
2533
+ var KDOP18 = [
2534
+ [1, 0, 0],
2535
+ [0, 1, 0],
2536
+ [0, 0, 1],
2537
+ [0, 1, 1],
2538
+ [0, 1, -1],
2539
+ [1, 0, 1],
2540
+ [1, 0, -1],
2541
+ [1, 1, 0],
2542
+ [1, -1, 0]
2543
+ ].flatMap(([x = 0, y = 0, z = 0]) => {
2544
+ const direction = new Vector3(x, y, z).normalize();
2545
+ return [direction, direction.clone().negate()];
2546
+ });
2547
+ function kdopCorners(extent, eps) {
2548
+ const corners = [];
2549
+ const [bc, ca, ab] = [new Vector3(), new Vector3(), new Vector3()];
2550
+ KDOP18.forEach((a, i) => {
2551
+ KDOP18.forEach((b, j) => {
2552
+ KDOP18.forEach((c, k) => {
2553
+ if (j <= i || k <= j) return;
2554
+ const det = a.dot(bc.crossVectors(b, c));
2555
+ if (Math.abs(det) < 1e-6) return;
2556
+ ca.crossVectors(c, a);
2557
+ ab.crossVectors(a, b);
2558
+ const corner = bc.clone().multiplyScalar(extent[i]).addScaledVector(ca, extent[j]).addScaledVector(ab, extent[k]).divideScalar(det);
2559
+ const outside = KDOP18.some((d, plane) => d.dot(corner) > extent[plane] + eps);
2560
+ if (!outside && !corners.some((seen) => seen.distanceTo(corner) < eps))
2561
+ corners.push(corner);
2562
+ });
2563
+ });
2564
+ });
2565
+ return corners;
2566
+ }
2567
+ function kdopSurface(points, size) {
2568
+ const extent = KDOP18.map(
2569
+ (direction) => points.reduce((max, point) => Math.max(max, direction.dot(point)), Number.NEGATIVE_INFINITY)
2570
+ );
2571
+ const eps = 1e-3 * size;
2572
+ const corners = kdopCorners(extent, eps);
2573
+ const indices = [];
2574
+ const [centre, u, v, offset] = [new Vector3(), new Vector3(), new Vector3(), new Vector3()];
2575
+ KDOP18.forEach((normal, plane) => {
2576
+ const face = corners.flatMap(
2577
+ (corner, index) => Math.abs(normal.dot(corner) - extent[plane]) <= eps ? [index] : []
2578
+ );
2579
+ if (face.length < 3) return;
2580
+ centre.set(0, 0, 0);
2581
+ for (const index of face) centre.add(corners[index]);
2582
+ centre.divideScalar(face.length);
2583
+ u.crossVectors(normal, Math.abs(normal.x) < 0.9 ? new Vector3(1, 0, 0) : new Vector3(0, 1, 0));
2584
+ v.crossVectors(normal, u);
2585
+ const angle = (index) => {
2586
+ offset.subVectors(corners[index], centre);
2587
+ return Math.atan2(offset.dot(v), offset.dot(u));
2588
+ };
2589
+ face.sort((left, right) => angle(left) - angle(right));
2590
+ for (let index = 1; index + 1 < face.length; index++)
2591
+ indices.push(face[0], face[index], face[index + 1]);
2592
+ });
2593
+ return { corners, indices: new Uint32Array(indices) };
2594
+ }
2595
+ var profiles = /* @__PURE__ */ new WeakMap();
2596
+ function profileOf(geometry) {
2597
+ const cached2 = profiles.get(geometry);
2598
+ if (cached2 !== void 0) return cached2;
2599
+ const position = geometry.getAttribute("position");
2600
+ if (position === void 0 || position.count < 4)
2601
+ throw new Error("ScatterColliders requires geometry with at least four vertex positions.");
2602
+ const points = Array.from(
2603
+ { length: position.count },
2604
+ (_, index) => new Vector3().fromBufferAttribute(position, index)
2605
+ );
2606
+ let [minY, maxY, reach, size] = [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY, 0, 1e-6];
2607
+ for (const point of points) {
2608
+ minY = Math.min(minY, point.y);
2609
+ maxY = Math.max(maxY, point.y);
2610
+ reach = Math.max(reach, Math.hypot(point.x, point.z));
2611
+ size = Math.max(size, Math.abs(point.x), Math.abs(point.y), Math.abs(point.z));
2612
+ }
2613
+ const height = maxY - minY;
2614
+ const band = points.filter((point) => point.y <= minY + TRUNK_BAND * height);
2615
+ const median = (axis) => band.map((point) => point[axis]).sort((a, b) => a - b)[band.length >> 1] ?? 0;
2616
+ const base = new Vector3(median("x"), minY, median("z"));
2617
+ const spread = band.map((point) => Math.hypot(point.x - base.x, point.z - base.z)).sort((a, b) => a - b);
2618
+ const radius = spread[Math.floor(spread.length * 0.9)] ?? 0;
2619
+ const profile = {
2620
+ minY,
2621
+ height,
2622
+ reach,
2623
+ base,
2624
+ radius,
2625
+ slender: radius <= SLENDER * height,
2626
+ hull: kdopSurface(points, size)
2627
+ };
2628
+ profiles.set(geometry, profile);
2629
+ return profile;
2630
+ }
2631
+ var column = new Vector3();
2632
+ function scales(matrix) {
2633
+ const x = column.setFromMatrixColumn(matrix, 0).length();
2634
+ const z = column.setFromMatrixColumn(matrix, 2).length();
2635
+ return { up: column.setFromMatrixColumn(matrix, 1).length(), across: Math.max(x, z) };
2636
+ }
2637
+ function classify(instance) {
2638
+ const collision = instance.collision ?? "auto";
2639
+ if (collision === "none") return NONE;
2640
+ if (collision === "hull") return HULL;
2641
+ if (collision === "trunk") return TRUNK;
2642
+ if (collision !== "auto")
2643
+ throw new Error(`ScatterColliders collision '${String(collision)}' is unknown.`);
2644
+ const profile = profileOf(instance.geometry);
2645
+ const { up, across } = scales(instance.matrix);
2646
+ if (profile.height * up < MIN_HEIGHT) return NONE;
2647
+ if (!profile.slender) return HULL;
2648
+ return profile.radius * across < MIN_TRUNK_RADIUS ? NONE : TRUNK;
2649
+ }
2650
+ var ScatterColliders = class {
2651
+ #physics;
2652
+ #follow;
2653
+ #radius;
2654
+ #layer;
2655
+ #mask;
2656
+ #instances = [];
2657
+ #resident = /* @__PURE__ */ new Map();
2658
+ #counts = { hulls: 0, trunks: 0, skipped: 0 };
2659
+ #lastX = Number.NaN;
2660
+ #lastZ = Number.NaN;
2661
+ #disposed = false;
2662
+ constructor(options) {
2663
+ if (options?.physics === void 0)
2664
+ throw new Error("ScatterColliders requires a physics context.");
2665
+ const radius = options.radius ?? 40;
2666
+ if (!Number.isFinite(radius) || radius <= 0)
2667
+ throw new Error(
2668
+ `ScatterColliders radius must be a positive finite number, received ${String(radius)}.`
2669
+ );
2670
+ this.#physics = options.physics;
2671
+ this.#follow = options.follow;
2672
+ this.#radius = radius;
2673
+ this.#layer = options.collisionLayer;
2674
+ this.#mask = options.collisionMask;
2675
+ for (const instance of options.instances) {
2676
+ const kind = classify(instance);
2677
+ if (kind === NONE) {
2678
+ this.#counts.skipped++;
2679
+ continue;
2680
+ }
2681
+ const x = instance.matrix.elements[12];
2682
+ const z = instance.matrix.elements[14];
2683
+ if (!Number.isFinite(x) || !Number.isFinite(z))
2684
+ throw new Error(
2685
+ `ScatterColliders instance ${this.#instances.length} has a non-finite position.`
2686
+ );
2687
+ const reach = profileOf(instance.geometry).reach * scales(instance.matrix).across;
2688
+ this.#instances.push({ instance, kind, x, z, reach });
2689
+ if (kind === HULL) this.#counts.hulls++;
2690
+ else this.#counts.trunks++;
2691
+ }
2692
+ console.info(`TN_SCATTER_COLLIDERS:${JSON.stringify({ ...this.#counts, radius })}`);
2693
+ }
2694
+ /** Create the bodies the follow point nears and release the ones it left. Cheap to call per frame. */
2695
+ update() {
2696
+ if (this.#disposed) return;
2697
+ const { x, z } = this.#follow.position;
2698
+ if (Math.hypot(x - this.#lastX, z - this.#lastZ) < this.#radius / 4) return;
2699
+ this.#lastX = x;
2700
+ this.#lastZ = z;
2701
+ this.#instances.forEach((entry, index) => {
2702
+ const gap = Math.hypot(entry.x - x, entry.z - z) - entry.reach;
2703
+ const body = this.#resident.get(index);
2704
+ if (gap <= this.#radius) {
2705
+ if (body === void 0) this.#resident.set(index, this.#create(entry.instance, entry.kind));
2706
+ } else if (body !== void 0 && gap > this.#radius * 1.25) {
2707
+ body.dispose();
2708
+ this.#resident.delete(index);
2709
+ }
2710
+ });
2711
+ }
2712
+ #create(instance, kind) {
2713
+ const profile = profileOf(instance.geometry);
2714
+ const origin = new Vector3().setFromMatrixPosition(instance.matrix);
2715
+ const linear = new Matrix3().setFromMatrix4(instance.matrix);
2716
+ const common = {
2717
+ physics: this.#physics,
2718
+ type: "fixed",
2719
+ collisionLayer: this.#layer,
2720
+ collisionMask: this.#mask
2721
+ };
2722
+ if (kind === TRUNK) {
2723
+ const { up, across } = scales(instance.matrix);
2724
+ const height = profile.height * up;
2725
+ const radius = Math.max(MIN_TRUNK_RADIUS, profile.radius * across);
2726
+ const base = profile.base.clone().applyMatrix3(linear).add(origin);
2727
+ return new RigidBody3D({
2728
+ ...common,
2729
+ position: { x: base.x, y: base.y + height / 2, z: base.z },
2730
+ shape: CollisionShape3D.capsule(Math.max(0, height / 2 - radius), radius)
2731
+ });
2732
+ }
2733
+ const vertices = new Float32Array(profile.hull.corners.length * 3);
2734
+ profile.hull.corners.forEach((corner, index) => {
2735
+ corner.clone().applyMatrix3(linear).toArray(vertices, index * 3);
2736
+ });
2737
+ return new RigidBody3D({
2738
+ ...common,
2739
+ position: origin,
2740
+ shape: CollisionShape3D.trimesh(vertices, profile.hull.indices)
2741
+ });
2742
+ }
2743
+ stats() {
2744
+ return { instances: this.#instances.length, ...this.#counts, resident: this.#resident.size };
2745
+ }
2746
+ dispose() {
2747
+ if (this.#disposed) return;
2748
+ this.#disposed = true;
2749
+ for (const body of this.#resident.values()) body.dispose();
2750
+ this.#resident.clear();
2751
+ }
2752
+ };
2329
2753
  var ONE = new Vector3(1, 1, 1);
2330
2754
  var PhysicsSoftBodyCollision = class {
2331
2755
  capacity;
@@ -2397,11 +2821,11 @@ function softBodyCollision(...bodies) {
2397
2821
  }
2398
2822
  function unionBounds(current, next) {
2399
2823
  if (current === void 0) return next;
2400
- const column = Math.min(current.column, next.column);
2824
+ const column2 = Math.min(current.column, next.column);
2401
2825
  const row = Math.min(current.row, next.row);
2402
2826
  return {
2403
- column,
2404
- columns: Math.max(current.column + current.columns, next.column + next.columns) - column,
2827
+ column: column2,
2828
+ columns: Math.max(current.column + current.columns, next.column + next.columns) - column2,
2405
2829
  row,
2406
2830
  rows: Math.max(current.row + current.rows, next.row + next.rows) - row
2407
2831
  };
@@ -2551,7 +2975,7 @@ function attachSnowPhysics(options) {
2551
2975
  let contacts = 0;
2552
2976
  let supported = 0;
2553
2977
  let load = 0;
2554
- let version2 = snow.version;
2978
+ let version = snow.version;
2555
2979
  let disposed = false;
2556
2980
  function surfaceDescriptor() {
2557
2981
  return {
@@ -2595,10 +3019,10 @@ function attachSnowPhysics(options) {
2595
3019
  function windowGap(window) {
2596
3020
  let gap = 0;
2597
3021
  const rows = field.rows;
2598
- for (let column = window.column; column < window.column + window.columns; column += 1) {
3022
+ for (let column2 = window.column; column2 < window.column + window.columns; column2 += 1) {
2599
3023
  for (let row = window.row; row < window.row + window.rows; row += 1) {
2600
- const installed = colliderHeights[column * rows + row];
2601
- gap = Math.max(gap, Math.abs(field.colliderHeight(row, column) - installed));
3024
+ const installed = colliderHeights[column2 * rows + row];
3025
+ gap = Math.max(gap, Math.abs(field.colliderHeight(row, column2) - installed));
2602
3026
  }
2603
3027
  }
2604
3028
  return gap;
@@ -2700,7 +3124,7 @@ function attachSnowPhysics(options) {
2700
3124
  return surfaceVersion;
2701
3125
  },
2702
3126
  get version() {
2703
- return version2;
3127
+ return version;
2704
3128
  },
2705
3129
  observe() {
2706
3130
  return {
@@ -2731,7 +3155,7 @@ function attachSnowPhysics(options) {
2731
3155
  const wind = Math.max(0, finiteOr(binding.wind, 0, "wind"));
2732
3156
  if (deposition > 0 || wind > 0) snow.recover(deltaTime, deposition, wind);
2733
3157
  refreshSurface();
2734
- version2 = snow.version;
3158
+ version = snow.version;
2735
3159
  },
2736
3160
  dispose() {
2737
3161
  if (disposed) return;
@@ -2758,8 +3182,8 @@ function footprintArea(footprint) {
2758
3182
  let area = 0;
2759
3183
  for (let row = 0; row < steps; row += 1) {
2760
3184
  const z = -footprint.extent + (row + 0.5) * step;
2761
- for (let column = 0; column < steps; column += 1) {
2762
- const x = -footprint.extent + (column + 0.5) * step;
3185
+ for (let column2 = 0; column2 < steps; column2 += 1) {
3186
+ const x = -footprint.extent + (column2 + 0.5) * step;
2763
3187
  area += footprint.sample(x, z).coverage * step * step;
2764
3188
  }
2765
3189
  }
@@ -2793,7 +3217,8 @@ function visibleId(buffer, offset) {
2793
3217
  throw new Error("IPhysicsSimulation returned an invalid visible body id.");
2794
3218
  return value;
2795
3219
  }
2796
- function rapier2(options = {}) {
3220
+ var PHYSICS_READY = /* @__PURE__ */ Symbol.for("threenative.physics.ready");
3221
+ function rapier(options = {}) {
2797
3222
  const backend = physicsSimulationBackend();
2798
3223
  let simulation;
2799
3224
  let context;
@@ -2814,6 +3239,7 @@ function rapier2(options = {}) {
2814
3239
  let debugSeries = [];
2815
3240
  let completedSteps = 0;
2816
3241
  let gameContext;
3242
+ let generations = 0;
2817
3243
  const interpolationRemovals = /* @__PURE__ */ new Map();
2818
3244
  function updateInterpolation(body) {
2819
3245
  interpolationRemovals.get(body)?.();
@@ -2841,6 +3267,10 @@ function rapier2(options = {}) {
2841
3267
  addBuoyancy: (buoyancy) => buoyancies.add(buoyancy),
2842
3268
  eventQueue: physicsHandle(selected.rawEventQueue),
2843
3269
  kinematicMotion: (colliderHandle) => kinematicMotions.get(colliderHandle),
3270
+ groundHolds: (bodyId2) => {
3271
+ const ground = bodiesById.get(bodyId2);
3272
+ return ground === void 0 || ground instanceof RigidBody3D && ground.type !== "dynamic";
3273
+ },
2844
3274
  numBodies: () => bodies.size,
2845
3275
  remove: (body) => {
2846
3276
  interpolationRemovals.get(body)?.();
@@ -2861,19 +3291,36 @@ function rapier2(options = {}) {
2861
3291
  };
2862
3292
  }
2863
3293
  return {
2864
- setup: async (ctx, runtime) => {
3294
+ // Rapier's Wasm initializes while the scene loads: a game builds bodies in `enter()`, and the
3295
+ // start gate holds `enter()` until `ctx.physics` is set, so a first visit does not wait for
3296
+ // Rapier before loading its textures and world (PRD-860). With no gate, setup awaits it.
3297
+ setup: (ctx, runtime) => {
2865
3298
  gameContext = ctx;
2866
- await backend.initialize();
2867
- const selected = backend.createSimulation(options);
2868
- simulation = selected;
2869
- if (runtime !== void 0) runtime.rapier = selected.version;
2870
- context = buildContext(selected);
2871
- ctx.physics = context;
2872
- unregisterObservations = runtime?.observations?.contribute({
2873
- capabilities: ["runtime.physics"],
2874
- sample: (request) => physicsObservations(ctx, runtime, request)
3299
+ const generation = ++generations;
3300
+ const ready = backend.initialize().then(() => {
3301
+ if (generation !== generations) {
3302
+ console.warn(
3303
+ "TN_PHYSICS_SETUP_SUPERSEDED: rapier initialized after its game was disposed; nothing was installed."
3304
+ );
3305
+ return void 0;
3306
+ }
3307
+ const selected = backend.createSimulation(options);
3308
+ simulation = selected;
3309
+ if (runtime !== void 0) runtime.rapier = selected.version;
3310
+ const built = buildContext(selected);
3311
+ context = built;
3312
+ ctx.physics = built;
3313
+ unregisterObservations = runtime?.observations?.contribute({
3314
+ capabilities: ["runtime.physics"],
3315
+ sample: (request) => physicsObservations(ctx, runtime, request)
3316
+ });
3317
+ return built;
2875
3318
  });
2876
- return unregisterObservations;
3319
+ Object.defineProperty(ctx, PHYSICS_READY, { configurable: true, value: ready });
3320
+ const cleanup = () => unregisterObservations?.();
3321
+ if (runtime?.holdStart === void 0) return ready.then(() => cleanup);
3322
+ void runtime.holdStart(ready.then(() => void 0)).catch(() => void 0);
3323
+ return cleanup;
2877
3324
  },
2878
3325
  update: (_ctx, dt) => {
2879
3326
  if (simulation === void 0) throw new Error("Physics plugin updated before setup.");
@@ -3005,6 +3452,7 @@ function rapier2(options = {}) {
3005
3452
  ctx.physics = context;
3006
3453
  },
3007
3454
  dispose: () => {
3455
+ generations += 1;
3008
3456
  unregisterObservations?.();
3009
3457
  unregisterObservations = void 0;
3010
3458
  for (const buoyancy of [...buoyancies]) buoyancy.dispose();
@@ -3304,4 +3752,4 @@ var VehicleBody3D = class extends RigidBody3D {
3304
3752
  }
3305
3753
  };
3306
3754
 
3307
- export { Area3D, Buoyancy3D, CharacterBody3D, CollisionShape3D, Joint3D, MAX_PHYSICS_QUERY_RESULTS, PHYSICS_COLLISION_EVENT_STRIDE, PHYSICS_TRANSFORM_STRIDE, PHYSICS_VEHICLE_WHEEL_STRIDE, PhysicsDirectSpaceState3D, RigidBody3D, VehicleBody3D, attachSnowPhysics, boxFootprint, buildStaticColliders, capsuleFootprint, interactionGroups, rapier2 as rapier, softBodyCollision };
3755
+ export { Area3D, Buoyancy3D, CharacterBody3D, CollisionShape3D, Joint3D, MAX_PHYSICS_QUERY_RESULTS, PHYSICS_COLLISION_EVENT_STRIDE, PHYSICS_TRANSFORM_STRIDE, PHYSICS_VEHICLE_WHEEL_STRIDE, PhysicsDirectSpaceState3D, RigidBody3D, ScatterColliders, VehicleBody3D, attachSnowPhysics, boxFootprint, buildStaticColliders, capsuleFootprint, interactionGroups, rapier, softBodyCollision };