Skip to content

Commit 8d3f1ce

Browse files
committed
Prefer one-line constructor+copy in clone methods
1 parent 9a9d73d commit 8d3f1ce

22 files changed

Lines changed: 22 additions & 44 deletions

src/cameras/Camera.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ THREE.Camera.prototype.lookAt = function () {
5252

5353
THREE.Camera.prototype.clone = function () {
5454

55-
var camera = new this.constructor();
56-
return camera.copy( this );
55+
return new this.constructor().copy( this );
5756

5857
};
5958

src/core/BufferGeometry.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,8 +1241,7 @@ THREE.BufferGeometry.prototype = {
12411241

12421242
clone: function () {
12431243

1244-
var bufferGeometry = new this.constructor();
1245-
return bufferGeometry.copy( this );
1244+
return new this.constructor().copy( this );
12461245

12471246
},
12481247

src/core/Face3.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ THREE.Face3.prototype = {
2727

2828
clone: function () {
2929

30-
var face = new this.constructor();
31-
return face.copy( this );
30+
return new this.constructor().copy( this );
3231

3332
},
3433

src/core/Geometry.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,8 +1174,7 @@ THREE.Geometry.prototype = {
11741174

11751175
clone: function () {
11761176

1177-
var geometry = new this.constructor();
1178-
return geometry.copy( this );
1177+
return new this.constructor().copy( this );
11791178

11801179
},
11811180

src/core/Object3D.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,7 @@ THREE.Object3D.prototype = {
675675

676676
clone: function ( recursive ) {
677677

678-
var object = new this.constructor();
679-
return object.copy( this, recursive );
678+
return new this.constructor().copy( this, recursive );
680679

681680
},
682681

src/materials/Material.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,7 @@ THREE.Material.prototype = {
172172

173173
clone: function () {
174174

175-
var material = new this.constructor();
176-
return material.copy( this );
175+
return new this.constructor().copy( this );
177176

178177
},
179178

src/math/Box2.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ THREE.Box2.prototype = {
5454

5555
clone: function () {
5656

57-
var box = new this.constructor();
58-
return box.copy( this );
57+
return new this.constructor().copy( this );
5958

6059
},
6160

src/math/Box3.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,7 @@ THREE.Box3.prototype = {
117117

118118
clone: function () {
119119

120-
var box = new this.constructor();
121-
return box.copy( this );
120+
return new this.constructor().copy( this );
122121

123122
},
124123

src/math/Frustum.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ THREE.Frustum.prototype = {
4040

4141
clone: function () {
4242

43-
var frustum = new this.constructor();
44-
return frustum.copy( this );
43+
return new this.constructor().copy( this );
4544

4645
},
4746

src/math/Line3.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ THREE.Line3.prototype = {
2424

2525
clone: function () {
2626

27-
var line = new this.constructor();
28-
return line.copy( this );
27+
return new this.constructor().copy( this );
2928

3029
},
3130

0 commit comments

Comments
 (0)