From 25d6480cf614c7386f710ab907d956b36928c781 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sun, 2 Oct 2011 00:08:40 +0200 Subject: [PATCH] Fixed yet more examples. --- build/Three.js | 290 ++++++++++++------------- build/custom/ThreeExtras.js | 90 ++++---- build/custom/ThreeWebGL.js | 58 ++--- examples/webgl_particles_random.html | 1 + examples/webgl_particles_sprites.html | 1 + examples/webgl_postprocessing_dof.html | 1 + examples/webgl_ribbons.html | 3 +- examples/webgl_rtt.html | 2 +- examples/webgl_sandbox.html | 109 +--------- examples/webgl_utf8loader.html | 10 +- src/extras/loaders/SceneLoader.js | 2 + src/renderers/WebGLRenderer.js | 1 + 12 files changed, 235 insertions(+), 333 deletions(-) diff --git a/build/Three.js b/build/Three.js index a876f4eca8..39b663021a 100644 --- a/build/Three.js +++ b/build/Three.js @@ -27,7 +27,7 @@ THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,m,k,n, c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,m=THREE.Matrix4.__v3;m.sub(b,c).normalize();if(m.length()===0)m.z=1;f.cross(e,m).normalize();f.length()===0&&(m.x+=1.0E-4,f.cross(e,m).normalize());h.cross(m,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=m.x;this.n21=f.y;this.n22=h.y;this.n23=m.y;this.n31=f.z;this.n32=h.z;this.n33=m.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,h=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*h; b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*h;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*h;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+ e*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,h=b.n13,m=b.n14,k=b.n21,n=b.n22,u=b.n23,p=b.n24,v=b.n31,t=b.n32,x=b.n33,w=b.n34,y=b.n41,z=b.n42,C=b.n43,A=b.n44,F=c.n11,D=c.n12, -I=c.n13,P=c.n14,S=c.n21,K=c.n22,H=c.n23,G=c.n24,Y=c.n31,E=c.n32,Q=c.n33,R=c.n34,W=c.n41,X=c.n42,o=c.n43,ea=c.n44;this.n11=e*F+f*S+h*Y+m*W;this.n12=e*D+f*K+h*E+m*X;this.n13=e*I+f*H+h*Q+m*o;this.n14=e*P+f*G+h*R+m*ea;this.n21=k*F+n*S+u*Y+p*W;this.n22=k*D+n*K+u*E+p*X;this.n23=k*I+n*H+u*Q+p*o;this.n24=k*P+n*G+u*R+p*ea;this.n31=v*F+t*S+x*Y+w*W;this.n32=v*D+t*K+x*E+w*X;this.n33=v*I+t*H+x*Q+w*o;this.n34=v*P+t*G+x*R+w*ea;this.n41=y*F+z*S+C*Y+A*W;this.n42=y*D+z*K+C*E+A*X;this.n43=y*I+z*H+C*Q+A*o;this.n44=y* +J=c.n13,P=c.n14,S=c.n21,I=c.n22,H=c.n23,G=c.n24,Y=c.n31,E=c.n32,Q=c.n33,R=c.n34,W=c.n41,X=c.n42,o=c.n43,ea=c.n44;this.n11=e*F+f*S+h*Y+m*W;this.n12=e*D+f*I+h*E+m*X;this.n13=e*J+f*H+h*Q+m*o;this.n14=e*P+f*G+h*R+m*ea;this.n21=k*F+n*S+u*Y+p*W;this.n22=k*D+n*I+u*E+p*X;this.n23=k*J+n*H+u*Q+p*o;this.n24=k*P+n*G+u*R+p*ea;this.n31=v*F+t*S+x*Y+w*W;this.n32=v*D+t*I+x*E+w*X;this.n33=v*J+t*H+x*Q+w*o;this.n34=v*P+t*G+x*R+w*ea;this.n41=y*F+z*S+C*Y+A*W;this.n42=y*D+z*I+C*E+A*X;this.n43=y*J+z*H+C*Q+A*o;this.n44=y* P+z*G+C*R+A*ea;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*= b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,e=this.n13,f=this.n14,h=this.n21,m=this.n22,k=this.n23,n=this.n24,u=this.n31,p=this.n32,v=this.n33,t=this.n34,x=this.n41,w=this.n42,y=this.n43,z=this.n44;return f*k*p*x-e*n*p*x-f*m*v*x+c*n*v*x+e*m*t*x-c*k*t*x-f*k*u*w+e*n*u*w+f*h*v*w-b*n*v*w-e*h*t*w+b*k*t*w+f*m*u*y-c*n*u*y-f*h*p*y+b*n*p*y+c*h*t*y-b*m*t*y-e*m*u*z+c*k*u*z+e*h*p*z-b*k*p*z-c*h* v*z+b*m*v*z},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34= @@ -54,17 +54,17 @@ this.rotation.setRotationFromMatrix(this.matrix)},add:function(b){if(this.childr c){var e,f,h;e=0;for(f=this.children.length;e=0&&h>=0&&m>=0&&n>=0?!0:k<0&&h<0||m<0&&n<0?!1:(k<0?c=Math.max(c,k/(k-h)):h<0&&(f=Math.min(f,k/(k-h))),m<0?c=Math.max(c,m/(m-n)):n<0&&(f=Math.min(f,m/(m-n))),fo&&k.positionScreen.z0&&K.z<1))ga=D[F]=D[F]||new THREE.RenderableParticle,F++,A=ga,A.x=K.x/K.w,A.y=K.y/K.w,A.z= -K.z,A.rotation=Z.rotation.z,A.scale.x=Z.scale.x*Math.abs(A.x-(K.x+h.projectionMatrix.n11)/(K.w+h.projectionMatrix.n14)),A.scale.y=Z.scale.y*Math.abs(A.y-(K.y+h.projectionMatrix.n22)/(K.w+h.projectionMatrix.n24)),A.materials=Z.materials,P.push(A);m&&P.sort(c);return P}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)}; +THREE.Projector=function(){function b(){var b=u[n]=u[n]||new THREE.RenderableVertex;n++;return b}function c(b,e){return e.z-b.z}function e(b,e){var c=0,f=1,k=b.z+b.w,h=e.z+e.w,m=-b.z+b.w,n=-e.z+e.w;return k>=0&&h>=0&&m>=0&&n>=0?!0:k<0&&h<0||m<0&&n<0?!1:(k<0?c=Math.max(c,k/(k-h)):h<0&&(f=Math.min(f,k/(k-h))),m<0?c=Math.max(c,m/(m-n)):n<0&&(f=Math.min(f,m/(m-n))),fo&&k.positionScreen.z0&&I.z<1))ga=D[F]=D[F]||new THREE.RenderableParticle,F++,A=ga,A.x=I.x/I.w,A.y=I.y/I.w,A.z= +I.z,A.rotation=Z.rotation.z,A.scale.x=Z.scale.x*Math.abs(A.x-(I.x+h.projectionMatrix.n11)/(I.w+h.projectionMatrix.n14)),A.scale.y=Z.scale.y*Math.abs(A.y-(I.y+h.projectionMatrix.n22)/(I.w+h.projectionMatrix.n24)),A.materials=Z.materials,P.push(A);m&&P.sort(c);return P}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=Math.PI/360,e=b.x*c,f=b.y*c,h=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-h),h=Math.sin(-h),m=Math.cos(e),e=Math.sin(e),k=b*c,n=f*h;this.w=k*m-n*e;this.x=k*e+n*m;this.y=f*c*m+b*h*e;this.z=b*h*m-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e); this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},multiplySelf:function(b){var c= @@ -79,8 +79,8 @@ c;b++)e=this.faces[b],e.centroid.set(0,0,0),e instanceof THREE.Face3?(e.centroid e,f,h,m,k,n=new THREE.Vector3,u=new THREE.Vector3;f=0;for(h=this.faces.length;f0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,e=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;c0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b* +u.height=v;N.set(-t,-x,t,x);O.set(-t,-x,t,x);C=1;A=0;S=P=J=D=F=null};this.setClearColor=function(b,e){y.copy(b);z=e;O.set(-t,-x,t,x)};this.setClearColorHex=function(b,e){y.setHex(b);z=e;O.set(-t,-x,t,x)};this.clear=function(){w.setTransform(1,0,0,-1,t,x);O.isEmpty()||(O.minSelf(N),O.inflate(2),z<1&&w.clearRect(Math.floor(O.getX()),Math.floor(O.getY()),Math.floor(O.getWidth()),Math.floor(O.getHeight())),z>0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b* 255)+","+z+")"),w.fillRect(Math.floor(O.getX()),Math.floor(O.getY()),Math.floor(O.getWidth()),Math.floor(O.getHeight()))),O.empty())};this.render=function(b,u){function p(b){var e,c,f,k=b.lights;oa.setRGB(0,0,0);xa.setRGB(0,0,0);va.setRGB(0,0,0);b=0;for(e=k.length;b>1,v=p.height>>1,m=k.scale.x*t,u=k.scale.y*x,o=m*Fa,n=u*v,M.set(b.x-o,b.y-n,b.x+o,b.y+n),N.intersects(M)&&(w.save(),w.translate(b.x,b.y),w.rotate(-k.rotation),w.scale(m,-u),w.translate(-Fa,-v),w.drawImage(p,0,0),w.restore())}else m instanceof THREE.ParticleCanvasMaterial&&(o=k.scale.x*t,n=k.scale.y*x,M.set(b.x-o,b.y-n,b.x+o,b.y+n),N.intersects(M)&&(f(m.color.getContextStyle()),h(m.color.getContextStyle()),w.save(),w.translate(b.x,b.y),w.rotate(-k.rotation),w.scale(o,n),m.program(w), -w.restore()))}function y(b,k,h,m){c(m.opacity);e(m.blending);w.beginPath();w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(k.positionScreen.x,k.positionScreen.y);w.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(I!=b)w.lineWidth=I=b;b=m.linecap;if(P!=b)w.lineCap=P=b;b=m.linejoin;if(S!=b)w.lineJoin=S=b;f(m.color.getContextStyle());w.stroke();M.inflate(m.linewidth*2)}}function z(b,f,k,h,n,t,p,w,x){m.info.render.vertices+=3;m.info.render.faces++;c(w.opacity);e(w.blending); +w.restore()))}function y(b,k,h,m){c(m.opacity);e(m.blending);w.beginPath();w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(k.positionScreen.x,k.positionScreen.y);w.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(J!=b)w.lineWidth=J=b;b=m.linecap;if(P!=b)w.lineCap=P=b;b=m.linejoin;if(S!=b)w.lineJoin=S=b;f(m.color.getContextStyle());w.stroke();M.inflate(m.linewidth*2)}}function z(b,f,k,h,n,t,p,w,x){m.info.render.vertices+=3;m.info.render.faces++;c(w.opacity);e(w.blending); R=b.positionScreen.x;W=b.positionScreen.y;X=f.positionScreen.x;o=f.positionScreen.y;ea=k.positionScreen.x;V=k.positionScreen.y;A(R,W,X,o,ea,V);if(w instanceof THREE.MeshBasicMaterial)if(w.map)w.map.mapping instanceof THREE.UVMapping&&(ra=p.uvs[0],ab(R,W,X,o,ea,V,ra[h].u,ra[h].v,ra[n].u,ra[n].v,ra[t].u,ra[t].v,w.map));else if(w.envMap){if(w.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=u.matrixWorldInverse,pa.copy(p.vertexNormalsWorld[0]),ua=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5, Ca=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[1]),Ea=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,za=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[2]),Ba=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,Ga=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,ab(R,W,X,o,ea,V,ua,Ca,Ea,za,Ba,Ga,w.envMap)}else w.wireframe?F(w.color,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):D(w.color);else if(w instanceof THREE.MeshLambertMaterial)w.map&&!w.wireframe&& (w.map.mapping instanceof THREE.UVMapping&&(ra=p.uvs[0],ab(R,W,X,o,ea,V,ra[h].u,ra[h].v,ra[n].u,ra[n].v,ra[t].u,ra[t].v,w.map)),e(THREE.SubtractiveBlending)),L?!w.wireframe&&w.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3?(U.r=Z.r=ga.r=oa.r,U.g=Z.g=ga.g=oa.g,U.b=Z.b=ga.b=oa.b,v(x,p.v1.positionWorld,p.vertexNormalsWorld[0],U),v(x,p.v2.positionWorld,p.vertexNormalsWorld[1],Z),v(x,p.v3.positionWorld,p.vertexNormalsWorld[2],ga),U.r=Math.max(0,Math.min(w.color.r*U.r,1)),U.g=Math.max(0,Math.min(w.color.g* -U.g,1)),U.b=Math.max(0,Math.min(w.color.b*U.b,1)),Z.r=Math.max(0,Math.min(w.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(w.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(w.color.b*Z.b,1)),ga.r=Math.max(0,Math.min(w.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(w.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(w.color.b*ga.b,1)),la.r=(Z.r+ga.r)*0.5,la.g=(Z.g+ga.g)*0.5,la.b=(Z.b+ga.b)*0.5,qa=Xa(U,Z,ga,la),Ta(R,W,X,o,ea,V,0,0,1,0,0,1,qa)):(ia.r=oa.r,ia.g=oa.g,ia.b=oa.b,v(x,p.centroidWorld,p.normalWorld,ia),da.r=Math.max(0, -Math.min(w.color.r*ia.r,1)),da.g=Math.max(0,Math.min(w.color.g*ia.g,1)),da.b=Math.max(0,Math.min(w.color.b*ia.b,1)),w.wireframe?F(da,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):D(da)):w.wireframe?F(w.color,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):D(w.color);else if(w instanceof THREE.MeshDepthMaterial)na=u.near,ha=u.far,U.r=U.g=U.b=1-Pa(b.positionScreen.z,na,ha),Z.r=Z.g=Z.b=1-Pa(f.positionScreen.z,na,ha),ga.r=ga.g=ga.b=1-Pa(k.positionScreen.z,na,ha),la.r=(Z.r+ -ga.r)*0.5,la.g=(Z.g+ga.g)*0.5,la.b=(Z.b+ga.b)*0.5,qa=Xa(U,Z,ga,la),Ta(R,W,X,o,ea,V,0,0,1,0,0,1,qa);else if(w instanceof THREE.MeshNormalMaterial)da.r=Ua(p.normalWorld.x),da.g=Ua(p.normalWorld.y),da.b=Ua(p.normalWorld.z),w.wireframe?F(da,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):D(da)}function C(b,f,k,h,n,w,t,p,x){m.info.render.vertices+=4;m.info.render.faces++;c(p.opacity);e(p.blending);if(p.map||p.envMap)z(b,f,h,0,1,3,t,p,x),z(n,k,w,1,2,3,t,p,x);else if(R=b.positionScreen.x,W= -b.positionScreen.y,X=f.positionScreen.x,o=f.positionScreen.y,ea=k.positionScreen.x,V=k.positionScreen.y,ma=h.positionScreen.x,aa=h.positionScreen.y,ja=n.positionScreen.x,ca=n.positionScreen.y,ka=w.positionScreen.x,fa=w.positionScreen.y,p instanceof THREE.MeshBasicMaterial)Ya(R,W,X,o,ea,V,ma,aa),p.wireframe?F(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):D(p.color);else if(p instanceof THREE.MeshLambertMaterial)L?!p.wireframe&&p.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length== -4?(U.r=Z.r=ga.r=la.r=oa.r,U.g=Z.g=ga.g=la.g=oa.g,U.b=Z.b=ga.b=la.b=oa.b,v(x,t.v1.positionWorld,t.vertexNormalsWorld[0],U),v(x,t.v2.positionWorld,t.vertexNormalsWorld[1],Z),v(x,t.v4.positionWorld,t.vertexNormalsWorld[3],ga),v(x,t.v3.positionWorld,t.vertexNormalsWorld[2],la),U.r=Math.max(0,Math.min(p.color.r*U.r,1)),U.g=Math.max(0,Math.min(p.color.g*U.g,1)),U.b=Math.max(0,Math.min(p.color.b*U.b,1)),Z.r=Math.max(0,Math.min(p.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(p.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(p.color.b* -Z.b,1)),ga.r=Math.max(0,Math.min(p.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(p.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(p.color.b*ga.b,1)),la.r=Math.max(0,Math.min(p.color.r*la.r,1)),la.g=Math.max(0,Math.min(p.color.g*la.g,1)),la.b=Math.max(0,Math.min(p.color.b*la.b,1)),qa=Xa(U,Z,ga,la),A(R,W,X,o,ma,aa),Ta(R,W,X,o,ma,aa,0,0,1,0,0,1,qa),A(ja,ca,ea,V,ka,fa),Ta(ja,ca,ea,V,ka,fa,1,0,1,1,0,1,qa)):(ia.r=oa.r,ia.g=oa.g,ia.b=oa.b,v(x,t.centroidWorld,t.normalWorld,ia),da.r=Math.max(0,Math.min(p.color.r*ia.r, -1)),da.g=Math.max(0,Math.min(p.color.g*ia.g,1)),da.b=Math.max(0,Math.min(p.color.b*ia.b,1)),Ya(R,W,X,o,ea,V,ma,aa),p.wireframe?F(da,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):D(da)):(Ya(R,W,X,o,ea,V,ma,aa),p.wireframe?F(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):D(p.color));else if(p instanceof THREE.MeshNormalMaterial)da.r=Ua(t.normalWorld.x),da.g=Ua(t.normalWorld.y),da.b=Ua(t.normalWorld.z),Ya(R,W,X,o,ea,V,ma,aa),p.wireframe?F(da,p.wireframeLinewidth, -p.wireframeLinecap,p.wireframeLinejoin):D(da);else if(p instanceof THREE.MeshDepthMaterial)na=u.near,ha=u.far,U.r=U.g=U.b=1-Pa(b.positionScreen.z,na,ha),Z.r=Z.g=Z.b=1-Pa(f.positionScreen.z,na,ha),ga.r=ga.g=ga.b=1-Pa(h.positionScreen.z,na,ha),la.r=la.g=la.b=1-Pa(k.positionScreen.z,na,ha),qa=Xa(U,Z,ga,la),A(R,W,X,o,ma,aa),Ta(R,W,X,o,ma,aa,0,0,1,0,0,1,qa),A(ja,ca,ea,V,ka,fa),Ta(ja,ca,ea,V,ka,fa,1,0,1,1,0,1,qa)}function A(b,e,c,f,k,h){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,h);w.lineTo(b, -e);w.closePath()}function Ya(b,e,c,f,k,h,m,o){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,h);w.lineTo(m,o);w.lineTo(b,e);w.closePath()}function F(b,e,c,k){if(I!=e)w.lineWidth=I=e;if(P!=c)w.lineCap=P=c;if(S!=k)w.lineJoin=S=k;f(b.getContextStyle());w.stroke();M.inflate(e*2)}function D(b){h(b.getContextStyle());w.fill()}function ab(b,e,c,f,k,m,o,n,p,t,u,Fa,v){if(v.image.width!=0){if(v.needsUpdate==!0||ta[v.id]==void 0){var x=v.wrapS==THREE.RepeatWrapping,N=v.wrapT==THREE.RepeatWrapping;ta[v.id]= +U.g,1)),U.b=Math.max(0,Math.min(w.color.b*U.b,1)),Z.r=Math.max(0,Math.min(w.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(w.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(w.color.b*Z.b,1)),ga.r=Math.max(0,Math.min(w.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(w.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(w.color.b*ga.b,1)),ka.r=(Z.r+ga.r)*0.5,ka.g=(Z.g+ga.g)*0.5,ka.b=(Z.b+ga.b)*0.5,qa=Xa(U,Z,ga,ka),Ta(R,W,X,o,ea,V,0,0,1,0,0,1,qa)):(ha.r=oa.r,ha.g=oa.g,ha.b=oa.b,v(x,p.centroidWorld,p.normalWorld,ha),da.r=Math.max(0, +Math.min(w.color.r*ha.r,1)),da.g=Math.max(0,Math.min(w.color.g*ha.g,1)),da.b=Math.max(0,Math.min(w.color.b*ha.b,1)),w.wireframe?F(da,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):D(da)):w.wireframe?F(w.color,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):D(w.color);else if(w instanceof THREE.MeshDepthMaterial)ma=u.near,na=u.far,U.r=U.g=U.b=1-Pa(b.positionScreen.z,ma,na),Z.r=Z.g=Z.b=1-Pa(f.positionScreen.z,ma,na),ga.r=ga.g=ga.b=1-Pa(k.positionScreen.z,ma,na),ka.r=(Z.r+ +ga.r)*0.5,ka.g=(Z.g+ga.g)*0.5,ka.b=(Z.b+ga.b)*0.5,qa=Xa(U,Z,ga,ka),Ta(R,W,X,o,ea,V,0,0,1,0,0,1,qa);else if(w instanceof THREE.MeshNormalMaterial)da.r=Ua(p.normalWorld.x),da.g=Ua(p.normalWorld.y),da.b=Ua(p.normalWorld.z),w.wireframe?F(da,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):D(da)}function C(b,f,k,h,n,w,t,p,x){m.info.render.vertices+=4;m.info.render.faces++;c(p.opacity);e(p.blending);if(p.map||p.envMap)z(b,f,h,0,1,3,t,p,x),z(n,k,w,1,2,3,t,p,x);else if(R=b.positionScreen.x,W= +b.positionScreen.y,X=f.positionScreen.x,o=f.positionScreen.y,ea=k.positionScreen.x,V=k.positionScreen.y,la=h.positionScreen.x,aa=h.positionScreen.y,ia=n.positionScreen.x,ca=n.positionScreen.y,ja=w.positionScreen.x,fa=w.positionScreen.y,p instanceof THREE.MeshBasicMaterial)Ya(R,W,X,o,ea,V,la,aa),p.wireframe?F(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):D(p.color);else if(p instanceof THREE.MeshLambertMaterial)L?!p.wireframe&&p.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length== +4?(U.r=Z.r=ga.r=ka.r=oa.r,U.g=Z.g=ga.g=ka.g=oa.g,U.b=Z.b=ga.b=ka.b=oa.b,v(x,t.v1.positionWorld,t.vertexNormalsWorld[0],U),v(x,t.v2.positionWorld,t.vertexNormalsWorld[1],Z),v(x,t.v4.positionWorld,t.vertexNormalsWorld[3],ga),v(x,t.v3.positionWorld,t.vertexNormalsWorld[2],ka),U.r=Math.max(0,Math.min(p.color.r*U.r,1)),U.g=Math.max(0,Math.min(p.color.g*U.g,1)),U.b=Math.max(0,Math.min(p.color.b*U.b,1)),Z.r=Math.max(0,Math.min(p.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(p.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(p.color.b* +Z.b,1)),ga.r=Math.max(0,Math.min(p.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(p.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(p.color.b*ga.b,1)),ka.r=Math.max(0,Math.min(p.color.r*ka.r,1)),ka.g=Math.max(0,Math.min(p.color.g*ka.g,1)),ka.b=Math.max(0,Math.min(p.color.b*ka.b,1)),qa=Xa(U,Z,ga,ka),A(R,W,X,o,la,aa),Ta(R,W,X,o,la,aa,0,0,1,0,0,1,qa),A(ia,ca,ea,V,ja,fa),Ta(ia,ca,ea,V,ja,fa,1,0,1,1,0,1,qa)):(ha.r=oa.r,ha.g=oa.g,ha.b=oa.b,v(x,t.centroidWorld,t.normalWorld,ha),da.r=Math.max(0,Math.min(p.color.r*ha.r, +1)),da.g=Math.max(0,Math.min(p.color.g*ha.g,1)),da.b=Math.max(0,Math.min(p.color.b*ha.b,1)),Ya(R,W,X,o,ea,V,la,aa),p.wireframe?F(da,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):D(da)):(Ya(R,W,X,o,ea,V,la,aa),p.wireframe?F(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):D(p.color));else if(p instanceof THREE.MeshNormalMaterial)da.r=Ua(t.normalWorld.x),da.g=Ua(t.normalWorld.y),da.b=Ua(t.normalWorld.z),Ya(R,W,X,o,ea,V,la,aa),p.wireframe?F(da,p.wireframeLinewidth, +p.wireframeLinecap,p.wireframeLinejoin):D(da);else if(p instanceof THREE.MeshDepthMaterial)ma=u.near,na=u.far,U.r=U.g=U.b=1-Pa(b.positionScreen.z,ma,na),Z.r=Z.g=Z.b=1-Pa(f.positionScreen.z,ma,na),ga.r=ga.g=ga.b=1-Pa(h.positionScreen.z,ma,na),ka.r=ka.g=ka.b=1-Pa(k.positionScreen.z,ma,na),qa=Xa(U,Z,ga,ka),A(R,W,X,o,la,aa),Ta(R,W,X,o,la,aa,0,0,1,0,0,1,qa),A(ia,ca,ea,V,ja,fa),Ta(ia,ca,ea,V,ja,fa,1,0,1,1,0,1,qa)}function A(b,e,c,f,k,h){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,h);w.lineTo(b, +e);w.closePath()}function Ya(b,e,c,f,k,h,m,o){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,h);w.lineTo(m,o);w.lineTo(b,e);w.closePath()}function F(b,e,c,k){if(J!=e)w.lineWidth=J=e;if(P!=c)w.lineCap=P=c;if(S!=k)w.lineJoin=S=k;f(b.getContextStyle());w.stroke();M.inflate(e*2)}function D(b){h(b.getContextStyle());w.fill()}function ab(b,e,c,f,k,m,o,n,p,t,u,Fa,v){if(v.image.width!=0){if(v.needsUpdate==!0||ta[v.id]==void 0){var x=v.wrapS==THREE.RepeatWrapping,N=v.wrapT==THREE.RepeatWrapping;ta[v.id]= w.createPattern(v.image,x&&N?"repeat":x&&!N?"repeat-x":!x&&N?"repeat-y":"no-repeat");v.needsUpdate=!1}h(ta[v.id]);var x=v.offset.x/v.repeat.x,N=v.offset.y/v.repeat.y,Wa=(v.image.width-1)*v.repeat.x,v=(v.image.height-1)*v.repeat.y,o=(o+x)*Wa,n=(n+N)*v,p=(p+x)*Wa,t=(t+N)*v,u=(u+x)*Wa,Fa=(Fa+N)*v;c-=b;f-=e;k-=b;m-=e;p-=o;t-=n;u-=o;Fa-=n;x=1/(p*Fa-u*t);v=(Fa*c-t*k)*x;t=(Fa*f-t*m)*x;c=(p*k-u*c)*x;f=(p*m-u*f)*x;b=b-v*o-c*n;e=e-t*o-f*n;w.save();w.transform(v,t,c,f,b,e);w.fill();w.restore()}}function Ta(b, e,c,f,k,h,m,o,n,p,t,u,Fa){var v,x;v=Fa.width-1;x=Fa.height-1;m*=v;o*=x;n*=v;p*=x;t*=v;u*=x;c-=b;f-=e;k-=b;h-=e;n-=m;p-=o;t-=m;u-=o;x=1/(n*u-t*p);v=(u*c-p*k)*x;p=(u*f-p*h)*x;c=(n*k-t*c)*x;f=(n*h-t*f)*x;b=b-v*m-c*o;e=e-p*m-f*o;w.save();w.transform(v,p,c,f,b,e);w.clip();w.drawImage(Fa,0,0);w.restore()}function Xa(b,e,c,f){var k=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),m=~~(e.r*255),o=~~(e.g*255),e=~~(e.b*255),n=~~(c.r*255),p=~~(c.g*255),c=~~(c.b*255),t=~~(f.r*255),w=~~(f.g*255),f=~~(f.b*255);Aa[0]=k< 0?0:k>255?255:k;Aa[1]=h<0?0:h>255?255:h;Aa[2]=b<0?0:b>255?255:b;Aa[4]=m<0?0:m>255?255:m;Aa[5]=o<0?0:o>255?255:o;Aa[6]=e<0?0:e>255?255:e;Aa[8]=n<0?0:n>255?255:n;Aa[9]=p<0?0:p>255?255:p;Aa[10]=c<0?0:c>255?255:c;Aa[12]=t<0?0:t>255?255:t;Aa[13]=w<0?0:w>255?255:w;Aa[14]=f<0?0:f>255?255:f;Da.putImageData(Ka,0,0);$.drawImage(wa,0,0);return Ha}function Pa(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Ua(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Na(b,e){var c=e.x-b.x,f=e.y-b.y,k=c*c+f*f;k!=0&&(k=1/Math.sqrt(k), -c*=k,f*=k,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Za,bb,sa,Ia,Oa,Va,$a,ya;this.autoClear?this.clear():w.setTransform(1,0,0,-1,t,x);m.info.render.vertices=0;m.info.render.faces=0;k=n.projectScene(b,u,this.sortElements);(L=b.lights.length>0)&&p(b);Za=0;for(bb=k.length;Za0)&&p(b);Za=0;for(bb=k.length;Za0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m)):h instanceof THREE.PointLight&&(Y.sub(h.position,e.centroidWorld),Y.normalize(),m=e.normalWorld.dot(Y)*h.intensity,m>0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m))}function c(e,c,k,o,n,p){m.info.render.vertices+=3;m.info.render.faces++;R=f(W++); -R.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?I.copy(n.color):n instanceof THREE.MeshLambertMaterial?D?(P.r=S.r,P.g=S.g,P.b=S.b,b(p,o,P),I.r=Math.max(0,Math.min(n.color.r*P.r,1)),I.g=Math.max(0,Math.min(n.color.g*P.g,1)),I.b=Math.max(0,Math.min(n.color.b*P.b,1))):I.copy(n.color):n instanceof THREE.MeshDepthMaterial?(G=1-n.__2near/(n.__farPlusNear- -o.z*n.__farMinusNear),I.setRGB(G,G,G)):n instanceof THREE.MeshNormalMaterial&&I.setRGB(h(o.normalWorld.x),h(o.normalWorld.y),h(o.normalWorld.z));n.wireframe?R.setAttribute("style","fill: none; stroke: "+I.getContextStyle()+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):R.setAttribute("style","fill: "+I.getContextStyle()+"; fill-opacity: "+n.opacity);u.appendChild(R)}function e(e,c,k,o,n,p,t){m.info.render.vertices+= -4;m.info.render.faces++;R=f(W++);R.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?I.copy(p.color):p instanceof THREE.MeshLambertMaterial?D?(P.r=S.r,P.g=S.g,P.b=S.b,b(t,n,P),I.r=Math.max(0,Math.min(p.color.r*P.r,1)),I.g=Math.max(0,Math.min(p.color.g*P.g,1)),I.b=Math.max(0,Math.min(p.color.b*P.b,1))): -I.copy(p.color):p instanceof THREE.MeshDepthMaterial?(G=1-p.__2near/(p.__farPlusNear-n.z*p.__farMinusNear),I.setRGB(G,G,G)):p instanceof THREE.MeshNormalMaterial&&I.setRGB(h(n.normalWorld.x),h(n.normalWorld.y),h(n.normalWorld.z));p.wireframe?R.setAttribute("style","fill: none; stroke: "+I.getContextStyle()+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):R.setAttribute("style","fill: "+I.getContextStyle()+ -"; fill-opacity: "+p.opacity);u.appendChild(R)}function f(b){E[b]==null&&(E[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),o==0&&E[b].setAttribute("shape-rendering","crispEdges"));return E[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var m=this,k=null,n=new THREE.Projector,u=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,v,t,x,w,y,z,C,A=new THREE.Rectangle,F=new THREE.Rectangle,D=!1,I=new THREE.Color(16777215),P=new THREE.Color(16777215),S=new THREE.Color(0), -K=new THREE.Color(0),H=new THREE.Color(0),G,Y=new THREE.Vector3,E=[],Q=[],R,W,X,o=1;this.domElement=u;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":o=1;break;case "low":o=0}};this.setSize=function(b,e){p=b;v=e;t=p/2;x=v/2;u.setAttribute("viewBox",-t+" "+-x+" "+p+" "+v);u.setAttribute("width",p);u.setAttribute("height",v);A.set(-t,-x,t,x)};this.clear=function(){for(;u.childNodes.length>0;)u.removeChild(u.childNodes[0])}; -this.render=function(b,f){var h,p,v,I,P,E,G,U;this.autoClear&&this.clear();m.info.render.vertices=0;m.info.render.faces=0;k=n.projectScene(b,f,this.sortElements);X=W=0;if(D=b.lights.length>0){G=b.lights;S.setRGB(0,0,0);K.setRGB(0,0,0);H.setRGB(0,0,0);h=0;for(p=G.length;h1?1:b}var m=this,k=null,n=new THREE.Projector,u=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,v,t,x,w,y,z,C,A=new THREE.Rectangle,F=new THREE.Rectangle,D=!1,J=new THREE.Color(16777215),P=new THREE.Color(16777215),S=new THREE.Color(0), +I=new THREE.Color(0),H=new THREE.Color(0),G,Y=new THREE.Vector3,E=[],Q=[],R,W,X,o=1;this.domElement=u;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":o=1;break;case "low":o=0}};this.setSize=function(b,e){p=b;v=e;t=p/2;x=v/2;u.setAttribute("viewBox",-t+" "+-x+" "+p+" "+v);u.setAttribute("width",p);u.setAttribute("height",v);A.set(-t,-x,t,x)};this.clear=function(){for(;u.childNodes.length>0;)u.removeChild(u.childNodes[0])}; +this.render=function(b,f){var h,p,v,J,P,E,G,U;this.autoClear&&this.clear();m.info.render.vertices=0;m.info.render.faces=0;k=n.projectScene(b,f,this.sortElements);X=W=0;if(D=b.lights.length>0){G=b.lights;S.setRGB(0,0,0);I.setRGB(0,0,0);H.setRGB(0,0,0);h=0;for(p=G.length;h=0)c&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(b.position,3,o.FLOAT,!1,0,0));else if(m.morphTargetBase){f=k.program.attributes;m.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[m.morphTargetBase]), +m.objectMatrix!==null&&o.uniformMatrix4fv(m.objectMatrix,!1,k._objectMatrixArray);return h}function f(b,c,f,k,h,m){if(k.opacity!=0){var n,f=e(b,c,f,k,m),b=f.attributes,c=!1,f=h.id*16777215+f.id;f!=ia&&(ia=f,c=!0);if(!k.morphTargets&&b.position>=0)c&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(b.position,3,o.FLOAT,!1,0,0));else if(m.morphTargetBase){f=k.program.attributes;m.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[m.morphTargetBase]), o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0)):f.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0));if(m.morphTargetForcedOrder.length)for(var p=0,t=m.morphTargetForcedOrder,w=m.morphTargetInfluences;pu&&(v=x,u=w[v]);o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[v]);o.vertexAttribPointer(f["morphTarget"+p],3,o.FLOAT,!1,0,0);m.__webglMorphTargetInfluences[p]=u;t[v]=1;u=-1;p++}}k.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(k.program.uniforms.morphTargetInfluences,m.__webglMorphTargetInfluences)}if(c){if(h.__webglCustomAttributes)for(n in h.__webglCustomAttributes)b[n]>= 0&&(f=h.__webglCustomAttributes[n],o.bindBuffer(o.ARRAY_BUFFER,f.buffer),o.vertexAttribPointer(b[n],f.size,o.FLOAT,!1,0,0));b.color>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglColorBuffer),o.vertexAttribPointer(b.color,3,o.FLOAT,!1,0,0));b.normal>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglNormalBuffer),o.vertexAttribPointer(b.normal,3,o.FLOAT,!1,0,0));b.tangent>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglTangentBuffer),o.vertexAttribPointer(b.tangent,4,o.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(o.bindBuffer(o.ARRAY_BUFFER, @@ -245,40 +245,40 @@ o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),o.vertex o.UNSIGNED_SHORT,0)):(c&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),o.drawElements(o.TRIANGLES,h.__webglFaceCount,o.UNSIGNED_SHORT,0)),X.info.render.calls++,X.info.render.vertices+=h.__webglFaceCount,X.info.render.faces+=h.__webglFaceCount/3):m instanceof THREE.Line?(m=m.type==THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(k.linewidth),o.drawArrays(m,0,h.__webglLineCount),X.info.render.calls++):m instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,h.__webglParticleCount),X.info.render.calls++): m instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,0,h.__webglVertexCount),X.info.render.calls++)}}function h(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=o.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=o.createBuffer();b.hasPos&&(o.bindBuffer(o.ARRAY_BUFFER,b.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,b.positionArray,o.DYNAMIC_DRAW),o.enableVertexAttribArray(e.attributes.position),o.vertexAttribPointer(e.attributes.position,3,o.FLOAT,!1,0,0));if(b.hasNormal){o.bindBuffer(o.ARRAY_BUFFER, b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,h,k,m,n,p,t,w,u,v,x=b.count*3;for(v=0;v=0;c--)b[c].object==e&&b.splice(c,1)}function P(b){function e(b){var h=[];c=0;for(f=b.length;c=0;c--)b[c].object==e&&b.splice(c,1)}function P(b){function e(b){var h=[];c=0;for(f=b.length;c65535&&(t[o].counter+=1,p=t[o].hash+"_"+t[o].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]={faces:[], -materials:n,vertices:0,numMorphTargets:w})),b.geometryGroups[p].faces.push(h),b.geometryGroups[p].vertices+=m;b.geometryGroupsList=[];for(var u in b.geometryGroups)b.geometryGroups[u].id=ca++,b.geometryGroupsList.push(b.geometryGroups[u])}function S(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function K(b){if(b!=da){switch(b){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD); +materials:n,vertices:0,numMorphTargets:w})),b.geometryGroups[p].faces.push(h),b.geometryGroups[p].vertices+=m;b.geometryGroupsList=[];for(var u in b.geometryGroups)b.geometryGroups[u].id=ca++,b.geometryGroupsList.push(b.geometryGroups[u])}function S(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function I(b){if(b!=da){switch(b){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD); o.blendFunc(o.ZERO,o.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.SRC_COLOR);break;default:o.blendEquationSeparate(o.FUNC_ADD,o.FUNC_ADD),o.blendFuncSeparate(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA)}da=b}}function H(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(o.texParameteri(b,o.TEXTURE_WRAP_S,W(e.wrapS)),o.texParameteri(b,o.TEXTURE_WRAP_T,W(e.wrapT)),o.texParameteri(b,o.TEXTURE_MAG_FILTER,W(e.magFilter)), o.texParameteri(b,o.TEXTURE_MIN_FILTER,W(e.minFilter)),o.generateMipmap(b)):(o.texParameteri(b,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_MAG_FILTER,R(e.magFilter)),o.texParameteri(b,o.TEXTURE_MIN_FILTER,R(e.minFilter)))}function G(b,e){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=o.createTexture(),X.info.memory.textures++;o.activeTexture(o.TEXTURE0+e);o.bindTexture(o.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?o.texImage2D(o.TEXTURE_2D,0,W(b.format),b.image.width,b.image.height,0,W(b.format),o.UNSIGNED_BYTE,b.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,b.image);H(o.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+e),o.bindTexture(o.TEXTURE_2D,b.__webglTexture)}function Y(b){var e=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0; b.__webglRenderbuffer=o.createRenderbuffer();b.__webglTexture=o.createTexture();if(e){o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture);H(o.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var c=0;c<6;c++)b.__webglFramebuffer[c]=o.createFramebuffer(),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,W(b.format),b.width,b.height,0,W(b.format),W(b.type),null)}else b.__webglFramebuffer=o.createFramebuffer(),o.bindTexture(o.TEXTURE_2D,b.__webglTexture),H(o.TEXTURE_2D,b,b),o.texImage2D(o.TEXTURE_2D,0,W(b.format), b.width,b.height,0,W(b.format),W(b.type),null);o.bindRenderbuffer(o.RENDERBUFFER,b.__webglRenderbuffer);if(e)for(c=0;c<6;++c)o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer[c]),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+c,b.__webglTexture,0);else o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER, o.DEPTH_COMPONENT16,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,b.__webglRenderbuffer)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,b.width,b.height);e?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER, -null);o.bindFramebuffer(o.FRAMEBUFFER,null)}var f,h;b?(e=e?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,c=b.width,b=b.height,h=f=0):(e=null,c=qa,b=ra,f=na,h=ha);e!=ma&&(o.bindFramebuffer(o.FRAMEBUFFER,e),o.viewport(f,h,c,b),ma=e)}function E(b){b instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP),o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,b.__webglTexture),o.generateMipmap(o.TEXTURE_2D), +null);o.bindFramebuffer(o.FRAMEBUFFER,null)}var f,h;b?(e=e?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,c=b.width,b=b.height,h=f=0):(e=null,c=qa,b=ra,f=ma,h=na);e!=la&&(o.bindFramebuffer(o.FRAMEBUFFER,e),o.viewport(f,h,c,b),la=e)}function E(b){b instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP),o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,b.__webglTexture),o.generateMipmap(o.TEXTURE_2D), o.bindTexture(o.TEXTURE_2D,null))}function Q(b,e){var c;b=="fragment"?c=o.createShader(o.FRAGMENT_SHADER):b=="vertex"&&(c=o.createShader(o.VERTEX_SHADER));o.shaderSource(c,e);o.compileShader(c);if(!o.getShaderParameter(c,o.COMPILE_STATUS))return console.error(o.getShaderInfoLog(c)),console.error(e),null;return c}function R(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return o.NEAREST;default:return o.LINEAR}}function W(b){switch(b){case THREE.RepeatWrapping:return o.REPEAT; case THREE.ClampToEdgeWrapping:return o.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return o.MIRRORED_REPEAT;case THREE.NearestFilter:return o.NEAREST;case THREE.NearestMipMapNearestFilter:return o.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return o.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return o.LINEAR;case THREE.LinearMipMapNearestFilter:return o.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return o.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return o.BYTE; case THREE.UnsignedByteType:return o.UNSIGNED_BYTE;case THREE.ShortType:return o.SHORT;case THREE.UnsignedShortType:return o.UNSIGNED_SHORT;case THREE.IntType:return o.INT;case THREE.UnsignedShortType:return o.UNSIGNED_INT;case THREE.FloatType:return o.FLOAT;case THREE.AlphaFormat:return o.ALPHA;case THREE.RGBFormat:return o.RGB;case THREE.RGBAFormat:return o.RGBA;case THREE.LuminanceFormat:return o.LUMINANCE;case THREE.LuminanceAlphaFormat:return o.LUMINANCE_ALPHA}return 0}var X=this,o,ea=[],V=null, -ma=null,aa=-1,ja=null,ca=0,ka=null,fa=null,da=null,U=null,Z=null,ga=null,la=null,ta=null,na=0,ha=0,qa=0,ra=0,ua=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ca=new THREE.Matrix4,Ea=new Float32Array(16),za=new Float32Array(16),Ba=new THREE.Vector4,Ga={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},N=b.canvas!==void 0?b.canvas:document.createElement("canvas"), -O=b.stencil!==void 0?b.stencil:!0,M=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,L=b.antialias!==void 0?b.antialias:!1,ia=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),oa=b.clearAlpha!==void 0?b.clearAlpha:0,xa=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=N;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear= +la=null,aa=-1,ia=null,ca=0,ja=null,fa=null,da=null,U=null,Z=null,ga=null,ka=null,ta=null,ma=0,na=0,qa=0,ra=0,ua=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ca=new THREE.Matrix4,Ea=new Float32Array(16),za=new Float32Array(16),Ba=new THREE.Vector4,Ga={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},N=b.canvas!==void 0?b.canvas:document.createElement("canvas"), +O=b.stencil!==void 0?b.stencil:!0,M=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,L=b.antialias!==void 0?b.antialias:!1,ha=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),oa=b.clearAlpha!==void 0?b.clearAlpha:0,xa=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=N;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear= !0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var va,pa=[],b=THREE.ShaderLib.depthRGBA,wa=THREE.UniformsUtils.clone(b.uniforms),Da=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:wa}),Ka=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader, uniforms:wa,morphTargets:!0});Da._shadowPass=!0;Ka._shadowPass=!0;try{if(!(o=N.getContext("experimental-webgl",{antialias:L,stencil:O,preserveDrawingBuffer:M})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+o.getParameter(o.VERSION)+" | "+o.getParameter(o.VENDOR)+" | "+o.getParameter(o.RENDERER)+" | "+o.getParameter(o.SHADING_LANGUAGE_VERSION))}catch(Aa){console.error(Aa)}o.clearColor(0,0,0,1);o.clearDepth(1);o.clearStencil(0);o.enable(o.DEPTH_TEST);o.depthFunc(o.LEQUAL); -o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE);o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA);o.clearColor(ia.r,ia.g,ia.b,oa);this.context=o;var Ha=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,$={};$.vertices=new Float32Array(16);$.faces=new Uint16Array(6);O=0;$.vertices[O++]=-1;$.vertices[O++]=-1;$.vertices[O++]=0;$.vertices[O++]=1;$.vertices[O++]=1;$.vertices[O++]=-1;$.vertices[O++]=1;$.vertices[O++]=1;$.vertices[O++]=1;$.vertices[O++]= +o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE);o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA);o.clearColor(ha.r,ha.g,ha.b,oa);this.context=o;var Ha=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,$={};$.vertices=new Float32Array(16);$.faces=new Uint16Array(6);O=0;$.vertices[O++]=-1;$.vertices[O++]=-1;$.vertices[O++]=0;$.vertices[O++]=1;$.vertices[O++]=1;$.vertices[O++]=-1;$.vertices[O++]=1;$.vertices[O++]=1;$.vertices[O++]=1;$.vertices[O++]= 1;$.vertices[O++]=1;$.vertices[O++]=0;$.vertices[O++]=-1;$.vertices[O++]=1;$.vertices[O++]=0;O=$.vertices[O++]=0;$.faces[O++]=0;$.faces[O++]=1;$.faces[O++]=2;$.faces[O++]=0;$.faces[O++]=2;$.faces[O++]=3;$.vertexBuffer=o.createBuffer();$.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,$.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,$.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,$.elementBuffer);o.bufferData(o.ELEMENT_ARRAY_BUFFER,$.faces,o.STATIC_DRAW);$.program=o.createProgram(); o.attachShader($.program,Q("fragment",THREE.ShaderLib.sprite.fragmentShader));o.attachShader($.program,Q("vertex",THREE.ShaderLib.sprite.vertexShader));o.linkProgram($.program);$.attributes={};$.uniforms={};$.attributes.position=o.getAttribLocation($.program,"position");$.attributes.uv=o.getAttribLocation($.program,"uv");$.uniforms.uvOffset=o.getUniformLocation($.program,"uvOffset");$.uniforms.uvScale=o.getUniformLocation($.program,"uvScale");$.uniforms.rotation=o.getUniformLocation($.program,"rotation"); $.uniforms.scale=o.getUniformLocation($.program,"scale");$.uniforms.alignment=o.getUniformLocation($.program,"alignment");$.uniforms.color=o.getUniformLocation($.program,"color");$.uniforms.map=o.getUniformLocation($.program,"map");$.uniforms.opacity=o.getUniformLocation($.program,"opacity");$.uniforms.useScreenCoordinates=o.getUniformLocation($.program,"useScreenCoordinates");$.uniforms.affectedByDistance=o.getUniformLocation($.program,"affectedByDistance");$.uniforms.screenPosition=o.getUniformLocation($.program, -"screenPosition");$.uniforms.modelViewMatrix=o.getUniformLocation($.program,"modelViewMatrix");$.uniforms.projectionMatrix=o.getUniformLocation($.program,"projectionMatrix");var Ja=!1;this.setSize=function(b,e){N.width=b;N.height=e;this.setViewport(0,0,N.width,N.height)};this.setViewport=function(b,e,c,f){na=b;ha=e;qa=c;ra=f;o.viewport(na,ha,qa,ra)};this.setScissor=function(b,e,c,f){o.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex= -function(b,e){ia.setHex(b);oa=e;o.clearColor(ia.r,ia.g,ia.b,oa)};this.setClearColor=function(b,e){ia.copy(b);oa=e;o.clearColor(ia.r,ia.g,ia.b,oa)};this.getClearColor=function(){return ia};this.getClearAlpha=function(){return oa};this.clear=function(b,e,c){var f=0;if(b==void 0||b)f|=o.COLOR_BUFFER_BIT;if(e==void 0||e)f|=o.DEPTH_BUFFER_BIT;if(c==void 0||c)f|=o.STENCIL_BUFFER_BIT;o.clear(f)};this.getContext=function(){return o};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix, +"screenPosition");$.uniforms.modelViewMatrix=o.getUniformLocation($.program,"modelViewMatrix");$.uniforms.projectionMatrix=o.getUniformLocation($.program,"projectionMatrix");var Ja=!1;this.setSize=function(b,e){N.width=b;N.height=e;this.setViewport(0,0,N.width,N.height)};this.setViewport=function(b,e,c,f){ma=b;na=e;qa=c;ra=f;o.viewport(ma,na,qa,ra)};this.setScissor=function(b,e,c,f){o.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex= +function(b,e){ha.setHex(b);oa=e;o.clearColor(ha.r,ha.g,ha.b,oa)};this.setClearColor=function(b,e){ha.copy(b);oa=e;o.clearColor(ha.r,ha.g,ha.b,oa)};this.getClearColor=function(){return ha};this.getClearAlpha=function(){return oa};this.clear=function(b,e,c){var f=0;if(b==void 0||b)f|=o.COLOR_BUFFER_BIT;if(e==void 0||e)f|=o.DEPTH_BUFFER_BIT;if(c==void 0||c)f|=o.STENCIL_BUFFER_BIT;o.clear(f)};this.getContext=function(){return o};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix, delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var e=b.geometry.geometryGroups[g];o.deleteBuffer(e.__webglVertexBuffer);o.deleteBuffer(e.__webglNormalBuffer);o.deleteBuffer(e.__webglTangentBuffer);o.deleteBuffer(e.__webglColorBuffer);o.deleteBuffer(e.__webglUVBuffer);o.deleteBuffer(e.__webglUV2Buffer);o.deleteBuffer(e.__webglSkinVertexABuffer);o.deleteBuffer(e.__webglSkinVertexBBuffer);o.deleteBuffer(e.__webglSkinIndicesBuffer); o.deleteBuffer(e.__webglSkinWeightsBuffer);o.deleteBuffer(e.__webglFaceBuffer);o.deleteBuffer(e.__webglLineBuffer);if(e.numMorphTargets)for(var c=0,f=e.numMorphTargets;c=0&&o.enableVertexAttribArray(x.position);x.color>=0&&o.enableVertexAttribArray(x.color);x.normal>=0&&o.enableVertexAttribArray(x.normal);x.tangent>=0&&o.enableVertexAttribArray(x.tangent);b.skinning&&x.skinVertexA>=0&&x.skinVertexB>=0&&x.skinIndex>=0&&x.skinWeight>=0&&(o.enableVertexAttribArray(x.skinVertexA), o.enableVertexAttribArray(x.skinVertexB),o.enableVertexAttribArray(x.skinIndex),o.enableVertexAttribArray(x.skinWeight));if(b.attributes)for(k in b.attributes)x[k]!==void 0&&x[k]>=0&&o.enableVertexAttribArray(x[k]);if(b.morphTargets)for(k=b.numSupportedMorphTargets=0;k=0&&(o.enableVertexAttribArray(x[N]),b.numSupportedMorphTargets++);b.uniformsList=[];for(h in b.uniforms)b.uniformsList.push([b.uniforms[h],h])};this.clearTarget=function(b,e,c,f){Y(b); -this.clear(e,c,f)};this.render=function(b,c,t,N){var M,O,F,D,I,na,L,H,oa=b.lights,G=b.fog;aa=-1;this.shadowMapEnabled&&z(b,c);X.info.render.calls=0;X.info.render.vertices=0;X.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(za);c.projectionMatrix.flattenToArray(Ea);Ca.multiply(c.projectionMatrix,c.matrixWorldInverse);p(Ca);this.initWebGLObjects(b);Y(t);(this.autoClear||N)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil); -I=b.__webglObjects.length;for(N=0;N=0;N--)if(M=b.__webglObjects[N],M.render){L=M.object;H=M.buffer;F=M.opaque;m(L);for(M=0;M=0;N--)if(M=b.__webglObjects[N],M.render){L=M.object;H=M.buffer;F=M.opaque;m(L);for(M=0;M=0;k--)f[k]==h&&f.splice(k,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&I(f.__webglObjectsImmediate,e);e.__webglActive=!1;b.__objectsRemoved.splice(0, -1)}e=0;for(f=b.__webglObjects.length;e0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER, -da,y));Ha&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglNormalBuffer),o.bufferData(o.ARRAY_BUFFER,la,y));Ka&&ma.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,ja,y));za&&ra>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,va,y));za&&V>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,ua,y));Aa&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.__webglFaceBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,ta,y),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, +e.__webglActive=!0}b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){e=b.__objectsRemoved[0];f=b;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)J(f.__webglObjects,e);else if(e instanceof THREE.Sprite){f=f.__webglSprites;h=e;k=void 0;for(k=f.length-1;k>=0;k--)f[k]==h&&f.splice(k,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&J(f.__webglObjectsImmediate,e);e.__webglActive=!1;b.__objectsRemoved.splice(0, +1)}e=0;for(f=b.__webglObjects.length;e0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER, +da,y));Ha&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglNormalBuffer),o.bufferData(o.ARRAY_BUFFER,ka,y));Ka&&la.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,ia,y));za&&ra>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,va,y));za&&V>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,ua,y));Aa&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.__webglFaceBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,ta,y),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, t.__webglLineBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,wa,y));T>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,ca,y),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,aa,y),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ea,y),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,fa,y));M&&(delete t.__inittedArrays,delete t.__colorArray,delete t.__normalArray, delete t.__tangentArray,delete t.__uvArray,delete t.__uv2Array,delete t.__faceArray,delete t.__vertexArray,delete t.__lineArray,delete t.__skinVertexAArray,delete t.__skinVertexBArray,delete t.__skinIndexArray,delete t.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;D(m)}else if(k instanceof THREE.Ribbon){h=k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=o.DYNAMIC_DRAW;n=x=M=M= void 0;u=k.vertices;p=k.colors;w=u.length;t=p.length;N=k.__vertexArray;y=k.__colorArray;O=k.__dirtyColors;if(k.__dirtyVertices){for(M=0;M0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,k,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-k,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,k,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-k,0)));for(n=0;nb&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function h(b){for(E=b.length;--E>=0;){ka=E;fa=E-1;fa<0&&(fa=b.length- -1);for(var c=0,e=w+v*2,c=0;cb&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function h(b){for(E=b.length;--E>=0;){ja=E;fa=E-1;fa<0&&(fa=b.length- +1);for(var c=0,e=w+v*2,c=0;c=0;R--){W=R/v;X=u*(1-W);W=p*Math.sin(W*Math.PI/2);E=0;for(Q=F.length;E=0;R--){W=R/v;X=u*(1-W);W=p*Math.sin(W*Math.PI/2);E=0;for(Q=F.length;E0)for(p=0;p2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return m}u=p;h<=u&&(u=0);p=u+1;h<=p&&(p=0);v=p+1;h<=v&&(v=0);var x;a:{x=b;var w=u,y=p,z=v,C=h,A=k,F=void 0,D=void 0,I=void 0, -P=void 0,S=void 0,K=void 0,H=void 0,G=void 0,Y=void 0,D=x[A[w]].x,I=x[A[w]].y,P=x[A[y]].x,S=x[A[y]].y,K=x[A[z]].x,H=x[A[z]].y;if(1.0E-10>(P-D)*(H-I)-(S-I)*(K-D))x=!1;else{for(F=0;F=0&&R>=0&&X>=0){x=!1; +(function(b){var c=function(b){for(var c=b.length,h=0,m=c-1,k=0;k0)for(p=0;p2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return m}u=p;h<=u&&(u=0);p=u+1;h<=p&&(p=0);v=p+1;h<=v&&(v=0);var x;a:{x=b;var w=u,y=p,z=v,C=h,A=k,F=void 0,D=void 0,J=void 0, +P=void 0,S=void 0,I=void 0,H=void 0,G=void 0,Y=void 0,D=x[A[w]].x,J=x[A[w]].y,P=x[A[y]].x,S=x[A[y]].y,I=x[A[z]].x,H=x[A[z]].y;if(1.0E-10>(P-D)*(H-J)-(S-J)*(I-D))x=!1;else{for(F=0;F=0&&R>=0&&X>=0){x=!1; break a}}x=!0}}if(x){m.push([b[k[u]],b[k[p]],b[k[v]]]);n.push([k[u],k[p],k[v]]);u=p;for(v=p+1;v>7)-127;f|=(k&127)<<16|h<<8;if(f==0&&n==-127)return 0;return(1-2*(m>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,n)}function h(b,c){var e=v(b,c),f=v(b,c+1),k=v(b,c+2);return(v(b,c+3)<<24)+(k<<16)+(f<<8)+e}function u(b,c){var e=v(b,c);return(v(b,c+1)<<8)+e}function p(b,c){var e=v(b,c);return e>127?e-256:e}function v(b,c){return b.charCodeAt(c)&255}function t(c){var e, -f,k;e=h(b,c);f=h(b,c+S);k=h(b,c+K);c=u(b,c+H);A.faces.push(new THREE.Face3(e,f,k,null,null,A.materials[c]))}function x(c){var e,f,k,m,o,p;e=h(b,c);f=h(b,c+S);k=h(b,c+K);m=u(b,c+H);o=h(b,c+G);p=h(b,c+Y);c=h(b,c+E);m=A.materials[m];var t=I[p*3],v=I[p*3+1];p=I[p*3+2];var w=I[c*3],x=I[c*3+1],c=I[c*3+2];A.faces.push(new THREE.Face3(e,f,k,[new THREE.Vector3(I[o*3],I[o*3+1],I[o*3+2]),new THREE.Vector3(t,v,p),new THREE.Vector3(w,x,c)],null,m))}function w(c){var e,f,k,m;e=h(b,c);f=h(b,c+Q);k=h(b,c+R);m=h(b, -c+W);c=u(b,c+X);A.faces.push(new THREE.Face4(e,f,k,m,null,null,A.materials[c]))}function y(c){var e,f,k,m,p,t,v,w;e=h(b,c);f=h(b,c+Q);k=h(b,c+R);m=h(b,c+W);p=u(b,c+X);t=h(b,c+o);v=h(b,c+ea);w=h(b,c+V);c=h(b,c+ma);p=A.materials[p];var x=I[v*3],N=I[v*3+1];v=I[v*3+2];var y=I[w*3],M=I[w*3+1];w=I[w*3+2];var L=I[c*3],z=I[c*3+1],c=I[c*3+2];A.faces.push(new THREE.Face4(e,f,k,m,[new THREE.Vector3(I[t*3],I[t*3+1],I[t*3+2]),new THREE.Vector3(x,N,v),new THREE.Vector3(y,M,w),new THREE.Vector3(L,z,c)],null,p))} -function z(c){var e,f,k,m;e=h(b,c);f=h(b,c+aa);k=h(b,c+ja);c=P[e*2];m=P[e*2+1];e=P[f*2];var o=A.faceVertexUvs[0];f=P[f*2+1];var p=P[k*2];k=P[k*2+1];var t=[];t.push(new THREE.UV(c,m));t.push(new THREE.UV(e,f));t.push(new THREE.UV(p,k));o.push(t)}function C(c){var e,f,k,m,o,p;e=h(b,c);f=h(b,c+ca);k=h(b,c+ka);m=h(b,c+fa);c=P[e*2];o=P[e*2+1];e=P[f*2];p=P[f*2+1];f=P[k*2];var t=A.faceVertexUvs[0];k=P[k*2+1];var u=P[m*2];m=P[m*2+1];var v=[];v.push(new THREE.UV(c,o));v.push(new THREE.UV(e,p));v.push(new THREE.UV(f, -k));v.push(new THREE.UV(u,m));t.push(v)}var A=this,F=0,D,I=[],P=[],S,K,H,G,Y,E,Q,R,W,X,o,ea,V,ma,aa,ja,ca,ka,fa,da,U,Z,ga,la,ta;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(A,f,c);D={signature:b.substr(F,8),header_bytes:v(b,F+8),vertex_coordinate_bytes:v(b,F+9),normal_coordinate_bytes:v(b,F+10),uv_coordinate_bytes:v(b,F+11),vertex_index_bytes:v(b,F+12),normal_index_bytes:v(b,F+13),uv_index_bytes:v(b,F+14),material_index_bytes:v(b,F+15),nvertices:h(b,F+16),nnormals:h(b,F+16+4),nuvs:h(b, -F+16+8),ntri_flat:h(b,F+16+12),ntri_smooth:h(b,F+16+16),ntri_flat_uv:h(b,F+16+20),ntri_smooth_uv:h(b,F+16+24),nquad_flat:h(b,F+16+28),nquad_smooth:h(b,F+16+32),nquad_flat_uv:h(b,F+16+36),nquad_smooth_uv:h(b,F+16+40)};F+=D.header_bytes;S=D.vertex_index_bytes;K=D.vertex_index_bytes*2;H=D.vertex_index_bytes*3;G=D.vertex_index_bytes*3+D.material_index_bytes;Y=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes;E=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*2;Q=D.vertex_index_bytes; -R=D.vertex_index_bytes*2;W=D.vertex_index_bytes*3;X=D.vertex_index_bytes*4;o=D.vertex_index_bytes*4+D.material_index_bytes;ea=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes;V=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*2;ma=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*3;aa=D.uv_index_bytes;ja=D.uv_index_bytes*2;ca=D.uv_index_bytes;ka=D.uv_index_bytes*2;fa=D.uv_index_bytes*3;c=D.vertex_index_bytes*3+D.material_index_bytes;ta=D.vertex_index_bytes* -4+D.material_index_bytes;da=D.ntri_flat*c;U=D.ntri_smooth*(c+D.normal_index_bytes*3);Z=D.ntri_flat_uv*(c+D.uv_index_bytes*3);ga=D.ntri_smooth_uv*(c+D.normal_index_bytes*3+D.uv_index_bytes*3);la=D.nquad_flat*ta;c=D.nquad_smooth*(ta+D.normal_index_bytes*4);ta=D.nquad_flat_uv*(ta+D.uv_index_bytes*4);F+=function(c){for(var f,h,m,n=D.vertex_coordinate_bytes*3,o=c+D.nvertices*n;c=0){y=o.invBindMatrices[v];p.invBindMatrix=y;p.skinningMatrix=new THREE.Matrix4;p.skinningMatrix.multiply(p.world,y);p.weights=[]; for(y=0;y1){o=new THREE.MeshFaceMaterial;for(j=0;j1){o=new THREE.MeshFaceMaterial;for(j=0;j1?e[1].substr(0,c):"0";e[1].length1?e[1].substr(0,c):"0";e[1].lengthc){u=p.output[o];break}m=u!==void 0?u instanceof THREE.Matrix4?m.multiply(m,u):m.multiply(m,n.matrix):m.multiply(m,n.matrix)}else m=m.multiply(m,n.matrix);c=m;e.push({time:b,pos:[c.n14, -c.n24,c.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=e}this.updateMatrix();return this};v.prototype.updateMatrix=function(){this.matrix.identity();for(var b=0;b0&&(this[e.nodeName]=parseFloat(f[0].textContent))}}this.create();return this};G.prototype.create=function(){var b= {},c=this.transparency!==void 0&&this.transparency<1,e;for(e in this)switch(e){case "ambient":case "emission":case "diffuse":case "specular":var f=this[e];if(f instanceof H)if(f.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(f=ta[this.effect.surface.init_from]))b.map=THREE.ImageUtils.loadTexture(Ea+f.init_from),b.map.wrapS=THREE.RepeatWrapping,b.map.wrapT=THREE.RepeatWrapping,b.map.repeat.x=1,b.map.repeat.y=-1}else e=="diffuse"?b.color= f.color.getHex():c||(b[e]=f.color.getHex());break;case "shininess":case "reflectivity":b[e]=this[e];break;case "transparency":if(c)b.transparent=!0,b.opacity=this[e],c=!0}b.shading=Ga;return this.material=new THREE.MeshLambertMaterial(b)};Y.prototype.parse=function(b){for(var c=0;c1&&(Y=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(S,Y);object.name=w;object.position.set(D[0],D[1],D[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=F.visible;V.scene.add(object);V.objects[w]=object;F.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),V.scene.collisions.colliders.push(b)); if(F.castsShadow)b=new THREE.ShadowVolume(S),V.scene.add(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},V.triggers[object.name]=b)}}else D=F.position,r=F.rotation,q=F.quaternion,s=F.scale,q=0,object=new THREE.Object3D,object.name=w,object.position.set(D[0],D[1],D[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], s[1],s[2]),object.visible=F.visible!==void 0?F.visible:!1,V.scene.add(object),V.objects[w]=object,V.empties[w]=object,F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},V.triggers[object.name]=b)}function u(b){return function(c){V.geometries[b]=c;n();W-=1;e.onLoadComplete();v()}}function p(b){return function(c){V.geometries[b]=c}}function v(){e.callbackProgress({totalModels:o,totalTextures:ea,loadedModels:o-W,loadedTextures:ea-X},V);e.onLoadProgress();W==0&&X==0&&c(V)}var t, -x,w,y,z,C,A,F,D,I,P,S,K,H,G,Y,E,Q,R,W,X,o,ea,V;Q=b.data;G=new THREE.BinaryLoader;R=new THREE.JSONLoader;X=W=0;V={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(w in Q.objects)if(F=Q.objects[w],F.meshCollider){b=!0;break}if(b)V.scene.collisions=new THREE.CollisionSystem;if(Q.transform){b=Q.transform.position;I=Q.transform.rotation;var ma=Q.transform.scale;b&&V.scene.position.set(b[0],b[1],b[2]);I&&V.scene.rotation.set(I[0], -I[1],I[2]);ma&&V.scene.scale.set(ma[0],ma[1],ma[2]);(b||I||ma)&&V.scene.updateMatrix()}b=function(){X-=1;v();e.onLoadComplete()};for(z in Q.cameras){I=Q.cameras[z];if(I.type=="perspective")K=new THREE.Camera(I.fov,I.aspect,I.near,I.far);else if(I.type=="ortho")K=new THREE.Camera,K.projectionMatrix=THREE.Matrix4.makeOrtho(I.left,I.right,I.top,I.bottom,I.near,I.far);D=I.position;I=I.target;K.position.set(D[0],D[1],D[2]);K.target.position.set(I[0],I[1],I[2]);V.cameras[z]=K}for(y in Q.lights)z=Q.lights[y], -K=z.color!==void 0?z.color:16777215,I=z.intensity!==void 0?z.intensity:1,z.type=="directional"?(D=z.direction,E=new THREE.DirectionalLight(K,I),E.position.set(D[0],D[1],D[2]),E.position.normalize()):z.type=="point"?(D=z.position,d=z.distance,E=new THREE.PointLight(K,I,d),E.position.set(D[0],D[1],D[2])):z.type=="ambient"&&(E=new THREE.AmbientLight(K)),V.scene.add(E),V.lights[y]=E;for(C in Q.fogs)y=Q.fogs[C],y.type=="linear"?H=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(H=new THREE.FogExp2(0,y.density)), -I=y.color,H.color.setRGB(I[0],I[1],I[2]),V.fogs[C]=H;if(V.cameras&&Q.defaults.camera)V.currentCamera=V.cameras[Q.defaults.camera];if(V.fogs&&Q.defaults.fog)V.scene.fog=V.fogs[Q.defaults.fog];I=Q.defaults.bgcolor;V.bgColor=new THREE.Color;V.bgColor.setRGB(I[0],I[1],I[2]);V.bgColorAlpha=Q.defaults.bgalpha;for(t in Q.geometries)if(C=Q.geometries[t],C.type=="bin_mesh"||C.type=="ascii_mesh")W+=1,e.onLoadStart();o=W;for(t in Q.geometries)C=Q.geometries[t],C.type=="cube"?(S=new THREE.CubeGeometry(C.width, -C.height,C.depth,C.segmentsWidth,C.segmentsHeight,C.segmentsDepth,null,C.flipped,C.sides),V.geometries[t]=S):C.type=="plane"?(S=new THREE.PlaneGeometry(C.width,C.height,C.segmentsWidth,C.segmentsHeight),V.geometries[t]=S):C.type=="sphere"?(S=new THREE.SphereGeometry(C.radius,C.segmentsWidth,C.segmentsHeight),V.geometries[t]=S):C.type=="cylinder"?(S=new THREE.CylinderGeometry(C.topRad,C.botRad,C.height,C.radSegs,C.heightSegs),V.geometries[t]=S):C.type=="torus"?(S=new THREE.TorusGeometry(C.radius,C.tube, -C.segmentsR,C.segmentsT),V.geometries[t]=S):C.type=="icosahedron"?(S=new THREE.IcosahedronGeometry(C.subdivisions),V.geometries[t]=S):C.type=="bin_mesh"?G.load({model:f(C.url,Q.urlBaseType),callback:u(t)}):C.type=="ascii_mesh"?R.load({model:f(C.url,Q.urlBaseType),callback:u(t)}):C.type=="embedded_mesh"&&(C=Q.embeds[C.id])&&R.createModel(C,p(t),"");for(A in Q.textures)if(t=Q.textures[A],t.url instanceof Array){X+=t.url.length;for(G=0;G=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,h=0;h<8;h++){for(var m=0,k=0;k>1^-(n&1);e[8*k+h]=m}f+=c}c=b.length-f;m=new Uint16Array(c);for(h=k=0;h=this.maxCount-3&&n(this)};this.begin=function(){this.count=0; this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(u=this.size-1);var x=Math.floor(p-n);x<1&&(x=1);p=Math.floor(p+n);p>this.size-1&&(p=this.size-1);var w=Math.floor(v-n);w<1&&(w=1);n=Math.floor(v+n);n>this.size-1&&(n=this.size- 1);for(var y,z,C,A,F,D;t0&&(this.field[C+y]+=A)}}};this.addPlaneX=function(b,c){var h,m,k,n,u,p=this.size,v=this.yd,t=this.zd,x=this.field,w=p*Math.sqrt(b/c);w>p&&(w=p);for(h=0;h0)for(m=0;ma&&(a+=Math.PI*2),anglec=(c+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(g).addSelf(k).subSelf(a).clone()}function g(a){for(B=a.length;--B>=0;){T=B;R=B-1;R<0&&(R=a.length- 1);for(var c=0,b=p+n*2,c=0;c=0;J--){L=J/n;N=l*(1-L);L=m*Math.sin(L*Math.PI/2);B=0;for(D=y.length;B=0;J--){L=J/n;N=l*(1-L);L=m*Math.sin(L*Math.PI/2);B=0;for(D=y.length;B0)for(m=0;m2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return h}l=m;g<=l&&(l=0);m=l+1;g<=m&&(m=0);n=m+1;g<=n&&(n=0);var t;a:{t=a;var p=l,x=m,v=n,u=g,z=f,y=void 0,w=void 0,A=void 0, -C=void 0,F=void 0,G=void 0,I=void 0,H=void 0,M=void 0,w=t[z[p]].x,A=t[z[p]].y,C=t[z[x]].x,F=t[z[x]].y,G=t[z[v]].x,I=t[z[v]].y;if(1.0E-10>(C-w)*(I-A)-(F-A)*(G-w))t=!1;else{for(y=0;y=0&&J>=0&&N>=0){t=!1;break a}}t=!0}}if(t){h.push([a[f[l]], +C=void 0,G=void 0,E=void 0,I=void 0,H=void 0,M=void 0,w=t[z[p]].x,A=t[z[p]].y,C=t[z[x]].x,G=t[z[x]].y,E=t[z[v]].x,I=t[z[v]].y;if(1.0E-10>(C-w)*(I-A)-(G-A)*(E-w))t=!1;else{for(y=0;y=0&&J>=0&&N>=0){t=!1;break a}}t=!0}}if(t){h.push([a[f[l]], a[f[m]],a[f[n]]]);k.push([f[l],f[m],f[n]]);l=m;for(n=m+1;n>7)-127;e|=(g&127)<<16|f<<8;if(e==0&&k==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,k)}function g(a,c){var b=n(a,c),e=n(a,c+1),f=n(a,c+2);return(n(a,c+3)<<24)+(f<<16)+(e<<8)+b}function l(a,c){var b=n(a,c);return(n(a,c+1)<<8)+b}function m(a,c){var b=n(a,c);return b>127?b-256:b}function n(a,c){return a.charCodeAt(c)&255}function o(c){var b, -e,f;b=g(a,c);e=g(a,c+F);f=g(a,c+G);c=l(a,c+I);z.faces.push(new THREE.Face3(b,e,f,null,null,z.materials[c]))}function t(c){var b,e,f,h,m,n;b=g(a,c);e=g(a,c+F);f=g(a,c+G);h=l(a,c+I);m=g(a,c+H);n=g(a,c+M);c=g(a,c+B);h=z.materials[h];var o=A[n*3],p=A[n*3+1];n=A[n*3+2];var t=A[c*3],ia=A[c*3+1],c=A[c*3+2];z.faces.push(new THREE.Face3(b,e,f,[new THREE.Vector3(A[m*3],A[m*3+1],A[m*3+2]),new THREE.Vector3(o,p,n),new THREE.Vector3(t,ia,c)],null,h))}function p(c){var b,e,f,h;b=g(a,c);e=g(a,c+D);f=g(a,c+J);h= -g(a,c+L);c=l(a,c+N);z.faces.push(new THREE.Face4(b,e,f,h,null,null,z.materials[c]))}function x(c){var b,e,f,h,m,n,o,p;b=g(a,c);e=g(a,c+D);f=g(a,c+J);h=g(a,c+L);m=l(a,c+N);n=g(a,c+K);o=g(a,c+P);p=g(a,c+E);c=g(a,c+S);m=z.materials[m];var t=A[o*3],ia=A[o*3+1];o=A[o*3+2];var la=A[p*3],ma=A[p*3+1];p=A[p*3+2];var v=A[c*3],u=A[c*3+1],c=A[c*3+2];z.faces.push(new THREE.Face4(b,e,f,h,[new THREE.Vector3(A[n*3],A[n*3+1],A[n*3+2]),new THREE.Vector3(t,ia,o),new THREE.Vector3(la,ma,p),new THREE.Vector3(v,u,c)], +e,f;b=g(a,c);e=g(a,c+G);f=g(a,c+E);c=l(a,c+I);z.faces.push(new THREE.Face3(b,e,f,null,null,z.materials[c]))}function t(c){var b,e,f,h,m,n;b=g(a,c);e=g(a,c+G);f=g(a,c+E);h=l(a,c+I);m=g(a,c+H);n=g(a,c+M);c=g(a,c+B);h=z.materials[h];var o=A[n*3],p=A[n*3+1];n=A[n*3+2];var t=A[c*3],ia=A[c*3+1],c=A[c*3+2];z.faces.push(new THREE.Face3(b,e,f,[new THREE.Vector3(A[m*3],A[m*3+1],A[m*3+2]),new THREE.Vector3(o,p,n),new THREE.Vector3(t,ia,c)],null,h))}function p(c){var b,e,f,h;b=g(a,c);e=g(a,c+D);f=g(a,c+J);h= +g(a,c+L);c=l(a,c+N);z.faces.push(new THREE.Face4(b,e,f,h,null,null,z.materials[c]))}function x(c){var b,e,f,h,m,n,o,p;b=g(a,c);e=g(a,c+D);f=g(a,c+J);h=g(a,c+L);m=l(a,c+N);n=g(a,c+K);o=g(a,c+P);p=g(a,c+F);c=g(a,c+S);m=z.materials[m];var t=A[o*3],ia=A[o*3+1];o=A[o*3+2];var la=A[p*3],ma=A[p*3+1];p=A[p*3+2];var v=A[c*3],u=A[c*3+1],c=A[c*3+2];z.faces.push(new THREE.Face4(b,e,f,h,[new THREE.Vector3(A[n*3],A[n*3+1],A[n*3+2]),new THREE.Vector3(t,ia,o),new THREE.Vector3(la,ma,p),new THREE.Vector3(v,u,c)], null,m))}function v(c){var b,e,f,h;b=g(a,c);e=g(a,c+O);f=g(a,c+U);c=C[b*2];h=C[b*2+1];b=C[e*2];var l=z.faceVertexUvs[0];e=C[e*2+1];var m=C[f*2];f=C[f*2+1];var n=[];n.push(new THREE.UV(c,h));n.push(new THREE.UV(b,e));n.push(new THREE.UV(m,f));l.push(n)}function u(c){var b,e,f,h,l,m;b=g(a,c);e=g(a,c+V);f=g(a,c+T);h=g(a,c+R);c=C[b*2];l=C[b*2+1];b=C[e*2];m=C[e*2+1];e=C[f*2];var n=z.faceVertexUvs[0];f=C[f*2+1];var o=C[h*2];h=C[h*2+1];var p=[];p.push(new THREE.UV(c,l));p.push(new THREE.UV(b,m));p.push(new THREE.UV(e, -f));p.push(new THREE.UV(o,h));n.push(p)}var z=this,y=0,w,A=[],C=[],F,G,I,H,M,B,D,J,L,N,K,P,E,S,O,U,V,T,R,Q,Z,W,$,X,Y;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(z,e,c);w={signature:a.substr(y,8),header_bytes:n(a,y+8),vertex_coordinate_bytes:n(a,y+9),normal_coordinate_bytes:n(a,y+10),uv_coordinate_bytes:n(a,y+11),vertex_index_bytes:n(a,y+12),normal_index_bytes:n(a,y+13),uv_index_bytes:n(a,y+14),material_index_bytes:n(a,y+15),nvertices:g(a,y+16),nnormals:g(a,y+16+4),nuvs:g(a,y+16+ -8),ntri_flat:g(a,y+16+12),ntri_smooth:g(a,y+16+16),ntri_flat_uv:g(a,y+16+20),ntri_smooth_uv:g(a,y+16+24),nquad_flat:g(a,y+16+28),nquad_smooth:g(a,y+16+32),nquad_flat_uv:g(a,y+16+36),nquad_smooth_uv:g(a,y+16+40)};y+=w.header_bytes;F=w.vertex_index_bytes;G=w.vertex_index_bytes*2;I=w.vertex_index_bytes*3;H=w.vertex_index_bytes*3+w.material_index_bytes;M=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes;B=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*2;D=w.vertex_index_bytes; -J=w.vertex_index_bytes*2;L=w.vertex_index_bytes*3;N=w.vertex_index_bytes*4;K=w.vertex_index_bytes*4+w.material_index_bytes;P=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes;E=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*2;S=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*3;O=w.uv_index_bytes;U=w.uv_index_bytes*2;V=w.uv_index_bytes;T=w.uv_index_bytes*2;R=w.uv_index_bytes*3;c=w.vertex_index_bytes*3+w.material_index_bytes;Y=w.vertex_index_bytes* +f));p.push(new THREE.UV(o,h));n.push(p)}var z=this,y=0,w,A=[],C=[],G,E,I,H,M,B,D,J,L,N,K,P,F,S,O,U,V,T,R,Q,Z,W,$,X,Y;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(z,e,c);w={signature:a.substr(y,8),header_bytes:n(a,y+8),vertex_coordinate_bytes:n(a,y+9),normal_coordinate_bytes:n(a,y+10),uv_coordinate_bytes:n(a,y+11),vertex_index_bytes:n(a,y+12),normal_index_bytes:n(a,y+13),uv_index_bytes:n(a,y+14),material_index_bytes:n(a,y+15),nvertices:g(a,y+16),nnormals:g(a,y+16+4),nuvs:g(a,y+16+ +8),ntri_flat:g(a,y+16+12),ntri_smooth:g(a,y+16+16),ntri_flat_uv:g(a,y+16+20),ntri_smooth_uv:g(a,y+16+24),nquad_flat:g(a,y+16+28),nquad_smooth:g(a,y+16+32),nquad_flat_uv:g(a,y+16+36),nquad_smooth_uv:g(a,y+16+40)};y+=w.header_bytes;G=w.vertex_index_bytes;E=w.vertex_index_bytes*2;I=w.vertex_index_bytes*3;H=w.vertex_index_bytes*3+w.material_index_bytes;M=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes;B=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*2;D=w.vertex_index_bytes; +J=w.vertex_index_bytes*2;L=w.vertex_index_bytes*3;N=w.vertex_index_bytes*4;K=w.vertex_index_bytes*4+w.material_index_bytes;P=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes;F=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*2;S=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*3;O=w.uv_index_bytes;U=w.uv_index_bytes*2;V=w.uv_index_bytes;T=w.uv_index_bytes*2;R=w.uv_index_bytes*3;c=w.vertex_index_bytes*3+w.material_index_bytes;Y=w.vertex_index_bytes* 4+w.material_index_bytes;Q=w.ntri_flat*c;Z=w.ntri_smooth*(c+w.normal_index_bytes*3);W=w.ntri_flat_uv*(c+w.uv_index_bytes*3);$=w.ntri_smooth_uv*(c+w.normal_index_bytes*3+w.uv_index_bytes*3);X=w.nquad_flat*Y;c=w.nquad_smooth*(Y+w.normal_index_bytes*4);Y=w.nquad_flat_uv*(Y+w.uv_index_bytes*4);y+=function(c){for(var e,h,g,k=w.vertex_coordinate_bytes*3,l=c+w.nvertices*k;c=0){u=l.invBindMatrices[p];m.invBindMatrix=u;m.skinningMatrix=new THREE.Matrix4;m.skinningMatrix.multiply(m.world,u);m.weights=[]; for(u=0;u1?b[1].substr(0,c):"0";b[1].length=0,g=f.indexOf("(")>=0,k;if(h)e=f.split("."),f=e.shift(),e.shift();else if(g){k=f.split("(");f=k.shift();for(e=0;ec){p=m.output[l];break}g=p!==void 0?p instanceof THREE.Matrix4?g.multiply(g,p):g.multiply(g,k.matrix):g.multiply(g,k.matrix)}else g=g.multiply(g,k.matrix);c=g;b.push({time:a,pos:[c.n14, c.n24,c.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=b}this.updateMatrix();return this};n.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[b.nodeName]=parseFloat(e[0].textContent))}}this.create();return this};H.prototype.create=function(){var a= +a.childNodes[c];if(b.nodeType==1)switch(b.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[b.nodeName]=(new I).parse(b);break;case "shininess":case "reflectivity":case "transparency":var e;e=Q.evaluate(".//dae:float",b,F,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var f=e.iterateNext(),h=[];f;)h.push(f),f=e.iterateNext();e=h;e.length>0&&(this[b.nodeName]=parseFloat(e[0].textContent))}}this.create();return this};H.prototype.create=function(){var a= {},c=this.transparency!==void 0&&this.transparency<1,b;for(b in this)switch(b){case "ambient":case "emission":case "diffuse":case "specular":var e=this[b];if(e instanceof I)if(e.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(e=Y[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(ja+e.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else b=="diffuse"?a.color= e.color.getHex():c||(a[b]=e.color.getHex());break;case "shininess":case "reflectivity":a[b]=this[b];break;case "transparency":if(c)a.transparent=!0,a.opacity=this[b],c=!0}a.shading=ka;return this.material=new THREE.MeshLambertMaterial(a)};M.prototype.parse=function(a){for(var c=0;c=0,e=a.indexOf("(")>=0,f,h;if(b)c=a.split("."),a=c.shift(),h=c.shift();else if(e){f=a.split("(");a=f.shift();for(c=0;c=0,e=a.indexOf("(")>=0,f,h;if(b)c=a.split("."),a=c.shift(),h=c.shift();else if(e){f=a.split("(");a=f.shift();for(c=0;c1&&(M=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(F,M);object.name=p;object.position.set(w[0],w[1],w[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=y.visible;E.scene.add(object);E.objects[p]=object;y.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),E.scene.collisions.colliders.push(a)); -if(y.castsShadow)a=new THREE.ShadowVolume(F),E.scene.add(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},E.triggers[object.name]=a)}}else w=y.position,r=y.rotation,q=y.quaternion,s=y.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(w[0],w[1],w[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], -s[1],s[2]),object.visible=y.visible!==void 0?y.visible:!1,E.scene.add(object),E.objects[p]=object,E.empties[p]=object,y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},E.triggers[object.name]=a)}function l(a){return function(b){E.geometries[a]=b;k();L-=1;c.onLoadComplete();n()}}function m(a){return function(c){E.geometries[a]=c}}function n(){c.callbackProgress({totalModels:K,totalTextures:P,loadedModels:K-L,loadedTextures:P-N},E);c.onLoadProgress();L==0&&N==0&&b(E)}var o,t, -p,x,v,u,z,y,w,A,C,F,G,I,H,M,B,D,J,L,N,K,P,E;D=a.data;H=new THREE.BinaryLoader;J=new THREE.JSONLoader;N=L=0;E={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(p in D.objects)if(y=D.objects[p],y.meshCollider){a=!0;break}if(a)E.scene.collisions=new THREE.CollisionSystem;if(D.transform){a=D.transform.position;A=D.transform.rotation;var S=D.transform.scale;a&&E.scene.position.set(a[0],a[1],a[2]);A&&E.scene.rotation.set(A[0], -A[1],A[2]);S&&E.scene.scale.set(S[0],S[1],S[2]);(a||A||S)&&E.scene.updateMatrix()}a=function(){N-=1;n();c.onLoadComplete()};for(v in D.cameras){A=D.cameras[v];if(A.type=="perspective")G=new THREE.Camera(A.fov,A.aspect,A.near,A.far);else if(A.type=="ortho")G=new THREE.Camera,G.projectionMatrix=THREE.Matrix4.makeOrtho(A.left,A.right,A.top,A.bottom,A.near,A.far);w=A.position;A=A.target;G.position.set(w[0],w[1],w[2]);G.target.position.set(A[0],A[1],A[2]);E.cameras[v]=G}for(x in D.lights)v=D.lights[x], -G=v.color!==void 0?v.color:16777215,A=v.intensity!==void 0?v.intensity:1,v.type=="directional"?(w=v.direction,B=new THREE.DirectionalLight(G,A),B.position.set(w[0],w[1],w[2]),B.position.normalize()):v.type=="point"?(w=v.position,d=v.distance,B=new THREE.PointLight(G,A,d),B.position.set(w[0],w[1],w[2])):v.type=="ambient"&&(B=new THREE.AmbientLight(G)),E.scene.add(B),E.lights[x]=B;for(u in D.fogs)x=D.fogs[u],x.type=="linear"?I=new THREE.Fog(0,x.near,x.far):x.type=="exp2"&&(I=new THREE.FogExp2(0,x.density)), -A=x.color,I.color.setRGB(A[0],A[1],A[2]),E.fogs[u]=I;if(E.cameras&&D.defaults.camera)E.currentCamera=E.cameras[D.defaults.camera];if(E.fogs&&D.defaults.fog)E.scene.fog=E.fogs[D.defaults.fog];A=D.defaults.bgcolor;E.bgColor=new THREE.Color;E.bgColor.setRGB(A[0],A[1],A[2]);E.bgColorAlpha=D.defaults.bgalpha;for(o in D.geometries)if(u=D.geometries[o],u.type=="bin_mesh"||u.type=="ascii_mesh")L+=1,c.onLoadStart();K=L;for(o in D.geometries)u=D.geometries[o],u.type=="cube"?(F=new THREE.CubeGeometry(u.width, -u.height,u.depth,u.segmentsWidth,u.segmentsHeight,u.segmentsDepth,null,u.flipped,u.sides),E.geometries[o]=F):u.type=="plane"?(F=new THREE.PlaneGeometry(u.width,u.height,u.segmentsWidth,u.segmentsHeight),E.geometries[o]=F):u.type=="sphere"?(F=new THREE.SphereGeometry(u.radius,u.segmentsWidth,u.segmentsHeight),E.geometries[o]=F):u.type=="cylinder"?(F=new THREE.CylinderGeometry(u.topRad,u.botRad,u.height,u.radSegs,u.heightSegs),E.geometries[o]=F):u.type=="torus"?(F=new THREE.TorusGeometry(u.radius,u.tube, -u.segmentsR,u.segmentsT),E.geometries[o]=F):u.type=="icosahedron"?(F=new THREE.IcosahedronGeometry(u.subdivisions),E.geometries[o]=F):u.type=="bin_mesh"?H.load({model:e(u.url,D.urlBaseType),callback:l(o)}):u.type=="ascii_mesh"?J.load({model:e(u.url,D.urlBaseType),callback:l(o)}):u.type=="embedded_mesh"&&(u=D.embeds[u.id])&&J.createModel(u,m(o),"");for(z in D.textures)if(o=D.textures[z],o.url instanceof Array){N+=o.url.length;for(H=0;H1&&(M=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(G,M);object.name=p;object.position.set(w[0],w[1],w[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=y.visible;F.scene.add(object);F.objects[p]=object;y.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),F.scene.collisions.colliders.push(a)); +if(y.castsShadow)a=new THREE.ShadowVolume(G),F.scene.add(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},F.triggers[object.name]=a)}}else w=y.position,r=y.rotation,q=y.quaternion,s=y.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(w[0],w[1],w[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], +s[1],s[2]),object.visible=y.visible!==void 0?y.visible:!1,F.scene.add(object),F.objects[p]=object,F.empties[p]=object,y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},F.triggers[object.name]=a)}function l(a){return function(b){F.geometries[a]=b;k();L-=1;c.onLoadComplete();n()}}function m(a){return function(c){F.geometries[a]=c}}function n(){c.callbackProgress({totalModels:K,totalTextures:P,loadedModels:K-L,loadedTextures:P-N},F);c.onLoadProgress();L==0&&N==0&&b(F)}var o,t, +p,x,v,u,z,y,w,A,C,G,E,I,H,M,B,D,J,L,N,K,P,F;D=a.data;H=new THREE.BinaryLoader;J=new THREE.JSONLoader;N=L=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(p in D.objects)if(y=D.objects[p],y.meshCollider){a=!0;break}if(a)F.scene.collisions=new THREE.CollisionSystem;if(D.transform){a=D.transform.position;A=D.transform.rotation;var S=D.transform.scale;a&&F.scene.position.set(a[0],a[1],a[2]);A&&F.scene.rotation.set(A[0], +A[1],A[2]);S&&F.scene.scale.set(S[0],S[1],S[2]);(a||A||S)&&F.scene.updateMatrix()}a=function(){N-=1;n();c.onLoadComplete()};for(v in D.cameras){A=D.cameras[v];if(A.type=="perspective")E=new THREE.Camera(A.fov,A.aspect,A.near,A.far),E.useTarget=!0;else if(A.type=="ortho")E=new THREE.Camera,E.useTarget=!0,E.projectionMatrix=THREE.Matrix4.makeOrtho(A.left,A.right,A.top,A.bottom,A.near,A.far);w=A.position;A=A.target;E.position.set(w[0],w[1],w[2]);E.target.position.set(A[0],A[1],A[2]);F.cameras[v]=E}for(x in D.lights)v= +D.lights[x],E=v.color!==void 0?v.color:16777215,A=v.intensity!==void 0?v.intensity:1,v.type=="directional"?(w=v.direction,B=new THREE.DirectionalLight(E,A),B.position.set(w[0],w[1],w[2]),B.position.normalize()):v.type=="point"?(w=v.position,d=v.distance,B=new THREE.PointLight(E,A,d),B.position.set(w[0],w[1],w[2])):v.type=="ambient"&&(B=new THREE.AmbientLight(E)),F.scene.add(B),F.lights[x]=B;for(u in D.fogs)x=D.fogs[u],x.type=="linear"?I=new THREE.Fog(0,x.near,x.far):x.type=="exp2"&&(I=new THREE.FogExp2(0, +x.density)),A=x.color,I.color.setRGB(A[0],A[1],A[2]),F.fogs[u]=I;if(F.cameras&&D.defaults.camera)F.currentCamera=F.cameras[D.defaults.camera];if(F.fogs&&D.defaults.fog)F.scene.fog=F.fogs[D.defaults.fog];A=D.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(A[0],A[1],A[2]);F.bgColorAlpha=D.defaults.bgalpha;for(o in D.geometries)if(u=D.geometries[o],u.type=="bin_mesh"||u.type=="ascii_mesh")L+=1,c.onLoadStart();K=L;for(o in D.geometries)u=D.geometries[o],u.type=="cube"?(G=new THREE.CubeGeometry(u.width, +u.height,u.depth,u.segmentsWidth,u.segmentsHeight,u.segmentsDepth,null,u.flipped,u.sides),F.geometries[o]=G):u.type=="plane"?(G=new THREE.PlaneGeometry(u.width,u.height,u.segmentsWidth,u.segmentsHeight),F.geometries[o]=G):u.type=="sphere"?(G=new THREE.SphereGeometry(u.radius,u.segmentsWidth,u.segmentsHeight),F.geometries[o]=G):u.type=="cylinder"?(G=new THREE.CylinderGeometry(u.topRad,u.botRad,u.height,u.radSegs,u.heightSegs),F.geometries[o]=G):u.type=="torus"?(G=new THREE.TorusGeometry(u.radius,u.tube, +u.segmentsR,u.segmentsT),F.geometries[o]=G):u.type=="icosahedron"?(G=new THREE.IcosahedronGeometry(u.subdivisions),F.geometries[o]=G):u.type=="bin_mesh"?H.load({model:e(u.url,D.urlBaseType),callback:l(o)}):u.type=="ascii_mesh"?J.load({model:e(u.url,D.urlBaseType),callback:l(o)}):u.type=="embedded_mesh"&&(u=D.embeds[u.id])&&J.createModel(u,m(o),"");for(z in D.textures)if(o=D.textures[z],o.url instanceof Array){N+=o.url.length;for(H=0;H=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),e=1,g=0;g<8;g++){for(var h=0,f=0;f>1^-(k&1);c[8*f+g]=h}e+=b}b=a.length-e;h=new Uint16Array(b);for(g=f=0;g=this.maxCount-3&&k(this)};this.begin=function(){this.count=0; this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;bthis.size-1&&(l=this.size-1);var t=Math.floor(m-k);t<1&&(t=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var p=Math.floor(n-k);p<1&&(p=1);k=Math.floor(n+k);k>this.size-1&&(k=this.size- 1);for(var x,v,u,z,y,w;o0&&(this.field[u+x]+=z)}}};this.addPlaneX=function(a,b){var g,h,f,k,l,m=this.size,n=this.yd,o=this.zd,t=this.field,p=m*Math.sqrt(a/b);p>m&&(p=m);for(g=0;g0)for(h=0;h=0&&i>=0&&h>=0&&j>=0?!0:f<0&&i<0||h<0&&j<0?!1:(f<0?d=Math.max(d,f/(f-i)):i<0&&(e=Math.min(e,f/(f-i))),h<0?d=Math.max(d,h/(h-j)):j<0&&(e=Math.min(e,h/(h-j))),ee&&j.positionScreen.ze&&j.positionScreen.z0&&G.z<1))Aa=xa[wa]=xa[wa]||new THREE.RenderableParticle,wa++,F=Aa,F.x=G.x/G.w,F.y=G.y/G.w,F.z=G.z,F.rotation=Q.rotation.z,F.scale.x=Q.scale.x*Math.abs(F.x- (G.x+i.projectionMatrix.n11)/(G.w+i.projectionMatrix.n14)),F.scale.y=Q.scale.y*Math.abs(F.y-(G.y+i.projectionMatrix.n22)/(G.w+i.projectionMatrix.n24)),F.materials=Q.materials,ra.push(F);h&&ra.sort(c);return ra}};THREE.Quaternion=function(b,c,d,f){this.set(b||0,c||0,d||0,f!==void 0?f:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,d,f){this.x=b;this.y=c;this.z=d;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=Math.PI/360,d=b.x*c,f=b.y*c,i=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-i),i=Math.sin(-i),h=Math.cos(d),d=Math.sin(d),j=b*c,k=f*i;this.w=j*h-k*d;this.x=j*d+k*h;this.y=f*c*h+b*i*d;this.z=b*i*h-f*c*d;return this},setFromAxisAngle:function(b,c){var d=c/2,f=Math.sin(d); @@ -193,7 +193,7 @@ k);else if(C=="v3v"){if(!m._array)m._array=new Float32Array(3*k.length);C=0;for( k),p=m.texture)if(p.image instanceof Array&&p.image.length==6){if(m=p,m.image.length==6)if(m.needsUpdate){if(!m.image.__webglTextureCube)m.image.__webglTextureCube=e.createTexture();e.activeTexture(e.TEXTURE0+k);e.bindTexture(e.TEXTURE_CUBE_MAP,m.image.__webglTextureCube);for(k=0;k<6;k++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,m.image[k]);u(e.TEXTURE_CUBE_MAP,m,m.image[0]);m.needsUpdate=!1}else e.activeTexture(e.TEXTURE0+k),e.bindTexture(e.TEXTURE_CUBE_MAP,m.image.__webglTextureCube)}else p instanceof THREE.WebGLRenderTargetCube?(m=p,e.activeTexture(e.TEXTURE0+k),e.bindTexture(e.TEXTURE_CUBE_MAP,m.__webglTexture)):S(p,k)}else if(C=="tv"){if(!m._array){m._array=[];C=0;for(q=m.texture.length;C=0)c&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglVertexBuffer),e.vertexAttribPointer(b.position,3,e.FLOAT,!1,0,0));else if(j.morphTargetBase){f=i.program.attributes;j.morphTargetBase!==-1?(e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[j.morphTargetBase]), +j.objectMatrix!==null&&e.uniformMatrix4fv(j.objectMatrix,!1,i._objectMatrixArray);return h}function f(b,c,f,i,h,j){if(i.opacity!=0){var k,f=d(b,c,f,i,j),b=f.attributes,c=!1,f=h.id*16777215+f.id;f!=W&&(W=f,c=!0);if(!i.morphTargets&&b.position>=0)c&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglVertexBuffer),e.vertexAttribPointer(b.position,3,e.FLOAT,!1,0,0));else if(j.morphTargetBase){f=i.program.attributes;j.morphTargetBase!==-1?(e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[j.morphTargetBase]), e.vertexAttribPointer(f.position,3,e.FLOAT,!1,0,0)):f.position>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglVertexBuffer),e.vertexAttribPointer(f.position,3,e.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var n=0,y=j.morphTargetForcedOrder,m=j.morphTargetInfluences;np&&(q=t,p=m[q]);e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[q]);e.vertexAttribPointer(f["morphTarget"+n],3,e.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[n]=p;y[q]=1;p=-1;n++}}i.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(i.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(c){if(h.__webglCustomAttributes)for(k in h.__webglCustomAttributes)b[k]>= 0&&(f=h.__webglCustomAttributes[k],e.bindBuffer(e.ARRAY_BUFFER,f.buffer),e.vertexAttribPointer(b[k],f.size,e.FLOAT,!1,0,0));b.color>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglColorBuffer),e.vertexAttribPointer(b.color,3,e.FLOAT,!1,0,0));b.normal>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglNormalBuffer),e.vertexAttribPointer(b.normal,3,e.FLOAT,!1,0,0));b.tangent>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglTangentBuffer),e.vertexAttribPointer(b.tangent,4,e.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(e.bindBuffer(e.ARRAY_BUFFER, @@ -205,17 +205,17 @@ b.__webglNormalBuffer);if(d==THREE.FlatShading){var f,h,i,j,k,y,n,m,p,q,C=b.coun 0,b.count);b.count=0}function h(b){if($!=b.doubleSided)b.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE),$=b.doubleSided;if(N!=b.flipSided)b.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW),N=b.flipSided}function j(b){sa!=b&&(b?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),sa=b)}function k(b){Q!=b&&(e.depthMask(b),Q=b)}function m(b,c,d){Aa!=b&&(b?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),Aa=b);if(b&&(Ja!=c||Ta!=d))e.polygonOffset(c,d),Ja=c,Ta=d}function n(b){aa[0].set(b.n41- b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);aa[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);aa[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);aa[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);aa[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);aa[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var c,b=0;b<6;b++)c=aa[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function q(b){for(var c=b.matrixWorld,e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x, Math.max(b.scale.y,b.scale.z)),d=0;d<6;d++)if(b=aa[d].x*c.n14+aa[d].y*c.n24+aa[d].z*c.n34+aa[d].w,b<=e)return!1;return!0}function p(b,c){b.list[b.count]=c;b.count+=1}function t(b){var c,e,d=b.object,f=b.opaque,h=b.transparent;h.count=0;b=f.count=0;for(c=d.materials.length;b=0;e--)b[e].object==c&&b.splice(e,1)}function ra(b){function c(b){var f=[];e=0;for(d=b.length;e65535&&(m[k].counter+=1,n=m[k].hash+"_"+m[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[], -materials:j,vertices:0,numMorphTargets:p})),b.geometryGroups[n].faces.push(f),b.geometryGroups[n].vertices+=i;b.geometryGroupsList=[];for(var q in b.geometryGroups)b.geometryGroups[q].id=J++,b.geometryGroupsList.push(b.geometryGroups[q])}function ja(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function G(b){if(b!=ka){switch(b){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD); +0;for(e=i.materials.length;c=0;e--)b[e].object==c&&b.splice(e,1)}function ra(b){function c(b){var f=[];e=0;for(d=b.length;e65535&&(m[k].counter+=1,n=m[k].hash+"_"+m[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]= +{faces:[],materials:j,vertices:0,numMorphTargets:p})),b.geometryGroups[n].faces.push(f),b.geometryGroups[n].vertices+=i;b.geometryGroupsList=[];for(var q in b.geometryGroups)b.geometryGroups[q].id=J++,b.geometryGroupsList.push(b.geometryGroups[q])}function ja(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function G(b){if(b!=ka){switch(b){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD); e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}ka=b}}function u(b,c,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(e.texParameteri(b,e.TEXTURE_WRAP_S,V(c.wrapS)),e.texParameteri(b,e.TEXTURE_WRAP_T,V(c.wrapT)),e.texParameteri(b,e.TEXTURE_MAG_FILTER,V(c.magFilter)), e.texParameteri(b,e.TEXTURE_MIN_FILTER,V(c.minFilter)),e.generateMipmap(b)):(e.texParameteri(b,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_MAG_FILTER,ya(c.magFilter)),e.texParameteri(b,e.TEXTURE_MIN_FILTER,ya(c.minFilter)))}function S(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=e.createTexture(),M.info.memory.textures++;e.activeTexture(e.TEXTURE0+c);e.bindTexture(e.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,V(b.format),b.image.width,b.image.height,0,V(b.format),e.UNSIGNED_BYTE,b.image.data):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,b.image);u(e.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else e.activeTexture(e.TEXTURE0+c),e.bindTexture(e.TEXTURE_2D,b.__webglTexture)}function L(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0; @@ -226,9 +226,9 @@ null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var f,h;b?(c=c?b.__webglFramebuffer[ e.bindTexture(e.TEXTURE_2D,null))}function Z(b,c){var d;b=="fragment"?d=e.createShader(e.FRAGMENT_SHADER):b=="vertex"&&(d=e.createShader(e.VERTEX_SHADER));e.shaderSource(d,c);e.compileShader(d);if(!e.getShaderParameter(d,e.COMPILE_STATUS))return console.error(e.getShaderInfoLog(d)),console.error(c),null;return d}function ya(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function V(b){switch(b){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 M=this,e,ua=[],Xa= -null,va=null,U=-1,na=null,J=0,$=null,N=null,ka=null,sa=null,Q=null,Aa=null,Ja=null,Ta=null,Ka=0,Ba=0,Ea=0,za=0,aa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ga=new THREE.Matrix4,Va=new Float32Array(16),Wa=new Float32Array(16),Sa=new THREE.Vector4,Za={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ca=b.canvas!==void 0?b.canvas:document.createElement("canvas"), +null,va=null,U=-1,W=null,J=0,$=null,N=null,ka=null,sa=null,Q=null,Aa=null,Ja=null,Ta=null,Ka=0,Ba=0,Ea=0,za=0,aa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ga=new THREE.Matrix4,Va=new Float32Array(16),Wa=new Float32Array(16),Sa=new THREE.Vector4,Za={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ca=b.canvas!==void 0?b.canvas:document.createElement("canvas"), R=b.stencil!==void 0?b.stencil:!0,db=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,eb=b.antialias!==void 0?b.antialias:!1,ha=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ha=b.clearAlpha!==void 0?b.clearAlpha:0,Ya=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Ca;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor= -this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var X,Ua=[],b=THREE.ShaderLib.depthRGBA,bb=THREE.UniformsUtils.clone(b.uniforms),La=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:bb}),$a=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader, +this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ma,Ua=[],b=THREE.ShaderLib.depthRGBA,bb=THREE.UniformsUtils.clone(b.uniforms),La=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:bb}),$a=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader, uniforms:bb,morphTargets:!0});La._shadowPass=!0;$a._shadowPass=!0;try{if(!(e=Ca.getContext("experimental-webgl",{antialias:eb,stencil:R,preserveDrawingBuffer:db})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION))}catch(fb){console.error(fb)}e.clearColor(0,0,0,1);e.clearDepth(1);e.clearStencil(0);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(ha.r,ha.g,ha.b,Ha);this.context=e;var cb=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,r={};r.vertices=new Float32Array(16);r.faces=new Uint16Array(6);R=0;r.vertices[R++]=-1;r.vertices[R++]=-1;r.vertices[R++]=0;r.vertices[R++]=1;r.vertices[R++]=1;r.vertices[R++]=-1;r.vertices[R++]=1;r.vertices[R++]=1;r.vertices[R++]=1;r.vertices[R++]= 1;r.vertices[R++]=1;r.vertices[R++]=0;r.vertices[R++]=-1;r.vertices[R++]=1;r.vertices[R++]=0;R=r.vertices[R++]=0;r.faces[R++]=0;r.faces[R++]=1;r.faces[R++]=2;r.faces[R++]=0;r.faces[R++]=2;r.faces[R++]=3;r.vertexBuffer=e.createBuffer();r.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,r.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,r.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,r.faces,e.STATIC_DRAW);r.program=e.createProgram(); @@ -248,12 +248,12 @@ d.shadowMapSoft?"#define SHADOWMAP_SOFT":"",d.shadowMapSoft?"#define SHADOWMAP_W e.getError()+"]");r.uniforms={};r.attributes={};var u,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(u in n)f.push(u);u=f;f=0;for(n=u.length;f=0&&e.enableVertexAttribArray(C.position);C.color>=0&&e.enableVertexAttribArray(C.color);C.normal>=0&&e.enableVertexAttribArray(C.normal);C.tangent>=0&&e.enableVertexAttribArray(C.tangent);b.skinning&&C.skinVertexA>=0&&C.skinVertexB>=0&&C.skinIndex>=0&&C.skinWeight>=0&&(e.enableVertexAttribArray(C.skinVertexA), e.enableVertexAttribArray(C.skinVertexB),e.enableVertexAttribArray(C.skinIndex),e.enableVertexAttribArray(C.skinWeight));if(b.attributes)for(i in b.attributes)C[i]!==void 0&&C[i]>=0&&e.enableVertexAttribArray(C[i]);if(b.morphTargets)for(i=b.numSupportedMorphTargets=0;i=0&&(e.enableVertexAttribArray(C[u]),b.numSupportedMorphTargets++);b.uniformsList=[];for(h in b.uniforms)b.uniformsList.push([b.uniforms[h],h])};this.clearTarget=function(b,c,d,e){L(b); -this.clear(c,d,e)};this.render=function(b,c,p,r){var I,u,Fa,W,y,J,D,Qa,Ra=b.lights,C=b.fog;U=-1;this.shadowMapEnabled&&x(b,c);M.info.render.calls=0;M.info.render.vertices=0;M.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Wa);c.projectionMatrix.flattenToArray(Va);Ga.multiply(c.projectionMatrix,c.matrixWorldInverse);n(Ga);this.initWebGLObjects(b);L(p);(this.autoClear||r)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil); +this.clear(c,d,e)};this.render=function(b,c,p,r){var I,u,Fa,X,y,J,D,Qa,Ra=b.lights,C=b.fog;U=-1;this.shadowMapEnabled&&x(b,c);M.info.render.calls=0;M.info.render.vertices=0;M.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Wa);c.projectionMatrix.flattenToArray(Va);Ga.multiply(c.projectionMatrix,c.matrixWorldInverse);n(Ga);this.initWebGLObjects(b);L(p);(this.autoClear||r)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil); y=b.__webglObjects.length;for(r=0;r=0;r--)if(I=b.__webglObjects[r],I.render){D=I.object;Qa=I.buffer;Fa=I.opaque;h(D);for(I=0;I=0;r--)if(I=b.__webglObjects[r],I.render){D=I.object;Qa=I.buffer;Fa=I.opaque;h(D);for(I=0;I=0;i--)f[i]==h&&f.splice(i,1)}else(d instanceof THREE.MarchingCubes||d.immediateRenderCallback)&&qa(f.__webglObjectsImmediate,d);d.__webglActive= !1;b.__objectsRemoved.splice(0,1)}d=0;for(f=b.__webglObjects.length;d0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,pa,v));Aa&&(e.bindBuffer(e.ARRAY_BUFFER, -m.__webglNormalBuffer),e.bufferData(e.ARRAY_BUFFER,X,v));Ba&&ta.hasTangents&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglTangentBuffer),e.bufferData(e.ARRAY_BUFFER,ca,v));ua&&Z>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,ka,v));ua&&$>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,na,v));za&&(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.__webglFaceBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,ha,v),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer), +m.__webglNormalBuffer),e.bufferData(e.ARRAY_BUFFER,W,v));Ba&&ta.hasTangents&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglTangentBuffer),e.bufferData(e.ARRAY_BUFFER,ca,v));ua&&Z>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,ka,v));ua&&$>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,ma,v));za&&(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.__webglFaceBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,ha,v),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer), e.bufferData(e.ELEMENT_ARRAY_BUFFER,Da,v));w>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,da,v),e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,ea,v),e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,fa,v),e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,ga,v));B&&(delete m.__inittedArrays,delete m.__colorArray,delete m.__normalArray,delete m.__tangentArray, delete m.__uvArray,delete m.__uv2Array,delete m.__faceArray,delete m.__vertexArray,delete m.__lineArray,delete m.__skinVertexAArray,delete m.__skinVertexBArray,delete m.__skinIndexArray,delete m.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;xa(j)}else if(i instanceof THREE.Ribbon){h=i.geometry;if(h.__dirtyVertices||h.__dirtyColors){i=h;j=e.DYNAMIC_DRAW;k=u=B=B=void 0;p=i.vertices;n= i.colors;r=p.length;m=n.length;t=i.__vertexArray;v=i.__colorArray;x=i.__dirtyColors;if(i.__dirtyVertices){for(B=0;B
three.js - webgl cube Fresnel shader demo.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -171,6 +65,7 @@ document.body.appendChild( container ); camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 10000 ); + camera.useTarget = true; camera.position.z = 3200; scene = new THREE.Scene(); diff --git a/examples/webgl_utf8loader.html b/examples/webgl_utf8loader.html index f8790317e4..28db45b4b4 100644 --- a/examples/webgl_utf8loader.html +++ b/examples/webgl_utf8loader.html @@ -71,8 +71,8 @@ document.body.appendChild( container ); camera = new THREE.Camera( 20, SCREEN_WIDTH / SCREEN_HEIGHT, NEAR, FAR ); + camera.useTarget = true; camera.position.z = 800; - camera.updateMatrix(); scene = new THREE.Scene(); scene.fog = new THREE.Fog( 0x000000, 800, FAR ); @@ -81,10 +81,10 @@ var path = "textures/cube/SwedishRoyalCastle/"; var format = '.jpg'; var urls = [ - path + 'px' + format, path + 'nx' + format, - path + 'py' + format, path + 'ny' + format, - path + 'pz' + format, path + 'nz' + format - ]; + path + 'px' + format, path + 'nx' + format, + path + 'py' + format, path + 'ny' + format, + path + 'pz' + format, path + 'nz' + format + ]; reflectionCube = THREE.ImageUtils.loadTextureCube( urls ); diff --git a/src/extras/loaders/SceneLoader.js b/src/extras/loaders/SceneLoader.js index ef2aabee67..5dddba0982 100644 --- a/src/extras/loaders/SceneLoader.js +++ b/src/extras/loaders/SceneLoader.js @@ -360,10 +360,12 @@ THREE.SceneLoader.prototype = { if ( c.type == "perspective" ) { camera = new THREE.Camera( c.fov, c.aspect, c.near, c.far ); + camera.useTarget = true; } else if ( c.type == "ortho" ) { camera = new THREE.Camera(); + camera.useTarget = true; camera.projectionMatrix = THREE.Matrix4.makeOrtho( c.left, c.right, c.top, c.bottom, c.near, c.far ); } diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index fdf28b2bd3..a8506faa4e 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -3488,6 +3488,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( ! _cameraLight ) { _cameraLight = new THREE.Camera( _this.shadowCameraFov, _this.shadowMapWidth / _this.shadowMapHeight, _this.shadowCameraNear, _this.shadowCameraFar ); + _cameraLight.useTarget = true; } -- GitLab