dojo.gfx 3d proof-of-concept implementation


This is the first proof-of-concept implementation of dojo.gfx 3d support. Just copy test3d.html to $dojo/trunk/tests/gfx/, and launch any SVG-based browser, Mozilla Firefox is preferred, and you would found a cube like this:

Cube SVG

This is a quite quick-n-dirty implementation, the Path3d class is more or less a hybrid of dojo.gfx.Path and dojo.gfx.path.Path, operations are copied from here and there with modification to meet our needs. The main contribution of this test is

  • Test case itself, we may use the same interface to manipulate the 3D objects
  • cameraTransform, the mapping of 3D space to 2D surface

We are probably inspired by this lousy implementation for its weakness:

  • Separate the 3D and 2D domain - this is essential since we want to reuse the interface as much as possible, for example, 3D space’s path syntax is the same as 2D’s with different number of arguments.
  • Move shared functions to infrastructure layer, then we can reuse it in both 2D and 3D domains
  • Move the matrix operation to dojo.gfx.matrix.3d namespace
  • Attach more meta data to the SVG DOM node, for example, original (x, y, z) path, transform, x, y, z axis’s rotation, scaling matrix for further transformation. CAUTION: this is quite computation extensive
  • Attach - this could be a big problem. When attaching a dojo.gfx object to existed SVG node, we need to differentiate the domains by using the meta data mentioned above.

I think I need to consult with my mentor for more details about refactoring.