Build and revise procedural 3D assets with your coding agent. Local MCP server, CLI and TypeScript engine with rendered review, editable source and GLB export.
Golden Gate scene: behaviour
This file specifies the scene's moving parts precisely enough to rebuild them in another engine
(owner direction D-21; PLAN 2.6). The numbers live in the JSON files beside it: layout.json,
traffic.json, driving.json, tiers.json and presets.json. The frame and units are those of
layout.json conventions: metres and seconds, right-handed with +Y up, +X west, +Z north, and
the water at Y = 0. The reference implementation is TypeScript in src/ (traffic/sim.ts,
traffic/traffic.ts, play/car.ts, play/car-pose.ts, camera/flights.ts, world/fog-banks.ts,
world/route.ts, world/alignment.ts, world/approach-mesh.ts, world/corridor.ts). Where this
file and the code disagree, the code is the reference and this file is the bug.
Randomness comes from mulberry32 seeded from the data. To reproduce the web scene exactly, draw
the numbers in the order given below:
function mulberry32(seed) {
let a = seed >>> 0;
return () => { a = (a + 0x6d2b79f5) >>> 0; let t = a; t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61); return ((t ^ (t >>> 14)) >>> 0) / 4294967296; };
}
Route coordinates
The car and the traffic drive one road, the route (world/route.ts): the bridge deck and both
approach roads (section 6). A point on it is a route station σ and a lateral offset d, in metres.
- Deck (
|σ| ≤ roadEndZ).σ = zandd = x. The height is the top of the bridge's Roadway. Over the deck's last 0.98 m, from the last 1 m row of the Roadway's height grid (|z| = 1032) toroadEndZ, it runs linearly to the approach's start elevation. - Approach.
σ = sign · (roadEndZ + s), wheresignis -1 for the south approach and +1 for the north, andsis the approach station from the deck's road end. The point isC(s) + sign · d · N(s):C(s)is the centreline;T(s)is its tangent (increasings), andN = (T.z, -T.x);yis the profile elevation ats, level across the road.
- So
σgrows northward along the whole route, and a lane keeps its deckxas itsdfrom one approach end to the other. - Heading and grade. The route heading is the direction of increasing
σ: +Z on the deck andsign · Ton an approach. The grade isdy/dσ: on the deck a central difference over ±0.5 m, on an approachsign× the profile grade. - Straightened road. The car and the traffic move in route coordinates, as on a straightened road.
On an approach curve of curvature
κ, a lane at offsetdis1 - κ dtimes as long as the centreline. The simulation ignores this; it is at most 2.6 % (the outer lane on the 300 m curve).
1. Traffic
Lanes
- There are six lanes (
layout.jsonlanes). Lanes 0 to 2 are northbound, at x < 0, inner to outer. Lanes 3 to 5 are southbound and mirror them at x > 0. Each lane has:- a lateral position
x, its route offsetdalong the whole route; - a cruising
speed; - the vehicle types it allows (
classes: trucks and buses stay out of the inner lanes); stations, the route stations of its entry and exit at the two approach ends, withentryandexitworld points there (northbound from the south end to the north end, southbound the other way);- a
polylinealong the Roadway from deck end to deck end.
- a lateral position
- A lane is one-dimensional. A vehicle's centre is at
smetres from the entry, where 0 ≤ s ≤ L and L = |stations[1] - stations[0]| = 4010.96 m (the 2065.96 m deck plus the 965 m south and 980 m north approaches).- Its route station is
σ = stations[0] + dir · s, wherediris +1 for north and -1 for south. - It sits at the route point
(σ, x). On the deck the polyline and the Roadway surface agree within 5 mm.
- Its route station is
- Vehicle classes are the six vehicle GLBs. Length, width and wheel radius are measured from each
model's LOD0 bounds and wheels.
traffic.jsonvehicles[].weightis each class's share of entries.
Creating a vehicle
A vehicle is created in lane k at position s. Its values are drawn in this order:
Class. A weighted draw over the classes the lane allows.
Cruise.
cruise = laneSpeed · (1 + (r - 0.5) · speed.personal).Paint. Build the set of colours to avoid:
- the colour of the car directly ahead in the lane;
- every colour within
paint.avoidRadiusofsin the three lanes of the same direction.
Make up to
paint.attemptsweighted draws frompaletteand keep the first colour not in the set. If none qualifies, take the heaviest colour not in the set. If every colour is in the set, take palette entry 0.Tint.
tint = linear(srgb) · (1 + (r - 0.5) · paint.brightnessJitter), wherelinear()is the sRGB transfer function.Phase.
phase = r · 2π.Period.
period = oscillationPeriod[0] + r · (oscillationPeriod[1] - oscillationPeriod[0]).Wheel angle.
spin = r · 2π.
A new vehicle starts at v = cruise, fade = 0 and brake = 0. Its tint replaces the albedo of
the Paint material only; every other material, including CargoBox and Trim, keeps its
authored colour.
An entry headway is drawn as
minHeadway + (meanHeadway - minHeadway) · (-ln(1 - r1) - ln(1 - r2)) / 2, a gamma distribution
with shape 2. meanHeadway is densityHeadway[density], and each tier chooses the density
(tiers.json features.*.traffic). Changing the density affects future entries only. The mean is
never set below minHeadway + 0.5.
Start-up
- The generator is seeded with
traffic.jsonseed. - For lanes 0 to 5, one entry countdown each:
nextEntry = headway(). - Fill. For each lane 0 to 5, with
Vthe lane speed:- Start at
s = L - fade - r · V · meanHeadway. - While
s > fadeand the lane holds fewer thanperLaneMaxvehicles, create a vehicle atswithfade = 1, then sets -= headway() · V. - Set
nextEntry = max(0, -s / V).
- Start at
- Settle. Run 20 s of steps.
Stepping
- The frame time is capped at 0.5 s. It is split into sub-steps of
h = min(remaining, 1 / stepsPerSecond), and scene timetadvances by eachh. - In each sub-step the lanes run 0 to 5. Within a lane, vehicles update leader first, and each follower sees its leader's already-updated state.
Each vehicle updates as follows:
- Gap.
gapruns from the leader's rear to this vehicle's front (∞ with no leader).vLeadis the leader's speed. - Player car. The player's car may be the leader; see "The player's car" below.
- Desired speed.
v0 = cruise · (1 + speed.oscillation · sin(2π t / period + phase)). - IDM (Treiber). Using the
idmvalues:a = accel · (1 - (v / v0)^4);- with a leader, compute
want = gap0 + max(0, v · headway + v · (v - vLead) / (2 · sqrt(accel · brake)))and thena -= accel · (want / max(gap, 0.5))^2; - clamp
ato[-emergency, accel]and setv = max(0, v + a · h).
- Backstop. No vehicle comes closer than
HARD_GAP= 0.5 m to its leader or to the player's car.limitis the leader's (or the car's) rear minus half this vehicle's length minus 0.5.- The new position is
min(s + v · h, max(s, limit)). - If that cut the move short,
v = (new s - s) / h.
- Wheels.
spin += v · h / wheelRadius, wrapped to 2π. - Brake lamp.
brake += ((a < -brakeLights.decel ? 1 : 0) - brake) · min(1, h · brakeLights.rate). - Fade.
fade = min(1, s / fade, (L - s) / fade).traffic.jsonfade(40 m) is no longer than either approach's dissolve stretch, which ends at the lane's end (section 6). So vehicles fade in and out only inside the dissolve stretches, and never at the deck.
After the vehicles, each lane handles its ends:
Exits. Vehicles with
s ≥ Lleave.Entries.
nextEntry -= h. When it reaches 0 or less and the lane has room underperLaneMax, a vehicle enters ats = 0if both hold:- the last vehicle's rear is more than
gap0 + longest class length + vLast · headwayfrom the entry; - the player's car is not in the lane between
s = -20ands = fade + 20.
The entering vehicle's speed is
min(cruise, vLast), andnextEntryis drawn again. If the entry is blocked, the lane retries on every step.- the last vehicle's rear is more than
The player's car
When traffic sees the car. Traffic in lane i sees the car only when both hold:
- the car drives in that lane's direction;
- its footprint enters the lane band:
|car.x - lane.x| < laneWidth / 2 + ex.
Here ex and ez are the car's half extents across and along the lane, including its heading
offset (section 2).
Where it sits. The car's x and z are its route offset and station (section 2). Its lane
position is s = (car.z - stations[0]) · dir. It counts with speed max(0, car speed) and half
length ez.
Who follows it.
- The car leads a vehicle only when it is wholly ahead of that vehicle's front and nearer than its leader.
- A vehicle already alongside keeps going. The car's own rules keep it clear sideways.
- Nothing ever collides physically.
Drawing
Pose.
- Each vehicle stands at its route point and faces its direction of travel: the route heading, reversed for the southbound lanes.
- Its pitch is
atan(dir · grade), with the route's grade. - The wheels spin by
spin, and the front wheels steer (0 for traffic).
LOD.
- Distances use the tier's
traffic.lodvalues[lod1, lod2, cull], defined at a 50° vertical field of view. dis the distance from the camera to the vehicle centre(x, y + height / 2, z). A vehicle withd > cullis not drawn.- The level comes from
d · tan(fov / 2) / tan(25°)against[lod1, lod2], with 6% hysteresis:- a vehicle moves to a coarser level beyond
limit · 1.06; - it moves back to a finer level below
limit · 0.94.
- a vehicle moves to a coarser level beyond
- Levels come from
MSFT_lodwhen present; otherwise from siblingLOD1/LOD2groups; otherwise LOD0 at every distance. - Wheels are drawn at LOD0 and LOD1 only.
- Distances use the tier's
Opacity. Vehicles are dithered (alpha-hashed). The opacity is the smallest of three values:
- the lane
fade; (cull - d) / (0.12 · cull);(along - length / 2 - 0.5) / 4, applied only when the camera stands inside the vehicle's lane footprint (withinwidth / 2 + 0.6across and from 0.5 below the road toheight + 0.5above it). Such a vehicle dissolves instead of passing through the camera.
Vehicles at opacity 0.01 or below are skipped.
- the lane
Driven car. It is always LOD0 and fully opaque.
Shadows. LOD0 and LOD1 cast sun shadows when the tier has shadows.
Contact shadows. A tier without a shadow map (
tiers.jsontraffic.contactShadow> 0) lays a soft black rectangle under each vehicle drawn at LOD0 or LOD1, the driven car included:- centred under the centre of the vehicle's LOD0 bounding box, turned with the vehicle and pitched with the deck, 0.04 m above the road;
- half extents
length / 2 + 0.45andwidth / 2 + 0.45; along each axis the opacity is1 - smoothstep(half - 1.05, half, |distance from the centre|), and the two axes multiply; - peak opacity
contactShadow× the vehicle's opacity ×min(1, (lod2 - d') / (0.2 · lod2)), whered'is the field-of-view-scaled distance, so the shadow is gone before LOD2; - blended over the road without writing depth.
Lamps. Section 5.
2. Driving the sedan (driving.json)
Controls
| Control | Inputs |
|---|---|
throttle |
the forward axis, 0 to 1 |
reverse |
the backward axis, 0 to 1 |
steer |
the side axis, -1 left to +1 right |
brake |
Space |
handbrake |
X |
All keys are listed in controls. While the turn-around fade runs, every control reads 0.
Local review2 adds held Shift boost (8 m/s² acceleration, 42 m/s forward ceiling; ordinary driving
remains 5 m/s² and 29 m/s). Traffic, road-end, curb and service-brake constraints still apply.
On touch the kit's VirtualJoystick in its throttle mode drives and steers. Its
forward and side axes are read separately: each has a dead zone of 12 % of the stick's 66 px reach
and rises linearly to 1 at full reach. Separate held Boost and Brake buttons sit opposite the
joystick. "Leave the car" in the toolbar exits driving. The orbit overview has no camera pad on touch: a drag
orbits, a pinch zooms, a two-finger drag pans and "Reset view" in the toolbar returns the camera to
its home pose (D-22; touch is the last touch or pen input, or a coarse pointer unless the keyboard
was used last). Keyboard and mouse layouts keep the pad with its Reset button.
Car state and stepping
State. The car's state is:
dir(+1 north, -1 south);xandz, the car's route offsetdand route stationσ("Route coordinates");- the signed
speed; - the heading offset
offsetfrom the lane direction (radians, positive to the left); - the front
wheelangle, the wheelspinand thebrakeLightlevel; - timers
held,curbCooldownandendHold, and thebumppitch.
The heading is
yaw = (dir > 0 ? 0 : π) + offset, and forward is(sin yaw, cos yaw)in (x, z), in route coordinates.Stepping. Steps are fixed at
h= 1/120 s. The frame time goes into an accumulator capped at 0.5 s.Traffic. The car sees the traffic of its own direction within 200 m as boxes, taken at the start of the frame. Between the car's steps each box moves on at its own speed.
Each step does the following, in order.
1. Longitudinal. Let coast(v) = coast.constant + coast.quadratic · v².
Rolling forward (v > 0).
driveisaccel · throttle · (1 - (v / topSpeed)²)with the throttle on, else-coast(v).stopis the largest ofbrake · brakeIn,brake · reverseandhandbrake(when held).v = max(0, v + (drive - stop) · h).
Rolling backward (v < 0).
driveis-reverse.accel · reversewhile|v| < reverse.maxSpeed; else 0 with reverse held, or+coast(v)without it.stopis the largest ofbrake · brakeIn,brake · throttleandhandbrake.v = min(0, v + (drive + stop) · h).
At rest (v = 0). "Free" means neither brake nor handbrake is held.
- With the throttle on and free,
v = accel · throttle · h. - With reverse on and free,
held += h. Onceheld ≥ reverse.afterStopSeconds,v = -reverse.accel · reverse · h. The brake lamp shows while it waits. - Near the road end (
toEnd ≤ roadEnd.promptDistance) reverse does not engage: the car stays at rest with the brake lamp on, and the hold counts toward a turn-around (below).
Brake lamps light whenever a stop term is non-zero.
- With the throttle on and free,
2. Steering. Let f = min(1, |v| / topSpeed). Let limit = lerp(steer.headingDeg[0], steer.headingDeg[1], f)
and rate = steer.rateDegPerSecond · min(1, |v| / steer.fullRateSpeed) · h.
- The offset moves toward
(v < 0 ? steer : -steer) · limitby at mostrate. When|offset| > limit, it is pulled back by at mostrate. - The wheel angle moves toward
-steer · lerp(steer.wheelDeg[0], steer.wheelDeg[1], f)by at most 4 rad/s.
3. Traffic ahead or behind.
- A box counts when it is in the car's lateral span:
|x - b.x| < ex + b.halfWidth + traffic.lateralMargin. approach(d, g) = min(g · d, sqrt(2 · 0.8 · brake · d)), withdclamped at 0 or above.- Driving forward. For a box ahead with
v > 0, the allowed speed isb.speed + approach(gap - traffic.minGap, traffic.followGain). - Reversing. For a box behind with
v < 0, the allowed backward speed isapproach(gap - minGap, followGain). - When the car exceeds the allowed speed, it slows toward it by at most
brake · hper step. This overrides the throttle.
4. End stops. The car's road ends are on the approach roads, past the deck ends:
roadEnd(dir) = dir · (roadEndZ + ends.car), with ends.car the approach's layout.json value
(south -1592.98, north 1632.98). The approach roads, with their traffic, run on beyond them to the
dissolve stretches. Each carriageway ends roadEnd.stopDistance short of its road end, at
endStop(dir) = roadEnd(dir) - dir · stopDistance. Toward either stop, the car is limited to
approach(room, ∞) in the same way as step 3.
5. Brake lamps. The lamps also light when the car slows faster than traffic.json
brakeLights.decel.
6. Move and clamp.
Move.
x += v · sin(yaw) · handz += v · cos(yaw) · h.Carriageway. The footprint
x ± exmust stay between the median (medianHalfWidth + curb.clearance) and the curb (roadHalfWidth - curb.clearance) on the car's own side. At either edge:- clamp
xand setoffset *= exp(-h / 0.15); - once per
curb.cooldown, when|v| > 0.5, setv *= curb.speedKeptand give a pitch kick ofcurb.bumpDeg, which decays with a 0.12 s time constant.
- clamp
Sideways into traffic. Let
reach = ex + b.halfWidth + lateralMargin. The car may not move sideways intoreachof a box in either of two cases:- Alongside:
|dz| < ez + b.halfLength. - Merging: it starts outside reach and
|dz| < ez + b.halfLength + mergeMargin. HeremergeMargin = longitudinalMargin + closing speed · 1 s. The closing speed is how fast the gap shrinks: for a box behind,max(0, b.speed - v); for a box ahead,max(0, v - b.speed).
When blocked,
xstops at the reach boundary (or keeps its previous value if already inside it), andoffsetrelaxes as at the edges.- Alongside:
Hard stop. Where each box will be at the end of the step, the car never comes within
ez + b.halfLength + minGapof it.- A box ahead pushes the car back, and the car's speed is capped at the box's speed.
- When reversing, a box behind stops the car.
End clamp.
znever passes the end stops.
7. Book-keeping.
spin += v · h / wheelRadius.brakeLightapproaches 0 or 1 at a rate of 12 per second.toEnd = (roadEnd(dir) - z) · dir.
Road end, start and leaving
- Turn-around triggers. The turn-around prompt shows in the status line when
toEnd ≤ roadEnd.promptDistance. Three things turn the car around:- R, when the prompt shows;
- holding the throttle at rest at the end stop for
roadEnd.holdSeconds; - holding reverse at rest while the prompt shows for
roadEnd.holdSeconds(on touch, the stick held back; D-22). Releasing either hold starts its count again.
- Turning around.
- Fade to black over
fadeSeconds. - Move the car to the first free spot on the other carriageway. It tries the lanes nearest the
mirror position
-xfirst, atz + newDir · {0, 10, 20, 30, 40}in turn. Failing all of those, it goes to the mirror position itself. - Face the car the other way, at rest, and restart the chase camera behind it.
- Fade back over
fadeSeconds.
- Fade to black over
- Free spot. In a candidate lane, every box that overlaps the car sideways (margin
lateralMargin) must be clear of it:- a box ahead by at least 12 m;
- a box behind by at least
10 + max(0, b.speed - speed)² / (2 · 4)m.
- Entering.
- The car starts in
start.laneatstart.z. If that spot is not free, it triesz ± 6, ± 12, …withinstart.window, in the lanes nearest the start lane. - It starts rolling at
min(start.speed, speed of the vehicle ahead in its lane). - Its paint is
driving.jsonpaint.
- The car starts in
- Drawing.
- The car stands at the route point
(z, x). Its world heading is the route heading plusyaw. yis the mean of the route heights at the front and rear axles,± wheelbase / 2along the heading in route coordinates.- Pitch is
atan2(front - back, wheelbase) + bump. - The front wheels steer by
wheel. - The HUD shows
round(|v| · 3.6)km/h, updated five times a second.
- The car stands at the route point
- Chase camera (
layout.jsoncameras.chase).- Aim. The camera looks at
car + (sin yaw · lookAhead, targetHeight, cos yaw · lookAhead). - Rest position. It rests
distancebehind the car along the heading andheightabove it. - Smoothing. Heading and position follow through critically damped springs,
ω = 2 / positionLagandω = 2 / yawLag. - Field of view.
fovruns fromfovat rest tofovAtTopSpeedattopSpeed. - Zoom. A pinch or the mouse wheel over the scene (the kit's per-frame
zoominputz) multiplies a zoom factor byexp(zoomRate · z), clamped tozoom.distanceandheightscale by the factor, which is 1 each time the car is entered. - Look. A one-finger or mouse drag over the scene swings the camera around the car by 0.005 rad per pixel; a drag is ignored while a second finger is down, so a pinch zooms without swinging (the kit's chase drag, GG-010). Three seconds after the last drag it springs back behind the car (the kit's orbit offset). The obstruction and suspender rules below still apply.
- Obstruction.
- Five rays run from the aim point to the camera: the centre, plus four offset by
castRadiusto the camera's right, left, up and down. They are tested against the bridge's obstruction nodes (layout.jsonbridge). - The camera may be no further than
max(minDistance, nearest hit - pad). It moves in at once and back out atrelaxm/s.
- Five rays run from the aim point to the camera: the centre, plus four offset by
- Suspender limit. The scene finally clamps the camera's lateral route offset to
|d| ≤ maxAbsX, keeping its station, and re-aims it. On the deck this is|x|, inside the suspender planes. On an approach it is inside the barriers.
- Aim. The camera looks at
- Leaving. E, Escape or "Leave the car" removes the car. The orbit takes over from the chase camera's pose, aimed at the car's last position, with the same hand-back rule as a flight (section 3).
3. Camera flights (layout.json flights)
Keys. A flight is a list of keys, each with a
position, atargetand a verticalfov, played oversecondsof scene time.Timing. A key's
secondsis its share of eased time since the previous key. Keys withoutsecondsshare the remaining time equally.Easing. The flight time
uin 0..1 is eased:- by default, quadratic ease-in-out:
2u²below 0.5, else1 - (2 - 2u)² / 2; smoothstep(3u² - 2u³) where a flight names it.
The eased value picks the segment
iand the fractionvwithin it.- by default, quadratic ease-in-out:
Interpolation.
- Position and target are two separate centripetal Catmull-Rom curves through the keys, with
α = 0.5 (three.js
CatmullRomCurve3,centripetal). They are evaluated at segmenti, fractionv: uniform in key index, not in arc length. - The end segments use mirrored phantom points:
P(-1) = 2P0 - P1, and likewise at the far end. fovand roll interpolate linearly within the segment. Roll is always 0.
- Position and target are two separate centripetal Catmull-Rom curves through the keys, with
α = 0.5 (three.js
Interruption. Any orbit input interrupts a flight.
Hand-back to the orbit. At the end, or on interruption, the orbit takes over from the current pose. Its new target lies along the view direction, at
clamp(|target - position|, 1.5 · orbit.minDistance, 0.6 · orbit.maxDistance), clamped to the orbit's target bounds.Fog roll. It plays only with the Fog preset.
Clearance. Every flight keeps
clearance.terrainMinimumabove the terrain of every tier and the water, andclearance.bridgefrom the bridge (tests/unit/flights.test.ts).
4. Fog banks (layout.json fogBanks)
Generation. Puffs come from
fogBanks.seed. Each tier uses the firsttiers.jsonfeatures.*.fogBanksbanks, taken in order. Each bank generates itspuffs; for each puff, drawu,v,sizeandjitter, thenseed, where:u = 2r - 1andv = 2r - 1;size = sizeMin + r · sizeRange;jitter = r · heightJitter.
The puff's centre is
(bank.x + u · spread[0], bank.y + jitter + size · heightPerSize, bank.z + v · spread[1]).Drift. Puffs drift toward -X (east, into the bay) at
driftSpeedand wrap within[wrap.east, wrap.west):x(t) = east + mod(x0 - driftSpeed · t - east, west - east), wheretis scene time.Shape. Each puff is a camera-facing sprite,
size · aspectwide andsizetall. Its opacity multiplies these terms:- a radial profile
(1 - r²)^1.6, broken up by tiling noise offset per puff by itsseed; - a soft intersection with the depth behind it, over 60 m;
- a fade-in with camera distance over 30-220 m;
- a fade-out over 9-16 km;
- a fade-in with height over 0-18 m above the water;
- the preset's
banksvalue; - a constant 0.55.
- a radial profile
Colour. Each puff is coloured with the fog's own in-scatter toward the viewer, so a bank reads as a denser pocket of the same air. Puffs are never reflected in the water.
5. Lamps (layout.json lights, levels in presets.json)
- Bridge lamps and beacons. The
LampGlassandBeaconEmissivematerials take their authored emissive intensity × the preset'slamps. - Vehicle lamps. Headlight, taillight and brake-lamp surfaces take their authored emissive colour ×
mix(gain[0], gain[1], lights)for their kind, wherelightsis the preset's value.- Brake lamps are further scaled by
mix(brakeOff, 1, brake), using the vehicle's brake level. - Taillights are normalised so their largest emissive channel is at most
taillightPeak. - Day has
lights0. Golden hour and Fog havelights1, which gives headlights at Golden and Fog.
- Brake lamps are further scaled by
6. Approach roads (layout.json approaches)
US 101 continues off both anchorages as the approach roads, so the deck ends on a road and the traffic
and the car drive on past the deck ends. Per approach (south, north):
- Authored:
- the horizontal
alignment; - the modelled
length; - the
joinof the structure profile with the at-grade profile; - the
structures; - the ground-fit
spacing; - the imagery
referencepoints andtolerance; - the
ends.
- the horizontal
- Derived:
start,profile,segments,centrelineanddeviation. They come from the bridge GLB's Roadway end and the canonical near terrain, and are written byscripts/layout.ts --writeand checked by--check(see "Deriving and checking" below).
Geometry
- Alignment (
world/alignment.ts). The approach starts on the bridge axis at the deck's road end,(0, sign · roadEndZ), heading away from the bridge. From there it runs as tangents joined by circular curves: at each point of intersectionpis[i]a curve of radiusradii[i], then a tangent toend. The stationsis the arc length along the centreline. - Profile. The profile is a list of points of vertical intersection
[s, y, L]:- straight grades run between the points;
- at each inner point a parabolic vertical curve of length
Lis centred on it (0 at the two ends); - beyond the ends the end grades continue.
- The first point is the deck end.
- Its elevation and grade are the Roadway's end row at
|z| = roadEndZand the grade of its last segment, read from the bridge GLB (start; g3: 62.55 m, falling away from the bridge at 3.18 %). - The first grade continues the deck's end grade unchanged, and the approach's own sag curve flattens it. The deck geometry is never changed.
- A new bridge profile re-derives the approaches cleanly:
layout.ts --writerebuilds the structure profile from the new end, and staging fails when an approach'sstartdiffers from the staged Roadway's end.
- Its elevation and grade are the Roadway's end row at
- Structure and at-grade profile.
- The structure profile runs from the deck end at grades of at most 4 % until the road reaches the ground.
- Beyond
join.stationthe profile follows the ground. The ground is fitted atground.spacingalong the centreline, excluding the structures, and smoothed. - The two meet with the vertical curves
join.curves.
- Segments.
segmentsclassifies the stations:viaductandoverpass: on structure, with bent stations (supports) andabutments;cut,fillandgrade: at grade, by the road's height against the natural ground.
- Cross-section (
crossSection, shared by both approaches).- The carriageway (±9.4488 m), lane lines, edge lines and median continue the deck's.
- Shoulders run to concrete barriers (
barrier: inner and outer offset, height) whose outer faces line up with the deck walkways' outer edge. - At the anchorage a short concrete ramp (
joint.ramp) takes the deck's walkways, 0.22 m above the road, down to the shoulder. - On structure: a slab (
deck.slab), a girder box (deck.girder,girderHalfWidth), and bents of two columns (supports) with a cap. The bents and abutment walls run down tosupports.footing, below the ground. - Materials: the bridge GLB's Asphalt, RoadMarkings and Concrete.
- Ends.
ends.caris the car's road end (section 2).ends.dissolveis the stretch where the road leaves the model. Before it the barriers taper to the road overjoint.taper, and the median and lines end. The asphalt runs on tolengthin a bed that rises frompavementto 0.1 m below the road. Traffic fades in and out inside the stretch (section 1).
Meshes
- Representations. The approach meshes (
world/approach-mesh.ts) are built from these data at load. There are two:- near, with 2 m stations, lines and median;
- far, with 10 m stations, road, barriers and structures only.
- Switching. The far one replaces the near one when the camera is more than 1.12 × the tier's
bridgeFarSwitchfrom the route (the deck axis or either centreline). It switches back below 0.88 ×. - Lane lines. The broken lane lines continue the deck's dash pattern by route station.
Terrain corridor
The terrain is edited along each approach (world/corridor.ts) on both near terrain levels, so the
road sits in a cut or on a fill where it runs at grade and clears its girders where it is a structure.
At approach station s and lateral offset d, for the natural height h:
- At grade. There is a bed
pavementbelow the road for|d|up to the barrier's outer edge plusenvelope.bedMargin. Beyond it the terrain is clamped between a fill slope falling atenvelope.filland a cut slope rising atenvelope.cutper metre from the bed edge. - Under a structure. Clear of the abutments, the terrain stays at least
clearancebelow the girders, with the same cut slope beyond the bed. - Fading. The edit fades out:
- laterally between
envelope.reach[0]and[1]; - over 5 m at the deck end;
- over 30 m past the approach's end.
- laterally between
- Imagery. It stays draped, and the edited slopes take their own normals.
Deriving and checking
scripts/layout.ts --write derives the data above, and --check checks them together with the lanes
(5 mm on the Roadway). The check sets are:
- Profile. The start equals the Roadway's end, and grades are at most 4 % until the ground (the join).
- Support. Every 5 m on both near terrain levels, sampled every 0.5 m across the barriers:
- no penetrations: no terrain above the road surface, or above the slab soffit under a structure;
- no station at grade without ground contact: terrain within
pavement+ 0.05 m below the road somewhere across the paved width. Stations on a structure stand on its bents and abutments.
- Imagery. The centreline is within
imagery.tolerance(5 m) of each road-centre reference read from the imagery. On structures the reference is first corrected for the orthophoto's relief displacement, which shows an elevated roadimagery.displacementm further toward -X per metre above the ground. - Sight. From the deck, the review poses and the driving cameras, no sight line reaches an end stretch (the dissolve and the 10 m before it, at vehicle-roof height) nearer than 300 m.
- Driving.
tests/tools/drive-check.tsdrives the car over the whole route, both ways, and every traffic lane end to end against the rendered road surfaces. It requires every wheel on a road, no vertical step over 0.03 m and no pitch change over 1° per step. The joints at both deck ends and both towers are resampled every 0.01 m.