schteppe / cannon.js

A lightweight 3D physics engine written in JavaScript.
http://schteppe.github.com/cannon.js
MIT License
4.67k stars 709 forks source link

Support for object sweeping/spherecasting? #253

Open JamesHagerman opened 8 years ago

JamesHagerman commented 8 years ago

I'm curious if it is possible to use cannon.js to implement some amount of spherecasting (sweeping an object along a ray and seeing what it runs into first and where the collision would occur). I know it can be done outside of cannon.js (using three.js and some legwork, for example), and I know that raycasting is often used for collision stuff...

I just don't really know enough about how cannon.js's update cycle works to build it at this point.

I'll start digging, but if there's any help, I'd love to see it!

schteppe commented 8 years ago

I'd love to see capsule casting in Cannon! But, I'm not familiar with any such algorithm. How does it work?

schteppe commented 8 years ago

Oh sorry, I meant sphere casting.. Maybe they are equivalent? (A swept sphere is a capsule)

JamesHagerman commented 8 years ago

I'm not entirely positive. I know Unity provides such functionally along with a "rigidbody sweep" to boot!

I'm pretty sure I need the functionality so I'll see what I can dig up!

On Jan 4, 2016, at 11:22 PM, Stefan Hedman notifications@github.com wrote:

I'd love to see capsule casting in Cannon! But, I'm not familiar with any such algorithm. How does it work?

― Reply to this email directly or view it on GitHub.

schteppe commented 8 years ago

Awesome!

JamesHagerman commented 8 years ago

So I know that this was put together by @toji https://gist.github.com/toji/2802287

It was based on this paper: http://peroxide.dk/papers/collision/collision.pdf

I haven't played with it enough because I don't know enough about how Cannon.js works to get a list of triangles in the physics engine. There are implementation notes at the bottom of the Gist.

That might be a good starting point...