// 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,n,p,u,t,v,o,y,x=a.geometry,w=x.vertices,h=0,k=x.faces.length;h0:v<0)))if(v=t.dot((new THREE.Vector3).sub(l,o))/v,o=o.addSelf(y.multiplyScalar(v)),e instanceof THREE.Face3)c(o,l,n,p)&&(e={distance:this.origin.distanceTo(o),point:o,face:e,object:a},f.push(e));else if(e instanceof THREE.Face4&&(c(o,l,n,u)||c(o,n,p,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,t){l=!1;b=k;c=h;e=u;f=t;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,t,v,o){l?(l=!1,b=ku?k>v?k:v:u>v?u:v,f=h>t?h>o?h:o:t>o?t: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>t?h>o?h>f?h:f:o>f?o:f:t>o?t>f?t: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))),em&&k.positionScreen.z0&&M.z<1))X=C[z]=C[z]||new THREE.RenderableParticle,z++,A=X,A.x=M.x/M.w,A.y=M.y/M.w,A.z=M.z,A.rotation=Y.rotation.z,A.scale.x=Y.scale.x*Math.abs(A.x-(M.x+f.projectionMatrix.n11)/(M.w+f.projectionMatrix.n14)),A.scale.y=Y.scale.y*Math.abs(A.y-(M.y+f.projectionMatrix.n22)/(M.w+f.projectionMatrix.n24)),A.materials=Y.materials,K.push(A);h&&K.sort(b);return K}};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,n=this.w,p=n*c+k*f-l*e,u=n*e+l*c-h*f,t=n*f+h*e-k*c,c=-h* c-k*e-l*f;b.x=p*n+c*-h+u*-l-t*-k;b.y=u*n+c*-k+t*-h-p*-l;b.z=t*n+c*-l+p*-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;p=this.points[c[0]];u=this.points[c[1]]; t=this.points[c[2]];v=this.points[c[3]];l=k*k;n=k*l;e.x=b(p.x,u.x,t.x,v.x,k,l,n);e.y=b(p.y,u.y,t.y,v.y,k,l,n);e.z=b(p.z,u.z,t.z,v.z,k,l,n);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(y.r*255)+","+Math.floor(y.g*255)+","+ Math.floor(y.b*255)+","+x+")"),o.fillRect(Math.floor(G.getX()),Math.floor(G.getY()),Math.floor(G.getWidth()),Math.floor(G.getHeight()))),G.empty())};this.render=function(a,n){function p(a){var c,b,e,f=a.lights;N.setRGB(0,0,0);ta.setRGB(0,0,0);pa.setRGB(0,0,0);a=0;for(c=f.length;a>1,wa=p.height>>1,h=k.scale.x*t,n=k.scale.y*v,m=h*u,l=n*wa,$.set(a.x-m,a.y-l,a.x+m,a.y+l),xa.intersects($)&&(o.save(),o.translate(a.x,a.y),o.rotate(-k.rotation),o.scale(h,-n),o.translate(-u,-wa),o.drawImage(p,0,0),o.restore())}else h instanceof THREE.ParticleCanvasMaterial&&(m=k.scale.x*t,l=k.scale.y*v,$.set(a.x-m,a.y-l,a.x+m,a.y+l),xa.intersects($)&&(e(h.color.getContextStyle()),f(h.color.getContextStyle()),o.save(),o.translate(a.x,a.y),o.rotate(-k.rotation),o.scale(m,l),h.program(o), o.restore()))}function w(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(B!=a)o.lineWidth=B=a;a=h.linecap;if(K!=a)o.lineCap=K=a;a=h.linejoin;if(F!=a)o.lineJoin=F=a;e(h.color.getContextStyle());o.stroke();$.inflate(h.linewidth*2)}}function y(a,e,f,k,l,p,t,o,v){h.info.render.vertices+=3;h.info.render.faces++;b(o.opacity);c(o.blending); L=a.positionScreen.x;T=a.positionScreen.y;S=e.positionScreen.x;m=e.positionScreen.y;aa=f.positionScreen.x;U=f.positionScreen.y;A(L,T,S,m,aa,U);if(o instanceof THREE.MeshBasicMaterial)if(o.map)o.map.mapping instanceof THREE.UVMapping&&(la=t.uvs[0],$a(L,T,S,m,aa,U,la[k].u,la[k].v,la[l].u,la[l].v,la[p].u,la[p].v,o.map));else if(o.envMap){if(o.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=n.matrixWorldInverse,ka.copy(t.vertexNormalsWorld[0]),ua=(ka.x*a.n11+ka.y*a.n12+ka.z*a.n13)*0.5+0.5, sa=-(ka.x*a.n21+ka.y*a.n22+ka.z*a.n23)*0.5+0.5,ka.copy(t.vertexNormalsWorld[1]),Da=(ka.x*a.n11+ka.y*a.n12+ka.z*a.n13)*0.5+0.5,Ea=-(ka.x*a.n21+ka.y*a.n22+ka.z*a.n23)*0.5+0.5,ka.copy(t.vertexNormalsWorld[2]),za=(ka.x*a.n11+ka.y*a.n12+ka.z*a.n13)*0.5+0.5,Fa=-(ka.x*a.n21+ka.y*a.n22+ka.z*a.n23)*0.5+0.5,$a(L,T,S,m,aa,U,ua,sa,Da,Ea,za,Fa,o.envMap)}else o.wireframe?Ka(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):La(o.color);else if(o instanceof THREE.MeshLambertMaterial)o.map&&!o.wireframe&& (o.map.mapping instanceof THREE.UVMapping&&(la=t.uvs[0],$a(L,T,S,m,aa,U,la[k].u,la[k].v,la[l].u,la[l].v,la[p].u,la[p].v,o.map)),c(THREE.SubtractiveBlending)),ma?!o.wireframe&&o.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==3?(R.r=Y.r=X.r=N.r,R.g=Y.g=X.g=N.g,R.b=Y.b=X.b=N.b,u(v,t.v1.positionWorld,t.vertexNormalsWorld[0],R),u(v,t.v2.positionWorld,t.vertexNormalsWorld[1],Y),u(v,t.v3.positionWorld,t.vertexNormalsWorld[2],X),R.r=Math.max(0,Math.min(o.color.r*R.r,1)),R.g=Math.max(0,Math.min(o.color.g* R.g,1)),R.b=Math.max(0,Math.min(o.color.b*R.b,1)),Y.r=Math.max(0,Math.min(o.color.r*Y.r,1)),Y.g=Math.max(0,Math.min(o.color.g*Y.g,1)),Y.b=Math.max(0,Math.min(o.color.b*Y.b,1)),X.r=Math.max(0,Math.min(o.color.r*X.r,1)),X.g=Math.max(0,Math.min(o.color.g*X.g,1)),X.b=Math.max(0,Math.min(o.color.b*X.b,1)),ga.r=(Y.r+X.r)*0.5,ga.g=(Y.g+X.g)*0.5,ga.b=(Y.b+X.b)*0.5,qa=Xa(R,Y,X,ga),Ua(L,T,S,m,aa,U,0,0,1,0,0,1,qa)):(I.r=N.r,I.g=N.g,I.b=N.b,u(v,t.centroidWorld,t.normalWorld,I),Z.r=Math.max(0,Math.min(o.color.r* I.r,1)),Z.g=Math.max(0,Math.min(o.color.g*I.g,1)),Z.b=Math.max(0,Math.min(o.color.b*I.b,1)),o.wireframe?Ka(Z,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):La(Z)):o.wireframe?Ka(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):La(o.color);else if(o instanceof THREE.MeshDepthMaterial)na=n.near,fa=n.far,R.r=R.g=R.b=1-Oa(a.positionScreen.z,na,fa),Y.r=Y.g=Y.b=1-Oa(e.positionScreen.z,na,fa),X.r=X.g=X.b=1-Oa(f.positionScreen.z,na,fa),ga.r=(Y.r+X.r)*0.5,ga.g=(Y.g+X.g)*0.5, ga.b=(Y.b+X.b)*0.5,qa=Xa(R,Y,X,ga),Ua(L,T,S,m,aa,U,0,0,1,0,0,1,qa);else if(o instanceof THREE.MeshNormalMaterial)Z.r=Va(t.normalWorld.x),Z.g=Va(t.normalWorld.y),Z.b=Va(t.normalWorld.z),o.wireframe?Ka(Z,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):La(Z)}function z(a,e,f,k,l,p,o,t,v){h.info.render.vertices+=4;h.info.render.faces++;b(t.opacity);c(t.blending);if(t.map||t.envMap)y(a,e,k,0,1,3,o,t,v),y(l,f,p,1,2,3,o,t,v);else if(L=a.positionScreen.x,T=a.positionScreen.y,S=e.positionScreen.x, m=e.positionScreen.y,aa=f.positionScreen.x,U=f.positionScreen.y,ea=k.positionScreen.x,da=k.positionScreen.y,ia=l.positionScreen.x,ha=l.positionScreen.y,ja=p.positionScreen.x,ca=p.positionScreen.y,t instanceof THREE.MeshBasicMaterial)C(L,T,S,m,aa,U,ea,da),t.wireframe?Ka(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(t.color);else if(t instanceof THREE.MeshLambertMaterial)ma?!t.wireframe&&t.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==4?(R.r=Y.r=X.r=ga.r=N.r,R.g= Y.g=X.g=ga.g=N.g,R.b=Y.b=X.b=ga.b=N.b,u(v,o.v1.positionWorld,o.vertexNormalsWorld[0],R),u(v,o.v2.positionWorld,o.vertexNormalsWorld[1],Y),u(v,o.v4.positionWorld,o.vertexNormalsWorld[3],X),u(v,o.v3.positionWorld,o.vertexNormalsWorld[2],ga),R.r=Math.max(0,Math.min(t.color.r*R.r,1)),R.g=Math.max(0,Math.min(t.color.g*R.g,1)),R.b=Math.max(0,Math.min(t.color.b*R.b,1)),Y.r=Math.max(0,Math.min(t.color.r*Y.r,1)),Y.g=Math.max(0,Math.min(t.color.g*Y.g,1)),Y.b=Math.max(0,Math.min(t.color.b*Y.b,1)),X.r=Math.max(0, Math.min(t.color.r*X.r,1)),X.g=Math.max(0,Math.min(t.color.g*X.g,1)),X.b=Math.max(0,Math.min(t.color.b*X.b,1)),ga.r=Math.max(0,Math.min(t.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(t.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(t.color.b*ga.b,1)),qa=Xa(R,Y,X,ga),A(L,T,S,m,ea,da),Ua(L,T,S,m,ea,da,0,0,1,0,0,1,qa),A(ia,ha,aa,U,ja,ca),Ua(ia,ha,aa,U,ja,ca,1,0,1,1,0,1,qa)):(I.r=N.r,I.g=N.g,I.b=N.b,u(v,o.centroidWorld,o.normalWorld,I),Z.r=Math.max(0,Math.min(t.color.r*I.r,1)),Z.g=Math.max(0,Math.min(t.color.g* I.g,1)),Z.b=Math.max(0,Math.min(t.color.b*I.b,1)),C(L,T,S,m,aa,U,ea,da),t.wireframe?Ka(Z,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(Z)):(C(L,T,S,m,aa,U,ea,da),t.wireframe?Ka(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(t.color));else if(t instanceof THREE.MeshNormalMaterial)Z.r=Va(o.normalWorld.x),Z.g=Va(o.normalWorld.y),Z.b=Va(o.normalWorld.z),C(L,T,S,m,aa,U,ea,da),t.wireframe?Ka(Z,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(Z); else if(t instanceof THREE.MeshDepthMaterial)na=n.near,fa=n.far,R.r=R.g=R.b=1-Oa(a.positionScreen.z,na,fa),Y.r=Y.g=Y.b=1-Oa(e.positionScreen.z,na,fa),X.r=X.g=X.b=1-Oa(k.positionScreen.z,na,fa),ga.r=ga.g=ga.b=1-Oa(f.positionScreen.z,na,fa),qa=Xa(R,Y,X,ga),A(L,T,S,m,ea,da),Ua(L,T,S,m,ea,da,0,0,1,0,0,1,qa),A(ia,ha,aa,U,ja,ca),Ua(ia,ha,aa,U,ja,ca,1,0,1,1,0,1,qa)}function A(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 C(a,c,b,e,f,k,h,m){o.beginPath(); o.moveTo(a,c);o.lineTo(b,e);o.lineTo(f,k);o.lineTo(h,m);o.lineTo(a,c);o.closePath()}function Ka(a,c,b,f){if(B!=c)o.lineWidth=B=c;if(K!=b)o.lineCap=K=b;if(F!=f)o.lineJoin=F=f;e(a.getContextStyle());o.stroke();$.inflate(c*2)}function La(a){f(a.getContextStyle());o.fill()}function $a(a,c,b,e,k,h,m,l,n,p,t,u,v){if(v.image.width!=0){if(v.needsUpdate==!0||oa[v.id]==void 0){var wa=v.wrapS==THREE.RepeatWrapping,G=v.wrapT==THREE.RepeatWrapping;oa[v.id]=o.createPattern(v.image,wa&&G?"repeat":wa&&!G?"repeat-x": !wa&&G?"repeat-y":"no-repeat");v.needsUpdate=!1}f(oa[v.id]);var wa=v.offset.x/v.repeat.x,G=v.offset.y/v.repeat.y,x=(v.image.width-1)*v.repeat.x,v=(v.image.height-1)*v.repeat.y,m=(m+wa)*x,l=(l+G)*v,n=(n+wa)*x,p=(p+G)*v,t=(t+wa)*x,u=(u+G)*v;b-=a;e-=c;k-=a;h-=c;n-=m;p-=l;t-=m;u-=l;wa=1/(n*u-t*p);v=(u*b-p*k)*wa;p=(u*e-p*h)*wa;b=(n*k-t*b)*wa;e=(n*h-t*e)*wa;a=a-v*m-b*l;c=c-p*m-e*l;o.save();o.transform(v,p,b,e,a,c);o.fill();o.restore()}}function Ua(a,c,b,e,f,k,h,m,l,n,p,t,v){var u,wa;u=v.width-1;wa=v.height- 1;h*=u;m*=wa;l*=u;n*=wa;p*=u;t*=wa;b-=a;e-=c;f-=a;k-=c;l-=h;n-=m;p-=h;t-=m;wa=1/(l*t-p*n);u=(t*b-n*f)*wa;n=(t*e-n*k)*wa;b=(l*f-p*b)*wa;e=(l*k-p*e)*wa;a=a-u*h-b*m;c=c-n*h-e*m;o.save();o.transform(u,n,b,e,a,c);o.clip();o.drawImage(v,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),m=~~(c.g*255),c=~~(c.b*255),l=~~(b.r*255),n=~~(b.g*255),b=~~(b.b*255),p=~~(e.r*255),t=~~(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]=m<0?0:m>255?255:m;Ba[6]=c<0?0:c>255?255:c;Ba[8]=l<0?0:l>255?255:l;Ba[9]=n<0?0:n>255?255:n;Ba[10]=b<0?0:b>255?255:b;Ba[12]=p<0?0:p>255?255:p;Ba[13]=t<0?0:t>255?255:t;Ba[14]=e<0?0:e>255?255:e;va.putImageData(Ca,0,0);W.drawImage(ya,0,0);return Ga}function Oa(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 Ma(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,ra,Ha,Na,Wa,Za,Aa;this.autoClear?this.clear():o.setTransform(1,0,0,-1,t,v);h.info.render.vertices=0;h.info.render.faces=0;k=l.projectScene(a,n,this.sortElements);(ma=a.lights.length>0)&&p(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&&(V.sub(k.position,c.centroidWorld),V.normalize(),h=c.normalWorld.dot(V)*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,m,l,p){h.info.render.vertices+=3;h.info.render.faces++;L=e(T++); L.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+b.positionScreen.x+" "+b.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");l instanceof THREE.MeshBasicMaterial?B.copy(l.color):l instanceof THREE.MeshLambertMaterial?C?(K.r=F.r,K.g=F.g,K.b=F.b,a(p,m,K),B.r=Math.max(0,Math.min(l.color.r*K.r,1)),B.g=Math.max(0,Math.min(l.color.g*K.g,1)),B.b=Math.max(0,Math.min(l.color.b*K.b,1))):B.copy(l.color):l instanceof THREE.MeshDepthMaterial?(O=1-l.__2near/(l.__farPlusNear- m.z*l.__farMinusNear),B.setRGB(O,O,O)):l instanceof THREE.MeshNormalMaterial&&B.setRGB(f(m.normalWorld.x),f(m.normalWorld.y),f(m.normalWorld.z));l.wireframe?L.setAttribute("style","fill: none; stroke: "+B.getContextStyle()+"; stroke-width: "+l.wireframeLinewidth+"; stroke-opacity: "+l.opacity+"; stroke-linecap: "+l.wireframeLinecap+"; stroke-linejoin: "+l.wireframeLinejoin):L.setAttribute("style","fill: "+B.getContextStyle()+"; fill-opacity: "+l.opacity);n.appendChild(L)}function c(c,b,k,m,l,p,t){h.info.render.vertices+= 4;h.info.render.faces++;L=e(T++);L.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+b.positionScreen.x+" "+b.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?B.copy(p.color):p instanceof THREE.MeshLambertMaterial?C?(K.r=F.r,K.g=F.g,K.b=F.b,a(t,l,K),B.r=Math.max(0,Math.min(p.color.r*K.r,1)),B.g=Math.max(0,Math.min(p.color.g*K.g,1)),B.b=Math.max(0,Math.min(p.color.b*K.b,1))): B.copy(p.color):p instanceof THREE.MeshDepthMaterial?(O=1-p.__2near/(p.__farPlusNear-l.z*p.__farMinusNear),B.setRGB(O,O,O)):p instanceof THREE.MeshNormalMaterial&&B.setRGB(f(l.normalWorld.x),f(l.normalWorld.y),f(l.normalWorld.z));p.wireframe?L.setAttribute("style","fill: none; stroke: "+B.getContextStyle()+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):L.setAttribute("style","fill: "+B.getContextStyle()+ "; fill-opacity: "+p.opacity);n.appendChild(L)}function e(a){H[a]==null&&(H[a]=document.createElementNS("http://www.w3.org/2000/svg","path"),m==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,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,u,t,v,o,y,x,w,A=new THREE.Rectangle,z=new THREE.Rectangle,C=!1,B=new THREE.Color(16777215),K=new THREE.Color(16777215),F=new THREE.Color(0), M=new THREE.Color(0),E=new THREE.Color(0),O,V=new THREE.Vector3,H=[],P=[],L,T,S,m=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(a){switch(a){case "high":m=1;break;case "low":m=0}};this.setSize=function(a,c){p=a;u=c;t=p/2;v=u/2;n.setAttribute("viewBox",-t+" "+-v+" "+p+" "+u);n.setAttribute("width",p);n.setAttribute("height",u);A.set(-t,-v,t,v)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])}; this.render=function(a,e){var f,p,u,B,O,H,K,R;this.autoClear&&this.clear();h.info.render.vertices=0;h.info.render.faces=0;k=l.projectScene(a,e,this.sortElements);S=T=0;if(C=a.lights.length>0){K=a.lights;F.setRGB(0,0,0);M.setRGB(0,0,0);E.setRGB(0,0,0);f=0;for(p=K.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)return a.geometry.materials[c.materialIndex]}function c(a,c,b){var e,f,k,h=a.vertices,l=h.length,n=a.colors,p=n.length,t=a.__vertexArray,o=a.__colorArray,u=a.__sortArray,v=a.__dirtyVertices,G=a.__dirtyColors,x=a.__webglCustomAttributesList,w;if(x){k=0;for(e=x.length;k=0)c&&(m.bindBuffer(m.ARRAY_BUFFER,f.__webglVertexBuffer),m.vertexAttribPointer(a.position,3,m.FLOAT,!1,0,0));else if(h.morphTargetBase){b=k.program.attributes;h.morphTargetBase!==-1?(m.bindBuffer(m.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[h.morphTargetBase]),m.vertexAttribPointer(b.position, 3,m.FLOAT,!1,0,0)):b.position>=0&&(m.bindBuffer(m.ARRAY_BUFFER,f.__webglVertexBuffer),m.vertexAttribPointer(b.position,3,m.FLOAT,!1,0,0));if(h.morphTargetForcedOrder.length){l=0;var p=h.morphTargetForcedOrder;for(n=h.morphTargetInfluences;lt&&(o=v,t=n[o]);m.bindBuffer(m.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[o]);m.vertexAttribPointer(b["morphTarget"+l],3,m.FLOAT,!1,0,0);h.__webglMorphTargetInfluences[l]=t;p[o]=1;t=-1;l++}}k.program.uniforms.morphTargetInfluences!==null&&m.uniform1fv(k.program.uniforms.morphTargetInfluences,h.__webglMorphTargetInfluences)}if(c){if(f.__webglCustomAttributesList){l=0;for(n= f.__webglCustomAttributesList.length;l=0&&(m.bindBuffer(m.ARRAY_BUFFER,b.buffer),m.vertexAttribPointer(a[b.buffer.belongsToAttribute],b.size,m.FLOAT,!1,0,0))}a.color>=0&&(m.bindBuffer(m.ARRAY_BUFFER,f.__webglColorBuffer),m.vertexAttribPointer(a.color,3,m.FLOAT,!1,0,0));a.normal>=0&&(m.bindBuffer(m.ARRAY_BUFFER,f.__webglNormalBuffer),m.vertexAttribPointer(a.normal,3,m.FLOAT,!1,0,0));a.tangent>=0&&(m.bindBuffer(m.ARRAY_BUFFER, f.__webglTangentBuffer),m.vertexAttribPointer(a.tangent,4,m.FLOAT,!1,0,0));a.uv>=0&&(f.__webglUVBuffer?(m.bindBuffer(m.ARRAY_BUFFER,f.__webglUVBuffer),m.vertexAttribPointer(a.uv,2,m.FLOAT,!1,0,0),m.enableVertexAttribArray(a.uv)):m.disableVertexAttribArray(a.uv));a.uv2>=0&&(f.__webglUV2Buffer?(m.bindBuffer(m.ARRAY_BUFFER,f.__webglUV2Buffer),m.vertexAttribPointer(a.uv2,2,m.FLOAT,!1,0,0),m.enableVertexAttribArray(a.uv2)):m.disableVertexAttribArray(a.uv2));k.skinning&&a.skinVertexA>=0&&a.skinVertexB>= 0&&a.skinIndex>=0&&a.skinWeight>=0&&(m.bindBuffer(m.ARRAY_BUFFER,f.__webglSkinVertexABuffer),m.vertexAttribPointer(a.skinVertexA,4,m.FLOAT,!1,0,0),m.bindBuffer(m.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),m.vertexAttribPointer(a.skinVertexB,4,m.FLOAT,!1,0,0),m.bindBuffer(m.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),m.vertexAttribPointer(a.skinIndex,4,m.FLOAT,!1,0,0),m.bindBuffer(m.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),m.vertexAttribPointer(a.skinWeight,4,m.FLOAT,!1,0,0))}h instanceof THREE.Mesh?(k.wireframe? (m.lineWidth(k.wireframeLinewidth),c&&m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),m.drawElements(m.LINES,f.__webglLineCount,m.UNSIGNED_SHORT,0)):(c&&m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),m.drawElements(m.TRIANGLES,f.__webglFaceCount,m.UNSIGNED_SHORT,0)),S.info.render.calls++,S.info.render.vertices+=f.__webglFaceCount,S.info.render.faces+=f.__webglFaceCount/3):h instanceof THREE.Line?(h=h.type===THREE.LineStrip?m.LINE_STRIP:m.LINES,m.lineWidth(k.linewidth),m.drawArrays(h, 0,f.__webglLineCount),S.info.render.calls++):h instanceof THREE.ParticleSystem?(m.drawArrays(m.POINTS,0,f.__webglParticleCount),S.info.render.calls++):h instanceof THREE.Ribbon&&(m.drawArrays(m.TRIANGLE_STRIP,0,f.__webglVertexCount),S.info.render.calls++)}}function h(a,c,b){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=m.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=m.createBuffer();a.hasPos&&(m.bindBuffer(m.ARRAY_BUFFER,a.__webglVertexBuffer),m.bufferData(m.ARRAY_BUFFER,a.positionArray, m.DYNAMIC_DRAW),m.enableVertexAttribArray(c.attributes.position),m.vertexAttribPointer(c.attributes.position,3,m.FLOAT,!1,0,0));if(a.hasNormal){m.bindBuffer(m.ARRAY_BUFFER,a.__webglNormalBuffer);if(b===THREE.FlatShading){var e,f,k,h,l,n,p,t,o,v,u=a.count*3;for(v=0;v=0)c=c.geometry.materials[b],c.transparent?(a.transparent=c,a.opaque=null):(a.opaque=c,a.transparent=null)}else if(c=e)c.transparent?(a.transparent=c,a.opaque=null):(a.opaque=c,a.transparent=null)}function y(a,c){return c.z-a.z}function x(a){var c,b,n,p=0,o,v,G,w,x=a.lights;pa||(pa=new THREE.PerspectiveCamera(S.shadowCameraFov,S.shadowMapWidth/S.shadowMapHeight,S.shadowCameraNear,S.shadowCameraFar));c=0;for(b=x.length;c=0;b--)a[b].object===c&&a.splice(b,1)}function K(a,c,b){a.push({buffer:c,object:b,opaque:null,transparent:null})}function F(a){if(a!==Z){switch(a){case THREE.AdditiveBlending:m.blendEquation(m.FUNC_ADD); m.blendFunc(m.SRC_ALPHA,m.ONE);break;case THREE.SubtractiveBlending:m.blendEquation(m.FUNC_ADD);m.blendFunc(m.ZERO,m.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:m.blendEquation(m.FUNC_ADD);m.blendFunc(m.ZERO,m.SRC_COLOR);break;default:m.blendEquationSeparate(m.FUNC_ADD,m.FUNC_ADD),m.blendFuncSeparate(m.SRC_ALPHA,m.ONE_MINUS_SRC_ALPHA,m.ONE,m.ONE_MINUS_SRC_ALPHA)}Z=a}}function M(a,c,b){(b.width&b.width-1)===0&&(b.height&b.height-1)===0?(m.texParameteri(a,m.TEXTURE_WRAP_S,T(c.wrapS)),m.texParameteri(a, m.TEXTURE_WRAP_T,T(c.wrapT)),m.texParameteri(a,m.TEXTURE_MAG_FILTER,T(c.magFilter)),m.texParameteri(a,m.TEXTURE_MIN_FILTER,T(c.minFilter)),m.generateMipmap(a)):(m.texParameteri(a,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(a,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.texParameteri(a,m.TEXTURE_MAG_FILTER,L(c.magFilter)),m.texParameteri(a,m.TEXTURE_MIN_FILTER,L(c.minFilter)))}function E(a,c){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=m.createTexture(),S.info.memory.textures++; m.activeTexture(m.TEXTURE0+c);m.bindTexture(m.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?m.texImage2D(m.TEXTURE_2D,0,T(a.format),a.image.width,a.image.height,0,T(a.format),m.UNSIGNED_BYTE,a.image.data):m.texImage2D(m.TEXTURE_2D,0,m.RGBA,m.RGBA,m.UNSIGNED_BYTE,a.image);M(m.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else m.activeTexture(m.TEXTURE0+c),m.bindTexture(m.TEXTURE_2D,a.__webglTexture)}function O(a,c){m.bindRenderbuffer(m.RENDERBUFFER,a);c.depthBuffer&&!c.stencilBuffer?(m.renderbufferStorage(m.RENDERBUFFER, m.DEPTH_COMPONENT16,c.width,c.height),m.framebufferRenderbuffer(m.FRAMEBUFFER,m.DEPTH_ATTACHMENT,m.RENDERBUFFER,a)):c.depthBuffer&&c.stencilBuffer?(m.renderbufferStorage(m.RENDERBUFFER,m.DEPTH_STENCIL,c.width,c.height),m.framebufferRenderbuffer(m.FRAMEBUFFER,m.DEPTH_STENCIL_ATTACHMENT,m.RENDERBUFFER,a)):m.renderbufferStorage(m.RENDERBUFFER,m.RGBA4,c.width,c.height)}function V(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=m.createTexture();if(c){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];m.bindTexture(m.TEXTURE_CUBE_MAP,a.__webglTexture);M(m.TEXTURE_CUBE_MAP,a,a);for(var b=0;b<6;b++){a.__webglFramebuffer[b]=m.createFramebuffer();a.__webglRenderbuffer[b]=m.createRenderbuffer();m.texImage2D(m.TEXTURE_CUBE_MAP_POSITIVE_X+b,0,T(a.format),a.width,a.height,0,T(a.format),T(a.type),null);var e=a,f=m.TEXTURE_CUBE_MAP_POSITIVE_X+b;m.bindFramebuffer(m.FRAMEBUFFER, a.__webglFramebuffer[b]);m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0,f,e.__webglTexture,0);O(a.__webglRenderbuffer[b],a)}}else a.__webglFramebuffer=m.createFramebuffer(),a.__webglRenderbuffer=m.createRenderbuffer(),m.bindTexture(m.TEXTURE_2D,a.__webglTexture),M(m.TEXTURE_2D,a,a),m.texImage2D(m.TEXTURE_2D,0,T(a.format),a.width,a.height,0,T(a.format),T(a.type),null),b=m.TEXTURE_2D,m.bindFramebuffer(m.FRAMEBUFFER,a.__webglFramebuffer),m.framebufferTexture2D(m.FRAMEBUFFER,m.COLOR_ATTACHMENT0, b,a.__webglTexture,0),m.bindRenderbuffer(m.RENDERBUFFER,a.__webglRenderbuffer),O(a.__webglRenderbuffer,a);c?m.bindTexture(m.TEXTURE_CUBE_MAP,null):m.bindTexture(m.TEXTURE_2D,null);m.bindRenderbuffer(m.RENDERBUFFER,null);m.bindFramebuffer(m.FRAMEBUFFER,null)}a?(c=c?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,b=a.width,a=a.height,f=e=0):(c=null,b=qa,a=la,e=na,f=fa);c!==ea&&(m.bindFramebuffer(m.FRAMEBUFFER,c),m.viewport(e,f,b,a),ea=c)}function H(a){a instanceof THREE.WebGLRenderTargetCube? (m.bindTexture(m.TEXTURE_CUBE_MAP,a.__webglTexture),m.generateMipmap(m.TEXTURE_CUBE_MAP),m.bindTexture(m.TEXTURE_CUBE_MAP,null)):(m.bindTexture(m.TEXTURE_2D,a.__webglTexture),m.generateMipmap(m.TEXTURE_2D),m.bindTexture(m.TEXTURE_2D,null))}function P(a,c){var b;a==="fragment"?b=m.createShader(m.FRAGMENT_SHADER):a==="vertex"&&(b=m.createShader(m.VERTEX_SHADER));m.shaderSource(b,c);m.compileShader(b);if(!m.getShaderParameter(b,m.COMPILE_STATUS))return console.error(m.getShaderInfoLog(b)),console.error(c), null;return b}function L(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return m.NEAREST;default:return m.LINEAR}}function T(a){switch(a){case THREE.RepeatWrapping:return m.REPEAT;case THREE.ClampToEdgeWrapping:return m.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return m.MIRRORED_REPEAT;case THREE.NearestFilter:return m.NEAREST;case THREE.NearestMipMapNearestFilter:return m.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return m.NEAREST_MIPMAP_LINEAR; case THREE.LinearFilter:return m.LINEAR;case THREE.LinearMipMapNearestFilter:return m.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return m.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return m.BYTE;case THREE.UnsignedByteType:return m.UNSIGNED_BYTE;case THREE.ShortType:return m.SHORT;case THREE.UnsignedShortType:return m.UNSIGNED_SHORT;case THREE.IntType:return m.INT;case THREE.UnsignedShortType:return m.UNSIGNED_INT;case THREE.FloatType:return m.FLOAT;case THREE.AlphaFormat:return m.ALPHA; case THREE.RGBFormat:return m.RGB;case THREE.RGBAFormat:return m.RGBA;case THREE.LuminanceFormat:return m.LUMINANCE;case THREE.LuminanceAlphaFormat:return m.LUMINANCE_ALPHA}return 0}var S=this,m,aa=[],U=null,ea=null,da=-1,ia=null,ha=0,ja=null,ca=null,Z=null,R=null,Y=null,X=null,ga=null,oa=null,na=0,fa=0,qa=0,la=0,ua=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],sa=new THREE.Matrix4,Da=new Float32Array(16),Ea=new Float32Array(16),za=new THREE.Vector4, Fa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},xa=a.canvas!==void 0?a.canvas:document.createElement("canvas"),G=a.stencil!==void 0?a.stencil:!0,$=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,ma=a.antialias!==void 0?a.antialias:!1,I=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),N=a.clearAlpha!==void 0?a.clearAlpha:0,ta=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=xa;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 pa,ka=[],a=THREE.ShaderLib.depthRGBA,ya=THREE.UniformsUtils.clone(a.uniforms),va=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:ya}),Ca=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:ya,morphTargets:!0});va._shadowPass=!0;Ca._shadowPass=!0;try{if(!(m=xa.getContext("experimental-webgl",{antialias:ma,stencil:G,preserveDrawingBuffer:$})))throw"Error creating WebGL context.";console.log(navigator.userAgent+ " | "+m.getParameter(m.VERSION)+" | "+m.getParameter(m.VENDOR)+" | "+m.getParameter(m.RENDERER)+" | "+m.getParameter(m.SHADING_LANGUAGE_VERSION))}catch(Ba){console.error(Ba)}m.clearColor(0,0,0,1);m.clearDepth(1);m.clearStencil(0);m.enable(m.DEPTH_TEST);m.depthFunc(m.LEQUAL);m.frontFace(m.CCW);m.cullFace(m.BACK);m.enable(m.CULL_FACE);m.enable(m.BLEND);m.blendEquation(m.FUNC_ADD);m.blendFunc(m.SRC_ALPHA,m.ONE_MINUS_SRC_ALPHA);m.clearColor(I.r,I.g,I.b,N);this.context=m;var Ga=m.getParameter(m.MAX_VERTEX_TEXTURE_IMAGE_UNITS)> 0,W={};W.vertices=new Float32Array(16);W.faces=new Uint16Array(6);G=0;W.vertices[G++]=-1;W.vertices[G++]=-1;W.vertices[G++]=0;W.vertices[G++]=1;W.vertices[G++]=1;W.vertices[G++]=-1;W.vertices[G++]=1;W.vertices[G++]=1;W.vertices[G++]=1;W.vertices[G++]=1;W.vertices[G++]=1;W.vertices[G++]=0;W.vertices[G++]=-1;W.vertices[G++]=1;W.vertices[G++]=0;G=W.vertices[G++]=0;W.faces[G++]=0;W.faces[G++]=1;W.faces[G++]=2;W.faces[G++]=0;W.faces[G++]=2;W.faces[G++]=3;W.vertexBuffer=m.createBuffer();W.elementBuffer= m.createBuffer();m.bindBuffer(m.ARRAY_BUFFER,W.vertexBuffer);m.bufferData(m.ARRAY_BUFFER,W.vertices,m.STATIC_DRAW);m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,W.elementBuffer);m.bufferData(m.ELEMENT_ARRAY_BUFFER,W.faces,m.STATIC_DRAW);W.program=m.createProgram();m.attachShader(W.program,P("fragment",THREE.ShaderLib.sprite.fragmentShader));m.attachShader(W.program,P("vertex",THREE.ShaderLib.sprite.vertexShader));m.linkProgram(W.program);W.attributes={};W.uniforms={};W.attributes.position=m.getAttribLocation(W.program, "position");W.attributes.uv=m.getAttribLocation(W.program,"uv");W.uniforms.uvOffset=m.getUniformLocation(W.program,"uvOffset");W.uniforms.uvScale=m.getUniformLocation(W.program,"uvScale");W.uniforms.rotation=m.getUniformLocation(W.program,"rotation");W.uniforms.scale=m.getUniformLocation(W.program,"scale");W.uniforms.alignment=m.getUniformLocation(W.program,"alignment");W.uniforms.color=m.getUniformLocation(W.program,"color");W.uniforms.map=m.getUniformLocation(W.program,"map");W.uniforms.opacity= m.getUniformLocation(W.program,"opacity");W.uniforms.useScreenCoordinates=m.getUniformLocation(W.program,"useScreenCoordinates");W.uniforms.affectedByDistance=m.getUniformLocation(W.program,"affectedByDistance");W.uniforms.screenPosition=m.getUniformLocation(W.program,"screenPosition");W.uniforms.modelViewMatrix=m.getUniformLocation(W.program,"modelViewMatrix");W.uniforms.projectionMatrix=m.getUniformLocation(W.program,"projectionMatrix");var Ta=!1;this.setSize=function(a,c){xa.width=a;xa.height= c;this.setViewport(0,0,xa.width,xa.height)};this.setViewport=function(a,c,b,e){na=a;fa=c;qa=b;la=e;m.viewport(na,fa,qa,la)};this.setScissor=function(a,c,b,e){m.scissor(a,c,b,e)};this.enableScissorTest=function(a){a?m.enable(m.SCISSOR_TEST):m.disable(m.SCISSOR_TEST)};this.setClearColorHex=function(a,c){I.setHex(a);N=c;m.clearColor(I.r,I.g,I.b,N)};this.setClearColor=function(a,c){I.copy(a);N=c;m.clearColor(I.r,I.g,I.b,N)};this.getClearColor=function(){return I};this.getClearAlpha=function(){return N}; this.clear=function(a,c,b){var e=0;if(a===void 0||a)e|=m.COLOR_BUFFER_BIT;if(c===void 0||c)e|=m.DEPTH_BUFFER_BIT;if(b===void 0||b)e|=m.STENCIL_BUFFER_BIT;m.clear(e)};this.getContext=function(){return m};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];m.deleteBuffer(c.__webglVertexBuffer); m.deleteBuffer(c.__webglNormalBuffer);m.deleteBuffer(c.__webglTangentBuffer);m.deleteBuffer(c.__webglColorBuffer);m.deleteBuffer(c.__webglUVBuffer);m.deleteBuffer(c.__webglUV2Buffer);m.deleteBuffer(c.__webglSkinVertexABuffer);m.deleteBuffer(c.__webglSkinVertexBBuffer);m.deleteBuffer(c.__webglSkinIndicesBuffer);m.deleteBuffer(c.__webglSkinWeightsBuffer);m.deleteBuffer(c.__webglFaceBuffer);m.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var b=0,e=c.numMorphTargets;b=0&&m.enableVertexAttribArray(u.position);u.color>=0&&m.enableVertexAttribArray(u.color);u.normal>=0&&m.enableVertexAttribArray(u.normal); u.tangent>=0&&m.enableVertexAttribArray(u.tangent);a.skinning&&u.skinVertexA>=0&&u.skinVertexB>=0&&u.skinIndex>=0&&u.skinWeight>=0&&(m.enableVertexAttribArray(u.skinVertexA),m.enableVertexAttribArray(u.skinVertexB),m.enableVertexAttribArray(u.skinIndex),m.enableVertexAttribArray(u.skinWeight));if(a.attributes)for(k in a.attributes)u[k]!==void 0&&u[k]>=0&&m.enableVertexAttribArray(u[k]);if(a.morphTargets)for(k=a.numSupportedMorphTargets=0;k=0&&(m.enableVertexAttribArray(u[G]), a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,c,b,e){V(a);this.clear(c,b,e)};this.updateShadowMap=function(a,c){x(a,c)};this.render=function(a,c,b,G){var ma,$,z,C,B,I,K,E=a.lights,na=a.fog;da=-1;this.shadowMapEnabled&&this.shadowMapAutoUpdate&&x(a,c);S.info.render.calls=0;S.info.render.vertices=0;S.info.render.faces=0;if(c.matrixAutoUpdate){for(z=c;z.parent;)z=z.parent;z.update(void 0,!0)}a.update(void 0,!1, c);c.matrixWorldInverse.flattenToArray(Ea);c.projectionMatrix.flattenToArray(Da);sa.multiply(c.projectionMatrix,c.matrixWorldInverse);u(sa);this.initWebGLObjects(a);V(b);(this.autoClear||G)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);z=a.__webglObjects.length;for(G=0;G=0;G--)if(B=a.__webglObjects[G],B.render&&(I=B.object,K=B.buffer,$=B.opaque))k(I),l($.depthTest),n($.depthWrite),p($.polygonOffset,$.polygonOffsetFactor,$.polygonOffsetUnits),f(c,E,na,$,K, I);for(G=0;G65535&&(G[v].counter+=1,u=G[v].hash+"_"+G[v].counter,l.geometryGroups[u]===void 0&&(l.geometryGroups[u]={faces:[], materialIndex:o,vertices:0,numMorphTargets:w})),l.geometryGroups[u].faces.push(n),l.geometryGroups[u].vertices+=t;l.geometryGroupsList=[];n=void 0;for(n in l.geometryGroups)l.geometryGroups[n].id=ha++,l.geometryGroupsList.push(l.geometryGroups[n])}for(k in h.geometryGroups)if(l=h.geometryGroups[k],!l.__webglVertexBuffer){n=l;n.__webglVertexBuffer=m.createBuffer();n.__webglNormalBuffer=m.createBuffer();n.__webglTangentBuffer=m.createBuffer();n.__webglColorBuffer=m.createBuffer();n.__webglUVBuffer= m.createBuffer();n.__webglUV2Buffer=m.createBuffer();n.__webglSkinVertexABuffer=m.createBuffer();n.__webglSkinVertexBBuffer=m.createBuffer();n.__webglSkinIndicesBuffer=m.createBuffer();n.__webglSkinWeightsBuffer=m.createBuffer();n.__webglFaceBuffer=m.createBuffer();n.__webglLineBuffer=m.createBuffer();if(n.numMorphTargets){o=p=void 0;n.__webglMorphTargetsBuffers=[];p=0;for(o=n.numMorphTargets;p0||w.faceVertexUvs.length>0)l.__uvArray=new Float32Array(n*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)l.__uv2Array=new Float32Array(n*2)}if(o.geometry.skinWeights.length&&o.geometry.skinIndices.length)l.__skinVertexAArray=new Float32Array(n*4),l.__skinVertexBArray=new Float32Array(n* 4),l.__skinIndexArray=new Float32Array(n*4),l.__skinWeightArray=new Float32Array(n*4);l.__faceArray=new Uint16Array(v*3);l.__lineArray=new Uint16Array(u*2);if(l.numMorphTargets){l.__morphTargetsArrays=[];w=0;for(x=l.numMorphTargets;w=0;h--)f[h]===k&&f.splice(h,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&B(f.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(f=a.__webglObjects.length;e0&&(m.bindBuffer(m.ARRAY_BUFFER,o.__webglColorBuffer),m.bufferData(m.ARRAY_BUFFER,da,v));Fa&&(m.bindBuffer(m.ARRAY_BUFFER,o.__webglNormalBuffer),m.bufferData(m.ARRAY_BUFFER,ya,v));xa&&sa.hasTangents&&(m.bindBuffer(m.ARRAY_BUFFER,o.__webglTangentBuffer),m.bufferData(m.ARRAY_BUFFER,aa, v));za&&qa>0&&(m.bindBuffer(m.ARRAY_BUFFER,o.__webglUVBuffer),m.bufferData(m.ARRAY_BUFFER,ia,v));za&&Y>0&&(m.bindBuffer(m.ARRAY_BUFFER,o.__webglUV2Buffer),m.bufferData(m.ARRAY_BUFFER,ua,v));Ea&&(m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,o.__webglFaceBuffer),m.bufferData(m.ELEMENT_ARRAY_BUFFER,Ca,v),m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,o.__webglLineBuffer),m.bufferData(m.ELEMENT_ARRAY_BUFFER,va,v));Q>0&&(m.bindBuffer(m.ARRAY_BUFFER,o.__webglSkinVertexABuffer),m.bufferData(m.ARRAY_BUFFER,ga,v),m.bindBuffer(m.ARRAY_BUFFER, o.__webglSkinVertexBBuffer),m.bufferData(m.ARRAY_BUFFER,ea,v),m.bindBuffer(m.ARRAY_BUFFER,o.__webglSkinIndicesBuffer),m.bufferData(m.ARRAY_BUFFER,Z,v),m.bindBuffer(m.ARRAY_BUFFER,o.__webglSkinWeightsBuffer),m.bufferData(m.ARRAY_BUFFER,ca,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.__dirtyColors=!1;k.__dirtyTangents=!1;l.attributes&&C(l)}else if(h instanceof THREE.Ribbon){if(k.__dirtyVertices||k.__dirtyColors){h=k;l=m.DYNAMIC_DRAW;n=G=u=u=void 0;w=h.vertices;p=h.colors;t=w.length;o=p.length;y=h.__vertexArray;v=h.__colorArray;ma=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,n=a.faces,p=h.faces,u=a.faceVertexUvs[0],t=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):p[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,n;k<=l;)if(e=Math.floor(k+(l-k)/2),n=c[e]-h,n<0)k=e+1;else if(n>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,y=k.y):(k=this.actions[e-1].args,o=k[k.length-2],y=k[k.length-1]);for(k=1;k<=a;k++)x=k/a,h=THREE.Shape.Utils.b2(x,o,t,l),x=THREE.Shape.Utils.b2(x,y,v, n),c.push(new THREE.Vector2(h,x));break;case THREE.PathActions.BEZIER_CURVE_TO:l=h[4];n=h[5];t=h[0];v=h[1];p=h[2];u=h[3];c.length>0?(k=c[c.length-1],o=k.x,y=k.y):(k=this.actions[e-1].args,o=k[k.length-2],y=k[k.length-1]);for(k=1;k<=a;k++)x=k/a,h=THREE.Shape.Utils.b3(x,o,t,p,l),x=THREE.Shape.Utils.b3(x,y,v,u,n),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];n=h[1];p=h[2];t=h[3];x=h[4];v=!!h[5];u=k[k.length-2];o=k[k.length-1];k.length==0&&(u=o=0);y=x-t;var w=a*2;for(k=1;k<=w;k++)x=k/w,v||(x=1-x),x=t+x*y,h=u+l+p*Math.cos(x),x=o+n+p*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,n,p,u,t;l=0;for(n=k.length;l=0?l-1:c.length-1;h=k-1>=0?k-1:p.length-1;var x=[p[k],c[l],c[f]];t=THREE.FontUtils.Triangulate.area(x);var w=[p[k],p[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+=p.length);k%=p.length;f=l-1>=0?l-1:c.length-1;h=k-1>=0?k-1:p.length-1;x=[p[k],c[l],c[f]];x=THREE.FontUtils.Triangulate.area(x);w=[p[k],p[h],c[l]];w=THREE.FontUtils.Triangulate.area(w);t+v>x+w&&(l=o,k=u,l<0&&(l+=c.length),l%=c.length,k<0&&(k+=p.length),k%=p.length,f=l-1>=0?l-1:c.length-1,h=k-1>=0?k-1:p.length-1);t=c.slice(0,l);v=c.slice(l);o=p.slice(k);u=p.slice(0,k);h=[p[k],p[h],c[l]];y.push([p[k],c[l],c[f]]);y.push(h);c=t.concat(o).concat(u).concat(v)}return{shape:c, isolatedPts:y,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,n,p={};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][p]===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]];n=a[c[2]];p=a[c[3]];c=f*f;k=f*c;e[0]=this.interpolate(h[0],l[0],n[0],p[0],f,c,k);e[1]=this.interpolate(h[1],l[1],n[1],p[1],f,c,k);e[2]=this.interpolate(h[2],l[2],n[2],p[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,A=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,n=0,p=0,u=0,t=0,v=0,o=window.innerWidth/2,y=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var b=a*this.lookSpeed; this.rotateHorizontally(b*t);this.rotateVertically(b*v)}b=a*this.movementSpeed;this.object.translateZ(-b*(n>0||this.autoForward&&!(n<0)?1:n));this.object.translateX(b*p);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+(p.y-n.y)*this.zoomSpeed;a!==1&&a>0&&(h.multiplyScalar(a),this.staticMoving?n=p:n.y+=(p.y-n.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=t.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=t:u.addSelf(a.sub(t,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;){ja=H;ca=H-1;ca<0&&(ca=a.length- 1);for(var c=0,b=o+u*2,c=0;c=0;L--){T=L/u;S=n*(1-T);T=p*Math.sin(T*Math.PI/2);H=0;for(P=z.length;H0||(u=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,l,v)))-1);p.push(u)}b.push(p)}for(var o,y,x,f=b.length,c=0;c0)for(e=0;e1&&(o= this.vertices[k].position.clone(),y=this.vertices[n].position.clone(),x=this.vertices[p].position.clone(),o.normalize(),y.normalize(),x.normalize(),this.faces.push(new THREE.Face3(k,n,p,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([u,t,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(p=0;p2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return l;return h}n=p;f<=n&&(n=0);p=n+1;f<=p&&(p=0);u=p+1;f<=u&&(u=0);var v;a:{v=a;var o=n,y=p,x=u,w=f,A=k,z=void 0,C=void 0,B=void 0, K=void 0,F=void 0,M=void 0,E=void 0,O=void 0,V=void 0,C=v[A[o]].x,B=v[A[o]].y,K=v[A[y]].x,F=v[A[y]].y,M=v[A[x]].x,E=v[A[x]].y;if(1.0E-10>(K-C)*(E-B)-(F-B)*(M-C))v=!1;else{for(z=0;z=0&&L>=0&&S>=0){v=!1; break a}}v=!0}}if(v){h.push([a[k[n]],a[k[p]],a[k[u]]]);l.push([k[n],k[p],k[u]]);n=p;for(u=p+1;u0;)this.smooth(a)}; THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,c,b,e,l,n){var o=new THREE.Face4(a,c,b,e,null,l.color,l.material);if(k.useOldVertexColors){o.vertexColors=[];for(var m,p,u,v=0;v<4;v++){u=n[v];m=new THREE.Color;m.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 n(a,c){var b=u(a,c);return(u(a,c+1)<<8)+b}function p(a,c){var b=u(a,c);return b>127?b-256:b}function u(a,c){return a.charCodeAt(c)&255}function t(c){var b, e,h;b=f(a,c);e=f(a,c+F);h=f(a,c+M);c=n(a,c+E);A.faces.push(new THREE.Face3(b,e,h,null,null,c))}function v(c){var b,e,h,k,m,o,p;b=f(a,c);e=f(a,c+F);h=f(a,c+M);k=n(a,c+E);m=f(a,c+O);o=f(a,c+V);p=f(a,c+H);var c=B[o*3],t=B[o*3+1];o=B[o*3+2];var u=B[p*3],v=B[p*3+1];p=B[p*3+2];A.faces.push(new THREE.Face3(b,e,h,[new THREE.Vector3(B[m*3],B[m*3+1],B[m*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+P);h=f(a,c+L);k=f(a,c+T);c=n(a,c+S);A.faces.push(new THREE.Face4(b, e,h,k,null,null,c))}function y(c){var b,e,h,k,o,p,t,u,v;b=f(a,c);e=f(a,c+P);h=f(a,c+L);k=f(a,c+T);o=n(a,c+S);p=f(a,c+m);t=f(a,c+aa);u=f(a,c+U);v=f(a,c+ea);var c=B[t*3],w=B[t*3+1];t=B[t*3+2];var G=B[u*3],x=B[u*3+1];u=B[u*3+2];var ma=B[v*3],I=B[v*3+1];v=B[v*3+2];A.faces.push(new THREE.Face4(b,e,h,k,[new THREE.Vector3(B[p*3],B[p*3+1],B[p*3+2]),new THREE.Vector3(c,w,t),new THREE.Vector3(G,x,u),new THREE.Vector3(ma,I,v)],null,o))}function x(c){var b,e,h,k;b=f(a,c);e=f(a,c+da);h=f(a,c+ia);c=K[b*2];k=K[b* 2+1];b=K[e*2];var m=A.faceVertexUvs[0];e=K[e*2+1];var n=K[h*2];h=K[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+ha);h=f(a,c+ja);k=f(a,c+ca);c=K[b*2];m=K[b*2+1];b=K[e*2];n=K[e*2+1];e=K[h*2];var o=A.faceVertexUvs[0];h=K[h*2+1];var p=K[k*2];k=K[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 A=this,z=0,C,B=[],K= [],F,M,E,O,V,H,P,L,T,S,m,aa,U,ea,da,ia,ha,ja,ca,Z,R,Y,X,ga,oa;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(A,e,c);C={signature:a.substr(z,8),header_bytes:u(a,z+8),vertex_coordinate_bytes:u(a,z+9),normal_coordinate_bytes:u(a,z+10),uv_coordinate_bytes:u(a,z+11),vertex_index_bytes:u(a,z+12),normal_index_bytes:u(a,z+13),uv_index_bytes:u(a,z+14),material_index_bytes:u(a,z+15),nvertices:f(a,z+16),nnormals:f(a,z+16+4),nuvs:f(a,z+16+8),ntri_flat:f(a,z+16+12),ntri_smooth:f(a,z+16+16),ntri_flat_uv:f(a, z+16+20),ntri_smooth_uv:f(a,z+16+24),nquad_flat:f(a,z+16+28),nquad_smooth:f(a,z+16+32),nquad_flat_uv:f(a,z+16+36),nquad_smooth_uv:f(a,z+16+40)};z+=C.header_bytes;F=C.vertex_index_bytes;M=C.vertex_index_bytes*2;E=C.vertex_index_bytes*3;O=C.vertex_index_bytes*3+C.material_index_bytes;V=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;H=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;P=C.vertex_index_bytes;L=C.vertex_index_bytes*2;T=C.vertex_index_bytes*3;S=C.vertex_index_bytes* 4;m=C.vertex_index_bytes*4+C.material_index_bytes;aa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;U=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;ea=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;da=C.uv_index_bytes;ia=C.uv_index_bytes*2;ha=C.uv_index_bytes;ja=C.uv_index_bytes*2;ca=C.uv_index_bytes*3;c=C.vertex_index_bytes*3+C.material_index_bytes;oa=C.vertex_index_bytes*4+C.material_index_bytes;Z=C.ntri_flat*c;R=C.ntri_smooth*(c+ C.normal_index_bytes*3);Y=C.ntri_flat_uv*(c+C.uv_index_bytes*3);X=C.ntri_smooth_uv*(c+C.normal_index_bytes*3+C.uv_index_bytes*3);ga=C.nquad_flat*oa;c=C.nquad_smooth*(oa+C.normal_index_bytes*4);oa=C.nquad_flat_uv*(oa+C.uv_index_bytes*4);z+=function(c){for(var e,h,f,l=C.vertex_coordinate_bytes*3,m=c+C.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){p=n.output[m];break}k=p!==void 0?p instanceof THREE.Matrix4? k.multiply(k,p):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};t.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[b.nodeName]=parseFloat(e[0].textContent))}}this.create();return this};V.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 O)if(e.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(e=na[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(Ea+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=xa;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&&(V=new THREE.MeshFaceMaterial);object=new THREE.Mesh(F,V);object.name=o;object.position.set(C[0],C[1],C[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=z.visible;U.scene.add(object);U.objects[o]=object;z.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),U.scene.collisions.colliders.push(a));if(z.castsShadow)a= new THREE.ShadowVolume(F),U.scene.add(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;z.trigger&&z.trigger.toLowerCase()!="none"&&(a={type:z.trigger,object:z},U.triggers[object.name]=a)}}else C=z.position,r=z.rotation,q=z.quaternion,s=z.scale,q=0,object=new THREE.Object3D,object.name=o,object.position.set(C[0],C[1],C[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= z.visible!==void 0?z.visible:!1,U.scene.add(object),U.objects[o]=object,U.empties[o]=object,z.trigger&&z.trigger.toLowerCase()!="none"&&(a={type:z.trigger,object:z},U.triggers[object.name]=a)}function n(a){return function(b){U.geometries[a]=b;l();T-=1;c.onLoadComplete();u()}}function p(a){return function(c){U.geometries[a]=c}}function u(){c.callbackProgress({totalModels:m,totalTextures:aa,loadedModels:m-T,loadedTextures:aa-S},U);c.onLoadProgress();T==0&&S==0&&b(U)}var t,v,o,y,x,w,A,z,C,B,K,F,M,E, O,V,H,P,L,T,S,m,aa,U;P=a.data;O=new THREE.BinaryLoader;L=new THREE.JSONLoader;S=T=0;U={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(o in P.objects)if(z=P.objects[o],z.meshCollider){a=!0;break}if(a)U.scene.collisions=new THREE.CollisionSystem;if(P.transform){a=P.transform.position;B=P.transform.rotation;var ea=P.transform.scale;a&&U.scene.position.set(a[0],a[1],a[2]);B&&U.scene.rotation.set(B[0],B[1],B[2]);ea&& U.scene.scale.set(ea[0],ea[1],ea[2]);(a||B||ea)&&U.scene.updateMatrix()}a=function(){S-=1;u();c.onLoadComplete()};for(x in P.cameras)B=P.cameras[x],B.type=="perspective"?M=new THREE.PerspectiveCamera(B.fov,B.aspect,B.near,B.far):B.type=="ortho"&&(M=new THREE.OrthographicCamera(B.left,B.right,B.top,B.bottom,B.near,B.far)),C=B.position,B=B.target,M.position.set(C[0],C[1],C[2]),M.target=new THREE.Vector3(B[0],B[1],B[2]),U.cameras[x]=M;for(y in P.lights)x=P.lights[y],M=x.color!==void 0?x.color:16777215, B=x.intensity!==void 0?x.intensity:1,x.type=="directional"?(C=x.direction,H=new THREE.DirectionalLight(M,B),H.position.set(C[0],C[1],C[2]),H.position.normalize()):x.type=="point"?(C=x.position,d=x.distance,H=new THREE.PointLight(M,B,d),H.position.set(C[0],C[1],C[2])):x.type=="ambient"&&(H=new THREE.AmbientLight(M)),U.scene.add(H),U.lights[y]=H;for(w in P.fogs)y=P.fogs[w],y.type=="linear"?E=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(E=new THREE.FogExp2(0,y.density)),B=y.color,E.color.setRGB(B[0], B[1],B[2]),U.fogs[w]=E;if(U.cameras&&P.defaults.camera)U.currentCamera=U.cameras[P.defaults.camera];if(U.fogs&&P.defaults.fog)U.scene.fog=U.fogs[P.defaults.fog];B=P.defaults.bgcolor;U.bgColor=new THREE.Color;U.bgColor.setRGB(B[0],B[1],B[2]);U.bgColorAlpha=P.defaults.bgalpha;for(t in P.geometries)if(w=P.geometries[t],w.type=="bin_mesh"||w.type=="ascii_mesh")T+=1,c.onLoadStart();m=T;for(t in P.geometries)w=P.geometries[t],w.type=="cube"?(F=new THREE.CubeGeometry(w.width,w.height,w.depth,w.segmentsWidth, w.segmentsHeight,w.segmentsDepth,null,w.flipped,w.sides),U.geometries[t]=F):w.type=="plane"?(F=new THREE.PlaneGeometry(w.width,w.height,w.segmentsWidth,w.segmentsHeight),U.geometries[t]=F):w.type=="sphere"?(F=new THREE.SphereGeometry(w.radius,w.segmentsWidth,w.segmentsHeight),U.geometries[t]=F):w.type=="cylinder"?(F=new THREE.CylinderGeometry(w.topRad,w.botRad,w.height,w.radSegs,w.heightSegs),U.geometries[t]=F):w.type=="torus"?(F=new THREE.TorusGeometry(w.radius,w.tube,w.segmentsR,w.segmentsT),U.geometries[t]= F):w.type=="icosahedron"?(F=new THREE.IcosahedronGeometry(w.subdivisions),U.geometries[t]=F):w.type=="bin_mesh"?O.load(e(w.url,P.urlBaseType),n(t)):w.type=="ascii_mesh"?L.load(e(w.url,P.urlBaseType),n(t)):w.type=="embedded_mesh"&&(w=P.embeds[w.id])&&L.createModel(w,p(t),"");for(A in P.textures)if(t=P.textures[A],t.url instanceof Array){S+=t.url.length;for(O=0;O=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&&(n=this.size-1);var v=Math.floor(p-l);v<1&&(v=1);p=Math.floor(p+l);p>this.size-1&&(p=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 y,x,w,A,z,C;t0&&(this.field[w+y]+=A)}}};this.addPlaneX=function(a,b){var f,h,k,l,n,p=this.size,u=this.yd,t=this.zd,v=this.field,o=p*Math.sqrt(a/b);o>p&&(o=p);for(f=0;f0)for(h=0;hu&&(y=u);for(h=0;h0){n=h*t;for(f=0;fsize&&(dist=size);for(k=0;k0){n=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,n=0,p=!0;c.origin.xb.max.x&&(e=b.max.x-c.origin.x,e/=c.direction.x,p=!1,k=1);c.origin.yb.max.y&&(f=b.max.y-c.origin.y,f/=c.direction.y, p=!1,l=1);c.origin.zb.max.z&&(h=b.max.z-c.origin.z,h/=c.direction.z,p=!1,n=1);if(p)return-1;p=0;f>e&&(p=1,e=f);h>e&&(p=2,e=h);switch(p){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,n)}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,n,p,u;f.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},t=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:t},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 y=new THREE.Scene;y.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){c.call(b,a,e);t.width=a;t.height=e;v.width=a;v.height=e};this.render=function(a,c){c.update(null,!0);if(n!==c.aspect||p!==c.near||u!==c.fov){n=c.aspect;p=c.near;u=c.fov;var A=c.projectionMatrix.clone(),z=125/30*0.5,C=z*p/125,B=p*Math.tan(u*Math.PI/360),K;k.n14=z;l.n14=-z;z=-B*n+C;K=B*n+C;A.n11=2*p/(K-z);A.n13=(K+z)/(K-z);f.projectionMatrix=A.clone();z=-B*n-C;K=B*n-C;A.n11=2*p/(K-z);A.n13= (K+z)/(K-z);h.projectionMatrix=A.clone()}f.matrix=c.matrixWorld.clone().multiplySelf(l);f.update(null,!0);f.position.copy(c.position);f.near=p;f.far=c.far;e.call(b,a,f,t,!0);h.matrix=c.matrixWorld.clone().multiplySelf(k);h.update(null,!0);h.position.copy(c.position);h.near=p;h.far=c.far;e.call(b,a,h,v,!0);e.call(b,y,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)}};