Browse Source

GLTFExporter: Ensure joints are uint8 or uint16.

Don McCurdy 7 years ago
parent
commit
655fc342d4
1 changed files with 11 additions and 0 deletions
  1. 11 0
      examples/js/exporters/GLTFExporter.js

+ 11 - 0
examples/js/exporters/GLTFExporter.js

@@ -926,6 +926,17 @@ THREE.GLTFExporter.prototype = {
 				var attribute = geometry.attributes[ attributeName ];
 				var attribute = geometry.attributes[ attributeName ];
 				attributeName = nameConversion[ attributeName ] || attributeName.toUpperCase();
 				attributeName = nameConversion[ attributeName ] || attributeName.toUpperCase();
 
 
+				// JOINTS_0 must be UNSIGNED_BYTE or UNSIGNED_SHORT.
+				if ( attributeName === 'JOINTS_0' &&
+						! ( attribute instanceof THREE.Uint16BufferAttribute ) &&
+						! ( attribute instanceof THREE.Uint8BufferAttribute ) ) {
+
+					console.warn( 'GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.' );
+
+					attribute = new THREE.Uint16BufferAttribute( attribute.array, attribute.itemSize, attribute.normalized );
+
+				}
+
 				if ( attributeName.substr( 0, 5 ) !== 'MORPH' ) {
 				if ( attributeName.substr( 0, 5 ) !== 'MORPH' ) {
 
 
 					attributes[ attributeName ] = processAccessor( attribute, geometry );
 					attributes[ attributeName ] = processAccessor( attribute, geometry );