@adatechnology/game-weapons-three 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.global.js +2094 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +495 -0
- package/dist/index.js.map +1 -0
- package/package.json +61 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Anderson Fernandes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { HostEvent, HostTool, TestableModule, AreaPlacement, DestructibleSpec } from '@adatechnology/game-contracts';
|
|
2
|
+
import { Arsenal, WeaponDef } from '@adatechnology/game-weapons';
|
|
3
|
+
import * as THREE_NS from 'three';
|
|
4
|
+
|
|
5
|
+
/** Sounds the weapon presentation plays. */
|
|
6
|
+
interface WeaponAudio {
|
|
7
|
+
/** A shot: louder and longer the more muzzle energy (joules). */
|
|
8
|
+
shot(energyJ: number, category: string): void;
|
|
9
|
+
/** Dry click of an empty weapon. */
|
|
10
|
+
click(): void;
|
|
11
|
+
/** Magazine out, or the first shell in. */
|
|
12
|
+
reloadStart(category: string): void;
|
|
13
|
+
/** Magazine seated and the action racked. */
|
|
14
|
+
reloadEnd(category: string): void;
|
|
15
|
+
/** The pump or lever cycling after a shot. */
|
|
16
|
+
cycle(): void;
|
|
17
|
+
/** A casing bouncing on the floor. */
|
|
18
|
+
clink(): void;
|
|
19
|
+
/** A magazine landing on the floor. */
|
|
20
|
+
thud(): void;
|
|
21
|
+
/** Master volume, 0 to 1. */
|
|
22
|
+
setVolume(volume: number): void;
|
|
23
|
+
dispose(): void;
|
|
24
|
+
}
|
|
25
|
+
declare function createWeaponAudio(volume?: number): WeaponAudio;
|
|
26
|
+
|
|
27
|
+
interface WeaponFxOptions {
|
|
28
|
+
THREE: typeof THREE_NS;
|
|
29
|
+
scene: THREE_NS.Scene;
|
|
30
|
+
camera: THREE_NS.Camera;
|
|
31
|
+
arsenal: Arsenal;
|
|
32
|
+
/** Height things rest on at (x, z): casings and magazines land there. */
|
|
33
|
+
groundAt: (x: number, z: number) => number;
|
|
34
|
+
/** Sounds (`createWeaponAudio`); null or absent: silent. */
|
|
35
|
+
audio?: WeaponAudio | null;
|
|
36
|
+
}
|
|
37
|
+
/** The weapon in the hands, its fire and reload motion, ejected casings and dropped magazines, and their sounds. */
|
|
38
|
+
interface WeaponFx {
|
|
39
|
+
/** Feed every tool event of the host, with the tool as it is after the event. */
|
|
40
|
+
handle(event: HostEvent, tool: HostTool): void;
|
|
41
|
+
update(dt: number): void;
|
|
42
|
+
/** Weapon shown in the hands, or null. */
|
|
43
|
+
readonly inHand: string | null;
|
|
44
|
+
/** Casings and magazines currently on the floor or in the air. */
|
|
45
|
+
readonly casings: number;
|
|
46
|
+
readonly magazines: number;
|
|
47
|
+
dispose(): void;
|
|
48
|
+
}
|
|
49
|
+
declare function createWeaponFx(options: WeaponFxOptions): WeaponFx;
|
|
50
|
+
|
|
51
|
+
interface WeaponsTestModuleOptions {
|
|
52
|
+
/** `en` or `pt-BR` (default). */
|
|
53
|
+
locale?: string;
|
|
54
|
+
/** The arsenal to lay out (default `createArsenal` with the locale). */
|
|
55
|
+
arsenal?: Arsenal;
|
|
56
|
+
/** Play sounds (default true; silent anyway where there is no AudioContext). */
|
|
57
|
+
sound?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/** Prefix of the item ids of the weapon props (`weapon_pistol_9mm`). */
|
|
60
|
+
declare const WEAPON_ITEM_PREFIX = "weapon_";
|
|
61
|
+
declare const COUNTER_ITEM_ID = "counter_weapons";
|
|
62
|
+
/** Where the counters go and where each weapon lies on them: three counters on the free left side of the room, props across them. */
|
|
63
|
+
declare function weaponsLayout(weaponItemIds: string[]): AreaPlacement[];
|
|
64
|
+
/**
|
|
65
|
+
* The weapons test area as a `TestableModule` of @adatechnology/game-contracts: one prop per weapon of the arsenal on counters (aim at one and
|
|
66
|
+
* press H to equip it), targets at shooting distance, and, through `attach`, the weapon in the hands with its fire and reload motion,
|
|
67
|
+
* ejected casings, dropped magazines and sounds, driven by the host's tool events.
|
|
68
|
+
*/
|
|
69
|
+
declare function createWeaponsTestModule(options?: WeaponsTestModuleOptions): TestableModule & {
|
|
70
|
+
readonly audio: WeaponAudio | null;
|
|
71
|
+
readonly fx: WeaponFx | null;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/** A low-poly prop: its destruction spec (box parts only) and one colour per part. */
|
|
75
|
+
interface WeaponProp {
|
|
76
|
+
spec: DestructibleSpec;
|
|
77
|
+
colors: Record<string, number>;
|
|
78
|
+
}
|
|
79
|
+
/** Body actions of the arsenal: nothing to hold or lay on a counter. */
|
|
80
|
+
declare const BODY_ACTIONS: ReadonlySet<string>;
|
|
81
|
+
/** The prop of a weapon: low-poly parts by category, the real mass of the weapon spread over them. */
|
|
82
|
+
declare function weaponProp(def: Pick<WeaponDef, 'id' | 'category' | 'mass'>, name?: string): WeaponProp;
|
|
83
|
+
/** One mesh per box part, named after the part (what destruction renderers bind to), in a group with its origin on the floor. */
|
|
84
|
+
declare function buildProp(THREE: typeof THREE_NS, prop: WeaponProp): THREE_NS.Group;
|
|
85
|
+
/** The model of a weapon for the hands or a shelf: the same prop the counters show. */
|
|
86
|
+
declare function buildWeaponModel(THREE: typeof THREE_NS, def: Pick<WeaponDef, 'id' | 'category' | 'mass'>): THREE_NS.Group;
|
|
87
|
+
|
|
88
|
+
export { BODY_ACTIONS, COUNTER_ITEM_ID, WEAPON_ITEM_PREFIX, type WeaponAudio, type WeaponFx, type WeaponFxOptions, type WeaponProp, type WeaponsTestModuleOptions, buildProp, buildWeaponModel, createWeaponAudio, createWeaponFx, createWeaponsTestModule, weaponProp, weaponsLayout };
|