Closed elisherer closed 3 years ago
Thanks for this, @elisherer! Instant collider view is very handy to have.
@marcofugaro do you want to weigh in on this? I'm not entirely sold on the idea of a debugger with erroneous representations (as a limitation) like in the Vehicle demo or even the demos pictured above, where the debug representation isn't accurate to the physics model.
@stockHuman, any other comments on this PR? I'm working with that version of use-cannon already and it saves me a lot of time building my bodies (can't see any other way of doing it). About your comment, I am using cannon-es-debugger as-is and what ever "erroneous representations" are part of it and will be fixed as it is a dependency. We can add it as a peer dependency instead of a dependency to allow upgrading the debugger without relying on use-cannon (but it will mean that every installation of use-cannon will require cannon-es-debugger);
Hey @elisherer, I've spoken to Paul, I think we'll merge. :)
Edit: in the future, it would be nice to make this an optional import as in:
import { Provider, Debug } from @react-three/cannon
<Provider>
<Debug>
...
@elisherer thanks! i made some adjustments:
i've documented it on the readme and here's a small example https://codesandbox.io/s/simple-physics-demo-with-debug-bounds-0k27n?file=/src/App.js
@drcmda, very cool! I haven't figured I made cannon-es
be bundled twice. Good idea to split it up.
I see you went with black as the default 😁
Addresses #21
Usage
Add a
debug
prop to the<Physics />
component.e.g.
Tech notes
propsToBody
algorithm from the worker, so theuseBody
hook could fill thedebugInfo
with its own bodies (so we could usecannon-es-debugger
as-is)THREE.Scene
for the same purpose of using the debugger as-is.useBody
hook. If switched off then no body information is collected.