Skip to content

Commit

Permalink
SkeletonHelper: Made getBoneList method private.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Jun 1, 2017
1 parent 83eefab commit 6086329
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 34 deletions.
10 changes: 1 addition & 9 deletions docs/api/helpers/SkeletonHelper.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,7 @@ <h3>[property:Object root]</h3>
<div>
The object passed in the constructor.
</div>

<h2>Methods</h2>

<h3>[method:Array getBoneList]( object )</h3>
<div>
getBoneList -- the object used in the constructor.<br /><br />

This is called automatically to generate a list of bones from the object passed in the constructor.
</div>


<h2>Source</h2>

Expand Down
53 changes: 28 additions & 25 deletions src/helpers/SkeletonHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,29 @@ import { Float32BufferAttribute } from '../core/BufferAttribute';
* @author Mugen87 / https://github.com/Mugen87
*/

function getBoneList( object ) {

var boneList = [];

if ( object && object.isBone ) {

boneList.push( object );

}

for ( var i = 0; i < object.children.length; i ++ ) {

boneList.push.apply( boneList, getBoneList( object.children[ i ] ) );

}

return boneList;

}

function SkeletonHelper( object ) {

this.bones = this.getBoneList( object );
var bones = getBoneList( object );

var geometry = new BufferGeometry();

Expand All @@ -27,9 +47,9 @@ function SkeletonHelper( object ) {
var color1 = new Color( 0, 0, 1 );
var color2 = new Color( 0, 1, 0 );

for ( var i = 0; i < this.bones.length; i ++ ) {
for ( var i = 0; i < bones.length; i ++ ) {

var bone = this.bones[ i ];
var bone = bones[ i ];

if ( bone.parent && bone.parent.isBone ) {

Expand All @@ -50,6 +70,7 @@ function SkeletonHelper( object ) {
LineSegments.call( this, geometry, material );

this.root = object;
this.bones = bones;

this.matrix = object.matrixWorld;
this.matrixAutoUpdate = false;
Expand All @@ -61,26 +82,6 @@ function SkeletonHelper( object ) {
SkeletonHelper.prototype = Object.create( LineSegments.prototype );
SkeletonHelper.prototype.constructor = SkeletonHelper;

SkeletonHelper.prototype.getBoneList = function( object ) {

var boneList = [];

if ( object && object.isBone ) {

boneList.push( object );

}

for ( var i = 0; i < object.children.length; i ++ ) {

boneList.push.apply( boneList, this.getBoneList( object.children[ i ] ) );

}

return boneList;

};

SkeletonHelper.prototype.onBeforeRender = function () {

var vector = new Vector3();
Expand All @@ -90,14 +91,16 @@ SkeletonHelper.prototype.onBeforeRender = function () {

return function onBeforeRender() {

var bones = this.bones;

var geometry = this.geometry;
var position = geometry.getAttribute( 'position' );

matrixWorldInv.getInverse( this.root.matrixWorld );

for ( var i = 0, j = 0; i < this.bones.length; i ++ ) {
for ( var i = 0, j = 0; i < bones.length; i ++ ) {

var bone = this.bones[ i ];
var bone = bones[ i ];

if ( bone.parent && bone.parent.isBone ) {

Expand Down

0 comments on commit 6086329

Please sign in to comment.