SCM

[#4877] Use more object-orientation in WebGL objects to support more interaction

Date:
2013-09-02 21:36
Priority:
3
State:
Closed
Submitted by:
Jeff Allen (trestletech)
Assigned to:
Nobody (None)
Component:
None
Version:
None
Resolution:
Awaiting Response
Summary:
Use more object-orientation in WebGL objects to support more interaction

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.)

Comments:

Message  ↓
Date: 2015-02-05 10:55
Sender: Duncan Murdoch

This is mostly implemented in the R-forge version now, following your design. I'll likely fine-tune the details; comments (and bug reports) would be welcome.

Date: 2015-01-28 19:26
Sender: Duncan Murdoch

I'd forgotten about this suggestion and patch, but have started implementing something that achieves similar aims in a different way. Yours is probably better Javascript code than mine, so I may come back to your approach, but there have been too many changes to writeWebGL since 2013 to apply your patch directly.

Date: 2013-09-03 00:28
Sender: Jeff Allen

(One minor bug: line 1402 in webGL.R should read:
for (var i = 0; i < this.fovCallbacks.length; i++){

Not sure how to update the patch on R-Forge, unfortunately..

Attached Files:

Attachments:
Size Name Date By Download
9 KiBwebgl-class.patch2013-09-02 21:36trestletechwebgl-class.patch
50 KiBwebGL.R2013-09-02 21:36trestletechwebGL.R
323 bytestemplate.html2013-09-02 21:36trestletechtemplate.html

Changes

Field Old Value Date By
status_idOpen2015-02-05 10:55murdoch
close_dateNone2015-02-05 10:55murdoch
File Added1660: webgl-class.patch2013-09-02 21:36trestletech
File Added1661: webGL.R2013-09-02 21:36trestletech
File Added1662: template.html2013-09-02 21:36trestletech
Thanks to:
Vienna University of Economics and Business Powered By FusionForge