@chanmeng666/archlang-3d 0.3.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.
- package/CHANGELOG.md +54 -0
- package/README.md +14 -3
- package/dist/browser.d.ts +8 -5
- package/dist/browser.js +30 -13
- package/dist/{camera-CLNYQ1Xv.d.ts → camera-DVOiag0F.d.ts} +21 -5
- package/dist/{chunk-PRZXP6FP.js → chunk-EG7UT2HG.js} +45 -4
- package/dist/{chunk-VPYTRKMK.js → chunk-EQBMPXB5.js} +24 -4
- package/dist/{chunk-WBA4LABI.js → chunk-KF5ME6KH.js} +12 -6
- package/dist/{chunk-ZE4PL6KP.js → chunk-RPGAMA3G.js} +14 -12
- package/dist/{chunk-QUSG4UCO.js → chunk-VS4OAVPD.js} +278 -22
- package/dist/cli.js +6 -6
- package/dist/{facts-B47HOKOh.d.ts → facts-BRIFxHL_.d.ts} +1 -1
- package/dist/index.d.ts +46 -7
- package/dist/index.js +14 -4
- package/dist/node.d.ts +6 -4
- package/dist/node.js +10 -4
- package/dist/replay.d.ts +24 -8
- package/dist/scene3d.schema.json +63 -0
- package/dist/{strip-CN_dTKqy.d.ts → strip-Nt7eJ-4E.d.ts} +59 -5
- package/dist/viewer.iife.js +169 -169
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,60 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.4.0] - 2026-11-06
|
|
6
|
+
|
|
7
|
+
The core peer range is now `^1.57.0` (was `^1.45.0`): 1.57.0 is the first core that exports
|
|
8
|
+
`treadCount`, which the stairs read. With an older core (npm warns of the peer range) everything
|
|
9
|
+
else works as before and no stair is built (`stair-no-flights`).
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Stairs. A straight stair and a turning stair (flights and landings) are built as stepped solids,
|
|
14
|
+
read from the core's own stair: each flight's rectangle, the edge it is climbed from and the
|
|
15
|
+
number of treads the plan draws on it (the core's new `treadCount` export), so the treads stand
|
|
16
|
+
on the drawing's tread lines. A stair climbs to the floor of the storey above in equal risers, one
|
|
17
|
+
per tread plus one at the head of each flight; a landing stands at the height its flight ends on.
|
|
18
|
+
The flight is as wide as the stair's `width`, centred as the plan centres it, and solid down to
|
|
19
|
+
its floor. The void in the floor above stays where the plan puts it.
|
|
20
|
+
- A stair is built once, on the storey it climbs from: a `dir up` stair climbs from its own
|
|
21
|
+
storey, and the `dir down` stop above it is the same stair. A `dir down` stair with no stair of
|
|
22
|
+
its id below is built from the storey below. A `dir up` stair on the top storey climbs that
|
|
23
|
+
storey's height; a `dir down` stair on the lowest storey is not built. Each case is in the
|
|
24
|
+
ledger.
|
|
25
|
+
- Stairs are oak, from the palette's `wood` (the core gives a stair no material), and the ledger
|
|
26
|
+
says so (`stair-material-default`), with the solid form (`stair-solid-default`) and each stair's
|
|
27
|
+
riser count (`stair-risers-from-treads`). In the GLB a stair is a `stair:<id>` node under its
|
|
28
|
+
storey, in a `stair` material, its facts (direction, width, flights, risers, rise) in
|
|
29
|
+
`extras.archlang`. In the replay it rises after its storey's walls. `build --json` counts stairs
|
|
30
|
+
per storey.
|
|
31
|
+
- Scene3D: a stair carries `flights` (each `at`, `size`, `foot` and `treads`) and `landings`. Both
|
|
32
|
+
are optional, so a Scene3D written before 0.4.0 still validates; its stairs are not built
|
|
33
|
+
(`stair-no-flights`). New exports: `stairSolid`, `stairRisers`, `StairSolid`, `STAIR_MATERIAL`.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- A replay of several storeys ends with the storeys assembled: they still rise one by one, each
|
|
38
|
+
lifted 3 m clear of the one below, and once everything is up they come down to their real heights
|
|
39
|
+
while the camera moves to frame the assembled building. The end frame, the Iso view and Reset show
|
|
40
|
+
the storeys stacked; hiding the storeys above one is the cutaway. Every earlier frame is unchanged.
|
|
41
|
+
`ReplayState` gains `settle` (0 while exploded, 1 at the end) and its `stop` runs on to the storey
|
|
42
|
+
count during the settle; `cameraStops` returns one more fit for several storeys (the assembled
|
|
43
|
+
building, last); `boxOfNodes` takes `settle`. New exports: `settledLift`, `stopCount`. A one-storey
|
|
44
|
+
replay is the same in every frame.
|
|
45
|
+
- The preview's label is the line every ArchLang surface uses: "Same source, plan and 3D preview.
|
|
46
|
+
The 3D preview is extruded from the same .arch file by the separate archlang-3d package, and
|
|
47
|
+
checked against the plan." (`PREVIEW_LABEL`; its first sentence is `PREVIEW_LEAD`). The replay
|
|
48
|
+
HTML also carries the limits line (`PREVIEW_LIMITS`): walls, openings, floors, stairs and furniture
|
|
49
|
+
in flat colours; no pitched roofs yet, and no sections, elevations or BIM. `PREVIEW_ABOUT_URL`
|
|
50
|
+
is the page that says what the preview shows.
|
|
51
|
+
- The side views' buttons are named "View from north" (east, south, west) instead of "North
|
|
52
|
+
elevation" and so on: the 3D preview draws no elevations. The buttons still read N, E, S and W.
|
|
53
|
+
- The ledger row `m1-omits-stairs-outdoor-fences` is now `m1-omits-outdoor-fences`, written once
|
|
54
|
+
for outdoor surfaces and once for fences, which are still not built.
|
|
55
|
+
- `PREVIEW_ABOUT_URL`, the page that says what the 3D preview shows and does not, is the docs
|
|
56
|
+
site's `https://archlang.uk/3d` (it was this package's npm page). The playground's "What it
|
|
57
|
+
shows" link follows it. The replay HTML does not carry the link, so its bytes are unchanged.
|
|
58
|
+
|
|
5
59
|
## [0.3.0] - 2026-11-05
|
|
6
60
|
|
|
7
61
|
### Added
|
package/README.md
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
your source and the core's drawing as they are.
|
|
6
6
|
|
|
7
7
|
From a plan it writes a replay (one HTML file: the plan draws itself, then the walls rise) and a GLB
|
|
8
|
-
for any glTF viewer.
|
|
8
|
+
for any glTF viewer. 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.
|
|
9
|
+
|
|
10
|
+
3D preview: walls, openings, floors, stairs and furniture in flat colours; no pitched roofs yet,
|
|
11
|
+
and no sections, elevations or BIM.
|
|
9
12
|
|
|
10
13
|
## Install
|
|
11
14
|
|
|
@@ -13,7 +16,7 @@ for any glTF viewer.
|
|
|
13
16
|
npm install @chanmeng666/archlang-3d @chanmeng666/archlang
|
|
14
17
|
```
|
|
15
18
|
|
|
16
|
-
Needs Node 20 or newer. The core, `@chanmeng666/archlang`, is a peer dependency at `^1.
|
|
19
|
+
Needs Node 20 or newer. The core, `@chanmeng666/archlang`, is a peer dependency at `^1.57.0`. To
|
|
17
20
|
follow along, take a plan from the examples the core ships:
|
|
18
21
|
|
|
19
22
|
```sh
|
|
@@ -29,7 +32,15 @@ npx archlang3d view plan.arch --replay -o plan.html
|
|
|
29
32
|
`plan.html` opens offline. three.js 0.186.1 is inside the file with its licence notice, and nothing
|
|
30
33
|
is fetched from a network. `--theme dark` and `--storey <n>` change what it shows.
|
|
31
34
|
|
|
32
|
-
|
|
35
|
+
A plan of several storeys rises storey by storey, each lifted clear of the one below so the floor
|
|
36
|
+
underneath stays in view, and at the end the storeys come down to stand on each other at their real
|
|
37
|
+
heights.
|
|
38
|
+
|
|
39
|
+
The view turns freely: drag to rotate, scroll or pinch to zoom, right-drag or two fingers to pan,
|
|
40
|
+
and the buttons give Iso, Top, the views from north, east, south and west, and Reset (and, with several storeys, hide the
|
|
41
|
+
storeys above one). Moving the view pauses the playback.
|
|
42
|
+
|
|
43
|
+
To make a video as well, add a browser and `ffmpeg` on your `PATH`:
|
|
33
44
|
|
|
34
45
|
```sh
|
|
35
46
|
npx playwright-core install chromium
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { P as PresetName, V as Vec3 } from './camera-
|
|
1
|
+
import { P as PresetName, V as Vec3 } from './camera-DVOiag0F.js';
|
|
2
2
|
import { ReplayPayload } from './replay.js';
|
|
3
|
-
export { PREVIEW_LABEL, ReplayNode, ReplayOptions, replayPayload, viewBoxOf } from './replay.js';
|
|
4
|
-
import { S as StripItem } from './strip-
|
|
5
|
-
export { R as ReplayFacts, s as stripAt } from './strip-
|
|
3
|
+
export { PREVIEW_ABOUT_URL, PREVIEW_LABEL, PREVIEW_LEAD, PREVIEW_LIMITS, ReplayNode, ReplayOptions, replayPayload, viewBoxOf } from './replay.js';
|
|
4
|
+
import { S as StripItem } from './strip-Nt7eJ-4E.js';
|
|
5
|
+
export { R as ReplayFacts, s as stripAt } from './strip-Nt7eJ-4E.js';
|
|
6
6
|
|
|
7
7
|
interface ReplayHandle {
|
|
8
8
|
/** Render the frame at replay time `t` (clamped to [0, 1]) into the canvas, synchronously. */
|
|
@@ -89,7 +89,10 @@ declare function mountReplay(out: HTMLCanvasElement, p: ReplayPayload, strip?: H
|
|
|
89
89
|
* the canvas.
|
|
90
90
|
*/
|
|
91
91
|
|
|
92
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Each preset's button text and its accessible name. The side views are "View from north" and so
|
|
94
|
+
* on, never "elevation": the 3D preview draws no elevations (the PS-D12 limits line).
|
|
95
|
+
*/
|
|
93
96
|
declare const PRESET_LABELS: ReadonlyArray<readonly [PresetName, string, string]>;
|
|
94
97
|
declare const VIEW_HINT = "Drag to turn, right-drag to pan, scroll to zoom; on the focused view, arrow keys turn and + / \u2212 zoom.";
|
|
95
98
|
/**
|
package/dist/browser.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PRESET_LABELS,
|
|
3
|
+
PREVIEW_ABOUT_URL,
|
|
3
4
|
PREVIEW_LABEL,
|
|
5
|
+
PREVIEW_LEAD,
|
|
6
|
+
PREVIEW_LIMITS,
|
|
4
7
|
VIEW_CONTROLS_LABEL,
|
|
5
8
|
VIEW_HINT,
|
|
6
9
|
replayPayload,
|
|
7
10
|
viewBoxOf,
|
|
8
11
|
viewToolbar
|
|
9
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-KF5ME6KH.js";
|
|
10
13
|
import {
|
|
11
14
|
ELEVATION_RANGE,
|
|
12
15
|
END_AZIMUTH,
|
|
@@ -24,12 +27,14 @@ import {
|
|
|
24
27
|
frameCamera,
|
|
25
28
|
pivotAbove,
|
|
26
29
|
presetCamera,
|
|
30
|
+
settledLift,
|
|
27
31
|
slotColour,
|
|
28
32
|
stateAt,
|
|
33
|
+
stopCount,
|
|
29
34
|
stripAt,
|
|
30
35
|
takenLens,
|
|
31
36
|
targetBounds
|
|
32
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-EQBMPXB5.js";
|
|
33
38
|
|
|
34
39
|
// src/replay/mount.ts
|
|
35
40
|
import {
|
|
@@ -94,7 +99,8 @@ var THEMES = {
|
|
|
94
99
|
"window:frame": "#5d86a8",
|
|
95
100
|
"window:glass": "#86c5ee",
|
|
96
101
|
"wall:demolish": "#e07a5f",
|
|
97
|
-
furniture: "#3f6a8f"
|
|
102
|
+
furniture: "#3f6a8f",
|
|
103
|
+
stair: "#5d86a8"
|
|
98
104
|
}
|
|
99
105
|
}
|
|
100
106
|
};
|
|
@@ -215,7 +221,7 @@ function mountReplay(out, p, strip, opts = {}) {
|
|
|
215
221
|
}
|
|
216
222
|
g.visible = false;
|
|
217
223
|
scene.add(g);
|
|
218
|
-
nodes.set(n.key, { g, flat: Math.min(1, FOOTPRINT_MM / Math.max(1e-6, topY - base)) });
|
|
224
|
+
nodes.set(n.key, { g, flat: Math.min(1, FOOTPRINT_MM / Math.max(1e-6, topY - base)), base, lift: n.lift ?? 0 });
|
|
219
225
|
}
|
|
220
226
|
const [vx, vy, vw, vh] = p.viewBox;
|
|
221
227
|
const aspect = W / H;
|
|
@@ -233,11 +239,12 @@ function mountReplay(out, p, strip, opts = {}) {
|
|
|
233
239
|
const fits = cameraStops(p.nodes, p.events, orbit);
|
|
234
240
|
const size = hi.clone().sub(lo);
|
|
235
241
|
const mid = lo.clone().add(hi).multiplyScalar(0.5);
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
size.length() * 0.75 + reach + Math.hypot(mid.x - (vx + vw / 2), mid.z - (vy + vh / 2)),
|
|
239
|
-
|
|
240
|
-
);
|
|
242
|
+
const radiusOver = (cams) => {
|
|
243
|
+
const reach = Math.max(...cams.map((f) => mid.distanceTo(new Vector3(...f.target))));
|
|
244
|
+
return Math.max(size.length() * 0.75 + reach + Math.hypot(mid.x - (vx + vw / 2), mid.z - (vy + vh / 2)), 1e3);
|
|
245
|
+
};
|
|
246
|
+
const radius = radiusOver(fits.slice(0, stopCount(p.events)));
|
|
247
|
+
const endRadius = radiusOver(fits);
|
|
241
248
|
const rad = (d) => d * Math.PI / 180;
|
|
242
249
|
const img = new Image();
|
|
243
250
|
const ready = new Promise((resolve) => {
|
|
@@ -253,7 +260,7 @@ function mountReplay(out, p, strip, opts = {}) {
|
|
|
253
260
|
let holder = "replay";
|
|
254
261
|
let tNow = 0;
|
|
255
262
|
const halfDiagonal = size.length() / 2;
|
|
256
|
-
const reachFrom = (target) => Math.max(
|
|
263
|
+
const reachFrom = (target) => Math.max(endRadius, mid.distanceTo(target) + halfDiagonal);
|
|
257
264
|
function place(f, r) {
|
|
258
265
|
const { fov, dist, elevation, azimuth } = f;
|
|
259
266
|
const target = new Vector3(...f.target);
|
|
@@ -267,7 +274,13 @@ function mountReplay(out, p, strip, opts = {}) {
|
|
|
267
274
|
persp.position.set(...cameraPosition([target.x, target.y, target.z], dist, { elevation, azimuth }));
|
|
268
275
|
persp.lookAt(target);
|
|
269
276
|
}
|
|
270
|
-
const viewScene = {
|
|
277
|
+
const viewScene = {
|
|
278
|
+
events: p.events,
|
|
279
|
+
fits,
|
|
280
|
+
frame: frameView,
|
|
281
|
+
box: boxOfNodes(p.nodes, { settle: 1 }),
|
|
282
|
+
aspect
|
|
283
|
+
};
|
|
271
284
|
const presets = /* @__PURE__ */ new Map();
|
|
272
285
|
const presetOf = (name) => {
|
|
273
286
|
const known = presets.get(name);
|
|
@@ -291,10 +304,11 @@ function mountReplay(out, p, strip, opts = {}) {
|
|
|
291
304
|
tNow = t;
|
|
292
305
|
if (strip && p.facts) paintStrip(strip, stripAt(p.facts, p.events, Math.min(1, Math.max(0, t))));
|
|
293
306
|
const s = stateAt(p.events, t);
|
|
294
|
-
for (const [key2, { g, flat }] of nodes) {
|
|
307
|
+
for (const [key2, { g, flat, base, lift }] of nodes) {
|
|
295
308
|
const st = s.nodes.get(key2);
|
|
296
309
|
g.visible = st?.visible === true && (storeyOf.get(key2) ?? 0) < shown;
|
|
297
310
|
g.scale.y = Math.max(flat, st?.rise ?? 0);
|
|
311
|
+
if (lift !== 0) g.position.y = base + settledLift(lift, s.settle);
|
|
298
312
|
}
|
|
299
313
|
let cam = ortho;
|
|
300
314
|
if (holder === "free" && controls) {
|
|
@@ -309,7 +323,7 @@ function mountReplay(out, p, strip, opts = {}) {
|
|
|
309
323
|
place(f, reachFrom(new Vector3(...f.target)));
|
|
310
324
|
cam = persp;
|
|
311
325
|
} else if (s.tilt > 0 || s.dolly > 0) {
|
|
312
|
-
place(frameCamera(s, fits, frameView), radius);
|
|
326
|
+
place(frameCamera(s, fits, frameView), s.settle > 0 ? endRadius : radius);
|
|
313
327
|
cam = persp;
|
|
314
328
|
}
|
|
315
329
|
renderer.render(scene, cam);
|
|
@@ -516,7 +530,10 @@ function mountReplay(out, p, strip, opts = {}) {
|
|
|
516
530
|
}
|
|
517
531
|
export {
|
|
518
532
|
PRESET_LABELS,
|
|
533
|
+
PREVIEW_ABOUT_URL,
|
|
519
534
|
PREVIEW_LABEL,
|
|
535
|
+
PREVIEW_LEAD,
|
|
536
|
+
PREVIEW_LIMITS,
|
|
520
537
|
VIEW_CONTROLS_LABEL,
|
|
521
538
|
VIEW_HINT,
|
|
522
539
|
mountReplay,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { y as ReplayEvent, z as ReplayState } from './strip-Nt7eJ-4E.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The replay's end camera as plain maths (card A3, look notes round 1): the viewer and the tests
|
|
@@ -65,6 +65,8 @@ declare const endElevation: (_storeys: number) => number;
|
|
|
65
65
|
* `lift` (the combined view's exploded storeys). A demolished wall's ghost (`part` "demolish") is not
|
|
66
66
|
* the building and is left out of a fit (`timeline.ts`'s header), unless nothing else is there;
|
|
67
67
|
* `ghosts: true` keeps it, for a box that must hold everything drawn (the viewer's clip range).
|
|
68
|
+
* `settle` (`ReplayState.settle`) lowers each lift to `settledLift(lift, settle)`: 1 is the
|
|
69
|
+
* assembled building, every storey at the height it stands at (the end frame's).
|
|
68
70
|
*/
|
|
69
71
|
declare function boxOfNodes(nodes: ReadonlyArray<{
|
|
70
72
|
positions: readonly number[];
|
|
@@ -72,13 +74,24 @@ declare function boxOfNodes(nodes: ReadonlyArray<{
|
|
|
72
74
|
part?: string;
|
|
73
75
|
}>, opts?: {
|
|
74
76
|
ghosts?: boolean;
|
|
77
|
+
settle?: number;
|
|
75
78
|
}): Box;
|
|
79
|
+
/**
|
|
80
|
+
* A node's lift (mm) at settle `settle` (`ReplayState.settle`): the whole lift while the storeys are
|
|
81
|
+
* exploded, none once they have settled. The viewer draws a node at this lift.
|
|
82
|
+
*/
|
|
83
|
+
declare const settledLift: (lift: number | undefined, settle: number) => number;
|
|
84
|
+
/** How many camera stops the rise has: one per storey of the event table (one storey: one). */
|
|
85
|
+
declare const stopCount: (events: readonly ReplayEvent[]) => number;
|
|
76
86
|
/** The perspective camera's lens at the start of the dolly (a near-orthographic top-down view). */
|
|
77
87
|
declare const START_FOV = 1.5;
|
|
78
88
|
/**
|
|
79
89
|
* One fitted camera per stop: stop k fills the frame with storeys 0…k (the combined view; a node's
|
|
80
|
-
* storey is its event's), the last stop with the whole building. One storey: one stop.
|
|
81
|
-
*
|
|
90
|
+
* storey is its event's), the last stop with the whole building, exploded. One storey: one stop.
|
|
91
|
+
* Several storeys add one fit after the stops: the assembled building (every lift settled), the
|
|
92
|
+
* camera the settle ends on (`stateAt`'s `settle`), so the last fit is always the whole building as
|
|
93
|
+
* the end frame shows it. Each is fitted for the end orbit, which `stateAt` has reached by the time
|
|
94
|
+
* of the first stop.
|
|
82
95
|
*/
|
|
83
96
|
declare function cameraStops(nodes: ReadonlyArray<{
|
|
84
97
|
key: string;
|
|
@@ -136,7 +149,10 @@ interface ViewScene {
|
|
|
136
149
|
oh: number;
|
|
137
150
|
elevation: number;
|
|
138
151
|
};
|
|
139
|
-
/**
|
|
152
|
+
/**
|
|
153
|
+
* The standing building as the end frame shows it (`boxOfNodes`, ghosts left out, `settle: 1`):
|
|
154
|
+
* the box the last fit is fitted to (`cameraStops`).
|
|
155
|
+
*/
|
|
140
156
|
box: Box;
|
|
141
157
|
/** Canvas width / height. */
|
|
142
158
|
aspect: number;
|
|
@@ -208,4 +224,4 @@ declare function targetBounds(box: Box): {
|
|
|
208
224
|
radius: number;
|
|
209
225
|
};
|
|
210
226
|
|
|
211
|
-
export { type Box as B, ELEVATION_AZIMUTH as E, FILL as F, type Orbit as O, type PresetName as P, START_FOV as S, type Vec3 as V, ZOOM as Z, ELEVATION_RANGE as a, END_AZIMUTH as b, END_FOV as c, type EndCamera as d, type FrameCamera as e, PRESET_NAMES as f, type ViewScene as g, boxOfNodes as h, cameraAtStop as i, cameraStops as j, corners as k, coverage as l, distanceLimits as m, drawingFrame as n, endElevation as o, fitEndCamera as p, frameCamera as q, pivotAbove as r, presetCamera as s, projectBox as t,
|
|
227
|
+
export { type Box as B, ELEVATION_AZIMUTH as E, FILL as F, type Orbit as O, type PresetName as P, START_FOV as S, type Vec3 as V, ZOOM as Z, ELEVATION_RANGE as a, END_AZIMUTH as b, END_FOV as c, type EndCamera as d, type FrameCamera as e, PRESET_NAMES as f, type ViewScene as g, boxOfNodes as h, cameraAtStop as i, cameraStops as j, corners as k, coverage as l, distanceLimits as m, drawingFrame as n, endElevation as o, fitEndCamera as p, frameCamera as q, pivotAbove as r, presetCamera as s, projectBox as t, settledLift as u, stopCount as v, takenLens as w, targetBounds as x };
|
|
@@ -3571,12 +3571,14 @@ function floorLifts(floors, overlaps) {
|
|
|
3571
3571
|
}
|
|
3572
3572
|
|
|
3573
3573
|
// package.json
|
|
3574
|
-
var version = "0.
|
|
3574
|
+
var version = "0.4.0";
|
|
3575
3575
|
|
|
3576
3576
|
// src/scene3d/build.ts
|
|
3577
|
+
import * as core2 from "@chanmeng666/archlang";
|
|
3577
3578
|
import {
|
|
3578
3579
|
doorLeaves,
|
|
3579
|
-
doorSwing
|
|
3580
|
+
doorSwing,
|
|
3581
|
+
entryEdges
|
|
3580
3582
|
} from "@chanmeng666/archlang";
|
|
3581
3583
|
|
|
3582
3584
|
// src/curves.ts
|
|
@@ -3673,12 +3675,32 @@ var fenceOf = (f) => ({
|
|
|
3673
3675
|
points: f.points.map(umPoint),
|
|
3674
3676
|
closed: f.closed
|
|
3675
3677
|
});
|
|
3678
|
+
var OPPOSITE = { top: "bottom", bottom: "top", left: "right", right: "left" };
|
|
3679
|
+
function stairPieces(s) {
|
|
3680
|
+
const treadCount3 = core2.treadCount;
|
|
3681
|
+
if (typeof treadCount3 !== "function") return void 0;
|
|
3682
|
+
const flight = (at, size, tail2) => ({
|
|
3683
|
+
at: umPoint(at),
|
|
3684
|
+
size: { w: um2(size.w), h: um2(size.h) },
|
|
3685
|
+
foot: s.dir === "up" ? tail2 : OPPOSITE[tail2],
|
|
3686
|
+
treads: treadCount3(tail2 === "top" || tail2 === "bottom" ? size.h : size.w)
|
|
3687
|
+
});
|
|
3688
|
+
if (s.flights && s.landings) {
|
|
3689
|
+
return {
|
|
3690
|
+
flights: s.flights.map((f) => flight(f.at, f.size, f.tail)),
|
|
3691
|
+
landings: s.landings.map((l) => ({ at: umPoint(l.at), size: { w: um2(l.size.w), h: um2(l.size.h) } }))
|
|
3692
|
+
};
|
|
3693
|
+
}
|
|
3694
|
+
const tail = entryEdges(s)[0];
|
|
3695
|
+
return tail ? { flights: [flight(s.at, s.size, tail)], landings: [] } : void 0;
|
|
3696
|
+
}
|
|
3676
3697
|
var stairOf = (s) => ({
|
|
3677
3698
|
id: s.id,
|
|
3678
3699
|
source: source(s),
|
|
3679
3700
|
box: box(s),
|
|
3680
3701
|
dir: s.dir,
|
|
3681
|
-
width: um2(s.width)
|
|
3702
|
+
width: um2(s.width),
|
|
3703
|
+
...stairPieces(s)
|
|
3682
3704
|
});
|
|
3683
3705
|
function wallsAndOpenings(ir, byId, tol) {
|
|
3684
3706
|
const own = wallOwnership(ir.walls, (loops) => tessellateLoops(loops, tol));
|
|
@@ -3940,6 +3962,9 @@ var object = (required, optional = {}) => (v, p, out) => {
|
|
|
3940
3962
|
if (!(k in required) && !(k in optional)) fail(out, `${p}/${k}`, "is not a Scene3D field");
|
|
3941
3963
|
}
|
|
3942
3964
|
};
|
|
3965
|
+
var treadCount2 = (v, p, out) => {
|
|
3966
|
+
if (!Number.isInteger(v) || v < 1) fail(out, p, "must be an integer of at least 1");
|
|
3967
|
+
};
|
|
3943
3968
|
var pt = array(integer, 2, 2);
|
|
3944
3969
|
var ring2 = array(pt, 3);
|
|
3945
3970
|
var polygon2 = object({ outer: ring2 }, { holes: array(ring2) });
|
|
@@ -3991,7 +4016,23 @@ var LEVEL_COLLECTIONS = {
|
|
|
3991
4016
|
{ room: string, mirror: oneOf(true) }
|
|
3992
4017
|
)
|
|
3993
4018
|
),
|
|
3994
|
-
stairs: array(
|
|
4019
|
+
stairs: array(
|
|
4020
|
+
object(
|
|
4021
|
+
{ id, source: source2, box: box2, dir: oneOf("up", "down"), width: integer },
|
|
4022
|
+
{
|
|
4023
|
+
flights: array(
|
|
4024
|
+
object({
|
|
4025
|
+
at: pt,
|
|
4026
|
+
size: sized("w", "h"),
|
|
4027
|
+
foot: oneOf("top", "bottom", "left", "right"),
|
|
4028
|
+
treads: treadCount2
|
|
4029
|
+
}),
|
|
4030
|
+
1
|
|
4031
|
+
),
|
|
4032
|
+
landings: array(object({ at: pt, size: sized("w", "h") }))
|
|
4033
|
+
}
|
|
4034
|
+
)
|
|
4035
|
+
),
|
|
3995
4036
|
voids: array(box2),
|
|
3996
4037
|
columns: array(box2),
|
|
3997
4038
|
outdoor: array(object({ id, source: source2, surface: string, polygon: polygon2 }, { rail: array(string) })),
|
|
@@ -46,6 +46,7 @@ var PALETTE = {
|
|
|
46
46
|
soil: m("#5f4b3b", 1),
|
|
47
47
|
water: m("#a3c6d0", 0.1, 0, 0.7)
|
|
48
48
|
};
|
|
49
|
+
var STAIR_MATERIAL = "wood";
|
|
49
50
|
var KIND_PALETTE = {
|
|
50
51
|
slab: m("#bdb6ab", 0.9),
|
|
51
52
|
column: m("#e6e1d8", 0.85),
|
|
@@ -56,7 +57,10 @@ var KIND_PALETTE = {
|
|
|
56
57
|
opening: m("#e6e1d8", 0.85),
|
|
57
58
|
furniture: m("#d6cec1", 0.9),
|
|
58
59
|
roof: m("#9c958a", 0.9),
|
|
59
|
-
"wall:demolish": m("#c8553d", 0.9, 0, 0.3)
|
|
60
|
+
"wall:demolish": m("#c8553d", 0.9, 0, 0.3),
|
|
61
|
+
// A stair (card X3): the core gives it no material, so the ledgered default (`STAIR_MATERIAL`,
|
|
62
|
+
// `stair-material-default`): that slot's own entry, never a second copy of its colour.
|
|
63
|
+
stair: PALETTE[STAIR_MATERIAL]
|
|
60
64
|
};
|
|
61
65
|
var WALL_CAP_SRGB = "#8f877d";
|
|
62
66
|
var FLOOR_FINISHES = ["timber", "tile", "neutral"];
|
|
@@ -127,7 +131,7 @@ var PHASE = {
|
|
|
127
131
|
tilted: 0.78,
|
|
128
132
|
/** Every wall has risen; fixtures rise from here. */
|
|
129
133
|
wallsUp: 0.84,
|
|
130
|
-
/** Everything has risen. */
|
|
134
|
+
/** Everything has risen; several storeys combined settle from here to the end (`stateAt`). */
|
|
131
135
|
done: 0.96
|
|
132
136
|
};
|
|
133
137
|
var FIXTURE_FAMILIES = /* @__PURE__ */ new Set([
|
|
@@ -160,6 +164,8 @@ function groupOf(n) {
|
|
|
160
164
|
return n.extras.category === "exterior" ? 1 : 2;
|
|
161
165
|
case "roof":
|
|
162
166
|
return 3;
|
|
167
|
+
case "stair":
|
|
168
|
+
return 3;
|
|
163
169
|
case "door":
|
|
164
170
|
return 0;
|
|
165
171
|
case "window":
|
|
@@ -305,16 +311,24 @@ function stateAt(events, t) {
|
|
|
305
311
|
const b = starts[k];
|
|
306
312
|
if (u > a) stop = k - 1 + (b > a ? ease((u - a) / (b - a)) : 1);
|
|
307
313
|
}
|
|
314
|
+
let settle = 0;
|
|
315
|
+
if (ends.length > 1) {
|
|
316
|
+
const from = settleFrom(ends);
|
|
317
|
+
settle = from < 1 ? ease((u - from) / (1 - from)) : u >= 1 ? 1 : 0;
|
|
318
|
+
if (settle > 0) stop = ends.length - 1 + settle;
|
|
319
|
+
}
|
|
308
320
|
return {
|
|
309
321
|
// The tilt is done by the first stop, so every stop sees the end orbit its camera was fitted for
|
|
310
322
|
// (one storey: `first` is 1 and the tilt keeps PHASE's own timing).
|
|
311
323
|
tilt: ease((u - PHASE.rise) / (Math.min(PHASE.tilted, first) - PHASE.rise)),
|
|
312
324
|
dolly: ease((u - PHASE.rise) / (first - PHASE.rise)),
|
|
313
325
|
stop,
|
|
326
|
+
settle,
|
|
314
327
|
svg,
|
|
315
328
|
nodes
|
|
316
329
|
};
|
|
317
330
|
}
|
|
331
|
+
var settleFrom = (ends) => Math.max(PHASE.done, ...ends);
|
|
318
332
|
function keyFrames(events) {
|
|
319
333
|
const first = (s) => events.filter((e) => e.stage === s && !e.hidden).reduce((m3, e) => m3 === void 0 || e.appear < m3 ? e.appear : m3, void 0);
|
|
320
334
|
const out = [];
|
|
@@ -456,7 +470,7 @@ function boxOfNodes(nodes, opts = {}) {
|
|
|
456
470
|
const hi = [-Infinity, -Infinity, -Infinity];
|
|
457
471
|
const standing = opts.ghosts ? nodes : nodes.filter((n) => n.part !== "demolish");
|
|
458
472
|
for (const n of standing.length > 0 ? standing : nodes) {
|
|
459
|
-
const lift = n.lift ?? 0;
|
|
473
|
+
const lift = opts.settle === void 0 ? n.lift ?? 0 : settledLift(n.lift, opts.settle);
|
|
460
474
|
for (let i = 0; i < n.positions.length; i += 3) {
|
|
461
475
|
const p = [
|
|
462
476
|
n.positions[i] / 1e3,
|
|
@@ -471,13 +485,16 @@ function boxOfNodes(nodes, opts = {}) {
|
|
|
471
485
|
}
|
|
472
486
|
return { lo, hi };
|
|
473
487
|
}
|
|
488
|
+
var settledLift = (lift, settle) => (lift ?? 0) * (1 - settle);
|
|
489
|
+
var stopCount = (events) => Math.max(1, ...events.map((e) => (e.storey ?? 0) + 1));
|
|
474
490
|
var START_FOV = 1.5;
|
|
475
491
|
function cameraStops(nodes, events, o) {
|
|
476
492
|
const storeyOf = new Map(events.map((e) => [e.key, e.storey ?? 0]));
|
|
477
|
-
const stops =
|
|
493
|
+
const stops = stopCount(events);
|
|
478
494
|
const fits = [];
|
|
479
495
|
for (let k = 0; k < stops; k++)
|
|
480
496
|
fits.push(fitEndCamera(boxOfNodes(nodes.filter((n) => (storeyOf.get(n.key) ?? 0) <= k)), o));
|
|
497
|
+
if (stops > 1) fits.push(fitEndCamera(boxOfNodes(nodes, { settle: 1 }), o));
|
|
481
498
|
return fits;
|
|
482
499
|
}
|
|
483
500
|
function cameraAtStop(fits, stop) {
|
|
@@ -551,6 +568,7 @@ function targetBounds(box) {
|
|
|
551
568
|
export {
|
|
552
569
|
MATERIAL_SLOTS,
|
|
553
570
|
PALETTE,
|
|
571
|
+
STAIR_MATERIAL,
|
|
554
572
|
KIND_PALETTE,
|
|
555
573
|
WALL_CAP_SRGB,
|
|
556
574
|
FLOOR_FINISHES,
|
|
@@ -585,6 +603,8 @@ export {
|
|
|
585
603
|
END_AZIMUTH,
|
|
586
604
|
endElevation,
|
|
587
605
|
boxOfNodes,
|
|
606
|
+
settledLift,
|
|
607
|
+
stopCount,
|
|
588
608
|
START_FOV,
|
|
589
609
|
cameraStops,
|
|
590
610
|
cameraAtStop,
|
|
@@ -5,16 +5,16 @@ import {
|
|
|
5
5
|
slotGroups,
|
|
6
6
|
storeysOf,
|
|
7
7
|
timeline
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-EQBMPXB5.js";
|
|
9
9
|
|
|
10
10
|
// src/replay/view-dom.ts
|
|
11
11
|
var PRESET_LABELS = [
|
|
12
12
|
["iso", "Iso", "Iso view: the replay's end view"],
|
|
13
13
|
["top", "Top", "Top view, the plan's top edge up"],
|
|
14
|
-
["north", "N", "
|
|
15
|
-
["east", "E", "
|
|
16
|
-
["south", "S", "
|
|
17
|
-
["west", "W", "
|
|
14
|
+
["north", "N", "View from north: level, from the plan's top edge"],
|
|
15
|
+
["east", "E", "View from east: level, from the plan's right edge"],
|
|
16
|
+
["south", "S", "View from south: level, from the plan's bottom edge"],
|
|
17
|
+
["west", "W", "View from west: level, from the plan's left edge"]
|
|
18
18
|
];
|
|
19
19
|
var VIEW_HINT = "Drag to turn, right-drag to pan, scroll to zoom; on the focused view, arrow keys turn and + / \u2212 zoom.";
|
|
20
20
|
var VIEW_CONTROLS_LABEL = "an interactive 3D view: drag or use the arrow keys to turn it, scroll or + and \u2212 to zoom";
|
|
@@ -75,7 +75,10 @@ function viewToolbar(view, opts = {}) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// src/replay/payload.ts
|
|
78
|
-
var
|
|
78
|
+
var PREVIEW_LEAD = "Same source, plan and 3D preview.";
|
|
79
|
+
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.";
|
|
80
|
+
var PREVIEW_LIMITS = "3D preview: walls, openings, floors, stairs and furniture in flat colours; no pitched roofs yet, and no sections, elevations or BIM.";
|
|
81
|
+
var PREVIEW_ABOUT_URL = "https://archlang.uk/3d";
|
|
79
82
|
function viewBoxOf(svg) {
|
|
80
83
|
const m = /viewBox="([-\d.\s]+)"/.exec(svg);
|
|
81
84
|
const v = (m?.[1] ?? "").trim().split(/\s+/).map(Number);
|
|
@@ -131,7 +134,10 @@ export {
|
|
|
131
134
|
VIEW_HINT,
|
|
132
135
|
VIEW_CONTROLS_LABEL,
|
|
133
136
|
viewToolbar,
|
|
137
|
+
PREVIEW_LEAD,
|
|
134
138
|
PREVIEW_LABEL,
|
|
139
|
+
PREVIEW_LIMITS,
|
|
140
|
+
PREVIEW_ABOUT_URL,
|
|
135
141
|
viewBoxOf,
|
|
136
142
|
replayPayload
|
|
137
143
|
};
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARCHLANG_3D_VERSION,
|
|
3
3
|
validateScene3D
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-EG7UT2HG.js";
|
|
5
5
|
import {
|
|
6
6
|
PREVIEW_LABEL,
|
|
7
|
+
PREVIEW_LIMITS,
|
|
7
8
|
VIEW_CONTROLS_LABEL,
|
|
8
9
|
replayPayload
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-KF5ME6KH.js";
|
|
10
11
|
import {
|
|
11
12
|
FINISH_PALETTE,
|
|
12
13
|
FLOOR_FINISHES,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
keyFrames,
|
|
16
17
|
linearRgb,
|
|
17
18
|
slotGroups
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-EQBMPXB5.js";
|
|
19
20
|
|
|
20
21
|
// src/node.ts
|
|
21
22
|
import { readFileSync as readFileSync2 } from "node:fs";
|
|
@@ -97,6 +98,7 @@ canvas:focus-visible{outline:2px solid ${fg};outline-offset:2px}
|
|
|
97
98
|
<input id="archlang-replay-t" type="range" min="0" max="1" step="0.001" value="0" aria-label="Replay position">
|
|
98
99
|
<div id="archlang-replay-views"></div>
|
|
99
100
|
<p>${escapeHtml(PREVIEW_LABEL)}</p>
|
|
101
|
+
<p>${escapeHtml(PREVIEW_LIMITS)}</p>
|
|
100
102
|
</main>
|
|
101
103
|
<script type="application/json" id="archlang-replay-payload">${json}</script>
|
|
102
104
|
<script>${script}</script>
|
|
@@ -121,20 +123,20 @@ var SWIFTSHADER_ARGS = [
|
|
|
121
123
|
];
|
|
122
124
|
|
|
123
125
|
// src/replay/video.ts
|
|
126
|
+
function seekOnly(html) {
|
|
127
|
+
return html.replace(
|
|
128
|
+
'<script type="application/json"',
|
|
129
|
+
// No scrollbar may shift the canvas between frames.
|
|
130
|
+
'<style>html,body{overflow:hidden}</style><script>window.__replayAutoplay=false</script>\n<script type="application/json"'
|
|
131
|
+
);
|
|
132
|
+
}
|
|
124
133
|
async function renderReplay(o) {
|
|
125
134
|
const fps = o.fps ?? 30;
|
|
126
135
|
const seconds = o.seconds ?? 15;
|
|
127
136
|
const frames = Math.round(fps * seconds);
|
|
128
137
|
const dir = mkdtempSync(join2(tmpdir(), "archlang3d-replay-"));
|
|
129
138
|
const file = join2(dir, "replay.html");
|
|
130
|
-
writeFileSync(
|
|
131
|
-
file,
|
|
132
|
-
o.html.replace(
|
|
133
|
-
'<script type="application/json"',
|
|
134
|
-
// No scrollbar may shift the canvas between frames.
|
|
135
|
-
'<style>html,body{overflow:hidden}</style><script>window.__replayAutoplay=false</script>\n<script type="application/json"'
|
|
136
|
-
)
|
|
137
|
-
);
|
|
139
|
+
writeFileSync(file, seekOnly(o.html));
|
|
138
140
|
const { chromium } = await import("playwright-core");
|
|
139
141
|
const browser = await chromium.launch({ args: SWIFTSHADER_ARGS });
|
|
140
142
|
try {
|
|
@@ -183,7 +185,7 @@ async function renderReplay(o) {
|
|
|
183
185
|
"-pix_fmt",
|
|
184
186
|
"yuv420p",
|
|
185
187
|
"-crf",
|
|
186
|
-
|
|
188
|
+
String(o.crf ?? 18),
|
|
187
189
|
"-movflags",
|
|
188
190
|
"+faststart",
|
|
189
191
|
o.mp4
|