From 247ec4901338a481a9869db93806de19c0e6732d Mon Sep 17 00:00:00 2001 From: alteredq Date: Sat, 19 Nov 2011 04:28:49 +0100 Subject: [PATCH] Small refactoring in plugins. --- build/Three.js | 739 +++++++++++++------------- build/custom/ThreeExtras.js | 228 ++++---- build/custom/ThreeWebGL.js | 353 ++++++------ src/extras/plugins/ShadowMapPlugin.js | 17 +- src/renderers/WebGLRenderer.js | 66 +-- 5 files changed, 696 insertions(+), 707 deletions(-) diff --git a/build/Three.js b/build/Three.js index 5f206156..cd9e623b 100644 --- a/build/Three.js +++ b/build/Three.js @@ -17,62 +17,62 @@ this.y=Math.asin(a.n13);Math.abs(b)>1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b), THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}}; -THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);q=o.dot(b);if(q<=0)return null;l=r.add(a,n.copy(b).multiplyScalar(q));return p=c.distanceTo(l)}function d(a,b,c,d){o.sub(d,b);r.sub(c,b);n.sub(a,b);s=o.dot(o);t=o.dot(r);v=o.dot(n);y=r.dot(r);I=r.dot(n);z=1/(s*y-t*t);G=(y*v-t*I)*z;u=(s*I-t*v)*z;return G>=0&&u>=0&&G+u<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b, -c,d=[];b=0;for(c=a.length;bn.scale.x)return[];l={distance:o,point:n.position,face:null,object:n};q.push(l)}else if(n instanceof THREE.Mesh){o=c(this.origin,this.direction,n.matrixWorld.getPosition());if(o===null||o>n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)))return q;var p,s=n.geometry,t=s.vertices,j;n.matrixRotationWorld.extractRotation(n.matrixWorld);o=0;for(r=s.faces.length;o0:p<0)))if(p=m.dot(i.sub(e,a))/p,k.add(a,b.multiplyScalar(p)),l instanceof THREE.Face3)d(k, -e,g,f)&&(l={distance:a.distanceTo(k),point:k.clone(),face:l,object:n},q.push(l));else if(l instanceof THREE.Face4&&(d(k,e,g,h)||d(k,g,f,h)))l={distance:a.distanceTo(k),point:k.clone(),face:l,object:n},q.push(l)}return q};var o=new THREE.Vector3,r=new THREE.Vector3,n=new THREE.Vector3,q,l,p,s,t,v,y,I,z,G,u}; -THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,f,k,o){h=!1;b=g;c=f;d=k;e=o;a()};this.addPoint=function(g,f){h?(h=!1,b=g,c=f,d=g,e=f):(b=bg?d:g,e=e>f?e:f);a()};this.add3Points= -function(g,f,k,o,r,n){h?(h=!1,b=gk?g>r?g:r:k>r?k:r,e=f>o?f>n?f:n:o>n?o:n):(b=gk?g>r?g>d?g:d:r>d?r:d:k>r?k>d?k:d:r>d?r:d,e=f>o?f>n?f>e?f:e:n>e?n:e:o>n?o>e?o:e:n>e?n:e);a()};this.addRectangle=function(g){h?(h=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),e=g.getBottom()):(b=bg.getRight()?d:g.getRight(),e=e> +THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);p=o.dot(b);if(p<=0)return null;n=r.add(a,m.copy(b).multiplyScalar(p));return q=c.distanceTo(n)}function d(a,b,c,d){o.sub(d,b);r.sub(c,b);m.sub(a,b);s=o.dot(o);t=o.dot(r);u=o.dot(m);v=r.dot(r);B=r.dot(m);x=1/(s*v-t*t);C=(v*u-t*B)*x;E=(s*B-t*u)*x;return C>=0&&E>=0&&C+E<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b, +c,d=[];b=0;for(c=a.length;bm.scale.x)return[];n={distance:o,point:m.position,face:null,object:m};p.push(n)}else if(m instanceof THREE.Mesh){o=c(this.origin,this.direction,m.matrixWorld.getPosition());if(o===null||o>m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)))return p;var q,s=m.geometry,t=s.vertices,u;m.matrixRotationWorld.extractRotation(m.matrixWorld);o=0;for(r=s.faces.length;o0:q<0)))if(q=l.dot(i.sub(e,a))/q,j.add(a,b.multiplyScalar(q)),n instanceof THREE.Face3)d(j, +e,g,f)&&(n={distance:a.distanceTo(j),point:j.clone(),face:n,object:m},p.push(n));else if(n instanceof THREE.Face4&&(d(j,e,g,h)||d(j,g,f,h)))n={distance:a.distanceTo(j),point:j.clone(),face:n,object:m},p.push(n)}return p};var o=new THREE.Vector3,r=new THREE.Vector3,m=new THREE.Vector3,p,n,q,s,t,u,v,B,x,C,E}; +THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,f,j,o){h=!1;b=g;c=f;d=j;e=o;a()};this.addPoint=function(g,f){h?(h=!1,b=g,c=f,d=g,e=f):(b=bg?d:g,e=e>f?e:f);a()};this.add3Points= +function(g,f,j,o,r,m){h?(h=!1,b=gj?g>r?g:r:j>r?j:r,e=f>o?f>m?f:m:o>m?o:m):(b=gj?g>r?g>d?g:d:r>d?r:d:j>r?j>d?j:d:r>d?r:d,e=f>o?f>m?f>e?f:e:m>e?m:e:o>m?o>e?o:e:m>e?m:e);a()};this.addRectangle=function(g){h?(h=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),e=g.getBottom()):(b=bg.getRight()?d:g.getRight(),e=e> g.getBottom()?e:g.getBottom());a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=0&&g>=0&&f>=0&&h>=0?!0:e<0&&g<0||f<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-g)):g<0&&(d=Math.min(d,e/(e-g))),f<0?c=Math.max(c,f/(f-h)):h<0&&(d=Math.min(d,f/(f-h))),df&&h.positionScreen.z0&&G.z<1))f=y[v]=y[v]||new THREE.RenderableParticle,v++,t=f,t.x= -G.x/G.w,t.y=G.y/G.w,t.z=G.z,t.rotation=V.rotation.z,t.scale.x=V.scale.x*Math.abs(t.x-(G.x+e.projectionMatrix.n11)/(G.w+e.projectionMatrix.n14)),t.scale.y=V.scale.y*Math.abs(t.y-(G.y+e.projectionMatrix.n22)/(G.w+e.projectionMatrix.n24)),t.material=V.material,I.elements.push(t);g&&I.elements.sort(c);return I}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; +THREE.Projector=function(){function a(){var a=f[g]=f[g]||new THREE.RenderableObject;g++;return a}function b(){var a=l[i]=l[i]||new THREE.RenderableVertex;i++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,g=b.z+b.w,f=-a.z+a.w,h=-b.z+b.w;return e>=0&&g>=0&&f>=0&&h>=0?!0:e<0&&g<0||f<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-g)):g<0&&(d=Math.min(d,e/(e-g))),f<0?c=Math.max(c,f/(f-h)):h<0&&(d=Math.min(d,f/(f-h))),df&&h.positionScreen.z0&&C.z<1))f=v[u]=v[u]||new THREE.RenderableParticle,u++,t=f,t.x= +C.x/C.w,t.y=C.y/C.w,t.z=C.z,t.rotation=X.rotation.z,t.scale.x=X.scale.x*Math.abs(t.x-(C.x+e.projectionMatrix.n11)/(C.w+e.projectionMatrix.n14)),t.scale.y=X.scale.y*Math.abs(t.y-(C.y+e.projectionMatrix.n22)/(C.w+e.projectionMatrix.n24)),t.material=X.material,B.elements.push(t);g&&B.elements.sort(c);return B}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= -this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,i=this.w,m=i*c+f*e-h*d,k=i*d+h*c-g*e,o=i*e+g*d-f*c,c=-g* -c-f*d-h*e;b.x=m*i+c*-g+k*-h-o*-f;b.y=k*i+c*-f+o*-g-m*-h;b.z=o*i+c*-h+m*-f-k*-g;return b}}; +this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,i=this.w,l=i*c+f*e-h*d,j=i*d+h*c-g*e,o=i*e+g*d-f*c,c=-g* +c-f*d-h*e;b.x=l*i+c*-g+j*-h-o*-f;b.y=j*i+c*-f+o*-g-l*-h;b.z=o*i+c*-h+l*-f-j*-g;return b}}; THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;e<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; @@ -83,15 +83,15 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid b,c,d,e,g,f=new THREE.Vector3,h=new THREE.Vector3;a=0;for(b=this.faces.length;a0){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 b=1,c=this.vertices.length;b0){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 b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a= 0,b=0,c=this.vertices.length;bthis.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;m=this.points[c[0]];k=this.points[c[1]]; -o=this.points[c[2]];r=this.points[c[3]];h=f*f;i=f*h;d.x=b(m.x,k.x,o.x,r.x,f,h,i);d.y=b(m.y,k.y,o.y,r.y,f,h,i);d.z=b(m.z,k.z,o.z,r.z,f,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;l=this.points[c[0]];j=this.points[c[1]]; +o=this.points[c[2]];r=this.points[c[3]];h=f*f;i=f*h;d.x=b(l.x,j.x,o.x,r.x,f,h,i);d.y=b(l.y,j.y,o.y,r.y,f,h,i);d.z=b(l.z,j.z,o.z,r.z,f,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a0&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b* -255)+","+s+")"),l.fillRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight()))),ta.empty())};this.render=function(a,k){function o(a){var b,c,d,e;wa.setRGB(0,0,0);Na.setRGB(0,0,0);Oa.setRGB(0,0,0);b=0;for(c=a.length;b>1,ma=i.height>>1,f=g.scale.x*n,j=g.scale.y*q,ga=f*k,h=j*ma,ua.set(a.x-ga,a.y-h,a.x+ga,a.y+h),ca.intersects(ua)&&(l.save(),l.translate(a.x,a.y),l.rotate(-g.rotation),l.scale(f,-j),l.translate(-k,-ma),l.drawImage(i,0,0),l.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(ga=g.scale.x*n,h=g.scale.y*q,ua.set(a.x-ga,a.y-h,a.x+ga,a.y+h),ca.intersects(ua)&&(d(f.color.getContextStyle()),e(f.color.getContextStyle()),l.save(),l.translate(a.x,a.y),l.rotate(-g.rotation),l.scale(ga, -h),f.program(l),l.restore()))}function s(a,e,g,f){b(f.opacity);c(f.blending);l.beginPath();l.moveTo(a.positionScreen.x,a.positionScreen.y);l.lineTo(e.positionScreen.x,e.positionScreen.y);l.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(z!=a)l.lineWidth=z=a;a=f.linecap;if(G!=a)l.lineCap=G=a;a=f.linejoin;if(u!=a)l.lineJoin=u=a;d(f.color.getContextStyle());l.stroke();ua.inflate(f.linewidth*2)}}function t(a,d,e,f,h,n,ca,l){g.info.render.vertices+=3;g.info.render.faces++;b(l.opacity); -c(l.blending);Y=a.positionScreen.x;K=a.positionScreen.y;j=d.positionScreen.x;W=d.positionScreen.y;J=e.positionScreen.x;L=e.positionScreen.y;y(Y,K,j,W,J,L);if(l instanceof THREE.MeshBasicMaterial)if(l.map)l.map.mapping instanceof THREE.UVMapping&&(la=ca.uvs[0],Q(Y,K,j,W,J,L,la[f].u,la[f].v,la[h].u,la[h].v,la[n].u,la[n].v,l.map));else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,ra.copy(ca.vertexNormalsWorld[f]),ya=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)* -0.5+0.5,va=-(ra.x*a.n21+ra.y*a.n22+ra.z*a.n23)*0.5+0.5,ra.copy(ca.vertexNormalsWorld[h]),xa=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,Aa=-(ra.x*a.n21+ra.y*a.n22+ra.z*a.n23)*0.5+0.5,ra.copy(ca.vertexNormalsWorld[n]),ga=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,ma=-(ra.x*a.n21+ra.y*a.n22+ra.z*a.n23)*0.5+0.5,Q(Y,K,j,W,J,L,ya,va,xa,Aa,ga,ma,l.envMap)}else l.wireframe?Ba(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):M(l.color);else if(l instanceof THREE.MeshLambertMaterial)l.map&& -!l.wireframe&&(l.map.mapping instanceof THREE.UVMapping&&(la=ca.uvs[0],Q(Y,K,j,W,J,L,la[f].u,la[f].v,la[h].u,la[h].v,la[n].u,la[n].v,l.map)),c(THREE.SubtractiveBlending)),Sa?!l.wireframe&&l.shading==THREE.SmoothShading&&ca.vertexNormalsWorld.length==3?(U.r=S.r=aa.r=wa.r,U.g=S.g=aa.g=wa.g,U.b=S.b=aa.b=wa.b,r(i,ca.v1.positionWorld,ca.vertexNormalsWorld[0],U),r(i,ca.v2.positionWorld,ca.vertexNormalsWorld[1],S),r(i,ca.v3.positionWorld,ca.vertexNormalsWorld[2],aa),U.r=Math.max(0,Math.min(l.color.r*U.r, -1)),U.g=Math.max(0,Math.min(l.color.g*U.g,1)),U.b=Math.max(0,Math.min(l.color.b*U.b,1)),S.r=Math.max(0,Math.min(l.color.r*S.r,1)),S.g=Math.max(0,Math.min(l.color.g*S.g,1)),S.b=Math.max(0,Math.min(l.color.b*S.b,1)),aa.r=Math.max(0,Math.min(l.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(l.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(l.color.b*aa.b,1)),Z.r=(S.r+aa.r)*0.5,Z.g=(S.g+aa.g)*0.5,Z.b=(S.b+aa.b)*0.5,ja=Qa(U,S,aa,Z),P(Y,K,j,W,J,L,0,0,1,0,0,1,ja)):(R.r=wa.r,R.g=wa.g,R.b=wa.b,r(i,ca.centroidWorld,ca.normalWorld, -R),R.r=Math.max(0,Math.min(l.color.r*R.r,1)),R.g=Math.max(0,Math.min(l.color.g*R.g,1)),R.b=Math.max(0,Math.min(l.color.b*R.b,1)),l.wireframe?Ba(R,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):M(R)):l.wireframe?Ba(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):M(l.color);else if(l instanceof THREE.MeshDepthMaterial)oa=k.near,sa=k.far,U.r=U.g=U.b=1-Fa(a.positionScreen.z,oa,sa),S.r=S.g=S.b=1-Fa(d.positionScreen.z,oa,sa),aa.r=aa.g=aa.b=1-Fa(e.positionScreen.z,oa,sa), -Z.r=(S.r+aa.r)*0.5,Z.g=(S.g+aa.g)*0.5,Z.b=(S.b+aa.b)*0.5,ja=Qa(U,S,aa,Z),P(Y,K,j,W,J,L,0,0,1,0,0,1,ja);else if(l instanceof THREE.MeshNormalMaterial)R.r=Ja(ca.normalWorld.x),R.g=Ja(ca.normalWorld.y),R.b=Ja(ca.normalWorld.z),l.wireframe?Ba(R,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):M(R)}function v(a,d,e,f,ga,h,l,n,ca){g.info.render.vertices+=4;g.info.render.faces++;b(n.opacity);c(n.blending);if(n.map||n.envMap)t(a,d,f,0,1,3,l,n,ca),t(ga,e,h,1,2,3,l,n,ca);else if(Y=a.positionScreen.x, -K=a.positionScreen.y,j=d.positionScreen.x,W=d.positionScreen.y,J=e.positionScreen.x,L=e.positionScreen.y,C=f.positionScreen.x,O=f.positionScreen.y,ea=ga.positionScreen.x,X=ga.positionScreen.y,fa=h.positionScreen.x,V=h.positionScreen.y,n instanceof THREE.MeshBasicMaterial)I(Y,K,j,W,J,L,C,O),n.wireframe?Ba(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):M(n.color);else if(n instanceof THREE.MeshLambertMaterial)Sa?!n.wireframe&&n.shading==THREE.SmoothShading&&l.vertexNormalsWorld.length== -4?(U.r=S.r=aa.r=Z.r=wa.r,U.g=S.g=aa.g=Z.g=wa.g,U.b=S.b=aa.b=Z.b=wa.b,r(i,l.v1.positionWorld,l.vertexNormalsWorld[0],U),r(i,l.v2.positionWorld,l.vertexNormalsWorld[1],S),r(i,l.v4.positionWorld,l.vertexNormalsWorld[3],aa),r(i,l.v3.positionWorld,l.vertexNormalsWorld[2],Z),U.r=Math.max(0,Math.min(n.color.r*U.r,1)),U.g=Math.max(0,Math.min(n.color.g*U.g,1)),U.b=Math.max(0,Math.min(n.color.b*U.b,1)),S.r=Math.max(0,Math.min(n.color.r*S.r,1)),S.g=Math.max(0,Math.min(n.color.g*S.g,1)),S.b=Math.max(0,Math.min(n.color.b* -S.b,1)),aa.r=Math.max(0,Math.min(n.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(n.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(n.color.b*aa.b,1)),Z.r=Math.max(0,Math.min(n.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(n.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(n.color.b*Z.b,1)),ja=Qa(U,S,aa,Z),y(Y,K,j,W,C,O),P(Y,K,j,W,C,O,0,0,1,0,0,1,ja),y(ea,X,J,L,fa,V),P(ea,X,J,L,fa,V,1,0,1,1,0,1,ja)):(R.r=wa.r,R.g=wa.g,R.b=wa.b,r(i,l.centroidWorld,l.normalWorld,R),R.r=Math.max(0,Math.min(n.color.r*R.r,1)),R.g=Math.max(0,Math.min(n.color.g* -R.g,1)),R.b=Math.max(0,Math.min(n.color.b*R.b,1)),I(Y,K,j,W,J,L,C,O),n.wireframe?Ba(R,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):M(R)):(I(Y,K,j,W,J,L,C,O),n.wireframe?Ba(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):M(n.color));else if(n instanceof THREE.MeshNormalMaterial)R.r=Ja(l.normalWorld.x),R.g=Ja(l.normalWorld.y),R.b=Ja(l.normalWorld.z),I(Y,K,j,W,J,L,C,O),n.wireframe?Ba(R,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):M(R);else if(n instanceof -THREE.MeshDepthMaterial)oa=k.near,sa=k.far,U.r=U.g=U.b=1-Fa(a.positionScreen.z,oa,sa),S.r=S.g=S.b=1-Fa(d.positionScreen.z,oa,sa),aa.r=aa.g=aa.b=1-Fa(f.positionScreen.z,oa,sa),Z.r=Z.g=Z.b=1-Fa(e.positionScreen.z,oa,sa),ja=Qa(U,S,aa,Z),y(Y,K,j,W,C,O),P(Y,K,j,W,C,O,0,0,1,0,0,1,ja),y(ea,X,J,L,fa,V),P(ea,X,J,L,fa,V,1,0,1,1,0,1,ja)}function y(a,b,c,d,e,g){l.beginPath();l.moveTo(a,b);l.lineTo(c,d);l.lineTo(e,g);l.lineTo(a,b);l.closePath()}function I(a,b,c,d,e,g,f,ga){l.beginPath();l.moveTo(a,b);l.lineTo(c, -d);l.lineTo(e,g);l.lineTo(f,ga);l.lineTo(a,b);l.closePath()}function Ba(a,b,c,e){if(z!=b)l.lineWidth=z=b;if(G!=c)l.lineCap=G=c;if(u!=e)l.lineJoin=u=e;d(a.getContextStyle());l.stroke();ua.inflate(b*2)}function M(a){e(a.getContextStyle());l.fill()}function Q(a,b,c,d,g,f,ga,h,j,i,n,k,ca){if(ca.image.width!=0){if(ca.needsUpdate==!0||qa[ca.id]==void 0){var ma=ca.wrapS==THREE.RepeatWrapping,m=ca.wrapT==THREE.RepeatWrapping;qa[ca.id]=l.createPattern(ca.image,ma&&m?"repeat":ma&&!m?"repeat-x":!ma&&m?"repeat-y": -"no-repeat");ca.needsUpdate=!1}e(qa[ca.id]);var ma=ca.offset.x/ca.repeat.x,m=ca.offset.y/ca.repeat.y,ta=ca.image.width*ca.repeat.x,o=ca.image.height*ca.repeat.y,ga=(ga+ma)*ta,h=(h+m)*o,j=(j+ma)*ta,i=(i+m)*o,n=(n+ma)*ta,k=(k+m)*o;c-=a;d-=b;g-=a;f-=b;j-=ga;i-=h;n-=ga;k-=h;ma=j*k-n*i;if(ma==0){if(da[ca.id]==void 0)b=document.createElement("canvas"),b.width=ca.image.width,b.height=ca.image.height,a=b.getContext("2d"),a.drawImage(ca.image,0,0),da[ca.id]=a.getImageData(0,0,ca.image.width,ca.image.height).data, -delete b;b=da[ca.id];ga=(Math.floor(ga)+Math.floor(h)*ca.image.width)*4;R.setRGB(b[ga]/255,b[ga+1]/255,b[ga+2]/255);M(R)}else ma=1/ma,ca=(k*c-i*g)*ma,i=(k*d-i*f)*ma,c=(j*g-n*c)*ma,d=(j*f-n*d)*ma,a=a-ca*ga-c*h,ga=b-i*ga-d*h,l.save(),l.transform(ca,i,c,d,a,ga),l.fill(),l.restore()}}function P(a,b,c,d,e,g,f,ga,h,j,i,n,k){var ca,ma;ca=k.width-1;ma=k.height-1;f*=ca;ga*=ma;h*=ca;j*=ma;i*=ca;n*=ma;c-=a;d-=b;e-=a;g-=b;h-=f;j-=ga;i-=f;n-=ga;ma=1/(h*n-i*j);ca=(n*c-j*e)*ma;j=(n*d-j*g)*ma;c=(h*e-i*c)*ma;d=(h* -g-i*d)*ma;a=a-ca*f-c*ga;b=b-j*f-d*ga;l.save();l.transform(ca,j,c,d,a,b);l.clip();l.drawImage(k,0,0);l.restore()}function Qa(a,b,c,d){var e=~~(a.r*255),g=~~(a.g*255),a=~~(a.b*255),f=~~(b.r*255),ga=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),i=~~(d.r*255),n=~~(d.g*255),d=~~(d.b*255);za[0]=e<0?0:e>255?255:e;za[1]=g<0?0:g>255?255:g;za[2]=a<0?0:a>255?255:a;za[4]=f<0?0:f>255?255:f;za[5]=ga<0?0:ga>255?255:ga;za[6]=b<0?0:b>255?255:b;za[8]=h<0?0:h>255?255:h;za[9]=j<0?0:j>255?255:j; -za[10]=c<0?0:c>255?255:c;za[12]=i<0?0:i>255?255:i;za[13]=n<0?0:n>255?255:n;za[14]=d<0?0:d>255?255:d;La.putImageData(D,0,0);Pa.drawImage(Ka,0,0);return Ma}function Fa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ja(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Ca(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Ra,Ta,T,$;this.autoClear?this.clear():l.setTransform(1,0,0,-1,n,q);g.info.render.vertices=0;g.info.render.faces=0;f=m.projectScene(a, -k,this.sortElements);h=f.elements;i=f.lights;(Sa=i.length>0)&&o(i);Ra=0;for(Ta=h.length;Ra1?1:a}var d=this,e,g,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,k,o,r,n,q,l,p,s=new THREE.Rectangle,t=new THREE.Rectangle,v=!1,y=new THREE.Color,I=new THREE.Color,z=new THREE.Color,G=new THREE.Color,u,F=new THREE.Vector3,A=[],x=[],B,N,ba,Y=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, -faces:0}};this.setQuality=function(a){switch(a){case "high":Y=1;break;case "low":Y=0}};this.setSize=function(a,b){m=a;k=b;o=m/2;r=k/2;i.setAttribute("viewBox",-o+" "+-r+" "+m+" "+k);i.setAttribute("width",m);i.setAttribute("height",k);s.set(-o,-r,o,r)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,j){var m,A,L,C;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(k,j,this.sortElements);g=e.elements; -f=e.lights;ba=N=0;if(v=f.length>0){I.setRGB(0,0,0);z.setRGB(0,0,0);G.setRGB(0,0,0);m=0;for(A=f.length;m0&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+s+")"),n.fillRect(Math.floor(va.getX()), +Math.floor(va.getY()),Math.floor(va.getWidth()),Math.floor(va.getHeight()))),va.empty())};this.render=function(a,j){function o(a){var b,c,d,e;wa.setRGB(0,0,0);Na.setRGB(0,0,0);Oa.setRGB(0,0,0);b=0;for(c=a.length;b>1,l=i.height>>1,f=g.scale.x*m,k=g.scale.y*p,h=f*j,ga=k*l,ta.set(a.x-h,a.y-ga,a.x+h,a.y+ga),ea.intersects(ta)&&(n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(f,-k),n.translate(-j,-l),n.drawImage(i,0,0),n.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(h=g.scale.x*m,ga=g.scale.y*p,ta.set(a.x-h,a.y-ga,a.x+h,a.y+ga),ea.intersects(ta)&&(d(f.color.getContextStyle()),e(f.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(h,ga),f.program(n), +n.restore()))}function s(a,e,g,f){b(f.opacity);c(f.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(x!=a)n.lineWidth=x=a;a=f.linecap;if(C!=a)n.lineCap=C=a;a=f.linejoin;if(E!=a)n.lineJoin=E=a;d(f.color.getContextStyle());n.stroke();ta.inflate(f.linewidth*2)}}function t(a,d,e,f,h,ea,m,n){g.info.render.vertices+=3;g.info.render.faces++;b(n.opacity);c(n.blending); +V=a.positionScreen.x;Y=a.positionScreen.y;T=d.positionScreen.x;k=d.positionScreen.y;M=e.positionScreen.x;L=e.positionScreen.y;v(V,Y,T,k,M,L);if(n instanceof THREE.MeshBasicMaterial)if(n.map)n.map.mapping instanceof THREE.UVMapping&&(la=m.uvs[0],Q(V,Y,T,k,M,L,la[f].u,la[f].v,la[h].u,la[h].v,la[ea].u,la[ea].v,n.map));else if(n.envMap){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=j.matrixWorldInverse,qa.copy(m.vertexNormalsWorld[f]),ya=(qa.x*a.n11+qa.y*a.n12+qa.z*a.n13)*0.5+0.5, +xa=-(qa.x*a.n21+qa.y*a.n22+qa.z*a.n23)*0.5+0.5,qa.copy(m.vertexNormalsWorld[h]),ua=(qa.x*a.n11+qa.y*a.n12+qa.z*a.n13)*0.5+0.5,za=-(qa.x*a.n21+qa.y*a.n22+qa.z*a.n23)*0.5+0.5,qa.copy(m.vertexNormalsWorld[ea]),H=(qa.x*a.n11+qa.y*a.n12+qa.z*a.n13)*0.5+0.5,ga=-(qa.x*a.n21+qa.y*a.n22+qa.z*a.n23)*0.5+0.5,Q(V,Y,T,k,M,L,ya,xa,ua,za,H,ga,n.envMap)}else n.wireframe?Ba(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Aa(n.color);else if(n instanceof THREE.MeshLambertMaterial)n.map&&!n.wireframe&& +(n.map.mapping instanceof THREE.UVMapping&&(la=m.uvs[0],Q(V,Y,T,k,M,L,la[f].u,la[f].v,la[h].u,la[h].v,la[ea].u,la[ea].v,n.map)),c(THREE.SubtractiveBlending)),Ra?!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3?($.r=O.r=ba.r=wa.r,$.g=O.g=ba.g=wa.g,$.b=O.b=ba.b=wa.b,r(i,m.v1.positionWorld,m.vertexNormalsWorld[0],$),r(i,m.v2.positionWorld,m.vertexNormalsWorld[1],O),r(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ba),$.r=Math.max(0,Math.min(n.color.r*$.r,1)),$.g=Math.max(0, +Math.min(n.color.g*$.g,1)),$.b=Math.max(0,Math.min(n.color.b*$.b,1)),O.r=Math.max(0,Math.min(n.color.r*O.r,1)),O.g=Math.max(0,Math.min(n.color.g*O.g,1)),O.b=Math.max(0,Math.min(n.color.b*O.b,1)),ba.r=Math.max(0,Math.min(n.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(n.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(n.color.b*ba.b,1)),aa.r=(O.r+ba.r)*0.5,aa.g=(O.g+ba.g)*0.5,aa.b=(O.b+ba.b)*0.5,ka=P($,O,ba,aa),N(V,Y,T,k,M,L,0,0,1,0,0,1,ka)):(S.r=wa.r,S.g=wa.g,S.b=wa.b,r(i,m.centroidWorld,m.normalWorld,S),S.r= +Math.max(0,Math.min(n.color.r*S.r,1)),S.g=Math.max(0,Math.min(n.color.g*S.g,1)),S.b=Math.max(0,Math.min(n.color.b*S.b,1)),n.wireframe?Ba(S,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Aa(S)):n.wireframe?Ba(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Aa(n.color);else if(n instanceof THREE.MeshDepthMaterial)na=j.near,sa=j.far,$.r=$.g=$.b=1-Fa(a.positionScreen.z,na,sa),O.r=O.g=O.b=1-Fa(d.positionScreen.z,na,sa),ba.r=ba.g=ba.b=1-Fa(e.positionScreen.z,na,sa),aa.r= +(O.r+ba.r)*0.5,aa.g=(O.g+ba.g)*0.5,aa.b=(O.b+ba.b)*0.5,ka=P($,O,ba,aa),N(V,Y,T,k,M,L,0,0,1,0,0,1,ka);else if(n instanceof THREE.MeshNormalMaterial)S.r=Ja(m.normalWorld.x),S.g=Ja(m.normalWorld.y),S.b=Ja(m.normalWorld.z),n.wireframe?Ba(S,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Aa(S)}function u(a,d,e,f,h,ga,n,m,ea){g.info.render.vertices+=4;g.info.render.faces++;b(m.opacity);c(m.blending);if(m.map||m.envMap)t(a,d,f,0,1,3,n,m,ea),t(h,e,ga,1,2,3,n,m,ea);else if(V=a.positionScreen.x, +Y=a.positionScreen.y,T=d.positionScreen.x,k=d.positionScreen.y,M=e.positionScreen.x,L=e.positionScreen.y,I=f.positionScreen.x,w=f.positionScreen.y,W=h.positionScreen.x,da=h.positionScreen.y,fa=ga.positionScreen.x,X=ga.positionScreen.y,m instanceof THREE.MeshBasicMaterial)B(V,Y,T,k,M,L,I,w),m.wireframe?Ba(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Aa(m.color);else if(m instanceof THREE.MeshLambertMaterial)Ra?!m.wireframe&&m.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length== +4?($.r=O.r=ba.r=aa.r=wa.r,$.g=O.g=ba.g=aa.g=wa.g,$.b=O.b=ba.b=aa.b=wa.b,r(i,n.v1.positionWorld,n.vertexNormalsWorld[0],$),r(i,n.v2.positionWorld,n.vertexNormalsWorld[1],O),r(i,n.v4.positionWorld,n.vertexNormalsWorld[3],ba),r(i,n.v3.positionWorld,n.vertexNormalsWorld[2],aa),$.r=Math.max(0,Math.min(m.color.r*$.r,1)),$.g=Math.max(0,Math.min(m.color.g*$.g,1)),$.b=Math.max(0,Math.min(m.color.b*$.b,1)),O.r=Math.max(0,Math.min(m.color.r*O.r,1)),O.g=Math.max(0,Math.min(m.color.g*O.g,1)),O.b=Math.max(0,Math.min(m.color.b* +O.b,1)),ba.r=Math.max(0,Math.min(m.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(m.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(m.color.b*ba.b,1)),aa.r=Math.max(0,Math.min(m.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(m.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(m.color.b*aa.b,1)),ka=P($,O,ba,aa),v(V,Y,T,k,I,w),N(V,Y,T,k,I,w,0,0,1,0,0,1,ka),v(W,da,M,L,fa,X),N(W,da,M,L,fa,X,1,0,1,1,0,1,ka)):(S.r=wa.r,S.g=wa.g,S.b=wa.b,r(i,n.centroidWorld,n.normalWorld,S),S.r=Math.max(0,Math.min(m.color.r*S.r,1)),S.g=Math.max(0, +Math.min(m.color.g*S.g,1)),S.b=Math.max(0,Math.min(m.color.b*S.b,1)),B(V,Y,T,k,M,L,I,w),m.wireframe?Ba(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Aa(S)):(B(V,Y,T,k,M,L,I,w),m.wireframe?Ba(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Aa(m.color));else if(m instanceof THREE.MeshNormalMaterial)S.r=Ja(n.normalWorld.x),S.g=Ja(n.normalWorld.y),S.b=Ja(n.normalWorld.z),B(V,Y,T,k,M,L,I,w),m.wireframe?Ba(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin): +Aa(S);else if(m instanceof THREE.MeshDepthMaterial)na=j.near,sa=j.far,$.r=$.g=$.b=1-Fa(a.positionScreen.z,na,sa),O.r=O.g=O.b=1-Fa(d.positionScreen.z,na,sa),ba.r=ba.g=ba.b=1-Fa(f.positionScreen.z,na,sa),aa.r=aa.g=aa.b=1-Fa(e.positionScreen.z,na,sa),ka=P($,O,ba,aa),v(V,Y,T,k,I,w),N(V,Y,T,k,I,w,0,0,1,0,0,1,ka),v(W,da,M,L,fa,X),N(W,da,M,L,fa,X,1,0,1,1,0,1,ka)}function v(a,b,c,d,e,g){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,g);n.lineTo(a,b);n.closePath()}function B(a,b,c,d,e,g,f,h){n.beginPath(); +n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,g);n.lineTo(f,h);n.lineTo(a,b);n.closePath()}function Ba(a,b,c,e){if(x!=b)n.lineWidth=x=b;if(C!=c)n.lineCap=C=c;if(E!=e)n.lineJoin=E=e;d(a.getContextStyle());n.stroke();ta.inflate(b*2)}function Aa(a){e(a.getContextStyle());n.fill()}function Q(a,b,c,d,g,f,h,ga,k,i,m,j,ea){if(ea.image.width!=0){if(ea.needsUpdate==!0||pa[ea.id]==void 0){var l=ea.wrapS==THREE.RepeatWrapping,o=ea.wrapT==THREE.RepeatWrapping;pa[ea.id]=n.createPattern(ea.image,l&&o?"repeat":l&&!o?"repeat-x": +!l&&o?"repeat-y":"no-repeat");ea.needsUpdate=!1}e(pa[ea.id]);var l=ea.offset.x/ea.repeat.x,o=ea.offset.y/ea.repeat.y,r=ea.image.width*ea.repeat.x,p=ea.image.height*ea.repeat.y,h=(h+l)*r,ga=(ga+o)*p,k=(k+l)*r,i=(i+o)*p,m=(m+l)*r,j=(j+o)*p;c-=a;d-=b;g-=a;f-=b;k-=h;i-=ga;m-=h;j-=ga;l=k*j-m*i;if(l==0){if(ca[ea.id]==void 0)b=document.createElement("canvas"),b.width=ea.image.width,b.height=ea.image.height,a=b.getContext("2d"),a.drawImage(ea.image,0,0),ca[ea.id]=a.getImageData(0,0,ea.image.width,ea.image.height).data, +delete b;b=ca[ea.id];h=(Math.floor(h)+Math.floor(ga)*ea.image.width)*4;S.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);Aa(S)}else l=1/l,ea=(j*c-i*g)*l,i=(j*d-i*f)*l,c=(k*g-m*c)*l,d=(k*f-m*d)*l,a=a-ea*h-c*ga,h=b-i*h-d*ga,n.save(),n.transform(ea,i,c,d,a,h),n.fill(),n.restore()}}function N(a,b,c,d,e,g,f,h,ga,k,i,m,j){var ea,l;ea=j.width-1;l=j.height-1;f*=ea;h*=l;ga*=ea;k*=l;i*=ea;m*=l;c-=a;d-=b;e-=a;g-=b;ga-=f;k-=h;i-=f;m-=h;l=1/(ga*m-i*k);ea=(m*c-k*e)*l;k=(m*d-k*g)*l;c=(ga*e-i*c)*l;d=(ga*g-i*d)*l;a=a-ea*f- +c*h;b=b-k*f-d*h;n.save();n.transform(ea,k,c,d,a,b);n.clip();n.drawImage(j,0,0);n.restore()}function P(a,b,c,d){var e=~~(a.r*255),g=~~(a.g*255),a=~~(a.b*255),f=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),ga=~~(c.r*255),k=~~(c.g*255),c=~~(c.b*255),i=~~(d.r*255),m=~~(d.g*255),d=~~(d.b*255);A[0]=e<0?0:e>255?255:e;A[1]=g<0?0:g>255?255:g;A[2]=a<0?0:a>255?255:a;A[4]=f<0?0:f>255?255:f;A[5]=h<0?0:h>255?255:h;A[6]=b<0?0:b>255?255:b;A[8]=ga<0?0:ga>255?255:ga;A[9]=k<0?0:k>255?255:k;A[10]=c<0?0:c>255?255:c;A[12]= +i<0?0:i>255?255:i;A[13]=m<0?0:m>255?255:m;A[14]=d<0?0:d>255?255:d;La.putImageData(Sa,0,0);Pa.drawImage(Ka,0,0);return Ma}function Fa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ja(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Ca(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Qa,Ta,ra,Z;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,p);g.info.render.vertices=0;g.info.render.faces=0;f=l.projectScene(a,j,this.sortElements);h=f.elements; +i=f.lights;(Ra=i.length>0)&&o(i);Qa=0;for(Ta=h.length;Qa1?1:a}var d=this,e,g,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,j,o,r,m,p,n,q,s=new THREE.Rectangle,t=new THREE.Rectangle,u=!1,v=new THREE.Color,B=new THREE.Color,x=new THREE.Color,C=new THREE.Color,E,G=new THREE.Vector3,R=[],z=[],J,K,U,V=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, +faces:0}};this.setQuality=function(a){switch(a){case "high":V=1;break;case "low":V=0}};this.setSize=function(a,b){l=a;j=b;o=l/2;r=j/2;i.setAttribute("viewBox",-o+" "+-r+" "+l+" "+j);i.setAttribute("width",l);i.setAttribute("height",j);s.set(-o,-r,o,r)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(j,l){var k,R,L,I;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(j,l,this.sortElements);g=e.elements; +f=e.lights;U=K=0;if(u=f.length>0){B.setRGB(0,0,0);x.setRGB(0,0,0);C.setRGB(0,0,0);k=0;for(R=f.length;k=0)return a.geometry.materials[b.materialIndex]}function d(a){if(a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial)return!1;return a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){if(a.vertexColors)return a.vertexColors;return!1}function g(a){if(a.map||a.lightMap||a instanceof THREE.ShaderMaterial)return!0; -return!1}function f(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;var i=a.colors,n=i.length,k=a.__vertexArray,l=a.__colorArray,m=a.__sortArray,o=a.__dirtyVertices,r=a.__dirtyColors,q=a.__webglCustomAttributesList;if(c.sortParticles){ya.multiplySelf(c.matrixWorld);for(d=0;d=0;c--)a[c].object===b&&a.splice(c,1)}function q(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function l(a,b,c,d,e){d.program||K.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(K.maxMorphTargets);for(var f=0,g=K.maxMorphTargets;f0;this.getContext=function(){return j};this.supportsVertexTextures= -function(){return Aa};this.setSize=function(a,b){u.width=a;u.height=b;this.setViewport(0,0,u.width,u.height)};this.setViewport=function(a,b,c,d){da=a;oa=b;sa=c;ja=d;j.viewport(da,oa,sa,ja)};this.setScissor=function(a,b,c,d){j.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)};this.setClearColorHex=function(a,b){N.setHex(a);ba=b;j.clearColor(N.r,N.g,N.b,ba)};this.setClearColor=function(a,b){N.copy(a);ba=b;j.clearColor(N.r,N.g,N.b,ba)};this.getClearColor= -function(){return N};this.getClearAlpha=function(){return ba};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=j.COLOR_BUFFER_BIT;if(b===void 0||b)d|=j.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit= -!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];j.deleteBuffer(c.__webglVertexBuffer);j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer); -j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d=0)a&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;f.morphTargetBase!==-1?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]),j.vertexAttribPointer(c.position, -3,j.FLOAT,!1,0,0)):c.position>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;gn&&(k=m,n=h[k]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[k]);j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[g]=n;i[k]=1;n=-1;g++}}d.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g=0;for(h= -e.__webglCustomAttributesList.length;g=0&&(j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,!1,0,0))}b.color>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglColorBuffer),j.vertexAttribPointer(b.color,3,j.FLOAT,!1,0,0));b.normal>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglNormalBuffer),j.vertexAttribPointer(b.normal,3,j.FLOAT,!1,0,0));b.tangent>=0&&(j.bindBuffer(j.ARRAY_BUFFER, -e.__webglTangentBuffer),j.vertexAttribPointer(b.tangent,4,j.FLOAT,!1,0,0));b.uv>=0&&(e.__webglUVBuffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUVBuffer),j.vertexAttribPointer(b.uv,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv)):j.disableVertexAttribArray(b.uv));b.uv2>=0&&(e.__webglUV2Buffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUV2Buffer),j.vertexAttribPointer(b.uv2,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv2)):j.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>= -0&&b.skinIndex>=0&&b.skinWeight>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexABuffer),j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe? -(d=d.wireframeLinewidth,d!==qa&&(j.lineWidth(d),qa=d),a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,0)):(a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)),K.info.render.calls++,K.info.render.vertices+=e.__webglFaceCount,K.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!== -qa&&(j.lineWidth(d),qa=d),j.drawArrays(f,0,e.__webglLineCount),K.info.render.calls++):f instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),K.info.render.calls++):f instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),K.info.render.calls++)}};this.render=function(a,b,c,d){var e,f,g,n,k=a.lights,l=a.fog;C=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."), -a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();if(this.renderPluginsPre.length){e=0;for(f=this.renderPluginsPre.length;e=0)x=q.geometry.materials[x],x.transparent?(o.transparent=x,o.opaque=null):(o.opaque=x,o.transparent=null)}else if(x)x.transparent?(o.transparent=x,o.opaque=null):(o.opaque=x,o.transparent=null);g.render=!0;if(this.sortObjects)n.renderDepth?g.z=n.renderDepth:(va.copy(n.position),ya.multiplyVector3(va),g.z=va.z)}this.sortObjects&&d.sort(h);d=a.__webglObjectsImmediate;e=0;for(f=d.length;e65535&&(A[y].counter+= -1,D=A[y].hash+"_"+A[y].counter,p.geometryGroups[D]===void 0&&(p.geometryGroups[D]={faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:N})),x instanceof THREE.Face3?p.geometryGroups[D].faces3.push(s):p.geometryGroups[D].faces4.push(s),p.geometryGroups[D].vertices+=B;p.geometryGroupsList=[];s=void 0;for(s in p.geometryGroups)p.geometryGroups[s].id=ea++,p.geometryGroupsList.push(p.geometryGroups[s])}for(l in m.geometryGroups)if(p=m.geometryGroups[l],!p.__webglVertexBuffer){s=p;s.__webglVertexBuffer= -j.createBuffer();s.__webglNormalBuffer=j.createBuffer();s.__webglTangentBuffer=j.createBuffer();s.__webglColorBuffer=j.createBuffer();s.__webglUVBuffer=j.createBuffer();s.__webglUV2Buffer=j.createBuffer();s.__webglSkinVertexABuffer=j.createBuffer();s.__webglSkinVertexBBuffer=j.createBuffer();s.__webglSkinIndicesBuffer=j.createBuffer();s.__webglSkinWeightsBuffer=j.createBuffer();s.__webglFaceBuffer=j.createBuffer();s.__webglLineBuffer=j.createBuffer();if(s.numMorphTargets){x=t=void 0;s.__webglMorphTargetsBuffers= -[];t=0;for(x=s.numMorphTargets;t0||B.faceVertexUvs.length>0)p.__uvArray= -new Float32Array(s*2);if(B.faceUvs.length>1||B.faceVertexUvs.length>1)p.__uv2Array=new Float32Array(s*2)}if(v.geometry.skinWeights.length&&v.geometry.skinIndices.length)p.__skinVertexAArray=new Float32Array(s*4),p.__skinVertexBArray=new Float32Array(s*4),p.__skinIndexArray=new Float32Array(s*4),p.__skinWeightArray=new Float32Array(s*4);p.__faceArray=new Uint16Array(x*3);p.__lineArray=new Uint16Array(y*2);if(p.numMorphTargets){p.__morphTargetsArrays=[];v=0;for(B=p.numMorphTargets;v0&&(j.bindBuffer(j.ARRAY_BUFFER,t.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,W,x),j.bindBuffer(j.ARRAY_BUFFER,t.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,S,x),j.bindBuffer(j.ARRAY_BUFFER,t.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,J,x),j.bindBuffer(j.ARRAY_BUFFER,t.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,pa,x))}if(ya&&y){D=0;for(A=C.length;D0&&(j.bindBuffer(j.ARRAY_BUFFER,t.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,V, -x))}if(ba&&U.hasTangents){D=0;for(A=C.length;D0&&(j.bindBuffer(j.ARRAY_BUFFER,t.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,fa,x))}if(va&&Aa&&L){D=0;for(A=C.length;D0&&(j.bindBuffer(j.ARRAY_BUFFER,t.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,E,x))}if(sa){D=0;for(A=C.length;D=0&&j.enableVertexAttribArray(o.position);o.color>=0&&j.enableVertexAttribArray(o.color);o.normal>=0&&j.enableVertexAttribArray(o.normal); -o.tangent>=0&&j.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(j.enableVertexAttribArray(o.skinVertexA),j.enableVertexAttribArray(o.skinVertexB),j.enableVertexAttribArray(o.skinIndex),j.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(f in a.attributes)o[f]!==void 0&&o[f]>=0&&j.enableVertexAttribArray(o[f]);if(a.morphTargets)for(f=a.numSupportedMorphTargets=0;f=0&&(j.enableVertexAttribArray(o[q]), -a.numSupportedMorphTargets++);a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?j.frontFace(j.CCW):j.frontFace(j.CW),a==="back"?j.cullFace(j.BACK):a==="front"?j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK),j.enable(j.CULL_FACE)):j.disable(j.CULL_FACE)};this.setObjectFaces=function(a){if(X!==a.doubleSided)a.doubleSided?j.disable(j.CULL_FACE):j.enable(j.CULL_FACE),X=a.doubleSided;if(fa!==a.flipSided)a.flipSided?j.frontFace(j.CW): -j.frontFace(j.CCW),fa=a.flipSided};this.setDepthTest=function(a){R!==a&&(a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),R=a)};this.setBlending=function(a){if(a!==V){switch(a){case THREE.AdditiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE);break;case THREE.SubtractiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.SRC_COLOR);break;default:j.blendEquationSeparate(j.FUNC_ADD, -j.FUNC_ADD),j.blendFuncSeparate(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA,j.ONE,j.ONE_MINUS_SRC_ALPHA)}V=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=j.createTexture(),K.info.memory.textures++;j.activeTexture(j.TEXTURE0+b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture);var c=y(j.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?j.texImage2D(j.TEXTURE_2D,0,G(a.format),a.image.width,a.image.height,0,G(a.format),j.UNSIGNED_BYTE,a.image.data):j.texImage2D(j.TEXTURE_2D, -0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,a.image);c&&j.generateMipmap(j.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else j.activeTexture(j.TEXTURE0+b),j.bindTexture(j.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=j.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];j.bindTexture(j.TEXTURE_CUBE_MAP, -a.__webglTexture);y(j.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=j.createFramebuffer();a.__webglRenderbuffer[c]=j.createRenderbuffer();j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,G(a.format),a.width,a.height,0,G(a.format),G(a.type),null);var d=a,e=j.TEXTURE_CUBE_MAP_POSITIVE_X+c;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[c]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,e,d.__webglTexture,0);I(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=j.createFramebuffer(), -a.__webglRenderbuffer=j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture),y(j.TEXTURE_2D,a,a),j.texImage2D(j.TEXTURE_2D,0,G(a.format),a.width,a.height,0,G(a.format),G(a.type),null),c=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,c,a.__webglTexture,0),I(a.__webglRenderbuffer,a);b?j.bindTexture(j.TEXTURE_CUBE_MAP,null):j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER, -null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=sa,a=ja,d=da,e=oa);b!==L&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(d,e,c,a),L=b)};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; +return!1}function f(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;var i=a.colors,m=i.length,j=a.__vertexArray,n=a.__colorArray,l=a.__sortArray,o=a.__dirtyVertices,r=a.__dirtyColors,p=a.__webglCustomAttributesList;if(c.sortParticles){xa.multiplySelf(c.matrixWorld);for(d=0;d=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,e){d.program||T.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences= +new Float32Array(T.maxMorphTargets);for(var f=0,g=T.maxMorphTargets;f +0;this.getContext=function(){return k};this.supportsVertexTextures=function(){return H};this.setSize=function(a,b){G.width=a;G.height=b;this.setViewport(0,0,G.width,G.height)};this.setViewport=function(a,b,c,d){na=a;sa=b;ka=c;la=d;k.viewport(na,sa,ka,la)};this.setScissor=function(a,b,c,d){k.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?k.enable(k.SCISSOR_TEST):k.disable(k.SCISSOR_TEST)};this.setClearColorHex=function(a,b){U.setHex(a);V=b;k.clearColor(U.r,U.g,U.b,V)};this.setClearColor=function(a, +b){U.copy(a);V=b;k.clearColor(U.r,U.g,U.b,V)};this.getClearColor=function(){return U};this.getClearAlpha=function(){return V};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=k.COLOR_BUFFER_BIT;if(b===void 0||b)d|=k.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=k.STENCIL_BUFFER_BIT;k.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)}; +this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];k.deleteBuffer(c.__webglVertexBuffer);k.deleteBuffer(c.__webglNormalBuffer);k.deleteBuffer(c.__webglTangentBuffer);k.deleteBuffer(c.__webglColorBuffer);k.deleteBuffer(c.__webglUVBuffer);k.deleteBuffer(c.__webglUV2Buffer); +k.deleteBuffer(c.__webglSkinVertexABuffer);k.deleteBuffer(c.__webglSkinVertexBBuffer);k.deleteBuffer(c.__webglSkinIndicesBuffer);k.deleteBuffer(c.__webglSkinWeightsBuffer);k.deleteBuffer(c.__webglFaceBuffer);k.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d=0)a&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglVertexBuffer),k.vertexAttribPointer(b.position,3,k.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;f.morphTargetBase!==-1?(k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]), +k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0)):c.position>=0&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglVertexBuffer),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;gm&&(j=n,m=h[j]);k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[j]);k.vertexAttribPointer(c["morphTarget"+g],3,k.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[g]=m;i[j]=1;m=-1;g++}}d.program.uniforms.morphTargetInfluences!==null&&k.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g= +0;for(h=e.__webglCustomAttributesList.length;g=0&&(k.bindBuffer(k.ARRAY_BUFFER,c.buffer),k.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,k.FLOAT,!1,0,0))}b.color>=0&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglColorBuffer),k.vertexAttribPointer(b.color,3,k.FLOAT,!1,0,0));b.normal>=0&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglNormalBuffer),k.vertexAttribPointer(b.normal,3,k.FLOAT,!1,0,0));b.tangent>=0&&(k.bindBuffer(k.ARRAY_BUFFER, +e.__webglTangentBuffer),k.vertexAttribPointer(b.tangent,4,k.FLOAT,!1,0,0));b.uv>=0&&(e.__webglUVBuffer?(k.bindBuffer(k.ARRAY_BUFFER,e.__webglUVBuffer),k.vertexAttribPointer(b.uv,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv)):k.disableVertexAttribArray(b.uv));b.uv2>=0&&(e.__webglUV2Buffer?(k.bindBuffer(k.ARRAY_BUFFER,e.__webglUV2Buffer),k.vertexAttribPointer(b.uv2,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv2)):k.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>= +0&&b.skinIndex>=0&&b.skinWeight>=0&&(k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinVertexABuffer),k.vertexAttribPointer(b.skinVertexA,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),k.vertexAttribPointer(b.skinVertexB,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),k.vertexAttribPointer(b.skinIndex,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe? +(d=d.wireframeLinewidth,d!==ca&&(k.lineWidth(d),ca=d),a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),k.drawElements(k.LINES,e.__webglLineCount,k.UNSIGNED_SHORT,0)):(a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),k.drawElements(k.TRIANGLES,e.__webglFaceCount,k.UNSIGNED_SHORT,0)),T.info.render.calls++,T.info.render.vertices+=e.__webglFaceCount,T.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?k.LINE_STRIP:k.LINES,d=d.linewidth,d!== +ca&&(k.lineWidth(d),ca=d),k.drawArrays(f,0,e.__webglLineCount),T.info.render.calls++):f instanceof THREE.ParticleSystem?(k.drawArrays(k.POINTS,0,e.__webglParticleCount),T.info.render.calls++):f instanceof THREE.Ribbon&&(k.drawArrays(k.TRIANGLE_STRIP,0,e.__webglVertexCount),T.info.render.calls++)}};this.render=function(a,b,c,d){var e,f,g,m,n=a.lights,o=a.fog;w=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."), +a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();i(this.renderPluginsPre,a,b);T.info.render.calls=0;T.info.render.vertices=0;T.info.render.faces=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);xa.multiply(b.projectionMatrix,b.matrixWorldInverse); +ya.setFromMatrix(xa);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0;for(e=m.length;d=0)H=r.geometry.materials[H], +H.transparent?(p.transparent=H,p.opaque=null):(p.opaque=H,p.transparent=null)}else if(H)H.transparent?(p.transparent=H,p.opaque=null):(p.opaque=H,p.transparent=null);f.render=!0;if(this.sortObjects)g.renderDepth?f.z=g.renderDepth:(ua.copy(g.position),xa.multiplyVector3(ua),f.z=ua.z)}this.sortObjects&&m.sort(h);m=a.__webglObjectsImmediate;d=0;for(e=m.length;d65535&&(v[J].counter+=1,A=v[J].hash+"_"+v[J].counter,H.geometryGroups[A]===void 0&&(H.geometryGroups[A]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:R})),t instanceof THREE.Face3?H.geometryGroups[A].faces3.push(q):H.geometryGroups[A].faces4.push(q), +H.geometryGroups[A].vertices+=u;H.geometryGroupsList=[];q=void 0;for(q in H.geometryGroups)H.geometryGroups[q].id=da++,H.geometryGroupsList.push(H.geometryGroups[q])}for(j in l.geometryGroups)if(H=l.geometryGroups[j],!H.__webglVertexBuffer){q=H;q.__webglVertexBuffer=k.createBuffer();q.__webglNormalBuffer=k.createBuffer();q.__webglTangentBuffer=k.createBuffer();q.__webglColorBuffer=k.createBuffer();q.__webglUVBuffer=k.createBuffer();q.__webglUV2Buffer=k.createBuffer();q.__webglSkinVertexABuffer=k.createBuffer(); +q.__webglSkinVertexBBuffer=k.createBuffer();q.__webglSkinIndicesBuffer=k.createBuffer();q.__webglSkinWeightsBuffer=k.createBuffer();q.__webglFaceBuffer=k.createBuffer();q.__webglLineBuffer=k.createBuffer();if(q.numMorphTargets){t=s=void 0;q.__webglMorphTargetsBuffers=[];s=0;for(t=q.numMorphTargets;s0||u.faceVertexUvs.length>0)H.__uvArray=new Float32Array(q*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)H.__uv2Array=new Float32Array(q*2)}if(z.geometry.skinWeights.length&&z.geometry.skinIndices.length)H.__skinVertexAArray=new Float32Array(q*4),H.__skinVertexBArray= +new Float32Array(q*4),H.__skinIndexArray=new Float32Array(q*4),H.__skinWeightArray=new Float32Array(q*4);H.__faceArray=new Uint16Array(t*3);H.__lineArray=new Uint16Array(J*2);if(H.numMorphTargets){H.__morphTargetsArrays=[];z=0;for(u=H.numMorphTargets;z0&&(k.bindBuffer(k.ARRAY_BUFFER,s.__webglSkinVertexABuffer),k.bufferData(k.ARRAY_BUFFER,S,t),k.bindBuffer(k.ARRAY_BUFFER,s.__webglSkinVertexBBuffer), +k.bufferData(k.ARRAY_BUFFER,X,t),k.bindBuffer(k.ARRAY_BUFFER,s.__webglSkinIndicesBuffer),k.bufferData(k.ARRAY_BUFFER,C,t),k.bindBuffer(k.ARRAY_BUFFER,s.__webglSkinWeightsBuffer),k.bufferData(k.ARRAY_BUFFER,oa,t))}if(xa&&J){A=0;for(v=x.length;A0&&(k.bindBuffer(k.ARRAY_BUFFER,s.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,W,t))}if(M&&V.hasTangents){A=0;for(v=x.length;A0&&(k.bindBuffer(k.ARRAY_BUFFER,s.__webglUVBuffer),k.bufferData(k.ARRAY_BUFFER,fa,t))}if(ua&&za&&L){A=0;for(v=x.length;A0&&(k.bindBuffer(k.ARRAY_BUFFER,s.__webglUV2Buffer), +k.bufferData(k.ARRAY_BUFFER,D,t))}if(sa){A=0;for(v=x.length;A=0&&k.enableVertexAttribArray(o.position);o.color>=0&&k.enableVertexAttribArray(o.color);o.normal>=0&&k.enableVertexAttribArray(o.normal); +o.tangent>=0&&k.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(k.enableVertexAttribArray(o.skinVertexA),k.enableVertexAttribArray(o.skinVertexB),k.enableVertexAttribArray(o.skinIndex),k.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(f in a.attributes)o[f]!==void 0&&o[f]>=0&&k.enableVertexAttribArray(o[f]);if(a.morphTargets)for(f=a.numSupportedMorphTargets=0;f=0&&(k.enableVertexAttribArray(o[q]), +a.numSupportedMorphTargets++);a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?k.frontFace(k.CCW):k.frontFace(k.CW),a==="back"?k.cullFace(k.BACK):a==="front"?k.cullFace(k.FRONT):k.cullFace(k.FRONT_AND_BACK),k.enable(k.CULL_FACE)):k.disable(k.CULL_FACE)};this.setObjectFaces=function(a){if(fa!==a.doubleSided)a.doubleSided?k.disable(k.CULL_FACE):k.enable(k.CULL_FACE),fa=a.doubleSided;if(X!==a.flipSided)a.flipSided?k.frontFace(k.CW): +k.frontFace(k.CCW),X=a.flipSided};this.setDepthTest=function(a){$!==a&&(a?k.enable(k.DEPTH_TEST):k.disable(k.DEPTH_TEST),$=a)};this.setBlending=function(a){if(a!==S){switch(a){case THREE.AdditiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE);break;case THREE.SubtractiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.SRC_COLOR);break;default:k.blendEquationSeparate(k.FUNC_ADD, +k.FUNC_ADD),k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)}S=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=k.createTexture(),T.info.memory.textures++;k.activeTexture(k.TEXTURE0+b);k.bindTexture(k.TEXTURE_2D,a.__webglTexture);var c=B(k.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?k.texImage2D(k.TEXTURE_2D,0,E(a.format),a.image.width,a.image.height,0,E(a.format),k.UNSIGNED_BYTE,a.image.data):k.texImage2D(k.TEXTURE_2D, +0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,a.image);c&&k.generateMipmap(k.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else k.activeTexture(k.TEXTURE0+b),k.bindTexture(k.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=k.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];k.bindTexture(k.TEXTURE_CUBE_MAP, +a.__webglTexture);B(k.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=k.createFramebuffer();a.__webglRenderbuffer[c]=k.createRenderbuffer();k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,E(a.format),a.width,a.height,0,E(a.format),E(a.type),null);var d=a,e=k.TEXTURE_CUBE_MAP_POSITIVE_X+c;k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer[c]);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,e,d.__webglTexture,0);x(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=k.createFramebuffer(), +a.__webglRenderbuffer=k.createRenderbuffer(),k.bindTexture(k.TEXTURE_2D,a.__webglTexture),B(k.TEXTURE_2D,a,a),k.texImage2D(k.TEXTURE_2D,0,E(a.format),a.width,a.height,0,E(a.format),E(a.type),null),c=k.TEXTURE_2D,k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer),k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,c,a.__webglTexture,0),x(a.__webglRenderbuffer,a);b?k.bindTexture(k.TEXTURE_CUBE_MAP,null):k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER, +null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=ka,a=la,d=na,e=sa);b!==I&&(k.bindFramebuffer(k.FRAMEBUFFER,b),k.viewport(d,e,c,a),I=b)};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==void 0?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==void 0?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==void 0?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==void 0?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:THREE.RGBAFormat;this.type=c.type!==void 0?c.type: THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:!0}; THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0}; @@ -340,19 +339,19 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null}; THREE.ColorUtils={adjustHSV:function(a,b,c,d){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.Math.clamp(e.h+b,0,1);e.s=THREE.Math.clamp(e.s+c,0,1);e.v=THREE.Math.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,e=a.b,g=Math.max(Math.max(c,d),e),f=Math.min(Math.min(c,d),e);if(f===g)f=c=0;else{var h=g-f,f=h/g,c=c===g?(d-e)/h:d===g?2+(e-c)/h:4+(c-d)/h;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=f;b.v=g;return b}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,g=b instanceof THREE.Mesh?b.geometry:b,f=a.vertices,h=g.vertices,i=a.faces,m=g.faces,k=a.faceVertexUvs[0],o=g.faceVertexUvs[0],r={},n=0;n1&&(d=1-d,e=1-e);g=1-d-e;f.copy(a);f.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);f.addSelf(h);h.copy(c);h.multiplyScalar(g);f.addSelf(h);return f},randomPointInFace:function(a,b,c){var d,e,g;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,e=b.vertices[a.b].position, g=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,g);else if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;g=b.vertices[a.c].position;var b=b.vertices[a.d].position,f;c?a._area1&&a._area2?(c=a._area1,f=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),f=THREE.GeometryUtils.triangleArea(e,g,b),a._area1=c,a._area2=f):(c=THREE.GeometryUtils.triangleArea(d,e,b),f=THREE.GeometryUtils.triangleArea(e,g,b));return THREE.GeometryUtils.random()*(c+ -f)a?b(c,e-1):m[e]a?b(c,e-1):l[e]0?(f=c[c.length-1],n=f.x,q=f.y):(f=this.actions[d-1].args,n=f[f.length-2],q=f[f.length-1]);for(f=1;f<=a;f++)l=f/a,g=THREE.Shape.Utils.b2(l,n,o,h),l=THREE.Shape.Utils.b2(l,q,r, -i),c.push(new THREE.Vector2(g,l));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];o=g[0];r=g[1];m=g[2];k=g[3];c.length>0?(f=c[c.length-1],n=f.x,q=f.y):(f=this.actions[d-1].args,n=f[f.length-2],q=f[f.length-1]);for(f=1;f<=a;f++)l=f/a,g=THREE.Shape.Utils.b3(l,n,o,m,h),l=THREE.Shape.Utils.b3(l,q,r,k,i),c.push(new THREE.Vector2(g,l));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];l=a*g[0].length;f=f.concat(g[0]);g=new THREE.SplineCurve(f); -for(f=1;f<=l;f++)c.push(g.getPointAt(f/l));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=g[0];i=g[1];m=g[2];o=g[3];l=g[4];r=!!g[5];k=f[f.length-2];n=f[f.length-1];f.length==0&&(k=n=0);q=l-o;var p=a*2;for(f=1;f<=p;f++)l=f/p,r||(l=1-l),l=o+l*q,g=k+h+m*Math.cos(l),l=n+i+m*Math.sin(l),c.push(new THREE.Vector2(g,l))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; -THREE.Path.prototype.nltransform=function(a,b,c,d,e,g){var f=this.getPoints(),h,i,m,k,o;h=0;for(i=f.length;h0?(f=c[c.length-1],m=f.x,p=f.y):(f=this.actions[d-1].args,m=f[f.length-2],p=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b2(n,m,o,h),n=THREE.Shape.Utils.b2(n,p,r, +i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];o=g[0];r=g[1];l=g[2];j=g[3];c.length>0?(f=c[c.length-1],m=f.x,p=f.y):(f=this.actions[d-1].args,m=f[f.length-2],p=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b3(n,m,o,l,h),n=THREE.Shape.Utils.b3(n,p,r,j,i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];n=a*g[0].length;f=f.concat(g[0]);g=new THREE.SplineCurve(f); +for(f=1;f<=n;f++)c.push(g.getPointAt(f/n));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=g[0];i=g[1];l=g[2];o=g[3];n=g[4];r=!!g[5];j=f[f.length-2];m=f[f.length-1];f.length==0&&(j=m=0);p=n-o;var q=a*2;for(f=1;f<=q;f++)n=f/q,r||(n=1-n),n=o+n*p,g=j+h+l*Math.cos(n),n=m+i+l*Math.sin(n),c.push(new THREE.Vector2(g,n))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; +THREE.Path.prototype.nltransform=function(a,b,c,d,e,g){var f=this.getPoints(),h,i,l,j,o;h=0;for(i=f.length;h=0?h-1:c.length-1;g=f-1>=0?f-1:m.length-1;var l=[m[f],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(l);var p=[m[f],m[g],c[h]];r=THREE.FontUtils.Triangulate.area(p);n=h;k=f;h+=1;f+=-1;h< -0&&(h+=c.length);h%=c.length;f<0&&(f+=m.length);f%=m.length;e=h-1>=0?h-1:c.length-1;g=f-1>=0?f-1:m.length-1;l=[m[f],c[h],c[e]];l=THREE.FontUtils.Triangulate.area(l);p=[m[f],m[g],c[h]];p=THREE.FontUtils.Triangulate.area(p);o+r>l+p&&(h=n,f=k,h<0&&(h+=c.length),h%=c.length,f<0&&(f+=m.length),f%=m.length,e=h-1>=0?h-1:c.length-1,g=f-1>=0?f-1:m.length-1);o=c.slice(0,h);r=c.slice(h);n=m.slice(f);k=m.slice(0,f);g=[m[f],m[g],c[h]];q.push([m[f],c[h],c[e]]);q.push(g);c=o.concat(n).concat(k).concat(r)}return{shape:c, -isolatedPts:q,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),g,f,h,i,m={};g=0;for(f=d.length;g=0?h-1:c.length-1;g=f-1>=0?f-1:l.length-1;var n=[l[f],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(n);var q=[l[f],l[g],c[h]];r=THREE.FontUtils.Triangulate.area(q);m=h;j=f;h+=1;f+=-1;h< +0&&(h+=c.length);h%=c.length;f<0&&(f+=l.length);f%=l.length;e=h-1>=0?h-1:c.length-1;g=f-1>=0?f-1:l.length-1;n=[l[f],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);q=[l[f],l[g],c[h]];q=THREE.FontUtils.Triangulate.area(q);o+r>n+q&&(h=m,f=j,h<0&&(h+=c.length),h%=c.length,f<0&&(f+=l.length),f%=l.length,e=h-1>=0?h-1:c.length-1,g=f-1>=0?f-1:l.length-1);o=c.slice(0,h);r=c.slice(h);m=l.slice(f);j=l.slice(0,f);g=[l[f],l[g],c[h]];p.push([l[f],c[h],c[e]]);p.push(g);c=o.concat(m).concat(j).concat(r)}return{shape:c, +isolatedPts:p,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),g,f,h,i,l={};g=0;for(f=d.length;g1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",n,f.index-1).pos,this.points[1]=e,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos,d=d*0.33+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(c=== -"rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d}}if(this.JITCompile&&k[0][m]===void 0){this.hierarchy[0].update(null,!0);for(n=0;na.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];h=a[c[1]];i=a[c[2]];m=a[c[3]];c=e*e;f=e*c;d[0]=this.interpolate(g[0],h[0],i[0],m[0],e,c,f);d[1]=this.interpolate(g[1],h[1],i[1],m[1],e,c,f);d[2]=this.interpolate(g[2],h[2],i[2],m[2],e,c,f);return d}; +THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,d,e,g,f,h,i,l,j=this.data.JIT.hierarchy,o,r;this.currentTime+=a*this.timeScale;r=this.currentTime;o=this.currentTime%=this.data.length;l=parseInt(Math.min(o*this.data.fps,this.data.length*this.data.fps),10);for(var m=0,p=this.hierarchy.length;m1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+m),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",m,f.index-1).pos,this.points[1]=e,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",m,h.index+1).pos,d=d*0.33+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(c=== +"rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d}}if(this.JITCompile&&j[0][l]===void 0){this.hierarchy[0].update(null,!0);for(m=0;ma.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];h=a[c[1]];i=a[c[2]];l=a[c[3]];c=e*e;f=e*c;d[0]=this.interpolate(g[0],h[0],i[0],l[0],e,c,f);d[1]=this.interpolate(g[1],h[1],i[1],l[1],e,c,f);d[2]=this.interpolate(g[2],h[2],i[2],l[2],e,c,f);return d}; THREE.Animation.prototype.interpolate=function(a,b,c,d,e,g,f){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*f+(-3*(b-c)-2*a-d)*g+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]}; THREE.CubeCamera=function(a,b,c,d){this.heightOffset=c;this.position=new THREE.Vector3(0,c,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position= @@ -449,14 +448,14 @@ function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37: this.object.translateX(b);this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);c=a*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a= 1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)* Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)}; -THREE.PathControls=function(a,b){function c(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function e(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),p=g.length,s=0;f=p-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f=0?a:a+f;b=this.verticalAngleMap.srcRange; a=this.verticalAngleMap.dstRange;b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove= function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}), c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=e(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a= -this.debugPath,b=this.spline,f=g(b,10),c=g(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),f=new THREE.Line(f,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));f.scale.set(1,1,1);a.add(f);c.scale.set(1,1,1);a.add(c);for(var f=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),n=0;n0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*m);this.object.translateY(b*k);f&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*l);this.object.translateY(b*j);f&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y1?d.normalize():d.z=Math.sqrt(1-e*e);f.copy(c.object.position).subSelf(c.target);e=c.object.up.clone().setLength(d.y);e.addSelf(c.object.up.clone().crossSelf(f).setLength(d.x));e.addSelf(f.setLength(d.z));return e};this.rotateCamera=function(){var a=Math.acos(h.dot(i)/h.length()/i.length());if(a){var b=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion;a*=c.rotateSpeed;d.setFromAxisAngle(b, --a);d.multiplyVector3(f);d.multiplyVector3(c.object.up);d.multiplyVector3(i);c.staticMoving?h=i:(d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-m.y)*c.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),c.staticMoving?m=k:m.y+=(k.y-m.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=r.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(f.length()*c.panSpeed);var b=f.clone().crossSelf(c.object.up).setLength(a.x);b.addSelf(c.object.up.clone().setLength(a.y)); +-a);d.multiplyVector3(f);d.multiplyVector3(c.object.up);d.multiplyVector3(i);c.staticMoving?h=i:(d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(j.y-l.y)*c.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),c.staticMoving?l=j:l.y+=(j.y-l.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=r.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(f.length()*c.panSpeed);var b=f.clone().crossSelf(c.object.up).setLength(a.x);b.addSelf(c.object.up.clone().setLength(a.y)); c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?o=r:o.addSelf(a.sub(r,o).multiplyScalar(c.dynamicDampingFactor))}};this.checkDistances=function(){if(!c.noZoom||!c.noPan)c.object.position.lengthSq()>c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),f.lengthSq()0?1:-1;for(h=0;h0?1:-1;for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(h=0;ha&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(a){for(x=a.length;--x>=0;){ea=x;X=x-1;X<0&&(X=a.length-1);for(var b= -0,c=n+k*2,b=0;b=0;N--){ba=N/k;Y=i*(1-ba);ba=m*Math.sin(ba*Math.PI/2);x=0;for(B=t.length;xa&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(a){for(z=a.length;--z>=0;){W=z;da=z-1;da<0&&(da=a.length-1);for(var b= +0,c=m+j*2,b=0;b=0;K--){U=K/j;V=i*(1-U);U=l*Math.sin(U*Math.PI/2);z=0;for(J=t.length;z0)for(m=0;m2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return g}i=m;e<=i&&(i=0);m=i+1;e<=m&&(m=0);k=m+1;e<=k&&(k=0);var r;a:{r=a;var n=i,q=m,l=k,p=e,s=f,t=void 0,v=void 0,y=void 0, -I=void 0,z=void 0,G=void 0,u=void 0,F=void 0,A=void 0,v=r[s[n]].x,y=r[s[n]].y,I=r[s[q]].x,z=r[s[q]].y,G=r[s[l]].x,u=r[s[l]].y;if(1.0E-10>(I-v)*(u-y)-(z-y)*(G-v))r=!1;else{for(t=0;t=0&&N>=0&&Y>=0){r=!1;break a}}r= -!0}}if(r){g.push([a[f[i]],a[f[m]],a[f[k]]]);h.push([f[i],f[m],f[k]]);i=m;for(k=m+1;k0)for(l=0;l2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return g}i=l;e<=i&&(i=0);l=i+1;e<=l&&(l=0);j=l+1;e<=j&&(j=0);var r;a:{r=a;var m=i,p=l,n=j,q=e,s=f,t=void 0,u=void 0,v=void 0, +B=void 0,x=void 0,C=void 0,E=void 0,G=void 0,R=void 0,u=r[s[m]].x,v=r[s[m]].y,B=r[s[p]].x,x=r[s[p]].y,C=r[s[n]].x,E=r[s[n]].y;if(1.0E-10>(B-u)*(E-v)-(x-v)*(C-u))r=!1;else{for(t=0;t=0&&K>=0&&V>=0){r=!1;break a}}r=!0}}if(r){g.push([a[f[i]], +a[f[l]],a[f[j]]]);h.push([f[i],f[l],f[j]]);i=l;for(j=l+1;j0;)this.smooth(a)}; -THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,b,c,d,h,i){var l=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(f.useOldVertexColors){l.vertexColors=[];for(var n,k,m,o=0;o<4;o++){m=i[o];n=new THREE.Color;n.setRGB(0,0,0);for(var p=0;p=0){p=i.invBindMatrices[n];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p1){j=new THREE.MeshFaceMaterial;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(f=0;f1?c[1].substr(0,b):"0";c[1].length=0){p=i.invBindMatrices[m];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p1){j=new THREE.MeshFaceMaterial;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(f=0;f1?c[1].substr(0,b):"0";c[1].length=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;db){k=j.output[i];break}g=k!==void 0?k instanceof THREE.Matrix4?g.multiply(g,k):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};o.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};A.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof F)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=Z[this.effect.surface.init_from]))a.map= -THREE.ImageUtils.loadTexture(ya+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=Aa;return this.material=new THREE.MeshLambertMaterial(a)};x.prototype.parse=function(a){for(var b=0;b=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};R.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof G)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=aa[this.effect.surface.init_from]))a.map= +THREE.ImageUtils.loadTexture(ya+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=za;return this.material=new THREE.MeshLambertMaterial(a)};z.prototype.parse=function(a){for(var b=0;b=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b1&&(B=new THREE.MeshFaceMaterial); -a=new THREE.Mesh(F,B);a.name=r;a.position.set(y[0],y[1],y[2]);z?(a.quaternion.set(z[0],z[1],z[2],z[3]),a.useQuaternion=!0):a.rotation.set(I[0],I[1],I[2]);a.scale.set(G[0],G[1],G[2]);a.visible=s.visible;J.scene.add(a);J.objects[r]=a;if(s.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);J.scene.collisions.colliders.push(b)}if(s.castsShadow)b=new THREE.ShadowVolume(F),J.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;s.trigger&&s.trigger.toLowerCase()!="none"&&(b= -{type:s.trigger,object:s},J.triggers[a.name]=b)}}else y=s.position,I=s.rotation,z=s.quaternion,G=s.scale,z=0,a=new THREE.Object3D,a.name=r,a.position.set(y[0],y[1],y[2]),z?(a.quaternion.set(z[0],z[1],z[2],z[3]),a.useQuaternion=!0):a.rotation.set(I[0],I[1],I[2]),a.scale.set(G[0],G[1],G[2]),a.visible=s.visible!==void 0?s.visible:!1,J.scene.add(a),J.objects[r]=a,J.empties[r]=a,s.trigger&&s.trigger.toLowerCase()!="none"&&(b={type:s.trigger,object:s},J.triggers[a.name]=b)}function g(a){return function(b){J.geometries[a]= -b;e();Y-=1;i.onLoadComplete();h()}}function f(a){return function(b){J.geometries[a]=b}}function h(){i.callbackProgress({totalModels:j,totalTextures:W,loadedModels:j-Y,loadedTextures:W-K},J);i.onLoadProgress();Y==0&&K==0&&b(J)}var i=this,m=THREE.Loader.prototype.extractUrlbase(c),k,o,r,n,q,l,p,s,t,v,y,I,z,G,u,F,A,x,B,N,ba,Y,K,j,W,J;N=a;c=new THREE.BinaryLoader;ba=new THREE.JSONLoader;K=Y=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, -empties:{}};a=!1;for(r in N.objects)if(s=N.objects[r],s.meshCollider){a=!0;break}if(a)J.scene.collisions=new THREE.CollisionSystem;if(N.transform){a=N.transform.position;t=N.transform.rotation;var L=N.transform.scale;a&&J.scene.position.set(a[0],a[1],a[2]);t&&J.scene.rotation.set(t[0],t[1],t[2]);L&&J.scene.scale.set(L[0],L[1],L[2]);(a||t||L)&&J.scene.updateMatrix()}a=function(){K-=1;h();i.onLoadComplete()};for(q in N.cameras)t=N.cameras[q],t.type=="perspective"?A=new THREE.PerspectiveCamera(t.fov, -t.aspect,t.near,t.far):t.type=="ortho"&&(A=new THREE.OrthographicCamera(t.left,t.right,t.top,t.bottom,t.near,t.far)),y=t.position,t=t.target,A.position.set(y[0],y[1],y[2]),A.target=new THREE.Vector3(t[0],t[1],t[2]),J.cameras[q]=A;for(n in N.lights)t=N.lights[n],q=t.color!==void 0?t.color:16777215,A=t.intensity!==void 0?t.intensity:1,t.type=="directional"?(y=t.direction,v=new THREE.DirectionalLight(q,A),v.position.set(y[0],y[1],y[2]),v.position.normalize()):t.type=="point"?(y=t.position,v=t.distance, -v=new THREE.PointLight(q,A,v),v.position.set(y[0],y[1],y[2])):t.type=="ambient"&&(v=new THREE.AmbientLight(q)),J.scene.add(v),J.lights[n]=v;for(l in N.fogs)n=N.fogs[l],n.type=="linear"?x=new THREE.Fog(0,n.near,n.far):n.type=="exp2"&&(x=new THREE.FogExp2(0,n.density)),t=n.color,x.color.setRGB(t[0],t[1],t[2]),J.fogs[l]=x;if(J.cameras&&N.defaults.camera)J.currentCamera=J.cameras[N.defaults.camera];if(J.fogs&&N.defaults.fog)J.scene.fog=J.fogs[N.defaults.fog];t=N.defaults.bgcolor;J.bgColor=new THREE.Color; -J.bgColor.setRGB(t[0],t[1],t[2]);J.bgColorAlpha=N.defaults.bgalpha;for(k in N.geometries)if(l=N.geometries[k],l.type=="bin_mesh"||l.type=="ascii_mesh")Y+=1,i.onLoadStart();j=Y;for(k in N.geometries)l=N.geometries[k],l.type=="cube"?(F=new THREE.CubeGeometry(l.width,l.height,l.depth,l.segmentsWidth,l.segmentsHeight,l.segmentsDepth,null,l.flipped,l.sides),J.geometries[k]=F):l.type=="plane"?(F=new THREE.PlaneGeometry(l.width,l.height,l.segmentsWidth,l.segmentsHeight),J.geometries[k]=F):l.type=="sphere"? -(F=new THREE.SphereGeometry(l.radius,l.segmentsWidth,l.segmentsHeight),J.geometries[k]=F):l.type=="cylinder"?(F=new THREE.CylinderGeometry(l.topRad,l.botRad,l.height,l.radSegs,l.heightSegs),J.geometries[k]=F):l.type=="torus"?(F=new THREE.TorusGeometry(l.radius,l.tube,l.segmentsR,l.segmentsT),J.geometries[k]=F):l.type=="icosahedron"?(F=new THREE.IcosahedronGeometry(l.subdivisions),J.geometries[k]=F):l.type=="bin_mesh"?c.load(d(l.url,N.urlBaseType),g(k)):l.type=="ascii_mesh"?ba.load(d(l.url,N.urlBaseType), -g(k)):l.type=="embedded_mesh"&&(l=N.embeds[l.id])&&ba.createModel(l,f(k),"");for(p in N.textures)if(k=N.textures[p],k.url instanceof Array){K+=k.url.length;for(l=0;l1&&(J=new THREE.MeshFaceMaterial); +a=new THREE.Mesh(G,J);a.name=r;a.position.set(v[0],v[1],v[2]);x?(a.quaternion.set(x[0],x[1],x[2],x[3]),a.useQuaternion=!0):a.rotation.set(B[0],B[1],B[2]);a.scale.set(C[0],C[1],C[2]);a.visible=s.visible;M.scene.add(a);M.objects[r]=a;if(s.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);M.scene.collisions.colliders.push(b)}if(s.castsShadow)b=new THREE.ShadowVolume(G),M.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;s.trigger&&s.trigger.toLowerCase()!="none"&&(b= +{type:s.trigger,object:s},M.triggers[a.name]=b)}}else v=s.position,B=s.rotation,x=s.quaternion,C=s.scale,x=0,a=new THREE.Object3D,a.name=r,a.position.set(v[0],v[1],v[2]),x?(a.quaternion.set(x[0],x[1],x[2],x[3]),a.useQuaternion=!0):a.rotation.set(B[0],B[1],B[2]),a.scale.set(C[0],C[1],C[2]),a.visible=s.visible!==void 0?s.visible:!1,M.scene.add(a),M.objects[r]=a,M.empties[r]=a,s.trigger&&s.trigger.toLowerCase()!="none"&&(b={type:s.trigger,object:s},M.triggers[a.name]=b)}function g(a){return function(b){M.geometries[a]= +b;e();V-=1;i.onLoadComplete();h()}}function f(a){return function(b){M.geometries[a]=b}}function h(){i.callbackProgress({totalModels:T,totalTextures:k,loadedModels:T-V,loadedTextures:k-Y},M);i.onLoadProgress();V==0&&Y==0&&b(M)}var i=this,l=THREE.Loader.prototype.extractUrlbase(c),j,o,r,m,p,n,q,s,t,u,v,B,x,C,E,G,R,z,J,K,U,V,Y,T,k,M;K=a;c=new THREE.BinaryLoader;U=new THREE.JSONLoader;Y=V=0;M={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, +empties:{}};a=!1;for(r in K.objects)if(s=K.objects[r],s.meshCollider){a=!0;break}if(a)M.scene.collisions=new THREE.CollisionSystem;if(K.transform){a=K.transform.position;t=K.transform.rotation;var L=K.transform.scale;a&&M.scene.position.set(a[0],a[1],a[2]);t&&M.scene.rotation.set(t[0],t[1],t[2]);L&&M.scene.scale.set(L[0],L[1],L[2]);(a||t||L)&&M.scene.updateMatrix()}a=function(){Y-=1;h();i.onLoadComplete()};for(p in K.cameras)t=K.cameras[p],t.type=="perspective"?R=new THREE.PerspectiveCamera(t.fov, +t.aspect,t.near,t.far):t.type=="ortho"&&(R=new THREE.OrthographicCamera(t.left,t.right,t.top,t.bottom,t.near,t.far)),v=t.position,t=t.target,R.position.set(v[0],v[1],v[2]),R.target=new THREE.Vector3(t[0],t[1],t[2]),M.cameras[p]=R;for(m in K.lights)t=K.lights[m],p=t.color!==void 0?t.color:16777215,R=t.intensity!==void 0?t.intensity:1,t.type=="directional"?(v=t.direction,u=new THREE.DirectionalLight(p,R),u.position.set(v[0],v[1],v[2]),u.position.normalize()):t.type=="point"?(v=t.position,u=t.distance, +u=new THREE.PointLight(p,R,u),u.position.set(v[0],v[1],v[2])):t.type=="ambient"&&(u=new THREE.AmbientLight(p)),M.scene.add(u),M.lights[m]=u;for(n in K.fogs)m=K.fogs[n],m.type=="linear"?z=new THREE.Fog(0,m.near,m.far):m.type=="exp2"&&(z=new THREE.FogExp2(0,m.density)),t=m.color,z.color.setRGB(t[0],t[1],t[2]),M.fogs[n]=z;if(M.cameras&&K.defaults.camera)M.currentCamera=M.cameras[K.defaults.camera];if(M.fogs&&K.defaults.fog)M.scene.fog=M.fogs[K.defaults.fog];t=K.defaults.bgcolor;M.bgColor=new THREE.Color; +M.bgColor.setRGB(t[0],t[1],t[2]);M.bgColorAlpha=K.defaults.bgalpha;for(j in K.geometries)if(n=K.geometries[j],n.type=="bin_mesh"||n.type=="ascii_mesh")V+=1,i.onLoadStart();T=V;for(j in K.geometries)n=K.geometries[j],n.type=="cube"?(G=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),M.geometries[j]=G):n.type=="plane"?(G=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),M.geometries[j]=G):n.type=="sphere"? +(G=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),M.geometries[j]=G):n.type=="cylinder"?(G=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),M.geometries[j]=G):n.type=="torus"?(G=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),M.geometries[j]=G):n.type=="icosahedron"?(G=new THREE.IcosahedronGeometry(n.subdivisions),M.geometries[j]=G):n.type=="bin_mesh"?c.load(d(n.url,K.urlBaseType),g(j)):n.type=="ascii_mesh"?U.load(d(n.url,K.urlBaseType), +g(j)):n.type=="embedded_mesh"&&(n=K.embeds[n.id])&&U.createModel(n,f(j),"");for(q in K.textures)if(j=K.textures[q],j.url instanceof Array){Y+=j.url.length;for(n=0;n=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;e<8;e++){for(var g=0,f=0;f>1^-(h&1);c[8*f+e]=g}d+=b}b=a.length-d;g=new Uint16Array(b);for(e=f=0;e=this.maxCount-3&&h(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&&(i=this.size-1);var r=Math.floor(m-h);r<1&&(r=1);m=Math.floor(m+h);m>this.size-1&&(m=this.size-1);var n=Math.floor(k-h);n<1&&(n=1);h=Math.floor(k+h);h>this.size-1&&(h=this.size- -1);for(var q,l,p,s,t,v;o0&&(this.field[p+q]+=s)}}};this.addPlaneX=function(a,b){var e,g,f,h,i,m=this.size,k=this.yd,o=this.zd,r=this.field,n=m*Math.sqrt(a/b);n>m&&(n=m);for(e=0;e0)for(g=0;gk&&(q=k);for(g=0;g0){i=g*o;for(e=0;ek&&(q=k);for(f=0;f0){i=r*f;for(g=0;gthis.size-1&&(i=this.size-1);var r=Math.floor(l-h);r<1&&(r=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var m=Math.floor(j-h);m<1&&(m=1);h=Math.floor(j+h);h>this.size-1&&(h=this.size- +1);for(var p,n,q,s,t,u;o0&&(this.field[q+p]+=s)}}};this.addPlaneX=function(a,b){var e,g,f,h,i,l=this.size,j=this.yd,o=this.zd,r=this.field,m=l*Math.sqrt(a/b);m>l&&(m=l);for(e=0;e0)for(g=0;gj&&(p=j);for(g=0;g0){i=g*o;for(e=0;ej&&(p=j);for(f=0;f0){i=r*f;for(g=0;g0&&p.x0&&p.y0.0010&&z.scale>0.0010)l.x=z.x,l.y=z.y,l.z=z.z,n=z.size*z.scale/ -h,q.x=n*k,q.y=n,b.uniform3f(s.screenPosition,l.x,l.y,l.z),b.uniform2f(s.scale,q.x,q.y),b.uniform1f(s.rotation,z.rotation),b.uniform1f(s.opacity,z.opacity),b.uniform3f(s.color,z.color.r,z.color.g,z.color.b),c.setBlending(z.blending),c.setTexture(z.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}}; +"color");d.uniforms.scale=b.getUniformLocation(d.program,"scale");d.uniforms.rotation=b.getUniformLocation(d.program,"rotation");d.uniforms.screenPosition=b.getUniformLocation(d.program,"screenPosition");d.attributesEnabled=!1};this.render=function(a,g,f,h){var a=a.__webglFlares,i=a.length;if(i){var l=new THREE.Vector3,j=h/f,o=f*0.5,r=h*0.5,m=16/h,p=new THREE.Vector2(m*j,m),n=new THREE.Vector3(1,1,0),q=new THREE.Vector2(1,1),s=d.uniforms,m=d.attributes;b.useProgram(d.program);if(!d.attributesEnabled)b.enableVertexAttribArray(d.attributes.vertex), +b.enableVertexAttribArray(d.attributes.uv),d.attributesEnabled=!0;b.uniform1i(s.occlusionMap,0);b.uniform1i(s.map,1);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(m.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(m.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.disable(b.CULL_FACE);b.depthMask(!1);var t,u,v,B,x;for(t=0;t0&&q.x0&&q.y0.0010&&x.scale>0.0010)n.x=x.x,n.y=x.y,n.z=x.z,m=x.size*x.scale/ +h,p.x=m*j,p.y=m,b.uniform3f(s.screenPosition,n.x,n.y,n.z),b.uniform2f(s.scale,p.x,p.y),b.uniform1f(s.rotation,x.rotation),b.uniform1f(s.opacity,x.opacity),b.uniform3f(s.color,x.color.r,x.color.g,x.color.b),c.setBlending(x.blending),c.setTexture(x.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}}; THREE.ShadowMapPlugin=function(){var a,b,c,d,e,g=new THREE.Frustum,f=new THREE.Matrix4;this.shadowMatrix=[];this.shadowMap=[];this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render= -function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(h){var i,m,k,o,r,n,q,l=0,p=h.lights;e||(e=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));i=0;for(m=p.length;i1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=f;b.v=g;return b}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,g=b instanceof THREE.Mesh?b.geometry:b,f=a.vertices,h=g.vertices,i=a.faces,k=g.faces,j=a.faceVertexUvs[0],r=g.faceVertexUvs[0],o={},m=0;m1&&(d=1-d,e=1-e);g=1-d-e;f.copy(a);f.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);f.addSelf(h);h.copy(c);h.multiplyScalar(g);f.addSelf(h);return f},randomPointInFace:function(a,b,c){var d,e,g;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,e=b.vertices[a.b].position, g=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,g);else if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;g=b.vertices[a.c].position;var b=b.vertices[a.d].position,f;c?a._area1&&a._area2?(c=a._area1,f=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),f=THREE.GeometryUtils.triangleArea(e,g,b),a._area1=c,a._area2=f):(c=THREE.GeometryUtils.triangleArea(d,e,b),f=THREE.GeometryUtils.triangleArea(e,g,b));return THREE.GeometryUtils.random()*(c+ -f)a?b(d,e-1):k[e]a?b(d,e-1):k[e]0?(f=c[c.length-1],m=f.x,l=f.y):(f=this.actions[d-1].args,m=f[f.length-2],l=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b2(n,m,r,h),n=THREE.Shape.Utils.b2(n,l,o, -i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];r=g[0];o=g[1];k=g[2];j=g[3];c.length>0?(f=c[c.length-1],m=f.x,l=f.y):(f=this.actions[d-1].args,m=f[f.length-2],l=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b3(n,m,r,k,h),n=THREE.Shape.Utils.b3(n,l,o,j,i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];n=a*g[0].length;f=f.concat(g[0]);g=new THREE.SplineCurve(f); -for(f=1;f<=n;f++)c.push(g.getPointAt(f/n));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=g[0];i=g[1];k=g[2];r=g[3];n=g[4];o=!!g[5];j=f[f.length-2];m=f[f.length-1];f.length==0&&(j=m=0);l=n-r;var q=a*2;for(f=1;f<=q;f++)n=f/q,o||(n=1-n),n=r+n*l,g=j+h+k*Math.cos(n),n=m+i+k*Math.sin(n),c.push(new THREE.Vector2(g,n))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; +THREE.Path.prototype.getPoints=function(a,b){var a=a||12,c=[],d,e,g,f,h,i,k,j,r,o,l,n,m;d=0;for(e=this.actions.length;d0?(f=c[c.length-1],l=f.x,n=f.y):(f=this.actions[d-1].args,l=f[f.length-2],n=f[f.length-1]);for(f=1;f<=a;f++)m=f/a,g=THREE.Shape.Utils.b2(m,l,r,h),m=THREE.Shape.Utils.b2(m,n,o, +i),c.push(new THREE.Vector2(g,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];r=g[0];o=g[1];k=g[2];j=g[3];c.length>0?(f=c[c.length-1],l=f.x,n=f.y):(f=this.actions[d-1].args,l=f[f.length-2],n=f[f.length-1]);for(f=1;f<=a;f++)m=f/a,g=THREE.Shape.Utils.b3(m,l,r,k,h),m=THREE.Shape.Utils.b3(m,n,o,j,i),c.push(new THREE.Vector2(g,m));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];m=a*g[0].length;f=f.concat(g[0]);g=new THREE.SplineCurve(f); +for(f=1;f<=m;f++)c.push(g.getPointAt(f/m));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=g[0];i=g[1];k=g[2];r=g[3];m=g[4];o=!!g[5];j=f[f.length-2];l=f[f.length-1];f.length==0&&(j=l=0);n=m-r;var q=a*2;for(f=1;f<=q;f++)m=f/q,o||(m=1-m),m=r+m*n,g=j+h+k*Math.cos(m),m=l+i+k*Math.sin(m),c.push(new THREE.Vector2(g,m))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; THREE.Path.prototype.nltransform=function(a,b,c,d,e,g){var f=this.getPoints(),h,i,k,j,r;h=0;for(i=f.length;h=0?h-1:c.length-1;g=f-1>=0?f-1:k.length-1;var n=[k[f],c[h],c[e]];r=THREE.FontUtils.Triangulate.area(n);var q=[k[f],k[g],c[h]];o=THREE.FontUtils.Triangulate.area(q);m=h;j=f;h+=1;f+=-1;h< -0&&(h+=c.length);h%=c.length;f<0&&(f+=k.length);f%=k.length;e=h-1>=0?h-1:c.length-1;g=f-1>=0?f-1:k.length-1;n=[k[f],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);q=[k[f],k[g],c[h]];q=THREE.FontUtils.Triangulate.area(q);r+o>n+q&&(h=m,f=j,h<0&&(h+=c.length),h%=c.length,f<0&&(f+=k.length),f%=k.length,e=h-1>=0?h-1:c.length-1,g=f-1>=0?f-1:k.length-1);r=c.slice(0,h);o=c.slice(h);m=k.slice(f);j=k.slice(0,f);g=[k[f],k[g],c[h]];l.push([k[f],c[h],c[e]]);l.push(g);c=r.concat(m).concat(j).concat(o)}return{shape:c, -isolatedPts:l,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),g,f,h,i,k={};g=0;for(f=d.length;g=0?h-1:c.length-1;g=f-1>=0?f-1:k.length-1;var m=[k[f],c[h],c[e]];r=THREE.FontUtils.Triangulate.area(m);var q=[k[f],k[g],c[h]];o=THREE.FontUtils.Triangulate.area(q);l=h;j=f;h+=1;f+=-1;h< +0&&(h+=c.length);h%=c.length;f<0&&(f+=k.length);f%=k.length;e=h-1>=0?h-1:c.length-1;g=f-1>=0?f-1:k.length-1;m=[k[f],c[h],c[e]];m=THREE.FontUtils.Triangulate.area(m);q=[k[f],k[g],c[h]];q=THREE.FontUtils.Triangulate.area(q);r+o>m+q&&(h=l,f=j,h<0&&(h+=c.length),h%=c.length,f<0&&(f+=k.length),f%=k.length,e=h-1>=0?h-1:c.length-1,g=f-1>=0?f-1:k.length-1);r=c.slice(0,h);o=c.slice(h);l=k.slice(f);j=k.slice(0,f);g=[k[f],k[g],c[h]];n.push([k[f],c[h],c[e]]);n.push(g);c=r.concat(l).concat(j).concat(o)}return{shape:c, +isolatedPts:n,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),g,f,h,i,k={};g=0;for(f=d.length;g1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+m),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",m,f.index-1).pos,this.points[1]=e,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",m,h.index+1).pos,d=d*0.33+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(c=== -"rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d}}if(this.JITCompile&&j[0][k]===void 0){this.hierarchy[0].update(null,!0);for(m=0;m1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+l),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",l,f.index-1).pos,this.points[1]=e,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",l,h.index+1).pos,d=d*0.33+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(c=== +"rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d}}if(this.JITCompile&&j[0][k]===void 0){this.hierarchy[0].update(null,!0);for(l=0;la.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];h=a[c[1]];i=a[c[2]];k=a[c[3]];c=e*e;f=e*c;d[0]=this.interpolate(g[0],h[0],i[0],k[0],e,c,f);d[1]=this.interpolate(g[1],h[1],i[1],k[1],e,c,f);d[2]=this.interpolate(g[2],h[2],i[2],k[2],e,c,f);return d}; THREE.Animation.prototype.interpolate=function(a,b,c,d,e,g,f){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*f+(-3*(b-c)-2*a-d)*g+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]}; @@ -117,7 +117,7 @@ this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this a=this.verticalAngleMap.dstRange;b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove= function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}), c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=e(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a= -this.debugPath,b=this.spline,f=g(b,10),c=g(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),f=new THREE.Line(f,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));f.scale.set(1,1,1);a.add(f);c.scale.set(1,1,1);a.add(c);for(var f=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),m=0;m0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*k);this.object.translateY(b*j);f&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y0?1:-1;for(h=0;h0?1:-1;for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(h=0;ha&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(a){for(v=a.length;--v>=0;){J=v;N=v-1;N<0&&(N=a.length-1);for(var b= -0,c=m+j*2,b=0;b=0;B--){G=B/j;I=i*(1-G);G=k*Math.sin(G*Math.PI/2);v=0;for(D=s.length;v=0;B--){G=B/j;I=i*(1-G);G=k*Math.sin(G*Math.PI/2);v=0;for(D=s.length;v0)for(k=0;k2;){if(r--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return g}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);j=k+1;e<=j&&(j=0);var o;a:{o=a;var m=i,l=k,n=j,q=e,p=f,s=void 0,t=void 0,w=void 0, -y=void 0,u=void 0,x=void 0,z=void 0,A=void 0,F=void 0,t=o[p[m]].x,w=o[p[m]].y,y=o[p[l]].x,u=o[p[l]].y,x=o[p[n]].x,z=o[p[n]].y;if(1.0E-10>(y-t)*(z-w)-(u-w)*(x-t))o=!1;else{for(s=0;s=0&&B>=0&&I>=0){o=!1;break a}}o=!0}}if(o){g.push([a[f[i]], +0,e=String(a).split(""),g=e.length,f=[],a=0;a0)for(k=0;k2;){if(r--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return g}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);j=k+1;e<=j&&(j=0);var o;a:{o=a;var l=i,n=k,m=j,q=e,p=f,s=void 0,t=void 0,w=void 0, +y=void 0,u=void 0,x=void 0,z=void 0,A=void 0,F=void 0,t=o[p[l]].x,w=o[p[l]].y,y=o[p[n]].x,u=o[p[n]].y,x=o[p[m]].x,z=o[p[m]].y;if(1.0E-10>(y-t)*(z-w)-(u-w)*(x-t))o=!1;else{for(s=0;s=0&&B>=0&&I>=0){o=!1;break a}}o=!0}}if(o){g.push([a[f[i]], a[f[k]],a[f[j]]]);h.push([f[i],f[k],f[j]]);i=k;for(j=k+1;j0;)this.smooth(a)}; -THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,b,c,d,h,i){var j=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(f.useOldVertexColors){j.vertexColors=[];for(var k,m,n,l=0;l<4;l++){n=i[l];k=new THREE.Color;k.setRGB(0,0,0);for(var p=0;p=0){o=i.invBindMatrices[n];j.invBindMatrix=o;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,o);j.weights=[];for(o=0;o1){j=new THREE.MeshFaceMaterial;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(f=0;f=0){o=i.invBindMatrices[m];j.invBindMatrix=o;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,o);j.weights=[];for(o=0;o1){j=new THREE.MeshFaceMaterial;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(f=0;f=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;db){k=j.output[i];break}g=k!==void 0?k instanceof THREE.Matrix4?g.multiply(g,k):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};r.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a1&&(D=new THREE.MeshFaceMaterial); a=new THREE.Mesh(A,D);a.name=o;a.position.set(w[0],w[1],w[2]);u?(a.quaternion.set(u[0],u[1],u[2],u[3]),a.useQuaternion=!0):a.rotation.set(y[0],y[1],y[2]);a.scale.set(x[0],x[1],x[2]);a.visible=p.visible;C.scene.add(a);C.objects[o]=a;if(p.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);C.scene.collisions.colliders.push(b)}if(p.castsShadow)b=new THREE.ShadowVolume(A),C.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;p.trigger&&p.trigger.toLowerCase()!="none"&&(b= {type:p.trigger,object:p},C.triggers[a.name]=b)}}else w=p.position,y=p.rotation,u=p.quaternion,x=p.scale,u=0,a=new THREE.Object3D,a.name=o,a.position.set(w[0],w[1],w[2]),u?(a.quaternion.set(u[0],u[1],u[2],u[3]),a.useQuaternion=!0):a.rotation.set(y[0],y[1],y[2]),a.scale.set(x[0],x[1],x[2]),a.visible=p.visible!==void 0?p.visible:!1,C.scene.add(a),C.objects[o]=a,C.empties[o]=a,p.trigger&&p.trigger.toLowerCase()!="none"&&(b={type:p.trigger,object:p},C.triggers[a.name]=b)}function g(a){return function(b){C.geometries[a]= -b;e();I-=1;i.onLoadComplete();h()}}function f(a){return function(b){C.geometries[a]=b}}function h(){i.callbackProgress({totalModels:K,totalTextures:O,loadedModels:K-I,loadedTextures:O-E},C);i.onLoadProgress();I==0&&E==0&&b(C)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),j,r,o,m,l,n,q,p,s,t,w,y,u,x,z,A,F,v,D,B,G,I,E,K,O,C;B=a;c=new THREE.BinaryLoader;G=new THREE.JSONLoader;E=I=0;C={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, -empties:{}};a=!1;for(o in B.objects)if(p=B.objects[o],p.meshCollider){a=!0;break}if(a)C.scene.collisions=new THREE.CollisionSystem;if(B.transform){a=B.transform.position;s=B.transform.rotation;var L=B.transform.scale;a&&C.scene.position.set(a[0],a[1],a[2]);s&&C.scene.rotation.set(s[0],s[1],s[2]);L&&C.scene.scale.set(L[0],L[1],L[2]);(a||s||L)&&C.scene.updateMatrix()}a=function(){E-=1;h();i.onLoadComplete()};for(l in B.cameras)s=B.cameras[l],s.type=="perspective"?F=new THREE.PerspectiveCamera(s.fov, -s.aspect,s.near,s.far):s.type=="ortho"&&(F=new THREE.OrthographicCamera(s.left,s.right,s.top,s.bottom,s.near,s.far)),w=s.position,s=s.target,F.position.set(w[0],w[1],w[2]),F.target=new THREE.Vector3(s[0],s[1],s[2]),C.cameras[l]=F;for(m in B.lights)s=B.lights[m],l=s.color!==void 0?s.color:16777215,F=s.intensity!==void 0?s.intensity:1,s.type=="directional"?(w=s.direction,t=new THREE.DirectionalLight(l,F),t.position.set(w[0],w[1],w[2]),t.position.normalize()):s.type=="point"?(w=s.position,t=s.distance, -t=new THREE.PointLight(l,F,t),t.position.set(w[0],w[1],w[2])):s.type=="ambient"&&(t=new THREE.AmbientLight(l)),C.scene.add(t),C.lights[m]=t;for(n in B.fogs)m=B.fogs[n],m.type=="linear"?v=new THREE.Fog(0,m.near,m.far):m.type=="exp2"&&(v=new THREE.FogExp2(0,m.density)),s=m.color,v.color.setRGB(s[0],s[1],s[2]),C.fogs[n]=v;if(C.cameras&&B.defaults.camera)C.currentCamera=C.cameras[B.defaults.camera];if(C.fogs&&B.defaults.fog)C.scene.fog=C.fogs[B.defaults.fog];s=B.defaults.bgcolor;C.bgColor=new THREE.Color; -C.bgColor.setRGB(s[0],s[1],s[2]);C.bgColorAlpha=B.defaults.bgalpha;for(j in B.geometries)if(n=B.geometries[j],n.type=="bin_mesh"||n.type=="ascii_mesh")I+=1,i.onLoadStart();K=I;for(j in B.geometries)n=B.geometries[j],n.type=="cube"?(A=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),C.geometries[j]=A):n.type=="plane"?(A=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),C.geometries[j]=A):n.type=="sphere"? -(A=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),C.geometries[j]=A):n.type=="cylinder"?(A=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),C.geometries[j]=A):n.type=="torus"?(A=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),C.geometries[j]=A):n.type=="icosahedron"?(A=new THREE.IcosahedronGeometry(n.subdivisions),C.geometries[j]=A):n.type=="bin_mesh"?c.load(d(n.url,B.urlBaseType),g(j)):n.type=="ascii_mesh"?G.load(d(n.url,B.urlBaseType), -g(j)):n.type=="embedded_mesh"&&(n=B.embeds[n.id])&&G.createModel(n,f(j),"");for(q in B.textures)if(j=B.textures[q],j.url instanceof Array){E+=j.url.length;for(n=0;n=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;e<8;e++){for(var g=0,f=0;f>1^-(h&1);c[8*f+e]=g}d+=b}b=a.length-d;g=new Uint16Array(b);for(e=f=0;e=this.maxCount-3&&h(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&&(i=this.size-1);var o=Math.floor(k-h);o<1&&(o=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var m=Math.floor(j-h);m<1&&(m=1);h=Math.floor(j+h);h>this.size-1&&(h=this.size- -1);for(var l,n,q,p,s,t;r0&&(this.field[q+l]+=p)}}};this.addPlaneX=function(a,b){var e,g,f,h,i,k=this.size,j=this.yd,r=this.zd,o=this.field,m=k*Math.sqrt(a/b);m>k&&(m=k);for(e=0;e0)for(g=0;gj&&(l=j);for(g=0;g0){i=g*r;for(e=0;ej&&(l=j);for(f=0;f0){i=o*f;for(g=0;gthis.size-1&&(i=this.size-1);var o=Math.floor(k-h);o<1&&(o=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var l=Math.floor(j-h);l<1&&(l=1);h=Math.floor(j+h);h>this.size-1&&(h=this.size- +1);for(var n,m,q,p,s,t;r0&&(this.field[q+n]+=p)}}};this.addPlaneX=function(a,b){var e,g,f,h,i,k=this.size,j=this.yd,r=this.zd,o=this.field,l=k*Math.sqrt(a/b);l>k&&(l=k);for(e=0;e0)for(g=0;gj&&(n=j);for(g=0;g0){i=g*r;for(e=0;ej&&(n=j);for(f=0;f0){i=o*f;for(g=0;g0&&q.x0&&q.y0.0010&&u.scale>0.0010)n.x=u.x,n.y=u.y,n.z=u.z,m=u.size*u.scale/ -h,l.x=m*j,l.y=m,b.uniform3f(p.screenPosition,n.x,n.y,n.z),b.uniform2f(p.scale,l.x,l.y),b.uniform1f(p.rotation,u.rotation),b.uniform1f(p.opacity,u.opacity),b.uniform3f(p.color,u.color.r,u.color.g,u.color.b),c.setBlending(u.blending),c.setTexture(u.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}}; +"color");d.uniforms.scale=b.getUniformLocation(d.program,"scale");d.uniforms.rotation=b.getUniformLocation(d.program,"rotation");d.uniforms.screenPosition=b.getUniformLocation(d.program,"screenPosition");d.attributesEnabled=!1};this.render=function(a,g,f,h){var a=a.__webglFlares,i=a.length;if(i){var k=new THREE.Vector3,j=h/f,r=f*0.5,o=h*0.5,l=16/h,n=new THREE.Vector2(l*j,l),m=new THREE.Vector3(1,1,0),q=new THREE.Vector2(1,1),p=d.uniforms,l=d.attributes;b.useProgram(d.program);if(!d.attributesEnabled)b.enableVertexAttribArray(d.attributes.vertex), +b.enableVertexAttribArray(d.attributes.uv),d.attributesEnabled=!0;b.uniform1i(p.occlusionMap,0);b.uniform1i(p.map,1);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(l.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(l.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.disable(b.CULL_FACE);b.depthMask(!1);var s,t,w,y,u;for(s=0;s0&&q.x0&&q.y0.0010&&u.scale>0.0010)m.x=u.x,m.y=u.y,m.z=u.z,l=u.size*u.scale/ +h,n.x=l*j,n.y=l,b.uniform3f(p.screenPosition,m.x,m.y,m.z),b.uniform2f(p.scale,n.x,n.y),b.uniform1f(p.rotation,u.rotation),b.uniform1f(p.opacity,u.opacity),b.uniform3f(p.color,u.color.r,u.color.g,u.color.b),c.setBlending(u.blending),c.setTexture(u.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}}; THREE.ShadowMapPlugin=function(){var a,b,c,d,e,g=new THREE.Frustum,f=new THREE.Matrix4;this.shadowMatrix=[];this.shadowMap=[];this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render= -function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(h){var i,k,j,r,o,m,l,n=0,q=h.lights;e||(e=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));i=0;for(k=q.length;i>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+ +THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,f,g;if(c===0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),f=a*6-d,a=c*(1-b),g=c*(1- +b*f),b=c*(1-b*(1-f)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+ Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this}, divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)}, @@ -14,85 +14,85 @@ this.y=Math.asin(a.n13);Math.abs(b)>1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b), THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}}; -THREE.Ray=function(a,b){function c(a,b,c){n.sub(c,a);G=n.dot(b);if(G<=0)return null;u=w.add(a,x.copy(b).multiplyScalar(G));return K=c.distanceTo(u)}function d(a,b,c,d){n.sub(d,b);w.sub(c,b);x.sub(a,b);ta=n.dot(n);O=n.dot(w);ia=n.dot(x);ea=w.dot(w);D=w.dot(x);P=1/(ta*ea-O*O);H=(ea*ia-O*D)*P;M=(ta*D-O*ia)*P;return H>=0&&M>=0&&H+M<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b, -c,d=[];b=0;for(c=a.length;bn.scale.x)return[];x={distance:w,point:n.position,face:null,object:n};G.push(x)}else if(n instanceof THREE.Mesh){w=c(this.origin,this.direction,n.matrixWorld.getPosition());if(w===null||w>n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)))return G;var ba,K=n.geometry,E=K.vertices,e;n.matrixRotationWorld.extractRotation(n.matrixWorld);w=0;for(u=K.faces.length;w0:ba<0)))if(ba=q.dot(p.sub(g,a))/ba,k.add(a,b.multiplyScalar(ba)),x instanceof THREE.Face3)d(k, -g,f,h)&&(x={distance:a.distanceTo(k),point:k.clone(),face:x,object:n},G.push(x));else if(x instanceof THREE.Face4&&(d(k,g,f,i)||d(k,f,h,i)))x={distance:a.distanceTo(k),point:k.clone(),face:x,object:n},G.push(x)}return G};var n=new THREE.Vector3,w=new THREE.Vector3,x=new THREE.Vector3,G,u,K,ta,O,ia,ea,D,P,H,M}; -THREE.Rectangle=function(){function a(){f=d-b;h=g-c}var b,c,d,g,f,h,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(f,h,k,n){i=!1;b=f;c=h;d=k;g=n;a()};this.addPoint=function(f,h){i?(i=!1,b=f,c=h,d=f,g=h):(b=bf?d:f,g=g>h?g:h);a()};this.add3Points= -function(f,h,k,n,w,x){i?(i=!1,b=fk?f>w?f:w:k>w?k:w,g=h>n?h>x?h:x:n>x?n:x):(b=fk?f>w?f>d?f:d:w>d?w:d:k>w?k>d?k:d:w>d?w:d,g=h>n?h>x?h>g?h:g:x>g?x:g:n>x?n>g?n:g:x>g?x:g);a()};this.addRectangle=function(f){i?(i=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),g=f.getBottom()):(b=bf.getRight()?d:f.getRight(),g=g> -f.getBottom()?g:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;g+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d=0&&Math.min(g,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){i=!0;g=d=c=b=0;a()};this.isEmpty=function(){return i}}; -THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=0&&O>=0&&N+O<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b, +c,d=[];b=0;for(c=a.length;bu.scale.x)return[];l={distance:w,point:u.position,face:null,object:u};G.push(l)}else if(u instanceof THREE.Mesh){w=c(this.origin,this.direction,u.matrixWorld.getPosition());if(w===null||w>u.geometry.boundingSphere.radius*Math.max(u.scale.x,Math.max(u.scale.y,u.scale.z)))return G;var L,J=u.geometry,K=J.vertices,E;u.matrixRotationWorld.extractRotation(u.matrixWorld);w=0;for(C=J.faces.length;w0:L<0)))if(L=n.dot(p.sub(f,a))/L,k.add(a,b.multiplyScalar(L)),l instanceof THREE.Face3)d(k, +f,g,h)&&(l={distance:a.distanceTo(k),point:k.clone(),face:l,object:u},G.push(l));else if(l instanceof THREE.Face4&&(d(k,f,g,i)||d(k,g,h,i)))l={distance:a.distanceTo(k),point:k.clone(),face:l,object:u},G.push(l)}return G};var l=new THREE.Vector3,w=new THREE.Vector3,u=new THREE.Vector3,G,C,J,qa,T,la,ga,K,P,N,O}; +THREE.Rectangle=function(){function a(){g=d-b;h=f-c}var b,c,d,f,g,h,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(g,h,k,l){i=!1;b=g;c=h;d=k;f=l;a()};this.addPoint=function(g,h){i?(i=!1,b=g,c=h,d=g,f=h):(b=bg?d:g,f=f>h?f:h);a()};this.add3Points= +function(g,h,k,l,w,u){i?(i=!1,b=gk?g>w?g:w:k>w?k:w,f=h>l?h>u?h:u:l>u?l:u):(b=gk?g>w?g>d?g:d:w>d?w:d:k>w?k>d?k:d:w>d?w:d,f=h>l?h>u?h>f?h:f:u>f?u:f:l>u?l>f?l:f:u>f?u:f);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),f=g.getBottom()):(b=bg.getRight()?d:g.getRight(),f=f> +g.getBottom()?f:g.getBottom());a()};this.inflate=function(g){b-=g;c-=g;d+=g;f+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){i=!0;f=d=c=b=0;a()};this.isEmpty=function(){return i}}; +THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dh&&i.positionScreen.z0&&H.z< -1))h=ea[ia]=ea[ia]||new THREE.RenderableParticle,ia++,O=h,O.x=H.x/H.w,O.y=H.y/H.w,O.z=H.z,O.rotation=S.rotation.z,O.scale.x=S.scale.x*Math.abs(O.x-(H.x+g.projectionMatrix.n11)/(H.w+g.projectionMatrix.n14)),O.scale.y=S.scale.y*Math.abs(O.y-(H.y+g.projectionMatrix.n22)/(H.w+g.projectionMatrix.n24)),O.material=S.material,D.elements.push(O);f&&D.elements.sort(c);return D}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; -THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,g=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-g),g=Math.sin(-g),f=Math.cos(c),c=Math.sin(c),h=a*b,i=d*g;this.w=h*f-i*c;this.x=h*c+i*f;this.y=d*b*f+a*g*c;this.z=a*g*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); +THREE.Projector=function(){function a(){var a=h[g]=h[g]||new THREE.RenderableObject;g++;return a}function b(){var a=n[p]=n[p]||new THREE.RenderableVertex;p++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,g=a.z+a.w,e=b.z+b.w,f=-a.z+a.w,h=-b.z+b.w;return g>=0&&e>=0&&f>=0&&h>=0?!0:g<0&&e<0||f<0&&h<0?!1:(g<0?c=Math.max(c,g/(g-e)):e<0&&(d=Math.min(d,g/(g-e))),f<0?c=Math.max(c,f/(f-h)):h<0&&(d=Math.min(d,f/(f-h))),dh&&i.positionScreen.z0&&N.z<1))h=ga[la]=ga[la]||new THREE.RenderableParticle, +la++,T=h,T.x=N.x/N.w,T.y=N.y/N.w,T.z=N.z,T.rotation=Z.rotation.z,T.scale.x=Z.scale.x*Math.abs(T.x-(N.x+g.projectionMatrix.n11)/(N.w+g.projectionMatrix.n14)),T.scale.y=Z.scale.y*Math.abs(T.y-(N.y+g.projectionMatrix.n22)/(N.w+g.projectionMatrix.n24)),T.material=Z.material,K.elements.push(T);f&&K.elements.sort(c);return K}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; +THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(c),c=Math.sin(c),h=a*b,i=d*f;this.w=h*g-i*c;this.x=h*c+i*g;this.y=d*b*g+a*f*c;this.z=a*f*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= -this.x,c=this.y,d=this.z,g=this.w,f=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+g*f+c*i-d*h;this.y=c*a+g*h+d*f-b*i;this.z=d*a+g*i+b*h-c*f;this.w=g*a-b*f-c*h-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,g=a.z,f=this.x,h=this.y,i=this.z,p=this.w,q=p*c+h*g-i*d,k=p*d+i*c-f*g,n=p*g+f*d-h*c,c=-f* -c-h*d-i*g;b.x=q*p+c*-f+k*-i-n*-h;b.y=k*p+c*-h+n*-f-q*-i;b.z=n*p+c*-i+q*-h-k*-f;return b}}; -THREE.Quaternion.slerp=function(a,b,c,d){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;g<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,g=-g):c.copy(b);if(Math.abs(g)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(g),g=Math.sqrt(1-g*g);if(Math.abs(g)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; -THREE.Face3=function(a,b,c,d,g,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; -THREE.Face4=function(a,b,c,d,g,f,h){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +this.x,c=this.y,d=this.z,f=this.w,g=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+f*g+c*i-d*h;this.y=c*a+f*h+d*g-b*i;this.z=d*a+f*i+b*h-c*g;this.w=f*a-b*g-c*h-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,h=this.y,i=this.z,p=this.w,n=p*c+h*f-i*d,k=p*d+i*c-g*f,l=p*f+g*d-h*c,c=-g* +c-h*d-i*f;b.x=n*p+c*-g+k*-i-l*-h;b.y=k*p+c*-h+l*-g-n*-i;b.z=l*p+c*-i+n*-h-k*-g;return b}}; +THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3}; +THREE.Face4=function(a,b,c,d,f,g,h){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; -THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,d=this.vertices.length;c0){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 b=1,c=this.vertices.length;b< +b,c,d,g,f,O){i=a.vertices[b].position;p=a.vertices[c].position;n=a.vertices[d].position;k=h[g];l=h[f];w=h[O];u=p.x-i.x;G=n.x-i.x;C=p.y-i.y;J=n.y-i.y;qa=p.z-i.z;T=n.z-i.z;la=l.u-k.u;ga=w.u-k.u;K=l.v-k.v;P=w.v-k.v;N=1/(la*P-ga*K);da.set((P*u-K*G)*N,(P*C-K*J)*N,(P*qa-K*T)*N);ta.set((la*G-ga*u)*N,(la*J-ga*C)*N,(la*T-ga*qa)*N);ja[b].addSelf(da);ja[c].addSelf(da);ja[d].addSelf(da);ua[b].addSelf(ta);ua[c].addSelf(ta);ua[d].addSelf(ta)}var b,c,d,f,g,h,i,p,n,k,l,w,u,G,C,J,qa,T,la,ga,K,P,N,O,ja=[],ua=[],da= +new THREE.Vector3,ta=new THREE.Vector3,ra=new THREE.Vector3,L=new THREE.Vector3,va=new THREE.Vector3;b=0;for(c=this.vertices.length;b0){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 b=1,c=this.vertices.length;b< c;b++){a=this.vertices[b];if(a.position.xthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a= -0,b=0,c=this.vertices.length;bthis.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;q=this.points[c[0]];k=this.points[c[1]]; -n=this.points[c[2]];w=this.points[c[3]];i=h*h;p=h*i;d.x=b(q.x,k.x,n.x,w.x,h,i,p);d.y=b(q.y,k.y,n.y,w.y,h,i,p);d.z=b(q.z,k.z,n.z,w.z,h,i,p);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;n=this.points[c[0]];k=this.points[c[1]]; +l=this.points[c[2]];w=this.points[c[3]];i=h*h;p=h*i;d.x=b(n.x,k.x,l.x,w.x,h,i,p);d.y=b(n.y,k.y,l.y,w.y,h,i,p);d.z=b(n.z,k.z,l.z,w.z,h,i,p);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a1){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var b=1;b=this.LODs[b].visibleAtDistance)this.LODs[b-1].object3D.visible=!1,this.LODs[b].object3D.visible=!0;else break;for(;b= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( shadowDarkness );\n#endif\n}\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"}; -THREE.UniformsUtils={merge:function(a){var b,c,d,g={};for(b=0;b=0)return a.geometry.materials[b.materialIndex]}function d(a){if(a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial)return!1;return a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function g(a){if(a.vertexColors)return a.vertexColors;return!1}function f(a){if(a.map||a.lightMap||a instanceof THREE.ShaderMaterial)return!0; -return!1}function h(a,b,c){var d,g,f,h,l=a.vertices;h=l.length;var I=a.colors,i=I.length,r=a.__vertexArray,n=a.__colorArray,j=a.__sortArray,o=a.__dirtyVertices,k=a.__dirtyColors,p=a.__webglCustomAttributesList;if(c.sortParticles){Ga.multiplySelf(c.matrixWorld);for(d=0;d=0;c--)a[c].object===b&&a.splice(c,1)}function G(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function u(a,b,c,d,f){d.program||E.initMaterial(d,b,c,f);if(d.morphTargets&&!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(E.maxMorphTargets);for(var g=0,h=E.maxMorphTargets;g0;this.getContext=function(){return e}; -this.supportsVertexTextures=function(){return Ma};this.setSize=function(a,b){M.width=a;M.height=b;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(a,b,c,d){za=a;Ja=b;Ha=c;Ia=d;e.viewport(za,Ja,Ha,Ia)};this.setScissor=function(a,b,c,d){e.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(a,b){R.setHex(a);ba=b;e.clearColor(R.r,R.g,R.b,ba)};this.setClearColor=function(a,b){R.copy(a);ba=b;e.clearColor(R.r, -R.g,R.b,ba)};this.getClearColor=function(){return R};this.getClearAlpha=function(){return ba};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=e.COLOR_BUFFER_BIT;if(b===void 0||b)d|=e.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=e.STENCIL_BUFFER_BIT;e.clear(d)};this.clearTarget=function(a,b,c,e){this.setRenderTarget(a);this.clear(b,c,e)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject= -function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];e.deleteBuffer(c.__webglVertexBuffer);e.deleteBuffer(c.__webglNormalBuffer);e.deleteBuffer(c.__webglTangentBuffer);e.deleteBuffer(c.__webglColorBuffer);e.deleteBuffer(c.__webglUVBuffer);e.deleteBuffer(c.__webglUV2Buffer);e.deleteBuffer(c.__webglSkinVertexABuffer); -e.deleteBuffer(c.__webglSkinVertexBBuffer);e.deleteBuffer(c.__webglSkinIndicesBuffer);e.deleteBuffer(c.__webglSkinWeightsBuffer);e.deleteBuffer(c.__webglFaceBuffer);e.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,f=c.numMorphTargets;d=0)a&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(b.position,3,e.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;g.morphTargetBase!==-1?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[g.morphTargetBase]), -e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0)):c.position>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){h=0;var k=g.morphTargetForcedOrder;for(i=g.morphTargetInfluences;hn&&(r=p,n=i[r]);e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[r]);e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=n;k[r]=1;n=-1;h++}}d.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){h= +function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;else if(b.materialIndex>=0)return a.geometry.materials[b.materialIndex]}function d(a){if(a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial)return!1;return a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function f(a){if(a.vertexColors)return a.vertexColors;return!1}function g(a){if(a.map||a.lightMap||a instanceof THREE.ShaderMaterial)return!0; +return!1}function h(a,b,c){var d,g,f,h,o=a.vertices;h=o.length;var H=a.colors,i=H.length,s=a.__vertexArray,k=a.__colorArray,j=a.__sortArray,q=a.__dirtyVertices,l=a.__dirtyColors,p=a.__webglCustomAttributesList;if(c.sortParticles){Fa.multiplySelf(c.matrixWorld);for(d=0;d=0;c--)a[c].object===b&&a.splice(c,1)}function C(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function J(a,b,c,d,f){d.program||E.initMaterial(d,b,c,f);if(d.morphTargets&&!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences= +new Float32Array(E.maxMorphTargets);for(var g=0,h=E.maxMorphTargets;g0;this.getContext=function(){return e};this.supportsVertexTextures=function(){return Ma};this.setSize=function(a,b){ja.width=a;ja.height=b;this.setViewport(0,0,ja.width,ja.height)};this.setViewport=function(a,b,c,d){Ia=a;Ja=b;Ga=c;Ha=d;e.viewport(Ia,Ja,Ga,Ha)};this.setScissor=function(a,b,c,d){e.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(a,b){L.setHex(a); +va=b;e.clearColor(L.r,L.g,L.b,va)};this.setClearColor=function(a,b){L.copy(a);va=b;e.clearColor(L.r,L.g,L.b,va)};this.getClearColor=function(){return L};this.getClearAlpha=function(){return va};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=e.COLOR_BUFFER_BIT;if(b===void 0||b)d|=e.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=e.STENCIL_BUFFER_BIT;e.clear(d)};this.clearTarget=function(a,b,c,e){this.setRenderTarget(a);this.clear(b,c,e)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)}; +this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];e.deleteBuffer(c.__webglVertexBuffer);e.deleteBuffer(c.__webglNormalBuffer);e.deleteBuffer(c.__webglTangentBuffer);e.deleteBuffer(c.__webglColorBuffer); +e.deleteBuffer(c.__webglUVBuffer);e.deleteBuffer(c.__webglUV2Buffer);e.deleteBuffer(c.__webglSkinVertexABuffer);e.deleteBuffer(c.__webglSkinVertexBBuffer);e.deleteBuffer(c.__webglSkinIndicesBuffer);e.deleteBuffer(c.__webglSkinWeightsBuffer);e.deleteBuffer(c.__webglFaceBuffer);e.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,f=c.numMorphTargets;d=0)a&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(b.position,3,e.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;g.morphTargetBase!==-1?(e.bindBuffer(e.ARRAY_BUFFER, +f.__webglMorphTargetsBuffers[g.morphTargetBase]),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0)):c.position>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){h=0;var l=g.morphTargetForcedOrder;for(i=g.morphTargetInfluences;hk&&(s=p,k=i[s]);e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[s]);e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=k;l[s]=1;k=-1;h++}}d.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){h= 0;for(i=f.__webglCustomAttributesList.length;h=0&&(e.bindBuffer(e.ARRAY_BUFFER,c.buffer),e.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,e.FLOAT,!1,0,0))}b.color>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglColorBuffer),e.vertexAttribPointer(b.color,3,e.FLOAT,!1,0,0));b.normal>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglNormalBuffer),e.vertexAttribPointer(b.normal,3,e.FLOAT,!1,0,0));b.tangent>=0&&(e.bindBuffer(e.ARRAY_BUFFER, f.__webglTangentBuffer),e.vertexAttribPointer(b.tangent,4,e.FLOAT,!1,0,0));b.uv>=0&&(f.__webglUVBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUVBuffer),e.vertexAttribPointer(b.uv,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv)):e.disableVertexAttribArray(b.uv));b.uv2>=0&&(f.__webglUV2Buffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUV2Buffer),e.vertexAttribPointer(b.uv2,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv2)):e.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>= 0&&b.skinIndex>=0&&b.skinWeight>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexABuffer),e.vertexAttribPointer(b.skinVertexA,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),e.vertexAttribPointer(b.skinVertexB,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),e.vertexAttribPointer(b.skinIndex,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),e.vertexAttribPointer(b.skinWeight,4,e.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe? -(d=d.wireframeLinewidth,d!==Aa&&(e.lineWidth(d),Aa=d),a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),e.drawElements(e.LINES,f.__webglLineCount,e.UNSIGNED_SHORT,0)):(a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),e.drawElements(e.TRIANGLES,f.__webglFaceCount,e.UNSIGNED_SHORT,0)),E.info.render.calls++,E.info.render.vertices+=f.__webglFaceCount,E.info.render.faces+=f.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?e.LINE_STRIP:e.LINES,d=d.linewidth,d!== -Aa&&(e.lineWidth(d),Aa=d),e.drawArrays(g,0,f.__webglLineCount),E.info.render.calls++):g instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS,0,f.__webglParticleCount),E.info.render.calls++):g instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,0,f.__webglVertexCount),E.info.render.calls++)}};this.render=function(a,b,c,d){var f,g,h,l,k=a.lights,n=a.fog;ua=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."), -a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();if(this.renderPluginsPre.length){f=0;for(g=this.renderPluginsPre.length;f=0)o=w.geometry.materials[o],o.transparent?(r.transparent=o,r.opaque=null):(r.opaque=o,r.transparent=null)}else if(o)o.transparent?(r.transparent=o,r.opaque=null):(r.opaque=o,r.transparent=null);h.render=!0;if(this.sortObjects)l.renderDepth?h.z=l.renderDepth:(Ea.copy(l.position),Ga.multiplyVector3(Ea),h.z=Ea.z)}this.sortObjects&&d.sort(i);d=a.__webglObjectsImmediate;f=0;for(g=d.length;f65535&&(o[Y].counter+= -1,j=o[Y].hash+"_"+o[Y].counter,B.geometryGroups[j]===void 0&&(B.geometryGroups[j]={faces3:[],faces4:[],materialIndex:$,vertices:0,numMorphTargets:H})),I instanceof THREE.Face3?B.geometryGroups[j].faces3.push(C):B.geometryGroups[j].faces4.push(C),B.geometryGroups[j].vertices+=r;B.geometryGroupsList=[];C=void 0;for(C in B.geometryGroups)B.geometryGroups[C].id=xa++,B.geometryGroupsList.push(B.geometryGroups[C])}for(q in u.geometryGroups)if(B=u.geometryGroups[q],!B.__webglVertexBuffer){C=B;C.__webglVertexBuffer= -e.createBuffer();C.__webglNormalBuffer=e.createBuffer();C.__webglTangentBuffer=e.createBuffer();C.__webglColorBuffer=e.createBuffer();C.__webglUVBuffer=e.createBuffer();C.__webglUV2Buffer=e.createBuffer();C.__webglSkinVertexABuffer=e.createBuffer();C.__webglSkinVertexBBuffer=e.createBuffer();C.__webglSkinIndicesBuffer=e.createBuffer();C.__webglSkinWeightsBuffer=e.createBuffer();C.__webglFaceBuffer=e.createBuffer();C.__webglLineBuffer=e.createBuffer();if(C.numMorphTargets){I=l=void 0;C.__webglMorphTargetsBuffers= -[];l=0;for(I=C.numMorphTargets;l0||r.faceVertexUvs.length>0)B.__uvArray= -new Float32Array(C*2);if(r.faceUvs.length>1||r.faceVertexUvs.length>1)B.__uv2Array=new Float32Array(C*2)}if($.geometry.skinWeights.length&&$.geometry.skinIndices.length)B.__skinVertexAArray=new Float32Array(C*4),B.__skinVertexBArray=new Float32Array(C*4),B.__skinIndexArray=new Float32Array(C*4),B.__skinWeightArray=new Float32Array(C*4);B.__faceArray=new Uint16Array(I*3);B.__lineArray=new Uint16Array(Y*2);if(B.numMorphTargets){B.__morphTargetsArrays=[];$=0;for(r=B.numMorphTargets;$0&&(e.bindBuffer(e.ARRAY_BUFFER,l.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,U,I),e.bindBuffer(e.ARRAY_BUFFER,l.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,V,I),e.bindBuffer(e.ARRAY_BUFFER,l.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,T,I),e.bindBuffer(e.ARRAY_BUFFER,l.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,ja,I))}if(wa&&Y){j=0;for(o=L.length;j0&&(e.bindBuffer(e.ARRAY_BUFFER,l.__webglColorBuffer), -e.bufferData(e.ARRAY_BUFFER,fa,I))}if(O&&ma.hasTangents){j=0;for(o=L.length;j0&&(e.bindBuffer(e.ARRAY_BUFFER,l.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,ba,I))}if(ta&& -va&&K){j=0;for(o=L.length;j0&&(e.bindBuffer(e.ARRAY_BUFFER,l.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,s,I))}if(ua){j=0;for(o=L.length;j=0&&e.enableVertexAttribArray(o.position);o.color>=0&&e.enableVertexAttribArray(o.color);o.normal>=0&&e.enableVertexAttribArray(o.normal); -o.tangent>=0&&e.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(e.enableVertexAttribArray(o.skinVertexA),e.enableVertexAttribArray(o.skinVertexB),e.enableVertexAttribArray(o.skinIndex),e.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(g in a.attributes)o[g]!==void 0&&o[g]>=0&&e.enableVertexAttribArray(o[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g=0&&(e.enableVertexAttribArray(o[u]), -a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW),a==="back"?e.cullFace(e.BACK):a==="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK),e.enable(e.CULL_FACE)):e.disable(e.CULL_FACE)};this.setObjectFaces=function(a){if(ka!==a.doubleSided)a.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE),ka=a.doubleSided;if(na!==a.flipSided)a.flipSided?e.frontFace(e.CW): -e.frontFace(e.CCW),na=a.flipSided};this.setDepthTest=function(a){qa!==a&&(a?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),qa=a)};this.setBlending=function(a){if(a!==S){switch(a){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)}S=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=e.createTexture(),E.info.memory.textures++;e.activeTexture(e.TEXTURE0+b);e.bindTexture(e.TEXTURE_2D,a.__webglTexture);var c=ea(e.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,H(a.format),a.image.width,a.image.height,0,H(a.format),e.UNSIGNED_BYTE,a.image.data):e.texImage2D(e.TEXTURE_2D, +(d=d.wireframeLinewidth,d!==ya&&(e.lineWidth(d),ya=d),a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),e.drawElements(e.LINES,f.__webglLineCount,e.UNSIGNED_SHORT,0)):(a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),e.drawElements(e.TRIANGLES,f.__webglFaceCount,e.UNSIGNED_SHORT,0)),E.info.render.calls++,E.info.render.vertices+=f.__webglFaceCount,E.info.render.faces+=f.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?e.LINE_STRIP:e.LINES,d=d.linewidth,d!== +ya&&(e.lineWidth(d),ya=d),e.drawArrays(g,0,f.__webglLineCount),E.info.render.calls++):g instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS,0,f.__webglParticleCount),E.info.render.calls++):g instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,0,f.__webglVertexCount),E.info.render.calls++)}};this.render=function(a,b,c,d){var f,g,h,o,l=a.lights,u=a.fog;D=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."), +a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();p(this.renderPluginsPre,a,b);E.info.render.calls=0;E.info.render.vertices=0;E.info.render.faces=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Fa.multiply(b.projectionMatrix,b.matrixWorldInverse); +Ka.setFromMatrix(Fa);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);o=a.__webglObjects;d=0;for(f=o.length;d=0)q=w.geometry.materials[q], +q.transparent?(s.transparent=q,s.opaque=null):(s.opaque=q,s.transparent=null)}else if(q)q.transparent?(s.transparent=q,s.opaque=null):(s.opaque=q,s.transparent=null);g.render=!0;if(this.sortObjects)h.renderDepth?g.z=h.renderDepth:(Da.copy(h.position),Fa.multiplyVector3(Da),g.z=Da.z)}this.sortObjects&&o.sort(i);o=a.__webglObjectsImmediate;d=0;for(f=o.length;d65535&&(q[Y].counter+=1,j=q[Y].hash+"_"+q[Y].counter,A.geometryGroups[j]===void 0&&(A.geometryGroups[j]={faces3:[],faces4:[],materialIndex:aa,vertices:0,numMorphTargets:J})),H instanceof THREE.Face3?A.geometryGroups[j].faces3.push(B):A.geometryGroups[j].faces4.push(B), +A.geometryGroups[j].vertices+=s;A.geometryGroupsList=[];B=void 0;for(B in A.geometryGroups)A.geometryGroups[B].id=pa++,A.geometryGroupsList.push(A.geometryGroups[B])}for(p in n.geometryGroups)if(A=n.geometryGroups[p],!A.__webglVertexBuffer){B=A;B.__webglVertexBuffer=e.createBuffer();B.__webglNormalBuffer=e.createBuffer();B.__webglTangentBuffer=e.createBuffer();B.__webglColorBuffer=e.createBuffer();B.__webglUVBuffer=e.createBuffer();B.__webglUV2Buffer=e.createBuffer();B.__webglSkinVertexABuffer=e.createBuffer(); +B.__webglSkinVertexBBuffer=e.createBuffer();B.__webglSkinIndicesBuffer=e.createBuffer();B.__webglSkinWeightsBuffer=e.createBuffer();B.__webglFaceBuffer=e.createBuffer();B.__webglLineBuffer=e.createBuffer();if(B.numMorphTargets){H=o=void 0;B.__webglMorphTargetsBuffers=[];o=0;for(H=B.numMorphTargets;o0||s.faceVertexUvs.length>0)A.__uvArray=new Float32Array(B*2);if(s.faceUvs.length>1||s.faceVertexUvs.length>1)A.__uv2Array=new Float32Array(B*2)}if(aa.geometry.skinWeights.length&&aa.geometry.skinIndices.length)A.__skinVertexAArray=new Float32Array(B*4),A.__skinVertexBArray= +new Float32Array(B*4),A.__skinIndexArray=new Float32Array(B*4),A.__skinWeightArray=new Float32Array(B*4);A.__faceArray=new Uint16Array(H*3);A.__lineArray=new Uint16Array(Y*2);if(A.numMorphTargets){A.__morphTargetsArrays=[];aa=0;for(s=A.numMorphTargets;aa0&&(e.bindBuffer(e.ARRAY_BUFFER,o.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,V,H),e.bindBuffer(e.ARRAY_BUFFER,o.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,W,H),e.bindBuffer(e.ARRAY_BUFFER,o.__webglSkinIndicesBuffer), +e.bufferData(e.ARRAY_BUFFER,U,H),e.bindBuffer(e.ARRAY_BUFFER,o.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,ka,H))}if(xa&&Y){j=0;for(q=M.length;j0&&(e.bindBuffer(e.ARRAY_BUFFER,o.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,fa,H))}if(P&&L.hasTangents){j=0;for(q=M.length;j0&&(e.bindBuffer(e.ARRAY_BUFFER,o.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,Z,H))}if(qa&&va&&K){j=0;for(q=M.length;j0&&(e.bindBuffer(e.ARRAY_BUFFER,o.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER, +r,H))}if(ta){j=0;for(q=M.length;j=0&&e.enableVertexAttribArray(q.position);q.color>=0&&e.enableVertexAttribArray(q.color);q.normal>=0&&e.enableVertexAttribArray(q.normal); +q.tangent>=0&&e.enableVertexAttribArray(q.tangent);a.skinning&&q.skinVertexA>=0&&q.skinVertexB>=0&&q.skinIndex>=0&&q.skinWeight>=0&&(e.enableVertexAttribArray(q.skinVertexA),e.enableVertexAttribArray(q.skinVertexB),e.enableVertexAttribArray(q.skinIndex),e.enableVertexAttribArray(q.skinWeight));if(a.attributes)for(g in a.attributes)q[g]!==void 0&&q[g]>=0&&e.enableVertexAttribArray(q[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g=0&&(e.enableVertexAttribArray(q[w]), +a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW),a==="back"?e.cullFace(e.BACK):a==="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK),e.enable(e.CULL_FACE)):e.disable(e.CULL_FACE)};this.setObjectFaces=function(a){if(xa!==a.doubleSided)a.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE),xa=a.doubleSided;if(Z!==a.flipSided)a.flipSided?e.frontFace(e.CW): +e.frontFace(e.CCW),Z=a.flipSided};this.setDepthTest=function(a){sa!==a&&(a?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),sa=a)};this.setBlending=function(a){if(a!==oa){switch(a){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)}oa=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=e.createTexture(),E.info.memory.textures++;e.activeTexture(e.TEXTURE0+b);e.bindTexture(e.TEXTURE_2D,a.__webglTexture);var c=K(e.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,O(a.format),a.image.width,a.image.height,0,O(a.format),e.UNSIGNED_BYTE,a.image.data):e.texImage2D(e.TEXTURE_2D, 0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,a.image);c&&e.generateMipmap(e.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else e.activeTexture(e.TEXTURE0+b),e.bindTexture(e.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=e.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];e.bindTexture(e.TEXTURE_CUBE_MAP, -a.__webglTexture);ea(e.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=e.createFramebuffer();a.__webglRenderbuffer[c]=e.createRenderbuffer();e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,H(a.format),a.width,a.height,0,H(a.format),H(a.type),null);var d=a,f=e.TEXTURE_CUBE_MAP_POSITIVE_X+c;e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[c]);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,f,d.__webglTexture,0);D(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer= -e.createFramebuffer(),a.__webglRenderbuffer=e.createRenderbuffer(),e.bindTexture(e.TEXTURE_2D,a.__webglTexture),ea(e.TEXTURE_2D,a,a),e.texImage2D(e.TEXTURE_2D,0,H(a.format),a.width,a.height,0,H(a.format),H(a.type),null),c=e.TEXTURE_2D,e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,c,a.__webglTexture,0),D(a.__webglRenderbuffer,a);b?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER, -null);e.bindFramebuffer(e.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=d=0):(b=null,c=Ha,a=Ia,d=za,f=Ja);b!==X&&(e.bindFramebuffer(e.FRAMEBUFFER,b),e.viewport(d,f,c,a),X=b)};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; +a.__webglTexture);K(e.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=e.createFramebuffer();a.__webglRenderbuffer[c]=e.createRenderbuffer();e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,O(a.format),a.width,a.height,0,O(a.format),O(a.type),null);var d=a,f=e.TEXTURE_CUBE_MAP_POSITIVE_X+c;e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[c]);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,f,d.__webglTexture,0);P(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=e.createFramebuffer(), +a.__webglRenderbuffer=e.createRenderbuffer(),e.bindTexture(e.TEXTURE_2D,a.__webglTexture),K(e.TEXTURE_2D,a,a),e.texImage2D(e.TEXTURE_2D,0,O(a.format),a.width,a.height,0,O(a.format),O(a.type),null),c=e.TEXTURE_2D,e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,c,a.__webglTexture,0),P(a.__webglRenderbuffer,a);b?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER, +null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=d=0):(b=null,c=Ga,a=Ha,d=Ia,f=Ja);b!==na&&(e.bindFramebuffer(e.FRAMEBUFFER,b),e.viewport(d,f,c,a),na=b)};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==void 0?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==void 0?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==void 0?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==void 0?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:THREE.RGBAFormat;this.type=c.type!==void 0?c.type: THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:!0}; THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0}; diff --git a/src/extras/plugins/ShadowMapPlugin.js b/src/extras/plugins/ShadowMapPlugin.js index 13c8953c..a98ca1e8 100644 --- a/src/extras/plugins/ShadowMapPlugin.js +++ b/src/extras/plugins/ShadowMapPlugin.js @@ -48,6 +48,7 @@ THREE.ShadowMapPlugin = function ( ) { shadowMap, shadowMatrix, program, buffer, material, webglObject, object, light, + renderList, shadowIndex = 0, @@ -130,11 +131,11 @@ THREE.ShadowMapPlugin = function ( ) { // set matrices & frustum culling - jl = scene.__webglObjects.length; + renderList = scene.__webglObjects; - for ( j = 0; j < jl; j ++ ) { + for ( j = 0, jl = renderList.length; j < jl; j ++ ) { - webglObject = scene.__webglObjects[ j ]; + webglObject = renderList[ j ]; object = webglObject.object; webglObject.render = false; @@ -161,9 +162,9 @@ THREE.ShadowMapPlugin = function ( ) { //_gl.cullFace( _gl.FRONT ); - for ( j = 0; j < jl; j ++ ) { + for ( j = 0, jl = renderList.length; j < jl; j ++ ) { - webglObject = scene.__webglObjects[ j ]; + webglObject = renderList[ j ]; if ( webglObject.render ) { @@ -194,11 +195,11 @@ THREE.ShadowMapPlugin = function ( ) { // set matrices and render immediate objects - jl = scene.__webglObjectsImmediate.length; + renderList = scene.__webglObjectsImmediate; - for ( j = 0; j < jl; j ++ ) { + for ( j = 0, jl = renderList.length; j < jl; j ++ ) { - webglObject = scene.__webglObjectsImmediate[ j ]; + webglObject = renderList[ j ]; object = webglObject.object; if ( object.visible && object.castShadow ) { diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 666aeeca..54d7a858 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -3032,29 +3032,7 @@ THREE.WebGLRenderer = function ( parameters ) { // custom render plugins (pre pass) - if ( this.renderPluginsPre.length ) { - - for ( i = 0, il = this.renderPluginsPre.length; i < il; i ++ ) { - - _currentProgram = null; - _oldBlending = -1; - _oldDepthTest = -1; - _oldDepthWrite = -1; - _currentGeometryGroupHash = -1; - _currentMaterialId = -1; - - this.renderPluginsPre[ i ].render( scene, camera, _viewportWidth, _viewportHeight ); - - _currentProgram = null; - _oldBlending = -1; - _oldDepthTest = -1; - _oldDepthWrite = -1; - _currentGeometryGroupHash = -1; - _currentMaterialId = -1; - - } - - } + renderPlugins( this.renderPluginsPre, scene, camera ); _this.info.render.calls = 0; _this.info.render.vertices = 0; @@ -3184,22 +3162,8 @@ THREE.WebGLRenderer = function ( parameters ) { // custom render plugins (post pass) - if ( this.renderPluginsPost.length ) { + renderPlugins( this.renderPluginsPost, scene, camera ); - for ( i = 0, il = this.renderPluginsPost.length; i < il; i ++ ) { - - this.renderPluginsPost[ i ].render( scene, camera, _viewportWidth, _viewportHeight ); - - _currentProgram = null; - _oldBlending = -1; - _oldDepthTest = -1; - _oldDepthWrite = -1; - _currentGeometryGroupHash = -1; - _currentMaterialId = -1; - - } - - } // Generate mipmap if we're using any kind of mipmap filtering @@ -3213,6 +3177,32 @@ THREE.WebGLRenderer = function ( parameters ) { }; + function renderPlugins( plugins, scene, camera ) { + + if ( ! plugins.length ) return; + + for ( var i = 0, il = plugins.length; i < il; i ++ ) { + + _currentProgram = null; + _oldBlending = -1; + _oldDepthTest = -1; + _oldDepthWrite = -1; + _currentGeometryGroupHash = -1; + _currentMaterialId = -1; + + plugins[ i ].render( scene, camera, _viewportWidth, _viewportHeight ); + + _currentProgram = null; + _oldBlending = -1; + _oldDepthTest = -1; + _oldDepthWrite = -1; + _currentGeometryGroupHash = -1; + _currentMaterialId = -1; + + } + + }; + function renderObjects ( renderList, reverse, materialType, camera, lights, fog, useBlending, overrideMaterial ) { var webglObject, object, buffer, material, start, end, delta;