Javascript load recommendation

General discussion about the R.U.B.E editor
Post Reply
mcylinder
Posts: 2
Joined: Mon May 13, 2013 1:39 pm

Javascript load recommendation

Post by mcylinder » Mon May 13, 2013 1:48 pm

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.

iforce2d
Site Admin
Posts: 860
Joined: Sat Dec 22, 2012 7:20 pm

Re: Javascript load recommendation

Post by iforce2d » Tue May 14, 2013 8:57 am

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();

mcylinder
Posts: 2
Joined: Mon May 13, 2013 1:39 pm

Re: Javascript load recommendation

Post by mcylinder » Tue May 14, 2013 1:14 pm

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.

Post Reply