diff --git a/build/Three.js b/build/Three.js index dc8246e5556e7f29de27e61c4e37f17515d5de53..b44b2effe9fed500b5eb18f56abd519f4d7311b8 100644 --- a/build/Three.js +++ b/build/Three.js @@ -1,10 +1,10 @@ // Three.js - http://github.com/mrdoob/three.js 'use strict';var THREE=THREE||{REVISION:"48dev"};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array; -(function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return Math.floor(255*this.r)<<16^Math.floor(255*this.g)<<8^Math.floor(255*this.b)},getContextStyle:function(){return"rgb("+Math.floor(255*this.r)+","+Math.floor(255*this.g)+","+Math.floor(255*this.b)+")"},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)}, @@ -19,94 +19,94 @@ this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this. 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.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]}; THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes;c[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);c[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);c[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);c[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);c[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);c[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;6>a;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}; THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3; -THREE.Ray=function(a,b){function c(a,b,c){n.sub(c,a);r=n.dot(b);s=q.add(a,m.copy(b).multiplyScalar(r));return t=c.distanceTo(s)}function d(a,b,c,d){n.sub(d,b);q.sub(c,b);m.sub(a,b);w=n.dot(n);u=n.dot(q);v=n.dot(m);B=q.dot(q);F=q.dot(m);z=1/(w*B-u*u);D=(B*v-u*F)*z;H=(w*F-u*v)*z;return 0<=D&&0<=H&&1>D+H}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;ba.scale.x)return[];b={distance:m,point:a.position,face:null,object:a};n.push(b)}else if(a instanceof THREE.Mesh){var m= -c(this.origin,this.direction,a.matrixWorld.getPosition()),q=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(m>a.geometry.boundingSphere.radius*Math.max(q.x,Math.max(q.y,q.z)))return n;var r,s,l=a.geometry,t=l.vertices,u;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(m=0,q=l.faces.length;mMath.abs(r))&&(s=p.dot(j)/r,!(0>s)&&(a.doubleSided||(a.flipSided?0r))))if(o.add(i,k.multiplyScalar(s)),b instanceof THREE.Face3)e=u.multiplyVector3(e.copy(t[b.a].position)),f=u.multiplyVector3(f.copy(t[b.b].position)),g=u.multiplyVector3(g.copy(t[b.c].position)),d(o,e,f,g)&&(b={distance:i.distanceTo(o),point:o.clone(),face:b,object:a},n.push(b));else if(b instanceof THREE.Face4&&(e=u.multiplyVector3(e.copy(t[b.a].position)), -f=u.multiplyVector3(f.copy(t[b.b].position)),g=u.multiplyVector3(g.copy(t[b.c].position)),h=u.multiplyVector3(h.copy(t[b.d].position)),d(o,e,f,h)||d(o,f,g,h)))b={distance:i.distanceTo(o),point:o.clone(),face:b,object:a},n.push(b)}return n};var n=new THREE.Vector3,q=new THREE.Vector3,m=new THREE.Vector3,r,s,t,w,u,v,B,F,z,D,H}; -THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,j,p){h=!1;b=f;c=g;d=j;e=p;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= -function(f,g,j,p,o,n){h?(h=!1,b=fj?f>o?f:o:j>o?j:o,e=g>p?g>n?g:n:p>n?p:n):(b=fj?f>o?f>d?f:d:o>d?o:d:j>o?j>d?j:d:o>d?o:d,e=g>p?g>n?g>e?g:e:n>e?n:e:p>n?p>e?p:e:n>e?n:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> -f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=da.getRight()||ea.getBottom()?!1:!0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}}; +THREE.Ray=function(a,b){function c(a,b,c){q.sub(c,a);s=q.dot(b);t=n.add(a,r.copy(b).multiplyScalar(s));return w=c.distanceTo(t)}function d(a,b,c,d){q.sub(d,b);n.sub(c,b);r.sub(a,b);u=q.dot(q);v=q.dot(n);B=q.dot(r);F=n.dot(n);z=n.dot(r);D=1/(u*F-v*v);H=(F*B-v*z)*D;J=(u*z-v*B)*D;return 0<=H&&0<=J&&1>H+J}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;ba.scale.x)return[];b={distance:q,point:a.position,face:null,object:a}; +n.push(b)}else if(a instanceof THREE.Mesh){var q=c(this.origin,this.direction,a.matrixWorld.getPosition()),r=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(q>a.geometry.boundingSphere.radius*Math.max(r.x,Math.max(r.y,r.z)))return n;var s,l,t=a.geometry,u=t.vertices,E;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(q=0,r=t.faces.length;ql)&&(a.doubleSided||(a.flipSided?0s))))if(m.add(j,k.multiplyScalar(l)),b instanceof THREE.Face3)g=E.multiplyVector3(g.copy(u[b.a].position)),f=E.multiplyVector3(f.copy(u[b.b].position)),h=E.multiplyVector3(h.copy(u[b.c].position)),d(m,g,f,h)&&(b={distance:j.distanceTo(m),point:m.clone(),face:b,object:a},n.push(b));else if(b instanceof +THREE.Face4&&(g=E.multiplyVector3(g.copy(u[b.a].position)),f=E.multiplyVector3(f.copy(u[b.b].position)),h=E.multiplyVector3(h.copy(u[b.c].position)),i=E.multiplyVector3(i.copy(u[b.d].position)),d(m,g,f,i)||d(m,f,h,i)))b={distance:j.distanceTo(m),point:m.clone(),face:b,object:a},n.push(b)}return n};var q=new THREE.Vector3,n=new THREE.Vector3,r=new THREE.Vector3,s,t,w,u,v,B,F,z,D,H,J}; +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,p){h=!1;b=g;c=f;d=k;e=p;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,p,o,m){h?(h=!1,b=gk?g>o?g:o:k>o?k:o,e=f>p?f>m?f:m:p>m?p:m):(b=gk?g>o?g>d?g:d:o>d?o:d:k>o?k>d?k:d:o>d?o:d,e=f>p?f>m?f>e?f:e:m>e?m:e:p>m?p>e?p: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=da.getRight()||ea.getBottom()?!1:!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 ae&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(dg&&h.positionScreen.z(ja.positionScreen.x-M.positionScreen.x)*(ba.positionScreen.y-M.positionScreen.y)-(ja.positionScreen.y-M.positionScreen.y)*(ba.positionScreen.x-M.positionScreen.x), -R.doubleSided||l!=R.flipSided)ha=o[p]=o[p]||new THREE.RenderableFace3,p++,j=ha,j.v1.copy(M),j.v2.copy(ba),j.v3.copy(ja);else continue;else continue;else if(E instanceof THREE.Face4)if(M=k[E.a],ba=k[E.b],ja=k[E.c],ha=k[E.d],M.visible&&ba.visible&&ja.visible&&ha.visible)if(l=0>(ha.positionScreen.x-M.positionScreen.x)*(ba.positionScreen.y-M.positionScreen.y)-(ha.positionScreen.y-M.positionScreen.y)*(ba.positionScreen.x-M.positionScreen.x)||0>(ba.positionScreen.x-ja.positionScreen.x)*(ha.positionScreen.y- -ja.positionScreen.y)-(ba.positionScreen.y-ja.positionScreen.y)*(ha.positionScreen.x-ja.positionScreen.x),R.doubleSided||l!=R.flipSided)Ia=q[n]=q[n]||new THREE.RenderableFace4,n++,j=Ia,j.v1.copy(M),j.v2.copy(ba),j.v3.copy(ja),j.v4.copy(ha);else continue;else continue;j.normalWorld.copy(E.normal);!l&&(R.flipSided||R.doubleSided)&&j.normalWorld.negate();U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(E.centroid);$.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);z.multiplyVector3(j.centroidScreen); -ja=E.vertexNormals;for(M=0,ba=ja.length;MF.z))g=u[w]=u[w]||new THREE.RenderableParticle,w++,t=g,t.x=F.x/F.w,t.y=F.y/F.w,t.z=F.z,t.rotation=R.rotation.z,t.scale.x=R.scale.x*Math.abs(t.x-(F.x+e.projectionMatrix.n11)/(F.w+e.projectionMatrix.n14)),t.scale.y=R.scale.y*Math.abs(t.y-(F.y+e.projectionMatrix.n22)/(F.w+e.projectionMatrix.n24)),t.material=R.material,v.elements.push(t);f&&v.elements.sort(c);return v}}; +THREE.Projector=function(){function a(){var a=f[g]=f[g]||new THREE.RenderableObject;g++;return a}function b(){var a=j[i]=j[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;if(0<=e&&0<=g&&0<=f&&0<=h)return!0;if(0>e&&0>g||0>f&&0>h)return!1;0>e?c=Math.max(c,e/(e-g)):0>g&&(d=Math.min(d,e/(e-g)));0>f?c=Math.max(c,f/(f-h)):0>h&&(d=Math.min(d,f/(f-h)));if(df&&h.positionScreen.z(ja.positionScreen.x-M.positionScreen.x)*(ba.positionScreen.y-M.positionScreen.y)-(ja.positionScreen.y-M.positionScreen.y)*(ba.positionScreen.x-M.positionScreen.x), +R.doubleSided||l!=R.flipSided)ha=o[p]=o[p]||new THREE.RenderableFace3,p++,k=ha,k.v1.copy(M),k.v2.copy(ba),k.v3.copy(ja);else continue;else continue;else if(E instanceof THREE.Face4)if(M=j[E.a],ba=j[E.b],ja=j[E.c],ha=j[E.d],M.visible&&ba.visible&&ja.visible&&ha.visible)if(l=0>(ha.positionScreen.x-M.positionScreen.x)*(ba.positionScreen.y-M.positionScreen.y)-(ha.positionScreen.y-M.positionScreen.y)*(ba.positionScreen.x-M.positionScreen.x)||0>(ba.positionScreen.x-ja.positionScreen.x)*(ha.positionScreen.y- +ja.positionScreen.y)-(ba.positionScreen.y-ja.positionScreen.y)*(ha.positionScreen.x-ja.positionScreen.x),R.doubleSided||l!=R.flipSided)Ja=q[m]=q[m]||new THREE.RenderableFace4,m++,k=Ja,k.v1.copy(M),k.v2.copy(ba),k.v3.copy(ja),k.v4.copy(ha);else continue;else continue;k.normalWorld.copy(E.normal);!l&&(R.flipSided||R.doubleSided)&&k.normalWorld.negate();U.multiplyVector3(k.normalWorld);k.centroidWorld.copy(E.centroid);$.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);z.multiplyVector3(k.centroidScreen); +ja=E.vertexNormals;for(M=0,ba=ja.length;MF.z))f=u[w]=u[w]||new THREE.RenderableParticle,w++,t=f,t.x=F.x/F.w,t.y=F.y/F.w,t.z=F.z,t.rotation=R.rotation.z,t.scale.x=R.scale.x*Math.abs(t.x-(F.x+e.projectionMatrix.n11)/(F.w+e.projectionMatrix.n14)),t.scale.y=R.scale.y*Math.abs(t.y-(F.y+e.projectionMatrix.n22)/(F.w+e.projectionMatrix.n24)),t.material=R.material,v.elements.push(t);g&&v.elements.sort(c);return v}}; THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e* -f-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=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31? +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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31? -Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-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);0===a?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,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-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,f=this.x,g=this.y,h=this.z,i=this.w,k=i*c+g*e-h*d,j=i*d+h*c-f*e,p=i*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=k*i+c*-f+j*-h-p*-g;b.y=j*i+c*-g+p*-f-k*-h;b.z=p*i+c*-h+k*-g-j*-f;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;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))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)/e;d=Math.sin(d*f)/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.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,e,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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; +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,j=i*c+f*e-h*d,k=i*d+h*c-g*e,p=i*e+g*d-f*c,c=-g*c-f*d-h*e;b.x=j*i+c*-g+k*-h-p*-f;b.y=k*i+c*-f+p*-g-j*-h;b.z=p*i+c*-h+j*-f-k*-g;return b}}; +THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))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(0.0010>Math.abs(e))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.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};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.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;be?-1:1,f.vertexTangents[d]=new THREE.Vector4(N.x,N.y,N.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0e?-1:1,g.vertexTangents[d]=new THREE.Vector4(N.x,N.y,N.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0c.x)c.x=a.x;if(a.yc.y)c.y=a.y;if(a.zc.z)c.z=a.z}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;cb&&(b=a);this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10, -4),f,g;for(f=0,g=this.vertices.length;fthis.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;k=this.points[c[0]];j=this.points[c[1]]; -p=this.points[c[2]];o=this.points[c[3]];h=g*g;i=g*h;d.x=b(k.x,j.x,p.x,o.x,g,h,i);d.y=b(k.y,j.y,p.y,o.y,g,h,i);d.z=b(k.z,j.z,p.z,o.z,g,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;j=this.points[c[0]];k=this.points[c[1]]; +p=this.points[c[2]];o=this.points[c[3]];h=f*f;i=f*h;d.x=b(j.x,k.x,p.x,o.x,f,h,i);d.y=b(j.y,k.y,p.y,o.y,f,h,i);d.z=b(j.z,k.z,p.z,o.z,f,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;ah.end)h.end=e;b||(b=g)}}a.firstAnimation=b}; +THREE.MorphAnimMesh.prototype.parseAnimations=function(){var a=this.geometry;if(!a.animations)a.animations={};for(var b,c=a.animations,d=/([a-z]+)(\d+)/,e=0,g=a.morphTargets.length;eh.end)h.end=e;b||(b=f)}}a.firstAnimation=b}; THREE.MorphAnimMesh.prototype.setAnimationLabel=function(a,b,c){if(!this.geometry.animations)this.geometry.animations={};this.geometry.animations[a]={start:b,end:c}};THREE.MorphAnimMesh.prototype.playAnimation=function(a,b){var c=this.geometry.animations[a];c?(this.setFrameRange(c.start,c.end),this.duration=1E3*((c.end-c.start)/b),this.time=0):console.warn("animation["+a+"] undefined")}; THREE.MorphAnimMesh.prototype.updateAnimation=function(a){var b=this.duration/this.length;this.time+=this.direction*a;if(this.mirroredLoop){if(this.time>this.duration||0>this.time){this.direction*=-1;if(this.time>this.duration)this.time=this.duration,this.directionBackwards=!0;if(0>this.time)this.time=0,this.directionBackwards=!1}}else this.time%=this.duration,0>this.time&&(this.time+=this.duration);a=this.startKeyframe+THREE.Math.clamp(Math.floor(this.time/b),0,this.length-1);if(a!==this.currentKeyframe)this.morphTargetInfluences[this.lastKeyframe]= 0,this.morphTargetInfluences[this.currentKeyframe]=1,this.morphTargetInfluences[a]=0,this.lastKeyframe=this.currentKeyframe,this.currentKeyframe=a;b=this.time%b/b;this.directionBackwards&&(b=1-b);this.morphTargetInfluences[this.currentKeyframe]=b;this.morphTargetInfluences[this.lastKeyframe]=1-b};THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon; @@ -166,55 +166,56 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog= THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)-1===this.lights.indexOf(a)&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&-1===this.objects.indexOf(a)){this.objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);-1!==b&&this.__objectsRemoved.splice(b,1)}for(b=0;bs&&m.clearRect(Math.floor(ra.getX()),Math.floor(ra.getY()),Math.floor(ra.getWidth()),Math.floor(ra.getHeight())),0=i||(i*=g.intensity,d.r+=h.r*i,d.g+=h.g*i,d.b+=h.b*i)):g instanceof THREE.PointLight&&(l=g.matrixWorld.getPosition(),i=c.dot(Y.sub(l,b).normalize()),0>=i||(i*=0==g.distance?1:1-Math.min(b.distanceTo(l)/g.distance,1),0!=i&&(i*=g.intensity,d.r+=h.r*i,d.g+=h.g*i,d.b+=h.b*i)))}function r(a,f,g){b(g.opacity);c(g.blending);var Y,h,l,i,j,k;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)i= -g.map.image,j=i.width>>1,k=i.height>>1,g=f.scale.x*n,l=f.scale.y*q,Y=g*j,h=l*k,ya.set(a.x-Y,a.y-h,a.x+Y,a.y+h),Ka.intersects(ya)&&(m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(g,-l),m.translate(-j,-k),m.drawImage(i,0,0),m.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(Y=f.scale.x*n,h=f.scale.y*q,ya.set(a.x-Y,a.y-h,a.x+Y,a.y+h),Ka.intersects(ya)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(Y,h),g.program(m), -m.restore()))}function s(a,e,f,g){b(g.opacity);c(g.blending);m.beginPath();m.moveTo(a.positionScreen.x,a.positionScreen.y);m.lineTo(e.positionScreen.x,e.positionScreen.y);m.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(B!=a)m.lineWidth=B=a;a=g.linecap;if(F!=a)m.lineCap=F=a;a=g.linejoin;if(z!=a)m.lineJoin=z=a;d(g.color.getContextStyle());m.stroke();ya.inflate(2*g.linewidth)}}function t(a,d,e,g,h,k,m,n){f.info.render.vertices+=3;f.info.render.faces++;b(n.opacity);c(n.blending); -Q=a.positionScreen.x;I=a.positionScreen.y;y=d.positionScreen.x;l=d.positionScreen.y;Z=e.positionScreen.x;C=e.positionScreen.y;v(Q,I,y,l,Z,C);if(n instanceof THREE.MeshBasicMaterial)if(n.map)n.map.mapping instanceof THREE.UVMapping&&(fa=m.uvs[0],Vc(Q,I,y,l,Z,C,fa[g].u,fa[g].v,fa[h].u,fa[h].v,fa[k].u,fa[k].v,n.map));else if(n.envMap){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=j.matrixWorldInverse,Y.copy(m.vertexNormalsWorld[g]),ib=0.5*(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)+0.5,cb=0.5* --(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)+0.5,Y.copy(m.vertexNormalsWorld[h]),lb=0.5*(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)+0.5,bb=0.5*-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)+0.5,Y.copy(m.vertexNormalsWorld[k]),Ya=0.5*(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)+0.5,Ra=0.5*-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)+0.5,Vc(Q,I,y,l,Z,C,ib,cb,lb,bb,Ya,Ra,n.envMap)}else n.wireframe?Mb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Gb(n.color);else if(n instanceof THREE.MeshLambertMaterial)n.map&&!n.wireframe&&(n.map.mapping instanceof -THREE.UVMapping&&(fa=m.uvs[0],Vc(Q,I,y,l,Z,C,fa[g].u,fa[g].v,fa[h].u,fa[h].v,fa[k].u,fa[k].v,n.map)),c(THREE.SubtractiveBlending)),Da?!n.wireframe&&n.shading==THREE.SmoothShading&&3==m.vertexNormalsWorld.length?($.r=U.r=aa.r=Ea.r,$.g=U.g=aa.g=Ea.g,$.b=U.b=aa.b=Ea.b,p(i,m.v1.positionWorld,m.vertexNormalsWorld[0],$),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],U),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],aa),$.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)),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)),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)),ga.r=0.5*(U.r+aa.r),ga.g=0.5*(U.g+aa.g),ga.b=0.5*(U.b+aa.b),pa=Dc($,U,aa,ga),gc(Q,I,y,l,Z,C,0,0,1,0,0,1,pa)):(R.r=Ea.r,R.g=Ea.g,R.b=Ea.b,p(i,m.centroidWorld,m.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)),n.wireframe?Mb(R,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Gb(R)):n.wireframe?Mb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Gb(n.color);else if(n instanceof THREE.MeshDepthMaterial)Ja=j.near,Fa=j.far,$.r=$.g=$.b=1-ac(a.positionScreen.z,Ja,Fa),U.r=U.g=U.b=1-ac(d.positionScreen.z,Ja,Fa),aa.r=aa.g=aa.b=1-ac(e.positionScreen.z,Ja,Fa),ga.r=0.5*(U.r+aa.r),ga.g=0.5*(U.g+ -aa.g),ga.b=0.5*(U.b+aa.b),pa=Dc($,U,aa,ga),gc(Q,I,y,l,Z,C,0,0,1,0,0,1,pa);else if(n instanceof THREE.MeshNormalMaterial)R.r=hc(m.normalWorld.x),R.g=hc(m.normalWorld.y),R.b=hc(m.normalWorld.z),n.wireframe?Mb(R,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Gb(R)}function u(a,d,e,g,Y,h,n,m,k){f.info.render.vertices+=4;f.info.render.faces++;b(m.opacity);c(m.blending);if(m.map||m.envMap)t(a,d,g,0,1,3,n,m,k),t(Y,e,h,1,2,3,n,m,k);else if(Q=a.positionScreen.x,I=a.positionScreen.y,y=d.positionScreen.x, -l=d.positionScreen.y,Z=e.positionScreen.x,C=e.positionScreen.y,E=g.positionScreen.x,T=g.positionScreen.y,M=Y.positionScreen.x,ba=Y.positionScreen.y,ja=h.positionScreen.x,ha=h.positionScreen.y,m instanceof THREE.MeshBasicMaterial)w(Q,I,y,l,Z,C,E,T),m.wireframe?Mb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(m.color);else if(m instanceof THREE.MeshLambertMaterial)Da?!m.wireframe&&m.shading==THREE.SmoothShading&&4==n.vertexNormalsWorld.length?($.r=U.r=aa.r=ga.r=Ea.r,$.g=U.g= -aa.g=ga.g=Ea.g,$.b=U.b=aa.b=ga.b=Ea.b,p(i,n.v1.positionWorld,n.vertexNormalsWorld[0],$),p(i,n.v2.positionWorld,n.vertexNormalsWorld[1],U),p(i,n.v4.positionWorld,n.vertexNormalsWorld[3],aa),p(i,n.v3.positionWorld,n.vertexNormalsWorld[2],ga),$.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)),U.r=Math.max(0,Math.min(m.color.r*U.r,1)),U.g=Math.max(0,Math.min(m.color.g*U.g,1)),U.b=Math.max(0,Math.min(m.color.b*U.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)),ga.r=Math.max(0,Math.min(m.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(m.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(m.color.b*ga.b,1)),pa=Dc($,U,aa,ga),v(Q,I,y,l,E,T),gc(Q,I,y,l,E,T,0,0,1,0,0,1,pa),v(M,ba,Z,C,ja,ha),gc(M,ba,Z,C,ja,ha,1,0,1,1,0,1,pa)):(R.r=Ea.r,R.g=Ea.g,R.b=Ea.b,p(i,n.centroidWorld,n.normalWorld,R),R.r=Math.max(0,Math.min(m.color.r*R.r,1)),R.g=Math.max(0,Math.min(m.color.g* -R.g,1)),R.b=Math.max(0,Math.min(m.color.b*R.b,1)),w(Q,I,y,l,Z,C,E,T),m.wireframe?Mb(R,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(R)):(w(Q,I,y,l,Z,C,E,T),m.wireframe?Mb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(m.color));else if(m instanceof THREE.MeshNormalMaterial)R.r=hc(n.normalWorld.x),R.g=hc(n.normalWorld.y),R.b=hc(n.normalWorld.z),w(Q,I,y,l,Z,C,E,T),m.wireframe?Mb(R,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(R);else if(m instanceof -THREE.MeshDepthMaterial)Ja=j.near,Fa=j.far,$.r=$.g=$.b=1-ac(a.positionScreen.z,Ja,Fa),U.r=U.g=U.b=1-ac(d.positionScreen.z,Ja,Fa),aa.r=aa.g=aa.b=1-ac(g.positionScreen.z,Ja,Fa),ga.r=ga.g=ga.b=1-ac(e.positionScreen.z,Ja,Fa),pa=Dc($,U,aa,ga),v(Q,I,y,l,E,T),gc(Q,I,y,l,E,T,0,0,1,0,0,1,pa),v(M,ba,Z,C,ja,ha),gc(M,ba,Z,C,ja,ha,1,0,1,1,0,1,pa)}function v(a,b,c,d,e,g){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,g);m.lineTo(a,b);m.closePath()}function w(a,b,c,d,e,g,f,Y){m.beginPath();m.moveTo(a,b);m.lineTo(c, -d);m.lineTo(e,g);m.lineTo(f,Y);m.lineTo(a,b);m.closePath()}function Mb(a,b,c,e){if(B!=b)m.lineWidth=B=b;if(F!=c)m.lineCap=F=c;if(z!=e)m.lineJoin=z=e;d(a.getContextStyle());m.stroke();ya.inflate(2*b)}function Gb(a){e(a.getContextStyle());m.fill()}function Vc(a,b,c,d,g,f,Y,h,l,i,n,j,k){if(0!=k.image.width){if(!0==k.needsUpdate||void 0==Sa[k.id]){var o=k.wrapS==THREE.RepeatWrapping,db=k.wrapT==THREE.RepeatWrapping;Sa[k.id]=m.createPattern(k.image,o&&db?"repeat":o&&!db?"repeat-x":!o&&db?"repeat-y":"no-repeat"); -k.needsUpdate=!1}e(Sa[k.id]);var o=k.offset.x/k.repeat.x,db=k.offset.y/k.repeat.y,Fb=k.image.width*k.repeat.x,p=k.image.height*k.repeat.y,Y=(Y+o)*Fb,h=(h+db)*p,c=c-a,d=d-b,g=g-a,f=f-b,l=(l+o)*Fb-Y,i=(i+db)*p-h,n=(n+o)*Fb-Y,j=(j+db)*p-h,o=l*j-n*i;if(0==o){if(void 0===Ia[k.id])b=document.createElement("canvas"),b.width=k.image.width,b.height=k.image.height,b=b.getContext("2d"),b.drawImage(k.image,0,0),Ia[k.id]=b.getImageData(0,0,k.image.width,k.image.height).data;b=Ia[k.id];Y=4*(Math.floor(Y)+Math.floor(h)* -k.image.width);R.setRGB(b[Y]/255,b[Y+1]/255,b[Y+2]/255);Gb(R)}else o=1/o,k=(j*c-i*g)*o,i=(j*d-i*f)*o,c=(l*g-n*c)*o,d=(l*f-n*d)*o,a=a-k*Y-c*h,Y=b-i*Y-d*h,m.save(),m.transform(k,i,c,d,a,Y),m.fill(),m.restore()}}function gc(a,b,c,d,e,g,f,Y,h,l,i,n,k){var j,o;j=k.width-1;o=k.height-1;f*=j;Y*=o;c-=a;d-=b;e-=a;g-=b;h=h*j-f;l=l*o-Y;i=i*j-f;n=n*o-Y;o=1/(h*n-i*l);j=(n*c-l*e)*o;l=(n*d-l*g)*o;c=(h*e-i*c)*o;d=(h*g-i*d)*o;a=a-j*f-c*Y;b=b-l*f-d*Y;m.save();m.transform(j,l,c,d,a,b);m.clip();m.drawImage(k,0,0);m.restore()} -function Dc(a,b,c,d){var e=~~(255*a.r),g=~~(255*a.g),a=~~(255*a.b),f=~~(255*b.r),Y=~~(255*b.g),b=~~(255*b.b),h=~~(255*c.r),l=~~(255*c.g),c=~~(255*c.b),i=~~(255*d.r),n=~~(255*d.g),d=~~(255*d.b);eb[0]=0>e?0:255g?0:255a?0:255f?0:255Y?0:255b?0:255h?0:255l?0:255c?0:255i?0:255n?0:255d?0:255a?0:1=n||(n*=f.intensity,d.r+=h.r*n,d.g+=h.g*n,d.b+=h.b*n)):f instanceof THREE.PointLight&&(i=f.matrixWorld.getPosition(),n=c.dot(D.sub(i,b).normalize()),0>=n||(n*=0==f.distance?1:1-Math.min(b.distanceTo(i)/f.distance,1),0!=n&&(n*=f.intensity,d.r+=h.r*n,d.g+=h.g*n,d.b+=h.b*n)))}function b(a){null==H[a]&&(H[a]=document.createElementNS("http://www.w3.org/2000/svg", -"path"),0==Q&&H[a].setAttribute("shape-rendering","crispEdges"));return H[a]}function c(a){a=0.5*(a+1);return 0>a?0:1s&&n.clearRect(Math.floor(sa.getX()),Math.floor(sa.getY()),Math.floor(sa.getWidth()),Math.floor(sa.getHeight())),0=i||(i*=f.intensity,d.r+=h.r*i,d.g+=h.g*i,d.b+=h.b*i)):f instanceof THREE.PointLight&&(l=f.matrixWorld.getPosition(),i=c.dot(Y.sub(l,b).normalize()),0>=i||(i*=0==f.distance?1:1-Math.min(b.distanceTo(l)/f.distance,1),0!=i&&(i*=f.intensity,d.r+=h.r*i,d.g+=h.g*i,d.b+=h.b*i)))}function r(a,g,f){b(f.opacity);c(f.blending);var Y,h,l,i,j,k;if(f instanceof THREE.ParticleBasicMaterial){if(f.map)i= +f.map.image,j=i.width>>1,k=i.height>>1,f=g.scale.x*m,l=g.scale.y*q,Y=f*j,h=l*k,za.set(a.x-Y,a.y-h,a.x+Y,a.y+h),La.intersects(za)&&(n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(f,-l),n.translate(-j,-k),n.drawImage(i,0,0),n.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(Y=g.scale.x*m,h=g.scale.y*q,za.set(a.x-Y,a.y-h,a.x+Y,a.y+h),La.intersects(za)&&(d(f.color.getContextStyle()),e(f.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(Y,h),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(B!=a)n.lineWidth=B=a;a=f.linecap;if(F!=a)n.lineCap=F=a;a=f.linejoin;if(z!=a)n.lineJoin=z=a;d(f.color.getContextStyle());n.stroke();za.inflate(2*f.linewidth)}}function t(a,d,e,f,h,j,n,m){g.info.render.vertices+=3;g.info.render.faces++;b(m.opacity);c(m.blending); +Q=a.positionScreen.x;I=a.positionScreen.y;y=d.positionScreen.x;l=d.positionScreen.y;Z=e.positionScreen.x;C=e.positionScreen.y;v(Q,I,y,l,Z,C);if(m instanceof THREE.MeshBasicMaterial)if(m.map)m.map.mapping instanceof THREE.UVMapping&&(fa=n.uvs[0],Vc(Q,I,y,l,Z,C,fa[f].u,fa[f].v,fa[h].u,fa[h].v,fa[j].u,fa[j].v,m.map));else if(m.envMap){if(m.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,Y.copy(n.vertexNormalsWorld[f]),ib=0.5*(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)+0.5,db=0.5* +-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)+0.5,Y.copy(n.vertexNormalsWorld[h]),lb=0.5*(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)+0.5,cb=0.5*-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)+0.5,Y.copy(n.vertexNormalsWorld[j]),Za=0.5*(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)+0.5,Sa=0.5*-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)+0.5,Vc(Q,I,y,l,Z,C,ib,db,lb,cb,Za,Sa,m.envMap)}else m.wireframe?Mb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(m.color);else if(m instanceof THREE.MeshLambertMaterial)m.map&&!m.wireframe&&(m.map.mapping instanceof +THREE.UVMapping&&(fa=n.uvs[0],Vc(Q,I,y,l,Z,C,fa[f].u,fa[f].v,fa[h].u,fa[h].v,fa[j].u,fa[j].v,m.map)),c(THREE.SubtractiveBlending)),Ea?!m.wireframe&&m.shading==THREE.SmoothShading&&3==n.vertexNormalsWorld.length?($.r=U.r=aa.r=Fa.r,$.g=U.g=aa.g=Fa.g,$.b=U.b=aa.b=Fa.b,p(i,n.v1.positionWorld,n.vertexNormalsWorld[0],$),p(i,n.v2.positionWorld,n.vertexNormalsWorld[1],U),p(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)),U.r=Math.max(0,Math.min(m.color.r*U.r,1)),U.g=Math.max(0,Math.min(m.color.g*U.g,1)),U.b=Math.max(0,Math.min(m.color.b*U.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)),ga.r=0.5*(U.r+aa.r),ga.g=0.5*(U.g+aa.g),ga.b=0.5*(U.b+aa.b),qa=Dc($,U,aa,ga),gc(Q,I,y,l,Z,C,0,0,1,0,0,1,qa)):(R.r=Fa.r,R.g=Fa.g,R.b=Fa.b,p(i,n.centroidWorld,n.normalWorld,R),R.r=Math.max(0,Math.min(m.color.r* +R.r,1)),R.g=Math.max(0,Math.min(m.color.g*R.g,1)),R.b=Math.max(0,Math.min(m.color.b*R.b,1)),m.wireframe?Mb(R,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(R)):m.wireframe?Mb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(m.color);else if(m instanceof THREE.MeshDepthMaterial)Ka=k.near,Ga=k.far,$.r=$.g=$.b=1-ac(a.positionScreen.z,Ka,Ga),U.r=U.g=U.b=1-ac(d.positionScreen.z,Ka,Ga),aa.r=aa.g=aa.b=1-ac(e.positionScreen.z,Ka,Ga),ga.r=0.5*(U.r+aa.r),ga.g=0.5*(U.g+ +aa.g),ga.b=0.5*(U.b+aa.b),qa=Dc($,U,aa,ga),gc(Q,I,y,l,Z,C,0,0,1,0,0,1,qa);else if(m instanceof THREE.MeshNormalMaterial)R.r=hc(n.normalWorld.x),R.g=hc(n.normalWorld.y),R.b=hc(n.normalWorld.z),m.wireframe?Mb(R,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(R)}function u(a,d,e,f,Y,h,m,j,n){g.info.render.vertices+=4;g.info.render.faces++;b(j.opacity);c(j.blending);if(j.map||j.envMap)t(a,d,f,0,1,3,m,j,n),t(Y,e,h,1,2,3,m,j,n);else if(Q=a.positionScreen.x,I=a.positionScreen.y,y=d.positionScreen.x, +l=d.positionScreen.y,Z=e.positionScreen.x,C=e.positionScreen.y,E=f.positionScreen.x,T=f.positionScreen.y,M=Y.positionScreen.x,ba=Y.positionScreen.y,ja=h.positionScreen.x,ha=h.positionScreen.y,j instanceof THREE.MeshBasicMaterial)w(Q,I,y,l,Z,C,E,T),j.wireframe?Mb(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Gb(j.color);else if(j instanceof THREE.MeshLambertMaterial)Ea?!j.wireframe&&j.shading==THREE.SmoothShading&&4==m.vertexNormalsWorld.length?($.r=U.r=aa.r=ga.r=Fa.r,$.g=U.g= +aa.g=ga.g=Fa.g,$.b=U.b=aa.b=ga.b=Fa.b,p(i,m.v1.positionWorld,m.vertexNormalsWorld[0],$),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],U),p(i,m.v4.positionWorld,m.vertexNormalsWorld[3],aa),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ga),$.r=Math.max(0,Math.min(j.color.r*$.r,1)),$.g=Math.max(0,Math.min(j.color.g*$.g,1)),$.b=Math.max(0,Math.min(j.color.b*$.b,1)),U.r=Math.max(0,Math.min(j.color.r*U.r,1)),U.g=Math.max(0,Math.min(j.color.g*U.g,1)),U.b=Math.max(0,Math.min(j.color.b*U.b,1)),aa.r=Math.max(0, +Math.min(j.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(j.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(j.color.b*aa.b,1)),ga.r=Math.max(0,Math.min(j.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(j.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(j.color.b*ga.b,1)),qa=Dc($,U,aa,ga),v(Q,I,y,l,E,T),gc(Q,I,y,l,E,T,0,0,1,0,0,1,qa),v(M,ba,Z,C,ja,ha),gc(M,ba,Z,C,ja,ha,1,0,1,1,0,1,qa)):(R.r=Fa.r,R.g=Fa.g,R.b=Fa.b,p(i,m.centroidWorld,m.normalWorld,R),R.r=Math.max(0,Math.min(j.color.r*R.r,1)),R.g=Math.max(0,Math.min(j.color.g* +R.g,1)),R.b=Math.max(0,Math.min(j.color.b*R.b,1)),w(Q,I,y,l,Z,C,E,T),j.wireframe?Mb(R,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Gb(R)):(w(Q,I,y,l,Z,C,E,T),j.wireframe?Mb(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Gb(j.color));else if(j instanceof THREE.MeshNormalMaterial)R.r=hc(m.normalWorld.x),R.g=hc(m.normalWorld.y),R.b=hc(m.normalWorld.z),w(Q,I,y,l,Z,C,E,T),j.wireframe?Mb(R,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Gb(R);else if(j instanceof +THREE.MeshDepthMaterial)Ka=k.near,Ga=k.far,$.r=$.g=$.b=1-ac(a.positionScreen.z,Ka,Ga),U.r=U.g=U.b=1-ac(d.positionScreen.z,Ka,Ga),aa.r=aa.g=aa.b=1-ac(f.positionScreen.z,Ka,Ga),ga.r=ga.g=ga.b=1-ac(e.positionScreen.z,Ka,Ga),qa=Dc($,U,aa,ga),v(Q,I,y,l,E,T),gc(Q,I,y,l,E,T,0,0,1,0,0,1,qa),v(M,ba,Z,C,ja,ha),gc(M,ba,Z,C,ja,ha,1,0,1,1,0,1,qa)}function v(a,b,c,d,e,f){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(a,b);n.closePath()}function w(a,b,c,d,e,f,g,Y){n.beginPath();n.moveTo(a,b);n.lineTo(c, +d);n.lineTo(e,f);n.lineTo(g,Y);n.lineTo(a,b);n.closePath()}function Mb(a,b,c,e){if(B!=b)n.lineWidth=B=b;if(F!=c)n.lineCap=F=c;if(z!=e)n.lineJoin=z=e;d(a.getContextStyle());n.stroke();za.inflate(2*b)}function Gb(a){e(a.getContextStyle());n.fill()}function Vc(a,b,c,d,f,g,Y,h,l,i,j,m,k){if(0!=k.image.width){if(!0==k.needsUpdate||void 0==Ta[k.id]){var pa=k.wrapS==THREE.RepeatWrapping,o=k.wrapT==THREE.RepeatWrapping;Ta[k.id]=n.createPattern(k.image,pa&&o?"repeat":pa&&!o?"repeat-x":!pa&&o?"repeat-y":"no-repeat"); +k.needsUpdate=!1}e(Ta[k.id]);var pa=k.offset.x/k.repeat.x,o=k.offset.y/k.repeat.y,p=k.image.width*k.repeat.x,Fb=k.image.height*k.repeat.y,Y=(Y+pa)*p,h=(h+o)*Fb,c=c-a,d=d-b,f=f-a,g=g-b,l=(l+pa)*p-Y,i=(i+o)*Fb-h,j=(j+pa)*p-Y,m=(m+o)*Fb-h,pa=l*m-j*i;if(0==pa){if(void 0===Ja[k.id])b=document.createElement("canvas"),b.width=k.image.width,b.height=k.image.height,b=b.getContext("2d"),b.drawImage(k.image,0,0),Ja[k.id]=b.getImageData(0,0,k.image.width,k.image.height).data;b=Ja[k.id];Y=4*(Math.floor(Y)+Math.floor(h)* +k.image.width);R.setRGB(b[Y]/255,b[Y+1]/255,b[Y+2]/255);Gb(R)}else pa=1/pa,k=(m*c-i*f)*pa,i=(m*d-i*g)*pa,c=(l*f-j*c)*pa,d=(l*g-j*d)*pa,a=a-k*Y-c*h,Y=b-i*Y-d*h,n.save(),n.transform(k,i,c,d,a,Y),n.fill(),n.restore()}}function gc(a,b,c,d,e,f,g,Y,h,l,i,j,m){var k,pa;k=m.width-1;pa=m.height-1;g*=k;Y*=pa;c-=a;d-=b;e-=a;f-=b;h=h*k-g;l=l*pa-Y;i=i*k-g;j=j*pa-Y;pa=1/(h*j-i*l);k=(j*c-l*e)*pa;l=(j*d-l*f)*pa;c=(h*e-i*c)*pa;d=(h*f-i*d)*pa;a=a-k*g-c*Y;b=b-l*g-d*Y;n.save();n.transform(k,l,c,d,a,b);n.clip();n.drawImage(m, +0,0);n.restore()}function Dc(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),Y=~~(255*b.g),b=~~(255*b.b),h=~~(255*c.r),l=~~(255*c.g),c=~~(255*c.b),i=~~(255*d.r),j=~~(255*d.g),d=~~(255*d.b);eb[0]=0>e?0:255f?0:255a?0:255g?0:255Y?0:255b?0:255h?0:255l?0:255c?0:255i?0:255j?0:255d?0:255a?0:1=j||(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),j=c.dot(D.sub(i,b).normalize()),0>=j||(j*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=j&&(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)))}function b(a){null==H[a]&&(H[a]=document.createElementNS("http://www.w3.org/2000/svg", +"path"),0==Q&&H[a].setAttribute("shape-rendering","crispEdges"));return H[a]}function c(a){a=0.5*(a+1);return 0>a?0:1 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif", -lights_lambert_vertex:"vLightWeighting = vec3( 0.0 );\ntransformedNormal = normalize( transformedNormal );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\n#ifdef WRAP_AROUND\nfloat directionalLightWeightingFull = max( dot( transformedNormal, dirVector ), 0.0 );\nfloat directionalLightWeightingHalf = max( 0.5 * dot( transformedNormal, dirVector ) + 0.5, 0.0 );\nvec3 directionalLightWeighting = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );\n#else\nfloat directionalLightWeighting = max( dot( transformedNormal, dirVector ), 0.0 );\n#endif\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#ifdef WRAP_AROUND\nfloat pointLightWeightingFull = max( dot( transformedNormal, lVector ), 0.0 );\nfloat pointLightWeightingHalf = max( 0.5 * dot( transformedNormal, lVector ) + 0.5, 0.0 );\nvec3 pointLightWeighting = mix( vec3 ( pointLightWeightingFull ), vec3( pointLightWeightingHalf ), wrapRGB );\n#else\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\n#endif\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n}\n#endif\nvLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;", +lights_lambert_vertex:"vLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\nvLightBack = vec3( 0.0 );\n#endif\ntransformedNormal = normalize( transformedNormal );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( transformedNormal, dirVector );\nvec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\ndirectionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\ndirectionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += directionalLightColor[ i ] * directionalLightWeighting;\n#ifdef DOUBLE_SIDED\nvLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;\n#endif\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat dotProduct = dot( transformedNormal, lVector );\nvec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\npointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\npointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;\n#ifdef DOUBLE_SIDED\nvLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;\n#endif\n}\n#endif\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor;\n#ifdef DOUBLE_SIDED\nvLightBack = vLightBack * diffuse + ambient * ambientLightColor;\n#endif", lights_phong_pars_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif",lights_phong_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#endif", lights_phong_pars_fragment:"uniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n#ifdef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#else\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;", -lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vPointLight[ i ].xyz );\nfloat lDistance = vPointLight[ i ].w;\n#endif\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dot( normal, lVector ), 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, lVector ) + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dot( normal, lVector ), 0.0 );\n#endif\npointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = max( pow( pointDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#endif\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\n#ifdef WRAP_AROUND\nfloat dirDiffuseWeightFull = max( dot( normal, dirVector ), 0.0 );\nfloat dirDiffuseWeightHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\n#endif\ndirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = max( pow( dirDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif", +lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#ifdef DOUBLE_SIDED\nnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n#endif\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vPointLight[ i ].xyz );\nfloat lDistance = vPointLight[ i ].w;\n#endif\nfloat dotProduct = dot( normal, lVector );\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dotProduct, 0.0 );\n#endif\npointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = max( pow( pointDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#endif\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( normal, dirVector );\n#ifdef WRAP_AROUND\nfloat dirDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dotProduct, 0.0 );\n#endif\ndirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = max( pow( dirDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n#ifdef GAMMA_INPUT\nvColor = color * color;\n#else\nvColor = color;\n#endif\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * modelViewMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[ 8 ];\n#else\nuniform float morphTargetInfluences[ 4 ];\n#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n#ifndef USE_MORPHNORMALS\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n#endif\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif", default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\nvec3 morphedNormal = vec3( 0.0 );\nmorphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\nmorphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\nmorphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\nmorphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\nmorphedNormal += normal;\nvec3 transformedNormal = normalMatrix * morphedNormal;\n#else\nvec3 transformedNormal = normalMatrix * normal;\n#endif", @@ -229,139 +230,140 @@ THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value: value:1}},vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}",fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}"},basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.shadowmap]),vertexShader:[THREE.ShaderChunk.map_pars_vertex, THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex, THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment, -THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["varying vec3 vLightWeighting;", +THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["varying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif", THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_lambert_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex, -THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment, -"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,"gl_FragColor.xyz = gl_FragColor.xyz * vLightWeighting;",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog, -THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["varying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_phong_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex, -THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = -mvPosition.xyz;",THREE.ShaderChunk.morphnormal_vertex,"vNormal = transformedNormal;",THREE.ShaderChunk.lights_phong_vertex, -THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_phong_pars_fragment, -THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle, -THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;", -THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", -THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}}; -THREE.WebGLRenderer=function(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(void 0===a.__webglCustomAttributesList)a.__webglCustomAttributesList=[];for(var e in d.attributes){var f=d.attributes[e];if(!f.__webglInitialized||f.createUniqueBuffers){f.__webglInitialized=!0;var g=1;"v2"===f.type?g=2:"v3"===f.type?g=3:"v4"===f.type?g=4:"c"===f.type&&(g=3);f.size=g;f.array=new Float32Array(c*g);f.buffer=l.createBuffer();f.buffer.belongsToAttribute=e;f.needsUpdate=!0}a.__webglCustomAttributesList.push(f)}}} -function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(0<=b.materialIndex)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?!0:!1}function f(a,b,c){var d,e,f,g,h=a.vertices;g=h.length; -var i=a.colors,n=i.length,m=a.__vertexArray,k=a.__colorArray,j=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,q=a.__webglCustomAttributesList;if(c.sortParticles){Ya.multiplySelf(c.matrixWorld);for(d=0;dk;k++){j=m;r=k;if(y.autoScaleCubemaps){if(s=h.image[k],E=Da,!(s.width<=E&&s.height<=E))u=Math.max(s.width, -s.height),t=Math.floor(s.width*E/u),E=Math.floor(s.height*E/u),u=document.createElement("canvas"),u.width=t,u.height=E,u.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,E),s=u}else s=h.image[k];j[r]=s}k=m[0];j=0===(k.width&k.width-1)&&0===(k.height&k.height-1);r=B(h.format);s=B(h.type);w(l.TEXTURE_CUBE_MAP,h,j);for(k=0;6>k;k++)l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,r,r,s,m[k]);h.generateMipmaps&&j&&l.generateMipmap(l.TEXTURE_CUBE_MAP);h.needsUpdate=!1;if(h.onUpdated)h.onUpdated()}else l.activeTexture(l.TEXTURE0+ -m),l.bindTexture(l.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}else k instanceof THREE.WebGLRenderTargetCube?(h=k,l.activeTexture(l.TEXTURE0+m),l.bindTexture(l.TEXTURE_CUBE_MAP,h.__webglTexture)):y.setTexture(k,m)}else if("tv"===j){if(!h._array){h._array=[];for(j=0,r=h.texture.length;jk;k++){n=m;r=k;if(y.autoScaleCubemaps){if(s=h.image[k],E=Ea,!(s.width<=E&&s.height<=E))u=Math.max(s.width, +s.height),t=Math.floor(s.width*E/u),E=Math.floor(s.height*E/u),u=document.createElement("canvas"),u.width=t,u.height=E,u.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,E),s=u}else s=h.image[k];n[r]=s}k=m[0];n=0===(k.width&k.width-1)&&0===(k.height&k.height-1);r=B(h.format);s=B(h.type);w(l.TEXTURE_CUBE_MAP,h,n);for(k=0;6>k;k++)l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,r,r,s,m[k]);h.generateMipmaps&&n&&l.generateMipmap(l.TEXTURE_CUBE_MAP);h.needsUpdate=!1;if(h.onUpdated)h.onUpdated()}else l.activeTexture(l.TEXTURE0+ +m),l.bindTexture(l.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}else k instanceof THREE.WebGLRenderTargetCube?(h=k,l.activeTexture(l.TEXTURE0+m),l.bindTexture(l.TEXTURE_CUBE_MAP,h.__webglTexture)):y.setTexture(k,m)}else if("tv"===n){if(!h._array){h._array=[];for(n=0,r=h.texture.length;nj&&(n=k,j=h[n]);l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[n]);l.vertexAttribPointer(c["morphTarget"+g],3,l.FLOAT,!1,0,0);d.morphNormals&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[n]),l.vertexAttribPointer(c["morphNormal"+ -g],3,l.FLOAT,!1,0,0));f.__webglMorphTargetInfluences[g]=j;i[n]=1;j=-1;g++}}null!==d.program.uniforms.morphTargetInfluences&&l.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(g=0,h=e.__webglCustomAttributesList.length;gj&&(m=k,j=h[m]);l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[m]);l.vertexAttribPointer(c["morphTarget"+f],3,l.FLOAT,!1,0,0);d.morphNormals&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[m]),l.vertexAttribPointer(c["morphNormal"+ +f],3,l.FLOAT,!1,0,0));g.__webglMorphTargetInfluences[f]=j;i[m]=1;j=-1;f++}}null!==d.program.uniforms.morphTargetInfluences&&l.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(f=0,h=e.__webglCustomAttributesList.length;fka;ka++)Vb=jc[ka],hb[Qa]=Vb.x,hb[Qa+1]=Vb.y,hb[Qa+2]=Vb.z,Qa+=3;else for(ka=0;3>ka;ka++)hb[Qa]=Ob.x,hb[Qa+1]=Ob.y,hb[Qa+2]=Ob.z,Qa+=3;for(G=0,S=ma.length;Gka;ka++)Vb=jc[ka],hb[Qa]=Vb.x,hb[Qa+1]=Vb.y,hb[Qa+2]=Vb.z,Qa+=3;else for(ka=0;4>ka;ka++)hb[Qa]= -Ob.x,hb[Qa+1]=Ob.y,hb[Qa+2]=Ob.z,Qa+=3;l.bindBuffer(l.ARRAY_BUFFER,da.__webglNormalBuffer);l.bufferData(l.ARRAY_BUFFER,hb,Za)}if(kd&&bd&&hd){for(G=0,S=la.length;Gka;ka++)mc=kc[ka],wc[Jb]=mc.u,wc[Jb+1]=mc.v,Jb+=2;for(G=0,S=ma.length;Gka;ka++)mc=kc[ka],wc[Jb]=mc.u,wc[Jb+1]=mc.v,Jb+=2;0ka;ka++)nc=lc[ka],xc[Kb]=nc.u,xc[Kb+1]=nc.v,Kb+=2;for(G=0,S=ma.length;Gka;ka++)nc=lc[ka],xc[Kb]=nc.u,xc[Kb+1]=nc.v,Kb+=2;0ka;ka++)Vb=jc[ka],hb[Ra]=Vb.x,hb[Ra+1]=Vb.y,hb[Ra+2]=Vb.z,Ra+=3;else for(ka=0;3>ka;ka++)hb[Ra]=Ob.x,hb[Ra+1]=Ob.y,hb[Ra+2]=Ob.z,Ra+=3;for(G=0,S=ma.length;Gka;ka++)Vb=jc[ka],hb[Ra]=Vb.x,hb[Ra+1]=Vb.y,hb[Ra+2]=Vb.z,Ra+=3;else for(ka=0;4>ka;ka++)hb[Ra]= +Ob.x,hb[Ra+1]=Ob.y,hb[Ra+2]=Ob.z,Ra+=3;l.bindBuffer(l.ARRAY_BUFFER,da.__webglNormalBuffer);l.bufferData(l.ARRAY_BUFFER,hb,$a)}if(kd&&bd&&hd){for(G=0,S=la.length;Gka;ka++)mc=kc[ka],wc[Jb]=mc.u,wc[Jb+1]=mc.v,Jb+=2;for(G=0,S=ma.length;Gka;ka++)mc=kc[ka],wc[Jb]=mc.u,wc[Jb+1]=mc.v,Jb+=2;0ka;ka++)nc=lc[ka],xc[Kb]=nc.u,xc[Kb+1]=nc.v,Kb+=2;for(G=0,S=ma.length;Gka;ka++)nc=lc[ka],xc[Kb]=nc.u,xc[Kb+1]=nc.v,Kb+=2;0c;c++){a.__webglFramebuffer[c]=l.createFramebuffer();a.__webglRenderbuffer[c]=l.createRenderbuffer();l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+ -c,0,d,a.width,a.height,0,d,e,null);var f=a,g=l.TEXTURE_CUBE_MAP_POSITIVE_X+c;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[c]);l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,g,f.__webglTexture,0);u(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=l.createFramebuffer(),a.__webglRenderbuffer=l.createRenderbuffer(),l.bindTexture(l.TEXTURE_2D,a.__webglTexture),w(l.TEXTURE_2D,a,c),l.texImage2D(l.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=l.TEXTURE_2D,l.bindFramebuffer(l.FRAMEBUFFER, -a.__webglFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,d,a.__webglTexture,0),u(a.__webglRenderbuffer,a);b?l.bindTexture(l.TEXTURE_CUBE_MAP,null):l.bindTexture(l.TEXTURE_2D,null);l.bindRenderbuffer(l.RENDERBUFFER,null);l.bindFramebuffer(l.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=fa,a=ib,e=Fa,c=pa);b!==E&&(l.bindFramebuffer(l.FRAMEBUFFER,b),l.viewport(e,c,d,a),E=b);cb=d;lb=a};this.shadowMapPlugin= -new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; +"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");l.attachShader(q,t("fragment",e+m)); +l.attachShader(q,t("vertex",d+k));l.linkProgram(q);l.getProgramParameter(q,l.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+l.getProgramParameter(q,l.VALIDATE_STATUS)+", gl error ["+l.getError()+"]");q.uniforms={};q.attributes={};var r,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,boneGlobalMatrices,morphTargetInfluences".split(",");for(r in j)d.push(r);r=d;for(d=0,j=r.length;dc;c++){a.__webglFramebuffer[c]=l.createFramebuffer(); +a.__webglRenderbuffer[c]=l.createRenderbuffer();l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,0,d,e,null);var g=a,f=l.TEXTURE_CUBE_MAP_POSITIVE_X+c;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[c]);l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,f,g.__webglTexture,0);u(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=l.createFramebuffer(),a.__webglRenderbuffer=l.createRenderbuffer(),l.bindTexture(l.TEXTURE_2D,a.__webglTexture),w(l.TEXTURE_2D,a,c),l.texImage2D(l.TEXTURE_2D, +0,d,a.width,a.height,0,d,e,null),d=l.TEXTURE_2D,l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,d,a.__webglTexture,0),u(a.__webglRenderbuffer,a);b?l.bindTexture(l.TEXTURE_CUBE_MAP,null):l.bindTexture(l.TEXTURE_2D,null);l.bindRenderbuffer(l.RENDERBUFFER,null);l.bindFramebuffer(l.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=fa,a=ib,e=Ga,c=qa);b!==E&&(l.bindFramebuffer(l.FRAMEBUFFER, +b),l.viewport(e,c,d,a),E=b);db=d;lb=a};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=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format:THREE.RGBAFormat;this.type=void 0!==c.type?c.type: THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!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}; @@ -369,28 +371,28 @@ THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRen THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null}; THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null}; THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.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,f=Math.max(Math.max(c,d),e),g=Math.min(Math.min(c,d),e);if(g===f)g=c=0;else{var h=f-g,g=h/f,c=(c===f?(d-e)/h:d===f?2+(e-c)/h:4+(c-d)/h)/6;0>c&&(c+=1);1c&&(c+=1);1a?b(c,e-1):k[e]b||n>b||p>b){h=a.vertices.length;t=d.clone();d=d.clone();o>=n&&o>=p?(i=i.clone(),i.position.lerpSelf(k.position,0.5),t.a=e,t.b=h,t.c=g,d.a=h,d.b=f,d.c=g,e= -0):n>=o&&n>=p?(i=k.clone(),i.position.lerpSelf(j.position,0.5),t.a=e,t.b=f,t.c=h,d.a=h,d.b=g,d.c=e,e=1):(i=i.clone(),i.position.lerpSelf(j.position,0.5),t.a=e,t.b=f,t.c=h,d.a=h,d.b=f,d.c=g,e=2);a.faces.splice(c,1,t,d);a.vertices.push(i);for(f=0;fb||n>b||q>b||m>b){r=a.vertices.length;s=a.vertices.length+1;t=d.clone(); -d=d.clone();o>=n&&o>=q&&o>=m||q>=n&&q>=o&&q>=m?(o=i.clone(),o.position.lerpSelf(k.position,0.5),k=j.clone(),k.position.lerpSelf(p.position,0.5),t.a=e,t.b=r,t.c=s,t.d=h,d.a=r,d.b=f,d.c=g,d.d=s,e=0):(o=k.clone(),o.position.lerpSelf(j.position,0.5),k=p.clone(),k.position.lerpSelf(i.position,0.5),t.a=e,t.b=f,t.c=r,t.d=s,d.a=s,d.b=r,d.c=g,d.d=h,e=1);a.faces.splice(c,1,t,d);a.vertices.push(o);a.vertices.push(k);for(f=0;fp-1?e-1:p-1,n=(p+1)%e,q=0>j-1?d-1:j-1,m=(j+1)%d,r=[],s=[0,0,h[4*(p*d+j)]/255*b];r.push([-1,0,h[4*(p*d+q)]/255*b]);r.push([-1,-1,h[4*(o*d+q)]/255*b]);r.push([0,-1, -h[4*(o*d+j)]/255*b]);r.push([1,-1,h[4*(o*d+m)]/255*b]);r.push([1,0,h[4*(p*d+m)]/255*b]);r.push([1,1,h[4*(n*d+m)]/255*b]);r.push([0,1,h[4*(n*d+j)]/255*b]);r.push([-1,1,h[4*(n*d+q)]/255*b]);o=[];q=r.length;for(n=0;na?b(c,e-1):j[e]b||m>b||p>b){h=a.vertices.length;t=d.clone();d=d.clone();o>=m&&o>=p?(i=i.clone(),i.position.lerpSelf(j.position,0.5),t.a=e,t.b=h,t.c=f,d.a=h,d.b=g,d.c=f,e= +0):m>=o&&m>=p?(i=j.clone(),i.position.lerpSelf(k.position,0.5),t.a=e,t.b=g,t.c=h,d.a=h,d.b=f,d.c=e,e=1):(i=i.clone(),i.position.lerpSelf(k.position,0.5),t.a=e,t.b=g,t.c=h,d.a=h,d.b=g,d.c=f,e=2);a.faces.splice(c,1,t,d);a.vertices.push(i);for(g=0;gb||m>b||q>b||n>b){r=a.vertices.length;s=a.vertices.length+1;t=d.clone(); +d=d.clone();o>=m&&o>=q&&o>=n||q>=m&&q>=o&&q>=n?(o=i.clone(),o.position.lerpSelf(j.position,0.5),j=k.clone(),j.position.lerpSelf(p.position,0.5),t.a=e,t.b=r,t.c=s,t.d=h,d.a=r,d.b=g,d.c=f,d.d=s,e=0):(o=j.clone(),o.position.lerpSelf(k.position,0.5),j=p.clone(),j.position.lerpSelf(i.position,0.5),t.a=e,t.b=g,t.c=r,t.d=s,d.a=s,d.b=r,d.c=f,d.d=h,e=1);a.faces.splice(c,1,t,d);a.vertices.push(o);a.vertices.push(j);for(g=0;gp-1?e-1:p-1,m=(p+1)%e,q=0>k-1?d-1:k-1,n=(k+1)%d,r=[],s=[0,0,h[4*(p*d+k)]/255*b];r.push([-1,0,h[4*(p*d+q)]/255*b]);r.push([-1,-1,h[4*(o*d+q)]/255*b]);r.push([0,-1, +h[4*(o*d+k)]/255*b]);r.push([1,-1,h[4*(o*d+n)]/255*b]);r.push([1,0,h[4*(p*d+n)]/255*b]);r.push([1,1,h[4*(m*d+n)]/255*b]);r.push([0,1,h[4*(m*d+k)]/255*b]);r.push([-1,1,h[4*(m*d+q)]/255*b]);o=[];q=r.length;for(m=0;mi)g=d+1;else if(0i)f=d+1;else if(0b&&(b=0);1d.length-2?a:a+1;c[3]=a>d.length-3?a:a+2;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,e);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,e);return b};THREE.ArcCurve=function(a,b,c,d,e,f){this.aX=a;this.aY=b;this.aRadius=c;this.aStartAngle=d;this.aEndAngle=e;this.aClockwise=f}; +THREE.SplineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2,c=[],d=this.points,e;e=(d.length-1)*a;a=Math.floor(e);e-=a;c[0]=0==a?a:a-1;c[1]=a;c[2]=a>d.length-2?a:a+1;c[3]=a>d.length-3?a:a+2;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,e);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,e);return b};THREE.ArcCurve=function(a,b,c,d,e,g){this.aX=a;this.aY=b;this.aRadius=c;this.aStartAngle=d;this.aEndAngle=e;this.aClockwise=g}; THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);b=this.aStartAngle+a*b;a=this.aX+this.aRadius*Math.cos(b);b=this.aY+this.aRadius*Math.sin(b);return new THREE.Vector2(a,b)}; -THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,e){var a=0.5*(c-a),d=0.5*(d-b),f=e*e;return(2*b-2*c+a+d)*e*f+(-3*b+3*c-2*a-d)*f+a*e+b}}; +THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,e){var a=0.5*(c-a),d=0.5*(d-b),g=e*e;return(2*b-2*c+a+d)*e*g+(-3*b+3*c-2*a-d)*g+a*e+b}}; THREE.Curve.create=function(a,b){a.prototype=new THREE.Curve;a.prototype.constructor=a;a.prototype.getPoint=b;return a};THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.sub(this.v2,this.v1);b.multiplyScalar(a);b.addSelf(this.v1);return b}); THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b,c;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);c=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(b,c,a)}); THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b,c;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);c=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(b,c,a)}); @@ -426,66 +428,66 @@ THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},fu THREE.CurvePath=function(){this.curves=[];this.bends=[];this.autoClose=!1};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))}; THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),a=0;a=b)return b=c[a]-b,a=this.curves[a],b=1-b/a.getLength(),a.getPointAt(b);a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]}; THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],b=0,c,d=this.curves.length;for(c=0;cb)b=f.x;else if(f.xc)c=f.y;else if(f.yb)b=g.x;else if(g.xc)c=g.y;else if(g.y -h&&(h+=c.length);h%=c.length;0>g&&(g+=k.length);g%=k.length;e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:k.length-1;m=[k[g],c[h],c[e]];m=THREE.FontUtils.Triangulate.area(m);r=[k[g],k[f],c[h]];r=THREE.FontUtils.Triangulate.area(r);p+o>m+r&&(h=n,g=j,0>h&&(h+=c.length),h%=c.length,0>g&&(g+=k.length),g%=k.length,e=0<=h-1?h-1:c.length-1,f=0<=g-1?g-1:k.length-1);p=c.slice(0,h);o=c.slice(h);n=k.slice(g);j=k.slice(0,g);f=[k[g],k[f],c[h]];q.push([k[g],c[h],c[e]]);q.push(f);c=p.concat(n).concat(j).concat(o)}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),f,g,h,i,k={};for(f=0,g=d.length;fd;d++)i=h[d].x+":"+h[d].y,i=k[i],void 0!==i&&(h[d]=i)}for(f=0,g=e.length;fd;d++)i=h[d].x+":"+h[d].y,i=k[i],void 0!==i&&(h[d]=i)}return c.concat(e)}, +THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,g,f,h,i,j,k,p,o,m,q=[];for(i=0;i +h&&(h+=c.length);h%=c.length;0>f&&(f+=j.length);f%=j.length;e=0<=h-1?h-1:c.length-1;g=0<=f-1?f-1:j.length-1;n=[j[f],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);r=[j[f],j[g],c[h]];r=THREE.FontUtils.Triangulate.area(r);p+o>n+r&&(h=m,f=k,0>h&&(h+=c.length),h%=c.length,0>f&&(f+=j.length),f%=j.length,e=0<=h-1?h-1:c.length-1,g=0<=f-1?f-1:j.length-1);p=c.slice(0,h);o=c.slice(h);m=j.slice(f);k=j.slice(0,f);g=[j[f],j[g],c[h]];q.push([j[f],c[h],c[e]]);q.push(g);c=p.concat(m).concat(k).concat(o)}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,j={};for(g=0,f=d.length;gd;d++)i=h[d].x+":"+h[d].y,i=j[i],void 0!==i&&(h[d]=i)}for(g=0,f=e.length;gd;d++)i=h[d].x+":"+h[d].y,i=j[i],void 0!==i&&(h[d]=i)}return c.concat(e)}, isClockWise:function(a){return 0>THREE.FontUtils.Triangulate.area(a)},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+ -this.b3p3(a,e)}};THREE.TextPath=function(a,b){THREE.Path.call(this);this.parameters=b||{};this.set(a)};THREE.TextPath.prototype.set=function(a,b){b=b||this.parameters;this.text=a;var c=void 0!==b.curveSegments?b.curveSegments:4,d=void 0!==b.font?b.font:"helvetiker",e=void 0!==b.weight?b.weight:"normal",f=void 0!==b.style?b.style:"normal";THREE.FontUtils.size=void 0!==b.size?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=e;THREE.FontUtils.style=f}; +this.b3p3(a,e)}};THREE.TextPath=function(a,b){THREE.Path.call(this);this.parameters=b||{};this.set(a)};THREE.TextPath.prototype.set=function(a,b){b=b||this.parameters;this.text=a;var c=void 0!==b.curveSegments?b.curveSegments:4,d=void 0!==b.font?b.font:"helvetiker",e=void 0!==b.weight?b.weight:"normal",g=void 0!==b.style?b.style:"normal";THREE.FontUtils.size=void 0!==b.size?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=e;THREE.FontUtils.style=g}; THREE.TextPath.prototype.toShapes=function(){for(var a=THREE.FontUtils.drawText(this.text).paths,b=[],c=0,d=a.length;ca.hierarchy[c].keys[d].time)a.hierarchy[c].keys[d].time= -0;if(void 0!==a.hierarchy[c].keys[d].rot&&!(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)){var h=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(a.hierarchy[c].keys.length&&void 0!==a.hierarchy[c].keys[0].morphTargets){h={};for(d=0;dm;m++){c=b[m];g=i.prevKey[c];h=i.nextKey[c];if(h.time<=o){if(pd||1d?0:1;if("pos"===c)if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[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,g.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos,d=0.33*d+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,1.01*d),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("rot"=== -c)THREE.Quaternion.slerp(e,f,a.quaternion,d);else if("scl"===c)c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d}}if(this.JITCompile&&void 0===j[0][k]){this.hierarchy[0].updateMatrixWorld(!0);for(n=0;na.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];k=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],k[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],k[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],k[2],e,c,g);return d}; -THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?cn;n++){c=b[n];f=i.prevKey[c];h=i.nextKey[c];if(h.time<=o){if(pd||1d?0:1;if("pos"===c)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=0.33*d+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,1.01*d),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("rot"=== +c)THREE.Quaternion.slerp(e,g,a.quaternion,d);else if("scl"===c)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&&void 0===k[0][j]){this.hierarchy[0].updateMatrixWorld(!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]];j=a[c[3]];c=e*e;f=e*c;d[0]=this.interpolate(g[0],h[0],i[0],j[0],e,c,f);d[1]=this.interpolate(g[1],h[1],i[1],j[1],e,c,f);d[2]=this.interpolate(g[2],h[2],i[2],j[2],e,c,f);return d}; +THREE.Animation.prototype.interpolate=function(a,b,c,d,e,g,f){a=0.5*(c-a);d=0.5*(d-b);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){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&void 0===f[0][e]){this.hierarchy[0].updateMatrixWorld(!0);for(a=0;a=f?b.interpolate(c,f):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&void 0===g[0][e]){this.hierarchy[0].updateMatrixWorld(!0);for(a=0;a(a*=2)?0.5*a*a:-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(),r=g.length,s=0;f=r-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(a*=2)?0.5*a*a:-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:[]},g,f=b.getControlPointsArray(),h=b.getLength(),r=f.length,s=0;g=r-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[g]={time:d,pos:f[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;gi)?1:i));this.object.translateX(b*k);this.object.translateY(b*j);g&&(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.yi)?1:i));this.object.translateX(b*j);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.yc.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),g.lengthSq()n;n++)this.materials.push(g)}n=0;r=1;q=2;s= -3;m=4;t=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(void 0!=h)for(var w in h)void 0!==this.sides[w]&&(this.sides[w]=h[w]);this.sides.px&&i("z","y",-1,-1,c,b,j,n);this.sides.nx&&i("z","y",1,-1,c,b,-j,r);this.sides.py&&i("x","z",1,1,a,c,p,q);this.sides.ny&&i("x","z",1,-1,a,c,-p,s);this.sides.pz&&i("x","y",1,-1,a,b,o,m);this.sides.nz&&i("x","y",-1,-1,a,b,-o,t);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry; +new THREE.Vector3;var d=new THREE.Vector3,e=!1,g=-1,f=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector2,k=new THREE.Vector2,p=new THREE.Vector2,o=new THREE.Vector2;this.handleEvent=function(a){if("function"==typeof this[a.type])this[a.type](a)};this.getMouseOnScreen=function(a,b){return new THREE.Vector2(0.5*((a-c.screen.offsetLeft)/c.radius),0.5*((b-c.screen.offsetTop)/c.radius))};this.getMouseProjectionOnBall=function(a,b){var d=new THREE.Vector3((a-0.5*c.screen.width- +c.screen.offsetLeft)/c.radius,(0.5*c.screen.height+c.screen.offsetTop-b)/c.radius,0),e=d.length();1c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),f.lengthSq()m;m++)this.materials.push(f)}m=0;r=1;q=2;s= +3;n=4;t=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(void 0!=h)for(var w in h)void 0!==this.sides[w]&&(this.sides[w]=h[w]);this.sides.px&&i("z","y",-1,-1,c,b,k,m);this.sides.nx&&i("z","y",1,-1,c,b,-k,r);this.sides.py&&i("x","z",1,1,a,c,p,q);this.sides.ny&&i("x","z",1,-1,a,c,-p,s);this.sides.pz&&i("x","y",1,-1,a,b,o,n);this.sides.nz&&i("x","y",-1,-1,a,b,-o,t);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry; THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry; -THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);var a=void 0!==a?a:20,b=void 0!==b?b:20,c=void 0!==c?c:100,g=c/2,d=d||8,e=e||1,h,i,k=[],j=[];for(i=0;i<=e;i++){var p=[],o=[],n=i/e,q=n*(b-a)+a;for(h=0;h<=d;h++){var m=h/d,r=q*Math.sin(2*m*Math.PI),s=-n*c+g,t=q*Math.cos(2*m*Math.PI);this.vertices.push(new THREE.Vertex(new THREE.Vector3(r,s,t)));p.push(this.vertices.length-1);o.push(new THREE.UV(m,n))}k.push(p);j.push(o)}for(i=0;ig?(b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),new THREE.Vector2(a,c)):d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(a){for(y=a.length;0<=--y;){Z=y;C=y-1;0>C&&(C=a.length-1);for(var b= -0,c=n+2*j,b=0;bMath.abs(d-l)? -z.faceVertexUvs[0].push([new THREE.UV(e,f),new THREE.UV(m,g),new THREE.UV(k,h),new THREE.UV(p,i)]):z.faceVertexUvs[0].push([new THREE.UV(d,f),new THREE.UV(l,g),new THREE.UV(o,h),new THREE.UV(q,i)])}}}function f(a,b,c){z.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c){a+=D;b+=D;c+=D;z.faces.push(new THREE.Face3(a,b,c,null,null,w));var d=z.vertices[b].position.x,b=z.vertices[b].position.y,e=z.vertices[c].position.x,c=z.vertices[c].position.y;z.faceVertexUvs[0].push([new THREE.UV(z.vertices[a].position.x, -1-z.vertices[a].position.y),new THREE.UV(d,1-b),new THREE.UV(e,1-c)])}var h=void 0!==b.amount?b.amount:100,i=void 0!==b.bevelThickness?b.bevelThickness:6,k=void 0!==b.bevelSize?b.bevelSize:i-2,j=void 0!==b.bevelSegments?b.bevelSegments:3,p=void 0!==b.bevelEnabled?b.bevelEnabled:!0,o=void 0!==b.curveSegments?b.curveSegments:12,n=void 0!==b.steps?b.steps:1,q=b.bendPath,m=b.extrudePath,r,s=!1,t=void 0!==b.useSpacedPoints?b.useSpacedPoints:!1,w=b.material,u=b.extrudeMaterial;if(m)r=m.getPoints(o),n=r.length, -s=!0,p=!1;p||(k=i=j=0);var v,B,F,z=this,D=this.vertices.length;q&&a.addWrapPath(q);o=t?a.extractAllSpacedPoints(o):a.extractAllPoints(o);q=o.shape;o=o.holes;if(m=!THREE.Shape.Utils.isClockWise(q)){q=q.reverse();for(B=0,F=o.length;Bf?(b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),new THREE.Vector2(a,c)):d.multiplyScalar(f).addSelf(h).subSelf(a).clone()}function e(a){for(y=a.length;0<=--y;){Z=y;C=y-1;0>C&&(C=a.length-1);for(var b= +0,c=m+2*k,b=0;bMath.abs(d-l)? +z.faceVertexUvs[0].push([new THREE.UV(e,g),new THREE.UV(j,f),new THREE.UV(n,h),new THREE.UV(p,i)]):z.faceVertexUvs[0].push([new THREE.UV(d,g),new THREE.UV(l,f),new THREE.UV(o,h),new THREE.UV(q,i)])}}}function g(a,b,c){z.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function f(a,b,c){a+=D;b+=D;c+=D;z.faces.push(new THREE.Face3(a,b,c,null,null,w));var d=z.vertices[b].position.x,b=z.vertices[b].position.y,e=z.vertices[c].position.x,c=z.vertices[c].position.y;z.faceVertexUvs[0].push([new THREE.UV(z.vertices[a].position.x, +1-z.vertices[a].position.y),new THREE.UV(d,1-b),new THREE.UV(e,1-c)])}var h=void 0!==b.amount?b.amount:100,i=void 0!==b.bevelThickness?b.bevelThickness:6,j=void 0!==b.bevelSize?b.bevelSize:i-2,k=void 0!==b.bevelSegments?b.bevelSegments:3,p=void 0!==b.bevelEnabled?b.bevelEnabled:!0,o=void 0!==b.curveSegments?b.curveSegments:12,m=void 0!==b.steps?b.steps:1,q=b.bendPath,n=b.extrudePath,r,s=!1,t=void 0!==b.useSpacedPoints?b.useSpacedPoints:!1,w=b.material,u=b.extrudeMaterial;if(n)r=n.getPoints(o),m=r.length, +s=!0,p=!1;p||(j=i=k=0);var v,B,F,z=this,D=this.vertices.length;q&&a.addWrapPath(q);o=t?a.extractAllSpacedPoints(o):a.extractAllPoints(o);q=o.shape;o=o.holes;if(n=!THREE.Shape.Utils.isClockWise(q)){q=q.reverse();for(B=0,F=o.length;Be)return null;var f=[],g=[],h=[],i,k,j;if(0=p--){console.log("Warning, unable to triangulate polygon!");break}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 n=i,q=k,m=j,r=e,s=g,t=void 0,w=void 0,u=void 0,v=void 0,B=void 0, -F=void 0,z=void 0,D=void 0,H=void 0,w=o[s[n]].x,u=o[s[n]].y,v=o[s[q]].x,B=o[s[q]].y,F=o[s[m]].x,z=o[s[m]].y;if(1.0E-10>(v-w)*(z-u)-(B-u)*(F-w))o=!1;else{for(t=0;te)return null;var g=[],f=[],h=[],i,j,k;if(0=p--){console.log("Warning, unable to triangulate polygon!");break}i=j;e<=i&&(i=0);j=i+1;e<=j&&(j=0);k=j+1;e<=k&&(k=0);var o;a:{o=a;var m=i,q=j,n=k,r=e,s=f,t=void 0,w=void 0,u=void 0,v=void 0,B=void 0, +F=void 0,z=void 0,D=void 0,H=void 0,w=o[s[m]].x,u=o[s[m]].y,v=o[s[q]].x,B=o[s[q]].y,F=o[s[n]].x,z=o[s[n]].y;if(1.0E-10>(v-w)*(z-u)-(B-u)*(F-w))o=!1;else{for(t=0;td?(d=new THREE.Face3(a.index,b.index,c.index,[a.position.clone(),b.position.clone(),c.position.clone()]),d.centroid.addSelf(a.position).addSelf(b.position).addSelf(c.position).divideScalar(3),d.normal=d.centroid.clone().normalize(), -i.faces.push(d),d=Math.atan2(d.centroid.z,-d.centroid.x),i.faceVertexUvs[0].push([h(a.uv,a.position,d),h(b.uv,b.position,d),h(c.uv,c.position,d)])):(d-=1,f(a,g(a,b),g(a,c),d),f(g(a,b),b,g(b,c),d),f(g(a,c),g(b,c),c,d),f(g(a,b),g(b,c),g(a,c),d))}function g(a,b){p[a.index]||(p[a.index]=[]);p[b.index]||(p[b.index]=[]);var c=p[a.index][b.index];void 0===c&&(p[a.index][b.index]=p[b.index][a.index]=c=e((new THREE.Vector3).add(a.position,b.position).divideScalar(2)));return c}function h(a,b,c){0>c&&1===a.u&& -(a=new THREE.UV(a.u-1,a.v));0===b.x&&0===b.z&&(a=new THREE.UV(c/2/Math.PI+0.5,a.v));return a}THREE.Geometry.call(this);for(var c=c||1,d=d||0,i=this,k=0,j=a.length;kd?(d=new THREE.Face3(a.index,b.index,c.index,[a.position.clone(),b.position.clone(),c.position.clone()]),d.centroid.addSelf(a.position).addSelf(b.position).addSelf(c.position).divideScalar(3),d.normal=d.centroid.clone().normalize(), +i.faces.push(d),d=Math.atan2(d.centroid.z,-d.centroid.x),i.faceVertexUvs[0].push([h(a.uv,a.position,d),h(b.uv,b.position,d),h(c.uv,c.position,d)])):(d-=1,g(a,f(a,b),f(a,c),d),g(f(a,b),b,f(b,c),d),g(f(a,c),f(b,c),c,d),g(f(a,b),f(b,c),f(a,c),d))}function f(a,b){p[a.index]||(p[a.index]=[]);p[b.index]||(p[b.index]=[]);var c=p[a.index][b.index];void 0===c&&(p[a.index][b.index]=p[b.index][a.index]=c=e((new THREE.Vector3).add(a.position,b.position).divideScalar(2)));return c}function h(a,b,c){0>c&&1===a.u&& +(a=new THREE.UV(a.u-1,a.v));0===b.x&&0===b.z&&(a=new THREE.UV(c/2/Math.PI+0.5,a.v));return a}THREE.Geometry.call(this);for(var c=c||1,d=d||0,i=this,j=0,k=a.length;jp;p++){n=i[p];m=new THREE.Color;m.setRGB(0,0,0);for(var q=0;qw.length&&(p[n]=!0)}for(n in q)if(w=q[n],s=w[0],w=w[1],v=n.split("_"),B=v[0],v=v[1],r=new THREE.Vector3,p[n]?(r.addSelf(h[B].position),r.addSelf(h[v].position),r.multiplyScalar(0.5)):(r.addSelf(k[s]),r.addSelf(k[w]),r.addSelf(h[B].position),r.addSelf(h[v].position),r.multiplyScalar(0.25)), -j[n]=t+d.length+u,i.push(new THREE.Vertex(r)),u++,g.supportUVs&&0!=o.length)w=new THREE.UV,w.u=o[B].u+o[v].u,w.v=o[B].v+o[v].v,w.u/=2,w.v/=2,o.push(w);var K,O;v=["123","12","2","23"];r=["123","23","3","31"];var D=["123","31","1","12"],H=["1234","12","2","23"],N=["1234","23","3","34"],P=["1234","34","4","41"],Q=["1234","41","1","12"];for(n=0,q=k.length;np;p++){n=i[p];k=new THREE.Color;k.setRGB(0,0,0);for(var q=0;qw.length&&(p[m]=!0)}for(m in q)if(w=q[m],s=w[0],w=w[1],v=m.split("_"),B=v[0],v=v[1],r=new THREE.Vector3,p[m]?(r.addSelf(h[B].position),r.addSelf(h[v].position),r.multiplyScalar(0.5)):(r.addSelf(j[s]),r.addSelf(j[w]),r.addSelf(h[B].position),r.addSelf(h[v].position),r.multiplyScalar(0.25)), +k[m]=t+d.length+u,i.push(new THREE.Vertex(r)),u++,f.supportUVs&&0!=o.length)w=new THREE.UV,w.u=o[B].u+o[v].u,w.v=o[B].v+o[v].v,w.u/=2,w.v/=2,o.push(w);var J,O;v=["123","12","2","23"];r=["123","23","3","31"];var D=["123","31","1","12"],H=["1234","12","2","23"],N=["1234","23","3","34"],P=["1234","34","4","41"],Q=["1234","41","1","12"];for(m=0,q=j.length;ma.length?".":a.join("/")+"/"},initMaterials:function(a,b,c){a.materials=[];for(var d=0;da.opacity)k.transparent=a.transparent;if(void 0!==a.depthTest)k.depthTest=a.depthTest;if(void 0!==a.vertexColors)if("face"==a.vertexColors)k.vertexColors=THREE.FaceColors;else if(a.vertexColors)k.vertexColors= -THREE.VertexColors;if(a.colorDiffuse)k.color=g(a.colorDiffuse);else if(a.DbgColor)k.color=a.DbgColor;if(a.colorSpecular)k.specular=g(a.colorSpecular);if(a.colorAmbient)k.ambient=g(a.colorAmbient);if(a.transparency)k.opacity=a.transparency;if(a.specularCoef)k.shininess=a.specularCoef;a.mapDiffuse&&b&&f(k,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&f(k,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&f(k,"normalMap", -a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&f(k,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var i=THREE.ShaderUtils.lib.normal,j=THREE.UniformsUtils.clone(i.uniforms);j.tNormal.texture=k.normalMap;if(a.mapNormalFactor)j.uNormalScale.value=a.mapNormalFactor;if(k.map)j.tDiffuse.texture=k.map,j.enableDiffuse.value=!0;if(k.specularMap)j.tSpecular.texture=k.specularMap,j.enableSpecular.value=!0;if(k.lightMap)j.tAO.texture= -k.lightMap,j.enableAO.value=!0;j.uDiffuseColor.value.setHex(k.color);j.uSpecularColor.value.setHex(k.specular);j.uAmbientColor.value.setHex(k.ambient);j.uShininess.value=k.shininess;if(void 0!==k.opacity)j.uOpacity.value=k.opacity;k=new THREE.ShaderMaterial({fragmentShader:i.fragmentShader,vertexShader:i.vertexShader,uniforms:j,lights:!0,fog:!0})}else k=new THREE[i](k);if(void 0!==a.DbgName)k.name=a.DbgName;return k}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)}; +Math.log(a)/Math.LN2;return Math.floor(a)==a}function d(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))}function e(a,b){var e=new Image;e.onload=function(){if(!c(this.width)||!c(this.height)){var b=d(this.width),e=d(this.height);a.image.width=b;a.image.height=e;a.image.getContext("2d").drawImage(this,0,0,b,e)}else a.image=this;a.needsUpdate=!0};e.crossOrigin=h.crossOrigin;e.src=b}function g(a,c,d,g,f,h){var i=document.createElement("canvas");a[c]=new THREE.Texture(i);a[c].sourceFile=d; +if(g){a[c].repeat.set(g[0],g[1]);if(1!=g[0])a[c].wrapS=THREE.RepeatWrapping;if(1!=g[1])a[c].wrapT=THREE.RepeatWrapping}f&&a[c].offset.set(f[0],f[1]);if(h){g={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(void 0!==g[h[0]])a[c].wrapS=g[h[0]];if(void 0!==g[h[1]])a[c].wrapT=g[h[1]]}e(a[c],b+"/"+d)}function f(a){return(255*a[0]<<16)+(255*a[1]<<8)+255*a[2]}var h=this,i="MeshLambertMaterial",j={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};a.shading&& +("Phong"==a.shading?i="MeshPhongMaterial":"Basic"==a.shading&&(i="MeshBasicMaterial"));if(a.blending)if("Additive"==a.blending)j.blending=THREE.AdditiveBlending;else if("Subtractive"==a.blending)j.blending=THREE.SubtractiveBlending;else if("Multiply"==a.blending)j.blending=THREE.MultiplyBlending;if(void 0!==a.transparent||1>a.opacity)j.transparent=a.transparent;if(void 0!==a.depthTest)j.depthTest=a.depthTest;if(void 0!==a.vertexColors)if("face"==a.vertexColors)j.vertexColors=THREE.FaceColors;else if(a.vertexColors)j.vertexColors= +THREE.VertexColors;if(a.colorDiffuse)j.color=f(a.colorDiffuse);else if(a.DbgColor)j.color=a.DbgColor;if(a.colorSpecular)j.specular=f(a.colorSpecular);if(a.colorAmbient)j.ambient=f(a.colorAmbient);if(a.transparency)j.opacity=a.transparency;if(a.specularCoef)j.shininess=a.specularCoef;a.mapDiffuse&&b&&g(j,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&g(j,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&g(j,"normalMap", +a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&g(j,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var i=THREE.ShaderUtils.lib.normal,k=THREE.UniformsUtils.clone(i.uniforms);k.tNormal.texture=j.normalMap;if(a.mapNormalFactor)k.uNormalScale.value=a.mapNormalFactor;if(j.map)k.tDiffuse.texture=j.map,k.enableDiffuse.value=!0;if(j.specularMap)k.tSpecular.texture=j.specularMap,k.enableSpecular.value=!0;if(j.lightMap)k.tAO.texture= +j.lightMap,k.enableAO.value=!0;k.uDiffuseColor.value.setHex(j.color);k.uSpecularColor.value.setHex(j.specular);k.uAmbientColor.value.setHex(j.ambient);k.uShininess.value=j.shininess;if(void 0!==j.opacity)k.uOpacity.value=j.opacity;j=new THREE.ShaderMaterial({fragmentShader:i.fragmentShader,vertexShader:i.vertexShader,uniforms:k,lights:!0,fog:!0})}else j=new THREE[i](j);if(void 0!==a.DbgName)j.name=a.DbgName;return j}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)}; THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype; THREE.BinaryLoader.prototype.load=function(a,b,c,d){if(a instanceof Object)console.warn("DEPRECATED: BinaryLoader( parameters ) is now BinaryLoader( url, callback, texturePath, binaryPath )."),d=a,a=d.model,b=d.callback,c=d.texture_path,d=d.bin_path;var c=c?c:this.extractUrlbase(a),d=d?d:this.extractUrlbase(a),e=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,e)}; -THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,f){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(4==g.readyState)if(200==g.status||0==g.status)try{var h=JSON.parse(g.responseText);void 0===h.metadata||void 0===h.metadata.formatVersion||3!==h.metadata.formatVersion?console.error("Deprecated file format."):a.loadAjaxBuffers(h,c,e,d,f)}catch(i){console.error(i),console.warn("DEPRECATED: ["+b+"] seems to be using old model format")}else console.error("Couldn't load ["+b+"] ["+ -g.status+"]")};g.open("GET",b,!0);g.overrideMimeType&&g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)}; -THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,e){var f=new XMLHttpRequest,g=c+"/"+a.buffers,h=0;f.onreadystatechange=function(){4==f.readyState?200==f.status||0==f.status?THREE.BinaryLoader.prototype.createBinModel(f.response,b,d,a.materials):console.error("Couldn't load ["+g+"] ["+f.status+"]"):3==f.readyState?e&&(0==h&&(h=f.getResponseHeader("Content-Length")),e({total:h,loaded:f.responseText.length})):2==f.readyState&&(h=f.getResponseHeader("Content-Length"))};f.open("GET",g,!0); -f.responseType="arraybuffer";f.send(null)}; -THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){var c,e,i,k,j,p,o,n,q,m,r,s,t,w,u,v;function B(a){return a%4?4-a%4:0}function F(a,b){return(new Uint8Array(a,b,1))[0]}function z(a,b){return(new Uint32Array(a,b,1))[0]}function D(b,c){var d,e,f,g,h,i,j,m,k=new Uint32Array(a,c,3*b);for(d=0;da.length?".":a.join("/")+"/");if((a=U.evaluate("//dae:asset",U,E,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;ea.length?".":a.join("/")+"/");if((a=U.evaluate("//dae:asset",U,E,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;eq)break}if(!s){s= +break;case "instance_camera":this.cameras.push((new C).parse(b));break;case "instance_controller":this.controllers.push((new m).parse(b));break;case "instance_geometry":this.geometries.push((new n).parse(b));break;case "instance_light":break;case "instance_node":b=b.getAttribute("url").replace(/^#/,"");(b=U.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",U,E,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new p).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new o).parse(b)); +break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in Ga)for(var e=Ga[d],f=0;fq)break}if(!s){s= new l(q);t=-1;u=0;for(v=d.length;u=q&&(t=u);q=t;d.splice(-1==q?d.length:q,0,s)}s.addTarget(f,j,g,r)}}else console.log('Could not find transform "'+b.sid+'" in node '+this.id)}for(c=0;cthis.transparency,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof D)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=Ja[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(Ra+e.init_from),e.wrapS=d.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping, -e.wrapT=d.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.offset.x=d.texOpts.offsetU,e.offset.y=d.texOpts.offsetV,e.repeat.x=d.texOpts.repeatU,e.repeat.y=d.texOpts.repeatV,a.map=e}}else"diffuse"==c?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=ya;return this.material=new THREE.MeshLambertMaterial(a)};K.prototype.parse=function(a){for(var b=0;b< +return this};H.prototype.create=function(){var a={},b=void 0!==this.transparency&&1>this.transparency,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof D)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=Ka[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(Sa+e.init_from),e.wrapS=d.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping, +e.wrapT=d.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.offset.x=d.texOpts.offsetU,e.offset.y=d.texOpts.offsetV,e.repeat.x=d.texOpts.repeatU,e.repeat.y=d.texOpts.repeatV,a.map=e}}else"diffuse"==c?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)};J.prototype.parse=function(a){for(var b=0;b< a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "init_from":this.init_from=c.textContent;break;case "format":this.format=c.textContent;break;default:console.log("unhandled Surface prop: "+c.nodeName)}}return this};O.prototype.parse=function(a){for(var b=0;bf||1f?0:1;if(h.length)for(var e=[],i=0;ir.parameters.opacity)r.parameters.transparent=!0;if(r.parameters.normalMap){a=THREE.ShaderUtils.lib.normal;j=THREE.UniformsUtils.clone(a.uniforms);m=r.parameters.color;N=r.parameters.specular;c=r.parameters.ambient;Q=r.parameters.shininess;j.tNormal.texture=C.textures[r.parameters.normalMap];if(r.parameters.normalMapFactor)j.uNormalScale.value=r.parameters.normalMapFactor;if(r.parameters.map)j.tDiffuse.texture=r.parameters.map,j.enableDiffuse.value=!0;if(r.parameters.lightMap)j.tAO.texture= -r.parameters.lightMap,j.enableAO.value=!0;if(r.parameters.specularMap)j.tSpecular.texture=C.textures[r.parameters.specularMap],j.enableSpecular.value=!0;j.uDiffuseColor.value.setHex(m);j.uSpecularColor.value.setHex(N);j.uAmbientColor.value.setHex(c);j.uShininess.value=Q;if(r.parameters.opacity)j.uOpacity.value=r.parameters.opacity;K=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:j,lights:!0,fog:!0})}else K=new THREE[r.type](r.parameters);C.materials[p]= -K}e();i.callbackSync(C);h()};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader; -THREE.UTF8Loader.prototype.load=function(a,b,c){if(a instanceof Object)console.warn("DEPRECATED: UTF8Loader( parameters ) is now UTF8Loader( url, callback, metaData )."),c=a,a=c.model,b=c.callback,c={scale:c.scale,offsetX:c.offsetX,offsetY:c.offsetY,offsetZ:c.offsetZ};var d=new XMLHttpRequest,e=void 0!==c.scale?c.scale:1,f=void 0!==c.offsetX?c.offsetX:0,g=void 0!==c.offsetY?c.offsetY:0,h=void 0!==c.offsetZ?c.offsetZ:0;d.onreadystatechange=function(){4==d.readyState?200==d.status||0==d.status?THREE.UTF8Loader.prototype.createModel(d.responseText, -b,e,f,g,h):alert("Couldn't load ["+a+"] ["+d.status+"]"):3!=d.readyState&&2==d.readyState&&d.getResponseHeader("Content-Length")};d.open("GET",a,!0);d.send(null)};THREE.UTF8Loader.prototype.decompressMesh=function(a){var b=a.charCodeAt(0);57344<=b&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;8>e;e++){for(var f=0,g=0;g>1^-(h&1));c[8*g+e]=f}d+=b}b=a.length-d;f=new Uint16Array(b);for(e=g=0;er.parameters.opacity)r.parameters.transparent=!0;if(r.parameters.normalMap){a=THREE.ShaderUtils.lib.normal;k=THREE.UniformsUtils.clone(a.uniforms);n=r.parameters.color;N=r.parameters.specular;c=r.parameters.ambient;Q=r.parameters.shininess;k.tNormal.texture=C.textures[r.parameters.normalMap];if(r.parameters.normalMapFactor)k.uNormalScale.value=r.parameters.normalMapFactor;if(r.parameters.map)k.tDiffuse.texture=r.parameters.map,k.enableDiffuse.value=!0;if(r.parameters.lightMap)k.tAO.texture= +r.parameters.lightMap,k.enableAO.value=!0;if(r.parameters.specularMap)k.tSpecular.texture=C.textures[r.parameters.specularMap],k.enableSpecular.value=!0;k.uDiffuseColor.value.setHex(n);k.uSpecularColor.value.setHex(N);k.uAmbientColor.value.setHex(c);k.uShininess.value=Q;if(r.parameters.opacity)k.uOpacity.value=r.parameters.opacity;J=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:k,lights:!0,fog:!0})}else J=new THREE[r.type](r.parameters);C.materials[p]= +J}e();i.callbackSync(C);h()};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader; +THREE.UTF8Loader.prototype.load=function(a,b,c){if(a instanceof Object)console.warn("DEPRECATED: UTF8Loader( parameters ) is now UTF8Loader( url, callback, metaData )."),c=a,a=c.model,b=c.callback,c={scale:c.scale,offsetX:c.offsetX,offsetY:c.offsetY,offsetZ:c.offsetZ};var d=new XMLHttpRequest,e=void 0!==c.scale?c.scale:1,g=void 0!==c.offsetX?c.offsetX:0,f=void 0!==c.offsetY?c.offsetY:0,h=void 0!==c.offsetZ?c.offsetZ:0;d.onreadystatechange=function(){4==d.readyState?200==d.status||0==d.status?THREE.UTF8Loader.prototype.createModel(d.responseText, +b,e,g,f,h):alert("Couldn't load ["+a+"] ["+d.status+"]"):3!=d.readyState&&2==d.readyState&&d.getResponseHeader("Content-Length")};d.open("GET",a,!0);d.send(null)};THREE.UTF8Loader.prototype.decompressMesh=function(a){var b=a.charCodeAt(0);57344<=b&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;8>e;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(0!==this.count){for(var b=3*this.count;bp&&(p=1);i=Math.floor(i+h);i>this.size-1&&(i=this.size-1);var o=Math.floor(k-h);1>o&&(o=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var n=Math.floor(j-h);1>n&&(n=1);h=Math.floor(j+h);h>this.size-1&&(h=this.size- -1);for(var q,m,r,s,t,w,u,j=p;jk&&(n=k);for(e=0;ej&&(q=j);for(f=0;fj&&(q=j);for(g=0;g=this.maxCount-3&&h(this)};this.begin=function(){this.count=0; +this.hasNormal=this.hasPos=!1};this.end=function(a){if(0!==this.count){for(var b=3*this.count;bp&&(p=1);i=Math.floor(i+h);i>this.size-1&&(i=this.size-1);var o=Math.floor(j-h);1>o&&(o=1);j=Math.floor(j+h);j>this.size-1&&(j=this.size-1);var m=Math.floor(k-h);1>m&&(m=1);h=Math.floor(k+h);h>this.size-1&&(h=this.size- +1);for(var q,n,r,s,t,w,u,k=p;kj&&(m=j);for(e=0;ek&&(q=k);for(g=0;gk&&(q=k);for(f=0;f=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(k=!1,j=a(THREE.ShaderFlares.lensFlare)):(k=!0,j=a(THREE.ShaderFlares.lensFlareVertexTexture));p={};o={};p.vertex=b.getAttribLocation(j,"position");p.uv=b.getAttribLocation(j,"uv");o.renderType=b.getUniformLocation(j,"renderType");o.map=b.getUniformLocation(j,"map");o.occlusionMap=b.getUniformLocation(j,"occlusionMap");o.opacity=b.getUniformLocation(j,"opacity");o.color=b.getUniformLocation(j, -"color");o.scale=b.getUniformLocation(j,"scale");o.rotation=b.getUniformLocation(j,"rotation");o.screenPosition=b.getUniformLocation(j,"screenPosition");n=!1};this.render=function(a,d,e,s){var a=a.__webglFlares,t=a.length;if(t){var w=new THREE.Vector3,u=s/e,v=0.5*e,B=0.5*s,F=16/s,z=new THREE.Vector2(F*u,F),D=new THREE.Vector3(1,1,0),H=new THREE.Vector2(1,1),K=o,F=p;b.useProgram(j);n||(b.enableVertexAttribArray(p.vertex),b.enableVertexAttribArray(p.uv),n=!0);b.uniform1i(K.occlusionMap,0);b.uniform1i(K.map, -1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(F.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(F.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(!1);var O,N,P,Q,I;for(O=0;O=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(j=!1,k=a(THREE.ShaderFlares.lensFlare)):(j=!0,k=a(THREE.ShaderFlares.lensFlareVertexTexture));p={};o={};p.vertex=b.getAttribLocation(k,"position");p.uv=b.getAttribLocation(k,"uv");o.renderType=b.getUniformLocation(k,"renderType");o.map=b.getUniformLocation(k,"map");o.occlusionMap=b.getUniformLocation(k,"occlusionMap");o.opacity=b.getUniformLocation(k,"opacity");o.color=b.getUniformLocation(k, +"color");o.scale=b.getUniformLocation(k,"scale");o.rotation=b.getUniformLocation(k,"rotation");o.screenPosition=b.getUniformLocation(k,"screenPosition");m=!1};this.render=function(a,d,e,s){var a=a.__webglFlares,t=a.length;if(t){var w=new THREE.Vector3,u=s/e,v=0.5*e,B=0.5*s,F=16/s,z=new THREE.Vector2(F*u,F),D=new THREE.Vector3(1,1,0),H=new THREE.Vector2(1,1),J=o,F=p;b.useProgram(k);m||(b.enableVertexAttribArray(p.vertex),b.enableVertexAttribArray(p.uv),m=!0);b.uniform1i(J.occlusionMap,0);b.uniform1i(J.map, +1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(F.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(F.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f);b.disable(b.CULL_FACE);b.depthMask(!1);var O,N,P,Q,I;for(O=0;Ov;v++)s[v]=new THREE.Vector3,m[v]=new THREE.Vector3;s=t.shadowCascadeNearZ[r];t=t.shadowCascadeFarZ[r];m[0].set(-1,-1,s);m[1].set(1,-1,s);m[2].set(-1,1,s);m[3].set(1,1,s);m[4].set(-1,-1,t);m[5].set(1,-1,t);m[6].set(-1,1,t);m[7].set(1,1,t);u.originalCamera=k;m=new THREE.Gyroscope;m.position=o.shadowCascadeOffset;m.add(u);m.add(u.target);k.add(m);o.shadowCascadeArray[q]=u;console.log("Created virtualLight",u)}r=o;s=q;t=r.shadowCascadeArray[s];t.position.copy(r.position); -t.target.position.copy(r.target.position);t.lookAt(t.target);t.shadowCameraVisible=r.shadowCameraVisible;t.shadowDarkness=r.shadowDarkness;t.shadowBias=r.shadowCascadeBias[s];m=r.shadowCascadeNearZ[s];r=r.shadowCascadeFarZ[s];t=t.pointsFrustum;t[0].z=m;t[1].z=m;t[2].z=m;t[3].z=m;t[4].z=r;t[5].z=r;t[6].z=r;t[7].z=r;w[n]=u;n++}else w[n]=o,n++;for(j=0,p=w.length;jv;v++)s[v]=new THREE.Vector3,n[v]=new THREE.Vector3;s=t.shadowCascadeNearZ[r];t=t.shadowCascadeFarZ[r];n[0].set(-1,-1,s);n[1].set(1,-1,s);n[2].set(-1,1,s);n[3].set(1,1,s);n[4].set(-1,-1,t);n[5].set(1,-1,t);n[6].set(-1,1,t);n[7].set(1,1,t);u.originalCamera=j;n=new THREE.Gyroscope;n.position=o.shadowCascadeOffset;n.add(u);n.add(u.target);j.add(n);o.shadowCascadeArray[q]=u;console.log("Created virtualLight",u)}r=o;s=q;t=r.shadowCascadeArray[s];t.position.copy(r.position); +t.target.position.copy(r.target.position);t.lookAt(t.target);t.shadowCameraVisible=r.shadowCameraVisible;t.shadowDarkness=r.shadowDarkness;t.shadowBias=r.shadowCascadeBias[s];n=r.shadowCascadeNearZ[s];r=r.shadowCascadeFarZ[s];t=t.pointsFrustum;t[0].z=n;t[1].z=n;t[2].z=n;t[3].z=n;t[4].z=r;t[5].z=r;t[6].z=r;t[7].z=r;w[m]=u;m++}else w[m]=o,m++;for(k=0,p=w.length;kr;r++){s=t[r];s.copy(m[r]);THREE.ShadowMapPlugin.__projector.unprojectVector(s, -q);n.matrixWorldInverse.multiplyVector3(s);if(s.xh.x)h.x=s.x;if(s.yh.y)h.y=s.y;if(s.zh.z)h.z=s.z}n.left=g.x;n.right=h.x;n.top=h.y;n.bottom=g.y;n.updateProjectionMatrix()}n=o.shadowMap;m=o.shadowMatrix;q=o.shadowCamera;q.position.copy(o.matrixWorld.getPosition());q.lookAt(o.target.matrixWorld.getPosition());q.updateMatrixWorld();q.matrixWorldInverse.getInverse(q.matrixWorld);if(o.cameraHelper)o.cameraHelper.lines.visible=o.shadowCameraVisible; -o.shadowCameraVisible&&o.cameraHelper.update(o.shadowCamera);m.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);m.multiplySelf(q.projectionMatrix);m.multiplySelf(q.matrixWorldInverse);if(!q._viewMatrixArray)q._viewMatrixArray=new Float32Array(16);q.matrixWorldInverse.flattenToArray(q._viewMatrixArray);if(!q._projectionMatrixArray)q._projectionMatrixArray=new Float32Array(16);q.projectionMatrix.flattenToArray(q._projectionMatrixArray);f.multiply(q.projectionMatrix,q.matrixWorldInverse);e.setFromMatrix(f); -b.setRenderTarget(n);b.clear();t=i.__webglObjects;for(o=0,n=t.length;or;r++){s=t[r];s.copy(n[r]);THREE.ShadowMapPlugin.__projector.unprojectVector(s, +q);m.matrixWorldInverse.multiplyVector3(s);if(s.xh.x)h.x=s.x;if(s.yh.y)h.y=s.y;if(s.zh.z)h.z=s.z}m.left=f.x;m.right=h.x;m.top=h.y;m.bottom=f.y;m.updateProjectionMatrix()}m=o.shadowMap;n=o.shadowMatrix;q=o.shadowCamera;q.position.copy(o.matrixWorld.getPosition());q.lookAt(o.target.matrixWorld.getPosition());q.updateMatrixWorld();q.matrixWorldInverse.getInverse(q.matrixWorld);if(o.cameraHelper)o.cameraHelper.lines.visible=o.shadowCameraVisible; +o.shadowCameraVisible&&o.cameraHelper.update(o.shadowCamera);n.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);n.multiplySelf(q.projectionMatrix);n.multiplySelf(q.matrixWorldInverse);if(!q._viewMatrixArray)q._viewMatrixArray=new Float32Array(16);q.matrixWorldInverse.flattenToArray(q._viewMatrixArray);if(!q._projectionMatrixArray)q._projectionMatrixArray=new Float32Array(16);q.projectionMatrix.flattenToArray(q._projectionMatrixArray);g.multiply(q.projectionMatrix,q.matrixWorldInverse);e.setFromMatrix(g); +b.setRenderTarget(m);b.clear();t=i.__webglObjects;for(o=0,m=t.length;oa;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}; THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3; -THREE.Ray=function(a,b){function c(a,b,c){k.sub(c,a);q=k.dot(b);x=p.add(a,i.copy(b).multiplyScalar(q));return v=c.distanceTo(x)}function d(a,b,c,d){k.sub(d,b);p.sub(c,b);i.sub(a,b);H=k.dot(k);E=k.dot(p);t=k.dot(i);G=p.dot(p);z=p.dot(i);F=1/(H*G-E*E);s=(G*t-E*z)*F;u=(H*z-E*t)*F;return 0<=s&&0<=u&&1>s+u}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;ba.scale.x)return[];b={distance:k,point:a.position,face:null,object:a};i.push(b)}else if(a instanceof THREE.Mesh){var k= -c(this.origin,this.direction,a.matrixWorld.getPosition()),p=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(k>a.geometry.boundingSphere.radius*Math.max(p.x,Math.max(p.y,p.z)))return i;var q,s,u=a.geometry,t=u.vertices,D;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(k=0,p=u.faces.length;kMath.abs(q))&&(s=o.dot(l)/q,!(0>s)&&(a.doubleSided||(a.flipSided?0q))))if(n.add(m,j.multiplyScalar(s)),b instanceof THREE.Face3)e=D.multiplyVector3(e.copy(t[b.a].position)),f=D.multiplyVector3(f.copy(t[b.b].position)),g=D.multiplyVector3(g.copy(t[b.c].position)),d(n,e,f,g)&&(b={distance:m.distanceTo(n),point:n.clone(),face:b,object:a},i.push(b));else if(b instanceof THREE.Face4&&(e=D.multiplyVector3(e.copy(t[b.a].position)), -f=D.multiplyVector3(f.copy(t[b.b].position)),g=D.multiplyVector3(g.copy(t[b.c].position)),h=D.multiplyVector3(h.copy(t[b.d].position)),d(n,e,f,h)||d(n,f,g,h)))b={distance:m.distanceTo(n),point:n.clone(),face:b,object:a},i.push(b)}return i};var k=new THREE.Vector3,p=new THREE.Vector3,i=new THREE.Vector3,q,x,v,H,E,t,G,z,F,s,u}; -THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,l,o){h=!1;b=f;c=g;d=l;e=o;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= -function(f,g,l,o,n,k){h?(h=!1,b=fl?f>n?f:n:l>n?l:n,e=g>o?g>k?g:k:o>k?o:k):(b=fl?f>n?f>d?f:d:n>d?n:d:l>n?l>d?l:d:n>d?n:d,e=g>o?g>k?g>e?g:e:k>e?k:e:o>k?o>e?o:e:k>e?k:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> +THREE.Ray=function(a,b){function c(a,b,c){p.sub(c,a);D=p.dot(b);u=k.add(a,r.copy(b).multiplyScalar(D));return G=c.distanceTo(u)}function d(a,b,c,d){p.sub(d,b);k.sub(c,b);r.sub(a,b);I=p.dot(p);v=p.dot(k);H=p.dot(r);A=k.dot(k);F=k.dot(r);s=1/(I*A-v*v);w=(A*H-v*F)*s;z=(I*F-v*H)*s;return 0<=w&&0<=z&&1>w+z}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;ba.scale.x)return[];b={distance:p,point:a.position,face:null,object:a}; +k.push(b)}else if(a instanceof THREE.Mesh){var p=c(this.origin,this.direction,a.matrixWorld.getPosition()),r=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(p>a.geometry.boundingSphere.radius*Math.max(r.x,Math.max(r.y,r.z)))return k;var s,w,v=a.geometry,E=v.vertices,u;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(p=0,r=v.faces.length;pw)&&(a.doubleSided||(a.flipSided?0s))))if(n.add(j,i.multiplyScalar(w)),b instanceof THREE.Face3)f=u.multiplyVector3(f.copy(E[b.a].position)),g=u.multiplyVector3(g.copy(E[b.b].position)),h=u.multiplyVector3(h.copy(E[b.c].position)),d(n,f,g,h)&&(b={distance:j.distanceTo(n),point:n.clone(),face:b,object:a},k.push(b));else if(b instanceof +THREE.Face4&&(f=u.multiplyVector3(f.copy(E[b.a].position)),g=u.multiplyVector3(g.copy(E[b.b].position)),h=u.multiplyVector3(h.copy(E[b.c].position)),l=u.multiplyVector3(l.copy(E[b.d].position)),d(n,f,g,l)||d(n,g,h,l)))b={distance:j.distanceTo(n),point:n.clone(),face:b,object:a},k.push(b)}return k};var p=new THREE.Vector3,k=new THREE.Vector3,r=new THREE.Vector3,D,u,G,I,v,H,A,F,s,w,z}; +THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,i,o){h=!1;b=f;c=g;d=i;e=o;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= +function(f,g,i,o,m,n){h?(h=!1,b=fi?f>m?f:m:i>m?i:m,e=g>o?g>n?g:n:o>n?o:n):(b=fi?f>m?f>d?f:d:m>d?m:d:i>m?i>d?i:d:m>d?m:d,e=g>o?g>n?g>e?g:e:n>e?n:e:o>n?o>e?o:e:n>e?n:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=da.getRight()||ea.getBottom()?!1:!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 ae&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(dg&&h.positionScreen.z(L.positionScreen.x-A.positionScreen.x)*(N.positionScreen.y-A.positionScreen.y)-(L.positionScreen.y-A.positionScreen.y)*(N.positionScreen.x-A.positionScreen.x),r.doubleSided|| -P!=r.flipSided)U=n[o]=n[o]||new THREE.RenderableFace3,o++,l=U,l.v1.copy(A),l.v2.copy(N),l.v3.copy(L);else continue;else continue;else if(I instanceof THREE.Face4)if(A=j[I.a],N=j[I.b],L=j[I.c],U=j[I.d],A.visible&&N.visible&&L.visible&&U.visible)if(P=0>(U.positionScreen.x-A.positionScreen.x)*(N.positionScreen.y-A.positionScreen.y)-(U.positionScreen.y-A.positionScreen.y)*(N.positionScreen.x-A.positionScreen.x)||0>(N.positionScreen.x-L.positionScreen.x)*(U.positionScreen.y-L.positionScreen.y)-(N.positionScreen.y- -L.positionScreen.y)*(U.positionScreen.x-L.positionScreen.x),r.doubleSided||P!=r.flipSided)ea=p[k]=p[k]||new THREE.RenderableFace4,k++,l=ea,l.v1.copy(A),l.v2.copy(N),l.v3.copy(L),l.v4.copy(U);else continue;else continue;l.normalWorld.copy(I.normal);!P&&(r.flipSided||r.doubleSided)&&l.normalWorld.negate();w.multiplyVector3(l.normalWorld);l.centroidWorld.copy(I.centroid);y.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);F.multiplyVector3(l.centroidScreen);L=I.vertexNormals;for(A= -0,N=L.length;Az.z))g=E[H]=E[H]||new THREE.RenderableParticle,H++,v=g,v.x=z.x/z.w,v.y=z.y/z.w,v.z=z.z,v.rotation=r.rotation.z,v.scale.x=r.scale.x*Math.abs(v.x-(z.x+e.projectionMatrix.n11)/(z.w+e.projectionMatrix.n14)),v.scale.y=r.scale.y*Math.abs(v.y-(z.y+e.projectionMatrix.n22)/(z.w+e.projectionMatrix.n24)),v.material=r.material,t.elements.push(v);f&&t.elements.sort(c);return t}}; +THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=j[l]=j[l]||new THREE.RenderableVertex;l++;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,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(dg&&h.positionScreen.z(M.positionScreen.x-B.positionScreen.x)*(O.positionScreen.y-B.positionScreen.y)-(M.positionScreen.y-B.positionScreen.y)*(O.positionScreen.x-B.positionScreen.x),t.doubleSided|| +Q!=t.flipSided)V=m[o]=m[o]||new THREE.RenderableFace3,o++,i=V,i.v1.copy(B),i.v2.copy(O),i.v3.copy(M);else continue;else continue;else if(J instanceof THREE.Face4)if(B=j[J.a],O=j[J.b],M=j[J.c],V=j[J.d],B.visible&&O.visible&&M.visible&&V.visible)if(Q=0>(V.positionScreen.x-B.positionScreen.x)*(O.positionScreen.y-B.positionScreen.y)-(V.positionScreen.y-B.positionScreen.y)*(O.positionScreen.x-B.positionScreen.x)||0>(O.positionScreen.x-M.positionScreen.x)*(V.positionScreen.y-M.positionScreen.y)-(O.positionScreen.y- +M.positionScreen.y)*(V.positionScreen.x-M.positionScreen.x),t.doubleSided||Q!=t.flipSided)fa=p[n]=p[n]||new THREE.RenderableFace4,n++,i=fa,i.v1.copy(B),i.v2.copy(O),i.v3.copy(M),i.v4.copy(V);else continue;else continue;i.normalWorld.copy(J.normal);!Q&&(t.flipSided||t.doubleSided)&&i.normalWorld.negate();x.multiplyVector3(i.normalWorld);i.centroidWorld.copy(J.centroid);y.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);F.multiplyVector3(i.centroidScreen);M=J.vertexNormals;for(B= +0,O=M.length;BA.z))g=I[G]=I[G]||new THREE.RenderableParticle,G++,u=g,u.x=A.x/A.w,u.y=A.y/A.w,u.z=A.z,u.rotation=t.rotation.z,u.scale.x=t.scale.x*Math.abs(u.x-(A.x+e.projectionMatrix.n11)/(A.w+e.projectionMatrix.n14)),u.scale.y=t.scale.y*Math.abs(u.y-(A.y+e.projectionMatrix.n22)/(A.w+e.projectionMatrix.n24)),u.material=t.material,v.elements.push(u);f&&v.elements.sort(c);return v}}; THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e* f-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=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31? -Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-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);0===a?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,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-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,f=this.x,g=this.y,h=this.z,m=this.w,j=m*c+g*e-h*d,l=m*d+h*c-f*e,o=m*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=j*m+c*-f+l*-h-o*-g;b.y=l*m+c*-g+o*-f-j*-h;b.z=o*m+c*-h+j*-g-l*-f;return b}}; +a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,l=this.w,j=l*c+g*e-h*d,i=l*d+h*c-f*e,o=l*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=j*l+c*-f+i*-h-o*-g;b.y=i*l+c*-g+o*-f-j*-h;b.z=o*l+c*-h+j*-g-i*-f;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;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))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)/e;d=Math.sin(d*f)/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.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,e,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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;be?-1:1,f.vertexTangents[d]=new THREE.Vector4(Z.x,Z.y,Z.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0e?-1:1,f.vertexTangents[d]=new THREE.Vector4($.x,$.y,$.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0c.x)c.x=a.x;if(a.yc.y)c.y=a.y;if(a.zc.z)c.z=a.z}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;cb&&(b=a);this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10, 4),f,g;for(f=0,g=this.vertices.length;fx&&i.clearRect(Math.floor(Y.getX()),Math.floor(Y.getY()),Math.floor(Y.getWidth()),Math.floor(Y.getHeight())),0=l||(l*=g.intensity,d.r+=h.r*l,d.g+=h.g*l,d.b+=h.b*l)):g instanceof THREE.PointLight&&(j=g.matrixWorld.getPosition(),l=c.dot(R.sub(j,b).normalize()),0>=l||(l*=0==g.distance?1:1-Math.min(b.distanceTo(j)/g.distance,1),0!=l&&(l*=g.intensity,d.r+=h.r*l,d.g+=h.g*l,d.b+=h.b*l)))}function q(a,f,g){b(g.opacity);c(g.blending);var h,l,j,m,za,o;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)m=g.map.image,za=m.width>>1,o=m.height>> -1,g=f.scale.x*k,j=f.scale.y*p,h=g*za,l=j*o,X.set(a.x-h,a.y-l,a.x+h,a.y+l),la.intersects(X)&&(i.save(),i.translate(a.x,a.y),i.rotate(-f.rotation),i.scale(g,-j),i.translate(-za,-o),i.drawImage(m,0,0),i.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*k,l=f.scale.y*p,X.set(a.x-h,a.y-l,a.x+h,a.y+l),la.intersects(X)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),i.save(),i.translate(a.x,a.y),i.rotate(-f.rotation),i.scale(h,l),g.program(i),i.restore()))}function t(a, -e,f,g){b(g.opacity);c(g.blending);i.beginPath();i.moveTo(a.positionScreen.x,a.positionScreen.y);i.lineTo(e.positionScreen.x,e.positionScreen.y);i.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(G!=a)i.lineWidth=G=a;a=g.linecap;if(z!=a)i.lineCap=z=a;a=g.linejoin;if(F!=a)i.lineJoin=F=a;d(g.color.getContextStyle());i.stroke();X.inflate(2*g.linewidth)}}function v(a,d,e,g,h,j,i,k){f.info.render.vertices+=3;f.info.render.faces++;b(k.opacity);c(k.blending);M=a.positionScreen.x;O=a.positionScreen.y; -S=d.positionScreen.x;P=d.positionScreen.y;T=e.positionScreen.x;D=e.positionScreen.y;x(M,O,S,P,T,D);if(k instanceof THREE.MeshBasicMaterial)if(k.map)k.map.mapping instanceof THREE.UVMapping&&($=i.uvs[0],Aa(M,O,S,P,T,D,$[g].u,$[g].v,$[h].u,$[h].v,$[j].u,$[j].v,k.map));else if(k.envMap){if(k.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,R.copy(i.vertexNormalsWorld[g]),Ba=0.5*(R.x*a.n11+R.y*a.n12+R.z*a.n13)+0.5,Ca=0.5*-(R.x*a.n21+R.y*a.n22+R.z*a.n23)+0.5,R.copy(i.vertexNormalsWorld[h]), -Da=0.5*(R.x*a.n11+R.y*a.n12+R.z*a.n13)+0.5,Ea=0.5*-(R.x*a.n21+R.y*a.n22+R.z*a.n23)+0.5,R.copy(i.vertexNormalsWorld[j]),Fa=0.5*(R.x*a.n11+R.y*a.n12+R.z*a.n13)+0.5,Ga=0.5*-(R.x*a.n21+R.y*a.n22+R.z*a.n23)+0.5,Aa(M,O,S,P,T,D,Ba,Ca,Da,Ea,Fa,Ga,k.envMap)}else k.wireframe?ia(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(k.color);else if(k instanceof THREE.MeshLambertMaterial)k.map&&!k.wireframe&&(k.map.mapping instanceof THREE.UVMapping&&($=i.uvs[0],Aa(M,O,S,P,T,D,$[g].u,$[g].v, -$[h].u,$[h].v,$[j].u,$[j].v,k.map)),c(THREE.SubtractiveBlending)),xa?!k.wireframe&&k.shading==THREE.SmoothShading&&3==i.vertexNormalsWorld.length?(y.r=w.r=B.r=W.r,y.g=w.g=B.g=W.g,y.b=w.b=B.b=W.b,n(m,i.v1.positionWorld,i.vertexNormalsWorld[0],y),n(m,i.v2.positionWorld,i.vertexNormalsWorld[1],w),n(m,i.v3.positionWorld,i.vertexNormalsWorld[2],B),y.r=Math.max(0,Math.min(k.color.r*y.r,1)),y.g=Math.max(0,Math.min(k.color.g*y.g,1)),y.b=Math.max(0,Math.min(k.color.b*y.b,1)),w.r=Math.max(0,Math.min(k.color.r* -w.r,1)),w.g=Math.max(0,Math.min(k.color.g*w.g,1)),w.b=Math.max(0,Math.min(k.color.b*w.b,1)),B.r=Math.max(0,Math.min(k.color.r*B.r,1)),B.g=Math.max(0,Math.min(k.color.g*B.g,1)),B.b=Math.max(0,Math.min(k.color.b*B.b,1)),K.r=0.5*(w.r+B.r),K.g=0.5*(w.g+B.g),K.b=0.5*(w.b+B.b),da=va(y,w,B,K),pa(M,O,S,P,T,D,0,0,1,0,0,1,da)):(r.r=W.r,r.g=W.g,r.b=W.b,n(m,i.centroidWorld,i.normalWorld,r),r.r=Math.max(0,Math.min(k.color.r*r.r,1)),r.g=Math.max(0,Math.min(k.color.g*r.g,1)),r.b=Math.max(0,Math.min(k.color.b*r.b, -1)),k.wireframe?ia(r,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(r)):k.wireframe?ia(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(k.color);else if(k instanceof THREE.MeshDepthMaterial)fa=l.near,ga=l.far,y.r=y.g=y.b=1-oa(a.positionScreen.z,fa,ga),w.r=w.g=w.b=1-oa(d.positionScreen.z,fa,ga),B.r=B.g=B.b=1-oa(e.positionScreen.z,fa,ga),K.r=0.5*(w.r+B.r),K.g=0.5*(w.g+B.g),K.b=0.5*(w.b+B.b),da=va(y,w,B,K),pa(M,O,S,P,T,D,0,0,1,0,0,1,da);else if(k instanceof THREE.MeshNormalMaterial)r.r= -qa(i.normalWorld.x),r.g=qa(i.normalWorld.y),r.b=qa(i.normalWorld.z),k.wireframe?ia(r,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(r)}function H(a,d,e,g,h,k,j,i,o){f.info.render.vertices+=4;f.info.render.faces++;b(i.opacity);c(i.blending);if(i.map||i.envMap)v(a,d,g,0,1,3,j,i,o),v(h,e,k,1,2,3,j,i,o);else if(M=a.positionScreen.x,O=a.positionScreen.y,S=d.positionScreen.x,P=d.positionScreen.y,T=e.positionScreen.x,D=e.positionScreen.y,I=g.positionScreen.x,Q=g.positionScreen.y,A=h.positionScreen.x, -N=h.positionScreen.y,L=k.positionScreen.x,U=k.positionScreen.y,i instanceof THREE.MeshBasicMaterial)E(M,O,S,P,T,D,I,Q),i.wireframe?ia(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(i.color);else if(i instanceof THREE.MeshLambertMaterial)xa?!i.wireframe&&i.shading==THREE.SmoothShading&&4==j.vertexNormalsWorld.length?(y.r=w.r=B.r=K.r=W.r,y.g=w.g=B.g=K.g=W.g,y.b=w.b=B.b=K.b=W.b,n(m,j.v1.positionWorld,j.vertexNormalsWorld[0],y),n(m,j.v2.positionWorld,j.vertexNormalsWorld[1],w), -n(m,j.v4.positionWorld,j.vertexNormalsWorld[3],B),n(m,j.v3.positionWorld,j.vertexNormalsWorld[2],K),y.r=Math.max(0,Math.min(i.color.r*y.r,1)),y.g=Math.max(0,Math.min(i.color.g*y.g,1)),y.b=Math.max(0,Math.min(i.color.b*y.b,1)),w.r=Math.max(0,Math.min(i.color.r*w.r,1)),w.g=Math.max(0,Math.min(i.color.g*w.g,1)),w.b=Math.max(0,Math.min(i.color.b*w.b,1)),B.r=Math.max(0,Math.min(i.color.r*B.r,1)),B.g=Math.max(0,Math.min(i.color.g*B.g,1)),B.b=Math.max(0,Math.min(i.color.b*B.b,1)),K.r=Math.max(0,Math.min(i.color.r* -K.r,1)),K.g=Math.max(0,Math.min(i.color.g*K.g,1)),K.b=Math.max(0,Math.min(i.color.b*K.b,1)),da=va(y,w,B,K),x(M,O,S,P,I,Q),pa(M,O,S,P,I,Q,0,0,1,0,0,1,da),x(A,N,T,D,L,U),pa(A,N,T,D,L,U,1,0,1,1,0,1,da)):(r.r=W.r,r.g=W.g,r.b=W.b,n(m,j.centroidWorld,j.normalWorld,r),r.r=Math.max(0,Math.min(i.color.r*r.r,1)),r.g=Math.max(0,Math.min(i.color.g*r.g,1)),r.b=Math.max(0,Math.min(i.color.b*r.b,1)),E(M,O,S,P,T,D,I,Q),i.wireframe?ia(r,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(r)):(E(M,O,S, -P,T,D,I,Q),i.wireframe?ia(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(i.color));else if(i instanceof THREE.MeshNormalMaterial)r.r=qa(j.normalWorld.x),r.g=qa(j.normalWorld.y),r.b=qa(j.normalWorld.z),E(M,O,S,P,T,D,I,Q),i.wireframe?ia(r,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(r);else if(i instanceof THREE.MeshDepthMaterial)fa=l.near,ga=l.far,y.r=y.g=y.b=1-oa(a.positionScreen.z,fa,ga),w.r=w.g=w.b=1-oa(d.positionScreen.z,fa,ga),B.r=B.g=B.b=1-oa(g.positionScreen.z, -fa,ga),K.r=K.g=K.b=1-oa(e.positionScreen.z,fa,ga),da=va(y,w,B,K),x(M,O,S,P,I,Q),pa(M,O,S,P,I,Q,0,0,1,0,0,1,da),x(A,N,T,D,L,U),pa(A,N,T,D,L,U,1,0,1,1,0,1,da)}function x(a,b,c,d,e,f){i.beginPath();i.moveTo(a,b);i.lineTo(c,d);i.lineTo(e,f);i.lineTo(a,b);i.closePath()}function E(a,b,c,d,e,f,g,h){i.beginPath();i.moveTo(a,b);i.lineTo(c,d);i.lineTo(e,f);i.lineTo(g,h);i.lineTo(a,b);i.closePath()}function ia(a,b,c,e){if(G!=b)i.lineWidth=G=b;if(z!=c)i.lineCap=z=c;if(F!=e)i.lineJoin=F=e;d(a.getContextStyle()); -i.stroke();X.inflate(2*b)}function ha(a){e(a.getContextStyle());i.fill()}function Aa(a,b,c,d,f,g,h,k,j,l,m,o,n){if(0!=n.image.width){if(!0==n.needsUpdate||void 0==ka[n.id]){var p=n.wrapS==THREE.RepeatWrapping,q=n.wrapT==THREE.RepeatWrapping;ka[n.id]=i.createPattern(n.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");n.needsUpdate=!1}e(ka[n.id]);var p=n.offset.x/n.repeat.x,q=n.offset.y/n.repeat.y,s=n.image.width*n.repeat.x,t=n.image.height*n.repeat.y,h=(h+p)*s,k=(k+q)*t,c=c-a,d=d- -b,f=f-a,g=g-b,j=(j+p)*s-h,l=(l+q)*t-k,m=(m+p)*s-h,o=(o+q)*t-k,p=j*o-m*l;if(0==p){if(void 0===ea[n.id])b=document.createElement("canvas"),b.width=n.image.width,b.height=n.image.height,b=b.getContext("2d"),b.drawImage(n.image,0,0),ea[n.id]=b.getImageData(0,0,n.image.width,n.image.height).data;b=ea[n.id];h=4*(Math.floor(h)+Math.floor(k)*n.image.width);r.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);ha(r)}else p=1/p,n=(o*c-l*f)*p,l=(o*d-l*g)*p,c=(j*f-m*c)*p,d=(j*g-m*d)*p,a=a-n*h-c*k,h=b-l*h-d*k,i.save(),i.transform(n, -l,c,d,a,h),i.fill(),i.restore()}}function pa(a,b,c,d,e,f,g,h,k,j,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;c-=a;d-=b;e-=a;f-=b;k=k*o-g;j=j*p-h;l=l*o-g;m=m*p-h;p=1/(k*m-l*j);o=(m*c-j*e)*p;j=(m*d-j*f)*p;c=(k*e-l*c)*p;d=(k*f-l*d)*p;a=a-o*g-c*h;b=b-j*g-d*h;i.save();i.transform(o,j,c,d,a,b);i.clip();i.drawImage(n,0,0);i.restore()}function va(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),h=~~(255*b.g),b=~~(255*b.b),i=~~(255*c.r),j=~~(255*c.g),c=~~(255*c.b),k=~~(255*d.r),l= -~~(255*d.g),d=~~(255*d.b);aa[0]=0>e?0:255f?0:255a?0:255g?0:255h?0:255b?0:255i?0:255j?0:255c?0:255k?0:255l?0:255d?0:255a?0:1D&&k.clearRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight())),0=i||(i*=g.intensity,d.r+=h.r*i,d.g+=h.g*i,d.b+=h.b*i)):g instanceof THREE.PointLight&&(j=g.matrixWorld.getPosition(),i=c.dot(S.sub(j,b).normalize()),0>=i||(i*=0==g.distance?1:1-Math.min(b.distanceTo(j)/g.distance,1),0!=i&&(i*=g.intensity,d.r+=h.r*i,d.g+=h.g*i,d.b+=h.b*i)))}function r(a,f,g){b(g.opacity);c(g.blending);var h,i,j,l,q,o;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)l=g.map.image,q=l.width>>1,o=l.height>> +1,g=f.scale.x*n,j=f.scale.y*p,h=g*q,i=j*o,Y.set(a.x-h,a.y-i,a.x+h,a.y+i),ma.intersects(Y)&&(k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(g,-j),k.translate(-q,-o),k.drawImage(l,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*n,i=f.scale.y*p,Y.set(a.x-h,a.y-i,a.x+h,a.y+i),ma.intersects(Y)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(h,i),g.program(k),k.restore()))}function u(a,e, +f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(H!=a)k.lineWidth=H=a;a=g.linecap;if(A!=a)k.lineCap=A=a;a=g.linejoin;if(F!=a)k.lineJoin=F=a;d(g.color.getContextStyle());k.stroke();Y.inflate(2*g.linewidth)}}function v(a,d,e,g,h,j,k,q){f.info.render.vertices+=3;f.info.render.faces++;b(q.opacity);c(q.blending);N=a.positionScreen.x;P=a.positionScreen.y; +T=d.positionScreen.x;Q=d.positionScreen.y;U=e.positionScreen.x;E=e.positionScreen.y;G(N,P,T,Q,U,E);if(q instanceof THREE.MeshBasicMaterial)if(q.map)q.map.mapping instanceof THREE.UVMapping&&(aa=k.uvs[0],Aa(N,P,T,Q,U,E,aa[g].u,aa[g].v,aa[h].u,aa[h].v,aa[j].u,aa[j].v,q.map));else if(q.envMap){if(q.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=i.matrixWorldInverse,S.copy(k.vertexNormalsWorld[g]),Ba=0.5*(S.x*a.n11+S.y*a.n12+S.z*a.n13)+0.5,Ca=0.5*-(S.x*a.n21+S.y*a.n22+S.z*a.n23)+0.5,S.copy(k.vertexNormalsWorld[h]), +Da=0.5*(S.x*a.n11+S.y*a.n12+S.z*a.n13)+0.5,Ea=0.5*-(S.x*a.n21+S.y*a.n22+S.z*a.n23)+0.5,S.copy(k.vertexNormalsWorld[j]),Fa=0.5*(S.x*a.n11+S.y*a.n12+S.z*a.n13)+0.5,Ga=0.5*-(S.x*a.n21+S.y*a.n22+S.z*a.n23)+0.5,Aa(N,P,T,Q,U,E,Ba,Ca,Da,Ea,Fa,Ga,q.envMap)}else q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshLambertMaterial)q.map&&!q.wireframe&&(q.map.mapping instanceof THREE.UVMapping&&(aa=k.uvs[0],Aa(N,P,T,Q,U,E,aa[g].u,aa[g].v, +aa[h].u,aa[h].v,aa[j].u,aa[j].v,q.map)),c(THREE.SubtractiveBlending)),ya?!q.wireframe&&q.shading==THREE.SmoothShading&&3==k.vertexNormalsWorld.length?(y.r=x.r=C.r=X.r,y.g=x.g=C.g=X.g,y.b=x.b=C.b=X.b,m(l,k.v1.positionWorld,k.vertexNormalsWorld[0],y),m(l,k.v2.positionWorld,k.vertexNormalsWorld[1],x),m(l,k.v3.positionWorld,k.vertexNormalsWorld[2],C),y.r=Math.max(0,Math.min(q.color.r*y.r,1)),y.g=Math.max(0,Math.min(q.color.g*y.g,1)),y.b=Math.max(0,Math.min(q.color.b*y.b,1)),x.r=Math.max(0,Math.min(q.color.r* +x.r,1)),x.g=Math.max(0,Math.min(q.color.g*x.g,1)),x.b=Math.max(0,Math.min(q.color.b*x.b,1)),C.r=Math.max(0,Math.min(q.color.r*C.r,1)),C.g=Math.max(0,Math.min(q.color.g*C.g,1)),C.b=Math.max(0,Math.min(q.color.b*C.b,1)),L.r=0.5*(x.r+C.r),L.g=0.5*(x.g+C.g),L.b=0.5*(x.b+C.b),ea=wa(y,x,C,L),qa(N,P,T,Q,U,E,0,0,1,0,0,1,ea)):(t.r=X.r,t.g=X.g,t.b=X.b,m(l,k.centroidWorld,k.normalWorld,t),t.r=Math.max(0,Math.min(q.color.r*t.r,1)),t.g=Math.max(0,Math.min(q.color.g*t.g,1)),t.b=Math.max(0,Math.min(q.color.b*t.b, +1)),q.wireframe?ja(t,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(t)):q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshDepthMaterial)ga=i.near,ha=i.far,y.r=y.g=y.b=1-pa(a.positionScreen.z,ga,ha),x.r=x.g=x.b=1-pa(d.positionScreen.z,ga,ha),C.r=C.g=C.b=1-pa(e.positionScreen.z,ga,ha),L.r=0.5*(x.r+C.r),L.g=0.5*(x.g+C.g),L.b=0.5*(x.b+C.b),ea=wa(y,x,C,L),qa(N,P,T,Q,U,E,0,0,1,0,0,1,ea);else if(q instanceof THREE.MeshNormalMaterial)t.r= +ra(k.normalWorld.x),t.g=ra(k.normalWorld.y),t.b=ra(k.normalWorld.z),q.wireframe?ja(t,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(t)}function D(a,d,e,g,h,j,k,q,n){f.info.render.vertices+=4;f.info.render.faces++;b(q.opacity);c(q.blending);if(q.map||q.envMap)v(a,d,g,0,1,3,k,q,n),v(h,e,j,1,2,3,k,q,n);else if(N=a.positionScreen.x,P=a.positionScreen.y,T=d.positionScreen.x,Q=d.positionScreen.y,U=e.positionScreen.x,E=e.positionScreen.y,J=g.positionScreen.x,R=g.positionScreen.y,B=h.positionScreen.x, +O=h.positionScreen.y,M=j.positionScreen.x,V=j.positionScreen.y,q instanceof THREE.MeshBasicMaterial)I(N,P,T,Q,U,E,J,R),q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshLambertMaterial)ya?!q.wireframe&&q.shading==THREE.SmoothShading&&4==k.vertexNormalsWorld.length?(y.r=x.r=C.r=L.r=X.r,y.g=x.g=C.g=L.g=X.g,y.b=x.b=C.b=L.b=X.b,m(l,k.v1.positionWorld,k.vertexNormalsWorld[0],y),m(l,k.v2.positionWorld,k.vertexNormalsWorld[1],x), +m(l,k.v4.positionWorld,k.vertexNormalsWorld[3],C),m(l,k.v3.positionWorld,k.vertexNormalsWorld[2],L),y.r=Math.max(0,Math.min(q.color.r*y.r,1)),y.g=Math.max(0,Math.min(q.color.g*y.g,1)),y.b=Math.max(0,Math.min(q.color.b*y.b,1)),x.r=Math.max(0,Math.min(q.color.r*x.r,1)),x.g=Math.max(0,Math.min(q.color.g*x.g,1)),x.b=Math.max(0,Math.min(q.color.b*x.b,1)),C.r=Math.max(0,Math.min(q.color.r*C.r,1)),C.g=Math.max(0,Math.min(q.color.g*C.g,1)),C.b=Math.max(0,Math.min(q.color.b*C.b,1)),L.r=Math.max(0,Math.min(q.color.r* +L.r,1)),L.g=Math.max(0,Math.min(q.color.g*L.g,1)),L.b=Math.max(0,Math.min(q.color.b*L.b,1)),ea=wa(y,x,C,L),G(N,P,T,Q,J,R),qa(N,P,T,Q,J,R,0,0,1,0,0,1,ea),G(B,O,U,E,M,V),qa(B,O,U,E,M,V,1,0,1,1,0,1,ea)):(t.r=X.r,t.g=X.g,t.b=X.b,m(l,k.centroidWorld,k.normalWorld,t),t.r=Math.max(0,Math.min(q.color.r*t.r,1)),t.g=Math.max(0,Math.min(q.color.g*t.g,1)),t.b=Math.max(0,Math.min(q.color.b*t.b,1)),I(N,P,T,Q,U,E,J,R),q.wireframe?ja(t,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(t)):(I(N,P,T, +Q,U,E,J,R),q.wireframe?ja(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color));else if(q instanceof THREE.MeshNormalMaterial)t.r=ra(k.normalWorld.x),t.g=ra(k.normalWorld.y),t.b=ra(k.normalWorld.z),I(N,P,T,Q,U,E,J,R),q.wireframe?ja(t,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(t);else if(q instanceof THREE.MeshDepthMaterial)ga=i.near,ha=i.far,y.r=y.g=y.b=1-pa(a.positionScreen.z,ga,ha),x.r=x.g=x.b=1-pa(d.positionScreen.z,ga,ha),C.r=C.g=C.b=1-pa(g.positionScreen.z, +ga,ha),L.r=L.g=L.b=1-pa(e.positionScreen.z,ga,ha),ea=wa(y,x,C,L),G(N,P,T,Q,J,R),qa(N,P,T,Q,J,R,0,0,1,0,0,1,ea),G(B,O,U,E,M,V),qa(B,O,U,E,M,V,1,0,1,1,0,1,ea)}function G(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function I(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function ja(a,b,c,e){if(H!=b)k.lineWidth=H=b;if(A!=c)k.lineCap=A=c;if(F!=e)k.lineJoin=F=e;d(a.getContextStyle()); +k.stroke();Y.inflate(2*b)}function ia(a){e(a.getContextStyle());k.fill()}function Aa(a,b,c,d,f,g,h,j,i,l,n,o,m){if(0!=m.image.width){if(!0==m.needsUpdate||void 0==la[m.id]){var p=m.wrapS==THREE.RepeatWrapping,r=m.wrapT==THREE.RepeatWrapping;la[m.id]=k.createPattern(m.image,p&&r?"repeat":p&&!r?"repeat-x":!p&&r?"repeat-y":"no-repeat");m.needsUpdate=!1}e(la[m.id]);var p=m.offset.x/m.repeat.x,r=m.offset.y/m.repeat.y,s=m.image.width*m.repeat.x,u=m.image.height*m.repeat.y,h=(h+p)*s,j=(j+r)*u,c=c-a,d=d- +b,f=f-a,g=g-b,i=(i+p)*s-h,l=(l+r)*u-j,n=(n+p)*s-h,o=(o+r)*u-j,p=i*o-n*l;if(0==p){if(void 0===fa[m.id])b=document.createElement("canvas"),b.width=m.image.width,b.height=m.image.height,b=b.getContext("2d"),b.drawImage(m.image,0,0),fa[m.id]=b.getImageData(0,0,m.image.width,m.image.height).data;b=fa[m.id];h=4*(Math.floor(h)+Math.floor(j)*m.image.width);t.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);ia(t)}else p=1/p,m=(o*c-l*f)*p,l=(o*d-l*g)*p,c=(i*f-n*c)*p,d=(i*g-n*d)*p,a=a-m*h-c*j,h=b-l*h-d*j,k.save(),k.transform(m, +l,c,d,a,h),k.fill(),k.restore()}}function qa(a,b,c,d,e,f,g,h,j,i,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;c-=a;d-=b;e-=a;f-=b;j=j*o-g;i=i*p-h;l=l*o-g;m=m*p-h;p=1/(j*m-l*i);o=(m*c-i*e)*p;i=(m*d-i*f)*p;c=(j*e-l*c)*p;d=(j*f-l*d)*p;a=a-o*g-c*h;b=b-i*g-d*h;k.save();k.transform(o,i,c,d,a,b);k.clip();k.drawImage(n,0,0);k.restore()}function wa(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),h=~~(255*b.g),b=~~(255*b.b),i=~~(255*c.r),j=~~(255*c.g),c=~~(255*c.b),k=~~(255*d.r),l= +~~(255*d.g),d=~~(255*d.b);ba[0]=0>e?0:255f?0:255a?0:255g?0:255h?0:255b?0:255i?0:255j?0:255c?0:255k?0:255l?0:255d?0:255a?0:1o-1?e-1:o-1,k=(o+1)%e,p=0>l-1?d-1:l-1,i=(l+1)%d,q=[],x=[0,0,h[4*(o*d+l)]/255*b];q.push([-1,0,h[4*(o*d+p)]/255*b]);q.push([-1,-1,h[4*(n*d+p)]/255*b]);q.push([0,-1, -h[4*(n*d+l)]/255*b]);q.push([1,-1,h[4*(n*d+i)]/255*b]);q.push([1,0,h[4*(o*d+i)]/255*b]);q.push([1,1,h[4*(k*d+i)]/255*b]);q.push([0,1,h[4*(k*d+l)]/255*b]);q.push([-1,1,h[4*(k*d+p)]/255*b]);n=[];p=q.length;for(k=0;ko-1?e-1:o-1,n=(o+1)%e,p=0>i-1?d-1:i-1,k=(i+1)%d,r=[],D=[0,0,h[4*(o*d+i)]/255*b];r.push([-1,0,h[4*(o*d+p)]/255*b]);r.push([-1,-1,h[4*(m*d+p)]/255*b]);r.push([0,-1, +h[4*(m*d+i)]/255*b]);r.push([1,-1,h[4*(m*d+k)]/255*b]);r.push([1,0,h[4*(o*d+k)]/255*b]);r.push([1,1,h[4*(n*d+k)]/255*b]);r.push([0,1,h[4*(n*d+i)]/255*b]);r.push([-1,1,h[4*(n*d+p)]/255*b]);m=[];p=r.length;for(n=0;na;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}; THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3; -THREE.Ray=function(a,b){function c(a,b,c){m.sub(c,a);p=m.dot(b);s=q.add(a,o.copy(b).multiplyScalar(p));return r=c.distanceTo(s)}function d(a,b,c,d){m.sub(d,b);q.sub(c,b);o.sub(a,b);v=m.dot(m);D=m.dot(q);t=m.dot(o);A=q.dot(q);w=q.dot(o);y=1/(v*A-D*D);F=(A*t-D*w)*y;J=(v*w-D*t)*y;return 0<=F&&0<=J&&1>F+J}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;ba.scale.x)return[];b={distance:o,point:a.position,face:null,object:a};m.push(b)}else if(a instanceof THREE.Mesh){var o= -c(this.origin,this.direction,a.matrixWorld.getPosition()),p=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(o>a.geometry.boundingSphere.radius*Math.max(p.x,Math.max(p.y,p.z)))return m;var q,r,t=a.geometry,v=t.vertices,s;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,p=t.faces.length;oMath.abs(q))&&(r=l.dot(j)/q,!(0>r)&&(a.doubleSided||(a.flipSided?0q))))if(n.add(k,i.multiplyScalar(r)),b instanceof THREE.Face3)e=s.multiplyVector3(e.copy(v[b.a].position)),f=s.multiplyVector3(f.copy(v[b.b].position)),g=s.multiplyVector3(g.copy(v[b.c].position)),d(n,e,f,g)&&(b={distance:k.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b));else if(b instanceof THREE.Face4&&(e=s.multiplyVector3(e.copy(v[b.a].position)), -f=s.multiplyVector3(f.copy(v[b.b].position)),g=s.multiplyVector3(g.copy(v[b.c].position)),h=s.multiplyVector3(h.copy(v[b.d].position)),d(n,e,f,h)||d(n,f,g,h)))b={distance:k.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b)}return m};var m=new THREE.Vector3,q=new THREE.Vector3,o=new THREE.Vector3,p,s,r,v,D,t,A,w,y,F,J}; -THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,j,l){h=!1;b=f;c=g;d=j;e=l;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= -function(f,g,j,l,n,m){h?(h=!1,b=fj?f>n?f:n:j>n?j:n,e=g>l?g>m?g:m:l>m?l:m):(b=fj?f>n?f>d?f:d:n>d?n:d:j>n?j>d?j:d:n>d?n:d,e=g>l?g>m?g>e?g:e:m>e?m:e:l>m?l>e?l:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> +THREE.Ray=function(a,b){function c(a,b,c){q.sub(c,a);u=q.dot(b);r=o.add(a,p.copy(b).multiplyScalar(u));return y=c.distanceTo(r)}function d(a,b,c,d){q.sub(d,b);o.sub(c,b);p.sub(a,b);D=q.dot(q);s=q.dot(o);B=q.dot(p);w=o.dot(o);z=o.dot(p);G=1/(D*w-s*s);J=(w*B-s*z)*G;E=(D*z-s*B)*G;return 0<=J&&0<=E&&1>J+E}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;ba.scale.x)return[];b={distance:p,point:a.position,face:null,object:a}; +o.push(b)}else if(a instanceof THREE.Mesh){var p=c(this.origin,this.direction,a.matrixWorld.getPosition()),q=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(p>a.geometry.boundingSphere.radius*Math.max(q.x,Math.max(q.y,q.z)))return o;var r,s,u=a.geometry,y=u.vertices,v;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(p=0,q=u.faces.length;ps)&&(a.doubleSided||(a.flipSided?0r))))if(m.add(i,j.multiplyScalar(s)),b instanceof THREE.Face3)f=v.multiplyVector3(f.copy(y[b.a].position)),g=v.multiplyVector3(g.copy(y[b.b].position)),h=v.multiplyVector3(h.copy(y[b.c].position)),d(m,f,g,h)&&(b={distance:i.distanceTo(m),point:m.clone(),face:b,object:a},o.push(b));else if(b instanceof +THREE.Face4&&(f=v.multiplyVector3(f.copy(y[b.a].position)),g=v.multiplyVector3(g.copy(y[b.b].position)),h=v.multiplyVector3(h.copy(y[b.c].position)),l=v.multiplyVector3(l.copy(y[b.d].position)),d(m,f,g,l)||d(m,g,h,l)))b={distance:i.distanceTo(m),point:m.clone(),face:b,object:a},o.push(b)}return o};var q=new THREE.Vector3,o=new THREE.Vector3,p=new THREE.Vector3,u,r,y,D,s,B,w,z,G,J,E}; +THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,j,k){h=!1;b=f;c=g;d=j;e=k;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= +function(f,g,j,k,n,m){h?(h=!1,b=fj?f>n?f:n:j>n?j:n,e=g>k?g>m?g:m:k>m?k:m):(b=fj?f>n?f>d?f:d:n>d?n:d:j>n?j>d?j:d:n>d?n:d,e=g>k?g>m?g>e?g:e:m>e?m:e:k>m?k>e?k:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=da.getRight()||ea.getBottom()?!1:!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 ae&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(dg&&h.positionScreen.z(z.positionScreen.x-u.positionScreen.x)*(C.positionScreen.y-u.positionScreen.y)-(z.positionScreen.y-u.positionScreen.y)*(C.positionScreen.x-u.positionScreen.x),x.doubleSided|| -N!=x.flipSided)E=n[l]=n[l]||new THREE.RenderableFace3,l++,j=E,j.v1.copy(u),j.v2.copy(C),j.v3.copy(z);else continue;else continue;else if(B instanceof THREE.Face4)if(u=i[B.a],C=i[B.b],z=i[B.c],E=i[B.d],u.visible&&C.visible&&z.visible&&E.visible)if(N=0>(E.positionScreen.x-u.positionScreen.x)*(C.positionScreen.y-u.positionScreen.y)-(E.positionScreen.y-u.positionScreen.y)*(C.positionScreen.x-u.positionScreen.x)||0>(C.positionScreen.x-z.positionScreen.x)*(E.positionScreen.y-z.positionScreen.y)-(C.positionScreen.y- -z.positionScreen.y)*(E.positionScreen.x-z.positionScreen.x),x.doubleSided||N!=x.flipSided)O=q[m]=q[m]||new THREE.RenderableFace4,m++,j=O,j.v1.copy(u),j.v2.copy(C),j.v3.copy(z),j.v4.copy(E);else continue;else continue;j.normalWorld.copy(B.normal);!N&&(x.flipSided||x.doubleSided)&&j.normalWorld.negate();M.multiplyVector3(j.normalWorld);j.centroidWorld.copy(B.centroid);K.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);y.multiplyVector3(j.centroidScreen);z=B.vertexNormals;for(u= -0,C=z.length;uw.z))g=D[v]=D[v]||new THREE.RenderableParticle,v++,r=g,r.x=w.x/w.w,r.y=w.y/w.w,r.z=w.z,r.rotation=x.rotation.z,r.scale.x=x.scale.x*Math.abs(r.x-(w.x+e.projectionMatrix.n11)/(w.w+e.projectionMatrix.n14)),r.scale.y=x.scale.y*Math.abs(r.y-(w.y+e.projectionMatrix.n22)/(w.w+e.projectionMatrix.n24)),r.material=x.material,t.elements.push(r);f&&t.elements.sort(c);return t}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}; +THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=i[l]=i[l]||new THREE.RenderableVertex;l++;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,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(dg&&h.positionScreen.z(A.positionScreen.x-t.positionScreen.x)*(C.positionScreen.y-t.positionScreen.y)-(A.positionScreen.y-t.positionScreen.y)*(C.positionScreen.x-t.positionScreen.x),x.doubleSided|| +N!=x.flipSided)F=n[k]=n[k]||new THREE.RenderableFace3,k++,j=F,j.v1.copy(t),j.v2.copy(C),j.v3.copy(A);else continue;else continue;else if(v instanceof THREE.Face4)if(t=i[v.a],C=i[v.b],A=i[v.c],F=i[v.d],t.visible&&C.visible&&A.visible&&F.visible)if(N=0>(F.positionScreen.x-t.positionScreen.x)*(C.positionScreen.y-t.positionScreen.y)-(F.positionScreen.y-t.positionScreen.y)*(C.positionScreen.x-t.positionScreen.x)||0>(C.positionScreen.x-A.positionScreen.x)*(F.positionScreen.y-A.positionScreen.y)-(C.positionScreen.y- +A.positionScreen.y)*(F.positionScreen.x-A.positionScreen.x),x.doubleSided||N!=x.flipSided)O=q[m]=q[m]||new THREE.RenderableFace4,m++,j=O,j.v1.copy(t),j.v2.copy(C),j.v3.copy(A),j.v4.copy(F);else continue;else continue;j.normalWorld.copy(v.normal);!N&&(x.flipSided||x.doubleSided)&&j.normalWorld.negate();M.multiplyVector3(j.normalWorld);j.centroidWorld.copy(v.centroid);K.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);z.multiplyVector3(j.centroidScreen);A=v.vertexNormals;for(t= +0,C=A.length;tw.z))g=D[y]=D[y]||new THREE.RenderableParticle,y++,r=g,r.x=w.x/w.w,r.y=w.y/w.w,r.z=w.z,r.rotation=x.rotation.z,r.scale.x=x.scale.x*Math.abs(r.x-(w.x+e.projectionMatrix.n11)/(w.w+e.projectionMatrix.n14)),r.scale.y=x.scale.y*Math.abs(r.y-(w.y+e.projectionMatrix.n22)/(w.w+e.projectionMatrix.n24)),r.material=x.material,s.elements.push(r);f&&s.elements.sort(c);return s}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e* f-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=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31? -Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-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);0===a?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,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-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,f=this.x,g=this.y,h=this.z,k=this.w,i=k*c+g*e-h*d,j=k*d+h*c-f*e,l=k*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=i*k+c*-f+j*-h-l*-g;b.y=j*k+c*-g+l*-f-i*-h;b.z=l*k+c*-h+i*-g-j*-f;return b}}; +a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,l=this.w,i=l*c+g*e-h*d,j=l*d+h*c-f*e,k=l*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=i*l+c*-f+j*-h-k*-g;b.y=j*l+c*-g+k*-f-i*-h;b.z=k*l+c*-h+i*-g-j*-f;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;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))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)/e;d=Math.sin(d*f)/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.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,e,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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;bl-1?e-1:l-1,m=(l+1)%e,q=0>j-1?d-1:j-1,o=(j+1)%d,p=[],s=[0,0,h[4*(l*d+j)]/255*b];p.push([-1,0,h[4*(l*d+q)]/255*b]);p.push([-1,-1,h[4*(n*d+q)]/255*b]);p.push([0,-1, -h[4*(n*d+j)]/255*b]);p.push([1,-1,h[4*(n*d+o)]/255*b]);p.push([1,0,h[4*(l*d+o)]/255*b]);p.push([1,1,h[4*(m*d+o)]/255*b]);p.push([0,1,h[4*(m*d+j)]/255*b]);p.push([-1,1,h[4*(m*d+q)]/255*b]);n=[];q=p.length;for(m=0;mk-1?e-1:k-1,m=(k+1)%e,q=0>j-1?d-1:j-1,o=(j+1)%d,p=[],u=[0,0,h[4*(k*d+j)]/255*b];p.push([-1,0,h[4*(k*d+q)]/255*b]);p.push([-1,-1,h[4*(n*d+q)]/255*b]);p.push([0,-1, +h[4*(n*d+j)]/255*b]);p.push([1,-1,h[4*(n*d+o)]/255*b]);p.push([1,0,h[4*(k*d+o)]/255*b]);p.push([1,1,h[4*(m*d+o)]/255*b]);p.push([0,1,h[4*(m*d+j)]/255*b]);p.push([-1,1,h[4*(m*d+q)]/255*b]);n=[];q=p.length;for(m=0;ma;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}; THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3; -THREE.Ray=function(a,b){function c(a,b,c){k.sub(c,a);q=k.dot(b);y=p.add(a,o.copy(b).multiplyScalar(q));return u=c.distanceTo(y)}function d(a,b,c,d){k.sub(d,b);p.sub(c,b);o.sub(a,b);D=k.dot(k);t=k.dot(p);v=k.dot(o);B=p.dot(p);x=p.dot(o);z=1/(D*B-t*t);E=(B*v-t*x)*z;C=(D*x-t*v)*z;return 0<=E&&0<=C&&1>E+C}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;ba.scale.x)return[];b={distance:o,point:a.position,face:null,object:a};k.push(b)}else if(a instanceof THREE.Mesh){var o= -c(this.origin,this.direction,a.matrixWorld.getPosition()),p=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(o>a.geometry.boundingSphere.radius*Math.max(p.x,Math.max(p.y,p.z)))return k;var q,t,v=a.geometry,u=v.vertices,s;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,p=v.faces.length;oMath.abs(q))&&(t=m.dot(j)/q,!(0>t)&&(a.doubleSided||(a.flipSided?0q))))if(n.add(l,i.multiplyScalar(t)),b instanceof THREE.Face3)e=s.multiplyVector3(e.copy(u[b.a].position)),f=s.multiplyVector3(f.copy(u[b.b].position)),g=s.multiplyVector3(g.copy(u[b.c].position)),d(n,e,f,g)&&(b={distance:l.distanceTo(n),point:n.clone(),face:b,object:a},k.push(b));else if(b instanceof THREE.Face4&&(e=s.multiplyVector3(e.copy(u[b.a].position)), -f=s.multiplyVector3(f.copy(u[b.b].position)),g=s.multiplyVector3(g.copy(u[b.c].position)),h=s.multiplyVector3(h.copy(u[b.d].position)),d(n,e,f,h)||d(n,f,g,h)))b={distance:l.distanceTo(n),point:n.clone(),face:b,object:a},k.push(b)}return k};var k=new THREE.Vector3,p=new THREE.Vector3,o=new THREE.Vector3,q,y,u,D,t,v,B,x,z,E,C}; +THREE.Ray=function(a,b){function c(a,b,c){p.sub(c,a);y=p.dot(b);v=o.add(a,q.copy(b).multiplyScalar(y));return D=c.distanceTo(v)}function d(a,b,c,d){p.sub(d,b);o.sub(c,b);q.sub(a,b);t=p.dot(p);u=p.dot(o);B=p.dot(q);x=o.dot(o);z=o.dot(q);E=1/(t*x-u*u);C=(x*B-u*z)*E;F=(t*z-u*B)*E;return 0<=C&&0<=F&&1>C+F}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;ba.scale.x)return[];b={distance:p,point:a.position,face:null,object:a}; +o.push(b)}else if(a instanceof THREE.Mesh){var p=c(this.origin,this.direction,a.matrixWorld.getPosition()),q=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(p>a.geometry.boundingSphere.radius*Math.max(q.x,Math.max(q.y,q.z)))return o;var t,u,v=a.geometry,s=v.vertices,r;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(p=0,q=v.faces.length;pu)&&(a.doubleSided||(a.flipSided?0t))))if(l.add(i,j.multiplyScalar(u)),b instanceof THREE.Face3)f=r.multiplyVector3(f.copy(s[b.a].position)),g=r.multiplyVector3(g.copy(s[b.b].position)),h=r.multiplyVector3(h.copy(s[b.c].position)),d(l,f,g,h)&&(b={distance:i.distanceTo(l),point:l.clone(),face:b,object:a},o.push(b));else if(b instanceof +THREE.Face4&&(f=r.multiplyVector3(f.copy(s[b.a].position)),g=r.multiplyVector3(g.copy(s[b.b].position)),h=r.multiplyVector3(h.copy(s[b.c].position)),k=r.multiplyVector3(k.copy(s[b.d].position)),d(l,f,g,k)||d(l,g,h,k)))b={distance:i.distanceTo(l),point:l.clone(),face:b,object:a},o.push(b)}return o};var p=new THREE.Vector3,o=new THREE.Vector3,q=new THREE.Vector3,y,v,D,t,u,B,x,z,E,C,F}; THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,j,m){h=!1;b=f;c=g;d=j;e=m;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= -function(f,g,j,m,n,k){h?(h=!1,b=fj?f>n?f:n:j>n?j:n,e=g>m?g>k?g:k:m>k?m:k):(b=fj?f>n?f>d?f:d:n>d?n:d:j>n?j>d?j:d:n>d?n:d,e=g>m?g>k?g>e?g:e:k>e?k:e:m>k?m>e?m:e:k>e?k:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> +function(f,g,j,m,n,l){h?(h=!1,b=fj?f>n?f:n:j>n?j:n,e=g>m?g>l?g:l:m>l?m:l):(b=fj?f>n?f>d?f:d:n>d?n:d:j>n?j>d?j:d:n>d?n:d,e=g>m?g>l?g>e?g:e:l>e?l:e:m>l?m>e?m:e:l>e?l:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=da.getRight()||ea.getBottom()?!1:!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 ae&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(dg&&h.positionScreen.z(H.positionScreen.x-w.positionScreen.x)*(G.positionScreen.y-w.positionScreen.y)-(H.positionScreen.y-w.positionScreen.y)*(G.positionScreen.x-w.positionScreen.x),F.doubleSided|| -R!=F.flipSided)K=n[m]=n[m]||new THREE.RenderableFace3,m++,j=K,j.v1.copy(w),j.v2.copy(G),j.v3.copy(H);else continue;else continue;else if(r instanceof THREE.Face4)if(w=i[r.a],G=i[r.b],H=i[r.c],K=i[r.d],w.visible&&G.visible&&H.visible&&K.visible)if(R=0>(K.positionScreen.x-w.positionScreen.x)*(G.positionScreen.y-w.positionScreen.y)-(K.positionScreen.y-w.positionScreen.y)*(G.positionScreen.x-w.positionScreen.x)||0>(G.positionScreen.x-H.positionScreen.x)*(K.positionScreen.y-H.positionScreen.y)-(G.positionScreen.y- -H.positionScreen.y)*(K.positionScreen.x-H.positionScreen.x),F.doubleSided||R!=F.flipSided)S=p[k]=p[k]||new THREE.RenderableFace4,k++,j=S,j.v1.copy(w),j.v2.copy(G),j.v3.copy(H),j.v4.copy(K);else continue;else continue;j.normalWorld.copy(r.normal);!R&&(F.flipSided||F.doubleSided)&&j.normalWorld.negate();P.multiplyVector3(j.normalWorld);j.centroidWorld.copy(r.centroid);N.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);z.multiplyVector3(j.centroidScreen);H=r.vertexNormals;for(w= -0,G=H.length;wx.z))g=t[D]=t[D]||new THREE.RenderableParticle,D++,u=g,u.x=x.x/x.w,u.y=x.y/x.w,u.z=x.z,u.rotation=F.rotation.z,u.scale.x=F.scale.x*Math.abs(u.x-(x.x+e.projectionMatrix.n11)/(x.w+e.projectionMatrix.n14)),u.scale.y=F.scale.y*Math.abs(u.y-(x.y+e.projectionMatrix.n22)/(x.w+e.projectionMatrix.n24)),u.material=F.material,v.elements.push(u);f&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}; +THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=i[k]=i[k]||new THREE.RenderableVertex;k++;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,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(dg&&h.positionScreen.z(I.positionScreen.x-w.positionScreen.x)*(H.positionScreen.y-w.positionScreen.y)-(I.positionScreen.y-w.positionScreen.y)*(H.positionScreen.x-w.positionScreen.x),G.doubleSided|| +R!=G.flipSided)K=n[m]=n[m]||new THREE.RenderableFace3,m++,j=K,j.v1.copy(w),j.v2.copy(H),j.v3.copy(I);else continue;else continue;else if(r instanceof THREE.Face4)if(w=i[r.a],H=i[r.b],I=i[r.c],K=i[r.d],w.visible&&H.visible&&I.visible&&K.visible)if(R=0>(K.positionScreen.x-w.positionScreen.x)*(H.positionScreen.y-w.positionScreen.y)-(K.positionScreen.y-w.positionScreen.y)*(H.positionScreen.x-w.positionScreen.x)||0>(H.positionScreen.x-I.positionScreen.x)*(K.positionScreen.y-I.positionScreen.y)-(H.positionScreen.y- +I.positionScreen.y)*(K.positionScreen.x-I.positionScreen.x),G.doubleSided||R!=G.flipSided)S=p[l]=p[l]||new THREE.RenderableFace4,l++,j=S,j.v1.copy(w),j.v2.copy(H),j.v3.copy(I),j.v4.copy(K);else continue;else continue;j.normalWorld.copy(r.normal);!R&&(G.flipSided||G.doubleSided)&&j.normalWorld.negate();P.multiplyVector3(j.normalWorld);j.centroidWorld.copy(r.centroid);N.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);z.multiplyVector3(j.centroidScreen);I=r.vertexNormals;for(w= +0,H=I.length;wx.z))g=t[D]=t[D]||new THREE.RenderableParticle,D++,v=g,v.x=x.x/x.w,v.y=x.y/x.w,v.z=x.z,v.rotation=G.rotation.z,v.scale.x=G.scale.x*Math.abs(v.x-(x.x+e.projectionMatrix.n11)/(x.w+e.projectionMatrix.n14)),v.scale.y=G.scale.y*Math.abs(v.y-(x.y+e.projectionMatrix.n22)/(x.w+e.projectionMatrix.n24)),v.material=G.material,u.elements.push(v);f&&u.elements.sort(c);return u}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e* f-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=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31? -Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-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);0===a?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,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-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,f=this.x,g=this.y,h=this.z,l=this.w,i=l*c+g*e-h*d,j=l*d+h*c-f*e,m=l*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=i*l+c*-f+j*-h-m*-g;b.y=j*l+c*-g+m*-f-i*-h;b.z=m*l+c*-h+i*-g-j*-f;return b}}; +a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,k=this.w,i=k*c+g*e-h*d,j=k*d+h*c-f*e,m=k*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=i*k+c*-f+j*-h-m*-g;b.y=j*k+c*-g+m*-f-i*-h;b.z=m*k+c*-h+i*-g-j*-f;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;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))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)/e;d=Math.sin(d*f)/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.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};THREE.Face3=function(a,b,c,d,e,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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;be?-1:1,f.vertexTangents[d]=new THREE.Vector4(L.x,L.y,L.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0c.x)c.x=a.x;if(a.yc.y)c.y=a.y;if(a.zc.z)c.z=a.z}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;cb&&(b=a);this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10, @@ -125,7 +125,7 @@ THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this THREE.Texture=function(a,b,c,d,e,f,g,h){this.id=THREE.TextureCount++;this.image=a;this.mapping=void 0!==b?b:new THREE.UVMapping;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==e?e:THREE.LinearFilter;this.minFilter=void 0!==f?f:THREE.LinearMipMapLinearFilter;this.format=void 0!==g?g:THREE.RGBAFormat;this.type=void 0!==h?h:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps= !0;this.needsUpdate=!1;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){}; THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11; -THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(a,b,c,d,e,f,g,h,l,i){THREE.Texture.call(this,null,f,g,h,l,i,d,e);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture; +THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(a,b,c,d,e,f,g,h,k,i){THREE.Texture.call(this,null,f,g,h,k,i,d,e);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture; THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle; THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.type=void 0!==c?c:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;if(b instanceof Array)console.warn("DEPRECATED: Mesh material can no longer be an Array. Using material at index 0..."),this.material=b[0];if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={}; @@ -140,22 +140,22 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog= THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)-1===this.lights.indexOf(a)&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&-1===this.objects.indexOf(a)){this.objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);-1!==b&&this.__objectsRemoved.splice(b,1)}for(b=0;b=j||(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),j=c.dot(E.sub(i,b).normalize()),0>=j||(j*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=j&&(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)))}function b(a){null==C[a]&&(C[a]=document.createElementNS("http://www.w3.org/2000/svg", -"path"),0==M&&C[a].setAttribute("shape-rendering","crispEdges"));return C[a]}function c(a){a=0.5*(a+1);return 0>a?0:1a?0:1m-1?e-1:m-1,k=(m+1)%e,p=0>j-1?d-1:j-1,o=(j+1)%d,q=[],y=[0,0,h[4*(m*d+j)]/255*b];q.push([-1,0,h[4*(m*d+p)]/255*b]);q.push([-1,-1,h[4*(n*d+p)]/255*b]);q.push([0,-1, -h[4*(n*d+j)]/255*b]);q.push([1,-1,h[4*(n*d+o)]/255*b]);q.push([1,0,h[4*(m*d+o)]/255*b]);q.push([1,1,h[4*(k*d+o)]/255*b]);q.push([0,1,h[4*(k*d+j)]/255*b]);q.push([-1,1,h[4*(k*d+p)]/255*b]);n=[];p=q.length;for(k=0;km-1?e-1:m-1,l=(m+1)%e,p=0>j-1?d-1:j-1,o=(j+1)%d,q=[],y=[0,0,h[4*(m*d+j)]/255*b];q.push([-1,0,h[4*(m*d+p)]/255*b]);q.push([-1,-1,h[4*(n*d+p)]/255*b]);q.push([0,-1, +h[4*(n*d+j)]/255*b]);q.push([1,-1,h[4*(n*d+o)]/255*b]);q.push([1,0,h[4*(m*d+o)]/255*b]);q.push([1,1,h[4*(l*d+o)]/255*b]);q.push([0,1,h[4*(l*d+j)]/255*b]);q.push([-1,1,h[4*(l*d+p)]/255*b]);n=[];p=q.length;for(l=0;la;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}; THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3; -THREE.Ray=function(a,b){function c(a,b,c){q.sub(c,a);p=q.dot(b);y=r.add(a,o.copy(b).multiplyScalar(p));return u=c.distanceTo(y)}function d(a,b,c,d){q.sub(d,b);r.sub(c,b);o.sub(a,b);K=q.dot(q);A=q.dot(r);v=q.dot(o);I=r.dot(r);B=r.dot(o);E=1/(K*I-A*A);L=(I*v-A*B)*E;J=(K*B-A*v)*E;return 0<=L&&0<=J&&1>L+J}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;ba.scale.x)return[];b={distance:q,point:a.position,face:null,object:a};r.push(b)}else if(a instanceof THREE.Mesh){var q= -c(this.origin,this.direction,a.matrixWorld.getPosition()),o=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(q>a.geometry.boundingSphere.radius*Math.max(o.x,Math.max(o.y,o.z)))return r;var p,y,f=a.geometry,u=f.vertices,v;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(q=0,o=f.faces.length;qMath.abs(p))&&(y=n.dot(j)/p,!(0>y)&&(a.doubleSided||(a.flipSided?0p))))if(m.add(k,l.multiplyScalar(y)),b instanceof THREE.Face3)e=v.multiplyVector3(e.copy(u[b.a].position)),g=v.multiplyVector3(g.copy(u[b.b].position)),h=v.multiplyVector3(h.copy(u[b.c].position)),d(m,e,g,h)&&(b={distance:k.distanceTo(m),point:m.clone(),face:b,object:a},r.push(b));else if(b instanceof THREE.Face4&&(e=v.multiplyVector3(e.copy(u[b.a].position)), -g=v.multiplyVector3(g.copy(u[b.b].position)),h=v.multiplyVector3(h.copy(u[b.c].position)),i=v.multiplyVector3(i.copy(u[b.d].position)),d(m,e,g,i)||d(m,g,h,i)))b={distance:k.distanceTo(m),point:m.clone(),face:b,object:a},r.push(b)}return r};var q=new THREE.Vector3,r=new THREE.Vector3,o=new THREE.Vector3,p,y,u,K,A,v,I,B,E,L,J}; +THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);u=o.dot(b);w=p.add(a,q.copy(b).multiplyScalar(u));return J=c.distanceTo(w)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);q.sub(a,b);A=o.dot(o);x=o.dot(p);I=o.dot(q);H=p.dot(p);D=p.dot(q);M=1/(A*H-x*x);K=(H*I-x*D)*M;N=(A*D-x*I)*M;return 0<=K&&0<=N&&1>K+N}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;ba.scale.x)return[];b={distance:p,point:a.position,face:null,object:a}; +o.push(b)}else if(a instanceof THREE.Mesh){var p=c(this.origin,this.direction,a.matrixWorld.getPosition()),q=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(p>a.geometry.boundingSphere.radius*Math.max(q.x,Math.max(q.y,q.z)))return o;var u,f,w=a.geometry,x=w.vertices,A;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(p=0,q=w.faces.length;pf)&&(a.doubleSided||(a.flipSided?0u))))if(r.add(k,j.multiplyScalar(f)),b instanceof THREE.Face3)g=A.multiplyVector3(g.copy(x[b.a].position)),h=A.multiplyVector3(h.copy(x[b.b].position)),i=A.multiplyVector3(i.copy(x[b.c].position)),d(r,g,h,i)&&(b={distance:k.distanceTo(r),point:r.clone(),face:b,object:a},o.push(b));else if(b instanceof +THREE.Face4&&(g=A.multiplyVector3(g.copy(x[b.a].position)),h=A.multiplyVector3(h.copy(x[b.b].position)),i=A.multiplyVector3(i.copy(x[b.c].position)),m=A.multiplyVector3(m.copy(x[b.d].position)),d(r,g,h,m)||d(r,h,i,m)))b={distance:k.distanceTo(r),point:r.clone(),face:b,object:a},o.push(b)}return o};var o=new THREE.Vector3,p=new THREE.Vector3,q=new THREE.Vector3,u,w,J,A,x,I,H,D,M,K,N}; THREE.Rectangle=function(){function a(){g=d-b;h=e-c}var b,c,d,e,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 e};this.set=function(g,h,j,n){i=!1;b=g;c=h;d=j;e=n;a()};this.addPoint=function(g,h){i?(i=!1,b=g,c=h,d=g,e=h):(b=bg?d:g,e=e>h?e:h);a()};this.add3Points= -function(g,h,j,n,m,q){i?(i=!1,b=gj?g>m?g:m:j>m?j:m,e=h>n?h>q?h:q:n>q?n:q):(b=gj?g>m?g>d?g:d:m>d?m:d:j>m?j>d?j:d:m>d?m:d,e=h>n?h>q?h>e?h:e:q>e?q:e:n>q?n>e?n:e:q>e?q:e);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),e=g.getBottom()):(b=bg.getRight()?d:g.getRight(),e=e> +function(g,h,j,n,l,r){i?(i=!1,b=gj?g>l?g:l:j>l?j:l,e=h>n?h>r?h:r:n>r?n:r):(b=gj?g>l?g>d?g:d:l>d?l:d:j>l?j>d?j:d:l>d?l:d,e=h>n?h>r?h>e?h:e:r>e?r:e:n>r?n>e?n:e:r>e?r:e);a()};this.addRectangle=function(g){i?(i=!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=da.getRight()||ea.getBottom()?!1:!0};this.empty=function(){i=!0;e=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 ae&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(dh&&i.positionScreen.z(ta.positionScreen.x-M.positionScreen.x)*(aa.positionScreen.y-M.positionScreen.y)-(ta.positionScreen.y-M.positionScreen.y)*(aa.positionScreen.x-M.positionScreen.x), -T.doubleSided||f!=T.flipSided)xa=m[n]=m[n]||new THREE.RenderableFace3,n++,j=xa,j.v1.copy(M),j.v2.copy(aa),j.v3.copy(ta);else continue;else continue;else if(S instanceof THREE.Face4)if(M=l[S.a],aa=l[S.b],ta=l[S.c],xa=l[S.d],M.visible&&aa.visible&&ta.visible&&xa.visible)if(f=0>(xa.positionScreen.x-M.positionScreen.x)*(aa.positionScreen.y-M.positionScreen.y)-(xa.positionScreen.y-M.positionScreen.y)*(aa.positionScreen.x-M.positionScreen.x)||0>(aa.positionScreen.x-ta.positionScreen.x)*(xa.positionScreen.y- -ta.positionScreen.y)-(aa.positionScreen.y-ta.positionScreen.y)*(xa.positionScreen.x-ta.positionScreen.x),T.doubleSided||f!=T.flipSided)Ma=r[q]=r[q]||new THREE.RenderableFace4,q++,j=Ma,j.v1.copy(M),j.v2.copy(aa),j.v3.copy(ta),j.v4.copy(xa);else continue;else continue;j.normalWorld.copy(S.normal);!f&&(T.flipSided||T.doubleSided)&&j.normalWorld.negate();Ga.multiplyVector3(j.normalWorld);j.centroidWorld.copy(S.centroid);Aa.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);E.multiplyVector3(j.centroidScreen); -ta=S.vertexNormals;for(M=0,aa=ta.length;MB.z))h=A[K]=A[K]||new THREE.RenderableParticle,K++,u=h,u.x=B.x/B.w,u.y=B.y/B.w,u.z=B.z,u.rotation=T.rotation.z,u.scale.x=T.scale.x*Math.abs(u.x-(B.x+e.projectionMatrix.n11)/(B.w+e.projectionMatrix.n14)),u.scale.y=T.scale.y*Math.abs(u.y-(B.y+e.projectionMatrix.n22)/(B.w+e.projectionMatrix.n24)),u.material=T.material,v.elements.push(u);g&&v.elements.sort(c);return v}}; +THREE.Projector=function(){function a(){var a=h[g]=h[g]||new THREE.RenderableObject;g++;return a}function b(){var a=k[m]=k[m]||new THREE.RenderableVertex;m++;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,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(dh&&i.positionScreen.z(ta.positionScreen.x-L.positionScreen.x)*(aa.positionScreen.y-L.positionScreen.y)-(ta.positionScreen.y-L.positionScreen.y)*(aa.positionScreen.x-L.positionScreen.x), +T.doubleSided||f!=T.flipSided)xa=l[n]=l[n]||new THREE.RenderableFace3,n++,j=xa,j.v1.copy(L),j.v2.copy(aa),j.v3.copy(ta);else continue;else continue;else if(S instanceof THREE.Face4)if(L=k[S.a],aa=k[S.b],ta=k[S.c],xa=k[S.d],L.visible&&aa.visible&&ta.visible&&xa.visible)if(f=0>(xa.positionScreen.x-L.positionScreen.x)*(aa.positionScreen.y-L.positionScreen.y)-(xa.positionScreen.y-L.positionScreen.y)*(aa.positionScreen.x-L.positionScreen.x)||0>(aa.positionScreen.x-ta.positionScreen.x)*(xa.positionScreen.y- +ta.positionScreen.y)-(aa.positionScreen.y-ta.positionScreen.y)*(xa.positionScreen.x-ta.positionScreen.x),T.doubleSided||f!=T.flipSided)Ma=o[r]=o[r]||new THREE.RenderableFace4,r++,j=Ma,j.v1.copy(L),j.v2.copy(aa),j.v3.copy(ta),j.v4.copy(xa);else continue;else continue;j.normalWorld.copy(S.normal);!f&&(T.flipSided||T.doubleSided)&&j.normalWorld.negate();Ga.multiplyVector3(j.normalWorld);j.centroidWorld.copy(S.centroid);Aa.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);D.multiplyVector3(j.centroidScreen); +ta=S.vertexNormals;for(L=0,aa=ta.length;LH.z))h=A[J]=A[J]||new THREE.RenderableParticle,J++,w=h,w.x=H.x/H.w,w.y=H.y/H.w,w.z=H.z,w.rotation=T.rotation.z,w.scale.x=T.scale.x*Math.abs(w.x-(H.x+e.projectionMatrix.n11)/(H.w+e.projectionMatrix.n14)),w.scale.y=T.scale.y*Math.abs(w.y-(H.y+e.projectionMatrix.n22)/(H.w+e.projectionMatrix.n24)),w.material=T.material,x.elements.push(w);g&&x.elements.sort(c);return x}}; THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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),h=a*b,i=d*e;this.w=h*g-i*c;this.x=h*c+i*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=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31? -Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-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);0===a?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,h=a.y,i=a.z,a=a.w;this.x=b*a+e*g+c*i-d*h;this.y=c*a+e*h+d*g-b*i;this.z=d*a+e*i+b*h-c*g;this.w=e*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,e=a.z,g=this.x,h=this.y,i=this.z,k=this.w,l=k*c+h*e-i*d,j=k*d+i*c-g*e,n=k*e+g*d-h*c,c=-g*c-h*d-i*e;b.x=l*k+c*-g+j*-i-n*-h;b.y=j*k+c*-h+n*-g-l*-i;b.z=n*k+c*-i+l*-h-j*-g;return b}}; +a);var c=a.x,d=a.y,e=a.z,g=this.x,h=this.y,i=this.z,m=this.w,k=m*c+h*e-i*d,j=m*d+i*c-g*e,n=m*e+g*d-h*c,c=-g*c-h*d-i*e;b.x=k*m+c*-g+j*-i-n*-h;b.y=j*m+c*-h+n*-g-k*-i;b.z=n*m+c*-i+k*-h-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;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))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(0.0010>Math.abs(e))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.Vertex.prototype={constructor:THREE.Vertex,clone:function(){return new THREE.Vertex(this.position.clone())}};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.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;for(b=0,c=this.vertexNormals.length;be?-1:1,g.vertexTangents[d]=new THREE.Vector4(oa.x,oa.y,oa.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0e?-1:1,g.vertexTangents[d]=new THREE.Vector4(oa.x,oa.y,oa.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0c.x)c.x=a.x;if(a.yc.y)c.y=a.y;if(a.zc.z)c.z=a.z}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};for(var a,b=0,c=0,d=this.vertices.length;cb&&(b=a);this.boundingSphere.radius=b},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10, 4),g,h;for(g=0,h=this.vertices.length;gthis.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]]; -n=this.points[c[2]];m=this.points[c[3]];i=h*h;k=h*i;d.x=b(l.x,j.x,n.x,m.x,h,i,k);d.y=b(l.y,j.y,n.y,m.y,h,i,k);d.z=b(l.z,j.z,n.z,m.z,h,i,k);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;k=this.points[c[0]];j=this.points[c[1]]; +n=this.points[c[2]];l=this.points[c[3]];i=h*h;m=h*i;d.x=b(k.x,j.x,n.x,l.x,h,i,m);d.y=b(k.y,j.y,n.y,l.y,h,i,m);d.z=b(k.z,j.z,n.z,l.z,h,i,m);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif", -lights_lambert_vertex:"vLightWeighting = vec3( 0.0 );\ntransformedNormal = normalize( transformedNormal );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\n#ifdef WRAP_AROUND\nfloat directionalLightWeightingFull = max( dot( transformedNormal, dirVector ), 0.0 );\nfloat directionalLightWeightingHalf = max( 0.5 * dot( transformedNormal, dirVector ) + 0.5, 0.0 );\nvec3 directionalLightWeighting = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );\n#else\nfloat directionalLightWeighting = max( dot( transformedNormal, dirVector ), 0.0 );\n#endif\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#ifdef WRAP_AROUND\nfloat pointLightWeightingFull = max( dot( transformedNormal, lVector ), 0.0 );\nfloat pointLightWeightingHalf = max( 0.5 * dot( transformedNormal, lVector ) + 0.5, 0.0 );\nvec3 pointLightWeighting = mix( vec3 ( pointLightWeightingFull ), vec3( pointLightWeightingHalf ), wrapRGB );\n#else\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\n#endif\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n}\n#endif\nvLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;", +lights_lambert_vertex:"vLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\nvLightBack = vec3( 0.0 );\n#endif\ntransformedNormal = normalize( transformedNormal );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( transformedNormal, dirVector );\nvec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\ndirectionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\ndirectionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += directionalLightColor[ i ] * directionalLightWeighting;\n#ifdef DOUBLE_SIDED\nvLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;\n#endif\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nfloat dotProduct = dot( transformedNormal, lVector );\nvec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );\n#ifdef DOUBLE_SIDED\nvec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );\n#endif\n#endif\n#ifdef WRAP_AROUND\nvec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );\npointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );\n#ifdef DOUBLE_SIDED\npointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );\n#endif\n#endif\nvLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;\n#ifdef DOUBLE_SIDED\nvLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;\n#endif\n}\n#endif\nvLightFront = vLightFront * diffuse + ambient * ambientLightColor;\n#ifdef DOUBLE_SIDED\nvLightBack = vLightBack * diffuse + ambient * ambientLightColor;\n#endif", lights_phong_pars_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif",lights_phong_vertex:"#if MAX_POINT_LIGHTS > 0\n#ifndef PHONG_PER_PIXEL\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#endif", lights_phong_pars_fragment:"uniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\n#ifdef PHONG_PER_PIXEL\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#else\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;", -lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vPointLight[ i ].xyz );\nfloat lDistance = vPointLight[ i ].w;\n#endif\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dot( normal, lVector ), 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, lVector ) + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dot( normal, lVector ), 0.0 );\n#endif\npointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = max( pow( pointDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#endif\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\n#ifdef WRAP_AROUND\nfloat dirDiffuseWeightFull = max( dot( normal, dirVector ), 0.0 );\nfloat dirDiffuseWeightHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\n#endif\ndirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = max( pow( dirDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif", +lights_phong_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#ifdef DOUBLE_SIDED\nnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n#endif\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\n#ifdef PHONG_PER_PIXEL\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz + vViewPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\n#else\nvec3 lVector = normalize( vPointLight[ i ].xyz );\nfloat lDistance = vPointLight[ i ].w;\n#endif\nfloat dotProduct = dot( normal, lVector );\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dotProduct, 0.0 );\n#endif\npointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * lDistance;\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = max( pow( pointDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * lDistance;\n#endif\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nfloat dotProduct = dot( normal, dirVector );\n#ifdef WRAP_AROUND\nfloat dirDiffuseWeightFull = max( dotProduct, 0.0 );\nfloat dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dotProduct, 0.0 );\n#endif\ndirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = max( pow( dirDotNormalHalf, shininess ), 0.0 );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( dirVector, dirHalfVector ), 5.0 );\ndirSpecular += schlick * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#else\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight * dirDiffuseWeight;\n#endif\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\n#ifdef METAL\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient + totalSpecular );\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * ambient ) + totalSpecular;\n#endif", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n#ifdef GAMMA_INPUT\nvColor = color * color;\n#else\nvColor = color;\n#endif\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * modelViewMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n#ifndef USE_MORPHNORMALS\nuniform float morphTargetInfluences[ 8 ];\n#else\nuniform float morphTargetInfluences[ 4 ];\n#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n#ifndef USE_MORPHNORMALS\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n#endif\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif", default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\nvec3 morphedNormal = vec3( 0.0 );\nmorphedNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\nmorphedNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\nmorphedNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\nmorphedNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\nmorphedNormal += normal;\nvec3 transformedNormal = normalMatrix * morphedNormal;\n#else\nvec3 transformedNormal = normalMatrix * normal;\n#endif", @@ -180,139 +181,139 @@ THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value: value:1}},vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}",fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}"},basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.shadowmap]),vertexShader:[THREE.ShaderChunk.map_pars_vertex, THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex, THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment, -THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["varying vec3 vLightWeighting;", +THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["varying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif", THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_lambert_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex, -THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment, -"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,"gl_FragColor.xyz = gl_FragColor.xyz * vLightWeighting;",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog, -THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["varying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_phong_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex, -THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = -mvPosition.xyz;",THREE.ShaderChunk.morphnormal_vertex,"vNormal = transformedNormal;",THREE.ShaderChunk.lights_phong_vertex, -THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_phong_pars_fragment, -THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle, -THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;", -THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", -THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}}; +THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\nvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment, +THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,"#ifdef DOUBLE_SIDED\nif ( gl_FrontFacing )\ngl_FragColor.xyz *= vLightFront;\nelse\ngl_FragColor.xyz *= vLightBack;\n#else\ngl_FragColor.xyz *= vLightFront;\n#endif",THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment, +THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.fog,THREE.UniformsLib.lights,THREE.UniformsLib.shadowmap,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30},wrapRGB:{type:"v3",value:new THREE.Vector3(1,1,1)}}]),vertexShader:["varying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex, +THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_phong_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = -mvPosition.xyz;", +THREE.ShaderChunk.morphnormal_vertex,"vNormal = transformedNormal;",THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment, +THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_phong_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3 ( 1.0 ), opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment, +THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;", +THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment, +"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}}; THREE.WebGLRenderer=function(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(void 0===a.__webglCustomAttributesList)a.__webglCustomAttributesList=[];for(var e in d.attributes){var g=d.attributes[e];if(!g.__webglInitialized||g.createUniqueBuffers){g.__webglInitialized=!0;var h=1;"v2"===g.type?h=2:"v3"===g.type?h=3:"v4"===g.type?h=4:"c"===g.type&&(h=3);g.size=h;g.array=new Float32Array(c*h);g.buffer=f.createBuffer();g.buffer.belongsToAttribute=e;g.needsUpdate=!0}a.__webglCustomAttributesList.push(g)}}} function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(0<=b.materialIndex)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?!0:!1}function g(a,b,c){var d,e,g,h,i=a.vertices;h=i.length; -var j=a.colors,m=j.length,l=a.__vertexArray,k=a.__colorArray,n=a.__sortArray,o=a.__dirtyVertices,q=a.__dirtyColors,r=a.__webglCustomAttributesList;if(c.sortParticles){Xa.multiplySelf(c.matrixWorld);for(d=0;dk;k++){n=l;p=k;if(D.autoScaleCubemaps){if(u=i.image[k],v=Ec,!(u.width<=v&&u.height<=v))A=Math.max(u.width, -u.height),y=Math.floor(u.width*v/A),v=Math.floor(u.height*v/A),A=document.createElement("canvas"),A.width=y,A.height=v,A.getContext("2d").drawImage(u,0,0,u.width,u.height,0,0,y,v),u=A}else u=i.image[k];n[p]=u}k=l[0];n=0===(k.width&k.width-1)&&0===(k.height&k.height-1);p=I(i.format);u=I(i.type);K(f.TEXTURE_CUBE_MAP,i,n);for(k=0;6>k;k++)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,p,p,u,l[k]);i.generateMipmaps&&n&&f.generateMipmap(f.TEXTURE_CUBE_MAP);i.needsUpdate=!1;if(i.onUpdated)i.onUpdated()}else f.activeTexture(f.TEXTURE0+ -l),f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube)}else k instanceof THREE.WebGLRenderTargetCube?(i=k,f.activeTexture(f.TEXTURE0+l),f.bindTexture(f.TEXTURE_CUBE_MAP,i.__webglTexture)):D.setTexture(k,l)}else if("tv"===n){if(!i._array){i._array=[];for(n=0,p=i.texture.length;nm;m++){n=l;q=m;if(C.autoScaleCubemaps){if(u=i.image[m],x=Ec,!(u.width<=x&&u.height<=x))A=Math.max(u.width, +u.height),w=Math.floor(u.width*x/A),x=Math.floor(u.height*x/A),A=document.createElement("canvas"),A.width=w,A.height=x,A.getContext("2d").drawImage(u,0,0,u.width,u.height,0,0,w,x),u=A}else u=i.image[m];n[q]=u}m=l[0];n=0===(m.width&m.width-1)&&0===(m.height&m.height-1);q=I(i.format);u=I(i.type);J(f.TEXTURE_CUBE_MAP,i,n);for(m=0;6>m;m++)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,q,q,u,l[m]);i.generateMipmaps&&n&&f.generateMipmap(f.TEXTURE_CUBE_MAP);i.needsUpdate=!1;if(i.onUpdated)i.onUpdated()}else f.activeTexture(f.TEXTURE0+ +l),f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube)}else m instanceof THREE.WebGLRenderTargetCube?(i=m,f.activeTexture(f.TEXTURE0+l),f.bindTexture(f.TEXTURE_CUBE_MAP,i.__webglTexture)):C.setTexture(m,l)}else if("tv"===n){if(!i._array){i._array=[];for(n=0,q=i.texture.length;nl&&(m=k,l=i[m]);f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[m]);f.vertexAttribPointer(c["morphTarget"+h],3,f.FLOAT,!1,0,0);d.morphNormals&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[m]),f.vertexAttribPointer(c["morphNormal"+ -h],3,f.FLOAT,!1,0,0));g.__webglMorphTargetInfluences[h]=l;j[m]=1;l=-1;h++}}null!==d.program.uniforms.morphTargetInfluences&&f.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(h=0,i=e.__webglCustomAttributesList.length;hl&&(k=m,l=i[k]);f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[k]);f.vertexAttribPointer(c["morphTarget"+h],3,f.FLOAT,!1,0,0);d.morphNormals&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[k]),f.vertexAttribPointer(c["morphNormal"+ +h],3,f.FLOAT,!1,0,0));g.__webglMorphTargetInfluences[h]=l;j[k]=1;l=-1;h++}}null!==d.program.uniforms.morphTargetInfluences&&f.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(h=0,i=e.__webglCustomAttributesList.length;hU;U++)Bb=Rb[U],Qa[za]=Bb.x,Qa[za+1]=Bb.y,Qa[za+2]=Bb.z,za+=3;else for(U=0;3>U;U++)Qa[za]=ub.x,Qa[za+1]=ub.y,Qa[za+2]=ub.z,za+=3;for(w=0,C=W.length;wU;U++)Bb=Rb[U],Qa[za]=Bb.x,Qa[za+1]=Bb.y,Qa[za+2]=Bb.z,za+=3;else for(U=0;4>U;U++)Qa[za]=ub.x,Qa[za+1]=ub.y,Qa[za+2]=ub.z,za+=3; -f.bindBuffer(f.ARRAY_BUFFER,P.__webglNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Qa,Ia)}if(Uc&&Mc&&Rc){for(w=0,C=V.length;wU;U++)Ub=Sb[U],fc[qb]=Ub.u,fc[qb+1]=Ub.v,qb+=2;for(w=0,C=W.length;wU;U++)Ub=Sb[U],fc[qb]=Ub.u,fc[qb+1]=Ub.v,qb+=2;0U;U++)Vb=Tb[U],gc[rb]=Vb.u,gc[rb+1]=Vb.v,rb+=2;for(w=0,C=W.length;wU;U++)Vb=Tb[U],gc[rb]=Vb.u,gc[rb+1]=Vb.v,rb+=2;0U;U++)Bb=Rb[U],Qa[za]=Bb.x,Qa[za+1]=Bb.y,Qa[za+2]=Bb.z,za+=3;else for(U=0;3>U;U++)Qa[za]=ub.x,Qa[za+1]=ub.y,Qa[za+2]=ub.z,za+=3;for(v=0,B=W.length;vU;U++)Bb=Rb[U],Qa[za]=Bb.x,Qa[za+1]=Bb.y,Qa[za+2]=Bb.z,za+=3;else for(U=0;4>U;U++)Qa[za]=ub.x,Qa[za+1]=ub.y,Qa[za+2]=ub.z,za+=3; +f.bindBuffer(f.ARRAY_BUFFER,P.__webglNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Qa,Ia)}if(Uc&&Mc&&Rc){for(v=0,B=V.length;vU;U++)Ub=Sb[U],fc[qb]=Ub.u,fc[qb+1]=Ub.v,qb+=2;for(v=0,B=W.length;vU;U++)Ub=Sb[U],fc[qb]=Ub.u,fc[qb+1]=Ub.v,qb+=2;0U;U++)Vb=Tb[U],gc[rb]=Vb.u,gc[rb+1]=Vb.v,rb+=2;for(v=0,B=W.length;vU;U++)Vb=Tb[U],gc[rb]=Vb.u,gc[rb+1]=Vb.v,rb+=2;0c;c++){a.__webglFramebuffer[c]=f.createFramebuffer();a.__webglRenderbuffer[c]=f.createRenderbuffer();f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+ -c,0,d,a.width,a.height,0,d,e,null);var g=a,h=f.TEXTURE_CUBE_MAP_POSITIVE_X+c;f.bindFramebuffer(f.FRAMEBUFFER,a.__webglFramebuffer[c]);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,h,g.__webglTexture,0);A(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=f.createFramebuffer(),a.__webglRenderbuffer=f.createRenderbuffer(),f.bindTexture(f.TEXTURE_2D,a.__webglTexture),K(f.TEXTURE_2D,a,c),f.texImage2D(f.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=f.TEXTURE_2D,f.bindFramebuffer(f.FRAMEBUFFER, -a.__webglFramebuffer),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,d,a.__webglTexture,0),A(a.__webglRenderbuffer,a);b?f.bindTexture(f.TEXTURE_CUBE_MAP,null):f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=Hb,a=Ob,e=Nb,c=Xb);b!==S&&(f.bindFramebuffer(f.FRAMEBUFFER,b),f.viewport(e,c,d,a),S=b);lc=d;mc=a};this.shadowMapPlugin= -new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; +ba.array[ia+2]=Fa.z,ia+=3;else if(4===ba.size)for(ya=0;yac;c++){a.__webglFramebuffer[c]= +f.createFramebuffer();a.__webglRenderbuffer[c]=f.createRenderbuffer();f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,0,d,e,null);var g=a,h=f.TEXTURE_CUBE_MAP_POSITIVE_X+c;f.bindFramebuffer(f.FRAMEBUFFER,a.__webglFramebuffer[c]);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,h,g.__webglTexture,0);A(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=f.createFramebuffer(),a.__webglRenderbuffer=f.createRenderbuffer(),f.bindTexture(f.TEXTURE_2D,a.__webglTexture),J(f.TEXTURE_2D, +a,c),f.texImage2D(f.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=f.TEXTURE_2D,f.bindFramebuffer(f.FRAMEBUFFER,a.__webglFramebuffer),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,d,a.__webglTexture,0),A(a.__webglRenderbuffer,a);b?f.bindTexture(f.TEXTURE_CUBE_MAP,null):f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=Hb,a= +Ob,e=Nb,c=Xb);b!==S&&(f.bindFramebuffer(f.FRAMEBUFFER,b),f.viewport(e,c,d,a),S=b);lc=d;mc=a};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=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format:THREE.RGBAFormat;this.type=void 0!==c.type?c.type: THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!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}; @@ -333,18 +334,18 @@ THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[] THREE.LensFlare.prototype.add=function(a,b,c,d,e,g){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===g&&(g=1);void 0===e&&(e=new THREE.Color(16777215));if(void 0===d)d=THREE.NormalBlending;c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:g,color:e,blending:d})}; THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,e=2*-this.positionScreen.y;for(a=0;a=this.maxCount-3&&i(this)};this.begin=function(){this.count=0; -this.hasNormal=this.hasPos=!1};this.end=function(a){if(0!==this.count){for(var b=3*this.count;bn&&(n=1);k=Math.floor(k+i);k>this.size-1&&(k=this.size-1);var m=Math.floor(l-i);1>m&&(m=1);l=Math.floor(l+i);l>this.size-1&&(l=this.size-1);var q=Math.floor(j-i);1>q&&(q=1);i=Math.floor(j+i);i>this.size-1&&(i=this.size- -1);for(var r,o,p,y,u,K,A,j=n;jl&&(q=l);for(e=0;ej&&(r=j);for(g=0;gj&&(r=j);for(h=0;h=this.maxCount-3&&i(this)};this.begin=function(){this.count=0; +this.hasNormal=this.hasPos=!1};this.end=function(a){if(0!==this.count){for(var b=3*this.count;bn&&(n=1);m=Math.floor(m+i);m>this.size-1&&(m=this.size-1);var l=Math.floor(k-i);1>l&&(l=1);k=Math.floor(k+i);k>this.size-1&&(k=this.size-1);var r=Math.floor(j-i);1>r&&(r=1);i=Math.floor(j+i);i>this.size-1&&(i=this.size- +1);for(var o,p,q,u,w,J,A,j=n;jk&&(r=k);for(e=0;ej&&(o=j);for(g=0;gj&&(o=j);for(h=0;h=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(l=!1,j=a(THREE.ShaderFlares.lensFlare)):(l=!0,j=a(THREE.ShaderFlares.lensFlareVertexTexture));n={};m={};n.vertex=b.getAttribLocation(j,"position");n.uv=b.getAttribLocation(j,"uv");m.renderType=b.getUniformLocation(j,"renderType");m.map=b.getUniformLocation(j,"map");m.occlusionMap=b.getUniformLocation(j,"occlusionMap");m.opacity=b.getUniformLocation(j,"opacity");m.color=b.getUniformLocation(j, -"color");m.scale=b.getUniformLocation(j,"scale");m.rotation=b.getUniformLocation(j,"rotation");m.screenPosition=b.getUniformLocation(j,"screenPosition");q=!1};this.render=function(a,d,e,y){var a=a.__webglFlares,u=a.length;if(u){var K=new THREE.Vector3,A=y/e,v=0.5*e,I=0.5*y,B=16/y,E=new THREE.Vector2(B*A,B),L=new THREE.Vector3(1,1,0),J=new THREE.Vector2(1,1),N=m,B=n;b.useProgram(j);q||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),q=!0);b.uniform1i(N.occlusionMap,0);b.uniform1i(N.map, -1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(B.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(B.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var ja,oa,ka,X,$;for(ja=0;ja=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(k=!1,j=a(THREE.ShaderFlares.lensFlare)):(k=!0,j=a(THREE.ShaderFlares.lensFlareVertexTexture));n={};l={};n.vertex=b.getAttribLocation(j,"position");n.uv=b.getAttribLocation(j,"uv");l.renderType=b.getUniformLocation(j,"renderType");l.map=b.getUniformLocation(j,"map");l.occlusionMap=b.getUniformLocation(j,"occlusionMap");l.opacity=b.getUniformLocation(j,"opacity");l.color=b.getUniformLocation(j, +"color");l.scale=b.getUniformLocation(j,"scale");l.rotation=b.getUniformLocation(j,"rotation");l.screenPosition=b.getUniformLocation(j,"screenPosition");r=!1};this.render=function(a,d,e,u){var a=a.__webglFlares,w=a.length;if(w){var J=new THREE.Vector3,A=u/e,x=0.5*e,I=0.5*u,H=16/u,D=new THREE.Vector2(H*A,H),M=new THREE.Vector3(1,1,0),K=new THREE.Vector2(1,1),N=l,H=n;b.useProgram(j);r||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),r=!0);b.uniform1i(N.occlusionMap,0);b.uniform1i(N.map, +1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(H.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(H.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var ja,oa,ka,X,$;for(ja=0;jav;v++)y[v]=new THREE.Vector3,o[v]=new THREE.Vector3;y=u.shadowCascadeNearZ[p];u=u.shadowCascadeFarZ[p];o[0].set(-1,-1,y);o[1].set(1,-1,y);o[2].set(-1,1,y);o[3].set(1,1,y);o[4].set(-1,-1,u);o[5].set(1,-1,u);o[6].set(-1,1,u);o[7].set(1,1,u);A.originalCamera=l;o=new THREE.Gyroscope;o.position=m.shadowCascadeOffset;o.add(A);o.add(A.target);l.add(o);m.shadowCascadeArray[r]=A;console.log("Created virtualLight",A)}p=m;y=r;u=p.shadowCascadeArray[y];u.position.copy(p.position); -u.target.position.copy(p.target.position);u.lookAt(u.target);u.shadowCameraVisible=p.shadowCameraVisible;u.shadowDarkness=p.shadowDarkness;u.shadowBias=p.shadowCascadeBias[y];o=p.shadowCascadeNearZ[y];p=p.shadowCascadeFarZ[y];u=u.pointsFrustum;u[0].z=o;u[1].z=o;u[2].z=o;u[3].z=o;u[4].z=p;u[5].z=p;u[6].z=p;u[7].z=p;K[q]=A;q++}else K[q]=m,q++;for(j=0,n=K.length;jp;p++){y=u[p];y.copy(o[p]);THREE.ShadowMapPlugin.__projector.unprojectVector(y, -r);q.matrixWorldInverse.multiplyVector3(y);if(y.xi.x)i.x=y.x;if(y.yi.y)i.y=y.y;if(y.zi.z)i.z=y.z}q.left=h.x;q.right=i.x;q.top=i.y;q.bottom=h.y;q.updateProjectionMatrix()}q=m.shadowMap;o=m.shadowMatrix;r=m.shadowCamera;r.position.copy(m.matrixWorld.getPosition());r.lookAt(m.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);if(m.cameraHelper)m.cameraHelper.lines.visible=m.shadowCameraVisible; -m.shadowCameraVisible&&m.cameraHelper.update(m.shadowCamera);o.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);o.multiplySelf(r.projectionMatrix);o.multiplySelf(r.matrixWorldInverse);if(!r._viewMatrixArray)r._viewMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);g.multiply(r.projectionMatrix,r.matrixWorldInverse);e.setFromMatrix(g); -b.setRenderTarget(q);b.clear();u=k.__webglObjects;for(m=0,q=u.length;mx;x++)u[x]=new THREE.Vector3,p[x]=new THREE.Vector3;u=w.shadowCascadeNearZ[q];w=w.shadowCascadeFarZ[q];p[0].set(-1,-1,u);p[1].set(1,-1,u);p[2].set(-1,1,u);p[3].set(1,1,u);p[4].set(-1,-1,w);p[5].set(1,-1,w);p[6].set(-1,1,w);p[7].set(1,1,w);A.originalCamera=k;p=new THREE.Gyroscope;p.position=l.shadowCascadeOffset;p.add(A);p.add(A.target);k.add(p);l.shadowCascadeArray[o]=A;console.log("Created virtualLight",A)}q=l;u=o;w=q.shadowCascadeArray[u];w.position.copy(q.position); +w.target.position.copy(q.target.position);w.lookAt(w.target);w.shadowCameraVisible=q.shadowCameraVisible;w.shadowDarkness=q.shadowDarkness;w.shadowBias=q.shadowCascadeBias[u];p=q.shadowCascadeNearZ[u];q=q.shadowCascadeFarZ[u];w=w.pointsFrustum;w[0].z=p;w[1].z=p;w[2].z=p;w[3].z=p;w[4].z=q;w[5].z=q;w[6].z=q;w[7].z=q;J[r]=A;r++}else J[r]=l,r++;for(j=0,n=J.length;jq;q++){u=w[q];u.copy(p[q]);THREE.ShadowMapPlugin.__projector.unprojectVector(u, +o);r.matrixWorldInverse.multiplyVector3(u);if(u.xi.x)i.x=u.x;if(u.yi.y)i.y=u.y;if(u.zi.z)i.z=u.z}r.left=h.x;r.right=i.x;r.top=i.y;r.bottom=h.y;r.updateProjectionMatrix()}r=l.shadowMap;p=l.shadowMatrix;o=l.shadowCamera;o.position.copy(l.matrixWorld.getPosition());o.lookAt(l.target.matrixWorld.getPosition());o.updateMatrixWorld();o.matrixWorldInverse.getInverse(o.matrixWorld);if(l.cameraHelper)l.cameraHelper.lines.visible=l.shadowCameraVisible; +l.shadowCameraVisible&&l.cameraHelper.update(l.shadowCamera);p.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);p.multiplySelf(o.projectionMatrix);p.multiplySelf(o.matrixWorldInverse);if(!o._viewMatrixArray)o._viewMatrixArray=new Float32Array(16);o.matrixWorldInverse.flattenToArray(o._viewMatrixArray);if(!o._projectionMatrixArray)o._projectionMatrixArray=new Float32Array(16);o.projectionMatrix.flattenToArray(o._projectionMatrixArray);g.multiply(o.projectionMatrix,o.matrixWorldInverse);e.setFromMatrix(g); +b.setRenderTarget(r);b.clear();w=m.__webglObjects;for(l=0,r=w.length;ln-1?e-1:n-1,q=(n+1)%e,r=0>j-1?d-1:j-1,o=(j+1)%d,p=[],y=[0,0,i[4*(n*d+j)]/255*b];p.push([-1,0,i[4*(n*d+r)]/255*b]);p.push([-1,-1,i[4*(m*d+r)]/255*b]);p.push([0,-1, -i[4*(m*d+j)]/255*b]);p.push([1,-1,i[4*(m*d+o)]/255*b]);p.push([1,0,i[4*(n*d+o)]/255*b]);p.push([1,1,i[4*(q*d+o)]/255*b]);p.push([0,1,i[4*(q*d+j)]/255*b]);p.push([-1,1,i[4*(q*d+r)]/255*b]);m=[];r=p.length;for(q=0;qn-1?e-1:n-1,r=(n+1)%e,o=0>j-1?d-1:j-1,p=(j+1)%d,q=[],u=[0,0,i[4*(n*d+j)]/255*b];q.push([-1,0,i[4*(n*d+o)]/255*b]);q.push([-1,-1,i[4*(l*d+o)]/255*b]);q.push([0,-1, +i[4*(l*d+j)]/255*b]);q.push([1,-1,i[4*(l*d+p)]/255*b]);q.push([1,0,i[4*(n*d+p)]/255*b]);q.push([1,1,i[4*(r*d+p)]/255*b]);q.push([0,1,i[4*(r*d+j)]/255*b]);q.push([-1,1,i[4*(r*d+o)]/255*b]);l=[];o=q.length;for(r=0;r + + + three.js webgl - performance + + + + + + + + + + + + + + + diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 6f1e097ee4ff041551d4725ff38228d8917236a8..703c4fdc1857949b738ce921568b24cb6b46fbf1 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -4211,7 +4211,8 @@ THREE.WebGLRenderer = function ( parameters ) { alphaTest: material.alphaTest, metal: material.metal, perPixel: material.perPixel, - wrapAround: material.wrapAround + wrapAround: material.wrapAround, + doubleSided: object && object.doubleSided }; @@ -5287,6 +5288,7 @@ THREE.WebGLRenderer = function ( parameters ) { parameters.morphNormals ? "#define USE_MORPHNORMALS" : "", parameters.perPixel ? "#define PHONG_PER_PIXEL" : "", parameters.wrapAround ? "#define WRAP_AROUND" : "", + parameters.doubleSided ? "#define DOUBLE_SIDED" : "", parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", parameters.shadowMapSoft ? "#define SHADOWMAP_SOFT" : "", @@ -5377,6 +5379,7 @@ THREE.WebGLRenderer = function ( parameters ) { parameters.metal ? "#define METAL" : "", parameters.perPixel ? "#define PHONG_PER_PIXEL" : "", parameters.wrapAround ? "#define WRAP_AROUND" : "", + parameters.doubleSided ? "#define DOUBLE_SIDED" : "", parameters.shadowMapEnabled ? "#define USE_SHADOWMAP" : "", parameters.shadowMapSoft ? "#define SHADOWMAP_SOFT" : "", diff --git a/src/renderers/WebGLShaders.js b/src/renderers/WebGLShaders.js index 76ff14279852b77f79f95a723a812b37cd41c251..424cad61d89ac92926c9a79fc2cd9c6b25b04c2a 100644 --- a/src/renderers/WebGLShaders.js +++ b/src/renderers/WebGLShaders.js @@ -74,7 +74,16 @@ THREE.ShaderChunk = { "#ifdef USE_ENVMAP", - "vec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );", + "#ifdef DOUBLE_SIDED", + + "float flipNormal = ( -1.0 + 2.0 * float( gl_FrontFacing ) );", + "vec4 cubeColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * vReflect.x, vReflect.yz ) );", + + "#else", + + "vec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );", + + "#endif", "#ifdef GAMMA_INPUT", @@ -285,7 +294,13 @@ THREE.ShaderChunk = { lights_lambert_vertex: [ - "vLightWeighting = vec3( 0.0 );", + "vLightFront = vec3( 0.0 );", + + "#ifdef DOUBLE_SIDED", + + "vLightBack = vec3( 0.0 );", + + "#endif", "transformedNormal = normalize( transformedNormal );", @@ -296,20 +311,41 @@ THREE.ShaderChunk = { "vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );", "vec3 dirVector = normalize( lDirection.xyz );", + "float dotProduct = dot( transformedNormal, dirVector );", + "vec3 directionalLightWeighting = vec3( max( dotProduct, 0.0 ) );", + + "#ifdef DOUBLE_SIDED", + + "vec3 directionalLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );", + + "#ifdef WRAP_AROUND", + + "vec3 directionalLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );", + + "#endif", + + "#endif", + "#ifdef WRAP_AROUND", - "float directionalLightWeightingFull = max( dot( transformedNormal, dirVector ), 0.0 );", - "float directionalLightWeightingHalf = max( 0.5 * dot( transformedNormal, dirVector ) + 0.5, 0.0 );", + "vec3 directionalLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );", + "directionalLightWeighting = mix( directionalLightWeighting, directionalLightWeightingHalf, wrapRGB );", - "vec3 directionalLightWeighting = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );", + "#ifdef DOUBLE_SIDED", - "#else", + "directionalLightWeightingBack = mix( directionalLightWeightingBack, directionalLightWeightingHalfBack, wrapRGB );", - "float directionalLightWeighting = max( dot( transformedNormal, dirVector ), 0.0 );", + "#endif", "#endif", - "vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;", + "vLightFront += directionalLightColor[ i ] * directionalLightWeighting;", + + "#ifdef DOUBLE_SIDED", + + "vLightBack += directionalLightColor[ i ] * directionalLightWeightingBack;", + + "#endif", "}", @@ -327,27 +363,54 @@ THREE.ShaderChunk = { "lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );", "lVector = normalize( lVector );", + "float dotProduct = dot( transformedNormal, lVector );", + + "vec3 pointLightWeighting = vec3( max( dotProduct, 0.0 ) );", + + "#ifdef DOUBLE_SIDED", + + "vec3 pointLightWeightingBack = vec3( max( -dotProduct, 0.0 ) );", + + "#ifdef WRAP_AROUND", + + "vec3 pointLightWeightingHalfBack = vec3( max( -0.5 * dotProduct + 0.5, 0.0 ) );", + + "#endif", + + "#endif", "#ifdef WRAP_AROUND", - "float pointLightWeightingFull = max( dot( transformedNormal, lVector ), 0.0 );", - "float pointLightWeightingHalf = max( 0.5 * dot( transformedNormal, lVector ) + 0.5, 0.0 );", + "vec3 pointLightWeightingHalf = vec3( max( 0.5 * dotProduct + 0.5, 0.0 ) );", + "pointLightWeighting = mix( pointLightWeighting, pointLightWeightingHalf, wrapRGB );", - "vec3 pointLightWeighting = mix( vec3 ( pointLightWeightingFull ), vec3( pointLightWeightingHalf ), wrapRGB );", + "#ifdef DOUBLE_SIDED", - "#else", + "pointLightWeightingBack = mix( pointLightWeightingBack, pointLightWeightingHalfBack, wrapRGB );", - "float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );", + "#endif", "#endif", - "vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;", + "vLightFront += pointLightColor[ i ] * pointLightWeighting * lDistance;", + + "#ifdef DOUBLE_SIDED", + + "vLightBack += pointLightColor[ i ] * pointLightWeightingBack * lDistance;", + + "#endif", "}", "#endif", - "vLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;", + "vLightFront = vLightFront * diffuse + ambient * ambientLightColor;", + + "#ifdef DOUBLE_SIDED", + + "vLightBack = vLightBack * diffuse + ambient * ambientLightColor;", + + "#endif", ].join("\n"), @@ -436,6 +499,12 @@ THREE.ShaderChunk = { "vec3 normal = normalize( vNormal );", "vec3 viewPosition = normalize( vViewPosition );", + "#ifdef DOUBLE_SIDED", + + "normal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );", + + "#endif", + "#if MAX_POINT_LIGHTS > 0", "vec3 pointDiffuse = vec3( 0.0 );", @@ -463,16 +532,18 @@ THREE.ShaderChunk = { // diffuse + "float dotProduct = dot( normal, lVector );", + "#ifdef WRAP_AROUND", - "float pointDiffuseWeightFull = max( dot( normal, lVector ), 0.0 );", - "float pointDiffuseWeightHalf = max( 0.5 * dot( normal, lVector ) + 0.5, 0.0 );", + "float pointDiffuseWeightFull = max( dotProduct, 0.0 );", + "float pointDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );", "vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );", "#else", - "float pointDiffuseWeight = max( dot( normal, lVector ), 0.0 );", + "float pointDiffuseWeight = max( dotProduct, 0.0 );", "#endif", @@ -511,16 +582,18 @@ THREE.ShaderChunk = { // diffuse + "float dotProduct = dot( normal, dirVector );", + "#ifdef WRAP_AROUND", - "float dirDiffuseWeightFull = max( dot( normal, dirVector ), 0.0 );", - "float dirDiffuseWeightHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );", + "float dirDiffuseWeightFull = max( dotProduct, 0.0 );", + "float dirDiffuseWeightHalf = max( 0.5 * dotProduct + 0.5, 0.0 );", "vec3 dirDiffuseWeight = mix( vec3( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), wrapRGB );", "#else", - "float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );", + "float dirDiffuseWeight = max( dotProduct, 0.0 );", "#endif", @@ -1321,7 +1394,13 @@ THREE.ShaderLib = { vertexShader: [ - "varying vec3 vLightWeighting;", + "varying vec3 vLightFront;", + + "#ifdef DOUBLE_SIDED", + + "varying vec3 vLightBack;", + + "#endif", THREE.ShaderChunk[ "map_pars_vertex" ], THREE.ShaderChunk[ "lightmap_pars_vertex" ], @@ -1358,7 +1437,13 @@ THREE.ShaderLib = { "uniform float opacity;", - "varying vec3 vLightWeighting;", + "varying vec3 vLightFront;", + + "#ifdef DOUBLE_SIDED", + + "varying vec3 vLightBack;", + + "#endif", THREE.ShaderChunk[ "color_pars_fragment" ], THREE.ShaderChunk[ "map_pars_fragment" ], @@ -1374,7 +1459,21 @@ THREE.ShaderLib = { THREE.ShaderChunk[ "map_fragment" ], THREE.ShaderChunk[ "alphatest_fragment" ], - "gl_FragColor.xyz = gl_FragColor.xyz * vLightWeighting;", + "#ifdef DOUBLE_SIDED", + + //"float isFront = float( gl_FrontFacing );", + //"gl_FragColor.xyz *= isFront * vLightFront + ( 1.0 - isFront ) * vLightBack;", + + "if ( gl_FrontFacing )", + "gl_FragColor.xyz *= vLightFront;", + "else", + "gl_FragColor.xyz *= vLightBack;", + + "#else", + + "gl_FragColor.xyz *= vLightFront;", + + "#endif", THREE.ShaderChunk[ "lightmap_fragment" ], THREE.ShaderChunk[ "color_fragment" ],