ModelAsset

Represents a raw model asset that can be loaded into the engine.

This record encapsulates the source of the model data (e.g., a file or stream), its name, and metadata. It provides methods to load and parse the model data into a usable format.

Example: ModelAsset.of("model", "custom", bytes).toResult().

Since

2.0.0

Parameters

rawName

the original raw name or path of the asset

name

the sanitized, pack-compliant name of the asset

extension

the model extension without a leading dot, matched without case sensitivity

sizeAssume

the estimated size of the asset in bytes (0 if unknown)

supplier

a supplier for the input stream containing the model data

Constructors

Link copied to clipboard
@ApiStatus.Internal
constructor(@NotNull rawName: @NotNull String, @NotNull name: @NotNull String, @NotNull extension: @NotNull String, sizeAssume: Long, @NotNull supplier: @NotNull ModelAsset.StreamSupplier)
Internal constructor for ModelAsset.
@ApiStatus.Internal
constructor(@NotNull rawName: @NotNull String, @NotNull name: @NotNull String, sizeAssume: Long, @NotNull supplier: @NotNull ModelAsset.StreamSupplier)
Creates an asset using the default bbmodel extension.

Types

Link copied to clipboard
interface StreamSupplier
A functional interface for supplying an input stream.

Companion functions

Link copied to clipboard
@NotNull
open fun of(@NotNull file: @NotNull File): @NotNull ModelAsset
Creates a new ModelAsset from a file, inferring its extension or using bbmodel when absent.
@NotNull
open fun of(@NotNull path: @NotNull Path): @NotNull ModelAsset
Creates a new ModelAsset from a path, inferring its extension or using bbmodel when absent.
@NotNull
open fun of(@NotNull name: @NotNull String, bytes: Array<Byte>): @NotNull ModelAsset
Creates a new ModelAsset from a name and byte array using the default bbmodel extension.
@NotNull
open fun of(@NotNull name: @NotNull String, @NotNull supplier: @NotNull ModelAsset.StreamSupplier): @NotNull ModelAsset
Creates a new ModelAsset from a name and stream supplier using the default bbmodel extension.
@NotNull
open fun of(@NotNull name: @NotNull String, @NotNull extension: @NotNull String, bytes: Array<Byte>): @NotNull ModelAsset
Creates an asset from bytes with an explicit extension.
@NotNull
open fun of(@NotNull name: @NotNull String, @NotNull extension: @NotNull String, @NotNull supplier: @NotNull ModelAsset.StreamSupplier): @NotNull ModelAsset
Creates an asset from a stream supplier with an explicit extension.
@NotNull
open fun of(@NotNull name: @NotNull String, sizeAssume: Long, @NotNull supplier: @NotNull ModelAsset.StreamSupplier): @NotNull ModelAsset
Creates a new ModelAsset from a name, stream supplier, and estimated size using the default bbmodel extension.
@NotNull
open fun of(@NotNull name: @NotNull String, @NotNull extension: @NotNull String, sizeAssume: Long, @NotNull supplier: @NotNull ModelAsset.StreamSupplier): @NotNull ModelAsset
Creates an asset with an explicit extension and estimated size.

Functions

Link copied to clipboard
open fun compareTo(@NotNull o: @NotNull ModelAsset): Int
Link copied to clipboard
open fun equals(o: Any): Boolean
Link copied to clipboard
open fun hashCode(): Int
Link copied to clipboard
@NotNull
open fun toResult(): @NotNull ModelLoadResult
Loads this asset using its registered extension importer, or the built-in bbmodel importer if none is registered.
Link copied to clipboard
@NotNull
open fun toString(): @NotNull String