Page 1 of 1

Javascript load recommendation

Posted: Mon May 13, 2013 1:48 pm
by mcylinder
I'm looking to see if anyone has a minified javascript loader for a standalone render. I've been deconstructing the testbed.js but wanted to better understand the logic. Essentially wanted to get away from the testbed setup and have a stand alone representation of the javascript.

Re: Javascript load recommendation

Posted: Tue May 14, 2013 8:57 am
by iforce2d
The loadrube.js is pretty much what you're talking about I think. It depends on box2dweb.js of course, so it's not entirely standalone.
To the goal of understanding the logic, I'm not really sure how a minified version would help. Did you mean non-minified? These are included in the trial download of RUBE, or you can see them at:
http://www.iforce2d.net/rube/loaders/ja ... ox2dweb.js
http://www.iforce2d.net/rube/loaders/ja ... oadrube.js

But the place where things get kicked off from is the createWorld function in this file:
http://www.iforce2d.net/rube/loaders/ja ... testbed.js

One of the tests in the "tests" folder will be created in a somewhat cryptic manner by this:

Code: Select all

eval( "window['currentTest']= new "+v+"();" );
...which will evaluate to something like this:

Code: Select all

window['currentTest'] = new jackinthebox();

Re: Javascript load recommendation

Posted: Tue May 14, 2013 1:14 pm
by mcylinder
I wasn't very clear. I was looking for a boilerplate script as a dedicated shell for loading a single RUBE file. Your suggestion

Code: Select all

window['currentTest'] = new jackinthebox();
was a big help. I took the testbed script and started stripping out anything that had to do with the functions dedicated to testing a script. Keeping only the ones that are needed to render a box2d world. Using a development paradigm I wanted to go from "production" to "live" so to speak.
Thanks for the suggestion.