Skip to main content

Scene

                            
                              
                                interface 
                                Scene
                                
                                  
                                    
                                      T
                                       = 
                                      unknown
                                    
                                  
                                
                              
                              

The main interface for scenes.

Any class implementing this interface should have a constructor matching SceneConstructor .

Type Parameters

  • T = unknown

    The type of the configuration object.

Implemented by

  • GeneratorScene

Properties

creationStack

                            
                              
                                creationStack
                                ?: 
                                string
                              
                              

logger

                            
                              
                                readonly 
                                logger
                                : 
                                Logger
                              
                              

meta

                            
                              
                                readonly 
                                meta
                                : 
                                ObjectMetaField
                                
                                  
                                    
                                      
                                        
                                          
                                            seed
                                            : 
                                            MetaField
                                            
                                              
                                                
                                                  any
                                                
                                                
                                                  number
                                                
                                              
                                            
                                             = 
                                            ...
                                          
                                          
                                            timeEvents
                                            : 
                                            MetaField
                                            
                                              
                                                
                                                  SerializedTimeEvent
                                                  []
                                                
                                                
                                                  SerializedTimeEvent
                                                  []
                                                
                                              
                                            
                                             = 
                                            ...
                                          
                                          
                                            version
                                            : 
                                            MetaField
                                            
                                              
                                                
                                                  any
                                                
                                                
                                                  number
                                                
                                              
                                            
                                             = 
                                            ...
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

name

                            
                              
                                readonly 
                                name
                                : 
                                string
                              
                              

Name of the scene.

Will be passed as the second argument to the constructor.


playback

                            
                              
                                readonly 
                                playback
                                : 
                                PlaybackStatus
                              
                              

Reference to the project.


random

                            
                              
                                readonly 
                                random
                                : 
                                Random
                              
                              

slides

                            
                              
                                readonly 
                                slides
                                : 
                                Slides
                              
                              

timeEvents

                            
                              
                                readonly 
                                timeEvents
                                : 
                                TimeEvents
                              
                              

variables

                            
                              
                                readonly 
                                variables
                                : 
                                Variables
                              
                              

Accessors

LifecycleEvents

                            
                              
                                public 
                                get 
                                LifecycleEvents
                                (): 
                                LifecycleEvents
                              
                              

The LifecycleEvents of this scene.

Deprecated

Use lifecycleEvents instead.


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 LifecycleEvents of this scene.


previous

                            
                              
                                public 
                                get 
                                previous
                                (): 
                                
                                  
                                    
                                      null
                                    
                                    
                                      Scene
                                      
                                        
                                          
                                            unknown
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

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

Events

onCacheChanged

                            
                              
                                public 
                                get 
                                onCacheChanged
                                (): 
                                SubscribableValueEvent
                                
                                  
                                    
                                      CachedSceneData
                                    
                                  
                                
                              
                              

Triggered when the cached data changes.


onRecalculated

                            
                              
                                public 
                                get 
                                onRecalculated
                                (): 
                                SubscribableEvent
                                
                                  
                                    
                                      void
                                    
                                  
                                
                              
                              

Triggered after scene is recalculated.


onReloaded

                            
                              
                                public 
                                get 
                                onReloaded
                                (): 
                                SubscribableEvent
                                
                                  
                                    
                                      void
                                    
                                  
                                
                              
                              

Triggered when the scene is reloaded.


onRenderLifecycle

                            
                              
                                public 
                                get 
                                onRenderLifecycle
                                (): 
                                SubscribableEvent
                                
                                  
                                    
                                      
                                        
                                          
                                            SceneRenderEvent
                                          
                                          
                                            CanvasRenderingContext2D
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

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


onReset

                            
                              
                                public 
                                get 
                                onReset
                                (): 
                                SubscribableEvent
                                
                                  
                                    
                                      void
                                    
                                  
                                
                              
                              

Triggered when the scene is reset.

Methods

canTransitionOut

                            
                              
                                public 
                                canTransitionOut
                                (): 
                                boolean
                              
                              

Is this scene in the CanTransitionOut state?


enterAfterTransitionIn

                            
                              
                                public 
                                enterAfterTransitionIn
                                (): 
                                void
                              
                              

Enter the AfterTransitionIn state.


enterCanTransitionOut

                            
                              
                                public 
                                enterCanTransitionOut
                                (): 
                                void
                              
                              

Enter the CanTransitionOut state.


enterInitial

                            
                              
                                public 
                                enterInitial
                                (): 
                                void
                              
                              

Enter the Initial state.


getSize

                            
                              
                                public 
                                getSize
                                (): 
                                Vector2
                              
                              

Get the size of this scene.

Usually return this.project.getSize() .


isAfterTransitionIn

                            
                              
                                public 
                                isAfterTransitionIn
                                (): 
                                boolean
                              
                              

Is this scene in the AfterTransitionIn state?


isCached

                            
                              
                                public 
                                isCached
                                (): 
                                boolean
                              
                              

Is this scene cached?

Used only by GeneratorScene . Seeking through a project thatcontains 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 Finished state?


next

                            
                              
                                public 
                                next
                                (): 
                                Promise
                                
                                  
                                    
                                      void
                                    
                                  
                                
                              
                              

Progress this scene one frame forward.


recalculate

                            
                              
                                public 
                                recalculate
                                
                                  
                                    
                                      setFrame
                                      : 
                                      public 
                                      
                                      ()
                                    
                                  
                                
                                : 
                                Promise
                                
                                  
                                    
                                      void
                                    
                                  
                                
                              
                              

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 atwhich this scene should start ( firstFrame ).

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

Should trigger onRecalculated .

Parameters


reload

                            
                              
                                public 
                                reload
                                
                                  
                                    
                                      description
                                      ?: 
                                      SceneDescriptionReload
                                      
                                        
                                          
                                            T
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                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 ?: SceneDescriptionReload T

    If present, an updated version of the description.


render

                            
                              
                                public 
                                render
                                
                                  
                                    
                                      context
                                      : 
                                      CanvasRenderingContext2D
                                    
                                  
                                
                                : 
                                Promise
                                
                                  
                                    
                                      void
                                    
                                  
                                
                              
                              

Render the scene onto a canvas.

Parameters


reset

                            
                              
                                public 
                                reset
                                
                                  
                                    
                                      previous
                                      ?: 
                                      Scene
                                      
                                        
                                          
                                            unknown
                                          
                                        
                                      
                                    
                                  
                                
                                : 
                                Promise
                                
                                  
                                    
                                      void
                                    
                                  
                                
                              
                              

Reset this scene to its initial state.

Parameters

  • previous ?: Scene unknown

    If present, the previous scene.