Procházet zdrojové kódy

GLTFExporter: Ensure joints are uint8 or uint16.

Don McCurdy před 7 roky
rodič
revize
655fc342d4
1 změnil soubory, kde provedl 11 přidání a 0 odebrání
  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 ];
 				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' ) {
 
 					attributes[ attributeName ] = processAccessor( attribute, geometry );