shiffman/The-Nature-of-Code-Examples-p5.js — pull request #26 by jihyunlee (2014-08-30 05:31:04+00:00)
Title: using box2d-html5.js (Box2D v.2.3.0)

Hi Dan!

More details/comments about this commit.

- no more translateToWorld / translateToPixels. only use scaleToWorld / scaleToPixels.

- sometimes.. simplified use of box2d method causes problems. So use full path of methods.
For example, use 'box2d.b2Vec2' instead of 'var Vec2 = box2d.b2Vec2'. One of the cases can be comparison of type. When I used var RevoluteJoint = box2d.b2RevoluteJoint; and then tried to use box2d.b2Joint.Create with the RevoluteJoint, "RevoluteJoint" will become 'null' in the following line of code. But it is ok with full version, box2d.b2RevoluteJoint.
b=new box2d.b2RevoluteJoint(a instanceof box2d.b2RevoluteJointDef ? a:null);

- I like the Draw method. I think it might be good for debugging. If you have a chance, please take a look at the box2d-helper.js.

- In the box2d-helper.js, I copied your scale methods and tweaked them a little bit -- adding comparison with 'undefined' and adding return newv; in the second if else statement in the scaleToPixels function.

- I added two lines of code to the original box2d-html5.js. I tweaked because it raises errors when I run the mouseJoint example. Just let you know...
I added if("undefined"==typeof a) a=new box2d.b2Vec2(); to both following methods:
box2d.b2MouseJoint.prototype.GetAnchorA and box2d.b2MouseJoint.prototype.GetAnchorB. And then all examples work fine.

Let me know if you have any questions :)
Hope this helps,
Jihyun