-
Notifications
You must be signed in to change notification settings - Fork 6
Scene
The scene makes up the core of the rendering portion of the application. This contains metadata about what is being rendered, and it works with the underlying threejs library to control what is actually rendered in the scene.
The entry point for the scene is scene.js. The scene is controlled with mainly 3 functions:
-
AddToScene()
- Adds content to the scene -
RemoveFromScene()
- Removes content from the scene -
SetTime()
- Specifies the current time of the scene
There's a lot of behind the scenes work that goes into building the scene. AddToScene()
takes a set of parameters that are passed along to Images which will return image data. The Image data is forwarded to the Model Factory which converts images into textures, and applies those textures to a Model. The model then contains both an actual 3D model, a list of textures, the dates for those textures, and the observer's position for those textures. The observer position is the point in space where the image was taken from, this is used to orient the model to make sure the image being displayed is pointing towards the observatory that created the image.
Since the models each have a list of textures with timestamps, when the Scene time is updated, the Scene will notify all the models to select their texture that is nearest to the scene time. In this way, all models in the scene will update their images and re-orient themselves in the scene. Animation is achieved by simply updating the scene time at a regular interval like 24fps. The time is set with the SetTime()
function.
RemoveFromScene()
is used to remove specific models from the scene that are no longer required.
The scene contains some callbacks which are used to notify the UI elements of changes to the scene. Typically the UI's React state will be updated in these callbacks.