Skip to content

Commit

Permalink
src: Default value for ES6 and clean up. (mrdoob#21971)
Browse files Browse the repository at this point in the history
  • Loading branch information
linbingquan authored Jun 9, 2021
1 parent 2dd9514 commit 69d8a96
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/core/InstancedBufferAttribute.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BufferAttribute } from './BufferAttribute.js';

class InstancedBufferAttribute extends BufferAttribute {

constructor( array, itemSize, normalized, meshPerAttribute ) {
constructor( array, itemSize, normalized, meshPerAttribute = 1 ) {

if ( typeof normalized === 'number' ) {

Expand All @@ -16,7 +16,7 @@ class InstancedBufferAttribute extends BufferAttribute {

super( array, itemSize, normalized );

this.meshPerAttribute = meshPerAttribute || 1;
this.meshPerAttribute = meshPerAttribute;

}

Expand All @@ -30,7 +30,7 @@ class InstancedBufferAttribute extends BufferAttribute {

}

toJSON() {
toJSON() {

const data = super.toJSON();

Expand Down
4 changes: 1 addition & 3 deletions src/extras/Earcut.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

const Earcut = {

triangulate: function ( data, holeIndices, dim ) {

dim = dim || 2;
triangulate: function ( data, holeIndices, dim = 2 ) {

const hasHoles = holeIndices && holeIndices.length;
const outerLen = hasHoles ? holeIndices[ 0 ] * dim : data.length;
Expand Down
4 changes: 1 addition & 3 deletions src/renderers/WebGLRenderTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Vector4 } from '../math/Vector4.js';
*/
class WebGLRenderTarget extends EventDispatcher {

constructor( width, height, options ) {
constructor( width, height, options = {} ) {

super();

Expand All @@ -23,8 +23,6 @@ class WebGLRenderTarget extends EventDispatcher {

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.image = { width: width, height: height, depth: 1 };
Expand Down
4 changes: 1 addition & 3 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ function createCanvasElement() {

}

function WebGLRenderer( parameters ) {

parameters = parameters || {};
function WebGLRenderer( parameters = {} ) {

const _canvas = parameters.canvas !== undefined ? parameters.canvas : createCanvasElement(),
_context = parameters.context !== undefined ? parameters.context : null,
Expand Down
8 changes: 4 additions & 4 deletions src/textures/DataTexture.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { NearestFilter } from '../constants.js';

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 );

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.flipY = false;
Expand Down

0 comments on commit 69d8a96

Please sign in to comment.