Browse Source

Exporters: Unify default options pattern. (#25060)

Michael Herzog 2 years ago
parent
commit
e8a448279e

+ 11 - 9
examples/jsm/exporters/DRACOExporter.js

@@ -16,15 +16,17 @@
 
 class DRACOExporter {
 
-	parse( object, options = {
-		decodeSpeed: 5,
-		encodeSpeed: 5,
-		encoderMethod: DRACOExporter.MESH_EDGEBREAKER_ENCODING,
-		quantization: [ 16, 8, 8, 8, 8 ],
-		exportUvs: true,
-		exportNormals: true,
-		exportColor: false,
-	} ) {
+	parse( object, options = {} ) {
+
+		options = Object.assign( {
+			decodeSpeed: 5,
+			encodeSpeed: 5,
+			encoderMethod: DRACOExporter.MESH_EDGEBREAKER_ENCODING,
+			quantization: [ 16, 8, 8, 8, 8 ],
+			exportUvs: true,
+			exportNormals: true,
+			exportColor: false,
+		}, options );
 
 		if ( DracoEncoderModule === undefined ) {
 

+ 2 - 2
examples/jsm/exporters/GLTFExporter.js

@@ -425,9 +425,9 @@ class GLTFWriter {
 	 * @param  {Function} onDone  Callback on completed
 	 * @param  {Object} options options
 	 */
-	async write( input, onDone, options ) {
+	async write( input, onDone, options = {} ) {
 
-		this.options = Object.assign( {}, {
+		this.options = Object.assign( {
 			// default options
 			binary: false,
 			trs: false,

+ 1 - 1
examples/jsm/exporters/PLYExporter.js

@@ -19,7 +19,7 @@ import {
 
 class PLYExporter {
 
-	parse( object, onDone, options ) {
+	parse( object, onDone, options = {} ) {
 
 		// Iterate over the valid meshes in the object
 		function traverseMeshes( cb ) {

+ 5 - 1
examples/jsm/exporters/STLExporter.js

@@ -13,7 +13,11 @@ class STLExporter {
 
 	parse( scene, options = {} ) {
 
-		const binary = options.binary !== undefined ? options.binary : false;
+		options = Object.assign( {
+			binary: false
+		}, options );
+
+		const binary = options.binary;
 
 		//
 

+ 8 - 1
examples/jsm/exporters/USDZExporter.js

@@ -6,7 +6,14 @@ import * as fflate from '../libs/fflate.module.js';
 
 class USDZExporter {
 
-	async parse( scene, options = { ar: { anchoring: { type: 'plane' }, planeAnchoring: { alignment: 'horizontal' } } } ) {
+	async parse( scene, options = {} ) {
+
+		options = Object.assign( {
+			ar: {
+				anchoring: { type: 'plane' },
+				planeAnchoring: { alignment: 'horizontal' }
+			}
+		}, options );
 
 		const files = {};
 		const modelFileName = 'model.usda';