GltfModelEntity
class GltfModelEntity : BaseEntity
| kotlin.Any | |||
| ↳ | 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 |
|---|
|
Specifies the current animation state of the GltfModelEntity. |
Public companion functions |
|
|---|---|
GltfModelEntity |
@MainThreadPublic factory function for a |
Public functions |
|
|---|---|
Unit |
@MainThreadClears a previously set material override for a specific primitive of a node within the glTF graph. |
Unit |
@MainThreadSets a material override for a primitive of a node within the glTF graph. |
Unit |
@MainThreadStarts animating the glTF with the first animation found in the model. |
Unit |
@MainThreadStarts the animation with the given name. |
Unit |
Stops the currently active animation. |
Public properties |
|
|---|---|
GltfModelEntity.AnimationState |
The current animation state of the GltfModelEntity. |
Inherited functions |
||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
Inherited properties |
||||||
|---|---|---|---|---|---|---|
|
||||||
Public companion functions
create
@MainThread
fun create(session: Session, model: GltfModel, pose: Pose = Pose.Identity): 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
Public functions
clearMaterialOverride
@MainThread
fun clearMaterialOverride(nodeName: String, primitiveIndex: Int = 0): Unit
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 | |
|---|---|
nodeName: String |
The name of the node containing the primitive whose material override will be cleared. |
primitiveIndex: Int = 0 |
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 |
setMaterialOverride
@MainThread
fun setMaterialOverride(
material: Material,
nodeName: String,
primitiveIndex: Int = 0
): Unit
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 | |
|---|---|
material: Material |
The new |
nodeName: String |
The name of the node as defined in the glTF graph, containing the primitive to override. |
primitiveIndex: Int = 0 |
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
fun startAnimation(loop: Boolean = true): Unit
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 | |
|---|---|
loop: Boolean = true |
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
fun startAnimation(loop: Boolean, animationName: String): Unit
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 | |
|---|---|
loop: Boolean |
If true, the animation plays in a loop indefinitely until |
animationName: String |
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
fun stopAnimation(): Unit
Stops the currently active animation.
This method must be called from the main thread. https://developer.android.com/guide/components/processes-and-threads
Public properties
animationState
val animationState: GltfModelEntity.AnimationState
The current animation state of the GltfModelEntity.
| Returns | |
|---|---|
GltfModelEntity.AnimationState |
The current animation state. |