# Spoor 1 diorama — Three.js reconstruction

Interactive 1:32 (Gauge 1) diorama of the *Magnolia & Gulf Railway – Ben Nance* plan (Bob Sprague),
dressed as a Dutch (NS) railway of the 1960s.

## Run

```bash
python -m http.server 8732
```

Open http://localhost:8732 (ES modules need a web server; Three.js r170 loads from jsDelivr).

## Sources (authoritative order)

1. `source/plan.pdf` — vector plan. **All track geometry comes from it**: the 78 pink 9-pt track-bed
   strokes are the track centre lines (75 after removing 3 zero-length strokes). Nothing is traced by hand.
2. `blueprint.jpg` — the same drawing as an image. Used for the overlay, the 2D view and the surface
   classes (woodland, grass, sand, concrete, water). It maps onto the PDF as `px = 1.6875·pt + offset`.

## Phase 1–3: analysis → structured layout → validation

`tools/pdf_paths.py` extracts every vector path. `tools/build_from_pdf.py` builds `js/layout-data.js`:

| Item | Found | Validation |
|---|---|---|
| Track beds (centre lines) | 75 | drawn on the JPG: `qc/pdf_overlay_*.png` (exact alignment) |
| Turnouts | 17 | frog angles 7.6° = **#7.5** (plan default) and 11.3° = **#5** exactly where the plan writes "#5" |
| Curved turnout | TO3 | matched to the plan label "#6c O72/O54" via its leader line |
| Diamond crossing | 1 | measured **30.0°**, matches the plan label "30°" |
| Turntable | 30″ circle | centre/radius from the circle path |
| Radial tracks | 11 | 5 roundhouse stalls (8° pitch) + 5 storage + servicing track |
| Structures | 14 | footprints are the plan's own fill polygons |

Topology (connections, turnouts, crossing) is derived from coinciding endpoints, endpoints on another bed,
and bed/bed intersections. The running train in the app uses this graph, so the connections are tested live.

## Calibration

The plan is drawn at 3/8″ = 1 ft (grid: 27 pt = 12″, room 16′×19′) for **O scale (1:48)**.
Gauge 1 needs parallel track centres of 125–160 mm; the plan has 10.1 pt = 4.49″ = 114 mm.
The whole plan is therefore scaled **uniformly** by **1.228** so the parallel mains are 140 mm apart.
Proportions, angles and topology are unchanged. Result: 1 pt = 13.86 mm, turntable Ø 0.94 m (≈ 30 m
prototype), layout ≈ 6.1 × 7.2 m. 1 Three.js unit = 1 m of the model; Y is up.

Gauge-1 dimensions used: gauge 45 mm, rail 4.8 mm flat-bottom profile, sleepers 81 × 7.8 × 5 mm at
20.3 mm pitch, ballast 156 mm base, adult figure 53–59 mm, contact wire 172 mm above rail (5.5 m).

## Working parts

- **Turnouts**: stock rails fixed; two switch blades (real rail profile, planed tips) pivot at the heel
  with a 6 mm throw, driven by a stretcher bar from a lever with a counterweight and a red/white target.
  There are a cast frog, check rails and long switch timbers where the routes share sleepers.
  Click a turnout (3D, 2D or the TO buttons) to throw it.
- **Train**: an electric loco and three coaches run over the network and follow the turnout settings.
  The train stops at red signals, at a dead end or at the open lift gate. **Keren** reverses it.
- **Signals**: NS three-lamp light signals (dwarf signals in the engine yard) protect the facing points.
  Green means the turnout is straight, yellow means diverging, red means stop (click a signal to force red).
- **Overhead line**: 1500 V DC catenary on all running lines, with portals over parallel tracks, cantilever
  masts on single tracks, a zig-zagged contact wire, a sagging messenger wire and droppers. The engine terminal,
  roundhouse and freight spurs are not electrified.
- **Turntable**: indexes to all 13 connections. **Lift gate** opens on its hinge.

## Assumptions (not determinable from the plan)

- Heights, architecture, colours and the Dutch 1960s styling of all buildings. The footprints are the plan's.
- The plan says "No grades", so all track is at board level. Terrain relief (wooded hills, river valley)
  only occurs away from the track. Two plate-girder bridges carry the left side over the river shown in the photo.
- Catenary mast positions and spans (~1.15 m, ≈ 37 m prototype) are generated, not drawn on the plan.
- Signal positions (0.45 m before each facing turnout) are generated. The plan shows no signals.
- Rolling stock, figures and vehicles are generic period types. They are not replicas of specific models.
- The lift-gate rectangle is taken from the plan's cut lines. The hinge side is an assumption.
- The plan's central operator aisle is filled in: the whole layout is one base plate, and the former aisle is polder meadow with poplar rows.
- Surface types come from the blueprint photo colours and are approximate at their boundaries.

## Code map

`js/geo.js` coordinates and sweep helpers · `js/track.js` ballast/sleepers/rails/turnouts ·
`js/turntable.js` turntable + roundhouse · `js/buildings.js` structures · `js/scenery.js` terrain,
water, bridges, vegetation, fences, lamps · `js/network.js` route graph, train, signals, catenary ·
`js/details.js` rolling stock, figures, vehicles, base plate · `js/main.js` app/UI.

## Credits

* **NS Plan V** treinstel (reizigerstrein 415): model "NS Plan V" door **accessviolation**
  (https://sketchfab.com/accessviolation), bron https://sketchfab.com/3d-models/ns-plan-v-25b6a64ab41f4a5da9f92847a4b77463,
  licentie **CC BY-NC-SA 4.0** (https://creativecommons.org/licenses/by-nc-sa/4.0/). Verkleind naar 1:32, glas vereenvoudigd.
* Geluid elektrisch: "On a Train" door **unfa**, freesound 162766, CC0. Geluid diesel: "Diesel Locomotive V16 GE Engine
  Idling (Loop)" door **WeenyBeany**, freesound 773336, CC BY 4.0 (luisterversies, ingekort tot lussen).
