@adatechnology/game-weapons-three 0.24.4 → 0.26.0

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/README.md CHANGED
@@ -62,3 +62,10 @@ Cenários: `explosives_p13_shot`, `explosives_p13_valve`, `explosives_p13_fire`,
62
62
  `createWeaponProps({ packs, patch, remove })` makes the weapon item model overrides of its own: the shipped ones plus `packs`. `packs` is a list of objects `{ [weaponId]: WeaponItemModel | null }` (`[{ axe: { item: 'hammer' }, baseball_bat: null }]`; `null` keeps the low-poly prop).
63
63
  `patch` merges fields by weapon id (`item`, `turn`, `flip`), `remove` lists weapon ids whose override is taken out. `props.buildModel`, `props.buildItemModel` and `props.itemModelOf` read that set; `buildModeledProp`, `buildTripodMountedProp` and `createWeaponsTestModule` take it as `props`.
64
64
  The global `registerWeaponItemModel` and the rest are deprecated delegates of `defaultWeaponProps()`.
65
+
66
+ ## Loose pieces in the physics engine (spec 008, T4.3)
67
+
68
+ `createWeaponFx({ physics })` takes a `SeamWorld` of `@adatechnology/game-physics`: the casings that the gallery's models eject become bodies of it (`casingCollider`: a cylinder along x, C_rr 0.015,
69
+ swept), roll, sleep and bounce by the world's floor; the host's loop steps the world. Without it they keep the gallery's own bounce. `explosiveCollider(THREE, 'm67')` is the grenade as drawn
70
+ (body, fuze and spoon, read from `M67_PARTS`, the numbers the drawing uses) with C_rr 0.015 and no artificial damping; `spawnLoose`, `syncLoose`
71
+ and `dropLoose` put a loose piece in the world, copy its pose onto a mesh (reporting a bounce and sleep) and take it out. Measured on the kit's floor (`KIT_WORLD`): 48 seeded throws rest in 4.03-5.95 s and within 7.39 m of where they land (the owner's limit for the drawn grenade is 6.5 s and 8 m: it rocks on its fuze); 200 of 200 casings asleep 5 s after the last, none under the floor.
@@ -9442,9 +9442,9 @@ var targetsOf = (THREE, hold, rootQuaternion, magazine, weights2) => {
9442
9442
  hold.works?.forEach((work, index) => {
9443
9443
  const k = weights2?.[index] ?? 0;
9444
9444
  if (k <= 0) return;
9445
- const pose = poseOf(work.anchor, rootQuaternion);
9446
- if (work.hand === "R") right = right ? blendPose(THREE, right, pose, k) : pose;
9447
- else left = left ? blendPose(THREE, left, pose, k) : pose;
9445
+ const pose2 = poseOf(work.anchor, rootQuaternion);
9446
+ if (work.hand === "R") right = right ? blendPose(THREE, right, pose2, k) : pose2;
9447
+ else left = left ? blendPose(THREE, left, pose2, k) : pose2;
9448
9448
  });
9449
9449
  const targets = { R: right, L: left, grip: hold.grip, gripL: hold.gripLeft, scale: hold.scale };
9450
9450
  if (hold.slideLeft && left) {
@@ -9757,11 +9757,17 @@ function drawItemWeapon({ THREE, def, items, itemId, turn: turn2, roll, flip, gr
9757
9757
 
9758
9758
  // src/models/explosives.ts
9759
9759
  import { markKitOrigin as markKitOrigin3 } from "@adatechnology/game-contracts";
9760
+ var M67_PARTS = {
9761
+ bodyRadius: 0.032,
9762
+ fuze: { radius: 0.011, height: 0.022, y: 0.04 },
9763
+ spoon: { size: [0.012, 0.07, 6e-3], x: 0.016, y: 0.018, tilt: 0.2 }
9764
+ };
9760
9765
  var grenade = (kit, group) => {
9761
9766
  const { M, sphere, cylinderY, box: box2, torus, THREE } = kit;
9762
- sphere(group, 0.032, M.olive, 0, 0.032, 0, 1);
9763
- cylinderY(group, 0.011, 0.022, M.metal, 0, 0.072, 0);
9764
- box2(group, 0.012, 0.07, 6e-3, M.metal, 0.016, 0.05, 0, 0.2);
9767
+ const { bodyRadius, fuze, spoon } = M67_PARTS;
9768
+ sphere(group, bodyRadius, M.olive, 0, bodyRadius, 0, 1);
9769
+ cylinderY(group, fuze.radius, fuze.height, M.metal, 0, bodyRadius + fuze.y, 0);
9770
+ box2(group, ...spoon.size, M.metal, spoon.x, bodyRadius + spoon.y, 0, spoon.tilt);
9765
9771
  torus(group, new THREE.TorusGeometry(85e-4, 16e-4, 6, 12), M.steel, -0.012, 0.082, 0);
9766
9772
  kit.mark(group, 0, 0.032, 0).name = "handle";
9767
9773
  };
@@ -10001,7 +10007,7 @@ function createBoxFx(options) {
10001
10007
  model.position.lerpVectors(holderAt, model.position, k);
10002
10008
  hand.updateMatrixWorld(true);
10003
10009
  };
10004
- const throwBody = (kind, mesh, from, velocity, radius) => {
10010
+ const throwBody = (kind, mesh, from, velocity2, radius) => {
10005
10011
  if (!(kind === "casing" ? layers.casings : layers.magazines)) {
10006
10012
  mesh.geometry.dispose();
10007
10013
  return;
@@ -10012,7 +10018,7 @@ function createBoxFx(options) {
10012
10018
  mesh.position.copy(from);
10013
10019
  mesh.castShadow = true;
10014
10020
  scene.add(mesh);
10015
- bodies.push({ mesh, velocity, spin: new THREE.Vector3(random() * 20 - 10, random() * 30 - 15, random() * 20 - 10), radius, age: 0, resting: false, bounces: 0, kind });
10021
+ bodies.push({ mesh, velocity: velocity2, spin: new THREE.Vector3(random() * 20 - 10, random() * 30 - 15, random() * 20 - 10), radius, age: 0, resting: false, bounces: 0, kind });
10016
10022
  };
10017
10023
  const ejectCasing = (caliberMm, isShell, downward) => {
10018
10024
  const radius = isShell ? 0.0105 : Math.max(3e-3, caliberMm / 1e3 * 0.6);
@@ -10022,8 +10028,8 @@ function createBoxFx(options) {
10022
10028
  const from = handPoint(0.03, 0.03, 0.05, new THREE.Vector3());
10023
10029
  const right = new THREE.Vector3(1, 0, 0).applyQuaternion(camera.quaternion);
10024
10030
  const up = new THREE.Vector3(0, 1, 0);
10025
- const velocity = downward ? up.clone().multiplyScalar(-0.5).addScaledVector(right, (random() - 0.5) * 0.4) : right.multiplyScalar(1.6 + random() * 0.8).addScaledVector(up, 1.4 + random() * 0.8);
10026
- throwBody("casing", mesh, from, velocity, radius);
10031
+ const velocity2 = downward ? up.clone().multiplyScalar(-0.5).addScaledVector(right, (random() - 0.5) * 0.4) : right.multiplyScalar(1.6 + random() * 0.8).addScaledVector(up, 1.4 + random() * 0.8);
10032
+ throwBody("casing", mesh, from, velocity2, radius);
10027
10033
  };
10028
10034
  const dropMagazine = (category) => {
10029
10035
  const long = category === "rifle" || category === "sniper" || category === "carbine";
@@ -10230,14 +10236,14 @@ function composeClip(id, tweens, events = [], minDuration = 0) {
10230
10236
  const poses = /* @__PURE__ */ new Map();
10231
10237
  for (const [key, list] of channels) {
10232
10238
  const [part, channel, axis] = key.split("|");
10233
- const pose = poses.get(part) ?? { position: [0, 0, 0], rotation: [0, 0, 0] };
10234
- pose[channel][AXIS_INDEX[axis]] = round(valueAt(list, t, includeInstants));
10235
- poses.set(part, pose);
10239
+ const pose2 = poses.get(part) ?? { position: [0, 0, 0], rotation: [0, 0, 0] };
10240
+ pose2[channel][AXIS_INDEX[axis]] = round(valueAt(list, t, includeInstants));
10241
+ poses.set(part, pose2);
10236
10242
  }
10237
10243
  const root = poses.get(ROOT);
10238
10244
  poses.delete(ROOT);
10239
10245
  const parts = {};
10240
- for (const [part, pose] of poses) parts[part] = pose;
10246
+ for (const [part, pose2] of poses) parts[part] = pose2;
10241
10247
  return { t, ...root ? { position: root.position, rotation: root.rotation } : {}, ...poses.size ? { parts } : {} };
10242
10248
  };
10243
10249
  const keys = [];
@@ -11336,13 +11342,13 @@ function createEffects(THREE, sink, random) {
11336
11342
  muzzleFlash(position, orientation, size, profile = MUZZLE_SMOKE.smokeless, track) {
11337
11343
  if (profile.puffs <= 0 && profile.flash <= 0) return;
11338
11344
  const follow = track ? () => {
11339
- const pose = track();
11340
- return pose ? { point: vec(pose.position), orientation: quaternion(pose.orientation) } : null;
11345
+ const pose2 = track();
11346
+ return pose2 ? { point: vec(pose2.position), orientation: quaternion(pose2.orientation) } : null;
11341
11347
  } : void 0;
11342
11348
  sink?.play({ effect: VIEWMODEL_EFFECT_IDS.flash, point: vec(position), direction: barrel(orientation), orientation: quaternion(orientation), seed: seed(), values: { size, ...profile }, ...follow ? { track: follow } : {} });
11343
11349
  },
11344
- smoke(position, velocity, size, life, opacity) {
11345
- sink?.play({ effect: VIEWMODEL_EFFECT_IDS.smoke, point: vec(position), seed: seed(), values: { vx: velocity.x, vy: velocity.y, vz: velocity.z, radius: size, life, opacity } });
11350
+ smoke(position, velocity2, size, life, opacity) {
11351
+ sink?.play({ effect: VIEWMODEL_EFFECT_IDS.smoke, point: vec(position), seed: seed(), values: { vx: velocity2.x, vy: velocity2.y, vz: velocity2.z, radius: size, life, opacity } });
11346
11352
  },
11347
11353
  backblast(rear, orientation) {
11348
11354
  sink?.play({ effect: VIEWMODEL_EFFECT_IDS.backblast, point: vec(rear), direction: barrel(orientation), orientation: quaternion(orientation), seed: seed() });
@@ -11508,6 +11514,85 @@ function pooledFlame(kit, pools, index) {
11508
11514
  return { geometry, material };
11509
11515
  }
11510
11516
 
11517
+ // src/engine-loose.ts
11518
+ var LOOSE_ROLLING_RESISTANCE = 0.015;
11519
+ var CASING_FILL = 0.25;
11520
+ var BRASS_DENSITY = 8500;
11521
+ var GRENADE_MASS_KG = 0.4;
11522
+ var LOOSE_USER = { casing: 100, grenade: 2 };
11523
+ var BOUNCE_FALL_SPEED = 0.5;
11524
+ var BOUNCE_RISE_SPEED = 0.2;
11525
+ var QUARTER_TURN_Z = [0, 0, Math.SQRT1_2, Math.SQRT1_2];
11526
+ var CASING_MATERIAL = { frictionStatic: 0.4, frictionDynamic: 0.3, restitution: 0.4 };
11527
+ var GRENADE_MATERIAL = { frictionStatic: 0.6, frictionDynamic: 0.5, restitution: 0.35 };
11528
+ function casingCollider(radius, length) {
11529
+ return {
11530
+ shape: { kind: "compound", children: [{ shape: { kind: "cylinder", halfHeight: length / 2, radius }, position: [0, 0, 0], rotation: QUARTER_TURN_Z }] },
11531
+ mass: Math.PI * radius * radius * length * BRASS_DENSITY * CASING_FILL,
11532
+ material: CASING_MATERIAL,
11533
+ rolling: { coefficient: LOOSE_ROLLING_RESISTANCE, radius },
11534
+ user: LOOSE_USER.casing
11535
+ };
11536
+ }
11537
+ function explosiveCollider(THREE, explosive) {
11538
+ if (explosive !== "m67") return void 0;
11539
+ const model = buildExplosiveModel(THREE, explosive);
11540
+ if (!model) return void 0;
11541
+ const centre = new THREE.Box3().setFromObject(model).getCenter(new THREE.Vector3());
11542
+ const { bodyRadius, fuze, spoon } = M67_PARTS;
11543
+ const at2 = (x, y) => [x - centre.x, y + bodyRadius - centre.y, 0 - centre.z];
11544
+ return {
11545
+ shape: {
11546
+ kind: "compound",
11547
+ children: [
11548
+ { shape: { kind: "sphere", radius: bodyRadius }, position: at2(0, 0) },
11549
+ { shape: { kind: "cylinder", halfHeight: fuze.height / 2, radius: fuze.radius }, position: at2(0, fuze.y) },
11550
+ { shape: { kind: "box", half: [spoon.size[0] / 2, spoon.size[1] / 2, spoon.size[2] / 2] }, position: at2(spoon.x, spoon.y), rotation: [0, 0, Math.sin(spoon.tilt / 2), Math.cos(spoon.tilt / 2)] }
11551
+ ]
11552
+ },
11553
+ mass: GRENADE_MASS_KG,
11554
+ material: GRENADE_MATERIAL,
11555
+ rolling: { coefficient: LOOSE_ROLLING_RESISTANCE, radius: bodyRadius },
11556
+ user: LOOSE_USER.grenade
11557
+ };
11558
+ }
11559
+ function spawnLoose(world, collider, launch) {
11560
+ const desc = {
11561
+ shape: collider.shape,
11562
+ motion: "dynamic",
11563
+ mass: collider.mass,
11564
+ position: [launch.position.x, launch.position.y, launch.position.z],
11565
+ rotation: [launch.rotation.x, launch.rotation.y, launch.rotation.z, launch.rotation.w],
11566
+ material: collider.material,
11567
+ layer: "debris",
11568
+ continuous: true,
11569
+ rolling: collider.rolling,
11570
+ linearVelocity: [launch.velocity.x, launch.velocity.y, launch.velocity.z],
11571
+ angularVelocity: [launch.spin.x, launch.spin.y, launch.spin.z],
11572
+ user: collider.user
11573
+ };
11574
+ return { id: world.createBody(desc), bounces: 0, fallSpeed: 0 };
11575
+ }
11576
+ var scratchReading = { asleep: false, bounceSpeed: void 0 };
11577
+ var pose = new Float64Array(7);
11578
+ var velocity = new Float64Array(6);
11579
+ function syncLoose(world, body, object) {
11580
+ world.readPose(body.id, pose, 0);
11581
+ world.readVelocity(body.id, velocity, 0);
11582
+ object.position.set(pose[0] ?? 0, pose[1] ?? 0, pose[2] ?? 0);
11583
+ object.quaternion.set(pose[3] ?? 0, pose[4] ?? 0, pose[5] ?? 0, pose[6] ?? 1);
11584
+ const vertical = velocity[1] ?? 0;
11585
+ const bounced = body.fallSpeed > BOUNCE_FALL_SPEED && vertical > BOUNCE_RISE_SPEED;
11586
+ scratchReading.bounceSpeed = bounced ? body.fallSpeed : void 0;
11587
+ body.fallSpeed = vertical < 0 ? -vertical : 0;
11588
+ if (bounced) body.bounces++;
11589
+ scratchReading.asleep = world.isSleeping(body.id);
11590
+ return scratchReading;
11591
+ }
11592
+ function dropLoose(world, body) {
11593
+ world.removeBody(body.id);
11594
+ }
11595
+
11511
11596
  // src/fx/particles.ts
11512
11597
  var MAX_PARTICLES = 900;
11513
11598
  var FLOOR_FRICTION = 0.45;
@@ -11522,7 +11607,7 @@ var disposeOwned = (object) => {
11522
11607
  if (mesh.isMesh) mesh.geometry.dispose();
11523
11608
  });
11524
11609
  };
11525
- function createParticles(THREE, scene, groundAt, limit, surface) {
11610
+ function createParticles(THREE, scene, groundAt, limit, surface, physics) {
11526
11611
  const from = new THREE.Vector3();
11527
11612
  const step = new THREE.Vector3();
11528
11613
  let list = [];
@@ -11532,6 +11617,7 @@ function createParticles(THREE, scene, groundAt, limit, surface) {
11532
11617
  });
11533
11618
  particle.object.removeFromParent();
11534
11619
  if (particle.ownsGeometry) disposeOwned(particle.object);
11620
+ if (particle.body && physics) dropLoose(physics, particle.body);
11535
11621
  particle.onRemove?.();
11536
11622
  if (particle.fadeFrom !== void 0) particle.object.material.dispose();
11537
11623
  list = list.filter((other) => other !== particle);
@@ -11547,24 +11633,24 @@ function createParticles(THREE, scene, groundAt, limit, surface) {
11547
11633
  if (!hit) return;
11548
11634
  const at2 = origin.y + travel.y * hit.distance;
11549
11635
  if (at2 <= groundAt(origin.x + travel.x * hit.distance, origin.z + travel.z * hit.distance) + radius + FLOOR_EPSILON) return;
11550
- const { velocity } = particle;
11551
- const impact = Math.abs(velocity.dot(hit.normal));
11636
+ const { velocity: velocity2 } = particle;
11637
+ const impact = Math.abs(velocity2.dot(hit.normal));
11552
11638
  object.position.copy(origin).addScaledVector(travel, Math.max(0, hit.distance - radius));
11553
- velocity.addScaledVector(hit.normal, -(1 + particle.bounce) * velocity.dot(hit.normal));
11554
- velocity.multiplyScalar(FLOOR_FRICTION);
11639
+ velocity2.addScaledVector(hit.normal, -(1 + particle.bounce) * velocity2.dot(hit.normal));
11640
+ velocity2.multiplyScalar(FLOOR_FRICTION);
11555
11641
  particle.spin.multiplyScalar(FLOOR_FRICTION);
11556
11642
  if (particle.bounces < 4) api.onBounce?.(particle.kind, { object, speed: impact, bounce: particle.bounces });
11557
11643
  particle.bounces++;
11558
11644
  };
11559
11645
  const api = {
11560
- spawn(object, velocity, options = {}) {
11646
+ spawn(object, velocity2, options = {}) {
11561
11647
  object.traverse((node) => {
11562
11648
  node.userData[PARTICLE_USERDATA_KEY] = true;
11563
11649
  });
11564
11650
  scene.add(object);
11565
11651
  list.push({
11566
11652
  object,
11567
- velocity,
11653
+ velocity: velocity2,
11568
11654
  spin: options.spin ?? new THREE.Vector3(),
11569
11655
  age: 0,
11570
11656
  resting: false,
@@ -11580,7 +11666,8 @@ function createParticles(THREE, scene, groundAt, limit, surface) {
11580
11666
  onGround: options.onGround,
11581
11667
  ownsGeometry: options.ownsGeometry ?? false,
11582
11668
  onRemove: options.onRemove,
11583
- bounces: 0
11669
+ bounces: 0,
11670
+ body: options.collider && physics ? spawnLoose(physics, options.collider, { position: object.position, rotation: object.quaternion, velocity: velocity2, spin: options.spin ?? new THREE.Vector3() }) : void 0
11584
11671
  });
11585
11672
  const hostLimit = limit?.();
11586
11673
  const oldest = list[0];
@@ -11597,6 +11684,13 @@ function createParticles(THREE, scene, groundAt, limit, surface) {
11597
11684
  const { object } = particle;
11598
11685
  if (particle.fadeFrom !== void 0) object.material.opacity = Math.max(0, particle.fadeFrom * (1 - particle.age / particle.life));
11599
11686
  if (particle.resting) continue;
11687
+ if (particle.body && physics) {
11688
+ const reading = syncLoose(physics, particle.body, object);
11689
+ if (reading.bounceSpeed !== void 0 && particle.bounces < 4) api.onBounce?.(particle.kind, { object, speed: reading.bounceSpeed, bounce: particle.bounces });
11690
+ if (reading.bounceSpeed !== void 0) particle.bounces++;
11691
+ if (reading.asleep) particle.resting = true;
11692
+ continue;
11693
+ }
11600
11694
  particle.velocity.y -= particle.gravity * dt;
11601
11695
  if (particle.drag) particle.velocity.multiplyScalar(Math.max(0, 1 - particle.drag * dt));
11602
11696
  const probed = surface !== void 0 && SOLID_KINDS.has(particle.kind) && probes < MAX_PROBES_PER_FRAME && particle.velocity.lengthSq() > PROBE_MIN_SPEED * PROBE_MIN_SPEED;
@@ -11645,20 +11739,20 @@ function createModelRig(model) {
11645
11739
  const registry = partRegistry(model.parts);
11646
11740
  const rest = /* @__PURE__ */ new Map();
11647
11741
  for (const part of [...registry.values(), model.root]) rest.set(part, { position: part.position.clone(), rotation: part.rotation.clone() });
11648
- const apply = (object, pose) => {
11742
+ const apply = (object, pose2) => {
11649
11743
  const base = rest.get(object);
11650
11744
  if (!base) return;
11651
- const [dx, dy, dz] = pose.position ?? [0, 0, 0];
11652
- const [rx, ry, rz] = pose.rotation ?? [0, 0, 0];
11745
+ const [dx, dy, dz] = pose2.position ?? [0, 0, 0];
11746
+ const [rx, ry, rz] = pose2.rotation ?? [0, 0, 0];
11653
11747
  object.position.set(base.position.x + dx, base.position.y + dy, base.position.z + dz);
11654
11748
  object.rotation.set(base.rotation.x + rx, base.rotation.y + ry, base.rotation.z + rz);
11655
11749
  };
11656
11750
  return {
11657
- setPartPose(partId, pose) {
11751
+ setPartPose(partId, pose2) {
11658
11752
  const part = registry.get(partId);
11659
- if (part) apply(part, pose);
11753
+ if (part) apply(part, pose2);
11660
11754
  },
11661
- setRootPose: (pose) => apply(model.root, pose)
11755
+ setRootPose: (pose2) => apply(model.root, pose2)
11662
11756
  };
11663
11757
  }
11664
11758
 
@@ -11689,13 +11783,13 @@ function createClipEventHandler(world, session) {
11689
11783
  const vector = (x, y, z) => new THREE.Vector3(x, y, z);
11690
11784
  const positionOf = (part) => worldPositionOf(session, part, new THREE.Vector3());
11691
11785
  const reach = Math.max(0.55, Math.min(1.2, session.lengthMetres));
11692
- const throwCase = (mark, velocity, spin, tilt = 0) => {
11786
+ const throwCase = (mark, velocity2, spin, tilt = 0) => {
11693
11787
  if (!session.cartridge || !world.layers.casings) return;
11694
11788
  const casing = buildCasing(kit, session.cartridge.dims, session.cartridge.shape);
11695
11789
  casing.group.position.copy(positionOf(mark));
11696
11790
  casing.group.rotation.set(0, random() * 0.6 - 0.3, tilt);
11697
11791
  if (session.cartridge.caseType) casing.group.userData["caseType"] = session.cartridge.caseType;
11698
- particles.spawn(casing.group, velocity, { kind: "casing", life: 25, radius: casing.radius, bounce: 0.35, spin, onRest: restFlat, ownsGeometry: true });
11792
+ particles.spawn(casing.group, velocity2, { kind: "casing", life: 25, radius: casing.radius, bounce: 0.35, spin, onRest: restFlat, ownsGeometry: true, collider: casingCollider(casing.radius, casing.length) });
11699
11793
  };
11700
11794
  const ejectFromPort = (down) => {
11701
11795
  if (!parts.eject) return;
@@ -11704,8 +11798,8 @@ function createClipEventHandler(world, session) {
11704
11798
  };
11705
11799
  const ejectAll = (marks, spent) => {
11706
11800
  marks?.forEach((mark, index) => {
11707
- const { velocity, spin, tilt } = spent(index);
11708
- throwCase(mark, toWorld(session, velocity), spin, tilt);
11801
+ const { velocity: velocity2, spin, tilt } = spent(index);
11802
+ throwCase(mark, toWorld(session, velocity2), spin, tilt);
11709
11803
  });
11710
11804
  };
11711
11805
  const moveIn = (from, to, tilt) => {
@@ -12357,11 +12451,11 @@ function createViewmodel(options) {
12357
12451
  const random = createRng2(options.seed ?? 1);
12358
12452
  const layers = options.layers ?? createLayers();
12359
12453
  const distance = () => options.soundDistance?.() ?? 0;
12360
- const particles = createParticles(THREE, scene, groundAt, options.particleLimit, createSurfaceRaycast(THREE, scene));
12454
+ const particles = createParticles(THREE, scene, groundAt, options.particleLimit, createSurfaceRaycast(THREE, scene), options.physics);
12361
12455
  const spawnParticle = particles.spawn.bind(particles);
12362
- particles.spawn = (object, velocity, particleOptions) => {
12456
+ particles.spawn = (object, velocity2, particleOptions) => {
12363
12457
  if (lens) toWorldLens(camera, object.position, worldFovOf(), lens.fov);
12364
- spawnParticle(object, velocity, particleOptions);
12458
+ spawnParticle(object, velocity2, particleOptions);
12365
12459
  };
12366
12460
  particles.onBounce = (kind, hit) => {
12367
12461
  if (!audio || kind !== "casing" && kind !== "magazine") return;
@@ -12386,10 +12480,10 @@ function createViewmodel(options) {
12386
12480
  stop: (handle) => worldSink.stop(handle)
12387
12481
  } : void 0;
12388
12482
  const effects = createEffects(THREE, lensSink, random);
12389
- function seenThroughLens(pose) {
12390
- if (!pose || !lens) return pose;
12391
- const at2 = toWorldLens(camera, trackPoint.set(...pose.point), worldFovOf(), lens.fov);
12392
- return { ...pose, point: [at2.x, at2.y, at2.z] };
12483
+ function seenThroughLens(pose2) {
12484
+ if (!pose2 || !lens) return pose2;
12485
+ const at2 = toWorldLens(camera, trackPoint.set(...pose2.point), worldFovOf(), lens.fov);
12486
+ return { ...pose2, point: [at2.x, at2.y, at2.z] };
12393
12487
  }
12394
12488
  const hand = new THREE.Group();
12395
12489
  hand.name = VIEWMODEL_NODE_NAME;
@@ -12615,9 +12709,9 @@ function createViewmodel(options) {
12615
12709
  eyeTurn.copy(camera.quaternion).invert();
12616
12710
  const rest = targetsOf(THREE, held, session.model.root.getWorldQuaternion(rootQuaternion), 0);
12617
12711
  let needed = 0;
12618
- for (const [anchor, pose] of [[held.right, rest.R], [held.left, rest.L]]) {
12619
- if (!anchor || !pose || anchor.part !== session.model.root) continue;
12620
- seen.set(...pose.position).sub(camera.position).applyQuaternion(eyeTurn);
12712
+ for (const [anchor, pose2] of [[held.right, rest.R], [held.left, rest.L]]) {
12713
+ if (!anchor || !pose2 || anchor.part !== session.model.root) continue;
12714
+ seen.set(...pose2.position).sub(camera.position).applyQuaternion(eyeTurn);
12621
12715
  if (-seen.z > 0.05) needed = Math.max(needed, HAND_IN_VIEW.floor * -seen.z * tanHalf - seen.y);
12622
12716
  }
12623
12717
  return Math.max(0, Math.min(HAND_IN_VIEW.max, needed));
@@ -12868,6 +12962,7 @@ var createHandFx = (options, layers, hand, oneHand) => {
12868
12962
  ...options.condition ? { condition: options.condition } : {},
12869
12963
  ...options.attachmentModels ? { attachmentModels: options.attachmentModels } : {},
12870
12964
  ...options.raycast ? { raycast: options.raycast } : {},
12965
+ ...options.physics ? { physics: options.physics } : {},
12871
12966
  ...options.contact ? { contact: options.contact } : {},
12872
12967
  ...options.bodyHold ? { bodyHold: options.bodyHold } : {},
12873
12968
  ...options.firstPerson ? { firstPerson: options.firstPerson } : {},
@@ -13118,7 +13213,7 @@ var createHolsteredWeapons = (options) => {
13118
13213
  const rigs = /* @__PURE__ */ new Map();
13119
13214
  const away = /* @__PURE__ */ new Map();
13120
13215
  const strapMaterial = new THREE.MeshStandardMaterial({ color: SLING_HANG.color, roughness: 0.85, metalness: 0 });
13121
- const frameOf = (pose) => ({ position: new THREE.Vector3(...pose.position), quaternion: new THREE.Quaternion(...pose.quaternion) });
13216
+ const frameOf = (pose2) => ({ position: new THREE.Vector3(...pose2.position), quaternion: new THREE.Quaternion(...pose2.quaternion) });
13122
13217
  const scratch3 = { position: new THREE.Vector3(), quaternion: new THREE.Quaternion(), inverse: new THREE.Quaternion(), acceleration: new THREE.Vector3(), velocity: new THREE.Vector3() };
13123
13218
  const holderOnHand = (rig, hand) => {
13124
13219
  const quaternion2 = hand.quaternion.clone().multiply(rig.grip.quaternion.clone().invert());
@@ -13130,8 +13225,8 @@ var createHolsteredWeapons = (options) => {
13130
13225
  };
13131
13226
  const inFrame = (local, base) => ({ position: local.position.clone().applyQuaternion(base.quaternion).add(base.position), quaternion: base.quaternion.clone().multiply(local.quaternion) });
13132
13227
  const holdFrame = () => {
13133
- const pose = options.holdFrame?.();
13134
- return pose ? frameOf(pose) : null;
13228
+ const pose2 = options.holdFrame?.();
13229
+ return pose2 ? frameOf(pose2) : null;
13135
13230
  };
13136
13231
  const goal = (entry) => {
13137
13232
  if (entry.motion?.kind === "toss") {
@@ -13144,9 +13239,9 @@ var createHolsteredWeapons = (options) => {
13144
13239
  const base = holdFrame();
13145
13240
  return base && entry.taken ? inFrame(entry.taken, base) : null;
13146
13241
  }
13147
- const pose = options.bodySlot(entry.slot);
13148
- if (!pose) return null;
13149
- return entry.swing ? hanging(entry, frameOf(pose)) : frameOf(pose);
13242
+ const pose2 = options.bodySlot(entry.slot);
13243
+ if (!pose2) return null;
13244
+ return entry.swing ? hanging(entry, frameOf(pose2)) : frameOf(pose2);
13150
13245
  };
13151
13246
  const hanging = (entry, frame) => {
13152
13247
  const forward = new THREE.Vector3(0, 0, 1).applyQuaternion(frame.quaternion);
@@ -13164,11 +13259,11 @@ var createHolsteredWeapons = (options) => {
13164
13259
  };
13165
13260
  const swingOf = (entry, frame, dt) => {
13166
13261
  if (!entry.swing || dt <= 0) return;
13167
- const { velocity, acceleration, inverse } = scratch3;
13168
- velocity.copy(frame.position).sub(entry.last ?? frame.position).divideScalar(dt);
13169
- acceleration.copy(velocity).sub(entry.last ? entry.speed : velocity).divideScalar(dt).clampLength(0, MAX_SWING_ACCELERATION);
13262
+ const { velocity: velocity2, acceleration, inverse } = scratch3;
13263
+ velocity2.copy(frame.position).sub(entry.last ?? frame.position).divideScalar(dt);
13264
+ acceleration.copy(velocity2).sub(entry.last ? entry.speed : velocity2).divideScalar(dt).clampLength(0, MAX_SWING_ACCELERATION);
13170
13265
  entry.last = (entry.last ?? new THREE.Vector3()).copy(frame.position);
13171
- entry.speed.copy(velocity);
13266
+ entry.speed.copy(velocity2);
13172
13267
  acceleration.applyQuaternion(inverse.copy(frame.quaternion).invert());
13173
13268
  const state = entry.swing.step(dt, [-acceleration.x, acceleration.y, acceleration.z]);
13174
13269
  entry.rig.swing.rotation.set(-(state.forward + Math.max(0, -entry.lean)), 0, -state.side);
@@ -15903,6 +15998,12 @@ export {
15903
15998
  buildCartridge,
15904
15999
  buildCasing,
15905
16000
  buildRound,
16001
+ LOOSE_ROLLING_RESISTANCE,
16002
+ casingCollider,
16003
+ explosiveCollider,
16004
+ spawnLoose,
16005
+ syncLoose,
16006
+ dropLoose,
15906
16007
  VIEW_MOTION,
15907
16008
  createWeaponFx,
15908
16009
  buildModeledProp,
@@ -15939,4 +16040,4 @@ export {
15939
16040
  DEFAULT_EXPLOSIVES_SCENE,
15940
16041
  createExplosivesTestModule
15941
16042
  };
15942
- //# sourceMappingURL=chunk-4MNVYCNY.js.map
16043
+ //# sourceMappingURL=chunk-CGGF5CDD.js.map