@adatechnology/game-weapons-three 0.23.0 → 0.24.1
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 +2 -0
- package/dist/{chunk-7BPQ2GZM.js → chunk-UUBO6H5O.js} +89 -7
- package/dist/chunk-UUBO6H5O.js.map +1 -0
- package/dist/index.d.ts +40 -2
- package/dist/index.global.js +745 -220
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/testing.js +1 -1
- package/package.json +10 -9
- package/dist/chunk-7BPQ2GZM.js.map +0 -1
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ The muzzle flash, the smoke, the backblast of a launched rocket and the flame je
|
|
|
7
7
|
**Hands.** The weapon in the hands tells the host where the hands go (`host.setHandTargets`, `HandTargets` of `game-contracts`): the right on the pistol grip (the `grip` pivot of the model, else under the receiver), the left on the handguard, on the pump of a pump gun (it moves with the pump), under the right on a handgun, and to the magazine while it is changed; the generic props take the right hand on the `handle` and the left under the `head` of a long gun. Sizes come from the model.
|
|
8
8
|
|
|
9
9
|
**On the body.** The weapon is the body's own, at its real size, in first and third person alike (spec 004: no first-person scale-down, no offset in front of the camera). `ModuleHost.holdFrame` lends the pocket of the right shoulder turned to the aim; a host with no body gets the same pocket under the camera's eye (`BODY_HOLD.eyeToPocket`). A shouldered long gun rests its stock in it (a gun with no stock slides forward so its grip is never behind the eye), a handgun or a short two-hand gun goes to mid-chest, a one-hand tool low. The grips of the hands are kept above the bottom of the view (`HAND_IN_VIEW`, up to 0.3 m of lift) and the weapon comes back from a wall (`WALL_PULL`, `contact`, up to 1.2 m); the hands follow it through `avatar.reach`, which also pulls them back from surfaces. The generic props (`box-fx`) ride the body the same way.
|
|
10
|
+
|
|
11
|
+
**Put away on the body.** A weapon the hands put away to carry or push something (`HostEvent` `holster`) is drawn at the place of the body that took it, read every frame from `ModuleHost.bodySlot`: a pistol muzzle down on the hip holster, a long gun across the back with the muzzle over the off shoulder (`HOLSTER_PLACEMENT`); drawn back in hand it is hidden. `createHolsteredWeapons` does it in the weapons area; `holsteredModel(THREE, weapon, slot)` builds one. The test `holstered.test.ts` puts them on the player's body and finds no face on a plane of the body's.
|
|
10
12
|
**Safety (destravar).** Turning the safety on or off (the `safety` event, B in the test room) plays `safety_on` / `safety_off` on every model: the weapon cants to the right and rises a little toward the eye, the shooting hand slides up its grip so the thumb reaches the lever (`thumb_safety` in `src/data/hand-work.json`; an AK-style rifle's support hand goes over to the big lever on the right, `lever_right`), the lever flicks (when the model draws one, the `safety` part) and the weapon settles. The seconds and radians are `SAFETY_MOTION` of `src/animation/shot-clips.ts`.
|
|
11
13
|
|
|
12
14
|
**Weapons the gallery did not model.** The melee weapons and tools with no gallery model (the bat, the axe, the machete, the knife, the hammer, the crowbar, the crossbow, the wrench, the extinguisher, the blowtorch...) are drawn with the team's item model of `@adatechnology/game-items-three` (Itens do Vale Cinzento), on the counters and in the hands: `buildItemWeaponModel` lays it along +x, flat, the head at +x, with an empty `handle` where the hand closes. The item is the one with the weapon's id, or the one `registerWeaponItemModel(weaponId, { item, turn, flip })` names (`wrench` → `adjustable_wrench`); `registerWeaponItemModel(id, null)` keeps the low-poly prop. The host lends the item models as `items` (`createWeaponFx`, `createWeaponsTestModule`, `createExplosivesTestModule`, `buildWeaponModel`, `worldExplosiveItem`): pass `itemModels` of `@adatechnology/game-items-three` (the recommended path; the kit's preset does). Without `items` the weapons still draw with `itemModels` of `game-items-three` as before; that default is deprecated and removed in the next major. Only a weapon with neither model falls back to the low-poly boxes of its category (`weaponProp`), and the kit's scene check (`tools/kit-audit/scene.mjs`) lists those as pending.
|
|
@@ -12884,7 +12884,7 @@ var createHandFx = (options, layers, hand, oneHand) => {
|
|
|
12884
12884
|
};
|
|
12885
12885
|
var handleHand = (pair, event, tool) => {
|
|
12886
12886
|
const { box: box2, model } = pair;
|
|
12887
|
-
if (event.type === "explosion" || event.type === "player" || event.type === "footfall") return;
|
|
12887
|
+
if (event.type === "explosion" || event.type === "player" || event.type === "footfall" || event.type === "holster") return;
|
|
12888
12888
|
if (event.type === "tool") {
|
|
12889
12889
|
if (hasWeaponModel(event.weapon)) box2.unequip();
|
|
12890
12890
|
else model.unequip();
|
|
@@ -12914,7 +12914,7 @@ function createWeaponFx(options) {
|
|
|
12914
12914
|
};
|
|
12915
12915
|
return {
|
|
12916
12916
|
handle(event, tool) {
|
|
12917
|
-
if (event.type === "explosion" || event.type === "player" || event.type === "footfall") return;
|
|
12917
|
+
if (event.type === "explosion" || event.type === "player" || event.type === "footfall" || event.type === "holster") return;
|
|
12918
12918
|
if (event.hand !== "L") {
|
|
12919
12919
|
handleHand(right, event, tool);
|
|
12920
12920
|
return;
|
|
@@ -12988,6 +12988,9 @@ function createWeaponFx(options) {
|
|
|
12988
12988
|
};
|
|
12989
12989
|
}
|
|
12990
12990
|
|
|
12991
|
+
// src/fx/holstered.ts
|
|
12992
|
+
import { discardObject3D as discardObject3D5 } from "@adatechnology/game-shapes-three";
|
|
12993
|
+
|
|
12991
12994
|
// src/modeled-prop.ts
|
|
12992
12995
|
import { markKitOrigin as markKitOrigin5 } from "@adatechnology/game-contracts";
|
|
12993
12996
|
import { itemMakeup, makeupSpec, tagMakeupParts } from "@adatechnology/game-items-three";
|
|
@@ -13039,6 +13042,72 @@ function modeledPropSpec(root, def, name) {
|
|
|
13039
13042
|
return { name, parts: [{ id: MODEL_BODY, material: "steel", shape: { kind: "box", size }, position: [0, size[1] / 2, 0], mass: def.mass }], joints: [], tags: ["weapon"] };
|
|
13040
13043
|
}
|
|
13041
13044
|
|
|
13045
|
+
// src/fx/holstered.ts
|
|
13046
|
+
var HOLSTER_PLACEMENT = {
|
|
13047
|
+
hip: { muzzle: [0, -1, 0], out: [-1, 0, 0] },
|
|
13048
|
+
back: { muzzle: [0.55, 0.835, 0], out: [0, 0, -1] }
|
|
13049
|
+
};
|
|
13050
|
+
var holsteredModel = (THREE, weapon, slot, items) => {
|
|
13051
|
+
const place = HOLSTER_PLACEMENT[slot];
|
|
13052
|
+
const model = place ? buildModeledProp(THREE, { id: weapon }, weapon, void 0, items) : void 0;
|
|
13053
|
+
if (!place || !model) return void 0;
|
|
13054
|
+
const [, height, thickness] = model.userData.footprint ?? [0, 0, 0];
|
|
13055
|
+
const muzzle = new THREE.Vector3(...place.muzzle).normalize();
|
|
13056
|
+
const out = new THREE.Vector3(...place.out).normalize();
|
|
13057
|
+
const top = new THREE.Vector3().crossVectors(out, muzzle).normalize();
|
|
13058
|
+
model.quaternion.setFromRotationMatrix(new THREE.Matrix4().makeBasis(muzzle, top, out));
|
|
13059
|
+
model.position.copy(top.multiplyScalar(-height / 2)).addScaledVector(out, thickness / 2);
|
|
13060
|
+
const holder = new THREE.Group();
|
|
13061
|
+
holder.name = `holstered_${weapon}`;
|
|
13062
|
+
holder.add(model);
|
|
13063
|
+
return holder;
|
|
13064
|
+
};
|
|
13065
|
+
var createHolsteredWeapons = (options) => {
|
|
13066
|
+
const { THREE } = options;
|
|
13067
|
+
const models = /* @__PURE__ */ new Map();
|
|
13068
|
+
const away = /* @__PURE__ */ new Map();
|
|
13069
|
+
const place = (weapon, slot) => {
|
|
13070
|
+
const holder = models.get(`${weapon}@${slot}`);
|
|
13071
|
+
const pose = options.bodySlot(slot);
|
|
13072
|
+
if (!holder) return;
|
|
13073
|
+
holder.visible = pose !== null;
|
|
13074
|
+
if (!pose) return;
|
|
13075
|
+
holder.position.set(pose.position[0], pose.position[1], pose.position[2]);
|
|
13076
|
+
holder.quaternion.set(pose.quaternion[0], pose.quaternion[1], pose.quaternion[2], pose.quaternion[3]);
|
|
13077
|
+
};
|
|
13078
|
+
return {
|
|
13079
|
+
handle(event) {
|
|
13080
|
+
const key = `${event.weapon}@${event.slot}`;
|
|
13081
|
+
if (!event.on) {
|
|
13082
|
+
away.delete(event.weapon);
|
|
13083
|
+
const holder = models.get(key);
|
|
13084
|
+
if (holder) holder.visible = false;
|
|
13085
|
+
return;
|
|
13086
|
+
}
|
|
13087
|
+
if (!options.arsenal.weapons.has(event.weapon)) return;
|
|
13088
|
+
if (!models.has(key)) {
|
|
13089
|
+
const holder = holsteredModel(THREE, event.weapon, event.slot, options.items);
|
|
13090
|
+
if (!holder) return;
|
|
13091
|
+
options.scene.add(holder);
|
|
13092
|
+
models.set(key, holder);
|
|
13093
|
+
}
|
|
13094
|
+
away.set(event.weapon, event.slot);
|
|
13095
|
+
place(event.weapon, event.slot);
|
|
13096
|
+
},
|
|
13097
|
+
update() {
|
|
13098
|
+
for (const [weapon, slot] of away) place(weapon, slot);
|
|
13099
|
+
},
|
|
13100
|
+
get drawn() {
|
|
13101
|
+
return [...away.keys()];
|
|
13102
|
+
},
|
|
13103
|
+
dispose() {
|
|
13104
|
+
discardObject3D5([...models.values()]);
|
|
13105
|
+
models.clear();
|
|
13106
|
+
away.clear();
|
|
13107
|
+
}
|
|
13108
|
+
};
|
|
13109
|
+
};
|
|
13110
|
+
|
|
13042
13111
|
// assets/weapon-svg/manifest.json
|
|
13043
13112
|
var manifest_default = {
|
|
13044
13113
|
version: 1,
|
|
@@ -14499,8 +14568,14 @@ function createWeaponsTestModule(options = {}) {
|
|
|
14499
14568
|
else if (change.kind === "control" && change.id === "fuse_length" && typeof change.value === "number") lent.configureTool?.({ fuse_length: String(change.value) });
|
|
14500
14569
|
});
|
|
14501
14570
|
const worldEffects = createWorldEffects({ arsenal });
|
|
14571
|
+
const bodySlot = lent.bodySlot?.bind(lent);
|
|
14572
|
+
const holstered = bodySlot ? createHolsteredWeapons({ THREE: lent.THREE, scene: lent.scene, arsenal, ...options.items ? { items: options.items } : {}, bodySlot }) : null;
|
|
14502
14573
|
const offEvents = lent.on((event) => {
|
|
14503
14574
|
worldEffects.handle(event, lent.effects);
|
|
14575
|
+
if (event.type === "holster") {
|
|
14576
|
+
holstered?.handle(event);
|
|
14577
|
+
return;
|
|
14578
|
+
}
|
|
14504
14579
|
if (event.type === "explosion") {
|
|
14505
14580
|
if (lentEngine) return;
|
|
14506
14581
|
const away = Math.hypot(event.point[0] - camera.position.x, event.point[1] - camera.position.y, event.point[2] - camera.position.z);
|
|
@@ -14518,7 +14593,10 @@ function createWeaponsTestModule(options = {}) {
|
|
|
14518
14593
|
}
|
|
14519
14594
|
if (event.type === "reload") lent.log(fill2(event.phase === "start" ? text.reloadStart : text.reloadEnd, { weapon: arsenal.name(event.weapon), ammo: tool.ammo, capacity: tool.capacity }), { weapon: event.weapon, phase: event.phase });
|
|
14520
14595
|
});
|
|
14521
|
-
const offFrame = lent.onFrame((dt) =>
|
|
14596
|
+
const offFrame = lent.onFrame((dt) => {
|
|
14597
|
+
created.update(dt);
|
|
14598
|
+
holstered?.update();
|
|
14599
|
+
});
|
|
14522
14600
|
const offHands = lent.setHandTargets?.(() => created.handTargets());
|
|
14523
14601
|
const offMuzzle = lent.setMuzzleSource?.((hand) => created.muzzle(hand));
|
|
14524
14602
|
created.handle({ type: "tool", weapon: lent.tool().weapon }, lent.tool());
|
|
@@ -14532,6 +14610,7 @@ function createWeaponsTestModule(options = {}) {
|
|
|
14532
14610
|
offHands?.();
|
|
14533
14611
|
offMuzzle?.();
|
|
14534
14612
|
created.dispose();
|
|
14613
|
+
holstered?.dispose();
|
|
14535
14614
|
audio?.dispose();
|
|
14536
14615
|
fx = null;
|
|
14537
14616
|
host = null;
|
|
@@ -14545,7 +14624,7 @@ import { EXPLOSIONS } from "@adatechnology/game-vfx";
|
|
|
14545
14624
|
import { createArsenal as createArsenal2 } from "@adatechnology/game-weapons";
|
|
14546
14625
|
|
|
14547
14626
|
// src/test-area/explosives-bench.ts
|
|
14548
|
-
import { discardObject3D as
|
|
14627
|
+
import { discardObject3D as discardObject3D6 } from "@adatechnology/game-shapes-three";
|
|
14549
14628
|
import { markKitOrigin as markKitOrigin7 } from "@adatechnology/game-contracts";
|
|
14550
14629
|
|
|
14551
14630
|
// src/test-area/explosives-text.ts
|
|
@@ -14825,7 +14904,7 @@ function createExplosivesBench(options) {
|
|
|
14825
14904
|
vessel.rings = group;
|
|
14826
14905
|
};
|
|
14827
14906
|
const clearRings = (vessel) => {
|
|
14828
|
-
if (vessel.rings)
|
|
14907
|
+
if (vessel.rings) discardObject3D6(vessel.rings);
|
|
14829
14908
|
vessel.rings = void 0;
|
|
14830
14909
|
};
|
|
14831
14910
|
const phaseOf = (vessel) => {
|
|
@@ -14914,7 +14993,7 @@ function createExplosivesBench(options) {
|
|
|
14914
14993
|
}
|
|
14915
14994
|
};
|
|
14916
14995
|
const clearShells = () => {
|
|
14917
|
-
|
|
14996
|
+
discardObject3D6(shells.map((shell) => shell.mesh));
|
|
14918
14997
|
shells.length = 0;
|
|
14919
14998
|
};
|
|
14920
14999
|
const fullVitality = /* @__PURE__ */ new Map();
|
|
@@ -15667,6 +15746,9 @@ export {
|
|
|
15667
15746
|
buildModeledProp,
|
|
15668
15747
|
buildTripodMountedProp,
|
|
15669
15748
|
modeledPropSpec,
|
|
15749
|
+
HOLSTER_PLACEMENT,
|
|
15750
|
+
holsteredModel,
|
|
15751
|
+
createHolsteredWeapons,
|
|
15670
15752
|
WEAPON_THUMBNAILS,
|
|
15671
15753
|
weaponThumbnailCredit,
|
|
15672
15754
|
DEFAULT_THUMBNAIL_BASE,
|
|
@@ -15691,4 +15773,4 @@ export {
|
|
|
15691
15773
|
DEFAULT_EXPLOSIVES_SCENE,
|
|
15692
15774
|
createExplosivesTestModule
|
|
15693
15775
|
};
|
|
15694
|
-
//# sourceMappingURL=chunk-
|
|
15776
|
+
//# sourceMappingURL=chunk-UUBO6H5O.js.map
|