Browse Source

src: Default value for ES6 and clean up. (#21971)

linbingquan 4 years ago
parent
commit
69d8a96184

+ 3 - 3
src/core/InstancedBufferAttribute.js

@@ -2,7 +2,7 @@ import { BufferAttribute } from './BufferAttribute.js';
 
 
 class InstancedBufferAttribute extends BufferAttribute {
 class InstancedBufferAttribute extends BufferAttribute {
 
 
-	constructor( array, itemSize, normalized, meshPerAttribute ) {
+	constructor( array, itemSize, normalized, meshPerAttribute = 1 ) {
 
 
 		if ( typeof normalized === 'number' ) {
 		if ( typeof normalized === 'number' ) {
 
 
@@ -16,7 +16,7 @@ class InstancedBufferAttribute extends BufferAttribute {
 
 
 		super( array, itemSize, normalized );
 		super( array, itemSize, normalized );
 
 
-		this.meshPerAttribute = meshPerAttribute || 1;
+		this.meshPerAttribute = meshPerAttribute;
 
 
 	}
 	}
 
 
@@ -30,7 +30,7 @@ class InstancedBufferAttribute extends BufferAttribute {
 
 
 	}
 	}
 
 
-	toJSON()	{
+	toJSON() {
 
 
 		const data = super.toJSON();
 		const data = super.toJSON();
 
 

+ 1 - 3
src/extras/Earcut.js

@@ -4,9 +4,7 @@
 
 
 const Earcut = {
 const Earcut = {
 
 
-	triangulate: function ( data, holeIndices, dim ) {
-
-		dim = dim || 2;
+	triangulate: function ( data, holeIndices, dim = 2 ) {
 
 
 		const hasHoles = holeIndices && holeIndices.length;
 		const hasHoles = holeIndices && holeIndices.length;
 		const outerLen = hasHoles ? holeIndices[ 0 ] * dim : data.length;
 		const outerLen = hasHoles ? holeIndices[ 0 ] * dim : data.length;

+ 1 - 3
src/renderers/WebGLRenderTarget.js

@@ -10,7 +10,7 @@ import { Vector4 } from '../math/Vector4.js';
 */
 */
 class WebGLRenderTarget extends EventDispatcher {
 class WebGLRenderTarget extends EventDispatcher {
 
 
-	constructor( width, height, options ) {
+	constructor( width, height, options = {} ) {
 
 
 		super();
 		super();
 
 
@@ -23,8 +23,6 @@ class WebGLRenderTarget extends EventDispatcher {
 
 
 		this.viewport = new Vector4( 0, 0, width, height );
 		this.viewport = new Vector4( 0, 0, width, height );
 
 
-		options = options || {};
-
 		this.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
 		this.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );
 
 
 		this.texture.image = { width: width, height: height, depth: 1 };
 		this.texture.image = { width: width, height: height, depth: 1 };

+ 1 - 3
src/renderers/WebGLRenderer.js

@@ -54,9 +54,7 @@ function createCanvasElement() {
 
 
 }
 }
 
 
-function WebGLRenderer( parameters ) {
-
-	parameters = parameters || {};
+function WebGLRenderer( parameters = {} ) {
 
 
 	const _canvas = parameters.canvas !== undefined ? parameters.canvas : createCanvasElement(),
 	const _canvas = parameters.canvas !== undefined ? parameters.canvas : createCanvasElement(),
 		_context = parameters.context !== undefined ? parameters.context : null,
 		_context = parameters.context !== undefined ? parameters.context : null,

+ 4 - 4
src/textures/DataTexture.js

@@ -3,14 +3,14 @@ import { NearestFilter } from '../constants.js';
 
 
 class DataTexture extends Texture {
 class DataTexture extends Texture {
 
 
-	constructor( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {
+	constructor( data = null, width = 1, height = 1, format, type, mapping, wrapS, wrapT, magFilter = NearestFilter, minFilter = NearestFilter, anisotropy, encoding ) {
 
 
 		super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
 		super( null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );
 
 
-		this.image = { data: data || null, width: width || 1, height: height || 1 };
+		this.image = { data: data, width: width, height: height };
 
 
-		this.magFilter = magFilter !== undefined ? magFilter : NearestFilter;
-		this.minFilter = minFilter !== undefined ? minFilter : NearestFilter;
+		this.magFilter = magFilter;
+		this.minFilter = minFilter;
 
 
 		this.generateMipmaps = false;
 		this.generateMipmaps = false;
 		this.flipY = false;
 		this.flipY = false;