MainPanelEntity


public final class MainPanelEntity extends 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 methods

final void

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

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

final void

Releases the listener previously added by addPerceivedResolutionChangedListener.

Inherited methods

From androidx.xr.scenecore.BaseScenePose
@NonNull Pose

The current Pose relative to the activity space root.

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

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

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.

@NonNull Vector3
transformDirectionTo(
    @NonNull Vector3 direction,
    @NonNull ScenePose destination
)

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

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

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

@NonNull Vector3
transformPositionTo(
    @NonNull Vector3 position,
    @NonNull ScenePose destination
)

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

@NonNull Vector3

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

From androidx.xr.scenecore.Entity
final void

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

final boolean

Adds a Component to this Entity.

final @FloatRange(from = 0.0, to = 1.0) float
getAlpha(@NonNull Space relativeTo)

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

final @NonNull List<@NonNull Entity>

Provides the list of all children of this entity.

final @NonNull List<@NonNull Component>

Retrieves all components attached to this Entity.

final @NonNull List<@NonNull T>

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

final @NonNull CharSequence

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

final Entity

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

@NonNull Pose
getPose(@NonNull Space relativeTo)

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

@FloatRange(from = 0.0) float
getScale(@NonNull Space relativeTo)

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

final boolean
isEnabled(boolean includeParents)

Returns the enabled status of this Entity.

final void

Remove all components from this Entity.

final void

Removes the given Component from this Entity.

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

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

final void

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

final void
setEnabled(boolean enabled)

Sets the local enabled state of this Entity.

final void

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

void
setPose(@NonNull Pose pose, @NonNull Space relativeTo)

Sets the Pose for this Entity.

void
setScale(@FloatRange(from = 0.0) float scale, @NonNull Space relativeTo)

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

From androidx.xr.scenecore.PanelEntity
final float

The corner radius of the PanelEntity, in meters.

final @NonNull PerceivedResolutionResult

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

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 value)

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.

final @NonNull Vector3

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

final @NonNull Vector3

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

Public methods

addPerceivedResolutionChangedListener

Added in 1.0.0-alpha16
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 PanelEntity.getPerceivedResolution or SurfaceEntity.getPerceivedResolution methods directly on the relevant entities to retrieve non-zero values in Full Space.

Parameters
@NonNull Consumer<@NonNull IntSize2d> listener

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
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 getPerceivedResolution method to retrieve non-zero values in Full Space.

Parameters
@NonNull Executor callbackExecutor

The Executor to run the listener on.

@NonNull Consumer<@NonNull IntSize2d> listener

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
public final void removePerceivedResolutionChangedListener(
    @NonNull Consumer<@NonNull IntSize2d> listener
)

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
@NonNull Consumer<@NonNull IntSize2d> listener

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