open class Texture


Represents a Texture in SceneCore.

A texture is an image that can be applied to a 3D model to give it color, detail, and realism. It can also be used as an alpha mask for a StereoSurfaceEntity.

It's important to dispose of the Texture when it's no longer needed to free up resources. This can be done by calling the dispose method.

Summary

Public companion functions

suspend Texture
@MainThread
create(session: Session, path: Path)

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

Public functions

open Unit

Disposes the given Texture.

Public companion functions

create

@MainThread
suspend fun create(session: Session, path: Path): Texture

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

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

Parameters
session: Session

The Session to use for loading the Texture.

path: Path

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

Returns
Texture

a Texture upon completion.

Throws
kotlin.IllegalArgumentException

if Path.isAbsolute is true, as this method requires a relative path.

Public functions

dispose

Added in 1.0.0-alpha07
@MainThread
open fun dispose(): Unit

Disposes the given Texture.

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.

When using a texture as an alpha mask for stereoscopic content, the StereoSurfaceEntity should be disposed before the texture is disposed.