SurfaceEntity
public final class SurfaceEntity extends BaseEntity
| java.lang.Object | |||
| ↳ | androidx.xr.scenecore.BaseScenePose | ||
| ↳ | androidx.xr.scenecore.BaseEntity | ||
| ↳ | androidx.xr.scenecore.SurfaceEntity |
SurfaceEntity is an Entity that hosts a Surface, which will be texture mapped onto the Shape. 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 Shape and StereoMode changes with application rendering or video decoding. Applications are advised to carefully hide this entity around state transitions (for example in response to video events) to manage glitchiness.
Summary
Nested types |
|---|
public abstract class SurfaceEntity.EdgeFeatheringParamsRepresents edge fading effects for a SurfaceEntity. |
public final class SurfaceEntity.EdgeFeatheringParams.NoFeathering extends SurfaceEntity.EdgeFeatheringParamsApplies no edge fading to any canvas. |
public final class SurfaceEntity.EdgeFeatheringParams.RectangleFeather extends SurfaceEntity.EdgeFeatheringParams |
public interface SurfaceEntity.ShapeRepresents the shape of the Canvas that backs a SurfaceEntity. |
public final class SurfaceEntity.Shape.Hemisphere implements SurfaceEntity.ShapeAn inwards-facing hemisphere-shaped canvas, where (0,0,0) is the center of the base of the hemisphere. |
public final class SurfaceEntity.Shape.Quad implements SurfaceEntity.ShapeA Quadrilateral-shaped canvas. |
public final class SurfaceEntity.Shape.Sphere implements SurfaceEntity.Shapecal An inwards-facing sphere-shaped mesh, centered at (0,0,0) in the local coordinate space. |
public final class SurfaceEntity.StereoModeSpecifies how the surface content will be routed for stereo viewing. |
public final class SurfaceEntity.SuperSamplingSpecifies whether super sampling should be enabled for this surface. |
public final class SurfaceEntity.SurfaceProtectionSpecifies whether the |
Public methods |
|
|---|---|
static final @NonNull SurfaceEntity |
@MainThreadPublic factory function for a SurfaceEntity. |
final @NonNull FloatSize3d |
Returns the size of the canvas in the local spatial coordinate system of the entity. |
final @NonNull SurfaceEntity.EdgeFeatheringParams |
The |
final @NonNull PerceivedResolutionResult |
Gets the perceived resolution of the entity in the camera view. |
final @NonNull SurfaceEntity.Shape |
getShape()The shape of the canvas that backs the Entity. |
final @NonNull SurfaceEntity.StereoMode |
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 |
@MainThreadThe |
final void |
@MainThreadThe shape of the canvas that backs the Entity. |
final void |
@MainThreadControls how the surface content will be routed for stereo viewing. |
Inherited methods |
||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
Public methods
create
@MainThread
public static final @NonNull SurfaceEntity create(
@NonNull Session session,
@NonNull Pose pose,
@NonNull SurfaceEntity.Shape shape,
@NonNull SurfaceEntity.StereoMode stereoMode,
@NonNull SurfaceEntity.SuperSampling superSampling,
@NonNull SurfaceEntity.SurfaceProtection surfaceProtection
)
Public factory function for a SurfaceEntity.
| Parameters | |
|---|---|
@NonNull Session session |
Session to create the SurfaceEntity in. |
@NonNull Pose pose |
Pose of this entity relative to its parent, default value is Identity. |
@NonNull SurfaceEntity.Shape shape |
The |
@NonNull SurfaceEntity.StereoMode stereoMode |
Stereo mode for the surface. |
@NonNull SurfaceEntity.SuperSampling superSampling |
The |
@NonNull SurfaceEntity.SurfaceProtection surfaceProtection |
The |
| Returns | |
|---|---|
@NonNull SurfaceEntity |
a SurfaceEntity instance |
getDimensions
public final @NonNull FloatSize3d getDimensions()
Returns the size of the canvas in the local spatial coordinate system of the entity.
This value is entirely determined by the value of shape.
getEdgeFeatheringParams
public final @NonNull SurfaceEntity.EdgeFeatheringParams getEdgeFeatheringParams()
The EdgeFeatheringParams feathering pattern to be used along the edges of the Shape. This value must only be set from the main thread.
| Throws | |
|---|---|
kotlin.IllegalStateException |
when setting this value if the Entity has been disposed. |
getPerceivedResolution
public final @NonNull PerceivedResolutionResult getPerceivedResolution()
Gets the perceived resolution of the entity in the camera view.
This API is only intended for use in Full Space Mode and will return PerceivedResolutionResult.InvalidCameraView in Home Space Mode.
The entity's own rotation and the camera's viewing direction are disregarded; this value represents the dimensions of the entity on the camera view if its largest surface was facing the camera without changing the distance of the entity to the camera.
| Returns | |
|---|---|
@NonNull PerceivedResolutionResult |
A |
| Throws | |
|---|---|
kotlin.IllegalStateException |
if |
| See also | |
|---|---|
PerceivedResolutionResult |
getShape
public final @NonNull SurfaceEntity.Shape getShape()
The shape of the canvas that backs the Entity. Updating this value will alter the dimensions of the Entity.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if an invalid canvas shape is provided. |
kotlin.IllegalStateException |
when setting this value if the Entity has been disposed. |
getStereoMode
public final @NonNull SurfaceEntity.StereoMode 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.
| Throws | |
|---|---|
kotlin.IllegalStateException |
when setting this value if the Entity has been disposed. |
getSurface
@MainThread
public final @NonNull Surface getSurface()
Returns a surface into which the application can render stereo image content. Note that android.graphics.Canvas Apis are not currently supported on this Canvas.
| Throws | |
|---|---|
kotlin.IllegalStateException |
if the Entity has been disposed. |
setEdgeFeatheringParams
@MainThread
public final void setEdgeFeatheringParams(
@NonNull SurfaceEntity.EdgeFeatheringParams edgeFeatheringParams
)
The EdgeFeatheringParams feathering pattern to be used along the edges of the Shape. This value must only be set from the main thread.
| Throws | |
|---|---|
kotlin.IllegalStateException |
when setting this value if the Entity has been disposed. |
setShape
@MainThread
public final void setShape(@NonNull SurfaceEntity.Shape shape)
The shape of the canvas that backs the Entity. Updating this value will alter the dimensions of the Entity.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if an invalid canvas shape is provided. |
kotlin.IllegalStateException |
when setting this value if the Entity has been disposed. |
setStereoMode
@MainThread
public final void setStereoMode(@NonNull SurfaceEntity.StereoMode 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.
| Throws | |
|---|---|
kotlin.IllegalStateException |
when setting this value if the Entity has been disposed. |