Cannon.js – Want to steer a car?? Then you need to make the HingeConstraint update-able

Hi…

 

I am playing around with Three.js and Cannon.js. Making my little car steerable needed to be able to update the characteristics of the hinge constraint during the runtime. What you need to do is the following:

Within the cannon.js file, locate the HingeConstraint constructor and add the follwoing lines of code:

With this, you can steer your car around…

CU

0xff

 

Rotating a Vector by means of a Quaternion

Hi…

using cannon.js I needed to rotate some bodies (otherwise the wheels fly onto the body of a car during the first few moments of your scene)… the following code rotates a vector by using a quaternion. More insights into quaternions you can find here

http://math.stackexchange.com/questions/40164/how-do-you-rotate-a-vector-by-a-unit-quaternion

Have fun…

CU

0xff