diff --git a/examples/js/exporters/GLTFExporter.js b/examples/js/exporters/GLTFExporter.js index 49758cee376710a7039ee6bd066d7eabf6c391b0..4cb200c6b02b6ac0b868943859a96defc476b0a9 100644 --- a/examples/js/exporters/GLTFExporter.js +++ b/examples/js/exporters/GLTFExporter.js @@ -68,7 +68,8 @@ THREE.GLTFExporter.prototype = { onlyVisible: true, truncateDrawRange: true, embedImages: true, - animations: [] + animations: [], + forceIndices: false }; options = Object.assign( {}, DEFAULT_OPTIONS, options ); @@ -809,6 +810,18 @@ THREE.GLTFExporter.prototype = { 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