Page Summary
-
Texture.Builderis a factory class used to createTextureobjects for rendering in Sceneform. -
It provides methods to set the texture source from various inputs like Bitmaps, URIs, resources, and input streams.
-
Developers can configure rendering parameters using
Texture.Samplerand specify data type usingTexture.Usage. -
Texture.Buildersupports texture reuse through registry IDs, optimizing performance. -
The
build()method creates a newTextureinstance based on the provided configurations.
Factory class for Texture
Public Methods
| CompletableFuture<Texture> | |
| Texture.Builder | |
| Texture.Builder |
setSampler(Texture.Sampler sampler)
Sets the
Texture.Samplerto control rendering parameters on the Texture. |
| Texture.Builder |
setSource(Callable<InputStream> inputStreamCreator)
Allows a
Texture to be constructed via callable function. |
| Texture.Builder | |
| Texture.Builder | |
| Texture.Builder | |
| Texture.Builder |
Inherited Methods
Public Methods
public CompletableFuture<Texture> build ()
Creates a new Texture based on the parameters set previously
Throws
| IllegalStateException | if the builder is not properly set |
|---|
public Texture.Builder setRegistryId (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.Builderfor chaining setup calls.
public Texture.Builder setSampler (Texture.Sampler sampler)
Sets the Texture.Samplerto control rendering parameters on the Texture.
Parameters
| sampler | Controls appearance of the Texture |
|---|
Returns
Texture.Builderfor chaining setup calls.
public Texture.Builder setSource (Callable<InputStream> inputStreamCreator)
Allows a Texture to be constructed via callable function.
Parameters
| inputStreamCreator | Supplies an InputStream with the Texture data. |
|---|
Returns
Texture.Builderfor chaining setup calls.
public Texture.Builder setSource (Context context, Uri sourceUri)
Parameters
| context | Sets the Context used to resolve sourceUri |
|---|---|
| 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. |
Returns
Texture.Builderfor chaining setup calls.
public Texture.Builder setSource (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:
getConfig()must beARGB_8888.isPremultiplied()must be true.- The width and height must be smaller than 4096 pixels.
Parameters
| bitmap | Bitmap source of texture data |
|---|
Throws
| IllegalArgumentException | if the bitmap isn't valid |
|---|
public Texture.Builder setSource (Context context, int resource)
Allows a Texture to be constructed from resource. Construction will be asynchronous.
Parameters
| context | Context used for resolution |
|---|---|
| resource | an android resource with raw type. A previously registered texture with the same resource id will be re-used. |
Returns
Texture.Builderfor chaining setup calls.
public Texture.Builder setUsage (Texture.Usage usage)
Mark the Texture as a containing color, normal or arbitrary data. Color is the
default.
Parameters
| usage | Sets the kind of data in Texture |
|---|
Returns
Texture.Builderfor chaining setup calls.