ModelLoader

class ModelLoader(val engine: Engine, context: Context, coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.IO))

Consumes a blob of glTF 2.0 content (either JSON or GLB) and produces a Model object, which is a bundle of Filament textures, vertex buffers, index buffers, etc.

A Model is composed of 1 or more ModelInstance objects which contain entities and components.

Constructors

Link copied to clipboard
constructor(engine: Engine, context: Context, coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.IO))

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val assetLoader: AssetLoader
Link copied to clipboard
val engine: Engine
Link copied to clipboard
val materialProvider: UbershaderProvider
Link copied to clipboard

Gets the status of an asynchronous resource load as a percentage in 0,1.

Link copied to clipboard
var resourceLoader: ResourceLoader

Functions

Link copied to clipboard
fun clear()
Link copied to clipboard

Adds a new instance to the asset.

Link copied to clipboard
fun createInstancedModel(file: File, count: Int, resourceResolver: (resourceFileName: String) -> Buffer? = { resourceFile -> File(file.parent, resourceFile).readBuffer() }): List<ModelInstance>
fun createInstancedModel(@RawRes rawResId: Int, count: Int, resourceResolver: (resourceFileName: String) -> Buffer? = { null }): List<ModelInstance>
fun createInstancedModel(assetFileLocation: String, count: Int, resourceResolver: (resourceFileName: String) -> Buffer? = { context.assets.readBuffer(getFolderPath(assetFileLocation, it)) }): List<ModelInstance>

Creates a primary Model with one or more ModelInstances from the contents of a GLB or GLTF file.

fun createInstancedModel(buffer: Buffer, count: Int, resourceResolver: (resourceFileName: String) -> Buffer? = { null }): List<ModelInstance>

Creates a Model with one or more ModelInstances from the contents of a GLB or GLTF file.

Link copied to clipboard
fun createModel(file: File, resourceResolver: (resourceFileName: String) -> Buffer? = { resourceFile -> File(file.parent, resourceFile).readBuffer() }): Model
fun createModel(assetFileLocation: String, resourceResolver: (resourceFileName: String) -> Buffer? = { resourceFile -> context.assets.readBuffer(getFolderPath(assetFileLocation, resourceFile)) }): Model

Creates a Model from the contents of a GLB or GLTF asset file.

fun createModel(buffer: Buffer, resourceResolver: (resourceFileName: String) -> Buffer? = { null }): Model

Creates a Model from the contents of a GLB or GLTF Buffer.

fun createModel(@RawRes rawResId: Int, resourceResolver: (resourceFileName: String) -> Buffer? = { null }): Model

Creates a Model from the contents of a GLB or GLTF raw file.

Link copied to clipboard
fun createModelInstance(file: File, resourceResolver: (resourceFileName: String) -> Buffer? = { resourceFile -> File(file.parent, resourceFile).readBuffer() }): ModelInstance
fun createModelInstance(@RawRes rawResId: Int, resourceResolver: (resourceFileName: String) -> Buffer? = { null }): ModelInstance

Creates a Model from the contents of a GLB or GLTF raw file and get its default instance.

fun createModelInstance(buffer: Buffer, resourceResolver: (resourceFileName: String) -> Buffer? = { null }): ModelInstance

Creates a Model from the contents of a GLB or GLTF Buffer.

fun createModelInstance(assetFileLocation: String, resourceResolver: (resourceFileName: String) -> Buffer? = { context.assets.readBuffer(getFolderPath(assetFileLocation, it)) }): ModelInstance

Creates a Model from the contents of a GLB or GLTF asset file and get its default instance.

Link copied to clipboard
fun destroy()
Link copied to clipboard
fun destroyModel(model: Model)
Link copied to clipboard
suspend fun loadInstancedModel(fileLocation: String, count: Int, resourceResolver: (resourceFileName: String) -> String = { getFolderPath(fileLocation, it) }): List<ModelInstance>

Loads a primary Model with one or more ModelInstances from the contents of a GLB or GLTF file.

Link copied to clipboard
fun loadInstancedModelAsync(fileLocation: String, count: Int, resourceResolver: (resourceFileName: String) -> String = { getFolderPath(fileLocation, it) }, onResult: (List<ModelInstance>) -> Unit): Job

Loads a primary Model with one or more ModelInstances from the contents of a GLB or GLTF file.

Link copied to clipboard
suspend fun loadModel(fileLocation: String, resourceResolver: (resourceFileName: String) -> String = { getFolderPath(fileLocation, it) }): Model?

Loads a Model from the contents of a GLB or GLTF file.

Link copied to clipboard
fun loadModelAsync(fileLocation: String, resourceResolver: (resourceFileName: String) -> String = { getFolderPath(fileLocation, it) }, onResult: (Model?) -> Unit): Job

Loads a Model from the contents of a GLB or GLTF file within a self owned coroutine scope.

Link copied to clipboard
suspend fun loadModelInstance(fileLocation: String, resourceResolver: (resourceFileName: String) -> String = { getFolderPath(fileLocation, it) }): ModelInstance?

Loads a Model from the contents of a GLB or GLTF file and get its default instance.

Link copied to clipboard
fun loadModelInstanceAsync(fileLocation: String, resourceResolver: (resourceFileName: String) -> String = { getFolderPath(fileLocation, it) }, onResult: (ModelInstance?) -> Unit): Job

Loads a Model from the contents of a GLB or GLTF file within a self owned coroutine scope