Browse Source

Updated clone + copy methods; rearranged methods; fix CubeTexture's clone method

- Better inheriting of `clone` + `copy` methods where appropriate. This is done by calling `new this.constructor()` in parent classes. `this.constructor` refers to the current instance's constructor, so it should all compose nicely;

- Pass in attributes directly as arguments to constructor when cloning, where appropriate (if arguments pattern is different from parent class). This mean `copy` isn't relied on to set those attributes.

- Change order of `clone` in some files (for better visibility into its relationship with `copy`, and to maintain consistency; can return to previous order if necessary);

- Fix CubeTexture's clone method
Daniel Hritzkiv 10 years ago
parent
commit
ba65769db7
65 changed files with 340 additions and 553 deletions
  1. 1 1
      src/cameras/Camera.js
  2. 11 14
      src/cameras/OrthographicCamera.js
  3. 11 11
      src/cameras/PerspectiveCamera.js
  4. 1 1
      src/core/BufferAttribute.js
  5. 2 1
      src/core/BufferGeometry.js
  6. 1 7
      src/core/DynamicBufferAttribute.js
  7. 7 6
      src/core/Face3.js
  8. 2 1
      src/core/Geometry.js
  9. 10 12
      src/core/InstancedBufferGeometry.js
  10. 1 1
      src/core/InstancedInterleavedBuffer.js
  11. 1 1
      src/core/InterleavedBuffer.js
  12. 2 1
      src/core/Object3D.js
  13. 0 10
      src/lights/AmbientLight.js
  14. 16 12
      src/lights/AreaLight.js
  15. 22 26
      src/lights/DirectionalLight.js
  16. 2 8
      src/lights/HemisphereLight.js
  17. 3 12
      src/lights/Light.js
  18. 2 9
      src/lights/PointLight.js
  19. 20 28
      src/lights/SpotLight.js
  20. 9 11
      src/materials/LineBasicMaterial.js
  21. 9 13
      src/materials/LineDashedMaterial.js
  22. 2 1
      src/materials/Material.js
  23. 24 26
      src/materials/MeshBasicMaterial.js
  24. 5 7
      src/materials/MeshDepthMaterial.js
  25. 1 1
      src/materials/MeshFaceMaterial.js
  26. 22 24
      src/materials/MeshLambertMaterial.js
  27. 5 7
      src/materials/MeshNormalMaterial.js
  28. 0 6
      src/materials/MeshPhongMaterial.js
  29. 10 12
      src/materials/PointCloudMaterial.js
  30. 1 11
      src/materials/RawShaderMaterial.js
  31. 0 7
      src/materials/ShaderMaterial.js
  32. 7 9
      src/materials/SpriteMaterial.js
  33. 7 6
      src/math/Box2.js
  34. 7 6
      src/math/Box3.js
  35. 6 6
      src/math/Color.js
  36. 7 7
      src/math/Euler.js
  37. 7 6
      src/math/Frustum.js
  38. 7 6
      src/math/Line3.js
  39. 7 6
      src/math/Matrix3.js
  40. 6 6
      src/math/Matrix4.js
  41. 6 6
      src/math/Plane.js
  42. 7 7
      src/math/Quaternion.js
  43. 7 6
      src/math/Ray.js
  44. 7 6
      src/math/Sphere.js
  45. 7 6
      src/math/Triangle.js
  46. 6 6
      src/math/Vector2.js
  47. 6 6
      src/math/Vector3.js
  48. 6 6
      src/math/Vector4.js
  49. 2 11
      src/objects/Bone.js
  50. 1 15
      src/objects/Group.js
  51. 0 8
      src/objects/LOD.js
  52. 0 7
      src/objects/LensFlare.js
  53. 1 8
      src/objects/Line.js
  54. 0 10
      src/objects/LineSegments.js
  55. 1 8
      src/objects/Mesh.js
  56. 2 9
      src/objects/MorphAnimMesh.js
  57. 1 8
      src/objects/PointCloud.js
  58. 1 8
      src/objects/SkinnedMesh.js
  59. 1 8
      src/objects/Sprite.js
  60. 7 6
      src/renderers/WebGLRenderTarget.js
  61. 0 7
      src/scenes/Scene.js
  62. 0 10
      src/textures/CompressedTexture.js
  63. 4 9
      src/textures/CubeTexture.js
  64. 1 11
      src/textures/DataTexture.js
  65. 2 15
      src/textures/Texture.js

+ 1 - 1
src/cameras/Camera.js

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

+ 11 - 14
src/cameras/OrthographicCamera.js

@@ -38,22 +38,19 @@ THREE.OrthographicCamera.prototype.updateProjectionMatrix = function () {
 
 THREE.OrthographicCamera.prototype.clone = function () {
 
-	var camera = new THREE.OrthographicCamera();
+	var camera = new this.constructor( this.left, this.right, this.top, this.bottom, this.near, this.far );
+	return camera.copy( this );
 
-	camera.copy( this );
-
-	camera.zoom = this.zoom;
-
-	camera.left = this.left;
-	camera.right = this.right;
-	camera.top = this.top;
-	camera.bottom = this.bottom;
-
-	camera.near = this.near;
-	camera.far = this.far;
-
-	return camera;
+};
 
+THREE.OrthographicCamera.prototype.copy = function ( source ) {
+	
+	THREE.Camera.prototype.copy.call( this, source );
+	
+	this.zoom = source.zoom;
+	
+	return this;
+		
 };
 
 THREE.OrthographicCamera.prototype.toJSON = function ( meta ) {

+ 11 - 11
src/cameras/PerspectiveCamera.js

@@ -124,19 +124,19 @@ THREE.PerspectiveCamera.prototype.updateProjectionMatrix = function () {
 
 THREE.PerspectiveCamera.prototype.clone = function () {
 
-	var camera = new THREE.PerspectiveCamera();
+	var camera = new this.constructor( this.fov, this.aspect, this.near, this.far );
+	return camera.copy( this );
 
-	camera.copy( this );
-
-	camera.zoom = this.zoom;
-
-	camera.fov = this.fov;
-	camera.aspect = this.aspect;
-	camera.near = this.near;
-	camera.far = this.far;
-
-	return camera;
+};
 
+THREE.PerspectiveCamera.prototype.copy = function ( source ) {
+	
+	THREE.Camera.prototype.copy.call( this, source );
+	
+	this.zoom = source.zoom;
+	
+	return this;
+		
 };
 
 THREE.PerspectiveCamera.prototype.toJSON = function ( meta ) {

+ 1 - 1
src/core/BufferAttribute.js

@@ -281,7 +281,7 @@ THREE.BufferAttribute.prototype = {
 
 	clone: function () {
 
-		return new THREE.BufferAttribute( new this.array.constructor( this.array ), this.itemSize );
+		return new this.constructor( new this.array.constructor( this.array ), this.itemSize );
 
 	}
 

+ 2 - 1
src/core/BufferGeometry.js

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

+ 1 - 7
src/core/DynamicBufferAttribute.js

@@ -12,10 +12,4 @@ THREE.DynamicBufferAttribute = function ( array, itemSize ) {
 };
 
 THREE.DynamicBufferAttribute.prototype = Object.create( THREE.BufferAttribute.prototype );
-THREE.DynamicBufferAttribute.prototype.constructor = THREE.DynamicBufferAttribute;
-
-THREE.DynamicBufferAttribute.prototype.clone = function () {
-
-	return new THREE.DynamicBufferAttribute( new this.array.constructor( this.array ), this.itemSize );
-
-};
+THREE.DynamicBufferAttribute.prototype.constructor = THREE.DynamicBufferAttribute;

+ 7 - 6
src/core/Face3.js

@@ -25,6 +25,13 @@ THREE.Face3.prototype = {
 
 	constructor: THREE.Face3,
 
+	clone: function () {
+
+		var face = new this.constructor();
+		return face.copy( this );
+
+	},
+
 	copy: function ( source ) {
 
 		this.a = source.a;
@@ -56,12 +63,6 @@ THREE.Face3.prototype = {
 
 		return this;
 
-	},
-
-	clone: function () {
-
-		return new THREE.Face3().copy( this );
-
 	}
 
 };

+ 2 - 1
src/core/Geometry.js

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

+ 10 - 12
src/core/InstancedBufferGeometry.js

@@ -25,28 +25,26 @@ THREE.InstancedBufferGeometry.prototype.addDrawCall = function ( start, count, i
 
 	} );
 
-},
-
-THREE.InstancedBufferGeometry.prototype.clone = function () {
-
-	var geometry = new THREE.InstancedBufferGeometry();
+};
 
-	for ( var attr in this.attributes ) {
+THREE.InstancedBufferGeometry.prototype.copy = function ( source ) {
+	
+	for ( var attr in source.attributes ) {
 
-		var sourceAttr = this.attributes[ attr ];
+		var sourceAttr = source.attributes[ attr ];
 		geometry.addAttribute( attr, sourceAttr.clone() );
 
 	}
 
-	for ( var i = 0, il = this.drawcalls.length; i < il; i ++ ) {
+	for ( var i = 0, il = source.drawcalls.length; i < il; i ++ ) {
 
-		var offset = this.drawcalls[ i ];
+		var offset = source.drawcalls[ i ];
 		geometry.addDrawCall( offset.start, offset.count, offset.index, offset.instances );
 
 	}
-
-	return geometry;
-
+	
+	return this;
+	
 };
 
 THREE.EventDispatcher.prototype.apply( THREE.InstancedBufferGeometry.prototype );

+ 1 - 1
src/core/InstancedInterleavedBuffer.js

@@ -15,6 +15,6 @@ THREE.InstancedInterleavedBuffer.prototype.constructor = THREE.InstancedInterlea
 
 THREE.InstancedInterleavedBuffer.prototype.clone = function () {
 
-	return new THREE.InstancedInterleavedBuffer( new this.array.constructor( this.array ), this.stride, this.dynamic, this.meshPerAttribute );
+	return new this.constructor( new this.array.constructor( this.array ), this.stride, this.dynamic, this.meshPerAttribute );
 
 };

+ 1 - 1
src/core/InterleavedBuffer.js

@@ -65,7 +65,7 @@ THREE.InterleavedBuffer.prototype = {
 
 	clone: function () {
 
-		return new THREE.InterleavedBuffer( new this.array.constructor( this.array ), this.stride, this.dynamic );
+		return new this.constructor( new this.array.constructor( this.array ), this.stride, this.dynamic );
 
 	}
 

+ 2 - 1
src/core/Object3D.js

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

+ 0 - 10
src/lights/AmbientLight.js

@@ -13,16 +13,6 @@ THREE.AmbientLight = function ( color ) {
 THREE.AmbientLight.prototype = Object.create( THREE.Light.prototype );
 THREE.AmbientLight.prototype.constructor = THREE.AmbientLight;
 
-THREE.AmbientLight.prototype.clone = function () {
-
-	var light = new THREE.AmbientLight();
-
-	light.copy( this );
-
-	return light;
-
-};
-
 THREE.AmbientLight.prototype.toJSON = function ( meta ) {
 
 	var data = THREE.Object3D.prototype.toJSON.call( this, meta );

+ 16 - 12
src/lights/AreaLight.js

@@ -27,22 +27,26 @@ THREE.AreaLight = function ( color, intensity ) {
 THREE.AreaLight.prototype = Object.create( THREE.Light.prototype );
 THREE.AreaLight.prototype.constructor = THREE.AreaLight;
 
-THREE.AreaLight.prototype.clone = function () {
+THREE.PointLight.prototype.clone = function () {
 
-	var light = new THREE.AreaLight();
+	var light = new this.constructor( this.color, this.intensity );
+	return light.copy( this );
 
-	light.copy( this );
+};
+
+THREE.AreaLight.prototype.copy = function ( source ) {
+
+	THREE.Object3D.prototype.copy.call( this, source );
 
-	light.normal.copy( this.normal );
-	light.right.copy( this.right );
-	light.intensity = this.intensity;
-	light.width = this.width;
-	light.height = this.height;
-	light.constantAttenuation = this.constantAttenuation;
-	light.linearAttenuation = this.linearAttenuation;
-	light.quadraticAttenuation = this.quadraticAttenuation;
+	this.normal.copy( source.normal );
+	this.right.copy( source.right );
+	this.width = source.width;
+	this.height = source.height;
+	this.constantAttenuation = source.constantAttenuation;
+	this.linearAttenuation = source.linearAttenuation;
+	this.quadraticAttenuation = source.quadraticAttenuation;
 
-	return light;
+	return this;
 
 };
 

+ 22 - 26
src/lights/DirectionalLight.js

@@ -19,8 +19,6 @@ THREE.DirectionalLight = function ( color, intensity ) {
 	this.castShadow = false;
 	this.onlyShadow = false;
 
-	//
-
 	this.shadowCameraNear = 50;
 	this.shadowCameraFar = 5000;
 
@@ -37,8 +35,6 @@ THREE.DirectionalLight = function ( color, intensity ) {
 	this.shadowMapWidth = 512;
 	this.shadowMapHeight = 512;
 
-	//
-
 	this.shadowMap = null;
 	this.shadowMapSize = null;
 	this.shadowCamera = null;
@@ -49,38 +45,38 @@ THREE.DirectionalLight = function ( color, intensity ) {
 THREE.DirectionalLight.prototype = Object.create( THREE.Light.prototype );
 THREE.DirectionalLight.prototype.constructor = THREE.DirectionalLight;
 
-THREE.DirectionalLight.prototype.clone = function () {
-
-	var light = new THREE.DirectionalLight();
-
-	light.copy( this );
+THREE.DirectionalLight.prototype.clone = function() {
+	
+	var light = new this.constructor( this.color, this.intensity );
+	return light.copy( this );
+}
 
-	light.target = this.target.clone();
+THREE.DirectionalLight.prototype.copy = function ( source ) {
 
-	light.intensity = this.intensity;
+	THREE.Object3D.prototype.copy.call( this, source );
 
-	light.castShadow = this.castShadow;
-	light.onlyShadow = this.onlyShadow;
+	this.target = source.target.clone();
 
-	//
+	this.castShadow = source.castShadow;
+	this.onlyShadow = source.onlyShadow;
 
-	light.shadowCameraNear = this.shadowCameraNear;
-	light.shadowCameraFar = this.shadowCameraFar;
+	this.shadowCameraNear = source.shadowCameraNear;
+	this.shadowCameraFar = source.shadowCameraFar;
 
-	light.shadowCameraLeft = this.shadowCameraLeft;
-	light.shadowCameraRight = this.shadowCameraRight;
-	light.shadowCameraTop = this.shadowCameraTop;
-	light.shadowCameraBottom = this.shadowCameraBottom;
+	this.shadowCameraLeft = source.shadowCameraLeft;
+	this.shadowCameraRight = source.shadowCameraRight;
+	this.shadowCameraTop = source.shadowCameraTop;
+	this.shadowCameraBottom = source.shadowCameraBottom;
 
-	light.shadowCameraVisible = this.shadowCameraVisible;
+	this.shadowCameraVisible = source.shadowCameraVisible;
 
-	light.shadowBias = this.shadowBias;
-	light.shadowDarkness = this.shadowDarkness;
+	this.shadowBias = source.shadowBias;
+	this.shadowDarkness = source.shadowDarkness;
 
-	light.shadowMapWidth = this.shadowMapWidth;
-	light.shadowMapHeight = this.shadowMapHeight;
+	this.shadowMapWidth = source.shadowMapWidth;
+	this.shadowMapHeight = source.shadowMapHeight;
 
-	return light;
+	return this;
 
 };
 

+ 2 - 8
src/lights/HemisphereLight.js

@@ -21,14 +21,8 @@ THREE.HemisphereLight.prototype.constructor = THREE.HemisphereLight;
 
 THREE.HemisphereLight.prototype.clone = function () {
 
-	var light = new THREE.HemisphereLight();
-
-	light.copy( this );
-
-	light.groundColor.copy( this.groundColor );
-	light.intensity = this.intensity;
-
-	return light;
+	var light = new this.constructor( this.color, this.groundColor, this.intensity );
+	return light.copy(this);
 
 };
 

+ 3 - 12
src/lights/Light.js

@@ -17,17 +17,8 @@ THREE.Light.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Light.prototype.constructor = THREE.Light;
 
 THREE.Light.prototype.clone = function () {
-
-	var light = new THREE.Light();
+	
+	var light = new this.constructor( this.color );
 	return light.copy( this );
 
-};
-
-THREE.Light.prototype.copy = function ( source ) {
-
-	THREE.Object3D.prototype.copy.call( this, source );
-	this.color.copy( source.color );
-
-	return this;
-
-};
+};

+ 2 - 9
src/lights/PointLight.js

@@ -19,15 +19,8 @@ THREE.PointLight.prototype.constructor = THREE.PointLight;
 
 THREE.PointLight.prototype.clone = function () {
 
-	var light = new THREE.PointLight();
-
-	light.copy( this );
-
-	light.intensity = this.intensity;
-	light.distance = this.distance;
-	light.decay = this.decay;
-
-	return light;
+	var light = new this.constructor( this.color, this.intensity, this.distance, this.decay );
+	return light.copy( this );
 
 };
 

+ 20 - 28
src/lights/SpotLight.js

@@ -22,8 +22,6 @@ THREE.SpotLight = function ( color, intensity, distance, angle, exponent, decay
 	this.castShadow = false;
 	this.onlyShadow = false;
 
-	//
-
 	this.shadowCameraNear = 50;
 	this.shadowCameraFar = 5000;
 	this.shadowCameraFov = 50;
@@ -36,8 +34,6 @@ THREE.SpotLight = function ( color, intensity, distance, angle, exponent, decay
 	this.shadowMapWidth = 512;
 	this.shadowMapHeight = 512;
 
-	//
-
 	this.shadowMap = null;
 	this.shadowMapSize = null;
 	this.shadowCamera = null;
@@ -50,38 +46,34 @@ THREE.SpotLight.prototype.constructor = THREE.SpotLight;
 
 THREE.SpotLight.prototype.clone = function () {
 
-	var light = new THREE.SpotLight();
-
-	light.copy( this );
-
-	light.target = this.target.clone();
+	var light = new this.constructor( this.color, this.intensity, this.distance, this.angle, this.exponent, this.decay );
+	return light.copy( this );
 
-	light.intensity = this.intensity;
-	light.distance = this.distance;
-	light.angle = this.angle;
-	light.exponent = this.exponent;
-	light.decay = this.decay;
-
-	light.castShadow = this.castShadow;
-	light.onlyShadow = this.onlyShadow;
+};
 
-	//
+THREE.SpotLight.prototype.copy = function ( source ) {
+	
+	THREE.Object3D.prototype.copy.call( this, source );
+	
+	this.target = source.target.clone();
 
-	light.shadowCameraNear = this.shadowCameraNear;
-	light.shadowCameraFar = this.shadowCameraFar;
-	light.shadowCameraFov = this.shadowCameraFov;
+	this.castShadow = source.castShadow;
+	this.onlyShadow = source.onlyShadow;
 
-	light.shadowCameraVisible = this.shadowCameraVisible;
+	this.shadowCameraNear = source.shadowCameraNear;
+	this.shadowCameraFar = source.shadowCameraFar;
+	this.shadowCameraFov = source.shadowCameraFov;
 
-	light.shadowBias = this.shadowBias;
-	light.shadowDarkness = this.shadowDarkness;
+	this.shadowCameraVisible = source.shadowCameraVisible;
 
-	light.shadowMapWidth = this.shadowMapWidth;
-	light.shadowMapHeight = this.shadowMapHeight;
+	this.shadowBias = source.shadowBias;
+	this.shadowDarkness = source.shadowDarkness;
 
-	return light;
+	this.shadowMapWidth = source.shadowMapWidth;
+	this.shadowMapHeight = source.shadowMapHeight;
 
-};
+	return this;
+}
 
 THREE.SpotLight.prototype.toJSON = function ( meta ) {
 

+ 9 - 11
src/materials/LineBasicMaterial.js

@@ -43,22 +43,20 @@ THREE.LineBasicMaterial = function ( parameters ) {
 THREE.LineBasicMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.LineBasicMaterial.prototype.constructor = THREE.LineBasicMaterial;
 
-THREE.LineBasicMaterial.prototype.clone = function () {
+THREE.LineBasicMaterial.prototype.copy = function ( source ) {
 
-	var material = new THREE.LineBasicMaterial();
+	THREE.Material.prototype.copy.call( this, source );
 
-	material.copy( this );
+	this.color.copy( source.color );
 
-	material.color.copy( this.color );
+	this.linewidth = source.linewidth;
+	this.linecap = source.linecap;
+	this.linejoin = source.linejoin;
 
-	material.linewidth = this.linewidth;
-	material.linecap = this.linecap;
-	material.linejoin = this.linejoin;
+	this.vertexColors = source.vertexColors;
 
-	material.vertexColors = this.vertexColors;
+	this.fog = source.fog;
 
-	material.fog = this.fog;
-
-	return material;
+	return this;
 
 };

+ 9 - 13
src/materials/LineDashedMaterial.js

@@ -46,24 +46,20 @@ THREE.LineDashedMaterial = function ( parameters ) {
 THREE.LineDashedMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.LineDashedMaterial.prototype.constructor = THREE.LineDashedMaterial;
 
-THREE.LineDashedMaterial.prototype.clone = function () {
+THREE.LineBasicMaterial.prototype.copy = function ( source ) {
 
-	var material = new THREE.LineDashedMaterial();
+	THREE.Material.prototype.copy.call( this, source );
 
-	material.copy( this );
+	this.color.copy( source.color );
 
-	material.color.copy( this.color );
+	this.scale = source.scale;
+	this.dashSize = source.dashSize;
+	this.gapSize = source.gapSize;
 
-	material.linewidth = this.linewidth;
+	this.vertexColors = source.vertexColors;
 
-	material.scale = this.scale;
-	material.dashSize = this.dashSize;
-	material.gapSize = this.gapSize;
+	this.fog = source.fog;
 
-	material.vertexColors = this.vertexColors;
-
-	material.fog = this.fog;
-
-	return material;
+	return this;
 
 };

+ 2 - 1
src/materials/Material.js

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

+ 24 - 26
src/materials/MeshBasicMaterial.js

@@ -79,42 +79,40 @@ THREE.MeshBasicMaterial = function ( parameters ) {
 THREE.MeshBasicMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.MeshBasicMaterial.prototype.constructor = THREE.MeshBasicMaterial;
 
-THREE.MeshBasicMaterial.prototype.clone = function () {
+THREE.MeshBasicMaterial.prototype.copy = function ( source ) {
+	
+	THREE.Material.prototype.copy.call( this, source );
 
-	var material = new THREE.MeshBasicMaterial();
+	this.color.copy( source.color );
 
-	material.copy( this );
+	this.map = source.map;
 
-	material.color.copy( this.color );
+	this.aoMap = source.aoMap;
+	this.aoMapIntensity = source.aoMapIntensity;
 
-	material.map = this.map;
+	this.specularMap = source.specularMap;
 
-	material.aoMap = this.aoMap;
-	material.aoMapIntensity = this.aoMapIntensity;
+	this.alphaMap = source.alphaMap;
 
-	material.specularMap = this.specularMap;
+	this.envMap = source.envMap;
+	this.combine = source.combine;
+	this.reflectivity = source.reflectivity;
+	this.refractionRatio = source.refractionRatio;
 
-	material.alphaMap = this.alphaMap;
+	this.fog = source.fog;
 
-	material.envMap = this.envMap;
-	material.combine = this.combine;
-	material.reflectivity = this.reflectivity;
-	material.refractionRatio = this.refractionRatio;
+	this.shading = source.shading;
 
-	material.fog = this.fog;
+	this.wireframe = source.wireframe;
+	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframeLinecap = source.wireframeLinecap;
+	this.wireframeLinejoin = source.wireframeLinejoin;
 
-	material.shading = this.shading;
+	this.vertexColors = source.vertexColors;
 
-	material.wireframe = this.wireframe;
-	material.wireframeLinewidth = this.wireframeLinewidth;
-	material.wireframeLinecap = this.wireframeLinecap;
-	material.wireframeLinejoin = this.wireframeLinejoin;
-
-	material.vertexColors = this.vertexColors;
-
-	material.skinning = this.skinning;
-	material.morphTargets = this.morphTargets;
-
-	return material;
+	this.skinning = source.skinning;
+	this.morphTargets = source.morphTargets;
+	
+	return this;
 
 };

+ 5 - 7
src/materials/MeshDepthMaterial.js

@@ -31,15 +31,13 @@ THREE.MeshDepthMaterial = function ( parameters ) {
 THREE.MeshDepthMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.MeshDepthMaterial.prototype.constructor = THREE.MeshDepthMaterial;
 
-THREE.MeshDepthMaterial.prototype.clone = function () {
+THREE.MeshDepthMaterial.prototype.copy = function ( source ) {
 
-	var material = new THREE.MeshDepthMaterial();
+	THREE.Material.prototype.copy.call( this, source );
 
-	material.copy( this );
+	this.wireframe = source.wireframe;
+	this.wireframeLinewidth = source.wireframeLinewidth;
 
-	material.wireframe = this.wireframe;
-	material.wireframeLinewidth = this.wireframeLinewidth;
-
-	return material;
+	return this;
 
 };

+ 1 - 1
src/materials/MeshFaceMaterial.js

@@ -45,7 +45,7 @@ THREE.MeshFaceMaterial.prototype = {
 
 	clone: function () {
 
-		var material = new THREE.MeshFaceMaterial();
+		var material = new this.constructor();
 
 		for ( var i = 0; i < this.materials.length; i ++ ) {
 

+ 22 - 24
src/materials/MeshLambertMaterial.js

@@ -78,41 +78,39 @@ THREE.MeshLambertMaterial = function ( parameters ) {
 THREE.MeshLambertMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.MeshLambertMaterial.prototype.constructor = THREE.MeshLambertMaterial;
 
-THREE.MeshLambertMaterial.prototype.clone = function () {
+THREE.MeshLambertMaterial.prototype.copy = function ( source ) {
 
-	var material = new THREE.MeshLambertMaterial();
+	THREE.Material.prototype.copy.call( this, source );
 
-	material.copy( this );
+	this.color.copy( source.color );
+	this.emissive.copy( source.emissive );
 
-	material.color.copy( this.color );
-	material.emissive.copy( this.emissive );
+	this.map = source.map;
 
-	material.map = this.map;
+	this.specularMap = source.specularMap;
 
-	material.specularMap = this.specularMap;
+	this.alphaMap = source.alphaMap;
 
-	material.alphaMap = this.alphaMap;
+	this.envMap = source.envMap;
+	this.combine = source.combine;
+	this.reflectivity = source.reflectivity;
+	this.refractionRatio = source.refractionRatio;
 
-	material.envMap = this.envMap;
-	material.combine = this.combine;
-	material.reflectivity = this.reflectivity;
-	material.refractionRatio = this.refractionRatio;
+	this.fog = source.fog;
 
-	material.fog = this.fog;
+	this.shading = source.shading;
 
-	material.shading = this.shading;
+	this.wireframe = source.wireframe;
+	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframeLinecap = source.wireframeLinecap;
+	this.wireframeLinejoin = source.wireframeLinejoin;
 
-	material.wireframe = this.wireframe;
-	material.wireframeLinewidth = this.wireframeLinewidth;
-	material.wireframeLinecap = this.wireframeLinecap;
-	material.wireframeLinejoin = this.wireframeLinejoin;
+	this.vertexColors = source.vertexColors;
 
-	material.vertexColors = this.vertexColors;
+	this.skinning = source.skinning;
+	this.morphTargets = source.morphTargets;
+	this.morphNormals = source.morphNormals;
 
-	material.skinning = this.skinning;
-	material.morphTargets = this.morphTargets;
-	material.morphNormals = this.morphNormals;
-
-	return material;
+	return this;
 
 };

+ 5 - 7
src/materials/MeshNormalMaterial.js

@@ -32,15 +32,13 @@ THREE.MeshNormalMaterial = function ( parameters ) {
 THREE.MeshNormalMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.MeshNormalMaterial.prototype.constructor = THREE.MeshNormalMaterial;
 
-THREE.MeshNormalMaterial.prototype.clone = function () {
+THREE.MeshNormalMaterial.prototype.copy = function ( source ) {
 
-	var material = new THREE.MeshNormalMaterial();
+	THREE.Material.prototype.copy.call( this, source );
 
-	material.copy( this );
+	this.wireframe = source.wireframe;
+	this.wireframeLinewidth = source.wireframeLinewidth;
 
-	material.wireframe = this.wireframe;
-	material.wireframeLinewidth = this.wireframeLinewidth;
-
-	return material;
+	return this;
 
 };

+ 0 - 6
src/materials/MeshPhongMaterial.js

@@ -166,9 +166,3 @@ THREE.MeshPhongMaterial.prototype.copy = function ( source ) {
 	return this;
 
 };
-
-THREE.MeshPhongMaterial.prototype.clone = function () {
-
-	return new THREE.MeshPhongMaterial().copy( this );
-
-};

+ 10 - 12
src/materials/PointCloudMaterial.js

@@ -44,24 +44,22 @@ THREE.PointCloudMaterial = function ( parameters ) {
 THREE.PointCloudMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.PointCloudMaterial.prototype.constructor = THREE.PointCloudMaterial;
 
-THREE.PointCloudMaterial.prototype.clone = function () {
+THREE.PointCloudMaterial.prototype.copy = function ( source ) {
 
-	var material = new THREE.PointCloudMaterial();
+	THREE.Material.prototype.copy.call( this, source );
 
-	material.copy( this );
+	this.color.copy( source.color );
 
-	material.color.copy( this.color );
+	this.map = source.map;
 
-	material.map = this.map;
+	this.size = source.size;
+	this.sizeAttenuation = source.sizeAttenuation;
 
-	material.size = this.size;
-	material.sizeAttenuation = this.sizeAttenuation;
+	this.vertexColors = source.vertexColors;
 
-	material.vertexColors = this.vertexColors;
-
-	material.fog = this.fog;
-
-	return material;
+	this.fog = source.fog;
+	
+	return this;
 
 };
 

+ 1 - 11
src/materials/RawShaderMaterial.js

@@ -11,14 +11,4 @@ THREE.RawShaderMaterial = function ( parameters ) {
 };
 
 THREE.RawShaderMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype );
-THREE.RawShaderMaterial.prototype.constructor = THREE.RawShaderMaterial;
-
-THREE.RawShaderMaterial.prototype.clone = function () {
-
-	var material = new THREE.RawShaderMaterial();
-
-	material.copy( this );
-
-	return material;
-
-};
+THREE.RawShaderMaterial.prototype.constructor = THREE.RawShaderMaterial;

+ 0 - 7
src/materials/ShaderMaterial.js

@@ -89,13 +89,6 @@ THREE.ShaderMaterial = function ( parameters ) {
 THREE.ShaderMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.ShaderMaterial.prototype.constructor = THREE.ShaderMaterial;
 
-THREE.ShaderMaterial.prototype.clone = function () {
-
-	var material = new THREE.ShaderMaterial();
-	return material.copy( this );
-
-};
-
 THREE.ShaderMaterial.prototype.copy = function ( source ) {
 
 	THREE.Material.prototype.copy.call( this, source );

+ 7 - 9
src/materials/SpriteMaterial.js

@@ -39,19 +39,17 @@ THREE.SpriteMaterial = function ( parameters ) {
 THREE.SpriteMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.SpriteMaterial.prototype.constructor = THREE.SpriteMaterial;
 
-THREE.SpriteMaterial.prototype.clone = function () {
+THREE.SpriteMaterial.prototype.copy = function ( source ) {
 
-	var material = new THREE.SpriteMaterial();
+	THREE.Material.prototype.copy.call( this, source );
 
-	material.copy( this );
+	this.color.copy( source.color );
+	this.map = source.map;
 
-	material.color.copy( this.color );
-	material.map = this.map;
+	this.rotation = source.rotation;
 
-	material.rotation = this.rotation;
+	this.fog = source.fog;
 
-	material.fog = this.fog;
-
-	return material;
+	return this;
 
 };

+ 7 - 6
src/math/Box2.js

@@ -51,6 +51,13 @@ THREE.Box2.prototype = {
 		};
 
 	}(),
+	
+	clone: function () {
+
+		var box = new this.constructor();
+		return box.copy( this );
+
+	},
 
 	copy: function ( box ) {
 
@@ -225,12 +232,6 @@ THREE.Box2.prototype = {
 
 		return box.min.equals( this.min ) && box.max.equals( this.max );
 
-	},
-
-	clone: function () {
-
-		return new THREE.Box2().copy( this );
-
 	}
 
 };

+ 7 - 6
src/math/Box3.js

@@ -115,6 +115,13 @@ THREE.Box3.prototype = {
 
 	}(),
 
+	clone: function () {
+
+		var box = new this.constructor();
+		return box.copy( this );
+
+	},
+
 	copy: function ( box ) {
 
 		this.min.copy( box.min );
@@ -343,12 +350,6 @@ THREE.Box3.prototype = {
 
 		return box.min.equals( this.min ) && box.max.equals( this.max );
 
-	},
-
-	clone: function () {
-
-		return new THREE.Box3().copy( this );
-
 	}
 
 };

+ 6 - 6
src/math/Color.js

@@ -271,6 +271,12 @@ THREE.Color.prototype = {
 
 	},
 
+	clone: function () {
+
+		return new this.constructor( this.color );
+
+	},
+
 	copy: function ( color ) {
 
 		this.r = color.r;
@@ -491,12 +497,6 @@ THREE.Color.prototype = {
 
 		return array;
 
-	},
-
-	clone: function () {
-
-		return new THREE.Color().copy( this );
-
 	}
 
 };

+ 7 - 7
src/math/Euler.js

@@ -86,6 +86,12 @@ THREE.Euler.prototype = {
 
 	},
 
+	clone: function () {
+
+		return new this.constructor( this._x, this._y, this._z, this._order);
+
+	},
+
 	copy: function ( euler ) {
 
 		this._x = euler._x;
@@ -314,12 +320,6 @@ THREE.Euler.prototype = {
 
 	},
 
-	onChangeCallback: function () {},
-
-	clone: function () {
-
-		return new THREE.Euler( this._x, this._y, this._z, this._order );
-
-	}
+	onChangeCallback: function () {}
 
 };

+ 7 - 6
src/math/Frustum.js

@@ -38,6 +38,13 @@ THREE.Frustum.prototype = {
 
 	},
 
+	clone: function () {
+
+		var frustum = new this.constructor();
+		return frustum.copy( this );
+
+	},
+
 	copy: function ( frustum ) {
 
 		var planes = this.planes;
@@ -169,12 +176,6 @@ THREE.Frustum.prototype = {
 
 		return true;
 
-	},
-
-	clone: function () {
-
-		return new THREE.Frustum().copy( this );
-
 	}
 
 };

+ 7 - 6
src/math/Line3.js

@@ -22,6 +22,13 @@ THREE.Line3.prototype = {
 
 	},
 
+	clone: function () {
+
+		var line = new this.constructor();
+		return line.copy( this );
+
+	},
+
 	copy: function ( line ) {
 
 		this.start.copy( line.start );
@@ -115,12 +122,6 @@ THREE.Line3.prototype = {
 
 		return line.start.equals( this.start ) && line.end.equals( this.end );
 
-	},
-
-	clone: function () {
-
-		return new THREE.Line3().copy( this );
-
 	}
 
 };

+ 7 - 6
src/math/Matrix3.js

@@ -52,6 +52,13 @@ THREE.Matrix3.prototype = {
 
 	},
 
+	clone: function () {
+
+		var matrix = new this.constructor();
+		return matrix.fromArray( this.elements );
+
+	},
+
 	copy: function ( m ) {
 
 		var me = m.elements;
@@ -284,12 +291,6 @@ THREE.Matrix3.prototype = {
 			te[ 6 ], te[ 7 ], te[ 8 ]
 		];
 
-	},
-
-	clone: function () {
-
-		return new THREE.Matrix3().fromArray( this.elements );
-
 	}
 
 };

+ 6 - 6
src/math/Matrix4.js

@@ -62,6 +62,12 @@ THREE.Matrix4.prototype = {
 
 	},
 
+	clone: function () {
+
+		return new THREE.Matrix4().fromArray( this.elements );
+
+	},
+
 	copy: function ( m ) {
 
 		this.elements.set( m.elements );
@@ -1025,12 +1031,6 @@ THREE.Matrix4.prototype = {
 			te[ 12 ], te[ 13 ], te[ 14 ], te[ 15 ]
 		];
 
-	},
-
-	clone: function () {
-
-		return new THREE.Matrix4().fromArray( this.elements );
-
 	}
 
 };

+ 6 - 6
src/math/Plane.js

@@ -59,6 +59,12 @@ THREE.Plane.prototype = {
 
 	}(),
 
+	clone: function () {
+
+		var plane = new this.constructor();
+		return plane.copy( this );
+
+	},
 
 	copy: function ( plane ) {
 
@@ -212,12 +218,6 @@ THREE.Plane.prototype = {
 
 		return plane.normal.equals( this.normal ) && ( plane.constant === this.constant );
 
-	},
-
-	clone: function () {
-
-		return new THREE.Plane().copy( this );
-
 	}
 
 };

+ 7 - 7
src/math/Quaternion.js

@@ -83,6 +83,12 @@ THREE.Quaternion.prototype = {
 
 	},
 
+	clone: function () {
+
+		return new this.constructor( this._x, this._y, this._z, this._w );
+
+	},
+
 	copy: function ( quaternion ) {
 
 		this._x = quaternion.x;
@@ -504,13 +510,7 @@ THREE.Quaternion.prototype = {
 
 	},
 
-	onChangeCallback: function () {},
-
-	clone: function () {
-
-		return new THREE.Quaternion( this._x, this._y, this._z, this._w );
-
-	}
+	onChangeCallback: function () {}
 
 };
 

+ 7 - 6
src/math/Ray.js

@@ -22,6 +22,13 @@ THREE.Ray.prototype = {
 
 	},
 
+	clone: function () {
+
+		var ray = new this.constructor();
+		return ray.copy( this );
+
+	},
+
 	copy: function ( ray ) {
 
 		this.origin.copy( ray.origin );
@@ -521,12 +528,6 @@ THREE.Ray.prototype = {
 
 		return ray.origin.equals( this.origin ) && ray.direction.equals( this.direction );
 
-	},
-
-	clone: function () {
-
-		return new THREE.Ray().copy( this );
-
 	}
 
 };

+ 7 - 6
src/math/Sphere.js

@@ -57,6 +57,13 @@ THREE.Sphere.prototype = {
 
 	}(),
 
+	clone: function () {
+
+		var sphere = new this.constructor();
+		return sphere.copy( this );
+
+	},
+
 	copy: function ( sphere ) {
 
 		this.center.copy( sphere.center );
@@ -142,12 +149,6 @@ THREE.Sphere.prototype = {
 
 		return sphere.center.equals( this.center ) && ( sphere.radius === this.radius );
 
-	},
-
-	clone: function () {
-
-		return new THREE.Sphere().copy( this );
-
 	}
 
 };

+ 7 - 6
src/math/Triangle.js

@@ -118,6 +118,13 @@ THREE.Triangle.prototype = {
 
 	},
 
+	clone: function () {
+
+		var triangle = new this.constructor();
+		return triangle.copy( this );
+
+	},
+
 	copy: function ( triangle ) {
 
 		this.a.copy( triangle.a );
@@ -181,12 +188,6 @@ THREE.Triangle.prototype = {
 
 		return triangle.a.equals( this.a ) && triangle.b.equals( this.b ) && triangle.c.equals( this.c );
 
-	},
-
-	clone: function () {
-
-		return new THREE.Triangle().copy( this );
-
 	}
 
 };

+ 6 - 6
src/math/Vector2.js

@@ -65,6 +65,12 @@ THREE.Vector2.prototype = {
 
 	},
 
+	clone: function () {
+
+		return new this.constructor( this.x, this.y );
+
+	},
+
 	copy: function ( v ) {
 
 		this.x = v.x;
@@ -443,12 +449,6 @@ THREE.Vector2.prototype = {
 
 		return this;
 
-	},
-
-	clone: function () {
-
-		return new THREE.Vector2( this.x, this.y );
-
 	}
 
 };

+ 6 - 6
src/math/Vector3.js

@@ -79,6 +79,12 @@ THREE.Vector3.prototype = {
 
 	},
 
+	clone: function () {
+
+		return new this.constructor( this.x, this.y, this.z );
+
+	},
+
 	copy: function ( v ) {
 
 		this.x = v.x;
@@ -852,12 +858,6 @@ THREE.Vector3.prototype = {
 
 		return this;
 
-	},
-
-	clone: function () {
-
-		return new THREE.Vector3( this.x, this.y, this.z );
-
 	}
 
 };

+ 6 - 6
src/math/Vector4.js

@@ -90,6 +90,12 @@ THREE.Vector4.prototype = {
 
 	},
 
+	clone: function () {
+
+		return new this.constructor( this.x, this.y, this.z, this.w );
+
+	},
+
 	copy: function ( v ) {
 
 		this.x = v.x;
@@ -697,12 +703,6 @@ THREE.Vector4.prototype = {
 
 		return this;
 
-	},
-
-	clone: function () {
-
-		return new THREE.Vector4( this.x, this.y, this.z, this.w );
-
 	}
 
 };

+ 2 - 11
src/objects/Bone.js

@@ -18,17 +18,8 @@ THREE.Bone.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Bone.prototype.constructor = THREE.Bone;
 
 THREE.Bone.prototype.clone = function () {
-
-	var bone = new THREE.Bone( this.skin );
+	
+	var bone = new this.constructor( this.skin );
 	return bone.copy( this );
 
 };
-
-THREE.Bone.prototype.copy = function ( source ) {
-
-	THREE.Object3D.prototype.copy.call( this, source );
-	this.skin = source.skin;
-
-	return this;
-
-};

+ 1 - 15
src/objects/Group.js

@@ -11,18 +11,4 @@ THREE.Group = function () {
 };
 
 THREE.Group.prototype = Object.create( THREE.Object3D.prototype );
-THREE.Group.prototype.constructor = THREE.Group;
-
-THREE.Group.prototype.clone = function () {
-
-	var group = new THREE.Group();
-	return group.copy( this );
-
-};
-
-THREE.Group.prototype.copy = function ( source ) {
-
-	THREE.Object3D.prototype.copy.call( this, source );
-	return this;
-
-};
+THREE.Group.prototype.constructor = THREE.Group;

+ 0 - 8
src/objects/LOD.js

@@ -132,14 +132,6 @@ THREE.LOD.prototype.update = function () {
 
 }();
 
-THREE.LOD.prototype.clone = function () {
-
-	var lod = new THREE.LOD();
-	return lod.copy( this );
-
-};
-
-
 THREE.LOD.prototype.copy = function ( source ) {
 
 	THREE.Object3D.prototype.copy.call( this, source, false );

+ 0 - 7
src/objects/LensFlare.js

@@ -78,13 +78,6 @@ THREE.LensFlare.prototype.updateLensFlares = function () {
 
 };
 
-THREE.LensFlare.prototype.clone = function () {
-
-	var flare = new THREE.LensFlare();
-	return flare.copy( this );
-
-};
-
 THREE.LensFlare.prototype.copy = function ( source ) {
 
 	THREE.Object3D.prototype.copy.call( this, source );

+ 1 - 8
src/objects/Line.js

@@ -185,18 +185,11 @@ THREE.Line.prototype.raycast = ( function () {
 
 THREE.Line.prototype.clone = function () {
 
-	var line = new THREE.Line( this.geometry, this.material );
+	var line = new this.constructor( this.geometry, this.material );
 	return line.copy( this );
 
 };
 
-THREE.Line.prototype.copy = function ( source ) {
-
-	THREE.Object3D.prototype.copy.call( this, source );
-	return this;
-
-};
-
 THREE.Line.prototype.toJSON = function ( meta ) {
 
 	var data = THREE.Object3D.prototype.toJSON.call( this, meta );

+ 0 - 10
src/objects/LineSegments.js

@@ -12,13 +12,3 @@ THREE.LineSegments = function ( geometry, material ) {
 
 THREE.LineSegments.prototype = Object.create( THREE.Line.prototype );
 THREE.LineSegments.prototype.constructor = THREE.LineSegments;
-
-THREE.LineSegments.prototype.clone = function () {
-
-	var line = new THREE.LineSegments( this.geometry, this.material );
-
-	line.copy( this );
-
-	return line;
-
-};

+ 1 - 8
src/objects/Mesh.js

@@ -307,18 +307,11 @@ THREE.Mesh.prototype.raycast = ( function () {
 
 THREE.Mesh.prototype.clone = function () {
 
-	var mesh = new THREE.Mesh( this.geometry, this.material );
+	var mesh = new this.constructor( this.geometry, this.material );
 	return mesh.copy( this );
 
 };
 
-THREE.Mesh.prototype.copy = function ( source ) {
-
-	THREE.Object3D.prototype.copy.call( this, source );
-	return this;
-
-};
-
 THREE.Mesh.prototype.toJSON = function ( meta ) {
 
 	var data = THREE.Object3D.prototype.toJSON.call( this, meta );

+ 2 - 9
src/objects/MorphAnimMesh.js

@@ -193,15 +193,10 @@ THREE.MorphAnimMesh.prototype.interpolateTargets = function ( a, b, t ) {
 
 };
 
-THREE.MorphAnimMesh.prototype.clone = function () {
-
-	var morph = new THREE.MorphAnimMesh( this.geometry, this.material );
-	return morph.copy( this );
-
-};
-
 THREE.MorphAnimMesh.prototype.copy = function ( source ) {
 
+	THREE.Object3D.prototype.copy.call( this, source );
+
 	this.duration = source.duration;
 	this.mirroredLoop = source.mirroredLoop;
 	this.time = source.time;
@@ -212,8 +207,6 @@ THREE.MorphAnimMesh.prototype.copy = function ( source ) {
 	this.direction = source.direction;
 	this.directionBackwards = source.directionBackwards;
 
-	THREE.Mesh.prototype.copy.call( this, source );
-
 	return this;
 
 };

+ 1 - 8
src/objects/PointCloud.js

@@ -138,18 +138,11 @@ THREE.PointCloud.prototype.raycast = ( function () {
 
 THREE.PointCloud.prototype.clone = function () {
 
-	var pointCloud = new THREE.PointCloud( this.geometry, this.material );
+	var pointCloud = new this.constructor( this.geometry, this.material );
 	return pointCloud.copy( this );
 
 };
 
-THREE.PointCloud.prototype.copy = function ( source ) {
-
-	THREE.Object3D.prototype.copy.call( this, source );
-	return this;
-
-};
-
 THREE.PointCloud.prototype.toJSON = function ( meta ) {
 
 	var data = THREE.Object3D.prototype.toJSON.call( this, meta );

+ 1 - 8
src/objects/SkinnedMesh.js

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

+ 1 - 8
src/objects/Sprite.js

@@ -62,18 +62,11 @@ THREE.Sprite.prototype.raycast = ( function () {
 
 THREE.Sprite.prototype.clone = function () {
 
-	var sprite = new THREE.Sprite( this.material );
+	var sprite = new this.constructor( this.material );
 	return sprite.copy( this );
 
 };
 
-THREE.Sprite.prototype.copy = function ( source ) {
-
-	THREE.Object3D.prototype.copy.call( this, source );
-	return this;
-
-};
-
 THREE.Sprite.prototype.toJSON = function ( meta ) {
 
 	var data = THREE.Object3D.prototype.toJSON.call( this, meta );

+ 7 - 6
src/renderers/WebGLRenderTarget.js

@@ -52,6 +52,13 @@ THREE.WebGLRenderTarget.prototype = {
 
 	},
 
+	clone: function () {
+
+		var renderTarget = new this.constructor();
+		return renderTarget.copy( this );
+
+	},
+
 	copy: function ( source ) {
 
 		this.width = source.width;
@@ -82,12 +89,6 @@ THREE.WebGLRenderTarget.prototype = {
 
 	},
 
-	clone: function () {
-
-		return new THREE.WebGLRenderTarget().copy( this );
-
-	},
-
 	dispose: function () {
 
 		this.dispatchEvent( { type: 'dispose' } );

+ 0 - 7
src/scenes/Scene.js

@@ -18,13 +18,6 @@ THREE.Scene = function () {
 THREE.Scene.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Scene.prototype.constructor = THREE.Scene;
 
-THREE.Scene.prototype.clone = function () {
-
-	var scene = new THREE.Scene();
-	return scene.copy( this );
-
-};
-
 THREE.Scene.prototype.copy = function ( source ) {
 
 	THREE.Object3D.prototype.copy.call( this, source );

+ 0 - 10
src/textures/CompressedTexture.js

@@ -23,13 +23,3 @@ THREE.CompressedTexture = function ( mipmaps, width, height, format, type, mappi
 
 THREE.CompressedTexture.prototype = Object.create( THREE.Texture.prototype );
 THREE.CompressedTexture.prototype.constructor = THREE.CompressedTexture;
-
-THREE.CompressedTexture.prototype.clone = function () {
-
-	var texture = new THREE.CompressedTexture();
-
-	texture.copy( this );
-
-	return texture;
-
-};

+ 4 - 9
src/textures/CubeTexture.js

@@ -16,14 +16,9 @@ THREE.CubeTexture = function ( images, mapping, wrapS, wrapT, magFilter, minFilt
 THREE.CubeTexture.prototype = Object.create( THREE.Texture.prototype );
 THREE.CubeTexture.prototype.constructor = THREE.CubeTexture;
 
-THREE.CubeTexture.clone = function () {
+THREE.CubeTexture.prototype.clone = function () {
 
-	var texture = new THREE.CubeTexture();
+	var texture = new this.constructor( this.images, this.mapping, this.wrapS, this.wrapT, this.magFilter, this.minFilter, this.format, this.type, this.anisotropy );
+	return texture.copy( this );
 
-	texture.copy( this );
-
-	texture.images = this.images;
-
-	return texture;
-
-};
+};

+ 1 - 11
src/textures/DataTexture.js

@@ -11,14 +11,4 @@ THREE.DataTexture = function ( data, width, height, format, type, mapping, wrapS
 };
 
 THREE.DataTexture.prototype = Object.create( THREE.Texture.prototype );
-THREE.DataTexture.prototype.constructor = THREE.DataTexture;
-
-THREE.DataTexture.prototype.clone = function () {
-
-	var texture = new THREE.DataTexture();
-
-	texture.copy( this );
-
-	return texture;
-
-};
+THREE.DataTexture.prototype.constructor = THREE.DataTexture;

+ 2 - 15
src/textures/Texture.js

@@ -57,28 +57,15 @@ THREE.Texture.prototype = {
 
 	clone: function () {
 
-		return new THREE.Texture().copy( this );
+		var texture = new this.constructor( this.image, this.mapping, this.wrapS, this.wrapT, this.magFilter, this.minFilter, this.format, this.type, this.anisotropy );
+		return texture.copy( this );
 
 	},
 
 	copy: function ( source ) {
 
-		this.image = source.image;
 		this.mipmaps = source.mipmaps.slice( 0 );
 
-		this.mapping = source.mapping;
-
-		this.wrapS = source.wrapS;
-		this.wrapT = source.wrapT;
-
-		this.magFilter = source.magFilter;
-		this.minFilter = source.minFilter;
-
-		this.anisotropy = source.anisotropy;
-
-		this.format = source.format;
-		this.type = source.type;
-
 		this.offset.copy( source.offset );
 		this.repeat.copy( source.repeat );