@react-three/rapier 0.8.2 → 0.9.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/Physics.d.ts +10 -2
- package/dist/declarations/src/types.d.ts +25 -13
- package/dist/declarations/src/utils-collider.d.ts +1 -1
- package/dist/react-three-rapier.cjs.dev.js +348 -246
- package/dist/react-three-rapier.cjs.prod.js +348 -246
- package/dist/react-three-rapier.esm.js +349 -247
- package/package.json +1 -1
- package/readme.md +39 -0
@@ -1,8 +1,8 @@
|
|
1
|
-
import React, { FC, ReactNode } from "react";
|
2
1
|
import type Rapier from "@dimforge/rapier3d-compat";
|
3
|
-
import { CollisionEnterHandler, CollisionExitHandler, IntersectionEnterHandler, IntersectionExitHandler, RigidBodyAutoCollider, Vector3Array, WorldApi } from "./types";
|
4
2
|
import { Collider, ColliderHandle, RigidBody, RigidBodyHandle } from "@dimforge/rapier3d-compat";
|
3
|
+
import React, { FC, ReactNode } from "react";
|
5
4
|
import { Matrix4, Object3D, Vector3 } from "three";
|
5
|
+
import { CollisionEnterHandler, CollisionExitHandler, ContactForceHandler, IntersectionEnterHandler, IntersectionExitHandler, RigidBodyAutoCollider, Vector3Array, WorldApi } from "./types";
|
6
6
|
export interface RigidBodyState {
|
7
7
|
rigidBody: RigidBody;
|
8
8
|
object: Object3D;
|
@@ -46,6 +46,7 @@ export declare type EventMap = Map<ColliderHandle | RigidBodyHandle, {
|
|
46
46
|
onCollisionExit?: CollisionExitHandler;
|
47
47
|
onIntersectionEnter?: IntersectionEnterHandler;
|
48
48
|
onIntersectionExit?: IntersectionExitHandler;
|
49
|
+
onContactForce?: ContactForceHandler;
|
49
50
|
}>;
|
50
51
|
interface RapierWorldProps {
|
51
52
|
children: ReactNode;
|
@@ -82,6 +83,13 @@ interface RapierWorldProps {
|
|
82
83
|
* @defaultValue undefined
|
83
84
|
*/
|
84
85
|
updatePriority?: number;
|
86
|
+
/**
|
87
|
+
* Interpolate the world transform using the frame delta times.
|
88
|
+
* Has no effect if timeStep is set to "vary".
|
89
|
+
*
|
90
|
+
* @default true
|
91
|
+
**/
|
92
|
+
interpolate?: boolean;
|
85
93
|
}
|
86
94
|
export declare const Physics: FC<RapierWorldProps>;
|
87
95
|
export {};
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { MutableRefObject } from "react";
|
2
2
|
import { CoefficientCombineRule, Collider as RapierCollider, InteractionGroups, RigidBody as RapierRigidBody, TempContactManifold } from "@dimforge/rapier3d-compat";
|
3
|
-
import {
|
4
|
-
import { ColliderProps } from ".";
|
3
|
+
import { Rotation, Vector } from "@dimforge/rapier3d-compat/math";
|
5
4
|
import { Object3DProps } from "@react-three/fiber";
|
6
5
|
import { Object3D } from "three";
|
6
|
+
import { ColliderProps } from ".";
|
7
|
+
import { createColliderApi, createJointApi, createRigidBodyApi, createWorldApi } from "./api";
|
7
8
|
export { CoefficientCombineRule as CoefficientCombineRule } from "@dimforge/rapier3d-compat";
|
8
9
|
export { RapierRigidBody, RapierCollider };
|
9
|
-
import { Rotation, Vector } from "@dimforge/rapier3d-compat/math";
|
10
10
|
export declare type RefGetter<T> = MutableRefObject<() => T | undefined>;
|
11
11
|
export declare type RigidBodyAutoCollider = "ball" | "cuboid" | "hull" | "trimesh" | false;
|
12
12
|
export interface UseRigidBodyAPI {
|
@@ -74,6 +74,10 @@ export declare type ColliderShape = "cuboid" | "trimesh" | "ball" | "capsule" |
|
|
74
74
|
export declare type Vector3Array = [x: number, y: number, z: number];
|
75
75
|
export declare type Boolean3Array = [x: boolean, y: boolean, z: boolean];
|
76
76
|
export interface UseColliderOptions<ColliderArgs extends Array<unknown>> {
|
77
|
+
/**
|
78
|
+
* The optional name passed to THREE's Object3D
|
79
|
+
*/
|
80
|
+
name?: string;
|
77
81
|
/**
|
78
82
|
* The shape of your collider
|
79
83
|
*/
|
@@ -136,6 +140,10 @@ export interface UseColliderOptions<ColliderArgs extends Array<unknown>> {
|
|
136
140
|
* Callback when this, or another collider stops intersecting, and at least one of them is a `sensor`.
|
137
141
|
*/
|
138
142
|
onIntersectionExit?: IntersectionExitHandler;
|
143
|
+
/**
|
144
|
+
* Callback when this, or another collider triggers a contact force event
|
145
|
+
*/
|
146
|
+
onContactForce?: ContactForceHandler;
|
139
147
|
/**
|
140
148
|
* The bit mask configuring the groups and mask for collision handling.
|
141
149
|
*/
|
@@ -175,26 +183,30 @@ export interface UseColliderOptions<ColliderArgs extends Array<unknown>> {
|
|
175
183
|
*/
|
176
184
|
sensor?: boolean;
|
177
185
|
}
|
178
|
-
export declare type
|
186
|
+
export declare type BaseCollisionPayload = {
|
179
187
|
rigidBody?: RapierRigidBody;
|
180
188
|
collider: RapierCollider;
|
181
|
-
manifold: TempContactManifold;
|
182
|
-
flipped: boolean;
|
183
189
|
rigidBodyObject?: Object3D;
|
184
190
|
colliderObject?: Object3D;
|
185
191
|
};
|
186
|
-
export declare type
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
192
|
+
export declare type CollisionEnterPayload = BaseCollisionPayload & {
|
193
|
+
manifold: TempContactManifold;
|
194
|
+
flipped: boolean;
|
195
|
+
};
|
196
|
+
export declare type CollisionExitPayload = BaseCollisionPayload;
|
197
|
+
export declare type IntersectionEnterPayload = BaseCollisionPayload;
|
198
|
+
export declare type IntersectionExitPayload = BaseCollisionPayload;
|
199
|
+
export declare type ContactForcePayload = BaseCollisionPayload & {
|
200
|
+
totalForce: Vector;
|
201
|
+
totalForceMagnitude: number;
|
202
|
+
maxForceDirection: Vector;
|
203
|
+
maxForceMagnitude: number;
|
191
204
|
};
|
192
|
-
export declare type IntersectionEnterPayload = CollisionExitPayload;
|
193
|
-
export declare type IntersectionExitPayload = CollisionExitPayload;
|
194
205
|
export declare type CollisionEnterHandler = (payload: CollisionEnterPayload) => void;
|
195
206
|
export declare type CollisionExitHandler = (payload: CollisionExitPayload) => void;
|
196
207
|
export declare type IntersectionEnterHandler = (payload: IntersectionEnterPayload) => void;
|
197
208
|
export declare type IntersectionExitHandler = (payload: IntersectionExitPayload) => void;
|
209
|
+
export declare type ContactForceHandler = (payload: ContactForcePayload) => void;
|
198
210
|
export interface UseRigidBodyOptions extends ColliderProps {
|
199
211
|
/**
|
200
212
|
* Specify the type of this rigid body
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Collider, RigidBody } from "@dimforge/rapier3d-compat";
|
2
2
|
import { MutableRefObject } from "react";
|
3
|
-
import {
|
3
|
+
import { BufferGeometry, Object3D, Vector3 } from "three";
|
4
4
|
import { ColliderProps, RigidBodyProps } from ".";
|
5
5
|
import { WorldApi } from "./api";
|
6
6
|
import { ColliderState, ColliderStateMap, EventMap } from "./Physics";
|