@joy-ride/joy-ride 0.0.0-stage → 0.1.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/README.md +48 -2
- package/THIRD_PARTY_NOTICES.md +76 -0
- package/npm/bookmarklet.d.ts +5 -0
- package/npm/bookmarklet.js +30 -0
- package/npm/embed-assets/audi-rs3-top-Zwm7ZQ20.webp +0 -0
- package/npm/embed-assets/bmw-m4-top-GKSf0h28.webp +0 -0
- package/npm/embed-assets/electric-gt-top-DTcvEjMR.webp +0 -0
- package/npm/embed-assets/ford-mustang-gt-top-DVzZTm7G.webp +0 -0
- package/npm/embed-assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- package/npm/embed-assets/jeep-wrangler-top-Dr43LU9c.webp +0 -0
- package/npm/embed-assets/lamborghini-huracan-evo-top-BCJJwrTj.webp +0 -0
- package/npm/embed-assets/logo-backing-DQNUb3C2.svg +1 -0
- package/npm/embed-assets/porsche-911-997-top-BE6uRNL4.webp +0 -0
- package/npm/embed-assets/roof-rocket-v1-Bs4IEw-s.webp +0 -0
- package/npm/embed-assets/side-gun-v1-BnpvZN1b.webp +0 -0
- package/npm/embed-assets/src-DCczMlG6.css +1 -0
- package/npm/embed-assets/subaru-wrx-top-dLvMFYDs.webp +0 -0
- package/npm/embed-assets/tire-screech-cc0-DEsAg1CH.mp3 +0 -0
- package/npm/embed-chunks/Documentation-BYRVcu7a.js +32 -0
- package/npm/embed-chunks/src-CHjCYOJf.js +1270 -0
- package/npm/embed.js +8 -0
- package/npm/index.d.ts +2776 -0
- package/npm/index.js +8 -0
- package/npm/playground-xDP5-tDc.d.ts +1164 -0
- package/package.json +150 -4
package/npm/index.d.ts
ADDED
|
@@ -0,0 +1,2776 @@
|
|
|
1
|
+
import { $ as SlotNumber, A as PlaygroundDefinitions, B as DebrisParticle, C as resolveWorkMode, D as ObjectPatch, E as DeepReadonly, F as DebrisAnchor, G as LiquidPourOptions, H as LiquidColor, I as DebrisBounds, J as VehicleTool, K as LiquidResidue, L as DebrisHandle, M as VehicleConfiguration, N as VehiclePatch, O as ObjectSpec, P as Debris, Q as LiquidEmission, R as DebrisKind, S as WorkModeSettings, T as Appearance, U as LiquidColorInput, V as DebrisVector, W as LiquidKind, X as VehicleToolPolicy, Y as VehicleToolDefinition, Z as availableVehicleTools, _ as SmokeTint, a as PlaygroundObject, at as Controls, b as WorkModeConfiguration, c as PlaygroundConfiguration, ct as Vec2, d as RuntimeOptionsPatch, et as VehicleSlot, f as SpeedZoomMode, g as FluidWall, h as FluidView, i as PlaygroundDiagnostic, it as LightningWeapon, j as RouteSpec, k as PlayerConfiguration, l as PortableVehicleConfiguration, lt as VehicleMode, m as FluidQuality, n as PlaygroundTriggerDetail, nt as FlamethrowerProfile, o as PlaygroundRegistry, ot as Simulation, p as SurfaceTone, q as LiquidSource, r as PlaygroundBinding, rt as VehiclePreset, s as PlaygroundTarget, st as SimulationState, t as PlaygroundRouteHandle, tt as VehicleSlots, u as RuntimeOptions, ut as CombustibleStage, v as VehicleLightToggle, w as definePlayground, x as WorkModeOptions, y as VehicleLightingOptions, z as DebrisOptions } from "./playground-xDP5-tDc.js";
|
|
2
|
+
/** Full tuning and presentation data for a host-owned vehicle selector. */
|
|
3
|
+
declare function listVehiclePresets(): VehiclePreset[];
|
|
4
|
+
declare function getVehiclePreset(id: string): VehiclePreset | undefined;
|
|
5
|
+
/** Compact data for menus and pickers. */
|
|
6
|
+
declare function listVehicleOptions(): {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string;
|
|
9
|
+
make: string | undefined;
|
|
10
|
+
model: string | undefined;
|
|
11
|
+
year: string | undefined;
|
|
12
|
+
image: string | undefined;
|
|
13
|
+
}[];
|
|
14
|
+
type ReserveWeapon = Exclude<VehicleTool, 'attractor'>;
|
|
15
|
+
/** Mutable per-vehicle weapon budget. It never owns input listeners or renderer state. */
|
|
16
|
+
declare class WeaponReserves {
|
|
17
|
+
private reserves;
|
|
18
|
+
private time;
|
|
19
|
+
private stepScales;
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
reset(): void;
|
|
22
|
+
captureState(): {
|
|
23
|
+
enabled: boolean;
|
|
24
|
+
time: number;
|
|
25
|
+
stepScales: [ReserveWeapon, number][];
|
|
26
|
+
reserves: (readonly [ReserveWeapon, {
|
|
27
|
+
readonly fill: number;
|
|
28
|
+
readonly pause: number;
|
|
29
|
+
readonly exhausted: boolean;
|
|
30
|
+
readonly lastUsedAt: number;
|
|
31
|
+
}])[];
|
|
32
|
+
};
|
|
33
|
+
restoreState(state: ReturnType<WeaponReserves['captureState']>): void;
|
|
34
|
+
consumptionScale(key: ReserveWeapon): number;
|
|
35
|
+
fraction(key: ReserveWeapon): number;
|
|
36
|
+
/** Returns the effective controls, allowing the same rule for player and AI cars. */
|
|
37
|
+
step(input: Controls, dt: number, boost?: {
|
|
38
|
+
durationSeconds: number;
|
|
39
|
+
cooldownSeconds: number;
|
|
40
|
+
}, consumption?: Partial<Record<ReserveWeapon, number>>): Controls;
|
|
41
|
+
/** A single bar shows the most recently used reserve until it refills and fades. */
|
|
42
|
+
indicator(now?: number): {
|
|
43
|
+
label: string;
|
|
44
|
+
fraction: number;
|
|
45
|
+
alpha: number;
|
|
46
|
+
depleted: boolean;
|
|
47
|
+
recharging: boolean;
|
|
48
|
+
} | null;
|
|
49
|
+
}
|
|
50
|
+
type TirePaintSource = {
|
|
51
|
+
/** Stable identity for a liquid patch whose sampled color may vary at its edges. */
|
|
52
|
+
id?: string;
|
|
53
|
+
/** CSS color deposited by the surface. */
|
|
54
|
+
color: string;
|
|
55
|
+
/** Maximum coverage of a fresh mark, from 0 to 1. */
|
|
56
|
+
opacity: number;
|
|
57
|
+
/** Distance this tire can carry the color after leaving the surface. */
|
|
58
|
+
distanceM: number;
|
|
59
|
+
material?: LiquidResidue;
|
|
60
|
+
};
|
|
61
|
+
type TirePigment = TirePaintSource & {
|
|
62
|
+
remaining: number;
|
|
63
|
+
};
|
|
64
|
+
type TirePaintMark = Pick<TirePaintSource, 'color' | 'opacity' | 'material'> & {
|
|
65
|
+
phaseM?: number;
|
|
66
|
+
wetness?: number;
|
|
67
|
+
slip?: number;
|
|
68
|
+
from: Vec2;
|
|
69
|
+
point: Vec2;
|
|
70
|
+
angle: number;
|
|
71
|
+
widthM: number;
|
|
72
|
+
/** Distance along a tire-deposited exit film; negative values are still inside the source. */
|
|
73
|
+
exit?: {
|
|
74
|
+
fromM: number;
|
|
75
|
+
toM: number;
|
|
76
|
+
lengthM: number;
|
|
77
|
+
leadInM?: number;
|
|
78
|
+
};
|
|
79
|
+
/** Mixed paint over a fresh pool is composited above that pool. */
|
|
80
|
+
overPuddle?: boolean;
|
|
81
|
+
/** Settled spray shares the tread tile archive, without creating a liquid pool. */
|
|
82
|
+
droplet?: {
|
|
83
|
+
aspect: number;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
/** Each tire independently picks up surface color and carries it onto the road. */
|
|
87
|
+
declare class TirePaint {
|
|
88
|
+
private coatings;
|
|
89
|
+
private previous;
|
|
90
|
+
private travelM;
|
|
91
|
+
private previousLayer;
|
|
92
|
+
private wetPaths;
|
|
93
|
+
private exits;
|
|
94
|
+
private sprayRemainder;
|
|
95
|
+
readonly marks: TirePaintMark[];
|
|
96
|
+
private markCount;
|
|
97
|
+
captureState(): {
|
|
98
|
+
coatings: Map<number, Map<string, TirePigment>>;
|
|
99
|
+
previous: Map<number, Vec2>;
|
|
100
|
+
travelM: Map<number, number>;
|
|
101
|
+
previousLayer: Map<number, boolean>;
|
|
102
|
+
wetPaths: Map<number, {
|
|
103
|
+
marks: TirePaintMark[];
|
|
104
|
+
distanceM: number;
|
|
105
|
+
}>;
|
|
106
|
+
exits: Map<number, {
|
|
107
|
+
distanceM: number;
|
|
108
|
+
lengthM: number;
|
|
109
|
+
}>;
|
|
110
|
+
sprayRemainder: Map<number, number>;
|
|
111
|
+
marks: TirePaintMark[];
|
|
112
|
+
markCount: number;
|
|
113
|
+
};
|
|
114
|
+
restoreState(state: ReturnType<TirePaint['captureState']>): void;
|
|
115
|
+
get totalMarks(): number;
|
|
116
|
+
get managedBytes(): number;
|
|
117
|
+
reset(): void;
|
|
118
|
+
step(distancesM: readonly number[]): void;
|
|
119
|
+
touch(index: number, source: TirePaintSource | null): void;
|
|
120
|
+
/** Wash one tire without erasing marks already left on the road. */
|
|
121
|
+
wash(index: number, freshSources?: readonly TirePaintSource[]): void;
|
|
122
|
+
/** Throw carried pigment even when its source is an HTML element, not a liquid field. */
|
|
123
|
+
splatter(index: number, point: Vec2, direction: Vec2, radiusPx: number, amount: number, energy: number, pixelsPerMeter: number): void;
|
|
124
|
+
/** Retain the real wheel path under a wet surface, without painting tracks across its center.
|
|
125
|
+
* On exit, a short immutable film bridges the settling liquid and the rolling tread.
|
|
126
|
+
*/
|
|
127
|
+
trackWet(index: number, point: Vec2, angle: number, widthM: number, pixelsPerMeter: number, slip?: number, overPuddle?: boolean): void;
|
|
128
|
+
/** Break contact history for teleports, washing, ghosts or disabled effects. */
|
|
129
|
+
pauseTrack(index: number): void;
|
|
130
|
+
track(index: number, point: Vec2, angle: number, widthM: number, pixelsPerMeter: number, overPuddle?: boolean, slip?: number): void;
|
|
131
|
+
coating(index: number): {
|
|
132
|
+
material: LiquidResidue | undefined;
|
|
133
|
+
wetness: number;
|
|
134
|
+
color: string;
|
|
135
|
+
opacity: number;
|
|
136
|
+
remaining: number;
|
|
137
|
+
distanceM: number;
|
|
138
|
+
} | null;
|
|
139
|
+
}
|
|
140
|
+
type Snapshot<TOutput> = {
|
|
141
|
+
status: 'active';
|
|
142
|
+
output: undefined;
|
|
143
|
+
error: undefined;
|
|
144
|
+
} | {
|
|
145
|
+
status: 'done';
|
|
146
|
+
output: TOutput;
|
|
147
|
+
error: undefined;
|
|
148
|
+
} | {
|
|
149
|
+
status: 'error';
|
|
150
|
+
output: undefined;
|
|
151
|
+
error: unknown;
|
|
152
|
+
} | {
|
|
153
|
+
status: 'stopped';
|
|
154
|
+
output: undefined;
|
|
155
|
+
error: undefined;
|
|
156
|
+
};
|
|
157
|
+
declare global {
|
|
158
|
+
interface SymbolConstructor {
|
|
159
|
+
readonly observable: symbol;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
type MaskRect = {
|
|
163
|
+
x: number;
|
|
164
|
+
y: number;
|
|
165
|
+
width: number;
|
|
166
|
+
height: number;
|
|
167
|
+
};
|
|
168
|
+
type MaskShape = {
|
|
169
|
+
center: Vec2;
|
|
170
|
+
forward: Vec2;
|
|
171
|
+
side: Vec2;
|
|
172
|
+
halfLength: number;
|
|
173
|
+
halfWidth: number;
|
|
174
|
+
};
|
|
175
|
+
type AlphaMask = {
|
|
176
|
+
columns: number;
|
|
177
|
+
rows: number;
|
|
178
|
+
solid: Uint8Array;
|
|
179
|
+
};
|
|
180
|
+
type VehicleMask = {
|
|
181
|
+
alpha: AlphaMask;
|
|
182
|
+
lengthM: number;
|
|
183
|
+
widthM: number;
|
|
184
|
+
};
|
|
185
|
+
/** Lazily loads cutout alpha once per image. Geometry stays tied to the rendered sprite. */
|
|
186
|
+
declare class VehicleMasks {
|
|
187
|
+
private loaded;
|
|
188
|
+
private pending;
|
|
189
|
+
private failed;
|
|
190
|
+
private fallback;
|
|
191
|
+
private keys;
|
|
192
|
+
private assembled;
|
|
193
|
+
forPreset(preset: VehiclePreset): VehicleMask;
|
|
194
|
+
private load;
|
|
195
|
+
}
|
|
196
|
+
/** The exact source crop and painted size shared by the renderer and collision mask. */
|
|
197
|
+
declare function vehicleImageFootprint(preset: VehiclePreset, imageWidth: number, imageHeight: number): {
|
|
198
|
+
source: {
|
|
199
|
+
x: number;
|
|
200
|
+
y: number;
|
|
201
|
+
width: number;
|
|
202
|
+
height: number;
|
|
203
|
+
};
|
|
204
|
+
lengthM: number;
|
|
205
|
+
widthM: number;
|
|
206
|
+
};
|
|
207
|
+
type Dent = {
|
|
208
|
+
center: Vec2;
|
|
209
|
+
inward: Vec2;
|
|
210
|
+
depthM: number;
|
|
211
|
+
radiusAlongM: number;
|
|
212
|
+
radiusAcrossM: number;
|
|
213
|
+
};
|
|
214
|
+
type Footprint = ReturnType<typeof vehicleImageFootprint>;
|
|
215
|
+
/** Persistent, local-space panel dents shared by the painted sprite and collision mask. */
|
|
216
|
+
declare class VehicleDamage {
|
|
217
|
+
private dents;
|
|
218
|
+
private revision;
|
|
219
|
+
private enabled;
|
|
220
|
+
private maxDepthM;
|
|
221
|
+
private maskCache;
|
|
222
|
+
private spriteCache;
|
|
223
|
+
captureState(): {
|
|
224
|
+
dents: Dent[];
|
|
225
|
+
revision: number;
|
|
226
|
+
enabled: boolean;
|
|
227
|
+
maxDepthM: number;
|
|
228
|
+
};
|
|
229
|
+
restoreState(state: ReturnType<VehicleDamage['captureState']>): void;
|
|
230
|
+
get hasDamage(): boolean;
|
|
231
|
+
get geometryRevision(): number;
|
|
232
|
+
setEnabled(enabled: boolean): void;
|
|
233
|
+
reset(): void;
|
|
234
|
+
/** The wall normal points into the vehicle; depth caps at 8 CSS pixels. */
|
|
235
|
+
hit(point: Vec2, inward: Vec2, shape: MaskShape, speedMps: number, pixelsPerMeter: number): boolean;
|
|
236
|
+
/** Deform an unrotated, metre-space point on the vehicle. */
|
|
237
|
+
point(point: Vec2): Vec2;
|
|
238
|
+
maskFor(base: VehicleMask): VehicleMask;
|
|
239
|
+
/** Rasterize a triangular texture mesh only when a dent changes. */
|
|
240
|
+
spriteFor(image: HTMLImageElement, footprint: Footprint): HTMLCanvasElement | null;
|
|
241
|
+
private drawTriangle;
|
|
242
|
+
}
|
|
243
|
+
type SideWeaponSprite = {
|
|
244
|
+
image: CanvasImageSource;
|
|
245
|
+
source: {
|
|
246
|
+
x: number;
|
|
247
|
+
y: number;
|
|
248
|
+
width: number;
|
|
249
|
+
height: number;
|
|
250
|
+
};
|
|
251
|
+
lengthM: number;
|
|
252
|
+
widthM: number;
|
|
253
|
+
};
|
|
254
|
+
type Phase$2 = 'idle' | 'opening' | 'raising' | 'igniting' | 'flying' | 'closing';
|
|
255
|
+
type RocketFlight = {
|
|
256
|
+
position: Vec2;
|
|
257
|
+
angle: number;
|
|
258
|
+
speedMps: number;
|
|
259
|
+
distanceM: number;
|
|
260
|
+
age: number;
|
|
261
|
+
};
|
|
262
|
+
type RocketSmoke = {
|
|
263
|
+
point: Vec2;
|
|
264
|
+
flow: Vec2;
|
|
265
|
+
amount: number;
|
|
266
|
+
radiusM: number;
|
|
267
|
+
};
|
|
268
|
+
type RocketJet = {
|
|
269
|
+
from: Vec2;
|
|
270
|
+
to: Vec2;
|
|
271
|
+
flow: Vec2;
|
|
272
|
+
widthM: number;
|
|
273
|
+
intensity: number;
|
|
274
|
+
};
|
|
275
|
+
/** Roof launcher with swept scene impacts and GPU jet emission points. */
|
|
276
|
+
declare class RoofRocket {
|
|
277
|
+
/** Editor inspection opens the actual hatch without arming a projectile. */
|
|
278
|
+
previewOpen: boolean;
|
|
279
|
+
private inspecting;
|
|
280
|
+
private phase;
|
|
281
|
+
private elapsed;
|
|
282
|
+
private held;
|
|
283
|
+
private presetId;
|
|
284
|
+
private flights;
|
|
285
|
+
private launchClock;
|
|
286
|
+
private queuedShots;
|
|
287
|
+
private launches;
|
|
288
|
+
private ignitionDuration;
|
|
289
|
+
captureState(): {
|
|
290
|
+
previewOpen: boolean;
|
|
291
|
+
inspecting: boolean;
|
|
292
|
+
phase: Phase$2;
|
|
293
|
+
elapsed: number;
|
|
294
|
+
held: boolean;
|
|
295
|
+
presetId: string | null;
|
|
296
|
+
flights: RocketFlight[];
|
|
297
|
+
launchClock: number;
|
|
298
|
+
queuedShots: number;
|
|
299
|
+
launches: number;
|
|
300
|
+
ignitionDuration: number;
|
|
301
|
+
};
|
|
302
|
+
restoreState(state: ReturnType<RoofRocket['captureState']>): void;
|
|
303
|
+
get state(): Phase$2;
|
|
304
|
+
get projectile(): {
|
|
305
|
+
position: {
|
|
306
|
+
x: number;
|
|
307
|
+
y: number;
|
|
308
|
+
};
|
|
309
|
+
angle: number;
|
|
310
|
+
speedMps: number;
|
|
311
|
+
distanceM: number;
|
|
312
|
+
age: number;
|
|
313
|
+
} | null;
|
|
314
|
+
get projectileCount(): number;
|
|
315
|
+
get managedBytes(): number;
|
|
316
|
+
get launchCount(): number;
|
|
317
|
+
reset(): void;
|
|
318
|
+
/** Cancel a pending launch while allowing rockets already in flight to finish. */
|
|
319
|
+
disarm(): void;
|
|
320
|
+
private transition;
|
|
321
|
+
step(dt: number, sim: Simulation, emitSmoke: (smoke: RocketSmoke) => void, collide?: (from: Vec2, to: Vec2, radiusM: number) => Vec2 | null, emitJet?: (jet: RocketJet) => void, onLaunch?: (point: Vec2) => void, onImpact?: (point: Vec2) => void, onIgnite?: (point: Vec2) => void): void;
|
|
322
|
+
private get open();
|
|
323
|
+
drawMount(context: CanvasRenderingContext2D, center: Vec2, angle: number, preset: VehiclePreset, zoom: number, opacity?: number, sprite?: SideWeaponSprite): void;
|
|
324
|
+
drawFlight(context: CanvasRenderingContext2D, project: (point: Vec2) => Vec2, preset: VehiclePreset, zoom: number, opacity?: number): void;
|
|
325
|
+
private drawBody;
|
|
326
|
+
}
|
|
327
|
+
type Phase$1 = 'closed' | 'opening' | 'active' | 'closing';
|
|
328
|
+
type Bullet = {
|
|
329
|
+
position: Vec2;
|
|
330
|
+
velocity: Vec2;
|
|
331
|
+
age: number;
|
|
332
|
+
};
|
|
333
|
+
/** The panels reveal the guns while held; only an open, held mount fires. */
|
|
334
|
+
declare class SideMachineGuns {
|
|
335
|
+
private phase;
|
|
336
|
+
private phaseTime;
|
|
337
|
+
private shotClock;
|
|
338
|
+
private flashAge;
|
|
339
|
+
private presetId;
|
|
340
|
+
private bullets;
|
|
341
|
+
captureState(): {
|
|
342
|
+
phase: Phase$1;
|
|
343
|
+
phaseTime: number;
|
|
344
|
+
shotClock: number;
|
|
345
|
+
flashAge: number;
|
|
346
|
+
presetId: string | null;
|
|
347
|
+
bullets: Bullet[];
|
|
348
|
+
};
|
|
349
|
+
restoreState(state: ReturnType<SideMachineGuns['captureState']>): void;
|
|
350
|
+
get state(): Phase$1;
|
|
351
|
+
get openAmount(): number;
|
|
352
|
+
get projectileCount(): number;
|
|
353
|
+
get managedBytes(): number;
|
|
354
|
+
reset(): void;
|
|
355
|
+
step(dt: number, sim: Simulation, collide?: (from: Vec2, to: Vec2, radiusM: number) => Vec2 | null, onShot?: () => void, onImpact?: (point: Vec2, velocity: Vec2) => void): void;
|
|
356
|
+
private fire;
|
|
357
|
+
private get open();
|
|
358
|
+
drawMount(context: CanvasRenderingContext2D, center: Vec2, angle: number, preset: VehiclePreset, zoom: number, opacity?: number, sprite?: SideWeaponSprite): void;
|
|
359
|
+
drawProjectiles(context: CanvasRenderingContext2D, project: (point: Vec2) => Vec2, zoom: number, opacity?: number): void;
|
|
360
|
+
}
|
|
361
|
+
type Phase = 'closed' | 'opening' | 'active' | 'closing';
|
|
362
|
+
type FlameJet = {
|
|
363
|
+
point: Vec2;
|
|
364
|
+
velocity: Vec2;
|
|
365
|
+
traveled: number;
|
|
366
|
+
range: number;
|
|
367
|
+
speed: number;
|
|
368
|
+
width: number;
|
|
369
|
+
};
|
|
370
|
+
/** Twin nozzles emit moving fuel jets and report their actual collision points. */
|
|
371
|
+
declare class SideFlamethrower {
|
|
372
|
+
private phase;
|
|
373
|
+
private phaseTime;
|
|
374
|
+
private emitting;
|
|
375
|
+
private presetId;
|
|
376
|
+
private fireClock;
|
|
377
|
+
private jets;
|
|
378
|
+
captureState(): {
|
|
379
|
+
phase: Phase;
|
|
380
|
+
phaseTime: number;
|
|
381
|
+
emitting: boolean;
|
|
382
|
+
presetId: string | null;
|
|
383
|
+
fireClock: number;
|
|
384
|
+
jets: FlameJet[];
|
|
385
|
+
};
|
|
386
|
+
restoreState(state: ReturnType<SideFlamethrower['captureState']>): void;
|
|
387
|
+
get state(): Phase;
|
|
388
|
+
get firing(): boolean;
|
|
389
|
+
get openAmount(): number;
|
|
390
|
+
get managedBytes(): number;
|
|
391
|
+
reset(): void;
|
|
392
|
+
step(dt: number, sim: Simulation, emitSmoke: (smoke: RocketSmoke) => void, contact?: (from: Vec2, to: Vec2, radiusM: number, seconds: number) => Vec2 | null | void, emitFire?: (from: Vec2, to: Vec2, widthM: number, velocity: Vec2, progress: number) => void): void;
|
|
393
|
+
private get open();
|
|
394
|
+
drawMount(context: CanvasRenderingContext2D, center: Vec2, angle: number, preset: VehiclePreset, zoom: number, opacity?: number, sprite?: SideWeaponSprite): void;
|
|
395
|
+
}
|
|
396
|
+
/** Weapon phases and projectiles belong to a vehicle; the renderer only draws them. */
|
|
397
|
+
declare class VehicleWeapons {
|
|
398
|
+
readonly rocket: RoofRocket;
|
|
399
|
+
readonly machineGuns: SideMachineGuns;
|
|
400
|
+
readonly flamethrower: SideFlamethrower;
|
|
401
|
+
readonly lightning: LightningWeapon;
|
|
402
|
+
reset(): void;
|
|
403
|
+
stopFiring(): void;
|
|
404
|
+
captureState(): {
|
|
405
|
+
rocket: {
|
|
406
|
+
previewOpen: boolean;
|
|
407
|
+
inspecting: boolean;
|
|
408
|
+
phase: "idle" | "opening" | "raising" | "igniting" | "flying" | "closing";
|
|
409
|
+
elapsed: number;
|
|
410
|
+
held: boolean;
|
|
411
|
+
presetId: string | null;
|
|
412
|
+
flights: {
|
|
413
|
+
position: Vec2;
|
|
414
|
+
angle: number;
|
|
415
|
+
speedMps: number;
|
|
416
|
+
distanceM: number;
|
|
417
|
+
age: number;
|
|
418
|
+
}[];
|
|
419
|
+
launchClock: number;
|
|
420
|
+
queuedShots: number;
|
|
421
|
+
launches: number;
|
|
422
|
+
ignitionDuration: number;
|
|
423
|
+
};
|
|
424
|
+
machineGuns: {
|
|
425
|
+
phase: "closed" | "opening" | "closing" | "active";
|
|
426
|
+
phaseTime: number;
|
|
427
|
+
shotClock: number;
|
|
428
|
+
flashAge: number;
|
|
429
|
+
presetId: string | null;
|
|
430
|
+
bullets: {
|
|
431
|
+
position: Vec2;
|
|
432
|
+
velocity: Vec2;
|
|
433
|
+
age: number;
|
|
434
|
+
}[];
|
|
435
|
+
};
|
|
436
|
+
flamethrower: {
|
|
437
|
+
phase: "closed" | "opening" | "closing" | "active";
|
|
438
|
+
phaseTime: number;
|
|
439
|
+
emitting: boolean;
|
|
440
|
+
presetId: string | null;
|
|
441
|
+
fireClock: number;
|
|
442
|
+
jets: {
|
|
443
|
+
point: Vec2;
|
|
444
|
+
velocity: Vec2;
|
|
445
|
+
traveled: number;
|
|
446
|
+
range: number;
|
|
447
|
+
speed: number;
|
|
448
|
+
width: number;
|
|
449
|
+
}[];
|
|
450
|
+
};
|
|
451
|
+
lightning: {
|
|
452
|
+
charging: boolean;
|
|
453
|
+
charge: number;
|
|
454
|
+
target: Vec2 | null;
|
|
455
|
+
dischargeAge: number;
|
|
456
|
+
dischargeId: number;
|
|
457
|
+
dischargeTargets: Vec2[];
|
|
458
|
+
dischargePaths: Vec2[][];
|
|
459
|
+
pending: boolean;
|
|
460
|
+
elapsed: number;
|
|
461
|
+
};
|
|
462
|
+
};
|
|
463
|
+
restoreState(state: ReturnType<VehicleWeapons['captureState']>): void;
|
|
464
|
+
get managedBytes(): number;
|
|
465
|
+
}
|
|
466
|
+
type PageRect = {
|
|
467
|
+
x: number;
|
|
468
|
+
y: number;
|
|
469
|
+
width: number;
|
|
470
|
+
height: number;
|
|
471
|
+
};
|
|
472
|
+
type ViewportRect = {
|
|
473
|
+
left: number;
|
|
474
|
+
top: number;
|
|
475
|
+
width: number;
|
|
476
|
+
height: number;
|
|
477
|
+
};
|
|
478
|
+
type DocumentProjection = {
|
|
479
|
+
readonly scale: number;
|
|
480
|
+
viewportRectToDocument(rect: ViewportRect, offset?: Vec2): PageRect;
|
|
481
|
+
};
|
|
482
|
+
type TourEntry = 'upper-left' | 'upper-middle' | 'upper-right' | 'left' | 'right' | 'lower-left' | 'lower-middle' | 'lower-right';
|
|
483
|
+
type TourStop = {
|
|
484
|
+
/** CSS selector measured when the tour starts. Its center anchors any donuts. */
|
|
485
|
+
selector: string;
|
|
486
|
+
/** Full-throttle, full-lock physics donuts around the element's center. */
|
|
487
|
+
donuts?: number;
|
|
488
|
+
/** Time spent stopped after this target, in milliseconds. */
|
|
489
|
+
pauseAfter?: number;
|
|
490
|
+
/** Extra stand-off for a stop without donuts, in CSS pixels. */
|
|
491
|
+
padding?: number;
|
|
492
|
+
};
|
|
493
|
+
/** A destination can be a selector, a live DOM element, or a stop with tour actions. */
|
|
494
|
+
type TourTarget = string | Element | TourStop | (Omit<TourStop, 'selector'> & {
|
|
495
|
+
element: Element;
|
|
496
|
+
});
|
|
497
|
+
type TourOptions = {
|
|
498
|
+
entry?: TourEntry;
|
|
499
|
+
speedPxPerSecond?: number;
|
|
500
|
+
clockwise?: boolean;
|
|
501
|
+
/** Override the overlay's viewport-wall setting for this run. */
|
|
502
|
+
viewportWalls?: boolean;
|
|
503
|
+
};
|
|
504
|
+
type VehicleTourOptions = Omit<TourOptions, 'entry'>;
|
|
505
|
+
type TourBox = {
|
|
506
|
+
x: number;
|
|
507
|
+
y: number;
|
|
508
|
+
width: number;
|
|
509
|
+
height: number;
|
|
510
|
+
};
|
|
511
|
+
type MeasuredTourStop = TourStop & {
|
|
512
|
+
box: TourBox;
|
|
513
|
+
};
|
|
514
|
+
type TourSample = {
|
|
515
|
+
point: Vec2;
|
|
516
|
+
tangent: Vec2;
|
|
517
|
+
speedPxPerSecond: number;
|
|
518
|
+
stopIndex: number;
|
|
519
|
+
phase: 'approach' | 'donut' | 'pause' | 'complete';
|
|
520
|
+
};
|
|
521
|
+
type Cubic = {
|
|
522
|
+
kind: 'curve';
|
|
523
|
+
from: Vec2;
|
|
524
|
+
control1: Vec2;
|
|
525
|
+
control2: Vec2;
|
|
526
|
+
to: Vec2;
|
|
527
|
+
length: number;
|
|
528
|
+
lengths: number[];
|
|
529
|
+
waypoints: Vec2[];
|
|
530
|
+
speed: number;
|
|
531
|
+
arrivalSpeed: number;
|
|
532
|
+
stopIndex: number;
|
|
533
|
+
phase: 'approach';
|
|
534
|
+
};
|
|
535
|
+
type Donut = {
|
|
536
|
+
kind: 'donut';
|
|
537
|
+
center: Vec2;
|
|
538
|
+
start: Vec2;
|
|
539
|
+
tangent: Vec2;
|
|
540
|
+
radius: number;
|
|
541
|
+
laps: number;
|
|
542
|
+
steer: -1 | 1;
|
|
543
|
+
stopIndex: number;
|
|
544
|
+
};
|
|
545
|
+
type Pause = {
|
|
546
|
+
kind: 'pause';
|
|
547
|
+
point: Vec2;
|
|
548
|
+
tangent: Vec2;
|
|
549
|
+
seconds: number;
|
|
550
|
+
stopIndex: number;
|
|
551
|
+
};
|
|
552
|
+
type Segment = Cubic | Donut | Pause;
|
|
553
|
+
/** Travel splines end near target centers; donuts are run by the vehicle physics. */
|
|
554
|
+
declare function createTourRoute(stops: readonly MeasuredTourStop[], viewport: TourBox, carLengthPx: number, options?: TourOptions, donutRadiusPx?: number): {
|
|
555
|
+
entry: Vec2;
|
|
556
|
+
segments: Segment[];
|
|
557
|
+
lastPoint: Vec2;
|
|
558
|
+
lastTangent: Vec2;
|
|
559
|
+
} | null;
|
|
560
|
+
type TourRoute = NonNullable<ReturnType<typeof createTourRoute>>;
|
|
561
|
+
type VehicleControlSource = 'player' | 'scripted';
|
|
562
|
+
type VehicleBurnFrame = {
|
|
563
|
+
stage: CombustibleStage;
|
|
564
|
+
health: number;
|
|
565
|
+
maxHealth: number;
|
|
566
|
+
key: object;
|
|
567
|
+
burnOriginLocal: Vec2;
|
|
568
|
+
blastAge: number;
|
|
569
|
+
explosionStarted: boolean;
|
|
570
|
+
blastPulse: boolean;
|
|
571
|
+
};
|
|
572
|
+
/** Per-vehicle mutable state. The world owns shared contacts, effects and audio. */
|
|
573
|
+
declare class VehicleEntity {
|
|
574
|
+
readonly id: string;
|
|
575
|
+
readonly sim: Simulation;
|
|
576
|
+
readonly damage: VehicleDamage;
|
|
577
|
+
readonly weapons: VehicleWeapons;
|
|
578
|
+
readonly weaponReserves: WeaponReserves;
|
|
579
|
+
readonly tirePaint: TirePaint;
|
|
580
|
+
private lifecycle;
|
|
581
|
+
controls: Controls;
|
|
582
|
+
controlSource: VehicleControlSource;
|
|
583
|
+
label: string;
|
|
584
|
+
appearance: 'auto' | 'light' | 'dark';
|
|
585
|
+
private slotConfiguration;
|
|
586
|
+
private slotHeld;
|
|
587
|
+
private slotPulses;
|
|
588
|
+
private slotPresses;
|
|
589
|
+
private disposed;
|
|
590
|
+
private previousSlotInput;
|
|
591
|
+
private activeEmitters;
|
|
592
|
+
get slots(): Readonly<VehicleSlots>;
|
|
593
|
+
set slots(configuration: VehicleSlots);
|
|
594
|
+
/** Read the already-resolved emissions after policy and reserve filtering. */
|
|
595
|
+
liquidEmissions(seconds: number): readonly LiquidEmission[];
|
|
596
|
+
useSlot(slot: number): boolean;
|
|
597
|
+
startSlot(slot: number): boolean;
|
|
598
|
+
stopSlot(slot: number): void;
|
|
599
|
+
private clearSlotInput;
|
|
600
|
+
private resolveSlots;
|
|
601
|
+
private tourCommands;
|
|
602
|
+
constructor(id: string, sim: Simulation);
|
|
603
|
+
get lifecycleState(): "drivable" | "destroyed";
|
|
604
|
+
/** Held, per-vehicle phasing state; the world applies it to every contact system. */
|
|
605
|
+
get isGhost(): boolean;
|
|
606
|
+
/** The world binds these commands when a tour planner is installed. */
|
|
607
|
+
bindTourCommands(commands: VehicleEntity['tourCommands']): void;
|
|
608
|
+
driveTo(target: TourTarget, options?: VehicleTourOptions): boolean;
|
|
609
|
+
tour(targets: readonly TourTarget[], options?: VehicleTourOptions): boolean;
|
|
610
|
+
stopTour(): boolean;
|
|
611
|
+
setControls(controls: Controls, source: VehicleControlSource, policy?: VehicleToolPolicy): void;
|
|
612
|
+
step(seconds: number, rpm: number | null | undefined, manualMoved?: boolean): void;
|
|
613
|
+
/** Only crossing a lifecycle boundary sends an XState event. */
|
|
614
|
+
synchronizeLifecycle(): void;
|
|
615
|
+
reset(): void;
|
|
616
|
+
/** Restore health without changing the vehicle's pose or other driving state. */
|
|
617
|
+
restoreHealth(): void;
|
|
618
|
+
setMode(mode: Parameters<Simulation['setMode']>[0]): void;
|
|
619
|
+
setPreset(preset: Parameters<Simulation['setPreset']>[0]): void;
|
|
620
|
+
/** Advances vehicle health and fixed-step respawn timing without rendering. */
|
|
621
|
+
advanceBurn(seconds: number): VehicleBurnFrame | null;
|
|
622
|
+
captureState(): {
|
|
623
|
+
id: string;
|
|
624
|
+
label: string;
|
|
625
|
+
appearance: "light" | "auto" | "dark";
|
|
626
|
+
slots: Readonly<Partial<Record<1 | 4 | 2 | 3 | 5 | 8 | 9 | 7 | 6, false | VehicleSlot>>>;
|
|
627
|
+
slotHeld: (1 | 4 | 2 | 3 | 5 | 8 | 9 | 7 | 6)[];
|
|
628
|
+
slotPulses: (1 | 4 | 2 | 3 | 5 | 8 | 9 | 7 | 6)[];
|
|
629
|
+
slotPresses: (1 | 4 | 2 | 3 | 5 | 8 | 9 | 7 | 6)[];
|
|
630
|
+
previousSlotInput: (1 | 4 | 2 | 3 | 5 | 8 | 9 | 7 | 6)[];
|
|
631
|
+
activeEmitters: {
|
|
632
|
+
slot: SlotNumber;
|
|
633
|
+
liquid: string;
|
|
634
|
+
pulse: boolean;
|
|
635
|
+
rate: number;
|
|
636
|
+
amount: number;
|
|
637
|
+
}[];
|
|
638
|
+
simulation: SimulationState;
|
|
639
|
+
damage: {
|
|
640
|
+
dents: {
|
|
641
|
+
center: Vec2;
|
|
642
|
+
inward: Vec2;
|
|
643
|
+
depthM: number;
|
|
644
|
+
radiusAlongM: number;
|
|
645
|
+
radiusAcrossM: number;
|
|
646
|
+
}[];
|
|
647
|
+
revision: number;
|
|
648
|
+
enabled: boolean;
|
|
649
|
+
maxDepthM: number;
|
|
650
|
+
};
|
|
651
|
+
weapons: {
|
|
652
|
+
rocket: {
|
|
653
|
+
previewOpen: boolean;
|
|
654
|
+
inspecting: boolean;
|
|
655
|
+
phase: "idle" | "opening" | "raising" | "igniting" | "flying" | "closing";
|
|
656
|
+
elapsed: number;
|
|
657
|
+
held: boolean;
|
|
658
|
+
presetId: string | null;
|
|
659
|
+
flights: {
|
|
660
|
+
position: Vec2;
|
|
661
|
+
angle: number;
|
|
662
|
+
speedMps: number;
|
|
663
|
+
distanceM: number;
|
|
664
|
+
age: number;
|
|
665
|
+
}[];
|
|
666
|
+
launchClock: number;
|
|
667
|
+
queuedShots: number;
|
|
668
|
+
launches: number;
|
|
669
|
+
ignitionDuration: number;
|
|
670
|
+
};
|
|
671
|
+
machineGuns: {
|
|
672
|
+
phase: "closed" | "opening" | "closing" | "active";
|
|
673
|
+
phaseTime: number;
|
|
674
|
+
shotClock: number;
|
|
675
|
+
flashAge: number;
|
|
676
|
+
presetId: string | null;
|
|
677
|
+
bullets: {
|
|
678
|
+
position: Vec2;
|
|
679
|
+
velocity: Vec2;
|
|
680
|
+
age: number;
|
|
681
|
+
}[];
|
|
682
|
+
};
|
|
683
|
+
flamethrower: {
|
|
684
|
+
phase: "closed" | "opening" | "closing" | "active";
|
|
685
|
+
phaseTime: number;
|
|
686
|
+
emitting: boolean;
|
|
687
|
+
presetId: string | null;
|
|
688
|
+
fireClock: number;
|
|
689
|
+
jets: {
|
|
690
|
+
point: Vec2;
|
|
691
|
+
velocity: Vec2;
|
|
692
|
+
traveled: number;
|
|
693
|
+
range: number;
|
|
694
|
+
speed: number;
|
|
695
|
+
width: number;
|
|
696
|
+
}[];
|
|
697
|
+
};
|
|
698
|
+
lightning: {
|
|
699
|
+
charging: boolean;
|
|
700
|
+
charge: number;
|
|
701
|
+
target: Vec2 | null;
|
|
702
|
+
dischargeAge: number;
|
|
703
|
+
dischargeId: number;
|
|
704
|
+
dischargeTargets: Vec2[];
|
|
705
|
+
dischargePaths: Vec2[][];
|
|
706
|
+
pending: boolean;
|
|
707
|
+
elapsed: number;
|
|
708
|
+
};
|
|
709
|
+
};
|
|
710
|
+
weaponReserves: {
|
|
711
|
+
enabled: boolean;
|
|
712
|
+
time: number;
|
|
713
|
+
stepScales: [ReserveWeapon, number][];
|
|
714
|
+
reserves: (readonly [ReserveWeapon, {
|
|
715
|
+
readonly fill: number;
|
|
716
|
+
readonly pause: number;
|
|
717
|
+
readonly exhausted: boolean;
|
|
718
|
+
readonly lastUsedAt: number;
|
|
719
|
+
}])[];
|
|
720
|
+
};
|
|
721
|
+
tirePaint: {
|
|
722
|
+
coatings: Map<number, Map<string, TirePaintSource & {
|
|
723
|
+
remaining: number;
|
|
724
|
+
}>>;
|
|
725
|
+
previous: Map<number, Vec2>;
|
|
726
|
+
travelM: Map<number, number>;
|
|
727
|
+
previousLayer: Map<number, boolean>;
|
|
728
|
+
wetPaths: Map<number, {
|
|
729
|
+
marks: TirePaintMark[];
|
|
730
|
+
distanceM: number;
|
|
731
|
+
}>;
|
|
732
|
+
exits: Map<number, {
|
|
733
|
+
distanceM: number;
|
|
734
|
+
lengthM: number;
|
|
735
|
+
}>;
|
|
736
|
+
sprayRemainder: Map<number, number>;
|
|
737
|
+
marks: TirePaintMark[];
|
|
738
|
+
markCount: number;
|
|
739
|
+
};
|
|
740
|
+
controls: Controls;
|
|
741
|
+
controlSource: VehicleControlSource;
|
|
742
|
+
lifecycle: Snapshot<unknown>;
|
|
743
|
+
};
|
|
744
|
+
restoreState(state: ReturnType<VehicleEntity['captureState']>): void;
|
|
745
|
+
dispose(): void;
|
|
746
|
+
}
|
|
747
|
+
type TireAudioContact = {
|
|
748
|
+
skidding: boolean;
|
|
749
|
+
slipMps: number;
|
|
750
|
+
/** Ground speed at this contact patch, including body rotation. */
|
|
751
|
+
speedMps: number;
|
|
752
|
+
/** Wheel circumference speed, including driven spin and rear axle lock. */
|
|
753
|
+
wheelSpeedMps: number;
|
|
754
|
+
loadN: number;
|
|
755
|
+
heat: number;
|
|
756
|
+
grip: number;
|
|
757
|
+
};
|
|
758
|
+
type EngineAudioOptions = {
|
|
759
|
+
idleSound?: boolean;
|
|
760
|
+
masterVolume?: number;
|
|
761
|
+
};
|
|
762
|
+
/** Bridges the visual driving model to Engine_Sim's procedural Web Audio engine. */
|
|
763
|
+
declare class EngineAudio {
|
|
764
|
+
private preset;
|
|
765
|
+
private engine;
|
|
766
|
+
private tires;
|
|
767
|
+
private lifecycle;
|
|
768
|
+
private electric;
|
|
769
|
+
private horn;
|
|
770
|
+
private crashes;
|
|
771
|
+
private flamethrower;
|
|
772
|
+
private boost;
|
|
773
|
+
private rockets;
|
|
774
|
+
private gunshot;
|
|
775
|
+
private ricochets;
|
|
776
|
+
private lastRicochetAt;
|
|
777
|
+
private crunch;
|
|
778
|
+
private combustibleExplosion;
|
|
779
|
+
private burningFire;
|
|
780
|
+
private electricCharge;
|
|
781
|
+
private electricBolt;
|
|
782
|
+
private ghostMode;
|
|
783
|
+
private attractor;
|
|
784
|
+
private fireOutput;
|
|
785
|
+
private hornPressed;
|
|
786
|
+
private output;
|
|
787
|
+
private engineStartPromise;
|
|
788
|
+
private startGateTimer;
|
|
789
|
+
private stopTimer;
|
|
790
|
+
private disposed;
|
|
791
|
+
private stopping;
|
|
792
|
+
private starting;
|
|
793
|
+
private ready;
|
|
794
|
+
private active;
|
|
795
|
+
private idleSound;
|
|
796
|
+
private driving;
|
|
797
|
+
private engineAudible;
|
|
798
|
+
private masterVolume;
|
|
799
|
+
private proximity;
|
|
800
|
+
private appliedVolume;
|
|
801
|
+
private baseLaunchFlareRpm;
|
|
802
|
+
private timeScale;
|
|
803
|
+
get playbackRate(): number;
|
|
804
|
+
setTimeScale(factor: number): void;
|
|
805
|
+
constructor(preset: VehiclePreset, options?: EngineAudioOptions);
|
|
806
|
+
get rpm(): number | null;
|
|
807
|
+
get gear(): number | null;
|
|
808
|
+
/** Visual tailpipe bursts follow the drivetrain's actual exhaust reports. */
|
|
809
|
+
takeExhaustPops(): number[];
|
|
810
|
+
/** The same limiter used by the procedural drivetrain and sound. */
|
|
811
|
+
get redlineRpm(): number | null;
|
|
812
|
+
get outputVolume(): number;
|
|
813
|
+
silenceTires(): void;
|
|
814
|
+
setMasterVolume(volume: number): void;
|
|
815
|
+
setProximity(proximity: number): void;
|
|
816
|
+
private syncOutputVolume;
|
|
817
|
+
/** Call from a click or key press so browsers allow the AudioContext to run. */
|
|
818
|
+
start(): Promise<void>;
|
|
819
|
+
setPreset(preset: VehiclePreset): void;
|
|
820
|
+
/** Hold to sound the selected vehicle's horn; starts audio on the key gesture if needed. */
|
|
821
|
+
setHorn(pressed: boolean): void;
|
|
822
|
+
/** Mirrors actual muzzle emission, after the panels finish opening. */
|
|
823
|
+
setFlamethrowerFiring(firing: boolean): void;
|
|
824
|
+
/** Follow the actual boost impulse, including charged burnout launches. */
|
|
825
|
+
setBoosting(boosting: boolean): void;
|
|
826
|
+
playRocketLaunch(proximity: number): void;
|
|
827
|
+
playRocketExplosion(proximity: number): void;
|
|
828
|
+
playCombustibleExplosion(proximity?: number): void;
|
|
829
|
+
setRocketFlightProximity(proximity: number): void;
|
|
830
|
+
setBurningFireProximity(proximity: number): void;
|
|
831
|
+
setElectricCharge(level: number): void;
|
|
832
|
+
playElectricBolt(proximity?: number): void;
|
|
833
|
+
setGhostMode(active: boolean): void;
|
|
834
|
+
setAttractor(active: boolean): void;
|
|
835
|
+
playCrush(): void;
|
|
836
|
+
playCrash(impactSpeedMps: number): void;
|
|
837
|
+
/** One synthesized report for each twin-gun volley. */
|
|
838
|
+
playGunshot(): void;
|
|
839
|
+
playBulletImpact(proximity?: number): void;
|
|
840
|
+
private applyPreset;
|
|
841
|
+
setIdleSound(enabled: boolean): void;
|
|
842
|
+
private syncEngineVolume;
|
|
843
|
+
setActive(active: boolean): void;
|
|
844
|
+
update(seconds: number, controls: Controls, speedMps: number, skidSlipMps?: number, skidHeat?: number, boostCharge?: number, tireContacts?: readonly TireAudioContact[]): void;
|
|
845
|
+
/** Play the engine wind-down, then release the audio graph. */
|
|
846
|
+
stop(): void;
|
|
847
|
+
dispose(): void;
|
|
848
|
+
}
|
|
849
|
+
declare const distanceDpi: {
|
|
850
|
+
readonly screen: 96;
|
|
851
|
+
readonly print: 300;
|
|
852
|
+
};
|
|
853
|
+
type DistanceDpiMode = keyof typeof distanceDpi;
|
|
854
|
+
type DistanceTotal = {
|
|
855
|
+
pixels: number;
|
|
856
|
+
};
|
|
857
|
+
type DistanceReadout = {
|
|
858
|
+
pixels: number;
|
|
859
|
+
kilometers: number;
|
|
860
|
+
miles: number;
|
|
861
|
+
dpi: number;
|
|
862
|
+
dpiMode: DistanceDpiMode;
|
|
863
|
+
};
|
|
864
|
+
/** Counts simulated travel; callers exclude replay and manual placement. */
|
|
865
|
+
declare class Odometer {
|
|
866
|
+
private readonly store;
|
|
867
|
+
readonly total: DistanceTotal;
|
|
868
|
+
private dirty;
|
|
869
|
+
private mode;
|
|
870
|
+
constructor(store?: Pick<Storage, 'getItem' | 'setItem'> | null);
|
|
871
|
+
add(distanceM: number, pixelsPerMeter: number): void;
|
|
872
|
+
reset(): void;
|
|
873
|
+
get dpiMode(): "screen" | "print";
|
|
874
|
+
captureState(): {
|
|
875
|
+
pixels: number;
|
|
876
|
+
mode: "screen" | "print";
|
|
877
|
+
};
|
|
878
|
+
restoreState(state: ReturnType<Odometer['captureState']>): void;
|
|
879
|
+
get dpi(): 300 | 96;
|
|
880
|
+
cycleDpi(): DistanceReadout;
|
|
881
|
+
flush(): void;
|
|
882
|
+
get kilometers(): number;
|
|
883
|
+
get miles(): number;
|
|
884
|
+
get readout(): DistanceReadout;
|
|
885
|
+
}
|
|
886
|
+
declare const recordingKeys: readonly ["KeyW", "ArrowUp", "KeyS", "ArrowDown", "KeyA", "ArrowLeft", "KeyD", "ArrowRight", "Space", "ShiftLeft", "ShiftRight", "KeyH", "Digit1", "Digit2", "Digit3", "Digit4", "Digit5", "Digit6", "Digit7", "Digit8", "Digit9"];
|
|
887
|
+
type RecordingKey = (typeof recordingKeys)[number];
|
|
888
|
+
type RecordingEvent = {
|
|
889
|
+
atMs: number;
|
|
890
|
+
code: RecordingKey;
|
|
891
|
+
type: 'down' | 'up';
|
|
892
|
+
};
|
|
893
|
+
type JoyRideRecording = {
|
|
894
|
+
format: 'joy-ride-recording';
|
|
895
|
+
version: 2;
|
|
896
|
+
createdAt: string;
|
|
897
|
+
/** Captures the car and its emitter materials; the surrounding host page remains external. */
|
|
898
|
+
vehicle: PortableVehicleConfiguration;
|
|
899
|
+
viewport: {
|
|
900
|
+
widthPx: number;
|
|
901
|
+
heightPx: number;
|
|
902
|
+
pixelsPerMeter: number;
|
|
903
|
+
};
|
|
904
|
+
viewportWalls: boolean;
|
|
905
|
+
initial: {
|
|
906
|
+
xPx: number;
|
|
907
|
+
yPx: number;
|
|
908
|
+
angleRad: number;
|
|
909
|
+
velocityXMps: number;
|
|
910
|
+
velocityYMps: number;
|
|
911
|
+
spinRadPerSecond: number;
|
|
912
|
+
};
|
|
913
|
+
durationMs: number;
|
|
914
|
+
events: RecordingEvent[];
|
|
915
|
+
};
|
|
916
|
+
type RecordingUiMode = 'playback' | 'record';
|
|
917
|
+
/** A structural Canvas 2D surface, shared by browsers, OffscreenCanvas and Node. */
|
|
918
|
+
interface HudContext {
|
|
919
|
+
save(): void;
|
|
920
|
+
restore(): void;
|
|
921
|
+
translate(x: number, y: number): void;
|
|
922
|
+
scale(x: number, y: number): void;
|
|
923
|
+
transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
|
|
924
|
+
beginPath(): void;
|
|
925
|
+
moveTo(x: number, y: number): void;
|
|
926
|
+
lineTo(x: number, y: number): void;
|
|
927
|
+
quadraticCurveTo(cx: number, cy: number, x: number, y: number): void;
|
|
928
|
+
bezierCurveTo(cx1: number, cy1: number, cx2: number, cy2: number, x: number, y: number): void;
|
|
929
|
+
closePath(): void;
|
|
930
|
+
fill(path?: never, rule?: 'evenodd' | 'nonzero'): void;
|
|
931
|
+
stroke(): void;
|
|
932
|
+
rect(x: number, y: number, width: number, height: number): void;
|
|
933
|
+
clip(): void;
|
|
934
|
+
arc(x: number, y: number, radius: number, start: number, end: number): void;
|
|
935
|
+
fillRect(x: number, y: number, width: number, height: number): void;
|
|
936
|
+
clearRect(x: number, y: number, width: number, height: number): void;
|
|
937
|
+
fillStyle: string | object;
|
|
938
|
+
strokeStyle: string | object;
|
|
939
|
+
lineWidth: number;
|
|
940
|
+
globalAlpha: number;
|
|
941
|
+
lineCap: 'butt' | 'round' | 'square';
|
|
942
|
+
lineJoin: 'bevel' | 'round' | 'miter';
|
|
943
|
+
}
|
|
944
|
+
interface HudPalette {
|
|
945
|
+
ink: string;
|
|
946
|
+
text: string;
|
|
947
|
+
muted: string;
|
|
948
|
+
track: string;
|
|
949
|
+
accent: string;
|
|
950
|
+
danger: string;
|
|
951
|
+
health: string;
|
|
952
|
+
ammo: string;
|
|
953
|
+
effect: string;
|
|
954
|
+
}
|
|
955
|
+
interface HudLink {
|
|
956
|
+
id: string;
|
|
957
|
+
label: string;
|
|
958
|
+
ariaLabel?: string;
|
|
959
|
+
strikethrough?: boolean;
|
|
960
|
+
onClick: () => void;
|
|
961
|
+
}
|
|
962
|
+
/** Stable frame anchors plus visibility flags for optional resources. */
|
|
963
|
+
interface HudBackgroundLayout {
|
|
964
|
+
width: number;
|
|
965
|
+
height: number;
|
|
966
|
+
hasRpm: true;
|
|
967
|
+
hasGear: true;
|
|
968
|
+
hasHp: boolean;
|
|
969
|
+
hasAmmo: boolean;
|
|
970
|
+
speedY: number;
|
|
971
|
+
resourceY: number;
|
|
972
|
+
footerY: number;
|
|
973
|
+
linkCount: number;
|
|
974
|
+
}
|
|
975
|
+
interface HudOptions {
|
|
976
|
+
/** Replace only the base ink background; receives logical HUD coordinates.
|
|
977
|
+
* Return false to defer the frame while an asynchronous backing loads. */
|
|
978
|
+
backgroundRenderer?: (context: HudContext, size: {
|
|
979
|
+
width: number;
|
|
980
|
+
height: number;
|
|
981
|
+
}, palette: HudPalette, layout: HudBackgroundLayout) => void | boolean;
|
|
982
|
+
/** Decorative paint spray; hosts can disable it for plain UI. */
|
|
983
|
+
decoration?: boolean;
|
|
984
|
+
mode?: 'dark' | 'light';
|
|
985
|
+
showTotalPoints?: boolean;
|
|
986
|
+
/** Explicit presentation time for deterministic flashing, in milliseconds. */
|
|
987
|
+
timeMs?: number;
|
|
988
|
+
reducedMotion?: boolean;
|
|
989
|
+
colors?: Partial<HudPalette>;
|
|
990
|
+
brand?: string;
|
|
991
|
+
/** Logical drawing coordinates. The caller controls the canvas backing resolution. */
|
|
992
|
+
x?: number;
|
|
993
|
+
y?: number;
|
|
994
|
+
scale?: number;
|
|
995
|
+
/** The host supplies interaction; rendering stays isomorphic and does not invoke callbacks. */
|
|
996
|
+
links?: readonly HudLink[];
|
|
997
|
+
hoveredLink?: string;
|
|
998
|
+
logoMotion?: {
|
|
999
|
+
x: number;
|
|
1000
|
+
y: number;
|
|
1001
|
+
rotation: number;
|
|
1002
|
+
};
|
|
1003
|
+
/** @deprecated Status effects are no longer visualized. */
|
|
1004
|
+
effectSlots?: number;
|
|
1005
|
+
}
|
|
1006
|
+
/** Named easing functions shared by the speed and camera ramps. */
|
|
1007
|
+
type SlowMoCurve = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out';
|
|
1008
|
+
type SlowMoOptions = {
|
|
1009
|
+
/** Simulation seconds per real second. Greater than zero, at most one. */
|
|
1010
|
+
speedFactor: number;
|
|
1011
|
+
/** Real milliseconds for either entering or exiting. Zero switches immediately. */
|
|
1012
|
+
rampMs: number;
|
|
1013
|
+
/** Camera multiplier. Zero disables extra zoom; 1.1 zooms in ten percent. */
|
|
1014
|
+
zoomFactor: number;
|
|
1015
|
+
curve: SlowMoCurve;
|
|
1016
|
+
};
|
|
1017
|
+
type SlowMoState = {
|
|
1018
|
+
options: SlowMoOptions;
|
|
1019
|
+
active: boolean;
|
|
1020
|
+
speed: number;
|
|
1021
|
+
zoom: number;
|
|
1022
|
+
fromSpeed: number;
|
|
1023
|
+
fromZoom: number;
|
|
1024
|
+
elapsed: number;
|
|
1025
|
+
};
|
|
1026
|
+
/** Host-owned presentation clock. advance consumes REAL seconds and returns simulation seconds.
|
|
1027
|
+
* Updates retain their real-time cadence with smaller game-time steps; exclude pause/hidden time. */
|
|
1028
|
+
declare class SlowMo {
|
|
1029
|
+
private settings;
|
|
1030
|
+
private enabled;
|
|
1031
|
+
private speed;
|
|
1032
|
+
private zoom;
|
|
1033
|
+
private fromSpeed;
|
|
1034
|
+
private fromZoom;
|
|
1035
|
+
private elapsed;
|
|
1036
|
+
constructor(options?: Partial<SlowMoOptions>);
|
|
1037
|
+
get options(): Readonly<SlowMoOptions>;
|
|
1038
|
+
get active(): boolean;
|
|
1039
|
+
get speedFactor(): number;
|
|
1040
|
+
get zoomFactor(): number;
|
|
1041
|
+
configure(options: Partial<SlowMoOptions>): void;
|
|
1042
|
+
setActive(active: boolean): void;
|
|
1043
|
+
start(): void;
|
|
1044
|
+
stop(): void;
|
|
1045
|
+
private beginRamp;
|
|
1046
|
+
advance(realSeconds: number): number;
|
|
1047
|
+
reset(): void;
|
|
1048
|
+
captureState(): SlowMoState;
|
|
1049
|
+
restoreState(state: SlowMoState): void;
|
|
1050
|
+
}
|
|
1051
|
+
/** A live piece of destructible ink that can feed GPU fire and embers. */
|
|
1052
|
+
type FireMask = {
|
|
1053
|
+
key: object;
|
|
1054
|
+
alpha: Uint8Array;
|
|
1055
|
+
pixelWidth: number;
|
|
1056
|
+
pixelHeight: number;
|
|
1057
|
+
x: number;
|
|
1058
|
+
y: number;
|
|
1059
|
+
width: number;
|
|
1060
|
+
height: number;
|
|
1061
|
+
angle?: number;
|
|
1062
|
+
origin: Vec2;
|
|
1063
|
+
age: number;
|
|
1064
|
+
farthest: number;
|
|
1065
|
+
spreadSeconds: number;
|
|
1066
|
+
burnSeconds: number;
|
|
1067
|
+
smokeRate?: number;
|
|
1068
|
+
/** Scales fuel injection without enlarging the burning area. */
|
|
1069
|
+
intensity?: number;
|
|
1070
|
+
/** Keeps ignition at one fixed spot while health drains. */
|
|
1071
|
+
fixedRadius?: number;
|
|
1072
|
+
smokeOnly?: boolean;
|
|
1073
|
+
/** A short, full-footprint fuel burst when a combustible object explodes. */
|
|
1074
|
+
blastAge?: number;
|
|
1075
|
+
blastSeconds?: number;
|
|
1076
|
+
revision?: number;
|
|
1077
|
+
};
|
|
1078
|
+
type GhostStyle = 'specter' | 'phantom' | 'wraith';
|
|
1079
|
+
/** An explicit, reusable GPU checkpoint. No pixels cross the CPU/GPU boundary. */
|
|
1080
|
+
declare class WebGLSurfaceState {
|
|
1081
|
+
private readonly gl;
|
|
1082
|
+
readonly width: number;
|
|
1083
|
+
readonly height: number;
|
|
1084
|
+
private readonly texture;
|
|
1085
|
+
private readonly framebuffer;
|
|
1086
|
+
private disposed;
|
|
1087
|
+
constructor(gl: WebGL2RenderingContext, source: WebGLFramebuffer, width: number, height: number, internalFormat: number, type: number);
|
|
1088
|
+
restore(target: WebGLFramebuffer, width?: number, height?: number): void;
|
|
1089
|
+
dispose(): void;
|
|
1090
|
+
}
|
|
1091
|
+
type WebGLFluidState = {
|
|
1092
|
+
velocity: WebGLSurfaceState | null;
|
|
1093
|
+
dye: WebGLSurfaceState | null;
|
|
1094
|
+
width: number;
|
|
1095
|
+
height: number;
|
|
1096
|
+
quality: FluidQuality;
|
|
1097
|
+
view: FluidView | null;
|
|
1098
|
+
active: boolean;
|
|
1099
|
+
sceneFireActive: boolean;
|
|
1100
|
+
idle: number;
|
|
1101
|
+
radialBlasts: {
|
|
1102
|
+
center: Vec2;
|
|
1103
|
+
radius: number;
|
|
1104
|
+
}[];
|
|
1105
|
+
flameOrigin: Vec2;
|
|
1106
|
+
dispose: () => void;
|
|
1107
|
+
};
|
|
1108
|
+
type BurningPoint = {
|
|
1109
|
+
point: Vec2;
|
|
1110
|
+
width: number;
|
|
1111
|
+
age: number;
|
|
1112
|
+
lifetime: number;
|
|
1113
|
+
};
|
|
1114
|
+
type TireFireState = {
|
|
1115
|
+
points: BurningPoint[];
|
|
1116
|
+
dispose: () => void;
|
|
1117
|
+
};
|
|
1118
|
+
/** An authored page shape that becomes one live liquid field. */
|
|
1119
|
+
type LiquidElementSeed = {
|
|
1120
|
+
key: object;
|
|
1121
|
+
signature: string;
|
|
1122
|
+
kind: LiquidKind;
|
|
1123
|
+
color: LiquidColor;
|
|
1124
|
+
profile: LiquidElementProfile;
|
|
1125
|
+
bounds: {
|
|
1126
|
+
x: number;
|
|
1127
|
+
y: number;
|
|
1128
|
+
width: number;
|
|
1129
|
+
height: number;
|
|
1130
|
+
};
|
|
1131
|
+
contains: (point: Vec2) => boolean;
|
|
1132
|
+
};
|
|
1133
|
+
type LiquidElementProfile = {
|
|
1134
|
+
opacity: number;
|
|
1135
|
+
deformation: number;
|
|
1136
|
+
distanceM: number;
|
|
1137
|
+
};
|
|
1138
|
+
type Droplet = {
|
|
1139
|
+
point: Vec2;
|
|
1140
|
+
radius: number;
|
|
1141
|
+
color: LiquidColor;
|
|
1142
|
+
opacity: number;
|
|
1143
|
+
age: number;
|
|
1144
|
+
};
|
|
1145
|
+
type Bounds = {
|
|
1146
|
+
left: number;
|
|
1147
|
+
top: number;
|
|
1148
|
+
right: number;
|
|
1149
|
+
bottom: number;
|
|
1150
|
+
};
|
|
1151
|
+
type LiquidShapeState = {
|
|
1152
|
+
width: number;
|
|
1153
|
+
height: number;
|
|
1154
|
+
cellSizePx: number;
|
|
1155
|
+
active: Bounds | null;
|
|
1156
|
+
pulled: boolean;
|
|
1157
|
+
authored: Uint8Array;
|
|
1158
|
+
deposited: Uint8Array;
|
|
1159
|
+
pigment: Float32Array;
|
|
1160
|
+
colorPixels: Uint8Array;
|
|
1161
|
+
outline: Float32Array;
|
|
1162
|
+
spring: Float32Array;
|
|
1163
|
+
velocity: Float32Array;
|
|
1164
|
+
drops: Droplet[];
|
|
1165
|
+
color: LiquidColor;
|
|
1166
|
+
dispose: () => void;
|
|
1167
|
+
};
|
|
1168
|
+
/** One wet outline for HTML seeds and dispensed liquid. Only deposition adds area. */
|
|
1169
|
+
declare class LiquidShapeField {
|
|
1170
|
+
readonly kind: LiquidKind;
|
|
1171
|
+
width: number;
|
|
1172
|
+
height: number;
|
|
1173
|
+
readonly profile?: LiquidElementProfile | undefined;
|
|
1174
|
+
readonly canvas: HTMLCanvasElement;
|
|
1175
|
+
private splatterCanvas;
|
|
1176
|
+
private splatterBounds;
|
|
1177
|
+
private splatterDirty;
|
|
1178
|
+
readonly material: {
|
|
1179
|
+
thickness: number;
|
|
1180
|
+
deformation: number;
|
|
1181
|
+
alpha: number;
|
|
1182
|
+
};
|
|
1183
|
+
private authored;
|
|
1184
|
+
private deposited;
|
|
1185
|
+
private pigment;
|
|
1186
|
+
private colorPixels;
|
|
1187
|
+
private basePixels;
|
|
1188
|
+
private outline;
|
|
1189
|
+
private spring;
|
|
1190
|
+
private velocity;
|
|
1191
|
+
private drops;
|
|
1192
|
+
private burnDecay;
|
|
1193
|
+
private revision;
|
|
1194
|
+
private pulled;
|
|
1195
|
+
private maxOutline;
|
|
1196
|
+
private presented;
|
|
1197
|
+
private active;
|
|
1198
|
+
private activeCells;
|
|
1199
|
+
private outlineCells;
|
|
1200
|
+
private wetBounds;
|
|
1201
|
+
private renderedBounds;
|
|
1202
|
+
private dirtyBounds;
|
|
1203
|
+
private fullDirty;
|
|
1204
|
+
private color;
|
|
1205
|
+
private readonly appearance;
|
|
1206
|
+
private cellSizePx;
|
|
1207
|
+
private listeners;
|
|
1208
|
+
constructor(kind: LiquidKind, width: number, height: number, color: LiquidColor, profile?: LiquidElementProfile | undefined);
|
|
1209
|
+
get shapeRevision(): number;
|
|
1210
|
+
get displaced(): boolean;
|
|
1211
|
+
get moving(): boolean;
|
|
1212
|
+
get hasSplatter(): boolean;
|
|
1213
|
+
get hasDeposits(): boolean;
|
|
1214
|
+
get managedBytes(): number;
|
|
1215
|
+
setCellSize(pixels: number): void;
|
|
1216
|
+
configure(color: LiquidColor, profile?: LiquidElementProfile): void;
|
|
1217
|
+
onChange(listener: () => void): () => boolean;
|
|
1218
|
+
private changed;
|
|
1219
|
+
private alphaAt;
|
|
1220
|
+
private refreshBasePixel;
|
|
1221
|
+
private rebuildBasePixels;
|
|
1222
|
+
private wetAt;
|
|
1223
|
+
private includeWetBounds;
|
|
1224
|
+
private rebuildWetBounds;
|
|
1225
|
+
private componentAt;
|
|
1226
|
+
offsetAt(point: Vec2, persistent?: boolean): Vec2;
|
|
1227
|
+
private sourcePoint;
|
|
1228
|
+
private rawCoverage;
|
|
1229
|
+
private rawCoverageXY;
|
|
1230
|
+
densityAt(point: Vec2): number;
|
|
1231
|
+
colorAt(point: Vec2): LiquidColor;
|
|
1232
|
+
captureFuel(): Float32Array<ArrayBuffer>;
|
|
1233
|
+
inspectState(): {
|
|
1234
|
+
volume: number;
|
|
1235
|
+
minimum: number;
|
|
1236
|
+
maximum: number;
|
|
1237
|
+
finite: boolean;
|
|
1238
|
+
};
|
|
1239
|
+
private setPigment;
|
|
1240
|
+
seedMask(mask: Uint8Array, _depth: number, _amount: number, color?: LiquidColor): void;
|
|
1241
|
+
removeSeed(): void;
|
|
1242
|
+
/** Add a continuous, tapered swept deposit to the existing outline. */
|
|
1243
|
+
pour(amount: number, _seed: number, point: Vec2, radius: number, _flow: Vec2, color?: LiquidColor, from?: Vec2, fromRadius?: number): void;
|
|
1244
|
+
transferPigment(from: Vec2, to: Vec2, radius: number, color: LiquidColor, strength: number): void;
|
|
1245
|
+
private eachContactPixel;
|
|
1246
|
+
drag(from: Vec2, to: Vec2, _dt: number, radius?: number, _trackOffset?: number): void;
|
|
1247
|
+
step(dt: number, burnRate?: number, _burnPoints?: readonly {
|
|
1248
|
+
point: Vec2;
|
|
1249
|
+
radius: number;
|
|
1250
|
+
}[], burnMask?: {
|
|
1251
|
+
size: number;
|
|
1252
|
+
rates: Float32Array;
|
|
1253
|
+
}, burnElapsed?: number): void;
|
|
1254
|
+
mayIntersect(from: Vec2, to: Vec2, radius?: number): boolean;
|
|
1255
|
+
spray(point: Vec2, direction: Vec2, radius: number, amount: number, energy?: number, color?: LiquidColor): void;
|
|
1256
|
+
/** Expand storage without resampling existing geometry or displacement. */
|
|
1257
|
+
grow(factor: number): number;
|
|
1258
|
+
setColor(color: LiquidColor): void;
|
|
1259
|
+
reset(): void;
|
|
1260
|
+
captureState(): LiquidShapeState;
|
|
1261
|
+
restoreState(state: LiquidShapeState): void;
|
|
1262
|
+
dispose(): void;
|
|
1263
|
+
private paintUnshaded;
|
|
1264
|
+
private present;
|
|
1265
|
+
draw(context: CanvasRenderingContext2D): void;
|
|
1266
|
+
drawSplatter(context: CanvasRenderingContext2D): void;
|
|
1267
|
+
}
|
|
1268
|
+
/** Coarse fuel cells share a full-resolution silhouette; no readback is needed while burning. */
|
|
1269
|
+
declare class LiquidFire {
|
|
1270
|
+
readonly density: Float32Array;
|
|
1271
|
+
readonly resolution: number;
|
|
1272
|
+
readonly rect: {
|
|
1273
|
+
x: number;
|
|
1274
|
+
y: number;
|
|
1275
|
+
width: number;
|
|
1276
|
+
height: number;
|
|
1277
|
+
};
|
|
1278
|
+
readonly lifetime: number;
|
|
1279
|
+
readonly spreadMps: number;
|
|
1280
|
+
readonly pixelsPerMeter: number;
|
|
1281
|
+
readonly size: number;
|
|
1282
|
+
readonly fuel: Float32Array;
|
|
1283
|
+
readonly starts: Float64Array;
|
|
1284
|
+
readonly ends: Float64Array;
|
|
1285
|
+
readonly rates: Float32Array;
|
|
1286
|
+
readonly alpha: Uint8Array;
|
|
1287
|
+
private readonly baseAlpha;
|
|
1288
|
+
private readonly light;
|
|
1289
|
+
private readonly pixelsByCell;
|
|
1290
|
+
revision: number;
|
|
1291
|
+
complete: boolean;
|
|
1292
|
+
lit: boolean;
|
|
1293
|
+
constructor(density: Float32Array, resolution: number, rect: {
|
|
1294
|
+
x: number;
|
|
1295
|
+
y: number;
|
|
1296
|
+
width: number;
|
|
1297
|
+
height: number;
|
|
1298
|
+
}, lifetime: number, spreadMps: number, pixelsPerMeter: number);
|
|
1299
|
+
point(index: number): Vec2;
|
|
1300
|
+
get spacing(): number;
|
|
1301
|
+
get managedBytes(): number;
|
|
1302
|
+
indexAt(point: Vec2): number;
|
|
1303
|
+
/** Re-sampling after new fuel is poured preserves the existing front and remaining lifetime. */
|
|
1304
|
+
inherit(previous: LiquidFire, time: number): void;
|
|
1305
|
+
update(time: number, dt: number): boolean;
|
|
1306
|
+
}
|
|
1307
|
+
type GroundField = {
|
|
1308
|
+
id: number;
|
|
1309
|
+
seedKey?: string;
|
|
1310
|
+
elementProfile?: LiquidElementProfile;
|
|
1311
|
+
kind: LiquidKind;
|
|
1312
|
+
color: LiquidColor;
|
|
1313
|
+
center: Vec2;
|
|
1314
|
+
pixelsPerMeter: number;
|
|
1315
|
+
resolution: number;
|
|
1316
|
+
extentM: number;
|
|
1317
|
+
fluid: LiquidShapeField;
|
|
1318
|
+
poured: number;
|
|
1319
|
+
fire?: LiquidFire;
|
|
1320
|
+
firePoured?: number;
|
|
1321
|
+
fireSampleAt?: number;
|
|
1322
|
+
fireUpdatedAt?: number;
|
|
1323
|
+
firePendingElapsed?: number;
|
|
1324
|
+
};
|
|
1325
|
+
type LiquidContact = {
|
|
1326
|
+
/** Actual liquid recipes under the tire, including custom kinds. */
|
|
1327
|
+
materials: LiquidKind[];
|
|
1328
|
+
paint: TirePaintSource | null;
|
|
1329
|
+
/** Only live liquid fields provide pickup; splatters and tread marks never do. */
|
|
1330
|
+
paints: TirePaintSource[];
|
|
1331
|
+
splashFieldId: number | null;
|
|
1332
|
+
};
|
|
1333
|
+
type TreadStamp = {
|
|
1334
|
+
point: Vec2;
|
|
1335
|
+
direction: Vec2;
|
|
1336
|
+
length: number;
|
|
1337
|
+
opacity: number;
|
|
1338
|
+
shoulder: number;
|
|
1339
|
+
};
|
|
1340
|
+
type SkidPath = {
|
|
1341
|
+
/** Asphalt scuffs keep their light ink independently of the page theme. */
|
|
1342
|
+
road?: boolean;
|
|
1343
|
+
points: Vec2[];
|
|
1344
|
+
stamps: TreadStamp[];
|
|
1345
|
+
contactStamps: number;
|
|
1346
|
+
widthM: number;
|
|
1347
|
+
/** Page-space width captured when this mark was laid down. */
|
|
1348
|
+
widthPx: number;
|
|
1349
|
+
opacity: number;
|
|
1350
|
+
nextStamp: number;
|
|
1351
|
+
bounds: {
|
|
1352
|
+
left: number;
|
|
1353
|
+
right: number;
|
|
1354
|
+
bottom: number;
|
|
1355
|
+
top: number;
|
|
1356
|
+
};
|
|
1357
|
+
};
|
|
1358
|
+
type ElectricalSparkPalette = {
|
|
1359
|
+
color: readonly [number, number, number];
|
|
1360
|
+
corona: readonly [number, number, number];
|
|
1361
|
+
};
|
|
1362
|
+
type ScreenShakeEvent = 'crashLow' | 'crashMedium' | 'crashFast' | 'rocketExplosion' | 'combustibleExplosion' | 'lightning';
|
|
1363
|
+
type ScreenShakeProfile = {
|
|
1364
|
+
/** Peak camera displacement, in CSS pixels. */
|
|
1365
|
+
amplitudePx: number;
|
|
1366
|
+
/** The impulse dies away within this many milliseconds. */
|
|
1367
|
+
durationMs: number;
|
|
1368
|
+
/** Oscillation speed; the two axes use slightly different frequencies. */
|
|
1369
|
+
frequencyHz: number;
|
|
1370
|
+
};
|
|
1371
|
+
type ScreenShakeProfiles = Record<ScreenShakeEvent, ScreenShakeProfile>;
|
|
1372
|
+
type ScreenShakeProfileOverrides = Partial<{ [Event in ScreenShakeEvent]: Partial<ScreenShakeProfile>; }>;
|
|
1373
|
+
type SparkImpact = {
|
|
1374
|
+
/** Contact, velocity, and inward-facing normal in document pixels. */
|
|
1375
|
+
point: Vec2;
|
|
1376
|
+
velocity: Vec2;
|
|
1377
|
+
normal: Vec2;
|
|
1378
|
+
/** Outward normal of the painted vehicle at the contact. */
|
|
1379
|
+
carNormal?: Vec2;
|
|
1380
|
+
/** The actual solid rectangle, when the impact is a DOM wall. */
|
|
1381
|
+
wall?: MaskRect;
|
|
1382
|
+
pixelsPerMeter: number;
|
|
1383
|
+
};
|
|
1384
|
+
type Rect = {
|
|
1385
|
+
x: number;
|
|
1386
|
+
y: number;
|
|
1387
|
+
width: number;
|
|
1388
|
+
height: number;
|
|
1389
|
+
};
|
|
1390
|
+
type FireBehavior = Pick<Required<FlamethrowerProfile>, 'ignitionSeconds' | 'spreadSeconds' | 'spreadRadiusPx' | 'burnSeconds' | 'smokePerSecond'>;
|
|
1391
|
+
/** A burning point that can ignite another material at the edge of its footprint. */
|
|
1392
|
+
type FireSource = {
|
|
1393
|
+
point: Vec2;
|
|
1394
|
+
radiusPx: number;
|
|
1395
|
+
/** Outgoing propagation time; receivers own their ignition threshold. */
|
|
1396
|
+
spreadSeconds?: number;
|
|
1397
|
+
profile?: FireBehavior;
|
|
1398
|
+
bounds?: Rect;
|
|
1399
|
+
mask?: {
|
|
1400
|
+
alpha: Uint8Array;
|
|
1401
|
+
pixelWidth: number;
|
|
1402
|
+
pixelHeight: number;
|
|
1403
|
+
origin: Vec2;
|
|
1404
|
+
frontRadius: number;
|
|
1405
|
+
};
|
|
1406
|
+
};
|
|
1407
|
+
type TrailPoint = {
|
|
1408
|
+
point: Vec2;
|
|
1409
|
+
age: number;
|
|
1410
|
+
color: string;
|
|
1411
|
+
};
|
|
1412
|
+
type PointPuff = {
|
|
1413
|
+
point: Vec2;
|
|
1414
|
+
amount: number;
|
|
1415
|
+
age: number;
|
|
1416
|
+
};
|
|
1417
|
+
type RendererEffectsInput = {
|
|
1418
|
+
walls?: readonly FluidWall[];
|
|
1419
|
+
carMask?: VehicleMask;
|
|
1420
|
+
tirePaintSources?: readonly (TirePaintSource | null)[] | ((points: readonly Vec2[]) => (TirePaintSource | null)[]);
|
|
1421
|
+
driven?: boolean;
|
|
1422
|
+
rocketCollision?: (vehicle: VehicleEntity, from: Vec2, to: Vec2, radiusPx: number) => Vec2 | null;
|
|
1423
|
+
bulletCollision?: (vehicle: VehicleEntity, from: Vec2, to: Vec2, radiusPx: number) => Vec2 | null;
|
|
1424
|
+
onGunshot?: () => void;
|
|
1425
|
+
flameContact?: (vehicle: VehicleEntity, from: Vec2, to: Vec2, radiusPx: number, seconds: number) => Vec2 | null;
|
|
1426
|
+
onRocketLaunch?: (point: Vec2) => void;
|
|
1427
|
+
onRocketImpact?: (point: Vec2) => void;
|
|
1428
|
+
onBulletImpact?: (point: Vec2) => void;
|
|
1429
|
+
maskFor?: (vehicle: VehicleEntity) => VehicleMask;
|
|
1430
|
+
companions?: readonly VehicleEntity[];
|
|
1431
|
+
};
|
|
1432
|
+
type ManagedMemoryGroup = {
|
|
1433
|
+
label: string;
|
|
1434
|
+
bytes: number;
|
|
1435
|
+
};
|
|
1436
|
+
declare class Renderer {
|
|
1437
|
+
private overlay;
|
|
1438
|
+
private canvasWorld;
|
|
1439
|
+
carVisualOffset(sim: Simulation): Vec2;
|
|
1440
|
+
get cameraLock(): boolean;
|
|
1441
|
+
set cameraLock(value: boolean);
|
|
1442
|
+
get cameraSmoothing(): number;
|
|
1443
|
+
set cameraSmoothing(value: number);
|
|
1444
|
+
get deadZone(): boolean;
|
|
1445
|
+
set deadZone(value: boolean);
|
|
1446
|
+
get speedZoom(): SpeedZoomMode;
|
|
1447
|
+
set speedZoom(value: SpeedZoomMode);
|
|
1448
|
+
get speedZoomMinimumScale(): number;
|
|
1449
|
+
set speedZoomMinimumScale(value: number);
|
|
1450
|
+
screen(point: Vec2): Vec2;
|
|
1451
|
+
world(point: Vec2): Vec2;
|
|
1452
|
+
vehicleViewportPosition(point: Vec2): Vec2;
|
|
1453
|
+
sceneScroll(): Vec2;
|
|
1454
|
+
get documentProjection(): DocumentProjection;
|
|
1455
|
+
virtualOffset(): Vec2;
|
|
1456
|
+
documentPoint(point: Vec2): Vec2;
|
|
1457
|
+
worldFromDocument(point: Vec2): Vec2;
|
|
1458
|
+
documentScale(): number;
|
|
1459
|
+
viewportSize(): {
|
|
1460
|
+
width: number;
|
|
1461
|
+
height: number;
|
|
1462
|
+
};
|
|
1463
|
+
presentationScale(): number;
|
|
1464
|
+
setSlowMoZoom(scale: number): void;
|
|
1465
|
+
setCanvasWorldScale(scale: number, maximumScale?: number): void;
|
|
1466
|
+
setCameraFrame(frame: {
|
|
1467
|
+
x: number;
|
|
1468
|
+
y: number;
|
|
1469
|
+
width: number;
|
|
1470
|
+
height: number;
|
|
1471
|
+
} | null): void;
|
|
1472
|
+
setCameraLock(enabled: boolean): void;
|
|
1473
|
+
viewportFromDocument(point: Vec2): Vec2;
|
|
1474
|
+
documentFromViewport(point: Vec2): Vec2;
|
|
1475
|
+
bounds(): {
|
|
1476
|
+
left: number;
|
|
1477
|
+
right: number;
|
|
1478
|
+
bottom: number;
|
|
1479
|
+
top: number;
|
|
1480
|
+
};
|
|
1481
|
+
vehicleMarkerAt(point: Vec2): VehicleEntity | null;
|
|
1482
|
+
revealVehicle(sim: Simulation): void;
|
|
1483
|
+
resumeFollow(): void;
|
|
1484
|
+
interruptFollow(): void;
|
|
1485
|
+
restorePage(sim: Simulation): void;
|
|
1486
|
+
followDocument(sim: Simulation): boolean;
|
|
1487
|
+
/** A host can render the parked car in DOM without drawing a duplicate live sprite. */
|
|
1488
|
+
primaryVehicleVisible: boolean;
|
|
1489
|
+
primaryVehicleOpacity: number;
|
|
1490
|
+
beginVehicleArrivalFade(): void;
|
|
1491
|
+
setVehicleArrivalOpacity(opacity: number): void;
|
|
1492
|
+
private readonly view;
|
|
1493
|
+
private readonly surface;
|
|
1494
|
+
private readonly vehicles;
|
|
1495
|
+
readonly debris: Debris;
|
|
1496
|
+
private get ctx();
|
|
1497
|
+
private nextHistoryPrune;
|
|
1498
|
+
private trailClock;
|
|
1499
|
+
private quality;
|
|
1500
|
+
private readonly fluidGovernor;
|
|
1501
|
+
private vehicleLights;
|
|
1502
|
+
private surfaceTones;
|
|
1503
|
+
private vehicleLighting;
|
|
1504
|
+
setVehicleLighting(options: Partial<VehicleLightingOptions>): void;
|
|
1505
|
+
getVehicleLighting(): VehicleLightingOptions;
|
|
1506
|
+
toggleVehicleLight(light: VehicleLightToggle): VehicleLightingOptions;
|
|
1507
|
+
private surfaceTone;
|
|
1508
|
+
private trail;
|
|
1509
|
+
private skidTracks;
|
|
1510
|
+
private volumetrics;
|
|
1511
|
+
private pointPuffs;
|
|
1512
|
+
private objectGlint;
|
|
1513
|
+
private showVehicleMarkers;
|
|
1514
|
+
private tireSmokeEnabled;
|
|
1515
|
+
private vehicleShadowsEnabled;
|
|
1516
|
+
private effectsFadeStartedAt;
|
|
1517
|
+
private wallRects;
|
|
1518
|
+
private combustion;
|
|
1519
|
+
private ghostVehicles;
|
|
1520
|
+
private sparks;
|
|
1521
|
+
private electricity;
|
|
1522
|
+
private liquidLayer;
|
|
1523
|
+
private tireMarks;
|
|
1524
|
+
/** Preload persistent document-space marks for a dense rendering benchmark. */
|
|
1525
|
+
seedGroundMarks(marks: readonly TirePaintMark[]): void;
|
|
1526
|
+
private focusVehicle;
|
|
1527
|
+
private activeVehicles;
|
|
1528
|
+
/** Focus is used by host commands; effect and draw passes receive their vehicle explicitly. */
|
|
1529
|
+
bindVehicle(vehicle: VehicleEntity): void;
|
|
1530
|
+
forgetVehicle(id: string): void;
|
|
1531
|
+
get rocketFlightPosition(): Vec2 | null;
|
|
1532
|
+
private screenShake;
|
|
1533
|
+
private exhaustBursts;
|
|
1534
|
+
queueExhaustPops(pops: readonly number[]): void;
|
|
1535
|
+
private lastFlowCenter;
|
|
1536
|
+
private flowVelocity;
|
|
1537
|
+
/** Expensive only when requested: live GPU surfaces are copied GPU-to-GPU. */
|
|
1538
|
+
captureState(): {
|
|
1539
|
+
at: number;
|
|
1540
|
+
data: {
|
|
1541
|
+
primaryVehicleVisible: boolean;
|
|
1542
|
+
primaryVehicleOpacity: number;
|
|
1543
|
+
nextHistoryPrune: number;
|
|
1544
|
+
trailClock: number;
|
|
1545
|
+
quality: FluidQuality;
|
|
1546
|
+
fluidQualityLimit: FluidQuality;
|
|
1547
|
+
vehicleLighting: VehicleLightingOptions;
|
|
1548
|
+
surfaceTone: SurfaceTone;
|
|
1549
|
+
trail: TrailPoint[];
|
|
1550
|
+
pointPuffs: PointPuff[];
|
|
1551
|
+
showVehicleMarkers: boolean;
|
|
1552
|
+
tireSmokeEnabled: boolean;
|
|
1553
|
+
vehicleShadowsEnabled: boolean;
|
|
1554
|
+
effectsFadeStartedAt: number | null;
|
|
1555
|
+
wallRects: readonly FluidWall[];
|
|
1556
|
+
exhaustBursts: {
|
|
1557
|
+
age: number;
|
|
1558
|
+
lifetime: number;
|
|
1559
|
+
intensity: number;
|
|
1560
|
+
}[];
|
|
1561
|
+
lastFlowCenter: Vec2 | null;
|
|
1562
|
+
flowVelocity: Vec2;
|
|
1563
|
+
debugDrive: boolean;
|
|
1564
|
+
previewGroundFire: boolean;
|
|
1565
|
+
previewWallSmoke: boolean;
|
|
1566
|
+
previewSparks: boolean;
|
|
1567
|
+
previewDamage: boolean;
|
|
1568
|
+
previewOil: boolean;
|
|
1569
|
+
previewOilSplatter: boolean;
|
|
1570
|
+
oilSplatterPreviewSeconds: number;
|
|
1571
|
+
sparkPreviewClock: number;
|
|
1572
|
+
damagePreviewApplied: boolean;
|
|
1573
|
+
groundFirePreviewLit: boolean;
|
|
1574
|
+
tourDebug: {
|
|
1575
|
+
route: TourRoute;
|
|
1576
|
+
stops: readonly MeasuredTourStop[];
|
|
1577
|
+
} | null;
|
|
1578
|
+
trailLifetime: number;
|
|
1579
|
+
fallbackSurfaceTone: {
|
|
1580
|
+
at: number;
|
|
1581
|
+
dark: boolean;
|
|
1582
|
+
};
|
|
1583
|
+
};
|
|
1584
|
+
camera: {
|
|
1585
|
+
outputWidth: number;
|
|
1586
|
+
outputHeight: number;
|
|
1587
|
+
cameraRotation: number;
|
|
1588
|
+
cameraLock: boolean;
|
|
1589
|
+
cameraSmoothing: number;
|
|
1590
|
+
cameraLockInitialized: boolean;
|
|
1591
|
+
width: number;
|
|
1592
|
+
height: number;
|
|
1593
|
+
dpr: number;
|
|
1594
|
+
smokeMargin: number;
|
|
1595
|
+
regionScale: number;
|
|
1596
|
+
canvasWorldScale: number;
|
|
1597
|
+
cameraFrame: {
|
|
1598
|
+
x: number;
|
|
1599
|
+
y: number;
|
|
1600
|
+
width: number;
|
|
1601
|
+
height: number;
|
|
1602
|
+
} | null;
|
|
1603
|
+
camera: Vec2;
|
|
1604
|
+
zoom: number;
|
|
1605
|
+
baseZoom: number;
|
|
1606
|
+
speedScale: number;
|
|
1607
|
+
slowMoScale: number;
|
|
1608
|
+
zoomAnchor: Vec2;
|
|
1609
|
+
pageSize: {
|
|
1610
|
+
width: number;
|
|
1611
|
+
height: number;
|
|
1612
|
+
};
|
|
1613
|
+
lastFrame: number;
|
|
1614
|
+
speedSamples: {
|
|
1615
|
+
time: number;
|
|
1616
|
+
speed: number;
|
|
1617
|
+
}[];
|
|
1618
|
+
originScroll: Vec2;
|
|
1619
|
+
observedScroll: Vec2;
|
|
1620
|
+
virtualScroll: Vec2;
|
|
1621
|
+
followInterrupted: boolean;
|
|
1622
|
+
deadZone: boolean;
|
|
1623
|
+
speedZoom: SpeedZoomMode;
|
|
1624
|
+
speedZoomMinimumScale: number;
|
|
1625
|
+
};
|
|
1626
|
+
diagnostics: {
|
|
1627
|
+
frameStart: number | null;
|
|
1628
|
+
lastFrame: number | null;
|
|
1629
|
+
frames: number;
|
|
1630
|
+
fps: number;
|
|
1631
|
+
};
|
|
1632
|
+
vehicles: {
|
|
1633
|
+
previousCarVelocity: Vec2 | null;
|
|
1634
|
+
poseOffset: Vec2;
|
|
1635
|
+
poseVelocity: Vec2;
|
|
1636
|
+
poseForce: Vec2;
|
|
1637
|
+
wheelPhase: number[];
|
|
1638
|
+
};
|
|
1639
|
+
volumetrics: {
|
|
1640
|
+
smoke: WebGLFluidState | null;
|
|
1641
|
+
ghost: WebGLFluidState | null;
|
|
1642
|
+
sources: {
|
|
1643
|
+
point: {
|
|
1644
|
+
x: number;
|
|
1645
|
+
y: number;
|
|
1646
|
+
};
|
|
1647
|
+
flow: {
|
|
1648
|
+
x: number;
|
|
1649
|
+
y: number;
|
|
1650
|
+
};
|
|
1651
|
+
amount: number;
|
|
1652
|
+
radiusPx: number;
|
|
1653
|
+
swirlPx: number;
|
|
1654
|
+
}[];
|
|
1655
|
+
smokeClock: number;
|
|
1656
|
+
ghostAttempted: boolean;
|
|
1657
|
+
ghostClock: number;
|
|
1658
|
+
ghostStyle: GhostStyle;
|
|
1659
|
+
ghostWallCoverage: Map<string, number>;
|
|
1660
|
+
ghostEmergence: Map<string, number>;
|
|
1661
|
+
dispose: () => void;
|
|
1662
|
+
};
|
|
1663
|
+
combustion: {
|
|
1664
|
+
tireFire: TireFireState;
|
|
1665
|
+
flame: WebGLFluidState | null;
|
|
1666
|
+
fluidAttempted: boolean;
|
|
1667
|
+
fluidClock: number;
|
|
1668
|
+
hadSceneMasks: boolean;
|
|
1669
|
+
stamps: {
|
|
1670
|
+
point: {
|
|
1671
|
+
x: number;
|
|
1672
|
+
y: number;
|
|
1673
|
+
};
|
|
1674
|
+
flow: {
|
|
1675
|
+
x: number;
|
|
1676
|
+
y: number;
|
|
1677
|
+
};
|
|
1678
|
+
radius: number;
|
|
1679
|
+
progress: number;
|
|
1680
|
+
blast?: boolean;
|
|
1681
|
+
strength?: number;
|
|
1682
|
+
source?: "rocket";
|
|
1683
|
+
stir?: boolean;
|
|
1684
|
+
}[];
|
|
1685
|
+
blasts: {
|
|
1686
|
+
point: {
|
|
1687
|
+
x: number;
|
|
1688
|
+
y: number;
|
|
1689
|
+
};
|
|
1690
|
+
radius: number;
|
|
1691
|
+
}[];
|
|
1692
|
+
previousFireTire: Map<number, {
|
|
1693
|
+
x: number;
|
|
1694
|
+
y: number;
|
|
1695
|
+
}>;
|
|
1696
|
+
fireRefreshClock: number;
|
|
1697
|
+
dispose: () => void;
|
|
1698
|
+
};
|
|
1699
|
+
liquids: {
|
|
1700
|
+
fields: {
|
|
1701
|
+
fields: {
|
|
1702
|
+
meta: Omit<GroundField, "fluid">;
|
|
1703
|
+
fluid: LiquidShapeState;
|
|
1704
|
+
}[];
|
|
1705
|
+
clock: number;
|
|
1706
|
+
fireTime: number;
|
|
1707
|
+
nextId: number;
|
|
1708
|
+
lastPours: Map<string, {
|
|
1709
|
+
kind: LiquidKind;
|
|
1710
|
+
color: LiquidColor;
|
|
1711
|
+
point: Vec2;
|
|
1712
|
+
age: number;
|
|
1713
|
+
localAmount: number;
|
|
1714
|
+
radiusM: number;
|
|
1715
|
+
}>;
|
|
1716
|
+
lastFirePlan: number;
|
|
1717
|
+
seam: {
|
|
1718
|
+
previousId: number;
|
|
1719
|
+
currentId: number;
|
|
1720
|
+
point: Vec2;
|
|
1721
|
+
} | null;
|
|
1722
|
+
wheelContacts: LiquidContact[];
|
|
1723
|
+
splashFields: Map<number, number>;
|
|
1724
|
+
quality: FluidQuality;
|
|
1725
|
+
dispose: () => void;
|
|
1726
|
+
};
|
|
1727
|
+
authoring: {
|
|
1728
|
+
elementFields: Map<object, {
|
|
1729
|
+
id: string;
|
|
1730
|
+
signature: string;
|
|
1731
|
+
center: Vec2;
|
|
1732
|
+
}>;
|
|
1733
|
+
nextElementId: number;
|
|
1734
|
+
initialPuddles: {
|
|
1735
|
+
kind: LiquidKind;
|
|
1736
|
+
color?: LiquidColor;
|
|
1737
|
+
point: Vec2;
|
|
1738
|
+
amount: number;
|
|
1739
|
+
}[];
|
|
1740
|
+
};
|
|
1741
|
+
dispose: () => void;
|
|
1742
|
+
};
|
|
1743
|
+
debris: {
|
|
1744
|
+
groups: Map<string, {
|
|
1745
|
+
options: Required<import("@joy-ride/joy-ride").DebrisOptions>;
|
|
1746
|
+
bounds: DebrisBounds;
|
|
1747
|
+
particles: DebrisParticle[];
|
|
1748
|
+
gust: DebrisVector;
|
|
1749
|
+
gustAge: number;
|
|
1750
|
+
}>;
|
|
1751
|
+
vortices: (DebrisVector & {
|
|
1752
|
+
vx: number;
|
|
1753
|
+
vy: number;
|
|
1754
|
+
strength: number;
|
|
1755
|
+
radius: number;
|
|
1756
|
+
age: number;
|
|
1757
|
+
})[];
|
|
1758
|
+
serial: number;
|
|
1759
|
+
time: number;
|
|
1760
|
+
wakeClock: number;
|
|
1761
|
+
};
|
|
1762
|
+
skidTracks: {
|
|
1763
|
+
clock: number;
|
|
1764
|
+
time: number;
|
|
1765
|
+
presetId: string | null;
|
|
1766
|
+
previous: Map<number, {
|
|
1767
|
+
path: SkidPath;
|
|
1768
|
+
time: number;
|
|
1769
|
+
}>;
|
|
1770
|
+
paths: SkidPath[];
|
|
1771
|
+
revealAlpha: number;
|
|
1772
|
+
pendingRevealIndices: number[];
|
|
1773
|
+
tiles: SkidPath[];
|
|
1774
|
+
};
|
|
1775
|
+
tireMarks: {
|
|
1776
|
+
ground: {
|
|
1777
|
+
marks: TirePaintMark[];
|
|
1778
|
+
processed: number;
|
|
1779
|
+
scale: number;
|
|
1780
|
+
};
|
|
1781
|
+
dry: (readonly [string, {
|
|
1782
|
+
marks: TirePaintMark[];
|
|
1783
|
+
processed: number;
|
|
1784
|
+
scale: number;
|
|
1785
|
+
}])[];
|
|
1786
|
+
wet: (readonly [string, {
|
|
1787
|
+
marks: TirePaintMark[];
|
|
1788
|
+
processed: number;
|
|
1789
|
+
scale: number;
|
|
1790
|
+
}])[];
|
|
1791
|
+
};
|
|
1792
|
+
sparks: {
|
|
1793
|
+
particles: {
|
|
1794
|
+
point: Vec2;
|
|
1795
|
+
previous: Vec2;
|
|
1796
|
+
velocity: Vec2;
|
|
1797
|
+
plane: {
|
|
1798
|
+
origin: Vec2;
|
|
1799
|
+
normal: Vec2;
|
|
1800
|
+
} | null;
|
|
1801
|
+
age: number;
|
|
1802
|
+
life: number;
|
|
1803
|
+
size: number;
|
|
1804
|
+
kind: 0 | 1 | 2 | 3 | 4;
|
|
1805
|
+
seed: number;
|
|
1806
|
+
}[];
|
|
1807
|
+
walls: readonly MaskRect[];
|
|
1808
|
+
gpuUnavailable: boolean;
|
|
1809
|
+
elapsed: number;
|
|
1810
|
+
lastEmission: number;
|
|
1811
|
+
enabled: boolean;
|
|
1812
|
+
electricalPalette: ElectricalSparkPalette;
|
|
1813
|
+
airflow: {
|
|
1814
|
+
point: Vec2;
|
|
1815
|
+
velocity: Vec2;
|
|
1816
|
+
radius: number;
|
|
1817
|
+
} | null;
|
|
1818
|
+
};
|
|
1819
|
+
screenShake: {
|
|
1820
|
+
at: number;
|
|
1821
|
+
data: {
|
|
1822
|
+
enabled: boolean;
|
|
1823
|
+
profiles: ScreenShakeProfiles;
|
|
1824
|
+
impulses: {
|
|
1825
|
+
event: ScreenShakeEvent;
|
|
1826
|
+
startedAt: number;
|
|
1827
|
+
phase: number;
|
|
1828
|
+
amplitudePx: number;
|
|
1829
|
+
profile: ScreenShakeProfile;
|
|
1830
|
+
}[];
|
|
1831
|
+
lastTriggered: Map<ScreenShakeEvent, number>;
|
|
1832
|
+
sequence: number;
|
|
1833
|
+
};
|
|
1834
|
+
};
|
|
1835
|
+
dispose: () => void;
|
|
1836
|
+
};
|
|
1837
|
+
restoreState(state: ReturnType<Renderer['captureState']>): void;
|
|
1838
|
+
private applyState;
|
|
1839
|
+
get flamethrowerFiring(): boolean;
|
|
1840
|
+
/** Approximate live effect payload, excluding reusable empty render targets. */
|
|
1841
|
+
get managedMemoryGroups(): ManagedMemoryGroup[];
|
|
1842
|
+
get managedBytes(): number;
|
|
1843
|
+
private debugDrive;
|
|
1844
|
+
private previewGroundFire;
|
|
1845
|
+
private previewWallSmoke;
|
|
1846
|
+
private previewSparks;
|
|
1847
|
+
private previewDamage;
|
|
1848
|
+
private previewOil;
|
|
1849
|
+
private previewOilSplatter;
|
|
1850
|
+
private oilSplatterPreviewSeconds;
|
|
1851
|
+
private sparkPreviewClock;
|
|
1852
|
+
private damagePreviewApplied;
|
|
1853
|
+
private groundFirePreviewLit;
|
|
1854
|
+
private diagnostics;
|
|
1855
|
+
private tourDebug;
|
|
1856
|
+
trailLifetime: number;
|
|
1857
|
+
constructor(canvas: HTMLCanvasElement, overlay?: boolean, quality?: FluidQuality, canvasWorld?: boolean);
|
|
1858
|
+
private get pixelSpace();
|
|
1859
|
+
/** Compile and allocate fire before the first playable frame when the session can use it. */
|
|
1860
|
+
prepareFire(): boolean;
|
|
1861
|
+
setQuality(quality: FluidQuality): void;
|
|
1862
|
+
/** Smoke, fire, and ghost run at the configured quality or the governor's lower limit. */
|
|
1863
|
+
private applyFluidQuality;
|
|
1864
|
+
setSmokeTint(tint: SmokeTint): void;
|
|
1865
|
+
setTireSmokeEnabled(enabled: boolean): void;
|
|
1866
|
+
setVehicleShadowsEnabled(enabled: boolean): void;
|
|
1867
|
+
setGhostStyle(style: GhostStyle): void;
|
|
1868
|
+
setSparksEnabled(enabled: boolean): void;
|
|
1869
|
+
setScreenShakeEnabled(enabled: boolean): void;
|
|
1870
|
+
setScreenShakeProfiles(profiles?: ScreenShakeProfileOverrides): void;
|
|
1871
|
+
emitCrashShake(speedMps: number): void;
|
|
1872
|
+
emitRocketExplosionShake(blastStrength?: number): void;
|
|
1873
|
+
emitCombustibleExplosion(point: Vec2, radiusPx: number): void;
|
|
1874
|
+
/** Feed the same WebGL fire field from an expanding radial ring. */
|
|
1875
|
+
emitCombustibleBlast(point: Vec2, radiusPx: number, age: number): void;
|
|
1876
|
+
/** Point burst into the same fuel-age field used by guns, objects, and tire paths. */
|
|
1877
|
+
emitRocketExplosion(point: Vec2, travel: Vec2, blastStrength?: number): void;
|
|
1878
|
+
setDeformEnabled(enabled: boolean): void;
|
|
1879
|
+
resetVehicleDamage(): void;
|
|
1880
|
+
emitSparks(impact: SparkImpact): void;
|
|
1881
|
+
/** Translate vehicle burn state into the shared fire field and return an explosion point. */
|
|
1882
|
+
emitVehicleBurn(vehicle: VehicleEntity, frame: VehicleBurnFrame, mask: VehicleMask, seconds: number): Vec2 | null;
|
|
1883
|
+
/** Whether scene fire queued during this fixed step reaches the combustion solve. */
|
|
1884
|
+
sceneFireDue(dt: number): boolean;
|
|
1885
|
+
/** Queue an object's ink for the shared WebGL combustion field. */
|
|
1886
|
+
emitSceneFire(mask: FireMask, _dt?: number): void;
|
|
1887
|
+
pourWorldLiquid(kind: LiquidKind, point: Vec2, amount: number, color?: LiquidColor, stream?: string): void;
|
|
1888
|
+
emitPaint(point: Vec2, radiusM: number, amount: number, color: LiquidColor, flowMps: Vec2): void;
|
|
1889
|
+
hasConductiveLiquidNear(sources: readonly Vec2[], radiusPx: number): boolean;
|
|
1890
|
+
conductLightning(sources: readonly Vec2[], radiusPx?: number): {
|
|
1891
|
+
points: Vec2[];
|
|
1892
|
+
contains: (point: Vec2, radius?: number) => boolean;
|
|
1893
|
+
intersects: (rect: {
|
|
1894
|
+
x: number;
|
|
1895
|
+
y: number;
|
|
1896
|
+
width: number;
|
|
1897
|
+
height: number;
|
|
1898
|
+
}, padding?: number) => boolean;
|
|
1899
|
+
pathTo: (point: Vec2, radius?: number) => Vec2[];
|
|
1900
|
+
};
|
|
1901
|
+
igniteLiquidAt(point: Vec2, radiusPx: number): void;
|
|
1902
|
+
igniteConductedLiquids(points: readonly Vec2[], radiusPx: number): void;
|
|
1903
|
+
igniteLiquidsFromFire(sources: readonly FireSource[]): void;
|
|
1904
|
+
burningLiquidSources(): FireSource[];
|
|
1905
|
+
hasLiquidContact(source: LiquidSource, worldPoints: readonly Vec2[]): boolean;
|
|
1906
|
+
addLiquid(source: LiquidSource, options: LiquidPourOptions): void;
|
|
1907
|
+
syncElementLiquids(seeds: readonly LiquidElementSeed[]): Map<object, GroundField>;
|
|
1908
|
+
ejectLiquid(sim: Simulation, kind?: LiquidKind, color?: LiquidColor): void;
|
|
1909
|
+
setInitialPuddles(puddles: readonly {
|
|
1910
|
+
kind: LiquidKind;
|
|
1911
|
+
color?: LiquidColor;
|
|
1912
|
+
point: Vec2;
|
|
1913
|
+
amount: number;
|
|
1914
|
+
}[]): void;
|
|
1915
|
+
setSurfaceTone(tone: SurfaceTone): void;
|
|
1916
|
+
private fallbackSurfaceTone;
|
|
1917
|
+
private darkSurface;
|
|
1918
|
+
setDebugEnabled(enabled: boolean): void;
|
|
1919
|
+
setTourDebugRoute(route: TourRoute | null, stops?: readonly MeasuredTourStop[]): void;
|
|
1920
|
+
/** Fade the old smoke, tracks, and fire before releasing their data. */
|
|
1921
|
+
fadeEffects(): void;
|
|
1922
|
+
private clearEffects;
|
|
1923
|
+
reset(): void;
|
|
1924
|
+
dispose(): void;
|
|
1925
|
+
resize(): void;
|
|
1926
|
+
/** Raster materials stay at output density while the camera interpolates its zoom. */
|
|
1927
|
+
private rasterPixelRatio;
|
|
1928
|
+
setShowVehicleMarkers(enabled: boolean): void;
|
|
1929
|
+
flashTargets(paint: (ctx: CanvasRenderingContext2D, scroll: Vec2) => void): void;
|
|
1930
|
+
private particlePoint;
|
|
1931
|
+
private particleScreen;
|
|
1932
|
+
private particleVelocity;
|
|
1933
|
+
private particleScale;
|
|
1934
|
+
/** Cosmetic feedback for object points; the world owns the accumulated score. */
|
|
1935
|
+
emitPoints(documentPoint: Vec2, amount: number): void;
|
|
1936
|
+
private fluidView;
|
|
1937
|
+
private flameView;
|
|
1938
|
+
private clipFluidWalls;
|
|
1939
|
+
private stepVehicleWeapons;
|
|
1940
|
+
private sprayTirePaint;
|
|
1941
|
+
advanceEffects(vehicle: VehicleEntity, dt: number, { walls, carMask, tirePaintSources, driven, rocketCollision, bulletCollision, onGunshot, flameContact, onRocketLaunch, onRocketImpact, onBulletImpact, maskFor, companions }?: RendererEffectsInput): void;
|
|
1942
|
+
private advanceVehicleTireEffects;
|
|
1943
|
+
private skidView;
|
|
1944
|
+
private vehicleLightInput;
|
|
1945
|
+
private drawVehicleAndWeapons;
|
|
1946
|
+
private drawGroundLayers;
|
|
1947
|
+
render(vehicle: VehicleEntity, time: number, drag?: {
|
|
1948
|
+
from: Vec2;
|
|
1949
|
+
to: Vec2;
|
|
1950
|
+
} | null, pageText?: {
|
|
1951
|
+
drawGround?: (ctx: CanvasRenderingContext2D, scroll: Vec2, viewport: {
|
|
1952
|
+
width: number;
|
|
1953
|
+
height: number;
|
|
1954
|
+
}) => void;
|
|
1955
|
+
draw: (ctx: CanvasRenderingContext2D, scroll: Vec2, viewport: {
|
|
1956
|
+
width: number;
|
|
1957
|
+
height: number;
|
|
1958
|
+
}) => void;
|
|
1959
|
+
drawDebug?: (ctx: CanvasRenderingContext2D, sim: Simulation, renderer: Renderer, damage: VehicleDamage) => void;
|
|
1960
|
+
drawForeground?: (ctx: CanvasRenderingContext2D, scroll: Vec2, viewport: {
|
|
1961
|
+
width: number;
|
|
1962
|
+
height: number;
|
|
1963
|
+
}) => void;
|
|
1964
|
+
drawHealthBars?: (ctx: CanvasRenderingContext2D, scroll: Vec2, viewport: {
|
|
1965
|
+
width: number;
|
|
1966
|
+
height: number;
|
|
1967
|
+
}, player: VehicleEntity, renderer: Renderer, otherVehicles: readonly VehicleEntity[]) => void;
|
|
1968
|
+
}, companions?: readonly VehicleEntity[]): void;
|
|
1969
|
+
/** `time` is the animation frame's timestamp, so the work since then is this frame's
|
|
1970
|
+
* main-thread cost. Deterministic playback passes synthetic times; skip those. */
|
|
1971
|
+
private governFluidQuality;
|
|
1972
|
+
}
|
|
1973
|
+
type AttractorField = {
|
|
1974
|
+
center: Vec2;
|
|
1975
|
+
velocity: Vec2;
|
|
1976
|
+
radiusPx: number;
|
|
1977
|
+
};
|
|
1978
|
+
type GameEvent = ({
|
|
1979
|
+
kind: 'impact';
|
|
1980
|
+
impact: CollisionImpact;
|
|
1981
|
+
} | {
|
|
1982
|
+
kind: 'scrape';
|
|
1983
|
+
impact: CollisionImpact;
|
|
1984
|
+
} | {
|
|
1985
|
+
kind: 'crush';
|
|
1986
|
+
point: Vec2;
|
|
1987
|
+
points: number;
|
|
1988
|
+
} | {
|
|
1989
|
+
kind: 'combustionExplosion';
|
|
1990
|
+
point: Vec2;
|
|
1991
|
+
points: number;
|
|
1992
|
+
} | {
|
|
1993
|
+
kind: 'destructibleDestroyed';
|
|
1994
|
+
point: Vec2;
|
|
1995
|
+
points: number;
|
|
1996
|
+
cause?: 'break' | 'burnout';
|
|
1997
|
+
} | {
|
|
1998
|
+
kind: 'object';
|
|
1999
|
+
type: 'hit' | 'ignite';
|
|
2000
|
+
point: Vec2;
|
|
2001
|
+
}) & {
|
|
2002
|
+
element?: Element;
|
|
2003
|
+
objectId?: string;
|
|
2004
|
+
vehicleId?: string;
|
|
2005
|
+
};
|
|
2006
|
+
/** Events are produced by systems and consumed once, in the same simulation step. */
|
|
2007
|
+
declare class GameEvents {
|
|
2008
|
+
private readonly onObserverError;
|
|
2009
|
+
private pending;
|
|
2010
|
+
private readonly listeners;
|
|
2011
|
+
private draining;
|
|
2012
|
+
constructor(onObserverError?: (error: unknown) => void);
|
|
2013
|
+
subscribe(listener: (event: GameEvent) => void): () => boolean;
|
|
2014
|
+
captureState(): GameEvent[];
|
|
2015
|
+
restoreState(state: readonly GameEvent[]): void;
|
|
2016
|
+
emit(event: GameEvent): void;
|
|
2017
|
+
drain(consume: (event: GameEvent) => void): void;
|
|
2018
|
+
clear(): void;
|
|
2019
|
+
}
|
|
2020
|
+
/** Shared object response for rockets, lightning and host-authored area impacts. */
|
|
2021
|
+
type AreaImpact = {
|
|
2022
|
+
radiusPx: number;
|
|
2023
|
+
coreRadiusPx: number;
|
|
2024
|
+
damage: number;
|
|
2025
|
+
impulse: number;
|
|
2026
|
+
/** Optional scene-space shove direction. Omit for the usual radial explosion. */
|
|
2027
|
+
impulseDirection?: {
|
|
2028
|
+
x: number;
|
|
2029
|
+
y: number;
|
|
2030
|
+
};
|
|
2031
|
+
ignite: boolean;
|
|
2032
|
+
};
|
|
2033
|
+
type SceneRect = {
|
|
2034
|
+
x: number;
|
|
2035
|
+
y: number;
|
|
2036
|
+
width: number;
|
|
2037
|
+
height: number;
|
|
2038
|
+
};
|
|
2039
|
+
type SceneHit = {
|
|
2040
|
+
point: Vec2;
|
|
2041
|
+
};
|
|
2042
|
+
type SceneArcTarget = {
|
|
2043
|
+
key: unknown;
|
|
2044
|
+
point: Vec2;
|
|
2045
|
+
bounds?: SceneRect;
|
|
2046
|
+
};
|
|
2047
|
+
type CollisionImpact = {
|
|
2048
|
+
speedMps: number;
|
|
2049
|
+
point: Vec2;
|
|
2050
|
+
velocity: Vec2;
|
|
2051
|
+
normal: Vec2;
|
|
2052
|
+
carNormal: Vec2;
|
|
2053
|
+
pixelsPerMeter: number;
|
|
2054
|
+
wall?: SceneRect;
|
|
2055
|
+
element?: Element;
|
|
2056
|
+
};
|
|
2057
|
+
/** The engine consumes geometry and lifecycle hooks, never selectors or DOM nodes. */
|
|
2058
|
+
interface SceneGeometry {
|
|
2059
|
+
setSourceVehicle?(id: string): void;
|
|
2060
|
+
reset?(): void;
|
|
2061
|
+
/** Restore one authored object by its stable scene identity. */
|
|
2062
|
+
resetObject?(id: string): boolean;
|
|
2063
|
+
readonly totalPoints: number;
|
|
2064
|
+
readonly managedBytes: number;
|
|
2065
|
+
setEvents(events: GameEvents): void;
|
|
2066
|
+
prepare(preset: VehiclePreset): void;
|
|
2067
|
+
vehicleMask(preset: VehiclePreset, damage?: VehicleDamage): ReturnType<VehicleMasks['forPreset']>;
|
|
2068
|
+
wallRects(): readonly SceneRect[];
|
|
2069
|
+
beginStep(renderer: Renderer, seconds: number): void;
|
|
2070
|
+
stepVehicle(sim: Simulation, renderer: Renderer, containViewport?: boolean, damage?: VehicleDamage, vehicleId?: string, intangible?: boolean): void;
|
|
2071
|
+
endStep(seconds: number, attractor?: AttractorField | null): void;
|
|
2072
|
+
forgetVehicle(id: string): void;
|
|
2073
|
+
setAutoPaint?(enabled: boolean): void;
|
|
2074
|
+
stepElementLiquids?(renderer: Renderer, vehicles: readonly VehicleEntity[], seconds: number): void;
|
|
2075
|
+
tirePaintAt(points: readonly Vec2[]): (TirePaintSource | null)[];
|
|
2076
|
+
projectileHit(from: Vec2, to: Vec2, radius: number): SceneHit | null;
|
|
2077
|
+
arcTargets?(center: Vec2, radius: number): readonly SceneArcTarget[];
|
|
2078
|
+
applyAreaImpact?(point: Vec2, profile: AreaImpact, affected?: Set<unknown>): void;
|
|
2079
|
+
bulletImpact(from: Vec2, to: Vec2, radius: number, knownHit?: SceneHit): Vec2 | null;
|
|
2080
|
+
rocketImpact(from: Vec2, to: Vec2, radius: number, strength?: number, knownHit?: SceneHit): Vec2 | null;
|
|
2081
|
+
flameContact(from: Vec2, to: Vec2, radius: number, seconds: number, profile?: FlamethrowerProfile): Vec2 | null;
|
|
2082
|
+
burningProximity(point: Vec2): number;
|
|
2083
|
+
burningFireSources?(): FireSource[];
|
|
2084
|
+
hasFireTargets?(): boolean;
|
|
2085
|
+
exposeToFire?(sources: readonly FireSource[], seconds: number): void;
|
|
2086
|
+
drawGround?(ctx: CanvasRenderingContext2D, scroll: Vec2, viewport: {
|
|
2087
|
+
width: number;
|
|
2088
|
+
height: number;
|
|
2089
|
+
}): void;
|
|
2090
|
+
draw(ctx: CanvasRenderingContext2D, scroll: Vec2, viewport: {
|
|
2091
|
+
width: number;
|
|
2092
|
+
height: number;
|
|
2093
|
+
}): void;
|
|
2094
|
+
drawDebug?(ctx: CanvasRenderingContext2D, sim: Simulation, renderer: Renderer, damage: VehicleDamage): void;
|
|
2095
|
+
/** Roofs/canopies drawn over vehicles and world effects, below HUD overlays. */
|
|
2096
|
+
drawForeground?(ctx: CanvasRenderingContext2D, scroll: Vec2, viewport: {
|
|
2097
|
+
width: number;
|
|
2098
|
+
height: number;
|
|
2099
|
+
}): void;
|
|
2100
|
+
drawHealthBars?(ctx: CanvasRenderingContext2D, scroll: Vec2, viewport: {
|
|
2101
|
+
width: number;
|
|
2102
|
+
height: number;
|
|
2103
|
+
}, player?: VehicleEntity, renderer?: Renderer, otherVehicles?: readonly VehicleEntity[]): void;
|
|
2104
|
+
captureState(): unknown;
|
|
2105
|
+
restoreState(state: unknown): void;
|
|
2106
|
+
destroy(): void;
|
|
2107
|
+
}
|
|
2108
|
+
/** One substrate owns its heat state and decides how incoming heat propagates. */
|
|
2109
|
+
type HeatDomain = {
|
|
2110
|
+
id: string;
|
|
2111
|
+
/** How often this receiver needs fresh source geometry; zero samples every physics step. */
|
|
2112
|
+
sampleIntervalSeconds?: number;
|
|
2113
|
+
canReceive?(): boolean;
|
|
2114
|
+
sources(): readonly FireSource[];
|
|
2115
|
+
expose(sources: readonly FireSource[], dt: number): void;
|
|
2116
|
+
/** A domain with its own internal propagation can ignore its own published sources. */
|
|
2117
|
+
receivesOwnSources: boolean;
|
|
2118
|
+
captureState?(): unknown;
|
|
2119
|
+
restoreState?(state: unknown): void;
|
|
2120
|
+
reset?(): void;
|
|
2121
|
+
};
|
|
2122
|
+
type ConductivePath = {
|
|
2123
|
+
points: Vec2[];
|
|
2124
|
+
contains(point: Vec2, radius?: number): boolean;
|
|
2125
|
+
intersects(rect: {
|
|
2126
|
+
x: number;
|
|
2127
|
+
y: number;
|
|
2128
|
+
width: number;
|
|
2129
|
+
height: number;
|
|
2130
|
+
}, padding?: number): boolean;
|
|
2131
|
+
pathTo(point: Vec2, radius?: number): Vec2[];
|
|
2132
|
+
};
|
|
2133
|
+
/** A substrate supplies its own connectivity and any heat response to a discharge. */
|
|
2134
|
+
type ConductiveDomain = {
|
|
2135
|
+
id: string;
|
|
2136
|
+
conduct(sources: readonly Vec2[], radiusPx: number): ConductivePath | null;
|
|
2137
|
+
ignite?(points: readonly Vec2[], radiusPx: number): void;
|
|
2138
|
+
captureState?(): unknown;
|
|
2139
|
+
restoreState?(state: unknown): void;
|
|
2140
|
+
reset?(): void;
|
|
2141
|
+
};
|
|
2142
|
+
/** World-owned contact phase: snapshot source domains, then expose each receiver. */
|
|
2143
|
+
declare class MaterialInteractions {
|
|
2144
|
+
private readonly domains;
|
|
2145
|
+
private readonly conductiveDomains;
|
|
2146
|
+
private readonly heatClocks;
|
|
2147
|
+
constructor(scene: SceneGeometry, renderer: Renderer);
|
|
2148
|
+
registerHeatDomain(domain: HeatDomain): () => void;
|
|
2149
|
+
registerConductiveDomain(domain: ConductiveDomain): () => void;
|
|
2150
|
+
captureState(): {
|
|
2151
|
+
heat: {
|
|
2152
|
+
id: string;
|
|
2153
|
+
state: unknown;
|
|
2154
|
+
}[];
|
|
2155
|
+
heatClocks: {
|
|
2156
|
+
id: string;
|
|
2157
|
+
elapsed: number;
|
|
2158
|
+
}[];
|
|
2159
|
+
conductive: {
|
|
2160
|
+
id: string;
|
|
2161
|
+
state: unknown;
|
|
2162
|
+
}[];
|
|
2163
|
+
};
|
|
2164
|
+
validateState(state: ReturnType<MaterialInteractions['captureState']>): void;
|
|
2165
|
+
restoreState(state: ReturnType<MaterialInteractions['captureState']>): void;
|
|
2166
|
+
reset(): void;
|
|
2167
|
+
/** A discharge follows connected conductive liquid, using the same wet-cell topology as fire. */
|
|
2168
|
+
conduct(sources: readonly Vec2[], radiusPx: number): {
|
|
2169
|
+
points: Vec2[];
|
|
2170
|
+
contains: (point: Vec2, radius?: number) => boolean;
|
|
2171
|
+
intersects: (rect: {
|
|
2172
|
+
x: number;
|
|
2173
|
+
y: number;
|
|
2174
|
+
width: number;
|
|
2175
|
+
height: number;
|
|
2176
|
+
}, padding?: number) => boolean;
|
|
2177
|
+
pathTo: (point: Vec2, radius?: number) => Vec2[];
|
|
2178
|
+
};
|
|
2179
|
+
igniteConducted(points: readonly Vec2[], radiusPx: number): void;
|
|
2180
|
+
stepFire(dt: number): void;
|
|
2181
|
+
}
|
|
2182
|
+
type GameState = {
|
|
2183
|
+
mode: VehicleMode;
|
|
2184
|
+
presetId: string;
|
|
2185
|
+
position: Vec2;
|
|
2186
|
+
speed: number;
|
|
2187
|
+
angle: number;
|
|
2188
|
+
spin: number;
|
|
2189
|
+
paused: boolean;
|
|
2190
|
+
health: number;
|
|
2191
|
+
maxHealth: number;
|
|
2192
|
+
burnStage: CombustibleStage;
|
|
2193
|
+
points: number;
|
|
2194
|
+
};
|
|
2195
|
+
type StepInput = {
|
|
2196
|
+
controls?: Controls;
|
|
2197
|
+
userDriven?: boolean;
|
|
2198
|
+
manualMoved?: boolean;
|
|
2199
|
+
/** Tour and recording observers run after physics, before contacts. */
|
|
2200
|
+
afterPhysics?: () => void;
|
|
2201
|
+
allowFollow?: () => boolean;
|
|
2202
|
+
};
|
|
2203
|
+
/** A driver chooses controls; vehicle motion still comes from the shared physics model. */
|
|
2204
|
+
type DriverWorldView = {
|
|
2205
|
+
/** Axis-aligned wall boxes in simulation metres, with Y pointing up. */
|
|
2206
|
+
walls: readonly {
|
|
2207
|
+
left: number;
|
|
2208
|
+
right: number;
|
|
2209
|
+
bottom: number;
|
|
2210
|
+
top: number;
|
|
2211
|
+
}[];
|
|
2212
|
+
vehicles: readonly {
|
|
2213
|
+
id: string;
|
|
2214
|
+
position: Vec2;
|
|
2215
|
+
velocity: Vec2;
|
|
2216
|
+
radiusM: number;
|
|
2217
|
+
}[];
|
|
2218
|
+
};
|
|
2219
|
+
type VehicleDriver = {
|
|
2220
|
+
(target: VehicleEntity | null, vehicle: VehicleEntity, seconds: number, world?: DriverWorldView): Controls;
|
|
2221
|
+
/** Stateful drivers opt in so a world checkpoint can restore their decisions. */
|
|
2222
|
+
captureState?: () => unknown;
|
|
2223
|
+
restoreState?: (state: unknown) => void;
|
|
2224
|
+
};
|
|
2225
|
+
/** A temporary input-driven action that can supersede either player or AI controls. */
|
|
2226
|
+
type VehicleDriveTask = {
|
|
2227
|
+
activate?: () => void;
|
|
2228
|
+
next: (vehicle: VehicleEntity, seconds: number) => Controls;
|
|
2229
|
+
afterPhysics: (vehicle: VehicleEntity, seconds: number) => void;
|
|
2230
|
+
readonly complete: boolean;
|
|
2231
|
+
cancel: () => void;
|
|
2232
|
+
captureState: () => unknown;
|
|
2233
|
+
restoreState: (state: unknown) => void;
|
|
2234
|
+
};
|
|
2235
|
+
type VehicleTourFactory = (vehicle: VehicleEntity, targets: readonly TourTarget[], options?: VehicleTourOptions) => VehicleDriveTask | null;
|
|
2236
|
+
type VehicleSpawn = {
|
|
2237
|
+
id: string;
|
|
2238
|
+
sim: Simulation;
|
|
2239
|
+
label?: string;
|
|
2240
|
+
control: {
|
|
2241
|
+
kind: 'player';
|
|
2242
|
+
} | {
|
|
2243
|
+
kind: 'ai';
|
|
2244
|
+
driver: VehicleDriver;
|
|
2245
|
+
targetId?: string;
|
|
2246
|
+
};
|
|
2247
|
+
};
|
|
2248
|
+
type SceneState = {
|
|
2249
|
+
extensions: Map<string, unknown>;
|
|
2250
|
+
vehicles: ReturnType<VehicleEntity['captureState']>[];
|
|
2251
|
+
drivers: Map<string, VehicleDriver>;
|
|
2252
|
+
driverStates: Map<string, unknown>;
|
|
2253
|
+
driveTasks: Map<string, VehicleDriveTask>;
|
|
2254
|
+
driveTaskStates: Map<string, unknown>;
|
|
2255
|
+
driverTargets: Map<string, string>;
|
|
2256
|
+
cameraVehicleId: string | null;
|
|
2257
|
+
deformationEnabled: boolean;
|
|
2258
|
+
weaponCooldownEnabled: boolean;
|
|
2259
|
+
vehicleDestructible: boolean;
|
|
2260
|
+
weaponsEnabled: boolean;
|
|
2261
|
+
enabledTools: VehicleTool[];
|
|
2262
|
+
slowMo: ReturnType<SlowMo['captureState']>;
|
|
2263
|
+
renderer: ReturnType<Renderer['captureState']>;
|
|
2264
|
+
materialInteractions: ReturnType<MaterialInteractions['captureState']>;
|
|
2265
|
+
collisions: unknown;
|
|
2266
|
+
odometer: ReturnType<Odometer['captureState']>;
|
|
2267
|
+
events: ReturnType<GameEvents['captureState']>;
|
|
2268
|
+
points: number;
|
|
2269
|
+
};
|
|
2270
|
+
/** Reusable same-world checkpoint. Dispose it when it is no longer needed. */
|
|
2271
|
+
declare class GameCheckpoint {
|
|
2272
|
+
readonly world: GameWorld;
|
|
2273
|
+
readonly state: SceneState;
|
|
2274
|
+
readonly version = 3;
|
|
2275
|
+
private disposed;
|
|
2276
|
+
constructor(world: GameWorld, state: SceneState);
|
|
2277
|
+
get available(): boolean;
|
|
2278
|
+
restore(): void;
|
|
2279
|
+
dispose(): void;
|
|
2280
|
+
}
|
|
2281
|
+
/** Framework-free owner of game systems. React only supplies browser inputs and UI sinks. */
|
|
2282
|
+
declare class GameWorld {
|
|
2283
|
+
readonly renderer: Renderer;
|
|
2284
|
+
readonly odometer: Odometer;
|
|
2285
|
+
private readonly sound;
|
|
2286
|
+
private readonly overlay;
|
|
2287
|
+
private readonly rocketBlastStrength;
|
|
2288
|
+
private readonly stateParticipants;
|
|
2289
|
+
registerStateParticipant<T>(name: string, participant: {
|
|
2290
|
+
captureState(): T;
|
|
2291
|
+
restoreState(state: T): void;
|
|
2292
|
+
}): () => boolean;
|
|
2293
|
+
readonly slowMo: SlowMo;
|
|
2294
|
+
readonly events: GameEvents;
|
|
2295
|
+
private readonly vehicleRegistry;
|
|
2296
|
+
private readonly drivers;
|
|
2297
|
+
private readonly driveTasks;
|
|
2298
|
+
private tourFactory;
|
|
2299
|
+
private readonly driverTargets;
|
|
2300
|
+
private cameraVehicleId;
|
|
2301
|
+
readonly collisions: SceneGeometry;
|
|
2302
|
+
private readonly materialInteractions;
|
|
2303
|
+
private readonly checkpoints;
|
|
2304
|
+
private readonly flameDamageThisStep;
|
|
2305
|
+
private stepSeconds;
|
|
2306
|
+
private destructionPoints;
|
|
2307
|
+
private disposed;
|
|
2308
|
+
constructor(sim: Simulation | null, renderer: Renderer, odometer: Odometer, sound: () => EngineAudio, overlay: boolean, rocketBlastStrength: () => number, geometry?: SceneGeometry, options?: WorkModeConfiguration & {
|
|
2309
|
+
autoPaint?: boolean;
|
|
2310
|
+
});
|
|
2311
|
+
/** The browser adapter may have a player; an AI-only world uses its first car as focus. */
|
|
2312
|
+
get playerVehicle(): VehicleEntity | undefined;
|
|
2313
|
+
get focusVehicle(): VehicleEntity | undefined;
|
|
2314
|
+
/** The player, or the focused vehicle in an AI-only world. */
|
|
2315
|
+
get primaryVehicle(): VehicleEntity;
|
|
2316
|
+
get sim(): Simulation;
|
|
2317
|
+
get damage(): VehicleDamage;
|
|
2318
|
+
getVehicle(id: string): VehicleEntity | undefined;
|
|
2319
|
+
get cameraVehicle(): VehicleEntity | undefined;
|
|
2320
|
+
/** Spectate a vehicle without changing who owns the driving controls. */
|
|
2321
|
+
watchVehicle(id: string | null, follow?: boolean): boolean;
|
|
2322
|
+
get companionVehicles(): VehicleEntity[];
|
|
2323
|
+
get vehicles(): VehicleEntity[];
|
|
2324
|
+
registerHeatDomain(domain: HeatDomain): () => void;
|
|
2325
|
+
registerConductiveDomain(domain: ConductiveDomain): () => void;
|
|
2326
|
+
/** All live configuration paths commit here, including editor, replay and page commands. */
|
|
2327
|
+
configureVehicle(id: string, changes: {
|
|
2328
|
+
preset?: VehiclePreset;
|
|
2329
|
+
appearance?: Appearance;
|
|
2330
|
+
slots?: VehicleSlots;
|
|
2331
|
+
control?: VehicleSpawn['control'];
|
|
2332
|
+
}): boolean;
|
|
2333
|
+
private projectedSound?;
|
|
2334
|
+
private projectedPreset?;
|
|
2335
|
+
private projectFocusVehicle;
|
|
2336
|
+
/** Immediate effect reset for level changes, tours, and recording playback. */
|
|
2337
|
+
resetEffects(): void;
|
|
2338
|
+
fadeEffects(): void;
|
|
2339
|
+
resetScene(): void;
|
|
2340
|
+
private deformationEnabled;
|
|
2341
|
+
private weaponCooldownEnabled;
|
|
2342
|
+
private vehicleDestructible;
|
|
2343
|
+
private weaponsEnabled;
|
|
2344
|
+
private enabledTools;
|
|
2345
|
+
setEnabledTools(tools: readonly VehicleTool[]): void;
|
|
2346
|
+
setVehicleDestructible(enabled: boolean): void;
|
|
2347
|
+
setWeaponsEnabled(enabled: boolean): void;
|
|
2348
|
+
setWeaponCooldownEnabled(enabled: boolean): void;
|
|
2349
|
+
setDeformationEnabled(enabled: boolean): void;
|
|
2350
|
+
spawnVehicle({ id, sim, control, label }: VehicleSpawn): VehicleEntity;
|
|
2351
|
+
setVehicleControl(id: string, control: VehicleSpawn['control']): boolean;
|
|
2352
|
+
removeVehicle(id: string): boolean;
|
|
2353
|
+
/** Explicit target selection also works in a world with no player vehicle. */
|
|
2354
|
+
setVehicleTarget(id: string, targetId: string | null): boolean;
|
|
2355
|
+
getVehicleTarget(id: string): VehicleEntity | null;
|
|
2356
|
+
private bindTourCommands;
|
|
2357
|
+
/** The AI package supplies route planning; the world owns task lifetime and input priority. */
|
|
2358
|
+
setVehicleTourFactory(factory: VehicleTourFactory | null): void;
|
|
2359
|
+
startVehicleTour(id: string, targets: readonly TourTarget[], options?: VehicleTourOptions): boolean;
|
|
2360
|
+
stopVehicleTour(id: string): boolean;
|
|
2361
|
+
getVehicleTour(id: string): VehicleDriveTask | null;
|
|
2362
|
+
private consumeEvent;
|
|
2363
|
+
private awardPoints;
|
|
2364
|
+
get points(): number;
|
|
2365
|
+
get totalPoints(): number;
|
|
2366
|
+
private vehicleProjectileHit;
|
|
2367
|
+
private nearestProjectileTarget;
|
|
2368
|
+
private rocketCollision;
|
|
2369
|
+
private bulletCollision;
|
|
2370
|
+
/** Input/reserves, targeting, area response and water propagation share the normal fixed step. */
|
|
2371
|
+
private stepLightning;
|
|
2372
|
+
private flameContact;
|
|
2373
|
+
private gunshot;
|
|
2374
|
+
private rocketLaunch;
|
|
2375
|
+
private rocketImpact;
|
|
2376
|
+
private bulletImpact;
|
|
2377
|
+
/** Exactly one simulation update: input, physics, contacts, effects, audio events. */
|
|
2378
|
+
step(input: StepInput | undefined, seconds: number): void;
|
|
2379
|
+
/** Maps a real-time tick to game time, synchronizing camera and audio before physics. */
|
|
2380
|
+
advanceTime(realSeconds: number): number;
|
|
2381
|
+
present(time: number, elapsed: number, controls: Controls, hornHeld: boolean, audioEnabled: boolean, masterVolume: number, drag?: {
|
|
2382
|
+
from: Vec2;
|
|
2383
|
+
to: Vec2;
|
|
2384
|
+
} | null): void;
|
|
2385
|
+
snapshot(): GameState;
|
|
2386
|
+
/** Freeze all engine-owned scene state, including live GPU fields and page objects. */
|
|
2387
|
+
saveState(): GameCheckpoint;
|
|
2388
|
+
restoreState(checkpoint: GameCheckpoint): void;
|
|
2389
|
+
releaseCheckpoint(checkpoint: GameCheckpoint): void;
|
|
2390
|
+
dispose(): void;
|
|
2391
|
+
}
|
|
2392
|
+
/** Shared screen-space ordering. Foreground page UI stays below the pause menu and HUD. */
|
|
2393
|
+
declare const overlayLayers: {
|
|
2394
|
+
readonly world: 2147483643;
|
|
2395
|
+
readonly foreground: 2147483644;
|
|
2396
|
+
readonly backdrop: 2147483645;
|
|
2397
|
+
readonly hud: 2147483646;
|
|
2398
|
+
readonly controls: 2147483647;
|
|
2399
|
+
};
|
|
2400
|
+
type OverlayLayer = keyof typeof overlayLayers;
|
|
2401
|
+
/** Set --joy-ride-z-index on :root to move the entire stack together. */
|
|
2402
|
+
declare function overlayZIndex(layer: OverlayLayer): string;
|
|
2403
|
+
type VehicleTourState = {
|
|
2404
|
+
vehicleId: string;
|
|
2405
|
+
phase: TourSample['phase'] | 'stopped';
|
|
2406
|
+
stopIndex: number;
|
|
2407
|
+
selector?: string;
|
|
2408
|
+
};
|
|
2409
|
+
type PageDebrisTarget = string | Element | Iterable<Element>;
|
|
2410
|
+
type PageDebrisHandle = DebrisHandle;
|
|
2411
|
+
declare global {
|
|
2412
|
+
interface DocumentEventMap {
|
|
2413
|
+
'joyride:reset': CustomEvent<null>;
|
|
2414
|
+
}
|
|
2415
|
+
interface HTMLElementEventMap {
|
|
2416
|
+
'joyride:reset': CustomEvent<null>;
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
type VehicleSpawnOptions = VehicleConfiguration & {
|
|
2420
|
+
at?: Element | Vec2;
|
|
2421
|
+
angleDeg?: number;
|
|
2422
|
+
};
|
|
2423
|
+
type VehicleHandle = {
|
|
2424
|
+
readonly id: string;
|
|
2425
|
+
readonly state: DeepReadonly<{
|
|
2426
|
+
id: string;
|
|
2427
|
+
vehicle: string;
|
|
2428
|
+
driver: NonNullable<VehicleConfiguration['driver']> | 'custom';
|
|
2429
|
+
position: Vec2;
|
|
2430
|
+
speedMps: number;
|
|
2431
|
+
health: number;
|
|
2432
|
+
maxHealth: number;
|
|
2433
|
+
appearance: Appearance;
|
|
2434
|
+
slots: Readonly<VehicleSlots>;
|
|
2435
|
+
}>;
|
|
2436
|
+
update(patch: VehiclePatch): void;
|
|
2437
|
+
useSlot(slot: SlotNumber): boolean;
|
|
2438
|
+
startSlot(slot: SlotNumber): boolean;
|
|
2439
|
+
stopSlot(slot: SlotNumber): void;
|
|
2440
|
+
dispose(): void;
|
|
2441
|
+
};
|
|
2442
|
+
type ElementSource = {
|
|
2443
|
+
readonly current: HTMLElement | null;
|
|
2444
|
+
};
|
|
2445
|
+
type TourState = {
|
|
2446
|
+
phase: TourSample['phase'] | 'stopped';
|
|
2447
|
+
stopIndex: number;
|
|
2448
|
+
selector?: string;
|
|
2449
|
+
};
|
|
2450
|
+
type VehicleArrivalOptions = {
|
|
2451
|
+
target: Element | {
|
|
2452
|
+
xPx: number;
|
|
2453
|
+
yPx: number;
|
|
2454
|
+
};
|
|
2455
|
+
/** Fractions of the target box; omitted values center the destination. */
|
|
2456
|
+
stopAt?: {
|
|
2457
|
+
x?: number;
|
|
2458
|
+
y?: number;
|
|
2459
|
+
offsetXPx?: number;
|
|
2460
|
+
offsetYPx?: number;
|
|
2461
|
+
};
|
|
2462
|
+
approach: {
|
|
2463
|
+
/** Document-space direction of travel, in radians. */
|
|
2464
|
+
angleRad: number;
|
|
2465
|
+
distancePx: number;
|
|
2466
|
+
/** Omit to derive the entry speed from the requested skid distance and vehicle physics. */
|
|
2467
|
+
initialSpeedMps?: number;
|
|
2468
|
+
/** Fraction of the predicted stop duration spent fading in; 0.5 fades over its first half. */
|
|
2469
|
+
fadeFraction: number;
|
|
2470
|
+
};
|
|
2471
|
+
/** The handbrake is engaged from the first simulation step. */
|
|
2472
|
+
handbrake?: {
|
|
2473
|
+
steer?: number;
|
|
2474
|
+
};
|
|
2475
|
+
};
|
|
2476
|
+
type VehicleArrivalResult = 'completed' | 'interrupted' | 'unavailable';
|
|
2477
|
+
type RecordingPlaybackOptions = {
|
|
2478
|
+
/** Override the recorded starting point in document pixels. */
|
|
2479
|
+
startAt?: {
|
|
2480
|
+
xPx: number;
|
|
2481
|
+
yPx: number;
|
|
2482
|
+
angleRad?: number;
|
|
2483
|
+
};
|
|
2484
|
+
/** Start engine audio with playback; disable for an automatic, silent entrance. */
|
|
2485
|
+
startAudio?: boolean;
|
|
2486
|
+
};
|
|
2487
|
+
type RecordingStopReason = 'manual' | 'placement';
|
|
2488
|
+
type CarAnchor = {
|
|
2489
|
+
x: number;
|
|
2490
|
+
y: number;
|
|
2491
|
+
width: number;
|
|
2492
|
+
height: number;
|
|
2493
|
+
};
|
|
2494
|
+
type BrowserState = GameState;
|
|
2495
|
+
type CompanionVehicle = {
|
|
2496
|
+
id: string;
|
|
2497
|
+
name?: string;
|
|
2498
|
+
preset?: VehiclePreset;
|
|
2499
|
+
initialOffsetM: Vec2;
|
|
2500
|
+
/** Spawn heading in radians. Defaults to the primary vehicle's heading. */
|
|
2501
|
+
readonly initialAngle?: number;
|
|
2502
|
+
driver: VehicleDriver;
|
|
2503
|
+
targetId?: string;
|
|
2504
|
+
};
|
|
2505
|
+
type BrowserSessionOptions = WorkModeConfiguration & {
|
|
2506
|
+
mode?: VehicleMode;
|
|
2507
|
+
readonly initialMode?: VehicleMode;
|
|
2508
|
+
readonly overlay?: boolean;
|
|
2509
|
+
viewportWalls?: boolean;
|
|
2510
|
+
speedZoom?: SpeedZoomMode;
|
|
2511
|
+
lighting?: Partial<VehicleLightingOptions>;
|
|
2512
|
+
onLightingChange?: (options: VehicleLightingOptions) => void;
|
|
2513
|
+
preset?: VehiclePreset;
|
|
2514
|
+
showVehicle?: boolean;
|
|
2515
|
+
readonly companionVehicles?: readonly CompanionVehicle[];
|
|
2516
|
+
paused?: boolean;
|
|
2517
|
+
audioEnabled?: boolean;
|
|
2518
|
+
readonly audioEngine?: EngineAudio;
|
|
2519
|
+
readonly spawnTarget?: ElementSource;
|
|
2520
|
+
readonly initialPuddles?: readonly {
|
|
2521
|
+
kind: LiquidKind;
|
|
2522
|
+
target: ElementSource;
|
|
2523
|
+
amount: number;
|
|
2524
|
+
color?: LiquidColor;
|
|
2525
|
+
}[];
|
|
2526
|
+
readonly initialGroundMarks?: readonly TirePaintMark[];
|
|
2527
|
+
readonly introDriveIn?: boolean;
|
|
2528
|
+
idleSound?: boolean;
|
|
2529
|
+
masterVolume?: number;
|
|
2530
|
+
quality?: FluidQuality;
|
|
2531
|
+
smokeTint?: SmokeTint;
|
|
2532
|
+
ghostStyle?: GhostStyle;
|
|
2533
|
+
tireSmoke?: boolean;
|
|
2534
|
+
vehicleShadows?: boolean;
|
|
2535
|
+
sparks?: boolean;
|
|
2536
|
+
deform?: boolean;
|
|
2537
|
+
screenShake?: boolean;
|
|
2538
|
+
showHealthBars?: boolean;
|
|
2539
|
+
showVehicleMarkers?: boolean;
|
|
2540
|
+
showWeaponBar?: boolean;
|
|
2541
|
+
weaponCooldown?: boolean;
|
|
2542
|
+
screenShakeProfiles?: ScreenShakeProfileOverrides;
|
|
2543
|
+
surfaceTone?: SurfaceTone;
|
|
2544
|
+
debug?: boolean;
|
|
2545
|
+
showHud?: boolean;
|
|
2546
|
+
showTotalPoints?: boolean;
|
|
2547
|
+
automatedInput?: Controls | null;
|
|
2548
|
+
bindings?: readonly {
|
|
2549
|
+
target: string;
|
|
2550
|
+
spec: ObjectPatch;
|
|
2551
|
+
}[];
|
|
2552
|
+
readonly definitions?: PlaygroundDefinitions;
|
|
2553
|
+
readonly playground?: PlaygroundRegistry;
|
|
2554
|
+
onReady?: (world: GameWorld, registry: PlaygroundRegistry) => void;
|
|
2555
|
+
autoPaint?: boolean;
|
|
2556
|
+
foregroundSelector?: string;
|
|
2557
|
+
destructibleBurnSeconds?: number;
|
|
2558
|
+
rocketBlastStrength?: number;
|
|
2559
|
+
readonly initialAngle?: number;
|
|
2560
|
+
canPlaceManually?: boolean;
|
|
2561
|
+
onStateChange?: (state: BrowserState) => void;
|
|
2562
|
+
onTourStateChange?: (state: TourState) => void;
|
|
2563
|
+
onVehicleTourStateChange?: (state: VehicleTourState) => void;
|
|
2564
|
+
onExit?: () => void;
|
|
2565
|
+
onToggleMute?: () => void;
|
|
2566
|
+
onAudioInteraction?: () => void;
|
|
2567
|
+
showToolbar?: boolean;
|
|
2568
|
+
onStartRequest?: () => void;
|
|
2569
|
+
onCarClick?: (anchor: CarAnchor) => void;
|
|
2570
|
+
onCompanionClick?: (id: string, anchor: CarAnchor) => void;
|
|
2571
|
+
onCompanionRemove?: (id: string) => void;
|
|
2572
|
+
onPlaybackEnd?: (completed: boolean) => void;
|
|
2573
|
+
onRecordingEnd?: (recording: JoyRideRecording, reason: RecordingStopReason) => void;
|
|
2574
|
+
onRecordShortcut?: () => boolean;
|
|
2575
|
+
onPlacementEnd?: (pose: {
|
|
2576
|
+
xPx: number;
|
|
2577
|
+
yPx: number;
|
|
2578
|
+
angleRad: number;
|
|
2579
|
+
}) => void;
|
|
2580
|
+
};
|
|
2581
|
+
type ObjectEventName = 'hit' | 'ignite' | 'break' | 'burnout' | 'explode' | 'crush';
|
|
2582
|
+
type ObjectEventDetail = Readonly<{
|
|
2583
|
+
object: PlaygroundObject;
|
|
2584
|
+
vehicle?: Readonly<{
|
|
2585
|
+
id: string;
|
|
2586
|
+
}>;
|
|
2587
|
+
point?: Readonly<Vec2>;
|
|
2588
|
+
points?: number;
|
|
2589
|
+
}>;
|
|
2590
|
+
type SharedBrowserOptions = Pick<BrowserSessionOptions, 'workMode' | 'bindings' | 'foregroundSelector' | 'screenShakeProfiles' | 'canPlaceManually'>;
|
|
2591
|
+
type EmbedOptions = SharedBrowserOptions & {
|
|
2592
|
+
root?: string | Element;
|
|
2593
|
+
definitions?: DeepReadonly<PlaygroundDefinitions>;
|
|
2594
|
+
player?: PlayerConfiguration;
|
|
2595
|
+
options?: RuntimeOptionsPatch;
|
|
2596
|
+
routes?: Readonly<Record<string, RouteSpec>>;
|
|
2597
|
+
recordingUiMode?: RecordingUiMode;
|
|
2598
|
+
shadowDom?: boolean;
|
|
2599
|
+
hudMode?: HudOptions['mode'];
|
|
2600
|
+
hudLinks?: readonly HudLink[];
|
|
2601
|
+
};
|
|
2602
|
+
type ObjectEvents = { [Name in ObjectEventName as `object:${Name}`]: ObjectEventDetail; };
|
|
2603
|
+
type RouteEventDetail = {
|
|
2604
|
+
readonly route: {
|
|
2605
|
+
readonly id: string;
|
|
2606
|
+
readonly completed: number;
|
|
2607
|
+
readonly total: number;
|
|
2608
|
+
readonly complete: boolean;
|
|
2609
|
+
};
|
|
2610
|
+
readonly vehicle?: {
|
|
2611
|
+
readonly id: string;
|
|
2612
|
+
};
|
|
2613
|
+
};
|
|
2614
|
+
interface PlaygroundEventMap extends ObjectEvents {
|
|
2615
|
+
reset: null;
|
|
2616
|
+
'trigger:enter': DeepReadonly<PlaygroundTriggerDetail>;
|
|
2617
|
+
'trigger:leave': DeepReadonly<PlaygroundTriggerDetail>;
|
|
2618
|
+
'trigger:qualify': DeepReadonly<PlaygroundTriggerDetail>;
|
|
2619
|
+
'trigger:change': DeepReadonly<PlaygroundTriggerDetail>;
|
|
2620
|
+
'trigger:stop': DeepReadonly<PlaygroundTriggerDetail>;
|
|
2621
|
+
diagnostic: PlaygroundDiagnostic;
|
|
2622
|
+
'state:change': PlaygroundState;
|
|
2623
|
+
'vehicle:change': {
|
|
2624
|
+
vehicle: VehicleHandle['state'];
|
|
2625
|
+
};
|
|
2626
|
+
'tour:change': TourState;
|
|
2627
|
+
'recording:end': {
|
|
2628
|
+
recording: JoyRideRecording;
|
|
2629
|
+
reason: RecordingStopReason;
|
|
2630
|
+
};
|
|
2631
|
+
dispose: undefined;
|
|
2632
|
+
'route:progress': RouteEventDetail;
|
|
2633
|
+
'route:complete': RouteEventDetail;
|
|
2634
|
+
}
|
|
2635
|
+
type PlaygroundState = DeepReadonly<{
|
|
2636
|
+
playerId: string | null;
|
|
2637
|
+
focusVehicleId: string | null;
|
|
2638
|
+
player: VehicleHandle['state'] | null;
|
|
2639
|
+
points: number;
|
|
2640
|
+
}>;
|
|
2641
|
+
type EmbedController = {
|
|
2642
|
+
readonly ready: Promise<EmbedController>;
|
|
2643
|
+
dispose: () => void;
|
|
2644
|
+
bind: (target: PlaygroundTarget, spec: ObjectPatch) => PlaygroundBinding;
|
|
2645
|
+
inspect: (target: Element | string) => PlaygroundObject | null;
|
|
2646
|
+
on: <Name extends keyof PlaygroundEventMap>(event: Name, listener: (detail: PlaygroundEventMap[Name]) => void) => () => void;
|
|
2647
|
+
spawn: (options: VehicleSpawnOptions) => VehicleHandle;
|
|
2648
|
+
debris: (target: PageDebrisTarget, options?: DebrisOptions) => PageDebrisHandle;
|
|
2649
|
+
pour: (liquid: string, options: {
|
|
2650
|
+
at: Element | {
|
|
2651
|
+
x: number;
|
|
2652
|
+
y: number;
|
|
2653
|
+
};
|
|
2654
|
+
amount?: number;
|
|
2655
|
+
color?: LiquidColorInput;
|
|
2656
|
+
}) => void;
|
|
2657
|
+
route: (id: string, options: RouteSpec) => PlaygroundRouteHandle;
|
|
2658
|
+
reset: () => void;
|
|
2659
|
+
update: (patch: RuntimeOptionsPatch) => void;
|
|
2660
|
+
readonly options: DeepReadonly<RuntimeOptions>;
|
|
2661
|
+
readonly state: PlaygroundState | null;
|
|
2662
|
+
readonly player: VehicleHandle | null;
|
|
2663
|
+
exportConfiguration: () => PlaygroundConfiguration;
|
|
2664
|
+
openConfigure: () => boolean;
|
|
2665
|
+
startAudio: () => Promise<void>;
|
|
2666
|
+
setSlowMo: (active: boolean, options?: Partial<SlowMoOptions>) => Promise<void>;
|
|
2667
|
+
getCarAnchor: () => CarAnchor | null;
|
|
2668
|
+
arriveAt: (options: VehicleArrivalOptions) => Promise<VehicleArrivalResult>;
|
|
2669
|
+
startTour: (stops: readonly TourStop[], options?: TourOptions) => Promise<boolean>;
|
|
2670
|
+
stopTour: () => void;
|
|
2671
|
+
getVehicle: (id: string) => VehicleHandle | null;
|
|
2672
|
+
driveVehicleTo: (id: string, target: TourTarget, options?: VehicleTourOptions) => Promise<boolean>;
|
|
2673
|
+
tourVehicle: (id: string, targets: readonly TourTarget[], options?: VehicleTourOptions) => Promise<boolean>;
|
|
2674
|
+
startRecording: () => boolean;
|
|
2675
|
+
stopRecording: () => JoyRideRecording | null;
|
|
2676
|
+
playRecording: (recording: JoyRideRecording, options?: RecordingPlaybackOptions) => Promise<boolean>;
|
|
2677
|
+
stopPlayback: () => void;
|
|
2678
|
+
};
|
|
2679
|
+
declare function mount(input?: EmbedOptions | PlaygroundConfiguration): EmbedController;
|
|
2680
|
+
/** Keep the runtime API available as the default export for bundled hosts. */
|
|
2681
|
+
declare const api: {
|
|
2682
|
+
mount: typeof mount;
|
|
2683
|
+
resolveWorkMode: typeof resolveWorkMode;
|
|
2684
|
+
vehicleTools: readonly VehicleToolDefinition[];
|
|
2685
|
+
availableVehicleTools: typeof availableVehicleTools;
|
|
2686
|
+
overlayLayers: {
|
|
2687
|
+
readonly world: 2147483643;
|
|
2688
|
+
readonly foreground: 2147483644;
|
|
2689
|
+
readonly backdrop: 2147483645;
|
|
2690
|
+
readonly hud: 2147483646;
|
|
2691
|
+
readonly controls: 2147483647;
|
|
2692
|
+
};
|
|
2693
|
+
overlayZIndex: typeof overlayZIndex;
|
|
2694
|
+
define: typeof definePlayground;
|
|
2695
|
+
readonly active: EmbedController | undefined;
|
|
2696
|
+
listPresets: typeof listVehiclePresets;
|
|
2697
|
+
listVehicleOptions: typeof listVehicleOptions;
|
|
2698
|
+
getPreset: typeof getVehiclePreset;
|
|
2699
|
+
keyboardControls: readonly [{
|
|
2700
|
+
readonly id: "accelerate";
|
|
2701
|
+
readonly label: "Accelerate";
|
|
2702
|
+
readonly keys: readonly ["W", "↑"];
|
|
2703
|
+
readonly codes: readonly ["KeyW", "ArrowUp"];
|
|
2704
|
+
}, {
|
|
2705
|
+
readonly id: "reverse";
|
|
2706
|
+
readonly label: "Reverse";
|
|
2707
|
+
readonly keys: readonly ["S", "↓"];
|
|
2708
|
+
readonly codes: readonly ["KeyS", "ArrowDown"];
|
|
2709
|
+
}, {
|
|
2710
|
+
readonly id: "left";
|
|
2711
|
+
readonly label: "Steer left";
|
|
2712
|
+
readonly keys: readonly ["A", "←"];
|
|
2713
|
+
readonly codes: readonly ["KeyA", "ArrowLeft"];
|
|
2714
|
+
}, {
|
|
2715
|
+
readonly id: "right";
|
|
2716
|
+
readonly label: "Steer right";
|
|
2717
|
+
readonly keys: readonly ["D", "→"];
|
|
2718
|
+
readonly codes: readonly ["KeyD", "ArrowRight"];
|
|
2719
|
+
}, {
|
|
2720
|
+
readonly id: "handbrake";
|
|
2721
|
+
readonly label: "Handbrake";
|
|
2722
|
+
readonly keys: readonly ["Space"];
|
|
2723
|
+
readonly codes: readonly ["Space"];
|
|
2724
|
+
}, {
|
|
2725
|
+
readonly id: "boost";
|
|
2726
|
+
readonly label: "Hold boost / charge burnout launch";
|
|
2727
|
+
readonly keys: readonly ["Shift"];
|
|
2728
|
+
readonly codes: readonly ["ShiftLeft", "ShiftRight"];
|
|
2729
|
+
}, ...{
|
|
2730
|
+
id: string;
|
|
2731
|
+
label: string;
|
|
2732
|
+
keys: string[];
|
|
2733
|
+
codes: string[];
|
|
2734
|
+
}[], {
|
|
2735
|
+
readonly id: "slowMo";
|
|
2736
|
+
readonly label: "Hold slow-mo";
|
|
2737
|
+
readonly keys: readonly ["V"];
|
|
2738
|
+
readonly codes: readonly ["KeyV"];
|
|
2739
|
+
}, {
|
|
2740
|
+
readonly id: "underglow";
|
|
2741
|
+
readonly label: "Toggle underglow";
|
|
2742
|
+
readonly keys: readonly ["U"];
|
|
2743
|
+
readonly codes: readonly ["KeyU"];
|
|
2744
|
+
}, {
|
|
2745
|
+
readonly id: "horn";
|
|
2746
|
+
readonly label: "Horn";
|
|
2747
|
+
readonly keys: readonly ["H"];
|
|
2748
|
+
readonly codes: readonly ["KeyH"];
|
|
2749
|
+
}, {
|
|
2750
|
+
readonly id: "record";
|
|
2751
|
+
readonly label: "Record";
|
|
2752
|
+
readonly keys: readonly ["R"];
|
|
2753
|
+
readonly codes: readonly ["KeyR"];
|
|
2754
|
+
}, {
|
|
2755
|
+
readonly id: "clean";
|
|
2756
|
+
readonly label: "Reset screen";
|
|
2757
|
+
readonly keys: readonly ["C"];
|
|
2758
|
+
readonly codes: readonly ["KeyC"];
|
|
2759
|
+
}, {
|
|
2760
|
+
readonly id: "targets";
|
|
2761
|
+
readonly label: "Flash destroyable objects";
|
|
2762
|
+
readonly keys: readonly ["F"];
|
|
2763
|
+
readonly codes: readonly ["KeyF"];
|
|
2764
|
+
}, {
|
|
2765
|
+
readonly id: "pause";
|
|
2766
|
+
readonly label: "Pause";
|
|
2767
|
+
readonly keys: readonly ["P"];
|
|
2768
|
+
readonly codes: readonly ["KeyP"];
|
|
2769
|
+
}, {
|
|
2770
|
+
readonly id: "exit";
|
|
2771
|
+
readonly label: "Exit";
|
|
2772
|
+
readonly keys: readonly ["Esc"];
|
|
2773
|
+
readonly codes: readonly ["Escape"];
|
|
2774
|
+
}];
|
|
2775
|
+
};
|
|
2776
|
+
export { type Appearance, type DebrisAnchor, type DebrisHandle, type DebrisKind, type DebrisOptions, type DeepReadonly, type EmbedController, type EmbedOptions, type ObjectPatch, type ObjectSpec, type PageDebrisHandle, type PageDebrisTarget, type PlayerConfiguration, type PlaygroundConfiguration, type PlaygroundEventMap, type PlaygroundState, type RuntimeOptions, type RuntimeOptionsPatch, type SlotNumber, type VehicleArrivalOptions, type VehicleArrivalResult, type VehicleConfiguration, type VehicleHandle, type VehiclePatch, type VehicleSpawnOptions, type WorkModeOptions, type WorkModeSettings, api as default };
|