SceneController

The SceneController is an abstract class so it should never be directly instantiated. This class defines the life cycle of a Scene and its components. The Runtime and editorRuntime both extend this class to implement functionality related to the scene when it's being played, and the scene when it's being edited respectively.

Properties

.camera

camera: THREE.Camera

The Camera instance that's currently "showing" us the scene.

.deltaTime

readonly deltaTime: number

This value represents the time elapsed between the last frame and the current one.

.clock

readonly clock: THREE.Clock

The three.js Clock being used to keep track of time.

.height

readonly height: number

This value represents the height of the Scene Renderer.

.width

readonly width: number

This value represents the width of the Scene Renderer.

.containerId

readonly containerId: HTMLElement

This field contains the id of the HTMLElement where the Scene is being rendered.

.renderer

readonly renderer: THREE.WebGLRenderer

The active WebGLrenderer.

.isRunning

readonly isRunning: boolean

This flag tells us if the SceneController is running the animation loop or not.

.isPaused

readonly isPaused: boolean

This flag tells us if the SceneController is paused. Pausing will only stop beforeUpdate() update() and afterUpdate() from running along with their respective event listeners, but not the loop itself, so keep that in mind.

.rogueDOMContainer

readonly rogueDOMContainer: HTMLElement

The HTMLELement associated with the renderer.

Methods

.pause

pause(): void

This method will pause the animation loop if it's running.

.resume

resume(): void

This method will resume the animation loop if it's paused.

.togglePause

togglePause(): void

This handy method will toggle between pause() and resume().

Events

.onPlay

onPlay(callback: () => any): {stop: () => void}

This event listener helps us hook into the initialization sequence of this SceneController instance. It returns an object with a stop() function you should call in order to stop the listener.

.onStop

onStop(callback: () => any): {stop: () => void}

This event listener helps us hook into the stopping sequence of this SceneController instance. It returns an object with a stop() function you should call in order to stop the listener.