public class PanelEntity implements ScenePose, Entity

Known direct subclasses
ActivityPanelEntity

ActivityPanelEntity creates a spatial panel for embedding an Activity in Android XR.

MainPanelEntity

Represents the main spatialized panel in a Scene.


PanelEntity contains an arbitrary 2D Android View, within a spatialized XR scene.

Summary

Public methods

static final @NonNull PanelEntity
create(
    @NonNull Session session,
    @NonNull View view,
    @NonNull FloatSize2d dimensions,
    @NonNull String name,
    @NonNull Pose pose
)

Factory method for a spatialized PanelEntity.

static final @NonNull PanelEntity
create(
    @NonNull Session session,
    @NonNull View view,
    @NonNull IntSize2d pixelDimensions,
    @NonNull String name,
    @NonNull Pose pose
)

Factory method for a spatialized PanelEntity.

final float

The corner radius of the PanelEntity, in meters.

final @NonNull PerceivedResolutionResult

Gets the perceived resolution of this Entity in the CameraView.

final @NonNull FloatSize2d

The dimensions of this PanelEntity in local space, in units relative to the scale of this Entity's parent.

final @NonNull IntSize2d

The dimensions of this PanelEntity, in pixels, which is the resolution of the underlying surface.

final boolean

True if this panel is the MainPanelEntity, false otherwise.

final void
setCornerRadius(float cornerRadius)

The corner radius of the PanelEntity, in meters.

final void

The dimensions of this PanelEntity in local space, in units relative to the scale of this Entity's parent.

final void

The dimensions of this PanelEntity, in pixels, which is the resolution of the underlying surface.

Inherited methods

From androidx.xr.scenecore.Entity
@FloatRange(from = 0.0, to = 1.0) float

Returns the alpha transparency set for this Entity.

@NonNull Pose

Returns the Pose for this Entity, relative to its parent.

@FloatRange(from = 0.0) float

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

void
setAlpha(@FloatRange(from = 0.0, to = 1.0) float alpha)

Sets the alpha transparency of the Entity and its children.

void

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

void
setScale(@FloatRange(from = 0.0) float scale)

Sets the scale of this Entity relative to its parent.

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

The current Pose relative to the activity space root.

abstract @NonNull HitTestResult
hitTest(@NonNull Vector3 origin, @NonNull Vector3 direction)

Creates a hit test from the specified origin in the specified direction into the Scene.

abstract @NonNull HitTestResult
hitTest(
    @NonNull Vector3 origin,
    @NonNull Vector3 direction,
    int hitTestFilter
)

Creates a hit test from the specified origin in the specified direction into the scene.

abstract @NonNull Pose
transformPoseTo(@NonNull Pose pose, @NonNull ScenePose destination)

Returns a Pose relative to this ScenePose, transformed into a Pose relative to the destination.

Public methods

create

Added in 1.0.0-alpha05
public static final @NonNull PanelEntity create(
    @NonNull Session session,
    @NonNull View view,
    @NonNull FloatSize2d dimensions,
    @NonNull String name,
    @NonNull Pose pose
)

Factory method for a spatialized PanelEntity.

Parameters
@NonNull Session session

XR Session in which to create the PanelEntity.

@NonNull View view

View to embed in this panel entity.

@NonNull FloatSize2d dimensions

Spatialized dimensions for the underlying surface for the given view, in meters.

@NonNull String name

Name of this PanelEntity.

@NonNull Pose pose

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

Returns
@NonNull PanelEntity

a PanelEntity instance.

create

Added in 1.0.0-alpha05
public static final @NonNull PanelEntity create(
    @NonNull Session session,
    @NonNull View view,
    @NonNull IntSize2d pixelDimensions,
    @NonNull String name,
    @NonNull Pose pose
)

Factory method for a spatialized PanelEntity.

Parameters
@NonNull Session session

XR Session in which to create the PanelEntity.

@NonNull View view

View to embed in this panel entity.

@NonNull IntSize2d pixelDimensions

Dimensions for the underlying surface for the given view, in pixels.

@NonNull String name

Name of the panel.

@NonNull Pose pose

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

Returns
@NonNull PanelEntity

a PanelEntity instance.

getCornerRadius

Added in 1.0.0-alpha05
public final float getCornerRadius()

The corner radius of the PanelEntity, in meters.

getPerceivedResolution

Added in 1.0.0-alpha05
public final @NonNull PerceivedResolutionResult getPerceivedResolution()

Gets the perceived resolution of this Entity in the CameraView.

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 PerceivedResolutionResult which encapsulates the outcome: - PerceivedResolutionResult.Success containing the PixelDimensions if the calculation is successful. - PerceivedResolutionResult.EntityTooClose if the Entity is too close to the camera. - PerceivedResolutionResult.InvalidCameraView if the camera information required for the calculation is invalid or unavailable.

Throws
kotlin.IllegalStateException

if Session.config.headTracking is set to Config.HeadTrackingMode.DISABLED.

getSize

Added in 1.0.0-alpha05
public final @NonNull FloatSize2d getSize()

The dimensions of this PanelEntity in local space, in units relative to the scale of this Entity's parent.

getSizeInPixels

Added in 1.0.0-alpha05
public final @NonNull IntSize2d getSizeInPixels()

The dimensions of this PanelEntity, in pixels, which is the resolution of the underlying surface.

This API doesn't do any scale compensation to the pixel dimensions.

isMainPanelEntity

Added in 1.0.0-alpha05
public final boolean isMainPanelEntity()

True if this panel is the MainPanelEntity, false otherwise.

setCornerRadius

Added in 1.0.0-alpha05
public final void setCornerRadius(float cornerRadius)

The corner radius of the PanelEntity, in meters.

setSize

Added in 1.0.0-alpha05
public final void setSize(@NonNull FloatSize2d size)

The dimensions of this PanelEntity in local space, in units relative to the scale of this Entity's parent.

setSizeInPixels

Added in 1.0.0-alpha05
public final void setSizeInPixels(@NonNull IntSize2d sizeInPixels)

The dimensions of this PanelEntity, in pixels, which is the resolution of the underlying surface.

This API doesn't do any scale compensation to the pixel dimensions.