import "@babylonjs/core/Physics/v2/physicsEngineComponent"; import { Matrix } from "@babylonjs/core/Maths/math.vector"; import type { Mesh } from "@babylonjs/core/Meshes/mesh"; import { TransformNode } from "@babylonjs/core/Meshes/transformNode"; import { PhysicsMotionType } from "@babylonjs/core/Physics/v2/IPhysicsEnginePlugin"; import { PhysicsBody } from "@babylonjs/core/Physics/v2/physicsBody"; import type { PhysicsConstraint } from "@babylonjs/core/Physics/v2/physicsConstraint"; 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 "./IMmdPhysics"; declare class MmdPhysicsTransformNode extends TransformNode { readonly linkedBone: Nullable; physicsMode: PmxObject.RigidBody.PhysicsMode; readonly bodyOffsetMatrix: Matrix; readonly bodyOffsetMatrixInverse: Matrix; physicsBody: Nullable; constructor(name: string, scene: Scene, linkedBone: Nullable, physicsMode: PmxObject.RigidBody.PhysicsMode, isPure?: boolean); private static readonly _WorldMatrix; computeBodyOffsetMatrix(parentWorldMatrixInverse: DeepImmutable): void; } declare class MmdPhysicsBody extends PhysicsBody { private _temporalEnablePrestep; private _kinematicToggle; constructor(transformNode: MmdPhysicsTransformNode, motionType: PhysicsMotionType, startAsleep: boolean, scene: Scene); get temporalEnablePrestep(): boolean; set temporalEnablePrestep(value: boolean); get kinematicToggle(): boolean; set kinematicToggle(value: boolean); } declare class MmdPhysicsBodyWithBone extends MmdPhysicsBody { readonly linkedBone: IMmdRuntimeBone; constructor(transformNode: MmdPhysicsTransformNode, motionType: PhysicsMotionType, startAsleep: boolean, linkedBone: IMmdRuntimeBone, scene: Scene); } /** * MMD physics model is container of the physics resources of the MMD model */ export declare class MmdPhysicsModel implements IMmdPhysicsModel { private readonly _mmdPhysics; private readonly _nodes; private readonly _bodies; private readonly _constraints; private readonly _syncedRigidBodyStates; private _disabledRigidBodyCount; /** * Create a new MMD physics model * @param mmdPhysics MMD physics * @param nodes MMD physics transform nodes * @param bodies Physics bodies * @param constraints Physics constraints */ constructor(mmdPhysics: MmdPhysics, nodes: Nullable[], bodies: Nullable[], constraints: Nullable[]); /** * Dispose the physics resources */ dispose(): void; private static readonly _NodeWorldMatrix; private static readonly _ZeroVector; /** * 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 _NodeWorldPosition; private static readonly _NodeWorldRotation; /** * 0: unknown, 1: kinematic, 2: target transform */ private _bodyKinematicToggleMap; /** * Set the rigid bodies transform to the bones transform */ syncBodies(): void; private static readonly _BoneWorldPosition; /** * Set the bones transform to the rigid bodies transform */ syncBones(): void; } /** * Use the v2 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 MmdPhysics implements IMmdPhysics { /** * Set a threshold in radian to clamp the constraint's angular limit to 0 (default: 5 * Math.PI / 180) * * If your model's constraints have an odd bend, try increasing the value appropriately. * * A value of 5 * Math.PI / 180 to 30 * Math.PI / 180 is expected to work well. */ angularLimitClampThreshold: number; private readonly _scene; private readonly _enablePreStepOnces; /** * Create a new MMD physics * * Scene must have a physics engine enabled * @param scene The scene to build the physics model */ constructor(scene: Scene); private _convertParameter; private _clampAngularLimit; /** * 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 havok physics engine is not enabled */ buildPhysics(rootMesh: Mesh, bones: readonly IMmdRuntimeBone[], rigidBodies: PmxObject["rigidBodies"], joints: PmxObject["joints"], logger: ILogger, physicsOptions: Nullable): MmdPhysicsModel; private readonly _onAfterPhysics; /** @internal */ _enablePreStepOnce(body: MmdPhysicsBody): void; } export {};