// 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,l,h;if(b===0)this.r=this.g=this.b=0;else switch(e=Math.floor(a*6),l=a*6-e,a=b*(1-c),h=b*(1- c*l),c=b*(1-c*(1-l)),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;c=0&&w>=0&&x+w<1}for(var e=new THREE.Vector3,l=new THREE.Vector3,h=new THREE.Vector3,f,k,n,p,v,u,x,w,y,t=[],B=0,A=a.children.length;Ba.scale.x)return[];y={distance:B,point:a.position, face:null,object:a};t.push(y)}else if(a instanceof THREE.Mesh){B=c(this.origin,this.direction,a.matrixWorld.getPosition());if(B===null||B>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return t;var D,C,H,O,T,E,S,K,N=a.geometry,L=N.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);B=0;for(A=N.faces.length;B0:E<0)))if(E=T.dot((new THREE.Vector3).sub(D,S))/E,S=S.addSelf(K.multiplyScalar(E)),y instanceof THREE.Face3)b(S,D,C,H)&&(y={distance:this.origin.distanceTo(S),point:S,face:y,object:a}, t.push(y));else if(y instanceof THREE.Face4&&(b(S,D,C,O)||b(S,C,H,O)))y={distance:this.origin.distanceTo(S),point:S,face:y,object:a},t.push(y)}return t}}; THREE.Rectangle=function(){function a(){h=e-c;f=l-b}var c,b,e,l,h,f,k=!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 l};this.set=function(h,f,v,u){k=!1;c=h;b=f;e=v;l=u;a()};this.addPoint=function(h,f){k?(k=!1,c=h,b=f,e=h,l=f):(c=ch?e:h,l=l>f?l:f);a()};this.add3Points= function(h,f,v,u,x,w){k?(k=!1,c=hv?h>x?h:x:v>x?v:x,l=f>u?f>w?f:w:u>w?u:w):(c=hv?h>x?h>e?h:e:x>e?x:e:v>x?v>e?v:e:x>e?x:e,l=f>u?f>w?f>l?f:l:w>l?w:l:u>w?u>l?u:l:w>l?w:l);a()};this.addRectangle=function(h){k?(k=!1,c=h.getLeft(),b=h.getTop(),e=h.getRight(),l=h.getBottom()):(c=ch.getRight()?e:h.getRight(),l=l> h.getBottom()?l:h.getBottom());a()};this.inflate=function(h){c-=h;b-=h;e+=h;l+=h;a()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();b=b>h.getTop()?b:h.getTop();e=e=0&&Math.min(l,a.getBottom())-Math.max(b,a.getTop())>=0};this.empty=function(){k=!0;l=e=b=c=0;a()};this.isEmpty=function(){return k}}; THREE.Math={clamp:function(a,c,b){return ab?b:a},clampBottom:function(a,c){return a=0&&l>=0&&f>=0&&k>=0?!0:h<0&&l<0||f<0&&k<0?!1:(h<0?c=Math.max(c,h/(h-l)):l<0&&(e=Math.min(e,h/(h-l))),f<0?c=Math.max(c,f/(f-k)):k<0&&(e=Math.min(e,f/(f-k))),ef&&k.positionScreen.z0&&E.z<1))f=H[C]=H[C]||new THREE.RenderableParticle,C++,D=f,D.x=E.x/E.w,D.y=E.y/E.w,D.z=E.z,D.rotation=U.rotation.z,D.scale.x=U.scale.x*Math.abs(D.x-(E.x+h.projectionMatrix.n11)/(E.w+h.projectionMatrix.n14)),D.scale.y=U.scale.y*Math.abs(D.y-(E.y+h.projectionMatrix.n22)/(E.w+h.projectionMatrix.n24)), D.material=U.material,O.elements.push(D);l&&O.elements.sort(b);return O}};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,l=a.z*c,a=Math.cos(e),e=Math.sin(e),c=Math.cos(-l),l=Math.sin(-l),h=Math.cos(b),b=Math.sin(b),f=a*c,k=e*l;this.w=f*h-k*b;this.x=f*b+k*h;this.y=e*c*h+a*l*b;this.z=a*l*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,l=this.w,h=a.x,f=a.y,k=a.z,a=a.w;this.x=c*a+l*h+b*k-e*f;this.y=b*a+l*f+e*h-c*k;this.z=e*a+l*k+c*f-b*h;this.w=l*a-c*h-b*f-e*k;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,l=a.z,h=this.x,f=this.y,k=this.z,n=this.w,p=n*b+f*l-k*e,v=n*e+k*b-h*l,u=n*l+h*e-f*b,b=-h* b-f*e-k*l;c.x=p*n+b*-h+v*-k-u*-f;c.y=v*n+b*-f+u*-h-p*-k;c.z=u*n+b*-k+p*-f-v*-h;return c}}; THREE.Quaternion.slerp=function(a,c,b,e){var l=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;l<0?(b.w=-c.w,b.x=-c.x,b.y=-c.y,b.z=-c.z,l=-l):b.copy(c);if(Math.abs(l)>=1)return b.w=a.w,b.x=a.x,b.y=a.y,b.z=a.z,b;var h=Math.acos(l),l=Math.sqrt(1-l*l);if(Math.abs(l)<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)/l;e=Math.sin(e*h)/l;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,l,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=l instanceof THREE.Color?l:new THREE.Color;this.vertexColors=l instanceof Array?l:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,c,b,e,l,h,f){this.a=a;this.b=c;this.c=b;this.d=e;this.normal=l instanceof THREE.Vector3?l:new THREE.Vector3;this.vertexNormals=l instanceof Array?l:[];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]];v=this.points[b[1]]; u=this.points[b[2]];x=this.points[b[3]];k=f*f;n=f*k;e.x=c(p.x,v.x,u.x,x.x,f,k,n);e.y=c(p.y,v.y,u.y,x.y,f,k,n);e.z=c(p.z,v.z,u.z,x.z,f,k,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),l("rgba("+Math.floor(B.r*255)+","+Math.floor(B.g*255)+","+Math.floor(B.b*255)+","+A+")"),t.fillRect(Math.floor(M.getX()), Math.floor(M.getY()),Math.floor(M.getWidth()),Math.floor(M.getHeight()))),M.empty())};this.render=function(a,v){function u(a){var b,c,e,h;ga.setRGB(0,0,0);ua.setRGB(0,0,0);va.setRGB(0,0,0);b=0;for(c=a.length;b>1,u=p.height>> 1,f=h.scale.x*w,n=h.scale.y*y,k=f*v,o=n*u,ca.set(a.x-k,a.y-o,a.x+k,a.y+o),P.intersects(ca)&&(t.save(),t.translate(a.x,a.y),t.rotate(-h.rotation),t.scale(f,-n),t.translate(-v,-u),t.drawImage(p,0,0),t.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*w,o=h.scale.y*y,ca.set(a.x-k,a.y-o,a.x+k,a.y+o),P.intersects(ca)&&(e(f.color.getContextStyle()),l(f.color.getContextStyle()),t.save(),t.translate(a.x,a.y),t.rotate(-h.rotation),t.scale(k,o),f.program(t),t.restore()))}function Ta(a, h,l,f){c(f.opacity);b(f.blending);t.beginPath();t.moveTo(a.positionScreen.x,a.positionScreen.y);t.lineTo(h.positionScreen.x,h.positionScreen.y);t.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(T!=a)t.lineWidth=T=a;a=f.linecap;if(E!=a)t.lineCap=E=a;a=f.linejoin;if(S!=a)t.lineJoin=S=a;e(f.color.getContextStyle());t.stroke();ca.inflate(f.linewidth*2)}}function A(a,e,f,l,k,p,w,u){h.info.render.vertices+=3;h.info.render.faces++;c(u.opacity);b(u.blending);Y=a.positionScreen.x;V=a.positionScreen.y; o=e.positionScreen.x;Q=e.positionScreen.y;qa=f.positionScreen.x;G=f.positionScreen.y;C(Y,V,o,Q,qa,G);if(u instanceof THREE.MeshBasicMaterial)if(u.map)u.map.mapping instanceof THREE.UVMapping&&(ta=w.uvs[0],Ja(Y,V,o,Q,qa,G,ta[l].u,ta[l].v,ta[k].u,ta[k].v,ta[p].u,ta[p].v,u.map));else if(u.envMap){if(u.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=v.matrixWorldInverse,ha.copy(w.vertexNormalsWorld[l]),pa=(ha.x*a.n11+ha.y*a.n12+ha.z*a.n13)*0.5+0.5,Ca=-(ha.x*a.n21+ha.y*a.n22+ha.z*a.n23)*0.5+ 0.5,ha.copy(w.vertexNormalsWorld[k]),za=(ha.x*a.n11+ha.y*a.n12+ha.z*a.n13)*0.5+0.5,Ba=-(ha.x*a.n21+ha.y*a.n22+ha.z*a.n23)*0.5+0.5,ha.copy(w.vertexNormalsWorld[p]),Ga=(ha.x*a.n11+ha.y*a.n12+ha.z*a.n13)*0.5+0.5,fa=-(ha.x*a.n21+ha.y*a.n22+ha.z*a.n23)*0.5+0.5,Ja(Y,V,o,Q,qa,G,pa,Ca,za,Ba,Ga,fa,u.envMap)}else u.wireframe?D(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):H(u.color);else if(u instanceof THREE.MeshLambertMaterial)u.map&&!u.wireframe&&(u.map.mapping instanceof THREE.UVMapping&& (ta=w.uvs[0],Ja(Y,V,o,Q,qa,G,ta[l].u,ta[l].v,ta[k].u,ta[k].v,ta[p].u,ta[p].v,u.map)),b(THREE.SubtractiveBlending)),ra?!u.wireframe&&u.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length==3?(ia.r=ea.r=la.r=ga.r,ia.g=ea.g=la.g=ga.g,ia.b=ea.b=la.b=ga.b,x(n,w.v1.positionWorld,w.vertexNormalsWorld[0],ia),x(n,w.v2.positionWorld,w.vertexNormalsWorld[1],ea),x(n,w.v3.positionWorld,w.vertexNormalsWorld[2],la),ia.r=Math.max(0,Math.min(u.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(u.color.g*ia.g,1)),ia.b= Math.max(0,Math.min(u.color.b*ia.b,1)),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)),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)),I.r=(ea.r+la.r)*0.5,I.g=(ea.g+la.g)*0.5,I.b=(ea.b+la.b)*0.5,ya=O(ia,ea,la,I),Na(Y,V,o,Q,qa,G,0,0,1,0,0,1,ya)):(da.r=ga.r,da.g=ga.g,da.b=ga.b,x(n,w.centroidWorld,w.normalWorld,da),da.r=Math.max(0,Math.min(u.color.r* da.r,1)),da.g=Math.max(0,Math.min(u.color.g*da.g,1)),da.b=Math.max(0,Math.min(u.color.b*da.b,1)),u.wireframe?D(da,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):H(da)):u.wireframe?D(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):H(u.color);else if(u instanceof THREE.MeshDepthMaterial)ja=v.near,ka=v.far,ia.r=ia.g=ia.b=1-Ma(a.positionScreen.z,ja,ka),ea.r=ea.g=ea.b=1-Ma(e.positionScreen.z,ja,ka),la.r=la.g=la.b=1-Ma(f.positionScreen.z,ja,ka),I.r=(ea.r+la.r)*0.5,I.g= (ea.g+la.g)*0.5,I.b=(ea.b+la.b)*0.5,ya=O(ia,ea,la,I),Na(Y,V,o,Q,qa,G,0,0,1,0,0,1,ya);else if(u instanceof THREE.MeshNormalMaterial)da.r=Oa(w.normalWorld.x),da.g=Oa(w.normalWorld.y),da.b=Oa(w.normalWorld.z),u.wireframe?D(da,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):H(da)}function Ua(a,e,f,l,k,p,w,u,wa){h.info.render.vertices+=4;h.info.render.faces++;c(u.opacity);b(u.blending);if(u.map||u.envMap)A(a,e,l,0,1,3,w,u,wa),A(k,f,p,1,2,3,w,u,wa);else if(Y=a.positionScreen.x,V=a.positionScreen.y, o=e.positionScreen.x,Q=e.positionScreen.y,qa=f.positionScreen.x,G=f.positionScreen.y,W=l.positionScreen.x,Z=l.positionScreen.y,na=k.positionScreen.x,ma=k.positionScreen.y,sa=p.positionScreen.x,U=p.positionScreen.y,u instanceof THREE.MeshBasicMaterial)Pa(Y,V,o,Q,qa,G,W,Z),u.wireframe?D(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):H(u.color);else if(u instanceof THREE.MeshLambertMaterial)ra?!u.wireframe&&u.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length==4?(ia.r=ea.r= la.r=I.r=ga.r,ia.g=ea.g=la.g=I.g=ga.g,ia.b=ea.b=la.b=I.b=ga.b,x(n,w.v1.positionWorld,w.vertexNormalsWorld[0],ia),x(n,w.v2.positionWorld,w.vertexNormalsWorld[1],ea),x(n,w.v4.positionWorld,w.vertexNormalsWorld[3],la),x(n,w.v3.positionWorld,w.vertexNormalsWorld[2],I),ia.r=Math.max(0,Math.min(u.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(u.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(u.color.b*ia.b,1)),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)),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)),I.r=Math.max(0,Math.min(u.color.r*I.r,1)),I.g=Math.max(0,Math.min(u.color.g*I.g,1)),I.b=Math.max(0,Math.min(u.color.b*I.b,1)),ya=O(ia,ea,la,I),C(Y,V,o,Q,W,Z),Na(Y,V,o,Q,W,Z,0,0,1,0,0,1,ya),C(na,ma,qa,G,sa,U),Na(na,ma,qa,G,sa,U,1,0,1,1,0,1,ya)):(da.r=ga.r,da.g=ga.g,da.b=ga.b,x(n,w.centroidWorld,w.normalWorld,da),da.r=Math.max(0,Math.min(u.color.r* da.r,1)),da.g=Math.max(0,Math.min(u.color.g*da.g,1)),da.b=Math.max(0,Math.min(u.color.b*da.b,1)),Pa(Y,V,o,Q,qa,G,W,Z),u.wireframe?D(da,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):H(da)):(Pa(Y,V,o,Q,qa,G,W,Z),u.wireframe?D(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):H(u.color));else if(u instanceof THREE.MeshNormalMaterial)da.r=Oa(w.normalWorld.x),da.g=Oa(w.normalWorld.y),da.b=Oa(w.normalWorld.z),Pa(Y,V,o,Q,qa,G,W,Z),u.wireframe?D(da,u.wireframeLinewidth,u.wireframeLinecap, u.wireframeLinejoin):H(da);else if(u instanceof THREE.MeshDepthMaterial)ja=v.near,ka=v.far,ia.r=ia.g=ia.b=1-Ma(a.positionScreen.z,ja,ka),ea.r=ea.g=ea.b=1-Ma(e.positionScreen.z,ja,ka),la.r=la.g=la.b=1-Ma(l.positionScreen.z,ja,ka),I.r=I.g=I.b=1-Ma(f.positionScreen.z,ja,ka),ya=O(ia,ea,la,I),C(Y,V,o,Q,W,Z),Na(Y,V,o,Q,W,Z,0,0,1,0,0,1,ya),C(na,ma,qa,G,sa,U),Na(na,ma,qa,G,sa,U,1,0,1,1,0,1,ya)}function C(a,b,c,e,h,f){t.beginPath();t.moveTo(a,b);t.lineTo(c,e);t.lineTo(h,f);t.lineTo(a,b);t.closePath()}function Pa(a, b,c,e,h,f,l,k){t.beginPath();t.moveTo(a,b);t.lineTo(c,e);t.lineTo(h,f);t.lineTo(l,k);t.lineTo(a,b);t.closePath()}function D(a,b,c,h){if(T!=b)t.lineWidth=T=b;if(E!=c)t.lineCap=E=c;if(S!=h)t.lineJoin=S=h;e(a.getContextStyle());t.stroke();ca.inflate(b*2)}function H(a){l(a.getContextStyle());t.fill()}function Ja(a,b,c,e,h,f,k,o,n,u,p,w,v){if(v.image.width!=0){if(v.needsUpdate==!0||R[v.id]==void 0){var wa=v.wrapS==THREE.RepeatWrapping,x=v.wrapT==THREE.RepeatWrapping;R[v.id]=t.createPattern(v.image,wa&& x?"repeat":wa&&!x?"repeat-x":!wa&&x?"repeat-y":"no-repeat");v.needsUpdate=!1}l(R[v.id]);var wa=v.offset.x/v.repeat.x,x=v.offset.y/v.repeat.y,fa=(v.image.width-1)*v.repeat.x,v=(v.image.height-1)*v.repeat.y,k=(k+wa)*fa,o=(o+x)*v,n=(n+wa)*fa,u=(u+x)*v,p=(p+wa)*fa,w=(w+x)*v;c-=a;e-=b;h-=a;f-=b;n-=k;u-=o;p-=k;w-=o;wa=1/(n*w-p*u);v=(w*c-u*h)*wa;u=(w*e-u*f)*wa;c=(n*h-p*c)*wa;e=(n*f-p*e)*wa;a=a-v*k-c*o;b=b-u*k-e*o;t.save();t.transform(v,u,c,e,a,b);t.fill();t.restore()}}function Na(a,b,c,e,h,f,l,k,o,n,u,p, w){var v,wa;v=w.width-1;wa=w.height-1;l*=v;k*=wa;o*=v;n*=wa;u*=v;p*=wa;c-=a;e-=b;h-=a;f-=b;o-=l;n-=k;u-=l;p-=k;wa=1/(o*p-u*n);v=(p*c-n*h)*wa;n=(p*e-n*f)*wa;c=(o*h-u*c)*wa;e=(o*f-u*e)*wa;a=a-v*l-c*k;b=b-n*l-e*k;t.save();t.transform(v,n,c,e,a,b);t.clip();t.drawImage(w,0,0);t.restore()}function O(a,b,c,e){var h=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),l=~~(b.r*255),k=~~(b.g*255),b=~~(b.b*255),o=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),u=~~(e.r*255),p=~~(e.g*255),e=~~(e.b*255);xa[0]=h<0?0:h>255?255:h;xa[1]= f<0?0:f>255?255:f;xa[2]=a<0?0:a>255?255:a;xa[4]=l<0?0:l>255?255:l;xa[5]=k<0?0:k>255?255:k;xa[6]=b<0?0:b>255?255:b;xa[8]=o<0?0:o>255?255:o;xa[9]=n<0?0:n>255?255:n;xa[10]=c<0?0:c>255?255:c;xa[12]=u<0?0:u>255?255:u;xa[13]=p<0?0:p>255?255:p;xa[14]=e<0?0:e>255?255:e;Ia.putImageData(Da,0,0);La.drawImage(Fa,0,0);return Ea}function Ma(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Oa(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Ka(a,b){var c=b.x-a.x,e=b.y-a.y,h=c*c+e*e;h!=0&&(h=1/Math.sqrt(h),c*=h,e*=h, b.x+=c,b.y+=e,a.x-=c,a.y-=e)}var Qa,Sa,Aa,Ha;this.autoClear?this.clear():t.setTransform(1,0,0,-1,w,y);h.info.render.vertices=0;h.info.render.faces=0;f=p.projectScene(a,v,this.sortElements);k=f.elements;n=f.lights;(ra=n.length>0)&&u(n);Qa=0;for(Sa=k.length;Qa1?1:a}var e=this,l,h,f,k=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,v,u,x,w,y,t,B,A=new THREE.Rectangle,D=new THREE.Rectangle,C=!1,H=new THREE.Color,O=new THREE.Color,T=new THREE.Color,E=new THREE.Color,S,K=new THREE.Vector3,N=[],L=[],J,X,oa,Y=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":Y=1;break;case "low":Y=0}};this.setSize=function(a,b){p=a;v=b;u=p/2;x=v/2;n.setAttribute("viewBox",-u+" "+-x+" "+p+" "+v);n.setAttribute("width",p);n.setAttribute("height",v);A.set(-u,-x,u,x)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(p,o){var v,K,G,W;this.autoClear&&this.clear();e.info.render.vertices=0;e.info.render.faces=0;l=k.projectScene(p,o,this.sortElements);h=l.elements; f=l.lights;oa=X=0;if(C=f.length>0){O.setRGB(0,0,0);T.setRGB(0,0,0);E.setRGB(0,0,0);v=0;for(K=f.length;v 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,l={};for(c=0;c=0)return a.geometry.materials[b.materialIndex]}function e(a,b,c){var e,h,f,l=a.vertices,k=l.length,n=a.colors,u=n.length,p=a.__vertexArray,w=a.__colorArray,v=a.__sortArray,t=a.__dirtyVertices,x=a.__dirtyColors,fa=a.__webglCustomAttributesList;if(c.sortParticles){Ca.multiplySelf(c.matrixWorld);for(e=0;e=0)a&&(o.bindBuffer(o.ARRAY_BUFFER,f.__webglVertexBuffer),o.vertexAttribPointer(b.position,3,o.FLOAT,!1,0,0));else if(h.morphTargetBase){c=e.program.attributes;h.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER, f.__webglMorphTargetsBuffers[h.morphTargetBase]),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0)):c.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,f.__webglVertexBuffer),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0));if(h.morphTargetForcedOrder.length){k=0;var u=h.morphTargetForcedOrder;for(n=h.morphTargetInfluences;kp&&(w=v,p=n[w]);o.bindBuffer(o.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[w]);o.vertexAttribPointer(c["morphTarget"+k],3,o.FLOAT,!1,0,0);h.__webglMorphTargetInfluences[k]=p;u[w]=1;p=-1;k++}}e.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(e.program.uniforms.morphTargetInfluences,h.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){k= 0;for(n=f.__webglCustomAttributesList.length;k=0&&(o.bindBuffer(o.ARRAY_BUFFER,c.buffer),o.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,o.FLOAT,!1,0,0))}b.color>=0&&(o.bindBuffer(o.ARRAY_BUFFER,f.__webglColorBuffer),o.vertexAttribPointer(b.color,3,o.FLOAT,!1,0,0));b.normal>=0&&(o.bindBuffer(o.ARRAY_BUFFER,f.__webglNormalBuffer),o.vertexAttribPointer(b.normal,3,o.FLOAT,!1,0,0));b.tangent>=0&&(o.bindBuffer(o.ARRAY_BUFFER, f.__webglTangentBuffer),o.vertexAttribPointer(b.tangent,4,o.FLOAT,!1,0,0));b.uv>=0&&(f.__webglUVBuffer?(o.bindBuffer(o.ARRAY_BUFFER,f.__webglUVBuffer),o.vertexAttribPointer(b.uv,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv)):o.disableVertexAttribArray(b.uv));b.uv2>=0&&(f.__webglUV2Buffer?(o.bindBuffer(o.ARRAY_BUFFER,f.__webglUV2Buffer),o.vertexAttribPointer(b.uv2,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv2)):o.disableVertexAttribArray(b.uv2));e.skinning&&b.skinVertexA>=0&&b.skinVertexB>= 0&&b.skinIndex>=0&&b.skinWeight>=0&&(o.bindBuffer(o.ARRAY_BUFFER,f.__webglSkinVertexABuffer),o.vertexAttribPointer(b.skinVertexA,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),o.vertexAttribPointer(b.skinVertexB,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),o.vertexAttribPointer(b.skinIndex,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),o.vertexAttribPointer(b.skinWeight,4,o.FLOAT,!1,0,0))}h instanceof THREE.Mesh?(e.wireframe? (e=e.wireframeLinewidth,e!==R&&(o.lineWidth(e),R=e),a&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),o.drawElements(o.LINES,f.__webglLineCount,o.UNSIGNED_SHORT,0)):(a&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),o.drawElements(o.TRIANGLES,f.__webglFaceCount,o.UNSIGNED_SHORT,0)),V.info.render.calls++,V.info.render.vertices+=f.__webglFaceCount,V.info.render.faces+=f.__webglFaceCount/3):h instanceof THREE.Line?(h=h.type===THREE.LineStrip?o.LINE_STRIP:o.LINES,e=e.linewidth,e!== R&&(o.lineWidth(e),R=e),o.drawArrays(h,0,f.__webglLineCount),V.info.render.calls++):h instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,f.__webglParticleCount),V.info.render.calls++):h instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,0,f.__webglVertexCount),V.info.render.calls++)}}function f(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,h,l,k,n,u,p,w,v,t=a.count*3;for(v=0;v=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 t(a,b){return b.z-a.z}function B(a){var b,c,e,p=0,w,v,t,y,fa=a.lights;ha||(ha=new THREE.PerspectiveCamera(V.shadowCameraFov,V.shadowMapWidth/V.shadowMapHeight,V.shadowCameraNear,V.shadowCameraFar));b=0;for(c= fa.length;b=0;c--)a[c].object=== b&&a.splice(c,1)}function T(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function E(a){if(a!==U){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)}U=a}}function S(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,oa(b.magFilter)), o.texParameteri(a,o.TEXTURE_MIN_FILTER,oa(b.minFilter)))}function K(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=o.createTexture(),V.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);S(o.TEXTURE_2D,a,a.image);a.needsUpdate= !1}else o.activeTexture(o.TEXTURE0+b),o.bindTexture(o.TEXTURE_2D,a.__webglTexture)}function N(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 L(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);S(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);N(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=o.createFramebuffer(),a.__webglRenderbuffer=o.createRenderbuffer(),o.bindTexture(o.TEXTURE_2D,a.__webglTexture),S(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),N(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=ya,a=ta,e=ja,f=ka);b!==G&&(o.bindFramebuffer(o.FRAMEBUFFER,b),o.viewport(e,f,c,a),G=b)}function J(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 X(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 oa(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 V=this,o,Q=[],qa=null,G=null,W=-1,Z=null,na=0,ma=null,sa=null,U=null,da=null,ia=null,ea=null,la=null,I=null,R=null,ja=0,ka=0,ya=0,ta=0,pa=[new THREE.Vector4,new THREE.Vector4, new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ca=new THREE.Matrix4,za=new Float32Array(16),Ba=new Float32Array(16),Ga=new THREE.Vector4,fa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},P=a.canvas!==void 0?a.canvas:document.createElement("canvas"),M=a.stencil!==void 0?a.stencil:!0,ca=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,ra=a.antialias!==void 0?a.antialias:!1,ga=a.clearColor!== void 0?new THREE.Color(a.clearColor):new THREE.Color(0),ua=a.clearAlpha!==void 0?a.clearAlpha:0,va=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=P;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 ha,Fa=[],a=THREE.ShaderLib.depthRGBA,Ia=THREE.UniformsUtils.clone(a.uniforms),Da=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:Ia}),xa=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:Ia,morphTargets:!0}); Da._shadowPass=!0;xa._shadowPass=!0;try{if(!(o=P.getContext("experimental-webgl",{antialias:ra,stencil:M,preserveDrawingBuffer:ca})))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(Ea){console.error(Ea)}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(ga.r,ga.g,ga.b,ua);this.context=o;var La=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,$={};$.vertices=new Float32Array(16);$.faces=new Uint16Array(6);M=0;$.vertices[M++]=-1;$.vertices[M++]=-1;$.vertices[M++]=0;$.vertices[M++]=1;$.vertices[M++]=1;$.vertices[M++]=-1;$.vertices[M++]=1;$.vertices[M++]=1;$.vertices[M++]=1;$.vertices[M++]=1;$.vertices[M++]=1;$.vertices[M++]= 0;$.vertices[M++]=-1;$.vertices[M++]=1;$.vertices[M++]=0;M=$.vertices[M++]=0;$.faces[M++]=0;$.faces[M++]=1;$.faces[M++]=2;$.faces[M++]=0;$.faces[M++]=2;$.faces[M++]=3;$.vertexBuffer=o.createBuffer();$.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,$.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,$.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,$.elementBuffer);o.bufferData(o.ELEMENT_ARRAY_BUFFER,$.faces,o.STATIC_DRAW);$.program=o.createProgram();o.attachShader($.program,X("fragment", THREE.ShaderLib.sprite.fragmentShader));o.attachShader($.program,X("vertex",THREE.ShaderLib.sprite.vertexShader));o.linkProgram($.program);$.attributes={};$.uniforms={};$.attributes.position=o.getAttribLocation($.program,"position");$.attributes.uv=o.getAttribLocation($.program,"uv");$.uniforms.uvOffset=o.getUniformLocation($.program,"uvOffset");$.uniforms.uvScale=o.getUniformLocation($.program,"uvScale");$.uniforms.rotation=o.getUniformLocation($.program,"rotation");$.uniforms.scale=o.getUniformLocation($.program, "scale");$.uniforms.alignment=o.getUniformLocation($.program,"alignment");$.uniforms.color=o.getUniformLocation($.program,"color");$.uniforms.map=o.getUniformLocation($.program,"map");$.uniforms.opacity=o.getUniformLocation($.program,"opacity");$.uniforms.useScreenCoordinates=o.getUniformLocation($.program,"useScreenCoordinates");$.uniforms.affectedByDistance=o.getUniformLocation($.program,"affectedByDistance");$.uniforms.screenPosition=o.getUniformLocation($.program,"screenPosition");$.uniforms.modelViewMatrix= o.getUniformLocation($.program,"modelViewMatrix");$.uniforms.projectionMatrix=o.getUniformLocation($.program,"projectionMatrix");var Ra=!1;this.setSize=function(a,b){P.width=a;P.height=b;this.setViewport(0,0,P.width,P.height)};this.setViewport=function(a,b,c,e){ja=a;ka=b;ya=c;ta=e;o.viewport(ja,ka,ya,ta)};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){ga.setHex(a);ua= b;o.clearColor(ga.r,ga.g,ga.b,ua)};this.setClearColor=function(a,b){ga.copy(a);ua=b;o.clearColor(ga.r,ga.g,ga.b,ua)};this.getClearColor=function(){return ga};this.getClearAlpha=function(){return ua};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(t.position);t.color>=0&&o.enableVertexAttribArray(t.color);t.normal>=0&&o.enableVertexAttribArray(t.normal); t.tangent>=0&&o.enableVertexAttribArray(t.tangent);a.skinning&&t.skinVertexA>=0&&t.skinVertexB>=0&&t.skinIndex>=0&&t.skinWeight>=0&&(o.enableVertexAttribArray(t.skinVertexA),o.enableVertexAttribArray(t.skinVertexB),o.enableVertexAttribArray(t.skinIndex),o.enableVertexAttribArray(t.skinWeight));if(a.attributes)for(h in a.attributes)t[h]!==void 0&&t[h]>=0&&o.enableVertexAttribArray(t[h]);if(a.morphTargets)for(h=a.numSupportedMorphTargets=0;h=0&&(o.enableVertexAttribArray(t[y]), a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,b,c,e){L(a);this.clear(b,c,e)};this.updateShadowMap=function(a,b){B(a,b)};this.render=function(a,b,c,e){var fa,M,C,P,H,ca,Ja,I=a.lights,ga=a.fog;W=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&B(a,b);V.info.render.calls=0;V.info.render.vertices=0;V.info.render.faces=0;b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."), a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(Ba);b.projectionMatrix.flattenToArray(za);Ca.multiply(b.projectionMatrix,b.matrixWorldInverse);u(Ca);L(c);(this.autoClear||e)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);C=a.__webglObjects.length;for(e=0;e=0;e--)if(H=a.__webglObjects[e],H.render&&(ca=H.object,Ja=H.buffer,M=H.opaque))k(ca),n(M.depthTest),p(M.depthWrite), v(M.polygonOffset,M.polygonOffsetFactor,M.polygonOffsetUnits),h(b,I,ga,M,Ja,ca);for(e=0;e65535&&(M[x].counter+=1,y=M[x].hash+"_"+M[x].counter,n.geometryGroups[y]===void 0&&(n.geometryGroups[y]={faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:fa})),u instanceof THREE.Face3?n.geometryGroups[y].faces3.push(w):n.geometryGroups[y].faces4.push(w),n.geometryGroups[y].vertices+=t;n.geometryGroupsList=[];w=void 0;for(w in n.geometryGroups)n.geometryGroups[w].id=na++,n.geometryGroupsList.push(n.geometryGroups[w])}for(l in k.geometryGroups)if(n=k.geometryGroups[l],!n.__webglVertexBuffer){w= n;w.__webglVertexBuffer=o.createBuffer();w.__webglNormalBuffer=o.createBuffer();w.__webglTangentBuffer=o.createBuffer();w.__webglColorBuffer=o.createBuffer();w.__webglUVBuffer=o.createBuffer();w.__webglUV2Buffer=o.createBuffer();w.__webglSkinVertexABuffer=o.createBuffer();w.__webglSkinVertexBBuffer=o.createBuffer();w.__webglSkinIndicesBuffer=o.createBuffer();w.__webglSkinWeightsBuffer=o.createBuffer();w.__webglFaceBuffer=o.createBuffer();w.__webglLineBuffer=o.createBuffer();if(w.numMorphTargets){u= p=void 0;w.__webglMorphTargetsBuffers=[];p=0;for(u=w.numMorphTargets;p0||t.faceVertexUvs.length>0)n.__uvArray=new Float32Array(w*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)n.__uv2Array=new Float32Array(w*2)}if(v.geometry.skinWeights.length&&v.geometry.skinIndices.length)n.__skinVertexAArray=new Float32Array(w* 4),n.__skinVertexBArray=new Float32Array(w*4),n.__skinIndexArray=new Float32Array(w*4),n.__skinWeightArray=new Float32Array(w*4);n.__faceArray=new Uint16Array(u*3);n.__lineArray=new Uint16Array(x*2);if(n.numMorphTargets){n.__morphTargetsArrays=[];v=0;for(t=n.numMorphTargets;v=0;k--)h[k]===l&&h.splice(k,1)}else(f instanceof THREE.MarchingCubes|| f.immediateRenderCallback)&&O(h.__webglObjectsImmediate,f);f.__webglActive=!1;a.__objectsRemoved.splice(0,1)}f=0;for(h=a.__webglObjects.length;f0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,ra,u),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,ja,u),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ga,u),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,ea,u))}if(Ia&&L){t=0;for(x=M.length;t0&&(o.bindBuffer(o.ARRAY_BUFFER, p.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,S,u))}if(sa&&va.hasTangents){t=0;for(x=M.length;t0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,la,u))}if(oa&& Ca&&W){t=0;for(x=M.length;t0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,F,u))}if(ia){t=0;for(x=M.length;t1&&(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,l=a.vertices.length,h=c instanceof THREE.Mesh?c.geometry:c,f=a.vertices,k=h.vertices,n=a.faces,p=h.faces,v=a.faceVertexUvs[0],u=h.faceVertexUvs[0],x={},w=0;w1&&(e=1-e,l=1-l);h=1-e-l;f.copy(a);f.multiplyScalar(e);k.copy(c);k.multiplyScalar(l);f.addSelf(k);k.copy(b);k.multiplyScalar(h);f.addSelf(k);return f},randomPointInFace:function(a,c,b){var e,l,h;if(a instanceof THREE.Face3)return e=c.vertices[a.a].position,l=c.vertices[a.b].position, h=c.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(e,l,h);else if(a instanceof THREE.Face4){e=c.vertices[a.a].position;l=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,l,c),f=THREE.GeometryUtils.triangleArea(l,h,c),a._area1=b,a._area2=f):(b=THREE.GeometryUtils.triangleArea(e,l,c),f=THREE.GeometryUtils.triangleArea(l,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),l,h=0;c.push(0);for(l=1;l<=a;l++)b=this.getPoint(l/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,l=b.length,h;h=c?c:a*b[l-1];time=Date.now();for(var f=0,k=l-1,n;f<=k;)if(e=Math.floor(f+(k-f)/2),n=b[e]-h,n<0)f=e+1;else if(n>0)k=e-1;else{k=e;break}e=k;if(b[e]==h)return e/(l-1);f=b[e];return b=(e+(h-f)/(b[e+1]-f))/(l-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 l=Array.prototype.slice.call(arguments),a=new THREE.Vector2(l[0],l[1]),c=new THREE.Vector2(l[2],l[3]),b=new THREE.Vector2(l[4],l[5]),e=new THREE.Vector2(l[6],l[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,l;l=(e.length-1)*a;a=Math.floor(l);l-=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,l);c.y=THREE.Curve.Utils.interpolate(e[b[0]].y,e[b[1]].y,e[b[2]].y,e[b[3]].y,l);return c};THREE.ArcCurve=function(a,c,b,e,l,h){this.aX=a;this.aY=c;this.aRadius=b;this.aStartAngle=e;this.aEndAngle=l;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,l){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*l},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,l){var a=(b-a)*0.5,e=(e-c)*0.5,h=l*l;return(2*c-2*b+a+e)*l*h+(-3*c+3*b-2*a-e)*h+a*l+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,l;l=(e.length-1)*a;a=Math.floor(l);l-=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,l);c.y=THREE.Curve.Utils.interpolate(e[b[0]].y,e[b[1]].y,e[b[2]].y,e[b[3]].y,l);c.z=THREE.Curve.Utils.interpolate(e[b[0]].z,e[b[1]].z,e[b[2]].z,e[b[3]].z,l);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],w=f.x,y=f.y):(f=this.actions[e-1].args,w=f[f.length-2],y=f[f.length-1]);for(f=1;f<=a;f++)t=f/a,h=THREE.Shape.Utils.b2(t,w,u,k),t=THREE.Shape.Utils.b2(t,y,x, n),b.push(new THREE.Vector2(h,t));break;case THREE.PathActions.BEZIER_CURVE_TO:k=h[4];n=h[5];u=h[0];x=h[1];p=h[2];v=h[3];b.length>0?(f=b[b.length-1],w=f.x,y=f.y):(f=this.actions[e-1].args,w=f[f.length-2],y=f[f.length-1]);for(f=1;f<=a;f++)t=f/a,h=THREE.Shape.Utils.b3(t,w,u,p,k),t=THREE.Shape.Utils.b3(t,y,x,v,n),b.push(new THREE.Vector2(h,t));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[e-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];t=a*h[0].length;f=f.concat(h[0]);h=new THREE.SplineCurve(f); for(f=1;f<=t;f++)b.push(h.getPointAt(f/t));break;case THREE.PathActions.ARC:f=this.actions[e-1].args;k=h[0];n=h[1];p=h[2];u=h[3];t=h[4];x=!!h[5];v=f[f.length-2];w=f[f.length-1];f.length==0&&(v=w=0);y=t-u;var B=a*2;for(f=1;f<=B;f++)t=f/B,x||(t=1-t),t=u+t*y,h=v+k+p*Math.cos(t),t=w+n+p*Math.sin(t),b.push(new THREE.Vector2(h,t))}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,l,h){var f=this.getPoints(),k,n,p,v,u;k=0;for(n=f.length;k=0?k-1:b.length-1;h=f-1>=0?f-1:p.length-1;var t=[p[f],b[k],b[l]];u=THREE.FontUtils.Triangulate.area(t);var B=[p[f],p[h],b[k]];x=THREE.FontUtils.Triangulate.area(B);w=k;v=f;k+=1;f+=-1;k< 0&&(k+=b.length);k%=b.length;f<0&&(f+=p.length);f%=p.length;l=k-1>=0?k-1:b.length-1;h=f-1>=0?f-1:p.length-1;t=[p[f],b[k],b[l]];t=THREE.FontUtils.Triangulate.area(t);B=[p[f],p[h],b[k]];B=THREE.FontUtils.Triangulate.area(B);u+x>t+B&&(k=w,f=v,k<0&&(k+=b.length),k%=b.length,f<0&&(f+=p.length),f%=p.length,l=k-1>=0?k-1:b.length-1,h=f-1>=0?f-1:p.length-1);u=b.slice(0,k);x=b.slice(k);w=p.slice(f);v=p.slice(0,f);h=[p[f],p[h],b[k]];y.push([p[f],b[k],b[l]]);y.push(h);b=u.concat(w).concat(v).concat(x)}return{shape:b, isolatedPts:y,allpoints:e}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),e=b.allpoints,l=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),h,f,k,n,p={};h=0;for(f=e.length;h1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+w),e=e<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=l[0]+(h[0]-l[0])*e,b.y=l[1]+(h[1]-l[1])*e,b.z=l[2]+(h[2]-l[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",w,f.index-1).pos,this.points[1]=l,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",w,k.index+1).pos,e=e*0.33+0.33,l=this.interpolateCatmullRom(this.points,e),b.x=l[0],b.y=l[1],b.z=l[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(l,h,a.quaternion,e);else if(b==="scl")b=a.scale,b.x=l[0]+(h[0]-l[0])*e,b.y=l[1]+(h[1]-l[1])*e,b.z=l[2]+(h[2]-l[2])*e}}if(this.JITCompile&&v[0][p]===void 0){this.hierarchy[0].update(null,!0);for(w=0;wa.length-2?h:h+1;b[3]=h>a.length-3?h:h+2;h=a[b[0]];k=a[b[1]];n=a[b[2]];p=a[b[3]];b=l*l;f=l*b;e[0]=this.interpolate(h[0],k[0],n[0],p[0],l,b,f);e[1]=this.interpolate(h[1],k[1],n[1],p[1],l,b,f);e[2]=this.interpolate(h[2],k[2],n[2],p[2],l,b,f);return e}; THREE.Animation.prototype.interpolate=function(a,c,b,e,l,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*l+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,l,h,f){THREE.Camera.call(this);this.fov=b;this.left=-a/2;this.right=a/2;this.top=c/2;this.bottom=-c/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,c/2,c/-2,h,f);this.cameraP=new THREE.PerspectiveCamera(b,a/c,e,l);this.zoom=1;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.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPersepectiveMode=!0;this.inOrthographicMode=!1}; THREE.CombinedCamera.prototype.toOrthographic=function(){var a=Math.tan(this.fov/2)*((this.cameraP.near+this.cameraP.far)/2),c=2*a*this.cameraP.aspect/2;a/=this.zoom;c/=this.zoom;this.cameraO.left=-c;this.cameraO.right=c;this.cameraO.top=a;this.cameraO.bottom=-a;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPersepectiveMode=!1;this.inOrthographicMode=!0}; THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};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.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()}; THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1}; THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1}; 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 l(a,b,c,e){var f={name:c,fps:0.6,length:e,hierarchy:[]},h,l=b.getControlPointsArray(),k=b.getLength(),B=l.length,A=0;h=B-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:l[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[h]={time:e,pos:l[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=l(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=l(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),k=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(c,k);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);k=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,l=new THREE.Vector3,h=new THREE.Matrix4,f=!1,k=1,n=0,p=0,v=0,u=0,x=0,w=window.innerWidth/2,y=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var c=a*this.lookSpeed; this.rotateHorizontally(c*u);this.rotateVertically(c*x)}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*v);f&&(this.roll+=this.rollSpeed*a*k);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(k.dot(n)/k.length()/n.length());if(a){var c=(new THREE.Vector3).cross(k,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?k=n:(e.setFromAxisAngle(c,a*(b.dynamicDampingFactor-1)),e.multiplyVector3(k))}};this.zoomCamera=function(){var a=1+(v.y-p.y)*b.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),b.staticMoving?p=v:p.y+=(v.y-p.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=x.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=x:u.addSelf(a.sub(x,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(k=0;k0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(k=0;ka&&(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 l(a){for(L=a.length;--L>=0;){na=L;ma=L-1;ma<0&&(ma=a.length- 1);for(var b=0,c=w+v*2,b=0;b=0;X--){oa=X/v;Y=n*(1-oa);oa=p*Math.sin(oa*Math.PI/2);L=0;for(J=D.length;L0||(v=this.vertices.push(new THREE.Vertex(new THREE.Vector3(u,k,x)))-1);p.push(v)}c.push(p)}for(var w,y,t,l=c.length,b=0;b0)for(e=0;e1&&(w= this.vertices[f].position.clone(),y=this.vertices[n].position.clone(),t=this.vertices[p].position.clone(),w.normalize(),y.normalize(),t.normalize(),this.faces.push(new THREE.Face3(f,n,p,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(t.x,t.y,t.z)])),this.faceVertexUvs[0].push([v,u,B]))}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,l=String(a).split(""),h=l.length,f=[],a=0;a0)for(p=0;p2;){if(u--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return h}n=p;l<=n&&(n=0);p=n+1;l<=p&&(p=0);v=p+1;l<=v&&(v=0);var x;a:{x=a;var w=n,y=p,t=v,B=l,A=f,D=void 0,C=void 0,H=void 0, O=void 0,T=void 0,E=void 0,S=void 0,K=void 0,N=void 0,C=x[A[w]].x,H=x[A[w]].y,O=x[A[y]].x,T=x[A[y]].y,E=x[A[t]].x,S=x[A[t]].y;if(1.0E-10>(O-C)*(S-H)-(T-H)*(E-C))x=!1;else{for(D=0;D=0&&X>=0&&Y>=0){x=!1;break a}}x= !0}}if(x){h.push([a[f[n]],a[f[p]],a[f[v]]]);k.push([f[n],f[p],f[v]]);n=p;for(v=p+1;v0;)this.smooth(a)}; THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,e,k,n){var p=new THREE.Face4(a,b,c,e,null,k.color,k.material);if(f.useOldVertexColors){p.vertexColors=[];for(var t,w,u,v=0;v<4;v++){u=n[v];t=new THREE.Color;t.setRGB(0,0,0);for(var y=0;y>7)-127;e|=(h&127)<<16|f<<8;if(e==0&&l==-127)return 0;return(1-2*(k>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,l)}function k(a,b){var c=v(a,b),e=v(a,b+1),f=v(a,b+2);return(v(a,b+3)<<24)+(f<<16)+(e<<8)+c}function l(a,b){var c=v(a,b);return(v(a,b+1)<<8)+c}function p(a,b){var c=v(a,b);return c>127?c-256:c}function v(a,b){return a.charCodeAt(b)&255}function u(b){var c, e,f;c=k(a,b);e=k(a,b+T);f=k(a,b+E);b=l(a,b+S);A.faces.push(new THREE.Face3(c,e,f,null,null,b))}function x(b){var c,e,f,h,o,p,t;c=k(a,b);e=k(a,b+T);f=k(a,b+E);h=l(a,b+S);o=k(a,b+K);p=k(a,b+N);t=k(a,b+L);var b=H[p*3],u=H[p*3+1];p=H[p*3+2];var w=H[t*3],v=H[t*3+1];t=H[t*3+2];A.faces.push(new THREE.Face3(c,e,f,[new THREE.Vector3(H[o*3],H[o*3+1],H[o*3+2]),new THREE.Vector3(b,u,p),new THREE.Vector3(w,v,t)],null,h))}function w(b){var c,e,f,h;c=k(a,b);e=k(a,b+J);f=k(a,b+X);h=k(a,b+oa);b=l(a,b+Y);A.faces.push(new THREE.Face4(c, e,f,h,null,null,b))}function y(b){var c,e,f,h,p,t,u,w,v;c=k(a,b);e=k(a,b+J);f=k(a,b+X);h=k(a,b+oa);p=l(a,b+Y);t=k(a,b+V);u=k(a,b+o);w=k(a,b+Q);v=k(a,b+qa);var b=H[u*3],x=H[u*3+1];u=H[u*3+2];var fa=H[w*3],P=H[w*3+1];w=H[w*3+2];var M=H[v*3],y=H[v*3+1];v=H[v*3+2];A.faces.push(new THREE.Face4(c,e,f,h,[new THREE.Vector3(H[t*3],H[t*3+1],H[t*3+2]),new THREE.Vector3(b,x,u),new THREE.Vector3(fa,P,w),new THREE.Vector3(M,y,v)],null,p))}function t(b){var c,e,f,h;c=k(a,b);e=k(a,b+G);f=k(a,b+W);b=O[c*2];h=O[c* 2+1];c=O[e*2];var l=A.faceVertexUvs[0];e=O[e*2+1];var n=O[f*2];f=O[f*2+1];var o=[];o.push(new THREE.UV(b,h));o.push(new THREE.UV(c,e));o.push(new THREE.UV(n,f));l.push(o)}function B(b){var c,e,f,h,l,n;c=k(a,b);e=k(a,b+Z);f=k(a,b+na);h=k(a,b+ma);b=O[c*2];l=O[c*2+1];c=O[e*2];n=O[e*2+1];e=O[f*2];var o=A.faceVertexUvs[0];f=O[f*2+1];var p=O[h*2];h=O[h*2+1];var t=[];t.push(new THREE.UV(b,l));t.push(new THREE.UV(c,n));t.push(new THREE.UV(e,f));t.push(new THREE.UV(p,h));o.push(t)}var A=this,D=0,C,H=[],O= [],T,E,S,K,N,L,J,X,oa,Y,V,o,Q,qa,G,W,Z,na,ma,sa,U,da,ia,ea,la;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(A,e,b);C={signature:a.substr(D,8),header_bytes:v(a,D+8),vertex_coordinate_bytes:v(a,D+9),normal_coordinate_bytes:v(a,D+10),uv_coordinate_bytes:v(a,D+11),vertex_index_bytes:v(a,D+12),normal_index_bytes:v(a,D+13),uv_index_bytes:v(a,D+14),material_index_bytes:v(a,D+15),nvertices:k(a,D+16),nnormals:k(a,D+16+4),nuvs:k(a,D+16+8),ntri_flat:k(a,D+16+12),ntri_smooth:k(a,D+16+16),ntri_flat_uv:k(a, D+16+20),ntri_smooth_uv:k(a,D+16+24),nquad_flat:k(a,D+16+28),nquad_smooth:k(a,D+16+32),nquad_flat_uv:k(a,D+16+36),nquad_smooth_uv:k(a,D+16+40)};D+=C.header_bytes;T=C.vertex_index_bytes;E=C.vertex_index_bytes*2;S=C.vertex_index_bytes*3;K=C.vertex_index_bytes*3+C.material_index_bytes;N=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;L=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;J=C.vertex_index_bytes;X=C.vertex_index_bytes*2;oa=C.vertex_index_bytes*3;Y=C.vertex_index_bytes* 4;V=C.vertex_index_bytes*4+C.material_index_bytes;o=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;Q=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;qa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;G=C.uv_index_bytes;W=C.uv_index_bytes*2;Z=C.uv_index_bytes;na=C.uv_index_bytes*2;ma=C.uv_index_bytes*3;b=C.vertex_index_bytes*3+C.material_index_bytes;la=C.vertex_index_bytes*4+C.material_index_bytes;sa=C.ntri_flat*b;U=C.ntri_smooth*(b+C.normal_index_bytes* 3);da=C.ntri_flat_uv*(b+C.uv_index_bytes*3);ia=C.ntri_smooth_uv*(b+C.normal_index_bytes*3+C.uv_index_bytes*3);ea=C.nquad_flat*la;b=C.nquad_smooth*(la+C.normal_index_bytes*4);la=C.nquad_flat_uv*(la+C.uv_index_bytes*4);D+=function(b){for(var e,h,k,l=C.vertex_coordinate_bytes*3,n=b+C.nvertices*l;b=0){x=n.invBindMatrices[u];o.invBindMatrix=x;o.skinningMatrix=new THREE.Matrix4;o.skinningMatrix.multiply(o.world,x);o.weights=[];for(x=0;x1){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=f.indexOf("(")>=0,l;if(h)e=f.split("."),f=e.shift(),e.shift();else if(k){l=f.split("(");f=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};N.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=I[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(Ca+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=Ga;return this.material=new THREE.MeshLambertMaterial(a)};L.prototype.parse=function(a){for(var b=0;b=0,e=a.indexOf("(")>=0,f,h;if(c)b=a.split("."),a=b.shift(),h=b.shift();else if(e){f=a.split("(");a=f.shift();for(b=0;b1&&(N=new THREE.MeshFaceMaterial);object=new THREE.Mesh(T,N);object.name=w;object.position.set(C[0],C[1],C[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=D.visible;Q.scene.add(object);Q.objects[w]=object;D.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),Q.scene.collisions.colliders.push(a));if(D.castsShadow)a= new THREE.ShadowVolume(T),Q.scene.add(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;D.trigger&&D.trigger.toLowerCase()!="none"&&(a={type:D.trigger,object:D},Q.triggers[object.name]=a)}}else C=D.position,r=D.rotation,q=D.quaternion,s=D.scale,q=0,object=new THREE.Object3D,object.name=w,object.position.set(C[0],C[1],C[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible= D.visible!==void 0?D.visible:!1,Q.scene.add(object),Q.objects[w]=object,Q.empties[w]=object,D.trigger&&D.trigger.toLowerCase()!="none"&&(a={type:D.trigger,object:D},Q.triggers[object.name]=a)}function n(a){return function(c){Q.geometries[a]=c;k();oa-=1;b.onLoadComplete();v()}}function p(a){return function(b){Q.geometries[a]=b}}function v(){b.callbackProgress({totalModels:V,totalTextures:o,loadedModels:V-oa,loadedTextures:o-Y},Q);b.onLoadProgress();oa==0&&Y==0&&c(Q)}var u,x,w,y,t,B,A,D,C,H,O,T,E,S, K,N,L,J,X,oa,Y,V,o,Q;J=a.data;K=new THREE.BinaryLoader;X=new THREE.JSONLoader;Y=oa=0;Q={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(w in J.objects)if(D=J.objects[w],D.meshCollider){a=!0;break}if(a)Q.scene.collisions=new THREE.CollisionSystem;if(J.transform){a=J.transform.position;H=J.transform.rotation;var qa=J.transform.scale;a&&Q.scene.position.set(a[0],a[1],a[2]);H&&Q.scene.rotation.set(H[0],H[1],H[2]);qa&& Q.scene.scale.set(qa[0],qa[1],qa[2]);(a||H||qa)&&Q.scene.updateMatrix()}a=function(){Y-=1;v();b.onLoadComplete()};for(t in J.cameras)H=J.cameras[t],H.type=="perspective"?E=new THREE.PerspectiveCamera(H.fov,H.aspect,H.near,H.far):H.type=="ortho"&&(E=new THREE.OrthographicCamera(H.left,H.right,H.top,H.bottom,H.near,H.far)),C=H.position,H=H.target,E.position.set(C[0],C[1],C[2]),E.target=new THREE.Vector3(H[0],H[1],H[2]),Q.cameras[t]=E;for(y in J.lights)t=J.lights[y],E=t.color!==void 0?t.color:16777215, H=t.intensity!==void 0?t.intensity:1,t.type=="directional"?(C=t.direction,L=new THREE.DirectionalLight(E,H),L.position.set(C[0],C[1],C[2]),L.position.normalize()):t.type=="point"?(C=t.position,d=t.distance,L=new THREE.PointLight(E,H,d),L.position.set(C[0],C[1],C[2])):t.type=="ambient"&&(L=new THREE.AmbientLight(E)),Q.scene.add(L),Q.lights[y]=L;for(B in J.fogs)y=J.fogs[B],y.type=="linear"?S=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(S=new THREE.FogExp2(0,y.density)),H=y.color,S.color.setRGB(H[0], H[1],H[2]),Q.fogs[B]=S;if(Q.cameras&&J.defaults.camera)Q.currentCamera=Q.cameras[J.defaults.camera];if(Q.fogs&&J.defaults.fog)Q.scene.fog=Q.fogs[J.defaults.fog];H=J.defaults.bgcolor;Q.bgColor=new THREE.Color;Q.bgColor.setRGB(H[0],H[1],H[2]);Q.bgColorAlpha=J.defaults.bgalpha;for(u in J.geometries)if(B=J.geometries[u],B.type=="bin_mesh"||B.type=="ascii_mesh")oa+=1,b.onLoadStart();V=oa;for(u in J.geometries)B=J.geometries[u],B.type=="cube"?(T=new THREE.CubeGeometry(B.width,B.height,B.depth,B.segmentsWidth, B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),Q.geometries[u]=T):B.type=="plane"?(T=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),Q.geometries[u]=T):B.type=="sphere"?(T=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),Q.geometries[u]=T):B.type=="cylinder"?(T=new THREE.CylinderGeometry(B.topRad,B.botRad,B.height,B.radSegs,B.heightSegs),Q.geometries[u]=T):B.type=="torus"?(T=new THREE.TorusGeometry(B.radius,B.tube,B.segmentsR,B.segmentsT),Q.geometries[u]= T):B.type=="icosahedron"?(T=new THREE.IcosahedronGeometry(B.subdivisions),Q.geometries[u]=T):B.type=="bin_mesh"?K.load(e(B.url,J.urlBaseType),n(u)):B.type=="ascii_mesh"?X.load(e(B.url,J.urlBaseType),n(u)):B.type=="embedded_mesh"&&(B=J.embeds[B.id])&&X.createModel(B,p(u),"");for(A in J.textures)if(u=J.textures[A],u.url instanceof Array){Y+=u.url.length;for(K=0;K=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),e=1,l=0;l<8;l++){for(var h=0,f=0;f>1^-(k&1);b[8*f+l]=h}e+=c}c=a.length-e;h=new Uint16Array(c);for(l=f=0;l=this.maxCount-3&&k(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 x=Math.floor(p-k);x<1&&(x=1);p=Math.floor(p+k);p>this.size-1&&(p=this.size-1);var w=Math.floor(v-k);w<1&&(w=1);k=Math.floor(v+k); k>this.size-1&&(k=this.size-1);for(var y,t,B,A,D,C;u0&&(this.field[B+y]+=A)}}};this.addPlaneX=function(a,c){var l,h,f,k,n,p=this.size,v=this.yd,u=this.zd,x=this.field,w=p*Math.sqrt(a/c);w>p&&(w=p);for(l=0;l0)for(h=0;hv&&(y=v);for(h=0;h0){n=h*u;for(l=0;lsize&&(dist=size);for(f=0;f0){n=zd*f;for(h=0;hh?this.hits.push(l):this.hits.unshift(l),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,l,h=0;h=k*l))return Number.MAX_VALUE;f/=k;k=THREE.CollisionSystem.__v3;k.copy(a.direction);k.multiplyScalar(f);k.addSelf(a.origin);Math.abs(h.x)> Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=k.y-c.y,h=b.y-c.y,l=e.y-c.y,k=k.z-c.z,b=b.z-c.z,e=e.z-c.z):(a=k.x-c.x,h=b.x-c.x,l=e.x-c.x,k=k.y-c.y,b=b.y-c.y,e=e.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(a=k.x-c.x,h=b.x-c.x,l=e.x-c.x,k=k.z-c.z,b=b.z-c.z,e=e.z-c.z):(a=k.x-c.x,h=b.x-c.x,l=e.x-c.x,k=k.y-c.y,b=b.y-c.y,e=e.y-c.y);c=h*e-b*l;if(c==0)return Number.MAX_VALUE;c=1/c;e=(a*e-k*l)*c;if(!(e>=0))return Number.MAX_VALUE;c*=h*k-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;b.getInverse(c.matrixWorld);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,l=0,h=0,f=0,k=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&&(l=c.max.y-b.origin.y,l/=b.direction.y, p=!1,k=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;l>e&&(p=1,e=l);h>e&&(p=2,e=h);switch(p){case 0:k=b.origin.y+b.direction.y*e;if(kc.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,k,0);break;case 2:f=b.origin.x+b.direction.x*e;if(fc.max.x)return Number.MAX_VALUE;k=b.origin.y+b.direction.y*e;if(kc.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,l=new THREE.PerspectiveCamera,h=new THREE.PerspectiveCamera,f=new THREE.Matrix4,k=new THREE.Matrix4,n,p,v,u;l.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},x=new THREE.WebGLRenderTarget(512,512,a),w=new THREE.WebGLRenderTarget(512,512,a),y=new THREE.PerspectiveCamera(53, 1,1,1E4);y.position.z=2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:x},mapRight:{type:"t",value:1,texture:w}},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 t=new THREE.Scene;t.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));t.add(y);this.setSize=function(a,e){b.call(c,a,e);x.width=a;x.height=e;w.width=a;w.height=e};this.render=function(a,b){a.updateMatrixWorld();if(n!==b.aspect||p!==b.near||v!==b.far||u!==b.fov){n=b.aspect;p=b.near;v=b.far;u=b.fov;var D=b.projectionMatrix.clone(),C=125/30*0.5,H=C*p/125,O=p*Math.tan(u*Math.PI/360),T;f.n14=C;k.n14=-C;C=-O*n+H;T=O*n+H;D.n11=2*p/(T-C);D.n13=(T+C)/(T-C);l.projectionMatrix.copy(D);C=-O*n-H; T=O*n-H;D.n11=2*p/(T-C);D.n13=(T+C)/(T-C);h.projectionMatrix.copy(D)}l.matrixWorld.copy(b.matrixWorld).multiplySelf(k);l.position.copy(b.position);l.near=b.near;l.far=b.far;e.call(c,a,l,x,!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,w,!0);t.updateMatrixWorld();e.call(c,t,y)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,e=this.render,l,h,f=new THREE.PerspectiveCamera;f.target=new THREE.Vector3(0,0,0);var k=new THREE.PerspectiveCamera;k.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);l=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);k.projectionMatrix=f.projectionMatrix;k.position.copy(b.position);k.target.copy(b.target);k.translateX(-c.separation);k.lookAt(k.target);this.setViewport(0,0,l,h);e.call(c,a,f);this.setViewport(l,0,l,h);e.call(c,a,k,!1)}};