@react-three/rapier 0.12.2 → 0.13.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 (26) hide show
  1. package/dist/declarations/src/{AnyCollider.d.ts → components/AnyCollider.d.ts} +51 -11
  2. package/dist/declarations/src/{Attractor.d.ts → components/Attractor.d.ts} +0 -0
  3. package/dist/declarations/src/{Debug.d.ts → components/Debug.d.ts} +0 -0
  4. package/dist/declarations/src/components/InstancedRigidBodies.d.ts +12 -0
  5. package/dist/declarations/src/{MeshCollider.d.ts → components/MeshCollider.d.ts} +5 -1
  6. package/dist/declarations/src/{Physics.d.ts → components/Physics.d.ts} +7 -2
  7. package/dist/declarations/src/{RigidBody.d.ts → components/RigidBody.d.ts} +10 -8
  8. package/dist/declarations/src/{hooks.d.ts → hooks/hooks.d.ts} +17 -5
  9. package/dist/declarations/src/{joints.d.ts → hooks/joints.d.ts} +19 -8
  10. package/dist/declarations/src/hooks/use-imperative-instance.d.ts +4 -0
  11. package/dist/declarations/src/index.d.ts +18 -17
  12. package/dist/declarations/src/types.d.ts +10 -10
  13. package/dist/declarations/src/utils/api.d.ts +18 -0
  14. package/dist/declarations/src/{interaction-groups.d.ts → utils/interaction-groups.d.ts} +0 -0
  15. package/dist/declarations/src/{shared-objects.d.ts → utils/shared-objects.d.ts} +0 -0
  16. package/dist/declarations/src/utils/three-object-helpers.d.ts +29 -0
  17. package/dist/declarations/src/{utils-collider.d.ts → utils/utils-collider.d.ts} +6 -7
  18. package/dist/declarations/src/{utils-rigidbody.d.ts → utils/utils-rigidbody.d.ts} +6 -6
  19. package/dist/declarations/src/{utils.d.ts → utils/utils.d.ts} +2 -2
  20. package/dist/react-three-rapier.cjs.dev.js +534 -588
  21. package/dist/react-three-rapier.cjs.prod.js +534 -588
  22. package/dist/react-three-rapier.esm.js +535 -592
  23. package/package.json +12 -12
  24. package/readme.md +165 -30
  25. package/dist/declarations/src/InstancedRigidBodies.d.ts +0 -10
  26. package/dist/declarations/src/api.d.ts +0 -179
@@ -1,10 +1,14 @@
1
1
  import { Collider } from "@dimforge/rapier3d-compat";
2
2
  import React, { ReactNode } from "react";
3
- import { ColliderOptions, CuboidArgs, RoundCuboidArgs, BallArgs, CapsuleArgs, HeightfieldArgs, TrimeshArgs, ConeArgs, CylinderArgs, ConvexHullArgs } from "./types";
3
+ import { ColliderOptions, CuboidArgs, RoundCuboidArgs, BallArgs, CapsuleArgs, HeightfieldArgs, TrimeshArgs, ConeArgs, CylinderArgs, ConvexHullArgs } from "../types";
4
4
  export interface ColliderProps extends ColliderOptions<any> {
5
5
  children?: ReactNode;
6
6
  }
7
- export declare const AnyCollider: React.MemoExoticComponent<React.ForwardRefExoticComponent<ColliderProps & React.RefAttributes<Collider[]>>>;
7
+ /**
8
+ * A collider is a shape that can be attached to a rigid body to define its physical properties.
9
+ * @internal
10
+ */
11
+ export declare const AnyCollider: React.MemoExoticComponent<React.ForwardRefExoticComponent<ColliderProps & React.RefAttributes<Collider>>>;
8
12
  export declare type ColliderOptionsRequiredArgs<T extends unknown[]> = Omit<ColliderOptions<T>, "args"> & {
9
13
  args: T;
10
14
  children?: ReactNode;
@@ -18,39 +22,75 @@ export declare type TrimeshColliderProps = ColliderOptionsRequiredArgs<TrimeshAr
18
22
  export declare type ConeColliderProps = ColliderOptionsRequiredArgs<ConeArgs>;
19
23
  export declare type CylinderColliderProps = ColliderOptionsRequiredArgs<CylinderArgs>;
20
24
  export declare type ConvexHullColliderProps = ColliderOptionsRequiredArgs<ConvexHullArgs>;
25
+ /**
26
+ * A cuboid collider shape
27
+ * @category Colliders
28
+ */
21
29
  export declare const CuboidCollider: React.ForwardRefExoticComponent<Omit<ColliderOptions<CuboidArgs>, "args"> & {
22
30
  args: CuboidArgs;
23
31
  children?: ReactNode;
24
- } & React.RefAttributes<Collider[]>>;
32
+ } & React.RefAttributes<Collider>>;
33
+ /**
34
+ * A round cuboid collider shape
35
+ * @category Colliders
36
+ */
25
37
  export declare const RoundCuboidCollider: React.ForwardRefExoticComponent<Omit<ColliderOptions<RoundCuboidArgs>, "args"> & {
26
38
  args: RoundCuboidArgs;
27
39
  children?: ReactNode;
28
- } & React.RefAttributes<Collider[]>>;
40
+ } & React.RefAttributes<Collider>>;
41
+ /**
42
+ * A ball collider shape
43
+ * @category Colliders
44
+ */
29
45
  export declare const BallCollider: React.ForwardRefExoticComponent<Omit<ColliderOptions<BallArgs>, "args"> & {
30
46
  args: BallArgs;
31
47
  children?: ReactNode;
32
- } & React.RefAttributes<Collider[]>>;
48
+ } & React.RefAttributes<Collider>>;
49
+ /**
50
+ * A capsule collider shape
51
+ * @category Colliders
52
+ */
33
53
  export declare const CapsuleCollider: React.ForwardRefExoticComponent<Omit<ColliderOptions<CapsuleArgs>, "args"> & {
34
54
  args: CapsuleArgs;
35
55
  children?: ReactNode;
36
- } & React.RefAttributes<Collider[]>>;
56
+ } & React.RefAttributes<Collider>>;
57
+ /**
58
+ * A heightfield collider shape
59
+ * @category Colliders
60
+ */
37
61
  export declare const HeightfieldCollider: React.ForwardRefExoticComponent<Omit<ColliderOptions<HeightfieldArgs>, "args"> & {
38
62
  args: HeightfieldArgs;
39
63
  children?: ReactNode;
40
- } & React.RefAttributes<Collider[]>>;
64
+ } & React.RefAttributes<Collider>>;
65
+ /**
66
+ * A trimesh collider shape
67
+ * @category Colliders
68
+ */
41
69
  export declare const TrimeshCollider: React.ForwardRefExoticComponent<Omit<ColliderOptions<TrimeshArgs>, "args"> & {
42
70
  args: TrimeshArgs;
43
71
  children?: ReactNode;
44
- } & React.RefAttributes<Collider[]>>;
72
+ } & React.RefAttributes<Collider>>;
73
+ /**
74
+ * A cone collider shape
75
+ * @category Colliders
76
+ */
45
77
  export declare const ConeCollider: React.ForwardRefExoticComponent<Omit<ColliderOptions<ConeArgs>, "args"> & {
46
78
  args: ConeArgs;
47
79
  children?: ReactNode;
48
- } & React.RefAttributes<Collider[]>>;
80
+ } & React.RefAttributes<Collider>>;
81
+ /**
82
+ * A cylinder collider shape
83
+ * @category Colliders
84
+ */
49
85
  export declare const CylinderCollider: React.ForwardRefExoticComponent<Omit<ColliderOptions<CylinderArgs>, "args"> & {
50
86
  args: CylinderArgs;
51
87
  children?: ReactNode;
52
- } & React.RefAttributes<Collider[]>>;
88
+ } & React.RefAttributes<Collider>>;
89
+ /**
90
+ * A convex hull collider shape
91
+ * @category Colliders
92
+ */
53
93
  export declare const ConvexHullCollider: React.ForwardRefExoticComponent<Omit<ColliderOptions<ConvexHullArgs>, "args"> & {
54
94
  args: ConvexHullArgs;
55
95
  children?: ReactNode;
56
- } & React.RefAttributes<Collider[]>>;
96
+ } & React.RefAttributes<Collider>>;
@@ -0,0 +1,12 @@
1
+ import React, { ReactNode } from "react";
2
+ import { RigidBodyProps } from "./RigidBody";
3
+ import { RapierRigidBody } from "../types";
4
+ export declare type InstancedRigidBodyProps = RigidBodyProps & {
5
+ key: string | number;
6
+ };
7
+ export interface InstancedRigidBodiesProps extends RigidBodyProps {
8
+ instances: InstancedRigidBodyProps[];
9
+ colliderNodes?: ReactNode[];
10
+ children: ReactNode;
11
+ }
12
+ export declare const InstancedRigidBodies: React.MemoExoticComponent<React.ForwardRefExoticComponent<InstancedRigidBodiesProps & React.RefAttributes<(RapierRigidBody | null)[]>>>;
@@ -1,7 +1,11 @@
1
1
  import React, { ReactNode } from "react";
2
- import { RigidBodyAutoCollider } from "./types";
2
+ import { RigidBodyAutoCollider } from "../types";
3
3
  export interface MeshColliderProps {
4
4
  children: ReactNode;
5
5
  type: RigidBodyAutoCollider;
6
6
  }
7
+ /**
8
+ * A mesh collider is a collider that is automatically generated from the geometry of the children.
9
+ * @category Colliders
10
+ */
7
11
  export declare const MeshCollider: React.MemoExoticComponent<(props: MeshColliderProps) => JSX.Element>;
@@ -2,10 +2,11 @@ import type Rapier from "@dimforge/rapier3d-compat";
2
2
  import { Collider, ColliderHandle, RigidBody, RigidBodyHandle } from "@dimforge/rapier3d-compat";
3
3
  import React, { FC, ReactNode } from "react";
4
4
  import { Matrix4, Object3D, Vector3 } from "three";
5
- import { CollisionEnterHandler, CollisionExitHandler, ContactForceHandler, IntersectionEnterHandler, IntersectionExitHandler, RigidBodyAutoCollider, Vector3Array } from "./types";
6
- import { WorldApi } from "./api";
5
+ import { CollisionEnterHandler, CollisionExitHandler, ContactForceHandler, IntersectionEnterHandler, IntersectionExitHandler, RigidBodyAutoCollider, Vector3Array } from "../types";
6
+ import { WorldApi } from "../utils/api";
7
7
  import { AttractorStateMap } from "./Attractor";
8
8
  export interface RigidBodyState {
9
+ meshType: "instancedMesh" | "mesh";
9
10
  rigidBody: RigidBody;
10
11
  object: Object3D;
11
12
  invertedWorldMatrix: Matrix4;
@@ -152,4 +153,8 @@ export interface PhysicsProps {
152
153
  **/
153
154
  interpolate?: boolean;
154
155
  }
156
+ /**
157
+ * The main physics component used to create a physics world.
158
+ * @category Components
159
+ */
155
160
  export declare const Physics: FC<PhysicsProps>;
@@ -1,20 +1,22 @@
1
1
  import React, { MutableRefObject, RefObject } from "react";
2
2
  import { ReactNode } from "react";
3
3
  import { Object3D } from "three";
4
- import { InstancedRigidBodyApi, RigidBodyApi } from "./api";
5
- import { InstancedRigidBodiesProps } from "./InstancedRigidBodies";
6
- import { RigidBodyOptions } from "./types";
4
+ import { RapierRigidBody, RigidBodyOptions } from "../types";
7
5
  export declare const RigidBodyContext: React.Context<{
8
6
  ref: RefObject<Object3D> | MutableRefObject<Object3D>;
9
- api: RigidBodyApi | InstancedRigidBodyApi;
10
- options: RigidBodyOptions | InstancedRigidBodiesProps;
7
+ getRigidBody: () => RapierRigidBody;
8
+ options: RigidBodyOptions;
11
9
  }>;
12
10
  export declare const useRigidBodyContext: () => {
13
11
  ref: RefObject<Object3D> | MutableRefObject<Object3D>;
14
- api: RigidBodyApi | InstancedRigidBodyApi;
15
- options: RigidBodyOptions | InstancedRigidBodiesProps;
12
+ getRigidBody: () => RapierRigidBody;
13
+ options: RigidBodyOptions;
16
14
  };
17
15
  export interface RigidBodyProps extends RigidBodyOptions {
18
16
  children?: ReactNode;
19
17
  }
20
- export declare const RigidBody: React.MemoExoticComponent<React.ForwardRefExoticComponent<RigidBodyProps & React.RefAttributes<RigidBodyApi>>>;
18
+ /**
19
+ * A rigid body is a physical object that can be simulated by the physics engine.
20
+ * @category Components
21
+ */
22
+ export declare const RigidBody: React.MemoExoticComponent<React.ForwardRefExoticComponent<RigidBodyProps & React.RefAttributes<RapierRigidBody>>>;
@@ -1,11 +1,23 @@
1
1
  import React, { MutableRefObject } from "react";
2
- import { RapierContext, WorldStepCallback } from "./Physics";
2
+ import { RapierContext, WorldStepCallback } from "../components/Physics";
3
3
  import { Object3D } from "three";
4
- import { RigidBodyOptions } from "./types";
5
- import { ColliderProps, RigidBodyProps } from ".";
6
- import { RigidBodyApi } from "./api";
4
+ import { ColliderProps, RigidBodyProps } from "..";
5
+ /**
6
+ * Exposes the Rapier context, and world
7
+ * @category Hooks
8
+ */
7
9
  export declare const useRapier: () => RapierContext;
10
+ /**
11
+ * Registers a callback to be called before the physics step
12
+ * @category Hooks
13
+ */
8
14
  export declare const useBeforePhysicsStep: (callback: WorldStepCallback) => void;
15
+ /**
16
+ * Registers a callback to be called after the physics step
17
+ * @category Hooks
18
+ */
9
19
  export declare const useAfterPhysicsStep: (callback: WorldStepCallback) => void;
20
+ /**
21
+ * @internal
22
+ */
10
23
  export declare const useChildColliderProps: <O extends Object3D<import("three").Event>>(ref: React.MutableRefObject<O | null | undefined>, options: RigidBodyProps, ignoreMeshColliders?: boolean) => ColliderProps[];
11
- export declare const useRigidBody: <O extends Object3D<import("three").Event>>(options?: RigidBodyOptions) => [React.MutableRefObject<O>, RigidBodyApi, ColliderProps[]];
@@ -1,30 +1,41 @@
1
- import { ImpulseJoint } from "@dimforge/rapier3d-compat";
2
- import { RigidBodyApiRef, UseImpulseJoint, FixedJointParams, SphericalJointParams, RevoluteJointParams, PrismaticJointParams } from ".";
1
+ import { ImpulseJoint, FixedImpulseJoint, SphericalImpulseJoint, RevoluteImpulseJoint, PrismaticImpulseJoint } from "@dimforge/rapier3d-compat";
2
+ import React, { RefObject } from "react";
3
+ import { RapierRigidBody, UseImpulseJoint, FixedJointParams, SphericalJointParams, RevoluteJointParams, PrismaticJointParams } from "..";
3
4
  import type Rapier from "@dimforge/rapier3d-compat";
4
- export declare const useImpulseJoint: <T extends ImpulseJoint>(body1: RigidBodyApiRef, body2: RigidBodyApiRef, params: Rapier.JointData) => import("./api").JointApi;
5
5
  /**
6
- *
6
+ * @internal
7
+ */
8
+ export declare const useImpulseJoint: <JointType extends ImpulseJoint>(body1: RefObject<RapierRigidBody>, body2: RefObject<RapierRigidBody>, params: Rapier.JointData) => React.MutableRefObject<JointType | undefined>;
9
+ /**
7
10
  * A fixed joint ensures that two rigid-bodies don't move relative to each other.
8
11
  * Fixed joints are characterized by one local frame (represented by an isometry) on each rigid-body.
9
12
  * The fixed-joint makes these frames coincide in world-space.
13
+ *
14
+ * @category Hooks - Joints
10
15
  */
11
- export declare const useFixedJoint: UseImpulseJoint<FixedJointParams>;
16
+ export declare const useFixedJoint: UseImpulseJoint<FixedJointParams, FixedImpulseJoint>;
12
17
  /**
13
18
  * The spherical joint ensures that two points on the local-spaces of two rigid-bodies always coincide (it prevents any relative
14
19
  * translational motion at this points). This is typically used to simulate ragdolls arms, pendulums, etc.
15
20
  * They are characterized by one local anchor on each rigid-body. Each anchor represents the location of the
16
21
  * points that need to coincide on the local-space of each rigid-body.
22
+ *
23
+ * @category Hooks - Joints
17
24
  */
18
- export declare const useSphericalJoint: UseImpulseJoint<SphericalJointParams>;
25
+ export declare const useSphericalJoint: UseImpulseJoint<SphericalJointParams, SphericalImpulseJoint>;
19
26
  /**
20
27
  * The revolute joint prevents any relative movement between two rigid-bodies, except for relative
21
28
  * rotations along one axis. This is typically used to simulate wheels, fans, etc.
22
29
  * They are characterized by one local anchor as well as one local axis on each rigid-body.
30
+ *
31
+ * @category Hooks - Joints
23
32
  */
24
- export declare const useRevoluteJoint: UseImpulseJoint<RevoluteJointParams>;
33
+ export declare const useRevoluteJoint: UseImpulseJoint<RevoluteJointParams, RevoluteImpulseJoint>;
25
34
  /**
26
35
  * The prismatic joint prevents any relative movement between two rigid-bodies, except for relative translations along one axis.
27
36
  * It is characterized by one local anchor as well as one local axis on each rigid-body. In 3D, an optional
28
37
  * local tangent axis can be specified for each rigid-body.
38
+ *
39
+ * @category Hooks - Joints
29
40
  */
30
- export declare const usePrismaticJoint: UseImpulseJoint<PrismaticJointParams>;
41
+ export declare const usePrismaticJoint: UseImpulseJoint<PrismaticJointParams, PrismaticImpulseJoint>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Initiate an instance and return a safe getter
3
+ */
4
+ export declare const useImperativeInstance: <InstanceType_1>(createFn: () => InstanceType_1, destroyFn: (instance: InstanceType_1) => void) => () => InstanceType_1;
@@ -1,18 +1,19 @@
1
1
  export * from "./types";
2
- export type { RigidBodyProps } from "./RigidBody";
3
- export type { InstancedRigidBodiesProps } from "./InstancedRigidBodies";
4
- export type { CylinderColliderProps, BallColliderProps, CapsuleColliderProps, ConeColliderProps, ConvexHullColliderProps, CuboidColliderProps, HeightfieldColliderProps, RoundCuboidColliderProps, TrimeshColliderProps, ColliderOptionsRequiredArgs } from "./AnyCollider";
5
- export type { PhysicsProps, RapierContext, WorldStepCallback } from "./Physics";
6
- export type { MeshColliderProps } from "./MeshCollider";
7
- export type { AttractorProps, AttractorGravityType } from "./Attractor";
8
- export type { RigidBodyApi, InstancedRigidBodyApi, JointApi, WorldApi } from "./api";
9
- export { Physics } from "./Physics";
10
- export { RigidBody } from "./RigidBody";
11
- export { MeshCollider } from "./MeshCollider";
12
- export { Debug } from "./Debug";
13
- export { InstancedRigidBodies } from "./InstancedRigidBodies";
14
- export * from "./AnyCollider";
15
- export { Attractor } from "./Attractor";
16
- export * from "./joints";
17
- export { useRapier, useBeforePhysicsStep, useAfterPhysicsStep } from "./hooks";
18
- export * from "./interaction-groups";
2
+ export type { RigidBodyProps } from "./components/RigidBody";
3
+ export type { InstancedRigidBodiesProps, InstancedRigidBodyProps } from "./components/InstancedRigidBodies";
4
+ export type { CylinderColliderProps, BallColliderProps, CapsuleColliderProps, ConeColliderProps, ConvexHullColliderProps, CuboidColliderProps, HeightfieldColliderProps, RoundCuboidColliderProps, TrimeshColliderProps, ColliderOptionsRequiredArgs } from "./components/AnyCollider";
5
+ export type { PhysicsProps, RapierContext, WorldStepCallback } from "./components/Physics";
6
+ export type { MeshColliderProps } from "./components/MeshCollider";
7
+ export type { AttractorProps, AttractorGravityType } from "./components/Attractor";
8
+ export type { WorldApi } from "./utils/api";
9
+ export { Physics } from "./components/Physics";
10
+ export { RigidBody } from "./components/RigidBody";
11
+ export { MeshCollider } from "./components/MeshCollider";
12
+ export { Debug } from "./components/Debug";
13
+ export { InstancedRigidBodies } from "./components/InstancedRigidBodies";
14
+ export * from "./components/AnyCollider";
15
+ export { Attractor } from "./components/Attractor";
16
+ export * from "./hooks/joints";
17
+ export { useRapier, useBeforePhysicsStep, useAfterPhysicsStep } from "./hooks/hooks";
18
+ export * from "./utils/interaction-groups";
19
+ export * from "./utils/three-object-helpers";
@@ -1,18 +1,14 @@
1
- import { MutableRefObject } from "react";
2
- import { CoefficientCombineRule, Collider as RapierCollider, InteractionGroups, RigidBody as RapierRigidBody, TempContactManifold } from "@dimforge/rapier3d-compat";
1
+ import { MutableRefObject, RefObject } from "react";
2
+ import { CoefficientCombineRule, Collider as RapierCollider, ImpulseJoint, InteractionGroups, RigidBody as RapierRigidBody, TempContactManifold } from "@dimforge/rapier3d-compat";
3
3
  import { Rotation, Vector } from "@dimforge/rapier3d-compat/math";
4
4
  import { Object3DProps } from "@react-three/fiber";
5
5
  import { Object3D } from "three";
6
6
  import { ColliderProps } from ".";
7
- import { RigidBodyApi, JointApi } from "./api";
7
+ import { RigidBodyState } from "./components/Physics";
8
8
  export { CoefficientCombineRule as CoefficientCombineRule } from "@dimforge/rapier3d-compat";
9
9
  export { RapierRigidBody, RapierCollider };
10
10
  export declare type RefGetter<T> = MutableRefObject<() => T | undefined>;
11
11
  export declare type RigidBodyAutoCollider = "ball" | "cuboid" | "hull" | "trimesh" | false;
12
- export interface UseRigidBodyAPI {
13
- rigidBody: RapierRigidBody;
14
- collider: RapierCollider;
15
- }
16
12
  export declare type CuboidArgs = [
17
13
  halfWidth: number,
18
14
  halfHeight: number,
@@ -323,6 +319,11 @@ export interface RigidBodyOptions extends ColliderProps {
323
319
  * Include invisible objects on the collider creation estimation.
324
320
  */
325
321
  includeInvisible?: boolean;
322
+ /**
323
+ * Transform the RigidBodyState
324
+ * @internal Do not use. Used internally by the InstancedRigidBodies to alter the RigidBody State
325
+ */
326
+ transformState?: (state: RigidBodyState) => RigidBodyState;
326
327
  }
327
328
  export declare type SphericalJointParams = [
328
329
  body1Anchor: Vector3Array,
@@ -347,7 +348,6 @@ export declare type RevoluteJointParams = [
347
348
  axis: Vector3Array,
348
349
  limits?: [min: number, max: number]
349
350
  ];
350
- export declare type RigidBodyApiRef = MutableRefObject<undefined | null | RigidBodyApi>;
351
- export interface UseImpulseJoint<P> {
352
- (body1: RigidBodyApiRef, body2: RigidBodyApiRef, params: P): JointApi;
351
+ export interface UseImpulseJoint<JointParams, JointType extends ImpulseJoint> {
352
+ (body1: RefObject<RapierRigidBody>, body2: RefObject<RapierRigidBody>, params: JointParams): RefObject<JointType | undefined>;
353
353
  }
@@ -0,0 +1,18 @@
1
+ import { Collider, ColliderDesc, DebugRenderBuffers, ImpulseJoint, JointData, RigidBody, RigidBodyDesc, World } from "@dimforge/rapier3d-compat";
2
+ import { Vector3 } from "three";
3
+ import { RefGetter } from "../types";
4
+ export interface WorldApi {
5
+ raw(): World;
6
+ getCollider(handle: number): Collider | undefined;
7
+ getRigidBody(handle: number): RigidBody | undefined;
8
+ createRigidBody(desc: RigidBodyDesc): RigidBody;
9
+ createCollider(desc: ColliderDesc, parent?: RigidBody): Collider;
10
+ removeRigidBody(rigidBody: RigidBody): void;
11
+ removeCollider(collider: Collider, wakeUp?: boolean): void;
12
+ createImpulseJoint(params: JointData, rigidBodyA: RigidBody, rigidBodyB: RigidBody, wakeUp?: boolean): ImpulseJoint;
13
+ removeImpulseJoint(joint: ImpulseJoint, wakeUp?: boolean): void;
14
+ forEachCollider(callback: (collider: Collider) => void): void;
15
+ setGravity(gravity: Vector3): void;
16
+ debugRender(): DebugRenderBuffers;
17
+ }
18
+ export declare const createWorldApi: (ref: RefGetter<World>) => WorldApi;
@@ -0,0 +1,29 @@
1
+ import { Euler, Quaternion, Vector3 } from "three";
2
+ /**
3
+ * Takes an object resembling a Vector3 and returs a Three.Vector3
4
+ * @category Math helpers
5
+ */
6
+ export declare const vec3: ({ x, y, z }?: {
7
+ x: number;
8
+ y: number;
9
+ z: number;
10
+ }) => Vector3;
11
+ /**
12
+ * Takes an object resembling a Quaternion and returs a Three.Quaternion
13
+ * @category Math helpers
14
+ */
15
+ export declare const quat: ({ x, y, z, w }?: {
16
+ x: number;
17
+ y: number;
18
+ z: number;
19
+ w: number;
20
+ }) => Quaternion;
21
+ /**
22
+ * Takes an object resembling an Euler and returs a Three.Euler
23
+ * @category Math helpers
24
+ */
25
+ export declare const euler: ({ x, y, z }?: {
26
+ x: number;
27
+ y: number;
28
+ z: number;
29
+ }) => Euler;
@@ -1,10 +1,9 @@
1
1
  import { Collider, RigidBody } from "@dimforge/rapier3d-compat";
2
- import { MutableRefObject } from "react";
3
2
  import { BufferGeometry, Object3D, Vector3 } from "three";
4
- import { ColliderProps, RigidBodyProps } from ".";
3
+ import { ColliderProps, RigidBodyProps } from "..";
5
4
  import { WorldApi } from "./api";
6
- import { ColliderState, ColliderStateMap, EventMap } from "./Physics";
7
- import { ColliderShape, RigidBodyAutoCollider } from "./types";
5
+ import { ColliderState, ColliderStateMap, EventMap } from "../components/Physics";
6
+ import { ColliderShape, RigidBodyAutoCollider } from "../types";
8
7
  export declare const scaleColliderArgs: (shape: ColliderShape, args: (number | ArrayLike<number> | {
9
8
  x: number;
10
9
  y: number;
@@ -14,11 +13,11 @@ export declare const scaleColliderArgs: (shape: ColliderShape, args: (number | A
14
13
  y: number;
15
14
  z: number;
16
15
  })[];
17
- export declare const createColliderFromOptions: (options: ColliderProps, world: WorldApi, scale: Vector3, rigidBody?: RigidBody) => Collider;
16
+ export declare const createColliderFromOptions: (options: ColliderProps, world: WorldApi, scale: Vector3, getRigidBody?: () => RigidBody) => Collider;
18
17
  declare type ImmutableColliderOptions = (keyof ColliderProps)[];
19
18
  export declare const immutableColliderOptions: ImmutableColliderOptions;
20
19
  export declare const setColliderOptions: (collider: Collider, options: ColliderProps, states: ColliderStateMap) => void;
21
- export declare const useUpdateColliderOptions: (collidersRef: MutableRefObject<Collider[]>, props: ColliderProps, states: ColliderStateMap) => void;
20
+ export declare const useUpdateColliderOptions: (getCollider: () => Collider, props: ColliderProps, states: ColliderStateMap) => void;
22
21
  export declare const createColliderState: (collider: Collider, object: Object3D, rigidBodyObject?: Object3D | null) => ColliderState;
23
22
  interface CreateColliderPropsFromChildren {
24
23
  (options: {
@@ -32,5 +31,5 @@ export declare const getColliderArgsFromGeometry: (geometry: BufferGeometry, col
32
31
  args: unknown[];
33
32
  offset: Vector3;
34
33
  };
35
- export declare const useColliderEvents: (collidersRef: MutableRefObject<Collider[] | undefined>, props: ColliderProps, events: EventMap) => void;
34
+ export declare const useColliderEvents: (getCollider: () => Collider, props: ColliderProps, events: EventMap) => void;
36
35
  export {};
@@ -1,8 +1,7 @@
1
1
  import { RigidBody, RigidBodyDesc } from "@dimforge/rapier3d-compat";
2
- import { MutableRefObject } from "react";
3
2
  import { Matrix4, Object3D, Vector3 } from "three";
4
- import { RigidBodyProps } from ".";
5
- import { EventMap, RigidBodyState, RigidBodyStateMap } from "./Physics";
3
+ import { RigidBodyProps } from "..";
4
+ import { EventMap, RigidBodyState, RigidBodyStateMap } from "../components/Physics";
6
5
  export declare const rigidBodyDescFromOptions: (options: RigidBodyProps) => RigidBodyDesc;
7
6
  interface CreateRigidBodyStateOptions {
8
7
  object: Object3D;
@@ -10,11 +9,12 @@ interface CreateRigidBodyStateOptions {
10
9
  setMatrix?: (matrix: Matrix4) => void;
11
10
  getMatrix?: (matrix: Matrix4) => Matrix4;
12
11
  worldScale?: Vector3;
12
+ meshType?: RigidBodyState["meshType"];
13
13
  }
14
- export declare const createRigidBodyState: ({ rigidBody, object, setMatrix, getMatrix, worldScale }: CreateRigidBodyStateOptions) => RigidBodyState;
14
+ export declare const createRigidBodyState: ({ rigidBody, object, setMatrix, getMatrix, worldScale, meshType }: CreateRigidBodyStateOptions) => RigidBodyState;
15
15
  declare type ImmutableRigidBodyOptions = (keyof RigidBodyProps)[];
16
16
  export declare const immutableRigidBodyOptions: ImmutableRigidBodyOptions;
17
17
  export declare const setRigidBodyOptions: (rigidBody: RigidBody, options: RigidBodyProps, states: RigidBodyStateMap, updateTranslations?: boolean) => void;
18
- export declare const useUpdateRigidBodyOptions: (rigidBodyRef: MutableRefObject<RigidBody | RigidBody[] | undefined>, props: RigidBodyProps, states: RigidBodyStateMap, updateTranslations?: boolean) => void;
19
- export declare const useRigidBodyEvents: (rigidBodyRef: MutableRefObject<RigidBody | RigidBody[] | undefined>, props: RigidBodyProps, events: EventMap) => void;
18
+ export declare const useUpdateRigidBodyOptions: (getRigidBody: () => RigidBody, props: RigidBodyProps, states: RigidBodyStateMap, updateTranslations?: boolean) => void;
19
+ export declare const useRigidBodyEvents: (getRigidBody: () => RigidBody, props: RigidBodyProps, events: EventMap) => void;
20
20
  export {};
@@ -1,12 +1,12 @@
1
1
  import { Quaternion as RapierQuaternion, Vector3 as RapierVector3 } from "@dimforge/rapier3d-compat";
2
2
  import { Euler, Quaternion, Vector3 } from "three";
3
- import { RigidBodyTypeString, Vector3Array } from "./types";
3
+ import { RigidBodyTypeString, Vector3Array } from "../types";
4
4
  export declare const vectorArrayToVector3: (arr: Vector3Array) => Vector3;
5
5
  export declare const tupleToObject: <T extends readonly any[], K extends readonly string[]>(tuple: T, keys: K) => { [Key in K[number]]: T[number]; };
6
6
  export declare const vector3ToQuaternion: (v: Vector3) => Quaternion;
7
7
  export declare const rapierVector3ToVector3: ({ x, y, z }: RapierVector3) => Vector3;
8
8
  export declare const rapierQuaternionToQuaternion: ({ x, y, z, w }: RapierQuaternion) => Quaternion;
9
- export declare const rigidBodyTypeFromString: (type: RigidBodyTypeString) => number;
9
+ export declare const rigidBodyTypeFromString: (type: RigidBodyTypeString) => 0 | 3 | 1 | 2;
10
10
  export declare const scaleVertices: (vertices: ArrayLike<number>, scale: Vector3) => number[];
11
11
  export declare const vectorToTuple: (v: Vector3 | Quaternion | any[] | undefined | number | Euler) => any[];
12
12
  export declare function useConst<T>(initialValue: T | (() => T)): T;