@bendyline/molen-tooling 0.0.14 → 0.0.16

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.
Files changed (46) hide show
  1. package/dist/capture/harness.js +736 -400
  2. package/dist/capture/worldgen-preview.js +409 -298
  3. package/dist/docs-src/guide/3d-art-guidelines.md +5 -2
  4. package/dist/docs-src/guide/adaptive-performance.md +50 -23
  5. package/dist/docs-src/guide/aircraft.md +275 -31
  6. package/dist/docs-src/guide/ambient-life.md +36 -9
  7. package/dist/docs-src/guide/building-interiors.md +92 -8
  8. package/dist/docs-src/guide/determinism.md +1 -1
  9. package/dist/docs-src/guide/dioramas.md +7 -0
  10. package/dist/docs-src/guide/earth-view.md +198 -16
  11. package/dist/docs-src/guide/entities.md +38 -7
  12. package/dist/docs-src/guide/figures.md +32 -4
  13. package/dist/docs-src/guide/graphics-performance.md +62 -19
  14. package/dist/docs-src/guide/livery-catalog.md +137 -1
  15. package/dist/docs-src/guide/livery-gallery.md +136 -1
  16. package/dist/docs-src/guide/medium-fi.md +194 -10
  17. package/dist/docs-src/guide/night-lighting.md +10 -0
  18. package/dist/docs-src/guide/regional-fleets.md +27 -5
  19. package/dist/docs-src/guide/regional-world.md +19 -1
  20. package/dist/docs-src/guide/rendering-backends.md +23 -2
  21. package/dist/docs-src/guide/sky.md +28 -2
  22. package/dist/docs-src/guide/snow.md +231 -0
  23. package/dist/docs-src/guide/surface-rendering.md +324 -9
  24. package/dist/docs-src/guide/terrain.md +84 -9
  25. package/dist/docs-src/guide/vehicle-interiors.md +6 -0
  26. package/dist/docs-src/guide/vehicles.md +368 -45
  27. package/dist/docs-src/guide/weather.md +7 -1
  28. package/dist/docs-src/guide/worldgen.md +82 -3
  29. package/dist/docs-src/llms.txt +3 -2
  30. package/dist/docs-src/schemas/README.md +1 -0
  31. package/dist/docs-src/schemas/components.md +749 -12
  32. package/dist/docs-src/schemas/figure.md +30 -4
  33. package/dist/docs-src/schemas/interior-catalog.md +56 -3
  34. package/dist/docs-src/schemas/map-overrides.md +658 -0
  35. package/dist/docs-src/schemas/structure-placement-data.md +195 -0
  36. package/dist/docs-src/schemas/structure-placements.md +195 -0
  37. package/dist/docs-src/schemas/worldgen-batch.md +54 -0
  38. package/dist/templates/city-courier/gen/molen-types.ts +113 -4
  39. package/dist/templates/city-courier/scripts/molen-scripts.d.ts +112 -3
  40. package/dist/templates/figures-gallery/test/headless.test.ts +3 -2
  41. package/dist/templates/index.json +17 -17
  42. package/dist/templates/skybound/gen/molen-types.ts +113 -4
  43. package/dist/templates/skybound/scripts/molen-scripts.d.ts +112 -3
  44. package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +112 -3
  45. package/dist/templates/top-down-arena/src/gen/molen-types.ts +113 -4
  46. package/package.json +12 -12
@@ -7,8 +7,9 @@ and frame/interlayer failure is independent of fracture.
7
7
  Generic vehicles use the Bendy house brand, with stable asset/type IDs. The Bendy Bus and
8
8
  Bendy Light Rail are also mountable through the vehicle API. World Explorer has buttons for
9
9
  both at the practice area: W/S applies traction or reverse, Space brakes, V switches view,
10
- and E exits after stopping. The bus steers with A/D; light rail has locked steering on its
11
- straight practice track. Player controls do not yet follow curved rail-network routes.
10
+ and E exits after stopping. The bus steers with A/D. Locomotives, rail cars and light rail
11
+ follow real track when the host supplies a track network; see
12
+ [Trains and track-guided vehicles](#trains-and-track-guided-vehicles).
12
13
  See the [close-view vehicle standard](medium-fi.md#controllable-vehicles-close-view-fidelity)
13
14
  for the extra model detail expected around the operator.
14
15
 
@@ -32,12 +33,26 @@ In **Walk mode**, approach a car and press **E** to enter its driver seat. **W/S
32
33
  brake then reverse; **A/D** steer; **Space** brakes; **Shift** pulls the handbrake; **V** switches
33
34
  cockpit/chase views. Mouse look works while seated. Stop and press **E** to exit.
34
35
 
35
- Cars drive on their tires. Push one past its grip and it slides: a front-drive sedan runs wide, a
36
- rear-drive pickup on full power swings its tail round, and steering with the handbrake up throws
37
- the back out for a handbrake turn. Brakes are anti-lock, so you can still steer while stopping.
38
- Rain and snow from the Weather setting make the road slippery (about 40% and 100% longer stops),
39
- and gusts push on the body. The body dives under braking, squats under power and leans out of
40
- turns. Hitting a wall or another car bounces you off it, and a corner hit spins you. The controller checks both sides and then the rear;
36
+ Every car drives like itself. Each has its own engine and gearbox, weight and weight
37
+ distribution, tires, suspension and aerodynamics, fitted to what a real one of its kind does: a
38
+ 911 reaches 100 km/h in a little over four seconds and tops out near 300 km/h, a city car takes
39
+ thirteen and runs out of breath under 150, a motorhome leans and takes half a minute. The engine
40
+ revs through its gears and changes up near the rev limit; lift off and it brakes on the engine,
41
+ floor it at a cruise and the gearbox kicks down. Electric cars pull from rest in one gear and
42
+ slow by regeneration. The status line shows the gear and engine speed.
43
+
44
+ Cars drive on their tires. A nose-heavy front-drive hatchback runs wide when pushed; a
45
+ tail-heavy sports car turns in sharply and wants care. Traction and stability control, where
46
+ the real car has them, hold wheelspin and catch a slide, so holding a key through a corner or
47
+ braking in the middle of one keeps the car in line; the handful of cars built without them (the
48
+ 2005 Ford GT, for one) will spin on full power in a corner. The handbrake still throws the back
49
+ out for a handbrake turn, and letting go of the wheel in a slide lets it countersteer by itself.
50
+ Brakes are anti-lock, so you can still steer while stopping. Rain and snow from the Weather
51
+ setting make the road slippery (about 40% and 100% longer stops), and gusts push on the body and
52
+ turn its nose. Leave the pavement and the ground matters: grass, gravel, dirt, sand and snow
53
+ grip less, drag at the wheels and shake the body, less so on off-road tires. The body dives
54
+ under braking, squats under power and leans out of turns. Hitting a wall or another car bounces
55
+ you off it, and a corner hit spins you. The controller checks both sides and then the rear;
41
56
  blocked exits leave the rider seated. Switching to Fly also requires a safe stopped exit.
42
57
 
43
58
  Modified cars stay where they were left throughout the current explorer session, even when their
@@ -64,6 +79,7 @@ import {
64
79
 
65
80
  export function setup(world) {
66
81
  const environment = {
82
+ // A third argument gives the vehicle's height, to tell stacked decks apart.
67
83
  groundHeight: (x, z) => 0,
68
84
  // Return undefined where terrain is unavailable.
69
85
  // Add canOccupy(position, yaw, spec, entity) for static/dynamic collisions.
@@ -100,27 +116,145 @@ the pilot, like the TF-51D trainer. Only the `driver` seat controls the vehicle.
100
116
  The solver is a dynamic bicycle model substepped at 120 Hz or finer. Each axle's tires turn slip
101
117
  angle into side force (`corneringStiffness` per unit load per radian) up to the road's grip, then
102
118
  let go to about 85% of it as they slide. Side grip is `grip` (m/s², so `grip / 9.81` is the
103
- friction coefficient); straight-line grip is 15% higher, and drive and brakes share it with
104
- cornering, so a car braking or under power at the limit steers less. `drive` picks the front,
105
- rear or all wheels; drive beyond the grip spins them. Anti-lock brakes split by `brakeBias` and
106
- stop just short of the limit. `handbrake` locks the rear wheels, which then slide. State carries
107
- the forward `speed`, the sideways `lateralSpeed`, `yawRate` and a 0–1 `skid` for tire sounds or
108
- effects.
109
-
110
- Weight moves between the axles through the suspension: the sprung body pitches by
119
+ friction coefficient; `rearGrip` where wider rear tires differ); straight-line grip is 15%
120
+ higher, and drive and brakes share it with cornering, so a car braking or under power at the
121
+ limit steers less. `drive` picks the front, rear or all wheels. `handbrake` locks the rear
122
+ wheels, which then slide. State carries the forward `speed`, the sideways `lateralSpeed`,
123
+ `yawRate` and a 0–1 `skid` for tire sounds or effects.
124
+
125
+ ### Tire loads and balance
126
+
127
+ Weight moves between the wheels through the suspension: the sprung body pitches by
111
128
  `pitchStiffness` and rolls by `rollStiffness` (radians per g) on springs of
112
- `suspensionFrequency` and `suspensionDamping`, so braking loads the front tires and lifting off
113
- in a turn can tighten it. `bodyPitch` and `bodyRoll` add to the terrain `pitch` and `roll` in the
114
- transform, so the cockpit view feels them too. Passed to the car visual as signals, they become
115
- suspension travel: the wheels move against the lean and stay on the road. Steering lock and steering speed fade with road
116
- speed (`steeringFadeSpeed`), and full lock never asks for more than half again the cornering the
117
- tires can give, so a keyboard tap changes lanes instead of spinning the car. At walking pace the
118
- car simply rolls where its wheels point, so it never turns in place and parks exactly.
119
-
120
- `installVehicles` reads the world's `weather`: rain takes up to 30% of the grip and snow up to 60%
121
- (`weatherGrip(weather)`), and the wind field, gusts included, pushes on the body's long side.
122
- Engine force, top and reverse speeds, rolling and air resistance, mass, wheel geometry and terrain
123
- tolerances come from `vehicle.spec` as before, and `yawInertia` defaults from the body size.
129
+ `suspensionFrequency` and `suspensionDamping`. Braking loads the front tires. Cornering loads
130
+ the outside ones, each axle taking the share its roll stiffness gives it: `rollBalance` is the
131
+ front's (default 0.6). A tire's friction falls as its load rises (`tireLoadSensitivity`, the
132
+ share lost when the load doubles; default 0.25), so two unevenly loaded tires grip less than
133
+ two evenly loaded ones. That is what gives a car its balance: the heavier axle and the
134
+ stiffer-sprung axle give up first. A nose-heavy car (`centerOfMass` ahead of the wheelbase's
135
+ middle) with a stiff front end pushes wide and is stable; a tail-heavy or rear-stiff one
136
+ rotates. It also means a car corners at less than its tires' rated `grip`: the nose-heavy
137
+ sedan holds about 0.85 g on tires rated 1.0. Set `tireLoadSensitivity` to 0 for grip proportional to load, which
138
+ makes every car neutral at any weight distribution.
139
+
140
+ `bodyPitch` and `bodyRoll` add to the terrain `pitch` and `roll` in the transform, so the
141
+ cockpit view feels them too. Passed to the car visual as signals, they become suspension
142
+ travel: the wheels move against the lean and stay on the road. At walking pace the car simply
143
+ rolls where its wheels point, so it never turns in place and parks exactly.
144
+
145
+ ### Engine and gearbox
146
+
147
+ `vehicle.spec.powertrain` gives a car an engine: `power` in watts at `peakPowerRpm`, a
148
+ `redline`, and a torque `curve` (`gasoline`, `turbo`, `diesel` or `electric`). `gears` lists the
149
+ overall ratios (gearbox × final drive), lowest first. Wheel force is engine torque through the
150
+ selected gear, less what it takes to spin the engine itself up (`inertia`), so a car pulls
151
+ hardest in first and runs out of power, not into a wall, at speed; `maxSpeed` remains a
152
+ governor. The automatic holds a gear to the rev limit under full throttle, short-shifts under a
153
+ light foot, kicks down when the pedal goes down, and drops most of the drive for `shiftTime`
154
+ seconds as it changes. Off the throttle the engine brakes the car (`engineBraking`); an electric
155
+ motor regenerates. `continuous: true` is a CVT ranging between the first and last ratios, which
156
+ holds the engine at its power peak. Delivered torque follows the pedal at the engine's own
157
+ pace (`response`: a turbo lags, a motor does not).
158
+
159
+ ```json
160
+ "powertrain": {
161
+ "power": 272000, "peakPowerRpm": 6500, "redline": 7500, "curve": "turbo",
162
+ "gears": [13.73, 9.36, 6.87, 5.17, 3.95, 3.04, 2.36], "efficiency": 0.9
163
+ }
164
+ ```
165
+
166
+ `vehicleState` carries the `gear` (-1 in reverse), the engine `rpm`, the delivered `engineLoad`
167
+ (0–1) and `shift`, all in keyframes and replays. Without a powertrain a vehicle keeps the
168
+ constant `engineForce` up to `maxSpeed`, as cycles and off-track rail vehicles do.
169
+ `powertrainWheelForce(powertrain, wheelRadius, speed, gear)` and `engineTorqueCurve(curve, x)`
170
+ are exported for tools that plot or check gearing.
171
+
172
+ Drive reaches the road through a differential. An open one (`limitedSlip` 0, the default)
173
+ pushes no harder than the unloaded inside wheel can hold, so a powerful car wastes its power
174
+ there out of a corner; toward 1 (locked) both wheels push, and both can spin.
175
+
176
+ ### Traction control, stability control and brakes
177
+
178
+ Drive beyond the grip spins the wheels, which then hardly hold the car sideways: that is how a
179
+ rear-drive car without aids comes round on power. `tractionControl` (default on) backs the
180
+ engine off to hold the tires at their limit instead, and brakes a spinning inside wheel.
181
+ `stabilityControl` (default on) watches the rear tires: when they slide past their peak it
182
+ brakes the outside front wheel, which turns the car back into line, slows it and cuts the
183
+ engine. `vehicleState.assist` reports how hard either is working, for a dashboard light. Set
184
+ them to `false` for a car built without them. The handbrake suspends stability control so a
185
+ handbrake turn still works.
186
+
187
+ Anti-lock brakes split by `brakeBias` and stop just short of the tire limit, leaving the front
188
+ some side grip to steer with. The rear brakes ease off a cornering tire (brake-force
189
+ distribution), so the lightly loaded tail keeps its side grip: braking hard in the middle of a
190
+ corner runs the car wide and slows it, where it used to spin it.
191
+
192
+ ### Steering
193
+
194
+ The driver's hands are part of the model. Steering lock fades with road speed
195
+ (`steeringFadeSpeed`), down to the angle that turns the car as hard as its tires can corner.
196
+ Turning in takes the same time at any speed (`maxSteer / steeringRate` when parking, half as
197
+ long again on a highway), so a tap on a key nudges the car across its lane and a held key
198
+ builds to the limit over about a second: past the lock the turn itself needs, the driver winds
199
+ on more only slowly, up to the slip angle where the front tires have all but their last percent
200
+ of grip, and no further, because more lock only slides them. In a slide the tires pull the
201
+ wheel toward the way the car is traveling, as caster does: let go and it countersteers by
202
+ itself; steer against the slide and the wheel goes to the opposite lock the tires can use.
203
+ Below a jogging pace the wheels simply point where they are turned.
204
+
205
+ ### Air and weather
206
+
207
+ `aerodynamicResistance` is drag as an acceleration per (m/s)², `0.5 × air density × drag area /
208
+ mass`: with a real drag area a car's top speed comes from its power. `aerodynamicLift` (1/m,
209
+ negative for downforce) takes load off the tires at speed, or adds it. The wind field, gusts
210
+ included, pushes on the body's long side and, acting ahead of the center of mass, turns the
211
+ nose downwind. `installVehicles` reads the world's `weather`: rain takes up to 30% of the grip
212
+ and snow up to 60% (`weatherGrip(weather)`).
213
+
214
+ ### Surfaces
215
+
216
+ Give the vehicle environment a `surface(x, z, y)` callback and the ground matters. It returns
217
+ a `VehicleSurface`: `grip` relative to dry pavement, `drag` (extra rolling resistance in m/s²)
218
+ and `roughness` (0–1, which works the springs as the car moves). `VEHICLE_SURFACES` holds stock
219
+ values by the names map data uses, and `vehicleSurface(name)` looks one up (undefined, which is
220
+ pavement, for names it does not know):
221
+
222
+ | Surface | Grip | Drag (m/s²) | Roughness |
223
+ |---|---|---|---|
224
+ | `asphalt`, `concrete`, `paved` | 1 | 0 | 0 |
225
+ | `stone` (cobbles, setts) | 0.9 | 0.05 | 0.35 |
226
+ | `wood`, `metal` | 0.85, 0.75 | 0.05, 0 | 0.2, 0.1 |
227
+ | `dirt` | 0.68 | 0.3 | 0.5 |
228
+ | `gravel` | 0.62 | 0.35 | 0.45 |
229
+ | `grass` | 0.55 | 0.6 | 0.6 |
230
+ | `leaves` (forest floor) | 0.5 | 0.7 | 0.75 |
231
+ | `sand` | 0.5 | 1.6 | 0.4 |
232
+ | `mud` | 0.42 | 1.4 | 0.55 |
233
+ | `snow` | 0.35 | 0.6 | 0.3 |
234
+
235
+ ```js
236
+ import { installVehicles, vehicleSurface } from '@bendyline/molen-kernel/vehicles';
237
+
238
+ installVehicles(world, {
239
+ groundHeight: (x, z) => 0,
240
+ // The road is a 7 m strip along z; everything else is a field.
241
+ surface: (x) => vehicleSurface(Math.abs(x) < 3.5 ? 'asphalt' : 'grass'),
242
+ });
243
+ ```
244
+
245
+ A surface may also carry `snow`, the share of the weather's lying snow it keeps: 0.3 for the
246
+ paved stock surfaces (ploughed and packed down), 1 for the rest. With a `weather.snowCover` the
247
+ solver adds the snow itself, whatever the surface: grip falls toward the `snow` row's, depth
248
+ drags at the wheels, and deep enough it holds the car fast (`vehicleState.snowDepth`, `stuck`).
249
+ [Snow cover](snow.md#on-wheels) has the numbers.
250
+
251
+ `looseSurfaceGrip` (0–1, off-road tread) wins back up to half the grip a loose surface takes
252
+ and 40% of its drag. Surface and weather multiply: wet grass is worse than either. The callback
253
+ is asked once per step for each moving car; `vehicleState.surfaceGrip` reports the result. In
254
+ an Earth view the mapped roads and land cover answer it (see below).
255
+
256
+ Top and reverse speeds, rolling resistance, mass, wheel geometry and terrain tolerances come
257
+ from `vehicle.spec` as before, and `yawInertia` defaults from the body size.
124
258
 
125
259
  Collision probes run at 120 Hz or finer through the host's `canOccupy` adapter. When it refuses a
126
260
  move, the solver finds which way is open by probing around the car, and answers with an impulse at
@@ -132,9 +266,11 @@ oriented chassis against other cars and nearby triangles for walls, fixtures and
132
266
  car it hits stays put. Terrain gaps pause motion; abrupt steps and slopes above 35 degrees stop
133
267
  the car. Cockpit views use the full chassis quaternion; chase views shorten at obstructions.
134
268
 
135
- This is a grounded driving model. It does not implement airborne rotation, rollovers, crash
136
- deformation, pushing other cars, per-surface friction (grass and gravel grip like the
137
- road), passenger animation, multiplayer ownership, or disk persistence. Background traffic is a
269
+ This is a grounded driving model with assisted steering. It does not implement airborne
270
+ rotation, rollovers, crash deformation, pushing other cars, manual gear selection or a clutch,
271
+ individual wheel speeds (wheelspin and lock-up are force limits, not spinning wheels), tire
272
+ temperature and wear, fuel, different surfaces under different wheels, passenger animation,
273
+ multiplayer ownership, or disk persistence. Background traffic is a
138
274
  separate package: [ambient life](ambient-life.md) moves NPC cars along lanes without this solver,
139
275
  and they stop for a car someone is driving. Without collision hooks, the reusable kernel solver
140
276
  supplies terrain driving only. Do not attach a second physics body to the same vehicle; the
@@ -171,6 +307,30 @@ All durable simulation state and mount relationships live in ECS components and
171
307
  and replay. Install the same systems/environment when restoring. Host streaming and render resources
172
308
  are separate from those checkpoints.
173
309
 
310
+ ### The fleet's figures
311
+
312
+ The `molen.entities` cars are not tuned by hand. In the engine repository,
313
+ [`vehicle-dynamics.json`](https://github.com/bendyline/molen/blob/main/content/entities/source/vehicle-dynamics.json)
314
+ lists one common trim of each of the 124 road vehicles: curb mass, power and engine speeds,
315
+ gearbox, driven wheels, front weight share, top speed, 0–100 km/h time, skidpad grip, drag area
316
+ and whether it has stability and traction control. A calibration step turns each row into a
317
+ complete spec (gear ratios, tire stiffness, suspension, roll balance, brake bias, drag and
318
+ lift) and then runs the production solver to fit the two things a driver knows a car by: it
319
+ adjusts driveline efficiency (or a motor's peak-power speed) until the simulated 0–100 km/h
320
+ time matches, and the tires' `grip` until a simulated skidpad does.
321
+
322
+ ```sh
323
+ # in the engine repository
324
+ pnpm vehicles:calibrate # ledger → source type documents → aggregate catalog
325
+ pnpm vehicles:bench # what each car does beside its reference figures
326
+ ```
327
+
328
+ The figures are representative, compiled from general knowledge of published specifications
329
+ and typical road tests without per-row sources: treat them as estimates. All 124 cars corner
330
+ within 2% of their skidpad figure and 117 reach 100 km/h within 10% of their time; the rest
331
+ are traction-limited rear-drive pickups and muscle cars whose published times assume four-wheel
332
+ drive or a prepared launch. Adding a car is one row in the ledger.
333
+
174
334
  ## In an Earth view
175
335
 
176
336
  `mountEarthView` drives the parked cars its street surfaces place, and can add one:
@@ -182,6 +342,15 @@ ground (under open sky, never a roof or deck), `board(id)` without walking to th
182
342
  in. The entity's `vehicle.color`, when set, paints the model's `paintMaterial`; without one the
183
343
  authored paint stays.
184
344
 
345
+ Cars feel the mapped ground under them: paved roads are pavement, tracks and unpaved roads
346
+ dirt or gravel, and off the road the land cover decides (grass, forest floor, sand, snow,
347
+ wetland). `mountEarthView` wires this itself. A host composing its own view passes
348
+ `surfaceAt: (x, z) => audioTerrain.sample(x, z).surface` to `EarthVehicles` (an
349
+ `EarthAudioTerrain` observing the semantic tiles); lookups are cached per two-meter cell, and
350
+ unmapped ground is pavement. `EarthVehicles.driveline` reports the driven car's `gear` (of
351
+ `gears`), `rpm`, `assist`, `surfaceGrip` and `skid` for a HUD, and `view.vehicleStatus()` carries `gear`, `rpm`,
352
+ `assist` and `surfaceGrip` for a car with a powertrain.
353
+
185
354
  A host can make boarding two presses, as the world explorer does: `openDoor(eye)` opens the shut
186
355
  front door (`doorFrontLeft` or `doorFrontRight`) on the walker's side of the nearest car in reach
187
356
  and returns false when there is none, so the next press falls through to `enter(eye)`.
@@ -214,14 +383,132 @@ rear one. In the Earth view, actors board and leave them (`{ kind: 'board', vehi
214
383
  `{ kind: 'alight' }`; see [actors](earth-view.md#actors-companions-and-npcs)), and
215
384
  `EarthVehicles.unmount(actor)` steps any mounted entity out by those rules.
216
385
 
386
+ ## Trains and track-guided vehicles
387
+
388
+ A vehicle whose `spec` has a `rail` block runs on rails. With a track guide in the vehicle
389
+ environment it follows the track instead of steering; without one it drives straight with locked
390
+ steering, as before.
391
+
392
+ ```json
393
+ "rail": { "truckCenters": 15.9, "couplerLength": 22.3, "power": 3100000, "gauge": 1.435 }
394
+ ```
395
+
396
+ `truckCenters` is the distance between the two trucks (bogies): the body rides as the chord between
397
+ them on curves. `couplerLength` spaces cars in a train. `power` is the power at the rail in watts;
398
+ tractive effort is the spec's `engineForce` (the starting tractive effort) up to `power / speed`,
399
+ so a locomotive pulls hard from a stand and holds its power at speed. A car without `power` only
400
+ brakes. `brakeDeceleration` is the full-service brake, `rollingResistance` and
401
+ `aerodynamicResistance` the resistance terms, and grade pulls the train down hill. Wet or icy rail
402
+ from the weather reduces adhesion.
403
+
404
+ Controls are the vehicle input you already have. **W** (positive throttle) powers the train, and
405
+ **S** (negative throttle) brakes it to a stand and then backs it. **Space** applies the full brake.
406
+ **A** or **D** (steering) picks the left or right route at the next facing switch; the choice holds
407
+ until the train passes one, then returns to straight on. The end of the track stops the train,
408
+ and a hard stop raises `vehicle-impact`.
409
+
410
+ ### Consists
411
+
412
+ A `coupled` component puts a car in a train: `{ "leader": "<lead entity>", "offset": 21.5 }`,
413
+ the distance in meters from the leader's center back to the car's center. The leader keeps a
414
+ trail of the track it ran over in `vehicleState.track.trail`. Its coupled cars ride that trail, so a
415
+ train leaving a siding keeps its tail on the siding until the tail passes the switch. Powered cars
416
+ add their traction to the leader's (multiple-unit control), and every car adds its mass and brakes.
417
+ `consistOffsets(specs)` gives the offsets for cars listed front to back.
418
+
419
+ ```js
420
+ import {
421
+ consistOffsets,
422
+ Coupled,
423
+ installVehicles,
424
+ settleRailConsist,
425
+ TrackNetwork,
426
+ } from '@bendyline/molen-kernel/vehicles';
427
+
428
+ const track = new TrackNetwork();
429
+ track.set('my-line', [{ points: [[0, -500], [0, 500]] }]);
430
+ const env = { groundHeight: () => 0, track };
431
+ installVehicles(world, env);
432
+ // ...spawn a locomotive 'loco' and cars 'car-1'..'car-n' with vehicle components, then:
433
+ const offsets = consistOffsets(specs);
434
+ cars.forEach((id, i) => world.set(id, Coupled, { leader: 'loco', offset: offsets[i + 1] }));
435
+ settleRailConsist(world, 'loco', env); // lay the trail and stand each car on the track
436
+ ```
437
+
438
+ ### Track guides
439
+
440
+ A `TrackGuide` has two calls. `snap(pose, radius)` finds the nearest track point. `advance(pose,
441
+ distance, route)` walks along the track and reports whether it passed a switch. `railTop` is the
442
+ height of the rail heads above the surface `groundHeight` reports on the track. `TrackNetwork` is
443
+ the stock guide over polylines. You hand it track centerlines in groups with `set(group, lines)`
444
+ and remove them with `delete(group)`, one group per streamed map tile for example. It continues
445
+ across the pieces map data splits a railway into. It treats near-identical copies (tile buffers,
446
+ coarser tiles under finer ones) as one track and follows the copy with the highest `rank`. It offers
447
+ a choice of route only where tracks really diverge. `nearest(x, z, radius, accept)` finds a
448
+ starting point by line tags and `tagsAt(pose)` reads a line's tags back.
449
+
450
+ ### Trains in an Earth view
451
+
452
+ `EarthRailNetwork` observes the human-features tiles: wrap the features renderer with
453
+ `observeSemanticTiles(renderer, rail)`. It builds a `TrackNetwork` from their live railway lines
454
+ (not disused lines, tunnels or platforms) and collects stations and platforms. Pass `rail.network`
455
+ as `track` to `EarthVehicles`. Then `EarthTrains` makes up and runs trains on it.
456
+
457
+ ```js
458
+ const rail = new EarthRailNetwork();
459
+ const vehicles = new EarthVehicles({ ...options, track: rail.network });
460
+ const trains = new EarthTrains({ vehicles, rail, types });
461
+ const train = trains.spawn('freight', x, z, { yaw }); // 'freight' | 'passenger' | 'light-rail'
462
+ trains.board(train, 'driver'); // or 'passenger': an engineer drives
463
+ // every frame, before vehicles.update(dt, input):
464
+ trains.update(dt);
465
+ ```
466
+
467
+ `spawn` finds the nearest suitable track within 2.5 km, preferring running lines over yards.
468
+ Light-rail trains keep to tram and light-rail lines, and heavy trains keep off them. `EarthTrains.makeUp`
469
+ builds a consist from the entity library. A freight train is two road locomotives and a mixed
470
+ manifest in blocks of alike cars. A commuter train is a locomotive and bilevel coaches. A light-rail
471
+ train is two cars. You can also pass your own `cars`. Riding as a passenger, an engineer drives for
472
+ you. It keeps to line speed and slows for curves, stops with the middle of the train at each station
473
+ or platform, and waits and runs back the other way at the end of the line. Walking up to a stopped
474
+ train and pressing **E** takes the cab's driver's seat, or a free passenger seat in a coach;
475
+ `EarthVehicles.freeSeat` picks it. `trains.status()` describes the train the viewer is aboard for a
476
+ HUD: speed, mass, line name, route at the next switch and next stop.
477
+
478
+ A train you drive stops against standing cars and other trains rather than running through them.
479
+ Power toward them does nothing while it is up against them, and reversing takes it away. Engineers
480
+ stop short of them too. `EarthVehicles.parkedRailCars()` lists the cars standing in the shown yards
481
+ (see [rolling stock in yards](surface-rendering.md#railways)), and `addInputFilter` is the hook
482
+ `EarthTrains` uses to hold the throttle.
483
+
484
+ `trains.yard(observer, { max, radius })`, called every frame, keeps up to `max` switchers (default
485
+ 2) working yard and siding tracks within `radius` meters (default 1400). Each is a yard locomotive
486
+ with three to eight cars on a stretch clear of standing cars. Its own engineer runs it back and forth
487
+ at about 15 km/h in moves of 70 to 300 m, waiting between them, and never takes it onto the main
488
+ line. Switchers left far behind go. You can ride one: walk up and take the conductor's seat.
489
+
490
+ In World Explorer, **Drive freight**, **Drive commuter** and **Ride commuter** put you on a train
491
+ on the nearest railway, and `?train=freight|commuter|ride|light-rail` does the same at startup.
492
+ Yards fill with standing cuts wherever parked cars are drawn, and with ambient life on,
493
+ switchers work near the camera.
494
+ `?yard=0` leaves the switchers out, and `?railCars=0.5` (an occupancy) thins the standing cars.
495
+ **Bendy Light Rail** runs on a real light-rail line when one is within 3 km. The `molen.entities`
496
+ pack carries the rolling stock: road and yard diesels, a commuter locomotive, bilevel coaches and
497
+ a cab car, and seven kinds of freight car. See [Reusable entities](entities.md).
498
+
217
499
  ## Riding cycles
218
500
 
219
- The entities pack includes six rideable types: `molen.entities.cycle.standard_motorcycle`,
220
- `cruiser_motorcycle`, `motor_scooter`, `city_bicycle`, `road_bicycle` and `cargo_bicycle` (the same
221
- namespace prefix applies to each). Mount, drive and exit them with the same APIs as cars. In the
222
- Earth view example, select a cycle beside **Drive**, then press **Drive**. **W** supplies motor or
223
- pedal power, **S** and **Space** brake, **A/D** steer, **V** changes view, and **E** steps off once
224
- stopped. These cycles have no powered reverse. The Earth view API accepts the full type ID:
501
+ The entities pack includes eleven rideable types under `molen.entities.cycle.`: the
502
+ `standard_motorcycle`, `cruiser_motorcycle` and `motor_scooter`; the `city_bicycle`, `road_bicycle`
503
+ and `cargo_bicycle`; an `underbone_moped` (the step-through commuter of South and Southeast Asia)
504
+ and an `electric_moped`; a shared electric `kick_scooter`; and a push `skateboard` and an
505
+ `electric_skateboard`. Mount, drive and exit them with the same APIs as cars. In the Earth view
506
+ example, select one beside **Drive**, then press **Drive**. **W** supplies motor or pedal power (on
507
+ the skateboard, the rider pushes off), **S** and **Space** brake, **A/D** steer, **V** changes view,
508
+ and **E** steps off once stopped. None has powered reverse. Two more ride on runners over lying
509
+ snow, `skis` and a `snowboard`, beside the `molen.entities.vehicle.snowmobile`: gravity moves
510
+ them down a slope, and [Snow cover](snow.md#the-three-rides) describes them. The Earth view API
511
+ accepts the full type ID:
225
512
 
226
513
  ```js
227
514
  view.setMode('drive', { vehicle: 'molen.entities.cycle.city_bicycle', force: true });
@@ -240,14 +527,48 @@ optional `pedals` describe metric contact points in model space. The figures cap
240
527
  Earth avatar renderer share the same pose evaluator: hands follow the turning handlebars and
241
528
  feet follow the pedals or footrests. At low-speed steering lock the rider counterweights at the
242
529
  saddle and turns the shoulders to keep both grips within reach. The stock dimensions fit an adult human; unusually small
243
- or large figures may not reach every contact point. The cockpit uses `spec.driverEye` separately
530
+ or large figures may not reach every contact point of a seated cycle. The cockpit uses `spec.driverEye` separately
244
531
  from the saddle. `vehicle.visual.animation` binds the moving parts in Earth; `model.signals`
245
532
  provides the same steering, wheel and pedal animation in ordinary Molen scenes.
246
533
 
534
+ ### Standing and sideways riders
535
+
536
+ `cycle.stance` says how the rider stands: on a saddle (`seated`, the default), upright on a deck
537
+ facing the bars (`standing`, the kick scooter), or across a board with the left foot forward
538
+ (`sideways`, the skateboards). A standing or sideways rider's driver seat is where an adult's hips
539
+ go; the pose stands on the idle pose rather than the seated one and raises or lowers the hips to
540
+ each body's own legs, so shorter and taller riders keep their feet on the deck and their hands on
541
+ the grips. A sideways rider turns across the board, looks down it and leans with it; their
542
+ `grips` are free hand positions held out beside the hips, which do not turn with the steering.
543
+
544
+ `cycle.kick` makes a cycle push-powered. Under power a sideways rider turns forward and pushes off
545
+ the ground with the rear foot, one push per `kick.stride` meters (never slower than a push from
546
+ rest), then rides sideways again. `vehicleState.pedalAngle` is the phase of the current push and
547
+ `vehicleState.kick` eases from 0 (sideways) to 1 (turned to push); a push under way when the power
548
+ stops finishes before the rider settles.
549
+
550
+ A board steers through its trucks rather than a turned wheel: its `visual.frontWheelNodes` is
551
+ empty and `visual.animation` turns `truck-front` and `truck-rear` against each other, each by half
552
+ the steering angle, which matches the turning circle of the solver's single steered axle.
553
+
554
+ ### Handlebar three-wheelers
555
+
556
+ `spec.handlebar` gives a vehicle that does not lean (the `molen.entities.vehicle.auto_rickshaw`)
557
+ the same rider contacts as a cycle: `riderLean`, `handlebarPivot`, `grips` and `footrests`, with
558
+ the driver seat as the pelvis anchor. It drives on the car solver with three wheel nodes, one
559
+ steered at the front. Its passengers sit as they do in a car. The auto-rickshaw also has
560
+ `headlights` and `wipers` actuators, so **L** and **K** work in it as in a car; its one beam
561
+ comes from the nose lamp named in `spec.headlamps` (see [Night lighting](night-lighting.md)).
562
+
247
563
  Cycles use the existing `molenVehicle(types, id)` helper and are enumerated separately by
248
- `MOLEN_CYCLE_ENTITY_IDS`; `MOLEN_VEHICLE_ENTITY_IDS` continues to enumerate cars and trucks.
249
- Cycles are excluded from automatic car parking and ambient traffic. Balance is assisted; this
250
- is grounded riding, without falls, wheelies, jumps, gears or stunt simulation.
564
+ `MOLEN_CYCLE_ENTITY_IDS`; `MOLEN_VEHICLE_ENTITY_IDS` continues to enumerate cars, trucks and the
565
+ auto-rickshaw. Motor two-wheelers (the motorcycle, scooter and both mopeds) and the auto-rickshaw
566
+ carry an `ambientRole` of weight 0: they never appear in default traffic or parking, only in
567
+ regions whose fleet profile weights them (see [Regional vehicle fleets](regional-fleets.md)). In
568
+ traffic their riders are drawn on the saddle and two-wheelers lean into turns; parked, two-wheelers
569
+ stand two or three to a bay. Bicycles, kick scooters and skateboards never park or join traffic.
570
+ Balance is assisted; this is grounded riding, without falls, wheelies, jumps, gears or stunt
571
+ simulation.
251
572
 
252
573
  For a repeatable mounted-rider review in the engine repository:
253
574
 
@@ -259,10 +580,12 @@ molen shot content/entities/scenes/cycles.scene.json --setup content/entities/sc
259
580
 
260
581
  ## Engine sound
261
582
 
262
- The original five road vehicle types carry an `audioSource`: the compact, sedan and SUV run
263
- `vehicle.engine.car`, the pickup and van `vehicle.engine.diesel`, each with its own pitch. The
264
- engine plays only while someone drives (`self.occupied`), rises in pitch with
265
- `vehicleState.speed`, and grows louder with `vehicleInput.throttle`. Any host that plays audio from
583
+ Every car and truck with a combustion engine carries an `audioSource`: petrol engines run
584
+ `vehicle.engine.car`, diesels `vehicle.engine.diesel`, pitched by engine size (a V8 lower than
585
+ a four). The engine plays only while someone drives (`self.occupied`), rises in pitch with
586
+ `vehicleState.rpm`, so it climbs through each gear and drops at every change, and grows louder
587
+ with `vehicleState.engineLoad`. Electric cars are silent; a hybrid's engine is quiet until it is
588
+ worked. Any host that plays audio from
266
589
  the entity world, such as `mountEarthView` or a page with `createAudioLayer(...).attachWorld(world)`,
267
590
  hears it with no extra code. Override the component on a type or entity to change the sound; see
268
591
  [Sound and music](audio.md).
@@ -56,6 +56,7 @@ external data with `weatherSchema.parse` before using it in typed code.
56
56
  | `clouds.baseAltitude`, `thickness`, `scale` | Absolute base Y and depth of the layer, and the horizontal pattern repeat size, in meters. |
57
57
  | `clouds.cirrus`, `cirrusAltitude` | Coverage 0–1 of a thin, wispy high cirrus layer (default 0) and its absolute Y (default 9000 m). Independent of the main layer. |
58
58
  | `precipitation.kind`, `intensity` | Explicit none/rain/snow and 0–1 visual intensity; not calibrated mm/hour. |
59
+ | `snowCover.level`, `transition`, `depth`, `depthGain`, `maxDepth` | Snow lying on the ground above a snow line at absolute world Y `level`, building over `transition` meters to `depth` and deepening with height. Absent: bare ground. Independent of falling snow; see [Snow cover](snow.md). |
59
60
  | `visibility` | Approximate visual fade distance in meters, independent of clouds and precipitation. |
60
61
  | `wind.referenceHeight` | Height above ground in meters where `windVelocity` applies; default 10. |
61
62
  | `wind.shear` | Power-law exponent of wind speed with height, to 600 m; default 0 (uniform). About 0.14 over open country, 0.3 over cities. |
@@ -190,7 +191,9 @@ clear foreground are preserved when weather visibility reaches beyond that limit
190
191
  deck the fog turns grey. Removing weather restores the authored fog and lighting. Clouds are a
191
192
  visual volume: flying through one does not simulate icing, turbulence or condensation (wind
192
193
  turbulence is the `wind` block's). Precipitation is a local visual field, including above cloud
193
- layers, without roof/terrain collision, splash, accumulation or wet-material response.
194
+ layers, without roof/terrain collision, splash or wet-material response, and it does not build
195
+ up: snow on the ground is the authored `snowCover` block, which whitens the ground, roofs and
196
+ trees above its snow line ([Snow cover](snow.md)).
194
197
 
195
198
  ## World explorer
196
199
 
@@ -205,6 +208,9 @@ graphics quality; High casts cloud shadows. Temperature and pressure controls
205
208
  refer to sea level, displayed in °C and hPa and stored in kelvin and pascals. The same component
206
209
  is installed in the explorer's vehicle/aircraft simulation.
207
210
 
211
+ The Snow level list lays snow on the ground: everywhere, or above a line from sea level to
212
+ 4,000 m (`?snow=1500`, `?snow=all`, `?snow=off`); see [Snow cover](snow.md#world-explorer).
213
+
208
214
  Use `?weather=rain` or another preset id. Custom edits are session-local. `?freeze=1` freezes
209
215
  weather motion for comparisons. The day slider changes lighting without moving the camera
210
216
  or seeking precipitation animation. The legacy `?sky=daylight` path stays weather-free unless