Canvas 3d JS Library

WebGL made easy!
  • rss
  • What is C3DL?
  • Download
  • Tutorials
    • Tutorial #1: WebGL Browsers
    • Tutorial #2: A simple scene
    • Tutorial #3: Callback
    • Tutorial #4: Models
    • Tutorial #5: Light effects
    • Tutorial #6: Picking
    • Tutorial #7: Materials
    • Tutorial #8: Particle Systems
    • Tutorial #9: Camera Basics
    • Tutorial #10: Advanced FreeCamera
    • Tutorial #11: OrbitCamera
    • Tutorial #12: Advanced Camera Functions
  • Development News
  • Documentation
  • Community
  • Resources
  • Contact
  • About
  • Advance Test/Debugger Page
    • http://matrix.senecac.on.ca/~pplam3/OSD/canvas3dapi-dev/test.html
  • Basic Demo Page
    • http://matrix.senecac.on.ca/~pplam3/OSD/canvas3dapi-dev/testDemo.html
There are definitely still some performance issue with the collision detection, so you might notice some lag in the “Basic Demo Page”.

The “Advance Test/Debugger Page” is more for my testing usage, but you’re still welcome to test out some functions with it. Instructions/walkthrough of how to use this page will be posted on the test page itself later. The project started out pretty smoothly. Just looking back at what I’ve done so far, it looks like I’ve done a lot:
  • Created flag for models to have collision detection
    • Created set/get functions for flag
  • Created function for bounding sphere for models
    • Returns array of 2: Sphere Position (array of 3), Sphere Radius (float)
  • Enable callback to check for collision detection when updating scene
  • Performed initial test for collision
    • Check flags
    • Check for bounding sphere collision with out models with flags on
      • Collision – distance of two bounding sphere’s position is less than the sum of the radius of both sphere
But then, what I’ve got to do after is a lot more. I still have to check to make sure the path of objects don’t pass each other during the duration of the update (tunneling test). When these are done, I have to actually do the collision tests with the actual objects instead of just their bounding spheres. It really makes me feel like I’ve only touched the tip of an iceberg. Today I began my usual day on irc when someone posted the following link for me: http://arstechnica.com/news.ars/post/20090121-smil-animation-and-3d-canvas-library-for-firefox.html It took me a moment to recover because I had not thought that too many people had been following our progress.  It is good to see that there are others out there that are interested in what we are doing.   As mentioned in the article, one of the major issues is the Canvas 3D extension is still highly experimental and can be quite finicky in terms of where it works.  One of my colleagues, Chris Tyler, has often remarked that he couldn’t get it working on his Linux system.  I think that some of these issues will eventually resolved.   Vlad had mentioned that he is working on a new version of the extension for firefox 3.1 which will include a feature for optional software only rendering.  Given that some of the issues are often driver/video card related, this new version may allow the extension to work on more platforms.

Tutorials two and three have been updated to work with the new c3dl namespaces. Both tutorials now also use collada models (of a duck) instead of the Cube object. Cube is considered deprecated and will most likely disappear in a future version of c3dl.

You can find all of our tutorials here:

http://www.c3dl.org/index.php/tutorials/

I have spent the last couple of days placing our entire library inside the ‘c3dl’ namespace, which will prevent name conflicts with other scripts. This change spans across the entire library, but upon our next release, it should be simple for users to adjust to the change. Users will have prefix every c3dl specific code with ‘c3dl’. That probably sounds like a whole lot, but it will typically only be needed on instantiation. For example, if a user needs to create a camera:

// old way
var cam = new FreeCamera();
// new way.  
var cam = new c3dl.FreeCamera();

I had some trepidation prior to placing everything inside what is essentially an object in JavaScript. My main concern was will jsdocToolkit know that c3dl is really a namespace and FreeCamera is an object? At first it didn’t seem so, but after playing around with the documentation tags, I managed to get it to output the correct documentation. Admittedly, the documentation still needs work, but it’s on its way.

Log Changes

In addition to the namespacing changes, I also changed the behaviour of the logging system. Users were not likely using those functions, so they wouldn’t need to change anything. The logging system is now an object, ‘debug’. This I took from Jeremy’s debug.js file and I integrated our own logging system which creates div elements inside the page. When a user runs a script and an error or warning is generated, the message will be placed on the page. If the user is running firebug, the message will also be appended inside the console.

Vector Changes

From what I can remember, we took apart the Vector class and instead placed a set of functions in the vector.js file because it was supposed to increase performance.

// This is what we had when the project began. 
//vec is a reference to a Vector object.
var vec = new Vector();
// current way. vec is a three element array.
var vec = makeVector();

With the namespace changes, I have essentially just placed all these vector functions back into an “object”, the c3dl namespace. So should we just change the Vector functions back into a class?

Constant Changes

There are a bunch of constants that also had to be placed under c3dl. However, namespacing and the const keyword causes issues. Instead, we are using Jeremy’s suggestion of creating a const namespace within c3dl.

// all constants are now take the form,
c3dl.const.TOLERANCE
c3dl.const.FIELD_OF_VIEW
// etc.

The variables of course aren’t really constant because of this fake const. However, by using this method, we are stating to the users we will not change these variables in the library.

More Changes!

As additional files are added to the library, there seems to be a growing need for more organization. Thus, I began creating directories and placing appropriate files within them. Matrix.js, Vector.js, Quaternion.js and mathhelper.js are now all under a math directory. Light classes are in a light directory and the same goes for cameras. I think this makes the library much more neat.

Final Thoughts

The change was time consuming and tedious, but I think the overall result is definitely worth it. I went back to some of my scripts including recent ones and older ones and tested them. Every once in a while I found a stray function not in the namespace, which I then fixed. So there may be some functions I missed, However they should all be found before the release.

I want to thank Jeremy, I believe he was the first to suggest the idea of using a namespace. He has also helped us quite a bit in terms of working with JS instead of against it!

Next Steps

Our team will have to decide if we will revert to using to using Vector and Matrix objects.

I will be returning to the light classes to finish up the code and documentation and of course test it all out

Videos

Demos

  • Asteroids-3D
  • RTS Prototype
  • Particle Systems Demo
  • Cross-Browser Orbiter
  • Mocap Demo With Spheres
  • Google Maps-3D

C3DL Development News

A spec change that keeps coming back to haunt me

At some point, the way firefox handles keyboard events changed. I’m not sure exactly when it happened, all I know is that it broke how I was dealing with keyboard interaction on almost every demo I’ve written (for example,the mocap demo and MotionView). When I wrote the demos, the keydown event would be fired once, [...]

Release 2.2

The 2.2 Release of the Canvas 3D Library includes a number of new features, updates to old features and fixes for several bugs along with the requisite changes to meet the evolving WebGL spec. Some of the things included (in no particular order) are: Better picking code. The ability to swap textures as a scene [...]

Tutorials

  • Tutorial #1: WebGL Browsers
  • Tutorial #2: A simple scene
  • Tutorial #3: Callback
  • Tutorial #4: Models
  • Tutorial #5: Light effects
  • Tutorial #6: Picking
  • Tutorial #7: Materials
  • Tutorial #8: Particle Systems
  • Tutorial #9: Camera Basics
    • Tutorial9-YawPitchRoll
  • Tutorial #10: Advanced FreeCamera
  • Tutorial #11: OrbitCamera
  • Tutorial #12: Advanced Camera Functions

Documentation

Archives

Archives

C3DL Development News

Recent Comments

  • June 2011
  • March 2011
  • October 2010
  • July 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • A spec change that keeps coming back to haunt me
  • Release 2.2
  • 2.1 Release and things to come
  • Level Up! An Open Web Game Jam
  • Site moved!
  • SceneCreator0.3
  • WWW2010 in Raleigh
  • Motionview
  • On the train to Mountainview
  • C3DL 2.0-WebGL and beyond
  • That depends on what... - peter
  • This application is ... - Haisens
  • I think that example... - peter
  • The above links are ... - Atash
  • Hi there, just wante... - Patrick H. Lauke
  • Firefox 4 was releas... - Cathy Leung
  • In order to access l... - peter
  • I am not able to dis... - preksha
  • "JavaScript can’t di... - Joe Hocking
  • I should point out t... - peter



Canvas 3d JS Library

©2007- 2010 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