Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can shapes work on the inside? #107

Open
drcmda opened this issue Aug 9, 2020 · 3 comments
Open

can shapes work on the inside? #107

drcmda opened this issue Aug 9, 2020 · 3 comments

Comments

@drcmda
Copy link
Member

drcmda commented Aug 9, 2020

this demo: https://codesandbox.io/s/r3f-ibl-envmap-simple-6ebrr?file=/src/App.js:1025-1561 realizes the pill-box using 6 infinite planes:

  const [ref, api] = useCompoundBody(() => ({
    shapes: [
      { type: 'Plane', position: [0, -1.8, 0], rotation: [-Math.PI / 2, 0, 0] },
      { type: 'Plane', position: [0, 1.8, 0], rotation: [Math.PI / 2, 0, 0] },
      { type: 'Plane', position: [-0.8, 0, 0], rotation: [0, Math.PI / 2, 0] },
      { type: 'Plane', position: [0.8, 0, 0], rotation: [0, -Math.PI / 2, 0] },
      { type: 'Plane', position: [0, 0, -0.8], rotation: [0, 0, 0] },
      { type: 'Plane', position: [0, 0, 0.8], rotation: [0, -Math.PI, 0] }
    ]
  }))

which is ineffective, messy to write, and it wouldn't work if there's supposed to be physics outside of it. couldn't i just write

  const [ref, api] = useBox(...)

and dump the spheres inside? i haven't tried, i just assumed i couldn't possibly work, but would this be feasible for any situation where you want some kind of container?

@codynova
Copy link
Member

codynova commented Aug 9, 2020

This shouldn't work, as shapes that aren't planes should be treated as solid objects by the simulation - this is why boxes tend to be better than planes for faster collisions. However I guess you could write a usePhysicsContainer helper hook or something and give it a geometry, and let it construct the planes?

@drcmda
Copy link
Member Author

drcmda commented Aug 9, 2020

or a flag that inverts the geometry? would that be hard to realize in cannon?

@codynova
Copy link
Member

codynova commented Aug 9, 2020

Unfortunately I imagine that would be very difficult, especially since we'd need to allow passing the flag on a per-Body basis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants