question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Simplify ConvexPolyhedron creation

See original GitHub issue

Hey, 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

dice 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:open
  • Created 2 years ago
  • Comments:27 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
Dannie226commented, Dec 28, 2021

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.

3reactions
rogerscgcommented, Jan 8, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CGAL: Simplify convex polyhedra in 3D - Stack Overflow
I have been using the cgal library to generate convex hulls which are further used for discrete element simulations. Currently, I am trying...
Read more >
17.12 Simplifying Polygons
– The simplest simplification is the convex hull of the object's vertices (see Section 17.2 (page 568)). The convex hull removes all internal...
Read more >
Polyhedron Generator - PD
A simple polyhedron generator.
Read more >
Algorithm to simplify 2D convex hull at the cost of extra area
Consider the triangular areas we add to the polygon. To make the definition easier, let's call the line which defines the p0 edge...
Read more >
Polyhedron Realization for Shape Transformation - Technion
The vertex– neighborhood graph of each convex polyhedron, created in the process, is isomorphic to a graph encountered during the simplification stage.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found