Class Texture.Builder

  • Enclosing class:
    Texture

    public static final class Texture.Builder
    extends java.lang.Object
    Factory class for Texture
    • Method Detail

      • setSource

        public Texture.Builder setSource​(android.content.Context context,
                                         android.net.Uri sourceUri)
        Allows a Texture to be constructed from Uri. Construction will be asynchronous.
        Parameters:
        sourceUri - Sets a remote Uri or android resource Uri. The texture will be added to the registry using the Uri A previously registered texture with the same Uri will be re-used.
        context - Sets the Context used to resolve sourceUri
        Returns:
        Texture.Builder for chaining setup calls.
      • setSource

        public Texture.Builder setSource​(java.util.concurrent.Callable<java.io.InputStream> inputStreamCreator)
        Allows a Texture to be constructed via callable function.
        Parameters:
        inputStreamCreator - Supplies an InputStream with the Texture data.
        Returns:
        Texture.Builder for chaining setup calls.
      • setSource

        public Texture.Builder setSource​(android.content.Context context,
                                         int resource)
        Allows a Texture to be constructed from resource. Construction will be asynchronous.
        Parameters:
        resource - an android resource with raw type. A previously registered texture with the same resource id will be re-used.
        context - Context used for resolution
        Returns:
        Texture.Builder for chaining setup calls.
      • setSource

        public Texture.Builder setSource​(android.graphics.Bitmap bitmap)
        Allows a Texture to be constructed from a Bitmap. Construction will be immediate.

        The Bitmap must meet the following conditions to be used by Sceneform:

        • Bitmap.getConfig() must be Bitmap.Config.ARGB_8888.
        • Bitmap.isPremultiplied() must be true.
        • The width and height must be smaller than 4096 pixels.
        Parameters:
        bitmap - Bitmap source of texture data
        Throws:
        java.lang.IllegalArgumentException - if the bitmap isn't valid
      • setRegistryId

        public Texture.Builder setRegistryId​(java.lang.Object registryId)
        Allows a Texture to be reused. If registryId is non-null it will be saved in a registry and the registry will be checked for this id before construction.
        Parameters:
        registryId - Allows the function to be skipped and a previous texture to be re-used.
        Returns:
        Texture.Builder for chaining setup calls.
      • build

        public java.util.concurrent.CompletableFuture<Texture> build()
        Creates a new Texture based on the parameters set previously
        Throws:
        java.lang.IllegalStateException - if the builder is not properly set