@joy-ride/joy-ride 0.0.0-stage → 0.1.0
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 +44 -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-b9Qe6IWu.js +32 -0
- package/npm/embed-chunks/src-d3m8FEbx.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 +149 -4
|
@@ -0,0 +1,1164 @@
|
|
|
1
|
+
/** Systems can introduce their own numeric multiplier names without changing this store. */
|
|
2
|
+
type VehicleModifier = string;
|
|
3
|
+
type StatusEffectDefinition = {
|
|
4
|
+
lifetime: {
|
|
5
|
+
unit: 'distanceM' | 'seconds';
|
|
6
|
+
amount: number;
|
|
7
|
+
};
|
|
8
|
+
/** Multipliers at full strength; each returns to 1 as the effect expires. */
|
|
9
|
+
modifiers: Partial<Record<VehicleModifier, number>>;
|
|
10
|
+
/** Additive stat changes, with the same lifetime and optional intensity curve. */
|
|
11
|
+
additiveModifiers?: Partial<Record<VehicleModifier, number>>;
|
|
12
|
+
intensity?: 'linear' | 'pulse' | 'constant';
|
|
13
|
+
};
|
|
14
|
+
type ActiveEffect = {
|
|
15
|
+
remaining: number;
|
|
16
|
+
definition: StatusEffectDefinition;
|
|
17
|
+
};
|
|
18
|
+
/** Vehicle-owned modifiers. Sources may target a tire or the whole vehicle. */
|
|
19
|
+
declare class VehicleStatusEffects {
|
|
20
|
+
private active;
|
|
21
|
+
private contacts;
|
|
22
|
+
captureState(): {
|
|
23
|
+
active: Map<string, Map<number | "vehicle", ActiveEffect>>;
|
|
24
|
+
contacts: Map<string, Map<number | "vehicle", Partial<Record<string, number>>>>;
|
|
25
|
+
};
|
|
26
|
+
restoreState(state: ReturnType<VehicleStatusEffects['captureState']>): void;
|
|
27
|
+
setContacts(id: string, modifiers: Partial<Record<VehicleModifier, number>>, tires: readonly number[]): void;
|
|
28
|
+
apply(id: string, definition: StatusEffectDefinition, tire?: number): void;
|
|
29
|
+
remaining(id: string, tire?: number): number;
|
|
30
|
+
remove(id: string): void;
|
|
31
|
+
/** Additive modifiers are useful for impulses that still need a finite lifetime. */
|
|
32
|
+
bonus(modifier: VehicleModifier, tire?: number, count?: number, leadSeconds?: number): number;
|
|
33
|
+
indicators(): {
|
|
34
|
+
label: string;
|
|
35
|
+
fraction: number;
|
|
36
|
+
}[];
|
|
37
|
+
factor(modifier: VehicleModifier, tire?: number, count?: number): number;
|
|
38
|
+
factorFrom(id: string | null, modifier: VehicleModifier, tire?: number, count?: number): number;
|
|
39
|
+
advance(distanceM: number, seconds: number): void;
|
|
40
|
+
clearTire(tire: number): void;
|
|
41
|
+
clear(): void;
|
|
42
|
+
}
|
|
43
|
+
type CombustibleStage = 'intact' | 'smoking' | 'smouldering' | 'burning' | 'exploded';
|
|
44
|
+
/** Shared health and burn lifecycle for DOM objects and vehicles. */
|
|
45
|
+
declare class Burnable {
|
|
46
|
+
maxHealth: number;
|
|
47
|
+
health: number;
|
|
48
|
+
explodedAt: number | null;
|
|
49
|
+
blastQueued: boolean;
|
|
50
|
+
blastAge: number;
|
|
51
|
+
lastBlastEmission: number;
|
|
52
|
+
lastDamageAt: number;
|
|
53
|
+
healthBarShownAt: number;
|
|
54
|
+
constructor(maxHealth?: number);
|
|
55
|
+
get stage(): CombustibleStage;
|
|
56
|
+
get healthFraction(): number;
|
|
57
|
+
resetBurnable(maxHealth?: number): void;
|
|
58
|
+
/** Returns true only for the hit that takes health to zero. */
|
|
59
|
+
damage(amount: number, now?: number): boolean;
|
|
60
|
+
/** Quick reveal on contact, then a short hold and fade. */
|
|
61
|
+
healthBarAlpha(now?: number): number;
|
|
62
|
+
}
|
|
63
|
+
type Vec2 = {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
};
|
|
67
|
+
type VehicleMode = 'car' | 'ship' | 'brick';
|
|
68
|
+
type Controls = {
|
|
69
|
+
throttle: number;
|
|
70
|
+
/** Service brake, separate from reverse throttle and the drift handbrake. */
|
|
71
|
+
brake?: number;
|
|
72
|
+
steer: number;
|
|
73
|
+
action: boolean;
|
|
74
|
+
boost?: boolean;
|
|
75
|
+
/** Raw numbered input, resolved by each vehicle before policy and physics. */
|
|
76
|
+
slots?: readonly number[];
|
|
77
|
+
slotPresses?: readonly number[];
|
|
78
|
+
eject?: boolean;
|
|
79
|
+
machineGun?: boolean;
|
|
80
|
+
flamethrower?: boolean;
|
|
81
|
+
rocket?: boolean;
|
|
82
|
+
ghost?: boolean;
|
|
83
|
+
attractor?: boolean;
|
|
84
|
+
lightning?: boolean;
|
|
85
|
+
};
|
|
86
|
+
declare class Body {
|
|
87
|
+
mass: number;
|
|
88
|
+
inertia: number;
|
|
89
|
+
position: Vec2;
|
|
90
|
+
velocity: Vec2;
|
|
91
|
+
angle: number;
|
|
92
|
+
spin: number;
|
|
93
|
+
private force;
|
|
94
|
+
private torque;
|
|
95
|
+
captureState(): {
|
|
96
|
+
mass: number;
|
|
97
|
+
inertia: number;
|
|
98
|
+
position: Vec2;
|
|
99
|
+
velocity: Vec2;
|
|
100
|
+
angle: number;
|
|
101
|
+
spin: number;
|
|
102
|
+
force: Vec2;
|
|
103
|
+
torque: number;
|
|
104
|
+
};
|
|
105
|
+
restoreState(state: ReturnType<Body['captureState']>): void;
|
|
106
|
+
reset(): void;
|
|
107
|
+
world(local: Vec2): Vec2;
|
|
108
|
+
local(world: Vec2): Vec2;
|
|
109
|
+
velocityAt(point: Vec2): Vec2;
|
|
110
|
+
push(force: Vec2, point?: Vec2): void;
|
|
111
|
+
impulse(force: Vec2, point?: Vec2): void;
|
|
112
|
+
tick(dt: number): void;
|
|
113
|
+
}
|
|
114
|
+
type Tire = {
|
|
115
|
+
local: Vec2;
|
|
116
|
+
front: boolean;
|
|
117
|
+
angle: number;
|
|
118
|
+
skidding: boolean;
|
|
119
|
+
lateralSpeed: number;
|
|
120
|
+
slipSpeedMps: number;
|
|
121
|
+
/** Signed tread speed along the wheel heading, including driven spin or a locked rear axle. */
|
|
122
|
+
wheelSurfaceSpeedMps: number;
|
|
123
|
+
slip: number;
|
|
124
|
+
heat: number;
|
|
125
|
+
spinning: boolean;
|
|
126
|
+
lateralForceN: number;
|
|
127
|
+
gripUtilization: number;
|
|
128
|
+
};
|
|
129
|
+
declare class Car extends Burnable {
|
|
130
|
+
/** Health/combustion is independent of visual dents and collision physics. */
|
|
131
|
+
destructible: boolean;
|
|
132
|
+
get stage(): Burnable['stage'];
|
|
133
|
+
damage(amount: number, now?: number): boolean;
|
|
134
|
+
tires: Tire[];
|
|
135
|
+
engineForce: number;
|
|
136
|
+
rollingResistance: number;
|
|
137
|
+
lateralResistance: number;
|
|
138
|
+
handbrakeStrength: number;
|
|
139
|
+
drifting: boolean;
|
|
140
|
+
donuting: boolean;
|
|
141
|
+
burnout: boolean;
|
|
142
|
+
launchSpinSeconds: number;
|
|
143
|
+
boostCharge: number;
|
|
144
|
+
boostReady: boolean;
|
|
145
|
+
get boostActive(): boolean;
|
|
146
|
+
burnOriginLocal: Vec2;
|
|
147
|
+
readonly statusEffects: VehicleStatusEffects;
|
|
148
|
+
get oilDistanceRemainingM(): number;
|
|
149
|
+
get oilGripFactor(): number;
|
|
150
|
+
oilGripFactorFor(index: number): number;
|
|
151
|
+
coatWithOil(index?: number): void;
|
|
152
|
+
coatWithMud(index?: number): void;
|
|
153
|
+
washWheel(index: number): void;
|
|
154
|
+
advanceOil(distanceM: number): void;
|
|
155
|
+
frontLoadFraction: number;
|
|
156
|
+
slideAngleRad: number;
|
|
157
|
+
countersteering: boolean;
|
|
158
|
+
private driftDirection;
|
|
159
|
+
private driftStart;
|
|
160
|
+
private donutDirection;
|
|
161
|
+
private steeringAngle;
|
|
162
|
+
private steeringReferenceSpeed;
|
|
163
|
+
private previousVelocity;
|
|
164
|
+
private longitudinalAcceleration;
|
|
165
|
+
private burnoutSeconds;
|
|
166
|
+
private boostChargeSeconds;
|
|
167
|
+
private launchPeakRpm;
|
|
168
|
+
private launchAssistElapsed;
|
|
169
|
+
private launchAssistGainMps;
|
|
170
|
+
preset: VehiclePreset;
|
|
171
|
+
constructor();
|
|
172
|
+
captureState(): {
|
|
173
|
+
maxHealth: number;
|
|
174
|
+
health: number;
|
|
175
|
+
explodedAt: number | null;
|
|
176
|
+
blastQueued: boolean;
|
|
177
|
+
blastAge: number;
|
|
178
|
+
lastBlastEmission: number;
|
|
179
|
+
lastDamageAt: number;
|
|
180
|
+
healthBarShownAt: number;
|
|
181
|
+
destructible: boolean;
|
|
182
|
+
tires: Tire[];
|
|
183
|
+
engineForce: number;
|
|
184
|
+
rollingResistance: number;
|
|
185
|
+
lateralResistance: number;
|
|
186
|
+
handbrakeStrength: number;
|
|
187
|
+
drifting: boolean;
|
|
188
|
+
donuting: boolean;
|
|
189
|
+
burnout: boolean;
|
|
190
|
+
launchSpinSeconds: number;
|
|
191
|
+
boostCharge: number;
|
|
192
|
+
boostReady: boolean;
|
|
193
|
+
burnOriginLocal: Vec2;
|
|
194
|
+
frontLoadFraction: number;
|
|
195
|
+
slideAngleRad: number;
|
|
196
|
+
countersteering: boolean;
|
|
197
|
+
driftDirection: number;
|
|
198
|
+
driftStart: {
|
|
199
|
+
position: Vec2;
|
|
200
|
+
velocity: Vec2;
|
|
201
|
+
angle: number;
|
|
202
|
+
spin: number;
|
|
203
|
+
} | null;
|
|
204
|
+
donutDirection: number;
|
|
205
|
+
steeringAngle: number;
|
|
206
|
+
steeringReferenceSpeed: number;
|
|
207
|
+
previousVelocity: Vec2 | null;
|
|
208
|
+
longitudinalAcceleration: number;
|
|
209
|
+
burnoutSeconds: number;
|
|
210
|
+
boostChargeSeconds: number;
|
|
211
|
+
launchPeakRpm: number;
|
|
212
|
+
launchAssistElapsed: number;
|
|
213
|
+
launchAssistGainMps: number;
|
|
214
|
+
statusEffects: {
|
|
215
|
+
active: Map<string, Map<number | "vehicle", {
|
|
216
|
+
remaining: number;
|
|
217
|
+
definition: StatusEffectDefinition;
|
|
218
|
+
}>>;
|
|
219
|
+
contacts: Map<string, Map<number | "vehicle", Partial<Record<string, number>>>>;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
restoreState(state: ReturnType<Car['captureState']>): void;
|
|
223
|
+
takeImpact(speedMps: number, localPoint?: Vec2): boolean;
|
|
224
|
+
advanceBurn(dt: number): boolean;
|
|
225
|
+
configure(preset: VehiclePreset): void;
|
|
226
|
+
reset(): void;
|
|
227
|
+
get fastDrifting(): boolean;
|
|
228
|
+
private prepareDrift;
|
|
229
|
+
tick(body: Body, input: Controls, dt: number, engineRpm?: number | null): void;
|
|
230
|
+
private tickForces;
|
|
231
|
+
slow(body: Body, input: Controls, dt: number): void;
|
|
232
|
+
finishDrift(body: Body, input: Controls, dt: number): void;
|
|
233
|
+
/** Let ordinary driving follow the nose promptly, while handbrake slides keep their own momentum. */
|
|
234
|
+
arcadeAssist(body: Body, input: Controls, dt: number): void;
|
|
235
|
+
}
|
|
236
|
+
declare class Ship {
|
|
237
|
+
headAngle: number;
|
|
238
|
+
appliedForce: Vec2;
|
|
239
|
+
readonly craft: Vec2;
|
|
240
|
+
readonly counterweight: Vec2;
|
|
241
|
+
readonly radius = 0.9;
|
|
242
|
+
captureState(): {
|
|
243
|
+
headAngle: number;
|
|
244
|
+
appliedForce: Vec2;
|
|
245
|
+
craft: Vec2;
|
|
246
|
+
counterweight: Vec2;
|
|
247
|
+
radius: number;
|
|
248
|
+
};
|
|
249
|
+
restoreState(state: ReturnType<Ship['captureState']>): void;
|
|
250
|
+
reset(): void;
|
|
251
|
+
tick(body: Body, input: Controls, dt: number): void;
|
|
252
|
+
}
|
|
253
|
+
type SimulationState = {
|
|
254
|
+
at: number;
|
|
255
|
+
preset: VehiclePreset;
|
|
256
|
+
simulation: {
|
|
257
|
+
mode: VehicleMode;
|
|
258
|
+
gravity: boolean;
|
|
259
|
+
barrier: boolean;
|
|
260
|
+
paused: boolean;
|
|
261
|
+
lastInput: Controls;
|
|
262
|
+
brickForce: {
|
|
263
|
+
local: Vec2;
|
|
264
|
+
force: Vec2;
|
|
265
|
+
} | null;
|
|
266
|
+
};
|
|
267
|
+
body: ReturnType<Body['captureState']>;
|
|
268
|
+
car: ReturnType<Car['captureState']>;
|
|
269
|
+
ship: ReturnType<Ship['captureState']>;
|
|
270
|
+
};
|
|
271
|
+
declare class Simulation {
|
|
272
|
+
readonly body: Body;
|
|
273
|
+
readonly car: Car;
|
|
274
|
+
readonly ship: Ship;
|
|
275
|
+
mode: VehicleMode;
|
|
276
|
+
gravity: boolean;
|
|
277
|
+
barrier: boolean;
|
|
278
|
+
paused: boolean;
|
|
279
|
+
lastInput: Controls;
|
|
280
|
+
brickForce: {
|
|
281
|
+
local: Vec2;
|
|
282
|
+
force: Vec2;
|
|
283
|
+
} | null;
|
|
284
|
+
/** An in-memory checkpoint of every mutable physics field, including forces and burn state. */
|
|
285
|
+
captureState(): SimulationState;
|
|
286
|
+
restoreState(state: SimulationState): void;
|
|
287
|
+
setPreset(preset: VehiclePreset): void;
|
|
288
|
+
setMode(mode: VehicleMode): void;
|
|
289
|
+
reset(): void;
|
|
290
|
+
/** Stop and clear wheel/boost state without moving or rotating the vehicle. */
|
|
291
|
+
resetAtCurrentPose(): void;
|
|
292
|
+
tick(input: Controls, dt: number, engineRpm?: number | null): void;
|
|
293
|
+
contain(bounds: {
|
|
294
|
+
left: number;
|
|
295
|
+
right: number;
|
|
296
|
+
bottom: number;
|
|
297
|
+
top: number;
|
|
298
|
+
}): void;
|
|
299
|
+
}
|
|
300
|
+
type LightningProfile = {
|
|
301
|
+
rangeM?: number;
|
|
302
|
+
/** Soft preference for the vehicle nose. Zero restores nearest-only targeting. */
|
|
303
|
+
forwardBias?: number;
|
|
304
|
+
chargeSeconds?: number;
|
|
305
|
+
statusSeconds?: number;
|
|
306
|
+
speedFactor?: number;
|
|
307
|
+
impactRadiusM?: number;
|
|
308
|
+
damage?: number;
|
|
309
|
+
impulse?: number;
|
|
310
|
+
ignite?: boolean;
|
|
311
|
+
};
|
|
312
|
+
/** Fixed-step charge state. Object discovery and damage belong to the world. */
|
|
313
|
+
declare class LightningWeapon {
|
|
314
|
+
charging: boolean;
|
|
315
|
+
charge: number;
|
|
316
|
+
target: Vec2 | null;
|
|
317
|
+
dischargeAge: number;
|
|
318
|
+
dischargeId: number;
|
|
319
|
+
dischargeTargets: Vec2[];
|
|
320
|
+
dischargePaths: Vec2[][];
|
|
321
|
+
private pending;
|
|
322
|
+
private elapsed;
|
|
323
|
+
captureState(): {
|
|
324
|
+
charging: boolean;
|
|
325
|
+
charge: number;
|
|
326
|
+
target: Vec2 | null;
|
|
327
|
+
dischargeAge: number;
|
|
328
|
+
dischargeId: number;
|
|
329
|
+
dischargeTargets: Vec2[];
|
|
330
|
+
dischargePaths: Vec2[][];
|
|
331
|
+
pending: boolean;
|
|
332
|
+
elapsed: number;
|
|
333
|
+
};
|
|
334
|
+
restoreState(state: ReturnType<LightningWeapon['captureState']>): void;
|
|
335
|
+
get visual(): {
|
|
336
|
+
phase: "discharged" | "charging" | "idle";
|
|
337
|
+
charge: number;
|
|
338
|
+
target: Vec2 | null;
|
|
339
|
+
dischargeAge: number;
|
|
340
|
+
dischargeId: number;
|
|
341
|
+
branches: Vec2[];
|
|
342
|
+
paths: Vec2[][];
|
|
343
|
+
};
|
|
344
|
+
step(seconds: number, held: boolean, capacity: number, reserveFraction?: number): void;
|
|
345
|
+
takeDischarge(): boolean;
|
|
346
|
+
discharge(targets: readonly Vec2[], paths?: readonly (readonly Vec2[])[]): void;
|
|
347
|
+
reset(): void;
|
|
348
|
+
}
|
|
349
|
+
type VehicleGeometry = {
|
|
350
|
+
/** Layout/physics dimensions; image alpha defines DOM collision when supplied. */
|
|
351
|
+
lengthM: number;
|
|
352
|
+
widthM: number;
|
|
353
|
+
wheelbaseM: number;
|
|
354
|
+
/** Optional independent axle centers, measured from the body center toward the nose. */
|
|
355
|
+
frontAxleXM?: number;
|
|
356
|
+
rearAxleXM?: number;
|
|
357
|
+
trackWidthM: number;
|
|
358
|
+
/** Optional axle-specific widths for sprites whose body tapers. */
|
|
359
|
+
frontTrackWidthM?: number;
|
|
360
|
+
rearTrackWidthM?: number;
|
|
361
|
+
tireLengthM: number;
|
|
362
|
+
tireWidthM: number;
|
|
363
|
+
};
|
|
364
|
+
/** A square roof hatch in body-local simulation metres; +x points toward the nose. */
|
|
365
|
+
type RoofRocketMount = {
|
|
366
|
+
xM: number;
|
|
367
|
+
yM: number;
|
|
368
|
+
sizeM: number;
|
|
369
|
+
panelColor: string;
|
|
370
|
+
};
|
|
371
|
+
/** Twin side mounts. Omitted values use the common arcade gun profile. */
|
|
372
|
+
type MachineGunProfile = {
|
|
373
|
+
/** Longitudinal position of each gun in body-local metres. */
|
|
374
|
+
xM?: number;
|
|
375
|
+
/** How far the body-side panel slides outward, exposing the fixed gun. */
|
|
376
|
+
revealM?: number;
|
|
377
|
+
/** Rounds per second from each gun. */
|
|
378
|
+
roundsPerSecond?: number;
|
|
379
|
+
bulletSpeedMps?: number;
|
|
380
|
+
bulletLifetimeSeconds?: number;
|
|
381
|
+
};
|
|
382
|
+
type FlamethrowerProfile = {
|
|
383
|
+
rangeM?: number;
|
|
384
|
+
ignitionSeconds?: number;
|
|
385
|
+
/** Time for fire to travel between touching destructible pieces or objects. */
|
|
386
|
+
spreadSeconds?: number;
|
|
387
|
+
/** Largest edge-to-edge gap fire can cross between destructible objects. */
|
|
388
|
+
spreadRadiusPx?: number;
|
|
389
|
+
burnSeconds?: number;
|
|
390
|
+
smokePerSecond?: number;
|
|
391
|
+
jetWidthM?: number;
|
|
392
|
+
/** Continuous flame output; scales heat exposure and fluid smoke. */
|
|
393
|
+
flowRate?: number;
|
|
394
|
+
};
|
|
395
|
+
type RocketWeaponProfile = {
|
|
396
|
+
roundsPerSecond?: number;
|
|
397
|
+
launchSpeedMps?: number;
|
|
398
|
+
accelerationMps2?: number;
|
|
399
|
+
maxSpeedMps?: number;
|
|
400
|
+
lifetimeSeconds?: number;
|
|
401
|
+
smokePerSecond?: number;
|
|
402
|
+
};
|
|
403
|
+
/** Stylized dual-note horn. Frequencies are inspired by automotive horn pairs, not OEM measurements. */
|
|
404
|
+
type HornProfile = {
|
|
405
|
+
lowHz: number;
|
|
406
|
+
highHz: number;
|
|
407
|
+
tone: 'disc' | 'trumpet' | 'electronic';
|
|
408
|
+
level: number;
|
|
409
|
+
};
|
|
410
|
+
type ExhaustLayout = 'left' | 'right' | 'center' | 'left-right';
|
|
411
|
+
/** One lamp in a mirrored pair. Body-local metres: +X nose, +Y left. */
|
|
412
|
+
type VehicleLightMount = {
|
|
413
|
+
xM: number;
|
|
414
|
+
yM: number;
|
|
415
|
+
};
|
|
416
|
+
type VehicleLightMounts = {
|
|
417
|
+
headlights: VehicleLightMount;
|
|
418
|
+
taillights: VehicleLightMount;
|
|
419
|
+
};
|
|
420
|
+
/** Physics values are tuned for the arcade model, not manufacturer specifications. */
|
|
421
|
+
type VehiclePreset = {
|
|
422
|
+
id: string;
|
|
423
|
+
name: string;
|
|
424
|
+
description: string;
|
|
425
|
+
make?: string;
|
|
426
|
+
model?: string;
|
|
427
|
+
year?: string;
|
|
428
|
+
massKg: number;
|
|
429
|
+
/** Maximum vehicle health. Omitted presets use the shared vehicle default. */
|
|
430
|
+
health?: number;
|
|
431
|
+
/** Arcade static balance. The remainder rests on the rear axle. */
|
|
432
|
+
frontWeightFraction?: number;
|
|
433
|
+
geometry: VehicleGeometry;
|
|
434
|
+
/** Tailpipe positions on the rear edge, viewed with the nose facing right. */
|
|
435
|
+
exhaust: {
|
|
436
|
+
layout: ExhaustLayout;
|
|
437
|
+
};
|
|
438
|
+
/** Lamp locations shared by sprite bloom, ground spill, smoke lighting, and the point editor. */
|
|
439
|
+
lights?: Partial<VehicleLightMounts>;
|
|
440
|
+
roofRocket: RoofRocketMount;
|
|
441
|
+
machineGuns?: MachineGunProfile;
|
|
442
|
+
flamethrower?: FlamethrowerProfile;
|
|
443
|
+
rockets?: RocketWeaponProfile;
|
|
444
|
+
lightning?: LightningProfile;
|
|
445
|
+
/** Engine_Sim sound and drivetrain profiles. */
|
|
446
|
+
sound: {
|
|
447
|
+
engineId: string;
|
|
448
|
+
vehicleId: string;
|
|
449
|
+
engineLabel: string;
|
|
450
|
+
turbo?: boolean;
|
|
451
|
+
/** Light or heavy recorded starter; defaults by vehicle size. */
|
|
452
|
+
starter?: 'light' | 'heavy';
|
|
453
|
+
horn: HornProfile;
|
|
454
|
+
/** Synthetic low-speed pedestrian tone; the combustion voice is muted. */
|
|
455
|
+
electric?: {
|
|
456
|
+
/** Low-speed pedestrian tone. */
|
|
457
|
+
fadeStartMps: number;
|
|
458
|
+
fadeEndMps: number;
|
|
459
|
+
/** Driving motor whine. */
|
|
460
|
+
motorFadeStartMps: number;
|
|
461
|
+
motorFadeEndMps: number;
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
/** Canvas fallback when no top-down image is supplied. */
|
|
465
|
+
visual?: {
|
|
466
|
+
color: string;
|
|
467
|
+
shape: 'coupe' | 'sedan' | 'suv' | 'supercar';
|
|
468
|
+
};
|
|
469
|
+
engineForceN: number;
|
|
470
|
+
reversePowerRatio: number;
|
|
471
|
+
/** Arcade top speed while backing up. Defaults to 7 m/s. */
|
|
472
|
+
maxReverseSpeedMps?: number;
|
|
473
|
+
rollingResistance: number;
|
|
474
|
+
/** Arcade deceleration when the driver releases the throttle, in m/s². */
|
|
475
|
+
coastDecelerationMps2: number;
|
|
476
|
+
/** Additional deceleration while the handbrake is held, in m/s². */
|
|
477
|
+
handbrakeDecelerationMps2: number;
|
|
478
|
+
/** Longitudinal service braking, separate from the drift handbrake. */
|
|
479
|
+
serviceBrakeDecelerationMps2?: number;
|
|
480
|
+
lateralResistance: number;
|
|
481
|
+
/** Arcade lateral acceleration budget for fast corners, in m/s². */
|
|
482
|
+
corneringAccelerationMps2: number;
|
|
483
|
+
maxSteerAngleRad: number;
|
|
484
|
+
handbrakeStrength: number;
|
|
485
|
+
/** Steerable handbrake drift shared by every vehicle. */
|
|
486
|
+
drift: {
|
|
487
|
+
entrySpeedMps: number;
|
|
488
|
+
slipAngleRad: number;
|
|
489
|
+
};
|
|
490
|
+
/** Brake-held launch. Hold Shift for a full burnout ramp to arm the fiery launch. */
|
|
491
|
+
launch: {
|
|
492
|
+
minRpm: number;
|
|
493
|
+
/** Extra speed budget spread over the launch assist window. */
|
|
494
|
+
boostMps: number;
|
|
495
|
+
boostedBoostMps: number;
|
|
496
|
+
assistDurationSeconds: number;
|
|
497
|
+
burnoutRampSeconds: number;
|
|
498
|
+
chargedSpinSeconds: number;
|
|
499
|
+
fireLifetimeSeconds: number;
|
|
500
|
+
};
|
|
501
|
+
/** Held Shift boost: total speed gain over a full reserve and its refill time. */
|
|
502
|
+
driveBoost: {
|
|
503
|
+
gainMps: number;
|
|
504
|
+
durationSeconds: number;
|
|
505
|
+
cooldownSeconds: number;
|
|
506
|
+
};
|
|
507
|
+
/** Optional transparent, top-down image with its nose facing right. */
|
|
508
|
+
image?: {
|
|
509
|
+
src: string;
|
|
510
|
+
/** Normalized visible-content rectangle, so transparent padding is not stretched. */
|
|
511
|
+
crop?: {
|
|
512
|
+
x: number;
|
|
513
|
+
y: number;
|
|
514
|
+
width: number;
|
|
515
|
+
height: number;
|
|
516
|
+
};
|
|
517
|
+
/** Uniform visual scale for aligning painted fenders with the simulated wheels. */
|
|
518
|
+
scale?: number;
|
|
519
|
+
/** Image-specific wheel reveal scale; omitted images use the standard fender fit. */
|
|
520
|
+
wheelVisualScale?: {
|
|
521
|
+
length: number;
|
|
522
|
+
width: number;
|
|
523
|
+
};
|
|
524
|
+
/** Visible body half-width at each axle, sampled from the cutout alpha. */
|
|
525
|
+
wheelEdgeHalfWidthM?: {
|
|
526
|
+
front: number;
|
|
527
|
+
rear: number;
|
|
528
|
+
};
|
|
529
|
+
};
|
|
530
|
+
};
|
|
531
|
+
/** Numbered vehicle actions. Input bindings never encode a material or weapon name. */
|
|
532
|
+
declare const slotNumbers: readonly [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
533
|
+
type SlotNumber = (typeof slotNumbers)[number];
|
|
534
|
+
type SlotActivation = 'tap' | 'hold';
|
|
535
|
+
declare const vehicleSlotActions: readonly ["eject", "machineGun", "flamethrower", "rocket", "ghost", "attractor", "lightning", "boost"];
|
|
536
|
+
type VehicleSlotAction = (typeof vehicleSlotActions)[number];
|
|
537
|
+
type LiquidSlot = {
|
|
538
|
+
action: 'eject';
|
|
539
|
+
liquid: string;
|
|
540
|
+
activation?: SlotActivation;
|
|
541
|
+
rate?: number;
|
|
542
|
+
amount?: number;
|
|
543
|
+
};
|
|
544
|
+
type ToolSlot = {
|
|
545
|
+
action: Exclude<VehicleSlotAction, 'eject'>;
|
|
546
|
+
liquid?: never;
|
|
547
|
+
activation?: SlotActivation;
|
|
548
|
+
rate?: never;
|
|
549
|
+
amount?: never;
|
|
550
|
+
};
|
|
551
|
+
type VehicleSlot = LiquidSlot | ToolSlot;
|
|
552
|
+
type VehicleSlots = Partial<Record<SlotNumber, VehicleSlot | false>>;
|
|
553
|
+
type LiquidEmission = {
|
|
554
|
+
slot: SlotNumber;
|
|
555
|
+
liquid: string;
|
|
556
|
+
amount: number;
|
|
557
|
+
};
|
|
558
|
+
type VehicleTool = VehicleSlot['action'];
|
|
559
|
+
type VehicleToolPolicy = {
|
|
560
|
+
enabledTools?: readonly VehicleTool[];
|
|
561
|
+
weaponsEnabled?: boolean;
|
|
562
|
+
};
|
|
563
|
+
type VehicleToolDefinition = {
|
|
564
|
+
id: VehicleTool;
|
|
565
|
+
label: string;
|
|
566
|
+
keys: readonly string[];
|
|
567
|
+
description: string;
|
|
568
|
+
sfw: boolean;
|
|
569
|
+
/** Used by the existing weaponsEnabled master switch. */
|
|
570
|
+
weapon: boolean;
|
|
571
|
+
};
|
|
572
|
+
declare function availableVehicleTools(enabledTools: readonly VehicleTool[], weaponsEnabled?: boolean, slots?: Readonly<VehicleSlots>): {
|
|
573
|
+
keys: string[];
|
|
574
|
+
id: VehicleTool;
|
|
575
|
+
label: string;
|
|
576
|
+
description: string;
|
|
577
|
+
sfw: boolean;
|
|
578
|
+
/** Used by the existing weaponsEnabled master switch. */
|
|
579
|
+
weapon: boolean;
|
|
580
|
+
}[];
|
|
581
|
+
type LiquidFamily = 'oil' | 'water' | 'paint' | 'mud';
|
|
582
|
+
type ConceptLiquidKind = 'concept-water' | 'concept-oil' | 'concept-syrup' | 'concept-clay' | 'concept-lava' | 'concept-acid' | 'concept-paint';
|
|
583
|
+
type BuiltinLiquidKind = LiquidFamily | 'iridescent-oil' | 'clear-water' | 'wet-clay' | ConceptLiquidKind;
|
|
584
|
+
type CustomLiquidKind = `custom:${string}`;
|
|
585
|
+
type LiquidKind = BuiltinLiquidKind | CustomLiquidKind;
|
|
586
|
+
type LiquidColor = readonly [number, number, number];
|
|
587
|
+
type LiquidColorInput = LiquidColor | `#${string}`;
|
|
588
|
+
type LiquidDefinition = {
|
|
589
|
+
readonly kind: LiquidKind;
|
|
590
|
+
};
|
|
591
|
+
type LiquidSource = LiquidKind | LiquidDefinition;
|
|
592
|
+
type LiquidPourOptions = {
|
|
593
|
+
at: {
|
|
594
|
+
x: number;
|
|
595
|
+
y: number;
|
|
596
|
+
};
|
|
597
|
+
amount?: number;
|
|
598
|
+
color?: LiquidColorInput;
|
|
599
|
+
/** Recreated when the scene is reset or effects are cleared. */
|
|
600
|
+
initial?: boolean;
|
|
601
|
+
};
|
|
602
|
+
/** Contact residue is a material property shared by pools, spray and tire stamps.
|
|
603
|
+
* No renderer chooses a tread or splatter shape by liquid name.
|
|
604
|
+
*/
|
|
605
|
+
type LiquidResidue = {
|
|
606
|
+
coverage: number;
|
|
607
|
+
breakup: number;
|
|
608
|
+
film: number;
|
|
609
|
+
gloss: number;
|
|
610
|
+
iridescence: number;
|
|
611
|
+
grain: number;
|
|
612
|
+
drain: number;
|
|
613
|
+
pitchM: number;
|
|
614
|
+
spray: number;
|
|
615
|
+
impact: number;
|
|
616
|
+
carryM: number;
|
|
617
|
+
emission: number;
|
|
618
|
+
};
|
|
619
|
+
type DefineLiquidOptions = {
|
|
620
|
+
base: LiquidKind;
|
|
621
|
+
/** Carry a discharge across connected wet cells. Inherited from the base. */
|
|
622
|
+
conductive?: boolean;
|
|
623
|
+
/** Accept ignition and consume fuel through the shared surface-fire system. */
|
|
624
|
+
burnable?: boolean;
|
|
625
|
+
color?: LiquidColorInput;
|
|
626
|
+
thickness?: number;
|
|
627
|
+
/** Tire pull strength, 0–4; defaults to the base material. */
|
|
628
|
+
deformation?: number;
|
|
629
|
+
opacity?: number;
|
|
630
|
+
/** Seconds each part of a burnable surface burns; inherits the base or defaults to 12. */
|
|
631
|
+
burnLifetime?: number;
|
|
632
|
+
/** Speed of the connected surface's fire front in metres per second. */
|
|
633
|
+
fireSpreadMps?: number;
|
|
634
|
+
/** Refreshed on wheel contact; fades after the wheel leaves the pool. */
|
|
635
|
+
effect?: StatusEffectDefinition;
|
|
636
|
+
};
|
|
637
|
+
type DustParcel = {
|
|
638
|
+
x: number;
|
|
639
|
+
y: number;
|
|
640
|
+
z: number;
|
|
641
|
+
vx: number;
|
|
642
|
+
vy: number;
|
|
643
|
+
vz: number;
|
|
644
|
+
radius: number;
|
|
645
|
+
spread: number;
|
|
646
|
+
angle: number;
|
|
647
|
+
mass: number;
|
|
648
|
+
seed: number;
|
|
649
|
+
};
|
|
650
|
+
type DustPatch = {
|
|
651
|
+
parcels: DustParcel[];
|
|
652
|
+
radius: number;
|
|
653
|
+
};
|
|
654
|
+
declare const debrisKinds: readonly ["paper", "crumpled-paper", "trash", "leaf", "dust"];
|
|
655
|
+
type DebrisKind = (typeof debrisKinds)[number];
|
|
656
|
+
declare const debrisAnchors: readonly ["center", "top", "top-right", "right", "bottom-right", "bottom", "bottom-left", "left", "top-left", "fill"];
|
|
657
|
+
type DebrisAnchor = (typeof debrisAnchors)[number];
|
|
658
|
+
type DebrisVector = {
|
|
659
|
+
x: number;
|
|
660
|
+
y: number;
|
|
661
|
+
};
|
|
662
|
+
type DebrisBounds = DebrisVector & {
|
|
663
|
+
width: number;
|
|
664
|
+
height: number;
|
|
665
|
+
};
|
|
666
|
+
type DebrisOptions = {
|
|
667
|
+
amount?: number;
|
|
668
|
+
kinds?: readonly DebrisKind[];
|
|
669
|
+
anchor?: DebrisAnchor;
|
|
670
|
+
/** Scatter radius in scene pixels; fill uses the element's complete bounds. */
|
|
671
|
+
spread?: number;
|
|
672
|
+
seed?: number;
|
|
673
|
+
/** Ambient air velocity in scene pixels/second. Vehicle wakes are added automatically. */
|
|
674
|
+
wind?: DebrisVector;
|
|
675
|
+
/** Optional powder/litter tint, otherwise each material uses its own natural palette. */
|
|
676
|
+
color?: string;
|
|
677
|
+
/** Mineral sparkle in powder, 0–1; default 0.12. Zero disables glints. */
|
|
678
|
+
glint?: number;
|
|
679
|
+
};
|
|
680
|
+
type DebrisParticle = {
|
|
681
|
+
kind: DebrisKind;
|
|
682
|
+
x: number;
|
|
683
|
+
y: number;
|
|
684
|
+
z: number;
|
|
685
|
+
vx: number;
|
|
686
|
+
vy: number;
|
|
687
|
+
vz: number;
|
|
688
|
+
angle: number;
|
|
689
|
+
spin: number;
|
|
690
|
+
tilt: number;
|
|
691
|
+
fold: number;
|
|
692
|
+
/** Independent sheet curvature and torsion, in radians; separate from whole-body tumble. */
|
|
693
|
+
curlX: number;
|
|
694
|
+
curlY: number;
|
|
695
|
+
twist: number;
|
|
696
|
+
curlVelocityX: number;
|
|
697
|
+
curlVelocityY: number;
|
|
698
|
+
twistVelocity: number;
|
|
699
|
+
size: number;
|
|
700
|
+
seed: number;
|
|
701
|
+
color: string;
|
|
702
|
+
age: number;
|
|
703
|
+
opacity: number;
|
|
704
|
+
glint: number;
|
|
705
|
+
dust?: DustPatch;
|
|
706
|
+
};
|
|
707
|
+
type DebrisVehicle = DebrisVector & {
|
|
708
|
+
vx: number;
|
|
709
|
+
vy: number;
|
|
710
|
+
angle: number;
|
|
711
|
+
length: number;
|
|
712
|
+
width: number;
|
|
713
|
+
};
|
|
714
|
+
type DebrisHandle = {
|
|
715
|
+
readonly id: string;
|
|
716
|
+
reset(): void;
|
|
717
|
+
gust(velocity: DebrisVector): void;
|
|
718
|
+
dispose(): void;
|
|
719
|
+
};
|
|
720
|
+
type Resolved = Required<DebrisOptions>;
|
|
721
|
+
type Group = {
|
|
722
|
+
options: Resolved;
|
|
723
|
+
bounds: DebrisBounds;
|
|
724
|
+
particles: DebrisParticle[];
|
|
725
|
+
gust: DebrisVector;
|
|
726
|
+
gustAge: number;
|
|
727
|
+
};
|
|
728
|
+
type Vortex = DebrisVector & {
|
|
729
|
+
vx: number;
|
|
730
|
+
vy: number;
|
|
731
|
+
strength: number;
|
|
732
|
+
radius: number;
|
|
733
|
+
age: number;
|
|
734
|
+
};
|
|
735
|
+
/** One bounded scene-pixel simulation, shared by the page and canvas worlds. No DOM or rendering. */
|
|
736
|
+
declare class Debris {
|
|
737
|
+
private groups;
|
|
738
|
+
private vortices;
|
|
739
|
+
private serial;
|
|
740
|
+
private time;
|
|
741
|
+
private wakeClock;
|
|
742
|
+
private collection;
|
|
743
|
+
get particles(): readonly DebrisParticle[];
|
|
744
|
+
get count(): number;
|
|
745
|
+
get managedBytes(): number;
|
|
746
|
+
private collect;
|
|
747
|
+
scatter(bounds: DebrisBounds, options?: DebrisOptions): DebrisHandle;
|
|
748
|
+
get(id: string): DebrisHandle | null;
|
|
749
|
+
private handle;
|
|
750
|
+
reset(): void;
|
|
751
|
+
clear(): void;
|
|
752
|
+
captureState(): {
|
|
753
|
+
groups: Map<string, Group>;
|
|
754
|
+
vortices: Vortex[];
|
|
755
|
+
serial: number;
|
|
756
|
+
time: number;
|
|
757
|
+
wakeClock: number;
|
|
758
|
+
};
|
|
759
|
+
restoreState(state: ReturnType<Debris['captureState']>): void;
|
|
760
|
+
step(seconds: number, vehicles?: readonly DebrisVehicle[], viewport?: DebrisBounds, walls?: readonly DebrisBounds[]): void;
|
|
761
|
+
private airAt;
|
|
762
|
+
private integrate;
|
|
763
|
+
}
|
|
764
|
+
type Capability<T extends object> = boolean | T;
|
|
765
|
+
type Appearance = 'auto' | 'light' | 'dark';
|
|
766
|
+
type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
767
|
+
readonly [key: string]: JsonValue;
|
|
768
|
+
};
|
|
769
|
+
type BreakableOptions = {
|
|
770
|
+
health?: number;
|
|
771
|
+
};
|
|
772
|
+
type BurnableOptions = {
|
|
773
|
+
burnSeconds?: number;
|
|
774
|
+
ignitionSeconds?: number;
|
|
775
|
+
spreadSeconds?: number;
|
|
776
|
+
};
|
|
777
|
+
type CombustibleOptions = {
|
|
778
|
+
health?: number;
|
|
779
|
+
burnSeconds?: number;
|
|
780
|
+
blastRadiusPx?: number;
|
|
781
|
+
};
|
|
782
|
+
type CrushableOptions = {
|
|
783
|
+
scale?: number;
|
|
784
|
+
opacity?: number;
|
|
785
|
+
/** Applied once on crush; engine-added tokens are removed on reset/disposal. */
|
|
786
|
+
crushedClass?: string;
|
|
787
|
+
/** Optional paint pigment released beneath the crushed object, sized from its bounds. */
|
|
788
|
+
crushedPaintColor?: LiquidColorInput;
|
|
789
|
+
};
|
|
790
|
+
type LiquidElementOptions = {
|
|
791
|
+
kind: string;
|
|
792
|
+
color?: LiquidColorInput | 'auto';
|
|
793
|
+
distanceM?: number;
|
|
794
|
+
opacity?: number;
|
|
795
|
+
deformation?: number;
|
|
796
|
+
};
|
|
797
|
+
type TriggerPreset = 'click' | 'check' | 'toggle' | 'pickup' | 'parking';
|
|
798
|
+
type TriggerPhase = 'idle' | 'entered' | 'dwelling' | 'success';
|
|
799
|
+
type TriggerOptions = {
|
|
800
|
+
preset?: TriggerPreset;
|
|
801
|
+
when?: 'enter' | 'stop';
|
|
802
|
+
dwellSeconds?: number;
|
|
803
|
+
maxSpeedMps?: number;
|
|
804
|
+
action?: 'event' | 'click' | 'check' | 'uncheck' | 'toggle';
|
|
805
|
+
event?: string;
|
|
806
|
+
repeat?: 'visit' | 'vehicle' | 'scene';
|
|
807
|
+
vehicles?: 'player' | 'all' | 'ai';
|
|
808
|
+
target?: string;
|
|
809
|
+
consume?: boolean;
|
|
810
|
+
exitMarginPx?: number;
|
|
811
|
+
containment?: 'overlap' | 'center' | 'full';
|
|
812
|
+
requireExit?: boolean;
|
|
813
|
+
suspended?: boolean;
|
|
814
|
+
reveal?: 'departed';
|
|
815
|
+
/** Optional space-separated classes, managed only while this trigger owns them. */
|
|
816
|
+
enteredClass?: string;
|
|
817
|
+
dwellingClass?: string;
|
|
818
|
+
successClass?: string;
|
|
819
|
+
};
|
|
820
|
+
type TriggerSpec = boolean | TriggerPreset | TriggerOptions;
|
|
821
|
+
type HudField = 'fps' | 'speed' | 'rpm' | 'gear' | 'health' | 'points';
|
|
822
|
+
type HudSpec = {
|
|
823
|
+
field: 'speed';
|
|
824
|
+
unit?: 'mph' | 'kmh' | 'mps';
|
|
825
|
+
precision?: number;
|
|
826
|
+
} | {
|
|
827
|
+
field: Exclude<HudField, 'speed'>;
|
|
828
|
+
unit?: never;
|
|
829
|
+
precision?: number;
|
|
830
|
+
};
|
|
831
|
+
type SharedSpec = {
|
|
832
|
+
id?: string;
|
|
833
|
+
enabled?: boolean;
|
|
834
|
+
debris?: Capability<DebrisOptions>;
|
|
835
|
+
trigger?: TriggerSpec;
|
|
836
|
+
meta?: Record<string, JsonValue>;
|
|
837
|
+
};
|
|
838
|
+
type OrdinarySpec = SharedSpec & {
|
|
839
|
+
object?: string;
|
|
840
|
+
vehicle?: never;
|
|
841
|
+
liquid?: LiquidElementOptions | false;
|
|
842
|
+
pushable?: boolean;
|
|
843
|
+
points?: number;
|
|
844
|
+
};
|
|
845
|
+
type Enabled<T extends object> = true | T;
|
|
846
|
+
type DamageSpec = {
|
|
847
|
+
combustible: Enabled<CombustibleOptions>;
|
|
848
|
+
breakable?: false;
|
|
849
|
+
burnable?: Capability<BurnableOptions>;
|
|
850
|
+
} | {
|
|
851
|
+
combustible?: false;
|
|
852
|
+
breakable?: Capability<BreakableOptions>;
|
|
853
|
+
burnable?: Capability<BurnableOptions>;
|
|
854
|
+
};
|
|
855
|
+
type TransformationSpec = {
|
|
856
|
+
crushable: Enabled<CrushableOptions>;
|
|
857
|
+
breakable?: false;
|
|
858
|
+
solid?: false;
|
|
859
|
+
} | {
|
|
860
|
+
crushable?: false;
|
|
861
|
+
solid?: boolean;
|
|
862
|
+
breakable?: Capability<BreakableOptions>;
|
|
863
|
+
};
|
|
864
|
+
/** Composition is checked again at runtime after layers are merged. */
|
|
865
|
+
type PresentationSpec = {
|
|
866
|
+
hud: HudSpec;
|
|
867
|
+
breakable?: false;
|
|
868
|
+
burnable?: false;
|
|
869
|
+
pushable?: false;
|
|
870
|
+
liquid?: never;
|
|
871
|
+
} | {
|
|
872
|
+
hud?: false;
|
|
873
|
+
breakable?: Capability<BreakableOptions>;
|
|
874
|
+
burnable?: Capability<BurnableOptions>;
|
|
875
|
+
pushable?: boolean;
|
|
876
|
+
};
|
|
877
|
+
type ObjectSpec = OrdinarySpec & DamageSpec & TransformationSpec & PresentationSpec;
|
|
878
|
+
/** Vehicles have an explicit JS lifetime, independent of DOM object bindings. */
|
|
879
|
+
type VehicleConfiguration = {
|
|
880
|
+
id?: string;
|
|
881
|
+
vehicle: string;
|
|
882
|
+
driver?: 'player' | 'idle' | 'follow' | 'flee' | 'pursue';
|
|
883
|
+
appearance?: Appearance;
|
|
884
|
+
slots?: VehicleSlots;
|
|
885
|
+
};
|
|
886
|
+
type PlayerConfiguration = Pick<VehicleConfiguration, 'vehicle' | 'appearance' | 'slots'>;
|
|
887
|
+
/** An omitted action edits the current action; a supplied action is a complete replacement. */
|
|
888
|
+
type VehicleSlotPatch = false | VehicleSlot | {
|
|
889
|
+
action?: never;
|
|
890
|
+
activation?: 'tap' | 'hold';
|
|
891
|
+
liquid?: string;
|
|
892
|
+
rate?: number;
|
|
893
|
+
amount?: number;
|
|
894
|
+
};
|
|
895
|
+
type VehicleSlotsPatch = Partial<Record<SlotNumber, VehicleSlotPatch>>;
|
|
896
|
+
type VehiclePatch = Omit<Partial<VehicleConfiguration>, 'slots'> & {
|
|
897
|
+
slots?: VehicleSlotsPatch;
|
|
898
|
+
};
|
|
899
|
+
type DeepReadonly<T> = JsonValue extends T ? T : T extends ((...args: never[]) => unknown) ? T : T extends readonly unknown[] ? { readonly [K in keyof T]: DeepReadonly<T[K]>; } : T extends object ? { readonly [K in keyof T]: DeepReadonly<T[K]>; } : T;
|
|
900
|
+
/** Layers may omit context supplied by a recipe or a lower layer. Full validation follows composition. */
|
|
901
|
+
type ObjectPatch = ObjectSpec extends (infer Spec) ? Spec extends object ? { [Key in keyof Spec]?: Key extends 'hud' ? Partial<Exclude<Spec[Key], undefined>> : Spec[Key]; } : never : never;
|
|
902
|
+
type RouteStop = string | {
|
|
903
|
+
target: string;
|
|
904
|
+
when?: 'enter' | 'stop';
|
|
905
|
+
dwellSeconds?: number;
|
|
906
|
+
maxSpeedMps?: number;
|
|
907
|
+
};
|
|
908
|
+
type RouteSpec = {
|
|
909
|
+
order?: 'ordered' | 'any';
|
|
910
|
+
stops: readonly RouteStop[];
|
|
911
|
+
progress?: 'vehicle' | 'scene';
|
|
912
|
+
event?: string;
|
|
913
|
+
};
|
|
914
|
+
type DeepPartial<T> = T extends readonly unknown[] ? T : T extends object ? { [K in keyof T]?: DeepPartial<T[K]>; } : T;
|
|
915
|
+
type VehicleDefinition = DeepPartial<Omit<VehiclePreset, 'id'>> & {
|
|
916
|
+
base: string;
|
|
917
|
+
appearance?: Appearance;
|
|
918
|
+
slots?: VehicleSlots;
|
|
919
|
+
};
|
|
920
|
+
type LiquidDefinitionOptions = Omit<DefineLiquidOptions, 'base'> & {
|
|
921
|
+
base: string;
|
|
922
|
+
};
|
|
923
|
+
type PlaygroundDefinitions = {
|
|
924
|
+
liquids?: Record<string, LiquidDefinitionOptions>;
|
|
925
|
+
vehicles?: Record<string, VehicleDefinition>;
|
|
926
|
+
objects?: Record<string, ObjectSpec>;
|
|
927
|
+
routes?: Record<string, RouteSpec>;
|
|
928
|
+
};
|
|
929
|
+
/** Catalog construction has no browser storage or module-global registration side effects. */
|
|
930
|
+
declare function definePlayground(input: DeepReadonly<PlaygroundDefinitions>): DeepReadonly<PlaygroundDefinitions>;
|
|
931
|
+
declare const workModeTabs: readonly ["vehicle", "objects", "weapons", "controls", "ai", "settings", "embed", "documentation"];
|
|
932
|
+
type WorkModeTab = (typeof workModeTabs)[number];
|
|
933
|
+
/** Ordinary options produced by workMode; each can also be supplied explicitly by a host. */
|
|
934
|
+
type WorkModeSettings = {
|
|
935
|
+
showHud: boolean;
|
|
936
|
+
showHealthBars: boolean;
|
|
937
|
+
showWeaponBar: boolean;
|
|
938
|
+
showLogo: boolean;
|
|
939
|
+
showGithub: boolean;
|
|
940
|
+
allowVehicleEditing: boolean;
|
|
941
|
+
vehicleTabs: readonly WorkModeTab[];
|
|
942
|
+
vehicleDestructible: boolean;
|
|
943
|
+
weaponsEnabled: boolean;
|
|
944
|
+
enabledTools: readonly VehicleTool[];
|
|
945
|
+
brandColor?: string;
|
|
946
|
+
brandName?: string;
|
|
947
|
+
};
|
|
948
|
+
type WorkModeOptions = Partial<WorkModeSettings> & {
|
|
949
|
+
/** Passive, unbranded defaults for embedding on a workplace website. */
|
|
950
|
+
sfw?: boolean;
|
|
951
|
+
};
|
|
952
|
+
type WorkModeConfiguration = Partial<WorkModeSettings> & {
|
|
953
|
+
workMode?: WorkModeOptions;
|
|
954
|
+
};
|
|
955
|
+
/** SFW defaults < workMode customizations < explicit options. Undefined never overrides a default. */
|
|
956
|
+
declare function resolveWorkMode(options?: WorkModeConfiguration): WorkModeSettings;
|
|
957
|
+
type VehicleLightingOptions = {
|
|
958
|
+
underglow: boolean;
|
|
959
|
+
underglowColor: string;
|
|
960
|
+
underglowOpacity: number;
|
|
961
|
+
headlights: boolean;
|
|
962
|
+
taillights: boolean;
|
|
963
|
+
/** Braking signal in daylight and darkness; enabled by default. */
|
|
964
|
+
brakeLights: boolean;
|
|
965
|
+
};
|
|
966
|
+
type VehicleLightToggle = 'underglow' | 'headlights' | 'taillights' | 'brakeLights';
|
|
967
|
+
type FluidQuality = 'low' | 'medium' | 'high';
|
|
968
|
+
type SmokeTint = 'natural' | 'cyan' | 'magenta';
|
|
969
|
+
type FluidView = {
|
|
970
|
+
origin: Vec2;
|
|
971
|
+
scaleX: number;
|
|
972
|
+
scaleY: number;
|
|
973
|
+
};
|
|
974
|
+
/** Solid obstacle in fluid-canvas pixel coordinates. */
|
|
975
|
+
type FluidWall = {
|
|
976
|
+
x: number;
|
|
977
|
+
y: number;
|
|
978
|
+
width: number;
|
|
979
|
+
height: number;
|
|
980
|
+
};
|
|
981
|
+
type SurfaceTone = 'auto' | 'light' | 'dark';
|
|
982
|
+
type SpeedZoomMode = 'auto' | boolean;
|
|
983
|
+
type DriveSettings = {
|
|
984
|
+
lighting?: VehicleLightingOptions;
|
|
985
|
+
masterVolume: number;
|
|
986
|
+
idleSound: boolean;
|
|
987
|
+
quality: FluidQuality;
|
|
988
|
+
smokeTint: SmokeTint;
|
|
989
|
+
surfaceTone: SurfaceTone;
|
|
990
|
+
debug: boolean;
|
|
991
|
+
sparks: boolean;
|
|
992
|
+
deform: boolean;
|
|
993
|
+
screenShake: boolean;
|
|
994
|
+
showHud: boolean;
|
|
995
|
+
showTotalPoints: boolean;
|
|
996
|
+
showHealthBars: boolean;
|
|
997
|
+
showVehicleMarkers: boolean;
|
|
998
|
+
showWeaponBar: boolean;
|
|
999
|
+
weaponCooldown: boolean;
|
|
1000
|
+
autoPaint?: boolean;
|
|
1001
|
+
rocketBlastStrength: number;
|
|
1002
|
+
viewportWalls: boolean;
|
|
1003
|
+
speedZoom: SpeedZoomMode;
|
|
1004
|
+
vehicleDestructible?: boolean;
|
|
1005
|
+
weaponsEnabled?: boolean;
|
|
1006
|
+
enabledTools?: readonly VehicleTool[];
|
|
1007
|
+
};
|
|
1008
|
+
type RuntimeOptions = {
|
|
1009
|
+
audio: Pick<DriveSettings, 'masterVolume' | 'idleSound'>;
|
|
1010
|
+
rendering: Pick<DriveSettings, 'quality' | 'smokeTint' | 'sparks' | 'deform' | 'screenShake' | 'surfaceTone' | 'debug'>;
|
|
1011
|
+
policy: Pick<DriveSettings, 'weaponCooldown' | 'vehicleDestructible' | 'weaponsEnabled' | 'enabledTools' | 'rocketBlastStrength'>;
|
|
1012
|
+
ui: Pick<DriveSettings, 'showHud' | 'showTotalPoints' | 'showHealthBars' | 'showVehicleMarkers' | 'showWeaponBar'>;
|
|
1013
|
+
camera: Pick<DriveSettings, 'viewportWalls' | 'speedZoom'>;
|
|
1014
|
+
lighting: VehicleLightingOptions;
|
|
1015
|
+
autoPaint: boolean;
|
|
1016
|
+
};
|
|
1017
|
+
type RuntimeOptionsPatch = { [K in keyof RuntimeOptions]?: RuntimeOptions[K] extends object ? Partial<RuntimeOptions[K]> : RuntimeOptions[K]; };
|
|
1018
|
+
type SerializableBinding = {
|
|
1019
|
+
readonly target: string;
|
|
1020
|
+
readonly spec: DeepReadonly<ObjectPatch>;
|
|
1021
|
+
};
|
|
1022
|
+
type PortableVehicleConfiguration = DeepReadonly<{
|
|
1023
|
+
preset: VehiclePreset;
|
|
1024
|
+
appearance: Appearance;
|
|
1025
|
+
slots: VehicleSlots;
|
|
1026
|
+
liquids: Record<string, LiquidDefinitionOptions>;
|
|
1027
|
+
}>;
|
|
1028
|
+
type PlaygroundConfigurationInput = {
|
|
1029
|
+
root?: string;
|
|
1030
|
+
definitions?: DeepReadonly<PlaygroundDefinitions>;
|
|
1031
|
+
player?: DeepReadonly<Pick<VehicleConfiguration, 'vehicle' | 'appearance' | 'slots'>>;
|
|
1032
|
+
bindings?: readonly SerializableBinding[];
|
|
1033
|
+
routes?: Readonly<Record<string, RouteSpec>>;
|
|
1034
|
+
options?: RuntimeOptionsPatch;
|
|
1035
|
+
workMode?: WorkModeOptions;
|
|
1036
|
+
};
|
|
1037
|
+
/** Portable authoring, never a checkpoint or a serialization of the host document. */
|
|
1038
|
+
type PlaygroundConfiguration = DeepReadonly<Omit<PlaygroundConfigurationInput, 'options'> & {
|
|
1039
|
+
format: 'joy-ride-playground';
|
|
1040
|
+
version: 1;
|
|
1041
|
+
options?: RuntimeOptions;
|
|
1042
|
+
}>;
|
|
1043
|
+
type PlaygroundTarget = string | Element | Iterable<Element>;
|
|
1044
|
+
type PlaygroundObject = {
|
|
1045
|
+
readonly id: string;
|
|
1046
|
+
readonly target: Element;
|
|
1047
|
+
readonly spec: DeepReadonly<ObjectSpec>;
|
|
1048
|
+
readonly revision: number;
|
|
1049
|
+
};
|
|
1050
|
+
type PlaygroundDiagnostic = {
|
|
1051
|
+
code: string;
|
|
1052
|
+
message: string;
|
|
1053
|
+
target?: Element;
|
|
1054
|
+
};
|
|
1055
|
+
type PlaygroundBinding = {
|
|
1056
|
+
readonly objects: readonly PlaygroundObject[];
|
|
1057
|
+
update(patch: ObjectPatch): void;
|
|
1058
|
+
replace(spec: ObjectPatch): void;
|
|
1059
|
+
refresh(): void;
|
|
1060
|
+
dispose(): void;
|
|
1061
|
+
};
|
|
1062
|
+
type PlaygroundRegistryState = {
|
|
1063
|
+
patches: Map<Element, ObjectPatch>;
|
|
1064
|
+
registrations: Map<number, ObjectPatch>;
|
|
1065
|
+
};
|
|
1066
|
+
/** All authoring paths converge here before physics, decoration, or interaction observes them. */
|
|
1067
|
+
declare class PlaygroundRegistry {
|
|
1068
|
+
readonly root: Document | Element;
|
|
1069
|
+
readonly definitions: DeepReadonly<PlaygroundDefinitions>;
|
|
1070
|
+
private readonly scope;
|
|
1071
|
+
private readonly registrations;
|
|
1072
|
+
private readonly records;
|
|
1073
|
+
private snapshot;
|
|
1074
|
+
private readonly identities;
|
|
1075
|
+
private readonly patches;
|
|
1076
|
+
private readonly listeners;
|
|
1077
|
+
private readonly diagnosticListeners;
|
|
1078
|
+
private readonly liquids;
|
|
1079
|
+
private readonly vehicles;
|
|
1080
|
+
private readonly importedVehicles;
|
|
1081
|
+
private readonly importedLiquids;
|
|
1082
|
+
private readonly recordingImports;
|
|
1083
|
+
private importSerial;
|
|
1084
|
+
private observer?;
|
|
1085
|
+
private dirty;
|
|
1086
|
+
private disposed;
|
|
1087
|
+
private nextId;
|
|
1088
|
+
private nextRegistration;
|
|
1089
|
+
private version;
|
|
1090
|
+
private readonly pageStateChanged;
|
|
1091
|
+
constructor(root?: Document | Element, definitions?: DeepReadonly<PlaygroundDefinitions>);
|
|
1092
|
+
private observe;
|
|
1093
|
+
private invalidate;
|
|
1094
|
+
subscribe(listener: () => void): () => boolean;
|
|
1095
|
+
onDiagnostic(listener: (diagnostic: PlaygroundDiagnostic) => void): () => boolean;
|
|
1096
|
+
report(error: unknown, target?: Element): void;
|
|
1097
|
+
private targets;
|
|
1098
|
+
private accepts;
|
|
1099
|
+
private compose;
|
|
1100
|
+
private validateChange;
|
|
1101
|
+
bindAll(bindings: readonly {
|
|
1102
|
+
target: PlaygroundTarget;
|
|
1103
|
+
spec: ObjectPatch;
|
|
1104
|
+
}[]): PlaygroundBinding[];
|
|
1105
|
+
bind(target: PlaygroundTarget, spec: ObjectPatch): PlaygroundBinding;
|
|
1106
|
+
update(target: Element, patch: ObjectPatch): void;
|
|
1107
|
+
get(target: Element): PlaygroundObject | undefined;
|
|
1108
|
+
get objects(): readonly PlaygroundObject[];
|
|
1109
|
+
refresh(): void;
|
|
1110
|
+
validateObject(input: unknown): ObjectSpec;
|
|
1111
|
+
exportBindings(): readonly SerializableBinding[];
|
|
1112
|
+
exportDefinitions(): DeepReadonly<PlaygroundDefinitions>;
|
|
1113
|
+
/** Imported editor vehicles become owned recipes rather than a second preset selection path. */
|
|
1114
|
+
registerVehiclePreset(name: string, input: VehiclePreset): string;
|
|
1115
|
+
vehicleName(id: string): string;
|
|
1116
|
+
captureVehicleConfiguration(preset: VehiclePreset, appearance: Appearance, slots: Readonly<VehicleSlots>): PortableVehicleConfiguration;
|
|
1117
|
+
importRecordedVehicle(input: PortableVehicleConfiguration): VehicleConfiguration;
|
|
1118
|
+
private resolve;
|
|
1119
|
+
resolveLiquid(name: string, seen?: Set<string>): LiquidKind;
|
|
1120
|
+
/** Recover authored material references when exporting recordings or scene configuration. */
|
|
1121
|
+
liquidName(kind: string): string;
|
|
1122
|
+
resolveVehicle(name: string, seen?: Set<string>): VehiclePreset;
|
|
1123
|
+
vehicleOptions(name: string): Record<string, unknown>;
|
|
1124
|
+
/** Checkpoints restore values on existing registrations; host registration lifetime stays external. */
|
|
1125
|
+
captureState(): PlaygroundRegistryState;
|
|
1126
|
+
restoreState(state: PlaygroundRegistryState): void;
|
|
1127
|
+
reset(): void;
|
|
1128
|
+
dispose(): void;
|
|
1129
|
+
}
|
|
1130
|
+
type PlaygroundTriggerDetail = {
|
|
1131
|
+
object: PlaygroundObject;
|
|
1132
|
+
vehicle: {
|
|
1133
|
+
id: string;
|
|
1134
|
+
};
|
|
1135
|
+
position: Vec2;
|
|
1136
|
+
speedMps: number;
|
|
1137
|
+
state: {
|
|
1138
|
+
inside: boolean;
|
|
1139
|
+
departed: boolean;
|
|
1140
|
+
stopped: boolean;
|
|
1141
|
+
phase: TriggerPhase;
|
|
1142
|
+
};
|
|
1143
|
+
};
|
|
1144
|
+
declare global {
|
|
1145
|
+
interface HTMLElementEventMap {
|
|
1146
|
+
'joyride:trigger:change': CustomEvent<PlaygroundTriggerDetail>;
|
|
1147
|
+
'joyride:trigger:enter': CustomEvent<PlaygroundTriggerDetail>;
|
|
1148
|
+
'joyride:trigger:leave': CustomEvent<PlaygroundTriggerDetail>;
|
|
1149
|
+
'joyride:trigger:qualify': CustomEvent<PlaygroundTriggerDetail>;
|
|
1150
|
+
'joyride:trigger:stop': CustomEvent<PlaygroundTriggerDetail>;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
type PlaygroundRouteHandle = {
|
|
1154
|
+
readonly id: string;
|
|
1155
|
+
readonly state: readonly {
|
|
1156
|
+
vehicleId: string;
|
|
1157
|
+
completed: number;
|
|
1158
|
+
total: number;
|
|
1159
|
+
complete: boolean;
|
|
1160
|
+
}[];
|
|
1161
|
+
reset(): void;
|
|
1162
|
+
dispose(): void;
|
|
1163
|
+
};
|
|
1164
|
+
export { SlotNumber as $, PlaygroundDefinitions as A, DebrisParticle as B, resolveWorkMode as C, ObjectPatch as D, DeepReadonly as E, DebrisAnchor as F, LiquidPourOptions as G, LiquidColor as H, DebrisBounds as I, VehicleTool as J, LiquidResidue as K, DebrisHandle as L, VehicleConfiguration as M, VehiclePatch as N, ObjectSpec as O, Debris as P, LiquidEmission as Q, DebrisKind as R, WorkModeSettings as S, Appearance as T, LiquidColorInput as U, DebrisVector as V, LiquidKind as W, VehicleToolPolicy as X, VehicleToolDefinition as Y, availableVehicleTools as Z, SmokeTint as _, PlaygroundObject as a, Controls as at, WorkModeConfiguration as b, PlaygroundConfiguration as c, Vec2 as ct, RuntimeOptionsPatch as d, VehicleSlot as et, SpeedZoomMode as f, FluidWall as g, FluidView as h, PlaygroundDiagnostic as i, LightningWeapon as it, RouteSpec as j, PlayerConfiguration as k, PortableVehicleConfiguration as l, VehicleMode as lt, FluidQuality as m, PlaygroundTriggerDetail as n, FlamethrowerProfile as nt, PlaygroundRegistry as o, Simulation as ot, SurfaceTone as p, LiquidSource as q, PlaygroundBinding as r, VehiclePreset as rt, PlaygroundTarget as s, SimulationState as st, PlaygroundRouteHandle as t, VehicleSlots as tt, RuntimeOptions as u, CombustibleStage as ut, VehicleLightToggle as v, definePlayground as w, WorkModeOptions as x, VehicleLightingOptions as y, DebrisOptions as z };
|