@adatechnology/game-test-room 0.6.1 → 0.8.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 +10 -1
- package/dist/index.d.ts +20 -1
- package/dist/index.global.js +12793 -1778
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +178 -17
- package/dist/index.js.map +1 -1
- package/package.json +10 -7
package/README.md
CHANGED
|
@@ -71,10 +71,16 @@ The items join the catalogue under the module's group and its scenarios become b
|
|
|
71
71
|
|
|
72
72
|
## Module bench
|
|
73
73
|
|
|
74
|
+
The room makes **one** effects world (`game-vfx` and its `game-vfx-three` layer) and steps it once per frame, after the destruction renderer. The destruction
|
|
75
|
+
renderer draws into it, every module gets it as `host.effects` (an `EffectSink`: `play({ effect: 'm67', point })`, `catalog()`), grenades and rockets play the
|
|
76
|
+
profile of their explosive (`explosive` is on the `explosion` host event), the camera shakes and the screen flashes through an overlay in the container, and the
|
|
77
|
+
`particles` metric counts its pools. Without a DOM nothing is drawn on the screen. `TestRoom.applyCamera()` wraps a host's own `render`; the room's loop does it itself.
|
|
78
|
+
`craters: true` swaps the floor for a deformable patch that big explosions dig into.
|
|
79
|
+
|
|
74
80
|
A module that declares `controls`, `layers` or `metrics` (see `@adatechnology/game-contracts`) gets a bench: `loadModule` checks it with
|
|
75
81
|
`checkBench` (a `✓ ... bench ok` / `✗ ... bench broken` line), lends `host.bench` to `attach`, then sends one change per control and layer. The
|
|
76
82
|
panel between the animations and the tests shows the active module (the one of the last `openArea`; else the first loaded with a bench, a later module never takes the panel from the one on screen): a
|
|
77
|
-
range per number, a checkbox per boolean, buttons (up to four options) or a select per choice, a button per action, the layers, and the
|
|
83
|
+
range per number, a checkbox per boolean, buttons (up to four options, no groups) or a select per choice (options with a `group` sit under `optgroup`s), a button per action, the layers, and the
|
|
78
84
|
module counters at 4 Hz with a bar when they have a budget (`warn` from 80 %, `bad` past it). A compact line on top shows the room counters
|
|
79
85
|
(`fps`, `frame_ms`, `draw_calls`, `triangles`, `objects`, `fragments`, `particles`, `decals`); `fps` uses the real frame time, so slow motion
|
|
80
86
|
does not change it.
|
|
@@ -85,6 +91,9 @@ room.bench()?.set('size', 2) // clamped and snapped; false for an unknown id, a
|
|
|
85
91
|
room.metrics() // { room: { fps, draw_calls, ... }, module: { particles: 120 } }
|
|
86
92
|
```
|
|
87
93
|
|
|
94
|
+
A module can put a **sheet** on the panel (`host.bench.sheet(sheet)`, `BenchSheet` of the contracts): a card with a kicker, a title, a text, facts, steps, colour swatches and a timeline of named segments whose playhead follows one of the module's numeric metrics.
|
|
95
|
+
The room also runs the film of the liquids that have one (`createFilmManager` of `game-fluids-three`): a leak of fuel, oil or blood drips into grids on the floor near the camera.
|
|
96
|
+
|
|
88
97
|
The state is `id=value;id=value` (`encodeBenchState` / `decodeBenchState`); decoding treats it as hostile input. `bench.state` is keyed by
|
|
89
98
|
module id, so two modules can share a control id; a module loaded again keeps its live values. The room never touches
|
|
90
99
|
`location`: the example page keeps it in `?bench.<moduleId>=`. `fps` and `frame_ms` use the real frame time, even past the 50 ms the simulation is clamped to. Loading a module again detaches the previous `attach` first. Q now reports the new fire
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as THREE_NS from 'three';
|
|
2
|
+
import { AudioEngine } from '@adatechnology/game-audio';
|
|
2
3
|
import { DestructibleSpec, Vec3, DestructionWorld, DestructionOptions, DestructionEvent, MaterialDef } from '@adatechnology/game-destruction';
|
|
3
4
|
export { DestructionEvent, Vec3 } from '@adatechnology/game-destruction';
|
|
4
5
|
import { SpecFromObjectOptions, DestructionRenderer, Quality } from '@adatechnology/game-destruction-three';
|
|
5
6
|
import { Arsenal, WeaponState, WeaponDef } from '@adatechnology/game-weapons';
|
|
6
7
|
import { FluidRenderer } from '@adatechnology/game-fluids-three';
|
|
7
8
|
import { ContainerSpec, FluidWorld, LiquidDef, ItemUseDef, SurfaceSpec } from '@adatechnology/game-fluids';
|
|
8
|
-
import { ModuleControl, ControlValue, ModuleLayer, DestructibleImpl, AnimationClipSpec, TestableModule } from '@adatechnology/game-contracts';
|
|
9
|
+
import { ModuleControl, ControlValue, ModuleLayer, DestructibleImpl, AnimationClipSpec, EnvironmentBus, TestableModule } from '@adatechnology/game-contracts';
|
|
9
10
|
export { AnimationClipSpec, DestructibleImpl, ItemAnimationContract, ModuleScenario, TestableItem, TestableModule } from '@adatechnology/game-contracts';
|
|
10
11
|
|
|
11
12
|
type NewEntry = NewLogEntry;
|
|
@@ -181,6 +182,8 @@ interface TestRoomOptions {
|
|
|
181
182
|
world?: DestructionWorld;
|
|
182
183
|
worldOptions?: DestructionOptions;
|
|
183
184
|
quality?: Quality;
|
|
185
|
+
/** Replaces the arena floor with a deformable patch (60 m, 33 cm cells) that the craters of big explosions dig into. Default false. */
|
|
186
|
+
craters?: boolean;
|
|
184
187
|
/** Heaviest object the player can carry (default 60 kg). */
|
|
185
188
|
maxCarryKg?: number;
|
|
186
189
|
/** Arena half size in metres (default 14). */
|
|
@@ -192,6 +195,13 @@ interface TestRoomOptions {
|
|
|
192
195
|
/** Called for every destruction event (to log, play sounds, sync over LAN). Fluid events reach the log too. */
|
|
193
196
|
onEvent?: (event: DestructionEvent) => void;
|
|
194
197
|
onSound?: (key: string, point: Vec3, volume: number) => void;
|
|
198
|
+
/**
|
|
199
|
+
* The sound engine of the room (@adatechnology/game-audio): the destruction renderer's sound keys play on it, and modules get it as `host.audio`.
|
|
200
|
+
* Default: a new engine of the room's own (it makes no AudioContext until the first sound); `false` for a silent room.
|
|
201
|
+
*/
|
|
202
|
+
audio?: AudioEngine | false;
|
|
203
|
+
/** The environment store modules get as `host.environment` (the weather module writes it, the others read it). Default: a new one with a calm dry day. */
|
|
204
|
+
environment?: EnvironmentBus;
|
|
195
205
|
/** Show the built-in HUD and panels (default true). */
|
|
196
206
|
ui?: boolean;
|
|
197
207
|
/** Room counters the bench panel shows and `TestRoom.metrics()` returns (default all); `false` for none. */
|
|
@@ -236,6 +246,10 @@ interface SpawnedObject {
|
|
|
236
246
|
movable: boolean;
|
|
237
247
|
}
|
|
238
248
|
interface TestRoom {
|
|
249
|
+
/** The room's sound engine, or `null` in a silent room. */
|
|
250
|
+
readonly audio: AudioEngine | null;
|
|
251
|
+
/** The environment store lent to modules as `host.environment`. */
|
|
252
|
+
readonly environment: EnvironmentBus;
|
|
239
253
|
readonly world: DestructionWorld;
|
|
240
254
|
readonly renderer: DestructionRenderer;
|
|
241
255
|
readonly scene: THREE_NS.Scene;
|
|
@@ -320,6 +334,11 @@ interface TestRoom {
|
|
|
320
334
|
/** The bench of a loaded module (default the active one: the module of the last `openArea`, else the last loaded with a bench), or null. */
|
|
321
335
|
bench(moduleId?: string): BenchHandle | null;
|
|
322
336
|
/** Room counters and the active module's metrics, read now. */
|
|
337
|
+
/**
|
|
338
|
+
* Shakes the camera for the render that follows, by the shake of the effects world, and answers the function that puts it back. The room's own loop
|
|
339
|
+
* wraps its render in it; a host that renders by itself calls it around its own `render`.
|
|
340
|
+
*/
|
|
341
|
+
applyCamera(): () => void;
|
|
323
342
|
metrics(): {
|
|
324
343
|
room: Partial<Record<RoomMetricId, number>>;
|
|
325
344
|
module: Record<string, number | string>;
|