Simplify ConvexPolyhedron creation
See original GitHub issueHey, First of all, this is a duplicate issue from another repository (three-to-cannon) that seems like to be not related to it at all. I used three-to-cannon first, then I switch for another method manually, both gave me the same results.
The error
Uncaught TypeError: Cannot read property 'x' of undefined at Vec3.copy (cannon-es.js:915) at ConvexPolyhedron.clipFaceAgainstHull (cannon-es.js:2593) at ConvexPolyhedron.clipAgainstHull (cannon-es.js:2335) at Narrowphase.convexConvex (cannon-es.js:11067) at Narrowphase.getContacts (cannon-es.js:10759) at World.internalStep (cannon-es.js:12774) at World.step (cannon-es.js:12650) at animate (index.js:149)
I’ve been getting this error when two bodies with the hull settings collide with each other. My knowledge about geometries is pretty low, so I don’t really understand what is happening. I found this (https://github.com/schteppe/cannon.js/issues/459) in the CannonJS issues tab, might be useful.
Edit: I forgot to say that I merged the vertices as user “Dannie226” said, and it didn’t change the problem, so I’m assuming that the fact that I’m using cannon-es is the whole reason it didn’t solved it.
Any help would be greatly appreciated!
Issue Analytics
- State:
- Created 2 years ago
- Comments:27 (6 by maintainers)
Top GitHub Comments
Apparently it doesn’t support .js files, so I had to zip it, but here it is. As I said above, I am mainly a JS developer because I cant download the tools for TS, so that is what the file is written in, so I hope that isn’t too much of an inconvenience. But, I have used this multiple times, and it works, and there is also a convenience static method in it for automatically creating the hull, and returning the faces. Cheers. QuickHull.zip
Edit: Formatting for the functions. The first parameter in all of the vector math functions are a target parameter (except for the ones that don’t actually change a vector), and then the other parameters are for whatever math is wanting to be done. And it always returns the target vector.
I’ve been trying to work on something like this for some time. Even when using ConvexGeometry from Three.js, I get errors along the lines of
<vector> looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right hand rule.
This in an incredibly frustrating part of the library. Would love to see some development here.