@adatechnology/game-test-room 0.20.0 → 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).
@@ -452,6 +471,11 @@ interface RoomAvatar {
452
471
  leg?: 'left' | 'right';
453
472
  hand?: 'left' | 'right';
454
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;
455
479
  /**
456
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
457
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.
@@ -677,6 +701,12 @@ interface TestRoomOptions {
677
701
  world?: DestructionWorld;
678
702
  worldOptions?: DestructionOptions;
679
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;
680
710
  /** What the floor is made of until an area lays its own (`TestableModule.ground`). Default a concrete slab. */
681
711
  ground?: GroundLayout;
682
712
  /** Limits of the floor's marks, thrown pieces and redraws per frame. */
@@ -754,6 +784,11 @@ interface TestRoomOptions {
754
784
  handStances?: Readonly<Record<string, string>>;
755
785
  /** The over-the-shoulder view of the `third` mode: distance, shoulder, height, wall probes. Defaults are the team game's. */
756
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;
757
792
  /** Room counters the bench panel shows and `TestRoom.metrics()` returns (default all); `false` for none. */
758
793
  metrics?: readonly RoomMetricId[] | false;
759
794
  /**
@@ -762,12 +797,21 @@ interface TestRoomOptions {
762
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,
763
798
  * a slab) stay as part of the map, with collision.
764
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;
765
807
  debris?: {
766
808
  fragmentLife?: number | FragmentLifeRule;
767
809
  maxFragments?: number;
768
810
  particles?: Readonly<Record<string, Partial<SpriteKindDef> | null>>;
769
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. */
770
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;
771
815
  };
772
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. */
773
817
  blast?: BlastOptions;
@@ -794,7 +838,9 @@ interface TestRoomOptions {
794
838
  /** Counters the room measures itself. `fps` and `frame_ms` use the real frame time, so slow motion does not change them. */
795
839
  type RoomMetricId = 'fps' | 'frame_ms' | 'draw_calls' | 'triangles' | 'objects' | 'fragments' | 'particles' | 'decals'
796
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. */
797
- | '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';
798
844
  /** A module control as the room holds it: the declaration with the module's patches applied, and its value (none for an action). */
799
845
  type BenchControl = ModuleControl & {
800
846
  readonly disabled: boolean;
@@ -831,6 +877,10 @@ interface TestRoom {
831
877
  readonly renderer: DestructionRenderer;
832
878
  readonly scene: THREE_NS.Scene;
833
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;
834
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. */
835
885
  readonly testTable: TestTable;
836
886
  /** Spawn a catalogue item at a world position (default in front of the player). */
@@ -850,8 +900,12 @@ interface TestRoom {
850
900
  readonly tool: WeaponState;
851
901
  /** Play an item use on the held item (`drink`, `pour`...). Returns false when nothing is held or the use does not apply. */
852
902
  useItem(useId: string): boolean;
853
- /** 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. */
854
- 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;
855
909
  /** Where the player's feet are. */
856
910
  readonly playerPosition: Vec3$1;
857
911
  /** Grab what the camera looks at (or drop what is held). */
@@ -888,11 +942,12 @@ interface TestRoom {
888
942
  /** Everything the inspector panel shows for the aimed part (state, joints and the tools that undo them), or null. */
889
943
  inspectInfo(): InspectInfo | null;
890
944
  spawned(): SpawnedObject[];
891
- /** 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. */
892
946
  update(dt: number): void;
893
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. */
894
948
  waitUntilReady(maxSeconds?: number): number;
895
- 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;
896
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. */
897
952
  tilt(rad: number): void;
898
953
  /** Open or close the tap over the table (default: toggle). Returns whether it is open. */
@@ -939,6 +994,10 @@ interface TestRoom {
939
994
  openAreaAsync(group: string): Promise<SpawnedObject[]>;
940
995
  /** The loading indicator of the room: `begin`, `busy`, `state`, `on` (see `RoomLoading`); modules get it as `ModuleHost.loading`. */
941
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;
942
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. */
943
1002
  busy<T>(label: string, work: (task: BusyTask) => T | Promise<T>, options?: BusyOptions): Promise<T>;
944
1003
  /** The scenarios the panel offers: the built-in `SCENARIOS` in the room locale plus `TestRoomOptions.scenarios`. */
@@ -1024,6 +1083,8 @@ interface TestRoom {
1024
1083
  room: Partial<Record<RoomMetricId, number>>;
1025
1084
  module: Record<string, number | string>;
1026
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;
1027
1088
  dispose(): void;
1028
1089
  }
1029
1090
  /** What `TestRoom.loadModule` did. */
@@ -1141,6 +1202,9 @@ interface ScenarioReport {
1141
1202
  }>;
1142
1203
  }
1143
1204
 
1205
+ /** What the trigger answered to `TestRoom.use`: the status of the weapons package's trigger. */
1206
+ type UseStatus = TriggerResult['status'];
1207
+
1144
1208
  /**
1145
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
1146
1210
  * `room.update(dt)` every frame and render yourself.
@@ -1187,4 +1251,4 @@ declare function encodeBenchState(controls: readonly BenchControl[], layers: rea
1187
1251
  /** Reads an encoded state as hostile input: unknown ids, NaN, options not offered and malformed pairs are dropped; numbers are clamped. */
1188
1252
  declare function decodeBenchState(encoded: string, controls: readonly ModuleControl[], layers: readonly ModuleLayer[]): Map<string, ControlValue>;
1189
1253
 
1190
- 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 };