Prechádzať zdrojové kódy

Added vertex coloring to the bone helper to help illustrate direction.
Fixed the name of the BoneHelper object.

michael 11 rokov pred
rodič
commit
209aab7db7

+ 1 - 1
examples/js/BlendCharacter.js

@@ -36,7 +36,7 @@ THREE.BlendCharacter = function () {
 
 			for ( var i = 0; i < self.skeleton.bones.length; ++i ) {
 
-				var helper = new THREE.BoneAxisHelper( self.skeleton.bones[ i ], 2, 1 );
+				var helper = new THREE.BoneHelper( self.skeleton.bones[ i ], 2, 1 );
 				helper.update();
 				self.add( helper );
 				self.boneHelpers.push( helper );

+ 8 - 6
src/extras/helpers/BoneHelper.js

@@ -3,22 +3,22 @@
  * @author Michael Guerrero / http://realitymeltdown.com
  */
 
-THREE.BoneAxisHelper = function ( bone, baseBoxSize, scaleRatio ) {
+THREE.BoneHelper = function ( bone, jointBoxSize, scaleRatio ) {
 
   THREE.Object3D.call( this );
 
   this.scaleRatio = ( scaleRatio !== undefined ) ? scaleRatio : 1;
   this.bone = bone;
 
-  var baseBoxSize = ( baseBoxSize !== undefined ) ? baseBoxSize : 1;
-  var boxSize = baseBoxSize * this.scaleRatio;
+  var jointBoxSize = ( jointBoxSize !== undefined ) ? jointBoxSize : 1;
+  var boxSize = jointBoxSize * this.scaleRatio;
   var boxGeometry = new THREE.BoxGeometry(boxSize, boxSize, boxSize);
   var boxMaterial = new THREE.MeshBasicMaterial();
 
   this.cube = new THREE.Mesh(boxGeometry, boxMaterial);
   this.add(this.cube);
 
-  this.axes = new THREE.AxisHelper( baseBoxSize * 3 );
+  this.axes = new THREE.AxisHelper( jointBoxSize * 3 );
   this.add( this.axes );
 
   if ( this.bone.parent instanceof THREE.Bone ) {
@@ -28,6 +28,8 @@ THREE.BoneAxisHelper = function ( bone, baseBoxSize, scaleRatio ) {
 
     lineGeometry.vertices.push( new THREE.Vector3() );
     lineGeometry.vertices.push( new THREE.Vector3() );
+    lineGeometry.colors.push( new THREE.Color( 0, 0, 0) );
+    lineGeometry.colors.push( new THREE.Color( 1, 1, 1) );
 
     this.line = new THREE.Line( lineGeometry, lineMaterial );
     this.add(this.line);
@@ -38,9 +40,9 @@ THREE.BoneAxisHelper = function ( bone, baseBoxSize, scaleRatio ) {
 };
 
 
-THREE.BoneAxisHelper.prototype = Object.create( THREE.Object3D.prototype );
+THREE.BoneHelper.prototype = Object.create( THREE.Object3D.prototype );
 
-THREE.BoneAxisHelper.prototype.update = function () {
+THREE.BoneHelper.prototype.update = function () {
 
   if ( this.visible && this.bone.parent instanceof THREE.Bone ) {