Distance joint in box2dWeb-2.1.a.3.js library
A simple example of how to make a distance joint in box2dWeb-2.1.a.3.js library.
// create a distance joint between bodies bodyDef1 and bodyDef2
distanceJoint = new b2DistanceJointDef();
distanceJoint.bodyA = bodyDef1;
distanceJoint.bodyB = bodyDef2;
// connect the bodies in points relative to the local body coordinate system
distanceJoint.localAnchorA = new b2Vec2(-0.7, 0);
distanceJoint.localAnchorB = new b2Vec2(0.7, 0);
// set the frequency and damping ratio for the distance joint
distanceJoint.frequencyHz = 4.0;
distanceJoint.dampingRatio = 0.5;
// set the length of the joint
distanceJoint.length = 3;
distanceJoint.collideConnected = true;
// create the joint in the world
world.CreateJoint(distanceJoint);