@adatechnology/game-test-room 0.19.1 → 0.21.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/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { LightBudget } from '@adatechnology/game-render-three';
1
2
  import * as THREE_NS from 'three';
2
3
  import { AudioEngine } from '@adatechnology/game-audio';
3
4
  import { Vec3 as Vec3$1, DestructionWorld, BlastOptions, DestructibleSpec, DestructionOptions, DestructionEvent } from '@adatechnology/game-destruction';
@@ -6,9 +7,12 @@ import { DoorUsePhase, FurniturePushPhase, FurniturePushBlock, FurniturePushRule
6
7
  import { BusySink, ItemSeat, Vec3, HandTargets, ModuleControl, ControlValue, ModuleLayer, EnvironmentBus, BusyTask, BusyOptions, TestableModule, ModuleItemSeal, DestructibleImpl, AnimationClipSpec, GroundLayout, BlastShoveOptions } from '@adatechnology/game-contracts';
7
8
  export { AnimationClipSpec, DestructibleImpl, ItemAnimationContract, ModuleScenario, TestableItem, TestableModule } from '@adatechnology/game-contracts';
8
9
  import { DestructionRenderer, SpecFromObjectOptions, Quality, FragmentLifeRule } from '@adatechnology/game-destruction-three';
9
- import { Arsenal, WeaponState, WeaponDef } from '@adatechnology/game-weapons';
10
+ import { StorageLike, GraphicsController } from '@adatechnology/game-graphics';
11
+ import { GraphicsScreen } from '@adatechnology/game-graphics/screen';
12
+ import { Arsenal, WeaponState, TriggerResult, WeaponDef } from '@adatechnology/game-weapons';
10
13
  import { VfxWorld, SpriteKindDef } from '@adatechnology/game-vfx';
11
14
  import { Terrain, TerrainBudget } from '@adatechnology/game-terrain';
15
+ import { SchedulerStats } from '@adatechnology/game-runtime';
12
16
  import { FilmBridge, FluidRenderer } from '@adatechnology/game-fluids-three';
13
17
  import { FluidWorld, ContainerSpec, LiquidDef, ItemUseDef, SurfaceSpec } from '@adatechnology/game-fluids';
14
18
 
@@ -101,6 +105,21 @@ interface LoadingOptions {
101
105
  declare const nextPaint: () => Promise<void>;
102
106
  declare function createLoading(options: LoadingOptions): RoomLoading;
103
107
 
108
+ /** The room's graphics settings (`TestRoomOptions.graphics`). */
109
+ interface RoomGraphicsOptions {
110
+ /** Where the player's choice is kept (default `localStorage`; null keeps it in memory). */
111
+ readonly storage?: StorageLike | null;
112
+ /** The key it is kept under (default `adatechnology.graphics`). */
113
+ readonly key?: string;
114
+ /** The short test of the first load, seconds (default 3; 0 skips it and starts the automatic mode at Alta). */
115
+ readonly calibrationSeconds?: number;
116
+ /**
117
+ * When the calibration of a first run starts: `idle` (default) after a few drawn frames with nothing on the loading indicator, or `manual`, where the page calls
118
+ * `room.graphics.calibrateIfNeeded()` once its content is in (a page that loads its content before it shows the room).
119
+ */
120
+ readonly calibrate?: 'idle' | 'manual';
121
+ }
122
+
104
123
  /**
105
124
  * The room's seats: puts the player on a seat an item brings (`TestRoomItem.seats`, the shape of a `game-interactables` seat) and back on its feet at the seat's exit.
106
125
  * Seated, the keys do not walk and the view stays within reach of the seat's facing; a walk key or a jump gets up, and so does losing the seat (the item is gone).
@@ -308,6 +327,21 @@ interface InspectInfo {
308
327
  /** Author and licence of the thumbnail (`TestRoomItem.thumbnailCredit`). */
309
328
  thumbnailCredit?: string;
310
329
  distance: number;
330
+ /** Set when the aim rests on the floor: what the ground is there (the room's terrain) instead of an object's part. */
331
+ ground?: GroundInspect;
332
+ }
333
+ /** The floor under the aim: its profile, the layer a blow reaches now and what has been done to it. */
334
+ interface GroundInspect {
335
+ /** Name of the ground profile (Dirt, Concrete slab). */
336
+ surface: string;
337
+ /** Name of the material exposed at that point (the turf, or the soil under it once dug). */
338
+ material: string;
339
+ /** Metres dug out under the untouched surface. */
340
+ dug: number;
341
+ /** Metres left before the digging limit (bedrock, or the bottom of a slab). */
342
+ remaining: number;
343
+ /** 0..1, how burnt the surface is. */
344
+ scorch: number;
311
345
  }
312
346
  interface HudState {
313
347
  toolName: string;
@@ -437,6 +471,11 @@ interface RoomAvatar {
437
471
  leg?: 'left' | 'right';
438
472
  hand?: 'left' | 'right';
439
473
  }): number | null;
474
+ /**
475
+ * The foot the body put down since the last call (its walk cycle reached a heel strike), or null. The room asks after each `update` and sends the footfall to the
476
+ * modules (`HostEvent` `footfall`), so the step is heard on the frame the foot is seen on the ground. Without it the room counts strides by distance.
477
+ */
478
+ footfall?(): 'left' | 'right' | null;
440
479
  /**
441
480
  * Brings the body's hands to the tool in them (`HandTargets`, world space: the module's). The room calls it in both views every frame, after the modules have placed the tool and
442
481
  * before the render, with `view` (the eye's camera, and `contact` to keep the hands out of walls) in both views. An avatar without it keeps the hands where its own pose puts them.
@@ -662,6 +701,12 @@ interface TestRoomOptions {
662
701
  world?: DestructionWorld;
663
702
  worldOptions?: DestructionOptions;
664
703
  quality?: Quality;
704
+ /**
705
+ * The player's graphics settings (`game-graphics`): a Gráficos button opens the screen (presets Automático, Baixa, Média, Alta, Ultra and each option), the
706
+ * choice is kept in the browser, the first load runs a short calibration on the loading indicator and the automatic mode moves what is left on auto. Only on a
707
+ * renderer the room makes. Default off (the fixed look of `quality`).
708
+ */
709
+ graphics?: boolean | RoomGraphicsOptions;
665
710
  /** What the floor is made of until an area lays its own (`TestableModule.ground`). Default a concrete slab. */
666
711
  ground?: GroundLayout;
667
712
  /** Limits of the floor's marks, thrown pieces and redraws per frame. */
@@ -739,6 +784,11 @@ interface TestRoomOptions {
739
784
  handStances?: Readonly<Record<string, string>>;
740
785
  /** The over-the-shoulder view of the `third` mode: distance, shoulder, height, wall probes. Defaults are the team game's. */
741
786
  thirdPerson?: ThirdPersonOptions;
787
+ /**
788
+ * Milliseconds of every frame the deferred queues (sound voices, destruction events, breach paint, vehicle crease) share. Default 8, the biggest budget the loose
789
+ * queues had; 4 is the library default of `@adatechnology/game-runtime`, for a room whose `maxFramesWaiting` stays under 15 (see `frameStats()`).
790
+ */
791
+ frameBudgetMs?: number;
742
792
  /** Room counters the bench panel shows and `TestRoom.metrics()` returns (default all); `false` for none. */
743
793
  metrics?: readonly RoomMetricId[] | false;
744
794
  /**
@@ -747,12 +797,21 @@ interface TestRoomOptions {
747
797
  * sprites (dust, smoke, chips, sparks...) by kind, e.g. `{ dust: { life: [10, 30] } }` (seconds, min and max). Loose pieces (what breaks off whole: a door, a leg,
748
798
  * a slab) stay as part of the map, with collision.
749
799
  */
800
+ /** Slots of the room's light budget (default 16 point and 4 spot). Each light is paid per pixel, lit or not, so a weak GPU gets fewer; changing them recompiles every lit program, so they are fixed at load. */
801
+ lightSizes?: {
802
+ readonly point?: number;
803
+ readonly spot?: number;
804
+ };
805
+ /** Drawn frames the GPU may be behind before the room holds a draw back (`createFramePacer`, default 2). */
806
+ framesInFlight?: number;
750
807
  debris?: {
751
808
  fragmentLife?: number | FragmentLifeRule;
752
809
  maxFragments?: number;
753
810
  particles?: Readonly<Record<string, Partial<SpriteKindDef> | null>>;
754
811
  /** Milliseconds of destruction events the renderer applies per frame; the rest wait for the next frames (default 8). `Infinity` applies every event in the frame it happens, which a test comparing counts needs. */
755
812
  eventBudgetMs?: number;
813
+ /** The most loose bodies (ejected casings, dropped magazines) modules may keep alive at once, lent as `ModuleHost.particleLimit` (default 900). */
814
+ particleLimit?: number;
756
815
  };
757
816
  /** Blast options every explosion of the room starts with (`shelter`, `fragmentHits`, `confinement`; default all off). The HUD toggles them and `TestRoom.setBlast` changes them. */
758
817
  blast?: BlastOptions;
@@ -779,7 +838,9 @@ interface TestRoomOptions {
779
838
  /** Counters the room measures itself. `fps` and `frame_ms` use the real frame time, so slow motion does not change them. */
780
839
  type RoomMetricId = 'fps' | 'frame_ms' | 'draw_calls' | 'triangles' | 'objects' | 'fragments' | 'particles' | 'decals'
781
840
  /** Of the last blast, once the room's blast options are on: the share that reached the most sheltered target (%), the pressure multiplier, the fragment hits. */
782
- | 'blast_shelter' | 'blast_confinement' | 'blast_fragments';
841
+ | 'blast_shelter' | 'blast_confinement' | 'blast_fragments'
842
+ /** Memory: geometries and textures alive on the GPU (three's `renderer.info.memory`), the JS heap in MB where the browser tells it. */
843
+ | 'geometries' | 'textures' | 'heap_mb';
783
844
  /** A module control as the room holds it: the declaration with the module's patches applied, and its value (none for an action). */
784
845
  type BenchControl = ModuleControl & {
785
846
  readonly disabled: boolean;
@@ -816,6 +877,10 @@ interface TestRoom {
816
877
  readonly renderer: DestructionRenderer;
817
878
  readonly scene: THREE_NS.Scene;
818
879
  readonly camera: THREE_NS.PerspectiveCamera;
880
+ /** The room's light budget (what `host.lights` lends): the one owner of its point and spot lights. */
881
+ readonly lights?: LightBudget;
882
+ /** The WebGL renderer the room draws with, for tools that read what the GPU got (the `light_slots` phase of `perf.mjs` reads the uniforms of a lit material). */
883
+ readonly webgl?: THREE_NS.WebGLRenderer;
819
884
  /** The test table: lays the catalogue on the `test_table` piece a page at a time and runs the trials (shot, punch, knife, fire, blast) on one item. */
820
885
  readonly testTable: TestTable;
821
886
  /** Spawn a catalogue item at a world position (default in front of the player). */
@@ -835,8 +900,12 @@ interface TestRoom {
835
900
  readonly tool: WeaponState;
836
901
  /** Play an item use on the held item (`drink`, `pour`...). Returns false when nothing is held or the use does not apply. */
837
902
  useItem(useId: string): boolean;
838
- /** Use the current tool once from the camera (tests and scripted demos), as the click does: bare hands punch (or let go of what they hold). `hold` seconds for continuous tools. */
839
- use(hold?: number): void;
903
+ /**
904
+ * Use the current tool once from the camera (tests and scripted demos), as the click does: bare hands punch (or let go of what they hold). `hold` seconds for continuous tools.
905
+ * Answers what the trigger said: `ok` when the tool did something; `drawing` when the draw is not over for the trigger yet (the frame that ends the draw is the trigger's
906
+ * too, so `tool.phase` turns null one frame before the first pull can go: a script waits a frame and pulls again), `cooldown`, `empty`, `reloading`... otherwise.
907
+ */
908
+ use(hold?: number): UseStatus;
840
909
  /** Where the player's feet are. */
841
910
  readonly playerPosition: Vec3$1;
842
911
  /** Grab what the camera looks at (or drop what is held). */
@@ -873,11 +942,12 @@ interface TestRoom {
873
942
  /** Everything the inspector panel shows for the aimed part (state, joints and the tools that undo them), or null. */
874
943
  inspectInfo(): InspectInfo | null;
875
944
  spawned(): SpawnedObject[];
876
- /** Advance one frame (only needed when the host owns the loop). */
945
+ /** Advance one frame, and throw what a system threw in it. The host that owns the loop must call it every frame: the deferred queues lent to the room's budget (sound voices, destruction events) drain only inside a frame. */
877
946
  update(dt: number): void;
878
947
  /** Advance frames until the tool in hand has no phase left (the draw `setTool` plays, a reload, a cycle) or `maxSeconds` pass; plus one frame so the next pull is not inside the phase; returns the seconds waited. */
879
948
  waitUntilReady(maxSeconds?: number): number;
880
- on(type: 'spawn' | 'tool' | 'grab' | 'throw' | 'event' | 'camera', fn: (data: unknown) => void): () => void;
949
+ /** `footfall`: a foot of the player's body touched the ground (`{ foot, gait, time }`), the moment its footstep sounds. */
950
+ on(type: 'spawn' | 'tool' | 'grab' | 'throw' | 'event' | 'camera' | 'footfall', fn: (data: unknown) => void): () => void;
881
951
  /** Tilt the held item by `rad` radians around its own x axis (hold Z in the room). Pouring and spilling follow from the tilt. */
882
952
  tilt(rad: number): void;
883
953
  /** Open or close the tap over the table (default: toggle). Returns whether it is open. */
@@ -924,6 +994,10 @@ interface TestRoom {
924
994
  openAreaAsync(group: string): Promise<SpawnedObject[]>;
925
995
  /** The loading indicator of the room: `begin`, `busy`, `state`, `on` (see `RoomLoading`); modules get it as `ModuleHost.loading`. */
926
996
  readonly loading: RoomLoading;
997
+ /** The player's graphics settings (`options.graphics`): presets, options, the automatic mode, the calibration; null without them. */
998
+ readonly graphics: GraphicsController | null;
999
+ /** The graphics screen (open, close, toggle); null without settings or without the panels. */
1000
+ readonly graphicsScreen: GraphicsScreen | null;
927
1001
  /** `loading.busy`: shows the indicator, waits for it to be painted, runs `work` and takes it down. The way to run a slow, synchronous job. */
928
1002
  busy<T>(label: string, work: (task: BusyTask) => T | Promise<T>, options?: BusyOptions): Promise<T>;
929
1003
  /** The scenarios the panel offers: the built-in `SCENARIOS` in the room locale plus `TestRoomOptions.scenarios`. */
@@ -1009,6 +1083,8 @@ interface TestRoom {
1009
1083
  room: Partial<Record<RoomMetricId, number>>;
1010
1084
  module: Record<string, number | string>;
1011
1085
  };
1086
+ /** What the frame scheduler measured: ms per phase of the last frame, substeps, and per deferred queue the work waiting, run, forced and the most frames anything waited. */
1087
+ frameStats?(): SchedulerStats;
1012
1088
  dispose(): void;
1013
1089
  }
1014
1090
  /** What `TestRoom.loadModule` did. */
@@ -1126,6 +1202,9 @@ interface ScenarioReport {
1126
1202
  }>;
1127
1203
  }
1128
1204
 
1205
+ /** What the trigger answered to `TestRoom.use`: the status of the weapons package's trigger. */
1206
+ type UseStatus = TriggerResult['status'];
1207
+
1129
1208
  /**
1130
1209
  * Create the test room. See `TestRoomOptions`. The room owns a renderer, scene and camera unless you pass them; with your own renderer you call
1131
1210
  * `room.update(dt)` every frame and render yourself.
@@ -1172,4 +1251,4 @@ declare function encodeBenchState(controls: readonly BenchControl[], layers: rea
1172
1251
  /** Reads an encoded state as hostile input: unknown ids, NaN, options not offered and malformed pairs are dropped; numbers are clamped. */
1173
1252
  declare function decodeBenchState(encoded: string, controls: readonly ModuleControl[], layers: readonly ModuleLayer[]): Map<string, ControlValue>;
1174
1253
 
1175
- export { type AnimationInfo, type BenchControl, type BenchHandle, type BenchLayer, type BuildFromSpecOptions, type CameraMode, DEFAULT_HAND_STANCES, DEFAULT_STRIKE_CLIPS, DEFAULT_TRIALS, type HudState, type InspectInfo, type KickLeg, LOADING_CLASS, LOADING_CSS, type LoadingOptions, type LoadingState, type LogEntry, MATERIAL_COLORS, type ModuleReport, type NewEntry, type NewLogEntry, type ProjectileModel, type ProjectileQuery, type PunchHand, type RoomAvatar, type RoomAvatarState, type RoomDoorEvent, type RoomDoorState, type RoomFirstPersonState, type RoomLoading, type RoomMetricId, type RoomPushEvent, type RoomPushState, type RoomReachView, type RoomSeat, type RoomStrings, type ScenarioContext, type ScenarioReport, type SceneryObject, type SceneryTap, type SpawnedObject, type StrikeComboOption, TRIAL_KINDS, type TestRoom, type TestRoomItem, type TestRoomLocale, type TestRoomLog, type TestRoomOptions, type TestRoomScenario, type TestTable, type TestTableContext, type TestTableObject, type TestTableOptions, type TestTablePage, type ThirdPersonOptions, type ThreeNamespace, type TrialKind, type TrialTool, type WritableLog, brickWallSpec, buildFromSpec, createLoading, createLog, createTestRoom, createTestTable, decodeBenchState, encodeBenchState, fitRow, loadingMarkup, locales, nextPaint, resolveStrings, rowCentres, trialView };
1254
+ export { type AnimationInfo, type BenchControl, type BenchHandle, type BenchLayer, type BuildFromSpecOptions, type CameraMode, DEFAULT_HAND_STANCES, DEFAULT_STRIKE_CLIPS, DEFAULT_TRIALS, type HudState, type InspectInfo, type KickLeg, LOADING_CLASS, LOADING_CSS, type LoadingOptions, type LoadingState, type LogEntry, MATERIAL_COLORS, type ModuleReport, type NewEntry, type NewLogEntry, type ProjectileModel, type ProjectileQuery, type PunchHand, type RoomAvatar, type RoomAvatarState, type RoomDoorEvent, type RoomDoorState, type RoomFirstPersonState, type RoomGraphicsOptions, type RoomLoading, type RoomMetricId, type RoomPushEvent, type RoomPushState, type RoomReachView, type RoomSeat, type RoomStrings, type ScenarioContext, type ScenarioReport, type SceneryObject, type SceneryTap, type SpawnedObject, type StrikeComboOption, TRIAL_KINDS, type TestRoom, type TestRoomItem, type TestRoomLocale, type TestRoomLog, type TestRoomOptions, type TestRoomScenario, type TestTable, type TestTableContext, type TestTableObject, type TestTableOptions, type TestTablePage, type ThirdPersonOptions, type ThreeNamespace, type TrialKind, type TrialTool, type UseStatus, type WritableLog, brickWallSpec, buildFromSpec, createLoading, createLog, createTestRoom, createTestTable, decodeBenchState, encodeBenchState, fitRow, loadingMarkup, locales, nextPaint, resolveStrings, rowCentres, trialView };