import { Matrix, Vector3 } from "@babylonjs/core/Maths/math.vector"; import type { DeepImmutable, Nullable } from "@babylonjs/core/types"; import type { MmdModelMetadata } from "../../Loader/mmdModelMetadata"; import type { IMmdRuntimeBone } from "../IMmdRuntimeBone"; import type { IMmdRuntimeLinkedBone } from "../IMmdRuntimeLinkedBone"; import { type WasmBufferedArray } from "./Misc/wasmBufferedArray"; import type { IMmdWasmInstance } from "./mmdWasmInstance"; import type { MmdWasmRuntime } from "./mmdWasmRuntime"; /** * Bone for MMD WASM runtime * * For mmd wasm 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 wasm runtime bone, which is the wrapper of the babylon.js bone */ export declare class MmdWasmRuntimeBone implements IMmdRuntimeBone { /** * The Babylon.js bone */ readonly linkedBone: IMmdRuntimeLinkedBone; /** * Name of the bone */ readonly name: string; /** * Parent bone */ parentBone: Nullable; /** * Child bones */ readonly childBones: IMmdRuntimeBone[]; /** * 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; private readonly _worldMatrix; /** * World matrix of this bone * * Slice of `MmdModel.worldTransformMatrices` that corresponds to this bone * * This array reference should not be copied elsewhere and must be read and written with minimal scope */ get worldMatrix(): Float32Array; /** * Rigid body indices * * If the bone does not have a rigid body, it's length is 0 */ readonly rigidBodyIndices: readonly number[]; /** * Get ik solver index * * If the bone does not have an ik solver, it will return -1 */ readonly ikSolverIndex: number; /** * Create MMD WASM runtime bone * @param linkedBone Linked Babylon.js bone * @param boneMetadata Bone metadata * @param worldTransformMatrices WASM buffered array of world transform matrices * @param boneIndex Bone index * @param rigidBodyIndices Readonly linked RigidBody indices * @param ikSolverIndex IK solver index * @param mmdRuntime MMD WASM runtime * @param mmdModelPtr MMD WASM side model pointer */ constructor(linkedBone: IMmdRuntimeLinkedBone, boneMetadata: MmdModelMetadata.Bone, worldTransformMatrices: WasmBufferedArray, boneIndex: number, rigidBodyIndices: readonly number[], ikSolverIndex: number, mmdRuntime: MmdWasmRuntime); /** * @internal * @param wasmInstance MMD WASM instance */ updateBackBufferReference(wasmInstance: IMmdWasmInstance): void; /** * 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; }