StereoSurfaceEntity


public final class StereoSurfaceEntity extends BaseEntity


StereoSurfaceEntity is a concrete implementation of Entity that hosts a StereoSurface Canvas. The entity creates and owns an Android Surface into which the application can render stereo image content. This Surface is then texture mapped to the canvas, and if a stereoscopic StereoMode is specified, then the User will see left and right eye content mapped to the appropriate display.

Note that it is not currently possible to synchronize CanvasShape and StereoMode changes with application rendering or video decoding. Applications are advised to carefully hide this entity around transitions to manage glitchiness.

Summary

Nested types

public abstract class StereoSurfaceEntity.CanvasShape

Represents the shape of the StereoSurface Canvas that backs a StereoSurfaceEntity.

public static class StereoSurfaceEntity.StereoMode

Public methods

static final @NonNull StereoSurfaceEntity
@MainThread
create(
    @NonNull Session session,
    int stereoMode,
    @NonNull Pose pose,
    @NonNull StereoSurfaceEntity.CanvasShape canvasShape
)

Public factory function for a StereoSurfaceEntity.

final @NonNull StereoSurfaceEntity.CanvasShape

The shape of the canvas that backs the Entity.

final @NonNull Dimensions

Returns the dimensions of the Entity.

final int

Controls how the surface content will be routed for stereo viewing.

final @NonNull Surface

Returns a surface into which the application can render stereo image content.

final void

The shape of the canvas that backs the Entity.

final void
@MainThread
setStereoMode(int stereoMode)

Controls how the surface content will be routed for stereo viewing.

Inherited methods

From androidx.xr.scenecore.ActivityPose
abstract @NonNull Pose

Returns the activity space pose for this ActivityPose.

abstract @NonNull Pose

Returns a pose relative to this ActivityPose transformed into a pose relative to the destination.

From androidx.xr.scenecore.BaseEntity
void

Sets an Entity to be represented in this coordinate space.

boolean

Adds a Component to this Entity.

void

Disposes of any system resources held by this Entity, and transitively calls dispose() on all its children.

float

Returns the global alpha of this entity computed by multiplying the parent's global alpha to this entity's local alpha.

float

Returns the alpha transparency set for this Entity.

@NonNull List<@NonNull Component>

Retrieves all components attached to this Entity.

@NonNull List<@NonNull T>

Retrieves all Components of the given type T and its sub-types attached to this Entity.

Entity

Returns the parent of this Entity.

@NonNull Pose

Returns the pose for this entity, relative to its parent.

float

Returns the local scale of this entity, not inclusive of the parent's scale.

@NonNull Dimensions

Returns the dimensions (in meters) for this Entity.

float

Returns the accumulated scale of this Entity.

boolean
isHidden(boolean includeParents)

Returns the hidden status of this Entity.

void

Remove all components from this Entity.

void

Removes the given Component from this Entity.

void
setAlpha(float alpha)

Sets the alpha transparency of the Entity and its children.

void

Sets alternate text for this entity to be consumed by Accessibility systems.

void
setHidden(boolean hidden)

Sets the local hidden state of this Entity.

void
setParent(Entity parent)

Sets this Entity to be represented in the parent's coordinate space.

void

Sets the pose for this Entity, relative to its parent.

void
setScale(float scale)

Sets the scale of this entity relative to its parent.

void
setSize(@NonNull Dimensions dimensions)

Sets the dimensions in pixels for the Entity.

Public methods

create

Added in 1.0.0-alpha02
@MainThread
public static final @NonNull StereoSurfaceEntity create(
    @NonNull Session session,
    int stereoMode,
    @NonNull Pose pose,
    @NonNull StereoSurfaceEntity.CanvasShape canvasShape
)

Public factory function for a StereoSurfaceEntity.

This method must be called from the main thread. https://developer.android.com/guide/components/processes-and-threads

Parameters
@NonNull Session session

Session to create the StereoSurfaceEntity in.

int stereoMode

Stereo mode for the surface.

@NonNull Pose pose

Pose of this entity relative to its parent, default value is Identity.

@NonNull StereoSurfaceEntity.CanvasShape canvasShape

The CanvasShape which describes the spatialized shape of the canvas.

Returns
@NonNull StereoSurfaceEntity

a StereoSurfaceEntity instance

getCanvasShape

Added in 1.0.0-alpha02
public final @NonNull StereoSurfaceEntity.CanvasShape getCanvasShape()

The shape of the canvas that backs the Entity.

Updating this value will alter the dimensions of the Entity.

getDimensions

Added in 1.0.0-alpha02
public final @NonNull Dimensions getDimensions()

Returns the dimensions of the Entity.

This is the size of the canvas in the local spatial coordinate system of the entity. This field cannot be directly set - to update the dimensions of the canvas, update the value of canvasShape.

getStereoMode

Added in 1.0.0-alpha02
public final int getStereoMode()

Controls how the surface content will be routed for stereo viewing. Applications must render into the surface in accordance with what is specified here in order for the compositor to correctly produce a stereoscopic view to the user.

Values must be one of the values from StereoMode.

getSurface

Added in 1.0.0-alpha02
@MainThread
public final @NonNull Surface getSurface()

Returns a surface into which the application can render stereo image content.

This method must be called from the main thread. https://developer.android.com/guide/components/processes-and-threads

setCanvasShape

Added in 1.0.0-alpha02
@MainThread
public final void setCanvasShape(@NonNull StereoSurfaceEntity.CanvasShape canvasShape)

The shape of the canvas that backs the Entity.

Updating this value will alter the dimensions of the Entity.

setStereoMode

Added in 1.0.0-alpha02
@MainThread
public final void setStereoMode(int stereoMode)

Controls how the surface content will be routed for stereo viewing. Applications must render into the surface in accordance with what is specified here in order for the compositor to correctly produce a stereoscopic view to the user.

Values must be one of the values from StereoMode.