- Advance Test/Debugger Page
- 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
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();
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.
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?
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.
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.
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!
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