Explorar o código

WebGLRenderer now logs some GL information (I think it may be handy).
Stencil and Sprite examples now using RequestAnimationFrame.

Mr.doob %!s(int64=14) %!d(string=hai) anos
pai
achega
b2d39cf832

+ 26 - 26
build/Three.js

@@ -48,7 +48,7 @@ c,d)}};THREE.Quaternion=function(b,c,d,f){this.set(b||0,c||0,d||0,f!==undefined?
 THREE.Quaternion.prototype={set:function(b,c,d,f){this.x=b;this.y=c;this.z=d;this.w=f;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,d=b.x*c,f=b.y*c,g=b.z*c;b=Math.cos(f);f=Math.sin(f);c=Math.cos(-g);g=Math.sin(-g);var h=Math.cos(d);d=Math.sin(d);var j=b*c,k=f*g;this.w=j*h-k*d;this.x=j*d+k*h;this.y=f*c*h+b*g*d;this.z=b*g*h-f*c*d;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);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},multiplySelf:function(b){var c=this.x,d=this.y,f=this.z,g=this.w,h=b.x,j=b.y,k=b.z;b=b.w;this.x=c*b+g*h+d*k-f*j;this.y=d*b+g*j+f*h-c*k;this.z=f*b+g*k+c*j-d*h;this.w=g*b-c*h-d*j-f*k;return this},
 multiplyVector3:function(b,c){c||(c=b);var d=b.x,f=b.y,g=b.z,h=this.x,j=this.y,k=this.z,n=this.w,p=n*d+j*g-k*f,o=n*f+k*d-h*g,w=n*g+h*f-j*d;d=-h*d-j*f-k*g;c.x=p*n+d*-h+o*-k-w*-j;c.y=o*n+d*-j+w*-h-p*-k;c.z=w*n+d*-k+p*-j-o*-h;return c}};
-THREE.Quaternion.slerp=function(b,c,d,f){var g=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(g)>=1){d.w=b.w;d.x=b.x;d.y=b.y;d.z=b.z;return d}var h=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.0010){d.w=0.5*(b.w+c.w);d.x=0.5*(b.x+c.x);d.y=0.5*(b.y+c.y);d.z=0.5*(b.z+c.z);return d}g=Math.sin((1-f)*h)/j;f=Math.sin(f*h)/j;d.w=b.w*g+c.w*f;d.x=b.x*g+c.x*f;d.y=b.y*g+c.y*f;d.z=b.z*g+c.z*f;return d};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Quaternion.slerp=function(b,c,d,f){var g=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(g)>=1){d.w=b.w;d.x=b.x;d.y=b.y;d.z=b.z;return d}var h=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.001){d.w=0.5*(b.w+c.w);d.x=0.5*(b.x+c.x);d.y=0.5*(b.y+c.y);d.z=0.5*(b.z+c.z);return d}g=Math.sin((1-f)*h)/j;f=Math.sin(f*h)/j;d.w=b.w*g+c.w*f;d.x=b.x*g+c.x*f;d.y=b.y*g+c.y*f;d.z=b.z*g+c.z*f;return d};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
 THREE.Face3=function(b,c,d,f,g,h){this.a=b;this.b=c;this.c=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=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
 THREE.Face4=function(b,c,d,f,g,h,j){this.a=b;this.b=c;this.c=d;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)};
 THREE.UV.prototype={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};
@@ -265,8 +265,8 @@ xa.darkness);e.bindBuffer(e.ARRAY_BUFFER,xa.vertexBuffer);e.vertexAttribPointer(
 I){e.disable(e.DEPTH_TEST);I=!1}J(z.blending);R(z.map,0);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(X)}function G(m,C){var x,u,z=m.__webglLensFlares.length,K,M,E,P=new THREE.Vector3,F=ja/ia,N=ia*0.5,I=ja*0.5,Y=16/ja,U=[Y*F,Y],ya=[1,1,0],wa=[1,1],ra=fa.uniforms;x=fa.attributes;e.useProgram(fa.program);Ca=fa.program;ga="";e.uniform1i(ra.occlusionMap,0);e.uniform1i(ra.map,1);e.bindBuffer(e.ARRAY_BUFFER,fa.vertexBuffer);e.vertexAttribPointer(x.vertex,
 2,e.FLOAT,!1,16,0);e.vertexAttribPointer(x.uv,2,e.FLOAT,!1,16,8);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,fa.elementBuffer);e.disable(e.CULL_FACE);e.depthMask(!1);e.activeTexture(e.TEXTURE0);e.bindTexture(e.TEXTURE_2D,fa.occlusionTexture);e.activeTexture(e.TEXTURE1);for(u=0;u<z;u++){x=m.__webglLensFlares[u].object;P.set(x.matrixWorld.n14,x.matrixWorld.n24,x.matrixWorld.n34);C.matrixWorldInverse.multiplyVector3(P);C.projectionMatrix.multiplyVector3(P);ya[0]=P.x;ya[1]=P.y;ya[2]=P.z;wa[0]=ya[0]*N+N;wa[1]=
 ya[1]*I+I;if(fa.hasVertexTexture||wa[0]>0&&wa[0]<ia&&wa[1]>0&&wa[1]<ja){e.bindTexture(e.TEXTURE_2D,fa.tempTexture);e.copyTexImage2D(e.TEXTURE_2D,0,e.RGB,wa[0]-8,wa[1]-8,16,16,0);e.uniform1i(ra.renderType,0);e.uniform2fv(ra.scale,U);e.uniform3fv(ra.screenPosition,ya);e.disable(e.BLEND);e.enable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);e.bindTexture(e.TEXTURE_2D,fa.occlusionTexture);e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,wa[0]-8,wa[1]-8,16,16,0);e.uniform1i(ra.renderType,1);e.disable(e.DEPTH_TEST);
-e.bindTexture(e.TEXTURE_2D,fa.tempTexture);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);x.positionScreen.x=ya[0];x.positionScreen.y=ya[1];x.positionScreen.z=ya[2];x.customUpdateCallback?x.customUpdateCallback(x):x.updateLensFlares();e.uniform1i(ra.renderType,2);e.enable(e.BLEND);K=0;for(M=x.lensFlares.length;K<M;K++){E=x.lensFlares[K];if(E.opacity>0.0010&&E.scale>0.0010){ya[0]=E.x;ya[1]=E.y;ya[2]=E.z;Y=E.size*E.scale/ja;U[0]=Y*F;U[1]=Y;e.uniform3fv(ra.screenPosition,ya);e.uniform2fv(ra.scale,
-U);e.uniform1f(ra.rotation,E.rotation);e.uniform1f(ra.opacity,E.opacity);J(E.blending);R(E.texture,1);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(X)}function H(m,C){m._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(m._modelViewMatrix).transposeIntoArray(m._normalMatrixArray)}function L(m){var C,x,u,z,K;if(m instanceof THREE.Mesh){x=m.geometry;for(C in x.geometryGroups){u=
+e.bindTexture(e.TEXTURE_2D,fa.tempTexture);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);x.positionScreen.x=ya[0];x.positionScreen.y=ya[1];x.positionScreen.z=ya[2];x.customUpdateCallback?x.customUpdateCallback(x):x.updateLensFlares();e.uniform1i(ra.renderType,2);e.enable(e.BLEND);K=0;for(M=x.lensFlares.length;K<M;K++){E=x.lensFlares[K];if(E.opacity>0.001&&E.scale>0.001){ya[0]=E.x;ya[1]=E.y;ya[2]=E.z;Y=E.size*E.scale/ja;U[0]=Y*F;U[1]=Y;e.uniform3fv(ra.screenPosition,ya);e.uniform2fv(ra.scale,U);
+e.uniform1f(ra.rotation,E.rotation);e.uniform1f(ra.opacity,E.opacity);J(E.blending);R(E.texture,1);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(X)}function H(m,C){m._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(m._modelViewMatrix).transposeIntoArray(m._normalMatrixArray)}function L(m){var C,x,u,z,K;if(m instanceof THREE.Mesh){x=m.geometry;for(C in x.geometryGroups){u=
 x.geometryGroups[C];K=!1;for(z in u.__webglCustomAttributes)if(u.__webglCustomAttributes[z].needsUpdate){K=!0;break}if(x.__dirtyVertices||x.__dirtyMorphTargets||x.__dirtyElements||x.__dirtyUvs||x.__dirtyNormals||x.__dirtyColors||x.__dirtyTangents||K){K=e.DYNAMIC_DRAW;var M=void 0,E=void 0,P=void 0,F=void 0;P=void 0;var N=void 0,I=void 0,Y=void 0,U=void 0,ya=void 0,wa=void 0,ra=void 0,Na=void 0,Sa=void 0,Ka=void 0,Ja=void 0,Ia=void 0,Wa=void 0;I=void 0;Y=void 0;F=void 0;U=void 0;F=void 0;var D=void 0,
 da=void 0;I=void 0;D=void 0;da=void 0;var t=void 0,bb=void 0;D=void 0;da=void 0;t=void 0;bb=void 0;D=void 0;da=void 0;t=void 0;bb=void 0;D=void 0;da=void 0;t=void 0;F=void 0;U=void 0;N=void 0;P=void 0;P=void 0;D=void 0;da=void 0;t=void 0;var eb=void 0,Ta=0,Qa=0,hb=0,gb=0,cb=0,fb=0,sa=0,Va=0,Pa=0,T=0,Xa=0;da=D=0;var La=u.__vertexArray,W=u.__uvArray,za=u.__uv2Array,na=u.__normalArray,aa=u.__tangentArray,Ba=u.__colorArray,qa=u.__skinVertexAArray,ha=u.__skinVertexBArray,Q=u.__skinIndexArray,Ea=u.__skinWeightArray,
 ib=u.__morphTargetsArrays,Ya=u.__webglCustomAttributes;t=void 0;var Za=u.__faceArray,db=u.__lineArray,jb=u.__needsSmoothNormals;wa=u.__vertexColorType;ya=u.__uvType;ra=u.__normalType;var Ua=m.geometry,sb=Ua.__dirtyVertices,tb=Ua.__dirtyElements,rb=Ua.__dirtyUvs,ub=Ua.__dirtyNormals,vb=Ua.__dirtyTangents,wb=Ua.__dirtyColors,xb=Ua.__dirtyMorphTargets,nb=Ua.vertices,yb=u.faces,Bb=Ua.faces,zb=Ua.faceVertexUvs[0],Ab=Ua.faceVertexUvs[1],ob=Ua.skinVerticesA,pb=Ua.skinVerticesB,qb=Ua.skinIndices,lb=Ua.skinWeights,
@@ -304,26 +304,26 @@ null)}var C,x;if(m){C=m.__webglFramebuffer;x=m.width;m=m.height}else{C=null;x=ia
 default:return e.LINEAR}}function $(m){switch(m){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;
 case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}
 var e,ea=document.createElement("canvas"),Aa=[],Ca=null,Ha=null,X=!0,oa=this,pa=null,ta=null,ga=null,Z=null,la=0,Ga=0,ia=0,ja=0,ua=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ra=new THREE.Matrix4,$a=new Float32Array(16),ab=new Float32Array(16),Oa=new THREE.Vector4,S={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},ca=!0,ma=!0,Da=new THREE.Color(0),Ma=0;if(b){if(b.stencil!=
-undefined)ca=b.stencil;if(b.antialias!==undefined)ma=b.antialias;b.clearColor!==undefined&&Da.setHex(b.clearColor);if(b.clearAlpha!==undefined)Ma=b.clearAlpha}this.maxMorphTargets=8;this.domElement=ea;this.autoClear=!0;this.sortObjects=!0;(function(m,C,x,u){try{if(!(e=ea.getContext("experimental-webgl",{antialias:m,stencil:u})))throw"Error creating WebGL context.";}catch(z){console.error(z)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);
-e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(C.r,C.g,C.b,x)})(ma,Da,Ma,ca);this.context=e;if(ca){var xa={};xa.vertices=new Float32Array(12);xa.faces=new Uint16Array(6);xa.darkness=0.5;xa.vertices[0]=-20;xa.vertices[1]=-20;xa.vertices[2]=-1;xa.vertices[3]=20;xa.vertices[4]=-20;xa.vertices[5]=-1;xa.vertices[6]=20;xa.vertices[7]=20;xa.vertices[8]=-1;xa.vertices[9]=-20;xa.vertices[10]=20;xa.vertices[11]=-1;xa.faces[0]=
-0;xa.faces[1]=1;xa.faces[2]=2;xa.faces[3]=0;xa.faces[4]=2;xa.faces[5]=3;xa.vertexBuffer=e.createBuffer();xa.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,xa.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,xa.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,xa.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,xa.faces,e.STATIC_DRAW);xa.program=e.createProgram();e.attachShader(xa.program,ka("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(xa.program,ka("vertex",
-THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(xa.program);xa.vertexLocation=e.getAttribLocation(xa.program,"position");xa.projectionLocation=e.getUniformLocation(xa.program,"projectionMatrix");xa.darknessLocation=e.getUniformLocation(xa.program,"darkness")}var fa={};fa.vertices=new Float32Array(16);fa.faces=new Uint16Array(6);b=0;fa.vertices[b++]=-1;fa.vertices[b++]=-1;fa.vertices[b++]=0;fa.vertices[b++]=0;fa.vertices[b++]=1;fa.vertices[b++]=-1;fa.vertices[b++]=1;fa.vertices[b++]=0;fa.vertices[b++]=
-1;fa.vertices[b++]=1;fa.vertices[b++]=1;fa.vertices[b++]=1;fa.vertices[b++]=-1;fa.vertices[b++]=1;fa.vertices[b++]=0;fa.vertices[b++]=1;b=0;fa.faces[b++]=0;fa.faces[b++]=1;fa.faces[b++]=2;fa.faces[b++]=0;fa.faces[b++]=2;fa.faces[b++]=3;fa.vertexBuffer=e.createBuffer();fa.elementBuffer=e.createBuffer();fa.tempTexture=e.createTexture();fa.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,fa.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,fa.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,
-fa.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,fa.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,fa.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.bindTexture(e.TEXTURE_2D,fa.occlusionTexture);e.texImage2D(e.TEXTURE_2D,
-0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);if(e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){fa.hasVertexTexture=!1;fa.program=e.createProgram();e.attachShader(fa.program,ka("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(fa.program,
-ka("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{fa.hasVertexTexture=!0;fa.program=e.createProgram();e.attachShader(fa.program,ka("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));e.attachShader(fa.program,ka("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(fa.program);fa.attributes={};fa.uniforms={};fa.attributes.vertex=e.getAttribLocation(fa.program,"position");fa.attributes.uv=e.getAttribLocation(fa.program,"UV");fa.uniforms.renderType=e.getUniformLocation(fa.program,
-"renderType");fa.uniforms.map=e.getUniformLocation(fa.program,"map");fa.uniforms.occlusionMap=e.getUniformLocation(fa.program,"occlusionMap");fa.uniforms.opacity=e.getUniformLocation(fa.program,"opacity");fa.uniforms.scale=e.getUniformLocation(fa.program,"scale");fa.uniforms.rotation=e.getUniformLocation(fa.program,"rotation");fa.uniforms.screenPosition=e.getUniformLocation(fa.program,"screenPosition");e.enableVertexAttribArray(fa.attributes.vertex);e.enableVertexAttribArray(fa.attributes.uv);_sprite=
-{};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=
-1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=e.createBuffer();_sprite.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,_sprite.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,_sprite.faces,e.STATIC_DRAW);_sprite.program=e.createProgram();e.attachShader(_sprite.program,ka("fragment",THREE.ShaderLib.sprite.fragmentShader));
-e.attachShader(_sprite.program,ka("vertex",THREE.ShaderLib.sprite.vertexShader));e.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=e.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=e.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=e.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=e.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=e.getUniformLocation(_sprite.program,
-"rotation");_sprite.uniforms.scale=e.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=e.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=e.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=e.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=e.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=e.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=
-e.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=e.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=e.getUniformLocation(_sprite.program,"projectionMatrix");e.enableVertexAttribArray(_sprite.attributes.position);e.enableVertexAttribArray(_sprite.attributes.uv);this.setSize=function(m,C){ea.width=m;ea.height=C;this.setViewport(0,0,ea.width,ea.height)};this.setViewport=function(m,C,x,u){la=m;Ga=C;ia=x;ja=u;e.viewport(la,Ga,
-ia,ja)};this.setScissor=function(m,C,x,u){e.scissor(m,C,x,u)};this.enableScissorTest=function(m){m?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(m){X=m;e.depthMask(m)};this.setClearColorHex=function(m,C){var x=new THREE.Color(m);e.clearColor(x.r,x.g,x.b,C)};this.setClearColor=function(m,C){e.clearColor(m.r,m.g,m.b,C)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(m){xa.darkness=
-m};this.initMaterial=function(m,C,x,u){var z,K,M;if(m instanceof THREE.MeshDepthMaterial)M="depth";else if(m instanceof THREE.ShadowVolumeDynamicMaterial)M="shadowVolumeDynamic";else if(m instanceof THREE.MeshNormalMaterial)M="normal";else if(m instanceof THREE.MeshBasicMaterial)M="basic";else if(m instanceof THREE.MeshLambertMaterial)M="lambert";else if(m instanceof THREE.MeshPhongMaterial)M="phong";else if(m instanceof THREE.LineBasicMaterial)M="basic";else m instanceof THREE.ParticleBasicMaterial&&
-(M="particle_basic");if(M){var E=THREE.ShaderLib[M];m.uniforms=Uniforms.clone(E.uniforms);m.vertexShader=E.vertexShader;m.fragmentShader=E.fragmentShader}var P,F,N;P=N=E=0;for(F=C.length;P<F;P++){K=C[P];K instanceof THREE.DirectionalLight&&N++;K instanceof THREE.PointLight&&E++}if(E+N<=4)C=N;else{C=Math.ceil(4*N/(E+N));E=4-C}K={directional:C,point:E};N=50;if(u!==undefined&&u instanceof THREE.SkinnedMesh)N=u.bones.length;var I;a:{P=m.fragmentShader;F=m.vertexShader;E=m.uniforms;C=m.attributes;x={map:!!m.map,
-envMap:!!m.envMap,lightMap:!!m.lightMap,vertexColors:m.vertexColors,fog:x,sizeAttenuation:m.sizeAttenuation,skinning:m.skinning,morphTargets:m.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:K.directional,maxPointLights:K.point,maxBones:N};var Y;K=[];if(M)K.push(M);else{K.push(P);K.push(F)}for(Y in x){K.push(Y);K.push(x[Y])}M=K.join();Y=0;for(K=Aa.length;Y<K;Y++)if(Aa[Y].code==M){I=Aa[Y].program;break a}Y=e.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif",
-"#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.fog?"#define USE_FOG":"",x.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",x.map?"#define USE_MAP":"",x.envMap?"#define USE_ENVMAP":"",x.lightMap?"#define USE_LIGHTMAP":"",x.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,
-"#define MAX_POINT_LIGHTS "+x.maxPointLights,"#define MAX_BONES "+x.maxBones,x.map?"#define USE_MAP":"",x.envMap?"#define USE_ENVMAP":"",x.lightMap?"#define USE_LIGHTMAP":"",x.vertexColors?"#define USE_COLOR":"",x.skinning?"#define USE_SKINNING":"",x.morphTargets?"#define USE_MORPHTARGETS":"",x.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");
+undefined)ca=b.stencil;if(b.antialias!==undefined)ma=b.antialias;b.clearColor!==undefined&&Da.setHex(b.clearColor);if(b.clearAlpha!==undefined)Ma=b.clearAlpha}this.maxMorphTargets=8;this.domElement=ea;this.autoClear=!0;this.sortObjects=!0;(function(m,C,x,u){try{if(!(e=ea.getContext("experimental-webgl",{antialias:m,stencil:u})))throw"Error creating WebGL context.";}catch(z){console.error(z)}console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+
+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION));e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(C.r,C.g,C.b,x)})(ma,Da,Ma,ca);this.context=e;if(ca){var xa={};xa.vertices=new Float32Array(12);xa.faces=new Uint16Array(6);xa.darkness=0.5;xa.vertices[0]=-20;xa.vertices[1]=-20;xa.vertices[2]=-1;xa.vertices[3]=
+20;xa.vertices[4]=-20;xa.vertices[5]=-1;xa.vertices[6]=20;xa.vertices[7]=20;xa.vertices[8]=-1;xa.vertices[9]=-20;xa.vertices[10]=20;xa.vertices[11]=-1;xa.faces[0]=0;xa.faces[1]=1;xa.faces[2]=2;xa.faces[3]=0;xa.faces[4]=2;xa.faces[5]=3;xa.vertexBuffer=e.createBuffer();xa.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,xa.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,xa.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,xa.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,xa.faces,
+e.STATIC_DRAW);xa.program=e.createProgram();e.attachShader(xa.program,ka("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(xa.program,ka("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(xa.program);xa.vertexLocation=e.getAttribLocation(xa.program,"position");xa.projectionLocation=e.getUniformLocation(xa.program,"projectionMatrix");xa.darknessLocation=e.getUniformLocation(xa.program,"darkness")}var fa={};fa.vertices=new Float32Array(16);fa.faces=new Uint16Array(6);
+b=0;fa.vertices[b++]=-1;fa.vertices[b++]=-1;fa.vertices[b++]=0;fa.vertices[b++]=0;fa.vertices[b++]=1;fa.vertices[b++]=-1;fa.vertices[b++]=1;fa.vertices[b++]=0;fa.vertices[b++]=1;fa.vertices[b++]=1;fa.vertices[b++]=1;fa.vertices[b++]=1;fa.vertices[b++]=-1;fa.vertices[b++]=1;fa.vertices[b++]=0;fa.vertices[b++]=1;b=0;fa.faces[b++]=0;fa.faces[b++]=1;fa.faces[b++]=2;fa.faces[b++]=0;fa.faces[b++]=2;fa.faces[b++]=3;fa.vertexBuffer=e.createBuffer();fa.elementBuffer=e.createBuffer();fa.tempTexture=e.createTexture();
+fa.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,fa.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,fa.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,fa.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,fa.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,fa.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,
+e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.bindTexture(e.TEXTURE_2D,fa.occlusionTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);if(e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=
+0){fa.hasVertexTexture=!1;fa.program=e.createProgram();e.attachShader(fa.program,ka("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(fa.program,ka("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{fa.hasVertexTexture=!0;fa.program=e.createProgram();e.attachShader(fa.program,ka("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));e.attachShader(fa.program,ka("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(fa.program);fa.attributes=
+{};fa.uniforms={};fa.attributes.vertex=e.getAttribLocation(fa.program,"position");fa.attributes.uv=e.getAttribLocation(fa.program,"UV");fa.uniforms.renderType=e.getUniformLocation(fa.program,"renderType");fa.uniforms.map=e.getUniformLocation(fa.program,"map");fa.uniforms.occlusionMap=e.getUniformLocation(fa.program,"occlusionMap");fa.uniforms.opacity=e.getUniformLocation(fa.program,"opacity");fa.uniforms.scale=e.getUniformLocation(fa.program,"scale");fa.uniforms.rotation=e.getUniformLocation(fa.program,
+"rotation");fa.uniforms.screenPosition=e.getUniformLocation(fa.program,"screenPosition");e.enableVertexAttribArray(fa.attributes.vertex);e.enableVertexAttribArray(fa.attributes.uv);_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=
+1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=e.createBuffer();_sprite.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,_sprite.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);
+e.bufferData(e.ELEMENT_ARRAY_BUFFER,_sprite.faces,e.STATIC_DRAW);_sprite.program=e.createProgram();e.attachShader(_sprite.program,ka("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,ka("vertex",THREE.ShaderLib.sprite.vertexShader));e.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=e.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=e.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=
+e.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=e.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=e.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=e.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=e.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=e.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=e.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=
+e.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=e.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=e.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=e.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=e.getUniformLocation(_sprite.program,"projectionMatrix");e.enableVertexAttribArray(_sprite.attributes.position);e.enableVertexAttribArray(_sprite.attributes.uv);
+this.setSize=function(m,C){ea.width=m;ea.height=C;this.setViewport(0,0,ea.width,ea.height)};this.setViewport=function(m,C,x,u){la=m;Ga=C;ia=x;ja=u;e.viewport(la,Ga,ia,ja)};this.setScissor=function(m,C,x,u){e.scissor(m,C,x,u)};this.enableScissorTest=function(m){m?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(m){X=m;e.depthMask(m)};this.setClearColorHex=function(m,C){var x=new THREE.Color(m);e.clearColor(x.r,x.g,x.b,C)};this.setClearColor=function(m,C){e.clearColor(m.r,
+m.g,m.b,C)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(m){xa.darkness=m};this.initMaterial=function(m,C,x,u){var z,K,M;if(m instanceof THREE.MeshDepthMaterial)M="depth";else if(m instanceof THREE.ShadowVolumeDynamicMaterial)M="shadowVolumeDynamic";else if(m instanceof THREE.MeshNormalMaterial)M="normal";else if(m instanceof THREE.MeshBasicMaterial)M="basic";else if(m instanceof THREE.MeshLambertMaterial)M="lambert";
+else if(m instanceof THREE.MeshPhongMaterial)M="phong";else if(m instanceof THREE.LineBasicMaterial)M="basic";else m instanceof THREE.ParticleBasicMaterial&&(M="particle_basic");if(M){var E=THREE.ShaderLib[M];m.uniforms=Uniforms.clone(E.uniforms);m.vertexShader=E.vertexShader;m.fragmentShader=E.fragmentShader}var P,F,N;P=N=E=0;for(F=C.length;P<F;P++){K=C[P];K instanceof THREE.DirectionalLight&&N++;K instanceof THREE.PointLight&&E++}if(E+N<=4)C=N;else{C=Math.ceil(4*N/(E+N));E=4-C}K={directional:C,
+point:E};N=50;if(u!==undefined&&u instanceof THREE.SkinnedMesh)N=u.bones.length;var I;a:{P=m.fragmentShader;F=m.vertexShader;E=m.uniforms;C=m.attributes;x={map:!!m.map,envMap:!!m.envMap,lightMap:!!m.lightMap,vertexColors:m.vertexColors,fog:x,sizeAttenuation:m.sizeAttenuation,skinning:m.skinning,morphTargets:m.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:K.directional,maxPointLights:K.point,maxBones:N};var Y;K=[];if(M)K.push(M);else{K.push(P);K.push(F)}for(Y in x){K.push(Y);K.push(x[Y])}M=
+K.join();Y=0;for(K=Aa.length;Y<K;Y++)if(Aa[Y].code==M){I=Aa[Y].program;break a}Y=e.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.fog?"#define USE_FOG":"",x.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",x.map?"#define USE_MAP":"",x.envMap?"#define USE_ENVMAP":"",x.lightMap?"#define USE_LIGHTMAP":"",x.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");
+prefix_vertex=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,"#define MAX_BONES "+x.maxBones,x.map?"#define USE_MAP":"",x.envMap?"#define USE_ENVMAP":"",x.lightMap?"#define USE_LIGHTMAP":"",x.vertexColors?"#define USE_COLOR":"",x.skinning?"#define USE_SKINNING":"",x.morphTargets?"#define USE_MORPHTARGETS":"",x.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");
 e.attachShader(Y,ka("fragment",prefix_fragment+P));e.attachShader(Y,ka("vertex",prefix_vertex+F));e.linkProgram(Y);e.getProgramParameter(Y,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(Y,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");Y.uniforms={};Y.attributes={};var U;P=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(U in E)P.push(U);
 U=P;E=0;for(P=U.length;E<P;E++){F=U[E];Y.uniforms[F]=e.getUniformLocation(Y,F)}P=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(U=0;U<x.maxMorphTargets;U++)P.push("morphTarget"+U);for(I in C)P.push(I);I=P;U=0;for(C=I.length;U<C;U++){x=I[U];Y.attributes[x]=e.getAttribLocation(Y,x)}Aa.push({program:Y,code:M});I=Y}m.program=I;I=m.program.attributes;e.enableVertexAttribArray(I.position);I.color>=0&&e.enableVertexAttribArray(I.color);I.normal>=
 0&&e.enableVertexAttribArray(I.normal);I.tangent>=0&&e.enableVertexAttribArray(I.tangent);if(m.skinning&&I.skinVertexA>=0&&I.skinVertexB>=0&&I.skinIndex>=0&&I.skinWeight>=0){e.enableVertexAttribArray(I.skinVertexA);e.enableVertexAttribArray(I.skinVertexB);e.enableVertexAttribArray(I.skinIndex);e.enableVertexAttribArray(I.skinWeight)}for(z in m.attributes)I[z]>=0&&e.enableVertexAttribArray(I[z]);if(m.morphTargets){m.numSupportedMorphTargets=0;if(I.morphTarget0>=0){e.enableVertexAttribArray(I.morphTarget0);
@@ -382,7 +382,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
 fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(b){var c,d,f,g,h=2*Math.ceil(b*3)+1;h>25&&(h=25);g=(h-1)*0.5;d=Array(h);for(c=f=0;c<h;++c){d[c]=Math.exp(-((c-g)*(c-g))/(2*b*b));f+=d[c]}for(c=0;c<h;++c)d[c]/=f;return d}};
-THREE.QuakeCamera=function(b){function c(d,f){return function(){f.apply(d,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;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.lookSpeed!==undefined)this.lookSpeed=
+THREE.QuakeCamera=function(b){function c(d,f){return function(){f.apply(d,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;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.lookSpeed!==undefined)this.lookSpeed=
 b.lookSpeed;if(b.noFly!==undefined)this.noFly=b.noFly;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.autoForward!==undefined)this.autoForward=b.autoForward;if(b.activeLook!==undefined)this.activeLook=b.activeLook;if(b.heightSpeed!==undefined)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==undefined)this.heightCoef=b.heightCoef;if(b.heightMin!==undefined)this.heightMin=b.heightMin;if(b.heightMax!==undefined)this.heightMax=b.heightMax;if(b.constrainVertical!==undefined)this.constrainVertical=
 b.constrainVertical;if(b.verticalMin!==undefined)this.verticalMin=b.verticalMin;if(b.verticalMax!==undefined)this.verticalMax=b.verticalMax;if(b.domElement!==undefined)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.freeze=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(d){d.preventDefault();
 d.stopPropagation();if(this.activeLook)switch(d.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(d){d.preventDefault();d.stopPropagation();if(this.activeLook)switch(d.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(d){this.mouseX=d.clientX-this.windowHalfX;this.mouseY=d.clientY-this.windowHalfY};this.onKeyDown=function(d){switch(d.keyCode){case 38:case 87:this.moveForward=
@@ -393,7 +393,7 @@ this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0
 this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.QuakeCamera.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(p,o,w,y){var v={name:w,fps:0.6,length:y,hierarchy:[]},B,G=o.getControlPointsArray(),H=o.getLength(),L=G.length,V=0;B=L-1;o={parent:-1,keys:[]};o.keys[0]={time:0,pos:G[0],rot:[0,0,0,1],scl:[1,1,1]};o.keys[B]={time:y,pos:G[B],rot:[0,0,0,1],scl:[1,1,1]};for(B=1;B<L-1;B++){V=y*H.chunks[B]/H.total;o.keys[B]={time:V,pos:G[B]}}v.hierarchy[0]=o;THREE.AnimationHandler.add(v);return new THREE.Animation(p,w,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function d(p,o){var w,
 y,v=new THREE.Geometry;for(w=0;w<p.points.length*o;w++){y=w/(p.points.length*o);y=p.getPoint(y);v.vertices[w]=new THREE.Vertex(new THREE.Vector3(y.x,y.y,y.z))}return v}function f(p,o){var w=d(o,10),y=d(o,10),v=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(w,v);particleObj=new THREE.ParticleSystem(y,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);p.addChild(lineObj);particleObj.scale.set(1,1,1);p.addChild(particleObj);y=new Sphere(1,
-16,8);v=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<o.points.length;i++){w=new THREE.Mesh(y,v);w.position.copy(o.points[i]);w.updateMatrix();p.addChild(w)}}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.lookVertical=
+16,8);v=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<o.points.length;i++){w=new THREE.Mesh(y,v);w.position.copy(o.points[i]);w.updateMatrix();p.addChild(w)}}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.lookVertical=
 !0;this.lookHorizontal=!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!==undefined)this.duration=b.duration*1E3;if(b.waypoints!==undefined)this.waypoints=b.waypoints;if(b.useConstantSpeed!==undefined)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==undefined)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==undefined)this.createDebugPath=b.createDebugPath;
 if(b.createDebugDummy!==undefined)this.createDebugDummy=b.createDebugDummy;if(b.lookSpeed!==undefined)this.lookSpeed=b.lookSpeed;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.lookHorizontal!==undefined)this.lookHorizontal=b.lookHorizontal;if(b.verticalAngleMap!==undefined)this.verticalAngleMap=b.verticalAngleMap;if(b.horizontalAngleMap!==undefined)this.horizontalAngleMap=b.horizontalAngleMap;if(b.domElement!==undefined)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,h=Math.PI/180;this.update=function(p,o,w){var y,v;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;y=this.phi%g;this.phi=y>=0?y:y+g;y=this.verticalAngleMap.srcRange;v=this.verticalAngleMap.dstRange;
@@ -410,7 +410,7 @@ THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(w.position.x,w.position.y)/p,0.5
 var Icosahedron=function(b){function c(w,y,v){var B=Math.sqrt(w*w+y*y+v*v);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(w/B,y/B,v/B)))-1}function d(w,y,v,B){B.faces.push(new THREE.Face3(w,y,v))}function f(w,y){var v=g.vertices[w].position,B=g.vertices[y].position;return c((v.x+B.x)/2,(v.y+B.y)/2,(v.z+B.z)/2)}var g=this,h=new THREE.Geometry,j;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);d(0,11,5,h);d(0,5,1,h);d(0,1,7,h);d(0,7,10,h);d(0,10,11,h);d(1,5,9,h);d(5,11,4,h);d(11,10,2,h);d(10,7,6,h);d(7,1,8,h);d(3,9,4,h);d(3,4,2,h);d(3,2,6,h);d(3,6,8,h);d(3,8,9,h);d(4,9,5,h);d(2,4,11,h);d(6,2,10,h);d(8,6,7,h);d(9,8,1,h);for(b=0;b<this.subdivisions;b++){j=new THREE.Geometry;for(var k in h.faces){var n=f(h.faces[k].a,h.faces[k].b),p=f(h.faces[k].b,h.faces[k].c),o=f(h.faces[k].c,h.faces[k].a);d(h.faces[k].a,n,o,j);d(h.faces[k].b,p,n,j);d(h.faces[k].c,
 o,p,j);d(n,p,o,j)}h.faces=j.faces}g.faces=h.faces;delete h;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
-function Lathe(b,c,d){THREE.Geometry.call(this);this.steps=c||12;this.angle=d||2*Math.PI;c=this.angle/this.steps;d=[];for(var f=[],g=[],h=[],j=(new THREE.Matrix4).setRotationZ(c),k=0;k<b.length;k++){this.vertices.push(new THREE.Vertex(b[k]));d[k]=b[k].clone();f[k]=this.vertices.length-1}for(var n=0;n<=this.angle+0.0010;n+=c){for(k=0;k<d.length;k++)if(n<this.angle){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));g[k]=this.vertices.length-1}else g=h;n==0&&(h=f);for(k=
+function Lathe(b,c,d){THREE.Geometry.call(this);this.steps=c||12;this.angle=d||2*Math.PI;c=this.angle/this.steps;d=[];for(var f=[],g=[],h=[],j=(new THREE.Matrix4).setRotationZ(c),k=0;k<b.length;k++){this.vertices.push(new THREE.Vertex(b[k]));d[k]=b[k].clone();f[k]=this.vertices.length-1}for(var n=0;n<=this.angle+0.001;n+=c){for(k=0;k<d.length;k++)if(n<this.angle){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));g[k]=this.vertices.length-1}else g=h;n==0&&(h=f);for(k=
 0;k<f.length-1;k++){this.faces.push(new THREE.Face4(g[k],g[k+1],f[k+1],f[k]));this.faceVertexUvs[0].push([new THREE.UV(1-n/this.angle,k/b.length),new THREE.UV(1-n/this.angle,(k+1)/b.length),new THREE.UV(1-(n-c)/this.angle,(k+1)/b.length),new THREE.UV(1-(n-c)/this.angle,k/b.length)])}f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
 var Plane=function(b,c,d,f){THREE.Geometry.call(this);var g,h=b/2,j=c/2;d=d||1;f=f||1;var k=d+1,n=f+1;b/=d;var p=c/f;for(g=0;g<n;g++)for(c=0;c<k;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-h,-(g*p-j),0)));for(g=0;g<f;g++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+k*g,c+k*(g+1),c+1+k*(g+1),c+1+k*g));this.faceVertexUvs[0].push([new THREE.UV(c/d,g/f),new THREE.UV(c/d,(g+1)/f),new THREE.UV((c+1)/d,(g+1)/f),new THREE.UV((c+1)/d,g/f)])}this.computeCentroids();this.computeFaceNormals()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;

+ 1 - 1
build/custom/ThreeCanvas.js

@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
 THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=e*d;this.w=f*g-i*c;this.x=f*c+i*g;this.y=e*b*g+a*d*c;this.z=a*d*g-e*b*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);if(a==0)this.w=this.z=this.y=this.x=0;else{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,e=this.z,d=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+d*g+c*i-e*f;this.y=c*a+d*f+e*g-b*i;this.z=e*a+d*i+b*f-c*g;this.w=d*a-b*g-c*f-e*i;return this},
 multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,k=h*e+i*c-g*d,n=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+k*-i-n*-f;b.y=k*h+c*-f+n*-g-j*-i;b.z=n*h+c*-i+j*-f-k*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.0010){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);return c}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.001){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);return c}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,e,d,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,e,d,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];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={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};

+ 1 - 1
build/custom/ThreeDOM.js

@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
 THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=e*d;this.w=f*g-i*c;this.x=f*c+i*g;this.y=e*b*g+a*d*c;this.z=a*d*g-e*b*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);if(a==0)this.w=this.z=this.y=this.x=0;else{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,e=this.z,d=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+d*g+c*i-e*f;this.y=c*a+d*f+e*g-b*i;this.z=e*a+d*i+b*f-c*g;this.w=d*a-b*g-c*f-e*i;return this},
 multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,l=h*e+i*c-g*d,m=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+l*-i-m*-f;b.y=l*h+c*-f+m*-g-j*-i;b.z=m*h+c*-i+j*-f-l*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.0010){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);return c}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.001){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);return c}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,e,d,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,e,d,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];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={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};

+ 3 - 3
build/custom/ThreeExtras.js

@@ -15,7 +15,7 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
 fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var f,b,e,c,d=2*Math.ceil(a*3)+1;d>25&&(d=25);c=(d-1)*0.5;b=Array(d);for(f=e=0;f<d;++f){b[f]=Math.exp(-((f-c)*(f-c))/(2*a*a));e+=b[f]}for(f=0;f<d;++f)b[f]/=e;return b}};
-THREE.QuakeCamera=function(a){function f(b,e){return function(){e.apply(b,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;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=
+THREE.QuakeCamera=function(a){function f(b,e){return function(){e.apply(b,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;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=
 a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.activeLook!==undefined)this.activeLook=a.activeLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.constrainVertical!==undefined)this.constrainVertical=
 a.constrainVertical;if(a.verticalMin!==undefined)this.verticalMin=a.verticalMin;if(a.verticalMax!==undefined)this.verticalMax=a.verticalMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.freeze=!1;this.mouseDragOn=!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=
@@ -26,7 +26,7 @@ this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0
 this.onMouseUp),!1);this.domElement.addEventListener("keydown",f(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",f(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.QuakeCamera.prototype.translate=function(a,f){this.matrix.rotateAxis(f);if(this.noFly)f.y=0;this.position.addSelf(f.multiplyScalar(a));this.target.position.addSelf(f.multiplyScalar(a))};
 THREE.PathCamera=function(a){function f(m,k,n,p){var t={name:n,fps:0.6,length:p,hierarchy:[]},w,x=k.getControlPointsArray(),u=k.getLength(),B=x.length,z=0;w=B-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:x[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[w]={time:p,pos:x[w],rot:[0,0,0,1],scl:[1,1,1]};for(w=1;w<B-1;w++){z=p*u.chunks[w]/u.total;k.keys[w]={time:z,pos:x[w]}}t.hierarchy[0]=k;THREE.AnimationHandler.add(t);return new THREE.Animation(m,n,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(m,k){var n,
 p,t=new THREE.Geometry;for(n=0;n<m.points.length*k;n++){p=n/(m.points.length*k);p=m.getPoint(p);t.vertices[n]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return t}function e(m,k){var n=b(k,10),p=b(k,10),t=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(n,t);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);m.addChild(lineObj);particleObj.scale.set(1,1,1);m.addChild(particleObj);p=new Sphere(1,
-16,8);t=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<k.points.length;i++){n=new THREE.Mesh(p,t);n.position.copy(k.points[i]);n.updateMatrix();m.addChild(n)}}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.lookVertical=
+16,8);t=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<k.points.length;i++){n=new THREE.Mesh(p,t);n.position.copy(k.points[i]);n.updateMatrix();m.addChild(n)}}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.lookVertical=
 !0;this.lookHorizontal=!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!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
 if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)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 c=Math.PI*2,d=Math.PI/180;this.update=function(m,k,n){var p,t;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)*d;this.theta=this.lon*d;p=this.phi%c;this.phi=p>=0?p:p+c;p=this.verticalAngleMap.srcRange;t=this.verticalAngleMap.dstRange;
@@ -43,7 +43,7 @@ THREE.Face4&&f.push(new THREE.UV(0.5+Math.atan2(n.position.x,n.position.y)/m,0.5
 var Icosahedron=function(a){function f(n,p,t){var w=Math.sqrt(n*n+p*p+t*t);return c.vertices.push(new THREE.Vertex(new THREE.Vector3(n/w,p/w,t/w)))-1}function b(n,p,t,w){w.faces.push(new THREE.Face3(n,p,t))}function e(n,p){var t=c.vertices[n].position,w=c.vertices[p].position;return f((t.x+w.x)/2,(t.y+w.y)/2,(t.z+w.z)/2)}var c=this,d=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;f(-1,a,0);f(1,a,0);f(-1,-a,0);f(1,-a,0);f(0,-1,a);f(0,1,a);f(0,-1,-a);f(0,
 1,-a);f(a,0,-1);f(a,0,1);f(-a,0,-1);f(-a,0,1);b(0,11,5,d);b(0,5,1,d);b(0,1,7,d);b(0,7,10,d);b(0,10,11,d);b(1,5,9,d);b(5,11,4,d);b(11,10,2,d);b(10,7,6,d);b(7,1,8,d);b(3,9,4,d);b(3,4,2,d);b(3,2,6,d);b(3,6,8,d);b(3,8,9,d);b(4,9,5,d);b(2,4,11,d);b(6,2,10,d);b(8,6,7,d);b(9,8,1,d);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var h in d.faces){var j=e(d.faces[h].a,d.faces[h].b),m=e(d.faces[h].b,d.faces[h].c),k=e(d.faces[h].c,d.faces[h].a);b(d.faces[h].a,j,k,g);b(d.faces[h].b,m,j,g);b(d.faces[h].c,
 k,m,g);b(j,m,k,g)}d.faces=g.faces}c.faces=d.faces;delete d;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
-function Lathe(a,f,b){THREE.Geometry.call(this);this.steps=f||12;this.angle=b||2*Math.PI;f=this.angle/this.steps;b=[];for(var e=[],c=[],d=[],g=(new THREE.Matrix4).setRotationZ(f),h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));b[h]=a[h].clone();e[h]=this.vertices.length-1}for(var j=0;j<=this.angle+0.0010;j+=f){for(h=0;h<b.length;h++)if(j<this.angle){b[h]=g.multiplyVector3(b[h].clone());this.vertices.push(new THREE.Vertex(b[h]));c[h]=this.vertices.length-1}else c=d;j==0&&(d=e);for(h=
+function Lathe(a,f,b){THREE.Geometry.call(this);this.steps=f||12;this.angle=b||2*Math.PI;f=this.angle/this.steps;b=[];for(var e=[],c=[],d=[],g=(new THREE.Matrix4).setRotationZ(f),h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));b[h]=a[h].clone();e[h]=this.vertices.length-1}for(var j=0;j<=this.angle+0.001;j+=f){for(h=0;h<b.length;h++)if(j<this.angle){b[h]=g.multiplyVector3(b[h].clone());this.vertices.push(new THREE.Vertex(b[h]));c[h]=this.vertices.length-1}else c=d;j==0&&(d=e);for(h=
 0;h<e.length-1;h++){this.faces.push(new THREE.Face4(c[h],c[h+1],e[h+1],e[h]));this.faceVertexUvs[0].push([new THREE.UV(1-j/this.angle,h/a.length),new THREE.UV(1-j/this.angle,(h+1)/a.length),new THREE.UV(1-(j-f)/this.angle,(h+1)/a.length),new THREE.UV(1-(j-f)/this.angle,h/a.length)])}e=c;c=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
 var Plane=function(a,f,b,e){THREE.Geometry.call(this);var c,d=a/2,g=f/2;b=b||1;e=e||1;var h=b+1,j=e+1;a/=b;var m=f/e;for(c=0;c<j;c++)for(f=0;f<h;f++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(f*a-d,-(c*m-g),0)));for(c=0;c<e;c++)for(f=0;f<b;f++){this.faces.push(new THREE.Face4(f+h*c,f+h*(c+1),f+1+h*(c+1),f+1+h*c));this.faceVertexUvs[0].push([new THREE.UV(f/b,c/e),new THREE.UV(f/b,(c+1)/e),new THREE.UV((f+1)/b,(c+1)/e),new THREE.UV((f+1)/b,c/e)])}this.computeCentroids();this.computeFaceNormals()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;

+ 1 - 1
build/custom/ThreeSVG.js

@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
 THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=e*d;this.w=f*g-i*c;this.x=f*c+i*g;this.y=e*b*g+a*d*c;this.z=a*d*g-e*b*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);if(a==0)this.w=this.z=this.y=this.x=0;else{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,e=this.z,d=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+d*g+c*i-e*f;this.y=c*a+d*f+e*g-b*i;this.z=e*a+d*i+b*f-c*g;this.w=d*a-b*g-c*f-e*i;return this},
 multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,l=h*e+i*c-g*d,m=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+l*-i-m*-f;b.y=l*h+c*-f+m*-g-j*-i;b.z=m*h+c*-i+j*-f-l*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.0010){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);return c}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.001){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);return c}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,e,d,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,e,d,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];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={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};

+ 49 - 48
build/custom/ThreeWebGL.js

@@ -48,7 +48,7 @@ d,e)}};THREE.Quaternion=function(b,d,e,h){this.set(b||0,d||0,e||0,h!==undefined?
 THREE.Quaternion.prototype={set:function(b,d,e,h){this.x=b;this.y=d;this.z=e;this.w=h;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,e=b.x*d,h=b.y*d,g=b.z*d;b=Math.cos(h);h=Math.sin(h);d=Math.cos(-g);g=Math.sin(-g);var m=Math.cos(e);e=Math.sin(e);var j=b*d,p=h*g;this.w=j*m-p*e;this.x=j*e+p*m;this.y=h*d*m+b*g*e;this.z=b*g*m-h*d*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);if(b==0)this.w=this.z=this.y=this.x=0;else{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,h=this.z,g=this.w,m=b.x,j=b.y,p=b.z;b=b.w;this.x=d*b+g*m+e*p-h*j;this.y=e*b+g*j+h*m-d*p;this.z=h*b+g*p+d*j-e*m;this.w=g*b-d*m-e*j-h*p;return this},
 multiplyVector3:function(b,d){d||(d=b);var e=b.x,h=b.y,g=b.z,m=this.x,j=this.y,p=this.z,q=this.w,v=q*e+j*g-p*h,E=q*h+p*e-m*g,G=q*g+m*h-j*e;e=-m*e-j*h-p*g;d.x=v*q+e*-m+E*-p-G*-j;d.y=E*q+e*-j+G*-m-v*-p;d.z=G*q+e*-p+v*-j-E*-m;return d}};
-THREE.Quaternion.slerp=function(b,d,e,h){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var m=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.0010){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);return e}g=Math.sin((1-h)*m)/j;h=Math.sin(h*m)/j;e.w=b.w*g+d.w*h;e.x=b.x*g+d.x*h;e.y=b.y*g+d.y*h;e.z=b.z*g+d.z*h;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Quaternion.slerp=function(b,d,e,h){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var m=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.001){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);return e}g=Math.sin((1-h)*m)/j;h=Math.sin(h*m)/j;e.w=b.w*g+d.w*h;e.x=b.x*g+d.x*h;e.y=b.y*g+d.y*h;e.z=b.z*g+d.z*h;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
 THREE.Face3=function(b,d,e,h,g,m){this.a=b;this.b=d;this.c=e;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=m instanceof Array?m:[m];this.centroid=new THREE.Vector3};
 THREE.Face4=function(b,d,e,h,g,m,j){this.a=b;this.b=d;this.c=e;this.d=h;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=m instanceof THREE.Color?m:new THREE.Color;this.vertexColors=m instanceof Array?m:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
 THREE.UV.prototype={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};
@@ -207,34 +207,34 @@ c.KEEP,c.INCR,c.KEEP);c.stencilOpSeparate(c.FRONT,c.KEEP,c.DECR,c.KEEP);var s,n=
 u;c.uniformMatrix4fv(A.projectionMatrix,!1,Ua);c.uniformMatrix4fv(A.viewMatrix,!1,Ya);c.uniform3fv(A.directionalLightDirection,w)}k.matrixWorld.flattenToArray(k._objectMatrixArray);c.uniformMatrix4fv(A.objectMatrix,!1,k._objectMatrixArray);c.bindBuffer(c.ARRAY_BUFFER,x.__webglVertexBuffer);c.vertexAttribPointer(t.position,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,x.__webglNormalBuffer);c.vertexAttribPointer(t.normal,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webglFaceBuffer);c.cullFace(c.FRONT);
 c.drawElements(c.TRIANGLES,x.__webglFaceCount,c.UNSIGNED_SHORT,0);c.cullFace(c.BACK);c.drawElements(c.TRIANGLES,x.__webglFaceCount,c.UNSIGNED_SHORT,0)}}}c.disable(c.POLYGON_OFFSET_FILL);c.colorMask(!0,!0,!0,!0);c.stencilFunc(c.NOTEQUAL,0,255);c.stencilOp(c.KEEP,c.KEEP,c.KEEP);c.disable(c.DEPTH_TEST);ga="";ra=U.program;c.useProgram(U.program);c.uniformMatrix4fv(U.projectionLocation,!1,Ua);c.uniform1f(U.darknessLocation,U.darkness);c.bindBuffer(c.ARRAY_BUFFER,U.vertexBuffer);c.vertexAttribPointer(U.vertexLocation,
 3,c.FLOAT,!1,0,0);c.enableVertexAttribArray(U.vertexLocation);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.blendEquation(c.FUNC_ADD);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,U.elementBuffer);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.disable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(ta)}function L(f,s){var n,k,o;n=_sprite.attributes;var w=_sprite.uniforms,x=za/ya,u,A=[],t=ya*0.5,y=za*0.5,z=!0;c.useProgram(_sprite.program);ra=_sprite.program;ga="";c.disable(c.CULL_FACE);c.enable(c.BLEND);
-c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.vertexAttribPointer(n.position,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(n.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.uniformMatrix4fv(w.projectionMatrix,!1,Ua);c.activeTexture(c.TEXTURE0);c.uniform1i(w.map,0);n=0;for(k=f.__webglSprites.length;n<k;n++){o=f.__webglSprites[n];if(o.useScreenCoordinates)o.z=-o.position.z;else{o._modelViewMatrix.multiplyToArray(s.matrixWorldInverse,o.matrixWorld,o._modelViewMatrixArray);
-o.z=-o._modelViewMatrix.n34}}f.__webglSprites.sort(I);n=0;for(k=f.__webglSprites.length;n<k;n++){o=f.__webglSprites[n];if(o.material===undefined&&o.map&&o.map.image&&o.map.image.width){if(o.useScreenCoordinates){c.uniform1i(w.useScreenCoordinates,1);c.uniform3f(w.screenPosition,(o.position.x-t)/t,(y-o.position.y)/y,o.position.z)}else{c.uniform1i(w.useScreenCoordinates,0);c.uniform1i(w.affectedByDistance,o.affectedByDistance?1:0);c.uniformMatrix4fv(w.modelViewMatrix,!1,o._modelViewMatrixArray)}u=o.map.image.width/
-(o.affectedByDistance?1:za);A[0]=u*x*o.scale.x;A[1]=u*o.scale.y;c.uniform2f(w.uvScale,o.uvScale.x,o.uvScale.y);c.uniform2f(w.uvOffset,o.uvOffset.x,o.uvOffset.y);c.uniform2f(w.alignment,o.alignment.x,o.alignment.y);c.uniform1f(w.opacity,o.opacity);c.uniform1f(w.rotation,o.rotation);c.uniform2fv(w.scale,A);if(o.mergeWith3D&&!z){c.enable(c.DEPTH_TEST);c.depthMask(!0);z=!0}else if(!o.mergeWith3D&&z){c.disable(c.DEPTH_TEST);c.depthMask(o.blending===THREE.NormalBlending?!0:!1);z=!1}c.depthMask(!0);oa(o.blending);
-K(o.map,0);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ta)}function M(f,s){var n,k,o=f.__webglLensFlares.length,w,x,u,A=new THREE.Vector3,t=za/ya,y=ya*0.5,z=za*0.5,D=16/za,B=[D*t,D],N=[1,1,0],W=[1,1],O=J.uniforms;n=J.attributes;c.useProgram(J.program);ra=J.program;ga="";c.uniform1i(O.occlusionMap,0);c.uniform1i(O.map,1);c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);c.vertexAttribPointer(n.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(n.uv,
-2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,J.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.activeTexture(c.TEXTURE1);for(k=0;k<o;k++){n=f.__webglLensFlares[k].object;A.set(n.matrixWorld.n14,n.matrixWorld.n24,n.matrixWorld.n34);s.matrixWorldInverse.multiplyVector3(A);s.projectionMatrix.multiplyVector3(A);N[0]=A.x;N[1]=A.y;N[2]=A.z;W[0]=N[0]*y+y;W[1]=N[1]*z+z;if(J.hasVertexTexture||W[0]>0&&W[0]<ya&&W[1]>
-0&&W[1]<za){c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGB,W[0]-8,W[1]-8,16,16,0);c.uniform1i(O.renderType,0);c.uniform2fv(O.scale,B);c.uniform3fv(O.screenPosition,N);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,W[0]-8,W[1]-8,16,16,0);c.uniform1i(O.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.drawElements(c.TRIANGLES,
-6,c.UNSIGNED_SHORT,0);n.positionScreen.x=N[0];n.positionScreen.y=N[1];n.positionScreen.z=N[2];n.customUpdateCallback?n.customUpdateCallback(n):n.updateLensFlares();c.uniform1i(O.renderType,2);c.enable(c.BLEND);w=0;for(x=n.lensFlares.length;w<x;w++){u=n.lensFlares[w];if(u.opacity>0.0010&&u.scale>0.0010){N[0]=u.x;N[1]=u.y;N[2]=u.z;D=u.size*u.scale/za;B[0]=D*t;B[1]=D;c.uniform3fv(O.screenPosition,N);c.uniform2fv(O.scale,B);c.uniform1f(O.rotation,u.rotation);c.uniform1f(O.opacity,u.opacity);oa(u.blending);
-K(u.texture,1);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ta)}function V(f,s){f._modelViewMatrix.multiplyToArray(s.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function P(f){var s,n,k,o,w;if(f instanceof THREE.Mesh){n=f.geometry;for(s in n.geometryGroups){k=n.geometryGroups[s];w=!1;for(o in k.__webglCustomAttributes)if(k.__webglCustomAttributes[o].needsUpdate){w=
-!0;break}if(n.__dirtyVertices||n.__dirtyMorphTargets||n.__dirtyElements||n.__dirtyUvs||n.__dirtyNormals||n.__dirtyColors||n.__dirtyTangents||w){w=c.DYNAMIC_DRAW;var x=void 0,u=void 0,A=void 0,t=void 0;A=void 0;var y=void 0,z=void 0,D=void 0,B=void 0,N=void 0,W=void 0,O=void 0,X=void 0,Ga=void 0,S=void 0,Q=void 0,T=void 0,ua=void 0;z=void 0;D=void 0;t=void 0;B=void 0;t=void 0;var r=void 0,F=void 0;z=void 0;r=void 0;F=void 0;var i=void 0,Ka=void 0;r=void 0;F=void 0;i=void 0;Ka=void 0;r=void 0;F=void 0;
-i=void 0;Ka=void 0;r=void 0;F=void 0;i=void 0;t=void 0;B=void 0;y=void 0;A=void 0;A=void 0;r=void 0;F=void 0;i=void 0;var Wa=void 0,va=0,Aa=0,bb=0,cb=0,Ja=0,La=0,ea=0,Ma=0,xa=0,C=0,Ba=0;F=r=0;var Ca=k.__vertexArray,ib=k.__uvArray,jb=k.__uv2Array,Qa=k.__normalArray,ha=k.__tangentArray,Da=k.__colorArray,ia=k.__skinVertexAArray,ja=k.__skinVertexBArray,ka=k.__skinIndexArray,la=k.__skinWeightArray,kb=k.__morphTargetsArrays,Ra=k.__webglCustomAttributes;i=void 0;var Na=k.__faceArray,Oa=k.__lineArray,rb=
-k.__needsSmoothNormals;W=k.__vertexColorType;N=k.__uvType;O=k.__normalType;var Ha=f.geometry,lb=Ha.__dirtyVertices,mb=Ha.__dirtyElements,hb=Ha.__dirtyUvs,nb=Ha.__dirtyNormals,ob=Ha.__dirtyTangents,pb=Ha.__dirtyColors,qb=Ha.__dirtyMorphTargets,db=Ha.vertices,sb=k.faces,xb=Ha.faces,tb=Ha.faceVertexUvs[0],ub=Ha.faceVertexUvs[1],eb=Ha.skinVerticesA,fb=Ha.skinVerticesB,gb=Ha.skinIndices,Xa=Ha.skinWeights,ab=Ha.edgeFaces,Ta=Ha.morphTargets;if(Ra)for(Wa in Ra){Ra[Wa].offset=0;Ra[Wa].offsetSrc=0}x=0;for(u=
-sb.length;x<u;x++){A=sb[x];t=xb[A];tb&&(X=tb[A]);ub&&(Ga=ub[A]);A=t.vertexNormals;y=t.normal;z=t.vertexColors;D=t.color;B=t.vertexTangents;if(t instanceof THREE.Face3){if(lb){S=db[t.a].position;Q=db[t.b].position;T=db[t.c].position;Ca[Aa]=S.x;Ca[Aa+1]=S.y;Ca[Aa+2]=S.z;Ca[Aa+3]=Q.x;Ca[Aa+4]=Q.y;Ca[Aa+5]=Q.z;Ca[Aa+6]=T.x;Ca[Aa+7]=T.y;Ca[Aa+8]=T.z;Aa+=9}if(Ra)for(Wa in Ra){i=Ra[Wa];if(i.needsUpdate){r=i.offset;F=i.offsetSrc;if(i.size===1){if(i.boundTo===undefined||i.boundTo==="vertices"){i.array[r+0]=
-i.value[t.a];i.array[r+1]=i.value[t.b];i.array[r+2]=i.value[t.c]}else if(i.boundTo==="faces"){i.array[r+0]=i.value[F];i.array[r+1]=i.value[F];i.array[r+2]=i.value[F];i.offsetSrc++}else if(i.boundTo==="faceVertices"){i.array[r+0]=i.value[F+0];i.array[r+1]=i.value[F+1];i.array[r+2]=i.value[F+2];i.offsetSrc+=3}i.offset+=3}else{if(i.boundTo===undefined||i.boundTo==="vertices"){S=i.value[t.a];Q=i.value[t.b];T=i.value[t.c]}else if(i.boundTo==="faces"){S=i.value[F];Q=i.value[F];T=i.value[F];i.offsetSrc++}else if(i.boundTo===
-"faceVertices"){S=i.value[F+0];Q=i.value[F+1];T=i.value[F+2];i.offsetSrc+=3}if(i.size===2){i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=Q.x;i.array[r+3]=Q.y;i.array[r+4]=T.x;i.array[r+5]=T.y;i.offset+=6}else if(i.size===3){if(i.type==="c"){i.array[r+0]=S.r;i.array[r+1]=S.g;i.array[r+2]=S.b;i.array[r+3]=Q.r;i.array[r+4]=Q.g;i.array[r+5]=Q.b;i.array[r+6]=T.r;i.array[r+7]=T.g;i.array[r+8]=T.b}else{i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=S.z;i.array[r+3]=Q.x;i.array[r+4]=Q.y;i.array[r+5]=Q.z;
-i.array[r+6]=T.x;i.array[r+7]=T.y;i.array[r+8]=T.z}i.offset+=9}else{i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=S.z;i.array[r+3]=S.w;i.array[r+4]=Q.x;i.array[r+5]=Q.y;i.array[r+6]=Q.z;i.array[r+7]=Q.w;i.array[r+8]=T.x;i.array[r+9]=T.y;i.array[r+10]=T.z;i.array[r+11]=T.w;i.offset+=12}}}}if(qb){r=0;for(F=Ta.length;r<F;r++){S=Ta[r].vertices[t.a].position;Q=Ta[r].vertices[t.b].position;T=Ta[r].vertices[t.c].position;i=kb[r];i[Ba+0]=S.x;i[Ba+1]=S.y;i[Ba+2]=S.z;i[Ba+3]=Q.x;i[Ba+4]=Q.y;i[Ba+5]=Q.z;i[Ba+
-6]=T.x;i[Ba+7]=T.y;i[Ba+8]=T.z}Ba+=9}if(Xa.length){r=Xa[t.a];F=Xa[t.b];i=Xa[t.c];la[C]=r.x;la[C+1]=r.y;la[C+2]=r.z;la[C+3]=r.w;la[C+4]=F.x;la[C+5]=F.y;la[C+6]=F.z;la[C+7]=F.w;la[C+8]=i.x;la[C+9]=i.y;la[C+10]=i.z;la[C+11]=i.w;r=gb[t.a];F=gb[t.b];i=gb[t.c];ka[C]=r.x;ka[C+1]=r.y;ka[C+2]=r.z;ka[C+3]=r.w;ka[C+4]=F.x;ka[C+5]=F.y;ka[C+6]=F.z;ka[C+7]=F.w;ka[C+8]=i.x;ka[C+9]=i.y;ka[C+10]=i.z;ka[C+11]=i.w;r=eb[t.a];F=eb[t.b];i=eb[t.c];ia[C]=r.x;ia[C+1]=r.y;ia[C+2]=r.z;ia[C+3]=1;ia[C+4]=F.x;ia[C+5]=F.y;ia[C+
-6]=F.z;ia[C+7]=1;ia[C+8]=i.x;ia[C+9]=i.y;ia[C+10]=i.z;ia[C+11]=1;r=fb[t.a];F=fb[t.b];i=fb[t.c];ja[C]=r.x;ja[C+1]=r.y;ja[C+2]=r.z;ja[C+3]=1;ja[C+4]=F.x;ja[C+5]=F.y;ja[C+6]=F.z;ja[C+7]=1;ja[C+8]=i.x;ja[C+9]=i.y;ja[C+10]=i.z;ja[C+11]=1;C+=12}if(pb&&W){if(z.length==3&&W==THREE.VertexColors){t=z[0];r=z[1];F=z[2]}else F=r=t=D;Da[xa]=t.r;Da[xa+1]=t.g;Da[xa+2]=t.b;Da[xa+3]=r.r;Da[xa+4]=r.g;Da[xa+5]=r.b;Da[xa+6]=F.r;Da[xa+7]=F.g;Da[xa+8]=F.b;xa+=9}if(ob&&Ha.hasTangents){z=B[0];D=B[1];t=B[2];ha[ea]=z.x;ha[ea+
-1]=z.y;ha[ea+2]=z.z;ha[ea+3]=z.w;ha[ea+4]=D.x;ha[ea+5]=D.y;ha[ea+6]=D.z;ha[ea+7]=D.w;ha[ea+8]=t.x;ha[ea+9]=t.y;ha[ea+10]=t.z;ha[ea+11]=t.w;ea+=12}if(nb&&O)if(A.length==3&&rb)for(B=0;B<3;B++){y=A[B];Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}else for(B=0;B<3;B++){Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}if(hb&&X!==undefined&&N)for(B=0;B<3;B++){A=X[B];ib[bb]=A.u;ib[bb+1]=A.v;bb+=2}if(hb&&Ga!==undefined&&N)for(B=0;B<3;B++){A=Ga[B];jb[cb]=A.u;jb[cb+1]=A.v;cb+=2}if(mb){Na[Ja]=va;Na[Ja+1]=va+1;Na[Ja+
-2]=va+2;Ja+=3;Oa[Ma]=va;Oa[Ma+1]=va+1;Oa[Ma+2]=va;Oa[Ma+3]=va+2;Oa[Ma+4]=va+1;Oa[Ma+5]=va+2;Ma+=6;va+=3}}else if(t instanceof THREE.Face4){if(lb){S=db[t.a].position;Q=db[t.b].position;T=db[t.c].position;ua=db[t.d].position;Ca[Aa]=S.x;Ca[Aa+1]=S.y;Ca[Aa+2]=S.z;Ca[Aa+3]=Q.x;Ca[Aa+4]=Q.y;Ca[Aa+5]=Q.z;Ca[Aa+6]=T.x;Ca[Aa+7]=T.y;Ca[Aa+8]=T.z;Ca[Aa+9]=ua.x;Ca[Aa+10]=ua.y;Ca[Aa+11]=ua.z;Aa+=12}if(Ra)for(Wa in Ra){i=Ra[Wa];if(i.needsUpdate){r=i.offset;F=i.offsetSrc;if(i.size===1){if(i.boundTo===undefined||
-i.boundTo==="vertices"){i.array[r+0]=i.value[t.a];i.array[r+1]=i.value[t.b];i.array[r+2]=i.value[t.c];i.array[r+2]=i.value[t.d]}else if(i.boundTo==="faces"){i.array[r+0]=i.value[F];i.array[r+1]=i.value[F];i.array[r+2]=i.value[F];i.array[r+2]=i.value[F];i.offsetSrc++}else if(i.boundTo==="faceVertices"){i.array[r+0]=i.value[F+0];i.array[r+1]=i.value[F+1];i.array[r+2]=i.value[F+2];i.array[r+2]=i.value[F+3];i.offsetSrc+=4}i.offset+=4}else{if(i.boundTo===undefined||i.boundTo==="vertices"){S=i.value[t.a];
-Q=i.value[t.b];T=i.value[t.c];ua=i.value[t.d]}else if(i.boundTo==="faces"){S=i.value[F];Q=i.value[F];T=i.value[F];ua=i.value[F];i.offsetSrc++}else if(i.boundTo==="faceVertices"){S=i.value[F+0];Q=i.value[F+1];T=i.value[F+2];ua=i.value[F+3];i.offsetSrc+=4}if(i.size===2){i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=Q.x;i.array[r+3]=Q.y;i.array[r+4]=T.x;i.array[r+5]=T.y;i.array[r+6]=ua.x;i.array[r+7]=ua.y;i.offset+=8}else if(i.size===3){if(i.type==="c"){i.array[r+0]=S.r;i.array[r+1]=S.g;i.array[r+2]=
-S.b;i.array[r+3]=Q.r;i.array[r+4]=Q.g;i.array[r+5]=Q.b;i.array[r+6]=T.r;i.array[r+7]=T.g;i.array[r+8]=T.b;i.array[r+9]=ua.r;i.array[r+10]=ua.g;i.array[r+11]=ua.b}else{i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=S.z;i.array[r+3]=Q.x;i.array[r+4]=Q.y;i.array[r+5]=Q.z;i.array[r+6]=T.x;i.array[r+7]=T.y;i.array[r+8]=T.z;i.array[r+9]=ua.x;i.array[r+10]=ua.y;i.array[r+11]=ua.z}i.offset+=12}else{i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=S.z;i.array[r+3]=S.w;i.array[r+4]=Q.x;i.array[r+5]=Q.y;i.array[r+
-6]=Q.z;i.array[r+7]=Q.w;i.array[r+8]=T.x;i.array[r+9]=T.y;i.array[r+10]=T.z;i.array[r+11]=T.w;i.array[r+12]=ua.x;i.array[r+13]=ua.y;i.array[r+14]=ua.z;i.array[r+15]=ua.w;i.offset+=16}}}}if(qb){r=0;for(F=Ta.length;r<F;r++){S=Ta[r].vertices[t.a].position;Q=Ta[r].vertices[t.b].position;T=Ta[r].vertices[t.c].position;ua=Ta[r].vertices[t.d].position;i=kb[r];i[Ba+0]=S.x;i[Ba+1]=S.y;i[Ba+2]=S.z;i[Ba+3]=Q.x;i[Ba+4]=Q.y;i[Ba+5]=Q.z;i[Ba+6]=T.x;i[Ba+7]=T.y;i[Ba+8]=T.z;i[Ba+9]=ua.x;i[Ba+10]=ua.y;i[Ba+11]=ua.z}Ba+=
-12}if(Xa.length){r=Xa[t.a];F=Xa[t.b];i=Xa[t.c];Ka=Xa[t.d];la[C]=r.x;la[C+1]=r.y;la[C+2]=r.z;la[C+3]=r.w;la[C+4]=F.x;la[C+5]=F.y;la[C+6]=F.z;la[C+7]=F.w;la[C+8]=i.x;la[C+9]=i.y;la[C+10]=i.z;la[C+11]=i.w;la[C+12]=Ka.x;la[C+13]=Ka.y;la[C+14]=Ka.z;la[C+15]=Ka.w;r=gb[t.a];F=gb[t.b];i=gb[t.c];Ka=gb[t.d];ka[C]=r.x;ka[C+1]=r.y;ka[C+2]=r.z;ka[C+3]=r.w;ka[C+4]=F.x;ka[C+5]=F.y;ka[C+6]=F.z;ka[C+7]=F.w;ka[C+8]=i.x;ka[C+9]=i.y;ka[C+10]=i.z;ka[C+11]=i.w;ka[C+12]=Ka.x;ka[C+13]=Ka.y;ka[C+14]=Ka.z;ka[C+15]=Ka.w;r=
-eb[t.a];F=eb[t.b];i=eb[t.c];Ka=eb[t.d];ia[C]=r.x;ia[C+1]=r.y;ia[C+2]=r.z;ia[C+3]=1;ia[C+4]=F.x;ia[C+5]=F.y;ia[C+6]=F.z;ia[C+7]=1;ia[C+8]=i.x;ia[C+9]=i.y;ia[C+10]=i.z;ia[C+11]=1;ia[C+12]=Ka.x;ia[C+13]=Ka.y;ia[C+14]=Ka.z;ia[C+15]=1;r=fb[t.a];F=fb[t.b];i=fb[t.c];t=fb[t.d];ja[C]=r.x;ja[C+1]=r.y;ja[C+2]=r.z;ja[C+3]=1;ja[C+4]=F.x;ja[C+5]=F.y;ja[C+6]=F.z;ja[C+7]=1;ja[C+8]=i.x;ja[C+9]=i.y;ja[C+10]=i.z;ja[C+11]=1;ja[C+12]=t.x;ja[C+13]=t.y;ja[C+14]=t.z;ja[C+15]=1;C+=16}if(pb&&W){if(z.length==4&&W==THREE.VertexColors){t=
-z[0];r=z[1];F=z[2];z=z[3]}else z=F=r=t=D;Da[xa]=t.r;Da[xa+1]=t.g;Da[xa+2]=t.b;Da[xa+3]=r.r;Da[xa+4]=r.g;Da[xa+5]=r.b;Da[xa+6]=F.r;Da[xa+7]=F.g;Da[xa+8]=F.b;Da[xa+9]=z.r;Da[xa+10]=z.g;Da[xa+11]=z.b;xa+=12}if(ob&&Ha.hasTangents){z=B[0];D=B[1];t=B[2];B=B[3];ha[ea]=z.x;ha[ea+1]=z.y;ha[ea+2]=z.z;ha[ea+3]=z.w;ha[ea+4]=D.x;ha[ea+5]=D.y;ha[ea+6]=D.z;ha[ea+7]=D.w;ha[ea+8]=t.x;ha[ea+9]=t.y;ha[ea+10]=t.z;ha[ea+11]=t.w;ha[ea+12]=B.x;ha[ea+13]=B.y;ha[ea+14]=B.z;ha[ea+15]=B.w;ea+=16}if(nb&&O)if(A.length==4&&rb)for(B=
-0;B<4;B++){y=A[B];Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}else for(B=0;B<4;B++){Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}if(hb&&X!==undefined&&N)for(B=0;B<4;B++){A=X[B];ib[bb]=A.u;ib[bb+1]=A.v;bb+=2}if(hb&&Ga!==undefined&&N)for(B=0;B<4;B++){A=Ga[B];jb[cb]=A.u;jb[cb+1]=A.v;cb+=2}if(mb){Na[Ja]=va;Na[Ja+1]=va+1;Na[Ja+2]=va+3;Na[Ja+3]=va+1;Na[Ja+4]=va+2;Na[Ja+5]=va+3;Ja+=6;Oa[Ma]=va;Oa[Ma+1]=va+1;Oa[Ma+2]=va;Oa[Ma+3]=va+3;Oa[Ma+4]=va+1;Oa[Ma+5]=va+2;Oa[Ma+6]=va+2;Oa[Ma+7]=va+3;Ma+=8;va+=4}}}if(ab){x=
-0;for(u=ab.length;x<u;x++){Na[Ja]=ab[x].a;Na[Ja+1]=ab[x].b;Na[Ja+2]=ab[x].c;Na[Ja+3]=ab[x].a;Na[Ja+4]=ab[x].c;Na[Ja+5]=ab[x].d;Ja+=6}}if(lb){c.bindBuffer(c.ARRAY_BUFFER,k.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Ca,w)}if(Ra)for(Wa in Ra){i=Ra[Wa];if(i.needsUpdate){c.bindBuffer(c.ARRAY_BUFFER,i.buffer);c.bufferData(c.ARRAY_BUFFER,i.array,w);i.needsUpdate=!1}}if(qb){r=0;for(F=Ta.length;r<F;r++){c.bindBuffer(c.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[r]);c.bufferData(c.ARRAY_BUFFER,kb[r],w)}}if(pb&&
+c.depthMask(!0);c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.vertexAttribPointer(n.position,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(n.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.uniformMatrix4fv(w.projectionMatrix,!1,Ua);c.activeTexture(c.TEXTURE0);c.uniform1i(w.map,0);n=0;for(k=f.__webglSprites.length;n<k;n++){o=f.__webglSprites[n];if(o.useScreenCoordinates)o.z=-o.position.z;else{o._modelViewMatrix.multiplyToArray(s.matrixWorldInverse,o.matrixWorld,
+o._modelViewMatrixArray);o.z=-o._modelViewMatrix.n34}}f.__webglSprites.sort(I);n=0;for(k=f.__webglSprites.length;n<k;n++){o=f.__webglSprites[n];if(o.material===undefined&&o.map&&o.map.image&&o.map.image.width){if(o.useScreenCoordinates){c.uniform1i(w.useScreenCoordinates,1);c.uniform3f(w.screenPosition,(o.position.x-t)/t,(y-o.position.y)/y,Math.max(0,Math.min(1,o.position.z)))}else{c.uniform1i(w.useScreenCoordinates,0);c.uniform1i(w.affectedByDistance,o.affectedByDistance?1:0);c.uniformMatrix4fv(w.modelViewMatrix,
+!1,o._modelViewMatrixArray)}u=o.map.image.width/(o.affectedByDistance?1:za);A[0]=u*x*o.scale.x;A[1]=u*o.scale.y;c.uniform2f(w.uvScale,o.uvScale.x,o.uvScale.y);c.uniform2f(w.uvOffset,o.uvOffset.x,o.uvOffset.y);c.uniform2f(w.alignment,o.alignment.x,o.alignment.y);c.uniform1f(w.opacity,o.opacity);c.uniform1f(w.rotation,o.rotation);c.uniform2fv(w.scale,A);if(o.mergeWith3D&&!z){c.enable(c.DEPTH_TEST);z=!0}else if(!o.mergeWith3D&&z){c.disable(c.DEPTH_TEST);z=!1}oa(o.blending);K(o.map,0);c.drawElements(c.TRIANGLES,
+6,c.UNSIGNED_SHORT,0)}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ta)}function M(f,s){var n,k,o=f.__webglLensFlares.length,w,x,u,A=new THREE.Vector3,t=za/ya,y=ya*0.5,z=za*0.5,D=16/za,B=[D*t,D],N=[1,1,0],W=[1,1],O=J.uniforms;n=J.attributes;c.useProgram(J.program);ra=J.program;ga="";c.uniform1i(O.occlusionMap,0);c.uniform1i(O.map,1);c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);c.vertexAttribPointer(n.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(n.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
+J.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.activeTexture(c.TEXTURE1);for(k=0;k<o;k++){n=f.__webglLensFlares[k].object;A.set(n.matrixWorld.n14,n.matrixWorld.n24,n.matrixWorld.n34);s.matrixWorldInverse.multiplyVector3(A);s.projectionMatrix.multiplyVector3(A);N[0]=A.x;N[1]=A.y;N[2]=A.z;W[0]=N[0]*y+y;W[1]=N[1]*z+z;if(J.hasVertexTexture||W[0]>0&&W[0]<ya&&W[1]>0&&W[1]<za){c.bindTexture(c.TEXTURE_2D,J.tempTexture);
+c.copyTexImage2D(c.TEXTURE_2D,0,c.RGB,W[0]-8,W[1]-8,16,16,0);c.uniform1i(O.renderType,0);c.uniform2fv(O.scale,B);c.uniform3fv(O.screenPosition,N);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.bindTexture(c.TEXTURE_2D,J.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,W[0]-8,W[1]-8,16,16,0);c.uniform1i(O.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,J.tempTexture);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);n.positionScreen.x=
+N[0];n.positionScreen.y=N[1];n.positionScreen.z=N[2];n.customUpdateCallback?n.customUpdateCallback(n):n.updateLensFlares();c.uniform1i(O.renderType,2);c.enable(c.BLEND);w=0;for(x=n.lensFlares.length;w<x;w++){u=n.lensFlares[w];if(u.opacity>0.001&&u.scale>0.001){N[0]=u.x;N[1]=u.y;N[2]=u.z;D=u.size*u.scale/za;B[0]=D*t;B[1]=D;c.uniform3fv(O.screenPosition,N);c.uniform2fv(O.scale,B);c.uniform1f(O.rotation,u.rotation);c.uniform1f(O.opacity,u.opacity);oa(u.blending);K(u.texture,1);c.drawElements(c.TRIANGLES,
+6,c.UNSIGNED_SHORT,0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ta)}function V(f,s){f._modelViewMatrix.multiplyToArray(s.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function P(f){var s,n,k,o,w;if(f instanceof THREE.Mesh){n=f.geometry;for(s in n.geometryGroups){k=n.geometryGroups[s];w=!1;for(o in k.__webglCustomAttributes)if(k.__webglCustomAttributes[o].needsUpdate){w=!0;break}if(n.__dirtyVertices||
+n.__dirtyMorphTargets||n.__dirtyElements||n.__dirtyUvs||n.__dirtyNormals||n.__dirtyColors||n.__dirtyTangents||w){w=c.DYNAMIC_DRAW;var x=void 0,u=void 0,A=void 0,t=void 0;A=void 0;var y=void 0,z=void 0,D=void 0,B=void 0,N=void 0,W=void 0,O=void 0,X=void 0,Ga=void 0,S=void 0,Q=void 0,T=void 0,ua=void 0;z=void 0;D=void 0;t=void 0;B=void 0;t=void 0;var r=void 0,F=void 0;z=void 0;r=void 0;F=void 0;var i=void 0,Ka=void 0;r=void 0;F=void 0;i=void 0;Ka=void 0;r=void 0;F=void 0;i=void 0;Ka=void 0;r=void 0;
+F=void 0;i=void 0;t=void 0;B=void 0;y=void 0;A=void 0;A=void 0;r=void 0;F=void 0;i=void 0;var Wa=void 0,va=0,Aa=0,bb=0,cb=0,Ja=0,La=0,ea=0,Ma=0,xa=0,C=0,Ba=0;F=r=0;var Ca=k.__vertexArray,ib=k.__uvArray,jb=k.__uv2Array,Qa=k.__normalArray,ha=k.__tangentArray,Da=k.__colorArray,ia=k.__skinVertexAArray,ja=k.__skinVertexBArray,ka=k.__skinIndexArray,la=k.__skinWeightArray,kb=k.__morphTargetsArrays,Ra=k.__webglCustomAttributes;i=void 0;var Na=k.__faceArray,Oa=k.__lineArray,rb=k.__needsSmoothNormals;W=k.__vertexColorType;
+N=k.__uvType;O=k.__normalType;var Ha=f.geometry,lb=Ha.__dirtyVertices,mb=Ha.__dirtyElements,hb=Ha.__dirtyUvs,nb=Ha.__dirtyNormals,ob=Ha.__dirtyTangents,pb=Ha.__dirtyColors,qb=Ha.__dirtyMorphTargets,db=Ha.vertices,sb=k.faces,xb=Ha.faces,tb=Ha.faceVertexUvs[0],ub=Ha.faceVertexUvs[1],eb=Ha.skinVerticesA,fb=Ha.skinVerticesB,gb=Ha.skinIndices,Xa=Ha.skinWeights,ab=Ha.edgeFaces,Ta=Ha.morphTargets;if(Ra)for(Wa in Ra){Ra[Wa].offset=0;Ra[Wa].offsetSrc=0}x=0;for(u=sb.length;x<u;x++){A=sb[x];t=xb[A];tb&&(X=tb[A]);
+ub&&(Ga=ub[A]);A=t.vertexNormals;y=t.normal;z=t.vertexColors;D=t.color;B=t.vertexTangents;if(t instanceof THREE.Face3){if(lb){S=db[t.a].position;Q=db[t.b].position;T=db[t.c].position;Ca[Aa]=S.x;Ca[Aa+1]=S.y;Ca[Aa+2]=S.z;Ca[Aa+3]=Q.x;Ca[Aa+4]=Q.y;Ca[Aa+5]=Q.z;Ca[Aa+6]=T.x;Ca[Aa+7]=T.y;Ca[Aa+8]=T.z;Aa+=9}if(Ra)for(Wa in Ra){i=Ra[Wa];if(i.needsUpdate){r=i.offset;F=i.offsetSrc;if(i.size===1){if(i.boundTo===undefined||i.boundTo==="vertices"){i.array[r+0]=i.value[t.a];i.array[r+1]=i.value[t.b];i.array[r+
+2]=i.value[t.c]}else if(i.boundTo==="faces"){i.array[r+0]=i.value[F];i.array[r+1]=i.value[F];i.array[r+2]=i.value[F];i.offsetSrc++}else if(i.boundTo==="faceVertices"){i.array[r+0]=i.value[F+0];i.array[r+1]=i.value[F+1];i.array[r+2]=i.value[F+2];i.offsetSrc+=3}i.offset+=3}else{if(i.boundTo===undefined||i.boundTo==="vertices"){S=i.value[t.a];Q=i.value[t.b];T=i.value[t.c]}else if(i.boundTo==="faces"){S=i.value[F];Q=i.value[F];T=i.value[F];i.offsetSrc++}else if(i.boundTo==="faceVertices"){S=i.value[F+
+0];Q=i.value[F+1];T=i.value[F+2];i.offsetSrc+=3}if(i.size===2){i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=Q.x;i.array[r+3]=Q.y;i.array[r+4]=T.x;i.array[r+5]=T.y;i.offset+=6}else if(i.size===3){if(i.type==="c"){i.array[r+0]=S.r;i.array[r+1]=S.g;i.array[r+2]=S.b;i.array[r+3]=Q.r;i.array[r+4]=Q.g;i.array[r+5]=Q.b;i.array[r+6]=T.r;i.array[r+7]=T.g;i.array[r+8]=T.b}else{i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=S.z;i.array[r+3]=Q.x;i.array[r+4]=Q.y;i.array[r+5]=Q.z;i.array[r+6]=T.x;i.array[r+
+7]=T.y;i.array[r+8]=T.z}i.offset+=9}else{i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=S.z;i.array[r+3]=S.w;i.array[r+4]=Q.x;i.array[r+5]=Q.y;i.array[r+6]=Q.z;i.array[r+7]=Q.w;i.array[r+8]=T.x;i.array[r+9]=T.y;i.array[r+10]=T.z;i.array[r+11]=T.w;i.offset+=12}}}}if(qb){r=0;for(F=Ta.length;r<F;r++){S=Ta[r].vertices[t.a].position;Q=Ta[r].vertices[t.b].position;T=Ta[r].vertices[t.c].position;i=kb[r];i[Ba+0]=S.x;i[Ba+1]=S.y;i[Ba+2]=S.z;i[Ba+3]=Q.x;i[Ba+4]=Q.y;i[Ba+5]=Q.z;i[Ba+6]=T.x;i[Ba+7]=T.y;i[Ba+
+8]=T.z}Ba+=9}if(Xa.length){r=Xa[t.a];F=Xa[t.b];i=Xa[t.c];la[C]=r.x;la[C+1]=r.y;la[C+2]=r.z;la[C+3]=r.w;la[C+4]=F.x;la[C+5]=F.y;la[C+6]=F.z;la[C+7]=F.w;la[C+8]=i.x;la[C+9]=i.y;la[C+10]=i.z;la[C+11]=i.w;r=gb[t.a];F=gb[t.b];i=gb[t.c];ka[C]=r.x;ka[C+1]=r.y;ka[C+2]=r.z;ka[C+3]=r.w;ka[C+4]=F.x;ka[C+5]=F.y;ka[C+6]=F.z;ka[C+7]=F.w;ka[C+8]=i.x;ka[C+9]=i.y;ka[C+10]=i.z;ka[C+11]=i.w;r=eb[t.a];F=eb[t.b];i=eb[t.c];ia[C]=r.x;ia[C+1]=r.y;ia[C+2]=r.z;ia[C+3]=1;ia[C+4]=F.x;ia[C+5]=F.y;ia[C+6]=F.z;ia[C+7]=1;ia[C+8]=
+i.x;ia[C+9]=i.y;ia[C+10]=i.z;ia[C+11]=1;r=fb[t.a];F=fb[t.b];i=fb[t.c];ja[C]=r.x;ja[C+1]=r.y;ja[C+2]=r.z;ja[C+3]=1;ja[C+4]=F.x;ja[C+5]=F.y;ja[C+6]=F.z;ja[C+7]=1;ja[C+8]=i.x;ja[C+9]=i.y;ja[C+10]=i.z;ja[C+11]=1;C+=12}if(pb&&W){if(z.length==3&&W==THREE.VertexColors){t=z[0];r=z[1];F=z[2]}else F=r=t=D;Da[xa]=t.r;Da[xa+1]=t.g;Da[xa+2]=t.b;Da[xa+3]=r.r;Da[xa+4]=r.g;Da[xa+5]=r.b;Da[xa+6]=F.r;Da[xa+7]=F.g;Da[xa+8]=F.b;xa+=9}if(ob&&Ha.hasTangents){z=B[0];D=B[1];t=B[2];ha[ea]=z.x;ha[ea+1]=z.y;ha[ea+2]=z.z;ha[ea+
+3]=z.w;ha[ea+4]=D.x;ha[ea+5]=D.y;ha[ea+6]=D.z;ha[ea+7]=D.w;ha[ea+8]=t.x;ha[ea+9]=t.y;ha[ea+10]=t.z;ha[ea+11]=t.w;ea+=12}if(nb&&O)if(A.length==3&&rb)for(B=0;B<3;B++){y=A[B];Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}else for(B=0;B<3;B++){Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}if(hb&&X!==undefined&&N)for(B=0;B<3;B++){A=X[B];ib[bb]=A.u;ib[bb+1]=A.v;bb+=2}if(hb&&Ga!==undefined&&N)for(B=0;B<3;B++){A=Ga[B];jb[cb]=A.u;jb[cb+1]=A.v;cb+=2}if(mb){Na[Ja]=va;Na[Ja+1]=va+1;Na[Ja+2]=va+2;Ja+=3;Oa[Ma]=va;Oa[Ma+
+1]=va+1;Oa[Ma+2]=va;Oa[Ma+3]=va+2;Oa[Ma+4]=va+1;Oa[Ma+5]=va+2;Ma+=6;va+=3}}else if(t instanceof THREE.Face4){if(lb){S=db[t.a].position;Q=db[t.b].position;T=db[t.c].position;ua=db[t.d].position;Ca[Aa]=S.x;Ca[Aa+1]=S.y;Ca[Aa+2]=S.z;Ca[Aa+3]=Q.x;Ca[Aa+4]=Q.y;Ca[Aa+5]=Q.z;Ca[Aa+6]=T.x;Ca[Aa+7]=T.y;Ca[Aa+8]=T.z;Ca[Aa+9]=ua.x;Ca[Aa+10]=ua.y;Ca[Aa+11]=ua.z;Aa+=12}if(Ra)for(Wa in Ra){i=Ra[Wa];if(i.needsUpdate){r=i.offset;F=i.offsetSrc;if(i.size===1){if(i.boundTo===undefined||i.boundTo==="vertices"){i.array[r+
+0]=i.value[t.a];i.array[r+1]=i.value[t.b];i.array[r+2]=i.value[t.c];i.array[r+2]=i.value[t.d]}else if(i.boundTo==="faces"){i.array[r+0]=i.value[F];i.array[r+1]=i.value[F];i.array[r+2]=i.value[F];i.array[r+2]=i.value[F];i.offsetSrc++}else if(i.boundTo==="faceVertices"){i.array[r+0]=i.value[F+0];i.array[r+1]=i.value[F+1];i.array[r+2]=i.value[F+2];i.array[r+2]=i.value[F+3];i.offsetSrc+=4}i.offset+=4}else{if(i.boundTo===undefined||i.boundTo==="vertices"){S=i.value[t.a];Q=i.value[t.b];T=i.value[t.c];ua=
+i.value[t.d]}else if(i.boundTo==="faces"){S=i.value[F];Q=i.value[F];T=i.value[F];ua=i.value[F];i.offsetSrc++}else if(i.boundTo==="faceVertices"){S=i.value[F+0];Q=i.value[F+1];T=i.value[F+2];ua=i.value[F+3];i.offsetSrc+=4}if(i.size===2){i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=Q.x;i.array[r+3]=Q.y;i.array[r+4]=T.x;i.array[r+5]=T.y;i.array[r+6]=ua.x;i.array[r+7]=ua.y;i.offset+=8}else if(i.size===3){if(i.type==="c"){i.array[r+0]=S.r;i.array[r+1]=S.g;i.array[r+2]=S.b;i.array[r+3]=Q.r;i.array[r+
+4]=Q.g;i.array[r+5]=Q.b;i.array[r+6]=T.r;i.array[r+7]=T.g;i.array[r+8]=T.b;i.array[r+9]=ua.r;i.array[r+10]=ua.g;i.array[r+11]=ua.b}else{i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=S.z;i.array[r+3]=Q.x;i.array[r+4]=Q.y;i.array[r+5]=Q.z;i.array[r+6]=T.x;i.array[r+7]=T.y;i.array[r+8]=T.z;i.array[r+9]=ua.x;i.array[r+10]=ua.y;i.array[r+11]=ua.z}i.offset+=12}else{i.array[r+0]=S.x;i.array[r+1]=S.y;i.array[r+2]=S.z;i.array[r+3]=S.w;i.array[r+4]=Q.x;i.array[r+5]=Q.y;i.array[r+6]=Q.z;i.array[r+7]=Q.w;i.array[r+
+8]=T.x;i.array[r+9]=T.y;i.array[r+10]=T.z;i.array[r+11]=T.w;i.array[r+12]=ua.x;i.array[r+13]=ua.y;i.array[r+14]=ua.z;i.array[r+15]=ua.w;i.offset+=16}}}}if(qb){r=0;for(F=Ta.length;r<F;r++){S=Ta[r].vertices[t.a].position;Q=Ta[r].vertices[t.b].position;T=Ta[r].vertices[t.c].position;ua=Ta[r].vertices[t.d].position;i=kb[r];i[Ba+0]=S.x;i[Ba+1]=S.y;i[Ba+2]=S.z;i[Ba+3]=Q.x;i[Ba+4]=Q.y;i[Ba+5]=Q.z;i[Ba+6]=T.x;i[Ba+7]=T.y;i[Ba+8]=T.z;i[Ba+9]=ua.x;i[Ba+10]=ua.y;i[Ba+11]=ua.z}Ba+=12}if(Xa.length){r=Xa[t.a];
+F=Xa[t.b];i=Xa[t.c];Ka=Xa[t.d];la[C]=r.x;la[C+1]=r.y;la[C+2]=r.z;la[C+3]=r.w;la[C+4]=F.x;la[C+5]=F.y;la[C+6]=F.z;la[C+7]=F.w;la[C+8]=i.x;la[C+9]=i.y;la[C+10]=i.z;la[C+11]=i.w;la[C+12]=Ka.x;la[C+13]=Ka.y;la[C+14]=Ka.z;la[C+15]=Ka.w;r=gb[t.a];F=gb[t.b];i=gb[t.c];Ka=gb[t.d];ka[C]=r.x;ka[C+1]=r.y;ka[C+2]=r.z;ka[C+3]=r.w;ka[C+4]=F.x;ka[C+5]=F.y;ka[C+6]=F.z;ka[C+7]=F.w;ka[C+8]=i.x;ka[C+9]=i.y;ka[C+10]=i.z;ka[C+11]=i.w;ka[C+12]=Ka.x;ka[C+13]=Ka.y;ka[C+14]=Ka.z;ka[C+15]=Ka.w;r=eb[t.a];F=eb[t.b];i=eb[t.c];
+Ka=eb[t.d];ia[C]=r.x;ia[C+1]=r.y;ia[C+2]=r.z;ia[C+3]=1;ia[C+4]=F.x;ia[C+5]=F.y;ia[C+6]=F.z;ia[C+7]=1;ia[C+8]=i.x;ia[C+9]=i.y;ia[C+10]=i.z;ia[C+11]=1;ia[C+12]=Ka.x;ia[C+13]=Ka.y;ia[C+14]=Ka.z;ia[C+15]=1;r=fb[t.a];F=fb[t.b];i=fb[t.c];t=fb[t.d];ja[C]=r.x;ja[C+1]=r.y;ja[C+2]=r.z;ja[C+3]=1;ja[C+4]=F.x;ja[C+5]=F.y;ja[C+6]=F.z;ja[C+7]=1;ja[C+8]=i.x;ja[C+9]=i.y;ja[C+10]=i.z;ja[C+11]=1;ja[C+12]=t.x;ja[C+13]=t.y;ja[C+14]=t.z;ja[C+15]=1;C+=16}if(pb&&W){if(z.length==4&&W==THREE.VertexColors){t=z[0];r=z[1];F=
+z[2];z=z[3]}else z=F=r=t=D;Da[xa]=t.r;Da[xa+1]=t.g;Da[xa+2]=t.b;Da[xa+3]=r.r;Da[xa+4]=r.g;Da[xa+5]=r.b;Da[xa+6]=F.r;Da[xa+7]=F.g;Da[xa+8]=F.b;Da[xa+9]=z.r;Da[xa+10]=z.g;Da[xa+11]=z.b;xa+=12}if(ob&&Ha.hasTangents){z=B[0];D=B[1];t=B[2];B=B[3];ha[ea]=z.x;ha[ea+1]=z.y;ha[ea+2]=z.z;ha[ea+3]=z.w;ha[ea+4]=D.x;ha[ea+5]=D.y;ha[ea+6]=D.z;ha[ea+7]=D.w;ha[ea+8]=t.x;ha[ea+9]=t.y;ha[ea+10]=t.z;ha[ea+11]=t.w;ha[ea+12]=B.x;ha[ea+13]=B.y;ha[ea+14]=B.z;ha[ea+15]=B.w;ea+=16}if(nb&&O)if(A.length==4&&rb)for(B=0;B<4;B++){y=
+A[B];Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}else for(B=0;B<4;B++){Qa[La]=y.x;Qa[La+1]=y.y;Qa[La+2]=y.z;La+=3}if(hb&&X!==undefined&&N)for(B=0;B<4;B++){A=X[B];ib[bb]=A.u;ib[bb+1]=A.v;bb+=2}if(hb&&Ga!==undefined&&N)for(B=0;B<4;B++){A=Ga[B];jb[cb]=A.u;jb[cb+1]=A.v;cb+=2}if(mb){Na[Ja]=va;Na[Ja+1]=va+1;Na[Ja+2]=va+3;Na[Ja+3]=va+1;Na[Ja+4]=va+2;Na[Ja+5]=va+3;Ja+=6;Oa[Ma]=va;Oa[Ma+1]=va+1;Oa[Ma+2]=va;Oa[Ma+3]=va+3;Oa[Ma+4]=va+1;Oa[Ma+5]=va+2;Oa[Ma+6]=va+2;Oa[Ma+7]=va+3;Ma+=8;va+=4}}}if(ab){x=0;for(u=
+ab.length;x<u;x++){Na[Ja]=ab[x].a;Na[Ja+1]=ab[x].b;Na[Ja+2]=ab[x].c;Na[Ja+3]=ab[x].a;Na[Ja+4]=ab[x].c;Na[Ja+5]=ab[x].d;Ja+=6}}if(lb){c.bindBuffer(c.ARRAY_BUFFER,k.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Ca,w)}if(Ra)for(Wa in Ra){i=Ra[Wa];if(i.needsUpdate){c.bindBuffer(c.ARRAY_BUFFER,i.buffer);c.bufferData(c.ARRAY_BUFFER,i.array,w);i.needsUpdate=!1}}if(qb){r=0;for(F=Ta.length;r<F;r++){c.bindBuffer(c.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[r]);c.bufferData(c.ARRAY_BUFFER,kb[r],w)}}if(pb&&
 xa>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,Da,w)}if(nb){c.bindBuffer(c.ARRAY_BUFFER,k.__webglNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Qa,w)}if(ob&&Ha.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,k.__webglTangentBuffer);c.bufferData(c.ARRAY_BUFFER,ha,w)}if(hb&&bb>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglUVBuffer);c.bufferData(c.ARRAY_BUFFER,ib,w)}if(hb&&cb>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglUV2Buffer);c.bufferData(c.ARRAY_BUFFER,jb,w)}if(mb){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
 k.__webglFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Na,w);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,k.__webglLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Oa,w)}if(C>0){c.bindBuffer(c.ARRAY_BUFFER,k.__webglSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ia,w);c.bindBuffer(c.ARRAY_BUFFER,k.__webglSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,ja,w);c.bindBuffer(c.ARRAY_BUFFER,k.__webglSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,ka,w);c.bindBuffer(c.ARRAY_BUFFER,k.__webglSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,
 la,w)}}}n.__dirtyVertices=!1;n.__dirtyMorphTargets=!1;n.__dirtyElements=!1;n.__dirtyUvs=!1;n.__dirtyNormals=!1;n.__dirtyTangents=!1;n.__dirtyColors=!1}else if(f instanceof THREE.Ribbon){n=f.geometry;if(n.__dirtyVertices||n.__dirtyColors){f=n;s=c.DYNAMIC_DRAW;W=f.vertices;k=f.colors;O=W.length;w=k.length;X=f.__vertexArray;x=f.__colorArray;Ga=f.__dirtyColors;if(f.__dirtyVertices){for(u=0;u<O;u++){N=W[u].position;o=u*3;X[o]=N.x;X[o+1]=N.y;X[o+2]=N.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);
@@ -252,25 +252,26 @@ s);c.compileShader(n);if(!c.getShaderParameter(n,c.COMPILE_STATUS)){console.erro
 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 c,R=document.createElement("canvas"),pa=[],ra=null,Fa=null,ta=!0,aa=this,ma=null,na=null,ga=null,Y=null,wa=0,qa=0,ya=0,za=0,$=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
 new THREE.Vector4,new THREE.Vector4],Pa=new THREE.Matrix4,Ua=new Float32Array(16),Ya=new Float32Array(16),Va=new THREE.Vector4,Sa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},Za=!0,$a=!0,vb=new THREE.Color(0),wb=0;if(b){if(b.stencil!=undefined)Za=b.stencil;if(b.antialias!==undefined)$a=b.antialias;b.clearColor!==undefined&&vb.setHex(b.clearColor);if(b.clearAlpha!==undefined)wb=b.clearAlpha}this.maxMorphTargets=8;this.domElement=
-R;this.autoClear=!0;this.sortObjects=!0;(function(f,s,n,k){try{if(!(c=R.getContext("experimental-webgl",{antialias:f,stencil:k})))throw"Error creating WebGL context.";}catch(o){console.error(o)}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(s.r,s.g,s.b,n)})($a,vb,wb,Za);this.context=c;if(Za){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,ca("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(U.program,ca("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 J={};J.vertices=new Float32Array(16);J.faces=new Uint16Array(6);b=0;J.vertices[b++]=-1;J.vertices[b++]=-1;J.vertices[b++]=0;J.vertices[b++]=0;J.vertices[b++]=1;J.vertices[b++]=-1;J.vertices[b++]=1;J.vertices[b++]=0;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=-1;J.vertices[b++]=1;J.vertices[b++]=0;J.vertices[b++]=1;b=0;J.faces[b++]=0;J.faces[b++]=1;J.faces[b++]=2;J.faces[b++]=0;J.faces[b++]=2;J.faces[b++]=3;
-J.vertexBuffer=c.createBuffer();J.elementBuffer=c.createBuffer();J.tempTexture=c.createTexture();J.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,J.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,J.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,J.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,J.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,J.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);if(c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){J.hasVertexTexture=!1;J.program=c.createProgram();c.attachShader(J.program,ca("fragment",THREE.ShaderLib.lensFlare.fragmentShader));c.attachShader(J.program,ca("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{J.hasVertexTexture=!0;J.program=c.createProgram();c.attachShader(J.program,ca("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));c.attachShader(J.program,
-ca("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}c.linkProgram(J.program);J.attributes={};J.uniforms={};J.attributes.vertex=c.getAttribLocation(J.program,"position");J.attributes.uv=c.getAttribLocation(J.program,"UV");J.uniforms.renderType=c.getUniformLocation(J.program,"renderType");J.uniforms.map=c.getUniformLocation(J.program,"map");J.uniforms.occlusionMap=c.getUniformLocation(J.program,"occlusionMap");J.uniforms.opacity=c.getUniformLocation(J.program,"opacity");J.uniforms.scale=
-c.getUniformLocation(J.program,"scale");J.uniforms.rotation=c.getUniformLocation(J.program,"rotation");J.uniforms.screenPosition=c.getUniformLocation(J.program,"screenPosition");_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=
-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=c.createBuffer();_sprite.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,_sprite.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);
-c.bufferData(c.ELEMENT_ARRAY_BUFFER,_sprite.faces,c.STATIC_DRAW);_sprite.program=c.createProgram();c.attachShader(_sprite.program,ca("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(_sprite.program,ca("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=c.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=c.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=
-c.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=c.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=c.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=c.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=c.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=c.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=c.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=
-c.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=c.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=c.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=c.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=c.getUniformLocation(_sprite.program,"projectionMatrix");this.setSize=function(f,s){R.width=f;R.height=s;this.setViewport(0,0,R.width,R.height)};
-this.setViewport=function(f,s,n,k){wa=f;qa=s;ya=n;za=k;c.viewport(wa,qa,ya,za)};this.setScissor=function(f,s,n,k){c.scissor(f,s,n,k)};this.enableScissorTest=function(f){f?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(f){ta=f;c.depthMask(f)};this.setClearColorHex=function(f,s){var n=new THREE.Color(f);c.clearColor(n.r,n.g,n.b,s)};this.setClearColor=function(f,s){c.clearColor(f.r,f.g,f.b,s)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|
-c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(f){U.darkness=f};this.initMaterial=function(f,s,n,k){var o,w,x;if(f instanceof THREE.MeshDepthMaterial)x="depth";else if(f instanceof THREE.ShadowVolumeDynamicMaterial)x="shadowVolumeDynamic";else if(f instanceof THREE.MeshNormalMaterial)x="normal";else if(f instanceof THREE.MeshBasicMaterial)x="basic";else if(f instanceof THREE.MeshLambertMaterial)x="lambert";else if(f instanceof THREE.MeshPhongMaterial)x="phong";else if(f instanceof THREE.LineBasicMaterial)x=
-"basic";else f instanceof THREE.ParticleBasicMaterial&&(x="particle_basic");if(x){var u=THREE.ShaderLib[x];f.uniforms=Uniforms.clone(u.uniforms);f.vertexShader=u.vertexShader;f.fragmentShader=u.fragmentShader}var A,t,y;A=y=u=0;for(t=s.length;A<t;A++){w=s[A];w instanceof THREE.DirectionalLight&&y++;w instanceof THREE.PointLight&&u++}if(u+y<=4)s=y;else{s=Math.ceil(4*y/(u+y));u=4-s}w={directional:s,point:u};y=50;if(k!==undefined&&k instanceof THREE.SkinnedMesh)y=k.bones.length;var z;a:{A=f.fragmentShader;
-t=f.vertexShader;u=f.uniforms;s=f.attributes;n={map:!!f.map,envMap:!!f.envMap,lightMap:!!f.lightMap,vertexColors:f.vertexColors,fog:n,sizeAttenuation:f.sizeAttenuation,skinning:f.skinning,morphTargets:f.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:w.directional,maxPointLights:w.point,maxBones:y};var D;w=[];if(x)w.push(x);else{w.push(A);w.push(t)}for(D in n){w.push(D);w.push(n[D])}x=w.join();D=0;for(w=pa.length;D<w;D++)if(pa[D].code==x){z=pa[D].program;break a}D=c.createProgram();
-prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,n.fog?"#define USE_FOG":"",n.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.lightMap?"#define USE_LIGHTMAP":"",n.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?
-"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,"#define MAX_BONES "+n.maxBones,n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.lightMap?"#define USE_LIGHTMAP":"",n.vertexColors?"#define USE_COLOR":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.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");
+R;this.autoClear=!0;this.sortObjects=!0;(function(f,s,n,k){try{if(!(c=R.getContext("experimental-webgl",{antialias:f,stencil:k})))throw"Error creating WebGL context.";}catch(o){console.error(o)}console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION));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(s.r,s.g,s.b,n)})($a,vb,wb,Za);this.context=c;if(Za){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,ca("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(U.program,ca("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 J={};J.vertices=new Float32Array(16);J.faces=new Uint16Array(6);b=0;J.vertices[b++]=-1;J.vertices[b++]=-1;J.vertices[b++]=0;J.vertices[b++]=0;J.vertices[b++]=1;J.vertices[b++]=-1;J.vertices[b++]=1;J.vertices[b++]=0;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=1;J.vertices[b++]=-1;
+J.vertices[b++]=1;J.vertices[b++]=0;J.vertices[b++]=1;b=0;J.faces[b++]=0;J.faces[b++]=1;J.faces[b++]=2;J.faces[b++]=0;J.faces[b++]=2;J.faces[b++]=3;J.vertexBuffer=c.createBuffer();J.elementBuffer=c.createBuffer();J.tempTexture=c.createTexture();J.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,J.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,J.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,J.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,J.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,
+J.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,J.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);if(c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){J.hasVertexTexture=!1;J.program=c.createProgram();c.attachShader(J.program,ca("fragment",THREE.ShaderLib.lensFlare.fragmentShader));c.attachShader(J.program,ca("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{J.hasVertexTexture=!0;J.program=c.createProgram();
+c.attachShader(J.program,ca("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));c.attachShader(J.program,ca("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}c.linkProgram(J.program);J.attributes={};J.uniforms={};J.attributes.vertex=c.getAttribLocation(J.program,"position");J.attributes.uv=c.getAttribLocation(J.program,"UV");J.uniforms.renderType=c.getUniformLocation(J.program,"renderType");J.uniforms.map=c.getUniformLocation(J.program,"map");J.uniforms.occlusionMap=c.getUniformLocation(J.program,
+"occlusionMap");J.uniforms.opacity=c.getUniformLocation(J.program,"opacity");J.uniforms.scale=c.getUniformLocation(J.program,"scale");J.uniforms.rotation=c.getUniformLocation(J.program,"rotation");J.uniforms.screenPosition=c.getUniformLocation(J.program,"screenPosition");c.enableVertexAttribArray(J.attributes.vertex);c.enableVertexAttribArray(J.attributes.uv);_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=
+0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=c.createBuffer();_sprite.elementBuffer=
+c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,_sprite.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,_sprite.faces,c.STATIC_DRAW);_sprite.program=c.createProgram();c.attachShader(_sprite.program,ca("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(_sprite.program,ca("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(_sprite.program);_sprite.attributes=
+{};_sprite.uniforms={};_sprite.attributes.position=c.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=c.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=c.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=c.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=c.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=c.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=c.getUniformLocation(_sprite.program,
+"alignment");_sprite.uniforms.map=c.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=c.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=c.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=c.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=c.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=c.getUniformLocation(_sprite.program,
+"modelViewMatrix");_sprite.uniforms.projectionMatrix=c.getUniformLocation(_sprite.program,"projectionMatrix");c.enableVertexAttribArray(_sprite.attributes.position);c.enableVertexAttribArray(_sprite.attributes.uv);this.setSize=function(f,s){R.width=f;R.height=s;this.setViewport(0,0,R.width,R.height)};this.setViewport=function(f,s,n,k){wa=f;qa=s;ya=n;za=k;c.viewport(wa,qa,ya,za)};this.setScissor=function(f,s,n,k){c.scissor(f,s,n,k)};this.enableScissorTest=function(f){f?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};
+this.enableDepthBufferWrite=function(f){ta=f;c.depthMask(f)};this.setClearColorHex=function(f,s){var n=new THREE.Color(f);c.clearColor(n.r,n.g,n.b,s)};this.setClearColor=function(f,s){c.clearColor(f.r,f.g,f.b,s)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(f){U.darkness=f};this.initMaterial=function(f,s,n,k){var o,w,x;if(f instanceof THREE.MeshDepthMaterial)x="depth";else if(f instanceof THREE.ShadowVolumeDynamicMaterial)x=
+"shadowVolumeDynamic";else if(f instanceof THREE.MeshNormalMaterial)x="normal";else if(f instanceof THREE.MeshBasicMaterial)x="basic";else if(f instanceof THREE.MeshLambertMaterial)x="lambert";else if(f instanceof THREE.MeshPhongMaterial)x="phong";else if(f instanceof THREE.LineBasicMaterial)x="basic";else f instanceof THREE.ParticleBasicMaterial&&(x="particle_basic");if(x){var u=THREE.ShaderLib[x];f.uniforms=Uniforms.clone(u.uniforms);f.vertexShader=u.vertexShader;f.fragmentShader=u.fragmentShader}var A,
+t,y;A=y=u=0;for(t=s.length;A<t;A++){w=s[A];w instanceof THREE.DirectionalLight&&y++;w instanceof THREE.PointLight&&u++}if(u+y<=4)s=y;else{s=Math.ceil(4*y/(u+y));u=4-s}w={directional:s,point:u};y=50;if(k!==undefined&&k instanceof THREE.SkinnedMesh)y=k.bones.length;var z;a:{A=f.fragmentShader;t=f.vertexShader;u=f.uniforms;s=f.attributes;n={map:!!f.map,envMap:!!f.envMap,lightMap:!!f.lightMap,vertexColors:f.vertexColors,fog:n,sizeAttenuation:f.sizeAttenuation,skinning:f.skinning,morphTargets:f.morphTargets,
+maxMorphTargets:this.maxMorphTargets,maxDirLights:w.directional,maxPointLights:w.point,maxBones:y};var D;w=[];if(x)w.push(x);else{w.push(A);w.push(t)}for(D in n){w.push(D);w.push(n[D])}x=w.join();D=0;for(w=pa.length;D<w;D++)if(pa[D].code==x){z=pa[D].program;break a}D=c.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,n.fog?"#define USE_FOG":"",n.fog instanceof THREE.FogExp2?"#define FOG_EXP2":
+"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.lightMap?"#define USE_LIGHTMAP":"",n.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,"#define MAX_BONES "+n.maxBones,n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.lightMap?"#define USE_LIGHTMAP":
+"",n.vertexColors?"#define USE_COLOR":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.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");
 c.attachShader(D,ca("fragment",prefix_fragment+A));c.attachShader(D,ca("vertex",prefix_vertex+t));c.linkProgram(D);c.getProgramParameter(D,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(D,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");D.uniforms={};D.attributes={};var B;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(B in u)A.push(B);
 B=A;u=0;for(A=B.length;u<A;u++){t=B[u];D.uniforms[t]=c.getUniformLocation(D,t)}A=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(B=0;B<n.maxMorphTargets;B++)A.push("morphTarget"+B);for(z in s)A.push(z);z=A;B=0;for(s=z.length;B<s;B++){n=z[B];D.attributes[n]=c.getAttribLocation(D,n)}pa.push({program:D,code:x});z=D}f.program=z;z=f.program.attributes;c.enableVertexAttribArray(z.position);z.color>=0&&c.enableVertexAttribArray(z.color);z.normal>=
 0&&c.enableVertexAttribArray(z.normal);z.tangent>=0&&c.enableVertexAttribArray(z.tangent);if(f.skinning&&z.skinVertexA>=0&&z.skinVertexB>=0&&z.skinIndex>=0&&z.skinWeight>=0){c.enableVertexAttribArray(z.skinVertexA);c.enableVertexAttribArray(z.skinVertexB);c.enableVertexAttribArray(z.skinIndex);c.enableVertexAttribArray(z.skinWeight)}for(o in f.attributes)z[o]>=0&&c.enableVertexAttribArray(z[o]);if(f.morphTargets){f.numSupportedMorphTargets=0;if(z.morphTarget0>=0){c.enableVertexAttribArray(z.morphTarget0);

+ 31 - 24
examples/webgl_sprites.html

@@ -16,6 +16,7 @@
 
 	<body>
 		<script type="text/javascript" src="../build/Three.js"></script>
+		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 
 		<script type="text/javascript">
@@ -32,9 +33,9 @@
 
 			var windowHalfX = window.innerWidth / 2;
 			var windowHalfY = window.innerHeight / 2;
-			
 
 			init();
+			animate();
 
 			function init() {
 
@@ -45,7 +46,7 @@
 				camera.position.z = 1500;
 
 				scene = new THREE.Scene();
-	
+
 
 				// create sprites
 
@@ -53,47 +54,47 @@
 				var radius = 500;
 				var mapA =  ImageUtils.loadTexture( "textures/sprite0.png" );
 				var mapB =  ImageUtils.loadTexture( "textures/sprite1.png" );
-				
+
 				nodeA = new THREE.Object3D();
-				
+
 				for( var a = 0; a < amount; a++ ) {
-					
+
 					var sprite = new THREE.Sprite( { map: mapA, useScreenCoordinates: false } );
-					sprite.position.set( Math.random() - 0.5, 
+					sprite.position.set( Math.random() - 0.5,
 					                     Math.random() - 0.5,
 					                     Math.random() - 0.5 );
-					
+
 					if( sprite.position.z < 0 ) {
-						
+
 						sprite.map = mapB;
-						
+
 					}
-					
+
 					sprite.position.normalize();
 					sprite.position.multiplyScalar( radius );
-					
+
 					nodeA.addChild( sprite );
 				}
-				
+
 				scene.addChild( nodeA );
 
 				// add 2d-sprites
-				
+
 				sprite = new THREE.Sprite( { map: mapA, alignment:THREE.SpriteAlignment.topLeft } );
 				sprite.position.set( 100, 100, 0 );
 				sprite.opacity = 0.25;
 				scene.addChild( sprite );
-						
+
 				sprite = new THREE.Sprite( { map: mapA, alignment:THREE.SpriteAlignment.topLeft } );
 				sprite.position.set( 150, 150, 2 );
 				sprite.opacity = 0.5;
 				scene.addChild( sprite );
-					
+
 				sprite = new THREE.Sprite( { map: mapA, alignment:THREE.SpriteAlignment.topLeft } );
 				sprite.position.set( 200, 200, 3 );
 				sprite.opacity = 1;
 				scene.addChild( sprite );
-				
+
 
 
 				// renderer
@@ -102,7 +103,7 @@
 				renderer.setClearColorHex( 0x000000, 1 );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.sortObjects = true;
-				
+
 				container.appendChild( renderer.domElement );
 
 				if ( statsEnabled ) {
@@ -115,17 +116,25 @@
 
 				}
 
-				setInterval( loop, 1000 / 60 );
 			}
 
 
-			function loop() {
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
+			function render() {
+
+				for ( var c = 0; c < nodeA.children.length; c++ ) {
 
-				for( var c = 0; c < nodeA.children.length; c++ ) {
-					
 					var sprite = nodeA.children[ c ];
 					var scale = Math.sin( time + sprite.position.x * 0.01 ) * 0.3 + 1.0;
-					
+
 					sprite.rotation += 0.1 * ( c / nodeA.children.length );
 					sprite.scale.set( scale, scale, 1.0 );
 					sprite.opacity = Math.sin( time + sprite.position.x * 0.01 ) * 0.4 + 0.6;
@@ -139,8 +148,6 @@
 
 				renderer.render( scene, camera );
 
-				if ( statsEnabled ) stats.update();
-
 			}
 
 			function log( text ) {

+ 21 - 18
examples/webgl_stencil.html

@@ -16,11 +16,11 @@
 
 	<body>
 		<script type="text/javascript" src="../build/Three.js"></script>
+		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 
 
 		<script type="text/javascript">
-			var statsEnabled = true;
 
 			var container, stats;
 
@@ -36,6 +36,7 @@
 			document.addEventListener( 'mousemove', onDocumentMouseMove, false );
 
 			init();
+			animate();
 
 			function init() {
 
@@ -46,7 +47,7 @@
 				camera.position.z = 250;
 
 				scene = new THREE.Scene();
-	
+
 
 				// world
 
@@ -72,8 +73,8 @@
 				new THREE.ShadowVolume( mesh1 )
 				new THREE.ShadowVolume( mesh2 )
 				new THREE.ShadowVolume( mesh3 )
-	
-	
+
+
 				// moving objects
 
 				var cube = new Cube( 40, 40, 40 );
@@ -85,7 +86,7 @@
 
 				boxMesh = new THREE.Mesh( cube, material2 );
 				scene.addChild( boxMesh );
-				
+
 				new THREE.ShadowVolume( mesh );
 				new THREE.ShadowVolume( boxMesh );
 
@@ -108,17 +109,12 @@
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 
-				if ( statsEnabled ) {
-
-					stats = new Stats();
-					stats.domElement.style.position = 'absolute';
-					stats.domElement.style.top = '0px';
-					stats.domElement.style.zIndex = 100;
-					container.appendChild( stats.domElement );
-
-				}
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				stats.domElement.style.zIndex = 100;
+				container.appendChild( stats.domElement );
 
-				setInterval( loop, 1000 / 60 );
 			}
 
 
@@ -129,9 +125,18 @@
 
 			}
 
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
 			var t = 0;
 
-			function loop() {
+			function render() {
 
 				mesh.position.x = Math.sin( t ) * 100;
 				mesh.position.y = Math.cos( t ) * 100;
@@ -158,8 +163,6 @@
 
 				renderer.render( scene, camera );
 
-				if ( statsEnabled ) stats.update();
-
 			}
 
 			function log( text ) {

+ 19 - 16
examples/webgl_stencilLensFlare.html

@@ -16,10 +16,10 @@
 
 	<body>
 		<script type="text/javascript" src="../build/Three.js"></script>
+		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 
 		<script type="text/javascript">
-			var statsEnabled = true;
 
 			var container, stats;
 
@@ -35,6 +35,7 @@
 			document.addEventListener( 'mousemove', onDocumentMouseMove, false );
 
 			init();
+			animate();
 
 			function init() {
 
@@ -45,7 +46,7 @@
 				camera.position.z = 250;
 
 				scene = new THREE.Scene();
-	
+
 
 				// world
 
@@ -109,7 +110,7 @@
 				lensFlare.add( ImageUtils.loadTexture( "textures/lensflare1.png" ), 256, 0.33, THREE.AdditiveBlending );
 				lensFlare.add( lensFlare.lensFlares[ 1 ].texture, 300, 0.66, THREE.AdditiveBlending );
 				lensFlare.add( lensFlare.lensFlares[ 1 ].texture, 400, 1.0, THREE.AdditiveBlending );
-	
+
 				lightCube.addChild( lensFlare );
 
 
@@ -120,17 +121,12 @@
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 
-				if ( statsEnabled ) {
-
-					stats = new Stats();
-					stats.domElement.style.position = 'absolute';
-					stats.domElement.style.top = '0px';
-					stats.domElement.style.zIndex = 100;
-					container.appendChild( stats.domElement );
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				stats.domElement.style.zIndex = 100;
+				container.appendChild( stats.domElement );
 
-				}
-
-				setInterval( loop, 1000 / 60 );
 			}
 
 
@@ -141,9 +137,18 @@
 
 			}
 
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
 			var t = 0;
 
-			function loop() {
+			function render() {
 
 				mesh.position.x = Math.sin( t ) * 100;
 				mesh.position.y = Math.cos( t ) * 100;
@@ -170,8 +175,6 @@
 
 				renderer.render( scene, camera );
 
-				if ( statsEnabled ) stats.update();
-
 			}
 
 			function log( text ) {

+ 8 - 0
src/renderers/WebGLRenderer.js

@@ -4109,6 +4109,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
+		console.log(
+			navigator.userAgent + " | " +
+			_gl.getParameter( _gl.VERSION ) + " | " +
+			_gl.getParameter( _gl.VENDOR ) + " | " +
+			_gl.getParameter( _gl.RENDERER ) + " | " +
+			_gl.getParameter( _gl.SHADING_LANGUAGE_VERSION )
+		);
+
 		_gl.clearColor( 0, 0, 0, 1 );
 		_gl.clearDepth( 1 );