Browse Source

GLTFExporter: Better support interleaved data in getMinMax().

Mugen87 4 years ago
parent
commit
a5607c6484
2 changed files with 34 additions and 2 deletions
  1. 17 1
      examples/js/exporters/GLTFExporter.js
  2. 17 1
      examples/jsm/exporters/GLTFExporter.js

+ 17 - 1
examples/js/exporters/GLTFExporter.js

@@ -212,7 +212,23 @@ THREE.GLTFExporter.prototype = {
 
 
 				for ( var a = 0; a < attribute.itemSize; a ++ ) {
 				for ( var a = 0; a < attribute.itemSize; a ++ ) {
 
 
-					var value = attribute.array[ i * attribute.itemSize + a ];
+					var value;
+
+					if ( attribute.itemSize > 4 ) {
+
+						 // no support for interleaved data for itemSize > 4
+
+						value = attribute.array[ i * attribute.itemSize + a ];
+
+					} else {
+
+						if ( a === 0 ) value = attribute.getX( i );
+						else if ( a === 1 ) value = attribute.getY( i );
+						else if ( a === 2 ) value = attribute.getZ( i );
+						else if ( a === 3 ) value = attribute.getW( i );
+
+					}
+
 					output.min[ a ] = Math.min( output.min[ a ], value );
 					output.min[ a ] = Math.min( output.min[ a ], value );
 					output.max[ a ] = Math.max( output.max[ a ], value );
 					output.max[ a ] = Math.max( output.max[ a ], value );
 
 

+ 17 - 1
examples/jsm/exporters/GLTFExporter.js

@@ -235,7 +235,23 @@ GLTFExporter.prototype = {
 
 
 				for ( var a = 0; a < attribute.itemSize; a ++ ) {
 				for ( var a = 0; a < attribute.itemSize; a ++ ) {
 
 
-					var value = attribute.array[ i * attribute.itemSize + a ];
+					var value;
+
+					if ( attribute.itemSize > 4 ) {
+
+						 // no support for interleaved data for itemSize > 4
+
+						value = attribute.array[ i * attribute.itemSize + a ];
+
+					} else {
+
+						if ( a === 0 ) value = attribute.getX( i );
+						else if ( a === 1 ) value = attribute.getY( i );
+						else if ( a === 2 ) value = attribute.getZ( i );
+						else if ( a === 3 ) value = attribute.getW( i );
+
+					}
+
 					output.min[ a ] = Math.min( output.min[ a ], value );
 					output.min[ a ] = Math.min( output.min[ a ], value );
 					output.max[ a ] = Math.max( output.max[ a ], value );
 					output.max[ a ] = Math.max( output.max[ a ], value );