Here's what the output looks like:
Try It Yourself
Render a REYES bumpy sphere in your browser.
And the source is here: http://code.google.com/p/reyes-dart/
Translating C++ to Dart
It was pretty easy to translate the original code from C++ to Dart.
- The original code made use of classes and overloaded operators, both of which are also in the Dart language.
- The original code used the SDL library to display output. It was easy to switch to the HTML5 CANVAS tag.
I used an early version of the "Dart Editor" IDE. The Dart Editor IDE was helpful because of the compiler warnings and errors.
I used a variety of techniques to debug the code:
- write() This is a utility function I wrote that appended the argument text to the document body of my HTML document. This has several advantages over "print":
- Easier to see output during development.
- Much easier to search and copy/paste large amounts of text.
- Dumping 3D geometry as text. At one point I wanted to check whether or not my geometry was correct. The easiest way to check it was to dump the geometry out as a 3D text file using "write()", and then copy-and-paste that code into a file and view it in the blender3d.org Blender app.
- Using Chrome to step through the compiled app.js code. This was pretty painful, but was occasionally useful. The stack crawls for exceptions usually gave good hits as to what was going wrong.
- The Dart "dom" library is not yet complete. Currently it can't write to canvas imageData. As a work-around I draw each pixel of output as a little filled rectangle.
Dart Editor Limitations
I wish the Dart Editor would support:
- Formatting code.
- Stripping whitespace from ends of lines on save.
- Converting tabs to spaces on save.