import type { Vec3 } from './vehicleMath'; export interface Box3 { min: Vec3; max: Vec3; name?: string; id?: string; } export declare const CLEARANCE_DEFAULTS: { /** Stop at least this far short of the nearest scenery (beyond the car's own bumper). */ readonly marginM: 1.5; /** Braking deceleration assumed when planning a stop (the foot brake): conservative, a road car manages 7-9. */ readonly brakeDecelMps2: 4; /** The coast the spin is sampled over, seconds (the route's sampleSpin window). */ readonly coastS: 1.3; /** * Planned time from throttle release to the brake. It must cover everything that happens at speed before the coast * window closes: slip settling (up to slipSettleMaxS), the camera move and page round trip before sampling starts, * the coast itself (coastS), the page guard's 0.25 s reaction allowance, and the push a car still gets after the * release (measured: the F40 gained 0.4 m/s). At 1.7 s the page guard cut the coast at 0.64-0.88 s on the 993 and the * F40 in the test grounds (17 m of room), so spin_with_speed failed on a harness limit, not the car. */ readonly coastPlanS: 2.6; /** Return-to-start: close enough along the start heading. */ readonly returnTolM: 0.5; /** Return-to-start: never drive faster than this, either way. */ readonly returnMaxSpeedMps: 3; /** Return-to-start: give up after this long (the occupant phase still runs; the facts say how far off it ended). */ readonly returnMaxS: 14; /** Exterior cameras: the near plane sits this far short of the closest point of the car (and occupant) box. */ readonly nearMarginM: 0.05; /** ...and never closer than the route's usual near. */ readonly minNearM: 0.05; /** A coasting car slows at a few m/s² at most (engine drag in first gear); faster than this is an impact, not a coast. */ readonly impactDecelMps2: 8; /** The coast is sampled once every wheel rolls within this fraction of road speed (launch wheelspin has died away). */ readonly slipSettledFraction: 0.06; /** ...waiting at most this long for it, seconds. */ readonly slipSettleMaxS: 0.5; }; /** Entry parameter of the ray `origin + t·dir` (t ≥ 0) into an axis-aligned box; 0 when the origin is inside; null on a miss. */ export declare function rayBoxEntry(origin: Vec3, dir: Vec3, box: Box3): number | null; export declare const boxContains: (box: Box3, p: Vec3, pad?: number) => boolean; /** * Clear distance from a set of ray origins (the car's bumper face, at a few heights and widths, WORLD frame) along `dir` * (unit) to the first scenery box. A box that already contains an origin is skipped: it is the ground slab under the * bumper or a mesh that encloses the whole grounds, and neither stops a car. Infinity when nothing is ahead. */ export declare function clearanceAlong(origins: Vec3[], dir: Vec3, boxes: Box3[]): { distanceM: number; box: string | null; skipped: number; }; /** Distance needed to stop from `speed` at `decel`. */ export declare const stoppingDistance: (speedMps: number, decelMps2?: number) => number; /** * Throttle phase: release now if, coasting `coastS` at the current speed and then braking, the car would get closer * than `marginM` to the scenery `clearM` metres ahead of where the throttle phase began. */ export declare function shouldRelease(o: { travelledM: number; speedMps: number; clearM: number; coastS?: number; marginM?: number; brakeDecelMps2?: number; }): boolean; /** Reverse phase: stop backing up before the planned stop would come within `marginM` of what is behind. */ export declare function shouldStopReversing(o: { travelledM: number; speedMps: number; clearM: number; wantM: number; marginM?: number; brakeDecelMps2?: number; }): boolean; export type ReturnAction = 'forward' | 'reverse' | 'brake' | 'coast' | 'done'; /** * One step of the closed-loop return to the start position. `alongM` is the car's displacement from the start along * the start heading (positive = ahead of it), `speedMps` its forward speed (positive = moving forward). */ export declare function returnStep(o: { alongM: number; speedMps: number; tolM?: number; maxSpeedMps?: number; brakeDecelMps2?: number; }): ReturnAction; export declare function unionBoxes(boxes: Array): Box3 | null; /** Axis-aligned box of flat xyz points (an occupant's skinned vertices). */ export declare function boxOfPoints(points: ArrayLike): Box3 | null; /** * Near plane for an exterior camera (BODY frame): just short of the closest corner of `keep` (the drawn car, with its * occupant and any open panel) along the view direction, so everything nearer to the lens than the car — a wall the * camera was put behind — is clipped, and no part of the car ever is. A camera at or inside the box keeps `minNear`. */ export declare function nearPlaneClearOf(pos: Vec3, target: Vec3, keep: Box3 | null, o?: { marginM?: number; minNearM?: number; }): number; /** * Scenery boxes (WORLD frame) that still cross a sight line from the camera to the car after the near plane: any part of * the segment camera→target beyond `nearM` (measured along the segment) inside the box. A box containing a target is the * world the car stands in (or the ground), not an occluder, and is never reported. */ export declare function occludersOf(cam: Vec3, targets: Vec3[], boxes: Box3[], nearM?: number): Box3[]; /** Row-major-free: a three.js `Matrix4.elements` (column-major) applied to a point. */ export declare function applyMatrix(e: ArrayLike, p: Vec3): Vec3; export interface CoastSample { t: number; x: number; z: number; forwardSpeed?: number; } /** * The spin is judged over a FREE coast. If the car hit something during the window (its physics forward speed drops faster * than any coast can over at least `windowMs`), only the samples before the impact are kept. Physics speed, not * frame-to-frame position: the physics steps at its own rate, so a render frame with no step reads as a stop. */ export declare function trimAtImpact(samples: S[], maxDecelMps2?: number, windowMs?: number): { samples: S[]; impactAtS: number | null; }; /** * The harness driver's traction control lifts W while a driven wheel slips, so a powerful car does not leave a spinning wheel * pushing on after the throttle is released. The engine holds a seated driver whose pedal axis is untouched (brake AND handbrake) * below 1.5 m/s (VehicleDriveAbility AUTO_HOLD_SPEED_MPS, humanoid-character 0.3.517+): a lift inside that band parks the car, * the wheels stop, W returns, the wheels spin again, and the car crawls (measured: 1.4 m in 4 s of full throttle on the Porsche 993, * R8 and Huayra, 7 lifts, wheels turned 0.00 rad). So the traction control only works above this speed; below it W stays down. */ export declare const TC_MIN_SPEED_MPS = 3; export declare const TC_SLIP = 0.25; /** Should the driver's traction control lift W now? Only above {@link TC_MIN_SPEED_MPS}, and only when a wheel slips more than {@link TC_SLIP}. */ export declare function tractionLift(speedMps: number, slip: number | null): boolean; /** Worst wheel slip: |wheel surface speed − road speed| / road speed, over every wheel that reports an angular velocity. */ export declare function worstSlip(speedMps: number, omegas: Array, radii: number[]): number | null; /** * The radius the runtime turns a wheel with: on the v2 land solver each wheel rolls on its axle's tyre * (`simulation.land.tyreByAxle[min(axle, n-1)].radius`; a staggered car has a different one per axle), otherwise on the * wheel contact's own radius. Never one chassis-wide `wheelRadius`. */ export declare function wheelRollingRadius(contact: { radius: number; axle?: number | null; }, tyreByAxle?: ReadonlyArray<{ radius?: number | null; } | null> | null): number;