Browse Source

Add includeCustomExtensions option.

Robert Long 7 years ago
parent
commit
304cd6e1e3

+ 1 - 0
docs/examples/exporters/GLTFExporter.html

@@ -84,6 +84,7 @@
 			<li>animations - Array<[page:AnimationClip AnimationClip]>. List of animations to be included in the export.</li>
 			<li>forceIndices - bool. Generate indices for non-index geometry and export with them. Default is false.</li>
 			<li>forcePowerOfTwoTextures - bool. Export with images resized to POT size. This option works only if embedImages is true. Default is false.</li>
+			<li>includeCustomExtensions - bool. Export custom glTF extensions defined on an object's <em>userData.gltfExtensions<em> property. Default is false.</li>
 		</ul>
 		</p>
 		<p>

+ 5 - 4
examples/js/exporters/GLTFExporter.js

@@ -73,7 +73,8 @@ THREE.GLTFExporter.prototype = {
 			embedImages: true,
 			animations: [],
 			forceIndices: false,
-			forcePowerOfTwoTextures: false
+			forcePowerOfTwoTextures: false,
+			includeCustomExtensions: false
 		};
 
 		options = Object.assign( {}, DEFAULT_OPTIONS, options );
@@ -345,7 +346,7 @@ THREE.GLTFExporter.prototype = {
 
 				var json = JSON.parse( JSON.stringify( object.userData ) );
 
-				if ( json.gltfExtensions ) {
+				if ( options.includeCustomExtensions && json.gltfExtensions ) {
 
 					if ( gltfProperty.extensions === undefined ) {
 
@@ -360,10 +361,10 @@ THREE.GLTFExporter.prototype = {
 
 					}
 
-					delete json.gltfExtensions;
-
 				}
 
+				delete json.gltfExtensions;
+
 				if ( Object.keys( json ).length > 0 ) {
 
 					gltfProperty.extras = json;