Detailed description |
I've attached a patch with a few changes to the JavaScript code in writeWebGL(). I think there's still room for improvement in how the generated JavaScript code could be organized, but I hope this is a step in the right direction...
I was needing to be able to inspect the zoom, FOV, and "perspective" (as captured in the CanvasMatrix4 object associated with the scene) dynamically. Ideally, I was even hoping to be able to setup an observer model which would notify me in the event that the user moved around in the WebGL object. This wasn't possible in the old version of the code, so I added this functionality with the following changes:
- Create JavaScript class named %prefix%WebGL which captures the JavaScript associated with a particular exported WebGL scene without polluting the global namespace.
- Modularize the FOV, Zoom, and CanvasMatrix4 objects associated with the scene as Class variables with their own getters and setters.
- Add an observer pattern on FOV, zoom, and pan actions which will execute the provided function(s) on each event.
Perhaps in the future I'll spend some time cleaning up some of the JS code that ends up being redundant when exporting multiple prefixed WebGL objects in one page. For now, this code doesn't offer any improvements over the old version in that regard.
(My apologies, but I'm new to contributing to an SVN project -- I've attached a "patch" file, along with the full source for the two files that were modified. Please let me know if there's a better way to do this.) |
|