Table Of Contents

Previous topic

21.37. The Reference Object

Next topic

21.39. The RequestHandler Object

This Page

21.38. The Renderable Interface

A Renderable specifies the base interface for rendering using the Scene. It has no implementation. The interface allows both the engine and developers to implement various versions of renderables for different geometryTypes. Any custom renderables will be fully integrated in to the scene and rendering, allowing correct visibility culling, lighting, shadows and sorting.

The engine provides the following implementations:

Custom renderables could be implemented for any bespoke requirements such as:

  • Particle systems
  • Morphs

A SceneNode has a collection of Renderables, either automatically created during loading or via SceneNode.addRenderable().

To be a valid renderable the below methods and properties are required.

21.38.1. Constructor

21.38.1.1. create

Summary

Creates and returns a Renderable object. This should only be used as a basis for other implementations.

Syntax

var renderable = Renderable.create();

21.38.2. Methods

21.38.2.1. clone

Summary

Creates a Renderable by cloning an existing Renderable. This should be overridden.

Syntax

var newRenderable = renderable.clone();

21.38.2.2. getWorldExtents

Summary

Get the world extents of the Renderable.

This is only valid when attached to a SceneNode and the node has been updated.

Syntax

var extents = renderable.getWorldExtents();

Returns an extents array.

21.38.2.3. addCustomWorldExtents

Summary

User defined extents that replace the ones calculated from any extents and the SceneNode’s world transform.

Syntax

var customExtents = renderable.getWorldExtents().slice();
var padding = 10;
customExtents[0] -= padding;
customExtents[1] -= padding;
customExtents[2] -= padding;
customExtents[3] += padding;
customExtents[4] += padding;
customExtents[5] += padding;
renderable.addCustomWorldExtents(customExtents);
customExtents
The custom extents to use instead of the default.

The Renderable must be attached to a SceneNode. Even if the SceneNode moves the extents will not be recalculated. This can be used as an optimization for animated objects that are constrained to a location.

21.38.2.4. removeCustomWorldExtents

Summary

Remove previously attached custom world extents.

Syntax

renderable.removeCustomWorldExtents();

21.38.2.5. getCustomWorldExtents

Summary

Get previously attached world extents. Maybe undefined.

Syntax

var extents = renderable.getCustomWorldExtents();

Returns an extents array.

21.38.2.6. hasCustomWorldExtents

Summary

Returns a boolean whether the object has custom world extents.

Syntax

if (renderable.hasCustomWorldExtents())
{
    //...
}

21.38.2.7. getNode

Summary

Get the SceneNodes the Renderable is attached to.

Syntax

var node = renderable.getNode();

Returns a SceneNode.

21.38.2.8. setMaterial

Summary

Set the material. Set the material.

Syntax

renderable.setMaterial(material);
material
Material to set.

21.38.2.9. getMaterial

Summary

Get the material.

Syntax

var material = renderable.getMaterial();

Returns a Material.

21.38.2.10. destroy

Summary

Free the resources attached to the object. Renderables attached to a SceneNode are destroyed when it is destroyed.

Syntax

renderable.destroy();

21.38.3. Properties

21.38.3.1. drawParameters

Summary

An array of DrawParameters. These are the objects the renderers use to render the renderable. Typically, the prepare() function registered with the Effects creates these and they are updated for visible renderables using the renderUpdate() method.

Syntax

var drawParameters = renderable.drawParameters;

21.38.3.2. diffuseDrawParameters

ForwardRender only.

Summary

An array of DrawParameters used for the diffuse pass.

Syntax

var drawParameters = renderable.diffuseDrawParameters;

21.38.3.3. shadowDrawParameters

DeferredRender only.

An array of DrawParameters used for the shadow pass.

Syntax

var drawParameters = renderable.shadowDrawParameters;

21.38.3.4. disabled

Summary

A boolean. If its true the object is not rendered.

Syntax

renderable.disabled = true;

21.38.3.5. worldExtents

Summary

The currently calculated worldExtents.

Syntax

var worldExtents = renderable.worldExtents;

21.38.3.6. sharedMaterial

Summary

The current material of the object.

Syntax

var sharedMaterial = renderable.sharedMaterial;

21.38.3.7. geometryType

Summary

A string representing the type of the geometry the renderable generates. This can any custom name and is used to register the type with the Effect object.

Reserved Names:

  • “rigid”
  • “skinned”

Syntax

myRenderable.geometryType = "mymorph";

21.38.3.8. distance

Summary

Reserved read only information used by the renderer.

The distance of the renderable from the camera the last time it was visible.

Syntax

var distance = renderable.distance;

21.38.3.9. rendererInfo

Summary

Reserved read only information used by the renderer.

Syntax

var rendererInfo = renderable.rendererInfo;

21.38.3.10. frameVisible

Summary

Reserved read only information used by the renderer.

The last frame the object was visible.

Syntax

if (lastFrameVisible !== renderable.frameVisible)
{
    //...
}