@kensnzk/koyu 0.23.0 → 0.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/bodies.d.ts +28 -0
- package/dist/core/bodies.d.ts.map +1 -0
- package/dist/core/bodies.js +75 -0
- package/dist/core/bodies.js.map +1 -0
- package/dist/core/model.d.ts +1 -1
- package/dist/core/model.js +1 -1
- package/dist/core/section.d.ts +1 -1
- package/dist/core/section.d.ts.map +1 -1
- package/dist/core/section.js +16 -58
- package/dist/core/section.js.map +1 -1
- package/dist/draw/index.d.ts +3 -0
- package/dist/draw/index.d.ts.map +1 -1
- package/dist/draw/index.js +3 -0
- package/dist/draw/index.js.map +1 -1
- package/dist/draw/marks.d.ts +126 -0
- package/dist/draw/marks.d.ts.map +1 -0
- package/dist/draw/marks.js +227 -0
- package/dist/draw/marks.js.map +1 -0
- package/dist/draw/plan.d.ts.map +1 -1
- package/dist/draw/plan.js +102 -117
- package/dist/draw/plan.js.map +1 -1
- package/dist/draw/scene.d.ts +133 -0
- package/dist/draw/scene.d.ts.map +1 -0
- package/dist/draw/scene.js +252 -0
- package/dist/draw/scene.js.map +1 -0
- package/dist/draw/written.d.ts +27 -0
- package/dist/draw/written.d.ts.map +1 -0
- package/dist/draw/written.js +50 -0
- package/dist/draw/written.js.map +1 -0
- package/package.json +2 -2
- package/src/core/bodies.ts +100 -0
- package/src/core/model.ts +1 -1
- package/src/core/section.ts +20 -69
- package/src/draw/index.ts +23 -0
- package/src/draw/marks.ts +315 -0
- package/src/draw/plan.ts +97 -108
- package/src/draw/scene.ts +390 -0
- package/src/draw/written.ts +64 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { Form, FormSwing } from "../core/derive.js";
|
|
2
|
+
import type { Pt } from "../core/model.js";
|
|
3
|
+
import type { Seg2 } from "../core/vertical.js";
|
|
4
|
+
/** World mm, x east+ / y north+ / z up+. Plain numbers only. */
|
|
5
|
+
export interface ScenePrism {
|
|
6
|
+
/** counter-clockwise plan ring — the winding every Form outline has */
|
|
7
|
+
ring: Pt[];
|
|
8
|
+
/** underside z per vertex. `bottom.length === ring.length` */
|
|
9
|
+
bottom: number[];
|
|
10
|
+
/** upper z per vertex. `top.length === ring.length` */
|
|
11
|
+
top: number[];
|
|
12
|
+
/**
|
|
13
|
+
* True when every `bottom` is one number and every `top` is one number — a right prism.
|
|
14
|
+
* **A fact about the numbers, not a hint about materials.** It is what lets a consumer take the
|
|
15
|
+
* cheap extrude path and know when it must stitch a per-vertex buffer instead (a ramp, a flight).
|
|
16
|
+
*/
|
|
17
|
+
level: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** A polyline at one height. Nothing in Form needs a per-vertex z on a line. */
|
|
20
|
+
export interface SceneLine {
|
|
21
|
+
points: Pt[];
|
|
22
|
+
z: number;
|
|
23
|
+
closed: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A place to put a symbol or a word. **It carries no word.** `extent` is the plan bounds of what
|
|
27
|
+
* the mark is about, so the wording a consumer chooses can be sized and offset against it.
|
|
28
|
+
*/
|
|
29
|
+
export interface SceneMark {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
z: number;
|
|
33
|
+
extent: {
|
|
34
|
+
x1: number;
|
|
35
|
+
y1: number;
|
|
36
|
+
x2: number;
|
|
37
|
+
y2: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export type SceneSubject = "space" | "boundary" | "opening" | "column" | "slab" | "run" | "site" | "level";
|
|
41
|
+
/**
|
|
42
|
+
* The geometric treatment. **Five, and closed.** Anything a consumer branches a *material* on
|
|
43
|
+
* beyond these — glass, selection, theme, storey colour — is read off a word, and words are the
|
|
44
|
+
* consumer's.
|
|
45
|
+
*/
|
|
46
|
+
export type SceneRole =
|
|
47
|
+
/** the air a space encloses, floor to ceiling */
|
|
48
|
+
"volume"
|
|
49
|
+
/** a space or the site read as a horizontal face (`bottom === top`) */
|
|
50
|
+
| "plate"
|
|
51
|
+
/** matter — a wall body, a column, a slab, a tread, a ramp, a leaf */
|
|
52
|
+
| "body"
|
|
53
|
+
/** a line, not a body — a boundary's centreline, the site edge */
|
|
54
|
+
| "edge"
|
|
55
|
+
/** a seat for a symbol or a word */
|
|
56
|
+
| "mark";
|
|
57
|
+
/** Booleans and free words carried verbatim. No colour, no line type, no wording. */
|
|
58
|
+
export interface SceneFacts {
|
|
59
|
+
/** `FormSpace.void` — a volume with no floor and no matter */
|
|
60
|
+
hollow?: boolean;
|
|
61
|
+
semiOutdoor?: boolean;
|
|
62
|
+
outside?: boolean;
|
|
63
|
+
indoor?: boolean;
|
|
64
|
+
covered?: boolean;
|
|
65
|
+
/** `FormBoundary.air` — does not occlude (a rail, a fence) */
|
|
66
|
+
air?: boolean;
|
|
67
|
+
/** `FormBoundary.derived` — came from contact, not from a declaration */
|
|
68
|
+
derived?: boolean;
|
|
69
|
+
sliding?: boolean;
|
|
70
|
+
/** `FormOpening.style` — a free word, carried and **not read** */
|
|
71
|
+
style?: string;
|
|
72
|
+
/** `FormOpening.name` — likewise */
|
|
73
|
+
name?: string;
|
|
74
|
+
/** `FormColumn.grid` — the drawing name of the intersection it stands on */
|
|
75
|
+
grid?: string;
|
|
76
|
+
areaM2?: number;
|
|
77
|
+
}
|
|
78
|
+
export interface SceneNode {
|
|
79
|
+
of: SceneSubject;
|
|
80
|
+
role: SceneRole;
|
|
81
|
+
/** the subject's identity in the spelling the rest of `Form` uses */
|
|
82
|
+
ref: string;
|
|
83
|
+
kind?: string;
|
|
84
|
+
/** the authored level this node belongs to, when it has one */
|
|
85
|
+
level?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Place in canonical boundary order — the same meaning as `Mark.written`. **Never an index into
|
|
88
|
+
* `model.boundaries`** (ADR-0041): declaration order is discarded by the canonical form, so
|
|
89
|
+
* indexing by it reads another boundary's attributes and nothing throws.
|
|
90
|
+
*/
|
|
91
|
+
written?: {
|
|
92
|
+
boundary: number;
|
|
93
|
+
index?: number;
|
|
94
|
+
};
|
|
95
|
+
/** the two spaces a boundary or opening relates */
|
|
96
|
+
pair?: {
|
|
97
|
+
a: string;
|
|
98
|
+
b: string;
|
|
99
|
+
};
|
|
100
|
+
/** exactly one of these three, matching `role` */
|
|
101
|
+
solid?: ScenePrism;
|
|
102
|
+
line?: SceneLine;
|
|
103
|
+
mark?: SceneMark;
|
|
104
|
+
/** wall bodies and opening leaves only — the axis, which cannot be read off `ring` */
|
|
105
|
+
centre?: Seg2;
|
|
106
|
+
t?: number;
|
|
107
|
+
/** verbatim, for a viewer that rotates a leaf open */
|
|
108
|
+
swing?: FormSwing;
|
|
109
|
+
facts: SceneFacts;
|
|
110
|
+
}
|
|
111
|
+
export interface SceneLevel {
|
|
112
|
+
name: string;
|
|
113
|
+
z: number;
|
|
114
|
+
pitch?: number;
|
|
115
|
+
}
|
|
116
|
+
export interface Scene {
|
|
117
|
+
levels: SceneLevel[];
|
|
118
|
+
/**
|
|
119
|
+
* The level that meets the ground — **the lowest level at or above z 0, not `levels[0]`**. A
|
|
120
|
+
* building with a basement otherwise lands its site and its landscaping on the basement plan.
|
|
121
|
+
* Undefined when nothing stands at or above ground.
|
|
122
|
+
*/
|
|
123
|
+
ground?: string;
|
|
124
|
+
nodes: SceneNode[];
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The scene a `Form` describes.
|
|
128
|
+
*
|
|
129
|
+
* Deterministic and cacheable: the same Form gives the same nodes in the same order, because the
|
|
130
|
+
* order is `Form`'s own and is never re-established here.
|
|
131
|
+
*/
|
|
132
|
+
export declare function sceneOf(form: Form): Scene;
|
|
133
|
+
//# sourceMappingURL=scene.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene.d.ts","sourceRoot":"","sources":["../../src/draw/scene.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO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,CAAC;CAChB;AAED,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,SAAS,EAAE,CAAC;CACpB;AAwBD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,KAAK,CAgNzC"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
// koyu — the scene a Form describes (`@kensnzk/koyu/draw`)
|
|
2
|
+
//
|
|
3
|
+
// **Plain data. No three.js, no colour, no word, and no option.** A viewer turns these nodes into
|
|
4
|
+
// meshes with its own materials, its own lighting and its own idea of what is selected; two viewers
|
|
5
|
+
// showing the same building disagree about all of that and about none of this.
|
|
6
|
+
//
|
|
7
|
+
// **Why data and not a scene graph.** The package declares no runtime dependency and a test holds
|
|
8
|
+
// it to that, so a `THREE.Group` cannot be returned from here. That constraint turned out to be the
|
|
9
|
+
// right shape anyway: the two viewers that exist both wrap the result in their own group, one of
|
|
10
|
+
// them explodes the levels apart, and neither wants the other's materials.
|
|
11
|
+
//
|
|
12
|
+
// **No options, deliberately.** Everything a viewer might have asked for — which levels, whether to
|
|
13
|
+
// draw openings, how thick a ground plate is, how far to spread the storeys — is either a filter
|
|
14
|
+
// over the nodes (`nodes.filter`) or a transform on the consumer's own group. Baking any of it in
|
|
15
|
+
// here would make the scene stop being a projection of the Form, and two viewers would then differ
|
|
16
|
+
// by which options they passed rather than by how they draw.
|
|
17
|
+
//
|
|
18
|
+
// Every z is true world z. A plate is a face (`bottom === top`), because Form derives no thickness
|
|
19
|
+
// for the ground and inventing one here would be a paper decision made in the wrong place.
|
|
20
|
+
import { formBodies } from "../core/bodies.js";
|
|
21
|
+
import { Extent } from "./sheet.js";
|
|
22
|
+
/** A right prism is one where every underside and every top is the same number. */
|
|
23
|
+
const prism = (ring, bottom, top) => ({
|
|
24
|
+
ring,
|
|
25
|
+
bottom,
|
|
26
|
+
top,
|
|
27
|
+
level: new Set(bottom).size <= 1 && new Set(top).size <= 1,
|
|
28
|
+
});
|
|
29
|
+
const flat = (ring, z0, z1) => prism(ring, ring.map(() => z0), ring.map(() => z1));
|
|
30
|
+
/** Drop the keys nobody set, so a node carries facts rather than a row of undefineds. */
|
|
31
|
+
const facts = (o) => {
|
|
32
|
+
const out = {};
|
|
33
|
+
for (const [k, v] of Object.entries(o))
|
|
34
|
+
if (v !== undefined)
|
|
35
|
+
out[k] = v;
|
|
36
|
+
return out;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The scene a `Form` describes.
|
|
40
|
+
*
|
|
41
|
+
* Deterministic and cacheable: the same Form gives the same nodes in the same order, because the
|
|
42
|
+
* order is `Form`'s own and is never re-established here.
|
|
43
|
+
*/
|
|
44
|
+
export function sceneOf(form) {
|
|
45
|
+
const nodes = [];
|
|
46
|
+
const spaces = new Map(form.spaces.map((s) => [s.path, s]));
|
|
47
|
+
const boundaries = new Map(form.boundaries.map((b) => [b.ref, b]));
|
|
48
|
+
const openings = new Map(form.openings.map((o) => [o.ref, o]));
|
|
49
|
+
const columns = new Map(form.columns.map((c) => [c.ref, c]));
|
|
50
|
+
const runs = new Map(form.runs.map((r) => [r.path, r]));
|
|
51
|
+
const levelZ = new Map(form.levels.map((l) => [l.name, l.z]));
|
|
52
|
+
// ---- the bodies, straight out of the one enumeration, in its order ----
|
|
53
|
+
for (const body of formBodies(form)) {
|
|
54
|
+
const solid = prism(body.poly, body.bottom, body.top);
|
|
55
|
+
switch (body.of) {
|
|
56
|
+
case "space": {
|
|
57
|
+
const s = spaces.get(body.ref);
|
|
58
|
+
nodes.push({
|
|
59
|
+
of: "space",
|
|
60
|
+
role: "volume",
|
|
61
|
+
ref: body.ref,
|
|
62
|
+
...(body.kind !== undefined ? { kind: body.kind } : {}),
|
|
63
|
+
...(s?.level !== undefined ? { level: s.level } : {}),
|
|
64
|
+
solid,
|
|
65
|
+
facts: facts({
|
|
66
|
+
hollow: s?.void,
|
|
67
|
+
semiOutdoor: s?.semiOutdoor,
|
|
68
|
+
outside: s?.outside,
|
|
69
|
+
indoor: s?.indoor,
|
|
70
|
+
covered: s?.covered,
|
|
71
|
+
}),
|
|
72
|
+
});
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
case "boundary": {
|
|
76
|
+
const b = boundaries.get(body.ref);
|
|
77
|
+
nodes.push({
|
|
78
|
+
of: "boundary",
|
|
79
|
+
role: "body",
|
|
80
|
+
ref: body.ref,
|
|
81
|
+
...(body.kind !== undefined ? { kind: body.kind } : {}),
|
|
82
|
+
...(b?.level !== undefined ? { level: b.level } : {}),
|
|
83
|
+
...(b ? { written: { boundary: b.boundary }, pair: { a: b.a, b: b.b } } : {}),
|
|
84
|
+
solid,
|
|
85
|
+
...(body.centre ? { centre: body.centre } : {}),
|
|
86
|
+
...(b?.material ? { t: b.material.t } : {}),
|
|
87
|
+
facts: facts({ air: b?.air, derived: b?.derived }),
|
|
88
|
+
});
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
case "opening": {
|
|
92
|
+
const o = openings.get(body.ref);
|
|
93
|
+
nodes.push({
|
|
94
|
+
of: "opening",
|
|
95
|
+
role: "body",
|
|
96
|
+
ref: body.ref,
|
|
97
|
+
...(body.kind !== undefined ? { kind: body.kind } : {}),
|
|
98
|
+
...(o?.level !== undefined ? { level: o.level } : {}),
|
|
99
|
+
...(o ? { written: { boundary: o.boundary, index: o.index }, pair: { a: o.a, b: o.b } } : {}),
|
|
100
|
+
solid,
|
|
101
|
+
...(body.centre ? { centre: body.centre } : {}),
|
|
102
|
+
...(o ? { t: o.t } : {}),
|
|
103
|
+
...(o?.swing ? { swing: o.swing } : {}),
|
|
104
|
+
facts: facts({ sliding: o?.sliding, style: o?.style, name: o?.name }),
|
|
105
|
+
});
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case "column": {
|
|
109
|
+
const c = columns.get(body.ref);
|
|
110
|
+
nodes.push({
|
|
111
|
+
of: "column",
|
|
112
|
+
role: "body",
|
|
113
|
+
ref: body.ref,
|
|
114
|
+
...(c?.level !== undefined ? { level: c.level } : {}),
|
|
115
|
+
solid,
|
|
116
|
+
facts: facts({ grid: c?.grid }),
|
|
117
|
+
});
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
case "slab": {
|
|
121
|
+
nodes.push({
|
|
122
|
+
of: "slab",
|
|
123
|
+
role: "body",
|
|
124
|
+
ref: body.ref,
|
|
125
|
+
...(body.kind !== undefined ? { kind: body.kind } : {}),
|
|
126
|
+
...(body.level !== undefined ? { level: body.level } : {}),
|
|
127
|
+
solid,
|
|
128
|
+
facts: {},
|
|
129
|
+
});
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
case "run": {
|
|
133
|
+
const r = runs.get(body.ref);
|
|
134
|
+
nodes.push({
|
|
135
|
+
of: "run",
|
|
136
|
+
role: "body",
|
|
137
|
+
ref: body.ref,
|
|
138
|
+
...(body.kind !== undefined ? { kind: body.kind } : {}),
|
|
139
|
+
...(r?.level !== undefined ? { level: r.level } : {}),
|
|
140
|
+
solid,
|
|
141
|
+
facts: {},
|
|
142
|
+
});
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// ---- the layers that are not bodies ----
|
|
148
|
+
// A space read as a face at its own floor, for a viewer that shows storeys as plates rather than
|
|
149
|
+
// as air. `Form` derives no thickness for it, so it is a face and the consumer extrudes.
|
|
150
|
+
for (const s of form.spaces) {
|
|
151
|
+
if (s.level === undefined)
|
|
152
|
+
continue;
|
|
153
|
+
const z = levelZ.get(s.level);
|
|
154
|
+
if (z === undefined)
|
|
155
|
+
continue;
|
|
156
|
+
for (const piece of s.outline) {
|
|
157
|
+
nodes.push({
|
|
158
|
+
of: "space",
|
|
159
|
+
role: "plate",
|
|
160
|
+
ref: s.path,
|
|
161
|
+
...(s.type !== undefined ? { kind: s.type } : {}),
|
|
162
|
+
level: s.level,
|
|
163
|
+
solid: flat(piece, z, z),
|
|
164
|
+
facts: facts({
|
|
165
|
+
hollow: s.void,
|
|
166
|
+
semiOutdoor: s.semiOutdoor,
|
|
167
|
+
outside: s.outside,
|
|
168
|
+
indoor: s.indoor,
|
|
169
|
+
covered: s.covered,
|
|
170
|
+
}),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
// Every boundary carries a centreline, whether or not it has matter — a relation with nothing in
|
|
175
|
+
// it is still a relation, and a viewer that only meshed bodies would never see one.
|
|
176
|
+
for (const b of form.boundaries) {
|
|
177
|
+
const z = b.level !== undefined ? levelZ.get(b.level) : undefined;
|
|
178
|
+
nodes.push({
|
|
179
|
+
of: "boundary",
|
|
180
|
+
role: "edge",
|
|
181
|
+
ref: b.ref,
|
|
182
|
+
kind: b.kind,
|
|
183
|
+
...(b.level !== undefined ? { level: b.level } : {}),
|
|
184
|
+
written: { boundary: b.boundary },
|
|
185
|
+
pair: { a: b.a, b: b.b },
|
|
186
|
+
line: {
|
|
187
|
+
points: [
|
|
188
|
+
{ x: b.segment.x1, y: b.segment.y1 },
|
|
189
|
+
{ x: b.segment.x2, y: b.segment.y2 },
|
|
190
|
+
],
|
|
191
|
+
z: z ?? 0,
|
|
192
|
+
closed: false,
|
|
193
|
+
},
|
|
194
|
+
facts: facts({ air: b.air, derived: b.derived }),
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
for (const p of form.site) {
|
|
198
|
+
nodes.push({
|
|
199
|
+
of: "site",
|
|
200
|
+
role: "plate",
|
|
201
|
+
ref: p.path,
|
|
202
|
+
solid: flat(p.points, 0, 0),
|
|
203
|
+
facts: { areaM2: p.areaM2 },
|
|
204
|
+
});
|
|
205
|
+
nodes.push({
|
|
206
|
+
of: "site",
|
|
207
|
+
role: "edge",
|
|
208
|
+
ref: p.path,
|
|
209
|
+
line: { points: p.points, z: 0, closed: true },
|
|
210
|
+
facts: { areaM2: p.areaM2 },
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
// A seat per level, for whatever a viewer wants to write beside a storey. The extent is folded,
|
|
214
|
+
// never spread — `Math.min(...pts)` overflows the stack on a model with tens of thousands of
|
|
215
|
+
// solids, and one of the bundled stress models is exactly that.
|
|
216
|
+
for (const l of form.levels) {
|
|
217
|
+
const e = new Extent();
|
|
218
|
+
for (const s of form.spaces) {
|
|
219
|
+
if (s.level !== l.name)
|
|
220
|
+
continue;
|
|
221
|
+
for (const piece of s.outline)
|
|
222
|
+
for (const pt of piece)
|
|
223
|
+
e.see(pt.x, pt.y);
|
|
224
|
+
}
|
|
225
|
+
if (e.empty)
|
|
226
|
+
continue;
|
|
227
|
+
nodes.push({
|
|
228
|
+
of: "level",
|
|
229
|
+
role: "mark",
|
|
230
|
+
ref: l.name,
|
|
231
|
+
level: l.name,
|
|
232
|
+
mark: {
|
|
233
|
+
x: e.min0,
|
|
234
|
+
y: (e.min1 + e.max1) / 2,
|
|
235
|
+
z: l.z,
|
|
236
|
+
extent: { x1: e.min0, y1: e.min1, x2: e.max0, y2: e.max1 },
|
|
237
|
+
},
|
|
238
|
+
facts: {},
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
const ground = form.levels.filter((l) => l.z >= 0).sort((a, b) => a.z - b.z)[0]?.name;
|
|
242
|
+
return {
|
|
243
|
+
levels: form.levels.map((l) => ({
|
|
244
|
+
name: l.name,
|
|
245
|
+
z: l.z,
|
|
246
|
+
...(l.pitch !== undefined ? { pitch: l.pitch } : {}),
|
|
247
|
+
})),
|
|
248
|
+
...(ground !== undefined ? { ground } : {}),
|
|
249
|
+
nodes,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
//# sourceMappingURL=scene.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene.js","sourceRoot":"","sources":["../../src/draw/scene.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,kGAAkG;AAClG,oGAAoG;AACpG,+EAA+E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IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE;aAC3D;YACD,KAAK,EAAE,EAAE;SACV,CAAC,CAAC;IACL,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC;IACtF,OAAO;QACL,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC9B,IAAI,EAAE,CAAC,CAAC,IAAI;YACZ,CAAC,EAAE,CAAC,CAAC,CAAC;YACN,GAAG,CAAC,CAAC,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACrD,CAAC,CAAC;QACH,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Model } from "../core/model.js";
|
|
2
|
+
/** What a model wrote at a place the `Form` points to. */
|
|
3
|
+
export interface Written {
|
|
4
|
+
/** the `spec` on a boundary, by its place in canonical order */
|
|
5
|
+
boundarySpec(boundary: number): string | undefined;
|
|
6
|
+
/** the `spec` on a segment that does not count */
|
|
7
|
+
segSpec(boundary: number, index: number): string | undefined;
|
|
8
|
+
/** the `spec` on an opening */
|
|
9
|
+
openingSpec(boundary: number, index: number): string | undefined;
|
|
10
|
+
/** any carried attribute on a boundary, including a namespaced one */
|
|
11
|
+
boundaryAttr(boundary: number, key: string): string | number | boolean | undefined;
|
|
12
|
+
/** any carried attribute on an opening */
|
|
13
|
+
openingAttr(boundary: number, index: number, key: string): string | number | boolean | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A window onto what a model wrote, addressed the way `Form` addresses it.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const written = writtenOf(model);
|
|
20
|
+
* for (const n of sceneOf(form).nodes) {
|
|
21
|
+
* const spec = n.written && written.boundarySpec(n.written.boundary);
|
|
22
|
+
* // deciding that a spec containing "glass" means transparent is the viewer's judgement
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function writtenOf(model: Model): Written;
|
|
27
|
+
//# sourceMappingURL=written.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"written.d.ts","sourceRoot":"","sources":["../../src/draw/written.ts"],"names":[],"mappings":"AAkBA,OAAO,EAA0B,KAAK,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEtE,0DAA0D;AAC1D,MAAM,WAAW,OAAO;IACtB,gEAAgE;IAChE,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACnD,kDAAkD;IAClD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC7D,+BAA+B;IAC/B,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACjE,sEAAsE;IACtE,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACnF,0CAA0C;IAC1C,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;CAClG;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAc/C"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// koyu — reading back what was written, from a mark or a scene node (`@kensnzk/koyu/draw`)
|
|
2
|
+
//
|
|
3
|
+
// `Mark.written` and `SceneNode.written` give a place in **canonical boundary order**. Reaching the
|
|
4
|
+
// attributes from that place needs the model, and needs it read in exactly one way: `Form`'s index
|
|
5
|
+
// is an index into `canonicalBoundaryOrder(model)`, never into `model.boundaries`. Declaration
|
|
6
|
+
// order is information the canonical form discards, so indexing by it does not throw — **it reads
|
|
7
|
+
// another boundary's `spec`**, on some models and not others (ADR-0041).
|
|
8
|
+
//
|
|
9
|
+
// **Why this and not the ordering function itself.** Two things go wrong when a consumer holds the
|
|
10
|
+
// sorted array. It sorts per lookup — both viewers did, once per boundary, re-sorting the whole
|
|
11
|
+
// building each time, which is the cost ADR-0041 names. And the raw array invites
|
|
12
|
+
// `model.boundaries[i]` to be substituted for it by anyone who does not know the difference, which
|
|
13
|
+
// is the failure the ordering exists to prevent. A window that answers "what was written here"
|
|
14
|
+
// closes both: sorted once per model, and there is no array to mis-index.
|
|
15
|
+
//
|
|
16
|
+
// This lives in the presentation face because it is not part of the language. `spec` is a carried
|
|
17
|
+
// free word — core neither reads it nor promises what it means (docs/reference/muro/attributes.md);
|
|
18
|
+
// only a drawing ever asks.
|
|
19
|
+
import { canonicalBoundaryOrder } from "../core/model.js";
|
|
20
|
+
// A model is a value, so the answer for one never changes. Sorting is O(n log n) over every
|
|
21
|
+
// boundary; doing it once per model is the whole point of the cache.
|
|
22
|
+
const cache = new WeakMap();
|
|
23
|
+
/**
|
|
24
|
+
* A window onto what a model wrote, addressed the way `Form` addresses it.
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* const written = writtenOf(model);
|
|
28
|
+
* for (const n of sceneOf(form).nodes) {
|
|
29
|
+
* const spec = n.written && written.boundarySpec(n.written.boundary);
|
|
30
|
+
* // deciding that a spec containing "glass" means transparent is the viewer's judgement
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export function writtenOf(model) {
|
|
35
|
+
const hit = cache.get(model);
|
|
36
|
+
if (hit)
|
|
37
|
+
return hit;
|
|
38
|
+
const ordered = canonicalBoundaryOrder(model);
|
|
39
|
+
const str = (v) => (typeof v === "string" ? v : undefined);
|
|
40
|
+
const made = {
|
|
41
|
+
boundarySpec: (b) => str(ordered[b]?.attrs["spec"]),
|
|
42
|
+
segSpec: (b, i) => str(ordered[b]?.segs[i]?.attrs["spec"]),
|
|
43
|
+
openingSpec: (b, i) => str(ordered[b]?.openings[i]?.attrs["spec"]),
|
|
44
|
+
boundaryAttr: (b, key) => ordered[b]?.attrs[key],
|
|
45
|
+
openingAttr: (b, i, key) => ordered[b]?.openings[i]?.attrs[key],
|
|
46
|
+
};
|
|
47
|
+
cache.set(model, made);
|
|
48
|
+
return made;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=written.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"written.js","sourceRoot":"","sources":["../../src/draw/written.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,oGAAoG;AACpG,mGAAmG;AACnG,+FAA+F;AAC/F,kGAAkG;AAClG,yEAAyE;AACzE,EAAE;AACF,mGAAmG;AACnG,gGAAgG;AAChG,kFAAkF;AAClF,mGAAmG;AACnG,+FAA+F;AAC/F,0EAA0E;AAC1E,EAAE;AACF,kGAAkG;AAClG,oGAAoG;AACpG,4BAA4B;AAC5B,OAAO,EAAE,sBAAsB,EAAc,MAAM,kBAAkB,CAAC;AAgBtE,4FAA4F;AAC5F,qEAAqE;AACr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;IACvB,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kensnzk/koyu",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"muro": {
|
|
5
5
|
"reads": [
|
|
6
6
|
"0.1",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"newest": "1.3",
|
|
17
17
|
"undeclared": "1.1"
|
|
18
18
|
},
|
|
19
|
-
"description": "
|
|
19
|
+
"description": "\u7a7a\u9593\u3092\u4e00\u6b21\u8981\u7d20\u3068\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u30cd\u30a4\u30c6\u30a3\u30d6\u5efa\u7bc9\u8a18\u8ff0\u306e\u63a2\u6c42 \u2014 writing architecture, not buildings",
|
|
20
20
|
"type": "module",
|
|
21
21
|
"main": "./dist/index.js",
|
|
22
22
|
"types": "./dist/index.d.ts",
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// koyu — every body of a Form, in the one shape every body reduces to.
|
|
2
|
+
//
|
|
3
|
+
// **This composes no matter.** Each body was already raised by `derive`, and the constructors
|
|
4
|
+
// called to raise the rest (`band` / `bandLine` / `columnRect` / `runPrism`) are the published
|
|
5
|
+
// ones. The enumeration lives here rather than inside the section because it is not the section's:
|
|
6
|
+
// a vertical plane cuts these bodies, a 3D scene meshes them, and an isometric paints them. Three
|
|
7
|
+
// readers, one list. Written twice, the second copy silently loses whatever `derive` adds next —
|
|
8
|
+
// which is the failure ADR-0040 already paid for once.
|
|
9
|
+
//
|
|
10
|
+
// **What it does not decide.** Which bodies a given drawing may use is the drawing's judgement,
|
|
11
|
+
// not the enumeration's. A section drops outside and semi-outdoor spaces because cutting one
|
|
12
|
+
// paints a garden as a room; a 3D scene keeps them because a garden is a thing you see. So the
|
|
13
|
+
// list is complete here and narrowed at each call site.
|
|
14
|
+
import { band, bandLine, columnRect, runPrism, type Form } from "./derive.js";
|
|
15
|
+
import type { Pt } from "./model.js";
|
|
16
|
+
import type { Seg2 } from "./vertical.js";
|
|
17
|
+
|
|
18
|
+
/** What a body stands for. */
|
|
19
|
+
export type FormSubject = "space" | "boundary" | "opening" | "column" | "slab" | "run";
|
|
20
|
+
|
|
21
|
+
/** A body of the Form, in the one shape every body reduces to. */
|
|
22
|
+
export interface FormBody {
|
|
23
|
+
of: FormSubject;
|
|
24
|
+
ref: string;
|
|
25
|
+
kind?: string;
|
|
26
|
+
/** the authored level this body belongs to, where the Form says so */
|
|
27
|
+
level?: string;
|
|
28
|
+
poly: Pt[];
|
|
29
|
+
/** underside z per vertex, mm. `bottom.length === poly.length` */
|
|
30
|
+
bottom: number[];
|
|
31
|
+
/** upper z per vertex, mm. `top.length === poly.length` */
|
|
32
|
+
top: number[];
|
|
33
|
+
/**
|
|
34
|
+
* The axis of a wall body or an opening leaf. **Carried because it cannot be read off `poly`** —
|
|
35
|
+
* a junction takes the body off its own centre line, so the midpoints of opposing sides are not
|
|
36
|
+
* the axis (see `FormPanel` in derive.ts). Recovering it on the drawing side puts a handrail
|
|
37
|
+
* beside itself at every corner.
|
|
38
|
+
*/
|
|
39
|
+
centre?: Seg2;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Every body of the Form, in canonical order. **The order is inherited, never re-established.** */
|
|
43
|
+
export function formBodies(form: Form): FormBody[] {
|
|
44
|
+
const out: FormBody[] = [];
|
|
45
|
+
const flat = (poly: Pt[], z0: number, z1: number): Pick<FormBody, "poly" | "bottom" | "top"> => ({
|
|
46
|
+
poly,
|
|
47
|
+
bottom: poly.map(() => z0),
|
|
48
|
+
top: poly.map(() => z1),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Spaces come first because space is the primary element.
|
|
52
|
+
for (const s of form.spaces) {
|
|
53
|
+
if (s.z0 === undefined || s.z1 === undefined) continue; // no ceiling height, no volume (SUF01)
|
|
54
|
+
for (const piece of s.outline) {
|
|
55
|
+
out.push({ of: "space", ref: s.path, ...(s.type ? { kind: s.type } : {}), ...flat(piece, s.z0, s.z1) });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
for (const b of form.boundaries) {
|
|
59
|
+
if (!b.material) continue; // type:open — a relation with no matter
|
|
60
|
+
for (const p of b.material.panels) {
|
|
61
|
+
out.push({
|
|
62
|
+
of: "boundary",
|
|
63
|
+
ref: b.ref,
|
|
64
|
+
kind: b.kind,
|
|
65
|
+
...flat(p.footprint, p.z0, p.z1),
|
|
66
|
+
centre: { x1: p.x1, y1: p.y1, x2: p.x2, y2: p.y2 },
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const o of form.openings) {
|
|
71
|
+
out.push({
|
|
72
|
+
of: "opening",
|
|
73
|
+
ref: o.ref,
|
|
74
|
+
kind: o.kind,
|
|
75
|
+
...flat(band(o.segment, o.cx, o.cy, o.w, o.t), o.z0, o.z1),
|
|
76
|
+
centre: bandLine(o.segment, o.cx, o.cy, o.w),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
for (const c of form.columns) {
|
|
80
|
+
out.push({ of: "column", ref: c.ref, ...flat(columnRect(c), c.z0, c.z1) });
|
|
81
|
+
}
|
|
82
|
+
for (const sl of form.slabs) {
|
|
83
|
+
// **面は自分の階を持って出る。**持たずに出せば、読む側が空間のパスから引き直すことに
|
|
84
|
+
// なり、二つの消費者が同じ引き直しを別々に書く — 実際にそうなった
|
|
85
|
+
out.push({
|
|
86
|
+
of: "slab",
|
|
87
|
+
ref: sl.space,
|
|
88
|
+
kind: sl.kind,
|
|
89
|
+
level: sl.level,
|
|
90
|
+
...flat(sl.outline, sl.z0, sl.z1),
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
for (const run of form.runs) {
|
|
94
|
+
for (const s of run.solids) {
|
|
95
|
+
const pr = runPrism(s);
|
|
96
|
+
out.push({ of: "run", ref: run.path, kind: run.device, poly: pr.poly, bottom: pr.bottom, top: pr.top });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return out;
|
|
100
|
+
}
|
package/src/core/model.ts
CHANGED
|
@@ -73,7 +73,7 @@ export const LAST_KOYU_SPELLED_VERSION = "1.1";
|
|
|
73
73
|
* `since` column is written in this vocabulary, and every surface that answers "which muro
|
|
74
74
|
* does this build speak" needs both halves at once.
|
|
75
75
|
*/
|
|
76
|
-
export const KOYU_VERSION = "0.
|
|
76
|
+
export const KOYU_VERSION = "0.25.0";
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Whether `a` names a later language version than `b`.
|