Procházet zdrojové kódy

GLTFExporter: Remove forceIndices.

Mr.doob před 5 roky
rodič
revize
a4db158278

+ 2 - 2
editor/js/Menubar.File.js

@@ -253,10 +253,10 @@ var MenubarFile = function ( editor ) {
 
 			saveArrayBuffer( result, 'scene.glb' );
 
-			// forceIndices: true, forcePowerOfTwoTextures: true
+			// forcePowerOfTwoTextures: true
 			// to allow compatibility with facebook
 
-		}, { binary: true, forceIndices: true, forcePowerOfTwoTextures: true } );
+		}, { binary: true, forcePowerOfTwoTextures: true } );
 
 	} );
 	options.add( option );

+ 0 - 34
examples/js/exporters/GLTFExporter.js

@@ -80,7 +80,6 @@ THREE.GLTFExporter.prototype = {
 			embedImages: true,
 			maxTextureSize: Infinity,
 			animations: [],
-			forceIndices: false,
 			forcePowerOfTwoTextures: false,
 			includeCustomExtensions: false
 		};
@@ -1372,37 +1371,10 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			var forceIndices = options.forceIndices;
 			var isMultiMaterial = Array.isArray( mesh.material );
 
 			if ( isMultiMaterial && geometry.groups.length === 0 ) return null;
 
-			if ( ! forceIndices && geometry.index === null && isMultiMaterial ) {
-
-				// temporal workaround.
-				console.warn( 'THREE.GLTFExporter: Creating index for non-indexed multi-material mesh.' );
-				forceIndices = true;
-
-			}
-
-			var didForceIndices = false;
-
-			if ( geometry.index === null && forceIndices ) {
-
-				var indices = [];
-
-				for ( var i = 0, il = geometry.attributes.position.count; i < il; i ++ ) {
-
-					indices[ i ] = i;
-
-				}
-
-				geometry.setIndex( indices );
-
-				didForceIndices = true;
-
-			}
-
 			var materials = isMultiMaterial ? mesh.material : [ mesh.material ];
 			var groups = isMultiMaterial ? geometry.groups : [ { materialIndex: 0, start: undefined, count: undefined } ];
 
@@ -1454,12 +1426,6 @@ THREE.GLTFExporter.prototype = {
 
 			}
 
-			if ( didForceIndices ) {
-
-				geometry.setIndex( null );
-
-			}
-
 			gltfMesh.primitives = primitives;
 
 			if ( ! outputJSON.meshes ) {

+ 0 - 34
examples/jsm/exporters/GLTFExporter.js

@@ -102,7 +102,6 @@ GLTFExporter.prototype = {
 			embedImages: true,
 			maxTextureSize: Infinity,
 			animations: [],
-			forceIndices: false,
 			forcePowerOfTwoTextures: false,
 			includeCustomExtensions: false
 		};
@@ -1394,37 +1393,10 @@ GLTFExporter.prototype = {
 
 			}
 
-			var forceIndices = options.forceIndices;
 			var isMultiMaterial = Array.isArray( mesh.material );
 
 			if ( isMultiMaterial && geometry.groups.length === 0 ) return null;
 
-			if ( ! forceIndices && geometry.index === null && isMultiMaterial ) {
-
-				// temporal workaround.
-				console.warn( 'THREE.GLTFExporter: Creating index for non-indexed multi-material mesh.' );
-				forceIndices = true;
-
-			}
-
-			var didForceIndices = false;
-
-			if ( geometry.index === null && forceIndices ) {
-
-				var indices = [];
-
-				for ( var i = 0, il = geometry.attributes.position.count; i < il; i ++ ) {
-
-					indices[ i ] = i;
-
-				}
-
-				geometry.setIndex( indices );
-
-				didForceIndices = true;
-
-			}
-
 			var materials = isMultiMaterial ? mesh.material : [ mesh.material ];
 			var groups = isMultiMaterial ? geometry.groups : [ { materialIndex: 0, start: undefined, count: undefined } ];
 
@@ -1476,12 +1448,6 @@ GLTFExporter.prototype = {
 
 			}
 
-			if ( didForceIndices ) {
-
-				geometry.setIndex( null );
-
-			}
-
 			gltfMesh.primitives = primitives;
 
 			if ( ! outputJSON.meshes ) {

+ 0 - 2
examples/misc_exporter_gltf.html

@@ -20,7 +20,6 @@
 			<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><br/>
 			<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>
 			<label><input id="option_forcepot" name="visible" type="checkbox">Force POT textures</label>
 			<label><input id="option_maxsize" name="maxSize" type="number" value="4096" min="2" max="8192" step="1"> Max texture size</label>
 		</div>
@@ -41,7 +40,6 @@
 					onlyVisible: document.getElementById( 'option_visible' ).checked,
 					truncateDrawRange: document.getElementById( 'option_drawrange' ).checked,
 					binary: document.getElementById( 'option_binary' ).checked,
-					forceIndices: document.getElementById( 'option_forceindices' ).checked,
 					forcePowerOfTwoTextures: document.getElementById( 'option_forcepot' ).checked,
 					maxTextureSize: Number( document.getElementById( 'option_maxsize' ).value ) || Infinity // To prevent NaN value
 				};