OverlayManager
Provides a mechanism for adding custom meshes. These meshes are added into their own overlay scenes, which are always rendered after the main scene.
new OverlayManager()
Methods
addScene(name)
Creates a scene that is always rendered after the main scene. It is rendered into a separate buffer when each frame of the main scene is drawn. The buffer is then composited over the main scene. If it is enabled, the overlay scenes use the main scene depth buffer for the depth testing, to allow the overlay to appear in the main scene.
Parameters
name* string | scene identifier |
Returns
type | description |
---|---|
boolean |
|
removeScene(name)
Removes a scene along with all the meshes in it.
Parameters
name* string | scene identifier |
Returns
type | description |
---|---|
boolean |
|
clearScene(name)
Removes all meshes from a scene.
Parameters
name* string | scene identifier |
hasScene(name)
Checks whether a scene already exists
Parameters
name* string | scene identifier |
Returns
type | description |
---|---|
boolean |
|
addMesh(mesh, sceneName)
Inserts one or more custom THREE.Mesh into an existing scene.
Parameters
mesh* THREE.Mesh, Array | A mesh instance or an Array of them. |
sceneName* string | Name of an existing scene. |
Returns
type | description |
---|---|
boolean |
|
Examples
// Create a new mesh
const geometry = new THREE.SphereGeometry(10, 8, 8);
const material = new THREE.MeshBasicMaterial({ color: 0x336699 });
const mesh = new THREE.Mesh(geometry, material);
mesh.position.x = 1.0; mesh.position.y = 2.0; mesh.position.z = 3.0;
// Add scene and mesh
addScene('my_scene');
addMesh([mesh], 'my_scene');
removeMesh(mesh, sceneName)
Removes one or more custom THREE.Mesh from an existing scene. Developers are responsible for disposing the material and geometry after the mesh is removed.
Parameters
mesh* THREE.Mesh, Array | A mesh instance or an Array of them. |
sceneName* string | Name of the scene the mesh(es) belong to. |
Returns
type | description |
---|---|
boolean |
|
hasMesh(mesh, sceneName)
Checks whether a mesh is already part of a scene.
Parameters
mesh* THREE.Mesh | The mesh instance. |
sceneName* string | Name of the scene to check against. |
Returns
type | description |
---|---|
boolean |
|