浏览代码

GLTFExporter: Add forceIndices

Fernando Serrano 7 年之前
父节点
当前提交
6906f9be51
共有 1 个文件被更改,包括 14 次插入1 次删除
  1. 14 1
      examples/js/exporters/GLTFExporter.js

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

@@ -68,7 +68,8 @@ THREE.GLTFExporter.prototype = {
 			onlyVisible: true,
 			onlyVisible: true,
 			truncateDrawRange: true,
 			truncateDrawRange: true,
 			embedImages: true,
 			embedImages: true,
-			animations: []
+			animations: [],
+			forceIndices: false
 		};
 		};
 
 
 		options = Object.assign( {}, DEFAULT_OPTIONS, options );
 		options = Object.assign( {}, DEFAULT_OPTIONS, options );
@@ -809,6 +810,18 @@ THREE.GLTFExporter.prototype = {
 
 
 				gltfMesh.primitives[ 0 ].indices = processAccessor( geometry.index, geometry );
 				gltfMesh.primitives[ 0 ].indices = processAccessor( geometry.index, geometry );
 
 
+			} else if ( options.forceIndices ) {
+
+				var numFaces = geometry.attributes.position.count;
+				var indices = new Uint32Array( numFaces );
+				for ( var i = 0; i < numFaces; i ++ ) {
+
+					indices[ i ] = i;
+
+				}
+
+				gltfMesh.primitives[ 0 ].indices = processAccessor( new THREE.Uint32BufferAttribute( indices, 1 ), geometry );
+
 			}
 			}
 
 
 			// We've just one primitive per mesh
 			// We've just one primitive per mesh