@bendyline/molen-tooling 0.0.9 → 0.0.10
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 +239 -236
- package/dist/capture/worldgen-preview.js +215 -215
- package/dist/cli.mjs +6 -5
- package/dist/docs-src/guide/adaptive-performance.md +5 -2
- package/dist/docs-src/guide/aircraft.md +113 -40
- package/dist/docs-src/guide/ambient-life.md +100 -11
- package/dist/docs-src/guide/audio.md +1 -1
- package/dist/docs-src/guide/boats.md +99 -0
- package/dist/docs-src/guide/determinism.md +1 -1
- package/dist/docs-src/guide/dioramas.md +167 -0
- package/dist/docs-src/guide/earth-view.md +241 -3
- package/dist/docs-src/guide/entities.md +32 -1
- package/dist/docs-src/guide/figures.md +7 -1
- package/dist/docs-src/guide/graphics-performance.md +16 -3
- package/dist/docs-src/guide/medium-fi.md +15 -6
- package/dist/docs-src/guide/sky.md +3 -2
- package/dist/docs-src/guide/surface-rendering.md +4 -1
- package/dist/docs-src/guide/vehicle-interiors.md +40 -2
- package/dist/docs-src/guide/vehicles.md +121 -19
- package/dist/docs-src/guide/weather.md +45 -3
- package/dist/docs-src/guide/worldgen.md +8 -0
- package/dist/docs-src/llms.txt +6 -4
- package/dist/docs-src/schemas/archstyle.md +114 -0
- package/dist/docs-src/schemas/components.md +1589 -137
- package/dist/docs-src/schemas/scene.md +6 -3
- package/dist/docs-src/schemas/transport-network.md +4 -2
- package/dist/index.mjs +1 -1
- package/dist/{mcp-BbHk4ibu.mjs → mcp-BbxqqnD1.mjs} +3 -2
- package/dist/{ops-CErtZh2t.mjs → ops-b4Pag8U-.mjs} +7 -5
- package/dist/templates/city-courier/README.md +18 -0
- package/dist/templates/city-courier/gen/molen-types.ts +217 -15
- package/dist/templates/city-courier/index.html +1 -1
- package/dist/templates/city-courier/scripts/molen-scripts.d.ts +219 -17
- package/dist/templates/city-courier/src/audio.ts +26 -4
- package/dist/templates/city-courier/src/game-shell.css +7 -3
- package/dist/templates/city-courier/src/main.ts +25 -3
- package/dist/templates/city-courier/src/shared/accessibility.css +325 -0
- package/dist/templates/city-courier/src/shared/game-controls.ts +406 -0
- package/dist/templates/city-courier/src/shared/game-descriptions.ts +143 -0
- package/dist/templates/city-courier/src/shared/playback.ts +146 -0
- package/dist/templates/city-courier/src/worker.ts +5 -1
- package/dist/templates/cubes/index.html +6 -1
- package/dist/templates/cubes/src/main.ts +25 -2
- package/dist/templates/cubes/src/shared/accessibility.css +325 -0
- package/dist/templates/cubes/src/shared/playback.ts +146 -0
- package/dist/templates/cubes/src/vite-env.d.ts +1 -0
- package/dist/templates/cubes/src/worker.ts +1 -0
- package/dist/templates/data-viz/README.md +4 -0
- package/dist/templates/data-viz/index.html +6 -1
- package/dist/templates/data-viz/src/main.ts +53 -11
- package/dist/templates/data-viz/src/shared/accessibility.css +325 -0
- package/dist/templates/data-viz/src/shared/playback.ts +146 -0
- package/dist/templates/data-viz/src/vite-env.d.ts +1 -0
- package/dist/templates/data-viz/src/worker.ts +1 -0
- package/dist/templates/figures-gallery/index.html +6 -1
- package/dist/templates/figures-gallery/src/main.ts +21 -2
- package/dist/templates/figures-gallery/src/shared/accessibility.css +325 -0
- package/dist/templates/figures-gallery/src/shared/playback.ts +146 -0
- package/dist/templates/figures-gallery/src/vite-env.d.ts +1 -0
- package/dist/templates/figures-gallery/src/worker.ts +1 -0
- package/dist/templates/index.json +36 -16
- package/dist/templates/skybound/README.md +18 -0
- package/dist/templates/skybound/gen/molen-types.ts +217 -15
- package/dist/templates/skybound/index.html +1 -1
- package/dist/templates/skybound/scripts/molen-scripts.d.ts +219 -17
- package/dist/templates/skybound/src/audio.ts +26 -4
- package/dist/templates/skybound/src/game-shell.css +7 -3
- package/dist/templates/skybound/src/main.ts +25 -3
- package/dist/templates/skybound/src/shared/accessibility.css +325 -0
- package/dist/templates/skybound/src/shared/game-controls.ts +406 -0
- package/dist/templates/skybound/src/shared/game-descriptions.ts +143 -0
- package/dist/templates/skybound/src/shared/playback.ts +146 -0
- package/dist/templates/skybound/src/worker.ts +1 -1
- package/dist/templates/terrain-flyover/README.md +5 -1
- package/dist/templates/terrain-flyover/index.html +4 -1
- package/dist/templates/terrain-flyover/src/main.ts +40 -39
- package/dist/templates/top-down-arena/index.html +6 -1
- package/dist/templates/top-down-arena/scripts/molen-scripts.d.ts +219 -17
- package/dist/templates/top-down-arena/src/audio.ts +26 -4
- package/dist/templates/top-down-arena/src/gen/molen-types.ts +217 -15
- package/dist/templates/top-down-arena/src/main.ts +31 -5
- package/dist/templates/top-down-arena/src/shared/accessibility.css +325 -0
- package/dist/templates/top-down-arena/src/shared/playback.ts +146 -0
- package/dist/templates/top-down-arena/src/worker.ts +1 -1
- package/package.json +12 -12
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as formatPacked, A as inspectContentPack, B as searchDocs, C as checkTypesOp, D as buildContentPack, E as reserveNamespace, F as previewFigure, H as describeOps, I as listFigurePresets, J as checkSoundbank, K as planAudio, L as exportFrames, M as bakeNetwork, N as generateTypes, O as extractContentPack, Q as formatBytes, R as driveScene, S as rasterizeMaterial, T as projectInfo, U as formatOp, V as OPS_CATALOG, W as checkScripts, X as stageAssets, Z as screenshotAsset, _ as loadComponentRegistry, b as diffSnapshots, c as validateAsset, d as runSimulation, dt as playExperience, et as packAsset, f as screenshotScene, g as listSchemasOp, h as listComponentsOp, i as bakeWorldgen, it as importAsset, j as verifyContentPack, k as fetchContentPack, l as applyUvPaintOp, m as getSchemaOp, n as worldgenStats, nt as listAssets, p as getComponentOp, q as importSound, r as previewWorldgen, s as simWatch, t as formatWorldgenStats, tt as inspectAsset, u as testTypes, v as scaffoldExperience, w as listTypes, x as runReplayFile, y as listTemplates } from "./ops-
|
|
2
|
+
import { $ as formatPacked, A as inspectContentPack, B as searchDocs, C as checkTypesOp, D as buildContentPack, E as reserveNamespace, F as previewFigure, H as describeOps, I as listFigurePresets, J as checkSoundbank, K as planAudio, L as exportFrames, M as bakeNetwork, N as generateTypes, O as extractContentPack, Q as formatBytes, R as driveScene, S as rasterizeMaterial, T as projectInfo, U as formatOp, V as OPS_CATALOG, W as checkScripts, X as stageAssets, Z as screenshotAsset, _ as loadComponentRegistry, b as diffSnapshots, c as validateAsset, d as runSimulation, dt as playExperience, et as packAsset, f as screenshotScene, g as listSchemasOp, h as listComponentsOp, i as bakeWorldgen, it as importAsset, j as verifyContentPack, k as fetchContentPack, l as applyUvPaintOp, m as getSchemaOp, n as worldgenStats, nt as listAssets, p as getComponentOp, q as importSound, r as previewWorldgen, s as simWatch, t as formatWorldgenStats, tt as inspectAsset, u as testTypes, v as scaffoldExperience, w as listTypes, x as runReplayFile, y as listTemplates } from "./ops-b4Pag8U-.mjs";
|
|
3
3
|
import { dirname, join } from "node:path";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
import { formatIssues } from "@bendyline/molen-schema";
|
|
@@ -1254,7 +1254,7 @@ async function cmdWorldgen(args) {
|
|
|
1254
1254
|
return 2;
|
|
1255
1255
|
}
|
|
1256
1256
|
async function cmdMcp() {
|
|
1257
|
-
const { startMcpServer } = await import("./mcp-
|
|
1257
|
+
const { startMcpServer } = await import("./mcp-BbxqqnD1.mjs");
|
|
1258
1258
|
await startMcpServer();
|
|
1259
1259
|
return 0;
|
|
1260
1260
|
}
|
|
@@ -1361,7 +1361,7 @@ async function runCli(argv) {
|
|
|
1361
1361
|
*/
|
|
1362
1362
|
async function cmdNetwork(args) {
|
|
1363
1363
|
const sub = args.positionals[0];
|
|
1364
|
-
const usage = "usage: molen network bake <terrain-package.json> (--tile z/x/y [--radius n] | --bbox w,s,e,n) --out network.json [--classes road,rail,path] [--heights] [--json]";
|
|
1364
|
+
const usage = "usage: molen network bake <terrain-package.json> (--tile z/x/y [--radius n] | --bbox w,s,e,n) --out network.json [--classes road,rail,path,water] [--heights] [--json]";
|
|
1365
1365
|
if (sub !== "bake") {
|
|
1366
1366
|
err(usage);
|
|
1367
1367
|
return 2;
|
|
@@ -1381,9 +1381,10 @@ async function cmdNetwork(args) {
|
|
|
1381
1381
|
if (classes?.some((c) => ![
|
|
1382
1382
|
"road",
|
|
1383
1383
|
"rail",
|
|
1384
|
-
"path"
|
|
1384
|
+
"path",
|
|
1385
|
+
"water"
|
|
1385
1386
|
].includes(c))) {
|
|
1386
|
-
err("--classes takes road, rail and/or
|
|
1387
|
+
err("--classes takes road, rail, path and/or water");
|
|
1387
1388
|
return 2;
|
|
1388
1389
|
}
|
|
1389
1390
|
const radius = str(args.flags.radius);
|
|
@@ -48,8 +48,11 @@ look: the palette, light rig and styles are the same in every tier (see the
|
|
|
48
48
|
Resident byte estimates count retained height arrays, geometry attributes/indices and instance
|
|
49
49
|
buffers, deduplicating shared backing storage within each object. They exclude textures, archive
|
|
50
50
|
caches and GPU copies, so they are not total device memory measurements. The resident cap is soft:
|
|
51
|
-
visible ground remains until a replacement is loaded. The controller
|
|
52
|
-
|
|
51
|
+
visible ground remains until a replacement is loaded. The explorer feeds the controller displayed
|
|
52
|
+
bytes over the fixed device budget (`earthMemoryBudget()`, as Earth view does), so a full,
|
|
53
|
+
reclaimable warm cache does not prevent recovery. It does not measure them against the tier's own
|
|
54
|
+
resident cap: each step down shrinks that cap, so a dense city's buildings would cascade every
|
|
55
|
+
step to the lowest tier while the view stayed the same. Total resident bytes
|
|
53
56
|
still control eviction. After asynchronous surface replacements settle, `refreshMemoryUsage()`
|
|
54
57
|
updates the cached estimates. Existing surface grids keep their resolution
|
|
55
58
|
to preserve drape alignment; newly admitted terrain uses the current cap.
|
|
@@ -32,13 +32,23 @@ streaming and floating-origin changes. Reloading starts a fresh session.
|
|
|
32
32
|
| R | Recover at the airfield after an impact |
|
|
33
33
|
|
|
34
34
|
Mustang: start the engine, set flaps, hold the brake while raising throttle, then release the brake.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
The propeller swings the nose left as the tail gets light, and a crosswind turns it into the wind:
|
|
36
|
+
hold a little right rudder (Z), or rudder away from the wind, to keep the runway centerline.
|
|
37
|
+
Rotate around 85–100 knots and release the pitch key once the nose is about 10 degrees up; the
|
|
38
|
+
airplane keeps the attitude it lifted off at. At climb power the propeller's torque rolls it
|
|
39
|
+
slowly left, so tap right bank (D) as needed. Retract gear and flaps after climbing. Reduce
|
|
40
|
+
throttle on approach, lower gear and flaps, and land with wings level and a gentle descent.
|
|
41
|
+
Gear-up and hard landings register an impact. To accelerate, ease the nose down toward level
|
|
42
|
+
flight after cleaning up; holding the takeoff attitude spends engine power on climbing. During a
|
|
43
|
+
stall, lower the nose, add power and gently level the wings. Let airspeed rebuild before pulling
|
|
44
|
+
out; hauling back immediately can stall the wing again, and rudder in a stall drops a wing. A
|
|
45
|
+
stall recovery requires altitude.
|
|
46
|
+
|
|
47
|
+
There are no attitude limits: hold A or D to roll through inverted, hold S at speed to loop.
|
|
48
|
+
Releasing the stick holds the flight path the airplane is on; a brief tap of W or S changes it
|
|
49
|
+
by a degree or so. Above about 250 knots full back stick stops at 6 g. In a bank the wing's lift
|
|
50
|
+
no longer holds the airplane up, so add back pressure to keep a turn level. Gusts and turbulence
|
|
51
|
+
from the Weather setting bump, roll and yaw the airplane, more so near the ground on windy days.
|
|
42
52
|
|
|
43
53
|
OH-6: start the engine and allow roughly six simulation seconds to reach full rotor speed. Raise
|
|
44
54
|
collective gradually toward 50%; exact hover power varies with altitude and ground effect. Small
|
|
@@ -48,8 +58,11 @@ flight while airborne. After an impact, R resets its aircraft state and places i
|
|
|
48
58
|
|
|
49
59
|
Cockpit needles show airspeed, altitude, heading, vertical speed and RPM; the artificial horizon
|
|
50
60
|
banks with the aircraft. The HUD supplies precise knot/feet/feet-per-minute readings, AGL height,
|
|
51
|
-
power, engine/gear/flap state, stall alerts and terrain waiting status. Propellers, both helicopter
|
|
52
|
-
rotors, controls, gear, flaps and
|
|
61
|
+
g load, power, engine/gear/flap state, stall alerts and terrain waiting status. Propellers, both helicopter
|
|
62
|
+
rotors, controls, gear, flaps, ailerons, elevators and rudder animate from simulation state. The
|
|
63
|
+
Mustang's gear takes 12 seconds: its inner wheel doors open, each main leg swings inboard into a
|
|
64
|
+
well in the wing root, the tail wheel folds forward into the fuselage, and the doors close behind
|
|
65
|
+
them. Its flaps take 13 seconds to run down to 50°.
|
|
53
66
|
|
|
54
67
|
## Reuse in another experience
|
|
55
68
|
|
|
@@ -88,24 +101,79 @@ bypass walking physics. Only the occupied pilot seat can submit flight intent.
|
|
|
88
101
|
The render half is `@bendyline/molen-client/aircraft`: `createAircraftVisual(loadedGlb, spec)` takes
|
|
89
102
|
ownership of a loaded GLB and animates the nodes named by `spec.visual` from aircraft state, and
|
|
90
103
|
`aircraftCameraPose(transform, spec, options)` returns the cockpit or chase pose from the same
|
|
91
|
-
`VehicleCameraOptions` that `@bendyline/molen-client/vehicles` exports.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
`
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
`VehicleCameraOptions` that `@bendyline/molen-client/vehicles` exports. The gear and flaps follow
|
|
105
|
+
`aircraftState.gearPosition` and `flapPosition` as they travel. `spec.visual.animation` adds
|
|
106
|
+
exterior moving parts as [model-signal bindings](vehicle-interiors.md#exterior-animation), with
|
|
107
|
+
keyframed curves so one gear position can sequence doors and legs.
|
|
108
|
+
|
|
109
|
+
The deterministic airplane solver is a six-degree-of-freedom rigid body. The transform's
|
|
110
|
+
quaternion is the attitude, with no pitch or bank stops, so loops, rolls, inverted flight and
|
|
111
|
+
spins follow from the forces; `aircraftState.yaw`, `pitch` and `roll` report that attitude (roll
|
|
112
|
+
is ±π inverted). Forces are lift, induced/profile/gear/flap drag, side force, propeller thrust
|
|
113
|
+
and gravity at the center of mass, from wind-relative airflow and air density. Moments are
|
|
114
|
+
angle-of-attack (pitch) and weathercock (yaw) stability, roll, pitch and yaw damping, dihedral
|
|
115
|
+
effect, roll from yaw rate, inertia coupling, asymmetric thrust, and, scaled by
|
|
116
|
+
`propellerEffects`, propeller torque, P-factor and slipstream yaw, and gyroscopic precession.
|
|
117
|
+
The airframe turns about its center of mass in flight and about its wheels on the ground.
|
|
118
|
+
|
|
119
|
+
Stall depends on wing incidence, including camber, rather than a fixed true-airspeed cutoff.
|
|
120
|
+
Separated flow progressively loses lift and control authority, adds drag, breaks the nose toward
|
|
121
|
+
attached flow, and loses roll damping so yaw drops a wing. Lift remains perpendicular to airflow.
|
|
122
|
+
Elevator and rudder retain limited propwash authority at low speed. Throttle controls shaft
|
|
123
|
+
power with a transient RPM spool limit, avoiding a second steady power penalty from RPM.
|
|
124
|
+
|
|
125
|
+
Flight assistance is limited to the pitch axis, so a keyboard can fly it. The stick moves an
|
|
126
|
+
elevator (deflecting at `pitchResponse` per second and springing back four times faster) that
|
|
127
|
+
adds up to `pitchAuthority` radians of angle of attack to a trim angle; the airframe's
|
|
128
|
+
short-period dynamics (`pitchFrequency`, `pitchDamping`) fly toward it. Trim follows the angle of
|
|
129
|
+
attack that keeps the flight path straight at `autoTrim` per second (0 leaves it fixed, like a
|
|
130
|
+
real stick-fixed airplane), is captured at liftoff, and never exceeds the stall. Full stick stops
|
|
131
|
+
at `maxLoadFactor` / `minLoadFactor` g at high speed. Ailerons command a roll rate
|
|
132
|
+
(`rollAuthority`) against roll damping (`rollResponse`). The rudder is a yaw moment
|
|
133
|
+
(`rudderAuthority`) against `directionalStability` and `yawDamping`; yaw damping acts on half the
|
|
134
|
+
turn rate, so turns need little rudder while dihedral (`dihedralEffect`) still levels the wings
|
|
135
|
+
slowly hands-off. Rates are given at `controlAuthoritySpeed` and scale with dynamic pressure.
|
|
136
|
+
|
|
137
|
+
On the ground a steerable tailwheel (`groundSteerSpeed`) and tire side grip (`groundTrackRate`)
|
|
138
|
+
hold the rolling direction to the nose, sharing the load with the wing: as lift builds the
|
|
139
|
+
tires let go, so crosswind weathervaning and propeller swing grow through the takeoff roll and
|
|
140
|
+
drift persists after touchdown. The gear holds the wings level and the nose at its resting
|
|
141
|
+
attitude until the elevator lifts it, up to `maxGroundPitch`.
|
|
142
|
+
|
|
143
|
+
The gear and flaps travel rather than switch. `aircraftInput.gear` and `flaps` select a position,
|
|
144
|
+
and `aircraftState.gearPosition` and `flapPosition` (0 up, 1 down) move toward it over
|
|
145
|
+
`airplane.gearTransitTime` seconds for a full gear cycle, doors included, and `flapTransitTime`
|
|
146
|
+
for full flap travel. Gear drag, flap lift and flap drag scale with the positions. A
|
|
147
|
+
weight-on-wheels lock holds the gear still on the ground, so selecting it up before takeoff raises
|
|
148
|
+
it once the wheels leave the runway. Touching down before the gear locks down is a belly landing,
|
|
149
|
+
which counts as a crash. Both times default to 0, which switches instantly as before, and a state
|
|
150
|
+
without positions starts at the selection.
|
|
151
|
+
|
|
152
|
+
Each engine's `propellerRotation` (default `clockwise` seen from the cockpit, the left-turning
|
|
153
|
+
case) and `propellerInertia` set the direction and size of the propeller effects;
|
|
154
|
+
`airplane.propellerEffects` scales them from 0 (none, the default) to 1. The shipped Mustang uses
|
|
155
|
+
0.2, enough to feel on the takeoff roll and at climb power; raise it toward 1 for the full
|
|
156
|
+
handful. `rollInertia`, `pitchInertia` and `yawInertia` set the moments of inertia.
|
|
157
|
+
`airplane.stallTransitionAngle` sets the separation transition width (radians, default `0.12`).
|
|
158
|
+
`stallDrag` is the broadside separated-flow coefficient, scaled by separation and
|
|
106
159
|
`sin(alpha)^2`. The legacy `stallSpeed` tuning reference no longer triggers aerodynamic stall.
|
|
107
|
-
|
|
108
|
-
|
|
160
|
+
Wing position remains metadata rather than a distributed lift model.
|
|
161
|
+
|
|
162
|
+
`levelFlightAngleOfAttack(spec, airspeed, density?)` returns the angle of attack that carries an
|
|
163
|
+
airplane's weight. Start an airplane in flight with that as its pitch and `pitchTrim` (the Earth
|
|
164
|
+
view's airborne launch does) and it holds level flight hands-off.
|
|
165
|
+
|
|
166
|
+
### Wind and turbulence
|
|
167
|
+
|
|
168
|
+
Aircraft feel the weather's wind field, not only its mean `windVelocity`: a shear profile with
|
|
169
|
+
height above ground, turbulence carried downwind, gusts along the wind, and slope flow that lifts
|
|
170
|
+
air up windward hillsides and sinks it, rougher, in the lee (see
|
|
171
|
+
[Weather](weather.md#wind-shear-turbulence-and-gusts)). The airplane samples it at its center of
|
|
172
|
+
mass and both wingtips, so uneven gusts across the span roll it; the helicopter samples across
|
|
173
|
+
its rotor disc. The field is a function of the weather, the position and simulation time, so
|
|
174
|
+
replays and keyframes reproduce every bump. `installAircraft` hands the solver the world clock;
|
|
175
|
+
callers of `stepAircraft` pass `time` in the environment. An explicit uniform `wind` override
|
|
176
|
+
turns the structure off.
|
|
109
177
|
|
|
110
178
|
## In an Earth view
|
|
111
179
|
|
|
@@ -117,7 +185,8 @@ altitude, vertical speed, attitude, power and engine/gear/flap state for a HUD,
|
|
|
117
185
|
Hosts composing their own view use `EarthAircraft` from `@bendyline/molen-earth/client`: it
|
|
118
186
|
spawns any aircraft type into the vehicles' ECS world, on the ground or with
|
|
119
187
|
`airborne: { speed, power }`, boards and releases the pilot, applies `EarthPilotControls` and
|
|
120
|
-
draws the models.
|
|
188
|
+
draws the models. To start from a real runway, ask `view.airfields` for one and spawn at its
|
|
189
|
+
`threshold` placement; see [Airfields](earth-view.md#airfields).
|
|
121
190
|
|
|
122
191
|
## Engine sound
|
|
123
192
|
|
|
@@ -165,9 +234,9 @@ Positions are meters from the aircraft's landing-contact origin, with +Z forward
|
|
|
165
234
|
`(position - centerOfMass) × thrust`. A failed left engine therefore leaves the right engine
|
|
166
235
|
yawing the nose left. Rudder can counter the yaw; cutting the remaining engine removes the
|
|
167
236
|
powered asymmetry. Greater lateral separation produces a larger moment. `airplane.yawInertia`
|
|
168
|
-
sets yaw inertia in kg m² (default `mass * (span² + length²) / 12`)
|
|
169
|
-
|
|
170
|
-
|
|
237
|
+
sets yaw inertia in kg m² (default `mass * (span² + length²) / 12`). The thrust moment joins the
|
|
238
|
+
airframe's other yaw moments in `aircraftState.yawRate`, against weathercock stability and yaw
|
|
239
|
+
damping in the air and tire grip on the ground.
|
|
171
240
|
|
|
172
241
|
The normal throttle and engine switch still control the whole bank. Optional
|
|
173
242
|
`aircraftInput.engines` entries override individual throttles or switches; omitted fields inherit
|
|
@@ -195,17 +264,18 @@ API does not add a twin-engine model, failure key or automatic random failures.
|
|
|
195
264
|
The solver initializes missing engine state from the legacy RPM/phase, then the per-engine state
|
|
196
265
|
is authoritative. The aggregate `rpm` is the maximum across engines, and aggregate `rotorAngle`
|
|
197
266
|
follows the first engine. Set `visual.rotors[].engine` to animate independent propellers; omitted
|
|
198
|
-
bindings retain the common phase.
|
|
267
|
+
bindings retain the common phase. Body rates, trim, all engine state and input overrides survive
|
|
199
268
|
keyframes/replay and pause at terrain gaps. Boarding and exit checks consider every engine.
|
|
200
269
|
|
|
201
|
-
This extension models propeller
|
|
202
|
-
|
|
203
|
-
|
|
270
|
+
This extension models propeller thrust imbalance as a yaw moment. It does not add pitch or roll
|
|
271
|
+
moments from the thrust line, feathering, windmilling drag or a calibrated minimum-control-speed
|
|
272
|
+
envelope; propeller torque, P-factor and precession come from `propellerEffects` above. Helicopters continue to use
|
|
204
273
|
one `engine` driving the shared rotor; multiple turbines feeding a common gearbox require a
|
|
205
274
|
different shaft-power model and are not represented by independent propeller engines.
|
|
206
275
|
|
|
207
276
|
Helicopter forces include rotor spool, collective lift, cyclic tilt, ground effect,
|
|
208
|
-
translational lift, air drag and assisted yaw
|
|
277
|
+
translational lift, air drag and assisted yaw; the helicopter keeps the assisted model, in which
|
|
278
|
+
cyclic commands a disc tilt bounded by `maxTilt`, and gusts across the disc tip it. State includes velocity, attitude/rates, rotor phase
|
|
209
279
|
and controls for checkpoint/replay. Translational lift uses air-relative horizontal speed, so
|
|
210
280
|
wind and forward motion give consistent results. Collision sampling is at least 120 Hz and at most one meter
|
|
211
281
|
of translation per substep. Unknown terrain pauses at the last known position and resumes when
|
|
@@ -217,10 +287,10 @@ conservative aircraft bounds. Imported collision hulls are
|
|
|
217
287
|
available for hosts that need a different collision solver. Without `canOccupy`, the kernel only
|
|
218
288
|
collides with terrain. Do not add a second physics body that also writes the aircraft transform.
|
|
219
289
|
|
|
220
|
-
This is
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
are outside this implementation. Cockpit switches and pedals are visual details; the listed input
|
|
290
|
+
This is a game flight model with recognizable polygonal aircraft, not a full aircraft systems
|
|
291
|
+
simulation or a calibrated replica of any airplane's handling. Rotor blade-element aerodynamics,
|
|
292
|
+
autorotation, vortex-ring state, a calibrated spin model, fuel, automatic engine damage, detailed
|
|
293
|
+
avionics and weapons are outside this implementation. Cockpit switches and pedals are visual details; the listed input
|
|
224
294
|
controls operate the simulated systems. Collision uses coarse airframe probes and resident world
|
|
225
295
|
geometry; it does not model deformation or distant unloaded obstacles.
|
|
226
296
|
|
|
@@ -234,7 +304,10 @@ scenario is `examples/world-explorer/test/visual/aircraft.play.json`.
|
|
|
234
304
|
|
|
235
305
|
`packages/kernel/test/aircraft-performance.test.ts` exercises level acceleration, part-throttle
|
|
236
306
|
power, configuration drag, stall recovery from either bank direction, coordinated turns,
|
|
237
|
-
unpowered energy loss, wind equivalence and 30/60/120 Hz consistency.
|
|
307
|
+
unpowered energy loss, wind equivalence and 30/60/120 Hz consistency.
|
|
308
|
+
`packages/kernel/test/aircraft-dynamics.test.ts` covers full rolls, loops and the load-factor
|
|
309
|
+
limit, flight-path hold, trimmed launches, propeller swing and crosswind on the takeoff roll,
|
|
310
|
+
and turbulence that matches across host rates and keyframes. In calm air at 1,000 m,
|
|
238
311
|
starting at 60 m/s and using a test pilot to hold altitude for 120 seconds, the tuned Mustang
|
|
239
312
|
reaches approximately 311 knots at full throttle, 262 knots at 65% throttle, and 203 knots with
|
|
240
313
|
gear and flaps extended. These are simulation regression targets, not a certified performance
|
|
@@ -66,8 +66,8 @@ is the road surface height.
|
|
|
66
66
|
|
|
67
67
|
| Field | What it holds |
|
|
68
68
|
|---|---|
|
|
69
|
-
| `ways[]` | `class` (`road`, `rail`, `path`, `air`), `subclass` (the OSM kind, for example `primary`, `residential`, `service`, `footway`, `tram`), `points`, and optionally `oneway`, `lanes`, `width`, `speed` (m/s), `layer`, `bridge`, `tunnel` |
|
|
70
|
-
| `stations[]` | `id`, `at: [x, z]`, `kind` (`rail` or `
|
|
69
|
+
| `ways[]` | `class` (`road`, `rail`, `path`, `air`, `water`), `subclass` (the OSM kind, for example `primary`, `residential`, `service`, `footway`, `tram`), `points`, and optionally `oneway`, `lanes`, `width`, `speed` (m/s), `layer`, `bridge`, `tunnel` |
|
|
70
|
+
| `stations[]` | `id`, `at: [x, z]`, `kind` (`rail`, `bus` or `ferry`), `dwell` in seconds. Trains stop at the rail station nearest their track |
|
|
71
71
|
| `signals[]` | `at: [x, z]` and `kind`. A `light` signalises the junction nearest the point. A `stop` or `yield` sign makes the arm it stands on give way |
|
|
72
72
|
| `aerodromes[]` | `id`, `at: [x, z]`, `heading`, `length`. Some aircraft fly its approach and departure |
|
|
73
73
|
| `drivingSide` | `right` (default) or `left` |
|
|
@@ -117,7 +117,7 @@ Every field is optional. [`molen/scene@3`](../schemas/scene.md) lists them with
|
|
|
117
117
|
|---|---|
|
|
118
118
|
| `network` | A path to a transport-network document, or the document inline |
|
|
119
119
|
| `observer` | The entity the spawn ring follows |
|
|
120
|
-
| `classes` | Which classes run: `car`, `pedestrian`, `train`, `aircraft` (default `["car"]`) |
|
|
120
|
+
| `classes` | Which classes run: `car`, `pedestrian`, `train`, `aircraft`, `boat` (default `["car"]`) |
|
|
121
121
|
| `density` | Target agents per kilometre of lane near the observer, per class. For `aircraft` it is the number in the sky |
|
|
122
122
|
| `drivingSide` | `right` (default) or `left`, when the network does not say |
|
|
123
123
|
| `radius` | Outer spawn radius for cars in metres (default 350) |
|
|
@@ -281,6 +281,14 @@ For streamed maps, `registerTile` and `unregisterTile` add and drop one tile's t
|
|
|
281
281
|
features. Changes queue until the next tick, so a tile never changes the network mid-step.
|
|
282
282
|
`blocks(box)` answers whether an ambient car overlaps a box, for a vehicle solver's obstacle test.
|
|
283
283
|
|
|
284
|
+
`createAmbientRenderer` draws pedestrians with `AmbientFigures`, which a host can also use for its
|
|
285
|
+
own characters: `update(walkers, camera, tick, tickRate)` takes `WalkerView`s (`id`, `figure`,
|
|
286
|
+
`pos`, `rot`, `speed`, `since`, `hidden`), pools a skinned body per descriptor and poses it from
|
|
287
|
+
its speed. Three optional fields go beyond walking: `mode` (`'run'`, or `'sit'` for a seated pose),
|
|
288
|
+
`anchor: 'eye'` (the position is the eye point, as a vehicle seat names it) and `lookAt` (a world
|
|
289
|
+
point the head turns toward). A seated or eye-anchored figure is drawn only at the animated detail
|
|
290
|
+
tiers. The Earth view draws its actors and the walker's avatar this way.
|
|
291
|
+
|
|
284
292
|
## In the Earth view
|
|
285
293
|
|
|
286
294
|
`mountEarthView` runs ambient life by default on the roads, footways and railways of the streamed
|
|
@@ -297,8 +305,7 @@ const view = await mountEarthView({
|
|
|
297
305
|
trafficButton.onclick = () => view.setAmbientEnabled(!view.ambientEnabled);
|
|
298
306
|
```
|
|
299
307
|
|
|
300
|
-
`density` scales how busy the streets are, from 0 to 1. `cars`, `pedestrians`, `rail` and
|
|
301
|
-
`aircraft` switch classes, and `drivingSide` sets the side of the road. `ambient: false` turns the
|
|
308
|
+
`density` scales how busy the streets are, from 0 to 1. `cars`, `pedestrians`, `rail`, `aircraft` and `boats` switch classes, and `drivingSide` sets the side of the road. `ambient: false` turns the
|
|
302
309
|
layer off entirely. `stats().ambient` reports the counts on screen and the tiles in use.
|
|
303
310
|
|
|
304
311
|
The quality tier caps the numbers:
|
|
@@ -313,8 +320,31 @@ The quality tier caps the numbers:
|
|
|
313
320
|
| Ultra | 320 | 120 | 2 | 4 | 16 | 1000 m |
|
|
314
321
|
|
|
315
322
|
Ambient cars share the view's vehicle world, so the car you drive stops against them and traffic
|
|
316
|
-
waits for you
|
|
317
|
-
re-anchors after a long
|
|
323
|
+
waits for you, and for the view's [actors](earth-view.md#actors-companions-and-npcs) on foot. They
|
|
324
|
+
follow the rendered ground and bridge decks, and they rebuild when the view re-anchors after a long
|
|
325
|
+
trip.
|
|
326
|
+
|
|
327
|
+
### Promoting a pedestrian
|
|
328
|
+
|
|
329
|
+
Ambient pedestrians come and go with the spawn ring; a host that wants one to stay (someone the
|
|
330
|
+
player stopped to talk to, a fare at the kerb) promotes it to an [actor](earth-view.md#actors-companions-and-npcs):
|
|
331
|
+
|
|
332
|
+
```ts
|
|
333
|
+
const view = await mountEarthView({ /* … */ interaction: { pedestrians: true } });
|
|
334
|
+
view.on('interact', ({ kind, id, claim }) => {
|
|
335
|
+
if (kind !== 'pedestrian' || id === undefined) return;
|
|
336
|
+
claim();
|
|
337
|
+
const actor = view.actors.adopt(id, { behaviour: { kind: 'follow', target: 'viewer' } });
|
|
338
|
+
if (actor !== undefined) startConversation(actor);
|
|
339
|
+
});
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
`interaction.pedestrians` makes the interact key offer the nearest pedestrian in reach
|
|
343
|
+
(`kind: 'pedestrian'`), and `view.actors.adopt(id, { id?, behaviour?, interactable? })` keeps it
|
|
344
|
+
where it stands with the same body. The agent leaves ambient life for good: it stops, the spawner
|
|
345
|
+
no longer counts or removes it, and the actors draw it from then on, looking at the viewer and
|
|
346
|
+
interactable unless the spec says otherwise. `adopt` returns undefined when the pedestrian has
|
|
347
|
+
already gone. It is one-way; an actor never returns to the pool.
|
|
318
348
|
|
|
319
349
|
## NPC content and `ambientRole`
|
|
320
350
|
|
|
@@ -345,17 +375,74 @@ An entity type joins the ambient pools with an `ambientRole`:
|
|
|
345
375
|
}
|
|
346
376
|
```
|
|
347
377
|
|
|
348
|
-
`role` is `car`, `bus` (drives with cars), `rail` or `
|
|
378
|
+
`role` is `car`, `bus` (drives with cars), `rail`, `aircraft`, `boat` or `ferry`. A type with a `vehicle`
|
|
349
379
|
component takes its dimensions and wheels from the vehicle spec, so its role can be as short as
|
|
350
380
|
`{ "role": "car" }`. Other types give `length`, `width` and `height`, and `visual` names their
|
|
351
381
|
wheel, paint, rotor and landing-gear nodes. `weight` sets how often a type spawns within its pool,
|
|
352
382
|
and `cars` how many cars a train has.
|
|
353
383
|
|
|
354
|
-
The `molen.entities` pack gives roles to its
|
|
355
|
-
|
|
356
|
-
view draws
|
|
384
|
+
The `molen.entities` pack gives roles to its eleven road vehicles, a city bus, a light-rail car, an airliner
|
|
385
|
+
the P-51 and OH-6 aircraft, and eight watercraft. See [Reusable entities](entities.md). Near the
|
|
386
|
+
camera the Earth view draws cars, trains and vessels with their full models, painted in the
|
|
387
|
+
agent's colour. Further
|
|
357
388
|
out, and without content, every vehicle is a proxy shape built from its dimensions.
|
|
358
389
|
|
|
390
|
+
## Water traffic
|
|
391
|
+
|
|
392
|
+
Enable the `boat` agent class and supply **navigation routes**, not water polygon boundaries:
|
|
393
|
+
|
|
394
|
+
```json
|
|
395
|
+
{
|
|
396
|
+
"ambient": {
|
|
397
|
+
"observer": "player",
|
|
398
|
+
"classes": ["boat"],
|
|
399
|
+
"density": { "boat": 1 },
|
|
400
|
+
"network": {
|
|
401
|
+
"format": "molen/transport-network@1",
|
|
402
|
+
"ways": [
|
|
403
|
+
{ "class": "water", "subclass": "ferry", "width": 60, "speed": 8,
|
|
404
|
+
"points": [[-800, 0, 0], [800, 0, 0]] },
|
|
405
|
+
{ "class": "water", "subclass": "channel", "width": 120, "speed": 7,
|
|
406
|
+
"points": [[-1200, 0, 250], [1200, 0, 250]] }
|
|
407
|
+
],
|
|
408
|
+
"stations": [{ "id": "harbor", "kind": "ferry", "at": [0, 0], "dwell": 20 }]
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
The boat pool serves `water` lanes only. Ferries use `ferry` routes; other vessels use `channel`
|
|
415
|
+
routes. Two-way routes keep to starboard regardless of the road driving side; `oneway: true`
|
|
416
|
+
uses the centreline. `width` is the whole navigation corridor: a vessel must fit its half on a
|
|
417
|
+
two-way route, and its length must fit the segment. Junction choices also reject narrower or
|
|
418
|
+
shorter branches. Roads crossing a water route never create road/water connections.
|
|
419
|
+
|
|
420
|
+
Two-coordinate points default to sea level, **never seabed terrain height**. Use explicit
|
|
421
|
+
`[x, y, z]` surface heights for inland/elevated water. Author broad curves and clear channels:
|
|
422
|
+
there is no depth, shoreline or obstacle planner. Mapped `ferry` transportation lines and
|
|
423
|
+
`ferry_terminal` POIs are retained by streamed Earth networks and `network bake --classes water`.
|
|
424
|
+
Mapped routes currently assume sea level; inland ferry elevation needs an authored network.
|
|
425
|
+
|
|
426
|
+
Vessels accelerate and brake slowly, follow the vessel ahead, and keep a generous gap. Ferries
|
|
427
|
+
dwell at terminals (`dwell` seconds, default 30), then resume; an unannotated route end also
|
|
428
|
+
receives a 30-second turnaround stop. Boats return along a two-way route at its end. No routes
|
|
429
|
+
means no boats: the engine does not invent shipping lanes across arbitrary water.
|
|
430
|
+
|
|
431
|
+
Defaults are near/far/keep radii of 100/1800/2400 metres, 0.8 vessels per lane-km and a cap of
|
|
432
|
+
12. `setBudget({ boats })` caps the kernel population. `createAmbientRenderer` uses vessel
|
|
433
|
+
proxies without content and up to four full vessel models within 1.2 km when a model provider
|
|
434
|
+
is available; `detailedBoats` controls that separate render budget. Earth quality tiers cap
|
|
435
|
+
boats at 0/2/4/6/8/12; `ambient: { boats: false }` disables them, and stats report `boats`.
|
|
436
|
+
|
|
437
|
+
Content hosts populate `types.boat` with `AmbientVehicleType` entries whose `waterway` is
|
|
438
|
+
`"ferry"` or `"channel"`, and supply full models through the existing renderer vehicle adapter
|
|
439
|
+
(with empty wheel lists). The Earth content adapter derives these from `ambientRole` automatically.
|
|
440
|
+
A scene may instead use `ambient.templates.boat` for a vessel prefab, as the engine repository's
|
|
441
|
+
harbor scene does. Without a type pool the capability uses dimensioned ferry/boat proxies.
|
|
442
|
+
|
|
443
|
+
This is ambient route following. It does not model buoyancy, waves, maritime crossing priority,
|
|
444
|
+
ship schedules, passenger boarding or player helm controls. Cycles are player-rideable through [vehicles](vehicles.md#riding-cycles); ambient cycle riders are not spawned.
|
|
445
|
+
|
|
359
446
|
## Determinism and cost
|
|
360
447
|
|
|
361
448
|
Agent state lives in components: lane, distance along it, speed, and the seed behind every choice.
|
|
@@ -380,6 +467,8 @@ most one tile every 200 ms. In the engine repository,
|
|
|
380
467
|
- Aircraft fly straight lines. They do not taxi, circle or land beyond the approach.
|
|
381
468
|
- Pedestrians keep to their lane and follow the walker ahead. They do not step around each other.
|
|
382
469
|
- Agents do not open doors, board, or park. A parked car in the Earth view is a separate entity.
|
|
470
|
+
- A promoted pedestrian keeps its body but nothing of its walk: it stands until its actor
|
|
471
|
+
behaviour moves it, and it never rejoins ambient life.
|
|
383
472
|
|
|
384
473
|
## Read next
|
|
385
474
|
|
|
@@ -128,7 +128,7 @@ makes a sound flicker.
|
|
|
128
128
|
| --- | --- |
|
|
129
129
|
| `<component>.<field>` | A field of a component on the source's entity, e.g. `vehicleState.speed`, `aircraftState.rpm`, `transform.pos.1`. In `audioEnvironment` rules it reads the `listenerEntity` |
|
|
130
130
|
| `self.speed`, `self.distance`, `self.x/y/z` | The source entity's measured speed (m/s), distance travelled (m) and position |
|
|
131
|
-
| `self.occupied` | true while someone rides the source entity (an entity's `mounted` component names it) |
|
|
131
|
+
| `self.occupied` | true while someone rides the source entity (an entity's `mounted` component names it), in any seat but a `passenger` one: a passenger alone does not start an engine |
|
|
132
132
|
| `listener.speed`, `listener.distance`, `listener.x/y/z`, `listener.altitude` | The listener's speed, odometer and position |
|
|
133
133
|
| `listener.heightAboveGround` | What the host reports as the listener's height above the terrain (m); 0 when it reports nothing |
|
|
134
134
|
| `listener.mode`, `listener.grounded`, `listener.surface`, `listener.indoors` | What the host reports: walk, drive, fly, pilot or orbit; on the ground; the surface underfoot; inside a building |
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Boats, passengers and water
|
|
2
|
+
|
|
3
|
+
Boats use a dedicated deterministic hull solver and the same driver/passenger seat contract as
|
|
4
|
+
cars and aircraft. The entities pack supplies eight powered watercraft: speedboat, sailboat
|
|
5
|
+
(using its auxiliary motor), fishing boat, tug, container ship, bulk carrier, passenger ferry and
|
|
6
|
+
car ferry. Their handling, draft, helm, boarding points and passenger seats live in their types.
|
|
7
|
+
|
|
8
|
+
## In Earth view and World Explorer
|
|
9
|
+
|
|
10
|
+
Earth view's **Boat** button launches a speedboat on nearby mapped water. In World Explorer,
|
|
11
|
+
press **B** near water (or open it with `?boat=1`). **W/S** apply forward/reverse thrust,
|
|
12
|
+
**A/D** steer, **Space** applies opposing thrust, and holding **Shift** drops anchor once speed
|
|
13
|
+
falls below walking pace. Release Shift to weigh anchor. **V** changes helm/chase view. Walk up
|
|
14
|
+
to a stopped boat's boarding point and press **E** to board; E leaves only beside a reachable,
|
|
15
|
+
clear shore or dock. A boat coasts when power is released; it has no road brakes. Reverse
|
|
16
|
+
thrust takes time to stop it, and steering reverses when backing up.
|
|
17
|
+
|
|
18
|
+
The hull samples water across its footprint, preventing its bow and sides from crossing land.
|
|
19
|
+
Missing water tiles pause it. Known depth below its draft grounds it. Earth uses the rendered
|
|
20
|
+
water polygons and their actual elevations, including inland lakes. Elevation DEMs are not
|
|
21
|
+
bathymetry: when depth is unavailable, the host checks water coverage without inventing a depth.
|
|
22
|
+
A host can supply measured depths through `waterAt`.
|
|
23
|
+
|
|
24
|
+
Swells lift, pitch and roll the hull, and turns produce a small bank. Currents carry an unanchored
|
|
25
|
+
boat; the helm needs forward motion or propeller wash to turn. Rendered water uses the same
|
|
26
|
+
analytic swell slopes and simulation time as the hull. The shoreline polygons stay flat: this
|
|
27
|
+
version adds moving normals, not displaced surf, breaking waves, tides or a fluid simulation.
|
|
28
|
+
Wind-driven sailing, capsize/damage, deck walking, and carrying loose cars/cargo are not included.
|
|
29
|
+
|
|
30
|
+
## Host API
|
|
31
|
+
|
|
32
|
+
`mountEarthView` accepts `water: { waves, current }`. Empty `waves` gives calm water;
|
|
33
|
+
`current` is `[east, south]` in meters per second. Each swell has `amplitude` and `wavelength`
|
|
34
|
+
in meters, `direction` in radians (zero towards +Z/south), and propagation `speed` in m/s.
|
|
35
|
+
The default is mild coastal chop with no current. A host can author stronger seas and currents
|
|
36
|
+
for a route or challenge; these are authored conditions, not live ocean observations.
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
const view = await mountEarthView({
|
|
40
|
+
canvas, terrain, content, camera,
|
|
41
|
+
water: {
|
|
42
|
+
waves: [{ amplitude: 0.4, wavelength: 22, direction: 0.7, speed: 4 }],
|
|
43
|
+
current: [0.5, 0],
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
view.setMode('drive', { vehicle: 'molen.entities.watercraft.speedboat', force: true });
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Boats use the existing `drive` navigation mode. `vehicleStatus()` distinguishes `kind: 'boat'`
|
|
50
|
+
and includes `anchored` and `grounded`, alongside speed, heading, camera view and streaming status.
|
|
51
|
+
For a persistent boat, call `view.vehicles.spawn({ type, latitude, longitude, heading })`, await
|
|
52
|
+
`whenPlaced(id)`, and call `board(id, { force: true })`. It survives release and frame re-anchoring.
|
|
53
|
+
Use `view.actors.setBehaviour(actor, { kind: 'board', vehicle: id })` for a passenger, and
|
|
54
|
+
`{ kind: 'alight' }` to leave by the same stopped, dry-exit rules. See [actors](earth-view.md#actors-companions-and-npcs).
|
|
55
|
+
|
|
56
|
+
Hosts composing a viewer directly can use `EarthVehicles.spawn`, `spawnNear`, `board`, `unmount`
|
|
57
|
+
and `boatTypeIds`, with the same `water` settings and optional `waterAt` callback. `EarthWater`
|
|
58
|
+
provides the rendered-water sampler. Its `sync()` refreshes visible mesh coverage after streaming.
|
|
59
|
+
The callback receives absolute metric X/Z in the current terrain frame, not longitude/latitude.
|
|
60
|
+
|
|
61
|
+
## Headless simulation
|
|
62
|
+
|
|
63
|
+
Import from `@bendyline/molen-kernel/boats`; no DOM or three.js is required.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { installBoats, driveBoat } from '@bendyline/molen-kernel/boats';
|
|
67
|
+
import { mountEntity, unmountEntity } from '@bendyline/molen-kernel/vehicles';
|
|
68
|
+
|
|
69
|
+
export function setup(world) {
|
|
70
|
+
installBoats(world, {
|
|
71
|
+
waterAt: (x, z) => ({ height: 0, depth: 8 }),
|
|
72
|
+
conditions: { waves: [], current: [0.3, 0] },
|
|
73
|
+
});
|
|
74
|
+
// Scene entities supply 'launch' (a boat type) and 'person' (with a transform).
|
|
75
|
+
world.registerCommand('board', () => mountEntity(world, 'person', 'launch'));
|
|
76
|
+
world.registerCommand('helm', (_world, command) => driveBoat(world, 'person', command.payload));
|
|
77
|
+
world.registerCommand('alight', () => unmountEntity(world, 'person', {
|
|
78
|
+
groundHeight: (x, z) => dockHeightAt(x, z), // undefined where there is no dry exit
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Declare the commands normally. Helm payloads contain `throttle` and `steering` in [-1,1] and
|
|
84
|
+
`anchor: boolean`. A passenger cannot change the helm. `mountEntity(world, actor, boat, seatId)`
|
|
85
|
+
reserves an exclusive seat, and shared seat following carries the rider through the full hull
|
|
86
|
+
rotation. Optional `mountable.entries` allow boarding at a gangway far below a raised helm;
|
|
87
|
+
`exits` specify local deck-height foot positions. Passenger entry/exit preserves driver input.
|
|
88
|
+
|
|
89
|
+
`waterAt` returns `{ height, depth?, current? }`, `null` for dry ground, and `undefined` for
|
|
90
|
+
unloaded coverage. Surface height is the mean datum; the solver adds waves. Per-point current
|
|
91
|
+
replaces the global current. `canOccupy(position, yaw, spec, id)` adds collision checks against
|
|
92
|
+
docks, bridges and other boats. Without it, only water coverage and depth constrain motion.
|
|
93
|
+
`conditions` may instead come from a world's registered `water` component. `boat`, `boatInput`
|
|
94
|
+
and `boatState` are registered components, saved with seats and transforms in snapshots. Restore
|
|
95
|
+
the same environment and systems to replay. Ambient vessels keep their route solver until a host
|
|
96
|
+
explicitly turns one into a player vessel; the hull system skips `ambientAgent` entities.
|
|
97
|
+
|
|
98
|
+
`stepBoat`, `boatSupport`, `initialBoatState`, and `sampleWaves` are also public for custom hosts.
|
|
99
|
+
Only one motion solver should own a boat's transform; do not attach a car solver or rigid body too.
|
|
@@ -135,7 +135,7 @@ Two constants live in `packages/kernel/src/version.ts` and they do different job
|
|
|
135
135
|
|
|
136
136
|
| Constant | Today | Role |
|
|
137
137
|
|---|---|---|
|
|
138
|
-
| `ENGINE_VERSION` | `0.0.
|
|
138
|
+
| `ENGINE_VERSION` | `0.0.7` | metadata. Written into a keyframe's `engine` field so a save says which build wrote it. **Never compared on load, never hashed.** |
|
|
139
139
|
| `STATE_FORMAT` | `1` | the gate. Written into a keyframe under the reserved `plugins.$format` key, compared by `applyKeyframeTo`, and folded into `stateHash` as `stateFormat`. |
|
|
140
140
|
|
|
141
141
|
So a release — even one that moves every package — keeps your keyframes
|