GltfModelEntity


public final class GltfModelEntity extends BaseEntity


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

Nested types

public static class GltfModelEntity.AnimationState

Public methods

static final @NonNull GltfModelEntity

Public factory function for a GltfModelEntity.

final int

Returns the current animation state of this glTF entity.

final void

Sets a material override for a mesh in the glTF model.

final void
@MainThread
startAnimation(boolean loop, String animationName)

Starts the animation with the given name.

final void

Stops the animation of the glTF entity.

Inherited methods

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

Returns the activity space pose for this ActivityPose.

abstract @NonNull ListenableFuture<@NonNull HitTestResult>
hitTestAsync(@NonNull Vector3 origin, @NonNull Vector3 direction)

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

abstract @NonNull ListenableFuture<@NonNull HitTestResult>
hitTestAsync(
    @NonNull Vector3 origin,
    @NonNull Vector3 direction,
    @ActivityPose.HitTestFilterValue int hitTestFilter
)

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

abstract @NonNull Pose

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

From androidx.xr.scenecore.BaseEntity
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
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.

Entity

Returns the parent of this Entity.

@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
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, int relativeTo)

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

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
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
float

Returns the alpha transparency set for 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.

void
setAlpha(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(float scale)

Sets the scale of this entity relative to its parent.

Public methods

create

Added in 1.0.0-alpha04
@MainThread
public static final @NonNull GltfModelEntity create(@NonNull Session session, @NonNull GltfModel model, @NonNull Pose pose)

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
@NonNull Session session

Session to create the GltfModel in.

@NonNull GltfModel model

The GltfModel this Entity is referencing.

@NonNull Pose pose

The initial pose of the entity.

Returns
@NonNull GltfModelEntity

a GltfModelEntity instance

getAnimationState

Added in 1.0.0-alpha04
public final int getAnimationState()

Returns the current animation state of this glTF entity.

setMaterialOverride

Added in 1.0.0-alpha04
@MainThread
public final void setMaterialOverride(@NonNull Material material, @NonNull String meshName)

Sets a material override for a mesh in the glTF model.

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

If the material is not created or the mesh name is not found in the glTF model, this method will throw an IllegalStateException.

Parameters
@NonNull Material material

The material to use for the mesh.

@NonNull String meshName

The name of the mesh to use the material for.

startAnimation

Added in 1.0.0-alpha04
@MainThread
public final void startAnimation(boolean loop, String animationName)

Starts the animation with the given name.

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

Parameters
boolean loop

Whether the animation should loop.

String animationName

The name of the animation to start. If null, the first animation found in the glTF will be played.

stopAnimation

Added in 1.0.0-alpha04
@MainThread
public final void stopAnimation()

Stops the animation of the glTF entity.

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