@adatechnology/game-weapons-three 0.24.4 → 0.25.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 +6 -0
- package/dist/{chunk-4MNVYCNY.js → chunk-DCMD54HC.js} +133 -57
- package/dist/chunk-DCMD54HC.js.map +1 -0
- package/dist/index.d.ts +39 -3
- package/dist/index.global.js +221 -145
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/{testing-eyLz_C6A.d.ts → testing-C9yn3tJI.d.ts} +3 -0
- package/dist/testing.d.ts +2 -1
- package/dist/testing.js +1 -1
- package/package.json +10 -8
- package/dist/chunk-4MNVYCNY.js.map +0 -1
package/README.md
CHANGED
|
@@ -62,3 +62,9 @@ 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. `spawnLoose`, `syncLoose`
|
|
70
|
+
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`): 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
|
|
9446
|
-
if (work.hand === "R") right = right ? blendPose(THREE, right,
|
|
9447
|
-
else left = left ? blendPose(THREE, left,
|
|
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
|
-
|
|
9763
|
-
|
|
9764
|
-
|
|
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,
|
|
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
|
|
10026
|
-
throwBody("casing", mesh, from,
|
|
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
|
|
10234
|
-
|
|
10235
|
-
poses.set(part,
|
|
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,
|
|
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
|
|
11340
|
-
return
|
|
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,
|
|
11345
|
-
sink?.play({ effect: VIEWMODEL_EFFECT_IDS.smoke, point: vec(position), seed: seed(), values: { vx:
|
|
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,61 @@ 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 LOOSE_USER = { casing: 100 };
|
|
11522
|
+
var BOUNCE_FALL_SPEED = 0.5;
|
|
11523
|
+
var BOUNCE_RISE_SPEED = 0.2;
|
|
11524
|
+
var QUARTER_TURN_Z = [0, 0, Math.SQRT1_2, Math.SQRT1_2];
|
|
11525
|
+
var CASING_MATERIAL = { frictionStatic: 0.4, frictionDynamic: 0.3, restitution: 0.4 };
|
|
11526
|
+
function casingCollider(radius, length) {
|
|
11527
|
+
return {
|
|
11528
|
+
shape: { kind: "compound", children: [{ shape: { kind: "cylinder", halfHeight: length / 2, radius }, position: [0, 0, 0], rotation: QUARTER_TURN_Z }] },
|
|
11529
|
+
mass: Math.PI * radius * radius * length * BRASS_DENSITY * CASING_FILL,
|
|
11530
|
+
material: CASING_MATERIAL,
|
|
11531
|
+
rolling: { coefficient: LOOSE_ROLLING_RESISTANCE, radius },
|
|
11532
|
+
user: LOOSE_USER.casing
|
|
11533
|
+
};
|
|
11534
|
+
}
|
|
11535
|
+
function spawnLoose(world, collider, launch) {
|
|
11536
|
+
const desc = {
|
|
11537
|
+
shape: collider.shape,
|
|
11538
|
+
motion: "dynamic",
|
|
11539
|
+
mass: collider.mass,
|
|
11540
|
+
position: [launch.position.x, launch.position.y, launch.position.z],
|
|
11541
|
+
rotation: [launch.rotation.x, launch.rotation.y, launch.rotation.z, launch.rotation.w],
|
|
11542
|
+
material: collider.material,
|
|
11543
|
+
layer: "debris",
|
|
11544
|
+
continuous: true,
|
|
11545
|
+
rolling: collider.rolling,
|
|
11546
|
+
linearVelocity: [launch.velocity.x, launch.velocity.y, launch.velocity.z],
|
|
11547
|
+
angularVelocity: [launch.spin.x, launch.spin.y, launch.spin.z],
|
|
11548
|
+
user: collider.user
|
|
11549
|
+
};
|
|
11550
|
+
return { id: world.createBody(desc), bounces: 0, fallSpeed: 0 };
|
|
11551
|
+
}
|
|
11552
|
+
var scratchReading = { asleep: false, bounceSpeed: void 0 };
|
|
11553
|
+
var pose = new Float64Array(7);
|
|
11554
|
+
var velocity = new Float64Array(6);
|
|
11555
|
+
function syncLoose(world, body, object) {
|
|
11556
|
+
world.readPose(body.id, pose, 0);
|
|
11557
|
+
world.readVelocity(body.id, velocity, 0);
|
|
11558
|
+
object.position.set(pose[0] ?? 0, pose[1] ?? 0, pose[2] ?? 0);
|
|
11559
|
+
object.quaternion.set(pose[3] ?? 0, pose[4] ?? 0, pose[5] ?? 0, pose[6] ?? 1);
|
|
11560
|
+
const vertical = velocity[1] ?? 0;
|
|
11561
|
+
const bounced = body.fallSpeed > BOUNCE_FALL_SPEED && vertical > BOUNCE_RISE_SPEED;
|
|
11562
|
+
scratchReading.bounceSpeed = bounced ? body.fallSpeed : void 0;
|
|
11563
|
+
body.fallSpeed = vertical < 0 ? -vertical : 0;
|
|
11564
|
+
if (bounced) body.bounces++;
|
|
11565
|
+
scratchReading.asleep = world.isSleeping(body.id);
|
|
11566
|
+
return scratchReading;
|
|
11567
|
+
}
|
|
11568
|
+
function dropLoose(world, body) {
|
|
11569
|
+
world.removeBody(body.id);
|
|
11570
|
+
}
|
|
11571
|
+
|
|
11511
11572
|
// src/fx/particles.ts
|
|
11512
11573
|
var MAX_PARTICLES = 900;
|
|
11513
11574
|
var FLOOR_FRICTION = 0.45;
|
|
@@ -11522,7 +11583,7 @@ var disposeOwned = (object) => {
|
|
|
11522
11583
|
if (mesh.isMesh) mesh.geometry.dispose();
|
|
11523
11584
|
});
|
|
11524
11585
|
};
|
|
11525
|
-
function createParticles(THREE, scene, groundAt, limit, surface) {
|
|
11586
|
+
function createParticles(THREE, scene, groundAt, limit, surface, physics) {
|
|
11526
11587
|
const from = new THREE.Vector3();
|
|
11527
11588
|
const step = new THREE.Vector3();
|
|
11528
11589
|
let list = [];
|
|
@@ -11532,6 +11593,7 @@ function createParticles(THREE, scene, groundAt, limit, surface) {
|
|
|
11532
11593
|
});
|
|
11533
11594
|
particle.object.removeFromParent();
|
|
11534
11595
|
if (particle.ownsGeometry) disposeOwned(particle.object);
|
|
11596
|
+
if (particle.body && physics) dropLoose(physics, particle.body);
|
|
11535
11597
|
particle.onRemove?.();
|
|
11536
11598
|
if (particle.fadeFrom !== void 0) particle.object.material.dispose();
|
|
11537
11599
|
list = list.filter((other) => other !== particle);
|
|
@@ -11547,24 +11609,24 @@ function createParticles(THREE, scene, groundAt, limit, surface) {
|
|
|
11547
11609
|
if (!hit) return;
|
|
11548
11610
|
const at2 = origin.y + travel.y * hit.distance;
|
|
11549
11611
|
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(
|
|
11612
|
+
const { velocity: velocity2 } = particle;
|
|
11613
|
+
const impact = Math.abs(velocity2.dot(hit.normal));
|
|
11552
11614
|
object.position.copy(origin).addScaledVector(travel, Math.max(0, hit.distance - radius));
|
|
11553
|
-
|
|
11554
|
-
|
|
11615
|
+
velocity2.addScaledVector(hit.normal, -(1 + particle.bounce) * velocity2.dot(hit.normal));
|
|
11616
|
+
velocity2.multiplyScalar(FLOOR_FRICTION);
|
|
11555
11617
|
particle.spin.multiplyScalar(FLOOR_FRICTION);
|
|
11556
11618
|
if (particle.bounces < 4) api.onBounce?.(particle.kind, { object, speed: impact, bounce: particle.bounces });
|
|
11557
11619
|
particle.bounces++;
|
|
11558
11620
|
};
|
|
11559
11621
|
const api = {
|
|
11560
|
-
spawn(object,
|
|
11622
|
+
spawn(object, velocity2, options = {}) {
|
|
11561
11623
|
object.traverse((node) => {
|
|
11562
11624
|
node.userData[PARTICLE_USERDATA_KEY] = true;
|
|
11563
11625
|
});
|
|
11564
11626
|
scene.add(object);
|
|
11565
11627
|
list.push({
|
|
11566
11628
|
object,
|
|
11567
|
-
velocity,
|
|
11629
|
+
velocity: velocity2,
|
|
11568
11630
|
spin: options.spin ?? new THREE.Vector3(),
|
|
11569
11631
|
age: 0,
|
|
11570
11632
|
resting: false,
|
|
@@ -11580,7 +11642,8 @@ function createParticles(THREE, scene, groundAt, limit, surface) {
|
|
|
11580
11642
|
onGround: options.onGround,
|
|
11581
11643
|
ownsGeometry: options.ownsGeometry ?? false,
|
|
11582
11644
|
onRemove: options.onRemove,
|
|
11583
|
-
bounces: 0
|
|
11645
|
+
bounces: 0,
|
|
11646
|
+
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
11647
|
});
|
|
11585
11648
|
const hostLimit = limit?.();
|
|
11586
11649
|
const oldest = list[0];
|
|
@@ -11597,6 +11660,13 @@ function createParticles(THREE, scene, groundAt, limit, surface) {
|
|
|
11597
11660
|
const { object } = particle;
|
|
11598
11661
|
if (particle.fadeFrom !== void 0) object.material.opacity = Math.max(0, particle.fadeFrom * (1 - particle.age / particle.life));
|
|
11599
11662
|
if (particle.resting) continue;
|
|
11663
|
+
if (particle.body && physics) {
|
|
11664
|
+
const reading = syncLoose(physics, particle.body, object);
|
|
11665
|
+
if (reading.bounceSpeed !== void 0 && particle.bounces < 4) api.onBounce?.(particle.kind, { object, speed: reading.bounceSpeed, bounce: particle.bounces });
|
|
11666
|
+
if (reading.bounceSpeed !== void 0) particle.bounces++;
|
|
11667
|
+
if (reading.asleep) particle.resting = true;
|
|
11668
|
+
continue;
|
|
11669
|
+
}
|
|
11600
11670
|
particle.velocity.y -= particle.gravity * dt;
|
|
11601
11671
|
if (particle.drag) particle.velocity.multiplyScalar(Math.max(0, 1 - particle.drag * dt));
|
|
11602
11672
|
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 +11715,20 @@ function createModelRig(model) {
|
|
|
11645
11715
|
const registry = partRegistry(model.parts);
|
|
11646
11716
|
const rest = /* @__PURE__ */ new Map();
|
|
11647
11717
|
for (const part of [...registry.values(), model.root]) rest.set(part, { position: part.position.clone(), rotation: part.rotation.clone() });
|
|
11648
|
-
const apply = (object,
|
|
11718
|
+
const apply = (object, pose2) => {
|
|
11649
11719
|
const base = rest.get(object);
|
|
11650
11720
|
if (!base) return;
|
|
11651
|
-
const [dx, dy, dz] =
|
|
11652
|
-
const [rx, ry, rz] =
|
|
11721
|
+
const [dx, dy, dz] = pose2.position ?? [0, 0, 0];
|
|
11722
|
+
const [rx, ry, rz] = pose2.rotation ?? [0, 0, 0];
|
|
11653
11723
|
object.position.set(base.position.x + dx, base.position.y + dy, base.position.z + dz);
|
|
11654
11724
|
object.rotation.set(base.rotation.x + rx, base.rotation.y + ry, base.rotation.z + rz);
|
|
11655
11725
|
};
|
|
11656
11726
|
return {
|
|
11657
|
-
setPartPose(partId,
|
|
11727
|
+
setPartPose(partId, pose2) {
|
|
11658
11728
|
const part = registry.get(partId);
|
|
11659
|
-
if (part) apply(part,
|
|
11729
|
+
if (part) apply(part, pose2);
|
|
11660
11730
|
},
|
|
11661
|
-
setRootPose: (
|
|
11731
|
+
setRootPose: (pose2) => apply(model.root, pose2)
|
|
11662
11732
|
};
|
|
11663
11733
|
}
|
|
11664
11734
|
|
|
@@ -11689,13 +11759,13 @@ function createClipEventHandler(world, session) {
|
|
|
11689
11759
|
const vector = (x, y, z) => new THREE.Vector3(x, y, z);
|
|
11690
11760
|
const positionOf = (part) => worldPositionOf(session, part, new THREE.Vector3());
|
|
11691
11761
|
const reach = Math.max(0.55, Math.min(1.2, session.lengthMetres));
|
|
11692
|
-
const throwCase = (mark,
|
|
11762
|
+
const throwCase = (mark, velocity2, spin, tilt = 0) => {
|
|
11693
11763
|
if (!session.cartridge || !world.layers.casings) return;
|
|
11694
11764
|
const casing = buildCasing(kit, session.cartridge.dims, session.cartridge.shape);
|
|
11695
11765
|
casing.group.position.copy(positionOf(mark));
|
|
11696
11766
|
casing.group.rotation.set(0, random() * 0.6 - 0.3, tilt);
|
|
11697
11767
|
if (session.cartridge.caseType) casing.group.userData["caseType"] = session.cartridge.caseType;
|
|
11698
|
-
particles.spawn(casing.group,
|
|
11768
|
+
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
11769
|
};
|
|
11700
11770
|
const ejectFromPort = (down) => {
|
|
11701
11771
|
if (!parts.eject) return;
|
|
@@ -11704,8 +11774,8 @@ function createClipEventHandler(world, session) {
|
|
|
11704
11774
|
};
|
|
11705
11775
|
const ejectAll = (marks, spent) => {
|
|
11706
11776
|
marks?.forEach((mark, index) => {
|
|
11707
|
-
const { velocity, spin, tilt } = spent(index);
|
|
11708
|
-
throwCase(mark, toWorld(session,
|
|
11777
|
+
const { velocity: velocity2, spin, tilt } = spent(index);
|
|
11778
|
+
throwCase(mark, toWorld(session, velocity2), spin, tilt);
|
|
11709
11779
|
});
|
|
11710
11780
|
};
|
|
11711
11781
|
const moveIn = (from, to, tilt) => {
|
|
@@ -12357,11 +12427,11 @@ function createViewmodel(options) {
|
|
|
12357
12427
|
const random = createRng2(options.seed ?? 1);
|
|
12358
12428
|
const layers = options.layers ?? createLayers();
|
|
12359
12429
|
const distance = () => options.soundDistance?.() ?? 0;
|
|
12360
|
-
const particles = createParticles(THREE, scene, groundAt, options.particleLimit, createSurfaceRaycast(THREE, scene));
|
|
12430
|
+
const particles = createParticles(THREE, scene, groundAt, options.particleLimit, createSurfaceRaycast(THREE, scene), options.physics);
|
|
12361
12431
|
const spawnParticle = particles.spawn.bind(particles);
|
|
12362
|
-
particles.spawn = (object,
|
|
12432
|
+
particles.spawn = (object, velocity2, particleOptions) => {
|
|
12363
12433
|
if (lens) toWorldLens(camera, object.position, worldFovOf(), lens.fov);
|
|
12364
|
-
spawnParticle(object,
|
|
12434
|
+
spawnParticle(object, velocity2, particleOptions);
|
|
12365
12435
|
};
|
|
12366
12436
|
particles.onBounce = (kind, hit) => {
|
|
12367
12437
|
if (!audio || kind !== "casing" && kind !== "magazine") return;
|
|
@@ -12386,10 +12456,10 @@ function createViewmodel(options) {
|
|
|
12386
12456
|
stop: (handle) => worldSink.stop(handle)
|
|
12387
12457
|
} : void 0;
|
|
12388
12458
|
const effects = createEffects(THREE, lensSink, random);
|
|
12389
|
-
function seenThroughLens(
|
|
12390
|
-
if (!
|
|
12391
|
-
const at2 = toWorldLens(camera, trackPoint.set(...
|
|
12392
|
-
return { ...
|
|
12459
|
+
function seenThroughLens(pose2) {
|
|
12460
|
+
if (!pose2 || !lens) return pose2;
|
|
12461
|
+
const at2 = toWorldLens(camera, trackPoint.set(...pose2.point), worldFovOf(), lens.fov);
|
|
12462
|
+
return { ...pose2, point: [at2.x, at2.y, at2.z] };
|
|
12393
12463
|
}
|
|
12394
12464
|
const hand = new THREE.Group();
|
|
12395
12465
|
hand.name = VIEWMODEL_NODE_NAME;
|
|
@@ -12615,9 +12685,9 @@ function createViewmodel(options) {
|
|
|
12615
12685
|
eyeTurn.copy(camera.quaternion).invert();
|
|
12616
12686
|
const rest = targetsOf(THREE, held, session.model.root.getWorldQuaternion(rootQuaternion), 0);
|
|
12617
12687
|
let needed = 0;
|
|
12618
|
-
for (const [anchor,
|
|
12619
|
-
if (!anchor || !
|
|
12620
|
-
seen.set(...
|
|
12688
|
+
for (const [anchor, pose2] of [[held.right, rest.R], [held.left, rest.L]]) {
|
|
12689
|
+
if (!anchor || !pose2 || anchor.part !== session.model.root) continue;
|
|
12690
|
+
seen.set(...pose2.position).sub(camera.position).applyQuaternion(eyeTurn);
|
|
12621
12691
|
if (-seen.z > 0.05) needed = Math.max(needed, HAND_IN_VIEW.floor * -seen.z * tanHalf - seen.y);
|
|
12622
12692
|
}
|
|
12623
12693
|
return Math.max(0, Math.min(HAND_IN_VIEW.max, needed));
|
|
@@ -12868,6 +12938,7 @@ var createHandFx = (options, layers, hand, oneHand) => {
|
|
|
12868
12938
|
...options.condition ? { condition: options.condition } : {},
|
|
12869
12939
|
...options.attachmentModels ? { attachmentModels: options.attachmentModels } : {},
|
|
12870
12940
|
...options.raycast ? { raycast: options.raycast } : {},
|
|
12941
|
+
...options.physics ? { physics: options.physics } : {},
|
|
12871
12942
|
...options.contact ? { contact: options.contact } : {},
|
|
12872
12943
|
...options.bodyHold ? { bodyHold: options.bodyHold } : {},
|
|
12873
12944
|
...options.firstPerson ? { firstPerson: options.firstPerson } : {},
|
|
@@ -13118,7 +13189,7 @@ var createHolsteredWeapons = (options) => {
|
|
|
13118
13189
|
const rigs = /* @__PURE__ */ new Map();
|
|
13119
13190
|
const away = /* @__PURE__ */ new Map();
|
|
13120
13191
|
const strapMaterial = new THREE.MeshStandardMaterial({ color: SLING_HANG.color, roughness: 0.85, metalness: 0 });
|
|
13121
|
-
const frameOf = (
|
|
13192
|
+
const frameOf = (pose2) => ({ position: new THREE.Vector3(...pose2.position), quaternion: new THREE.Quaternion(...pose2.quaternion) });
|
|
13122
13193
|
const scratch3 = { position: new THREE.Vector3(), quaternion: new THREE.Quaternion(), inverse: new THREE.Quaternion(), acceleration: new THREE.Vector3(), velocity: new THREE.Vector3() };
|
|
13123
13194
|
const holderOnHand = (rig, hand) => {
|
|
13124
13195
|
const quaternion2 = hand.quaternion.clone().multiply(rig.grip.quaternion.clone().invert());
|
|
@@ -13130,8 +13201,8 @@ var createHolsteredWeapons = (options) => {
|
|
|
13130
13201
|
};
|
|
13131
13202
|
const inFrame = (local, base) => ({ position: local.position.clone().applyQuaternion(base.quaternion).add(base.position), quaternion: base.quaternion.clone().multiply(local.quaternion) });
|
|
13132
13203
|
const holdFrame = () => {
|
|
13133
|
-
const
|
|
13134
|
-
return
|
|
13204
|
+
const pose2 = options.holdFrame?.();
|
|
13205
|
+
return pose2 ? frameOf(pose2) : null;
|
|
13135
13206
|
};
|
|
13136
13207
|
const goal = (entry) => {
|
|
13137
13208
|
if (entry.motion?.kind === "toss") {
|
|
@@ -13144,9 +13215,9 @@ var createHolsteredWeapons = (options) => {
|
|
|
13144
13215
|
const base = holdFrame();
|
|
13145
13216
|
return base && entry.taken ? inFrame(entry.taken, base) : null;
|
|
13146
13217
|
}
|
|
13147
|
-
const
|
|
13148
|
-
if (!
|
|
13149
|
-
return entry.swing ? hanging(entry, frameOf(
|
|
13218
|
+
const pose2 = options.bodySlot(entry.slot);
|
|
13219
|
+
if (!pose2) return null;
|
|
13220
|
+
return entry.swing ? hanging(entry, frameOf(pose2)) : frameOf(pose2);
|
|
13150
13221
|
};
|
|
13151
13222
|
const hanging = (entry, frame) => {
|
|
13152
13223
|
const forward = new THREE.Vector3(0, 0, 1).applyQuaternion(frame.quaternion);
|
|
@@ -13164,11 +13235,11 @@ var createHolsteredWeapons = (options) => {
|
|
|
13164
13235
|
};
|
|
13165
13236
|
const swingOf = (entry, frame, dt) => {
|
|
13166
13237
|
if (!entry.swing || dt <= 0) return;
|
|
13167
|
-
const { velocity, acceleration, inverse } = scratch3;
|
|
13168
|
-
|
|
13169
|
-
acceleration.copy(
|
|
13238
|
+
const { velocity: velocity2, acceleration, inverse } = scratch3;
|
|
13239
|
+
velocity2.copy(frame.position).sub(entry.last ?? frame.position).divideScalar(dt);
|
|
13240
|
+
acceleration.copy(velocity2).sub(entry.last ? entry.speed : velocity2).divideScalar(dt).clampLength(0, MAX_SWING_ACCELERATION);
|
|
13170
13241
|
entry.last = (entry.last ?? new THREE.Vector3()).copy(frame.position);
|
|
13171
|
-
entry.speed.copy(
|
|
13242
|
+
entry.speed.copy(velocity2);
|
|
13172
13243
|
acceleration.applyQuaternion(inverse.copy(frame.quaternion).invert());
|
|
13173
13244
|
const state = entry.swing.step(dt, [-acceleration.x, acceleration.y, acceleration.z]);
|
|
13174
13245
|
entry.rig.swing.rotation.set(-(state.forward + Math.max(0, -entry.lean)), 0, -state.side);
|
|
@@ -15903,6 +15974,11 @@ export {
|
|
|
15903
15974
|
buildCartridge,
|
|
15904
15975
|
buildCasing,
|
|
15905
15976
|
buildRound,
|
|
15977
|
+
LOOSE_ROLLING_RESISTANCE,
|
|
15978
|
+
casingCollider,
|
|
15979
|
+
spawnLoose,
|
|
15980
|
+
syncLoose,
|
|
15981
|
+
dropLoose,
|
|
15906
15982
|
VIEW_MOTION,
|
|
15907
15983
|
createWeaponFx,
|
|
15908
15984
|
buildModeledProp,
|
|
@@ -15939,4 +16015,4 @@ export {
|
|
|
15939
16015
|
DEFAULT_EXPLOSIVES_SCENE,
|
|
15940
16016
|
createExplosivesTestModule
|
|
15941
16017
|
};
|
|
15942
|
-
//# sourceMappingURL=chunk-
|
|
16018
|
+
//# sourceMappingURL=chunk-DCMD54HC.js.map
|