@jgengine/core 0.18.0 → 0.19.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/CHANGELOG.md +265 -2
- package/dist/ai/decisionGraph.d.ts +96 -0
- package/dist/ai/decisionGraph.js +212 -0
- package/dist/ai/groupAssist.d.ts +10 -0
- package/dist/ai/groupAssist.js +11 -0
- package/dist/ai/mobBrainGraph.d.ts +3 -0
- package/dist/ai/mobBrainGraph.js +25 -0
- package/dist/ai/pursuit.d.ts +1 -1
- package/dist/ai/pursuit.js +1 -1
- package/dist/ai/tacticalQueries.d.ts +30 -0
- package/dist/ai/tacticalQueries.js +45 -0
- package/dist/ai/threat.d.ts +8 -0
- package/dist/ai/threat.js +10 -0
- package/dist/anim/animGraph.d.ts +155 -0
- package/dist/anim/animGraph.js +414 -0
- package/dist/anim/boneTexture.d.ts +55 -0
- package/dist/anim/boneTexture.js +43 -0
- package/dist/anim/footPlacement.d.ts +57 -0
- package/dist/anim/footPlacement.js +67 -0
- package/dist/anim/ikSolver.d.ts +51 -0
- package/dist/anim/ikSolver.js +124 -0
- package/dist/anim/locomotionGraph.d.ts +35 -0
- package/dist/anim/locomotionGraph.js +62 -0
- package/dist/assets/spriteAtlas.d.ts +21 -0
- package/dist/assets/spriteAtlas.js +103 -0
- package/dist/audio/audioFalloff.d.ts +12 -0
- package/dist/audio/doppler.d.ts +21 -0
- package/dist/audio/doppler.js +32 -0
- package/dist/audio/engineLayers.d.ts +83 -0
- package/dist/audio/engineLayers.js +115 -0
- package/dist/combat/abilityKit.d.ts +1 -0
- package/dist/combat/abilityKit.js +1 -0
- package/dist/combat/death.d.ts +7 -0
- package/dist/combat/shotOrigin.d.ts +6 -0
- package/dist/combat/shotOrigin.js +6 -0
- package/dist/combat/weaponFeedback.d.ts +36 -0
- package/dist/combat/weaponFeedback.js +42 -0
- package/dist/combat/weaponHandling.d.ts +161 -0
- package/dist/combat/weaponHandling.js +202 -0
- package/dist/combat/weaponPresentation.d.ts +115 -0
- package/dist/combat/weaponPresentation.js +96 -0
- package/dist/devtools/warnOnce.d.ts +8 -0
- package/dist/devtools/warnOnce.js +18 -0
- package/dist/economy/currency.d.ts +16 -2
- package/dist/economy/currency.js +55 -14
- package/dist/economy/wallet.d.ts +5 -4
- package/dist/economy/wallet.js +8 -4
- package/dist/editor/commandApply.js +1 -0
- package/dist/editor/commands.d.ts +4 -1
- package/dist/editor/document.d.ts +2 -1
- package/dist/editor/document.js +92 -1
- package/dist/editor/environment.d.ts +3 -0
- package/dist/editor/environment.js +24 -0
- package/dist/editor/index.d.ts +4 -2
- package/dist/editor/index.js +1 -1
- package/dist/editor/types.d.ts +20 -0
- package/dist/faction/reputation.d.ts +6 -0
- package/dist/faction/reputation.js +11 -0
- package/dist/game/cameraConfig.d.ts +59 -1
- package/dist/game/chat.d.ts +22 -1
- package/dist/game/chat.js +48 -19
- package/dist/game/controlGate.d.ts +6 -0
- package/dist/game/controlGate.js +30 -1
- package/dist/game/defineGame.d.ts +10 -1
- package/dist/game/events.d.ts +14 -1
- package/dist/game/lootTable.d.ts +4 -0
- package/dist/game/lootTable.js +16 -0
- package/dist/game/pixelPerfect.d.ts +25 -0
- package/dist/game/pixelPerfect.js +29 -0
- package/dist/game/playableGame.d.ts +167 -6
- package/dist/game/systemRuntime.js +6 -1
- package/dist/game/toasts.d.ts +8 -0
- package/dist/game/toasts.js +7 -0
- package/dist/game/vfxInstance.d.ts +9 -0
- package/dist/game/vfxInstance.js +12 -1
- package/dist/game/viewports.d.ts +43 -0
- package/dist/game/viewports.js +46 -0
- package/dist/game/worldItem.d.ts +5 -1
- package/dist/game/worldItem.js +0 -1
- package/dist/input/actionBindings.d.ts +17 -2
- package/dist/input/actionBindings.js +24 -11
- package/dist/input/actionContexts.d.ts +45 -0
- package/dist/input/actionContexts.js +113 -0
- package/dist/input/axisInput.d.ts +4 -0
- package/dist/input/axisInput.js +4 -0
- package/dist/input/axisShaper.d.ts +73 -0
- package/dist/input/axisShaper.js +105 -0
- package/dist/input/gamepadModel.d.ts +79 -0
- package/dist/input/gamepadModel.js +108 -0
- package/dist/input/haptics.d.ts +50 -0
- package/dist/input/haptics.js +74 -0
- package/dist/input/inputBuffer.d.ts +40 -0
- package/dist/input/inputBuffer.js +59 -0
- package/dist/input/lookChannel.d.ts +10 -0
- package/dist/input/lookChannel.js +6 -0
- package/dist/input/pointer.d.ts +2 -0
- package/dist/input/pointer.js +4 -0
- package/dist/item/affix.d.ts +6 -0
- package/dist/item/affix.js +6 -0
- package/dist/meta/changelog.d.ts +1 -1
- package/dist/meta/changelog.js +196 -1
- package/dist/movement/characterController.d.ts +76 -0
- package/dist/movement/characterController.js +216 -0
- package/dist/movement/freeFlight.d.ts +119 -0
- package/dist/movement/freeFlight.js +294 -0
- package/dist/movement/glideModel.d.ts +3 -0
- package/dist/movement/glideModel.js +6 -0
- package/dist/movement/grappleSwing.d.ts +2 -0
- package/dist/movement/grappleSwing.js +5 -1
- package/dist/movement/movementModel.d.ts +39 -0
- package/dist/movement/movementModel.js +62 -19
- package/dist/movement/movementProbe.d.ts +51 -0
- package/dist/movement/movementProbe.js +119 -0
- package/dist/movement/playerMovement.d.ts +30 -3
- package/dist/movement/playerMovement.js +304 -7
- package/dist/movement/serverStep.d.ts +5 -0
- package/dist/movement/serverStep.js +6 -0
- package/dist/movement/solidObstacles.d.ts +39 -8
- package/dist/movement/solidObstacles.js +71 -6
- package/dist/movement/voxelController.js +7 -7
- package/dist/multiplayer/poseSyncGate.d.ts +3 -1
- package/dist/multiplayer/poseSyncGate.js +9 -1
- package/dist/multiplayer/presenceContract.d.ts +6 -0
- package/dist/multiplayer/presenceModel.d.ts +2 -0
- package/dist/multiplayer/presenceModel.js +11 -0
- package/dist/nav/navFromEnvironment.d.ts +9 -3
- package/dist/nav/navFromEnvironment.js +18 -12
- package/dist/nav/navMesh.d.ts +74 -0
- package/dist/nav/navMesh.js +570 -0
- package/dist/physics/aircraftDynamics.d.ts +390 -0
- package/dist/physics/aircraftDynamics.js +704 -0
- package/dist/physics/boatDynamics.d.ts +116 -0
- package/dist/physics/boatDynamics.js +160 -0
- package/dist/physics/drivableVehicle.d.ts +22 -8
- package/dist/physics/drivableVehicle.js +4 -2
- package/dist/physics/flightDynamics.d.ts +29 -4
- package/dist/physics/flightDynamics.js +28 -5
- package/dist/physics/handlingProbe.d.ts +249 -0
- package/dist/physics/handlingProbe.js +606 -0
- package/dist/physics/kinematicVehicle.d.ts +37 -2
- package/dist/physics/kinematicVehicle.js +15 -0
- package/dist/physics/physicsBackend.d.ts +203 -0
- package/dist/physics/physicsBackend.js +49 -0
- package/dist/physics/physicsBackendConformance.d.ts +27 -0
- package/dist/physics/physicsBackendConformance.js +151 -0
- package/dist/physics/physicsWorldBackend.d.ts +45 -0
- package/dist/physics/physicsWorldBackend.js +518 -0
- package/dist/physics/vehicleBackendLink.d.ts +49 -0
- package/dist/physics/vehicleBackendLink.js +102 -0
- package/dist/physics/vehicleDynamics.d.ts +374 -0
- package/dist/physics/vehicleDynamics.js +737 -0
- package/dist/physics/worldColliders.d.ts +13 -0
- package/dist/physics/worldColliders.js +128 -0
- package/dist/puzzle/cellGrid.d.ts +15 -9
- package/dist/puzzle/cellGrid.js +13 -9
- package/dist/random/rng.d.ts +12 -1
- package/dist/random/rng.js +20 -3
- package/dist/render/environment.d.ts +23 -0
- package/dist/render/environment.js +1 -0
- package/dist/render/lookPreset.d.ts +19 -6
- package/dist/render/lookPreset.js +56 -4
- package/dist/render/postProcessing.d.ts +40 -1
- package/dist/render/postProcessing.js +1 -1
- package/dist/render/sprite2d.d.ts +38 -0
- package/dist/render/sprite2d.js +40 -0
- package/dist/runtime/adapter.d.ts +20 -1
- package/dist/runtime/adapter.js +8 -1
- package/dist/runtime/cameraDirector.d.ts +17 -3
- package/dist/runtime/cameraDirector.js +25 -0
- package/dist/runtime/commandInput.d.ts +52 -0
- package/dist/runtime/commandInput.js +71 -0
- package/dist/runtime/commandRunner.d.ts +39 -7
- package/dist/runtime/commandRunner.js +35 -5
- package/dist/runtime/context/combat.d.ts +1 -0
- package/dist/runtime/context/combat.js +2 -1
- package/dist/runtime/context/deathLoot.d.ts +2 -0
- package/dist/runtime/context/deathLoot.js +1 -0
- package/dist/runtime/gameContext.js +18 -1
- package/dist/runtime/gameContextTypes.d.ts +33 -7
- package/dist/runtime/gameRuntime.d.ts +23 -5
- package/dist/runtime/gameRuntime.js +21 -4
- package/dist/runtime/headlessRunner.d.ts +10 -0
- package/dist/runtime/headlessRunner.js +26 -8
- package/dist/runtime/hostPolicy.d.ts +3 -2
- package/dist/runtime/hostPolicy.js +8 -10
- package/dist/runtime/hostedGameRunner.js +34 -6
- package/dist/runtime/hostedWorldSession.d.ts +12 -16
- package/dist/runtime/hostedWorldSession.js +29 -6
- package/dist/runtime/hostedWorldStore.d.ts +20 -0
- package/dist/runtime/hostedWorldStore.js +1 -0
- package/dist/runtime/inputRecorder.d.ts +30 -0
- package/dist/runtime/inputRecorder.js +59 -0
- package/dist/runtime/inputSnapshot.d.ts +14 -0
- package/dist/runtime/inputSnapshot.js +11 -0
- package/dist/runtime/localPlayers.d.ts +73 -0
- package/dist/runtime/localPlayers.js +119 -0
- package/dist/runtime/poseInterpolation.d.ts +36 -0
- package/dist/runtime/poseInterpolation.js +91 -0
- package/dist/runtime/prediction.d.ts +45 -0
- package/dist/runtime/prediction.js +62 -0
- package/dist/runtime/simContext.d.ts +45 -0
- package/dist/runtime/simContext.js +65 -0
- package/dist/runtime/simLoop.d.ts +52 -0
- package/dist/runtime/simLoop.js +72 -0
- package/dist/runtime/simSnapshot.d.ts +32 -0
- package/dist/runtime/simSnapshot.js +60 -0
- package/dist/runtime/snapshot.d.ts +8 -0
- package/dist/runtime/snapshotBuffer.d.ts +33 -0
- package/dist/runtime/snapshotBuffer.js +58 -0
- package/dist/runtime/transport.d.ts +41 -2
- package/dist/runtime/transport.js +7 -1
- package/dist/runtime/worldChunks.d.ts +2 -0
- package/dist/runtime/worldChunks.js +14 -0
- package/dist/runtime/worldProjection.d.ts +9 -0
- package/dist/runtime/worldProjection.js +17 -1
- package/dist/runtime/worldSnapshot.d.ts +6 -0
- package/dist/runtime/worldSnapshot.js +3 -0
- package/dist/scene/behaviorRuntime.d.ts +29 -1
- package/dist/scene/behaviorRuntime.js +71 -4
- package/dist/scene/behaviors.d.ts +12 -1
- package/dist/scene/builtinSceneKinds.js +10 -0
- package/dist/scene/sceneKinds.d.ts +9 -0
- package/dist/scene/vehicleSeat.d.ts +5 -1
- package/dist/scene/vehicleSeat.js +5 -1
- package/dist/sensor/concealment.d.ts +6 -0
- package/dist/sensor/concealment.js +8 -0
- package/dist/sensor/freezeMonitor.d.ts +6 -0
- package/dist/sensor/freezeMonitor.js +8 -0
- package/dist/sensor/perception.d.ts +70 -0
- package/dist/sensor/perception.js +189 -0
- package/dist/sensor/recordingBuffer.d.ts +3 -0
- package/dist/sensor/recordingBuffer.js +8 -0
- package/dist/session/roundState.d.ts +4 -0
- package/dist/session/roundState.js +11 -0
- package/dist/settings/frameRateLimit.d.ts +16 -0
- package/dist/settings/frameRateLimit.js +37 -0
- package/dist/settings/graphicsProfile.d.ts +21 -0
- package/dist/settings/graphicsProfile.js +48 -0
- package/dist/settings/graphicsSettings.d.ts +40 -0
- package/dist/settings/graphicsSettings.js +81 -0
- package/dist/settings/settingsModel.d.ts +9 -1
- package/dist/settings/settingsModel.js +10 -0
- package/dist/stats/eventMeter.d.ts +1 -1
- package/dist/stats/eventMeter.js +1 -1
- package/dist/time/accrueSince.d.ts +10 -0
- package/dist/time/accrueSince.js +9 -0
- package/dist/time/rateWindow.d.ts +16 -0
- package/dist/time/rateWindow.js +14 -0
- package/dist/time/serverTick.d.ts +21 -3
- package/dist/time/serverTick.js +14 -13
- package/dist/vfx/feedbackMixer.d.ts +61 -0
- package/dist/vfx/feedbackMixer.js +106 -0
- package/dist/vfx/particleDirector.d.ts +68 -0
- package/dist/vfx/particleDirector.js +81 -0
- package/dist/visibility/simulationCulling.d.ts +8 -1
- package/dist/visibility/simulationCulling.js +7 -0
- package/dist/visibility/spatialIndex.d.ts +21 -0
- package/dist/visibility/spatialIndex.js +16 -0
- package/dist/world/authoredSolids.d.ts +46 -0
- package/dist/world/authoredSolids.js +75 -0
- package/dist/world/buildingGenerator.js +2 -2
- package/dist/world/buildingKit.d.ts +3 -1
- package/dist/world/buildings.d.ts +46 -2
- package/dist/world/buildings.js +53 -3
- package/dist/world/cityContent.js +103 -25
- package/dist/world/cityKind.d.ts +139 -0
- package/dist/world/cityKind.js +367 -16
- package/dist/world/features.d.ts +56 -3
- package/dist/world/features.js +13 -2
- package/dist/world/footprintGrid.d.ts +7 -0
- package/dist/world/footprintGrid.js +16 -0
- package/dist/world/interiors.d.ts +1 -0
- package/dist/world/interiors.js +5 -3
- package/dist/world/lod.d.ts +6 -0
- package/dist/world/lod.js +8 -0
- package/dist/world/placement.d.ts +7 -0
- package/dist/world/placement.js +2 -0
- package/dist/world/placementController.d.ts +1 -1
- package/dist/world/placementController.js +7 -0
- package/dist/world/raceCircuit.d.ts +168 -0
- package/dist/world/raceCircuit.js +797 -0
- package/dist/world/terraform.d.ts +8 -0
- package/dist/world/terraform.js +7 -0
- package/dist/world/terrain.d.ts +5 -1
- package/dist/world/terrain.js +5 -0
- package/dist/world/territory.d.ts +97 -0
- package/dist/world/territory.js +182 -0
- package/dist/world/walls.d.ts +7 -0
- package/dist/world/walls.js +7 -0
- package/dist/world/worldSolids.d.ts +84 -0
- package/dist/world/worldSolids.js +240 -0
- package/dist/world.d.ts +5 -3
- package/dist/world.js +4 -2
- package/package.json +1 -1
- package/skills/ce-handoff/SKILL.md +2 -2
- package/skills/game-design/SKILL.md +11 -1
- package/skills/jgengine/SKILL.md +9 -5
- package/skills/jgengine/api.md +205 -101
- package/skills/jgengine/capabilities.md +56 -0
- package/skills/jgengine/recipes/minimal-game.md +3 -0
- package/skills/jgengine-combat/SKILL.md +5 -0
- package/skills/jgengine-combat/api.md +138 -103
- package/skills/jgengine-combat/capabilities.md +29 -1
- package/skills/jgengine-combat/recipes/weapon-feel.md +50 -0
- package/skills/jgengine-gameplay/SKILL.md +10 -0
- package/skills/jgengine-gameplay/api.md +501 -453
- package/skills/jgengine-gameplay/capabilities.md +36 -0
- package/skills/jgengine-gameplay/reference-systems.md +4 -0
- package/skills/jgengine-world/SKILL.md +21 -3
- package/skills/jgengine-world/api.md +1172 -625
- package/skills/jgengine-world/capabilities.md +229 -3
- package/skills/jgengine-world/recipes/character-animation.md +39 -0
- package/skills/jgengine-world/recipes/controls.md +44 -0
- package/skills/jgengine-world/recipes/flight-feel.md +76 -0
- package/skills/jgengine-world/recipes/npc-senses.md +43 -0
- package/skills/jgengine-world/recipes/vehicle-feel.md +85 -0
- package/skills/jgengine-world/reference.md +31 -2
- package/skills/jgengine-world/visibility.md +112 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import type { AxisInput } from "../input/axisInput.js";
|
|
2
|
+
import type { GripCurve } from "./vehicleBody.js";
|
|
3
|
+
/**
|
|
4
|
+
* One axle's tire, in physical terms. Lateral force follows a simplified Pacejka curve
|
|
5
|
+
* `μ·Fz·sin(C·atan(B·α))` whose `B`/`C` are solved from `peakSlipAngle` and `slideGrip`, so the three
|
|
6
|
+
* numbers read the way a driver feels them: how much grip, how early it peaks, how much is left sliding.
|
|
7
|
+
*/
|
|
8
|
+
export interface VehicleTireTuning {
|
|
9
|
+
/** Peak friction coefficient μ on an ideal surface (0.7 worn street … 1.1 sport … 1.6 slick/arcade). */
|
|
10
|
+
peakGrip: number;
|
|
11
|
+
/** Slip angle in radians where lateral force peaks (0.07 stiff race tire … 0.2 soft, forgiving tire). */
|
|
12
|
+
peakSlipAngle: number;
|
|
13
|
+
/** Fraction of peak force left at a full 90° slide, `0..1` (0.6 snappy … 0.95 drift-friendly). */
|
|
14
|
+
slideGrip: number;
|
|
15
|
+
}
|
|
16
|
+
/** Engine and gearbox. Drive force at the wheels = torque · curve(rpm) · gear · finalDrive · efficiency / wheelRadius. */
|
|
17
|
+
export interface VehicleGearboxTuning {
|
|
18
|
+
kind: "gearbox";
|
|
19
|
+
/** Peak engine torque, N·m. */
|
|
20
|
+
peakTorque: number;
|
|
21
|
+
/** Torque multiplier by normalized rpm (`0` = idle, `1` = redline); same shape as a grip curve. */
|
|
22
|
+
torqueCurve: GripCurve;
|
|
23
|
+
idleRpm: number;
|
|
24
|
+
redlineRpm: number;
|
|
25
|
+
shiftUpRpm: number;
|
|
26
|
+
shiftDownRpm: number;
|
|
27
|
+
/** Seconds of reduced drive during a shift. */
|
|
28
|
+
shiftSeconds: number;
|
|
29
|
+
gears: readonly number[];
|
|
30
|
+
reverseGear: number;
|
|
31
|
+
finalDrive: number;
|
|
32
|
+
/** Driven wheel radius, m. */
|
|
33
|
+
wheelRadius: number;
|
|
34
|
+
/** Driveline efficiency `0..1` (default `0.85`). */
|
|
35
|
+
efficiency?: number;
|
|
36
|
+
/** Engine-braking torque at the crank with the throttle closed, N·m (default `0.12 · peakTorque`). */
|
|
37
|
+
engineBrakeTorque?: number;
|
|
38
|
+
/** Clutch-slip rpm the engine holds while launching from rest (default halfway between idle and peak). */
|
|
39
|
+
launchRpm?: number;
|
|
40
|
+
}
|
|
41
|
+
/** Single-speed drive (electric, kart, arcade ball-car): force capped by power, so top speed comes out of drag. */
|
|
42
|
+
export interface VehicleDirectDriveTuning {
|
|
43
|
+
kind: "direct";
|
|
44
|
+
/** Maximum tractive force at the wheels, N. */
|
|
45
|
+
maxForce: number;
|
|
46
|
+
/** Maximum power, W; force falls off as `power / speed` above the crossover. */
|
|
47
|
+
maxPower: number;
|
|
48
|
+
/** Reverse force as a fraction of `maxForce` (default `0.5`). */
|
|
49
|
+
reverseScale?: number;
|
|
50
|
+
/** Throttle-off drag force at the wheels, N (default `0.08 · maxForce`). */
|
|
51
|
+
coastForce?: number;
|
|
52
|
+
}
|
|
53
|
+
/** Steering rack: lock, speed-sensitive lock, rack speed, and caster self-alignment. */
|
|
54
|
+
export interface VehicleSteeringTuning {
|
|
55
|
+
/** Front-wheel lock at parking speed, rad. */
|
|
56
|
+
maxAngle: number;
|
|
57
|
+
/** Lock at and above `highSpeedAt`, rad; lower = calmer at speed. */
|
|
58
|
+
highSpeedAngle: number;
|
|
59
|
+
/** Speed where lock reaches `highSpeedAngle`, m/s. */
|
|
60
|
+
highSpeedAt: number;
|
|
61
|
+
/** Rack speed toward the requested angle, rad/s — a keyboard tap and a stick flick both pass through this. */
|
|
62
|
+
rate: number;
|
|
63
|
+
/** Rack speed back to centre when the request is released or reversed, rad/s (default `rate`). */
|
|
64
|
+
returnRate?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Caster self-alignment `0..1`: the fraction of the car's sideslip the front wheels steer into on their
|
|
67
|
+
* own. `0` leaves every catch to the driver (sim), `~0.3` is a real street car, `0.8+` catches slides for
|
|
68
|
+
* the player (arcade).
|
|
69
|
+
*/
|
|
70
|
+
selfAlign?: number;
|
|
71
|
+
}
|
|
72
|
+
/** Electronic and arcade assists; each is a strength `0..1`, `0`/omitted = off. */
|
|
73
|
+
export interface VehicleAssistTuning {
|
|
74
|
+
/** Anti-lock: caps brake force below the tire's remaining grip so the front keeps steering. */
|
|
75
|
+
abs?: number;
|
|
76
|
+
/** Traction control: caps drive force below the driven axle's remaining grip. */
|
|
77
|
+
tractionControl?: number;
|
|
78
|
+
/**
|
|
79
|
+
* Stability (yaw) control: a corrective yaw torque once sideslip exceeds `maxSideslip`. Real ESC is subtle
|
|
80
|
+
* (`~0.3`); arcade street cars that can't spin out sit near `1`.
|
|
81
|
+
*/
|
|
82
|
+
stability?: number;
|
|
83
|
+
/** Sideslip in rad that `stability` allows before it intervenes (default `0.2`, ≈11°). */
|
|
84
|
+
maxSideslip?: number;
|
|
85
|
+
/** Anti-wheelie: caps drive below the acceleration that lifts the front (`g·b/h`); reports as `tractionLimited`. */
|
|
86
|
+
antiWheelie?: number;
|
|
87
|
+
/** Anti-stoppie: caps braking below the deceleration that lifts the rear (`g·a/h`); reports as `absActive`. */
|
|
88
|
+
antiStoppie?: number;
|
|
89
|
+
}
|
|
90
|
+
/** Aero and resistance. Uses air density 1.225 kg/m³. */
|
|
91
|
+
export interface VehicleAeroTuning {
|
|
92
|
+
/** Drag coefficient × frontal area, m² (0.6 sports car … 1.0 SUV). */
|
|
93
|
+
dragArea?: number;
|
|
94
|
+
/** Lift coefficient × area producing downforce, m² (0 road car … 3 race car). */
|
|
95
|
+
downforceArea?: number;
|
|
96
|
+
/** Share of downforce on the front axle, `0..1` (default `0.45`). */
|
|
97
|
+
downforceFront?: number;
|
|
98
|
+
/** Rolling-resistance coefficient (default `0.015`). */
|
|
99
|
+
rollingResistance?: number;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Four sprung corners. With this block the chassis heaves, pitches and rolls on real springs, axle loads come
|
|
103
|
+
* from spring forces instead of a filtered estimate, slopes pull the car downhill, and the car can leave
|
|
104
|
+
* the ground and land. Omit it for the flat-ground model.
|
|
105
|
+
*/
|
|
106
|
+
export interface VehicleSuspensionTuning {
|
|
107
|
+
/** Spring rate per wheel, N/m (20 000 soft road car … 60 000 race car; monster trucks go lower with more travel). */
|
|
108
|
+
springRate: number;
|
|
109
|
+
/** Damper rate per wheel in compression, N·s/m (roughly 2·√(k·m/4)·0.3 for a comfortable car, higher for a racer). */
|
|
110
|
+
damperRate: number;
|
|
111
|
+
/** Damper rate per wheel in extension, N·s/m (default `1.5 · damperRate`); higher keeps a landing from bouncing. */
|
|
112
|
+
reboundRate?: number;
|
|
113
|
+
/** Compression available before the bump stop, m (0.08 race car … 0.6 monster truck). */
|
|
114
|
+
travel: number;
|
|
115
|
+
/** Centre-of-mass height above level ground at static rest, m. */
|
|
116
|
+
rideHeight: number;
|
|
117
|
+
/** Total anti-roll bar stiffness, N·m/rad, split between axles by `rollStiffnessFront` (default `0`). */
|
|
118
|
+
antiRoll?: number;
|
|
119
|
+
/** Pitch inertia as a multiple of `m·a·b` (default `0.9`). */
|
|
120
|
+
pitchInertiaIndex?: number;
|
|
121
|
+
}
|
|
122
|
+
/** Control of the body while airborne (needs `suspension`, the only way to leave the ground). */
|
|
123
|
+
export interface VehicleAirTuning {
|
|
124
|
+
/** Angular acceleration at full input, rad/s², per axis. */
|
|
125
|
+
pitchAccel: number;
|
|
126
|
+
yawAccel: number;
|
|
127
|
+
rollAccel: number;
|
|
128
|
+
/** Angular damping while airborne, 1/s (default `1.5`); higher stops rotation when input is released. */
|
|
129
|
+
damping?: number;
|
|
130
|
+
/** Largest angular rate input can build, rad/s (default `5.5`). */
|
|
131
|
+
maxRate?: number;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Single-track lean for motorcycles, bicycles and scooters. Steer input asks for a lean angle; the front wheel
|
|
135
|
+
* then takes whatever angle a balanced turn at that lean needs (curvature = g·tan(lean) / v²), with a brief
|
|
136
|
+
* countersteer as the lean starts. Tire grip still limits the turn, so over-leaning on a low-grip surface slides.
|
|
137
|
+
*/
|
|
138
|
+
export interface VehicleLeanTuning {
|
|
139
|
+
/** Largest lean the rider asks for at full steer, rad (0.7 ≈ 40° road bike … 0.95 ≈ 55° race bike). */
|
|
140
|
+
maxLean: number;
|
|
141
|
+
/** How fast the bike can change lean, rad/s (2 heavy tourer … 5 light sport bike). */
|
|
142
|
+
leanRate: number;
|
|
143
|
+
/** Seconds of opposite bar per rad/s of lean change — the countersteer that starts a lean (default `0.012`, about 3° of bar on a quick sport bike). */
|
|
144
|
+
countersteer?: number;
|
|
145
|
+
/** Below this speed the bar steers directly, like walking a bike (default `3` m/s). */
|
|
146
|
+
directSteerBelow?: number;
|
|
147
|
+
}
|
|
148
|
+
/** Jumps from the ground and in the air. */
|
|
149
|
+
export interface VehicleJumpTuning {
|
|
150
|
+
/** Upward velocity a jump adds, m/s. */
|
|
151
|
+
speed: number;
|
|
152
|
+
/** Jumps allowed per flight, counting the first from the ground (default `1`; `2` = double jump). */
|
|
153
|
+
count?: number;
|
|
154
|
+
/** Seconds after leaving the ground during which later jumps are allowed (default `Infinity`). */
|
|
155
|
+
window?: number;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Tuning for {@link createVehicleDynamics}. Every number is a physical quantity in SI units (kg, m, N,
|
|
159
|
+
* N·m, rad, s), so a feel target maps to a knob a person can reason about: more rear grip or a lower
|
|
160
|
+
* centre of mass for stability, softer tires for forgiveness, more drive to the rear for power oversteer.
|
|
161
|
+
*/
|
|
162
|
+
export interface VehicleDynamicsTuning {
|
|
163
|
+
/** Total mass, kg. */
|
|
164
|
+
massKg: number;
|
|
165
|
+
/** Axle-to-axle distance, m. */
|
|
166
|
+
wheelbase: number;
|
|
167
|
+
/** Share of static weight on the front axle, `0..1` (0.6 front-engined FWD … 0.45 mid-engine). */
|
|
168
|
+
frontWeight: number;
|
|
169
|
+
/** Centre-of-mass height, m; drives longitudinal and lateral load transfer and body attitude. */
|
|
170
|
+
comHeight: number;
|
|
171
|
+
/** Track width, m. */
|
|
172
|
+
trackWidth: number;
|
|
173
|
+
/** Yaw inertia as a dynamic index `Iz / (m·a·b)` (default `1`; `<1` rotates eagerly, `>1` lazily). */
|
|
174
|
+
yawInertiaIndex?: number;
|
|
175
|
+
/**
|
|
176
|
+
* Share of lateral load transfer taken by the front axle, `0..1` (default `0.5`). The classic balance knob:
|
|
177
|
+
* more front → the front saturates first (understeer), less → the rear does (oversteer).
|
|
178
|
+
*/
|
|
179
|
+
rollStiffnessFront?: number;
|
|
180
|
+
/** Tire load sensitivity `0..0.5`: how much an axle's grip drops as load moves across it (default `0.2`). */
|
|
181
|
+
loadSensitivity?: number;
|
|
182
|
+
front: VehicleTireTuning;
|
|
183
|
+
/** Rear tire; defaults to `front`. */
|
|
184
|
+
rear?: VehicleTireTuning;
|
|
185
|
+
/** Share of drive force to the front axle, `0..1` (`0` RWD, `1` FWD, `0.35` rear-biased AWD). */
|
|
186
|
+
driveFront: number;
|
|
187
|
+
powertrain: VehicleGearboxTuning | VehicleDirectDriveTuning;
|
|
188
|
+
/** Peak service-brake force across all wheels, N. */
|
|
189
|
+
brakeForce: number;
|
|
190
|
+
/** Share of brake force on the front axle, `0..1` (default `0.65`). */
|
|
191
|
+
brakeFront?: number;
|
|
192
|
+
/** Rear lateral grip multiplier while the handbrake is fully on (default `0.35`). */
|
|
193
|
+
handbrakeGrip?: number;
|
|
194
|
+
steering: VehicleSteeringTuning;
|
|
195
|
+
assists?: VehicleAssistTuning;
|
|
196
|
+
aero?: VehicleAeroTuning;
|
|
197
|
+
/**
|
|
198
|
+
* Drive governor, m/s: drive force fades out over the last 0.5 m/s below it (arcade caps, electronic
|
|
199
|
+
* limiters). Thrust, slopes and impulses can still carry the car past it. Omit to let power and drag decide.
|
|
200
|
+
*/
|
|
201
|
+
speedLimit?: number;
|
|
202
|
+
/** Reverse speed cap, m/s (default `8`). */
|
|
203
|
+
reverseSpeed?: number;
|
|
204
|
+
/** Body roll stiffness, N·m/rad, for the visual lean (default derived for ~3° at 1 g). */
|
|
205
|
+
rollStiffness?: number;
|
|
206
|
+
/** Body pitch stiffness, N·m/rad, for dive and squat (default derived for ~2° at 1 g). */
|
|
207
|
+
pitchStiffness?: number;
|
|
208
|
+
/** Suspension settle rate for load transfer and body attitude, 1/s (default `8`). */
|
|
209
|
+
suspensionResponse?: number;
|
|
210
|
+
/** Largest integration substep, s (default `1/240`); ticks are split so the result does not depend on frame rate. */
|
|
211
|
+
maxSubstep?: number;
|
|
212
|
+
/** Brake held near standstill drives in reverse (default `true`). Set `false` for a separate reverse action. */
|
|
213
|
+
reverseOnBrake?: boolean;
|
|
214
|
+
/** Sprung corners, slopes and air; omit for the flat-ground model. */
|
|
215
|
+
suspension?: VehicleSuspensionTuning;
|
|
216
|
+
/** Air control; needs `suspension`. Input comes from `modifiers.air`, else throttle−brake pitches and steer yaws. */
|
|
217
|
+
air?: VehicleAirTuning;
|
|
218
|
+
/** Enables {@link VehicleDynamics.jump}; needs `suspension`. */
|
|
219
|
+
jump?: VehicleJumpTuning;
|
|
220
|
+
/** Single-track lean (motorcycle); omit for a four-wheeled car. `trackWidth` then only sets the render width. */
|
|
221
|
+
lean?: VehicleLeanTuning;
|
|
222
|
+
}
|
|
223
|
+
/** Air-control input, each `-1..1`: `pitch > 0` noses down, `yaw > 0` turns like `steer > 0`, `roll > 0` drops the left side. */
|
|
224
|
+
export interface VehicleAirInput {
|
|
225
|
+
pitch: number;
|
|
226
|
+
yaw: number;
|
|
227
|
+
roll: number;
|
|
228
|
+
}
|
|
229
|
+
/** Per-tick overrides layered over tuning: boost, grip zones, damage. Each scale defaults to `1`. */
|
|
230
|
+
export interface VehicleDynamicsModifiers {
|
|
231
|
+
driveScale?: number;
|
|
232
|
+
brakeScale?: number;
|
|
233
|
+
gripScale?: number;
|
|
234
|
+
steerScale?: number;
|
|
235
|
+
/** Thrust along the heading that bypasses the tires, N — boost, a rocket, a tow. */
|
|
236
|
+
thrust?: number;
|
|
237
|
+
/** Air-control input this tick; omitted, throttle−brake pitches and steer yaws while airborne. */
|
|
238
|
+
air?: VehicleAirInput;
|
|
239
|
+
}
|
|
240
|
+
/** World hooks for one vehicle instance. */
|
|
241
|
+
export interface VehicleDynamicsOptions {
|
|
242
|
+
position?: readonly [number, number, number];
|
|
243
|
+
heading?: number;
|
|
244
|
+
/** Grip multiplier by world position (gravel, ice, wet paint); default `1`. */
|
|
245
|
+
surfaceFriction?: (x: number, z: number) => number;
|
|
246
|
+
/** Clamp a planar move (walls, bounds); velocity is rederived from the allowed displacement. */
|
|
247
|
+
clampMove?: (from: readonly [number, number], to: readonly [number, number]) => readonly [number, number];
|
|
248
|
+
/** Terrain height under a point; read per wheel when `suspension` is set (ramps, hills, ledges). Default flat at the spawn height. */
|
|
249
|
+
groundHeight?: (x: number, z: number) => number;
|
|
250
|
+
}
|
|
251
|
+
/** Serializable integrator state: everything {@link VehicleDynamics.restore} needs to resume bit-for-bit. */
|
|
252
|
+
export interface VehicleDynamicsState {
|
|
253
|
+
x: number;
|
|
254
|
+
y: number;
|
|
255
|
+
z: number;
|
|
256
|
+
heading: number;
|
|
257
|
+
vx: number;
|
|
258
|
+
vz: number;
|
|
259
|
+
yawRate: number;
|
|
260
|
+
steerAngle: number;
|
|
261
|
+
gearIndex: number;
|
|
262
|
+
reversing: boolean;
|
|
263
|
+
shiftRemaining: number;
|
|
264
|
+
rpm: number;
|
|
265
|
+
longitudinalAccel: number;
|
|
266
|
+
lateralAccel: number;
|
|
267
|
+
bodyPitch: number;
|
|
268
|
+
bodyRoll: number;
|
|
269
|
+
/** Vertical velocity of the chassis, m/s (suspension only). */
|
|
270
|
+
vy: number;
|
|
271
|
+
pitchRate: number;
|
|
272
|
+
rollRate: number;
|
|
273
|
+
/** Per-corner spring compression, m, in order front-left, front-right, rear-left, rear-right. */
|
|
274
|
+
compression: [number, number, number, number];
|
|
275
|
+
airborne: boolean;
|
|
276
|
+
/** The lean the rider is asking for, rad, positive right; it sets the turn the bar steers for. */
|
|
277
|
+
lean: number;
|
|
278
|
+
/** The rider's bar correction on top of the balanced-turn angle, rad. */
|
|
279
|
+
leanTrim: number;
|
|
280
|
+
/** Jumps used since last on the ground. */
|
|
281
|
+
jumpsUsed: number;
|
|
282
|
+
/** Seconds since leaving the ground (`0` while grounded). */
|
|
283
|
+
airTime: number;
|
|
284
|
+
}
|
|
285
|
+
/** Result of one {@link VehicleDynamics.tick}: pose plus the telemetry camera, audio, haptics and HUD read. */
|
|
286
|
+
export interface VehicleDynamicsStep {
|
|
287
|
+
position: readonly [number, number, number];
|
|
288
|
+
heading: number;
|
|
289
|
+
/** Signed speed along the heading, m/s. */
|
|
290
|
+
forwardSpeed: number;
|
|
291
|
+
/** Lateral speed, m/s (same sign convention as `KinematicVehicleStep.lateralSpeed`). */
|
|
292
|
+
lateralSpeed: number;
|
|
293
|
+
yawRate: number;
|
|
294
|
+
/** Front-wheel angle, rad; positive steers the heading down, like `AxisInput.steer`. */
|
|
295
|
+
steerAngle: number;
|
|
296
|
+
/** Body sideslip β, rad: angle between heading and velocity. */
|
|
297
|
+
sideslip: number;
|
|
298
|
+
slipAngleFront: number;
|
|
299
|
+
slipAngleRear: number;
|
|
300
|
+
/** Share of each axle's friction budget in use, `0..1+`; `≥1` means that axle is sliding. Squeal, rumble and HUD key off it. */
|
|
301
|
+
frontSaturation: number;
|
|
302
|
+
rearSaturation: number;
|
|
303
|
+
/** Lateral acceleration, m/s²; positive toward the car's right, the way `steer > 0` turns. */
|
|
304
|
+
lateralAccel: number;
|
|
305
|
+
longitudinalAccel: number;
|
|
306
|
+
frontLoad: number;
|
|
307
|
+
rearLoad: number;
|
|
308
|
+
/** Surface multiplier sampled this tick. */
|
|
309
|
+
surface: number;
|
|
310
|
+
/** One-based forward gear; `-1` in reverse. */
|
|
311
|
+
gear: number;
|
|
312
|
+
rpm: number;
|
|
313
|
+
/** Throttle `0..1` actually applied after traction control and the rev limiter — engine audio load. */
|
|
314
|
+
engineLoad: number;
|
|
315
|
+
wheelspin: boolean;
|
|
316
|
+
wheelLock: boolean;
|
|
317
|
+
absActive: boolean;
|
|
318
|
+
tractionLimited: boolean;
|
|
319
|
+
stabilityActive: boolean;
|
|
320
|
+
bodyPitch: number;
|
|
321
|
+
bodyRoll: number;
|
|
322
|
+
/** Height of the car's base above the terrain under it, m; `0` on the ground and always `0` without `suspension`. */
|
|
323
|
+
airOffset: number;
|
|
324
|
+
/** No wheel touches the ground. */
|
|
325
|
+
airborne: boolean;
|
|
326
|
+
/** Vertical speed at the moment of touchdown this tick, m/s (`0` otherwise) — landing shake, thud, rumble. */
|
|
327
|
+
landingSpeed: number;
|
|
328
|
+
/** Per-corner spring load, N (front-left, front-right, rear-left, rear-right); all `0` without `suspension`. */
|
|
329
|
+
wheelLoads: readonly [number, number, number, number];
|
|
330
|
+
/** Balance lean the bike actually shows, `atan(lateral g)`, rad, positive leaning right; `0` without a `lean` block. */
|
|
331
|
+
lean: number;
|
|
332
|
+
/** Acceleration has taken all the load off the front axle. */
|
|
333
|
+
wheelie: boolean;
|
|
334
|
+
/** Braking has taken all the load off the rear axle. */
|
|
335
|
+
stoppie: boolean;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Force-based planar car: a two-axle ("bicycle") model where yaw comes from tire forces rather than being
|
|
339
|
+
* commanded, so understeer, oversteer, lift-off rotation, trail-braking, power slides and handbrake turns
|
|
340
|
+
* emerge from the numbers instead of from special cases. Deterministic for a given `dt` sequence; ticks are
|
|
341
|
+
* split into fixed substeps. Pairs with `tickDrivableVehicle` for the entity pose and `measureHandling`
|
|
342
|
+
* for asserting feel.
|
|
343
|
+
*/
|
|
344
|
+
export interface VehicleDynamics {
|
|
345
|
+
tick(dt: number, input: AxisInput, modifiers?: VehicleDynamicsModifiers): VehicleDynamicsStep;
|
|
346
|
+
pose(): {
|
|
347
|
+
position: readonly [number, number, number];
|
|
348
|
+
heading: number;
|
|
349
|
+
};
|
|
350
|
+
/** World velocity on the ground plane, `[vx, vz]`, m/s. */
|
|
351
|
+
velocity(): readonly [number, number];
|
|
352
|
+
/** Scale planar velocity and yaw rate (crash, boost pad). */
|
|
353
|
+
scaleVelocity(factor: number): void;
|
|
354
|
+
/** Add a world-space velocity change, m/s (impacts, knockback, a jump pad's `dvy` with `suspension`). */
|
|
355
|
+
applyImpulse(dvx: number, dvz: number, dvy?: number): void;
|
|
356
|
+
/**
|
|
357
|
+
* Jump if the tuning's `jump` block allows it now: from the ground, or in the air while jumps remain inside
|
|
358
|
+
* the window. Returns `false` and changes nothing otherwise, so a held key cannot stack jumps.
|
|
359
|
+
*/
|
|
360
|
+
jump(): boolean;
|
|
361
|
+
/** Add angular velocity to the body, rad/s: `pitch > 0` noses down, `yaw` in heading sense, `roll > 0` drops the left side (dodges, flips, hits). */
|
|
362
|
+
applyAngularImpulse(pitch: number, yaw: number, roll: number): void;
|
|
363
|
+
/** Swap tuning in place (upgrades, damage, a live tuning panel) without losing momentum. */
|
|
364
|
+
retune(next: VehicleDynamicsTuning): void;
|
|
365
|
+
tuning(): VehicleDynamicsTuning;
|
|
366
|
+
snapshot(): VehicleDynamicsState;
|
|
367
|
+
restore(state: VehicleDynamicsState): void;
|
|
368
|
+
resetTo(position: readonly [number, number, number], heading: number): void;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Creates a {@link VehicleDynamics}.
|
|
372
|
+
* @capability vehicle-dynamics force-based car handling — tires, load transfer, drivetrain, assists — tuned with physical numbers
|
|
373
|
+
*/
|
|
374
|
+
export declare function createVehicleDynamics(initialTuning: VehicleDynamicsTuning, options?: VehicleDynamicsOptions): VehicleDynamics;
|