@threenative/physics 0.3.3 → 0.3.5

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.
@@ -154,6 +154,62 @@ interface IPhysicsCharacterState {
154
154
  readonly groundCollider?: number;
155
155
  readonly groundNormal?: IPhysicsVector3;
156
156
  }
157
+ /** One record is wheel contact (0 or 1), suspension length in metres, and rotation in radians. */
158
+ declare const PHYSICS_VEHICLE_WHEEL_STRIDE = 3;
159
+ /** Godot's `VehicleWheel3D`, as backend-neutral data: the numbers, never a vehicle object. */
160
+ interface IPhysicsVehicleWheelOptions {
161
+ /** The wheel's attachment point in chassis-local space. */
162
+ readonly position: IPhysicsVector3;
163
+ readonly wheelRadius: number;
164
+ readonly suspensionRestLength: number;
165
+ /**
166
+ * Suspension stiffness, mass-normalised: the square of the suspension's natural frequency in
167
+ * rad/s, not newtons per metre. Sag is about `9.81 / (4 * suspensionStiffness)` metres, so `100`
168
+ * is a road car and `20` — Godot's default number — bottoms the strut out under its own weight.
169
+ */
170
+ readonly suspensionStiffness: number;
171
+ /** Damping while the suspension compresses. */
172
+ readonly dampingCompression: number;
173
+ /** Damping while the suspension extends. */
174
+ readonly dampingRelaxation: number;
175
+ /** How hard this tyre grips; a higher value brakes harder and flips the car more easily. */
176
+ readonly wheelFrictionSlip: number;
177
+ /** Maximum travel either side of the rest length, in metres. */
178
+ readonly maxSuspensionTravel?: number;
179
+ readonly useAsSteering: boolean;
180
+ readonly useAsTraction: boolean;
181
+ }
182
+ interface IPhysicsVehicleCreateOptions {
183
+ /** The chassis body the wheels hang from; it must be dynamic. */
184
+ readonly bodyId: number;
185
+ /** Chassis-local forward axis: `0` = x, `2` = z. */
186
+ readonly forwardAxis: 0 | 2;
187
+ /**
188
+ * The wheels' axle, chassis-local. The vehicle's forward is `up × axle`, so its sign decides
189
+ * which way a positive `engineForce` drives and which way a positive `speed` means.
190
+ */
191
+ readonly axle: IPhysicsVector3;
192
+ readonly wheels: readonly IPhysicsVehicleWheelOptions[];
193
+ }
194
+ interface IPhysicsVehicleInput {
195
+ /** Newtons per traction wheel. */
196
+ readonly engineForce: number;
197
+ /** Braking impulse per wheel. */
198
+ readonly brake: number;
199
+ /** Steering angle in radians, on steering wheels only. */
200
+ readonly steering: number;
201
+ }
202
+ /**
203
+ * Reflects the most recently completed step, and reuses one record per vehicle, so the next call
204
+ * overwrites the object it returned. Read it in the same tick, or copy the fields out before the
205
+ * step advances.
206
+ */
207
+ interface IPhysicsVehicleState {
208
+ /** Signed metres per second along the chassis forward axis. */
209
+ speed: number;
210
+ /** Reused flat per-wheel records; see `PHYSICS_VEHICLE_WHEEL_STRIDE`. */
211
+ readonly wheels: Float32Array;
212
+ }
157
213
  interface IPhysicsInputSnapshot {
158
214
  /** One eight-float record per kinematic body. The buffer is caller-owned and reusable. */
159
215
  readonly kinematicTransforms: Readonly<Float32Array>;
@@ -214,6 +270,39 @@ interface IPhysicsSimulation {
214
270
  * the same tick, or copy the fields out before the step advances.
215
271
  */
216
272
  areaIntersections?(id: number): ReadonlySet<number>;
273
+ /**
274
+ * Persistent solved contacts between one target collider and a set of candidate colliders.
275
+ *
276
+ * Collision start/stop events say a pair began touching; they carry no point, normal or load,
277
+ * so a contact that persists cannot be observed through them. This reads the narrow phase's
278
+ * solved manifolds directly, which is what a deformation or support consumer needs.
279
+ *
280
+ * One `PHYSICS_CONTACT_STRIDE` record per solved manifold, written from index 0. Returns the
281
+ * total record count; when that exceeds the buffer's capacity only the first records were
282
+ * written, and the caller must grow the buffer and read again before the next step. A sleeping
283
+ * body was not solved and reports nothing. Optional: a backend with no narrow-phase access
284
+ * omits it, and a caller that needs contacts must fail closed instead of assuming support.
285
+ */
286
+ readContacts?(target: IPhysicsColliderHandle, colliders: Uint32Array, buffer: Float32Array): number;
287
+ /**
288
+ * Replace a collider's shape in place, keeping its handle, owning body, filters and scene
289
+ * cleanup. Recreating a collider instead leaves every recorded identity stale. Bodies sleeping
290
+ * on the old shape must wake, since the new one may no longer support them.
291
+ */
292
+ setColliderShape?(collider: IPhysicsColliderHandle, shape: IPhysicsShapeDescriptor): void;
293
+ /**
294
+ * Attach ray-cast wheels to a dynamic chassis. A vehicle lives and dies with its body, so
295
+ * `removeBody()` releases its controller; there is no separate vehicle removal call.
296
+ *
297
+ * Optional because a backend that cannot honour it must fail loudly at construction rather than
298
+ * simulate a car that is not there. `VehicleBody3D` throws `TN_VEHICLE_NATIVE_UNAVAILABLE` when
299
+ * these are absent.
300
+ */
301
+ createVehicle?(options: IPhysicsVehicleCreateOptions): number;
302
+ setVehicleInput?(id: number, input: IPhysicsVehicleInput): void;
303
+ readVehicleState?(id: number): IPhysicsVehicleState | undefined;
304
+ /** Cold-path respawn: move the chassis, drop both velocities, and face the given yaw in radians. */
305
+ resetVehicle?(id: number, position: IPhysicsVector3, yaw: number): void;
217
306
  drainCollisionEvents(buffer: Uint32Array): number;
218
307
  dispose(): void;
219
308
  }
@@ -297,6 +386,9 @@ declare class RigidBody3D {
297
386
  /** The effective continuous-collision setting; dynamic defaults true, fixed and kinematic are always false. */
298
387
  readonly continuousCollision: boolean;
299
388
  buoyancy: Buoyancy3D | undefined;
389
+ /** Draw between solved ticks; false presents this body at its true tick pose. */
390
+ get interpolate(): boolean;
391
+ set interpolate(enabled: boolean);
300
392
  constructor(options: IRigidBody3DOptions);
301
393
  get physics(): IPhysicsContext | undefined;
302
394
  /** Called by the shared plugin before a bulk step. */
@@ -307,6 +399,9 @@ declare class RigidBody3D {
307
399
  readonly y: number;
308
400
  readonly z: number;
309
401
  };
402
+ /** Assign a world position to teleport; mutate object.position for ordinary kinematic motion. */
403
+ get position(): Pick<Vector3, "x" | "y" | "z">;
404
+ set position(position: Pick<Vector3, "x" | "y" | "z">);
310
405
  syncToPhysics(): void;
311
406
  /**
312
407
  * Godot's `apply_impulse`. The one-shot shove: a thrown crate, a jump pad, a hit reaction.
@@ -470,6 +565,9 @@ declare class CharacterBody3D {
470
565
  groundBody: IPhysicsBodyHandle | undefined;
471
566
  /** Radians between `groundNormal` and world up (+Y). */
472
567
  slopeAngle: number;
568
+ /** Draw between solved ticks; false presents this body at its true tick pose. */
569
+ get interpolate(): boolean;
570
+ set interpolate(enabled: boolean);
473
571
  constructor(options: ICharacterBody3DOptions);
474
572
  move(desiredTranslation: Pick<Vector3, "x" | "y" | "z">): void;
475
573
  /**
@@ -626,6 +724,7 @@ type NavigationPlugin = IGamePluginHooks<Record<string, unknown>, IPhysicsContex
626
724
  * @situation NPC patrols a level and chases a player
627
725
  * @constraint requires rapier() earlier in the plugins array
628
726
  * @example const game = defineGame({ plugins: [rapier(), recast()] });
727
+ * @requires npm i @threenative/physics
629
728
  */
630
729
  declare function recast(): NavigationPlugin;
631
730
 
@@ -660,6 +759,9 @@ interface IPhysicsContext {
660
759
  readonly simulation: IPhysicsSimulation;
661
760
  readonly directSpaceState: PhysicsDirectSpaceState3D;
662
761
  navigation?: INavigationContext;
762
+ /** Engine-owned draw history; optional for standalone physics contexts. */
763
+ resetInterpolation?(object: Object3D): void;
764
+ updateInterpolation?(body: PhysicsBody3D): void;
663
765
  add(body: PhysicsBody3D): void;
664
766
  numBodies(): number;
665
767
  kinematicMotion?(colliderHandle: number): {
@@ -716,4 +818,4 @@ declare class Area3D {
716
818
  dispose(): void;
717
819
  }
718
820
 
719
- export { type ICharacterBody3DOptions as $, Area3D as A, Buoyancy3D as B, CharacterBody3D as C, type IPhysicsShapeDescriptor as D, type IPhysicsShapeQuery as E, type IPhysicsSimulation as F, type IPointHit as G, type IRayHit as H, type IPhysicsContext as I, type IRigidBody3DOptions as J, type IShapeHit as K, PHYSICS_TRANSFORM_STRIDE as L, MAX_PHYSICS_QUERY_RESULTS as M, type PhysicsBody3D as N, PhysicsDirectSpaceState3D as O, PHYSICS_COLLISION_EVENT_STRIDE as P, type PhysicsJointKind as Q, RigidBody3D as R, type PhysicsQueryVector3 as S, type PhysicsShapeKind as T, type RigidBodyType as U, rapier as V, type AreaEvent as W, type AreaHandler as X, type CollisionShapeKind as Y, type IArea3DOptions as Z, type IAreaContact as _, type IPhysicsWorldHandle as a, type IPhysicsOptions as a0, type PhysicsPlugin as a1, type INavigationAgent3DOptions as a2, type INavigationContext as a3, type INavigationObstacle3DOptions as a4, type INavigationRegion3DOptions as a5, NavigationAgent3D as a6, type NavigationAgentEvent as a7, type NavigationAgentHandler as a8, NavigationObstacle3D as a9, type NavigationPlugin as aa, NavigationRegion3D as ab, recast as ac, type IPhysicsBodyHandle as b, type IPhysicsVector3 as c, type IPhysicsRotation as d, type IPhysicsJointLimit as e, type BuoyancyPointPosition as f, CollisionShape3D as g, type IBuoyancy3DOptions as h, type IBuoyancyHullPoint as i, type IBuoyancySurface as j, type IBuoyancySurfaceSample as k, type ICollisionShapeHandle as l, type IIntersectPointOptions as m, type IIntersectRayOptions as n, type IIntersectShapeOptions as o, type IPhysicsBodyCreateOptions as p, type IPhysicsCharacterOptions as q, type IPhysicsColliderHandle as r, type IPhysicsHandle as s, type IPhysicsInputSnapshot as t, type IPhysicsJointCreateOptions as u, type IPhysicsPointQuery as v, type IPhysicsQueryHit as w, type IPhysicsRayHit as x, type IPhysicsRayQuery as y, type IPhysicsRuntimeSimulation as z };
821
+ export { type AreaEvent as $, Area3D as A, Buoyancy3D as B, CollisionShape3D as C, type IPhysicsRuntimeSimulation as D, type IPhysicsShapeDescriptor as E, type IPhysicsShapeQuery as F, type IPhysicsSimulation as G, type IPhysicsVehicleCreateOptions as H, type IPhysicsContext as I, type IPhysicsVehicleInput as J, type IPhysicsVehicleState as K, type IPointHit as L, type IRayHit as M, type IRigidBody3DOptions as N, type IShapeHit as O, type PhysicsBody3D as P, MAX_PHYSICS_QUERY_RESULTS as Q, RigidBody3D as R, PHYSICS_COLLISION_EVENT_STRIDE as S, PHYSICS_TRANSFORM_STRIDE as T, PHYSICS_VEHICLE_WHEEL_STRIDE as U, PhysicsDirectSpaceState3D as V, type PhysicsJointKind as W, type PhysicsQueryVector3 as X, type PhysicsShapeKind as Y, type RigidBodyType as Z, rapier as _, type IPhysicsWorldHandle as a, type AreaHandler as a0, type CollisionShapeKind as a1, type IArea3DOptions as a2, type IAreaContact as a3, type ICharacterBody3DOptions as a4, type IPhysicsOptions as a5, type PhysicsPlugin as a6, type INavigationAgent3DOptions as a7, type INavigationContext as a8, type INavigationObstacle3DOptions as a9, type INavigationRegion3DOptions as aa, NavigationAgent3D as ab, type NavigationAgentEvent as ac, type NavigationAgentHandler as ad, NavigationObstacle3D as ae, type NavigationPlugin as af, NavigationRegion3D as ag, recast as ah, type IPhysicsBodyHandle as b, type IPhysicsVector3 as c, type IPhysicsRotation as d, type IPhysicsJointLimit as e, type IPhysicsColliderHandle as f, type IPhysicsVehicleWheelOptions as g, type BuoyancyPointPosition as h, CharacterBody3D as i, type IBuoyancy3DOptions as j, type IBuoyancyHullPoint as k, type IBuoyancySurface as l, type IBuoyancySurfaceSample as m, type ICollisionShapeHandle as n, type IIntersectPointOptions as o, type IIntersectRayOptions as p, type IIntersectShapeOptions as q, type IPhysicsBodyCreateOptions as r, type IPhysicsCharacterOptions as s, type IPhysicsHandle as t, type IPhysicsInputSnapshot as u, type IPhysicsJointCreateOptions as v, type IPhysicsPointQuery as w, type IPhysicsQueryHit as x, type IPhysicsRayHit as y, type IPhysicsRayQuery as z };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { I as IPhysicsContext, a as IPhysicsWorldHandle, b as IPhysicsBodyHandle, c as IPhysicsVector3, d as IPhysicsRotation, e as IPhysicsJointLimit, R as RigidBody3D } from './Area3D-BQDiAwQb.js';
2
- export { A as Area3D, B as Buoyancy3D, f as BuoyancyPointPosition, C as CharacterBody3D, g as CollisionShape3D, h as IBuoyancy3DOptions, i as IBuoyancyHullPoint, j as IBuoyancySurface, k as IBuoyancySurfaceSample, l as ICollisionShapeHandle, m as IIntersectPointOptions, n as IIntersectRayOptions, o as IIntersectShapeOptions, p as IPhysicsBodyCreateOptions, q as IPhysicsCharacterOptions, r as IPhysicsColliderHandle, s as IPhysicsHandle, t as IPhysicsInputSnapshot, u as IPhysicsJointCreateOptions, v as IPhysicsPointQuery, w as IPhysicsQueryHit, x as IPhysicsRayHit, y as IPhysicsRayQuery, z as IPhysicsRuntimeSimulation, D as IPhysicsShapeDescriptor, E as IPhysicsShapeQuery, F as IPhysicsSimulation, G as IPointHit, H as IRayHit, J as IRigidBody3DOptions, K as IShapeHit, M as MAX_PHYSICS_QUERY_RESULTS, P as PHYSICS_COLLISION_EVENT_STRIDE, L as PHYSICS_TRANSFORM_STRIDE, N as PhysicsBody3D, O as PhysicsDirectSpaceState3D, Q as PhysicsJointKind, S as PhysicsQueryVector3, T as PhysicsShapeKind, U as RigidBodyType, V as rapier } from './Area3D-BQDiAwQb.js';
1
+ import { I as IPhysicsContext, a as IPhysicsWorldHandle, b as IPhysicsBodyHandle, c as IPhysicsVector3, d as IPhysicsRotation, e as IPhysicsJointLimit, R as RigidBody3D, f as IPhysicsColliderHandle, P as PhysicsBody3D, C as CollisionShape3D, g as IPhysicsVehicleWheelOptions } from './Area3D-vbmjpxsN.js';
2
+ export { A as Area3D, B as Buoyancy3D, h as BuoyancyPointPosition, i as CharacterBody3D, j as IBuoyancy3DOptions, k as IBuoyancyHullPoint, l as IBuoyancySurface, m as IBuoyancySurfaceSample, n as ICollisionShapeHandle, o as IIntersectPointOptions, p as IIntersectRayOptions, q as IIntersectShapeOptions, r as IPhysicsBodyCreateOptions, s as IPhysicsCharacterOptions, t as IPhysicsHandle, u as IPhysicsInputSnapshot, v as IPhysicsJointCreateOptions, w as IPhysicsPointQuery, x as IPhysicsQueryHit, y as IPhysicsRayHit, z as IPhysicsRayQuery, D as IPhysicsRuntimeSimulation, E as IPhysicsShapeDescriptor, F as IPhysicsShapeQuery, G as IPhysicsSimulation, H as IPhysicsVehicleCreateOptions, J as IPhysicsVehicleInput, K as IPhysicsVehicleState, L as IPointHit, M as IRayHit, N as IRigidBody3DOptions, O as IShapeHit, Q as MAX_PHYSICS_QUERY_RESULTS, S as PHYSICS_COLLISION_EVENT_STRIDE, T as PHYSICS_TRANSFORM_STRIDE, U as PHYSICS_VEHICLE_WHEEL_STRIDE, V as PhysicsDirectSpaceState3D, W as PhysicsJointKind, X as PhysicsQueryVector3, Y as PhysicsShapeKind, Z as RigidBodyType, _ as rapier } from './Area3D-vbmjpxsN.js';
3
3
  import { Object3D } from 'three';
4
4
  import { ISoftBodyCollision } from '@threenative/core';
5
+ import { ISnowFootprint, SnowField } from '@threenative/core/world';
5
6
  import 'recast-navigation';
6
7
 
7
8
  /** A body handle or a shared physics node exposing one. */
@@ -72,7 +73,201 @@ declare function buildStaticColliders(context: IStaticColliderContext, root: Obj
72
73
  /** Adapt existing physics bodies into `SoftBody3D` collision input without a second shape API. */
73
74
  declare function softBodyCollision(...bodies: readonly RigidBody3D[]): ISoftBodyCollision;
74
75
 
76
+ /**
77
+ * A stadium contact: a rectangle of half-length `halfHeight` and half-width `radius`, capped by
78
+ * two half-discs of `radius`. The shape a capsule lies on, so a knocked-over body sinks along a
79
+ * line instead of at a point. Coverage is full across the body's own width and fades just
80
+ * outside it, so the body's edge never rests on a half-pressed rim; the bank rises beyond that.
81
+ * @situation let a fallen capsule, limb or barrel leave a linear imprint in snow
82
+ * @situation give a capsule a shape-appropriate snow contact instead of a sphere's dot
83
+ * @constraint radius and halfHeight are metres and never grow with load
84
+ * @example const footprint = capsuleFootprint(0.5, 0.2);
85
+ * @requires npm i @threenative/physics
86
+ */
87
+ declare function capsuleFootprint(halfHeight: number, radius: number): ISnowFootprint;
88
+ /**
89
+ * A rectangular contact: the face a box rests on, in the contact's own frame. Coverage is full
90
+ * across the face and fades just outside it; the bank rises beyond that.
91
+ * @situation let a crate, platform or plank press a rectangular pit into snow
92
+ * @situation imprint a box's own footprint rather than a circle around it
93
+ * @constraint halfWidth and halfDepth are metres; rotation comes from the contact, not the footprint
94
+ * @example const footprint = boxFootprint(0.4, 0.25);
95
+ * @requires npm i @threenative/physics
96
+ */
97
+ declare function boxFootprint(halfWidth: number, halfDepth: number): ISnowFootprint;
98
+ interface ISnowPhysicsOptions {
99
+ /** The physics context whose solved steps drive the deformation. */
100
+ readonly physics: IPhysicsContext;
101
+ /** The snow surface these bodies deform. */
102
+ readonly snow: SnowField;
103
+ /** Bodies to watch from the start. Register more later with `add`. */
104
+ readonly bodies?: readonly PhysicsBody3D[];
105
+ /** Collision layer of the generated snow surface collider. Default 1. */
106
+ readonly collisionLayer?: number;
107
+ /** Collision mask of the generated snow surface collider. Default 0xffff. */
108
+ readonly collisionMask?: number;
109
+ /** Multiplier turning a solved contact impulse into load. Default 1. */
110
+ readonly loadScale?: number;
111
+ /** Smallest contact-normal height that counts as support. Default 0.35. */
112
+ readonly supportNormal?: number;
113
+ /**
114
+ * Largest gap, in metres, the live collider may keep from the canonical surface before it is
115
+ * rebuilt. Default 0.0005. A resting body's print converges geometrically, so rebuilding on
116
+ * every sub-millimetre change would wake it every step and it would never sleep.
117
+ */
118
+ readonly colliderTolerance?: number;
119
+ /** Snowfall deposition in metres per second, forwarded to `SnowField.recover`. Default 0. */
120
+ readonly deposition?: number;
121
+ /** Wind erosion rate, forwarded to `SnowField.recover`. Default 0. */
122
+ readonly wind?: number;
123
+ }
124
+ /** What the last consumed step observed, for a registry snapshot or a playtest probe. */
125
+ interface ISnowPhysicsObservation {
126
+ /** Solved snow-contact manifolds read in the most recent step. */
127
+ readonly contacts: number;
128
+ /** Bodies whose supported, downward-loaded contacts pressed the snow in that step. */
129
+ readonly supported: number;
130
+ /** Summed load those bodies pressed with, in newtons. */
131
+ readonly load: number;
132
+ /** How `load` was obtained. It is estimated from solver impulses, never measured. */
133
+ readonly loadProvenance: "solver-impulse-per-step";
134
+ /** Canonical snow surface version. */
135
+ readonly version: number;
136
+ /** Canonical version the live collider was last reconciled with. */
137
+ readonly colliderVersion: number;
138
+ /** Largest gap between the collider's source samples and the canonical surface, in metres. */
139
+ readonly colliderError: number;
140
+ }
141
+ interface ISnowPhysicsBinding {
142
+ /** The generated snow surface collider. Its identity survives every deformation. */
143
+ readonly surface: IPhysicsColliderHandle;
144
+ /** Canonical surface version the live collider was last reconciled with. */
145
+ readonly surfaceVersion: number;
146
+ /** Solved contact manifolds read in the most recent step. */
147
+ readonly contacts: number;
148
+ /** Bodies that pressed the snow in the most recent step. */
149
+ readonly supported: number;
150
+ /** Snow surface version at the last step this binding ran. */
151
+ readonly version: number;
152
+ /** Live snowfall deposition in metres per second; checked at the next step. */
153
+ deposition: number;
154
+ /** Live wind erosion rate; checked at the next step. */
155
+ wind: number;
156
+ add(body: PhysicsBody3D, footprint?: ISnowFootprint): void;
157
+ remove(body: PhysicsBody3D): void;
158
+ /** Load one watched body pressed into the snow in the last step, newtons; 0 when airborne. */
159
+ loadOf(body: PhysicsBody3D): number;
160
+ /**
161
+ * Consume one solved step: read contacts, deform the snow, let it recover, then publish the
162
+ * changed surface to collision. Call it once per fixed step, after the physics step and before
163
+ * the next one.
164
+ */
165
+ step(deltaTime: number): void;
166
+ /** The last step's observation, with the collider measured against the canonical surface. */
167
+ observe(): ISnowPhysicsObservation;
168
+ /** Idempotent cleanup: removes the surface body and forgets every watched body. */
169
+ dispose(): void;
170
+ }
171
+ /**
172
+ * Drive a `SnowField` from real solved contacts.
173
+ *
174
+ * The binding creates the snow surface collider from the field's own canonical samples and keeps
175
+ * it in step with them, so a body lands on the surface a query would report. Each fixed step it
176
+ * reads the solver's persistent contacts — not collision start/stop events, which carry no point
177
+ * or load — deforms the snow only where a contact is supported and loaded downward, then
178
+ * republishes the surface before the next step. Airborne bodies, side contacts and unrelated
179
+ * colliders never deform anything.
180
+ *
181
+ * A dropped sphere settles on the surface it made; a pushed one rotates and carves a connected
182
+ * track without its transform being copied anywhere. Footprints come from the body's own
183
+ * collision shape and orientation unless the game supplies one.
184
+ *
185
+ * Contact load is `impulse / deltaTime * loadScale`: a solver impulse over a step, which
186
+ * estimates a contact force and is not measured. `observe().loadProvenance` says so.
187
+ * @situation leave footprints and tracks where physical bodies actually touch snow
188
+ * @situation let a dropped or pushed sphere carve and settle into deformable snow
189
+ * @situation make a crate, capsule or ball compress the surface it rests on
190
+ * @constraint register `rapier()` before attaching, and call `step` once per fixed step after the physics step
191
+ * @constraint the backend must expose persistent solved contacts and in-place shape refresh; one that does not fails at attach
192
+ * @constraint verified on browser WebGPU and the native Linux desktop host; Android and iOS share the native seam but have not run it
193
+ * @constraint automatic profiles cover sphere, box and capsule; any other shape needs an explicit footprint
194
+ * @override loadScale, supportNormal, colliderTolerance, deposition, wind, collisionLayer and collisionMask name the binding's own behaviour
195
+ * @requires @threenative/core/world SnowField as the surface it deforms
196
+ * @example const snowPhysics = attachSnowPhysics({ physics: ctx.physics, snow, bodies: [ball] });
197
+ * afterPhysics(ctx, (dt) => snowPhysics.step(dt));
198
+ */
199
+ declare function attachSnowPhysics(options: ISnowPhysicsOptions): ISnowPhysicsBinding;
200
+
75
201
  /** Rapier packs membership in the high 16 bits and the filter in the low 16. */
76
202
  declare function interactionGroups(layer: number, mask: number): number;
77
203
 
78
- export { type IBuildStaticCollidersOptions, type IFixedJoint3DOptions, type IHingeJoint3DOptions, type IJoint3DOptions, IPhysicsBodyHandle, IPhysicsContext, IPhysicsJointLimit, IPhysicsRotation, IPhysicsVector3, IPhysicsWorldHandle, type IPinJoint3DOptions, type IStaticColliderContext, Joint3D, type PhysicsJointBody, RigidBody3D, type StaticColliderPredicate, buildStaticColliders, interactionGroups, softBodyCollision };
204
+ /** Godot's `VehicleWheel3D`, one entry of `IVehicleBody3DOptions.wheels`. */
205
+ type IVehicleWheel3D = IPhysicsVehicleWheelOptions;
206
+ /**
207
+ * Which chassis-local axis the car drives along, and which way `engineForce` pushes it. `-z` is the
208
+ * default because that is the direction a Three.js object faces.
209
+ */
210
+ type VehicleForwardAxis = "-x" | "-z" | "x" | "z";
211
+ interface IVehicleBody3DOptions {
212
+ /** The visual root the body drives; its position and quaternion are written back every step. */
213
+ readonly object: Object3D;
214
+ readonly entity?: string;
215
+ readonly physics?: IPhysicsContext;
216
+ /** @deprecated Prefer `physics`; a raw web world is backend-specific. */
217
+ readonly world?: IPhysicsWorldHandle | unknown;
218
+ /** The chassis collider, and the only shape the wheels are not tested against. */
219
+ readonly shape: CollisionShape3D;
220
+ /** Chassis mass in kg. Default 0, which Rapier fills in from the collider. */
221
+ readonly mass?: number;
222
+ readonly forwardAxis?: VehicleForwardAxis;
223
+ readonly wheels: readonly IVehicleWheel3D[];
224
+ /** Godot's collision_layer — which layers the chassis occupies. Default 1. */
225
+ readonly collisionLayer?: number;
226
+ /** Godot's collision_mask — which layers the chassis and its wheel rays scan. Default 0xffff. */
227
+ readonly collisionMask?: number;
228
+ }
229
+ /**
230
+ * Godot's `VehicleBody3D`: a dynamic chassis carried on ray-cast wheels with a real suspension.
231
+ *
232
+ * It is a `RigidBody3D` — the chassis collider, mass, transform sync and `dispose()` are the ones
233
+ * that class already has — plus the wheel controller, which is why a vehicle's lifetime is its
234
+ * body's lifetime and there is no separate removal call.
235
+ */
236
+ declare class VehicleBody3D extends RigidBody3D {
237
+ #private;
238
+ /** A vehicle always drives an object; the base type only allows one for fixed bodies. */
239
+ readonly object: Object3D;
240
+ readonly wheels: readonly IVehicleWheel3D[];
241
+ constructor(options: IVehicleBody3DOptions);
242
+ /**
243
+ * Godot's `engine_force`, in newtons. Every wheel with `useAsTraction` receives the full value,
244
+ * so two driven wheels are twice the force. Negative is reverse.
245
+ */
246
+ get engineForce(): number;
247
+ set engineForce(value: number);
248
+ /** Godot's `brake`, applied to every wheel. It is a braking impulse, not a force. */
249
+ get brake(): number;
250
+ set brake(value: number);
251
+ /** Godot's `steering`, in radians, applied to every wheel with `useAsSteering`. */
252
+ get steering(): number;
253
+ set steering(value: number);
254
+ /**
255
+ * Signed metres per second along `forwardAxis`: positive while accelerating forward. It reflects
256
+ * the last completed step, so read it after the physics update.
257
+ */
258
+ get speed(): number;
259
+ /** Whether this wheel's suspension ray found ground on the last completed step. */
260
+ wheelContact(index: number): boolean;
261
+ /** How far the wheel hangs below its attachment point, in metres. Below the rest length while loaded. */
262
+ wheelSuspensionLength(index: number): number;
263
+ /** The wheel's spin angle in radians, for animating the mesh. */
264
+ wheelRotation(index: number): number;
265
+ /**
266
+ * Respawn: move the chassis, face `yaw` radians, and drop both velocities. Wheels keep their
267
+ * cached spin, so the first frame after a rescue is one frame of stale wheel animation.
268
+ */
269
+ teleport(position: Pick<Object3D["position"], "x" | "y" | "z">, yaw: number): void;
270
+ dispose(): void;
271
+ }
272
+
273
+ export { CollisionShape3D, type IBuildStaticCollidersOptions, type IFixedJoint3DOptions, type IHingeJoint3DOptions, type IJoint3DOptions, IPhysicsBodyHandle, IPhysicsColliderHandle, IPhysicsContext, IPhysicsJointLimit, IPhysicsRotation, IPhysicsVector3, IPhysicsWorldHandle, type IPinJoint3DOptions, type ISnowPhysicsBinding, type ISnowPhysicsObservation, type ISnowPhysicsOptions, type IStaticColliderContext, type IVehicleBody3DOptions, type IVehicleWheel3D, Joint3D, PhysicsBody3D, type PhysicsJointBody, RigidBody3D, type StaticColliderPredicate, VehicleBody3D, type VehicleForwardAxis, attachSnowPhysics, boxFootprint, buildStaticColliders, capsuleFootprint, interactionGroups, softBodyCollision };