h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);0===f&&(console.log("Either infinite or no solutions!"),0===g?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;return0>g?(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+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),newTHREE.Vector2(a,c)):d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}functionf(a){for(y=a.length;0<=--y;){C=y;L=y-1;0>L&&(L=a.length-1);for(varb=
h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);0===f&&(console.log("Either infinite or no solutions!"),0===g?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;return0>g?(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+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),newTHREE.Vector2(a,c)):d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}functionf(a){for(y=a.length;0<=--y;){C=y;K=y-1;0>K&&(K=a.length-1);for(varb=
(function(a){varb=function(a){for(varb=a.length,f=0,g=b-1,e=0;e<b;g=e++)f+=a[g].x*a[e].y-a[e].x*a[g].y;return0.5*f};a.Triangulate=function(a,d){varf=a.length;if(3>f)returnnull;varg=[],e=[],h=[],i,k,j;if(0<b(a))for(k=0;k<f;k++)e[k]=k;elsefor(k=0;k<f;k++)e[k]=f-1-k;varm=2*f;for(k=f-1;2<f;){if(0>=m--){console.log("Warning, unable to triangulate polygon!");break}i=k;f<=i&&(i=0);k=i+1;f<=k&&(k=0);j=k+1;f<=j&&(j=0);varp;a:{p=a;varn=i,l=k,o=j,q=f,r=e,s=void0,t=void0,v=void0,u=void0,w=void0,
n=x(a,D+20+4);l=x(a,D+20+8);b=x(a,D+20+12);o=x(a,D+20+16);q=x(a,D+20+20);r=x(a,D+20+24);s=x(a,D+20+28);t=x(a,D+20+32);v=x(a,D+20+36);u=x(a,D+20+40);"Three.js 003"!==c&&console.warn("DEPRECATED: binary model seems to be using old format");D+=f;c=3*i+m;C=4*i+m;f=b*c;K=o*(c+3*k);i=q*(c+3*j);m=r*(c+3*k+3*j);c=s*C;k=t*(C+4*k);j=v*(C+4*j);D+=function(b){varb=newFloat32Array(a,b,3*p),c,d,e,f;for(c=0;c<p;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],G.vertices.push(newTHREE.Vertex(newTHREE.Vector3(d,e,f)));return3*
n=x(a,D+20+4);l=x(a,D+20+8);b=x(a,D+20+12);o=x(a,D+20+16);q=x(a,D+20+20);r=x(a,D+20+24);s=x(a,D+20+28);t=x(a,D+20+32);v=x(a,D+20+36);u=x(a,D+20+40);"Three.js 003"!==c&&console.warn("DEPRECATED: binary model seems to be using old format");D+=f;c=3*i+m;C=4*i+m;f=b*c;L=o*(c+3*k);i=q*(c+3*j);m=r*(c+3*k+3*j);c=s*C;k=t*(C+4*k);j=v*(C+4*j);D+=function(b){varb=newFloat32Array(a,b,3*p),c,d,e,f;for(c=0;c<p;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],G.vertices.push(newTHREE.Vertex(newTHREE.Vector3(d,e,f)));return3*
g;b++)d.hierarchy.push({keys:[],sids:[]});returnd}functiond(a,b,c,e){a.world=a.world||newTHREE.Matrix4;a.world.copy(a.matrix);if(a.channels&&a.channels.length){varf=a.channels[0].sampler.output[c];finstanceofTHREE.Matrix4&&a.world.copy(f)}e&&a.world.multiply(e,a.world);b.push(a);for(e=0;e<a.nodes.length;e++)d(a.nodes[e],b,c,a.world)}functionf(a,b,c){vare,f=T[b.url];if(!f||!f.skin)console.log("ColladaLoader: Could not find skin controller.");elseif(!b.skeleton||!b.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");
k=f.skin;for(m=0;m<j.length;m++)if(l=j[m],o=-1,"JOINT"==l.type){for(varn=0;n<k.joints.length;n++)if(l.sid==k.joints[n]){o=n;break}if(0<=o){n=k.invBindMatrices[o];l.invBindMatrix=n;l.skinningMatrix=newTHREE.Matrix4;l.skinningMatrix.multiply(l.world,n);l.weights=[];for(n=0;n<k.weights.length;n++)for(varp=0;p<k.weights[n].length;p++){varr=k.weights[n][p];r.joint==o&&l.weights.push(r)}}elsethrow"ColladaLoader: Could not find joint '"+l.sid+"'.";}for(j=0;j<h.length;j++)if("JOINT"==h[j].type)for(k=
i.faces[h],l.materialIndex=k[l.daeMaterial]}if(void0!==c)f(i,c),j.morphTargets=!0,j=newTHREE.SkinnedMesh(i,j),j.skeleton=c.skeleton,j.skinController=T[c.url],j.skinInstanceController=c,j.name="skin_"+aa.length,aa.push(j);elseif(void0!==d){h=i;k=dinstanceofn?T[d.url]:d;if(!k||!k.morph)console.log("could not find morph controller!");else{k=k.morph;for(l=0;l<k.targets.length;l++)if(m=U[k.targets[l]],m.mesh&&m.mesh.primitives&&m.mesh.primitives.length)m=m.mesh.primitives[0].geometry,m.vertices.length===
"X";break;case"YtoZ":case"ZtoX":case"ZtoY":g="Y"}}varh=b.sampler,i=h.input,j=this.getTransformBySid(b.sid);if(j){-1===a.indexOf(f)&&a.push(f);b=0;for(vark=i.length;b<k;b++){varl=i[b],r=h.getData(j.type,b),q;q=null;for(vars=0,t=d.length;s<t&&null==q;s++){varu=d[s];if(u.time===l)q=u;elseif(u.time>l)break}if(!q){q=newy(l);s=-1;t=0;for(u=d.length;t<u&&-1==s;t++)d[t].time>=l&&(s=t);l=s;d.splice(-1==l?d.length:l,0,q)}q.addTarget(f,j,g,r)}}elseconsole.log('Could not find transform "'+b.sid+'" in node '+
this.data[1],this.data[2]);break;case"scale":O(this.data,1);this.obj=newTHREE.Vector3(this.data[0],this.data[1],this.data[2]);break;default:console.log("Can not convert Transform of type "+this.type)}};p.prototype.apply=function(a){switch(this.type){case"matrix":a.multiplySelf(this.obj);break;case"translate":a.translate(this.obj);break;case"rotate":a.rotateByAxis(this.obj,this.angle);break;case"scale":a.scale(this.obj)}};p.prototype.update=function(a,b){switch(this.type){case"matrix":console.log("Currently not handling matrix transform updates");
a.childNodes.length;b++){varc=a.childNodes[b];switch(c.nodeName){case"mesh":this.mesh=(newr(this)).parse(c)}}returnthis};r.prototype.parse=function(a){this.primitives=[];varb;for(b=0;b<a.childNodes.length;b++){varc=a.childNodes[b];switch(c.nodeName){case"source":vard=c.getAttribute("id");void0==Y[d]&&(Y[d]=(newz(d)).parse(c));break;case"vertices":this.vertices=(newu).parse(c);break;case"triangles":this.primitives.push((newt).parse(c));break;case"polygons":console.warn("polygon holes not yet supported!");
e.daeMaterial=a.material;b.faces.push(e);for(e=0;e<o.length;e++)q=r[o[e]],q=4<m?[q[0],q[n+1],q[n+2]]:4===m?[q[0],q[1],q[2],q[3]]:[q[0],q[1],q[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(q)}}elseconsole.log("dropped face with vcount "+m+" for geometry with id: "+b.id);c+=g.length*m}};s.prototype=newt;s.prototype.constructor=s;t.prototype.setVertices=function(a){for(varb=0;b<this.inputs.length;b++)if(this.inputs[b].source==a.id)this.inputs[b].source=a.input.POSITION.source};
16){varc=this.data.slice(b,b+16),c=ba(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}returna};x.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(varb=0;b<a.childNodes.length;b++)if("instance_effect"==a.childNodes[b].nodeName){this.instance_effect=(newB).parse(a.childNodes[b]);break}returnthis};A.prototype.isColor=function(){returnnull==this.texture};A.prototype.isTexture=function(){returnnull!=
this.targets[c],e=a.getTarget(d.sid);if(e){varf=(b-this.time)/(a.time-this.time),g=e.data,h=d.data;if(0>f||1<f)console.log("Key.interpolate: Warning! Scale out of bounds:"+f),f=0>f?0:1;if(h.length)for(vare=[],i=0;i<h.length;++i)e[i]=h[i]+(g[i]-h[i])*f;elsee=h+(g-h)*f}elsee=d.data;d.transform.update(e,d.member)}};return{load:function(b,c,d){vare=0;if(document.implementation&&document.implementation.createDocument){varf=newXMLHttpRequest;f.overrideMimeType&&f.overrideMimeType("text/xml");f.onreadystatechange=
function(){if(4==f.readyState){if(0==f.status||200==f.status)f.responseXML?(ia=c,a(f.responseXML,void0,b)):console.error("ColladaLoader: Empty or non-existing file ("+b+")")}else3==f.readyState&&d&&(0==e&&(e=f.getResponseHeader("Content-Length")),d({total:e,loaded:f.responseText.length}))};f.open("GET",b,!0);f.send(null)}elsealert("Don't know how to parse XML!")},parse:a,setPreferredShading:function(a){ka=a},applySkin:f,geometries:U,options:Q}};
sids:[]}]};e=0;for(f=a.children.length;e<f;e++)for(varb=0,g=c(a.children[e]).hierarchy.length;b<g;b++)d.hierarchy.push({keys:[],sids:[]});returnd}functiond(a,b,c,e){a.world=a.world||newTHREE.Matrix4;a.world.copy(a.matrix);if(a.channels&&a.channels.length){varf=a.channels[0].sampler.output[c];finstanceofTHREE.Matrix4&&a.world.copy(f)}e&&a.world.multiply(e,a.world);b.push(a);for(e=0;e<a.nodes.length;e++)d(a.nodes[e],b,c,a.world)}functionf(a,b,c){vare,f=U[b.url];if(!f||!f.skin)console.log("ColladaLoader: Could not find skin controller.");
elseif(!b.skeleton||!b.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{varc=1E6,g=-c,h=0;for(einX)for(vari=X[e],j=0;j<i.sampler.length;j++){vark=i.sampler[j];k.create();c=Math.min(c,k.startTime);g=Math.max(g,k.endTime);h=Math.max(h,k.input.length)}e=h;for(varb=T.getChildById(b.skeleton[0],!0)||T.getChildBySid(b.skeleton[0],!0),l,m,g=newTHREE.Vector3,o,j=0;j<a.vertices.length;j++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[j].position);for(c=
0;c<e;c++){h=[];i=[];for(j=0;j<a.vertices.length;j++)i.push(newTHREE.Vertex(newTHREE.Vector3));d(b,h,c);j=h;k=f.skin;for(m=0;m<j.length;m++)if(l=j[m],o=-1,"JOINT"==l.type){for(varn=0;n<k.joints.length;n++)if(l.sid==k.joints[n]){o=n;break}if(0<=o){n=k.invBindMatrices[o];l.invBindMatrix=n;l.skinningMatrix=newTHREE.Matrix4;l.skinningMatrix.multiply(l.world,n);l.weights=[];for(n=0;n<k.weights.length;n++)for(varp=0;p<k.weights[n].length;p++){varr=k.weights[n][p];r.joint==o&&l.weights.push(r)}}elsethrow"ColladaLoader: Could not find joint '"+
l;for(h=0;h<i.faces.length;h++)l=i.faces[h],l.materialIndex=k[l.daeMaterial]}if(void0!==c)f(i,c),j.morphTargets=!0,j=newTHREE.SkinnedMesh(i,j),j.skeleton=c.skeleton,j.skinController=U[c.url],j.skinInstanceController=c,j.name="skin_"+ba.length,ba.push(j);elseif(void0!==d){h=i;k=dinstanceofn?U[d.url]:d;if(!k||!k.morph)console.log("could not find morph controller!");else{k=k.morph;for(l=0;l<k.targets.length;l++)if(m=V[k.targets[l]],m.mesh&&m.mesh.primitives&&m.mesh.primitives.length)m=m.mesh.primitives[0].geometry,
newy(l);s=-1;t=0;for(u=d.length;t<u&&-1==s;t++)d[t].time>=l&&(s=t);l=s;d.splice(-1==l?d.length:l,0,q)}q.addTarget(f,j,g,r)}}elseconsole.log('Could not find transform "'+b.sid+'" in node '+this.id)}for(c=0;c<a.length;c++){e=a[c];for(b=0;b<d.length;b++)if(q=d[b],!q.hasTarget(e)){h=d;f=q;j=b;g=e;i=void0;a:{i=j?j-1:0;for(i=0<=i?i:i+h.length;0<=i;i--)if(k=h[i],k.hasTarget(g)){i=k;breaka}i=null}k=void0;a:{for(j+=1;j<h.length;j++)if(k=h[j],k.hasTarget(g))breaka;k=null}if(i&&k){h=(f.time-i.time)/(k.time-
returnthis};p.prototype.convert=function(){switch(this.type){case"matrix":this.obj=ca(this.data);break;case"rotate":this.angle=this.data[3]*ja;case"translate":P(this.data,-1);this.obj=newTHREE.Vector3(this.data[0],this.data[1],this.data[2]);break;case"scale":P(this.data,1);this.obj=newTHREE.Vector3(this.data[0],this.data[1],this.data[2]);break;default:console.log("Can not convert Transform of type "+this.type)}};p.prototype.apply=function(a){switch(this.type){case"matrix":a.multiplySelf(this.obj);
break;case"translate":a.translate(this.obj);break;case"rotate":a.rotateByAxis(this.obj,this.angle);break;case"scale":a.scale(this.obj)}};p.prototype.update=function(a,b){switch(this.type){case"matrix":console.log("Currently not handling matrix transform updates");break;case"translate":case"scale":switch(b){case"X":this.obj.x=a;break;case"Y":this.obj.y=a;break;case"Z":this.obj.z=a;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2]}break;case"rotate":switch(b){case"X":this.obj.x=
switch(c.nodeName){case"source":vard=c.getAttribute("id");void0==Z[d]&&(Z[d]=(newz(d)).parse(c));break;case"vertices":this.vertices=(newu).parse(c);break;case"triangles":this.primitives.push((newt).parse(c));break;case"polygons":console.warn("polygon holes not yet supported!");case"polylist":this.primitives.push((news).parse(c))}}this.geometry3js=newTHREE.Geometry;a=Z[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(newTHREE.Vertex(ka(a,
[]),b.faceVertexUvs[e].push(q)}}elseconsole.log("dropped face with vcount "+m+" for geometry with id: "+b.id);c+=g.length*m}};s.prototype=newt;s.prototype.constructor=s;t.prototype.setVertices=function(a){for(varb=0;b<this.inputs.length;b++)if(this.inputs[b].source==a.id)this.inputs[b].source=a.input.POSITION.source};t.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=O(a,"count",0);for(varb=0;b<a.childNodes.length;b++){varc=a.childNodes[b];switch(c.nodeName){case"input":this.inputs.push((neww).parse(a.childNodes[b]));
break}}}returnthis};z.prototype.read=function(){vara=[],b=this.accessor.params[0];switch(b.type){case"IDREF":case"Name":case"name":case"float":returnthis.data;case"float4x4":for(b=0;b<this.data.length;b+=16){varc=this.data.slice(b,b+16),c=ca(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}returna};x.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(varb=0;b<a.childNodes.length;b++)if("instance_effect"==
f)console.log("Key.interpolate: Warning! Scale out of bounds:"+f),f=0>f?0:1;if(h.length)for(vare=[],i=0;i<h.length;++i)e[i]=h[i]+(g[i]-h[i])*f;elsee=h+(g-h)*f}elsee=d.data;d.transform.update(e,d.member)}};L.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(varb=0;b<a.childNodes.length;b++){varc=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case"optics":this.parseOptics(c)}}returnthis};L.prototype.parseOptics=function(a){for(varb=0;b<a.childNodes.length;b++)if("technique_common"==
c,d){vare=0;if(document.implementation&&document.implementation.createDocument){varf=newXMLHttpRequest;f.overrideMimeType&&f.overrideMimeType("text/xml");f.onreadystatechange=function(){if(4==f.readyState){if(0==f.status||200==f.status)f.responseXML?(la=c,a(f.responseXML,void0,b)):console.error("ColladaLoader: Empty or non-existing file ("+b+")")}else3==f.readyState&&d&&(0==e&&(e=f.getResponseHeader("Content-Length")),d({total:e,loaded:f.responseText.length}))};f.open("GET",b,!0);f.send(null)}elsealert("Don't know how to parse XML!")},
THREE.JSONLoader.prototype.load=function(a,b,c){if(ainstanceofObject)console.warn("DEPRECATED: JSONLoader( parameters ) is now JSONLoader( url, callback, texturePath )."),c=a,a=c.model,b=c.callback,c=c.texture_path;c=c?c:this.extractUrlbase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)};
THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,f){varg=newXMLHttpRequest,e=0;g.onreadystatechange=function(){if(4==g.readyState)if(200==g.status||0==g.status){try{varh=JSON.parse(g.responseText)}catch(i){console.warn("DEPRECATED: ["+b+"] seems to be using old model format")}a.createModel(h,c,d);a.onLoadComplete()}elseconsole.error("Couldn't load ["+b+"] ["+g.status+"]");else3==g.readyState?f&&(0==e&&(e=g.getResponseHeader("Content-Length")),f({total:e,loaded:g.responseText.length})):
THREE.SceneLoader.prototype.load=function(a,b){varc=this,d=newXMLHttpRequest;d.onreadystatechange=function(){if(4==d.readyState)if(200==d.status||0==d.status)try{varf=JSON.parse(d.responseText);void0===f.metadata||void0===f.metadata.formatVersion||3!==f.metadata.formatVersion?console.error("Deprecated file format."):c.createScene(f,b,a)}catch(g){console.error(g),console.warn("DEPRECATED: ["+a+"] seems to be using old model format")}elseconsole.error("Couldn't load ["+a+"] ["+d.status+"]")};