topical media & game development
mobile-query-three-plugins-cannonjs-vendor-cannon.js-libs-Three.js / js
// three.min.js - http://github.com/mrdoob/three.js
'use strict';var THREE=THREE||{REVISION:"51"};void 0===self.console&&(self.console={info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}});void 0===self.Int32Array&&(self.Int32Array=Array,self.Float32Array=Array);void 0===String.prototype.startsWith&&(String.prototype.startsWith=function(a){return this.slice(0,a.length)===a});
void 0===String.prototype.endsWith&&(String.prototype.endsWith=function(a){var a=String(a),b=this.lastIndexOf(a);return b>=0&&b===this.length-a.length});void 0===!String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^\s+|\s+.copy(Y);ba=i[a];K.copy(ba);K.subSelf(Y.multiplyScalar(Y.dot(ba))).normalize();
V.cross(=new THREE.Vector3,L,ba,Q;D=0;for(G=J.length;D<G;++D){M=J[D].start;H=J[D].count;I=J[D].index;z=M;
for(M=M+H;z<M;z=z+3){H=I+b[z];O=I+b[z+1];F=I+b[z+2];a(H);a(O);a(F)}}this.tangentsNeedUpdate=this.hasTangents=true}}};
THREE.Spline=function(a){function b(a,b,c,d,f,e,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*e+a*f+b}this.points=a;var c=[],d={x:0,y:0,z:0},f,e,g,h,i,j,l,n,m;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){f=(this.points.length-1)*a;e=Math.floor(f);g=f-e;c[0]=e===0?e:e-1;c[1]=e;c[2]=e>this.points.length-2?this.points.length-1:e+1;c[3]=e>this.points.length-3?this.points.length-1:
e+2;j=this.points[c[0]];l=this.points[c[1]];n=this.points[c[2]];m=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,l.x,n.x,m.x,g,h,i);d.y=b(j.y,l.y,n.y,m.y,g,h,i);d.z=b(j.z,l.z,n.z,m.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++){b=this.points[a];d[a]=[b.x,b.y,b.z]}return d};this.getLength=function(a){var b,c,d,f=b=b=0,e=new THREE.Vector3,g=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;e.copy(this.points[0]);for(a=1;a<c;a++){b=
a/c;d=this.getPoint(b);g.copy(d);i=i+g.distanceTo(e);e.copy(d);b=(this.points.length-1)*b;b=Math.floor(b);if(b!=f){h[b]=i;f=b}}h[h.length]=i;return{chunks:h,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,f,e,g,h=[],i=new THREE.Vector3,l=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=l.chunks[b]-l.chunks[b-1];g=Math.ceil(a*c/l.total);f=(b-1)/(this.points.length-1);e=b/(this.points.length-1);for(c=1;c<g-1;c++){d=f+c*(1/g)*(e-f);d=this.getPoint(d);
h.push(i.copy(d).clone())}h.push(i.copy(this.points[b]).clone())}this.points=h}};THREE.Camera=function(){THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=Object.create(THREE.Object3D.prototype);THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate===true&&this.rotation.setEulerFromRotationMatrix(this.matrix,this.eulerOrder)};
THREE.OrthographicCamera=function(a,b,c,d,f,e){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=f!==void 0?f:0.1;this.far=e!==void 0?e:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=Object.create(THREE.Camera.prototype);THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix.makeOrthographic(this.left,this.right,this.top,this.bottom,this.near,this.far)};
THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=a!==void 0?a:50;this.aspect=b!==void 0?b:1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=Object.create(THREE.Camera.prototype);THREE.PerspectiveCamera.prototype.setLens=function(a,b){b===void 0&&(b=24);this.fov=2*Math.atan(b/(a*2))*(180/Math.PI);this.updateProjectionMatrix()};
THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,f,e){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=f;this.height=e;this.updateProjectionMatrix()};
THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(this.fov,this.aspect,this.near,this.far)};
THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=Object.create(THREE.Object3D.prototype);THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=Object.create(THREE.Light.prototype);
THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0;this.onlyShadow=this.castShadow=false;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraLeft=-500;this.shadowCameraTop=this.shadowCameraRight=500;this.shadowCameraBottom=-500;this.shadowCameraVisible=false;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;
this.shadowCascade=false;this.shadowCascadeOffset=new THREE.Vector3(0,0,-1E3);this.shadowCascadeCount=2;this.shadowCascadeBias=[0,0,0];this.shadowCascadeWidth=[512,512,512];this.shadowCascadeHeight=[512,512,512];this.shadowCascadeNearZ=[-1,0.99,0.998];this.shadowCascadeFarZ=[0.99,0.998,1];this.shadowCascadeArray=[];this.shadowMatrix=this.shadowCamera=this.shadowMapSize=this.shadowMap=null};THREE.DirectionalLight.prototype=Object.create(THREE.Light.prototype);
THREE.HemisphereLight=function(a,b,c){THREE.Light.call(this,a);this.groundColor=new THREE.Color(b);this.position=new THREE.Vector3(0,100,0);this.intensity=c!==void 0?c:1};THREE.HemisphereLight.prototype=Object.create(THREE.Light.prototype);THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0};THREE.PointLight.prototype=Object.create(THREE.Light.prototype);
THREE.SpotLight=function(a,b,c,d,f){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=b!==void 0?b:1;this.distance=c!==void 0?c:0;this.angle=d!==void 0?d:Math.PI/2;this.exponent=f!==void 0?f:10;this.onlyShadow=this.castShadow=false;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowCameraVisible=false;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowMatrix=
this.shadowCamera=this.shadowMapSize=this.shadowMap=null};THREE.SpotLight.prototype=Object.create(THREE.Light.prototype);THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:"anonymous",addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ",b=a.total?b+((100*a.loaded/
a.total).toFixed(0)+"%"):b+((a.loaded/1E3).toFixed(2)+" KB");this.statusDomElement.innerHTML=b},extractUrlBase:function(a){a=a.split("/");a.pop();return(a.length<1?".":a.join("/"))+"/"},initMaterials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(b[d],c)},hasNormals:function(a){var b,c,d=a.materials.length;for(c=0;c<d;c++){b=a.materials[c];if(b instanceof THREE.ShaderMaterial)return true}return false},createMaterial:function(a,b){function c(a){a=
Math.log(a)/Math.LN2;return Math.floor(a)==a}function d(a){a=Math.log(a)/Math.LN2;return Math.pow(2,Math.round(a))}function f(a,f,e,h,i,j,r){var t=e.toLowerCase().endsWith(".dds"),u=b+"/"+e;if(t){var w=THREE.ImageUtils.loadCompressedTexture(u);a[f]=w}else{w=document.createElement("canvas");a[f]=new THREE.Texture(w)}a[f].sourceFile=e;if(h){a[f].repeat.set(h[0],h[1]);if(h[0]!==1)a[f].wrapS=THREE.RepeatWrapping;if(h[1]!==1)a[f].wrapT=THREE.RepeatWrapping}i&&a[f].offset.set(i[0],i[1]);if(j){e={repeat:THREE.RepeatWrapping,
mirror:THREE.MirroredRepeatWrapping};if(e[j[0]]!==void 0)a[f].wrapS=e[j[0]];if(e[j[1]]!==void 0)a[f].wrapT=e[j[1]]}if(r)a[f].anisotropy=r;if(!t){var s=a[f],a=new Image;a.onload=function(){if(!c(this.width)||!c(this.height)){var a=d(this.width),b=d(this.height);s.image.width=a;s.image.height=b;s.image.getContext("2d").drawImage(this,0,0,a,b)}else s.image=this;s.needsUpdate=true};a.crossOrigin=g.crossOrigin;a.src=u}}function e(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var g=this,h="MeshLambertMaterial",
i={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,bumpMap:null,wireframe:false};if(a.shading){var j=a.shading.toLowerCase();j==="phong"?h="MeshPhongMaterial":j==="basic"&&(h="MeshBasicMaterial")}if(a.blending!==void 0&&THREE[a.blending]!==void 0)i.blending=THREE[a.blending];if(a.transparent!==void 0||a.opacity<1)i.transparent=a.transparent;if(a.depthTest!==void 0)i.depthTest=a.depthTest;if(a.depthWrite!==void 0)i.depthWrite=a.depthWrite;if(a.visible!==void 0)i.visible=a.visible;if(a.flipSided!==
void 0)i.side=THREE.BackSide;if(a.doubleSided!==void 0)i.side=THREE.DoubleSide;if(a.wireframe!==void 0)i.wireframe=a.wireframe;if(a.vertexColors!==void 0)if(a.vertexColors==="face")i.vertexColors=THREE.FaceColors;else if(a.vertexColors)i.vertexColors=THREE.VertexColors;if(a.colorDiffuse)i.color=e(a.colorDiffuse);else if(a.DbgColor)i.color=a.DbgColor;if(a.colorSpecular)i.specular=e(a.colorSpecular);if(a.colorAmbient)i.ambient=e(a.colorAmbient);if(a.transparency)i.opacity=a.transparency;if(a.specularCoef)i.shininess=
a.specularCoef;a.mapDiffuse&&b&&f(i,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);a.mapLight&&b&&f(i,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);a.mapBump&&b&&f(i,"bumpMap",a.mapBump,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);a.mapNormal&&b&&f(i,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);a.mapSpecular&&b&&f(i,"specularMap",
a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);if(a.mapBumpScale)i.bumpScale=a.mapBumpScale;if(a.mapNormal){h=THREE.ShaderUtils.lib.normal;j=THREE.UniformsUtils.clone(h.uniforms);j.tNormal.value=i.normalMap;a.mapNormalFactor&&j.uNormalScale.value.set(a.mapNormalFactor,a.mapNormalFactor);if(i.map){j.tDiffuse.value=i.map;j.enableDiffuse.value=true}if(i.specularMap){j.tSpecular.value=i.specularMap;j.enableSpecular.value=true}if(i.lightMap){j.tAO.value=
i.lightMap;j.enableAO.value=true}j.uDiffuseColor.value.setHex(i.color);j.uSpecularColor.value.setHex(i.specular);j.uAmbientColor.value.setHex(i.ambient);j.uShininess.value=i.shininess;if(i.opacity!==void 0)j.uOpacity.value=i.opacity;i=new THREE.ShaderMaterial({fragmentShader:h.fragmentShader,vertexShader:h.vertexShader,uniforms:j,lights:true,fog:true})}else i=new THREE[h](i);if(a.DbgName!==void 0)i.name=a.DbgName;return i}};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};
THREE.BinaryLoader.prototype=Object.create(THREE.Loader.prototype);THREE.BinaryLoader.prototype.load=function(a,b,c,d){var c=c?c:this.extractUrlBase(a),d=d?d:this.extractUrlBase(a),f=this.showProgress?THREE.Loader.prototype.updateProgress:null;this.onLoadStart();this.loadAjaxJSON(this,a,b,c,d,f)};
THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,f,e){var g=new XMLHttpRequest;g.onreadystatechange=function(){if(g.readyState==4)if(g.status==200||g.status==0){var h=JSON.parse(g.responseText);a.loadAjaxBuffers(h,c,f,d,e)}else console.error("THREE.BinaryLoader: Couldn't load ["+b+"] ["+g.status+"]")};g.open("GET",b,true);g.send(null)};
THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,f){var e=new XMLHttpRequest,g=c+"/"+a.buffers,h=0;e.onreadystatechange=function(){if(e.readyState==4)if(e.status==200||e.status==0){var c=e.response;if(c===void 0)c=(new Uint8Array(e.responseBody)).buffer;THREE.BinaryLoader.prototype.createBinModel(c,b,d,a.materials)}else console.error("THREE.BinaryLoader: Couldn't load ["+g+"] ["+e.status+"]");else if(e.readyState==3){if(f){h==0&&(h=e.getResponseHeader("Content-Length"));f({total:h,loaded:e.responseText.length})}}else e.readyState==
2&&(h=e.getResponseHeader("Content-Length"))};e.open("GET",g,true);e.responseType="arraybuffer";e.send(null)};
THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var f=function(b){var c,f,i,j,l,n,m,q,p,o,r,t,u,w,s;function B(a){return a%4?4-a%4:0}function v(a,b){return(new Uint8Array(a,b,1))[0]}function A(a,b){return(new Uint32Array(a,b,1))[0]}function E(b,c){var d,f,e,g,h,i,j,l,n=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){f=n[d*3];e=n[d*3+1];g=n[d*3+2];h=I[f*2];f=I[f*2+1];i=I[e*2];j=I[e*2+1];e=I[g*2];l=I[g*2+1];g=O.faceVertexUvs[0];var m=[];m.push(new THREE.UV(h,f));m.push(new THREE.UV(i,j));m.push(new THREE.UV(e,
l));g.push(m)}}function z(b,c){var d,f,e,g,h,i,j,l,n,m,o=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){f=o[d*4];e=o[d*4+1];g=o[d*4+2];h=o[d*4+3];i=I[f*2];f=I[f*2+1];j=I[e*2];n=I[e*2+1];l=I[g*2];m=I[g*2+1];g=I[h*2];e=I[h*2+1];h=O.faceVertexUvs[0];var p=[];p.push(new THREE.UV(i,f));p.push(new THREE.UV(j,n));p.push(new THREE.UV(l,m));p.push(new THREE.UV(g,e));h.push(p)}}function M(b,c,d){for(var f,e,g,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++){f=c[d*3];e=c[d*3+1];g=c[d*3+2];h=i[d];
O.faces.push(new THREE.Face3(f,e,g,null,null,h))}}function D(b,c,d){for(var f,e,g,h,i,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++){f=c[d*4];e=c[d*4+1];g=c[d*4+2];h=c[d*4+3];i=j[d];O.faces.push(new THREE.Face4(f,e,g,h,null,null,i))}}function G(b,c,d,f){for(var e,g,h,i,j,l,n,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),m=new Uint16Array(a,f,b),f=0;f<b;f++){e=c[f*3];g=c[f*3+1];h=c[f*3+2];j=d[f*3];l=d[f*3+1];n=d[f*3+2];i=m[f];var o=J[l*3],p=J[l*3+1];l=J[l*3+2];var q=J[n*3],
r=J[n*3+1];n=J[n*3+2];O.faces.push(new THREE.Face3(e,g,h,[new THREE.Vector3(J[j*3],J[j*3+1],J[j*3+2]),new THREE.Vector3(o,p,l),new THREE.Vector3(q,r,n)],null,i))}}function H(b,c,d,f){for(var e,g,h,i,j,l,n,m,o,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),p=new Uint16Array(a,f,b),f=0;f<b;f++){e=c[f*4];g=c[f*4+1];h=c[f*4+2];i=c[f*4+3];l=d[f*4];n=d[f*4+1];m=d[f*4+2];o=d[f*4+3];j=p[f];var q=J[n*3],r=J[n*3+1];n=J[n*3+2];var s=J[m*3],t=J[m*3+1];m=J[m*3+2];var v=J[o*3],u=J[o*3+1];o=J[o*3+2];O.faces.push(new THREE.Face4(e,
g,h,i,[new THREE.Vector3(J[l*3],J[l*3+1],J[l*3+2]),new THREE.Vector3(q,r,n),new THREE.Vector3(s,t,m),new THREE.Vector3(v,u,o)],null,j))}}var O=this,F=0,J=[],I=[],K,V,Y;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(O,d,b);s=a;V=F;b=new Uint8Array(s,V,12);o="";for(u=0;u<12;u++)o=o+String.fromCharCode(b[V+u]);c=v(s,V+12);v(s,V+13);v(s,V+14);v(s,V+15);f=v(s,V+16);i=v(s,V+17);j=v(s,V+18);l=v(s,V+19);n=A(s,V+20);m=A(s,V+20+4);q=A(s,V+20+8);p=A(s,V+20+12);o=A(s,V+20+16);r=A(s,V+20+20);t=
A(s,V+20+24);u=A(s,V+20+28);b=A(s,V+20+32);w=A(s,V+20+36);s=A(s,V+20+40);F=F+c;V=f*3+l;Y=f*4+l;K=p*V;c=o*(V+i*3);f=r*(V+j*3);l=t*(V+i*3+j*3);V=u*Y;i=b*(Y+i*4);j=w*(Y+j*4);Y=F;var F=new Float32Array(a,F,n*3),=0;++){L=F[*3+1];Q=F[=F[Y*3];L=F[Y*3+1];ba=F[Y*3+2];J.push(=F[n*2+1];I.push(Y,,L,ba,Q,fa,ta,da=new THREE.Color,ga=new THREE.Color,N=new THREE.Color,U=new THREE.Color,ia=new THREE.Color,Ia={},pa={},ua,Ca,Ja,Xa,ja,pb,Oa,Ya,wb,xb,fb=new THREE.Rectangle,Fa=new THREE.Rectangle,xa=new THREE.Rectangle,qb=false,Ga=new THREE.Color,a.setRGB(0,0,0);rb.setRGB(0,0,0);Vb=0;for(Ec=i.length;Vb<Ec;Vb++){X=i[Vb];var ca=X.color;if(X instanceof THREE.AmbientLight){Ga.r=Ga.r+ca.r;Ga.g=Ga.g+ca.g;Ga.b=Ga.b+ca.b}else if(X instanceof THREE.DirectionalLight){a.r+ca.r;a.g+ca.g;a.b+ca.b}else if(X instanceof
THREE.PointLight){rb.r=rb.r+ca.r;rb.g=rb.g+ca.g;rb.b=rb.b+ca.b}}}Vb=0;for(Ec=h.length;Vb<Ec;Vb++){B=h[Vb];X=B.material;if(!(X===void 0||X.visible===false)){xa.empty();if(B instanceof THREE.RenderableParticle){z=B;z.x=z.x*q;z.y=z.y*p;var ca=z,oa=B;b(X.opacity);c(X.blending);var Ea=void 0,tb=void 0,jb=void 0,kb=void 0,Wb=void 0,Tc=B=void 0;if(X instanceof THREE.ParticleBasicMaterial)if(X.map===null){jb=oa.object.scale.x;kb=oa.object.scale.y;jb=jb*oa.scale.x*q;kb=kb*oa.scale.y*p;xa.set(ca.x-jb,ca.y-
kb,ca.x+jb,ca.y+kb);if(fb.intersects(xa)!==false){f(X.color.getContextStyle());o.save();o.translate(ca.x,ca.y);o.rotate(-oa.rotation);o.scale(jb,kb);o.fillRect(-1,-1,2,2);o.restore()}}else{Wb=X.map.image;B=Wb.width>>1;Tc=Wb.height>>1;jb=oa.scale.x*q;kb=oa.scale.y*p;Ea=jb*B;tb=kb*Tc;xa.set(ca.x-Ea,ca.y-tb,ca.x+Ea,ca.y+tb);if(fb.intersects(xa)!==false){o.save();o.translate(ca.x,ca.y);o.rotate(-oa.rotation);o.scale(jb,-kb);o.translate(-B,-Tc);o.drawImage(Wb,0,0);o.restore()}}else if(X instanceof THREE.ParticleCanvasMaterial){Ea=
oa.scale.x*q;tb=oa.scale.y*p;xa.set(ca.x-Ea,ca.y-tb,ca.x+Ea,ca.y+tb);if(fb.intersects(xa)!==false){d(X.color.getContextStyle());f(X.color.getContextStyle());o.save();o.translate(ca.x,ca.y);o.rotate(-oa.rotation);o.scale(Ea,tb);X.program(o);o.restore()}}}else if(B instanceof THREE.RenderableLine){z=B.v1;M=B.v2;z.positionScreen.x=z.positionScreen.x*q;z.positionScreen.y=z.positionScreen.y*p;M.positionScreen.x=M.positionScreen.x*q;M.positionScreen.y=M.positionScreen.y*p;xa.addPoint(z.positionScreen.x,
z.positionScreen.y);xa.addPoint(M.positionScreen.x,M.positionScreen.y);if(fb.intersects(xa)===true){ca=z;oa=M;b(X.opacity);c(X.blending);o.beginPath();o.moveTo(ca.positionScreen.x,ca.positionScreen.y);o.lineTo(oa.positionScreen.x,oa.positionScreen.y);if(X instanceof THREE.LineBasicMaterial){ca=X.linewidth;if(v!==ca)v=o.lineWidth=ca;ca=X.linecap;if(A!==ca)A=o.lineCap=ca;ca=X.linejoin;if(E!==ca)E=o.lineJoin=ca;d(X.color.getContextStyle());o.stroke();xa.inflate(X.linewidth*2)}}}else if(B instanceof THREE.RenderableFace3){z=
B.v1;M=B.v2;D=B.v3;z.positionScreen.x=z.positionScreen.x*q;z.positionScreen.y=z.positionScreen.y*p;M.positionScreen.x=M.positionScreen.x*q;M.positionScreen.y=M.positionScreen.y*p;D.positionScreen.x=D.positionScreen.x*q;D.positionScreen.y=D.positionScreen.y*p;if(X.overdraw===true){sb(z.positionScreen,M.positionScreen);sb(M.positionScreen,D.positionScreen);sb(D.positionScreen,z.positionScreen)}xa.add3Points(z.positionScreen.x,z.positionScreen.y,M.positionScreen.x,M.positionScreen.y,D.positionScreen.x,
D.positionScreen.y);fb.intersects(xa)===true&&n(z,M,D,0,1,2,B,X,a)}else if(B instanceof THREE.RenderableFace4){z=B.v1;M=B.v2;D=B.v3;G=B.v4;z.positionScreen.x=z.positionScreen.x*q;z.positionScreen.y=z.positionScreen.y*p;M.positionScreen.x=M.positionScreen.x*q;M.positionScreen.y=M.positionScreen.y*p;D.positionScreen.x=D.positionScreen.x*q;D.positionScreen.y=D.positionScreen.y*p;G.positionScreen.x=G.positionScreen.x*q;G.positionScreen.y=G.positionScreen.y*p;H.positionScreen.copy(M.positionScreen);O.positionScreen.copy(G.positionScreen);
if(X.overdraw===true){sb(z.positionScreen,M.positionScreen);sb(M.positionScreen,G.positionScreen);sb(G.positionScreen,z.positionScreen);sb(D.positionScreen,H.positionScreen);sb(D.positionScreen,O.positionScreen)}xa.addPoint(z.positionScreen.x,z.positionScreen.y);xa.addPoint(M.positionScreen.x,M.positionScreen.y);xa.addPoint(D.positionScreen.x,D.positionScreen.y);xa.addPoint(G.positionScreen.x,G.positionScreen.y);if(fb.intersects(xa)===true){oa=z;Ea=M;tb=D;jb=G;kb=H;Wb=O;ca=B;B=a;e.info.render.vertices=
e.info.render.vertices+4;e.info.render.faces++;b(X.opacity);c(X.blending);if(X.map!==void 0&&X.map!==null||X.envMap!==void 0&&X.envMap!==null){n(oa,Ea,jb,0,1,3,ca,X,B);n(kb,tb,Wb,1,2,3,ca,X,B)}else{F=oa.positionScreen.x;J=oa.positionScreen.y;I=Ea.positionScreen.x;K=Ea.positionScreen.y;V=tb.positionScreen.x;Y=tb.positionScreen.y;,L);w(F,J,I,K,,L);X.wireframe===true?s(da,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):
t(da)}}else{r(F,J,I,K,V,Y,,L);X.wireframe===true?s(X.color,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):t(X.color)}else if(X instanceof THREE.MeshNormalMaterial){da.r=jc(ca.normalWorld.x);da.g=jc(ca.normalWorld.y);da.b=jc(ca.normalWorld.z);r(F,J,I,K,V,Y,,L);w(F,J,I,K,=0,ba=0,Y=0,c=o=q=q=p=0,e=b.length;c<e;c++){j=b[c];if(!j.onlyShadow&&j.visible){o=
j.color;r=j.intensity;p=j.distance;if(j instanceof THREE.AmbientLight)if(Q.gammaInput){l=l+o.r*o.r;m=m+o.g*o.g;n=n+o.b*o.b}else{l=l+o.r;m=m+o.g;n=n+o.b}else if(j instanceof THREE.DirectionalLight){p=V*3;Q.gammaInput?B(t,p,o,r*r):v(t,p,o,r);Qa.copy(j.matrixWorld.getPosition());Qa.subSelf(j.target.matrixWorld.getPosition());Qa.normalize();u[p]=Qa.x;u[p+1]=Qa.y;u[p+2]=Qa.z;V=V+1}else if(j instanceof THREE.PointLight){q=]=p;+1}else if(j instanceof THREE.SpotLight){q=ba*3;Q.gammaInput?B(D,q,o,r*r):v(D,q,o,r);r=j.matrixWorld.getPosition();G[q]=r.x;G[q+1]=r.y;G[q+2]=r.z;I[ba]=p;Qa.copy(r);Qa.subSelf(j.target.matrixWorld.getPosition());Qa.normalize();F[q]=Qa.x;F[q+1]=Qa.y;F[q+2]=Qa.z;J[ba]=Math.cos(j.angle);K[ba]=j.exponent;ba=ba+1}else if(j instanceof THREE.HemisphereLight){p=j.color;q=j.groundColor;o=Y*3;if(Q.gammaInput){r=r*r;B(L,o,p,r);B(U,o,q,r)}else{v(L,o,p,r);v(U,o,q,r)}r=j.matrixWorld.getPosition();
ga[o]=r.x;ga[o+1]=r.y;ga[o+2]=r.z;Y=Y+1}}}c=V*3;for(e=t.length;c<e;c++)t[c]=0;c=;s.spot.length=ba;s.hemi.length=Y;s.ambient[0]=l;s.ambient[1]=m;s.ambient[2]=n;hb=false}c=qc;i.ambientLightColor.value=c.ambient;i.directionalLightColor.value=c.directional.colors;i.directionalLightDirection.value=c.directional.positions;i.pointLightColor.value=
c.point.colors;i.pointLightPosition.value=c.point.positions;i.pointLightDistance.value=c.point.distances;i.spotLightColor.value=c.spot.colors;i.spotLightPosition.value=c.spot.positions;i.spotLightDistance.value=c.spot.distances;i.spotLightDirection.value=c.spot.directions;i.spotLightAngle.value=c.spot.angles;i.spotLightExponent.value=c.spot.exponents;i.hemisphereLightSkyColor.value=c.hemi.skyColors;i.hemisphereLightGroundColor.value=c.hemi.groundColors;i.hemisphereLightPosition.value=c.hemi.positions}if(d instanceof
THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial){i.opacity.value=d.opacity;Q.gammaInput?i.diffuse.value.copyGammaToLinear(d.color):i.diffuse.value=d.color;i.map.value=d.map;i.lightMap.value=d.lightMap;i.specularMap.value=d.specularMap;if(d.bumpMap){i.bumpMap.value=d.bumpMap;i.bumpScale.value=d.bumpScale}if(d.normalMap){i.normalMap.value=d.normalMap;i.normalScale.value.copy(d.normalScale)}var fa;if(d.map)fa=d.map;else if(d.specularMap)fa=d.specularMap;
else if(d.normalMap)fa=d.normalMap;else if(d.bumpMap)fa=d.bumpMap;if(fa!==void 0){c=fa.offset;fa=fa.repeat;i.offsetRepeat.value.set(c.x,c.y,fa.x,fa.y)}i.envMap.value=d.envMap;i.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1;i.reflectivity.value=d.reflectivity;i.refractionRatio.value=d.refractionRatio;i.combine.value=d.combine;i.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping}if(d instanceof THREE.LineBasicMaterial){i.diffuse.value=d.color;
i.opacity.value=d.opacity}else if(d instanceof THREE.ParticleBasicMaterial){i.psColor.value=d.color;i.opacity.value=d.opacity;i.size.value=d.size;i.scale.value=O.height/2;i.map.value=d.map}else if(d instanceof THREE.MeshPhongMaterial){i.shininess.value=d.shininess;if(Q.gammaInput){i.ambient.value.copyGammaToLinear(d.ambient);i.emissive.value.copyGammaToLinear(d.emissive);i.specular.value.copyGammaToLinear(d.specular)}else{i.ambient.value=d.ambient;i.emissive.value=d.emissive;i.specular.value=d.specular}d.wrapAround&&
i.wrapRGB.value.copy(d.wrapRGB)}else if(d instanceof THREE.MeshLambertMaterial){if(Q.gammaInput){i.ambient.value.copyGammaToLinear(d.ambient);i.emissive.value.copyGammaToLinear(d.emissive)}else{i.ambient.value=d.ambient;i.emissive.value=d.emissive}d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB)}else if(d instanceof THREE.MeshDepthMaterial){i.mNear.value=a.near;i.mFar.value=a.far;i.opacity.value=d.opacity}else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=d.opacity;if(f.receiveShadow&&!d._shadowPass&&
i.shadowMatrix){c=fa=0;for(e=b.length;c<e;c++){j=b[c];if(j.castShadow&&(j instanceof THREE.SpotLight||j instanceof THREE.DirectionalLight&&!j.shadowCascade)){i.shadowMap.value[fa]=j.shadowMap;i.shadowMapSize.value[fa]=j.shadowMapSize;i.shadowMatrix.value[fa]=j.shadowMatrix;i.shadowDarkness.value[fa]=j.shadowDarkness;i.shadowBias.value[fa]=j.shadowBias;fa++}}}b=d.uniformsList;i=0;for(fa=b.length;i<fa;i++)if(e=g.uniforms[b[i][1]]){c=b[i][0];l=c.type;j=c.value;if(l==="i")k.uniform1i(e,j);else if(l===
"f")k.uniform1f(e,j);else if(l==="v2")k.uniform2f(e,j.x,j.y);else if(l==="v3")k.uniform3f(e,j.x,j.y,j.z);else if(l==="v4")k.uniform4f(e,j.x,j.y,j.z,j.w);else if(l==="c")k.uniform3f(e,j.r,j.g,j.b);else if(l==="iv1")k.uniform1iv(e,j);else if(l==="iv")k.uniform3iv(e,j);else if(l==="fv1")k.uniform1fv(e,j);else if(l==="fv")k.uniform3fv(e,j);else if(l==="v2v"){if(c._array===void 0)c._array=new Float32Array(2*j.length);l=0;for(m=j.length;l<m;l++){n=l*2;c._array[n]=j[l].x;c._array[n+1]=j[l].y}k.uniform2fv(e,
c._array)}else if(l==="v3v"){if(c._array===void 0)c._array=new Float32Array(3*j.length);l=0;for(m=j.length;l<m;l++){n=l*3;c._array[n]=j[l].x;c._array[n+1]=j[l].y;c._array[n+2]=j[l].z}k.uniform3fv(e,c._array)}else if(l==="v4v"){if(c._array===void 0)c._array=new Float32Array(4*j.length);l=0;for(m=j.length;l<m;l++){n=l*4;c._array[n]=j[l].x;c._array[n+1]=j[l].y;c._array[n+2]=j[l].z;c._array[n+3]=j[l].w}k.uniform4fv(e,c._array)}else if(l==="m4"){if(c._array===void 0)c._array=new Float32Array(16);j.flattenToArray(c._array);
k.uniformMatrix4fv(e,false,c._array)}else if(l==="m4v"){if(c._array===void 0)c._array=new Float32Array(16*j.length);l=0;for(m=j.length;l<m;l++)j[l].flattenToArrayOffset(c._array,l*16);k.uniformMatrix4fv(e,false,c._array)}else if(l==="t"){n=j;j=w();k.uniform1i(e,j);if(n)if(n.image instanceof Array&&n.image.length===6){c=n;e=j;if(c.image.length===6)if(c.needsUpdate){if(!c.image.__webglTextureCube)c.image.__webglTextureCube=k.createTexture();k.activeTexture(k.TEXTURE0+e);k.bindTexture(k.TEXTURE_CUBE_MAP,
c.image.__webglTextureCube);k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,c.flipY);e=c instanceof THREE.CompressedTexture;j=[];for(l=0;l<6;l++)if(Q.autoScaleCubemaps&&!e){m=j;n=l;s=c.image[l];u=Sc;if(!(s.width<=u&&s.height<=u)){z=Math.max(s.width,s.height);t=Math.floor(s.width*u/z);u=Math.floor(s.height*u/z);z=document.createElement("canvas");z.width=t;z.height=u;z.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,u);s=z}m[n]=s}else j[l]=c.image[l];l=j[0];m=(l.width&l.width-1)===0&&(l.height&l.height-
1)===0;n=H(c.format);s=H(c.type);M(k.TEXTURE_CUBE_MAP,c,m);for(l=0;l<6;l++)if(e){u=j[l].mipmaps;z=0;for(A=u.length;z<A;z++){t=u[z];k.compressedTexImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+l,z,n,t.width,t.height,0,t.data)}}else k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,n,n,s,j[l]);c.generateMipmaps&&m&&k.generateMipmap(k.TEXTURE_CUBE_MAP);c.needsUpdate=false;if(c.onUpdate)c.onUpdate()}else{k.activeTexture(k.TEXTURE0+e);k.bindTexture(k.TEXTURE_CUBE_MAP,c.image.__webglTextureCube)}}else if(n instanceof
THREE.WebGLRenderTargetCube){c=n;k.activeTexture(k.TEXTURE0+j);k.bindTexture(k.TEXTURE_CUBE_MAP,c.__webglTexture)}else Q.setTexture(n,j)}else if(l==="tv"){if(c._array===void 0)c._array=[];l=0;for(m=c.value.length;l<m;l++)c._array[l]=w();k.uniform1iv(e,c._array);l=0;for(m=c.value.length;l<m;l++){n=c.value[l];j=c._array[l];n&&Q.setTexture(n,j)}}}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&h.cameraPosition!==null){b=a.matrixWorld.getPosition();k.uniform3f(h.cameraPosition,
b.x,b.y,b.z)}(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&h.viewMatrix!==null&&k.uniformMatrix4fv(h.viewMatrix,false,a._viewMatrixArray)}k.uniformMatrix4fv(h.modelViewMatrix,false,f._modelViewMatrix.elements);h.normalMatrix&&k.uniformMatrix3fv(h.normalMatrix,false,f._normalMatrix.elements);h.modelMatrix!==null&&k.uniformMatrix4fv(h.modelMatrix,false,f.matrixWorld.elements);return g}function w(){var a=pa;a>=Dc&&console.warn("Trying to use "+
a+" texture units while this GPU supports only "+Dc);pa=pa+1;return a}function s(a,b){a._modelViewMatrix.multiply(b.matrixWorldInverse,a.matrixWorld);a._normalMatrix.getInverse(a._modelViewMatrix);a._normalMatrix.transpose()}function B(a,b,c,d){a[b]=c.r*c.r*d;a[b+1]=c.g*c.g*d;a[b+2]=c.b*c.b*d}function v(a,b,c,d){a[b]=c.r*d;a[b+1]=c.g*d;a[b+2]=c.b*d}function A(a,b,c){if(wb!==a){a?k.enable(k.POLYGON_OFFSET_FILL):k.disable(k.POLYGON_OFFSET_FILL);wb=a}if(a&&(xb!==b||fb!==c)){k.polygonOffset(b,c);xb=b;
fb=c}}function E(a){for(var a=a.split("\n"),b=0,c=a.length;b<c;b++)a[b]=b+1+": "+a[b];return a.join("\n")}function z(a,b){var c;a==="fragment"?c=k.createShader(k.FRAGMENT_SHADER):a==="vertex"&&(c=k.createShader(k.VERTEX_SHADER));k.shaderSource(c,b);k.compileShader(c);if(!k.getShaderParameter(c,k.COMPILE_STATUS)){console.error(k.getShaderInfoLog(c));console.error(E(b));return null}return c}function M(a,b,c){if(c){k.texParameteri(a,k.TEXTURE_WRAP_S,H(b.wrapS));k.texParameteri(a,k.TEXTURE_WRAP_T,H(b.wrapT));
k.texParameteri(a,k.TEXTURE_MAG_FILTER,H(b.magFilter));k.texParameteri(a,k.TEXTURE_MIN_FILTER,H(b.minFilter))}else{k.texParameteri(a,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE);k.texParameteri(a,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(a,k.TEXTURE_MAG_FILTER,G(b.magFilter));k.texParameteri(a,k.TEXTURE_MIN_FILTER,G(b.minFilter))}if(Pb&&b.type!==THREE.FloatType&&(b.anisotropy>1||b.__oldAnisotropy)){k.texParameterf(a,Pb.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(b.anisotropy,rc));b.__oldAnisotropy=b.anisotropy}}
function D(a,b){k.bindRenderbuffer(k.RENDERBUFFER,a);if(b.depthBuffer&&!b.stencilBuffer){k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_COMPONENT16,b.width,b.height);k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_ATTACHMENT,k.RENDERBUFFER,a)}else if(b.depthBuffer&&b.stencilBuffer){k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_STENCIL,b.width,b.height);k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_STENCIL_ATTACHMENT,k.RENDERBUFFER,a)}else k.renderbufferStorage(k.RENDERBUFFER,k.RGBA4,b.width,b.height)}
function G(a){return a===THREE.NearestFilter||a===THREE.NearestMipMapNearestFilter||a===THREE.NearestMipMapLinearFilter?k.NEAREST:k.LINEAR}function H(a){if(a===THREE.RepeatWrapping)return k.REPEAT;if(a===THREE.ClampToEdgeWrapping)return k.CLAMP_TO_EDGE;if(a===THREE.MirroredRepeatWrapping)return k.MIRRORED_REPEAT;if(a===THREE.NearestFilter)return k.NEAREST;if(a===THREE.NearestMipMapNearestFilter)return k.NEAREST_MIPMAP_NEAREST;if(a===THREE.NearestMipMapLinearFilter)return k.NEAREST_MIPMAP_LINEAR;if(a===
THREE.LinearFilter)return k.LINEAR;if(a===THREE.LinearMipMapNearestFilter)return k.LINEAR_MIPMAP_NEAREST;if(a===THREE.LinearMipMapLinearFilter)return k.LINEAR_MIPMAP_LINEAR;if(a===THREE.UnsignedByteType)return k.UNSIGNED_BYTE;if(a===THREE.UnsignedShort4444Type)return k.UNSIGNED_SHORT_4_4_4_4;if(a===THREE.UnsignedShort5551Type)return k.UNSIGNED_SHORT_5_5_5_1;if(a===THREE.UnsignedShort565Type)return k.UNSIGNED_SHORT_5_6_5;if(a===THREE.ByteType)return k.BYTE;if(a===THREE.ShortType)return k.SHORT;if(a===
THREE.UnsignedShortType)return k.UNSIGNED_SHORT;if(a===THREE.IntType)return k.INT;if(a===THREE.UnsignedIntType)return k.UNSIGNED_INT;if(a===THREE.FloatType)return k.FLOAT;if(a===THREE.AlphaFormat)return k.ALPHA;if(a===THREE.RGBFormat)return k.RGB;if(a===THREE.RGBAFormat)return k.RGBA;if(a===THREE.LuminanceFormat)return k.LUMINANCE;if(a===THREE.LuminanceAlphaFormat)return k.LUMINANCE_ALPHA;if(a===THREE.AddEquation)return k.FUNC_ADD;if(a===THREE.SubtractEquation)return k.FUNC_SUBTRACT;if(a===THREE.ReverseSubtractEquation)return k.FUNC_REVERSE_SUBTRACT;
if(a===THREE.ZeroFactor)return k.ZERO;if(a===THREE.OneFactor)return k.ONE;if(a===THREE.SrcColorFactor)return k.SRC_COLOR;if(a===THREE.OneMinusSrcColorFactor)return k.ONE_MINUS_SRC_COLOR;if(a===THREE.SrcAlphaFactor)return k.SRC_ALPHA;if(a===THREE.OneMinusSrcAlphaFactor)return k.ONE_MINUS_SRC_ALPHA;if(a===THREE.DstAlphaFactor)return k.DST_ALPHA;if(a===THREE.OneMinusDstAlphaFactor)return k.ONE_MINUS_DST_ALPHA;if(a===THREE.DstColorFactor)return k.DST_COLOR;if(a===THREE.OneMinusDstColorFactor)return k.ONE_MINUS_DST_COLOR;
if(a===THREE.SrcAlphaSaturateFactor)return k.SRC_ALPHA_SATURATE;if(yb!==void 0){if(a===THREE.RGB_S3TC_DXT1_Format)return yb.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT1_Format)return yb.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT3_Format)return yb.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===THREE.RGBA_S3TC_DXT5_Format)return yb.COMPRESSED_RGBA_S3TC_DXT5_EXT}return 0}console.log("THREE.WebGLRenderer",THREE.REVISION);var a=a||{},O=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
F=a.precision!==void 0?a.precision:"highp",J=a.alpha!==void 0?a.alpha:true,I=a.premultipliedAlpha!==void 0?a.premultipliedAlpha:true,K=a.antialias!==void 0?a.antialias:false,V=a.stencil!==void 0?a.stencil:true,Y=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:false,a=0,rb=0,Da=0,ab=new THREE.Frustum,bb=new THREE.Matrix4,gb=new THREE.Matrix4,Pa=new THREE.Vector4,Qa=new THREE.Vector3,hb=true,qc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],
angles:[],exponents:[]},hemi:{length:0,skyColors:[],groundColors:[],positions:[]}},k,Pb,yb;try{if(!(k=O.getContext("experimental-webgl",{alpha:J,premultipliedAlpha:I,antialias:K,stencil:V,preserveDrawingBuffer:Y})))throw"Error creating WebGL context.";}catch(Rc){console.error(Rc)}a=k.getExtension("OES_texture_float");J=k.getExtension("OES_standard_derivatives");Pb=k.getExtension("EXT_texture_filter_anisotropic")||k.getExtension("MOZ_EXT_texture_filter_anisotropic")||k.getExtension("WEBKIT_EXT_texture_filter_anisotropic");
yb=k.getExtension("WEBGL_compressed_texture_s3tc")||k.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||k.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");a||console.log("THREE.WebGLRenderer: Float textures not supported.");J||console.log("THREE.WebGLRenderer: Standard derivatives not supported.");Pb||console.log("THREE.WebGLRenderer: Anisotropic texture filtering not supported.");yb||console.log("THREE.WebGLRenderer: S3TC compressed textures not supported.");k.clearColor(0,0,0,1);k.clearDepth(1);
k.clearStencil(0);k.enable(k.DEPTH_TEST);k.depthFunc(k.LEQUAL);k.frontFace(k.CCW);k.cullFace(k.BACK);k.enable(k.CULL_FACE);k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA);k.clearColor(.g,a=d!==void 0?d:O.height;k.viewport(xa,qb,Ga,.setHex(a);L=b;k.clearColor(.g,.copy(a);L=b;k.clearColor(.g,};this.getClearAlpha=function(){return L};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d=d|k.COLOR_BUFFER_BIT;if(b===void 0||b)d=d|k.DEPTH_BUFFER_BIT;if(c===void 0||c)d=d|k.STENCIL_BUFFER_BIT;k.clear(d)};this.clearTarget=function(a,b,
c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit){a.__webglInit=false;delete a._modelViewMatrix;delete a._normalMatrix;delete a._normalMatrixArray;delete a._modelViewMatrixArray;delete a._modelMatrixArray;if(a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];
k.deleteBuffer(c.__webglVertexBuffer);k.deleteBuffer(c.__webglNormalBuffer);k.deleteBuffer(c.__webglTangentBuffer);k.deleteBuffer(c.__webglColorBuffer);k.deleteBuffer(c.__webglUVBuffer);k.deleteBuffer(c.__webglUV2Buffer);k.deleteBuffer(c.__webglSkinIndicesBuffer);k.deleteBuffer(c.__webglSkinWeightsBuffer);k.deleteBuffer(c.__webglFaceBuffer);k.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets){d=0;for(e=c.numMorphTargets;d<e;d++)k.deleteBuffer(c.__webglMorphTargetsBuffers[d])}if(c.numMorphNormals){d=
0;for(e=c.numMorphNormals;d<e;d++)k.deleteBuffer(c.__webglMorphNormalsBuffers[d])}if(c.__webglCustomAttributesList){d=void 0;for(d in c.__webglCustomAttributesList)k.deleteBuffer(c.__webglCustomAttributesList[d].buffer)}Q.info.memory.geometries--}else if(a instanceof THREE.Ribbon){a=a.geometry;k.deleteBuffer(a.__webglVertexBuffer);k.deleteBuffer(a.__webglColorBuffer);Q.info.memory.geometries--}else if(a instanceof THREE.Line){a=a.geometry;k.deleteBuffer(a.__webglVertexBuffer);k.deleteBuffer(a.__webglColorBuffer);
Q.info.memory.geometries--}else if(a instanceof THREE.ParticleSystem){a=a.geometry;k.deleteBuffer(a.__webglVertexBuffer);k.deleteBuffer(a.__webglColorBuffer);Q.info.memory.geometries--}}};this.deallocateTexture=function(a){if(a.__webglInit){a.__webglInit=false;k.deleteTexture(a.__webglTexture);Q.info.memory.textures--}};this.deallocateRenderTarget=function(a){if(a&&a.__webglTexture){k.deleteTexture(a.__webglTexture);if(a instanceof THREE.WebGLRenderTargetCube)for(var b=0;b<6;b++){k.deleteFramebuffer(a.__webglFramebuffer[b]);
k.deleteRenderbuffer(a.__webglRenderbuffer[b])}else{k.deleteFramebuffer(a.__webglFramebuffer);k.deleteRenderbuffer(a.__webglRenderbuffer)}}};this.deallocateMaterial=function(a){var b=a.program;if(b){a.program=void 0;var c,d,e=false,a=0;for(c=fa.length;a<c;a++){d=fa[a];if(d.program===b){d.usedTimes--;d.usedTimes===0&&(e=true);break}}if(e){e=[];a=0;for(c=fa.length;a<c;a++){d=fa[a];d.program!==b&&e.push(d)}fa=e;k.deleteProgram(b);Q.info.memory.programs--}}};this.updateShadowMap=function(a,b){da=null;
N=U=Ya=Oa=Ja=-1;hb=true;Ca=ua=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(a.hasPositions&&!a.__webglVertexBuffer)a.__webglVertexBuffer=k.createBuffer();if(a.hasNormals&&!a.__webglNormalBuffer)a.__webglNormalBuffer=k.createBuffer();if(a.hasUvs&&!a.__webglUvBuffer)a.__webglUvBuffer=k.createBuffer();if(a.hasColors&&!a.__webglColorBuffer)a.__webglColorBuffer=k.createBuffer();if(a.hasPositions){k.bindBuffer(k.ARRAY_BUFFER,a.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,
a.positionArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(b.attributes.position);k.vertexAttribPointer(b.attributes.position,3,k.FLOAT,false,0,0)}if(a.hasNormals){k.bindBuffer(k.ARRAY_BUFFER,a.__webglNormalBuffer);if(c.shading===THREE.FlatShading){var d,e,f,g,h,i,j,l,n,m,o,p=a.count*3;for(o=0;o<p;o=o+9){m=a.normalArray;d=m[o];e=m[o+1];f=m[o+2];g=m[o+3];i=m[o+4];l=m[o+5];h=m[o+6];j=m[o+7];n=m[o+8];d=(d+g+h)/3;e=(e+i+j)/3;f=(f+l+n)/3;m[o]=d;m[o+1]=e;m[o+2]=f;m[o+3]=d;m[o+4]=e;m[o+5]=f;m[o+6]=d;m[o+
7]=e;m[o+8]=f}}k.bufferData(k.ARRAY_BUFFER,a.normalArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(b.attributes.normal);k.vertexAttribPointer(b.attributes.normal,3,k.FLOAT,false,0,0)}if(a.hasUvs&&c.map){k.bindBuffer(k.ARRAY_BUFFER,a.__webglUvBuffer);k.bufferData(k.ARRAY_BUFFER,a.uvArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(b.attributes.uv);k.vertexAttribPointer(b.attributes.uv,2,k.FLOAT,false,0,0)}if(a.hasColors&&c.vertexColors!==THREE.NoColors){k.bindBuffer(k.ARRAY_BUFFER,a.__webglColorBuffer);
k.bufferData(k.ARRAY_BUFFER,a.colorArray,k.DYNAMIC_DRAW);k.enableVertexAttribArray(b.attributes.color);k.vertexAttribPointer(b.attributes.color,3,k.FLOAT,false,0,0)}k.drawArrays(k.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){if(d.visible!==false){c=u(a,b,c,d,f);a=c.attributes;b=false;d=e.id*16777215+c.id*2+(d.wireframe?1:0);if(d!==U){U=d;b=true}if(f instanceof THREE.Mesh){f=e.offsets;f.length>1&&(b=true);d=0;for(c=f.length;d<c;++d){var g=f[d].index;if(b){var h=e.attributes.position,
i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.position,i,k.FLOAT,false,0,g*i*4);h=e.attributes.normal;if(a.normal>=0&&h){i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.normal,i,k.FLOAT,false,0,g*i*4)}h=e.attributes.uv;if(a.uv>=0&&h)if(h.buffer){i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.uv,i,k.FLOAT,false,0,g*i*4);k.enableVertexAttribArray(a.uv)}else k.disableVertexAttribArray(a.uv);i=e.attributes.color;if(a.color>=
0&&i){var j=i.itemSize;k.bindBuffer(k.ARRAY_BUFFER,i.buffer);k.vertexAttribPointer(a.color,j,k.FLOAT,false,0,g*j*4)}h=e.attributes.tangent;if(a.tangent>=0&&h){i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.tangent,i,k.FLOAT,false,0,g*i*4)}k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.attributes.index.buffer)}k.drawElements(k.TRIANGLES,f[d].count,k.UNSIGNED_SHORT,f[d].start*2);Q.info.render.calls++;Q.info.render.vertices=Q.info.render.vertices+f[d].count;Q.info.render.faces=Q.info.render.faces+
f[d].count/3}}else if(f instanceof THREE.ParticleSystem&&b){h=e.attributes.position;i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.position,i,k.FLOAT,false,0,0);i=e.attributes.color;if(a.color>=0&&i){j=i.itemSize;k.bindBuffer(k.ARRAY_BUFFER,i.buffer);k.vertexAttribPointer(a.color,j,k.FLOAT,false,0,0)}k.drawArrays(k.POINTS,0,h.numItems/3);Q.info.render.calls++;Q.info.render.points=Q.info.render.points+h.numItems/3}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==
false){var g,h,c=u(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==U){U=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){k.bindBuffer(k.ARRAY_BUFFER,e.__webglVertexBuffer);k.vertexAttribPointer(b.position,3,k.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]);k.vertexAttribPointer(c.position,3,k.FLOAT,false,0,0)}else if(c.position>=0){k.bindBuffer(k.ARRAY_BUFFER,
e.__webglVertexBuffer);k.vertexAttribPointer(c.position,3,k.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var i=0;h=f.morphTargetForcedOrder;for(g=f.morphTargetInfluences;i<d.numSupportedMorphTargets&&i<h.length;){k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[h[i]]);k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,false,0,0);if(d.morphNormals){k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[h[i]]);k.vertexAttribPointer(c["morphNormal"+i],3,k.FLOAT,false,0,0)}f.__webglMorphTargetInfluences[i]=
g[h[i]];i++}}else{h=[];g=f.morphTargetInfluences;var l,m=g.length;for(l=0;l<m;l++){i=g[l];i>0&&h.push([l,i])}if(h.length>d.numSupportedMorphTargets){h.sort(j);h.length=d.numSupportedMorphTargets}else h.length>d.numSupportedMorphNormals?h.sort(j):h.length===0&&h.push([0,0]);for(i=0;i<d.numSupportedMorphTargets;){if(h[i]){l=h[i][0];k.bindBuffer(k.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,false,0,0);if(d.morphNormals){k.bindBuffer(k.ARRAY_BUFFER,
e.__webglMorphNormalsBuffers[l]);k.vertexAttribPointer(c["morphNormal"+i],3,k.FLOAT,false,0,0)}f.__webglMorphTargetInfluences[i]=g[l]}else{k.vertexAttribPointer(c["morphTarget"+i],3,k.FLOAT,false,0,0);d.morphNormals&&k.vertexAttribPointer(c["morphNormal"+i],3,k.FLOAT,false,0,0);f.__webglMorphTargetInfluences[i]=0}i++}}d.program.uniforms.morphTargetInfluences!==null&&k.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g=0;for(h=
e.__webglCustomAttributesList.length;g<h;g++){c=e.__webglCustomAttributesList[g];if(b[c.buffer.belongsToAttribute]>=0){k.bindBuffer(k.ARRAY_BUFFER,c.buffer);k.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,k.FLOAT,false,0,0)}}}if(b.color>=0){k.bindBuffer(k.ARRAY_BUFFER,e.__webglColorBuffer);k.vertexAttribPointer(b.color,3,k.FLOAT,false,0,0)}if(b.normal>=0){k.bindBuffer(k.ARRAY_BUFFER,e.__webglNormalBuffer);k.vertexAttribPointer(b.normal,3,k.FLOAT,false,0,0)}if(b.tangent>=0){k.bindBuffer(k.ARRAY_BUFFER,
e.__webglTangentBuffer);k.vertexAttribPointer(b.tangent,4,k.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){k.bindBuffer(k.ARRAY_BUFFER,e.__webglUVBuffer);k.vertexAttribPointer(b.uv,2,k.FLOAT,false,0,0);k.enableVertexAttribArray(b.uv)}else k.disableVertexAttribArray(b.uv);if(b.uv2>=0)if(e.__webglUV2Buffer){k.bindBuffer(k.ARRAY_BUFFER,e.__webglUV2Buffer);k.vertexAttribPointer(b.uv2,2,k.FLOAT,false,0,0);k.enableVertexAttribArray(b.uv2)}else k.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinIndex>=
0&&b.skinWeight>=0){k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);k.vertexAttribPointer(b.skinIndex,4,k.FLOAT,false,0,0);k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==Fa){k.lineWidth(d);Fa=d}a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);k.drawElements(k.LINES,e.__webglLineCount,k.UNSIGNED_SHORT,0)}else{a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,
e.__webglFaceBuffer);k.drawElements(k.TRIANGLES,e.__webglFaceCount,k.UNSIGNED_SHORT,0)}Q.info.render.calls++;Q.info.render.vertices=Q.info.render.vertices+e.__webglFaceCount;Q.info.render.faces=Q.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?k.LINE_STRIP:k.LINES;d=d.linewidth;if(d!==Fa){k.lineWidth(d);Fa=d}k.drawArrays(f,0,e.__webglLineCount);Q.info.render.calls++}else if(f instanceof THREE.ParticleSystem){k.drawArrays(k.POINTS,0,e.__webglParticleCount);
Q.info.render.calls++;Q.info.render.points=Q.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){k.drawArrays(k.TRIANGLE_STRIP,0,e.__webglVertexCount);Q.info.render.calls++}}};this.render=function(a,b,c,d){if(b instanceof THREE.Camera===false)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else{var e,f,g,h,j=a.__lights,o=a.fog;N=-1;hb=true;this.autoUpdateScene&&a.updateMatrixWorld();b.parent===void 0&&b.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=
new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);bb.multiply(b.projectionMatrix,b.matrixWorldInverse);ab.setFromMatrix(bb);this.autoUpdateObjects&&this.initWebGLObjects(a);l(this.renderPluginsPre,a,b);Q.info.render.calls=0;Q.info.render.vertices=0;Q.info.render.faces=0;Q.info.render.points=
0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);h=a.__webglObjects;d=0;for(e=h.length;d<e;d++){f=h[d];g=f.object;f.render=false;if(g.visible&&(!(g instanceof THREE.Mesh||g instanceof THREE.ParticleSystem)||!g.frustumCulled||ab.contains(g))){s(g,b);var p=f,q=p.object,r=p.buffer,t=void 0,t=t=void 0,t=q.material;if(t instanceof THREE.MeshFaceMaterial){t=r.materialIndex;if(t>=0){t=q.geometry.materials[t];if(t.transparent){p.transparent=
t;p.opaque=null}else{p.opaque=t;p.transparent=null}}}else if(t)if(t.transparent){p.transparent=t;p.opaque=null}else{p.opaque=t;p.transparent=null}f.render=true;if(this.sortObjects===true)if(g.renderDepth!==null)f.z=g.renderDepth;else{Pa.copy(g.matrixWorld.getPosition());bb.multiplyVector3(Pa);f.z=Pa.z}}}this.sortObjects&&h.sort(i);h=a.__webglObjectsImmediate;d=0;for(e=h.length;d<e;d++){f=h[d];g=f.object;if(g.visible){s(g,b);g=f.object.material;if(g.transparent){f.transparent=g;f.opaque=null}else{f.opaque=
g;f.transparent=null}}}if(a.overrideMaterial){d=a.overrideMaterial;this.setBlending(d.blending,d.blendEquation,d.blendSrc,d.blendDst);this.setDepthTest(d.depthTest);this.setDepthWrite(d.depthWrite);A(d.polygonOffset,d.polygonOffsetFactor,d.polygonOffsetUnits);n(a.__webglObjects,false,"",b,j,o,true,d);m(a.__webglObjectsImmediate,"",b,j,o,false,d)}else{this.setBlending(THREE.NormalBlending);n(a.__webglObjects,true,"opaque",b,j,o,false);m(a.__webglObjectsImmediate,"opaque",b,j,o,false);n(a.__webglObjects,
false,"transparent",b,j,o,true);m(a.__webglObjectsImmediate,"transparent",b,j,o,true)}l(this.renderPluginsPost,a,b);if(c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter)if(c instanceof THREE.WebGLRenderTargetCube){k.bindTexture(k.TEXTURE_CUBE_MAP,c.__webglTexture);k.generateMipmap(k.TEXTURE_CUBE_MAP);k.bindTexture(k.TEXTURE_CUBE_MAP,null)}else{k.bindTexture(k.TEXTURE_2D,c.__webglTexture);k.generateMipmap(k.TEXTURE_2D);k.bindTexture(k.TEXTURE_2D,null)}this.setDepthTest(true);
this.setDepthWrite(true)}};this.renderImmediateObject=function(a,b,c,d,e){var f=u(a,b,c,d,e);U=-1;Q.setMaterialFaces(d);e.immediateRenderCallback?e.immediateRenderCallback(f,k,ab):e.render(function(a){Q.renderBufferImmediate(a,f,d)})};this.initWebGLObjects=function(a){if(!a.__webglObjects){a.__webglObjects=[];a.__webglObjectsImmediate=[];a.__webglSprites=[];a.__webglFlares=[]}for(;a.__objectsAdded.length;){var i=a.__objectsAdded[0],j=a,l=void 0,m=void 0,n=void 0;if(!i.__webglInit){i.__webglInit=true;
i._modelViewMatrix=new THREE.Matrix4;i._normalMatrix=new THREE.Matrix3;if(i instanceof THREE.Mesh){m=i.geometry;if(m instanceof THREE.Geometry){if(m.geometryGroups===void 0){var s=m,u=void 0,v=void 0,w=void 0,z=void 0,A=void 0,B=void 0,E=void 0,D={},G=s.morphTargets.length,H=s.morphNormals.length;s.geometryGroups={};u=0;for(v=s.faces.length;u<v;u++){w=s.faces[u];z=w.materialIndex;B=z!==void 0?z:-1;D[B]===void 0&&(D[B]={hash:B,counter:0});E=D[B].hash+"_"+D[B].counter;s.geometryGroups[E]===void 0&&
(s.geometryGroups[E]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:G,numMorphNormals:H});A=w instanceof THREE.Face3?3:4;if(s.geometryGroups[E].vertices+A>65535){D[B].counter=D[B].counter+1;E=D[B].hash+"_"+D[B].counter;s.geometryGroups[E]===void 0&&(s.geometryGroups[E]={faces3:[],faces4:[],materialIndex:z,vertices:0,numMorphTargets:G,numMorphNormals:H})}w instanceof THREE.Face3?s.geometryGroups[E].faces3.push(u):s.geometryGroups[E].faces4.push(u);s.geometryGroups[E].vertices=s.geometryGroups[E].vertices+
A}s.geometryGroupsList=[];var I=void 0;for(I in s.geometryGroups){s.geometryGroups[I].id=Ia++;s.geometryGroupsList.push(s.geometryGroups[I])}}for(l in m.geometryGroups){n=m.geometryGroups[l];if(!n.__webglVertexBuffer){var F=n;F.__webglVertexBuffer=k.createBuffer();F.__webglNormalBuffer=k.createBuffer();F.__webglTangentBuffer=k.createBuffer();F.__webglColorBuffer=k.createBuffer();F.__webglUVBuffer=k.createBuffer();F.__webglUV2Buffer=k.createBuffer();F.__webglSkinIndicesBuffer=k.createBuffer();F.__webglSkinWeightsBuffer=
k.createBuffer();F.__webglFaceBuffer=k.createBuffer();F.__webglLineBuffer=k.createBuffer();var L=void 0,J=void 0;if(F.numMorphTargets){F.__webglMorphTargetsBuffers=[];L=0;for(J=F.numMorphTargets;L<J;L++)F.__webglMorphTargetsBuffers.push(k.createBuffer())}if(F.numMorphNormals){F.__webglMorphNormalsBuffers=[];L=0;for(J=F.numMorphNormals;L<J;L++)F.__webglMorphNormalsBuffers.push(k.createBuffer())}Q.info.memory.geometries++;var N=n,K=i,M=K.geometry,O=N.faces3,da=N.faces4,U=O.length*3+da.length*4,ga=O.length*
1+da.length*2,V=O.length*3+da.length*4,),ia=d(.vertexColors?.attributes){if(N.__webglCustomAttributesList===
void 0)N.__webglCustomAttributesList=[];var ua=void 0;for(ua in .attributes[ua],ja={},Ja;for(Ja in Ca)ja[Ja]=Ca[Ja];if(!ja.__webglInitialized||ja.createUniqueBuffers){ja.__webglInitialized=true;var ta=1;ja.type==="v2"?ta=2:ja.type==="v3"?ta=3:ja.type==="v4"?ta=4:ja.type==="c"&&(ta=3);ja.size=ta;ja.array=new Float32Array(U*ta);ja.buffer=k.createBuffer();ja.buffer.belongsToAttribute=ua;Ca.needsUpdate=true;ja.__original=Ca}N.__webglCustomAttributesList.push(ja)}}N.__inittedArrays=
true;m.verticesNeedUpdate=true;m.morphTargetsNeedUpdate=true;m.elementsNeedUpdate=true;m.uvsNeedUpdate=true;m.normalsNeedUpdate=true;m.tangentsNeedUpdate=true;m.colorsNeedUpdate=true}}}else m instanceof THREE.BufferGeometry&&e(m)}else if(i instanceof THREE.Ribbon){m=i.geometry;if(!m.__webglVertexBuffer){var Da=m;Da.__webglVertexBuffer=k.createBuffer();Da.__webglColorBuffer=k.createBuffer();Q.info.memory.geometries++;var xa=m,Ga=xa.vertices.length;xa.__vertexArray=new Float32Array(Ga*3);xa.__colorArray=
new Float32Array(Ga*3);xa.__webglVertexCount=Ga;m.verticesNeedUpdate=true;m.colorsNeedUpdate=true}}else if(i instanceof THREE.Line){m=i.geometry;if(!m.__webglVertexBuffer){var Oa=m;Oa.__webglVertexBuffer=k.createBuffer();Oa.__webglColorBuffer=k.createBuffer();Q.info.memory.geometries++;var Fa=m,Pa=i,Qa=Fa.vertices.length;Fa.__vertexArray=new Float32Array(Qa*3);Fa.__colorArray=new Float32Array(Qa*3);Fa.__webglLineCount=Qa;b(Fa,Pa);m.verticesNeedUpdate=true;m.colorsNeedUpdate=true}}else if(i instanceof
THREE.ParticleSystem){m=i.geometry;if(!m.__webglVertexBuffer)if(m instanceof THREE.Geometry){var Xa=m;Xa.__webglVertexBuffer=k.createBuffer();Xa.__webglColorBuffer=k.createBuffer();Q.info.memory.geometries++;var Ya=m,pb=i,fb=Ya.vertices.length;Ya.__vertexArray=new Float32Array(fb*3);Ya.__colorArray=new Float32Array(fb*3);Ya.__sortArray=[];Ya.__webglParticleCount=fb;b(Ya,pb);m.verticesNeedUpdate=true;m.colorsNeedUpdate=true}else m instanceof THREE.BufferGeometry&&e(m)}}if(!i.__webglActive){if(i instanceof
THREE.Mesh){m=i.geometry;if(m instanceof THREE.BufferGeometry)q(j.__webglObjects,m,i);else for(l in m.geometryGroups){n=m.geometryGroups[l];q(j.__webglObjects,n,i)}}else if(i instanceof THREE.Ribbon||i instanceof THREE.Line||i instanceof THREE.ParticleSystem){m=i.geometry;q(j.__webglObjects,m,i)}else i instanceof THREE.ImmediateRenderObject||i.immediateRenderCallback?j.__webglObjectsImmediate.push({object:i,opaque:null,transparent:null}):i instanceof THREE.Sprite?j.__webglSprites.push(i):i instanceof
THREE.LensFlare&&j.__webglFlares.push(i);i.__webglActive=true}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var lb=a.__objectsRemoved[0],a.__webglObjects,lb):lb instanceof THREE.Sprite?t(a.__webglFlares,lb):(lb instanceof THREE.ImmediateRenderObject||lb.immediateRenderCallback)&&r(b=void 0,Rb=void 0,Ha=0,La=0,
Sb=0,Tb=0,nb=0,Va=0,sa=0,Za=0,Ka=0,aa=0,ha=0,y=0,ra=void 0,Sa=la.__vertexArray,xc=la.__uvArray,yc=la.__uv2Array,ob=la.__normalArray,ya=la.__tangentArray,Ta=la.__colorArray,za=la.__skinIndexArray,Aa=la.__skinWeightArray,Uc=la.__morphTargetsArrays,Vc=la.__morphNormalsArrays,Wc=la.__webglCustomAttributesList,x=void 0,Ob=la.__faceArray,ib=la.__lineArray,db=xb.geometry,Dc=db.elementsNeedUpdate,ad=db.uvsNeedUpdate,Rc=db.normalsNeedUpdate,Sc=db.tangentsNeedUpdate,hd=db.colorsNeedUpdate,id=db.morphTargetsNeedUpdate,
gc=db.vertices,ma=la.faces3,na=la.faces4,Wa=db.faces,Xc=db.faceVertexUvs[0],Yc=db.faceVertexUvs[1],hc=db.skinIndices,ac=db.skinWeights,bc=db.morphTargets,Hc=db.morphNormals;if(db.verticesNeedUpdate){C=0;for(W=ma.length;C<W;C++){P=Wa[ma[C]];R=gc[P.a];S=gc[P.b];T=gc[P.c];Sa[La]=R.x;Sa[La+1]=R.y;Sa[La+2]=R.z;Sa[La+3]=S.x;Sa[La+4]=S.y;Sa[La+5]=S.z;Sa[La+6]=T.x;Sa[La+7]=T.y;Sa[La+8]=T.z;La=La+9}C=0;for(W=na.length;C<W;C++){P=Wa[na[C]];R=gc[P.a];S=gc[P.b];T=gc[P.c];ka=gc[P.d];Sa[La]=R.x;Sa[La+1]=R.y;Sa[La+
2]=R.z;Sa[La+3]=S.x;Sa[La+4]=S.y;Sa[La+5]=S.z;Sa[La+6]=T.x;Sa[La+7]=T.y;Sa[La+8]=T.z;Sa[La+9]=ka.x;Sa[La+10]=ka.y;Sa[La+11]=ka.z;La=La+12}k.bindBuffer(k.ARRAY_BUFFER,la.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,Sa,mb)}if(id){Ra=0;for(rc=bc.length;Ra<rc;Ra++){C=ha=0;for(W=ma.length;C<W;C++){b];R=bc[Ra].vertices[P.a];S=bc[Ra].vertices[P.b];T=bc[Ra].vertices[P.c];Ma=Uc[Ra];Ma[ha]=R.x;Ma[ha+1]=R.y;Ma[ha+2]=R.z;Ma[ha+3]=S.x;Ma[ha+4]=S.y;Ma[ha+5]=S.z;Ma[ha+6]=T.x;Ma[ha+7]=T.y;Ma[ha+
8]=T.z;if(gb.morphNormals){if(Fc){Rb=Hc[Ra].vertexNormals[b];Na=Vc[Ra];Na[ha]=Cb.x;Na[ha+1]=Cb.y;Na[ha+2]=Cb.z;Na[ha+3]=Db.x;Na[ha+4]=Db.y;Na[ha+5]=Db.z;Na[ha+6]=Eb.x;Na[ha+7]=Eb.y;Na[ha+8]=Eb.z}ha=ha+9}C=0;for(W=na.length;C<W;C++){b];R=bc[Ra].vertices[P.a];S=bc[Ra].vertices[P.b];T=bc[Ra].vertices[P.c];ka=bc[Ra].vertices[P.d];Ma=Uc[Ra];Ma[ha]=R.x;Ma[ha+1]=R.y;Ma[ha+2]=R.z;Ma[ha+3]=S.x;Ma[ha+4]=S.y;Ma[ha+5]=S.z;Ma[ha+6]=T.x;
Ma[ha+7]=T.y;Ma[ha+8]=T.z;Ma[ha+9]=ka.x;Ma[ha+10]=ka.y;Ma[ha+11]=ka.z;if(gb.morphNormals){if(Fc){Rb=Hc[Ra].vertexNormals[b];Na=Vc[Ra];Na[ha]=Cb.x;Na[ha+1]=Cb.y;Na[ha+2]=Cb.z;Na[ha+3]=Db.x;Na[ha+4]=Db.y;Na[ha+5]=Db.z;Na[ha+6]=Eb.x;Na[ha+7]=Eb.y;Na[ha+8]=Eb.z;Na[ha+9]=tc.x;Na[ha+10]=tc.y;Na[ha+11]=tc.z}ha=ha+12}k.bindBuffer(k.ARRAY_BUFFER,la.__webglMorphTargetsBuffers[Ra]);k.bufferData(k.ARRAY_BUFFER,Uc[Ra],mb);if(gb.morphNormals){k.bindBuffer(k.ARRAY_BUFFER,
la.__webglMorphNormalsBuffers[Ra]);k.bufferData(k.ARRAY_BUFFER,Vc[Ra],mb)}}}if(ac.length){C=0;for(W=ma.length;C<W;C++){P=Wa[ma[C]];Ib=ac[P.a];Jb=ac[P.b];Kb=ac[P.c];Aa[aa]=Ib.x;Aa[aa+1]=Ib.y;Aa[aa+2]=Ib.z;Aa[aa+3]=Ib.w;Aa[aa+4]=Jb.x;Aa[aa+5]=Jb.y;Aa[aa+6]=Jb.z;Aa[aa+7]=Jb.w;Aa[aa+8]=Kb.x;Aa[aa+9]=Kb.y;Aa[aa+10]=Kb.z;Aa[aa+11]=Kb.w;Lb=hc[P.a];Mb=hc[P.b];Nb=hc[P.c];za[aa]=Lb.x;za[aa+1]=Lb.y;za[aa+2]=Lb.z;za[aa+3]=Lb.w;za[aa+4]=Mb.x;za[aa+5]=Mb.y;za[aa+6]=Mb.z;za[aa+7]=Mb.w;za[aa+8]=Nb.x;za[aa+9]=Nb.y;
za[aa+10]=Nb.z;za[aa+11]=Nb.w;aa=aa+12}C=0;for(W=na.length;C<W;C++){P=Wa[na[C]];Ib=ac[P.a];Jb=ac[P.b];Kb=ac[P.c];vc=ac[P.d];Aa[aa]=Ib.x;Aa[aa+1]=Ib.y;Aa[aa+2]=Ib.z;Aa[aa+3]=Ib.w;Aa[aa+4]=Jb.x;Aa[aa+5]=Jb.y;Aa[aa+6]=Jb.z;Aa[aa+7]=Jb.w;Aa[aa+8]=Kb.x;Aa[aa+9]=Kb.y;Aa[aa+10]=Kb.z;Aa[aa+11]=Kb.w;Aa[aa+12]=vc.x;Aa[aa+13]=vc.y;Aa[aa+14]=vc.z;Aa[aa+15]=vc.w;Lb=hc[P.a];Mb=hc[P.b];Nb=hc[P.c];wc=hc[P.d];za[aa]=Lb.x;za[aa+1]=Lb.y;za[aa+2]=Lb.z;za[aa+3]=Lb.w;za[aa+4]=Mb.x;za[aa+5]=Mb.y;za[aa+6]=Mb.z;za[aa+7]=
Mb.w;za[aa+8]=Nb.x;za[aa+9]=Nb.y;za[aa+10]=Nb.z;za[aa+11]=Nb.w;za[aa+12]=wc.x;za[aa+13]=wc.y;za[aa+14]=wc.z;za[aa+15]=wc.w;aa=aa+16}if(aa>0){k.bindBuffer(k.ARRAY_BUFFER,la.__webglSkinIndicesBuffer);k.bufferData(k.ARRAY_BUFFER,za,mb);k.bindBuffer(k.ARRAY_BUFFER,la.__webglSkinWeightsBuffer);k.bufferData(k.ARRAY_BUFFER,Aa,mb)}}if(hd&&ec){C=0;for(W=ma.length;C<W;C++){P=Wa[ma[C]];vb=P.vertexColors;Gc=P.color;if(vb.length===3&&ec===THREE.VertexColors){Fb=vb[0];Gb=vb[1];Hb=vb[2]}else Hb=Gb=Fb=Gc;Ta[Ka]=
Fb.r;Ta[Ka+1]=Fb.g;Ta[Ka+2]=Fb.b;Ta[Ka+3]=Gb.r;Ta[Ka+4]=Gb.g;Ta[Ka+5]=Gb.b;Ta[Ka+6]=Hb.r;Ta[Ka+7]=Hb.g;Ta[Ka+8]=Hb.b;Ka=Ka+9}C=0;for(W=na.length;C<W;C++){P=Wa[na[C]];vb=P.vertexColors;Gc=P.color;if(vb.length===4&&ec===THREE.VertexColors){Fb=vb[0];Gb=vb[1];Hb=vb[2];uc=vb[3]}else uc=Hb=Gb=Fb=Gc;Ta[Ka]=Fb.r;Ta[Ka+1]=Fb.g;Ta[Ka+2]=Fb.b;Ta[Ka+3]=Gb.r;Ta[Ka+4]=Gb.g;Ta[Ka+5]=Gb.b;Ta[Ka+6]=Hb.r;Ta[Ka+7]=Hb.g;Ta[Ka+8]=Hb.b;Ta[Ka+9]=uc.r;Ta[Ka+10]=uc.g;Ta[Ka+11]=uc.b;Ka=Ka+12}if(Ka>0){k.bindBuffer(k.ARRAY_BUFFER,
la.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,Ta,mb)}}if(Sc&&db.hasTangents){C=0;for(W=ma.length;C<W;C++){P=Wa[ma[C]];Qb=P.vertexTangents;zb=Qb[0];Ab=Qb[1];Bb=Qb[2];ya[sa]=zb.x;ya[sa+1]=zb.y;ya[sa+2]=zb.z;ya[sa+3]=zb.w;ya[sa+4]=Ab.x;ya[sa+5]=Ab.y;ya[sa+6]=Ab.z;ya[sa+7]=Ab.w;ya[sa+8]=Bb.x;ya[sa+9]=Bb.y;ya[sa+10]=Bb.z;ya[sa+11]=Bb.w;sa=sa+12}C=0;for(W=na.length;C<W;C++){P=Wa[na[C]];Qb=P.vertexTangents;zb=Qb[0];Ab=Qb[1];Bb=Qb[2];sc=Qb[3];ya[sa]=zb.x;ya[sa+1]=zb.y;ya[sa+2]=zb.z;ya[sa+3]=zb.w;ya[sa+
4]=Ab.x;ya[sa+5]=Ab.y;ya[sa+6]=Ab.z;ya[sa+7]=Ab.w;ya[sa+8]=Bb.x;ya[sa+9]=Bb.y;ya[sa+10]=Bb.z;ya[sa+11]=Bb.w;ya[sa+12]=sc.x;ya[sa+13]=sc.y;ya[sa+14]=sc.z;ya[sa+15]=sc.w;sa=sa+16}k.bindBuffer(k.ARRAY_BUFFER,la.__webglTangentBuffer);k.bufferData(k.ARRAY_BUFFER,ya,mb)}if(Rc&&Pb){C=0;for(W=ma.length;C<W;C++){P=Wa[ma[C]];kc=P.vertexNormals;Yb=P.normal;if(kc.length===3&&Fc)for(qa=0;qa<3;qa++){Zb=kc[qa];ob[Va]=Zb.x;ob[Va+1]=Zb.y;ob[Va+2]=Zb.z;Va=Va+3}else for(qa=0;qa<3;qa++){ob[Va]=Yb.x;ob[Va+1]=Yb.y;ob[Va+
2]=Yb.z;Va=Va+3}}C=0;for(W=na.length;C<W;C++){P=Wa[na[C]];kc=P.vertexNormals;Yb=P.normal;if(kc.length===4&&Fc)for(qa=0;qa<4;qa++){Zb=kc[qa];ob[Va]=Zb.x;ob[Va+1]=Zb.y;ob[Va+2]=Zb.z;Va=Va+3}else for(qa=0;qa<4;qa++){ob[Va]=Yb.x;ob[Va+1]=Yb.y;ob[Va+2]=Yb.z;Va=Va+3}}k.bindBuffer(k.ARRAY_BUFFER,la.__webglNormalBuffer);k.bufferData(k.ARRAY_BUFFER,ob,mb)}if(ad&&Xc&&ic){C=0;for(W=ma.length;C<W;C++){Xb=ma[C];lc=Xc[Xb];if(lc!==void 0)for(qa=0;qa<3;qa++){nc=lc[qa];xc[Sb]=nc.u;xc[Sb+1]=nc.v;Sb=Sb+2}}C=0;for(W=
na.length;C<W;C++){Xb=na[C];lc=Xc[Xb];if(lc!==void 0)for(qa=0;qa<4;qa++){nc=lc[qa];xc[Sb]=nc.u;xc[Sb+1]=nc.v;Sb=Sb+2}}if(Sb>0){k.bindBuffer(k.ARRAY_BUFFER,la.__webglUVBuffer);k.bufferData(k.ARRAY_BUFFER,xc,mb)}}if(ad&&Yc&&ic){C=0;for(W=ma.length;C<W;C++){Xb=ma[C];mc=Yc[Xb];if(mc!==void 0)for(qa=0;qa<3;qa++){oc=mc[qa];yc[Tb]=oc.u;yc[Tb+1]=oc.v;Tb=Tb+2}}C=0;for(W=na.length;C<W;C++){Xb=na[C];mc=Yc[Xb];if(mc!==void 0)for(qa=0;qa<4;qa++){oc=mc[qa];yc[Tb]=oc.u;yc[Tb+1]=oc.v;Tb=Tb+2}}if(Tb>0){k.bindBuffer(k.ARRAY_BUFFER,
la.__webglUV2Buffer);k.bufferData(k.ARRAY_BUFFER,yc,mb)}}if(Dc){C=0;for(W=ma.length;C<W;C++){Ob[nb]=Ha;Ob[nb+1]=Ha+1;Ob[nb+2]=Ha+2;nb=nb+3;ib[Za]=Ha;ib[Za+1]=Ha+1;ib[Za+2]=Ha;ib[Za+3]=Ha+2;ib[Za+4]=Ha+1;ib[Za+5]=Ha+2;Za=Za+6;Ha=Ha+3}C=0;for(W=na.length;C<W;C++){Ob[nb]=Ha;Ob[nb+1]=Ha+1;Ob[nb+2]=Ha+3;Ob[nb+3]=Ha+1;Ob[nb+4]=Ha+2;Ob[nb+5]=Ha+3;nb=nb+6;ib[Za]=Ha;ib[Za+1]=Ha+1;ib[Za+2]=Ha;ib[Za+3]=Ha+3;ib[Za+4]=Ha+1;ib[Za+5]=Ha+2;ib[Za+6]=Ha+2;ib[Za+7]=Ha+3;Za=Za+8;Ha=Ha+4}k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,
la.__webglFaceBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,Ob,mb);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,la.__webglLineBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,ib,mb)}if(Wc){qa=0;for(qc=Wc.length;qa<qc;qa++){x=Wc[qa];if(x.__original.needsUpdate){y=0;if(x.size===1)if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(W=ma.length;C<W;C++){P=Wa[ma[C]];x.array[y]=x.value[P.a];x.array[y+1]=x.value[P.b];x.array[y+2]=x.value[P.c];y=y+3}C=0;for(W=na.length;C<W;C++){P=Wa[na[C]];x.array[y]=x.value[P.a];x.array[y+
1]=x.value[P.b];x.array[y+2]=x.value[P.c];x.array[y+3]=x.value[P.d];y=y+4}}else{if(x.boundTo==="faces"){C=0;for(W=ma.length;C<W;C++){ra=x.value[ma[C]];x.array[y]=ra;x.array[y+1]=ra;x.array[y+2]=ra;y=y+3}C=0;for(W=na.length;C<W;C++){ra=x.value[na[C]];x.array[y]=ra;x.array[y+1]=ra;x.array[y+2]=ra;x.array[y+3]=ra;y=y+4}}}else if(x.size===2)if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(W=ma.length;C<W;C++){P=Wa[ma[C]];R=x.value[P.a];S=x.value[P.b];T=x.value[P.c];x.array[y]=R.x;x.array[y+1]=R.y;
x.array[y+2]=S.x;x.array[y+3]=S.y;x.array[y+4]=T.x;x.array[y+5]=T.y;y=y+6}C=0;for(W=na.length;C<W;C++){P=Wa[na[C]];R=x.value[P.a];S=x.value[P.b];T=x.value[P.c];ka=x.value[P.d];x.array[y]=R.x;x.array[y+1]=R.y;x.array[y+2]=S.x;x.array[y+3]=S.y;x.array[y+4]=T.x;x.array[y+5]=T.y;x.array[y+6]=ka.x;x.array[y+7]=ka.y;y=y+8}}else{if(x.boundTo==="faces"){C=0;for(W=ma.length;C<W;C++){T=S=R=ra=x.value[ma[C]];x.array[y]=R.x;x.array[y+1]=R.y;x.array[y+2]=S.x;x.array[y+3]=S.y;x.array[y+4]=T.x;x.array[y+5]=T.y;
y=y+6}C=0;for(W=na.length;C<W;C++){ka=T=S=R=ra=x.value[na[C]];x.array[y]=R.x;x.array[y+1]=R.y;x.array[y+2]=S.x;x.array[y+3]=S.y;x.array[y+4]=T.x;x.array[y+5]=T.y;x.array[y+6]=ka.x;x.array[y+7]=ka.y;y=y+8}}}else if(x.size===3){var Z;Z=x.type==="c"?["r","g","b"]:["x","y","z"];if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(W=ma.length;C<W;C++){P=Wa[ma[C]];R=x.value[P.a];S=x.value[P.b];T=x.value[P.c];x.array[y]=R[Z[0]];x.array[y+1]=R[Z[1]];x.array[y+2]=R[Z[2]];x.array[y+3]=S[Z[0]];x.array[y+4]=
S[Z[1]];x.array[y+5]=S[Z[2]];x.array[y+6]=T[Z[0]];x.array[y+7]=T[Z[1]];x.array[y+8]=T[Z[2]];y=y+9}C=0;for(W=na.length;C<W;C++){P=Wa[na[C]];R=x.value[P.a];S=x.value[P.b];T=x.value[P.c];ka=x.value[P.d];x.array[y]=R[Z[0]];x.array[y+1]=R[Z[1]];x.array[y+2]=R[Z[2]];x.array[y+3]=S[Z[0]];x.array[y+4]=S[Z[1]];x.array[y+5]=S[Z[2]];x.array[y+6]=T[Z[0]];x.array[y+7]=T[Z[1]];x.array[y+8]=T[Z[2]];x.array[y+9]=ka[Z[0]];x.array[y+10]=ka[Z[1]];x.array[y+11]=ka[Z[2]];y=y+12}}else if(x.boundTo==="faces"){C=0;for(W=
ma.length;C<W;C++){T=S=R=ra=x.value[ma[C]];x.array[y]=R[Z[0]];x.array[y+1]=R[Z[1]];x.array[y+2]=R[Z[2]];x.array[y+3]=S[Z[0]];x.array[y+4]=S[Z[1]];x.array[y+5]=S[Z[2]];x.array[y+6]=T[Z[0]];x.array[y+7]=T[Z[1]];x.array[y+8]=T[Z[2]];y=y+9}C=0;for(W=na.length;C<W;C++){ka=T=S=R=ra=x.value[na[C]];x.array[y]=R[Z[0]];x.array[y+1]=R[Z[1]];x.array[y+2]=R[Z[2]];x.array[y+3]=S[Z[0]];x.array[y+4]=S[Z[1]];x.array[y+5]=S[Z[2]];x.array[y+6]=T[Z[0]];x.array[y+7]=T[Z[1]];x.array[y+8]=T[Z[2]];x.array[y+9]=ka[Z[0]];
x.array[y+10]=ka[Z[1]];x.array[y+11]=ka[Z[2]];y=y+12}}else if(x.boundTo==="faceVertices"){C=0;for(W=ma.length;C<W;C++){ra=x.value[ma[C]];R=ra[0];S=ra[1];T=ra[2];x.array[y]=R[Z[0]];x.array[y+1]=R[Z[1]];x.array[y+2]=R[Z[2]];x.array[y+3]=S[Z[0]];x.array[y+4]=S[Z[1]];x.array[y+5]=S[Z[2]];x.array[y+6]=T[Z[0]];x.array[y+7]=T[Z[1]];x.array[y+8]=T[Z[2]];y=y+9}C=0;for(W=na.length;C<W;C++){ra=x.value[na[C]];R=ra[0];S=ra[1];T=ra[2];ka=ra[3];x.array[y]=R[Z[0]];x.array[y+1]=R[Z[1]];x.array[y+2]=R[Z[2]];x.array[y+
3]=S[Z[0]];x.array[y+4]=S[Z[1]];x.array[y+5]=S[Z[2]];x.array[y+6]=T[Z[0]];x.array[y+7]=T[Z[1]];x.array[y+8]=T[Z[2]];x.array[y+9]=ka[Z[0]];x.array[y+10]=ka[Z[1]];x.array[y+11]=ka[Z[2]];y=y+12}}}else if(x.size===4)if(x.boundTo===void 0||x.boundTo==="vertices"){C=0;for(W=ma.length;C<W;C++){P=Wa[ma[C]];R=x.value[P.a];S=x.value[P.b];T=x.value[P.c];x.array[y]=R.x;x.array[y+1]=R.y;x.array[y+2]=R.z;x.array[y+3]=R.w;x.array[y+4]=S.x;x.array[y+5]=S.y;x.array[y+6]=S.z;x.array[y+7]=S.w;x.array[y+8]=T.x;x.array[y+
9]=T.y;x.array[y+10]=T.z;x.array[y+11]=T.w;y=y+12}C=0;for(W=na.length;C<W;C++){P=Wa[na[C]];R=x.value[P.a];S=x.value[P.b];T=x.value[P.c];ka=x.value[P.d];x.array[y]=R.x;x.array[y+1]=R.y;x.array[y+2]=R.z;x.array[y+3]=R.w;x.array[y+4]=S.x;x.array[y+5]=S.y;x.array[y+6]=S.z;x.array[y+7]=S.w;x.array[y+8]=T.x;x.array[y+9]=T.y;x.array[y+10]=T.z;x.array[y+11]=T.w;x.array[y+12]=ka.x;x.array[y+13]=ka.y;x.array[y+14]=ka.z;x.array[y+15]=ka.w;y=y+16}}else if(x.boundTo==="faces"){C=0;for(W=ma.length;C<W;C++){T=S=
R=ra=x.value[ma[C]];x.array[y]=R.x;x.array[y+1]=R.y;x.array[y+2]=R.z;x.array[y+3]=R.w;x.array[y+4]=S.x;x.array[y+5]=S.y;x.array[y+6]=S.z;x.array[y+7]=S.w;x.array[y+8]=T.x;x.array[y+9]=T.y;x.array[y+10]=T.z;x.array[y+11]=T.w;y=y+12}C=0;for(W=na.length;C<W;C++){ka=T=S=R=ra=x.value[na[C]];x.array[y]=R.x;x.array[y+1]=R.y;x.array[y+2]=R.z;x.array[y+3]=R.w;x.array[y+4]=S.x;x.array[y+5]=S.y;x.array[y+6]=S.z;x.array[y+7]=S.w;x.array[y+8]=T.x;x.array[y+9]=T.y;x.array[y+10]=T.z;x.array[y+11]=T.w;x.array[y+
12]=ka.x;x.array[y+13]=ka.y;x.array[y+14]=ka.z;x.array[y+15]=ka.w;y=y+16}}else if(x.boundTo==="faceVertices"){C=0;for(W=ma.length;C<W;C++){ra=x.value[ma[C]];R=ra[0];S=ra[1];T=ra[2];x.array[y]=R.x;x.array[y+1]=R.y;x.array[y+2]=R.z;x.array[y+3]=R.w;x.array[y+4]=S.x;x.array[y+5]=S.y;x.array[y+6]=S.z;x.array[y+7]=S.w;x.array[y+8]=T.x;x.array[y+9]=T.y;x.array[y+10]=T.z;x.array[y+11]=T.w;y=y+12}C=0;for(W=na.length;C<W;C++){ra=x.value[na[C]];R=ra[0];S=ra[1];T=ra[2];ka=ra[3];x.array[y]=R.x;x.array[y+1]=R.y;
x.array[y+2]=R.z;x.array[y+3]=R.w;x.array[y+4]=S.x;x.array[y+5]=S.y;x.array[y+6]=S.z;x.array[y+7]=S.w;x.array[y+8]=T.x;x.array[y+9]=T.y;x.array[y+10]=T.z;x.array[y+11]=T.w;x.array[y+12]=ka.x;x.array[y+13]=ka.y;x.array[y+14]=ka.z;x.array[y+15]=ka.w;y=y+16}}k.bindBuffer(k.ARRAY_BUFFER,x.buffer);k.bufferData(k.ARRAY_BUFFER,x.array,mb)}}}if(yb){delete la.__inittedArrays;delete la.__colorArray;delete la.__normalArray;delete la.__tangentArray;delete la.__uvArray;delete la.__uv2Array;delete la.__faceArray;
delete la.__vertexArray;delete la.__lineArray;delete la.__skinIndexArray;delete la.__skinWeightArray}}}}ea.verticesNeedUpdate=false;ea.morphTargetsNeedUpdate=false;ea.elementsNeedUpdate=false;ea.uvsNeedUpdate=false;ea.normalsNeedUpdate=false;ea.colorsNeedUpdate=false;ea.tangentsNeedUpdate=false;cb.attributes&&o(cb)}else if(ub instanceof THREE.Ribbon){if(ea.verticesNeedUpdate||ea.colorsNeedUpdate){var cc=ea,bd=k.DYNAMIC_DRAW,zc=void 0,Ac=void 0,Ic=void 0,dc=void 0,Jc=void 0,cd=cc.vertices,dd=cc.colors,
jd=cd.length,kd=dd.length,Kc=cc.__vertexArray,Lc=cc.__colorArray,ld=cc.colorsNeedUpdate;if(cc.verticesNeedUpdate){for(zc=0;zc<jd;zc++){Ic=cd[zc];dc=zc*3;Kc[dc]=Ic.x;Kc[dc+1]=Ic.y;Kc[dc+2]=Ic.z}k.bindBuffer(k.ARRAY_BUFFER,cc.__webglVertexBuffer);k.bufferData(k.ARRAY_BUFFER,Kc,bd)}if(ld){for(Ac=0;Ac<kd;Ac++){Jc=dd[Ac];dc=Ac*3;Lc[dc]=Jc.r;Lc[dc+1]=Jc.g;Lc[dc+2]=Jc.b}k.bindBuffer(k.ARRAY_BUFFER,cc.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,Lc,bd)}}ea.verticesNeedUpdate=false;ea.colorsNeedUpdate=
false}else if(ub instanceof THREE.Line){cb=c(ub,bb);ab=cb.attributes&&p(cb);if(ea.verticesNeedUpdate||ea.colorsNeedUpdate||ab){var Ub=ea,Zc=k.DYNAMIC_DRAW,Bc=void 0,Cc=void 0,Mc=void 0,Ba=void 0,Nc=void 0,ed=Ub.vertices,fd=Ub.colors,md=ed.length,nd=fd.length,Oc=Ub.__vertexArray,Pc=Ub.__colorArray,od=Ub.colorsNeedUpdate,c){Qc=0;for(gd=c[Qc];if(wa.needsUpdate&&(wa.boundTo===void 0||wa.boundTo==="vertices")){Ba=0;pc=wa.value.length;if(wa.size===1)for(Ua=0;Ua<pc;Ua++)wa.array[Ua]=wa.value[Ua];else if(wa.size===2)for(Ua=
0;Ua<pc;Ua++){eb=wa.value[Ua];wa.array[Ba]=eb.x;wa.array[Ba+1]=eb.y;Ba=Ba+2}else if(wa.size===3)if(wa.type==="c")for(Ua=0;Ua<pc;Ua++){eb=wa.value[Ua];wa.array[Ba]=eb.r;wa.array[Ba+1]=eb.g;wa.array[Ba+2]=eb.b;Ba=Ba+3}else for(Ua=0;Ua<pc;Ua++){eb=wa.value[Ua];wa.array[Ba]=eb.x;wa.array[Ba+1]=eb.y;wa.array[Ba+2]=eb.z;Ba=Ba+3}else if(wa.size===4)for(Ua=0;Ua<pc;Ua++){eb=wa.value[Ua];wa.array[Ba]=eb.x;wa.array[Ba+1]=eb.y;wa.array[Ba+2]=eb.z;wa.array[Ba+3]=eb.w;Ba=Ba+4}k.bindBuffer(k.ARRAY_BUFFER,wa.buffer);
k.bufferData(k.ARRAY_BUFFER,wa.array,Zc)}}}}ea.verticesNeedUpdate=false;ea.colorsNeedUpdate=false;cb.attributes&&o(cb)}else if(ub instanceof THREE.ParticleSystem)if(ea instanceof THREE.BufferGeometry){(ea.verticesNeedUpdate||ea.colorsNeedUpdate)&&h(ea,k.DYNAMIC_DRAW,!ea.dynamic);ea.verticesNeedUpdate=false;ea.colorsNeedUpdate=false}else{cb=c(ub,bb);ab=cb.attributes&&p(cb);(ea.verticesNeedUpdate||ea.colorsNeedUpdate||ub.sortParticles||ab)&&g(ea,k.DYNAMIC_DRAW,ub);ea.verticesNeedUpdate=false;ea.colorsNeedUpdate=
false;cb.attributes&&o(cb)}}};this.initMaterial=function(a,b,c,d){var e,f,g,h,i,j,l,m,n;a instanceof THREE.MeshDepthMaterial?n="depth":a instanceof THREE.MeshNormalMaterial?n="normal":a instanceof THREE.MeshBasicMaterial?n="basic":a instanceof THREE.MeshLambertMaterial?n="lambert":a instanceof THREE.MeshPhongMaterial?n="phong":a instanceof THREE.LineBasicMaterial?n="basic":a instanceof THREE.ParticleBasicMaterial&&(n="particle_basic");if(n){var o=THREE.ShaderLib[n];a.uniforms=THREE.UniformsUtils.clone(o.uniforms);
a.vertexShader=o.vertexShader;a.fragmentShader=o.fragmentShader}var p,q;p=h=f=e=o=0;for(g=b.length;p<g;p++){q=b[p];if(!q.onlyShadow){q instanceof THREE.DirectionalLight&&h++;q instanceof THREE.PointLight&&f++;q instanceof THREE.SpotLight&&e++;q instanceof THREE.HemisphereLight&&o++}}if(f+e+h+o<=ba){p=h;g=e}else{p=Math.ceil(ba*h/(f+h));g=f=ba-p;o=p}e=p;h=o;o=m=0;for(p=b.length;o<p;o++){q=b[o];if(q.castShadow){q instanceof THREE.SpotLight&&m++;q instanceof THREE.DirectionalLight&&!q.shadowCascade&&
m++}}if(ec&&d&&d.useVertexTexture)l=1024;else{b=k.getParameter(k.MAX_VERTEX_UNIFORM_VECTORS);b=Math.floor((b-20)/4);if(d!==void 0&&d instanceof THREE.SkinnedMesh){b=Math.min(d.bones.length,b);b<d.bones.length&&console.warn("WebGLRenderer: too many bones - "+d.bones.length+", this GPU supports just "+b+" (try OpenGL instead of ANGLE)")}l=b}var r;a:{q=a.fragmentShader;p=a.vertexShader;var o=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,bumpMap:!!a.bumpMap,normalMap:!!a.normalMap,
specularMap:!!a.specularMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,maxBones:l,useVertexTexture:ec&&d&&d.useVertexTexture,boneTextureWidth:d&&d.boneTextureWidth,boneTextureHeight:d&&d.boneTextureHeight,morphTargets:a.morphTargets,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:e,maxPointLights:f,maxSpotLights:g,maxHemiLights:h,maxShadows:m,shadowMapEnabled:this.shadowMapEnabled&&
d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,shadowMapCascade:this.shadowMapCascade,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround,doubleSided:a.side===THREE.DoubleSide,flipSided:a.side===THREE.BackSide},s,d=[];if(n)d.push(n);else{d.push(q);d.push(p)}for(s in c){d.push(s);d.push(c[s])}n=d.join();s=0;for(d=fa.length;s<d;s++){e=fa[s];if(e.code===n){e.usedTimes++;r=e.program;break a}}s=k.createProgram();d=["precision "+F+" float;",
ic?"#define VERTEX_TEXTURES":"",Q.gammaInput?"#define GAMMA_INPUT":"",Q.gammaOutput?"#define GAMMA_OUTPUT":"",Q.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_HEMI_LIGHTS "+c.maxHemiLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":
"",c.bumpMap?"#define USE_BUMPMAP":"",c.normalMap?"#define USE_NORMALMAP":"",c.specularMap?"#define USE_SPECULARMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.useVertexTexture?"#define BONE_TEXTURE":"",c.boneTextureWidth?"#define N_BONE_PIXEL_X "+c.boneTextureWidth.toFixed(1):"",c.boneTextureHeight?"#define N_BONE_PIXEL_Y "+c.boneTextureHeight.toFixed(1):"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":
"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.flipSided?"#define FLIP_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
e=["precision "+F+" float;",c.bumpMap||c.normalMap?"#extension GL_OES_standard_derivatives : enable":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_HEMI_LIGHTS "+c.maxHemiLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",Q.gammaInput?"#define GAMMA_INPUT":"",Q.gammaOutput?"#define GAMMA_OUTPUT":"",Q.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",
c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.bumpMap?"#define USE_BUMPMAP":"",c.normalMap?"#define USE_NORMALMAP":"",c.specularMap?"#define USE_SPECULARMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.flipSided?
"#define FLIP_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");e=z("fragment",e+q);d=z("vertex",d+p);k.attachShader(s,d);k.attachShader(s,e);k.linkProgram(s);k.getProgramParameter(s,k.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+k.getProgramParameter(s,
k.VALIDATE_STATUS)+", gl error ["+k.getError()+"]");k.deleteShader(e);k.deleteShader(d);s.uniforms={};s.attributes={};var t,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","modelMatrix","cameraPosition","morphTargetInfluences"];c.useVertexTexture?d.push("boneTexture"):d.push("boneGlobalMatrices");for(t in o)d.push(t);t=d;d=0;for(o=t.length;d<o;d++){e=t[d];s.uniforms[e]=k.getUniformLocation(s,e)}d=["position","normal","uv","uv2","tangent","color","skinIndex","skinWeight"];for(t=
0;t<c.maxMorphTargets;t++)d.push("morphTarget"+t);for(t=0;t<c.maxMorphNormals;t++)d.push("morphNormal"+t);for(r in b)d.push(r);r=d;t=0;for(c=r.length;t<c;t++){d=r[t];s.attributes[d]=k.getAttribLocation(s,d)}s.id=ta++;fa.push({program:s,code:n,usedTimes:1});Q.info.memory.programs=fa.length;r=s}a.program=r;r=a.program.attributes;r.position>=0&&k.enableVertexAttribArray(r.position);r.color>=0&&k.enableVertexAttribArray(r.color);r.normal>=0&&k.enableVertexAttribArray(r.normal);r.tangent>=0&&k.enableVertexAttribArray(r.tangent);
if(a.skinning&&r.skinIndex>=0&&r.skinWeight>=0){k.enableVertexAttribArray(r.skinIndex);k.enableVertexAttribArray(r.skinWeight)}if(a.attributes)for(j in a.attributes)r[j]!==void 0&&r[j]>=0&&k.enableVertexAttribArray(r[j]);if(a.morphTargets){a.numSupportedMorphTargets=0;s="morphTarget";for(j=0;j<this.maxMorphTargets;j++){t=s+j;if(r[t]>=0){k.enableVertexAttribArray(r[t]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;s="morphNormal";for(j=0;j<this.maxMorphNormals;j++){t=
s+j;if(r[t]>=0){k.enableVertexAttribArray(r[t]);a.numSupportedMorphNormals++}}}a.uniformsList=[];for(i in a.uniforms)a.uniformsList.push([a.uniforms[i],i])};this.setFaceCulling=function(a,b){if(a){!b||b==="ccw"?k.frontFace(k.CCW):k.frontFace(k.CW);a==="back"?k.cullFace(k.BACK):a==="front"?k.cullFace(k.FRONT):k.cullFace(k.FRONT_AND_BACK);k.enable(k.CULL_FACE)}else k.disable(k.CULL_FACE)};this.setMaterialFaces=function(a){var b=a.side===THREE.DoubleSide,a=a.side===THREE.BackSide;if(ua!==b){b?k.disable(k.CULL_FACE):
k.enable(k.CULL_FACE);ua=b}if(Ca!==a){a?k.frontFace(k.CW):k.frontFace(k.CCW);Ca=a}};this.setDepthTest=function(a){if(Oa!==a){a?k.enable(k.DEPTH_TEST):k.disable(k.DEPTH_TEST);Oa=a}};this.setDepthWrite=function(a){if(Ya!==a){k.depthMask(a);Ya=a}};this.setBlending=function(a,b,c,d){if(a!==Ja){if(a===THREE.NoBlending)k.disable(k.BLEND);else if(a===THREE.AdditiveBlending){k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE)}else if(a===THREE.SubtractiveBlending){k.enable(k.BLEND);
k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR)}else if(a===THREE.MultiplyBlending){k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.SRC_COLOR)}else if(a===THREE.CustomBlending)k.enable(k.BLEND);else{k.enable(k.BLEND);k.blendEquationSeparate(k.FUNC_ADD,k.FUNC_ADD);k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)}Ja=a}if(a===THREE.CustomBlending){if(b!==Xa){k.blendEquation(H(b));Xa=b}if(c!==ja||d!==pb){k.blendFunc(H(c),H(d));
ja=c;pb=d}}else pb=ja=Xa=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=k.createTexture();Q.info.memory.textures++}k.activeTexture(k.TEXTURE0+b);k.bindTexture(k.TEXTURE_2D,a.__webglTexture);k.pixelStorei(k.UNPACK_FLIP_Y_WEBGL,a.flipY);k.pixelStorei(k.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=(c.width&c.width-1)===0&&(c.height&c.height-1)===0,e=H(a.format),f=H(a.type);M(k.TEXTURE_2D,a,d);if(a instanceof THREE.CompressedTexture)for(var f=
a.mipmaps,g=0,h=f.length;g<h;g++){c=f[g];k.compressedTexImage2D(k.TEXTURE_2D,g,e,c.width,c.height,0,c.data)}else a instanceof THREE.DataTexture?k.texImage2D(k.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):k.texImage2D(k.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&k.generateMipmap(k.TEXTURE_2D);a.needsUpdate=false;if(a.onUpdate)a.onUpdate()}else{k.activeTexture(k.TEXTURE0+b);k.bindTexture(k.TEXTURE_2D,a.__webglTexture)}};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;
if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=true;if(a.stencilBuffer===void 0)a.stencilBuffer=true;a.__webglTexture=k.createTexture();var c=(a.width&a.width-1)===0&&(a.height&a.height-1)===0,d=H(a.format),e=H(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];k.bindTexture(k.TEXTURE_CUBE_MAP,a.__webglTexture);M(k.TEXTURE_CUBE_MAP,a,c);for(var f=0;f<6;f++){a.__webglFramebuffer[f]=k.createFramebuffer();a.__webglRenderbuffer[f]=k.createRenderbuffer();k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+
f,0,d,a.width,a.height,0,d,e,null);var g=a,h=k.TEXTURE_CUBE_MAP_POSITIVE_X+f;k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer[f]);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,h,g.__webglTexture,0);D(a.__webglRenderbuffer[f],a)}c&&k.generateMipmap(k.TEXTURE_CUBE_MAP)}else{a.__webglFramebuffer=k.createFramebuffer();a.__webglRenderbuffer=k.createRenderbuffer();k.bindTexture(k.TEXTURE_2D,a.__webglTexture);M(k.TEXTURE_2D,a,c);k.texImage2D(k.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null);d=
k.TEXTURE_2D;k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,d,a.__webglTexture,0);D(a.__webglRenderbuffer,a);c&&k.generateMipmap(k.TEXTURE_2D)}b?k.bindTexture(k.TEXTURE_CUBE_MAP,null):k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER,null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer;c=a.width;a=a.height;e=d=0}else{b=null;c=Ga;a==void 0,L=void 0,D=H=F=void 0,D=A-B,G=E-v,H=w-A,O=s-E,F=B-w,J=v-s,I=z-w,K=M-s,V=z-B,Y=M-v,;if(D>=0&&H>=0&&F>=0){m=false;break a}}m=true}}if(m){e.push([a[g[i]],
a[g[j]],a[g[l]]]);h.push([g[i],g[j],g[l]]);i=j;for(l=j+1;l<f;i++,l++)g[i]=g[l];f--;n=2*f}}return d?h:e};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){a=this.getUtoTmapping(a);return this.getPoint(a)};
THREE.Curve.prototype.getPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c};THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};
THREE.Curve.prototype.getLengths=function(a){a||(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=false;var b=[],c,d=this.getPoint(0),f,e=0;b.push(0);for(f=1;f<=a;f++){c=this.getPoint(f/a);e=e+c.distanceTo(d);b.push(e);d=c}return this.cacheArcLengths=b};THREE.Curve.prototype.updateArcLengths=function(){this.needsUpdate=true;this.getLengths()};
THREE.Curve.prototype.getUtoTmapping=function(a,b){var c=this.getLengths(),d=0,f=c.length,e;e=b?b:a*c[f-1];for(var g=0,h=f-1,i;g<=h;){d=Math.floor(g+(h-g)/2);i=c[d]-e;if(i<0)g=d+1;else if(i>0)h=d-1;else{h=d;break}}d=h;if(c[d]==e)return d/(f-1);g=c[d];return c=(d+(e-g)/(c[d+1]-g))/(f-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)};
THREE.Curve.prototype.getTangent=function(a){var b=a-1E-4,a=a+1E-4;b<0&&(b=0);a>1&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().subSelf(b).normalize()};THREE.Curve.prototype.getTangentAt=function(a){a=this.getUtoTmapping(a);return this.getTangent(a)};THREE.LineCurve=function(a,b){this.v1=a;this.v2=b};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().subSelf(this.v1);b.multiplyScalar(a).addSelf(this.v1);return b};
THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){return this.v2.clone().subSelf(this.v1).normalize()};THREE.QuadraticBezierCurve=function(a,b,c){this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype);
THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(b,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);b=new THREE.Vector2(b,a);b.normalize();return b};
THREE.CubicBezierCurve=function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d};THREE.CubicBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.CubicBezierCurve.prototype.getPoint=function(a){var b;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(b,a)};
THREE.CubicBezierCurve.prototype.getTangent=function(a){var b;b=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=new THREE.Vector2(b,a);b.normalize();return b};THREE.SplineCurve=function(a){this.points=a==void 0?[]:a};THREE.SplineCurve.prototype=Object.create(THREE.Curve.prototype);
THREE.SplineCurve.prototype.getPoint=function(a){var b=new THREE.Vector2,c=[],d=this.points,f;f=(d.length-1)*a;a=Math.floor(f);f=f-a;c[0]=a==0?a:a-1;c[1]=a;c[2]=a>d.length-2?d.length-1:a+1;c[3]=a>d.length-3?d.length-1:a+2;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,f);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,f);return b};
THREE.EllipseCurve=function(a,b,c,d,f,e,g){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=f;this.aEndAngle=e;this.aClockwise=g};THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype);THREE.EllipseCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);b=this.aStartAngle+a*b;a=this.aX+this.xRadius*Math.cos(b);b=this.aY+this.yRadius*Math.sin(b);return new THREE.Vector2(a,b)};
THREE.ArcCurve=function(a,b,c,d,f,e){THREE.EllipseCurve.call(this,a,b,c,c,d,f,e)};THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype);
THREE.Curve.Utils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,f){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*f},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,f){var a=(c-a)*0.5,d=(d-b)*0.5,e=f*f;return(2*b-2*c+a+d)*f*e+(-3*b+3*c-2*a-d)*e+a*f+b}};
THREE.Curve.create=function(a,b){a.prototype=Object.create(THREE.Curve.prototype);a.prototype.getPoint=b;return a};THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.sub(this.v2,this.v1);b.multiplyScalar(a);b.addSelf(this.v1);return b});
THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b,c;b=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);c=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(b,c,a)});
THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b,c;b=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);c=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(b,c,a)});
THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=a==void 0?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,f,a=(d.length-1)*a;f=Math.floor(a);a=a-f;c[0]=f==0?f:f-1;c[1]=f;c[2]=f>d.length-2?d.length-1:f+1;c[3]=f>d.length-3?d.length-1:f+2;f=d[c[0]];var e=d[c[1]],g=d[c[2]],c=d[c[3]];b.x=THREE.Curve.Utils.interpolate(f.x,e.x,g.x,c.x,a);b.y=THREE.Curve.Utils.interpolate(f.y,e.y,g.y,c.y,a);b.z=THREE.Curve.Utils.interpolate(f.z,e.z,g.z,c.z,a);return b});
THREE.ClosedSplineCurve3=THREE.Curve.create(function(a){this.points=a==void 0?[]:a},function(a){var b=new THREE.Vector3,c=[],d=this.points,f;f=(d.length-0)*a;a=Math.floor(f);f=f-a;a=a+(a>0?0:(Math.floor(Math.abs(a)/d.length)+1)*d.length);c[0]=(a-1)\%d.length;c[1]=a\%d.length;c[2]=(a+1)\%d.length;c[3]=(a+2)\%d.length;b.x=THREE.Curve.Utils.interpolate(d[c[0]].x,d[c[1]].x,d[c[2]].x,d[c[3]].x,f);b.y=THREE.Curve.Utils.interpolate(d[c[0]].y,d[c[1]].y,d[c[2]].y,d[c[3]].y,f);b.z=THREE.Curve.Utils.interpolate(d[c[0]].z,
d[c[1]].z,d[c[2]].z,d[c[3]].z,f);return b});THREE.CurvePath=function(){this.curves=[];this.bends=[];this.autoClose=false};THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype);THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))};
THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),a=0;a<c.length;){if(c[a]>=b){b=c[a]-b;a=this.curves[a];b=1-b/a.getLength();return a.getPointAt(b)}a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]};
THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],b=0,c,d=this.curves.length;for(c=0;c<d;c++){b=b+this.curves[c].getLength();a.push(b)}return this.cacheLengths=a};
THREE.CurvePath.prototype.getBoundingBox=function(){var a=this.getPoints(),b,c,d,f,e,g;b=c=Number.NEGATIVE_INFINITY;f=e=Number.POSITIVE_INFINITY;var h,i,j,l,n=a[0]instanceof THREE.Vector3;l=n?new THREE.Vector3:new THREE.Vector2;i=0;for(j=a.length;i<j;i++){h=a[i];if(h.x>b)b=h.x;else if(h.x<f)f=h.x;if(h.y>c)c=h.y;else if(h.y<e)e=h.y;if(n)if(h.z>d)d=h.z;else if(h.z<g)g=h.z;l.addSelf(h)}a={minX:f,minY:e,maxX:b,maxY:c,centroid:l.divideScalar(j)};if(n){a.maxZ=d;a.minZ=g}return a};
THREE.CurvePath.prototype.createPointsGeometry=function(a){a=this.getPoints(a,true);return this.createGeometry(a)};THREE.CurvePath.prototype.createSpacedPointsGeometry=function(a){a=this.getSpacedPoints(a,true);return this.createGeometry(a)};THREE.CurvePath.prototype.createGeometry=function(a){for(var b=new THREE.Geometry,c=0;c<a.length;c++)b.vertices.push(new THREE.Vector3(a[c].x,a[c].y,a[c].z||0));return b};THREE.CurvePath.prototype.addWrapPath=function(a){this.bends.push(a)};
THREE.CurvePath.prototype.getTransformedPoints=function(a,b){var c=this.getPoints(a),d,f;if(!b)b=this.bends;d=0;for(f=b.length;d<f;d++)c=this.getWrapPoints(c,b[d]);return c};THREE.CurvePath.prototype.getTransformedSpacedPoints=function(a,b){var c=this.getSpacedPoints(a),d,f;if(!b)b=this.bends;d=0;for(f=b.length;d<f;d++)c=this.getWrapPoints(c,b[d]);return c};
THREE.CurvePath.prototype.getWrapPoints=function(a,b){var c=this.getBoundingBox(),d,f,e,g,h,i;d=0;for(f=a.length;d<f;d++){e=a[d];g=e.x;h=e.y;i=g/c.maxX;i=b.getUtoTmapping(i,g);g=b.getPoint(i);h=b.getNormalVector(i).multiplyScalar(h);e.x=g.x+h.x;e.y=g.y+h.y}return a};THREE.Gyroscope=function(){THREE.Object3D.call(this)};THREE.Gyroscope.prototype=Object.create(THREE.Object3D.prototype);
THREE.Gyroscope.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a){if(this.parent){this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix);this.matrixWorld.decompose(this.translationWorld,this.rotationWorld,this.scaleWorld);this.matrix.decompose(this.translationObject,this.rotationObject,this.scaleObject);this.matrixWorld.compose(this.translationWorld,this.rotationObject,this.scaleWorld)}else this.matrixWorld.copy(this.matrix);
this.matrixWorldNeedsUpdate=false;a=true}for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)};THREE.Gyroscope.prototype.translationWorld=new THREE.Vector3;THREE.Gyroscope.prototype.translationObject=new THREE.Vector3;THREE.Gyroscope.prototype.rotationWorld=new THREE.Quaternion;THREE.Gyroscope.prototype.rotationObject=new THREE.Quaternion;THREE.Gyroscope.prototype.scaleWorld=new THREE.Vector3;THREE.Gyroscope.prototype.scaleObject=new THREE.Vector3;
THREE.Path=function(a){THREE.CurvePath.call(this);this.actions=[];a&&this.fromPoints(a)};THREE.Path.prototype=Object.create(THREE.CurvePath.prototype);THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc",ELLIPSE:"ellipse"};THREE.Path.prototype.fromPoints=function(a){this.moveTo(a[0].x,a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y)};
THREE.Path.prototype.moveTo=function(a,b){var c=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:c})};THREE.Path.prototype.lineTo=function(a,b){var c=Array.prototype.slice.call(arguments),d=this.actions[this.actions.length-1].args,d=new THREE.LineCurve(new THREE.Vector2(d[d.length-2],d[d.length-1]),new THREE.Vector2(a,b));this.curves.push(d);this.actions.push({action:THREE.PathActions.LINE_TO,args:c})};
THREE.Path.prototype.quadraticCurveTo=function(a,b,c,d){var f=Array.prototype.slice.call(arguments),e=this.actions[this.actions.length-1].args,e=new THREE.QuadraticBezierCurve(new THREE.Vector2(e[e.length-2],e[e.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d));this.curves.push(e);this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:f})};
THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,f,e){var g=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args,h=new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length-2],h[h.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d),new THREE.Vector2(f,e));this.curves.push(h);this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:g})};
THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a);c=new THREE.SplineCurve(c);this.curves.push(c);this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:b})};THREE.Path.prototype.arc=function(a,b,c,d,f,e){var g=this.actions[this.actions.length-1].args;this.absarc(a+g[g.length-2],b+g[g.length-1],c,d,f,e)};
THREE.Path.prototype.absarc=function(a,b,c,d,f,e){this.absellipse(a,b,c,c,d,f,e)};THREE.Path.prototype.ellipse=function(a,b,c,d,f,e,g){var h=this.actions[this.actions.length-1].args;this.absellipse(a+h[h.length-2],b+h[h.length-1],c,d,f,e,g)};THREE.Path.prototype.absellipse=function(a,b,c,d,f,e,g){var h=Array.prototype.slice.call(arguments),i=new THREE.EllipseCurve(a,b,c,d,f,e,g);this.curves.push(i);i=i.getPoint(g?1:0);h.push(i.x);h.push(i.y);this.actions.push({action:THREE.PathActions.ELLIPSE,args:h})};
THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c<a;c++)b.push(this.getPoint(c/a));return b};
THREE.Path.prototype.getPoints=function(a,b){if(this.useSpacedPoints){console.log("tata");return this.getSpacedPoints(a,b)}var a=a||12,c=[],d,f,e,g,h,i,j,l,n,m,q,p,o;d=0;for(f=this.actions.length;d<f;d++){e=this.actions[d];g=e.action;e=e.args;switch(g){case THREE.PathActions.MOVE_TO:c.push(new THREE.Vector2(e[0],e[1]));break;case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(e[0],e[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=e[2];i=e[3];n=e[0];m=e[1];if(c.length>0){g=c[c.length-1];
q=g.x;p=g.y}else{g=this.actions[d-1].args;q=g[g.length-2];p=g[g.length-1]}for(e=1;e<=a;e++){o=e/a;g=THREE.Shape.Utils.b2(o,q,n,h);o=THREE.Shape.Utils.b2(o,p,m,i);c.push(new THREE.Vector2(g,o))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=e[4];i=e[5];n=e[0];m=e[1];j=e[2];l=e[3];if(c.length>0){g=c[c.length-1];q=g.x;p=g.y}else{g=this.actions[d-1].args;q=g[g.length-2];p=g[g.length-1]}for(e=1;e<=a;e++){o=e/a;g=THREE.Shape.Utils.b3(o,q,n,j,h);o=THREE.Shape.Utils.b3(o,p,m,l,i);c.push(new THREE.Vector2(g,
o))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;o=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=a*e[0].length;o=o.concat(e[0]);o=new THREE.SplineCurve(o);for(e=1;e<=g;e++)c.push(o.getPointAt(e/g));break;case THREE.PathActions.ARC:h=e[0];i=e[1];m=e[2];j=e[3];g=e[4];n=!!e[5];q=g-j;p=a*2;for(e=1;e<=p;e++){o=e/p;n||(o=1-o);o=j+o*q;g=h+m*Math.cos(o);o=i+m*Math.sin(o);c.push(new THREE.Vector2(g,o))}break;case THREE.PathActions.ELLIPSE:h=e[0];i=e[1];m=e[2];l=e[3];j=e[4];g=e[5];
n=!!e[6];q=g-j;p=a*2;for(e=1;e<=p;e++){o=e/p;n||(o=1-o);o=j+o*q;g=h+m*Math.cos(o);o=i+l*Math.sin(o);c.push(new THREE.Vector2(g,o))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1E-10&&Math.abs(d.y-c[0].y)<1E-10&&c.splice(c.length-1,1);b&&c.push(c[0]);return c};
THREE.Path.prototype.toShapes=function(){var a,b,c,d,f=[],e=new THREE.Path;a=0;for(b=this.actions.length;a<b;a++){c=this.actions[a];d=c.args;c=c.action;if(c==THREE.PathActions.MOVE_TO&&e.actions.length!=0){f.push(e);e=new THREE.Path}e[c].apply(e,d)}e.actions.length!=0&&f.push(e);if(f.length==0)return[];var g;d=[];a=!THREE.Shape.Utils.isClockWise(f[0].getPoints());if(f.length==1){e=f[0];g=new THREE.Shape;g.actions=e.actions;g.curves=e.curves;d.push(g);return d}if(a){g=new THREE.Shape;a=0;for(b=f.length;a<
b;a++){e=f[a];if(THREE.Shape.Utils.isClockWise(e.getPoints())){g.actions=e.actions;g.curves=e.curves;d.push(g);g=new THREE.Shape}else g.holes.push(e)}}else{a=0;for(b=f.length;a<b;a++){e=f[a];if(THREE.Shape.Utils.isClockWise(e.getPoints())){g&&d.push(g);g=new THREE.Shape;g.actions=e.actions;g.curves=e.curves}else g.holes.push(e)}d.push(g)}return d};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=Object.create(THREE.Path.prototype);
THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};THREE.Shape.prototype.makeGeometry=function(a){return new THREE.ShapeGeometry(this,a)};THREE.Shape.prototype.getPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedPoints(a,this.bends);return d};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedSpacedPoints(a,this.bends);return d};
THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}};THREE.Shape.prototype.extractPoints=function(a){return this.useSpacedPoints?this.extractAllSpacedPoints(a):this.extractAllPoints(a)};THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}};
THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),f,e,g,h,i,j,l,n,m,q,p=[];for(i=0;i<b.length;i++){j=b[i];Array.prototype.push.apply(d,j);e=Number.POSITIVE_INFINITY;for(f=0;f<j.length;f++){m=j[f];q=[];for(n=0;n<c.length;n++){l=c[n];l=m.distanceToSquared(l);q.push(l);if(l<e){e=l;g=f;h=n}}}f=h-1>=0?h-1:c.length-1;e=g-1>=0?g-1:j.length-1;var o=[j[g],c[h],c[f]];n=THREE.FontUtils.Triangulate.area(o);var r=[j[g],j[e],c[h]];m=THREE.FontUtils.Triangulate.area(r);q=h;l=g;h=h+1;g=g+
-1;h<0&&(h=h+c.length);h=h\%c.length;g<0&&(g=g+j.length);g=g\%j.length;f=h-1>=0?h-1:c.length-1;e=g-1>=0?g-1:j.length-1;o=[j[g],c[h],c[f]];o=THREE.FontUtils.Triangulate.area(o);r=[j[g],j[e],c[h]];r=THREE.FontUtils.Triangulate.area(r);if(n+m>o+r){h=q;g=l;h<0&&(h=h+c.length);h=h\%c.length;g<0&&(g=g+j.length);g=g\%j.length;f=h-1>=0?h-1:c.length-1;e=g-1>=0?g-1:j.length-1}n=c.slice(0,h);m=c.slice(h);q=j.slice(g);l=j.slice(0,g);e=[j[g],j[e],c[h]];p.push([j[g],c[h],c[f]]);p.push(e);c=n.concat(q).concat(l).concat(m)}return{shape:c,
isolatedPts:p,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,f=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,false),e,g,h,i,j={};e=0;for(g=d.length;e<g;e++){i=d[e].x+":"+d[e].y;j[i]!==void 0&&console.log("Duplicate point",i);j[i]=e}e=0;for(g=c.length;e<g;e++){h=c[e];for(d=0;d<3;d++){i=h[d].x+":"+h[d].y;i=j[i];i!==void 0&&(h[d]=i)}}e=0;for(g=f.length;e<g;e++){h=f[e];for(d=0;d<3;d++){i=h[d].x+":"+h[d].y;i=j[i];i!==void 0&&(h[d]=i)}}return c.concat(f)},
isClockWise:function(a){return THREE.FontUtils.Triangulate.area(a)<0},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,f){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+
this.b3p3(a,f)}};
THREE.AnimationHandler=function(){var a=[],b={},c={update:function(b){for(var c=0;c<a.length;c++)a[c].update(b)},addToUpdate:function(b){a.indexOf(b)===-1&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);b!==-1&&a.splice(b,1)},add:function(a){b[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");b[a.name]=a;if(a.initialized!==true){for(var c=0;c<a.hierarchy.length;c++){for(var d=0;d<a.hierarchy[c].keys.length;d++){if(a.hierarchy[c].keys[d].time<0)a.hierarchy[c].keys[d].time=
0;if(a.hierarchy[c].keys[d].rot!==void 0&&!(a.hierarchy[c].keys[d].rot instanceof THREE.Quaternion)){var h=a.hierarchy[c].keys[d].rot;a.hierarchy[c].keys[d].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(a.hierarchy[c].keys.length&&a.hierarchy[c].keys[0].morphTargets!==void 0){h={};for(d=0;d<a.hierarchy[c].keys.length;d++)for(var i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++){var j=a.hierarchy[c].keys[d].morphTargets[i];h[j]=-1}a.hierarchy[c].usedMorphTargets=h;for(d=0;d<a.hierarchy[c].keys.length;d++){var l=
{};for(j in h){for(i=0;i<a.hierarchy[c].keys[d].morphTargets.length;i++)if(a.hierarchy[c].keys[d].morphTargets[i]===j){l[j]=a.hierarchy[c].keys[d].morphTargetsInfluences[i];break}i===a.hierarchy[c].keys[d].morphTargets.length&&(l[j]=0)}a.hierarchy[c].keys[d].morphTargetsInfluences=l}}for(d=1;d<a.hierarchy[c].keys.length;d++)if(a.hierarchy[c].keys[d].time===a.hierarchy[c].keys[d-1].time){a.hierarchy[c].keys.splice(d,1);d--}for(d=0;d<a.hierarchy[c].keys.length;d++)a.hierarchy[c].keys[d].index=d}d=parseInt(a.length*
a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(c=0;c<a.hierarchy.length;c++)a.JIT.hierarchy.push(Array(d));a.initialized=true}},get:function(a){if(typeof a==="string"){if(b[a])return b[a];console.log("THREE.AnimationHandler.get: Couldn't find animation "+a);return null}},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else d(a,b);return b}},d=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)d(a.children[c],b)};c.LINEAR=0;c.CATMULLROM=
1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=false;this.loop=this.isPaused=true;this.interpolationType=c!==void 0?c:THREE.AnimationHandler.LINEAR;this.points=[];this.target=new THREE.Vector3};
THREE.Animation.prototype.play=function(a,b){if(this.isPlaying===false){this.isPlaying=true;this.loop=a!==void 0?a:true;this.currentTime=b!==void 0?b:0;var c,d=this.hierarchy.length,f;for(c=0;c<d;c++){f=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)f.useQuaternion=true;f.matrixAutoUpdate=true;if(f.animationCache===void 0){f.animationCache={};f.animationCache.prevKey={pos:0,rot:0,scl:0};f.animationCache.nextKey={pos:0,rot:0,scl:0};f.animationCache.originalMatrix=
f instanceof THREE.Bone?f.skinMatrix:f.matrix}var e=f.animationCache.prevKey;f=f.animationCache.nextKey;e.pos=this.data.hierarchy[c].keys[0];e.rot=this.data.hierarchy[c].keys[0];e.scl=this.data.hierarchy[c].keys[0];f.pos=this.getNextKeyWith("pos",c,1);f.rot=this.getNextKeyWith("rot",c,1);f.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=false;THREE.AnimationHandler.addToUpdate(this)};
THREE.Animation.prototype.pause=function(){this.isPaused===true?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=false;THREE.AnimationHandler.removeFromUpdate(this)};
THREE.Animation.prototype.update=function(a){if(this.isPlaying!==false){var b=["pos","rot","scl"],c,d,f,e,g,h,i,j,l;l=this.currentTime=this.currentTime+a*this.timeScale;j=this.currentTime=this.currentTime\%this.data.length;parseInt(Math.min(j*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,m=this.hierarchy.length;n<m;n++){a=this.hierarchy[n];i=a.animationCache;for(var q=0;q<3;q++){c=b[q];g=i.prevKey[c];h=i.nextKey[c];if(h.time<=l){if(j<l)if(this.loop){g=this.data.hierarchy[n].keys[0];
for(h=this.getNextKeyWith(c,n,1);h.time<j;){g=h;h=this.getNextKeyWith(c,n,h.index+1)}}else{this.stop();return}else{do{g=h;h=this.getNextKeyWith(c,n,h.index+1)}while(h.time<j)}i.prevKey[c]=g;i.nextKey[c]=h}a.matrixAutoUpdate=true;a.matrixWorldNeedsUpdate=true;d=(j-g.time)/(h.time-g.time);f=g[c];e=h[c];if(d<0||d>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n);d=d<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=f[0]+
(e[0]-f[0])*d;c.y=f[1]+(e[1]-f[1])*d;c.z=f[2]+(e[2]-f[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=this.getPrevKeyWith("pos",n,g.index-1).pos;this.points[1]=f;this.points[2]=e;this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos;d=d*0.33+0.33;f=this.interpolateCatmullRom(this.points,d);c.x=f[0];c.y=f[1];c.z=f[2];if(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(c);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(c==="rot")THREE.Quaternion.slerp(f,e,a.quaternion,d);else if(c==="scl"){c=a.scale;c.x=f[0]+(e[0]-f[0])*d;c.y=f[1]+(e[1]-f[1])*d;c.z=f[2]+(e[2]-f[2])*d}}}}};
THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],f,e,g,h,i,j;f=(a.length-1)*b;e=Math.floor(f);f=f-e;c[0]=e===0?e:e-1;c[1]=e;c[2]=e>a.length-2?e:e+1;c[3]=e>a.length-3?e:e+2;e=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=f*f;g=f*c;d[0]=this.interpolate(e[0],h[0],i[0],j[0],f,c,g);d[1]=this.interpolate(e[1],h[1],i[1],j[1],f,c,g);d[2]=this.interpolate(e[2],h[2],i[2],j[2],f,c,g);return d};
THREE.Animation.prototype.interpolate=function(a,b,c,d,f,e,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*e+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c\%d.length;c<d.length;c++)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[0]};
THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]};
THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.001;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var f=0;f<c.length;f++){var e=c[f],g=this.getNextKeyWith(e,a,0);g&&g.apply(e)}d.matrixAutoUpdate=
false;this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}};
THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=true;this.loop=a!==void 0?a:true;this.currentTime=b!==void 0?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,f,e;for(c=0;c<d;c++){f=this.hierarchy[c];e=this.data.hierarchy[c];f.useQuaternion=true;if(e.animationCache===void 0){e.animationCache={};e.animationCache.prevKey=null;e.animationCache.nextKey=null;e.animationCache.originalMatrix=f instanceof THREE.Bone?
f.skinMatrix:f.matrix}f=this.data.hierarchy[c].keys;if(f.length){e.animationCache.prevKey=f[0];e.animationCache.nextKey=f[1];this.startTime=Math.min(f[0].time,this.startTime);this.endTime=Math.max(f[f.length-1].time,this.endTime)}}this.update(0)}this.isPaused=false;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
THREE.KeyFrameAnimation.prototype.stop=function(){this.isPaused=this.isPlaying=false;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.data.hierarchy.length;a++){var b=this.hierarchy[a],c=this.data.hierarchy[a];if(c.animationCache!==void 0){var d=c.animationCache.originalMatrix;if(b instanceof THREE.Bone){d.copy(b.skinMatrix);b.skinMatrix=d}else{d.copy(b.matrix);b.matrix=d}delete c.animationCache}}};
THREE.KeyFrameAnimation.prototype.update=function(a){if(this.isPlaying){var b,c,d,f,e=this.data.JIT.hierarchy,g,h,i;h=this.currentTime=this.currentTime+a*this.timeScale;g=this.currentTime=this.currentTime\%this.data.length;if(g<this.startTimeMs)g=this.currentTime=this.startTimeMs+g;f=parseInt(Math.min(g*this.data.fps,this.data.length*this.data.fps),10);if((i=g<h)&&!this.loop){for(var a=0,j=this.hierarchy.length;a<j;a++){var l=this.data.hierarchy[a].keys,e=this.data.hierarchy[a].sids;d=l.length-1;f=
this.hierarchy[a];if(l.length){for(l=0;l<e.length;l++){g=e[l];(h=this.getPrevKeyWith(g,a,d))&&h.apply(g)}this.data.hierarchy[a].node.updateMatrix();f.matrixWorldNeedsUpdate=true}}this.stop()}else if(!(g<this.startTime)){a=0;for(j=this.hierarchy.length;a<j;a++){d=this.hierarchy[a];b=this.data.hierarchy[a];var l=b.keys,n=b.animationCache;if(this.JITCompile&&e[a][f]!==void 0)if(d instanceof THREE.Bone){d.skinMatrix=e[a][f];d.matrixWorldNeedsUpdate=false}else{d.matrix=e[a][f];d.matrixWorldNeedsUpdate=
true}else if(l.length){if(this.JITCompile&&n)d instanceof THREE.Bone?d.skinMatrix=n.originalMatrix:d.matrix=n.originalMatrix;b=n.prevKey;c=n.nextKey;if(b&&c){if(c.time<=h){if(i&&this.loop){b=l[0];for(c=l[1];c.time<g;){b=c;c=l[b.index+1]}}else if(!i)for(var m=l.length-1;c.time<g&&c.index!==m;){b=c;c=l[b.index+1]}n.prevKey=b;n.nextKey=c}c.time>=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}if(this.JITCompile&&e[0][f]===void 0){this.hierarchy[0].updateMatrixWorld(true);
for(a=0;a<this.hierarchy.length;a++)e[a][f]=this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix.clone():this.hierarchy[a].matrix.clone()}}}};THREE.KeyFrameAnimation.prototype.getNextKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=c\%b.length;c<b.length;c++)if(b[c].hasTarget(a))return b[c];return b[0]};
THREE.KeyFrameAnimation.prototype.getPrevKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=c>=0?c:c+b.length;c>=0;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]};
THREE.CubeCamera=function(a,b,c){THREE.Object3D.call(this);var d=new THREE.PerspectiveCamera(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new THREE.Vector3(1,0,0));this.add(d);var f=new THREE.PerspectiveCamera(90,1,a,b);f.up.set(0,-1,0);f.lookAt(new THREE.Vector3(-1,0,0));this.add(f);var e=new THREE.PerspectiveCamera(90,1,a,b);e.up.set(0,0,1);e.lookAt(new THREE.Vector3(0,1,0));this.add(e);var g=new THREE.PerspectiveCamera(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new THREE.Vector3(0,-1,0));this.add(g);var h=new THREE.PerspectiveCamera(90,
1,a,b);h.up.set(0,-1,0);h.lookAt(new THREE.Vector3(0,0,1));this.add(h);var i=new THREE.PerspectiveCamera(90,1,a,b);i.up.set(0,-1,0);i.lookAt(new THREE.Vector3(0,0,-1));this.add(i);this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updateCubeMap=function(a,b){var c=this.renderTarget,m=c.generateMipmaps;c.generateMipmaps=false;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,f,c);c.activeCubeFace=
2;a.render(b,e,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.generateMipmaps=m;c.activeCubeFace=5;a.render(b,i,c)}};THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype);THREE.CombinedCamera=function(a,b,c,d,f,e,g){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,e,g);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,f);this.zoom=1;this.toPerspective()};
THREE.CombinedCamera.prototype=Object.create(THREE.Camera.prototype);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.inPerspectiveMode=true;this.inOrthographicMode=false};
THREE.CombinedCamera.prototype.toOrthographic=function(){var a=this.cameraP.aspect,b=(this.cameraP.near+this.cameraP.far)/2,b=Math.tan(this.fov/2)*b,a=2*b*a/2,b=b/this.zoom,a=a/this.zoom;this.cameraO.left=-a;this.cameraO.right=a;this.cameraO.top=b;this.cameraO.bottom=-b;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPerspectiveMode=false;this.inOrthographicMode=true};
THREE.CombinedCamera.prototype.setSize=function(a,b){this.cameraP.aspect=a/b;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2};THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.updateProjectionMatrix=function(){if(this.inPerspectiveMode)this.toPerspective();else{this.toPerspective();this.toOrthographic()}};
THREE.CombinedCamera.prototype.setLens=function(a,b){b===void 0&&(b=24);var c=2*Math.atan(b/(a*2))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPerspectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};
THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=false};
THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=false};
THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=b!==void 0?b:document;this.movementSpeed=1;this.lookSpeed=0.005;this.lookVertical=true;this.autoForward=false;this.activeLook=true;this.heightSpeed=false;this.heightCoef=1;this.heightMin=0;this.heightMax=1;this.constrainVertical=false;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=false;this.viewHalfY=this.viewHalfX=0;this.domElement!==document&&this.domElement.setAttribute("tabindex",-1);this.handleResize=function(){if(this.domElement===document){this.viewHalfX=window.innerWidth/2;this.viewHalfY=window.innerHeight/2}else{this.viewHalfX=this.domElement.offsetWidth/2;this.viewHalfY=this.domElement.offsetHeight/2}};this.onMouseDown=function(a){this.domElement!==
document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=true;break;case 2:this.moveBackward=true}this.mouseDragOn=true};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=false;break;case 2:this.moveBackward=false}this.mouseDragOn=false};this.onMouseMove=function(a){if(this.domElement===document){this.mouseX=a.pageX-this.viewHalfX;this.mouseY=a.pageY-
this.viewHalfY}else{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=true;break;case 37:case 65:this.moveLeft=true;break;case 40:case 83:this.moveBackward=true;break;case 39:case 68:this.moveRight=true;break;case 82:this.moveUp=true;break;case 70:this.moveDown=true;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=
false;break;case 37:case 65:this.moveLeft=false;break;case 40:case 83:this.moveBackward=false;break;case 39:case 68:this.moveRight=false;break;case 82:this.moveUp=false;break;case 70:this.moveDown=false}};this.update=function(a){var b=0;if(!this.freeze){if(this.heightSpeed){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);a=a*this.lookSpeed;this.activeLook||(a=0);this.lon=this.lon+this.mouseX*a;if(this.lookVertical)this.lat=this.lat-this.mouseY*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;var b=
this.target,c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);b=1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon=this.lon+this.mouseX*a;if(this.lookVertical)this.lat=this.lat-this.mouseY*a*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;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,
0,Math.PI,this.verticalMin,this.verticalMax);b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(b)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),false);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),false);this.domElement.addEventListener("mouseup",
c(this,this.onMouseUp),false);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),false);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),false);this.handleResize()};
THREE.PathControls=function(a,b){function c(a){return(a=a*2)<1?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function f(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),r=g.length,t=0;f=r-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<r-1;f++){t=d*h.chunks[f]/h.total;b.keys[f]={time:t,pos:g[f]}}e.hierarchy[0]=b;THREE.AnimationHandler.add(e);
return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,false)}function e(a,b){var c,d,e=new THREE.Geometry;for(c=0;c<a.points.length*b;c++){d=c/(a.points.length*b);d=a.getPoint(d);e.vertices[c]=new THREE.Vector3(d.x,d.y,d.z)}return e}this.object=a;this.domElement=b!==void 0?b:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=true;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;
this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookHorizontal=this.lookVertical=true;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;var g=Math.PI*2,h=Math.PI/180;this.viewHalfY=this.viewHalfX=0;this.domElement!==document&&this.domElement.setAttribute("tabindex",-1);this.handleResize=function(){if(this.domElement===
document){this.viewHalfX=window.innerWidth/2;this.viewHalfY=window.innerHeight/2}else{this.viewHalfX=this.domElement.offsetWidth/2;this.viewHalfY=this.domElement.offsetHeight/2}};this.update=function(a){var b;if(this.lookHorizontal)this.lon=this.lon+this.mouseX*this.lookSpeed*a;if(this.lookVertical)this.lat=this.lat-this.mouseY*this.lookSpeed*a;this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;a=this.phi\%g;this.phi=
a>=0?a:a+g;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange;b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-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){if(this.domElement===document){this.mouseX=a.pageX-this.viewHalfX;this.mouseY=a.pageY-this.viewHalfY}else{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),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(g,b);a.position.set(0,10,0);this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else{this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.target);this.animationParent.add(this.object)}if(this.createDebugPath){var a=
this.debugPath,b=this.spline,g=e(b,10),c=e(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),g=new THREE.Line(g,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));g.scale.set(1,1,1);a.add(g);c.scale.set(1,1,1);a.add(c);for(var g=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),q=0;q<b.points.length;q++){c=new THREE.Mesh(g,h);c.position.copy(b.points[q]);a.add(c)}}this.domElement.addEventListener("mousemove",d(this,
this.onMouseMove),false)};this.handleResize()};THREE.PathControlsIdCounter=0;
THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=b!==void 0?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=false;this.object.useQuaternion=true;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=
new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=
1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=
0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
true;break;case 2:this.object.moveBackward=true}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),c=b.size[0]/2,g=b.size[1]/2;this.moveState.yawLeft=-(a.pageX-b.offset[0]-c)/c;this.moveState.pitchDown=(a.pageY-b.offset[1]-g)/g;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=
false;break;case 2:this.moveBackward=false}this.updateRotationVector()};this.update=function(a){var b=a*this.movementSpeed,a=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=true};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=
-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),false);this.domElement.addEventListener("mousedown",c(this,this.mousedown),false);this.domElement.addEventListener("mouseup",
c(this,this.mouseup),false);this.domElement.addEventListener("keydown",c(this,this.keydown),false);this.domElement.addEventListener("keyup",c(this,this.keyup),false);this.updateMovementVector();this.updateRotationVector()};
THREE.RollControls=function(a,b){this.object=a;this.domElement=b!==void 0?b:document;this.mouseLook=true;this.autoForward=false;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=false;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,d=new THREE.Vector3,f=new THREE.Vector3,e=new THREE.Matrix4,g=false,h=1,i=0,j=0,l=0,n=0,m=0,q=0,p=0;this.handleResize=function(){q=window.innerWidth/2;p=window.innerHeight/2};this.update=
function(a){if(this.mouseLook){var b=a*this.lookSpeed;this.rotateHorizontally(b*n);this.rotateVertically(b*m)}b=a*this.movementSpeed;this.object.translateZ(-b*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*j);this.object.translateY(b*l);if(g)this.roll=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.y<this.constrainVertical[0]){this.forward.y=this.constrainVertical[0];this.forward.normalize()}f.copy(this.forward);
d.set(0,1,0);c.cross(d,f).normalize();d.cross(f,c).normalize();this.object.matrix.elements[0]=c.x;this.object.matrix.elements[4]=d.x;this.object.matrix.elements[8]=f.x;this.object.matrix.elements[1]=c.y;this.object.matrix.elements[5]=d.y;this.object.matrix.elements[9]=f.y;this.object.matrix.elements[2]=c.z;this.object.matrix.elements[6]=d.z;this.object.matrix.elements[10]=f.z;e.identity();e.elements[0]=Math.cos(this.roll);e.elements[4]=-Math.sin(this.roll);e.elements[1]=Math.sin(this.roll);e.elements[5]=
Math.cos(this.roll);this.object.matrix.multiplySelf(e);this.object.matrixWorldNeedsUpdate=true;this.object.matrix.elements[12]=this.object.position.x;this.object.matrix.elements[13]=this.object.position.y;this.object.matrix.elements[14]=this.object.position.z};this.translateX=function(a){this.object.position.x=this.object.position.x+this.object.matrix.elements[0]*a;this.object.position.y=this.object.position.y+this.object.matrix.elements[1]*a;this.object.position.z=this.object.position.z+this.object.matrix.elements[2]*
a};this.translateY=function(a){this.object.position.x=this.object.position.x+this.object.matrix.elements[4]*a;this.object.position.y=this.object.position.y+this.object.matrix.elements[5]*a;this.object.position.z=this.object.position.z+this.object.matrix.elements[6]*a};this.translateZ=function(a){this.object.position.x=this.object.position.x-this.object.matrix.elements[8]*a;this.object.position.y=this.object.position.y-this.object.matrix.elements[9]*a;this.object.position.z=this.object.position.z-
this.object.matrix.elements[10]*a};this.rotateHorizontally=function(a){c.set(this.object.matrix.elements[0],this.object.matrix.elements[1],this.object.matrix.elements[2]);c.multiplyScalar(a);this.forward.subSelf(c);this.forward.normalize()};this.rotateVertically=function(a){d.set(this.object.matrix.elements[4],this.object.matrix.elements[5],this.object.matrix.elements[6]);d.multiplyScalar(a);this.forward.addSelf(d);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},
false);this.domElement.addEventListener("mousemove",function(a){n=(a.clientX-q)/window.innerWidth;m=(a.clientY-p)/window.innerHeight},false);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=1;break;case 2:i=-1}},false);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=0;break;case 2:i=0}},false);this.domElement.addEventListener("keydown",function(a){switch(a.keyCode){case 38:case 87:i=
1;break;case 37:case 65:j=-1;break;case 40:case 83:i=-1;break;case 39:case 68:j=1;break;case 81:g=true;h=1;break;case 69:g=true;h=-1;break;case 82:l=1;break;case 70:l=-1}},false);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:i=0;break;case 37:case 65:j=0;break;case 40:case 83:i=0;break;case 39:case 68:j=0;break;case 81:g=false;break;case 69:g=false;break;case 82:l=0;break;case 70:l=0}},false);this.handleResize()};
THREE.TrackballControls=function(a,b){function c(a){if(d.enabled){a.preventDefault();a.stopPropagation();var b=0;a.wheelDelta?b=a.wheelDelta/40:a.detail&&(b=-a.detail/3);l.y=l.y+1/b*0.05}}THREE.EventTarget.call(this);var d=this;this.object=a;this.domElement=b!==void 0?b:document;this.enabled=true;this.screen={width:0,height:0,offsetLeft:0,offsetTop:0};this.radius=(this.screen.width+this.screen.height)/4;this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=0.3;this.staticMoving=this.noPan=this.noZoom=
this.noRotate=false;this.dynamicDampingFactor=0.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];this.target=new THREE.Vector3;var f=new THREE.Vector3,e=false,g=-1,h=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,l=new THREE.Vector2,n=new THREE.Vector2,m=new THREE.Vector2,q=new THREE.Vector2,p={type:"change"};this.handleResize=function(){this.screen.width=window.innerWidth;this.screen.height=window.innerHeight;this.screen.offsetLeft=0;this.screen.offsetTop=0;this.radius=
(this.screen.width+this.screen.height)/4};this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,b){return new THREE.Vector2((a-d.screen.offsetLeft)/d.radius*0.5,(b-d.screen.offsetTop)/d.radius*0.5)};this.getMouseProjectionOnBall=function(a,b){var c=new THREE.Vector3((a-d.screen.width*0.5-d.screen.offsetLeft)/d.radius,(d.screen.height*0.5+d.screen.offsetTop-b)/d.radius,0),e=c.length();e>1?c.normalize():c.z=Math.sqrt(1-e*e);h.copy(d.object.position).subSelf(d.target);
e=d.object.up.clone().setLength(c.y);e.addSelf(d.object.up.clone().crossSelf(h).setLength(c.x));e.addSelf(h.setLength(c.z));return e};this.rotateCamera=function(){var a=Math.acos(i.dot(j)/i.length()/j.length());if(a){var b=(new THREE.Vector3).cross(i,j).normalize(),c=new THREE.Quaternion,a=a*d.rotateSpeed;c.setFromAxisAngle(b,-a);c.multiplyVector3(h);c.multiplyVector3(d.object.up);c.multiplyVector3(j);if(d.staticMoving)i.copy(j);else{c.setFromAxisAngle(b,a*(d.dynamicDampingFactor-1));c.multiplyVector3(i)}}};
this.zoomCamera=function(){var a=1+(n.y-l.y)*d.zoomSpeed;if(a!==1&&a>0){h.multiplyScalar(a);d.staticMoving?l.copy(n):l.y=l.y+(n.y-l.y)*this.dynamicDampingFactor}};this.panCamera=function(){var a=q.clone().subSelf(m);if(a.lengthSq()){a.multiplyScalar(h.length()*d.panSpeed);var b=h.clone().crossSelf(d.object.up).setLength(a.x);b.addSelf(d.object.up.clone().setLength(a.y));d.object.position.addSelf(b);d.target.addSelf(b);d.staticMoving?m=q:m.addSelf(a.sub(q,m).multiplyScalar(d.dynamicDampingFactor))}};
this.checkDistances=function(){if(!d.noZoom||!d.noPan){d.object.position.lengthSq()>d.maxDistance*d.maxDistance&&d.object.position.setLength(d.maxDistance);h.lengthSq()<d.minDistance*d.minDistance&&d.object.position.add(d.target,h.setLength(d.minDistance))}};this.update=function(){h.copy(d.object.position).subSelf(d.target);d.noRotate||d.rotateCamera();d.noZoom||d.zoomCamera();d.noPan||d.panCamera();d.object.position.add(d.target,h);d.checkDistances();d.object.lookAt(d.target);if(f.distanceToSquared(d.object.position)>
0){d.dispatchEvent(p);f.copy(d.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousemove",function(a){if(d.enabled){if(e){i=j=d.getMouseProjectionOnBall(a.clientX,a.clientY);l=n=d.getMouseOnScreen(a.clientX,a.clientY);m=q=d.getMouseOnScreen(a.clientX,a.clientY);e=false}g!==-1&&(g===0&&!d.noRotate?j=d.getMouseProjectionOnBall(a.clientX,a.clientY):g===1&&!d.noZoom?n=d.getMouseOnScreen(a.clientX,a.clientY):g===
2&&!d.noPan&&(q=d.getMouseOnScreen(a.clientX,a.clientY)))}},false);this.domElement.addEventListener("mousedown",function(a){if(d.enabled){a.preventDefault();a.stopPropagation();if(g===-1){g=a.button;g===0&&!d.noRotate?i=j=d.getMouseProjectionOnBall(a.clientX,a.clientY):g===1&&!d.noZoom?l=n=d.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(m=q=d.getMouseOnScreen(a.clientX,a.clientY))}}},false);this.domElement.addEventListener("mouseup",function(a){if(d.enabled){a.preventDefault();a.stopPropagation();
g=-1}},false);this.domElement.addEventListener("DOMMouseScroll",c,false);this.domElement.addEventListener("mousewheel",c,false);window.addEventListener("keydown",function(a){if(d.enabled&&g===-1){a.keyCode===d.keys[0]&&!d.noRotate?g=0:a.keyCode===d.keys[1]&&!d.noZoom?g=1:a.keyCode===d.keys[2]&&!d.noPan&&(g=2);g!==-1&&(e=true)}},false);window.addEventListener("keyup",function(){d.enabled&&g!==-1&&(g=-1)},false);this.handleResize()};
THREE.OrbitControls=function(a,b){function c(){return 2*Math.PI/60/60*e.autoRotateSpeed}function d(a){a.preventDefault();if(u===t.ROTATE){i.set(a.clientX,a.clientY);j.sub(i,h);e.rotateLeft(2*Math.PI*j.x/g*e.userRotateSpeed);e.rotateUp(2*Math.PI*j.y/g*e.userRotateSpeed);h.copy(i)}else if(u===t.ZOOM){n.set(a.clientX,a.clientY);m.sub(n,l);m.y>0?e.zoomIn():e.zoomOut();l.copy(n)}}function f(){if(e.userRotate){document.removeEventListener("mousemove",d,false);document.removeEventListener("mouseup",f,false);
u=t.NONE}}THREE.EventTarget.call(this);this.object=a;this.domElement=b!==void 0?b:document;this.center=new THREE.Vector3;this.userZoom=true;this.userZoomSpeed=1;this.userRotate=true;this.userRotateSpeed=1;this.autoRotate=false;this.autoRotateSpeed=2;var e=this,g=1800,h=new THREE.Vector2,i=new THREE.Vector2,j=new THREE.Vector2,l=new THREE.Vector2,n=new THREE.Vector2,m=new THREE.Vector2,q=0,p=0,o=1,r=new THREE.Vector3,t={NONE:-1,ROTATE:0,ZOOM:1},u=t.NONE,w={type:"change"};this.rotateLeft=function(a){a===
void 0&&(a=c());p=p-a};this.rotateRight=function(a){a===void 0&&(a=c());p=p+a};this.rotateUp=function(a){a===void 0&&(a=c());q=q-a};this.rotateDown=function(a){a===void 0&&(a=c());q=q+a};this.zoomIn=function(a){a===void 0&&(a=Math.pow(0.95,e.userZoomSpeed));o=o/a};this.zoomOut=function(a){a===void 0&&(a=Math.pow(0.95,e.userZoomSpeed));o=o*a};this.update=function(){var a=this.object.position,b=a.clone().subSelf(this.center),d=Math.atan2(b.x,b.z),e=Math.atan2(Math.sqrt(b.x*b.x+b.z*b.z),b.y);this.autoRotate&&
this.rotateLeft(c());var d=d+p,e=e+q,e=Math.max(1E-6,Math.min(Math.PI-1E-6,e)),f=b.length();b.x=f*Math.sin(e)*Math.sin(d);b.y=f*Math.cos(e);b.z=f*Math.sin(e)*Math.cos(d);b.multiplyScalar(o);a.copy(this.center).addSelf(b);this.object.lookAt(this.center);q=p=0;o=1;if(r.distanceTo(this.object.position)>0){this.dispatchEvent(w);r.copy(this.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousedown",function(a){if(e.userRotate){a.preventDefault();
if(a.button===0||a.button===2){u=t.ROTATE;h.set(a.clientX,a.clientY)}else if(a.button===1){u=t.ZOOM;l.set(a.clientX,a.clientY)}document.addEventListener("mousemove",d,false);document.addEventListener("mouseup",f,false)}},false);this.domElement.addEventListener("mousewheel",function(a){e.userZoom&&(a.wheelDelta>0?e.zoomOut():e.zoomIn())},false)};
THREE.CircleGeometry=function(a,b,c,d){THREE.Geometry.call(this);var a=a||50,c=c!==void 0?c:0,d=d!==void 0?d:Math.PI*2,b=b!==void 0?Math.max(3,b):8,f,e=[];f=new THREE.Vector3;var g=new THREE.UV(0.5,0.5);this.vertices.push(f);e.push(g);for(f=0;f<=b;f++){var h=new THREE.Vector3;h.x=a*Math.cos(c+f/b*d);h.y=a*Math.sin(c+f/b*d);this.vertices.push(h);e.push(new THREE.UV((h.x/a+1)/2,-(h.y/a+1)/2+1))}c=new THREE.Vector3(0,0,-1);for(f=1;f<=b;f++){this.faces.push(new THREE.Face3(f,f+1,0,[c,c,c]));this.faceVertexUvs[0].push([e[f],
e[f+1],g])}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.CubeGeometry=function(a,b,c,d,f,e,g,h){function i(a,b,c,g,h,i,l,m){var n,o=d||1,p=f||1,q=h/2,r=i/2,t=j.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){n="y";p=e||1}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){n="x";o=e||1}var u=o+1,w=p+1,Y=h/o,-r)*g;ba[n]=l;j.vertices.push(ba)}for(h=0;h<p;h++)for(i=0;i<o;i++){a=new THREE.Face4(i+
u*h+t,i+u*(h+1)+t,i+1+u*(h+1)+t,i+1+u*h+t);a.normal.copy(L);a.vertexNormals.push(L.clone(),L.clone(),L.clone(),L.clone());a.materialIndex=m;j.faces.push(a);j.faceVertexUvs[0].push([new THREE.UV(i/o,1-h/p),new THREE.UV(i/o,1-(h+1)/p),new THREE.UV((i+1)/o,1-(h+1)/p),new THREE.UV((i+1)/o,1-h/p)])}}THREE.Geometry.call(this);var j=this,l=a/2,n=b/2,m=c/2,q,p,o,r,t,u;if(g!==void 0){if(g instanceof Array)this.materials=g;else{this.materials=[];for(q=0;q<6;q++)this.materials.push(g)}q=0;r=1;p=2;t=3;o=4;u=
5}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(h!=void 0)for(var w in h)this.sides[w]!==void 0&&(this.sides[w]=h[w]);this.sides.px&&i("z","y",-1,-1,c,b,l,q);this.sides.nx&&i("z","y",1,-1,c,b,-l,r);this.sides.py&&i("x","z",1,1,a,c,n,p);this.sides.ny&&i("x","z",1,-1,a,c,-n,t);this.sides.pz&&i("x","y",1,-1,a,b,m,o);this.sides.nz&&i("x","y",-1,-1,a,b,-m,u);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.CylinderGeometry=function(a,b,c,d,f,e){THREE.Geometry.call(this);var a=a!==void 0?a:20,b=b!==void 0?b:20,c=c!==void 0?c:100,g=c/2,d=d||8,f=f||1,h,i,j=[],l=[];for(i=0;i<=f;i++){var n=[],m=[],q=i/f,p=q*(b-a)+a;for(h=0;h<=d;h++){var o=h/d,r=new THREE.Vector3;r.x=p*Math.sin(o*Math.PI*2);r.y=-q*c+g;r.z=p*Math.cos(o*Math.PI*2);this.vertices.push(r);n.push(this.vertices.length-1);m.push(new THREE.UV(o,1-q))}j.push(n);l.push(m)}c=(b-a)/c;for(h=0;h<d;h++){if(a!==0){n=this.vertices[j[0][h]].clone();m=
this.vertices[j[0][h+1]].clone()}else{n=this.vertices[j[1][h]].clone();m=this.vertices[j[1][h+1]].clone()}n.setY(Math.sqrt(n.x*n.x+n.z*n.z)*c).normalize();m.setY(Math.sqrt(m.x*m.x+m.z*m.z)*c).normalize();for(i=0;i<f;i++){var q=j[i][h],p=j[i+1][h],o=j[i+1][h+1],r=j[i][h+1],t=n.clone(),u=n.clone(),w=m.clone(),s=m.clone(),B=l[i][h].clone(),v=l[i+1][h].clone(),A=l[i+1][h+1].clone(),E=l[i][h+1].clone();this.faces.push(new THREE.Face4(q,p,o,r,[t,u,w,s]));this.faceVertexUvs[0].push([B,v,A,E])}}if(!e&&a>
0){this.vertices.push(new THREE.Vector3(0,g,0));for(h=0;h<d;h++){q=j[0][h];p=j[0][h+1];o=this.vertices.length-1;t=new THREE.Vector3(0,1,0);u=new THREE.Vector3(0,1,0);w=new THREE.Vector3(0,1,0);B=l[0][h].clone();v=l[0][h+1].clone();A=new THREE.UV(v.u,0);this.faces.push(new THREE.Face3(q,p,o,[t,u,w]));this.faceVertexUvs[0].push([B,v,A])}}if(!e&&b>0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;h<d;h++){q=j[i][h+1];p=j[i][h];o=this.vertices.length-1;t=new THREE.Vector3(0,-1,0);u=new THREE.Vector3(0,
-1,0);w=new THREE.Vector3(0,-1,0);B=l[i][h+1].clone();v=l[i][h].clone();A=new THREE.UV(v.u,1);this.faces.push(new THREE.Face3(q,p,o,[t,u,w]));this.faceVertexUvs[0].push([B,v,A])}}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.ExtrudeGeometry=function(a,b){if(typeof a!=="undefined"){THREE.Geometry.call(this);a=a instanceof Array?a:[a];this.shapebb=a[a.length-1].getBoundingBox();this.addShapeList(a,b);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};
THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);i.copy(a).addSelf(g);if(h.equals(i))return g.clone();
h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);if(f===0){console.log("Either infinite or no solutions!");g===0?console.log("Its finite solutions."):console.log("Too bad, no solutions.")}g=g/f;if(g<0){b=Math.atan2(b.y-a.y,b.x-a.x);a=Math.atan2(c.y-a.y,c.x-a.x);b>a&&(a=a+Math.PI*2);c=(b+a)/2;a=-Math.cos(c);c=-Math.sin(c);return new THREE.Vector2(a,c)}return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function f(c,d){var e,f;for(L=c.length;--L>=0;){e=L;f=L-1;f<0&&(f=
c.length-1);for(var g=0,h=m+l*2,g=0;g<h;g++){var i=V*g,j=V*(g+1),n=d+e+i,i=d+f+i,o=d+f+j,j=d+e+j,p=c,q=g,r=h,s=e,v=f,n=n+D,i=i+D,o=o+D,j=j+D;M.faces.push(new THREE.Face4(n,i,o,j,null,null,t));n=u.generateSideWallUV(M,a,p,b,n,i,o,j,q,r,s,v);M.faceVertexUvs[0].push(n)}}}function e(a,b,c){M.vertices.push(new THREE.Vector3(a,b,c))}function g(c,d,e,f){c=c+D;d=d+D;e=e+D;M.faces.push(new THREE.Face3(c,d,e,null,null,r));c=f?u.generateBottomUV(M,a,b,c,d,e):u.generateTopUV(M,a,b,c,d,e);M.faceVertexUvs[0].push(c)}
var h=b.amount!==void 0?b.amount:100,i=b.bevelThickness!==void 0?b.bevelThickness:6,j=b.bevelSize!==void 0?b.bevelSize:i-2,l=b.bevelSegments!==void 0?b.bevelSegments:3,n=b.bevelEnabled!==void 0?b.bevelEnabled:true,m=b.steps!==void 0?b.steps:1,q=b.extrudePath,p,o=false,r=b.material,t=b.extrudeMaterial,u=b.UVGenerator!==void 0?b.UVGenerator:THREE.ExtrudeGeometry.WorldUVGenerator,w,s,B,v;if(q){p=q.getSpacedPoints(m);o=true;n=false;w=b.frames!==void 0?b.frames:new THREE.TubeGeometry.FrenetFrames(q,m,
false);s=new THREE.Vector3;B=new THREE.Vector3;v=new THREE.Vector3}if(!n)j=i=l=0;var A,E,z,M=this,D=this.vertices.length,q=a.extractPoints(),G=q.shape,q=q.holes,H=!THREE.Shape.Utils.isClockWise(G);if(H){G=G.reverse();E=0;for(z=q.length;E<z;E++){A=q[E];THREE.Shape.Utils.isClockWise(A)&&(q[E]=A.reverse())}H=false}var O=THREE.Shape.Utils.triangulateShape(G,q),H=G;E=0;for(z=q.length;E<z;E++){A=q[E];G=G.concat(A)}var F,J,I,K,V=G.length,Y=O.length,[L]=d(H[L],H[F],H[J])}var Q=[],fa,ta=[L],J);e(K.x,K.y,-I)}E=0;for(z=q.length;E<z;E++){A=q[E];fa=Q[E];L=0;for(ba=A.length;L<ba;L++){K=c(A[L],fa[L],J);e(K.x,K.y,-I)}}}J=j;for(L=0;L<V;L++){K=n?c(G[L],
ta[L],J):G[L];if(o){B.copy(w.normals[0]).multiplyScalar(K.x);s.copy(w.binormals[0]).multiplyScalar(K.y);v.copy(p[0]).addSelf(B).addSelf(s);e(v.x,v.y,v.z)}else e(K.x,K.y,0)}for(A=1;A<=m;A++)for(L=0;L<V;L++){K=n?c(G[L],ta[L],J):G[L];if(o){B.copy(w.normals[A]).multiplyScalar(K.x);s.copy(w.binormals[A]).multiplyScalar(K.y);v.copy(p[A]).addSelf(B).addSelf(s);e(v.x,v.y,v.z)}else e(K.x,K.y,h/m*A)}for(F=l-1;F>=0;F--){A=F/l;I=i*(1-A);J=j*Math.sin(A*Math.PI/2);L=0;for(ba=H.length;L<ba;L++){K=c(H[L],
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.