@bendyline/molen-ambient 0.0.3
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/README.md +102 -0
- package/dist/client.d.mts +170 -0
- package/dist/client.mjs +922 -0
- package/dist/components-CupqU6fR.mjs +673 -0
- package/dist/kernel.d.mts +887 -0
- package/dist/kernel.mjs +3804 -0
- package/package.json +78 -0
|
@@ -0,0 +1,887 @@
|
|
|
1
|
+
import { Quat } from "@bendyline/molen-kernel/determinism";
|
|
2
|
+
import { ComponentType, JsonObject, World } from "@bendyline/molen-kernel/world";
|
|
3
|
+
import { ComponentMap, EntityId, SceneManifest } from "@bendyline/molen-schema";
|
|
4
|
+
import { TerrainLinePath, TerrainPoiFeature, TerrainTransportationFeature } from "@bendyline/molen-terrain/kernel";
|
|
5
|
+
|
|
6
|
+
//#region src/kernel/components.d.ts
|
|
7
|
+
/** An ambient NPC class. */
|
|
8
|
+
type AmbientKind = "car" | "pedestrian" | "train" | "aircraft";
|
|
9
|
+
declare const AMBIENT_KINDS: readonly AmbientKind[];
|
|
10
|
+
/** An aircraft corridor: a straight line flown at linearly varying altitude. */
|
|
11
|
+
interface AmbientAirCorridor extends JsonObject {
|
|
12
|
+
x: number;
|
|
13
|
+
z: number;
|
|
14
|
+
dx: number;
|
|
15
|
+
dz: number;
|
|
16
|
+
y0: number;
|
|
17
|
+
y1: number;
|
|
18
|
+
length: number;
|
|
19
|
+
}
|
|
20
|
+
interface AmbientAgentData extends JsonObject {
|
|
21
|
+
kind: AmbientKind;
|
|
22
|
+
type: string;
|
|
23
|
+
color?: string;
|
|
24
|
+
lane: string;
|
|
25
|
+
s: number;
|
|
26
|
+
speed: number;
|
|
27
|
+
prev?: string;
|
|
28
|
+
next?: string;
|
|
29
|
+
seed: number;
|
|
30
|
+
length: number;
|
|
31
|
+
width: number;
|
|
32
|
+
state: "move" | "wait" | "dwell" | "idle";
|
|
33
|
+
since: number;
|
|
34
|
+
hops: number;
|
|
35
|
+
hidden?: boolean;
|
|
36
|
+
consist?: string;
|
|
37
|
+
carIndex?: number;
|
|
38
|
+
trail?: string[];
|
|
39
|
+
served?: string;
|
|
40
|
+
air?: AmbientAirCorridor;
|
|
41
|
+
spawnedTick: number;
|
|
42
|
+
}
|
|
43
|
+
interface AmbientObserverData extends JsonObject {
|
|
44
|
+
radius?: number;
|
|
45
|
+
despawnRadius?: number;
|
|
46
|
+
density?: number;
|
|
47
|
+
}
|
|
48
|
+
interface AmbientRoleVisual extends JsonObject {
|
|
49
|
+
wheelNodes?: string[];
|
|
50
|
+
frontWheelNodes?: string[];
|
|
51
|
+
paintMaterial?: string;
|
|
52
|
+
wheelRadius?: number;
|
|
53
|
+
wheelbase?: number;
|
|
54
|
+
rotors?: string[];
|
|
55
|
+
gearNodes?: string[];
|
|
56
|
+
}
|
|
57
|
+
interface AmbientRoleData extends JsonObject {
|
|
58
|
+
role: "car" | "bus" | "rail" | "aircraft";
|
|
59
|
+
length?: number;
|
|
60
|
+
width?: number;
|
|
61
|
+
height?: number;
|
|
62
|
+
cruise?: number;
|
|
63
|
+
max?: number;
|
|
64
|
+
weight?: number;
|
|
65
|
+
cars?: number;
|
|
66
|
+
colors?: string[];
|
|
67
|
+
visual?: AmbientRoleVisual;
|
|
68
|
+
}
|
|
69
|
+
interface AmbientObserverState extends JsonObject {
|
|
70
|
+
pos?: [number, number, number];
|
|
71
|
+
forward?: [number, number];
|
|
72
|
+
entity?: string;
|
|
73
|
+
setAtTick: number;
|
|
74
|
+
}
|
|
75
|
+
interface AmbientStateData extends JsonObject {
|
|
76
|
+
observer?: AmbientObserverState;
|
|
77
|
+
nextSeq: number;
|
|
78
|
+
spawned: number;
|
|
79
|
+
despawned: number;
|
|
80
|
+
policy?: JsonObject;
|
|
81
|
+
}
|
|
82
|
+
declare const AmbientAgent: ComponentType<AmbientAgentData>;
|
|
83
|
+
declare const AmbientObserver: ComponentType<AmbientObserverData>;
|
|
84
|
+
declare const AmbientRole: ComponentType<AmbientRoleData>;
|
|
85
|
+
declare const AmbientState: ComponentType<AmbientStateData>;
|
|
86
|
+
/** The singleton entity holding ambient bookkeeping. */
|
|
87
|
+
declare const AMBIENT_ENTITY: "$ambient";
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/kernel/spawn/policy.d.ts
|
|
90
|
+
interface AmbientClassPolicy {
|
|
91
|
+
enabled: boolean;
|
|
92
|
+
/** Never spawn closer than this (metres). */
|
|
93
|
+
near: number;
|
|
94
|
+
/** Spawn out to this distance (metres). */
|
|
95
|
+
far: number;
|
|
96
|
+
/** Remove beyond this distance (metres). */
|
|
97
|
+
keep: number;
|
|
98
|
+
/** Target agents per kilometre of lane within `far`. */
|
|
99
|
+
perLaneKm: number;
|
|
100
|
+
/** Hard cap on live agents of the class (consists for trains). */
|
|
101
|
+
max: number;
|
|
102
|
+
}
|
|
103
|
+
interface DriverParams {
|
|
104
|
+
/** Maximum acceleration (m/s²). */
|
|
105
|
+
accel: number;
|
|
106
|
+
/** Comfortable braking (m/s²). */
|
|
107
|
+
brake: number;
|
|
108
|
+
/** Minimum standstill gap (m). */
|
|
109
|
+
gap: number;
|
|
110
|
+
/** Time headway (s). */
|
|
111
|
+
headway: number;
|
|
112
|
+
}
|
|
113
|
+
interface AmbientPolicy {
|
|
114
|
+
/** Run the spawner every N ticks. */
|
|
115
|
+
spawnEveryTicks: number;
|
|
116
|
+
/** Spawns per spawner run, across classes. */
|
|
117
|
+
spawnBudget: number;
|
|
118
|
+
/** Cosine of the half-angle of the view cone spawns avoid near the observer. */
|
|
119
|
+
forwardConeCos: number;
|
|
120
|
+
/** How far ahead (m) the view cone stays free of spawns; beyond it agents fade in. */
|
|
121
|
+
forwardConeReach: number;
|
|
122
|
+
/** Seconds a stuck agent waits before it is removed (out of sight only). */
|
|
123
|
+
stuckSeconds: number;
|
|
124
|
+
/** Seconds after which a junction deadlock is broken. */
|
|
125
|
+
deadlockSeconds: number;
|
|
126
|
+
car: AmbientClassPolicy;
|
|
127
|
+
pedestrian: AmbientClassPolicy;
|
|
128
|
+
train: AmbientClassPolicy;
|
|
129
|
+
aircraft: AmbientClassPolicy;
|
|
130
|
+
driver: DriverParams;
|
|
131
|
+
rail: DriverParams;
|
|
132
|
+
}
|
|
133
|
+
declare const DEFAULT_POLICY: AmbientPolicy;
|
|
134
|
+
type DeepPartial<T> = { [K in keyof T]?: T[K] extends object ? DeepPartial<T[K]> : T[K] };
|
|
135
|
+
/** Merge overrides into a policy (plain objects merge; other values replace). */
|
|
136
|
+
declare function mergePolicy(base: AmbientPolicy, ...overrides: (DeepPartial<AmbientPolicy> | JsonObject | undefined)[]): AmbientPolicy;
|
|
137
|
+
/** Scale the rings and caps for a density factor and caps from a host budget. */
|
|
138
|
+
interface AmbientBudget {
|
|
139
|
+
cars?: number;
|
|
140
|
+
pedestrians?: number;
|
|
141
|
+
trains?: number;
|
|
142
|
+
aircraft?: number;
|
|
143
|
+
/** Outer spawn radius for cars; trains keep their ratio to it. */
|
|
144
|
+
radius?: number;
|
|
145
|
+
/** Outer spawn radius for pedestrians. */
|
|
146
|
+
pedestrianRadius?: number;
|
|
147
|
+
}
|
|
148
|
+
/** A policy with a host budget's caps and ring sizes applied. */
|
|
149
|
+
declare function policyForBudget(policy: AmbientPolicy, budget: AmbientBudget): AmbientPolicy;
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/kernel/agents/idm.d.ts
|
|
152
|
+
/**
|
|
153
|
+
* IDM acceleration. `gap` is the bumper-to-bumper distance to the leader (Infinity when free),
|
|
154
|
+
* `dv` the closing speed (own speed minus the leader's).
|
|
155
|
+
*/
|
|
156
|
+
declare function idmAcceleration(v: number, v0: number, gap: number, dv: number, p: DriverParams): number;
|
|
157
|
+
/** Distance needed to stop from speed `v` at deceleration `b`. */
|
|
158
|
+
declare function stoppingDistance(v: number, b: number): number;
|
|
159
|
+
//#endregion
|
|
160
|
+
//#region src/kernel/graph/types.d.ts
|
|
161
|
+
/** Which agents a lane serves. */
|
|
162
|
+
type TransportClass = "road" | "rail" | "walk" | "air";
|
|
163
|
+
/** Finer classification used for speeds, spawn preferences and routing weights. */
|
|
164
|
+
type RoadKind = "motorway" | "trunk" | "primary" | "secondary" | "tertiary" | "street" | "living" | "service" | "path" | "crossing" | "rail" | "tram";
|
|
165
|
+
type TurnKind = "straight" | "left" | "right" | "uturn" | "merge";
|
|
166
|
+
/** An endpoint or split point shared by edges. */
|
|
167
|
+
interface TransportNode {
|
|
168
|
+
readonly id: string;
|
|
169
|
+
readonly x: number;
|
|
170
|
+
readonly z: number;
|
|
171
|
+
readonly layer: number;
|
|
172
|
+
readonly class: TransportClass;
|
|
173
|
+
/** Incident edge ids (both directions). */
|
|
174
|
+
readonly edges: string[];
|
|
175
|
+
/** Owning tile key (`'*'` for documents and polylines). */
|
|
176
|
+
readonly tile: string;
|
|
177
|
+
/** True when the node lies on its tile's boundary (a stitching candidate). */
|
|
178
|
+
readonly border: boolean;
|
|
179
|
+
/** The node in a neighbouring tile this border node is stitched to, if any. */
|
|
180
|
+
link?: string;
|
|
181
|
+
}
|
|
182
|
+
/** A polyline between two nodes. Lanes run along it in either direction. */
|
|
183
|
+
interface TransportEdge {
|
|
184
|
+
readonly id: string;
|
|
185
|
+
readonly tile: string;
|
|
186
|
+
readonly class: TransportClass;
|
|
187
|
+
readonly kind: RoadKind;
|
|
188
|
+
readonly from: string;
|
|
189
|
+
readonly to: string;
|
|
190
|
+
/** World metres, [x, z] per vertex, with cumulative distances. */
|
|
191
|
+
readonly path: TerrainLinePath;
|
|
192
|
+
/** Surface height per path vertex (same indexing as `path.points`). */
|
|
193
|
+
readonly ys: Float64Array;
|
|
194
|
+
readonly width: number;
|
|
195
|
+
/** Design speed in m/s before per-agent variation. */
|
|
196
|
+
readonly speed: number;
|
|
197
|
+
readonly layer: number;
|
|
198
|
+
readonly bridge: boolean;
|
|
199
|
+
readonly tunnel: boolean;
|
|
200
|
+
readonly link: boolean;
|
|
201
|
+
readonly oneway: boolean;
|
|
202
|
+
readonly lanes: string[];
|
|
203
|
+
/** Source feature name, when mapped. */
|
|
204
|
+
readonly name?: string;
|
|
205
|
+
}
|
|
206
|
+
/** A directed lane. `s` runs from 0 at the lane start to `length` at its end. */
|
|
207
|
+
interface TransportLane {
|
|
208
|
+
readonly id: string;
|
|
209
|
+
readonly edge: string;
|
|
210
|
+
readonly class: TransportClass;
|
|
211
|
+
/** 1 travels the edge path forward (from → to), -1 backward. */
|
|
212
|
+
readonly dir: 1 | -1;
|
|
213
|
+
/** 0 = innermost (nearest the centreline for two-way roads, leftmost for one-way). */
|
|
214
|
+
readonly index: number;
|
|
215
|
+
/** Signed lateral offset from the centreline, positive to the right of travel. */
|
|
216
|
+
readonly offset: number;
|
|
217
|
+
/** Edge-path distance trimmed from the start and end (junction cores). */
|
|
218
|
+
trimStart: number;
|
|
219
|
+
trimEnd: number;
|
|
220
|
+
length: number;
|
|
221
|
+
/** Surface lift above the edge's baked heights (sidewalks sit on the kerb). */
|
|
222
|
+
readonly lift: number;
|
|
223
|
+
/** Node the lane starts from and ends at. */
|
|
224
|
+
readonly start: string;
|
|
225
|
+
readonly end: string;
|
|
226
|
+
/** Outgoing movements at the lane end. */
|
|
227
|
+
next: LaneMovement[];
|
|
228
|
+
/** Stop points along the lane: stations, stops, crossings. */
|
|
229
|
+
stops: LaneStop[];
|
|
230
|
+
}
|
|
231
|
+
interface LaneStop {
|
|
232
|
+
/** Edge-path distance of the stop (convert with `laneCoordinate`). */
|
|
233
|
+
readonly d: number;
|
|
234
|
+
readonly kind: "station" | "bus" | "crossing" | "level-crossing";
|
|
235
|
+
/** Station/crossing id, used to remember a served stop. */
|
|
236
|
+
readonly id: string;
|
|
237
|
+
/** Stations: dwell time in seconds (default: a seeded 20–40 s). */
|
|
238
|
+
readonly dwell?: number;
|
|
239
|
+
}
|
|
240
|
+
/** A way from the end of one lane onto the start of another, through a connector curve. */
|
|
241
|
+
interface LaneMovement {
|
|
242
|
+
readonly to: string;
|
|
243
|
+
readonly turn: TurnKind;
|
|
244
|
+
/** Junction whose core this movement crosses (absent at plain through nodes). */
|
|
245
|
+
readonly junction?: string;
|
|
246
|
+
/** Arm-pair key `inArm * armCount + outArm` within the junction. */
|
|
247
|
+
readonly key: number;
|
|
248
|
+
readonly weight: number;
|
|
249
|
+
/** Connector: quadratic Bezier from the lane end, via a control point, to the next lane start. */
|
|
250
|
+
readonly p0: readonly [number, number, number];
|
|
251
|
+
readonly p1: readonly [number, number, number];
|
|
252
|
+
readonly p2: readonly [number, number, number];
|
|
253
|
+
readonly length: number;
|
|
254
|
+
/** Walk movements: the road arms (by index) whose carriageway this connector crosses. */
|
|
255
|
+
readonly crosses?: readonly number[];
|
|
256
|
+
}
|
|
257
|
+
type JunctionControl = "none" | "yield" | "signal";
|
|
258
|
+
interface JunctionArm {
|
|
259
|
+
readonly edge: string;
|
|
260
|
+
readonly node: string;
|
|
261
|
+
/** Unit direction pointing away from the junction along the edge. */
|
|
262
|
+
readonly dx: number;
|
|
263
|
+
readonly dz: number;
|
|
264
|
+
readonly width: number;
|
|
265
|
+
readonly kind: RoadKind;
|
|
266
|
+
readonly link: boolean;
|
|
267
|
+
/** Signal phase group this arm belongs to. */
|
|
268
|
+
group: number;
|
|
269
|
+
/** A stop or yield sign on this arm: its traffic gives way. */
|
|
270
|
+
yields?: boolean;
|
|
271
|
+
}
|
|
272
|
+
interface TransportJunction {
|
|
273
|
+
readonly id: string;
|
|
274
|
+
readonly x: number;
|
|
275
|
+
readonly z: number;
|
|
276
|
+
readonly nodes: readonly string[];
|
|
277
|
+
readonly arms: readonly JunctionArm[];
|
|
278
|
+
control: JunctionControl;
|
|
279
|
+
/** Core radius in metres (lanes are trimmed this far back). */
|
|
280
|
+
readonly radius: number;
|
|
281
|
+
/** conflicts[a * n² + b] for arm-pair keys a and b. */
|
|
282
|
+
readonly conflicts: Uint8Array;
|
|
283
|
+
/** Number of signal phase groups (≥ 2 when signalised). */
|
|
284
|
+
readonly groups: number;
|
|
285
|
+
}
|
|
286
|
+
/** A lane-level sample: position, surface height and travel direction. */
|
|
287
|
+
interface LaneSample {
|
|
288
|
+
x: number;
|
|
289
|
+
y: number;
|
|
290
|
+
z: number;
|
|
291
|
+
/** Unit horizontal travel direction. */
|
|
292
|
+
dx: number;
|
|
293
|
+
dz: number;
|
|
294
|
+
/** Grade (rise per metre travelled). */
|
|
295
|
+
grade: number;
|
|
296
|
+
}
|
|
297
|
+
/** A mapped runway, kept for aircraft approach corridors. */
|
|
298
|
+
interface TransportRunway {
|
|
299
|
+
readonly tile: string;
|
|
300
|
+
readonly ax: number;
|
|
301
|
+
readonly az: number;
|
|
302
|
+
readonly bx: number;
|
|
303
|
+
readonly bz: number;
|
|
304
|
+
readonly y: number;
|
|
305
|
+
}
|
|
306
|
+
/** A point where a mapped footway crossing or a railway crosses a road edge. */
|
|
307
|
+
interface TransportCrossing {
|
|
308
|
+
readonly id: string;
|
|
309
|
+
readonly tile: string;
|
|
310
|
+
readonly kind: "crossing" | "level-crossing";
|
|
311
|
+
readonly road: string;
|
|
312
|
+
/** Distance along the road edge's path. */
|
|
313
|
+
readonly roadS: number;
|
|
314
|
+
/** The crossing edge (walk crossing or rail) and the distance along it. */
|
|
315
|
+
readonly other: string;
|
|
316
|
+
readonly otherS: number;
|
|
317
|
+
}
|
|
318
|
+
//#endregion
|
|
319
|
+
//#region src/kernel/agents/signals.d.ts
|
|
320
|
+
type SignalColor = "green" | "amber" | "red";
|
|
321
|
+
interface SignalTiming {
|
|
322
|
+
cycleTicks: number;
|
|
323
|
+
offsetTicks: number;
|
|
324
|
+
greenTicks: number[];
|
|
325
|
+
}
|
|
326
|
+
/** Timing for a signalised junction: 18–30 s green per phase group, seeded by the junction id. */
|
|
327
|
+
declare function signalTiming(junction: TransportJunction, tickRate: number): SignalTiming;
|
|
328
|
+
/** The colour shown to arms of phase group `group` at `tick`. */
|
|
329
|
+
declare function signalColor(junction: TransportJunction, group: number, tick: number, tickRate: number, timing?: SignalTiming): SignalColor;
|
|
330
|
+
/** Whether every group is red at `tick` (the all-red clearance interval). */
|
|
331
|
+
declare function allRed(junction: TransportJunction, tick: number, tickRate: number, timing?: SignalTiming): boolean;
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/kernel/graph/drafts.d.ts
|
|
334
|
+
type Point2 = [number, number];
|
|
335
|
+
/** A polyline awaiting the planar split, in world metres. */
|
|
336
|
+
interface EdgeDraft {
|
|
337
|
+
class: TransportClass;
|
|
338
|
+
kind: RoadKind;
|
|
339
|
+
points: Point2[];
|
|
340
|
+
/** Absolute surface heights per point (documents); otherwise baked from the ground sampler. */
|
|
341
|
+
heights?: number[];
|
|
342
|
+
width: number;
|
|
343
|
+
/** Total lanes across both directions (road), ignored for other classes. */
|
|
344
|
+
lanes: number;
|
|
345
|
+
oneway: boolean;
|
|
346
|
+
layer: number;
|
|
347
|
+
bridge: boolean;
|
|
348
|
+
tunnel: boolean;
|
|
349
|
+
link: boolean;
|
|
350
|
+
speed?: number;
|
|
351
|
+
name?: string;
|
|
352
|
+
deckElevation?: number;
|
|
353
|
+
bridgeConnections?: {
|
|
354
|
+
point: Point2;
|
|
355
|
+
elevation: number;
|
|
356
|
+
radius: number;
|
|
357
|
+
}[];
|
|
358
|
+
}
|
|
359
|
+
/** Design speeds in m/s by kind. */
|
|
360
|
+
declare const KIND_SPEED: Readonly<Record<RoadKind, number>>;
|
|
361
|
+
interface FeatureDraftOptions {
|
|
362
|
+
/** Tunnels: keep them with hidden agents (default) or drop them. */
|
|
363
|
+
tunnels: "hidden" | "skip";
|
|
364
|
+
}
|
|
365
|
+
/** Classify a mapped feature; `undefined` for features no agent uses. */
|
|
366
|
+
declare function classifyFeature(feature: TerrainTransportationFeature): {
|
|
367
|
+
class: TransportClass;
|
|
368
|
+
kind: RoadKind;
|
|
369
|
+
} | "runway" | undefined;
|
|
370
|
+
/**
|
|
371
|
+
* Clip a polyline to an axis-aligned rectangle, returning the visible pieces (a line that leaves
|
|
372
|
+
* and re-enters the tile yields several pieces).
|
|
373
|
+
*/
|
|
374
|
+
declare function clipPolyline(points: readonly Point2[], minX: number, minZ: number, maxX: number, maxZ: number): Point2[][];
|
|
375
|
+
interface TileDraftInput {
|
|
376
|
+
origin: readonly [number, number];
|
|
377
|
+
tileSize: number;
|
|
378
|
+
features: readonly TerrainTransportationFeature[];
|
|
379
|
+
}
|
|
380
|
+
interface TileDrafts {
|
|
381
|
+
drafts: EdgeDraft[];
|
|
382
|
+
runways: {
|
|
383
|
+
a: Point2;
|
|
384
|
+
b: Point2;
|
|
385
|
+
}[];
|
|
386
|
+
}
|
|
387
|
+
/** Convert a tile's transportation features to clipped world-metre drafts. */
|
|
388
|
+
declare function featureDrafts(input: TileDraftInput, options: FeatureDraftOptions): TileDrafts;
|
|
389
|
+
/** POIs in world metres, filtered to the kinds agents care about. */
|
|
390
|
+
interface WorldPoi {
|
|
391
|
+
kind: "station" | "tram_stop" | "bus_stop" | "traffic_signals" | "give_way" | "crossing" | "aerodrome";
|
|
392
|
+
x: number;
|
|
393
|
+
z: number;
|
|
394
|
+
name?: string;
|
|
395
|
+
/** Stations: dwell time in seconds. */
|
|
396
|
+
dwell?: number;
|
|
397
|
+
}
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/kernel/graph/doc.d.ts
|
|
400
|
+
declare const TRANSPORT_NETWORK_FORMAT: "molen/transport-network@1";
|
|
401
|
+
/** A way's point: `[x, z]` or `[x, y, z]` in scene metres. */
|
|
402
|
+
type TransportNetworkPoint = [number, number] | [number, number, number];
|
|
403
|
+
interface TransportNetworkWay {
|
|
404
|
+
id?: string;
|
|
405
|
+
class: "road" | "rail" | "path" | "air";
|
|
406
|
+
subclass?: string;
|
|
407
|
+
points: TransportNetworkPoint[];
|
|
408
|
+
oneway?: boolean;
|
|
409
|
+
lanes?: number;
|
|
410
|
+
width?: number;
|
|
411
|
+
layer?: number;
|
|
412
|
+
speed?: number;
|
|
413
|
+
bridge?: boolean;
|
|
414
|
+
tunnel?: boolean;
|
|
415
|
+
name?: string;
|
|
416
|
+
}
|
|
417
|
+
interface TransportNetworkStation {
|
|
418
|
+
id: string;
|
|
419
|
+
at: [number, number];
|
|
420
|
+
kind: "rail" | "bus";
|
|
421
|
+
dwell?: number;
|
|
422
|
+
}
|
|
423
|
+
interface TransportNetworkSignal {
|
|
424
|
+
at: [number, number];
|
|
425
|
+
kind: "stop" | "yield" | "light";
|
|
426
|
+
}
|
|
427
|
+
interface TransportNetworkAerodrome {
|
|
428
|
+
id: string;
|
|
429
|
+
at: [number, number];
|
|
430
|
+
/** Runway heading in radians about +Y (0 = +Z). */
|
|
431
|
+
heading?: number;
|
|
432
|
+
/** Runway length in metres (default 2500). */
|
|
433
|
+
length?: number;
|
|
434
|
+
}
|
|
435
|
+
interface TransportNetworkDocument {
|
|
436
|
+
format: "molen/transport-network@1";
|
|
437
|
+
name?: string;
|
|
438
|
+
origin?: {
|
|
439
|
+
latitude: number;
|
|
440
|
+
longitude: number;
|
|
441
|
+
} | {
|
|
442
|
+
x: number;
|
|
443
|
+
z: number;
|
|
444
|
+
};
|
|
445
|
+
drivingSide?: "right" | "left";
|
|
446
|
+
/** Infer sidewalks (walk lanes) along streets without mapped paths (default false). */
|
|
447
|
+
sidewalks?: boolean;
|
|
448
|
+
ways: TransportNetworkWay[];
|
|
449
|
+
stations?: TransportNetworkStation[];
|
|
450
|
+
signals?: TransportNetworkSignal[];
|
|
451
|
+
aerodromes?: TransportNetworkAerodrome[];
|
|
452
|
+
}
|
|
453
|
+
declare const TRANSPORT_NETWORK_EXAMPLE: TransportNetworkDocument;
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/kernel/graph/junctions.d.ts
|
|
456
|
+
/** What the builder reads from and writes to the network. */
|
|
457
|
+
interface GraphStore {
|
|
458
|
+
readonly traffic: "right" | "left";
|
|
459
|
+
node(id: string): TransportNode | undefined;
|
|
460
|
+
edge(id: string): TransportEdge | undefined;
|
|
461
|
+
lane(id: string): TransportLane | undefined;
|
|
462
|
+
junction(id: string): TransportJunction | undefined;
|
|
463
|
+
setJunction(junction: TransportJunction): void;
|
|
464
|
+
deleteJunction(id: string): void;
|
|
465
|
+
/** Whether a mapped traffic-signal point lies within `radius` of a point. */
|
|
466
|
+
signalNear(x: number, z: number, radius: number): boolean;
|
|
467
|
+
/** Stop and yield signs within `radius` of a point. */
|
|
468
|
+
giveWayNear(x: number, z: number, radius: number): readonly {
|
|
469
|
+
x: number;
|
|
470
|
+
z: number;
|
|
471
|
+
}[];
|
|
472
|
+
}
|
|
473
|
+
/** Monotone stand-in for atan2 in [0, 4): orders directions without transcendental math. */
|
|
474
|
+
declare function pseudoAngle(dx: number, dz: number): number;
|
|
475
|
+
//#endregion
|
|
476
|
+
//#region src/kernel/graph/spatial.d.ts
|
|
477
|
+
declare const GRID_CELL = 64;
|
|
478
|
+
interface EdgeSpan {
|
|
479
|
+
readonly edge: string;
|
|
480
|
+
/** Edge-path distances bounding the span. */
|
|
481
|
+
readonly d0: number;
|
|
482
|
+
readonly d1: number;
|
|
483
|
+
/** Midpoint, for distance tests. */
|
|
484
|
+
readonly x: number;
|
|
485
|
+
readonly z: number;
|
|
486
|
+
}
|
|
487
|
+
declare class LaneGrid {
|
|
488
|
+
private readonly cells;
|
|
489
|
+
private readonly edgeCells;
|
|
490
|
+
/** Bumped on every change; lets callers cache derived sums. */
|
|
491
|
+
version: number;
|
|
492
|
+
insert(edge: TransportEdge, laneCounts: Readonly<Record<TransportClass, number>>): void;
|
|
493
|
+
remove(edgeId: string): void;
|
|
494
|
+
/** Visit cells overlapping the disc of radius `r`, in a deterministic order. */
|
|
495
|
+
private cellsNear;
|
|
496
|
+
/** Lane-metres of a class in cells overlapping the disc. */
|
|
497
|
+
laneMeters(x: number, z: number, r: number, cls: TransportClass): number;
|
|
498
|
+
/** Spans whose midpoint lies in the annulus [rMin, rMax]. */
|
|
499
|
+
spansWithin(x: number, z: number, rMin: number, rMax: number): EdgeSpan[];
|
|
500
|
+
/** Distinct edge ids with a span within `r` (span midpoints, padded by half a span). */
|
|
501
|
+
edgesNear(x: number, z: number, r: number): string[];
|
|
502
|
+
clear(): void;
|
|
503
|
+
}
|
|
504
|
+
//#endregion
|
|
505
|
+
//#region src/kernel/graph/network.d.ts
|
|
506
|
+
/** One streamed map tile's transport data. */
|
|
507
|
+
interface AmbientTileInput {
|
|
508
|
+
/** Unique tile key, e.g. `terrainPyramidTileKey(address)`. */
|
|
509
|
+
key: string;
|
|
510
|
+
/** World X/Z of the tile's north-west corner, in metres. */
|
|
511
|
+
origin: readonly [number, number];
|
|
512
|
+
/** Tile edge length in metres; feature coordinates are normalized to it. */
|
|
513
|
+
tileSize: number;
|
|
514
|
+
features: readonly TerrainTransportationFeature[];
|
|
515
|
+
pois?: readonly TerrainPoiFeature[];
|
|
516
|
+
/** Ground height at a world X/Z (default: the network's ground sampler). */
|
|
517
|
+
heightAt?: (x: number, z: number) => number;
|
|
518
|
+
/** Infer sidewalks along streets without mapped footways (default true). */
|
|
519
|
+
sidewalks?: boolean;
|
|
520
|
+
}
|
|
521
|
+
interface TransportNetworkOptions {
|
|
522
|
+
traffic?: "right" | "left";
|
|
523
|
+
tunnels?: "hidden" | "skip";
|
|
524
|
+
/** Ground height used when a tile or document gives none (default 0). */
|
|
525
|
+
ground?: (x: number, z: number) => number;
|
|
526
|
+
/** Lane classes to build (default all); skipping unused classes makes tiles cheaper. */
|
|
527
|
+
classes?: readonly TransportClass[];
|
|
528
|
+
}
|
|
529
|
+
interface TransportNetworkStats {
|
|
530
|
+
tiles: number;
|
|
531
|
+
nodes: number;
|
|
532
|
+
edges: number;
|
|
533
|
+
lanes: number;
|
|
534
|
+
junctions: number;
|
|
535
|
+
signals: number;
|
|
536
|
+
/** Lane-kilometres per class. */
|
|
537
|
+
laneKm: Record<TransportClass, number>;
|
|
538
|
+
degradedTiles: number;
|
|
539
|
+
}
|
|
540
|
+
/** A script-added polyline. */
|
|
541
|
+
interface AmbientPolyline {
|
|
542
|
+
class: "road" | "rail" | "path";
|
|
543
|
+
subclass?: string;
|
|
544
|
+
/** `[x, z]` or `[x, y, z]` points in scene metres. */
|
|
545
|
+
points: ([number, number] | [number, number, number])[];
|
|
546
|
+
oneway?: boolean;
|
|
547
|
+
lanes?: number;
|
|
548
|
+
width?: number;
|
|
549
|
+
speed?: number;
|
|
550
|
+
layer?: number;
|
|
551
|
+
}
|
|
552
|
+
declare class TransportNetwork implements GraphStore {
|
|
553
|
+
readonly traffic: "right" | "left";
|
|
554
|
+
readonly grid: LaneGrid;
|
|
555
|
+
private readonly tunnels;
|
|
556
|
+
private readonly ground;
|
|
557
|
+
private classes;
|
|
558
|
+
private readonly nodes;
|
|
559
|
+
private readonly edges;
|
|
560
|
+
private readonly lanes;
|
|
561
|
+
private readonly junctions;
|
|
562
|
+
private readonly tiles;
|
|
563
|
+
private readonly borders;
|
|
564
|
+
private readonly crossings;
|
|
565
|
+
private readonly crossingsByEdge;
|
|
566
|
+
private readonly signalCells;
|
|
567
|
+
private readonly docDrafts;
|
|
568
|
+
private readonly docPois;
|
|
569
|
+
private readonly docRunways;
|
|
570
|
+
private docSidewalks;
|
|
571
|
+
/** Bumped whenever lanes appear, disappear or change. */
|
|
572
|
+
version: number;
|
|
573
|
+
constructor(options?: TransportNetworkOptions);
|
|
574
|
+
/** Change which lane classes are built (applies to tiles registered afterwards). */
|
|
575
|
+
setClasses(classes: readonly TransportClass[]): void;
|
|
576
|
+
/** Whether a lane class is being built. */
|
|
577
|
+
builds(cls: TransportClass): boolean;
|
|
578
|
+
node(id: string): TransportNode | undefined;
|
|
579
|
+
edge(id: string): TransportEdge | undefined;
|
|
580
|
+
lane(id: string): TransportLane | undefined;
|
|
581
|
+
junction(id: string): TransportJunction | undefined;
|
|
582
|
+
setJunction(junction: TransportJunction): void;
|
|
583
|
+
deleteJunction(id: string): void;
|
|
584
|
+
signalNear(x: number, z: number, radius: number): boolean;
|
|
585
|
+
giveWayNear(x: number, z: number, radius: number): readonly WorldPoi[];
|
|
586
|
+
private controlsNear;
|
|
587
|
+
/** Whether a tile key is registered. */
|
|
588
|
+
hasTile(key: string): boolean;
|
|
589
|
+
tileKeys(): string[];
|
|
590
|
+
/** Every lane id (registration order). */
|
|
591
|
+
laneIds(): IterableIterator<string>;
|
|
592
|
+
junctionList(): IterableIterator<TransportJunction>;
|
|
593
|
+
runways(): TransportRunway[];
|
|
594
|
+
/** Aerodrome POIs (and runway midpoints) across registered tiles. */
|
|
595
|
+
aerodromes(): WorldPoi[];
|
|
596
|
+
crossingsOf(edgeId: string): readonly TransportCrossing[];
|
|
597
|
+
/** The movement from `from` onto `to`, if one exists. */
|
|
598
|
+
movement(from: string | undefined, to: string): LaneMovement | undefined;
|
|
599
|
+
/** Build and add one map tile (replacing a previous registration under the same key). */
|
|
600
|
+
registerTile(input: AmbientTileInput): void;
|
|
601
|
+
/** Remove a tile: its edges, lanes and nodes; stitched neighbours become open ends again. */
|
|
602
|
+
unregisterTile(key: string): void;
|
|
603
|
+
/** Add a transport-network document's ways, stations, signals and aerodromes. */
|
|
604
|
+
addDocument(doc: TransportNetworkDocument): void;
|
|
605
|
+
/** Add one polyline (scripts); returns the id of the first edge it produced, if any. */
|
|
606
|
+
addPolyline(line: AmbientPolyline): string | undefined;
|
|
607
|
+
private rebuildDocTile;
|
|
608
|
+
private addTile;
|
|
609
|
+
private createLanes;
|
|
610
|
+
private stitch;
|
|
611
|
+
private addSignal;
|
|
612
|
+
private removeSignal;
|
|
613
|
+
/** Project stations onto rail lanes and bus stops onto footways. */
|
|
614
|
+
private addStops;
|
|
615
|
+
/** Record where footway crossings and railways cross roads at grade. */
|
|
616
|
+
private addCrossings;
|
|
617
|
+
/** Sample a lane body at `s` (clamped to the lane). */
|
|
618
|
+
sampleLane(laneId: string, s: number, out?: LaneSample): LaneSample | undefined;
|
|
619
|
+
/** The nearest lane of a class to a point, with the lane coordinate of the closest point. */
|
|
620
|
+
laneAt(x: number, z: number, opts?: {
|
|
621
|
+
class?: TransportClass;
|
|
622
|
+
radius?: number;
|
|
623
|
+
}): {
|
|
624
|
+
lane: string;
|
|
625
|
+
s: number;
|
|
626
|
+
distance: number;
|
|
627
|
+
} | undefined;
|
|
628
|
+
stats(): TransportNetworkStats;
|
|
629
|
+
/** Drop everything. */
|
|
630
|
+
clear(): void;
|
|
631
|
+
/** Every edge, for export (`networkToDocument`). */
|
|
632
|
+
edgeList(): IterableIterator<TransportEdge>;
|
|
633
|
+
}
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region src/kernel/agents/step.d.ts
|
|
636
|
+
/** A solid thing agents must not drive into (the player's car, a parked aircraft). */
|
|
637
|
+
interface AmbientSolid {
|
|
638
|
+
x: number;
|
|
639
|
+
z: number;
|
|
640
|
+
radius: number;
|
|
641
|
+
}
|
|
642
|
+
interface AgentEnv {
|
|
643
|
+
net: TransportNetwork;
|
|
644
|
+
policy: AmbientPolicy;
|
|
645
|
+
tick: number;
|
|
646
|
+
tickRate: number;
|
|
647
|
+
dt: number;
|
|
648
|
+
/** Solids cars yield to (queried from the world by the caller). */
|
|
649
|
+
solids: readonly AmbientSolid[];
|
|
650
|
+
}
|
|
651
|
+
/** Pick the next lane at a lane's end (seeded by the agent and its hop count). */
|
|
652
|
+
declare function chooseNext(lane: TransportLane, seed: number, hops: number): string | undefined;
|
|
653
|
+
/** Where an agent is: its lane body, or the connector curve into its lane. */
|
|
654
|
+
declare function agentSample(net: TransportNetwork, agent: Readonly<AmbientAgentData>, out: LaneSample): LaneSample | undefined;
|
|
655
|
+
/** Rotation for an agent facing along a sample (with pitch unless flat). */
|
|
656
|
+
declare function agentRotation(sample: LaneSample, pitch: boolean): Quat;
|
|
657
|
+
/** Advance every ambient agent one tick. */
|
|
658
|
+
declare function stepAgents(world: World, env: AgentEnv): void;
|
|
659
|
+
/** Step back `distance` metres from a lane position along the lead's trail. */
|
|
660
|
+
declare function walkBack(net: TransportNetwork, laneId: string, s: number, prev: string | undefined, trail: readonly string[], distance: number): {
|
|
661
|
+
lane: string;
|
|
662
|
+
s: number;
|
|
663
|
+
prev?: string;
|
|
664
|
+
};
|
|
665
|
+
//#endregion
|
|
666
|
+
//#region src/kernel/templates.d.ts
|
|
667
|
+
interface AmbientVehicleType {
|
|
668
|
+
/** Content type id, or a proxy name. */
|
|
669
|
+
id: string;
|
|
670
|
+
/** Relative spawn weight within the class (default 1). */
|
|
671
|
+
weight?: number;
|
|
672
|
+
length: number;
|
|
673
|
+
width: number;
|
|
674
|
+
height?: number;
|
|
675
|
+
/** Preferred cruise speed in m/s (default: the lane's design speed). */
|
|
676
|
+
cruise?: number;
|
|
677
|
+
/** Top speed in m/s. */
|
|
678
|
+
max?: number;
|
|
679
|
+
/** Body colours to pick from (default: a realistic car palette). */
|
|
680
|
+
colors?: string[];
|
|
681
|
+
/** Rail: cars per consist. */
|
|
682
|
+
cars?: number;
|
|
683
|
+
}
|
|
684
|
+
interface AmbientPedestrianType {
|
|
685
|
+
preset: "human.adult" | "human.elder" | "human.child";
|
|
686
|
+
weight?: number;
|
|
687
|
+
}
|
|
688
|
+
interface AmbientTypes {
|
|
689
|
+
car: AmbientVehicleType[];
|
|
690
|
+
train: AmbientVehicleType[];
|
|
691
|
+
aircraft: AmbientVehicleType[];
|
|
692
|
+
pedestrian: AmbientPedestrianType[];
|
|
693
|
+
}
|
|
694
|
+
/** Common real-world car body colours, weighted by repetition. */
|
|
695
|
+
declare const CAR_COLORS: readonly string[];
|
|
696
|
+
declare const DEFAULT_TYPES: AmbientTypes;
|
|
697
|
+
/** Weighted pick from a list using a stateless draw. */
|
|
698
|
+
declare function pickWeighted<T extends {
|
|
699
|
+
weight?: number;
|
|
700
|
+
}>(list: readonly T[], u: number): T | undefined;
|
|
701
|
+
/** The details a template sees when an agent spawns. */
|
|
702
|
+
interface AmbientSpawnInfo {
|
|
703
|
+
id: string;
|
|
704
|
+
kind: AmbientKind;
|
|
705
|
+
type: string;
|
|
706
|
+
seed: number;
|
|
707
|
+
color?: string;
|
|
708
|
+
}
|
|
709
|
+
/** Extra components for a spawned agent (beyond `ambientAgent` and `transform`). */
|
|
710
|
+
type AmbientTemplate = (agent: AmbientSpawnInfo) => ComponentMap;
|
|
711
|
+
/** Built-in templates: vehicles render through `ambient-vehicle`, pedestrians as figures. */
|
|
712
|
+
declare const DEFAULT_TEMPLATES: Readonly<Record<AmbientKind, AmbientTemplate>>;
|
|
713
|
+
//#endregion
|
|
714
|
+
//#region src/kernel/install.d.ts
|
|
715
|
+
interface AmbientOptions {
|
|
716
|
+
/** Which side of the road traffic keeps to (default 'right'). */
|
|
717
|
+
traffic?: "right" | "left";
|
|
718
|
+
/** Tunnels: keep them with hidden agents (default) or drop them. */
|
|
719
|
+
tunnels?: "hidden" | "skip";
|
|
720
|
+
/** Ground height for documents, aircraft and tiles without their own sampler (default 0). */
|
|
721
|
+
ground?: (x: number, z: number) => number;
|
|
722
|
+
/** Which classes run (default ['car']). */
|
|
723
|
+
classes?: readonly AmbientKind[];
|
|
724
|
+
/** Policy overrides (rings, densities, caps, driver parameters). */
|
|
725
|
+
policy?: DeepPartial<AmbientPolicy>;
|
|
726
|
+
/** Vehicle and pedestrian types per class (default: proxy dimensions). */
|
|
727
|
+
types?: Partial<AmbientTypes>;
|
|
728
|
+
/** Extra components per class; `null` spawns bare agents (ambientAgent + transform only). */
|
|
729
|
+
templates?: Partial<Record<AmbientKind, AmbientTemplate | null>>;
|
|
730
|
+
/** Seed for spawn draws (default: 'ambient'). */
|
|
731
|
+
seed?: string | number;
|
|
732
|
+
/** Cars yield to vehicles someone is driving (`mounted` riders); default true. */
|
|
733
|
+
yieldToDriven?: boolean;
|
|
734
|
+
}
|
|
735
|
+
interface AmbientStats {
|
|
736
|
+
network: TransportNetworkStats;
|
|
737
|
+
agents: Record<AmbientKind, number>;
|
|
738
|
+
waiting: number;
|
|
739
|
+
spawned: number;
|
|
740
|
+
despawned: number;
|
|
741
|
+
pendingTiles: number;
|
|
742
|
+
}
|
|
743
|
+
/** An oriented box on the ground (for host collision queries). */
|
|
744
|
+
interface AmbientBox {
|
|
745
|
+
center: readonly [number, number, number];
|
|
746
|
+
/** Half extents: x across, y up, z along. */
|
|
747
|
+
halfSize: readonly [number, number, number];
|
|
748
|
+
/** Yaw about +Y (0 = +Z forward). */
|
|
749
|
+
yaw: number;
|
|
750
|
+
}
|
|
751
|
+
interface AmbientHandle {
|
|
752
|
+
readonly world: World;
|
|
753
|
+
readonly network: TransportNetwork;
|
|
754
|
+
/** Queue a streamed tile (applied at the next tick, or by `flush()`). */
|
|
755
|
+
registerTile(tile: AmbientTileInput): void;
|
|
756
|
+
unregisterTile(key: string): void;
|
|
757
|
+
/** Apply queued tile changes now (outside a tick). */
|
|
758
|
+
flush(): void;
|
|
759
|
+
addDocument(doc: TransportNetworkDocument): void;
|
|
760
|
+
addPolyline(line: AmbientPolyline): void;
|
|
761
|
+
setObserver(observer: {
|
|
762
|
+
pos: readonly [number, number, number];
|
|
763
|
+
forward?: readonly [number, number];
|
|
764
|
+
} | {
|
|
765
|
+
entity: EntityId;
|
|
766
|
+
} | null): void;
|
|
767
|
+
/** Persistent policy overrides (recorded in world state). */
|
|
768
|
+
setPolicy(policy: DeepPartial<AmbientPolicy>): void;
|
|
769
|
+
/** Host budget: caps and ring size (not recorded; hosts reapply after a restore). */
|
|
770
|
+
setBudget(budget: AmbientBudget): void;
|
|
771
|
+
/** Extra solids cars yield to (e.g. the walking player). */
|
|
772
|
+
setSolids(solids: readonly AmbientSolid[]): void;
|
|
773
|
+
policy(): AmbientPolicy;
|
|
774
|
+
stats(): AmbientStats;
|
|
775
|
+
laneAt(x: number, z: number, opts?: {
|
|
776
|
+
class?: TransportClass;
|
|
777
|
+
radius?: number;
|
|
778
|
+
}): {
|
|
779
|
+
lane: string;
|
|
780
|
+
s: number;
|
|
781
|
+
distance: number;
|
|
782
|
+
} | undefined;
|
|
783
|
+
laneSample(lane: string, s: number): LaneSample | undefined;
|
|
784
|
+
agentsNear(x: number, z: number, radius: number, kind?: AmbientKind): EntityId[];
|
|
785
|
+
/** Whether an ambient car overlaps a box (for a host vehicle solver's `canOccupy`). */
|
|
786
|
+
blocks(box: AmbientBox, except?: EntityId): boolean;
|
|
787
|
+
despawnAll(kind?: AmbientKind): void;
|
|
788
|
+
dispose(): void;
|
|
789
|
+
}
|
|
790
|
+
/** Install the ambient systems (idempotent per world) and return the handle. */
|
|
791
|
+
declare function installAmbient(world: World, options?: AmbientOptions): AmbientHandle;
|
|
792
|
+
/** The ambient handle installed on a world, if any. */
|
|
793
|
+
declare function ambientOf(world: World): AmbientHandle | undefined;
|
|
794
|
+
//#endregion
|
|
795
|
+
//#region src/kernel/capability.d.ts
|
|
796
|
+
interface AmbientCapabilityOptions extends Omit<AmbientOptions, "classes" | "seed" | "traffic"> {
|
|
797
|
+
/** Networks for `ambient.network` paths, keyed by the path as written in the scene. */
|
|
798
|
+
networks?: Readonly<Record<string, TransportNetworkDocument>>;
|
|
799
|
+
}
|
|
800
|
+
/** Build-world capability hook: `buildWorld(scene, setup, { capabilities: [ambientCapability()] })`. */
|
|
801
|
+
declare function ambientCapability(opts?: AmbientCapabilityOptions): (world: World, manifest: SceneManifest) => Record<string, object> | undefined;
|
|
802
|
+
//#endregion
|
|
803
|
+
//#region src/kernel/graph/export.d.ts
|
|
804
|
+
/** Every road, rail and path edge as a way (with surface heights), plus stations and signals. */
|
|
805
|
+
declare function networkToDocument(network: TransportNetwork, meta?: Pick<TransportNetworkDocument, "name" | "origin">, options?: {
|
|
806
|
+
heights?: boolean;
|
|
807
|
+
}): TransportNetworkDocument;
|
|
808
|
+
//#endregion
|
|
809
|
+
//#region src/kernel/graph/planar.d.ts
|
|
810
|
+
interface PlanarNode {
|
|
811
|
+
x: number;
|
|
812
|
+
z: number;
|
|
813
|
+
layer: number;
|
|
814
|
+
class: EdgeDraft["class"];
|
|
815
|
+
}
|
|
816
|
+
interface PlanarPiece {
|
|
817
|
+
draft: number;
|
|
818
|
+
from: number;
|
|
819
|
+
to: number;
|
|
820
|
+
points: Point2[];
|
|
821
|
+
/** Absolute heights per point when the draft supplied them. */
|
|
822
|
+
heights?: number[];
|
|
823
|
+
}
|
|
824
|
+
interface PlanarResult {
|
|
825
|
+
nodes: PlanarNode[];
|
|
826
|
+
pieces: PlanarPiece[];
|
|
827
|
+
/** True when the comparison budget ran out and some crossings were not detected. */
|
|
828
|
+
degraded: boolean;
|
|
829
|
+
}
|
|
830
|
+
interface PlanarOptions {
|
|
831
|
+
/** Points closer than this merge into one node (metres). */
|
|
832
|
+
snap?: number;
|
|
833
|
+
maxSegments?: number;
|
|
834
|
+
maxComparisons?: number;
|
|
835
|
+
}
|
|
836
|
+
/** Split drafts into pieces between nodes. Drafts only connect within their class. */
|
|
837
|
+
declare function planarSplit(drafts: readonly EdgeDraft[], options?: PlanarOptions): PlanarResult;
|
|
838
|
+
//#endregion
|
|
839
|
+
//#region src/kernel/graph/sample.d.ts
|
|
840
|
+
/** Edge-path distance of lane coordinate `s` (clamped to the lane). */
|
|
841
|
+
declare function laneEdgeDistance(lane: TransportLane, edge: TransportEdge, s: number): number;
|
|
842
|
+
/** Lane coordinate of edge-path distance `d`. */
|
|
843
|
+
declare function laneCoordinate(lane: TransportLane, edge: TransportEdge, d: number): number;
|
|
844
|
+
/** Height of the edge surface at an edge-path distance. */
|
|
845
|
+
declare function edgeHeight(edge: TransportEdge, d: number): number;
|
|
846
|
+
/** Sample a lane at `s` within [0, length], writing into `out`. */
|
|
847
|
+
declare function sampleLaneBody(lane: TransportLane, edge: TransportEdge, s: number, out: LaneSample): LaneSample;
|
|
848
|
+
/** Point and tangent on a movement's connector at arc-length fraction `t` in [0, 1]. */
|
|
849
|
+
declare function sampleConnector(move: LaneMovement, t: number, out: LaneSample): LaneSample;
|
|
850
|
+
/** A fresh sample record. */
|
|
851
|
+
declare function laneSample(): LaneSample;
|
|
852
|
+
//#endregion
|
|
853
|
+
//#region src/kernel/ids.d.ts
|
|
854
|
+
/** murmur3 finalizer: a full-avalanche 32-bit mix. */
|
|
855
|
+
declare function fmix32(x: number): number;
|
|
856
|
+
/** Independent stateless draw in [0, 1) for a (seed, stream) pair. */
|
|
857
|
+
declare function unit01(seed: number, stream: number): number;
|
|
858
|
+
//#endregion
|
|
859
|
+
//#region src/kernel/schema.d.ts
|
|
860
|
+
declare const AMBIENT_AGENT_COMPONENT: "ambientAgent";
|
|
861
|
+
declare const AMBIENT_OBSERVER_COMPONENT: "ambientObserver";
|
|
862
|
+
declare const AMBIENT_ROLE_COMPONENT: "ambientRole";
|
|
863
|
+
declare const AMBIENT_STATE_COMPONENT: "ambientState";
|
|
864
|
+
/** Register the ambient components, renderable kind and format (idempotent). */
|
|
865
|
+
declare function registerAmbientSchema(): void;
|
|
866
|
+
//#endregion
|
|
867
|
+
//#region src/kernel/script-api.d.ts
|
|
868
|
+
/** The script-api namespace for ambient life (`molen.ambient.*`); pass via `buildWorld` capabilities. */
|
|
869
|
+
declare function ambientScriptApi(handle: AmbientHandle): object;
|
|
870
|
+
//#endregion
|
|
871
|
+
//#region src/kernel/spawn/spawner.d.ts
|
|
872
|
+
interface ObserverView {
|
|
873
|
+
x: number;
|
|
874
|
+
y: number;
|
|
875
|
+
z: number;
|
|
876
|
+
/** Unit horizontal view direction, when known. */
|
|
877
|
+
fx?: number;
|
|
878
|
+
fz?: number;
|
|
879
|
+
/** Density factor from the observer entity's `ambientObserver`. */
|
|
880
|
+
density: number;
|
|
881
|
+
/** Car spawn radius from the observer entity's `ambientObserver`. */
|
|
882
|
+
radius?: number;
|
|
883
|
+
/** Car despawn radius from the observer entity's `ambientObserver`. */
|
|
884
|
+
keep?: number;
|
|
885
|
+
}
|
|
886
|
+
//#endregion
|
|
887
|
+
export { AMBIENT_AGENT_COMPONENT, AMBIENT_ENTITY, AMBIENT_KINDS, AMBIENT_OBSERVER_COMPONENT, AMBIENT_ROLE_COMPONENT, AMBIENT_STATE_COMPONENT, type AgentEnv, AmbientAgent, type AmbientAgentData, type AmbientAirCorridor, type AmbientBox, type AmbientBudget, type AmbientCapabilityOptions, type AmbientClassPolicy, type AmbientHandle, type AmbientKind, AmbientObserver, type AmbientObserverData, type AmbientObserverState, type AmbientOptions, type AmbientPedestrianType, type AmbientPolicy, type AmbientPolyline, AmbientRole, type AmbientRoleData, type AmbientRoleVisual, type AmbientSolid, type AmbientSpawnInfo, AmbientState, type AmbientStateData, type AmbientStats, type AmbientTemplate, type AmbientTileInput, type AmbientTypes, type AmbientVehicleType, CAR_COLORS, DEFAULT_POLICY, DEFAULT_TEMPLATES, DEFAULT_TYPES, type DeepPartial, type DriverParams, type EdgeDraft, type EdgeSpan, GRID_CELL, type JunctionArm, type JunctionControl, KIND_SPEED, LaneGrid, type LaneMovement, type LaneSample, type LaneStop, type ObserverView, type PlanarNode, type PlanarPiece, type PlanarResult, type RoadKind, type SignalColor, type SignalTiming, TRANSPORT_NETWORK_EXAMPLE, TRANSPORT_NETWORK_FORMAT, type TransportClass, type TransportCrossing, type TransportEdge, type TransportJunction, type TransportLane, TransportNetwork, type TransportNetworkAerodrome, type TransportNetworkDocument, type TransportNetworkOptions, type TransportNetworkPoint, type TransportNetworkSignal, type TransportNetworkStation, type TransportNetworkStats, type TransportNetworkWay, type TransportNode, type TransportRunway, type TurnKind, type WorldPoi, agentRotation, agentSample, allRed, ambientCapability, ambientOf, ambientScriptApi, chooseNext, classifyFeature, clipPolyline, edgeHeight, featureDrafts, fmix32, idmAcceleration, installAmbient, laneCoordinate, laneEdgeDistance, laneSample, mergePolicy, networkToDocument, pickWeighted, planarSplit, policyForBudget, pseudoAngle, registerAmbientSchema, sampleConnector, sampleLaneBody, signalColor, signalTiming, stepAgents, stoppingDistance, unit01, walkBack };
|