// Three.js r46dev - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;THREE.Clock=function(a){this.autoStart=a!==void 0?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(){this.elapsedTime+=this.getDelta();return this.elapsedTime}; 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){a!==void 0&&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},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var e,f,h;if(c==0)this.r=this.g=this.b=0;else switch(e=Math.floor(a*6),f=a*6-e,a=c*(1-b),h=c*(1- b*f),b=c*(1-b*(1-f)),e){case 1:this.r=h;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=h;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=h;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+ Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this}, divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)}, 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.set(0,0,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){return this.set(this.y*a.z-this.z*a.y,this.z*a.x-this.x*a.z,this.x*a.y-this.y*a.x)},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); Math.abs(b)>1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b),this.z=Math.atan2(-a.n12/b,a.n11/b)):(this.x=0,this.z=Math.atan2(a.n21,a.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e!==void 0?e:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.objects)},intersectObjects:function(a){var b,c,e=[];b=0;for(c=a.length;b0&&a>0&&k+a<1}for(var e,f=[],h=0,k=a.children.length;ha.scale.x)return[];e={distance:h,point:a.position,face:null,object:a};f.push(e)}else if(a instanceof THREE.Mesh){h=b(this.origin, this.direction,a.matrixWorld.getPosition());if(h==null||h>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return f;for(var l,m,t,u,p,v,o,z,x=a.geometry,w=x.vertices,h=0,k=x.faces.length;h0:v<0)))if(v=p.dot((new THREE.Vector3).sub(l,o))/v,o=o.addSelf(z.multiplyScalar(v)),e instanceof THREE.Face3)c(o,l,m,t)&&(e={distance:this.origin.distanceTo(o),point:o,face:e,object:a},f.push(e));else if(e instanceof THREE.Face4&&(c(o,l,m,u)||c(o,m,t,u)))e={distance:this.origin.distanceTo(o),point:o,face:e,object:a},f.push(e)}return f}}; THREE.Rectangle=function(){function a(){h=e-b;k=f-c}var b,c,e,f,h,k,l=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(k,h,u,p){l=!1;b=k;c=h;e=u;f=p;a()};this.addPoint=function(k,h){l?(l=!1,b=k,c=h,e=k,f=h):(b=bk?e:k,f=f>h?f:h);a()};this.add3Points= function(k,h,u,p,v,o){l?(l=!1,b=ku?k>v?k:v:u>v?u:v,f=h>p?h>o?h:o:p>o?p:o):(b=ku?k>v?k>e?k:e:v>e?v:e:u>v?u>e?u:e:v>e?v:e,f=h>p?h>o?h>f?h:f:o>f?o:f:p>o?p>f?p:f:o>f?o:f);a()};this.addRectangle=function(k){l?(l=!1,b=k.getLeft(),c=k.getTop(),e=k.getRight(),f=k.getBottom()):(b=bk.getRight()?e:k.getRight(),f=f> k.getBottom()?f:k.getBottom());a()};this.inflate=function(k){b-=k;c-=k;e+=k;f+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();c=c>k.getTop()?c:k.getTop();e=e=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){l=!0;f=e=c=b=0;a()};this.isEmpty=function(){return l}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=0&&k>=0&&h>=0&&l>=0?!0:f<0&&k<0||h<0&&l<0?!1:(f<0?b=Math.max(b,f/(f-k)):k<0&&(e=Math.min(e,f/(f-k))),h<0?b=Math.max(b,h/(h-l)):l<0&&(e=Math.min(e,h/(h-l))),eE&&k.positionScreen.z0&&F.z<1))fa=A[y]=A[y]||new THREE.RenderableParticle,y++,B=fa,B.x=F.x/F.w,B.y=F.y/F.w,B.z=F.z,B.rotation=T.rotation.z,B.scale.x=T.scale.x*Math.abs(B.x-(F.x+f.projectionMatrix.n11)/(F.w+f.projectionMatrix.n14)),B.scale.y=T.scale.y*Math.abs(B.y-(F.y+f.projectionMatrix.n22)/(F.w+f.projectionMatrix.n24)),B.materials=T.materials,C.push(B);h&&C.sort(b);return C}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==void 0?e:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;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,e=a.y*b,f=a.z*b,a=Math.cos(e),e=Math.sin(e),b=Math.cos(-f),f=Math.sin(-f),h=Math.cos(c),c=Math.sin(c),k=a*b,l=e*f;this.w=k*h-l*c;this.x=k*c+l*h;this.y=e*b*h+a*f*c;this.z=a*f*h-e*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,e=Math.sin(c); this.x=a.x*e;this.y=a.y*e;this.z=a.z*e;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= this.x,c=this.y,e=this.z,f=this.w,h=a.x,k=a.y,l=a.z,a=a.w;this.x=b*a+f*h+c*l-e*k;this.y=c*a+f*k+e*h-b*l;this.z=e*a+f*l+b*k-c*h;this.w=f*a-b*h-c*k-e*l;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,e=a.y,f=a.z,h=this.x,k=this.y,l=this.z,m=this.w,t=m*c+k*f-l*e,u=m*e+l*c-h*f,p=m*f+h*e-k*c,c=-h* c-k*e-l*f;b.x=t*m+c*-h+u*-l-p*-k;b.y=u*m+c*-k+p*-h-t*-l;b.z=p*m+c*-l+t*-k-u*-h;return b}};THREE.Quaternion.slerp=function(a,b,c,e){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var h=Math.acos(f),k=Math.sqrt(1-f*f);if(Math.abs(k)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-e)*h)/k;e=Math.sin(e*h)/k;c.w=a.w*f+b.w*e;c.x=a.x*f+b.x*e;c.y=a.y*f+b.y*e;c.z=a.z*f+b.z*e;return c}; THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,e,f,h){this.a=a;this.b=b;this.c=c;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=h;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,e,f,h,k){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materialIndex=k;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,e=this.vertices.length;c0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;bthis.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;t=this.points[c[0]];u=this.points[c[1]]; p=this.points[c[2]];v=this.points[c[3]];l=k*k;m=k*l;e.x=b(t.x,u.x,p.x,v.x,k,l,m);e.y=b(t.y,u.y,p.y,v.y,k,l,m);e.z=b(t.z,u.z,p.z,v.z,k,l,m);return e};this.getControlPointsArray=function(){var a,c,b=this.points.length,e=[];for(a=0;athis.duration||this.time<0){this.direction*=-1;if(this.time>this.duration)this.time=this.duration,this.directionBackwards=!0;if(this.time<0)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){b===void 0&&(b=0);for(var b=Math.abs(b),c=0;c1){a=c.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1, this.LODs[e].object3D.visible=!0;else break;for(;e0&&(c(THREE.NormalBlending),b(1),f("rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+ Math.floor(z.b*255)+","+x+")"),o.fillRect(Math.floor(M.getX()),Math.floor(M.getY()),Math.floor(M.getWidth()),Math.floor(M.getHeight()))),M.empty())};this.render=function(a,m){function t(a){var c,b,e,f=a.lights;K.setRGB(0,0,0);ra.setRGB(0,0,0);wa.setRGB(0,0,0);a=0;for(c=f.length;a>1,va=t.height>>1,h=k.scale.x*p,m=k.scale.y*v,n=h*u,l=m*va,Y.set(a.x-n,a.y-l,a.x+n,a.y+l),Da.intersects(Y)&&(o.save(),o.translate(a.x,a.y),o.rotate(-k.rotation),o.scale(h,-m),o.translate(-u,-va),o.drawImage(t,0,0),o.restore())}else h instanceof THREE.ParticleCanvasMaterial&&(n=k.scale.x*p,l=k.scale.y*v,Y.set(a.x-n,a.y-l,a.x+n,a.y+l),Da.intersects(Y)&&(e(h.color.getContextStyle()),f(h.color.getContextStyle()),o.save(),o.translate(a.x,a.y),o.rotate(-k.rotation),o.scale(n,l),h.program(o), o.restore()))}function x(a,f,k,h){b(h.opacity);c(h.blending);o.beginPath();o.moveTo(a.positionScreen.x,a.positionScreen.y);o.lineTo(f.positionScreen.x,f.positionScreen.y);o.closePath();if(h instanceof THREE.LineBasicMaterial){a=h.linewidth;if(E!=a)o.lineWidth=E=a;a=h.linecap;if(C!=a)o.lineCap=C=a;a=h.linejoin;if(L!=a)o.lineJoin=L=a;e(h.color.getContextStyle());o.stroke();Y.inflate(h.linewidth*2)}}function z(a,e,f,k,l,t,p,o,v){h.info.render.vertices+=3;h.info.render.faces++;b(o.opacity);c(o.blending); J=a.positionScreen.x;V=a.positionScreen.y;X=e.positionScreen.x;O=e.positionScreen.y;n=f.positionScreen.x;U=f.positionScreen.y;B(J,V,X,O,n,U);if(o instanceof THREE.MeshBasicMaterial)if(o.map)o.map.mapping instanceof THREE.UVMapping&&(ma=p.uvs[0],$a(J,V,X,O,n,U,ma[k].u,ma[k].v,ma[l].u,ma[l].v,ma[t].u,ma[t].v,o.map));else if(o.envMap){if(o.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=m.matrixWorldInverse,ha.copy(p.vertexNormalsWorld[0]),na=(ha.x*a.n11+ha.y*a.n12+ha.z*a.n13)*0.5+0.5,pa= -(ha.x*a.n21+ha.y*a.n22+ha.z*a.n23)*0.5+0.5,ha.copy(p.vertexNormalsWorld[1]),Ca=(ha.x*a.n11+ha.y*a.n12+ha.z*a.n13)*0.5+0.5,Fa=-(ha.x*a.n21+ha.y*a.n22+ha.z*a.n23)*0.5+0.5,ha.copy(p.vertexNormalsWorld[2]),Ea=(ha.x*a.n11+ha.y*a.n12+ha.z*a.n13)*0.5+0.5,za=-(ha.x*a.n21+ha.y*a.n22+ha.z*a.n23)*0.5+0.5,$a(J,V,X,O,n,U,na,pa,Ca,Fa,Ea,za,o.envMap)}else o.wireframe?Ma(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(o.color);else if(o instanceof THREE.MeshLambertMaterial)o.map&&!o.wireframe&& (o.map.mapping instanceof THREE.UVMapping&&(ma=p.uvs[0],$a(J,V,X,O,n,U,ma[k].u,ma[k].v,ma[l].u,ma[l].v,ma[t].u,ma[t].v,o.map)),c(THREE.SubtractiveBlending)),ia?!o.wireframe&&o.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3?(Q.r=T.r=fa.r=K.r,Q.g=T.g=fa.g=K.g,Q.b=T.b=fa.b=K.b,u(v,p.v1.positionWorld,p.vertexNormalsWorld[0],Q),u(v,p.v2.positionWorld,p.vertexNormalsWorld[1],T),u(v,p.v3.positionWorld,p.vertexNormalsWorld[2],fa),Q.r=Math.max(0,Math.min(o.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(o.color.g* Q.g,1)),Q.b=Math.max(0,Math.min(o.color.b*Q.b,1)),T.r=Math.max(0,Math.min(o.color.r*T.r,1)),T.g=Math.max(0,Math.min(o.color.g*T.g,1)),T.b=Math.max(0,Math.min(o.color.b*T.b,1)),fa.r=Math.max(0,Math.min(o.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(o.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(o.color.b*fa.b,1)),ga.r=(T.r+fa.r)*0.5,ga.g=(T.g+fa.g)*0.5,ga.b=(T.b+fa.b)*0.5,sa=Xa(Q,T,fa,ga),Ua(J,V,X,O,n,U,0,0,1,0,0,1,sa)):(ja.r=K.r,ja.g=K.g,ja.b=K.b,u(v,p.centroidWorld,p.normalWorld,ja),Z.r=Math.max(0,Math.min(o.color.r* ja.r,1)),Z.g=Math.max(0,Math.min(o.color.g*ja.g,1)),Z.b=Math.max(0,Math.min(o.color.b*ja.b,1)),o.wireframe?Ma(Z,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(Z)):o.wireframe?Ma(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(o.color);else if(o instanceof THREE.MeshDepthMaterial)oa=m.near,da=m.far,Q.r=Q.g=Q.b=1-Qa(a.positionScreen.z,oa,da),T.r=T.g=T.b=1-Qa(e.positionScreen.z,oa,da),fa.r=fa.g=fa.b=1-Qa(f.positionScreen.z,oa,da),ga.r=(T.r+fa.r)*0.5,ga.g=(T.g+ fa.g)*0.5,ga.b=(T.b+fa.b)*0.5,sa=Xa(Q,T,fa,ga),Ua(J,V,X,O,n,U,0,0,1,0,0,1,sa);else if(o instanceof THREE.MeshNormalMaterial)Z.r=Va(p.normalWorld.x),Z.g=Va(p.normalWorld.y),Z.b=Va(p.normalWorld.z),o.wireframe?Ma(Z,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(Z)}function y(a,e,f,k,l,t,o,p,v){h.info.render.vertices+=4;h.info.render.faces++;b(p.opacity);c(p.blending);if(p.map||p.envMap)z(a,e,k,0,1,3,o,p,v),z(l,f,t,1,2,3,o,p,v);else if(J=a.positionScreen.x,V=a.positionScreen.y,X=e.positionScreen.x, O=e.positionScreen.y,n=f.positionScreen.x,U=f.positionScreen.y,$=k.positionScreen.x,aa=k.positionScreen.y,ca=l.positionScreen.x,ea=l.positionScreen.y,la=t.positionScreen.x,ka=t.positionScreen.y,p instanceof THREE.MeshBasicMaterial)A(J,V,X,O,n,U,$,aa),p.wireframe?Ma(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Na(p.color);else if(p instanceof THREE.MeshLambertMaterial)ia?!p.wireframe&&p.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==4?(Q.r=T.r=fa.r=ga.r=K.r,Q.g= T.g=fa.g=ga.g=K.g,Q.b=T.b=fa.b=ga.b=K.b,u(v,o.v1.positionWorld,o.vertexNormalsWorld[0],Q),u(v,o.v2.positionWorld,o.vertexNormalsWorld[1],T),u(v,o.v4.positionWorld,o.vertexNormalsWorld[3],fa),u(v,o.v3.positionWorld,o.vertexNormalsWorld[2],ga),Q.r=Math.max(0,Math.min(p.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(p.color.g*Q.g,1)),Q.b=Math.max(0,Math.min(p.color.b*Q.b,1)),T.r=Math.max(0,Math.min(p.color.r*T.r,1)),T.g=Math.max(0,Math.min(p.color.g*T.g,1)),T.b=Math.max(0,Math.min(p.color.b*T.b,1)),fa.r=Math.max(0, Math.min(p.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(p.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(p.color.b*fa.b,1)),ga.r=Math.max(0,Math.min(p.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(p.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(p.color.b*ga.b,1)),sa=Xa(Q,T,fa,ga),B(J,V,X,O,$,aa),Ua(J,V,X,O,$,aa,0,0,1,0,0,1,sa),B(ca,ea,n,U,la,ka),Ua(ca,ea,n,U,la,ka,1,0,1,1,0,1,sa)):(ja.r=K.r,ja.g=K.g,ja.b=K.b,u(v,o.centroidWorld,o.normalWorld,ja),Z.r=Math.max(0,Math.min(p.color.r*ja.r,1)),Z.g=Math.max(0,Math.min(p.color.g* ja.g,1)),Z.b=Math.max(0,Math.min(p.color.b*ja.b,1)),A(J,V,X,O,n,U,$,aa),p.wireframe?Ma(Z,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Na(Z)):(A(J,V,X,O,n,U,$,aa),p.wireframe?Ma(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Na(p.color));else if(p instanceof THREE.MeshNormalMaterial)Z.r=Va(o.normalWorld.x),Z.g=Va(o.normalWorld.y),Z.b=Va(o.normalWorld.z),A(J,V,X,O,n,U,$,aa),p.wireframe?Ma(Z,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Na(Z);else if(p instanceof THREE.MeshDepthMaterial)oa=m.near,da=m.far,Q.r=Q.g=Q.b=1-Qa(a.positionScreen.z,oa,da),T.r=T.g=T.b=1-Qa(e.positionScreen.z,oa,da),fa.r=fa.g=fa.b=1-Qa(k.positionScreen.z,oa,da),ga.r=ga.g=ga.b=1-Qa(f.positionScreen.z,oa,da),sa=Xa(Q,T,fa,ga),B(J,V,X,O,$,aa),Ua(J,V,X,O,$,aa,0,0,1,0,0,1,sa),B(ca,ea,n,U,la,ka),Ua(ca,ea,n,U,la,ka,1,0,1,1,0,1,sa)}function B(a,c,b,e,f,k){o.beginPath();o.moveTo(a,c);o.lineTo(b,e);o.lineTo(f,k);o.lineTo(a,c);o.closePath()}function A(a,c,b,e,f,k,h,n){o.beginPath();o.moveTo(a, c);o.lineTo(b,e);o.lineTo(f,k);o.lineTo(h,n);o.lineTo(a,c);o.closePath()}function Ma(a,c,b,f){if(E!=c)o.lineWidth=E=c;if(C!=b)o.lineCap=C=b;if(L!=f)o.lineJoin=L=f;e(a.getContextStyle());o.stroke();Y.inflate(c*2)}function Na(a){f(a.getContextStyle());o.fill()}function $a(a,c,b,e,k,h,n,l,m,t,p,v,u){if(u.image.width!=0){if(u.needsUpdate==!0||qa[u.id]==void 0){var va=u.wrapS==THREE.RepeatWrapping,M=u.wrapT==THREE.RepeatWrapping;qa[u.id]=o.createPattern(u.image,va&&M?"repeat":va&&!M?"repeat-x":!va&&M? "repeat-y":"no-repeat");u.needsUpdate=!1}f(qa[u.id]);var va=u.offset.x/u.repeat.x,M=u.offset.y/u.repeat.y,w=(u.image.width-1)*u.repeat.x,u=(u.image.height-1)*u.repeat.y,n=(n+va)*w,l=(l+M)*u,m=(m+va)*w,t=(t+M)*u,p=(p+va)*w,v=(v+M)*u;b-=a;e-=c;k-=a;h-=c;m-=n;t-=l;p-=n;v-=l;va=1/(m*v-p*t);u=(v*b-t*k)*va;t=(v*e-t*h)*va;b=(m*k-p*b)*va;e=(m*h-p*e)*va;a=a-u*n-b*l;c=c-t*n-e*l;o.save();o.transform(u,t,b,e,a,c);o.fill();o.restore()}}function Ua(a,c,b,e,f,k,h,n,l,m,t,p,u){var v,va;v=u.width-1;va=u.height-1; h*=v;n*=va;l*=v;m*=va;t*=v;p*=va;b-=a;e-=c;f-=a;k-=c;l-=h;m-=n;t-=h;p-=n;va=1/(l*p-t*m);v=(p*b-m*f)*va;m=(p*e-m*k)*va;b=(l*f-t*b)*va;e=(l*k-t*e)*va;a=a-v*h-b*n;c=c-m*h-e*n;o.save();o.transform(v,m,b,e,a,c);o.clip();o.drawImage(u,0,0);o.restore()}function Xa(a,c,b,e){var f=~~(a.r*255),k=~~(a.g*255),a=~~(a.b*255),h=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),l=~~(b.r*255),m=~~(b.g*255),b=~~(b.b*255),t=~~(e.r*255),p=~~(e.g*255),e=~~(e.b*255);Ba[0]=f<0?0:f>255?255:f;Ba[1]=k<0?0:k>255?255:k;Ba[2]=a<0?0:a> 255?255:a;Ba[4]=h<0?0:h>255?255:h;Ba[5]=n<0?0:n>255?255:n;Ba[6]=c<0?0:c>255?255:c;Ba[8]=l<0?0:l>255?255:l;Ba[9]=m<0?0:m>255?255:m;Ba[10]=b<0?0:b>255?255:b;Ba[12]=t<0?0:t>255?255:t;Ba[13]=p<0?0:p>255?255:p;Ba[14]=e<0?0:e>255?255:e;ua.putImageData(ya,0,0);Ia.drawImage(xa,0,0);return Ha}function Qa(a,c,b){a=(a-c)/(b-c);return a*a*(3-2*a)}function Va(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Oa(a,c){var b=c.x-a.x,e=c.y-a.y,f=b*b+e*e;f!=0&&(f=1/Math.sqrt(f),b*=f,e*=f,c.x+=b,c.y+=e,a.x-=b,a.y-=e)}var Ya, ab,ta,Ga,Pa,Wa,Za,Aa;this.autoClear?this.clear():o.setTransform(1,0,0,-1,p,v);h.info.render.vertices=0;h.info.render.faces=0;k=l.projectScene(a,m,this.sortElements);(ia=a.lights.length>0)&&t(a);Ya=0;for(ab=k.length;Ya0&&(b.r+=k.color.r*h,b.g+=k.color.g*h,b.b+=k.color.b*h)):k instanceof THREE.PointLight&&(R.sub(k.position,c.centroidWorld),R.normalize(),h=c.normalWorld.dot(R)*k.intensity,h>0&&(b.r+=k.color.r*h,b.g+=k.color.g*h,b.b+=k.color.b*h))}function b(c,b,k,l,t,p){h.info.render.vertices+=3;h.info.render.faces++;J=e(V++); J.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+b.positionScreen.x+" "+b.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?E.copy(t.color):t instanceof THREE.MeshLambertMaterial?A?(C.r=L.r,C.g=L.g,C.b=L.b,a(p,l,C),E.r=Math.max(0,Math.min(t.color.r*C.r,1)),E.g=Math.max(0,Math.min(t.color.g*C.g,1)),E.b=Math.max(0,Math.min(t.color.b*C.b,1))):E.copy(t.color):t instanceof THREE.MeshDepthMaterial?(N=1-t.__2near/(t.__farPlusNear- l.z*t.__farMinusNear),E.setRGB(N,N,N)):t instanceof THREE.MeshNormalMaterial&&E.setRGB(f(l.normalWorld.x),f(l.normalWorld.y),f(l.normalWorld.z));t.wireframe?J.setAttribute("style","fill: none; stroke: "+E.getContextStyle()+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):J.setAttribute("style","fill: "+E.getContextStyle()+"; fill-opacity: "+t.opacity);m.appendChild(J)}function c(c,b,k,l,t,p,o){h.info.render.vertices+= 4;h.info.render.faces++;J=e(V++);J.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+b.positionScreen.x+" "+b.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+" L "+l.positionScreen.x+","+l.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?E.copy(p.color):p instanceof THREE.MeshLambertMaterial?A?(C.r=L.r,C.g=L.g,C.b=L.b,a(o,t,C),E.r=Math.max(0,Math.min(p.color.r*C.r,1)),E.g=Math.max(0,Math.min(p.color.g*C.g,1)),E.b=Math.max(0,Math.min(p.color.b*C.b,1))): E.copy(p.color):p instanceof THREE.MeshDepthMaterial?(N=1-p.__2near/(p.__farPlusNear-t.z*p.__farMinusNear),E.setRGB(N,N,N)):p instanceof THREE.MeshNormalMaterial&&E.setRGB(f(t.normalWorld.x),f(t.normalWorld.y),f(t.normalWorld.z));p.wireframe?J.setAttribute("style","fill: none; stroke: "+E.getContextStyle()+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):J.setAttribute("style","fill: "+E.getContextStyle()+ "; fill-opacity: "+p.opacity);m.appendChild(J)}function e(a){H[a]==null&&(H[a]=document.createElementNS("http://www.w3.org/2000/svg","path"),O==0&&H[a].setAttribute("shape-rendering","crispEdges"));return H[a]}function f(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var h=this,k=null,l=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),t,u,p,v,o,z,x,w,B=new THREE.Rectangle,y=new THREE.Rectangle,A=!1,E=new THREE.Color(16777215),C=new THREE.Color(16777215),L=new THREE.Color(0), F=new THREE.Color(0),G=new THREE.Color(0),N,R=new THREE.Vector3,H=[],S=[],J,V,X,O=1;this.domElement=m;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(a){switch(a){case "high":O=1;break;case "low":O=0}};this.setSize=function(a,c){t=a;u=c;p=t/2;v=u/2;m.setAttribute("viewBox",-p+" "+-v+" "+t+" "+u);m.setAttribute("width",t);m.setAttribute("height",u);B.set(-p,-v,p,v)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])}; this.render=function(a,e){var f,t,u,E,N,H,C,Q;this.autoClear&&this.clear();h.info.render.vertices=0;h.info.render.faces=0;k=l.projectScene(a,e,this.sortElements);X=V=0;if(A=a.lights.length>0){C=a.lights;L.setRGB(0,0,0);F.setRGB(0,0,0);G.setRGB(0,0,0);f=0;for(t=C.length;f 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", lights_lambert_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = 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 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\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 );\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n}\n#endif\nvLightWeighting = vLightWeighting * diffuse + ambient * ambientLightColor;\n}", 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 );\nlVector = normalize( lVector );\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\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\nvec3 pointHalfVector = normalize( lVector + viewPosition );\nfloat pointDistance = lDistance;\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointDiffuseWeight = max( dot( normal, lVector ), 0.0 );\nfloat pointSpecularWeight = pow( pointDotNormalHalf, shininess );\n#ifdef PHYSICALLY_BASED_SHADING\nvec3 schlick = specular + vec3( 1.0 - specular ) * pow( dot( lVector, pointHalfVector ), 5.0 );\npointSpecular += schlick * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance;\n#else\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDiffuseWeight * pointDistance;\n#endif\npointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * pointDistance;\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 );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = pow( dirDotNormalHalf, shininess );\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\ndirDiffuse += diffuse * directionalLightColor[ i ] * 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\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 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nshadowCoord.z += shadowBias;\nif ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( shadowDarkness );\n#endif\n}\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"}; THREE.UniformsUtils={merge:function(a){var b,c,e,f={};for(b=0;b=0&&(b=a.geometry.materials[c.materialIndex]);return b}function c(a,c,b){var e,f,k,h=a.vertices,l=h.length,m=a.colors,t=m.length,p=a.__vertexArray,o=a.__colorArray,u=a.__sortArray,v=a.__dirtyVertices,M=a.__dirtyColors,w=a.__webglCustomAttributesList,x;if(w){k=0;for(e=w.length;k=0)c&&(n.bindBuffer(n.ARRAY_BUFFER,f.__webglVertexBuffer),n.vertexAttribPointer(a.position,3,n.FLOAT,!1,0,0));else if(h.morphTargetBase){b=k.program.attributes;h.morphTargetBase!==-1?(n.bindBuffer(n.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[h.morphTargetBase]),n.vertexAttribPointer(b.position,3,n.FLOAT,!1,0,0)):b.position>=0&&(n.bindBuffer(n.ARRAY_BUFFER,f.__webglVertexBuffer), n.vertexAttribPointer(b.position,3,n.FLOAT,!1,0,0));if(h.morphTargetForcedOrder.length){l=0;var p=h.morphTargetForcedOrder;for(m=h.morphTargetInfluences;lt&&(o=u,t=m[o]);n.bindBuffer(n.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[o]);n.vertexAttribPointer(b["morphTarget"+l],3,n.FLOAT,!1,0,0);h.__webglMorphTargetInfluences[l]=t;p[o]=1;t=-1;l++}}k.program.uniforms.morphTargetInfluences!==null&&n.uniform1fv(k.program.uniforms.morphTargetInfluences,h.__webglMorphTargetInfluences)}if(c){if(f.__webglCustomAttributesList){l=0;for(m=f.__webglCustomAttributesList.length;l= 0&&(n.bindBuffer(n.ARRAY_BUFFER,b.buffer),n.vertexAttribPointer(a[b.buffer.belongsToAttribute],b.size,n.FLOAT,!1,0,0))}a.color>=0&&(n.bindBuffer(n.ARRAY_BUFFER,f.__webglColorBuffer),n.vertexAttribPointer(a.color,3,n.FLOAT,!1,0,0));a.normal>=0&&(n.bindBuffer(n.ARRAY_BUFFER,f.__webglNormalBuffer),n.vertexAttribPointer(a.normal,3,n.FLOAT,!1,0,0));a.tangent>=0&&(n.bindBuffer(n.ARRAY_BUFFER,f.__webglTangentBuffer),n.vertexAttribPointer(a.tangent,4,n.FLOAT,!1,0,0));a.uv>=0&&(f.__webglUVBuffer?(n.bindBuffer(n.ARRAY_BUFFER, f.__webglUVBuffer),n.vertexAttribPointer(a.uv,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(a.uv)):n.disableVertexAttribArray(a.uv));a.uv2>=0&&(f.__webglUV2Buffer?(n.bindBuffer(n.ARRAY_BUFFER,f.__webglUV2Buffer),n.vertexAttribPointer(a.uv2,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(a.uv2)):n.disableVertexAttribArray(a.uv2));k.skinning&&a.skinVertexA>=0&&a.skinVertexB>=0&&a.skinIndex>=0&&a.skinWeight>=0&&(n.bindBuffer(n.ARRAY_BUFFER,f.__webglSkinVertexABuffer),n.vertexAttribPointer(a.skinVertexA,4, n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),n.vertexAttribPointer(a.skinVertexB,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),n.vertexAttribPointer(a.skinIndex,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),n.vertexAttribPointer(a.skinWeight,4,n.FLOAT,!1,0,0))}h instanceof THREE.Mesh?(k.wireframe?(n.lineWidth(k.wireframeLinewidth),c&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),n.drawElements(n.LINES,f.__webglLineCount, n.UNSIGNED_SHORT,0)):(c&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),n.drawElements(n.TRIANGLES,f.__webglFaceCount,n.UNSIGNED_SHORT,0)),O.info.render.calls++,O.info.render.vertices+=f.__webglFaceCount,O.info.render.faces+=f.__webglFaceCount/3):h instanceof THREE.Line?(h=h.type==THREE.LineStrip?n.LINE_STRIP:n.LINES,n.lineWidth(k.linewidth),n.drawArrays(h,0,f.__webglLineCount),O.info.render.calls++):h instanceof THREE.ParticleSystem?(n.drawArrays(n.POINTS,0,f.__webglParticleCount),O.info.render.calls++): h instanceof THREE.Ribbon&&(n.drawArrays(n.TRIANGLE_STRIP,0,f.__webglVertexCount),O.info.render.calls++)}}function h(a,c,b){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=n.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=n.createBuffer();a.hasPos&&(n.bindBuffer(n.ARRAY_BUFFER,a.__webglVertexBuffer),n.bufferData(n.ARRAY_BUFFER,a.positionArray,n.DYNAMIC_DRAW),n.enableVertexAttribArray(c.attributes.position),n.vertexAttribPointer(c.attributes.position,3,n.FLOAT,!1,0,0));if(a.hasNormal){n.bindBuffer(n.ARRAY_BUFFER, a.__webglNormalBuffer);if(b==THREE.FlatShading){var e,f,k,h,l,m,p,t,o,u,v=a.count*3;for(u=0;u=0&&(c=c.geometry.materials[materialIndex], c.transparent?v(a,c):v(f,c))):(c=b)&&(c.transparent?v(a,c):v(f,c))}function x(a,c){return c.z-a.z}function w(a){var c,b,m,t=0,o,v,x,w,M=a.lights;ha||(ha=new THREE.PerspectiveCamera(O.shadowCameraFov,O.shadowMapWidth/O.shadowMapHeight,O.shadowCameraNear,O.shadowCameraFar));c=0;for(b=M.length;c=0;b--)a[b].object==c&&a.splice(b,1)}function L(a,c,b){a.push({buffer:c,object:b,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function F(a){if(a!=Q){switch(a){case THREE.AdditiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE);break;case THREE.SubtractiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,n.ONE_MINUS_SRC_COLOR); break;case THREE.MultiplyBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}Q=a}}function G(a,c,b){(b.width&b.width-1)==0&&(b.height&b.height-1)==0?(n.texParameteri(a,n.TEXTURE_WRAP_S,X(c.wrapS)),n.texParameteri(a,n.TEXTURE_WRAP_T,X(c.wrapT)),n.texParameteri(a,n.TEXTURE_MAG_FILTER,X(c.magFilter)),n.texParameteri(a,n.TEXTURE_MIN_FILTER,X(c.minFilter)), n.generateMipmap(a)):(n.texParameteri(a,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(a,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(a,n.TEXTURE_MAG_FILTER,V(c.magFilter)),n.texParameteri(a,n.TEXTURE_MIN_FILTER,V(c.minFilter)))}function N(a,c){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=n.createTexture(),O.info.memory.textures++;n.activeTexture(n.TEXTURE0+c);n.bindTexture(n.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?n.texImage2D(n.TEXTURE_2D,0,X(a.format), a.image.width,a.image.height,0,X(a.format),n.UNSIGNED_BYTE,a.image.data):n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,a.image);G(n.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else n.activeTexture(n.TEXTURE0+c),n.bindTexture(n.TEXTURE_2D,a.__webglTexture)}function R(a,c){n.bindRenderbuffer(n.RENDERBUFFER,a);c.depthBuffer&&!c.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,c.width,c.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,a)): c.depthBuffer&&c.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,c.width,c.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,a)):n.renderbufferStorage(n.RENDERBUFFER,n.RGBA4,c.width,c.height)}function H(a){var c=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=n.createTexture();if(c){a.__webglFramebuffer=[];a.__webglRenderbuffer= [];n.bindTexture(n.TEXTURE_CUBE_MAP,a.__webglTexture);G(n.TEXTURE_CUBE_MAP,a,a);for(var b=0;b<6;b++){a.__webglFramebuffer[b]=n.createFramebuffer();a.__webglRenderbuffer[b]=n.createRenderbuffer();n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+b,0,X(a.format),a.width,a.height,0,X(a.format),X(a.type),null);var e=a,f=n.TEXTURE_CUBE_MAP_POSITIVE_X+b;n.bindFramebuffer(n.FRAMEBUFFER,a.__webglFramebuffer[b]);n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,f,e.__webglTexture,0);R(a.__webglRenderbuffer[b], a)}}else a.__webglFramebuffer=n.createFramebuffer(),a.__webglRenderbuffer=n.createRenderbuffer(),n.bindTexture(n.TEXTURE_2D,a.__webglTexture),G(n.TEXTURE_2D,a,a),n.texImage2D(n.TEXTURE_2D,0,X(a.format),a.width,a.height,0,X(a.format),X(a.type),null),b=n.TEXTURE_2D,n.bindFramebuffer(n.FRAMEBUFFER,a.__webglFramebuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,b,a.__webglTexture,0),n.bindRenderbuffer(n.RENDERBUFFER,a.__webglRenderbuffer),R(a.__webglRenderbuffer,a);c?n.bindTexture(n.TEXTURE_CUBE_MAP, null):n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null)}a?(c=c?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,b=a.width,a=a.height,f=e=0):(c=null,b=ma,a=na,e=da,f=sa);c!=aa&&(n.bindFramebuffer(n.FRAMEBUFFER,c),n.viewport(e,f,b,a),aa=c)}function S(a){a instanceof THREE.WebGLRenderTargetCube?(n.bindTexture(n.TEXTURE_CUBE_MAP,a.__webglTexture),n.generateMipmap(n.TEXTURE_CUBE_MAP),n.bindTexture(n.TEXTURE_CUBE_MAP,null)):(n.bindTexture(n.TEXTURE_2D, a.__webglTexture),n.generateMipmap(n.TEXTURE_2D),n.bindTexture(n.TEXTURE_2D,null))}function J(a,c){var b;a=="fragment"?b=n.createShader(n.FRAGMENT_SHADER):a=="vertex"&&(b=n.createShader(n.VERTEX_SHADER));n.shaderSource(b,c);n.compileShader(b);if(!n.getShaderParameter(b,n.COMPILE_STATUS))return console.error(n.getShaderInfoLog(b)),console.error(c),null;return b}function V(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return n.NEAREST; default:return n.LINEAR}}function X(a){switch(a){case THREE.RepeatWrapping:return n.REPEAT;case THREE.ClampToEdgeWrapping:return n.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return n.MIRRORED_REPEAT;case THREE.NearestFilter:return n.NEAREST;case THREE.NearestMipMapNearestFilter:return n.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return n.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return n.LINEAR;case THREE.LinearMipMapNearestFilter:return n.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return n.LINEAR_MIPMAP_LINEAR; case THREE.ByteType:return n.BYTE;case THREE.UnsignedByteType:return n.UNSIGNED_BYTE;case THREE.ShortType:return n.SHORT;case THREE.UnsignedShortType:return n.UNSIGNED_SHORT;case THREE.IntType:return n.INT;case THREE.UnsignedShortType:return n.UNSIGNED_INT;case THREE.FloatType:return n.FLOAT;case THREE.AlphaFormat:return n.ALPHA;case THREE.RGBFormat:return n.RGB;case THREE.RGBAFormat:return n.RGBA;case THREE.LuminanceFormat:return n.LUMINANCE;case THREE.LuminanceAlphaFormat:return n.LUMINANCE_ALPHA}return 0} var O=this,n,U=[],$=null,aa=null,ca=-1,ea=null,la=0,ka=null,Z=null,Q=null,T=null,fa=null,ga=null,qa=null,oa=null,da=0,sa=0,ma=0,na=0,pa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ca=new THREE.Matrix4,Fa=new Float32Array(16),Ea=new Float32Array(16),za=new THREE.Vector4,Da={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},M=a.canvas!==void 0?a.canvas:document.createElement("canvas"), Y=a.stencil!==void 0?a.stencil:!0,ia=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,ja=a.antialias!==void 0?a.antialias:!1,K=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),ra=a.clearAlpha!==void 0?a.clearAlpha:0,wa=a.maxLights!==void 0?a.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=M;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear= !0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;var ha,xa=[],a=THREE.ShaderLib.depthRGBA,ua=THREE.UniformsUtils.clone(a.uniforms),ya=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:ua}), Ba=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:ua,morphTargets:!0});ya._shadowPass=!0;Ba._shadowPass=!0;try{if(!(n=M.getContext("experimental-webgl",{antialias:ja,stencil:Y,preserveDrawingBuffer:ia})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+n.getParameter(n.VERSION)+" | "+n.getParameter(n.VENDOR)+" | "+n.getParameter(n.RENDERER)+" | "+n.getParameter(n.SHADING_LANGUAGE_VERSION))}catch(Ha){console.error(Ha)}n.clearColor(0, 0,0,1);n.clearDepth(1);n.clearStencil(0);n.enable(n.DEPTH_TEST);n.depthFunc(n.LEQUAL);n.frontFace(n.CCW);n.cullFace(n.BACK);n.enable(n.CULL_FACE);n.enable(n.BLEND);n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA);n.clearColor(K.r,K.g,K.b,ra);this.context=n;var Ia=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,W={};W.vertices=new Float32Array(16);W.faces=new Uint16Array(6);Y=0;W.vertices[Y++]=-1;W.vertices[Y++]=-1;W.vertices[Y++]=0;W.vertices[Y++]=1;W.vertices[Y++]=1; W.vertices[Y++]=-1;W.vertices[Y++]=1;W.vertices[Y++]=1;W.vertices[Y++]=1;W.vertices[Y++]=1;W.vertices[Y++]=1;W.vertices[Y++]=0;W.vertices[Y++]=-1;W.vertices[Y++]=1;W.vertices[Y++]=0;Y=W.vertices[Y++]=0;W.faces[Y++]=0;W.faces[Y++]=1;W.faces[Y++]=2;W.faces[Y++]=0;W.faces[Y++]=2;W.faces[Y++]=3;W.vertexBuffer=n.createBuffer();W.elementBuffer=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,W.vertexBuffer);n.bufferData(n.ARRAY_BUFFER,W.vertices,n.STATIC_DRAW);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,W.elementBuffer); n.bufferData(n.ELEMENT_ARRAY_BUFFER,W.faces,n.STATIC_DRAW);W.program=n.createProgram();n.attachShader(W.program,J("fragment",THREE.ShaderLib.sprite.fragmentShader));n.attachShader(W.program,J("vertex",THREE.ShaderLib.sprite.vertexShader));n.linkProgram(W.program);W.attributes={};W.uniforms={};W.attributes.position=n.getAttribLocation(W.program,"position");W.attributes.uv=n.getAttribLocation(W.program,"uv");W.uniforms.uvOffset=n.getUniformLocation(W.program,"uvOffset");W.uniforms.uvScale=n.getUniformLocation(W.program, "uvScale");W.uniforms.rotation=n.getUniformLocation(W.program,"rotation");W.uniforms.scale=n.getUniformLocation(W.program,"scale");W.uniforms.alignment=n.getUniformLocation(W.program,"alignment");W.uniforms.color=n.getUniformLocation(W.program,"color");W.uniforms.map=n.getUniformLocation(W.program,"map");W.uniforms.opacity=n.getUniformLocation(W.program,"opacity");W.uniforms.useScreenCoordinates=n.getUniformLocation(W.program,"useScreenCoordinates");W.uniforms.affectedByDistance=n.getUniformLocation(W.program, "affectedByDistance");W.uniforms.screenPosition=n.getUniformLocation(W.program,"screenPosition");W.uniforms.modelViewMatrix=n.getUniformLocation(W.program,"modelViewMatrix");W.uniforms.projectionMatrix=n.getUniformLocation(W.program,"projectionMatrix");var Ja=!1;this.setSize=function(a,c){M.width=a;M.height=c;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(a,c,b,e){da=a;sa=c;ma=b;na=e;n.viewport(da,sa,ma,na)};this.setScissor=function(a,c,b,e){n.scissor(a,c,b,e)};this.enableScissorTest= function(a){a?n.enable(n.SCISSOR_TEST):n.disable(n.SCISSOR_TEST)};this.setClearColorHex=function(a,c){K.setHex(a);ra=c;n.clearColor(K.r,K.g,K.b,ra)};this.setClearColor=function(a,c){K.copy(a);ra=c;n.clearColor(K.r,K.g,K.b,ra)};this.getClearColor=function(){return K};this.getClearAlpha=function(){return ra};this.clear=function(a,c,b){var e=0;if(a==void 0||a)e|=n.COLOR_BUFFER_BIT;if(c==void 0||c)e|=n.DEPTH_BUFFER_BIT;if(b==void 0||b)e|=n.STENCIL_BUFFER_BIT;n.clear(e)};this.getContext=function(){return n}; this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(g in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[g];n.deleteBuffer(c.__webglVertexBuffer);n.deleteBuffer(c.__webglNormalBuffer);n.deleteBuffer(c.__webglTangentBuffer);n.deleteBuffer(c.__webglColorBuffer);n.deleteBuffer(c.__webglUVBuffer);n.deleteBuffer(c.__webglUV2Buffer);n.deleteBuffer(c.__webglSkinVertexABuffer); n.deleteBuffer(c.__webglSkinVertexBBuffer);n.deleteBuffer(c.__webglSkinIndicesBuffer);n.deleteBuffer(c.__webglSkinWeightsBuffer);n.deleteBuffer(c.__webglFaceBuffer);n.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var b=0,e=c.numMorphTargets;b=0&&n.enableVertexAttribArray(v.position);v.color>=0&&n.enableVertexAttribArray(v.color);v.normal>=0&&n.enableVertexAttribArray(v.normal); v.tangent>=0&&n.enableVertexAttribArray(v.tangent);a.skinning&&v.skinVertexA>=0&&v.skinVertexB>=0&&v.skinIndex>=0&&v.skinWeight>=0&&(n.enableVertexAttribArray(v.skinVertexA),n.enableVertexAttribArray(v.skinVertexB),n.enableVertexAttribArray(v.skinIndex),n.enableVertexAttribArray(v.skinWeight));if(a.attributes)for(k in a.attributes)v[k]!==void 0&&v[k]>=0&&n.enableVertexAttribArray(v[k]);if(a.morphTargets)for(k=a.numSupportedMorphTargets=0;k=0&&(n.enableVertexAttribArray(v[x]), a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,c,b,e){H(a);this.clear(c,b,e)};this.updateShadowMap=function(a,c){w(a,c)};this.render=function(a,c,b,v){var M,Y,ia,A,E,ja,C,G,oa=a.lights,N=a.fog;ca=-1;this.shadowMapEnabled&&this.shadowMapAutoUpdate&&w(a,c);O.info.render.calls=0;O.info.render.vertices=0;O.info.render.faces=0;if(c.matrixAutoUpdate){for(E=c;E.parent;)E=E.parent;E.update(void 0,!0)}a.update(void 0, !1,c);c.matrixWorldInverse.flattenToArray(Ea);c.projectionMatrix.flattenToArray(Fa);Ca.multiply(c.projectionMatrix,c.matrixWorldInverse);u(Ca);this.initWebGLObjects(a);H(b);(this.autoClear||v)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);E=a.__webglObjects.length;for(v=0;v=0;v--)if(M=a.__webglObjects[v],M.render){C=M.object;G=M.buffer;ia=M.opaque;k(C);for(M=0;M65535&&(w[v].counter+=1,u=w[v].hash+"_"+w[v].counter,l.geometryGroups[u]==void 0&&(l.geometryGroups[u]={faces:[],materialIndex:o,vertices:0,numMorphTargets:M})),l.geometryGroups[u].faces.push(m),l.geometryGroups[u].vertices+=t;l.geometryGroupsList=[];m=void 0;for(m in l.geometryGroups)l.geometryGroups[m].id=la++,l.geometryGroupsList.push(l.geometryGroups[m])}for(k in h.geometryGroups)if(l=h.geometryGroups[k],!l.__webglVertexBuffer){m=l;m.__webglVertexBuffer=n.createBuffer();m.__webglNormalBuffer= n.createBuffer();m.__webglTangentBuffer=n.createBuffer();m.__webglColorBuffer=n.createBuffer();m.__webglUVBuffer=n.createBuffer();m.__webglUV2Buffer=n.createBuffer();m.__webglSkinVertexABuffer=n.createBuffer();m.__webglSkinVertexBBuffer=n.createBuffer();m.__webglSkinIndicesBuffer=n.createBuffer();m.__webglSkinWeightsBuffer=n.createBuffer();m.__webglFaceBuffer=n.createBuffer();m.__webglLineBuffer=n.createBuffer();if(m.numMorphTargets){o=p=void 0;m.__webglMorphTargetsBuffers=[];p=0;for(o=m.numMorphTargets;p< o;p++)m.__webglMorphTargetsBuffers.push(n.createBuffer())}O.info.memory.geometries++;for(var o=e,x=t=w=void 0,v=x=M=x=void 0,u=v=m=0,z=t=void 0,Y=void 0,t=p=M=w=void 0,M=o.geometry,z=M.faces,Y=l.faces,w=0,t=Y.length;w0||M.faceVertexUvs.length>0)l.__uvArray=new Float32Array(m*2);if(M.faceUvs.length>1||M.faceVertexUvs.length>1)l.__uv2Array=new Float32Array(m*2)}if(o.geometry.skinWeights.length&&o.geometry.skinIndices.length)l.__skinVertexAArray= new Float32Array(m*4),l.__skinVertexBArray=new Float32Array(m*4),l.__skinIndexArray=new Float32Array(m*4),l.__skinWeightArray=new Float32Array(m*4);l.__faceArray=new Uint16Array(v*3+(o.geometry.edgeFaces?o.geometry.edgeFaces.length*6:0));l.__lineArray=new Uint16Array(u*2);if(l.numMorphTargets){l.__morphTargetsArrays=[];M=0;for(x=l.numMorphTargets;M=0;h--)f[h]==k&&f.splice(h,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&C(f.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(f=a.__webglObjects.length;e0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglColorBuffer), n.bufferData(n.ARRAY_BUFFER,aa,v));Ia&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglNormalBuffer),n.bufferData(n.ARRAY_BUFFER,xa,v));Ea&&ua.hasTangents&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglTangentBuffer),n.bufferData(n.ARRAY_BUFFER,ca,v));za&&sa>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglUVBuffer),n.bufferData(n.ARRAY_BUFFER,fa,v));za&&S>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglUV2Buffer),n.bufferData(n.ARRAY_BUFFER,ea,v));Fa&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,o.__webglFaceBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER, qa,v),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,o.__webglLineBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,pa,v));P>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinVertexABuffer),n.bufferData(n.ARRAY_BUFFER,ga,v),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinVertexBBuffer),n.bufferData(n.ARRAY_BUFFER,$,v),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinIndicesBuffer),n.bufferData(n.ARRAY_BUFFER,na,v),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinWeightsBuffer),n.bufferData(n.ARRAY_BUFFER,Z,v));u&&(delete o.__inittedArrays,delete o.__colorArray, delete o.__normalArray,delete o.__tangentArray,delete o.__uvArray,delete o.__uv2Array,delete o.__faceArray,delete o.__vertexArray,delete o.__lineArray,delete o.__skinVertexAArray,delete o.__skinVertexBArray,delete o.__skinIndexArray,delete o.__skinWeightArray)}k.__dirtyVertices=!1;k.__dirtyMorphTargets=!1;k.__dirtyElements=!1;k.__dirtyUvs=!1;k.__dirtyNormals=!1;k.__dirtyTangents=!1;k.__dirtyColors=!1;E(l,h)}else if(h instanceof THREE.Ribbon){k=h.geometry;if(k.__dirtyVertices||k.__dirtyColors){h=k; l=n.DYNAMIC_DRAW;m=w=u=u=void 0;M=h.vertices;p=h.colors;t=M.length;o=p.length;z=h.__vertexArray;v=h.__colorArray;Y=h.__dirtyColors;if(h.__dirtyVertices){for(u=0;u1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=k;b.v=h;return b}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; THREE.GeometryUtils={merge:function(a,b){for(var c,e,f=a.vertices.length,h=b instanceof THREE.Mesh?b.geometry:b,k=a.vertices,l=h.vertices,m=a.faces,t=h.faces,u=a.faceVertexUvs[0],p=h.faceVertexUvs[0],v={},o=0;o1&&(e=1-e,f=1-f);h=1-e-f;k.copy(a);k.multiplyScalar(e);l.copy(b);l.multiplyScalar(f);k.addSelf(l);l.copy(c);l.multiplyScalar(h);k.addSelf(l);return k},randomPointInFace:function(a,b,c){var e,f,h;if(a instanceof THREE.Face3)return e=b.vertices[a.a].position,f=b.vertices[a.b].position, h=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(e,f,h);else if(a instanceof THREE.Face4){e=b.vertices[a.a].position;f=b.vertices[a.b].position;h=b.vertices[a.c].position;var b=b.vertices[a.d].position,k;c?a._area1&&a._area2?(c=a._area1,k=a._area2):(c=THREE.GeometryUtils.triangleArea(e,f,b),k=THREE.GeometryUtils.triangleArea(f,h,b),a._area1=c,a._area2=k):(c=THREE.GeometryUtils.triangleArea(e,f,b),k=THREE.GeometryUtils.triangleArea(f,h,b));return THREE.GeometryUtils.random()*(c+ k)a?c(b,f-1):t[f] 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\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 )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, 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 );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;\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 );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;\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 ) );\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, uReflectivity );\n}", THREE.ShaderChunk.shadowmap_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 = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\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( 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.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,e=this.getPoint(0),f,h=0;b.push(0);for(f=1;f<=a;f++)c=this.getPoint(f/a),h+=c.distanceTo(e),b.push(h),e=c;return this.cacheArcLengths=b}; THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),e=0,f=c.length,h;h=b?b:a*c[f-1];time=Date.now();for(var k=0,l=f-1,m;k<=l;)if(e=Math.floor(k+(l-k)/2),m=c[e]-h,m<0)k=e+1;else if(m>0)l=e-1;else{l=e;break}e=l;if(c[e]==h)return e/(f-1);k=c[e];return c=(e+(h-k)/(c[e+1]-k))/(f-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)}; THREE.Curve.prototype.getTangent=function(a){var b=a-1.0E-4;a+=1.0E-4;b<0&&(b=0);a>1&&(a=1);var b=this.getPoint(b),a=this.getPoint(a),c=new THREE.Vector2;c.sub(a,b);return c.unit()};THREE.LineCurve=function(a,b){a instanceof THREE.Vector2?(this.v1=a,this.v2=b):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(a,b,c,e){this.constructor(new THREE.Vector2(a,b),new THREE.Vector2(c,e))};THREE.LineCurve.prototype=new THREE.Curve; THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2;b.sub(this.v2,this.v1);b.multiplyScalar(a).addSelf(this.v1);return b};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){var a=new THREE.Vector2;a.sub(this.v2,this.v1);a.normalize();return a}; THREE.QuadraticBezierCurve=function(a,b,c){if(!(b instanceof THREE.Vector2))var e=Array.prototype.slice.call(arguments),a=new THREE.Vector2(e[0],e[1]),b=new THREE.Vector2(e[2],e[3]),c=new THREE.Vector2(e[4],e[5]);this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(b,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);b=new THREE.Vector2(b,a);b.normalize();return b}; THREE.CubicBezierCurve=function(a,b,c,e){if(!(b instanceof THREE.Vector2))var f=Array.prototype.slice.call(arguments),a=new THREE.Vector2(f[0],f[1]),b=new THREE.Vector2(f[2],f[3]),c=new THREE.Vector2(f[4],f[5]),e=new THREE.Vector2(f[6],f[7]);this.v0=a;this.v1=b;this.v2=c;this.v3=e};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; THREE.CubicBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(b,a)};THREE.CubicBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=new THREE.Vector2(b,a);b.normalize();return b}; THREE.SplineCurve=function(a){this.points=a};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve; THREE.SplineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2,c=[],e=this.points,f;f=(e.length-1)*a;a=Math.floor(f);f-=a;c[0]=a==0?a:a-1;c[1]=a;c[2]=a>e.length-2?a:a+1;c[3]=a>e.length-3?a:a+2;b.x=THREE.Curve.Utils.interpolate(e[c[0]].x,e[c[1]].x,e[c[2]].x,e[c[3]].x,f);b.y=THREE.Curve.Utils.interpolate(e[c[0]].y,e[c[1]].y,e[c[2]].y,e[c[3]].y,f);return b};THREE.ArcCurve=function(a,b,c,e,f,h){this.aX=a;this.aY=b;this.aRadius=c;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=h}; 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);a=this.aStartAngle+a*b;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(a),this.aY+this.aRadius*Math.sin(a))}; THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,e){return 2*(1-a)*(c-b)+2*a*(e-c)},tangentCubicBezier:function(a,b,c,e,f){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*e*(1-a)-3*a*a*e+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,e,f){var a=(c-a)*0.5,e=(e-b)*0.5,h=f*f;return(2*b-2*c+a+e)*f*h+(-3*b+3*c-2*a-e)*h+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(v2,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,e){this.v0=a;this.v1=b;this.v2=c;this.v3=e},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=a},function(a){var b=new THREE.Vector3,c=[],e=this.points,f;f=(e.length-1)*a;a=Math.floor(f);f-=a;c[0]=a==0?a:a-1;c[1]=a;c[2]=a>e.length-2?a:a+1;c[3]=a>e.length-3?a:a+2;b.x=THREE.Curve.Utils.interpolate(e[c[0]].x,e[c[1]].x,e[c[2]].x,e[c[3]].x,f);b.y=THREE.Curve.Utils.interpolate(e[c[0]].y,e[c[1]].y,e[c[2]].y,e[c[3]].y,f);b.z=THREE.Curve.Utils.interpolate(e[c[0]].z,e[c[1]].z,e[c[2]].z,e[c[3]].z,f);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,e=this.curves.length;for(c=0;cb)b=h.x;else if(h.xc)c=h.y;else if(h.y0?(k=c[c.length-1],o=k.x,z=k.y):(k=this.actions[e-1].args,o=k[k.length-2],z=k[k.length-1]);for(k=1;k<=a;k++)x=k/a,h=THREE.Shape.Utils.b2(x,o,p,l),x=THREE.Shape.Utils.b2(x,z,v, m),c.push(new THREE.Vector2(h,x));break;case THREE.PathActions.BEZIER_CURVE_TO:l=h[4];m=h[5];p=h[0];v=h[1];t=h[2];u=h[3];c.length>0?(k=c[c.length-1],o=k.x,z=k.y):(k=this.actions[e-1].args,o=k[k.length-2],z=k[k.length-1]);for(k=1;k<=a;k++)x=k/a,h=THREE.Shape.Utils.b3(x,o,p,t,l),x=THREE.Shape.Utils.b3(x,z,v,u,m),c.push(new THREE.Vector2(h,x));break;case THREE.PathActions.CSPLINE_THRU:k=this.actions[e-1].args;k=[new THREE.Vector2(k[k.length-2],k[k.length-1])];x=a*h[0].length;k=k.concat(h[0]);h=new THREE.SplineCurve(k); for(k=1;k<=x;k++)c.push(h.getPointAt(k/x));break;case THREE.PathActions.ARC:k=this.actions[e-1].args;l=h[0];m=h[1];t=h[2];p=h[3];x=h[4];v=!!h[5];u=k[k.length-2];o=k[k.length-1];k.length==0&&(u=o=0);z=x-p;var w=a*2;for(k=1;k<=w;k++)x=k/w,v||(x=1-x),x=p+x*z,h=u+l+t*Math.cos(x),x=o+m+t*Math.sin(x),c.push(new THREE.Vector2(h,x))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; THREE.Path.prototype.nltransform=function(a,b,c,e,f,h){var k=this.getPoints(),l,m,t,u,p;l=0;for(m=k.length;l=0?l-1:c.length-1;h=k-1>=0?k-1:t.length-1;var x=[t[k],c[l],c[f]];p=THREE.FontUtils.Triangulate.area(x);var w=[t[k],t[h],c[l]];v=THREE.FontUtils.Triangulate.area(w);o=l;u=k;l+=1;k+=-1;l< 0&&(l+=c.length);l%=c.length;k<0&&(k+=t.length);k%=t.length;f=l-1>=0?l-1:c.length-1;h=k-1>=0?k-1:t.length-1;x=[t[k],c[l],c[f]];x=THREE.FontUtils.Triangulate.area(x);w=[t[k],t[h],c[l]];w=THREE.FontUtils.Triangulate.area(w);p+v>x+w&&(l=o,k=u,l<0&&(l+=c.length),l%=c.length,k<0&&(k+=t.length),k%=t.length,f=l-1>=0?l-1:c.length-1,h=k-1>=0?k-1:t.length-1);p=c.slice(0,l);v=c.slice(l);o=t.slice(k);u=t.slice(0,k);h=[t[k],t[h],c[l]];z.push([t[k],c[l],c[f]]);z.push(h);c=p.concat(o).concat(u).concat(v)}return{shape:c, isolatedPts:z,allpoints:e}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),e=c.allpoints,f=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),h,k,l,m,t={};h=0;for(k=e.length;h1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o),e=e<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=f[0]+(h[0]-f[0])*e,c.y=f[1]+(h[1]-f[1])*e,c.z=f[2]+(h[2]-f[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",o,k.index-1).pos,this.points[1]=f,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",o,l.index+1).pos,e=e*0.33+0.33,f=this.interpolateCatmullRom(this.points,e),c.x=f[0],c.y=f[1],c.z=f[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(c=== "rot")THREE.Quaternion.slerp(f,h,a.quaternion,e);else if(c==="scl")c=a.scale,c.x=f[0]+(h[0]-f[0])*e,c.y=f[1]+(h[1]-f[1])*e,c.z=f[2]+(h[2]-f[2])*e}}if(this.JITCompile&&u[0][t]===void 0){this.hierarchy[0].update(void 0,!0);for(o=0;oa.length-2?h:h+1;c[3]=h>a.length-3?h:h+2;h=a[c[0]];l=a[c[1]];m=a[c[2]];t=a[c[3]];c=f*f;k=f*c;e[0]=this.interpolate(h[0],l[0],m[0],t[0],f,c,k);e[1]=this.interpolate(h[1],l[1],m[1],t[1],f,c,k);e[2]=this.interpolate(h[2],l[2],m[2],t[2],f,c,k);return e}; THREE.Animation.prototype.interpolate=function(a,b,c,e,f,h,k){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*k+(-3*(b-c)-2*a-e)*h+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==void 0)return e[c];return this.data.hierarchy[b].keys[e.length-1]}; THREE.CubeCamera=function(a,b,c,e){this.heightOffset=c;this.position=new THREE.Vector3(0,c,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position= this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ= new THREE.Vector3(0,0,0);this.renderTarget=new THREE.WebGLRenderTargetCube(e,e,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(a){this.position.copy(a);this.position.y+=this.heightOffset;this.targetPX.copy(this.position);this.targetNX.copy(this.position);this.targetPY.copy(this.position);this.targetNY.copy(this.position);this.targetPZ.copy(this.position);this.targetNZ.copy(this.position);this.targetPX.x+=1;this.targetNX.x-=1;this.targetPY.y+= 1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,c){var b=this.renderTarget;b.activeCubeFace=0;a.render(c,this.cameraPX,b);b.activeCubeFace=1;a.render(c,this.cameraNX,b);b.activeCubeFace=2;a.render(c,this.cameraPY,b);b.activeCubeFace=3;a.render(c, this.cameraNY,b);b.activeCubeFace=4;a.render(c,this.cameraPZ,b);b.activeCubeFace=5;a.render(c,this.cameraNZ,b)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")}; THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,b,c,e,f,h,k){THREE.Camera.call(this);this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,h,k);this.cameraP=new THREE.PerspectiveCamera(c,a/b,e,f);this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera; THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.projectionMatrix=this.cameraP.projectionMatrix};THREE.CombinedCamera.prototype.toOrthographic=function(){this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix};THREE.CombinedCamera.prototype.setFov=function(a){this.cameraP.fov=a;this.cameraP.updateProjectionMatrix();this.toPerspective()}; THREE.CombinedCamera.prototype.setLens=function(a,b){b||(b=43.25);var c=2*Math.atan(b/(a*2));c*=180/Math.PI;this.setFov(c);return c}; THREE.FirstPersonControls=function(a,b){function c(a,c){return function(){c.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=b!==void 0?b:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor= 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward= !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown= function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp= !1;break;case 70:this.moveDown=!1}};this.update=function(a){if(!this.freeze){if(this.heightSpeed){var c=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=a*c*this.heightCoef}else this.autoSpeedFactor=0;c=a*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(c);this.moveLeft&&this.object.translateX(-c);this.moveRight&&this.object.translateX(c); this.moveUp&&this.object.translateY(c);this.moveDown&&this.object.translateY(-c);c=a*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target,b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a=1;this.constrainVertical&& (a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta); this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)}; THREE.PathControls=function(a,b){function c(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function e(a,c){return function(){c.apply(a,arguments)}}function f(a,c,b,e){var k={name:b,fps:0.6,length:e,hierarchy:[]},h,f=c.getControlPointsArray(),l=c.getLength(),w=f.length,B=0;h=w-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[h]={time:e,pos:f[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h=0?a:a+k;b=this.verticalAngleMap.srcRange; a=this.verticalAngleMap.dstRange;b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var e=a[1]-a[0];this.phi=c((b-a[0])/e)*e+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);e=a[1]-a[0];this.theta=c((b-a[0])/e)*e+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove= function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),c=new THREE.MeshLambertMaterial({color:65280}), b=new THREE.CubeGeometry(10,10,20),k=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(b,a);a=new THREE.Mesh(k,c);a.position.set(0,10,0);this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=f(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a= this.debugPath,c=this.spline,b=h(c,10),k=h(c,10),l=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(b,l);particleObj=new THREE.ParticleSystem(k,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.add(lineObj);particleObj.scale.set(1,1,1);a.add(particleObj);k=new THREE.SphereGeometry(1,16,8);l=new THREE.MeshBasicMaterial({color:65280});for(i=0;i0){var c=this.getContainerDimensions(),b=c.size[0]/2,k=c.size[1]/2;this.moveState.yawLeft=-(a.pageX-c.offset[0]-b)/b;this.moveState.pitchDown=(a.pageY-c.offset[1]-k)/k;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward= !1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(a){var c=a*this.movementSpeed;a*=this.rollSpeed;this.object.translateX(this.moveVector.x*c);this.object.translateY(this.moveVector.y*c);this.object.translateZ(this.moveVector.z*c);this.tmpQuaternion.set(this.rotationVector.x*a,this.rotationVector.y*a,this.rotationVector.z*a,1).normalize();this.object.quaternion.multiplySelf(this.tmpQuaternion);this.object.matrix.setPosition(this.object.position);this.object.matrix.setRotationFromQuaternion(this.object.quaternion); this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z= -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this, this.mouseup),!1);this.domElement.addEventListener("keydown",c(this,this.keydown),!1);this.domElement.addEventListener("keyup",c(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()}; THREE.RollControls=function(a,b){this.object=a;this.domElement=b!==void 0?b:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Matrix4,k=!1,l=1,m=0,t=0,u=0,p=0,v=0,o=window.innerWidth/2,z=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var b=a*this.lookSpeed; this.rotateHorizontally(b*p);this.rotateVertically(b*v)}b=a*this.movementSpeed;this.object.translateZ(-b*(m>0||this.autoForward&&!(m<0)?1:m));this.object.translateX(b*t);this.object.translateY(b*u);k&&(this.roll+=this.rollSpeed*a*l);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y1?b.normalize():b.z=Math.sqrt(1-e*e);h.copy(this.object.position).subSelf(this.target);e=this.object.up.clone().setLength(b.y);e.addSelf(this.object.up.clone().crossSelf(h).setLength(b.x));e.addSelf(h.setLength(b.z));return e};this.rotateCamera=function(){var a=Math.acos(k.dot(l)/k.length()/l.length());if(a){var c=(new THREE.Vector3).cross(k,l).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c, -a);b.multiplyVector3(h);b.multiplyVector3(this.object.up);b.multiplyVector3(l);this.staticMoving?k=l:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(k))}};this.zoomCamera=function(){var a=1+(t.y-m.y)*this.zoomSpeed;a!==1&&a>0&&(h.multiplyScalar(a),this.staticMoving?m=t:m.y+=(t.y-m.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=p.clone().subSelf(u);if(a.lengthSq()){a.multiplyScalar(h.length()*this.panSpeed);var c=h.clone().crossSelf(this.object.up).setLength(a.x); c.addSelf(this.object.up.clone().setLength(a.y));this.object.position.addSelf(c);this.target.addSelf(c);this.staticMoving?u=p:u.addSelf(a.sub(p,u).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.object.position.lengthSq()>this.maxDistance*this.maxDistance&&this.object.position.setLength(this.maxDistance),h.lengthSq()0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,k,0)));for(l=0;l0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-k,0)));for(l=0;la&&(a+=Math.PI*2),anglec=(c+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(f).addSelf(l).subSelf(a).clone()}function f(a){for(H=a.length;--H>=0;){la=H;ka=H-1;ka<0&&(ka=a.length- 1);for(var c=0,b=o+u*2,c=0;c=0;J--){V=J/u;X=m*(1-V);V=t*Math.sin(V*Math.PI/2);H=0;for(S=y.length;H0||(u=this.vertices.push(new THREE.Vertex(new THREE.Vector3(p,l,v)))-1);t.push(u)}b.push(t)}for(var o,z,x,f=b.length,c=0;c0)for(e=0;e1&&(o= this.vertices[k].position.clone(),z=this.vertices[m].position.clone(),x=this.vertices[t].position.clone(),o.normalize(),z.normalize(),x.normalize(),this.faces.push(new THREE.Face3(k,m,t,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([u,p,w]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry; THREE.TextGeometry=function(a,b){var c=(new THREE.TextPath(a,b)).toShapes();b.amount=b.height!==void 0?b.height:50;if(b.bevelThickness===void 0)b.bevelThickness=10;if(b.bevelSize===void 0)b.bevelSize=8;if(b.bevelEnabled===void 0)b.bevelEnabled=!1;if(b.bend){var e=c[c.length-1].getBoundingBox().maxX;b.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(e/2,120),new THREE.Vector2(e,0))}THREE.ExtrudeGeometry.call(this,c,b)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(a,b){return(new TextPath(a,b)).toShapes()},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b= this.getFace(),c=this.size/b.resolution,e=0,f=String(a).split(""),h=f.length,k=[],a=0;a0)for(t=0;t2;){if(p--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return l;return h}m=t;f<=m&&(m=0);t=m+1;f<=t&&(t=0);u=t+1;f<=u&&(u=0);var v;a:{v=a;var o=m,z=t,x=u,w=f,B=k,y=void 0,A=void 0,E=void 0, C=void 0,L=void 0,F=void 0,G=void 0,N=void 0,R=void 0,A=v[B[o]].x,E=v[B[o]].y,C=v[B[z]].x,L=v[B[z]].y,F=v[B[x]].x,G=v[B[x]].y;if(1.0E-10>(C-A)*(G-E)-(L-E)*(F-A))v=!1;else{for(y=0;y=0&&J>=0&&X>=0){v=!1;break a}}v= !0}}if(v){h.push([a[k[m]],a[k[t]],a[k[u]]]);l.push([k[m],k[t],k[u]]);m=t;for(u=t+1;u0;)this.smooth(a)}; THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,c,b,e,l,m){var o=new THREE.Face4(a,c,b,e,null,l.color,l.material);if(k.useOldVertexColors){o.vertexColors=[];for(var t,n,u,v=0;v<4;v++){u=m[v];t=new THREE.Color;t.setRGB(0,0,0);for(var w=0;w>7)-127;e|=(h&127)<<16|f<<8;if(e==0&&l==-127)return 0;return(1-2*(k>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,l)}function f(a,c){var b=u(a,c),e=u(a,c+1),h=u(a,c+2);return(u(a,c+3)<<24)+(h<<16)+(e<<8)+b}function m(a,c){var b=u(a,c);return(u(a,c+1)<<8)+b}function t(a,c){var b=u(a,c);return b>127?b-256:b}function u(a,c){return a.charCodeAt(c)&255}function p(c){var b, e,h;b=f(a,c);e=f(a,c+L);h=f(a,c+F);c=m(a,c+G);B.faces.push(new THREE.Face3(b,e,h,null,null,c))}function v(c){var b,e,h,k,n,o,p;b=f(a,c);e=f(a,c+L);h=f(a,c+F);k=m(a,c+G);n=f(a,c+N);o=f(a,c+R);p=f(a,c+H);var c=E[o*3],t=E[o*3+1];o=E[o*3+2];var u=E[p*3],v=E[p*3+1];p=E[p*3+2];B.faces.push(new THREE.Face3(b,e,h,[new THREE.Vector3(E[n*3],E[n*3+1],E[n*3+2]),new THREE.Vector3(c,t,o),new THREE.Vector3(u,v,p)],null,k))}function o(c){var b,e,h,k;b=f(a,c);e=f(a,c+S);h=f(a,c+J);k=f(a,c+V);c=m(a,c+X);B.faces.push(new THREE.Face4(b, e,h,k,null,null,c))}function z(c){var b,e,h,k,o,p,t,u,v;b=f(a,c);e=f(a,c+S);h=f(a,c+J);k=f(a,c+V);o=m(a,c+X);p=f(a,c+O);t=f(a,c+n);u=f(a,c+U);v=f(a,c+$);var c=E[t*3],w=E[t*3+1];t=E[t*3+2];var M=E[u*3],x=E[u*3+1];u=E[u*3+2];var ia=E[v*3],y=E[v*3+1];v=E[v*3+2];B.faces.push(new THREE.Face4(b,e,h,k,[new THREE.Vector3(E[p*3],E[p*3+1],E[p*3+2]),new THREE.Vector3(c,w,t),new THREE.Vector3(M,x,u),new THREE.Vector3(ia,y,v)],null,o))}function x(c){var b,e,h,k;b=f(a,c);e=f(a,c+aa);h=f(a,c+ca);c=C[b*2];k=C[b* 2+1];b=C[e*2];var m=B.faceVertexUvs[0];e=C[e*2+1];var n=C[h*2];h=C[h*2+1];var o=[];o.push(new THREE.UV(c,k));o.push(new THREE.UV(b,e));o.push(new THREE.UV(n,h));m.push(o)}function w(c){var b,e,h,k,m,n;b=f(a,c);e=f(a,c+ea);h=f(a,c+la);k=f(a,c+ka);c=C[b*2];m=C[b*2+1];b=C[e*2];n=C[e*2+1];e=C[h*2];var o=B.faceVertexUvs[0];h=C[h*2+1];var p=C[k*2];k=C[k*2+1];var t=[];t.push(new THREE.UV(c,m));t.push(new THREE.UV(b,n));t.push(new THREE.UV(e,h));t.push(new THREE.UV(p,k));o.push(t)}var B=this,y=0,A,E=[],C= [],L,F,G,N,R,H,S,J,V,X,O,n,U,$,aa,ca,ea,la,ka,Z,Q,T,fa,ga,qa;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(B,e,c);A={signature:a.substr(y,8),header_bytes:u(a,y+8),vertex_coordinate_bytes:u(a,y+9),normal_coordinate_bytes:u(a,y+10),uv_coordinate_bytes:u(a,y+11),vertex_index_bytes:u(a,y+12),normal_index_bytes:u(a,y+13),uv_index_bytes:u(a,y+14),material_index_bytes:u(a,y+15),nvertices:f(a,y+16),nnormals:f(a,y+16+4),nuvs:f(a,y+16+8),ntri_flat:f(a,y+16+12),ntri_smooth:f(a,y+16+16),ntri_flat_uv:f(a, y+16+20),ntri_smooth_uv:f(a,y+16+24),nquad_flat:f(a,y+16+28),nquad_smooth:f(a,y+16+32),nquad_flat_uv:f(a,y+16+36),nquad_smooth_uv:f(a,y+16+40)};y+=A.header_bytes;L=A.vertex_index_bytes;F=A.vertex_index_bytes*2;G=A.vertex_index_bytes*3;N=A.vertex_index_bytes*3+A.material_index_bytes;R=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;H=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;S=A.vertex_index_bytes;J=A.vertex_index_bytes*2;V=A.vertex_index_bytes*3;X=A.vertex_index_bytes* 4;O=A.vertex_index_bytes*4+A.material_index_bytes;n=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;U=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;$=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;aa=A.uv_index_bytes;ca=A.uv_index_bytes*2;ea=A.uv_index_bytes;la=A.uv_index_bytes*2;ka=A.uv_index_bytes*3;c=A.vertex_index_bytes*3+A.material_index_bytes;qa=A.vertex_index_bytes*4+A.material_index_bytes;Z=A.ntri_flat*c;Q=A.ntri_smooth*(c+A.normal_index_bytes* 3);T=A.ntri_flat_uv*(c+A.uv_index_bytes*3);fa=A.ntri_smooth_uv*(c+A.normal_index_bytes*3+A.uv_index_bytes*3);ga=A.nquad_flat*qa;c=A.nquad_smooth*(qa+A.normal_index_bytes*4);qa=A.nquad_flat_uv*(qa+A.uv_index_bytes*4);y+=function(c){for(var e,h,f,l=A.vertex_coordinate_bytes*3,m=c+A.nvertices*l;c=0){w=m.invBindMatrices[t];n.invBindMatrix=w;n.skinningMatrix=new THREE.Matrix4;n.skinningMatrix.multiply(n.world,w);n.weights=[];for(w=0;w1){m=new THREE.MeshFaceMaterial;for(j=0;j1?b[1].substr(0,c):"0";b[1].length=0,k=h.indexOf("(")>=0,l;if(f)e=h.split("."),h=e.shift(),e.shift();else if(k){l=h.split("(");h=l.shift(); for(e=0;ec){t=n.output[m];break}k=t!==void 0?t instanceof THREE.Matrix4?k.multiply(k,t):k.multiply(k,l.matrix):k.multiply(k,l.matrix)}else k=k.multiply(k,l.matrix);c=k;b.push({time:a,pos:[c.n14, c.n24,c.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=b}this.updateMatrix();return this};p.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[b.nodeName]=parseFloat(e[0].textContent))}}this.create();return this};R.prototype.create=function(){var a= {},c=this.transparency!==void 0&&this.transparency<1,b;for(b in this)switch(b){case "ambient":case "emission":case "diffuse":case "specular":var e=this[b];if(e instanceof N)if(e.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(e=oa[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(Fa+e.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else b=="diffuse"?a.color= e.color.getHex():c||(a[b]=e.color.getHex());break;case "shininess":case "reflectivity":a[b]=this[b];break;case "transparency":if(c)a.transparent=!0,a.opacity=this[b],c=!0}a.shading=Da;return this.material=new THREE.MeshLambertMaterial(a)};H.prototype.parse=function(a){for(var c=0;c=0,e=a.indexOf("(")>=0,h,f;if(b)c=a.split("."),a=c.shift(),f=c.shift();else if(e){h=a.split("(");a=h.shift();for(c=0;c1&&(R=new THREE.MeshFaceMaterial);object=new THREE.Mesh(L,R);object.name=o;object.position.set(A[0],A[1],A[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=y.visible;U.scene.add(object);U.objects[o]=object;y.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),U.scene.collisions.colliders.push(a));if(y.castsShadow)a= new THREE.ShadowVolume(L),U.scene.add(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},U.triggers[object.name]=a)}}else A=y.position,r=y.rotation,q=y.quaternion,s=y.scale,q=0,object=new THREE.Object3D,object.name=o,object.position.set(A[0],A[1],A[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible= y.visible!==void 0?y.visible:!1,U.scene.add(object),U.objects[o]=object,U.empties[o]=object,y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},U.triggers[object.name]=a)}function m(a){return function(b){U.geometries[a]=b;l();V-=1;c.onLoadComplete();u()}}function t(a){return function(c){U.geometries[a]=c}}function u(){c.callbackProgress({totalModels:O,totalTextures:n,loadedModels:O-V,loadedTextures:n-X},U);c.onLoadProgress();V==0&&X==0&&b(U)}var p,v,o,z,x,w,B,y,A,E,C,L,F,G,N, R,H,S,J,V,X,O,n,U;S=a.data;N=new THREE.BinaryLoader;J=new THREE.JSONLoader;X=V=0;U={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(o in S.objects)if(y=S.objects[o],y.meshCollider){a=!0;break}if(a)U.scene.collisions=new THREE.CollisionSystem;if(S.transform){a=S.transform.position;E=S.transform.rotation;var $=S.transform.scale;a&&U.scene.position.set(a[0],a[1],a[2]);E&&U.scene.rotation.set(E[0],E[1],E[2]);$&&U.scene.scale.set($[0], $[1],$[2]);(a||E||$)&&U.scene.updateMatrix()}a=function(){X-=1;u();c.onLoadComplete()};for(x in S.cameras)E=S.cameras[x],E.type=="perspective"?F=new THREE.PerspectiveCamera(E.fov,E.aspect,E.near,E.far):E.type=="ortho"&&(F=new THREE.OrthographicCamera(E.left,E.right,E.top,E.bottom,E.near,E.far)),A=E.position,E=E.target,F.position.set(A[0],A[1],A[2]),F.target=new THREE.Vector3(E[0],E[1],E[2]),U.cameras[x]=F;for(z in S.lights)x=S.lights[z],F=x.color!==void 0?x.color:16777215,E=x.intensity!==void 0?x.intensity: 1,x.type=="directional"?(A=x.direction,H=new THREE.DirectionalLight(F,E),H.position.set(A[0],A[1],A[2]),H.position.normalize()):x.type=="point"?(A=x.position,d=x.distance,H=new THREE.PointLight(F,E,d),H.position.set(A[0],A[1],A[2])):x.type=="ambient"&&(H=new THREE.AmbientLight(F)),U.scene.add(H),U.lights[z]=H;for(w in S.fogs)z=S.fogs[w],z.type=="linear"?G=new THREE.Fog(0,z.near,z.far):z.type=="exp2"&&(G=new THREE.FogExp2(0,z.density)),E=z.color,G.color.setRGB(E[0],E[1],E[2]),U.fogs[w]=G;if(U.cameras&& S.defaults.camera)U.currentCamera=U.cameras[S.defaults.camera];if(U.fogs&&S.defaults.fog)U.scene.fog=U.fogs[S.defaults.fog];E=S.defaults.bgcolor;U.bgColor=new THREE.Color;U.bgColor.setRGB(E[0],E[1],E[2]);U.bgColorAlpha=S.defaults.bgalpha;for(p in S.geometries)if(w=S.geometries[p],w.type=="bin_mesh"||w.type=="ascii_mesh")V+=1,c.onLoadStart();O=V;for(p in S.geometries)w=S.geometries[p],w.type=="cube"?(L=new THREE.CubeGeometry(w.width,w.height,w.depth,w.segmentsWidth,w.segmentsHeight,w.segmentsDepth, null,w.flipped,w.sides),U.geometries[p]=L):w.type=="plane"?(L=new THREE.PlaneGeometry(w.width,w.height,w.segmentsWidth,w.segmentsHeight),U.geometries[p]=L):w.type=="sphere"?(L=new THREE.SphereGeometry(w.radius,w.segmentsWidth,w.segmentsHeight),U.geometries[p]=L):w.type=="cylinder"?(L=new THREE.CylinderGeometry(w.topRad,w.botRad,w.height,w.radSegs,w.heightSegs),U.geometries[p]=L):w.type=="torus"?(L=new THREE.TorusGeometry(w.radius,w.tube,w.segmentsR,w.segmentsT),U.geometries[p]=L):w.type=="icosahedron"? (L=new THREE.IcosahedronGeometry(w.subdivisions),U.geometries[p]=L):w.type=="bin_mesh"?N.load(e(w.url,S.urlBaseType),m(p)):w.type=="ascii_mesh"?J.load(e(w.url,S.urlBaseType),m(p)):w.type=="embedded_mesh"&&(w=S.embeds[w.id])&&J.createModel(w,t(p),"");for(B in S.textures)if(p=S.textures[B],p.url instanceof Array){X+=p.url.length;for(N=0;N=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),e=1,f=0;f<8;f++){for(var h=0,k=0;k>1^-(l&1);c[8*k+f]=h}e+=b}b=a.length-e;h=new Uint16Array(b);for(f=k=0;f=this.maxCount-3&&l(this)};this.begin=function(){this.count=0; this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;bthis.size-1&&(m=this.size-1);var v=Math.floor(t-l);v<1&&(v=1);t=Math.floor(t+l);t>this.size-1&&(t=this.size-1);var o=Math.floor(u-l);o<1&&(o=1);l=Math.floor(u+l);l>this.size-1&&(l=this.size- 1);for(var z,x,w,B,y,A;p0&&(this.field[w+z]+=B)}}};this.addPlaneX=function(a,b){var f,h,k,l,m,t=this.size,u=this.yd,p=this.zd,v=this.field,o=t*Math.sqrt(a/b);o>t&&(o=t);for(f=0;f0)for(h=0;hu&&(z=u);for(h=0;h0){m=h*p;for(f=0;fsize&&(dist=size);for(k=0;k0){m=zd*k;for(h=0;hh?this.hits.push(f):this.hits.unshift(f),h=e;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(a){var b=this.rayCastAll(a);if(b.length==0)return null;for(var c=0;b[c]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,b[c]);if(e.distb.length)return null;return b[c]}; THREE.CollisionSystem.prototype.rayCast=function(a,b){if(b instanceof THREE.PlaneCollider)return this.rayPlane(a,b);else if(b instanceof THREE.SphereCollider)return this.raySphere(a,b);else if(b instanceof THREE.BoxCollider)return this.rayBox(a,b);else if(b instanceof THREE.MeshCollider&&b.box)return this.rayBox(a,b.box)}; THREE.CollisionSystem.prototype.rayMesh=function(a,b){for(var c=this.makeRayLocal(a,b.mesh),e=Number.MAX_VALUE,f,h=0;h=l*f))return Number.MAX_VALUE;k/=l;l=THREE.CollisionSystem.__v3;l.copy(a.direction);l.multiplyScalar(k);l.addSelf(a.origin);Math.abs(h.x)> Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=l.y-b.y,h=c.y-b.y,f=e.y-b.y,l=l.z-b.z,c=c.z-b.z,e=e.z-b.z):(a=l.x-b.x,h=c.x-b.x,f=e.x-b.x,l=l.y-b.y,c=c.y-b.y,e=e.y-b.y):Math.abs(h.y)>Math.abs(h.z)?(a=l.x-b.x,h=c.x-b.x,f=e.x-b.x,l=l.z-b.z,c=c.z-b.z,e=e.z-b.z):(a=l.x-b.x,h=c.x-b.x,f=e.x-b.x,l=l.y-b.y,c=c.y-b.y,e=e.y-b.y);b=h*e-c*f;if(b==0)return Number.MAX_VALUE;b=1/b;e=(a*e-l*f)*b;if(!(e>=0))return Number.MAX_VALUE;b*=h*l-c*a;if(!(b>=0))return Number.MAX_VALUE;if(!(1-e-b>=0))return Number.MAX_VALUE;return k}; THREE.CollisionSystem.prototype.makeRayLocal=function(a,b){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(b.matrixWorld,c);var e=THREE.CollisionSystem.__r;e.origin.copy(a.origin);e.direction.copy(a.direction);c.multiplyVector3(e.origin);c.rotateAxis(e.direction);e.direction.normalize();return e}; THREE.CollisionSystem.prototype.rayBox=function(a,b){var c;b.dynamic&&b.mesh&&b.mesh.matrixWorld?c=this.makeRayLocal(a,b.mesh):(c=THREE.CollisionSystem.__r,c.origin.copy(a.origin),c.direction.copy(a.direction));var e=0,f=0,h=0,k=0,l=0,m=0,t=!0;c.origin.xb.max.x&&(e=b.max.x-c.origin.x,e/=c.direction.x,t=!1,k=1);c.origin.yb.max.y&&(f=b.max.y-c.origin.y,f/=c.direction.y, t=!1,l=1);c.origin.zb.max.z&&(h=b.max.z-c.origin.z,h/=c.direction.z,t=!1,m=1);if(t)return-1;t=0;f>e&&(t=1,e=f);h>e&&(t=2,e=h);switch(t){case 0:l=c.origin.y+c.direction.y*e;if(lb.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*e;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(k,0,0);break;case 1:k=c.origin.x+c.direction.x*e;if(kb.max.x)return Number.MAX_VALUE;c=c.origin.z+c.direction.z* e;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(0,l,0);break;case 2:k=c.origin.x+c.direction.x*e;if(kb.max.x)return Number.MAX_VALUE;l=c.origin.y+c.direction.y*e;if(lb.max.y)return Number.MAX_VALUE;b.normal.set(0,0,m)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,b){var c=a.direction.dot(b.normal),e=b.point.dot(b.normal);if(c<0)c=(e-a.origin.dot(b.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(a,b){var c=b.center.clone().subSelf(a.origin);if(c.lengthSq=0)return Math.abs(e)-Math.sqrt(c);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var b=a.geometry.boundingBox,c=new THREE.Vector3(b.x[0],b.y[0],b.z[0]),b=new THREE.Vector3(b.x[1],b.y[1],b.z[1]),c=new THREE.BoxCollider(c,b);c.mesh=a;return c};THREE.CollisionUtils.MeshAABB=function(a){var b=THREE.CollisionUtils.MeshOBB(a);b.min.addSelf(a.position);b.max.addSelf(a.position);b.dynamic=!1;return b}; THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))}; if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var b=this,c=this.setSize,e=this.render,f=new THREE.PerspectiveCamera,h=new THREE.PerspectiveCamera,k=new THREE.Matrix4,l=new THREE.Matrix4,m,t,u;f.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},p=new THREE.WebGLRenderTarget(512,512,a),v=new THREE.WebGLRenderTarget(512,512,a),o=new THREE.PerspectiveCamera(53,1,1,1E4);o.position.z= 2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:p},mapRight:{type:"t",value:1,texture:v}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}); var z=new THREE.Scene;z.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){c.call(b,a,e);p.width=a;p.height=e;v.width=a;v.height=e};this.render=function(a,c){c.update(null,!0);if(m!==c.aspect||t!==c.near||u!==c.fov){m=c.aspect;t=c.near;u=c.fov;var B=c.projectionMatrix.clone(),y=125/30*0.5,A=y*t/125,E=t*Math.tan(u*Math.PI/360),C;k.n14=y;l.n14=-y;y=-E*m+A;C=E*m+A;B.n11=2*t/(C-y);B.n13=(C+y)/(C-y);f.projectionMatrix=B.clone();y=-E*m-A;C=E*m-A;B.n11=2*t/(C-y);B.n13= (C+y)/(C-y);h.projectionMatrix=B.clone()}f.matrix=c.matrixWorld.clone().multiplySelf(l);f.update(null,!0);f.position.copy(c.position);f.near=t;f.far=c.far;e.call(b,a,f,p,!0);h.matrix=c.matrixWorld.clone().multiplySelf(k);h.update(null,!0);h.position.copy(c.position);h.near=t;h.far=c.far;e.call(b,a,h,v,!0);e.call(b,z,o)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,e=this.render,f,h,k=new THREE.PerspectiveCamera;k.target=new THREE.Vector3(0,0,0);var l=new THREE.PerspectiveCamera;l.target=new THREE.Vector3(0,0,0);b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;this.setSize=function(a,e){c.call(b,a,e);f=a/2;h=e};this.render=function(a,c){this.clear();k.fov=c.fov;k.aspect=0.5*c.aspect;k.near=c.near;k.far= c.far;k.updateProjectionMatrix();k.position.copy(c.position);k.target.copy(c.target);k.translateX(b.separation);k.lookAt(k.target);l.projectionMatrix=k.projectionMatrix;l.position.copy(c.position);l.target.copy(c.target);l.translateX(-b.separation);l.lookAt(l.target);this.setViewport(0,0,f,h);e.call(b,a,k);this.setViewport(f,0,f,h);e.call(b,a,l,!1)}};