xtk/X — pull request #125 by swederik (2013-05-26 20:37:23+00:00)
Title: Support for Compressed Triangle Meshes (.ctm)

Hello!

This PR adds support for CTM meshes into XTK. Why? Because

> ...using efficient entropy-reduction techniques, combined with state of the art entropy coding (LZMA). An STL file can usually be compressed to 5-6% of its original size.

Yes, you read that correctly. **Meshes can be downloaded 20x faster in CTM format**. In my tests so XTK will parse and render the file only about 2x slower than an STL.

An example with three.js:
http://alteredqualia.com/three/examples/webgl_loader_ctm_materials.html
An example with js-openctm and some webgl:
http://www.inmensia.com/files/ctm/demo/demo.html

An demo gist for loading a CTM mesh can be found here (thus far I still need to include the lzma.js script):
https://gist.github.com/swederik/5653223

The cross-platform command line tool "ctmconv" (http://openctm.sourceforge.net) can be used to convert an STL to a CTM (but seems to break for ASCII files). Meshlab (http://meshlab.sourceforge.net) can also save them.

This is a work-in-progress. Some current caveats:

* Altering the request in loader.js seems a bit weird, but I couldn't find a better alternative, since the js-openctm library wants a string, rather than an ArrayBuffer.
* I just copy/pasted the js-openctm (http://code.google.com/p/js-openctm/) library and replaced CTM with X.parserCTM, since I don't really know where to put the variables (e.g. CTM or LZMA) to make XTK build properly
* Files with included normals are untested so far, despite the loops being set up.
* Haven't tried to incorporate UV maps or vertex colours at all.

I'm very new to javascript so give me some slack if this is all totally wrong.