@react-three/rapier 0.5.1 → 0.6.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-three/rapier",
3
- "version": "0.5.1",
3
+ "version": "0.6.1",
4
4
  "source": "src/index.ts",
5
5
  "main": "dist/react-three-rapier.cjs.js",
6
6
  "module": "dist/react-three-rapier.esm.js",
package/readme.md CHANGED
@@ -1,4 +1,6 @@
1
- <h1 align="center">@react-three/rapier 🗡</h1>
1
+ <p align="center">
2
+ <img src="misc/hero.svg" />
3
+ </p>
2
4
 
3
5
  <p align="center">⚠️ Under heavy development. All APIs are subject to change. ⚠️</p>
4
6
 
@@ -103,14 +105,61 @@ Objects work inside other transformed objects as well. Simulation runs in world
103
105
  import { Box } from "@react-three/drei";
104
106
  import { RigidBody, CuboidCollider } from "@react-three/rapier";
105
107
 
108
+ const Scene = () => (
109
+ <group position={[2, 5, 0]} rotation={[0, 0.3, 2]}>
110
+ <RigidBody>
111
+ <Box />
112
+ <CuboidCollider args={[0.5, 0.5, 0.5]} />
113
+ </RigidBody>
114
+ </group>
115
+ );
116
+ ```
117
+
118
+ ## Instanced Meshes
119
+
120
+ Instanced meshes can also be used and have automatic colliders generated from their mesh.
121
+
122
+ By wrapping the `InstancedMesh` in `<InstancedRigidBodies />`, each instance will be attached to an individual `RigidBody`.
123
+
124
+ ```tsx
125
+ import { InstancedRigidBodies } from "@react-three/rapier";
126
+
127
+ const COUNT = 1000;
128
+
106
129
  const Scene = () => {
130
+ const instancedApi = useRef<InstancedRigidBodyApi>(null);
131
+
132
+ useEffect(() => {
133
+ // You can access individual instanced by their index
134
+ instancedApi.at(40).applyImpulse({ x: 0, y: 10, z: 0 });
135
+
136
+ // Or update all instances as if they were in an array
137
+ instancedApi.forEach((api) => {
138
+ api.applyImpulse({ x: 0, y: 10, z: 0 });
139
+ });
140
+ }, []);
141
+
142
+ // We can set the initial positions, and rotations, of the instances by providing an array equal to the instance count
143
+ const positions = Array.from({ length: COUNT }, (_, index) => [index, 0, 0]);
144
+
145
+ const rotations = Array.from({ length: COUNT }, (_, index) => [
146
+ Math.random(),
147
+ Math.random(),
148
+ Math.random(),
149
+ ]);
150
+
107
151
  return (
108
- <group position={[2, 5, 0]} rotation={[0, 0.3, 2]}>
109
- <RigidBody>
110
- <Box />
111
- <CuboidCollider args={[0.5, 0.5, 0.5]} />
112
- </RigidBody>
113
- </group>
152
+ <InstancedRigidBodies
153
+ ref={instancedApi}
154
+ positions={positions}
155
+ rotations={rotations}
156
+ colliders="ball"
157
+ >
158
+ <instancedMesh args={[undefined, undefined, COUNT]}>
159
+ <sphereBufferGeometry args={[0.2]} />
160
+ <meshPhysicalGeometry color="blue" />
161
+ </instancedMesh>
162
+ </InstancedRigidBodies>
114
163
  );
115
164
  };
116
165
  ```
@@ -170,19 +219,22 @@ return (
170
219
 
171
220
  WIP
172
221
 
173
- ## Roadmap?
222
+ ---
223
+
224
+ ## Roadmap
174
225
 
175
226
  In order, but also not necessarily:
176
227
 
177
- - [x] Draft of all base shapes
178
- - [x] Draft of all base joints
228
+ - [x] RigidBodies, Colliders
229
+ - [x] Joints
179
230
  - [x] Nested objects retain world transforms
180
231
  - [x] Nested objects retain correct collider scale
181
232
  - [x] Automatic colliders based on rigidbody children
182
233
  - [x] Translation and rotational constraints
183
234
  - [x] Collision events
184
- - [ ] Colliders outside RigidBodies
185
- - [ ] InstancedMesh support
235
+ - [x] Colliders outside RigidBodies
236
+ - [x] InstancedMesh support
237
+ - [ ] Normalize and improve collision events (add events to single Colliders, InstancedRigidBodies, etc)
186
238
  - [ ] Docs
187
239
  - [ ] CodeSandbox examples
188
240
  - [ ] Helpers, for things like Vehicle, Rope, Player, etc
package/CHANGELOG.md DELETED
@@ -1,93 +0,0 @@
1
- # @react-three/rapier
2
-
3
- ## 0.5.1
4
-
5
- ### Patch Changes
6
-
7
- - c36be39: Add MeshCollider, allowing more fine control over automatic collider creation
8
-
9
- ## 0.5.0
10
-
11
- ### Minor Changes
12
-
13
- - a3be5f6: Remove hooks api in favor of better fleshed out components
14
-
15
- ### Patch Changes
16
-
17
- - a3be5f6: Update types for Joints -- now only allow RefObjects of RigidBodyApi
18
- - a3be5f6: Fix setKinematicRotation (convert Vector3 to Quaternion)
19
- - a3be5f6: Update to @dimforge/rapier3d-compat@0.9.0
20
- - a3be5f6: Allow setting the physics timeStep
21
- - a3be5f6: Add rotational and transitional constraits to RigidBody
22
- - a3be5f6: Allow updating the gravity at runtime
23
-
24
- ## 0.4.3
25
-
26
- ### Patch Changes
27
-
28
- - f7a8a2d: Rigid body creation hooks should not use auto colliders
29
- - 663eeb5: Fix default collider setting
30
-
31
- ## 0.4.2
32
-
33
- ### Patch Changes
34
-
35
- - 387b32c: Add restitution and friction as props for auto-generated colliders on RigidBody
36
-
37
- ## 0.4.1
38
-
39
- ### Patch Changes
40
-
41
- - bb7a269: Add useful proxied api methods to rigidbody
42
-
43
- ## 0.4.0
44
-
45
- ### Minor Changes
46
-
47
- - dd535aa: Update to @dimforge/rapier3d-compat@0.8.1, pinned version
48
-
49
- ### Patch Changes
50
-
51
- - dd535aa: Better <Physics /> lifecycle making reinitialization more stable
52
-
53
- ## 0.3.1
54
-
55
- ### Patch Changes
56
-
57
- - 37d2621: Pin rapier3d version to 0.8.0-alpha.2
58
-
59
- ## 0.3.0
60
-
61
- ### Minor Changes
62
-
63
- - 7e36172: Add collision and sleep/awake events
64
-
65
- ## 0.2.0
66
-
67
- ### Minor Changes
68
-
69
- - 584ce08: Expose joint api, however no joint is returned when created (rapier bug?)
70
-
71
- ### Patch Changes
72
-
73
- - 584ce08: All parts now uses a more rigid initiation process
74
- - 584ce08: Apply bounding box offset for auto colliders
75
- - 584ce08: Use single update loop instead of individual rigid body callbacks
76
-
77
- ## 0.1.2
78
-
79
- ### Patch Changes
80
-
81
- - 4f7440c: fix: make global colliders setting progate to children
82
-
83
- ## 0.1.1
84
-
85
- ### Patch Changes
86
-
87
- - 260e6d1: Fix Physics "colliders" value not being applied in children by default
88
-
89
- ## 0.1.0
90
-
91
- ### Minor Changes
92
-
93
- - First release with base functionality of RigidBodies in Rapier