@chanmeng666/archlang-3d 0.8.1 → 0.9.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/CHANGELOG.md +36 -0
- package/README.md +19 -0
- package/THIRD_PARTY_NOTICES +1 -1
- package/dist/browser.d.ts +4 -3
- package/dist/browser.js +14 -11
- package/dist/{camera-BAsRq_eC.d.ts → camera-BqK_JhhV.d.ts} +1 -1
- package/dist/{chunk-33J3YGNF.js → chunk-42XZPE7C.js} +2303 -285
- package/dist/{chunk-VMVKI2WQ.js → chunk-6EAHOIL6.js} +7 -5
- package/dist/chunk-E65Z5S4K.js +225 -0
- package/dist/{chunk-LNIVDMPG.js → chunk-EL4456GB.js} +1 -273
- package/dist/chunk-ISFIFLC7.js +25 -0
- package/dist/chunk-LTMZVJIM.js +4992 -0
- package/dist/chunk-ONUOWO37.js +251 -0
- package/dist/{chunk-JQTG6BDR.js → chunk-PKFGND2A.js} +7 -3
- package/dist/{chunk-WOEJKIXN.js → chunk-UFY6MZNL.js} +22 -147
- package/dist/chunk-YUI76V23.js +6 -0
- package/dist/cli.js +13 -8
- package/dist/{facts-CsO0xtFw.d.ts → facts-DGA14BcU.d.ts} +1 -1
- package/dist/glb-BxaVYFWv.d.ts +37 -0
- package/dist/glb.d.ts +3 -0
- package/dist/glb.js +18 -0
- package/dist/index.d.ts +8 -5
- package/dist/index.js +58 -54
- package/dist/node.d.ts +7 -38
- package/dist/node.js +16 -12
- package/dist/payload-CKSLN1CG.d.ts +358 -0
- package/dist/replay.d.ts +2 -1
- package/dist/{payload-DwiB2P7x.d.ts → types-BQ7xE4YH.d.ts} +3 -358
- package/package.json +7 -1
- package/dist/chunk-CYSES7C3.js +0 -2276
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// src/materials.ts
|
|
2
|
+
var MATERIAL_SLOTS = [
|
|
3
|
+
"body",
|
|
4
|
+
"wood",
|
|
5
|
+
"wood_dark",
|
|
6
|
+
"fabric",
|
|
7
|
+
"cushion",
|
|
8
|
+
"linen",
|
|
9
|
+
"wool",
|
|
10
|
+
"ceramic",
|
|
11
|
+
"stone",
|
|
12
|
+
"metal",
|
|
13
|
+
"glass",
|
|
14
|
+
"appliance",
|
|
15
|
+
"screen",
|
|
16
|
+
"paint",
|
|
17
|
+
"rubber",
|
|
18
|
+
"foliage",
|
|
19
|
+
"bark",
|
|
20
|
+
"soil",
|
|
21
|
+
"water"
|
|
22
|
+
];
|
|
23
|
+
var m = (srgb, roughness, metallic = 0, alpha = 1) => ({
|
|
24
|
+
srgb,
|
|
25
|
+
alpha,
|
|
26
|
+
metallic,
|
|
27
|
+
roughness
|
|
28
|
+
});
|
|
29
|
+
var PALETTE = {
|
|
30
|
+
wood: m("#c6a785", 0.75),
|
|
31
|
+
wood_dark: m("#7b5b44", 0.7),
|
|
32
|
+
fabric: m("#968f85", 0.95),
|
|
33
|
+
cushion: m("#bfb7ab", 0.95),
|
|
34
|
+
linen: m("#f3efe7", 0.9),
|
|
35
|
+
wool: m("#a7ac98", 1),
|
|
36
|
+
ceramic: m("#f6f4f0", 0.25),
|
|
37
|
+
stone: m("#d8d4cc", 0.45),
|
|
38
|
+
metal: m("#aeb2b4", 0.35, 1),
|
|
39
|
+
glass: m("#c9dee6", 0.05, 0, 0.35),
|
|
40
|
+
appliance: m("#dcdcd8", 0.35),
|
|
41
|
+
screen: m("#2e3033", 0.2),
|
|
42
|
+
paint: m("#a9b1a2", 0.6),
|
|
43
|
+
rubber: m("#3b3b3b", 0.9),
|
|
44
|
+
foliage: m("#8c9b78", 0.9),
|
|
45
|
+
bark: m("#6f5b49", 0.9),
|
|
46
|
+
soil: m("#5f4b3b", 1),
|
|
47
|
+
water: m("#a3c6d0", 0.1, 0, 0.7)
|
|
48
|
+
};
|
|
49
|
+
var STAIR_MATERIAL = "wood";
|
|
50
|
+
var STAIR_RAIL_MATERIAL = "wood_dark";
|
|
51
|
+
var DOOR_OAK = m("#c2a27e", 0.7);
|
|
52
|
+
var FRAME_BRONZE = m("#55534f", 0.5);
|
|
53
|
+
var KIND_PALETTE = {
|
|
54
|
+
slab: m("#bdb6ab", 0.9),
|
|
55
|
+
column: m("#e6e1d8", 0.85),
|
|
56
|
+
wall: m("#f2f0eb", 0.9),
|
|
57
|
+
door: DOOR_OAK,
|
|
58
|
+
"window:frame": FRAME_BRONZE,
|
|
59
|
+
"window:glass": m("#bcd6e0", 0.05, 0, 0.4),
|
|
60
|
+
// The trim (card RM8.6): a window's reveal in its frame's bronze, its exterior sill in the pale
|
|
61
|
+
// stone and its interior board in the oak of the palette; a cased opening's lining and casing in
|
|
62
|
+
// the doors' oak (a door's own lining and casing are `door`). Drafting defaults, ledgered once per
|
|
63
|
+
// Mesh3D as `trim-material-default` from `TRIM_MATERIAL`.
|
|
64
|
+
"window:reveal": FRAME_BRONZE,
|
|
65
|
+
"window:sill": PALETTE.stone,
|
|
66
|
+
"window:board": PALETTE.wood,
|
|
67
|
+
"opening:lining": DOOR_OAK,
|
|
68
|
+
"opening:casing": DOOR_OAK,
|
|
69
|
+
opening: m("#e6e1d8", 0.85),
|
|
70
|
+
furniture: m("#d6cec1", 0.9),
|
|
71
|
+
roof: m("#9c958a", 0.9),
|
|
72
|
+
"wall:demolish": m("#c8553d", 0.9, 0, 0.3),
|
|
73
|
+
// A stair (card X3): the core gives it no material, so the ledgered default (`STAIR_MATERIAL`,
|
|
74
|
+
// `stair-material-default`): that slot's own entry, never a second copy of its colour.
|
|
75
|
+
stair: PALETTE[STAIR_MATERIAL],
|
|
76
|
+
"stair:rail": PALETTE[STAIR_RAIL_MATERIAL]
|
|
77
|
+
};
|
|
78
|
+
var TRIM_MATERIAL = {
|
|
79
|
+
"door:lining": { material: "door", srgb: KIND_PALETTE.door.srgb },
|
|
80
|
+
"door:casing": { material: "door", srgb: KIND_PALETTE.door.srgb },
|
|
81
|
+
"opening:lining": { material: "opening:lining", srgb: KIND_PALETTE["opening:lining"].srgb },
|
|
82
|
+
"opening:casing": { material: "opening:casing", srgb: KIND_PALETTE["opening:casing"].srgb },
|
|
83
|
+
"window:reveal": { material: "window:reveal", srgb: KIND_PALETTE["window:reveal"].srgb },
|
|
84
|
+
"window:sill": { material: "window:sill", srgb: KIND_PALETTE["window:sill"].srgb },
|
|
85
|
+
"window:board": { material: "window:board", srgb: KIND_PALETTE["window:board"].srgb }
|
|
86
|
+
};
|
|
87
|
+
var WALL_CAP_SRGB = "#8f877d";
|
|
88
|
+
var FLOOR_FINISHES = [
|
|
89
|
+
"timber",
|
|
90
|
+
"tile",
|
|
91
|
+
"neutral",
|
|
92
|
+
"carpeting",
|
|
93
|
+
"stone",
|
|
94
|
+
"deck",
|
|
95
|
+
"paving",
|
|
96
|
+
"concrete"
|
|
97
|
+
];
|
|
98
|
+
var FINISH_PALETTE = {
|
|
99
|
+
timber: m("#cdb596", 0.6),
|
|
100
|
+
tile: m("#e3e1db", 0.35),
|
|
101
|
+
neutral: m("#e8e2d7", 0.9),
|
|
102
|
+
carpeting: PALETTE.wool,
|
|
103
|
+
stone: PALETTE.stone,
|
|
104
|
+
deck: PALETTE.wood,
|
|
105
|
+
paving: m("#ab9f87", 0.85),
|
|
106
|
+
concrete: m("#c9c5be", 0.6)
|
|
107
|
+
};
|
|
108
|
+
var FLOOR_WORD_FINISH = {
|
|
109
|
+
tile: "tile",
|
|
110
|
+
paving: "paving",
|
|
111
|
+
deck: "deck",
|
|
112
|
+
concrete: "concrete",
|
|
113
|
+
timber: "timber",
|
|
114
|
+
carpeting: "carpeting",
|
|
115
|
+
stone: "stone"
|
|
116
|
+
};
|
|
117
|
+
function wordFinish(word) {
|
|
118
|
+
return word !== void 0 && Object.hasOwn(FLOOR_WORD_FINISH, word) ? FLOOR_WORD_FINISH[word] : void 0;
|
|
119
|
+
}
|
|
120
|
+
var FLOOR_FINISH_RULES = [
|
|
121
|
+
["tile", ["bath", "wc", "utility"]],
|
|
122
|
+
["timber", ["living", "dining", "bedroom", "office", "hall", "circulation"]],
|
|
123
|
+
["tile", ["kitchen", "entry"]]
|
|
124
|
+
];
|
|
125
|
+
function floorFinish(uses) {
|
|
126
|
+
for (const [finish, kinds] of FLOOR_FINISH_RULES) if (uses?.some((u) => kinds.includes(u))) return finish;
|
|
127
|
+
return "neutral";
|
|
128
|
+
}
|
|
129
|
+
var GROUND_TINT = {
|
|
130
|
+
lawn: "lawn",
|
|
131
|
+
planting: "lawn",
|
|
132
|
+
paving: "paving",
|
|
133
|
+
deck: "paving",
|
|
134
|
+
gravel: "paving",
|
|
135
|
+
water: "water",
|
|
136
|
+
driveway: "paving",
|
|
137
|
+
patio: "paving",
|
|
138
|
+
balcony: "paving",
|
|
139
|
+
sand: "paving",
|
|
140
|
+
soil: "paving"
|
|
141
|
+
};
|
|
142
|
+
var GROUND_WASH = 6;
|
|
143
|
+
var SITE_PALETTE = {
|
|
144
|
+
gravel: m("#cbc3b4", 0.95),
|
|
145
|
+
tarmac: m("#8c8984", 0.85),
|
|
146
|
+
sand: m("#dcc9a3", 0.95)
|
|
147
|
+
};
|
|
148
|
+
var GROUND_SPLITS = {
|
|
149
|
+
planting: PALETTE.foliage,
|
|
150
|
+
deck: PALETTE.wood,
|
|
151
|
+
gravel: SITE_PALETTE.gravel,
|
|
152
|
+
driveway: SITE_PALETTE.tarmac,
|
|
153
|
+
sand: SITE_PALETTE.sand,
|
|
154
|
+
soil: PALETTE.soil
|
|
155
|
+
};
|
|
156
|
+
var GROUND_ROUGHNESS = { lawn: 0.95, paving: 0.85, water: 0.1 };
|
|
157
|
+
var FENCE_PALETTE = {
|
|
158
|
+
picket: m("#eeebe4", 0.8),
|
|
159
|
+
panel: PALETTE.wood,
|
|
160
|
+
post: PALETTE.wood_dark
|
|
161
|
+
};
|
|
162
|
+
var GROUND_PLANE = { light: "#e2ddd3", dark: "#16293d", marginMm: 6e3 };
|
|
163
|
+
var CONTACT_SHADOW = {
|
|
164
|
+
wall: { of: 0.75, minMm: 80, maxMm: 200 },
|
|
165
|
+
furniture: { of: 0.12, minMm: 30, maxMm: 120 },
|
|
166
|
+
fence: { of: 1.5, minMm: 40, maxMm: 120 },
|
|
167
|
+
stairThicknessMm: 100,
|
|
168
|
+
alpha: { floor: 0.2, corner: 0.12, furniture: 0.18 },
|
|
169
|
+
alphaDark: { floor: 0.3, corner: 0.18, furniture: 0.27 },
|
|
170
|
+
liftMm: 1
|
|
171
|
+
};
|
|
172
|
+
function contactBandMm(rule, size) {
|
|
173
|
+
return Math.min(rule.maxMm, Math.max(rule.minMm, Math.round(rule.of * size)));
|
|
174
|
+
}
|
|
175
|
+
function siteColour(own, theme, toward) {
|
|
176
|
+
if (theme === "light") return own;
|
|
177
|
+
const mix = (i) => {
|
|
178
|
+
const a = Number.parseInt(own.slice(i, i + 2), 16);
|
|
179
|
+
const b = Number.parseInt(toward.slice(i, i + 2), 16);
|
|
180
|
+
return Math.round(a * 0.4 + b * 0.6).toString(16).padStart(2, "0");
|
|
181
|
+
};
|
|
182
|
+
return `#${mix(1)}${mix(3)}${mix(5)}`;
|
|
183
|
+
}
|
|
184
|
+
function linearRgb(hex) {
|
|
185
|
+
const ch = (i) => {
|
|
186
|
+
const c = Number.parseInt(hex.slice(i, i + 2), 16) / 255;
|
|
187
|
+
const v = c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
188
|
+
return Math.round(v * 1e4) / 1e4;
|
|
189
|
+
};
|
|
190
|
+
return [ch(1), ch(3), ch(5)];
|
|
191
|
+
}
|
|
192
|
+
function slotColour(slot, theme, furniture) {
|
|
193
|
+
const own = PALETTE[slot].srgb;
|
|
194
|
+
if (theme === "light") return own;
|
|
195
|
+
const mix = (i) => {
|
|
196
|
+
const a = Number.parseInt(own.slice(i, i + 2), 16);
|
|
197
|
+
const b = Number.parseInt(furniture.slice(i, i + 2), 16);
|
|
198
|
+
return Math.round(a * 0.4 + b * 0.6).toString(16).padStart(2, "0");
|
|
199
|
+
};
|
|
200
|
+
return `#${mix(1)}${mix(3)}${mix(5)}`;
|
|
201
|
+
}
|
|
202
|
+
function finishColour(finish, theme, floor) {
|
|
203
|
+
const own = FINISH_PALETTE[finish].srgb;
|
|
204
|
+
if (theme === "light") return own;
|
|
205
|
+
const mix = (i) => {
|
|
206
|
+
const a = Number.parseInt(own.slice(i, i + 2), 16);
|
|
207
|
+
const b = Number.parseInt(floor.slice(i, i + 2), 16);
|
|
208
|
+
return Math.round(a * 0.4 + b * 0.6).toString(16).padStart(2, "0");
|
|
209
|
+
};
|
|
210
|
+
return `#${mix(1)}${mix(3)}${mix(5)}`;
|
|
211
|
+
}
|
|
212
|
+
function slotGroups(shells) {
|
|
213
|
+
const by = /* @__PURE__ */ new Map();
|
|
214
|
+
for (const s of shells) {
|
|
215
|
+
const k = s.slot ?? "body";
|
|
216
|
+
const g = by.get(k);
|
|
217
|
+
if (g) g.push(s);
|
|
218
|
+
else by.set(k, [s]);
|
|
219
|
+
}
|
|
220
|
+
return MATERIAL_SLOTS.filter((k) => by.has(k)).map((slot) => ({ slot, shells: by.get(slot) }));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export {
|
|
224
|
+
MATERIAL_SLOTS,
|
|
225
|
+
PALETTE,
|
|
226
|
+
STAIR_MATERIAL,
|
|
227
|
+
STAIR_RAIL_MATERIAL,
|
|
228
|
+
KIND_PALETTE,
|
|
229
|
+
TRIM_MATERIAL,
|
|
230
|
+
WALL_CAP_SRGB,
|
|
231
|
+
FLOOR_FINISHES,
|
|
232
|
+
FINISH_PALETTE,
|
|
233
|
+
FLOOR_WORD_FINISH,
|
|
234
|
+
wordFinish,
|
|
235
|
+
FLOOR_FINISH_RULES,
|
|
236
|
+
floorFinish,
|
|
237
|
+
GROUND_TINT,
|
|
238
|
+
GROUND_WASH,
|
|
239
|
+
SITE_PALETTE,
|
|
240
|
+
GROUND_SPLITS,
|
|
241
|
+
GROUND_ROUGHNESS,
|
|
242
|
+
FENCE_PALETTE,
|
|
243
|
+
GROUND_PLANE,
|
|
244
|
+
CONTACT_SHADOW,
|
|
245
|
+
contactBandMm,
|
|
246
|
+
siteColour,
|
|
247
|
+
linearRgb,
|
|
248
|
+
slotColour,
|
|
249
|
+
finishColour,
|
|
250
|
+
slotGroups
|
|
251
|
+
};
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
C16,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
S16
|
|
4
|
+
} from "./chunk-ISFIFLC7.js";
|
|
5
|
+
import {
|
|
5
6
|
ease
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-EL4456GB.js";
|
|
8
|
+
import {
|
|
9
|
+
CONTACT_SHADOW
|
|
10
|
+
} from "./chunk-ONUOWO37.js";
|
|
7
11
|
|
|
8
12
|
// src/replay/wall-lines.ts
|
|
9
13
|
function takesWallLines(n) {
|
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
-
ARCHLANG_3D_VERSION,
|
|
3
2
|
validateScene3D
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-E65Z5S4K.js";
|
|
5
4
|
import {
|
|
6
5
|
PREVIEW_LABEL,
|
|
7
6
|
PREVIEW_LIMITS,
|
|
8
7
|
VIEW_CONTROLS_LABEL,
|
|
9
8
|
noticeLevelLabel,
|
|
10
9
|
replayPayload
|
|
11
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6EAHOIL6.js";
|
|
12
11
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
GROUND_TINT,
|
|
19
|
-
KIND_PALETTE,
|
|
20
|
-
PALETTE,
|
|
21
|
-
keyFrames,
|
|
22
|
-
linearRgb,
|
|
23
|
-
slotGroups
|
|
24
|
-
} from "./chunk-LNIVDMPG.js";
|
|
12
|
+
keyFrames
|
|
13
|
+
} from "./chunk-EL4456GB.js";
|
|
14
|
+
import {
|
|
15
|
+
readGlbNodes
|
|
16
|
+
} from "./chunk-LTMZVJIM.js";
|
|
25
17
|
|
|
26
18
|
// src/world.ts
|
|
27
19
|
import { readFileSync, realpathSync, statSync } from "node:fs";
|
|
@@ -235,16 +227,23 @@ function withSupersample(html, k = 1) {
|
|
|
235
227
|
const json = JSON.stringify({ ...p, supersample: k }).replace(/</g, "\\u003c");
|
|
236
228
|
return html.slice(0, at + PAYLOAD_OPEN.length) + json + html.slice(end);
|
|
237
229
|
}
|
|
230
|
+
function removeScratch(dir) {
|
|
231
|
+
try {
|
|
232
|
+
rmSync(dir, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });
|
|
233
|
+
} catch {
|
|
234
|
+
}
|
|
235
|
+
}
|
|
238
236
|
async function renderReplay(o) {
|
|
239
237
|
const fps = o.fps ?? 30;
|
|
240
238
|
const seconds = o.seconds ?? 15;
|
|
241
239
|
const frames = Math.round(fps * seconds);
|
|
242
240
|
const dir = mkdtempSync(join2(tmpdir(), "archlang3d-replay-"));
|
|
243
|
-
|
|
244
|
-
writeFileSync(file, seekOnly(withSupersample(o.html, o.supersample)));
|
|
245
|
-
const { chromium } = await import("playwright-core");
|
|
246
|
-
const browser = await chromium.launch({ args: SWIFTSHADER_ARGS });
|
|
241
|
+
let browser;
|
|
247
242
|
try {
|
|
243
|
+
const file = join2(dir, "replay.html");
|
|
244
|
+
writeFileSync(file, seekOnly(withSupersample(o.html, o.supersample)));
|
|
245
|
+
const { chromium } = await import("playwright-core");
|
|
246
|
+
browser = await chromium.launch({ args: SWIFTSHADER_ARGS });
|
|
248
247
|
const page = await browser.newPage({
|
|
249
248
|
viewport: { width: o.width + 40, height: o.height + 120 },
|
|
250
249
|
deviceScaleFactor: 1
|
|
@@ -352,129 +351,12 @@ async function renderReplay(o) {
|
|
|
352
351
|
browser: browser.version()
|
|
353
352
|
};
|
|
354
353
|
} finally {
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
// src/glb/write.ts
|
|
361
|
-
import { Document, Logger, WebIO } from "@gltf-transform/core";
|
|
362
|
-
var GLB_GENERATOR = `archlang-3d ${ARCHLANG_3D_VERSION}`;
|
|
363
|
-
function bodyMaterialName(n) {
|
|
364
|
-
if (n.kind === "floor") return `floor:${FLOOR_FINISHES.find((f) => f === n.extras.finish) ?? "neutral"}`;
|
|
365
|
-
if (n.kind === "wall" && n.part === "demolish") return "wall:demolish";
|
|
366
|
-
if (n.kind === "window" && n.part && `window:${n.part}` in KIND_PALETTE) return `window:${n.part}`;
|
|
367
|
-
if ((n.kind === "opening" || n.kind === "stair") && n.part && `${n.kind}:${n.part}` in KIND_PALETTE)
|
|
368
|
-
return `${n.kind}:${n.part}`;
|
|
369
|
-
if (n.kind === "outdoor") return `outdoor:${String(n.extras.surface)}`;
|
|
370
|
-
if (n.kind === "fence") return `fence:${String(n.extras.style)}`;
|
|
371
|
-
return n.kind;
|
|
372
|
-
}
|
|
373
|
-
function bodyMaterial(name, n) {
|
|
374
|
-
if (n.kind === "outdoor" || n.kind === "fence") {
|
|
375
|
-
const own = n.kind === "fence" ? FENCE_PALETTE[String(n.extras.style)] : GROUND_SPLITS[String(n.extras.surface)];
|
|
376
|
-
const tint = GROUND_TINT[String(n.extras.surface)] ?? "paving";
|
|
377
|
-
const roughness = own?.roughness ?? (n.kind === "fence" ? FENCE_PALETTE.picket.roughness : GROUND_ROUGHNESS[tint]);
|
|
378
|
-
const srgb = typeof n.extras.colour === "string" ? n.extras.colour : KIND_PALETTE.furniture.srgb;
|
|
379
|
-
return { srgb, alpha: 1, metallic: 0, roughness };
|
|
380
|
-
}
|
|
381
|
-
if (name.startsWith("floor:")) return FINISH_PALETTE[name.slice("floor:".length)];
|
|
382
|
-
return KIND_PALETTE[name] ?? KIND_PALETTE.furniture;
|
|
383
|
-
}
|
|
384
|
-
var glbNodeName = (n) => n.key.slice(n.key.indexOf("/") + 1);
|
|
385
|
-
var levelNodeName = (level) => `level:L${level}`;
|
|
386
|
-
function nodeExtras(n) {
|
|
387
|
-
const own = Object.keys(n.extras).sort().map((k) => [k, n.extras[k]]);
|
|
388
|
-
return {
|
|
389
|
-
key: n.key,
|
|
390
|
-
kind: n.kind,
|
|
391
|
-
id: n.id,
|
|
392
|
-
...n.part ? { part: n.part } : {},
|
|
393
|
-
level: n.level,
|
|
394
|
-
stage: n.stage,
|
|
395
|
-
order: n.order,
|
|
396
|
-
...n.hidden ? { hidden: true } : {},
|
|
397
|
-
...Object.fromEntries(own)
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
async function writeGlb(mesh, opts = {}) {
|
|
401
|
-
const doc = new Document();
|
|
402
|
-
doc.setLogger(new Logger(Logger.Verbosity.SILENT));
|
|
403
|
-
doc.getRoot().getAsset().generator = opts.generator ?? GLB_GENERATOR;
|
|
404
|
-
const buffer = doc.createBuffer();
|
|
405
|
-
const scene = doc.createScene(mesh.name);
|
|
406
|
-
doc.getRoot().setDefaultScene(scene);
|
|
407
|
-
const materials = /* @__PURE__ */ new Map();
|
|
408
|
-
const material = (n) => {
|
|
409
|
-
const key = bodyMaterialName(n);
|
|
410
|
-
let m = materials.get(key);
|
|
411
|
-
if (!m) {
|
|
412
|
-
const p = bodyMaterial(key, n);
|
|
413
|
-
m = doc.createMaterial(key).setBaseColorFactor([...linearRgb(p.srgb), p.alpha]).setMetallicFactor(p.metallic).setRoughnessFactor(p.roughness);
|
|
414
|
-
if (p.alpha < 1) m.setAlphaMode("BLEND");
|
|
415
|
-
materials.set(key, m);
|
|
416
|
-
}
|
|
417
|
-
return m;
|
|
418
|
-
};
|
|
419
|
-
const slotMaterial = (slot) => {
|
|
420
|
-
const key = `fixture:${slot}`;
|
|
421
|
-
let m = materials.get(key);
|
|
422
|
-
if (!m) {
|
|
423
|
-
const p = PALETTE[slot];
|
|
424
|
-
m = doc.createMaterial(key).setBaseColorFactor([...linearRgb(p.srgb), p.alpha]).setMetallicFactor(p.metallic).setRoughnessFactor(p.roughness);
|
|
425
|
-
if (p.alpha < 1) m.setAlphaMode("BLEND");
|
|
426
|
-
materials.set(key, m);
|
|
427
|
-
}
|
|
428
|
-
return m;
|
|
429
|
-
};
|
|
430
|
-
const levels = /* @__PURE__ */ new Map();
|
|
431
|
-
for (const n of mesh.nodes) {
|
|
432
|
-
let group = levels.get(n.level);
|
|
433
|
-
if (!group) {
|
|
434
|
-
group = doc.createNode(levelNodeName(n.level)).setExtras({ archlang: { kind: "level", level: n.level } });
|
|
435
|
-
scene.addChild(group);
|
|
436
|
-
levels.set(n.level, group);
|
|
437
|
-
}
|
|
438
|
-
const name = glbNodeName(n);
|
|
439
|
-
const gmesh = doc.createMesh(name);
|
|
440
|
-
for (const g of slotGroups(n.shells)) {
|
|
441
|
-
const positions = [];
|
|
442
|
-
const indices = [];
|
|
443
|
-
for (const s of g.shells) {
|
|
444
|
-
const base = positions.length / 3;
|
|
445
|
-
for (const v of s.positions) positions.push(v / 1e6);
|
|
446
|
-
for (const i of s.indices) indices.push(base + i);
|
|
447
|
-
}
|
|
448
|
-
const count = positions.length / 3;
|
|
449
|
-
const pos = doc.createAccessor().setType("VEC3").setArray(new Float32Array(positions)).setBuffer(buffer);
|
|
450
|
-
const idx = doc.createAccessor().setType("SCALAR").setArray(count > 65535 ? new Uint32Array(indices) : new Uint16Array(indices)).setBuffer(buffer);
|
|
451
|
-
const mat = g.slot === "body" ? material(n) : slotMaterial(g.slot);
|
|
452
|
-
gmesh.addPrimitive(doc.createPrimitive().setAttribute("POSITION", pos).setIndices(idx).setMaterial(mat));
|
|
453
|
-
}
|
|
454
|
-
const node = doc.createNode(name).setMesh(gmesh).setExtras({ archlang: nodeExtras(n) });
|
|
455
|
-
group.addChild(node);
|
|
456
|
-
}
|
|
457
|
-
return new WebIO().writeBinary(doc);
|
|
458
|
-
}
|
|
459
|
-
async function readGlbNodes(glb) {
|
|
460
|
-
const doc = await new WebIO().readBinary(glb);
|
|
461
|
-
const levels = [];
|
|
462
|
-
const nodes = [];
|
|
463
|
-
const walk = (parent, prefix) => {
|
|
464
|
-
for (const c of parent.listChildren()) {
|
|
465
|
-
const extras = c.getExtras().archlang ?? {};
|
|
466
|
-
nodes.push({ key: `${prefix}${c.getName()}`, name: c.getName(), extras });
|
|
467
|
-
walk(c, prefix);
|
|
468
|
-
}
|
|
469
|
-
};
|
|
470
|
-
for (const scene of doc.getRoot().listScenes()) {
|
|
471
|
-
for (const group of scene.listChildren()) {
|
|
472
|
-
const lv = group.getName();
|
|
473
|
-
levels.push(lv);
|
|
474
|
-
walk(group, lv.startsWith("level:") ? `${lv.slice("level:".length)}/` : "");
|
|
354
|
+
try {
|
|
355
|
+
await browser?.close();
|
|
356
|
+
} finally {
|
|
357
|
+
removeScratch(dir);
|
|
475
358
|
}
|
|
476
359
|
}
|
|
477
|
-
return { levels, nodes };
|
|
478
360
|
}
|
|
479
361
|
|
|
480
362
|
// src/check/verify.ts
|
|
@@ -609,13 +491,6 @@ export {
|
|
|
609
491
|
replayHtml,
|
|
610
492
|
SWIFTSHADER_ARGS,
|
|
611
493
|
renderReplay,
|
|
612
|
-
GLB_GENERATOR,
|
|
613
|
-
bodyMaterialName,
|
|
614
|
-
glbNodeName,
|
|
615
|
-
levelNodeName,
|
|
616
|
-
nodeExtras,
|
|
617
|
-
writeGlb,
|
|
618
|
-
readGlbNodes,
|
|
619
494
|
openEdges,
|
|
620
495
|
signedVolume,
|
|
621
496
|
checkScene,
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
+
ARCHLANG_3D_VERSION,
|
|
3
4
|
DOOR_POSES,
|
|
4
5
|
adaptPlan,
|
|
5
6
|
buildMesh
|
|
6
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-42XZPE7C.js";
|
|
8
|
+
import "./chunk-ISFIFLC7.js";
|
|
7
9
|
import {
|
|
8
10
|
SWIFTSHADER_ARGS,
|
|
9
11
|
checkGlb,
|
|
@@ -11,20 +13,23 @@ import {
|
|
|
11
13
|
checkShells,
|
|
12
14
|
makeNodeWorld,
|
|
13
15
|
renderReplay,
|
|
14
|
-
replayHtml
|
|
15
|
-
|
|
16
|
-
} from "./chunk-WOEJKIXN.js";
|
|
16
|
+
replayHtml
|
|
17
|
+
} from "./chunk-UFY6MZNL.js";
|
|
17
18
|
import {
|
|
18
|
-
ARCHLANG_3D_VERSION,
|
|
19
19
|
replayFacts
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-E65Z5S4K.js";
|
|
21
|
+
import "./chunk-6EAHOIL6.js";
|
|
22
22
|
import {
|
|
23
23
|
storeysOf,
|
|
24
24
|
timeline,
|
|
25
25
|
viewLabel,
|
|
26
26
|
viewMesh
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-EL4456GB.js";
|
|
28
|
+
import {
|
|
29
|
+
writeGlb
|
|
30
|
+
} from "./chunk-LTMZVJIM.js";
|
|
31
|
+
import "./chunk-YUI76V23.js";
|
|
32
|
+
import "./chunk-ONUOWO37.js";
|
|
28
33
|
|
|
29
34
|
// src/cli/run.ts
|
|
30
35
|
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { World } from '@chanmeng666/archlang';
|
|
2
|
-
import {
|
|
2
|
+
import { b as ReplayView, c as ReplayFacts } from './payload-CKSLN1CG.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The metrics strip's numbers (card G4), read from the core's public `describe()` and `lint()` for
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { a as MeshNode, M as Mesh3D } from './types-BQ7xE4YH.js';
|
|
2
|
+
|
|
3
|
+
/** `asset.generator`: the package and its version (`ARCHLANG_3D_VERSION`), never a time (plan §3.7). */
|
|
4
|
+
declare const GLB_GENERATOR: string;
|
|
5
|
+
/**
|
|
6
|
+
* The material a node's untagged (`body`) shells are written in (visual-assets V9): a floor's finish
|
|
7
|
+
* (`floor:<finish>`, from `extras.finish`), a window's frame or glass, a demolished wall's ghost
|
|
8
|
+
* (`wall:demolish`, B3a), else its kind. Each reads the one palette the viewer reads (`materials.ts`).
|
|
9
|
+
*/
|
|
10
|
+
declare function bodyMaterialName(n: MeshNode): string;
|
|
11
|
+
/** The glTF node name of a Mesh3D node: its key without the storey prefix (plan §3.6). */
|
|
12
|
+
declare const glbNodeName: (n: MeshNode) => string;
|
|
13
|
+
/** The storey group node's name. */
|
|
14
|
+
declare const levelNodeName: (level: number) => string;
|
|
15
|
+
/** `extras.archlang` of a Mesh3D node: identity first, then the node's own facts, in a fixed key order. */
|
|
16
|
+
declare function nodeExtras(n: MeshNode): Record<string, string | number | boolean>;
|
|
17
|
+
/** The GLB of `mesh`: same Mesh3D and `generator`, same bytes. */
|
|
18
|
+
declare function writeGlb(mesh: Mesh3D, opts?: {
|
|
19
|
+
generator?: string;
|
|
20
|
+
}): Promise<Uint8Array>;
|
|
21
|
+
/** One node read back from a GLB: its global key (`L<n>/<name>`) and its `extras.archlang`. */
|
|
22
|
+
interface GlbNode {
|
|
23
|
+
key: string;
|
|
24
|
+
name: string;
|
|
25
|
+
extras: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The storey groups (each scene's root nodes) and every node below them at any depth, depth first
|
|
29
|
+
* in file order. This module writes element nodes one level under their group only, so a node
|
|
30
|
+
* nested deeper is reported too (and then named and diffed like any other), never skipped.
|
|
31
|
+
*/
|
|
32
|
+
declare function readGlbNodes(glb: Uint8Array): Promise<{
|
|
33
|
+
levels: string[];
|
|
34
|
+
nodes: GlbNode[];
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export { type GlbNode as G, GLB_GENERATOR as a, bodyMaterialName as b, glbNodeName as g, levelNodeName as l, nodeExtras as n, readGlbNodes as r, writeGlb as w };
|
package/dist/glb.d.ts
ADDED
package/dist/glb.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GLB_GENERATOR,
|
|
3
|
+
bodyMaterialName,
|
|
4
|
+
glbNodeName,
|
|
5
|
+
levelNodeName,
|
|
6
|
+
nodeExtras,
|
|
7
|
+
writeGlb
|
|
8
|
+
} from "./chunk-LTMZVJIM.js";
|
|
9
|
+
import "./chunk-YUI76V23.js";
|
|
10
|
+
import "./chunk-ONUOWO37.js";
|
|
11
|
+
export {
|
|
12
|
+
GLB_GENERATOR,
|
|
13
|
+
bodyMaterialName,
|
|
14
|
+
glbNodeName,
|
|
15
|
+
levelNodeName,
|
|
16
|
+
nodeExtras,
|
|
17
|
+
writeGlb
|
|
18
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import * as _chanmeng666_archlang from '@chanmeng666/archlang';
|
|
2
2
|
import { RWall, Point, JoinedCut, loopsToPolygons, ResolvedPlan, World, Diagnostic } from '@chanmeng666/archlang';
|
|
3
3
|
export { Point } from '@chanmeng666/archlang';
|
|
4
|
-
import {
|
|
5
|
-
export { C as CONTACT_SHADOW, D as DoorKind,
|
|
6
|
-
|
|
7
|
-
export {
|
|
4
|
+
import { c as Scene3D, e as Floor, P as Polygon, M as Mesh3D, f as Pt, d as Shell, R as Ring3, A as Assumption, O as Opening, L as Level, g as Side, h as Stair, i as StairFlight, j as StairLanding, b as MaterialSlot, k as Furniture, l as Fence, G as GroundTint } from './types-BQ7xE4YH.js';
|
|
5
|
+
export { C as CONTACT_SHADOW, D as DoorKind, m as FENCE_PALETTE, n as FINISH_PALETTE, o as FLOOR_FINISHES, p as FLOOR_FINISH_RULES, q as FLOOR_WORD_FINISH, F as FloorFinish, r as GROUND_PLANE, s as GROUND_ROUGHNESS, t as GROUND_SPLITS, u as GROUND_TINT, v as GROUND_WASH, K as KIND_PALETTE, w as KindMaterial, x as MATERIAL_SLOTS, a as MeshNode, y as Meta, N as NodeKind, z as Outdoor, B as PALETTE, E as Provenance, H as Roof, I as SITE_PALETTE, J as STAIR_MATERIAL, Q as STAIR_RAIL_MATERIAL, T as SlotMaterial, U as Source, S as Stage, V as TRIM_MATERIAL, W as Um, X as WALL_CAP_SRGB, Y as Wall, Z as contactBandMm, _ as finishColour, $ as floorFinish, a0 as linearRgb, a1 as siteColour, a2 as slotColour, a3 as slotGroups, a4 as wordFinish } from './types-BQ7xE4YH.js';
|
|
6
|
+
import { h as ReplayNode } from './payload-CKSLN1CG.js';
|
|
7
|
+
export { E as EXPLODE_GAP_MM, F as FIXTURE_FAMILIES, N as NodeState, j as PHASE, R as ReplayEvent, c as ReplayFacts, a as ReplayState, b as ReplayView, k as STOP_LEAD, S as StripItem, l as authoringOrder, m as ease, o as explodeLifts, p as keyFrames, q as stateAt, t as storeysOf, s as stripAt, u as timeline, w as viewLabel, x as viewMesh } from './payload-CKSLN1CG.js';
|
|
8
|
+
export { F as FactsOptions, r as replayFacts } from './facts-DGA14BcU.js';
|
|
9
|
+
export { B as Box, E as ELEVATION_AZIMUTH, a as ELEVATION_RANGE, b as END_AZIMUTH, c as END_FOV, d as EndCamera, F as FILL, e as FrameCamera, O as Orbit, f as PRESET_NAMES, P as PresetName, S as START_FOV, V as Vec3, g as ViewScene, Z as ZOOM, h as boxOfNodes, i as cameraAtStop, j as cameraStops, k as corners, l as coverage, m as distanceLimits, n as drawingFrame, o as endElevation, p as fitEndCamera, q as frameCamera, r as pivotAbove, s as presetCamera, t as projectBox, u as settledLift, v as stopCount, w as takenLens, x as targetBounds } from './camera-BqK_JhhV.js';
|
|
8
10
|
|
|
9
11
|
/** A ring of plan points (mm), as `loopsToPolygons` returns it: closed, no repeated vertex. */
|
|
10
12
|
type Ring = Point[];
|
|
@@ -620,7 +622,8 @@ type DomeTable = ReadonlyArray<readonly [number, number]>;
|
|
|
620
622
|
/**
|
|
621
623
|
* T0 parametric furniture (archlang-3d plan §4.4, §5.1–5.3; card A2b; visual-assets V1–V3,
|
|
622
624
|
* V5–V7): pure generators that build a piece from a few parts, fitted EXACTLY to the plan's
|
|
623
|
-
* footprint. The twelve families laneway-house
|
|
625
|
+
* footprint. The twelve families laneway-house first used are here (its chairs, since RM9.6, are
|
|
626
|
+
* `t0-living.ts`'s); the living, bedroom, dining and
|
|
624
627
|
* office batch is `t0-living.ts` (V5), the kitchen, bath and utility batch `t0-utility.ts` (V6),
|
|
625
628
|
* the site (planting, garden, vehicles, terrace, the small standing objects) `t0-outdoor.ts` and
|
|
626
629
|
* the office and commercial pieces `t0-office.ts` (V7). Every catalogued family is built; a word
|