Skip to main content

Scene2D

class Scene2D extends GeneratorSceneView2Dimplements Inspectable

Constructors​

constructor​

Parameters

Overwrites GeneratorScene<View2D>.constructor

Properties​

creationStack​

creationStack?: string
Inherited from GeneratorScene.creationStack

experimentalFeatures​

readonly experimentalFeatures: boolean

Whether experimental features are enabled.

Inherited from GeneratorScene.experimentalFeatures

lifecycleEvents​

The scenes.LifecycleEvents of this scene.

Inherited from GeneratorScene.lifecycleEvents

logger​

readonly logger: Logger
Inherited from GeneratorScene.logger

meta​

Inherited from GeneratorScene.meta

name​

readonly name: string

Name of the scene.

Will be passed as the second argument to the constructor.

Inherited from GeneratorScene.name

playback​

Reference to the project.

Inherited from GeneratorScene.playback

previousOnTop​

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

Inherited from GeneratorScene.previousOnTop

random​

Inherited from GeneratorScene.random

shaders​

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

slides​

readonly slides: Slides
Inherited from GeneratorScene.slides

sounds​

readonly sounds: Sounds
Inherited from GeneratorScene.sounds

timeEvents​

Inherited from GeneratorScene.timeEvents

variables​

Inherited from GeneratorScene.variables

Accessors​

firstFrame​

public get firstFrame(): number

The frame at which this scene starts.

Inherited from GeneratorScene.firstFrame

lastFrame​

public get lastFrame(): number

The frame at which this scene ends.

Inherited from GeneratorScene.lastFrame

LifecycleEvents​

public get LifecycleEvents(): LifecycleEvents

The scenes.LifecycleEvents of this scene.

Deprecated

Use lifecycleEvents instead.

Inherited from GeneratorScene.LifecycleEvents

previous​

public get previous(): Sceneunknownnull

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

Inherited from GeneratorScene.previous

transitionDuration​

public get transitionDuration(): number

Scene transition duration in frames.

Inherited from GeneratorScene.transitionDuration

Methods​

canTransitionOut​

public canTransitionOut(): boolean

Is this scene in the SceneState.CanTransitionOut state?

Inherited from GeneratorScene.canTransitionOut

draw​

Parameters

Overwrites GeneratorScene.draw

drawOverlay​

public drawOverlayelement: unknownmatrix: DOMMatrixcontext: CanvasRenderingContext2D: void

Draw an overlay for the inspected element.

This method can be used to overlay additional information about an element on top of the animation.

Parameters


enterAfterTransitionIn​

public enterAfterTransitionIn(): void

Enter the SceneState.AfterTransitionIn state.

Inherited from GeneratorScene.enterAfterTransitionIn

enterCanTransitionOut​

public enterCanTransitionOut(): void

Enter the SceneState.CanTransitionOut state.

Inherited from GeneratorScene.enterCanTransitionOut

enterInitial​

public enterInitial(): void

Enter the SceneState.Initial state.

Inherited from GeneratorScene.enterInitial

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.

Inherited from GeneratorScene.execute

getDetachedNodes​

public getDetachedNodes(): GeneratorNodevoidunknown

getNode​

public getNodekey: any: Nodenull

Parameters


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.

Inherited from GeneratorScene.getRealSize

getSize​

public getSize(): Vector2

Get the size of this scene.

Usually returns this.project.getSize().

Inherited from GeneratorScene.getSize

getView​

public override getView(): View2D
Overwrites GeneratorScene.getView

inspectAttributes​

public inspectAttributeselement: unknown: InspectedAttributesnull

Return the attributes of the inspected element.

This information will be displayed in the "Properties" panel.

Parameters

  • element: unknown

    The element to inspect.


inspectElementMatrix​

public inspectElementMatrixelement: unknown: DOMMatrixnull

Get the matrix mapping an inspected element's local space to scene space.

Parameters

  • element: unknown

    The inspected element.


inspectPosition​

public inspectPositionx: numbery: number: unknown

Get a possible element to inspect at a given position.

Parameters

  • x: number

    The x coordinate.

  • y: number

    The y coordinate.


isAfterTransitionIn​

public isAfterTransitionIn(): boolean

Is this scene in the SceneState.AfterTransitionIn state?

Inherited from GeneratorScene.isAfterTransitionIn

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.

Inherited from GeneratorScene.isCached

isFinished​

public isFinished(): boolean

Is this scene in the SceneState.Finished state?

Inherited from GeneratorScene.isFinished

next​

public override next(): Promisevoid
Overwrites GeneratorScene.next

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

Inherited from GeneratorScene.recalculate

registerNode​

public registerNodenode: Nodekey?: string: string() => void

Parameters


reload​

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

Inherited from GeneratorScene.reload

render​

Render the scene onto a canvas.

Parameters

Inherited from GeneratorScene.render

reset​

public override resetpreviousScene?: Sceneunknown: Promisevoid

Parameters

Overwrites GeneratorScene.reset

transformMousePosition​

public transformMousePositionx: numbery: number: Vector2null

Transform the absolute mouse coordinates into the scene's coordinate system.

Parameters

  • x: number

    The x coordinate.

  • y: number

    The y coordinate.


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.

Inherited from GeneratorScene.update

validateInspection​

public validateInspectionelement: unknown: unknown

Check if the inspected element is still valid.

If a scene destroys and recreates its components upon every reset, the reference may no longer be valid. Even though the component is still present. This method should check that and return a new reference.

Parameters

  • element: unknown

    The element to validate.

Events​

onCacheChanged​

public get onCacheChanged(): SubscribableValueEventCachedSceneData

Triggered when the cached data changes.

Inherited from GeneratorScene.onCacheChanged

onRecalculated​

public get onRecalculated(): SubscribablevoidEventHandlervoid

Triggered after scene is recalculated.

Inherited from GeneratorScene.onRecalculated

onReloaded​

public get onReloaded(): SubscribablevoidEventHandlervoid

Triggered when the scene is reloaded.

Inherited from GeneratorScene.onReloaded

onRenderLifecycle​

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

Inherited from GeneratorScene.onRenderLifecycle

onReset​

public get onReset(): SubscribablevoidEventHandlervoid

Triggered when the scene is reset.

Inherited from GeneratorScene.onReset

onThreadChanged​

public get onThreadChanged(): SubscribableValueEventThreadnull

Triggered when the main thread changes.

Inherited from GeneratorScene.onThreadChanged