@react-three/rapier 0.9.0 → 0.10.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/dist/declarations/src/Attractor.d.ts +51 -0
- package/dist/declarations/src/MeshCollider.d.ts +4 -1
- package/dist/declarations/src/Physics.d.ts +33 -4
- package/dist/declarations/src/index.d.ts +2 -1
- package/dist/declarations/src/{bitmasks.d.ts → interaction-groups.d.ts} +0 -0
- package/dist/declarations/src/types.d.ts +20 -6
- package/dist/react-three-rapier.cjs.dev.js +1055 -917
- package/dist/react-three-rapier.cjs.prod.js +1055 -917
- package/dist/react-three-rapier.esm.js +1059 -922
- package/package.json +1 -1
- package/readme.md +112 -47
@@ -0,0 +1,51 @@
|
|
1
|
+
import { InteractionGroups, RigidBody } from "@dimforge/rapier3d-compat";
|
2
|
+
import { FC } from "react";
|
3
|
+
import { Object3D } from "three";
|
4
|
+
import { Object3DProps } from "@react-three/fiber";
|
5
|
+
declare type GravityType = "static" | "linear" | "newtonian";
|
6
|
+
interface AttractorProps {
|
7
|
+
/**
|
8
|
+
* The relative position of this attractor
|
9
|
+
*/
|
10
|
+
position?: Object3DProps["position"];
|
11
|
+
/**
|
12
|
+
* The strength of the attractor.
|
13
|
+
* Positive values attract, negative values repel.
|
14
|
+
*
|
15
|
+
* @default 1
|
16
|
+
*/
|
17
|
+
strength?: number;
|
18
|
+
/**
|
19
|
+
* The range of the attractor. Will not affect objects outside of this range.
|
20
|
+
*
|
21
|
+
* @default 10
|
22
|
+
* @min 0
|
23
|
+
*/
|
24
|
+
range?: number;
|
25
|
+
/**
|
26
|
+
* The type of gravity to use.
|
27
|
+
* - static: The gravity is constant and does not change over time.
|
28
|
+
* - linear: The gravity is linearly interpolated the closer the object is to the attractor.
|
29
|
+
* - newtonian: The gravity is calculated using the newtonian gravity formula.
|
30
|
+
* @default "static"
|
31
|
+
*/
|
32
|
+
type?: GravityType;
|
33
|
+
/**
|
34
|
+
* The mass of the attractor. Used when type is `newtonian`.
|
35
|
+
* @default 6.673e-11
|
36
|
+
*/
|
37
|
+
gravitationalConstant?: number;
|
38
|
+
/**
|
39
|
+
* The collision groups that this attractor will apply effects to. If a RigidBody contains one or more colliders that are in one of the mask group, it will be affected by this attractor.
|
40
|
+
* If not specified, the attractor will apply effects to all RigidBodies.
|
41
|
+
*/
|
42
|
+
collisionGroups?: InteractionGroups;
|
43
|
+
}
|
44
|
+
export interface AttractorState extends Required<Omit<AttractorProps, "position" | "collisionGroups">> {
|
45
|
+
object: Object3D;
|
46
|
+
collisionGroups?: InteractionGroups;
|
47
|
+
}
|
48
|
+
export declare type AttractorStateMap = Map<Object3D["uuid"], AttractorState>;
|
49
|
+
export declare const applyAttractorForceOnRigidBody: (rigidBody: RigidBody, { object, strength, range, gravitationalConstant, collisionGroups, type }: AttractorState) => void;
|
50
|
+
export declare const Attractor: FC<AttractorProps>;
|
51
|
+
export {};
|
@@ -4,5 +4,8 @@ interface MeshColliderProps {
|
|
4
4
|
children: ReactNode;
|
5
5
|
type: RigidBodyAutoCollider;
|
6
6
|
}
|
7
|
-
export declare const MeshCollider:
|
7
|
+
export declare const MeshCollider: {
|
8
|
+
(props: MeshColliderProps): JSX.Element;
|
9
|
+
displayName: string;
|
10
|
+
};
|
8
11
|
export {};
|
@@ -3,6 +3,7 @@ import { Collider, ColliderHandle, RigidBody, RigidBodyHandle } from "@dimforge/
|
|
3
3
|
import React, { FC, ReactNode } from "react";
|
4
4
|
import { Matrix4, Object3D, Vector3 } from "three";
|
5
5
|
import { CollisionEnterHandler, CollisionExitHandler, ContactForceHandler, IntersectionEnterHandler, IntersectionExitHandler, RigidBodyAutoCollider, Vector3Array, WorldApi } from "./types";
|
6
|
+
import { AttractorStateMap } from "./Attractor";
|
6
7
|
export interface RigidBodyState {
|
7
8
|
rigidBody: RigidBody;
|
8
9
|
object: Object3D;
|
@@ -21,25 +22,52 @@ export interface ColliderState {
|
|
21
22
|
object: Object3D;
|
22
23
|
/**
|
23
24
|
* The parent of which this collider needs to base its
|
24
|
-
* world position on
|
25
|
+
* world position on, can be empty
|
25
26
|
*/
|
26
|
-
worldParent
|
27
|
+
worldParent?: Object3D;
|
27
28
|
}
|
28
29
|
export declare type ColliderStateMap = Map<Collider["handle"], ColliderState>;
|
29
30
|
export interface RapierContext {
|
30
31
|
rapier: typeof Rapier;
|
31
32
|
world: WorldApi;
|
33
|
+
/**
|
34
|
+
* @internal
|
35
|
+
*/
|
32
36
|
rigidBodyStates: RigidBodyStateMap;
|
37
|
+
/**
|
38
|
+
* @internal
|
39
|
+
*/
|
33
40
|
colliderStates: ColliderStateMap;
|
41
|
+
/**
|
42
|
+
* @internal
|
43
|
+
*/
|
34
44
|
rigidBodyEvents: EventMap;
|
45
|
+
/**
|
46
|
+
* @internal
|
47
|
+
*/
|
35
48
|
colliderEvents: EventMap;
|
49
|
+
/**
|
50
|
+
* @internal
|
51
|
+
*/
|
52
|
+
attractorStates: AttractorStateMap;
|
36
53
|
physicsOptions: {
|
37
54
|
colliders: RigidBodyAutoCollider;
|
38
55
|
};
|
39
56
|
isPaused: boolean;
|
57
|
+
/**
|
58
|
+
* Step the physics world one step
|
59
|
+
*
|
60
|
+
* @param deltaTime The delta time to step the world with
|
61
|
+
*
|
62
|
+
* @example
|
63
|
+
* ```
|
64
|
+
* step(1/60)
|
65
|
+
* ```
|
66
|
+
*/
|
67
|
+
step: (deltaTime: number) => void;
|
40
68
|
}
|
41
69
|
export declare const RapierContext: React.Context<RapierContext | undefined>;
|
42
|
-
export declare type
|
70
|
+
export declare type EventMapValue = {
|
43
71
|
onSleep?(): void;
|
44
72
|
onWake?(): void;
|
45
73
|
onCollisionEnter?: CollisionEnterHandler;
|
@@ -47,7 +75,8 @@ export declare type EventMap = Map<ColliderHandle | RigidBodyHandle, {
|
|
47
75
|
onIntersectionEnter?: IntersectionEnterHandler;
|
48
76
|
onIntersectionExit?: IntersectionExitHandler;
|
49
77
|
onContactForce?: ContactForceHandler;
|
50
|
-
}
|
78
|
+
};
|
79
|
+
export declare type EventMap = Map<ColliderHandle | RigidBodyHandle, EventMapValue>;
|
51
80
|
interface RapierWorldProps {
|
52
81
|
children: ReactNode;
|
53
82
|
/**
|
@@ -9,5 +9,6 @@ export { MeshCollider } from "./MeshCollider";
|
|
9
9
|
export { Debug } from "./Debug";
|
10
10
|
export { InstancedRigidBodies } from "./InstancedRigidBodies";
|
11
11
|
export * from "./AnyCollider";
|
12
|
+
export { Attractor } from "./Attractor";
|
12
13
|
export * from "./hooks";
|
13
|
-
export * from "./
|
14
|
+
export * from "./interaction-groups";
|
File without changes
|
@@ -183,20 +183,34 @@ export interface UseColliderOptions<ColliderArgs extends Array<unknown>> {
|
|
183
183
|
*/
|
184
184
|
sensor?: boolean;
|
185
185
|
}
|
186
|
-
export declare type
|
186
|
+
export declare type CollisionTarget = {
|
187
187
|
rigidBody?: RapierRigidBody;
|
188
188
|
collider: RapierCollider;
|
189
189
|
rigidBodyObject?: Object3D;
|
190
190
|
colliderObject?: Object3D;
|
191
191
|
};
|
192
|
-
export declare type
|
192
|
+
export declare type CollisionPayload = {
|
193
|
+
/** the object firing the event */
|
194
|
+
target: CollisionTarget;
|
195
|
+
/** the other object involved in the event */
|
196
|
+
other: CollisionTarget;
|
197
|
+
/** deprecated use `payload.other.rigidBody` instead */
|
198
|
+
rigidBody?: RapierRigidBody;
|
199
|
+
/** deprecated use `payload.other.collider` instead */
|
200
|
+
collider: RapierCollider;
|
201
|
+
/** deprecated use `payload.other.rigidBodyObject` instead */
|
202
|
+
rigidBodyObject?: Object3D;
|
203
|
+
/** deprecated use `payload.other.colliderObject` instead */
|
204
|
+
colliderObject?: Object3D;
|
205
|
+
};
|
206
|
+
export declare type CollisionEnterPayload = CollisionPayload & {
|
193
207
|
manifold: TempContactManifold;
|
194
208
|
flipped: boolean;
|
195
209
|
};
|
196
|
-
export declare type CollisionExitPayload =
|
197
|
-
export declare type IntersectionEnterPayload =
|
198
|
-
export declare type IntersectionExitPayload =
|
199
|
-
export declare type ContactForcePayload =
|
210
|
+
export declare type CollisionExitPayload = CollisionPayload;
|
211
|
+
export declare type IntersectionEnterPayload = CollisionPayload;
|
212
|
+
export declare type IntersectionExitPayload = CollisionPayload;
|
213
|
+
export declare type ContactForcePayload = CollisionPayload & {
|
200
214
|
totalForce: Vector;
|
201
215
|
totalForceMagnitude: number;
|
202
216
|
maxForceDirection: Vector;
|