CCDIKSolver

优质
小牛编辑
129浏览
2023-12-01

A solver for IK with CCD Algorithm.

CCDIKSolver solves Inverse Kinematics Problem with CCD Algorithm. CCDIKSolver is designed to work with SkinnedMesh loaded by MMDLoader but also can be used for generic SkinnedMesh.

代码示例

const ikSolver;
// Load MMD resources and instantiate CCDIKSolver
new MMDLoader().load(
  'models/mmd/miku.pmd',
  function ( mesh ) {
    ikSolver = new CCDIKSolver( mesh, mesh.geometry.iks );
    scene.add( mesh );
  }
);
function render() {
  animate(); // update bones
  if ( ikSolver !== undefined ) ikSolver.update();
  renderer.render( scene, camera );
}

例子

webgl_loader_mmd
webgl_loader_mmd_pose
webgl_loader_mmd_audio

Constructor

CCDIKSolver( mesh : SkinnedMesh, iks : Array )

meshSkinnedMesh for which CCDIKSolver solves IK problem.
iks — An array of Object specifying IK parameter. target, effector, and link-index are index integers in .skeleton.bones. The bones relation should be "links[ n ], links[ n - 1 ], ..., links[ 0 ], effector" in order from parent to child.

  • target — Target bone.
  • effector — Effector bone.
  • links — An array of [page: Object] specifying link bones.
    • index — Link bone.
    • limitation — (optional) Rotation axis. Default is undefined.
    • rotationMin — (optional) Rotation minimum limit. Default is undefined.
    • rotationMax — (optional) Rotation maximum limit. Default is undefined.
    • enabled — (optional) Default is true.
  • iteration — (optional) Iteration number of calculation. Smaller is faster but less precise. Default is 1.
  • minAngle — (optional) Minimum rotation angle in a step. Default is undefined.
  • maxAngle — (optional) Maximum rotation angle in a step. Default is undefined.

Creates a new CCDIKSolver.

Properties

.iks : Array

An array of IK parameter passed to the constructor.

.mesh : SkinnedMesh

SkinnedMesh passed to the constructor.

Methods

.createHelper () : CCDIKHelper

Return CCDIKHelper. You can visualize IK bones by adding the helper to scene.

.update () : CCDIKSolver

Update bones quaternion by solving CCD algorithm.

.updateOne ( ikParam : Object ) : CCDIKSolver

Update an IK bone quaternion by solving CCD algorithm.

Source

examples/jsm/animation/CCDIKSolver.js