@react-three/rapier 0.5.2 → 0.6.2
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 +11 -0
- package/dist/declarations/src/MeshCollider.d.ts +8 -0
- package/dist/declarations/src/Physics.d.ts +11 -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 +14 -9
- package/dist/react-three-rapier.cjs.dev.js +409 -289
- package/dist/react-three-rapier.cjs.prod.js +409 -289
- package/dist/react-three-rapier.esm.js +411 -291
- package/package.json +1 -1
- package/readme.md +72 -12
package/package.json
CHANGED
package/readme.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
<
|
1
|
+
<p align="center">
|
2
|
+
<img src="https://raw.githubusercontent.com/pmndrs/react-three-rapier/HEAD/packages/react-three-rapier/misc/hero.svg" alt="@react-three/rapier" />
|
3
|
+
</p>
|
2
4
|
|
3
5
|
<p align="center">⚠️ Under heavy development. All APIs are subject to change. ⚠️</p>
|
4
6
|
|
@@ -103,14 +105,69 @@ 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, and scales, of
|
143
|
+
// the instances by providing an array equal to the instance count
|
144
|
+
const positions = Array.from({ length: COUNT }, (_, index) => [index, 0, 0]);
|
145
|
+
|
146
|
+
const rotations = Array.from({ length: COUNT }, (_, index) => [
|
147
|
+
Math.random(),
|
148
|
+
Math.random(),
|
149
|
+
Math.random(),
|
150
|
+
]);
|
151
|
+
|
152
|
+
const scales = Array.from({ length: COUNT }, (_, index) => [
|
153
|
+
Math.random(),
|
154
|
+
Math.random(),
|
155
|
+
Math.random(),
|
156
|
+
]);
|
157
|
+
|
107
158
|
return (
|
108
|
-
<
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
159
|
+
<InstancedRigidBodies
|
160
|
+
ref={instancedApi}
|
161
|
+
positions={positions}
|
162
|
+
rotations={rotations}
|
163
|
+
scales={scales}
|
164
|
+
colliders="ball"
|
165
|
+
>
|
166
|
+
<instancedMesh args={[undefined, undefined, COUNT]}>
|
167
|
+
<sphereBufferGeometry args={[0.2]} />
|
168
|
+
<meshPhysicalGeometry color="blue" />
|
169
|
+
</instancedMesh>
|
170
|
+
</InstancedRigidBodies>
|
114
171
|
);
|
115
172
|
};
|
116
173
|
```
|
@@ -170,19 +227,22 @@ return (
|
|
170
227
|
|
171
228
|
WIP
|
172
229
|
|
173
|
-
|
230
|
+
---
|
231
|
+
|
232
|
+
## Roadmap
|
174
233
|
|
175
234
|
In order, but also not necessarily:
|
176
235
|
|
177
|
-
- [x]
|
178
|
-
- [x]
|
236
|
+
- [x] RigidBodies, Colliders
|
237
|
+
- [x] Joints
|
179
238
|
- [x] Nested objects retain world transforms
|
180
239
|
- [x] Nested objects retain correct collider scale
|
181
240
|
- [x] Automatic colliders based on rigidbody children
|
182
241
|
- [x] Translation and rotational constraints
|
183
242
|
- [x] Collision events
|
184
|
-
- [
|
185
|
-
- [
|
243
|
+
- [x] Colliders outside RigidBodies
|
244
|
+
- [x] InstancedMesh support
|
245
|
+
- [ ] Normalize and improve collision events (add events to single Colliders, InstancedRigidBodies, etc)
|
186
246
|
- [ ] Docs
|
187
247
|
- [ ] CodeSandbox examples
|
188
248
|
- [ ] Helpers, for things like Vehicle, Rope, Player, etc
|