@chanmeng666/archlang-3d 0.1.2 → 0.2.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/CHANGELOG.md +52 -0
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +93 -48
- package/dist/{chunk-54YVSAVZ.js → chunk-2ZINQMUB.js} +18 -6
- package/dist/{chunk-DLZMYNAR.js → chunk-4AF5Q7M3.js} +104 -267
- package/dist/{chunk-CTFMM64C.js → chunk-EYEEIS4R.js} +128 -1
- package/dist/{chunk-KIRWFAD6.js → chunk-KUK6ARJC.js} +52 -32
- package/dist/chunk-VUSBWX7N.js +4125 -0
- package/dist/cli.js +5 -5
- package/dist/{facts-fLIb8sZ2.d.ts → facts-DHuCDilh.d.ts} +1 -1
- package/dist/index.d.ts +166 -64
- package/dist/index.js +51 -11
- package/dist/node.d.ts +10 -4
- package/dist/node.js +6 -4
- package/dist/replay.d.ts +12 -1
- package/dist/scene3d.schema.json +4 -0
- package/dist/{strip-DElA8ZbJ.d.ts → strip-CdTeMoHA.d.ts} +102 -1
- package/dist/viewer.iife.js +175 -175
- package/package.json +1 -1
- package/dist/chunk-PJMKP2ML.js +0 -950
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.2.0] - 2026-11-04
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- The twelve T0 furniture pieces are drawn in materials instead of one colour per kind: oak, linen,
|
|
10
|
+
wool, upholstery, ceramic, stone, brushed steel, glass and more, from one palette that the GLB and
|
|
11
|
+
the replay both read. Each piece is still one node under its key (`furniture:<id>`); in the GLB it
|
|
12
|
+
holds one primitive per material, named `fixture:<slot>`. The ledger records each family's
|
|
13
|
+
materials (`furniture-material-default`).
|
|
14
|
+
- The pieces are more detailed: a bed with legs, a mattress, a duvet with its sheet turned down,
|
|
15
|
+
pillows and a throw; a sofa with rolled arms and separate seat and back cushions; kitchen units with
|
|
16
|
+
fronts, pulls and a stone worktop, a steel sink with its tap, an oven door and a hob with burner
|
|
17
|
+
rings; a shower with a glass screen and a head; a WC and a basin with rounded ceramics. A kitchen
|
|
18
|
+
sink, basin and shower are now ledgered taller (1160, 990 and 2000 mm: tap and screen), a rug lower
|
|
19
|
+
(12 mm).
|
|
20
|
+
- A part can have rounded corners (`radius`), lie on its side (`axis`) or follow a polygon
|
|
21
|
+
(`profile`). New exports: `t0Shells`, `t0LocalParts`, `partShell`, `sectionRing`, `T0_MATERIALS` and
|
|
22
|
+
the palette (`PALETTE`, `MATERIAL_SLOTS`, `slotColour`, `slotGroups`, `linearRgb`).
|
|
23
|
+
- A small or thin piece keeps every part inside its footprint and its ledgered height; a detail with
|
|
24
|
+
no room is left out, and a hole a part is built without is ledgered (`hole-degenerate`).
|
|
25
|
+
- The replay is lit as a model in soft daylight: a sky-and-ground light, one fixed key light and a
|
|
26
|
+
soft fill (no shadow maps; still a pure function of `t`), so a wall's two visible faces read apart.
|
|
27
|
+
Walls are a warm white with their cut tops drawn darker, doors oak, window frames slim and dark,
|
|
28
|
+
glass pale and translucent; outlines are steady instead of stippled.
|
|
29
|
+
- Each floor is laid in a finish from its room's `uses`: timber for living, dining, bedroom, office,
|
|
30
|
+
hall and circulation; pale tile for a bath, WC or utility room (whatever else it is) and for a
|
|
31
|
+
kitchen or entry on its own; a neutral finish otherwise. Colour only. The floor node carries it
|
|
32
|
+
(`extras.finish`), the ledger records it per floor (`floor-finish-default`), and the GLB writes it
|
|
33
|
+
as `floor:timber`, `floor:tile` or `floor:neutral`.
|
|
34
|
+
- The GLB's building materials now come from the same palette as the replay (`KIND_PALETTE`,
|
|
35
|
+
`FINISH_PALETTE`), and a window's frame and glass are written apart (`window:frame`, and
|
|
36
|
+
`window:glass`, translucent) instead of one `window` material. New exports: `KIND_PALETTE`,
|
|
37
|
+
`FINISH_PALETTE`, `FLOOR_FINISHES`, `FLOOR_FINISH_RULES`, `floorFinish`, `finishColour`,
|
|
38
|
+
`WALL_CAP_SRGB`, and `bodyMaterialName` from `./node`.
|
|
39
|
+
- Every catalogued furniture word is built as a T0 piece; none is a grey box any more. Only a word
|
|
40
|
+
outside the core's catalogue still stands as one. New pieces include planting (trees, a conifer,
|
|
41
|
+
shrubs, a hedge, a palm, flower and raised beds), garden and play furniture, vehicles (a car, a
|
|
42
|
+
bicycle, a motorcycle), the small site objects, and office, care and gym pieces. A towel rail
|
|
43
|
+
hangs with its underside at 200 mm and a whiteboard at 900 mm (`furniture-mount-default`).
|
|
44
|
+
- `T0_HANDED` now also holds `reception_desk`, `bicycle` and `motorcycle`. A bicycle or a
|
|
45
|
+
motorcycle is handed only laid along its width, as the core draws it; the new export
|
|
46
|
+
`handedAt(family, W, D)` says whether a piece is handed at its size. A piece that is symmetric at
|
|
47
|
+
its size is never greyed when the plan's reflection is unknown.
|
|
48
|
+
- A standing piece taller than its storey's walls (a tree in a garden) is built at its default
|
|
49
|
+
height and ledgered (`furniture-above-walls`), never clipped.
|
|
50
|
+
|
|
51
|
+
### Removed
|
|
52
|
+
|
|
53
|
+
- **Breaking:** `t0Parts` and its `PlacedPart` type are gone. Use `t0Shells(furniture, floor)`, which
|
|
54
|
+
returns the placed shells (with their material slots) and the count of holes left out, or
|
|
55
|
+
`t0LocalParts(family, W, D)` for the parts in the piece's own frame.
|
|
56
|
+
|
|
5
57
|
## [0.1.2] - 2026-11-02
|
|
6
58
|
|
|
7
59
|
### Fixed
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReplayPayload } from './replay.js';
|
|
2
2
|
export { PREVIEW_LABEL, ReplayNode, ReplayOptions, replayPayload, viewBoxOf } from './replay.js';
|
|
3
|
-
import { S as StripItem } from './strip-
|
|
4
|
-
export { R as ReplayFacts, s as stripAt } from './strip-
|
|
3
|
+
import { S as StripItem } from './strip-CdTeMoHA.js';
|
|
4
|
+
export { R as ReplayFacts, s as stripAt } from './strip-CdTeMoHA.js';
|
|
5
5
|
|
|
6
6
|
interface ReplayHandle {
|
|
7
7
|
/** Render the frame at replay time `t` (clamped to [0, 1]) into the canvas, synchronously. */
|
package/dist/browser.js
CHANGED
|
@@ -2,33 +2,39 @@ import {
|
|
|
2
2
|
PREVIEW_LABEL,
|
|
3
3
|
replayPayload,
|
|
4
4
|
viewBoxOf
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-2ZINQMUB.js";
|
|
6
6
|
import {
|
|
7
7
|
END_AZIMUTH,
|
|
8
8
|
END_FOV,
|
|
9
|
+
KIND_PALETTE,
|
|
10
|
+
PALETTE,
|
|
9
11
|
START_FOV,
|
|
12
|
+
WALL_CAP_SRGB,
|
|
10
13
|
boxOfNodes,
|
|
11
14
|
cameraPosition,
|
|
12
15
|
cameraStops,
|
|
13
16
|
drawingFrame,
|
|
17
|
+
finishColour,
|
|
14
18
|
frameCamera,
|
|
19
|
+
slotColour,
|
|
15
20
|
stateAt,
|
|
16
21
|
stripAt
|
|
17
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-EYEEIS4R.js";
|
|
18
23
|
|
|
19
24
|
// src/replay/mount.ts
|
|
20
25
|
import {
|
|
21
|
-
AmbientLight,
|
|
22
26
|
BufferAttribute,
|
|
23
27
|
BufferGeometry,
|
|
24
28
|
Color,
|
|
25
29
|
DirectionalLight,
|
|
26
30
|
EdgesGeometry,
|
|
27
31
|
Group,
|
|
32
|
+
HemisphereLight,
|
|
28
33
|
LineBasicMaterial,
|
|
29
34
|
LineSegments,
|
|
30
35
|
Mesh,
|
|
31
36
|
MeshLambertMaterial,
|
|
37
|
+
NeutralToneMapping,
|
|
32
38
|
OrthographicCamera,
|
|
33
39
|
PerspectiveCamera,
|
|
34
40
|
Scene,
|
|
@@ -57,23 +63,14 @@ function paintStrip(el, items) {
|
|
|
57
63
|
var THEMES = {
|
|
58
64
|
light: {
|
|
59
65
|
background: "#f7f5f0",
|
|
60
|
-
edge: "#
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
floor: "#ece5d8",
|
|
64
|
-
column: "#bdb5a8",
|
|
65
|
-
wall: "#f4f1eb",
|
|
66
|
-
roof: "#9c958a",
|
|
67
|
-
door: "#b48a5c",
|
|
68
|
-
"window:frame": "#e9e6e0",
|
|
69
|
-
"window:glass": "#a9c7d8",
|
|
70
|
-
"wall:demolish": "#c8553d",
|
|
71
|
-
furniture: "#d9d1c3"
|
|
72
|
-
}
|
|
66
|
+
edge: "#8f877c",
|
|
67
|
+
cap: WALL_CAP_SRGB,
|
|
68
|
+
colors: Object.fromEntries(Object.entries(KIND_PALETTE).map(([k, v]) => [k, v.srgb]))
|
|
73
69
|
},
|
|
74
70
|
dark: {
|
|
75
71
|
background: "#0f2235",
|
|
76
72
|
edge: "#cfe3f5",
|
|
73
|
+
cap: "#cfe3f5",
|
|
77
74
|
colors: {
|
|
78
75
|
slab: "#20384f",
|
|
79
76
|
floor: "#1b3248",
|
|
@@ -88,9 +85,21 @@ var THEMES = {
|
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
87
|
};
|
|
88
|
+
var LIGHT = {
|
|
89
|
+
sky: 16317439,
|
|
90
|
+
ground: 14275271,
|
|
91
|
+
hemi: 2.4,
|
|
92
|
+
keyColour: 16775922,
|
|
93
|
+
key: 2.7,
|
|
94
|
+
keyFrom: [-1, 1.25, 0.3],
|
|
95
|
+
fillColour: 15002869,
|
|
96
|
+
fill: 0.5,
|
|
97
|
+
fillFrom: [0.7, 0.5, -0.6]
|
|
98
|
+
};
|
|
91
99
|
var FOOTPRINT_MM = 12;
|
|
92
100
|
function mountReplay(out, p, strip) {
|
|
93
101
|
const theme = THEMES[p.theme];
|
|
102
|
+
const furniture = theme.colors.furniture;
|
|
94
103
|
const W = p.width;
|
|
95
104
|
const H = p.height;
|
|
96
105
|
const gl = document.createElement("canvas");
|
|
@@ -102,12 +111,16 @@ function mountReplay(out, p, strip) {
|
|
|
102
111
|
const renderer = new WebGLRenderer({ canvas: gl, antialias: false, preserveDrawingBuffer: true });
|
|
103
112
|
renderer.setPixelRatio(1);
|
|
104
113
|
renderer.setSize(W, H, false);
|
|
114
|
+
renderer.toneMapping = NeutralToneMapping;
|
|
105
115
|
const scene = new Scene();
|
|
106
116
|
scene.background = new Color(theme.background);
|
|
107
|
-
scene.add(new
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
scene.add(
|
|
117
|
+
scene.add(new HemisphereLight(LIGHT.sky, LIGHT.ground, LIGHT.hemi));
|
|
118
|
+
const key = new DirectionalLight(LIGHT.keyColour, LIGHT.key);
|
|
119
|
+
key.position.set(...LIGHT.keyFrom);
|
|
120
|
+
scene.add(key);
|
|
121
|
+
const fill = new DirectionalLight(LIGHT.fillColour, LIGHT.fill);
|
|
122
|
+
fill.position.set(...LIGHT.fillFrom);
|
|
123
|
+
scene.add(fill);
|
|
111
124
|
const nodes = /* @__PURE__ */ new Map();
|
|
112
125
|
const owned = [];
|
|
113
126
|
for (const n of p.nodes) {
|
|
@@ -126,34 +139,66 @@ function mountReplay(out, p, strip) {
|
|
|
126
139
|
pos[i + 1] = y - base;
|
|
127
140
|
pos[i + 2] = z;
|
|
128
141
|
}
|
|
129
|
-
const
|
|
130
|
-
geo.setAttribute("position", new BufferAttribute(pos, 3));
|
|
131
|
-
geo.setIndex(n.indices);
|
|
132
|
-
geo.computeVertexNormals();
|
|
133
|
-
const key = n.part ? `${n.kind}:${n.part}` : n.kind;
|
|
134
|
-
const glass = key === "window:glass";
|
|
135
|
-
const ghost = key === "wall:demolish";
|
|
136
|
-
const mat = new MeshLambertMaterial({
|
|
137
|
-
color: new Color(theme.colors[key] ?? theme.colors.furniture),
|
|
138
|
-
transparent: glass || ghost,
|
|
139
|
-
opacity: glass ? 0.45 : ghost ? 0.3 : 1,
|
|
140
|
-
depthWrite: !ghost,
|
|
141
|
-
flatShading: true,
|
|
142
|
-
// The floor finish sits a few millimetres under every footprint: pushed back in depth, so a
|
|
143
|
-
// flat footprint never fights it in perspective.
|
|
144
|
-
polygonOffset: n.kind === "floor" || n.kind === "slab",
|
|
145
|
-
polygonOffsetFactor: 1,
|
|
146
|
-
polygonOffsetUnits: 4
|
|
147
|
-
});
|
|
148
|
-
owned.push(geo, mat);
|
|
142
|
+
const key2 = n.part ? `${n.kind}:${n.part}` : n.kind;
|
|
149
143
|
const g = new Group();
|
|
150
144
|
g.position.y = base + (n.lift ?? 0);
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
145
|
+
const add = (attr2, indices, colour, glass, opacity, normals, edged = true) => {
|
|
146
|
+
const geo = new BufferGeometry();
|
|
147
|
+
geo.setAttribute("position", attr2);
|
|
148
|
+
geo.setIndex(indices);
|
|
149
|
+
if (normals) geo.computeVertexNormals();
|
|
150
|
+
const ghost = key2 === "wall:demolish";
|
|
151
|
+
const flatLaid = n.kind === "floor" || n.kind === "slab";
|
|
152
|
+
const mat = new MeshLambertMaterial({
|
|
153
|
+
color: new Color(colour),
|
|
154
|
+
transparent: glass || ghost,
|
|
155
|
+
opacity: glass ? opacity : ghost ? 0.3 : 1,
|
|
156
|
+
depthWrite: !ghost,
|
|
157
|
+
flatShading: true,
|
|
158
|
+
// Every face is pushed back a little, so the outline drawn on it wins the depth test
|
|
159
|
+
// cleanly instead of stippling into a dashed line. The floor finish sits a few millimetres
|
|
160
|
+
// under every footprint: pushed back further, so a flat footprint never fights it in
|
|
161
|
+
// perspective.
|
|
162
|
+
polygonOffset: true,
|
|
163
|
+
polygonOffsetFactor: 1,
|
|
164
|
+
polygonOffsetUnits: flatLaid ? 4 : 1
|
|
165
|
+
});
|
|
166
|
+
owned.push(geo, mat);
|
|
167
|
+
g.add(new Mesh(geo, mat));
|
|
168
|
+
if (n.kind !== "slab" && !glass && edged) {
|
|
169
|
+
const edges = new EdgesGeometry(geo, 30);
|
|
170
|
+
const line = new LineBasicMaterial({ color: new Color(theme.edge) });
|
|
171
|
+
owned.push(edges, line);
|
|
172
|
+
g.add(new LineSegments(edges, line));
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const attr = new BufferAttribute(pos, 3);
|
|
176
|
+
if (n.groups) {
|
|
177
|
+
let at = 0;
|
|
178
|
+
for (const { slot, count } of n.groups) {
|
|
179
|
+
const run = n.indices.slice(at, at + count);
|
|
180
|
+
at += count;
|
|
181
|
+
if (slot === "body") add(attr, run, theme.colors[key2] ?? furniture, false, 1, false);
|
|
182
|
+
else {
|
|
183
|
+
const { alpha } = PALETTE[slot];
|
|
184
|
+
add(attr, run, slotColour(slot, p.theme, furniture), alpha < 1, alpha, false);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
} else if (n.finish) {
|
|
188
|
+
add(attr, n.indices, finishColour(n.finish, p.theme, THEMES.dark.colors.floor), false, 1, true);
|
|
189
|
+
} else if (key2 === "wall") {
|
|
190
|
+
const atTop = (v) => n.positions[v * 3 + 1] / 1e3 === topY;
|
|
191
|
+
const cap = [];
|
|
192
|
+
const body = [];
|
|
193
|
+
for (let i = 0; i < n.indices.length; i += 3) {
|
|
194
|
+
const tri = n.indices.slice(i, i + 3);
|
|
195
|
+
(tri.every(atTop) ? cap : body).push(...tri);
|
|
196
|
+
}
|
|
197
|
+
add(attr, body, theme.colors.wall ?? furniture, false, 1, true);
|
|
198
|
+
if (cap.length) add(attr, cap, theme.cap, false, 1, true, false);
|
|
199
|
+
} else {
|
|
200
|
+
const glass = key2 === "window:glass";
|
|
201
|
+
add(attr, n.indices, theme.colors[key2] ?? furniture, glass, glass ? KIND_PALETTE["window:glass"].alpha : 1, true);
|
|
157
202
|
}
|
|
158
203
|
g.visible = false;
|
|
159
204
|
scene.add(g);
|
|
@@ -192,8 +237,8 @@ function mountReplay(out, p, strip) {
|
|
|
192
237
|
if (disposed) return;
|
|
193
238
|
if (strip && p.facts) paintStrip(strip, stripAt(p.facts, p.events, Math.min(1, Math.max(0, t))));
|
|
194
239
|
const s = stateAt(p.events, t);
|
|
195
|
-
for (const [
|
|
196
|
-
const st = s.nodes.get(
|
|
240
|
+
for (const [key2, { g, flat }] of nodes) {
|
|
241
|
+
const st = s.nodes.get(key2);
|
|
197
242
|
g.visible = st?.visible === true;
|
|
198
243
|
g.scale.y = Math.max(flat, st?.rise ?? 0);
|
|
199
244
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
FLOOR_FINISHES,
|
|
2
3
|
endElevation,
|
|
3
4
|
explodeLifts,
|
|
5
|
+
slotGroups,
|
|
4
6
|
storeysOf,
|
|
5
7
|
timeline
|
|
6
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EYEEIS4R.js";
|
|
7
9
|
|
|
8
10
|
// src/replay/payload.ts
|
|
9
11
|
var PREVIEW_LABEL = "Preview \u2014 from the separate archlang-3d package. ArchLang itself draws plans.";
|
|
@@ -28,19 +30,29 @@ function replayPayload(mesh, opts) {
|
|
|
28
30
|
nodes: mesh.nodes.filter((n) => !n.hidden).map((n) => {
|
|
29
31
|
const positions = [];
|
|
30
32
|
const indices = [];
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const slotted = n.shells.some((s) => s.slot !== void 0);
|
|
34
|
+
const groups = slotted ? slotGroups(n.shells) : [{ slot: "body", shells: n.shells }];
|
|
35
|
+
const runs = [];
|
|
36
|
+
for (const g of groups) {
|
|
37
|
+
const start = indices.length;
|
|
38
|
+
for (const s of g.shells) {
|
|
39
|
+
const base = positions.length / 3;
|
|
40
|
+
positions.push(...s.positions);
|
|
41
|
+
for (const i of s.indices) indices.push(base + i);
|
|
42
|
+
}
|
|
43
|
+
runs.push({ slot: g.slot, count: indices.length - start });
|
|
35
44
|
}
|
|
36
45
|
const lift = lifts.get(n.level) ?? 0;
|
|
46
|
+
const finish = FLOOR_FINISHES.find((f) => f === n.extras.finish);
|
|
37
47
|
return {
|
|
38
48
|
key: n.key,
|
|
39
49
|
kind: n.kind,
|
|
40
50
|
...n.part ? { part: n.part } : {},
|
|
41
51
|
...lift !== 0 ? { lift } : {},
|
|
42
52
|
positions,
|
|
43
|
-
indices
|
|
53
|
+
indices,
|
|
54
|
+
...slotted ? { groups: runs } : {},
|
|
55
|
+
...n.kind === "floor" && finish ? { finish } : {}
|
|
44
56
|
};
|
|
45
57
|
}),
|
|
46
58
|
events: timeline(mesh)
|