From dad6911bb03b2253a2bec8714f1eece887feddce Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sat, 29 Oct 2011 10:30:08 +0200 Subject: [PATCH] Optimised Ray a bit more Removed some clone() calls while still keeping the code somewhat pretty. --- build/Three.js | 724 +++++++++++++------------- build/custom/ThreeCanvas.js | 140 ++--- build/custom/ThreeDOM.js | 80 +-- build/custom/ThreeSVG.js | 106 ++-- build/custom/ThreeWebGL.js | 342 ++++++------ examples/webgl_interactive_cubes.html | 2 +- src/core/Ray.js | 116 ++--- 7 files changed, 755 insertions(+), 755 deletions(-) diff --git a/build/Three.js b/build/Three.js index 4c4e4be1..ea35a64f 100644 --- a/build/Three.js +++ b/build/Three.js @@ -14,39 +14,39 @@ cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y Math.abs(c)>1.0E-5?(this.x=Math.atan2(-a.n23/c,a.n33/c),this.z=Math.atan2(-a.n12/c,a.n11/c)):(this.x=0,this.z=Math.atan2(a.n21,a.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(a,c,b,d){this.x=a||0;this.y=c||0;this.z=b||0;this.w=d!==void 0?d:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z- c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, -normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c;return this}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.children)},intersectObjects:function(a){var c,b,d=[];c=0;for(b=a.length;c=0&&n>=0&&q+n<1}for(var d=new THREE.Vector3,g=new THREE.Vector3,e=new THREE.Vector3,f,h,i,k,l,m,q,n,t,p=[],o=0,v=a.children.length;oa.scale.x)return[];t={distance:o,point:a.position, -face:null,object:a};p.push(t)}else if(a instanceof THREE.Mesh){o=c(this.origin,this.direction,a.matrixWorld.getPosition());if(o===null||o>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return p;var w,r,s,u,x,H,G,F,y=a.geometry,C=y.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);o=0;for(v=y.faces.length;o0:H<0)))if(H=x.dot((new THREE.Vector3).sub(w,G))/H,G=G.addSelf(F.multiplyScalar(H)),t instanceof THREE.Face3)b(G,w,r,s)&&(t={distance:this.origin.distanceTo(G),point:G,face:t,object:a}, -p.push(t));else if(t instanceof THREE.Face4&&(b(G,w,r,u)||b(G,r,s,u)))t={distance:this.origin.distanceTo(G),point:G,face:t,object:a},p.push(t)}return p}}; -THREE.Rectangle=function(){function a(){e=d-c;f=g-b}var c,b,d,g,e,f,h=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return e};this.getHeight=function(){return f};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(e,f,l,m){h=!1;c=e;b=f;d=l;g=m;a()};this.addPoint=function(e,f){h?(h=!1,c=e,b=f,d=e,g=f):(c=ce?d:e,g=g>f?g:f);a()};this.add3Points= -function(e,f,l,m,q,n){h?(h=!1,c=el?e>q?e:q:l>q?l:q,g=f>m?f>n?f:n:m>n?m:n):(c=el?e>q?e>d?e:d:q>d?q:d:l>q?l>d?l:d:q>d?q:d,g=f>m?f>n?f>g?f:g:n>g?n:g:m>n?m>g?m:g:n>g?n:g);a()};this.addRectangle=function(e){h?(h=!1,c=e.getLeft(),b=e.getTop(),d=e.getRight(),g=e.getBottom()):(c=ce.getRight()?d:e.getRight(),g=g> +normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c;return this}}; +THREE.Ray=function(a,c){function b(a,b,c){var d;d=c.clone().subSelf(a).dot(b);if(d<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function d(a,b,c,d){k.copy(d).subSelf(b);l.copy(c).subSelf(b);n.copy(a).subSelf(b);o=k.dot(k);m=k.dot(l);s=k.dot(n);p=l.dot(l);r=l.dot(n);t=1/(o*p-m*m);w=(p*s-m*r)*t;q=(o*r-m*s)*t;return w>=0&&q>=0&&w+q<1}this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)}; +this.intersectObjects=function(a){var b,c,d=[];b=0;for(c=a.length;ba.scale.x)return[];c={distance:k,point:a.position,face:null,object:a};m.push(c)}else if(a instanceof THREE.Mesh){k=b(this.origin,this.direction,a.matrixWorld.getPosition());if(k===null||k>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return m;var n,p,o,s,r=a.geometry,q=r.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);k=0;for(l=r.faces.length;k0:n<0)))if(p=i.dot((new THREE.Vector3).sub(g,o))/n,o=o.addSelf(s.multiplyScalar(p)), +c instanceof THREE.Face3)d(o,g,e,f)&&(c={distance:this.origin.distanceTo(o),point:o,face:c,object:a},m.push(c));else if(c instanceof THREE.Face4&&(d(o,g,e,h)||d(o,e,f,h)))c={distance:this.origin.distanceTo(o),point:o,face:c,object:a},m.push(c)}return m};var k=new THREE.Vector3,l=new THREE.Vector3,n=new THREE.Vector3,o,m,s,p,r,t,w,q}; +THREE.Rectangle=function(){function a(){e=d-c;f=g-b}var c,b,d,g,e,f,h=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return e};this.getHeight=function(){return f};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(e,f,l,n){h=!1;c=e;b=f;d=l;g=n;a()};this.addPoint=function(e,f){h?(h=!1,c=e,b=f,d=e,g=f):(c=ce?d:e,g=g>f?g:f);a()};this.add3Points= +function(e,f,l,n,o,m){h?(h=!1,c=el?e>o?e:o:l>o?l:o,g=f>n?f>m?f:m:n>m?n:m):(c=el?e>o?e>d?e:d:o>d?o:d:l>o?l>d?l:d:o>d?o:d,g=f>n?f>m?f>g?f:g:m>g?m:g:n>m?n>g?n:g:m>g?m:g);a()};this.addRectangle=function(e){h?(h=!1,c=e.getLeft(),b=e.getTop(),d=e.getRight(),g=e.getBottom()):(c=ce.getRight()?d:e.getRight(),g=g> e.getBottom()?g:e.getBottom());a()};this.inflate=function(e){c-=e;b-=e;d+=e;g+=e;a()};this.minSelf=function(e){c=c>e.getLeft()?c:e.getLeft();b=b>e.getTop()?b:e.getTop();d=d=0&&Math.min(g,a.getBottom())-Math.max(b,a.getTop())>=0};this.empty=function(){h=!0;g=d=b=c=0;a()};this.isEmpty=function(){return h}}; THREE.Math={clamp:function(a,c,b){return ab?b:a},clampBottom:function(a,c){return a=0&&g>=0&&f>=0&&h>=0?!0:e<0&&g<0||f<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-g)):g<0&&(d=Math.min(d,e/(e-g))),f<0?c=Math.max(c,f/(f-h)):h<0&&(d=Math.min(d,f/(f-h))),df&&h.positionScreen.z0&&H.z<1))f=s[r]=s[r]||new THREE.RenderableParticle,r++,w=f,w.x=H.x/H.w,w.y=H.y/H.w,w.z=H.z,w.rotation=X.rotation.z,w.scale.x=X.scale.x*Math.abs(w.x-(H.x+e.projectionMatrix.n11)/(H.w+e.projectionMatrix.n14)),w.scale.y=X.scale.y*Math.abs(w.y-(H.y+e.projectionMatrix.n22)/(H.w+e.projectionMatrix.n24)),w.material=X.material,u.elements.push(w); -g&&u.elements.sort(b);return u}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==void 0?d:1)}; +l,n,o=[],m,s=[],p,r,t=[],w,q,C=[],v={objects:[],sprites:[],lights:[],elements:[]},x=new THREE.Vector3,I=new THREE.Vector4,K=new THREE.Matrix4,G=new THREE.Matrix4,y=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],D=new THREE.Vector4,Q=new THREE.Vector4;this.computeFrustum=function(a){y[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);y[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);y[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+ +a.n23,a.n44+a.n24);y[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);y[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);y[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;a<6;a++){var b=y[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);K.multiply(b.projectionMatrix,b.matrixWorldInverse);K.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix); +K.multiply(b.matrixWorld,b.projectionMatrixInverse);K.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(c,d){e=0;v.objects.length=0;v.sprites.length=0;v.lights.length=0;var f=function(b){if(b.visible!==!1){var c;if(c=b instanceof THREE.Mesh||b instanceof THREE.Line)if(!(c=b.frustumCulled===!1))a:{for(var d=b.matrixWorld, +e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),h=0;h<6;h++)if(c=y[h].x*d.n14+y[h].y*d.n24+y[h].z*d.n34+y[h].w,c<=e){c=!1;break a}c=!0}c?(K.multiplyVector3(x.copy(b.position)),g=a(),g.object=b,g.z=x.z,v.objects.push(g)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(K.multiplyVector3(x.copy(b.position)),g=a(),g.object=b,g.z=x.z,v.sprites.push(g)):b instanceof THREE.Light&&v.lights.push(b);c=0;for(d=b.children.length;cf&&h.positionScreen.z0&&I.z<1))f=C[q]=C[q]||new THREE.RenderableParticle,q++,w=f,w.x=I.x/I.w,w.y=I.y/I.w,w.z=I.z,w.rotation=Z.rotation.z,w.scale.x=Z.scale.x*Math.abs(w.x-(I.x+e.projectionMatrix.n11)/(I.w+e.projectionMatrix.n14)),w.scale.y=Z.scale.y*Math.abs(w.y-(I.y+e.projectionMatrix.n22)/(I.w+e.projectionMatrix.n24)),w.material=Z.material,v.elements.push(w); +g&&v.elements.sort(b);return v}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==void 0?d:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var c=Math.PI/360,b=a.x*c,d=a.y*c,g=a.z*c,a=Math.cos(d),d=Math.sin(d),c=Math.cos(-g),g=Math.sin(-g),e=Math.cos(b),b=Math.sin(b),f=a*c,h=d*g;this.w=f*e-h*b;this.x=f*b+h*e;this.y=d*c*e+a*g*b;this.z=a*g*e-d*c*b;return this},setFromAxisAngle:function(a,c){var b=c/2,d=Math.sin(b); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(b);return this},setFromRotationMatrix:function(a){var c=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,c+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,c-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,c-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var c= -this.x,b=this.y,d=this.z,g=this.w,e=a.x,f=a.y,h=a.z,a=a.w;this.x=c*a+g*e+b*h-d*f;this.y=b*a+g*f+d*e-c*h;this.z=d*a+g*h+c*f-b*e;this.w=g*a-c*e-b*f-d*h;return this},multiply:function(a,c){this.x=a.x*c.w+a.y*c.z-a.z*c.y+a.w*c.x;this.y=-a.x*c.z+a.y*c.w+a.z*c.x+a.w*c.y;this.z=a.x*c.y-a.y*c.x+a.z*c.w+a.w*c.z;this.w=-a.x*c.x-a.y*c.y-a.z*c.z+a.w*c.w;return this},multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,g=a.z,e=this.x,f=this.y,h=this.z,i=this.w,k=i*b+f*g-h*d,l=i*d+h*b-e*g,m=i*g+e*d-f*b,b=-e* -b-f*d-h*g;c.x=k*i+b*-e+l*-h-m*-f;c.y=l*i+b*-f+m*-e-k*-h;c.z=m*i+b*-h+k*-f-l*-e;return c}}; +this.x,b=this.y,d=this.z,g=this.w,e=a.x,f=a.y,h=a.z,a=a.w;this.x=c*a+g*e+b*h-d*f;this.y=b*a+g*f+d*e-c*h;this.z=d*a+g*h+c*f-b*e;this.w=g*a-c*e-b*f-d*h;return this},multiply:function(a,c){this.x=a.x*c.w+a.y*c.z-a.z*c.y+a.w*c.x;this.y=-a.x*c.z+a.y*c.w+a.z*c.x+a.w*c.y;this.z=a.x*c.y-a.y*c.x+a.z*c.w+a.w*c.z;this.w=-a.x*c.x-a.y*c.y-a.z*c.z+a.w*c.w;return this},multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,g=a.z,e=this.x,f=this.y,h=this.z,i=this.w,k=i*b+f*g-h*d,l=i*d+h*b-e*g,n=i*g+e*d-f*b,b=-e* +b-f*d-h*g;c.x=k*i+b*-e+l*-h-n*-f;c.y=l*i+b*-f+n*-e-k*-h;c.z=n*i+b*-h+k*-f-l*-e;return c}}; THREE.Quaternion.slerp=function(a,c,b,d){var g=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;g<0?(b.w=-c.w,b.x=-c.x,b.y=-c.y,b.z=-c.z,g=-g):b.copy(c);if(Math.abs(g)>=1)return b.w=a.w,b.x=a.x,b.y=a.y,b.z=a.z,b;var e=Math.acos(g),g=Math.sqrt(1-g*g);if(Math.abs(g)<0.001)return b.w=0.5*(a.w+c.w),b.x=0.5*(a.x+c.x),b.y=0.5*(a.y+c.y),b.z=0.5*(a.z+c.z),b;c=Math.sin((1-d)*e)/g;d=Math.sin(d*e)/g;b.w=a.w*c+b.w*d;b.x=a.x*c+b.x*d;b.y=a.y*c+b.y*d;b.z=a.z*c+b.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,c,b,d,g,e){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,c,b,d,g,e,f){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.u=a||0;this.v=c||0}; @@ -83,14 +83,14 @@ c;a++)b=this.faces[a],b.centroid.set(0,0,0),b instanceof THREE.Face3?(b.centroid b,d,g,e,f,h=new THREE.Vector3,i=new THREE.Vector3;d=0;for(g=this.faces.length;d0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, +b.vertexNormals[1].copy(d[b.b]),b.vertexNormals[2].copy(d[b.c]),b.vertexNormals[3].copy(d[b.d]))},computeTangents:function(){function a(a,b,c,d,e,g,j){h=a.vertices[b].position;i=a.vertices[c].position;k=a.vertices[d].position;l=f[e];n=f[g];o=f[j];m=i.x-h.x;s=k.x-h.x;p=i.y-h.y;r=k.y-h.y;t=i.z-h.z;w=k.z-h.z;q=n.u-l.u;C=o.u-l.u;v=n.v-l.v;x=o.v-l.v;I=1/(q*x-C*v);D.set((x*m-v*s)*I,(x*p-v*r)*I,(x*t-v*w)*I);Q.set((q*s-C*m)*I,(q*r-C*p)*I,(q*w-C*t)*I);G[b].addSelf(D);G[c].addSelf(D);G[d].addSelf(D);y[b].addSelf(Q); +y[c].addSelf(Q);y[d].addSelf(Q)}var c,b,d,g,e,f,h,i,k,l,n,o,m,s,p,r,t,w,q,C,v,x,I,K,G=[],y=[],D=new THREE.Vector3,Q=new THREE.Vector3,H=new THREE.Vector3,aa=new THREE.Vector3,M=new THREE.Vector3;c=0;for(b=this.vertices.length;c0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,b=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,c=0,b=this.vertices.length;cthis.points.length-2?e:e+1;b[3]=e>this.points.length-3?e:e+2;k=this.points[b[0]];l=this.points[b[1]]; -m=this.points[b[2]];q=this.points[b[3]];h=f*f;i=f*h;d.x=c(k.x,l.x,m.x,q.x,f,h,i);d.y=c(k.y,l.y,m.y,q.y,f,h,i);d.z=c(k.z,l.z,m.z,q.z,f,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.points.length-2?e:e+1;b[3]=e>this.points.length-3?e:e+2;k=this.points[b[0]];l=this.points[b[1]]; +n=this.points[b[2]];o=this.points[b[3]];h=f*f;i=f*h;d.x=c(k.x,l.x,n.x,o.x,f,h,i);d.y=c(k.y,l.y,n.y,o.y,f,h,i);d.z=c(k.z,l.z,n.z,o.z,f,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a0&&(b(THREE.NormalBlending),c(1),g("rgba("+Math.floor(o.r*255)+","+Math.floor(o.g*255)+","+Math.floor(o.b*255)+","+v+")"),p.fillRect(Math.floor(Y.getX()), -Math.floor(Y.getY()),Math.floor(Y.getWidth()),Math.floor(Y.getHeight()))),Y.empty())};this.render=function(a,l){function m(a){var b,c,d,e;ka.setRGB(0,0,0);V.setRGB(0,0,0);T.setRGB(0,0,0);b=0;for(c=a.length;b>1,W=k.height>>1,f=e.scale.x* -n,i=e.scale.y*t,j=f*l,h=i*W,ba.set(a.x-j,a.y-h,a.x+j,a.y+h),D.intersects(ba)&&(p.save(),p.translate(a.x,a.y),p.rotate(-e.rotation),p.scale(f,-i),p.translate(-l,-W),p.drawImage(k,0,0),p.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(j=e.scale.x*n,h=e.scale.y*t,ba.set(a.x-j,a.y-h,a.x+j,a.y+h),D.intersects(ba)&&(d(f.color.getContextStyle()),g(f.color.getContextStyle()),p.save(),p.translate(a.x,a.y),p.rotate(-e.rotation),p.scale(j,h),f.program(p),p.restore()))}function r(a,e,g,f){c(f.opacity); -b(f.blending);p.beginPath();p.moveTo(a.positionScreen.x,a.positionScreen.y);p.lineTo(e.positionScreen.x,e.positionScreen.y);p.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(x!=a)p.lineWidth=x=a;a=f.linecap;if(H!=a)p.lineCap=H=a;a=f.linejoin;if(G!=a)p.lineJoin=G=a;d(f.color.getContextStyle());p.stroke();ba.inflate(f.linewidth*2)}}function v(a,d,f,g,j,h,k,n){e.info.render.vertices+=3;e.info.render.faces++;c(n.opacity);b(n.blending);L=a.positionScreen.x;P=a.positionScreen.y;da= -d.positionScreen.x;ja=d.positionScreen.y;R=f.positionScreen.x;z=f.positionScreen.y;s(L,P,da,ja,R,z);if(n instanceof THREE.MeshBasicMaterial)if(n.map)n.map.mapping instanceof THREE.UVMapping&&(ma=k.uvs[0],Ga(L,P,da,ja,R,z,ma[g].u,ma[g].v,ma[j].u,ma[j].v,ma[h].u,ma[h].v,n.map));else if(n.envMap){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,aa.copy(k.vertexNormalsWorld[g]),sa=(aa.x*a.n11+aa.y*a.n12+aa.z*a.n13)*0.5+0.5,ua=-(aa.x*a.n21+aa.y*a.n22+aa.z*a.n23)*0.5+ -0.5,aa.copy(k.vertexNormalsWorld[j]),pa=(aa.x*a.n11+aa.y*a.n12+aa.z*a.n13)*0.5+0.5,ra=-(aa.x*a.n21+aa.y*a.n22+aa.z*a.n23)*0.5+0.5,aa.copy(k.vertexNormalsWorld[h]),wa=(aa.x*a.n11+aa.y*a.n12+aa.z*a.n13)*0.5+0.5,S=-(aa.x*a.n21+aa.y*a.n22+aa.z*a.n23)*0.5+0.5,Ga(L,P,da,ja,R,z,sa,ua,pa,ra,wa,S,n.envMap)}else n.wireframe?ya(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):u(n.color);else if(n instanceof THREE.MeshLambertMaterial)n.map&&!n.wireframe&&(n.map.mapping instanceof THREE.UVMapping&& -(ma=k.uvs[0],Ga(L,P,da,ja,R,z,ma[g].u,ma[g].v,ma[j].u,ma[j].v,ma[h].u,ma[h].v,n.map)),b(THREE.SubtractiveBlending)),ia?!n.wireframe&&n.shading==THREE.SmoothShading&&k.vertexNormalsWorld.length==3?(M.r=ea.r=U.r=ka.r,M.g=ea.g=U.g=ka.g,M.b=ea.b=U.b=ka.b,q(i,k.v1.positionWorld,k.vertexNormalsWorld[0],M),q(i,k.v2.positionWorld,k.vertexNormalsWorld[1],ea),q(i,k.v3.positionWorld,k.vertexNormalsWorld[2],U),M.r=Math.max(0,Math.min(n.color.r*M.r,1)),M.g=Math.max(0,Math.min(n.color.g*M.g,1)),M.b=Math.max(0, -Math.min(n.color.b*M.b,1)),ea.r=Math.max(0,Math.min(n.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(n.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(n.color.b*ea.b,1)),U.r=Math.max(0,Math.min(n.color.r*U.r,1)),U.g=Math.max(0,Math.min(n.color.g*U.g,1)),U.b=Math.max(0,Math.min(n.color.b*U.b,1)),ca.r=(ea.r+U.r)*0.5,ca.g=(ea.g+U.g)*0.5,ca.b=(ea.b+U.b)*0.5,qa=Da(M,ea,U,ca),Ba(L,P,da,ja,R,z,0,0,1,0,0,1,qa)):(Q.r=ka.r,Q.g=ka.g,Q.b=ka.b,q(i,k.centroidWorld,k.normalWorld,Q),Q.r=Math.max(0,Math.min(n.color.r*Q.r,1)), -Q.g=Math.max(0,Math.min(n.color.g*Q.g,1)),Q.b=Math.max(0,Math.min(n.color.b*Q.b,1)),n.wireframe?ya(Q,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):u(Q)):n.wireframe?ya(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):u(n.color);else if(n instanceof THREE.MeshDepthMaterial)fa=l.near,la=l.far,M.r=M.g=M.b=1-Aa(a.positionScreen.z,fa,la),ea.r=ea.g=ea.b=1-Aa(d.positionScreen.z,fa,la),U.r=U.g=U.b=1-Aa(f.positionScreen.z,fa,la),ca.r=(ea.r+U.r)*0.5,ca.g=(ea.g+U.g)*0.5,ca.b= -(ea.b+U.b)*0.5,qa=Da(M,ea,U,ca),Ba(L,P,da,ja,R,z,0,0,1,0,0,1,qa);else if(n instanceof THREE.MeshNormalMaterial)Q.r=Ca(k.normalWorld.x),Q.g=Ca(k.normalWorld.y),Q.b=Ca(k.normalWorld.z),n.wireframe?ya(Q,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):u(Q)}function w(a,d,f,g,h,n,k,W,m){e.info.render.vertices+=4;e.info.render.faces++;c(W.opacity);b(W.blending);if(W.map||W.envMap)v(a,d,g,0,1,3,k,W,m),v(h,f,n,1,2,3,k,W,m);else if(L=a.positionScreen.x,P=a.positionScreen.y,da=d.positionScreen.x, -ja=d.positionScreen.y,R=f.positionScreen.x,z=f.positionScreen.y,B=g.positionScreen.x,I=g.positionScreen.y,j=h.positionScreen.x,N=h.positionScreen.y,ga=n.positionScreen.x,X=n.positionScreen.y,W instanceof THREE.MeshBasicMaterial)Ea(L,P,da,ja,R,z,B,I),W.wireframe?ya(W.color,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):u(W.color);else if(W instanceof THREE.MeshLambertMaterial)ia?!W.wireframe&&W.shading==THREE.SmoothShading&&k.vertexNormalsWorld.length==4?(M.r=ea.r=U.r=ca.r=ka.r,M.g=ea.g= -U.g=ca.g=ka.g,M.b=ea.b=U.b=ca.b=ka.b,q(i,k.v1.positionWorld,k.vertexNormalsWorld[0],M),q(i,k.v2.positionWorld,k.vertexNormalsWorld[1],ea),q(i,k.v4.positionWorld,k.vertexNormalsWorld[3],U),q(i,k.v3.positionWorld,k.vertexNormalsWorld[2],ca),M.r=Math.max(0,Math.min(W.color.r*M.r,1)),M.g=Math.max(0,Math.min(W.color.g*M.g,1)),M.b=Math.max(0,Math.min(W.color.b*M.b,1)),ea.r=Math.max(0,Math.min(W.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(W.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(W.color.b*ea.b,1)),U.r= -Math.max(0,Math.min(W.color.r*U.r,1)),U.g=Math.max(0,Math.min(W.color.g*U.g,1)),U.b=Math.max(0,Math.min(W.color.b*U.b,1)),ca.r=Math.max(0,Math.min(W.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(W.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(W.color.b*ca.b,1)),qa=Da(M,ea,U,ca),s(L,P,da,ja,B,I),Ba(L,P,da,ja,B,I,0,0,1,0,0,1,qa),s(j,N,R,z,ga,X),Ba(j,N,R,z,ga,X,1,0,1,1,0,1,qa)):(Q.r=ka.r,Q.g=ka.g,Q.b=ka.b,q(i,k.centroidWorld,k.normalWorld,Q),Q.r=Math.max(0,Math.min(W.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(W.color.g* -Q.g,1)),Q.b=Math.max(0,Math.min(W.color.b*Q.b,1)),Ea(L,P,da,ja,R,z,B,I),W.wireframe?ya(Q,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):u(Q)):(Ea(L,P,da,ja,R,z,B,I),W.wireframe?ya(W.color,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):u(W.color));else if(W instanceof THREE.MeshNormalMaterial)Q.r=Ca(k.normalWorld.x),Q.g=Ca(k.normalWorld.y),Q.b=Ca(k.normalWorld.z),Ea(L,P,da,ja,R,z,B,I),W.wireframe?ya(Q,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):u(Q);else if(W instanceof -THREE.MeshDepthMaterial)fa=l.near,la=l.far,M.r=M.g=M.b=1-Aa(a.positionScreen.z,fa,la),ea.r=ea.g=ea.b=1-Aa(d.positionScreen.z,fa,la),U.r=U.g=U.b=1-Aa(g.positionScreen.z,fa,la),ca.r=ca.g=ca.b=1-Aa(f.positionScreen.z,fa,la),qa=Da(M,ea,U,ca),s(L,P,da,ja,B,I),Ba(L,P,da,ja,B,I,0,0,1,0,0,1,qa),s(j,N,R,z,ga,X),Ba(j,N,R,z,ga,X,1,0,1,1,0,1,qa)}function s(a,b,c,d,e,f){p.beginPath();p.moveTo(a,b);p.lineTo(c,d);p.lineTo(e,f);p.lineTo(a,b);p.closePath()}function Ea(a,b,c,d,e,f,g,j){p.beginPath();p.moveTo(a,b); -p.lineTo(c,d);p.lineTo(e,f);p.lineTo(g,j);p.lineTo(a,b);p.closePath()}function ya(a,b,c,e){if(x!=b)p.lineWidth=x=b;if(H!=c)p.lineCap=H=c;if(G!=e)p.lineJoin=G=e;d(a.getContextStyle());p.stroke();ba.inflate(b*2)}function u(a){g(a.getContextStyle());p.fill()}function Ga(a,b,c,d,e,f,j,h,i,n,k,W,l){if(l.image.width!=0){if(l.needsUpdate==!0||Z[l.id]==void 0){var m=l.wrapS==THREE.RepeatWrapping,q=l.wrapT==THREE.RepeatWrapping;Z[l.id]=p.createPattern(l.image,m&&q?"repeat":m&&!q?"repeat-x":!m&&q?"repeat-y": -"no-repeat");l.needsUpdate=!1}g(Z[l.id]);var m=l.offset.x/l.repeat.x,q=l.offset.y/l.repeat.y,S=(l.image.width-1)*l.repeat.x,l=(l.image.height-1)*l.repeat.y,j=(j+m)*S,h=(h+q)*l,i=(i+m)*S,n=(n+q)*l,k=(k+m)*S,W=(W+q)*l;c-=a;d-=b;e-=a;f-=b;i-=j;n-=h;k-=j;W-=h;m=1/(i*W-k*n);l=(W*c-n*e)*m;n=(W*d-n*f)*m;c=(i*e-k*c)*m;d=(i*f-k*d)*m;a=a-l*j-c*h;b=b-n*j-d*h;p.save();p.transform(l,n,c,d,a,b);p.fill();p.restore()}}function Ba(a,b,c,d,e,f,g,j,h,i,n,k,l){var W,m;W=l.width-1;m=l.height-1;g*=W;j*=m;h*=W;i*=m;n*= -W;k*=m;c-=a;d-=b;e-=a;f-=b;h-=g;i-=j;n-=g;k-=j;m=1/(h*k-n*i);W=(k*c-i*e)*m;i=(k*d-i*f)*m;c=(h*e-n*c)*m;d=(h*f-n*d)*m;a=a-W*g-c*j;b=b-i*g-d*j;p.save();p.transform(W,i,c,d,a,b);p.clip();p.drawImage(l,0,0);p.restore()}function Da(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),j=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),i=~~(c.g*255),c=~~(c.b*255),n=~~(d.r*255),k=~~(d.g*255),d=~~(d.b*255);na[0]=e<0?0:e>255?255:e;na[1]=f<0?0:f>255?255:f;na[2]=a<0?0:a>255?255:a;na[4]=g<0?0:g>255?255: -g;na[5]=j<0?0:j>255?255:j;na[6]=b<0?0:b>255?255:b;na[8]=h<0?0:h>255?255:h;na[9]=i<0?0:i>255?255:i;na[10]=c<0?0:c>255?255:c;na[12]=n<0?0:n>255?255:n;na[13]=k<0?0:k>255?255:k;na[14]=d<0?0:d>255?255:d;xa.putImageData(K,0,0);W.drawImage(ha,0,0);return ta}function Aa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ca(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function za(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Fa,Ha,oa,va;this.autoClear?this.clear(): -p.setTransform(1,0,0,-1,n,t);e.info.render.vertices=0;e.info.render.faces=0;f=k.projectScene(a,l,this.sortElements);h=f.elements;i=f.lights;(ia=i.length>0)&&m(i);Fa=0;for(Ha=h.length;Fa1?1:a}var d=this,g,e,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,m,q,n,t,p,o,v=new THREE.Rectangle,w=new THREE.Rectangle,r=!1,s=new THREE.Color,u=new THREE.Color,x=new THREE.Color,H=new THREE.Color,G,F=new THREE.Vector3,y=[],C=[],O,J,$,L=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, -faces:0}};this.setQuality=function(a){switch(a){case "high":L=1;break;case "low":L=0}};this.setSize=function(a,b){k=a;l=b;m=k/2;q=l/2;i.setAttribute("viewBox",-m+" "+-q+" "+k+" "+l);i.setAttribute("width",k);i.setAttribute("height",l);v.set(-m,-q,m,q)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,l){var F,y,z,B;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;g=h.projectScene(k,l,this.sortElements);e=g.elements; -f=g.lights;$=J=0;if(r=f.length>0){u.setRGB(0,0,0);x.setRGB(0,0,0);H.setRGB(0,0,0);F=0;for(y=f.length;F0&&(b(THREE.NormalBlending),c(1),g("rgba("+Math.floor(r.r*255)+","+Math.floor(r.g*255)+","+Math.floor(r.b*255)+","+t+")"),p.fillRect(Math.floor(J.getX()), +Math.floor(J.getY()),Math.floor(J.getWidth()),Math.floor(J.getHeight()))),J.empty())};this.render=function(a,l){function n(a){var b,c,d,e;la.setRGB(0,0,0);W.setRGB(0,0,0);ha.setRGB(0,0,0);b=0;for(c=a.length;b>1,X=k.height>> +1,f=e.scale.x*m,i=e.scale.y*s,j=f*l,h=i*X,E.set(a.x-j,a.y-h,a.x+j,a.y+h),u.intersects(E)&&(p.save(),p.translate(a.x,a.y),p.rotate(-e.rotation),p.scale(f,-i),p.translate(-l,-X),p.drawImage(k,0,0),p.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(j=e.scale.x*m,h=e.scale.y*s,E.set(a.x-j,a.y-h,a.x+j,a.y+h),u.intersects(E)&&(d(f.color.getContextStyle()),g(f.color.getContextStyle()),p.save(),p.translate(a.x,a.y),p.rotate(-e.rotation),p.scale(j,h),f.program(p),p.restore()))}function r(a,e,g, +f){c(f.opacity);b(f.blending);p.beginPath();p.moveTo(a.positionScreen.x,a.positionScreen.y);p.lineTo(e.positionScreen.x,e.positionScreen.y);p.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(x!=a)p.lineWidth=x=a;a=f.linecap;if(I!=a)p.lineCap=I=a;a=f.linejoin;if(K!=a)p.lineJoin=K=a;d(f.color.getContextStyle());p.stroke();E.inflate(f.linewidth*2)}}function t(a,d,f,g,j,h,k,m){e.info.render.vertices+=3;e.info.render.faces++;c(m.opacity);b(m.blending);M=a.positionScreen.x;R=a.positionScreen.y; +da=d.positionScreen.x;ja=d.positionScreen.y;T=f.positionScreen.x;z=f.positionScreen.y;C(M,R,da,ja,T,z);if(m instanceof THREE.MeshBasicMaterial)if(m.map)m.map.mapping instanceof THREE.UVMapping&&(ma=k.uvs[0],Ga(M,R,da,ja,T,z,ma[g].u,ma[g].v,ma[j].u,ma[j].v,ma[h].u,ma[h].v,m.map));else if(m.envMap){if(m.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,ba.copy(k.vertexNormalsWorld[g]),sa=(ba.x*a.n11+ba.y*a.n12+ba.z*a.n13)*0.5+0.5,ua=-(ba.x*a.n21+ba.y*a.n22+ba.z*a.n23)* +0.5+0.5,ba.copy(k.vertexNormalsWorld[j]),pa=(ba.x*a.n11+ba.y*a.n12+ba.z*a.n13)*0.5+0.5,ra=-(ba.x*a.n21+ba.y*a.n22+ba.z*a.n23)*0.5+0.5,ba.copy(k.vertexNormalsWorld[h]),wa=(ba.x*a.n11+ba.y*a.n12+ba.z*a.n13)*0.5+0.5,U=-(ba.x*a.n21+ba.y*a.n22+ba.z*a.n23)*0.5+0.5,Ga(M,R,da,ja,T,z,sa,ua,pa,ra,wa,U,m.envMap)}else m.wireframe?ya(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):v(m.color);else if(m instanceof THREE.MeshLambertMaterial)m.map&&!m.wireframe&&(m.map.mapping instanceof THREE.UVMapping&& +(ma=k.uvs[0],Ga(M,R,da,ja,T,z,ma[g].u,ma[g].v,ma[j].u,ma[j].v,ma[h].u,ma[h].v,m.map)),b(THREE.SubtractiveBlending)),ga?!m.wireframe&&m.shading==THREE.SmoothShading&&k.vertexNormalsWorld.length==3?(O.r=ea.r=V.r=la.r,O.g=ea.g=V.g=la.g,O.b=ea.b=V.b=la.b,o(i,k.v1.positionWorld,k.vertexNormalsWorld[0],O),o(i,k.v2.positionWorld,k.vertexNormalsWorld[1],ea),o(i,k.v3.positionWorld,k.vertexNormalsWorld[2],V),O.r=Math.max(0,Math.min(m.color.r*O.r,1)),O.g=Math.max(0,Math.min(m.color.g*O.g,1)),O.b=Math.max(0, +Math.min(m.color.b*O.b,1)),ea.r=Math.max(0,Math.min(m.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(m.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(m.color.b*ea.b,1)),V.r=Math.max(0,Math.min(m.color.r*V.r,1)),V.g=Math.max(0,Math.min(m.color.g*V.g,1)),V.b=Math.max(0,Math.min(m.color.b*V.b,1)),ca.r=(ea.r+V.r)*0.5,ca.g=(ea.g+V.g)*0.5,ca.b=(ea.b+V.b)*0.5,qa=Da(O,ea,V,ca),Ba(M,R,da,ja,T,z,0,0,1,0,0,1,qa)):(S.r=la.r,S.g=la.g,S.b=la.b,o(i,k.centroidWorld,k.normalWorld,S),S.r=Math.max(0,Math.min(m.color.r*S.r,1)), +S.g=Math.max(0,Math.min(m.color.g*S.g,1)),S.b=Math.max(0,Math.min(m.color.b*S.b,1)),m.wireframe?ya(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):v(S)):m.wireframe?ya(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):v(m.color);else if(m instanceof THREE.MeshDepthMaterial)Y=l.near,ka=l.far,O.r=O.g=O.b=1-Aa(a.positionScreen.z,Y,ka),ea.r=ea.g=ea.b=1-Aa(d.positionScreen.z,Y,ka),V.r=V.g=V.b=1-Aa(f.positionScreen.z,Y,ka),ca.r=(ea.r+V.r)*0.5,ca.g=(ea.g+V.g)*0.5,ca.b=(ea.b+ +V.b)*0.5,qa=Da(O,ea,V,ca),Ba(M,R,da,ja,T,z,0,0,1,0,0,1,qa);else if(m instanceof THREE.MeshNormalMaterial)S.r=Ca(k.normalWorld.x),S.g=Ca(k.normalWorld.y),S.b=Ca(k.normalWorld.z),m.wireframe?ya(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):v(S)}function w(a,d,f,g,h,m,k,X,n){e.info.render.vertices+=4;e.info.render.faces++;c(X.opacity);b(X.blending);if(X.map||X.envMap)t(a,d,g,0,1,3,k,X,n),t(h,f,m,1,2,3,k,X,n);else if(M=a.positionScreen.x,R=a.positionScreen.y,da=d.positionScreen.x,ja= +d.positionScreen.y,T=f.positionScreen.x,z=f.positionScreen.y,B=g.positionScreen.x,L=g.positionScreen.y,j=h.positionScreen.x,P=h.positionScreen.y,fa=m.positionScreen.x,Z=m.positionScreen.y,X instanceof THREE.MeshBasicMaterial)Ea(M,R,da,ja,T,z,B,L),X.wireframe?ya(X.color,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):v(X.color);else if(X instanceof THREE.MeshLambertMaterial)ga?!X.wireframe&&X.shading==THREE.SmoothShading&&k.vertexNormalsWorld.length==4?(O.r=ea.r=V.r=ca.r=la.r,O.g=ea.g= +V.g=ca.g=la.g,O.b=ea.b=V.b=ca.b=la.b,o(i,k.v1.positionWorld,k.vertexNormalsWorld[0],O),o(i,k.v2.positionWorld,k.vertexNormalsWorld[1],ea),o(i,k.v4.positionWorld,k.vertexNormalsWorld[3],V),o(i,k.v3.positionWorld,k.vertexNormalsWorld[2],ca),O.r=Math.max(0,Math.min(X.color.r*O.r,1)),O.g=Math.max(0,Math.min(X.color.g*O.g,1)),O.b=Math.max(0,Math.min(X.color.b*O.b,1)),ea.r=Math.max(0,Math.min(X.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(X.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(X.color.b*ea.b,1)),V.r= +Math.max(0,Math.min(X.color.r*V.r,1)),V.g=Math.max(0,Math.min(X.color.g*V.g,1)),V.b=Math.max(0,Math.min(X.color.b*V.b,1)),ca.r=Math.max(0,Math.min(X.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(X.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(X.color.b*ca.b,1)),qa=Da(O,ea,V,ca),C(M,R,da,ja,B,L),Ba(M,R,da,ja,B,L,0,0,1,0,0,1,qa),C(j,P,T,z,fa,Z),Ba(j,P,T,z,fa,Z,1,0,1,1,0,1,qa)):(S.r=la.r,S.g=la.g,S.b=la.b,o(i,k.centroidWorld,k.normalWorld,S),S.r=Math.max(0,Math.min(X.color.r*S.r,1)),S.g=Math.max(0,Math.min(X.color.g* +S.g,1)),S.b=Math.max(0,Math.min(X.color.b*S.b,1)),Ea(M,R,da,ja,T,z,B,L),X.wireframe?ya(S,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):v(S)):(Ea(M,R,da,ja,T,z,B,L),X.wireframe?ya(X.color,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):v(X.color));else if(X instanceof THREE.MeshNormalMaterial)S.r=Ca(k.normalWorld.x),S.g=Ca(k.normalWorld.y),S.b=Ca(k.normalWorld.z),Ea(M,R,da,ja,T,z,B,L),X.wireframe?ya(S,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):v(S);else if(X instanceof +THREE.MeshDepthMaterial)Y=l.near,ka=l.far,O.r=O.g=O.b=1-Aa(a.positionScreen.z,Y,ka),ea.r=ea.g=ea.b=1-Aa(d.positionScreen.z,Y,ka),V.r=V.g=V.b=1-Aa(g.positionScreen.z,Y,ka),ca.r=ca.g=ca.b=1-Aa(f.positionScreen.z,Y,ka),qa=Da(O,ea,V,ca),C(M,R,da,ja,B,L),Ba(M,R,da,ja,B,L,0,0,1,0,0,1,qa),C(j,P,T,z,fa,Z),Ba(j,P,T,z,fa,Z,1,0,1,1,0,1,qa)}function C(a,b,c,d,e,f){p.beginPath();p.moveTo(a,b);p.lineTo(c,d);p.lineTo(e,f);p.lineTo(a,b);p.closePath()}function Ea(a,b,c,d,e,f,g,j){p.beginPath();p.moveTo(a,b);p.lineTo(c, +d);p.lineTo(e,f);p.lineTo(g,j);p.lineTo(a,b);p.closePath()}function ya(a,b,c,e){if(x!=b)p.lineWidth=x=b;if(I!=c)p.lineCap=I=c;if(K!=e)p.lineJoin=K=e;d(a.getContextStyle());p.stroke();E.inflate(b*2)}function v(a){g(a.getContextStyle());p.fill()}function Ga(a,b,c,d,e,f,j,h,i,m,k,X,l){if(l.image.width!=0){if(l.needsUpdate==!0||$[l.id]==void 0){var n=l.wrapS==THREE.RepeatWrapping,o=l.wrapT==THREE.RepeatWrapping;$[l.id]=p.createPattern(l.image,n&&o?"repeat":n&&!o?"repeat-x":!n&&o?"repeat-y":"no-repeat"); +l.needsUpdate=!1}g($[l.id]);var n=l.offset.x/l.repeat.x,o=l.offset.y/l.repeat.y,U=(l.image.width-1)*l.repeat.x,l=(l.image.height-1)*l.repeat.y,j=(j+n)*U,h=(h+o)*l,i=(i+n)*U,m=(m+o)*l,k=(k+n)*U,X=(X+o)*l;c-=a;d-=b;e-=a;f-=b;i-=j;m-=h;k-=j;X-=h;n=1/(i*X-k*m);l=(X*c-m*e)*n;m=(X*d-m*f)*n;c=(i*e-k*c)*n;d=(i*f-k*d)*n;a=a-l*j-c*h;b=b-m*j-d*h;p.save();p.transform(l,m,c,d,a,b);p.fill();p.restore()}}function Ba(a,b,c,d,e,f,g,j,h,i,m,k,l){var X,n;X=l.width-1;n=l.height-1;g*=X;j*=n;h*=X;i*=n;m*=X;k*=n;c-=a;d-= +b;e-=a;f-=b;h-=g;i-=j;m-=g;k-=j;n=1/(h*k-m*i);X=(k*c-i*e)*n;i=(k*d-i*f)*n;c=(h*e-m*c)*n;d=(h*f-m*d)*n;a=a-X*g-c*j;b=b-i*g-d*j;p.save();p.transform(X,i,c,d,a,b);p.clip();p.drawImage(l,0,0);p.restore()}function Da(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),j=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),i=~~(c.g*255),c=~~(c.b*255),m=~~(d.r*255),k=~~(d.g*255),d=~~(d.b*255);na[0]=e<0?0:e>255?255:e;na[1]=f<0?0:f>255?255:f;na[2]=a<0?0:a>255?255:a;na[4]=g<0?0:g>255?255:g;na[5]=j<0?0: +j>255?255:j;na[6]=b<0?0:b>255?255:b;na[8]=h<0?0:h>255?255:h;na[9]=i<0?0:i>255?255:i;na[10]=c<0?0:c>255?255:c;na[12]=m<0?0:m>255?255:m;na[13]=k<0?0:k>255?255:k;na[14]=d<0?0:d>255?255:d;xa.putImageData(N,0,0);X.drawImage(ia,0,0);return ta}function Aa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ca(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function za(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Fa,Ha,oa,va;this.autoClear?this.clear():p.setTransform(1, +0,0,-1,m,s);e.info.render.vertices=0;e.info.render.faces=0;f=k.projectScene(a,l,this.sortElements);h=f.elements;i=f.lights;(ga=i.length>0)&&n(i);Fa=0;for(Ha=h.length;Fa1?1:a}var d=this,g,e,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,n,o,m,s,p,r,t=new THREE.Rectangle,w=new THREE.Rectangle,q=!1,C=new THREE.Color,v=new THREE.Color,x=new THREE.Color,I=new THREE.Color,K,G=new THREE.Vector3,y=[],D=[],Q,H,aa,M=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, +faces:0}};this.setQuality=function(a){switch(a){case "high":M=1;break;case "low":M=0}};this.setSize=function(a,b){k=a;l=b;n=k/2;o=l/2;i.setAttribute("viewBox",-n+" "+-o+" "+k+" "+l);i.setAttribute("width",k);i.setAttribute("height",l);t.set(-n,-o,n,o)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,l){var G,y,z,B;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;g=h.projectScene(k,l,this.sortElements);e=g.elements; +f=g.lights;aa=H=0;if(q=f.length>0){v.setRGB(0,0,0);x.setRGB(0,0,0);I.setRGB(0,0,0);G=0;for(y=f.length;G=0)return a.geometry.materials[b.materialIndex]}function d(a,b,c){var d,e,g,f,h=a.vertices;f=h.length;var i=a.colors,n=i.length,k=a.__vertexArray,l=a.__colorArray,m=a.__sortArray,p=a.__dirtyVertices,q=a.__dirtyColors,S=a.__webglCustomAttributesList;if(c.sortParticles){Y.multiplySelf(c.matrixWorld);for(d=0;d=0)return a.geometry.materials[b.materialIndex]}function d(a,b,c){var d,e,g,f,h=a.vertices;f=h.length;var i=a.colors,m=i.length,k=a.__vertexArray,l=a.__colorArray,n=a.__sortArray,p=a.__dirtyVertices,o=a.__dirtyColors,U=a.__webglCustomAttributesList;if(c.sortParticles){J.multiplySelf(c.matrixWorld);for(d=0;d=0)a&&(j.bindBuffer(j.ARRAY_BUFFER, +g+=4}}if(p||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,k,b);if(o||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,l,b);if(U){i=0;for(m=U.length;i=0)a&&(j.bindBuffer(j.ARRAY_BUFFER, e.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;g.morphTargetBase!==-1?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[g.morphTargetBase]),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):c.position>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){f=0;var i=g.morphTargetForcedOrder;for(h=g.morphTargetInfluences;fn&&(k=l,n=h[k]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[k]);j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[f]= -n;i[k]=1;n=-1;f++}}d.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){f=0;for(h=e.__webglCustomAttributesList.length;f=0&&(j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,!1,0,0))}b.color>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglColorBuffer),j.vertexAttribPointer(b.color, +fm&&(k=l,m=h[k]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[k]);j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[f]= +m;i[k]=1;m=-1;f++}}d.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){f=0;for(h=e.__webglCustomAttributesList.length;f=0&&(j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,!1,0,0))}b.color>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglColorBuffer),j.vertexAttribPointer(b.color, 3,j.FLOAT,!1,0,0));b.normal>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglNormalBuffer),j.vertexAttribPointer(b.normal,3,j.FLOAT,!1,0,0));b.tangent>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglTangentBuffer),j.vertexAttribPointer(b.tangent,4,j.FLOAT,!1,0,0));b.uv>=0&&(e.__webglUVBuffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUVBuffer),j.vertexAttribPointer(b.uv,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv)):j.disableVertexAttribArray(b.uv));b.uv2>=0&&(e.__webglUV2Buffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUV2Buffer), j.vertexAttribPointer(b.uv2,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv2)):j.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexABuffer),j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex, -4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==ua&&(j.lineWidth(d),ua=d),a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,0)):(a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)),I.info.render.calls++,I.info.render.vertices+= -e.__webglFaceCount,I.info.render.faces+=e.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==ua&&(j.lineWidth(d),ua=d),j.drawArrays(g,0,e.__webglLineCount),I.info.render.calls++):g instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),I.info.render.calls++):g instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),I.info.render.calls++)}}function f(a){D[0].set(a.n41-a.n11,a.n42-a.n12,a.n43- -a.n13,a.n44-a.n14);D[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);D[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);D[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);D[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);D[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=D[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function h(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y, -a.scale.z)),d=0;d<6;d++)if(a=D[d].x*b.n14+D[d].y*b.n24+D[d].z*b.n34+D[d].w,a<=c)return!1;return!0}function i(a,b){return b.z-a.z}function k(a){var b,c,d,i,n,k,l,m,p=0,q=a.lights;T||(T=new THREE.PerspectiveCamera(I.shadowCameraFov,I.shadowMapWidth/I.shadowMapHeight,I.shadowCameraNear,I.shadowCameraFar));b=0;for(c=q.length;b=0;c--)a[c].object===b&&a.splice(c,1)}function o(a,b,c,d,e){d.program||I.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(I.maxMorphTargets); -for(var g=0,f=I.maxMorphTargets;g0;this.getContext=function(){return j};this.supportsVertexTextures= -function(){return ta};this.setSize=function(a,b){$.width=a;$.height=b;this.setViewport(0,0,$.width,$.height)};this.setViewport=function(a,b,c,d){pa=a;ra=b;wa=c;S=d;j.viewport(pa,ra,wa,S)};this.setScissor=function(a,b,c,d){j.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)};this.setClearColorHex=function(a,b){R.setHex(a);z=b;j.clearColor(R.r,R.g,R.b,z)};this.setClearColor=function(a,b){R.copy(a);z=b;j.clearColor(R.r,R.g,R.b,z)};this.getClearColor= -function(){return R};this.getClearAlpha=function(){return z};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=j.COLOR_BUFFER_BIT;if(b===void 0||b)d|=j.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){C(a);this.clear(b,c,d)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c= -a.geometry.geometryGroups[b];j.deleteBuffer(c.__webglVertexBuffer);j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer);j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d= -0,e=c.numMorphTargets;d=0)B=D.geometry.materials[B],B.transparent?(o.transparent=B,o.opaque=null):(o.opaque=B,o.transparent=null)}else if(B)B.transparent?(o.transparent=B,o.opaque=null):(o.opaque=B,o.transparent=null);g.render=!0;if(this.sortObjects)n.renderDepth?g.z=n.renderDepth:(ka.copy(n.position),Y.multiplyVector3(ka),g.z=ka.z)}this.sortObjects&&p.sort(i);p=a.__webglObjectsImmediate; -d=0;for(e=p.length;d65535&&(r[D].counter+=1,Y=r[D].hash+"_"+r[D].counter,i.geometryGroups[Y]===void 0&&(i.geometryGroups[Y]= -{faces3:[],faces4:[],materialIndex:S,vertices:0,numMorphTargets:v})),m instanceof THREE.Face3?i.geometryGroups[Y].faces3.push(k):i.geometryGroups[Y].faces4.push(k),i.geometryGroups[Y].vertices+=o;i.geometryGroupsList=[];k=void 0;for(k in i.geometryGroups)i.geometryGroups[k].id=ea++,i.geometryGroupsList.push(i.geometryGroups[k])}for(f in h.geometryGroups)if(i=h.geometryGroups[f],!i.__webglVertexBuffer){k=i;k.__webglVertexBuffer=j.createBuffer();k.__webglNormalBuffer=j.createBuffer();k.__webglTangentBuffer= -j.createBuffer();k.__webglColorBuffer=j.createBuffer();k.__webglUVBuffer=j.createBuffer();k.__webglUV2Buffer=j.createBuffer();k.__webglSkinVertexABuffer=j.createBuffer();k.__webglSkinVertexBBuffer=j.createBuffer();k.__webglSkinIndicesBuffer=j.createBuffer();k.__webglSkinWeightsBuffer=j.createBuffer();k.__webglFaceBuffer=j.createBuffer();k.__webglLineBuffer=j.createBuffer();if(k.numMorphTargets){m=l=void 0;k.__webglMorphTargetsBuffers=[];l=0;for(m=k.numMorphTargets;l0||o.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(o.faceUvs.length>1||o.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k*2)}if(S.geometry.skinWeights.length&&S.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4),i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(m*3); -i.__lineArray=new Uint16Array(D*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];S=0;for(o=i.numMorphTargets;S=0;h--)g[h]===f&&g.splice(h,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&p(g.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(g=a.__webglObjects.length;e0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,K,m),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,N,m),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,C,m),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinWeightsBuffer), -j.bufferData(j.ARRAY_BUFFER,U,m))}if(xa&&ka){o=0;for(D=r.length;o0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,ia,m))}if(ja&&F.hasTangents){o=0;for(D=r.length;o0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,O,m))}if($&&ua&&H){o=0;for(D=r.length;o0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,E,m))}if(ga){o=0;for(D=r.length;o=0&&j.enableVertexAttribArray(o.position);o.color>=0&&j.enableVertexAttribArray(o.color);o.normal>=0&&j.enableVertexAttribArray(o.normal); -o.tangent>=0&&j.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(j.enableVertexAttribArray(o.skinVertexA),j.enableVertexAttribArray(o.skinVertexB),j.enableVertexAttribArray(o.skinIndex),j.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(g in a.attributes)o[g]!==void 0&&o[g]>=0&&j.enableVertexAttribArray(o[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g=0&&(j.enableVertexAttribArray(o[q]), +4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==ua&&(j.lineWidth(d),ua=d),a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,0)):(a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)),L.info.render.calls++,L.info.render.vertices+= +e.__webglFaceCount,L.info.render.faces+=e.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==ua&&(j.lineWidth(d),ua=d),j.drawArrays(g,0,e.__webglLineCount),L.info.render.calls++):g instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),L.info.render.calls++):g instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),L.info.render.calls++)}}function f(a){u[0].set(a.n41-a.n11,a.n42-a.n12,a.n43- +a.n13,a.n44-a.n14);u[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);u[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);u[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);u[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);u[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=u[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function h(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y, +a.scale.z)),d=0;d<6;d++)if(a=u[d].x*b.n14+u[d].y*b.n24+u[d].z*b.n34+u[d].w,a<=c)return!1;return!0}function i(a,b){return b.z-a.z}function k(a){var b,c,d,i,m,k,l,n,p=0,o=a.lights;ha||(ha=new THREE.PerspectiveCamera(L.shadowCameraFov,L.shadowMapWidth/L.shadowMapHeight,L.shadowCameraNear,L.shadowCameraFar));b=0;for(c=o.length;b=0;c--)a[c].object===b&&a.splice(c,1)}function r(a,b,c,d,e){d.program||L.initMaterial(d,b,c,e);if(d.morphTargets&& +!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(L.maxMorphTargets);for(var g=0,f=L.maxMorphTargets;g0;this.getContext=function(){return j};this.supportsVertexTextures=function(){return ta};this.setSize=function(a,b){aa.width=a;aa.height=b;this.setViewport(0,0,aa.width,aa.height)};this.setViewport=function(a,b,c,d){pa=a;ra=b;wa=c;U=d;j.viewport(pa,ra,wa,U)};this.setScissor=function(a,b,c,d){j.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)}; +this.setClearColorHex=function(a,b){T.setHex(a);z=b;j.clearColor(T.r,T.g,T.b,z)};this.setClearColor=function(a,b){T.copy(a);z=b;j.clearColor(T.r,T.g,T.b,z)};this.getClearColor=function(){return T};this.getClearAlpha=function(){return z};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=j.COLOR_BUFFER_BIT;if(b===void 0||b)d|=j.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){D(a);this.clear(b,c,d)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit= +!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];j.deleteBuffer(c.__webglVertexBuffer);j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer); +j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d=0)B=u.geometry.materials[B],B.transparent?(r.transparent=B,r.opaque=null):(r.opaque=B,r.transparent=null)}else if(B)B.transparent? +(r.transparent=B,r.opaque=null):(r.opaque=B,r.transparent=null);g.render=!0;if(this.sortObjects)m.renderDepth?g.z=m.renderDepth:(la.copy(m.position),J.multiplyVector3(la),g.z=la.z)}this.sortObjects&&p.sort(i);p=a.__webglObjectsImmediate;d=0;for(e=p.length;d65535&&(r[J].counter+=1,q=r[J].hash+"_"+r[J].counter,i.geometryGroups[q]===void 0&&(i.geometryGroups[q]={faces3:[],faces4:[],materialIndex:U,vertices:0,numMorphTargets:t})),n instanceof THREE.Face3?i.geometryGroups[q].faces3.push(k):i.geometryGroups[q].faces4.push(k),i.geometryGroups[q].vertices+=u;i.geometryGroupsList=[];k=void 0;for(k in i.geometryGroups)i.geometryGroups[k].id= +ea++,i.geometryGroupsList.push(i.geometryGroups[k])}for(f in h.geometryGroups)if(i=h.geometryGroups[f],!i.__webglVertexBuffer){k=i;k.__webglVertexBuffer=j.createBuffer();k.__webglNormalBuffer=j.createBuffer();k.__webglTangentBuffer=j.createBuffer();k.__webglColorBuffer=j.createBuffer();k.__webglUVBuffer=j.createBuffer();k.__webglUV2Buffer=j.createBuffer();k.__webglSkinVertexABuffer=j.createBuffer();k.__webglSkinVertexBBuffer=j.createBuffer();k.__webglSkinIndicesBuffer=j.createBuffer();k.__webglSkinWeightsBuffer= +j.createBuffer();k.__webglFaceBuffer=j.createBuffer();k.__webglLineBuffer=j.createBuffer();if(k.numMorphTargets){n=l=void 0;k.__webglMorphTargetsBuffers=[];l=0;for(n=k.numMorphTargets;l0||u.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k* +2)}if(U.geometry.skinWeights.length&&U.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4),i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(n*3);i.__lineArray=new Uint16Array(J*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];U=0;for(u=i.numMorphTargets;U=0;h--)g[h]===f&&g.splice(h,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&p(g.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(g=a.__webglObjects.length;e0&&(j.bindBuffer(j.ARRAY_BUFFER, +l.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,P,n),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,Y,n),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,D,n),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,V,n))}if(xa&&I){u=0;for(J=r.length;u0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,N,n))}if(ja&&G.hasTangents){u=0;for(J=r.length;u< +J;u++)E=ia[r[u]],G=E.vertexTangents,ga=G[0],N=G[1],I=G[2],C[H]=ga.x,C[H+1]=ga.y,C[H+2]=ga.z,C[H+3]=ga.w,C[H+4]=N.x,C[H+5]=N.y,C[H+6]=N.z,C[H+7]=N.w,C[H+8]=I.x,C[H+9]=I.y,C[H+10]=I.z,C[H+11]=I.w,H+=12;u=0;for(J=t.length;u0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,Q,n))}if(aa&&ua&&la){u=0;for(J=r.length;u0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,F,n))}if(fa){u=0;for(J=r.length;u=0&&j.enableVertexAttribArray(u.position);u.color>=0&&j.enableVertexAttribArray(u.color);u.normal>=0&&j.enableVertexAttribArray(u.normal); +u.tangent>=0&&j.enableVertexAttribArray(u.tangent);a.skinning&&u.skinVertexA>=0&&u.skinVertexB>=0&&u.skinIndex>=0&&u.skinWeight>=0&&(j.enableVertexAttribArray(u.skinVertexA),j.enableVertexAttribArray(u.skinVertexB),j.enableVertexAttribArray(u.skinIndex),j.enableVertexAttribArray(u.skinWeight));if(a.attributes)for(g in a.attributes)u[g]!==void 0&&u[g]>=0&&j.enableVertexAttribArray(u[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g=0&&(j.enableVertexAttribArray(u[o]), a.numSupportedMorphTargets++);a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?j.frontFace(j.CCW):j.frontFace(j.CW),a==="back"?j.cullFace(j.BACK):a==="front"?j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK),j.enable(j.CULL_FACE)):j.disable(j.CULL_FACE)}}; THREE.WebGLRenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==void 0?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==void 0?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==void 0?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==void 0?b.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=b.format!==void 0?b.format:THREE.RGBAFormat;this.type=b.type!==void 0?b.type: THREE.UnsignedByteType;this.depthBuffer=b.depthBuffer!==void 0?b.depthBuffer:!0;this.stencilBuffer=b.stencilBuffer!==void 0?b.stencilBuffer:!0}; @@ -349,19 +349,19 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null}; THREE.ColorUtils={adjustHSV:function(a,c,b,d){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,g);g.h=THREE.Math.clamp(g.h+c,0,1);g.s=THREE.Math.clamp(g.s+b,0,1);g.v=THREE.Math.clamp(g.v+d,0,1);a.setHSV(g.h,g.s,g.v)},rgbToHsv:function(a,c){var b=a.r,d=a.g,g=a.b,e=Math.max(Math.max(b,d),g),f=Math.min(Math.min(b,d),g);if(f===e)f=b=0;else{var h=e-f,f=h/e,b=b===e?(d-g)/h:d===e?2+(g-b)/h:4+(b-d)/h;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=f;c.v=e;return c}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(a,c){for(var b,d,g=a.vertices.length,e=c instanceof THREE.Mesh?c.geometry:c,f=a.vertices,h=e.vertices,i=a.faces,k=e.faces,l=a.faceVertexUvs[0],m=e.faceVertexUvs[0],q={},n=0;n1&&(d=1-d,g=1-g);e=1-d-g;f.copy(a);f.multiplyScalar(d);h.copy(c);h.multiplyScalar(g);f.addSelf(h);h.copy(b);h.multiplyScalar(e);f.addSelf(h);return f},randomPointInFace:function(a,c,b){var d,g,e;if(a instanceof THREE.Face3)return d=c.vertices[a.a].position,g=c.vertices[a.b].position, e=c.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,g,e);else if(a instanceof THREE.Face4){d=c.vertices[a.a].position;g=c.vertices[a.b].position;e=c.vertices[a.c].position;var c=c.vertices[a.d].position,f;b?a._area1&&a._area2?(b=a._area1,f=a._area2):(b=THREE.GeometryUtils.triangleArea(d,g,c),f=THREE.GeometryUtils.triangleArea(g,e,c),a._area1=b,a._area2=f):(b=THREE.GeometryUtils.triangleArea(d,g,c),f=THREE.GeometryUtils.triangleArea(g,e,c));return THREE.GeometryUtils.random()*(b+ -f)a?b(c,e-1):k[e]a?b(c,e-1):k[e]0?(f=b[b.length-1],n=f.x,t=f.y):(f=this.actions[d-1].args,n=f[f.length-2],t=f[f.length-1]);for(f=1;f<=a;f++)p=f/a,e=THREE.Shape.Utils.b2(p,n,m,h),p=THREE.Shape.Utils.b2(p,t,q, -i),b.push(new THREE.Vector2(e,p));break;case THREE.PathActions.BEZIER_CURVE_TO:h=e[4];i=e[5];m=e[0];q=e[1];k=e[2];l=e[3];b.length>0?(f=b[b.length-1],n=f.x,t=f.y):(f=this.actions[d-1].args,n=f[f.length-2],t=f[f.length-1]);for(f=1;f<=a;f++)p=f/a,e=THREE.Shape.Utils.b3(p,n,m,k,h),p=THREE.Shape.Utils.b3(p,t,q,l,i),b.push(new THREE.Vector2(e,p));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];p=a*e[0].length;f=f.concat(e[0]);e=new THREE.SplineCurve(f); -for(f=1;f<=p;f++)b.push(e.getPointAt(f/p));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=e[0];i=e[1];k=e[2];m=e[3];p=e[4];q=!!e[5];l=f[f.length-2];n=f[f.length-1];f.length==0&&(l=n=0);t=p-m;var o=a*2;for(f=1;f<=o;f++)p=f/o,q||(p=1-p),p=m+p*t,e=l+h+k*Math.cos(p),p=n+i+k*Math.sin(p),b.push(new THREE.Vector2(e,p))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)}; -THREE.Path.prototype.nltransform=function(a,c,b,d,g,e){var f=this.getPoints(),h,i,k,l,m;h=0;for(i=f.length;h0?(f=b[b.length-1],m=f.x,s=f.y):(f=this.actions[d-1].args,m=f[f.length-2],s=f[f.length-1]);for(f=1;f<=a;f++)p=f/a,e=THREE.Shape.Utils.b2(p,m,n,h),p=THREE.Shape.Utils.b2(p,s,o, +i),b.push(new THREE.Vector2(e,p));break;case THREE.PathActions.BEZIER_CURVE_TO:h=e[4];i=e[5];n=e[0];o=e[1];k=e[2];l=e[3];b.length>0?(f=b[b.length-1],m=f.x,s=f.y):(f=this.actions[d-1].args,m=f[f.length-2],s=f[f.length-1]);for(f=1;f<=a;f++)p=f/a,e=THREE.Shape.Utils.b3(p,m,n,k,h),p=THREE.Shape.Utils.b3(p,s,o,l,i),b.push(new THREE.Vector2(e,p));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];p=a*e[0].length;f=f.concat(e[0]);e=new THREE.SplineCurve(f); +for(f=1;f<=p;f++)b.push(e.getPointAt(f/p));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=e[0];i=e[1];k=e[2];n=e[3];p=e[4];o=!!e[5];l=f[f.length-2];m=f[f.length-1];f.length==0&&(l=m=0);s=p-n;var r=a*2;for(f=1;f<=r;f++)p=f/r,o||(p=1-p),p=n+p*s,e=l+h+k*Math.cos(p),p=m+i+k*Math.sin(p),b.push(new THREE.Vector2(e,p))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)}; +THREE.Path.prototype.nltransform=function(a,c,b,d,g,e){var f=this.getPoints(),h,i,k,l,n;h=0;for(i=f.length;h=0?h-1:b.length-1;e=f-1>=0?f-1:k.length-1;var p=[k[f],b[h],b[g]];m=THREE.FontUtils.Triangulate.area(p);var o=[k[f],k[e],b[h]];q=THREE.FontUtils.Triangulate.area(o);n=h;l=f;h+=1;f+=-1;h< -0&&(h+=b.length);h%=b.length;f<0&&(f+=k.length);f%=k.length;g=h-1>=0?h-1:b.length-1;e=f-1>=0?f-1:k.length-1;p=[k[f],b[h],b[g]];p=THREE.FontUtils.Triangulate.area(p);o=[k[f],k[e],b[h]];o=THREE.FontUtils.Triangulate.area(o);m+q>p+o&&(h=n,f=l,h<0&&(h+=b.length),h%=b.length,f<0&&(f+=k.length),f%=k.length,g=h-1>=0?h-1:b.length-1,e=f-1>=0?f-1:k.length-1);m=b.slice(0,h);q=b.slice(h);n=k.slice(f);l=k.slice(0,f);e=[k[f],k[e],b[h]];t.push([k[f],b[h],b[g]]);t.push(e);b=m.concat(n).concat(l).concat(q)}return{shape:b, -isolatedPts:t,allpoints:d}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),d=b.allpoints,g=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),e,f,h,i,k={};e=0;for(f=d.length;e=0?h-1:b.length-1;e=f-1>=0?f-1:k.length-1;var p=[k[f],b[h],b[g]];n=THREE.FontUtils.Triangulate.area(p);var r=[k[f],k[e],b[h]];o=THREE.FontUtils.Triangulate.area(r);m=h;l=f;h+=1;f+=-1;h< +0&&(h+=b.length);h%=b.length;f<0&&(f+=k.length);f%=k.length;g=h-1>=0?h-1:b.length-1;e=f-1>=0?f-1:k.length-1;p=[k[f],b[h],b[g]];p=THREE.FontUtils.Triangulate.area(p);r=[k[f],k[e],b[h]];r=THREE.FontUtils.Triangulate.area(r);n+o>p+r&&(h=m,f=l,h<0&&(h+=b.length),h%=b.length,f<0&&(f+=k.length),f%=k.length,g=h-1>=0?h-1:b.length-1,e=f-1>=0?f-1:k.length-1);n=b.slice(0,h);o=b.slice(h);m=k.slice(f);l=k.slice(0,f);e=[k[f],k[e],b[h]];s.push([k[f],b[h],b[g]]);s.push(e);b=n.concat(m).concat(l).concat(o)}return{shape:b, +isolatedPts:s,allpoints:d}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),d=b.allpoints,g=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),e,f,h,i,k={};e=0;for(f=d.length;e1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n),d=d<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=g[0]+(e[0]-g[0])*d,b.y=g[1]+(e[1]-g[1])*d,b.z=g[2]+(e[2]-g[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",n,f.index-1).pos,this.points[1]=g,this.points[2]=e,this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos,d=d*0.33+0.33,g=this.interpolateCatmullRom(this.points,d),b.x=g[0],b.y=g[1],b.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(b=== -"rot")THREE.Quaternion.slerp(g,e,a.quaternion,d);else if(b==="scl")b=a.scale,b.x=g[0]+(e[0]-g[0])*d,b.y=g[1]+(e[1]-g[1])*d,b.z=g[2]+(e[2]-g[2])*d}}if(this.JITCompile&&l[0][k]===void 0){this.hierarchy[0].update(null,!0);for(n=0;n1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+m),d=d<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=g[0]+(e[0]-g[0])*d,b.y=g[1]+(e[1]-g[1])*d,b.z=g[2]+(e[2]-g[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",m,f.index-1).pos,this.points[1]=g,this.points[2]=e,this.points[3]=this.getNextKeyWith("pos",m,h.index+1).pos,d=d*0.33+0.33,g=this.interpolateCatmullRom(this.points,d),b.x=g[0],b.y=g[1],b.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(b=== +"rot")THREE.Quaternion.slerp(g,e,a.quaternion,d);else if(b==="scl")b=a.scale,b.x=g[0]+(e[0]-g[0])*d,b.y=g[1]+(e[1]-g[1])*d,b.z=g[2]+(e[2]-g[2])*d}}if(this.JITCompile&&l[0][k]===void 0){this.hierarchy[0].update(null,!0);for(m=0;ma.length-2?e:e+1;b[3]=e>a.length-3?e:e+2;e=a[b[0]];h=a[b[1]];i=a[b[2]];k=a[b[3]];b=g*g;f=g*b;d[0]=this.interpolate(e[0],h[0],i[0],k[0],g,b,f);d[1]=this.interpolate(e[1],h[1],i[1],k[1],g,b,f);d[2]=this.interpolate(e[2],h[2],i[2],k[2],g,b,f);return d}; THREE.Animation.prototype.interpolate=function(a,c,b,d,g,e,f){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*f+(-3*(c-b)-2*a-d)*e+a*g+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b0?b:0:b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==void 0)return d[b];return this.data.hierarchy[c].keys[d.length-1]}; @@ -452,14 +452,14 @@ function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37: this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);b=a*this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target,c=this.object.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a=1;this.constrainVertical&& (a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;c=this.object.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta); this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)}; -THREE.PathControls=function(a,c){function b(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function g(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),o=g.length,v=0;f=o-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f=0?a:a+f;c=this.verticalAngleMap.srcRange; a=this.verticalAngleMap.dstRange;c=THREE.Math.mapLinear(this.phi,c[0],c[1],a[0],a[1]);var d=a[1]-a[0];this.phi=b((c-a[0])/d)*d+a[0];c=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;c=THREE.Math.mapLinear(this.theta,c[0],c[1],a[0],a[1]);d=a[1]-a[0];this.theta=b((c-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove= function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}), c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=g(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=g(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a= -this.debugPath,b=this.spline,f=e(b,10),c=e(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),f=new THREE.Line(f,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));f.scale.set(1,1,1);a.add(f);c.scale.set(1,1,1);a.add(c);for(var f=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),n=0;n0||this.autoForward&&!(i<0)?1:i));this.object.translateX(c*k);this.object.translateY(c*l);f&&(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.y0||this.autoForward&&!(i<0)?1:i));this.object.translateX(c*k);this.object.translateY(c*l);f&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y1?d.normalize():d.z=Math.sqrt(1-e*e);f.copy(b.object.position).subSelf(b.target);e=b.object.up.clone().setLength(d.y);e.addSelf(b.object.up.clone().crossSelf(f).setLength(d.x));e.addSelf(f.setLength(d.z));return e};this.rotateCamera=function(){var a=Math.acos(h.dot(i)/h.length()/i.length());if(a){var c=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion;a*=b.rotateSpeed;d.setFromAxisAngle(c,-a);d.multiplyVector3(f); -d.multiplyVector3(b.object.up);d.multiplyVector3(i);b.staticMoving?h=i:(d.setFromAxisAngle(c,a*(b.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(l.y-k.y)*b.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),b.staticMoving?k=l:k.y+=(l.y-k.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=q.clone().subSelf(m);if(a.lengthSq()){a.multiplyScalar(f.length()*b.panSpeed);var c=f.clone().crossSelf(b.object.up).setLength(a.x);c.addSelf(b.object.up.clone().setLength(a.y)); -b.object.position.addSelf(c);b.target.addSelf(c);b.staticMoving?m=q:m.addSelf(a.sub(q,m).multiplyScalar(b.dynamicDampingFactor))}};this.checkDistances=function(){if(!b.noZoom||!b.noPan)b.object.position.lengthSq()>b.maxDistance*b.maxDistance&&b.object.position.setLength(b.maxDistance),f.lengthSq()0&&(f.multiplyScalar(a),b.staticMoving?k=l:k.y+=(l.y-k.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=o.clone().subSelf(n);if(a.lengthSq()){a.multiplyScalar(f.length()*b.panSpeed);var c=f.clone().crossSelf(b.object.up).setLength(a.x);c.addSelf(b.object.up.clone().setLength(a.y)); +b.object.position.addSelf(c);b.target.addSelf(c);b.staticMoving?n=o:n.addSelf(a.sub(o,n).multiplyScalar(b.dynamicDampingFactor))}};this.checkDistances=function(){if(!b.noZoom||!b.noPan)b.object.position.lengthSq()>b.maxDistance*b.maxDistance&&b.object.position.setLength(b.maxDistance),f.lengthSq()0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,f,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-f,0)));for(h=0;ha&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function g(a){for(C=a.length;--C>=0;){j=C;N=C-1;N<0&&(N=a.length-1);for(var b= -0,c=n+l*2,b=0;b=0;J--){$=J/l;L=i*(1-$);$=k*Math.sin($*Math.PI/2);C=0;for(O=w.length;Ca&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function g(a){for(D=a.length;--D>=0;){j=D;P=D-1;P<0&&(P=a.length-1);for(var b= +0,c=m+l*2,b=0;b=0;H--){aa=H/l;M=i*(1-aa);aa=k*Math.sin(aa*Math.PI/2);D=0;for(Q=w.length;D0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,h,q)))-1);k.push(l)}c.push(k)}for(var n,t,p,g=c.length,b=0;b0)for(d=0;d1&&(n= -this.vertices[f].position.clone(),t=this.vertices[i].position.clone(),p=this.vertices[k].position.clone(),n.normalize(),t.normalize(),p.normalize(),this.faces.push(new THREE.Face3(f,i,k,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(p.x,p.y,p.z)])),this.faceVertexUvs[0].push([l,m,o]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry=function(a,c,b){THREE.Geometry.call(this);for(var a=a||50,d,g=Math.PI,e=Math.max(3,c||8),f=Math.max(2,b||6),c=[],b=0;b0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,h,o)))-1);k.push(l)}c.push(k)}for(var m,s,p,g=c.length,b=0;b0)for(d=0;d1&&(m= +this.vertices[f].position.clone(),s=this.vertices[i].position.clone(),p=this.vertices[k].position.clone(),m.normalize(),s.normalize(),p.normalize(),this.faces.push(new THREE.Face3(f,i,k,[new THREE.Vector3(m.x,m.y,m.z),new THREE.Vector3(s.x,s.y,s.z),new THREE.Vector3(p.x,p.y,p.z)])),this.faceVertexUvs[0].push([l,n,r]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry; THREE.TextGeometry=function(a,c){var b=(new THREE.TextPath(a,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var d=b[b.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(d/2,120),new THREE.Vector2(d,0))}THREE.ExtrudeGeometry.call(this,b,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[c][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var c=this.getFace(),b=this.size/c.resolution,d= -0,g=String(a).split(""),e=g.length,f=[],a=0;a0)for(k=0;k2;){if(m--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return e}i=k;g<=i&&(i=0);k=i+1;g<=k&&(k=0);l=k+1;g<=l&&(l=0);var q;a:{q=a;var n=i,t=k,p=l,o=g,v=f,w=void 0,r=void 0,s=void 0, -u=void 0,x=void 0,H=void 0,G=void 0,F=void 0,y=void 0,r=q[v[n]].x,s=q[v[n]].y,u=q[v[t]].x,x=q[v[t]].y,H=q[v[p]].x,G=q[v[p]].y;if(1.0E-10>(u-r)*(G-s)-(x-s)*(H-r))q=!1;else{for(w=0;w=0&&J>=0&&L>=0){q=!1;break a}}q= -!0}}if(q){e.push([a[f[i]],a[f[k]],a[f[l]]]);h.push([f[i],f[k],f[l]]);i=k;for(l=k+1;l0)for(k=0;k2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return e}i=k;g<=i&&(i=0);k=i+1;g<=k&&(k=0);l=k+1;g<=l&&(l=0);var o;a:{o=a;var m=i,s=k,p=l,r=g,t=f,w=void 0,q=void 0,C=void 0, +v=void 0,x=void 0,I=void 0,K=void 0,G=void 0,y=void 0,q=o[t[m]].x,C=o[t[m]].y,v=o[t[s]].x,x=o[t[s]].y,I=o[t[p]].x,K=o[t[p]].y;if(1.0E-10>(v-q)*(K-C)-(x-C)*(I-q))o=!1;else{for(w=0;w=0&&H>=0&&M>=0){o=!1;break a}}o= +!0}}if(o){e.push([a[f[i]],a[f[k]],a[f[l]]]);h.push([f[i],f[k],f[l]]);i=k;for(l=k+1;l0;)this.smooth(a)}; -THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,d,h,i){var k=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(f.useOldVertexColors){k.vertexColors=[];for(var j,l,n,m=0;m<4;m++){n=i[m];j=new THREE.Color;j.setRGB(0,0,0);for(var o=0;o>7)-127;d|=(f&127)<<16|e<<8;if(d==0&&h==-127)return 0;return(1-2*(g>>7))*(1+d*Math.pow(2,-23))*Math.pow(2,h)}function g(a,b){var c=l(a,b),d=l(a,b+1),e=l(a,b+2);return(l(a,b+3)<<24)+(e<<16)+(d<<8)+c}function i(a,b){var c=l(a,b);return(l(a,b+1)<<8)+c}function k(a,b){var c=l(a,b);return c>127?c-256:c}function l(a,b){return a.charCodeAt(b)&255}function m(b){var c, -d,e;c=g(a,b);d=g(a,b+x);e=g(a,b+H);b=i(a,b+G);v.faces.push(new THREE.Face3(c,d,e,null,null,b))}function q(b){var c,d,e,f,j,k,l;c=g(a,b);d=g(a,b+x);e=g(a,b+H);f=i(a,b+G);j=g(a,b+F);k=g(a,b+y);l=g(a,b+C);var b=s[k*3],n=s[k*3+1];k=s[k*3+2];var m=s[l*3],o=s[l*3+1];l=s[l*3+2];v.faces.push(new THREE.Face3(c,d,e,[new THREE.Vector3(s[j*3],s[j*3+1],s[j*3+2]),new THREE.Vector3(b,n,k),new THREE.Vector3(m,o,l)],null,f))}function n(b){var c,d,e,f;c=g(a,b);d=g(a,b+O);e=g(a,b+J);f=g(a,b+$);b=i(a,b+L);v.faces.push(new THREE.Face4(c, -d,e,f,null,null,b))}function t(b){var c,d,e,f,j,k,l,n,m;c=g(a,b);d=g(a,b+O);e=g(a,b+J);f=g(a,b+$);j=i(a,b+L);k=g(a,b+P);l=g(a,b+da);n=g(a,b+ja);m=g(a,b+R);var b=s[l*3],o=s[l*3+1];l=s[l*3+2];var p=s[n*3],D=s[n*3+1];n=s[n*3+2];var q=s[m*3],r=s[m*3+1];m=s[m*3+2];v.faces.push(new THREE.Face4(c,d,e,f,[new THREE.Vector3(s[k*3],s[k*3+1],s[k*3+2]),new THREE.Vector3(b,o,l),new THREE.Vector3(p,D,n),new THREE.Vector3(q,r,m)],null,j))}function p(b){var c,d,e,f;c=g(a,b);d=g(a,b+z);e=g(a,b+B);b=u[c*2];f=u[c*2+ -1];c=u[d*2];var i=v.faceVertexUvs[0];d=u[d*2+1];var j=u[e*2];e=u[e*2+1];var k=[];k.push(new THREE.UV(b,f));k.push(new THREE.UV(c,d));k.push(new THREE.UV(j,e));i.push(k)}function o(b){var c,d,e,f,i,k;c=g(a,b);d=g(a,b+I);e=g(a,b+j);f=g(a,b+N);b=u[c*2];i=u[c*2+1];c=u[d*2];k=u[d*2+1];d=u[e*2];var l=v.faceVertexUvs[0];e=u[e*2+1];var n=u[f*2];f=u[f*2+1];var m=[];m.push(new THREE.UV(b,i));m.push(new THREE.UV(c,k));m.push(new THREE.UV(d,e));m.push(new THREE.UV(n,f));l.push(m)}var v=this,w=0,r,s=[],u=[],x, -H,G,F,y,C,O,J,$,L,P,da,ja,R,z,B,I,j,N,ga,X,Q,M,ea,U;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(v,d,b);r={signature:a.substr(w,8),header_bytes:l(a,w+8),vertex_coordinate_bytes:l(a,w+9),normal_coordinate_bytes:l(a,w+10),uv_coordinate_bytes:l(a,w+11),vertex_index_bytes:l(a,w+12),normal_index_bytes:l(a,w+13),uv_index_bytes:l(a,w+14),material_index_bytes:l(a,w+15),nvertices:g(a,w+16),nnormals:g(a,w+16+4),nuvs:g(a,w+16+8),ntri_flat:g(a,w+16+12),ntri_smooth:g(a,w+16+16),ntri_flat_uv:g(a, -w+16+20),ntri_smooth_uv:g(a,w+16+24),nquad_flat:g(a,w+16+28),nquad_smooth:g(a,w+16+32),nquad_flat_uv:g(a,w+16+36),nquad_smooth_uv:g(a,w+16+40)};w+=r.header_bytes;x=r.vertex_index_bytes;H=r.vertex_index_bytes*2;G=r.vertex_index_bytes*3;F=r.vertex_index_bytes*3+r.material_index_bytes;y=r.vertex_index_bytes*3+r.material_index_bytes+r.normal_index_bytes;C=r.vertex_index_bytes*3+r.material_index_bytes+r.normal_index_bytes*2;O=r.vertex_index_bytes;J=r.vertex_index_bytes*2;$=r.vertex_index_bytes*3;L=r.vertex_index_bytes* -4;P=r.vertex_index_bytes*4+r.material_index_bytes;da=r.vertex_index_bytes*4+r.material_index_bytes+r.normal_index_bytes;ja=r.vertex_index_bytes*4+r.material_index_bytes+r.normal_index_bytes*2;R=r.vertex_index_bytes*4+r.material_index_bytes+r.normal_index_bytes*3;z=r.uv_index_bytes;B=r.uv_index_bytes*2;I=r.uv_index_bytes;j=r.uv_index_bytes*2;N=r.uv_index_bytes*3;b=r.vertex_index_bytes*3+r.material_index_bytes;U=r.vertex_index_bytes*4+r.material_index_bytes;ga=r.ntri_flat*b;X=r.ntri_smooth*(b+r.normal_index_bytes* -3);Q=r.ntri_flat_uv*(b+r.uv_index_bytes*3);M=r.ntri_smooth_uv*(b+r.normal_index_bytes*3+r.uv_index_bytes*3);ea=r.nquad_flat*U;b=r.nquad_smooth*(U+r.normal_index_bytes*4);U=r.nquad_flat_uv*(U+r.uv_index_bytes*4);w+=function(b){for(var d,e,g,h=r.vertex_coordinate_bytes*3,i=b+r.nvertices*h;b=0){p=i.invBindMatrices[m];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p1){j=new THREE.MeshFaceMaterial;for(h=0;h>7)-127;d|=(f&127)<<16|e<<8;if(d==0&&h==-127)return 0;return(1-2*(g>>7))*(1+d*Math.pow(2,-23))*Math.pow(2,h)}function g(a,b){var c=l(a,b),d=l(a,b+1),e=l(a,b+2);return(l(a,b+3)<<24)+(e<<16)+(d<<8)+c}function i(a,b){var c=l(a,b);return(l(a,b+1)<<8)+c}function k(a,b){var c=l(a,b);return c>127?c-256:c}function l(a,b){return a.charCodeAt(b)&255}function n(b){var c, +d,e;c=g(a,b);d=g(a,b+x);e=g(a,b+I);b=i(a,b+K);t.faces.push(new THREE.Face3(c,d,e,null,null,b))}function o(b){var c,d,e,f,j,k,l;c=g(a,b);d=g(a,b+x);e=g(a,b+I);f=i(a,b+K);j=g(a,b+G);k=g(a,b+y);l=g(a,b+D);var b=C[k*3],m=C[k*3+1];k=C[k*3+2];var n=C[l*3],o=C[l*3+1];l=C[l*3+2];t.faces.push(new THREE.Face3(c,d,e,[new THREE.Vector3(C[j*3],C[j*3+1],C[j*3+2]),new THREE.Vector3(b,m,k),new THREE.Vector3(n,o,l)],null,f))}function m(b){var c,d,e,f;c=g(a,b);d=g(a,b+Q);e=g(a,b+H);f=g(a,b+aa);b=i(a,b+M);t.faces.push(new THREE.Face4(c, +d,e,f,null,null,b))}function s(b){var c,d,e,f,j,k,l,m,n;c=g(a,b);d=g(a,b+Q);e=g(a,b+H);f=g(a,b+aa);j=i(a,b+M);k=g(a,b+R);l=g(a,b+da);m=g(a,b+ja);n=g(a,b+T);var b=C[l*3],o=C[l*3+1];l=C[l*3+2];var p=C[m*3],u=C[m*3+1];m=C[m*3+2];var J=C[n*3],r=C[n*3+1];n=C[n*3+2];t.faces.push(new THREE.Face4(c,d,e,f,[new THREE.Vector3(C[k*3],C[k*3+1],C[k*3+2]),new THREE.Vector3(b,o,l),new THREE.Vector3(p,u,m),new THREE.Vector3(J,r,n)],null,j))}function p(b){var c,d,e,f;c=g(a,b);d=g(a,b+z);e=g(a,b+B);b=v[c*2];f=v[c*2+ +1];c=v[d*2];var i=t.faceVertexUvs[0];d=v[d*2+1];var j=v[e*2];e=v[e*2+1];var k=[];k.push(new THREE.UV(b,f));k.push(new THREE.UV(c,d));k.push(new THREE.UV(j,e));i.push(k)}function r(b){var c,d,e,f,i,k;c=g(a,b);d=g(a,b+L);e=g(a,b+j);f=g(a,b+P);b=v[c*2];i=v[c*2+1];c=v[d*2];k=v[d*2+1];d=v[e*2];var l=t.faceVertexUvs[0];e=v[e*2+1];var m=v[f*2];f=v[f*2+1];var n=[];n.push(new THREE.UV(b,i));n.push(new THREE.UV(c,k));n.push(new THREE.UV(d,e));n.push(new THREE.UV(m,f));l.push(n)}var t=this,w=0,q,C=[],v=[],x, +I,K,G,y,D,Q,H,aa,M,R,da,ja,T,z,B,L,j,P,fa,Z,S,O,ea,V;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(t,d,b);q={signature:a.substr(w,8),header_bytes:l(a,w+8),vertex_coordinate_bytes:l(a,w+9),normal_coordinate_bytes:l(a,w+10),uv_coordinate_bytes:l(a,w+11),vertex_index_bytes:l(a,w+12),normal_index_bytes:l(a,w+13),uv_index_bytes:l(a,w+14),material_index_bytes:l(a,w+15),nvertices:g(a,w+16),nnormals:g(a,w+16+4),nuvs:g(a,w+16+8),ntri_flat:g(a,w+16+12),ntri_smooth:g(a,w+16+16),ntri_flat_uv:g(a, +w+16+20),ntri_smooth_uv:g(a,w+16+24),nquad_flat:g(a,w+16+28),nquad_smooth:g(a,w+16+32),nquad_flat_uv:g(a,w+16+36),nquad_smooth_uv:g(a,w+16+40)};w+=q.header_bytes;x=q.vertex_index_bytes;I=q.vertex_index_bytes*2;K=q.vertex_index_bytes*3;G=q.vertex_index_bytes*3+q.material_index_bytes;y=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes;D=q.vertex_index_bytes*3+q.material_index_bytes+q.normal_index_bytes*2;Q=q.vertex_index_bytes;H=q.vertex_index_bytes*2;aa=q.vertex_index_bytes*3;M=q.vertex_index_bytes* +4;R=q.vertex_index_bytes*4+q.material_index_bytes;da=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes;ja=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*2;T=q.vertex_index_bytes*4+q.material_index_bytes+q.normal_index_bytes*3;z=q.uv_index_bytes;B=q.uv_index_bytes*2;L=q.uv_index_bytes;j=q.uv_index_bytes*2;P=q.uv_index_bytes*3;b=q.vertex_index_bytes*3+q.material_index_bytes;V=q.vertex_index_bytes*4+q.material_index_bytes;fa=q.ntri_flat*b;Z=q.ntri_smooth*(b+q.normal_index_bytes* +3);S=q.ntri_flat_uv*(b+q.uv_index_bytes*3);O=q.ntri_smooth_uv*(b+q.normal_index_bytes*3+q.uv_index_bytes*3);ea=q.nquad_flat*V;b=q.nquad_smooth*(V+q.normal_index_bytes*4);V=q.nquad_flat_uv*(V+q.uv_index_bytes*4);w+=function(b){for(var d,e,g,h=q.vertex_coordinate_bytes*3,i=b+q.nvertices*h;b=0){p=i.invBindMatrices[m];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p1){j=new THREE.MeshFaceMaterial;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(f=0;f1?c[1].substr(0,b):"0";c[1].length=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;db){k=j.output[i];break}g=k!==void 0?k instanceof THREE.Matrix4?g.multiply(g,k):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};m.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};y.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof F)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=ca[this.effect.surface.init_from]))a.map= -THREE.ImageUtils.loadTexture(ua+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=wa;return this.material=new THREE.MeshLambertMaterial(a)};C.prototype.parse=function(a){for(var b=0;b1?c[1].substr(0,b):"0";c[1].length=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;db){k=j.output[i];break}g=k!==void 0?k instanceof THREE.Matrix4?g.multiply(g,k):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix(); +return this};n.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};y.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof G)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=ca[this.effect.surface.init_from]))a.map= +THREE.ImageUtils.loadTexture(ua+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=wa;return this.material=new THREE.MeshLambertMaterial(a)};D.prototype.parse=function(a){for(var b=0;b=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b1&&($=new THREE.MeshFaceMaterial);a=new THREE.Mesh(y,$);a.name=n;a.position.set(u[0],u[1],u[2]);H?(a.quaternion.set(H[0],H[1],H[2],H[3]),a.useQuaternion=!0):a.rotation.set(x[0],x[1],x[2]);a.scale.set(G[0],G[1],G[2]);a.visible=w.visible;B.scene.add(a);B.objects[n]=a;if(w.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);B.scene.collisions.colliders.push(b)}if(w.castsShadow)b=new THREE.ShadowVolume(y),B.scene.add(b),b.position= -a.position,b.rotation=a.rotation,b.scale=a.scale;w.trigger&&w.trigger.toLowerCase()!="none"&&(b={type:w.trigger,object:w},B.triggers[a.name]=b)}}else u=w.position,x=w.rotation,H=w.quaternion,G=w.scale,H=0,a=new THREE.Object3D,a.name=n,a.position.set(u[0],u[1],u[2]),H?(a.quaternion.set(H[0],H[1],H[2],H[3]),a.useQuaternion=!0):a.rotation.set(x[0],x[1],x[2]),a.scale.set(G[0],G[1],G[2]),a.visible=w.visible!==void 0?w.visible:!1,B.scene.add(a),B.objects[n]=a,B.empties[n]=a,w.trigger&&w.trigger.toLowerCase()!= -"none"&&(b={type:w.trigger,object:w},B.triggers[a.name]=b)}function i(a){return function(c){B.geometries[a]=c;h();da-=1;b.onLoadComplete();l()}}function k(a){return function(b){B.geometries[a]=b}}function l(){b.callbackProgress({totalModels:R,totalTextures:z,loadedModels:R-da,loadedTextures:z-ja},B);b.onLoadProgress();da==0&&ja==0&&c(B)}var m,q,n,t,p,o,v,w,r,s,u,x,H,G,F,y,C,O,J,$,L,P,da,ja,R,z,B;L=a.data;J=new THREE.BinaryLoader;P=new THREE.JSONLoader;ja=da=0;B={scene:new THREE.Scene,geometries:{}, -materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(n in L.objects)if(w=L.objects[n],w.meshCollider){a=!0;break}if(a)B.scene.collisions=new THREE.CollisionSystem;if(L.transform){a=L.transform.position;r=L.transform.rotation;var I=L.transform.scale;a&&B.scene.position.set(a[0],a[1],a[2]);r&&B.scene.rotation.set(r[0],r[1],r[2]);I&&B.scene.scale.set(I[0],I[1],I[2]);(a||r||I)&&B.scene.updateMatrix()}a=function(){ja-=1;l();b.onLoadComplete()};for(p in L.cameras)r= -L.cameras[p],r.type=="perspective"?C=new THREE.PerspectiveCamera(r.fov,r.aspect,r.near,r.far):r.type=="ortho"&&(C=new THREE.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)),u=r.position,r=r.target,C.position.set(u[0],u[1],u[2]),C.target=new THREE.Vector3(r[0],r[1],r[2]),B.cameras[p]=C;for(t in L.lights)r=L.lights[t],p=r.color!==void 0?r.color:16777215,C=r.intensity!==void 0?r.intensity:1,r.type=="directional"?(u=r.direction,s=new THREE.DirectionalLight(p,C),s.position.set(u[0],u[1], -u[2]),s.position.normalize()):r.type=="point"?(u=r.position,s=r.distance,s=new THREE.PointLight(p,C,s),s.position.set(u[0],u[1],u[2])):r.type=="ambient"&&(s=new THREE.AmbientLight(p)),B.scene.add(s),B.lights[t]=s;for(o in L.fogs)t=L.fogs[o],t.type=="linear"?O=new THREE.Fog(0,t.near,t.far):t.type=="exp2"&&(O=new THREE.FogExp2(0,t.density)),r=t.color,O.color.setRGB(r[0],r[1],r[2]),B.fogs[o]=O;if(B.cameras&&L.defaults.camera)B.currentCamera=B.cameras[L.defaults.camera];if(B.fogs&&L.defaults.fog)B.scene.fog= -B.fogs[L.defaults.fog];r=L.defaults.bgcolor;B.bgColor=new THREE.Color;B.bgColor.setRGB(r[0],r[1],r[2]);B.bgColorAlpha=L.defaults.bgalpha;for(m in L.geometries)if(o=L.geometries[m],o.type=="bin_mesh"||o.type=="ascii_mesh")da+=1,b.onLoadStart();R=da;for(m in L.geometries)o=L.geometries[m],o.type=="cube"?(y=new THREE.CubeGeometry(o.width,o.height,o.depth,o.segmentsWidth,o.segmentsHeight,o.segmentsDepth,null,o.flipped,o.sides),B.geometries[m]=y):o.type=="plane"?(y=new THREE.PlaneGeometry(o.width,o.height, -o.segmentsWidth,o.segmentsHeight),B.geometries[m]=y):o.type=="sphere"?(y=new THREE.SphereGeometry(o.radius,o.segmentsWidth,o.segmentsHeight),B.geometries[m]=y):o.type=="cylinder"?(y=new THREE.CylinderGeometry(o.topRad,o.botRad,o.height,o.radSegs,o.heightSegs),B.geometries[m]=y):o.type=="torus"?(y=new THREE.TorusGeometry(o.radius,o.tube,o.segmentsR,o.segmentsT),B.geometries[m]=y):o.type=="icosahedron"?(y=new THREE.IcosahedronGeometry(o.subdivisions),B.geometries[m]=y):o.type=="bin_mesh"?J.load(d(o.url, -L.urlBaseType),i(m)):o.type=="ascii_mesh"?P.load(d(o.url,L.urlBaseType),i(m)):o.type=="embedded_mesh"&&(o=L.embeds[o.id])&&P.createModel(o,k(m),"");for(v in L.textures)if(m=L.textures[v],m.url instanceof Array){ja+=m.url.length;for(J=0;J1&&(aa=new THREE.MeshFaceMaterial);a=new THREE.Mesh(y,aa);a.name=m;a.position.set(v[0],v[1],v[2]);I?(a.quaternion.set(I[0],I[1],I[2],I[3]),a.useQuaternion=!0):a.rotation.set(x[0],x[1],x[2]);a.scale.set(K[0],K[1],K[2]);a.visible=w.visible;B.scene.add(a);B.objects[m]=a;if(w.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);B.scene.collisions.colliders.push(b)}if(w.castsShadow)b=new THREE.ShadowVolume(y),B.scene.add(b), +b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;w.trigger&&w.trigger.toLowerCase()!="none"&&(b={type:w.trigger,object:w},B.triggers[a.name]=b)}}else v=w.position,x=w.rotation,I=w.quaternion,K=w.scale,I=0,a=new THREE.Object3D,a.name=m,a.position.set(v[0],v[1],v[2]),I?(a.quaternion.set(I[0],I[1],I[2],I[3]),a.useQuaternion=!0):a.rotation.set(x[0],x[1],x[2]),a.scale.set(K[0],K[1],K[2]),a.visible=w.visible!==void 0?w.visible:!1,B.scene.add(a),B.objects[m]=a,B.empties[m]=a,w.trigger&&w.trigger.toLowerCase()!= +"none"&&(b={type:w.trigger,object:w},B.triggers[a.name]=b)}function i(a){return function(c){B.geometries[a]=c;h();da-=1;b.onLoadComplete();l()}}function k(a){return function(b){B.geometries[a]=b}}function l(){b.callbackProgress({totalModels:T,totalTextures:z,loadedModels:T-da,loadedTextures:z-ja},B);b.onLoadProgress();da==0&&ja==0&&c(B)}var n,o,m,s,p,r,t,w,q,C,v,x,I,K,G,y,D,Q,H,aa,M,R,da,ja,T,z,B;M=a.data;H=new THREE.BinaryLoader;R=new THREE.JSONLoader;ja=da=0;B={scene:new THREE.Scene,geometries:{}, +materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(m in M.objects)if(w=M.objects[m],w.meshCollider){a=!0;break}if(a)B.scene.collisions=new THREE.CollisionSystem;if(M.transform){a=M.transform.position;q=M.transform.rotation;var L=M.transform.scale;a&&B.scene.position.set(a[0],a[1],a[2]);q&&B.scene.rotation.set(q[0],q[1],q[2]);L&&B.scene.scale.set(L[0],L[1],L[2]);(a||q||L)&&B.scene.updateMatrix()}a=function(){ja-=1;l();b.onLoadComplete()};for(p in M.cameras)q= +M.cameras[p],q.type=="perspective"?D=new THREE.PerspectiveCamera(q.fov,q.aspect,q.near,q.far):q.type=="ortho"&&(D=new THREE.OrthographicCamera(q.left,q.right,q.top,q.bottom,q.near,q.far)),v=q.position,q=q.target,D.position.set(v[0],v[1],v[2]),D.target=new THREE.Vector3(q[0],q[1],q[2]),B.cameras[p]=D;for(s in M.lights)q=M.lights[s],p=q.color!==void 0?q.color:16777215,D=q.intensity!==void 0?q.intensity:1,q.type=="directional"?(v=q.direction,C=new THREE.DirectionalLight(p,D),C.position.set(v[0],v[1], +v[2]),C.position.normalize()):q.type=="point"?(v=q.position,C=q.distance,C=new THREE.PointLight(p,D,C),C.position.set(v[0],v[1],v[2])):q.type=="ambient"&&(C=new THREE.AmbientLight(p)),B.scene.add(C),B.lights[s]=C;for(r in M.fogs)s=M.fogs[r],s.type=="linear"?Q=new THREE.Fog(0,s.near,s.far):s.type=="exp2"&&(Q=new THREE.FogExp2(0,s.density)),q=s.color,Q.color.setRGB(q[0],q[1],q[2]),B.fogs[r]=Q;if(B.cameras&&M.defaults.camera)B.currentCamera=B.cameras[M.defaults.camera];if(B.fogs&&M.defaults.fog)B.scene.fog= +B.fogs[M.defaults.fog];q=M.defaults.bgcolor;B.bgColor=new THREE.Color;B.bgColor.setRGB(q[0],q[1],q[2]);B.bgColorAlpha=M.defaults.bgalpha;for(n in M.geometries)if(r=M.geometries[n],r.type=="bin_mesh"||r.type=="ascii_mesh")da+=1,b.onLoadStart();T=da;for(n in M.geometries)r=M.geometries[n],r.type=="cube"?(y=new THREE.CubeGeometry(r.width,r.height,r.depth,r.segmentsWidth,r.segmentsHeight,r.segmentsDepth,null,r.flipped,r.sides),B.geometries[n]=y):r.type=="plane"?(y=new THREE.PlaneGeometry(r.width,r.height, +r.segmentsWidth,r.segmentsHeight),B.geometries[n]=y):r.type=="sphere"?(y=new THREE.SphereGeometry(r.radius,r.segmentsWidth,r.segmentsHeight),B.geometries[n]=y):r.type=="cylinder"?(y=new THREE.CylinderGeometry(r.topRad,r.botRad,r.height,r.radSegs,r.heightSegs),B.geometries[n]=y):r.type=="torus"?(y=new THREE.TorusGeometry(r.radius,r.tube,r.segmentsR,r.segmentsT),B.geometries[n]=y):r.type=="icosahedron"?(y=new THREE.IcosahedronGeometry(r.subdivisions),B.geometries[n]=y):r.type=="bin_mesh"?H.load(d(r.url, +M.urlBaseType),i(n)):r.type=="ascii_mesh"?R.load(d(r.url,M.urlBaseType),i(n)):r.type=="embedded_mesh"&&(r=M.embeds[r.id])&&R.createModel(r,k(n),"");for(t in M.textures)if(n=M.textures[t],n.url instanceof Array){ja+=n.url.length;for(H=0;H=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),d=1,g=0;g<8;g++){for(var e=0,f=0;f>1^-(h&1);b[8*f+g]=e}d+=c}c=a.length-d;e=new Uint16Array(c);for(g=f=0;g=this.maxCount-3&&h(this)};this.begin= -function(){this.count=0;this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!==0){for(var c=this.count*3;cthis.size-1&&(i=this.size-1);var q=Math.floor(k-h);q<1&&(q=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var n=Math.floor(l-h);n<1&&(n=1);h=Math.floor(l+h); -h>this.size-1&&(h=this.size-1);for(var t,p,o,v,w,r;m0&&(this.field[o+t]+=v)}}};this.addPlaneX=function(a,c){var g,e,f,h,i,k=this.size,l=this.yd,m=this.zd,q=this.field,n=k*Math.sqrt(a/c);n>k&&(n=k);for(g=0;g0)for(e=0;el&&(t=l);for(e=0;e0){i=e*m;for(g=0;gl&&(t=l);for(f=0;f0){i=q*f;for(e=0;ethis.size-1&&(i=this.size-1);var o=Math.floor(k-h);o<1&&(o=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var m=Math.floor(l-h);m<1&&(m=1);h=Math.floor(l+h); +h>this.size-1&&(h=this.size-1);for(var s,p,r,t,w,q;n0&&(this.field[r+s]+=t)}}};this.addPlaneX=function(a,c){var g,e,f,h,i,k=this.size,l=this.yd,n=this.zd,o=this.field,m=k*Math.sqrt(a/c);m>k&&(m=k);for(g=0;g0)for(e=0;el&&(s=l);for(e=0;e0){i=e*n;for(g=0;gl&&(s=l);for(f=0;f0){i=o*f;for(e=0;ec.max.z)return Number.MAX_VALUE;c.normal.set(0,h,0);break;case THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq=0)return Math.abs(d)-Math.sqrt(b);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var c=a.geometry.boundingBox,b=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c}; THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var c=this,b=this.setSize,d=this.render,g=new THREE.PerspectiveCamera,e=new THREE.PerspectiveCamera,f=new THREE.Matrix4,h=new THREE.Matrix4,i,k,l,m;g.matrixAutoUpdate=e.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},q=new THREE.WebGLRenderTarget(512,512,a),n=new THREE.WebGLRenderTarget(512,512,a),t=new THREE.PerspectiveCamera(53, -1,1,1E4);t.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:q},mapRight:{type:"t",value:1,texture:n}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}), -p=new THREE.Scene;p.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));p.add(t);this.setSize=function(a,d){b.call(c,a,d);q.width=a;q.height=d;n.width=a;n.height=d};this.render=function(a,b){a.updateMatrixWorld();if(i!==b.aspect||k!==b.near||l!==b.far||m!==b.fov){i=b.aspect;k=b.near;l=b.far;m=b.fov;var w=b.projectionMatrix.clone(),r=125/30*0.5,s=r*k/125,u=k*Math.tan(m*Math.PI/360),x;f.n14=r;h.n14=-r;r=-u*i+s;x=u*i+s;w.n11=2*k/(x-r);w.n13=(x+r)/(x-r);g.projectionMatrix.copy(w);r=-u*i-s;x=u*i-s;w.n11= -2*k/(x-r);w.n13=(x+r)/(x-r);e.projectionMatrix.copy(w)}g.matrixWorld.copy(b.matrixWorld).multiplySelf(h);g.position.copy(b.position);g.near=b.near;g.far=b.far;d.call(c,a,g,q,!0);e.matrixWorld.copy(b.matrixWorld).multiplySelf(f);e.position.copy(b.position);e.near=b.near;e.far=b.far;d.call(c,a,e,n,!0);p.updateMatrixWorld();d.call(c,p,t)}}; +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var c=this,b=this.setSize,d=this.render,g=new THREE.PerspectiveCamera,e=new THREE.PerspectiveCamera,f=new THREE.Matrix4,h=new THREE.Matrix4,i,k,l,n;g.matrixAutoUpdate=e.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},o=new THREE.WebGLRenderTarget(512,512,a),m=new THREE.WebGLRenderTarget(512,512,a),s=new THREE.PerspectiveCamera(53, +1,1,1E4);s.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:o},mapRight:{type:"t",value:1,texture:m}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}), +p=new THREE.Scene;p.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));p.add(s);this.setSize=function(a,d){b.call(c,a,d);o.width=a;o.height=d;m.width=a;m.height=d};this.render=function(a,b){a.updateMatrixWorld();if(i!==b.aspect||k!==b.near||l!==b.far||n!==b.fov){i=b.aspect;k=b.near;l=b.far;n=b.fov;var w=b.projectionMatrix.clone(),q=125/30*0.5,C=q*k/125,v=k*Math.tan(n*Math.PI/360),x;f.n14=q;h.n14=-q;q=-v*i+C;x=v*i+C;w.n11=2*k/(x-q);w.n13=(x+q)/(x-q);g.projectionMatrix.copy(w);q=-v*i-C;x=v*i-C;w.n11= +2*k/(x-q);w.n13=(x+q)/(x-q);e.projectionMatrix.copy(w)}g.matrixWorld.copy(b.matrixWorld).multiplySelf(h);g.position.copy(b.position);g.near=b.near;g.far=b.far;d.call(c,a,g,o,!0);e.matrixWorld.copy(b.matrixWorld).multiplySelf(f);e.position.copy(b.position);e.near=b.near;e.far=b.far;d.call(c,a,e,m,!0);p.updateMatrixWorld();d.call(c,p,s)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,d=this.render,g,e,f=new THREE.PerspectiveCamera;f.target=new THREE.Vector3(0,0,0);var h=new THREE.PerspectiveCamera;h.target=new THREE.Vector3(0,0,0);c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;this.setSize=function(a,d){b.call(c,a,d);g=a/2;e=d};this.render=function(a,b){this.clear();f.fov=b.fov;f.aspect=0.5*b.aspect;f.near=b.near;f.far= b.far;f.updateProjectionMatrix();f.position.copy(b.position);f.target.copy(b.target);f.translateX(c.separation);f.lookAt(f.target);h.projectionMatrix=f.projectionMatrix;h.position.copy(b.position);h.target.copy(b.target);h.translateX(-c.separation);h.lookAt(h.target);this.setViewport(0,0,g,e);d.call(c,a,f);this.setViewport(g,0,g,e);d.call(c,a,h,!1)}}; diff --git a/build/custom/ThreeCanvas.js b/build/custom/ThreeCanvas.js index de6f7973..300b3506 100644 --- a/build/custom/ThreeCanvas.js +++ b/build/custom/ThreeCanvas.js @@ -13,39 +13,39 @@ cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y Math.abs(b)>1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b),this.z=Math.atan2(-a.n12/b,a.n11/b)):(this.x=0,this.z=Math.atan2(a.n21,a.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, -normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.children)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b=0&&o>=0&&p+o<1}for(var d=new THREE.Vector3,f=new THREE.Vector3,e=new THREE.Vector3,g,h,l,n,j,i,p,o,m,k=[],r=0,H=a.children.length;ra.scale.x)return[];m={distance:r,point:a.position, -face:null,object:a};k.push(m)}else if(a instanceof THREE.Mesh){r=b(this.origin,this.direction,a.matrixWorld.getPosition());if(r===null||r>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return k;var E,L,M,t,F,w,x,u,s=a.geometry,B=s.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);r=0;for(H=s.faces.length;r0:w<0)))if(w=F.dot((new THREE.Vector3).sub(E,x))/w,x=x.addSelf(u.multiplyScalar(w)),m instanceof THREE.Face3)c(x,E,L,M)&&(m={distance:this.origin.distanceTo(x),point:x,face:m,object:a}, -k.push(m));else if(m instanceof THREE.Face4&&(c(x,E,L,t)||c(x,L,M,t)))m={distance:this.origin.distanceTo(x),point:x,face:m,object:a},k.push(m)}return k}}; -THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,j,i){h=!1;b=e;c=g;d=j;f=i;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=be?d:e,f=f>g?f:g);a()};this.add3Points= -function(e,g,j,i,p,o){h?(h=!1,b=ej?e>p?e:p:j>p?j:p,f=g>i?g>o?g:o:i>o?i:o):(b=ej?e>p?e>d?e:d:p>d?p:d:j>p?j>d?j:d:p>d?p:d,f=g>i?g>o?g>f?g:f:o>f?o:f:i>o?i>f?i:f:o>f?o:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> +normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}}; +THREE.Ray=function(a,b){function c(a,b,c){var d;d=c.clone().subSelf(a).dot(b);if(d<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function d(a,b,c,d){n.copy(d).subSelf(b);i.copy(c).subSelf(b);j.copy(a).subSelf(b);m=n.dot(n);o=n.dot(i);q=n.dot(j);k=i.dot(i);s=i.dot(j);H=1/(m*k-o*o);E=(k*q-o*s)*H;M=(m*s-o*q)*H;return E>=0&&M>=0&&E+M<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)}; +this.intersectObjects=function(a){var b,c,d=[];b=0;for(c=a.length;ba.scale.x)return[];b={distance:i,point:a.position,face:null,object:a};n.push(b)}else if(a instanceof THREE.Mesh){i=c(this.origin,this.direction,a.matrixWorld.getPosition());if(i===null||i>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return n;var o,j,m,q,W=a.geometry,Y=W.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);i=0;for(k=W.faces.length;i0:o<0)))if(j=l.dot((new THREE.Vector3).sub(f,m))/o,m=m.addSelf(q.multiplyScalar(j)), +b instanceof THREE.Face3)d(m,f,e,g)&&(b={distance:this.origin.distanceTo(m),point:m,face:b,object:a},n.push(b));else if(b instanceof THREE.Face4&&(d(m,f,e,h)||d(m,e,g,h)))b={distance:this.origin.distanceTo(m),point:m,face:b,object:a},n.push(b)}return n};var n=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,m,o,q,k,s,H,E,M}; +THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,i,j){h=!1;b=e;c=g;d=i;f=j;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=be?d:e,f=f>g?f:g);a()};this.add3Points= +function(e,g,i,j,m,o){h?(h=!1,b=ei?e>m?e:m:i>m?i:m,f=g>j?g>o?g:o:j>o?j:o):(b=ei?e>m?e>d?e:d:m>d?m:d:i>m?i>d?i:d:m>d?m:d,f=g>j?g>o?g>f?g:f:o>f?o:f:j>o?j>f?j:f:o>f?o:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> e.getBottom()?f:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;f+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;f=d=c=b=0;a()};this.isEmpty=function(){return h}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dg&&h.positionScreen.z0&&w.z<1))g=M[L]=M[L]||new THREE.RenderableParticle,L++,E=g,E.x=w.x/w.w,E.y=w.y/w.w,E.z=w.z,E.rotation=G.rotation.z,E.scale.x=G.scale.x*Math.abs(E.x-(w.x+e.projectionMatrix.n11)/(w.w+e.projectionMatrix.n14)),E.scale.y=G.scale.y*Math.abs(E.y-(w.y+e.projectionMatrix.n22)/(w.w+e.projectionMatrix.n24)),E.material=G.material,t.elements.push(E);f&&t.elements.sort(c); -return t}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; +i,j,m=[],o,q=[],k,s,H=[],E,M,Q=[],z={objects:[],sprites:[],lights:[],elements:[]},A=new THREE.Vector3,C=new THREE.Vector4,F=new THREE.Matrix4,u=new THREE.Matrix4,r=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],D=new THREE.Vector4,K=new THREE.Vector4;this.computeFrustum=function(a){r[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);r[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);r[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+ +a.n23,a.n44+a.n24);r[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);r[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);r[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;a<6;a++){var b=r[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);F.multiply(b.projectionMatrix,b.matrixWorldInverse);F.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix); +F.multiply(b.matrixWorld,b.projectionMatrixInverse);F.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){e=0;z.objects.length=0;z.sprites.length=0;z.lights.length=0;var g=function(b){if(b.visible!==!1){var c;if(c=b instanceof THREE.Mesh||b instanceof THREE.Line)if(!(c=b.frustumCulled===!1))a:{for(var d=b.matrixWorld, +e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),h=0;h<6;h++)if(c=r[h].x*d.n14+r[h].y*d.n24+r[h].z*d.n34+r[h].w,c<=e){c=!1;break a}c=!0}c?(F.multiplyVector3(A.copy(b.position)),f=a(),f.object=b,f.z=A.z,z.objects.push(f)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(F.multiplyVector3(A.copy(b.position)),f=a(),f.object=b,f.z=A.z,z.sprites.push(f)):b instanceof THREE.Light&&z.lights.push(b);c=0;for(d=b.children.length;cg&&h.positionScreen.z0&&C.z<1))g=Q[M]=Q[M]||new THREE.RenderableParticle,M++,E=g,E.x=C.x/C.w,E.y=C.y/C.w,E.z=C.z,E.rotation=G.rotation.z,E.scale.x=G.scale.x*Math.abs(E.x-(C.x+e.projectionMatrix.n11)/(C.w+e.projectionMatrix.n14)),E.scale.y=G.scale.y*Math.abs(E.y-(C.y+e.projectionMatrix.n22)/(C.w+e.projectionMatrix.n24)),E.material=G.material,z.elements.push(E); +f&&z.elements.sort(c);return z}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),e=Math.cos(c),c=Math.sin(c),g=a*b,h=d*f;this.w=g*e-h*c;this.x=g*c+h*e;this.y=d*b*e+a*f*c;this.z=a*f*e-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= -this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=this.y,h=this.z,l=this.w,n=l*c+g*f-h*d,j=l*d+h*c-e*f,i=l*f+e*d-g*c,c=-e* -c-g*d-h*f;b.x=n*l+c*-e+j*-h-i*-g;b.y=j*l+c*-g+i*-e-n*-h;b.z=i*l+c*-h+n*-g-j*-e;return b}}; +this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=this.y,h=this.z,l=this.w,n=l*c+g*f-h*d,i=l*d+h*c-e*f,j=l*f+e*d-g*c,c=-e* +c-g*d-h*f;b.x=n*l+c*-e+i*-h-j*-g;b.y=i*l+c*-g+j*-e-n*-h;b.z=j*l+c*-h+n*-g-i*-e;return b}}; THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*e)/f;d=Math.sin(d*e)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,f,e,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; @@ -82,9 +82,9 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid c,d,f,e,g,h=new THREE.Vector3,l=new THREE.Vector3;d=0;for(f=this.faces.length;d0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, +c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,e,f,F){h=a.vertices[b].position;l=a.vertices[c].position;n=a.vertices[d].position;i=g[e];j=g[f];m=g[F];o=l.x-h.x;q=n.x-h.x;k=l.y-h.y;s=n.y-h.y;H=l.z-h.z;E=n.z-h.z;M=j.u-i.u;Q=m.u-i.u;z=j.v-i.v;A=m.v-i.v;C=1/(M*A-Q*z);D.set((A*o-z*q)*C,(A*k-z*s)*C,(A*H-z*E)*C);K.set((M*q-Q*o)*C,(M*s-Q*k)*C,(M*E-Q*H)*C);u[b].addSelf(D);u[c].addSelf(D);u[d].addSelf(D);r[b].addSelf(K); +r[c].addSelf(K);r[d].addSelf(K)}var b,c,d,f,e,g,h,l,n,i,j,m,o,q,k,s,H,E,M,Q,z,A,C,F,u=[],r=[],D=new THREE.Vector3,K=new THREE.Vector3,W=new THREE.Vector3,Y=new THREE.Vector3,N=new THREE.Vector3;b=0;for(c=this.vertices.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b0&&(c(THREE.NormalBlending),b(1),f("rgba("+Math.floor(r.r*255)+","+Math.floor(r.g*255)+","+Math.floor(r.b*255)+","+H+")"),k.fillRect(Math.floor(Y.getX()), -Math.floor(Y.getY()),Math.floor(Y.getWidth()),Math.floor(Y.getHeight()))),Y.empty())};this.render=function(a,j){function i(a){var b,c,d,e;Z.setRGB(0,0,0);sa.setRGB(0,0,0);ta.setRGB(0,0,0);b=0;for(c=a.length;b>1,n=i.height>> -1,g=e.scale.x*o,l=e.scale.y*m,h=g*q,j=l*n,W.set(a.x-h,a.y-j,a.x+h,a.y+j),la.intersects(W)&&(k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(g,-l),k.translate(-q,-n),k.drawImage(i,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*o,j=e.scale.y*m,W.set(a.x-h,a.y-j,a.x+h,a.y+j),la.intersects(W)&&(d(g.color.getContextStyle()),f(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(h,j),g.program(k),k.restore()))}function t(a,e, -f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(F!=a)k.lineWidth=F=a;a=g.linecap;if(w!=a)k.lineCap=w=a;a=g.linejoin;if(x!=a)k.lineJoin=x=a;d(g.color.getContextStyle());k.stroke();W.inflate(g.linewidth*2)}}function E(a,d,f,g,h,k,i,q){e.info.render.vertices+=3;e.info.render.faces++;b(q.opacity);c(q.blending);O=a.positionScreen.x;Q=a.positionScreen.y; -T=d.positionScreen.x;X=d.positionScreen.y;I=f.positionScreen.x;D=f.positionScreen.y;H(O,Q,T,X,I,D);if(q instanceof THREE.MeshBasicMaterial)if(q.map)q.map.mapping instanceof THREE.UVMapping&&(ba=i.uvs[0],za(O,Q,T,X,I,D,ba[g].u,ba[g].v,ba[h].u,ba[h].v,ba[k].u,ba[k].v,q.map));else if(q.envMap){if(q.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=j.matrixWorldInverse,S.copy(i.vertexNormalsWorld[g]),Aa=(S.x*a.n11+S.y*a.n12+S.z*a.n13)*0.5+0.5,Ba=-(S.x*a.n21+S.y*a.n22+S.z*a.n23)*0.5+0.5,S.copy(i.vertexNormalsWorld[h]), -Ca=(S.x*a.n11+S.y*a.n12+S.z*a.n13)*0.5+0.5,Da=-(S.x*a.n21+S.y*a.n22+S.z*a.n23)*0.5+0.5,S.copy(i.vertexNormalsWorld[k]),Ea=(S.x*a.n11+S.y*a.n12+S.z*a.n13)*0.5+0.5,Fa=-(S.x*a.n21+S.y*a.n22+S.z*a.n23)*0.5+0.5,za(O,Q,T,X,I,D,Aa,Ba,Ca,Da,Ea,Fa,q.envMap)}else q.wireframe?ha(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshLambertMaterial)q.map&&!q.wireframe&&(q.map.mapping instanceof THREE.UVMapping&&(ba=i.uvs[0],za(O,Q,T,X,I,D,ba[g].u,ba[g].v, -ba[h].u,ba[h].v,ba[k].u,ba[k].v,q.map)),c(THREE.SubtractiveBlending)),xa?!q.wireframe&&q.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3?(C.r=z.r=A.r=Z.r,C.g=z.g=A.g=Z.g,C.b=z.b=A.b=Z.b,p(l,i.v1.positionWorld,i.vertexNormalsWorld[0],C),p(l,i.v2.positionWorld,i.vertexNormalsWorld[1],z),p(l,i.v3.positionWorld,i.vertexNormalsWorld[2],A),C.r=Math.max(0,Math.min(q.color.r*C.r,1)),C.g=Math.max(0,Math.min(q.color.g*C.g,1)),C.b=Math.max(0,Math.min(q.color.b*C.b,1)),z.r=Math.max(0,Math.min(q.color.r* -z.r,1)),z.g=Math.max(0,Math.min(q.color.g*z.g,1)),z.b=Math.max(0,Math.min(q.color.b*z.b,1)),A.r=Math.max(0,Math.min(q.color.r*A.r,1)),A.g=Math.max(0,Math.min(q.color.g*A.g,1)),A.b=Math.max(0,Math.min(q.color.b*A.b,1)),J.r=(z.r+A.r)*0.5,J.g=(z.g+A.g)*0.5,J.b=(z.b+A.b)*0.5,fa=va(C,z,A,J),na(O,Q,T,X,I,D,0,0,1,0,0,1,fa)):(v.r=Z.r,v.g=Z.g,v.b=Z.b,p(l,i.centroidWorld,i.normalWorld,v),v.r=Math.max(0,Math.min(q.color.r*v.r,1)),v.g=Math.max(0,Math.min(q.color.g*v.g,1)),v.b=Math.max(0,Math.min(q.color.b*v.b, -1)),q.wireframe?ha(v,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(v)):q.wireframe?ha(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshDepthMaterial)$=j.near,ga=j.far,C.r=C.g=C.b=1-ma(a.positionScreen.z,$,ga),z.r=z.g=z.b=1-ma(d.positionScreen.z,$,ga),A.r=A.g=A.b=1-ma(f.positionScreen.z,$,ga),J.r=(z.r+A.r)*0.5,J.g=(z.g+A.g)*0.5,J.b=(z.b+A.b)*0.5,fa=va(C,z,A,J),na(O,Q,T,X,I,D,0,0,1,0,0,1,fa);else if(q instanceof THREE.MeshNormalMaterial)v.r= -oa(i.normalWorld.x),v.g=oa(i.normalWorld.y),v.b=oa(i.normalWorld.z),q.wireframe?ha(v,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(v)}function L(a,d,f,g,h,k,i,q,n){e.info.render.vertices+=4;e.info.render.faces++;b(q.opacity);c(q.blending);if(q.map||q.envMap)E(a,d,g,0,1,3,i,q,n),E(h,f,k,1,2,3,i,q,n);else if(O=a.positionScreen.x,Q=a.positionScreen.y,T=d.positionScreen.x,X=d.positionScreen.y,I=f.positionScreen.x,D=f.positionScreen.y,R=g.positionScreen.x,y=g.positionScreen.y,P=h.positionScreen.x, -N=h.positionScreen.y,V=k.positionScreen.x,G=k.positionScreen.y,q instanceof THREE.MeshBasicMaterial)M(O,Q,T,X,I,D,R,y),q.wireframe?ha(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color);else if(q instanceof THREE.MeshLambertMaterial)xa?!q.wireframe&&q.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==4?(C.r=z.r=A.r=J.r=Z.r,C.g=z.g=A.g=J.g=Z.g,C.b=z.b=A.b=J.b=Z.b,p(l,i.v1.positionWorld,i.vertexNormalsWorld[0],C),p(l,i.v2.positionWorld,i.vertexNormalsWorld[1],z), -p(l,i.v4.positionWorld,i.vertexNormalsWorld[3],A),p(l,i.v3.positionWorld,i.vertexNormalsWorld[2],J),C.r=Math.max(0,Math.min(q.color.r*C.r,1)),C.g=Math.max(0,Math.min(q.color.g*C.g,1)),C.b=Math.max(0,Math.min(q.color.b*C.b,1)),z.r=Math.max(0,Math.min(q.color.r*z.r,1)),z.g=Math.max(0,Math.min(q.color.g*z.g,1)),z.b=Math.max(0,Math.min(q.color.b*z.b,1)),A.r=Math.max(0,Math.min(q.color.r*A.r,1)),A.g=Math.max(0,Math.min(q.color.g*A.g,1)),A.b=Math.max(0,Math.min(q.color.b*A.b,1)),J.r=Math.max(0,Math.min(q.color.r* -J.r,1)),J.g=Math.max(0,Math.min(q.color.g*J.g,1)),J.b=Math.max(0,Math.min(q.color.b*J.b,1)),fa=va(C,z,A,J),H(O,Q,T,X,R,y),na(O,Q,T,X,R,y,0,0,1,0,0,1,fa),H(P,N,I,D,V,G),na(P,N,I,D,V,G,1,0,1,1,0,1,fa)):(v.r=Z.r,v.g=Z.g,v.b=Z.b,p(l,i.centroidWorld,i.normalWorld,v),v.r=Math.max(0,Math.min(q.color.r*v.r,1)),v.g=Math.max(0,Math.min(q.color.g*v.g,1)),v.b=Math.max(0,Math.min(q.color.b*v.b,1)),M(O,Q,T,X,I,D,R,y),q.wireframe?ha(v,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(v)):(M(O,Q,T, -X,I,D,R,y),q.wireframe?ha(q.color,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(q.color));else if(q instanceof THREE.MeshNormalMaterial)v.r=oa(i.normalWorld.x),v.g=oa(i.normalWorld.y),v.b=oa(i.normalWorld.z),M(O,Q,T,X,I,D,R,y),q.wireframe?ha(v,q.wireframeLinewidth,q.wireframeLinecap,q.wireframeLinejoin):ia(v);else if(q instanceof THREE.MeshDepthMaterial)$=j.near,ga=j.far,C.r=C.g=C.b=1-ma(a.positionScreen.z,$,ga),z.r=z.g=z.b=1-ma(d.positionScreen.z,$,ga),A.r=A.g=A.b=1-ma(g.positionScreen.z, -$,ga),J.r=J.g=J.b=1-ma(f.positionScreen.z,$,ga),fa=va(C,z,A,J),H(O,Q,T,X,R,y),na(O,Q,T,X,R,y,0,0,1,0,0,1,fa),H(P,N,I,D,V,G),na(P,N,I,D,V,G,1,0,1,1,0,1,fa)}function H(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function M(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function ha(a,b,c,e){if(F!=b)k.lineWidth=F=b;if(w!=c)k.lineCap=w=c;if(x!=e)k.lineJoin=x=e;d(a.getContextStyle()); -k.stroke();W.inflate(b*2)}function ia(a){f(a.getContextStyle());k.fill()}function za(a,b,c,d,e,g,h,j,i,l,n,o,m){if(m.image.width!=0){if(m.needsUpdate==!0||ka[m.id]==void 0){var p=m.wrapS==THREE.RepeatWrapping,r=m.wrapT==THREE.RepeatWrapping;ka[m.id]=k.createPattern(m.image,p&&r?"repeat":p&&!r?"repeat-x":!p&&r?"repeat-y":"no-repeat");m.needsUpdate=!1}f(ka[m.id]);var p=m.offset.x/m.repeat.x,r=m.offset.y/m.repeat.y,s=(m.image.width-1)*m.repeat.x,m=(m.image.height-1)*m.repeat.y,h=(h+p)*s,j=(j+r)*m,i= -(i+p)*s,l=(l+r)*m,n=(n+p)*s,o=(o+r)*m;c-=a;d-=b;e-=a;g-=b;i-=h;l-=j;n-=h;o-=j;p=1/(i*o-n*l);m=(o*c-l*e)*p;l=(o*d-l*g)*p;c=(i*e-n*c)*p;d=(i*g-n*d)*p;a=a-m*h-c*j;b=b-l*h-d*j;k.save();k.transform(m,l,c,d,a,b);k.fill();k.restore()}}function na(a,b,c,d,e,f,g,h,j,i,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;j*=o;i*=p;l*=o;m*=p;c-=a;d-=b;e-=a;f-=b;j-=g;i-=h;l-=g;m-=h;p=1/(j*m-l*i);o=(m*c-i*e)*p;i=(m*d-i*f)*p;c=(j*e-l*c)*p;d=(j*f-l*d)*p;a=a-o*g-c*h;b=b-i*g-d*h;k.save();k.transform(o,i,c,d,a,b);k.clip(); +THREE.CanvasRenderer=function(a){function b(a){if(E!=a)k.globalAlpha=E=a}function c(a){if(M!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}M=a}}function d(a){if(Q!=a)k.strokeStyle=Q=a}function f(a){if(z!=a)k.fillStyle=z=a}var e=this,g,h,l,n=new THREE.Projector,a=a||{},i=a.canvas!==void 0?a.canvas:document.createElement("canvas"), +j,m,o,q,k=i.getContext("2d"),s=new THREE.Color(0),H=0,E=1,M=0,Q=null,z=null,A=null,C=null,F=null,u,r,D,K,W=new THREE.RenderableVertex,Y=new THREE.RenderableVertex,N,P,T,U,I,B,R,v,O,L,oa,G,t=new THREE.Color,y=new THREE.Color,w=new THREE.Color,x=new THREE.Color,J=new THREE.Color,ja=[],aa,fa,ea,ba,Aa,Ba,Ca,Da,Ea,Fa,ka=new THREE.Rectangle,Z=new THREE.Rectangle,X=new THREE.Rectangle,xa=!1,$=new THREE.Color,sa=new THREE.Color,ta=new THREE.Color,S=new THREE.Vector3,pa,qa,ya,ca,ra,ua,a=16;pa=document.createElement("canvas"); +pa.width=pa.height=2;qa=pa.getContext("2d");qa.fillStyle="rgba(0,0,0,1)";qa.fillRect(0,0,2,2);ya=qa.getImageData(0,0,2,2);ca=ya.data;ra=document.createElement("canvas");ra.width=ra.height=a;ua=ra.getContext("2d");ua.translate(-a/2,-a/2);ua.scale(a,a);a--;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){j=a;m=b;o=Math.floor(j/2);q=Math.floor(m/2);i.width=j;i.height=m;ka.set(-o,-q,o,q);Z.set(-o,-q,o,q);E=1;M=0; +F=C=A=z=Q=null};this.setClearColor=function(a,b){s.copy(a);H=b;Z.set(-o,-q,o,q)};this.setClearColorHex=function(a,b){s.setHex(a);H=b;Z.set(-o,-q,o,q)};this.clear=function(){k.setTransform(1,0,0,-1,o,q);Z.isEmpty()||(Z.minSelf(ka),Z.inflate(2),H<1&&k.clearRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight())),H>0&&(c(THREE.NormalBlending),b(1),f("rgba("+Math.floor(s.r*255)+","+Math.floor(s.g*255)+","+Math.floor(s.b*255)+","+H+")"),k.fillRect(Math.floor(Z.getX()), +Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight()))),Z.empty())};this.render=function(a,i){function j(a){var b,c,d,e;$.setRGB(0,0,0);sa.setRGB(0,0,0);ta.setRGB(0,0,0);b=0;for(c=a.length;b>1,n=j.height>> +1,g=e.scale.x*o,l=e.scale.y*q,h=g*p,i=l*n,X.set(a.x-h,a.y-i,a.x+h,a.y+i),ka.intersects(X)&&(k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(g,-l),k.translate(-p,-n),k.drawImage(j,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*o,i=e.scale.y*q,X.set(a.x-h,a.y-i,a.x+h,a.y+i),ka.intersects(X)&&(d(g.color.getContextStyle()),f(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(h,i),g.program(k),k.restore()))}function z(a,e, +f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(A!=a)k.lineWidth=A=a;a=g.linecap;if(C!=a)k.lineCap=C=a;a=g.linejoin;if(F!=a)k.lineJoin=F=a;d(g.color.getContextStyle());k.stroke();X.inflate(g.linewidth*2)}}function E(a,d,f,g,h,k,j,p){e.info.render.vertices+=3;e.info.render.faces++;b(p.opacity);c(p.blending);N=a.positionScreen.x;P=a.positionScreen.y; +T=d.positionScreen.x;U=d.positionScreen.y;I=f.positionScreen.x;B=f.positionScreen.y;H(N,P,T,U,I,B);if(p instanceof THREE.MeshBasicMaterial)if(p.map)p.map.mapping instanceof THREE.UVMapping&&(ba=j.uvs[0],za(N,P,T,U,I,B,ba[g].u,ba[g].v,ba[h].u,ba[h].v,ba[k].u,ba[k].v,p.map));else if(p.envMap){if(p.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=i.matrixWorldInverse,S.copy(j.vertexNormalsWorld[g]),Aa=(S.x*a.n11+S.y*a.n12+S.z*a.n13)*0.5+0.5,Ba=-(S.x*a.n21+S.y*a.n22+S.z*a.n23)*0.5+0.5,S.copy(j.vertexNormalsWorld[h]), +Ca=(S.x*a.n11+S.y*a.n12+S.z*a.n13)*0.5+0.5,Da=-(S.x*a.n21+S.y*a.n22+S.z*a.n23)*0.5+0.5,S.copy(j.vertexNormalsWorld[k]),Ea=(S.x*a.n11+S.y*a.n12+S.z*a.n13)*0.5+0.5,Fa=-(S.x*a.n21+S.y*a.n22+S.z*a.n23)*0.5+0.5,za(N,P,T,U,I,B,Aa,Ba,Ca,Da,Ea,Fa,p.envMap)}else p.wireframe?ga(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(p.color);else if(p instanceof THREE.MeshLambertMaterial)p.map&&!p.wireframe&&(p.map.mapping instanceof THREE.UVMapping&&(ba=j.uvs[0],za(N,P,T,U,I,B,ba[g].u,ba[g].v, +ba[h].u,ba[h].v,ba[k].u,ba[k].v,p.map)),c(THREE.SubtractiveBlending)),xa?!p.wireframe&&p.shading==THREE.SmoothShading&&j.vertexNormalsWorld.length==3?(y.r=w.r=x.r=$.r,y.g=w.g=x.g=$.g,y.b=w.b=x.b=$.b,m(l,j.v1.positionWorld,j.vertexNormalsWorld[0],y),m(l,j.v2.positionWorld,j.vertexNormalsWorld[1],w),m(l,j.v3.positionWorld,j.vertexNormalsWorld[2],x),y.r=Math.max(0,Math.min(p.color.r*y.r,1)),y.g=Math.max(0,Math.min(p.color.g*y.g,1)),y.b=Math.max(0,Math.min(p.color.b*y.b,1)),w.r=Math.max(0,Math.min(p.color.r* +w.r,1)),w.g=Math.max(0,Math.min(p.color.g*w.g,1)),w.b=Math.max(0,Math.min(p.color.b*w.b,1)),x.r=Math.max(0,Math.min(p.color.r*x.r,1)),x.g=Math.max(0,Math.min(p.color.g*x.g,1)),x.b=Math.max(0,Math.min(p.color.b*x.b,1)),J.r=(w.r+x.r)*0.5,J.g=(w.g+x.g)*0.5,J.b=(w.b+x.b)*0.5,ea=va(y,w,x,J),ma(N,P,T,U,I,B,0,0,1,0,0,1,ea)):(t.r=$.r,t.g=$.g,t.b=$.b,m(l,j.centroidWorld,j.normalWorld,t),t.r=Math.max(0,Math.min(p.color.r*t.r,1)),t.g=Math.max(0,Math.min(p.color.g*t.g,1)),t.b=Math.max(0,Math.min(p.color.b*t.b, +1)),p.wireframe?ga(t,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(t)):p.wireframe?ga(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(p.color);else if(p instanceof THREE.MeshDepthMaterial)aa=i.near,fa=i.far,y.r=y.g=y.b=1-la(a.positionScreen.z,aa,fa),w.r=w.g=w.b=1-la(d.positionScreen.z,aa,fa),x.r=x.g=x.b=1-la(f.positionScreen.z,aa,fa),J.r=(w.r+x.r)*0.5,J.g=(w.g+x.g)*0.5,J.b=(w.b+x.b)*0.5,ea=va(y,w,x,J),ma(N,P,T,U,I,B,0,0,1,0,0,1,ea);else if(p instanceof THREE.MeshNormalMaterial)t.r= +na(j.normalWorld.x),t.g=na(j.normalWorld.y),t.b=na(j.normalWorld.z),p.wireframe?ga(t,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(t)}function M(a,d,f,g,h,k,j,p,n){e.info.render.vertices+=4;e.info.render.faces++;b(p.opacity);c(p.blending);if(p.map||p.envMap)E(a,d,g,0,1,3,j,p,n),E(h,f,k,1,2,3,j,p,n);else if(N=a.positionScreen.x,P=a.positionScreen.y,T=d.positionScreen.x,U=d.positionScreen.y,I=f.positionScreen.x,B=f.positionScreen.y,R=g.positionScreen.x,v=g.positionScreen.y,O=h.positionScreen.x, +L=h.positionScreen.y,oa=k.positionScreen.x,G=k.positionScreen.y,p instanceof THREE.MeshBasicMaterial)Q(N,P,T,U,I,B,R,v),p.wireframe?ga(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(p.color);else if(p instanceof THREE.MeshLambertMaterial)xa?!p.wireframe&&p.shading==THREE.SmoothShading&&j.vertexNormalsWorld.length==4?(y.r=w.r=x.r=J.r=$.r,y.g=w.g=x.g=J.g=$.g,y.b=w.b=x.b=J.b=$.b,m(l,j.v1.positionWorld,j.vertexNormalsWorld[0],y),m(l,j.v2.positionWorld,j.vertexNormalsWorld[1], +w),m(l,j.v4.positionWorld,j.vertexNormalsWorld[3],x),m(l,j.v3.positionWorld,j.vertexNormalsWorld[2],J),y.r=Math.max(0,Math.min(p.color.r*y.r,1)),y.g=Math.max(0,Math.min(p.color.g*y.g,1)),y.b=Math.max(0,Math.min(p.color.b*y.b,1)),w.r=Math.max(0,Math.min(p.color.r*w.r,1)),w.g=Math.max(0,Math.min(p.color.g*w.g,1)),w.b=Math.max(0,Math.min(p.color.b*w.b,1)),x.r=Math.max(0,Math.min(p.color.r*x.r,1)),x.g=Math.max(0,Math.min(p.color.g*x.g,1)),x.b=Math.max(0,Math.min(p.color.b*x.b,1)),J.r=Math.max(0,Math.min(p.color.r* +J.r,1)),J.g=Math.max(0,Math.min(p.color.g*J.g,1)),J.b=Math.max(0,Math.min(p.color.b*J.b,1)),ea=va(y,w,x,J),H(N,P,T,U,R,v),ma(N,P,T,U,R,v,0,0,1,0,0,1,ea),H(O,L,I,B,oa,G),ma(O,L,I,B,oa,G,1,0,1,1,0,1,ea)):(t.r=$.r,t.g=$.g,t.b=$.b,m(l,j.centroidWorld,j.normalWorld,t),t.r=Math.max(0,Math.min(p.color.r*t.r,1)),t.g=Math.max(0,Math.min(p.color.g*t.g,1)),t.b=Math.max(0,Math.min(p.color.b*t.b,1)),Q(N,P,T,U,I,B,R,v),p.wireframe?ga(t,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(t)):(Q(N,P, +T,U,I,B,R,v),p.wireframe?ga(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(p.color));else if(p instanceof THREE.MeshNormalMaterial)t.r=na(j.normalWorld.x),t.g=na(j.normalWorld.y),t.b=na(j.normalWorld.z),Q(N,P,T,U,I,B,R,v),p.wireframe?ga(t,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):ha(t);else if(p instanceof THREE.MeshDepthMaterial)aa=i.near,fa=i.far,y.r=y.g=y.b=1-la(a.positionScreen.z,aa,fa),w.r=w.g=w.b=1-la(d.positionScreen.z,aa,fa),x.r=x.g=x.b=1-la(g.positionScreen.z, +aa,fa),J.r=J.g=J.b=1-la(f.positionScreen.z,aa,fa),ea=va(y,w,x,J),H(N,P,T,U,R,v),ma(N,P,T,U,R,v,0,0,1,0,0,1,ea),H(O,L,I,B,oa,G),ma(O,L,I,B,oa,G,1,0,1,1,0,1,ea)}function H(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function Q(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function ga(a,b,c,e){if(A!=b)k.lineWidth=A=b;if(C!=c)k.lineCap=C=c;if(F!=e)k.lineJoin=F=e;d(a.getContextStyle()); +k.stroke();X.inflate(b*2)}function ha(a){f(a.getContextStyle());k.fill()}function za(a,b,c,d,e,g,h,i,j,l,n,o,m){if(m.image.width!=0){if(m.needsUpdate==!0||ja[m.id]==void 0){var q=m.wrapS==THREE.RepeatWrapping,r=m.wrapT==THREE.RepeatWrapping;ja[m.id]=k.createPattern(m.image,q&&r?"repeat":q&&!r?"repeat-x":!q&&r?"repeat-y":"no-repeat");m.needsUpdate=!1}f(ja[m.id]);var q=m.offset.x/m.repeat.x,r=m.offset.y/m.repeat.y,s=(m.image.width-1)*m.repeat.x,m=(m.image.height-1)*m.repeat.y,h=(h+q)*s,i=(i+r)*m,j= +(j+q)*s,l=(l+r)*m,n=(n+q)*s,o=(o+r)*m;c-=a;d-=b;e-=a;g-=b;j-=h;l-=i;n-=h;o-=i;q=1/(j*o-n*l);m=(o*c-l*e)*q;l=(o*d-l*g)*q;c=(j*e-n*c)*q;d=(j*g-n*d)*q;a=a-m*h-c*i;b=b-l*h-d*i;k.save();k.transform(m,l,c,d,a,b);k.fill();k.restore()}}function ma(a,b,c,d,e,f,g,h,i,j,l,m,n){var o,q;o=n.width-1;q=n.height-1;g*=o;h*=q;i*=o;j*=q;l*=o;m*=q;c-=a;d-=b;e-=a;f-=b;i-=g;j-=h;l-=g;m-=h;q=1/(i*m-l*j);o=(m*c-j*e)*q;j=(m*d-j*f)*q;c=(i*e-l*c)*q;d=(i*f-l*d)*q;a=a-o*g-c*h;b=b-j*g-d*h;k.save();k.transform(o,j,c,d,a,b);k.clip(); k.drawImage(n,0,0);k.restore()}function va(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);ca[0]=e<0?0:e>255?255:e;ca[1]=f<0?0:f>255?255:f;ca[2]=a<0?0:a>255?255:a;ca[4]=g<0?0:g>255?255:g;ca[5]=h<0?0:h>255?255:h;ca[6]=b<0?0:b>255?255:b;ca[8]=i<0?0:i>255?255:i;ca[9]=j<0?0:j>255?255:j;ca[10]=c<0?0:c>255?255:c;ca[12]=k<0?0:k>255?255:k;ca[13]=l<0?0:l>255?255:l;ca[14]=d<0? -0:d>255?255:d;qa.putImageData(ya,0,0);ua.drawImage(pa,0,0);return ra}function ma(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function oa(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ja(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var wa,Ga,U,da;this.autoClear?this.clear():k.setTransform(1,0,0,-1,o,m);e.info.render.vertices=0;e.info.render.faces=0;g=n.projectScene(a,j,this.sortElements);h=g.elements;l=g.lights;(xa=l.length>0)&&i(l);wa=0;for(Ga=h.length;wa< -Ga;wa++)if(U=h[wa],da=U.material,da=da instanceof THREE.MeshFaceMaterial?U.faceMaterial:da,!(da==null||da.opacity==0)){W.empty();if(U instanceof THREE.RenderableParticle)u=U,u.x*=o,u.y*=m,r(u,U,da,a);else if(U instanceof THREE.RenderableLine)u=U.v1,s=U.v2,u.positionScreen.x*=o,u.positionScreen.y*=m,s.positionScreen.x*=o,s.positionScreen.y*=m,W.addPoint(u.positionScreen.x,u.positionScreen.y),W.addPoint(s.positionScreen.x,s.positionScreen.y),la.intersects(W)&&t(u,s,U,da,a);else if(U instanceof THREE.RenderableFace3)u= -U.v1,s=U.v2,B=U.v3,u.positionScreen.x*=o,u.positionScreen.y*=m,s.positionScreen.x*=o,s.positionScreen.y*=m,B.positionScreen.x*=o,B.positionScreen.y*=m,da.overdraw&&(ja(u.positionScreen,s.positionScreen),ja(s.positionScreen,B.positionScreen),ja(B.positionScreen,u.positionScreen)),W.add3Points(u.positionScreen.x,u.positionScreen.y,s.positionScreen.x,s.positionScreen.y,B.positionScreen.x,B.positionScreen.y),la.intersects(W)&&E(u,s,B,0,1,2,U,da,a);else if(U instanceof THREE.RenderableFace4)u=U.v1,s=U.v2, -B=U.v3,K=U.v4,u.positionScreen.x*=o,u.positionScreen.y*=m,s.positionScreen.x*=o,s.positionScreen.y*=m,B.positionScreen.x*=o,B.positionScreen.y*=m,K.positionScreen.x*=o,K.positionScreen.y*=m,aa.positionScreen.copy(s.positionScreen),ea.positionScreen.copy(K.positionScreen),da.overdraw&&(ja(u.positionScreen,s.positionScreen),ja(s.positionScreen,K.positionScreen),ja(K.positionScreen,u.positionScreen),ja(B.positionScreen,aa.positionScreen),ja(B.positionScreen,ea.positionScreen)),W.addPoint(u.positionScreen.x, -u.positionScreen.y),W.addPoint(s.positionScreen.x,s.positionScreen.y),W.addPoint(B.positionScreen.x,B.positionScreen.y),W.addPoint(K.positionScreen.x,K.positionScreen.y),la.intersects(W)&&L(u,s,B,K,aa,ea,U,da,a);Y.addRectangle(W)}k.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)}; +0:d>255?255:d;qa.putImageData(ya,0,0);ua.drawImage(pa,0,0);return ra}function la(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function na(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ia(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var wa,Ga,V,da;this.autoClear?this.clear():k.setTransform(1,0,0,-1,o,q);e.info.render.vertices=0;e.info.render.faces=0;g=n.projectScene(a,i,this.sortElements);h=g.elements;l=g.lights;(xa=l.length>0)&&j(l);wa=0;for(Ga=h.length;wa< +Ga;wa++)if(V=h[wa],da=V.material,da=da instanceof THREE.MeshFaceMaterial?V.faceMaterial:da,!(da==null||da.opacity==0)){X.empty();if(V instanceof THREE.RenderableParticle)u=V,u.x*=o,u.y*=q,s(u,V,da,a);else if(V instanceof THREE.RenderableLine)u=V.v1,r=V.v2,u.positionScreen.x*=o,u.positionScreen.y*=q,r.positionScreen.x*=o,r.positionScreen.y*=q,X.addPoint(u.positionScreen.x,u.positionScreen.y),X.addPoint(r.positionScreen.x,r.positionScreen.y),ka.intersects(X)&&z(u,r,V,da,a);else if(V instanceof THREE.RenderableFace3)u= +V.v1,r=V.v2,D=V.v3,u.positionScreen.x*=o,u.positionScreen.y*=q,r.positionScreen.x*=o,r.positionScreen.y*=q,D.positionScreen.x*=o,D.positionScreen.y*=q,da.overdraw&&(ia(u.positionScreen,r.positionScreen),ia(r.positionScreen,D.positionScreen),ia(D.positionScreen,u.positionScreen)),X.add3Points(u.positionScreen.x,u.positionScreen.y,r.positionScreen.x,r.positionScreen.y,D.positionScreen.x,D.positionScreen.y),ka.intersects(X)&&E(u,r,D,0,1,2,V,da,a);else if(V instanceof THREE.RenderableFace4)u=V.v1,r=V.v2, +D=V.v3,K=V.v4,u.positionScreen.x*=o,u.positionScreen.y*=q,r.positionScreen.x*=o,r.positionScreen.y*=q,D.positionScreen.x*=o,D.positionScreen.y*=q,K.positionScreen.x*=o,K.positionScreen.y*=q,W.positionScreen.copy(r.positionScreen),Y.positionScreen.copy(K.positionScreen),da.overdraw&&(ia(u.positionScreen,r.positionScreen),ia(r.positionScreen,K.positionScreen),ia(K.positionScreen,u.positionScreen),ia(D.positionScreen,W.positionScreen),ia(D.positionScreen,Y.positionScreen)),X.addPoint(u.positionScreen.x, +u.positionScreen.y),X.addPoint(r.positionScreen.x,r.positionScreen.y),X.addPoint(D.positionScreen.x,D.positionScreen.y),X.addPoint(K.positionScreen.x,K.positionScreen.y),ka.intersects(X)&&M(u,r,D,K,W,Y,V,da,a);Z.addRectangle(X)}k.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)}; THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null}; THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null}; THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null}; diff --git a/build/custom/ThreeDOM.js b/build/custom/ThreeDOM.js index 761a5e87..95563e13 100644 --- a/build/custom/ThreeDOM.js +++ b/build/custom/ThreeDOM.js @@ -13,65 +13,65 @@ cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y Math.abs(b)>1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b),this.z=Math.atan2(-a.n12/b,a.n11/b)):(this.x=0,this.z=Math.atan2(a.n21,a.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, -normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.children)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b=0&&m>=0&&n+m<1}for(var d=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Vector3,g,h,j,k,i,l,n,m,o,p=[],q=0,I=a.children.length;qa.scale.x)return[];o={distance:q,point:a.position, -face:null,object:a};p.push(o)}else if(a instanceof THREE.Mesh){q=b(this.origin,this.direction,a.matrixWorld.getPosition());if(q===null||q>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return p;var v,D,J,r,A,u,t,F,w=a.geometry,C=w.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);q=0;for(I=w.faces.length;q0:u<0)))if(u=A.dot((new THREE.Vector3).sub(v,t))/u,t=t.addSelf(F.multiplyScalar(u)),o instanceof THREE.Face3)c(t,v,D,J)&&(o={distance:this.origin.distanceTo(t),point:t,face:o,object:a}, -p.push(o));else if(o instanceof THREE.Face4&&(c(t,v,D,r)||c(t,D,J,r)))o={distance:this.origin.distanceTo(t),point:t,face:o,object:a},p.push(o)}return p}}; -THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(j,f,g,l){h=!1;b=j;c=f;d=g;e=l;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= -function(f,g,i,l,n,m){h?(h=!1,b=fi?f>n?f:n:i>n?i:n,e=g>l?g>m?g:m:l>m?l:m):(b=fi?f>n?f>d?f:d:n>d?n:d:i>n?i>d?i:d:n>d?n:d,e=g>l?g>m?g>e?g:e:m>e?m:e:l>m?l>e?l:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> -f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}}; +normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}}; +THREE.Ray=function(a,b){function c(a,b,c){var d;d=c.clone().subSelf(a).dot(b);if(d<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function d(a,b,c,d){j.copy(d).subSelf(b);h.copy(c).subSelf(b);l.copy(a).subSelf(b);n=j.dot(j);m=j.dot(h);p=j.dot(l);o=h.dot(h);q=h.dot(l);F=1/(n*o-m*m);v=(o*p-m*q)*F;D=(n*q-m*p)*F;return v>=0&&D>=0&&v+D<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)}; +this.intersectObjects=function(a){var b,c,d=[];b=0;for(c=a.length;ba.scale.x)return[];b={distance:h,point:a.position,face:null,object:a};j.push(b)}else if(a instanceof THREE.Mesh){h=c(this.origin,this.direction,a.matrixWorld.getPosition());if(h===null||h>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return j;var m,n,o,p,M=a.geometry,J=M.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);h=0;for(l=M.faces.length;h0:m<0)))if(n=k.dot((new THREE.Vector3).sub(e,o))/m,o=o.addSelf(p.multiplyScalar(n)), +b instanceof THREE.Face3)d(o,e,f,g)&&(b={distance:this.origin.distanceTo(o),point:o,face:b,object:a},j.push(b));else if(b instanceof THREE.Face4&&(d(o,e,f,i)||d(o,f,g,i)))b={distance:this.origin.distanceTo(o),point:o,face:b,object:a},j.push(b)}return j};var j=new THREE.Vector3,h=new THREE.Vector3,l=new THREE.Vector3,n,m,p,o,q,F,v,D}; +THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(k,f,g,l){i=!1;b=k;c=f;d=g;e=l;a()};this.addPoint=function(f,g){i?(i=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= +function(f,g,h,l,n,m){i?(i=!1,b=fh?f>n?f:n:h>n?h:n,e=g>l?g>m?g:m:l>m?l:m):(b=fh?f>n?f>d?f:d:n>d?n:d:h>n?h>d?h:d:n>d?n:d,e=g>l?g>m?g>e?g:e:m>e?m:e:l>m?l>e?l:e:m>e?m:e);a()};this.addRectangle=function(f){i?(i=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> +f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dg&&h.positionScreen.z0&&u.z<1))g=J[D]=J[D]||new THREE.RenderableParticle,D++,v=g,v.x=u.x/u.w,v.y=u.y/u.w,v.z=u.z,v.rotation=x.rotation.z,v.scale.x=x.scale.x*Math.abs(v.x-(u.x+e.projectionMatrix.n11)/(u.w+e.projectionMatrix.n14)),v.scale.y=x.scale.y*Math.abs(v.y-(u.y+e.projectionMatrix.n22)/(u.w+e.projectionMatrix.n24)),v.material=x.material,r.elements.push(v);f&&r.elements.sort(c); -return r}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; -THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); +THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=j[k]=j[k]||new THREE.RenderableVertex;k++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dg&&i.positionScreen.z0&&u.z<1))g=N[D]=N[D]||new THREE.RenderableParticle,D++,v=g,v.x=u.x/u.w,v.y=u.y/u.w,v.z=u.z,v.rotation=t.rotation.z,v.scale.x=t.scale.x*Math.abs(v.x-(u.x+e.projectionMatrix.n11)/(u.w+e.projectionMatrix.n14)),v.scale.y=t.scale.y*Math.abs(v.y-(u.y+e.projectionMatrix.n22)/(u.w+e.projectionMatrix.n24)),v.material=t.material,s.elements.push(v);f&&s.elements.sort(c); +return s}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; +THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,i=d*e;this.w=g*f-i*c;this.x=g*c+i*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= -this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,j=this.w,k=j*c+g*e-h*d,i=j*d+h*c-f*e,l=j*e+f*d-g*c,c=-f* -c-g*d-h*e;b.x=k*j+c*-f+i*-h-l*-g;b.y=i*j+c*-g+l*-f-k*-h;b.z=l*j+c*-h+k*-g-i*-f;return b}}; +this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,i=a.z,a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,k=this.w,j=k*c+g*e-i*d,h=k*d+i*c-f*e,l=k*e+f*d-g*c,c=-f* +c-g*d-i*e;b.x=j*k+c*-f+h*-i-l*-g;b.y=h*k+c*-g+l*-f-j*-i;b.z=l*k+c*-i+j*-g-h*-f;return b}}; THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;e<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; @@ -90,5 +90,5 @@ THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.ce THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene; THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);b!==-1&&this.__objectsRemoved.splice(b,1)}for(b=0;b1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b),this.z=Math.atan2(-a.n12/b,a.n11/b)):(this.x=0,this.z=Math.atan2(a.n21,a.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, -normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.children)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b=0&&m>=0&&n+m<1}for(var d=new THREE.Vector3,f=new THREE.Vector3,e=new THREE.Vector3,g,h,j,l,i,k,n,m,o,p=[],s=0,I=a.children.length;sa.scale.x)return[];o={distance:s,point:a.position, -face:null,object:a};p.push(o)}else if(a instanceof THREE.Mesh){s=b(this.origin,this.direction,a.matrixWorld.getPosition());if(s===null||s>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return p;var y,G,u,t,B,w,v,D,x=a.geometry,E=x.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);s=0;for(I=x.faces.length;s0:w<0)))if(w=B.dot((new THREE.Vector3).sub(y,v))/w,v=v.addSelf(D.multiplyScalar(w)),o instanceof THREE.Face3)c(v,y,G,u)&&(o={distance:this.origin.distanceTo(v),point:v,face:o,object:a}, -p.push(o));else if(o instanceof THREE.Face4&&(c(v,y,G,t)||c(v,G,u,t)))o={distance:this.origin.distanceTo(v),point:v,face:o,object:a},p.push(o)}return p}}; -THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,i,k){h=!1;b=e;c=g;d=i;f=k;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=be?d:e,f=f>g?f:g);a()};this.add3Points= -function(e,g,i,k,n,m){h?(h=!1,b=ei?e>n?e:n:i>n?i:n,f=g>k?g>m?g:m:k>m?k:m):(b=ei?e>n?e>d?e:d:n>d?n:d:i>n?i>d?i:d:n>d?n:d,f=g>k?g>m?g>f?g:f:m>f?m:f:k>m?k>f?k:f:m>f?m:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> +normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}}; +THREE.Ray=function(a,b){function c(a,b,c){var d;d=c.clone().subSelf(a).dot(b);if(d<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function d(a,b,c,d){k.copy(d).subSelf(b);i.copy(c).subSelf(b);j.copy(a).subSelf(b);n=k.dot(k);m=k.dot(i);o=k.dot(j);p=i.dot(i);t=i.dot(j);I=1/(n*p-m*m);w=(p*o-m*t)*I;E=(n*t-m*o)*I;return w>=0&&E>=0&&w+E<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)}; +this.intersectObjects=function(a){var b,c,d=[];b=0;for(c=a.length;ba.scale.x)return[];b={distance:i,point:a.position,face:null,object:a};k.push(b)}else if(a instanceof THREE.Mesh){i=c(this.origin,this.direction,a.matrixWorld.getPosition());if(i===null||i>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return k;var m,n,o,p,J=a.geometry,L=J.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);i=0;for(j=J.faces.length;i0:m<0)))if(n=l.dot((new THREE.Vector3).sub(f,o))/m,o=o.addSelf(p.multiplyScalar(n)), +b instanceof THREE.Face3)d(o,f,e,g)&&(b={distance:this.origin.distanceTo(o),point:o,face:b,object:a},k.push(b));else if(b instanceof THREE.Face4&&(d(o,f,e,h)||d(o,e,g,h)))b={distance:this.origin.distanceTo(o),point:o,face:b,object:a},k.push(b)}return k};var k=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,n,m,o,p,t,I,w,E}; +THREE.Rectangle=function(){function a(){e=d-b;g=f-c}var b,c,d,f,e,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,i,j){h=!1;b=e;c=g;d=i;f=j;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=be?d:e,f=f>g?f:g);a()};this.add3Points= +function(e,g,i,j,n,m){h?(h=!1,b=ei?e>n?e:n:i>n?i:n,f=g>j?g>m?g:m:j>m?j:m):(b=ei?e>n?e>d?e:d:n>d?n:d:i>n?i>d?i:d:n>d?n:d,f=g>j?g>m?g>f?g:f:m>f?m:f:j>m?j>f?j:f:m>f?m:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=be.getRight()?d:e.getRight(),f=f> e.getBottom()?f:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;f+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;f=d=c=b=0;a()};this.isEmpty=function(){return h}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dg&&h.positionScreen.z0&&w.z<1))g=u[G]=u[G]||new THREE.RenderableParticle,G++,y=g,y.x=w.x/w.w,y.y=w.y/w.w,y.z=w.z,y.rotation=H.rotation.z,y.scale.x=H.scale.x*Math.abs(y.x-(w.x+e.projectionMatrix.n11)/(w.w+e.projectionMatrix.n14)),y.scale.y=H.scale.y*Math.abs(y.y-(w.y+e.projectionMatrix.n22)/(w.w+e.projectionMatrix.n24)),y.material=H.material,t.elements.push(y);f&&t.elements.sort(c); -return t}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; +THREE.Projector=function(){function a(){var a=g[e]=g[e]||new THREE.RenderableObject;e++;return a}function b(){var a=k[l]=k[l]||new THREE.RenderableVertex;l++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dg&&h.positionScreen.z0&&z.z<1))g=s[E]=s[E]||new THREE.RenderableParticle,E++,w=g,w.x=z.x/z.w,w.y=z.y/z.w,w.z=z.z,w.rotation=F.rotation.z,w.scale.x=F.scale.x*Math.abs(w.x-(z.x+e.projectionMatrix.n11)/(z.w+e.projectionMatrix.n14)),w.scale.y=F.scale.y*Math.abs(w.y-(z.y+e.projectionMatrix.n22)/(z.w+e.projectionMatrix.n24)),w.material=F.material,u.elements.push(w);f&&u.elements.sort(c); +return u}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),e=Math.cos(c),c=Math.sin(c),g=a*b,h=d*f;this.w=g*e-h*c;this.x=g*c+h*e;this.y=d*b*e+a*f*c;this.z=a*f*e-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= -this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=this.y,h=this.z,j=this.w,l=j*c+g*f-h*d,i=j*d+h*c-e*f,k=j*f+e*d-g*c,c=-e* -c-g*d-h*f;b.x=l*j+c*-e+i*-h-k*-g;b.y=i*j+c*-g+k*-e-l*-h;b.z=k*j+c*-h+l*-g-i*-e;return b}}; +this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=this.y,h=this.z,l=this.w,k=l*c+g*f-h*d,i=l*d+h*c-e*f,j=l*f+e*d-g*c,c=-e* +c-g*d-h*f;b.x=k*l+c*-e+i*-h-j*-g;b.y=i*l+c*-g+j*-e-k*-h;b.z=j*l+c*-h+k*-g-i*-e;return b}}; THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*e)/f;d=Math.sin(d*e)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,f,e,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; @@ -79,12 +79,12 @@ THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;ret THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,d=this.vertices.length;c0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, +c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,e,f,B){h=a.vertices[b].position;l=a.vertices[c].position;k=a.vertices[d].position;i=g[e];j=g[f];n=g[B];m=l.x-h.x;o=k.x-h.x;p=l.y-h.y;t=k.y-h.y;I=l.z-h.z;w=k.z-h.z;E=j.u-i.u;s=n.u-i.u;u=j.v-i.v;D=n.v-i.v;z=1/(E*D-s*u);H.set((D*m-u*o)*z,(D*p-u*t)*z,(D*I-u*w)*z);y.set((E*o-s*m)*z,(E*t-s*p)*z,(E*w-s*I)*z);G[b].addSelf(H);G[c].addSelf(H);G[d].addSelf(H);x[b].addSelf(y); +x[c].addSelf(y);x[d].addSelf(y)}var b,c,d,f,e,g,h,l,k,i,j,n,m,o,p,t,I,w,E,s,u,D,z,A,G=[],x=[],H=new THREE.Vector3,y=new THREE.Vector3,J=new THREE.Vector3,L=new THREE.Vector3,M=new THREE.Vector3;b=0;for(c=this.vertices.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b1?1:a}var d=this,f,e,g,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,i,k,n,m,o,p,s,I=new THREE.Rectangle,y=new THREE.Rectangle,G=!1,u=new THREE.Color,t=new THREE.Color,B=new THREE.Color,w=new THREE.Color,v,D=new THREE.Vector3,x=[],E=[],A,K,M,L=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, -faces:0}};this.setQuality=function(a){switch(a){case "high":L=1;break;case "low":L=0}};this.setSize=function(a,b){l=a;i=b;k=l/2;n=i/2;j.setAttribute("viewBox",-k+" "+-n+" "+l+" "+i);j.setAttribute("width",l);j.setAttribute("height",i);I.set(-k,-n,k,n)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};this.render=function(i,l){var x,D,r,q;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;f=h.projectScene(i,l,this.sortElements);e=f.elements; -g=f.lights;M=K=0;if(G=g.length>0){t.setRGB(0,0,0);B.setRGB(0,0,0);w.setRGB(0,0,0);x=0;for(D=g.length;x1?1:a}var d=this,f,e,g,h=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,i,j,n,m,o,p,t,I=new THREE.Rectangle,w=new THREE.Rectangle,E=!1,s=new THREE.Color,u=new THREE.Color,D=new THREE.Color,z=new THREE.Color,A,G=new THREE.Vector3,x=[],H=[],y,J,L,M=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, +faces:0}};this.setQuality=function(a){switch(a){case "high":M=1;break;case "low":M=0}};this.setSize=function(a,b){k=a;i=b;j=k/2;n=i/2;l.setAttribute("viewBox",-j+" "+-n+" "+k+" "+i);l.setAttribute("width",k);l.setAttribute("height",i);I.set(-j,-n,j,n)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(i,k){var x,G,r,q;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;f=h.projectScene(i,k,this.sortElements);e=f.elements; +g=f.lights;L=J=0;if(E=g.length>0){u.setRGB(0,0,0);D.setRGB(0,0,0);z.setRGB(0,0,0);x=0;for(G=g.length;x1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b),this.z=Math.atan2(-a.n12/b,a.n11/b)):(this.x=0,this.z=Math.atan2(a.n21,a.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e!==void 0?e:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z- b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, -normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.children)},intersectObjects:function(a){var b,c,e=[];b=0;for(c=a.length;b=0&&F>=0&&x+F<1}for(var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,i,h,o,p,j,r,x,F,I,M=[],C=0,ma=a.children.length;Ca.scale.x)return[];I={distance:C,point:a.position, -face:null,object:a};M.push(I)}else if(a instanceof THREE.Mesh){C=b(this.origin,this.direction,a.matrixWorld.getPosition());if(C===null||C>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return M;var X,ea,la,D,R,L,G,ha,J=a.geometry,S=J.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);C=0;for(ma=J.faces.length;C0:L<0)))if(L=R.dot((new THREE.Vector3).sub(X,G))/L,G=G.addSelf(ha.multiplyScalar(L)),I instanceof THREE.Face3)c(G,X,ea,la)&&(I={distance:this.origin.distanceTo(G),point:G,face:I,object:a}, -M.push(I));else if(I instanceof THREE.Face4&&(c(G,X,ea,D)||c(G,ea,la,D)))I={distance:this.origin.distanceTo(G),point:G,face:I,object:a},M.push(I)}return M}}; -THREE.Rectangle=function(){function a(){g=e-b;i=f-c}var b,c,e,f,g,i,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return i};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,i,j,r){h=!1;b=g;c=i;e=j;f=r;a()};this.addPoint=function(g,i){h?(h=!1,b=g,c=i,e=g,f=i):(b=bg?e:g,f=f>i?f:i);a()};this.add3Points= -function(g,i,j,r,x,F){h?(h=!1,b=gj?g>x?g:x:j>x?j:x,f=i>r?i>F?i:F:r>F?r:F):(b=gj?g>x?g>e?g:e:x>e?x:e:j>x?j>e?j:e:x>e?x:e,f=i>r?i>F?i>f?i:f:F>f?F:f:r>F?r>f?r:f:F>f?F:f);a()};this.addRectangle=function(g){h?(h=!1,b=g.getLeft(),c=g.getTop(),e=g.getRight(),f=g.getBottom()):(b=bg.getRight()?e:g.getRight(),f=f> +normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}}; +THREE.Ray=function(a,b){function c(a,b,c){var e;e=c.clone().subSelf(a).dot(b);if(e<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(e));return c.distanceTo(a)}function e(a,b,c,e){p.copy(e).subSelf(b);i.copy(c).subSelf(b);o.copy(a).subSelf(b);u=p.dot(p);C=p.dot(i);I=p.dot(o);J=i.dot(i);E=i.dot(o);pa=1/(u*J-C*C);O=(J*I-C*E)*pa;ha=(u*E-C*I)*pa;return O>=0&&ha>=0&&O+ha<1}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)}; +this.intersectObjects=function(a){var b,c,e=[];b=0;for(c=a.length;ba.scale.x)return[];b={distance:i,point:a.position,face:null,object:a};p.push(b)}else if(a instanceof THREE.Mesh){i=c(this.origin,this.direction,a.matrixWorld.getPosition());if(i===null||i>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return p;var o,I,u,J,M=a.geometry,sa=M.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);i=0;for(C=M.faces.length;i0:o<0)))if(I=r.dot((new THREE.Vector3).sub(f,u))/o,u=u.addSelf(J.multiplyScalar(I)), +b instanceof THREE.Face3)e(u,f,g,j)&&(b={distance:this.origin.distanceTo(u),point:u,face:b,object:a},p.push(b));else if(b instanceof THREE.Face4&&(e(u,f,g,h)||e(u,g,j,h)))b={distance:this.origin.distanceTo(u),point:u,face:b,object:a},p.push(b)}return p};var p=new THREE.Vector3,i=new THREE.Vector3,o=new THREE.Vector3,u,C,I,J,E,pa,O,ha}; +THREE.Rectangle=function(){function a(){g=e-b;j=f-c}var b,c,e,f,g,j,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return j};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,j,i,o){h=!1;b=g;c=j;e=i;f=o;a()};this.addPoint=function(g,j){h?(h=!1,b=g,c=j,e=g,f=j):(b=bg?e:g,f=f>j?f:j);a()};this.add3Points= +function(g,j,i,o,u,C){h?(h=!1,b=gi?g>u?g:u:i>u?i:u,f=j>o?j>C?j:C:o>C?o:C):(b=gi?g>u?g>e?g:e:u>e?u:e:i>u?i>e?i:e:u>e?u:e,f=j>o?j>C?j>f?j:f:C>f?C:f:o>C?o>f?o:f:C>f?C:f);a()};this.addRectangle=function(g){h?(h=!1,b=g.getLeft(),c=g.getTop(),e=g.getRight(),f=g.getBottom()):(b=bg.getRight()?e:g.getRight(),f=f> g.getBottom()?f:g.getBottom());a()};this.inflate=function(g){b-=g;c-=g;e+=g;f+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();e=e=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;f=e=c=b=0;a()};this.isEmpty=function(){return h}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=0&&f>=0&&i>=0&&h>=0?!0:g<0&&f<0||i<0&&h<0?!1:(g<0?c=Math.max(c,g/(g-f)):f<0&&(e=Math.min(e,g/(g-f))),i<0?c=Math.max(c,i/(i-h)):h<0&&(e=Math.min(e,i/(i-h))),ei&&h.positionScreen.z0&&L.z<1))i=la[ea]=la[ea]||new THREE.RenderableParticle,ea++,X=i,X.x=L.x/L.w,X.y=L.y/L.w,X.z=L.z,X.rotation=ga.rotation.z,X.scale.x=ga.scale.x*Math.abs(X.x-(L.x+g.projectionMatrix.n11)/(L.w+g.projectionMatrix.n14)),X.scale.y=ga.scale.y*Math.abs(X.y-(L.y+g.projectionMatrix.n22)/ -(L.w+g.projectionMatrix.n24)),X.material=ga.material,D.elements.push(X);f&&D.elements.sort(c);return D}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==void 0?e:1)}; -THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,e=a.y*b,f=a.z*b,a=Math.cos(e),e=Math.sin(e),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(c),c=Math.sin(c),i=a*b,h=e*f;this.w=i*g-h*c;this.x=i*c+h*g;this.y=e*b*g+a*f*c;this.z=a*f*g-e*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,e=Math.sin(c); +THREE.Projector=function(){function a(){var a=j[g]=j[g]||new THREE.RenderableObject;g++;return a}function b(){var a=p[r]=p[r]||new THREE.RenderableVertex;r++;return a}function c(a,b){return b.z-a.z}function e(a,b){var c=0,e=1,g=a.z+a.w,f=b.z+b.w,j=-a.z+a.w,h=-b.z+b.w;return g>=0&&f>=0&&j>=0&&h>=0?!0:g<0&&f<0||j<0&&h<0?!1:(g<0?c=Math.max(c,g/(g-f)):f<0&&(e=Math.min(e,g/(g-f))),j<0?c=Math.max(c,j/(j-h)):h<0&&(e=Math.min(e,j/(j-h))),ej&&h.positionScreen.z< +ia;ma=0;for(P=Ba.length;ma0&&K.z<1))j=la[ha]=la[ha]||new THREE.RenderableParticle,ha++,O=j,O.x=K.x/K.w,O.y=K.y/K.w,O.z=K.z,O.rotation=ga.rotation.z,O.scale.x=ga.scale.x*Math.abs(O.x-(K.x+g.projectionMatrix.n11)/(K.w+g.projectionMatrix.n14)),O.scale.y=ga.scale.y*Math.abs(O.y- +(K.y+g.projectionMatrix.n22)/(K.w+g.projectionMatrix.n24)),O.material=ga.material,F.elements.push(O);f&&F.elements.sort(c);return F}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==void 0?e:1)}; +THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,e=a.y*b,f=a.z*b,a=Math.cos(e),e=Math.sin(e),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(c),c=Math.sin(c),j=a*b,h=e*f;this.w=j*g-h*c;this.x=j*c+h*g;this.y=e*b*g+a*f*c;this.z=a*f*g-e*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,e=Math.sin(c); this.x=a.x*e;this.y=a.y*e;this.z=a.z*e;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= -this.x,c=this.y,e=this.z,f=this.w,g=a.x,i=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-e*i;this.y=c*a+f*i+e*g-b*h;this.z=e*a+f*h+b*i-c*g;this.w=f*a-b*g-c*i-e*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,f=a.z,g=this.x,i=this.y,h=this.z,o=this.w,p=o*c+i*f-h*e,j=o*e+h*c-g*f,r=o*f+g*e-i*c,c=-g* -c-i*e-h*f;b.x=p*o+c*-g+j*-h-r*-i;b.y=j*o+c*-i+r*-g-p*-h;b.z=r*o+c*-h+p*-i-j*-g;return b}}; +this.x,c=this.y,e=this.z,f=this.w,g=a.x,j=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-e*j;this.y=c*a+f*j+e*g-b*h;this.z=e*a+f*h+b*j-c*g;this.w=f*a-b*g-c*j-e*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,f=a.z,g=this.x,j=this.y,h=this.z,r=this.w,p=r*c+j*f-h*e,i=r*e+h*c-g*f,o=r*f+g*e-j*c,c=-g* +c-j*e-h*f;b.x=p*r+c*-g+i*-h-o*-j;b.y=i*r+c*-j+o*-g-p*-h;b.z=o*r+c*-h+p*-j-i*-g;return b}}; THREE.Quaternion.slerp=function(a,b,c,e){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*b+c.w*e;c.x=a.x*b+c.x*e;c.y=a.y*b+c.y*e;c.z=a.z*b+c.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,e,f,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3}; -THREE.Face4=function(a,b,c,e,f,g,i){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=i;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.Face4=function(a,b,c,e,f,g,j){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=j;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; -THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,e=this.vertices.length;c0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], -y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z< -this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;bthis.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;p=this.points[c[0]];j=this.points[c[1]]; -r=this.points[c[2]];x=this.points[c[3]];h=i*i;o=i*h;e.x=b(p.x,j.x,r.x,x.x,i,h,o);e.y=b(p.y,j.y,r.y,x.y,i,h,o);e.z=b(p.z,j.z,r.z,x.z,i,h,o);return e};this.getControlPointsArray=function(){var a,b,c=this.points.length,e=[];for(a=0;a0){this.boundingBox={x:[this.vertices[0].position.x, +this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]= +a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;bthis.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;p=this.points[c[0]];i=this.points[c[1]]; +o=this.points[c[2]];u=this.points[c[3]];h=j*j;r=j*h;e.x=b(p.x,i.x,o.x,u.x,j,h,r);e.y=b(p.y,i.y,o.y,u.y,j,h,r);e.z=b(p.z,i.z,o.z,u.z,j,h,r);return e};this.getControlPointsArray=function(){var a,b,c=this.points.length,e=[];for(a=0;a=0)return a.geometry.materials[b.materialIndex]}function e(a,b,c){var e,g,f,q,l=a.vertices;q=l.length;var i=a.colors,h=i.length,k=a.__vertexArray,m=a.__colorArray,j=a.__sortArray,y=a.__dirtyVertices,o=a.__dirtyColors,p=a.__webglCustomAttributesList;if(c.sortParticles){xa.multiplySelf(c.matrixWorld);for(e=0;e=0)return a.geometry.materials[b.materialIndex]}function e(a,b,c){var e,g,f,q,l=a.vertices;q=l.length;var j=a.colors,h=j.length,k=a.__vertexArray,m=a.__colorArray,i=a.__sortArray,y=a.__dirtyVertices,p=a.__dirtyColors,o=a.__webglCustomAttributesList;if(c.sortParticles){za.multiplySelf(c.matrixWorld);for(e=0;e=0)a&&(d.bindBuffer(d.ARRAY_BUFFER, -f.__webglVertexBuffer),d.vertexAttribPointer(b.position,3,d.FLOAT,!1,0,0));else if(g.morphTargetBase){c=e.program.attributes;g.morphTargetBase!==-1?(d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[g.morphTargetBase]),d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0)):c.position>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglVertexBuffer),d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){i=0;var w=g.morphTargetForcedOrder;for(l=g.morphTargetInfluences;ih&&(k=m,h=l[k]);d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[k]);d.vertexAttribPointer(c["morphTarget"+i],3,d.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[i]= -h;w[k]=1;h=-1;i++}}e.program.uniforms.morphTargetInfluences!==null&&d.uniform1fv(e.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){i=0;for(l=f.__webglCustomAttributesList.length;i=0&&(d.bindBuffer(d.ARRAY_BUFFER,c.buffer),d.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,d.FLOAT,!1,0,0))}b.color>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglColorBuffer),d.vertexAttribPointer(b.color, +3]=q.w,f+=4}}if(y||c.sortParticles)d.bindBuffer(d.ARRAY_BUFFER,a.__webglVertexBuffer),d.bufferData(d.ARRAY_BUFFER,k,b);if(p||c.sortParticles)d.bindBuffer(d.ARRAY_BUFFER,a.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,m,b);if(o){j=0;for(h=o.length;j=0)a&&(d.bindBuffer(d.ARRAY_BUFFER, +f.__webglVertexBuffer),d.vertexAttribPointer(b.position,3,d.FLOAT,!1,0,0));else if(g.morphTargetBase){c=e.program.attributes;g.morphTargetBase!==-1?(d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[g.morphTargetBase]),d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0)):c.position>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglVertexBuffer),d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){j=0;var w=g.morphTargetForcedOrder;for(l=g.morphTargetInfluences;jh&&(k=m,h=l[k]);d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[k]);d.vertexAttribPointer(c["morphTarget"+j],3,d.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[j]= +h;w[k]=1;h=-1;j++}}e.program.uniforms.morphTargetInfluences!==null&&d.uniform1fv(e.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){j=0;for(l=f.__webglCustomAttributesList.length;j=0&&(d.bindBuffer(d.ARRAY_BUFFER,c.buffer),d.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,d.FLOAT,!1,0,0))}b.color>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglColorBuffer),d.vertexAttribPointer(b.color, 3,d.FLOAT,!1,0,0));b.normal>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglNormalBuffer),d.vertexAttribPointer(b.normal,3,d.FLOAT,!1,0,0));b.tangent>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglTangentBuffer),d.vertexAttribPointer(b.tangent,4,d.FLOAT,!1,0,0));b.uv>=0&&(f.__webglUVBuffer?(d.bindBuffer(d.ARRAY_BUFFER,f.__webglUVBuffer),d.vertexAttribPointer(b.uv,2,d.FLOAT,!1,0,0),d.enableVertexAttribArray(b.uv)):d.disableVertexAttribArray(b.uv));b.uv2>=0&&(f.__webglUV2Buffer?(d.bindBuffer(d.ARRAY_BUFFER,f.__webglUV2Buffer), d.vertexAttribPointer(b.uv2,2,d.FLOAT,!1,0,0),d.enableVertexAttribArray(b.uv2)):d.disableVertexAttribArray(b.uv2));e.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinVertexABuffer),d.vertexAttribPointer(b.skinVertexA,4,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),d.vertexAttribPointer(b.skinVertexB,4,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),d.vertexAttribPointer(b.skinIndex, -4,d.FLOAT,!1,0,0),d.bindBuffer(d.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),d.vertexAttribPointer(b.skinWeight,4,d.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(e.wireframe?(e=e.wireframeLinewidth,e!==Ha&&(d.lineWidth(e),Ha=e),a&&d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),d.drawElements(d.LINES,f.__webglLineCount,d.UNSIGNED_SHORT,0)):(a&&d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),d.drawElements(d.TRIANGLES,f.__webglFaceCount,d.UNSIGNED_SHORT,0)),E.info.render.calls++,E.info.render.vertices+= -f.__webglFaceCount,E.info.render.faces+=f.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?d.LINE_STRIP:d.LINES,e=e.linewidth,e!==Ha&&(d.lineWidth(e),Ha=e),d.drawArrays(g,0,f.__webglLineCount),E.info.render.calls++):g instanceof THREE.ParticleSystem?(d.drawArrays(d.POINTS,0,f.__webglParticleCount),E.info.render.calls++):g instanceof THREE.Ribbon&&(d.drawArrays(d.TRIANGLE_STRIP,0,f.__webglVertexCount),E.info.render.calls++)}}function i(a){qa[0].set(a.n41-a.n11,a.n42-a.n12,a.n43- -a.n13,a.n44-a.n14);qa[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);qa[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);qa[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);qa[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);qa[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=qa[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function h(a){for(var b=a.matrixWorld,d=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y, -a.scale.z)),c=0;c<6;c++)if(a=qa[c].x*b.n14+qa[c].y*b.n24+qa[c].z*b.n34+qa[c].w,a<=d)return!1;return!0}function o(a,b){return b.z-a.z}function p(a){var b,c,e,j,La,q,l,w,Aa=0,k=a.lights;ra||(ra=new THREE.PerspectiveCamera(E.shadowCameraFov,E.shadowMapWidth/E.shadowMapHeight,E.shadowCameraNear,E.shadowCameraFar));b=0;for(c=k.length;b=0;d--)a[d].object===b&&a.splice(d,1)}function C(a,b,c,e,f){e.program||E.initMaterial(e, -b,c,f);if(e.morphTargets&&!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(E.maxMorphTargets);for(var g=0,i=E.maxMorphTargets;g=0;d--)a[d].object===b&&a.splice(d,1)}function E(a,b,c,e,f){e.program||D.initMaterial(e, +b,c,f);if(e.morphTargets&&!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(D.maxMorphTargets);for(var g=0,j=D.maxMorphTargets;g0;this.getContext=function(){return d};this.supportsVertexTextures=function(){return Va};this.setSize=function(a,b){ka.width=a;ka.height=b;this.setViewport(0,0,ka.width,ka.height)};this.setViewport=function(a,b,c,e){Oa=a;Pa=b;Ga=c;Ca=e;d.viewport(Oa,Pa,Ga,Ca)};this.setScissor=function(a,b,c,e){d.scissor(a,b,c,e)};this.enableScissorTest=function(a){a?d.enable(d.SCISSOR_TEST):d.disable(d.SCISSOR_TEST)}; -this.setClearColorHex=function(a,b){V.setHex(a);N=b;d.clearColor(V.r,V.g,V.b,N)};this.setClearColor=function(a,b){V.copy(a);N=b;d.clearColor(V.r,V.g,V.b,N)};this.getClearColor=function(){return V};this.getClearAlpha=function(){return N};this.clear=function(a,b,c){var e=0;if(a===void 0||a)e|=d.COLOR_BUFFER_BIT;if(b===void 0||b)e|=d.DEPTH_BUFFER_BIT;if(c===void 0||c)e|=d.STENCIL_BUFFER_BIT;d.clear(e)};this.clearTarget=function(a,b,c,d){S(a);this.clear(b,c,d)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit= +case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var a=a||{},sa=a.canvas!==void 0?a.canvas:document.createElement("canvas"),va=a.precision!==void 0?a.precision:"highp",xa=a.antialias!==void 0?a.antialias:!1,Aa=a.stencil!==void 0?a.stencil:!0,Xa=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,P=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0), +R=a.clearAlpha!==void 0?a.clearAlpha:0,ma=a.maxLights!==void 0?a.maxLights:4;this.domElement=sa;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap= +[];this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};var D=this,d,ba=[],ja=null,ga=null,oa=-1,ta=null,Ea=0,Fa=null,Ba=null,ya=null,wa=null,Oa=null,Sa=null,Ta=null,Ua=null,Ia=null,Pa=0,Qa=0,Ha=0,Da=0,ua=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],za=new THREE.Matrix4,La=new Float32Array(16),Ka=new Float32Array(16), +Ca=new THREE.Vector4,Ra={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},ka,Ja=[],Ga,Na,x={},Va=!1;d=function(){var a;try{if(!(a=sa.getContext("experimental-webgl",{antialias:xa,stencil:Aa,preserveDrawingBuffer:Xa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}(); +d.clearColor(0,0,0,1);d.clearDepth(1);d.clearStencil(0);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);d.clearColor(P.r,P.g,P.b,R);(function(){x.vertices=new Float32Array(16);x.faces=new Uint16Array(6);var a=0;x.vertices[a++]=-1;x.vertices[a++]=-1;x.vertices[a++]=0;x.vertices[a++]=1;x.vertices[a++]=1;x.vertices[a++]=-1;x.vertices[a++]=1;x.vertices[a++]= +1;x.vertices[a++]=1;x.vertices[a++]=1;x.vertices[a++]=1;x.vertices[a++]=0;x.vertices[a++]=-1;x.vertices[a++]=1;x.vertices[a++]=0;a=x.vertices[a++]=0;x.faces[a++]=0;x.faces[a++]=1;x.faces[a++]=2;x.faces[a++]=0;x.faces[a++]=2;x.faces[a++]=3;x.vertexBuffer=d.createBuffer();x.elementBuffer=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,x.vertexBuffer);d.bufferData(d.ARRAY_BUFFER,x.vertices,d.STATIC_DRAW);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,x.elementBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,x.faces,d.STATIC_DRAW); +x.program=d.createProgram();d.attachShader(x.program,K("fragment",THREE.ShaderLib.sprite.fragmentShader));d.attachShader(x.program,K("vertex",THREE.ShaderLib.sprite.vertexShader));d.linkProgram(x.program);x.attributes={};x.uniforms={};x.attributes.position=d.getAttribLocation(x.program,"position");x.attributes.uv=d.getAttribLocation(x.program,"uv");x.uniforms.uvOffset=d.getUniformLocation(x.program,"uvOffset");x.uniforms.uvScale=d.getUniformLocation(x.program,"uvScale");x.uniforms.rotation=d.getUniformLocation(x.program, +"rotation");x.uniforms.scale=d.getUniformLocation(x.program,"scale");x.uniforms.alignment=d.getUniformLocation(x.program,"alignment");x.uniforms.color=d.getUniformLocation(x.program,"color");x.uniforms.map=d.getUniformLocation(x.program,"map");x.uniforms.opacity=d.getUniformLocation(x.program,"opacity");x.uniforms.useScreenCoordinates=d.getUniformLocation(x.program,"useScreenCoordinates");x.uniforms.affectedByDistance=d.getUniformLocation(x.program,"affectedByDistance");x.uniforms.screenPosition= +d.getUniformLocation(x.program,"screenPosition");x.uniforms.modelViewMatrix=d.getUniformLocation(x.program,"modelViewMatrix");x.uniforms.projectionMatrix=d.getUniformLocation(x.program,"projectionMatrix")})();(function(){var a=THREE.ShaderLib.depthRGBA,b=THREE.UniformsUtils.clone(a.uniforms);Ga=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:b});Na=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:b,morphTargets:!0}); +Ga._shadowPass=!0;Na._shadowPass=!0})();this.context=d;var Wa=d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;this.getContext=function(){return d};this.supportsVertexTextures=function(){return Wa};this.setSize=function(a,b){sa.width=a;sa.height=b;this.setViewport(0,0,sa.width,sa.height)};this.setViewport=function(a,b,c,e){Pa=a;Qa=b;Ha=c;Da=e;d.viewport(Pa,Qa,Ha,Da)};this.setScissor=function(a,b,c,e){d.scissor(a,b,c,e)};this.enableScissorTest=function(a){a?d.enable(d.SCISSOR_TEST):d.disable(d.SCISSOR_TEST)}; +this.setClearColorHex=function(a,b){P.setHex(a);R=b;d.clearColor(P.r,P.g,P.b,R)};this.setClearColor=function(a,b){P.copy(a);R=b;d.clearColor(P.r,P.g,P.b,R)};this.getClearColor=function(){return P};this.getClearAlpha=function(){return R};this.clear=function(a,b,c){var e=0;if(a===void 0||a)e|=d.COLOR_BUFFER_BIT;if(b===void 0||b)e|=d.DEPTH_BUFFER_BIT;if(c===void 0||c)e|=d.STENCIL_BUFFER_BIT;d.clear(e)};this.clearTarget=function(a,b,c,d){ra(a);this.clear(b,c,d)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit= !1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];d.deleteBuffer(c.__webglVertexBuffer);d.deleteBuffer(c.__webglNormalBuffer);d.deleteBuffer(c.__webglTangentBuffer);d.deleteBuffer(c.__webglColorBuffer);d.deleteBuffer(c.__webglUVBuffer);d.deleteBuffer(c.__webglUV2Buffer);d.deleteBuffer(c.__webglSkinVertexABuffer);d.deleteBuffer(c.__webglSkinVertexBBuffer); -d.deleteBuffer(c.__webglSkinIndicesBuffer);d.deleteBuffer(c.__webglSkinWeightsBuffer);d.deleteBuffer(c.__webglFaceBuffer);d.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var e=0,f=c.numMorphTargets;e=0)y=m.geometry.materials[y],y.transparent?(k.transparent=y,k.opaque=null):(k.opaque=y,k.transparent=null)}else if(y)y.transparent? -(k.transparent=y,k.opaque=null):(k.opaque=y,k.transparent=null);g.render=!0;if(this.sortObjects)q.renderDepth?g.z=q.renderDepth:(Ba.copy(q.position),xa.multiplyVector3(Ba),g.z=Ba.z)}this.sortObjects&&l.sort(o);l=a.__webglObjectsImmediate;e=0;for(f=l.length;e65535&&(y[m].counter+=1,p=y[m].hash+"_"+y[m].counter,j.geometryGroups[p]===void 0&&(j.geometryGroups[p]={faces3:[],faces4:[],materialIndex:o,vertices:0,numMorphTargets:r})),w instanceof THREE.Face3?j.geometryGroups[p].faces3.push(q):j.geometryGroups[p].faces4.push(q), -j.geometryGroups[p].vertices+=k;j.geometryGroupsList=[];q=void 0;for(q in j.geometryGroups)j.geometryGroups[q].id=Da++,j.geometryGroupsList.push(j.geometryGroups[q])}for(i in h.geometryGroups)if(j=h.geometryGroups[i],!j.__webglVertexBuffer){q=j;q.__webglVertexBuffer=d.createBuffer();q.__webglNormalBuffer=d.createBuffer();q.__webglTangentBuffer=d.createBuffer();q.__webglColorBuffer=d.createBuffer();q.__webglUVBuffer=d.createBuffer();q.__webglUV2Buffer=d.createBuffer();q.__webglSkinVertexABuffer=d.createBuffer(); -q.__webglSkinVertexBBuffer=d.createBuffer();q.__webglSkinIndicesBuffer=d.createBuffer();q.__webglSkinWeightsBuffer=d.createBuffer();q.__webglFaceBuffer=d.createBuffer();q.__webglLineBuffer=d.createBuffer();if(q.numMorphTargets){w=l=void 0;q.__webglMorphTargetsBuffers=[];l=0;for(w=q.numMorphTargets;l0||k.faceVertexUvs.length> -0)j.__uvArray=new Float32Array(q*2);if(k.faceUvs.length>1||k.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(q*2)}if(o.geometry.skinWeights.length&&o.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(q*4),j.__skinVertexBArray=new Float32Array(q*4),j.__skinIndexArray=new Float32Array(q*4),j.__skinWeightArray=new Float32Array(q*4);j.__faceArray=new Uint16Array(w*3);j.__lineArray=new Uint16Array(m*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];o=0;for(k=j.numMorphTargets;o=0;h--)g[h]===i&&g.splice(h,1)}else(f instanceof THREE.MarchingCubes||f.immediateRenderCallback)&&M(g.__webglObjectsImmediate,f);f.__webglActive=!1;a.__objectsRemoved.splice(0,1)}f=0;for(g=a.__webglObjects.length;f0&&(d.bindBuffer(d.ARRAY_BUFFER,l.__webglSkinVertexABuffer),d.bufferData(d.ARRAY_BUFFER,T,w),d.bindBuffer(d.ARRAY_BUFFER,l.__webglSkinVertexBBuffer),d.bufferData(d.ARRAY_BUFFER,U,w),d.bindBuffer(d.ARRAY_BUFFER,l.__webglSkinIndicesBuffer),d.bufferData(d.ARRAY_BUFFER,G,w),d.bindBuffer(d.ARRAY_BUFFER,l.__webglSkinWeightsBuffer),d.bufferData(d.ARRAY_BUFFER,fa,w))}if(sa&&R){k=0;for(m=y.length;k0&&(d.bindBuffer(d.ARRAY_BUFFER, -l.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,$,w))}if(ma&&J.hasTangents){k=0;for(m=y.length;k0&&(d.bindBuffer(d.ARRAY_BUFFER,l.__webglUVBuffer),d.bufferData(d.ARRAY_BUFFER,V,w))}if(ha&&ra&&X){k=0;for(m=y.length;k0&&(d.bindBuffer(d.ARRAY_BUFFER,l.__webglUV2Buffer),d.bufferData(d.ARRAY_BUFFER,t,w))}if(ia){k=0;for(m=y.length;k=0)y=m.geometry.materials[y],y.transparent?(k.transparent=y,k.opaque=null):(k.opaque=y,k.transparent=null)}else if(y)y.transparent? +(k.transparent=y,k.opaque=null):(k.opaque=y,k.transparent=null);g.render=!0;if(this.sortObjects)q.renderDepth?g.z=q.renderDepth:(Ca.copy(q.position),za.multiplyVector3(Ca),g.z=Ca.z)}this.sortObjects&&l.sort(r);l=a.__webglObjectsImmediate;e=0;for(f=l.length;e65535&&(y[m].counter+=1,p=y[m].hash+"_"+y[m].counter,i.geometryGroups[p]===void 0&&(i.geometryGroups[p]={faces3:[],faces4:[],materialIndex:o,vertices:0,numMorphTargets:r})),w instanceof THREE.Face3?i.geometryGroups[p].faces3.push(q):i.geometryGroups[p].faces4.push(q), +i.geometryGroups[p].vertices+=k;i.geometryGroupsList=[];q=void 0;for(q in i.geometryGroups)i.geometryGroups[q].id=Ea++,i.geometryGroupsList.push(i.geometryGroups[q])}for(j in h.geometryGroups)if(i=h.geometryGroups[j],!i.__webglVertexBuffer){q=i;q.__webglVertexBuffer=d.createBuffer();q.__webglNormalBuffer=d.createBuffer();q.__webglTangentBuffer=d.createBuffer();q.__webglColorBuffer=d.createBuffer();q.__webglUVBuffer=d.createBuffer();q.__webglUV2Buffer=d.createBuffer();q.__webglSkinVertexABuffer=d.createBuffer(); +q.__webglSkinVertexBBuffer=d.createBuffer();q.__webglSkinIndicesBuffer=d.createBuffer();q.__webglSkinWeightsBuffer=d.createBuffer();q.__webglFaceBuffer=d.createBuffer();q.__webglLineBuffer=d.createBuffer();if(q.numMorphTargets){w=l=void 0;q.__webglMorphTargetsBuffers=[];l=0;for(w=q.numMorphTargets;l0||k.faceVertexUvs.length> +0)i.__uvArray=new Float32Array(q*2);if(k.faceUvs.length>1||k.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(q*2)}if(o.geometry.skinWeights.length&&o.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(q*4),i.__skinVertexBArray=new Float32Array(q*4),i.__skinIndexArray=new Float32Array(q*4),i.__skinWeightArray=new Float32Array(q*4);i.__faceArray=new Uint16Array(w*3);i.__lineArray=new Uint16Array(m*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];o=0;for(k=i.numMorphTargets;o=0;h--)g[h]===j&&g.splice(h,1)}else(f instanceof THREE.MarchingCubes||f.immediateRenderCallback)&&J(g.__webglObjectsImmediate,f);f.__webglActive=!1;a.__objectsRemoved.splice(0,1)}f=0;for(g=a.__webglObjects.length;f0&&(d.bindBuffer(d.ARRAY_BUFFER,l.__webglSkinVertexABuffer),d.bufferData(d.ARRAY_BUFFER,S,w),d.bindBuffer(d.ARRAY_BUFFER,l.__webglSkinVertexBBuffer),d.bufferData(d.ARRAY_BUFFER,T,w),d.bindBuffer(d.ARRAY_BUFFER,l.__webglSkinIndicesBuffer),d.bufferData(d.ARRAY_BUFFER,Y,w),d.bindBuffer(d.ARRAY_BUFFER,l.__webglSkinWeightsBuffer),d.bufferData(d.ARRAY_BUFFER,fa,w))}if(sa&&O){k=0;for(m=y.length;k0&&(d.bindBuffer(d.ARRAY_BUFFER, +l.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,$,w))}if(ra&&Z.hasTangents){k=0;for(m=y.length;k0&&(d.bindBuffer(d.ARRAY_BUFFER,l.__webglUVBuffer),d.bufferData(d.ARRAY_BUFFER,R,w))}if(ha&&qa&&X){k=0;for(m=y.length;k0&&(d.bindBuffer(d.ARRAY_BUFFER,l.__webglUV2Buffer),d.bufferData(d.ARRAY_BUFFER,t,w))}if(ia){k=0;for(m=y.length;k=0&&d.enableVertexAttribArray(p.position);p.color>=0&&d.enableVertexAttribArray(p.color);p.normal>=0&&d.enableVertexAttribArray(p.normal); +h=["#ifdef GL_ES","precision "+va+" float;","#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",D.gammaInput?"#define GAMMA_INPUT":"",D.gammaOutput?"#define GAMMA_OUTPUT":"",D.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.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");d.attachShader(u,K("fragment",h+o));d.attachShader(u, +K("vertex",e+k));d.linkProgram(u);d.getProgramParameter(u,d.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+d.getProgramParameter(u,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");u.uniforms={};u.attributes={};var x,e=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(x in i)e.push(x);x=e;e=0;for(i=x.length;e=0&&d.enableVertexAttribArray(p.position);p.color>=0&&d.enableVertexAttribArray(p.color);p.normal>=0&&d.enableVertexAttribArray(p.normal); p.tangent>=0&&d.enableVertexAttribArray(p.tangent);a.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(d.enableVertexAttribArray(p.skinVertexA),d.enableVertexAttribArray(p.skinVertexB),d.enableVertexAttribArray(p.skinIndex),d.enableVertexAttribArray(p.skinWeight));if(a.attributes)for(g in a.attributes)p[g]!==void 0&&p[g]>=0&&d.enableVertexAttribArray(p[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g=0&&(d.enableVertexAttribArray(p[x]), a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW),a==="back"?d.cullFace(d.BACK):a==="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK),d.enable(d.CULL_FACE)):d.disable(d.CULL_FACE)}}; THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==void 0?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==void 0?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==void 0?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==void 0?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:THREE.RGBAFormat;this.type=c.type!==void 0?c.type: diff --git a/examples/webgl_interactive_cubes.html b/examples/webgl_interactive_cubes.html index b18888bc..cbf44a4e 100644 --- a/examples/webgl_interactive_cubes.html +++ b/examples/webgl_interactive_cubes.html @@ -130,7 +130,7 @@ // find intersections - var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 ); + var vector = new THREE.Vector3( mouse.x, mouse.y, 1 ); projector.unprojectVector( vector, camera ); var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() ); diff --git a/src/core/Ray.js b/src/core/Ray.js index 288555a8..acea0f2f 100644 --- a/src/core/Ray.js +++ b/src/core/Ray.js @@ -7,19 +7,13 @@ THREE.Ray = function ( origin, direction ) { this.origin = origin || new THREE.Vector3(); this.direction = direction || new THREE.Vector3(); -} - -THREE.Ray.prototype = { - - constructor: THREE.Ray, - - intersectScene: function ( scene ) { + this.intersectScene = function ( scene ) { return this.intersectObjects( scene.children ); - }, + }; - intersectObjects: function ( objects ) { + this.intersectObjects = function ( objects ) { var i, l, object, intersects = []; @@ -34,52 +28,18 @@ THREE.Ray.prototype = { return intersects; - }, + }; - intersectObject: function ( object ) { + var a = new THREE.Vector3(); + var b = new THREE.Vector3(); + var c = new THREE.Vector3(); + var d = new THREE.Vector3(); - function distanceFromIntersection( origin, direction, position ) { + var origin = new THREE.Vector3(); + var direction = new THREE.Vector3(); + var normal = new THREE.Vector3(); - var vector, dot, intersect, distance; - - vector = position.clone().subSelf( origin ); - dot = vector.dot( direction ); - - if ( dot <= 0 ) return null; // check if position behind origin. - - intersect = origin.clone().addSelf( direction.clone().multiplyScalar( dot ) ); - distance = position.distanceTo( intersect ); - - return distance; - - } - - // http://www.blackpawn.com/texts/pointinpoly/default.html - - var v0 = new THREE.Vector3(), v1 = new THREE.Vector3(), v2 = new THREE.Vector3(); - var dot00, dot01, dot02, dot11, dot12, invDenom, u, v; - - function pointInFace3( p, a, b, c ) { - - v0.copy( c ).subSelf( a ); - v1.copy( b ).subSelf( a ); - v2.copy( p ).subSelf( a ); - - dot00 = v0.dot( v0 ); - dot01 = v0.dot( v1 ); - dot02 = v0.dot( v2 ); - dot11 = v1.dot( v1 ); - dot12 = v1.dot( v2 ); - - invDenom = 1 / ( dot00 * dot11 - dot01 * dot01 ); - u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom; - v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom; - - return ( u >= 0 ) && ( v >= 0 ) && ( u + v < 1 ); - - } - - // + this.intersectObject = function ( object ) { var intersect, intersects = []; @@ -125,7 +85,6 @@ THREE.Ray.prototype = { // Checking faces var f, fl, face, - a, b, c, d, normal, vector, dot, scalar, origin, direction, geometry = object.geometry, @@ -153,12 +112,12 @@ THREE.Ray.prototype = { // - a = objMatrix.multiplyVector3( vertices[ face.a ].position.clone() ); - b = objMatrix.multiplyVector3( vertices[ face.b ].position.clone() ); - c = objMatrix.multiplyVector3( vertices[ face.c ].position.clone() ); - d = face instanceof THREE.Face4 ? objMatrix.multiplyVector3( vertices[ face.d ].position.clone() ) : null; + a = objMatrix.multiplyVector3( a.copy( vertices[ face.a ].position ) ); + b = objMatrix.multiplyVector3( b.copy( vertices[ face.b ].position ) ); + c = objMatrix.multiplyVector3( c.copy( vertices[ face.c ].position ) ); + d = face instanceof THREE.Face4 ? objMatrix.multiplyVector3( d.copy( vertices[ face.d ].position ) ) : null; - normal = object.matrixRotationWorld.multiplyVector3( face.normal.clone() ); + normal = object.matrixRotationWorld.multiplyVector3( normal.copy( face.normal ) ); dot = direction.dot( normal ); if ( object.doubleSided || ( object.flipSided ? dot > 0 : dot < 0 ) ) { // Math.abs( dot ) > 0.0001 @@ -212,4 +171,45 @@ THREE.Ray.prototype = { } + function distanceFromIntersection( origin, direction, position ) { + + var vector, dot, intersect, distance; + + vector = position.clone().subSelf( origin ); + dot = vector.dot( direction ); + + if ( dot <= 0 ) return null; // check if position behind origin. + + intersect = origin.clone().addSelf( direction.clone().multiplyScalar( dot ) ); + distance = position.distanceTo( intersect ); + + return distance; + + } + + // http://www.blackpawn.com/texts/pointinpoly/default.html + + var v0 = new THREE.Vector3(), v1 = new THREE.Vector3(), v2 = new THREE.Vector3(); + var dot00, dot01, dot02, dot11, dot12, invDenom, u, v; + + function pointInFace3( p, a, b, c ) { + + v0.copy( c ).subSelf( a ); + v1.copy( b ).subSelf( a ); + v2.copy( p ).subSelf( a ); + + dot00 = v0.dot( v0 ); + dot01 = v0.dot( v1 ); + dot02 = v0.dot( v2 ); + dot11 = v1.dot( v1 ); + dot12 = v1.dot( v2 ); + + invDenom = 1 / ( dot00 * dot11 - dot01 * dot01 ); + u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom; + v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom; + + return ( u >= 0 ) && ( v >= 0 ) && ( u + v < 1 ); + + } + };