GltfModelEntity


class GltfModelEntity : Entity


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

Note: The size property of this Entity is always reported as {0, 0, 0}, regardless of the actual size of the model.

Summary

Public companion functions

GltfModelEntity
@MainThread
create(session: Session, model: GltfModel, pose: Pose, parent: Entity?)

Public factory function for a GltfModelEntity.

Public properties

List<GltfAnimation>

A list of all GltfAnimations defined in the GltfModelEntity.

List<GltfModelNode>

A list of all GltfModelNodes defined in the GltfModelEntity.

Inherited functions

From androidx.xr.scenecore.BaseScenePose
open suspend HitTestResult?
hitTest(origin: Vector3, direction: Vector3)

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

open suspend HitTestResult?
hitTest(origin: Vector3, direction: Vector3, hitTestFilter: Int)

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

open Vector3
transformDirectionTo(direction: Vector3, destination: ScenePose)

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

open Pose
transformPoseTo(pose: Pose, destination: ScenePose)

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

open Vector3
transformPositionTo(position: Vector3, destination: ScenePose)

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

open Vector3
transformVectorTo(vector: Vector3, destination: ScenePose)

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

From androidx.xr.scenecore.Entity
Unit
addChild(child: Entity)

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

Boolean
addComponent(component: Component)

Adds a Component to this Entity.

@FloatRange(from = 0.0, to = 1.0) Float
getAlpha(relativeTo: Space)

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

List<Component>

Retrieves all components attached to this Entity.

List<T>

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

open Pose
getPose(relativeTo: Space)

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

open @FloatRange(from = 0.0) Float
getScale(relativeTo: Space)

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

Boolean
isEnabled(includeParents: Boolean)

Returns the enabled status of this Entity.

Unit

Remove all components from this Entity.

Unit

Removes the given Component from this Entity.

Unit
setAlpha(alpha: @FloatRange(from = 0.0, to = 1.0) Float)

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

Unit
setEnabled(enabled: Boolean)

Sets the local enabled state of this Entity.

open Unit
setPose(pose: Pose, relativeTo: Space)

Sets the Pose for this Entity.

open Unit
setScale(scale: @FloatRange(from = 0.0) Float, relativeTo: Space)

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

Inherited properties

From androidx.xr.scenecore.BaseScenePose
open Pose

The current Pose relative to the activity space root.

From androidx.xr.scenecore.Entity
List<Entity>

Provides the list of all children of this entity.

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.

Public companion functions

create

Added in 1.0.0-alpha16
@MainThread
fun create(
    session: Session,
    model: GltfModel,
    pose: Pose = Pose.Identity,
    parent: Entity? = null
): GltfModelEntity

Public factory function for a GltfModelEntity.

This method must be called from the main thread. https://developer.android.com/guide/components/processes-and-threads

Parameters
session: Session

Session to create the GltfModel in.

model: GltfModel

The GltfModel this Entity is referencing.

pose: Pose = Pose.Identity

The initial Pose of the Entity. The default value is Pose.Identity.

parent: Entity? = null

Parent entity. Defaults to null. If null, the entity is created but not attached to the scene graph, meaning it will be invisible. If a parent entity (e.g., ActivitySpace or any other Entity already present in the scene) is assigned later, the entity will become visible (provided it is enabled). This allows for Entity pre-configuration before making it visible.

Public properties

animations

Added in 1.0.0-alpha16
val animationsList<GltfAnimation>

A list of all GltfAnimations defined in the GltfModelEntity. The list is lazily initialized on the first access.

The returned list corresponds to the array of animations defined in the source glTF file. The order of elements in this list is guaranteed to match the order of animations in the glTF file's animations array.

nodes

Added in 1.0.0-alpha16
val nodesList<GltfModelNode>

A list of all GltfModelNodes defined in the GltfModelEntity. The list is lazily initialized on the first access.

The returned list corresponds to the flattened array of nodes defined in the source glTF file. The order of elements in this list is guaranteed to match the order of nodes in the glTF file's nodes array.