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

final void

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

final void

Releases the listener previously added by addPerceivedResolutionChangedListener.

Inherited methods

From androidx.xr.scenecore.BaseEntity
void

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

boolean

Adds a Component to this Entity.

void

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

float
getAlpha(int relativeTo)

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

@NonNull List<@NonNull Component>

Retrieves all components attached to this Entity.

@NonNull List<@NonNull T>

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

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

@NonNull Pose
getPose(int relativeTo)

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

float
getScale(int relativeTo)

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

boolean
isEnabled(boolean includeParents)

Returns the enabled status of this Entity.

void

Remove all components from this Entity.

void

Removes the given Component from this Entity.

void
setAlpha(float alpha, int relativeTo)

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

void

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

void
setEnabled(boolean enabled)

Sets the local enabled state of this Entity.

void
setParent(Entity parent)

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

void
setPose(@NonNull Pose pose, int relativeTo)

Sets the Pose for this Entity.

void
setScale(float scale, int relativeTo)

Sets the scale of this Entity relative to given Space.

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

Returns the alpha transparency set for this Entity.

@NonNull Pose

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

@FloatRange(from = 0.0) float

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

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

Sets the alpha transparency of the Entity and its children.

void

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

void
setScale(@FloatRange(from = 0.0) float scale)

Sets the scale of this Entity relative to its parent.

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

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

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.

From androidx.xr.scenecore.ScenePose
abstract @NonNull Pose

The current Pose relative to the activity space root.

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

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

abstract @NonNull 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.

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

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

Public methods

addPerceivedResolutionChangedListener

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

Releases the listener previously added by addPerceivedResolutionChangedListener.

Parameters
@NonNull Consumer<@NonNull IntSize2d> listener

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