import { AssetContainer } from "@babylonjs/core/assetContainer"; import { Skeleton } from "@babylonjs/core/Bones/skeleton"; import type { ISceneLoaderAsyncResult, ISceneLoaderPluginAsync, ISceneLoaderPluginExtensions, ISceneLoaderPluginFactory, ISceneLoaderProgressEvent, SceneLoaderPluginOptions } from "@babylonjs/core/Loading/sceneLoader"; import type { Material } from "@babylonjs/core/Materials/material"; import type { MultiMaterial } from "@babylonjs/core/Materials/multiMaterial"; import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture"; import type { Geometry } from "@babylonjs/core/Meshes/geometry"; import type { Mesh } from "@babylonjs/core/Meshes/mesh"; import type { MorphTargetManager } from "@babylonjs/core/Morph/morphTargetManager"; import type { Scene } from "@babylonjs/core/scene"; import type { Nullable } from "@babylonjs/core/types"; import type { IMmdMaterialBuilder } from "./IMmdMaterialBuilder"; import type { MmdModelMetadata } from "./mmdModelMetadata"; import type { IBpmxLoaderOptions } from "./Optimized/bpmxLoader"; import type { BpmxObject } from "./Optimized/Parser/bpmxObject"; import type { ILogger } from "./Parser/ILogger"; import type { PmxObject } from "./Parser/pmxObject"; import type { IPmLoaderOptions } from "./pmLoader"; import type { IProgressTask } from "./progress"; import { Progress } from "./progress"; declare module "@babylonjs/core/Loading/sceneLoader" { interface SceneLoaderPluginOptions { /** * Defines options for the pmx/pmd/bpmx loader. */ mmdmodel?: Partial; } } /** @internal */ export interface IMmdModelLoaderOptions { /** * Material builder used by loader * * This property can be overwritten to customize the material of the loaded model */ readonly materialBuilder: Nullable; /** * Whether to use SDEF (default: true) * * Spherical Deformation(SDEF) is a feature that allows you to deform the model more naturally than the traditional skinning method * * But it uses more memory and is slower than the traditional skinning method * * If you are targeting a platform with limited memory or performance, you may want to disable this feature */ readonly useSdef: boolean; /** * Whether to build skeleton (default: true) * * If you want to load a model without a skeleton, you can disable this feature * * This feature is useful when you want to load a model that is not animated (e.g. background object) */ readonly buildSkeleton: boolean; /** * Whether to build morph (default: true) * * If you want to load a model without morph, you can disable this feature * * This feature is useful when you want to load a model that is not animated (e.g. background object) */ readonly buildMorph: boolean; /** * Margin of the bounding box of the model (default: 10) * * This property is used to calculate the bounding box of the model * * If the bounding box of the model is too small, the model may not be rendered correctly * * This value may need to be set higher, especially in motion with a large movement range */ readonly boundingBoxMargin: number; /** * Whether to always set bounding info for submeshes (default: true) * * If this property is true, the loader will always set bounding info for submeshes * Otherwise, it will only set bounding info for submeshes if the mesh has more than one submesh */ readonly alwaysSetSubMeshesBoundingInfo: boolean; /** * Whether to preserve the data used for serialization (default: false) * * If you want to serialize the model, you need to set this property to true * * This property is used to serialize the model into bpmx file */ readonly preserveSerializationData: boolean; /** * Enable or disable debug logging (default: false) */ readonly loggingEnabled: boolean; } /** @internal */ export interface IMmdModelLoadState { readonly arrayBuffer: ArrayBufferLike; readonly pmFileId: string; readonly materialBuilder: Nullable; readonly useSdef: boolean; readonly buildSkeleton: boolean; readonly buildMorph: boolean; readonly boundingBoxMargin: number; readonly alwaysSetSubMeshesBoundingInfo: boolean; readonly preserveSerializationData: boolean; } /** @internal */ export interface IMmdModelBuildGeometryResult { readonly rootMesh: Mesh; readonly meshes: Mesh[]; readonly geometries: Geometry[]; } /** @internal */ export interface IBuildMaterialResult { readonly materials: Material[]; readonly multiMaterials: MultiMaterial[]; readonly textureLoadPromise: Promise; } /** @internal */ export interface IBuildMorphResult { readonly morphsMetadata: MmdModelMetadata.Morph[]; readonly morphTargetManagers: MorphTargetManager[]; } /** * @internal * Base class of loader for MMD model (pmx / pmd / bpmx) */ export declare abstract class MmdModelLoader implements IMmdModelLoaderOptions, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory, ILogger { /** * Name of the loader */ name: string; /** * Extensions supported by this loader */ extensions: ISceneLoaderPluginExtensions; materialBuilder: Nullable; useSdef: boolean; buildSkeleton: boolean; buildMorph: boolean; boundingBoxMargin: number; alwaysSetSubMeshesBoundingInfo: boolean; preserveSerializationData: boolean; private _loggingEnabled; /** @internal */ log: (message: string) => void; /** @internal */ warn: (message: string) => void; /** @internal */ error: (message: string) => void; /** * Shared material builder instance */ static SharedMaterialBuilder: Nullable; /** * Create a new MMD model loader * * @param name Name of the loader * @param extensions Extensions supported by this loader * @param options babylon.js scene loader options * @param loaderOptions Overriding options, typically pass global mmd model loader instance as loaderOptions */ constructor(name: string, extensions: ISceneLoaderPluginExtensions, options?: Partial, loaderOptions?: IMmdModelLoaderOptions); importMeshAsync(_meshesNames: any, scene: Scene, data: LoadState, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, _fileName?: string): Promise; loadAsync(scene: Scene, data: LoadState, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, _fileName?: string): Promise; loadAssetContainerAsync(scene: Scene, data: LoadState, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, _fileName?: string): Promise; abstract createPlugin(options: SceneLoaderPluginOptions): ISceneLoaderPluginAsync; private _loadInternalAsync; protected abstract _parseFileAsync(arrayBuffer: ArrayBufferLike): Promise; protected _getProgressTaskCosts(state: LoadState, modelObject: ModelObject): IProgressTask[]; protected abstract _buildGeometryAsync(state: LoadState, modelObject: ModelObject, scene: Scene, assetContainer: Nullable, progress: Progress): Promise; protected abstract _buildMaterialAsync(state: LoadState, modelObject: ModelObject, rootMesh: Mesh, meshes: Mesh[], textureNameMap: Nullable>, scene: Scene, assetContainer: Nullable, rootUrl: string, progress: Progress): Promise; protected _buildSkeletonAsync(state: LoadState, modelObject: ModelObject, meshes: Mesh[], scene: Scene, assetContainer: Nullable, bonesMetadata: MmdModelMetadata.Bone[] | MmdModelMetadata.SerializationBone[], progress: Progress): Promise>; protected abstract _buildMorphAsync(state: LoadState, modelObject: ModelObject, buildGeometryResult: BuildGeometryResult, scene: Scene, assetContainer: Nullable, progress: Progress): Promise; private _applyBoundingBoxToSubmeshes; /** * Enable or disable debug logging (default: false) */ get loggingEnabled(): boolean; set loggingEnabled(value: boolean); private _logEnabled; private _logDisabled; private _warnEnabled; private _warnDisabled; private _errorEnabled; private _errorDisabled; }