@chanmeng666/archlang-3d 0.2.0 → 0.4.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.
@@ -1,3 +1,99 @@
1
+ /**
2
+ * Material slots (visual-assets card V1): the ONE palette both the GLB writer (`glb/write.ts`) and
3
+ * the replay viewer (`replay/mount.ts`) read, so a piece's oak or ceramic is the same colour in
4
+ * both. A T0 part names its slot (`Part.mat`, `mesh/t0.ts`); its shell carries it (`Shell.slot`);
5
+ * a node with slotted shells is still ONE node under its key (`furniture:<id>`), drawn as one
6
+ * primitive (GLB, material `fixture:<slot>`) or one mesh (viewer) per slot.
7
+ *
8
+ * `body` is the untagged part: it carries no slot and keeps its kind's own colour, so a piece that
9
+ * names no slot is drawn exactly as before. Browser-safe and pure: no clock, no random source.
10
+ */
11
+
12
+ /** The closed set of slots, in the order a node's primitives (GLB) and meshes (viewer) are written. */
13
+ declare const MATERIAL_SLOTS: readonly ["body", "wood", "wood_dark", "fabric", "cushion", "linen", "wool", "ceramic", "stone", "metal", "glass", "appliance", "screen", "paint", "rubber", "foliage", "bark", "soil", "water"];
14
+ type MaterialSlot = (typeof MATERIAL_SLOTS)[number];
15
+ interface SlotMaterial {
16
+ /** Base colour, sRGB `#rrggbb`: the viewer's colour, and the GLB's after `linearRgb`. */
17
+ srgb: string;
18
+ /** 1 = opaque; below 1 the GLB writes `alphaMode: BLEND` and the viewer draws it translucent. */
19
+ alpha: number;
20
+ /** glTF metallic-roughness factors (the viewer's Lambert shading reads neither). */
21
+ metallic: number;
22
+ roughness: number;
23
+ }
24
+ /**
25
+ * The palette: warm and quiet, a furnished Scandinavian interior rather than a massing model —
26
+ * light oak and walnut, warm grey upholstery, off-white linen and ceramics, a pale stone worktop,
27
+ * brushed steel, a sage-grey kitchen and muted greens outdoors.
28
+ */
29
+ declare const PALETTE: Readonly<Record<Exclude<MaterialSlot, "body">, SlotMaterial>>;
30
+ /** The slot a stair is built in (card X3): oak treads. The core gives a stair no material, so
31
+ * this is a drafting default, ledgered (`stair-material-default`). */
32
+ declare const STAIR_MATERIAL = "wood";
33
+ /**
34
+ * The building's own materials (visual-assets V9), by Mesh3D kind, and `<kind>:<part>` where a
35
+ * part differs (a window's frame and glass, a demolished wall's ghost): the light replay's colours
36
+ * and, through `linearRgb`, the GLB's. Soft daylight on a refined model: warm-white walls on a
37
+ * warm-grey concrete slab, oak doors, slim dark-bronze window frames, pale glass. A floor takes its
38
+ * finish's colour (`FINISH_PALETTE`), never a kind colour.
39
+ */
40
+ declare const KIND_PALETTE: {
41
+ readonly slab: SlotMaterial;
42
+ readonly column: SlotMaterial;
43
+ readonly wall: SlotMaterial;
44
+ readonly door: SlotMaterial;
45
+ readonly "window:frame": SlotMaterial;
46
+ readonly "window:glass": SlotMaterial;
47
+ readonly opening: SlotMaterial;
48
+ readonly furniture: SlotMaterial;
49
+ readonly roof: SlotMaterial;
50
+ readonly "wall:demolish": SlotMaterial;
51
+ readonly stair: SlotMaterial;
52
+ };
53
+ type KindMaterial = keyof typeof KIND_PALETTE;
54
+ /**
55
+ * The replay's colour for a wall's cut top (its cap, the faces at its full height): the poché of a
56
+ * plan, read as the section through a model whose roof is lifted off. A display convention of the
57
+ * viewer, not a material: the GLB has no cap.
58
+ */
59
+ declare const WALL_CAP_SRGB = "#8f877d";
60
+ /** The floor finishes a room's floor is laid in (visual-assets V9): colour only, no texture. */
61
+ declare const FLOOR_FINISHES: readonly ["timber", "tile", "neutral"];
62
+ type FloorFinish = (typeof FLOOR_FINISHES)[number];
63
+ /** Light oak boards, pale stone tile, and the neutral finish a room whose use is unknown keeps. */
64
+ declare const FINISH_PALETTE: Readonly<Record<FloorFinish, SlotMaterial>>;
65
+ /**
66
+ * A room's floor finish from its declared `uses` (the core's use kinds, read off the plan by
67
+ * `adaptPlan`), first rule that names one of them: a wet room is tiled whatever else it is (`bath
68
+ * wc`, `utility wc`); a room lived in, slept or worked in, or walked through is timber (an open
69
+ * `living kitchen` keeps its boards); a kitchen or an entry on its own is tiled; anything else (a
70
+ * garage, a store, a room without `uses`) keeps the neutral finish. A drafting default, ledgered per
71
+ * floor as `floor-finish-default` (ADR 0030 decision 5); never read from a label.
72
+ */
73
+ declare const FLOOR_FINISH_RULES: ReadonlyArray<readonly [FloorFinish, readonly string[]]>;
74
+ /** The finish {@link FLOOR_FINISH_RULES} gives a room with these `uses`. */
75
+ declare function floorFinish(uses: readonly string[] | undefined): FloorFinish;
76
+ /** sRGB `#rrggbb` → linear RGB, each channel rounded to 4 decimals (glTF base colours are linear). */
77
+ declare function linearRgb(hex: string): [number, number, number];
78
+ /**
79
+ * A slot's viewer colour under a replay theme: the palette itself on the light theme; on the dark
80
+ * (blueprint) theme, 60% of the way from the palette to the theme's furniture colour, so materials
81
+ * stay told apart without leaving the theme. Each channel is one float multiply-add of 0–255
82
+ * integers, rounded to a whole channel value: basic IEEE-754 operations, correctly rounded in
83
+ * every engine, so every engine agrees.
84
+ */
85
+ declare function slotColour(slot: Exclude<MaterialSlot, "body">, theme: "light" | "dark", furniture: string): string;
86
+ /**
87
+ * A floor finish's viewer colour under a replay theme: the finish itself on the light theme; on the
88
+ * dark one, 60% of the way to the theme's floor colour (the same arithmetic as `slotColour`).
89
+ */
90
+ declare function finishColour(finish: FloorFinish, theme: "light" | "dark", floor: string): string;
91
+ /** A node's shells grouped by slot, in `MATERIAL_SLOTS` order (untagged `body` first). */
92
+ declare function slotGroups(shells: readonly Shell[]): Array<{
93
+ slot: MaterialSlot;
94
+ shells: Shell[];
95
+ }>;
96
+
1
97
  /**
2
98
  * Scene3D v0: a renderer-independent, plan-aligned 2.5D scene read off a resolved plan
3
99
  * (archlang-3d plan §3.5, appendix A). Plan axes: x right, y DOWN; z up. Every length is an
@@ -133,12 +229,46 @@ interface Box {
133
229
  h: Um;
134
230
  };
135
231
  }
232
+ /** A plan rectangle's edge. */
233
+ type Side = "top" | "bottom" | "left" | "right";
234
+ /**
235
+ * One straight flight of a stair, as the core resolves it: its rectangle, the edge a person
236
+ * CLIMBING it starts from (`foot`, the same on every storey whatever `dir` that storey draws), and
237
+ * the tread divisions the plan draws on it (the core's `treadCount` of its run).
238
+ */
239
+ interface StairFlight {
240
+ at: Pt;
241
+ size: {
242
+ w: Um;
243
+ h: Um;
244
+ };
245
+ foot: Side;
246
+ treads: number;
247
+ }
248
+ /** A landing between two flights of a turning stair: its rectangle. */
249
+ interface StairLanding {
250
+ at: Pt;
251
+ size: {
252
+ w: Um;
253
+ h: Um;
254
+ };
255
+ }
136
256
  interface Stair {
137
257
  id: string;
138
258
  source: Source;
259
+ /** The footprint's bounding box (on a turning stair it holds floor that is no stair: read `flights`). */
139
260
  box: Box;
140
261
  dir: "up" | "down";
262
+ /** The flight band's width, centred across each flight. */
141
263
  width: Um;
264
+ /**
265
+ * The flights in climbing order (one on a straight stair), from the core's `RStair.flights` or
266
+ * the stair itself. Absent when the core does not export `treadCount`, or on a Scene3D written
267
+ * before 0.4.0: such a stair is not built (ledgered `stair-no-flights`).
268
+ */
269
+ flights?: StairFlight[];
270
+ /** `landings[i]` stands between `flights[i]` and `flights[i + 1]`; present with `flights`. */
271
+ landings?: StairLanding[];
142
272
  }
143
273
  interface Outdoor {
144
274
  id: string;
@@ -214,7 +344,7 @@ interface Shell {
214
344
  /** A T0 part's material slot (`materials.ts`); absent = `body`, the node kind's own colour. */
215
345
  slot?: Exclude<MaterialSlot, "body">;
216
346
  }
217
- type NodeKind = "slab" | "floor" | "column" | "wall" | "door" | "window" | "opening" | "furniture" | "roof";
347
+ type NodeKind = "slab" | "floor" | "column" | "wall" | "door" | "window" | "opening" | "furniture" | "roof" | "stair";
218
348
  interface MeshNode {
219
349
  /** `L<level>/<kind>:<id>[:<part>]`, unique in the mesh (plan §3.6). */
220
350
  key: string;
@@ -241,98 +371,6 @@ interface Mesh3D {
241
371
  nodes: MeshNode[];
242
372
  }
243
373
 
244
- /**
245
- * Material slots (visual-assets card V1): the ONE palette both the GLB writer (`glb/write.ts`) and
246
- * the replay viewer (`replay/mount.ts`) read, so a piece's oak or ceramic is the same colour in
247
- * both. A T0 part names its slot (`Part.mat`, `mesh/t0.ts`); its shell carries it (`Shell.slot`);
248
- * a node with slotted shells is still ONE node under its key (`furniture:<id>`), drawn as one
249
- * primitive (GLB, material `fixture:<slot>`) or one mesh (viewer) per slot.
250
- *
251
- * `body` is the untagged part: it carries no slot and keeps its kind's own colour, so a piece that
252
- * names no slot is drawn exactly as before. Browser-safe and pure: no clock, no random source.
253
- */
254
-
255
- /** The closed set of slots, in the order a node's primitives (GLB) and meshes (viewer) are written. */
256
- declare const MATERIAL_SLOTS: readonly ["body", "wood", "wood_dark", "fabric", "cushion", "linen", "wool", "ceramic", "stone", "metal", "glass", "appliance", "screen", "paint", "rubber", "foliage", "bark", "soil", "water"];
257
- type MaterialSlot = (typeof MATERIAL_SLOTS)[number];
258
- interface SlotMaterial {
259
- /** Base colour, sRGB `#rrggbb`: the viewer's colour, and the GLB's after `linearRgb`. */
260
- srgb: string;
261
- /** 1 = opaque; below 1 the GLB writes `alphaMode: BLEND` and the viewer draws it translucent. */
262
- alpha: number;
263
- /** glTF metallic-roughness factors (the viewer's Lambert shading reads neither). */
264
- metallic: number;
265
- roughness: number;
266
- }
267
- /**
268
- * The palette: warm and quiet, a furnished Scandinavian interior rather than a massing model —
269
- * light oak and walnut, warm grey upholstery, off-white linen and ceramics, a pale stone worktop,
270
- * brushed steel, a sage-grey kitchen and muted greens outdoors.
271
- */
272
- declare const PALETTE: Readonly<Record<Exclude<MaterialSlot, "body">, SlotMaterial>>;
273
- /**
274
- * The building's own materials (visual-assets V9), by Mesh3D kind, and `<kind>:<part>` where a
275
- * part differs (a window's frame and glass, a demolished wall's ghost): the light replay's colours
276
- * and, through `linearRgb`, the GLB's. Soft daylight on a refined model: warm-white walls on a
277
- * warm-grey concrete slab, oak doors, slim dark-bronze window frames, pale glass. A floor takes its
278
- * finish's colour (`FINISH_PALETTE`), never a kind colour.
279
- */
280
- declare const KIND_PALETTE: {
281
- readonly slab: SlotMaterial;
282
- readonly column: SlotMaterial;
283
- readonly wall: SlotMaterial;
284
- readonly door: SlotMaterial;
285
- readonly "window:frame": SlotMaterial;
286
- readonly "window:glass": SlotMaterial;
287
- readonly opening: SlotMaterial;
288
- readonly furniture: SlotMaterial;
289
- readonly roof: SlotMaterial;
290
- readonly "wall:demolish": SlotMaterial;
291
- };
292
- type KindMaterial = keyof typeof KIND_PALETTE;
293
- /**
294
- * The replay's colour for a wall's cut top (its cap, the faces at its full height): the poché of a
295
- * plan, read as the section through a model whose roof is lifted off. A display convention of the
296
- * viewer, not a material: the GLB has no cap.
297
- */
298
- declare const WALL_CAP_SRGB = "#8f877d";
299
- /** The floor finishes a room's floor is laid in (visual-assets V9): colour only, no texture. */
300
- declare const FLOOR_FINISHES: readonly ["timber", "tile", "neutral"];
301
- type FloorFinish = (typeof FLOOR_FINISHES)[number];
302
- /** Light oak boards, pale stone tile, and the neutral finish a room whose use is unknown keeps. */
303
- declare const FINISH_PALETTE: Readonly<Record<FloorFinish, SlotMaterial>>;
304
- /**
305
- * A room's floor finish from its declared `uses` (the core's use kinds, read off the plan by
306
- * `adaptPlan`), first rule that names one of them: a wet room is tiled whatever else it is (`bath
307
- * wc`, `utility wc`); a room lived in, slept or worked in, or walked through is timber (an open
308
- * `living kitchen` keeps its boards); a kitchen or an entry on its own is tiled; anything else (a
309
- * garage, a store, a room without `uses`) keeps the neutral finish. A drafting default, ledgered per
310
- * floor as `floor-finish-default` (ADR 0030 decision 5); never read from a label.
311
- */
312
- declare const FLOOR_FINISH_RULES: ReadonlyArray<readonly [FloorFinish, readonly string[]]>;
313
- /** The finish {@link FLOOR_FINISH_RULES} gives a room with these `uses`. */
314
- declare function floorFinish(uses: readonly string[] | undefined): FloorFinish;
315
- /** sRGB `#rrggbb` → linear RGB, each channel rounded to 4 decimals (glTF base colours are linear). */
316
- declare function linearRgb(hex: string): [number, number, number];
317
- /**
318
- * A slot's viewer colour under a replay theme: the palette itself on the light theme; on the dark
319
- * (blueprint) theme, 60% of the way from the palette to the theme's furniture colour, so materials
320
- * stay told apart without leaving the theme. Each channel is one float multiply-add of 0–255
321
- * integers, rounded to a whole channel value: basic IEEE-754 operations, correctly rounded in
322
- * every engine, so every engine agrees.
323
- */
324
- declare function slotColour(slot: Exclude<MaterialSlot, "body">, theme: "light" | "dark", furniture: string): string;
325
- /**
326
- * A floor finish's viewer colour under a replay theme: the finish itself on the light theme; on the
327
- * dark one, 60% of the way to the theme's floor colour (the same arithmetic as `slotColour`).
328
- */
329
- declare function finishColour(finish: FloorFinish, theme: "light" | "dark", floor: string): string;
330
- /** A node's shells grouped by slot, in `MATERIAL_SLOTS` order (untagged `body` first). */
331
- declare function slotGroups(shells: readonly Shell[]): Array<{
332
- slot: MaterialSlot;
333
- shells: Shell[];
334
- }>;
335
-
336
374
  /**
337
375
  * The replay as a pure function of time (card A3; archlang-3d plan §6.5; decision D3). The plan
338
376
  * draws itself in its authoring order, then rises:
@@ -369,6 +407,14 @@ declare function slotGroups(shells: readonly Shell[]): Array<{
369
407
  * Considered, not built: upper storeys fading (translucent walls over a furnished floor; neither
370
408
  * storey reads cleanly) and a cutaway (it removes the storey the viewer just watched rise).
371
409
  *
410
+ * The explode is the RISE's, not the building's (public-surfaces card X2): once every storey is up
411
+ * (`PHASE.done`), the storeys SETTLE: in the replay's last stretch each comes down by its lift to
412
+ * the height it really stands at, and the camera moves from the last stop (the exploded building)
413
+ * to a framing of the assembled one (`stateAt`'s `settle`; `cameraStops`'s last fit). So the end
414
+ * frame, the frame a host opens on and the Iso view show the storeys stacked; every frame before
415
+ * the settle is the exploded rise, unchanged. Hiding the storeys above one (the viewer's toolbar) is
416
+ * the cutaway of the assembled building.
417
+ *
372
418
  * A demolished wall's ghost (B3a; `part` "demolish") is NOT construction (decision, red-team round 1
373
419
  * of card A2b): it takes no place in the build order. Its footprint appears in phase 1 with its
374
420
  * storey's walls (at the time of the standing node drawn just before it) without taking a step of
@@ -394,7 +440,7 @@ declare const PHASE: {
394
440
  readonly tilted: 0.78;
395
441
  /** Every wall has risen; fixtures rise from here. */
396
442
  readonly wallsUp: 0.84;
397
- /** Everything has risen. */
443
+ /** Everything has risen; several storeys combined settle from here to the end (`stateAt`). */
398
444
  readonly done: 0.96;
399
445
  };
400
446
  /**
@@ -470,10 +516,18 @@ interface ReplayState {
470
516
  /** 0…1 along the dolly (to the first camera stop). */
471
517
  dolly: number;
472
518
  /**
473
- * The combined view's camera stop, 0…storeys − 1: at k the camera frames storeys 0…k; between
474
- * stops it moves from one framing to the next. Always 0 for one storey.
519
+ * The combined view's camera stop, 0…storeys − 1 during the rise: at k the camera frames storeys
520
+ * 0…k; between stops it moves from one framing to the next. During the settle it runs on from
521
+ * storeys − 1 to storeys, the assembled building's framing (`cameraStops`'s last fit). Always 0
522
+ * for one storey.
475
523
  */
476
524
  stop: number;
525
+ /**
526
+ * The combined view's settle, 0…1: 0 while the storeys are exploded (the whole rise), 1 when each
527
+ * has come down to the height it stands at (the end frame). A node's lift is `lift × (1 − settle)`
528
+ * (`settledLift`). Always 0 for one storey.
529
+ */
530
+ settle: number;
477
531
  /** Opacity of the core's drawing over the scene. */
478
532
  svg: number;
479
533
  nodes: Map<string, NodeState>;
@@ -531,4 +585,4 @@ interface StripItem {
531
585
  */
532
586
  declare function stripAt(facts: ReplayFacts, events: readonly ReplayEvent[], t: number): StripItem[];
533
587
 
534
- export { slotColour as $, type Assumption as A, STOP_LEAD as B, type SlotMaterial as C, type DoorKind as D, EXPLODE_GAP_MM as E, type Floor as F, type Source as G, type Stage as H, type Stair as I, type Wall as J, KIND_PALETTE as K, type Level as L, type Mesh3D as M, type NodeKind as N, type Opening as O, type Polygon as P, authoringOrder as Q, type ReplayFacts as R, type StripItem as S, ease as T, type Um as U, explodeLifts as V, WALL_CAP_SRGB as W, finishColour as X, floorFinish as Y, keyFrames as Z, linearRgb as _, type Scene3D as a, slotGroups as a0, stateAt as a1, storeysOf as a2, timeline as a3, viewLabel as a4, viewMesh as a5, type Pt as b, type Shell as c, type Ring3 as d, type MaterialSlot as e, type Furniture as f, type ReplayEvent as g, type ReplayState as h, FINISH_PALETTE as i, FIXTURE_FAMILIES as j, FLOOR_FINISHES as k, FLOOR_FINISH_RULES as l, type Fence as m, type FloorFinish as n, type KindMaterial as o, MATERIAL_SLOTS as p, type MeshNode as q, type Meta as r, stripAt as s, type NodeState as t, type Outdoor as u, PALETTE as v, PHASE as w, type Provenance as x, type ReplayView as y, type Roof as z };
588
+ export { finishColour as $, type Assumption as A, type ReplayView as B, type Roof as C, type DoorKind as D, EXPLODE_GAP_MM as E, type Floor as F, STAIR_MATERIAL as G, STOP_LEAD as H, type Side as I, type SlotMaterial as J, KIND_PALETTE as K, type Level as L, type Mesh3D as M, type NodeKind as N, type Opening as O, type Polygon as P, type Source as Q, type ReplayFacts as R, type StripItem as S, type Stage as T, type StairLanding as U, type Um as V, WALL_CAP_SRGB as W, type Wall as X, authoringOrder as Y, ease as Z, explodeLifts as _, type Scene3D as a, floorFinish as a0, keyFrames as a1, linearRgb as a2, slotColour as a3, slotGroups as a4, stateAt as a5, storeysOf as a6, timeline as a7, viewLabel as a8, viewMesh as a9, type Pt as b, type Shell as c, type Ring3 as d, type StairFlight as e, type Stair as f, type MaterialSlot as g, type Furniture as h, FINISH_PALETTE as i, FIXTURE_FAMILIES as j, FLOOR_FINISHES as k, FLOOR_FINISH_RULES as l, type Fence as m, type FloorFinish as n, type KindMaterial as o, MATERIAL_SLOTS as p, type MeshNode as q, type Meta as r, stripAt as s, type NodeState as t, type Outdoor as u, PALETTE as v, PHASE as w, type Provenance as x, type ReplayEvent as y, type ReplayState as z };