Class: Scene

Scene(viewer, view)

A Scene is a stack of layers sharing the same view and hotspot container. It belongs to the viewer inside which it is displayed.

Clients should call Viewer#createScene instead of invoking the constructor directly.

Constructor

new Scene(viewer, view)

Parameters:
Name Type Description
viewer Viewer

The viewer this scene belongs to.

view View

The scene's underlying view.

Methods

createLayer(opts) → {Layer}

Creates a new layer and adds it into the scene in the foreground position.

Parameters:
Name Type Description
opts Object

Layer creation options.

Properties
Name Type Attributes Default Description
source Source

The layer's underlying Source.

geometry Source

The layer's underlying Geometry.

pinFirstLevel boolean <optional>
false

Whether to pin the first level to provide a fallback of last resort, at the cost of memory consumption.

textureStoreOpts Object <optional>
{}

Options to pass to the TextureStore constructor.

layerOpts Object <optional>
{}

Options to pass to the Layer constructor.

Returns:
Type
Layer

destroy()

Destructor. Clients should call Viewer#destroyScene instead.

destroyAllLayers()

Destroys all layers and removes them from the scene.

destroyLayer(layer)

Destroys a layer and removes it from the scene.

Parameters:
Name Type Description
layer Layer
Throws:

An error if the layer does not belong to the scene.

hotspotContainer() → {Layer}

Returns the hotspot container for the scene.

Returns:
Type
Layer

layer() → {Layer}

Returns the first of the layers belonging to the scene, or null if the scene has no layers.

This method is equivalent to Scene#listLayers[0]. It may be removed in the future.

Returns:
Type
Layer

listLayers() → {Array.<Layer>}

Returns a list of all layers belonging to the scene. The returned list is in display order, background to foreground.

Returns:
Type
Array.<Layer>

lookTo(params, opts, done)

Tweens the scene's underlying view.

Parameters:
Name Type Description
params Object

Target view parameters.

opts Object

Transition options.

Properties
Name Type Attributes Default Description
ease function <optional>
easeInOutQuad

Tween easing function

controlsInterrupt number <optional>
false

allow controls to interrupt an ongoing tween.

transitionDuration number <optional>
1000

Tween duration, in milliseconds.

closest number <optional>
true

Whether to tween through the shortest path between the initial and final view parameters. This requires View#normalizeToClosest to be implemented, and does nothing otherwise.

done function

Function to call when the tween finishes or is interrupted.

movement() → {function}

Returns the current movement.

Returns:
Type
function

startMovement(fn, done)

Starts a movement, possibly replacing the current movement.

Parameters:
Name Type Description
fn function

The movement function.

done function

Function to be called when the movement finishes or is interrupted.

stopMovement()

Stops the current movement.

switchTo(opts, done)

Switches to the scene.

This is equivalent to calling Viewer#switchScene on this scene.

Parameters:
Name Type Description
opts Object

Options to pass into Viewer#switchScene.

done function

Function to call when the switch is complete.

view() → {View}

Returns the scene's underlying view.

Returns:
Type
View

viewer() → {Viewer}

Returns the viewer the scene belongs to.

Returns:
Type
Viewer

visible() → {boolean}

Returns whether the scene is currently visible.

Returns:
Type
boolean

Events

layerChange

Signals that the scene's layers have changed.

viewChange

Signals that the scene's view has changed. See View#event:change.