PanelEntity
open class PanelEntity : BaseEntity
| kotlin.Any | |||
| ↳ | androidx.xr.scenecore.BaseScenePose | ||
| ↳ | androidx.xr.scenecore.BaseEntity | ||
| ↳ | androidx.xr.scenecore.PanelEntity |
ActivityPanelEntity |
ActivityPanelEntity creates a spatial panel for embedding an |
MainPanelEntity |
Represents the main spatialized panel in a |
PanelEntity contains an arbitrary 2D Android View, within a spatialized XR scene.
Summary
Public companion functions |
|
|---|---|
PanelEntity |
Factory method for a spatialized PanelEntity. |
PanelEntity |
Factory method for a spatialized PanelEntity. |
Public functions |
|
|---|---|
PerceivedResolutionResult |
Gets the perceived resolution of this Entity in the |
Pose |
Gets the 3D pose of a 2D normalized extent coordinate within the Entity's local space. |
Pose |
Gets the 3D pose of a 2D pixel coordinate within the Entity's local space. |
Public properties |
|
|---|---|
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. |
Inherited functions |
||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
Inherited properties |
||||||
|---|---|---|---|---|---|---|
|
||||||
Public companion functions
create
fun create(
session: Session,
view: View,
dimensions: FloatSize2d,
name: String,
pose: Pose = Pose.Identity
): PanelEntity
Factory method for a spatialized PanelEntity.
| Parameters | |
|---|---|
session: Session |
XR |
view: View |
|
dimensions: FloatSize2d |
Spatialized dimensions for the underlying surface for the given view, in meters. |
name: String |
Name of this PanelEntity. |
pose: Pose = Pose.Identity |
|
| Returns | |
|---|---|
PanelEntity |
a PanelEntity instance. |
create
fun create(
session: Session,
view: View,
pixelDimensions: IntSize2d,
name: String,
pose: Pose = Pose.Identity
): PanelEntity
Factory method for a spatialized PanelEntity.
| Parameters | |
|---|---|
session: Session |
XR |
view: View |
|
pixelDimensions: IntSize2d |
Dimensions for the underlying surface for the given view, in pixels. |
name: String |
Name of the panel. |
pose: Pose = Pose.Identity |
|
| Returns | |
|---|---|
PanelEntity |
a PanelEntity instance. |
Public functions
getPerceivedResolution
fun getPerceivedResolution(): PerceivedResolutionResult
Gets the perceived resolution of this Entity in the CameraView.
This API is only intended for use in Full Space Mode and will return PerceivedResolutionResult.InvalidCameraView in Home Space Mode. For applications requiring perceived resolution in Home Space Mode, see MainPanelEntity.getPerceivedResolution.
This value represents the dimensions of the Entity on the camera view if its largest surface was facing the camera without changing the distance of the Entity to the camera. This can be used by clients to dynamically optimize the resolution of assets within the PanelEntity, for example by using lower-resolution assets within panels that are further from the viewer. The Entity's own rotation and the camera's viewing direction are disregarded.
| Returns | |
|---|---|
PerceivedResolutionResult |
A |
| Throws | |
|---|---|
kotlin.IllegalStateException |
if |
| See also | |
|---|---|
PerceivedResolutionResult |
transformNormalizedCoordinatesToPose
@ExperimentalPanelCoordinateApi
fun transformNormalizedCoordinatesToPose(coordinates: Vector2): Pose
Gets the 3D pose of a 2D normalized extent coordinate within the Entity's local space.
This method's inputs use a 2D normalized coordinate system where:
-
The origin (0.0, 0.0) is at the center of the panel.
-
The +X axis points towards the right edge (mapped to 1.0) of the panel content.
-
The +Y axis points towards the top edge (mapped to 1.0) of the panel content.
Values outside the -1.0, 1.0 range are permitted and will result in a pose positioned outside the panel's surface.
Note that calling this method on MainPanelEntity during android.app.Activity.onCreate can result in incorrect values.
| Parameters | |
|---|---|
coordinates: Vector2 |
The normalized coordinates, relative to the origin at the center of the panel. |
| Returns | |
|---|---|
Pose |
The 3D pose corresponding to the 2D normalized coordinate. The position will be coplanar to the panel's surface (z=0 in the panel's local space), and the orientation will be the identity rotation such that the Z axis points outwards from the panel. |
| See also | |
|---|---|
transformPoseTo |
to transform the pose to a different coordinate space. |
transformPixelCoordinatesToPose
@ExperimentalPanelCoordinateApi
fun transformPixelCoordinatesToPose(coordinates: Vector2): Pose
Gets the 3D pose of a 2D pixel coordinate within the Entity's local space.
This method's inputs use a 2D pixel coordinate system where:
-
The origin (0, 0) is at the top-left corner of the panel.
-
The +X axis points towards the right edge of the panel content.
-
The +Y axis points towards the bottom edge of the panel content.
Input values are floats to allow for sub-pixel accuracy. Values outside the panel's pixel dimensions (e.g., x < 0 or y > panelHeight) are permitted and will result in a pose positioned outside the panel's surface.
Note that calling this method on MainPanelEntity during android.app.Activity.onCreate can result in incorrect values.
| Parameters | |
|---|---|
coordinates: Vector2 |
The pixel coordinate, relative to the top-left origin. |
| Returns | |
|---|---|
Pose |
The 3D pose corresponding to the 2D pixel coordinate. The position will be coplanar to the panel's surface (z=0 in the panel's local space), and the orientation will be the identity rotation such that the Z axis points outwards from the panel. |
| See also | |
|---|---|
transformPoseTo |
to transform the pose to a different coordinate space. |
Public properties
cornerRadius
var cornerRadius: Float
The corner radius of the PanelEntity, in meters.
isMainPanelEntity
val isMainPanelEntity: Boolean
True if this panel is the MainPanelEntity, false otherwise.
size
var size: FloatSize2d
The dimensions of this PanelEntity in local space, in units relative to the scale of this Entity's parent.
sizeInPixels
var sizeInPixels: IntSize2d
The dimensions of this PanelEntity, in pixels, which is the resolution of the underlying surface.
This API doesn't do any scale compensation to the pixel dimensions.