public class Texture

Known direct subclasses
CubeMapTexture

CubeMapTexture represents a cube map texture that can be used with materials.


Texture represents a texture that can be used with materials.

Summary

Public methods

static final @NonNull Texture
@MainThread
create(
    @NonNull Session session,
    @NonNull Path path,
    @NonNull TextureSampler sampler
)

Public factory for a Texture, asynchronously loading a preprocessed texture from a Path relative to the application's assets/ folder.

void

Disposes the given Texture.

Public methods

create

@MainThread
public static final @NonNull Texture create(
    @NonNull Session session,
    @NonNull Path path,
    @NonNull TextureSampler sampler
)

Public factory for a Texture, asynchronously loading a preprocessed texture from a Path relative to the application's assets/ folder.

This method must be called from the main thread. https://developer.android.com/guide/components/processes-and-threads

Currently, only URLs and relative paths from the android_assets/ directory are supported.

Parameters
@NonNull Session session

The Session to use for loading the Texture.

@NonNull Path path

The Path of the .png texture file to be loaded, relative to the application's assets/ folder.

@NonNull TextureSampler sampler

A TextureSampler descriptor which describes how the texture will be filtered

Returns
@NonNull Texture

a Texture upon completion.

Throws
kotlin.IllegalArgumentException

if Path.isAbsolute is true, as this method requires a relative path, or if the path does not specify a .zip file.

dispose

Added in 1.0.0-alpha05
@MainThread
public void dispose()

Disposes the given Texture.

This method must be called from the main thread. https://developer.android.com/guide/components/processes-and-threads

Currently, a glTF model (which this texture will be used with) can't be disposed. This means that calling dispose on the texture will lead to a crash if the call is made out of order, that is, if the texture is disposed before the glTF model that uses it.