From 4392cf14a9d0fc447cd2df82cdeb0e2520c1059c Mon Sep 17 00:00:00 2001 From: Fernando Serrano Date: Fri, 23 Feb 2018 01:59:40 +0100 Subject: [PATCH] GLTFExporter: Add forceIndices --- examples/js/exporters/GLTFExporter.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/js/exporters/GLTFExporter.js b/examples/js/exporters/GLTFExporter.js index 49758cee37..4cb200c6b0 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 -- GitLab