From 209aab7db7b7862bfa29c2f9bb680108e0e3b360 Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 9 Apr 2014 09:03:42 -0700 Subject: [PATCH] Added vertex coloring to the bone helper to help illustrate direction. Fixed the name of the BoneHelper object. --- examples/js/BlendCharacter.js | 2 +- src/extras/helpers/BoneHelper.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/examples/js/BlendCharacter.js b/examples/js/BlendCharacter.js index 8f7b994a00..933ffc77b7 100644 --- a/examples/js/BlendCharacter.js +++ b/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 ); diff --git a/src/extras/helpers/BoneHelper.js b/src/extras/helpers/BoneHelper.js index f061e383c9..8fec97dc94 100644 --- a/src/extras/helpers/BoneHelper.js +++ b/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 ) { -- GitLab