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

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

Unit

Releases the listener previously added by addPerceivedResolutionChangedListener.

Inherited functions

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

Gets the perceived resolution of this Entity in the CameraView.

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

From androidx.xr.scenecore.ScenePose
abstract Pose

The current Pose relative to the activity space root.

Public functions

addPerceivedResolutionChangedListener

Added in 1.0.0-alpha05
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 Mode.

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 Mode. In Full Space Mode, 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 Mode.

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

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 Mode. In Full Space Mode, the callback will always return a (0,0) size. Use the getPerceivedResolution method to retrieve non-zero values in Full Space Mode.

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-alpha05
fun removePerceivedResolutionChangedListener(listener: Consumer<IntSize2d>): Unit

Releases the listener previously added by addPerceivedResolutionChangedListener.

Parameters
listener: Consumer<IntSize2d>

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