@adatechnology/game-weapons-three 0.4.1 → 0.6.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 +1 -1
- package/dist/index.d.ts +55 -5
- package/dist/index.global.js +1681 -121
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +250 -97
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @adatechnology/game-weapons-three
|
|
2
2
|
|
|
3
|
-
three.js presentation for `@adatechnology/game-weapons`: the real models of the arsenal, the weapon in the hands, ejected casings, sounds and the weapons test area.
|
|
3
|
+
three.js presentation for `@adatechnology/game-weapons`: the real models of the arsenal, the weapon in the hands, ejected casings, sounds (recipes on `@adatechnology/game-audio`; `createWeaponAudio(volume, { engine })` plays on a shared engine) and the weapons test area.
|
|
4
4
|
|
|
5
5
|
## Licenses
|
|
6
6
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { HostTool, HostEvent, TestableModule, AreaPlacement, TestableItem, DestructibleSpec, ToolClipSet } from '@adatechnology/game-contracts';
|
|
1
|
+
import { HostTool, HostEvent, TestableModule, AreaPlacement, TestableItem, EffectSink, DestructibleSpec, ToolClipSet } from '@adatechnology/game-contracts';
|
|
2
2
|
import { CaliberDef, ReloadStageId, WeaponEvent, MountKind, AttachmentDef, FittedAttachment, Arsenal, ExplosiveDef, WeaponDef, CartridgeDims, CaseType, ReloadFamily } from '@adatechnology/game-weapons';
|
|
3
|
+
import { AudioEngine } from '@adatechnology/game-audio';
|
|
3
4
|
import * as THREE_NS from 'three';
|
|
4
5
|
|
|
5
6
|
/** One sound of the game: [lowpass cutoff Hz, gain, seconds]. Literal from the `P` table of `sfx` in the game (jogo.js L62101-L62104). */
|
|
@@ -135,12 +136,34 @@ type SoundStep =
|
|
|
135
136
|
readonly at: number;
|
|
136
137
|
readonly gain: number;
|
|
137
138
|
readonly frequency: number;
|
|
139
|
+
}
|
|
140
|
+
/** The art scene's `sTone` (cena L1324): a tone sliding from `f` to `f2` (default `f`) in `d` seconds, at `vol`, `at` seconds after the start. */
|
|
141
|
+
| {
|
|
142
|
+
readonly layer: 'scene_tone';
|
|
143
|
+
readonly at: number;
|
|
144
|
+
readonly wave: 'sine' | 'square';
|
|
145
|
+
readonly f: number;
|
|
146
|
+
readonly f2?: number;
|
|
147
|
+
readonly d: number;
|
|
148
|
+
readonly vol: number;
|
|
149
|
+
}
|
|
150
|
+
/** The art scene's `sNoise` (cena L1323): filtered noise, the filter sliding to `f2` when given, `d` seconds, at `vol`. */
|
|
151
|
+
| {
|
|
152
|
+
readonly layer: 'scene_noise';
|
|
153
|
+
readonly at: number;
|
|
154
|
+
readonly type: 'lowpass' | 'highpass' | 'bandpass';
|
|
155
|
+
readonly f: number;
|
|
156
|
+
readonly f2?: number;
|
|
157
|
+
readonly q: number;
|
|
158
|
+
readonly d: number;
|
|
159
|
+
readonly vol: number;
|
|
138
160
|
};
|
|
139
161
|
type MechanicalSoundId = ReloadStageId | 'dry_fire' | 'misfire' | 'feed' | 'cycle' | 'mode' | 'safety_on' | 'safety_off' | 'jam' | 'clear_start' | 'clear_end' | 'stock_fold' | 'light_click' | 'attach';
|
|
140
162
|
/**
|
|
141
163
|
* Sounds keyed by the rule: the `reload_stage` ids of `RELOAD_STAGES`, plus the other weapon events. The click of an empty weapon and the generic
|
|
142
|
-
* reload tick are the game's `vazio` and `recarga` classes (jogo.js L62101-L62104; played at L68644-L68662)
|
|
143
|
-
*
|
|
164
|
+
* reload tick are the game's `vazio` and `recarga` classes (jogo.js L62101-L62104; played at L68644-L68662). The Cena de Arte delivered the reload sounds
|
|
165
|
+
* (`empty` -> dry_fire, `magOut` -> magazine_out, `magIn` -> magazine_in, `bolt` -> charge, `shell` -> round_in; cena L1339-L1343), so those use them; the gallery
|
|
166
|
+
* (sources/armas-itens__galeria-3d-arsenal.js) has no sound, and the other metal layers are the SDK synth (the same `metal` used since the first version).
|
|
144
167
|
*/
|
|
145
168
|
declare const MECHANICAL_SOUNDS: Readonly<Record<MechanicalSoundId, readonly SoundStep[]>>;
|
|
146
169
|
/** Which mechanical sound a weapon event asks for, if any (`shot`, `draw` and `reload` start/end have their own handling). */
|
|
@@ -153,8 +176,14 @@ interface WeaponAudioOptions extends ShotSoundOptions {
|
|
|
153
176
|
readonly seed?: number;
|
|
154
177
|
/** Replaces or adds mechanical sounds by id. */
|
|
155
178
|
readonly mechanical?: Readonly<Partial<Record<MechanicalSoundId, readonly SoundStep[]>>>;
|
|
156
|
-
/** Where the AudioContext comes from (default: the global one); lets a host or a test lend its own. */
|
|
179
|
+
/** Where the AudioContext comes from (default: the global one); lets a host or a test lend its own. Not used with `engine`. */
|
|
157
180
|
readonly createContext?: () => AudioContext;
|
|
181
|
+
/**
|
|
182
|
+
* A sound engine the host already has (one shared engine mixes, limits and pans every module the same way). The weapon sounds are registered in it
|
|
183
|
+
* and play on its `weapons` bus; `seed` gives them their own random stream, the master volume and the context stay the engine's. Without it the
|
|
184
|
+
* weapon audio makes its own engine with the game mix, no voice limit, and the master at `volume`.
|
|
185
|
+
*/
|
|
186
|
+
readonly engine?: AudioEngine;
|
|
158
187
|
}
|
|
159
188
|
/** Sounds the weapon presentation plays. */
|
|
160
189
|
interface WeaponAudio {
|
|
@@ -607,6 +636,27 @@ declare const WORLD_EXPLOSIVE_IDS: readonly string[];
|
|
|
607
636
|
/** An explosive of the arsenal standing in the world: it goes off by a bullet, fire or another blast, after the delay its `chain` gives. */
|
|
608
637
|
declare const worldExplosiveItem: (def: ExplosiveDef, name: string) => TestableItem | undefined;
|
|
609
638
|
|
|
639
|
+
/** The effect ids a weapon of a case type shows when it is seen from outside: its muzzle flash and its ejected case (the host's catalogue names them). */
|
|
640
|
+
interface WorldEffectIds {
|
|
641
|
+
readonly muzzle: string;
|
|
642
|
+
readonly casing: string;
|
|
643
|
+
}
|
|
644
|
+
declare const WORLD_EFFECTS: Readonly<Record<string, WorldEffectIds>>;
|
|
645
|
+
interface WorldEffectsOptions {
|
|
646
|
+
readonly arsenal: Arsenal;
|
|
647
|
+
/** The case type of a weapon (`pistol`, `rifle`, `shell`, `big`, `tiny`); default from its caliber. */
|
|
648
|
+
readonly caseTypeOf?: (weapon: string) => string | undefined;
|
|
649
|
+
/** The ids by case type; default `WORLD_EFFECTS`. A game adds or changes entries. */
|
|
650
|
+
readonly ids?: Readonly<Record<string, WorldEffectIds>>;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* The shooter's flash and ejected case for a shot the viewer sees from outside (a `shot` event that carries `origin`), played through the host's
|
|
654
|
+
* effect sink. The player's own first-person shot has no `origin` and is drawn by the weapon in the hands, so nothing doubles.
|
|
655
|
+
*/
|
|
656
|
+
declare function createWorldEffects(options: WorldEffectsOptions): {
|
|
657
|
+
handle(event: HostEvent, sink: EffectSink | undefined): number;
|
|
658
|
+
};
|
|
659
|
+
|
|
610
660
|
/** A low-poly prop: its destruction spec (box parts only) and one colour per part. */
|
|
611
661
|
interface WeaponProp {
|
|
612
662
|
spec: DestructibleSpec;
|
|
@@ -702,4 +752,4 @@ declare function rigUnderbarrel(THREE: typeof THREE_NS, model: WeaponModel, def:
|
|
|
702
752
|
*/
|
|
703
753
|
declare function rigStock(THREE: typeof THREE_NS, model: WeaponModel, def: Pick<WeaponDef, 'stock' | 'dimensions'>): void;
|
|
704
754
|
|
|
705
|
-
export { ARCHETYPE_MODELS, ATTACHMENT_MODELS, type AttachmentBuildContext, type AttachmentModel, type AttachmentModelBuilder, type AttachmentModelRegistry, type AttachmentRig, BODY_ACTIONS, CLASS_REFERENCE_ENERGY, COUNTER_ITEM_ID, type CartridgeShape, type ClipContext, DEFAULT_ENERGY_CURVE, DEFAULT_THUMBNAIL_BASE, type DistanceCurve, type EnergyCurve, type FitAttachmentOptions, type FxLayers, GAME_DISTANCE_CURVE, GAME_SOUND_CLASSES, type LaserRaycast, MECHANICAL_SOUNDS, MODEL_ENTRIES, MOUNTED_M134_ITEM_ID, type MechanicalSoundId, type ModelEntry, type ModelFamily, type ModelKit, type ModelMaterials, type ModelOptions, type ModelParts, type MountFrame, type ShotExtras, type ShotSound, type ShotSoundClass, type ShotSoundInput, type ShotSoundOptions, type SoundClassDef, type SoundStep, WEAPON_ITEM_PREFIX, WEAPON_THUMBNAILS, WORLD_EXPLOSIVE_IDS, WORLD_EXPLOSIVE_PREFIX, type WeaponAudio, type WeaponAudioOptions, type WeaponFx, type WeaponFxOptions, type WeaponModel, type WeaponProp, type WeaponThumbnailEntry, type WeaponsTestModuleOptions, applyCondition, buildCartridge, buildCasing, buildProp, buildRound, buildToolClips, buildWeaponModel, buildWeaponModelById, cartridgeShape, computeShotSound, createWeaponAudio, createWeaponFx, createWeaponsTestModule, deriveFrames, fitAttachmentModels, hasWeaponModel, mechanicalSoundOf, modelKit, mountFrame, partRegistry, rigStock, rigUnderbarrel, weaponProp, weaponThumbnailCredit, weaponThumbnailUrl, weaponsLayout, worldExplosiveItem };
|
|
755
|
+
export { ARCHETYPE_MODELS, ATTACHMENT_MODELS, type AttachmentBuildContext, type AttachmentModel, type AttachmentModelBuilder, type AttachmentModelRegistry, type AttachmentRig, BODY_ACTIONS, CLASS_REFERENCE_ENERGY, COUNTER_ITEM_ID, type CartridgeShape, type ClipContext, DEFAULT_ENERGY_CURVE, DEFAULT_THUMBNAIL_BASE, type DistanceCurve, type EnergyCurve, type FitAttachmentOptions, type FxLayers, GAME_DISTANCE_CURVE, GAME_SOUND_CLASSES, type LaserRaycast, MECHANICAL_SOUNDS, MODEL_ENTRIES, MOUNTED_M134_ITEM_ID, type MechanicalSoundId, type ModelEntry, type ModelFamily, type ModelKit, type ModelMaterials, type ModelOptions, type ModelParts, type MountFrame, type ShotExtras, type ShotSound, type ShotSoundClass, type ShotSoundInput, type ShotSoundOptions, type SoundClassDef, type SoundStep, WEAPON_ITEM_PREFIX, WEAPON_THUMBNAILS, WORLD_EFFECTS, WORLD_EXPLOSIVE_IDS, WORLD_EXPLOSIVE_PREFIX, type WeaponAudio, type WeaponAudioOptions, type WeaponFx, type WeaponFxOptions, type WeaponModel, type WeaponProp, type WeaponThumbnailEntry, type WeaponsTestModuleOptions, type WorldEffectIds, type WorldEffectsOptions, applyCondition, buildCartridge, buildCasing, buildProp, buildRound, buildToolClips, buildWeaponModel, buildWeaponModelById, cartridgeShape, computeShotSound, createWeaponAudio, createWeaponFx, createWeaponsTestModule, createWorldEffects, deriveFrames, fitAttachmentModels, hasWeaponModel, mechanicalSoundOf, modelKit, mountFrame, partRegistry, rigStock, rigUnderbarrel, weaponProp, weaponThumbnailCredit, weaponThumbnailUrl, weaponsLayout, worldExplosiveItem };
|