Class Index | File Index

Classes


Class c3dl.EffectTemplate

An EffectTemplate is a template for creating many Effects which have similar rendering results. Effects instantiated from EffectTemplates achieve different rendering results by changing the parameters of the EffectTemplate.

Effects cannot instantiate EffectTemplates until the EffectTemplate has been initialized. However, once initialized, the EffectTemplate can no longer be modified. This includes changing the callback, parameters, shaders, etc.

When an effect is instantiated from an effect template, any parameters the effect template has which are do not have default values must be set before the object with the effect is rendered.


Defined in: effecttemplate.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
addFragmentShader(fragmentShader)
Adds a fragment shader to the list of fragment shaders which need to be compiled.
 
addParameter(paramName, paramType, paramDefaultValue)
Add a parameter which and instance effect can modify.
 
addVertexShader(vertexShader)
Adds a vertex shader to the list of vertex shaders which need to be compiled.
 
Get the callback which is to be called when the geometric object with an effect created from this effect template is rendered.
 
init()
Call this once the vertex shader, fragment shader and rendering callback have been set and all parameters have been created.
 
Set the rendering callback which will be called by the renderer when the object with this effect needs to be rendered.
 
toString(delimiter)
Get a string representation of this object.
Class Detail
c3dl.EffectTemplate()
Method Detail
addFragmentShader(fragmentShader)
Adds a fragment shader to the list of fragment shaders which need to be compiled. The fragment shader strings are literally added together, therefore the order which they are added is important. For example, if the material struct it used, the variable holding the material string code should be added before the light string code since the light code depends on material code.
Parameters:
{String} fragmentShader

addParameter(paramName, paramType, paramDefaultValue)
Add a parameter which and instance effect can modify. Parameters should be simple, built-in types such as Boolean, Number, Array etc. They should not be Objects created with {}.
Parameters:
{String} paramName
paramType
Constructor used to create the object such as Boolean, Number, Array, etc.
paramDefaultValue
The default value to be used if the user does not specify any value. If null, user will have to specify a value, otherwise the object with this effect will not be rendered.

addVertexShader(vertexShader)
Adds a vertex shader to the list of vertex shaders which need to be compiled. The vertex shader strings are literally added together, therefore the order which they are added is important. For example, if the material struct it used, the variable holding the material string code should be added before the light string code since the light code depends on material code.
Parameters:
{String} vertexShader

{Function} getRenderingCallback()
Get the callback which is to be called when the geometric object with an effect created from this effect template is rendered.
Returns:
{Function} The function which will render the geometric object with an effect created from this template effect.

{bool} init()
Call this once the vertex shader, fragment shader and rendering callback have been set and all parameters have been created. Once the EffectTemplate has been initialized, neither the shaders, callback or parameters can be changed.
Returns:
{bool} true if the EffectTemplate was initialized, false otherwise.

setRenderingCallback(func)
Set the rendering callback which will be called by the renderer when the object with this effect needs to be rendered. The renderer will pass a renderingObject to the function which can be queried for context, renderer, effect, etc.
Parameters:
{Function} func
See:
c3dl.RenderingObject.

toString(delimiter)
Get a string representation of this object.
Parameters:
{String} delimiter Optional, Default: ","
A string which will separate values.

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