@bendyline/molen-tooling 0.0.1
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/LICENSE +21 -0
- package/NOTICE.md +15 -0
- package/README.md +91 -0
- package/dist/capture/THIRD-PARTY-NOTICES.md +223 -0
- package/dist/capture/basis/LICENSE.txt +55 -0
- package/dist/capture/basis/basis_transcoder.js +19 -0
- package/dist/capture/basis/basis_transcoder.wasm +0 -0
- package/dist/capture/capture.html +15 -0
- package/dist/capture/harness.js +4671 -0
- package/dist/capture/worldgen-preview.html +15 -0
- package/dist/capture/worldgen-preview.js +4617 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +1276 -0
- package/dist/docs-src/guide/3d-art-guidelines.md +157 -0
- package/dist/docs-src/guide/3d-model-assets.md +286 -0
- package/dist/docs-src/guide/adaptive-performance.md +89 -0
- package/dist/docs-src/guide/agent-loop.md +156 -0
- package/dist/docs-src/guide/aircraft.md +225 -0
- package/dist/docs-src/guide/browser-mount.md +185 -0
- package/dist/docs-src/guide/building-interiors.md +175 -0
- package/dist/docs-src/guide/capability-authoring.md +69 -0
- package/dist/docs-src/guide/determinism.md +285 -0
- package/dist/docs-src/guide/entities.md +47 -0
- package/dist/docs-src/guide/examples.md +58 -0
- package/dist/docs-src/guide/experience-playback.md +57 -0
- package/dist/docs-src/guide/figures.md +164 -0
- package/dist/docs-src/guide/game-samples.md +100 -0
- package/dist/docs-src/guide/graphics-performance.md +167 -0
- package/dist/docs-src/guide/input.md +205 -0
- package/dist/docs-src/guide/materials.md +125 -0
- package/dist/docs-src/guide/project.md +157 -0
- package/dist/docs-src/guide/quickstart.md +63 -0
- package/dist/docs-src/guide/recognizable-places.md +158 -0
- package/dist/docs-src/guide/rendering-backends.md +231 -0
- package/dist/docs-src/guide/scripting.md +330 -0
- package/dist/docs-src/guide/sky.md +192 -0
- package/dist/docs-src/guide/source-bundles.md +42 -0
- package/dist/docs-src/guide/structure-library.md +114 -0
- package/dist/docs-src/guide/surface-rendering.md +203 -0
- package/dist/docs-src/guide/terrain.md +389 -0
- package/dist/docs-src/guide/three-surface.md +70 -0
- package/dist/docs-src/guide/vehicle-interiors.md +126 -0
- package/dist/docs-src/guide/vehicles.md +110 -0
- package/dist/docs-src/guide/weather.md +123 -0
- package/dist/docs-src/guide/worldgen.md +434 -0
- package/dist/docs-src/llms.txt +129 -0
- package/dist/docs-src/schemas/README.md +36 -0
- package/dist/docs-src/schemas/archstyle.md +2340 -0
- package/dist/docs-src/schemas/assert.md +169 -0
- package/dist/docs-src/schemas/asset.md +543 -0
- package/dist/docs-src/schemas/business-catalog.md +162 -0
- package/dist/docs-src/schemas/cameratrack.md +132 -0
- package/dist/docs-src/schemas/command.md +112 -0
- package/dist/docs-src/schemas/components.md +5826 -0
- package/dist/docs-src/schemas/delta.md +204 -0
- package/dist/docs-src/schemas/experience-play.md +452 -0
- package/dist/docs-src/schemas/figure.md +290 -0
- package/dist/docs-src/schemas/interior-catalog.md +230 -0
- package/dist/docs-src/schemas/keyframe.md +314 -0
- package/dist/docs-src/schemas/landmark-catalog.md +56 -0
- package/dist/docs-src/schemas/landmark.md +293 -0
- package/dist/docs-src/schemas/matgraph.md +1163 -0
- package/dist/docs-src/schemas/pack-index.md +82 -0
- package/dist/docs-src/schemas/pack-source.md +139 -0
- package/dist/docs-src/schemas/pack.md +225 -0
- package/dist/docs-src/schemas/pixelgrid.md +108 -0
- package/dist/docs-src/schemas/prefab.md +106 -0
- package/dist/docs-src/schemas/project.md +271 -0
- package/dist/docs-src/schemas/region-atlas.md +612 -0
- package/dist/docs-src/schemas/replay.md +807 -0
- package/dist/docs-src/schemas/scatter.md +541 -0
- package/dist/docs-src/schemas/scene.md +1152 -0
- package/dist/docs-src/schemas/source-bundle.md +266 -0
- package/dist/docs-src/schemas/stylepack.md +420 -0
- package/dist/docs-src/schemas/terrain-package.md +731 -0
- package/dist/docs-src/schemas/terrain.md +313 -0
- package/dist/docs-src/schemas/types.md +218 -0
- package/dist/docs-src/schemas/uvpaint.md +149 -0
- package/dist/docs-src/schemas/worldgen-batch.md +743 -0
- package/dist/index.d.mts +1271 -0
- package/dist/index.mjs +78 -0
- package/dist/mcp-BFnCWrg0.mjs +796 -0
- package/dist/ops-BGxhSP6w.mjs +7246 -0
- package/package.json +96 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Mountable vehicles and driving
|
|
2
|
+
|
|
3
|
+
For the P-51D Mustang and OH-6, see [Aircraft](aircraft.md). They share the mount/seat
|
|
4
|
+
foundation and add separate flight controls, physics, assets and cockpit cameras.
|
|
5
|
+
|
|
6
|
+
World explorer's parking cars are external entity types with stable IDs, metric dimensions, and five
|
|
7
|
+
models: compact, sedan, SUV, pickup and van. Each type owns its GLB reference, complete physics
|
|
8
|
+
configuration, seats, named visual bindings, and optional deterministic scripts. Dormant cars use
|
|
9
|
+
generic dimension-driven instance proxies; approaching or entering one loads its independent GLB
|
|
10
|
+
with its own interior and controls. See [Vehicle interiors](vehicle-interiors.md).
|
|
11
|
+
No concrete car model or handling catalog is compiled into schema,
|
|
12
|
+
kernel, or client.
|
|
13
|
+
|
|
14
|
+
In **Walk mode**, approach a car and press **E** to enter its driver seat. **W/S** accelerate or
|
|
15
|
+
brake then reverse; **A/D** steer; **Space** brakes; **V** switches cockpit/chase views. Mouse look
|
|
16
|
+
works while seated. Stop and press **E** to exit. The controller checks both sides and then the rear;
|
|
17
|
+
blocked exits leave the rider seated. Switching to Fly also requires a safe stopped exit.
|
|
18
|
+
|
|
19
|
+
Modified cars stay where they were left throughout the current explorer session, even when their
|
|
20
|
+
original terrain tiles are evicted or rebuilt. Unmodified cars stream with their tiles. A page reload
|
|
21
|
+
starts a fresh session. Rendering uses absolute metric transforms under the floating-origin root.
|
|
22
|
+
|
|
23
|
+
## Reusable simulation
|
|
24
|
+
|
|
25
|
+
Import from `@bendyline/molen-kernel/vehicles`. `Vehicle`, `VehicleInput`, `VehicleState`,
|
|
26
|
+
`Mountable`, and `Mounted` are registered, validated components. The kernel owns the generic
|
|
27
|
+
wheeled-vehicle solver; every `vehicle` component supplies its own `spec` and `visual` data. Units
|
|
28
|
+
are meters and seconds; +Y is up, +Z forward, and +X is the driver's left side. Positive steering
|
|
29
|
+
turns right.
|
|
30
|
+
|
|
31
|
+
The car itself is data. List the `molen.entities` content pack in `project.json` `packs` and
|
|
32
|
+
declare it in the scene as `{ "id": "car", "type": "molen.entities.vehicle.sedan", ... }`; the
|
|
33
|
+
type supplies its `vehicle`, `mountable` and renderable components. The setup adds the player and
|
|
34
|
+
the commands:
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
import {
|
|
38
|
+
installVehicles, mountEntity, driveVehicle, unmountEntity,
|
|
39
|
+
} from '@bendyline/molen-kernel/vehicles';
|
|
40
|
+
|
|
41
|
+
export function setup(world) {
|
|
42
|
+
const environment = {
|
|
43
|
+
groundHeight: (x, z) => 0,
|
|
44
|
+
// Return undefined where terrain is unavailable.
|
|
45
|
+
// Add canOccupy(position, yaw, spec, entity) for static/dynamic collisions.
|
|
46
|
+
// Add canExit(position, actor, vehicle) for safe person-sized exits.
|
|
47
|
+
};
|
|
48
|
+
installVehicles(world, environment);
|
|
49
|
+
world.spawnRaw({ transform: { pos: [1.6, 0, 0], rot: [0, 0, 0, 1] } }, 'player');
|
|
50
|
+
world.registerCommand('enter', () => mountEntity(world, 'player', 'car'));
|
|
51
|
+
world.registerCommand('drive', (_w, command) =>
|
|
52
|
+
driveVehicle(world, 'player', command.payload));
|
|
53
|
+
world.registerCommand('exit', () => unmountEntity(world, 'player', environment));
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Outside a scene, resolve a type's components from the pack's type documents with
|
|
58
|
+
`createTypeLibrary(docs).components('molen.entities.vehicle.sedan')` from
|
|
59
|
+
`@bendyline/molen-kernel/content`, and spawn a copy.
|
|
60
|
+
|
|
61
|
+
Declare commands and input bindings in the scene using the normal input schema. Give `drive`
|
|
62
|
+
a payload schema with `throttle` and `steering` numbers in [-1,1] and a boolean `brake`.
|
|
63
|
+
Run this setup through `buildWorld`, the Worker, or `molen sim run --setup`.
|
|
64
|
+
|
|
65
|
+
`mountable.seats` is reusable for passenger seats or non-car mounts. Each seat has a unique
|
|
66
|
+
`id`, a `driver` or `passenger` role, and a local camera/rider anchor `position`. `exits` are
|
|
67
|
+
ordered local foot positions; `reach` limits mounting distance. A seat accepts one rider, and
|
|
68
|
+
only the current driver can submit vehicle intent. Mounted actors bypass the kernel character
|
|
69
|
+
and kinematics solvers. When the mount disappears, the rider is detached.
|
|
70
|
+
|
|
71
|
+
The fixed-step bicycle solver integrates signed speed, steering slew, wheel rotation, mass-scaled
|
|
72
|
+
engine force, rolling/air resistance, braking, reverse limits, lateral grip, gravity and four-wheel
|
|
73
|
+
terrain support. All chassis-specific coefficients, mass/center of gravity, wheel geometry, limits,
|
|
74
|
+
and terrain tolerances come from `vehicle.spec`. Collision probes run at 120 Hz or finer (through
|
|
75
|
+
the host's `canOccupy` adapter).
|
|
76
|
+
World explorer uses an oriented chassis against other cars and nearby triangles for walls,
|
|
77
|
+
fixtures and buildings. Terrain gaps pause motion; abrupt steps and slopes above 35 degrees stop
|
|
78
|
+
the car. Cockpit views use the full chassis quaternion; chase views shorten at obstructions.
|
|
79
|
+
|
|
80
|
+
This is a grounded driving foundation. It does not implement rigid-body rollovers, crash deformation,
|
|
81
|
+
traffic AI, passenger animation, multiplayer ownership, or disk persistence. Without collision hooks,
|
|
82
|
+
the reusable kernel solver supplies terrain driving only. Do not attach a second physics body to the
|
|
83
|
+
same vehicle; the vehicle solver owns its transform.
|
|
84
|
+
|
|
85
|
+
All durable simulation state and mount relationships live in ECS components and survive keyframes
|
|
86
|
+
and replay. Install the same systems/environment when restoring. Host streaming and render resources
|
|
87
|
+
are separate from those checkpoints.
|
|
88
|
+
|
|
89
|
+
## Reusable views and parking data
|
|
90
|
+
|
|
91
|
+
`@bendyline/molen-client/vehicles` exports `createVehicleVisual`, `createParkedVehicleBatch`,
|
|
92
|
+
and `vehicleCameraPose`. `createVehicleVisual(loadedGlb, vehicleData)` binds wheel, steering, and
|
|
93
|
+
paint nodes named by `vehicle.visual`; dynamic visuals expose `update(steer, wheelAngle)` and
|
|
94
|
+
`dispose()`. The camera helper accepts a transform, `vehicle.spec`, view, look offsets, and an
|
|
95
|
+
optional obstruction-distance callback.
|
|
96
|
+
|
|
97
|
+
Surface objects expose `userData.vehicles: VehiclePlacement[]`; each record has an `id`, external
|
|
98
|
+
type `kind`, `color`, resolved `spec`, absolute metric `position`, and `yaw`, with optional
|
|
99
|
+
terrain-alignment `pitch` and `roll`. IDs derive from world-space bay positions rather
|
|
100
|
+
than tile IDs. Instance meshes retain `userData.vehicleIds` for promotion and duplicate suppression.
|
|
101
|
+
The worker transports the same placement records as synchronous generation.
|
|
102
|
+
|
|
103
|
+
For repeatable visual review use `?synthetic=1&parking=1`. The browser scenario
|
|
104
|
+
`examples/world-explorer/test/visual/vehicles.play.json` visits a car, enters the cockpit,
|
|
105
|
+
drives, turns in chase view, brakes, and exits:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
pnpm --filter @bendyline/molen-examples-world-explorer build
|
|
109
|
+
node packages/tooling/dist/cli.mjs play examples/world-explorer/dist --scenario examples/world-explorer/test/visual/vehicles.play.json --out-dir .artifacts/vehicles
|
|
110
|
+
```
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Weather and physical atmosphere
|
|
2
|
+
|
|
3
|
+
The singleton `weather` component describes atmospheric conditions independently of the
|
|
4
|
+
`environment` component's Earth or authored sky. Clouds, precipitation and visibility are
|
|
5
|
+
separate axes. Overcast need not rain; temperature never silently selects rain versus snow.
|
|
6
|
+
There is no forecast service, browser geolocation request, or implicit host clock.
|
|
7
|
+
|
|
8
|
+
Add this entity to a `molen/scene@3` manifest:
|
|
9
|
+
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"id": "conditions",
|
|
13
|
+
"components": {
|
|
14
|
+
"weather": {
|
|
15
|
+
"atmosphere": {
|
|
16
|
+
"temperatureK": 282.15,
|
|
17
|
+
"pressurePa": 100200,
|
|
18
|
+
"relativeHumidity": 0.95,
|
|
19
|
+
"windVelocity": [7, 0, 3],
|
|
20
|
+
"referenceAltitude": 0,
|
|
21
|
+
"gasConstant": 287.05
|
|
22
|
+
},
|
|
23
|
+
"clouds": { "coverage": 0.98, "density": 0.95, "baseAltitude": 1600, "thickness": 1200, "scale": 16000 },
|
|
24
|
+
"precipitation": { "kind": "rain", "intensity": 0.7 },
|
|
25
|
+
"visibility": 4500,
|
|
26
|
+
"seed": 1
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
One weather entity is supported: the first entity carrying the component wins. Changes,
|
|
33
|
+
component removal and keyframe replacement propagate through the snapshot/delta path.
|
|
34
|
+
Weather participates in state hashes, checkpoints and replays.
|
|
35
|
+
|
|
36
|
+
## Units and profiles
|
|
37
|
+
|
|
38
|
+
`WeatherData`, `weatherSchema`, `resolveWeather`, `WeatherProfile` and `weatherProfile` are
|
|
39
|
+
exported by `@bendyline/molen-schema`. The client re-exports the types, resolver and presets.
|
|
40
|
+
`weatherProfile('sunny' | 'partly-cloudy' | 'overcast' | 'rain' | 'snow' | 'fog')` returns fresh
|
|
41
|
+
editable data. `resolveWeather(data)` supplies defaults and copies nested values. Validate
|
|
42
|
+
external data with `weatherSchema.parse` before using it in typed code.
|
|
43
|
+
|
|
44
|
+
| Parameter | Meaning |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `atmosphere.temperatureK` | Kelvin at the reference altitude; default 288.15 K (15 °C). |
|
|
47
|
+
| `atmosphere.pressurePa` | Absolute pressure at the reference altitude; default 101325 Pa. Zero allows vacuum. |
|
|
48
|
+
| `atmosphere.relativeHumidity` | 0–1; stored for consumers, independent of precipitation. |
|
|
49
|
+
| `atmosphere.windVelocity` | World XYZ velocity in m/s; +X east and -Z north in Earth worlds. A velocity toward a direction, not a meteorological "from" bearing. |
|
|
50
|
+
| `atmosphere.referenceAltitude` | Absolute world Y where temperature/pressure apply, default 0 m. |
|
|
51
|
+
| `atmosphere.gasConstant` | Specific gas constant, default 287.05 J/(kg·K) for dry air; configurable for other worlds. |
|
|
52
|
+
| `clouds.coverage`, `density` | Independent 0–1 coverage and optical density controls. |
|
|
53
|
+
| `clouds.baseAltitude`, `thickness`, `scale` | Absolute base Y, layer separation, and horizontal pattern repeat size in meters. |
|
|
54
|
+
| `precipitation.kind`, `intensity` | Explicit none/rain/snow and 0–1 visual intensity; not calibrated mm/hour. |
|
|
55
|
+
| `visibility` | Approximate visual fade distance in meters, independent of clouds and precipitation. |
|
|
56
|
+
|
|
57
|
+
Presets are starting points, not classifications that constrain these independent parameters.
|
|
58
|
+
|
|
59
|
+
## Simulation and physics
|
|
60
|
+
|
|
61
|
+
Scripts read and update the ordinary component:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
const current = molen.get('conditions', 'weather');
|
|
65
|
+
if (current) molen.patch('conditions', 'weather', {
|
|
66
|
+
atmosphere: { ...current.atmosphere, temperatureK: 271.15 }
|
|
67
|
+
});
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Typed systems use `Weather`, `weatherOf(world)` and `sampleAtmosphere(data, altitude, gravity?)`
|
|
71
|
+
from `@bendyline/molen-kernel`. The sample contains `temperatureK`, `pressurePa`, `densityKgM3`,
|
|
72
|
+
`relativeHumidity` and `windVelocity`. It uses deterministic math, ideal-gas density
|
|
73
|
+
`pressure / (gasConstant * temperature)` and an isothermal hydrostatic pressure profile.
|
|
74
|
+
Gravity defaults to 9.80665 m/s². Humidity is informational: there is no moist-air correction,
|
|
75
|
+
temperature lapse rate or fluid simulation.
|
|
76
|
+
|
|
77
|
+
`installAircraft` reads the world's weather each physics tick. Wind changes airspeed, and
|
|
78
|
+
temperature/pressure change aerodynamic density. Explicit `AircraftEnvironment.weather`
|
|
79
|
+
overrides the component; explicit `wind` overrides its wind. `stepAircraft` accepts the same
|
|
80
|
+
optional weather value. Without weather, aircraft retain their existing altitude-density
|
|
81
|
+
model exactly. Ground friction and character temperature exposure are not implicitly changed.
|
|
82
|
+
|
|
83
|
+
## Rendering and clocks
|
|
84
|
+
|
|
85
|
+
The normal client mirrors weather automatically. Standalone hosts can call:
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
import { weatherProfile } from '@bendyline/molen-client';
|
|
89
|
+
viewer.renderer.setWeather(weatherProfile('partly-cloudy'));
|
|
90
|
+
viewer.renderer.setWeatherTimeOverride(20); // absolute preview seconds
|
|
91
|
+
viewer.renderer.setWeatherTimeOverride(undefined); // resume simulation time
|
|
92
|
+
viewer.renderer.setWeather(undefined); // remove weather effects
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Clouds use two wind-advected procedural layers at absolute world altitudes. They occlude
|
|
96
|
+
celestial bodies, tint through dusk/night, and reduce direct lighting. Rain and snow share a
|
|
97
|
+
bounded camera-local particle batch with wind drift. Seed/time sampling is deterministic;
|
|
98
|
+
floating-origin changes preserve world alignment. No simulation random numbers are consumed.
|
|
99
|
+
|
|
100
|
+
Standard materials work on WebGL and WebGPU, with up to two cloud draws and one precipitation
|
|
101
|
+
draw. Textures generate locally when needed; sunny startup generates no cloud noise and
|
|
102
|
+
allocates no particle batch. Animation follows simulation time independently of a sky-time
|
|
103
|
+
preview override, so pauses and captures remain repeatable.
|
|
104
|
+
|
|
105
|
+
Weather visibility temporarily limits scene fog; a nearer authored terrain fog limit and its
|
|
106
|
+
clear foreground are preserved when weather visibility reaches beyond that limit. Removing
|
|
107
|
+
weather restores the authored fog and lighting. Clouds are layered
|
|
108
|
+
surfaces, not ray-marched 3D volumes: flying through a layer does not simulate condensation.
|
|
109
|
+
Precipitation is a local visual field, including above cloud layers, without roof/terrain
|
|
110
|
+
collision, splash, accumulation or wet-material response.
|
|
111
|
+
|
|
112
|
+
## World explorer
|
|
113
|
+
|
|
114
|
+
The Weather dropdown includes Sunny / clear, Partly cloudy, Overcast, Rain, Snow and Fog.
|
|
115
|
+
Weather details mixes cloud coverage/density/altitude, precipitation, intensity, visibility,
|
|
116
|
+
temperature, pressure and wind, marking the profile Custom. Temperature and pressure controls
|
|
117
|
+
refer to sea level, displayed in °C and hPa and stored in kelvin and pascals. The same component
|
|
118
|
+
is installed in the explorer's vehicle/aircraft simulation.
|
|
119
|
+
|
|
120
|
+
Use `?weather=rain` or another preset id. Custom edits are session-local. `?freeze=1` freezes
|
|
121
|
+
weather motion for comparisons. The day slider changes lighting without moving the camera
|
|
122
|
+
or seeking precipitation animation. The legacy `?sky=daylight` path stays weather-free unless
|
|
123
|
+
a weather profile is explicitly requested.
|