Browse Source

Merge pull request #6974 from TatumCreative/bones-fix

Fixed bone texture size issue
Mr.doob 10 years ago
parent
commit
ef2794db40
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/objects/Skeleton.js

+ 4 - 3
src/objects/Skeleton.js

@@ -28,9 +28,10 @@ THREE.Skeleton = function ( bones, boneInverses, useVertexTexture ) {
 		//       32x32 pixel texture max  256 bones * 4 pixels = (32 * 32)
 		//       32x32 pixel texture max  256 bones * 4 pixels = (32 * 32)
 		//       64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
 		//       64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)
 
 
-		var size = THREE.Math.nextPowerOfTwo( Math.sqrt( this.bones.length * 4 ) ); // 4 pixels needed for 1 matrix
-
-		if ( size === 0 ) size = 2; // Avoid creating empty texture
+		
+		var size = Math.sqrt( this.bones.length * 4 ); // 4 pixels needed for 1 matrix
+		size = THREE.Math.nextPowerOfTwo( Math.ceil( size ) );
+		size = Math.max( size, 4 );
 
 
 		this.boneTextureWidth = size;
 		this.boneTextureWidth = size;
 		this.boneTextureHeight = size;
 		this.boneTextureHeight = size;