Create a new OutlineRenderer.
The application.
OptionalrenderingLayer: Layer
The layer the outlined mesh instances are added to, and which the internal outline camera renders. It must be part of the scene's layer composition. Defaults to the 'Immediate' layer. As the scene camera renders the 'Immediate' layer by default, the outlined objects are then rendered by the scene camera a second time - to avoid this, supply a dedicated layer which is not rendered by any other camera.
Optionalpriority: number = -1
The priority of the internal outline camera. It needs to render before the scene camera, so it has to be smaller than the priority of the scene camera. Defaults to -1.
Add an entity to the outline renderer, to draw an outline around it. The mesh instances of
the entity's render and model components are outlined, including those of its descendants
unless recursive is false. Adding an entity that is already outlined changes its outline
color.
Render and model components that are not currently rendered, because they or their entity are disabled, are skipped - this is evaluated when the entity is added.
Note that this sets StandardMaterial#onUpdateShader on the materials of the outlined mesh instances, replacing any existing callback. OutlineRenderer#removeEntity clears it.
Destroy the outline renderer and its resources.
Update the outline renderer. This needs to be called once per frame, after the scene camera
has been positioned, for example from the application's update event, which fires after
scripts have been updated. It matches the internal outline camera to the scene camera's
transform, projection, clip planes and resolution, and schedules the outlines to be
composited into the scene for this frame.
The outlines are composited just before the scene camera renders the opaque or transparent
part of blendLayer, so that part of the layer, and everything rendered after it, is drawn
on top of the outlines. The scene camera needs to render blendLayer, otherwise the
outlines are not visible.
The entity with the camera component used to render the scene.
The layer before which the outlines are composited.
True to composite the outlines before the
transparent part of blendLayer, false to composite them before its opaque part.
Remove all entities from the outline renderer, for example to clear the selection. Note that this removes all mesh instances from the rendering layer supplied to the constructor.
Remove an entity from the outline renderer, to stop drawing its outline. This also works for an entity that has been disabled since it was added.
The entity to remove.
Optionalrecursive: boolean = true
Whether to also remove the mesh instances of the entity's descendants. Defaults to true.
The OutlineRenderer draws solid color outlines around the silhouettes of entities, for example to highlight objects that are selected or hovered in an editor. Each entity can be outlined in its own color.
The outlines are generated in three steps:
The outlines are drawn over everything the scene camera has rendered up to that layer, so they remain visible when the outlined objects are occluded by other objects. Anything rendered in that layer or after it, such as gizmos, is drawn on top of the outlines.
OutlineRenderer#frameUpdate needs to be called every frame to keep the outlines in sync with the scene camera. Only render and model components are outlined, and the outline color is applied to mesh instances using a StandardMaterial.
Relevant Engine API examples:
Example