File: MMDPhysics.html

package info (click to toggle)
three.js 111%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,184 kB
  • sloc: javascript: 133,174; makefile: 24; sh: 1
file content (114 lines) | stat: -rw-r--r-- 2,993 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<!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="https://github.com/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>

		<p>
			[link:https://github.com/mrdoob/three.js/blob/master/examples/js/animation/MMDPhysics.js examples/js/animation/MMDPhysics.js]
		</p>
	</body>
</html>