chandlerprall / GoblinPhysics

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

How to make sphere rotate when moving? Automatic or do I implement?? #40

Closed Druidhawk closed 9 years ago

Druidhawk commented 9 years ago

All, If I have a physics sphere and I hit it a glancing blow I would expect that the sphere would roll/rotate across the ground. What is the correct way to set this up and also make the associate threejs mesh rotate.

chandlerprall commented 9 years ago

Can you give an example of what you have so far to show how it isn't working as expected?

Druidhawk commented 9 years ago

Well several things show up. I am working a test scene, with different shapes etc. If I have a sphere lying on a plane, and I shoot a physics ball at it (moving with velocity) the expected collision and bounce of the two shapes occurs. I was expecting a glancing collision to introduce a rotation in both shapes since the impact is not dead center. Also when a shape falls off an edge, such as a box sliding off a box. The upper box slides over its entire bottom and falls directly down the Y axis. In a real situation the top box would start falling, rotating, as its center of mass pass the edge of the bottom box. Hope that makes sense.

On a side note, sometimes when i drop a cylinder, from a higher Y position with only gravity as a force, on a flat plane it 'skitters' across the surface of the plane for some reason.

Druidhawk commented 9 years ago

So the lack of rotation was my fault by not updating threejs shape quaternion while updating three js shape position