// Three.js r46 - 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.001*(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 d,g,f;if(b===0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),g=a*6-d,a=b*(1-c),f=b*(1- c*g),c=b*(1-c*(1-g)),d){case 1:this.r=f;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=f;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=f;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.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)}, cross:function(a,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){var c=this.x,b=this.y,d=this.z;this.x=b*a.z-d*a.y;this.y=d*a.x-c*a.z;this.z=c*a.y-b*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,a).lengthSq()},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){var 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,d){this.x=a||0;this.y=c||0;this.z=b||0;this.w=d!==void 0?d:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;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){function b(a,b,c){o.sub(c,a);r=o.dot(b);if(r<=0)return null;n=p.add(a,m.copy(b).multiplyScalar(r));return q=c.distanceTo(n)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);m.sub(a,b);t=o.dot(o);w=o.dot(p);u=o.dot(m);B=p.dot(p);F=p.dot(m);A=1/(t*B-w*w);x=(B*u-w*F)*A;y=(t*F-w*u)*A;return x>=0&&y>=0&&x+y<1}this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b, c,d=[];b=0;for(c=a.length;bm.scale.x)return[];n={distance:p,point:m.position,face:null,object:m};o.push(n)}else if(m instanceof THREE.Mesh){p=b(this.origin,this.direction,m.matrixWorld.getPosition());if(p===null||p>m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)))return o;var q,t=m.geometry,w=t.vertices,u;m.matrixRotationWorld.extractRotation(m.matrixWorld);p=0;for(r=t.faces.length;p0:q<0)))if(q=l.dot(i.sub(g,a))/q,k.add(a,c.multiplyScalar(q)),n instanceof THREE.Face3)d(k, g,f,e)&&(n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},o.push(n));else if(n instanceof THREE.Face4&&(d(k,g,f,h)||d(k,f,e,h)))n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},o.push(n)}return o};var o=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector3,r,n,q,t,w,u,B,F,A,x,y}; THREE.Rectangle=function(){function a(){f=d-c;e=g-b}var c,b,d,g,f,e,h=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return f};this.getHeight=function(){return e};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(f,e,k,o){h=!1;c=f;b=e;d=k;g=o;a()};this.addPoint=function(f,e){h?(h=!1,c=f,b=e,d=f,g=e):(c=cf?d:f,g=g>e?g:e);a()};this.add3Points= function(f,e,k,o,p,m){h?(h=!1,c=fk?f>p?f:p:k>p?k:p,g=e>o?e>m?e:m:o>m?o:m):(c=fk?f>p?f>d?f:d:p>d?p:d:k>p?k>d?k:d:p>d?p:d,g=e>o?e>m?e>g?e:g:m>g?m:g:o>m?o>g?o:g:m>g?m:g);a()};this.addRectangle=function(f){h?(h=!1,c=f.getLeft(),b=f.getTop(),d=f.getRight(),g=f.getBottom()):(c=cf.getRight()?d:f.getRight(),g=g> f.getBottom()?g:f.getBottom());a()};this.inflate=function(f){c-=f;b-=f;d+=f;g+=f;a()};this.minSelf=function(f){c=c>f.getLeft()?c:f.getLeft();b=b>f.getTop()?b:f.getTop();d=d=0&&Math.min(g,a.getBottom())-Math.max(b,a.getTop())>=0};this.empty=function(){h=!0;g=d=b=c=0;a()};this.isEmpty=function(){return h}}; THREE.Math={clamp:function(a,c,b){return ab?b:a},clampBottom:function(a,c){return a=0&&f>=0&&e>=0&&h>=0?!0:g<0&&f<0||e<0&&h<0?!1:(g<0?c=Math.max(c,g/(g-f)):f<0&&(d=Math.min(d,g/(g-f))),e<0?c=Math.max(c,e/(e-h)):h<0&&(d=Math.min(d,e/(e-h))),de&&h.positionScreen.z0&&x.z<1))e=B[u]=B[u]||new THREE.RenderableParticle,u++,w=e,w.x=x.x/x.w,w.y=x.y/x.w,w.z=x.z,w.rotation=j.rotation.z,w.scale.x=j.scale.x*Math.abs(w.x-(x.x+g.projectionMatrix.n11)/(x.w+g.projectionMatrix.n14)),w.scale.y=j.scale.y*Math.abs(w.y-(x.y+g.projectionMatrix.n22)/(x.w+g.projectionMatrix.n24)),w.material=j.material,F.elements.push(w); f&&F.elements.sort(b);return F}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==void 0?d:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var c=Math.PI/360,b=a.x*c,d=a.y*c,g=a.z*c,a=Math.cos(d),d=Math.sin(d),c=Math.cos(-g),g=Math.sin(-g),f=Math.cos(b),b=Math.sin(b),e=a*c,h=d*g;this.w=e*f-h*b;this.x=e*b+h*f;this.y=d*c*f+a*g*b;this.z=a*g*f-d*c*b;return this},setFromAxisAngle:function(a,c){var b=c/2,d=Math.sin(b); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;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,d=this.z,g=this.w,f=a.x,e=a.y,h=a.z,a=a.w;this.x=c*a+g*f+b*h-d*e;this.y=b*a+g*e+d*f-c*h;this.z=d*a+g*h+c*e-b*f;this.w=g*a-c*f-b*e-d*h;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,d=a.y,g=a.z,f=this.x,e=this.y,h=this.z,i=this.w,l=i*b+e*g-h*d,k=i*d+h*b-f*g,o=i*g+f*d-e*b,b=-f* b-e*d-h*g;c.x=l*i+b*-f+k*-h-o*-e;c.y=k*i+b*-e+o*-f-l*-h;c.z=o*i+b*-h+l*-e-k*-f;return c}}; THREE.Quaternion.slerp=function(a,c,b,d){var g=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;g<0?(b.w=-c.w,b.x=-c.x,b.y=-c.y,b.z=-c.z,g=-g):b.copy(c);if(Math.abs(g)>=1)return b.w=a.w,b.x=a.x,b.y=a.y,b.z=a.z,b;var f=Math.acos(g),g=Math.sqrt(1-g*g);if(Math.abs(g)<0.001)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-d)*f)/g;d=Math.sin(d*f)/g;b.w=a.w*c+b.w*d;b.x=a.x*c+b.x*d;b.y=a.y*c+b.y*d;b.z=a.z*c+b.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,c,b,d,g,f){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,c,b,d,g,f,e){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;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,d=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?f:f+1;b[3]=f>this.points.length-3?f:f+2;l=this.points[b[0]];k=this.points[b[1]]; o=this.points[b[2]];p=this.points[b[3]];h=e*e;i=e*h;d.x=c(l.x,k.x,o.x,p.x,e,h,i);d.y=c(l.y,k.y,o.y,p.y,e,h,i);d.z=c(l.z,k.z,o.z,p.z,e,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];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),g("rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+t+")"),n.fillRect(Math.floor(ea.getX()), Math.floor(ea.getY()),Math.floor(ea.getWidth()),Math.floor(ea.getHeight()))),ea.empty())};this.render=function(a,k){function p(a){var b,c,d,g;ca.setRGB(0,0,0);la.setRGB(0,0,0);ma.setRGB(0,0,0);b=0;for(c=a.length;b> 1,ia=k.height>>1,e=f.scale.x*m,i=f.scale.y*r,j=e*l,h=i*ia,ha.set(a.x-j,a.y-h,a.x+j,a.y+h),Q.intersects(ha)&&(n.save(),n.translate(a.x,a.y),n.rotate(-f.rotation),n.scale(e,-i),n.translate(-l,-ia),n.drawImage(k,0,0),n.restore())}else e instanceof THREE.ParticleCanvasMaterial&&(j=f.scale.x*m,h=f.scale.y*r,ha.set(a.x-j,a.y-h,a.x+j,a.y+h),Q.intersects(ha)&&(d(e.color.getContextStyle()),g(e.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-f.rotation),n.scale(j,h),e.program(n),n.restore()))} function t(a,g,f,e){c(e.opacity);b(e.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(g.positionScreen.x,g.positionScreen.y);n.closePath();if(e instanceof THREE.LineBasicMaterial){a=e.linewidth;if(A!=a)n.lineWidth=A=a;a=e.linecap;if(x!=a)n.lineCap=x=a;a=e.linejoin;if(y!=a)n.lineJoin=y=a;d(e.color.getContextStyle());n.stroke();ha.inflate(e.linewidth*2)}}function w(a,d,g,e,j,h,m,n){f.info.render.vertices+=3;f.info.render.faces++;c(n.opacity);b(n.blending);K=a.positionScreen.x; P=a.positionScreen.y;O=d.positionScreen.x;aa=d.positionScreen.y;H=g.positionScreen.x;G=g.positionScreen.y;Ga(K,P,O,aa,H,G);if(n instanceof THREE.MeshBasicMaterial)if(n.map)n.map.mapping instanceof THREE.UVMapping&&(pa=m.uvs[0],Ka(K,P,O,aa,H,G,pa[e].u,pa[e].v,pa[j].u,pa[j].v,pa[h].u,pa[h].v,n.map));else if(n.envMap){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,fa.copy(m.vertexNormalsWorld[e]),Da=(fa.x*a.n11+fa.y*a.n12+fa.z*a.n13)*0.5+0.5,za=-(fa.x*a.n21+fa.y* a.n22+fa.z*a.n23)*0.5+0.5,fa.copy(m.vertexNormalsWorld[j]),Aa=(fa.x*a.n11+fa.y*a.n12+fa.z*a.n13)*0.5+0.5,Ba=-(fa.x*a.n21+fa.y*a.n22+fa.z*a.n23)*0.5+0.5,fa.copy(m.vertexNormalsWorld[h]),L=(fa.x*a.n11+fa.y*a.n12+fa.z*a.n13)*0.5+0.5,Z=-(fa.x*a.n21+fa.y*a.n22+fa.z*a.n23)*0.5+0.5,Ka(K,P,O,aa,H,G,Da,za,Aa,Ba,L,Z,n.envMap)}else n.wireframe?u(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Ca(n.color);else if(n instanceof THREE.MeshLambertMaterial)n.map&&!n.wireframe&&(n.map.mapping instanceof THREE.UVMapping&&(pa=m.uvs[0],Ka(K,P,O,aa,H,G,pa[e].u,pa[e].v,pa[j].u,pa[j].v,pa[h].u,pa[h].v,n.map)),b(THREE.SubtractiveBlending)),N?!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3?(V.r=da.r=ga.r=ca.r,V.g=da.g=ga.g=ca.g,V.b=da.b=ga.b=ca.b,o(i,m.v1.positionWorld,m.vertexNormalsWorld[0],V),o(i,m.v2.positionWorld,m.vertexNormalsWorld[1],da),o(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ga),V.r=Math.max(0,Math.min(n.color.r*V.r,1)),V.g=Math.max(0,Math.min(n.color.g*V.g, 1)),V.b=Math.max(0,Math.min(n.color.b*V.b,1)),da.r=Math.max(0,Math.min(n.color.r*da.r,1)),da.g=Math.max(0,Math.min(n.color.g*da.g,1)),da.b=Math.max(0,Math.min(n.color.b*da.b,1)),ga.r=Math.max(0,Math.min(n.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(n.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(n.color.b*ga.b,1)),$.r=(da.r+ga.r)*0.5,$.g=(da.g+ga.g)*0.5,$.b=(da.b+ga.b)*0.5,oa=Ha(V,da,ga,$),Fa(K,P,O,aa,H,G,0,0,1,0,0,1,oa)):(X.r=ca.r,X.g=ca.g,X.b=ca.b,o(i,m.centroidWorld,m.normalWorld,X),X.r=Math.max(0,Math.min(n.color.r* X.r,1)),X.g=Math.max(0,Math.min(n.color.g*X.g,1)),X.b=Math.max(0,Math.min(n.color.b*X.b,1)),n.wireframe?u(X,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Ca(X)):n.wireframe?u(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Ca(n.color);else if(n instanceof THREE.MeshDepthMaterial)qa=k.near,na=k.far,V.r=V.g=V.b=1-B(a.positionScreen.z,qa,na),da.r=da.g=da.b=1-B(d.positionScreen.z,qa,na),ga.r=ga.g=ga.b=1-B(g.positionScreen.z,qa,na),$.r=(da.r+ga.r)*0.5,$.g=(da.g+ga.g)* 0.5,$.b=(da.b+ga.b)*0.5,oa=Ha(V,da,ga,$),Fa(K,P,O,aa,H,G,0,0,1,0,0,1,oa);else if(n instanceof THREE.MeshNormalMaterial)X.r=F(m.normalWorld.x),X.g=F(m.normalWorld.y),X.b=F(m.normalWorld.z),n.wireframe?u(X,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Ca(X)}function Ma(a,d,g,e,h,n,m,l,p){f.info.render.vertices+=4;f.info.render.faces++;c(l.opacity);b(l.blending);if(l.map||l.envMap)w(a,d,e,0,1,3,m,l,p),w(h,g,n,1,2,3,m,l,p);else if(K=a.positionScreen.x,P=a.positionScreen.y,O=d.positionScreen.x, aa=d.positionScreen.y,H=g.positionScreen.x,G=g.positionScreen.y,I=e.positionScreen.x,M=e.positionScreen.y,S=h.positionScreen.x,ba=h.positionScreen.y,W=n.positionScreen.x,j=n.positionScreen.y,l instanceof THREE.MeshBasicMaterial)Ia(K,P,O,aa,H,G,I,M),l.wireframe?u(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):Ca(l.color);else if(l instanceof THREE.MeshLambertMaterial)N?!l.wireframe&&l.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==4?(V.r=da.r=ga.r=$.r=ca.r,V.g=da.g= ga.g=$.g=ca.g,V.b=da.b=ga.b=$.b=ca.b,o(i,m.v1.positionWorld,m.vertexNormalsWorld[0],V),o(i,m.v2.positionWorld,m.vertexNormalsWorld[1],da),o(i,m.v4.positionWorld,m.vertexNormalsWorld[3],ga),o(i,m.v3.positionWorld,m.vertexNormalsWorld[2],$),V.r=Math.max(0,Math.min(l.color.r*V.r,1)),V.g=Math.max(0,Math.min(l.color.g*V.g,1)),V.b=Math.max(0,Math.min(l.color.b*V.b,1)),da.r=Math.max(0,Math.min(l.color.r*da.r,1)),da.g=Math.max(0,Math.min(l.color.g*da.g,1)),da.b=Math.max(0,Math.min(l.color.b*da.b,1)),ga.r= Math.max(0,Math.min(l.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(l.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(l.color.b*ga.b,1)),$.r=Math.max(0,Math.min(l.color.r*$.r,1)),$.g=Math.max(0,Math.min(l.color.g*$.g,1)),$.b=Math.max(0,Math.min(l.color.b*$.b,1)),oa=Ha(V,da,ga,$),Ga(K,P,O,aa,I,M),Fa(K,P,O,aa,I,M,0,0,1,0,0,1,oa),Ga(S,ba,H,G,W,j),Fa(S,ba,H,G,W,j,1,0,1,1,0,1,oa)):(X.r=ca.r,X.g=ca.g,X.b=ca.b,o(i,m.centroidWorld,m.normalWorld,X),X.r=Math.max(0,Math.min(l.color.r*X.r,1)),X.g=Math.max(0,Math.min(l.color.g* X.g,1)),X.b=Math.max(0,Math.min(l.color.b*X.b,1)),Ia(K,P,O,aa,H,G,I,M),l.wireframe?u(X,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):Ca(X)):(Ia(K,P,O,aa,H,G,I,M),l.wireframe?u(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):Ca(l.color));else if(l instanceof THREE.MeshNormalMaterial)X.r=F(m.normalWorld.x),X.g=F(m.normalWorld.y),X.b=F(m.normalWorld.z),Ia(K,P,O,aa,H,G,I,M),l.wireframe?u(X,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):Ca(X);else if(l instanceof THREE.MeshDepthMaterial)qa=k.near,na=k.far,V.r=V.g=V.b=1-B(a.positionScreen.z,qa,na),da.r=da.g=da.b=1-B(d.positionScreen.z,qa,na),ga.r=ga.g=ga.b=1-B(e.positionScreen.z,qa,na),$.r=$.g=$.b=1-B(g.positionScreen.z,qa,na),oa=Ha(V,da,ga,$),Ga(K,P,O,aa,I,M),Fa(K,P,O,aa,I,M,0,0,1,0,0,1,oa),Ga(S,ba,H,G,W,j),Fa(S,ba,H,G,W,j,1,0,1,1,0,1,oa)}function Ga(a,b,c,d,g,e){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(g,e);n.lineTo(a,b);n.closePath()}function Ia(a,b,c,d,g,e,f,j){n.beginPath();n.moveTo(a,b);n.lineTo(c, d);n.lineTo(g,e);n.lineTo(f,j);n.lineTo(a,b);n.closePath()}function u(a,b,c,g){if(A!=b)n.lineWidth=A=b;if(x!=c)n.lineCap=x=c;if(y!=g)n.lineJoin=y=g;d(a.getContextStyle());n.stroke();ha.inflate(b*2)}function Ca(a){g(a.getContextStyle());n.fill()}function Ka(a,b,c,d,e,f,j,h,i,m,k,l,ia){if(ia.image.width!=0){if(ia.needsUpdate==!0||ua[ia.id]==void 0){var o=ia.wrapS==THREE.RepeatWrapping,p=ia.wrapT==THREE.RepeatWrapping;ua[ia.id]=n.createPattern(ia.image,o&&p?"repeat":o&&!p?"repeat-x":!o&&p?"repeat-y": "no-repeat");ia.needsUpdate=!1}g(ua[ia.id]);var o=ia.offset.x/ia.repeat.x,p=ia.offset.y/ia.repeat.y,L=ia.image.width*ia.repeat.x,q=ia.image.height*ia.repeat.y,j=(j+o)*L,h=(h+p)*q,i=(i+o)*L,m=(m+p)*q,k=(k+o)*L,l=(l+p)*q;c-=a;d-=b;e-=a;f-=b;i-=j;m-=h;k-=j;l-=h;o=i*l-k*m;if(o==0){if(ra[ia.id]==void 0)b=document.createElement("canvas"),b.width=ia.image.width,b.height=ia.image.height,a=b.getContext("2d"),a.drawImage(ia.image,0,0),ra[ia.id]=a.getImageData(0,0,ia.image.width,ia.image.height).data,delete b; b=ra[ia.id];j=(Math.floor(j)+Math.floor(h)*ia.image.width)*4;X.setRGB(b[j]/255,b[j+1]/255,b[j+2]/255);Ca(X)}else o=1/o,ia=(l*c-m*e)*o,m=(l*d-m*f)*o,c=(i*e-k*c)*o,d=(i*f-k*d)*o,a=a-ia*j-c*h,j=b-m*j-d*h,n.save(),n.transform(ia,m,c,d,a,j),n.fill(),n.restore()}}function Fa(a,b,c,d,g,e,f,j,h,i,m,k,l){var ia,o;ia=l.width-1;o=l.height-1;f*=ia;j*=o;h*=ia;i*=o;m*=ia;k*=o;c-=a;d-=b;g-=a;e-=b;h-=f;i-=j;m-=f;k-=j;o=1/(h*k-m*i);ia=(k*c-i*g)*o;i=(k*d-i*e)*o;c=(h*g-m*c)*o;d=(h*e-m*d)*o;a=a-ia*f-c*j;b=b-i*f-d*j; n.save();n.transform(ia,i,c,d,a,b);n.clip();n.drawImage(l,0,0);n.restore()}function Ha(a,b,c,d){var g=~~(a.r*255),e=~~(a.g*255),a=~~(a.b*255),f=~~(b.r*255),j=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),i=~~(c.g*255),c=~~(c.b*255),m=~~(d.r*255),k=~~(d.g*255),d=~~(d.b*255);ta[0]=g<0?0:g>255?255:g;ta[1]=e<0?0:e>255?255:e;ta[2]=a<0?0:a>255?255:a;ta[4]=f<0?0:f>255?255:f;ta[5]=j<0?0:j>255?255:j;ta[6]=b<0?0:b>255?255:b;ta[8]=h<0?0:h>255?255:h;ta[9]=i<0?0:i>255?255:i;ta[10]=c<0?0:c>255?255:c;ta[12]=m<0?0:m>255? 255:m;ta[13]=k<0?0:k>255?255:k;ta[14]=d<0?0:d>255?255:d;xa.putImageData(va,0,0);wa.drawImage(Y,0,0);return T}function B(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function F(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Ea(a,b){var c=b.x-a.x,d=b.y-a.y,g=c*c+d*d;g!=0&&(g=1/Math.sqrt(g),c*=g,d*=g,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Ja,La,sa,D;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,r);f.info.render.vertices=0;f.info.render.faces=0;e=l.projectScene(a,k,this.sortElements);h=e.elements;i=e.lights; (N=i.length>0)&&p(i);Ja=0;for(La=h.length;Ja1?1:a}var d=this,g,f,e,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,k,o,p,m,r,n,q,t=new THREE.Rectangle,w=new THREE.Rectangle,u=!1,B=new THREE.Color,F=new THREE.Color,A=new THREE.Color,x=new THREE.Color,y,v=new THREE.Vector3,J=[],s=[],E,R,U,K=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, faces:0}};this.setQuality=function(a){switch(a){case "high":K=1;break;case "low":K=0}};this.setSize=function(a,b){l=a;k=b;o=l/2;p=k/2;i.setAttribute("viewBox",-o+" "+-p+" "+l+" "+k);i.setAttribute("width",l);i.setAttribute("height",k);t.set(-o,-p,o,p)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,l){var J,v,G,I;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;g=h.projectScene(k,l,this.sortElements);f=g.elements; e=g.lights;U=R=0;if(u=e.length>0){F.setRGB(0,0,0);A.setRGB(0,0,0);x.setRGB(0,0,0);J=0;for(v=e.length;J 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:"vLightWeighting = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\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;", 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,d,g={};for(c=0;c=0)return a.geometry.materials[b.materialIndex]}function d(a){if(a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial)return!1;return a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function g(a){if(a.vertexColors)return a.vertexColors;return!1}function f(a){if(a.map||a.lightMap||a instanceof THREE.ShaderMaterial)return!0; return!1}function e(a,b,c){var d,g,f,e,h=a.vertices;e=h.length;var i=a.colors,m=i.length,k=a.__vertexArray,n=a.__colorArray,l=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,L=a.__webglCustomAttributesList;if(c.sortParticles){N.multiplySelf(c.matrixWorld);for(d=0;d=0)a&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;f.morphTargetBase!==-1?(j.bindBuffer(j.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[f.morphTargetBase]), j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):c.position>=0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){e=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;em&&(l=k,m=h[l]);j.bindBuffer(j.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[l]);j.vertexAttribPointer(c["morphTarget"+e],3,j.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[e]=m;i[l]=1;m=-1;e++}}d.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(g.__webglCustomAttributesList){e= 0;for(h=g.__webglCustomAttributesList.length;e=0&&(j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,!1,0,0))}b.color>=0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglColorBuffer),j.vertexAttribPointer(b.color,3,j.FLOAT,!1,0,0));b.normal>=0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglNormalBuffer),j.vertexAttribPointer(b.normal,3,j.FLOAT,!1,0,0));b.tangent>=0&&(j.bindBuffer(j.ARRAY_BUFFER, g.__webglTangentBuffer),j.vertexAttribPointer(b.tangent,4,j.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(j.bindBuffer(j.ARRAY_BUFFER,g.__webglUVBuffer),j.vertexAttribPointer(b.uv,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv)):j.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(j.bindBuffer(j.ARRAY_BUFFER,g.__webglUV2Buffer),j.vertexAttribPointer(b.uv2,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv2)):j.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>= 0&&b.skinIndex>=0&&b.skinWeight>=0&&(j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinVertexABuffer),j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe? (d=d.wireframeLinewidth,d!==Ba&&(j.lineWidth(d),Ba=d),a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),j.drawElements(j.LINES,g.__webglLineCount,j.UNSIGNED_SHORT,0)):(a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),j.drawElements(j.TRIANGLES,g.__webglFaceCount,j.UNSIGNED_SHORT,0)),W.info.render.calls++,W.info.render.vertices+=g.__webglFaceCount,W.info.render.faces+=g.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!== Ba&&(j.lineWidth(d),Ba=d),j.drawArrays(f,0,g.__webglLineCount),W.info.render.calls++):f instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,g.__webglParticleCount),W.info.render.calls++):f instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,g.__webglVertexCount),W.info.render.calls++)}}function l(a){ha[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);ha[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);ha[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);ha[3].set(a.n41- a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);ha[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);ha[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=ha[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function k(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),d=0;d<6;d++)if(a=ha[d].x*b.n14+ha[d].y*b.n24+ha[d].z*b.n34+ha[d].w,a<=c)return!1;return!0}function o(a,b){return b.z-a.z}function p(a){var b, c,d,g,f,e,m,n,o=0,p=a.lights;Y||(Y=new THREE.PerspectiveCamera(W.shadowCameraFov,W.shadowMapWidth/W.shadowMapHeight,W.shadowCameraNear,W.shadowCameraFar));b=0;for(c=p.length;b=0;c--)a[c].object===b&&a.splice(c,1)}function u(a,b,c,d,g){d.program||W.initMaterial(d,b,c,g);if(d.morphTargets&&!g.__webglMorphTargetInfluences){g.__webglMorphTargetInfluences=new Float32Array(W.maxMorphTargets);for(var f=0,e=W.maxMorphTargets;f0;this.getContext=function(){return j};this.supportsVertexTextures=function(){return ya};this.setSize=function(a,b){O.width=a;O.height=b;this.setViewport(0,0,O.width,O.height)};this.setViewport=function(a,b,c,d){L=a;Z=b;Q=c;ea=d;j.viewport(L,Z,Q,ea)};this.setScissor=function(a,b,c,d){j.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)}; this.setClearColorHex=function(a,b){M.setHex(a);S=b;j.clearColor(M.r,M.g,M.b,S)};this.setClearColor=function(a,b){M.copy(a);S=b;j.clearColor(M.r,M.g,M.b,S)};this.getClearColor=function(){return M};this.getClearAlpha=function(){return S};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=j.COLOR_BUFFER_BIT;if(b===void 0||b)d|=j.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){U(a);this.clear(b,c,d)};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(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];j.deleteBuffer(c.__webglVertexBuffer);j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer); j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,g=c.numMorphTargets;d=0)Z=q.geometry.materials[Z],Z.transparent?(L.transparent=Z,L.opaque=null):(L.opaque=Z,L.transparent=null)}else if(Z)Z.transparent?(L.transparent=Z,L.opaque=null):(L.opaque=Z,L.transparent=null);f.render=!0;if(this.sortObjects)e.renderDepth?f.z=e.renderDepth:(ma.copy(e.position),N.multiplyVector3(ma),f.z=ma.z)}this.sortObjects&&h.sort(o);h=a.__webglObjectsImmediate;d=0;for(g=h.length;d65535&&(u[Z].counter+=1,s=u[Z].hash+"_"+u[Z].counter,k.geometryGroups[s]===void 0&&(k.geometryGroups[s]={faces3:[],faces4:[],materialIndex:r,vertices:0, numMorphTargets:J})),L instanceof THREE.Face3?k.geometryGroups[s].faces3.push(o):k.geometryGroups[s].faces4.push(o),k.geometryGroups[s].vertices+=Q;k.geometryGroupsList=[];o=void 0;for(o in k.geometryGroups)k.geometryGroups[o].id=ua++,k.geometryGroupsList.push(k.geometryGroups[o])}for(m in l.geometryGroups)if(k=l.geometryGroups[m],!k.__webglVertexBuffer){o=k;o.__webglVertexBuffer=j.createBuffer();o.__webglNormalBuffer=j.createBuffer();o.__webglTangentBuffer=j.createBuffer();o.__webglColorBuffer=j.createBuffer(); o.__webglUVBuffer=j.createBuffer();o.__webglUV2Buffer=j.createBuffer();o.__webglSkinVertexABuffer=j.createBuffer();o.__webglSkinVertexBBuffer=j.createBuffer();o.__webglSkinIndicesBuffer=j.createBuffer();o.__webglSkinWeightsBuffer=j.createBuffer();o.__webglFaceBuffer=j.createBuffer();o.__webglLineBuffer=j.createBuffer();if(o.numMorphTargets){L=p=void 0;o.__webglMorphTargetsBuffers=[];p=0;for(L=o.numMorphTargets;p0||Q.faceVertexUvs.length>0)k.__uvArray=new Float32Array(o*2);if(Q.faceUvs.length>1||Q.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(o*2)}if(r.geometry.skinWeights.length&& r.geometry.skinIndices.length)k.__skinVertexAArray=new Float32Array(o*4),k.__skinVertexBArray=new Float32Array(o*4),k.__skinIndexArray=new Float32Array(o*4),k.__skinWeightArray=new Float32Array(o*4);k.__faceArray=new Uint16Array(L*3);k.__lineArray=new Uint16Array(Z*2);if(k.numMorphTargets){k.__morphTargetsArrays=[];r=0;for(Q=k.numMorphTargets;r=0;l--)i[l]===m&&i.splice(l,1)}else(h instanceof THREE.MarchingCubes|| h.immediateRenderCallback)&&w(i.__webglObjectsImmediate,h);h.__webglActive=!1;a.__objectsRemoved.splice(0,1)}h=0;for(i=a.__webglObjects.length;h0&&(j.bindBuffer(j.ARRAY_BUFFER,p.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,ca,L),j.bindBuffer(j.ARRAY_BUFFER,p.__webglSkinVertexBBuffer), j.bufferData(j.ARRAY_BUFFER,U,L),j.bindBuffer(j.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,A,L),j.bindBuffer(j.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,$,L))}if(ra&&Z){s=0;for(u=E.length;s0&&(j.bindBuffer(j.ARRAY_BUFFER,p.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,P,L))}if(ha&&S.hasTangents){s=0;for(u=E.length;s0&&(j.bindBuffer(j.ARRAY_BUFFER,p.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,T,L))}if(ta&&pa&&B){s=0;for(u=E.length;s0&&(j.bindBuffer(j.ARRAY_BUFFER, p.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,C,L))}if(xa){s=0;for(u=E.length;s=0&&j.enableVertexAttribArray(o.position);o.color>=0&&j.enableVertexAttribArray(o.color);o.normal>=0&&j.enableVertexAttribArray(o.normal); o.tangent>=0&&j.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(j.enableVertexAttribArray(o.skinVertexA),j.enableVertexAttribArray(o.skinVertexB),j.enableVertexAttribArray(o.skinIndex),j.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(e in a.attributes)o[e]!==void 0&&o[e]>=0&&j.enableVertexAttribArray(o[e]);if(a.morphTargets)for(e=a.numSupportedMorphTargets=0;e=0&&(j.enableVertexAttribArray(o[L]), a.numSupportedMorphTargets++);a.uniformsList=[];for(g in a.uniforms)a.uniformsList.push([a.uniforms[g],g])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?j.frontFace(j.CCW):j.frontFace(j.CW),a==="back"?j.cullFace(j.BACK):a==="front"?j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK),j.enable(j.CULL_FACE)):j.disable(j.CULL_FACE)}}; THREE.WebGLRenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==void 0?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==void 0?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==void 0?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==void 0?b.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=b.format!==void 0?b.format:THREE.RGBAFormat;this.type=b.type!==void 0?b.type: THREE.UnsignedByteType;this.depthBuffer=b.depthBuffer!==void 0?b.depthBuffer:!0;this.stencilBuffer=b.stencilBuffer!==void 0?b.stencilBuffer:!0}; THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,c,b){THREE.WebGLRenderTarget.call(this,a,c,b);this.activeCubeFace=0}; THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)}; THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null}; THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null}; THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null}; THREE.ColorUtils={adjustHSV:function(a,c,b,d){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,g);g.h=THREE.Math.clamp(g.h+c,0,1);g.s=THREE.Math.clamp(g.s+b,0,1);g.v=THREE.Math.clamp(g.v+d,0,1);a.setHSV(g.h,g.s,g.v)},rgbToHsv:function(a,c){var b=a.r,d=a.g,g=a.b,f=Math.max(Math.max(b,d),g),e=Math.min(Math.min(b,d),g);if(e===f)e=b=0;else{var h=f-e,e=h/f,b=b===f?(d-g)/h:d===f?2+(g-b)/h:4+(b-d)/h;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=e;c.v=f;return c}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; THREE.GeometryUtils={merge:function(a,c){for(var b,d,g=a.vertices.length,f=c instanceof THREE.Mesh?c.geometry:c,e=a.vertices,h=f.vertices,i=a.faces,l=f.faces,k=a.faceVertexUvs[0],o=f.faceVertexUvs[0],p={},m=0;m1&&(d=1-d,g=1-g);f=1-d-g;e.copy(a);e.multiplyScalar(d);h.copy(c);h.multiplyScalar(g);e.addSelf(h);h.copy(b);h.multiplyScalar(f);e.addSelf(h);return e},randomPointInFace:function(a,c,b){var d,g,f;if(a instanceof THREE.Face3)return d=c.vertices[a.a].position,g=c.vertices[a.b].position, f=c.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,g,f);else if(a instanceof THREE.Face4){d=c.vertices[a.a].position;g=c.vertices[a.b].position;f=c.vertices[a.c].position;var c=c.vertices[a.d].position,e;b?a._area1&&a._area2?(b=a._area1,e=a._area2):(b=THREE.GeometryUtils.triangleArea(d,g,c),e=THREE.GeometryUtils.triangleArea(g,f,c),a._area1=b,a._area2=e):(b=THREE.GeometryUtils.triangleArea(d,g,c),e=THREE.GeometryUtils.triangleArea(g,f,c));return THREE.GeometryUtils.random()*(b+ e)a?b(c,e-1):l[e] 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,d=this.getPoint(0),g,f=0;c.push(0);for(g=1;g<=a;g++)b=this.getPoint(g/a),f+=b.distanceTo(d),c.push(f),d=b;return this.cacheArcLengths=c}; THREE.Curve.prototype.getUtoTmapping=function(a,c){var b=this.getLengths(),d=0,g=b.length,f;f=c?c:a*b[g-1];for(var e=0,h=g-1,i;e<=h;)if(d=Math.floor(e+(h-e)/2),i=b[d]-f,i<0)e=d+1;else if(i>0)h=d-1;else{h=d;break}d=h;if(b[d]==f)return d/(g-1);e=b[d];return b=(d+(f-e)/(b[d+1]-e))/(g-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);c=this.getPoint(c);a=this.getPoint(a);return c.clone().subSelf(a).normalize()};THREE.Curve.prototype.getTangentAt=function(a){return this.getTangent(this.getUtoTmapping(a))};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,d){this.constructor(new THREE.Vector2(a,c),new THREE.Vector2(b,d))};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 d=Array.prototype.slice.call(arguments),a=new THREE.Vector2(d[0],d[1]),c=new THREE.Vector2(d[2],d[3]),b=new THREE.Vector2(d[4],d[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,d){if(!(c instanceof THREE.Vector2))var g=Array.prototype.slice.call(arguments),a=new THREE.Vector2(g[0],g[1]),c=new THREE.Vector2(g[2],g[3]),b=new THREE.Vector2(g[4],g[5]),d=new THREE.Vector2(g[6],g[7]);this.v0=a;this.v1=c;this.v2=b;this.v3=d};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==void 0?[]: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=[],d=this.points,g;g=(d.length-1)*a;a=Math.floor(g);g-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>d.length-2?a:a+1;b[3]=a>d.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(d[b[0]].x,d[b[1]].x,d[b[2]].x,d[b[3]].x,g);c.y=THREE.Curve.Utils.interpolate(d[b[0]].y,d[b[1]].y,d[b[2]].y,d[b[3]].y,g);return c};THREE.ArcCurve=function(a,c,b,d,g,f){this.aX=a;this.aY=c;this.aRadius=b;this.aStartAngle=d;this.aEndAngle=g;this.aClockwise=f}; 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,d){return 2*(1-a)*(b-c)+2*a*(d-b)},tangentCubicBezier:function(a,c,b,d,g){return-3*c*(1-a)*(1-a)+3*b*(1-a)*(1-a)-6*a*b*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*g},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,d,g){var a=(b-a)*0.5,d=(d-c)*0.5,f=g*g;return(2*c-2*b+a+d)*g*f+(-3*c+3*b-2*a-d)*f+a*g+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(this.v2,this.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,d){this.v0=a;this.v1=c;this.v2=b;this.v3=d},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==void 0?[]:a},function(a){var c=new THREE.Vector3,b=[],d=this.points,g;g=(d.length-1)*a;a=Math.floor(g);g-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>d.length-2?a:a+1;b[3]=a>d.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(d[b[0]].x,d[b[1]].x,d[b[2]].x,d[b[3]].x,g);c.y=THREE.Curve.Utils.interpolate(d[b[0]].y,d[b[1]].y,d[b[2]].y,d[b[3]].y,g);c.z=THREE.Curve.Utils.interpolate(d[b[0]].z,d[b[1]].z,d[b[2]].z,d[b[3]].z,g);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,d=this.curves.length;for(b=0;bc)c=f.x;else if(f.xb)b=f.y;else if(f.y0?(e=b[b.length-1],m=e.x,r=e.y):(e=this.actions[d-1].args,m=e[e.length-2],r=e[e.length-1]);for(e=1;e<=a;e++)n=e/a,f=THREE.Shape.Utils.b2(n,m,o,h),n=THREE.Shape.Utils.b2(n,r,p, i),b.push(new THREE.Vector2(f,n));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];o=f[0];p=f[1];l=f[2];k=f[3];b.length>0?(e=b[b.length-1],m=e.x,r=e.y):(e=this.actions[d-1].args,m=e[e.length-2],r=e[e.length-1]);for(e=1;e<=a;e++)n=e/a,f=THREE.Shape.Utils.b3(n,m,o,l,h),n=THREE.Shape.Utils.b3(n,r,p,k,i),b.push(new THREE.Vector2(f,n));break;case THREE.PathActions.CSPLINE_THRU:e=this.actions[d-1].args;e=[new THREE.Vector2(e[e.length-2],e[e.length-1])];n=a*f[0].length;e=e.concat(f[0]);f=new THREE.SplineCurve(e); for(e=1;e<=n;e++)b.push(f.getPointAt(e/n));break;case THREE.PathActions.ARC:e=this.actions[d-1].args;h=f[0];i=f[1];l=f[2];o=f[3];n=f[4];p=!!f[5];k=e[e.length-2];m=e[e.length-1];e.length==0&&(k=m=0);r=n-o;var q=a*2;for(e=1;e<=q;e++)n=e/q,p||(n=1-n),n=o+n*r,f=k+h+l*Math.cos(n),n=m+i+l*Math.sin(n),b.push(new THREE.Vector2(f,n))}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,d,g,f){var e=this.getPoints(),h,i,l,k,o;h=0;for(i=e.length;h=0?h-1:b.length-1;f=e-1>=0?e-1:l.length-1;var n=[l[e],b[h],b[g]];o=THREE.FontUtils.Triangulate.area(n);var q=[l[e],l[f],b[h]];p=THREE.FontUtils.Triangulate.area(q);m=h;k=e;h+=1;e+=-1;h< 0&&(h+=b.length);h%=b.length;e<0&&(e+=l.length);e%=l.length;g=h-1>=0?h-1:b.length-1;f=e-1>=0?e-1:l.length-1;n=[l[e],b[h],b[g]];n=THREE.FontUtils.Triangulate.area(n);q=[l[e],l[f],b[h]];q=THREE.FontUtils.Triangulate.area(q);o+p>n+q&&(h=m,e=k,h<0&&(h+=b.length),h%=b.length,e<0&&(e+=l.length),e%=l.length,g=h-1>=0?h-1:b.length-1,f=e-1>=0?e-1:l.length-1);o=b.slice(0,h);p=b.slice(h);m=l.slice(e);k=l.slice(0,e);f=[l[e],l[f],b[h]];r.push([l[e],b[h],b[g]]);r.push(f);b=o.concat(m).concat(k).concat(p)}return{shape:b, isolatedPts:r,allpoints:d}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),d=b.allpoints,g=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),f,e,h,i,l={};f=0;for(e=d.length;f1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+m),d=d<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=g[0]+(f[0]-g[0])*d,b.y=g[1]+(f[1]-g[1])*d,b.z=g[2]+(f[2]-g[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",m,e.index-1).pos,this.points[1]=g,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",m,h.index+1).pos,d=d*0.33+0.33,g=this.interpolateCatmullRom(this.points,d),b.x=g[0],b.y=g[1],b.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(b=== "rot")THREE.Quaternion.slerp(g,f,a.quaternion,d);else if(b==="scl")b=a.scale,b.x=g[0]+(f[0]-g[0])*d,b.y=g[1]+(f[1]-g[1])*d,b.z=g[2]+(f[2]-g[2])*d}}if(this.JITCompile&&k[0][l]===void 0){this.hierarchy[0].update(null,!0);for(m=0;ma.length-2?f:f+1;b[3]=f>a.length-3?f:f+2;f=a[b[0]];h=a[b[1]];i=a[b[2]];l=a[b[3]];b=g*g;e=g*b;d[0]=this.interpolate(f[0],h[0],i[0],l[0],g,b,e);d[1]=this.interpolate(f[1],h[1],i[1],l[1],g,b,e);d[2]=this.interpolate(f[2],h[2],i[2],l[2],g,b,e);return d}; THREE.Animation.prototype.interpolate=function(a,c,b,d,g,f,e){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*e+(-3*(c-b)-2*a-d)*f+a*g+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=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+d.length;b>=0;b--)if(d[b][a]!==void 0)return d[b];return this.data.hierarchy[c].keys[d.length-1]}; THREE.CubeCamera=function(a,c,b,d){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(d,d,{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,d,g,f,e){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,f,e);this.cameraP=new THREE.PerspectiveCamera(b,a/c,d,g);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.005;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){var b=0;if(!this.freeze){if(this.heightSpeed){var c=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=a*c*this.heightCoef}else this.autoSpeedFactor=0;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);c=a*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a= 1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)* Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",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 d(a,b){return function(){b.apply(a,arguments)}}function g(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),q=g.length,t=0;f=q-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f=0?a:a+e;c=this.verticalAngleMap.srcRange; a=this.verticalAngleMap.dstRange;c=THREE.Math.mapLinear(this.phi,c[0],c[1],a[0],a[1]);var d=a[1]-a[0];this.phi=b((c-a[0])/d)*d+a[0];c=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;c=THREE.Math.mapLinear(this.theta,c[0],c[1],a[0],a[1]);d=a[1]-a[0];this.theta=b((c-a[0])/d)*d+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),e=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(e,b);a.position.set(0,10,0);this.animation=g(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=g(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,e=f(b,10),c=f(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),e=new THREE.Line(e,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));e.scale.set(1,1,1);a.add(e);c.scale.set(1,1,1);a.add(c);for(var e=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),m=0;m0){var b=this.getContainerDimensions(),c=b.size[0]/2,e=b.size[1]/2;this.moveState.yawLeft=-(a.pageX-b.offset[0]-c)/c;this.moveState.pitchDown=(a.pageY-b.offset[1]-e)/e;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,d=new THREE.Vector3,g=new THREE.Vector3,f=new THREE.Matrix4,e=!1,h=1,i=0,l=0,k=0,o=0,p=0,m=window.innerWidth/2,r=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var c=a*this.lookSpeed; this.rotateHorizontally(c*o);this.rotateVertically(c*p)}c=a*this.movementSpeed;this.object.translateZ(-c*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(c*l);this.object.translateY(c*k);e&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y1?d.normalize():d.z=Math.sqrt(1-f*f);e.copy(b.object.position).subSelf(b.target);f=b.object.up.clone().setLength(d.y);f.addSelf(b.object.up.clone().crossSelf(e).setLength(d.x));f.addSelf(e.setLength(d.z));return f};this.rotateCamera=function(){var a=Math.acos(h.dot(i)/h.length()/i.length());if(a){var c=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion;a*=b.rotateSpeed;d.setFromAxisAngle(c, -a);d.multiplyVector3(e);d.multiplyVector3(b.object.up);d.multiplyVector3(i);b.staticMoving?h=i:(d.setFromAxisAngle(c,a*(b.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-l.y)*b.zoomSpeed;a!==1&&a>0&&(e.multiplyScalar(a),b.staticMoving?l=k:l.y+=(k.y-l.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=p.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(e.length()*b.panSpeed);var c=e.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?o=p:o.addSelf(a.sub(p,o).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),e.lengthSq()0?1:-1;for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,e,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-e,0)));for(h=0;ha&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function g(a){for(s=a.length;--s>=0;){S=s;ba=s-1;ba<0&&(ba=a.length-1);for(var b= 0,c=m+k*2,b=0;b=0;R--){U=R/k;K=i*(1-U);U=l*Math.sin(U*Math.PI/2);s=0;for(E=w.length;s0)for(l=0;l2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return f}i=l;g<=i&&(i=0);l=i+1;g<=l&&(l=0);k=l+1;g<=k&&(k=0);var p;a:{p=a;var m=i,r=l,n=k,q=g,t=e,w=void 0,u=void 0,B=void 0, F=void 0,A=void 0,x=void 0,y=void 0,v=void 0,J=void 0,u=p[t[m]].x,B=p[t[m]].y,F=p[t[r]].x,A=p[t[r]].y,x=p[t[n]].x,y=p[t[n]].y;if(1.0E-10>(F-u)*(y-B)-(A-B)*(x-u))p=!1;else{for(w=0;w=0&&R>=0&&K>=0){p=!1;break a}}p= !0}}if(p){f.push([a[e[i]],a[e[l]],a[e[k]]]);h.push([e[i],e[l],e[k]]);i=l;for(k=l+1;k0;)this.smooth(a)}; THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,d,h,i){var k=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(e.useOldVertexColors){k.vertexColors=[];for(var l,m,n,j=0;j<4;j++){n=i[j];l=new THREE.Color;l.setRGB(0,0,0);for(var o=0;o=0){p=i.invBindMatrices[m];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p1){j=new THREE.MeshFaceMaterial;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(e=0;e1?c[1].substr(0,b):"0";c[1].length=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;db){l=k.output[i];break}g=l!==void 0?l instanceof THREE.Matrix4?g.multiply(g,l):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;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};o.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};J.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 d=this[c];if(d instanceof v)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=$[this.effect.surface.init_from]))a.map= THREE.ImageUtils.loadTexture(Da+d.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=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=Ba;return this.material=new THREE.MeshLambertMaterial(a)};s.prototype.parse=function(a){for(var b=0;b=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b1&&(E=new THREE.MeshFaceMaterial); a=new THREE.Mesh(v,E);a.name=p;a.position.set(B[0],B[1],B[2]);A?(a.quaternion.set(A[0],A[1],A[2],A[3]),a.useQuaternion=!0):a.rotation.set(F[0],F[1],F[2]);a.scale.set(x[0],x[1],x[2]);a.visible=t.visible;H.scene.add(a);H.objects[p]=a;if(t.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);H.scene.collisions.colliders.push(b)}if(t.castsShadow)b=new THREE.ShadowVolume(v),H.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;t.trigger&&t.trigger.toLowerCase()!="none"&&(b= {type:t.trigger,object:t},H.triggers[a.name]=b)}}else B=t.position,F=t.rotation,A=t.quaternion,x=t.scale,A=0,a=new THREE.Object3D,a.name=p,a.position.set(B[0],B[1],B[2]),A?(a.quaternion.set(A[0],A[1],A[2],A[3]),a.useQuaternion=!0):a.rotation.set(F[0],F[1],F[2]),a.scale.set(x[0],x[1],x[2]),a.visible=t.visible!==void 0?t.visible:!1,H.scene.add(a),H.objects[p]=a,H.empties[p]=a,t.trigger&&t.trigger.toLowerCase()!="none"&&(b={type:t.trigger,object:t},H.triggers[a.name]=b)}function f(a){return function(b){H.geometries[a]= b;g();K-=1;i.onLoadComplete();h()}}function e(a){return function(b){H.geometries[a]=b}}function h(){i.callbackProgress({totalModels:O,totalTextures:aa,loadedModels:O-K,loadedTextures:aa-P},H);i.onLoadProgress();K==0&&P==0&&c(H)}var i=this,l=THREE.Loader.prototype.extractUrlbase(b),k,o,p,m,r,n,q,t,w,u,B,F,A,x,y,v,J,s,E,R,U,K,P,O,aa,H;R=a;b=new THREE.BinaryLoader;U=new THREE.JSONLoader;P=K=0;H={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, empties:{}};a=!1;for(p in R.objects)if(t=R.objects[p],t.meshCollider){a=!0;break}if(a)H.scene.collisions=new THREE.CollisionSystem;if(R.transform){a=R.transform.position;w=R.transform.rotation;var G=R.transform.scale;a&&H.scene.position.set(a[0],a[1],a[2]);w&&H.scene.rotation.set(w[0],w[1],w[2]);G&&H.scene.scale.set(G[0],G[1],G[2]);(a||w||G)&&H.scene.updateMatrix()}a=function(){P-=1;h();i.onLoadComplete()};for(r in R.cameras)w=R.cameras[r],w.type=="perspective"?J=new THREE.PerspectiveCamera(w.fov, w.aspect,w.near,w.far):w.type=="ortho"&&(J=new THREE.OrthographicCamera(w.left,w.right,w.top,w.bottom,w.near,w.far)),B=w.position,w=w.target,J.position.set(B[0],B[1],B[2]),J.target=new THREE.Vector3(w[0],w[1],w[2]),H.cameras[r]=J;for(m in R.lights)w=R.lights[m],r=w.color!==void 0?w.color:16777215,J=w.intensity!==void 0?w.intensity:1,w.type=="directional"?(B=w.direction,u=new THREE.DirectionalLight(r,J),u.position.set(B[0],B[1],B[2]),u.position.normalize()):w.type=="point"?(B=w.position,u=w.distance, u=new THREE.PointLight(r,J,u),u.position.set(B[0],B[1],B[2])):w.type=="ambient"&&(u=new THREE.AmbientLight(r)),H.scene.add(u),H.lights[m]=u;for(n in R.fogs)m=R.fogs[n],m.type=="linear"?s=new THREE.Fog(0,m.near,m.far):m.type=="exp2"&&(s=new THREE.FogExp2(0,m.density)),w=m.color,s.color.setRGB(w[0],w[1],w[2]),H.fogs[n]=s;if(H.cameras&&R.defaults.camera)H.currentCamera=H.cameras[R.defaults.camera];if(H.fogs&&R.defaults.fog)H.scene.fog=H.fogs[R.defaults.fog];w=R.defaults.bgcolor;H.bgColor=new THREE.Color; H.bgColor.setRGB(w[0],w[1],w[2]);H.bgColorAlpha=R.defaults.bgalpha;for(k in R.geometries)if(n=R.geometries[k],n.type=="bin_mesh"||n.type=="ascii_mesh")K+=1,i.onLoadStart();O=K;for(k in R.geometries)n=R.geometries[k],n.type=="cube"?(v=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),H.geometries[k]=v):n.type=="plane"?(v=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),H.geometries[k]=v):n.type=="sphere"? (v=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),H.geometries[k]=v):n.type=="cylinder"?(v=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),H.geometries[k]=v):n.type=="torus"?(v=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),H.geometries[k]=v):n.type=="icosahedron"?(v=new THREE.IcosahedronGeometry(n.subdivisions),H.geometries[k]=v):n.type=="bin_mesh"?b.load(d(n.url,R.urlBaseType),f(k)):n.type=="ascii_mesh"?U.load(d(n.url,R.urlBaseType), f(k)):n.type=="embedded_mesh"&&(n=R.embeds[n.id])&&U.createModel(n,e(k),"");for(q in R.textures)if(k=R.textures[q],k.url instanceof Array){P+=k.url.length;for(n=0;n=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),d=1,g=0;g<8;g++){for(var f=0,e=0;e>1^-(h&1);b[8*e+g]=f}d+=c}c=a.length-d;f=new Uint16Array(c);for(g=e=0;g=this.maxCount-3&&h(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&&(i=this.size-1);var p=Math.floor(l-h);p<1&&(p=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var m=Math.floor(k-h);m<1&&(m=1);h=Math.floor(k+h);h>this.size-1&&(h=this.size- 1);for(var r,n,q,t,w,u;o0&&(this.field[q+r]+=t)}}};this.addPlaneX=function(a,c){var g,f,e,h,i,l=this.size,k=this.yd,o=this.zd,p=this.field,m=l*Math.sqrt(a/c);m>l&&(m=l);for(g=0;g0)for(f=0;fk&&(r=k);for(f=0;f0){i=f*o;for(g=0;gk&&(r=k);for(e=0;e0){i=p*e;for(f=0;f