Browse Source

Simplified .clone()s.

Mr.doob 10 years ago
parent
commit
c66c419832

+ 1 - 2
src/core/BufferGeometry.js

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

+ 1 - 2
src/core/Geometry.js

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

+ 1 - 2
src/core/Object3D.js

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

+ 1 - 2
src/materials/Material.js

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

+ 1 - 2
src/materials/MeshPhongMaterial.js

@@ -169,7 +169,6 @@ THREE.MeshPhongMaterial.prototype.copy = function ( source ) {
 
 THREE.MeshPhongMaterial.prototype.clone = function () {
 
-	var material = new THREE.MeshPhongMaterial();
-	return material.copy( this );
+	return new THREE.MeshPhongMaterial().copy( this );
 
 };

+ 1 - 1
src/math/Color.js

@@ -495,7 +495,7 @@ THREE.Color.prototype = {
 
 	clone: function () {
 
-		return new THREE.Color().setRGB( this.r, this.g, this.b );
+		return new THREE.Color().copy( this );
 
 	}
 

+ 1 - 2
src/textures/Texture.js

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