@threenative/physics 0.2.1 → 0.3.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/LICENSE +21 -0
- package/README.md +2 -2
- package/dist/{Area3D-CvwDbfU6.d.ts → Area3D-CnqoAfEr.d.ts} +205 -69
- package/dist/index.d.ts +45 -3
- package/dist/index.js +775 -172
- package/dist/native/index.d.ts +2 -2
- package/dist/native/index.js +720 -134
- package/dist/navigation/index.d.ts +1 -1
- package/dist/navigation/index.js +201 -4678
- package/package.json +8 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 João Paulo Furtado
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@ Godot-shaped physics nodes backed by Rapier: `RigidBody3D`, `Area3D`,
|
|
|
5
5
|
|
|
6
6
|
## Backend portability
|
|
7
7
|
|
|
8
|
-
Browser
|
|
8
|
+
Browser builds use Rapier WASM `0.19.3`. Native desktop, Android, and iOS builds select the
|
|
9
9
|
ThreeNative runtime's native Rapier `0.30.0` adapter through the `threenative-native` export
|
|
10
10
|
condition. Physics replays and snapshots are repeatable only within the exact pinned runtime
|
|
11
|
-
that recorded them; they are not portable between web
|
|
11
|
+
that recorded them; they are not portable between web and native builds,
|
|
12
12
|
Rapier versions, operating systems, or architectures.
|
|
13
13
|
|
|
14
14
|
`world.raw`, `body.raw`, `collider.raw`, and `CollisionShape3D.raw` are backend-specific.
|
|
@@ -83,6 +83,23 @@ interface IPhysicsRotation {
|
|
|
83
83
|
readonly z: number;
|
|
84
84
|
readonly w: number;
|
|
85
85
|
}
|
|
86
|
+
type PhysicsJointKind = "pin" | "hinge" | "fixed";
|
|
87
|
+
interface IPhysicsJointLimit {
|
|
88
|
+
readonly lower: number;
|
|
89
|
+
readonly upper: number;
|
|
90
|
+
}
|
|
91
|
+
/** Backend-neutral data for a cold-path joint creation call. Anchors and frames are local-space. */
|
|
92
|
+
interface IPhysicsJointCreateOptions {
|
|
93
|
+
readonly type: PhysicsJointKind;
|
|
94
|
+
readonly bodyA: number;
|
|
95
|
+
readonly bodyB: number;
|
|
96
|
+
readonly anchorA: IPhysicsVector3;
|
|
97
|
+
readonly anchorB: IPhysicsVector3;
|
|
98
|
+
readonly axis?: IPhysicsVector3;
|
|
99
|
+
readonly limit?: IPhysicsJointLimit;
|
|
100
|
+
readonly frameA?: IPhysicsRotation;
|
|
101
|
+
readonly frameB?: IPhysicsRotation;
|
|
102
|
+
}
|
|
86
103
|
interface IPhysicsRayQuery {
|
|
87
104
|
readonly from: IPhysicsVector3;
|
|
88
105
|
readonly to: IPhysicsVector3;
|
|
@@ -131,7 +148,9 @@ interface IPhysicsCharacterOptions {
|
|
|
131
148
|
}
|
|
132
149
|
interface IPhysicsCharacterState {
|
|
133
150
|
readonly grounded: boolean;
|
|
151
|
+
readonly groundBody?: IPhysicsBodyHandle;
|
|
134
152
|
readonly groundCollider?: number;
|
|
153
|
+
readonly groundNormal?: IPhysicsVector3;
|
|
135
154
|
}
|
|
136
155
|
interface IPhysicsInputSnapshot {
|
|
137
156
|
/** One eight-float record per kinematic body. The buffer is caller-owned and reusable. */
|
|
@@ -141,8 +160,10 @@ interface IPhysicsInputSnapshot {
|
|
|
141
160
|
/** The backend seam used by all shared physics nodes. */
|
|
142
161
|
interface IPhysicsSimulation {
|
|
143
162
|
createBody(options: IPhysicsBodyCreateOptions): IPhysicsBodyRegistration;
|
|
163
|
+
createJoint(options: IPhysicsJointCreateOptions): number;
|
|
144
164
|
configureCharacter(id: number, options: IPhysicsCharacterOptions): void;
|
|
145
165
|
removeBody(id: number): void;
|
|
166
|
+
removeJoint(id: number): void;
|
|
146
167
|
/** Cold-path repositioning for teleport/setup. Per-frame kinematics use `step()` input. */
|
|
147
168
|
setBodyTransform(id: number, position: {
|
|
148
169
|
readonly x: number;
|
|
@@ -155,6 +176,7 @@ interface IPhysicsSimulation {
|
|
|
155
176
|
*/
|
|
156
177
|
applyBodyImpulse(id: number, impulse: IPhysicsVector3): void;
|
|
157
178
|
applyBodyForce(id: number, force: IPhysicsVector3): void;
|
|
179
|
+
applyBodyForceAtPoint(id: number, force: IPhysicsVector3, point: IPhysicsVector3): void;
|
|
158
180
|
setBodyLinearVelocity(id: number, velocity: IPhysicsVector3): void;
|
|
159
181
|
readBodyLinearVelocity(id: number): IPhysicsVector3;
|
|
160
182
|
step(deltaTime: number, inputSnapshot?: IPhysicsInputSnapshot): void;
|
|
@@ -176,9 +198,19 @@ interface IPhysicsSimulation {
|
|
|
176
198
|
readonly w: number;
|
|
177
199
|
};
|
|
178
200
|
} | undefined;
|
|
179
|
-
/**
|
|
201
|
+
/**
|
|
202
|
+
* Reflects the most recently completed step, independent of visible-transform reads.
|
|
203
|
+
*
|
|
204
|
+
* This reuses one record per character, so the next call overwrites the object it returned.
|
|
205
|
+
* Read it in the same tick, or copy the fields out before the step advances.
|
|
206
|
+
*/
|
|
180
207
|
readCharacterState?(id: number): IPhysicsCharacterState | undefined;
|
|
181
|
-
/**
|
|
208
|
+
/**
|
|
209
|
+
* Reflects the most recently completed step, independent of visible-transform reads.
|
|
210
|
+
*
|
|
211
|
+
* This reuses one set per area, so the next call overwrites the set it returned. Read it in
|
|
212
|
+
* the same tick, or copy the fields out before the step advances.
|
|
213
|
+
*/
|
|
182
214
|
areaIntersections?(id: number): ReadonlySet<number>;
|
|
183
215
|
drainCollisionEvents(buffer: Uint32Array): number;
|
|
184
216
|
dispose(): void;
|
|
@@ -231,6 +263,149 @@ declare class CollisionShape3D {
|
|
|
231
263
|
setSensor(sensor: boolean): this;
|
|
232
264
|
}
|
|
233
265
|
|
|
266
|
+
type RigidBodyType = "dynamic" | "fixed" | "kinematic";
|
|
267
|
+
interface IRigidBody3DOptions {
|
|
268
|
+
/** The transform this body drives. Omit for a fixed collider with no visual; supply `position`. */
|
|
269
|
+
readonly object?: Object3D;
|
|
270
|
+
/** Initial world position. Only for a fixed body with no `object`. */
|
|
271
|
+
readonly position?: Pick<Vector3, "x" | "y" | "z">;
|
|
272
|
+
readonly entity?: string;
|
|
273
|
+
readonly physics?: IPhysicsContext;
|
|
274
|
+
/** @deprecated Prefer `physics`; a raw web world is backend-specific. */
|
|
275
|
+
readonly world?: IPhysicsWorldHandle | unknown;
|
|
276
|
+
readonly shape: CollisionShape3D;
|
|
277
|
+
readonly mass?: number;
|
|
278
|
+
readonly type?: RigidBodyType;
|
|
279
|
+
/** Godot's collision_layer — which layers this body occupies. Default 1. */
|
|
280
|
+
readonly collisionLayer?: number;
|
|
281
|
+
/** Godot's collision_mask — which layers this body scans. Default 0xffff. */
|
|
282
|
+
readonly collisionMask?: number;
|
|
283
|
+
}
|
|
284
|
+
declare class RigidBody3D {
|
|
285
|
+
#private;
|
|
286
|
+
readonly body: IPhysicsBodyHandle;
|
|
287
|
+
readonly collider: IPhysicsColliderHandle;
|
|
288
|
+
/** The supplied transform; position-only fixed bodies have no runtime object. */
|
|
289
|
+
readonly object: Object3D | undefined;
|
|
290
|
+
readonly shape: CollisionShape3D;
|
|
291
|
+
readonly type: RigidBodyType;
|
|
292
|
+
readonly mass: number;
|
|
293
|
+
buoyancy: Buoyancy3D | undefined;
|
|
294
|
+
constructor(options: IRigidBody3DOptions);
|
|
295
|
+
get physics(): IPhysicsContext | undefined;
|
|
296
|
+
/** Called by the shared plugin before a bulk step. */
|
|
297
|
+
writeKinematic(buffer: Float32Array, offset: number): void;
|
|
298
|
+
/** Displacement since the last backend transform, used for moving-platform carry. */
|
|
299
|
+
kinematicMotion(): {
|
|
300
|
+
readonly x: number;
|
|
301
|
+
readonly y: number;
|
|
302
|
+
readonly z: number;
|
|
303
|
+
};
|
|
304
|
+
syncToPhysics(): void;
|
|
305
|
+
/**
|
|
306
|
+
* Godot's `apply_impulse`. The one-shot shove: a thrown crate, a jump pad, a hit reaction.
|
|
307
|
+
*
|
|
308
|
+
* These four members exist because there is otherwise no portable way to move a dynamic body
|
|
309
|
+
* at all. `body.raw` is a Rapier object on web and opaque on native, so reaching through it
|
|
310
|
+
* forks the game by platform, and a transform write is discarded by the next step.
|
|
311
|
+
*/
|
|
312
|
+
applyImpulse(impulse: {
|
|
313
|
+
readonly x: number;
|
|
314
|
+
readonly y: number;
|
|
315
|
+
readonly z: number;
|
|
316
|
+
}): void;
|
|
317
|
+
/** Godot's `apply_force`. Continuous push; cleared by the backend each step. */
|
|
318
|
+
applyForce(force: {
|
|
319
|
+
readonly x: number;
|
|
320
|
+
readonly y: number;
|
|
321
|
+
readonly z: number;
|
|
322
|
+
}): void;
|
|
323
|
+
/** Godot's force-at-position equivalent. Continuous push in world space; cleared each step. */
|
|
324
|
+
applyForceAtPoint(force: {
|
|
325
|
+
readonly x: number;
|
|
326
|
+
readonly y: number;
|
|
327
|
+
readonly z: number;
|
|
328
|
+
}, point: {
|
|
329
|
+
readonly x: number;
|
|
330
|
+
readonly y: number;
|
|
331
|
+
readonly z: number;
|
|
332
|
+
}): void;
|
|
333
|
+
/** Godot's `linear_velocity`. */
|
|
334
|
+
get linearVelocity(): {
|
|
335
|
+
readonly x: number;
|
|
336
|
+
readonly y: number;
|
|
337
|
+
readonly z: number;
|
|
338
|
+
};
|
|
339
|
+
set linearVelocity(velocity: {
|
|
340
|
+
readonly x: number;
|
|
341
|
+
readonly y: number;
|
|
342
|
+
readonly z: number;
|
|
343
|
+
});
|
|
344
|
+
syncFromPhysics(): void;
|
|
345
|
+
applyTransform(values: Readonly<Float32Array>, offset: number): void;
|
|
346
|
+
dispose(): void;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
interface IBuoyancySurfaceSample {
|
|
350
|
+
readonly height: number;
|
|
351
|
+
readonly normal?: {
|
|
352
|
+
readonly x: number;
|
|
353
|
+
readonly y: number;
|
|
354
|
+
readonly z: number;
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
interface IBuoyancySurface {
|
|
358
|
+
sample(x: number, z: number, time: number): IBuoyancySurfaceSample;
|
|
359
|
+
}
|
|
360
|
+
type BuoyancyPointPosition = readonly [number, number, number] | {
|
|
361
|
+
readonly x: number;
|
|
362
|
+
readonly y: number;
|
|
363
|
+
readonly z: number;
|
|
364
|
+
};
|
|
365
|
+
interface IBuoyancyHullPoint {
|
|
366
|
+
readonly position: BuoyancyPointPosition;
|
|
367
|
+
readonly volume?: number;
|
|
368
|
+
readonly spacing?: number;
|
|
369
|
+
}
|
|
370
|
+
interface IBuoyancy3DOptions {
|
|
371
|
+
readonly body: RigidBody3D;
|
|
372
|
+
readonly hullPoints: readonly IBuoyancyHullPoint[];
|
|
373
|
+
readonly surface?: IBuoyancySurface;
|
|
374
|
+
readonly heightSource?: IBuoyancySurface;
|
|
375
|
+
readonly field?: IBuoyancySurface;
|
|
376
|
+
readonly physics?: IPhysicsContext;
|
|
377
|
+
/** Fluid density in the same units as the body's mass and world gravity. */
|
|
378
|
+
readonly density?: number;
|
|
379
|
+
/** Total displaced volume when points do not carry individual volumes. */
|
|
380
|
+
readonly volume?: number;
|
|
381
|
+
/** Vertical sample span used to turn a hull point into a partial volume. */
|
|
382
|
+
readonly pointSpacing?: number;
|
|
383
|
+
/** Continuous velocity drag for the submerged volume. */
|
|
384
|
+
readonly drag?: number;
|
|
385
|
+
readonly gravity?: number;
|
|
386
|
+
/** Convention switch. Measurement continues when false. */
|
|
387
|
+
readonly buoyancy?: boolean;
|
|
388
|
+
}
|
|
389
|
+
/** Applies game-authored displaced-volume forces before the shared physics step. */
|
|
390
|
+
declare class Buoyancy3D {
|
|
391
|
+
#private;
|
|
392
|
+
readonly body: RigidBody3D;
|
|
393
|
+
readonly hullPoints: readonly IBuoyancyHullPoint[];
|
|
394
|
+
readonly density: number;
|
|
395
|
+
readonly drag: number;
|
|
396
|
+
readonly gravity: number;
|
|
397
|
+
constructor(options: IBuoyancy3DOptions);
|
|
398
|
+
get enabled(): boolean;
|
|
399
|
+
set enabled(value: boolean);
|
|
400
|
+
get buoyancy(): boolean;
|
|
401
|
+
set buoyancy(value: boolean);
|
|
402
|
+
get submergedFraction(): number;
|
|
403
|
+
get time(): number;
|
|
404
|
+
/** Called by `rapier()` immediately before its fixed-step backend call. */
|
|
405
|
+
apply(deltaTime: number): void;
|
|
406
|
+
dispose(): void;
|
|
407
|
+
}
|
|
408
|
+
|
|
234
409
|
interface ICharacterBody3DOptions {
|
|
235
410
|
readonly object: Object3D;
|
|
236
411
|
readonly entity?: string;
|
|
@@ -283,8 +458,25 @@ declare class CharacterBody3D {
|
|
|
283
458
|
maxFallSpeed: number;
|
|
284
459
|
readonly oneWayLayers: number;
|
|
285
460
|
grounded: boolean;
|
|
461
|
+
/** Contact normal from the completed physics step; reset to +Y while airborne. */
|
|
462
|
+
readonly groundNormal: Vector3;
|
|
463
|
+
/** Portable handle for the body currently supporting this character. */
|
|
464
|
+
groundBody: IPhysicsBodyHandle | undefined;
|
|
465
|
+
/** Radians between `groundNormal` and world up (+Y). */
|
|
466
|
+
slopeAngle: number;
|
|
286
467
|
constructor(options: ICharacterBody3DOptions);
|
|
287
468
|
move(desiredTranslation: Pick<Vector3, "x" | "y" | "z">): void;
|
|
469
|
+
/**
|
|
470
|
+
* Queue velocity-based motion for the shared bulk physics step.
|
|
471
|
+
*
|
|
472
|
+
* @remarks
|
|
473
|
+
* This does not move `object` synchronously. The solver writes the transform after the step, so
|
|
474
|
+
* reading `object.position` immediately after this call still observes the previous transform.
|
|
475
|
+
* Three.js `Vector3` instances are mutable, so do not retain `object.position` itself as the
|
|
476
|
+
* snapshot: use `const before = object.position.clone()` (or copy its `x`, `y`, and `z` scalars).
|
|
477
|
+
* Compare that snapshot with `object.position` only after the deferred bulk physics step,
|
|
478
|
+
* typically on the next frame, to measure the motion that the solver applied.
|
|
479
|
+
*/
|
|
288
480
|
moveAndSlide(dt: number): void;
|
|
289
481
|
/** Called by the shared plugin before a bulk step. */
|
|
290
482
|
writeKinematic(buffer: Float32Array, offset: number): void;
|
|
@@ -333,71 +525,6 @@ declare class PhysicsDirectSpaceState3D {
|
|
|
333
525
|
intersectPoint(options: IIntersectPointOptions): readonly IPointHit[];
|
|
334
526
|
}
|
|
335
527
|
|
|
336
|
-
type RigidBodyType = "dynamic" | "fixed" | "kinematic";
|
|
337
|
-
interface IRigidBody3DOptions {
|
|
338
|
-
readonly object: Object3D;
|
|
339
|
-
readonly entity?: string;
|
|
340
|
-
readonly physics?: IPhysicsContext;
|
|
341
|
-
/** @deprecated Prefer `physics`; a raw web world is backend-specific. */
|
|
342
|
-
readonly world?: IPhysicsWorldHandle | unknown;
|
|
343
|
-
readonly shape: CollisionShape3D;
|
|
344
|
-
readonly mass?: number;
|
|
345
|
-
readonly type?: RigidBodyType;
|
|
346
|
-
/** Godot's collision_layer — which layers this body occupies. Default 1. */
|
|
347
|
-
readonly collisionLayer?: number;
|
|
348
|
-
/** Godot's collision_mask — which layers this body scans. Default 0xffff. */
|
|
349
|
-
readonly collisionMask?: number;
|
|
350
|
-
}
|
|
351
|
-
declare class RigidBody3D {
|
|
352
|
-
#private;
|
|
353
|
-
readonly body: IPhysicsBodyHandle;
|
|
354
|
-
readonly collider: IPhysicsColliderHandle;
|
|
355
|
-
readonly object: Object3D;
|
|
356
|
-
readonly type: RigidBodyType;
|
|
357
|
-
constructor(options: IRigidBody3DOptions);
|
|
358
|
-
/** Called by the shared plugin before a bulk step. */
|
|
359
|
-
writeKinematic(buffer: Float32Array, offset: number): void;
|
|
360
|
-
/** Displacement since the last backend transform, used for moving-platform carry. */
|
|
361
|
-
kinematicMotion(): {
|
|
362
|
-
readonly x: number;
|
|
363
|
-
readonly y: number;
|
|
364
|
-
readonly z: number;
|
|
365
|
-
};
|
|
366
|
-
syncToPhysics(): void;
|
|
367
|
-
/**
|
|
368
|
-
* Godot's `apply_impulse`. The one-shot shove: a thrown crate, a jump pad, a hit reaction.
|
|
369
|
-
*
|
|
370
|
-
* These four members exist because there is otherwise no portable way to move a dynamic body
|
|
371
|
-
* at all. `body.raw` is a Rapier object on web and opaque on native, so reaching through it
|
|
372
|
-
* forks the game by platform, and a transform write is discarded by the next step.
|
|
373
|
-
*/
|
|
374
|
-
applyImpulse(impulse: {
|
|
375
|
-
readonly x: number;
|
|
376
|
-
readonly y: number;
|
|
377
|
-
readonly z: number;
|
|
378
|
-
}): void;
|
|
379
|
-
/** Godot's `apply_force`. Continuous push; cleared by the backend each step. */
|
|
380
|
-
applyForce(force: {
|
|
381
|
-
readonly x: number;
|
|
382
|
-
readonly y: number;
|
|
383
|
-
readonly z: number;
|
|
384
|
-
}): void;
|
|
385
|
-
/** Godot's `linear_velocity`. */
|
|
386
|
-
get linearVelocity(): {
|
|
387
|
-
readonly x: number;
|
|
388
|
-
readonly y: number;
|
|
389
|
-
readonly z: number;
|
|
390
|
-
};
|
|
391
|
-
set linearVelocity(velocity: {
|
|
392
|
-
readonly x: number;
|
|
393
|
-
readonly y: number;
|
|
394
|
-
readonly z: number;
|
|
395
|
-
});
|
|
396
|
-
syncFromPhysics(): void;
|
|
397
|
-
applyTransform(values: Readonly<Float32Array>, offset: number): void;
|
|
398
|
-
dispose(): void;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
528
|
type NavigationAgentEvent = "targetReached" | "navigationFinished" | "pathChanged";
|
|
402
529
|
type NavigationAgentHandler = () => void;
|
|
403
530
|
interface INavigationAgent3DOptions {
|
|
@@ -425,7 +552,7 @@ declare class NavigationAgent3D {
|
|
|
425
552
|
set avoidanceEnabled(value: boolean);
|
|
426
553
|
on(event: NavigationAgentEvent, handler: NavigationAgentHandler): () => void;
|
|
427
554
|
setTargetPosition(position: Pick<Vector3, "x" | "y" | "z">): void;
|
|
428
|
-
getNextPathPosition(): Vector3;
|
|
555
|
+
getNextPathPosition(target?: Vector3): Vector3;
|
|
429
556
|
isNavigationFinished(): boolean;
|
|
430
557
|
isTargetReachable(position?: Pick<Vector3, "x" | "y" | "z">): boolean;
|
|
431
558
|
getFinalPosition(): Vector3;
|
|
@@ -487,6 +614,13 @@ interface INavigationContext {
|
|
|
487
614
|
crowd?: Crowd;
|
|
488
615
|
}
|
|
489
616
|
type NavigationPlugin = IGamePluginHooks<Record<string, unknown>, IPhysicsContext>;
|
|
617
|
+
/**
|
|
618
|
+
* Install navmesh pathfinding and crowd avoidance.
|
|
619
|
+
* @situation enemy walks around a wall
|
|
620
|
+
* @situation NPC patrols a level and chases a player
|
|
621
|
+
* @constraint requires rapier() earlier in the plugins array
|
|
622
|
+
* @example const game = defineGame({ plugins: [rapier(), recast()] });
|
|
623
|
+
*/
|
|
490
624
|
declare function recast(): NavigationPlugin;
|
|
491
625
|
|
|
492
626
|
interface IPhysicsOptions {
|
|
@@ -530,6 +664,8 @@ interface IPhysicsContext {
|
|
|
530
664
|
remove(body: PhysicsBody3D): void;
|
|
531
665
|
addArea(area: Area3D): void;
|
|
532
666
|
removeArea(area: Area3D): void;
|
|
667
|
+
addBuoyancy(buoyancy: Buoyancy3D): void;
|
|
668
|
+
removeBuoyancy(buoyancy: Buoyancy3D): void;
|
|
533
669
|
}
|
|
534
670
|
type PhysicsPlugin = IGamePluginHooks<Record<string, unknown>, IPhysicsContext>;
|
|
535
671
|
declare function rapier(options?: IPhysicsOptions): PhysicsPlugin;
|
|
@@ -574,4 +710,4 @@ declare class Area3D {
|
|
|
574
710
|
dispose(): void;
|
|
575
711
|
}
|
|
576
712
|
|
|
577
|
-
export { type
|
|
713
|
+
export { type IRigidBody3DOptions 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 IShapeHit as J, PHYSICS_TRANSFORM_STRIDE as K, type PhysicsBody3D as L, MAX_PHYSICS_QUERY_RESULTS as M, PhysicsDirectSpaceState3D as N, type PhysicsJointKind as O, PHYSICS_COLLISION_EVENT_STRIDE as P, type PhysicsQueryVector3 as Q, RigidBody3D as R, type PhysicsShapeKind as S, rapier as T, type AreaEvent as U, type AreaHandler as V, type CollisionShapeKind as W, type IArea3DOptions as X, type IAreaContact as Y, type ICharacterBody3DOptions as Z, type IPhysicsOptions as _, type IPhysicsWorldHandle as a, type PhysicsPlugin as a0, type RigidBodyType 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
|
-
|
|
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-CnqoAfEr.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 IShapeHit, M as MAX_PHYSICS_QUERY_RESULTS, P as PHYSICS_COLLISION_EVENT_STRIDE, K as PHYSICS_TRANSFORM_STRIDE, L as PhysicsBody3D, N as PhysicsDirectSpaceState3D, O as PhysicsJointKind, Q as PhysicsQueryVector3, S as PhysicsShapeKind, T as rapier } from './Area3D-CnqoAfEr.js';
|
|
3
|
+
import { ISoftBodyCollision } from '@threenative/core';
|
|
2
4
|
import 'three';
|
|
3
|
-
import '@threenative/core';
|
|
4
5
|
import 'recast-navigation';
|
|
5
6
|
|
|
7
|
+
/** A body handle or a shared physics node exposing one. */
|
|
8
|
+
type PhysicsJointBody = IPhysicsBodyHandle | {
|
|
9
|
+
readonly body: IPhysicsBodyHandle;
|
|
10
|
+
};
|
|
11
|
+
interface IJoint3DOptions {
|
|
12
|
+
readonly physics?: IPhysicsContext;
|
|
13
|
+
/** @deprecated Prefer `physics`; a raw backend world is backend-specific. */
|
|
14
|
+
readonly world?: IPhysicsWorldHandle | unknown;
|
|
15
|
+
readonly bodyA: PhysicsJointBody;
|
|
16
|
+
readonly bodyB: PhysicsJointBody;
|
|
17
|
+
/** Local-space anchor on body A. Defaults to the body origin. */
|
|
18
|
+
readonly anchorA?: IPhysicsVector3;
|
|
19
|
+
/** Local-space anchor on body B. Defaults to the body origin. */
|
|
20
|
+
readonly anchorB?: IPhysicsVector3;
|
|
21
|
+
}
|
|
22
|
+
interface IPinJoint3DOptions extends IJoint3DOptions {
|
|
23
|
+
}
|
|
24
|
+
interface IHingeJoint3DOptions extends IJoint3DOptions {
|
|
25
|
+
/** Local-space axis on both bodies. Defaults to the local X axis. */
|
|
26
|
+
readonly axis?: IPhysicsVector3;
|
|
27
|
+
/** Optional lower and upper angular limits, in radians. */
|
|
28
|
+
readonly limit?: IPhysicsJointLimit;
|
|
29
|
+
}
|
|
30
|
+
interface IFixedJoint3DOptions extends IJoint3DOptions {
|
|
31
|
+
/** Optional local reference frames. Identity frames preserve equal initial orientations. */
|
|
32
|
+
readonly frameA?: IPhysicsRotation;
|
|
33
|
+
readonly frameB?: IPhysicsRotation;
|
|
34
|
+
}
|
|
35
|
+
declare class Joint3D {
|
|
36
|
+
#private;
|
|
37
|
+
readonly id: number;
|
|
38
|
+
private constructor();
|
|
39
|
+
static pin(options: IPinJoint3DOptions): Joint3D;
|
|
40
|
+
static hinge(options: IHingeJoint3DOptions): Joint3D;
|
|
41
|
+
static fixed(options: IFixedJoint3DOptions): Joint3D;
|
|
42
|
+
dispose(): void;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Adapt existing physics bodies into `SoftBody3D` collision input without a second shape API. */
|
|
46
|
+
declare function softBodyCollision(...bodies: readonly RigidBody3D[]): ISoftBodyCollision;
|
|
47
|
+
|
|
6
48
|
/** Rapier packs membership in the high 16 bits and the filter in the low 16. */
|
|
7
49
|
declare function interactionGroups(layer: number, mask: number): number;
|
|
8
50
|
|
|
9
|
-
export { interactionGroups };
|
|
51
|
+
export { type IFixedJoint3DOptions, type IHingeJoint3DOptions, type IJoint3DOptions, IPhysicsBodyHandle, IPhysicsContext, IPhysicsJointLimit, IPhysicsRotation, IPhysicsVector3, IPhysicsWorldHandle, type IPinJoint3DOptions, Joint3D, type PhysicsJointBody, RigidBody3D, interactionGroups, softBodyCollision };
|