@react-three/rapier 0.5.2 → 0.6.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/{components.d.ts → AnyCollider.d.ts} +1 -11
- package/dist/declarations/src/InstancedRigidBodies.d.ts +10 -0
- package/dist/declarations/src/MeshCollider.d.ts +8 -0
- package/dist/declarations/src/Physics.d.ts +10 -4
- package/dist/declarations/src/RigidBody.d.ts +14 -0
- package/dist/declarations/src/api.d.ts +9 -0
- package/dist/declarations/src/hooks.d.ts +1 -5
- package/dist/declarations/src/index.d.ts +7 -3
- package/dist/declarations/src/shared-objects.d.ts +6 -0
- package/dist/declarations/src/utils.d.ts +13 -4
- package/dist/react-three-rapier.cjs.dev.js +421 -312
- package/dist/react-three-rapier.cjs.prod.js +421 -312
- package/dist/react-three-rapier.esm.js +395 -286
- package/package.json +1 -1
- package/readme.md +64 -12
package/package.json
CHANGED
package/readme.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
<
|
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
|
-
<
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
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
|
-
|
222
|
+
---
|
223
|
+
|
224
|
+
## Roadmap
|
174
225
|
|
175
226
|
In order, but also not necessarily:
|
176
227
|
|
177
|
-
- [x]
|
178
|
-
- [x]
|
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
|
-
- [
|
185
|
-
- [
|
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
|