// 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 c=Date.now(),a=0.0010*(c-this.oldTime);this.oldTime=c;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,c,b){this.r=a;this.g=c;this.b=b;return this},setHSV:function(a,c,b){var e,k,h;if(b===0)this.r=this.g=this.b=0;else switch(e=Math.floor(a*6),k=a*6-e,a=b*(1-c),h=b*(1- c*k),c=b*(1-c*(1-k)),e){case 1:this.r=h;this.g=b;this.b=a;break;case 2:this.r=a;this.g=b;this.b=c;break;case 3:this.r=a;this.g=h;this.b=b;break;case 4:this.r=c;this.g=a;this.b=b;break;case 5:this.r=b;this.g=a;this.b=h;break;case 6:case 0:this.r=b,this.g=c,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,c){this.x=a||0;this.y=c||0}; THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.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 c=this.x-a.x,a=this.y-a.y;return c*c+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,c,b){this.x=a||0;this.y=c||0;this.z=b||0}; THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,c,b){this.x=a;this.y=c;this.z=b;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.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 c=Math.cos(this.y);this.y=Math.asin(a.n13); Math.abs(c)>1.0E-5?(this.x=Math.atan2(-a.n23/c,a.n33/c),this.z=Math.atan2(-a.n12/c,a.n11/c)):(this.x=0,this.z=Math.atan2(a.n21,a.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(a,c,b,e){this.x=a||0;this.y=c||0;this.z=b||0;this.w=e!==void 0?e:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,c,b,e){this.x=a;this.y=c;this.z=b;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z- c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c;return this}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.children)},intersectObjects:function(a){var c,b,e=[];c=0;for(b=a.length;c0&&a>0&&f+a<1}for(var e,k=[],h=0,f=a.children.length;ha.scale.x)return[];e={distance:h,point:a.position,face:null,object:a};k.push(e)}else if(a instanceof THREE.Mesh){h= c(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 k;var l,n,p,t,u,w,v,z,x=a.geometry,y=x.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);h=0;for(f=x.faces.length;h0:w<0)))if(w=u.dot((new THREE.Vector3).sub(l,v))/w,v=v.addSelf(z.multiplyScalar(w)),e instanceof THREE.Face3)b(v,l,n,p)&&(e={distance:this.origin.distanceTo(v),point:v,face:e,object:a},k.push(e));else if(e instanceof THREE.Face4&&(b(v,l,n,t)||b(v,n,p,t)))e={distance:this.origin.distanceTo(v), point:v,face:e,object:a},k.push(e)}return k}}; THREE.Rectangle=function(){function a(){h=e-c;f=k-b}var c,b,e,k,h,f,l=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return e};this.getBottom=function(){return k};this.set=function(f,h,t,u){l=!1;c=f;b=h;e=t;k=u;a()};this.addPoint=function(f,h){l?(l=!1,c=f,b=h,e=f,k=h):(c=cf?e:f,k=k>h?k:h);a()};this.add3Points= function(f,h,t,u,w,v){l?(l=!1,c=ft?f>w?f:w:t>w?t:w,k=h>u?h>v?h:v:u>v?u:v):(c=ft?f>w?f>e?f:e:w>e?w:e:t>w?t>e?t:e:w>e?w:e,k=h>u?h>v?h>k?h:k:v>k?v:k:u>v?u>k?u:k:v>k?v:k);a()};this.addRectangle=function(f){l?(l=!1,c=f.getLeft(),b=f.getTop(),e=f.getRight(),k=f.getBottom()):(c=cf.getRight()?e:f.getRight(),k=k> f.getBottom()?k:f.getBottom());a()};this.inflate=function(f){c-=f;b-=f;e+=f;k+=f;a()};this.minSelf=function(f){c=c>f.getLeft()?c:f.getLeft();b=b>f.getTop()?b:f.getTop();e=e=0&&Math.min(k,a.getBottom())-Math.max(b,a.getTop())>=0};this.empty=function(){l=!0;k=e=b=c=0;a()};this.isEmpty=function(){return l}}; THREE.Math={clamp:function(a,c,b){return ab?b:a},clampBottom:function(a,c){return a=0&&k>=0&&h>=0&&l>=0?!0:f<0&&k<0||h<0&&l<0?!1:(f<0?c=Math.max(c,f/(f-k)):k<0&&(e=Math.min(e,f/(f-k))),h<0?c=Math.max(c,h/(h-l)):l<0&&(e=Math.min(e,h/(h-l))),eN&&e.positionScreen.z0&&B.z<1))N=y[x]=y[x]||new THREE.RenderableParticle,x++,z=N,z.x=B.x/B.w,z.y=B.y/B.w,z.z=B.z,z.rotation= J.rotation.z,z.scale.x=J.scale.x*Math.abs(z.x-(B.x+K.projectionMatrix.n11)/(B.w+K.projectionMatrix.n14)),z.scale.y=J.scale.y*Math.abs(z.y-(B.y+K.projectionMatrix.n22)/(B.w+K.projectionMatrix.n24)),z.material=J.material,D.elements.push(z);W&&D.elements.sort(c);return D}};THREE.Quaternion=function(a,c,b,e){this.set(a||0,c||0,b||0,e!==void 0?e:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,c,b,e){this.x=a;this.y=c;this.z=b;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 c=Math.PI/360,b=a.x*c,e=a.y*c,k=a.z*c,a=Math.cos(e),e=Math.sin(e),c=Math.cos(-k),k=Math.sin(-k),h=Math.cos(b),b=Math.sin(b),f=a*c,l=e*k;this.w=f*h-l*b;this.x=f*b+l*h;this.y=e*c*h+a*k*b;this.z=a*k*h-e*c*b;return this},setFromAxisAngle:function(a,c){var b=c/2,e=Math.sin(b); this.x=a.x*e;this.y=a.y*e;this.z=a.z*e;this.w=Math.cos(b);return this},setFromRotationMatrix:function(a){var c=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,c+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,c-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,c-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 c= this.x,b=this.y,e=this.z,k=this.w,h=a.x,f=a.y,l=a.z,a=a.w;this.x=c*a+k*h+b*l-e*f;this.y=b*a+k*f+e*h-c*l;this.z=e*a+k*l+c*f-b*h;this.w=k*a-c*h-b*f-e*l;return this},multiply:function(a,c){this.x=a.x*c.w+a.y*c.z-a.z*c.y+a.w*c.x;this.y=-a.x*c.z+a.y*c.w+a.z*c.x+a.w*c.y;this.z=a.x*c.y-a.y*c.x+a.z*c.w+a.w*c.z;this.w=-a.x*c.x-a.y*c.y-a.z*c.z+a.w*c.w;return this},multiplyVector3:function(a,c){c||(c=a);var b=a.x,e=a.y,k=a.z,h=this.x,f=this.y,l=this.z,n=this.w,p=n*b+f*k-l*e,t=n*e+l*b-h*k,u=n*k+h*e-f*b,b=-h* b-f*e-l*k;c.x=p*n+b*-h+t*-l-u*-f;c.y=t*n+b*-f+u*-h-p*-l;c.z=u*n+b*-l+p*-f-t*-h;return c}}; THREE.Quaternion.slerp=function(a,c,b,e){var k=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;k<0?(b.w=-c.w,b.x=-c.x,b.y=-c.y,b.z=-c.z,k=-k):b.copy(c);if(Math.abs(k)>=1)return b.w=a.w,b.x=a.x,b.y=a.y,b.z=a.z,b;var h=Math.acos(k),k=Math.sqrt(1-k*k);if(Math.abs(k)<0.0010)return b.w=0.5*(a.w+c.w),b.x=0.5*(a.x+c.x),b.y=0.5*(a.y+c.y),b.z=0.5*(a.z+c.z),b;c=Math.sin((1-e)*h)/k;e=Math.sin(e*h)/k;b.w=a.w*c+b.w*e;b.x=a.x*c+b.x*e;b.y=a.y*c+b.y*e;b.z=a.z*c+b.z*e;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,c,b,e,k,h){this.a=a;this.b=c;this.c=b;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=k instanceof THREE.Color?k:new THREE.Color;this.vertexColors=k instanceof Array?k:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,c,b,e,k,h,f){this.a=a;this.b=c;this.c=b;this.d=e;this.normal=k instanceof THREE.Vector3?k:new THREE.Vector3;this.vertexNormals=k instanceof Array?k:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.u=a||0;this.v=c||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,c){this.u=a;this.v=c;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 c=new THREE.Matrix4;c.extractRotation(a,new THREE.Vector3(1,1,1));for(var b=0,e=this.vertices.length;b0){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 c=1,b=this.vertices.length;cthis.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,c=0,b=this.vertices.length;cthis.points.length-2?h:h+1;b[3]=h>this.points.length-3?h:h+2;p=this.points[b[0]];t=this.points[b[1]]; u=this.points[b[2]];w=this.points[b[3]];l=f*f;n=f*l;e.x=c(p.x,t.x,u.x,w.x,f,l,n);e.y=c(p.y,t.y,u.y,w.y,f,l,n);e.z=c(p.z,t.z,u.z,w.z,f,l,n);return e};this.getControlPointsArray=function(){var a,b,c=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/c),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;c=this.time%c/c;this.directionBackwards&&(c=1-c);this.morphTargetInfluences[this.currentKeyframe]=c;this.morphTargetInfluences[this.lastKeyframe]=1-c};THREE.Ribbon=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.material=c};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,c){c===void 0&&(c=0);for(var c=Math.abs(c),b=0;b1){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.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 c=1;c=this.LODs[c].visibleAtDistance)this.LODs[c-1].object3D.visible=!1,this.LODs[c].object3D.visible=!0;else break;for(;c0&&(b(THREE.NormalBlending),c(1),k("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b*255)+","+D+")"),x.fillRect(Math.floor(ia.getX()), Math.floor(ia.getY()),Math.floor(ia.getWidth()),Math.floor(ia.getHeight()))),ia.empty())};this.render=function(a,t){function u(a){var b,c,e,f;sa.setRGB(0,0,0);va.setRGB(0,0,0);ua.setRGB(0,0,0);b=0;for(c=a.length;b> 1,u=p.height>>1,h=f.scale.x*v,n=f.scale.y*z,o=h*t,l=n*u,H.set(a.x-o,a.y-l,a.x+o,a.y+l),fa.intersects(H)&&(x.save(),x.translate(a.x,a.y),x.rotate(-f.rotation),x.scale(h,-n),x.translate(-t,-u),x.drawImage(p,0,0),x.restore())}else h instanceof THREE.ParticleCanvasMaterial&&(o=f.scale.x*v,l=f.scale.y*z,H.set(a.x-o,a.y-l,a.x+o,a.y+l),fa.intersects(H)&&(e(h.color.getContextStyle()),k(h.color.getContextStyle()),x.save(),x.translate(a.x,a.y),x.rotate(-f.rotation),x.scale(o,l),h.program(x),x.restore()))}function ab(a, f,h,k){c(k.opacity);b(k.blending);x.beginPath();x.moveTo(a.positionScreen.x,a.positionScreen.y);x.lineTo(f.positionScreen.x,f.positionScreen.y);x.closePath();if(k instanceof THREE.LineBasicMaterial){a=k.linewidth;if(G!=a)x.lineWidth=G=a;a=k.linecap;if(M!=a)x.lineCap=M=a;a=k.linejoin;if(V!=a)x.lineJoin=V=a;e(k.color.getContextStyle());x.stroke();H.inflate(k.linewidth*2)}}function A(a,e,f,k,l,p,v,u){h.info.render.vertices+=3;h.info.render.faces++;c(u.opacity);b(u.blending);P=a.positionScreen.x;o=a.positionScreen.y; U=e.positionScreen.x;Q=e.positionScreen.y;aa=f.positionScreen.x;T=f.positionScreen.y;D(P,o,U,Q,aa,T);if(u instanceof THREE.MeshBasicMaterial)if(u.map)u.map.mapping instanceof THREE.UVMapping&&(ta=v.uvs[0],Wa(P,o,U,Q,aa,T,ta[k].u,ta[k].v,ta[l].u,ta[l].v,ta[p].u,ta[p].v,u.map));else if(u.envMap){if(u.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=t.matrixWorldInverse,wa.copy(v.vertexNormalsWorld[k]),Da=(wa.x*a.n11+wa.y*a.n12+wa.z*a.n13)*0.5+0.5,Ea=-(wa.x*a.n21+wa.y*a.n22+wa.z*a.n23)*0.5+ 0.5,wa.copy(v.vertexNormalsWorld[l]),Ca=(wa.x*a.n11+wa.y*a.n12+wa.z*a.n13)*0.5+0.5,Fa=-(wa.x*a.n21+wa.y*a.n22+wa.z*a.n23)*0.5+0.5,wa.copy(v.vertexNormalsWorld[p]),za=(wa.x*a.n11+wa.y*a.n12+wa.z*a.n13)*0.5+0.5,F=-(wa.x*a.n21+wa.y*a.n22+wa.z*a.n23)*0.5+0.5,Wa(P,o,U,Q,aa,T,Da,Ea,Ca,Fa,za,F,u.envMap)}else u.wireframe?L(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(u.color);else if(u instanceof THREE.MeshLambertMaterial)u.map&&!u.wireframe&&(u.map.mapping instanceof THREE.UVMapping&& (ta=v.uvs[0],Wa(P,o,U,Q,aa,T,ta[k].u,ta[k].v,ta[l].u,ta[l].v,ta[p].u,ta[p].v,u.map)),b(THREE.SubtractiveBlending)),da?!u.wireframe&&u.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==3?(ea.r=ca.r=$.r=sa.r,ea.g=ca.g=$.g=sa.g,ea.b=ca.b=$.b=sa.b,w(n,v.v1.positionWorld,v.vertexNormalsWorld[0],ea),w(n,v.v2.positionWorld,v.vertexNormalsWorld[1],ca),w(n,v.v3.positionWorld,v.vertexNormalsWorld[2],$),ea.r=Math.max(0,Math.min(u.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(u.color.g*ea.g,1)),ea.b=Math.max(0, Math.min(u.color.b*ea.b,1)),ca.r=Math.max(0,Math.min(u.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(u.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(u.color.b*ca.b,1)),$.r=Math.max(0,Math.min(u.color.r*$.r,1)),$.g=Math.max(0,Math.min(u.color.g*$.g,1)),$.b=Math.max(0,Math.min(u.color.b*$.b,1)),ga.r=(ca.r+$.r)*0.5,ga.g=(ca.g+$.g)*0.5,ga.b=(ca.b+$.b)*0.5,ka=Ua(ea,ca,$,ga),Sa(P,o,U,Q,aa,T,0,0,1,0,0,1,ka)):(la.r=sa.r,la.g=sa.g,la.b=sa.b,w(n,v.centroidWorld,v.normalWorld,la),la.r=Math.max(0,Math.min(u.color.r* la.r,1)),la.g=Math.max(0,Math.min(u.color.g*la.g,1)),la.b=Math.max(0,Math.min(u.color.b*la.b,1)),u.wireframe?L(la,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(la)):u.wireframe?L(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(u.color);else if(u instanceof THREE.MeshDepthMaterial)oa=t.near,ma=t.far,ea.r=ea.g=ea.b=1-Oa(a.positionScreen.z,oa,ma),ca.r=ca.g=ca.b=1-Oa(e.positionScreen.z,oa,ma),$.r=$.g=$.b=1-Oa(f.positionScreen.z,oa,ma),ga.r=(ca.r+$.r)*0.5,ga.g= (ca.g+$.g)*0.5,ga.b=(ca.b+$.b)*0.5,ka=Ua(ea,ca,$,ga),Sa(P,o,U,Q,aa,T,0,0,1,0,0,1,ka);else if(u instanceof THREE.MeshNormalMaterial)la.r=Ta(v.normalWorld.x),la.g=Ta(v.normalWorld.y),la.b=Ta(v.normalWorld.z),u.wireframe?L(la,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(la)}function B(a,e,f,k,l,p,u,v,xa){h.info.render.vertices+=4;h.info.render.faces++;c(v.opacity);b(v.blending);if(v.map||v.envMap)A(a,e,k,0,1,3,u,v,xa),A(l,f,p,1,2,3,u,v,xa);else if(P=a.positionScreen.x,o=a.positionScreen.y, U=e.positionScreen.x,Q=e.positionScreen.y,aa=f.positionScreen.x,T=f.positionScreen.y,J=k.positionScreen.x,ra=k.positionScreen.y,pa=l.positionScreen.x,na=l.positionScreen.y,qa=p.positionScreen.x,ja=p.positionScreen.y,v instanceof THREE.MeshBasicMaterial)C(P,o,U,Q,aa,T,J,ra),v.wireframe?L(v.color,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Ma(v.color);else if(v instanceof THREE.MeshLambertMaterial)da?!v.wireframe&&v.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==4?(ea.r= ca.r=$.r=ga.r=sa.r,ea.g=ca.g=$.g=ga.g=sa.g,ea.b=ca.b=$.b=ga.b=sa.b,w(n,u.v1.positionWorld,u.vertexNormalsWorld[0],ea),w(n,u.v2.positionWorld,u.vertexNormalsWorld[1],ca),w(n,u.v4.positionWorld,u.vertexNormalsWorld[3],$),w(n,u.v3.positionWorld,u.vertexNormalsWorld[2],ga),ea.r=Math.max(0,Math.min(v.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(v.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(v.color.b*ea.b,1)),ca.r=Math.max(0,Math.min(v.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(v.color.g*ca.g,1)),ca.b=Math.max(0, Math.min(v.color.b*ca.b,1)),$.r=Math.max(0,Math.min(v.color.r*$.r,1)),$.g=Math.max(0,Math.min(v.color.g*$.g,1)),$.b=Math.max(0,Math.min(v.color.b*$.b,1)),ga.r=Math.max(0,Math.min(v.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(v.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(v.color.b*ga.b,1)),ka=Ua(ea,ca,$,ga),D(P,o,U,Q,J,ra),Sa(P,o,U,Q,J,ra,0,0,1,0,0,1,ka),D(pa,na,aa,T,qa,ja),Sa(pa,na,aa,T,qa,ja,1,0,1,1,0,1,ka)):(la.r=sa.r,la.g=sa.g,la.b=sa.b,w(n,u.centroidWorld,u.normalWorld,la),la.r=Math.max(0,Math.min(v.color.r* la.r,1)),la.g=Math.max(0,Math.min(v.color.g*la.g,1)),la.b=Math.max(0,Math.min(v.color.b*la.b,1)),C(P,o,U,Q,aa,T,J,ra),v.wireframe?L(la,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Ma(la)):(C(P,o,U,Q,aa,T,J,ra),v.wireframe?L(v.color,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Ma(v.color));else if(v instanceof THREE.MeshNormalMaterial)la.r=Ta(u.normalWorld.x),la.g=Ta(u.normalWorld.y),la.b=Ta(u.normalWorld.z),C(P,o,U,Q,aa,T,J,ra),v.wireframe?L(la,v.wireframeLinewidth, v.wireframeLinecap,v.wireframeLinejoin):Ma(la);else if(v instanceof THREE.MeshDepthMaterial)oa=t.near,ma=t.far,ea.r=ea.g=ea.b=1-Oa(a.positionScreen.z,oa,ma),ca.r=ca.g=ca.b=1-Oa(e.positionScreen.z,oa,ma),$.r=$.g=$.b=1-Oa(k.positionScreen.z,oa,ma),ga.r=ga.g=ga.b=1-Oa(f.positionScreen.z,oa,ma),ka=Ua(ea,ca,$,ga),D(P,o,U,Q,J,ra),Sa(P,o,U,Q,J,ra,0,0,1,0,0,1,ka),D(pa,na,aa,T,qa,ja),Sa(pa,na,aa,T,qa,ja,1,0,1,1,0,1,ka)}function D(a,b,c,e,f,k){x.beginPath();x.moveTo(a,b);x.lineTo(c,e);x.lineTo(f,k);x.lineTo(a, b);x.closePath()}function C(a,b,c,e,f,k,h,o){x.beginPath();x.moveTo(a,b);x.lineTo(c,e);x.lineTo(f,k);x.lineTo(h,o);x.lineTo(a,b);x.closePath()}function L(a,b,c,f){if(G!=b)x.lineWidth=G=b;if(M!=c)x.lineCap=M=c;if(V!=f)x.lineJoin=V=f;e(a.getContextStyle());x.stroke();H.inflate(b*2)}function Ma(a){k(a.getContextStyle());x.fill()}function Wa(a,b,c,e,f,h,o,l,n,v,u,p,t){if(t.image.width!=0){if(t.needsUpdate==!0||ha[t.id]==void 0){var xa=t.wrapS==THREE.RepeatWrapping,w=t.wrapT==THREE.RepeatWrapping;ha[t.id]= x.createPattern(t.image,xa&&w?"repeat":xa&&!w?"repeat-x":!xa&&w?"repeat-y":"no-repeat");t.needsUpdate=!1}k(ha[t.id]);var xa=t.offset.x/t.repeat.x,w=t.offset.y/t.repeat.y,F=(t.image.width-1)*t.repeat.x,t=(t.image.height-1)*t.repeat.y,o=(o+xa)*F,l=(l+w)*t,n=(n+xa)*F,v=(v+w)*t,u=(u+xa)*F,p=(p+w)*t;c-=a;e-=b;f-=a;h-=b;n-=o;v-=l;u-=o;p-=l;xa=1/(n*p-u*v);t=(p*c-v*f)*xa;v=(p*e-v*h)*xa;c=(n*f-u*c)*xa;e=(n*h-u*e)*xa;a=a-t*o-c*l;b=b-v*o-e*l;x.save();x.transform(t,v,c,e,a,b);x.fill();x.restore()}}function Sa(a, b,c,e,f,k,h,o,l,n,v,u,p){var t,xa;t=p.width-1;xa=p.height-1;h*=t;o*=xa;l*=t;n*=xa;v*=t;u*=xa;c-=a;e-=b;f-=a;k-=b;l-=h;n-=o;v-=h;u-=o;xa=1/(l*u-v*n);t=(u*c-n*f)*xa;n=(u*e-n*k)*xa;c=(l*f-v*c)*xa;e=(l*k-v*e)*xa;a=a-t*h-c*o;b=b-n*h-e*o;x.save();x.transform(t,n,c,e,a,b);x.clip();x.drawImage(p,0,0);x.restore()}function Ua(a,b,c,e){var f=~~(a.r*255),k=~~(a.g*255),a=~~(a.b*255),h=~~(b.r*255),o=~~(b.g*255),b=~~(b.b*255),l=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),v=~~(e.r*255),u=~~(e.g*255),e=~~(e.b*255);ya[0]= f<0?0:f>255?255:f;ya[1]=k<0?0:k>255?255:k;ya[2]=a<0?0:a>255?255:a;ya[4]=h<0?0:h>255?255:h;ya[5]=o<0?0:o>255?255:o;ya[6]=b<0?0:b>255?255:b;ya[8]=l<0?0:l>255?255:l;ya[9]=n<0?0:n>255?255:n;ya[10]=c<0?0:c>255?255:c;ya[12]=v<0?0:v>255?255:v;ya[13]=u<0?0:u>255?255:u;ya[14]=e<0?0:e>255?255:e;Ba.putImageData(Ka,0,0);Ia.drawImage(Ga,0,0);return X}function Oa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ta(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Na(a,b){var c=b.x-a.x,e=b.y-a.y,f=c*c+e*e;f!=0&&(f=1/ Math.sqrt(f),c*=f,e*=f,b.x+=c,b.y+=e,a.x-=c,a.y-=e)}var Va,Xa,Aa,Ha;this.autoClear?this.clear():x.setTransform(1,0,0,-1,v,z);h.info.render.vertices=0;h.info.render.faces=0;f=p.projectScene(a,t,this.sortElements);l=f.elements;n=f.lights;(da=n.length>0)&&u(n);Va=0;for(Xa=l.length;Va1?1:a}var e=this,k,h,f,l=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,t,u,w,v,z,x,y,D=new THREE.Rectangle,B=new THREE.Rectangle,A=!1,C=new THREE.Color,L=new THREE.Color,G=new THREE.Color,M=new THREE.Color,V,K=new THREE.Vector3,W=[],N=[],O,Z,Y,P=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":P=1;break;case "low":P=0}};this.setSize=function(a,b){p=a;t=b;u=p/2;w=t/2;n.setAttribute("viewBox",-u+" "+-w+" "+p+" "+t);n.setAttribute("width",p);n.setAttribute("height",t);D.set(-u,-w,u,w)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(o,p){var t,K,T,J;this.autoClear&&this.clear();e.info.render.vertices=0;e.info.render.faces=0;k=l.projectScene(o,p,this.sortElements);h=k.elements; f=k.lights;Y=Z=0;if(A=f.length>0){L.setRGB(0,0,0);G.setRGB(0,0,0);M.setRGB(0,0,0);t=0;for(K=f.length;t 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 c,b,e,k={};for(c=0;c=0)return a.geometry.materials[b.materialIndex]}function b(a,b,c){var e,f,h,k=a.vertices,l=k.length,n=a.colors,v=n.length,u=a.__vertexArray,p=a.__colorArray,t=a.__sortArray,x=a.__dirtyVertices,w=a.__dirtyColors,F=a.__webglCustomAttributesList,y;if(F){h=0;for(e=F.length;h=0)b&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer),o.vertexAttribPointer(a.position,3,o.FLOAT,!1,0,0));else if(h.morphTargetBase){c=f.program.attributes;h.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[h.morphTargetBase]),o.vertexAttribPointer(c.position, 3,o.FLOAT,!1,0,0)):c.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0));if(h.morphTargetForcedOrder.length){l=0;var v=h.morphTargetForcedOrder;for(n=h.morphTargetInfluences;lu&&(p=t,u=n[p]);o.bindBuffer(o.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[p]);o.vertexAttribPointer(c["morphTarget"+l],3,o.FLOAT,!1,0,0);h.__webglMorphTargetInfluences[l]=u;v[p]=1;u=-1;l++}}f.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(f.program.uniforms.morphTargetInfluences,h.__webglMorphTargetInfluences)}if(b){if(k.__webglCustomAttributesList){l=0;for(n= k.__webglCustomAttributesList.length;l=0&&(o.bindBuffer(o.ARRAY_BUFFER,c.buffer),o.vertexAttribPointer(a[c.buffer.belongsToAttribute],c.size,o.FLOAT,!1,0,0))}a.color>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglColorBuffer),o.vertexAttribPointer(a.color,3,o.FLOAT,!1,0,0));a.normal>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglNormalBuffer),o.vertexAttribPointer(a.normal,3,o.FLOAT,!1,0,0));a.tangent>=0&&(o.bindBuffer(o.ARRAY_BUFFER, k.__webglTangentBuffer),o.vertexAttribPointer(a.tangent,4,o.FLOAT,!1,0,0));a.uv>=0&&(k.__webglUVBuffer?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglUVBuffer),o.vertexAttribPointer(a.uv,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(a.uv)):o.disableVertexAttribArray(a.uv));a.uv2>=0&&(k.__webglUV2Buffer?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglUV2Buffer),o.vertexAttribPointer(a.uv2,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(a.uv2)):o.disableVertexAttribArray(a.uv2));f.skinning&&a.skinVertexA>=0&&a.skinVertexB>= 0&&a.skinIndex>=0&&a.skinWeight>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinVertexABuffer),o.vertexAttribPointer(a.skinVertexA,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinVertexBBuffer),o.vertexAttribPointer(a.skinVertexB,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinIndicesBuffer),o.vertexAttribPointer(a.skinIndex,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinWeightsBuffer),o.vertexAttribPointer(a.skinWeight,4,o.FLOAT,!1,0,0))}h instanceof THREE.Mesh?(f.wireframe? (o.lineWidth(f.wireframeLinewidth),b&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,k.__webglLineBuffer),o.drawElements(o.LINES,k.__webglLineCount,o.UNSIGNED_SHORT,0)):(b&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,k.__webglFaceBuffer),o.drawElements(o.TRIANGLES,k.__webglFaceCount,o.UNSIGNED_SHORT,0)),P.info.render.calls++,P.info.render.vertices+=k.__webglFaceCount,P.info.render.faces+=k.__webglFaceCount/3):h instanceof THREE.Line?(h=h.type===THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(f.linewidth),o.drawArrays(h, 0,k.__webglLineCount),P.info.render.calls++):h instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,k.__webglParticleCount),P.info.render.calls++):h instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,0,k.__webglVertexCount),P.info.render.calls++)}}function h(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=o.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=o.createBuffer();a.hasPos&&(o.bindBuffer(o.ARRAY_BUFFER,a.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,a.positionArray, o.DYNAMIC_DRAW),o.enableVertexAttribArray(b.attributes.position),o.vertexAttribPointer(b.attributes.position,3,o.FLOAT,!1,0,0));if(a.hasNormal){o.bindBuffer(o.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var e,f,k,h,l,n,v,u,p,t,x=a.count*3;for(t=0;t=0)b=b.geometry.materials[c],b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}else if(b=e)b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function z(a,b){return b.z-a.z}function x(a){var b,c,n,v=0,p,x,w,F,y=a.lights;va||(va=new THREE.PerspectiveCamera(P.shadowCameraFov,P.shadowMapWidth/P.shadowMapHeight,P.shadowCameraNear,P.shadowCameraFar));b=0;for(c=y.length;b=0;c--)a[c].object===b&&a.splice(c,1)}function L(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})} function G(a){if(a!==qa){switch(a){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.SRC_COLOR);break;default:o.blendEquationSeparate(o.FUNC_ADD,o.FUNC_ADD),o.blendFuncSeparate(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA)}qa=a}}function M(a,b,c){(c.width&c.width- 1)===0&&(c.height&c.height-1)===0?(o.texParameteri(a,o.TEXTURE_WRAP_S,Y(b.wrapS)),o.texParameteri(a,o.TEXTURE_WRAP_T,Y(b.wrapT)),o.texParameteri(a,o.TEXTURE_MAG_FILTER,Y(b.magFilter)),o.texParameteri(a,o.TEXTURE_MIN_FILTER,Y(b.minFilter)),o.generateMipmap(a)):(o.texParameteri(a,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(a,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(a,o.TEXTURE_MAG_FILTER,Z(b.magFilter)),o.texParameteri(a,o.TEXTURE_MIN_FILTER,Z(b.minFilter)))}function V(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit= !0,a.__webglTexture=o.createTexture(),P.info.memory.textures++;o.activeTexture(o.TEXTURE0+b);o.bindTexture(o.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?o.texImage2D(o.TEXTURE_2D,0,Y(a.format),a.image.width,a.image.height,0,Y(a.format),o.UNSIGNED_BYTE,a.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,a.image);M(o.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+b),o.bindTexture(o.TEXTURE_2D,a.__webglTexture)}function K(a,b){o.bindRenderbuffer(o.RENDERBUFFER, a);b.depthBuffer&&!b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_COMPONENT16,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,a)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,b.width,b.height)}function W(a){var b=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=o.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];o.bindTexture(o.TEXTURE_CUBE_MAP,a.__webglTexture);M(o.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=o.createFramebuffer();a.__webglRenderbuffer[c]=o.createRenderbuffer();o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,Y(a.format),a.width,a.height,0,Y(a.format),Y(a.type), null);var e=a,f=o.TEXTURE_CUBE_MAP_POSITIVE_X+c;o.bindFramebuffer(o.FRAMEBUFFER,a.__webglFramebuffer[c]);o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,f,e.__webglTexture,0);K(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=o.createFramebuffer(),a.__webglRenderbuffer=o.createRenderbuffer(),o.bindTexture(o.TEXTURE_2D,a.__webglTexture),M(o.TEXTURE_2D,a,a),o.texImage2D(o.TEXTURE_2D,0,Y(a.format),a.width,a.height,0,Y(a.format),Y(a.type),null),c=o.TEXTURE_2D,o.bindFramebuffer(o.FRAMEBUFFER, a.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,a.__webglTexture,0),o.bindRenderbuffer(o.RENDERBUFFER,a.__webglRenderbuffer),K(a.__webglRenderbuffer,a);b?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER,null);o.bindFramebuffer(o.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=e=0):(b=null,c=oa,a=ma,e=ga,f=ha);b!==aa&&(o.bindFramebuffer(o.FRAMEBUFFER, b),o.viewport(e,f,c,a),aa=b)}function N(a){a instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,a.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP),o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,a.__webglTexture),o.generateMipmap(o.TEXTURE_2D),o.bindTexture(o.TEXTURE_2D,null))}function O(a,b){var c;a==="fragment"?c=o.createShader(o.FRAGMENT_SHADER):a==="vertex"&&(c=o.createShader(o.VERTEX_SHADER));o.shaderSource(c,b);o.compileShader(c);if(!o.getShaderParameter(c, o.COMPILE_STATUS))return console.error(o.getShaderInfoLog(c)),console.error(b),null;return c}function Z(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return o.NEAREST;default:return o.LINEAR}}function Y(a){switch(a){case THREE.RepeatWrapping:return o.REPEAT;case THREE.ClampToEdgeWrapping:return o.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return o.MIRRORED_REPEAT;case THREE.NearestFilter:return o.NEAREST;case THREE.NearestMipMapNearestFilter:return o.NEAREST_MIPMAP_NEAREST; case THREE.NearestMipMapLinearFilter:return o.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return o.LINEAR;case THREE.LinearMipMapNearestFilter:return o.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return o.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return o.BYTE;case THREE.UnsignedByteType:return o.UNSIGNED_BYTE;case THREE.ShortType:return o.SHORT;case THREE.UnsignedShortType:return o.UNSIGNED_SHORT;case THREE.IntType:return o.INT;case THREE.UnsignedShortType:return o.UNSIGNED_INT;case THREE.FloatType:return o.FLOAT; case THREE.AlphaFormat:return o.ALPHA;case THREE.RGBFormat:return o.RGB;case THREE.RGBAFormat:return o.RGBA;case THREE.LuminanceFormat:return o.LUMINANCE;case THREE.LuminanceAlphaFormat:return o.LUMINANCE_ALPHA}return 0}var P=this,o,U=[],Q=null,aa=null,T=-1,J=null,ra=0,pa=null,na=null,qa=null,ja=null,la=null,ea=null,ca=null,$=null,ga=0,ha=0,oa=0,ma=0,ka=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ta=new THREE.Matrix4,Da=new Float32Array(16), Ea=new Float32Array(16),Ca=new THREE.Vector4,Fa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},za=a.canvas!==void 0?a.canvas:document.createElement("canvas"),F=a.stencil!==void 0?a.stencil:!0,fa=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,ia=a.antialias!==void 0?a.antialias:!1,H=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),da=a.clearAlpha!==void 0?a.clearAlpha:0,sa=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=za;this.autoUpdateScene=this.autoUpdateObjects=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 va,ua=[],a=THREE.ShaderLib.depthRGBA,wa=THREE.UniformsUtils.clone(a.uniforms),Ga=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:wa}),Ba=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:wa,morphTargets:!0});Ga._shadowPass=!0;Ba._shadowPass=!0;try{if(!(o=za.getContext("experimental-webgl", {antialias:ia,stencil:F,preserveDrawingBuffer:fa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+o.getParameter(o.VERSION)+" | "+o.getParameter(o.VENDOR)+" | "+o.getParameter(o.RENDERER)+" | "+o.getParameter(o.SHADING_LANGUAGE_VERSION))}catch(Ka){console.error(Ka)}o.clearColor(0,0,0,1);o.clearDepth(1);o.clearStencil(0);o.enable(o.DEPTH_TEST);o.depthFunc(o.LEQUAL);o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE);o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD); o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA);o.clearColor(H.r,H.g,H.b,da);this.context=o;var ya=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,X={};X.vertices=new Float32Array(16);X.faces=new Uint16Array(6);F=0;X.vertices[F++]=-1;X.vertices[F++]=-1;X.vertices[F++]=0;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=-1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=1;X.vertices[F++]=0;X.vertices[F++]=-1;X.vertices[F++]=1;X.vertices[F++]=0;F=X.vertices[F++]= 0;X.faces[F++]=0;X.faces[F++]=1;X.faces[F++]=2;X.faces[F++]=0;X.faces[F++]=2;X.faces[F++]=3;X.vertexBuffer=o.createBuffer();X.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,X.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,X.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,X.elementBuffer);o.bufferData(o.ELEMENT_ARRAY_BUFFER,X.faces,o.STATIC_DRAW);X.program=o.createProgram();o.attachShader(X.program,O("fragment",THREE.ShaderLib.sprite.fragmentShader));o.attachShader(X.program,O("vertex", THREE.ShaderLib.sprite.vertexShader));o.linkProgram(X.program);X.attributes={};X.uniforms={};X.attributes.position=o.getAttribLocation(X.program,"position");X.attributes.uv=o.getAttribLocation(X.program,"uv");X.uniforms.uvOffset=o.getUniformLocation(X.program,"uvOffset");X.uniforms.uvScale=o.getUniformLocation(X.program,"uvScale");X.uniforms.rotation=o.getUniformLocation(X.program,"rotation");X.uniforms.scale=o.getUniformLocation(X.program,"scale");X.uniforms.alignment=o.getUniformLocation(X.program, "alignment");X.uniforms.color=o.getUniformLocation(X.program,"color");X.uniforms.map=o.getUniformLocation(X.program,"map");X.uniforms.opacity=o.getUniformLocation(X.program,"opacity");X.uniforms.useScreenCoordinates=o.getUniformLocation(X.program,"useScreenCoordinates");X.uniforms.affectedByDistance=o.getUniformLocation(X.program,"affectedByDistance");X.uniforms.screenPosition=o.getUniformLocation(X.program,"screenPosition");X.uniforms.modelViewMatrix=o.getUniformLocation(X.program,"modelViewMatrix"); X.uniforms.projectionMatrix=o.getUniformLocation(X.program,"projectionMatrix");var Ia=!1;this.setSize=function(a,b){za.width=a;za.height=b;this.setViewport(0,0,za.width,za.height)};this.setViewport=function(a,b,c,e){ga=a;ha=b;oa=c;ma=e;o.viewport(ga,ha,oa,ma)};this.setScissor=function(a,b,c,e){o.scissor(a,b,c,e)};this.enableScissorTest=function(a){a?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex=function(a,b){H.setHex(a);da=b;o.clearColor(H.r,H.g,H.b,da)};this.setClearColor= function(a,b){H.copy(a);da=b;o.clearColor(H.r,H.g,H.b,da)};this.getClearColor=function(){return H};this.getClearAlpha=function(){return da};this.clear=function(a,b,c){var e=0;if(a===void 0||a)e|=o.COLOR_BUFFER_BIT;if(b===void 0||b)e|=o.DEPTH_BUFFER_BIT;if(c===void 0||c)e|=o.STENCIL_BUFFER_BIT;o.clear(e)};this.getContext=function(){return o};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 b=a.geometry.geometryGroups[g];o.deleteBuffer(b.__webglVertexBuffer);o.deleteBuffer(b.__webglNormalBuffer);o.deleteBuffer(b.__webglTangentBuffer);o.deleteBuffer(b.__webglColorBuffer);o.deleteBuffer(b.__webglUVBuffer);o.deleteBuffer(b.__webglUV2Buffer);o.deleteBuffer(b.__webglSkinVertexABuffer);o.deleteBuffer(b.__webglSkinVertexBBuffer);o.deleteBuffer(b.__webglSkinIndicesBuffer);o.deleteBuffer(b.__webglSkinWeightsBuffer);o.deleteBuffer(b.__webglFaceBuffer); o.deleteBuffer(b.__webglLineBuffer);if(b.numMorphTargets)for(var c=0,e=b.numMorphTargets;c=0&&o.enableVertexAttribArray(x.position);x.color>=0&&o.enableVertexAttribArray(x.color);x.normal>=0&&o.enableVertexAttribArray(x.normal); x.tangent>=0&&o.enableVertexAttribArray(x.tangent);a.skinning&&x.skinVertexA>=0&&x.skinVertexB>=0&&x.skinIndex>=0&&x.skinWeight>=0&&(o.enableVertexAttribArray(x.skinVertexA),o.enableVertexAttribArray(x.skinVertexB),o.enableVertexAttribArray(x.skinIndex),o.enableVertexAttribArray(x.skinWeight));if(a.attributes)for(k in a.attributes)x[k]!==void 0&&x[k]>=0&&o.enableVertexAttribArray(x[k]);if(a.morphTargets)for(k=a.numSupportedMorphTargets=0;k=0&&(o.enableVertexAttribArray(x[w]), a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,b,c,e){W(a);this.clear(b,c,e)};this.updateShadowMap=function(a,b){x(a,b)};this.render=function(a,b,c,F){var ia,fa,A,B,C,H,ga,K=a.lights,sa=a.fog;T=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&x(a,b);P.info.render.calls=0;P.info.render.vertices=0;P.info.render.faces=0;b.parent==null&&(console.warn("Camera is not on the Scene. Adding it..."), a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(Ea);b.projectionMatrix.flattenToArray(Da);ta.multiply(b.projectionMatrix,b.matrixWorldInverse);t(ta);W(c);(this.autoClear||F)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);A=a.__webglObjects.length;for(F=0;F=0;F--)if(C=a.__webglObjects[F],C.render&&(H=C.object,ga=C.buffer,fa=C.opaque))f(H),l(fa.depthTest),n(fa.depthWrite),p(fa.polygonOffset, fa.polygonOffsetFactor,fa.polygonOffsetUnits),k(b,K,sa,fa,ga,H);for(F=0;F65535&&(x[t].counter+=1,F=x[t].hash+"_"+x[t].counter,l.geometryGroups[F]===void 0&&(l.geometryGroups[F]={faces:[],materialIndex:p,vertices:0,numMorphTargets:w})),l.geometryGroups[F].faces.push(n),l.geometryGroups[F].vertices+=u;l.geometryGroupsList=[];n=void 0;for(n in l.geometryGroups)l.geometryGroups[n].id=ra++,l.geometryGroupsList.push(l.geometryGroups[n])}for(k in h.geometryGroups)if(l=h.geometryGroups[k],!l.__webglVertexBuffer){n=l;n.__webglVertexBuffer=o.createBuffer();n.__webglNormalBuffer= o.createBuffer();n.__webglTangentBuffer=o.createBuffer();n.__webglColorBuffer=o.createBuffer();n.__webglUVBuffer=o.createBuffer();n.__webglUV2Buffer=o.createBuffer();n.__webglSkinVertexABuffer=o.createBuffer();n.__webglSkinVertexBBuffer=o.createBuffer();n.__webglSkinIndicesBuffer=o.createBuffer();n.__webglSkinWeightsBuffer=o.createBuffer();n.__webglFaceBuffer=o.createBuffer();n.__webglLineBuffer=o.createBuffer();if(n.numMorphTargets){p=v=void 0;n.__webglMorphTargetsBuffers=[];v=0;for(p=n.numMorphTargets;v< p;v++)n.__webglMorphTargetsBuffers.push(o.createBuffer())}P.info.memory.geometries++;for(var p=e,y=u=x=void 0,t=y=w=y=void 0,F=t=n=0,z=u=void 0,ia=void 0,u=v=w=x=void 0,w=p.geometry,z=w.faces,ia=l.faces,x=0,u=ia.length;x0||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(p.geometry.skinWeights.length&&p.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(t*3);l.__lineArray=new Uint16Array(F*2);if(l.numMorphTargets){l.__morphTargetsArrays=[];w=0;for(y=l.numMorphTargets;w=0;h--)f[h]===k&&f.splice(h,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&C(f.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(f=a.__webglObjects.length;e0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,ea,t));Ka&&(o.bindBuffer(o.ARRAY_BUFFER, p.__webglNormalBuffer),o.bufferData(o.ARRAY_BUFFER,aa,t));Ca&&qa.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,ka,t));ya&&T>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,wa,t));ya&&W>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,la,t));Ea&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,p.__webglFaceBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,Ba,t),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,p.__webglLineBuffer), o.bufferData(o.ELEMENT_ARRAY_BUFFER,na,t));S>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,$,t),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,ca,t),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ua,t),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,ja,t));F&&(delete p.__inittedArrays,delete p.__colorArray,delete p.__normalArray,delete p.__tangentArray, delete p.__uvArray,delete p.__uv2Array,delete p.__faceArray,delete p.__vertexArray,delete p.__lineArray,delete p.__skinVertexAArray,delete p.__skinVertexBArray,delete p.__skinIndexArray,delete p.__skinWeightArray)}k.__dirtyVertices=!1;k.__dirtyMorphTargets=!1;k.__dirtyElements=!1;k.__dirtyUvs=!1;k.__dirtyNormals=!1;k.__dirtyColors=!1;k.__dirtyTangents=!1;l.attributes&&A(l)}else if(h instanceof THREE.Ribbon){if(k.__dirtyVertices||k.__dirtyColors){h=k;l=o.DYNAMIC_DRAW;n=x=F=F=void 0;w=h.vertices;v= h.colors;u=w.length;p=v.length;z=h.__vertexArray;t=h.__colorArray;ia=h.__dirtyColors;if(h.__dirtyVertices){for(F=0;F1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=f;c.v=h;return c}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; THREE.GeometryUtils={merge:function(a,c){for(var b,e,k=a.vertices.length,h=c instanceof THREE.Mesh?c.geometry:c,f=a.vertices,l=h.vertices,n=a.faces,p=h.faces,t=a.faceVertexUvs[0],u=h.faceVertexUvs[0],w={},v=0;v1&&(e=1-e,k=1-k);h=1-e-k;f.copy(a);f.multiplyScalar(e);l.copy(c);l.multiplyScalar(k);f.addSelf(l);l.copy(b);l.multiplyScalar(h);f.addSelf(l);return f},randomPointInFace:function(a,c,b){var e,k,h;if(a instanceof THREE.Face3)return e=c.vertices[a.a].position,k=c.vertices[a.b].position, h=c.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(e,k,h);else if(a instanceof THREE.Face4){e=c.vertices[a.a].position;k=c.vertices[a.b].position;h=c.vertices[a.c].position;var c=c.vertices[a.d].position,f;b?a._area1&&a._area2?(b=a._area1,f=a._area2):(b=THREE.GeometryUtils.triangleArea(e,k,c),f=THREE.GeometryUtils.triangleArea(k,h,c),a._area1=b,a._area2=f):(b=THREE.GeometryUtils.triangleArea(e,k,c),f=THREE.GeometryUtils.triangleArea(k,h,c));return THREE.GeometryUtils.random()*(b+ f)a?b(c,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 c,b=[];for(c=0;c<=a;c++)b.push(this.getPoint(c/a));return b};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPointAt(c/a));return b}; 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 c=[],b,e=this.getPoint(0),k,h=0;c.push(0);for(k=1;k<=a;k++)b=this.getPoint(k/a),h+=b.distanceTo(e),c.push(h),e=b;return this.cacheArcLengths=c}; THREE.Curve.prototype.getUtoTmapping=function(a,c){var b=this.getLengths(),e=0,k=b.length,h;h=c?c:a*b[k-1];time=Date.now();for(var f=0,l=k-1,n;f<=l;)if(e=Math.floor(f+(l-f)/2),n=b[e]-h,n<0)f=e+1;else if(n>0)l=e-1;else{l=e;break}e=l;if(b[e]==h)return e/(k-1);f=b[e];return b=(e+(h-f)/(b[e+1]-f))/(k-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 c=a-1.0E-4;a+=1.0E-4;c<0&&(c=0);a>1&&(a=1);var c=this.getPoint(c),a=this.getPoint(a),b=new THREE.Vector2;b.sub(a,c);return b.unit()};THREE.LineCurve=function(a,c){a instanceof THREE.Vector2?(this.v1=a,this.v2=c):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(a,c,b,e){this.constructor(new THREE.Vector2(a,c),new THREE.Vector2(b,e))};THREE.LineCurve.prototype=new THREE.Curve; THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2;c.sub(this.v2,this.v1);c.multiplyScalar(a).addSelf(this.v1);return c};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,c,b){if(!(c instanceof THREE.Vector2))var e=Array.prototype.slice.call(arguments),a=new THREE.Vector2(e[0],e[1]),c=new THREE.Vector2(e[2],e[3]),b=new THREE.Vector2(e[4],e[5]);this.v0=a;this.v1=c;this.v2=b};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var c;c=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(c,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var c;c=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);c=new THREE.Vector2(c,a);c.normalize();return c}; THREE.CubicBezierCurve=function(a,c,b,e){if(!(c instanceof THREE.Vector2))var k=Array.prototype.slice.call(arguments),a=new THREE.Vector2(k[0],k[1]),c=new THREE.Vector2(k[2],k[3]),b=new THREE.Vector2(k[4],k[5]),e=new THREE.Vector2(k[6],k[7]);this.v0=a;this.v1=c;this.v2=b;this.v3=e};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; THREE.CubicBezierCurve.prototype.getPoint=function(a){var c;c=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(c,a)};THREE.CubicBezierCurve.prototype.getTangent=function(a){var c;c=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);c=new THREE.Vector2(c,a);c.normalize();return c}; 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 c=new THREE.Vector2,b=[],e=this.points,k;k=(e.length-1)*a;a=Math.floor(k);k-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>e.length-2?a:a+1;b[3]=a>e.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(e[b[0]].x,e[b[1]].x,e[b[2]].x,e[b[3]].x,k);c.y=THREE.Curve.Utils.interpolate(e[b[0]].y,e[b[1]].y,e[b[2]].y,e[b[3]].y,k);return c};THREE.ArcCurve=function(a,c,b,e,k,h){this.aX=a;this.aY=c;this.aRadius=b;this.aStartAngle=e;this.aEndAngle=k;this.aClockwise=h}; THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(a){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);a=this.aStartAngle+a*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(a),this.aY+this.aRadius*Math.sin(a))}; THREE.Curve.Utils={tangentQuadraticBezier:function(a,c,b,e){return 2*(1-a)*(b-c)+2*a*(e-b)},tangentCubicBezier:function(a,c,b,e,k){return-3*c*(1-a)*(1-a)+3*b*(1-a)*(1-a)-6*a*b*(1-a)+6*a*e*(1-a)-3*a*a*e+3*a*a*k},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,c,b,e,k){var a=(b-a)*0.5,e=(e-c)*0.5,h=k*k;return(2*c-2*b+a+e)*k*h+(-3*c+3*b-2*a-e)*h+a*k+c}}; THREE.Curve.create=function(a,c){a.prototype=new THREE.Curve;a.prototype.constructor=a;a.prototype.getPoint=c;return a};THREE.LineCurve3=THREE.Curve.create(function(a,c){this.v1=a;this.v2=c},function(a){var c=new THREE.Vector3;c.sub(v2,v1);c.multiplyScalar(a);c.addSelf(this.v1);return c}); THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,c,b){this.v0=a;this.v1=c;this.v2=b},function(a){var c,b;c=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);b=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(c,b,a)}); THREE.CubicBezierCurve3=THREE.Curve.create(function(a,c,b,e){this.v0=a;this.v1=c;this.v2=b;this.v3=e},function(a){var c,b;c=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=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(c,b,a)}); THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=a},function(a){var c=new THREE.Vector3,b=[],e=this.points,k;k=(e.length-1)*a;a=Math.floor(k);k-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>e.length-2?a:a+1;b[3]=a>e.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(e[b[0]].x,e[b[1]].x,e[b[2]].x,e[b[3]].x,k);c.y=THREE.Curve.Utils.interpolate(e[b[0]].y,e[b[1]].y,e[b[2]].y,e[b[3]].y,k);c.z=THREE.Curve.Utils.interpolate(e[b[0]].z,e[b[1]].z,e[b[2]].z,e[b[3]].z,k);return c}); 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 c=a*this.getLength(),b=this.getCurveLengths(),a=0;a=c)return c=b[a]-c,a=this.curves[a],c=1-c/a.getLength(),a.getPointAt(c);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=[],c=0,b,e=this.curves.length;for(b=0;bc)c=h.x;else if(h.xb)b=h.y;else if(h.y0?(f=b[b.length-1],v=f.x,z=f.y):(f=this.actions[e-1].args,v=f[f.length-2],z=f[f.length-1]);for(f=1;f<=a;f++)x=f/a,h=THREE.Shape.Utils.b2(x,v,u,l),x=THREE.Shape.Utils.b2(x,z,w, n),b.push(new THREE.Vector2(h,x));break;case THREE.PathActions.BEZIER_CURVE_TO:l=h[4];n=h[5];u=h[0];w=h[1];p=h[2];t=h[3];b.length>0?(f=b[b.length-1],v=f.x,z=f.y):(f=this.actions[e-1].args,v=f[f.length-2],z=f[f.length-1]);for(f=1;f<=a;f++)x=f/a,h=THREE.Shape.Utils.b3(x,v,u,p,l),x=THREE.Shape.Utils.b3(x,z,w,t,n),b.push(new THREE.Vector2(h,x));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[e-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];x=a*h[0].length;f=f.concat(h[0]);h=new THREE.SplineCurve(f); for(f=1;f<=x;f++)b.push(h.getPointAt(f/x));break;case THREE.PathActions.ARC:f=this.actions[e-1].args;l=h[0];n=h[1];p=h[2];u=h[3];x=h[4];w=!!h[5];t=f[f.length-2];v=f[f.length-1];f.length==0&&(t=v=0);z=x-u;var y=a*2;for(f=1;f<=y;f++)x=f/y,w||(x=1-x),x=u+x*z,h=t+l+p*Math.cos(x),x=v+n+p*Math.sin(x),b.push(new THREE.Vector2(h,x))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)}; THREE.Path.prototype.nltransform=function(a,c,b,e,k,h){var f=this.getPoints(),l,n,p,t,u;l=0;for(n=f.length;l=0?l-1:b.length-1;h=f-1>=0?f-1:p.length-1;var x=[p[f],b[l],b[k]];u=THREE.FontUtils.Triangulate.area(x);var y=[p[f],p[h],b[l]];w=THREE.FontUtils.Triangulate.area(y);v=l;t=f;l+=1;f+=-1;l< 0&&(l+=b.length);l%=b.length;f<0&&(f+=p.length);f%=p.length;k=l-1>=0?l-1:b.length-1;h=f-1>=0?f-1:p.length-1;x=[p[f],b[l],b[k]];x=THREE.FontUtils.Triangulate.area(x);y=[p[f],p[h],b[l]];y=THREE.FontUtils.Triangulate.area(y);u+w>x+y&&(l=v,f=t,l<0&&(l+=b.length),l%=b.length,f<0&&(f+=p.length),f%=p.length,k=l-1>=0?l-1:b.length-1,h=f-1>=0?f-1:p.length-1);u=b.slice(0,l);w=b.slice(l);v=p.slice(f);t=p.slice(0,f);h=[p[f],p[h],b[l]];z.push([p[f],b[l],b[k]]);z.push(h);b=u.concat(v).concat(t).concat(w)}return{shape:b, isolatedPts:z,allpoints:e}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),e=b.allpoints,k=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),h,f,l,n,p={};h=0;for(f=e.length;h1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+v),e=e<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=k[0]+(h[0]-k[0])*e,b.y=k[1]+(h[1]-k[1])*e,b.z=k[2]+(h[2]-k[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",v,f.index-1).pos,this.points[1]=k,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",v,l.index+1).pos,e=e*0.33+0.33,k=this.interpolateCatmullRom(this.points,e),b.x=k[0],b.y=k[1],b.z=k[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(b),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(b=== "rot")THREE.Quaternion.slerp(k,h,a.quaternion,e);else if(b==="scl")b=a.scale,b.x=k[0]+(h[0]-k[0])*e,b.y=k[1]+(h[1]-k[1])*e,b.z=k[2]+(h[2]-k[2])*e}}if(this.JITCompile&&t[0][p]===void 0){this.hierarchy[0].update(null,!0);for(v=0;va.length-2?h:h+1;b[3]=h>a.length-3?h:h+2;h=a[b[0]];l=a[b[1]];n=a[b[2]];p=a[b[3]];b=k*k;f=k*b;e[0]=this.interpolate(h[0],l[0],n[0],p[0],k,b,f);e[1]=this.interpolate(h[1],l[1],n[1],p[1],k,b,f);e[2]=this.interpolate(h[2],l[2],n[2],p[2],k,b,f);return e}; THREE.Animation.prototype.interpolate=function(a,c,b,e,k,h,f){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*f+(-3*(c-b)-2*a-e)*h+a*k+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b0?b:0:b>=0?b:b+e.length;b>=0;b--)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[e.length-1]}; THREE.CubeCamera=function(a,c,b,e){this.heightOffset=b;this.position=new THREE.Vector3(0,b,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,c);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,b){var c=this.renderTarget;c.activeCubeFace=0;a.render(b,this.cameraPX,c);c.activeCubeFace=1;a.render(b,this.cameraNX,c);c.activeCubeFace=2;a.render(b,this.cameraPY,c);c.activeCubeFace=3;a.render(b, this.cameraNY,c);c.activeCubeFace=4;a.render(b,this.cameraPZ,c);c.activeCubeFace=5;a.render(b,this.cameraNZ,c)}};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,c,b,e,k,h,f){THREE.Camera.call(this);this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,c/2,c/-2,h,f);this.cameraP=new THREE.PerspectiveCamera(b,a/c,e,k);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,c){c||(c=43.25);var b=2*Math.atan(c/(a*2));b*=180/Math.PI;this.setFov(b);return b}; THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c: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 b=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=a*b*this.heightCoef}else this.autoSpeedFactor=0;b=a*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(b);this.moveLeft&&this.object.translateX(-b);this.moveRight&&this.object.translateX(b); this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);b=a*this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);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,c=this.object.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.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*b;this.lookVertical&&(this.lat-=this.mouseY*b*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;c=this.object.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.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",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)}; THREE.PathControls=function(a,c){function b(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function e(a,b){return function(){b.apply(a,arguments)}}function k(a,b,c,e){var f={name:c,fps:0.6,length:e,hierarchy:[]},h,k=b.getControlPointsArray(),l=b.getLength(),y=k.length,D=0;h=y-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:k[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[h]={time:e,pos:k[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h=0?a:a+f;c=this.verticalAngleMap.srcRange; a=this.verticalAngleMap.dstRange;c=THREE.Math.mapLinear(this.phi,c[0],c[1],a[0],a[1]);var e=a[1]-a[0];this.phi=b((c-a[0])/e)*e+a[0];c=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;c=THREE.Math.mapLinear(this.theta,c[0],c[1],a[0],a[1]);e=a[1]-a[0];this.theta=b((c-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}),b=new THREE.MeshLambertMaterial({color:65280}), c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=k(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=k(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,b=this.spline,c=h(b,10),f=h(b,10),l=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(c,l);particleObj=new THREE.ParticleSystem(f,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);f=new THREE.SphereGeometry(1,16,8);l=new THREE.MeshBasicMaterial({color:65280});for(i=0;i0){var b=this.getContainerDimensions(),c=b.size[0]/2,f=b.size[1]/2;this.moveState.yawLeft=-(a.pageX-b.offset[0]-c)/c;this.moveState.pitchDown=(a.pageY-b.offset[1]-f)/f;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 b=a*this.movementSpeed;a*=this.rollSpeed;this.object.translateX(this.moveVector.x*b);this.object.translateY(this.moveVector.y*b);this.object.translateZ(this.moveVector.z*b);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",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this, this.mouseup),!1);this.domElement.addEventListener("keydown",b(this,this.keydown),!1);this.domElement.addEventListener("keyup",b(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()}; THREE.RollControls=function(a,c){this.object=a;this.domElement=c!==void 0?c: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 b=new THREE.Vector3,e=new THREE.Vector3,k=new THREE.Vector3,h=new THREE.Matrix4,f=!1,l=1,n=0,p=0,t=0,u=0,w=0,v=window.innerWidth/2,z=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var c=a*this.lookSpeed; this.rotateHorizontally(c*u);this.rotateVertically(c*w)}c=a*this.movementSpeed;this.object.translateZ(-c*(n>0||this.autoForward&&!(n<0)?1:n));this.object.translateX(c*p);this.object.translateY(c*t);f&&(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?e.normalize():e.z=Math.sqrt(1-h*h);f.copy(b.object.position).subSelf(b.target);h=b.object.up.clone().setLength(e.y);h.addSelf(b.object.up.clone().crossSelf(f).setLength(e.x));h.addSelf(f.setLength(e.z));return h};this.rotateCamera=function(){var a=Math.acos(l.dot(n)/l.length()/n.length());if(a){var c=(new THREE.Vector3).cross(l,n).normalize(),e=new THREE.Quaternion;a*=b.rotateSpeed;e.setFromAxisAngle(c,-a);e.multiplyVector3(f); e.multiplyVector3(b.object.up);e.multiplyVector3(n);b.staticMoving?l=n:(e.setFromAxisAngle(c,a*(b.dynamicDampingFactor-1)),e.multiplyVector3(l))}};this.zoomCamera=function(){var a=1+(t.y-p.y)*b.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),b.staticMoving?p=t:p.y+=(t.y-p.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=w.clone().subSelf(u);if(a.lengthSq()){a.multiplyScalar(f.length()*b.panSpeed);var c=f.clone().crossSelf(b.object.up).setLength(a.x);c.addSelf(b.object.up.clone().setLength(a.y)); b.object.position.addSelf(c);b.target.addSelf(c);b.staticMoving?u=w:u.addSelf(a.sub(w,u).multiplyScalar(b.dynamicDampingFactor))}};this.checkDistances=function(){if(!b.noZoom||!b.noPan)b.object.position.lengthSq()>b.maxDistance*b.maxDistance&&b.object.position.setLength(b.maxDistance),f.lengthSq()0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(l=0;l0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(l=0;la&&(a+=Math.PI*2),anglec=(b+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(k).addSelf(l).subSelf(a).clone()}function k(a){for(N=a.length;--N>=0;){pa=N;na=N-1;na<0&&(na=a.length- 1);for(var b=0,c=v+t*2,b=0;b=0;Z--){Y=Z/t;P=n*(1-Y);Y=p*Math.sin(Y*Math.PI/2);N=0;for(O=B.length;N0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(u,l,w)))-1);p.push(t)}c.push(p)}for(var v,z,x,k=c.length,b=0;b0)for(e=0;e1&&(v= this.vertices[f].position.clone(),z=this.vertices[n].position.clone(),x=this.vertices[p].position.clone(),v.normalize(),z.normalize(),x.normalize(),this.faces.push(new THREE.Face3(f,n,p,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([t,u,y]))}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,c){var b=(new THREE.TextPath(a,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var e=b[b.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(e/2,120),new THREE.Vector2(e,0))}THREE.ExtrudeGeometry.call(this,b,c)};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,c){return(new TextPath(a,c)).toShapes()},loadFace:function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[c][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var c= this.getFace(),b=this.size/c.resolution,e=0,k=String(a).split(""),h=k.length,f=[],a=0;a0)for(p=0;p2;){if(u--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return l;return h}n=p;k<=n&&(n=0);p=n+1;k<=p&&(p=0);t=p+1;k<=t&&(t=0);var w;a:{w=a;var v=n,z=p,x=t,y=k,D=f,B=void 0,A=void 0,C=void 0, L=void 0,G=void 0,M=void 0,V=void 0,K=void 0,W=void 0,A=w[D[v]].x,C=w[D[v]].y,L=w[D[z]].x,G=w[D[z]].y,M=w[D[x]].x,V=w[D[x]].y;if(1.0E-10>(L-A)*(V-C)-(G-C)*(M-A))w=!1;else{for(B=0;B=0&&Z>=0&&P>=0){w=!1;break a}}w= !0}}if(w){h.push([a[f[n]],a[f[p]],a[f[t]]]);l.push([f[n],f[p],f[t]]);n=p;for(t=p+1;t0;)this.smooth(a)}; THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,e,l,n){var p=new THREE.Face4(a,b,c,e,null,l.color,l.material);if(f.useOldVertexColors){p.vertexColors=[];for(var o,v,t,x=0;x<4;x++){t=n[x];o=new THREE.Color;o.setRGB(0,0,0);for(var w=0;w>7)-127;e|=(f&127)<<16|h<<8;if(e==0&&l==-127)return 0;return(1-2*(k>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,l)}function k(a,b){var c=t(a,b),e=t(a,b+1),h=t(a,b+2);return(t(a,b+3)<<24)+(h<<16)+(e<<8)+c}function n(a,b){var c=t(a,b);return(t(a,b+1)<<8)+c}function p(a,b){var c=t(a,b);return c>127?c-256:c}function t(a,b){return a.charCodeAt(b)&255}function u(b){var c, e,h;c=k(a,b);e=k(a,b+G);h=k(a,b+M);b=n(a,b+V);D.faces.push(new THREE.Face3(c,e,h,null,null,b))}function w(b){var c,e,h,f,o,p,u;c=k(a,b);e=k(a,b+G);h=k(a,b+M);f=n(a,b+V);o=k(a,b+K);p=k(a,b+W);u=k(a,b+N);var b=C[p*3],t=C[p*3+1];p=C[p*3+2];var v=C[u*3],x=C[u*3+1];u=C[u*3+2];D.faces.push(new THREE.Face3(c,e,h,[new THREE.Vector3(C[o*3],C[o*3+1],C[o*3+2]),new THREE.Vector3(b,t,p),new THREE.Vector3(v,x,u)],null,f))}function v(b){var c,e,h,f;c=k(a,b);e=k(a,b+O);h=k(a,b+Z);f=k(a,b+Y);b=n(a,b+P);D.faces.push(new THREE.Face4(c, e,h,f,null,null,b))}function z(b){var c,e,h,f,p,u,t,v,x;c=k(a,b);e=k(a,b+O);h=k(a,b+Z);f=k(a,b+Y);p=n(a,b+P);u=k(a,b+o);t=k(a,b+U);v=k(a,b+Q);x=k(a,b+aa);var b=C[t*3],w=C[t*3+1];t=C[t*3+2];var F=C[v*3],y=C[v*3+1];v=C[v*3+2];var ia=C[x*3],H=C[x*3+1];x=C[x*3+2];D.faces.push(new THREE.Face4(c,e,h,f,[new THREE.Vector3(C[u*3],C[u*3+1],C[u*3+2]),new THREE.Vector3(b,w,t),new THREE.Vector3(F,y,v),new THREE.Vector3(ia,H,x)],null,p))}function x(b){var c,e,h,f;c=k(a,b);e=k(a,b+T);h=k(a,b+J);b=L[c*2];f=L[c*2+ 1];c=L[e*2];var n=D.faceVertexUvs[0];e=L[e*2+1];var o=L[h*2];h=L[h*2+1];var p=[];p.push(new THREE.UV(b,f));p.push(new THREE.UV(c,e));p.push(new THREE.UV(o,h));n.push(p)}function y(b){var c,e,h,f,n,o;c=k(a,b);e=k(a,b+ra);h=k(a,b+pa);f=k(a,b+na);b=L[c*2];n=L[c*2+1];c=L[e*2];o=L[e*2+1];e=L[h*2];var p=D.faceVertexUvs[0];h=L[h*2+1];var u=L[f*2];f=L[f*2+1];var t=[];t.push(new THREE.UV(b,n));t.push(new THREE.UV(c,o));t.push(new THREE.UV(e,h));t.push(new THREE.UV(u,f));p.push(t)}var D=this,B=0,A,C=[],L=[], G,M,V,K,W,N,O,Z,Y,P,o,U,Q,aa,T,J,ra,pa,na,qa,ja,la,ea,ca,$;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(D,e,b);A={signature:a.substr(B,8),header_bytes:t(a,B+8),vertex_coordinate_bytes:t(a,B+9),normal_coordinate_bytes:t(a,B+10),uv_coordinate_bytes:t(a,B+11),vertex_index_bytes:t(a,B+12),normal_index_bytes:t(a,B+13),uv_index_bytes:t(a,B+14),material_index_bytes:t(a,B+15),nvertices:k(a,B+16),nnormals:k(a,B+16+4),nuvs:k(a,B+16+8),ntri_flat:k(a,B+16+12),ntri_smooth:k(a,B+16+16),ntri_flat_uv:k(a, B+16+20),ntri_smooth_uv:k(a,B+16+24),nquad_flat:k(a,B+16+28),nquad_smooth:k(a,B+16+32),nquad_flat_uv:k(a,B+16+36),nquad_smooth_uv:k(a,B+16+40)};B+=A.header_bytes;G=A.vertex_index_bytes;M=A.vertex_index_bytes*2;V=A.vertex_index_bytes*3;K=A.vertex_index_bytes*3+A.material_index_bytes;W=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;N=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;O=A.vertex_index_bytes;Z=A.vertex_index_bytes*2;Y=A.vertex_index_bytes*3;P=A.vertex_index_bytes* 4;o=A.vertex_index_bytes*4+A.material_index_bytes;U=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;Q=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;aa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;T=A.uv_index_bytes;J=A.uv_index_bytes*2;ra=A.uv_index_bytes;pa=A.uv_index_bytes*2;na=A.uv_index_bytes*3;b=A.vertex_index_bytes*3+A.material_index_bytes;$=A.vertex_index_bytes*4+A.material_index_bytes;qa=A.ntri_flat*b;ja=A.ntri_smooth*(b+A.normal_index_bytes* 3);la=A.ntri_flat_uv*(b+A.uv_index_bytes*3);ea=A.ntri_smooth_uv*(b+A.normal_index_bytes*3+A.uv_index_bytes*3);ca=A.nquad_flat*$;b=A.nquad_smooth*($+A.normal_index_bytes*4);$=A.nquad_flat_uv*($+A.uv_index_bytes*4);B+=function(b){for(var e,h,k,l=A.vertex_coordinate_bytes*3,n=b+A.nvertices*l;b=0){w=n.invBindMatrices[t];o.invBindMatrix=w;o.skinningMatrix=new THREE.Matrix4;o.skinningMatrix.multiply(o.world,w);o.weights=[];for(w=0;w1){n=new THREE.MeshFaceMaterial;for(j=0;j1?b.add(n):b=n}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation, b.scale);for(f=0;f1?c[1].substr(0,b):"0";c[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;eb){p=o.output[n];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);b=k;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};u.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(e[0].textContent))}}this.create();return this};W.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var e=this[c];if(e instanceof K)if(e.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(e=ga[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 c=="diffuse"?a.color=e.color.getHex():b||(a[c]=e.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=za;return this.material=new THREE.MeshLambertMaterial(a)};N.prototype.parse=function(a){for(var b=0;b=0,e=a.indexOf("(")>=0,h,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(e){h=a.split("(");a=h.shift();for(b=0;b1&&(W=new THREE.MeshFaceMaterial);object=new THREE.Mesh(G,W);object.name=v;object.position.set(A[0],A[1],A[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;Q.scene.add(object);Q.objects[v]=object;B.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),Q.scene.collisions.colliders.push(a));if(B.castsShadow)a= new THREE.ShadowVolume(G),Q.scene.add(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;B.trigger&&B.trigger.toLowerCase()!="none"&&(a={type:B.trigger,object:B},Q.triggers[object.name]=a)}}else A=B.position,r=B.rotation,q=B.quaternion,s=B.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(A[0],A[1],A[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible= B.visible!==void 0?B.visible:!1,Q.scene.add(object),Q.objects[v]=object,Q.empties[v]=object,B.trigger&&B.trigger.toLowerCase()!="none"&&(a={type:B.trigger,object:B},Q.triggers[object.name]=a)}function n(a){return function(c){Q.geometries[a]=c;l();Y-=1;b.onLoadComplete();t()}}function p(a){return function(b){Q.geometries[a]=b}}function t(){b.callbackProgress({totalModels:o,totalTextures:U,loadedModels:o-Y,loadedTextures:U-P},Q);b.onLoadProgress();Y==0&&P==0&&c(Q)}var u,w,v,z,x,y,D,B,A,C,L,G,M,V,K, W,N,O,Z,Y,P,o,U,Q;O=a.data;K=new THREE.BinaryLoader;Z=new THREE.JSONLoader;P=Y=0;Q={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(v in O.objects)if(B=O.objects[v],B.meshCollider){a=!0;break}if(a)Q.scene.collisions=new THREE.CollisionSystem;if(O.transform){a=O.transform.position;C=O.transform.rotation;var aa=O.transform.scale;a&&Q.scene.position.set(a[0],a[1],a[2]);C&&Q.scene.rotation.set(C[0],C[1],C[2]);aa&&Q.scene.scale.set(aa[0], aa[1],aa[2]);(a||C||aa)&&Q.scene.updateMatrix()}a=function(){P-=1;t();b.onLoadComplete()};for(x in O.cameras)C=O.cameras[x],C.type=="perspective"?M=new THREE.PerspectiveCamera(C.fov,C.aspect,C.near,C.far):C.type=="ortho"&&(M=new THREE.OrthographicCamera(C.left,C.right,C.top,C.bottom,C.near,C.far)),A=C.position,C=C.target,M.position.set(A[0],A[1],A[2]),M.target=new THREE.Vector3(C[0],C[1],C[2]),Q.cameras[x]=M;for(z in O.lights)x=O.lights[z],M=x.color!==void 0?x.color:16777215,C=x.intensity!==void 0? x.intensity:1,x.type=="directional"?(A=x.direction,N=new THREE.DirectionalLight(M,C),N.position.set(A[0],A[1],A[2]),N.position.normalize()):x.type=="point"?(A=x.position,d=x.distance,N=new THREE.PointLight(M,C,d),N.position.set(A[0],A[1],A[2])):x.type=="ambient"&&(N=new THREE.AmbientLight(M)),Q.scene.add(N),Q.lights[z]=N;for(y in O.fogs)z=O.fogs[y],z.type=="linear"?V=new THREE.Fog(0,z.near,z.far):z.type=="exp2"&&(V=new THREE.FogExp2(0,z.density)),C=z.color,V.color.setRGB(C[0],C[1],C[2]),Q.fogs[y]= V;if(Q.cameras&&O.defaults.camera)Q.currentCamera=Q.cameras[O.defaults.camera];if(Q.fogs&&O.defaults.fog)Q.scene.fog=Q.fogs[O.defaults.fog];C=O.defaults.bgcolor;Q.bgColor=new THREE.Color;Q.bgColor.setRGB(C[0],C[1],C[2]);Q.bgColorAlpha=O.defaults.bgalpha;for(u in O.geometries)if(y=O.geometries[u],y.type=="bin_mesh"||y.type=="ascii_mesh")Y+=1,b.onLoadStart();o=Y;for(u in O.geometries)y=O.geometries[u],y.type=="cube"?(G=new THREE.CubeGeometry(y.width,y.height,y.depth,y.segmentsWidth,y.segmentsHeight, y.segmentsDepth,null,y.flipped,y.sides),Q.geometries[u]=G):y.type=="plane"?(G=new THREE.PlaneGeometry(y.width,y.height,y.segmentsWidth,y.segmentsHeight),Q.geometries[u]=G):y.type=="sphere"?(G=new THREE.SphereGeometry(y.radius,y.segmentsWidth,y.segmentsHeight),Q.geometries[u]=G):y.type=="cylinder"?(G=new THREE.CylinderGeometry(y.topRad,y.botRad,y.height,y.radSegs,y.heightSegs),Q.geometries[u]=G):y.type=="torus"?(G=new THREE.TorusGeometry(y.radius,y.tube,y.segmentsR,y.segmentsT),Q.geometries[u]=G): y.type=="icosahedron"?(G=new THREE.IcosahedronGeometry(y.subdivisions),Q.geometries[u]=G):y.type=="bin_mesh"?K.load(e(y.url,O.urlBaseType),n(u)):y.type=="ascii_mesh"?Z.load(e(y.url,O.urlBaseType),n(u)):y.type=="embedded_mesh"&&(y=O.embeds[y.id])&&Z.createModel(y,p(u),"");for(D in O.textures)if(u=O.textures[D],u.url instanceof Array){P+=u.url.length;for(K=0;K=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),e=1,k=0;k<8;k++){for(var h=0,f=0;f>1^-(l&1);b[8*f+k]=h}e+=c}c=a.length-e;h=new Uint16Array(c);for(k=f=0;k=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 c=this.count*3;cthis.size-1&&(n=this.size-1);var w=Math.floor(p-l);w<1&&(w=1);p=Math.floor(p+l);p>this.size-1&&(p=this.size-1);var v=Math.floor(t-l);v<1&&(v=1);l=Math.floor(t+l); l>this.size-1&&(l=this.size-1);for(var z,x,y,D,B,A;u0&&(this.field[y+z]+=D)}}};this.addPlaneX=function(a,c){var k,h,f,l,n,p=this.size,t=this.yd,u=this.zd,w=this.field,v=p*Math.sqrt(a/c);v>p&&(v=p);for(k=0;k0)for(h=0;ht&&(z=t);for(h=0;h0){n=h*u;for(k=0;ksize&&(dist=size);for(f=0;f0){n=zd*f;for(h=0;hh?this.hits.push(k):this.hits.unshift(k),h=e;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(a){var c=this.rayCastAll(a);if(c.length==0)return null;for(var b=0;c[b]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,c[b]);if(e.distc.length)return null;return c[b]}; THREE.CollisionSystem.prototype.rayCast=function(a,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(a,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(a,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(a,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(a,c.box)}; THREE.CollisionSystem.prototype.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),e=Number.MAX_VALUE,k,h=0;h=l*k))return Number.MAX_VALUE;f/=l;l=THREE.CollisionSystem.__v3;l.copy(a.direction);l.multiplyScalar(f);l.addSelf(a.origin);Math.abs(h.x)> Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=l.y-c.y,h=b.y-c.y,k=e.y-c.y,l=l.z-c.z,b=b.z-c.z,e=e.z-c.z):(a=l.x-c.x,h=b.x-c.x,k=e.x-c.x,l=l.y-c.y,b=b.y-c.y,e=e.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(a=l.x-c.x,h=b.x-c.x,k=e.x-c.x,l=l.z-c.z,b=b.z-c.z,e=e.z-c.z):(a=l.x-c.x,h=b.x-c.x,k=e.x-c.x,l=l.y-c.y,b=b.y-c.y,e=e.y-c.y);c=h*e-b*k;if(c==0)return Number.MAX_VALUE;c=1/c;e=(a*e-l*k)*c;if(!(e>=0))return Number.MAX_VALUE;c*=h*l-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return f}; THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,b);var e=THREE.CollisionSystem.__r;e.origin.copy(a.origin);e.direction.copy(a.direction);b.multiplyVector3(e.origin);b.rotateAxis(e.direction);e.direction.normalize();return e}; THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;c.dynamic&&c.mesh&&c.mesh.matrixWorld?b=this.makeRayLocal(a,c.mesh):(b=THREE.CollisionSystem.__r,b.origin.copy(a.origin),b.direction.copy(a.direction));var e=0,k=0,h=0,f=0,l=0,n=0,p=!0;b.origin.xc.max.x&&(e=c.max.x-b.origin.x,e/=b.direction.x,p=!1,f=1);b.origin.yc.max.y&&(k=c.max.y-b.origin.y,k/=b.direction.y, p=!1,l=1);b.origin.zc.max.z&&(h=c.max.z-b.origin.z,h/=b.direction.z,p=!1,n=1);if(p)return-1;p=0;k>e&&(p=1,e=k);h>e&&(p=2,e=h);switch(p){case 0:l=b.origin.y+b.direction.y*e;if(lc.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(f,0,0);break;case 1:f=b.origin.x+b.direction.x*e;if(fc.max.x)return Number.MAX_VALUE;b=b.origin.z+b.direction.z* e;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(0,l,0);break;case 2:f=b.origin.x+b.direction.x*e;if(fc.max.x)return Number.MAX_VALUE;l=b.origin.y+b.direction.y*e;if(lc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,n)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),e=c.point.dot(c.normal);if(b<0)b=(e-a.origin.dot(c.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq=0)return Math.abs(e)-Math.sqrt(b);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 c=a.geometry.boundingBox,b=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c}; 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);this.autoUpdateScene=!1;var c=this,b=this.setSize,e=this.render,k=new THREE.PerspectiveCamera,h=new THREE.PerspectiveCamera,f=new THREE.Matrix4,l=new THREE.Matrix4,n,p,t,u;k.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},w=new THREE.WebGLRenderTarget(512,512,a),v=new THREE.WebGLRenderTarget(512,512,a),z=new THREE.PerspectiveCamera(53, 1,1,1E4);z.position.z=2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:w},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 x=new THREE.Scene;x.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));x.add(z);this.setSize=function(a,e){b.call(c,a,e);w.width=a;w.height=e;v.width=a;v.height=e};this.render=function(a,b){a.updateMatrixWorld();if(n!==b.aspect||p!==b.near||t!==b.far||u!==b.fov){n=b.aspect;p=b.near;t=b.far;u=b.fov;var B=b.projectionMatrix.clone(),A=125/30*0.5,C=A*p/125,L=p*Math.tan(u*Math.PI/360),G;f.n14=A;l.n14=-A;A=-L*n+C;G=L*n+C;B.n11=2*p/(G-A);B.n13=(G+A)/(G-A);k.projectionMatrix.copy(B);A=-L*n-C; G=L*n-C;B.n11=2*p/(G-A);B.n13=(G+A)/(G-A);h.projectionMatrix.copy(B)}k.matrixWorld.copy(b.matrixWorld).multiplySelf(l);k.position.copy(b.position);k.near=b.near;k.far=b.far;e.call(c,a,k,w,!0);h.matrixWorld.copy(b.matrixWorld).multiplySelf(f);h.position.copy(b.position);h.near=b.near;h.far=b.far;e.call(c,a,h,v,!0);x.updateMatrixWorld();e.call(c,x,z)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,e=this.render,k,h,f=new THREE.PerspectiveCamera;f.target=new THREE.Vector3(0,0,0);var l=new THREE.PerspectiveCamera;l.target=new THREE.Vector3(0,0,0);c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;this.setSize=function(a,e){b.call(c,a,e);k=a/2;h=e};this.render=function(a,b){this.clear();f.fov=b.fov;f.aspect=0.5*b.aspect;f.near=b.near;f.far= b.far;f.updateProjectionMatrix();f.position.copy(b.position);f.target.copy(b.target);f.translateX(c.separation);f.lookAt(f.target);l.projectionMatrix=f.projectionMatrix;l.position.copy(b.position);l.target.copy(b.target);l.translateX(-c.separation);l.lookAt(l.target);this.setViewport(0,0,k,h);e.call(c,a,f);this.setViewport(k,0,k,h);e.call(c,a,l,!1)}};