@absolutejs/rapier3d 0.0.0-stage → 0.1.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.
Files changed (50) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +56 -2
  3. package/absolutejs/README.md +57 -0
  4. package/dist/provenance.json +10 -0
  5. package/dist/rapier.mjs +1 -0
  6. package/dist/types/coarena.d.ts +15 -0
  7. package/dist/types/control/character_controller.d.ts +191 -0
  8. package/dist/types/control/index.d.ts +3 -0
  9. package/dist/types/control/pid_controller.d.ts +50 -0
  10. package/dist/types/control/ray_cast_vehicle_controller.d.ts +277 -0
  11. package/dist/types/dynamics/ccd_solver.d.ts +15 -0
  12. package/dist/types/dynamics/coefficient_combine_rule.d.ts +13 -0
  13. package/dist/types/dynamics/impulse_joint.d.ts +359 -0
  14. package/dist/types/dynamics/impulse_joint_set.d.ts +84 -0
  15. package/dist/types/dynamics/index.d.ts +12 -0
  16. package/dist/types/dynamics/integration_parameters.d.ts +101 -0
  17. package/dist/types/dynamics/island_manager.d.ts +24 -0
  18. package/dist/types/dynamics/multibody_joint.d.ts +42 -0
  19. package/dist/types/dynamics/multibody_joint_set.d.ts +81 -0
  20. package/dist/types/dynamics/rigid_body.d.ts +839 -0
  21. package/dist/types/dynamics/rigid_body_set.d.ts +90 -0
  22. package/dist/types/dynamics/soft_body.d.ts +1210 -0
  23. package/dist/types/dynamics/soft_body_set.d.ts +99 -0
  24. package/dist/types/exports.d.ts +8 -0
  25. package/dist/types/geometry/broad_phase.d.ts +162 -0
  26. package/dist/types/geometry/collider.d.ts +1016 -0
  27. package/dist/types/geometry/collider_set.d.ts +97 -0
  28. package/dist/types/geometry/contact.d.ts +36 -0
  29. package/dist/types/geometry/feature.d.ts +6 -0
  30. package/dist/types/geometry/index.d.ts +11 -0
  31. package/dist/types/geometry/interaction_groups.d.ts +18 -0
  32. package/dist/types/geometry/narrow_phase.d.ts +140 -0
  33. package/dist/types/geometry/point.d.ts +58 -0
  34. package/dist/types/geometry/ray.d.ts +108 -0
  35. package/dist/types/geometry/shape.d.ts +681 -0
  36. package/dist/types/geometry/toi.d.ts +59 -0
  37. package/dist/types/init.d.ts +3 -0
  38. package/dist/types/math.d.ts +98 -0
  39. package/dist/types/pipeline/debug_render_pipeline.d.ts +40 -0
  40. package/dist/types/pipeline/event_queue.d.ts +113 -0
  41. package/dist/types/pipeline/index.d.ts +7 -0
  42. package/dist/types/pipeline/physics_hooks.d.ts +39 -0
  43. package/dist/types/pipeline/physics_pipeline.d.ts +12 -0
  44. package/dist/types/pipeline/query_pipeline.d.ts +38 -0
  45. package/dist/types/pipeline/serialization_pipeline.d.ts +37 -0
  46. package/dist/types/pipeline/world.d.ts +674 -0
  47. package/dist/types/rapier.d.ts +3 -0
  48. package/dist/types/rapier_wasm3d.d.ts +2908 -0
  49. package/dist/types/raw.d.ts +1 -0
  50. package/package.json +33 -4
@@ -0,0 +1,99 @@
1
+ import { RawSoftBodySet } from "../raw";
2
+ import { Vector } from "../math";
3
+ import { SoftBody, SoftBodyDesc, SoftBodyHandle, SoftBodyTearEvent } from "./soft_body";
4
+ import { RigidBodySet } from "./rigid_body_set";
5
+ import { ColliderSet } from "../geometry";
6
+ import { ImpulseJointSet } from "./impulse_joint_set";
7
+ import { MultibodyJointSet } from "./multibody_joint_set";
8
+ import { IslandManager } from "./island_manager";
9
+ /**
10
+ * A set of soft bodies that can be handled by a physics pipeline.
11
+ *
12
+ * To avoid leaking WASM resources, this MUST be freed manually with `softBodySet.free()`
13
+ * once you are done using it (and all the soft bodies it created).
14
+ */
15
+ export declare class SoftBodySet {
16
+ raw: RawSoftBodySet;
17
+ private map;
18
+ /**
19
+ * Release the WASM memory occupied by this soft-body set.
20
+ */
21
+ free(): void;
22
+ constructor(raw?: RawSoftBodySet);
23
+ /**
24
+ * Internal method, do not call this explicitly.
25
+ */
26
+ finalizeDeserialization(bodies: RigidBodySet, colliders: ColliderSet): void;
27
+ /**
28
+ * Creates a new soft body, its hidden root rigid body and its colliders, and returns it.
29
+ *
30
+ * @param bodies - The set of rigid bodies receiving the body's proxies.
31
+ * @param colliders - The set of colliders receiving the body's colliders.
32
+ * @param desc - The description of the soft body to create.
33
+ */
34
+ createSoftBody(bodies: RigidBodySet, colliders: ColliderSet, desc: SoftBodyDesc): SoftBody;
35
+ /**
36
+ * Removes a soft body from this set, with its proxies, colliders and attached joints.
37
+ */
38
+ remove(handle: SoftBodyHandle, islands: IslandManager, bodies: RigidBodySet, colliders: ColliderSet, impulseJoints: ImpulseJointSet, multibodyJoints: MultibodyJointSet): void;
39
+ /**
40
+ * Adds a cluster over the given particles: a rigid proxy that joints and colliders can
41
+ * attach to. Returns the cluster's index, or `null` if no particle was valid.
42
+ */
43
+ addCluster(handle: SoftBodyHandle, particles: Uint32Array | number[], bodies: RigidBodySet, colliders: ColliderSet): number | null;
44
+ /**
45
+ * Removes a cluster with its proxy, colliders and joints. Returns `false` if the cluster
46
+ * did not exist.
47
+ */
48
+ removeCluster(handle: SoftBodyHandle, cluster: number, islands: IslandManager, bodies: RigidBodySet, colliders: ColliderSet, impulseJoints: ImpulseJointSet, multibodyJoints: MultibodyJointSet): boolean;
49
+ /**
50
+ * Tears a soft body at once along the given edges and through the given cells, without
51
+ * removing material. Pieces disconnected by the tear become soft bodies of their own.
52
+ *
53
+ * Returns the tear event (which must be freed), or `null` when nothing changed.
54
+ */
55
+ tear(handle: SoftBodyHandle, edges: Uint32Array | number[], cells: Uint32Array | number[], islands: IslandManager, bodies: RigidBodySet, colliders: ColliderSet, impulseJoints: ImpulseJointSet, multibodyJoints: MultibodyJointSet): SoftBodyTearEvent | null;
56
+ /**
57
+ * Cuts a soft body along a blade: a segment (two points) in 2D, a triangle (three points)
58
+ * in 3D. Pieces disconnected by the cut become soft bodies of their own.
59
+ *
60
+ * Returns the tear event (which must be freed), or `null` when nothing changed.
61
+ */
62
+ cut(handle: SoftBodyHandle, blade: Vector[], islands: IslandManager, bodies: RigidBodySet, colliders: ColliderSet, impulseJoints: ImpulseJointSet, multibodyJoints: MultibodyJointSet): SoftBodyTearEvent | null;
63
+ /**
64
+ * Maps the soft bodies, proxies and colliders a topology change created, and unmaps what
65
+ * it removed.
66
+ */
67
+ private finishTopologyChange;
68
+ /**
69
+ * Wraps the soft bodies the engine created (the pieces a tear split off) that have no
70
+ * JavaScript wrapper yet; the pieces of a tear event are only reachable after this.
71
+ */
72
+ mapNewSoftBodies(bodies: RigidBodySet, colliders: ColliderSet): void;
73
+ /**
74
+ * Wakes a soft body and everything it touches up.
75
+ *
76
+ * @param strong - If `true` the bodies stay awake for a while even if they are at rest.
77
+ */
78
+ wakeUp(handle: SoftBodyHandle, bodies: RigidBodySet, strong: boolean): void;
79
+ /**
80
+ * The number of soft bodies on this set.
81
+ */
82
+ len(): number;
83
+ /**
84
+ * Does this set contain a soft body with the given handle?
85
+ */
86
+ contains(handle: SoftBodyHandle): boolean;
87
+ /**
88
+ * Gets the soft body with the given handle.
89
+ */
90
+ get(handle: SoftBodyHandle): SoftBody | null;
91
+ /**
92
+ * Applies the given closure to each soft body contained by this set.
93
+ */
94
+ forEach(f: (body: SoftBody) => void): void;
95
+ /**
96
+ * Gets all soft bodies in the list.
97
+ */
98
+ getAll(): SoftBody[];
99
+ }
@@ -0,0 +1,8 @@
1
+ export declare function version(): string;
2
+ export declare function reserveMemory(extraBytesCount: number): void;
3
+ export * from "./math";
4
+ export * from "./dynamics";
5
+ export * from "./geometry";
6
+ export * from "./pipeline";
7
+ export * from "./init";
8
+ export * from "./control";
@@ -0,0 +1,162 @@
1
+ import { RawBroadPhase } from "../raw";
2
+ import { RigidBodyHandle, RigidBodySet } from "../dynamics";
3
+ import { ColliderSet } from "./collider_set";
4
+ import { Ray, RayColliderHit, RayColliderIntersection } from "./ray";
5
+ import { InteractionGroups } from "./interaction_groups";
6
+ import { ColliderHandle } from "./collider";
7
+ import { Rotation, Vector } from "../math";
8
+ import { Shape } from "./shape";
9
+ import { PointColliderProjection } from "./point";
10
+ import { ColliderShapeCastHit } from "./toi";
11
+ import { QueryFilterFlags } from "../pipeline";
12
+ import { NarrowPhase } from "./narrow_phase";
13
+ /**
14
+ * The broad-phase used for coarse collision-detection.
15
+ *
16
+ * To avoid leaking WASM resources, this MUST be freed manually with `broadPhase.free()`
17
+ * once you are done using it.
18
+ */
19
+ export declare class BroadPhase {
20
+ raw: RawBroadPhase;
21
+ /**
22
+ * Release the WASM memory occupied by this broad-phase.
23
+ */
24
+ free(): void;
25
+ constructor(raw?: RawBroadPhase);
26
+ /**
27
+ * Find the closest intersection between a ray and a set of collider.
28
+ *
29
+ * @param colliders - The set of colliders taking part in this pipeline.
30
+ * @param ray - The ray to cast.
31
+ * @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
32
+ * limits the length of the ray to `ray.dir.norm() * maxToi`.
33
+ * @param solid - If `false` then the ray will attempt to hit the boundary of a shape, even if its
34
+ * origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain,
35
+ * whereas `false` implies that all shapes are hollow for this ray-cast.
36
+ * @param groups - Used to filter the colliders that can or cannot be hit by the ray.
37
+ * @param filter - The callback to filter out which collider will be hit.
38
+ */
39
+ castRay(narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, ray: Ray, maxToi: number, solid: boolean, filterFlags?: QueryFilterFlags, filterGroups?: InteractionGroups, filterExcludeCollider?: ColliderHandle, filterExcludeRigidBody?: RigidBodyHandle, filterPredicate?: (collider: ColliderHandle) => boolean): RayColliderHit | null;
40
+ /**
41
+ * Find the closest intersection between a ray and a set of collider.
42
+ *
43
+ * This also computes the normal at the hit point.
44
+ * @param colliders - The set of colliders taking part in this pipeline.
45
+ * @param ray - The ray to cast.
46
+ * @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
47
+ * limits the length of the ray to `ray.dir.norm() * maxToi`.
48
+ * @param solid - If `false` then the ray will attempt to hit the boundary of a shape, even if its
49
+ * origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain,
50
+ * whereas `false` implies that all shapes are hollow for this ray-cast.
51
+ * @param groups - Used to filter the colliders that can or cannot be hit by the ray.
52
+ */
53
+ castRayAndGetNormal(narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, ray: Ray, maxToi: number, solid: boolean, filterFlags?: QueryFilterFlags, filterGroups?: InteractionGroups, filterExcludeCollider?: ColliderHandle, filterExcludeRigidBody?: RigidBodyHandle, filterPredicate?: (collider: ColliderHandle) => boolean, target?: RayColliderIntersection): RayColliderIntersection | null;
54
+ /**
55
+ * Cast a ray and collects all the intersections between a ray and the scene.
56
+ *
57
+ * @param colliders - The set of colliders taking part in this pipeline.
58
+ * @param ray - The ray to cast.
59
+ * @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
60
+ * limits the length of the ray to `ray.dir.norm() * maxToi`.
61
+ * @param solid - If `false` then the ray will attempt to hit the boundary of a shape, even if its
62
+ * origin already lies inside of a shape. In other terms, `true` implies that all shapes are plain,
63
+ * whereas `false` implies that all shapes are hollow for this ray-cast.
64
+ * @param groups - Used to filter the colliders that can or cannot be hit by the ray.
65
+ * @param callback - The callback called once per hit (in no particular order) between a ray and a collider.
66
+ * If this callback returns `false`, then the cast will stop and no further hits will be detected/reported.
67
+ */
68
+ intersectionsWithRay(narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, ray: Ray, maxToi: number, solid: boolean, callback: (intersect: RayColliderIntersection) => boolean, filterFlags?: QueryFilterFlags, filterGroups?: InteractionGroups, filterExcludeCollider?: ColliderHandle, filterExcludeRigidBody?: RigidBodyHandle, filterPredicate?: (collider: ColliderHandle) => boolean): void;
69
+ /**
70
+ * Gets the handle of up to one collider intersecting the given shape.
71
+ *
72
+ * @param colliders - The set of colliders taking part in this pipeline.
73
+ * @param shapePos - The position of the shape used for the intersection test.
74
+ * @param shapeRot - The orientation of the shape used for the intersection test.
75
+ * @param shape - The shape used for the intersection test.
76
+ * @param groups - The bit groups and filter associated to the ray, in order to only
77
+ * hit the colliders with collision groups compatible with the ray's group.
78
+ */
79
+ intersectionWithShape(narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, shapePos: Vector, shapeRot: Rotation, shape: Shape, filterFlags?: QueryFilterFlags, filterGroups?: InteractionGroups, filterExcludeCollider?: ColliderHandle, filterExcludeRigidBody?: RigidBodyHandle, filterPredicate?: (collider: ColliderHandle) => boolean): ColliderHandle | null;
80
+ /**
81
+ * Find the projection of a point on the closest collider.
82
+ *
83
+ * @param colliders - The set of colliders taking part in this pipeline.
84
+ * @param point - The point to project.
85
+ * @param solid - If this is set to `true` then the collider shapes are considered to
86
+ * be plain (if the point is located inside of a plain shape, its projection is the point
87
+ * itself). If it is set to `false` the collider shapes are considered to be hollow
88
+ * (if the point is located inside of an hollow shape, it is projected on the shape's
89
+ * boundary).
90
+ * @param groups - The bit groups and filter associated to the point to project, in order to only
91
+ * project on colliders with collision groups compatible with the ray's group.
92
+ */
93
+ projectPoint(narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, point: Vector, solid: boolean, filterFlags?: QueryFilterFlags, filterGroups?: InteractionGroups, filterExcludeCollider?: ColliderHandle, filterExcludeRigidBody?: RigidBodyHandle, filterPredicate?: (collider: ColliderHandle) => boolean, target?: PointColliderProjection): PointColliderProjection | null;
94
+ /**
95
+ * Find the projection of a point on the closest collider.
96
+ *
97
+ * @param colliders - The set of colliders taking part in this pipeline.
98
+ * @param point - The point to project.
99
+ * @param groups - The bit groups and filter associated to the point to project, in order to only
100
+ * project on colliders with collision groups compatible with the ray's group.
101
+ */
102
+ projectPointAndGetFeature(narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, point: Vector, filterFlags?: QueryFilterFlags, filterGroups?: InteractionGroups, filterExcludeCollider?: ColliderHandle, filterExcludeRigidBody?: RigidBodyHandle, filterPredicate?: (collider: ColliderHandle) => boolean, target?: PointColliderProjection): PointColliderProjection | null;
103
+ /**
104
+ * Find all the colliders containing the given point.
105
+ *
106
+ * @param colliders - The set of colliders taking part in this pipeline.
107
+ * @param point - The point used for the containment test.
108
+ * @param groups - The bit groups and filter associated to the point to test, in order to only
109
+ * test on colliders with collision groups compatible with the ray's group.
110
+ * @param callback - A function called with the handles of each collider with a shape
111
+ * containing the `point`.
112
+ */
113
+ intersectionsWithPoint(narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, point: Vector, callback: (handle: ColliderHandle) => boolean, filterFlags?: QueryFilterFlags, filterGroups?: InteractionGroups, filterExcludeCollider?: ColliderHandle, filterExcludeRigidBody?: RigidBodyHandle, filterPredicate?: (collider: ColliderHandle) => boolean): void;
114
+ /**
115
+ * Casts a shape at a constant linear velocity and retrieve the first collider it hits.
116
+ * This is similar to ray-casting except that we are casting a whole shape instead of
117
+ * just a point (the ray origin).
118
+ *
119
+ * In the returned hit, `witness1` and `normal1` lie on the hit collider and are expressed in
120
+ * world-space, while `witness2` and `normal2` lie on the cast shape and are expressed in its
121
+ * local-space (relative to `shapePos` and `shapeRot`).
122
+ *
123
+ * @param colliders - The set of colliders taking part in this pipeline.
124
+ * @param shapePos - The initial position of the shape to cast.
125
+ * @param shapeRot - The initial rotation of the shape to cast.
126
+ * @param shapeVel - The constant velocity of the shape to cast (i.e. the cast direction).
127
+ * @param shape - The shape to cast.
128
+ * @param targetDistance − If the shape moves closer to this distance from a collider, a hit
129
+ * will be returned.
130
+ * @param maxToi - The maximum time-of-impact that can be reported by this cast. This effectively
131
+ * limits the distance traveled by the shape to `shapeVel.norm() * maxToi`.
132
+ * @param stopAtPenetration - If set to `false`, the linear shape-cast won’t immediately stop if
133
+ * the shape is penetrating another shape at its starting point **and** its trajectory is such
134
+ * that it’s on a path to exit that penetration state.
135
+ * @param groups - The bit groups and filter associated to the shape to cast, in order to only
136
+ * test on colliders with collision groups compatible with this group.
137
+ * @param {ColliderShapeCastHit?} target - The object to be populated. If provided,
138
+ * the function returns this object instead of creating a new one.
139
+ */
140
+ castShape(narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, shapePos: Vector, shapeRot: Rotation, shapeVel: Vector, shape: Shape, targetDistance: number, maxToi: number, stopAtPenetration: boolean, filterFlags?: QueryFilterFlags, filterGroups?: InteractionGroups, filterExcludeCollider?: ColliderHandle, filterExcludeRigidBody?: RigidBodyHandle, filterPredicate?: (collider: ColliderHandle) => boolean, target?: ColliderShapeCastHit): ColliderShapeCastHit | null;
141
+ /**
142
+ * Retrieve all the colliders intersecting the given shape.
143
+ *
144
+ * @param colliders - The set of colliders taking part in this pipeline.
145
+ * @param shapePos - The position of the shape to test.
146
+ * @param shapeRot - The orientation of the shape to test.
147
+ * @param shape - The shape to test.
148
+ * @param groups - The bit groups and filter associated to the shape to test, in order to only
149
+ * test on colliders with collision groups compatible with this group.
150
+ * @param callback - A function called with the handles of each collider intersecting the `shape`.
151
+ */
152
+ intersectionsWithShape(narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, shapePos: Vector, shapeRot: Rotation, shape: Shape, callback: (handle: ColliderHandle) => boolean, filterFlags?: QueryFilterFlags, filterGroups?: InteractionGroups, filterExcludeCollider?: ColliderHandle, filterExcludeRigidBody?: RigidBodyHandle, filterPredicate?: (collider: ColliderHandle) => boolean): void;
153
+ /**
154
+ * Finds the handles of all the colliders with an AABB intersecting the given AABB.
155
+ *
156
+ * @param aabbCenter - The center of the AABB to test.
157
+ * @param aabbHalfExtents - The half-extents of the AABB to test.
158
+ * @param callback - The callback that will be called with the handles of all the colliders
159
+ * currently intersecting the given AABB.
160
+ */
161
+ collidersWithAabbIntersectingAabb(narrowPhase: NarrowPhase, bodies: RigidBodySet, colliders: ColliderSet, aabbCenter: Vector, aabbHalfExtents: Vector, callback: (handle: ColliderHandle) => boolean): void;
162
+ }