@adatechnology/game-vehicles-driving 0.2.10 → 0.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +383 -1
- package/dist/index.global.js +467 -11
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +466 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -242,6 +242,8 @@ interface SemiSimSpec {
|
|
|
242
242
|
centreHeight: number;
|
|
243
243
|
wheels: readonly SemiWheel[];
|
|
244
244
|
wheelRadius: number;
|
|
245
|
+
/** Radius of the bare rim, metres, when a wheel loses its tyre. Default `RIM_RADIUS_SHARE` of `wheelRadius`. */
|
|
246
|
+
rimRadius?: number;
|
|
245
247
|
fourWheelDrive: boolean;
|
|
246
248
|
/** Air drag: `0.5 * 1.2 * Cd * A`, in kg/m. */
|
|
247
249
|
drag: number;
|
|
@@ -288,6 +290,8 @@ interface SemiSimSpec {
|
|
|
288
290
|
interface VehicleCondition {
|
|
289
291
|
/** Health of each wheel in the order of `spec.wheels`. Under 0.2 the tyre is flat. */
|
|
290
292
|
tyres?: readonly number[];
|
|
293
|
+
/** Which wheels have lost their tyre, in the order of `spec.wheels`: the bare rim runs on the road (smaller, metal on asphalt). */
|
|
294
|
+
rims?: readonly boolean[];
|
|
291
295
|
engine?: number;
|
|
292
296
|
suspension?: number;
|
|
293
297
|
/** How much of the brake force is left, 0..1: worn or broken brakes, no brake fluid. */
|
|
@@ -296,6 +300,12 @@ interface VehicleCondition {
|
|
|
296
300
|
interface SemiInput extends DriveInput {
|
|
297
301
|
/** Forces a gear (1-based, 0 = neutral, -1 = reverse). Absent = automatic. */
|
|
298
302
|
gear?: number;
|
|
303
|
+
/** Clutch pedal, 0 released (engaged) to 1 pressed. Absent = no clutch (automatic). Released in gear at too low a speed without gas, the engine stalls. */
|
|
304
|
+
clutch?: number;
|
|
305
|
+
/** The starter turns this step. When given, it is the only way the engine starts again (no gas-pedal start). */
|
|
306
|
+
start?: boolean;
|
|
307
|
+
/** Share of the engine torque allowed this step, 0..1 (traction control cutting, an overheated engine in limp mode). Default 1. */
|
|
308
|
+
powerLimit?: number;
|
|
299
309
|
}
|
|
300
310
|
interface SemiGround {
|
|
301
311
|
/** Height of the ground under the point, metres. Default 0. */
|
|
@@ -402,6 +412,193 @@ interface BodyDimensions {
|
|
|
402
412
|
*/
|
|
403
413
|
declare function semiSpecFromStats(stats: DesignStats, body: BodyDimensions, base?: Partial<SemiSimSpec>): SemiSimSpec;
|
|
404
414
|
|
|
415
|
+
/**
|
|
416
|
+
* The driver aids the controls apply between the pedals and the engine: the drive profile (economy shifts early and softens the gas, sport holds the
|
|
417
|
+
* gears and sharpens it), traction control (cuts the torque while a driven wheel spins past its grip) and cruise control (holds the set speed with the
|
|
418
|
+
* gas; the brake or the clutch cancels it, the gas pedal overrides it while pressed). Pure functions over numbers, every threshold an option.
|
|
419
|
+
*/
|
|
420
|
+
type DriveProfile = 'eco' | 'normal' | 'sport';
|
|
421
|
+
interface ProfileTuning {
|
|
422
|
+
/** Multiplies the gas pedal. */
|
|
423
|
+
readonly throttle: number;
|
|
424
|
+
/** Upshift and downshift points, shares of the redline (the semi driver's `upshiftFraction` and `downshiftFraction`). */
|
|
425
|
+
readonly upshift: number;
|
|
426
|
+
readonly downshift: number;
|
|
427
|
+
}
|
|
428
|
+
declare const DRIVE_PROFILES: Readonly<Record<DriveProfile, ProfileTuning>>;
|
|
429
|
+
interface TractionOptions {
|
|
430
|
+
/** Grip in use of a driven wheel (1 = sliding) above which the torque is cut. */
|
|
431
|
+
readonly slip: number;
|
|
432
|
+
/** Torque left at full spin. */
|
|
433
|
+
readonly floor: number;
|
|
434
|
+
}
|
|
435
|
+
declare const DEFAULT_TRACTION: TractionOptions;
|
|
436
|
+
/** Share of the torque traction control lets through for the worst driven wheel's grip in use (1 = sliding). */
|
|
437
|
+
declare function tractionLimit(slips: readonly number[], options?: TractionOptions): number;
|
|
438
|
+
interface CruiseOptions {
|
|
439
|
+
/** Gas per m/s under the set speed. */
|
|
440
|
+
readonly gain: number;
|
|
441
|
+
/** Lowest speed it engages at, m/s (about 30 km/h). */
|
|
442
|
+
readonly minSpeed: number;
|
|
443
|
+
}
|
|
444
|
+
declare const DEFAULT_CRUISE: CruiseOptions;
|
|
445
|
+
/** Gas cruise control asks for to hold `target` at `speed` (m/s); none above the target, the car coasts down to it. */
|
|
446
|
+
declare function cruiseThrottle(target: number, speed: number, options?: CruiseOptions): number;
|
|
447
|
+
|
|
448
|
+
type ControlCommand = 'ignition' | 'gearbox' | 'gear_up' | 'gear_down' | 'parking_brake' | 'drive_mode' | 'lights' | 'high_beam' | 'fog_lights' | 'interior_light' | 'alarm' | 'radio' | 'radio_source' | 'radio_track' | 'exit' | 'indicator_left' | 'indicator_right' | 'hazard' | 'wipers' | 'seatbelt' | 'drive_profile' | 'traction_control' | 'abs' | 'cruise' | 'climate' | 'demist';
|
|
449
|
+
type ControlKeyMap = {
|
|
450
|
+
readonly throttle: readonly string[];
|
|
451
|
+
readonly brake: readonly string[];
|
|
452
|
+
readonly left: readonly string[];
|
|
453
|
+
readonly right: readonly string[];
|
|
454
|
+
readonly handbrake: readonly string[];
|
|
455
|
+
readonly horn: readonly string[];
|
|
456
|
+
readonly clutch: readonly string[];
|
|
457
|
+
/** Flashes the high beam while held. */
|
|
458
|
+
readonly flash: readonly string[];
|
|
459
|
+
readonly washer: readonly string[];
|
|
460
|
+
} & {
|
|
461
|
+
readonly [command in ControlCommand]: readonly string[];
|
|
462
|
+
};
|
|
463
|
+
/** Keys of a keyboard (`KeyboardEvent.code`). The host keeps them from its own bindings while someone drives. */
|
|
464
|
+
declare const DEFAULT_CONTROL_KEYS: ControlKeyMap;
|
|
465
|
+
type Gearbox = 'automatic' | 'manual';
|
|
466
|
+
type DriveMode = '4x2' | '4x4' | 'auto';
|
|
467
|
+
type LampMode = 'off' | 'position' | 'low' | 'high';
|
|
468
|
+
type AlarmState = 'off' | 'armed' | 'ringing';
|
|
469
|
+
type RadioSource = 'radio' | 'tape';
|
|
470
|
+
type Indicator = 'off' | 'left' | 'right' | 'hazard';
|
|
471
|
+
type Wipers = 'off' | 'intermittent' | 'slow' | 'fast';
|
|
472
|
+
interface ControlState {
|
|
473
|
+
ignition: boolean;
|
|
474
|
+
gearbox: Gearbox;
|
|
475
|
+
/** The gear the driver chose (manual): -1 reverse, 0 neutral, 1.. forward. */
|
|
476
|
+
gear: number;
|
|
477
|
+
/** Pulled and left pulled (P); Space holds it only while pressed. */
|
|
478
|
+
parkingBrake: boolean;
|
|
479
|
+
driveMode: DriveMode;
|
|
480
|
+
/** The front axle drives now (4x4, or automatic 4x4 that felt the rear slip). */
|
|
481
|
+
fourWheelEngaged: boolean;
|
|
482
|
+
/** `flash`: the high beam lit while the flash key is held, over any mode. */
|
|
483
|
+
lamps: {
|
|
484
|
+
mode: LampMode;
|
|
485
|
+
fog: boolean;
|
|
486
|
+
interior: boolean;
|
|
487
|
+
flash: boolean;
|
|
488
|
+
};
|
|
489
|
+
/** What the rear lamps show this step: brake (pedal or handbrake) and reversing. */
|
|
490
|
+
brakeLights: boolean;
|
|
491
|
+
reverseLights: boolean;
|
|
492
|
+
horn: boolean;
|
|
493
|
+
alarm: AlarmState;
|
|
494
|
+
/** `track`: the station or the song on the tape, 0-based (`radioTracks` of them). */
|
|
495
|
+
radio: {
|
|
496
|
+
on: boolean;
|
|
497
|
+
source: RadioSource;
|
|
498
|
+
track: number;
|
|
499
|
+
};
|
|
500
|
+
indicator: Indicator;
|
|
501
|
+
/** The indicator lamps are lit this instant (they blink at `blinkHz`); `tick` is true on the step the relay clicks. */
|
|
502
|
+
blinkOn: boolean;
|
|
503
|
+
tick: boolean;
|
|
504
|
+
wipers: Wipers;
|
|
505
|
+
/** The washer squirts while its key is held (the wipers sweep with it). */
|
|
506
|
+
washer: boolean;
|
|
507
|
+
seatbelt: boolean;
|
|
508
|
+
/** Clutch pedal, 0 up to 1 down (manual gearbox). */
|
|
509
|
+
clutch: number;
|
|
510
|
+
profile: DriveProfile;
|
|
511
|
+
tractionControl: boolean;
|
|
512
|
+
abs: boolean;
|
|
513
|
+
/** Cruise control: the speed it holds, m/s. */
|
|
514
|
+
cruise: {
|
|
515
|
+
on: boolean;
|
|
516
|
+
speed: number;
|
|
517
|
+
};
|
|
518
|
+
climate: {
|
|
519
|
+
on: boolean;
|
|
520
|
+
demist: boolean;
|
|
521
|
+
};
|
|
522
|
+
/** The starter turns this step. */
|
|
523
|
+
cranking: boolean;
|
|
524
|
+
}
|
|
525
|
+
type ControlEvent = {
|
|
526
|
+
type: 'command';
|
|
527
|
+
command: ControlCommand;
|
|
528
|
+
state: ControlState;
|
|
529
|
+
} | {
|
|
530
|
+
type: 'refused';
|
|
531
|
+
command: ControlCommand;
|
|
532
|
+
reason: 'no_four_wheel_drive' | 'no_fog_lamps' | 'ignition_off' | 'battery_flat' | 'too_slow';
|
|
533
|
+
} | {
|
|
534
|
+
type: 'cruise_cancelled';
|
|
535
|
+
};
|
|
536
|
+
interface VehicleControlOptions {
|
|
537
|
+
/** Forward gears of the gearbox. */
|
|
538
|
+
gears: number;
|
|
539
|
+
/** The vehicle can drive both axles (4x4 and automatic 4x4 are offered). */
|
|
540
|
+
fourWheelDrive?: boolean;
|
|
541
|
+
/** The vehicle has fog lamps. Default true. */
|
|
542
|
+
fogLamps?: boolean;
|
|
543
|
+
keys?: Partial<ControlKeyMap>;
|
|
544
|
+
gearbox?: Gearbox;
|
|
545
|
+
/** Automatic 4x4: the front axle comes in above this slip of a driven wheel (1 = sliding) and goes out after `releaseSeconds` below it. */
|
|
546
|
+
autoFourWheel?: {
|
|
547
|
+
slip: number;
|
|
548
|
+
releaseSeconds: number;
|
|
549
|
+
};
|
|
550
|
+
/** The engine runs from the start (a vehicle the player gets into with the engine on). Default false: the key turns it on (I) or the gas pedal starts it. */
|
|
551
|
+
running?: boolean;
|
|
552
|
+
/** Blinks a second of the indicators (default 1.5, the 90 a minute of the road codes). */
|
|
553
|
+
blinkHz?: number;
|
|
554
|
+
/** The steering wheel coming back this far (0..1 of the lock) after a turn cancels the indicator, as the column does. Default 0.15. */
|
|
555
|
+
indicatorCancel?: number;
|
|
556
|
+
/** Stations or songs the radio steps through (`radio_track`). Default 3. */
|
|
557
|
+
radioTracks?: number;
|
|
558
|
+
/** The driver works the clutch (C) in manual: released in gear too slowly or without gas, the engine stalls. Default false (the clutch is automated). */
|
|
559
|
+
clutchPedal?: boolean;
|
|
560
|
+
/** The starter can turn the engine over (a battery with charge); asked at every crank. Default always. */
|
|
561
|
+
canCrank?: () => boolean;
|
|
562
|
+
/** A crank happened (takes the battery's energy). */
|
|
563
|
+
onCrank?: () => void;
|
|
564
|
+
/** Share of the torque the engine gives besides the aids (an overheated engine). Default 1. */
|
|
565
|
+
powerLimit?: () => number;
|
|
566
|
+
onEvent?: (event: ControlEvent) => void;
|
|
567
|
+
}
|
|
568
|
+
/** What the controls read of the driver each step, and the one thing they change on it (which axles drive). */
|
|
569
|
+
interface ControlledDriver {
|
|
570
|
+
readonly spec: {
|
|
571
|
+
fourWheelDrive: boolean;
|
|
572
|
+
abs?: boolean;
|
|
573
|
+
upshiftFraction?: number;
|
|
574
|
+
downshiftFraction?: number;
|
|
575
|
+
readonly wheels?: ReadonlyArray<{
|
|
576
|
+
drive?: boolean;
|
|
577
|
+
}>;
|
|
578
|
+
};
|
|
579
|
+
readonly state: {
|
|
580
|
+
u: number;
|
|
581
|
+
gear: number;
|
|
582
|
+
slip: readonly number[];
|
|
583
|
+
engineOn: boolean;
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
interface VehicleControls {
|
|
587
|
+
/** A key went down or up. True when it is a driving key (the host keeps it from its own bindings). */
|
|
588
|
+
key(code: string, down: boolean): boolean;
|
|
589
|
+
/** Runs a command as its key would (a button of a panel). */
|
|
590
|
+
command(command: ControlCommand): void;
|
|
591
|
+
/** The input for this step, pedals and wheel eased over `dt` seconds. */
|
|
592
|
+
input(dt: number, driver?: ControlledDriver): SemiInput;
|
|
593
|
+
/** After the driver stepped: the automatic 4x4 watches the slip, the ignition the engine. */
|
|
594
|
+
after(driver: ControlledDriver, dt: number): void;
|
|
595
|
+
readonly state: ControlState;
|
|
596
|
+
readonly keys: ControlKeyMap;
|
|
597
|
+
/** Lets go of every key (the window lost focus, the driver got out). */
|
|
598
|
+
release(): void;
|
|
599
|
+
}
|
|
600
|
+
declare function createVehicleControls(options: VehicleControlOptions): VehicleControls;
|
|
601
|
+
|
|
405
602
|
/** Matches a damage model's wheels to a driver's: each wheel of the spec takes the health of the tyre nearest to it. */
|
|
406
603
|
|
|
407
604
|
type DamagedTyre = {
|
|
@@ -410,6 +607,8 @@ type DamagedTyre = {
|
|
|
410
607
|
readonly z: number;
|
|
411
608
|
/** 0 flat or gone, 1 whole. */
|
|
412
609
|
readonly health: number;
|
|
610
|
+
/** The tyre is gone and the rim is on the road. */
|
|
611
|
+
readonly rim?: boolean;
|
|
413
612
|
};
|
|
414
613
|
type DamageReport = {
|
|
415
614
|
readonly tyres: readonly DamagedTyre[];
|
|
@@ -419,4 +618,187 @@ type DamageReport = {
|
|
|
419
618
|
};
|
|
420
619
|
declare function conditionFromDamage(spec: Pick<SemiSimSpec, 'wheels'>, report: DamageReport): VehicleCondition;
|
|
421
620
|
|
|
422
|
-
|
|
621
|
+
/**
|
|
622
|
+
* What keeps a car running besides the engine: the 12 V battery (the lamps, radio, wipers and alarm draw from it, the alternator charges it while
|
|
623
|
+
* the engine turns, and below what the starter needs the car does not start), the coolant temperature (it climbs with the work of the engine, the air
|
|
624
|
+
* through the radiator and the fan take it away, and a damaged radiator boils it: past `limpC` the engine loses power, past `seizeC` it dies) and the
|
|
625
|
+
* spare tyre (one flat wheel can be swapped for it). It reads the driver and the controls and changes only what a real car would: the engine state,
|
|
626
|
+
* the power it gives and the tyres. Every number is an option.
|
|
627
|
+
*/
|
|
628
|
+
|
|
629
|
+
interface ElectricalLoads {
|
|
630
|
+
/** Watts of each consumer while on. */
|
|
631
|
+
readonly position: number;
|
|
632
|
+
readonly low: number;
|
|
633
|
+
readonly high: number;
|
|
634
|
+
readonly fog: number;
|
|
635
|
+
readonly interior: number;
|
|
636
|
+
readonly radio: number;
|
|
637
|
+
readonly wipers: number;
|
|
638
|
+
readonly indicators: number;
|
|
639
|
+
readonly horn: number;
|
|
640
|
+
readonly alarm: number;
|
|
641
|
+
readonly brakeLights: number;
|
|
642
|
+
readonly climate: number;
|
|
643
|
+
}
|
|
644
|
+
interface VehicleSystemsOptions {
|
|
645
|
+
/** Battery capacity, watt-hours (a 12 V 60 Ah battery holds 720). */
|
|
646
|
+
batteryWh?: number;
|
|
647
|
+
/** Charge at the start, 0..1. */
|
|
648
|
+
charge?: number;
|
|
649
|
+
/** Alternator output, watts, at idle and from 2000 rpm up. */
|
|
650
|
+
alternatorW?: {
|
|
651
|
+
idle: number;
|
|
652
|
+
full: number;
|
|
653
|
+
};
|
|
654
|
+
/** Below this charge the starter does not turn the engine over. */
|
|
655
|
+
crankCharge?: number;
|
|
656
|
+
/** Energy of one start, watt-hours. */
|
|
657
|
+
startWh?: number;
|
|
658
|
+
loads?: Partial<ElectricalLoads>;
|
|
659
|
+
/** Air temperature, °C. */
|
|
660
|
+
ambientC?: number;
|
|
661
|
+
/** The thermostat holds the coolant here once warm. */
|
|
662
|
+
thermostatC?: number;
|
|
663
|
+
/** Limp mode above this (power cut), engine seizes above `seizeC`. */
|
|
664
|
+
limpC?: number;
|
|
665
|
+
seizeC?: number;
|
|
666
|
+
/** Warming of the coolant, °C per second at full power; cooling share of the gap to the air per second, at a stop and at 100 km/h. */
|
|
667
|
+
heatPerSecond?: number;
|
|
668
|
+
cooling?: {
|
|
669
|
+
stopped: number;
|
|
670
|
+
fast: number;
|
|
671
|
+
};
|
|
672
|
+
/** Spare tyres carried. */
|
|
673
|
+
spares?: number;
|
|
674
|
+
}
|
|
675
|
+
declare const DEFAULT_LOADS: ElectricalLoads;
|
|
676
|
+
type SystemsEvent = {
|
|
677
|
+
type: 'battery_flat';
|
|
678
|
+
} | {
|
|
679
|
+
type: 'overheating';
|
|
680
|
+
} | {
|
|
681
|
+
type: 'seized';
|
|
682
|
+
} | {
|
|
683
|
+
type: 'spare_fitted';
|
|
684
|
+
wheel: number;
|
|
685
|
+
} | {
|
|
686
|
+
type: 'no_spare';
|
|
687
|
+
};
|
|
688
|
+
interface SystemsState {
|
|
689
|
+
/** 0..1. */
|
|
690
|
+
charge: number;
|
|
691
|
+
/** Coolant, °C. */
|
|
692
|
+
coolantC: number;
|
|
693
|
+
/** 0 cold (the air) to 1 (the seize point), for a gauge. */
|
|
694
|
+
temperature: number;
|
|
695
|
+
overheating: boolean;
|
|
696
|
+
seized: boolean;
|
|
697
|
+
spares: number;
|
|
698
|
+
/** Net watts on the battery this step: positive charging, negative draining. */
|
|
699
|
+
netW: number;
|
|
700
|
+
}
|
|
701
|
+
interface SystemsDriver {
|
|
702
|
+
readonly state: Pick<SemiState, 'engineOn' | 'rpm' | 'u'>;
|
|
703
|
+
condition: VehicleCondition;
|
|
704
|
+
}
|
|
705
|
+
interface SystemsStepParams {
|
|
706
|
+
driver: SystemsDriver;
|
|
707
|
+
controls: ControlState;
|
|
708
|
+
/** The gas the engine got this step, 0..1. */
|
|
709
|
+
throttle: number;
|
|
710
|
+
dt: number;
|
|
711
|
+
/** What is left of the radiator, 0..1. Default 1. */
|
|
712
|
+
radiator?: number;
|
|
713
|
+
/** The coolant temperature from a damage model that tracks it (the vehicle destructible's `runEngine`): it replaces this model's own. */
|
|
714
|
+
coolantC?: number;
|
|
715
|
+
}
|
|
716
|
+
interface VehicleSystems {
|
|
717
|
+
readonly state: SystemsState;
|
|
718
|
+
/** The starter can turn the engine over now. */
|
|
719
|
+
canCrank(): boolean;
|
|
720
|
+
/** Takes the energy of one start. */
|
|
721
|
+
crank(): void;
|
|
722
|
+
/** Share of the torque the engine gives now (limp mode when hot). */
|
|
723
|
+
powerLimit(): number;
|
|
724
|
+
/** Advances `dt` seconds; `throttle` is the gas the engine got, `controls` what is switched on. */
|
|
725
|
+
step(params: SystemsStepParams): SystemsEvent[];
|
|
726
|
+
/** Swaps the flat tyre of `wheel` for the spare. */
|
|
727
|
+
fitSpare(driver: SystemsDriver, wheel: number): SystemsEvent;
|
|
728
|
+
/** Fills the battery (a jump start or a charger), 0..1 of the capacity. */
|
|
729
|
+
charge(share: number): void;
|
|
730
|
+
}
|
|
731
|
+
declare function createVehicleSystems(options?: VehicleSystemsOptions): VehicleSystems;
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Who leaves the car in a crash. An occupant without a belt keeps the speed the car had (inertia) while the car stops: in a frontal crash past
|
|
735
|
+
* about 30 km/h of change in speed the body goes through the windshield, in a hard side impact or a rollover through the side window on the side it
|
|
736
|
+
* is thrown to. A belted occupant stays in (a belt holds a person to the seat up to crashes far harder than a road car survives). The glass breaks
|
|
737
|
+
* first; the body flies with most of the car's speed before the crash and a little lift. Pure numbers, every threshold an option.
|
|
738
|
+
*/
|
|
739
|
+
type EjectionExit = 'windshield' | 'left_window' | 'right_window' | 'rear_window';
|
|
740
|
+
interface EjectionOptions {
|
|
741
|
+
/** Change of speed, m/s, past which an unbelted occupant goes through the windshield (about 30 km/h). */
|
|
742
|
+
frontal: number;
|
|
743
|
+
/** Sideways change of speed, m/s, past which an unbelted occupant goes out of a side window. */
|
|
744
|
+
side: number;
|
|
745
|
+
/** Share of the speed before the crash the body keeps on the way out (the glass and the dash take the rest). */
|
|
746
|
+
keep: number;
|
|
747
|
+
/** Upward speed of the body leaving, m/s (it rides up over the dash). */
|
|
748
|
+
lift: number;
|
|
749
|
+
}
|
|
750
|
+
declare const DEFAULT_EJECTION: EjectionOptions;
|
|
751
|
+
interface CrashPulse {
|
|
752
|
+
/** Body-frame speed before and after the crash, m/s: forward and to the right. */
|
|
753
|
+
readonly before: {
|
|
754
|
+
readonly u: number;
|
|
755
|
+
readonly w: number;
|
|
756
|
+
};
|
|
757
|
+
readonly after: {
|
|
758
|
+
readonly u: number;
|
|
759
|
+
readonly w: number;
|
|
760
|
+
};
|
|
761
|
+
/** The car rolled over in it. */
|
|
762
|
+
readonly rolled?: boolean;
|
|
763
|
+
}
|
|
764
|
+
interface Ejection {
|
|
765
|
+
readonly exit: EjectionExit;
|
|
766
|
+
/** Body-frame velocity of the body leaving, m/s: forward, to the right, up. */
|
|
767
|
+
readonly velocity: readonly [number, number, number];
|
|
768
|
+
/** Change of speed of the crash, m/s (what the injuries scale with). */
|
|
769
|
+
readonly deltaV: number;
|
|
770
|
+
}
|
|
771
|
+
/** The ejection of one occupant, or null when the occupant stays in. */
|
|
772
|
+
declare function ejectionOf(pulse: CrashPulse, belted: boolean, options?: EjectionOptions): Ejection | null;
|
|
773
|
+
|
|
774
|
+
/**
|
|
775
|
+
* Parking sensors: the bumper's distance to the nearest obstacle in the way turns into the beep the cabin plays, slower far away, faster close,
|
|
776
|
+
* continuous at the last few centimetres. Pure numbers, the distances are options.
|
|
777
|
+
*/
|
|
778
|
+
interface ParkingSensorOptions {
|
|
779
|
+
/** Farther than this (metres) it stays quiet. */
|
|
780
|
+
readonly range: number;
|
|
781
|
+
/** Closer than this it beeps without pause. */
|
|
782
|
+
readonly solid: number;
|
|
783
|
+
/** Pause between beeps at the edge of the range and near `solid`, seconds. */
|
|
784
|
+
readonly slowest: number;
|
|
785
|
+
readonly fastest: number;
|
|
786
|
+
}
|
|
787
|
+
declare const DEFAULT_PARKING_SENSOR: ParkingSensorOptions;
|
|
788
|
+
/** Seconds between beeps for an obstacle `distance` metres from the bumper: null when quiet, 0 when continuous. */
|
|
789
|
+
declare function parkingBeepInterval(distance: number, options?: ParkingSensorOptions): number | null;
|
|
790
|
+
/**
|
|
791
|
+
* The bumper's distance to the nearest of `obstacles` (world x, z) in the vehicle's path: ahead when `forward`, behind otherwise. The vehicle is
|
|
792
|
+
* at (x, z) facing `heading` (unit x, z), `length` and `width` metres; obstacles off to the side of its width are not in the way.
|
|
793
|
+
*/
|
|
794
|
+
declare function bumperDistance(params: {
|
|
795
|
+
x: number;
|
|
796
|
+
z: number;
|
|
797
|
+
heading: readonly [number, number];
|
|
798
|
+
length: number;
|
|
799
|
+
width: number;
|
|
800
|
+
forward: boolean;
|
|
801
|
+
obstacles: ReadonlyArray<readonly [number, number]>;
|
|
802
|
+
}): number;
|
|
803
|
+
|
|
804
|
+
export { type AlarmState, type ArcadeOptions, type ArcadeSpec, type BodyDimensions, type ControlCommand, type ControlEvent, type ControlKeyMap, type ControlState, type ControlledDriver, type CrashPulse, type CrashRules, type CruiseOptions, DEFAULT_CONTROL_KEYS, DEFAULT_CRUISE, DEFAULT_EJECTION, DEFAULT_LOADS, DEFAULT_PARKING_SENSOR, DEFAULT_TRACTION, DRIVE_PROFILES, type DamageReport, type DamagedTyre, type DesignStats, type DriveInput, type DriveMode, type DriveProfile, type Driver, type DriverState, type DrivingBody, type DrivingEvent, type DrivingWorld, type Ejection, type EjectionExit, type EjectionOptions, type ElectricalLoads, type FuelModel, type Gearbox, type Indicator, type LampMode, type ParkingSensorOptions, type ProfileTuning, type RadioSource, type RunOverOutcome, type RunOverRules, type SemiDriver, type SemiEvent, type SemiGround, type SemiInput, type SemiSimOptions, type SemiSimSpec, type SemiState, type SemiWheel, type SemiWorld, type StepResult, type Surface, type SurfaceOptions, type SurfaceRegistry, type SystemsDriver, type SystemsEvent, type SystemsState, type SystemsStepParams, type TractionOptions, type VehicleCondition, type VehicleControlOptions, type VehicleControls, type VehicleSystems, type VehicleSystemsOptions, type Wipers, bodyDamage, bumperDistance, conditionFromDamage, createArcadeDriver, createSemiSimDriver, createSurfaces, createVehicleControls, createVehicleSystems, cruiseThrottle, defaultArcadeSpec, defaultFuelModel, defaultSemiSpec, defaultSurfaces, ejectionOf, fuelRate, impactEnergy, parkingBeepInterval, runOver, semiSpecFromStats, speedLoss, surfaceGrip, tractionLimit, vehicleCorners, vehicleDamageFromImpact };
|