chandlerprall / GoblinPhysics

Collision Detection & Response in JavaScript
http://www.goblinphysics.com
Other
147 stars 18 forks source link

Three.js example? #68

Closed trusktr closed 7 years ago

trusktr commented 7 years ago

Would you mind making a small example of using Goblin with Three.js?

chandlerprall commented 7 years ago

All of the examples - except Raytracer - use Three.js

trusktr commented 7 years ago

Oops, I missed the exampleUtils. I was looking at the html files and thought that that was showing the Goblin API and that it used its own rendering behind the scenes.

Thanks!

I'm looking at various physics engines, and I'm noticing a pattern: the end user has to create two parallel trees. For example, in your exampleUtils, you create the Three.js scene graph tree, and on every node you attach the goblin body which composes the second Goblin world tree. Then, the end user has to make sure to sync positions from the physics tree to the visual tree.

I myself am making a 3D library (planning to add WebGL soon, but currently just CSS3D). I'm debating on how I want to implement physics: should the end user create a single tree with physics integrated, which may be easier to reason about and work with, or should I make the end user make two trees which is more complicated and more work.

One of my goals is to make the API as easy as possible to use.

chandlerprall commented 7 years ago

Your observation about the two trees + syncing is correct. I have another project called Physijs which adds physics to Three.js as a plugin, the v2 branch uses Goblin - this is actually why I started Goblin in the first place.