@bendyline/molen-tooling 0.0.15 → 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.
- package/dist/capture/harness.js +736 -400
- package/dist/capture/worldgen-preview.js +409 -298
- package/dist/docs-src/guide/3d-art-guidelines.md +5 -2
- package/dist/docs-src/guide/adaptive-performance.md +50 -23
- package/dist/docs-src/guide/aircraft.md +263 -29
- package/dist/docs-src/guide/ambient-life.md +36 -9
- package/dist/docs-src/guide/building-interiors.md +92 -8
- package/dist/docs-src/guide/determinism.md +1 -1
- package/dist/docs-src/guide/earth-view.md +198 -16
- package/dist/docs-src/guide/entities.md +38 -7
- package/dist/docs-src/guide/figures.md +32 -4
- package/dist/docs-src/guide/graphics-performance.md +44 -12
- package/dist/docs-src/guide/livery-catalog.md +137 -1
- package/dist/docs-src/guide/livery-gallery.md +136 -1
- package/dist/docs-src/guide/medium-fi.md +194 -10
- package/dist/docs-src/guide/night-lighting.md +10 -0
- package/dist/docs-src/guide/regional-fleets.md +27 -5
- package/dist/docs-src/guide/regional-world.md +19 -1
- package/dist/docs-src/guide/rendering-backends.md +23 -2
- package/dist/docs-src/guide/sky.md +28 -2
- package/dist/docs-src/guide/snow.md +231 -0
- package/dist/docs-src/guide/surface-rendering.md +324 -9
- package/dist/docs-src/guide/terrain.md +74 -5
- package/dist/docs-src/guide/vehicle-interiors.md +6 -0
- package/dist/docs-src/guide/vehicles.md +368 -45
- package/dist/docs-src/guide/weather.md +7 -1
- package/dist/docs-src/guide/worldgen.md +82 -3
- package/dist/docs-src/llms.txt +3 -2
- package/dist/docs-src/schemas/README.md +1 -0
- package/dist/docs-src/schemas/components.md +749 -12
- package/dist/docs-src/schemas/figure.md +30 -4
- package/dist/docs-src/schemas/interior-catalog.md +56 -3
- package/dist/docs-src/schemas/map-overrides.md +658 -0
- package/dist/docs-src/schemas/structure-placement-data.md +195 -0
- package/dist/docs-src/schemas/structure-placements.md +195 -0
- package/dist/docs-src/schemas/worldgen-batch.md +54 -0
- package/dist/templates/city-courier/gen/molen-types.ts +113 -4
- package/dist/templates/city-courier/scripts/molen-scripts.d.ts +112 -3
- package/dist/templates/figures-gallery/test/headless.test.ts +3 -2
- package/dist/templates/index.json +17 -17
- package/dist/templates/skybound/gen/molen-types.ts +113 -4
- package/dist/templates/skybound/scripts/molen-scripts.d.ts +112 -3
- package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +112 -3
- package/dist/templates/top-down-arena/src/gen/molen-types.ts +113 -4
- package/package.json +12 -12
|
@@ -183,8 +183,13 @@ movement trigger coherent grid-snapped rebases for every engine-owned object aut
|
|
|
183
183
|
`terrainStreamBudgetForQuality('economy' | 'balanced' | 'high')` returns portable residency and
|
|
184
184
|
concurrency budgets. `stream.stats()` reports decoded samples, geometry bytes, triangles, draw
|
|
185
185
|
calls, instances, loading/failure counts, and evictions for live quality diagnostics. It walks
|
|
186
|
-
|
|
187
|
-
`stream.loading()` (tiles and layers loading now) and `stream.pressure()` are constant-time.
|
|
186
|
+
the displayed tiles' objects to count them, so call it for diagnostics, not every frame:
|
|
187
|
+
`stream.loading()` (tiles and layers loading now) and `stream.pressure()` are constant-time. On the
|
|
188
|
+
pyramid stream, `stats()` also counts `builtTiles`/`builtLayers` and how many of those repeated an
|
|
189
|
+
earlier build (`rebuiltTiles`/`rebuiltLayers`), which is the cache missing. `stream.viewCoverage`
|
|
190
|
+
reports how finished the view is by distance, a tile count per band of tiles `complete`, drawn from
|
|
191
|
+
another level (`stale`), drawn with layers missing (`bare`) and undrawn (`empty`), and the
|
|
192
|
+
`onLayerTiming` option reports where each layer's build time went.
|
|
188
193
|
|
|
189
194
|
## 4. Screenshot it headlessly
|
|
190
195
|
|
|
@@ -387,8 +392,41 @@ detail (`peripheralDetail`, default 0.4, weighs their error), with hydrology pre
|
|
|
387
392
|
turning the camera reveals ground and mapped water that are already there. Buildings and vegetation
|
|
388
393
|
build once the tile is in view. In-flight surface
|
|
389
394
|
requests finish into a bounded warm cache instead of being restarted on every small camera turn;
|
|
390
|
-
hidden cached tiles are evicted only when capacity is needed
|
|
391
|
-
|
|
395
|
+
hidden cached tiles are evicted only when capacity is needed, farthest first in tile widths from
|
|
396
|
+
the camera rather than least recently used, because a circling camera returns to the ground it saw
|
|
397
|
+
longest ago. A hidden tile leaves the scene graph as well as the draw list, so a large cache costs
|
|
398
|
+
memory and no frame time. Sparse descendants also share a bounded decoded-ancestor cache, avoiding
|
|
399
|
+
repeated PNG decode/resample work while panning.
|
|
400
|
+
|
|
401
|
+
Refinement measures a tile's distance from the ground it holds. Until a tile or an ancestor has
|
|
402
|
+
loaded it can reach anywhere in the package's height range, and a camera inside that range has no
|
|
403
|
+
height above it; `tileHeight` on `selectTerrainPyramidTiles` supplies the same knowledge to your
|
|
404
|
+
own selection.
|
|
405
|
+
|
|
406
|
+
A camera that travels gets its tiles before it arrives. The stream follows the track of the
|
|
407
|
+
positions passed to `update`, as a speed and a turn rate, so an aircraft in a steady turn is
|
|
408
|
+
predicted along its arc. No host wiring is needed, and it works for whatever moves the camera.
|
|
409
|
+
|
|
410
|
+
- Work is ordered for where the camera will be when it finishes, so a fast camera does not spend
|
|
411
|
+
its capacity on the ground beneath it. Ground with no layers on it comes before more detail for
|
|
412
|
+
ground that has some.
|
|
413
|
+
- Tiles the track reaches within `lookAhead.seconds` (default 3, 6, 12 and 20) are built hidden
|
|
414
|
+
from spare capacity, with one layer slot kept free and only while the frame queue has no backlog.
|
|
415
|
+
They appear finished when selected, and are the first thing given up under memory pressure.
|
|
416
|
+
- Levels whose tiles the camera crosses in under `lookAhead.minTileSeconds` (default 5) refine
|
|
417
|
+
only near the camera. Each takes `lookAhead.fastDetail` (default 0.25) of the work of a level
|
|
418
|
+
built across the whole view, so the faster the camera, the nearer its finest detail stops.
|
|
419
|
+
Refining the whole view at speed starts far more tiles than the stream can finish, and it then
|
|
420
|
+
finishes little of any. This limits only what is built: finer ground already built stays as
|
|
421
|
+
long as the view would show it at rest, so speeding up or turning does not take detail off the
|
|
422
|
+
screen. `fastDetail: 0` builds none of those levels. Detail spreads out again when the camera
|
|
423
|
+
slows.
|
|
424
|
+
|
|
425
|
+
`lookAhead: false` turns all of this off. A camera has to hold a track for most of a second before
|
|
426
|
+
any of it applies. A teleport starts the track over, and so does a second without an `update`, so a
|
|
427
|
+
host that updates only while the camera moves still gets full detail when it stops. `stats()` reports `aheadTiles`, `aheadReady`,
|
|
428
|
+
`cameraSpeed` and `speedLevel`, and counts ground in view that changed level: `refinedInView` as
|
|
429
|
+
detail arrives, `coarsenedInView` as it is given up, which reads as popping.
|
|
392
430
|
|
|
393
431
|
With `shadows: true` every tile surface and layer mesh receives sun shadows, and layer meshes
|
|
394
432
|
taller than `shadowCasterHeight` (default 1.5 m: buildings, trees, landmarks) cast them. A layer
|
|
@@ -428,7 +466,9 @@ per-tile feature/point limits for other MVT producers.
|
|
|
428
466
|
trees inside forest polygons, combined terrain-draped road ribbons, combined footprint extrusions,
|
|
429
467
|
flat polygonal water, and draped linear waterways. `createTerrainWaterMaterial` provides an opaque
|
|
430
468
|
physical material with optional world-space animation; call `setTerrainWaterTime` each frame to
|
|
431
|
-
advance its highlights without discontinuities across floating-origin shifts.
|
|
469
|
+
advance its highlights without discontinuities across floating-origin shifts. It folds the origin
|
|
470
|
+
into the ripples in double precision, so water stays sharp at planet-scale coordinates. Ripples a
|
|
471
|
+
pixel cannot resolve fade into a broader highlight instead of shimmering. Opaque coverage
|
|
432
472
|
avoids dark overlap seams while adjacent or parent/child water tiles refine. Expensive semantics
|
|
433
473
|
can be level-bounded, toggled without re-decoding resident objects, and disposed with the elevation
|
|
434
474
|
tile. Applications may replace the decoder, renderer, materials, or model geometry independently.
|
|
@@ -573,6 +613,16 @@ Circa 1910 changes the surface treatment of the present-day map; it does not rec
|
|
|
573
613
|
|
|
574
614
|
See [Surface styles and parameterized line features](surface-rendering.md) for the shared rendering API, parking inference rules, budgets, and rail/utility profile examples.
|
|
575
615
|
|
|
616
|
+
Railways are surfaces too: ballasted track beds whose sleepers and rails the pavement material
|
|
617
|
+
draws (so a yard reads as parallel tracks from the air), rails in 3D close up, level crossings
|
|
618
|
+
with their panels, crossbucks, lights and gates, switch stands, color-light signals at mapped
|
|
619
|
+
signal points, lineside signs, platforms and overhead catenary. Which tracks are wired is the
|
|
620
|
+
surface style's `railElectrification`: `'light'` by default (light rail, trams and open-air
|
|
621
|
+
subways), `'all'` where main lines are electrified too, or `'none'`; `railGauge` sets the main
|
|
622
|
+
lines' gauge where it is not standard. World explorer wires Kyoto, Sydney and New Delhi
|
|
623
|
+
throughout, with Kyoto's lines at 1.067 m and New Delhi's at 1.676 m. See
|
|
624
|
+
[Railways](surface-rendering.md#railways).
|
|
625
|
+
|
|
576
626
|
The explorer plans adaptive streaming at 10 Hz, independently of rendering and movement. Covered
|
|
577
627
|
ancestors that were evicted under memory pressure are not reloaded while finer resident tiles
|
|
578
628
|
supply their coverage; coarse coverage remains warm for camera turns. The HUD reports actual
|
|
@@ -583,6 +633,25 @@ Land-cover draping can run off-thread with `createTerrainLandcoverWorkerBridge(w
|
|
|
583
633
|
bridge through `landcoverGenerator`; the caller disposes it after its tiles are disposed. It
|
|
584
634
|
preserves source height samples, terrain triangle alignment, colors, holes, and material settings.
|
|
585
635
|
|
|
636
|
+
Distant tiles can draw land cover as one texture each instead: pass `landcoverRaster` in the
|
|
637
|
+
semantic mesh options (`TerrainLandcoverRasterOptions`) and a shared
|
|
638
|
+
`createTerrainGroundTextureMaterialAsync({}, renderer.backend)` as `materials.landcoverRaster`
|
|
639
|
+
(`createTerrainGroundTextureMaterial()` is its synchronous WebGL form; keep the material's origin
|
|
640
|
+
current with `setTerrainGroundOrigin`, as for the ground). Tiles at least `minDepth`
|
|
641
|
+
levels coarser than the pyramid's finest (default 2) then paint their classes into a `size`
|
|
642
|
+
texture (default 256 texels across) and draw it on a copy of the tile's own terrain grid, cut by
|
|
643
|
+
shorelines and model openings like the draped mesh. Each class takes the color the draped mesh
|
|
644
|
+
settles to with distance: crop rows and shrub crowns at their mean. The tile's mapped roads and
|
|
645
|
+
building footprints are painted over the classes (`features`, default on), each texel by the
|
|
646
|
+
share of it they cover, so a town past the range of road and building geometry still reads as
|
|
647
|
+
one; `canopy` tints wooded classes on tiles past the range a host places trees in. The draped
|
|
648
|
+
mesh clips every polygon to the terrain grid and carries 88 bytes a vertex for crop rows, class
|
|
649
|
+
blends and ground detail, none of which shows from kilometers away: over Bellevue at Balanced
|
|
650
|
+
detail it was 1.9 of a view's 4.8 million triangles and 208 of its 671 MiB of visible geometry,
|
|
651
|
+
and its slowest layer to build. With the texture on tiles from two levels down, the same view
|
|
652
|
+
draws 2.5 million triangles and holds 276 MiB, and a flight that had filled its 2 GiB cache and
|
|
653
|
+
evicted 79 tiles stayed at 1.2 GiB and evicted none. The worker bridge builds either form.
|
|
654
|
+
|
|
586
655
|
|
|
587
656
|
Runtime quality controllers can call `stream.setBudget(partialBudget)` with measured screen-space
|
|
588
657
|
error, view distance, selected/resident tile ceilings, concurrency, and optional `maxResidentBytes`.
|
|
@@ -89,6 +89,12 @@ before adding labels and small switches. Record calibration and differences, inc
|
|
|
89
89
|
depths or variant mismatches. If suitable interior references cannot be found, document the
|
|
90
90
|
search and mark the affected geometry as approximate; do not infer approval from exterior QA.
|
|
91
91
|
|
|
92
|
+
Measure each aircraft from the seat as well. `node packages/entities/scripts/cockpit-sweep.mjs
|
|
93
|
+
--ids=<slug>` casts rays from `pilotEye` and reports head clearance, where the seat sits under the
|
|
94
|
+
eye, the view over the nose, and whether the attitude display is in frame. Then look at a seat
|
|
95
|
+
render: world-explorer enters the cockpit 10.3 degrees below level, and Earth view enters level, so
|
|
96
|
+
check the frame the pilot gets. `content/entities/PROPORTION-REVIEW.md` lists each column and limit.
|
|
97
|
+
|
|
92
98
|
Aircraft generators accept `--out /path/to/candidate.glb` for reviewing changes without
|
|
93
99
|
overwriting the master or baseline. Import an approved master with `molen asset import`, update
|
|
94
100
|
the source manifest hash, and run the entity package's `generate` command for aggregate types.
|
|
@@ -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
|
|
11
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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%
|
|
104
|
-
cornering, so a car braking or under power at the
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
|
136
|
-
deformation, pushing other cars,
|
|
137
|
-
|
|
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
|
|
220
|
-
`
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
|
249
|
-
|
|
250
|
-
|
|
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
|
-
|
|
263
|
-
`vehicle.engine.car`,
|
|
264
|
-
engine plays only while someone drives (`self.occupied`), rises in pitch with
|
|
265
|
-
`vehicleState.
|
|
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).
|