SceneView

public class SceneView
Known Direct Subclasses

A Sceneform SurfaceView that manages rendering and interaction with the scene.

Inherited Constants

Inherited Fields

Public Constructors

SceneView(Context context)
Constructs a SceneView object and binds it to an Android Context.
SceneView(Context context, AttributeSet attrs)
Constructs a SceneView object and binds it to an Android Context.

Public Methods

void
destroy()
Required to exit Sceneform.
static void
destroyAllResources()
Immediately releases all rendering resources, even if in use.
void
enableDebug(boolean enable)
If enabled, provides various visualizations for debugging.
Scene
getScene()
Returns the Sceneform Scene created by this view.
boolean
isDebugEnabled()
Indicates whether debugging is enabled for this view.
boolean
onTouchEvent(MotionEvent motionEvent)
void
pause()
Pause Sceneform, which pauses the rendering thread.
static long
reclaimReleasedResources()
Releases rendering resources ready for garbage collection

Called every frame to collect unused resources.

void
resume()
Resume Sceneform, which resumes the rendering thread.
void
setBackground(Drawable background)
Set the background to a given Drawable, or remove the background.
void
startMirroringToSurface(Surface surface, int left, int bottom, int width, int height)
To capture the contents of this view, designate a Surface onto which this SceneView should be mirrored.
void
stopMirroringToSurface(Surface surface)
When capturing is complete, call this method to stop mirroring the SceneView to the specified Surface.

Inherited Methods

Public Constructors

public SceneView (Context context)

Constructs a SceneView object and binds it to an Android Context.

Parameters
context the Android Context to use

public SceneView (Context context, AttributeSet attrs)

Constructs a SceneView object and binds it to an Android Context.

Parameters
context the Android Context to use
attrs the Android AttributeSet to associate with

Public Methods

public void destroy ()

Required to exit Sceneform.

Typically called from onDestroy().

public static void destroyAllResources ()

Immediately releases all rendering resources, even if in use.

Use this if nothing more will be rendered in this scene or any other, and the memory must be released immediately.

public void enableDebug (boolean enable)

If enabled, provides various visualizations for debugging.

Parameters
enable True to enable debugging visualizations, false to disable it.

public Scene getScene ()

Returns the Sceneform Scene created by this view.

public boolean isDebugEnabled ()

Indicates whether debugging is enabled for this view.

public boolean onTouchEvent (MotionEvent motionEvent)

Parameters
motionEvent

public void pause ()

Pause Sceneform, which pauses the rendering thread.

Typically called from onPause().

public static long reclaimReleasedResources ()

Releases rendering resources ready for garbage collection

Called every frame to collect unused resources. May be called manually to release resources after rendering has stopped.

Returns
  • Count of resources currently in use

public void resume ()

Resume Sceneform, which resumes the rendering thread.

Typically called from onResume().

Throws
CameraNotAvailableException

public void setBackground (Drawable background)

Set the background to a given Drawable, or remove the background. If the background is a ColorDrawable, then the background color of the Scene is set to getColor() (the alpha of the color is ignored). Otherwise, default to the behavior of setBackground(Drawable).

Parameters
background

public void startMirroringToSurface (Surface surface, int left, int bottom, int width, int height)

To capture the contents of this view, designate a Surface onto which this SceneView should be mirrored. Use getSurface(), createInputSurface() or createPersistentInputSurface() to obtain the input surface for recording. This will incur a rendering performance cost and should only be set when capturing this view. To stop the additional rendering, call stopMirroringToSurface.

Parameters
surface the Surface onto which the rendered scene should be mirrored.
left the left edge of the rectangle into which the view should be mirrored on surface.
bottom the bottom edge of the rectangle into which the view should be mirrored on surface.
width the width of the rectangle into which the SceneView should be mirrored on surface.
height the height of the rectangle into which the SceneView should be mirrored on surface.

public void stopMirroringToSurface (Surface surface)

When capturing is complete, call this method to stop mirroring the SceneView to the specified Surface. If this is not called, the additional performance cost will remain.

The application is responsible for calling release() on the Surface when done.

Parameters
surface