Class FilamentAsset


  • public class FilamentAsset
    extends java.lang.Object
    Owns a bundle of Filament objects that have been created by AssetLoader.

    For usage instructions, see the documentation for AssetLoader.

    This class owns a hierarchy of entities that have been loaded from a glTF asset. Every entity has a TransformManager component, and some entities also have compnents managed by NameComponentManager, RenderableManager, and others.

    In addition to the aforementioned entities, an asset has strong ownership over a list of VertexBuffer, IndexBuffer, and Texture.

    Clients can use ResourceLoader to create textures, compute tangent quaternions, and upload data into vertex buffers and index buffers.

    See Also:
    ResourceLoader, FilamentInstance, AssetLoader
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.google.android.filament.Box getBoundingBox()
      Gets the bounding box computed from the supplied min / max values in glTF accessors.
      int[] getCameraEntities()
      Gets only the entities that have camera components.
      com.google.android.filament.Engine getEngine()  
      int[] getEntities()
      Gets the list of entities, one for each glTF node.
      int[] getEntitiesByName​(java.lang.String name)
      Gets a list of entities with the given name.
      int[] getEntitiesByPrefix​(java.lang.String prefix)
      Gets a list of entities whose names start with the given prefix.
      java.lang.String getExtras​(int entity)
      Gets the glTF extras string for the asset or a specific node.
      int getFirstEntityByName​(java.lang.String name)
      Returns the first entity with the given name, or 0 if none exist.
      FilamentInstance getInstance()  
      int[] getLightEntities()
      Gets only the entities that have light components.
      java.lang.String[] getMorphTargetNames​(int entity)
      Gets the names of all morph targets in the given entity.
      java.lang.String getName​(int entity)
      Gets the NameComponentManager label for the given entity, if it exists.
      int[] getRenderableEntities()
      Gets only the entities that have renderable components.
      java.lang.String[] getResourceUris()
      Gets resource URIs for all externally-referenced buffers.
      int getRoot()
      Gets the transform root for the asset, which has no matching glTF node.
      int popRenderable()
      Pops a ready renderable off the queue, or returns 0 if no renderables have become ready.
      int popRenderables​(int[] entities)
      Pops one or more renderables off the queue, or returns the available number.
      void releaseSourceData()
      Reclaims CPU-side memory for URI strings, binding lists, and raw animation data.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getRoot

        public int getRoot()
        Gets the transform root for the asset, which has no matching glTF node.
      • popRenderable

        public int popRenderable()
        Pops a ready renderable off the queue, or returns 0 if no renderables have become ready. NOTE: To determine the progress percentage or completion status, please use ResourceLoader#asyncGetLoadProgress. This helper method allows clients to progressively add renderables to the scene as textures gradually become ready through asynchronous loading. See also ResourceLoader#asyncBeginLoad.
      • popRenderables

        public int popRenderables​(@Nullable
                                  int[] entities)
        Pops one or more renderables off the queue, or returns the available number. Returns the number of entities written into the given array. If the given array is null, returns the number of available renderables.
      • getEntities

        @NonNull
        public int[] getEntities()
        Gets the list of entities, one for each glTF node.

        All of these have a transform component. Some of the returned entities may also have a renderable or light component.

      • getLightEntities

        @NonNull
        public int[] getLightEntities()
        Gets only the entities that have light components.
      • getRenderableEntities

        @NonNull
        public int[] getRenderableEntities()
        Gets only the entities that have renderable components.
      • getCameraEntities

        @NonNull
        public int[] getCameraEntities()
        Gets only the entities that have camera components.

        Note about aspect ratios:
        gltfio always uses an aspect ratio of 1.0 when setting the projection matrix for perspective cameras. gltfio then sets the camera's scaling matrix with the aspect ratio specified in the glTF file (if present).
        The camera's scaling matrix allows clients to adjust the aspect ratio independently from the camera's projection.

        See Also:
        Camera.setScaling(double, double)
      • getFirstEntityByName

        public int getFirstEntityByName​(java.lang.String name)
        Returns the first entity with the given name, or 0 if none exist.
      • getEntitiesByName

        @NonNull
        public int[] getEntitiesByName​(java.lang.String name)
        Gets a list of entities with the given name.
      • getEntitiesByPrefix

        @NonNull
        public int[] getEntitiesByPrefix​(java.lang.String prefix)
        Gets a list of entities whose names start with the given prefix.
      • getBoundingBox

        @NonNull
        public com.google.android.filament.Box getBoundingBox()
        Gets the bounding box computed from the supplied min / max values in glTF accessors. This does not return a bounding box over all FilamentInstance, it's just a straightforward AAAB that can be determined at load time from the asset data.
      • getName

        public java.lang.String getName​(int entity)
        Gets the NameComponentManager label for the given entity, if it exists.
      • getExtras

        @Nullable
        public java.lang.String getExtras​(int entity)
        Gets the glTF extras string for the asset or a specific node.
        Parameters:
        entity - the entity corresponding to the glTF node, or 0 to get the asset-level string.
        Returns:
        the requested extras string, or null if it does not exist.
      • getMorphTargetNames

        @NonNull
        public java.lang.String[] getMorphTargetNames​(int entity)
        Gets the names of all morph targets in the given entity.
      • getResourceUris

        @NonNull
        public java.lang.String[] getResourceUris()
        Gets resource URIs for all externally-referenced buffers.
      • releaseSourceData

        public void releaseSourceData()
        Reclaims CPU-side memory for URI strings, binding lists, and raw animation data. This should only be called after ResourceLoader#loadResources() or ResourceLoader#asyncBeginLoad(). If this is an instanced asset, this prevents creation of new instances.
      • getEngine

        public com.google.android.filament.Engine getEngine()