import type { Material } from "@babylonjs/core/Materials/material"; import { Observable } from "@babylonjs/core/Misc/observable"; import type { Nullable } from "@babylonjs/core/types"; import type { IMmdBindableModelAnimation } from "./Animation/IMmdBindableAnimation"; import type { IMmdRuntimeModelAnimation } from "./Animation/IMmdRuntimeAnimation"; import type { MmdCompositeRuntimeModelAnimation } from "./Animation/mmdCompositeRuntimeModelAnimation"; import type { MmdRuntimeModelAnimation } from "./Animation/mmdRuntimeModelAnimation"; import type { MmdRuntimeModelAnimationGroup } from "./Animation/mmdRuntimeModelAnimationGroup"; import type { ILogger } from "./ILogger"; import type { IMmdMaterialProxyConstructor } from "./IMmdMaterialProxy"; import type { IMmdLinkedBoneContainer } from "./IMmdRuntimeLinkedBone"; import type { HumanoidMesh, MmdMesh, RuntimeMmdMesh } from "./mmdMesh"; import { MmdMorphController } from "./mmdMorphController"; import type { MmdPhysics } from "./mmdPhysics"; import type { IMmdRuntimeBone } from "./mmdRuntimeBone"; type RuntimeModelAnimation = MmdRuntimeModelAnimation | MmdRuntimeModelAnimationGroup | MmdCompositeRuntimeModelAnimation | IMmdRuntimeModelAnimation; /** * MmdModel is a class that controls the `MmdMesh` to animate the Mesh with MMD Runtime * * The mesh that instantiates `MmdModel` ignores some original implementations of Babylon.js and follows the MMD specifications * * The biggest difference is that the methods that get the absolute transform of `mesh.skeleton.bones` no longer work properly and can only get absolute transform through `bone.getFinalMatrix()` * * Final matrix is guaranteed to be updated after `MmdModel.afterPhysics()` stage */ export declare class MmdModel { /** * The mesh of this model */ readonly mesh: RuntimeMmdMesh; /** * The skeleton of this model * * This can be a instance of `Skeleton`, or if you are using a humanoid model, it will be referencing a virtualized bone tree * * So MmdModel.mesh.skeleton is not always equal to MmdModel.skeleton */ readonly skeleton: IMmdLinkedBoneContainer; /** * The morph controller of this model * * The `MmdMorphController` not only wrapper of `MorphTargetManager` but also controls the CPU bound morphs (bone, material, group) */ readonly morph: MmdMorphController; private readonly _physicsModel; private readonly _logger; private readonly _sortedRuntimeBones; private readonly _sortedRuntimeRootBones; readonly onCurrentAnimationChangedObservable: Observable>; private readonly _animations; private readonly _animationIndexMap; private _currentAnimation; /** * Create a MmdModel * @param mmdMesh Mesh that able to instantiate `MmdModel` * @param skeleton The virtualized bone container of the mesh * @param materialProxyConstructor The constructor of `IMmdMaterialProxy` * @param mmdPhysics Physics builder * @param logger Logger */ constructor(mmdMesh: MmdMesh, skeleton: IMmdLinkedBoneContainer, materialProxyConstructor: Nullable>, mmdPhysics: Nullable, logger: ILogger); /** * Create a MmdModel from `HumanoidMesh` * @param humanoidMesh Mesh that able to instantiate `MmdModel` * @param skeleton The virtualized bone container of the mesh * @param materialProxyConstructor The constructor of `IMmdMaterialProxy` * @param mmdPhysics Physics builder * @param logger Logger */ constructor(humanoidMesh: HumanoidMesh, skeleton: IMmdLinkedBoneContainer, materialProxyConstructor: Nullable>, mmdPhysics: Nullable, logger: ILogger); /** * Dispose this model * * Restore the original bone matrix update behavior * * Dispose the physics resources if the physics is enabled */ dispose(): void; /** * Get the sorted bones of this model * * The bones are sorted by `transformOrder` */ get sortedRuntimeBones(): readonly IMmdRuntimeBone[]; /** * Add an animation to this model * @param animation MMD animation or MMD model animation group to add * @param retargetingMap Model bone name to animation bone name map */ addAnimation(animation: IMmdBindableModelAnimation, retargetingMap?: { [key: string]: string; }): void; /** * Remove an animation from this model * * if index is out of range, do nothing * @param index The index of the animation to remove */ removeAnimation(index: number): void; /** * Set the current animation of this model * @param name The name of the animation to set * @throws {Error} if the animation is not found */ setAnimation(name: Nullable): void; /** * Get the animations of this model */ get runtimeAnimations(): readonly RuntimeModelAnimation[]; /** * Get the current animation of this model */ get currentAnimation(): Nullable; /** * Reset the morph weights and IK enabled state of this model */ resetState(): void; /** * Reset the rigid body positions and velocities of this model */ initializePhysics(): void; /** * Before the physics stage, update animations and run MMD runtime solvers * * This method must be called before the physics stage * * if frameTime is null, animations are not updated * @param frameTime The time elapsed since the last frame in 30fps */ beforePhysics(frameTime: Nullable): void; /** * After the physics stage, run MMD runtime solvers * * This method must be called after the physics stage */ afterPhysics(): void; private _update; private _buildRuntimeSkeleton; private _originalComputeTransformMatrices; private _disableSkeletonWorldMatrixUpdate; private _enableSkeletonWorldMatrixUpdate; private _resetPose; } export {};