import { Matrix, Quaternion, Vector3 } from "@babylonjs/core/Maths/math.vector"; import type { DeepImmutable, Nullable } from "@babylonjs/core/types"; import type { MmdModelMetadata } from "../Loader/mmdModelMetadata"; import type { AppendTransformSolver } from "./appendTransformSolver"; import type { IkChainInfo } from "./ikChainInfo"; import type { IkSolver } from "./ikSolver"; import type { IMmdRuntimeBone } from "./IMmdRuntimeBone"; import type { IMmdRuntimeLinkedBone } from "./IMmdRuntimeLinkedBone"; /** * Bone for MMD runtime * * For mmd runtime, it is necessary to override the bone system because it has a different implementation than the usual matrix update method * * Which requires the mmd runtime bone, which is the wrapper of the babylon.js bone */ export declare class MmdRuntimeBone implements IMmdRuntimeBone { /** * The Babylon.js bone */ readonly linkedBone: IMmdRuntimeLinkedBone; /** * Name of the bone */ readonly name: string; /** * Parent bone */ parentBone: Nullable; /** * Child bones */ readonly childBones: MmdRuntimeBone[]; /** * Transform order */ readonly transformOrder: number; /** * Bone flag * * @see PmxObject.Bone.Flag */ readonly flag: number; /** * Whether the bone transform is applied after physics */ readonly transformAfterPhysics: boolean; /** * Append transform solver * * If the bone does not have an append transform solver, it will be null */ appendTransformSolver: Nullable; /** * Axis limitation of the bone */ readonly axisLimit: Nullable>; /** * IK solver * * If the bone does not have an ik solver, it will be null */ ikSolver: Nullable; /** * The position offset value to be moved by the bone morph * * This is a field that is primarily updated by the morph controller */ readonly morphPositionOffset: Vector3; /** * The rotation offset value to be moved by the bone morph * * This is a field that is primarily updated by the morph controller */ readonly morphRotationOffset: Quaternion; /** * IK chain bone states * * If this bone is an Ik chain, this value is non-null */ ikChainInfo: Nullable; /** * Rigid body indices * * If the bone does not have a rigid body, it's length is 0 */ readonly rigidBodyIndices: readonly number[]; /** * World matrix of this bone * * Slice of `MmdModel.worldTransformMatrices` that corresponds to this bone */ readonly worldMatrix: Float32Array; /** * Gets the rotation of a local transform with animations and bone morphs applied */ getAnimatedRotationToRef: (target: Quaternion) => Quaternion; /** * Get the position offset of the local transform with animation and bone morph applied * * Refers to the change from the rest position */ getAnimationPositionOffsetToRef: (target: Vector3) => Vector3; /** * Create MMD runtime bone * @param linkedBone Linked Babylon.js bone * @param boneMetadata Bone metadata * @param worldTransformMatrices World transform matrices * @param boneIndex Bone index * @param rigidBodyIndices Rigid body indicies */ constructor(linkedBone: IMmdRuntimeLinkedBone, boneMetadata: MmdModelMetadata.Bone, worldTransformMatrices: Float32Array, boneIndex: number, rigidBodyIndices: readonly number[]); private static readonly _TempAxis; private _getAnimatedRotationToRef; private _getAnimatedRotationWithMorphToRef; private static readonly _TempVector3; private _getAnimationPositionOffsetToRef; private _getAnimationPositionOffsetWithMorphToRef; /** * Allows the animation of this bone to be affected by the `morphPositionOffset` and `morphRotationOffset` fields */ enableMorph(): void; /** * Disables the animation of this bone to be affected by the `morphPositionOffset` and `morphRotationOffset` fields */ disableMorph(): void; /** * Reset world matrix, append transform, and ik chain state * @internal */ resetTransformState(): void; private static readonly _TempRotation; private static readonly _TempPosition; private static readonly _TempPosition2; private static readonly _TempMatrix; private static readonly _TempMatrix2; /** * Update the world matrix of this bone to account for append transform and ik * @param usePhysics Whether to use physics simulation * @param computeIk Whether to compute ik * @internal */ updateWorldMatrix(usePhysics: boolean, computeIk: boolean): void; /** * @internal */ updateIkChainWorldMatrix(): void; private static readonly _WorldMatrixUpdateStack; private _updateWorldMatrixRecursive; /** * Get the world matrix of this bone * * The result of this method is not same as `linkedBone.getFinalMatrix()` * * `linkedBone.getFinalMatrix()` updated at the end of the mmd runtime update, so it may not be the latest value * @param target target matrix * @returns target matrix */ getWorldMatrixToRef(target: Matrix): Matrix; /** * Get the world translation of this bone * @param target target vector * @returns target vector */ getWorldTranslationToRef(target: Vector3): Vector3; /** * Set the world translation of this bone * @param source source vector */ setWorldTranslation(source: DeepImmutable): void; /** * Get ik solver index * * If the bone does not have an ik solver, it will return -1 */ get ikSolverIndex(): number; }