Examples: include example code of importing a HCAD convex hull from a GLTF file
See original GitHub issueHello, Thanks for maintaining cannon!
I have an error when I create ConvexPolyhedron, I must miss something
I have a few errors when creating a ConvexPolyhedron Body :
cannon-es.js:2247 .faceNormals[0] = Vec3(0,0,-0.9999999999999999) looks like it points into the shape? The vertices follow. Make sure they are ordered CCW around the normal, using the right-hand rule.
My process :
- Loading a mesh with a buffer geometry from an HCAD convex decomposition
- I retrieve the faces & vertex to create the cannon body
Code :
CreateConvexPolyhedron(geometry, scaleVec) {
if (!geometry.vertices) {
geometry = new THREE.Geometry()
.fromBufferGeometry(geometry)
.scale(scaleVec.x, scaleVec.y, scaleVec.z)
geometry.mergeVertices()
geometry.computeBoundingSphere()
geometry.computeFaceNormals()
}
const points = [],
faces = []
points = geometry.vertices.map(function (v) {
return new CANNON.Vec3(v.x, v.y, v.z)
})
faces = geometry.faces.map(function (f) {
return [f.a, f.b, f.c]
})
return new CANNON.ConvexPolyhedron({ vertices: points, faces })
}
Help would be more than welcome 😃
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:16 (5 by maintainers)
Top Results From Across the Web
Prototype GLTF importer and convex hull collision detection
It's designed to convert GLTF files to HMD as part of resource processing. A 3D convex hull generator and GJK/EPA collision detection algorithm....
Read more >Convex Hull using Divide and Conquer Algorithm
A convex hull is the smallest convex polygon containing all the given points. Recommended: Please solve it on “PRACTICE” first, before moving ...
Read more >How to properly import and setup physics objects - GLTf
I'm trying to import a mesh from a GLTF file and turn it into a rigid body - physics object. I have the...
Read more >cannon-es - bytemeta
Examples : include example code of importing a HCAD convex hull from a GLTF file. patreeceeo. patreeceeo OPEN · Updated 1 year ago ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve got this bug with the generated body though, do you think it’s related to the way I’m making the convex polyhedron ? Bodies constructed from primitives behave normally ( they don’t jump wildly when colliding ). In this scene the sphere, the box and the convex polyhedron have a mass of 1 and use the same material.
https://user-images.githubusercontent.com/46470486/107856840-4b3efb80-6e2b-11eb-8bd9-6de604ac52db.mp4
@marcofugaro
I came up with this :
No idea if it’s optimal, I’m just starting with cannon.js. Thank you for maintaining this fork btw !