three-to-cannon icon indicating copy to clipboard operation
three-to-cannon copied to clipboard

Support CANNON.Heightfield

Open donmccurdy opened this issue 8 years ago • 3 comments

Relevant to this thread: http://www.html5gamedevs.com/topic/24944-cannonjs-heightfield-from-imported-mesh/

Some discussion here: https://github.com/schteppe/cannon.js/issues/221

And several github issues:

  • https://github.com/donmccurdy/aframe-extras/issues/41
  • https://github.com/donmccurdy/aframe-physics-system/issues/9

Also, docs could be improved per cannon issue 222.

donmccurdy avatar Dec 11 '16 18:12 donmccurdy

@donmccurdy I created a Heightfield shape for the environment component https://github.com/feiss/aframe-environment-component/pull/24 The environment component uses a THREE.PlaneGeometry where we modify the z of all vertices. I don't think we can generalize the work I did to put in three-to-cannon, but anyway it can inspire others.

vincentfretin avatar Oct 09 '17 18:10 vincentfretin

@vincentfretin that's great!

I agree it probably doesn't generalize to support any Mesh (I'm not planning to solve that case, at this point) but it would be helpful if three-to-cannon was able to do:

var shape = mesh2shape(object3D, {type: mesh2shape.Type.HEIGHTFIELD});
// succeeds if object3D contains exactly 1 PlaneGeometry, else returns null and logs error

I'd be glad for a PR doing just that, if you're interested. 🙂

donmccurdy avatar Oct 14 '17 20:10 donmccurdy

Hey, you're right, I'll probably do that. This way I won't put lots of changes in the environment component and I'll probably do an option to enable the heightfield, disabled by default.

vincentfretin avatar Oct 15 '17 15:10 vincentfretin