Skip to content

Commit 97daea3

Browse files
authored
Merge pull request #20840 from linbingquan/dev-es6-defaultvalue
src: ES6 default value.
2 parents 326b83d + 93e1c2e commit 97daea3

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

src/animation/AnimationClip.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { VectorKeyframeTrack } from './tracks/VectorKeyframeTrack.js';
99
import { MathUtils } from '../math/MathUtils.js';
1010
import { NormalAnimationBlendMode } from '../constants.js';
1111

12-
function AnimationClip( name, duration, tracks, blendMode ) {
12+
function AnimationClip( name, duration = - 1, tracks, blendMode = NormalAnimationBlendMode ) {
1313

1414
this.name = name;
1515
this.tracks = tracks;
16-
this.duration = ( duration !== undefined ) ? duration : - 1;
17-
this.blendMode = ( blendMode !== undefined ) ? blendMode : NormalAnimationBlendMode;
16+
this.duration = duration;
17+
this.blendMode = blendMode;
1818

1919
this.uuid = MathUtils.generateUUID();
2020

src/cameras/OrthographicCamera.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Camera } from './Camera.js';
22
import { Object3D } from '../core/Object3D.js';
33

4-
function OrthographicCamera( left, right, top, bottom, near, far ) {
4+
function OrthographicCamera( left = - 1, right = 1, top = 1, bottom = - 1, near = 0.1, far = 2000 ) {
55

66
Camera.call( this );
77

@@ -10,13 +10,13 @@ function OrthographicCamera( left, right, top, bottom, near, far ) {
1010
this.zoom = 1;
1111
this.view = null;
1212

13-
this.left = ( left !== undefined ) ? left : - 1;
14-
this.right = ( right !== undefined ) ? right : 1;
15-
this.top = ( top !== undefined ) ? top : 1;
16-
this.bottom = ( bottom !== undefined ) ? bottom : - 1;
13+
this.left = left;
14+
this.right = right;
15+
this.top = top;
16+
this.bottom = bottom;
1717

18-
this.near = ( near !== undefined ) ? near : 0.1;
19-
this.far = ( far !== undefined ) ? far : 2000;
18+
this.near = near;
19+
this.far = far;
2020

2121
this.updateProjectionMatrix();
2222

src/objects/Line.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const _inverseMatrix = new Matrix4();
1313
const _ray = new Ray();
1414
const _sphere = new Sphere();
1515

16-
function Line( geometry, material, mode ) {
16+
function Line( geometry = new BufferGeometry(), material = new LineBasicMaterial(), mode ) {
1717

1818
if ( mode === 1 ) {
1919

@@ -25,8 +25,8 @@ function Line( geometry, material, mode ) {
2525

2626
this.type = 'Line';
2727

28-
this.geometry = geometry !== undefined ? geometry : new BufferGeometry();
29-
this.material = material !== undefined ? material : new LineBasicMaterial();
28+
this.geometry = geometry;
29+
this.material = material;
3030

3131
this.updateMorphTargets();
3232

src/objects/Mesh.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ const _uvC = new Vector2();
3333
const _intersectionPoint = new Vector3();
3434
const _intersectionPointWorld = new Vector3();
3535

36-
function Mesh( geometry, material ) {
36+
function Mesh( geometry = new BufferGeometry(), material = new MeshBasicMaterial() ) {
3737

3838
Object3D.call( this );
3939

4040
this.type = 'Mesh';
4141

42-
this.geometry = geometry !== undefined ? geometry : new BufferGeometry();
43-
this.material = material !== undefined ? material : new MeshBasicMaterial();
42+
this.geometry = geometry;
43+
this.material = material;
4444

4545
this.updateMorphTargets();
4646

src/objects/Points.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ const _ray = new Ray();
1111
const _sphere = new Sphere();
1212
const _position = new Vector3();
1313

14-
function Points( geometry, material ) {
14+
function Points( geometry = new BufferGeometry(), material = new PointsMaterial() ) {
1515

1616
Object3D.call( this );
1717

1818
this.type = 'Points';
1919

20-
this.geometry = geometry !== undefined ? geometry : new BufferGeometry();
21-
this.material = material !== undefined ? material : new PointsMaterial();
20+
this.geometry = geometry;
21+
this.material = material;
2222

2323
this.updateMorphTargets();
2424

0 commit comments

Comments
 (0)