import type { AssetContainer } from "@babylonjs/core/assetContainer"; import { Texture } from "@babylonjs/core/Materials/Textures/texture"; import { Observable } from "@babylonjs/core/Misc/observable"; import type { Scene } from "@babylonjs/core/scene"; import type { Nullable } from "@babylonjs/core/types"; declare class MmdTextureData { readonly cacheKey: string; private readonly _scene; private readonly _assetContainer; private readonly _onLoad; private readonly _onError?; private _arrayBuffer; private _texture; constructor(cacheKey: string, scene: Scene, assetContainer: Nullable, urlOrTextureName: string, useLazyLoadWithBuffer: boolean, onLoad: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>); loadFromArrayBuffer(arrayBuffer: ArrayBuffer): void; private _createTexture; get arrayBuffer(): Nullable; get texture(): Nullable; } /** * MMD texture load result */ export interface MmdTextureLoadResult { /** * Loaded texture * * If the texture has load error or decoding error, this value is null */ readonly texture: Nullable; /** * Loaded texture data in encoded format(PNG/JPG/BMP) * * If the texture is not loaded, this value is null */ readonly arrayBuffer: Nullable; } /** * MMD async texture loader * * The MMD async texture loader caches redundant textures across multiple materials and simplifies asynchronous textural loading * * It also includes handling when multiple models are loaded at the same time */ export declare class MmdAsyncTextureLoader { /** * Observable which is notified when all textures of the model are loaded * * key: uniqueId, value: Observable */ readonly onModelTextureLoadedObservable: Map>; /** * Texture cache * * This cache is used to avoid loading the same texture multiple times * * Once loaded, all textures are stored in the cache and deleted from the cache on their own when the texture is disposed * * key: requestString, value: texture */ readonly textureCache: Map; private readonly _textureLoadInfoMap; private readonly _loadingModels; private readonly _errorTexturesReferenceCount; private static readonly _EmptyResult; private _incrementLeftLoadCount; private _decrementLeftLoadCount; /** * Notify that the model texture load request has been ended * * If all the textures are cached, no event callback is called * * so this method must be called and specified at the end of the model's text load request to handle such an edge case * * @param uniqueId Model unique id */ loadModelTexturesEnd(uniqueId: number): void; private _addErrorTextureReferenceCount; private _removeErrorTexturesReferenceCount; private _handleTextureOnDispose; private _loadTextureAsyncInternal; /** * Load texture asynchronously * * All texture requests for one model must be executed within one synchronization routine without await * * Because the internally used left texture count mechanism requires knowing the total number of textures required at the time the request is processed * * @param uniqueId Model unique id * @param rootUrl Root url * @param relativeTexturePathOrIndex Relative texture path or shared toon texture index * @param scene Scene * @param assetContainer Asset container * @returns MMD texture load result */ loadTextureAsync(uniqueId: number, rootUrl: string, relativeTexturePathOrIndex: string | number, scene: Scene, assetContainer: Nullable): Promise; /** * Load texture from buffer asynchronously * * All texture requests for one model must be executed within one synchronization routine without await * * Because the internally used left texture count mechanism requires knowing the total number of textures required at the time the request is processed * * @param uniqueId Model unique id * @param textureName Texture name * @param arrayBufferOrBlob Texture data encoded in PNG/JPG/BMP * @param scene Scene * @param assetContainer Asset container * @param applyPathNormalization Whether to apply path normalization to the texture name (default: true) * @returns MMD texture load result */ loadTextureFromBufferAsync(uniqueId: number, textureName: string, arrayBufferOrBlob: ArrayBuffer | Blob, scene: Scene, assetContainer: Nullable, applyPathNormalization?: boolean): Promise; /** * Normalize path * @param path Path * @returns Normalized path */ pathNormalize(path: string): string; } export {};