// 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)}, equals:function(a){return a.x===this.x&&a.y===this.y},isZero:function(){return 1.0E-4>this.lengthSq()}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}; THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this}, addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this}, divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a):this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)}, cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,a).lengthSq()},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34;return this},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13); var b=Math.cos(this.y);1.0E-5this.lengthSq()}};THREE.Vector4=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.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y; this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.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)),f=0;6>f;f++)if(a=b[f].x*c.n14+b[f].y*c.n24+b[f].z*c.n34+b[f].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3; THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);r=o.dot(b);s=q.add(a,m.copy(b).multiplyScalar(r));return t=c.distanceTo(s)}function d(a,b,c,d){o.sub(d,b);q.sub(c,b);m.sub(a,b);u=o.dot(o);x=o.dot(q);v=o.dot(m);B=q.dot(q);D=q.dot(m);C=1/(u*B-x*x);A=(B*v-x*D)*C;E=(u*D-x*v)*C;return 0<=A&&0<=E&&1>A+E}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];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){o=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(o>a.geometry.boundingSphere.radius*Math.max(q.x,Math.max(q.y,q.z)))return m;var r,s,j=a.geometry,t=j.vertices,y;a.matrixRotationWorld.extractRotation(a.matrixWorld); for(o=0,q=j.faces.length;oMath.abs(r))&&(s=p.dot(l)/r,!(0>s)&&(a.doubleSided||(a.flipSided?0r))))if(n.add(i,k.multiplyScalar(s)),b instanceof THREE.Face3)f=y.multiplyVector3(f.copy(t[b.a].position)),g=y.multiplyVector3(g.copy(t[b.b].position)),e=y.multiplyVector3(e.copy(t[b.c].position)), d(n,f,g,e)&&(b={distance:i.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b));else if(b instanceof THREE.Face4&&(f=y.multiplyVector3(f.copy(t[b.a].position)),g=y.multiplyVector3(g.copy(t[b.b].position)),e=y.multiplyVector3(e.copy(t[b.c].position)),h=y.multiplyVector3(h.copy(t[b.d].position)),d(n,f,g,h)||d(n,g,e,h)))b={distance:i.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b)}return m};var o=new THREE.Vector3,q=new THREE.Vector3,m=new THREE.Vector3,r,s,t,u,x,v,B,D,C,A,E}; THREE.Rectangle=function(){function a(){g=d-b;e=f-c}var b,c,d,f,g,e,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return e};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,l,p){h=!1;b=e;c=g;d=l;f=p;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=be?d:e,f=f>g?f:g);a()};this.add3Points= function(e,g,l,p,n,o){h?(h=!1,b=el?e>n?e:n:l>n?l:n,f=g>p?g>o?g:o:p>o?p:o):(b=el?e>n?e>d?e:d:n>d?n:d:l>n?l>d?l:d:n>d?n:d,f=g>p?g>o?g>f?g:f:o>f?o:f:p>o?p>f?p:f:o>f?o:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> e.getBottom()?f:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;f+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=da.getRight()||fa.getBottom()?!1:!0};this.empty=function(){h=!0;f=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 af&&0>e||0>g&&0>h)return!1;0>f?c=Math.max(c,f/(f-e)):0>e&&(d=Math.min(d,f/(f-e)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(dg&&h.positionScreen.z(ca.positionScreen.x-P.positionScreen.x)*(Q.positionScreen.y-P.positionScreen.y)-(ca.positionScreen.y-P.positionScreen.y)*(Q.positionScreen.x- P.positionScreen.x)))ga=n[p]=n[p]||new THREE.RenderableFace3,p++,l=ga,l.v1.copy(P),l.v2.copy(Q),l.v3.copy(ca);else continue;else if(y instanceof THREE.Face4)if(P=k[y.a],Q=k[y.b],ca=k[y.c],ga=k[y.d],P.visible&&Q.visible&&ca.visible&&ga.visible&&(ba.doubleSided||ba.flipSided!=(0>(ga.positionScreen.x-P.positionScreen.x)*(Q.positionScreen.y-P.positionScreen.y)-(ga.positionScreen.y-P.positionScreen.y)*(Q.positionScreen.x-P.positionScreen.x)||0>(Q.positionScreen.x-ca.positionScreen.x)*(ga.positionScreen.y- ca.positionScreen.y)-(Q.positionScreen.y-ca.positionScreen.y)*(ga.positionScreen.x-ca.positionScreen.x))))na=q[o]=q[o]||new THREE.RenderableFace4,o++,l=na,l.v1.copy(P),l.v2.copy(Q),l.v3.copy(ca),l.v4.copy(ga);else continue;l.normalWorld.copy(y.normal);aa.multiplyVector3(l.normalWorld);l.centroidWorld.copy(y.centroid);T.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);C.multiplyVector3(l.centroidScreen);ca=y.vertexNormals;for(P=0,Q=ca.length;PD.z))g=x[u]=x[u]||new THREE.RenderableParticle,u++,t=g, t.x=D.x/D.w,t.y=D.y/D.w,t.z=D.z,t.rotation=ba.rotation.z,t.scale.x=ba.scale.x*Math.abs(t.x-(D.x+f.projectionMatrix.n11)/(D.w+f.projectionMatrix.n14)),t.scale.y=ba.scale.y*Math.abs(t.y-(D.y+f.projectionMatrix.n22)/(D.w+f.projectionMatrix.n24)),t.material=ba.material,v.elements.push(t);e&&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,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(c),c=Math.sin(c),e=a*b,h=d*f;this.w=e*g-h*c;this.x=e*c+h*g;this.y=d*b*g+a*f*c;this.z=a*f* g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=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,f=this.w,g=a.x,e=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-d*e;this.y=c*a+f*e+d*g-b*h;this.z=d*a+f*h+b*e-c*g;this.w=f*a-b*g-c*e-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b= a);var c=a.x,d=a.y,f=a.z,g=this.x,e=this.y,h=this.z,i=this.w,k=i*c+e*f-h*d,l=i*d+h*c-g*f,p=i*f+g*d-e*c,c=-g*c-e*d-h*f;b.x=k*i+c*-g+l*-h-p*-e;b.y=l*i+c*-e+p*-g-k*-h;b.z=p*i+c*-h+k*-e-l*-g;return b}}; THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>f?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(1<=Math.abs(f))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),f=Math.sqrt(1-f*f);if(0.001>Math.abs(f))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,f,g,e){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,d=this.vertices.length;cf?-1:1,g.vertexTangents[d]=new THREE.Vector4(Y.x,Y.y,Y.z,f)}this.hasTangents=!0},computeBoundingBox:function(){if(0c.x)c.x=a.x;if(a.yc.y)c.y=a.y;if(a.zc.z)c.z=a.z}}},computeBoundingSphere:function(){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,f=Math.pow(10,4),g,e;for(g=0,e=this.vertices.length;gthis.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;k=this.points[c[0]];l=this.points[c[1]]; p=this.points[c[2]];n=this.points[c[3]];h=e*e;i=e*h;d.x=b(k.x,l.x,p.x,n.x,e,h,i);d.y=b(k.y,l.y,p.y,n.y,e,h,i);d.z=b(k.z,l.z,p.z,n.z,e,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.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;a=THREE.Math.clamp(Math.floor(this.time/b),0,this.geometry.morphTargets.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; THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.addLevel=function(a,b){void 0===b&&(b=0);for(var b=Math.abs(b),c=0;c=this.LODs[b].visibleAtDistance)this.LODs[b-1].object3D.visible=!1,this.LODs[b].object3D.visible=!0;else break;for(;bs&&m.clearRect(Math.floor(xa.getX()),Math.floor(xa.getY()),Math.floor(xa.getWidth()),Math.floor(xa.getHeight())),0=i||(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),i=c.dot(Z.sub(h,b).normalize()),0>=i||(i*=0==g.distance?1:1-Math.min(b.distanceTo(h)/g.distance,1),0!=i&&(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function r(a,e,g){b(g.opacity);c(g.blending);var Z,j,h,i,k,l;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)i= g.map.image,k=i.width>>1,l=i.height>>1,g=e.scale.x*o,h=e.scale.y*q,Z=g*k,j=h*l,ya.set(a.x-Z,a.y-j,a.x+Z,a.y+j),Fa.intersects(ya)&&(m.save(),m.translate(a.x,a.y),m.rotate(-e.rotation),m.scale(g,-h),m.translate(-k,-l),m.drawImage(i,0,0),m.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(Z=e.scale.x*o,j=e.scale.y*q,ya.set(a.x-Z,a.y-j,a.x+Z,a.y+j),Fa.intersects(ya)&&(d(g.color.getContextStyle()),f(g.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-e.rotation),m.scale(Z,j),g.program(m), m.restore()))}function s(a,f,e,g){b(g.opacity);c(g.blending);m.beginPath();m.moveTo(a.positionScreen.x,a.positionScreen.y);m.lineTo(f.positionScreen.x,f.positionScreen.y);m.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(B!=a)m.lineWidth=B=a;a=g.linecap;if(D!=a)m.lineCap=D=a;a=g.linejoin;if(C!=a)m.lineJoin=C=a;d(g.color.getContextStyle());m.stroke();ya.inflate(2*g.linewidth)}}function t(a,d,f,e,h,k,ha,m){g.info.render.vertices+=3;g.info.render.faces++;b(m.opacity);c(m.blending); O=a.positionScreen.x;M=a.positionScreen.y;H=d.positionScreen.x;j=d.positionScreen.y;X=f.positionScreen.x;y=f.positionScreen.y;x(O,M,H,j,X,y);if(m instanceof THREE.MeshBasicMaterial)if(m.map)m.map.mapping instanceof THREE.UVMapping&&(ja=ha.uvs[0],Lc(O,M,H,j,X,y,ja[e].u,ja[e].v,ja[h].u,ja[h].v,ja[k].u,ja[k].v,m.map));else if(m.envMap){if(m.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,Z.copy(ha.vertexNormalsWorld[e]),ab=0.5*(Z.x*a.n11+Z.y*a.n12+Z.z*a.n13)+0.5,kb= 0.5*-(Z.x*a.n21+Z.y*a.n22+Z.z*a.n23)+0.5,Z.copy(ha.vertexNormalsWorld[h]),db=0.5*(Z.x*a.n11+Z.y*a.n12+Z.z*a.n13)+0.5,Xa=0.5*-(Z.x*a.n21+Z.y*a.n22+Z.z*a.n23)+0.5,Z.copy(ha.vertexNormalsWorld[k]),Ya=0.5*(Z.x*a.n11+Z.y*a.n12+Z.z*a.n13)+0.5,Qa=0.5*-(Z.x*a.n21+Z.y*a.n22+Z.z*a.n23)+0.5,Lc(O,M,H,j,X,y,ab,kb,db,Xa,Ya,Qa,m.envMap)}else m.wireframe?Hb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Cb(m.color);else if(m instanceof THREE.MeshLambertMaterial)m.map&&!m.wireframe&&(m.map.mapping instanceof THREE.UVMapping&&(ja=ha.uvs[0],Lc(O,M,H,j,X,y,ja[e].u,ja[e].v,ja[h].u,ja[h].v,ja[k].u,ja[k].v,m.map)),c(THREE.SubtractiveBlending)),Oa?!m.wireframe&&m.shading==THREE.SmoothShading&&3==ha.vertexNormalsWorld.length?(aa.r=S.r=$.r=Ha.r,aa.g=S.g=$.g=Ha.g,aa.b=S.b=$.b=Ha.b,p(i,ha.v1.positionWorld,ha.vertexNormalsWorld[0],aa),p(i,ha.v2.positionWorld,ha.vertexNormalsWorld[1],S),p(i,ha.v3.positionWorld,ha.vertexNormalsWorld[2],$),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)),S.r=Math.max(0,Math.min(m.color.r*S.r,1)),S.g=Math.max(0,Math.min(m.color.g*S.g,1)),S.b=Math.max(0,Math.min(m.color.b*S.b,1)),$.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)),fa.r=0.5*(S.r+$.r),fa.g=0.5*(S.g+$.g),fa.b=0.5*(S.b+$.b),Aa=vc(aa,S,$,fa),$b(O,M,H,j,X,y,0,0,1,0,0,1,Aa)):(T.r=Ha.r,T.g=Ha.g,T.b=Ha.b,p(i,ha.centroidWorld,ha.normalWorld,T),T.r=Math.max(0,Math.min(m.color.r* T.r,1)),T.g=Math.max(0,Math.min(m.color.g*T.g,1)),T.b=Math.max(0,Math.min(m.color.b*T.b,1)),m.wireframe?Hb(T,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Cb(T)):m.wireframe?Hb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Cb(m.color);else if(m instanceof THREE.MeshDepthMaterial)Ja=l.near,Ea=l.far,aa.r=aa.g=aa.b=1-Vb(a.positionScreen.z,Ja,Ea),S.r=S.g=S.b=1-Vb(d.positionScreen.z,Ja,Ea),$.r=$.g=$.b=1-Vb(f.positionScreen.z,Ja,Ea),fa.r=0.5*(S.r+$.r),fa.g=0.5*(S.g+ $.g),fa.b=0.5*(S.b+$.b),Aa=vc(aa,S,$,fa),$b(O,M,H,j,X,y,0,0,1,0,0,1,Aa);else if(m instanceof THREE.MeshNormalMaterial)T.r=ac(ha.normalWorld.x),T.g=ac(ha.normalWorld.y),T.b=ac(ha.normalWorld.z),m.wireframe?Hb(T,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Cb(T)}function u(a,d,f,e,Z,h,k,m,ha){g.info.render.vertices+=4;g.info.render.faces++;b(m.opacity);c(m.blending);if(m.map||m.envMap)t(a,d,e,0,1,3,k,m,ha),t(Z,f,h,1,2,3,k,m,ha);else if(O=a.positionScreen.x,M=a.positionScreen.y,H=d.positionScreen.x, j=d.positionScreen.y,X=f.positionScreen.x,y=f.positionScreen.y,F=e.positionScreen.x,P=e.positionScreen.y,Q=Z.positionScreen.x,ca=Z.positionScreen.y,ga=h.positionScreen.x,ba=h.positionScreen.y,m instanceof THREE.MeshBasicMaterial)v(O,M,H,j,X,y,F,P),m.wireframe?Hb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Cb(m.color);else if(m instanceof THREE.MeshLambertMaterial)Oa?!m.wireframe&&m.shading==THREE.SmoothShading&&4==k.vertexNormalsWorld.length?(aa.r=S.r=$.r=fa.r=Ha.r,aa.g=S.g= $.g=fa.g=Ha.g,aa.b=S.b=$.b=fa.b=Ha.b,p(i,k.v1.positionWorld,k.vertexNormalsWorld[0],aa),p(i,k.v2.positionWorld,k.vertexNormalsWorld[1],S),p(i,k.v4.positionWorld,k.vertexNormalsWorld[3],$),p(i,k.v3.positionWorld,k.vertexNormalsWorld[2],fa),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)),S.r=Math.max(0,Math.min(m.color.r*S.r,1)),S.g=Math.max(0,Math.min(m.color.g*S.g,1)),S.b=Math.max(0,Math.min(m.color.b*S.b,1)),$.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)),fa.r=Math.max(0,Math.min(m.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(m.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(m.color.b*fa.b,1)),Aa=vc(aa,S,$,fa),x(O,M,H,j,F,P),$b(O,M,H,j,F,P,0,0,1,0,0,1,Aa),x(Q,ca,X,y,ga,ba),$b(Q,ca,X,y,ga,ba,1,0,1,1,0,1,Aa)):(T.r=Ha.r,T.g=Ha.g,T.b=Ha.b,p(i,k.centroidWorld,k.normalWorld,T),T.r=Math.max(0,Math.min(m.color.r*T.r,1)),T.g=Math.max(0,Math.min(m.color.g* T.g,1)),T.b=Math.max(0,Math.min(m.color.b*T.b,1)),v(O,M,H,j,X,y,F,P),m.wireframe?Hb(T,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Cb(T)):(v(O,M,H,j,X,y,F,P),m.wireframe?Hb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Cb(m.color));else if(m instanceof THREE.MeshNormalMaterial)T.r=ac(k.normalWorld.x),T.g=ac(k.normalWorld.y),T.b=ac(k.normalWorld.z),v(O,M,H,j,X,y,F,P),m.wireframe?Hb(T,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Cb(T);else if(m instanceof THREE.MeshDepthMaterial)Ja=l.near,Ea=l.far,aa.r=aa.g=aa.b=1-Vb(a.positionScreen.z,Ja,Ea),S.r=S.g=S.b=1-Vb(d.positionScreen.z,Ja,Ea),$.r=$.g=$.b=1-Vb(e.positionScreen.z,Ja,Ea),fa.r=fa.g=fa.b=1-Vb(f.positionScreen.z,Ja,Ea),Aa=vc(aa,S,$,fa),x(O,M,H,j,F,P),$b(O,M,H,j,F,P,0,0,1,0,0,1,Aa),x(Q,ca,X,y,ga,ba),$b(Q,ca,X,y,ga,ba,1,0,1,1,0,1,Aa)}function x(a,b,c,d,f,e){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(f,e);m.lineTo(a,b);m.closePath()}function v(a,b,c,d,f,e,g,Z){m.beginPath();m.moveTo(a,b);m.lineTo(c, d);m.lineTo(f,e);m.lineTo(g,Z);m.lineTo(a,b);m.closePath()}function Hb(a,b,c,f){if(B!=b)m.lineWidth=B=b;if(D!=c)m.lineCap=D=c;if(C!=f)m.lineJoin=C=f;d(a.getContextStyle());m.stroke();ya.inflate(2*b)}function Cb(a){f(a.getContextStyle());m.fill()}function Lc(a,b,c,d,e,g,Z,j,h,i,k,ha,l){if(0!=l.image.width){if(!0==l.needsUpdate||void 0==Ra[l.id]){var n=l.wrapS==THREE.RepeatWrapping,o=l.wrapT==THREE.RepeatWrapping;Ra[l.id]=m.createPattern(l.image,n&&o?"repeat":n&&!o?"repeat-x":!n&&o?"repeat-y":"no-repeat"); l.needsUpdate=!1}f(Ra[l.id]);var n=l.offset.x/l.repeat.x,o=l.offset.y/l.repeat.y,p=l.image.width*l.repeat.x,Bb=l.image.height*l.repeat.y,Z=(Z+n)*p,j=(j+o)*Bb,c=c-a,d=d-b,e=e-a,g=g-b,h=(h+n)*p-Z,i=(i+o)*Bb-j,k=(k+n)*p-Z,ha=(ha+o)*Bb-j,n=h*ha-k*i;if(0==n){if(void 0===na[l.id])b=document.createElement("canvas"),b.width=l.image.width,b.height=l.image.height,b=b.getContext("2d"),b.drawImage(l.image,0,0),na[l.id]=b.getImageData(0,0,l.image.width,l.image.height).data;b=na[l.id];Z=4*(Math.floor(Z)+Math.floor(j)* l.image.width);T.setRGB(b[Z]/255,b[Z+1]/255,b[Z+2]/255);Cb(T)}else n=1/n,l=(ha*c-i*e)*n,i=(ha*d-i*g)*n,c=(h*e-k*c)*n,d=(h*g-k*d)*n,a=a-l*Z-c*j,Z=b-i*Z-d*j,m.save(),m.transform(l,i,c,d,a,Z),m.fill(),m.restore()}}function $b(a,b,c,d,f,e,g,Z,j,h,i,k,l){var ha,n;ha=l.width-1;n=l.height-1;g*=ha;Z*=n;c-=a;d-=b;f-=a;e-=b;j=j*ha-g;h=h*n-Z;i=i*ha-g;k=k*n-Z;n=1/(j*k-i*h);ha=(k*c-h*f)*n;h=(k*d-h*e)*n;c=(j*f-i*c)*n;d=(j*e-i*d)*n;a=a-ha*g-c*Z;b=b-h*g-d*Z;m.save();m.transform(ha,h,c,d,a,b);m.clip();m.drawImage(l, 0,0);m.restore()}function vc(a,b,c,d){var f=~~(255*a.r),e=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),Z=~~(255*b.g),b=~~(255*b.b),j=~~(255*c.r),h=~~(255*c.g),c=~~(255*c.b),i=~~(255*d.r),m=~~(255*d.g),d=~~(255*d.b);eb[0]=0>f?0:255e?0:255a?0:255g?0:255Z?0:255b?0:255j?0:255h?0:255c?0:255i?0:255m?0:255d?0:255a?0:1=m||(m*=g.intensity,d.r+=h.r*m,d.g+=h.g*m,d.b+=h.b*m)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),m=c.dot(A.sub(i,b).normalize()),0>=m||(m*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=m&&(m*=g.intensity,d.r+=h.r*m,d.g+=h.g*m,d.b+=h.b*m)))}function b(a){null==E[a]&&(E[a]=document.createElementNS("http://www.w3.org/2000/svg", "path"),0==O&&E[a].setAttribute("shape-rendering","crispEdges"));return E[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 );\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_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", 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 * viewMatrix * objectMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\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",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform vec2 shadowMapSize[ MAX_SHADOWS ];\nuniform float shadowDarkness[ MAX_SHADOWS ];\nuniform float shadowBias[ MAX_SHADOWS ];\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif", shadowmap_fragment:"#ifdef USE_SHADOWMAP\nvec3 shadowColor = vec3( 1.0 );\nfloat fDepth;\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nif ( shadowCoord.z <= 1.0 ) {\nshadowCoord.z += shadowBias[ i ];\nbvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nif ( all( shadowTest ) ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nconst float shadowDelta = 1.0 / 9.0;\nfloat xPixelOffset = 1.0 / shadowMapSize[ i ].x;\nfloat yPixelOffset = 1.0 / shadowMapSize[ i ].y;\nfloat dx0 = -1.25 * xPixelOffset;\nfloat dy0 = -1.25 * yPixelOffset;\nfloat dx1 = 1.25 * xPixelOffset;\nfloat dy1 = 1.25 * yPixelOffset;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness[ i ] * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( 1.0 - shadowDarkness[ i ] );\n#endif\n}\n}\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\n#ifdef USE_MORPHTARGETS\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( morphed, 1.0 );\n#else\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n#endif\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif", linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"}; THREE.UniformsUtils={merge:function(a){var b,c,d,f={};for(b=0;bl;l++){n=k;r=l;if(H.autoScaleCubemaps){if(s=h.image[l],F=Oa,!(s.width<=F&&s.height<=F))x=Math.max(s.width,s.height),t=Math.floor(s.width* F/x),F=Math.floor(s.height*F/x),x=document.createElement("canvas"),x.width=t,x.height=F,x.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,F),s=x}else s=h.image[l];n[r]=s}l=k[0];n=0===(l.width&l.width-1)&&0===(l.height&l.height-1);r=B(h.format);s=B(h.type);u(j.TEXTURE_CUBE_MAP,h,n);for(l=0;6>l;l++)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,r,r,s,k[l]);h.generateMipmaps&&n&&j.generateMipmap(j.TEXTURE_CUBE_MAP);h.needsUpdate=!1;if(h.onUpdated)h.onUpdated()}else j.activeTexture(j.TEXTURE0+ k),j.bindTexture(j.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}else l instanceof THREE.WebGLRenderTargetCube?(h=l,j.activeTexture(j.TEXTURE0+k),j.bindTexture(j.TEXTURE_CUBE_MAP,h.__webglTexture)):H.setTexture(l,k)}else if("tv"===n){if(!h._array){h._array=[];for(n=0,r=h.texture.length;n k&&(l=n,k=h[l]);j.bindBuffer(j.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[l]);j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0);e.__webglMorphTargetInfluences[g]=k;i[l]=1;k=-1;g++}}null!==d.program.uniforms.morphTargetInfluences&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,e.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList)for(g=0,h=f.__webglCustomAttributesList.length;gka;ka++)Qb=cc[ka],hb[Pa]=Qb.x,hb[Pa+1]=Qb.y,hb[Pa+2]=Qb.z,Pa+=3;else for(ka=0;3>ka;ka++)hb[Pa]=Jb.x,hb[Pa+1]=Jb.y,hb[Pa+2]=Jb.z,Pa+=3;for(G=0,R=ma.length;Gka;ka++)Qb=cc[ka],hb[Pa]=Qb.x,hb[Pa+1]=Qb.y,hb[Pa+ 2]=Qb.z,Pa+=3;else for(ka=0;4>ka;ka++)hb[Pa]=Jb.x,hb[Pa+1]=Jb.y,hb[Pa+2]=Jb.z,Pa+=3;j.bindBuffer(j.ARRAY_BUFFER,da.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,hb,bb)}if(ad&&Rc&&Xc){for(G=0,R=la.length;Gka;ka++)fc=dc[ka],oc[Eb]=fc.u,oc[Eb+1]=fc.v,Eb+=2;for(G=0,R=ma.length;Gka;ka++)fc=dc[ka],oc[Eb]=fc.u,oc[Eb+1]=fc.v,Eb+=2;0ka;ka++)gc=ec[ka],pc[Fb]=gc.u,pc[Fb+1]=gc.v,Fb+=2;for(G=0,R=ma.length;Gka;ka++)gc=ec[ka],pc[Fb]=gc.u,pc[Fb+1]=gc.v,Fb+=2;0c;c++){a.__webglFramebuffer[c]=j.createFramebuffer();a.__webglRenderbuffer[c]=j.createRenderbuffer();j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,0,d,f,null);var e=a,g=j.TEXTURE_CUBE_MAP_POSITIVE_X+c;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[c]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,g,e.__webglTexture,0);x(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer= j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture),u(j.TEXTURE_2D,a,c),j.texImage2D(j.TEXTURE_2D,0,d,a.width,a.height,0,d,f,null),d=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,d,a.__webglTexture,0),x(a.__webglRenderbuffer,a);b?j.bindTexture(j.TEXTURE_CUBE_MAP,null):j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]: a.__webglFramebuffer,d=a.width,a=a.height,c=f=0):(b=null,d=ja,a=ab,f=Ea,c=Aa);b!==F&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(f,c,d,a),F=b);kb=d;db=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}; THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)}; THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.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 f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.Math.clamp(f.h+b,0,1);f.s=THREE.Math.clamp(f.s+c,0,1);f.v=THREE.Math.clamp(f.v+d,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,f=a.b,g=Math.max(Math.max(c,d),f),e=Math.min(Math.min(c,d),f);if(e===g)e=c=0;else{var h=g-e,e=h/g,c=(c===g?(d-f)/h:d===g?2+(f-c)/h:4+(c-d)/h)/6;0>c&&(c+=1);1a?b(c,f-1):k[f]p-1?f-1:p-1,o=(p+1)%f,q=0>l-1?d-1:l-1,m=(l+1)%d,r=[],s=[0,0,h[4*(p*d+l)]/255*b];r.push([-1,0,h[4*(p*d+q)]/255*b]);r.push([-1,-1,h[4*(n*d+q)]/255*b]);r.push([0,-1, h[4*(n*d+l)]/255*b]);r.push([1,-1,h[4*(n*d+m)]/255*b]);r.push([1,0,h[4*(p*d+m)]/255*b]);r.push([1,1,h[4*(o*d+m)]/255*b]);r.push([0,1,h[4*(o*d+l)]/255*b]);r.push([-1,1,h[4*(o*d+q)]/255*b]);n=[];q=r.length;for(o=0;o 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 ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#ifdef WRAP_AROUND\nuniform vec3 wrapRGB;\n#endif\nvarying vec3 vViewPosition;", THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3( 1.0 ), uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse ) {\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( tDiffuse, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\n#endif\n}\nif( enableAO ) {\n#ifdef GAMMA_INPUT\nvec4 aoColor = texture2D( tAO, vUv );\naoColor.xyz *= aoColor.xyz;\ngl_FragColor.xyz = gl_FragColor.xyz * aoColor.xyz;\n#else\ngl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\n#endif\n}\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( normalize( vTangent ), normalize( vBinormal ), normalize( vNormal ) );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\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 ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nfloat pointDistance = vPointLight[ i ].w;\n#ifdef WRAP_AROUND\nfloat pointDiffuseWeightFull = max( dot( normal, pointVector ), 0.0 );\nfloat pointDiffuseWeightHalf = max( 0.5 * dot( normal, pointVector ) + 0.5, 0.0 );\nvec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), wrapRGB );\n#else\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\n#endif\npointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;\nvec3 pointHalfVector = normalize( pointVector + viewPosition );\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointSpecularWeight = specularTex.r * max( pow( pointDotNormalHalf, uShininess ), 0.0 );\npointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;\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 directionalLightWeightingFull = max( dot( normal, dirVector ), 0.0 );\nfloat directionalLightWeightingHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );\nvec3 dirDiffuseWeight = mix( vec3( directionalLightWeightingFull ), vec3( directionalLightWeightingHalf ), wrapRGB );\n#else\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\n#endif\ndirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;\nvec3 dirHalfVector = normalize( dirVector + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirSpecularWeight = specularTex.r * max( pow( dirDotNormalHalf, uShininess ), 0.0 );\ndirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;\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\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor) + totalSpecular;\nif ( enableReflection ) {\nvec3 wPos = cameraPosition - vViewPosition;\nvec3 vReflect = reflect( normalize( wPos ), normal );\nvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, specularTex.r * uReflectivity );\n}", THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;", THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalMatrix * normal;\nvTangent = normalMatrix * tangent.xyz;\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvUv = uv * uRepeat + uOffset;\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 );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( normalize( vNormal.xyz ) * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif", THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}}; THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.vertexColorArray=this.vertexUvArray=this.vertexNormalArray=this.vertexPositionArray=this.vertexIndexArray=this.vertexColorBuffer=this.vertexUvBuffer=this.vertexNormalBuffer=this.vertexPositionBuffer=this.vertexIndexBuffer=null;this.dynamic=!1;this.boundingSphere=this.boundingBox=null;this.morphTargets=[]};THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,computeBoundingBox:function(){},computeBoundingSphere:function(){}}; THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c}; THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1)return this.cacheArcLengths;var b=[],c,d=this.getPoint(0),f,g=0;b.push(0);for(f=1;f<=a;f++)c=this.getPoint(f/a),g+=c.distanceTo(d),b.push(g),d=c;return this.cacheArcLengths=b}; THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,f=c.length,g;g=b?b:a*c[f-1];for(var e=0,h=f-1,i;e<=h;)if(d=Math.floor(e+(h-e)/2),i=c[d]-g,0>i)e=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,f);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,f);return b};THREE.ArcCurve=function(a,b,c,d,f,g){this.aX=a;this.aY=b;this.aRadius=c;this.aStartAngle=d;this.aEndAngle=f;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,f){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*f},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,f){var a=0.5*(c-a),d=0.5*(d-b),g=f*f;return(2*b-2*c+a+d)*f*g+(-3*b+3*c-2*a-d)*g+a*f+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)}); THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=void 0==a?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,f;f=(d.length-1)*a;a=Math.floor(f);f-=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,f);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,f);b.z=THREE.Curve.Utils.interpolate(d[c[0]].z,d[c[1]].z,d[c[2]].z,d[c[3]].z,f);return b}); 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=g.x;else if(g.xc)c=g.y;else if(g.y h&&(h+=c.length);h%=c.length;0>e&&(e+=k.length);e%=k.length;f=0<=h-1?h-1:c.length-1;g=0<=e-1?e-1:k.length-1;m=[k[e],c[h],c[f]];m=THREE.FontUtils.Triangulate.area(m);r=[k[e],k[g],c[h]];r=THREE.FontUtils.Triangulate.area(r);p+n>m+r&&(h=o,e=l,0>h&&(h+=c.length),h%=c.length,0>e&&(e+=k.length),e%=k.length,f=0<=h-1?h-1:c.length-1,g=0<=e-1?e-1:k.length-1);p=c.slice(0,h);n=c.slice(h);o=k.slice(e);l=k.slice(0,e);g=[k[e],k[g],c[h]];q.push([k[e],c[h],c[f]]);q.push(g);c=p.concat(o).concat(l).concat(n)}return{shape:c, isolatedPts:q,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,f=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),g,e,h,i,k={};for(g=0,e=d.length;gd;d++)i=h[d].x+":"+h[d].y,i=k[i],void 0!==i&&(h[d]=i)}for(g=0,e=f.length;gd;d++)i=h[d].x+":"+h[d].y,i=k[i],void 0!==i&&(h[d]=i)}return c.concat(f)}, 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,f){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+ this.b3p3(a,f)}};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",f=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=f;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];e=i.prevKey[c];h=i.nextKey[c];if(h.time<=n){if(pd||1d?0:1;if("pos"===c)if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=f[0]+(g[0]-f[0])*d,c.y=f[1]+(g[1]-f[1])*d,c.z=f[2]+(g[2]-f[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",o,e.index-1).pos,this.points[1]=f,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",o,h.index+1).pos,d=0.33*d+0.33,f=this.interpolateCatmullRom(this.points,d),c.x=f[0],c.y=f[1],c.z=f[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(f,g,a.quaternion,d);else if("scl"===c)c=a.scale,c.x=f[0]+(g[0]-f[0])*d,c.y=f[1]+(g[1]-f[1])*d,c.z=f[2]+(g[2]-f[2])*d}}if(this.JITCompile&&void 0===l[0][k]){this.hierarchy[0].updateMatrixWorld(!0);for(o=0;oa.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];h=a[c[1]];i=a[c[2]];k=a[c[3]];c=f*f;e=f*c;d[0]=this.interpolate(g[0],h[0],i[0],k[0],f,c,e);d[1]=this.interpolate(g[1],h[1],i[1],k[1],f,c,e);d[2]=this.interpolate(g[2],h[2],i[2],k[2],f,c,e);return d}; THREE.Animation.prototype.interpolate=function(a,b,c,d,f,g,e){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*e+(-3*(b-c)-2*a-d)*g+a*f+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(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function f(a,b,c,d){var f={name:c,fps:0.6,length:d,hierarchy:[]},e,g=b.getControlPointsArray(),h=b.getLength(),r=g.length,s=0;e=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[e]={time:d,pos:g[e],rot:[0,0,0,1],scl:[1,1,1]};for(e=1;ei)?1:i));this.object.translateX(b*k);this.object.translateY(b*l);e&&(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()o;o++)this.materials.push(e)}o=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 u in h)void 0!==this.sides[u]&&(this.sides[u]=h[u]);this.sides.px&&i("z","y",-1,-1,c,b,l,o);this.sides.nx&&i("z","y",1,-1,c,b,-l,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,n,m);this.sides.nz&&i("x","y",-1,-1,a,b,-n,t);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry; THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry; THREE.CylinderGeometry=function(a,b,c,d,f,g){THREE.Geometry.call(this);var a=void 0!==a?a:20,b=void 0!==b?b:20,c=void 0!==c?c:100,e=c/2,d=d||8,f=f||1,h,i,k=[],l=[];for(i=0;i<=f;i++){var p=[],n=[],o=i/f,q=o*(b-a)+a;for(h=0;h<=d;h++){var m=h/d,r=q*Math.sin(2*m*Math.PI),s=-o*c+e,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);n.push(new THREE.UV(m,o))}k.push(p);l.push(n)}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 f(a){for(j=a.length;0<=--j;){y=j;F=j-1;0>F&&(F=a.length-1);for(var b= 0,c=o+2*l,b=0;bf)return null;var g=[],e=[],h=[],i,k,l;if(0=p--){console.log("Warning, unable to triangulate polygon!");break}i=k;f<=i&&(i=0);k=i+1;f<=k&&(k=0);l=k+1;f<=l&&(l=0);var n;a:{n=a;var o=i,q=k,m=l,r=f,s=e,t=void 0,u=void 0,x=void 0,v=void 0,B=void 0, D=void 0,C=void 0,A=void 0,E=void 0,u=n[s[o]].x,x=n[s[o]].y,v=n[s[q]].x,B=n[s[q]].y,D=n[s[m]].x,C=n[s[m]].y;if(1.0E-10>(v-u)*(C-x)-(B-x)*(D-u))n=!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,g(a,e(a,b),e(a,c),d),g(e(a,b),b,e(b,c),d),g(e(a,c),e(b,c),c,d),g(e(a,b),e(b,c),e(a,c),d))}function e(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=f((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,l=a.length;ko;o++){p=i[o];k=new THREE.Color;k.setRGB(0,0,0);for(var q=0;qu.length&&(p[o]=!0)}for(o in q)if(u=q[o],s=u[0],u=u[1],v=o.split("_"),B=v[0],v=v[1],r=new THREE.Vector3,p[o]?(r.addSelf(h[B].position),r.addSelf(h[v].position),r.multiplyScalar(0.5)):(r.addSelf(k[s]),r.addSelf(k[u]),r.addSelf(h[B].position),r.addSelf(h[v].position),r.multiplyScalar(0.25)), l[o]=t+d.length+x,i.push(new THREE.Vertex(r)),x++,e.supportUVs&&0!=n.length)u=new THREE.UV,u.u=n[B].u+n[v].u,u.v=n[B].v+n[v].v,u.u/=2,u.v/=2,n.push(u);var J,N;v=["123","12","2","23"];r=["123","23","3","31"];var A=["123","31","1","12"],E=["1234","12","2","23"],Y=["1234","23","3","34"],K=["1234","34","4","41"],O=["1234","41","1","12"];for(o=0,q=k.length;oa.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=e(a.colorDiffuse);else if(a.DbgColor)k.color=a.DbgColor;if(a.colorSpecular)k.specular=e(a.colorSpecular);if(a.colorAmbient)k.ambient=e(a.colorAmbient);if(a.transparency)k.opacity=a.transparency;if(a.specularCoef)k.shininess=a.specularCoef;a.mapDiffuse&&b&&g(k,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&g(k,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&g(k,"normalMap", a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);a.mapSpecular&&b&&g(k,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var i=THREE.ShaderUtils.lib.normal,l=THREE.UniformsUtils.clone(i.uniforms);l.tNormal.texture=k.normalMap;if(a.mapNormalFactor)l.uNormalScale.value=a.mapNormalFactor;if(k.map)l.tDiffuse.texture=k.map,l.enableDiffuse.value=!0;if(k.specularMap)l.tSpecular.texture=k.specularMap,l.enableSpecular.value=!0;if(k.lightMap)l.tAO.texture= k.lightMap,l.enableAO.value=!0;l.uDiffuseColor.value.setHex(k.color);l.uSpecularColor.value.setHex(k.specular);l.uAmbientColor.value.setHex(k.ambient);l.uShininess.value=k.shininess;if(void 0!==k.opacity)l.uOpacity.value=k.opacity;k=new THREE.ShaderMaterial({fragmentShader:i.fragmentShader,vertexShader:i.vertexShader,uniforms:l,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)}; 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),f=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,f)}; THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,f,g){var e=new XMLHttpRequest;e.onreadystatechange=function(){if(4==e.readyState)if(200==e.status||0==e.status)try{var h=JSON.parse(e.responseText);void 0===h.metadata||void 0===h.metadata.formatVersion||3!==h.metadata.formatVersion?console.error("Deprecated file format."):a.loadAjaxBuffers(h,c,f,d,g)}catch(i){console.error(i),console.warn("DEPRECATED: ["+b+"] seems to be using old model format")}else console.error("Couldn't load ["+b+"] ["+ e.status+"]")};e.open("GET",b,!0);e.overrideMimeType&&e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)}; THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,f){var g=new XMLHttpRequest,e=c+"/"+a.buffers,h=0;g.onreadystatechange=function(){4==g.readyState?200==g.status||0==g.status?THREE.BinaryLoader.prototype.createBinModel(g.response,b,d,a.materials):console.error("Couldn't load ["+e+"] ["+g.status+"]"):3==g.readyState?f&&(0==h&&(h=g.getResponseHeader("Content-Length")),f({total:h,loaded:g.responseText.length})):2==g.readyState&&(h=g.getResponseHeader("Content-Length"))};g.open("GET",e,!0); g.responseType="arraybuffer";g.send(null)}; THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var f=function(b){var c,f,i,k,l,p,n,o,q,m,r,s,t,u,x,v;function B(a){return a%4?4-a%4:0}function D(a,b){return(new Uint8Array(a,b,1))[0]}function C(a,b){return(new Uint32Array(a,b,1))[0]}function A(b,c){var d,e,f,g,h,i,m,k,l=new Uint32Array(a,c,3*b);for(d=0;da.length?"":a.join("/")+"/");if((a=S.evaluate("//dae:asset",S,F,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(f=0;fq)break}if(!s){s= new j(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,k,g,r)}}else console.log('Could not find transform "'+b.sid+'" in node '+this.id)}for(c=0;cthis.set)this.set=0;return this};D.prototype.parse=function(a){this.id=a.getAttribute("id"); for(var b=0;bthis.transparency,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c]; if(d instanceof A)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(Qa+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)};J.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){l=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(l.uniforms);m=r.parameters.color;N=r.parameters.specular;c=r.parameters.ambient;O=r.parameters.shininess;a.tNormal.texture=y.textures[r.parameters.normalMap];if(r.parameters.normalMapFactor)a.uNormalScale.value= r.parameters.normalMapFactor;if(r.parameters.map)a.tDiffuse.texture=r.parameters.map,a.enableDiffuse.value=!0;if(r.parameters.lightMap)a.tAO.texture=r.parameters.lightMap,a.enableAO.value=!0;if(r.parameters.specularMap)a.tSpecular.texture=y.textures[r.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(m);a.uSpecularColor.value.setHex(N);a.uAmbientColor.value.setHex(c);a.uShininess.value=O;if(r.parameters.opacity)a.uOpacity.value=r.parameters.opacity;r=new THREE.ShaderMaterial({fragmentShader:l.fragmentShader, vertexShader:l.vertexShader,uniforms:a,lights:!0,fog:!0})}else r=new THREE[r.type](r.parameters);y.materials[p]=r}f();i.callbackSync(y);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,f=void 0!==c.scale?c.scale:1,g=void 0!==c.offsetX?c.offsetX:0,e=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,f,g,e,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,f=0;8>f;f++){for(var g=0,e=0;e>1^-(h&1));c[8*e+f]=g}d+=b}b=a.length-d;g=new Uint16Array(b);for(f=e=0;f=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 n=Math.floor(k-h);1>n&&(n=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var o=Math.floor(l-h);1>o&&(o=1);h=Math.floor(l+h);h>this.size-1&&(h=this.size- 1);for(var q,m,r,s,t,u,x,l=p;lk&&(o=k);for(f=0;fl&&(q=l);for(g=0;gl&&(q=l);for(e=0;e=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(k=!1,l=a(THREE.ShaderFlares.lensFlare)):(k=!0,l=a(THREE.ShaderFlares.lensFlareVertexTexture));p={};n={};p.vertex=b.getAttribLocation(l,"position");p.uv=b.getAttribLocation(l,"uv");n.renderType=b.getUniformLocation(l,"renderType");n.map=b.getUniformLocation(l,"map");n.occlusionMap=b.getUniformLocation(l,"occlusionMap");n.opacity=b.getUniformLocation(l,"opacity");n.color=b.getUniformLocation(l, "color");n.scale=b.getUniformLocation(l,"scale");n.rotation=b.getUniformLocation(l,"rotation");n.screenPosition=b.getUniformLocation(l,"screenPosition");o=!1};this.render=function(a,d,f,s){var a=a.__webglFlares,t=a.length;if(t){var u=new THREE.Vector3,x=s/f,v=0.5*f,B=0.5*s,D=16/s,C=new THREE.Vector2(D*x,D),A=new THREE.Vector3(1,1,0),E=new THREE.Vector2(1,1),J=n,D=p;b.useProgram(l);o||(b.enableVertexAttribArray(p.vertex),b.enableVertexAttribArray(p.uv),o=!0);b.uniform1i(J.occlusionMap,0);b.uniform1i(J.map, 1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(D.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(D.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e);b.disable(b.CULL_FACE);b.depthMask(!1);var N,Y,K,O,M;for(N=0;N