open class PanelEntity : BaseEntity

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 companion functions

PanelEntity
create(
    session: Session,
    view: View,
    dimensions: FloatSize2d,
    name: String,
    pose: Pose
)

Factory method for a spatialized PanelEntity.

PanelEntity
create(
    session: Session,
    view: View,
    pixelDimensions: IntSize2d,
    name: String,
    pose: Pose
)

Factory method for a spatialized PanelEntity.

Public functions

PerceivedResolutionResult

Gets the perceived resolution of this Entity in the CameraView.

Public properties

Float

The corner radius of the PanelEntity, in meters.

Boolean

True if this panel is the MainPanelEntity, false otherwise.

FloatSize2d

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

IntSize2d

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

Inherited functions

From androidx.xr.scenecore.BaseEntity
open Unit
addChild(child: Entity)

Sets an Entity to be a child of this Entity in the scene graph.

open Boolean
addComponent(component: Component)

Adds a Component to this Entity.

open Unit

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

open Float
getAlpha(relativeTo: Int)

Returns the alpha transparency set for this Entity, relative to given Space.

open List<Component>

Retrieves all components attached to this Entity.

open List<T>

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

open Pose
getPose(relativeTo: Int)

Returns the Pose for this Entity, relative to the provided Space.

open Float
getScale(relativeTo: Int)

Returns the scale of this entity, relative to given space.

open Boolean
isEnabled(includeParents: Boolean)

Returns the enabled status of this Entity.

open Unit

Remove all components from this Entity.

open Unit

Removes the given Component from this Entity.

open Unit
setAlpha(alpha: Float, relativeTo: Int)

Sets the alpha transparency of the Entity relative to given Space.

open Unit
setEnabled(enabled: Boolean)

Sets the local enabled state of this Entity.

open Unit
setPose(pose: Pose, relativeTo: Int)

Sets the Pose for this Entity.

open Unit
setScale(scale: Float, relativeTo: Int)

Sets the scale of this Entity relative to given Space.

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

Returns the alpha transparency set for this Entity.

open Pose

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

open @FloatRange(from = 0.0) Float

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

open Unit
setAlpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float)

Sets the alpha transparency of the Entity and its children.

open Unit
setPose(pose: Pose)

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

open Unit
setScale(scale: @FloatRange(from = 0.0) Float)

Sets the scale of this Entity relative to its parent.

From androidx.xr.scenecore.ScenePose
abstract suspend HitTestResult
hitTest(origin: Vector3, direction: Vector3)

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

abstract suspend HitTestResult
hitTest(origin: Vector3, direction: Vector3, hitTestFilter: Int)

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

abstract Pose
transformPoseTo(pose: Pose, destination: ScenePose)

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

Inherited properties

From androidx.xr.scenecore.BaseEntity
open CharSequence

Alternate text for this Entity to be consumed by Accessibility systems.

open Entity?

The parent of this Entity, from which this Entity will inherit most of its properties.

From androidx.xr.scenecore.ScenePose
abstract Pose

The current Pose relative to the activity space root.

Public companion functions

create

Added in 1.0.0-alpha06
fun create(
    session: Session,
    view: View,
    dimensions: FloatSize2d,
    name: String,
    pose: Pose = Pose.Identity
): PanelEntity

Factory method for a spatialized PanelEntity.

Parameters
session: Session

XR Session in which to create the PanelEntity.

view: View

View to embed in this panel entity.

dimensions: FloatSize2d

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

name: String

Name of this PanelEntity.

pose: Pose = Pose.Identity

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

Returns
PanelEntity

a PanelEntity instance.

create

Added in 1.0.0-alpha06
fun create(
    session: Session,
    view: View,
    pixelDimensions: IntSize2d,
    name: String,
    pose: Pose = Pose.Identity
): PanelEntity

Factory method for a spatialized PanelEntity.

Parameters
session: Session

XR Session in which to create the PanelEntity.

view: View

View to embed in this panel entity.

pixelDimensions: IntSize2d

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

name: String

Name of the panel.

pose: Pose = Pose.Identity

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

Returns
PanelEntity

a PanelEntity instance.

Public functions

getPerceivedResolution

Added in 1.0.0-alpha06
fun getPerceivedResolution(): PerceivedResolutionResult

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
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.

Public properties

cornerRadius

Added in 1.0.0-alpha06
var cornerRadiusFloat

The corner radius of the PanelEntity, in meters.

isMainPanelEntity

Added in 1.0.0-alpha06
val isMainPanelEntityBoolean

True if this panel is the MainPanelEntity, false otherwise.

size

Added in 1.0.0-alpha06
var sizeFloatSize2d

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

sizeInPixels

Added in 1.0.0-alpha06
var sizeInPixelsIntSize2d

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.