MainPanelEntity


class MainPanelEntity : PanelEntity


Represents the main spatialized panel in a Scene.

This entity serves as the primary 2D surface for the application, especially in Home Space, where it functions as the activity's main window.

Summary

Public functions

Unit

Sets the listener to be invoked on the Main Thread Executor when the perceived resolution of the main window changes in Home Space.

Unit
addPerceivedResolutionChangedListener(
    callbackExecutor: Executor,
    listener: Consumer<IntSize2d>
)

Sets the listener to be invoked when the perceived resolution of the main window changes in Home Space.

Unit

Releases the listener previously added by addPerceivedResolutionChangedListener.

Inherited functions

From androidx.xr.scenecore.BaseScenePose
open suspend HitTestResult?
hitTest(origin: Vector3, direction: Vector3)

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

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

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

open Vector3
transformDirectionTo(direction: Vector3, destination: ScenePose)

Transforms a direction from this ScenePose's local space to the destination ScenePose's local space.

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

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

open Vector3
transformPositionTo(position: Vector3, destination: ScenePose)

Transforms a position from this ScenePose's local space to the destination ScenePose's local space.

open Vector3
transformVectorTo(vector: Vector3, destination: ScenePose)

Transforms a vector from this ScenePose's local space to the destination ScenePose's local space.

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

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

Boolean
addComponent(component: Component)

Adds a Component to this Entity.

@FloatRange(from = 0.0, to = 1.0) Float
getAlpha(relativeTo: Space)

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

List<Component>

Retrieves all components attached to this Entity.

List<T>

Retrieves all Components of the given type T and its subtypes attached to this Entity.

open Pose
getPose(relativeTo: Space)

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

open @FloatRange(from = 0.0) Float
getScale(relativeTo: Space)

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

Boolean
isEnabled(includeParents: Boolean)

Returns the enabled status of this Entity.

Unit

Remove all components from this Entity.

Unit

Removes the given Component from this Entity.

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

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

Unit
setEnabled(enabled: Boolean)

Sets the local enabled state of this Entity.

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

Sets the Pose for this Entity.

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

Sets the scale of this Entity relative to the given Space.

From androidx.xr.scenecore.PanelEntity
PerceivedResolutionResult

Gets the perceived resolution of this Entity in the provided RenderViewpoint.

Vector3

Gets the 3D position of a 2D normalized extent coordinate within the entity's local space.

Vector3

Gets the 3D position of a 2D pixel coordinate within the entity's local space.

Inherited properties

From androidx.xr.scenecore.BaseScenePose
open Pose

The current Pose relative to the activity space root.

From androidx.xr.scenecore.Entity
List<Entity>

Provides the list of all children of this entity.

CharSequence

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

Entity?

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

From androidx.xr.scenecore.PanelEntity
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.

Public functions

addPerceivedResolutionChangedListener

Added in 1.0.0-alpha16
fun addPerceivedResolutionChangedListener(listener: Consumer<IntSize2d>): Unit

Sets the listener to be invoked on the Main Thread Executor when the perceived resolution of the main window changes in Home Space.

The main panel's own rotation and the display's viewing direction are disregarded; this value represents the pixel dimensions of the panel on the camera view without changing its distance to the display.

There can only be one listener set at a time. If a new listener is set, the previous listener will be released.

Non-zero values are only guaranteed in Home Space. In Full Space, the callback will always return a (0,0) size. Use the PanelEntity.getPerceivedResolution or SurfaceEntity.getPerceivedResolution methods directly on the relevant entities to retrieve non-zero values in Full Space.

Parameters
listener: Consumer<IntSize2d>

The Consumer to be invoked asynchronously on the given callbackExecutor whenever the maximum perceived resolution of the main panel changes. The parameter passed to the Consumer’s accept method is the new value for IntSize2d value for perceived resolution.

addPerceivedResolutionChangedListener

Added in 1.0.0-alpha16
fun addPerceivedResolutionChangedListener(
    callbackExecutor: Executor,
    listener: Consumer<IntSize2d>
): Unit

Sets the listener to be invoked when the perceived resolution of the main window changes in Home Space.

The main panel's own rotation and the display's viewing direction are disregarded; this value represents the pixel dimensions of the panel on the camera view without changing its distance to the display.

The listener is invoked on the provided executor.

Non-zero values are only guaranteed in Home Space. In Full Space, the callback will always return a (0,0) size. Use the getPerceivedResolution method to retrieve non-zero values in Full Space.

Parameters
callbackExecutor: Executor

The Executor to run the listener on.

listener: Consumer<IntSize2d>

The Consumer to be invoked asynchronously on the given callbackExecutor whenever the maximum perceived resolution of the main panel changes. The parameter passed to the Consumer’s accept method is the new value for IntSize2d value for perceived resolution.

removePerceivedResolutionChangedListener

Added in 1.0.0-alpha16
fun removePerceivedResolutionChangedListener(listener: Consumer<IntSize2d>): Unit

Releases the listener previously added by addPerceivedResolutionChangedListener.

All listeners are automatically removed when the MainPanelEntity is disposed even if this method is not explicitly called.

Parameters
listener: Consumer<IntSize2d>

The Consumer to be removed. It will no longer receive change events.