GltfModelEntity
public final class GltfModelEntity extends BaseEntity
| java.lang.Object | |||
| ↳ | androidx.xr.scenecore.BaseScenePose | ||
| ↳ | androidx.xr.scenecore.BaseEntity | ||
| ↳ | androidx.xr.scenecore.GltfModelEntity |
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 final class GltfModelEntity.AnimationStateSpecifies the current animation state of the GltfModelEntity. |
Public methods |
|
|---|---|
final void |
@MainThreadClears a previously set material override for a specific primitive of a node within the glTF graph. |
static final @NonNull GltfModelEntity |
Public factory function for a |
final @NonNull GltfModelEntity.AnimationState |
The current animation state of the GltfModelEntity. |
final void |
@MainThreadSets a material override for a primitive of a node within the glTF graph. |
final void |
@MainThreadStarts animating the glTF with the first animation found in the model. |
final void |
@MainThreadStarts the animation with the given name. |
final void |
Stops the currently active animation. |
Inherited methods |
||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
Public methods
clearMaterialOverride
@MainThread
public final void clearMaterialOverride(@NonNull String nodeName, int primitiveIndex)
Clears a previously set material override for a specific primitive of a node within the glTF graph.
If no override was previously set for that primitive, this call has no effect.
| Parameters | |
|---|---|
@NonNull String nodeName |
The name of the node containing the primitive whose material override will be cleared. |
int primitiveIndex |
The zero-based index for the primitive of the specified node, as defined in the glTF graph. Default is the first primitive of that node. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the provided |
kotlin.IndexOutOfBoundsException |
if the |
create
@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
getAnimationState
public final @NonNull GltfModelEntity.AnimationState getAnimationState()
The current animation state of the GltfModelEntity.
| Returns | |
|---|---|
@NonNull GltfModelEntity.AnimationState |
The current animation state. |
setMaterialOverride
@MainThread
public final void setMaterialOverride(
@NonNull Material material,
@NonNull String nodeName,
int primitiveIndex
)
Sets a material override for a primitive of a node within the glTF graph.
This function searches for the first node in the glTF scene graph with a matching nodeName. The override is then applied to a primitive of that node at the specified primitiveIndex.
| Parameters | |
|---|---|
@NonNull Material material |
The new |
@NonNull String nodeName |
The name of the node as defined in the glTF graph, containing the primitive to override. |
int primitiveIndex |
The zero-based index for the primitive of the specified node, as defined in the glTF graph. Default is the first primitive of that node. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the provided |
kotlin.IndexOutOfBoundsException |
if the |
startAnimation
@MainThread
public final void startAnimation(boolean loop)
Starts animating the glTF with the first animation found in the model.
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 over or stop after animating once. Defaults to true. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the underlying model doesn't contain any animations. |
startAnimation
@MainThread
public final void startAnimation(boolean loop, @NonNull String animationName)
Starts the animation with the given name. Only one animation can be playing at a time.
This method must be called from the main thread. https://developer.android.com/guide/components/processes-and-threads
| Parameters | |
|---|---|
boolean loop |
If true, the animation plays in a loop indefinitely until |
@NonNull String animationName |
The name of the animation to start. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
if the underlying model doesn't contain an animation with the given name. |
stopAnimation
@MainThread
public final void stopAnimation()
Stops the currently active animation.
This method must be called from the main thread. https://developer.android.com/guide/components/processes-and-threads