Class Index | File Index

Classes


Class c3dl.Scene

A Scene should be thought of as a scene on a movie set. A scene would typically contain objects which are moving and a current camera, lights, etc.
Defined in: scene.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
addLight(light)
Adds a light to a scene if the maximum number of lights in the scene has not been exceeded.
 
Add the object 'obj' to the scene.
 
Get the ambient light of the scene.
 
Get the color of the background.
 
Get the camera of the scene.
 
Return the canvas
 
Get the number of frames rendered in the last second.
 
Get the context.
 
getLight(lightName)
Get a reference to a light from the list in the scene.
 
getObj(indxNum)
Get a reference of a particular object in the scene.
 
Get the number of objects in the scene.
 
Get the function which will be called when the user clicks on the canvas.
 
Get the type of test which will run when a user clicks on the canvas.
 
 
Get how the points are rendered in the scene.
 
Get the size of the spheres when they are rendered as points.
 
If point smoothing is on, points are rendered as circles, otherwise they are rendered as squares.
 
Get the scene's Renderer
 
Get the Scene.
 
Get the SkyModel.
 
init()
Acquire the OpenGL Context
 
removeLight(lightName)
Remove a light from the scene.
 
Remove an object from the scene.
 
Set the ambient light of the scene.
 
Set the color of the background.
 
setCamera(cam)
Set the Scene's camera.
 
setCanvasTag(canvasTagID)
 
setKeyboardCallback(keyUpCB, keyDownCD)
Set the functions to call when a key is pressed or released.
 
setMouseCallback(mouseUpCB, mouseDownCB, mouseMoveCB, mouseScrollCB)
Pass in the functions to call when mouse event occur such as when a button is pressed, released or the mousewheel is scrolled.
 
setPickingCallback(pickingHandler)
Tell the scene what function to call when a user clicks on the canvas.
 
If the scene has been provided with a picking callback, when the user clicks the canvas either one or two sets of tests will run.
 
Set how the points attenuate for this scene.
 
Set how c3dl.Point objects are rendered.
 
Sets the point size when rendering points as spheres.
 
If point smoothing is on, points are rendered as circles, otherwise they are rendered as squares.
 
setRenderer(renderType)
Set the renderer used to render the scene.
 
Set the SkyModel.
 
Set the function to call everytime the scene is updated.
 
Start scene sets a default ambient light to white with full intensity.
 
Flags the main loop for exit.
Class Detail
c3dl.Scene()
Method Detail
{boolean} addLight(light)
Adds a light to a scene if the maximum number of lights in the scene has not been exceeded.
Parameters:
{c3dl.PositionalLight|c3dl.DirectionalLight|c3dl.SpotLight} light
the light to add.
Returns:
{boolean} true if the light could be added, otherwise returns false.

{boolean} addObjectToScene(obj)
Add the object 'obj' to the scene.
Parameters:
{c3dl.Primitive|c3dl.ParticleSystem|c3dl.Point|c3dl.Line} obj
A reference to an object.
Returns:
{boolean} True if the object was added to the scene, false otherwise.

{Array} getAmbientLight()
Get the ambient light of the scene.
Returns:
{Array} An Array of 3 values in the order RGB.

{Array} getBackgroundColor()
Get the color of the background.
Returns:
{Array} Array of three values in the order RGB.

{Camera} getCamera()
Get the camera of the scene.
Returns:
{Camera} The camera of the scene.

getCanvas()
Return the canvas

{float} getFPS()
Get the number of frames rendered in the last second.
Returns:
{float} the number of frames rendered in the last second.

{Context} getGL()
Get the context.
Returns:
{Context}

getLight(lightName)
Get a reference to a light from the list in the scene. This is an O(n) operation.
Parameters:
{String} lightName
the name of the light.
Returns:
a reference to a light object or null if it was not found.

getObj(indxNum)
Get a reference of a particular object in the scene.
Parameters:
indxNum
The index number of the object.
Returns:
the reference to the object at index number indxNum or null if indxNum was out of bounds.

{int} getObjListSize()
Get the number of objects in the scene.
Returns:
{int} The number of objects in the object list.

{Function} getPickingCallback()
Get the function which will be called when the user clicks on the canvas.
Returns:
{Function} the function which is called when the user clicks on the canvas.

getPickingPrecision()
Get the type of test which will run when a user clicks on the canvas.
Returns:
c3dl.PICK_PRECISION_BOUNDING_VOLUME or c3dl.PICK_PRECISION_TRIANGLE.

{Array} getPointAttenuation()
Returns:
{Array}

{c3dl.POINT_MODE_POINT | c3dl.POINT_MODE_SPHERE} getPointRenderingMode()
Get how the points are rendered in the scene. Either they are rendered using WebGL's built-in method, or are rendered as sphere meshes.
Returns:
{c3dl.POINT_MODE_POINT | c3dl.POINT_MODE_SPHERE} rendering mode.

{float} getPointSize()
Get the size of the spheres when they are rendered as points.
Returns:
{float} size the points will be when they are rendered as spheres.

{bool} getPointSmooth()
If point smoothing is on, points are rendered as circles, otherwise they are rendered as squares.
Returns:
{bool} true if points will be rendered as circles, false if points are rendered as squares.

getRenderer()
Get the scene's Renderer

{c3dl.Scene} getScene()
Get the Scene.
Returns:
{c3dl.Scene}

{c3dl.Collada} getSkyModel()
Get the SkyModel.
Returns:
{c3dl.Collada} The Scene's SkyModel.

{boolean} init()
Acquire the OpenGL Context
Returns:
{boolean} true if the renderer was initialized, otherwise false.

removeLight(lightName)
Remove a light from the scene. The first light found matching the name lightName will be removed.
Parameters:
{String} lightName
the name of the light

{boolean} removeObjectFromScene(obj)
Remove an object from the scene. This is an O(n) operation.
Parameters:
{c3dl.Primitive|c3dl.ParticleSystem|c3dl.Point|c3dl.Line} obj
The object to remove from the scene.
Returns:
{boolean} true if the object was found and removed from the scene or false if the argument 'obj' was not found.

setAmbientLight(light)
Set the ambient light of the scene.
Parameters:
{Array} light
An array of 3 floating point values ranging from 0 to 1.

setBackgroundColor(bgColor)
Set the color of the background. Values are clamped to the range [0,1].
Parameters:
{Array} bgColor
Array of four values in the order [r,g,b,a].

setCamera(cam)
Set the Scene's camera.
Parameters:
{c3dl.FreeCamera} cam
The camera.

setCanvasTag(canvasTagID)
Parameters:
{String} canvasTagID
The id of the canvas, which is a property of the canvas tag in the html file.

setKeyboardCallback(keyUpCB, keyDownCD)
Set the functions to call when a key is pressed or released.
TODO: add keyPress event callback as windows and osx versions of firefox handle keyboard events differently.
Parameters:
{function} keyUpCB
The callback function for the up key.
{function} keyDownCD
The callback function for the down key.

setMouseCallback(mouseUpCB, mouseDownCB, mouseMoveCB, mouseScrollCB)
Pass in the functions to call when mouse event occur such as when a button is pressed, released or the mousewheel is scrolled. The scene will call these functions when the events occur.
Parameters:
{function} mouseUpCB
{function} mouseDownCB
{function} mouseMoveCB
{function} mouseScrollCB

setPickingCallback(pickingHandler)
Tell the scene what function to call when a user clicks on the canvas.
Parameters:
{function} pickingHandler
The function to call when the user clicks on the canvas.

setPickingPrecision(precision)
If the scene has been provided with a picking callback, when the user clicks the canvas either one or two sets of tests will run. If the bounding volume constant is passed to this function, a fast, approximate test is run for objects which can be picked against the ray generated by the click. If the triangles constant is passed in, both the ray/bounding volume test will run along with a ray/triangle test for each object which can be picked.
Parameters:
{c3dl.PICK_PRECISION_BOUNDING_VOLUME | c3dl.PICK_PRECISION_TRIANGLE} precision
The precision test to use when the user clicks the canvas.

setPointAttenuation(attn)
Set how the points attenuate for this scene.
Parameters:
{Array} attn
with three values.
first contains constant attenuation
second contains linear attenuation
third contains quadratic attenuation
At least one of the elements must be greater than one or the argument is ignored.

setPointRenderingMode(mode)
Set how c3dl.Point objects are rendered. c3dl.POINT_MODE_POINT will render the points using WebGL's built-in 2D billboarded point primitives c3dl.POINT_MODE_SPHERE will render points using sphere objects.
Parameters:
{c3dl.POINT_MODE_POINT | c3dl.POINT_MODE_SPHERE} mode

setPointSize(size)
Sets the point size when rendering points as spheres. To change point size when rendering points as circles, or using the built-in points, use setPointAttenuation.
Parameters:
{float} size
Must be greater than zero.

{bool} setPointSmooth(smooth)
If point smoothing is on, points are rendered as circles, otherwise they are rendered as squares.
Parameters:
smooth
Returns:
{bool} true if points are rendered as circles, false if points are rendered as squares.

setRenderer(renderType)
Set the renderer used to render the scene.
Parameters:
{c3dl.OpenGLES20} renderType

setSkyModel(sky)
Set the SkyModel. A SkyModel acts like a skybox, when the camera moves in the scene the SkyModel maintains the same distance from the camera. This creates the illusion that there are parts to the scene that are very far away which cannot be reached. Applications of this would include creating clouds, or mountain ranges, starfields, etc. Any Model can be passed in and is not restricted to a Cube. Whatever model that is appropirate should be used.
Parameters:
{c3dl.Collada} sky
A Model which will maintain the same distance from the Scene's camera.

setUpdateCallback(updateCB)
Set the function to call everytime the scene is updated.
Parameters:
{function} updateCB
The function to call everytime the scene is updated.

startScene()
Start scene sets a default ambient light to white with full intensity. If this ambient lighting is not desired, call setAmbientLight(..) after this method, which will undo the default ambient light values.

stopScene()
Flags the main loop for exit.

Documentation generated by JsDoc Toolkit 2.1.0 on Fri Feb 19 2010 17:58:41 GMT-0500 (EST)