@revideo/2d / scenes / Scene2D
Class: Scene2D
Defined in: 2d/src/lib/scenes/Scene2D.ts:20
Extends
GeneratorScene<View2D>
Implements
Inspectable
Constructors
Constructor
new Scene2D(
description):Scene2D
Defined in: 2d/src/lib/scenes/Scene2D.ts:26
Parameters
description
FullSceneDescription<ThreadGeneratorFactory<View2D>>
Returns
Scene2D
Overrides
GeneratorScene<View2D>.constructor
Properties
creationStack?
optionalcreationStack?:string
Defined in: core/lib/scenes/GeneratorScene.d.ts:27
Inherited from
GeneratorScene.creationStack
experimentalFeatures
readonlyexperimentalFeatures:boolean
Defined in: core/lib/scenes/GeneratorScene.d.ts:49
Whether experimental features are enabled.
Inherited from
GeneratorScene.experimentalFeatures
lifecycleEvents
readonlylifecycleEvents:LifecycleEvents
Defined in: core/lib/scenes/GeneratorScene.d.ts:43
The scenes.LifecycleEvents of this scene.
Inherited from
GeneratorScene.lifecycleEvents
logger
readonlylogger:Logger
Defined in: core/lib/scenes/GeneratorScene.d.ts:23
Inherited from
GeneratorScene.logger
name
readonlyname:string
Defined in: core/lib/scenes/GeneratorScene.d.ts:21
Name of the scene.
Remarks
Will be passed as the second argument to the constructor.
Inherited from
GeneratorScene.name
playback
readonlyplayback:PlaybackStatus
Defined in: core/lib/scenes/GeneratorScene.d.ts:22
Reference to the project.
Inherited from
GeneratorScene.playback
previousOnTop
previousOnTop:
SignalValue<boolean>
Defined in: core/lib/scenes/GeneratorScene.d.ts:28
Should this scene be rendered below the previous scene during a transition?
Inherited from
GeneratorScene.previousOnTop
renderLifecycle
protectedreadonlyrenderLifecycle:EventDispatcher<[SceneRenderEvent,CanvasRenderingContext2D]>
Defined in: core/lib/scenes/GeneratorScene.d.ts:40
Inherited from
GeneratorScene.renderLifecycle
resolutionScale
protectedresolutionScale:number
Defined in: core/lib/scenes/GeneratorScene.d.ts:50
Inherited from
GeneratorScene.resolutionScale
shaders
readonlyshaders:Shaders
Defined in: core/lib/scenes/GeneratorScene.d.ts:24
Experimental
Inherited from
GeneratorScene.shaders
slides
readonlyslides:Slides
Defined in: core/lib/scenes/GeneratorScene.d.ts:25
Inherited from
GeneratorScene.slides
variables
readonlyvariables:Variables
Defined in: core/lib/scenes/GeneratorScene.d.ts:26
Inherited from
GeneratorScene.variables
Accessors
firstFrame
Get Signature
get firstFrame():
number
Defined in: core/lib/scenes/GeneratorScene.d.ts:29
The frame at which this scene starts.
Returns
number
Inherited from
GeneratorScene.firstFrame
lastFrame
Get Signature
get lastFrame():
number
Defined in: core/lib/scenes/GeneratorScene.d.ts:30
The frame at which this scene ends.
Returns
number
Inherited from
GeneratorScene.lastFrame
LifecycleEvents
Get Signature
get LifecycleEvents():
LifecycleEvents
Defined in: core/lib/scenes/GeneratorScene.d.ts:44
The scenes.LifecycleEvents of this scene.
Deprecated
Use lifecycleEvents instead.
Returns
LifecycleEvents
Inherited from
GeneratorScene.LifecycleEvents
previous
Get Signature
get previous():
Scene<unknown> |null
Defined in: core/lib/scenes/GeneratorScene.d.ts:45
The scene directly before this scene, or null if omitted for performance.
Returns
Scene<unknown> | null
Inherited from
GeneratorScene.previous
Methods
adjustVolume()
adjustVolume(
volumeScale):void
Defined in: 2d/src/lib/scenes/Scene2D.ts:221
Parameters
volumeScale
number
Returns
void
Overrides
GeneratorScene.adjustVolume
canTransitionOut()
canTransitionOut():
boolean
Defined in: core/lib/scenes/GeneratorScene.d.ts:78
Is this scene in the SceneState.CanTransitionOut state?
Returns
boolean
Inherited from
GeneratorScene.canTransitionOut
draw()
draw(
context):Promise<void>
Defined in: 2d/src/lib/scenes/Scene2D.ts:50
Parameters
context
CanvasRenderingContext2D
Returns
Promise<void>
Overrides
GeneratorScene.draw
drawOverlay()
drawOverlay(
element,matrix,context):void
Defined in: 2d/src/lib/scenes/Scene2D.ts:115
Draw an overlay for the inspected element.
Parameters
element
unknown
The element for which to draw an overlay.
matrix
DOMMatrix
A local-to-screen matrix.
context
CanvasRenderingContext2D
The context to draw with.
Returns
void
Remarks
This method can be used to overlay additional information about an element on top of the animation.
Implementation of
Inspectable.drawOverlay
enterAfterTransitionIn()
enterAfterTransitionIn():
void
Defined in: core/lib/scenes/GeneratorScene.d.ts:81
Enter the SceneState.AfterTransitionIn state.
Returns
void
Inherited from
GeneratorScene.enterAfterTransitionIn
enterCanTransitionOut()
enterCanTransitionOut():
void
Defined in: core/lib/scenes/GeneratorScene.d.ts:82
Enter the SceneState.CanTransitionOut state.
Returns
void
Inherited from
GeneratorScene.enterCanTransitionOut
enterInitial()
enterInitial():
void
Defined in: core/lib/scenes/GeneratorScene.d.ts:80
Enter the SceneState.Initial state.
Returns
void
Inherited from
GeneratorScene.enterInitial
execute()
protectedexecute<T>(callback):T
Defined in: core/lib/scenes/GeneratorScene.d.ts:93
Invoke the given callback in the context of this scene.
Type Parameters
T
T
Parameters
callback
() => T
The callback to invoke.
Returns
T
Remarks
This method makes sure that the context of this scene is globally available during the execution of the callback.
Inherited from
GeneratorScene.execute
getDetachedNodes()
getDetachedNodes():
Generator<Node,void,unknown>
Defined in: 2d/src/lib/scenes/Scene2D.ts:160
Returns
Generator<Node, void, unknown>
getMediaAssets()
getMediaAssets():
AssetInfo[]
Defined in: 2d/src/lib/scenes/Scene2D.ts:166
Returns
AssetInfo[]
Overrides
GeneratorScene.getMediaAssets
getNode()
getNode(
key):Node|null
Defined in: 2d/src/lib/scenes/Scene2D.ts:155
Parameters
key
any
Returns
Node | null
getNodeByPosition()
getNodeByPosition(
x,y):Node|null
Defined in: 2d/src/lib/scenes/Scene2D.ts:87
Parameters
x
number
y
number
Returns
Node | null
getRealSize()
getRealSize():
Vector2
Defined in: core/lib/scenes/GeneratorScene.d.ts:76
Get the real size of this scene.
Returns
Vector2
Remarks
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()
getSize():
Vector2
Defined in: core/lib/scenes/GeneratorScene.d.ts:75
Get the size of this scene.
Returns
Vector2
Remarks
Usually returns this.project.getSize().
Inherited from
GeneratorScene.getSize
getView()
getView():
View2D
Defined in: 2d/src/lib/scenes/Scene2D.ts:39
Returns
Overrides
GeneratorScene.getView
inspectAttributes()
inspectAttributes(
element):InspectedAttributes|null
Defined in: 2d/src/lib/scenes/Scene2D.ts:97
Return the attributes of the inspected element.
Parameters
element
unknown
The element to inspect.
Returns
InspectedAttributes | null
Remarks
This information will be displayed in the “Properties” panel.
Implementation of
Inspectable.inspectAttributes
inspectPosition()
inspectPosition(
x,y):unknown
Defined in: 2d/src/lib/scenes/Scene2D.ts:82
Get a possible element to inspect at a given position.
Parameters
x
number
The x coordinate.
y
number
The y coordinate.
Returns
unknown
Implementation of
Inspectable.inspectPosition
isAfterTransitionIn()
isAfterTransitionIn():
boolean
Defined in: core/lib/scenes/GeneratorScene.d.ts:77
Is this scene in the SceneState.AfterTransitionIn state?
Returns
boolean
Inherited from
GeneratorScene.isAfterTransitionIn
isCached()
isCached():
boolean
Defined in: core/lib/scenes/GeneratorScene.d.ts:83
Is this scene cached?
Returns
boolean
Remarks
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()
isFinished():
boolean
Defined in: core/lib/scenes/GeneratorScene.d.ts:79
Is this scene in the SceneState.Finished state?
Returns
boolean
Inherited from
GeneratorScene.isFinished
next()
next():
Promise<void>
Defined in: 2d/src/lib/scenes/Scene2D.ts:43
Returns
Promise<void>
Overrides
GeneratorScene.next
recalculate()
recalculate(
setFrame):Promise<void>
Defined in: core/lib/scenes/GeneratorScene.d.ts:72
Recalculate the scene.
Parameters
setFrame
(frame) => void
Returns
Promise<void>
Remarks
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.
Inherited from
GeneratorScene.recalculate
recreateView()
protectedrecreateView():void
Defined in: 2d/src/lib/scenes/Scene2D.ts:231
Returns
void
registerNode()
registerNode(
node,key?): [string, () =>void]
Defined in: 2d/src/lib/scenes/Scene2D.ts:135
Parameters
node
key?
string
Returns
[string, () => void]
reload()
reload(
description?):void
Defined in: core/lib/scenes/GeneratorScene.d.ts:71
Reload the scene.
Parameters
description?
SceneDescriptionReload<ThreadGeneratorFactory<View2D>>
If present, an updated version of the description.
Returns
void
Remarks
This method is called whenever something related to this scene has changed: time events, source code, metadata, etc.
Should trigger onReloaded.
Inherited from
GeneratorScene.reload
render()
render(
context):Promise<void>
Defined in: core/lib/scenes/GeneratorScene.d.ts:69
Render the scene onto a canvas.
Parameters
context
CanvasRenderingContext2D
The context to used when rendering.
Returns
Promise<void>
Inherited from
GeneratorScene.render
reset()
reset(
previousScene?):Promise<void>
Defined in: 2d/src/lib/scenes/Scene2D.ts:66
Parameters
previousScene?
Scene<unknown>
Returns
Promise<void>
Overrides
GeneratorScene.reset
stopAllMedia()
stopAllMedia():
void
Defined in: 2d/src/lib/scenes/Scene2D.ts:211
Returns
void
Overrides
GeneratorScene.stopAllMedia
transformMousePosition()
transformMousePosition(
x,y):Vector2|null
Defined in: 2d/src/lib/scenes/Scene2D.ts:128
Transform the absolute mouse coordinates into the scene’s coordinate system.
Parameters
x
number
The x coordinate.
y
number
The y coordinate.
Returns
Vector2 | null
Implementation of
Inspectable.transformMousePosition
update()
update():
void
Defined in: core/lib/scenes/GeneratorScene.d.ts:68
Update the view.
Invoked after each step of the main generator. Can be used for calculating layout.
Can modify the state of the view.
Returns
void
Inherited from
GeneratorScene.update
validateInspection()
validateInspection(
element):unknown
Defined in: 2d/src/lib/scenes/Scene2D.ts:91
Check if the inspected element is still valid.
Parameters
element
unknown
The element to validate.
Returns
unknown
Remarks
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.
Implementation of
Inspectable.validateInspection
Events
onCacheChanged
Get Signature
get onCacheChanged():
SubscribableValueEvent<CachedSceneData>
Defined in: core/lib/scenes/GeneratorScene.d.ts:31
Triggered when the cached data changes.
Returns
SubscribableValueEvent<CachedSceneData>
Inherited from
GeneratorScene.onCacheChanged
onRecalculated
Get Signature
get onRecalculated():
Subscribable<void,EventHandler<void>>
Defined in: core/lib/scenes/GeneratorScene.d.ts:35
Triggered after scene is recalculated.
Returns
Subscribable<void, EventHandler<void>>
Inherited from
GeneratorScene.onRecalculated
onReloaded
Get Signature
get onReloaded():
Subscribable<void,EventHandler<void>>
Defined in: core/lib/scenes/GeneratorScene.d.ts:33
Triggered when the scene is reloaded.
Returns
Subscribable<void, EventHandler<void>>
Inherited from
GeneratorScene.onReloaded
onRenderLifecycle
Get Signature
get onRenderLifecycle():
Subscribable<[SceneRenderEvent,CanvasRenderingContext2D],EventHandler<[SceneRenderEvent,CanvasRenderingContext2D]>>
Defined in: core/lib/scenes/GeneratorScene.d.ts:39
Triggered at various stages of the render lifecycle with an event title and a Context2D.
Returns
Subscribable<[SceneRenderEvent, CanvasRenderingContext2D], EventHandler<[SceneRenderEvent, CanvasRenderingContext2D]>>
Inherited from
GeneratorScene.onRenderLifecycle
onReset
Get Signature
get onReset():
Subscribable<void,EventHandler<void>>
Defined in: core/lib/scenes/GeneratorScene.d.ts:41
Triggered when the scene is reset.
Returns
Subscribable<void, EventHandler<void>>
Inherited from
GeneratorScene.onReset
onThreadChanged
Get Signature
get onThreadChanged():
SubscribableValueEvent<Thread|null>
Defined in: core/lib/scenes/GeneratorScene.d.ts:37
Triggered when the main thread changes.
Returns
SubscribableValueEvent<Thread | null>
Inherited from
GeneratorScene.onThreadChanged