Most visited

Recently visited

Scene

public class Scene
extends Object

java.lang.Object
   ↳ com.viro.core.Scene
Known Direct Subclasses
ARScene ARScene blends virtual 3D content with the device camera's view of the real world. 


Scene represents a scene graph - a hierarchy of Nodes that together represent the 3D world. UI controls, 3D objects, lights, camera, and more are attached to the Nodes to build the displayable 3D scene. To display a Scene in an Android View, use ViroView.

For an extended discussion of Viro's scene graph, refer to the Scene Guide.

Summary

Nested classes

enum Scene.AudioMaterial

AudioMaterial is used to define the Scene's reverb effects. 

class Scene.SceneBuilder<R extends Scene, B extends SceneBuilder<R, B>>

SceneBuilder for creating Scene objects. 

interface Scene.VisibilityListener

Receives callbacks in response to a Scene appearing and disappearing. 

Public constructors

Scene()

Construct a new Scene.

Public methods

static SceneBuilder<? extends Scene, ? extends SceneBuilder> builder()

Creates a builder for building complex Scene objects.

void dispose()

Release native resources associated with this Scene.

Texture getLightingEnvironment()

Get the lighting environment used by this Scene.

PhysicsWorld getPhysicsWorld()

Get the physics simulation for the Scene.

Node getRootNode()

Retrieve the root Node of the scene graph.

void setBackgroundCubeTexture(Texture cubeTexture)

Set the background of this Scene to display a cube-map.

void setBackgroundCubeWithColor(long color)

Set the background of this Scene to display the given color.

void setBackgroundRotation(Vector rotation)

Rotate the background image or video by the given radians about the X, Y, and Z axes.

void setBackgroundTexture(Texture texture)

Set the background of this Scene to display the texture.

void setLightingEnvironment(Texture lightingEnvironment)

Set the lighting environment to use for the Scene.

void setSoundRoom(ViroContext viroContext, Vector size, Scene.AudioMaterial wall, Scene.AudioMaterial ceiling, Scene.AudioMaterial floor)

Set the sound room, which enables reverb effects for all SpatialSound in the Scene.

void setVisibilityListener(Scene.VisibilityListener listener)

Set the given Scene.VisibilityListener to receive callbacks when the Scene's visibility status changes.

Public constructors

Scene

Scene ()

Construct a new Scene.

Public methods

builder

SceneBuilder<? extends Scene, ? extends SceneBuilder> builder ()

Creates a builder for building complex Scene objects.

Returns
SceneBuilder<? extends Scene, ? extends SceneBuilder> Scene.SceneBuilder object.

dispose

void dispose ()

Release native resources associated with this Scene.

getLightingEnvironment

Texture getLightingEnvironment ()

Get the lighting environment used by this Scene. The lighting environment is a Texture that acts as a global light source, illuminating surfaces with diffuse and specular ambient light.

Returns
Texture The equirectangular Texture being used as the lighting environment.

getPhysicsWorld

PhysicsWorld getPhysicsWorld ()

Get the physics simulation for the Scene.

Returns
PhysicsWorld The PhysicsWorld for the Scene.

getRootNode

Node getRootNode ()

Retrieve the root Node of the scene graph.

Returns
Node The root node.

setBackgroundCubeTexture

void setBackgroundCubeTexture (Texture cubeTexture)

Set the background of this Scene to display a cube-map. The provided Texture should wrap a cube-map image. The cube-map will be rendered behind all other content.

Parameters
cubeTexture Texture: The Texture containing the cube-map.

setBackgroundCubeWithColor

void setBackgroundCubeWithColor (long color)

Set the background of this Scene to display the given color. The color will be rendered behind all other content.

Parameters
color long: The Color's int value.

setBackgroundRotation

void setBackgroundRotation (Vector rotation)

Rotate the background image or video by the given radians about the X, Y, and Z axes.

Parameters
rotation Vector: Vector containing rotation about the X, Y, and Z axes.

setBackgroundTexture

void setBackgroundTexture (Texture texture)

Set the background of this Scene to display the texture. The provided Texture should contain a spherical image or spherical video. The image or video will be rendered behind all other content.

Parameters
texture Texture: The Texture containing the image, or VideoTexture containing the video.

setLightingEnvironment

void setLightingEnvironment (Texture lightingEnvironment)

Set the lighting environment to use for the Scene. The lighting environment is a Texture that acts as a global light source, illuminating surfaces with diffuse and specular ambient light. Each pixel in the lighting environment is treated as a light emitter, thereby capturing the environment's global lighting and general feel. This gives objects a sense of belonging to their environment. For this reason it is common to use the scene's background texture as the lighting environment, but this is not necessary.

This method expects an equirectangular texture. Radiance HDR textures (*.hdr) work best, and can be loaded with loadRadianceHDRTexture(Uri).

Parameters
lightingEnvironment Texture: The equirectangular Texture to use as the lighting environment.

setSoundRoom

void setSoundRoom (ViroContext viroContext, 
                Vector size, 
                Scene.AudioMaterial wall, 
                Scene.AudioMaterial ceiling, 
                Scene.AudioMaterial floor)

Set the sound room, which enables reverb effects for all SpatialSound in the Scene. The sound room is defined by three Scene.AudioMaterials, each of which has unique absorption properties which differ with frequency. The room is also give a size in meters, which is centered around the user. Larger rooms are more reverberant than smaller rooms, and harder surface materials are more reverberant than rooms made of soft, absorbent materials.

Parameters
viroContext ViroContext: ViroContext is required to set the sound room.

size Vector: The size of the room's X, Y, and Z dimensions in meters, as a Vector.

wall Scene.AudioMaterial: The wall Scene.AudioMaterial.

ceiling Scene.AudioMaterial: The ceiling Scene.AudioMaterial.

floor Scene.AudioMaterial: The floor Scene.AudioMaterial.

setVisibilityListener

void setVisibilityListener (Scene.VisibilityListener listener)

Set the given Scene.VisibilityListener to receive callbacks when the Scene's visibility status changes.

Parameters
listener Scene.VisibilityListener

Hooray!