#Custom shape in cannon es
15 messages · Page 1 of 1 (latest)
in theory cannon-es can have convex polyhedrons which is a closed hull basically, i only have a react example https://codesandbox.io/s/08s1u but it's essentially this:
/**
* Returns legacy geometry vertices, faces for ConvP
* @param {THREE.BufferGeometry} bufferGeometry
*/
function toConvexProps(bufferGeometry) {
const geo = new Geometry().fromBufferGeometry(bufferGeometry);
// Merge duplicate vertices resulting from glTF export.
// Cannon assumes contiguous, closed meshes to work
geo.mergeVertices();
return [geo.vertices.map((v) => [v.x, v.y, v.z]), geo.faces.map((f) => [f.a, f.b, f.c]), []]; // prettier-ignore
}
the problem is that it's really slow, and i think it's fair to say that the library is probably too old for this. i'd just use a cube,
i need the chains to be interconnected
its a peice of a chain
can i use multiple box shapes to form this
more or less, try "sphere chain" https://pmndrs.github.io/cannon-es/examples/constraints
but interlinked i don't think so. try convex and see if it works. otherwise, in rapier this would easily be possible.
actually i am making it for mobile browsers
which physics engine is most optimised for that
at this point rapier is probably the fastest. but whatever you pick, you can be certain that cannon is the slowest. especially when it comes to convex hull shapes. in your case you would need a trimesh anyway, im not sure if cannon supports that.
just tried it in rapier, there it seems easy https://codesandbox.io/s/gallant-grass-e1dz3b?file=/src/App.js
thanks a lot