// Three.js r47dev - http://github.com/mrdoob/three.js 'use strict';var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;if(!self.requestAnimationFrame)self.requestAnimationFrame=function(){return self.webkitRequestAnimationFrame||self.mozRequestAnimationFrame||self.oRequestAnimationFrame||self.msRequestAnimationFrame||function(a){self.setTimeout(a,1E3/60)}}();THREE.Clock=function(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}; THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){return this.elapsedTime+=this.getDelta()};THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.0010*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a}; THREE.Color=function(a){void 0!==a&&this.setHex(a);return this}; THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g); this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,f;if(0===c)this.r=this.g=this.b=0;else switch(d=Math.floor(6*a),e=6*a-d,a=c*(1-b),f=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=f;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=f;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=f;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a= Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return 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.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=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.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.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}};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 this.x+this.y+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},setRotationFromMatrix:function(a){var b=Math.cos(this.y); this.y=Math.asin(a.n13);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},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}}; THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);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);A=q.dot(q);D=q.dot(m);E=1/(u*A-x*x);C=(A*v-x*D)*E;F=(u*D-x*v)*E;return 0<=C&&0<=F&&1>C+F}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());if(o>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return m;var r,j=a.geometry,s=j.vertices,t;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,q=j.faces.length;o=r)&&(e=t.multiplyVector3(e.copy(s[b.a].position)),f=t.multiplyVector3(f.copy(s[b.b].position)),g=t.multiplyVector3(g.copy(s[b.c].position)),b instanceof THREE.Face4&&(h=t.multiplyVector3(h.copy(s[b.d].position))),p=a.matrixRotationWorld.multiplyVector3(p.copy(b.normal)),r=k.dot(p),a.doubleSided||(a.flipSided?0r)))if(r=p.dot(l.sub(e,i))/r,n.add(i,k.multiplyScalar(r)),b instanceof THREE.Face3)d(n,e,f,g)&&(b={distance:i.distanceTo(n), point:n.clone(),face:b,object:a},m.push(b));else if(b instanceof THREE.Face4&&(d(n,e,f,h)||d(n,f,g,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,A,D,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,l,p){h=!1;b=f;c=g;d=l;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,l,p,n,o){h?(h=!1,b=fl?f>n?f:n:l>n?l:n,e=g>p?g>o?g:o:p>o?p:o):(b=fl?f>n?f>d?f:d:n>d?n:d:l>n?l>d?l:d:n>d?n:d,e=g>p?g>o?g>e?g:e:o>e?o:e:p>o?p>e?p:e:o>e?o: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(aa.positionScreen.x-O.positionScreen.x)*(T.positionScreen.y-O.positionScreen.y)-(aa.positionScreen.y-O.positionScreen.y)*(T.positionScreen.x- O.positionScreen.x)))ga=n[p]=n[p]||new THREE.RenderableFace3,p++,l=ga,l.v1.copy(O),l.v2.copy(T),l.v3.copy(aa);else continue;else if(y instanceof THREE.Face4)if(O=k[y.a],T=k[y.b],aa=k[y.c],ga=k[y.d],O.visible&&T.visible&&aa.visible&&ga.visible&&(fa.doubleSided||fa.flipSided!=(0>(ga.positionScreen.x-O.positionScreen.x)*(T.positionScreen.y-O.positionScreen.y)-(ga.positionScreen.y-O.positionScreen.y)*(T.positionScreen.x-O.positionScreen.x)||0>(T.positionScreen.x-aa.positionScreen.x)*(ga.positionScreen.y- aa.positionScreen.y)-(T.positionScreen.y-aa.positionScreen.y)*(ga.positionScreen.x-aa.positionScreen.x))))ja=q[o]=q[o]||new THREE.RenderableFace4,o++,l=ja,l.v1.copy(O),l.v2.copy(T),l.v3.copy(aa),l.v4.copy(ga);else continue;l.normalWorld.copy(y.normal);ba.multiplyVector3(l.normalWorld);l.centroidWorld.copy(y.centroid);S.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);E.multiplyVector3(l.centroidScreen);aa=y.vertexNormals;for(O=0,T=aa.length;OD.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=fa.rotation.z,t.scale.x=fa.scale.x*Math.abs(t.x-(D.x+e.projectionMatrix.n11)/(D.w+e.projectionMatrix.n14)),t.scale.y=fa.scale.y*Math.abs(t.y-(D.y+e.projectionMatrix.n22)/(D.w+e.projectionMatrix.n24)),t.material=fa.material,v.elements.push(t);f&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,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},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,i=this.w,k=i*c+g*e-h*d,l=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+l*-h-p*-g;b.y=l*i+c*-g+p*-f-k*-h;b.z=p*i+c*-h+k*-g-l*-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.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.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=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.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;ce?-1:1,f.vertexTangents[d]=new THREE.Vector4(R.x,R.y,R.z,e)}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,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]];l=this.points[c[1]]; p=this.points[c[2]];n=this.points[c[3]];h=g*g;i=g*h;d.x=b(k.x,l.x,p.x,n.x,g,h,i);d.y=b(k.y,l.y,p.y,n.y,g,h,i);d.z=b(k.z,l.z,p.z,n.z,g,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(Ma.getX()),Math.floor(Ma.getY()),Math.floor(Ma.getWidth()),Math.floor(Ma.getHeight())),0=j||(j*=g.intensity,d.r+=Z.r*j,d.g+=Z.g*j,d.b+=Z.b*j)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),j=c.dot(Ia.sub(h,b).normalize()),0>=j||(j*=0==g.distance?1:1-Math.min(b.distanceTo(h)/g.distance,1),0!=j&&(j*=g.intensity,d.r+=Z.r*j,d.g+=Z.g*j,d.b+=Z.b*j)))}function r(a,f,g){b(g.opacity);c(g.blending);var Z,j,h,i,l,k;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)i= g.map.image,l=i.width>>1,k=i.height>>1,g=f.scale.x*o,h=f.scale.y*q,Z=g*l,j=h*k,xa.set(a.x-Z,a.y-j,a.x+Z,a.y+j),Aa.intersects(xa)&&(m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(g,-h),m.translate(-l,-k),m.drawImage(i,0,0),m.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(Z=f.scale.x*o,j=f.scale.y*q,xa.set(a.x-Z,a.y-j,a.x+Z,a.y+j),Aa.intersects(xa)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(Z,j),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(A!=a)m.lineWidth=A=a;a=g.linecap;if(D!=a)m.lineCap=D=a;a=g.linejoin;if(E!=a)m.lineJoin=E=a;d(g.color.getContextStyle());m.stroke();xa.inflate(2*g.linewidth)}}function t(a,d,e,g,h,k,Q,m){f.info.render.vertices+=3;f.info.render.faces++;b(m.opacity);c(m.blending); P=a.positionScreen.x;B=a.positionScreen.y;j=d.positionScreen.x;H=d.positionScreen.y;V=e.positionScreen.x;y=e.positionScreen.y;x(P,B,j,H,V,y);if(m instanceof THREE.MeshBasicMaterial)if(m.map)m.map.mapping instanceof THREE.UVMapping&&(Fa=Q.uvs[0],Mc(P,B,j,H,V,y,Fa[g].u,Fa[g].v,Fa[h].u,Fa[h].v,Fa[k].u,Fa[k].v,m.map));else if(m.envMap){if(m.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,Ia.copy(Q.vertexNormalsWorld[g]),ab=0.5*(Ia.x*a.n11+Ia.y*a.n12+Ia.z*a.n13)+0.5,gb= 0.5*-(Ia.x*a.n21+Ia.y*a.n22+Ia.z*a.n23)+0.5,Ia.copy(Q.vertexNormalsWorld[h]),Ra=0.5*(Ia.x*a.n11+Ia.y*a.n12+Ia.z*a.n13)+0.5,Sa=0.5*-(Ia.x*a.n21+Ia.y*a.n22+Ia.z*a.n23)+0.5,Ia.copy(Q.vertexNormalsWorld[k]),bb=0.5*(Ia.x*a.n11+Ia.y*a.n12+Ia.z*a.n13)+0.5,Wa=0.5*-(Ia.x*a.n21+Ia.y*a.n22+Ia.z*a.n23)+0.5,Mc(P,B,j,H,V,y,ab,gb,Ra,Sa,bb,Wa,m.envMap)}else m.wireframe?Eb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(m.color);else if(m instanceof THREE.MeshLambertMaterial)m.map&&!m.wireframe&& (m.map.mapping instanceof THREE.UVMapping&&(Fa=Q.uvs[0],Mc(P,B,j,H,V,y,Fa[g].u,Fa[g].v,Fa[h].u,Fa[h].v,Fa[k].u,Fa[k].v,m.map)),c(THREE.SubtractiveBlending)),Sb?!m.wireframe&&m.shading==THREE.SmoothShading&&3==Q.vertexNormalsWorld.length?(ba.r=$.r=ca.r=Z.r,ba.g=$.g=ca.g=Z.g,ba.b=$.b=ca.b=Z.b,p(i,Q.v1.positionWorld,Q.vertexNormalsWorld[0],ba),p(i,Q.v2.positionWorld,Q.vertexNormalsWorld[1],$),p(i,Q.v3.positionWorld,Q.vertexNormalsWorld[2],ca),ba.r=Math.max(0,Math.min(m.color.r*ba.r,1)),ba.g=Math.max(0, Math.min(m.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(m.color.b*ba.b,1)),$.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)),ca.r=Math.max(0,Math.min(m.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(m.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(m.color.b*ca.b,1)),ia.r=0.5*($.r+ca.r),ia.g=0.5*($.g+ca.g),ia.b=0.5*($.b+ca.b),Ga=vc(ba,$,ca,ia),Yb(P,B,j,H,V,y,0,0,1,0,0,1,Ga)):(S.r=Z.r,S.g=Z.g,S.b=Z.b,p(i,Q.centroidWorld,Q.normalWorld,S), S.r=Math.max(0,Math.min(m.color.r*S.r,1)),S.g=Math.max(0,Math.min(m.color.g*S.g,1)),S.b=Math.max(0,Math.min(m.color.b*S.b,1)),m.wireframe?Eb(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(S)):m.wireframe?Eb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(m.color);else if(m instanceof THREE.MeshDepthMaterial)za=l.near,qa=l.far,ba.r=ba.g=ba.b=1-Tb(a.positionScreen.z,za,qa),$.r=$.g=$.b=1-Tb(d.positionScreen.z,za,qa),ca.r=ca.g=ca.b=1-Tb(e.positionScreen.z,za, qa),ia.r=0.5*($.r+ca.r),ia.g=0.5*($.g+ca.g),ia.b=0.5*($.b+ca.b),Ga=vc(ba,$,ca,ia),Yb(P,B,j,H,V,y,0,0,1,0,0,1,Ga);else if(m instanceof THREE.MeshNormalMaterial)S.r=Zb(Q.normalWorld.x),S.g=Zb(Q.normalWorld.y),S.b=Zb(Q.normalWorld.z),m.wireframe?Eb(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(S)}function u(a,d,e,g,h,k,m,Q,n){f.info.render.vertices+=4;f.info.render.faces++;b(Q.opacity);c(Q.blending);if(Q.map||Q.envMap)t(a,d,g,0,1,3,m,Q,n),t(h,e,k,1,2,3,m,Q,n);else if(P=a.positionScreen.x, B=a.positionScreen.y,j=d.positionScreen.x,H=d.positionScreen.y,V=e.positionScreen.x,y=e.positionScreen.y,I=g.positionScreen.x,O=g.positionScreen.y,T=h.positionScreen.x,aa=h.positionScreen.y,ga=k.positionScreen.x,fa=k.positionScreen.y,Q instanceof THREE.MeshBasicMaterial)v(P,B,j,H,V,y,I,O),Q.wireframe?Eb(Q.color,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):zb(Q.color);else if(Q instanceof THREE.MeshLambertMaterial)Sb?!Q.wireframe&&Q.shading==THREE.SmoothShading&&4==m.vertexNormalsWorld.length? (ba.r=$.r=ca.r=ia.r=Z.r,ba.g=$.g=ca.g=ia.g=Z.g,ba.b=$.b=ca.b=ia.b=Z.b,p(i,m.v1.positionWorld,m.vertexNormalsWorld[0],ba),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],$),p(i,m.v4.positionWorld,m.vertexNormalsWorld[3],ca),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ia),ba.r=Math.max(0,Math.min(Q.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(Q.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(Q.color.b*ba.b,1)),$.r=Math.max(0,Math.min(Q.color.r*$.r,1)),$.g=Math.max(0,Math.min(Q.color.g*$.g,1)),$.b=Math.max(0, Math.min(Q.color.b*$.b,1)),ca.r=Math.max(0,Math.min(Q.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(Q.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(Q.color.b*ca.b,1)),ia.r=Math.max(0,Math.min(Q.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(Q.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(Q.color.b*ia.b,1)),Ga=vc(ba,$,ca,ia),x(P,B,j,H,I,O),Yb(P,B,j,H,I,O,0,0,1,0,0,1,Ga),x(T,aa,V,y,ga,fa),Yb(T,aa,V,y,ga,fa,1,0,1,1,0,1,Ga)):(S.r=Z.r,S.g=Z.g,S.b=Z.b,p(i,m.centroidWorld,m.normalWorld,S),S.r=Math.max(0,Math.min(Q.color.r* S.r,1)),S.g=Math.max(0,Math.min(Q.color.g*S.g,1)),S.b=Math.max(0,Math.min(Q.color.b*S.b,1)),v(P,B,j,H,V,y,I,O),Q.wireframe?Eb(S,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):zb(S)):(v(P,B,j,H,V,y,I,O),Q.wireframe?Eb(Q.color,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):zb(Q.color));else if(Q instanceof THREE.MeshNormalMaterial)S.r=Zb(m.normalWorld.x),S.g=Zb(m.normalWorld.y),S.b=Zb(m.normalWorld.z),v(P,B,j,H,V,y,I,O),Q.wireframe?Eb(S,Q.wireframeLinewidth,Q.wireframeLinecap, Q.wireframeLinejoin):zb(S);else if(Q instanceof THREE.MeshDepthMaterial)za=l.near,qa=l.far,ba.r=ba.g=ba.b=1-Tb(a.positionScreen.z,za,qa),$.r=$.g=$.b=1-Tb(d.positionScreen.z,za,qa),ca.r=ca.g=ca.b=1-Tb(g.positionScreen.z,za,qa),ia.r=ia.g=ia.b=1-Tb(e.positionScreen.z,za,qa),Ga=vc(ba,$,ca,ia),x(P,B,j,H,I,O),Yb(P,B,j,H,I,O,0,0,1,0,0,1,Ga),x(T,aa,V,y,ga,fa),Yb(T,aa,V,y,ga,fa,1,0,1,1,0,1,Ga)}function x(a,b,c,d,e,f){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(a,b);m.closePath()}function v(a, b,c,d,e,f,g,Z){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(g,Z);m.lineTo(a,b);m.closePath()}function Eb(a,b,c,e){if(A!=b)m.lineWidth=A=b;if(D!=c)m.lineCap=D=c;if(E!=e)m.lineJoin=E=e;d(a.getContextStyle());m.stroke();xa.inflate(2*b)}function zb(a){e(a.getContextStyle());m.fill()}function Mc(a,b,c,d,f,g,Z,h,j,i,Q,l,k){if(0!=k.image.width){if(!0==k.needsUpdate||void 0==La[k.id]){var n=k.wrapS==THREE.RepeatWrapping,p=k.wrapT==THREE.RepeatWrapping;La[k.id]=m.createPattern(k.image, n&&p?"repeat":n&&!p?"repeat-x":!n&&p?"repeat-y":"no-repeat");k.needsUpdate=!1}e(La[k.id]);var n=k.offset.x/k.repeat.x,p=k.offset.y/k.repeat.y,jb=k.image.width*k.repeat.x,o=k.image.height*k.repeat.y,Z=(Z+n)*jb,h=(h+p)*o,c=c-a,d=d-b,f=f-a,g=g-b,j=(j+n)*jb-Z,i=(i+p)*o-h,Q=(Q+n)*jb-Z,l=(l+p)*o-h,n=j*l-Q*i;if(0==n){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];Z=4*(Math.floor(Z)+Math.floor(h)*k.image.width);S.setRGB(b[Z]/255,b[Z+1]/255,b[Z+2]/255);zb(S)}else n=1/n,k=(l*c-i*f)*n,i=(l*d-i*g)*n,c=(j*f-Q*c)*n,d=(j*g-Q*d)*n,a=a-k*Z-c*h,Z=b-i*Z-d*h,m.save(),m.transform(k,i,c,d,a,Z),m.fill(),m.restore()}}function Yb(a,b,c,d,e,f,g,Z,h,j,i,k,Q){var l,n;l=Q.width-1;n=Q.height-1;g*=l;Z*=n;c-=a;d-=b;e-=a;f-=b;h=h*l-g;j=j*n-Z;i=i*l-g;k=k*n-Z;n=1/(h*k-i*j);l=(k*c-j*e)*n;j=(k*d-j*f)*n;c=(h*e-i*c)*n;d=(h*f-i*d)*n;a=a-l*g-c*Z;b=b-j*g-d*Z; m.save();m.transform(l,j,c,d,a,b);m.clip();m.drawImage(Q,0,0);m.restore()}function vc(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),Z=~~(255*b.g),b=~~(255*b.b),h=~~(255*c.r),j=~~(255*c.g),c=~~(255*c.b),i=~~(255*d.r),k=~~(255*d.g),d=~~(255*d.b);cb[0]=0>e?0:255f?0:255a?0:255g?0:255Z?0:255b?0:255h?0:255j?0:255c?0:255i?0:255< i?255:i;cb[13]=0>k?0:255d?0:255a?0:1=k||(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),k=c.dot(C.sub(i,b).normalize()),0>=k||(k*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=k&&(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)))}function b(a){null==F[a]&&(F[a]=document.createElementNS("http://www.w3.org/2000/svg", "path"),0==P&&F[a].setAttribute("shape-rendering","crispEdges"));return F[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 float shadowDarkness;\nuniform float shadowBias;\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\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec3 shadowColor = vec3( 1.0 );\nfloat fDepth;\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nshadowCoord.z += shadowBias;\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;\nconst float dx0 = -1.25 * xPixelOffset;\nconst float dy0 = -1.25 * yPixelOffset;\nconst float dx1 = 1.25 * xPixelOffset;\nconst float 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 * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( 1.0 - shadowDarkness );\n#endif\n}\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"}; THREE.UniformsUtils={merge:function(a){var b,c,d,e={};for(b=0;bn;n++){p=m;r=n;if(B.autoScaleCubemaps){if(s= h.image[n],O=Aa,!(s.width<=O&&s.height<=O))u=Math.max(s.width,s.height),t=Math.floor(s.width*O/u),O=Math.floor(s.height*O/u),u=document.createElement("canvas"),u.width=t,u.height=O,u.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,O),s=u}else s=h.image[n];p[r]=s}n=m[0];p=0===(n.width&n.width-1)&&0===(n.height&n.height-1);r=D(h.format);s=D(h.type);x(j.TEXTURE_CUBE_MAP,h,p);for(n=0;6>n;n++)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,r,r,s,m[n]);h.generateMipmaps&&p&&j.generateMipmap(j.TEXTURE_CUBE_MAP); h.needsUpdate=!1;if(h.onUpdated)h.onUpdated()}else j.activeTexture(j.TEXTURE0+m),j.bindTexture(j.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}else n instanceof THREE.WebGLRenderTargetCube?(h=n,j.activeTexture(j.TEXTURE0+m),j.bindTexture(j.TEXTURE_CUBE_MAP,h.__webglTexture)):B.setTexture(n,m)}else if("tv"===p){if(!h._array){h._array=[];for(p=0,r=h.texture.length;p k&&(l=n,k=h[l]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[g]=k;i[l]=1;k=-1;g++}}null!==d.program.uniforms.morphTargetInfluences&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(g=0,h=e.__webglCustomAttributesList.length;gka;ka++)Nb=ac[ka],fb[Pa]=Nb.x,fb[Pa+1]=Nb.y,fb[Pa+2]=Nb.z,Pa+=3;else for(ka=0;3>ka;ka++)fb[Pa]=Gb.x,fb[Pa+1]=Gb.y,fb[Pa+2]=Gb.z,Pa+=3;for(G=0,U=ma.length;Gka;ka++)Nb=ac[ka],fb[Pa]=Nb.x,fb[Pa+1]=Nb.y,fb[Pa+2]=Nb.z,Pa+=3;else for(ka=0;4>ka;ka++)fb[Pa]=Gb.x,fb[Pa+1]=Gb.y,fb[Pa+2]=Gb.z,Pa+=3;j.bindBuffer(j.ARRAY_BUFFER, da.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,fb,Za)}if(cd&&Tc&&Zc){for(G=0,U=la.length;Gka;ka++)dc=bc[ka],oc[Bb]=dc.u,oc[Bb+1]=dc.v,Bb+=2;for(G=0,U=ma.length;Gka;ka++)dc=bc[ka],oc[Bb]=dc.u,oc[Bb+1]=dc.v,Bb+=2;0ka;ka++)ec=cc[ka],pc[Cb]=ec.u,pc[Cb+1]=ec.v,Cb+=2;for(G=0,U=ma.length;Gka;ka++)ec=cc[ka],pc[Cb]=ec.u,pc[Cb+1]=ec.v,Cb+=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,e,null);var f=a,g=j.TEXTURE_CUBE_MAP_POSITIVE_X+c;j.bindFramebuffer(j.FRAMEBUFFER, a.__webglFramebuffer[c]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,g,f.__webglTexture,0);v(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer=j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture),x(j.TEXTURE_2D,a,c),j.texImage2D(j.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,d,a.__webglTexture,0),v(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=e=0):(b=null,d=qa,a=Ga,e=ja,c=za);b!==y&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(e,c,d,a),y=b);Fa=d;ab=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 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);1a?b(c,e-1):k[e]p-1?e-1:p-1,o=(p+1)%e,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),e,f=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),f+=c.distanceTo(d),b.push(f),d=c;return this.cacheArcLengths=b}; THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,e=c.length,f;f=b?b:a*c[e-1];for(var g=0,h=e-1,i;g<=h;)if(d=Math.floor(g+(h-g)/2),i=c[d]-f,0>i)g=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.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.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,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);b.z=THREE.Curve.Utils.interpolate(d[c[0]].z,d[c[1]].z,d[c[2]].z,d[c[3]].z,e);return b}); THREE.CurvePath=function(){this.curves=[];this.bends=[]};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(){}; 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.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+n>m+r&&(h=o,g=l,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);n=c.slice(h);o=k.slice(g);l=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(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,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)}, 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}; 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<=n){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",o,g.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",o,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===l[0][k]){this.hierarchy[0].updateMatrixWorld(!0);for(o=0;oa.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?c(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;fi)?1:i));this.object.translateX(b*k);this.object.translateY(b*l);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.yc.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),f.lengthSq()o;o++)this.materials.push(g)}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,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=[],l=[];for(i=0;i<=e;i++){var p=[],n=[],o=i/e,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+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);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 e(a){for(H=a.length;0<=--H;){y=H;I=H-1;0>I&&(I=a.length-1);for(var b= 0,c=o+2*l,b=0;bh?(h=new THREE.Face3(a.index,b.index,c.index,[a.position,b.position,c.position]),h.centroid.addSelf(a.position).addSelf(b.position).addSelf(c.position).divideScalar(3),h.normal=h.centroid.clone().normalize(), g.faces.push(h),h=Math.atan2(h.centroid.z,-h.centroid.x),g.faceVertexUvs[0].push([f(a.uv,a.position,h),f(b.uv,b.position,h),f(c.uv,c.position,h)])):(h-=1,d(a,e(a,b),e(a,c),h),d(e(a,b),b,e(b,c),h),d(e(a,c),e(b,c),c,h),d(e(a,b),e(b,c),e(a,c),h))}function e(a,b){h[a.index]||(h[a.index]=[]);h[b.index]||(h[b.index]=[]);var d=h[a.index][b.index];void 0===d&&(h[a.index][b.index]=h[b.index][a.index]=d=c((new THREE.Vector3).add(a.position,b.position).divideScalar(2)));return d}function f(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);var b=b||0,g=this;c(new THREE.Vector3(1,0,0));c(new THREE.Vector3(-1,0,0));c(new THREE.Vector3(0,1,0));c(new THREE.Vector3(0,-1,0));c(new THREE.Vector3(0,0,1));c(new THREE.Vector3(0,0,-1));var h=[],i=this.vertices;d(i[0],i[2],i[4],b);d(i[0],i[4],i[3],b);d(i[0],i[3],i[5],b);d(i[0],i[5],i[2],b);d(i[1],i[2],i[5],b);d(i[1],i[5],i[3],b);d(i[1],i[3],i[4],b);d(i[1],i[4],i[2],b);this.boundingSphere= {radius:a}};THREE.OctahedronGeometry.prototype=new THREE.Geometry;THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry; THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);for(var e=a/2,f=b/2,c=c||1,d=d||1,g=c+1,h=d+1,i=a/c,k=b/d,l=new THREE.Vector3(0,0,1),a=0;ae)return null;var f=[],g=[],h=[],i,k,l;if(0=p--){console.log("Warning, unable to triangulate polygon!");break}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);l=k+1;e<=l&&(l=0);var n;a:{n=a;var o=i,q=k,m=l,r=e,s=g,t=void 0,u=void 0,x=void 0,v=void 0,A=void 0, D=void 0,E=void 0,C=void 0,F=void 0,u=n[s[o]].x,x=n[s[o]].y,v=n[s[q]].x,A=n[s[q]].y,D=n[s[m]].x,E=n[s[m]].y;if(1.0E-10>(v-u)*(E-x)-(A-x)*(D-u))n=!1;else{for(t=0;to;o++){p=i[o];l=new THREE.Color;l.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("_"),A=v[0],v=v[1],r=new THREE.Vector3,p[o]?(r.addSelf(h[A].position),r.addSelf(h[v].position),r.multiplyScalar(0.5)):(r.addSelf(k[s]),r.addSelf(k[u]),r.addSelf(h[A].position),r.addSelf(h[v].position),r.multiplyScalar(0.25)), l[o]=t+d.length+x,i.push(new THREE.Vertex(r)),x++,g.supportUVs&&0!=n.length)u=new THREE.UV,u.u=n[A].u+n[v].u,u.v=n[A].v+n[v].v,u.u/=2,u.v/=2,n.push(u);var K,L;v=["123","12","2","23"];r=["123","23","3","31"];var C=["123","31","1","12"],F=["1234","12","2","23"],R=["1234","23","3","34"],N=["1234","34","4","41"],P=["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=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,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),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,l,p,n,o,q,m,r,s,t,u,x,v;function A(a){return a%4?4-a%4:0}function D(a,b){return(new Uint8Array(a,b,1))[0]}function E(a,b){return(new Uint32Array(a,b,1))[0]}function C(b,c){var d,e,f,g,h,i,j,k,l=new Uint32Array(a,c,3*b);for(d=0;da.length?"":a.join("/")+"/");if((a=S.evaluate("//dae:asset",S,V,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;el)break}if(!r){r=new H(l);s=-1;t=0;for(u=d.length;t=l&&(s=t);l=s;d.splice(-1==l?d.length:l,0,r)}r.addTarget(f,j,g,q)}}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 C)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=La[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=Wa;return this.material=new THREE.MeshLambertMaterial(a)};K.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};L.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;L=r.parameters.specular;c=r.parameters.ambient;P=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(L);a.uAmbientColor.value.setHex(c);a.uShininess.value=P;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}e();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,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;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 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(e=0;el&&(q=l);for(f=0;fl&&(q=l);for(g=0;g=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,e,s){var a=a.__webglFlares,t=a.length;if(t){var u=new THREE.Vector3,x=s/e,v=0.5*e,A=0.5*s,D=16/s,E=new THREE.Vector2(D*x,D),C=new THREE.Vector3(1,1,0),F=new THREE.Vector2(1,1),K=n,D=p;b.useProgram(l);o||(b.enableVertexAttribArray(p.vertex),b.enableVertexAttribArray(p.uv),o=!0);b.uniform1i(K.occlusionMap,0);b.uniform1i(K.map, 1);b.bindBuffer(b.ARRAY_BUFFER,f);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,g);b.disable(b.CULL_FACE);b.depthMask(!1);var L,R,N,P,B;for(L=0;L