瀏覽代碼

Merge pull request #13609 from donmccurdy/bug-gltfexporter-uint-joints

GLTFExporter: Ensure joints are uint8 or uint16.
Mr.doob 7 年之前
父節點
當前提交
40cf507651
共有 1 個文件被更改,包括 11 次插入0 次删除
  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.
+				var array = attribute.array;
+				if ( attributeName === 'JOINTS_0' &&
+					! ( array instanceof Uint16Array ) &&
+					! ( array instanceof Uint8Array ) ) {
+
+					console.warn( 'GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.' );
+					attribute = new THREE.BufferAttribute( new Uint16Array( array ), attribute.itemSize, attribute.normalized );
+
+				}
+
 				if ( attributeName.substr( 0, 5 ) !== 'MORPH' ) {
 
 					attributes[ attributeName ] = processAccessor( attribute, geometry );