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:
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.
Summary
Creates and returns a Renderable object. This should only be used as a basis for other implementations.
Syntax
var renderable = Renderable.create();
Summary
Creates a Renderable by cloning an existing Renderable. This should be overridden.
Syntax
var newRenderable = renderable.clone();
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.
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);
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.
Summary
Remove previously attached custom world extents.
Syntax
renderable.removeCustomWorldExtents();
Summary
Get previously attached world extents. Maybe undefined.
Syntax
var extents = renderable.getCustomWorldExtents();
Returns an extents array.
Summary
Returns a boolean whether the object has custom world extents.
Syntax
if (renderable.hasCustomWorldExtents())
{
//...
}
Summary
Get the SceneNodes the Renderable is attached to.
Syntax
var node = renderable.getNode();
Returns a SceneNode.
Summary
Set the material. Set the material.
Syntax
renderable.setMaterial(material);
Summary
Get the material.
Syntax
var material = renderable.getMaterial();
Returns a Material.
Summary
Free the resources attached to the object. Renderables attached to a SceneNode are destroyed when it is destroyed.
Syntax
renderable.destroy();
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;
ForwardRender only.
Summary
An array of DrawParameters used for the diffuse pass.
Syntax
var drawParameters = renderable.diffuseDrawParameters;
DeferredRender only.
An array of DrawParameters used for the shadow pass.
Syntax
var drawParameters = renderable.shadowDrawParameters;
Summary
A boolean. If its true the object is not rendered.
Syntax
renderable.disabled = true;
Summary
The currently calculated worldExtents.
Syntax
var worldExtents = renderable.worldExtents;
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:
Syntax
myRenderable.geometryType = "mymorph";
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;
Summary
Reserved read only information used by the renderer.
Syntax
var rendererInfo = renderable.rendererInfo;
Summary
Reserved read only information used by the renderer.
The last frame the object was visible.
Syntax
if (lastFrameVisible !== renderable.frameVisible)
{
//...
}