@adatechnology/game-weapons-three 0.24.3 → 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 +7 -1
- package/dist/{chunk-UUBO6H5O.js → chunk-DCMD54HC.js} +331 -89
- package/dist/chunk-DCMD54HC.js.map +1 -0
- package/dist/index.d.ts +97 -10
- package/dist/index.global.js +461 -181
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +19 -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 +14 -12
- package/dist/chunk-UUBO6H5O.js.map +0 -1
package/dist/index.global.js
CHANGED
|
@@ -35,18 +35,22 @@ var GameWeaponsThree = (() => {
|
|
|
35
35
|
EXPLOSIVE_MODEL_IDS: () => EXPLOSIVE_MODEL_IDS,
|
|
36
36
|
GAME_DISTANCE_CURVE: () => GAME_DISTANCE_CURVE,
|
|
37
37
|
GAME_SOUND_CLASSES: () => GAME_SOUND_CLASSES,
|
|
38
|
+
GROUND_SLOT: () => GROUND_SLOT,
|
|
38
39
|
GUNSHOT_PROFILES: () => GUNSHOT_PROFILES,
|
|
39
40
|
GUNSHOT_SAMPLE: () => GUNSHOT_SAMPLE,
|
|
40
41
|
GUNSHOT_SAMPLE_IDS: () => GUNSHOT_SAMPLE_IDS,
|
|
41
42
|
HOLSTER_PLACEMENT: () => HOLSTER_PLACEMENT,
|
|
43
|
+
HOLSTER_TOSS: () => HOLSTER_TOSS,
|
|
42
44
|
LAUNCH_SAMPLE: () => LAUNCH_SAMPLE,
|
|
43
45
|
LAUNCH_SOUND_IDS: () => LAUNCH_SOUND_IDS,
|
|
46
|
+
LOOSE_ROLLING_RESISTANCE: () => LOOSE_ROLLING_RESISTANCE,
|
|
44
47
|
MECHANICAL_SOUNDS: () => MECHANICAL_SOUNDS,
|
|
45
48
|
MODEL_ENTRIES: () => MODEL_ENTRIES,
|
|
46
49
|
MOUNTED_M134_ITEM_ID: () => MOUNTED_M134_ITEM_ID,
|
|
47
50
|
P13_VALVE_MESH: () => P13_VALVE_MESH,
|
|
48
51
|
RELOAD_SAMPLE: () => RELOAD_SAMPLE,
|
|
49
52
|
RELOAD_SAMPLE_HITS: () => RELOAD_SAMPLE_HITS,
|
|
53
|
+
SLING_HANG: () => SLING_HANG,
|
|
50
54
|
TOOL_MOTIONS: () => TOOL_MOTIONS,
|
|
51
55
|
VIEW_HOLD: () => VIEW_HOLD,
|
|
52
56
|
VIEW_MOTION: () => VIEW_MOTION,
|
|
@@ -60,6 +64,7 @@ var GameWeaponsThree = (() => {
|
|
|
60
64
|
buildCartridge: () => buildCartridge,
|
|
61
65
|
buildCasing: () => buildCasing,
|
|
62
66
|
buildExplosiveModel: () => buildExplosiveModel,
|
|
67
|
+
buildHolsterRig: () => buildHolsterRig,
|
|
63
68
|
buildItemWeaponModel: () => buildItemWeaponModel,
|
|
64
69
|
buildModeledProp: () => buildModeledProp,
|
|
65
70
|
buildProp: () => buildProp,
|
|
@@ -70,6 +75,7 @@ var GameWeaponsThree = (() => {
|
|
|
70
75
|
buildWeaponModel: () => buildWeaponModel,
|
|
71
76
|
buildWeaponModelById: () => buildWeaponModelById,
|
|
72
77
|
cartridgeShape: () => cartridgeShape,
|
|
78
|
+
casingCollider: () => casingCollider,
|
|
73
79
|
computeCasingSound: () => computeCasingSound,
|
|
74
80
|
computeFlyby: () => computeFlyby,
|
|
75
81
|
computeGunshot: () => computeGunshot,
|
|
@@ -84,6 +90,7 @@ var GameWeaponsThree = (() => {
|
|
|
84
90
|
createWorldExplosiveShells: () => createWorldExplosiveShells,
|
|
85
91
|
defaultWeaponProps: () => defaultWeaponProps,
|
|
86
92
|
deriveFrames: () => deriveFrames,
|
|
93
|
+
dropLoose: () => dropLoose,
|
|
87
94
|
explosivesTextOf: () => explosivesTextOf,
|
|
88
95
|
fitAttachmentModels: () => fitAttachmentModels,
|
|
89
96
|
hasExplosiveModel: () => hasExplosiveModel,
|
|
@@ -101,6 +108,8 @@ var GameWeaponsThree = (() => {
|
|
|
101
108
|
rigStock: () => rigStock,
|
|
102
109
|
rigUnderbarrel: () => rigUnderbarrel,
|
|
103
110
|
sampleToolMotion: () => sampleToolMotion,
|
|
111
|
+
spawnLoose: () => spawnLoose,
|
|
112
|
+
syncLoose: () => syncLoose,
|
|
104
113
|
toWorldLens: () => toWorldLens,
|
|
105
114
|
weaponProp: () => weaponProp,
|
|
106
115
|
weaponSampleBank: () => weaponSampleBank,
|
|
@@ -431,8 +440,8 @@ var GameWeaponsThree = (() => {
|
|
|
431
440
|
];
|
|
432
441
|
var sampleClip = (clip, partId, time) => {
|
|
433
442
|
const points = clip.keys.map((key2) => {
|
|
434
|
-
const
|
|
435
|
-
return { t: key2.t, position:
|
|
443
|
+
const pose2 = partId === void 0 ? key2 : key2.parts?.[partId];
|
|
444
|
+
return { t: key2.t, position: pose2?.position ?? ZERO, rotation: pose2?.rotation ?? ZERO };
|
|
436
445
|
});
|
|
437
446
|
const first = points[0];
|
|
438
447
|
if (!first || first.t > 0) points.unshift({ t: 0, position: ZERO, rotation: ZERO });
|
|
@@ -15373,10 +15382,10 @@ var GameWeaponsThree = (() => {
|
|
|
15373
15382
|
// tucking a pistol in the belt and drawing it back is a short motion of one hand
|
|
15374
15383
|
stowSeconds: 0.45
|
|
15375
15384
|
},
|
|
15376
|
-
// as mãos de cada arma e onde ela vai quando as mãos são pedidas (decisão do dono, 2026-11-24): arma longa pede as duas mãos; a de cinto vai no coldre, a longa na bandoleira ou nas costas
|
|
15385
|
+
// as mãos de cada arma e onde ela vai quando as mãos são pedidas (decisão do dono, 2026-11-24): arma longa pede as duas mãos; a de cinto vai no coldre, a longa na bandoleira ou nas costas; o fuzil e a espingarda pendem da bandoleira (dono, 2026-11-25): sem bandoleira vão para as costas (SLOT_FALLBACKS do game-player)
|
|
15377
15386
|
hands: {
|
|
15378
15387
|
twoHanded: { categories: ["smg", "rifle", "carbine", "sniper", "dmr", "hunting", "machine_gun", "launcher", "shotgun", "bow", "crossbow", "extinguisher"], weapons: ["flamethrower"] },
|
|
15379
|
-
slots: { pistol: "hip", revolver: "hip", melee_blade: "hip", melee_blunt: "hip", tool: "hip", throwable: "hip", heat: "hip", smg: "
|
|
15388
|
+
slots: { pistol: "hip", revolver: "hip", melee_blade: "hip", melee_blunt: "hip", tool: "hip", throwable: "hip", heat: "hip", smg: "sling", rifle: "sling", carbine: "sling", sniper: "sling", dmr: "sling", hunting: "sling", shotgun: "sling", bow: "back", crossbow: "back", machine_gun: "back", launcher: "back" },
|
|
15380
15389
|
// the long-handled tools and the long blade hang across the back; a chainsaw has no place on the body
|
|
15381
15390
|
weaponSlots: { lighter: "hip", flamethrower: "back", axe: "back", sledgehammer: "back", pickaxe: "back", shovel: "back", katana: "back", chainsaw: null },
|
|
15382
15391
|
bare: ["kick", "shove", "fists"]
|
|
@@ -15411,16 +15420,16 @@ var GameWeaponsThree = (() => {
|
|
|
15411
15420
|
var EPS = 1e-9;
|
|
15412
15421
|
var STILL_STEPS = 2;
|
|
15413
15422
|
var STILL_SHARE = 0.05;
|
|
15414
|
-
var bounce = (
|
|
15415
|
-
const along2 = dot(
|
|
15416
|
-
if (along2 >= 0) return
|
|
15423
|
+
var bounce = (velocity2, normal, ground, rules) => {
|
|
15424
|
+
const along2 = dot(velocity2, normal);
|
|
15425
|
+
if (along2 >= 0) return velocity2;
|
|
15417
15426
|
const restitution = ground ? rules.groundRestitution : rules.wallRestitution;
|
|
15418
15427
|
const friction = ground ? rules.groundFriction : 1;
|
|
15419
15428
|
const normalPart = [normal[0] * along2, normal[1] * along2, normal[2] * along2];
|
|
15420
15429
|
return [
|
|
15421
|
-
(
|
|
15422
|
-
(
|
|
15423
|
-
(
|
|
15430
|
+
(velocity2[0] - normalPart[0]) * friction - normalPart[0] * restitution,
|
|
15431
|
+
(velocity2[1] - normalPart[1]) * friction - normalPart[1] * restitution,
|
|
15432
|
+
(velocity2[2] - normalPart[2]) * friction - normalPart[2] * restitution
|
|
15424
15433
|
];
|
|
15425
15434
|
};
|
|
15426
15435
|
var ExplosiveBody = class {
|
|
@@ -15601,13 +15610,13 @@ var GameWeaponsThree = (() => {
|
|
|
15601
15610
|
return range3[0] + (range3[1] - range3[0]) * random();
|
|
15602
15611
|
};
|
|
15603
15612
|
var launcherUses = ({ action, explosive, origin, direction, armDistance }) => {
|
|
15604
|
-
const
|
|
15613
|
+
const velocity2 = [direction[0] * action.speed, direction[1] * action.speed, direction[2] * action.speed];
|
|
15605
15614
|
const projectile = {
|
|
15606
15615
|
kind: "throw",
|
|
15607
15616
|
energy: explosive?.energy ?? 0,
|
|
15608
15617
|
radius: explosive?.lethalRadius ?? 0,
|
|
15609
15618
|
fuse: 0,
|
|
15610
|
-
velocity,
|
|
15619
|
+
velocity: velocity2,
|
|
15611
15620
|
origin,
|
|
15612
15621
|
explosive: action.projectile,
|
|
15613
15622
|
trigger: "impact",
|
|
@@ -15639,8 +15648,8 @@ var GameWeaponsThree = (() => {
|
|
|
15639
15648
|
var throwableUse = (params) => {
|
|
15640
15649
|
const { action, explosive, origin, direction, fuse, cooked, inHand } = params;
|
|
15641
15650
|
if (explosive && isPlaced(explosive, fuse, params.rules)) return placedUse({ ...params, explosive });
|
|
15642
|
-
const
|
|
15643
|
-
const use = { kind: "throw", energy: action.energy, radius: action.radius, fuse, velocity, origin };
|
|
15651
|
+
const velocity2 = inHand ? [0, 0, 0] : [direction[0] * action.throwSpeed, direction[1] * action.throwSpeed + action.throwSpeed * THROW_LIFT, direction[2] * action.throwSpeed];
|
|
15652
|
+
const use = { kind: "throw", energy: action.energy, radius: action.radius, fuse, velocity: velocity2, origin };
|
|
15644
15653
|
if (cooked !== void 0) use.cooked = cooked;
|
|
15645
15654
|
if (inHand) use.inHand = true;
|
|
15646
15655
|
if (action.fire) use.fire = { ...action.fire };
|
|
@@ -17059,6 +17068,44 @@ ${problems.map((problem) => ` - ${problem}`).join("\n")}`);
|
|
|
17059
17068
|
if (optic) return optic.zoom[0];
|
|
17060
17069
|
return arsenal.rules.aim.ironSightZoom[def.category] ?? 1;
|
|
17061
17070
|
}
|
|
17071
|
+
var SLING_SWING_DEFAULTS = { length: 0.34, damping: 2.6, limits: { forward: 0.9, side: 0.75 }, restitution: 0.25, maxStep: 1 / 240, gravity: 9.81 };
|
|
17072
|
+
function createSlingSwing(rules = SLING_SWING_DEFAULTS) {
|
|
17073
|
+
let forward = 0;
|
|
17074
|
+
let side = 0;
|
|
17075
|
+
let forwardSpeed = 0;
|
|
17076
|
+
let sideSpeed = 0;
|
|
17077
|
+
const bounce22 = (angle, speed, min2, max2) => {
|
|
17078
|
+
if (angle < min2) return [min2, speed < 0 ? -speed * rules.restitution : speed];
|
|
17079
|
+
if (angle > max2) return [max2, speed > 0 ? -speed * rules.restitution : speed];
|
|
17080
|
+
return [angle, speed];
|
|
17081
|
+
};
|
|
17082
|
+
const substep = (h, acceleration) => {
|
|
17083
|
+
const gravity = Math.max(0.5, rules.gravity + acceleration[1]);
|
|
17084
|
+
const forwardAccel = (-gravity * Math.sin(forward) - acceleration[2] * Math.cos(forward)) / rules.length - rules.damping * forwardSpeed;
|
|
17085
|
+
const sideAccel = (-gravity * Math.sin(side) - acceleration[0] * Math.cos(side)) / rules.length - rules.damping * sideSpeed;
|
|
17086
|
+
forwardSpeed += forwardAccel * h;
|
|
17087
|
+
sideSpeed += sideAccel * h;
|
|
17088
|
+
[forward, forwardSpeed] = bounce22(forward + forwardSpeed * h, forwardSpeed, 0, rules.limits.forward);
|
|
17089
|
+
[side, sideSpeed] = bounce22(side + sideSpeed * h, sideSpeed, -rules.limits.side, rules.limits.side);
|
|
17090
|
+
};
|
|
17091
|
+
return {
|
|
17092
|
+
step(dt, acceleration) {
|
|
17093
|
+
let left = Math.max(0, Math.min(dt, 0.25));
|
|
17094
|
+
while (left > 1e-9) {
|
|
17095
|
+
const h = Math.min(rules.maxStep, left);
|
|
17096
|
+
substep(h, acceleration);
|
|
17097
|
+
left -= h;
|
|
17098
|
+
}
|
|
17099
|
+
return { forward, side };
|
|
17100
|
+
},
|
|
17101
|
+
get state() {
|
|
17102
|
+
return { forward, side };
|
|
17103
|
+
},
|
|
17104
|
+
reset() {
|
|
17105
|
+
forward = side = forwardSpeed = sideSpeed = 0;
|
|
17106
|
+
}
|
|
17107
|
+
};
|
|
17108
|
+
}
|
|
17062
17109
|
var isGenericKind = (kind, category) => kind === "firearm" && category !== "bow" && category !== "crossbow" || kind === "flame";
|
|
17063
17110
|
function genericWeapons(arsenal) {
|
|
17064
17111
|
const archetypes = new Set(ARCHETYPE_IDS);
|
|
@@ -24684,37 +24731,37 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
24684
24731
|
if (shape.kind === "cylinder") return [shape.radius, shape.height / 2, shape.radius];
|
|
24685
24732
|
return [shape.radius, shape.radius, shape.radius];
|
|
24686
24733
|
};
|
|
24687
|
-
var hostedSolids = (spec, state,
|
|
24734
|
+
var hostedSolids = (spec, state, pose2) => {
|
|
24688
24735
|
const byId = new Map((state?.parts ?? []).map((p) => [p.id, p]));
|
|
24689
24736
|
const out = [];
|
|
24690
24737
|
for (const ps of spec.parts) {
|
|
24691
24738
|
const st = byId.get(ps.id);
|
|
24692
24739
|
if (st && (GONE.has(st.status) || st.group !== 0)) continue;
|
|
24693
|
-
const ov =
|
|
24694
|
-
const center = toWorld(
|
|
24695
|
-
const rotation2 = quat.mul(
|
|
24740
|
+
const ov = pose2.poses.get(ps.id);
|
|
24741
|
+
const center = toWorld(pose2.position, pose2.rotation, ov?.pos ?? ps.position);
|
|
24742
|
+
const rotation2 = quat.mul(pose2.rotation, ov?.q ?? quatFromEuler(...ps.rotation ?? [0, 0, 0]));
|
|
24696
24743
|
out.push({ center, half: halfOf(ps.shape), rotation: rotation2 });
|
|
24697
24744
|
}
|
|
24698
24745
|
return out;
|
|
24699
24746
|
};
|
|
24700
24747
|
var placedPieces = /* @__PURE__ */ new WeakMap();
|
|
24701
24748
|
var isSamePose = ({ known, position, rotation: rotation2 }) => known.position[0] === position[0] && known.position[1] === position[1] && known.position[2] === position[2] && known.rotation[0] === rotation2[0] && known.rotation[1] === rotation2[1] && known.rotation[2] === rotation2[2] && known.rotation[3] === rotation2[3];
|
|
24702
|
-
var hostedPieces = (pieces,
|
|
24749
|
+
var hostedPieces = (pieces, pose2) => pieces.map((piece2, index) => {
|
|
24703
24750
|
const known = placedPieces.get(piece2);
|
|
24704
|
-
const p =
|
|
24751
|
+
const p = pose2.position, q = pose2.rotation;
|
|
24705
24752
|
const isSamePlace = known !== void 0 && (piece2.key !== void 0 || known.index === index) && isSamePose({ known, position: p, rotation: q });
|
|
24706
24753
|
if (known && isSamePlace) return known.solid;
|
|
24707
|
-
const solid2 = placedPiece(piece2, index,
|
|
24754
|
+
const solid2 = placedPiece(piece2, index, pose2);
|
|
24708
24755
|
placedPieces.set(piece2, { position: [p[0], p[1], p[2]], rotation: [q[0], q[1], q[2], q[3]], index, solid: solid2 });
|
|
24709
24756
|
return solid2;
|
|
24710
24757
|
});
|
|
24711
|
-
var placedPiece = (piece2, index,
|
|
24712
|
-
const base = { center: toWorld(
|
|
24758
|
+
var placedPiece = (piece2, index, pose2) => {
|
|
24759
|
+
const base = { center: toWorld(pose2.position, pose2.rotation, piece2.center), half: piece2.half, rotation: quat.mul(pose2.rotation, piece2.rotation), key: piece2.key ?? `${piece2.id}:${index}` };
|
|
24713
24760
|
if (!piece2.mesh) return base;
|
|
24714
24761
|
const source = piece2.mesh.vertices;
|
|
24715
24762
|
const vertices = new Float32Array(source.length);
|
|
24716
24763
|
for (let i = 0; i < source.length; i += 3) {
|
|
24717
|
-
const world = toWorld(
|
|
24764
|
+
const world = toWorld(pose2.position, pose2.rotation, [source[i], source[i + 1], source[i + 2]]);
|
|
24718
24765
|
vertices[i] = world[0];
|
|
24719
24766
|
vertices[i + 1] = world[1];
|
|
24720
24767
|
vertices[i + 2] = world[2];
|
|
@@ -53639,8 +53686,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
53639
53686
|
}
|
|
53640
53687
|
}
|
|
53641
53688
|
connect(e, spec, valves);
|
|
53642
|
-
const
|
|
53643
|
-
world.add(e.id, spec, { x:
|
|
53689
|
+
const pose2 = at(e.item);
|
|
53690
|
+
world.add(e.id, spec, { x: pose2.x, y: e.floorY, z: pose2.z, ry: pose2.ry });
|
|
53644
53691
|
out.added++;
|
|
53645
53692
|
if (!isBlocked2) continue;
|
|
53646
53693
|
for (const p of spec.parts || []) {
|
|
@@ -54847,7 +54894,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
54847
54894
|
}
|
|
54848
54895
|
var residentialTower = residentialTowerTemplate();
|
|
54849
54896
|
|
|
54850
|
-
// ../game-floorplan-three/dist/chunk-
|
|
54897
|
+
// ../game-floorplan-three/dist/chunk-W4VG2X7N.js
|
|
54851
54898
|
var __defProp4 = Object.defineProperty;
|
|
54852
54899
|
var __defNormalProp2 = (obj, key2, value) => key2 in obj ? __defProp4(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
|
|
54853
54900
|
var __publicField2 = (obj, key2, value) => __defNormalProp2(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
|
|
@@ -67243,7 +67290,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
67243
67290
|
if (LOOSE.has(part.material) || part.shape.kind !== "box" || part.rotation) continue;
|
|
67244
67291
|
const [x, y, z] = part.shape.size;
|
|
67245
67292
|
if (y >= x && y >= z) {
|
|
67246
|
-
if (z < x && x >= 0.6 * width)
|
|
67293
|
+
if (z < x && x >= 0.6 * width) {
|
|
67294
|
+
part.anchored = false;
|
|
67295
|
+
part.structure = { role: "beam", maxSpan: SHELF_SPAN * x };
|
|
67296
|
+
continue;
|
|
67297
|
+
}
|
|
67247
67298
|
part.structure = { role: "column" };
|
|
67248
67299
|
} else if (y <= x && y <= z) part.structure = { role: "beam", maxSpan: SHELF_SPAN * Math.max(x, z) };
|
|
67249
67300
|
}
|
|
@@ -81168,9 +81219,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
81168
81219
|
hold.works?.forEach((work, index) => {
|
|
81169
81220
|
const k = weights2?.[index] ?? 0;
|
|
81170
81221
|
if (k <= 0) return;
|
|
81171
|
-
const
|
|
81172
|
-
if (work.hand === "R") right = right ? blendPose(THREE, right,
|
|
81173
|
-
else left = left ? blendPose(THREE, left,
|
|
81222
|
+
const pose2 = poseOf(work.anchor, rootQuaternion);
|
|
81223
|
+
if (work.hand === "R") right = right ? blendPose(THREE, right, pose2, k) : pose2;
|
|
81224
|
+
else left = left ? blendPose(THREE, left, pose2, k) : pose2;
|
|
81174
81225
|
});
|
|
81175
81226
|
const targets = { R: right, L: left, grip: hold.grip, gripL: hold.gripLeft, scale: hold.scale };
|
|
81176
81227
|
if (hold.slideLeft && left) {
|
|
@@ -81927,13 +81978,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
81927
81978
|
}
|
|
81928
81979
|
var REGION_NAMES = ["wall", "sidewalk", "curb", "road"];
|
|
81929
81980
|
var dot3 = (a, b) => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
81930
|
-
function impactOf(region, position,
|
|
81981
|
+
function impactOf(region, position, velocity2, cellSize) {
|
|
81931
81982
|
const local2 = [position[0] - region.origin[0], position[1] - region.origin[1], position[2] - region.origin[2]];
|
|
81932
81983
|
return {
|
|
81933
81984
|
row: region.firstRow + dot3(local2, region.rowAxis) / cellSize,
|
|
81934
81985
|
column: dot3(local2, region.columnAxis) / cellSize,
|
|
81935
|
-
along: [dot3(
|
|
81936
|
-
normalSpeed: -dot3(
|
|
81986
|
+
along: [dot3(velocity2, region.columnAxis), dot3(velocity2, region.rowAxis)],
|
|
81987
|
+
normalSpeed: -dot3(velocity2, region.normal)
|
|
81937
81988
|
};
|
|
81938
81989
|
}
|
|
81939
81990
|
function cellToWorldOf(regions, cellSize, row, column) {
|
|
@@ -82033,7 +82084,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
82033
82084
|
}
|
|
82034
82085
|
return -1;
|
|
82035
82086
|
},
|
|
82036
|
-
impact: (region, position,
|
|
82087
|
+
impact: (region, position, velocity2) => impactOf(regions[region], position, velocity2, cellSize),
|
|
82037
82088
|
contains: (position) => position[0] > originX && position[0] < maxX && (!rules.clipRoadEnd || position[2] < roadEndZ),
|
|
82038
82089
|
escaped(position) {
|
|
82039
82090
|
if (position[1] < -1) return true;
|
|
@@ -88676,11 +88727,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
88676
88727
|
}
|
|
88677
88728
|
|
|
88678
88729
|
// src/models/explosives.ts
|
|
88730
|
+
var M67_PARTS = {
|
|
88731
|
+
bodyRadius: 0.032,
|
|
88732
|
+
fuze: { radius: 0.011, height: 0.022, y: 0.04 },
|
|
88733
|
+
spoon: { size: [0.012, 0.07, 6e-3], x: 0.016, y: 0.018, tilt: 0.2 }
|
|
88734
|
+
};
|
|
88679
88735
|
var grenade = (kit, group) => {
|
|
88680
88736
|
const { M, sphere: sphere2, cylinderY, box: box5, torus: torus2, THREE } = kit;
|
|
88681
|
-
|
|
88682
|
-
|
|
88683
|
-
|
|
88737
|
+
const { bodyRadius, fuze, spoon } = M67_PARTS;
|
|
88738
|
+
sphere2(group, bodyRadius, M.olive, 0, bodyRadius, 0, 1);
|
|
88739
|
+
cylinderY(group, fuze.radius, fuze.height, M.metal, 0, bodyRadius + fuze.y, 0);
|
|
88740
|
+
box5(group, ...spoon.size, M.metal, spoon.x, bodyRadius + spoon.y, 0, spoon.tilt);
|
|
88684
88741
|
torus2(group, new THREE.TorusGeometry(85e-4, 16e-4, 6, 12), M.steel, -0.012, 0.082, 0);
|
|
88685
88742
|
kit.mark(group, 0, 0.032, 0).name = "handle";
|
|
88686
88743
|
};
|
|
@@ -88920,7 +88977,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
88920
88977
|
model.position.lerpVectors(holderAt, model.position, k);
|
|
88921
88978
|
hand.updateMatrixWorld(true);
|
|
88922
88979
|
};
|
|
88923
|
-
const throwBody = (kind, mesh3, from,
|
|
88980
|
+
const throwBody = (kind, mesh3, from, velocity2, radius) => {
|
|
88924
88981
|
if (!(kind === "casing" ? layers.casings : layers.magazines)) {
|
|
88925
88982
|
mesh3.geometry.dispose();
|
|
88926
88983
|
return;
|
|
@@ -88931,7 +88988,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
88931
88988
|
mesh3.position.copy(from);
|
|
88932
88989
|
mesh3.castShadow = true;
|
|
88933
88990
|
scene.add(mesh3);
|
|
88934
|
-
bodies.push({ mesh: mesh3, velocity, spin: new THREE.Vector3(random() * 20 - 10, random() * 30 - 15, random() * 20 - 10), radius, age: 0, resting: false, bounces: 0, kind });
|
|
88991
|
+
bodies.push({ mesh: mesh3, velocity: velocity2, spin: new THREE.Vector3(random() * 20 - 10, random() * 30 - 15, random() * 20 - 10), radius, age: 0, resting: false, bounces: 0, kind });
|
|
88935
88992
|
};
|
|
88936
88993
|
const ejectCasing = (caliberMm, isShell, downward) => {
|
|
88937
88994
|
const radius = isShell ? 0.0105 : Math.max(3e-3, caliberMm / 1e3 * 0.6);
|
|
@@ -88941,8 +88998,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
88941
88998
|
const from = handPoint(0.03, 0.03, 0.05, new THREE.Vector3());
|
|
88942
88999
|
const right = new THREE.Vector3(1, 0, 0).applyQuaternion(camera2.quaternion);
|
|
88943
89000
|
const up = new THREE.Vector3(0, 1, 0);
|
|
88944
|
-
const
|
|
88945
|
-
throwBody("casing", mesh3, from,
|
|
89001
|
+
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);
|
|
89002
|
+
throwBody("casing", mesh3, from, velocity2, radius);
|
|
88946
89003
|
};
|
|
88947
89004
|
const dropMagazine = (category) => {
|
|
88948
89005
|
const long = category === "rifle" || category === "sniper" || category === "carbine";
|
|
@@ -89143,14 +89200,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
89143
89200
|
const poses = /* @__PURE__ */ new Map();
|
|
89144
89201
|
for (const [key2, list2] of channels) {
|
|
89145
89202
|
const [part, channel, axis2] = key2.split("|");
|
|
89146
|
-
const
|
|
89147
|
-
|
|
89148
|
-
poses.set(part,
|
|
89203
|
+
const pose2 = poses.get(part) ?? { position: [0, 0, 0], rotation: [0, 0, 0] };
|
|
89204
|
+
pose2[channel][AXIS_INDEX[axis2]] = round3(valueAt(list2, t, includeInstants));
|
|
89205
|
+
poses.set(part, pose2);
|
|
89149
89206
|
}
|
|
89150
89207
|
const root = poses.get(ROOT2);
|
|
89151
89208
|
poses.delete(ROOT2);
|
|
89152
89209
|
const parts2 = {};
|
|
89153
|
-
for (const [part,
|
|
89210
|
+
for (const [part, pose2] of poses) parts2[part] = pose2;
|
|
89154
89211
|
return { t, ...root ? { position: root.position, rotation: root.rotation } : {}, ...poses.size ? { parts: parts2 } : {} };
|
|
89155
89212
|
};
|
|
89156
89213
|
const keys = [];
|
|
@@ -91749,12 +91806,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
91749
91806
|
return false;
|
|
91750
91807
|
}
|
|
91751
91808
|
};
|
|
91752
|
-
function slideInto(out,
|
|
91753
|
-
const into =
|
|
91809
|
+
function slideInto(out, velocity2) {
|
|
91810
|
+
const into = velocity2.vx * out.nx + velocity2.vy * out.ny + velocity2.vz * out.nz;
|
|
91754
91811
|
if (into >= 0) return;
|
|
91755
|
-
|
|
91756
|
-
|
|
91757
|
-
|
|
91812
|
+
velocity2.vx -= into * out.nx;
|
|
91813
|
+
velocity2.vy -= into * out.ny;
|
|
91814
|
+
velocity2.vz -= into * out.nz;
|
|
91758
91815
|
}
|
|
91759
91816
|
function slideAlong(out, vx2, vy2, vz2) {
|
|
91760
91817
|
const into = vx2 * out.nx + vy2 * out.ny + vz2 * out.nz;
|
|
@@ -93988,10 +94045,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
93988
94045
|
var FLASH_SCALE = variable("flash");
|
|
93989
94046
|
var fallback = (name, defaultValue) => ite(ne(variable(name), void 0), variable(name), defaultValue);
|
|
93990
94047
|
var wide = (width) => mul(sub(rand(), 0.5), width);
|
|
93991
|
-
var puff2 = (point,
|
|
94048
|
+
var puff2 = (point, velocity2, world, radius, life, opacity, growth = SMOKE.growth) => mesh2({
|
|
93992
94049
|
shape: "sphere",
|
|
93993
94050
|
p: point,
|
|
93994
|
-
v:
|
|
94051
|
+
v: velocity2,
|
|
93995
94052
|
wv: world,
|
|
93996
94053
|
r: radius,
|
|
93997
94054
|
seg: SMOKE.width,
|
|
@@ -94005,9 +94062,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94005
94062
|
drag: SMOKE.drag,
|
|
94006
94063
|
grow: growth
|
|
94007
94064
|
});
|
|
94008
|
-
var flameBit = (point,
|
|
94065
|
+
var flameBit = (point, velocity2, world, radius, life) => [
|
|
94009
94066
|
set("bitPoint", point),
|
|
94010
|
-
set("bitVelocity",
|
|
94067
|
+
set("bitVelocity", velocity2),
|
|
94011
94068
|
set("bitWorld", world),
|
|
94012
94069
|
set("bitRadius", radius),
|
|
94013
94070
|
set("bitLife", life),
|
|
@@ -94438,7 +94495,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94438
94495
|
var clamp32 = (value, low, high) => value < low ? low : value > high ? high : value;
|
|
94439
94496
|
function createCylinderBehavior() {
|
|
94440
94497
|
let position = SPOT2;
|
|
94441
|
-
let
|
|
94498
|
+
let velocity2 = [0, 0, 0];
|
|
94442
94499
|
let rotationZ = 0;
|
|
94443
94500
|
let angle = 0;
|
|
94444
94501
|
let spin = 0;
|
|
@@ -94447,7 +94504,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94447
94504
|
let direction = [1, 0, 0];
|
|
94448
94505
|
const clear = () => {
|
|
94449
94506
|
position = SPOT2;
|
|
94450
|
-
|
|
94507
|
+
velocity2 = [0, 0, 0];
|
|
94451
94508
|
rotationZ = 0;
|
|
94452
94509
|
angle = 0;
|
|
94453
94510
|
spin = 0;
|
|
@@ -94462,7 +94519,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94462
94519
|
oxygen = args.oxygen;
|
|
94463
94520
|
} else if (action === "puncture") {
|
|
94464
94521
|
live = true;
|
|
94465
|
-
if (oxygen)
|
|
94522
|
+
if (oxygen) velocity2 = [-5, 0, -0.3];
|
|
94466
94523
|
else spin = 9;
|
|
94467
94524
|
} else if (action === "step") {
|
|
94468
94525
|
if (!live) return;
|
|
@@ -94476,18 +94533,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94476
94533
|
position = [position[0] + direction[0] * (-0.6 * k * dt), y + direction[1] * (-0.6 * k * dt), position[2] + direction[2] * (-0.6 * k * dt)];
|
|
94477
94534
|
return;
|
|
94478
94535
|
}
|
|
94479
|
-
let [vx2, vy2, vz2] =
|
|
94536
|
+
let [vx2, vy2, vz2] = velocity2;
|
|
94480
94537
|
if (k > 0) vx2 -= 4 * k * dt;
|
|
94481
94538
|
const damping = Math.exp(-dt * (k > 0 ? 0.3 : 3));
|
|
94482
94539
|
vx2 *= damping;
|
|
94483
94540
|
vy2 *= damping;
|
|
94484
94541
|
vz2 *= damping;
|
|
94485
|
-
|
|
94542
|
+
velocity2 = [vx2, vy2, vz2];
|
|
94486
94543
|
rotationZ = lerp3(rotationZ, -QUARTER_TURN2, dt * 10);
|
|
94487
94544
|
position = [position[0] + vx2 * dt, lerp3(position[1], 0.12, dt * 10) + vy2 * dt, position[2] + vz2 * dt];
|
|
94488
94545
|
if (position[0] < WALL_X) {
|
|
94489
94546
|
position = [WALL_X, position[1], position[2]];
|
|
94490
|
-
|
|
94547
|
+
velocity2 = [velocity2[0] * -0.3, velocity2[1], velocity2[2]];
|
|
94491
94548
|
host.engine.screen.shake += 0.08;
|
|
94492
94549
|
sparkAt(host.engine, position, normalized([1, 0.5, 0]), 16, 1);
|
|
94493
94550
|
}
|
|
@@ -94504,7 +94561,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
94504
94561
|
case "direction":
|
|
94505
94562
|
return direction;
|
|
94506
94563
|
case "speed_x":
|
|
94507
|
-
return
|
|
94564
|
+
return velocity2[0];
|
|
94508
94565
|
case "rotation_z":
|
|
94509
94566
|
return rotationZ;
|
|
94510
94567
|
case "tip":
|
|
@@ -95275,10 +95332,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
95275
95332
|
return { origin, anchor: entry2.anchor, yaw: entry2.yaw, ...entry2.orientation ? { orientation: entry2.orientation } : {} };
|
|
95276
95333
|
}
|
|
95277
95334
|
function moveCarrier(entry2) {
|
|
95278
|
-
const
|
|
95279
|
-
if (!
|
|
95280
|
-
entry2.carrier.origin = [
|
|
95281
|
-
if (
|
|
95335
|
+
const pose2 = entry2.track?.();
|
|
95336
|
+
if (!pose2 || !entry2.carrier) return;
|
|
95337
|
+
entry2.carrier.origin = [pose2.point[0], pose2.point[1], pose2.point[2]];
|
|
95338
|
+
if (pose2.orientation) entry2.carrier.orientation = pose2.orientation;
|
|
95282
95339
|
}
|
|
95283
95340
|
function drawing(entry2, action) {
|
|
95284
95341
|
const context = engine.context;
|
|
@@ -96697,9 +96754,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
96697
96754
|
return { index, def: this.defs[index] };
|
|
96698
96755
|
}
|
|
96699
96756
|
/** One sprite with an explicit velocity. */
|
|
96700
|
-
spawn(kind, point,
|
|
96757
|
+
spawn(kind, point, velocity2, options) {
|
|
96701
96758
|
const { index, def } = this.kindOf(kind);
|
|
96702
|
-
(def.additive ? this.additive : this.normal).spawn(index, point,
|
|
96759
|
+
(def.additive ? this.additive : this.normal).spawn(index, point, velocity2, this.random, options);
|
|
96703
96760
|
}
|
|
96704
96761
|
/** `count` sprites leaving `point` around `normal` at about `speed` m/s. */
|
|
96705
96762
|
burst(kind, point, normal, count, speed = 1, options) {
|
|
@@ -97019,7 +97076,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97019
97076
|
return this.particles.length;
|
|
97020
97077
|
}
|
|
97021
97078
|
spawn(options, frame2 = IDENTITY2, carried) {
|
|
97022
|
-
const
|
|
97079
|
+
const velocity2 = options.v ?? [0, 0, 0];
|
|
97023
97080
|
const world = options.wv ?? [0, 0, 0];
|
|
97024
97081
|
const particle = {
|
|
97025
97082
|
id: ++this.serial,
|
|
@@ -97046,9 +97103,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97046
97103
|
opacity: options.a,
|
|
97047
97104
|
age: 0,
|
|
97048
97105
|
life: options.life,
|
|
97049
|
-
vx:
|
|
97050
|
-
vy:
|
|
97051
|
-
vz:
|
|
97106
|
+
vx: velocity2[0] + world[0],
|
|
97107
|
+
vy: velocity2[1] + world[1],
|
|
97108
|
+
vz: velocity2[2] + world[2],
|
|
97052
97109
|
spin: options.spin ?? [0, 0, 0],
|
|
97053
97110
|
gravity: options.g ?? 0,
|
|
97054
97111
|
drag: options.drag ?? 0,
|
|
@@ -97228,7 +97285,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97228
97285
|
this.count = 0;
|
|
97229
97286
|
}
|
|
97230
97287
|
update(dt, leaveDecal) {
|
|
97231
|
-
const { position, velocity } = this;
|
|
97288
|
+
const { position, velocity: velocity2 } = this;
|
|
97232
97289
|
const confiner = this.context.confiner;
|
|
97233
97290
|
for (let index = this.count - 1; index >= 0; index--) {
|
|
97234
97291
|
this.life[index] -= dt;
|
|
@@ -97238,17 +97295,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97238
97295
|
}
|
|
97239
97296
|
const offset = index * FLOATS_PER_VECTOR;
|
|
97240
97297
|
const age = 1 - this.life[index] / this.maxLife[index];
|
|
97241
|
-
|
|
97298
|
+
velocity2[offset + 1] -= this.gravity[index] * dt;
|
|
97242
97299
|
const factor = Math.max(0, 1 - this.drag[index] * dt);
|
|
97243
|
-
|
|
97244
|
-
|
|
97245
|
-
|
|
97300
|
+
velocity2[offset] *= factor;
|
|
97301
|
+
velocity2[offset + 1] *= factor;
|
|
97302
|
+
velocity2[offset + 2] *= factor;
|
|
97246
97303
|
const x0 = position[offset];
|
|
97247
97304
|
const y0 = position[offset + 1];
|
|
97248
97305
|
const z0 = position[offset + 2];
|
|
97249
|
-
position[offset] +=
|
|
97250
|
-
position[offset + 1] +=
|
|
97251
|
-
position[offset + 2] +=
|
|
97306
|
+
position[offset] += velocity2[offset] * dt;
|
|
97307
|
+
position[offset + 1] += velocity2[offset + 1] * dt;
|
|
97308
|
+
position[offset + 2] += velocity2[offset + 2] * dt;
|
|
97252
97309
|
if (this.carried && confiner && !confiner.empty && Math.abs(this.gravity[index]) < CARRIED_GRAVITY) {
|
|
97253
97310
|
const size = this.startSize[index] * (1 + (this.growth[index] - 1) * age);
|
|
97254
97311
|
if (confiner.confine(x0, y0, z0, position[offset], position[offset + 1], position[offset + 2], size * PAD_OF_SIZE3, dt)) {
|
|
@@ -97256,10 +97313,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97256
97313
|
position[offset] = out.x;
|
|
97257
97314
|
position[offset + 1] = out.y;
|
|
97258
97315
|
position[offset + 2] = out.z;
|
|
97259
|
-
const [vx2, vy2, vz2] = slideAlong(out,
|
|
97260
|
-
|
|
97261
|
-
|
|
97262
|
-
|
|
97316
|
+
const [vx2, vy2, vz2] = slideAlong(out, velocity2[offset], velocity2[offset + 1], velocity2[offset + 2]);
|
|
97317
|
+
velocity2[offset] = vx2;
|
|
97318
|
+
velocity2[offset + 1] = vy2;
|
|
97319
|
+
velocity2[offset + 2] = vz2;
|
|
97263
97320
|
}
|
|
97264
97321
|
}
|
|
97265
97322
|
const mode = this.groundMode[index];
|
|
@@ -97272,9 +97329,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97272
97329
|
}
|
|
97273
97330
|
if (mode === 2) {
|
|
97274
97331
|
position[offset + 1] = groundHeight + 1e-3;
|
|
97275
|
-
|
|
97276
|
-
|
|
97277
|
-
|
|
97332
|
+
velocity2[offset + 1] *= -0.3;
|
|
97333
|
+
velocity2[offset] *= 0.55;
|
|
97334
|
+
velocity2[offset + 2] *= 0.55;
|
|
97278
97335
|
}
|
|
97279
97336
|
if (mode === 3) {
|
|
97280
97337
|
if (this.context.quality.level < 2) {
|
|
@@ -97380,7 +97437,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97380
97437
|
this.count = 0;
|
|
97381
97438
|
}
|
|
97382
97439
|
update(dt) {
|
|
97383
|
-
const { point, velocity } = this;
|
|
97440
|
+
const { point, velocity: velocity2 } = this;
|
|
97384
97441
|
for (let index = this.count - 1; index >= 0; index--) {
|
|
97385
97442
|
this.life[index] -= dt;
|
|
97386
97443
|
if (this.life[index] <= 0) {
|
|
@@ -97389,14 +97446,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97389
97446
|
}
|
|
97390
97447
|
const offset = index * FLOATS_PER_VECTOR2;
|
|
97391
97448
|
const age = 1 - this.life[index] / this.maxLife[index];
|
|
97392
|
-
|
|
97449
|
+
velocity2[offset + 1] -= this.gravity[index] * dt;
|
|
97393
97450
|
const factor = Math.max(0, 1 - this.drag[index] * dt);
|
|
97394
|
-
|
|
97395
|
-
|
|
97396
|
-
|
|
97397
|
-
point[offset] +=
|
|
97398
|
-
point[offset + 1] +=
|
|
97399
|
-
point[offset + 2] +=
|
|
97451
|
+
velocity2[offset] *= factor;
|
|
97452
|
+
velocity2[offset + 1] *= factor;
|
|
97453
|
+
velocity2[offset + 2] *= factor;
|
|
97454
|
+
point[offset] += velocity2[offset] * dt;
|
|
97455
|
+
point[offset + 1] += velocity2[offset + 1] * dt;
|
|
97456
|
+
point[offset + 2] += velocity2[offset + 2] * dt;
|
|
97400
97457
|
if (this.groundMode[index]) {
|
|
97401
97458
|
const groundHeight = this.context.groundAt(point[offset], point[offset + 2]);
|
|
97402
97459
|
if (point[offset + 1] < groundHeight) {
|
|
@@ -97405,9 +97462,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97405
97462
|
continue;
|
|
97406
97463
|
}
|
|
97407
97464
|
point[offset + 1] = groundHeight + 1e-3;
|
|
97408
|
-
|
|
97409
|
-
|
|
97410
|
-
|
|
97465
|
+
velocity2[offset + 1] *= -0.35;
|
|
97466
|
+
velocity2[offset] *= 0.6;
|
|
97467
|
+
velocity2[offset + 2] *= 0.6;
|
|
97411
97468
|
}
|
|
97412
97469
|
}
|
|
97413
97470
|
const length2 = this.length[index];
|
|
@@ -97416,9 +97473,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97416
97473
|
this.segment[at32] = point[offset];
|
|
97417
97474
|
this.segment[at32 + 1] = point[offset + 1];
|
|
97418
97475
|
this.segment[at32 + 2] = point[offset + 2];
|
|
97419
|
-
this.segment[at32 + 3] = point[offset] -
|
|
97420
|
-
this.segment[at32 + 4] = point[offset + 1] -
|
|
97421
|
-
this.segment[at32 + 5] = point[offset + 2] -
|
|
97476
|
+
this.segment[at32 + 3] = point[offset] - velocity2[offset] * length2;
|
|
97477
|
+
this.segment[at32 + 4] = point[offset + 1] - velocity2[offset + 1] * length2;
|
|
97478
|
+
this.segment[at32 + 5] = point[offset + 2] - velocity2[offset + 2] * length2;
|
|
97422
97479
|
for (let channel = 0; channel < FLOATS_PER_VECTOR2; channel++) {
|
|
97423
97480
|
const shade3 = lerp2(this.colorStart[offset + channel], this.colorEnd[offset + channel], age) * alpha;
|
|
97424
97481
|
this.segmentColor[at32 + channel] = shade3;
|
|
@@ -97850,7 +97907,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
|
|
|
97850
97907
|
return true;
|
|
97851
97908
|
},
|
|
97852
97909
|
burst: (kind, point, normal, count, speed, spriteOptions) => spriteSystem.burst(kind, point, normal, count, speed, spriteOptions),
|
|
97853
|
-
spawn: (kind, point,
|
|
97910
|
+
spawn: (kind, point, velocity2, spriteOptions) => spriteSystem.spawn(kind, point, velocity2, spriteOptions),
|
|
97854
97911
|
onLand: (owner, listener) => spriteSystem.onLand(owner, listener),
|
|
97855
97912
|
sprites: () => spriteSystem,
|
|
97856
97913
|
workshop,
|
|
@@ -98156,9 +98213,9 @@ void main(){
|
|
|
98156
98213
|
geometry.setAttribute("position", new THREE.Float32BufferAttribute([-0.5, 0, 0, 0.5, 0, 0, 0.5, 1, 0, -0.5, 1, 0], 3));
|
|
98157
98214
|
geometry.setIndex([0, 1, 2, 0, 2, 3]);
|
|
98158
98215
|
const position = new Float32Array(capacity * 3);
|
|
98159
|
-
const
|
|
98216
|
+
const velocity2 = new Float32Array(capacity * 3);
|
|
98160
98217
|
const extra = new Float32Array(capacity * 4);
|
|
98161
|
-
const attributes = [dynamic(THREE, position, 3), dynamic(THREE,
|
|
98218
|
+
const attributes = [dynamic(THREE, position, 3), dynamic(THREE, velocity2, 3), dynamic(THREE, extra, 4)];
|
|
98162
98219
|
geometry.setAttribute("aPos", attributes[0]);
|
|
98163
98220
|
geometry.setAttribute("aVel", attributes[1]);
|
|
98164
98221
|
geometry.setAttribute("aE", attributes[2]);
|
|
@@ -98176,9 +98233,9 @@ void main(){
|
|
|
98176
98233
|
position[n * 3] = s.x;
|
|
98177
98234
|
position[n * 3 + 1] = s.y;
|
|
98178
98235
|
position[n * 3 + 2] = s.z;
|
|
98179
|
-
|
|
98180
|
-
|
|
98181
|
-
|
|
98236
|
+
velocity2[n * 3] = s.vx;
|
|
98237
|
+
velocity2[n * 3 + 1] = s.vy;
|
|
98238
|
+
velocity2[n * 3 + 2] = s.vz;
|
|
98182
98239
|
extra[n * 4] = s.age;
|
|
98183
98240
|
extra[n * 4 + 1] = s.w;
|
|
98184
98241
|
extra[n * 4 + 2] = s.st;
|
|
@@ -99573,13 +99630,13 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
99573
99630
|
muzzleFlash(position, orientation, size, profile = MUZZLE_SMOKE.smokeless, track) {
|
|
99574
99631
|
if (profile.puffs <= 0 && profile.flash <= 0) return;
|
|
99575
99632
|
const follow = track ? () => {
|
|
99576
|
-
const
|
|
99577
|
-
return
|
|
99633
|
+
const pose2 = track();
|
|
99634
|
+
return pose2 ? { point: vec4(pose2.position), orientation: quaternion(pose2.orientation) } : null;
|
|
99578
99635
|
} : void 0;
|
|
99579
99636
|
sink?.play({ effect: VIEWMODEL_EFFECT_IDS.flash, point: vec4(position), direction: barrel(orientation), orientation: quaternion(orientation), seed: seed(), values: { size, ...profile }, ...follow ? { track: follow } : {} });
|
|
99580
99637
|
},
|
|
99581
|
-
smoke(position,
|
|
99582
|
-
sink?.play({ effect: VIEWMODEL_EFFECT_IDS.smoke, point: vec4(position), seed: seed(), values: { vx:
|
|
99638
|
+
smoke(position, velocity2, size, life, opacity) {
|
|
99639
|
+
sink?.play({ effect: VIEWMODEL_EFFECT_IDS.smoke, point: vec4(position), seed: seed(), values: { vx: velocity2.x, vy: velocity2.y, vz: velocity2.z, radius: size, life, opacity } });
|
|
99583
99640
|
},
|
|
99584
99641
|
backblast(rear, orientation) {
|
|
99585
99642
|
sink?.play({ effect: VIEWMODEL_EFFECT_IDS.backblast, point: vec4(rear), direction: barrel(orientation), orientation: quaternion(orientation), seed: seed() });
|
|
@@ -99743,6 +99800,61 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
99743
99800
|
return { geometry, material };
|
|
99744
99801
|
}
|
|
99745
99802
|
|
|
99803
|
+
// src/engine-loose.ts
|
|
99804
|
+
var LOOSE_ROLLING_RESISTANCE = 0.015;
|
|
99805
|
+
var CASING_FILL = 0.25;
|
|
99806
|
+
var BRASS_DENSITY = 8500;
|
|
99807
|
+
var LOOSE_USER = { casing: 100 };
|
|
99808
|
+
var BOUNCE_FALL_SPEED = 0.5;
|
|
99809
|
+
var BOUNCE_RISE_SPEED = 0.2;
|
|
99810
|
+
var QUARTER_TURN_Z = [0, 0, Math.SQRT1_2, Math.SQRT1_2];
|
|
99811
|
+
var CASING_MATERIAL = { frictionStatic: 0.4, frictionDynamic: 0.3, restitution: 0.4 };
|
|
99812
|
+
function casingCollider(radius, length2) {
|
|
99813
|
+
return {
|
|
99814
|
+
shape: { kind: "compound", children: [{ shape: { kind: "cylinder", halfHeight: length2 / 2, radius }, position: [0, 0, 0], rotation: QUARTER_TURN_Z }] },
|
|
99815
|
+
mass: Math.PI * radius * radius * length2 * BRASS_DENSITY * CASING_FILL,
|
|
99816
|
+
material: CASING_MATERIAL,
|
|
99817
|
+
rolling: { coefficient: LOOSE_ROLLING_RESISTANCE, radius },
|
|
99818
|
+
user: LOOSE_USER.casing
|
|
99819
|
+
};
|
|
99820
|
+
}
|
|
99821
|
+
function spawnLoose(world, collider, launch) {
|
|
99822
|
+
const desc = {
|
|
99823
|
+
shape: collider.shape,
|
|
99824
|
+
motion: "dynamic",
|
|
99825
|
+
mass: collider.mass,
|
|
99826
|
+
position: [launch.position.x, launch.position.y, launch.position.z],
|
|
99827
|
+
rotation: [launch.rotation.x, launch.rotation.y, launch.rotation.z, launch.rotation.w],
|
|
99828
|
+
material: collider.material,
|
|
99829
|
+
layer: "debris",
|
|
99830
|
+
continuous: true,
|
|
99831
|
+
rolling: collider.rolling,
|
|
99832
|
+
linearVelocity: [launch.velocity.x, launch.velocity.y, launch.velocity.z],
|
|
99833
|
+
angularVelocity: [launch.spin.x, launch.spin.y, launch.spin.z],
|
|
99834
|
+
user: collider.user
|
|
99835
|
+
};
|
|
99836
|
+
return { id: world.createBody(desc), bounces: 0, fallSpeed: 0 };
|
|
99837
|
+
}
|
|
99838
|
+
var scratchReading = { asleep: false, bounceSpeed: void 0 };
|
|
99839
|
+
var pose = new Float64Array(7);
|
|
99840
|
+
var velocity = new Float64Array(6);
|
|
99841
|
+
function syncLoose(world, body, object2) {
|
|
99842
|
+
world.readPose(body.id, pose, 0);
|
|
99843
|
+
world.readVelocity(body.id, velocity, 0);
|
|
99844
|
+
object2.position.set(pose[0] ?? 0, pose[1] ?? 0, pose[2] ?? 0);
|
|
99845
|
+
object2.quaternion.set(pose[3] ?? 0, pose[4] ?? 0, pose[5] ?? 0, pose[6] ?? 1);
|
|
99846
|
+
const vertical = velocity[1] ?? 0;
|
|
99847
|
+
const bounced = body.fallSpeed > BOUNCE_FALL_SPEED && vertical > BOUNCE_RISE_SPEED;
|
|
99848
|
+
scratchReading.bounceSpeed = bounced ? body.fallSpeed : void 0;
|
|
99849
|
+
body.fallSpeed = vertical < 0 ? -vertical : 0;
|
|
99850
|
+
if (bounced) body.bounces++;
|
|
99851
|
+
scratchReading.asleep = world.isSleeping(body.id);
|
|
99852
|
+
return scratchReading;
|
|
99853
|
+
}
|
|
99854
|
+
function dropLoose(world, body) {
|
|
99855
|
+
world.removeBody(body.id);
|
|
99856
|
+
}
|
|
99857
|
+
|
|
99746
99858
|
// src/fx/particles.ts
|
|
99747
99859
|
var MAX_PARTICLES = 900;
|
|
99748
99860
|
var FLOOR_FRICTION = 0.45;
|
|
@@ -99757,7 +99869,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
99757
99869
|
if (mesh3.isMesh) mesh3.geometry.dispose();
|
|
99758
99870
|
});
|
|
99759
99871
|
};
|
|
99760
|
-
function createParticles(THREE, scene, groundAt, limit, surface) {
|
|
99872
|
+
function createParticles(THREE, scene, groundAt, limit, surface, physics) {
|
|
99761
99873
|
const from = new THREE.Vector3();
|
|
99762
99874
|
const step = new THREE.Vector3();
|
|
99763
99875
|
let list2 = [];
|
|
@@ -99767,6 +99879,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
99767
99879
|
});
|
|
99768
99880
|
particle.object.removeFromParent();
|
|
99769
99881
|
if (particle.ownsGeometry) disposeOwned(particle.object);
|
|
99882
|
+
if (particle.body && physics) dropLoose(physics, particle.body);
|
|
99770
99883
|
particle.onRemove?.();
|
|
99771
99884
|
if (particle.fadeFrom !== void 0) particle.object.material.dispose();
|
|
99772
99885
|
list2 = list2.filter((other) => other !== particle);
|
|
@@ -99782,24 +99895,24 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
99782
99895
|
if (!hit) return;
|
|
99783
99896
|
const at4 = origin.y + travel.y * hit.distance;
|
|
99784
99897
|
if (at4 <= groundAt(origin.x + travel.x * hit.distance, origin.z + travel.z * hit.distance) + radius + FLOOR_EPSILON) return;
|
|
99785
|
-
const { velocity } = particle;
|
|
99786
|
-
const impact3 = Math.abs(
|
|
99898
|
+
const { velocity: velocity2 } = particle;
|
|
99899
|
+
const impact3 = Math.abs(velocity2.dot(hit.normal));
|
|
99787
99900
|
object2.position.copy(origin).addScaledVector(travel, Math.max(0, hit.distance - radius));
|
|
99788
|
-
|
|
99789
|
-
|
|
99901
|
+
velocity2.addScaledVector(hit.normal, -(1 + particle.bounce) * velocity2.dot(hit.normal));
|
|
99902
|
+
velocity2.multiplyScalar(FLOOR_FRICTION);
|
|
99790
99903
|
particle.spin.multiplyScalar(FLOOR_FRICTION);
|
|
99791
99904
|
if (particle.bounces < 4) api.onBounce?.(particle.kind, { object: object2, speed: impact3, bounce: particle.bounces });
|
|
99792
99905
|
particle.bounces++;
|
|
99793
99906
|
};
|
|
99794
99907
|
const api = {
|
|
99795
|
-
spawn(object2,
|
|
99908
|
+
spawn(object2, velocity2, options = {}) {
|
|
99796
99909
|
object2.traverse((node) => {
|
|
99797
99910
|
node.userData[PARTICLE_USERDATA_KEY] = true;
|
|
99798
99911
|
});
|
|
99799
99912
|
scene.add(object2);
|
|
99800
99913
|
list2.push({
|
|
99801
99914
|
object: object2,
|
|
99802
|
-
velocity,
|
|
99915
|
+
velocity: velocity2,
|
|
99803
99916
|
spin: options.spin ?? new THREE.Vector3(),
|
|
99804
99917
|
age: 0,
|
|
99805
99918
|
resting: false,
|
|
@@ -99815,7 +99928,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
99815
99928
|
onGround: options.onGround,
|
|
99816
99929
|
ownsGeometry: options.ownsGeometry ?? false,
|
|
99817
99930
|
onRemove: options.onRemove,
|
|
99818
|
-
bounces: 0
|
|
99931
|
+
bounces: 0,
|
|
99932
|
+
body: options.collider && physics ? spawnLoose(physics, options.collider, { position: object2.position, rotation: object2.quaternion, velocity: velocity2, spin: options.spin ?? new THREE.Vector3() }) : void 0
|
|
99819
99933
|
});
|
|
99820
99934
|
const hostLimit = limit?.();
|
|
99821
99935
|
const oldest = list2[0];
|
|
@@ -99832,6 +99946,13 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
99832
99946
|
const { object: object2 } = particle;
|
|
99833
99947
|
if (particle.fadeFrom !== void 0) object2.material.opacity = Math.max(0, particle.fadeFrom * (1 - particle.age / particle.life));
|
|
99834
99948
|
if (particle.resting) continue;
|
|
99949
|
+
if (particle.body && physics) {
|
|
99950
|
+
const reading = syncLoose(physics, particle.body, object2);
|
|
99951
|
+
if (reading.bounceSpeed !== void 0 && particle.bounces < 4) api.onBounce?.(particle.kind, { object: object2, speed: reading.bounceSpeed, bounce: particle.bounces });
|
|
99952
|
+
if (reading.bounceSpeed !== void 0) particle.bounces++;
|
|
99953
|
+
if (reading.asleep) particle.resting = true;
|
|
99954
|
+
continue;
|
|
99955
|
+
}
|
|
99835
99956
|
particle.velocity.y -= particle.gravity * dt;
|
|
99836
99957
|
if (particle.drag) particle.velocity.multiplyScalar(Math.max(0, 1 - particle.drag * dt));
|
|
99837
99958
|
const probed = surface !== void 0 && SOLID_KINDS.has(particle.kind) && probes < MAX_PROBES_PER_FRAME && particle.velocity.lengthSq() > PROBE_MIN_SPEED * PROBE_MIN_SPEED;
|
|
@@ -99880,20 +100001,20 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
99880
100001
|
const registry = partRegistry(model.parts);
|
|
99881
100002
|
const rest2 = /* @__PURE__ */ new Map();
|
|
99882
100003
|
for (const part of [...registry.values(), model.root]) rest2.set(part, { position: part.position.clone(), rotation: part.rotation.clone() });
|
|
99883
|
-
const apply = (object2,
|
|
100004
|
+
const apply = (object2, pose2) => {
|
|
99884
100005
|
const base = rest2.get(object2);
|
|
99885
100006
|
if (!base) return;
|
|
99886
|
-
const [dx, dy, dz] =
|
|
99887
|
-
const [rx, ry, rz] =
|
|
100007
|
+
const [dx, dy, dz] = pose2.position ?? [0, 0, 0];
|
|
100008
|
+
const [rx, ry, rz] = pose2.rotation ?? [0, 0, 0];
|
|
99888
100009
|
object2.position.set(base.position.x + dx, base.position.y + dy, base.position.z + dz);
|
|
99889
100010
|
object2.rotation.set(base.rotation.x + rx, base.rotation.y + ry, base.rotation.z + rz);
|
|
99890
100011
|
};
|
|
99891
100012
|
return {
|
|
99892
|
-
setPartPose(partId,
|
|
100013
|
+
setPartPose(partId, pose2) {
|
|
99893
100014
|
const part = registry.get(partId);
|
|
99894
|
-
if (part) apply(part,
|
|
100015
|
+
if (part) apply(part, pose2);
|
|
99895
100016
|
},
|
|
99896
|
-
setRootPose: (
|
|
100017
|
+
setRootPose: (pose2) => apply(model.root, pose2)
|
|
99897
100018
|
};
|
|
99898
100019
|
}
|
|
99899
100020
|
|
|
@@ -99922,13 +100043,13 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
99922
100043
|
const vector2 = (x, y, z) => new THREE.Vector3(x, y, z);
|
|
99923
100044
|
const positionOf3 = (part) => worldPositionOf(session, part, new THREE.Vector3());
|
|
99924
100045
|
const reach2 = Math.max(0.55, Math.min(1.2, session.lengthMetres));
|
|
99925
|
-
const throwCase = (mark,
|
|
100046
|
+
const throwCase = (mark, velocity2, spin, tilt = 0) => {
|
|
99926
100047
|
if (!session.cartridge || !world.layers.casings) return;
|
|
99927
100048
|
const casing2 = buildCasing(kit, session.cartridge.dims, session.cartridge.shape);
|
|
99928
100049
|
casing2.group.position.copy(positionOf3(mark));
|
|
99929
100050
|
casing2.group.rotation.set(0, random() * 0.6 - 0.3, tilt);
|
|
99930
100051
|
if (session.cartridge.caseType) casing2.group.userData["caseType"] = session.cartridge.caseType;
|
|
99931
|
-
particles.spawn(casing2.group,
|
|
100052
|
+
particles.spawn(casing2.group, velocity2, { kind: "casing", life: 25, radius: casing2.radius, bounce: 0.35, spin, onRest: restFlat, ownsGeometry: true, collider: casingCollider(casing2.radius, casing2.length) });
|
|
99932
100053
|
};
|
|
99933
100054
|
const ejectFromPort = (down2) => {
|
|
99934
100055
|
if (!parts2.eject) return;
|
|
@@ -99937,8 +100058,8 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
99937
100058
|
};
|
|
99938
100059
|
const ejectAll = (marks, spent) => {
|
|
99939
100060
|
marks?.forEach((mark, index) => {
|
|
99940
|
-
const { velocity, spin, tilt } = spent(index);
|
|
99941
|
-
throwCase(mark, toWorld3(session,
|
|
100061
|
+
const { velocity: velocity2, spin, tilt } = spent(index);
|
|
100062
|
+
throwCase(mark, toWorld3(session, velocity2), spin, tilt);
|
|
99942
100063
|
});
|
|
99943
100064
|
};
|
|
99944
100065
|
const moveIn = (from, to, tilt) => {
|
|
@@ -100587,11 +100708,11 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
100587
100708
|
const random = createRng(options.seed ?? 1);
|
|
100588
100709
|
const layers = options.layers ?? createLayers();
|
|
100589
100710
|
const distance4 = () => options.soundDistance?.() ?? 0;
|
|
100590
|
-
const particles = createParticles(THREE, scene, groundAt, options.particleLimit, createSurfaceRaycast(THREE, scene));
|
|
100711
|
+
const particles = createParticles(THREE, scene, groundAt, options.particleLimit, createSurfaceRaycast(THREE, scene), options.physics);
|
|
100591
100712
|
const spawnParticle = particles.spawn.bind(particles);
|
|
100592
|
-
particles.spawn = (object2,
|
|
100713
|
+
particles.spawn = (object2, velocity2, particleOptions) => {
|
|
100593
100714
|
if (lens2) toWorldLens(camera2, object2.position, worldFovOf(), lens2.fov);
|
|
100594
|
-
spawnParticle(object2,
|
|
100715
|
+
spawnParticle(object2, velocity2, particleOptions);
|
|
100595
100716
|
};
|
|
100596
100717
|
particles.onBounce = (kind, hit) => {
|
|
100597
100718
|
if (!audio || kind !== "casing" && kind !== "magazine") return;
|
|
@@ -100616,10 +100737,10 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
100616
100737
|
stop: (handle) => worldSink.stop(handle)
|
|
100617
100738
|
} : void 0;
|
|
100618
100739
|
const effects = createEffects(THREE, lensSink, random);
|
|
100619
|
-
function seenThroughLens(
|
|
100620
|
-
if (!
|
|
100621
|
-
const at4 = toWorldLens(camera2, trackPoint.set(...
|
|
100622
|
-
return { ...
|
|
100740
|
+
function seenThroughLens(pose2) {
|
|
100741
|
+
if (!pose2 || !lens2) return pose2;
|
|
100742
|
+
const at4 = toWorldLens(camera2, trackPoint.set(...pose2.point), worldFovOf(), lens2.fov);
|
|
100743
|
+
return { ...pose2, point: [at4.x, at4.y, at4.z] };
|
|
100623
100744
|
}
|
|
100624
100745
|
const hand = new THREE.Group();
|
|
100625
100746
|
hand.name = VIEWMODEL_NODE_NAME;
|
|
@@ -100845,9 +100966,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
100845
100966
|
eyeTurn.copy(camera2.quaternion).invert();
|
|
100846
100967
|
const rest2 = targetsOf(THREE, held, session.model.root.getWorldQuaternion(rootQuaternion), 0);
|
|
100847
100968
|
let needed = 0;
|
|
100848
|
-
for (const [anchor,
|
|
100849
|
-
if (!anchor || !
|
|
100850
|
-
seen.set(...
|
|
100969
|
+
for (const [anchor, pose2] of [[held.right, rest2.R], [held.left, rest2.L]]) {
|
|
100970
|
+
if (!anchor || !pose2 || anchor.part !== session.model.root) continue;
|
|
100971
|
+
seen.set(...pose2.position).sub(camera2.position).applyQuaternion(eyeTurn);
|
|
100851
100972
|
if (-seen.z > 0.05) needed = Math.max(needed, HAND_IN_VIEW.floor * -seen.z * tanHalf - seen.y);
|
|
100852
100973
|
}
|
|
100853
100974
|
return Math.max(0, Math.min(HAND_IN_VIEW.max, needed));
|
|
@@ -101098,6 +101219,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
101098
101219
|
...options.condition ? { condition: options.condition } : {},
|
|
101099
101220
|
...options.attachmentModels ? { attachmentModels: options.attachmentModels } : {},
|
|
101100
101221
|
...options.raycast ? { raycast: options.raycast } : {},
|
|
101222
|
+
...options.physics ? { physics: options.physics } : {},
|
|
101101
101223
|
...options.contact ? { contact: options.contact } : {},
|
|
101102
101224
|
...options.bodyHold ? { bodyHold: options.bodyHold } : {},
|
|
101103
101225
|
...options.firstPerson ? { firstPerson: options.firstPerson } : {},
|
|
@@ -101266,67 +101388,224 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
101266
101388
|
return { name, parts: [{ id: MODEL_BODY, material: "steel", shape: { kind: "box", size }, position: [0, size[1] / 2, 0], mass: def.mass }], joints: [], tags: ["weapon"] };
|
|
101267
101389
|
}
|
|
101268
101390
|
|
|
101269
|
-
// src/fx/
|
|
101391
|
+
// src/fx/holster-rig.ts
|
|
101270
101392
|
var HOLSTER_PLACEMENT = {
|
|
101271
101393
|
hip: { muzzle: [0, -1, 0], out: [-1, 0, 0] },
|
|
101272
|
-
back: { muzzle: [0.55, 0.835, 0], out: [0, 0, -1] }
|
|
101394
|
+
back: { muzzle: [0.55, 0.835, 0], out: [0, 0, -1] },
|
|
101395
|
+
sling: { muzzle: [0.32, -0.947, 0], out: [0, 0, 1] }
|
|
101396
|
+
};
|
|
101397
|
+
var SLING_HANG = { pivotBehind: 0.3, frontSwivel: 0.3, shoulder: [0.19, 0.2, -0.04], strapRadius: 8e-3, sag: 0.03, color: 4146217 };
|
|
101398
|
+
var gripOfProp = (THREE, weapon2, footprint) => {
|
|
101399
|
+
const model = buildWeaponModelById(THREE, weapon2);
|
|
101400
|
+
const right = model ? holdOfModel(THREE, model, 1).right : null;
|
|
101401
|
+
if (!model || !right) return { position: new THREE.Vector3(-footprint[0] * 0.15, footprint[1] * 0.3, 0), quaternion: new THREE.Quaternion() };
|
|
101402
|
+
const box5 = new THREE.Box3().setFromObject(model.root);
|
|
101403
|
+
const center = box5.getCenter(new THREE.Vector3());
|
|
101404
|
+
const frame2 = new THREE.Group();
|
|
101405
|
+
frame2.add(model.root);
|
|
101406
|
+
model.root.position.set(-center.x, -box5.min.y, -center.z);
|
|
101407
|
+
frame2.updateMatrixWorld(true);
|
|
101408
|
+
return { position: right.part.localToWorld(right.offset.clone()), quaternion: right.quaternion.clone() };
|
|
101273
101409
|
};
|
|
101274
|
-
var
|
|
101275
|
-
const place = HOLSTER_PLACEMENT[slot];
|
|
101276
|
-
const model = place ? buildModeledProp(THREE, { id: weapon2 }, weapon2, void 0, items) : void 0;
|
|
101277
|
-
if (!place || !model) return void 0;
|
|
101410
|
+
var placeModel = (THREE, model, place, middle) => {
|
|
101278
101411
|
const [, height, thickness] = model.userData.footprint ?? [0, 0, 0];
|
|
101279
101412
|
const muzzle2 = new THREE.Vector3(...place.muzzle).normalize();
|
|
101280
101413
|
const out = new THREE.Vector3(...place.out).normalize();
|
|
101281
101414
|
const top = new THREE.Vector3().crossVectors(out, muzzle2).normalize();
|
|
101282
101415
|
model.quaternion.setFromRotationMatrix(new THREE.Matrix4().makeBasis(muzzle2, top, out));
|
|
101283
|
-
model.position.copy(
|
|
101416
|
+
model.position.copy(middle).addScaledVector(top, -height / 2).addScaledVector(out, thickness / 2);
|
|
101417
|
+
};
|
|
101418
|
+
var buildHolsterRig = (THREE, weapon2, slot, options = {}) => {
|
|
101419
|
+
const place = HOLSTER_PLACEMENT[slot];
|
|
101420
|
+
const model = place ? buildModeledProp(THREE, { id: weapon2 }, weapon2, void 0, options.items) : void 0;
|
|
101421
|
+
if (!place || !model) return void 0;
|
|
101422
|
+
const footprint = model.userData.footprint ?? [0, 0, 0];
|
|
101284
101423
|
const holder = new THREE.Group();
|
|
101285
101424
|
holder.name = `holstered_${weapon2}`;
|
|
101286
|
-
|
|
101287
|
-
|
|
101425
|
+
const slung = slot === "sling" && options.strapMaterial !== void 0;
|
|
101426
|
+
const swing = slung ? new THREE.Group() : holder;
|
|
101427
|
+
if (slung) holder.add(swing);
|
|
101428
|
+
const muzzle2 = new THREE.Vector3(...place.muzzle).normalize();
|
|
101429
|
+
const middle = slung ? muzzle2.clone().multiplyScalar(footprint[0] * SLING_HANG.pivotBehind) : new THREE.Vector3();
|
|
101430
|
+
placeModel(THREE, model, place, middle);
|
|
101431
|
+
swing.add(model);
|
|
101432
|
+
const strap = [];
|
|
101433
|
+
if (slung && options.strapMaterial) {
|
|
101434
|
+
const out = new THREE.Vector3(...place.out).normalize();
|
|
101435
|
+
const front = middle.clone().addScaledVector(muzzle2, footprint[0] * SLING_HANG.frontSwivel).addScaledVector(out, footprint[2] / 2);
|
|
101436
|
+
strap.push(createCord(THREE, catenary([0, 0, 0], SLING_HANG.shoulder, SLING_HANG.sag, 8), SLING_HANG.strapRadius, options.strapMaterial));
|
|
101437
|
+
strap.push(createCord(THREE, catenary([front.x, front.y, front.z], [0, 0, 0], SLING_HANG.sag, 8), SLING_HANG.strapRadius, options.strapMaterial));
|
|
101438
|
+
holder.add(strap[0]);
|
|
101439
|
+
swing.add(strap[1]);
|
|
101440
|
+
}
|
|
101441
|
+
holder.updateMatrixWorld(true);
|
|
101442
|
+
const inProp = gripOfProp(THREE, weapon2, footprint);
|
|
101443
|
+
const position = model.localToWorld(inProp.position.clone());
|
|
101444
|
+
const quaternion2 = model.quaternion.clone().multiply(inProp.quaternion);
|
|
101445
|
+
return { holder, swing, grip: { position, quaternion: quaternion2 }, strap };
|
|
101446
|
+
};
|
|
101447
|
+
|
|
101448
|
+
// src/fx/holstered.ts
|
|
101449
|
+
var GROUND_SLOT = "ground";
|
|
101450
|
+
var HOLSTER_TOSS = { drop: 0.8, ahead: 0.3, turn: 1.3, release: 0.4 };
|
|
101451
|
+
var MOVE_GRIP = 0.9;
|
|
101452
|
+
var MAX_SWING_ACCELERATION = 40;
|
|
101453
|
+
var holsteredModel = (THREE, weapon2, slot, items) => buildHolsterRig(THREE, weapon2, slot, items ? { items } : {})?.holder;
|
|
101454
|
+
var ease5 = (t) => {
|
|
101455
|
+
const k = Math.min(1, Math.max(0, t));
|
|
101456
|
+
return k * k * (3 - 2 * k);
|
|
101288
101457
|
};
|
|
101289
101458
|
var createHolsteredWeapons = (options) => {
|
|
101290
101459
|
const { THREE } = options;
|
|
101291
|
-
const
|
|
101460
|
+
const rigs = /* @__PURE__ */ new Map();
|
|
101292
101461
|
const away = /* @__PURE__ */ new Map();
|
|
101293
|
-
const
|
|
101294
|
-
|
|
101295
|
-
|
|
101296
|
-
|
|
101297
|
-
|
|
101298
|
-
|
|
101299
|
-
|
|
101300
|
-
|
|
101462
|
+
const strapMaterial = new THREE.MeshStandardMaterial({ color: SLING_HANG.color, roughness: 0.85, metalness: 0 });
|
|
101463
|
+
const frameOf2 = (pose2) => ({ position: new THREE.Vector3(...pose2.position), quaternion: new THREE.Quaternion(...pose2.quaternion) });
|
|
101464
|
+
const scratch3 = { position: new THREE.Vector3(), quaternion: new THREE.Quaternion(), inverse: new THREE.Quaternion(), acceleration: new THREE.Vector3(), velocity: new THREE.Vector3() };
|
|
101465
|
+
const holderOnHand = (rig, hand) => {
|
|
101466
|
+
const quaternion2 = hand.quaternion.clone().multiply(rig.grip.quaternion.clone().invert());
|
|
101467
|
+
return { position: hand.position.clone().sub(rig.grip.position.clone().applyQuaternion(quaternion2)), quaternion: quaternion2 };
|
|
101468
|
+
};
|
|
101469
|
+
const relativeTo = (frame2, base) => {
|
|
101470
|
+
const inverse = base.quaternion.clone().invert();
|
|
101471
|
+
return { position: frame2.position.clone().sub(base.position).applyQuaternion(inverse), quaternion: inverse.multiply(frame2.quaternion) };
|
|
101472
|
+
};
|
|
101473
|
+
const inFrame = (local2, base) => ({ position: local2.position.clone().applyQuaternion(base.quaternion).add(base.position), quaternion: base.quaternion.clone().multiply(local2.quaternion) });
|
|
101474
|
+
const holdFrame = () => {
|
|
101475
|
+
const pose2 = options.holdFrame?.();
|
|
101476
|
+
return pose2 ? frameOf2(pose2) : null;
|
|
101477
|
+
};
|
|
101478
|
+
const goal = (entry2) => {
|
|
101479
|
+
if (entry2.motion?.kind === "toss") {
|
|
101480
|
+
const start = entry2.motion.start;
|
|
101481
|
+
const ahead = new THREE.Vector3(0, 0, -1).applyQuaternion(holdFrame()?.quaternion ?? start.quaternion).setY(0).normalize();
|
|
101482
|
+
const turn2 = new THREE.Quaternion().setFromAxisAngle(new THREE.Vector3().crossVectors(ahead, new THREE.Vector3(0, 1, 0)).normalize(), HOLSTER_TOSS.turn);
|
|
101483
|
+
return { position: start.position.clone().addScaledVector(ahead, HOLSTER_TOSS.ahead).add(new THREE.Vector3(0, -HOLSTER_TOSS.drop, 0)), quaternion: turn2.multiply(start.quaternion.clone()) };
|
|
101484
|
+
}
|
|
101485
|
+
if (entry2.motion?.kind === "back") {
|
|
101486
|
+
const base = holdFrame();
|
|
101487
|
+
return base && entry2.taken ? inFrame(entry2.taken, base) : null;
|
|
101488
|
+
}
|
|
101489
|
+
const pose2 = options.bodySlot(entry2.slot);
|
|
101490
|
+
if (!pose2) return null;
|
|
101491
|
+
return entry2.swing ? hanging(entry2, frameOf2(pose2)) : frameOf2(pose2);
|
|
101492
|
+
};
|
|
101493
|
+
const hanging = (entry2, frame2) => {
|
|
101494
|
+
const forward = new THREE.Vector3(0, 0, 1).applyQuaternion(frame2.quaternion);
|
|
101495
|
+
const up = new THREE.Vector3(0, 1, 0).applyQuaternion(frame2.quaternion);
|
|
101496
|
+
forward.y = 0;
|
|
101497
|
+
if (forward.lengthSq() < 1e-8) return frame2;
|
|
101498
|
+
forward.normalize();
|
|
101499
|
+
entry2.lean = Math.atan2(up.dot(forward), up.y);
|
|
101500
|
+
return { position: frame2.position, quaternion: new THREE.Quaternion().setFromUnitVectors(new THREE.Vector3(0, 0, 1), forward) };
|
|
101501
|
+
};
|
|
101502
|
+
const place = (entry2, frame2) => {
|
|
101503
|
+
entry2.rig.holder.position.copy(frame2.position);
|
|
101504
|
+
entry2.rig.holder.quaternion.copy(frame2.quaternion);
|
|
101505
|
+
entry2.rig.holder.updateMatrixWorld(true);
|
|
101506
|
+
};
|
|
101507
|
+
const swingOf = (entry2, frame2, dt) => {
|
|
101508
|
+
if (!entry2.swing || dt <= 0) return;
|
|
101509
|
+
const { velocity: velocity2, acceleration, inverse } = scratch3;
|
|
101510
|
+
velocity2.copy(frame2.position).sub(entry2.last ?? frame2.position).divideScalar(dt);
|
|
101511
|
+
acceleration.copy(velocity2).sub(entry2.last ? entry2.speed : velocity2).divideScalar(dt).clampLength(0, MAX_SWING_ACCELERATION);
|
|
101512
|
+
entry2.last = (entry2.last ?? new THREE.Vector3()).copy(frame2.position);
|
|
101513
|
+
entry2.speed.copy(velocity2);
|
|
101514
|
+
acceleration.applyQuaternion(inverse.copy(frame2.quaternion).invert());
|
|
101515
|
+
const state = entry2.swing.step(dt, [-acceleration.x, acceleration.y, acceleration.z]);
|
|
101516
|
+
entry2.rig.swing.rotation.set(-(state.forward + Math.max(0, -entry2.lean)), 0, -state.side);
|
|
101517
|
+
entry2.rig.holder.updateMatrixWorld(true);
|
|
101518
|
+
};
|
|
101519
|
+
const hide = (weapon2) => {
|
|
101520
|
+
const entry2 = away.get(weapon2);
|
|
101521
|
+
if (!entry2) return;
|
|
101522
|
+
entry2.rig.holder.visible = false;
|
|
101523
|
+
away.delete(weapon2);
|
|
101524
|
+
};
|
|
101525
|
+
const step = (entry2, dt) => {
|
|
101526
|
+
const motion = entry2.motion;
|
|
101527
|
+
const target = goal(entry2);
|
|
101528
|
+
entry2.rig.holder.visible = target !== null;
|
|
101529
|
+
const body = entry2.rig.strap[0];
|
|
101530
|
+
if (body) body.visible = motion === null;
|
|
101531
|
+
if (!target) return;
|
|
101532
|
+
if (!motion) {
|
|
101533
|
+
place(entry2, target);
|
|
101534
|
+
swingOf(entry2, target, dt);
|
|
101535
|
+
return;
|
|
101536
|
+
}
|
|
101537
|
+
motion.time = Math.min(motion.seconds, motion.time + dt);
|
|
101538
|
+
const k = ease5(motion.time / motion.seconds);
|
|
101539
|
+
place(entry2, { position: motion.start.position.clone().lerp(target.position, k), quaternion: motion.start.quaternion.clone().slerp(target.quaternion, k) });
|
|
101540
|
+
if (motion.time < motion.seconds) return;
|
|
101541
|
+
if (motion.kind === "away") {
|
|
101542
|
+
entry2.motion = null;
|
|
101543
|
+
if (body) body.visible = true;
|
|
101544
|
+
}
|
|
101545
|
+
if (motion.kind === "toss") hide(entry2.weapon);
|
|
101546
|
+
};
|
|
101547
|
+
const rigOf = (weapon2, slot) => {
|
|
101548
|
+
const key2 = `${weapon2}@${slot}`;
|
|
101549
|
+
const known = rigs.get(key2);
|
|
101550
|
+
if (known) return known;
|
|
101551
|
+
const rig = buildHolsterRig(THREE, weapon2, slot === GROUND_SLOT ? "hip" : slot, { ...options.items ? { items: options.items } : {}, strapMaterial });
|
|
101552
|
+
if (!rig) return void 0;
|
|
101553
|
+
options.scene.add(rig.holder);
|
|
101554
|
+
rig.holder.visible = false;
|
|
101555
|
+
rigs.set(key2, rig);
|
|
101556
|
+
return rig;
|
|
101557
|
+
};
|
|
101558
|
+
const putAway = (event, seconds) => {
|
|
101559
|
+
if (!options.arsenal.weapons.has(event.weapon)) return;
|
|
101560
|
+
hide(event.weapon);
|
|
101561
|
+
const rig = rigOf(event.weapon, event.slot);
|
|
101562
|
+
if (!rig) return;
|
|
101563
|
+
rig.swing.rotation.set(0, 0, 0);
|
|
101564
|
+
const entry2 = { weapon: event.weapon, slot: event.slot, rig, motion: null, taken: null, swing: event.slot === "sling" ? createSlingSwing() : null, last: null, speed: new THREE.Vector3(), lean: 0 };
|
|
101565
|
+
if (event.from && seconds > 0) {
|
|
101566
|
+
const start = holderOnHand(rig, frameOf2(event.from));
|
|
101567
|
+
const base = holdFrame();
|
|
101568
|
+
entry2.taken = base ? relativeTo(start, base) : null;
|
|
101569
|
+
entry2.motion = { kind: event.slot === GROUND_SLOT ? "toss" : "away", time: 0, seconds, start };
|
|
101570
|
+
} else if (event.slot === GROUND_SLOT) return;
|
|
101571
|
+
away.set(event.weapon, entry2);
|
|
101572
|
+
step(entry2, 0);
|
|
101301
101573
|
};
|
|
101302
101574
|
return {
|
|
101303
101575
|
handle(event) {
|
|
101304
|
-
const
|
|
101305
|
-
if (
|
|
101306
|
-
|
|
101307
|
-
|
|
101308
|
-
|
|
101309
|
-
|
|
101310
|
-
|
|
101311
|
-
if (!options.arsenal.weapons.has(event.weapon)) return;
|
|
101312
|
-
if (!models.has(key2)) {
|
|
101313
|
-
const holder = holsteredModel(THREE, event.weapon, event.slot, options.items);
|
|
101314
|
-
if (!holder) return;
|
|
101315
|
-
options.scene.add(holder);
|
|
101316
|
-
models.set(key2, holder);
|
|
101317
|
-
}
|
|
101318
|
-
away.set(event.weapon, event.slot);
|
|
101319
|
-
place(event.weapon, event.slot);
|
|
101576
|
+
const seconds = event.seconds ?? 0;
|
|
101577
|
+
if (event.on) return putAway(event, seconds);
|
|
101578
|
+
const entry2 = away.get(event.weapon);
|
|
101579
|
+
if (!entry2 || seconds <= 0 || !entry2.taken || !holdFrame()) return hide(event.weapon);
|
|
101580
|
+
entry2.motion = { kind: "back", time: 0, seconds, start: { position: entry2.rig.holder.position.clone(), quaternion: entry2.rig.holder.quaternion.clone() } };
|
|
101581
|
+
entry2.swing?.reset();
|
|
101582
|
+
entry2.rig.swing.rotation.set(0, 0, 0);
|
|
101320
101583
|
},
|
|
101321
|
-
|
|
101322
|
-
|
|
101584
|
+
inHand(weapon2) {
|
|
101585
|
+
if (away.get(weapon2)?.motion?.kind !== "toss") hide(weapon2);
|
|
101586
|
+
},
|
|
101587
|
+
update(dt = 0) {
|
|
101588
|
+
for (const entry2 of [...away.values()]) step(entry2, dt);
|
|
101589
|
+
},
|
|
101590
|
+
handTargets() {
|
|
101591
|
+
for (const entry2 of away.values()) {
|
|
101592
|
+
const motion = entry2.motion;
|
|
101593
|
+
if (!motion || !entry2.rig.holder.visible) continue;
|
|
101594
|
+
if (motion.kind === "toss" && motion.time / motion.seconds > HOLSTER_TOSS.release) continue;
|
|
101595
|
+
const { position, quaternion: quaternion2 } = scratch3;
|
|
101596
|
+
position.copy(entry2.rig.grip.position).applyMatrix4(entry2.rig.holder.matrixWorld);
|
|
101597
|
+
quaternion2.copy(entry2.rig.holder.quaternion).multiply(entry2.rig.grip.quaternion);
|
|
101598
|
+
return { R: { position: [position.x, position.y, position.z], quaternion: [quaternion2.x, quaternion2.y, quaternion2.z, quaternion2.w] }, grip: MOVE_GRIP };
|
|
101599
|
+
}
|
|
101600
|
+
return null;
|
|
101323
101601
|
},
|
|
101324
101602
|
get drawn() {
|
|
101325
|
-
return [...away.
|
|
101603
|
+
return [...away.values()].filter((entry2) => entry2.motion?.kind !== "toss").map((entry2) => entry2.weapon);
|
|
101326
101604
|
},
|
|
101327
101605
|
dispose() {
|
|
101328
|
-
discardObject3D([...
|
|
101329
|
-
|
|
101606
|
+
discardObject3D([...rigs.values()].map((rig) => rig.holder));
|
|
101607
|
+
strapMaterial.dispose();
|
|
101608
|
+
rigs.clear();
|
|
101330
101609
|
away.clear();
|
|
101331
101610
|
}
|
|
101332
101611
|
};
|
|
@@ -102792,7 +103071,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
102792
103071
|
});
|
|
102793
103072
|
const worldEffects = createWorldEffects({ arsenal });
|
|
102794
103073
|
const bodySlot = lent.bodySlot?.bind(lent);
|
|
102795
|
-
const holstered = bodySlot ? createHolsteredWeapons({ THREE: lent.THREE, scene: lent.scene, arsenal, ...options.items ? { items: options.items } : {}, bodySlot }) : null;
|
|
103074
|
+
const holstered = bodySlot ? createHolsteredWeapons({ THREE: lent.THREE, scene: lent.scene, arsenal, ...options.items ? { items: options.items } : {}, bodySlot, holdFrame: () => lent.holdFrame?.("R") ?? null }) : null;
|
|
102796
103075
|
const offEvents = lent.on((event) => {
|
|
102797
103076
|
worldEffects.handle(event, lent.effects);
|
|
102798
103077
|
if (event.type === "holster") {
|
|
@@ -102806,6 +103085,7 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
102806
103085
|
return;
|
|
102807
103086
|
}
|
|
102808
103087
|
const tool2 = lent.tool();
|
|
103088
|
+
if (event.type === "tool") holstered?.inHand(event.weapon);
|
|
102809
103089
|
created.handle(event, tool2);
|
|
102810
103090
|
if (event.type === "reload" && event.phase === "start") {
|
|
102811
103091
|
const clip = created.clips.find((entry2) => entry2.name.startsWith("reload"));
|
|
@@ -102818,9 +103098,9 @@ vec3 c=mix(uDeep,uFoam,dome>.5?.8:.65+.35*vY);float alpha=body*vA;if(alpha<.004)
|
|
|
102818
103098
|
});
|
|
102819
103099
|
const offFrame = lent.onFrame((dt) => {
|
|
102820
103100
|
created.update(dt);
|
|
102821
|
-
holstered?.update();
|
|
103101
|
+
holstered?.update(dt);
|
|
102822
103102
|
});
|
|
102823
|
-
const offHands = lent.setHandTargets?.(() => created.handTargets());
|
|
103103
|
+
const offHands = lent.setHandTargets?.(() => holstered?.handTargets() ?? created.handTargets());
|
|
102824
103104
|
const offMuzzle = lent.setMuzzleSource?.((hand) => created.muzzle(hand));
|
|
102825
103105
|
created.handle({ type: "tool", weapon: lent.tool().weapon }, lent.tool());
|
|
102826
103106
|
return () => {
|