ソースを参照

Fixed CanvasRenderer clearColor with opacity. Now follows WebGL behaviour. (thx @sebleedelisle)

Mr.doob 14 年 前
コミット
5bbb1327e9

+ 2 - 2
README.md

@@ -66,7 +66,7 @@ More? [#three.js on irc.freenode.net](http://webchat.freenode.net/?channels=thre
 [![Infinite beanstalk](http://mrdoob.github.com/three.js/assets/projects/19_beanstalk.png)](http://inear.se/beanstalk/)
 [![Mission Control](http://mrdoob.github.com/three.js/assets/projects/18_missioncontrol.png)](http://superfad.com/missioncontrol/)
 [![ROME](http://mrdoob.github.com/three.js/assets/projects/17_rome.png)](http://ro.me/)
-[![Globe](http://mrdoob.github.com/three.js/assets/projects/16_globe.png)](http://data-arts.appspot.com/globe/)
+[![Globe](http://mrdoob.github.com/three.js/assets/projects/16_globe.png)](http://data-arts.appspot.com/globe)
 [![Photoparticles](http://mrdoob.github.com/three.js/assets/projects/15_photoparticles.png)](http://lab.aerotwist.com/webgl/photoparticles/)
 [![Plumegraph](http://mrdoob.github.com/three.js/assets/projects/14_plumegraph.png)](http://plumegraph.org/)
 [![HelloRacer](http://mrdoob.github.com/three.js/assets/projects/13_helloracer.png)](http://helloracer.com/webgl/)
@@ -154,7 +154,7 @@ This code creates a camera, then creates a scene, adds a cube on it, creates a &
 
 2011 05 31 - **r41/ROME** (265.317 KB, gzip: 64.849 KB)
 
-(Up to this point, some [rome](http://ro.me) specific features managed to get in the lib. The aim is to clean this up in next revisions.)
+(Up to this point, some [RO.ME](http://ro.me) specific features managed to get in the lib. The aim is to clean this up in next revisions.)
 
 * Improved Blender Object and Scene exporters. ([alteredq](http://github.com/alteredq))
 * Fixes on WebGL attributes. ([alteredq](http://github.com/alteredq) and [empaempa](http://github.com/empaempa))

+ 31 - 30
build/Three.js

@@ -54,7 +54,7 @@ THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){t
 this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=
 b,this.w*=b);return this},multiplySelf:function(b){var c=this.x,e=this.y,f=this.z,g=this.w,j=b.x,h=b.y,m=b.z,b=b.w;this.x=c*b+g*j+e*m-f*h;this.y=e*b+g*h+f*j-c*m;this.z=f*b+g*m+c*h-e*j;this.w=g*b-c*j-e*h-f*m;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var e=b.x,f=b.y,g=b.z,j=this.x,h=this.y,m=this.z,
 n=this.w,p=n*e+h*g-m*f,o=n*f+m*e-j*g,t=n*g+j*f-h*e,e=-j*e-h*f-m*g;c.x=p*n+e*-j+o*-m-t*-h;c.y=o*n+e*-h+t*-j-p*-m;c.z=t*n+e*-m+p*-h-o*-j;return c}};
-THREE.Quaternion.slerp=function(b,c,e,f){var g=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(g)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var j=Math.acos(g),h=Math.sqrt(1-g*g);if(Math.abs(h)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;g=Math.sin((1-f)*j)/h;f=Math.sin(f*j)/h;e.w=b.w*g+c.w*f;e.x=b.x*g+c.x*f;e.y=b.y*g+c.y*f;e.z=b.z*g+c.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Quaternion.slerp=function(b,c,e,f){var g=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(g)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var j=Math.acos(g),h=Math.sqrt(1-g*g);if(Math.abs(h)<0.001)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;g=Math.sin((1-f)*j)/h;f=Math.sin(f*j)/h;e.w=b.w*g+c.w*f;e.x=b.x*g+c.x*f;e.y=b.y*g+c.y*f;e.z=b.z*g+c.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
 THREE.Face3=function(b,c,e,f,g,j){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};
 THREE.Face4=function(b,c,e,f,g,j,h){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)};
 THREE.UV.prototype={constructor:THREE.UV,set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -155,30 +155,31 @@ I.w),R.multiplyScalar(1/R.w),ca=x[z]=x[z]||new THREE.RenderableLine,z++,y=ca,y.v
 THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;j=f/2};this.render=function(e,f){var n,p,o,t,v,u,y,z;b=c.projectScene(e,f);n=0;for(p=b.length;n<p;n++)if(v=b[n],v instanceof THREE.RenderableParticle){y=v.x*g+g;z=v.y*j+j;o=0;for(t=v.material.length;o<t;o++)if(u=v.material[o],u instanceof THREE.ParticleDOMMaterial)u=u.domElement,u.style.left=y+"px",u.style.top=z+"px"}}};
 THREE.CanvasRenderer=function(b){function c(b){if(x!=b)u.globalAlpha=x=b}function e(b){if(w!=b){switch(b){case THREE.NormalBlending:u.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:u.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:u.globalCompositeOperation="darker"}w=b}}function f(b){if(H!=b)u.strokeStyle=H=b}function g(b){if(B!=b)u.fillStyle=B=b}var j=this,h=null,m=new THREE.Projector,b=b||{},n=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
 p,o,t,v,u=n.getContext("2d"),y=new THREE.Color(0),z=0,x=1,w=0,H=null,B=null,F=null,J=null,D=null,L,G,I,R,da=new THREE.RenderableVertex,T=new THREE.RenderableVertex,C,ea,S,P,k,M,Y,aa,Z,ha,ka,fa,U=new THREE.Color(0),X=new THREE.Color(0),ca=new THREE.Color(0),ma=new THREE.Color(0),la=new THREE.Color(0),sa=[],K,V,ga,ja,qa,wa,Aa,La,za,Oa,W=new THREE.Rectangle,ta=new THREE.Rectangle,na=new THREE.Rectangle,ua=!1,ia=new THREE.Color,ra=new THREE.Color,xa=new THREE.Color,Ba=new THREE.Color,pa=new THREE.Vector3,
-ya,Da,$,Q,Ea,O,b=16;ya=document.createElement("canvas");ya.width=ya.height=2;Da=ya.getContext("2d");Da.fillStyle="rgba(0,0,0,1)";Da.fillRect(0,0,2,2);$=Da.getImageData(0,0,2,2);Q=$.data;Ea=document.createElement("canvas");Ea.width=Ea.height=b;O=Ea.getContext("2d");O.translate(-b/2,-b/2);O.scale(b,b);b--;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(b,e){p=b;o=e;t=p/2;v=o/2;n.width=p;n.height=o;W.set(-t,-v,t,v);ta.set(-t,
--v,t,v);x=1;w=0;D=J=F=B=H=null};this.setClearColor=function(b,e){y=b;z=e;ta.set(-t,-v,t,v)};this.setClearColorHex=function(b,e){y.setHex(b);z=e;ta.set(-t,-v,t,v)};this.clear=function(){u.setTransform(1,0,0,-1,t,v);ta.isEmpty()||(ta.inflate(1),ta.minSelf(W),z==0?u.clearRect(ta.getX(),ta.getY(),ta.getWidth(),ta.getHeight()):(e(THREE.NormalBlending),c(1),setContextFillStyle("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+z+")"),u.fillRect(ta.getX(),ta.getY(),ta.getWidth(),
-ta.getHeight())),ta.empty())};this.render=function(b,n){function p(b){var e,c,f,h=b.lights;ra.setRGB(0,0,0);xa.setRGB(0,0,0);Ba.setRGB(0,0,0);b=0;for(e=h.length;b<e;b++)c=h[b],f=c.color,c instanceof THREE.AmbientLight?(ra.r+=f.r,ra.g+=f.g,ra.b+=f.b):c instanceof THREE.DirectionalLight?(xa.r+=f.r,xa.g+=f.g,xa.b+=f.b):c instanceof THREE.PointLight&&(Ba.r+=f.r,Ba.g+=f.g,Ba.b+=f.b)}function o(b,e,c,f){var h,g,k,j,m=b.lights,b=0;for(h=m.length;b<h;b++)g=m[b],k=g.color,g instanceof THREE.DirectionalLight?
-(j=c.dot(g.position),j<=0||(j*=g.intensity,f.r+=k.r*j,f.g+=k.g*j,f.b+=k.b*j)):g instanceof THREE.PointLight&&(j=c.dot(pa.sub(g.position,e).normalize()),j<=0||(j*=g.distance==0?1:1-Math.min(e.distanceTo(g.position)/g.distance,1),j!=0&&(j*=g.intensity,f.r+=k.r*j,f.g+=k.g*j,f.b+=k.b*j)))}function Sa(b,h,j){c(j.opacity);e(j.blending);var k,m,n,p,va,o;if(j instanceof THREE.ParticleBasicMaterial){if(j.map)p=j.map.image,va=p.width>>1,o=p.height>>1,j=h.scale.x*t,n=h.scale.y*v,k=j*va,m=n*o,na.set(b.x-k,b.y-
-m,b.x+k,b.y+m),W.instersects(na)&&(u.save(),u.translate(b.x,b.y),u.rotate(-h.rotation),u.scale(j,-n),u.translate(-va,-o),u.drawImage(p,0,0),u.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*t,m=h.scale.y*v,na.set(b.x-k,b.y-m,b.x+k,b.y+m),W.instersects(na)&&(f(j.color.getContextStyle()),g(j.color.getContextStyle()),u.save(),u.translate(b.x,b.y),u.rotate(-h.rotation),u.scale(k,m),j.program(u),u.restore()))}function Ya(b,h,g,j){c(j.opacity);e(j.blending);u.beginPath();u.moveTo(b.positionScreen.x,
-b.positionScreen.y);u.lineTo(h.positionScreen.x,h.positionScreen.y);u.closePath();if(j instanceof THREE.LineBasicMaterial){b=j.linewidth;if(F!=b)u.lineWidth=F=b;b=j.linecap;if(J!=b)u.lineCap=J=b;b=j.linejoin;if(D!=b)u.lineJoin=D=b;f(j.color.getContextStyle());u.stroke();na.inflate(j.linewidth*2)}}function y(b,f,h,g,m,t,p,u,v){j.data.vertices+=3;j.data.faces++;c(u.opacity);e(u.blending);C=b.positionScreen.x;ea=b.positionScreen.y;S=f.positionScreen.x;P=f.positionScreen.y;k=h.positionScreen.x;M=h.positionScreen.y;
-z(C,ea,S,P,k,M);if(u instanceof THREE.MeshBasicMaterial)if(u.map)u.map.mapping instanceof THREE.UVMapping&&(ja=p.uvs[0],H(C,ea,S,P,k,M,ja[g].u,ja[g].v,ja[m].u,ja[m].v,ja[t].u,ja[t].v,u.map));else if(u.envMap){if(u.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=n.matrixWorldInverse,pa.copy(p.vertexNormalsWorld[0]),qa=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,wa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[1]),Aa=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,
-La=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[2]),za=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,Oa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,H(C,ea,S,P,k,M,qa,wa,Aa,La,za,Oa,u.envMap)}else u.wireframe?B(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(u.color);else if(u instanceof THREE.MeshLambertMaterial)u.map&&!u.wireframe&&(u.map.mapping instanceof THREE.UVMapping&&(ja=p.uvs[0],H(C,ea,S,P,k,M,ja[g].u,ja[g].v,ja[m].u,ja[m].v,ja[t].u,ja[t].v,
-u.map)),e(THREE.SubtractiveBlending)),ua?!u.wireframe&&u.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3?(X.r=ca.r=ma.r=ra.r,X.g=ca.g=ma.g=ra.g,X.b=ca.b=ma.b=ra.b,o(v,p.v1.positionWorld,p.vertexNormalsWorld[0],X),o(v,p.v2.positionWorld,p.vertexNormalsWorld[1],ca),o(v,p.v3.positionWorld,p.vertexNormalsWorld[2],ma),la.r=(ca.r+ma.r)*0.5,la.g=(ca.g+ma.g)*0.5,la.b=(ca.b+ma.b)*0.5,ga=Ta(X,ca,ma,la),Pa(C,ea,S,P,k,M,0,0,1,0,0,1,ga)):(ia.r=ra.r,ia.g=ra.g,ia.b=ra.b,o(v,p.centroidWorld,p.normalWorld,
-ia),U.r=Math.max(0,Math.min(u.color.r*ia.r,1)),U.g=Math.max(0,Math.min(u.color.g*ia.g,1)),U.b=Math.max(0,Math.min(u.color.b*ia.b,1)),u.wireframe?B(U,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(U)):u.wireframe?B(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(u.color);else if(u instanceof THREE.MeshDepthMaterial)K=n.near,V=n.far,X.r=X.g=X.b=1-Ma(b.positionScreen.z,K,V),ca.r=ca.g=ca.b=1-Ma(f.positionScreen.z,K,V),ma.r=ma.g=ma.b=1-Ma(h.positionScreen.z,K,V),
-la.r=(ca.r+ma.r)*0.5,la.g=(ca.g+ma.g)*0.5,la.b=(ca.b+ma.b)*0.5,ga=Ta(X,ca,ma,la),Pa(C,ea,S,P,k,M,0,0,1,0,0,1,ga);else if(u instanceof THREE.MeshNormalMaterial)U.r=Qa(p.normalWorld.x),U.g=Qa(p.normalWorld.y),U.b=Qa(p.normalWorld.z),u.wireframe?B(U,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(U)}function w(b,f,h,g,m,p,u,t,v){j.data.vertices+=4;j.data.faces++;c(t.opacity);e(t.blending);if(t.map||t.envMap)y(b,f,g,0,1,3,u,t,v),y(m,h,p,1,2,3,u,t,v);else if(C=b.positionScreen.x,ea=b.positionScreen.y,
-S=f.positionScreen.x,P=f.positionScreen.y,k=h.positionScreen.x,M=h.positionScreen.y,Y=g.positionScreen.x,aa=g.positionScreen.y,Z=m.positionScreen.x,ha=m.positionScreen.y,ka=p.positionScreen.x,fa=p.positionScreen.y,t instanceof THREE.MeshBasicMaterial)x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(t.color);else if(t instanceof THREE.MeshLambertMaterial)ua?!t.wireframe&&t.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==4?(X.r=ca.r=
-ma.r=la.r=ra.r,X.g=ca.g=ma.g=la.g=ra.g,X.b=ca.b=ma.b=la.b=ra.b,o(v,u.v1.positionWorld,u.vertexNormalsWorld[0],X),o(v,u.v2.positionWorld,u.vertexNormalsWorld[1],ca),o(v,u.v4.positionWorld,u.vertexNormalsWorld[3],ma),o(v,u.v3.positionWorld,u.vertexNormalsWorld[2],la),ga=Ta(X,ca,ma,la),z(C,ea,S,P,Y,aa),Pa(C,ea,S,P,Y,aa,0,0,1,0,0,1,ga),z(Z,ha,k,M,ka,fa),Pa(Z,ha,k,M,ka,fa,1,0,1,1,0,1,ga)):(ia.r=ra.r,ia.g=ra.g,ia.b=ra.b,o(v,u.centroidWorld,u.normalWorld,ia),U.r=Math.max(0,Math.min(t.color.r*ia.r,1)),U.g=
-Math.max(0,Math.min(t.color.g*ia.g,1)),U.b=Math.max(0,Math.min(t.color.b*ia.b,1)),x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(U,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(U)):(x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(t.color));else if(t instanceof THREE.MeshNormalMaterial)U.r=Qa(u.normalWorld.x),U.g=Qa(u.normalWorld.y),U.b=Qa(u.normalWorld.z),x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(U,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):
-Ha(U);else if(t instanceof THREE.MeshDepthMaterial)K=n.near,V=n.far,X.r=X.g=X.b=1-Ma(b.positionScreen.z,K,V),ca.r=ca.g=ca.b=1-Ma(f.positionScreen.z,K,V),ma.r=ma.g=ma.b=1-Ma(g.positionScreen.z,K,V),la.r=la.g=la.b=1-Ma(h.positionScreen.z,K,V),ga=Ta(X,ca,ma,la),z(C,ea,S,P,Y,aa),Pa(C,ea,S,P,Y,aa,0,0,1,0,0,1,ga),z(Z,ha,k,M,ka,fa),Pa(Z,ha,k,M,ka,fa,1,0,1,1,0,1,ga)}function z(b,e,c,f,h,g){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(h,g);u.lineTo(b,e);u.closePath()}function x(b,e,c,f,h,g,j,k){u.beginPath();
-u.moveTo(b,e);u.lineTo(c,f);u.lineTo(h,g);u.lineTo(j,k);u.lineTo(b,e);u.closePath()}function B(b,e,c,h){if(F!=e)u.lineWidth=F=e;if(J!=c)u.lineCap=J=c;if(D!=h)u.lineJoin=D=h;f(b.getContextStyle());u.stroke();na.inflate(e*2)}function Ha(b){g(b.getContextStyle());u.fill()}function H(b,e,c,f,h,j,k,m,n,t,p,va,o){if(o.image.width!=0){if(o.needsUpdate==!0||sa[o.id]==void 0){var v=o.wrapS==THREE.RepeatWrapping,Sa=o.wrapT==THREE.RepeatWrapping;sa[o.id]=u.createPattern(o.image,v&&Sa?"repeat":v&&!Sa?"repeat-x":
-!v&&Sa?"repeat-y":"no-repeat");o.needsUpdate=!1}g(sa[o.id]);v=(o.image.width-1)*o.repeat.x;o=(o.image.height-1)*o.repeat.y;k*=v;m*=o;n*=v;t*=o;p*=v;va*=o;c-=b;f-=e;h-=b;j-=e;n-=k;t-=m;p-=k;va-=m;v=1/(n*va-p*t);o=(va*c-t*h)*v;t=(va*f-t*j)*v;c=(n*h-p*c)*v;f=(n*j-p*f)*v;b=b-o*k-c*m;e=e-t*k-f*m;u.save();u.transform(o,t,c,f,b,e);u.fill();u.restore()}}function Pa(b,e,c,f,h,g,j,k,m,n,t,p,o){var va,v;va=o.width-1;v=o.height-1;j*=va;k*=v;m*=va;n*=v;t*=va;p*=v;c-=b;f-=e;h-=b;g-=e;m-=j;n-=k;t-=j;p-=k;v=1/(m*
-p-t*n);va=(p*c-n*h)*v;n=(p*f-n*g)*v;c=(m*h-t*c)*v;f=(m*g-t*f)*v;b=b-va*j-c*k;e=e-n*j-f*k;u.save();u.transform(va,n,c,f,b,e);u.clip();u.drawImage(o,0,0);u.restore()}function Ta(b,e,c,f){var h=~~(b.r*255),g=~~(b.g*255),b=~~(b.b*255),j=~~(e.r*255),k=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),t=~~(f.r*255),p=~~(f.g*255),f=~~(f.b*255);Q[0]=h<0?0:h>255?255:h;Q[1]=g<0?0:g>255?255:g;Q[2]=b<0?0:b>255?255:b;Q[4]=j<0?0:j>255?255:j;Q[5]=k<0?0:k>255?255:k;Q[6]=e<0?0:e>255?255:e;Q[8]=m<
-0?0:m>255?255:m;Q[9]=n<0?0:n>255?255:n;Q[10]=c<0?0:c>255?255:c;Q[12]=t<0?0:t>255?255:t;Q[13]=p<0?0:p>255?255:p;Q[14]=f<0?0:f>255?255:f;Da.putImageData($,0,0);O.drawImage(ya,0,0);return Ea}function Ma(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Qa(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Ia(b,e){var c=e.x-b.x,f=e.y-b.y,h=c*c+f*f;h!=0&&(h=1/Math.sqrt(h),c*=h,f*=h,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Ua,Xa,oa,Ca,Ja,Ra,Va,E;this.autoClear?this.clear():u.setTransform(1,0,0,-1,t,v);j.data.vertices=
-0;j.data.faces=0;h=m.projectScene(b,n,this.sortElements);(ua=b.lights.length>0)&&p(b);Ua=0;for(Xa=h.length;Ua<Xa;Ua++){oa=h[Ua];na.empty();if(oa instanceof THREE.RenderableParticle){L=oa;L.x*=t;L.y*=v;Ca=0;for(Ja=oa.materials.length;Ca<Ja;)E=oa.materials[Ca++],E.opacity!=0&&Sa(L,oa,E,b)}else if(oa instanceof THREE.RenderableLine){if(L=oa.v1,G=oa.v2,L.positionScreen.x*=t,L.positionScreen.y*=v,G.positionScreen.x*=t,G.positionScreen.y*=v,na.addPoint(L.positionScreen.x,L.positionScreen.y),na.addPoint(G.positionScreen.x,
-G.positionScreen.y),W.instersects(na)){Ca=0;for(Ja=oa.materials.length;Ca<Ja;)E=oa.materials[Ca++],E.opacity!=0&&Ya(L,G,oa,E,b)}}else if(oa instanceof THREE.RenderableFace3){if(L=oa.v1,G=oa.v2,I=oa.v3,L.positionScreen.x*=t,L.positionScreen.y*=v,G.positionScreen.x*=t,G.positionScreen.y*=v,I.positionScreen.x*=t,I.positionScreen.y*=v,oa.overdraw&&(Ia(L.positionScreen,G.positionScreen),Ia(G.positionScreen,I.positionScreen),Ia(I.positionScreen,L.positionScreen)),na.add3Points(L.positionScreen.x,L.positionScreen.y,
-G.positionScreen.x,G.positionScreen.y,I.positionScreen.x,I.positionScreen.y),W.instersects(na)){Ca=0;for(Ja=oa.meshMaterials.length;Ca<Ja;)if(E=oa.meshMaterials[Ca++],E instanceof THREE.MeshFaceMaterial){Ra=0;for(Va=oa.faceMaterials.length;Ra<Va;)(E=oa.faceMaterials[Ra++])&&E.opacity!=0&&y(L,G,I,0,1,2,oa,E,b)}else E.opacity!=0&&y(L,G,I,0,1,2,oa,E,b)}}else if(oa instanceof THREE.RenderableFace4&&(L=oa.v1,G=oa.v2,I=oa.v3,R=oa.v4,L.positionScreen.x*=t,L.positionScreen.y*=v,G.positionScreen.x*=t,G.positionScreen.y*=
-v,I.positionScreen.x*=t,I.positionScreen.y*=v,R.positionScreen.x*=t,R.positionScreen.y*=v,da.positionScreen.copy(G.positionScreen),T.positionScreen.copy(R.positionScreen),oa.overdraw&&(Ia(L.positionScreen,G.positionScreen),Ia(G.positionScreen,R.positionScreen),Ia(R.positionScreen,L.positionScreen),Ia(I.positionScreen,da.positionScreen),Ia(I.positionScreen,T.positionScreen)),na.addPoint(L.positionScreen.x,L.positionScreen.y),na.addPoint(G.positionScreen.x,G.positionScreen.y),na.addPoint(I.positionScreen.x,
-I.positionScreen.y),na.addPoint(R.positionScreen.x,R.positionScreen.y),W.instersects(na))){Ca=0;for(Ja=oa.meshMaterials.length;Ca<Ja;)if(E=oa.meshMaterials[Ca++],E instanceof THREE.MeshFaceMaterial){Ra=0;for(Va=oa.faceMaterials.length;Ra<Va;)(E=oa.faceMaterials[Ra++])&&E.opacity!=0&&w(L,G,I,R,da,T,oa,E,b)}else E.opacity!=0&&w(L,G,I,R,da,T,oa,E,b)}ta.addRectangle(na)}u.setTransform(1,0,0,1,0,0)}};
+ya,Da,$,Q,Ea,O,b=16;ya=document.createElement("canvas");ya.width=ya.height=2;Da=ya.getContext("2d");Da.fillStyle="rgba(0,0,0,1)";Da.fillRect(0,0,2,2);$=Da.getImageData(0,0,2,2);Q=$.data;Ea=document.createElement("canvas");Ea.width=Ea.height=b;O=Ea.getContext("2d");O.translate(-b/2,-b/2);O.scale(b,b);b--;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(b,e){p=b;o=e;t=Math.floor(p/2);v=Math.floor(o/2);n.width=p;n.height=o;W.set(-t,
+-v,t,v);ta.set(-t,-v,t,v);x=1;w=0;D=J=F=B=H=null};this.setClearColor=function(b,e){y.copy(b);z=e;ta.set(-t,-v,t,v)};this.setClearColorHex=function(b,e){y.setHex(b);z=e;ta.set(-t,-v,t,v)};this.clear=function(){u.setTransform(1,0,0,-1,t,v);ta.isEmpty()||(ta.inflate(2),ta.minSelf(W),z<1&&u.clearRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight())),z>0&&(e(THREE.NormalBlending),c(1),g("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*
+255)+","+z+")"),u.fillRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight()))),ta.empty())};this.render=function(b,n){function p(b){var e,c,f,h=b.lights;ra.setRGB(0,0,0);xa.setRGB(0,0,0);Ba.setRGB(0,0,0);b=0;for(e=h.length;b<e;b++)c=h[b],f=c.color,c instanceof THREE.AmbientLight?(ra.r+=f.r,ra.g+=f.g,ra.b+=f.b):c instanceof THREE.DirectionalLight?(xa.r+=f.r,xa.g+=f.g,xa.b+=f.b):c instanceof THREE.PointLight&&(Ba.r+=f.r,Ba.g+=f.g,Ba.b+=f.b)}function o(b,
+e,c,f){var h,g,k,j,m=b.lights,b=0;for(h=m.length;b<h;b++)g=m[b],k=g.color,g instanceof THREE.DirectionalLight?(j=c.dot(g.position),j<=0||(j*=g.intensity,f.r+=k.r*j,f.g+=k.g*j,f.b+=k.b*j)):g instanceof THREE.PointLight&&(j=c.dot(pa.sub(g.position,e).normalize()),j<=0||(j*=g.distance==0?1:1-Math.min(e.distanceTo(g.position)/g.distance,1),j!=0&&(j*=g.intensity,f.r+=k.r*j,f.g+=k.g*j,f.b+=k.b*j)))}function Sa(b,h,j){c(j.opacity);e(j.blending);var k,m,n,p,va,o;if(j instanceof THREE.ParticleBasicMaterial){if(j.map)p=
+j.map.image,va=p.width>>1,o=p.height>>1,j=h.scale.x*t,n=h.scale.y*v,k=j*va,m=n*o,na.set(b.x-k,b.y-m,b.x+k,b.y+m),W.instersects(na)&&(u.save(),u.translate(b.x,b.y),u.rotate(-h.rotation),u.scale(j,-n),u.translate(-va,-o),u.drawImage(p,0,0),u.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*t,m=h.scale.y*v,na.set(b.x-k,b.y-m,b.x+k,b.y+m),W.instersects(na)&&(f(j.color.getContextStyle()),g(j.color.getContextStyle()),u.save(),u.translate(b.x,b.y),u.rotate(-h.rotation),u.scale(k,m),
+j.program(u),u.restore()))}function Ya(b,h,g,j){c(j.opacity);e(j.blending);u.beginPath();u.moveTo(b.positionScreen.x,b.positionScreen.y);u.lineTo(h.positionScreen.x,h.positionScreen.y);u.closePath();if(j instanceof THREE.LineBasicMaterial){b=j.linewidth;if(F!=b)u.lineWidth=F=b;b=j.linecap;if(J!=b)u.lineCap=J=b;b=j.linejoin;if(D!=b)u.lineJoin=D=b;f(j.color.getContextStyle());u.stroke();na.inflate(j.linewidth*2)}}function y(b,f,h,g,m,t,p,u,v){j.data.vertices+=3;j.data.faces++;c(u.opacity);e(u.blending);
+C=b.positionScreen.x;ea=b.positionScreen.y;S=f.positionScreen.x;P=f.positionScreen.y;k=h.positionScreen.x;M=h.positionScreen.y;z(C,ea,S,P,k,M);if(u instanceof THREE.MeshBasicMaterial)if(u.map)u.map.mapping instanceof THREE.UVMapping&&(ja=p.uvs[0],H(C,ea,S,P,k,M,ja[g].u,ja[g].v,ja[m].u,ja[m].v,ja[t].u,ja[t].v,u.map));else if(u.envMap){if(u.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=n.matrixWorldInverse,pa.copy(p.vertexNormalsWorld[0]),qa=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,
+wa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[1]),Aa=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,La=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[2]),za=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,Oa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,H(C,ea,S,P,k,M,qa,wa,Aa,La,za,Oa,u.envMap)}else u.wireframe?B(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(u.color);else if(u instanceof THREE.MeshLambertMaterial)u.map&&!u.wireframe&&
+(u.map.mapping instanceof THREE.UVMapping&&(ja=p.uvs[0],H(C,ea,S,P,k,M,ja[g].u,ja[g].v,ja[m].u,ja[m].v,ja[t].u,ja[t].v,u.map)),e(THREE.SubtractiveBlending)),ua?!u.wireframe&&u.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3?(X.r=ca.r=ma.r=ra.r,X.g=ca.g=ma.g=ra.g,X.b=ca.b=ma.b=ra.b,o(v,p.v1.positionWorld,p.vertexNormalsWorld[0],X),o(v,p.v2.positionWorld,p.vertexNormalsWorld[1],ca),o(v,p.v3.positionWorld,p.vertexNormalsWorld[2],ma),la.r=(ca.r+ma.r)*0.5,la.g=(ca.g+ma.g)*0.5,la.b=(ca.b+ma.b)*
+0.5,ga=Ta(X,ca,ma,la),Pa(C,ea,S,P,k,M,0,0,1,0,0,1,ga)):(ia.r=ra.r,ia.g=ra.g,ia.b=ra.b,o(v,p.centroidWorld,p.normalWorld,ia),U.r=Math.max(0,Math.min(u.color.r*ia.r,1)),U.g=Math.max(0,Math.min(u.color.g*ia.g,1)),U.b=Math.max(0,Math.min(u.color.b*ia.b,1)),u.wireframe?B(U,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(U)):u.wireframe?B(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(u.color);else if(u instanceof THREE.MeshDepthMaterial)K=n.near,V=n.far,X.r=X.g=
+X.b=1-Ma(b.positionScreen.z,K,V),ca.r=ca.g=ca.b=1-Ma(f.positionScreen.z,K,V),ma.r=ma.g=ma.b=1-Ma(h.positionScreen.z,K,V),la.r=(ca.r+ma.r)*0.5,la.g=(ca.g+ma.g)*0.5,la.b=(ca.b+ma.b)*0.5,ga=Ta(X,ca,ma,la),Pa(C,ea,S,P,k,M,0,0,1,0,0,1,ga);else if(u instanceof THREE.MeshNormalMaterial)U.r=Qa(p.normalWorld.x),U.g=Qa(p.normalWorld.y),U.b=Qa(p.normalWorld.z),u.wireframe?B(U,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ha(U)}function w(b,f,h,g,m,p,u,t,v){j.data.vertices+=4;j.data.faces++;c(t.opacity);
+e(t.blending);if(t.map||t.envMap)y(b,f,g,0,1,3,u,t,v),y(m,h,p,1,2,3,u,t,v);else if(C=b.positionScreen.x,ea=b.positionScreen.y,S=f.positionScreen.x,P=f.positionScreen.y,k=h.positionScreen.x,M=h.positionScreen.y,Y=g.positionScreen.x,aa=g.positionScreen.y,Z=m.positionScreen.x,ha=m.positionScreen.y,ka=p.positionScreen.x,fa=p.positionScreen.y,t instanceof THREE.MeshBasicMaterial)x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(t.color);else if(t instanceof
+THREE.MeshLambertMaterial)ua?!t.wireframe&&t.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==4?(X.r=ca.r=ma.r=la.r=ra.r,X.g=ca.g=ma.g=la.g=ra.g,X.b=ca.b=ma.b=la.b=ra.b,o(v,u.v1.positionWorld,u.vertexNormalsWorld[0],X),o(v,u.v2.positionWorld,u.vertexNormalsWorld[1],ca),o(v,u.v4.positionWorld,u.vertexNormalsWorld[3],ma),o(v,u.v3.positionWorld,u.vertexNormalsWorld[2],la),ga=Ta(X,ca,ma,la),z(C,ea,S,P,Y,aa),Pa(C,ea,S,P,Y,aa,0,0,1,0,0,1,ga),z(Z,ha,k,M,ka,fa),Pa(Z,ha,k,M,ka,fa,1,0,1,1,0,1,ga)):
+(ia.r=ra.r,ia.g=ra.g,ia.b=ra.b,o(v,u.centroidWorld,u.normalWorld,ia),U.r=Math.max(0,Math.min(t.color.r*ia.r,1)),U.g=Math.max(0,Math.min(t.color.g*ia.g,1)),U.b=Math.max(0,Math.min(t.color.b*ia.b,1)),x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(U,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(U)):(x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(t.color));else if(t instanceof THREE.MeshNormalMaterial)U.r=Qa(u.normalWorld.x),U.g=Qa(u.normalWorld.y),
+U.b=Qa(u.normalWorld.z),x(C,ea,S,P,k,M,Y,aa),t.wireframe?B(U,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ha(U);else if(t instanceof THREE.MeshDepthMaterial)K=n.near,V=n.far,X.r=X.g=X.b=1-Ma(b.positionScreen.z,K,V),ca.r=ca.g=ca.b=1-Ma(f.positionScreen.z,K,V),ma.r=ma.g=ma.b=1-Ma(g.positionScreen.z,K,V),la.r=la.g=la.b=1-Ma(h.positionScreen.z,K,V),ga=Ta(X,ca,ma,la),z(C,ea,S,P,Y,aa),Pa(C,ea,S,P,Y,aa,0,0,1,0,0,1,ga),z(Z,ha,k,M,ka,fa),Pa(Z,ha,k,M,ka,fa,1,0,1,1,0,1,ga)}function z(b,e,c,f,
+h,g){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(h,g);u.lineTo(b,e);u.closePath()}function x(b,e,c,f,h,g,j,k){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(h,g);u.lineTo(j,k);u.lineTo(b,e);u.closePath()}function B(b,e,c,h){if(F!=e)u.lineWidth=F=e;if(J!=c)u.lineCap=J=c;if(D!=h)u.lineJoin=D=h;f(b.getContextStyle());u.stroke();na.inflate(e*2)}function Ha(b){g(b.getContextStyle());u.fill()}function H(b,e,c,f,h,j,k,m,n,t,p,va,o){if(o.image.width!=0){if(o.needsUpdate==!0||sa[o.id]==void 0){var v=
+o.wrapS==THREE.RepeatWrapping,Sa=o.wrapT==THREE.RepeatWrapping;sa[o.id]=u.createPattern(o.image,v&&Sa?"repeat":v&&!Sa?"repeat-x":!v&&Sa?"repeat-y":"no-repeat");o.needsUpdate=!1}g(sa[o.id]);v=(o.image.width-1)*o.repeat.x;o=(o.image.height-1)*o.repeat.y;k*=v;m*=o;n*=v;t*=o;p*=v;va*=o;c-=b;f-=e;h-=b;j-=e;n-=k;t-=m;p-=k;va-=m;v=1/(n*va-p*t);o=(va*c-t*h)*v;t=(va*f-t*j)*v;c=(n*h-p*c)*v;f=(n*j-p*f)*v;b=b-o*k-c*m;e=e-t*k-f*m;u.save();u.transform(o,t,c,f,b,e);u.fill();u.restore()}}function Pa(b,e,c,f,h,g,
+j,k,m,n,t,p,o){var va,v;va=o.width-1;v=o.height-1;j*=va;k*=v;m*=va;n*=v;t*=va;p*=v;c-=b;f-=e;h-=b;g-=e;m-=j;n-=k;t-=j;p-=k;v=1/(m*p-t*n);va=(p*c-n*h)*v;n=(p*f-n*g)*v;c=(m*h-t*c)*v;f=(m*g-t*f)*v;b=b-va*j-c*k;e=e-n*j-f*k;u.save();u.transform(va,n,c,f,b,e);u.clip();u.drawImage(o,0,0);u.restore()}function Ta(b,e,c,f){var h=~~(b.r*255),g=~~(b.g*255),b=~~(b.b*255),j=~~(e.r*255),k=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),t=~~(f.r*255),p=~~(f.g*255),f=~~(f.b*255);Q[0]=h<0?0:h>255?
+255:h;Q[1]=g<0?0:g>255?255:g;Q[2]=b<0?0:b>255?255:b;Q[4]=j<0?0:j>255?255:j;Q[5]=k<0?0:k>255?255:k;Q[6]=e<0?0:e>255?255:e;Q[8]=m<0?0:m>255?255:m;Q[9]=n<0?0:n>255?255:n;Q[10]=c<0?0:c>255?255:c;Q[12]=t<0?0:t>255?255:t;Q[13]=p<0?0:p>255?255:p;Q[14]=f<0?0:f>255?255:f;Da.putImageData($,0,0);O.drawImage(ya,0,0);return Ea}function Ma(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Qa(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Ia(b,e){var c=e.x-b.x,f=e.y-b.y,h=c*c+f*f;h!=0&&(h=1/Math.sqrt(h),c*=h,f*=h,
+e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Ua,Xa,oa,Ca,Ja,Ra,Va,E;this.autoClear?this.clear():u.setTransform(1,0,0,-1,t,v);j.data.vertices=0;j.data.faces=0;h=m.projectScene(b,n,this.sortElements);(ua=b.lights.length>0)&&p(b);Ua=0;for(Xa=h.length;Ua<Xa;Ua++){oa=h[Ua];na.empty();if(oa instanceof THREE.RenderableParticle){L=oa;L.x*=t;L.y*=v;Ca=0;for(Ja=oa.materials.length;Ca<Ja;)E=oa.materials[Ca++],E.opacity!=0&&Sa(L,oa,E,b)}else if(oa instanceof THREE.RenderableLine){if(L=oa.v1,G=oa.v2,L.positionScreen.x*=t,
+L.positionScreen.y*=v,G.positionScreen.x*=t,G.positionScreen.y*=v,na.addPoint(L.positionScreen.x,L.positionScreen.y),na.addPoint(G.positionScreen.x,G.positionScreen.y),W.instersects(na)){Ca=0;for(Ja=oa.materials.length;Ca<Ja;)E=oa.materials[Ca++],E.opacity!=0&&Ya(L,G,oa,E,b)}}else if(oa instanceof THREE.RenderableFace3){if(L=oa.v1,G=oa.v2,I=oa.v3,L.positionScreen.x*=t,L.positionScreen.y*=v,G.positionScreen.x*=t,G.positionScreen.y*=v,I.positionScreen.x*=t,I.positionScreen.y*=v,oa.overdraw&&(Ia(L.positionScreen,
+G.positionScreen),Ia(G.positionScreen,I.positionScreen),Ia(I.positionScreen,L.positionScreen)),na.add3Points(L.positionScreen.x,L.positionScreen.y,G.positionScreen.x,G.positionScreen.y,I.positionScreen.x,I.positionScreen.y),W.instersects(na)){Ca=0;for(Ja=oa.meshMaterials.length;Ca<Ja;)if(E=oa.meshMaterials[Ca++],E instanceof THREE.MeshFaceMaterial){Ra=0;for(Va=oa.faceMaterials.length;Ra<Va;)(E=oa.faceMaterials[Ra++])&&E.opacity!=0&&y(L,G,I,0,1,2,oa,E,b)}else E.opacity!=0&&y(L,G,I,0,1,2,oa,E,b)}}else if(oa instanceof
+THREE.RenderableFace4&&(L=oa.v1,G=oa.v2,I=oa.v3,R=oa.v4,L.positionScreen.x*=t,L.positionScreen.y*=v,G.positionScreen.x*=t,G.positionScreen.y*=v,I.positionScreen.x*=t,I.positionScreen.y*=v,R.positionScreen.x*=t,R.positionScreen.y*=v,da.positionScreen.copy(G.positionScreen),T.positionScreen.copy(R.positionScreen),oa.overdraw&&(Ia(L.positionScreen,G.positionScreen),Ia(G.positionScreen,R.positionScreen),Ia(R.positionScreen,L.positionScreen),Ia(I.positionScreen,da.positionScreen),Ia(I.positionScreen,T.positionScreen)),
+na.addPoint(L.positionScreen.x,L.positionScreen.y),na.addPoint(G.positionScreen.x,G.positionScreen.y),na.addPoint(I.positionScreen.x,I.positionScreen.y),na.addPoint(R.positionScreen.x,R.positionScreen.y),W.instersects(na))){Ca=0;for(Ja=oa.meshMaterials.length;Ca<Ja;)if(E=oa.meshMaterials[Ca++],E instanceof THREE.MeshFaceMaterial){Ra=0;for(Va=oa.faceMaterials.length;Ra<Va;)(E=oa.faceMaterials[Ra++])&&E.opacity!=0&&w(L,G,I,R,da,T,oa,E,b)}else E.opacity!=0&&w(L,G,I,R,da,T,oa,E,b)}ta.addRectangle(na)}u.setTransform(1,
+0,0,1,0,0)}};
 THREE.SVGRenderer=function(){function b(b,e,c){var f,h,g,j;f=0;for(h=b.lights.length;f<h;f++)g=b.lights[f],g instanceof THREE.DirectionalLight?(j=e.normalWorld.dot(g.position)*g.intensity,j>0&&(c.r+=g.color.r*j,c.g+=g.color.g*j,c.b+=g.color.b*j)):g instanceof THREE.PointLight&&(R.sub(g.position,e.centroidWorld),R.normalize(),j=e.normalWorld.dot(R)*g.intensity,j>0&&(c.r+=g.color.r*j,c.g+=g.color.g*j,c.b+=g.color.b*j))}function c(e,c,h,m,t,p){j.data.vertices+=3;j.data.faces++;C=f(ea++);C.setAttribute("d",
 "M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?F.copy(t.color):t instanceof THREE.MeshLambertMaterial?B?(J.r=D.r,J.g=D.g,J.b=D.b,b(p,m,J),F.r=Math.max(0,Math.min(t.color.r*J.r,1)),F.g=Math.max(0,Math.min(t.color.g*J.g,1)),F.b=Math.max(0,Math.min(t.color.b*J.b,1))):F.copy(t.color):t instanceof THREE.MeshDepthMaterial?(I=1-t.__2near/(t.__farPlusNear-m.z*t.__farMinusNear),
 F.setRGB(I,I,I)):t instanceof THREE.MeshNormalMaterial&&F.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));t.wireframe?C.setAttribute("style","fill: none; stroke: "+F.getContextStyle()+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):C.setAttribute("style","fill: "+F.getContextStyle()+"; fill-opacity: "+t.opacity);n.appendChild(C)}function e(e,c,h,m,t,p,u){j.data.vertices+=4;j.data.faces++;
@@ -269,7 +270,7 @@ g.uvOffset.x,g.uvOffset.y),k.uniform2f(h.alignment,g.alignment.x,g.alignment.y),
 V*0.5,u=16/V,v=[u*t,u],y=[1,1,0],w=[1,1],x=Q.uniforms;e=Q.attributes;k.useProgram(Q.program);Y=Q.program;U=fa=-1;Ea||(k.enableVertexAttribArray(Q.attributes.vertex),k.enableVertexAttribArray(Q.attributes.uv),Ea=!0);k.uniform1i(x.occlusionMap,0);k.uniform1i(x.map,1);k.bindBuffer(k.ARRAY_BUFFER,Q.vertexBuffer);k.vertexAttribPointer(e.vertex,2,k.FLOAT,!1,16,0);k.vertexAttribPointer(e.uv,2,k.FLOAT,!1,16,8);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,Q.elementBuffer);k.disable(k.CULL_FACE);k.depthMask(!1);k.activeTexture(k.TEXTURE0);
 k.bindTexture(k.TEXTURE_2D,Q.occlusionTexture);k.activeTexture(k.TEXTURE1);for(f=0;f<g;f++)if(e=b.__webglLensFlares[f].object,n.set(e.matrixWorld.n14,e.matrixWorld.n24,e.matrixWorld.n34),c.matrixWorldInverse.multiplyVector3(n),c.projectionMatrix.multiplyVector3(n),y[0]=n.x,y[1]=n.y,y[2]=n.z,w[0]=y[0]*p+p,w[1]=y[1]*o+o,Q.hasVertexTexture||w[0]>0&&w[0]<K&&w[1]>0&&w[1]<V){k.bindTexture(k.TEXTURE_2D,Q.tempTexture);k.copyTexImage2D(k.TEXTURE_2D,0,k.RGB,w[0]-8,w[1]-8,16,16,0);k.uniform1i(x.renderType,0);
 k.uniform2fv(x.scale,v);k.uniform3fv(x.screenPosition,y);k.disable(k.BLEND);k.enable(k.DEPTH_TEST);k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0);k.bindTexture(k.TEXTURE_2D,Q.occlusionTexture);k.copyTexImage2D(k.TEXTURE_2D,0,k.RGBA,w[0]-8,w[1]-8,16,16,0);k.uniform1i(x.renderType,1);k.disable(k.DEPTH_TEST);k.bindTexture(k.TEXTURE_2D,Q.tempTexture);k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0);e.positionScreen.x=y[0];e.positionScreen.y=y[1];e.positionScreen.z=y[2];e.customUpdateCallback?e.customUpdateCallback(e):
-e.updateLensFlares();k.uniform1i(x.renderType,2);k.enable(k.BLEND);h=0;for(j=e.lensFlares.length;h<j;h++)if(m=e.lensFlares[h],m.opacity>0.0010&&m.scale>0.0010)y[0]=m.x,y[1]=m.y,y[2]=m.z,u=m.size*m.scale/V,v[0]=u*t,v[1]=u,k.uniform3fv(x.screenPosition,y),k.uniform2fv(x.scale,v),k.uniform1f(x.rotation,m.rotation),k.uniform1f(x.opacity,m.opacity),I(m.blending),da(m.texture,1),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0)}k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST);k.depthMask(Z)}function H(b,c,e){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,
+e.updateLensFlares();k.uniform1i(x.renderType,2);k.enable(k.BLEND);h=0;for(j=e.lensFlares.length;h<j;h++)if(m=e.lensFlares[h],m.opacity>0.001&&m.scale>0.001)y[0]=m.x,y[1]=m.y,y[2]=m.z,u=m.size*m.scale/V,v[0]=u*t,v[1]=u,k.uniform3fv(x.screenPosition,y),k.uniform2fv(x.scale,v),k.uniform1f(x.rotation,m.rotation),k.uniform1f(x.opacity,m.opacity),I(m.blending),da(m.texture,1),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0)}k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST);k.depthMask(Z)}function H(b,c,e){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,
 b.matrixWorld,b._modelViewMatrixArray);e&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function B(b){var c,e,f,g;g=b.__materials;b=0;for(e=g.length;b<e;b++)if(f=g[b],f.attributes)for(c in f.attributes)if(f.attributes[c].needsUpdate)return!0;return!1}function F(b){var c,e,f,g;g=b.__materials;b=0;for(e=g.length;b<e;b++)if(f=g[b],f.attributes)for(c in f.attributes)f.attributes[c].needsUpdate=!1}function J(b){var e,f,g,h;if(b instanceof THREE.Mesh){f=b.geometry;
 for(e in f.geometryGroups)if(g=f.geometryGroups[e],h=B(g),f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||h){h=g;var j=b,m=k.DYNAMIC_DRAW;if(h.__inittedArrays){var n=void 0,t=void 0,p=void 0,o=void 0,u=p=void 0,v=void 0,y=void 0,w=void 0,x=void 0,z=void 0,H=void 0,G=void 0,J=void 0,K=void 0,D=void 0,I=void 0,V=void 0,E=o=w=o=y=v=void 0,A=void 0,C=A=E=v=void 0,M=void 0,U=C=A=E=p=p=u=w=o=C=A=E=M=C=A=E=M=C=A=E=void 0,L=
 0,ga=0,X=0,Q=0,R=0,Z=0,O=0,T=0,ja=0,N=0,P=0,C=E=0,C=void 0,S=h.__vertexArray,da=h.__uvArray,ea=h.__uv2Array,ka=h.__normalArray,W=h.__tangentArray,aa=h.__colorArray,Y=h.__skinVertexAArray,fa=h.__skinVertexBArray,ca=h.__skinIndexArray,$=h.__skinWeightArray,ma=h.__morphTargetsArrays,ha=h.__webglCustomAttributes,A=void 0,qa=h.__faceArray,la=h.__lineArray,na=h.__needsSmoothNormals,z=h.__vertexColorType,x=h.__uvType,H=h.__normalType,ia=j.geometry,sa=ia.__dirtyVertices,pa=ia.__dirtyElements,wa=ia.__dirtyUvs,
@@ -396,7 +397,7 @@ this.getPrevKeyWith("pos",u,h.index-1).pos,this.points[1]=g,this.points[2]=j,thi
 THREE.Animation.prototype.interpolateCatmullRom=function(b,c){var e=[],f=[],g,j,h,m,n,p;g=(b.length-1)*c;j=Math.floor(g);g-=j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>b.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];m=b[e[1]];n=b[e[2]];p=b[e[3]];e=g*g;h=g*e;f[0]=this.interpolate(j[0],m[0],n[0],p[0],g,e,h);f[1]=this.interpolate(j[1],m[1],n[1],p[1],g,e,h);f[2]=this.interpolate(j[2],m[2],n[2],p[2],g,e,h);return f};
 THREE.Animation.prototype.interpolate=function(b,c,e,f,g,j,h){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*h+(-3*(c-e)-2*b-f)*j+b*g+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,e){var f=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e=e<f.length-1?e:f.length-1:e%=f.length;e<f.length;e++)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(b,c,e){for(var f=this.data.hierarchy[c].keys,e=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e>0?e:0:e>=0?e:e+f.length;e>=0;e--)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[f.length-1]};
-THREE.FirstPersonCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=
+THREE.FirstPersonCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=
 b.movementSpeed;if(b.lookSpeed!==void 0)this.lookSpeed=b.lookSpeed;if(b.noFly!==void 0)this.noFly=b.noFly;if(b.lookVertical!==void 0)this.lookVertical=b.lookVertical;if(b.autoForward!==void 0)this.autoForward=b.autoForward;if(b.activeLook!==void 0)this.activeLook=b.activeLook;if(b.heightSpeed!==void 0)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==void 0)this.heightCoef=b.heightCoef;if(b.heightMin!==void 0)this.heightMin=b.heightMin;if(b.heightMax!==void 0)this.heightMax=b.heightMax;if(b.constrainVertical!==
 void 0)this.constrainVertical=b.constrainVertical;if(b.verticalMin!==void 0)this.verticalMin=b.verticalMin;if(b.verticalMax!==void 0)this.verticalMax=b.verticalMax;if(b.domElement!==void 0)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();
 b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=
@@ -408,7 +409,7 @@ Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListen
 THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))};
 THREE.PathCamera=function(b){function c(b,e,c,f){var h={name:c,fps:0.6,length:f,hierarchy:[]},g,j=e.getControlPointsArray(),m=e.getLength(),n=j.length,H=0;g=n-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[g]={time:f,pos:j[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;g<n-1;g++)H=f*m.chunks[g]/m.total,e.keys[g]={time:H,pos:j[g]};h.hierarchy[0]=e;THREE.AnimationHandler.add(h);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,e){var c,
 f,h=new THREE.Geometry;for(c=0;c<b.points.length*e;c++)f=c/(b.points.length*e),f=b.getPoint(f),h.vertices[c]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return h}function f(b,c){var f=e(c,10),h=e(c,10),g=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,g);particleObj=new THREE.ParticleSystem(h,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.addChild(lineObj);particleObj.scale.set(1,1,1);b.addChild(particleObj);h=new THREE.SphereGeometry(1,
-16,8);g=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(h,g),f.position.copy(c.points[i]),f.updateMatrix(),b.addChild(f)}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=
+16,8);g=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(h,g),f.position.copy(c.points[i]),f.updateMatrix(),b.addChild(f)}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookHorizontal=
 this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(b){if(b.duration!==void 0)this.duration=b.duration*1E3;if(b.waypoints!==void 0)this.waypoints=b.waypoints;if(b.useConstantSpeed!==void 0)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==void 0)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==void 0)this.createDebugPath=b.createDebugPath;if(b.createDebugDummy!==
 void 0)this.createDebugDummy=b.createDebugDummy;if(b.lookSpeed!==void 0)this.lookSpeed=b.lookSpeed;if(b.lookVertical!==void 0)this.lookVertical=b.lookVertical;if(b.lookHorizontal!==void 0)this.lookHorizontal=b.lookHorizontal;if(b.verticalAngleMap!==void 0)this.verticalAngleMap=b.verticalAngleMap;if(b.horizontalAngleMap!==void 0)this.horizontalAngleMap=b.horizontalAngleMap;if(b.domElement!==void 0)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=
 window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,j=Math.PI/180;this.update=function(b,e,c){var f,h;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*j;this.theta=this.lon*j;f=this.phi%g;this.phi=f>=0?f:f+g;f=this.verticalAngleMap.srcRange;h=this.verticalAngleMap.dstRange;var m=h[1]-h[0];this.phi=
@@ -416,7 +417,7 @@ TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(h[1]-h[0])/(f[1]-f[0])+h[0]-h
 b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),h=new THREE.MeshLambertMaterial({color:65280}),m=new THREE.CubeGeometry(10,10,20),n=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(n,h);b.position.set(0,10,0);this.animation=
 c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,e){return function(){e.apply(b,arguments)}}(this,this.onMouseMove),
 !1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
-THREE.FlyCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==void 0)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==void 0)this.dragToLook=b.dragToLook;if(b.autoForward!==void 0)this.autoForward=
+THREE.FlyCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.domElement=document;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==void 0)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==void 0)this.dragToLook=b.dragToLook;if(b.autoForward!==void 0)this.autoForward=
 b.autoForward;if(b.domElement!==void 0)this.domElement=b.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier=
 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};
 this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;
@@ -506,7 +507,7 @@ THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THRE
 THREE.IcosahedronGeometry=function(b){function c(b,c,e){var f=Math.sqrt(b*b+c*c+e*e);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(b/f,c/f,e/f)))-1}function e(b,c,e,f){f.faces.push(new THREE.Face3(b,c,e))}function f(b,e){var f=g.vertices[b].position,h=g.vertices[e].position;return c((f.x+h.x)/2,(f.y+h.y)/2,(f.z+h.z)/2)}var g=this,j=new THREE.Geometry,h;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;c(-1,b,0);c(1,b,0);c(-1,-b,0);c(1,-b,0);c(0,-1,b);c(0,1,b);c(0,-1,
 -b);c(0,1,-b);c(b,0,-1);c(b,0,1);c(-b,0,-1);c(-b,0,1);e(0,11,5,j);e(0,5,1,j);e(0,1,7,j);e(0,7,10,j);e(0,10,11,j);e(1,5,9,j);e(5,11,4,j);e(11,10,2,j);e(10,7,6,j);e(7,1,8,j);e(3,9,4,j);e(3,4,2,j);e(3,2,6,j);e(3,6,8,j);e(3,8,9,j);e(4,9,5,j);e(2,4,11,j);e(6,2,10,j);e(8,6,7,j);e(9,8,1,j);for(b=0;b<this.subdivisions;b++){h=new THREE.Geometry;for(var m in j.faces){var n=f(j.faces[m].a,j.faces[m].b),p=f(j.faces[m].b,j.faces[m].c),o=f(j.faces[m].c,j.faces[m].a);e(j.faces[m].a,n,o,h);e(j.faces[m].b,p,n,h);
 e(j.faces[m].c,o,p,h);e(n,p,o,h)}j.faces=h.faces}g.faces=j.faces;delete j;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
-THREE.LatheGeometry=function(b,c,e){THREE.Geometry.call(this);this.steps=c||12;this.angle=e||2*Math.PI;for(var c=this.angle/this.steps,e=[],f=[],g=[],j=[],h=(new THREE.Matrix4).setRotationZ(c),m=0;m<b.length;m++)this.vertices.push(new THREE.Vertex(b[m])),e[m]=b[m].clone(),f[m]=this.vertices.length-1;for(var n=0;n<=this.angle+0.0010;n+=c){for(m=0;m<e.length;m++)n<this.angle?(e[m]=h.multiplyVector3(e[m].clone()),this.vertices.push(new THREE.Vertex(e[m])),g[m]=this.vertices.length-1):g=j;n==0&&(j=f);
+THREE.LatheGeometry=function(b,c,e){THREE.Geometry.call(this);this.steps=c||12;this.angle=e||2*Math.PI;for(var c=this.angle/this.steps,e=[],f=[],g=[],j=[],h=(new THREE.Matrix4).setRotationZ(c),m=0;m<b.length;m++)this.vertices.push(new THREE.Vertex(b[m])),e[m]=b[m].clone(),f[m]=this.vertices.length-1;for(var n=0;n<=this.angle+0.001;n+=c){for(m=0;m<e.length;m++)n<this.angle?(e[m]=h.multiplyVector3(e[m].clone()),this.vertices.push(new THREE.Vertex(e[m])),g[m]=this.vertices.length-1):g=j;n==0&&(j=f);
 for(m=0;m<f.length-1;m++)this.faces.push(new THREE.Face4(g[m],g[m+1],f[m+1],f[m])),this.faceVertexUvs[0].push([new THREE.UV(1-n/this.angle,m/b.length),new THREE.UV(1-n/this.angle,(m+1)/b.length),new THREE.UV(1-(n-c)/this.angle,(m+1)/b.length),new THREE.UV(1-(n-c)/this.angle,m/b.length)]);f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
 THREE.PlaneGeometry=function(b,c,e,f){THREE.Geometry.call(this);var g,j=b/2,h=c/2,e=e||1,f=f||1,m=e+1,n=f+1;b/=e;var p=c/f;for(g=0;g<n;g++)for(c=0;c<m;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-j,-(g*p-h),0)));for(g=0;g<f;g++)for(c=0;c<e;c++)this.faces.push(new THREE.Face4(c+m*g,c+m*(g+1),c+1+m*(g+1),c+1+m*g)),this.faceVertexUvs[0].push([new THREE.UV(c/e,g/f),new THREE.UV(c/e,(g+1)/f),new THREE.UV((c+1)/e,(g+1)/f),new THREE.UV((c+1)/e,g/f)]);this.computeCentroids();this.computeFaceNormals()};
 THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;

+ 26 - 25
build/custom/ThreeCanvas.js

@@ -54,7 +54,7 @@ THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){t
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=
 a,this.w*=a);return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,e=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-d*e;this.y=c*a+f*e+d*g-b*h;this.z=d*a+f*h+b*e-c*g;this.w=f*a-b*g-c*e-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,e=this.y,h=this.z,
 k=this.w,l=k*c+e*f-h*d,m=k*d+h*c-g*f,i=k*f+g*d-e*c,c=-g*c-e*d-h*f;b.x=l*k+c*-g+m*-h-i*-e;b.y=m*k+c*-e+i*-g-l*-h;b.z=i*k+c*-h+l*-e-m*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,f,g,e){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=e instanceof Array?e:[e];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -118,30 +118,31 @@ q++,p=A,p.v1.positionScreen.copy(x),p.v2.positionScreen.copy(E),p.z=Math.max(x.z
 f.projectionMatrix.n22)/(B.w+f.projectionMatrix.n24)),s.materials=u.materials,D.push(s);g&&D.sort(b);return D}};
 THREE.CanvasRenderer=function(a){function b(a){if(v!=a)j.globalAlpha=v=a}function c(a){if(s!=a){switch(a){case THREE.NormalBlending:j.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:j.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:j.globalCompositeOperation="darker"}s=a}}function d(a){if(O!=a)j.strokeStyle=O=a}function f(a){if(P!=a)j.fillStyle=P=a}var g=this,e=null,h=new THREE.Projector,a=a||{},k=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
 l,m,i,n,j=k.getContext("2d"),p=new THREE.Color(0),q=0,v=1,s=0,O=null,P=null,y=null,B=null,o=null,t,r,x,E,Z=new THREE.RenderableVertex,$=new THREE.RenderableVertex,I,D,J,M,F,K,G,Q,w,N,L,pa,C=new THREE.Color(0),u=new THREE.Color(0),A=new THREE.Color(0),H=new THREE.Color(0),S=new THREE.Color(0),la=[],V,ca,W,aa,Da,Ea,Fa,Ga,Ha,Ia,ja=new THREE.Rectangle,X=new THREE.Rectangle,U=new THREE.Rectangle,za=!1,ba=new THREE.Color,Y=new THREE.Color,ta=new THREE.Color,ua=new THREE.Color,R=new THREE.Vector3,qa,ra,
-Aa,da,sa,va,a=16;qa=document.createElement("canvas");qa.width=qa.height=2;ra=qa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0,0,2,2);Aa=ra.getImageData(0,0,2,2);da=Aa.data;sa=document.createElement("canvas");sa.width=sa.height=a;va=sa.getContext("2d");va.translate(-a/2,-a/2);va.scale(a,a);a--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(a,b){l=a;m=b;i=l/2;n=m/2;k.width=l;k.height=m;ja.set(-i,-n,i,n);X.set(-i,
--n,i,n);v=1;s=0;o=B=y=P=O=null};this.setClearColor=function(a,b){p=a;q=b;X.set(-i,-n,i,n)};this.setClearColorHex=function(a,b){p.setHex(a);q=b;X.set(-i,-n,i,n)};this.clear=function(){j.setTransform(1,0,0,-1,i,n);X.isEmpty()||(X.inflate(1),X.minSelf(ja),q==0?j.clearRect(X.getX(),X.getY(),X.getWidth(),X.getHeight()):(c(THREE.NormalBlending),b(1),setContextFillStyle("rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+q+")"),j.fillRect(X.getX(),X.getY(),X.getWidth(),X.getHeight())),
-X.empty())};this.render=function(a,l){function k(a){var b,c,d,f=a.lights;Y.setRGB(0,0,0);ta.setRGB(0,0,0);ua.setRGB(0,0,0);a=0;for(b=f.length;a<b;a++)c=f[a],d=c.color,c instanceof THREE.AmbientLight?(Y.r+=d.r,Y.g+=d.g,Y.b+=d.b):c instanceof THREE.DirectionalLight?(ta.r+=d.r,ta.g+=d.g,ta.b+=d.b):c instanceof THREE.PointLight&&(ua.r+=d.r,ua.g+=d.g,ua.b+=d.b)}function m(a,b,c,d){var f,e,g,h,l=a.lights,a=0;for(f=l.length;a<f;a++)e=l[a],g=e.color,e instanceof THREE.DirectionalLight?(h=c.dot(e.position),
-h<=0||(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)):e instanceof THREE.PointLight&&(h=c.dot(R.sub(e.position,b).normalize()),h<=0||(h*=e.distance==0?1:1-Math.min(b.distanceTo(e.position)/e.distance,1),h!=0&&(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)))}function p(a,e,g){b(g.opacity);c(g.blending);var h,l,m,k,Ba,o;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)k=g.map.image,Ba=k.width>>1,o=k.height>>1,g=e.scale.x*i,m=e.scale.y*n,h=g*Ba,l=m*o,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(U)&&
-(j.save(),j.translate(a.x,a.y),j.rotate(-e.rotation),j.scale(g,-m),j.translate(-Ba,-o),j.drawImage(k,0,0),j.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*i,l=e.scale.y*n,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(U)&&(d(g.color.getContextStyle()),f(g.color.getContextStyle()),j.save(),j.translate(a.x,a.y),j.rotate(-e.rotation),j.scale(h,l),g.program(j),j.restore()))}function q(a,e,f,g){b(g.opacity);c(g.blending);j.beginPath();j.moveTo(a.positionScreen.x,a.positionScreen.y);
-j.lineTo(e.positionScreen.x,e.positionScreen.y);j.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)j.lineWidth=y=a;a=g.linecap;if(B!=a)j.lineCap=B=a;a=g.linejoin;if(o!=a)j.lineJoin=o=a;d(g.color.getContextStyle());j.stroke();U.inflate(g.linewidth*2)}}function s(a,d,e,f,h,j,i,k,n){g.data.vertices+=3;g.data.faces++;b(k.opacity);c(k.blending);I=a.positionScreen.x;D=a.positionScreen.y;J=d.positionScreen.x;M=d.positionScreen.y;F=e.positionScreen.x;K=e.positionScreen.y;O(I,D,J,
-M,F,K);if(k instanceof THREE.MeshBasicMaterial)if(k.map)k.map.mapping instanceof THREE.UVMapping&&(aa=i.uvs[0],Ca(I,D,J,M,F,K,aa[f].u,aa[f].v,aa[h].u,aa[h].v,aa[j].u,aa[j].v,k.map));else if(k.envMap){if(k.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,R.copy(i.vertexNormalsWorld[0]),Da=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ea=-(R.x*a.n21+R.y*a.n22+R.z*a.n23)*0.5+0.5,R.copy(i.vertexNormalsWorld[1]),Fa=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ga=-(R.x*a.n21+R.y*a.n22+
-R.z*a.n23)*0.5+0.5,R.copy(i.vertexNormalsWorld[2]),Ha=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ia=-(R.x*a.n21+R.y*a.n22+R.z*a.n23)*0.5+0.5,Ca(I,D,J,M,F,K,Da,Ea,Fa,Ga,Ha,Ia,k.envMap)}else k.wireframe?fa(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(k.color);else if(k instanceof THREE.MeshLambertMaterial)k.map&&!k.wireframe&&(k.map.mapping instanceof THREE.UVMapping&&(aa=i.uvs[0],Ca(I,D,J,M,F,K,aa[f].u,aa[f].v,aa[h].u,aa[h].v,aa[j].u,aa[j].v,k.map)),c(THREE.SubtractiveBlending)),
-za?!k.wireframe&&k.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3?(u.r=A.r=H.r=Y.r,u.g=A.g=H.g=Y.g,u.b=A.b=H.b=Y.b,m(n,i.v1.positionWorld,i.vertexNormalsWorld[0],u),m(n,i.v2.positionWorld,i.vertexNormalsWorld[1],A),m(n,i.v3.positionWorld,i.vertexNormalsWorld[2],H),S.r=(A.r+H.r)*0.5,S.g=(A.g+H.g)*0.5,S.b=(A.b+H.b)*0.5,W=wa(u,A,H,S),ma(I,D,J,M,F,K,0,0,1,0,0,1,W)):(ba.r=Y.r,ba.g=Y.g,ba.b=Y.b,m(n,i.centroidWorld,i.normalWorld,ba),C.r=Math.max(0,Math.min(k.color.r*ba.r,1)),C.g=Math.max(0,
-Math.min(k.color.g*ba.g,1)),C.b=Math.max(0,Math.min(k.color.b*ba.b,1)),k.wireframe?fa(C,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(C)):k.wireframe?fa(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(k.color);else if(k instanceof THREE.MeshDepthMaterial)V=l.near,ca=l.far,u.r=u.g=u.b=1-ka(a.positionScreen.z,V,ca),A.r=A.g=A.b=1-ka(d.positionScreen.z,V,ca),H.r=H.g=H.b=1-ka(e.positionScreen.z,V,ca),S.r=(A.r+H.r)*0.5,S.g=(A.g+H.g)*0.5,S.b=(A.b+H.b)*0.5,W=wa(u,
-A,H,S),ma(I,D,J,M,F,K,0,0,1,0,0,1,W);else if(k instanceof THREE.MeshNormalMaterial)C.r=na(i.normalWorld.x),C.g=na(i.normalWorld.y),C.b=na(i.normalWorld.z),k.wireframe?fa(C,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(C)}function v(a,d,e,f,h,k,i,j,n){g.data.vertices+=4;g.data.faces++;b(j.opacity);c(j.blending);if(j.map||j.envMap)s(a,d,f,0,1,3,i,j,n),s(h,e,k,1,2,3,i,j,n);else if(I=a.positionScreen.x,D=a.positionScreen.y,J=d.positionScreen.x,M=d.positionScreen.y,F=e.positionScreen.x,
-K=e.positionScreen.y,G=f.positionScreen.x,Q=f.positionScreen.y,w=h.positionScreen.x,N=h.positionScreen.y,L=k.positionScreen.x,pa=k.positionScreen.y,j instanceof THREE.MeshBasicMaterial)P(I,D,J,M,F,K,G,Q),j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshLambertMaterial)za?!j.wireframe&&j.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==4?(u.r=A.r=H.r=S.r=Y.r,u.g=A.g=H.g=S.g=Y.g,u.b=A.b=H.b=S.b=Y.b,m(n,i.v1.positionWorld,
-i.vertexNormalsWorld[0],u),m(n,i.v2.positionWorld,i.vertexNormalsWorld[1],A),m(n,i.v4.positionWorld,i.vertexNormalsWorld[3],H),m(n,i.v3.positionWorld,i.vertexNormalsWorld[2],S),W=wa(u,A,H,S),O(I,D,J,M,G,Q),ma(I,D,J,M,G,Q,0,0,1,0,0,1,W),O(w,N,F,K,L,pa),ma(w,N,F,K,L,pa,1,0,1,1,0,1,W)):(ba.r=Y.r,ba.g=Y.g,ba.b=Y.b,m(n,i.centroidWorld,i.normalWorld,ba),C.r=Math.max(0,Math.min(j.color.r*ba.r,1)),C.g=Math.max(0,Math.min(j.color.g*ba.g,1)),C.b=Math.max(0,Math.min(j.color.b*ba.b,1)),P(I,D,J,M,F,K,G,Q),j.wireframe?
-fa(C,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(C)):(P(I,D,J,M,F,K,G,Q),j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color));else if(j instanceof THREE.MeshNormalMaterial)C.r=na(i.normalWorld.x),C.g=na(i.normalWorld.y),C.b=na(i.normalWorld.z),P(I,D,J,M,F,K,G,Q),j.wireframe?fa(C,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(C);else if(j instanceof THREE.MeshDepthMaterial)V=l.near,ca=l.far,u.r=u.g=u.b=1-ka(a.positionScreen.z,
-V,ca),A.r=A.g=A.b=1-ka(d.positionScreen.z,V,ca),H.r=H.g=H.b=1-ka(f.positionScreen.z,V,ca),S.r=S.g=S.b=1-ka(e.positionScreen.z,V,ca),W=wa(u,A,H,S),O(I,D,J,M,G,Q),ma(I,D,J,M,G,Q,0,0,1,0,0,1,W),O(w,N,F,K,L,pa),ma(w,N,F,K,L,pa,1,0,1,1,0,1,W)}function O(a,b,c,d,e,f){j.beginPath();j.moveTo(a,b);j.lineTo(c,d);j.lineTo(e,f);j.lineTo(a,b);j.closePath()}function P(a,b,c,d,e,f,g,h){j.beginPath();j.moveTo(a,b);j.lineTo(c,d);j.lineTo(e,f);j.lineTo(g,h);j.lineTo(a,b);j.closePath()}function fa(a,b,c,e){if(y!=b)j.lineWidth=
-y=b;if(B!=c)j.lineCap=B=c;if(o!=e)j.lineJoin=o=e;d(a.getContextStyle());j.stroke();U.inflate(b*2)}function ga(a){f(a.getContextStyle());j.fill()}function Ca(a,b,c,d,e,g,h,k,i,l,m,n,o){if(o.image.width!=0){if(o.needsUpdate==!0||la[o.id]==void 0){var p=o.wrapS==THREE.RepeatWrapping,q=o.wrapT==THREE.RepeatWrapping;la[o.id]=j.createPattern(o.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");o.needsUpdate=!1}f(la[o.id]);p=(o.image.width-1)*o.repeat.x;o=(o.image.height-1)*o.repeat.y;h*=
-p;k*=o;i*=p;l*=o;m*=p;n*=o;c-=a;d-=b;e-=a;g-=b;i-=h;l-=k;m-=h;n-=k;p=1/(i*n-m*l);o=(n*c-l*e)*p;l=(n*d-l*g)*p;c=(i*e-m*c)*p;d=(i*g-m*d)*p;a=a-o*h-c*k;b=b-l*h-d*k;j.save();j.transform(o,l,c,d,a,b);j.fill();j.restore()}}function ma(a,b,c,d,e,f,g,h,k,i,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;k*=o;i*=p;l*=o;m*=p;c-=a;d-=b;e-=a;f-=b;k-=g;i-=h;l-=g;m-=h;p=1/(k*m-l*i);o=(m*c-i*e)*p;i=(m*d-i*f)*p;c=(k*e-l*c)*p;d=(k*f-l*d)*p;a=a-o*g-c*h;b=b-i*g-d*h;j.save();j.transform(o,i,c,d,a,b);j.clip();j.drawImage(n,
-0,0);j.restore()}function wa(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);da[0]=e<0?0:e>255?255:e;da[1]=f<0?0:f>255?255:f;da[2]=a<0?0:a>255?255:a;da[4]=g<0?0:g>255?255:g;da[5]=h<0?0:h>255?255:h;da[6]=b<0?0:b>255?255:b;da[8]=i<0?0:i>255?255:i;da[9]=j<0?0:j>255?255:j;da[10]=c<0?0:c>255?255:c;da[12]=k<0?0:k>255?255:k;da[13]=l<0?0:l>255?255:l;da[14]=d<0?0:d>255?255:d;
-ra.putImageData(Aa,0,0);va.drawImage(qa,0,0);return sa}function ka(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function na(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ha(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var xa,Ja,z,ea,ia,oa,ya,T;this.autoClear?this.clear():j.setTransform(1,0,0,-1,i,n);g.data.vertices=0;g.data.faces=0;e=h.projectScene(a,l,this.sortElements);(za=a.lights.length>0)&&k(a);xa=0;for(Ja=e.length;xa<Ja;xa++){z=e[xa];U.empty();
-if(z instanceof THREE.RenderableParticle){t=z;t.x*=i;t.y*=n;ea=0;for(ia=z.materials.length;ea<ia;)T=z.materials[ea++],T.opacity!=0&&p(t,z,T,a)}else if(z instanceof THREE.RenderableLine){if(t=z.v1,r=z.v2,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,U.addPoint(t.positionScreen.x,t.positionScreen.y),U.addPoint(r.positionScreen.x,r.positionScreen.y),ja.instersects(U)){ea=0;for(ia=z.materials.length;ea<ia;)T=z.materials[ea++],T.opacity!=0&&q(t,r,z,T,a)}}else if(z instanceof
-THREE.RenderableFace3){if(t=z.v1,r=z.v2,x=z.v3,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,x.positionScreen.x*=i,x.positionScreen.y*=n,z.overdraw&&(ha(t.positionScreen,r.positionScreen),ha(r.positionScreen,x.positionScreen),ha(x.positionScreen,t.positionScreen)),U.add3Points(t.positionScreen.x,t.positionScreen.y,r.positionScreen.x,r.positionScreen.y,x.positionScreen.x,x.positionScreen.y),ja.instersects(U)){ea=0;for(ia=z.meshMaterials.length;ea<ia;)if(T=
-z.meshMaterials[ea++],T instanceof THREE.MeshFaceMaterial){oa=0;for(ya=z.faceMaterials.length;oa<ya;)(T=z.faceMaterials[oa++])&&T.opacity!=0&&s(t,r,x,0,1,2,z,T,a)}else T.opacity!=0&&s(t,r,x,0,1,2,z,T,a)}}else if(z instanceof THREE.RenderableFace4&&(t=z.v1,r=z.v2,x=z.v3,E=z.v4,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,x.positionScreen.x*=i,x.positionScreen.y*=n,E.positionScreen.x*=i,E.positionScreen.y*=n,Z.positionScreen.copy(r.positionScreen),$.positionScreen.copy(E.positionScreen),
-z.overdraw&&(ha(t.positionScreen,r.positionScreen),ha(r.positionScreen,E.positionScreen),ha(E.positionScreen,t.positionScreen),ha(x.positionScreen,Z.positionScreen),ha(x.positionScreen,$.positionScreen)),U.addPoint(t.positionScreen.x,t.positionScreen.y),U.addPoint(r.positionScreen.x,r.positionScreen.y),U.addPoint(x.positionScreen.x,x.positionScreen.y),U.addPoint(E.positionScreen.x,E.positionScreen.y),ja.instersects(U))){ea=0;for(ia=z.meshMaterials.length;ea<ia;)if(T=z.meshMaterials[ea++],T instanceof
-THREE.MeshFaceMaterial){oa=0;for(ya=z.faceMaterials.length;oa<ya;)(T=z.faceMaterials[oa++])&&T.opacity!=0&&v(t,r,x,E,Z,$,z,T,a)}else T.opacity!=0&&v(t,r,x,E,Z,$,z,T,a)}X.addRectangle(U)}j.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
+Aa,da,sa,va,a=16;qa=document.createElement("canvas");qa.width=qa.height=2;ra=qa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0,0,2,2);Aa=ra.getImageData(0,0,2,2);da=Aa.data;sa=document.createElement("canvas");sa.width=sa.height=a;va=sa.getContext("2d");va.translate(-a/2,-a/2);va.scale(a,a);a--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(a,b){l=a;m=b;i=Math.floor(l/2);n=Math.floor(m/2);k.width=l;k.height=m;
+ja.set(-i,-n,i,n);X.set(-i,-n,i,n);v=1;s=0;o=B=y=P=O=null};this.setClearColor=function(a,b){p.copy(a);q=b;X.set(-i,-n,i,n)};this.setClearColorHex=function(a,b){p.setHex(a);q=b;X.set(-i,-n,i,n)};this.clear=function(){j.setTransform(1,0,0,-1,i,n);X.isEmpty()||(X.inflate(2),X.minSelf(ja),q<1&&j.clearRect(Math.floor(X.getX()),Math.floor(X.getY()),Math.floor(X.getWidth()),Math.floor(X.getHeight())),q>0&&(c(THREE.NormalBlending),b(1),f("rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*
+255)+","+q+")"),j.fillRect(Math.floor(X.getX()),Math.floor(X.getY()),Math.floor(X.getWidth()),Math.floor(X.getHeight()))),X.empty())};this.render=function(a,l){function k(a){var b,c,d,f=a.lights;Y.setRGB(0,0,0);ta.setRGB(0,0,0);ua.setRGB(0,0,0);a=0;for(b=f.length;a<b;a++)c=f[a],d=c.color,c instanceof THREE.AmbientLight?(Y.r+=d.r,Y.g+=d.g,Y.b+=d.b):c instanceof THREE.DirectionalLight?(ta.r+=d.r,ta.g+=d.g,ta.b+=d.b):c instanceof THREE.PointLight&&(ua.r+=d.r,ua.g+=d.g,ua.b+=d.b)}function m(a,b,c,d){var f,
+e,g,h,l=a.lights,a=0;for(f=l.length;a<f;a++)e=l[a],g=e.color,e instanceof THREE.DirectionalLight?(h=c.dot(e.position),h<=0||(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)):e instanceof THREE.PointLight&&(h=c.dot(R.sub(e.position,b).normalize()),h<=0||(h*=e.distance==0?1:1-Math.min(b.distanceTo(e.position)/e.distance,1),h!=0&&(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)))}function p(a,e,g){b(g.opacity);c(g.blending);var h,l,m,k,Ba,o;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)k=g.map.image,
+Ba=k.width>>1,o=k.height>>1,g=e.scale.x*i,m=e.scale.y*n,h=g*Ba,l=m*o,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(U)&&(j.save(),j.translate(a.x,a.y),j.rotate(-e.rotation),j.scale(g,-m),j.translate(-Ba,-o),j.drawImage(k,0,0),j.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*i,l=e.scale.y*n,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(U)&&(d(g.color.getContextStyle()),f(g.color.getContextStyle()),j.save(),j.translate(a.x,a.y),j.rotate(-e.rotation),j.scale(h,l),g.program(j),
+j.restore()))}function q(a,e,f,g){b(g.opacity);c(g.blending);j.beginPath();j.moveTo(a.positionScreen.x,a.positionScreen.y);j.lineTo(e.positionScreen.x,e.positionScreen.y);j.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)j.lineWidth=y=a;a=g.linecap;if(B!=a)j.lineCap=B=a;a=g.linejoin;if(o!=a)j.lineJoin=o=a;d(g.color.getContextStyle());j.stroke();U.inflate(g.linewidth*2)}}function s(a,d,e,f,h,j,i,k,n){g.data.vertices+=3;g.data.faces++;b(k.opacity);c(k.blending);I=a.positionScreen.x;
+D=a.positionScreen.y;J=d.positionScreen.x;M=d.positionScreen.y;F=e.positionScreen.x;K=e.positionScreen.y;O(I,D,J,M,F,K);if(k instanceof THREE.MeshBasicMaterial)if(k.map)k.map.mapping instanceof THREE.UVMapping&&(aa=i.uvs[0],Ca(I,D,J,M,F,K,aa[f].u,aa[f].v,aa[h].u,aa[h].v,aa[j].u,aa[j].v,k.map));else if(k.envMap){if(k.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,R.copy(i.vertexNormalsWorld[0]),Da=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ea=-(R.x*a.n21+R.y*a.n22+R.z*
+a.n23)*0.5+0.5,R.copy(i.vertexNormalsWorld[1]),Fa=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ga=-(R.x*a.n21+R.y*a.n22+R.z*a.n23)*0.5+0.5,R.copy(i.vertexNormalsWorld[2]),Ha=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ia=-(R.x*a.n21+R.y*a.n22+R.z*a.n23)*0.5+0.5,Ca(I,D,J,M,F,K,Da,Ea,Fa,Ga,Ha,Ia,k.envMap)}else k.wireframe?fa(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(k.color);else if(k instanceof THREE.MeshLambertMaterial)k.map&&!k.wireframe&&(k.map.mapping instanceof THREE.UVMapping&&
+(aa=i.uvs[0],Ca(I,D,J,M,F,K,aa[f].u,aa[f].v,aa[h].u,aa[h].v,aa[j].u,aa[j].v,k.map)),c(THREE.SubtractiveBlending)),za?!k.wireframe&&k.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3?(u.r=A.r=H.r=Y.r,u.g=A.g=H.g=Y.g,u.b=A.b=H.b=Y.b,m(n,i.v1.positionWorld,i.vertexNormalsWorld[0],u),m(n,i.v2.positionWorld,i.vertexNormalsWorld[1],A),m(n,i.v3.positionWorld,i.vertexNormalsWorld[2],H),S.r=(A.r+H.r)*0.5,S.g=(A.g+H.g)*0.5,S.b=(A.b+H.b)*0.5,W=wa(u,A,H,S),ma(I,D,J,M,F,K,0,0,1,0,0,1,W)):(ba.r=Y.r,
+ba.g=Y.g,ba.b=Y.b,m(n,i.centroidWorld,i.normalWorld,ba),C.r=Math.max(0,Math.min(k.color.r*ba.r,1)),C.g=Math.max(0,Math.min(k.color.g*ba.g,1)),C.b=Math.max(0,Math.min(k.color.b*ba.b,1)),k.wireframe?fa(C,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(C)):k.wireframe?fa(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(k.color);else if(k instanceof THREE.MeshDepthMaterial)V=l.near,ca=l.far,u.r=u.g=u.b=1-ka(a.positionScreen.z,V,ca),A.r=A.g=A.b=1-ka(d.positionScreen.z,
+V,ca),H.r=H.g=H.b=1-ka(e.positionScreen.z,V,ca),S.r=(A.r+H.r)*0.5,S.g=(A.g+H.g)*0.5,S.b=(A.b+H.b)*0.5,W=wa(u,A,H,S),ma(I,D,J,M,F,K,0,0,1,0,0,1,W);else if(k instanceof THREE.MeshNormalMaterial)C.r=na(i.normalWorld.x),C.g=na(i.normalWorld.y),C.b=na(i.normalWorld.z),k.wireframe?fa(C,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(C)}function v(a,d,e,f,h,k,i,j,n){g.data.vertices+=4;g.data.faces++;b(j.opacity);c(j.blending);if(j.map||j.envMap)s(a,d,f,0,1,3,i,j,n),s(h,e,k,1,2,3,i,j,n);else if(I=
+a.positionScreen.x,D=a.positionScreen.y,J=d.positionScreen.x,M=d.positionScreen.y,F=e.positionScreen.x,K=e.positionScreen.y,G=f.positionScreen.x,Q=f.positionScreen.y,w=h.positionScreen.x,N=h.positionScreen.y,L=k.positionScreen.x,pa=k.positionScreen.y,j instanceof THREE.MeshBasicMaterial)P(I,D,J,M,F,K,G,Q),j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshLambertMaterial)za?!j.wireframe&&j.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==
+4?(u.r=A.r=H.r=S.r=Y.r,u.g=A.g=H.g=S.g=Y.g,u.b=A.b=H.b=S.b=Y.b,m(n,i.v1.positionWorld,i.vertexNormalsWorld[0],u),m(n,i.v2.positionWorld,i.vertexNormalsWorld[1],A),m(n,i.v4.positionWorld,i.vertexNormalsWorld[3],H),m(n,i.v3.positionWorld,i.vertexNormalsWorld[2],S),W=wa(u,A,H,S),O(I,D,J,M,G,Q),ma(I,D,J,M,G,Q,0,0,1,0,0,1,W),O(w,N,F,K,L,pa),ma(w,N,F,K,L,pa,1,0,1,1,0,1,W)):(ba.r=Y.r,ba.g=Y.g,ba.b=Y.b,m(n,i.centroidWorld,i.normalWorld,ba),C.r=Math.max(0,Math.min(j.color.r*ba.r,1)),C.g=Math.max(0,Math.min(j.color.g*
+ba.g,1)),C.b=Math.max(0,Math.min(j.color.b*ba.b,1)),P(I,D,J,M,F,K,G,Q),j.wireframe?fa(C,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(C)):(P(I,D,J,M,F,K,G,Q),j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color));else if(j instanceof THREE.MeshNormalMaterial)C.r=na(i.normalWorld.x),C.g=na(i.normalWorld.y),C.b=na(i.normalWorld.z),P(I,D,J,M,F,K,G,Q),j.wireframe?fa(C,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(C);else if(j instanceof
+THREE.MeshDepthMaterial)V=l.near,ca=l.far,u.r=u.g=u.b=1-ka(a.positionScreen.z,V,ca),A.r=A.g=A.b=1-ka(d.positionScreen.z,V,ca),H.r=H.g=H.b=1-ka(f.positionScreen.z,V,ca),S.r=S.g=S.b=1-ka(e.positionScreen.z,V,ca),W=wa(u,A,H,S),O(I,D,J,M,G,Q),ma(I,D,J,M,G,Q,0,0,1,0,0,1,W),O(w,N,F,K,L,pa),ma(w,N,F,K,L,pa,1,0,1,1,0,1,W)}function O(a,b,c,d,e,f){j.beginPath();j.moveTo(a,b);j.lineTo(c,d);j.lineTo(e,f);j.lineTo(a,b);j.closePath()}function P(a,b,c,d,e,f,g,h){j.beginPath();j.moveTo(a,b);j.lineTo(c,d);j.lineTo(e,
+f);j.lineTo(g,h);j.lineTo(a,b);j.closePath()}function fa(a,b,c,e){if(y!=b)j.lineWidth=y=b;if(B!=c)j.lineCap=B=c;if(o!=e)j.lineJoin=o=e;d(a.getContextStyle());j.stroke();U.inflate(b*2)}function ga(a){f(a.getContextStyle());j.fill()}function Ca(a,b,c,d,e,g,h,k,i,l,m,n,o){if(o.image.width!=0){if(o.needsUpdate==!0||la[o.id]==void 0){var p=o.wrapS==THREE.RepeatWrapping,q=o.wrapT==THREE.RepeatWrapping;la[o.id]=j.createPattern(o.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");o.needsUpdate=
+!1}f(la[o.id]);p=(o.image.width-1)*o.repeat.x;o=(o.image.height-1)*o.repeat.y;h*=p;k*=o;i*=p;l*=o;m*=p;n*=o;c-=a;d-=b;e-=a;g-=b;i-=h;l-=k;m-=h;n-=k;p=1/(i*n-m*l);o=(n*c-l*e)*p;l=(n*d-l*g)*p;c=(i*e-m*c)*p;d=(i*g-m*d)*p;a=a-o*h-c*k;b=b-l*h-d*k;j.save();j.transform(o,l,c,d,a,b);j.fill();j.restore()}}function ma(a,b,c,d,e,f,g,h,k,i,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;k*=o;i*=p;l*=o;m*=p;c-=a;d-=b;e-=a;f-=b;k-=g;i-=h;l-=g;m-=h;p=1/(k*m-l*i);o=(m*c-i*e)*p;i=(m*d-i*f)*p;c=(k*e-l*c)*p;d=(k*
+f-l*d)*p;a=a-o*g-c*h;b=b-i*g-d*h;j.save();j.transform(o,i,c,d,a,b);j.clip();j.drawImage(n,0,0);j.restore()}function wa(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);da[0]=e<0?0:e>255?255:e;da[1]=f<0?0:f>255?255:f;da[2]=a<0?0:a>255?255:a;da[4]=g<0?0:g>255?255:g;da[5]=h<0?0:h>255?255:h;da[6]=b<0?0:b>255?255:b;da[8]=i<0?0:i>255?255:i;da[9]=j<0?0:j>255?255:j;da[10]=c<
+0?0:c>255?255:c;da[12]=k<0?0:k>255?255:k;da[13]=l<0?0:l>255?255:l;da[14]=d<0?0:d>255?255:d;ra.putImageData(Aa,0,0);va.drawImage(qa,0,0);return sa}function ka(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function na(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ha(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var xa,Ja,z,ea,ia,oa,ya,T;this.autoClear?this.clear():j.setTransform(1,0,0,-1,i,n);g.data.vertices=0;g.data.faces=0;e=h.projectScene(a,l,this.sortElements);
+(za=a.lights.length>0)&&k(a);xa=0;for(Ja=e.length;xa<Ja;xa++){z=e[xa];U.empty();if(z instanceof THREE.RenderableParticle){t=z;t.x*=i;t.y*=n;ea=0;for(ia=z.materials.length;ea<ia;)T=z.materials[ea++],T.opacity!=0&&p(t,z,T,a)}else if(z instanceof THREE.RenderableLine){if(t=z.v1,r=z.v2,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,U.addPoint(t.positionScreen.x,t.positionScreen.y),U.addPoint(r.positionScreen.x,r.positionScreen.y),ja.instersects(U)){ea=0;for(ia=
+z.materials.length;ea<ia;)T=z.materials[ea++],T.opacity!=0&&q(t,r,z,T,a)}}else if(z instanceof THREE.RenderableFace3){if(t=z.v1,r=z.v2,x=z.v3,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,x.positionScreen.x*=i,x.positionScreen.y*=n,z.overdraw&&(ha(t.positionScreen,r.positionScreen),ha(r.positionScreen,x.positionScreen),ha(x.positionScreen,t.positionScreen)),U.add3Points(t.positionScreen.x,t.positionScreen.y,r.positionScreen.x,r.positionScreen.y,x.positionScreen.x,
+x.positionScreen.y),ja.instersects(U)){ea=0;for(ia=z.meshMaterials.length;ea<ia;)if(T=z.meshMaterials[ea++],T instanceof THREE.MeshFaceMaterial){oa=0;for(ya=z.faceMaterials.length;oa<ya;)(T=z.faceMaterials[oa++])&&T.opacity!=0&&s(t,r,x,0,1,2,z,T,a)}else T.opacity!=0&&s(t,r,x,0,1,2,z,T,a)}}else if(z instanceof THREE.RenderableFace4&&(t=z.v1,r=z.v2,x=z.v3,E=z.v4,t.positionScreen.x*=i,t.positionScreen.y*=n,r.positionScreen.x*=i,r.positionScreen.y*=n,x.positionScreen.x*=i,x.positionScreen.y*=n,E.positionScreen.x*=
+i,E.positionScreen.y*=n,Z.positionScreen.copy(r.positionScreen),$.positionScreen.copy(E.positionScreen),z.overdraw&&(ha(t.positionScreen,r.positionScreen),ha(r.positionScreen,E.positionScreen),ha(E.positionScreen,t.positionScreen),ha(x.positionScreen,Z.positionScreen),ha(x.positionScreen,$.positionScreen)),U.addPoint(t.positionScreen.x,t.positionScreen.y),U.addPoint(r.positionScreen.x,r.positionScreen.y),U.addPoint(x.positionScreen.x,x.positionScreen.y),U.addPoint(E.positionScreen.x,E.positionScreen.y),
+ja.instersects(U))){ea=0;for(ia=z.meshMaterials.length;ea<ia;)if(T=z.meshMaterials[ea++],T instanceof THREE.MeshFaceMaterial){oa=0;for(ya=z.faceMaterials.length;oa<ya;)(T=z.faceMaterials[oa++])&&T.opacity!=0&&v(t,r,x,E,Z,$,z,T,a)}else T.opacity!=0&&v(t,r,x,E,Z,$,z,T,a)}X.addRectangle(U)}j.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};
+THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};

+ 1 - 1
build/custom/ThreeDOM.js

@@ -54,7 +54,7 @@ THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){t
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=
 a,this.w*=a);return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,
 j=this.w,i=j*c+f*e-h*d,k=j*d+h*c-g*e,l=j*e+g*d-f*c,c=-g*c-f*d-h*e;b.x=i*j+c*-g+k*-h-l*-f;b.y=k*j+c*-f+l*-g-i*-h;b.z=l*j+c*-h+i*-f-k*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;

+ 4 - 4
build/custom/ThreeExtras.js

@@ -38,7 +38,7 @@ this.getPrevKeyWith("pos",t,g.index-1).pos,this.points[1]=f,this.points[2]=h,thi
 THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],e=[],f,h,g,j,k,l;f=(a.length-1)*b;h=Math.floor(f);f-=h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>a.length-2?h:h+1;c[3]=h>a.length-3?h:h+2;h=a[c[0]];j=a[c[1]];k=a[c[2]];l=a[c[3]];c=f*f;g=f*c;e[0]=this.interpolate(h[0],j[0],k[0],l[0],f,c,g);e[1]=this.interpolate(h[1],j[1],k[1],l[1],f,c,g);e[2]=this.interpolate(h[2],j[2],k[2],l[2],f,c,g);return e};
 THREE.Animation.prototype.interpolate=function(a,b,c,e,f,h,g){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*g+(-3*(b-c)-2*a-e)*h+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c<e.length-1?c:e.length-1:c%=e.length;c<e.length;c++)if(e[c][a]!==void 0)return e[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var e=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==void 0)return e[c];return this.data.hierarchy[b].keys[e.length-1]};
-THREE.FirstPersonCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=
+THREE.FirstPersonCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=
 a.movementSpeed;if(a.lookSpeed!==void 0)this.lookSpeed=a.lookSpeed;if(a.noFly!==void 0)this.noFly=a.noFly;if(a.lookVertical!==void 0)this.lookVertical=a.lookVertical;if(a.autoForward!==void 0)this.autoForward=a.autoForward;if(a.activeLook!==void 0)this.activeLook=a.activeLook;if(a.heightSpeed!==void 0)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==void 0)this.heightCoef=a.heightCoef;if(a.heightMin!==void 0)this.heightMin=a.heightMin;if(a.heightMax!==void 0)this.heightMax=a.heightMax;if(a.constrainVertical!==
 void 0)this.constrainVertical=a.constrainVertical;if(a.verticalMin!==void 0)this.verticalMin=a.verticalMin;if(a.verticalMax!==void 0)this.verticalMax=a.verticalMax;if(a.domElement!==void 0)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(a){a.preventDefault();
 a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.mouseX=a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.onKeyDown=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=
@@ -50,7 +50,7 @@ Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListen
 THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);if(this.noFly)b.y=0;this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};
 THREE.PathCamera=function(a){function b(a,c,b,e){var g={name:b,fps:0.6,length:e,hierarchy:[]},h,f=c.getControlPointsArray(),j=c.getLength(),k=f.length,x=0;h=k-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[h]={time:e,pos:f[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<k-1;h++)x=e*j.chunks[h]/j.total,c.keys[h]={time:x,pos:f[h]};g.hierarchy[0]=c;THREE.AnimationHandler.add(g);return new THREE.Animation(a,b,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(a,c){var b,
 e,g=new THREE.Geometry;for(b=0;b<a.points.length*c;b++)e=b/(a.points.length*c),e=a.getPoint(e),g.vertices[b]=new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z));return g}function e(a,b){var e=c(b,10),g=c(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(e,h);particleObj=new THREE.ParticleSystem(g,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.addChild(lineObj);particleObj.scale.set(1,1,1);a.addChild(particleObj);g=new THREE.SphereGeometry(1,
-16,8);h=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<b.points.length;i++)e=new THREE.Mesh(g,h),e.position.copy(b.points[i]),e.updateMatrix(),a.addChild(e)}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=
+16,8);h=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<b.points.length;i++)e=new THREE.Mesh(g,h),e.position.copy(b.points[i]),e.updateMatrix(),a.addChild(e)}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookHorizontal=
 this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==void 0)this.duration=a.duration*1E3;if(a.waypoints!==void 0)this.waypoints=a.waypoints;if(a.useConstantSpeed!==void 0)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==void 0)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==void 0)this.createDebugPath=a.createDebugPath;if(a.createDebugDummy!==
 void 0)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==void 0)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==void 0)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==void 0)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==void 0)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==void 0)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==void 0)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=
 window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,h=Math.PI/180;this.update=function(a,c,b){var e,g;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;e=this.phi%f;this.phi=e>=0?e:e+f;e=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var j=g[1]-g[0];this.phi=
@@ -58,7 +58,7 @@ TWEEN.Easing.Quadratic.EaseInOut(((this.phi-e[0])*(g[1]-g[0])/(e[1]-e[0])+g[0]-g
 a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),g=new THREE.MeshLambertMaterial({color:65280}),j=new THREE.CubeGeometry(10,10,20),k=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,g);a.position.set(0,10,0);this.animation=
 b(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=b(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(a,c){return function(){c.apply(a,arguments)}}(this,this.onMouseMove),
 !1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
-THREE.FlyCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==void 0)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==void 0)this.dragToLook=a.dragToLook;if(a.autoForward!==void 0)this.autoForward=
+THREE.FlyCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.domElement=document;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==void 0)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==void 0)this.dragToLook=a.dragToLook;if(a.autoForward!==void 0)this.autoForward=
 a.autoForward;if(a.domElement!==void 0)this.domElement=a.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=
 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};
 this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;
@@ -148,7 +148,7 @@ THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THRE
 THREE.IcosahedronGeometry=function(a){function b(a,b,c){var e=Math.sqrt(a*a+b*b+c*c);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(a/e,b/e,c/e)))-1}function c(a,b,c,e){e.faces.push(new THREE.Face3(a,b,c))}function e(a,c){var e=f.vertices[a].position,g=f.vertices[c].position;return b((e.x+g.x)/2,(e.y+g.y)/2,(e.z+g.z)/2)}var f=this,h=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,
 -a);b(0,1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,h);c(0,5,1,h);c(0,1,7,h);c(0,7,10,h);c(0,10,11,h);c(1,5,9,h);c(5,11,4,h);c(11,10,2,h);c(10,7,6,h);c(7,1,8,h);c(3,9,4,h);c(3,4,2,h);c(3,2,6,h);c(3,6,8,h);c(3,8,9,h);c(4,9,5,h);c(2,4,11,h);c(6,2,10,h);c(8,6,7,h);c(9,8,1,h);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var j in h.faces){var k=e(h.faces[j].a,h.faces[j].b),l=e(h.faces[j].b,h.faces[j].c),m=e(h.faces[j].c,h.faces[j].a);c(h.faces[j].a,k,m,g);c(h.faces[j].b,l,k,g);
 c(h.faces[j].c,m,l,g);c(k,l,m,g)}h.faces=g.faces}f.faces=h.faces;delete h;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
-THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],e=[],f=[],h=[],g=(new THREE.Matrix4).setRotationZ(b),j=0;j<a.length;j++)this.vertices.push(new THREE.Vertex(a[j])),c[j]=a[j].clone(),e[j]=this.vertices.length-1;for(var k=0;k<=this.angle+0.0010;k+=b){for(j=0;j<c.length;j++)k<this.angle?(c[j]=g.multiplyVector3(c[j].clone()),this.vertices.push(new THREE.Vertex(c[j])),f[j]=this.vertices.length-1):f=h;k==0&&(h=e);
+THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],e=[],f=[],h=[],g=(new THREE.Matrix4).setRotationZ(b),j=0;j<a.length;j++)this.vertices.push(new THREE.Vertex(a[j])),c[j]=a[j].clone(),e[j]=this.vertices.length-1;for(var k=0;k<=this.angle+0.001;k+=b){for(j=0;j<c.length;j++)k<this.angle?(c[j]=g.multiplyVector3(c[j].clone()),this.vertices.push(new THREE.Vertex(c[j])),f[j]=this.vertices.length-1):f=h;k==0&&(h=e);
 for(j=0;j<e.length-1;j++)this.faces.push(new THREE.Face4(f[j],f[j+1],e[j+1],e[j])),this.faceVertexUvs[0].push([new THREE.UV(1-k/this.angle,j/a.length),new THREE.UV(1-k/this.angle,(j+1)/a.length),new THREE.UV(1-(k-b)/this.angle,(j+1)/a.length),new THREE.UV(1-(k-b)/this.angle,j/a.length)]);e=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
 THREE.PlaneGeometry=function(a,b,c,e){THREE.Geometry.call(this);var f,h=a/2,g=b/2,c=c||1,e=e||1,j=c+1,k=e+1;a/=c;var l=b/e;for(f=0;f<k;f++)for(b=0;b<j;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-h,-(f*l-g),0)));for(f=0;f<e;f++)for(b=0;b<c;b++)this.faces.push(new THREE.Face4(b+j*f,b+j*(f+1),b+1+j*(f+1),b+1+j*f)),this.faceVertexUvs[0].push([new THREE.UV(b/c,f/e),new THREE.UV(b/c,(f+1)/e),new THREE.UV((b+1)/c,(f+1)/e),new THREE.UV((b+1)/c,f/e)]);this.computeCentroids();this.computeFaceNormals()};
 THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;

+ 1 - 1
build/custom/ThreeSVG.js

@@ -54,7 +54,7 @@ THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){t
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=
 a,this.w*=a);return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,e=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-d*e;this.y=c*a+f*e+d*g-b*h;this.z=d*a+f*h+b*e-c*g;this.w=f*a-b*g-c*e-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,e=this.y,h=this.z,
 l=this.w,i=l*c+e*f-h*d,k=l*d+h*c-g*f,j=l*f+g*d-e*c,c=-g*c-e*d-h*f;b.x=i*l+c*-g+k*-h-j*-e;b.y=k*l+c*-e+j*-g-i*-h;b.z=j*l+c*-h+i*-e-k*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,f,g,e){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=e instanceof Array?e:[e];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};

+ 59 - 59
build/custom/ThreeWebGL.js

@@ -54,7 +54,7 @@ THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,d,e,f){t
 this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=
 b,this.w*=b);return this},multiplySelf:function(b){var d=this.x,e=this.y,f=this.z,h=this.w,i=b.x,g=b.y,j=b.z,b=b.w;this.x=d*b+h*i+e*j-f*g;this.y=e*b+h*g+f*i-d*j;this.z=f*b+h*j+d*g-e*i;this.w=h*b-d*i-e*g-f*j;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var e=b.x,f=b.y,h=b.z,i=this.x,g=this.y,j=this.z,
 k=this.w,q=k*e+g*h-j*f,n=k*f+j*e-i*h,r=k*h+i*f-g*e,e=-i*e-g*f-j*h;d.x=q*k+e*-i+n*-j-r*-g;d.y=n*k+e*-g+r*-i-q*-j;d.z=r*k+e*-j+q*-g-n*-i;return d}};
-THREE.Quaternion.slerp=function(b,d,e,f){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(h),g=Math.sqrt(1-h*h);if(Math.abs(g)<0.0010)return e.w=0.5*(b.w+d.w),e.x=0.5*(b.x+d.x),e.y=0.5*(b.y+d.y),e.z=0.5*(b.z+d.z),e;h=Math.sin((1-f)*i)/g;f=Math.sin(f*i)/g;e.w=b.w*h+d.w*f;e.x=b.x*h+d.x*f;e.y=b.y*h+d.y*f;e.z=b.z*h+d.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Quaternion.slerp=function(b,d,e,f){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var i=Math.acos(h),g=Math.sqrt(1-h*h);if(Math.abs(g)<0.001)return e.w=0.5*(b.w+d.w),e.x=0.5*(b.x+d.x),e.y=0.5*(b.y+d.y),e.z=0.5*(b.z+d.z),e;h=Math.sin((1-f)*i)/g;f=Math.sin(f*i)/g;e.w=b.w*h+d.w*f;e.x=b.x*h+d.x*f;e.y=b.y*h+d.y*f;e.z=b.z*h+d.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
 THREE.Face3=function(b,d,e,f,h,i){this.a=b;this.b=d;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=i instanceof Array?i:[i];this.centroid=new THREE.Vector3};
 THREE.Face4=function(b,d,e,f,h,i,g){this.a=b;this.b=d;this.c=e;this.d=f;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=i instanceof THREE.Color?i:new THREE.Color;this.vertexColors=i instanceof Array?i:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
 THREE.UV.prototype={constructor:THREE.UV,set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -227,64 +227,64 @@ g.uvScale.x,g.uvScale.y),c.uniform2f(h.uvOffset,g.uvOffset.x,g.uvOffset.y),c.uni
 h,i,j,k=new THREE.Vector3,q=qa/la,p=la*0.5,n=qa*0.5,r=16/qa,t=[r*q,r],o=[1,1,0],w=[1,1],v=A.uniforms;d=A.attributes;c.useProgram(A.program);R=A.program;T=da=-1;Ua||(c.enableVertexAttribArray(A.attributes.vertex),c.enableVertexAttribArray(A.attributes.uv),Ua=!0);c.uniform1i(v.occlusionMap,0);c.uniform1i(v.map,1);c.bindBuffer(c.ARRAY_BUFFER,A.vertexBuffer);c.vertexAttribPointer(d.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(d.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.elementBuffer);
 c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,A.occlusionTexture);c.activeTexture(c.TEXTURE1);for(f=0;f<g;f++)if(d=b.__webglLensFlares[f].object,k.set(d.matrixWorld.n14,d.matrixWorld.n24,d.matrixWorld.n34),e.matrixWorldInverse.multiplyVector3(k),e.projectionMatrix.multiplyVector3(k),o[0]=k.x,o[1]=k.y,o[2]=k.z,w[0]=o[0]*p+p,w[1]=o[1]*n+n,A.hasVertexTexture||w[0]>0&&w[0]<la&&w[1]>0&&w[1]<qa){c.bindTexture(c.TEXTURE_2D,A.tempTexture);c.copyTexImage2D(c.TEXTURE_2D,
 0,c.RGB,w[0]-8,w[1]-8,16,16,0);c.uniform1i(v.renderType,0);c.uniform2fv(v.scale,t);c.uniform3fv(v.screenPosition,o);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.bindTexture(c.TEXTURE_2D,A.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,w[0]-8,w[1]-8,16,16,0);c.uniform1i(v.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,A.tempTexture);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);d.positionScreen.x=o[0];d.positionScreen.y=
-o[1];d.positionScreen.z=o[2];d.customUpdateCallback?d.customUpdateCallback(d):d.updateLensFlares();c.uniform1i(v.renderType,2);c.enable(c.BLEND);h=0;for(i=d.lensFlares.length;h<i;h++)if(j=d.lensFlares[h],j.opacity>0.0010&&j.scale>0.0010)o[0]=j.x,o[1]=j.y,o[2]=j.z,r=j.size*j.scale/qa,t[0]=r*q,t[1]=r,c.uniform3fv(v.screenPosition,o),c.uniform2fv(v.scale,t),c.uniform1f(v.rotation,j.rotation),c.uniform1f(v.opacity,j.opacity),M(j.blending),ra(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,
-0)}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(L)}function U(b,c,d){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function ta(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)if(e.attributes[c].needsUpdate)return!0;return!1}function fa(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=
-f[b],e.attributes)for(c in e.attributes)e.attributes[c].needsUpdate=!1}function I(b){var e,f,g,h;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups)if(g=f.geometryGroups[e],h=ta(g),f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||h){h=g;var i=b,j=c.DYNAMIC_DRAW;if(h.__inittedArrays){var k=void 0,q=void 0,n=void 0,p=void 0,r=n=void 0,C=void 0,t=void 0,o=void 0,w=void 0,v=void 0,A=void 0,E=void 0,F=void 0,
-x=void 0,y=void 0,u=void 0,G=void 0,s=p=o=p=t=C=void 0,m=void 0,B=m=s=C=void 0,K=void 0,L=B=m=s=n=n=r=o=p=B=m=s=K=B=m=s=K=B=m=s=void 0,I=0,J=0,R=0,S=0,M=0,N=0,V=0,O=0,ea=0,z=0,ga=0,B=s=0,B=void 0,ia=h.__vertexArray,aa=h.__uvArray,ca=h.__uv2Array,Q=h.__normalArray,W=h.__tangentArray,ja=h.__colorArray,X=h.__skinVertexAArray,Y=h.__skinVertexBArray,Z=h.__skinIndexArray,$=h.__skinWeightArray,da=h.__morphTargetsArrays,U=h.__webglCustomAttributes,m=void 0,P=h.__faceArray,T=h.__lineArray,ma=h.__needsSmoothNormals,
-v=h.__vertexColorType,w=h.__uvType,A=h.__normalType,oa=i.geometry,la=oa.__dirtyVertices,na=oa.__dirtyElements,ha=oa.__dirtyUvs,pa=oa.__dirtyNormals,qa=oa.__dirtyTangents,ra=oa.__dirtyColors,sa=oa.__dirtyMorphTargets,ka=oa.vertices,ua=h.faces,va=oa.faces,wa=oa.faceVertexUvs[0],xa=oa.faceVertexUvs[1],Da=oa.skinVerticesA,Ea=oa.skinVerticesB,Fa=oa.skinIndices,za=oa.skinWeights,Aa=i instanceof THREE.ShadowVolume?oa.edgeFaces:void 0,ya=oa.morphTargets;if(U)for(L in U)U[L].offset=0,U[L].offsetSrc=0;k=0;
-for(q=ua.length;k<q;k++)if(n=ua[k],p=va[n],wa&&(E=wa[n]),xa&&(F=xa[n]),n=p.vertexNormals,r=p.normal,C=p.vertexColors,t=p.color,o=p.vertexTangents,p instanceof THREE.Face3){if(la)x=ka[p.a].position,y=ka[p.b].position,u=ka[p.c].position,ia[J]=x.x,ia[J+1]=x.y,ia[J+2]=x.z,ia[J+3]=y.x,ia[J+4]=y.y,ia[J+5]=y.z,ia[J+6]=u.x,ia[J+7]=u.y,ia[J+8]=u.z,J+=9;if(U)for(L in U)if(m=U[L],m.__original.needsUpdate)s=m.offset,B=m.offsetSrc,m.size===1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[s]=m.value[p.a],
-m.array[s+1]=m.value[p.b],m.array[s+2]=m.value[p.c]):m.boundTo==="faces"?(B=m.value[B],m.array[s]=B,m.array[s+1]=B,m.array[s+2]=B,m.offsetSrc++):m.boundTo==="faceVertices"&&(m.array[s]=m.value[B],m.array[s+1]=m.value[B+1],m.array[s+2]=m.value[B+2],m.offsetSrc+=3),m.offset+=3):(m.boundTo===void 0||m.boundTo==="vertices"?(x=m.value[p.a],y=m.value[p.b],u=m.value[p.c]):m.boundTo==="faces"?(u=y=x=B=m.value[B],m.offsetSrc++):m.boundTo==="faceVertices"&&(x=m.value[B],y=m.value[B+1],u=m.value[B+2],m.offsetSrc+=
-3),m.size===2?(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=y.x,m.array[s+3]=y.y,m.array[s+4]=u.x,m.array[s+5]=u.y,m.offset+=6):m.size===3?(m.type==="c"?(m.array[s]=x.r,m.array[s+1]=x.g,m.array[s+2]=x.b,m.array[s+3]=y.r,m.array[s+4]=y.g,m.array[s+5]=y.b,m.array[s+6]=u.r,m.array[s+7]=u.g,m.array[s+8]=u.b):(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=y.x,m.array[s+4]=y.y,m.array[s+5]=y.z,m.array[s+6]=u.x,m.array[s+7]=u.y,m.array[s+8]=u.z),m.offset+=9):(m.array[s]=x.x,m.array[s+1]=
-x.y,m.array[s+2]=x.z,m.array[s+3]=x.w,m.array[s+4]=y.x,m.array[s+5]=y.y,m.array[s+6]=y.z,m.array[s+7]=y.w,m.array[s+8]=u.x,m.array[s+9]=u.y,m.array[s+10]=u.z,m.array[s+11]=u.w,m.offset+=12));if(sa){s=0;for(m=ya.length;s<m;s++)x=ya[s].vertices[p.a].position,y=ya[s].vertices[p.b].position,u=ya[s].vertices[p.c].position,B=da[s],B[ga]=x.x,B[ga+1]=x.y,B[ga+2]=x.z,B[ga+3]=y.x,B[ga+4]=y.y,B[ga+5]=y.z,B[ga+6]=u.x,B[ga+7]=u.y,B[ga+8]=u.z;ga+=9}if(za.length)s=za[p.a],m=za[p.b],B=za[p.c],$[z]=s.x,$[z+1]=s.y,
-$[z+2]=s.z,$[z+3]=s.w,$[z+4]=m.x,$[z+5]=m.y,$[z+6]=m.z,$[z+7]=m.w,$[z+8]=B.x,$[z+9]=B.y,$[z+10]=B.z,$[z+11]=B.w,s=Fa[p.a],m=Fa[p.b],B=Fa[p.c],Z[z]=s.x,Z[z+1]=s.y,Z[z+2]=s.z,Z[z+3]=s.w,Z[z+4]=m.x,Z[z+5]=m.y,Z[z+6]=m.z,Z[z+7]=m.w,Z[z+8]=B.x,Z[z+9]=B.y,Z[z+10]=B.z,Z[z+11]=B.w,s=Da[p.a],m=Da[p.b],B=Da[p.c],X[z]=s.x,X[z+1]=s.y,X[z+2]=s.z,X[z+3]=1,X[z+4]=m.x,X[z+5]=m.y,X[z+6]=m.z,X[z+7]=1,X[z+8]=B.x,X[z+9]=B.y,X[z+10]=B.z,X[z+11]=1,s=Ea[p.a],m=Ea[p.b],B=Ea[p.c],Y[z]=s.x,Y[z+1]=s.y,Y[z+2]=s.z,Y[z+3]=1,Y[z+
-4]=m.x,Y[z+5]=m.y,Y[z+6]=m.z,Y[z+7]=1,Y[z+8]=B.x,Y[z+9]=B.y,Y[z+10]=B.z,Y[z+11]=1,z+=12;if(ra&&v)C.length==3&&v==THREE.VertexColors?(p=C[0],s=C[1],m=C[2]):m=s=p=t,ja[ea]=p.r,ja[ea+1]=p.g,ja[ea+2]=p.b,ja[ea+3]=s.r,ja[ea+4]=s.g,ja[ea+5]=s.b,ja[ea+6]=m.r,ja[ea+7]=m.g,ja[ea+8]=m.b,ea+=9;if(qa&&oa.hasTangents)C=o[0],t=o[1],p=o[2],W[V]=C.x,W[V+1]=C.y,W[V+2]=C.z,W[V+3]=C.w,W[V+4]=t.x,W[V+5]=t.y,W[V+6]=t.z,W[V+7]=t.w,W[V+8]=p.x,W[V+9]=p.y,W[V+10]=p.z,W[V+11]=p.w,V+=12;if(pa&&A)if(n.length==3&&ma)for(o=0;o<
-3;o++)r=n[o],Q[N]=r.x,Q[N+1]=r.y,Q[N+2]=r.z,N+=3;else for(o=0;o<3;o++)Q[N]=r.x,Q[N+1]=r.y,Q[N+2]=r.z,N+=3;if(ha&&E!==void 0&&w)for(o=0;o<3;o++)n=E[o],aa[R]=n.u,aa[R+1]=n.v,R+=2;if(ha&&F!==void 0&&w)for(o=0;o<3;o++)n=F[o],ca[S]=n.u,ca[S+1]=n.v,S+=2;na&&(P[M]=I,P[M+1]=I+1,P[M+2]=I+2,M+=3,T[O]=I,T[O+1]=I+1,T[O+2]=I,T[O+3]=I+2,T[O+4]=I+1,T[O+5]=I+2,O+=6,I+=3)}else if(p instanceof THREE.Face4){if(la)x=ka[p.a].position,y=ka[p.b].position,u=ka[p.c].position,G=ka[p.d].position,ia[J]=x.x,ia[J+1]=x.y,ia[J+
-2]=x.z,ia[J+3]=y.x,ia[J+4]=y.y,ia[J+5]=y.z,ia[J+6]=u.x,ia[J+7]=u.y,ia[J+8]=u.z,ia[J+9]=G.x,ia[J+10]=G.y,ia[J+11]=G.z,J+=12;if(U)for(L in U)if(m=U[L],m.__original.needsUpdate)s=m.offset,B=m.offsetSrc,m.size===1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[s]=m.value[p.a],m.array[s+1]=m.value[p.b],m.array[s+2]=m.value[p.c],m.array[s+3]=m.value[p.d]):m.boundTo==="faces"?(B=m.value[B],m.array[s]=B,m.array[s+1]=B,m.array[s+2]=B,m.array[s+3]=B,m.offsetSrc++):m.boundTo==="faceVertices"&&(m.array[s]=
-m.value[B],m.array[s+1]=m.value[B+1],m.array[s+2]=m.value[B+2],m.array[s+3]=m.value[B+3],m.offsetSrc+=4),m.offset+=4):(m.boundTo===void 0||m.boundTo==="vertices"?(x=m.value[p.a],y=m.value[p.b],u=m.value[p.c],G=m.value[p.d]):m.boundTo==="faces"?(G=u=y=x=B=m.value[B],m.offsetSrc++):m.boundTo==="faceVertices"&&(x=m.value[B],y=m.value[B+1],u=m.value[B+2],G=m.value[B+3],m.offsetSrc+=4),m.size===2?(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=y.x,m.array[s+3]=y.y,m.array[s+4]=u.x,m.array[s+5]=u.y,m.array[s+
-6]=G.x,m.array[s+7]=G.y,m.offset+=8):m.size===3?(m.type==="c"?(m.array[s]=x.r,m.array[s+1]=x.g,m.array[s+2]=x.b,m.array[s+3]=y.r,m.array[s+4]=y.g,m.array[s+5]=y.b,m.array[s+6]=u.r,m.array[s+7]=u.g,m.array[s+8]=u.b,m.array[s+9]=G.r,m.array[s+10]=G.g,m.array[s+11]=G.b):(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=y.x,m.array[s+4]=y.y,m.array[s+5]=y.z,m.array[s+6]=u.x,m.array[s+7]=u.y,m.array[s+8]=u.z,m.array[s+9]=G.x,m.array[s+10]=G.y,m.array[s+11]=G.z),m.offset+=12):(m.array[s]=x.x,
-m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=x.w,m.array[s+4]=y.x,m.array[s+5]=y.y,m.array[s+6]=y.z,m.array[s+7]=y.w,m.array[s+8]=u.x,m.array[s+9]=u.y,m.array[s+10]=u.z,m.array[s+11]=u.w,m.array[s+12]=G.x,m.array[s+13]=G.y,m.array[s+14]=G.z,m.array[s+15]=G.w,m.offset+=16));if(sa){s=0;for(m=ya.length;s<m;s++)x=ya[s].vertices[p.a].position,y=ya[s].vertices[p.b].position,u=ya[s].vertices[p.c].position,G=ya[s].vertices[p.d].position,B=da[s],B[ga]=x.x,B[ga+1]=x.y,B[ga+2]=x.z,B[ga+3]=y.x,B[ga+4]=y.y,
-B[ga+5]=y.z,B[ga+6]=u.x,B[ga+7]=u.y,B[ga+8]=u.z,B[ga+9]=G.x,B[ga+10]=G.y,B[ga+11]=G.z;ga+=12}if(za.length)s=za[p.a],m=za[p.b],B=za[p.c],K=za[p.d],$[z]=s.x,$[z+1]=s.y,$[z+2]=s.z,$[z+3]=s.w,$[z+4]=m.x,$[z+5]=m.y,$[z+6]=m.z,$[z+7]=m.w,$[z+8]=B.x,$[z+9]=B.y,$[z+10]=B.z,$[z+11]=B.w,$[z+12]=K.x,$[z+13]=K.y,$[z+14]=K.z,$[z+15]=K.w,s=Fa[p.a],m=Fa[p.b],B=Fa[p.c],K=Fa[p.d],Z[z]=s.x,Z[z+1]=s.y,Z[z+2]=s.z,Z[z+3]=s.w,Z[z+4]=m.x,Z[z+5]=m.y,Z[z+6]=m.z,Z[z+7]=m.w,Z[z+8]=B.x,Z[z+9]=B.y,Z[z+10]=B.z,Z[z+11]=B.w,Z[z+
-12]=K.x,Z[z+13]=K.y,Z[z+14]=K.z,Z[z+15]=K.w,s=Da[p.a],m=Da[p.b],B=Da[p.c],K=Da[p.d],X[z]=s.x,X[z+1]=s.y,X[z+2]=s.z,X[z+3]=1,X[z+4]=m.x,X[z+5]=m.y,X[z+6]=m.z,X[z+7]=1,X[z+8]=B.x,X[z+9]=B.y,X[z+10]=B.z,X[z+11]=1,X[z+12]=K.x,X[z+13]=K.y,X[z+14]=K.z,X[z+15]=1,s=Ea[p.a],m=Ea[p.b],B=Ea[p.c],p=Ea[p.d],Y[z]=s.x,Y[z+1]=s.y,Y[z+2]=s.z,Y[z+3]=1,Y[z+4]=m.x,Y[z+5]=m.y,Y[z+6]=m.z,Y[z+7]=1,Y[z+8]=B.x,Y[z+9]=B.y,Y[z+10]=B.z,Y[z+11]=1,Y[z+12]=p.x,Y[z+13]=p.y,Y[z+14]=p.z,Y[z+15]=1,z+=16;if(ra&&v)C.length==4&&v==THREE.VertexColors?
-(p=C[0],s=C[1],m=C[2],C=C[3]):C=m=s=p=t,ja[ea]=p.r,ja[ea+1]=p.g,ja[ea+2]=p.b,ja[ea+3]=s.r,ja[ea+4]=s.g,ja[ea+5]=s.b,ja[ea+6]=m.r,ja[ea+7]=m.g,ja[ea+8]=m.b,ja[ea+9]=C.r,ja[ea+10]=C.g,ja[ea+11]=C.b,ea+=12;if(qa&&oa.hasTangents)C=o[0],t=o[1],p=o[2],o=o[3],W[V]=C.x,W[V+1]=C.y,W[V+2]=C.z,W[V+3]=C.w,W[V+4]=t.x,W[V+5]=t.y,W[V+6]=t.z,W[V+7]=t.w,W[V+8]=p.x,W[V+9]=p.y,W[V+10]=p.z,W[V+11]=p.w,W[V+12]=o.x,W[V+13]=o.y,W[V+14]=o.z,W[V+15]=o.w,V+=16;if(pa&&A)if(n.length==4&&ma)for(o=0;o<4;o++)r=n[o],Q[N]=r.x,Q[N+
-1]=r.y,Q[N+2]=r.z,N+=3;else for(o=0;o<4;o++)Q[N]=r.x,Q[N+1]=r.y,Q[N+2]=r.z,N+=3;if(ha&&E!==void 0&&w)for(o=0;o<4;o++)n=E[o],aa[R]=n.u,aa[R+1]=n.v,R+=2;if(ha&&F!==void 0&&w)for(o=0;o<4;o++)n=F[o],ca[S]=n.u,ca[S+1]=n.v,S+=2;na&&(P[M]=I,P[M+1]=I+1,P[M+2]=I+3,P[M+3]=I+1,P[M+4]=I+2,P[M+5]=I+3,M+=6,T[O]=I,T[O+1]=I+1,T[O+2]=I,T[O+3]=I+3,T[O+4]=I+1,T[O+5]=I+2,T[O+6]=I+2,T[O+7]=I+3,O+=8,I+=4)}if(Aa){k=0;for(q=Aa.length;k<q;k++)P[M]=Aa[k].a,P[M+1]=Aa[k].b,P[M+2]=Aa[k].c,P[M+3]=Aa[k].a,P[M+4]=Aa[k].c,P[M+5]=
-Aa[k].d,M+=6}la&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,ia,j));if(U)for(L in U)m=U[L],m.__original.needsUpdate&&(c.bindBuffer(c.ARRAY_BUFFER,m.buffer),c.bufferData(c.ARRAY_BUFFER,m.array,j));if(sa){s=0;for(m=ya.length;s<m;s++)c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[s]),c.bufferData(c.ARRAY_BUFFER,da[s],j)}ra&&ea>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,ja,j));pa&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglNormalBuffer),
-c.bufferData(c.ARRAY_BUFFER,Q,j));qa&&oa.hasTangents&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglTangentBuffer),c.bufferData(c.ARRAY_BUFFER,W,j));ha&&R>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUVBuffer),c.bufferData(c.ARRAY_BUFFER,aa,j));ha&&S>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUV2Buffer),c.bufferData(c.ARRAY_BUFFER,ca,j));na&&(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,P,j),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,
-T,j));z>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexABuffer),c.bufferData(c.ARRAY_BUFFER,X,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),c.bufferData(c.ARRAY_BUFFER,Y,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),c.bufferData(c.ARRAY_BUFFER,Z,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),c.bufferData(c.ARRAY_BUFFER,$,j));i.dynamic||(delete h.__inittedArrays,delete h.__colorArray,delete h.__normalArray,delete h.__tangentArray,delete h.__uvArray,delete h.__uv2Array,
-delete h.__faceArray,delete h.__vertexArray,delete h.__lineArray,delete h.__skinVertexAArray,delete h.__skinVertexBArray,delete h.__skinIndexArray,delete h.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;fa(g)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=c.DYNAMIC_DRAW;w=b.vertices;h=b.colors;v=w.length;i=h.length;A=b.__vertexArray;j=b.__colorArray;
-E=b.__dirtyColors;if(b.__dirtyVertices){for(k=0;k<v;k++)q=w[k].position,g=k*3,A[g]=q.x,A[g+1]=q.y,A[g+2]=q.z;c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,A,e)}if(E){for(k=0;k<i;k++)color=h[k],g=k*3,j[g]=color.r,j[g+1]=color.g,j[g+2]=color.b;c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,j,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.Line){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=c.DYNAMIC_DRAW;
-w=b.vertices;h=b.colors;v=w.length;i=h.length;A=b.__vertexArray;j=b.__colorArray;E=b.__dirtyColors;if(b.__dirtyVertices){for(k=0;k<v;k++)q=w[k].position,g=k*3,A[g]=q.x,A[g+1]=q.y,A[g+2]=q.z;c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,A,e)}if(E){for(k=0;k<i;k++)color=h[k],g=k*3,j[g]=color.r,j[g+1]=color.g,j[g+2]=color.b;c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,j,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)f=
-b.geometry,h=ta(f),(f.__dirtyVertices||f.__dirtyColors||b.sortParticles||h)&&d(f,c.DYNAMIC_DRAW,b),f.__dirtyVertices=!1,f.__dirtyColors=!1,fa(f)}function w(b,c){var d;for(d=b.length-1;d>=0;d--)b[d].object==c&&b.splice(d,1)}function P(b){function c(b){var f=[];d=0;for(e=b.length;d<e;d++)b[d]==void 0?f.push("undefined"):f.push(b[d].id);return f.join("_")}var d,e,f,h,g,i,j,k,p={},n=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(h=b.faces.length;f<h;f++)g=b.faces[f],i=g.materials,
-j=c(i),p[j]==void 0&&(p[j]={hash:j,counter:0}),k=p[j].hash+"_"+p[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:n}),g=g instanceof THREE.Face3?3:4,b.geometryGroups[k].vertices+g>65535&&(p[j].counter+=1,k=p[j].hash+"_"+p[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:n})),b.geometryGroups[k].faces.push(f),b.geometryGroups[k].vertices+=g}function J(b,c,d){b.push({buffer:c,object:d,
-opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(b){if(b!=da){switch(b){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD),c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}da=
-b}}function Q(b,d,e){(e.width&e.width-1)==0&&(e.height&e.height-1)==0?(c.texParameteri(b,c.TEXTURE_WRAP_S,N(d.wrapS)),c.texParameteri(b,c.TEXTURE_WRAP_T,N(d.wrapT)),c.texParameteri(b,c.TEXTURE_MAG_FILTER,N(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,N(d.minFilter)),c.generateMipmap(b)):(c.texParameteri(b,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_MAG_FILTER,va(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,va(d.minFilter)))}
-function ra(b,d){if(b.needsUpdate){if(!b.__webglInit)b.__webglTexture=c.createTexture(),b.__webglInit=!0;c.bindTexture(c.TEXTURE_2D,b.__webglTexture);b.image.data?c.texImage2D(c.TEXTURE_2D,0,N(b.format),b.image.width,b.image.height,0,N(b.format),c.UNSIGNED_BYTE,b.image.data):c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b.image);Q(c.TEXTURE_2D,b,b.image);c.bindTexture(c.TEXTURE_2D,null);b.needsUpdate=!1}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,b.__webglTexture)}function ka(b){if(b&&
-!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=c.createFramebuffer();b.__webglRenderbuffer=c.createRenderbuffer();b.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,b.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,N(b.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,N(b.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,N(b.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
-N(b.minFilter));c.texImage2D(c.TEXTURE_2D,0,N(b.format),b.width,b.height,0,N(b.format),N(b.type),null);c.bindRenderbuffer(c.RENDERBUFFER,b.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,b.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):
-b.depthBuffer&&b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_STENCIL,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,b.width,b.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var d,e;b?(d=b.__webglFramebuffer,e=b.width,b=b.height):(d=null,e=la,b=qa);d!=pa&&(c.bindFramebuffer(c.FRAMEBUFFER,d),
-c.viewport(Ha,Ia,e,b),pa=d)}function aa(b,d){var e;b=="fragment"?e=c.createShader(c.FRAGMENT_SHADER):b=="vertex"&&(e=c.createShader(c.VERTEX_SHADER));c.shaderSource(e,d);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS))return console.error(c.getShaderInfoLog(e)),console.error(d),null;return e}function va(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function N(b){switch(b){case THREE.RepeatWrapping:return c.REPEAT;
-case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;
-case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var K=this,c,ha=[],R=null,
-pa=null,L=!0,ca=null,O=null,da=null,T=null,S=null,ua=null,Ga=null,Ha=0,Ia=0,la=0,qa=0,ma=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],wa=new THREE.Matrix4,Ka=new Float32Array(16),La=new Float32Array(16),Ja=new THREE.Vector4,Ra={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},xa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Pa=b.stencil!==void 0?
-b.stencil:!0,y=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,Xa=b.antialias!==void 0?b.antialias:!1,sa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ma=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=xa;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=
-50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var na,Na=[],b=THREE.ShaderLib.depthRGBA,Va=THREE.UniformsUtils.clone(b.uniforms),Oa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Va}),Sa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Va,morphTargets:!0});Oa._shadowPass=!0;Sa._shadowPass=!0;try{if(!(c=xa.getContext("experimental-webgl",{antialias:Xa,stencil:Pa,preserveDrawingBuffer:y})))throw"Error creating WebGL context.";
-console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION))}catch(Ya){console.error(Ya)}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(sa.r,sa.g,sa.b,Ma);this.context=c;var Wa=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
-0;if(Pa){var u={};u.vertices=new Float32Array(12);u.faces=new Uint16Array(6);u.darkness=0.5;u.vertices[0]=-20;u.vertices[1]=-20;u.vertices[2]=-1;u.vertices[3]=20;u.vertices[4]=-20;u.vertices[5]=-1;u.vertices[6]=20;u.vertices[7]=20;u.vertices[8]=-1;u.vertices[9]=-20;u.vertices[10]=20;u.vertices[11]=-1;u.faces[0]=0;u.faces[1]=1;u.faces[2]=2;u.faces[3]=0;u.faces[4]=2;u.faces[5]=3;u.vertexBuffer=c.createBuffer();u.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,u.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,
-u.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,u.faces,c.STATIC_DRAW);u.program=c.createProgram();c.attachShader(u.program,aa("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(u.program,aa("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(u.program);u.vertexLocation=c.getAttribLocation(u.program,"position");u.projectionLocation=c.getUniformLocation(u.program,"projectionMatrix");u.darknessLocation=
-c.getUniformLocation(u.program,"darkness")}var A={};A.vertices=new Float32Array(16);A.faces=new Uint16Array(6);y=0;A.vertices[y++]=-1;A.vertices[y++]=-1;A.vertices[y++]=0;A.vertices[y++]=0;A.vertices[y++]=1;A.vertices[y++]=-1;A.vertices[y++]=1;A.vertices[y++]=0;A.vertices[y++]=1;A.vertices[y++]=1;A.vertices[y++]=1;A.vertices[y++]=1;A.vertices[y++]=-1;A.vertices[y++]=1;A.vertices[y++]=0;A.vertices[y++]=1;y=0;A.faces[y++]=0;A.faces[y++]=1;A.faces[y++]=2;A.faces[y++]=0;A.faces[y++]=2;A.faces[y++]=3;
-A.vertexBuffer=c.createBuffer();A.elementBuffer=c.createBuffer();A.tempTexture=c.createTexture();A.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,A.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,A.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,A.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,A.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,
-c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.bindTexture(c.TEXTURE_2D,A.occlusionTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);
-c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(A.hasVertexTexture=!1,A.program=c.createProgram(),c.attachShader(A.program,aa("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),c.attachShader(A.program,aa("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(A.hasVertexTexture=!0,A.program=c.createProgram(),c.attachShader(A.program,aa("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),c.attachShader(A.program,aa("vertex",
-THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));c.linkProgram(A.program);A.attributes={};A.uniforms={};A.attributes.vertex=c.getAttribLocation(A.program,"position");A.attributes.uv=c.getAttribLocation(A.program,"UV");A.uniforms.renderType=c.getUniformLocation(A.program,"renderType");A.uniforms.map=c.getUniformLocation(A.program,"map");A.uniforms.occlusionMap=c.getUniformLocation(A.program,"occlusionMap");A.uniforms.opacity=c.getUniformLocation(A.program,"opacity");A.uniforms.scale=c.getUniformLocation(A.program,
-"scale");A.uniforms.rotation=c.getUniformLocation(A.program,"rotation");A.uniforms.screenPosition=c.getUniformLocation(A.program,"screenPosition");var Ua=!1,v={};v.vertices=new Float32Array(16);v.faces=new Uint16Array(6);y=0;v.vertices[y++]=-1;v.vertices[y++]=-1;v.vertices[y++]=0;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=-1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=0;v.vertices[y++]=-1;v.vertices[y++]=1;v.vertices[y++]=0;y=
-v.vertices[y++]=0;v.faces[y++]=0;v.faces[y++]=1;v.faces[y++]=2;v.faces[y++]=0;v.faces[y++]=2;v.faces[y++]=3;v.vertexBuffer=c.createBuffer();v.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,v.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,v.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,v.faces,c.STATIC_DRAW);v.program=c.createProgram();c.attachShader(v.program,aa("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(v.program,
-aa("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(v.program);v.attributes={};v.uniforms={};v.attributes.position=c.getAttribLocation(v.program,"position");v.attributes.uv=c.getAttribLocation(v.program,"uv");v.uniforms.uvOffset=c.getUniformLocation(v.program,"uvOffset");v.uniforms.uvScale=c.getUniformLocation(v.program,"uvScale");v.uniforms.rotation=c.getUniformLocation(v.program,"rotation");v.uniforms.scale=c.getUniformLocation(v.program,"scale");v.uniforms.alignment=c.getUniformLocation(v.program,
-"alignment");v.uniforms.map=c.getUniformLocation(v.program,"map");v.uniforms.opacity=c.getUniformLocation(v.program,"opacity");v.uniforms.useScreenCoordinates=c.getUniformLocation(v.program,"useScreenCoordinates");v.uniforms.affectedByDistance=c.getUniformLocation(v.program,"affectedByDistance");v.uniforms.screenPosition=c.getUniformLocation(v.program,"screenPosition");v.uniforms.modelViewMatrix=c.getUniformLocation(v.program,"modelViewMatrix");v.uniforms.projectionMatrix=c.getUniformLocation(v.program,
-"projectionMatrix");var Ta=!1;this.setSize=function(b,c){xa.width=b;xa.height=c;this.setViewport(0,0,xa.width,xa.height)};this.setViewport=function(b,d,e,f){Ha=b;Ia=d;la=e;qa=f;c.viewport(Ha,Ia,la,qa)};this.setScissor=function(b,d,e,f){c.scissor(b,d,e,f)};this.enableScissorTest=function(b){b?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){L=b;c.depthMask(b)};this.setClearColorHex=function(b,d){sa.setHex(b);Ma=d;c.clearColor(sa.r,sa.g,sa.b,Ma)};this.setClearColor=
-function(b,d){sa.copy(b);Ma=d;c.clearColor(sa.r,sa.g,sa.b,Ma)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){u.darkness=b};this.getContext=function(){return c};this.initMaterial=function(b,d,e,f){var h,g,i;b instanceof THREE.MeshDepthMaterial?i="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?i="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?i="normal":b instanceof THREE.MeshBasicMaterial?i="basic":
-b instanceof THREE.MeshLambertMaterial?i="lambert":b instanceof THREE.MeshPhongMaterial?i="phong":b instanceof THREE.LineBasicMaterial?i="basic":b instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];b.uniforms=THREE.UniformsUtils.clone(j.uniforms);b.vertexShader=j.vertexShader;b.fragmentShader=j.fragmentShader}var k,n,p;k=p=j=0;for(n=d.length;k<n;k++)g=d[k],g instanceof THREE.SpotLight&&p++,g instanceof THREE.DirectionalLight&&p++,g instanceof THREE.PointLight&&
-j++;j+p<=4?k=p:(k=Math.ceil(4*p/(j+p)),j=4-k);g={directional:k,point:j};j=p=0;for(k=d.length;j<k;j++)n=d[j],n instanceof THREE.SpotLight&&n.castShadow&&p++;var q=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)q=f.bones.length;var o;a:{k=b.fragmentShader;n=b.vertexShader;var j=b.uniforms,d=b.attributes,e={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:e,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,
-maxDirLights:g.directional,maxPointLights:g.point,maxBones:q,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:p,alphaTest:b.alphaTest},r,f=[];i?f.push(i):(f.push(k),f.push(n));for(r in e)f.push(r),f.push(e[r]);i=f.join();r=0;for(f=ha.length;r<f;r++)if(ha[r].code==i){o=ha[r].program;break a}r=c.createProgram();f=[Wa?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+e.maxDirLights,
-"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,"#define MAX_BONES "+e.maxBones,e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+o[1];d.positionScreen.z=o[2];d.customUpdateCallback?d.customUpdateCallback(d):d.updateLensFlares();c.uniform1i(v.renderType,2);c.enable(c.BLEND);h=0;for(i=d.lensFlares.length;h<i;h++)if(j=d.lensFlares[h],j.opacity>0.001&&j.scale>0.001)o[0]=j.x,o[1]=j.y,o[2]=j.z,r=j.size*j.scale/qa,t[0]=r*q,t[1]=r,c.uniform3fv(v.screenPosition,o),c.uniform2fv(v.scale,t),c.uniform1f(v.rotation,j.rotation),c.uniform1f(v.opacity,j.opacity),M(j.blending),ra(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}c.enable(c.CULL_FACE);
+c.enable(c.DEPTH_TEST);c.depthMask(L)}function U(b,c,d){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function ta(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)if(e.attributes[c].needsUpdate)return!0;return!1}function fa(b){var c,d,e,f;f=b.__materials;b=0;for(d=f.length;b<d;b++)if(e=f[b],e.attributes)for(c in e.attributes)e.attributes[c].needsUpdate=
+!1}function I(b){var e,f,g,h;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups)if(g=f.geometryGroups[e],h=ta(g),f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||h){h=g;var i=b,j=c.DYNAMIC_DRAW;if(h.__inittedArrays){var k=void 0,q=void 0,n=void 0,p=void 0,r=n=void 0,C=void 0,t=void 0,o=void 0,w=void 0,v=void 0,A=void 0,E=void 0,F=void 0,x=void 0,y=void 0,u=void 0,G=void 0,s=p=o=p=t=C=void 0,m=void 0,B=
+m=s=C=void 0,K=void 0,L=B=m=s=n=n=r=o=p=B=m=s=K=B=m=s=K=B=m=s=void 0,I=0,J=0,R=0,S=0,M=0,N=0,V=0,O=0,ea=0,z=0,ga=0,B=s=0,B=void 0,ia=h.__vertexArray,aa=h.__uvArray,ca=h.__uv2Array,Q=h.__normalArray,W=h.__tangentArray,ja=h.__colorArray,X=h.__skinVertexAArray,Y=h.__skinVertexBArray,Z=h.__skinIndexArray,$=h.__skinWeightArray,da=h.__morphTargetsArrays,U=h.__webglCustomAttributes,m=void 0,P=h.__faceArray,T=h.__lineArray,ma=h.__needsSmoothNormals,v=h.__vertexColorType,w=h.__uvType,A=h.__normalType,oa=i.geometry,
+la=oa.__dirtyVertices,na=oa.__dirtyElements,ha=oa.__dirtyUvs,pa=oa.__dirtyNormals,qa=oa.__dirtyTangents,ra=oa.__dirtyColors,sa=oa.__dirtyMorphTargets,ka=oa.vertices,ua=h.faces,va=oa.faces,wa=oa.faceVertexUvs[0],xa=oa.faceVertexUvs[1],Da=oa.skinVerticesA,Ea=oa.skinVerticesB,Fa=oa.skinIndices,za=oa.skinWeights,Aa=i instanceof THREE.ShadowVolume?oa.edgeFaces:void 0,ya=oa.morphTargets;if(U)for(L in U)U[L].offset=0,U[L].offsetSrc=0;k=0;for(q=ua.length;k<q;k++)if(n=ua[k],p=va[n],wa&&(E=wa[n]),xa&&(F=xa[n]),
+n=p.vertexNormals,r=p.normal,C=p.vertexColors,t=p.color,o=p.vertexTangents,p instanceof THREE.Face3){if(la)x=ka[p.a].position,y=ka[p.b].position,u=ka[p.c].position,ia[J]=x.x,ia[J+1]=x.y,ia[J+2]=x.z,ia[J+3]=y.x,ia[J+4]=y.y,ia[J+5]=y.z,ia[J+6]=u.x,ia[J+7]=u.y,ia[J+8]=u.z,J+=9;if(U)for(L in U)if(m=U[L],m.__original.needsUpdate)s=m.offset,B=m.offsetSrc,m.size===1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[s]=m.value[p.a],m.array[s+1]=m.value[p.b],m.array[s+2]=m.value[p.c]):m.boundTo==="faces"?
+(B=m.value[B],m.array[s]=B,m.array[s+1]=B,m.array[s+2]=B,m.offsetSrc++):m.boundTo==="faceVertices"&&(m.array[s]=m.value[B],m.array[s+1]=m.value[B+1],m.array[s+2]=m.value[B+2],m.offsetSrc+=3),m.offset+=3):(m.boundTo===void 0||m.boundTo==="vertices"?(x=m.value[p.a],y=m.value[p.b],u=m.value[p.c]):m.boundTo==="faces"?(u=y=x=B=m.value[B],m.offsetSrc++):m.boundTo==="faceVertices"&&(x=m.value[B],y=m.value[B+1],u=m.value[B+2],m.offsetSrc+=3),m.size===2?(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=y.x,m.array[s+
+3]=y.y,m.array[s+4]=u.x,m.array[s+5]=u.y,m.offset+=6):m.size===3?(m.type==="c"?(m.array[s]=x.r,m.array[s+1]=x.g,m.array[s+2]=x.b,m.array[s+3]=y.r,m.array[s+4]=y.g,m.array[s+5]=y.b,m.array[s+6]=u.r,m.array[s+7]=u.g,m.array[s+8]=u.b):(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=y.x,m.array[s+4]=y.y,m.array[s+5]=y.z,m.array[s+6]=u.x,m.array[s+7]=u.y,m.array[s+8]=u.z),m.offset+=9):(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=x.w,m.array[s+4]=y.x,m.array[s+5]=y.y,m.array[s+
+6]=y.z,m.array[s+7]=y.w,m.array[s+8]=u.x,m.array[s+9]=u.y,m.array[s+10]=u.z,m.array[s+11]=u.w,m.offset+=12));if(sa){s=0;for(m=ya.length;s<m;s++)x=ya[s].vertices[p.a].position,y=ya[s].vertices[p.b].position,u=ya[s].vertices[p.c].position,B=da[s],B[ga]=x.x,B[ga+1]=x.y,B[ga+2]=x.z,B[ga+3]=y.x,B[ga+4]=y.y,B[ga+5]=y.z,B[ga+6]=u.x,B[ga+7]=u.y,B[ga+8]=u.z;ga+=9}if(za.length)s=za[p.a],m=za[p.b],B=za[p.c],$[z]=s.x,$[z+1]=s.y,$[z+2]=s.z,$[z+3]=s.w,$[z+4]=m.x,$[z+5]=m.y,$[z+6]=m.z,$[z+7]=m.w,$[z+8]=B.x,$[z+
+9]=B.y,$[z+10]=B.z,$[z+11]=B.w,s=Fa[p.a],m=Fa[p.b],B=Fa[p.c],Z[z]=s.x,Z[z+1]=s.y,Z[z+2]=s.z,Z[z+3]=s.w,Z[z+4]=m.x,Z[z+5]=m.y,Z[z+6]=m.z,Z[z+7]=m.w,Z[z+8]=B.x,Z[z+9]=B.y,Z[z+10]=B.z,Z[z+11]=B.w,s=Da[p.a],m=Da[p.b],B=Da[p.c],X[z]=s.x,X[z+1]=s.y,X[z+2]=s.z,X[z+3]=1,X[z+4]=m.x,X[z+5]=m.y,X[z+6]=m.z,X[z+7]=1,X[z+8]=B.x,X[z+9]=B.y,X[z+10]=B.z,X[z+11]=1,s=Ea[p.a],m=Ea[p.b],B=Ea[p.c],Y[z]=s.x,Y[z+1]=s.y,Y[z+2]=s.z,Y[z+3]=1,Y[z+4]=m.x,Y[z+5]=m.y,Y[z+6]=m.z,Y[z+7]=1,Y[z+8]=B.x,Y[z+9]=B.y,Y[z+10]=B.z,Y[z+11]=
+1,z+=12;if(ra&&v)C.length==3&&v==THREE.VertexColors?(p=C[0],s=C[1],m=C[2]):m=s=p=t,ja[ea]=p.r,ja[ea+1]=p.g,ja[ea+2]=p.b,ja[ea+3]=s.r,ja[ea+4]=s.g,ja[ea+5]=s.b,ja[ea+6]=m.r,ja[ea+7]=m.g,ja[ea+8]=m.b,ea+=9;if(qa&&oa.hasTangents)C=o[0],t=o[1],p=o[2],W[V]=C.x,W[V+1]=C.y,W[V+2]=C.z,W[V+3]=C.w,W[V+4]=t.x,W[V+5]=t.y,W[V+6]=t.z,W[V+7]=t.w,W[V+8]=p.x,W[V+9]=p.y,W[V+10]=p.z,W[V+11]=p.w,V+=12;if(pa&&A)if(n.length==3&&ma)for(o=0;o<3;o++)r=n[o],Q[N]=r.x,Q[N+1]=r.y,Q[N+2]=r.z,N+=3;else for(o=0;o<3;o++)Q[N]=r.x,
+Q[N+1]=r.y,Q[N+2]=r.z,N+=3;if(ha&&E!==void 0&&w)for(o=0;o<3;o++)n=E[o],aa[R]=n.u,aa[R+1]=n.v,R+=2;if(ha&&F!==void 0&&w)for(o=0;o<3;o++)n=F[o],ca[S]=n.u,ca[S+1]=n.v,S+=2;na&&(P[M]=I,P[M+1]=I+1,P[M+2]=I+2,M+=3,T[O]=I,T[O+1]=I+1,T[O+2]=I,T[O+3]=I+2,T[O+4]=I+1,T[O+5]=I+2,O+=6,I+=3)}else if(p instanceof THREE.Face4){if(la)x=ka[p.a].position,y=ka[p.b].position,u=ka[p.c].position,G=ka[p.d].position,ia[J]=x.x,ia[J+1]=x.y,ia[J+2]=x.z,ia[J+3]=y.x,ia[J+4]=y.y,ia[J+5]=y.z,ia[J+6]=u.x,ia[J+7]=u.y,ia[J+8]=u.z,
+ia[J+9]=G.x,ia[J+10]=G.y,ia[J+11]=G.z,J+=12;if(U)for(L in U)if(m=U[L],m.__original.needsUpdate)s=m.offset,B=m.offsetSrc,m.size===1?(m.boundTo===void 0||m.boundTo==="vertices"?(m.array[s]=m.value[p.a],m.array[s+1]=m.value[p.b],m.array[s+2]=m.value[p.c],m.array[s+3]=m.value[p.d]):m.boundTo==="faces"?(B=m.value[B],m.array[s]=B,m.array[s+1]=B,m.array[s+2]=B,m.array[s+3]=B,m.offsetSrc++):m.boundTo==="faceVertices"&&(m.array[s]=m.value[B],m.array[s+1]=m.value[B+1],m.array[s+2]=m.value[B+2],m.array[s+3]=
+m.value[B+3],m.offsetSrc+=4),m.offset+=4):(m.boundTo===void 0||m.boundTo==="vertices"?(x=m.value[p.a],y=m.value[p.b],u=m.value[p.c],G=m.value[p.d]):m.boundTo==="faces"?(G=u=y=x=B=m.value[B],m.offsetSrc++):m.boundTo==="faceVertices"&&(x=m.value[B],y=m.value[B+1],u=m.value[B+2],G=m.value[B+3],m.offsetSrc+=4),m.size===2?(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=y.x,m.array[s+3]=y.y,m.array[s+4]=u.x,m.array[s+5]=u.y,m.array[s+6]=G.x,m.array[s+7]=G.y,m.offset+=8):m.size===3?(m.type==="c"?(m.array[s]=
+x.r,m.array[s+1]=x.g,m.array[s+2]=x.b,m.array[s+3]=y.r,m.array[s+4]=y.g,m.array[s+5]=y.b,m.array[s+6]=u.r,m.array[s+7]=u.g,m.array[s+8]=u.b,m.array[s+9]=G.r,m.array[s+10]=G.g,m.array[s+11]=G.b):(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=y.x,m.array[s+4]=y.y,m.array[s+5]=y.z,m.array[s+6]=u.x,m.array[s+7]=u.y,m.array[s+8]=u.z,m.array[s+9]=G.x,m.array[s+10]=G.y,m.array[s+11]=G.z),m.offset+=12):(m.array[s]=x.x,m.array[s+1]=x.y,m.array[s+2]=x.z,m.array[s+3]=x.w,m.array[s+4]=y.x,m.array[s+
+5]=y.y,m.array[s+6]=y.z,m.array[s+7]=y.w,m.array[s+8]=u.x,m.array[s+9]=u.y,m.array[s+10]=u.z,m.array[s+11]=u.w,m.array[s+12]=G.x,m.array[s+13]=G.y,m.array[s+14]=G.z,m.array[s+15]=G.w,m.offset+=16));if(sa){s=0;for(m=ya.length;s<m;s++)x=ya[s].vertices[p.a].position,y=ya[s].vertices[p.b].position,u=ya[s].vertices[p.c].position,G=ya[s].vertices[p.d].position,B=da[s],B[ga]=x.x,B[ga+1]=x.y,B[ga+2]=x.z,B[ga+3]=y.x,B[ga+4]=y.y,B[ga+5]=y.z,B[ga+6]=u.x,B[ga+7]=u.y,B[ga+8]=u.z,B[ga+9]=G.x,B[ga+10]=G.y,B[ga+
+11]=G.z;ga+=12}if(za.length)s=za[p.a],m=za[p.b],B=za[p.c],K=za[p.d],$[z]=s.x,$[z+1]=s.y,$[z+2]=s.z,$[z+3]=s.w,$[z+4]=m.x,$[z+5]=m.y,$[z+6]=m.z,$[z+7]=m.w,$[z+8]=B.x,$[z+9]=B.y,$[z+10]=B.z,$[z+11]=B.w,$[z+12]=K.x,$[z+13]=K.y,$[z+14]=K.z,$[z+15]=K.w,s=Fa[p.a],m=Fa[p.b],B=Fa[p.c],K=Fa[p.d],Z[z]=s.x,Z[z+1]=s.y,Z[z+2]=s.z,Z[z+3]=s.w,Z[z+4]=m.x,Z[z+5]=m.y,Z[z+6]=m.z,Z[z+7]=m.w,Z[z+8]=B.x,Z[z+9]=B.y,Z[z+10]=B.z,Z[z+11]=B.w,Z[z+12]=K.x,Z[z+13]=K.y,Z[z+14]=K.z,Z[z+15]=K.w,s=Da[p.a],m=Da[p.b],B=Da[p.c],K=Da[p.d],
+X[z]=s.x,X[z+1]=s.y,X[z+2]=s.z,X[z+3]=1,X[z+4]=m.x,X[z+5]=m.y,X[z+6]=m.z,X[z+7]=1,X[z+8]=B.x,X[z+9]=B.y,X[z+10]=B.z,X[z+11]=1,X[z+12]=K.x,X[z+13]=K.y,X[z+14]=K.z,X[z+15]=1,s=Ea[p.a],m=Ea[p.b],B=Ea[p.c],p=Ea[p.d],Y[z]=s.x,Y[z+1]=s.y,Y[z+2]=s.z,Y[z+3]=1,Y[z+4]=m.x,Y[z+5]=m.y,Y[z+6]=m.z,Y[z+7]=1,Y[z+8]=B.x,Y[z+9]=B.y,Y[z+10]=B.z,Y[z+11]=1,Y[z+12]=p.x,Y[z+13]=p.y,Y[z+14]=p.z,Y[z+15]=1,z+=16;if(ra&&v)C.length==4&&v==THREE.VertexColors?(p=C[0],s=C[1],m=C[2],C=C[3]):C=m=s=p=t,ja[ea]=p.r,ja[ea+1]=p.g,ja[ea+
+2]=p.b,ja[ea+3]=s.r,ja[ea+4]=s.g,ja[ea+5]=s.b,ja[ea+6]=m.r,ja[ea+7]=m.g,ja[ea+8]=m.b,ja[ea+9]=C.r,ja[ea+10]=C.g,ja[ea+11]=C.b,ea+=12;if(qa&&oa.hasTangents)C=o[0],t=o[1],p=o[2],o=o[3],W[V]=C.x,W[V+1]=C.y,W[V+2]=C.z,W[V+3]=C.w,W[V+4]=t.x,W[V+5]=t.y,W[V+6]=t.z,W[V+7]=t.w,W[V+8]=p.x,W[V+9]=p.y,W[V+10]=p.z,W[V+11]=p.w,W[V+12]=o.x,W[V+13]=o.y,W[V+14]=o.z,W[V+15]=o.w,V+=16;if(pa&&A)if(n.length==4&&ma)for(o=0;o<4;o++)r=n[o],Q[N]=r.x,Q[N+1]=r.y,Q[N+2]=r.z,N+=3;else for(o=0;o<4;o++)Q[N]=r.x,Q[N+1]=r.y,Q[N+
+2]=r.z,N+=3;if(ha&&E!==void 0&&w)for(o=0;o<4;o++)n=E[o],aa[R]=n.u,aa[R+1]=n.v,R+=2;if(ha&&F!==void 0&&w)for(o=0;o<4;o++)n=F[o],ca[S]=n.u,ca[S+1]=n.v,S+=2;na&&(P[M]=I,P[M+1]=I+1,P[M+2]=I+3,P[M+3]=I+1,P[M+4]=I+2,P[M+5]=I+3,M+=6,T[O]=I,T[O+1]=I+1,T[O+2]=I,T[O+3]=I+3,T[O+4]=I+1,T[O+5]=I+2,T[O+6]=I+2,T[O+7]=I+3,O+=8,I+=4)}if(Aa){k=0;for(q=Aa.length;k<q;k++)P[M]=Aa[k].a,P[M+1]=Aa[k].b,P[M+2]=Aa[k].c,P[M+3]=Aa[k].a,P[M+4]=Aa[k].c,P[M+5]=Aa[k].d,M+=6}la&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglVertexBuffer),
+c.bufferData(c.ARRAY_BUFFER,ia,j));if(U)for(L in U)m=U[L],m.__original.needsUpdate&&(c.bindBuffer(c.ARRAY_BUFFER,m.buffer),c.bufferData(c.ARRAY_BUFFER,m.array,j));if(sa){s=0;for(m=ya.length;s<m;s++)c.bindBuffer(c.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[s]),c.bufferData(c.ARRAY_BUFFER,da[s],j)}ra&&ea>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglColorBuffer),c.bufferData(c.ARRAY_BUFFER,ja,j));pa&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglNormalBuffer),c.bufferData(c.ARRAY_BUFFER,Q,j));qa&&oa.hasTangents&&
+(c.bindBuffer(c.ARRAY_BUFFER,h.__webglTangentBuffer),c.bufferData(c.ARRAY_BUFFER,W,j));ha&&R>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUVBuffer),c.bufferData(c.ARRAY_BUFFER,aa,j));ha&&S>0&&(c.bindBuffer(c.ARRAY_BUFFER,h.__webglUV2Buffer),c.bufferData(c.ARRAY_BUFFER,ca,j));na&&(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,P,j),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,T,j));z>0&&(c.bindBuffer(c.ARRAY_BUFFER,
+h.__webglSkinVertexABuffer),c.bufferData(c.ARRAY_BUFFER,X,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),c.bufferData(c.ARRAY_BUFFER,Y,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),c.bufferData(c.ARRAY_BUFFER,Z,j),c.bindBuffer(c.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),c.bufferData(c.ARRAY_BUFFER,$,j));i.dynamic||(delete h.__inittedArrays,delete h.__colorArray,delete h.__normalArray,delete h.__tangentArray,delete h.__uvArray,delete h.__uv2Array,delete h.__faceArray,delete h.__vertexArray,
+delete h.__lineArray,delete h.__skinVertexAArray,delete h.__skinVertexBArray,delete h.__skinIndexArray,delete h.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;fa(g)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=c.DYNAMIC_DRAW;w=b.vertices;h=b.colors;v=w.length;i=h.length;A=b.__vertexArray;j=b.__colorArray;E=b.__dirtyColors;if(b.__dirtyVertices){for(k=
+0;k<v;k++)q=w[k].position,g=k*3,A[g]=q.x,A[g+1]=q.y,A[g+2]=q.z;c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,A,e)}if(E){for(k=0;k<i;k++)color=h[k],g=k*3,j[g]=color.r,j[g+1]=color.g,j[g+2]=color.b;c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,j,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.Line){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=c.DYNAMIC_DRAW;w=b.vertices;h=b.colors;v=w.length;i=h.length;
+A=b.__vertexArray;j=b.__colorArray;E=b.__dirtyColors;if(b.__dirtyVertices){for(k=0;k<v;k++)q=w[k].position,g=k*3,A[g]=q.x,A[g+1]=q.y,A[g+2]=q.z;c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,A,e)}if(E){for(k=0;k<i;k++)color=h[k],g=k*3,j[g]=color.r,j[g+1]=color.g,j[g+2]=color.b;c.bindBuffer(c.ARRAY_BUFFER,b.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,j,e)}}f.__dirtyVertices=!1;f.__dirtyColors=!1}else if(b instanceof THREE.ParticleSystem)f=b.geometry,h=ta(f),(f.__dirtyVertices||
+f.__dirtyColors||b.sortParticles||h)&&d(f,c.DYNAMIC_DRAW,b),f.__dirtyVertices=!1,f.__dirtyColors=!1,fa(f)}function w(b,c){var d;for(d=b.length-1;d>=0;d--)b[d].object==c&&b.splice(d,1)}function P(b){function c(b){var f=[];d=0;for(e=b.length;d<e;d++)b[d]==void 0?f.push("undefined"):f.push(b[d].id);return f.join("_")}var d,e,f,h,g,i,j,k,p={},n=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(h=b.faces.length;f<h;f++)g=b.faces[f],i=g.materials,j=c(i),p[j]==void 0&&(p[j]={hash:j,
+counter:0}),k=p[j].hash+"_"+p[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:n}),g=g instanceof THREE.Face3?3:4,b.geometryGroups[k].vertices+g>65535&&(p[j].counter+=1,k=p[j].hash+"_"+p[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:n})),b.geometryGroups[k].faces.push(f),b.geometryGroups[k].vertices+=g}function J(b,c,d){b.push({buffer:c,object:d,opaque:{list:[],count:0},transparent:{list:[],
+count:0}})}function M(b){if(b!=da){switch(b){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD),c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}da=b}}function Q(b,d,e){(e.width&
+e.width-1)==0&&(e.height&e.height-1)==0?(c.texParameteri(b,c.TEXTURE_WRAP_S,N(d.wrapS)),c.texParameteri(b,c.TEXTURE_WRAP_T,N(d.wrapT)),c.texParameteri(b,c.TEXTURE_MAG_FILTER,N(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,N(d.minFilter)),c.generateMipmap(b)):(c.texParameteri(b,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_MAG_FILTER,va(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,va(d.minFilter)))}function ra(b,d){if(b.needsUpdate){if(!b.__webglInit)b.__webglTexture=
+c.createTexture(),b.__webglInit=!0;c.bindTexture(c.TEXTURE_2D,b.__webglTexture);b.image.data?c.texImage2D(c.TEXTURE_2D,0,N(b.format),b.image.width,b.image.height,0,N(b.format),c.UNSIGNED_BYTE,b.image.data):c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b.image);Q(c.TEXTURE_2D,b,b.image);c.bindTexture(c.TEXTURE_2D,null);b.needsUpdate=!1}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,b.__webglTexture)}function ka(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=
+!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=c.createFramebuffer();b.__webglRenderbuffer=c.createRenderbuffer();b.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,b.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,N(b.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,N(b.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,N(b.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,N(b.minFilter));c.texImage2D(c.TEXTURE_2D,0,N(b.format),
+b.width,b.height,0,N(b.format),N(b.type),null);c.bindRenderbuffer(c.RENDERBUFFER,b.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,b.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,
+c.DEPTH_STENCIL,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,b.width,b.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var d,e;b?(d=b.__webglFramebuffer,e=b.width,b=b.height):(d=null,e=la,b=qa);d!=pa&&(c.bindFramebuffer(c.FRAMEBUFFER,d),c.viewport(Ha,Ia,e,b),pa=d)}function aa(b,d){var e;b=="fragment"?e=c.createShader(c.FRAGMENT_SHADER):
+b=="vertex"&&(e=c.createShader(c.VERTEX_SHADER));c.shaderSource(e,d);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS))return console.error(c.getShaderInfoLog(e)),console.error(d),null;return e}function va(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function N(b){switch(b){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;
+case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;
+case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var K=this,c,ha=[],R=null,pa=null,L=!0,ca=null,O=null,da=null,T=null,S=null,ua=null,Ga=null,Ha=0,Ia=0,la=0,qa=0,ma=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
+new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],wa=new THREE.Matrix4,Ka=new Float32Array(16),La=new Float32Array(16),Ja=new THREE.Vector4,Ra={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},xa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Pa=b.stencil!==void 0?b.stencil:!0,y=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,Xa=b.antialias!==void 0?b.antialias:!1,sa=b.clearColor!==void 0?new THREE.Color(b.clearColor):
+new THREE.Color(0),Ma=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=xa;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var na,Na=[],b=THREE.ShaderLib.depthRGBA,Va=THREE.UniformsUtils.clone(b.uniforms),Oa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,
+vertexShader:b.vertexShader,uniforms:Va}),Sa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Va,morphTargets:!0});Oa._shadowPass=!0;Sa._shadowPass=!0;try{if(!(c=xa.getContext("experimental-webgl",{antialias:Xa,stencil:Pa,preserveDrawingBuffer:y})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION))}catch(Ya){console.error(Ya)}c.clearColor(0,
+0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(sa.r,sa.g,sa.b,Ma);this.context=c;var Wa=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(Pa){var u={};u.vertices=new Float32Array(12);u.faces=new Uint16Array(6);u.darkness=0.5;u.vertices[0]=-20;u.vertices[1]=-20;u.vertices[2]=-1;u.vertices[3]=20;u.vertices[4]=-20;
+u.vertices[5]=-1;u.vertices[6]=20;u.vertices[7]=20;u.vertices[8]=-1;u.vertices[9]=-20;u.vertices[10]=20;u.vertices[11]=-1;u.faces[0]=0;u.faces[1]=1;u.faces[2]=2;u.faces[3]=0;u.faces[4]=2;u.faces[5]=3;u.vertexBuffer=c.createBuffer();u.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,u.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,u.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,u.faces,c.STATIC_DRAW);u.program=c.createProgram();
+c.attachShader(u.program,aa("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(u.program,aa("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(u.program);u.vertexLocation=c.getAttribLocation(u.program,"position");u.projectionLocation=c.getUniformLocation(u.program,"projectionMatrix");u.darknessLocation=c.getUniformLocation(u.program,"darkness")}var A={};A.vertices=new Float32Array(16);A.faces=new Uint16Array(6);y=0;A.vertices[y++]=-1;A.vertices[y++]=-1;A.vertices[y++]=
+0;A.vertices[y++]=0;A.vertices[y++]=1;A.vertices[y++]=-1;A.vertices[y++]=1;A.vertices[y++]=0;A.vertices[y++]=1;A.vertices[y++]=1;A.vertices[y++]=1;A.vertices[y++]=1;A.vertices[y++]=-1;A.vertices[y++]=1;A.vertices[y++]=0;A.vertices[y++]=1;y=0;A.faces[y++]=0;A.faces[y++]=1;A.faces[y++]=2;A.faces[y++]=0;A.faces[y++]=2;A.faces[y++]=3;A.vertexBuffer=c.createBuffer();A.elementBuffer=c.createBuffer();A.tempTexture=c.createTexture();A.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,A.vertexBuffer);
+c.bufferData(c.ARRAY_BUFFER,A.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,A.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,A.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
+c.NEAREST);c.bindTexture(c.TEXTURE_2D,A.occlusionTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(A.hasVertexTexture=!1,A.program=c.createProgram(),c.attachShader(A.program,
+aa("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),c.attachShader(A.program,aa("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(A.hasVertexTexture=!0,A.program=c.createProgram(),c.attachShader(A.program,aa("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),c.attachShader(A.program,aa("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));c.linkProgram(A.program);A.attributes={};A.uniforms={};A.attributes.vertex=c.getAttribLocation(A.program,"position");A.attributes.uv=
+c.getAttribLocation(A.program,"UV");A.uniforms.renderType=c.getUniformLocation(A.program,"renderType");A.uniforms.map=c.getUniformLocation(A.program,"map");A.uniforms.occlusionMap=c.getUniformLocation(A.program,"occlusionMap");A.uniforms.opacity=c.getUniformLocation(A.program,"opacity");A.uniforms.scale=c.getUniformLocation(A.program,"scale");A.uniforms.rotation=c.getUniformLocation(A.program,"rotation");A.uniforms.screenPosition=c.getUniformLocation(A.program,"screenPosition");var Ua=!1,v={};v.vertices=
+new Float32Array(16);v.faces=new Uint16Array(6);y=0;v.vertices[y++]=-1;v.vertices[y++]=-1;v.vertices[y++]=0;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=-1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=1;v.vertices[y++]=0;v.vertices[y++]=-1;v.vertices[y++]=1;v.vertices[y++]=0;y=v.vertices[y++]=0;v.faces[y++]=0;v.faces[y++]=1;v.faces[y++]=2;v.faces[y++]=0;v.faces[y++]=2;v.faces[y++]=3;v.vertexBuffer=c.createBuffer();v.elementBuffer=c.createBuffer();
+c.bindBuffer(c.ARRAY_BUFFER,v.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,v.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,v.faces,c.STATIC_DRAW);v.program=c.createProgram();c.attachShader(v.program,aa("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(v.program,aa("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(v.program);v.attributes={};v.uniforms={};v.attributes.position=c.getAttribLocation(v.program,"position");
+v.attributes.uv=c.getAttribLocation(v.program,"uv");v.uniforms.uvOffset=c.getUniformLocation(v.program,"uvOffset");v.uniforms.uvScale=c.getUniformLocation(v.program,"uvScale");v.uniforms.rotation=c.getUniformLocation(v.program,"rotation");v.uniforms.scale=c.getUniformLocation(v.program,"scale");v.uniforms.alignment=c.getUniformLocation(v.program,"alignment");v.uniforms.map=c.getUniformLocation(v.program,"map");v.uniforms.opacity=c.getUniformLocation(v.program,"opacity");v.uniforms.useScreenCoordinates=
+c.getUniformLocation(v.program,"useScreenCoordinates");v.uniforms.affectedByDistance=c.getUniformLocation(v.program,"affectedByDistance");v.uniforms.screenPosition=c.getUniformLocation(v.program,"screenPosition");v.uniforms.modelViewMatrix=c.getUniformLocation(v.program,"modelViewMatrix");v.uniforms.projectionMatrix=c.getUniformLocation(v.program,"projectionMatrix");var Ta=!1;this.setSize=function(b,c){xa.width=b;xa.height=c;this.setViewport(0,0,xa.width,xa.height)};this.setViewport=function(b,d,
+e,f){Ha=b;Ia=d;la=e;qa=f;c.viewport(Ha,Ia,la,qa)};this.setScissor=function(b,d,e,f){c.scissor(b,d,e,f)};this.enableScissorTest=function(b){b?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){L=b;c.depthMask(b)};this.setClearColorHex=function(b,d){sa.setHex(b);Ma=d;c.clearColor(sa.r,sa.g,sa.b,Ma)};this.setClearColor=function(b,d){sa.copy(b);Ma=d;c.clearColor(sa.r,sa.g,sa.b,Ma)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};
+this.setStencilShadowDarkness=function(b){u.darkness=b};this.getContext=function(){return c};this.initMaterial=function(b,d,e,f){var h,g,i;b instanceof THREE.MeshDepthMaterial?i="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?i="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?i="normal":b instanceof THREE.MeshBasicMaterial?i="basic":b instanceof THREE.MeshLambertMaterial?i="lambert":b instanceof THREE.MeshPhongMaterial?i="phong":b instanceof THREE.LineBasicMaterial?i="basic":b instanceof
+THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];b.uniforms=THREE.UniformsUtils.clone(j.uniforms);b.vertexShader=j.vertexShader;b.fragmentShader=j.fragmentShader}var k,n,p;k=p=j=0;for(n=d.length;k<n;k++)g=d[k],g instanceof THREE.SpotLight&&p++,g instanceof THREE.DirectionalLight&&p++,g instanceof THREE.PointLight&&j++;j+p<=4?k=p:(k=Math.ceil(4*p/(j+p)),j=4-k);g={directional:k,point:j};j=p=0;for(k=d.length;j<k;j++)n=d[j],n instanceof THREE.SpotLight&&n.castShadow&&p++;
+var q=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)q=f.bones.length;var o;a:{k=b.fragmentShader;n=b.vertexShader;var j=b.uniforms,d=b.attributes,e={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:e,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:g.directional,maxPointLights:g.point,maxBones:q,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,
+shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:p,alphaTest:b.alphaTest},r,f=[];i?f.push(i):(f.push(k),f.push(n));for(r in e)f.push(r),f.push(e[r]);i=f.join();r=0;for(f=ha.length;r<f;r++)if(ha[r].code==i){o=ha[r].program;break a}r=c.createProgram();f=[Wa?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,"#define MAX_BONES "+e.maxBones,e.map?"#define USE_MAP":"",e.envMap?
+"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
 g=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+e.maxDirLights,"#define MAX_POINT_LIGHTS "+e.maxPointLights,"#define MAX_SHADOWS "+e.maxShadows,e.alphaTest?"#define ALPHATEST "+e.alphaTest:"",e.fog?"#define USE_FOG":"",e.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.lightMap?"#define USE_LIGHTMAP":"",e.vertexColors?"#define USE_COLOR":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapSoft?"#define SHADOWMAP_SOFT":
 "",e.shadowMapSoft?"#define SHADOWMAP_WIDTH "+e.shadowMapWidth.toFixed(1):"",e.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+e.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");c.attachShader(r,aa("fragment",g+k));c.attachShader(r,aa("vertex",f+n));c.linkProgram(r);c.getProgramParameter(r,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(r,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");r.uniforms=
 {};r.attributes={};var t,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(t in j)f.push(t);t=f;f=0;for(j=t.length;f<j;f++)k=t[f],r.uniforms[k]=c.getUniformLocation(r,k);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(t=0;t<e.maxMorphTargets;t++)f.push("morphTarget"+t);for(o in d)f.push(o);o=f;t=0;for(d=o.length;t<d;t++)e=

+ 1 - 0
examples/canvas_particles_sprites.html

@@ -60,6 +60,7 @@
 				renderer = new THREE.CanvasRenderer();
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.sortElements = false;
+				renderer.setClearColorHex( 0x0000ff, 0.25 );
 				container.appendChild( renderer.domElement );
 
 				stats = new Stats();

+ 19 - 16
src/renderers/CanvasRenderer.js

@@ -38,7 +38,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 	_color2 = new THREE.Color( 0x000000 ),
 	_color3 = new THREE.Color( 0x000000 ),
 	_color4 = new THREE.Color( 0x000000 ),
-	
+
 	_patterns = [],
 
 	_near, _far,
@@ -98,8 +98,8 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		_canvasWidth = width;
 		_canvasHeight = height;
-		_canvasWidthHalf = _canvasWidth / 2;
-		_canvasHeightHalf = _canvasHeight / 2;
+		_canvasWidthHalf = Math.floor( _canvasWidth / 2 );
+		_canvasHeightHalf = Math.floor( _canvasHeight / 2 );
 
 		_canvas.width = _canvasWidth;
 		_canvas.height = _canvasHeight;
@@ -119,7 +119,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 	this.setClearColor = function( color, opacity ) {
 
-		_clearColor = color;
+		_clearColor.copy( color );
 		_clearOpacity = opacity;
 
 		_clearRect.set( - _canvasWidthHalf, - _canvasHeightHalf, _canvasWidthHalf, _canvasHeightHalf );
@@ -141,21 +141,23 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		if ( !_clearRect.isEmpty() ) {
 
-			_clearRect.inflate( 1 );
+			_clearRect.inflate( 2 );
 			_clearRect.minSelf( _clipRect );
 
-			if ( _clearOpacity == 0 ) {
+			if ( _clearOpacity < 1 ) {
+
+				_context.clearRect( Math.floor( _clearRect.getX() ), Math.floor( _clearRect.getY() ), Math.floor( _clearRect.getWidth() ), Math.floor( _clearRect.getHeight() ) );
 
-				_context.clearRect( _clearRect.getX(), _clearRect.getY(), _clearRect.getWidth(), _clearRect.getHeight() );
+			}
 
-			} else {
+			if ( _clearOpacity > 0 ) {
 
 				setBlending( THREE.NormalBlending );
 				setOpacity( 1 );
 
-				setContextFillStyle( 'rgba(' + Math.floor( _clearColor.r * 255 ) + ',' + Math.floor( _clearColor.g * 255 ) + ',' + Math.floor( _clearColor.b * 255 ) + ',' + _clearOpacity + ')' );
+				setFillStyle( 'rgba(' + Math.floor( _clearColor.r * 255 ) + ',' + Math.floor( _clearColor.g * 255 ) + ',' + Math.floor( _clearColor.b * 255 ) + ',' + _clearOpacity + ')' );
 
-				_context.fillRect( _clearRect.getX(), _clearRect.getY(), _clearRect.getWidth(), _clearRect.getHeight() );
+				_context.fillRect( Math.floor( _clearRect.getX() ), Math.floor( _clearRect.getY() ), Math.floor( _clearRect.getWidth() ), Math.floor( _clearRect.getHeight() ) );
 
 			}
 
@@ -163,6 +165,7 @@ THREE.CanvasRenderer = function ( parameters ) {
 
 		}
 
+
 	};
 
 	this.render = function ( scene, camera ) {
@@ -862,22 +865,22 @@ THREE.CanvasRenderer = function ( parameters ) {
 			_context.fill();
 
 		}
-		
+
 		function patternPath( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, texture ) {
 
 			if ( texture.image.width == 0 ) return;
 
 			if ( texture.needsUpdate == true || _patterns[ texture.id ] == undefined ) {
-			
+
 				var repeatX = texture.wrapS == THREE.RepeatWrapping;
 				var repeatY = texture.wrapT == THREE.RepeatWrapping;
-				
+
 				_patterns[ texture.id ] = _context.createPattern( texture.image, repeatX && repeatY ? 'repeat' : repeatX && !repeatY ? 'repeat-x' : !repeatX && repeatY ? 'repeat-y' : 'no-repeat' );
-				
+
 				texture.needsUpdate = false;
-				
+
 			}
-			
+
 			setFillStyle( _patterns[ texture.id ] );
 
 			// http://extremelysatisfactorytotalitarianism.com/blog/?p=2120