# MainPanelEntity

Artifact: [androidx.xr.scenecore:scenecore](https://developer.android.com/jetpack/androidx/releases/xr-scenecore) [View Source](https://cs.android.com/search?q=file:androidx/xr/scenecore/MainPanelEntity.kt+class:androidx.xr.scenecore.MainPanelEntity) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

*** ** * ** ***


```
public final class MainPanelEntity extends PanelEntity
```

<br />

|---|---|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||||
| ↳ | [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose) ||||
|   | ↳ | [androidx.xr.scenecore.Entity](https://developer.android.com/reference/androidx/xr/scenecore/Entity) |||
|   |   | ↳ | [androidx.xr.scenecore.PanelEntity](https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity) ||
|   |   |   | ↳ | [androidx.xr.scenecore.MainPanelEntity](https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity) |

*** ** * ** ***

Represents the main spatialized panel in a `https://developer.android.com/reference/androidx/xr/scenecore/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 methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity#addPerceivedResolutionChangedListener(java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/IntSize2d> listener )` Sets the listener to be invoked on the Main Thread Executor when the perceived resolution of the main window changes in Home Space. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity#addPerceivedResolutionChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/IntSize2d> listener )` Sets the listener to be invoked when the perceived resolution of the main window changes in Home Space. |
| `final void` | `https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity#removePerceivedResolutionChangedListener(java.util.function.Consumer)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/IntSize2d> listener )` Releases the listener previously added by `https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity#addPerceivedResolutionChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)`. |

### Inherited methods

From [androidx.xr.scenecore.BaseScenePose](https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose) `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose#getPoseInActivitySpace()()`

The current `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` relative to the activity space root.
`https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult` `https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 origin, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 direction)`

Perform a hit test from the specified origin in the specified direction into the Scene.
`https://developer.android.com/reference/androidx/xr/scenecore/HitTestResult` `https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose#hitTest(androidx.xr.runtime.math.Vector3,androidx.xr.runtime.math.Vector3,kotlin.Int)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 origin,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 direction,
int hitTestFilter
)`

Creates a hit test from the specified origin in the specified direction into the scene.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose#transformDirectionTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 direction,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ScenePose destination
)`

Transforms a direction from this ScenePose's local space to the destination ScenePose's local space.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose#transformPoseTo(androidx.xr.runtime.math.Pose,androidx.xr.scenecore.ScenePose)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose pose, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ScenePose destination)`

Returns a `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` relative to this ScenePose, transformed into a Pose relative to the destination.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose#transformPositionTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 position,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ScenePose destination
)`

Transforms a position from this ScenePose's local space to the destination ScenePose's local space.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/androidx/xr/scenecore/BaseScenePose#transformVectorTo(androidx.xr.runtime.math.Vector3,androidx.xr.scenecore.ScenePose)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3 vector, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/ScenePose destination)`

Transforms a vector from this ScenePose's local space to the destination ScenePose's local space.
From [androidx.xr.scenecore.Entity](https://developer.android.com/reference/androidx/xr/scenecore/Entity) `final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#addChild(androidx.xr.scenecore.Entity)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Entity child)`

Sets an Entity to be a child of this Entity in the scene graph.
`final boolean` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#addComponent(androidx.xr.scenecore.Component)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Component component)`

Adds a Component to this Entity.
`final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getAlpha(androidx.xr.scenecore.Space)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Space relativeTo)`

Returns the alpha transparency set for this Entity, relative to given Space.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Entity>` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getChildren()()`

Provides the list of all children of this entity.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Component>` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getComponents()()`

Retrieves all components attached to this Entity.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T>` `<T extends https://developer.android.com/reference/androidx/xr/scenecore/Component> https://developer.android.com/reference/androidx/xr/scenecore/Entity#getComponentsOfType(java.lang.Class)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> type)`

Retrieves all Components of the given type `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getComponentsOfType(java.lang.Class)` and its subtypes attached to this Entity.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getContentDescription()()`

Alternate text for this Entity to be consumed by Accessibility systems.
`https://developer.android.com/reference/androidx/xr/scenecore/Entity` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getParent()()`

The parent of this Entity, from which this Entity will inherit most of its properties.
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getPose(androidx.xr.scenecore.Space)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Space relativeTo)`

Returns the `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` for this Entity, relative to the provided `https://developer.android.com/reference/androidx/xr/scenecore/Space`.
`@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#getScale(androidx.xr.scenecore.Space)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Space relativeTo)`

Returns the scale of this entity, relative to given space.
`final boolean` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#isEnabled(kotlin.Boolean)(boolean includeParents)`

Returns the enabled status of this Entity.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#removeAllComponents()()`

Remove all components from this Entity.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#removeComponent(androidx.xr.scenecore.Component)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Component component)`

Removes the given Component from this Entity.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setAlpha(kotlin.Float)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0, to = 1.0) float alpha)`

Sets the alpha transparency of the Entity relative to the parent Space.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setContentDescription(kotlin.CharSequence)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/CharSequence.html value)`

Alternate text for this Entity to be consumed by Accessibility systems.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setEnabled(kotlin.Boolean)(boolean enabled)`

Sets the local enabled state of this Entity.
`void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setParent(androidx.xr.scenecore.Entity)(https://developer.android.com/reference/androidx/xr/scenecore/Entity value)`

The parent of this Entity, from which this Entity will inherit most of its properties.
`void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setPose(androidx.xr.runtime.math.Pose,androidx.xr.scenecore.Space)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Pose pose, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Space relativeTo)`

Sets the `https://developer.android.com/reference/androidx/xr/runtime/math/Pose` for this Entity.
`void` `https://developer.android.com/reference/androidx/xr/scenecore/Entity#setScale(kotlin.Float,androidx.xr.scenecore.Space)(@https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float scale, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/Space relativeTo)`

Sets the scale of this Entity relative to the given Space.
From [androidx.xr.scenecore.PanelEntity](https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity) `final float` `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#getCornerRadius()()`

The corner radius of the PanelEntity, in meters.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/scenecore/PerceivedResolutionResult` `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#getPerceivedResolution(androidx.xr.arcore.RenderViewpoint)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/arcore/RenderViewpoint renderViewpoint)`

Gets the perceived resolution of this Entity in the provided `https://developer.android.com/reference/androidx/xr/arcore/RenderViewpoint`.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize2d` `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#getSize()()`

The dimensions of this PanelEntity in local space, in units relative to the scale of this Entity's parent.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/IntSize2d` `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#getSizeInPixels()()`

The dimensions of this PanelEntity, in pixels, which is the resolution of the underlying surface.
`final boolean` `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#isMainPanelEntity()()`

True if this panel is the [MainPanelEntity](https://developer.android.com/develop/xr/jetpack-xr-sdk/work-with-entities), false otherwise.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#setCornerRadius(kotlin.Float)(float value)`

The corner radius of the PanelEntity, in meters.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#setSize(androidx.xr.runtime.math.FloatSize2d)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/FloatSize2d value)`

The dimensions of this PanelEntity in local space, in units relative to the scale of this Entity's parent.
`final void` `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#setSizeInPixels(androidx.xr.runtime.math.IntSize2d)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/IntSize2d value)`

The dimensions of this PanelEntity, in pixels, which is the resolution of the underlying surface.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#transformNormalizedCoordinatesToLocalPosition(androidx.xr.runtime.math.Vector2)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector2 coordinates
)`

Gets the 3D position of a 2D normalized extent coordinate within the entity's local space.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector3` `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#transformPixelCoordinatesToLocalPosition(androidx.xr.runtime.math.Vector2)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/Vector2 coordinates)`

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

## Public methods

### addPerceivedResolutionChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void addPerceivedResolutionChangedListener(
    @NonNull Consumer<@NonNull IntSize2d> listener
)
```

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 `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#getPerceivedResolution(androidx.xr.arcore.RenderViewpoint)` or `https://developer.android.com/reference/androidx/xr/scenecore/SurfaceEntity#getPerceivedResolution(androidx.xr.arcore.RenderViewpoint)` methods directly on the relevant entities to retrieve non-zero values in Full Space.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/IntSize2d> listener` | The `https://developer.android.com/reference/java/util/function/Consumer.html` 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 `https://developer.android.com/reference/androidx/xr/runtime/math/IntSize2d` value for perceived resolution. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if `https://developer.android.com/reference/androidx/xr/runtime/Session#config()` is not set to `https://developer.android.com/reference/androidx/xr/runtime/DeviceTrackingMode#SPATIAL()`. |

### addPerceivedResolutionChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void addPerceivedResolutionChangedListener(
    @NonNull Executor callbackExecutor,
    @NonNull Consumer<@NonNull IntSize2d> listener
)
```

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 `https://developer.android.com/reference/androidx/xr/scenecore/PanelEntity#getPerceivedResolution(androidx.xr.arcore.RenderViewpoint)` method to retrieve non-zero values in Full Space.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/concurrent/Executor.html callbackExecutor` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` to run the listener on. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/IntSize2d> listener` | The `https://developer.android.com/reference/java/util/function/Consumer.html` 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 `https://developer.android.com/reference/androidx/xr/runtime/math/IntSize2d` value for perceived resolution. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if `https://developer.android.com/reference/androidx/xr/runtime/Session#config()` is not set to `https://developer.android.com/reference/androidx/xr/runtime/DeviceTrackingMode#SPATIAL()`. |

### removePerceivedResolutionChangedListener

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/xr-scenecore#1.0.0)

```
public final void removePerceivedResolutionChangedListener(
    @NonNull Consumer<@NonNull IntSize2d> listener
)
```

Releases the listener previously added by `https://developer.android.com/reference/androidx/xr/scenecore/MainPanelEntity#addPerceivedResolutionChangedListener(java.util.concurrent.Executor,java.util.function.Consumer)`.

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/function/Consumer.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/xr/runtime/math/IntSize2d> listener` | The `https://developer.android.com/reference/java/util/function/Consumer.html` to be removed. It will no longer receive change events. |