@adatechnology/game-weapons-three 0.16.0 → 0.17.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/dist/{chunk-KWJQO6JS.js → chunk-BDYIF7JD.js} +218 -53
- package/dist/chunk-BDYIF7JD.js.map +1 -0
- package/dist/index.d.ts +45 -3
- package/dist/index.global.js +322 -92
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/{testing-CEcZ-zzz.d.ts → testing-BKDGK6cq.d.ts} +15 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +9 -9
- package/dist/chunk-KWJQO6JS.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -23,6 +23,8 @@ import {
|
|
|
23
23
|
RELOAD_SAMPLE,
|
|
24
24
|
RELOAD_SAMPLE_HITS,
|
|
25
25
|
SHIPPED_WEAPON_ITEM_MODELS,
|
|
26
|
+
VIEW_HOLD,
|
|
27
|
+
VIEW_MOTION,
|
|
26
28
|
WEAPON_ITEM_PREFIX,
|
|
27
29
|
WEAPON_THUMBNAILS,
|
|
28
30
|
WEIGHT_INTENSITY,
|
|
@@ -69,6 +71,7 @@ import {
|
|
|
69
71
|
registerWeaponItemModel,
|
|
70
72
|
rigStock,
|
|
71
73
|
rigUnderbarrel,
|
|
74
|
+
toWorldLens,
|
|
72
75
|
weaponProp,
|
|
73
76
|
weaponPropsOver,
|
|
74
77
|
weaponSampleBank,
|
|
@@ -79,7 +82,7 @@ import {
|
|
|
79
82
|
worldExplosiveItem,
|
|
80
83
|
worldExplosiveShell,
|
|
81
84
|
worldExplosiveValve
|
|
82
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-BDYIF7JD.js";
|
|
83
86
|
|
|
84
87
|
// src/projectile-model.ts
|
|
85
88
|
import { markKitOrigin } from "@adatechnology/game-contracts";
|
|
@@ -136,6 +139,8 @@ export {
|
|
|
136
139
|
P13_VALVE_MESH,
|
|
137
140
|
RELOAD_SAMPLE,
|
|
138
141
|
RELOAD_SAMPLE_HITS,
|
|
142
|
+
VIEW_HOLD,
|
|
143
|
+
VIEW_MOTION,
|
|
139
144
|
WEAPON_ITEM_PREFIX,
|
|
140
145
|
WEAPON_THUMBNAILS,
|
|
141
146
|
WEIGHT_INTENSITY,
|
|
@@ -183,6 +188,7 @@ export {
|
|
|
183
188
|
registerWeaponItemModel,
|
|
184
189
|
rigStock,
|
|
185
190
|
rigUnderbarrel,
|
|
191
|
+
toWorldLens,
|
|
186
192
|
weaponProp,
|
|
187
193
|
weaponSampleBank,
|
|
188
194
|
weaponSampleDefaults,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/projectile-model.ts","../src/weapon-props.ts"],"sourcesContent":["import { markKitOrigin } from '@adatechnology/game-contracts'\nimport type * as THREE_NS from 'three'\n\nimport { buildWeaponModelById } from './models'\nimport { buildExplosiveModel } from './models/explosives'\nimport { modelKit } from './models/kit'\nimport { buildFlyingRocket } from './models/launcher-rounds'\n\n/** What a host asks for a thrown or set down explosive: the weapon in the hand, the explosive it carries and how it is used (`rocket`, `grenade`, `molotov`, `charge`). */\nexport interface ProjectileQuery {\n readonly weapon: string\n readonly explosive?: string | undefined\n readonly kind: string\n}\n\n/** The model of a projectile and the axis along its length. */\nexport interface ProjectileModel {\n readonly model: THREE_NS.Object3D\n readonly axis: [number, number, number]\n}\n\n/**\n * The model of what a weapon throws or fires, drawn by the same code as the weapon itself: the round of a rocket launcher (the RPG-7's PG-7V, the Carl Gustaf's 84 mm round, the rocket of\n * the disposable tubes), long axis +x, and the explosives of the gallery (the M67, the molotov, the pipe bomb, the dynamite, the C4, the Claymore, the flashbang), centred, axis +y.\n * Answers `null` where the gallery has no model (the 40 mm grenade of a launcher), and a host keeps its primitive for it.\n */\nexport function projectileModel(THREE: typeof THREE_NS, query: ProjectileQuery): ProjectileModel | null {\n if (query.kind !== 'rocket') return explosiveProjectile(THREE, query)\n const launcher = buildWeaponModelById(THREE, query.weapon)\n if (!launcher || launcher.parts.family !== 'rocket') return null\n const round = launcher.parts.makeRound ? launcher.parts.makeRound() : buildFlyingRocket(modelKit(THREE), launcher.parts.launcherType)\n return { model: round, axis: [1, 0, 0] }\n}\n\n// a thrown or set down explosive the gallery drew: its model centred on its middle (it tumbles about it in flight), standing axis +y\nfunction explosiveProjectile(THREE: typeof THREE_NS, query: ProjectileQuery): ProjectileModel | null {\n const model = query.explosive === undefined ? undefined : buildExplosiveModel(THREE, query.explosive)\n if (!model) return null\n const centre = new THREE.Box3().setFromObject(model).getCenter(new THREE.Vector3())\n const holder = markKitOrigin(new THREE.Group(), { owner: 'game-weapons-three', kind: 'explosive', id: model.name })\n holder.name = model.name\n model.position.sub(centre)\n holder.add(model)\n return { model: holder, axis: [0, 1, 0] }\n}\n","import { applyPatches, mergeById, removeIds } from '@adatechnology/game-contracts'\nimport type { DeepPartial } from '@adatechnology/game-contracts'\n\nimport { SHIPPED_WEAPON_ITEM_MODELS, weaponPropsOver } from './weapon-item-model'\nimport type { WeaponItemModel, WeaponProps } from './weapon-item-model'\n\nexport interface WeaponPropsOptions {\n /** Item model overrides by weapon id, added to the shipped ones (`null` keeps the low-poly prop); later packs replace earlier ones. */\n readonly packs?: readonly Readonly<Record<string, WeaponItemModel | null>>[]\n /** Changes to an override by weapon id, merged field by field. */\n readonly patch?: Readonly<Record<string, DeepPartial<WeaponItemModel>>>\n /** Weapon ids whose override is taken out (the weapon id itself is then the item model id). */\n readonly remove?: readonly string[]\n}\n\ntype Entry = { readonly id: string; readonly model: WeaponItemModel }\n\n/** A set of weapon prop overrides of its own: the shipped ones plus `packs`, `patch` and `remove`. Nothing is shared with any other set on the page. */\nexport function createWeaponProps(options: WeaponPropsOptions = {}): WeaponProps {\n const entryOf = ([id, model]: readonly [string, WeaponItemModel | null]): Entry => ({ id, model: model ?? { item: '' } })\n const entries = mergeById<Entry>(SHIPPED_WEAPON_ITEM_MODELS.map(entryOf), (options.packs ?? []).flatMap((pack) => Object.entries(pack).map(entryOf)))\n const patches: Record<string, { model: DeepPartial<WeaponItemModel> }> = {}\n for (const [id, model] of Object.entries(options.patch ?? {})) patches[id] = { model }\n applyPatches(entries, patches)\n removeIds(entries, options.remove)\n return weaponPropsOver(new Map([...entries].map(([id, entry]) => [id, entry.model])))\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/projectile-model.ts","../src/weapon-props.ts"],"sourcesContent":["import { markKitOrigin } from '@adatechnology/game-contracts'\nimport type * as THREE_NS from 'three'\n\nimport { buildWeaponModelById } from './models'\nimport { buildExplosiveModel } from './models/explosives'\nimport { modelKit } from './models/kit'\nimport { buildFlyingRocket } from './models/launcher-rounds'\n\n/** What a host asks for a thrown or set down explosive: the weapon in the hand, the explosive it carries and how it is used (`rocket`, `grenade`, `molotov`, `charge`). */\nexport interface ProjectileQuery {\n readonly weapon: string\n readonly explosive?: string | undefined\n readonly kind: string\n}\n\n/** The model of a projectile and the axis along its length. */\nexport interface ProjectileModel {\n readonly model: THREE_NS.Object3D\n readonly axis: [number, number, number]\n}\n\n/**\n * The model of what a weapon throws or fires, drawn by the same code as the weapon itself: the round of a rocket launcher (the RPG-7's PG-7V, the Carl Gustaf's 84 mm round, the rocket of\n * the disposable tubes), long axis +x, and the explosives of the gallery (the M67, the molotov, the pipe bomb, the dynamite, the C4, the Claymore, the flashbang), centred, axis +y.\n * Answers `null` where the gallery has no model (the 40 mm grenade of a launcher), and a host keeps its primitive for it.\n */\nexport function projectileModel(THREE: typeof THREE_NS, query: ProjectileQuery): ProjectileModel | null {\n if (query.kind !== 'rocket') return explosiveProjectile(THREE, query)\n const launcher = buildWeaponModelById(THREE, query.weapon)\n if (!launcher || launcher.parts.family !== 'rocket') return null\n const round = launcher.parts.makeRound ? launcher.parts.makeRound() : buildFlyingRocket(modelKit(THREE), launcher.parts.launcherType)\n return { model: round, axis: [1, 0, 0] }\n}\n\n// a thrown or set down explosive the gallery drew: its model centred on its middle (it tumbles about it in flight), standing axis +y\nfunction explosiveProjectile(THREE: typeof THREE_NS, query: ProjectileQuery): ProjectileModel | null {\n const model = query.explosive === undefined ? undefined : buildExplosiveModel(THREE, query.explosive)\n if (!model) return null\n const centre = new THREE.Box3().setFromObject(model).getCenter(new THREE.Vector3())\n const holder = markKitOrigin(new THREE.Group(), { owner: 'game-weapons-three', kind: 'explosive', id: model.name })\n holder.name = model.name\n model.position.sub(centre)\n holder.add(model)\n return { model: holder, axis: [0, 1, 0] }\n}\n","import { applyPatches, mergeById, removeIds } from '@adatechnology/game-contracts'\nimport type { DeepPartial } from '@adatechnology/game-contracts'\n\nimport { SHIPPED_WEAPON_ITEM_MODELS, weaponPropsOver } from './weapon-item-model'\nimport type { WeaponItemModel, WeaponProps } from './weapon-item-model'\n\nexport interface WeaponPropsOptions {\n /** Item model overrides by weapon id, added to the shipped ones (`null` keeps the low-poly prop); later packs replace earlier ones. */\n readonly packs?: readonly Readonly<Record<string, WeaponItemModel | null>>[]\n /** Changes to an override by weapon id, merged field by field. */\n readonly patch?: Readonly<Record<string, DeepPartial<WeaponItemModel>>>\n /** Weapon ids whose override is taken out (the weapon id itself is then the item model id). */\n readonly remove?: readonly string[]\n}\n\ntype Entry = { readonly id: string; readonly model: WeaponItemModel }\n\n/** A set of weapon prop overrides of its own: the shipped ones plus `packs`, `patch` and `remove`. Nothing is shared with any other set on the page. */\nexport function createWeaponProps(options: WeaponPropsOptions = {}): WeaponProps {\n const entryOf = ([id, model]: readonly [string, WeaponItemModel | null]): Entry => ({ id, model: model ?? { item: '' } })\n const entries = mergeById<Entry>(SHIPPED_WEAPON_ITEM_MODELS.map(entryOf), (options.packs ?? []).flatMap((pack) => Object.entries(pack).map(entryOf)))\n const patches: Record<string, { model: DeepPartial<WeaponItemModel> }> = {}\n for (const [id, model] of Object.entries(options.patch ?? {})) patches[id] = { model }\n applyPatches(entries, patches)\n removeIds(entries, options.remove)\n return weaponPropsOver(new Map([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B,IAAI,OAAO,IAAI,QAAQ,SAAS,CAAC,GAAG,QAAQ,CAAC,SAAS,OAAO,QAAQ,IAAI,EAAE,IAAI,OAAO,CAAC,CAAC;AACpJ,QAAM,UAAmE,CAAC;AAC1E,aAAW,CAAC,IAAI,KAAK,KAAK,OAAO,QAAQ,QAAQ,SAAS,CAAC,CAAC,EAAG,SAAQ,EAAE,IAAI,EAAE,MAAM;AACrF,eAAa,SAAS,OAAO;AAC7B,YAAU,SAAS,QAAQ,MAAM;AACjC,SAAO,gBAAgB,IAAI,IAAI,CAAC,GAAG,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,MAAM,KAAK,CAAC,CAAC,CAAC;AACtF;","names":[]}
|
|
@@ -1009,6 +1009,12 @@ type ModelFamily = 'pistol' | 'revolver' | 'rifle' | 'semiint' | 'semi12' | 'p90
|
|
|
1009
1009
|
/** The named parts a model exposes to the animation: pivots and marks inside the model, never copies. */
|
|
1010
1010
|
interface ModelParts {
|
|
1011
1011
|
family: ModelFamily;
|
|
1012
|
+
/** Where the right hand takes a gun that names it (a rotary gun's rear spade grip, a horizontal handle along z): the top of the handle. */
|
|
1013
|
+
holdRight?: THREE_NS.Object3D;
|
|
1014
|
+
/** Where the supporting hand takes a gun that names it (the carry handle on top): the top of the handle, the palm on it. */
|
|
1015
|
+
holdLeft?: THREE_NS.Object3D;
|
|
1016
|
+
/** How the body carries it: `hip`, too heavy for the shoulder (a hand-held rotary gun), low at the right hip, level ahead. */
|
|
1017
|
+
carry?: 'hip';
|
|
1012
1018
|
/** Recoil strength of the model (the page's `kick`). */
|
|
1013
1019
|
kick?: number;
|
|
1014
1020
|
/** How far the slide or bolt travels back, in metres. */
|
|
@@ -1283,6 +1289,15 @@ interface WeaponFxOptions {
|
|
|
1283
1289
|
bodyHold?: () => HandPose | null;
|
|
1284
1290
|
/** Whether the view is the player's own eye: the gallery's guns are then framed in the view (`VIEW_HOLD`) instead of held on the body. */
|
|
1285
1291
|
firstPerson?: () => boolean;
|
|
1292
|
+
/** The lens the host draws the first-person layer with (`ModuleHost.setViewmodelFov`): the gun in the hands sets the one of its family, and null when it leaves the view. */
|
|
1293
|
+
viewmodelFov?: (degrees: number | null) => void;
|
|
1294
|
+
/** How far the gun is brought to the eye, 0 at the hip to 1 aimed down the sights. */
|
|
1295
|
+
aim?: () => number;
|
|
1296
|
+
/** How the body moves, for the bob of the step and the sway of the gun in the view. */
|
|
1297
|
+
motion?: () => {
|
|
1298
|
+
readonly speed: number;
|
|
1299
|
+
readonly running: boolean;
|
|
1300
|
+
};
|
|
1286
1301
|
/** The host's effects: the muzzle flash, smoke, backblast and flame jet of the gallery models are recipes it plays; without it the viewmodel makes a world of its own for them. */
|
|
1287
1302
|
effects?: EffectSink;
|
|
1288
1303
|
/** The most casings and magazines alive at once (`host.particleLimit`), read at each spawn; without it the viewmodel keeps a cap of its own. */
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { i as COUNTER_ITEM_ID, m as DEFAULT_EXPLOSIVES_SCENE, E as EXPLOSIVES_AREA_ID, o as EXPLOSIVES_TEXT, q as ExplosivesRoom, r as ExplosivesScene, s as ExplosivesTestModuleOptions, t as ExplosivesText, N as MOUNTED_M134_ITEM_ID, $ as WEAPON_ITEM_PREFIX, a7 as WeaponsTestModuleOptions, af as createExplosivesTestModule, ai as createWeaponsTestModule, al as explosivesTextOf, au as weaponsLayout } from './testing-
|
|
1
|
+
export { i as COUNTER_ITEM_ID, m as DEFAULT_EXPLOSIVES_SCENE, E as EXPLOSIVES_AREA_ID, o as EXPLOSIVES_TEXT, q as ExplosivesRoom, r as ExplosivesScene, s as ExplosivesTestModuleOptions, t as ExplosivesText, N as MOUNTED_M134_ITEM_ID, $ as WEAPON_ITEM_PREFIX, a7 as WeaponsTestModuleOptions, af as createExplosivesTestModule, ai as createWeaponsTestModule, al as explosivesTextOf, au as weaponsLayout } from './testing-BKDGK6cq.js';
|
|
2
2
|
import '@adatechnology/game-contracts';
|
|
3
3
|
import '@adatechnology/game-weapons';
|
|
4
4
|
import '@adatechnology/game-audio';
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adatechnology/game-weapons-three",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"license": "MIT AND CC-BY-SA-4.0 AND CC-BY-SA-3.0 AND CC-BY-3.0 AND CC0-1.0 AND LicenseRef-Public-Domain",
|
|
5
5
|
"description": "three.js presentation for @adatechnology/game-weapons: the real models of the Galeria 3D do Arsenal (78 weapons, a cartridge and a case per calibre), the weapon in the hands playing the tool-animation clips (fire, burst, cycle, jam, clear, safety and the seven reloads), ejected casings and dropped magazines, worn-metal conditions, synthesized sounds, and the weapons test area (counters with every weapon) as a TestableModule.",
|
|
6
6
|
"keywords": [
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"assets"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@adatechnology/game-audio": "^0.9.
|
|
48
|
-
"@adatechnology/game-contracts": "^0.
|
|
49
|
-
"@adatechnology/game-floorplan-three": "^0.10.
|
|
50
|
-
"@adatechnology/game-items-three": "^0.7.
|
|
47
|
+
"@adatechnology/game-audio": "^0.9.1",
|
|
48
|
+
"@adatechnology/game-contracts": "^0.27.0",
|
|
49
|
+
"@adatechnology/game-floorplan-three": "^0.10.2",
|
|
50
|
+
"@adatechnology/game-items-three": "^0.7.5",
|
|
51
51
|
"@adatechnology/game-render-three": "^0.2.0",
|
|
52
52
|
"@adatechnology/game-shapes-three": "^0.3.1",
|
|
53
|
-
"@adatechnology/game-vfx": "^0.
|
|
54
|
-
"@adatechnology/game-vfx-three": "^0.7.
|
|
55
|
-
"@adatechnology/game-weapons": "^0.
|
|
53
|
+
"@adatechnology/game-vfx": "^0.9.0",
|
|
54
|
+
"@adatechnology/game-vfx-three": "^0.7.3",
|
|
55
|
+
"@adatechnology/game-weapons": "^0.8.0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"three": "^0.160.0"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"tsup": "^8.5.1",
|
|
66
66
|
"typescript": "^5.7.3",
|
|
67
67
|
"vitest": "^3.2.4",
|
|
68
|
-
"@adatechnology/game-test-room": "^0.
|
|
68
|
+
"@adatechnology/game-test-room": "^0.28.1",
|
|
69
69
|
"@adatechnology/golden-tool": "^0.0.0"
|
|
70
70
|
},
|
|
71
71
|
"scripts": {
|