Table Of Contents

Previous topic

21.14. The Draw2DSprite Object

Next topic

21.17. The EffectManager Object

This Page

21.16. The Effect Object

An Effect is a named object that defines a standard appearance style, e.g. “blinn”, “translucent” and “env”.

It provides a mapping from a geometryType, e.g. “rigid” and “skinned”, to an object that can prepare a renderable so that it can be drawn. Typically the prepare function will reference shaders and techniques it has requested to be loaded.

The renderers register a number of Effects during their create() methods.

This abstraction allows custom effect types to be registered for custom geometry types.

Required scripts

The Effect object requires:

/*{{ javascript("jslib/effectmanager.js") }}*/

21.16.1. Constructor

21.16.1.1. create

Summary

Create a named Effect.

Syntax

var effect = Effect.create(name);

21.16.2. Method

21.16.2.1. add

Summary

For a given geometry type add a prepare object that can process a renderable of that type.

Syntax

effect.add(geometryType, prepareObject);
geometryType
A string identifying the type.
prepareObject
An object with a prepare() method that takes a renderable as an argument. i.e. prepareObject.prepare(renderable).

See also Effect Registration.

21.16.2.2. remove

Summary

Deletes the geometryType stored with the given name.

Syntax

effect.remove(name);
name
The name of the geometryType to remove.

21.16.2.3. get

Summary

Returns the prepare object associated with the geometryType.

Syntax

var prepareObject = effect.get("rigid");
prepareObject.prepare(geometryInstance);
name
The name of the geometryType to get.

Returns a prepareObject previously registered with the add() method.

21.16.3. Properties

21.16.3.1. version

Summary

The version number of the Effect implementation.

Syntax

var versionNumber = Effect.version;

21.16.3.2. name

Summary

The name of the Effect.

Syntax

var name = effect.name;