@adatechnology/game-floorplan 0.2.2 → 0.3.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.
- package/README.md +6 -0
- package/dist/index.d.ts +655 -201
- package/dist/index.global.js +366 -207
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +272 -205
- package/dist/index.js.map +1 -1
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DeepPartial } from '@adatechnology/game-contracts';
|
|
2
|
+
|
|
1
3
|
/** Seeded random helpers. Same seed and key always produce the same stream. */
|
|
2
4
|
type Rng = () => number;
|
|
3
5
|
declare function mulberry32(a: number): Rng;
|
|
@@ -5,11 +7,66 @@ declare function hashString(input: string | number): number;
|
|
|
5
7
|
/** Independent stream for a `(seed, key)` pair. */
|
|
6
8
|
declare const createRng: (seed: string | number, key: string) => Rng;
|
|
7
9
|
|
|
10
|
+
/** Tools handed to a style recipe. `jit` and `rng` draw from the style's seeded stream: draw order is part of the contract. */
|
|
11
|
+
interface PaletteDraw {
|
|
12
|
+
rng: Rng;
|
|
13
|
+
base: [string, number, number, number];
|
|
14
|
+
H0: number;
|
|
15
|
+
H1: number;
|
|
16
|
+
H2: number;
|
|
17
|
+
jit(v: number, a: number): number;
|
|
18
|
+
hsl(h: number, s: number, l: number): Hsl;
|
|
19
|
+
}
|
|
20
|
+
interface PaletteEarly {
|
|
21
|
+
/** Accent mode: true saturates walls, false puts accents on objects. */
|
|
22
|
+
wallMode: boolean;
|
|
23
|
+
/** Maximum wall saturation. */
|
|
24
|
+
sMax: number;
|
|
25
|
+
/** Facade, wall, gate, roof, ceiling... in insertion order. */
|
|
26
|
+
roles: Record<string, Hsl>;
|
|
27
|
+
/** General floor `[h, s, l]` for room types that do not define their own. */
|
|
28
|
+
generalFloor: [number, number, number];
|
|
29
|
+
}
|
|
30
|
+
interface PaletteStyleDef {
|
|
31
|
+
/** Legacy stream suffix; defaults to the style id. */
|
|
32
|
+
seedKey?: string;
|
|
33
|
+
/** Facade colour table `[labelKey, h, s, l]`. */
|
|
34
|
+
facadeColors: [string, number, number, number][];
|
|
35
|
+
/** Draws up to the room colours (before the room loop). */
|
|
36
|
+
early(d: PaletteDraw): PaletteEarly;
|
|
37
|
+
/** Draws the object roles (wood, fabrics, metal, ground colours) after the room loop. */
|
|
38
|
+
late(d: PaletteDraw, e: PaletteEarly): Record<string, Hsl>;
|
|
39
|
+
}
|
|
40
|
+
interface PaletteContext extends PaletteDraw {
|
|
41
|
+
style: string;
|
|
42
|
+
sMax: number;
|
|
43
|
+
wallMode: boolean;
|
|
44
|
+
generalFloor: [number, number, number];
|
|
45
|
+
}
|
|
46
|
+
interface PaletteOptions {
|
|
47
|
+
seed?: number | string;
|
|
48
|
+
style?: string;
|
|
49
|
+
state?: string;
|
|
50
|
+
}
|
|
51
|
+
type Palette = {
|
|
52
|
+
meta: {
|
|
53
|
+
seed: number | string;
|
|
54
|
+
style: string;
|
|
55
|
+
state: string;
|
|
56
|
+
scheme: string;
|
|
57
|
+
base: string;
|
|
58
|
+
accentMode: 'wall' | 'object';
|
|
59
|
+
};
|
|
60
|
+
} & Record<string, number | object>;
|
|
61
|
+
/** Seeded colour-harmony palette: a facade base colour, a harmony scheme, role colours and contrast rules. */
|
|
62
|
+
declare function palette(o?: PaletteOptions): Palette;
|
|
63
|
+
|
|
8
64
|
/** Axis-aligned rectangle `[u0, v0, u1, v1]`. `u` runs along the facade, `v` from the street to the back. */
|
|
9
65
|
type Rect = [number, number, number, number];
|
|
10
66
|
type Vec2 = [number, number];
|
|
11
67
|
type Weights = Record<string, number>;
|
|
12
|
-
|
|
68
|
+
/** An open value from a template or a plugin: narrow it before use. */
|
|
69
|
+
type Json = unknown;
|
|
13
70
|
type MeshFront = '+z' | '-z' | '+x' | '-x';
|
|
14
71
|
type Mount = 'ceiling' | 'wall' | 'window' | 'support' | 'floor' | 'roof' | 'ground' | 'wall_top' | (string & {});
|
|
15
72
|
/** How an item is coloured: a palette role, a fixed colour, or a seeded pick from a list. */
|
|
@@ -78,6 +135,10 @@ interface SlotDef {
|
|
|
78
135
|
facing?: FacingRule;
|
|
79
136
|
target?: string;
|
|
80
137
|
slide?: number;
|
|
138
|
+
/** Parent slot id of an `on`/`inside` slot (copied from `on` when the room's slots are expanded). */
|
|
139
|
+
parent?: string;
|
|
140
|
+
/** The slot may sit over door and stair swing zones. */
|
|
141
|
+
floorFree?: boolean;
|
|
81
142
|
[extra: string]: Json;
|
|
82
143
|
}
|
|
83
144
|
type SlotLibrary = SlotDef[] | ((room: {
|
|
@@ -217,7 +278,7 @@ interface TemplateDef {
|
|
|
217
278
|
veranda?: boolean;
|
|
218
279
|
steelDoor?: boolean;
|
|
219
280
|
};
|
|
220
|
-
facadeExtra?: (facade:
|
|
281
|
+
facadeExtra?: (facade: Facade, rng: Rng, w: number, d: number, o: FloorplanOptions) => void;
|
|
221
282
|
building?: (w: number, d: number, o: FloorplanOptions) => Json;
|
|
222
283
|
singleFloor?: boolean;
|
|
223
284
|
/** Place tag of the building for finds (`house`, `pharmacy`...). */
|
|
@@ -241,14 +302,14 @@ interface TemplateDef {
|
|
|
241
302
|
reservations?: (plan: Plan) => void;
|
|
242
303
|
/** Own paths from the doors that sit away from the building edge (tents); replaces the generated ones. */
|
|
243
304
|
paths?: (plan: Plan, context: {
|
|
244
|
-
gates:
|
|
305
|
+
gates: PlanGate[];
|
|
245
306
|
setback: number;
|
|
246
307
|
marginLeft: number;
|
|
247
308
|
marginRight: number;
|
|
248
309
|
backyard: number;
|
|
249
310
|
w: number;
|
|
250
311
|
d: number;
|
|
251
|
-
}) =>
|
|
312
|
+
}) => LotPath[];
|
|
252
313
|
/** Sides built against a neighbour (`left` / `right`): exempt from the side setback. */
|
|
253
314
|
partyWalls?: ('left' | 'right')[];
|
|
254
315
|
options?: Json;
|
|
@@ -294,13 +355,13 @@ interface CarClearance {
|
|
|
294
355
|
interface ResultExtensionContext {
|
|
295
356
|
plan: Plan;
|
|
296
357
|
/** The result built so far: the plan, the items, the state items and the extensions that ran before. */
|
|
297
|
-
result:
|
|
358
|
+
result: FloorplanResult;
|
|
298
359
|
seed: number | string;
|
|
299
360
|
/** Seeded stream of the extension: `createRng(seed, seedKey ?? name)`. */
|
|
300
361
|
rng: Rng;
|
|
301
362
|
options: FloorplanOptions;
|
|
302
363
|
}
|
|
303
|
-
type ResultExtensionRun = (context: ResultExtensionContext) =>
|
|
364
|
+
type ResultExtensionRun = (context: ResultExtensionContext) => unknown;
|
|
304
365
|
interface ResultExtensionOptions {
|
|
305
366
|
/** Extensions that must run first. */
|
|
306
367
|
after?: string[];
|
|
@@ -384,6 +445,156 @@ interface Room {
|
|
|
384
445
|
seedKey?: string;
|
|
385
446
|
ground?: string;
|
|
386
447
|
}
|
|
448
|
+
/** Axis a wall or opening runs along: `u` is across the lot (x), `v` is front to back (z). */
|
|
449
|
+
type PlanAxis = 'u' | 'v';
|
|
450
|
+
/** A door placed on a wall of one storey (`Plan.doors`). */
|
|
451
|
+
interface PlanDoor {
|
|
452
|
+
id: string;
|
|
453
|
+
floor: number;
|
|
454
|
+
u: number;
|
|
455
|
+
v: number;
|
|
456
|
+
axis: PlanAxis;
|
|
457
|
+
/** Position of the wall line on the other axis. */
|
|
458
|
+
pos: number;
|
|
459
|
+
/** Centre of the door along the wall. */
|
|
460
|
+
at: number;
|
|
461
|
+
width: number;
|
|
462
|
+
/** Room on each side; `b` is `outside` on an exterior door. */
|
|
463
|
+
a: string;
|
|
464
|
+
b: string;
|
|
465
|
+
opensTo: string;
|
|
466
|
+
exterior: boolean;
|
|
467
|
+
side: string | null;
|
|
468
|
+
leaves: number;
|
|
469
|
+
model: string;
|
|
470
|
+
type: string;
|
|
471
|
+
steps: number;
|
|
472
|
+
hinge: string;
|
|
473
|
+
/** Swing areas on both sides that furniture keeps clear of. */
|
|
474
|
+
zones: Rect[];
|
|
475
|
+
/** Left open (set by a house state). */
|
|
476
|
+
open?: boolean;
|
|
477
|
+
/** Blocked shut, e.g. barricaded (set by a house state). */
|
|
478
|
+
blocked?: boolean;
|
|
479
|
+
}
|
|
480
|
+
/** One straight piece of wall or railing of one storey (`Plan.walls`). */
|
|
481
|
+
interface PlanWall {
|
|
482
|
+
floor: number;
|
|
483
|
+
axis: PlanAxis;
|
|
484
|
+
u0: number;
|
|
485
|
+
v0: number;
|
|
486
|
+
u1: number;
|
|
487
|
+
v1: number;
|
|
488
|
+
thickness: number;
|
|
489
|
+
/** Room ids on each face (`outside` for the street side). */
|
|
490
|
+
sides: [string, string];
|
|
491
|
+
exterior: boolean;
|
|
492
|
+
type: 'railing' | 'wall';
|
|
493
|
+
/** Height in metres (the storey ceiling for a full wall). */
|
|
494
|
+
h: number;
|
|
495
|
+
}
|
|
496
|
+
/** A window on an exterior wall (`Plan.windows`). */
|
|
497
|
+
interface PlanWindow {
|
|
498
|
+
id: string;
|
|
499
|
+
floor: number;
|
|
500
|
+
u: number;
|
|
501
|
+
v: number;
|
|
502
|
+
axis: PlanAxis;
|
|
503
|
+
pos: number;
|
|
504
|
+
at: number;
|
|
505
|
+
width: number;
|
|
506
|
+
/** Sill and head heights above the storey floor. */
|
|
507
|
+
y0: number;
|
|
508
|
+
y1: number;
|
|
509
|
+
room: string;
|
|
510
|
+
side: string;
|
|
511
|
+
/** Boarded up (set by a house state). */
|
|
512
|
+
boards?: boolean;
|
|
513
|
+
}
|
|
514
|
+
/** A gate in the lot boundary (`Plan.gates`). */
|
|
515
|
+
interface PlanGate {
|
|
516
|
+
id: string;
|
|
517
|
+
type: string;
|
|
518
|
+
model: string;
|
|
519
|
+
u: number;
|
|
520
|
+
v: number;
|
|
521
|
+
axis: PlanAxis;
|
|
522
|
+
width: number;
|
|
523
|
+
height: number;
|
|
524
|
+
side: string;
|
|
525
|
+
/** What the gate leads to (`door`, `inner_garage`...), or null. */
|
|
526
|
+
to: string | null;
|
|
527
|
+
material: string;
|
|
528
|
+
zones: Rect[];
|
|
529
|
+
/** Starts open (set by a template or a later pass). */
|
|
530
|
+
open?: boolean;
|
|
531
|
+
}
|
|
532
|
+
/** A door or a lot gate: anything a path or the furniture fill has to keep clear. */
|
|
533
|
+
type PlanOpening = PlanDoor | PlanGate;
|
|
534
|
+
/** A walkway or driveway across the lot (`Plan.paths`). */
|
|
535
|
+
interface LotPath {
|
|
536
|
+
id: string;
|
|
537
|
+
type: 'pedestrian' | 'vehicle' | string;
|
|
538
|
+
/** Gate the path starts at, or null when it starts at no gate. */
|
|
539
|
+
from: string | null;
|
|
540
|
+
to: string;
|
|
541
|
+
width: number;
|
|
542
|
+
rects: Rect[];
|
|
543
|
+
points: Vec2[];
|
|
544
|
+
}
|
|
545
|
+
/** How one side of the lot is closed (wall, fence or railing). */
|
|
546
|
+
interface LotBoundary {
|
|
547
|
+
type: string;
|
|
548
|
+
material: string;
|
|
549
|
+
height: number;
|
|
550
|
+
top: string;
|
|
551
|
+
totalHeight: number;
|
|
552
|
+
thickness: number;
|
|
553
|
+
}
|
|
554
|
+
/** One straight piece of the lot boundary. */
|
|
555
|
+
interface LotPerimeterPiece extends LotBoundary {
|
|
556
|
+
id: string;
|
|
557
|
+
side: string;
|
|
558
|
+
u0: number;
|
|
559
|
+
v0: number;
|
|
560
|
+
u1: number;
|
|
561
|
+
v1: number;
|
|
562
|
+
}
|
|
563
|
+
/** The lot around the building (`Plan.lot`). */
|
|
564
|
+
interface Lot {
|
|
565
|
+
rect: Rect;
|
|
566
|
+
setback: number;
|
|
567
|
+
sideYard: {
|
|
568
|
+
left: number;
|
|
569
|
+
right: number;
|
|
570
|
+
};
|
|
571
|
+
backyard: number;
|
|
572
|
+
style: string;
|
|
573
|
+
zones: Room[];
|
|
574
|
+
perimeter: LotPerimeterPiece[];
|
|
575
|
+
gates: PlanGate[];
|
|
576
|
+
paths: LotPath[];
|
|
577
|
+
pool: boolean;
|
|
578
|
+
}
|
|
579
|
+
/** The known fields of a facade. */
|
|
580
|
+
interface FacadeFields {
|
|
581
|
+
style: string;
|
|
582
|
+
color: {
|
|
583
|
+
name: string;
|
|
584
|
+
hex: string;
|
|
585
|
+
};
|
|
586
|
+
finish: string;
|
|
587
|
+
grilles: boolean;
|
|
588
|
+
roof: string;
|
|
589
|
+
balcony: boolean;
|
|
590
|
+
veranda: boolean;
|
|
591
|
+
steelDoor: boolean;
|
|
592
|
+
floors: number;
|
|
593
|
+
}
|
|
594
|
+
/** The look of the building from the street (`Plan.facade`); templates may add fields through `facadeExtra`. */
|
|
595
|
+
interface Facade extends FacadeFields {
|
|
596
|
+
[extra: string]: unknown;
|
|
597
|
+
}
|
|
387
598
|
interface Plan {
|
|
388
599
|
w: number;
|
|
389
600
|
d: number;
|
|
@@ -399,13 +610,13 @@ interface Plan {
|
|
|
399
610
|
}[];
|
|
400
611
|
rooms: Room[];
|
|
401
612
|
zones: Room[];
|
|
402
|
-
doors:
|
|
403
|
-
windows:
|
|
404
|
-
walls:
|
|
405
|
-
gates:
|
|
406
|
-
paths:
|
|
407
|
-
lot:
|
|
408
|
-
facade?:
|
|
613
|
+
doors: PlanDoor[];
|
|
614
|
+
windows: PlanWindow[];
|
|
615
|
+
walls: PlanWall[];
|
|
616
|
+
gates: PlanGate[];
|
|
617
|
+
paths: LotPath[];
|
|
618
|
+
lot: Lot | null;
|
|
619
|
+
facade?: Facade;
|
|
409
620
|
openPairs: Record<number, [string, string][]>;
|
|
410
621
|
zoning?: ZoningReport;
|
|
411
622
|
/** Lot areas the building keeps out of the fill (set by `TemplateDef.reservations`). */
|
|
@@ -419,7 +630,16 @@ interface Plan {
|
|
|
419
630
|
playerRadius: number;
|
|
420
631
|
carClearance: CarClearance;
|
|
421
632
|
}
|
|
422
|
-
|
|
633
|
+
/** Where a resolved slot sits inside the room: its cell, facing, the room part and the walls it leans on. */
|
|
634
|
+
interface SlotCell {
|
|
635
|
+
rect: Rect;
|
|
636
|
+
f: Vec2;
|
|
637
|
+
enclosed: string[];
|
|
638
|
+
R: Rect;
|
|
639
|
+
size: Vec2;
|
|
640
|
+
}
|
|
641
|
+
/** The known fields of a resolved slot. */
|
|
642
|
+
interface SlotFields {
|
|
423
643
|
id: string;
|
|
424
644
|
room: string;
|
|
425
645
|
floor: number;
|
|
@@ -427,11 +647,35 @@ interface Slot {
|
|
|
427
647
|
anchor: string;
|
|
428
648
|
side: string | null;
|
|
429
649
|
cats: Weights;
|
|
650
|
+
slide?: number;
|
|
651
|
+
required: boolean;
|
|
652
|
+
chance: number;
|
|
653
|
+
clearance: number;
|
|
654
|
+
front: string;
|
|
655
|
+
group: string | null;
|
|
656
|
+
requires: string | null;
|
|
657
|
+
/** Parent slot of an `on`/`inside` slot. */
|
|
658
|
+
on: string | null;
|
|
659
|
+
target: string | null;
|
|
430
660
|
valid: boolean;
|
|
431
661
|
reason: string | null;
|
|
662
|
+
x: number;
|
|
663
|
+
z: number;
|
|
664
|
+
ry: number;
|
|
665
|
+
w: number;
|
|
666
|
+
d: number;
|
|
667
|
+
frontU: number;
|
|
668
|
+
frontV: number;
|
|
669
|
+
aabb: Rect;
|
|
670
|
+
/** Null on an invalid slot. */
|
|
671
|
+
_cell: SlotCell | null;
|
|
672
|
+
}
|
|
673
|
+
/** A slot of a room after it has been placed (`resolveSlot`); a library may carry fields of its own. */
|
|
674
|
+
interface Slot extends SlotFields {
|
|
432
675
|
[extra: string]: Json;
|
|
433
676
|
}
|
|
434
|
-
|
|
677
|
+
/** The known fields of a placed item (`PlacedItem` without its open extras). */
|
|
678
|
+
interface PlacedItemFields {
|
|
435
679
|
id: string;
|
|
436
680
|
type: string;
|
|
437
681
|
category: string;
|
|
@@ -447,8 +691,149 @@ interface PlacedItem {
|
|
|
447
691
|
outdoor: boolean;
|
|
448
692
|
aabb: Rect;
|
|
449
693
|
color?: number | string;
|
|
694
|
+
/** Facing of the item's front. */
|
|
695
|
+
frontU?: number;
|
|
696
|
+
frontV?: number;
|
|
697
|
+
/** Slot that placed it, and the item it stands on or in. */
|
|
698
|
+
slot?: string;
|
|
699
|
+
on?: string | null;
|
|
700
|
+
mode?: 'on' | 'inside' | null;
|
|
701
|
+
clearance?: number;
|
|
702
|
+
flat?: boolean;
|
|
703
|
+
low?: boolean;
|
|
704
|
+
decor?: boolean;
|
|
705
|
+
overhead?: boolean;
|
|
706
|
+
/** Driver side of a car (unit vector). */
|
|
707
|
+
driver?: Vec2;
|
|
708
|
+
carClearance?: CarClearance;
|
|
709
|
+
/** Storeys a stair or passage room connects, or the id of the item this one serves (a gas cylinder names its stove). */
|
|
710
|
+
link?: {
|
|
711
|
+
from: number;
|
|
712
|
+
to: number;
|
|
713
|
+
} | string;
|
|
714
|
+
/** Unrounded footprint used by the fill, dropped from the result. */
|
|
715
|
+
_r?: Rect;
|
|
716
|
+
_seedId?: string;
|
|
717
|
+
/** Where a decor item hangs (`floor`, `wall`...). */
|
|
718
|
+
mount?: Mount;
|
|
719
|
+
/** Colour rule set by a plugin; replaced by `color` in the result. */
|
|
720
|
+
colorSpec?: ItemColor;
|
|
721
|
+
}
|
|
722
|
+
/** An item placed by the fill, a decor pass or a state plugin; plugins may add fields of their own. */
|
|
723
|
+
interface PlacedItem extends PlacedItemFields {
|
|
450
724
|
[extra: string]: Json;
|
|
451
725
|
}
|
|
726
|
+
/** A storey of the result. */
|
|
727
|
+
interface ResultFloor {
|
|
728
|
+
index: number;
|
|
729
|
+
label?: string;
|
|
730
|
+
name?: string;
|
|
731
|
+
number?: number;
|
|
732
|
+
y0: number;
|
|
733
|
+
ceiling: number;
|
|
734
|
+
}
|
|
735
|
+
/** A room of the result, with its first part spread as `u0..v1` and the colour roles of its wall and floor. */
|
|
736
|
+
interface ResultRoom {
|
|
737
|
+
id: string;
|
|
738
|
+
type: string;
|
|
739
|
+
label?: string;
|
|
740
|
+
name?: string;
|
|
741
|
+
floor: number;
|
|
742
|
+
u0: number;
|
|
743
|
+
v0: number;
|
|
744
|
+
u1: number;
|
|
745
|
+
v1: number;
|
|
746
|
+
parts: Rect[];
|
|
747
|
+
link: number[] | null;
|
|
748
|
+
ceiling: number;
|
|
749
|
+
color: {
|
|
750
|
+
wall: string;
|
|
751
|
+
floor: string;
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
/** A gate of the result lot. */
|
|
755
|
+
interface ResultGate extends Omit<PlanGate, 'zones' | 'open'> {
|
|
756
|
+
open: boolean;
|
|
757
|
+
color: string;
|
|
758
|
+
}
|
|
759
|
+
/** The lot of the result (null for apartments). */
|
|
760
|
+
interface ResultLot {
|
|
761
|
+
rect: Rect;
|
|
762
|
+
setback: number;
|
|
763
|
+
backyard: number;
|
|
764
|
+
sideYard: {
|
|
765
|
+
left: number;
|
|
766
|
+
right: number;
|
|
767
|
+
};
|
|
768
|
+
style: string;
|
|
769
|
+
pool: boolean;
|
|
770
|
+
zones: {
|
|
771
|
+
id: string;
|
|
772
|
+
type: string;
|
|
773
|
+
label?: string;
|
|
774
|
+
name?: string;
|
|
775
|
+
parts: Rect[];
|
|
776
|
+
ground?: string;
|
|
777
|
+
}[];
|
|
778
|
+
perimeter: (LotPerimeterPiece & {
|
|
779
|
+
color: string;
|
|
780
|
+
})[];
|
|
781
|
+
gates: ResultGate[];
|
|
782
|
+
paths: LotPath[];
|
|
783
|
+
}
|
|
784
|
+
/** The facade of the result: the plan facade with the palette colour and the colour roles. */
|
|
785
|
+
interface ResultFacade extends Omit<FacadeFields, 'color'> {
|
|
786
|
+
color: {
|
|
787
|
+
name?: string;
|
|
788
|
+
key: string;
|
|
789
|
+
hex: string;
|
|
790
|
+
};
|
|
791
|
+
roles: Record<string, string>;
|
|
792
|
+
[extra: string]: unknown;
|
|
793
|
+
}
|
|
794
|
+
/** An item of the result: the placed item without its internal fields, with its colour role or value. */
|
|
795
|
+
interface ResultItem extends Omit<PlacedItemFields, '_r' | '_seedId' | 'colorSpec'> {
|
|
796
|
+
[extra: string]: unknown;
|
|
797
|
+
}
|
|
798
|
+
/** The known fields of a `generate` result. */
|
|
799
|
+
interface FloorplanResultFields {
|
|
800
|
+
template: string;
|
|
801
|
+
name: string;
|
|
802
|
+
use: string;
|
|
803
|
+
seed: number | string;
|
|
804
|
+
style: string;
|
|
805
|
+
state: string;
|
|
806
|
+
locale?: string;
|
|
807
|
+
w: number;
|
|
808
|
+
d: number;
|
|
809
|
+
floors: ResultFloor[];
|
|
810
|
+
rooms: ResultRoom[];
|
|
811
|
+
walls: PlanWall[];
|
|
812
|
+
doors: PlanDoor[];
|
|
813
|
+
windows: PlanWindow[];
|
|
814
|
+
openPairs: [string, string][];
|
|
815
|
+
facade: ResultFacade;
|
|
816
|
+
lot: ResultLot | null;
|
|
817
|
+
items: ResultItem[];
|
|
818
|
+
stateItems: ResultItem[];
|
|
819
|
+
colors: Palette;
|
|
820
|
+
/** Output of `TemplateDef.building`. */
|
|
821
|
+
building: Json;
|
|
822
|
+
missing: {
|
|
823
|
+
room: string;
|
|
824
|
+
slot: string;
|
|
825
|
+
}[];
|
|
826
|
+
/** Storey of an apartment unit. */
|
|
827
|
+
floorNumber?: number;
|
|
828
|
+
partyWalls: string[];
|
|
829
|
+
/** Output of `TemplateDef.config`. */
|
|
830
|
+
config?: Json;
|
|
831
|
+
zoning?: ZoningReport;
|
|
832
|
+
}
|
|
833
|
+
/** What `generate` returns. Result extensions add their output under their own name. */
|
|
834
|
+
interface FloorplanResult extends FloorplanResultFields {
|
|
835
|
+
[extension: string]: unknown;
|
|
836
|
+
}
|
|
452
837
|
interface ZoneDef {
|
|
453
838
|
id: string;
|
|
454
839
|
/** Generic use strings: `residential_single`, `residential_multi`, `commercial`, `mixed`, `industrial`... */
|
|
@@ -510,13 +895,39 @@ interface StatePlugin {
|
|
|
510
895
|
/** Adjusts the palette roles (HSL) before the contrast rules run. */
|
|
511
896
|
adjustPalette?(roles: Record<string, Hsl>): void;
|
|
512
897
|
}
|
|
898
|
+
/** Walkability grid of a room (`createGrid`): cells of `gs` metres, the walkable ones and the entry cells. */
|
|
899
|
+
interface WalkGrid {
|
|
900
|
+
gs: number;
|
|
901
|
+
u0: number;
|
|
902
|
+
v0: number;
|
|
903
|
+
nx: number;
|
|
904
|
+
nz: number;
|
|
905
|
+
inside: Uint8Array;
|
|
906
|
+
entries: [number, number][];
|
|
907
|
+
center: [number, number];
|
|
908
|
+
}
|
|
909
|
+
/** Options of `PlacementContext.placeOnFloor`. */
|
|
910
|
+
interface PlaceOnFloorOptions {
|
|
911
|
+
/** Treat the item as flat (no clearance or walkability check). */
|
|
912
|
+
flat?: boolean;
|
|
913
|
+
/** Candidate rectangles to try instead of the corners and walls. */
|
|
914
|
+
cands?: Rect[];
|
|
915
|
+
/** Footprint to use instead of the catalogue size. */
|
|
916
|
+
dim?: readonly number[];
|
|
917
|
+
/** Try the candidates in order instead of shuffled. */
|
|
918
|
+
ordered?: boolean;
|
|
919
|
+
/** Rejects a candidate. */
|
|
920
|
+
without?: (rect: Rect) => boolean;
|
|
921
|
+
/** Walkability grid to check instead of the room's. */
|
|
922
|
+
railing?: WalkGrid;
|
|
923
|
+
}
|
|
513
924
|
interface PlacementContext {
|
|
514
|
-
make(room: Room, type: string, rect: Rect, front: Vec2, extra?:
|
|
925
|
+
make(room: Room, type: string, rect: Rect, front: Vec2, extra?: Partial<PlacedItem>): PlacedItem;
|
|
515
926
|
add(item: PlacedItem): PlacedItem;
|
|
516
|
-
placeOnFloor(room: Room, type: string, rng: Rng, opts?:
|
|
927
|
+
placeOnFloor(room: Room, type: string, rng: Rng, opts?: PlaceOnFloorOptions): Rect | null;
|
|
517
928
|
itemsOfRoom(room: Room): PlacedItem[];
|
|
518
929
|
solidsOfRoom(room: Room): Rect[];
|
|
519
|
-
gridOf(room: Room):
|
|
930
|
+
gridOf(room: Room): WalkGrid;
|
|
520
931
|
extraSolids: Record<string, Rect[]>;
|
|
521
932
|
roomById(id: string): Room | undefined;
|
|
522
933
|
setIgnored(ids: Set<string> | null): void;
|
|
@@ -536,11 +947,11 @@ interface PlacementKit {
|
|
|
536
947
|
insideUnion(r: Rect, inners: Rect[]): boolean;
|
|
537
948
|
usableParts(room: Room, extra?: number): Rect[];
|
|
538
949
|
zonesOfFloor(plan: Plan, floor: number): Rect[];
|
|
539
|
-
windowsOfRoom(plan: Plan, room: Room):
|
|
540
|
-
windowZone(j:
|
|
950
|
+
windowsOfRoom(plan: Plan, room: Room): PlanWindow[];
|
|
951
|
+
windowZone(j: Pick<PlanWindow, 'width' | 'side' | 'u' | 'v' | 'axis'>, outside?: boolean): Rect;
|
|
541
952
|
roomAt(plan: Plan, u: number, v: number, floor: number): Room | null;
|
|
542
|
-
reachable(grid:
|
|
543
|
-
createGrid(plan: Plan, room: Room, ignored?: Set<string> | null):
|
|
953
|
+
reachable(grid: WalkGrid, solids: Rect[], inflation: number): boolean;
|
|
954
|
+
createGrid(plan: Plan, room: Room, ignored?: Set<string> | null): WalkGrid;
|
|
544
955
|
clearRect(r: Rect, f: Vec2, clearance: number): Rect;
|
|
545
956
|
pickWeighted(rng: Rng, w: Weights): string;
|
|
546
957
|
createRng(seed: number | string, key: string): Rng;
|
|
@@ -549,7 +960,7 @@ interface PlacementKit {
|
|
|
549
960
|
shuffle<T>(a: T[], rng: Rng): T[];
|
|
550
961
|
facingRotation(f: Vec2, type: string): number;
|
|
551
962
|
cutIntervals(intervals: [number, number][], a: number, b: number): [number, number][];
|
|
552
|
-
blocksWindow(it: FurnitureDef, j:
|
|
963
|
+
blocksWindow(it: FurnitureDef, j: Pick<PlanWindow, 'y0'>, overheadOff?: boolean): boolean;
|
|
553
964
|
}
|
|
554
965
|
interface DecorPassContext {
|
|
555
966
|
plan: Plan;
|
|
@@ -604,7 +1015,8 @@ interface FloorplanLocale {
|
|
|
604
1015
|
interface ViewerLayerContext {
|
|
605
1016
|
/** Canvas 2D context, already in CSS pixels. */
|
|
606
1017
|
g: CanvasRenderingContext2D;
|
|
607
|
-
|
|
1018
|
+
/** The `generate` result being drawn. */
|
|
1019
|
+
plan: FloorplanResult;
|
|
608
1020
|
/** Storey being drawn (0 when `all`). */
|
|
609
1021
|
floor: number;
|
|
610
1022
|
/** All storeys at once (the lot view). */
|
|
@@ -629,103 +1041,25 @@ interface ViewerLayer {
|
|
|
629
1041
|
label: string;
|
|
630
1042
|
defaultOn?: boolean;
|
|
631
1043
|
draw(context: ViewerLayerContext): void;
|
|
632
|
-
legend?(plan:
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
/** Tools handed to a style recipe. `jit` and `rng` draw from the style's seeded stream: draw order is part of the contract. */
|
|
636
|
-
interface PaletteDraw {
|
|
637
|
-
rng: Rng;
|
|
638
|
-
base: [string, number, number, number];
|
|
639
|
-
H0: number;
|
|
640
|
-
H1: number;
|
|
641
|
-
H2: number;
|
|
642
|
-
jit(v: number, a: number): number;
|
|
643
|
-
hsl(h: number, s: number, l: number): Hsl;
|
|
644
|
-
}
|
|
645
|
-
interface PaletteEarly {
|
|
646
|
-
/** Accent mode: true saturates walls, false puts accents on objects. */
|
|
647
|
-
wallMode: boolean;
|
|
648
|
-
/** Maximum wall saturation. */
|
|
649
|
-
sMax: number;
|
|
650
|
-
/** Facade, wall, gate, roof, ceiling... in insertion order. */
|
|
651
|
-
roles: Record<string, Hsl>;
|
|
652
|
-
/** General floor `[h, s, l]` for room types that do not define their own. */
|
|
653
|
-
generalFloor: [number, number, number];
|
|
654
|
-
}
|
|
655
|
-
interface PaletteStyleDef {
|
|
656
|
-
/** Legacy stream suffix; defaults to the style id. */
|
|
657
|
-
seedKey?: string;
|
|
658
|
-
/** Facade colour table `[labelKey, h, s, l]`. */
|
|
659
|
-
facadeColors: [string, number, number, number][];
|
|
660
|
-
/** Draws up to the room colours (before the room loop). */
|
|
661
|
-
early(d: PaletteDraw): PaletteEarly;
|
|
662
|
-
/** Draws the object roles (wood, fabrics, metal, ground colours) after the room loop. */
|
|
663
|
-
late(d: PaletteDraw, e: PaletteEarly): Record<string, Hsl>;
|
|
664
|
-
}
|
|
665
|
-
interface PaletteContext extends PaletteDraw {
|
|
666
|
-
style: string;
|
|
667
|
-
sMax: number;
|
|
668
|
-
wallMode: boolean;
|
|
669
|
-
generalFloor: [number, number, number];
|
|
670
|
-
}
|
|
671
|
-
interface PaletteOptions {
|
|
672
|
-
seed?: number | string;
|
|
673
|
-
style?: string;
|
|
674
|
-
state?: string;
|
|
1044
|
+
legend?(plan: FloorplanResult): ViewerLayerLegendEntry[];
|
|
675
1045
|
}
|
|
676
|
-
type Palette = {
|
|
677
|
-
meta: {
|
|
678
|
-
seed: number | string;
|
|
679
|
-
style: string;
|
|
680
|
-
state: string;
|
|
681
|
-
scheme: string;
|
|
682
|
-
base: string;
|
|
683
|
-
accentMode: 'wall' | 'object';
|
|
684
|
-
};
|
|
685
|
-
} & Record<string, number | object>;
|
|
686
|
-
/** Seeded colour-harmony palette: a facade base colour, a harmony scheme, role colours and contrast rules. */
|
|
687
|
-
declare function palette(o?: PaletteOptions): Palette;
|
|
688
1046
|
|
|
689
1047
|
/** What a container holds, from the first registered provider that answers (`null` passes to the next); none answering means nothing. */
|
|
690
1048
|
declare function findsFor(query: FindsQuery): readonly FindStack[];
|
|
691
1049
|
/** Like `findsFor`, but `null` when no provider answered, so a pack can fall back to its own default. */
|
|
692
1050
|
declare function findsAnswer(query: FindsQuery): readonly FindStack[] | null;
|
|
693
1051
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
declare function registerStyle(style: StyleDef): void;
|
|
700
|
-
declare function registerPaletteStyle(id: string, def: PaletteStyleDef): void;
|
|
701
|
-
declare function registerRoomColors(list: RoomColorDef[]): void;
|
|
702
|
-
declare function registerDecorProfile(styleId: string, profile: Json): void;
|
|
703
|
-
declare function registerPass(name: string, run: DecorPass): void;
|
|
704
|
-
declare function registerGroundOverlay(rule: GroundOverlayRule): void;
|
|
705
|
-
declare function registerWallTop(id: string, height: number): void;
|
|
706
|
-
/** Legacy RNG stream names for rooms and items, so seeds recorded before the English ids still reproduce. */
|
|
707
|
-
declare function registerSeedKeys(keys: {
|
|
708
|
-
rooms?: Record<string, string>;
|
|
709
|
-
items?: Record<string, string>;
|
|
710
|
-
}): void;
|
|
711
|
-
/** Registers a house state. The engine only ships `normal`. */
|
|
712
|
-
declare function registerState(name: string, plugin: StatePlugin): void;
|
|
713
|
-
/** Default state draw when `options.state` is absent: `{ state: weight }` on its own seeded stream. */
|
|
714
|
-
declare function setStateDistribution(weights: Record<string, number> | null, seedKey?: string): void;
|
|
715
|
-
declare const listStates: () => string[];
|
|
716
|
-
/** Adds a named piece to every result, after the state and before the zoning report; its output lands in `result[name]`. */
|
|
717
|
-
declare function registerResultExtension(name: string, run: ResultExtensionRun, options?: ResultExtensionOptions): void;
|
|
718
|
-
/** Registers who answers what a container holds (the item packs, from phase 3 on). */
|
|
719
|
-
declare function registerFindsProvider(provider: FindsProvider): void;
|
|
720
|
-
/** Adds (or replaces, by id) a layer of the 2D viewer; drawn after the items, before the labels. */
|
|
721
|
-
declare function registerViewerLayer(layer: ViewerLayer): void;
|
|
722
|
-
|
|
1052
|
+
/** A recorded slot: the resolved slot without its internal fields, with the category names only. */
|
|
1053
|
+
interface RecordedSlot extends Omit<SlotFields, '_cell' | 'cats'> {
|
|
1054
|
+
cats: string[];
|
|
1055
|
+
[extra: string]: unknown;
|
|
1056
|
+
}
|
|
723
1057
|
/** Recorded slots (resolved positions) of every storey and of the lot. */
|
|
724
|
-
declare function slots(template: string | TemplateDef, options?: FloorplanOptions):
|
|
1058
|
+
declare function slots(template: string | TemplateDef, options?: FloorplanOptions): RecordedSlot[];
|
|
725
1059
|
/** Generates a plan: building, lot, seeded item fill, decor, house state and palette. */
|
|
726
|
-
declare function generate(template: string | TemplateDef, options?: FloorplanOptions):
|
|
1060
|
+
declare function generate(template: string | TemplateDef, options?: FloorplanOptions): FloorplanResult;
|
|
727
1061
|
/** Validates a result of `generate`; returns a list of messages (empty when valid). */
|
|
728
|
-
declare function validate(result:
|
|
1062
|
+
declare function validate(result: FloorplanResult, options?: {
|
|
729
1063
|
locale?: string;
|
|
730
1064
|
}): string[];
|
|
731
1065
|
/** Size limits and default size of a template (they can depend on options such as `tier`). */
|
|
@@ -755,9 +1089,12 @@ declare function listTemplates(locale?: string): {
|
|
|
755
1089
|
floors: number;
|
|
756
1090
|
floorRange: [number, number] | null;
|
|
757
1091
|
lot: boolean;
|
|
758
|
-
options:
|
|
1092
|
+
options: {};
|
|
759
1093
|
}[];
|
|
760
1094
|
|
|
1095
|
+
declare const overlaps: (a: Rect, b: Rect, e?: number) => boolean;
|
|
1096
|
+
declare function openingZones(u: number, v: number, axis: 'u' | 'v', width: number, depth: number): Rect[];
|
|
1097
|
+
|
|
761
1098
|
type Namespace = keyof FloorplanLocale;
|
|
762
1099
|
/** Registers (or extends) the strings of a language. Packs call this with their JSON files. */
|
|
763
1100
|
declare function registerLocale(code: string, table: FloorplanLocale): void;
|
|
@@ -765,9 +1102,111 @@ declare const listLocales: () => string[];
|
|
|
765
1102
|
/** Looks a key up in a namespace. Falls back to English, then to the key itself. `{n}`-style variables are replaced. */
|
|
766
1103
|
declare function translate(ns: Namespace, key: string, locale?: string, vars?: Record<string, string | number>): string;
|
|
767
1104
|
|
|
768
|
-
/**
|
|
769
|
-
declare
|
|
1105
|
+
/** Keep-out zone of a window (inside, or outside for the lot). */
|
|
1106
|
+
declare function windowZone(j: Pick<PlanWindow, 'width' | 'side' | 'u' | 'v' | 'axis'>, outside?: boolean): Rect;
|
|
1107
|
+
/** `overheadOff`: the counter sits under the window without its wall cabinet. */
|
|
1108
|
+
declare function blocksWindow(it: Pick<FurnitureDef, 'window' | 'overhead' | 'windowHeight'> & {
|
|
1109
|
+
h: number;
|
|
1110
|
+
}, win: Pick<PlanWindow, 'y0'>, overheadOff?: boolean): boolean;
|
|
1111
|
+
|
|
1112
|
+
/** All content registries of one engine instance. Content packs fill them through the `register*` functions. */
|
|
1113
|
+
type Registries = {
|
|
1114
|
+
CATALOG: Record<string, FurnitureDef>;
|
|
1115
|
+
LIBRARIES: Record<string, SlotLibrary>;
|
|
1116
|
+
LIBRARY_ALIAS: Record<string, string>;
|
|
1117
|
+
TEMPLATES: Record<string, TemplateDef>;
|
|
1118
|
+
STYLES: Record<string, StyleDef>;
|
|
1119
|
+
STYLE_ALIAS: Record<string, string>;
|
|
1120
|
+
PALETTE_STYLES: Record<string, PaletteStyleDef>;
|
|
1121
|
+
ROOM_COLORS: RoomColorDef[];
|
|
1122
|
+
PASSES: {
|
|
1123
|
+
name: string;
|
|
1124
|
+
run: DecorPass;
|
|
1125
|
+
}[];
|
|
1126
|
+
DECOR_PROFILES: Record<string, Json>;
|
|
1127
|
+
GROUND_OVERLAYS: GroundOverlayRule[];
|
|
1128
|
+
STATE_PLUGINS: Record<string, StatePlugin>;
|
|
1129
|
+
WALL_TOP_HEIGHTS: Record<string, number>;
|
|
1130
|
+
SEED_KEYS: {
|
|
1131
|
+
rooms: Record<string, string>;
|
|
1132
|
+
items: Record<string, string>;
|
|
1133
|
+
};
|
|
1134
|
+
stateDistribution: {
|
|
1135
|
+
weights: Record<string, number> | null;
|
|
1136
|
+
seedKey: string;
|
|
1137
|
+
};
|
|
1138
|
+
RESULT_EXTENSIONS: ResultExtension[];
|
|
1139
|
+
FINDS_PROVIDERS: FindsProvider[];
|
|
1140
|
+
VIEWER_LAYERS: ViewerLayer[];
|
|
1141
|
+
LOCALES: Record<string, FloorplanLocale>;
|
|
1142
|
+
ZONES: Record<string, ZoneDef>;
|
|
1143
|
+
PERMEABLE_GROUNDS: Set<string>;
|
|
1144
|
+
};
|
|
1145
|
+
declare function registerItem(def: ItemInput): FurnitureDef;
|
|
1146
|
+
declare function registerItems(list: ItemInput[]): void;
|
|
1147
|
+
declare function registerLibrary(id: string, library: SlotLibrary): void;
|
|
1148
|
+
declare function registerLibraryAlias(alias: string, id: string): void;
|
|
1149
|
+
declare function registerTemplate<T extends TemplateDef>(t: T): T;
|
|
1150
|
+
declare function registerStyle(style: StyleDef): void;
|
|
1151
|
+
declare function registerPaletteStyle(id: string, def: PaletteStyleDef): void;
|
|
1152
|
+
declare function registerRoomColors(list: RoomColorDef[]): void;
|
|
1153
|
+
declare function registerDecorProfile(styleId: string, profile: Json): void;
|
|
1154
|
+
declare function registerPass(name: string, run: DecorPass): void;
|
|
1155
|
+
declare function registerGroundOverlay(rule: GroundOverlayRule): void;
|
|
1156
|
+
declare function registerWallTop(id: string, height: number): void;
|
|
1157
|
+
/** Legacy RNG stream names for rooms and items, so seeds recorded before the English ids still reproduce. */
|
|
1158
|
+
declare function registerSeedKeys(keys: {
|
|
1159
|
+
rooms?: Record<string, string>;
|
|
1160
|
+
items?: Record<string, string>;
|
|
1161
|
+
}): void;
|
|
1162
|
+
/** Registers a house state. The engine only ships `normal`. */
|
|
1163
|
+
declare function registerState(name: string, plugin: StatePlugin): void;
|
|
1164
|
+
/** Default state draw when `options.state` is absent: `{ state: weight }` on its own seeded stream. */
|
|
1165
|
+
declare function setStateDistribution(weights: Record<string, number> | null, seedKey?: string): void;
|
|
1166
|
+
declare const listStates: () => string[];
|
|
1167
|
+
interface ResultExtension {
|
|
1168
|
+
name: string;
|
|
1169
|
+
run: ResultExtensionRun;
|
|
1170
|
+
after: string[];
|
|
1171
|
+
seedKey: string;
|
|
1172
|
+
}
|
|
1173
|
+
/** Adds a named piece to every result, after the state and before the zoning report; its output lands in `result[name]`. */
|
|
1174
|
+
declare function registerResultExtension(name: string, run: ResultExtensionRun, options?: ResultExtensionOptions): void;
|
|
1175
|
+
/** Registers who answers what a container holds (the item packs, from phase 3 on). */
|
|
1176
|
+
declare function registerFindsProvider(provider: FindsProvider): void;
|
|
1177
|
+
/** Adds (or replaces, by id) a layer of the 2D viewer; drawn after the items, before the labels. */
|
|
1178
|
+
declare function registerViewerLayer(layer: ViewerLayer): void;
|
|
770
1179
|
|
|
1180
|
+
/** What the zone checks read from a plan: a generated result or the internal plan. */
|
|
1181
|
+
interface ZoneCheckedPlan {
|
|
1182
|
+
floors: {
|
|
1183
|
+
y0: number;
|
|
1184
|
+
ceiling: number;
|
|
1185
|
+
}[];
|
|
1186
|
+
floorNumber?: number | null;
|
|
1187
|
+
rooms?: {
|
|
1188
|
+
floor: number;
|
|
1189
|
+
parts: readonly (readonly number[])[];
|
|
1190
|
+
}[];
|
|
1191
|
+
w: number;
|
|
1192
|
+
d: number;
|
|
1193
|
+
use?: string;
|
|
1194
|
+
partyWalls?: string[];
|
|
1195
|
+
}
|
|
1196
|
+
/** What the zone checks read from a lot (`result.lot`). */
|
|
1197
|
+
interface ZoneCheckedLot {
|
|
1198
|
+
rect: readonly number[];
|
|
1199
|
+
setback: number;
|
|
1200
|
+
sideYard: {
|
|
1201
|
+
left: number;
|
|
1202
|
+
right: number;
|
|
1203
|
+
};
|
|
1204
|
+
backyard: number;
|
|
1205
|
+
zones: {
|
|
1206
|
+
ground?: string;
|
|
1207
|
+
parts: readonly (readonly number[])[];
|
|
1208
|
+
}[];
|
|
1209
|
+
}
|
|
771
1210
|
/** Registers an urban zone (zoning rules). Returns the stored definition. */
|
|
772
1211
|
declare function defineZone(zone: ZoneDef): ZoneDef;
|
|
773
1212
|
declare const getZone: (id: string) => ZoneDef | undefined;
|
|
@@ -778,17 +1217,106 @@ declare function registerPermeableGround(...types: string[]): void;
|
|
|
778
1217
|
* Checks a generated lot against a zone and returns the violations (empty when compliant).
|
|
779
1218
|
* `lot` is `result.lot` (may be null for apartments), `plan` is the result of `generate`.
|
|
780
1219
|
*/
|
|
781
|
-
declare function checkLot(zoneIn: string | ZoneDef, lot:
|
|
1220
|
+
declare function checkLot(zoneIn: string | ZoneDef, lot: ZoneCheckedLot | null | undefined, plan: ZoneCheckedPlan): ZoneViolation[];
|
|
782
1221
|
|
|
783
|
-
declare const
|
|
784
|
-
|
|
1222
|
+
declare const version = "0.1.0";
|
|
1223
|
+
/** Registers `packs` and applies `patch` / `remove` over the catalogs, by id. Items are keyed by `type`, templates by `id`. */
|
|
1224
|
+
type CreateFloorplanOptions = {
|
|
1225
|
+
/** Content packs, applied in order: a function `(engine) => void` or an object with `register(engine)`. */
|
|
1226
|
+
readonly packs?: readonly FloorplanPack[];
|
|
1227
|
+
readonly patch?: {
|
|
1228
|
+
readonly items?: Readonly<Record<string, DeepPartial<FurnitureDef>>>;
|
|
1229
|
+
readonly templates?: Readonly<Record<string, DeepPartial<TemplateDef>>>;
|
|
1230
|
+
};
|
|
1231
|
+
readonly remove?: {
|
|
1232
|
+
readonly items?: readonly string[];
|
|
1233
|
+
readonly templates?: readonly string[];
|
|
1234
|
+
};
|
|
1235
|
+
};
|
|
1236
|
+
type FloorplanPack = ((engine: FloorplanEngine) => void) | {
|
|
1237
|
+
readonly register: (engine: FloorplanEngine) => void;
|
|
1238
|
+
};
|
|
1239
|
+
declare function buildEngine(scope: Registries): {
|
|
1240
|
+
version: string;
|
|
1241
|
+
generate: typeof generate;
|
|
1242
|
+
slots: typeof slots;
|
|
1243
|
+
validate: typeof validate;
|
|
1244
|
+
palette: typeof palette;
|
|
1245
|
+
limitsOf: typeof limitsOf;
|
|
1246
|
+
listTemplates: typeof listTemplates;
|
|
1247
|
+
listStates: () => string[];
|
|
1248
|
+
registerItem: typeof registerItem;
|
|
1249
|
+
registerItems: typeof registerItems;
|
|
1250
|
+
registerLibrary: typeof registerLibrary;
|
|
1251
|
+
registerLibraryAlias: typeof registerLibraryAlias;
|
|
1252
|
+
registerTemplate: typeof registerTemplate;
|
|
1253
|
+
registerStyle: typeof registerStyle;
|
|
1254
|
+
registerPaletteStyle: typeof registerPaletteStyle;
|
|
1255
|
+
registerRoomColors: typeof registerRoomColors;
|
|
1256
|
+
registerDecorProfile: typeof registerDecorProfile;
|
|
1257
|
+
registerPass: typeof registerPass;
|
|
1258
|
+
registerGroundOverlay: typeof registerGroundOverlay;
|
|
1259
|
+
registerWallTop: typeof registerWallTop;
|
|
1260
|
+
registerSeedKeys: typeof registerSeedKeys;
|
|
1261
|
+
registerState: typeof registerState;
|
|
1262
|
+
setStateDistribution: typeof setStateDistribution;
|
|
1263
|
+
registerLocale: typeof registerLocale;
|
|
1264
|
+
registerResultExtension: typeof registerResultExtension;
|
|
1265
|
+
registerFindsProvider: typeof registerFindsProvider;
|
|
1266
|
+
findsFor: typeof findsFor;
|
|
1267
|
+
findsAnswer: typeof findsAnswer;
|
|
1268
|
+
registerViewerLayer: typeof registerViewerLayer;
|
|
1269
|
+
viewerLayers: ViewerLayer[];
|
|
1270
|
+
blocksWindow: typeof blocksWindow;
|
|
1271
|
+
defineZone: typeof defineZone;
|
|
1272
|
+
getZone: (id: string) => ZoneDef | undefined;
|
|
1273
|
+
listZones: () => ZoneDef[];
|
|
1274
|
+
checkLot: typeof checkLot;
|
|
1275
|
+
registerPermeableGround: typeof registerPermeableGround;
|
|
1276
|
+
slotKit: SlotKit;
|
|
1277
|
+
translate: typeof translate;
|
|
1278
|
+
listLocales: () => string[];
|
|
1279
|
+
templates: Record<string, TemplateDef>;
|
|
1280
|
+
catalog: Record<string, FurnitureDef>;
|
|
1281
|
+
libraries: Record<string, SlotLibrary>;
|
|
1282
|
+
styles: Record<string, StyleDef>;
|
|
1283
|
+
paletteStyles: Record<string, PaletteStyleDef>;
|
|
1284
|
+
createRng: (seed: string | number, key: string) => Rng;
|
|
1285
|
+
mulberry32: typeof mulberry32;
|
|
1286
|
+
hashString: typeof hashString;
|
|
1287
|
+
overlaps: (a: Rect, b: Rect, e?: number) => boolean;
|
|
1288
|
+
windowZone: typeof windowZone;
|
|
1289
|
+
openingZones: typeof openingZones;
|
|
1290
|
+
color: {
|
|
1291
|
+
lstar: (n: number) => number;
|
|
1292
|
+
hex: (n: number) => string;
|
|
1293
|
+
hsl: (n: number) => Hsl;
|
|
1294
|
+
HIGH_SATURATION: number;
|
|
1295
|
+
MIN_WALL_FLOOR_CONTRAST: number;
|
|
1296
|
+
MIN_FABRIC_FLOOR_CONTRAST: number;
|
|
1297
|
+
};
|
|
1298
|
+
constants: {
|
|
1299
|
+
WALL_THICKNESS: number;
|
|
1300
|
+
DOOR_CLEARANCE: number;
|
|
1301
|
+
PLAYER_RADIUS: number;
|
|
1302
|
+
DOOR_EDGE_CLEARANCE: number;
|
|
1303
|
+
WINDOW_EDGE_CLEARANCE: number;
|
|
1304
|
+
OVERHEAD_TOP: number;
|
|
1305
|
+
CAR_CLEARANCE: {
|
|
1306
|
+
readonly driver: 0.8;
|
|
1307
|
+
readonly side: 0.6;
|
|
1308
|
+
readonly end: 0.6;
|
|
1309
|
+
};
|
|
1310
|
+
};
|
|
1311
|
+
};
|
|
1312
|
+
type FloorplanEngine = ReturnType<typeof buildEngine>;
|
|
1313
|
+
/** An engine of its own: registries, zones and locales are not shared with any other engine on the page. */
|
|
1314
|
+
declare function createFloorplan(options?: CreateFloorplanOptions): FloorplanEngine;
|
|
1315
|
+
/** The engine the global `engine` stands for, created on first use. Content packs of the old `register(engine)` calls fill this one. */
|
|
1316
|
+
declare function defaultFloorplan(): FloorplanEngine;
|
|
785
1317
|
|
|
786
|
-
/**
|
|
787
|
-
declare
|
|
788
|
-
/** `overheadOff`: the counter sits under the window without its wall cabinet. */
|
|
789
|
-
declare function blocksWindow(it: Pick<FurnitureDef, 'window' | 'overhead' | 'windowHeight'> & {
|
|
790
|
-
h: number;
|
|
791
|
-
}, win: Json, overheadOff?: boolean): boolean;
|
|
1318
|
+
/** Builders for the slot definitions of a room library. */
|
|
1319
|
+
declare const slotKit: SlotKit;
|
|
792
1320
|
|
|
793
1321
|
/** One primitive of a far-away silhouette. Parts are listed in creation order; `parent` is the index of a group part (`-1` is the root). */
|
|
794
1322
|
type SilhouettePart = {
|
|
@@ -974,84 +1502,10 @@ type DetachedHouseParams = Seeded & {
|
|
|
974
1502
|
/** One-storey detached house; boarded windows get two crossed planks each. */
|
|
975
1503
|
declare function createDetachedHouse(p: DetachedHouseParams): Silhouette;
|
|
976
1504
|
|
|
977
|
-
declare const version = "0.1.0";
|
|
978
1505
|
/**
|
|
979
|
-
* The engine
|
|
980
|
-
*
|
|
1506
|
+
* The global engine. Content packs take it as an argument (`register(engine)`), so that several bundles (ESM or IIFE) fill the same registries.
|
|
1507
|
+
* @deprecated use `createFloorplan({ packs, patch, remove })`, an engine of its own, or `defaultFloorplan()` for the shared one.
|
|
981
1508
|
*/
|
|
982
|
-
declare const engine:
|
|
983
|
-
version: string;
|
|
984
|
-
generate: typeof generate;
|
|
985
|
-
slots: typeof slots;
|
|
986
|
-
validate: typeof validate;
|
|
987
|
-
palette: typeof palette;
|
|
988
|
-
limitsOf: typeof limitsOf;
|
|
989
|
-
listTemplates: typeof listTemplates;
|
|
990
|
-
listStates: () => string[];
|
|
991
|
-
registerItem: typeof registerItem;
|
|
992
|
-
registerItems: typeof registerItems;
|
|
993
|
-
registerLibrary: typeof registerLibrary;
|
|
994
|
-
registerLibraryAlias: typeof registerLibraryAlias;
|
|
995
|
-
registerTemplate: typeof registerTemplate;
|
|
996
|
-
registerStyle: typeof registerStyle;
|
|
997
|
-
registerPaletteStyle: typeof registerPaletteStyle;
|
|
998
|
-
registerRoomColors: typeof registerRoomColors;
|
|
999
|
-
registerDecorProfile: typeof registerDecorProfile;
|
|
1000
|
-
registerPass: typeof registerPass;
|
|
1001
|
-
registerGroundOverlay: typeof registerGroundOverlay;
|
|
1002
|
-
registerWallTop: typeof registerWallTop;
|
|
1003
|
-
registerSeedKeys: typeof registerSeedKeys;
|
|
1004
|
-
registerState: typeof registerState;
|
|
1005
|
-
setStateDistribution: typeof setStateDistribution;
|
|
1006
|
-
registerLocale: typeof registerLocale;
|
|
1007
|
-
registerResultExtension: typeof registerResultExtension;
|
|
1008
|
-
registerFindsProvider: typeof registerFindsProvider;
|
|
1009
|
-
findsFor: typeof findsFor;
|
|
1010
|
-
findsAnswer: typeof findsAnswer;
|
|
1011
|
-
registerViewerLayer: typeof registerViewerLayer;
|
|
1012
|
-
viewerLayers: ViewerLayer[];
|
|
1013
|
-
blocksWindow: typeof blocksWindow;
|
|
1014
|
-
defineZone: typeof defineZone;
|
|
1015
|
-
getZone: (id: string) => ZoneDef | undefined;
|
|
1016
|
-
listZones: () => ZoneDef[];
|
|
1017
|
-
checkLot: typeof checkLot;
|
|
1018
|
-
registerPermeableGround: typeof registerPermeableGround;
|
|
1019
|
-
slotKit: SlotKit;
|
|
1020
|
-
translate: typeof translate;
|
|
1021
|
-
listLocales: () => string[];
|
|
1022
|
-
templates: Record<string, TemplateDef>;
|
|
1023
|
-
catalog: Record<string, FurnitureDef>;
|
|
1024
|
-
libraries: Record<string, SlotLibrary>;
|
|
1025
|
-
styles: Record<string, StyleDef>;
|
|
1026
|
-
paletteStyles: Record<string, PaletteStyleDef>;
|
|
1027
|
-
createRng: (seed: string | number, key: string) => Rng;
|
|
1028
|
-
mulberry32: typeof mulberry32;
|
|
1029
|
-
hashString: typeof hashString;
|
|
1030
|
-
overlaps: (a: Rect, b: Rect, e?: number) => boolean;
|
|
1031
|
-
windowZone: typeof windowZone;
|
|
1032
|
-
openingZones: typeof openingZones;
|
|
1033
|
-
color: {
|
|
1034
|
-
lstar: (n: number) => number;
|
|
1035
|
-
hex: (n: number) => string;
|
|
1036
|
-
hsl: (n: number) => Hsl;
|
|
1037
|
-
HIGH_SATURATION: number;
|
|
1038
|
-
MIN_WALL_FLOOR_CONTRAST: number;
|
|
1039
|
-
MIN_FABRIC_FLOOR_CONTRAST: number;
|
|
1040
|
-
};
|
|
1041
|
-
constants: {
|
|
1042
|
-
WALL_THICKNESS: number;
|
|
1043
|
-
DOOR_CLEARANCE: number;
|
|
1044
|
-
PLAYER_RADIUS: number;
|
|
1045
|
-
DOOR_EDGE_CLEARANCE: number;
|
|
1046
|
-
WINDOW_EDGE_CLEARANCE: number;
|
|
1047
|
-
OVERHEAD_TOP: number;
|
|
1048
|
-
CAR_CLEARANCE: {
|
|
1049
|
-
readonly driver: 0.8;
|
|
1050
|
-
readonly side: 0.6;
|
|
1051
|
-
readonly end: 0.6;
|
|
1052
|
-
};
|
|
1053
|
-
};
|
|
1054
|
-
};
|
|
1055
|
-
type FloorplanEngine = typeof engine;
|
|
1509
|
+
declare const engine: FloorplanEngine;
|
|
1056
1510
|
|
|
1057
|
-
export { type Anchor, type BoundaryRule, type CarClearance, type ChaletParams, type CityBuildingParams, type ColonialParams, type CompanyHouseParams, type DecorPass, type DecorPassContext, type DetachedHouseParams, type DoorDef, type FacingRule, type FarmhouseParams, type FindStack, type FindsProvider, type FindsQuery, type FloorDef, type FloorplanEngine, type FloorplanLocale, type FloorplanOptions, type FurnitureDef, type GateCfg, type GroundOverlayRule, type Hsl, type ItemColor, type ItemInput, type Json, type LotConfig, type MeshFront, type Mount, type PaletteDraw, type PaletteEarly, type PaletteStyleDef, type PlacedItem, type PlacementContext, type PlacementKit, type Plan, type RandomSource, type Rect, type ResultExtensionContext, type ResultExtensionOptions, type ResultExtensionRun, type Room, type RoomColorDef, type RoomDef, type Side, type Silhouette, type SilhouettePart, type SilhouetteWindow, type SlabHouseParams, type Slot, type SlotDef, type SlotKit, type SlotLibrary, type StateContext, type StatePlugin, type StiltHouseParams, type StyleDef, type TemplateDef, type TwoStoreyParams, type Vec2, type ViewerLayer, type ViewerLayerContext, type ViewerLayerLegendEntry, type Weights, type WindowDef, type ZoneAdjustment, type ZoneDef, type ZoneViolation, type ZoningReport, blocksWindow, boxRadius, checkLot, createChalet, createCityBuilding, createColonialHouse, createCompanyHouse, createDetachedHouse, createFarmhouse, createRng, createSilhouetteRandom, createSlabHouse, createStiltHouse, createTwoStoreyHouse, defineZone, engine, findsAnswer, findsFor, generate, getZone, hashString, limitsOf, listLocales, listStates, listTemplates, listZones, mulberry32, openingZones, overlaps, palette, registerDecorProfile, registerFindsProvider, registerGroundOverlay, registerItem, registerItems, registerLibrary, registerLibraryAlias, registerLocale, registerPaletteStyle, registerPass, registerPermeableGround, registerResultExtension, registerRoomColors, registerSeedKeys, registerState, registerStyle, registerTemplate, registerViewerLayer, registerWallTop, setStateDistribution, slotKit, slots, translate, validate, version, windowZone };
|
|
1511
|
+
export { type Anchor, type BoundaryRule, type CarClearance, type ChaletParams, type CityBuildingParams, type ColonialParams, type CompanyHouseParams, type CreateFloorplanOptions, type DecorPass, type DecorPassContext, type DetachedHouseParams, type DoorDef, type Facade, type FacadeFields, type FacingRule, type FarmhouseParams, type FindStack, type FindsProvider, type FindsQuery, type FloorDef, type FloorplanEngine, type FloorplanLocale, type FloorplanOptions, type FloorplanPack, type FloorplanResult, type FloorplanResultFields, type FurnitureDef, type GateCfg, type GroundOverlayRule, type Hsl, type ItemColor, type ItemInput, type Json, type Lot, type LotBoundary, type LotConfig, type LotPath, type LotPerimeterPiece, type MeshFront, type Mount, type PaletteDraw, type PaletteEarly, type PaletteStyleDef, type PlaceOnFloorOptions, type PlacedItem, type PlacedItemFields, type PlacementContext, type PlacementKit, type Plan, type PlanAxis, type PlanDoor, type PlanGate, type PlanOpening, type PlanWall, type PlanWindow, type RandomSource, type RecordedSlot, type Rect, type ResultExtensionContext, type ResultExtensionOptions, type ResultExtensionRun, type ResultFacade, type ResultFloor, type ResultGate, type ResultItem, type ResultLot, type ResultRoom, type Room, type RoomColorDef, type RoomDef, type Side, type Silhouette, type SilhouettePart, type SilhouetteWindow, type SlabHouseParams, type Slot, type SlotCell, type SlotDef, type SlotFields, type SlotKit, type SlotLibrary, type StateContext, type StatePlugin, type StiltHouseParams, type StyleDef, type TemplateDef, type TwoStoreyParams, type Vec2, type ViewerLayer, type ViewerLayerContext, type ViewerLayerLegendEntry, type WalkGrid, type Weights, type WindowDef, type ZoneAdjustment, type ZoneCheckedLot, type ZoneCheckedPlan, type ZoneDef, type ZoneViolation, type ZoningReport, blocksWindow, boxRadius, checkLot, createChalet, createCityBuilding, createColonialHouse, createCompanyHouse, createDetachedHouse, createFarmhouse, createFloorplan, createRng, createSilhouetteRandom, createSlabHouse, createStiltHouse, createTwoStoreyHouse, defaultFloorplan, defineZone, engine, findsAnswer, findsFor, generate, getZone, hashString, limitsOf, listLocales, listStates, listTemplates, listZones, mulberry32, openingZones, overlaps, palette, registerDecorProfile, registerFindsProvider, registerGroundOverlay, registerItem, registerItems, registerLibrary, registerLibraryAlias, registerLocale, registerPaletteStyle, registerPass, registerPermeableGround, registerResultExtension, registerRoomColors, registerSeedKeys, registerState, registerStyle, registerTemplate, registerViewerLayer, registerWallTop, setStateDistribution, slotKit, slots, translate, validate, version, windowZone };
|