未验证 提交 90cea0ac 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #13410 from fernandojsg/fixindices

GLTFExporter: Added forceIndices for non-indexed geometry
......@@ -197,9 +197,10 @@ Menubar.File = function ( editor ) {
saveArrayBuffer( result, 'scene.glb' );
}, { binary: true } );
// forceIndices: true to allow compatibility with facebook
// https://github.com/mrdoob/three.js/issues/13397
}, { binary: true, forceIndices: true } );
} );
options.add( option );
......
......@@ -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
......
......@@ -33,6 +33,7 @@
<label><input id="option_visible" name="visible" type="checkbox" checked="checked"/>Only Visible</label>
<label><input id="option_drawrange" name="visible" type="checkbox" checked="checked"/>Truncate drawRange</label>
<label><input id="option_binary" name="visible" type="checkbox">Binary (<code>.glb</code>)</label>
<label><input id="option_forceindices" name="visible" type="checkbox">Force indices</label>
</div>
<script src="../build/three.js"></script>
......@@ -50,7 +51,8 @@
trs: document.getElementById('option_trs').checked,
onlyVisible: document.getElementById('option_visible').checked,
truncateDrawRange: document.getElementById('option_drawrange').checked,
binary: document.getElementById('option_binary').checked
binary: document.getElementById('option_binary').checked,
forceIndices: document.getElementById('option_forceindices').checked
};
gltfExporter.parse( input, function( result ) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册