Canvas 3d JS Library

where 3D is born!
  • rss
  • What is C3DL?
  • Download
  • Tutorials
    • Tutorial #1: Installing Canvas 3D Addon
    • Tutorial #2: A Scene and a Cube
    • Tutorial #3: Update Callback
    • Tutorial #4: Models 101
  • Development News
  • Demos
    • Typing Game V2.1
    • Typing Game V3 (0.3 Release)
    • Explorer
    • Flickr - Picking
    • Ricochet
    • FSOSS Pictures
    • Puzzler
  • Resources
  • Contact
  • About

.obj to .dae

Andor 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);

Where the parameters are defined in the file. The problem with this approach is that is introduces possible naming conflicts and is awkward to use as a model has to go through several passes just to get it into a scene. This approach is used because JavaScript can’t directly read files. The tradeoffs of parsing data this way are a bit high and we are now working on loading collada data, a .dae file which is really just xml. The parsing will be slower, but the process of getting a model into a scene will be more intuitive and less work on the user’s side as they will only have to do minimal conversion.  If they have an asset in another format, they can convert it.  But this is something we pretty much can’t avoid.  Even if we decided to use another format, we would have to jam it inside an xml file and that would just be awful.  We might as well use a standard that’s not only supported by many authoring tools, but also web-friendly.

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();

model.init(“car.dae”);

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.

Categories
c3dl development
Comments rss
Comments rss

« Road Segment The Matrix Stack »

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Search

Demos

  • Explorer
  • Flickr - Picking
  • FSOSS Pictures
  • Puzzler
  • Ricochet
  • Typing Game V2.1
  • Typing Game V3 (0.3 Release)

C3DL Development News

Portable Canvas v0.2!

Portable Canvas version 0.2 is available!!

It is now a usable browser, but restricted to pages on c3dl.org only. It can display canvas elements right out of the box, and doesn’t require anything else to be on your system (not even FF3!)*. It’s only been tested on Windows XP, but in theory it should be easy [...]

Namespaces and const

As our library expands with more functions, classes and global variables, the need for namespacing increases.  I started placing code in a C3DL namespace when I wrote the matrix stack operations.  However, yesterday I was looking in the constants.js file and saw the ‘tolerance’ variable.  It’s a const variable used when comparing floats to check [...]

Tutorials

  • Tutorial #1: Installing Canvas 3D Addon
  • Tutorial #2: A Scene and a Cube
  • Tutorial #3: Update Callback
  • Tutorial #4: Models 101

Archives

C3DL Development News

Recent Comments

  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • Portable Canvas v0.2!
  • Namespaces and const
  • DAE Scenegraph
  • The Matrix Stack
  • .obj to .dae
  • 0.5 Release and Other News!
  • Tracemonkey performance
  • More memory usage improvements
  • Canvas3D crashes in tracemonkey
  • Patched one hole in floating text
  • For name spaces, my... - Jeremy Giberson
  • Great! Really really... - Edson Mattos
  • Beautiful!... - Funtomas
  • Was no need to conta... - Andrew Smith
  • Andrew, have you con... - Funtomas
  • Thanks for posting t... - Andrew Smith
  • Vlad was in town and... - Cathy Leung
  • the upside down issu... - Cathy Leung
  • Got it! the addon is... - Bill Mill
  • Yes it does. The ad... - Cathy Leung



Canvas 3d JS Library

©2007- 2008 Canvas 3d JS Library

Disclaimer: This website is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 Canada License.
The Canvas 3d JS Library and Demos found on this website are licenced under the MIT License

Creative Commons License