Browse Source

Prefer one-line constructor+copy in clone methods

Daniel Hritzkiv 10 years ago
parent
commit
8d3f1ce652

+ 1 - 2
src/cameras/Camera.js

@@ -52,8 +52,7 @@ THREE.Camera.prototype.lookAt = function () {
 
 THREE.Camera.prototype.clone = function () {
 
-	var camera = new this.constructor();
-	return camera.copy( this );
+	return new this.constructor().copy( this );
 
 };
 

+ 1 - 2
src/core/BufferGeometry.js

@@ -1241,8 +1241,7 @@ THREE.BufferGeometry.prototype = {
 
 	clone: function () {
 
-		var bufferGeometry = new this.constructor();
-		return bufferGeometry.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/core/Face3.js

@@ -27,8 +27,7 @@ THREE.Face3.prototype = {
 
 	clone: function () {
 
-		var face = new this.constructor();
-		return face.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/core/Geometry.js

@@ -1174,8 +1174,7 @@ THREE.Geometry.prototype = {
 
 	clone: function () {
 
-		var geometry = new this.constructor();
-		return geometry.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/core/Object3D.js

@@ -675,8 +675,7 @@ THREE.Object3D.prototype = {
 
 	clone: function ( recursive ) {
 
-		var object = new this.constructor();
-		return object.copy( this, recursive );
+		return new this.constructor().copy( this, recursive );
 
 	},
 

+ 1 - 2
src/materials/Material.js

@@ -172,8 +172,7 @@ THREE.Material.prototype = {
 
 	clone: function () {
 
-		var material = new this.constructor();
-		return material.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/math/Box2.js

@@ -54,8 +54,7 @@ THREE.Box2.prototype = {
 	
 	clone: function () {
 
-		var box = new this.constructor();
-		return box.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/math/Box3.js

@@ -117,8 +117,7 @@ THREE.Box3.prototype = {
 
 	clone: function () {
 
-		var box = new this.constructor();
-		return box.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/math/Frustum.js

@@ -40,8 +40,7 @@ THREE.Frustum.prototype = {
 
 	clone: function () {
 
-		var frustum = new this.constructor();
-		return frustum.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/math/Line3.js

@@ -24,8 +24,7 @@ THREE.Line3.prototype = {
 
 	clone: function () {
 
-		var line = new this.constructor();
-		return line.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/math/Matrix3.js

@@ -54,8 +54,7 @@ THREE.Matrix3.prototype = {
 
 	clone: function () {
 
-		var matrix = new this.constructor();
-		return matrix.fromArray( this.elements );
+		return new this.constructor().fromArray( this.elements );
 
 	},
 

+ 1 - 2
src/math/Plane.js

@@ -61,8 +61,7 @@ THREE.Plane.prototype = {
 
 	clone: function () {
 
-		var plane = new this.constructor();
-		return plane.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/math/Ray.js

@@ -24,8 +24,7 @@ THREE.Ray.prototype = {
 
 	clone: function () {
 
-		var ray = new this.constructor();
-		return ray.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/math/Sphere.js

@@ -59,8 +59,7 @@ THREE.Sphere.prototype = {
 
 	clone: function () {
 
-		var sphere = new this.constructor();
-		return sphere.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/math/Triangle.js

@@ -120,8 +120,7 @@ THREE.Triangle.prototype = {
 
 	clone: function () {
 
-		var triangle = new this.constructor();
-		return triangle.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/objects/Line.js

@@ -185,8 +185,7 @@ THREE.Line.prototype.raycast = ( function () {
 
 THREE.Line.prototype.clone = function () {
 
-	var line = new this.constructor( this.geometry, this.material );
-	return line.copy( this );
+	return new this.constructor( this.geometry, this.material ).copy( this );
 
 };
 

+ 1 - 2
src/objects/Mesh.js

@@ -307,8 +307,7 @@ THREE.Mesh.prototype.raycast = ( function () {
 
 THREE.Mesh.prototype.clone = function () {
 
-	var mesh = new this.constructor( this.geometry, this.material );
-	return mesh.copy( this );
+	return new this.constructor( this.geometry, this.material ).copy( this );
 
 };
 

+ 1 - 2
src/objects/PointCloud.js

@@ -138,8 +138,7 @@ THREE.PointCloud.prototype.raycast = ( function () {
 
 THREE.PointCloud.prototype.clone = function () {
 
-	var pointCloud = new this.constructor( this.geometry, this.material );
-	return pointCloud.copy( this );
+	return new this.constructor( this.geometry, this.material ).copy( this );
 
 };
 

+ 1 - 2
src/objects/SkinnedMesh.js

@@ -145,7 +145,6 @@ THREE.SkinnedMesh.prototype.updateMatrixWorld = function( force ) {
 
 THREE.SkinnedMesh.prototype.clone = function() {
 
-	var skinMesh = new this.constructor( this.geometry, this.material, this.useVertexTexture );
-	return skinMesh.copy( this );
+	return new this.constructor( this.geometry, this.material, this.useVertexTexture ).copy( this );
 
 };

+ 1 - 2
src/objects/Sprite.js

@@ -62,8 +62,7 @@ THREE.Sprite.prototype.raycast = ( function () {
 
 THREE.Sprite.prototype.clone = function () {
 
-	var sprite = new this.constructor( this.material );
-	return sprite.copy( this );
+	return new this.constructor( this.material ).copy( this );
 
 };
 

+ 1 - 2
src/renderers/WebGLRenderTarget.js

@@ -54,8 +54,7 @@ THREE.WebGLRenderTarget.prototype = {
 
 	clone: function () {
 
-		var renderTarget = new this.constructor();
-		return renderTarget.copy( this );
+		return new this.constructor().copy( this );
 
 	},
 

+ 1 - 2
src/textures/Texture.js

@@ -57,8 +57,7 @@ THREE.Texture.prototype = {
 
 	clone: function () {
 
-		var texture = new this.constructor();
-		return texture.copy( this );
+		return new this.constructor().copy( this );
 
 	},