roamwright 0.61.16 → 0.61.17

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.
@@ -0,0 +1,475 @@
1
+ import {
2
+ bearingOf,
3
+ bindMapInput,
4
+ clusterMapPoints,
5
+ createAtlasRelief,
6
+ createCompassStrip,
7
+ createMapLabelSet,
8
+ createNoise,
9
+ createWhereabouts,
10
+ distanceText,
11
+ drawMapCompass,
12
+ drawMapGlyph,
13
+ drawMapLabel,
14
+ drawMapScaleBar,
15
+ formatSpotCard,
16
+ frameMapSheet,
17
+ mulberry32,
18
+ paintMapPick,
19
+ paintMapVisitor,
20
+ paintTerrainSheet,
21
+ pickMapHit,
22
+ rectUnionOutline,
23
+ roundedDistance,
24
+ sheetMaxZoom,
25
+ sheetMinZoom,
26
+ spacedCaps,
27
+ } from 'roamwright';
28
+ import { clamp, sstep } from 'roamwright/math/scalar.js';
29
+ import { readSeed } from './stage.js';
30
+
31
+ const seed = readSeed(42);
32
+ const random = mulberry32(seed);
33
+ const noise = createNoise(seed);
34
+
35
+ const byId = id => document.getElementById(id);
36
+ const canvas = document.querySelector('canvas');
37
+ const ctx = canvas.getContext('2d');
38
+ const [whereLine, pickCard, pickName, pickKind, pickDesc] = ['where-line', 'pick-card', 'pick-name', 'pick-kind', 'pick-desc'].map(byId);
39
+ const pairs = flat => Array.from({ length: flat.length / 2 }, (_, i) => [flat[i * 2], flat[i * 2 + 1]]);
40
+
41
+ const SHEET_W = 1600;
42
+ const SHEET_H = 1000;
43
+ const LAND_SIZE = 2000;
44
+ const STRIDE = 192;
45
+
46
+ // Generate a seeded western continent and eastern archipelago with bays and peninsulas.
47
+ function makeIslandPoly(cx, cy, rx, ry, sides, lobeAmp = 0.28, phase = 0) {
48
+ const poly = [];
49
+ for (let i = 0; i < sides; i++) {
50
+ const a = (i / sides) * Math.PI * 2;
51
+ const lobe = 1 + lobeAmp * Math.sin(a * 2 + phase) + 0.14 * Math.cos(a * 3 - phase * 0.7);
52
+ const warp = (0.76 + 0.36 * noise.fbm(Math.cos(a) * 1.6 + cx * 0.01, Math.sin(a) * 1.6 + cy * 0.01, 3, 19)) * lobe;
53
+ poly.push([cx + Math.cos(a) * rx * warp, cy + Math.sin(a) * ry * warp]);
54
+ }
55
+ return poly;
56
+ }
57
+
58
+ const westPoly = makeIslandPoly(440, 490, 310, 240, 18, 0.24, 0.4);
59
+ const eastPoly = makeIslandPoly(1145, 490, 275, 245, 16, 0.22, -0.8);
60
+ const islePoly = makeIslandPoly(830, 755, 108, 66, 11, 0.18, 1.1);
61
+
62
+ const frameBox = { x: 960, y: 290, side: 360 };
63
+ const frameOutline = rectUnionOutline([frameBox]);
64
+
65
+ const atlasRelief = createAtlasRelief({
66
+ sheetWidth: SHEET_W,
67
+ sheetHeight: SHEET_H,
68
+ seed: seed * 17 + 4411,
69
+ lands: [{ poly: westPoly }, { poly: eastPoly }, { poly: islePoly }],
70
+ relief: [
71
+ {
72
+ k: 'range',
73
+ pts: pairs([280, 360 + (random() - 0.5) * 40, 430, 430 + (random() - 0.5) * 40, 560, 560 + (random() - 0.5) * 30]),
74
+ w: 28,
75
+ size: 6,
76
+ },
77
+ {
78
+ k: 'range',
79
+ pts: pairs([1020, 350 + (random() - 0.5) * 30, 1180, 410 + (random() - 0.5) * 30, 1280, 520 + (random() - 0.5) * 30]),
80
+ w: 22,
81
+ size: 5.5,
82
+ },
83
+ { k: 'forest', at: [390, 570], r: [95, 75], turn: 0.25 },
84
+ { k: 'forest', at: [1090, 540], r: [85, 65], turn: -0.3 },
85
+ { k: 'desert', at: [570, 390], r: [88, 62], turn: -0.2 },
86
+ { k: 'plateau', at: [1220, 580], r: [52, 34], turn: 0.35 },
87
+ { k: 'water', at: [1135, 470], r: [32, 22], turn: 0.1 },
88
+ ],
89
+ rivers: [pairs([420, 440, 480, 500, 540, 560, 620, 620, 690, 660]), pairs([1150, 390, 1135, 470, 1080, 540, 1010, 610])],
90
+ routes: [
91
+ { n: 'Eastbound Merchant Passage', book: 1, pts: pairs([690, 640, 835, 665, 980, 585]) },
92
+ { n: 'Northern Trade Run', book: 2, pts: pairs([660, 360, 810, 285, 985, 360]) },
93
+ ],
94
+ });
95
+
96
+ // Bake a procedural island heightfield for the Terrain sheet and Parchment views.
97
+ const heights = new Float32Array(STRIDE * STRIDE);
98
+ const colors = new Uint8Array(STRIDE * STRIDE * 3);
99
+ for (let j = 0; j < STRIDE; j++) {
100
+ for (let i = 0; i < STRIDE; i++) {
101
+ const nx = (i / (STRIDE - 1)) * 2 - 1;
102
+ const nz = (j / (STRIDE - 1)) * 2 - 1;
103
+ const radial = Math.hypot(nx * 1.05, nz * 1.15);
104
+ const shape = 1 - sstep(0.42, 0.94, radial + 0.16 * noise.fbm(nx * 2.2, nz * 2.2, 3, 31));
105
+ const ridge = 42 * noise.ridged(nx * 2.8, nz * 2.8, 4, 17);
106
+ const h = -12 + shape * (24 + ridge + 14 * noise.fbm(nx * 3.4, nz * 3.4, 3, 5));
107
+ const k = j * STRIDE + i;
108
+ heights[k] = h;
109
+ const meadow = sstep(2, 16, h);
110
+ const rock = sstep(28, 46, h);
111
+ colors[k * 3] = clamp(Math.round(196 * (1 - meadow) + 122 * meadow * (1 - rock) + 150 * rock), 0, 255);
112
+ colors[k * 3 + 1] = clamp(Math.round(178 * (1 - meadow) + 142 * meadow * (1 - rock) + 146 * rock), 0, 255);
113
+ colors[k * 3 + 2] = clamp(Math.round(132 * (1 - meadow) + 92 * meadow * (1 - rock) + 138 * rock), 0, 255);
114
+ }
115
+ }
116
+
117
+ const land = {
118
+ id: 'isle',
119
+ name: 'Alder Reach',
120
+ x0: -LAND_SIZE / 2,
121
+ z0: -LAND_SIZE / 2,
122
+ size: LAND_SIZE,
123
+ stride: STRIDE,
124
+ colors,
125
+ depth: k => -heights[k],
126
+ normal(k, out) {
127
+ const i = k % STRIDE;
128
+ const j = (k / STRIDE) | 0;
129
+ const hL = heights[j * STRIDE + Math.max(0, i - 1)];
130
+ const hR = heights[j * STRIDE + Math.min(STRIDE - 1, i + 1)];
131
+ const hU = heights[Math.max(0, j - 1) * STRIDE + i];
132
+ const hD = heights[Math.min(STRIDE - 1, j + 1) * STRIDE + i];
133
+ const dx = (hL - hR) * 0.12;
134
+ const dz = (hU - hD) * 0.12;
135
+ const len = Math.hypot(dx, 1, dz);
136
+ out[0] = dx / len;
137
+ out[1] = 1 / len;
138
+ out[2] = dz / len;
139
+ return out;
140
+ },
141
+ toAtlas: (x, z) => [
142
+ frameBox.x + ((x + LAND_SIZE / 2) / LAND_SIZE) * frameBox.side,
143
+ frameBox.y + ((z + LAND_SIZE / 2) / LAND_SIZE) * frameBox.side,
144
+ ],
145
+ fromAtlas: (x, y) => [
146
+ ((x - frameBox.x) / frameBox.side) * LAND_SIZE - LAND_SIZE / 2,
147
+ ((y - frameBox.y) / frameBox.side) * LAND_SIZE - LAND_SIZE / 2,
148
+ ],
149
+ };
150
+
151
+ const shadedSheet = paintTerrainSheet(land, true, { noise: noise.vnoise });
152
+ const parchmentSheet = paintTerrainSheet(land, false, { noise: noise.vnoise });
153
+
154
+ const atlasPlaces = [
155
+ { n: 'Highhaven', x: 640, y: 610, k: 'cities', kind: 'Harbour city', desc: 'Walled trading port at the river mouth.' },
156
+ { n: 'Cairnwatch', x: 350, y: 455, k: 'holy', kind: 'Sanctuary', desc: 'Stone citadel overlooking the western pass.' },
157
+ { n: 'Alderford', x: 1090, y: 495, k: 'cities', kind: 'City', desc: 'Timber and stone town beside the central lake.' },
158
+ { n: 'Saltmere', x: 1240, y: 435, k: 'town', kind: 'Town', desc: 'Quarry town below the eastern ridge.' },
159
+ { n: 'South Beacon', x: 835, y: 745, k: 'enter', kind: 'Lighthouse', desc: 'Enterable stone tower guarding the channel.' },
160
+ { n: 'Old Crossing', x: 520, y: 530, k: 'battle', kind: 'Historic ford', desc: 'Stone bridgehead across the valley river.' },
161
+ ];
162
+
163
+ const landPlaces = [
164
+ { id: 'alderford', space: 'isle', kind: 'city', name: 'Alderford', x: -120, z: 60, desc: 'Market town on the sheltered cove.' },
165
+ {
166
+ id: 'ridgekeep',
167
+ space: 'isle',
168
+ kind: 'landmark',
169
+ name: 'Ridgekeep',
170
+ x: 240,
171
+ z: -180,
172
+ enter: true,
173
+ desc: 'Enterable stone watchtower on the northern crest.',
174
+ },
175
+ {
176
+ id: 'oldmill',
177
+ space: 'isle',
178
+ kind: 'landmark',
179
+ name: 'The Old Mill',
180
+ x: -340,
181
+ z: -160,
182
+ desc: 'Watermill at the head of the valley stream.',
183
+ },
184
+ {
185
+ id: 'cove',
186
+ space: 'isle',
187
+ kind: 'region',
188
+ name: 'Emerald Reach',
189
+ x: 60,
190
+ z: 290,
191
+ desc: 'Broad coastal grassland facing the south strait.',
192
+ },
193
+ ];
194
+
195
+ const landMarkers = [
196
+ { x: -100, z: 45, title: 'Harbour Fair' },
197
+ { x: -80, z: 58, title: 'Timber Quay' },
198
+ { x: 210, z: -140, title: 'Signal Fire' },
199
+ ];
200
+
201
+ const landRoads = [pairs([-340, -160, -210, -50, -120, 60, 80, -30, 240, -180])];
202
+ const landRivers = [pairs([160, -420, 60, -210, -10, -40, -90, 120, -180, 390])];
203
+
204
+ const visitor = { x: -40, z: 120, yaw: 0.45 };
205
+ const state = {
206
+ mode: 'atlas',
207
+ wx: SHEET_W * 0.5,
208
+ wy: SHEET_H * 0.5,
209
+ wz: 1,
210
+ cx: 0,
211
+ cz: 0,
212
+ zoom: 1,
213
+ w: 1,
214
+ h: 1,
215
+ dpr: 1,
216
+ k: 1,
217
+ hits: [],
218
+ sel: { x: 640, z: 610, world: true, name: 'Highhaven', kind: 'Harbour city', desc: 'Walled trading port at the river mouth.' },
219
+ };
220
+ const mv = { x0: 0, z0: 0, k: 1, w: 1, h: 1, u: 1, mini: false };
221
+
222
+ const wb = createWhereabouts({
223
+ getLocations: () => landPlaces,
224
+ getSpace: () => ({ id: 'isle', flyable: true, name: 'Alder Reach' }),
225
+ });
226
+ const camProxy = { x: visitor.x, z: visitor.z, yaw: visitor.yaw };
227
+ const compass = createCompassStrip({
228
+ getStrip: () => document.getElementById('compass-strip'),
229
+ getContainer: () => document.getElementById('compass'),
230
+ getLocations: () => landPlaces,
231
+ getCamera: () => camProxy,
232
+ getWaypoint: () => ({ pos: { x: 240, z: -180 }, title: 'Ridgekeep' }),
233
+ kindOf: wb.kindOf,
234
+ placeOf(loc, out) {
235
+ if (!wb.placeOf(loc)) return false;
236
+ out.x = wb.placeAt.x;
237
+ out.z = wb.placeAt.z;
238
+ return true;
239
+ },
240
+ bearingOf,
241
+ roundDistance: roundedDistance,
242
+ formatDistance: distanceText,
243
+ });
244
+ compass.build();
245
+
246
+ function showPick(sel) {
247
+ state.sel = sel;
248
+ pickCard.hidden = !sel;
249
+ if (!sel) return;
250
+ pickName.textContent = sel.name;
251
+ pickKind.textContent = sel.kind || '';
252
+ pickDesc.textContent = sel.desc || '';
253
+ }
254
+ showPick(state.sel);
255
+
256
+ function resize() {
257
+ state.dpr = Math.min(window.devicePixelRatio || 1, 2);
258
+ const w = Math.max(1, window.innerWidth);
259
+ const h = Math.max(1, window.innerHeight);
260
+ state.w = canvas.width = Math.round(w * state.dpr);
261
+ state.h = canvas.height = Math.round(h * state.dpr);
262
+ }
263
+ window.addEventListener('resize', resize);
264
+ resize();
265
+
266
+ function zoomBy(factor) {
267
+ if (state.mode === 'atlas') state.wz = clamp(state.wz * factor, 1, 8);
268
+ else state.zoom = clamp(state.zoom * factor, sheetMinZoom(state.w, state.h), sheetMaxZoom(land.size));
269
+ }
270
+
271
+ bindMapInput(canvas, {
272
+ getSize: () => ({ w: state.w, h: state.h }),
273
+ onPan(dx, dy) {
274
+ const step = state.dpr / state.k;
275
+ if (state.mode === 'atlas') {
276
+ state.wx -= dx * step;
277
+ state.wy -= dy * step;
278
+ } else {
279
+ state.cx -= dx * step;
280
+ state.cz -= dy * step;
281
+ }
282
+ },
283
+ onZoom: zoomBy,
284
+ onTap(px, py) {
285
+ const hit = pickMapHit(state.hits, px, py, state.dpr);
286
+ if (hit) {
287
+ showPick(hit.sel);
288
+ return;
289
+ }
290
+ const sx = mv.x0 + px / mv.k;
291
+ const sz = mv.z0 + py / mv.k;
292
+ if (state.mode === 'atlas') {
293
+ const [lx, lz] = land.fromAtlas(sx, sz);
294
+ showPick(formatSpotCard({ land, x: lx, z: lz, at: { x: sx, z: sz, world: true }, namedPlaces: landPlaces }));
295
+ } else {
296
+ showPick(formatSpotCard({ land, x: sx, z: sz, at: { x: sx, z: sz, world: false }, namedPlaces: landPlaces }));
297
+ }
298
+ },
299
+ });
300
+
301
+ for (const btn of document.querySelectorAll('[data-view]')) {
302
+ btn.addEventListener('click', () => {
303
+ state.mode = btn.dataset.view;
304
+ for (const other of document.querySelectorAll('[data-view]')) {
305
+ other.setAttribute('aria-pressed', String(other === btn));
306
+ }
307
+ if (state.mode === 'atlas') {
308
+ showPick({ x: 640, z: 610, world: true, name: 'Highhaven', kind: 'Harbour city', desc: 'Walled trading port at the river mouth.' });
309
+ } else {
310
+ showPick({ x: -120, z: 60, world: false, name: 'Alderford', kind: 'City', desc: 'Market town on the sheltered cove.' });
311
+ }
312
+ });
313
+ }
314
+
315
+ function paintAtlas() {
316
+ [state.wx, state.wy] = frameMapSheet(mv, {
317
+ cx: state.wx,
318
+ cz: state.wy,
319
+ zoom: state.wz,
320
+ originX: 0,
321
+ originZ: 0,
322
+ sheetWidth: SHEET_W,
323
+ sheetHeight: SHEET_H,
324
+ canvasWidth: state.w,
325
+ canvasHeight: state.h,
326
+ dpr: state.dpr,
327
+ whole: false,
328
+ });
329
+ state.k = mv.k;
330
+ const X = x => (x - mv.x0) * mv.k;
331
+ const Y = y => (y - mv.z0) * mv.k;
332
+ const u = mv.u;
333
+ state.hits.length = 0;
334
+
335
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
336
+ ctx.drawImage(atlasRelief.getCanvas(mv), 0, 0);
337
+
338
+ // Framed explorable region overlay.
339
+ ctx.fillStyle = 'rgba(98,230,203,.12)';
340
+ ctx.fillRect(X(frameBox.x), Y(frameBox.y), frameBox.side * mv.k, frameBox.side * mv.k);
341
+ ctx.strokeStyle = '#62e6cb';
342
+ ctx.lineWidth = 1.8 * u;
343
+ ctx.beginPath();
344
+ for (let i = 0; i < frameOutline.length; i += 4) {
345
+ ctx.moveTo(X(frameOutline[i]), Y(frameOutline[i + 1]));
346
+ ctx.lineTo(X(frameOutline[i + 2]), Y(frameOutline[i + 3]));
347
+ }
348
+ ctx.stroke();
349
+
350
+ const labels = createMapLabelSet(ctx, state.w, state.h, u);
351
+ labels.on(spacedCaps('Westreach'), X(410), Y(485), 16 * u, { italic: true, must: true });
352
+ labels.on(spacedCaps('East Isles'), X(1160), Y(690), 15 * u, { italic: true, must: true });
353
+ labels.on('Alder Reach', X(frameBox.x + frameBox.side / 2), Y(frameBox.y) - 10 * u, 12 * u, { color: '#8ff0dc', must: true });
354
+
355
+ for (const p of atlasPlaces) {
356
+ const px = X(p.x);
357
+ const py = Y(p.y);
358
+ drawMapGlyph(ctx, p.k, px, py, u * (p.k === 'cities' ? 1.15 : 0.95));
359
+ labels.keep(px, py, 8 * u);
360
+ if (!(state.sel?.world && state.sel.name === p.n)) {
361
+ labels.beside(p.n, px, py, (p.k === 'cities' ? 13 : 11) * u, { must: p.k === 'cities', gap: 13 });
362
+ }
363
+ state.hits.push({ x: px, y: py, r: 14 * u, sel: { x: p.x, z: p.y, world: true, name: p.n, kind: p.kind, desc: p.desc } });
364
+ }
365
+
366
+ const [vx, vy] = land.toAtlas(visitor.x, visitor.z);
367
+ paintMapVisitor(ctx, X(vx), Y(vy), u, camProxy.yaw);
368
+ labels.keep(X(vx), Y(vy), 14 * u);
369
+ labels.flush();
370
+ drawMapCompass(ctx, state.w - 30 * u, state.h - 80 * u, u);
371
+ drawMapLabel(ctx, 'not to scale', state.w - 50 * u, state.h - 76 * u, 10.5 * u, {
372
+ italic: true,
373
+ color: 'rgba(243,236,217,.65)',
374
+ align: 'right',
375
+ });
376
+ if (state.sel?.world) paintMapPick(ctx, X(state.sel.x), Y(state.sel.z), u, state.sel.name);
377
+ }
378
+
379
+ function paintLandSheet() {
380
+ [state.cx, state.cz] = frameMapSheet(mv, {
381
+ cx: state.cx,
382
+ cz: state.cz,
383
+ zoom: state.zoom,
384
+ originX: land.x0,
385
+ originZ: land.z0,
386
+ sheetWidth: land.size,
387
+ sheetHeight: land.size,
388
+ canvasWidth: state.w,
389
+ canvasHeight: state.h,
390
+ dpr: state.dpr,
391
+ whole: false,
392
+ });
393
+ state.k = mv.k;
394
+ const X = x => (x - mv.x0) * mv.k;
395
+ const Z = z => (z - mv.z0) * mv.k;
396
+ const u = mv.u;
397
+ state.hits.length = 0;
398
+
399
+ ctx.setTransform(1, 0, 0, 1, 0, 0);
400
+ ctx.fillStyle = '#0b1114';
401
+ ctx.fillRect(0, 0, state.w, state.h);
402
+ ctx.imageSmoothingEnabled = true;
403
+ ctx.imageSmoothingQuality = 'high';
404
+ ctx.drawImage(state.mode === 'terrain' ? shadedSheet : parchmentSheet, X(land.x0), Z(land.z0), land.size * mv.k, land.size * mv.k);
405
+
406
+ // Rivers & roads
407
+ ctx.strokeStyle = '#5a9cc4';
408
+ ctx.lineWidth = Math.max(2 * u, 12 * mv.k);
409
+ ctx.lineCap = 'round';
410
+ for (const r of landRivers) {
411
+ ctx.beginPath();
412
+ r.forEach(([rx, rz], i) => (i ? ctx.lineTo(X(rx), Z(rz)) : ctx.moveTo(X(rx), Z(rz))));
413
+ ctx.stroke();
414
+ }
415
+ for (const r of landRoads) {
416
+ ctx.beginPath();
417
+ r.forEach(([rx, rz], i) => (i ? ctx.lineTo(X(rx), Z(rz)) : ctx.moveTo(X(rx), Z(rz))));
418
+ ctx.strokeStyle = 'rgba(30,22,14,.8)';
419
+ ctx.lineWidth = 3.2 * u;
420
+ ctx.setLineDash([]);
421
+ ctx.stroke();
422
+ ctx.strokeStyle = '#ecd9a8';
423
+ ctx.lineWidth = 1.5 * u;
424
+ ctx.setLineDash([5 * u, 3.5 * u]);
425
+ ctx.stroke();
426
+ }
427
+ ctx.setLineDash([]);
428
+
429
+ const labels = createMapLabelSet(ctx, state.w, state.h, u);
430
+ if (state.sel && !state.sel.world) {
431
+ labels.keep(X(state.sel.x), Z(state.sel.z) - 22 * u, 30 * u);
432
+ }
433
+ for (const loc of landPlaces) {
434
+ const px = X(loc.x);
435
+ const py = Z(loc.z);
436
+ if (loc.kind === 'region') {
437
+ labels.on(spacedCaps(loc.name), px, py, 13 * u, { italic: true, color: 'rgba(243,236,217,.85)' });
438
+ continue;
439
+ }
440
+ const glyph = loc.kind === 'city' ? 'cities' : loc.enter ? 'enter' : 'landmarks';
441
+ drawMapGlyph(ctx, glyph, px, py, u * 1.15);
442
+ labels.keep(px, py, 10 * u);
443
+ if (!(state.sel && !state.sel.world && state.sel.name === loc.name)) {
444
+ labels.beside(loc.name, px, py, (loc.kind === 'city' ? 15 : 12) * u, { must: true });
445
+ }
446
+ state.hits.push({ x: px, y: py, r: 15 * u, sel: { x: loc.x, z: loc.z, world: false, name: loc.name, kind: loc.kind, desc: loc.desc } });
447
+ }
448
+
449
+ for (const cluster of clusterMapPoints(landMarkers, X, Z, 20 * u)) {
450
+ const count = cluster.list.length;
451
+ drawMapGlyph(ctx, 'scenes', cluster.x, cluster.y, u * (count > 1 ? 1.6 : 1.2));
452
+ labels.keep(cluster.x, cluster.y, 12 * u);
453
+ labels.beside(count > 1 ? `${count} events` : cluster.list[0].title, cluster.x, cluster.y, 10 * u, { italic: true, color: '#ffd9a0' });
454
+ }
455
+
456
+ paintMapVisitor(ctx, X(visitor.x), Z(visitor.z), u, camProxy.yaw);
457
+ labels.flush();
458
+ drawMapScaleBar(ctx, { w: state.w, h: state.h - 118 * u, k: mv.k, u });
459
+ if (state.sel && !state.sel.world) paintMapPick(ctx, X(state.sel.x), Z(state.sel.z), u, state.sel.name);
460
+ }
461
+
462
+ let last = performance.now();
463
+ function tick(now) {
464
+ const dt = Math.min(0.1, (now - last) / 1000);
465
+ last = now;
466
+ camProxy.yaw = 0.45 + Math.sin(now * 0.00035) * 0.65;
467
+ compass.update(dt);
468
+ if (wb.update(visitor.x, visitor.z) || !whereLine.textContent) {
469
+ whereLine.textContent = wb.where.way ? `${wb.where.name} · ${wb.where.way}` : wb.where.name;
470
+ }
471
+ if (state.mode === 'atlas') paintAtlas();
472
+ else paintLandSheet();
473
+ requestAnimationFrame(tick);
474
+ }
475
+ requestAnimationFrame(tick);
package/index.js CHANGED
@@ -257,3 +257,70 @@ export { createPerfBox } from './rendering/perf-box.js';
257
257
  export { PERF_BOX_DEFAULTS, attachPerfBoxWorker, createPerfBoxRenderer } from './rendering/perf-box-worker.js';
258
258
  export { createFrameSampler } from './runtime/perf-probe.js';
259
259
  export { flyProbeRoute, runSelfProbe } from './rendering/perf-probe.js';
260
+
261
+ // ── Map kit ──────────────────────────────────────────────────────────────
262
+ export {
263
+ clampViewCenter,
264
+ clusterMapPoints,
265
+ fitMapDimensions,
266
+ frameMapSheet,
267
+ pickMapHit,
268
+ rectUnionOutline,
269
+ sheetMaxZoom,
270
+ sheetMinZoom,
271
+ } from './runtime/map-view.js';
272
+ export { COMPASS_WINDS, describeMapSpot, findLandAtAtlas, formatSpotCard, isOnLand, landOffCentre } from './runtime/map-spot.js';
273
+ export {
274
+ brokenCoast,
275
+ buildAtlasMarks,
276
+ rangePeaks,
277
+ routeLength,
278
+ routeMidpoint,
279
+ scatterReliefMarks,
280
+ shadeTerrainPixel,
281
+ } from './runtime/map-relief.js';
282
+ export {
283
+ DEFAULT_MAP_FONT,
284
+ MAP_COLORS,
285
+ MAP_GLYPHS,
286
+ drawDune,
287
+ drawMapArch,
288
+ drawMapCompass,
289
+ drawMapDisc,
290
+ drawMapGlyph,
291
+ drawMapLabel,
292
+ drawMapNote,
293
+ drawMapPoly,
294
+ drawMapScaleBar,
295
+ drawPeak,
296
+ drawTree,
297
+ } from './rendering/map-glyphs.js';
298
+ export { createMapLabelSet, spacedCaps, turnAlongLine } from './rendering/map-labels.js';
299
+ export { paintMapPick, paintMapVisitor } from './rendering/map-signs.js';
300
+ export { createAtlasRelief, paintTerrainSheet } from './rendering/map-relief.js';
301
+ export { bindMapInput, fitMapCanvas } from './rendering/map-input.js';
302
+
303
+ // ── Controls, HUD & wayfinding ───────────────────────────────────────────
304
+ export { createStageFrame } from './runtime/stage-frame.js';
305
+ export { createWorldControls } from './runtime/world-controls.js';
306
+ export { COMPASS_POINTS, compassStripHtml, createCompassStrip } from './runtime/compass-strip.js';
307
+ export { createWayBack } from './runtime/way-back.js';
308
+ export { createHudFrame, formatDayClock } from './runtime/hud-frame.js';
309
+ export {
310
+ COMPASS_CARDINALS,
311
+ DEFAULT_PLACE_KINDS,
312
+ bearingOf,
313
+ createWhereabouts,
314
+ distanceText,
315
+ inSentence,
316
+ roundedDistance,
317
+ } from './runtime/whereabouts.js';
318
+ export { createUrlRouter, defaultSlug, normalizeSlash, parseRoutePath } from './runtime/url-router.js';
319
+ export { DEFAULT_PLACE_TAG_STYLES, DEFAULT_SMALL_TAG_STYLES, createPlaceNames } from './rendering/place-names.js';
320
+ export { createPanelShell, scrollItemIntoView } from './runtime/panel-shell.js';
321
+ export { DEFAULT_PORTRAIT_GROUND, convertPortraitPixels, createPortraitStudio } from './rendering/portrait-studio.js';
322
+ export { boxesOverlapOBB, placeLinkLabel, renderRelationGraph } from './runtime/relation-graph.js';
323
+ export { lowerQualityLevel, watchContextLost } from './runtime/context-lost.js';
324
+ export { extractBuildId, watchBuildFreshness } from './runtime/build-freshness.js';
325
+ export { pickScreenActor, pickScreenTag } from './rendering/screen-pick.js';
326
+ export { findClearExit, stepDoorwayTrigger } from './runtime/doorways.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roamwright",
3
- "version": "0.61.16",
3
+ "version": "0.61.17",
4
4
  "description": "A procedural worldbuilding engine built on top of Three.js. Generate landscapes with rivers and changing weather, animate crowds, and explore on foot or in flight.",
5
5
  "keywords": [
6
6
  "threejs",