public sealed class BaseEntity<RtEntityType extends JxrPlatformAdapter.Entity> extends BaseActivityPose implements Entity

Known direct subclasses
ActivitySpace

ActivitySpace is an Entity used to track the system-managed pose and boundary of the volume associated with this Spatialized Activity.

AnchorEntity

An AnchorEntity is created to track a Pose relative to some position or surface in the "Real World." Children of this Entity will remain positioned relative to that location in the real world, for the purposes of creating Augmented Reality experiences.

BasePanelEntity

Provides implementations for common Panel functionality.

ContentlessEntity

An Entity that itself has no content.

GltfModelEntity

GltfModelEntity is a concrete implementation of Entity that hosts a glTF model.

StereoSurfaceEntity

StereoSurfaceEntity is a concrete implementation of Entity that hosts a StereoSurface Panel.

Known indirect subclasses
ActivityPanelEntity

ActivityPanelEntity creates a spatial panel for embedding an Activity in Android XR.

PanelEntity

PanelEntity creates a spatial panel in Android XR.


The BaseEntity is an implementation of Entity interface that wraps a platform entity.

Summary

Protected constructors

<RtEntityType extends JxrPlatformAdapter.Entity> BaseEntity(
    @NonNull RtEntityType rtEntity,
    @NonNull EntityManager entityManager
)

Public methods

void

Sets an Entity to be represented in this coordinate space.

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

Returns the global alpha of this entity computed by multiplying the parent's global alpha to this entity's local alpha.

float

Returns the alpha transparency set for this Entity.

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

Entity

Returns the parent of this Entity.

@NonNull Pose

Returns the pose for this entity, relative to its parent.

float

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

@NonNull Dimensions

Returns the dimensions (in meters) for this Entity.

float

Returns the accumulated scale of this Entity.

boolean
isHidden(boolean includeParents)

Returns the hidden status of this Entity.

void

Remove all components from this Entity.

void

Removes the given Component from this Entity.

void
setAlpha(float alpha)

Sets the alpha transparency of the Entity and its children.

void

Sets alternate text for this entity to be consumed by Accessibility systems.

void
setHidden(boolean hidden)

Sets the local hidden state of this Entity.

void
setParent(Entity parent)

Sets this Entity to be represented in the parent's coordinate space.

void

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

void
setScale(float scale)

Sets the scale of this entity relative to its parent.

void
setSize(@NonNull Dimensions dimensions)

Sets the dimensions in pixels for the Entity.

Inherited methods

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

Returns the activity space pose for this ActivityPose.

abstract @NonNull Pose

Returns a pose relative to this ActivityPose transformed into a pose relative to the destination.

Protected constructors

BaseEntity

protected <RtEntityType extends JxrPlatformAdapter.Entity> BaseEntity(
    @NonNull RtEntityType rtEntity,
    @NonNull EntityManager entityManager
)

Public methods

addChild

Added in 1.0.0-alpha01
public void addChild(@NonNull Entity child)

Sets an Entity to be represented in this coordinate space. From a User's perspective, as this Entity moves, the child Entity will move with it.

Parameters
@NonNull Entity child

The Entity to be attached.

addComponent

Added in 1.0.0-alpha01
public boolean addComponent(@NonNull Component component)

Adds a Component to this Entity.

Parameters
@NonNull Component component

the Component to be added to the Entity.

Returns
boolean

True if given Component is added to the Entity.

dispose

Added in 1.0.0-alpha01
public void dispose()

Disposes of any system resources held by this Entity, and transitively calls dispose() on all its children. Once disposed, this Entity is invalid and cannot be used again.

getActivitySpaceAlpha

Added in 1.0.0-alpha01
public float getActivitySpaceAlpha()

Returns the global alpha of this entity computed by multiplying the parent's global alpha to this entity's local alpha.

This does not necessarily equal the perceived alpha of the entity as the entity may have some alpha difference applied from the system.

Returns
float

Total Float alpha applied to this entity.

getAlpha

Added in 1.0.0-alpha01
public float getAlpha()

Returns the alpha transparency set for this Entity.

This does not necessarily equal the perceived alpha of the entity as the entity may have some alpha difference applied from its parent or the system.

getComponents

Added in 1.0.0-alpha01
public @NonNull List<@NonNull ComponentgetComponents()

Retrieves all components attached to this Entity.

Returns
@NonNull List<@NonNull Component>

List attached to this Entity.

getComponentsOfType

Added in 1.0.0-alpha01
public @NonNull List<@NonNull T> <T extends Component> getComponentsOfType(@NonNull Class<@NonNull T> type)

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

Parameters
@NonNull Class<@NonNull T> type

The type of Component to retrieve.

Returns
@NonNull List<@NonNull T>

List of the given type attached to this Entity.

getParent

Added in 1.0.0-alpha01
public Entity getParent()

Returns the parent of this Entity.

Returns
Entity

The Entity that this Entity is attached to. Returns null if this Entity has no parent and is the root of its hierarchy.

getPose

Added in 1.0.0-alpha01
public @NonNull Pose getPose()

Returns the pose for this entity, relative to its parent.

Returns
@NonNull Pose

Current Pose offset from the parent.

getScale

Added in 1.0.0-alpha01
public float getScale()

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

Returns
float

Current uniform scale applied to self and children.

getSize

Added in 1.0.0-alpha01
public @NonNull Dimensions getSize()

Returns the dimensions (in meters) for this Entity.

getWorldSpaceScale

Added in 1.0.0-alpha01
public float getWorldSpaceScale()

Returns the accumulated scale of this Entity. This value includes the parent's world space scale.

Returns
float

Total uniform scale applied to self and children.

isHidden

Added in 1.0.0-alpha01
public boolean isHidden(boolean includeParents)

Returns the hidden status of this Entity.

Parameters
boolean includeParents

Whether to include the hidden status of parents in the returned value.

Returns
boolean

If includeParents is true, the returned value will be true if this Entity or any of its ancestors is hidden. If includeParents is false, the local hidden state is returned. Regardless of the local hidden state, an entity will not be rendered if any of its ancestors are hidden.

removeAllComponents

Added in 1.0.0-alpha01
public void removeAllComponents()

Remove all components from this Entity.

removeComponent

Added in 1.0.0-alpha01
public void removeComponent(@NonNull Component component)

Removes the given Component from this Entity.

Parameters
@NonNull Component component

Component to be removed from this entity.

setAlpha

Added in 1.0.0-alpha01
public void setAlpha(float alpha)

Sets the alpha transparency of the Entity and its children. Values are in the range 0, 1 with 0 being fully transparent and 1 being fully opaque.

This value will affect the rendering of this Entity's children. Children of this node will have their alpha levels multiplied by this value and any alpha of this entity's ancestors.

setContentDescription

Added in 1.0.0-alpha01
public void setContentDescription(@NonNull String text)

Sets alternate text for this entity to be consumed by Accessibility systems.

Parameters
@NonNull String text

A11y content.

setHidden

Added in 1.0.0-alpha01
public void setHidden(boolean hidden)

Sets the local hidden state of this Entity. When true, this Entity and all descendants will not be rendered in the scene. When the hidden state is false, an entity will be rendered if its ancestors are not hidden.

Parameters
boolean hidden

The new local hidden state of this Entity.

setParent

Added in 1.0.0-alpha01
public void setParent(Entity parent)

Sets this Entity to be represented in the parent's coordinate space. From a User's perspective, as the parent moves, this Entity will move with it. Setting the parent to null will cause the Entity to not be rendered.

Parameters
Entity parent

The Entity to attach to.

setPose

Added in 1.0.0-alpha01
public void setPose(@NonNull Pose pose)

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

Parameters
@NonNull Pose pose

The Pose offset from the parent.

setScale

Added in 1.0.0-alpha01
public void setScale(float scale)

Sets the scale of this entity relative to its parent. This value will affect the rendering of this Entity's children. As the scale increases, this will uniformly stretch the content of the Entity.

Parameters
float scale

The uniform scale factor from the parent.

setSize

Added in 1.0.0-alpha01
public void setSize(@NonNull Dimensions dimensions)

Sets the dimensions in pixels for the Entity.

("This method is deprecated. Use BasePanelEntity<*>.setPixelDimensions() instead.")

Parameters
@NonNull Dimensions dimensions

Dimensions in pixels. (Z will be ignored)