@chanmeng666/archlang-3d 0.6.0 → 0.8.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 +100 -0
- package/README.md +4 -4
- package/dist/browser.d.ts +3 -5
- package/dist/browser.js +98 -475
- package/dist/{camera-DcyxtBjK.d.ts → camera-BAsRq_eC.d.ts} +1 -1
- package/dist/{chunk-6WCS4TAT.js → chunk-B4PZWWSP.js} +452 -37
- package/dist/{chunk-TNNJ7CAO.js → chunk-LNIVDMPG.js} +103 -9
- package/dist/{chunk-LMFD5NP4.js → chunk-MCASL4MM.js} +18 -7
- package/dist/chunk-MXKKNJPU.js +983 -0
- package/dist/{chunk-CX6IVI7I.js → chunk-VMVKI2WQ.js} +65 -3
- package/dist/chunk-WARUDAOQ.js +2276 -0
- package/dist/cli.js +12 -6
- package/dist/{facts-Dje5wcHh.d.ts → facts-CsO0xtFw.d.ts} +1 -1
- package/dist/index.d.ts +341 -37
- package/dist/index.js +36 -6
- package/dist/node.d.ts +23 -7
- package/dist/node.js +4 -4
- package/dist/{strip-CA-IAT0N.d.ts → payload-DwiB2P7x.d.ts} +276 -12
- package/dist/replay.d.ts +1 -115
- package/dist/scene3d.schema.json +12 -0
- package/dist/viewer.iife.js +181 -181
- package/package.json +3 -3
- package/dist/chunk-VXGQYUMN.js +0 -1198
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CONTACT_SHADOW,
|
|
2
3
|
FLOOR_FINISHES,
|
|
4
|
+
contactBandMm,
|
|
3
5
|
endElevation,
|
|
4
6
|
explodeLifts,
|
|
5
7
|
slotGroups,
|
|
6
8
|
storeysOf,
|
|
7
9
|
timeline
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-LNIVDMPG.js";
|
|
9
11
|
|
|
10
12
|
// src/replay/view-dom.ts
|
|
11
13
|
var PRESET_LABELS = [
|
|
@@ -131,8 +133,11 @@ function viewToolbar(view, opts = {}) {
|
|
|
131
133
|
// src/replay/payload.ts
|
|
132
134
|
var PREVIEW_LEAD = "Same source, plan and 3D preview.";
|
|
133
135
|
var PREVIEW_LABEL = "Same source, plan and 3D preview. The 3D preview is extruded from the same .arch file by the separate archlang-3d package, and checked against the plan: every 3D element comes from the plan's elements, and every solid is closed.";
|
|
134
|
-
var PREVIEW_LIMITS = "3D preview: walls, openings, floors, stairs, furniture, outdoor surfaces and fences in
|
|
136
|
+
var PREVIEW_LIMITS = "3D preview: walls, openings, floors, stairs, furniture, outdoor surfaces and fences in plain colours; the ground and the soft contact shadows are the viewer's, not part of the building and not in the file; no pitched roofs or balcony railings yet, and no sections, elevations or BIM.";
|
|
135
137
|
var PREVIEW_ABOUT_URL = "https://archlang.uk/3d";
|
|
138
|
+
function noticeLevelLabel(level) {
|
|
139
|
+
return `L${level} \xB7`;
|
|
140
|
+
}
|
|
136
141
|
function viewBoxOf(svg) {
|
|
137
142
|
const m = /viewBox="([-\d.\s]+)"/.exec(svg);
|
|
138
143
|
const v = (m?.[1] ?? "").trim().split(/\s+/).map(Number);
|
|
@@ -141,6 +146,7 @@ function viewBoxOf(svg) {
|
|
|
141
146
|
}
|
|
142
147
|
function replayPayload(mesh, opts) {
|
|
143
148
|
const lifts = explodeLifts(mesh);
|
|
149
|
+
const facts = castFacts(mesh);
|
|
144
150
|
return {
|
|
145
151
|
title: opts.title,
|
|
146
152
|
theme: opts.theme ?? "light",
|
|
@@ -178,13 +184,68 @@ function replayPayload(mesh, opts) {
|
|
|
178
184
|
indices,
|
|
179
185
|
...slotted ? { groups: runs } : {},
|
|
180
186
|
...n.kind === "floor" && finish ? { finish } : {},
|
|
181
|
-
...(n.kind === "outdoor" || n.kind === "fence") && colour ? { colour } : {}
|
|
187
|
+
...(n.kind === "outdoor" || n.kind === "fence") && colour ? { colour } : {},
|
|
188
|
+
...bandOf(n, positions, facts)
|
|
182
189
|
};
|
|
183
190
|
}),
|
|
184
191
|
events: timeline(mesh),
|
|
185
192
|
...groundOf(mesh)
|
|
186
193
|
};
|
|
187
194
|
}
|
|
195
|
+
function bandOf(n, positions, facts) {
|
|
196
|
+
if (positions.length === 0) return {};
|
|
197
|
+
const side = () => {
|
|
198
|
+
let x0 = Infinity;
|
|
199
|
+
let x1 = -Infinity;
|
|
200
|
+
let z0 = Infinity;
|
|
201
|
+
let z1 = -Infinity;
|
|
202
|
+
for (let i = 0; i < positions.length; i += 3) {
|
|
203
|
+
const x = positions[i];
|
|
204
|
+
const z = positions[i + 2];
|
|
205
|
+
if (x < x0) x0 = x;
|
|
206
|
+
if (x > x1) x1 = x;
|
|
207
|
+
if (z < z0) z0 = z;
|
|
208
|
+
if (z > z1) z1 = z;
|
|
209
|
+
}
|
|
210
|
+
return Math.min(x1 - x0, z1 - z0) / 1e3;
|
|
211
|
+
};
|
|
212
|
+
if (n.kind === "wall" && n.part === void 0) {
|
|
213
|
+
const t = typeof n.extras.thickness_mm === "number" ? n.extras.thickness_mm : side();
|
|
214
|
+
return { band: contactBandMm(CONTACT_SHADOW.wall, t) };
|
|
215
|
+
}
|
|
216
|
+
if (n.kind === "column") return { band: contactBandMm(CONTACT_SHADOW.wall, side()) };
|
|
217
|
+
if (n.kind === "furniture") {
|
|
218
|
+
if (n.extras.hung === true) return {};
|
|
219
|
+
const band = contactBandMm(CONTACT_SHADOW.furniture, side());
|
|
220
|
+
let lo = Infinity;
|
|
221
|
+
let hi = -Infinity;
|
|
222
|
+
for (let i = 1; i < positions.length; i += 3) {
|
|
223
|
+
const y = positions[i];
|
|
224
|
+
if (y < lo) lo = y;
|
|
225
|
+
if (y > hi) hi = y;
|
|
226
|
+
}
|
|
227
|
+
return hi - lo < band * 1e3 ? { flat: true } : { band };
|
|
228
|
+
}
|
|
229
|
+
if (n.kind === "fence") {
|
|
230
|
+
const post = facts.fencePosts.get(String(n.extras.style)) ?? side();
|
|
231
|
+
return { band: contactBandMm(CONTACT_SHADOW.fence, post) };
|
|
232
|
+
}
|
|
233
|
+
if (n.kind === "stair" && n.part === "stringer")
|
|
234
|
+
return { band: contactBandMm(CONTACT_SHADOW.wall, CONTACT_SHADOW.stairThicknessMm) };
|
|
235
|
+
return {};
|
|
236
|
+
}
|
|
237
|
+
function castFacts(mesh) {
|
|
238
|
+
const facts = { fencePosts: /* @__PURE__ */ new Map() };
|
|
239
|
+
const inParens = (field) => /^[a-z_]+\((.+)\)$/.exec(field)?.[1];
|
|
240
|
+
for (const a of mesh.assumptions) {
|
|
241
|
+
if (a.rule === "fence-profile-default") {
|
|
242
|
+
const style = inParens(a.field);
|
|
243
|
+
const post = a.value?.post_mm;
|
|
244
|
+
if (style !== void 0 && typeof post === "number") facts.fencePosts.set(style, post);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return facts;
|
|
248
|
+
}
|
|
188
249
|
function groundOf(mesh) {
|
|
189
250
|
const row = mesh.assumptions.find((a) => a.rule === "ground-plane-viewer-only")?.value;
|
|
190
251
|
const lowest = typeof row?.level === "number" ? row.level : storeysOf(mesh)[0];
|
|
@@ -205,6 +266,7 @@ export {
|
|
|
205
266
|
PREVIEW_LABEL,
|
|
206
267
|
PREVIEW_LIMITS,
|
|
207
268
|
PREVIEW_ABOUT_URL,
|
|
269
|
+
noticeLevelLabel,
|
|
208
270
|
viewBoxOf,
|
|
209
271
|
replayPayload
|
|
210
272
|
};
|