#Custom shape in cannon es

15 messages · Page 1 of 1 (latest)

left meteor
#

Hey all need a help on cannon-es , how to create a shape for the attached image

steep delta
#

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
}

Using cannon collisions with GLTFs converted into convex hulls.

left meteor
#

thanks a lot

#

will try this

steep delta
#

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,

left meteor
#

i need the chains to be interconnected

#

its a peice of a chain

#

can i use multiple box shapes to form this

steep delta
#

but interlinked i don't think so. try convex and see if it works. otherwise, in rapier this would easily be possible.

left meteor
#

actually i am making it for mobile browsers

#

which physics engine is most optimised for that

steep delta
#

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.

left meteor
#

thanks a lot