Skip to main content

GeneratorScene

abstract class GeneratorSceneT implements SceneThreadGeneratorFactoryTThreadable

The default implementation of the Scene interface.

Uses generators to control the animation.

Type Parameters

Constructors​

constructor​

public new GeneratorScenedescription: FullSceneDescriptionThreadGeneratorFactoryT: GeneratorSceneT

Parameters

  • description: FullSceneDescriptionThreadGeneratorFactoryT

Properties​

creationStack​

public creationStack?: string

experimentalFeatures​

readonly public experimentalFeatures: boolean

Whether experimental features are enabled.


lifecycleEvents​

readonly public lifecycleEvents: LifecycleEvents = ...

The scenes.LifecycleEvents of this scene.


logger​

readonly public logger: Logger

meta​

readonly public meta: ObjectMetaField

name​

readonly public name: string

Name of the scene.

Will be passed as the second argument to the constructor.


playback​

readonly public playback: PlaybackStatus

Reference to the project.


previousOnTop​

public previousOnTop: SignalValueboolean

Should this scene be rendered below the previous scene during a transition?


random​

public random: Random

shaders​

readonly public shaders: Shaders
Experimental
This is an experimental feature. The behavior and API may change drastically between minor releases.

slides​

readonly public slides: Slides

sounds​

readonly public sounds: Sounds

timeEvents​

readonly public timeEvents: TimeEvents

variables​

readonly public variables: Variables

Accessors​

firstFrame​

public get firstFrame(): number

The frame at which this scene starts.


lastFrame​

public get lastFrame(): number

The frame at which this scene ends.


LifecycleEvents​

public get LifecycleEvents(): LifecycleEvents

The scenes.LifecycleEvents of this scene.

Deprecated

Use lifecycleEvents instead.


previous​

public get previous(): Sceneunknownnull

The scene directly before this scene, or null if omitted for performance.


transitionDuration​

public get transitionDuration(): number

Scene transition duration in frames.

Methods​

canTransitionOut​

public canTransitionOut(): boolean

Is this scene in the SceneState.CanTransitionOut state?


enterAfterTransitionIn​

public enterAfterTransitionIn(): void

Enter the SceneState.AfterTransitionIn state.


enterCanTransitionOut​

public enterCanTransitionOut(): void

Enter the SceneState.CanTransitionOut state.


enterInitial​

public enterInitial(): void

Enter the SceneState.Initial state.


execute​

public executecallback: () => T: T

Invoke the given callback in the context of this scene.

This method makes sure that the context of this scene is globally available during the execution of the callback.

Parameters

  • callback: () => T

    The callback to invoke.


getRealSize​

public getRealSize(): Vector2

Get the real size of this scene.

Returns the size of the scene multiplied by the resolution scale. This is the actual size of the canvas onto which the scene is rendered.


getSize​

public getSize(): Vector2

Get the size of this scene.

Usually returns this.project.getSize().


getView​

abstract public getView(): T

isAfterTransitionIn​

public isAfterTransitionIn(): boolean

Is this scene in the SceneState.AfterTransitionIn state?


isCached​

public isCached(): boolean

Is this scene cached?

Used only by GeneratorScene. Seeking through a project that contains at least one uncached scene will log a warning to the console.

Should always return true.


isFinished​

public isFinished(): boolean

Is this scene in the SceneState.Finished state?


next​

public next(): Promisevoid

Progress this scene one frame forward.


recalculate​

public recalculatesetFrame: frame: number => void: Promisevoid

Recalculate the scene.

The task of this method is to calculate new timings stored in the cache. When this method is invoked, this.project.frame is set to the frame at which this scene should start (firstFrame).

At the end of execution, this method should set this.project.frame to the frame at which this scene ends (lastFrame).

Should trigger onRecalculated.

Parameters


reload​

public reloaddescription: SceneDescriptionReloadThreadGeneratorFactoryT = {}: void

Reload the scene.

This method is called whenever something related to this scene has changed: time events, source code, metadata, etc.

Should trigger onReloaded.

Parameters

  • description: SceneDescriptionReloadThreadGeneratorFactoryT = {}

    If present, an updated version of the description.


render​

Render the scene onto a canvas.

Parameters


reset​

public resetpreviousScene: Sceneunknownnull = null: Promisevoid

Reset this scene to its initial state.

Parameters


update​

public update(): void

Update the view.

Invoked after each step of the main generator. Can be used for calculating layout.

Can modify the state of the view.

Events​

onCacheChanged​

public get onCacheChanged(): SubscribableValueEventCachedSceneData

Triggered when the cached data changes.


onRecalculated​

public get onRecalculated(): SubscribablevoidEventHandlervoid

Triggered after scene is recalculated.


onReloaded​

public get onReloaded(): SubscribablevoidEventHandlervoid

Triggered when the scene is reloaded.


onRenderLifecycle​

public get onRenderLifecycle(): SubscribableSceneRenderEventCanvasRenderingContext2DEventHandlerSceneRenderEventCanvasRenderingContext2D

Triggered at various stages of the render lifecycle with an event title and a Context2D.


onReset​

public get onReset(): SubscribablevoidEventHandlervoid

Triggered when the scene is reset.


onThreadChanged​

public get onThreadChanged(): SubscribableValueEventThreadnull

Triggered when the main thread changes.