From 4b962fa473f6ef7f2de90db660562f03bf38497d Mon Sep 17 00:00:00 2001 From: libra guest Date: Mon, 6 Aug 2012 05:48:29 -0400 Subject: [PATCH] add material.clone --- src/core/Color.js | 1 + src/materials/LineBasicMaterial.js | 7 +++++++ src/materials/Material.js | 5 +++++ src/materials/MeshBasicMaterial.js | 6 ++++++ src/materials/MeshDepthMaterial.js | 5 +++++ src/materials/MeshFaceMaterial.js | 7 +++++++ src/materials/MeshLambertMaterial.js | 6 ++++++ src/materials/MeshNormalMaterial.js | 6 ++++++ src/materials/MeshPhongMaterial.js | 7 +++++++ src/materials/ParticleBasicMaterial.js | 5 +++++ src/materials/ParticleCanvasMaterial.js | 5 +++++ src/materials/ParticleDOMMaterial.js | 6 ++++++ src/materials/ShaderMaterial.js | 6 ++++++ 13 files changed, 72 insertions(+) diff --git a/src/core/Color.js b/src/core/Color.js index 9dee60ca2a..3b6e05fd69 100644 --- a/src/core/Color.js +++ b/src/core/Color.js @@ -4,6 +4,7 @@ THREE.Color = function ( hex ) { + if ( hex instanceof THREE.Color ) return this.clone(); if ( hex !== undefined ) this.setHex( hex ); return this; diff --git a/src/materials/LineBasicMaterial.js b/src/materials/LineBasicMaterial.js index 24d6fbe0ac..38e88f3b29 100644 --- a/src/materials/LineBasicMaterial.js +++ b/src/materials/LineBasicMaterial.js @@ -38,3 +38,10 @@ THREE.LineBasicMaterial = function ( parameters ) { }; THREE.LineBasicMaterial.prototype = Object.create( THREE.Material.prototype ); + + +THREE.LineBasicMaterial.prototype.clone = function(){ + var returnValue = new THREE.LineBasicMaterial(this); + return returnValue; +}; + diff --git a/src/materials/Material.js b/src/materials/Material.js index 26097ec0ef..d38c5f469e 100644 --- a/src/materials/Material.js +++ b/src/materials/Material.js @@ -39,4 +39,9 @@ THREE.Material = function ( parameters ) { } +THREE.Material.prototype.clone = function(){ + var returnValue = new THREE.Material(this); + return returnValue; +}; + THREE.MaterialCount = 0; diff --git a/src/materials/MeshBasicMaterial.js b/src/materials/MeshBasicMaterial.js index 28de48c125..41bfe0fc4e 100644 --- a/src/materials/MeshBasicMaterial.js +++ b/src/materials/MeshBasicMaterial.js @@ -66,3 +66,9 @@ THREE.MeshBasicMaterial = function ( parameters ) { }; THREE.MeshBasicMaterial.prototype = Object.create( THREE.Material.prototype ); + + +THREE.MeshBasicMaterial.prototype.clone = function(){ + var returnValue = new THREE.MeshBasicMaterial(this); + return returnValue; +}; diff --git a/src/materials/MeshDepthMaterial.js b/src/materials/MeshDepthMaterial.js index 5368e52b27..0baeecbcf8 100644 --- a/src/materials/MeshDepthMaterial.js +++ b/src/materials/MeshDepthMaterial.js @@ -27,3 +27,8 @@ THREE.MeshDepthMaterial = function ( parameters ) { }; THREE.MeshDepthMaterial.prototype = Object.create( THREE.Material.prototype ); + +THREE.MeshDepthMaterial.prototype.clone = function(){ + var returnValue = new THREE.MeshDepthMaterial(this); + return returnValue; +}; diff --git a/src/materials/MeshFaceMaterial.js b/src/materials/MeshFaceMaterial.js index a9d752f572..1bb8f8cbae 100644 --- a/src/materials/MeshFaceMaterial.js +++ b/src/materials/MeshFaceMaterial.js @@ -7,3 +7,10 @@ THREE.MeshFaceMaterial = function ( parameters ) { THREE.Material.call( this, parameters ); }; + + + +THREE.MeshFaceMaterial.prototype.clone = function(){ + var returnValue = new THREE.MeshFaceMaterial(this); + return returnValue; +}; \ No newline at end of file diff --git a/src/materials/MeshLambertMaterial.js b/src/materials/MeshLambertMaterial.js index 68dda61797..5479b49a8c 100644 --- a/src/materials/MeshLambertMaterial.js +++ b/src/materials/MeshLambertMaterial.js @@ -76,3 +76,9 @@ THREE.MeshLambertMaterial = function ( parameters ) { }; THREE.MeshLambertMaterial.prototype = Object.create( THREE.Material.prototype ); + +THREE.MeshLambertMaterial.prototype.clone = function(){ + var returnValue = new THREE.MeshLambertMaterial(this); + returnValue.wrapRGB = this.wrapRGB.clone(); + return returnValue; +}; diff --git a/src/materials/MeshNormalMaterial.js b/src/materials/MeshNormalMaterial.js index 1936085883..53b6af1be2 100644 --- a/src/materials/MeshNormalMaterial.js +++ b/src/materials/MeshNormalMaterial.js @@ -27,3 +27,9 @@ THREE.MeshNormalMaterial = function ( parameters ) { }; THREE.MeshNormalMaterial.prototype = Object.create( THREE.Material.prototype ); + + +THREE.MeshNormalMaterial.prototype.clone = function(){ + var returnValue = new THREE.MeshNormalMaterial(this); + return returnValue; +}; \ No newline at end of file diff --git a/src/materials/MeshPhongMaterial.js b/src/materials/MeshPhongMaterial.js index 5f4a051023..7cf5ad8330 100644 --- a/src/materials/MeshPhongMaterial.js +++ b/src/materials/MeshPhongMaterial.js @@ -83,3 +83,10 @@ THREE.MeshPhongMaterial = function ( parameters ) { }; THREE.MeshPhongMaterial.prototype = Object.create( THREE.Material.prototype ); + + +THREE.MeshPhongMaterial.prototype.clone = function(){ + var returnValue = new THREE.MeshPhongMaterial(this); + returnValue.wrapRGB = this.wrapRGB.clone(); + return returnValue; +}; diff --git a/src/materials/ParticleBasicMaterial.js b/src/materials/ParticleBasicMaterial.js index a13f9e3116..62343d7911 100644 --- a/src/materials/ParticleBasicMaterial.js +++ b/src/materials/ParticleBasicMaterial.js @@ -38,3 +38,8 @@ THREE.ParticleBasicMaterial = function ( parameters ) { }; THREE.ParticleBasicMaterial.prototype = Object.create( THREE.Material.prototype ); + +THREE.ParticleBasicMaterial.prototype.clone = function(){ + var returnValue = new THREE.ParticleBasicMaterial(this); + return returnValue; +}; \ No newline at end of file diff --git a/src/materials/ParticleCanvasMaterial.js b/src/materials/ParticleCanvasMaterial.js index 4bd2a77e74..ac656e62c5 100644 --- a/src/materials/ParticleCanvasMaterial.js +++ b/src/materials/ParticleCanvasMaterial.js @@ -21,3 +21,8 @@ THREE.ParticleCanvasMaterial = function ( parameters ) { }; THREE.ParticleCanvasMaterial.prototype = Object.create( THREE.Material.prototype ); + +THREE.ParticleCanvasMaterial.prototype.clone = function(){ + var returnValue = new THREE.ParticleCanvasMaterial(this); + return returnValue; +}; \ No newline at end of file diff --git a/src/materials/ParticleDOMMaterial.js b/src/materials/ParticleDOMMaterial.js index 13012a8536..854832a762 100644 --- a/src/materials/ParticleDOMMaterial.js +++ b/src/materials/ParticleDOMMaterial.js @@ -9,3 +9,9 @@ THREE.ParticleDOMMaterial = function ( domElement ) { this.domElement = domElement; }; + + +THREE.ParticleDOMMaterial.prototype.clone = function(){ + var returnValue = new THREE.ParticleDOMMaterial(this); + return returnValue; +}; \ No newline at end of file diff --git a/src/materials/ShaderMaterial.js b/src/materials/ShaderMaterial.js index 38f80e2384..1a479dfb1a 100644 --- a/src/materials/ShaderMaterial.js +++ b/src/materials/ShaderMaterial.js @@ -56,3 +56,9 @@ THREE.ShaderMaterial = function ( parameters ) { }; THREE.ShaderMaterial.prototype = Object.create( THREE.Material.prototype ); + + +THREE.ShaderMaterial.prototype.clone = function(){ + var returnValue = new THREE.ShaderMaterial(this); + return returnValue; +}; -- GitLab