.obj to .daeAndor Salga | 8 October, 2008 | 12:59
One aspect of the library which can use improvement is loading Models. Currently, to load a model, one would have export an asset to a .obj format from an authoring tool then run the file through a converter. The converter reads the vertices, normals, etc and writes them out to a .js file. That file simply contains the arrays need to load the model. That file is then imported into an html file as a js resource and the variables from the file are ready to be used. So a model can be created as such:
Var model = new Model();
model.init(sphereVerts, sphereNormals, SphereTex, sphereFaces);
When deciding which format to support for model loading, we rejected collada because it appeared unacceptably slow. It turns out it was the script itself and not something in the .dae which was slowing it down. So now our model initialization becomes:
var model = new Model();
Inside the car.dae is a reference to a texture, which the parser will take care of loading and applying to the geometry. It makes creating models easier, but more complicated in the library. The collada file actually contains a scene graph and writing one in JS is a bit intimidating. Nonetheless, it must be done for proper support.