import type { AssetContainer } from "@babylonjs/core/assetContainer"; import type { ISceneLoaderProgressEvent } from "@babylonjs/core/Loading/sceneLoader"; import type { MultiMaterial } from "@babylonjs/core/Materials/multiMaterial"; import { Scene } from "@babylonjs/core/scene"; import type { Nullable } from "@babylonjs/core/types"; import type { IMmdMaterialBuilder, MaterialInfo } from "./IMmdMaterialBuilder"; import { MmdStandardMaterial } from "./mmdStandardMaterial"; import type { ILogger } from "./Parser/ILogger"; import type { IArrayBufferFile } from "./referenceFileResolver"; import { ReferenceFileResolver } from "./referenceFileResolver"; import { TextureAlphaChecker } from "./textureAlphaChecker"; /** * MMD standard material builder * * Use `MmdStandardMaterial` to create a mesh material */ export declare class MmdStandardMaterialBuilder implements IMmdMaterialBuilder { /** * The scale factor of the edge size (default: 0.01) * * The mmd outline parameter needs to be scaled to fit the outline shader of the Babylon.js */ static EdgeSizeScaleFactor: number; /** * The threshold of material alpha to use transparency mode. (default: 195) * * lower value is more likely to use transparency mode. (0 - 255) */ alphaThreshold: number; /** * The threshold of transparency mode to use alpha blend. (default: 100) * * lower value is more likely to use alpha test mode. otherwise use alpha blemd mode */ alphaBlendThreshold: number; /** * Whether to use alpha evaluation (default: true) * * If true, evaluate the alpha of the texture to automatically determine the blending method of the material * * This automatic blend mode decision is not perfect and is quite costly * * For load time optimization, it is recommended to turn off this feature and set the blending mode for the material manually */ useAlphaEvaluation: boolean; /** * The canvas resolution to evaluate alpha (default: 512) * * Resolution of the render canvas used to evaluate alpha internally * * The higher the resolution, the higher the accuracy and the longer the load time */ alphaEvaluationResolution: number; private readonly _textureLoader; buildMaterials(uniqueId: number, materialsInfo: readonly MaterialInfo[], texturePathTable: readonly string[], rootUrl: string, fileRootId: string, referenceFiles: readonly File[] | readonly IArrayBufferFile[], scene: Scene, assetContainer: Nullable, indices: Uint16Array | Uint32Array, uvs: Float32Array, multiMaterial: MultiMaterial, logger: ILogger, onTextureLoadProgress?: (event: ISceneLoaderProgressEvent) => void, onTextureLoadComplete?: () => void): void; /** * Load general scalar properties (diffuse, specular, ambient, alpha, shininess) * * This method can be overridden for customizing the material loading process * @param material Material * @param materialInfo Material information */ loadGeneralScalarProperties: (material: MmdStandardMaterial, materialInfo: MaterialInfo) => Promise | void; /** * Load diffuse texture * * This method can be overridden for customizing the material loading process * @param uniqueId Model unique id * @param material Material * @param materialInfo Material information * @param texturePathTable Texture path table * @param scene Scene * @param assetContainer Asset container * @param rootUrl Root url * @param fileRootId File root id * @param referenceFileResolver Reference file resolver * @param offset Offset of the material index * @param logger Logger * @param getTextureAlphaChecker Get texture alpha checker * @param onTextureLoadComplete Texture load complete callback */ loadDiffuseTexture: (uniqueId: number, material: MmdStandardMaterial, materialInfo: MaterialInfo, texturePathTable: readonly string[], scene: Scene, assetContainer: Nullable, rootUrl: string, fileRootId: string, referenceFileResolver: ReferenceFileResolver, materialIndexOffset: number, logger: ILogger, getTextureAlphaChecker: () => Nullable, onTextureLoadComplete?: () => void) => Promise | void; /** * Load sphere texture * * This method can be overridden for customizing the material loading process * @param uniqueId Model unique id * @param material Material * @param materialInfo Material information * @param texturePathTable Texture path table * @param scene Scene * @param assetContainer Asset container * @param rootUrl Root url * @param fileRootId File root id * @param referenceFileResolver Reference file resolver * @param logger Logger * @param onTextureLoadComplete Texture load complete callback */ loadSphereTexture: (uniqueId: number, material: MmdStandardMaterial, materialInfo: MaterialInfo, texturePathTable: readonly string[], scene: Scene, assetContainer: Nullable, rootUrl: string, fileRootId: string, referenceFileResolver: ReferenceFileResolver, logger: ILogger, onTextureLoadComplete?: () => void) => Promise | void; /** * Load toon texture * * This method can be overridden for customizing the material loading process * @param uniqueId Model unique id * @param material Material * @param materialInfo Material information * @param texturePathTable Texture path table * @param scene Scene * @param assetContainer Asset container * @param rootUrl Root url * @param fileRootId File root id * @param referenceFileResolver Reference file resolver * @param logger Logger * @param onTextureLoadComplete Texture load complete callback */ loadToonTexture: (uniqueId: number, material: MmdStandardMaterial, materialInfo: MaterialInfo, texturePathTable: readonly string[], scene: Scene, assetContainer: Nullable, rootUrl: string, fileRootId: string, referenceFileResolver: ReferenceFileResolver, logger: ILogger, onTextureLoadComplete?: () => void) => Promise | void; /** * Load outline rendering properties * * This method can be overridden for customizing the material loading process * @param material Material * @param materialInfo Material information * @param logger Logger */ loadOutlineRenderingProperties: (material: MmdStandardMaterial, materialInfo: MaterialInfo, logger: ILogger) => Promise | void; /** * Called after building a single material * * This method is called after the material and textures have been loaded */ afterBuildSingleMaterial: (material: MmdStandardMaterial, materialIndex: number, materialInfo: MaterialInfo, multiMaterial: MultiMaterial, texturePathTable: readonly string[], scene: Scene, rootUrl: string) => void; }