import "@babylonjs/core/Physics/v2/physicsEngineComponent"; import { Matrix } from "@babylonjs/core/Maths/math.vector"; import type { Mesh } from "@babylonjs/core/Meshes/mesh"; import type { Scene } from "@babylonjs/core/scene"; import type { DeepImmutable, Nullable } from "@babylonjs/core/types"; import { PmxObject } from "../../../Loader/Parser/pmxObject"; import type { ILogger } from "../../ILogger"; import type { IMmdRuntimeBone } from "../../IMmdRuntimeBone"; import type { IMmdModelPhysicsCreationOptions } from "../../mmdRuntime"; import type { IMmdPhysics, IMmdPhysicsModel } from "../../Physics/IMmdPhysics"; import type { Constraint } from "./Bind/constraint"; import type { IPhysicsRuntime } from "./Bind/Impl/IPhysicsRuntime"; import type { MultiPhysicsRuntime } from "./Bind/Impl/multiPhysicsRuntime"; import { RigidBodyBundle } from "./Bind/rigidBodyBundle"; import { RigidBodyConstructionInfoList } from "./Bind/rigidBodyConstructionInfoList"; declare class MmdRigidBodyData { readonly linkedBone: Nullable; physicsMode: PmxObject.RigidBody.PhysicsMode; readonly bodyOffsetMatrix: Matrix; readonly bodyOffsetMatrixInverse: Matrix; constructor(linkedBone: Nullable, physicsMode: PmxObject.RigidBody.PhysicsMode); computeBodyOffsetMatrix(worldMatrix: DeepImmutable, parentWorldMatrixInverse: DeepImmutable): void; } declare class MmdRigidBodyBundle extends RigidBodyBundle { readonly rigidBodyData: MmdRigidBodyData[]; constructor(runtime: IPhysicsRuntime, info: RigidBodyConstructionInfoList, data: MmdRigidBodyData[], count: number); } /** * MMD bullet physics model is container of the bullet physics resources of the MMD model */ export declare class MmdBulletPhysicsModel implements IMmdPhysicsModel { private readonly _physicsRuntime; private readonly _worldId; private readonly _kinematicSharedWorldIds; private readonly _rigidBodyIndexMap; private _bundle; private readonly _constraints; private readonly _rootMesh; private readonly _syncedRigidBodyStates; private _disabledRigidBodyCount; /** * Create a new MMD bullet physics model * @param physicsRuntime The physics runtime * @param worldId The world id * @param kinematicSharedWorldIds The kinematic shared world ids * @param rigidBodyIndexMap The rigid body index map * @param bundle Rigid body bundle * @param constraints Physics constraints */ constructor(physicsRuntime: MultiPhysicsRuntime, worldId: number, kinematicSharedWorldIds: readonly number[], rigidBodyIndexMap: Int32Array, bundle: MmdRigidBodyBundle, constraints: Nullable[], rootMesh: Mesh); /** * Dispose the physics resources */ dispose(): void; private static readonly _BodyWorldMatrix; /** * Reset the rigid body positions and velocities */ initialize(): void; /** * Indicate whether all IK must be solved */ get needDeoptimize(): boolean; /** * commit rigid body states to physics model * * if rigidBodyStates[i] is 0, the rigid body motion type is kinematic, * if rigidBodyStates[i] is 1 and physicsMode is not FollowBone, the rigid body motion type is dynamic. * * @param rigidBodyStates state of rigid bodies for physics toggle */ commitBodyStates(rigidBodyStates: Uint8Array): void; private static readonly _Position; private static readonly _Rotation; private static readonly _CurrentPosition; private static readonly _CurrentRotation; private static readonly _EulerAngles1; private static readonly _EulerAngles2; private static readonly _Velocity; /** * 0: unknown, 1: kinematic, 2: target transform */ private _bodyKinematicToggleMap; /** * Set the rigid bodies transform to the bones transform */ syncBodies(): void; private static readonly _ModelWorldMatrixInverse; private static readonly _BoneWorldPosition; /** * Set the bones transform to the rigid bodies transform */ syncBones(): void; } /** * Use the bullet physics engine to build the physics model of the MMD model * * If you do not want to use a physics engine, you can reduce the bundling size by not import this class */ export declare class MmdBulletPhysics implements IMmdPhysics { /** * The world id of the physics model * * when you not specify the world id, the physics model will be created in new world */ nextWorldId: number; private readonly _sceneOrRuntime; /** * Create a new MMD bullet physics * * Scene must have a physics engine enabled * @param sceneOrRuntime The scene or the physics runtime to build the physics model */ constructor(sceneOrRuntime: Scene | MultiPhysicsRuntime); /** * Build the physics model of the MMD model * @param rootMesh Root mesh of the MMD model * @param bones MMD runtime bones * @param rigidBodies rigid bodies information * @param joints joints information * @param logger Logger * @param physicsOptions Optional physics options * @returns MMD physics model * @throws If the physics model cannot be built */ buildPhysics(rootMesh: Mesh, bones: readonly IMmdRuntimeBone[], rigidBodies: PmxObject["rigidBodies"], joints: PmxObject["joints"], logger: ILogger, physicsOptions: Nullable): IMmdPhysicsModel; } export {};