2
0
Эх сурвалжийг харах

Clone should take no argument. Introduce CloneProperties

dubejf 10 жил өмнө
parent
commit
89491d9ba0
59 өөрчлөгдсөн 230 нэмэгдсэн , 146 устгасан
  1. 1 1
      examples/js/renderers/CanvasRenderer.js
  2. 1 1
      examples/js/wip/ProxyGeometry.js
  3. 9 3
      src/cameras/Camera.js
  4. 1 1
      src/cameras/OrthographicCamera.js
  5. 1 1
      src/cameras/PerspectiveCamera.js
  6. 5 0
      src/core/BufferGeometry.js
  7. 8 9
      src/core/Geometry.js
  8. 8 2
      src/core/Object3D.js
  9. 1 1
      src/extras/geometries/BoxGeometry.js
  10. 1 1
      src/extras/geometries/CircleBufferGeometry.js
  11. 1 1
      src/extras/geometries/CircleGeometry.js
  12. 1 1
      src/extras/geometries/CylinderGeometry.js
  13. 1 1
      src/extras/geometries/DodecahedronGeometry.js
  14. 1 1
      src/extras/geometries/IcosahedronGeometry.js
  15. 1 1
      src/extras/geometries/OctahedronGeometry.js
  16. 1 1
      src/extras/geometries/PlaneBufferGeometry.js
  17. 1 1
      src/extras/geometries/PlaneGeometry.js
  18. 12 11
      src/extras/geometries/PolyhedronGeometry.js
  19. 1 1
      src/extras/geometries/RingGeometry.js
  20. 1 1
      src/extras/geometries/SphereBufferGeometry.js
  21. 1 1
      src/extras/geometries/SphereGeometry.js
  22. 1 1
      src/extras/geometries/TetrahedronGeometry.js
  23. 1 1
      src/extras/geometries/TorusGeometry.js
  24. 1 1
      src/extras/geometries/TorusKnotGeometry.js
  25. 1 1
      src/lights/AmbientLight.js
  26. 1 1
      src/lights/AreaLight.js
  27. 1 1
      src/lights/DirectionalLight.js
  28. 1 1
      src/lights/HemisphereLight.js
  29. 8 4
      src/lights/Light.js
  30. 1 1
      src/lights/PointLight.js
  31. 1 1
      src/lights/SpotLight.js
  32. 1 1
      src/materials/LineBasicMaterial.js
  33. 1 1
      src/materials/LineDashedMaterial.js
  34. 7 2
      src/materials/Material.js
  35. 1 1
      src/materials/MeshBasicMaterial.js
  36. 1 1
      src/materials/MeshDepthMaterial.js
  37. 1 1
      src/materials/MeshLambertMaterial.js
  38. 1 1
      src/materials/MeshNormalMaterial.js
  39. 1 1
      src/materials/MeshPhongMaterial.js
  40. 1 1
      src/materials/PointCloudMaterial.js
  41. 1 1
      src/materials/RawShaderMaterial.js
  42. 8 3
      src/materials/ShaderMaterial.js
  43. 1 1
      src/materials/SpriteMaterial.js
  44. 11 6
      src/objects/Bone.js
  45. 9 5
      src/objects/Group.js
  46. 11 5
      src/objects/LOD.js
  47. 13 8
      src/objects/LensFlare.js
  48. 8 4
      src/objects/Line.js
  49. 4 4
      src/objects/LineSegments.js
  50. 9 4
      src/objects/Mesh.js
  51. 16 11
      src/objects/MorphAnimMesh.js
  52. 8 4
      src/objects/PointCloud.js
  53. 7 8
      src/objects/SkinnedMesh.js
  54. 9 5
      src/objects/Sprite.js
  55. 15 8
      src/scenes/Scene.js
  56. 1 1
      src/textures/CompressedTexture.js
  57. 1 1
      src/textures/CubeTexture.js
  58. 1 1
      src/textures/DataTexture.js
  59. 7 2
      src/textures/Texture.js

+ 1 - 1
examples/js/renderers/CanvasRenderer.js

@@ -22,7 +22,7 @@ THREE.SpriteCanvasMaterial.prototype.clone = function () {
 
 	var material = new THREE.SpriteCanvasMaterial();
 
-	THREE.Material.prototype.clone.call( this, material );
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.color.copy( this.color );
 	material.program = this.program;

+ 1 - 1
examples/js/wip/ProxyGeometry.js

@@ -741,7 +741,7 @@ THREE.ProxyGeometry.prototype.computeBoundingBox = function () {
 };
 THREE.ProxyGeometry.prototype.clone = function () {
 
-	var buff = THREE.BufferGeometry.prototype.clone.call(this);
+	var buff = THREE.BufferGeometry.prototype.cloneProperties.call(this);
 	var geo = new THREE.ProxyGeometry();
 	geo.attributes = buff.attributes;
 	geo.offsets = buff.drawcalls;

+ 9 - 3
src/cameras/Camera.js

@@ -50,14 +50,20 @@ THREE.Camera.prototype.lookAt = function () {
 
 }();
 
-THREE.Camera.prototype.clone = function ( camera ) {
+THREE.Camera.prototype.clone = function () {
 
-	if ( camera === undefined ) camera = new THREE.Camera();
+	var camera = new THREE.Camera();
+	return this.cloneProperties( camera );
 
-	THREE.Object3D.prototype.clone.call( this, camera );
+};
+
+THREE.Camera.prototype.cloneProperties = function ( camera ) {
+
+	THREE.Object3D.prototype.cloneProperties.call( this, camera );
 
 	camera.matrixWorldInverse.copy( this.matrixWorldInverse );
 	camera.projectionMatrix.copy( this.projectionMatrix );
 
 	return camera;
+
 };

+ 1 - 1
src/cameras/OrthographicCamera.js

@@ -40,7 +40,7 @@ THREE.OrthographicCamera.prototype.clone = function () {
 
 	var camera = new THREE.OrthographicCamera();
 
-	THREE.Camera.prototype.clone.call( this, camera );
+	THREE.Camera.prototype.cloneProperties.call( this, camera );
 
 	camera.zoom = this.zoom;
 

+ 1 - 1
src/cameras/PerspectiveCamera.js

@@ -126,7 +126,7 @@ THREE.PerspectiveCamera.prototype.clone = function () {
 
 	var camera = new THREE.PerspectiveCamera();
 
-	THREE.Camera.prototype.clone.call( this, camera );
+	THREE.Camera.prototype.cloneProperties.call( this, camera );
 
 	camera.zoom = this.zoom;
 

+ 5 - 0
src/core/BufferGeometry.js

@@ -1108,6 +1108,11 @@ THREE.BufferGeometry.prototype = {
 	clone: function () {
 
 		var geometry = new THREE.BufferGeometry();
+		return this.cloneProperties( geometry );
+
+	},
+
+	cloneProperties: function ( geometry ) {
 
 		for ( var attr in this.attributes ) {
 

+ 8 - 9
src/core/Geometry.js

@@ -1046,19 +1046,18 @@ THREE.Geometry.prototype = {
 
 	},
 
-	clone: function ( geometry ) {
+	clone: function () {
 
-		if ( geometry === undefined ) {
+		var geometry = new THREE.Geometry();
+		return this.cloneProperties( geometry );
 
-			geometry = new THREE.Geometry();
-
-		} else {
+	},
 
-			geometry.vertices = [];
-			geometry.faces = [];
-			geometry.faceVertexUvs = [ [] ];
+	cloneProperties: function ( geometry ) {
 
-		}
+		geometry.vertices = [];
+		geometry.faces = [];
+		geometry.faceVertexUvs = [ [] ];
 
 		var vertices = this.vertices;
 

+ 8 - 2
src/core/Object3D.js

@@ -659,9 +659,15 @@ THREE.Object3D.prototype = {
 
 	},
 
-	clone: function ( object, recursive ) {
+	clone: function ( recursive ) {
+
+		var object = new THREE.Object3D();
+		return this.cloneProperties( object, recursive );
+
+	},
+
+	cloneProperties: function ( object, recursive ) {
 
-		if ( object === undefined ) object = new THREE.Object3D();
 		if ( recursive === undefined ) recursive = true;
 
 		object.name = this.name;

+ 1 - 1
src/extras/geometries/BoxGeometry.js

@@ -135,7 +135,7 @@ THREE.BoxGeometry.prototype.clone = function () {
 		this.parameters.depthSegments
 	);
 
-	THREE.Geometry.prototype.clone.call( this, geometry );
+	THREE.Geometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/CircleBufferGeometry.js

@@ -77,7 +77,7 @@ THREE.CircleBufferGeometry.prototype.clone = function () {
 		this.parameters.thetaLength
 	);
 
-	THREE.BufferGeometry.prototype.clone.call( this, geometry );
+	THREE.BufferGeometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/CircleGeometry.js

@@ -67,7 +67,7 @@ THREE.CircleGeometry.prototype.clone = function () {
 		this.parameters.thetaLength
 	);
 
-	THREE.Geometry.prototype.clone.call( this, geometry );
+	THREE.Geometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/CylinderGeometry.js

@@ -184,7 +184,7 @@ THREE.CylinderGeometry.prototype.clone = function () {
 		this.parameters.thetaLength
 	);
 
-	THREE.Geometry.prototype.clone.call( this, geometry );
+	THREE.Geometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/DodecahedronGeometry.js

@@ -64,7 +64,7 @@ THREE.DodecahedronGeometry.prototype.clone = function () {
 		this.parameters.detail
 	);
 
-	THREE.PolyhedronGeometry.prototype.clone.call( this, geometry );
+	THREE.PolyhedronGeometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/IcosahedronGeometry.js

@@ -39,7 +39,7 @@ THREE.IcosahedronGeometry.prototype.clone = function () {
 		this.parameters.detail
 	);
 
-	THREE.PolyhedronGeometry.prototype.clone.call( this, geometry );
+	THREE.PolyhedronGeometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/OctahedronGeometry.js

@@ -32,7 +32,7 @@ THREE.OctahedronGeometry.prototype.clone = function () {
 		this.parameters.detail
 	);
 
-	THREE.PolyhedronGeometry.prototype.clone.call( this, geometry );
+	THREE.PolyhedronGeometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/PlaneBufferGeometry.js

@@ -104,7 +104,7 @@ THREE.PlaneBufferGeometry.prototype.clone = function () {
 		this.parameters.heightSegments
 	);
 
-	THREE.BufferGeometry.prototype.clone.call( this, geometry );
+	THREE.BufferGeometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/PlaneGeometry.js

@@ -32,7 +32,7 @@ THREE.PlaneGeometry.prototype.clone = function () {
 		this.parameters.heightSegments
 	);
 
-	THREE.Geometry.prototype.clone.call( this, geometry );
+	THREE.Geometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 12 - 11
src/extras/geometries/PolyhedronGeometry.js

@@ -234,21 +234,22 @@ THREE.PolyhedronGeometry = function ( vertices, indices, radius, detail ) {
 THREE.PolyhedronGeometry.prototype = Object.create( THREE.Geometry.prototype );
 THREE.PolyhedronGeometry.prototype.constructor = THREE.PolyhedronGeometry;
 
-THREE.PolyhedronGeometry.prototype.clone = function ( geometry ) {
+THREE.PolyhedronGeometry.prototype.clone = function () {
 
-	if ( geometry === undefined ) {
+	var geometry = new THREE.PolyhedronGeometry(
+		this.parameters.vertices,
+		this.parameters.indices,
+		this.parameters.radius,
+		this.parameters.detail
+	);
 
-		geometry = new THREE.PolyhedronGeometry(
-			this.parameters.vertices,
-			this.parameters.indices,
-			this.parameters.radius,
-			this.parameters.detail
-		);
+	return this.cloneProperties( geometry );
 
-	}
+};
 
-	THREE.Geometry.prototype.clone.call( this, geometry );
+THREE.PolyhedronGeometry.prototype.cloneProperties = function ( geometry ) {
 
+	THREE.Geometry.prototype.cloneProperties.call( this, geometry );
 	return geometry;
 
-};
+};

+ 1 - 1
src/extras/geometries/RingGeometry.js

@@ -92,7 +92,7 @@ THREE.RingGeometry.prototype.clone = function () {
 		this.parameters.thetaLength
 	);
 
-	THREE.Geometry.prototype.clone.call( this, geometry );
+	THREE.Geometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/SphereBufferGeometry.js

@@ -112,7 +112,7 @@ THREE.SphereBufferGeometry.prototype.clone = function () {
 		this.parameters.thetaLength
 	);
 
-	THREE.BufferGeometry.prototype.clone.call( this, geometry );
+	THREE.BufferGeometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/SphereGeometry.js

@@ -126,7 +126,7 @@ THREE.SphereGeometry.prototype.clone = function () {
 		this.parameters.thetaLength
 	);
 
-	THREE.Geometry.prototype.clone.call( this, geometry );
+	THREE.Geometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/TetrahedronGeometry.js

@@ -33,7 +33,7 @@ THREE.TetrahedronGeometry.prototype.clone = function () {
 		this.parameters.detail
 	);
 
-	THREE.PolyhedronGeometry.prototype.clone.call( this, geometry );
+	THREE.PolyhedronGeometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/TorusGeometry.js

@@ -88,7 +88,7 @@ THREE.TorusGeometry.prototype.clone = function () {
 		this.parameters.arc
 	);
 
-	THREE.Geometry.prototype.clone.call( this, geometry );
+	THREE.Geometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/extras/geometries/TorusKnotGeometry.js

@@ -124,7 +124,7 @@ THREE.TorusKnotGeometry.prototype.clone = function () {
 		this.parameters.heightScale
 	);
 
-	THREE.Geometry.prototype.clone.call( this, geometry );
+	THREE.Geometry.prototype.cloneProperties.call( this, geometry );
 
 	return geometry;
 

+ 1 - 1
src/lights/AmbientLight.js

@@ -17,7 +17,7 @@ THREE.AmbientLight.prototype.clone = function () {
 
 	var light = new THREE.AmbientLight();
 
-	THREE.Light.prototype.clone.call( this, light );
+	THREE.Light.prototype.cloneProperties.call( this, light );
 
 	return light;
 

+ 1 - 1
src/lights/AreaLight.js

@@ -31,7 +31,7 @@ THREE.AreaLight.prototype.clone = function () {
 
 	var light = new THREE.AreaLight();
 
-	THREE.Light.prototype.clone.call( this, light );
+	THREE.Light.prototype.cloneProperties.call( this, light );
 
 	light.normal.copy(this.normal);
 	light.right.copy(this.right);

+ 1 - 1
src/lights/DirectionalLight.js

@@ -67,7 +67,7 @@ THREE.DirectionalLight.prototype.clone = function () {
 
 	var light = new THREE.DirectionalLight();
 
-	THREE.Light.prototype.clone.call( this, light );
+	THREE.Light.prototype.cloneProperties.call( this, light );
 
 	light.target = this.target.clone();
 

+ 1 - 1
src/lights/HemisphereLight.js

@@ -22,7 +22,7 @@ THREE.HemisphereLight.prototype.clone = function () {
 
 	var light = new THREE.HemisphereLight();
 
-	THREE.Light.prototype.clone.call( this, light );
+	THREE.Light.prototype.cloneProperties.call( this, light );
 
 	light.groundColor.copy( this.groundColor );
 	light.intensity = this.intensity;

+ 8 - 4
src/lights/Light.js

@@ -8,7 +8,7 @@ THREE.Light = function ( color ) {
 	THREE.Object3D.call( this );
 
 	this.type = 'Light';
-	
+
 	this.color = new THREE.Color( color );
 
 };
@@ -16,12 +16,16 @@ THREE.Light = function ( color ) {
 THREE.Light.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Light.prototype.constructor = THREE.Light;
 
-THREE.Light.prototype.clone = function ( light ) {
+THREE.Light.prototype.clone = function () {
+
+	var light = new THREE.Light();
+	return this.cloneProperties( light );
 
-	if ( light === undefined ) light = new THREE.Light();
+};
 
-	THREE.Object3D.prototype.clone.call( this, light );
+THREE.Light.prototype.cloneProperties = function ( light ) {
 
+	THREE.Object3D.prototype.cloneProperties.call( this, light );
 	light.color.copy( this.color );
 
 	return light;

+ 1 - 1
src/lights/PointLight.js

@@ -21,7 +21,7 @@ THREE.PointLight.prototype.clone = function () {
 
 	var light = new THREE.PointLight();
 
-	THREE.Light.prototype.clone.call( this, light );
+	THREE.Light.prototype.cloneProperties.call( this, light );
 
 	light.intensity = this.intensity;
 	light.distance = this.distance;

+ 1 - 1
src/lights/SpotLight.js

@@ -50,7 +50,7 @@ THREE.SpotLight.prototype.clone = function () {
 
 	var light = new THREE.SpotLight();
 
-	THREE.Light.prototype.clone.call( this, light );
+	THREE.Light.prototype.cloneProperties.call( this, light );
 
 	light.target = this.target.clone();
 

+ 1 - 1
src/materials/LineBasicMaterial.js

@@ -47,7 +47,7 @@ THREE.LineBasicMaterial.prototype.clone = function () {
 
 	var material = new THREE.LineBasicMaterial();
 
-	THREE.Material.prototype.clone.call( this, material );
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.color.copy( this.color );
 

+ 1 - 1
src/materials/LineDashedMaterial.js

@@ -50,7 +50,7 @@ THREE.LineDashedMaterial.prototype.clone = function () {
 
 	var material = new THREE.LineDashedMaterial();
 
-	THREE.Material.prototype.clone.call( this, material );
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.color.copy( this.color );
 

+ 7 - 2
src/materials/Material.js

@@ -161,9 +161,14 @@ THREE.Material.prototype = {
 
 	},
 
-	clone: function ( material ) {
+	clone: function () {
 
-		if ( material === undefined ) material = new THREE.Material();
+		var material = new THREE.Material();
+		return this.cloneProperties( material );
+
+	},
+
+	cloneProperties: function ( material ) {
 
 		material.name = this.name;
 

+ 1 - 1
src/materials/MeshBasicMaterial.js

@@ -83,7 +83,7 @@ THREE.MeshBasicMaterial.prototype.clone = function () {
 
 	var material = new THREE.MeshBasicMaterial();
 
-	THREE.Material.prototype.clone.call( this, material );
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.color.copy( this.color );
 

+ 1 - 1
src/materials/MeshDepthMaterial.js

@@ -35,7 +35,7 @@ THREE.MeshDepthMaterial.prototype.clone = function () {
 
 	var material = new THREE.MeshDepthMaterial();
 
-	THREE.Material.prototype.clone.call( this, material );
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.wireframe = this.wireframe;
 	material.wireframeLinewidth = this.wireframeLinewidth;

+ 1 - 1
src/materials/MeshLambertMaterial.js

@@ -82,7 +82,7 @@ THREE.MeshLambertMaterial.prototype.clone = function () {
 
 	var material = new THREE.MeshLambertMaterial();
 
-	THREE.Material.prototype.clone.call( this, material );
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.color.copy( this.color );
 	material.emissive.copy( this.emissive );

+ 1 - 1
src/materials/MeshNormalMaterial.js

@@ -36,7 +36,7 @@ THREE.MeshNormalMaterial.prototype.clone = function () {
 
 	var material = new THREE.MeshNormalMaterial();
 
-	THREE.Material.prototype.clone.call( this, material );
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.wireframe = this.wireframe;
 	material.wireframeLinewidth = this.wireframeLinewidth;

+ 1 - 1
src/materials/MeshPhongMaterial.js

@@ -116,7 +116,7 @@ THREE.MeshPhongMaterial.prototype.clone = function () {
 
 	var material = new THREE.MeshPhongMaterial();
 
-	THREE.Material.prototype.clone.call( this, material );
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.color.copy( this.color );
 	material.emissive.copy( this.emissive );

+ 1 - 1
src/materials/PointCloudMaterial.js

@@ -48,7 +48,7 @@ THREE.PointCloudMaterial.prototype.clone = function () {
 
 	var material = new THREE.PointCloudMaterial();
 
-	THREE.Material.prototype.clone.call( this, material );
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.color.copy( this.color );
 

+ 1 - 1
src/materials/RawShaderMaterial.js

@@ -17,7 +17,7 @@ THREE.RawShaderMaterial.prototype.clone = function () {
 
 	var material = new THREE.RawShaderMaterial();
 
-	THREE.ShaderMaterial.prototype.clone.call( this, material );
+	THREE.ShaderMaterial.prototype.cloneProperties.call( this, material );
 
 	return material;
 

+ 8 - 3
src/materials/ShaderMaterial.js

@@ -89,11 +89,16 @@ THREE.ShaderMaterial = function ( parameters ) {
 THREE.ShaderMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.ShaderMaterial.prototype.constructor = THREE.ShaderMaterial;
 
-THREE.ShaderMaterial.prototype.clone = function ( material ) {
+THREE.ShaderMaterial.prototype.clone = function () {
 
-	if ( material === undefined ) material = new THREE.ShaderMaterial();
+	var material = new THREE.ShaderMaterial();
+	return this.clone( material );
 
-	THREE.Material.prototype.clone.call( this, material );
+};
+
+THREE.ShaderMaterial.prototype.cloneProperties = function ( material ) {
+
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.fragmentShader = this.fragmentShader;
 	material.vertexShader = this.vertexShader;

+ 1 - 1
src/materials/SpriteMaterial.js

@@ -43,7 +43,7 @@ THREE.SpriteMaterial.prototype.clone = function () {
 
 	var material = new THREE.SpriteMaterial();
 
-	THREE.Material.prototype.clone.call( this, material );
+	THREE.Material.prototype.cloneProperties.call( this, material );
 
 	material.color.copy( this.color );
 	material.map = this.map;

+ 11 - 6
src/objects/Bone.js

@@ -17,13 +17,18 @@ THREE.Bone = function ( skin ) {
 THREE.Bone.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Bone.prototype.constructor = THREE.Bone;
 
-THREE.Bone.prototype.clone = function ( object ) {
+THREE.Bone.prototype.clone = function () {
 
-	if ( object === undefined ) object = new THREE.Bone( this.skin );
+	var bone = new THREE.Bone( this.skin );
+	return this.cloneProperties( bone );
 
-	THREE.Object3D.prototype.clone.call( this, object );
-	object.skin = this.skin; 
+};
+
+THREE.Bone.prototype.cloneProperties = function ( bone ) {
 
-	return object;
+	THREE.Object3D.prototype.cloneProperties.call( this, bone );
+	bone.skin = this.skin;
 
-};
+	return bone;
+
+};

+ 9 - 5
src/objects/Group.js

@@ -13,12 +13,16 @@ THREE.Group = function () {
 THREE.Group.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Group.prototype.constructor = THREE.Group;
 
-THREE.Group.prototype.clone = function ( object ) {
+THREE.Group.prototype.clone = function () {
 
-	if ( object === undefined ) object = new THREE.Group();
+	var group = new THREE.Group();
+	return this.cloneProperties( group );
 
-	THREE.Object3D.prototype.clone.call( this, object );
+};
+
+THREE.Group.prototype.cloneProperties = function ( group ) {
 
-	return object;
+	THREE.Object3D.prototype.cloneProperties.call( this, group );
+	return group;
 
-};
+};

+ 11 - 5
src/objects/LOD.js

@@ -130,11 +130,17 @@ THREE.LOD.prototype.update = function () {
 
 }();
 
-THREE.LOD.prototype.clone = function ( object ) {
+THREE.LOD.prototype.clone = function () {
 
-	if ( object === undefined ) object = new THREE.LOD();
+	var lod = new THREE.LOD();
+	return this.cloneProperties( lod );
 
-	THREE.Object3D.prototype.clone.call( this, object, false );
+};
+
+
+THREE.LOD.prototype.cloneProperties = function ( lod ) {
+
+	THREE.Object3D.prototype.cloneProperties.call( this, lod, false );
 
 	var levels = this.levels;
 
@@ -142,10 +148,10 @@ THREE.LOD.prototype.clone = function ( object ) {
 
 		var level = levels[ i ];
 
-		object.addLevel( level.object.clone(), level.distance );
+		lod.addLevel( level.object.clone(), level.distance );
 
 	}
 
-	return object;
+	return lod;
 
 };

+ 13 - 8
src/objects/LensFlare.js

@@ -78,21 +78,26 @@ THREE.LensFlare.prototype.updateLensFlares = function () {
 
 };
 
-THREE.LensFlare.prototype.clone = function ( object ) {
+THREE.LensFlare.prototype.clone = function () {
 
-	if ( object === undefined ) object = new THREE.LensFlare();
+	var flare = new THREE.LensFlare();
+	return this.cloneProperties( flare );
 
-	THREE.Object3D.prototype.clone.call( this, object );
+};
+
+THREE.LensFlare.prototype.cloneProperties = function ( flare ) {
 
-	object.positionScreen.copy( this.positionScreen );
-	object.customUpdateCallback = this.customUpdateCallback;
+	THREE.Object3D.prototype.cloneProperties.call( this, flare );
+
+	flare.positionScreen.copy( this.positionScreen );
+	flare.customUpdateCallback = this.customUpdateCallback;
 
 	for ( var i = 0, l = this.lensFlares.length; i < l; i ++ ) {
 
-		object.lensFlares.push( this.lensFlares[ i ] );
+		flare.lensFlares.push( this.lensFlares[ i ] );
 
 	}
 
-	return object;
+	return flare;
 
-};
+};

+ 8 - 4
src/objects/Line.js

@@ -183,13 +183,17 @@ THREE.Line.prototype.raycast = ( function () {
 
 }() );
 
-THREE.Line.prototype.clone = function ( object ) {
+THREE.Line.prototype.clone = function () {
 
-	if ( object === undefined ) object = new THREE[ this.type ]( this.geometry, this.material );
+	var line = new THREE.Line( this.geometry, this.material );
+	return this.cloneProperties( line );
 
-	THREE.Object3D.prototype.clone.call( this, object );
+};
+
+THREE.Line.prototype.cloneProperties = function ( line ) {
 
-	return object;
+	THREE.Object3D.prototype.cloneProperties.call( this, line );
+	return line;
 
 };
 

+ 4 - 4
src/objects/LineSegments.js

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

+ 9 - 4
src/objects/Mesh.js

@@ -305,13 +305,18 @@ THREE.Mesh.prototype.raycast = ( function () {
 
 }() );
 
-THREE.Mesh.prototype.clone = function ( object, recursive ) {
+THREE.Mesh.prototype.clone = function ( recursive ) {
 
-	if ( object === undefined ) object = new THREE.Mesh( this.geometry, this.material );
+	var mesh = new THREE.Mesh( this.geometry, this.material );
+	return this.cloneProperties( mesh );
 
-	THREE.Object3D.prototype.clone.call( this, object, recursive );
+};
+
+THREE.Mesh.prototype.cloneProperties = function ( mesh, recursive ) {
+
+	THREE.Object3D.prototype.cloneProperties.call( this, mesh, recursive );
 
-	return object;
+	return mesh;
 
 };
 

+ 16 - 11
src/objects/MorphAnimMesh.js

@@ -192,22 +192,27 @@ THREE.MorphAnimMesh.prototype.interpolateTargets = function ( a, b, t ) {
 
 };
 
-THREE.MorphAnimMesh.prototype.clone = function ( object ) {
+THREE.MorphAnimMesh.prototype.clone = function () {
 
-	if ( object === undefined ) object = new THREE.MorphAnimMesh( this.geometry, this.material );
+	var morph = new THREE.MorphAnimMesh( this.geometry, this.material );
+	return this.cloneProperties( morph );
 
-	object.duration = this.duration;
-	object.mirroredLoop = this.mirroredLoop;
-	object.time = this.time;
+};
+
+THREE.MorphAnimMesh.prototype.cloneProperties = function ( morph ) {
+
+	morph.duration = this.duration;
+	morph.mirroredLoop = this.mirroredLoop;
+	morph.time = this.time;
 
-	object.lastKeyframe = this.lastKeyframe;
-	object.currentKeyframe = this.currentKeyframe;
+	morph.lastKeyframe = this.lastKeyframe;
+	morph.currentKeyframe = this.currentKeyframe;
 
-	object.direction = this.direction;
-	object.directionBackwards = this.directionBackwards;
+	morph.direction = this.direction;
+	morph.directionBackwards = this.directionBackwards;
 
-	THREE.Mesh.prototype.clone.call( this, object );
+	THREE.Mesh.prototype.cloneProperties.call( this, morph );
 
-	return object;
+	return morph;
 
 };

+ 8 - 4
src/objects/PointCloud.js

@@ -136,13 +136,17 @@ THREE.PointCloud.prototype.raycast = ( function () {
 
 }() );
 
-THREE.PointCloud.prototype.clone = function ( object ) {
+THREE.PointCloud.prototype.clone = function () {
 
-	if ( object === undefined ) object = new THREE.PointCloud( this.geometry, this.material );
+	var pointCloud = new THREE.PointCloud( this.geometry, this.material );
+	return this.cloneProperties( pointCloud );
 
-	THREE.Object3D.prototype.clone.call( this, object );
+};
+
+THREE.PointCloud.prototype.cloneProperties = function ( pointCloud ) {
 
-	return object;
+	THREE.Object3D.prototype.cloneProperties.call( this, pointCloud );
+	return pointCloud;
 
 };
 

+ 7 - 8
src/objects/SkinnedMesh.js

@@ -154,17 +154,16 @@ THREE.SkinnedMesh.prototype.updateMatrixWorld = function( force ) {
 
 };
 
-THREE.SkinnedMesh.prototype.clone = function( object ) {
+THREE.SkinnedMesh.prototype.clone = function() {
 
-	if ( object === undefined ) {
+	var skinMesh = new THREE.SkinnedMesh( this.geometry, this.material, this.useVertexTexture );
+	return this.cloneProperties( skinMesh );
 
-		object = new THREE.SkinnedMesh( this.geometry, this.material, this.useVertexTexture );
-
-	}
+};
 
-	THREE.Mesh.prototype.clone.call( this, object );
+THREE.SkinnedMesh.prototype.cloneProperties = function( skinMesh ) {
 
-	return object;
+	THREE.Mesh.prototype.cloneProperties.call( this, skinMesh );
+	return skinMesh;
 
 };
-

+ 9 - 5
src/objects/Sprite.js

@@ -40,7 +40,7 @@ THREE.Sprite.prototype.raycast = ( function () {
 
 		var distanceSq = raycaster.ray.distanceSqToPoint( matrixPosition );
 		var guessSizeSq = this.scale.x * this.scale.y;
-		
+
 		if ( distanceSq > guessSizeSq ) {
 
 			return;
@@ -60,13 +60,17 @@ THREE.Sprite.prototype.raycast = ( function () {
 
 }() );
 
-THREE.Sprite.prototype.clone = function ( object ) {
+THREE.Sprite.prototype.clone = function () {
+
+	var sprite = new THREE.Sprite( this.material );
+	return this.cloneProperties( sprite );
 
-	if ( object === undefined ) object = new THREE.Sprite( this.material );
+};
 
-	THREE.Object3D.prototype.clone.call( this, object );
+THREE.Sprite.prototype.cloneProperties = function ( sprite ) {
 
-	return object;
+	THREE.Object3D.prototype.cloneProperties.call( this, sprite );
+	return sprite;
 
 };
 

+ 15 - 8
src/scenes/Scene.js

@@ -18,18 +18,25 @@ THREE.Scene = function () {
 THREE.Scene.prototype = Object.create( THREE.Object3D.prototype );
 THREE.Scene.prototype.constructor = THREE.Scene;
 
-THREE.Scene.prototype.clone = function ( object ) {
+THREE.Scene.prototype.clone = function () {
 
-	if ( object === undefined ) object = new THREE.Scene();
+	var scene = new THREE.Scene();
+	return this.cloneProperties( scene );
 
-	THREE.Object3D.prototype.clone.call( this, object );
+};
+
+THREE.Scene.prototype.cloneProperties = function ( scene ) {
+
+	if ( scene === undefined ) scene = new THREE.Scene();
+
+	THREE.Object3D.prototype.cloneProperties.call( this, scene );
 
-	if ( this.fog !== null ) object.fog = this.fog.clone();
-	if ( this.overrideMaterial !== null ) object.overrideMaterial = this.overrideMaterial.clone();
+	if ( this.fog !== null ) scene.fog = this.fog.clone();
+	if ( this.overrideMaterial !== null ) scene.overrideMaterial = this.overrideMaterial.clone();
 
-	object.autoUpdate = this.autoUpdate;
-	object.matrixAutoUpdate = this.matrixAutoUpdate;
+	scene.autoUpdate = this.autoUpdate;
+	scene.matrixAutoUpdate = this.matrixAutoUpdate;
 
-	return object;
+	return scene;
 
 };

+ 1 - 1
src/textures/CompressedTexture.js

@@ -28,7 +28,7 @@ THREE.CompressedTexture.prototype.clone = function () {
 
 	var texture = new THREE.CompressedTexture();
 
-	THREE.Texture.prototype.clone.call( this, texture );
+	THREE.Texture.prototype.cloneProperties.call( this, texture );
 
 	return texture;
 

+ 1 - 1
src/textures/CubeTexture.js

@@ -20,7 +20,7 @@ THREE.CubeTexture.clone = function ( texture ) {
 
 	if ( texture === undefined ) texture = new THREE.CubeTexture();
 
-	THREE.Texture.prototype.clone.call( this, texture );
+	THREE.Texture.prototype.cloneProperties.call( this, texture );
 
 	texture.images = this.images;
 

+ 1 - 1
src/textures/DataTexture.js

@@ -17,7 +17,7 @@ THREE.DataTexture.prototype.clone = function () {
 
 	var texture = new THREE.DataTexture();
 
-	THREE.Texture.prototype.clone.call( this, texture );
+	THREE.Texture.prototype.cloneProperties.call( this, texture );
 
 	return texture;
 

+ 7 - 2
src/textures/Texture.js

@@ -63,9 +63,14 @@ THREE.Texture.prototype = {
 
 	},
 
-	clone: function ( texture ) {
+	clone: function () {
 
-		if ( texture === undefined ) texture = new THREE.Texture();
+		var texture = new THREE.Texture();
+		return this.cloneProperties( texture );
+
+	},
+
+	cloneProperties: function ( texture ) {
 
 		texture.image = this.image;
 		texture.mipmaps = this.mipmaps.slice( 0 );