Monday, July 2, 2012

Upgrading to Gladius 0.2

‹prev | My Chain | next›

I had my first go at binding keys to Gladius events last night. My approach was very much that of a web developer, not a Gladius developer (using document.addEventListener() instead of gladius-input). Before trying the Gladius way, I think this is a good time to upgrade from version 0.1 that I have been using to the newer 0.2.

I have a local copy of the Gladius repository, so I merge the most recent changes on GitHub into my local copy. I copy the updated and new Gladius files into my "gladius-my" example/testing repository:
➜  scripts git:(gh-pages) cp ../../gladius/gladius-* .
(I really cannot wait until Dart packages become the norm)

I reload my planetary retrograde simulation to find a blank page and the usual JavaScript console output:
CubicVR Log: Calibrated maximum lights per pass to: 8 
These early versions of Gladius have the annoying habit of silently swallowing errors and it seems that this is another case. The tried-and-true technique of console.log("here") eventually tells me that the the problem is at the very outset of my game() function. Specifically, the Space class is no longer declared as:
  function game( engine, resources ) {
    var space = new engine.simulation.Space();
    console.log("here");
    // ...
  }
Instead, the Space class is now a top-level namespaced class and has been renamed as SimulationSpace. Making the change in my game() function gets me past that error:
  function game( engine, resources ) {
    var space = new engine.SimulationSpace();
    // ...
  }
I still see a blank page and no JavaScript console errors, however.

It also seems that engine.Simulation.Entity has been mercifully shortened to engine.Entity, meaning that things like:
    var sun = new engine.simulation.Entity( "sun",
      [
        new engine.core.Transform(),
        new cubicvr.Model( resources.mesh, resources.sun_material )
      ]
    );
Are now written as:
    var sun = new engine.Entity( "sun",
      [
        new engine.core.Transform(),
        new cubicvr.Model( resources.mesh, resources.sun_material )
      ]
    );
I am always happy when a breaking API change results in fewer characters. So I make that change as well and my solar system simulator is again working, this time on Gladius 0.2:


I am eager to begin playing with some of the newer and better documented features of Gladius, but I call it a night here. I have much scheming that won't scheme itself.


Day #435

No comments:

Post a Comment