Explorar o código

Merge pull request #20586 from linbingquan/dev-es6-default-value

src: Covert to ES6 default value.
Mr.doob %!s(int64=4) %!d(string=hai) anos
pai
achega
29d6058fba

+ 1 - 3
src/Three.Legacy.js

@@ -112,9 +112,7 @@ export function MeshFaceMaterial( materials ) {
 
 
 }
 }
 
 
-export function MultiMaterial( materials ) {
-
-	if ( materials === undefined ) materials = [];
+export function MultiMaterial( materials = [] ) {
 
 
 	console.warn( 'THREE.MultiMaterial has been removed. Use an Array instead.' );
 	console.warn( 'THREE.MultiMaterial has been removed. Use an Array instead.' );
 	materials.isMultiMaterial = true;
 	materials.isMultiMaterial = true;

+ 2 - 4
src/animation/AnimationUtils.js

@@ -230,11 +230,9 @@ const AnimationUtils = {
 
 
 	},
 	},
 
 
-	makeClipAdditive: function ( targetClip, referenceFrame, referenceClip, fps ) {
+	makeClipAdditive: function ( targetClip, referenceFrame = 0, referenceClip = targetClip, fps = 30 ) {
 
 
-		if ( referenceFrame === undefined ) referenceFrame = 0;
-		if ( referenceClip === undefined ) referenceClip = targetClip;
-		if ( fps === undefined || fps <= 0 ) fps = 30;
+		if ( fps <= 0 ) fps = 30;
 
 
 		const numTracks = referenceClip.tracks.length;
 		const numTracks = referenceClip.tracks.length;
 		const referenceTime = referenceFrame / fps;
 		const referenceTime = referenceFrame / fps;

+ 1 - 3
src/audio/Audio.js

@@ -87,9 +87,7 @@ class Audio extends Object3D {
 
 
 	}
 	}
 
 
-	play( delay ) {
-
-		if ( delay === undefined ) delay = 0;
+	play( delay = 0 ) {
 
 
 		if ( this.isPlaying === true ) {
 		if ( this.isPlaying === true ) {
 
 

+ 1 - 3
src/core/BufferAttribute.js

@@ -278,9 +278,7 @@ Object.assign( BufferAttribute.prototype, {
 
 
 	},
 	},
 
 
-	set: function ( value, offset ) {
-
-		if ( offset === undefined ) offset = 0;
+	set: function ( value, offset = 0 ) {
 
 
 		this.array.set( value, offset );
 		this.array.set( value, offset );
 
 

+ 2 - 6
src/core/Geometry.js

@@ -373,9 +373,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 
 	},
 	},
 
 
-	computeVertexNormals: function ( areaWeighted ) {
-
-		if ( areaWeighted === undefined ) areaWeighted = true;
+	computeVertexNormals: function ( areaWeighted = true ) {
 
 
 		const vertices = new Array( this.vertices.length );
 		const vertices = new Array( this.vertices.length );
 
 
@@ -631,7 +629,7 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 
 	},
 	},
 
 
-	merge: function ( geometry, matrix, materialIndexOffset ) {
+	merge: function ( geometry, matrix, materialIndexOffset = 0 ) {
 
 
 		if ( ! ( geometry && geometry.isGeometry ) ) {
 		if ( ! ( geometry && geometry.isGeometry ) ) {
 
 
@@ -649,8 +647,6 @@ Geometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 			colors1 = this.colors,
 			colors1 = this.colors,
 			colors2 = geometry.colors;
 			colors2 = geometry.colors;
 
 
-		if ( materialIndexOffset === undefined ) materialIndexOffset = 0;
-
 		if ( matrix !== undefined ) {
 		if ( matrix !== undefined ) {
 
 
 			normalMatrix = new Matrix3().getNormalMatrix( matrix );
 			normalMatrix = new Matrix3().getNormalMatrix( matrix );

+ 1 - 3
src/core/InterleavedBuffer.js

@@ -66,9 +66,7 @@ Object.assign( InterleavedBuffer.prototype, {
 
 
 	},
 	},
 
 
-	set: function ( value, offset ) {
-
-		if ( offset === undefined ) offset = 0;
+	set: function ( value, offset = 0 ) {
 
 
 		this.array.set( value, offset );
 		this.array.set( value, offset );
 
 

+ 1 - 3
src/core/Object3D.js

@@ -843,9 +843,7 @@ Object3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 
 
 	},
 	},
 
 
-	copy: function ( source, recursive ) {
-
-		if ( recursive === undefined ) recursive = true;
+	copy: function ( source, recursive = true ) {
 
 
 		this.name = source.name;
 		this.name = source.name;
 
 

+ 2 - 6
src/extras/core/Curve.js

@@ -65,9 +65,7 @@ Object.assign( Curve.prototype, {
 
 
 	// Get sequence of points using getPoint( t )
 	// Get sequence of points using getPoint( t )
 
 
-	getPoints: function ( divisions ) {
-
-		if ( divisions === undefined ) divisions = 5;
+	getPoints: function ( divisions = 5 ) {
 
 
 		const points = [];
 		const points = [];
 
 
@@ -83,9 +81,7 @@ Object.assign( Curve.prototype, {
 
 
 	// Get sequence of points using getPointAt( u )
 	// Get sequence of points using getPointAt( u )
 
 
-	getSpacedPoints: function ( divisions ) {
-
-		if ( divisions === undefined ) divisions = 5;
+	getSpacedPoints: function ( divisions = 5 ) {
 
 
 		const points = [];
 		const points = [];
 
 

+ 1 - 3
src/extras/core/CurvePath.js

@@ -134,9 +134,7 @@ CurvePath.prototype = Object.assign( Object.create( Curve.prototype ), {
 
 
 	},
 	},
 
 
-	getSpacedPoints: function ( divisions ) {
-
-		if ( divisions === undefined ) divisions = 40;
+	getSpacedPoints: function ( divisions = 40 ) {
 
 
 		const points = [];
 		const points = [];
 
 

+ 1 - 3
src/extras/core/Font.js

@@ -12,9 +12,7 @@ Object.assign( Font.prototype, {
 
 
 	isFont: true,
 	isFont: true,
 
 
-	generateShapes: function ( text, size ) {
-
-		if ( size === undefined ) size = 100;
+	generateShapes: function ( text, size = 100 ) {
 
 
 		const shapes = [];
 		const shapes = [];
 		const paths = createPaths( text, size, this.data );
 		const paths = createPaths( text, size, this.data );

+ 3 - 3
src/helpers/PlaneHelper.js

@@ -8,9 +8,9 @@ import { FrontSide, BackSide } from '../constants.js';
 
 
 class PlaneHelper extends Line {
 class PlaneHelper extends Line {
 
 
-	constructor( plane, size, hex ) {
+	constructor( plane, size = 1, hex = 0xffff00 ) {
 
 
-		const color = ( hex !== undefined ) ? hex : 0xffff00;
+		const color = hex;
 
 
 		const positions = [ 1, - 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0 ];
 		const positions = [ 1, - 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, - 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0 ];
 
 
@@ -24,7 +24,7 @@ class PlaneHelper extends Line {
 
 
 		this.plane = plane;
 		this.plane = plane;
 
 
-		this.size = ( size === undefined ) ? 1 : size;
+		this.size = size;
 
 
 		const positions2 = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, - 1, 1, 1, - 1, 1 ];
 		const positions2 = [ 1, 1, 1, - 1, 1, 1, - 1, - 1, 1, 1, 1, 1, - 1, - 1, 1, 1, - 1, 1 ];
 
 

+ 1 - 3
src/lights/PointLightShadow.js

@@ -58,9 +58,7 @@ PointLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype
 
 
 	isPointLightShadow: true,
 	isPointLightShadow: true,
 
 
-	updateMatrices: function ( light, viewportIndex ) {
-
-		if ( viewportIndex === undefined ) viewportIndex = 0;
+	updateMatrices: function ( light, viewportIndex = 0 ) {
 
 
 		const camera = this.camera,
 		const camera = this.camera,
 			shadowMatrix = this.matrix,
 			shadowMatrix = this.matrix,

+ 2 - 6
src/math/Color.js

@@ -300,9 +300,7 @@ class Color {
 
 
 	}
 	}
 
 
-	copyGammaToLinear( color, gammaFactor ) {
-
-		if ( gammaFactor === undefined ) gammaFactor = 2.0;
+	copyGammaToLinear( color, gammaFactor = 2.0 ) {
 
 
 		this.r = Math.pow( color.r, gammaFactor );
 		this.r = Math.pow( color.r, gammaFactor );
 		this.g = Math.pow( color.g, gammaFactor );
 		this.g = Math.pow( color.g, gammaFactor );
@@ -312,9 +310,7 @@ class Color {
 
 
 	}
 	}
 
 
-	copyLinearToGamma( color, gammaFactor ) {
-
-		if ( gammaFactor === undefined ) gammaFactor = 2.0;
+	copyLinearToGamma( color, gammaFactor = 2.0 ) {
 
 
 		const safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;
 		const safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;
 
 

+ 1 - 3
src/objects/LOD.js

@@ -49,9 +49,7 @@ LOD.prototype = Object.assign( Object.create( Object3D.prototype ), {
 
 
 	},
 	},
 
 
-	addLevel: function ( object, distance ) {
-
-		if ( distance === undefined ) distance = 0;
+	addLevel: function ( object, distance = 0 ) {
 
 
 		distance = Math.abs( distance );
 		distance = Math.abs( distance );
 
 

+ 2 - 6
src/renderers/WebGLRenderer.js

@@ -1922,9 +1922,7 @@ function WebGLRenderer( parameters ) {
 
 
 	};
 	};
 
 
-	this.copyFramebufferToTexture = function ( position, texture, level ) {
-
-		if ( level === undefined ) level = 0;
+	this.copyFramebufferToTexture = function ( position, texture, level = 0 ) {
 
 
 		const levelScale = Math.pow( 2, - level );
 		const levelScale = Math.pow( 2, - level );
 		const width = Math.floor( texture.image.width * levelScale );
 		const width = Math.floor( texture.image.width * levelScale );
@@ -1939,9 +1937,7 @@ function WebGLRenderer( parameters ) {
 
 
 	};
 	};
 
 
-	this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level ) {
-
-		if ( level === undefined ) level = 0;
+	this.copyTextureToTexture = function ( position, srcTexture, dstTexture, level = 0 ) {
 
 
 		const width = srcTexture.image.width;
 		const width = srcTexture.image.width;
 		const height = srcTexture.image.height;
 		const height = srcTexture.image.height;