Class SceneManager

Classdesc

SceneManager class, used for managing scenes and to transition between scenes

Example

const sceneManager = new SceneManager({
initialScene: scene,
canvas: document.getElementById("canvas")
});

Example

// Example animation between two scene
const sceneManger = new SceneManager({
initialScene: scene,
canvas: document.getElementById("canvas")
});
sceneManager.addScene(scene2);
sceneManager.animate("quickFade", scene2, 1000);

Hierarchy (view full)

Constructors

Properties

activeScene: string

ID of the active scene

animateTo: Scene

Scene to animate to

animationNames: string[]

Names of the animations that can be used

animationRunTime: number

How long the animation should run for

animationRunning: boolean

Whether or not the animation is running

animationStartTime: number

Time when the animation started

canvas: HTMLCanvasElement

Canvas element to draw the scenes on

ctx: CanvasRenderingContext2D

Canvas rendering context of the canvas

fromScenePrevHadLights: boolean

Whether or not the scene that the animation is coming from had lighting enabled

height: number

Height of the canvas (Will resize the canvas to this height). By default is the width of the canvas element

sceneAnimation: string

Animation to use when transitioning between scenes

scenes: {
    [key: string]: Scene;
}

Scenes in the scene manager

Type declaration

start: boolean

Whether or not to start the scene manager when it is initialized (true by default)

toScenePrevHadLights: boolean

Whether or not the scene that the animation is going to had lighting enabled

width: number

Width of the canvas (Will resize the canvas to this width). By default is the width of the canvas element

Methods

  • Adds a sceen to the scene manager

    Parameters

    • scene: Scene

      Scene to add to the scene manager

    Returns void

  • Smoothly animates between scenes (unless lighting is enabled, in which case lighting is temporarily disabled as the animation is running)

    Parameters

    • transition: string

      Name of the transition to use

    • scene: Scene

      Scene to transition to

    • duration: number = 1000

      Time (in ms) to run the transition for

    Returns void

  • Changes the active scene, with no transition

    Parameters

    • scene: Scene

      Scene to change to

    Returns void

  • Draws the active scene onto the canvas, also runs animations if they are running

    Returns void

Generated using TypeDoc