Skip to content
100 changes: 100 additions & 0 deletions docs/examples/animations/CCDIKSolver.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>

<p class="desc"> A solver for IK with <a href="https://sites.google.com/site/auraliusproject/ccd-algorithm"><em>CCD Algorithm</em></a>. <br /><br />
[name] solves Inverse Kinematics Problem with CCD Algorithm.
[name] is designed to work with [page:SkinnedMesh] loaded by [page:MMDLoader] but also can be used for generic [page:SkinnedMesh].
</p>

<h2>Example</h2>

<code>
var ikSolver;

// Load MMD resources and instantiate CCDIKSolver
new THREE.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 );

}
</code>

[example:webgl_loader_mmd]<br />
[example:webgl_loader_mmd_pose]<br />
[example:webgl_loader_mmd_audio]<br />

<br />
<hr>

<h2>Constructor</h2>

<h3>[name]( [param:SkinnedMesh mesh], [param:Array iks] )</h3>
<p>
[page:SkinnedMesh mesh] — [page:SkinnedMesh] for which [name] solves IK problem.<br />
[page:Array iks] — An array of [page: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.<br />
<ul>
<li>[page:Integer target] — Target bone.</li>
<li>[page:Integer effector] — Effector bone.</li>
<li>[page:Array links] — An array of [page: Object] specifying link bones.
<ul>
<li>[page:Integer index] — Link bone.</li>
<li>[page:Vector3 limitation] — (optional) Rotation axis. Default is undefined.</li>
<li>[page:Boolean enabled] — (optional) Default is true.</li>
</ul>
</li>
<li>[page:Integer iteration] — (optional) Iteration number of calculation. Smaller is faster but less precise. Default is 1.</li>
<li>[page:Number minAngle] — (optional) Minimum rotation angle in a step. Default is undefined.</li>
<li>[page:Number maxAngle] — (optional) Maximum rotation angle in a step. Default is undefined.</li>
</ul>
</p>
<p>
Creates a new [name].
</p>

<h2>Properties</h2>

<h3>[property:Array iks]</h3>
<p>An array of IK parameter passed to the constructor.</p>

<h3>[property:SkinnedMesh mesh]</h3>
<p>[page:SkinnedMesh] passed to the constructor.</p>

<h2>Methods</h2>

<h3>[method:CCDIKHelper createHelper]()</h3>
<p>
Return [page:CCDIKHelper]. You can visualize IK bones by adding the helper to scene.
</p>

<h3>[method:CCDIKSolver update]()</h3>
<p>
Update bones quaternion by solving CCD algorithm.
</p>

<h2>Source</h2>

[link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/CCDIKSolver.js examples/js/animation/CCDIKSolver.js]
</body>
</html>
9 changes: 8 additions & 1 deletion docs/examples/animations/MMDAnimationHelper.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>[name]</h1>

<p class="desc"> A animation helper for <a href="http://www.geocities.jp/higuchuu4/index_e.htm"><em>MMD</em></a> resources. <br /><br />
[name] handles animation of MMD assets loaded by [page:MMDLoader] with MMD special features as IK, Grant, and Physics.
It uses [page:CCDIKSolver] and [page:MMDPhysics] inside.
</p>

<h2>Example</h2>
Expand All @@ -31,7 +32,7 @@ <h2>Example</h2>
physics: true
} );

scene.add( mesh );
scene.add( mmd.mesh );

new THREE.AudioLoader().load(
'audios/mmd/song.mp3',
Expand Down Expand Up @@ -97,6 +98,8 @@ <h3>[property:Array meshes]</h3>
<h3>[property:WeakMap objects]</h3>
<p>A [page:WeakMap] which holds animation stuffs used in helper for objects added to helper. For example, you can access [page:AnimationMixer] for an added [page:SkinnedMesh] with "helper.objects.get( mesh ).mixer"</p>

<h3>[property:function onBeforePhysics]</h3>
<p>An optional callback that is executed immediately before the physicis calculation for an [page:SkinnedMesh]. This function is called with the [page:SkinnedMesh].</p>

<h2>Methods</h2>

Expand All @@ -107,6 +110,10 @@ <h3>[method:MMDAnimationHelper add]( [param:Object3D object], [param:Object para
<ul>
<li>[page:AnimationClip animation] - an [page:AnimationClip] or an array of [page:AnimationClip] set to object. Only for [page:SkinnedMesh] and [page:Camera]. Default is undefined.</li>
<li>[page:Boolean physics] - Only for [page:SkinnedMesh]. A flag whether turn on physics. Default is true.</li>
<li>[page:Integer warmup] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is 60.</li>
<li>[page:Number unitStep] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is 1 / 65.</li>
<li>[page:Integer maxStepNum] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is 3.</li>
<li>[page:Vector3 gravity] - Only for [page:SkinnedMesh] and physics is true. Physics parameter. Default is ( 0, - 9.8 * 10, 0 ).</li>
<li>[page:Number delayTime] - Only for [page:Audio]. Default is 0.0.</li>
</ul>
</p>
Expand Down
112 changes: 112 additions & 0 deletions docs/examples/animations/MMDPhysics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<base href="../../" />
<script src="list.js"></script>
<script src="page.js"></script>
<link type="text/css" rel="stylesheet" href="page.css" />
</head>
<body>
<h1>[name]</h1>

<p class="desc"> A Physics handler for <a href="http://www.geocities.jp/higuchuu4/index_e.htm"><em>MMD</em></a> resources. <br /><br />
[name] calculates Physics for model loaded by [page:MMDLoader] with <a href="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/kripken/ammo.js/">ammo.js</a> (Bullet-based JavaScript Physics engine).
</p>

<h2>Example</h2>

<code>
var physics;

// Load MMD resources and instantiate MMDPhysics
new THREE.MMDLoader().load(
'models/mmd/miku.pmd',
function ( mesh ) {

physics = new THREE.MMDPhysics( mesh )
scene.add( mesh );

}
);

function render() {

var delta = clock.getDelta();
animate( delta ); // update bones
if ( physics !== undefined ) physics.update( delta );
renderer.render( scene, camera );

}
</code>

[example:webgl_loader_mmd]<br />
[example:webgl_loader_mmd_audio]<br />

<br />
<hr>

<h2>Constructor</h2>

<h3>[name]( [param:SkinnedMesh mesh], [param:Array rigidBodyParams], [param:Array constraintParams], [param:Object params] )</h3>
<p>
[page:SkinnedMesh mesh] — [page:SkinnedMesh] for which [name] calculates Physics.<br />
[page:Array rigidBodyParams] — An array of [page:Object] specifying Rigid Body parameters.<br />
[page:Array constraintParams] — (optional) An array of [page:Object] specifying Constraint parameters.<br />
[page:Object params] — (optional)<br />
<ul>
<li>[page:Number unitStep] - Default is 1 / 65.</li>
<li>[page:Integer maxStepNum] - Default is 3.</li>
<li>[page:Vector3 gravity] - Default is ( 0, - 9.8 * 10, 0 )</li>
</ul>
</p>
<p>
Creates a new [name].
</p>

<h2>Properties</h2>

<h3>[property:Array mesh]</h3>
<p>[page:SkinnedMesh] passed to the constructor.</p>

<h2>Methods</h2>

<h3>[method:MMDPhysicsHelper createHelper]()</h3>
<p>
Return [page:MMDPhysicsHelper]. You can visualize Rigid bodies by adding the helper to scene.
</p>

<h3>[method:CCDIKSolver reset]()</h3>
<p>
Resets Rigid bodies transorm to current bone's.
</p>

<h3>[method:CCDIKSolver setGravity]( [param:Vector3 gravity] )</h3>
<p>
[page:Vector3 gravity] — Direction and volume of gravity.
</p>
<p>
Set gravity.
</p>

<h3>[method:CCDIKSolver update]( [param:Number delta] )</h3>
<p>
[page:Number delta] — Time in second.
</p>
<p>
Advance Physics calculation and updates bones.
</p>

<h3>[method:CCDIKSolver warmup]( [param:Integer cycles] )</h3>
<p>
[page:Number delta] — Time in second.
</p>
<p>
Warm up Rigid bodies. Calculates cycles steps.
</p>

<h2>Source</h2>

[link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/MMDPhysics.js examples/js/animation/MMDPhysics.js]
</body>
</html>
4 changes: 3 additions & 1 deletion docs/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ var list = {
"Examples": {

"Animations": {
"MMDAnimationHelper": "examples/animations/MMDAnimationHelper"
"CCDIKSolver": "examples/animations/CCDIKSolver",
"MMDAnimationHelper": "examples/animations/MMDAnimationHelper",
"MMDPhysics": "examples/animations/MMDPhysics"
},

"Controls": {
Expand Down
Loading