Jelajahi Sumber

Refactored materials code.

Mr.doob 13 tahun lalu
induk
melakukan
4845632e15

+ 14 - 18
build/Three.js

@@ -189,24 +189,20 @@ THREE.FaceColors;else if(x.parameters[H])x.parameters[H]=THREE.VertexColors;if(x
 x.parameters.map;a.enableDiffuse.value=true}if(x.parameters.lightMap){a.tAO.texture=x.parameters.lightMap;a.enableAO.value=true}if(x.parameters.specularMap){a.tSpecular.texture=N.textures[x.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(l);a.uSpecularColor.value.setHex(o);a.uAmbientColor.value.setHex(Z);a.uShininess.value=c;if(x.parameters.opacity)a.uOpacity.value=x.parameters.opacity;M=new THREE.ShaderMaterial({fragmentShader:q.fragmentShader,vertexShader:q.vertexShader,
 x.parameters.map;a.enableDiffuse.value=true}if(x.parameters.lightMap){a.tAO.texture=x.parameters.lightMap;a.enableAO.value=true}if(x.parameters.specularMap){a.tSpecular.texture=N.textures[x.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(l);a.uSpecularColor.value.setHex(o);a.uAmbientColor.value.setHex(Z);a.uShininess.value=c;if(x.parameters.opacity)a.uOpacity.value=x.parameters.opacity;M=new THREE.ShaderMaterial({fragmentShader:q.fragmentShader,vertexShader:q.vertexShader,
 uniforms:a,lights:true,fog:true})}else M=new THREE[x.type](x.parameters);N.materials[m]=M}e(N.scene,B.objects);i.callbackSync(N);h()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
 uniforms:a,lights:true,fog:true})}else M=new THREE[x.type](x.parameters);N.materials[m]=M}e(N.scene,B.objects);i.callbackSync(N);h()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
 THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=true;b.dispatchEvent({type:"load",content:a})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};
 THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=true;b.dispatchEvent({type:"load",content:a})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};
-THREE.Material=function(a){a=a||{};this.id=THREE.MaterialCount++;this.name="";this.side=a.side!==void 0?a.side:THREE.FrontSide;this.opacity=a.opacity!==void 0?a.opacity:1;this.transparent=a.transparent!==void 0?a.transparent:false;this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.blendSrc=a.blendSrc!==void 0?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=a.blendDst!==void 0?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=a.blendEquation!==void 0?a.blendEquation:THREE.AddEquation;
-this.depthTest=a.depthTest!==void 0?a.depthTest:true;this.depthWrite=a.depthWrite!==void 0?a.depthWrite:true;this.polygonOffset=a.polygonOffset!==void 0?a.polygonOffset:false;this.polygonOffsetFactor=a.polygonOffsetFactor!==void 0?a.polygonOffsetFactor:0;this.polygonOffsetUnits=a.polygonOffsetUnits!==void 0?a.polygonOffsetUnits:0;this.alphaTest=a.alphaTest!==void 0?a.alphaTest:0;this.overdraw=a.overdraw!==void 0?a.overdraw:false;this.visible=a.visible!==void 0?a.visible:true;this.needsUpdate=true};
-THREE.MaterialCount=0;THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=a.linewidth!==void 0?a.linewidth:1;this.linecap=a.linecap!==void 0?a.linecap:"round";this.linejoin=a.linejoin!==void 0?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:false;this.fog=a.fog!==void 0?a.fog:true};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:
-true;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==
-void 0?a.morphTargets:false};THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshLambertMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=a.emissive!==void 0?new THREE.Color(a.emissive):new THREE.Color(0);this.wrapAround=a.wrapAround!==void 0?a.wrapAround:false;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=
-a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:true;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?
-a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshPhongMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=a.emissive!==void 0?new THREE.Color(a.emissive):new THREE.Color(0);this.specular=a.specular!==void 0?new THREE.Color(a.specular):new THREE.Color(1118481);this.shininess=a.shininess!==void 0?a.shininess:30;this.metal=a.metal!==void 0?a.metal:false;this.perPixel=
-a.perPixel!==void 0?a.perPixel:false;this.wrapAround=a.wrapAround!==void 0?a.wrapAround:false;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:true;this.shading=
-a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?
-a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshFaceMaterial=function(a){THREE.Material.call(this,a)};
-THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:true;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:false;this.fog=a.fog!==void 0?a.fog:true};THREE.ParticleBasicMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.program=a.program!==void 0?a.program:function(){}};THREE.ParticleCanvasMaterial.prototype=Object.create(THREE.Material.prototype);THREE.ParticleDOMMaterial=function(a){THREE.Material.call(this);this.domElement=a};
-THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=a.fragmentShader!==void 0?a.fragmentShader:"void main() {}";this.vertexShader=a.vertexShader!==void 0?a.vertexShader:"void main() {}";this.uniforms=a.uniforms!==void 0?a.uniforms:{};this.attributes=a.attributes;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.fog=
-a.fog!==void 0?a.fog:false;this.lights=a.lights!==void 0?a.lights:false;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype);
+THREE.Material=function(){this.id=THREE.MaterialCount++;this.name="";this.side=THREE.FrontSide;this.opacity=1;this.transparent=false;this.blending=THREE.NormalBlending;this.blendSrc=THREE.SrcAlphaFactor;this.blendDst=THREE.OneMinusSrcAlphaFactor;this.blendEquation=THREE.AddEquation;this.depthWrite=this.depthTest=true;this.polygonOffset=false;this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.overdraw=false;this.needsUpdate=this.visible=true};
+THREE.Material.prototype.setParameters=function(a){a===void 0&&(a={});for(var b in a){var c=a[b];if(this[b]!==void 0)switch(b){case "color":case "ambient":case "emissive":case "specular":c instanceof THREE.Color?this[b].copy(c):this[b].setHex(c);break;case "wrapRGB":this[b].copy(c);break;default:this[b]=c}}};THREE.Material.prototype.clone=function(){return new THREE.Material(this)};THREE.MaterialCount=0;
+THREE.LineBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=false;this.fog=true;this.setParameters(a)};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);THREE.LineBasicMaterial.prototype.clone=function(){return new THREE.LineBasicMaterial(this)};
+THREE.MeshBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);
+THREE.MeshBasicMaterial.prototype.clone=function(){return new THREE.MeshBasicMaterial(this)};
+THREE.MeshLambertMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(16777215);this.emissive=new THREE.Color(0);this.wrapAround=false;this.wrapRGB=new THREE.Vector3(1,1,1);this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";
+this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshLambertMaterial.prototype.clone=function(){var a=new THREE.MeshLambertMaterial(this);a.wrapRGB=this.wrapRGB.clone();return a};
+THREE.MeshPhongMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(16777215);this.emissive=new THREE.Color(0);this.specular=new THREE.Color(1118481);this.shininess=30;this.wrapAround=this.perPixel=this.metal=false;this.wrapRGB=new THREE.Vector3(1,1,1);this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;
+this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshPhongMaterial.prototype.clone=function(){var a=new THREE.MeshPhongMaterial(this);a.wrapRGB=this.wrapRGB.clone();return a};
+THREE.MeshDepthMaterial=function(a){THREE.Material.call(this);this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.setParameters(a)};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial.prototype.clone=function(){return new THREE.MeshDepthMaterial(this)};THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);this.shading=THREE.FlatShading;this.wireframe=false;this.wireframeLinewidth=1;this.setParameters(a)};
+THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshNormalMaterial.prototype.clone=function(){return new THREE.MeshNormalMaterial(this)};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype.clone=function(){return new THREE.MeshFaceMaterial};THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.map=null;this.size=1;this.sizeAttenuation=true;this.vertexColors=false;this.fog=true;this.setParameters(a)};
+THREE.ParticleBasicMaterial.prototype=Object.create(THREE.Material.prototype);THREE.ParticleBasicMaterial.prototype.clone=function(){return new THREE.ParticleBasicMaterial(this)};THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.program=function(){};this.setParameters(a)};THREE.ParticleCanvasMaterial.prototype=Object.create(THREE.Material.prototype);THREE.ParticleCanvasMaterial.prototype.clone=function(){return new THREE.ParticleCanvasMaterial(this)};
+THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype.clone=function(){return new THREE.ParticleDOMMaterial(this.domElement)};
+THREE.ShaderMaterial=function(a){THREE.Material.call(this);this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.attributes=null;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.lights=this.fog=false;this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype);THREE.ShaderMaterial.prototype.clone=function(){return new THREE.ShaderMaterial(this)};
 THREE.Texture=function(a,b,c,d,e,f,g,h,i){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==void 0?e:THREE.LinearFilter;this.minFilter=f!==void 0?f:THREE.LinearMipMapLinearFilter;this.anisotropy=i!==void 0?i:1;this.format=g!==void 0?g:THREE.RGBAFormat;this.type=h!==void 0?h:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=
 THREE.Texture=function(a,b,c,d,e,f,g,h,i){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==void 0?e:THREE.LinearFilter;this.minFilter=f!==void 0?f:THREE.LinearMipMapLinearFilter;this.anisotropy=i!==void 0?i:1;this.format=g!==void 0?g:THREE.RGBAFormat;this.type=h!==void 0?h:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=
 new THREE.Vector2(1,1);this.generateMipmaps=true;this.premultiplyAlpha=false;this.flipY=true;this.needsUpdate=false;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type,this.anisotropy);a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.generateMipmaps=this.generateMipmaps;a.premultiplyAlpha=this.premultiplyAlpha;a.flipY=this.flipY;return a}};
 new THREE.Vector2(1,1);this.generateMipmaps=true;this.premultiplyAlpha=false;this.flipY=true;this.needsUpdate=false;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type,this.anisotropy);a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.generateMipmaps=this.generateMipmaps;a.premultiplyAlpha=this.premultiplyAlpha;a.flipY=this.flipY;return a}};
 THREE.TextureCount=0;THREE.DataTexture=function(a,b,c,d,e,f,g,h,i,j){THREE.Texture.call(this,null,f,g,h,i,j,d,e);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};
 THREE.TextureCount=0;THREE.DataTexture=function(a,b,c,d,e,f,g,h,i,j){THREE.Texture.call(this,null,f,g,h,i,j,d,e);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};

+ 12 - 16
build/custom/ThreeCanvas.js

@@ -182,22 +182,18 @@ THREE.FaceColors;else if(u.parameters[w])u.parameters[w]=THREE.VertexColors;if(u
 u.parameters.map;a.enableDiffuse.value=true}if(u.parameters.lightMap){a.tAO.texture=u.parameters.lightMap;a.enableAO.value=true}if(u.parameters.specularMap){a.tSpecular.texture=z.textures[u.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(h);a.uSpecularColor.value.setHex(l);a.uAmbientColor.value.setHex(N);a.uShininess.value=c;if(u.parameters.opacity)a.uOpacity.value=u.parameters.opacity;K=new THREE.ShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,
 u.parameters.map;a.enableDiffuse.value=true}if(u.parameters.lightMap){a.tAO.texture=u.parameters.lightMap;a.enableAO.value=true}if(u.parameters.specularMap){a.tSpecular.texture=z.textures[u.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(h);a.uSpecularColor.value.setHex(l);a.uAmbientColor.value.setHex(N);a.uShininess.value=c;if(u.parameters.opacity)a.uOpacity.value=u.parameters.opacity;K=new THREE.ShaderMaterial({fragmentShader:p.fragmentShader,vertexShader:p.vertexShader,
 uniforms:a,lights:true,fog:true})}else K=new THREE[u.type](u.parameters);z.materials[n]=K}f(z.scene,t.objects);m.callbackSync(z);j()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
 uniforms:a,lights:true,fog:true})}else K=new THREE[u.type](u.parameters);z.materials[n]=K}f(z.scene,t.objects);m.callbackSync(z);j()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
 THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=true;b.dispatchEvent({type:"load",content:a})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};
 THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=true;b.dispatchEvent({type:"load",content:a})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};
-THREE.Material=function(a){a=a||{};this.id=THREE.MaterialCount++;this.name="";this.side=a.side!==void 0?a.side:THREE.FrontSide;this.opacity=a.opacity!==void 0?a.opacity:1;this.transparent=a.transparent!==void 0?a.transparent:false;this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.blendSrc=a.blendSrc!==void 0?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=a.blendDst!==void 0?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=a.blendEquation!==void 0?a.blendEquation:THREE.AddEquation;
-this.depthTest=a.depthTest!==void 0?a.depthTest:true;this.depthWrite=a.depthWrite!==void 0?a.depthWrite:true;this.polygonOffset=a.polygonOffset!==void 0?a.polygonOffset:false;this.polygonOffsetFactor=a.polygonOffsetFactor!==void 0?a.polygonOffsetFactor:0;this.polygonOffsetUnits=a.polygonOffsetUnits!==void 0?a.polygonOffsetUnits:0;this.alphaTest=a.alphaTest!==void 0?a.alphaTest:0;this.overdraw=a.overdraw!==void 0?a.overdraw:false;this.visible=a.visible!==void 0?a.visible:true;this.needsUpdate=true};
-THREE.MaterialCount=0;THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=a.linewidth!==void 0?a.linewidth:1;this.linecap=a.linecap!==void 0?a.linecap:"round";this.linejoin=a.linejoin!==void 0?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:false;this.fog=a.fog!==void 0?a.fog:true};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:
-true;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==
-void 0?a.morphTargets:false};THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshLambertMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=a.emissive!==void 0?new THREE.Color(a.emissive):new THREE.Color(0);this.wrapAround=a.wrapAround!==void 0?a.wrapAround:false;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=
-a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:true;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?
-a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshPhongMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=a.emissive!==void 0?new THREE.Color(a.emissive):new THREE.Color(0);this.specular=a.specular!==void 0?new THREE.Color(a.specular):new THREE.Color(1118481);this.shininess=a.shininess!==void 0?a.shininess:30;this.metal=a.metal!==void 0?a.metal:false;this.perPixel=
-a.perPixel!==void 0?a.perPixel:false;this.wrapAround=a.wrapAround!==void 0?a.wrapAround:false;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:true;this.shading=
-a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?
-a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshFaceMaterial=function(a){THREE.Material.call(this,a)};
-THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:true;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:false;this.fog=a.fog!==void 0?a.fog:true};THREE.ParticleBasicMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.program=a.program!==void 0?a.program:function(){}};THREE.ParticleCanvasMaterial.prototype=Object.create(THREE.Material.prototype);
+THREE.Material=function(){this.id=THREE.MaterialCount++;this.name="";this.side=THREE.FrontSide;this.opacity=1;this.transparent=false;this.blending=THREE.NormalBlending;this.blendSrc=THREE.SrcAlphaFactor;this.blendDst=THREE.OneMinusSrcAlphaFactor;this.blendEquation=THREE.AddEquation;this.depthWrite=this.depthTest=true;this.polygonOffset=false;this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.overdraw=false;this.needsUpdate=this.visible=true};
+THREE.Material.prototype.setParameters=function(a){a===void 0&&(a={});for(var b in a){var c=a[b];if(this[b]!==void 0)switch(b){case "color":case "ambient":case "emissive":case "specular":c instanceof THREE.Color?this[b].copy(c):this[b].setHex(c);break;case "wrapRGB":this[b].copy(c);break;default:this[b]=c}}};THREE.Material.prototype.clone=function(){return new THREE.Material(this)};THREE.MaterialCount=0;
+THREE.LineBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=false;this.fog=true;this.setParameters(a)};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);THREE.LineBasicMaterial.prototype.clone=function(){return new THREE.LineBasicMaterial(this)};
+THREE.MeshBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);
+THREE.MeshBasicMaterial.prototype.clone=function(){return new THREE.MeshBasicMaterial(this)};
+THREE.MeshLambertMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(16777215);this.emissive=new THREE.Color(0);this.wrapAround=false;this.wrapRGB=new THREE.Vector3(1,1,1);this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";
+this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshLambertMaterial.prototype.clone=function(){var a=new THREE.MeshLambertMaterial(this);a.wrapRGB=this.wrapRGB.clone();return a};
+THREE.MeshPhongMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(16777215);this.emissive=new THREE.Color(0);this.specular=new THREE.Color(1118481);this.shininess=30;this.wrapAround=this.perPixel=this.metal=false;this.wrapRGB=new THREE.Vector3(1,1,1);this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;
+this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshPhongMaterial.prototype.clone=function(){var a=new THREE.MeshPhongMaterial(this);a.wrapRGB=this.wrapRGB.clone();return a};
+THREE.MeshDepthMaterial=function(a){THREE.Material.call(this);this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.setParameters(a)};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial.prototype.clone=function(){return new THREE.MeshDepthMaterial(this)};THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);this.shading=THREE.FlatShading;this.wireframe=false;this.wireframeLinewidth=1;this.setParameters(a)};
+THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshNormalMaterial.prototype.clone=function(){return new THREE.MeshNormalMaterial(this)};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype.clone=function(){return new THREE.MeshFaceMaterial};THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.map=null;this.size=1;this.sizeAttenuation=true;this.vertexColors=false;this.fog=true;this.setParameters(a)};
+THREE.ParticleBasicMaterial.prototype=Object.create(THREE.Material.prototype);THREE.ParticleBasicMaterial.prototype.clone=function(){return new THREE.ParticleBasicMaterial(this)};THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.program=function(){};this.setParameters(a)};THREE.ParticleCanvasMaterial.prototype=Object.create(THREE.Material.prototype);THREE.ParticleCanvasMaterial.prototype.clone=function(){return new THREE.ParticleCanvasMaterial(this)};
 THREE.Texture=function(a,b,c,d,f,e,g,j,m){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=f!==void 0?f:THREE.LinearFilter;this.minFilter=e!==void 0?e:THREE.LinearMipMapLinearFilter;this.anisotropy=m!==void 0?m:1;this.format=g!==void 0?g:THREE.RGBAFormat;this.type=j!==void 0?j:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=
 THREE.Texture=function(a,b,c,d,f,e,g,j,m){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=f!==void 0?f:THREE.LinearFilter;this.minFilter=e!==void 0?e:THREE.LinearMipMapLinearFilter;this.anisotropy=m!==void 0?m:1;this.format=g!==void 0?g:THREE.RGBAFormat;this.type=j!==void 0?j:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=
 new THREE.Vector2(1,1);this.generateMipmaps=true;this.premultiplyAlpha=false;this.flipY=true;this.needsUpdate=false;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type,this.anisotropy);a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.generateMipmaps=this.generateMipmaps;a.premultiplyAlpha=this.premultiplyAlpha;a.flipY=this.flipY;return a}};
 new THREE.Vector2(1,1);this.generateMipmaps=true;this.premultiplyAlpha=false;this.flipY=true;this.needsUpdate=false;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type,this.anisotropy);a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.generateMipmaps=this.generateMipmaps;a.premultiplyAlpha=this.premultiplyAlpha;a.flipY=this.flipY;return a}};
 THREE.TextureCount=0;THREE.DataTexture=function(a,b,c,d,f,e,g,j,m,k){THREE.Texture.call(this,null,e,g,j,m,k,d,f);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};
 THREE.TextureCount=0;THREE.DataTexture=function(a,b,c,d,f,e,g,j,m,k){THREE.Texture.call(this,null,e,g,j,m,k,d,f);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};

+ 13 - 17
build/custom/ThreeWebGL.js

@@ -188,23 +188,19 @@ q}for(m in z.materials){x=z.materials[m];for(P in x.parameters)if(P==="envMap"||
 if(x.parameters.map){a.tDiffuse.texture=x.parameters.map;a.enableDiffuse.value=true}if(x.parameters.lightMap){a.tAO.texture=x.parameters.lightMap;a.enableAO.value=true}if(x.parameters.specularMap){a.tSpecular.texture=N.textures[x.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(i);a.uSpecularColor.value.setHex(q);a.uAmbientColor.value.setHex(S);a.uShininess.value=c;if(x.parameters.opacity)a.uOpacity.value=x.parameters.opacity;U=new THREE.ShaderMaterial({fragmentShader:r.fragmentShader,
 if(x.parameters.map){a.tDiffuse.texture=x.parameters.map;a.enableDiffuse.value=true}if(x.parameters.lightMap){a.tAO.texture=x.parameters.lightMap;a.enableAO.value=true}if(x.parameters.specularMap){a.tSpecular.texture=N.textures[x.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(i);a.uSpecularColor.value.setHex(q);a.uAmbientColor.value.setHex(S);a.uShininess.value=c;if(x.parameters.opacity)a.uOpacity.value=x.parameters.opacity;U=new THREE.ShaderMaterial({fragmentShader:r.fragmentShader,
 vertexShader:r.vertexShader,uniforms:a,lights:true,fog:true})}else U=new THREE[x.type](x.parameters);N.materials[m]=U}e(N.scene,z.objects);l.callbackSync(N);j()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
 vertexShader:r.vertexShader,uniforms:a,lights:true,fog:true})}else U=new THREE[x.type](x.parameters);N.materials[m]=U}e(N.scene,z.objects);l.callbackSync(N);j()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null};
 THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=true;b.dispatchEvent({type:"load",content:a})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};
 THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=true;b.dispatchEvent({type:"load",content:a})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}};
-THREE.Material=function(a){a=a||{};this.id=THREE.MaterialCount++;this.name="";this.side=a.side!==void 0?a.side:THREE.FrontSide;this.opacity=a.opacity!==void 0?a.opacity:1;this.transparent=a.transparent!==void 0?a.transparent:false;this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.blendSrc=a.blendSrc!==void 0?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=a.blendDst!==void 0?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=a.blendEquation!==void 0?a.blendEquation:THREE.AddEquation;
-this.depthTest=a.depthTest!==void 0?a.depthTest:true;this.depthWrite=a.depthWrite!==void 0?a.depthWrite:true;this.polygonOffset=a.polygonOffset!==void 0?a.polygonOffset:false;this.polygonOffsetFactor=a.polygonOffsetFactor!==void 0?a.polygonOffsetFactor:0;this.polygonOffsetUnits=a.polygonOffsetUnits!==void 0?a.polygonOffsetUnits:0;this.alphaTest=a.alphaTest!==void 0?a.alphaTest:0;this.overdraw=a.overdraw!==void 0?a.overdraw:false;this.visible=a.visible!==void 0?a.visible:true;this.needsUpdate=true};
-THREE.MaterialCount=0;THREE.LineBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.linewidth=a.linewidth!==void 0?a.linewidth:1;this.linecap=a.linecap!==void 0?a.linecap:"round";this.linejoin=a.linejoin!==void 0?a.linejoin:"round";this.vertexColors=a.vertexColors?a.vertexColors:false;this.fog=a.fog!==void 0?a.fog:true};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:
-true;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==
-void 0?a.morphTargets:false};THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshLambertMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=a.emissive!==void 0?new THREE.Color(a.emissive):new THREE.Color(0);this.wrapAround=a.wrapAround!==void 0?a.wrapAround:false;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=
-a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:true;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?
-a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshPhongMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.ambient=a.ambient!==void 0?new THREE.Color(a.ambient):new THREE.Color(16777215);this.emissive=a.emissive!==void 0?new THREE.Color(a.emissive):new THREE.Color(0);this.specular=a.specular!==void 0?new THREE.Color(a.specular):new THREE.Color(1118481);this.shininess=a.shininess!==void 0?a.shininess:30;this.metal=a.metal!==void 0?a.metal:false;this.perPixel=
-a.perPixel!==void 0?a.perPixel:false;this.wrapAround=a.wrapAround!==void 0?a.wrapAround:false;this.wrapRGB=new THREE.Vector3(1,1,1);this.map=a.map!==void 0?a.map:null;this.lightMap=a.lightMap!==void 0?a.lightMap:null;this.envMap=a.envMap!==void 0?a.envMap:null;this.combine=a.combine!==void 0?a.combine:THREE.MultiplyOperation;this.reflectivity=a.reflectivity!==void 0?a.reflectivity:1;this.refractionRatio=a.refractionRatio!==void 0?a.refractionRatio:0.98;this.fog=a.fog!==void 0?a.fog:true;this.shading=
-a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.wireframeLinecap=a.wireframeLinecap!==void 0?a.wireframeLinecap:"round";this.wireframeLinejoin=a.wireframeLinejoin!==void 0?a.wireframeLinejoin:"round";this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?
-a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshFaceMaterial=function(a){THREE.Material.call(this,a)};
-THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:true;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:false;this.fog=a.fog!==void 0?a.fog:true};THREE.ParticleBasicMaterial.prototype=Object.create(THREE.Material.prototype);
-THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=a.fragmentShader!==void 0?a.fragmentShader:"void main() {}";this.vertexShader=a.vertexShader!==void 0?a.vertexShader:"void main() {}";this.uniforms=a.uniforms!==void 0?a.uniforms:{};this.attributes=a.attributes;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.fog=
-a.fog!==void 0?a.fog:false;this.lights=a.lights!==void 0?a.lights:false;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype);
+THREE.Material=function(){this.id=THREE.MaterialCount++;this.name="";this.side=THREE.FrontSide;this.opacity=1;this.transparent=false;this.blending=THREE.NormalBlending;this.blendSrc=THREE.SrcAlphaFactor;this.blendDst=THREE.OneMinusSrcAlphaFactor;this.blendEquation=THREE.AddEquation;this.depthWrite=this.depthTest=true;this.polygonOffset=false;this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.overdraw=false;this.needsUpdate=this.visible=true};
+THREE.Material.prototype.setParameters=function(a){a===void 0&&(a={});for(var b in a){var c=a[b];if(this[b]!==void 0)switch(b){case "color":case "ambient":case "emissive":case "specular":c instanceof THREE.Color?this[b].copy(c):this[b].setHex(c);break;case "wrapRGB":this[b].copy(c);break;default:this[b]=c}}};THREE.Material.prototype.clone=function(){return new THREE.Material(this)};THREE.MaterialCount=0;
+THREE.LineBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=false;this.fog=true;this.setParameters(a)};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);THREE.LineBasicMaterial.prototype.clone=function(){return new THREE.LineBasicMaterial(this)};
+THREE.MeshBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);
+THREE.MeshBasicMaterial.prototype.clone=function(){return new THREE.MeshBasicMaterial(this)};
+THREE.MeshLambertMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(16777215);this.emissive=new THREE.Color(0);this.wrapAround=false;this.wrapRGB=new THREE.Vector3(1,1,1);this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";
+this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshLambertMaterial.prototype.clone=function(){var a=new THREE.MeshLambertMaterial(this);a.wrapRGB=this.wrapRGB.clone();return a};
+THREE.MeshPhongMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(16777215);this.emissive=new THREE.Color(0);this.specular=new THREE.Color(1118481);this.shininess=30;this.wrapAround=this.perPixel=this.metal=false;this.wrapRGB=new THREE.Vector3(1,1,1);this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=true;this.shading=THREE.SmoothShading;this.wireframe=false;
+this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshPhongMaterial.prototype.clone=function(){var a=new THREE.MeshPhongMaterial(this);a.wrapRGB=this.wrapRGB.clone();return a};
+THREE.MeshDepthMaterial=function(a){THREE.Material.call(this);this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.setParameters(a)};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial.prototype.clone=function(){return new THREE.MeshDepthMaterial(this)};THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);this.shading=THREE.FlatShading;this.wireframe=false;this.wireframeLinewidth=1;this.setParameters(a)};
+THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshNormalMaterial.prototype.clone=function(){return new THREE.MeshNormalMaterial(this)};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype.clone=function(){return new THREE.MeshFaceMaterial};THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this);this.color=new THREE.Color(16777215);this.map=null;this.size=1;this.sizeAttenuation=true;this.vertexColors=false;this.fog=true;this.setParameters(a)};
+THREE.ParticleBasicMaterial.prototype=Object.create(THREE.Material.prototype);THREE.ParticleBasicMaterial.prototype.clone=function(){return new THREE.ParticleBasicMaterial(this)};
+THREE.ShaderMaterial=function(a){THREE.Material.call(this);this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.attributes=null;this.shading=THREE.SmoothShading;this.wireframe=false;this.wireframeLinewidth=1;this.lights=this.fog=false;this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=false;this.setParameters(a)};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype);THREE.ShaderMaterial.prototype.clone=function(){return new THREE.ShaderMaterial(this)};
 THREE.Texture=function(a,b,c,d,e,f,h,j,l){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==void 0?e:THREE.LinearFilter;this.minFilter=f!==void 0?f:THREE.LinearMipMapLinearFilter;this.anisotropy=l!==void 0?l:1;this.format=h!==void 0?h:THREE.RGBAFormat;this.type=j!==void 0?j:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=
 THREE.Texture=function(a,b,c,d,e,f,h,j,l){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==void 0?e:THREE.LinearFilter;this.minFilter=f!==void 0?f:THREE.LinearMipMapLinearFilter;this.anisotropy=l!==void 0?l:1;this.format=h!==void 0?h:THREE.RGBAFormat;this.type=j!==void 0?j:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=
 new THREE.Vector2(1,1);this.generateMipmaps=true;this.premultiplyAlpha=false;this.flipY=true;this.needsUpdate=false;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type,this.anisotropy);a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.generateMipmaps=this.generateMipmaps;a.premultiplyAlpha=this.premultiplyAlpha;a.flipY=this.flipY;return a}};
 new THREE.Vector2(1,1);this.generateMipmaps=true;this.premultiplyAlpha=false;this.flipY=true;this.needsUpdate=false;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type,this.anisotropy);a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.generateMipmaps=this.generateMipmaps;a.premultiplyAlpha=this.premultiplyAlpha;a.flipY=this.flipY;return a}};
 THREE.TextureCount=0;THREE.DataTexture=function(a,b,c,d,e,f,h,j,l,k){THREE.Texture.call(this,null,f,h,j,l,k,d,e);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};
 THREE.TextureCount=0;THREE.DataTexture=function(a,b,c,d,e,f,h,j,l,k){THREE.Texture.call(this,null,f,h,j,l,k,d,e);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};

+ 1 - 2
examples/canvas_particles_floor.html

@@ -48,8 +48,7 @@
 
 
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
 
 
-				var PI2 = Math.PI * 2;
-				var material = new THREE.ParticleBasicMaterial( { color: 0xffffff } );
+				var material = new THREE.ParticleBasicMaterial();
 
 
 				for ( var ix = 0; ix < AMOUNTX; ix++ ) {
 				for ( var ix = 0; ix < AMOUNTX; ix++ ) {
 
 

+ 1 - 1
src/core/Color.js

@@ -4,8 +4,8 @@
 
 
 THREE.Color = function ( hex ) {
 THREE.Color = function ( hex ) {
 
 
-	if ( hex instanceof THREE.Color ) return this.clone();
 	if ( hex !== undefined ) this.setHex( hex );
 	if ( hex !== undefined ) this.setHex( hex );
+
 	return this;
 	return this;
 
 
 };
 };

+ 11 - 12
src/materials/LineBasicMaterial.js

@@ -21,27 +21,26 @@
 
 
 THREE.LineBasicMaterial = function ( parameters ) {
 THREE.LineBasicMaterial = function ( parameters ) {
 
 
-	THREE.Material.call( this, parameters );
+	THREE.Material.call( this );
 
 
-	parameters = parameters || {};
+	this.color = new THREE.Color( 0xffffff );
 
 
-	this.color = parameters.color !== undefined ? new THREE.Color( parameters.color ) : new THREE.Color( 0xffffff );
+	this.linewidth = 1;
+	this.linecap = 'round';
+	this.linejoin = 'round';
 
 
-	this.linewidth = parameters.linewidth !== undefined ? parameters.linewidth : 1;
-	this.linecap = parameters.linecap !== undefined ? parameters.linecap : 'round';
-	this.linejoin = parameters.linejoin !== undefined ? parameters.linejoin : 'round';
+	this.vertexColors = false;
 
 
-	this.vertexColors = parameters.vertexColors ? parameters.vertexColors : false;
+	this.fog = true;
 
 
-	this.fog = parameters.fog !== undefined ? parameters.fog : true;
+	this.setParameters( parameters );
 
 
 };
 };
 
 
 THREE.LineBasicMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.LineBasicMaterial.prototype = Object.create( THREE.Material.prototype );
 
 
+THREE.LineBasicMaterial.prototype.clone = function () {
 
 
-THREE.LineBasicMaterial.prototype.clone = function(){ 
-	var returnValue = new THREE.LineBasicMaterial(this);
-	return returnValue;
-};
+	return new THREE.LineBasicMaterial( this );
 
 
+};

+ 67 - 21
src/materials/Material.js

@@ -5,43 +5,89 @@
 
 
 THREE.Material = function ( parameters ) {
 THREE.Material = function ( parameters ) {
 
 
-	parameters = parameters || {};
-
 	this.id = THREE.MaterialCount ++;
 	this.id = THREE.MaterialCount ++;
 
 
 	this.name = '';
 	this.name = '';
 
 
-	this.side = parameters.side !== undefined ? parameters.side : THREE.FrontSide;
+	this.side = THREE.FrontSide;
 
 
-	this.opacity = parameters.opacity !== undefined ? parameters.opacity : 1;
-	this.transparent = parameters.transparent !== undefined ? parameters.transparent : false;
+	this.opacity = 1;
+	this.transparent = false;
 
 
-	this.blending = parameters.blending !== undefined ? parameters.blending : THREE.NormalBlending;
+	this.blending = THREE.NormalBlending;
 
 
-	this.blendSrc = parameters.blendSrc !== undefined ? parameters.blendSrc : THREE.SrcAlphaFactor;
-	this.blendDst = parameters.blendDst !== undefined ? parameters.blendDst : THREE.OneMinusSrcAlphaFactor;
-	this.blendEquation = parameters.blendEquation !== undefined ? parameters.blendEquation : THREE.AddEquation;
+	this.blendSrc = THREE.SrcAlphaFactor;
+	this.blendDst = THREE.OneMinusSrcAlphaFactor;
+	this.blendEquation = THREE.AddEquation;
 
 
-	this.depthTest = parameters.depthTest !== undefined ? parameters.depthTest : true;
-	this.depthWrite = parameters.depthWrite !== undefined ? parameters.depthWrite : true;
+	this.depthTest = true;
+	this.depthWrite = true;
 
 
-	this.polygonOffset = parameters.polygonOffset !== undefined ? parameters.polygonOffset : false;
-	this.polygonOffsetFactor = parameters.polygonOffsetFactor !== undefined ? parameters.polygonOffsetFactor : 0;
-	this.polygonOffsetUnits = parameters.polygonOffsetUnits !== undefined ? parameters.polygonOffsetUnits : 0;
+	this.polygonOffset = false;
+	this.polygonOffsetFactor = 0;
+	this.polygonOffsetUnits = 0;
 
 
-	this.alphaTest = parameters.alphaTest !== undefined ? parameters.alphaTest : 0;
+	this.alphaTest = 0;
 
 
-	this.overdraw = parameters.overdraw !== undefined ? parameters.overdraw : false; // Boolean for fixing antialiasing gaps in CanvasRenderer
+	this.overdraw = false; // Boolean for fixing antialiasing gaps in CanvasRenderer
 
 
-	this.visible = parameters.visible !== undefined ? parameters.visible : true;
+	this.visible = true;
 
 
 	this.needsUpdate = true;
 	this.needsUpdate = true;
 
 
-}
+};
+
+THREE.Material.prototype.setParameters = function ( parameters ) {
+
+	if ( parameters === undefined ) parameters = {};
+
+	for ( var key in parameters ) {
+
+		var value = parameters[ key ];
+
+		if ( this[ key ] !== undefined ) {
+
+			switch ( key ) {
+
+				case "color":
+				case "ambient":
+				case "emissive":
+				case "specular":
+
+					if ( value instanceof THREE.Color ) {
+
+						this[ key ].copy( value );
+
+					} else {
+
+						this[ key ].setHex( value );
+
+					}
+
+					break;
+
+				case "wrapRGB":
+
+					this[ key ].copy( value );
+
+					break;
+
+				default:
+
+					this[ key ] = value;
+
+			}
+
+		}
+
+	}
+
+};
+
+THREE.Material.prototype.clone = function () {
+
+	return new THREE.Material( this );
 
 
-THREE.Material.prototype.clone = function(){
-	var returnValue = new THREE.Material(this);
-	return returnValue;
 };
 };
 
 
 THREE.MaterialCount = 0;
 THREE.MaterialCount = 0;

+ 22 - 24
src/materials/MeshBasicMaterial.js

@@ -26,49 +26,47 @@
  *  skinning: <bool>,
  *  skinning: <bool>,
  *  morphTargets: <bool>,
  *  morphTargets: <bool>,
  *
  *
- *	fog: <bool>
+ *  fog: <bool>
  * }
  * }
  */
  */
 
 
 THREE.MeshBasicMaterial = function ( parameters ) {
 THREE.MeshBasicMaterial = function ( parameters ) {
 
 
-	THREE.Material.call( this, parameters );
+	THREE.Material.call( this );
 
 
-	parameters = parameters || {};
+	this.color = new THREE.Color( 0xffffff ); // emissive
 
 
-	// color property represents emissive for MeshBasicMaterial
+	this.map = null;
 
 
-	this.color = parameters.color !== undefined ? new THREE.Color( parameters.color ) : new THREE.Color( 0xffffff );
+	this.lightMap = null;
 
 
-	this.map = parameters.map !== undefined ? parameters.map : null;
+	this.envMap = null;
+	this.combine = THREE.MultiplyOperation;
+	this.reflectivity = 1;
+	this.refractionRatio = 0.98;
 
 
-	this.lightMap = parameters.lightMap !== undefined ? parameters.lightMap : null;
+	this.fog = true;
 
 
-	this.envMap = parameters.envMap !== undefined ? parameters.envMap : null;
-	this.combine = parameters.combine !== undefined ? parameters.combine : THREE.MultiplyOperation;
-	this.reflectivity = parameters.reflectivity !== undefined ? parameters.reflectivity : 1;
-	this.refractionRatio = parameters.refractionRatio !== undefined ? parameters.refractionRatio : 0.98;
+	this.shading = THREE.SmoothShading;
 
 
-	this.fog = parameters.fog !== undefined ? parameters.fog : true;
+	this.wireframe = false;
+	this.wireframeLinewidth = 1;
+	this.wireframeLinecap = 'round';
+	this.wireframeLinejoin = 'round';
 
 
-	this.shading = parameters.shading !== undefined ? parameters.shading : THREE.SmoothShading;
+	this.vertexColors = THREE.NoColors;
 
 
-	this.wireframe = parameters.wireframe !== undefined ? parameters.wireframe : false;
-	this.wireframeLinewidth = parameters.wireframeLinewidth !== undefined ? parameters.wireframeLinewidth : 1;
-	this.wireframeLinecap = parameters.wireframeLinecap !== undefined ? parameters.wireframeLinecap : 'round';
-	this.wireframeLinejoin = parameters.wireframeLinejoin !== undefined ? parameters.wireframeLinejoin : 'round';
+	this.skinning = false;
+	this.morphTargets = false;
 
 
-	this.vertexColors = parameters.vertexColors !== undefined ? parameters.vertexColors : THREE.NoColors;
-
-	this.skinning = parameters.skinning !== undefined ? parameters.skinning : false;
-	this.morphTargets = parameters.morphTargets !== undefined ? parameters.morphTargets : false;
+	this.setParameters( parameters );
 
 
 };
 };
 
 
 THREE.MeshBasicMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.MeshBasicMaterial.prototype = Object.create( THREE.Material.prototype );
 
 
+THREE.MeshBasicMaterial.prototype.clone = function () {
+
+	return new THREE.MeshBasicMaterial( this );
 
 
-THREE.MeshBasicMaterial.prototype.clone = function(){ 
-	var returnValue = new THREE.MeshBasicMaterial(this);
-	return returnValue;
 };
 };

+ 9 - 8
src/materials/MeshDepthMaterial.js

@@ -15,20 +15,21 @@
 
 
 THREE.MeshDepthMaterial = function ( parameters ) {
 THREE.MeshDepthMaterial = function ( parameters ) {
 
 
-	THREE.Material.call( this, parameters );
+	THREE.Material.call( this );
 
 
-	parameters = parameters || {};
+	this.shading = THREE.SmoothShading; // doesn't really apply here, normals are not used
 
 
-	this.shading = parameters.shading !== undefined ? parameters.shading : THREE.SmoothShading; // doesn't really apply here, normals are not used
+	this.wireframe = false;
+	this.wireframeLinewidth = 1;
 
 
-	this.wireframe = parameters.wireframe !== undefined ? parameters.wireframe : false;
-	this.wireframeLinewidth = parameters.wireframeLinewidth !== undefined ? parameters.wireframeLinewidth : 1;
+	this.setParameters( parameters );
 
 
 };
 };
 
 
 THREE.MeshDepthMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.MeshDepthMaterial.prototype = Object.create( THREE.Material.prototype );
 
 
-THREE.MeshDepthMaterial.prototype.clone = function(){ 
-	var returnValue = new THREE.MeshDepthMaterial(this);
-	return returnValue;
+THREE.MeshDepthMaterial.prototype.clone = function () {
+
+	return new THREE.MeshDepthMaterial( this );
+
 };
 };

+ 4 - 9
src/materials/MeshFaceMaterial.js

@@ -2,15 +2,10 @@
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  */
  */
 
 
-THREE.MeshFaceMaterial = function ( parameters ) {
+THREE.MeshFaceMaterial = function () {};
 
 
-	THREE.Material.call( this, parameters );
-
-};
+THREE.MeshFaceMaterial.prototype.clone = function () {
 
 
+	return new THREE.MeshFaceMaterial();
 
 
-
-THREE.MeshFaceMaterial.prototype.clone = function(){ 
-	var returnValue = new THREE.MeshFaceMaterial(this);
-	return returnValue;
-};
+};

+ 29 - 29
src/materials/MeshLambertMaterial.js

@@ -36,49 +36,49 @@
 
 
 THREE.MeshLambertMaterial = function ( parameters ) {
 THREE.MeshLambertMaterial = function ( parameters ) {
 
 
-	THREE.Material.call( this, parameters );
+	THREE.Material.call( this );
 
 
-	parameters = parameters || {};
+	this.color = new THREE.Color( 0xffffff ); // diffuse
+	this.ambient = new THREE.Color( 0xffffff );
+	this.emissive = new THREE.Color( 0x000000 );
 
 
-	// color property represents diffuse for MeshLambertMaterial
-
-	this.color = parameters.color !== undefined ? new THREE.Color( parameters.color ) : new THREE.Color( 0xffffff );
-	this.ambient = parameters.ambient !== undefined ? new THREE.Color( parameters.ambient ) : new THREE.Color( 0xffffff );
-	this.emissive = parameters.emissive !== undefined ? new THREE.Color( parameters.emissive ) : new THREE.Color( 0x000000 );
-
-	this.wrapAround = parameters.wrapAround !== undefined ? parameters.wrapAround: false;
+	this.wrapAround = false;
 	this.wrapRGB = new THREE.Vector3( 1, 1, 1 );
 	this.wrapRGB = new THREE.Vector3( 1, 1, 1 );
 
 
-	this.map = parameters.map !== undefined ? parameters.map : null;
+	this.map = null;
+
+	this.lightMap = null;
 
 
-	this.lightMap = parameters.lightMap !== undefined ? parameters.lightMap : null;
+	this.envMap = null;
+	this.combine = THREE.MultiplyOperation;
+	this.reflectivity = 1;
+	this.refractionRatio = 0.98;
 
 
-	this.envMap = parameters.envMap !== undefined ? parameters.envMap : null;
-	this.combine = parameters.combine !== undefined ? parameters.combine : THREE.MultiplyOperation;
-	this.reflectivity = parameters.reflectivity !== undefined ? parameters.reflectivity : 1;
-	this.refractionRatio = parameters.refractionRatio !== undefined ? parameters.refractionRatio : 0.98;
+	this.fog = true;
 
 
-	this.fog = parameters.fog !== undefined ? parameters.fog : true;
+	this.shading = THREE.SmoothShading;
 
 
-	this.shading = parameters.shading !== undefined ? parameters.shading : THREE.SmoothShading;
+	this.wireframe = false;
+	this.wireframeLinewidth = 1;
+	this.wireframeLinecap = 'round';
+	this.wireframeLinejoin = 'round';
 
 
-	this.wireframe = parameters.wireframe !== undefined ? parameters.wireframe : false;
-	this.wireframeLinewidth = parameters.wireframeLinewidth !== undefined ? parameters.wireframeLinewidth : 1;
-	this.wireframeLinecap = parameters.wireframeLinecap !== undefined ? parameters.wireframeLinecap : 'round';
-	this.wireframeLinejoin = parameters.wireframeLinejoin !== undefined ? parameters.wireframeLinejoin : 'round';
+	this.vertexColors = THREE.NoColors;
 
 
-	this.vertexColors = parameters.vertexColors !== undefined ? parameters.vertexColors : THREE.NoColors;
+	this.skinning = false;
+	this.morphTargets = false;
+	this.morphNormals = false;
 
 
-	this.skinning = parameters.skinning !== undefined ? parameters.skinning : false;
-	this.morphTargets = parameters.morphTargets !== undefined ? parameters.morphTargets : false;
-	this.morphNormals = parameters.morphNormals !== undefined ? parameters.morphNormals : false;
+	this.setParameters( parameters );
 
 
 };
 };
 
 
 THREE.MeshLambertMaterial.prototype = Object.create( THREE.Material.prototype );
 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;
+THREE.MeshLambertMaterial.prototype.clone = function () {
+
+	var material = new THREE.MeshLambertMaterial( this );
+	material.wrapRGB = this.wrapRGB.clone();
+	return material;
+
 };
 };

+ 8 - 8
src/materials/MeshNormalMaterial.js

@@ -17,19 +17,19 @@ THREE.MeshNormalMaterial = function ( parameters ) {
 
 
 	THREE.Material.call( this, parameters );
 	THREE.Material.call( this, parameters );
 
 
-	parameters = parameters || {};
+	this.shading = THREE.FlatShading;
 
 
-	this.shading = parameters.shading ? parameters.shading : THREE.FlatShading;
+	this.wireframe = false;
+	this.wireframeLinewidth = 1;
 
 
-	this.wireframe = parameters.wireframe ? parameters.wireframe : false;
-	this.wireframeLinewidth = parameters.wireframeLinewidth ? parameters.wireframeLinewidth : 1;
+	this.setParameters( parameters );
 
 
 };
 };
 
 
 THREE.MeshNormalMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.MeshNormalMaterial.prototype = Object.create( THREE.Material.prototype );
 
 
+THREE.MeshNormalMaterial.prototype.clone = function () {
 
 
-THREE.MeshNormalMaterial.prototype.clone = function(){ 
-	var returnValue = new THREE.MeshNormalMaterial(this);
-	return returnValue;
-};
+	return new THREE.MeshNormalMaterial( this );
+
+};

+ 32 - 33
src/materials/MeshPhongMaterial.js

@@ -38,55 +38,54 @@
 
 
 THREE.MeshPhongMaterial = function ( parameters ) {
 THREE.MeshPhongMaterial = function ( parameters ) {
 
 
-	THREE.Material.call( this, parameters );
+	THREE.Material.call( this );
 
 
-	parameters = parameters || {};
+	this.color = new THREE.Color( 0xffffff ); // diffuse
+	this.ambient = new THREE.Color( 0xffffff );
+	this.emissive = new THREE.Color( 0x000000 );
+	this.specular = new THREE.Color( 0x111111 );
+	this.shininess = 30;
 
 
-	// color property represents diffuse for MeshPhongMaterial
+	this.metal = false;
+	this.perPixel = false;
 
 
-	this.color = parameters.color !== undefined ? new THREE.Color( parameters.color ) : new THREE.Color( 0xffffff );
-	this.ambient = parameters.ambient !== undefined ? new THREE.Color( parameters.ambient ) : new THREE.Color( 0xffffff );
-	this.emissive = parameters.emissive !== undefined ? new THREE.Color( parameters.emissive ) : new THREE.Color( 0x000000 );
-	this.specular = parameters.specular !== undefined ? new THREE.Color( parameters.specular ) : new THREE.Color( 0x111111 );
-	this.shininess = parameters.shininess !== undefined ? parameters.shininess : 30;
-
-	this.metal = parameters.metal !== undefined ? parameters.metal : false;
-	this.perPixel = parameters.perPixel !== undefined ? parameters.perPixel : false;
-
-	this.wrapAround = parameters.wrapAround !== undefined ? parameters.wrapAround: false;
+	this.wrapAround = false;
 	this.wrapRGB = new THREE.Vector3( 1, 1, 1 );
 	this.wrapRGB = new THREE.Vector3( 1, 1, 1 );
 
 
-	this.map = parameters.map !== undefined ? parameters.map : null;
+	this.map = null;
 
 
-	this.lightMap = parameters.lightMap !== undefined ? parameters.lightMap : null;
+	this.lightMap = null;
 
 
-	this.envMap = parameters.envMap !== undefined ? parameters.envMap : null;
-	this.combine = parameters.combine !== undefined ? parameters.combine : THREE.MultiplyOperation;
-	this.reflectivity = parameters.reflectivity !== undefined ? parameters.reflectivity : 1;
-	this.refractionRatio = parameters.refractionRatio !== undefined ? parameters.refractionRatio : 0.98;
+	this.envMap = null;
+	this.combine = THREE.MultiplyOperation;
+	this.reflectivity = 1;
+	this.refractionRatio = 0.98;
 
 
-	this.fog = parameters.fog !== undefined ? parameters.fog : true;
+	this.fog = true;
 
 
-	this.shading = parameters.shading !== undefined ? parameters.shading : THREE.SmoothShading;
+	this.shading = THREE.SmoothShading;
 
 
-	this.wireframe = parameters.wireframe !== undefined ? parameters.wireframe : false;
-	this.wireframeLinewidth = parameters.wireframeLinewidth !== undefined ? parameters.wireframeLinewidth : 1;
-	this.wireframeLinecap = parameters.wireframeLinecap !== undefined ? parameters.wireframeLinecap : 'round';
-	this.wireframeLinejoin = parameters.wireframeLinejoin !== undefined ? parameters.wireframeLinejoin : 'round';
+	this.wireframe = false;
+	this.wireframeLinewidth = 1;
+	this.wireframeLinecap = 'round';
+	this.wireframeLinejoin = 'round';
 
 
-	this.vertexColors = parameters.vertexColors !== undefined ? parameters.vertexColors : THREE.NoColors;
+	this.vertexColors = THREE.NoColors;
 
 
-	this.skinning = parameters.skinning !== undefined ? parameters.skinning : false;
-	this.morphTargets = parameters.morphTargets !== undefined ? parameters.morphTargets : false;
-	this.morphNormals = parameters.morphNormals !== undefined ? parameters.morphNormals : false;
+	this.skinning = false;
+	this.morphTargets = false;
+	this.morphNormals = false;
+
+	this.setParameters( parameters );
 
 
 };
 };
 
 
 THREE.MeshPhongMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.MeshPhongMaterial.prototype = Object.create( THREE.Material.prototype );
 
 
+THREE.MeshPhongMaterial.prototype.clone = function () {
+
+	var material = new THREE.MeshPhongMaterial( this );
+	material.wrapRGB = this.wrapRGB.clone();
+	return material;
 
 
-THREE.MeshPhongMaterial.prototype.clone = function(){ 
-	var returnValue = new THREE.MeshPhongMaterial(this);
-	returnValue.wrapRGB = this.wrapRGB.clone();
-	return returnValue;
 };
 };

+ 13 - 12
src/materials/ParticleBasicMaterial.js

@@ -20,26 +20,27 @@
 
 
 THREE.ParticleBasicMaterial = function ( parameters ) {
 THREE.ParticleBasicMaterial = function ( parameters ) {
 
 
-	THREE.Material.call( this, parameters );
+	THREE.Material.call( this );
 
 
-	parameters = parameters || {};
+	this.color = new THREE.Color( 0xffffff );
 
 
-	this.color = parameters.color !== undefined ? new THREE.Color( parameters.color ) : new THREE.Color( 0xffffff );
+	this.map = null;
 
 
-	this.map = parameters.map !== undefined ? parameters.map : null;
+	this.size = 1;
+	this.sizeAttenuation = true;
 
 
-	this.size = parameters.size !== undefined ? parameters.size : 1;
-	this.sizeAttenuation = parameters.sizeAttenuation !== undefined ? parameters.sizeAttenuation : true;
+	this.vertexColors = false;
 
 
-	this.vertexColors = parameters.vertexColors !== undefined ? parameters.vertexColors : false;
+	this.fog = true;
 
 
-	this.fog = parameters.fog !== undefined ? parameters.fog : true;
+	this.setParameters( parameters );
 
 
 };
 };
 
 
 THREE.ParticleBasicMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.ParticleBasicMaterial.prototype = Object.create( THREE.Material.prototype );
 
 
-THREE.ParticleBasicMaterial.prototype.clone = function(){ 
-	var returnValue = new THREE.ParticleBasicMaterial(this);
-	return returnValue;
-};
+THREE.ParticleBasicMaterial.prototype.clone = function () {
+
+	return new THREE.ParticleBasicMaterial( this );
+
+};

+ 9 - 8
src/materials/ParticleCanvasMaterial.js

@@ -11,18 +11,19 @@
 
 
 THREE.ParticleCanvasMaterial = function ( parameters ) {
 THREE.ParticleCanvasMaterial = function ( parameters ) {
 
 
-	THREE.Material.call( this, parameters );
+	THREE.Material.call( this );
 
 
-	parameters = parameters || {};
+	this.color = new THREE.Color( 0xffffff );
+	this.program = function ( context, color ) {};
 
 
-	this.color = parameters.color !== undefined ? new THREE.Color( parameters.color ) : new THREE.Color( 0xffffff );
-	this.program = parameters.program !== undefined ? parameters.program : function ( context, color ) {};
+	this.setParameters( parameters );
 
 
 };
 };
 
 
 THREE.ParticleCanvasMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.ParticleCanvasMaterial.prototype = Object.create( THREE.Material.prototype );
 
 
-THREE.ParticleCanvasMaterial.prototype.clone = function(){ 
-	var returnValue = new THREE.ParticleCanvasMaterial(this);
-	return returnValue;
-};
+THREE.ParticleCanvasMaterial.prototype.clone = function () {
+
+	return new THREE.ParticleCanvasMaterial( this );
+
+};

+ 4 - 6
src/materials/ParticleDOMMaterial.js

@@ -4,14 +4,12 @@
 
 
 THREE.ParticleDOMMaterial = function ( domElement ) {
 THREE.ParticleDOMMaterial = function ( domElement ) {
 
 
-	THREE.Material.call( this );
-
 	this.domElement = domElement;
 	this.domElement = domElement;
 
 
 };
 };
 
 
-
 THREE.ParticleDOMMaterial.prototype.clone = function(){ 
 THREE.ParticleDOMMaterial.prototype.clone = function(){ 
-	var returnValue = new THREE.ParticleDOMMaterial(this);
-	return returnValue;
-};
+
+	return new THREE.ParticleDOMMaterial( this.domElement );
+
+};

+ 18 - 18
src/materials/ShaderMaterial.js

@@ -28,37 +28,37 @@
 
 
 THREE.ShaderMaterial = function ( parameters ) {
 THREE.ShaderMaterial = function ( parameters ) {
 
 
-	THREE.Material.call( this, parameters );
+	THREE.Material.call( this );
 
 
-	parameters = parameters || {};
+	this.fragmentShader = "void main() {}";
+	this.vertexShader = "void main() {}";
+	this.uniforms = {};
+	this.attributes = null;
 
 
-	this.fragmentShader = parameters.fragmentShader !== undefined ? parameters.fragmentShader : "void main() {}";
-	this.vertexShader = parameters.vertexShader !== undefined ? parameters.vertexShader : "void main() {}";
-	this.uniforms = parameters.uniforms !== undefined ? parameters.uniforms : {};
-	this.attributes = parameters.attributes;
+	this.shading = THREE.SmoothShading;
 
 
-	this.shading = parameters.shading !== undefined ? parameters.shading : THREE.SmoothShading;
+	this.wireframe = false;
+	this.wireframeLinewidth = 1;
 
 
-	this.wireframe = parameters.wireframe !== undefined ? parameters.wireframe : false;
-	this.wireframeLinewidth = parameters.wireframeLinewidth !== undefined ? parameters.wireframeLinewidth : 1;
+	this.fog = false; // set to use scene fog
 
 
-	this.fog = parameters.fog !== undefined ? parameters.fog : false; // set to use scene fog
+	this.lights = false; // set to use scene lights
 
 
-	this.lights = parameters.lights !== undefined ? parameters.lights : false; // set to use scene lights
+	this.vertexColors = THREE.NoColors; // set to use "color" attribute stream
 
 
-	this.vertexColors = parameters.vertexColors !== undefined ? parameters.vertexColors : THREE.NoColors; // set to use "color" attribute stream
+	this.skinning = false; // set to use skinning attribute streams
 
 
-	this.skinning = parameters.skinning !== undefined ? parameters.skinning : false; // set to use skinning attribute streams
+	this.morphTargets = false; // set to use morph targets
+	this.morphNormals = false; // set to use morph normals
 
 
-	this.morphTargets = parameters.morphTargets !== undefined ? parameters.morphTargets : false; // set to use morph targets
-	this.morphNormals = parameters.morphNormals !== undefined ? parameters.morphNormals : false; // set to use morph normals
+	this.setParameters( parameters );
 
 
 };
 };
 
 
 THREE.ShaderMaterial.prototype = Object.create( THREE.Material.prototype );
 THREE.ShaderMaterial.prototype = Object.create( THREE.Material.prototype );
 
 
+THREE.ShaderMaterial.prototype.clone = function () {
+
+	return new THREE.ShaderMaterial( this );
 
 
-THREE.ShaderMaterial.prototype.clone = function(){ 
-	var returnValue = new THREE.ShaderMaterial(this);
-	return returnValue;
 };
 };