@adatechnology/game-floorplan-three 0.9.3 → 0.10.1

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.
@@ -1,379 +0,0 @@
1
- import { DeferredQueue, ModuleScenario, TestableModule } from '@adatechnology/game-contracts';
2
- import { LightBudget } from '@adatechnology/game-render-three';
3
-
4
- /** Texts the house shows to the player (interaction prompts, messages, outbuilding labels), by locale. */
5
- type Messages = Record<string, string>;
6
- declare const en: Messages;
7
- declare const ptBR: Messages;
8
- declare const locales: Record<string, Messages>;
9
- type Translate = (key: string, params?: Record<string, string | number>) => string;
10
- /**
11
- * Translator for a locale id ('en', 'pt-BR'), or for a partial table that overrides the English one.
12
- * A missing key falls back to English and then to the key itself.
13
- */
14
- declare function createTranslator(locale?: string | Partial<Messages>): Translate;
15
-
16
- /** A part of the house a hit can damage (door, window, glass, tank...): the game reads `hp`. */
17
- interface Damageable {
18
- type: string;
19
- hp: number;
20
- hpMax: number;
21
- }
22
- /** What `create(THREE, options)` reads. Everything is optional; the three.js namespace is the first argument. */
23
- interface HouseRendererOptions {
24
- /** Document used to draw the procedural textures on a canvas (default: the page's). */
25
- document?: any;
26
- /** `'game'` merges more and draws less than `'high'`. */
27
- quality?: 'high' | 'game';
28
- /** Locale of the texts the house shows (`en`, `pt-BR`) or a table of messages. */
29
- locale?: string | Partial<Messages>;
30
- /** `@adatechnology/game-props3d` (default: the package's own dependency). */
31
- props?: any;
32
- /** `THREE.Reflector` (three/examples/jsm/objects/Reflector.js); without it the mirrors use only the environment map. */
33
- reflector?: any;
34
- /** Cars of the lot and garage: `build(kind, { quality, seed })` -> `{ group, damageable, release() }`. Without it there are no cars. */
35
- fleet?: {
36
- build(kind: string, options: {
37
- quality: string;
38
- seed: number;
39
- }): any;
40
- } | null;
41
- /** Car kinds (fleet ids) per lot style (`budget`, `mid`, `high`); replaces the list of a style. */
42
- carKinds?: Record<string, string[]>;
43
- /** Hit points per damage class (glass, wood, water, metal, masonry, rubber, fuel, gas). */
44
- hp?: Record<string, number>;
45
- /** Textures from the app that replace the procedural ones. */
46
- textures?: Record<string, any>;
47
- atlas?: Record<string, any>;
48
- /** Materials the game swaps (a material or a function of the default one). */
49
- materials?: Record<string, any>;
50
- /** The world of `@adatechnology/game-destruction`; the house registers itself in it on first need. */
51
- destruction?: any;
52
- /** `createDestructionRenderer(THREE, { scene, world })` of `@adatechnology/game-destruction-three`: draws fracture, collapse, fragments, spalls and the rebar cage on the house's meshes. */
53
- destructionRenderer?: any;
54
- /** The lights of effects (a blast, a fire, a flare) light the room where their point is, and the rooms either side of an open door or window next to it (see `effectLights` and `lighting`). Default true; false keeps them off every house surface. */
55
- effectLightsIndoors?: boolean;
56
- /** Milliseconds per frame the house may spend repainting damaged walls (chipped plaster, holes); events of one frame are painted together. Default `Infinity` (all of them at the frame's flush); a game loop sets a few ms. */
57
- breachPaintBudgetMs?: number;
58
- /** The interactables kit, injected: `{ GameInteractables, GameInteractablesHousehold, GameInteractablesThree, adapter (optional), adapterOptions, locale, region, items, effects, effectSink, camera, onEvent, onSeat }`. */
59
- interactives?: any;
60
- /** The vegetation packages, injected: `{ GameVegetation, GameVegetationSpecies }`. */
61
- vegetation?: any;
62
- /** Maps an id of the plan to the key its seeded random draws use, to reproduce a scene drawn with other ids (golden tests). */
63
- seedKey?: (id: string) => string | null | undefined;
64
- /** Distance (m) beyond which the interior (`interior`) and the house (`hide`) are drawn no more, or `false` to switch distance LOD off. */
65
- lod?: false | {
66
- interior?: number;
67
- hide?: number;
68
- };
69
- drawCallBudget?: number;
70
- onChange?: (change: {
71
- shadow: boolean;
72
- }) => void;
73
- onCollider?: (collider: any) => void;
74
- onDamage?: (part: any, point: {
75
- x: number;
76
- y: number;
77
- z: number;
78
- } | null, type: string) => void;
79
- onWreck?: (event: any, house: any) => void;
80
- onInteract?: (target: any, action: any) => boolean | void;
81
- onLight?: (light: any) => void;
82
- onMessage?: (text: string) => void;
83
- }
84
- interface BuildOptions {
85
- /** `'high'` (default) or `'game'`. */
86
- quality?: 'high' | 'game';
87
- /** Night: lit windows and room lamps. */
88
- night?: boolean;
89
- /** Roof cut off and floors above hidden, to look into the plan. */
90
- cut?: boolean;
91
- /** A state returned by `newState()`: pass the same one to rebuild without closing every door. */
92
- state?: any;
93
- /** `false`: the app already has ground, street and lawn. */
94
- terrain?: boolean;
95
- /** `true`: no lot wall, fence or gates (the game has its own). */
96
- noPerimeter?: boolean;
97
- /** `'meshes'`: one mesh per structural piece instead of one per group and material. */
98
- pieces?: 'meshes';
99
- drawCallBudget?: number;
100
- building?: {
101
- floors?: number;
102
- floor?: number;
103
- unit?: number;
104
- showBuilding?: boolean;
105
- };
106
- }
107
- /** The house the renderer built. The three.js groups are ready to add to a scene. */
108
- interface House {
109
- version: string;
110
- r: any;
111
- name: string;
112
- quality: string;
113
- group: any;
114
- house: any;
115
- groups: Record<string, any>;
116
- floors: any[];
117
- ceilings: any[];
118
- roof: any;
119
- lot: any;
120
- ground: any;
121
- building: any;
122
- /** Public colliders: walls, doors, lot walls and gates (aabb) and furniture (obb). */
123
- colliders: any[];
124
- /** Parts that move or take damage: id -> `{ group, type, opens(t), damageable }`. */
125
- parts: Record<string, any>;
126
- doors: any[];
127
- stairs: any[];
128
- labels: any[];
129
- /** The real lights the builders asked for (at night) in `list`, and the same grouped by room id in `byRoom`. */
130
- lights: {
131
- list: any[];
132
- byRoom: Record<string, any[]>;
133
- };
134
- stats: any;
135
- structure: any;
136
- destruction: any;
137
- interactives: any;
138
- update(dt: number, time?: number, focus?: {
139
- x: number;
140
- y: number;
141
- z: number;
142
- }): void;
143
- show(options: {
144
- floor?: number;
145
- cut?: boolean;
146
- lot?: boolean;
147
- }): void;
148
- target(eye: any, options?: any): any;
149
- interact(target: any): any;
150
- toggleDoor(id: string): any;
151
- toggleLight(room?: string): any;
152
- lightOn(room: string): boolean;
153
- collide(x: number, z: number, floor: number, options?: any): any;
154
- roomAt(floor: number, x: number, z: number): any;
155
- setLod(level: number): void;
156
- readonly lod: number;
157
- damage(id: string, point?: any, type?: string, amount?: number): void;
158
- colliderDamage(collider: any, point?: any, type?: string, amount?: number): void;
159
- /** The part (door, window, furniture piece...) an object belongs to, found by going up its parents. */
160
- partOf(object: any): any | null;
161
- /** The first part whose box holds the point (with a tolerance, default 5 cm). */
162
- partAt(point: {
163
- x: number;
164
- y: number;
165
- z: number;
166
- }, tolerance?: number): any | null;
167
- dispose(): void;
168
- [extra: string]: any;
169
- }
170
- /** What `HouseRenderer.lighting` reads. */
171
- interface LightingOptions {
172
- scene?: any;
173
- /** Room lights, 1 to 12 (6). */
174
- n?: number;
175
- /** How many of them cast shadows (2). */
176
- shadows?: number;
177
- shadowSize?: number;
178
- /** Outside lamps that may take a light (2). */
179
- external?: number;
180
- /**
181
- * The host's LightBudget: the house leases `n` point slots (`shadows` with shadow) for good instead of creating lights, and the room masks are written at the slot of each light (what the shader
182
- * indexes by). Without it the lights are created here, which changes every lit material's program key (deprecated, removed in the next major).
183
- */
184
- budget?: LightBudget;
185
- }
186
- /** The renderer `create(THREE, options)` returns. */
187
- interface HouseRenderer {
188
- version: string;
189
- build(result: any, options?: BuildOptions): House;
190
- newState(): any;
191
- types: Record<string, any>;
192
- mv: any;
193
- applyPart(group: any, t: number): void;
194
- materials: Record<string, any>;
195
- roomLightMask(material: any): void;
196
- lighting(options?: LightingOptions): any;
197
- /**
198
- * Lets the lights of effects (a blast, a fire, a flare) that hold slots of `budget` light the room their point is in, and the rooms either side of an open door or window next to it.
199
- * Call `update(houses)` every frame after the budget's `present`. Works without `lighting()`. Off for every house with `effectLightsIndoors: false`.
200
- */
201
- effectLights?(options: {
202
- budget: any;
203
- }): {
204
- update(houses: unknown): void;
205
- };
206
- setNight(night: boolean): void;
207
- /** The painting of the damaged walls of every house as a `DeferredQueue` for a shared frame budget; `budget.register` attaches it and `flush()` stops painting from `onFrame`. */
208
- deferredQueue?(): DeferredQueue;
209
- cars: {
210
- model(kind: string, seed?: number): any;
211
- group(...args: any[]): any;
212
- info(kind: string, seed?: number): any;
213
- };
214
- dispose(): void;
215
- }
216
-
217
- type AreaText = {
218
- group: string;
219
- name: string;
220
- controls: Record<'package' | 'template' | 'state' | 'seed' | 'quality' | 'lod' | 'houses' | 'budget' | 'floor_view' | 'hit', string>;
221
- hints: Record<'template' | 'houses' | 'budget' | 'lod' | 'floor_view' | 'hit', string>;
222
- actions: Record<'build' | 'enter' | 'up' | 'down' | 'door' | 'strike' | 'reset' | 'clear', string>;
223
- options: {
224
- quality: Record<string, string>;
225
- lod: Record<string, string>;
226
- floor_view: Record<string, string>;
227
- hit: Record<string, string>;
228
- state: Record<string, string>;
229
- };
230
- layers: Record<'roof' | 'lot' | 'night' | 'room_lights', string>;
231
- metrics: Record<'houses' | 'parts' | 'standing' | 'broken' | 'holes' | 'draw_calls' | 'triangles' | 'lod' | 'floor' | 'doors_open' | 'target' | 'planned', string>;
232
- sheet: {
233
- kicker: string;
234
- title: string;
235
- template: string;
236
- seed: string;
237
- state: string;
238
- floors: string;
239
- size: string;
240
- parts: string;
241
- look: string;
242
- none: string;
243
- no_engine: string;
244
- };
245
- specimens: Record<string, string>;
246
- scenarios: Record<string, string>;
247
- steps: Record<'built' | 'no_engine' | 'entered' | 'floor' | 'no_floor' | 'door' | 'no_door' | 'strike' | 'no_aim' | 'cleared' | 'reset' | 'one_pillar_broke' | 'slabs_whole' | 'no_slab_fell' | 'two_slab_fell' | 'two_roof_fell' | 'partition_broke' | 'slab_stayed' | 'glass_hole' | 'glass_broke' | 'walls_whole' | 'tank_hole' | 'tank_leaked' | 'gas_exploded' | 'gas_damaged', string>;
248
- };
249
-
250
- /** What the room hands a scenario (`ScenarioContext` of game-test-room), narrowed to what these use. */
251
- interface AreaContext {
252
- room: any;
253
- step(seconds: number): void;
254
- expect(condition: boolean, label: string, data?: Record<string, unknown>): void;
255
- }
256
- type Vec3 = readonly [number, number, number];
257
- /** Where the team's page lays its specimens (the arena has 14 m of half width). */
258
- declare const SPECIMEN_AT: Vec3;
259
- /**
260
- * The six structural scenarios of the team's house area (sala-de-testes/area-casas, L3833-3868), same ids and same checks, on the specimens the area builds: destroy a pillar, two pillars, a partition,
261
- * shoot a window, puncture the water tank, set the gas bottle on fire. The hits are the team's (3 MJ blunt on a pillar, 600 J 9 mm on the glass and the tank, 900 C fire on the bottle). A scenario
262
- * passes when every check holds; the names of the checks are in `text.steps`.
263
- */
264
- declare function createHouseScenarios(text: AreaText, at?: Vec3): Array<ModuleScenario<AreaContext>>;
265
-
266
- /** The part of the floorplan engine (`engine` of `@adatechnology/game-floorplan`, with the content packs the page registered) the test area reads. */
267
- interface FloorplanEngineLike {
268
- generate(template: string, options?: {
269
- seed?: number;
270
- state?: string;
271
- floors?: number;
272
- }): any;
273
- listTemplates(): Array<{
274
- id: string;
275
- name?: string;
276
- floors?: number;
277
- floorRange?: number[] | null;
278
- }>;
279
- listStates(): string[];
280
- translate?(namespace: any, key: string, locale?: string, vars?: Record<string, string | number>): string;
281
- }
282
- /** A pack of templates the bench lists together (residential, commercial, rural, post-apocalyptic). Ids the engine does not know are left out. */
283
- interface TemplateGroup {
284
- id: string;
285
- /** Name by locale (`en`, `pt-BR`); the id when absent. */
286
- name?: Record<string, string>;
287
- templates: readonly string[];
288
- }
289
- /** A small house the area lays out for the structural scenarios: the structure spec of a template, drawn as boxes named by part (the team's HouseArea items). */
290
- interface SpecimenDef {
291
- /** Item id (`house_casa_portico`): the scenarios and the golden name them. */
292
- id: string;
293
- template: string;
294
- seed?: number;
295
- state?: string;
296
- /** The bearing walls only close: a frame of pillars and beams carries the building. */
297
- portico?: boolean;
298
- /**
299
- * How the structure is sized (`toDestructibleSpec`): `safety` is the share of its capacity a pillar uses at rest, `redundancy` the most it uses after one other pillar is lost.
300
- * A slab on four pillars is held by the sum of the four: with `safety` 0.72 and `redundancy` 0.97 it holds one loss (0.96) and falls with two.
301
- */
302
- sizing?: {
303
- safety?: number;
304
- redundancy?: number;
305
- safetyOthers?: number;
306
- };
307
- /** Name by locale; the text of the area when absent. */
308
- name?: Record<string, string>;
309
- }
310
- interface FloorplanTestOptions {
311
- locale?: string;
312
- /** The engine with the packs registered. Without it the module has no houses to build. */
313
- engine?: FloorplanEngineLike;
314
- /** The packs the bench lists, in order. Default: every template of the engine in one group. */
315
- groups?: readonly TemplateGroup[];
316
- /** The states the bench offers (`normal`, `fortified`, `abandoned`). Default: the engine's. */
317
- states?: readonly string[];
318
- /** The room's destruction world and renderer (`room.world`, `room.renderer`): the houses built here register in them, so every shot, blast and fire of the room reaches the walls. */
319
- world?: any;
320
- renderer?: any;
321
- /** Passed to the house renderer: `fleet`, `reflector`, `interactives`, `vegetation`, `props`, `textures`... */
322
- house?: Partial<HouseRendererOptions>;
323
- /** Template and seed the bench starts with. */
324
- template?: string;
325
- seed?: number;
326
- /** Specimens of the structural scenarios; default the five of the team's house area, those whose template the engine has. */
327
- specimens?: readonly SpecimenDef[];
328
- /** Half size of the room's arena (`createTestRoom({ arenaSize })`), 14 by default: where the houses are laid. */
329
- arenaSize?: number;
330
- /** Where the specimens stand for the scenarios (the team's page: `[-5, 0, -11]`). */
331
- specimenAt?: readonly [number, number, number];
332
- }
333
-
334
- declare const FLOORPLAN_AREA_ID = "floorplan_area";
335
- type Placed = {
336
- house: any;
337
- plan: any;
338
- seed: number;
339
- width: number;
340
- depth: number;
341
- };
342
- /**
343
- * The houses test area as a `TestableModule`: any typology of the content packs the page registered (residential, commercial, rural, post-apocalyptic) built with game-floorplan-three from a seed, laid
344
- * in the room, with the player able to walk in (walls and closed doors stop the walk), use the doors (E), go up and down the floors, see the level of detail (manual, by distance, or shared among a row
345
- * of houses by a draw-call budget), and hit the walls with what the room throws (its tools, or the bench's hit): the houses register in the room's destruction world, so shots, blows, blasts and fire
346
- * reach the structure and the room's renderer draws the fracture, the brick courses and the collapse. Dust and sparks are the room's own effects: this module draws no particles.
347
- * Everything that is a pack of content comes in by option: this package knows no game.
348
- */
349
- declare function createFloorplanTestModule(options?: FloorplanTestOptions): TestableModule<AreaContext> & {
350
- readonly houses: readonly Placed[];
351
- build(): void;
352
- clear(): void;
353
- groups(): readonly TemplateGroup[];
354
- };
355
-
356
- /**
357
- * The five items of the team's house area (sala-de-testes/area-casas): a frame house, a whole house, a wood-frame house, a log cabin and a tent. The team's frame house is its single-storey house A; here it is the
358
- * two-storey townhouse, because the ceiling slab of the single-storey plan keeps standing on its bearing partitions when two pillars go (see evidence, T2.6). The frame house is a reinforced concrete frame (T10 §12): the slabs
359
- * are cut into panels on real beams, the pillars are sized (`sizing`) to carry the load of the ones lost, and the beams to carry the span the lost pillar leaves: one pillar lost and the slab stays,
360
- * the two ends of a side lost and that side comes down (owner, 2026-10-24: "4 pilares e a sustentação é a soma dos 4"; 2026-10-25: the real structure of the houses).
361
- */
362
- declare const DEFAULT_SPECIMENS: readonly SpecimenDef[];
363
- /** What the area keeps of a built specimen: the structure spec the house draws (what the destruction world is given) and the plan it came from. */
364
- interface SpecimenSpec {
365
- readonly spec: any;
366
- readonly plan: any;
367
- }
368
- /**
369
- * The structure spec of a specimen: the engine draws the plan, the house renderer draws the house, and the house describes its structure (`house.structure.spec`) with what the water tank holds and
370
- * what makes the gas bottle explode. The spec is cached per three.js namespace and specimen; each call hands out a copy.
371
- */
372
- declare function specimenSpec(THREE: any, engine: FloorplanEngineLike, def: SpecimenDef, houseOptions?: Partial<HouseRendererOptions>): SpecimenSpec;
373
- /**
374
- * One box (or cylinder, sphere) per part, named by the part id and coloured by its material, in the space of the house (the origin at the corner of the plan): what the team's house area draws, so the
375
- * room binds each mesh to the part of the same name. The anchored terrain slab is left out (the room has a floor).
376
- */
377
- declare function buildSpecimenMeshes(THREE: any, spec: any): any;
378
-
379
- export { type AreaContext as A, type BuildOptions as B, DEFAULT_SPECIMENS as D, FLOORPLAN_AREA_ID as F, type HouseRendererOptions as H, type LightingOptions as L, type Messages as M, SPECIMEN_AT as S, type TemplateGroup as T, type HouseRenderer as a, type Damageable as b, type FloorplanEngineLike as c, type FloorplanTestOptions as d, type House as e, type SpecimenDef as f, type Translate as g, buildSpecimenMeshes as h, createFloorplanTestModule as i, createHouseScenarios as j, createTranslator as k, en as l, locales as m, ptBR as p, specimenSpec as s };