From 1dcf5fc79b6e3c4d25ec5e499315027fbcf77b7b Mon Sep 17 00:00:00 2001 From: alteredq Date: Fri, 18 Nov 2011 05:08:40 +0100 Subject: [PATCH] Moved sprite handling into plugin. Work in progress. Still just experimenting. Probably will make some auto-adding of plugins. --- build/Three.js | 750 +++++++++++++++++---------------- build/custom/ThreeExtras.js | 321 +++++++------- build/custom/ThreeWebGL.js | 407 +++++++++--------- examples/webgl_sprites.html | 4 + src/renderers/WebGLRenderer.js | 219 +--------- src/renderers/WebGLShaders.js | 72 ---- utils/build.py | 4 +- 7 files changed, 749 insertions(+), 1028 deletions(-) diff --git a/build/Three.js b/build/Three.js index 9d0f73ca..7f5131d6 100644 --- a/build/Three.js +++ b/build/Three.js @@ -15,64 +15,64 @@ this.y=Math.asin(a.n13);Math.abs(b)>1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b), 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){function c(a,b,c){o.sub(c,a);r=o.dot(b);if(r<=0)return null;n=p.add(a,m.copy(b).multiplyScalar(r));return q=c.distanceTo(n)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);m.sub(a,b);t=o.dot(o);v=o.dot(p);z=o.dot(m);u=p.dot(p);B=p.dot(m);A=1/(t*u-v*v);F=(u*z-v*B)*A;H=(t*B-v*z)*A;return F>=0&&H>=0&&F+H<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;bm.scale.x)return[];n={distance:p,point:m.position,face:null,object:m};o.push(n)}else if(m instanceof THREE.Mesh){p=c(this.origin,this.direction,m.matrixWorld.getPosition());if(p===null||p>m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)))return o;var q,t=m.geometry,v=t.vertices,z;m.matrixRotationWorld.extractRotation(m.matrixWorld);p=0;for(r=t.faces.length;p0:q<0)))if(q=l.dot(i.sub(e,a))/q,k.add(a,b.multiplyScalar(q)),n instanceof THREE.Face3)d(k, -e,g,f)&&(n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},o.push(n));else if(n instanceof THREE.Face4&&(d(k,e,g,h)||d(k,g,f,h)))n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},o.push(n)}return o};var o=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector3,r,n,q,t,v,z,u,B,A,F,H}; +THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);q=o.dot(b);if(q<=0)return null;n=p.add(a,m.copy(b).multiplyScalar(q));return r=c.distanceTo(n)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);m.sub(a,b);t=o.dot(o);u=o.dot(p);y=o.dot(m);v=p.dot(p);A=p.dot(m);z=1/(t*v-u*u);w=(v*y-u*A)*z;I=(t*A-u*y)*z;return w>=0&&I>=0&&w+I<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;bm.scale.x)return[];n={distance:p,point:m.position,face:null,object:m};o.push(n)}else if(m instanceof THREE.Mesh){p=c(this.origin,this.direction,m.matrixWorld.getPosition());if(p===null||p>m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)))return o;var r,t=m.geometry,u=t.vertices,y;m.matrixRotationWorld.extractRotation(m.matrixWorld);p=0;for(q=t.faces.length;p0:r<0)))if(r=j.dot(i.sub(e,a))/r,k.add(a,b.multiplyScalar(r)),n instanceof THREE.Face3)d(k, +e,g,f)&&(n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},o.push(n));else if(n instanceof THREE.Face4&&(d(k,e,g,h)||d(k,g,f,h)))n={distance:a.distanceTo(k),point:k.clone(),face:n,object:m},o.push(n)}return o};var o=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector3,q,n,r,t,u,y,v,A,z,w,I}; THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,f,k,o){h=!1;b=g;c=f;d=k;e=o;a()};this.addPoint=function(g,f){h?(h=!1,b=g,c=f,d=g,e=f):(b=bg?d:g,e=e>f?e:f);a()};this.add3Points= function(g,f,k,o,p,m){h?(h=!1,b=gk?g>p?g:p:k>p?k:p,e=f>o?f>m?f:m:o>m?o:m):(b=gk?g>p?g>d?g:d:p>d?p:d:k>p?k>d?k:d:p>d?p:d,e=f>o?f>m?f>e?f:e:m>e?m:e:o>m?o>e?o:e:m>e?m:e);a()};this.addRectangle=function(g){h?(h=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),e=g.getBottom()):(b=bg.getRight()?d:g.getRight(),e=e> g.getBottom()?e:g.getBottom());a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.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}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){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&&F.z<1))f=u[z]=u[z]||new THREE.RenderableParticle,z++,v=f,v.x=F.x/F.w,v.y=F.y/F.w,v.z=F.z,v.rotation=ba.rotation.z,v.scale.x=ba.scale.x*Math.abs(v.x-(F.x+e.projectionMatrix.n11)/(F.w+e.projectionMatrix.n14)),v.scale.y=ba.scale.y*Math.abs(v.y-(F.y+e.projectionMatrix.n22)/(F.w+e.projectionMatrix.n24)),v.material=ba.material,B.elements.push(v); -g&&B.elements.sort(c);return B}};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=f[g]=f[g]||new THREE.RenderableObject;g++;return a}function b(){var a=j[i]=j[i]||new THREE.RenderableVertex;i++;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,g=b.z+b.w,f=-a.z+a.w,h=-b.z+b.w;return e>=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&&w.z<1))f=v[y]=v[y]||new THREE.RenderableParticle,y++,u=f,u.x=w.x/w.w,u.y=w.y/w.w,u.z=w.z,u.rotation=ca.rotation.z,u.scale.x=ca.scale.x*Math.abs(u.x-(w.x+e.projectionMatrix.n11)/(w.w+e.projectionMatrix.n14)),u.scale.y=ca.scale.y*Math.abs(u.y-(w.y+e.projectionMatrix.n22)/(w.w+e.projectionMatrix.n24)),u.material=ca.material,A.elements.push(u); +g&&A.elements.sort(c);return A}};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),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-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,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-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,g=this.x,f=this.y,h=this.z,i=this.w,l=i*c+f*e-h*d,k=i*d+h*c-g*e,o=i*e+g*d-f*c,c=-g* -c-f*d-h*e;b.x=l*i+c*-g+k*-h-o*-f;b.y=k*i+c*-f+o*-g-l*-h;b.z=o*i+c*-h+l*-f-k*-g;return b}}; +this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-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,g=this.x,f=this.y,h=this.z,i=this.w,j=i*c+f*e-h*d,k=i*d+h*c-g*e,o=i*e+g*d-f*c,c=-g* +c-f*d-h*e;b.x=j*i+c*-g+k*-h-o*-f;b.y=k*i+c*-f+o*-g-j*-h;b.z=o*i+c*-h+j*-f-k*-g;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 g=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.0010)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)*g)/e;d=Math.sin(d*g)/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,g){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=g;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,e,g,f){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=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; @@ -83,14 +83,14 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid b,c,d,e,g,f=new THREE.Vector3,h=new THREE.Vector3;a=0;for(b=this.faces.length;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;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;bthis.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;l=this.points[c[0]];k=this.points[c[1]]; -o=this.points[c[2]];p=this.points[c[3]];h=f*f;i=f*h;d.x=b(l.x,k.x,o.x,p.x,f,h,i);d.y=b(l.y,k.y,o.y,p.y,f,h,i);d.z=b(l.z,k.z,o.z,p.z,f,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;j=this.points[c[0]];k=this.points[c[1]]; +o=this.points[c[2]];p=this.points[c[3]];h=f*f;i=f*h;d.x=b(j.x,k.x,o.x,p.x,f,h,i);d.y=b(j.y,k.y,o.y,p.y,f,h,i);d.z=b(j.z,k.z,o.z,p.z,f,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a0&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+t+")"),n.fillRect(Math.floor(ca.getX()), -Math.floor(ca.getY()),Math.floor(ca.getWidth()),Math.floor(ca.getHeight()))),ca.empty())};this.render=function(a,k){function p(a){var b,c,d,e;aa.setRGB(0,0,0);Y.setRGB(0,0,0);qa.setRGB(0,0,0);b=0;for(c=a.length;b>1,ja=k.height>> -1,f=g.scale.x*m,i=g.scale.y*r,j=f*l,h=i*ja,J.set(a.x-j,a.y-h,a.x+j,a.y+h),S.intersects(J)&&(n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(f,-i),n.translate(-l,-ja),n.drawImage(k,0,0),n.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(j=g.scale.x*m,h=g.scale.y*r,J.set(a.x-j,a.y-h,a.x+j,a.y+h),S.intersects(J)&&(d(f.color.getContextStyle()),e(f.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(j,h),f.program(n),n.restore()))}function t(a,e, -g,f){b(f.opacity);c(f.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(A!=a)n.lineWidth=A=a;a=f.linecap;if(F!=a)n.lineCap=F=a;a=f.linejoin;if(H!=a)n.lineJoin=H=a;d(f.color.getContextStyle());n.stroke();J.inflate(f.linewidth*2)}}function v(a,d,e,f,j,h,m,n){g.info.render.vertices+=3;g.info.render.faces++;b(n.opacity);c(n.blending);Q=a.positionScreen.x;T=a.positionScreen.y; -$=d.positionScreen.x;ia=d.positionScreen.y;y=e.positionScreen.x;N=e.positionScreen.y;Ha(Q,T,$,ia,y,N);if(n instanceof THREE.MeshBasicMaterial)if(n.map)n.map.mapping instanceof THREE.UVMapping&&(ta=m.uvs[0],Ja(Q,T,$,ia,y,N,ta[f].u,ta[f].v,ta[j].u,ta[j].v,ta[h].u,ta[h].v,n.map));else if(n.envMap){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,X.copy(m.vertexNormalsWorld[f]),Ba=(X.x*a.n11+X.y*a.n12+X.z*a.n13)*0.5+0.5,va=-(X.x*a.n21+X.y*a.n22+X.z*a.n23)*0.5+0.5, -X.copy(m.vertexNormalsWorld[j]),ua=(X.x*a.n11+X.y*a.n12+X.z*a.n13)*0.5+0.5,Aa=-(X.x*a.n21+X.y*a.n22+X.z*a.n23)*0.5+0.5,X.copy(m.vertexNormalsWorld[h]),K=(X.x*a.n11+X.y*a.n12+X.z*a.n13)*0.5+0.5,ea=-(X.x*a.n21+X.y*a.n22+X.z*a.n23)*0.5+0.5,Ja(Q,T,$,ia,y,N,Ba,va,ua,Aa,K,ea,n.envMap)}else n.wireframe?Ca(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&&(ta=m.uvs[0], -Ja(Q,T,$,ia,y,N,ta[f].u,ta[f].v,ta[j].u,ta[j].v,ta[h].u,ta[h].v,n.map)),c(THREE.SubtractiveBlending)),P?!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3?(ga.r=fa.r=W.r=aa.r,ga.g=fa.g=W.g=aa.g,ga.b=fa.b=W.b=aa.b,o(i,m.v1.positionWorld,m.vertexNormalsWorld[0],ga),o(i,m.v2.positionWorld,m.vertexNormalsWorld[1],fa),o(i,m.v3.positionWorld,m.vertexNormalsWorld[2],W),ga.r=Math.max(0,Math.min(n.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(n.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(n.color.b* -ga.b,1)),fa.r=Math.max(0,Math.min(n.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(n.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(n.color.b*fa.b,1)),W.r=Math.max(0,Math.min(n.color.r*W.r,1)),W.g=Math.max(0,Math.min(n.color.g*W.g,1)),W.b=Math.max(0,Math.min(n.color.b*W.b,1)),na.r=(fa.r+W.r)*0.5,na.g=(fa.g+W.g)*0.5,na.b=(fa.b+W.b)*0.5,sa=B(ga,fa,W,na),Fa(Q,T,$,ia,y,N,0,0,1,0,0,1,sa)):(O.r=aa.r,O.g=aa.g,O.b=aa.b,o(i,m.centroidWorld,m.normalWorld,O),O.r=Math.max(0,Math.min(n.color.r*O.r,1)),O.g=Math.max(0,Math.min(n.color.g* -O.g,1)),O.b=Math.max(0,Math.min(n.color.b*O.b,1)),n.wireframe?Ca(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):u(O)):n.wireframe?Ca(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):u(n.color);else if(n instanceof THREE.MeshDepthMaterial)oa=k.near,pa=k.far,ga.r=ga.g=ga.b=1-Ea(a.positionScreen.z,oa,pa),fa.r=fa.g=fa.b=1-Ea(d.positionScreen.z,oa,pa),W.r=W.g=W.b=1-Ea(e.positionScreen.z,oa,pa),na.r=(fa.r+W.r)*0.5,na.g=(fa.g+W.g)*0.5,na.b=(fa.b+W.b)*0.5,sa=B(ga,fa,W, -na),Fa(Q,T,$,ia,y,N,0,0,1,0,0,1,sa);else if(n instanceof THREE.MeshNormalMaterial)O.r=Ga(m.normalWorld.x),O.g=Ga(m.normalWorld.y),O.b=Ga(m.normalWorld.z),n.wireframe?Ca(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):u(O)}function La(a,d,e,f,h,m,n,l,ja){g.info.render.vertices+=4;g.info.render.faces++;b(l.opacity);c(l.blending);if(l.map||l.envMap)v(a,d,f,0,1,3,n,l,ja),v(h,e,m,1,2,3,n,l,ja);else if(Q=a.positionScreen.x,T=a.positionScreen.y,$=d.positionScreen.x,ia=d.positionScreen.y,y= -e.positionScreen.x,N=e.positionScreen.y,I=f.positionScreen.x,w=f.positionScreen.y,V=h.positionScreen.x,R=h.positionScreen.y,j=m.positionScreen.x,ba=m.positionScreen.y,l instanceof THREE.MeshBasicMaterial)z(Q,T,$,ia,y,N,I,w),l.wireframe?Ca(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):u(l.color);else if(l instanceof THREE.MeshLambertMaterial)P?!l.wireframe&&l.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==4?(ga.r=fa.r=W.r=na.r=aa.r,ga.g=fa.g=W.g=na.g=aa.g,ga.b=fa.b= -W.b=na.b=aa.b,o(i,n.v1.positionWorld,n.vertexNormalsWorld[0],ga),o(i,n.v2.positionWorld,n.vertexNormalsWorld[1],fa),o(i,n.v4.positionWorld,n.vertexNormalsWorld[3],W),o(i,n.v3.positionWorld,n.vertexNormalsWorld[2],na),ga.r=Math.max(0,Math.min(l.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(l.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(l.color.b*ga.b,1)),fa.r=Math.max(0,Math.min(l.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(l.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(l.color.b*fa.b,1)),W.r=Math.max(0,Math.min(l.color.r* -W.r,1)),W.g=Math.max(0,Math.min(l.color.g*W.g,1)),W.b=Math.max(0,Math.min(l.color.b*W.b,1)),na.r=Math.max(0,Math.min(l.color.r*na.r,1)),na.g=Math.max(0,Math.min(l.color.g*na.g,1)),na.b=Math.max(0,Math.min(l.color.b*na.b,1)),sa=B(ga,fa,W,na),Ha(Q,T,$,ia,I,w),Fa(Q,T,$,ia,I,w,0,0,1,0,0,1,sa),Ha(V,R,y,N,j,ba),Fa(V,R,y,N,j,ba,1,0,1,1,0,1,sa)):(O.r=aa.r,O.g=aa.g,O.b=aa.b,o(i,n.centroidWorld,n.normalWorld,O),O.r=Math.max(0,Math.min(l.color.r*O.r,1)),O.g=Math.max(0,Math.min(l.color.g*O.g,1)),O.b=Math.max(0, -Math.min(l.color.b*O.b,1)),z(Q,T,$,ia,y,N,I,w),l.wireframe?Ca(O,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):u(O)):(z(Q,T,$,ia,y,N,I,w),l.wireframe?Ca(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):u(l.color));else if(l instanceof THREE.MeshNormalMaterial)O.r=Ga(n.normalWorld.x),O.g=Ga(n.normalWorld.y),O.b=Ga(n.normalWorld.z),z(Q,T,$,ia,y,N,I,w),l.wireframe?Ca(O,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):u(O);else if(l instanceof THREE.MeshDepthMaterial)oa= -k.near,pa=k.far,ga.r=ga.g=ga.b=1-Ea(a.positionScreen.z,oa,pa),fa.r=fa.g=fa.b=1-Ea(d.positionScreen.z,oa,pa),W.r=W.g=W.b=1-Ea(f.positionScreen.z,oa,pa),na.r=na.g=na.b=1-Ea(e.positionScreen.z,oa,pa),sa=B(ga,fa,W,na),Ha(Q,T,$,ia,I,w),Fa(Q,T,$,ia,I,w,0,0,1,0,0,1,sa),Ha(V,R,y,N,j,ba),Fa(V,R,y,N,j,ba,1,0,1,1,0,1,sa)}function Ha(a,b,c,d,e,f){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(a,b);n.closePath()}function z(a,b,c,d,e,f,g,j){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e, -f);n.lineTo(g,j);n.lineTo(a,b);n.closePath()}function Ca(a,b,c,e){if(A!=b)n.lineWidth=A=b;if(F!=c)n.lineCap=F=c;if(H!=e)n.lineJoin=H=e;d(a.getContextStyle());n.stroke();J.inflate(b*2)}function u(a){e(a.getContextStyle());n.fill()}function Ja(a,b,c,d,f,g,j,h,i,m,k,l,ja){if(ja.image.width!=0){if(ja.needsUpdate==!0||ha[ja.id]==void 0){var o=ja.wrapS==THREE.RepeatWrapping,p=ja.wrapT==THREE.RepeatWrapping;ha[ja.id]=n.createPattern(ja.image,o&&p?"repeat":o&&!p?"repeat-x":!o&&p?"repeat-y":"no-repeat");ja.needsUpdate= -!1}e(ha[ja.id]);var o=ja.offset.x/ja.repeat.x,p=ja.offset.y/ja.repeat.y,K=ja.image.width*ja.repeat.x,q=ja.image.height*ja.repeat.y,j=(j+o)*K,h=(h+p)*q,i=(i+o)*K,m=(m+p)*q,k=(k+o)*K,l=(l+p)*q;c-=a;d-=b;f-=a;g-=b;i-=j;m-=h;k-=j;l-=h;o=i*l-k*m;if(o==0){if(ra[ja.id]==void 0)b=document.createElement("canvas"),b.width=ja.image.width,b.height=ja.image.height,a=b.getContext("2d"),a.drawImage(ja.image,0,0),ra[ja.id]=a.getImageData(0,0,ja.image.width,ja.image.height).data,delete b;b=ra[ja.id];j=(Math.floor(j)+ -Math.floor(h)*ja.image.width)*4;O.setRGB(b[j]/255,b[j+1]/255,b[j+2]/255);u(O)}else o=1/o,ja=(l*c-m*f)*o,m=(l*d-m*g)*o,c=(i*f-k*c)*o,d=(i*g-k*d)*o,a=a-ja*j-c*h,j=b-m*j-d*h,n.save(),n.transform(ja,m,c,d,a,j),n.fill(),n.restore()}}function Fa(a,b,c,d,e,f,g,j,h,i,m,k,l){var ja,o;ja=l.width-1;o=l.height-1;g*=ja;j*=o;h*=ja;i*=o;m*=ja;k*=o;c-=a;d-=b;e-=a;f-=b;h-=g;i-=j;m-=g;k-=j;o=1/(h*k-m*i);ja=(k*c-i*e)*o;i=(k*d-i*f)*o;c=(h*e-m*c)*o;d=(h*f-m*d)*o;a=a-ja*g-c*j;b=b-i*g-d*j;n.save();n.transform(ja,i,c,d, -a,b);n.clip();n.drawImage(l,0,0);n.restore()}function B(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),n=~~(d.g*255),d=~~(d.b*255);M[0]=e<0?0:e>255?255:e;M[1]=f<0?0:f>255?255:f;M[2]=a<0?0:a>255?255:a;M[4]=g<0?0:g>255?255:g;M[5]=j<0?0:j>255?255:j;M[6]=b<0?0:b>255?255:b;M[8]=h<0?0:h>255?255:h;M[9]=i<0?0:i>255?255:i;M[10]=c<0?0:c>255?255:c;M[12]=m<0?0:m>255?255:m;M[13]=n<0?0:n>255?255:n;M[14]=d< -0?0:d>255?255:d;da.putImageData(xa,0,0);za.drawImage(ka,0,0);return wa}function Ea(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ga(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Da(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 Ia,Ka,C,ya;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,r);g.info.render.vertices=0;g.info.render.faces=0;f=l.projectScene(a,k,this.sortElements);h=f.elements;i=f.lights;(P=i.length>0)&&p(i);Ia=0;for(Ka= -h.length;Ia1?1:a}var d=this,e,g,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,k,o,p,m,r,n,q,t=new THREE.Rectangle,v=new THREE.Rectangle,z=!1,u=new THREE.Color,B=new THREE.Color,A=new THREE.Color,F=new THREE.Color,H,E=new THREE.Vector3,L=[],s=[],G,U,Z,Q=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":Q=1;break;case "low":Q=0}};this.setSize=function(a,b){l=a;k=b;o=l/2;p=k/2;i.setAttribute("viewBox",-o+" "+-p+" "+l+" "+k);i.setAttribute("width",l);i.setAttribute("height",k);t.set(-o,-p,o,p)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,l){var L,E,N,I;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(k,l,this.sortElements);g=e.elements; -f=e.lights;Z=U=0;if(z=f.length>0){B.setRGB(0,0,0);A.setRGB(0,0,0);F.setRGB(0,0,0);L=0;for(E=f.length;L0&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(r.r*255)+","+Math.floor(r.g*255)+","+Math.floor(r.b*255)+","+t+")"),n.fillRect(Math.floor(ha.getX()), +Math.floor(ha.getY()),Math.floor(ha.getWidth()),Math.floor(ha.getHeight()))),ha.empty())};this.render=function(a,k){function o(a){var b,c,d,e;aa.setRGB(0,0,0);Y.setRGB(0,0,0);sa.setRGB(0,0,0);b=0;for(c=a.length;b>1,ga=k.height>> +1,f=g.scale.x*m,i=g.scale.y*q,h=f*j,l=i*ga,J.set(a.x-h,a.y-l,a.x+h,a.y+l),S.intersects(J)&&(n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(f,-i),n.translate(-j,-ga),n.drawImage(k,0,0),n.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(h=g.scale.x*m,l=g.scale.y*q,J.set(a.x-h,a.y-l,a.x+h,a.y+l),S.intersects(J)&&(d(f.color.getContextStyle()),e(f.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-g.rotation),n.scale(h,l),f.program(n),n.restore()))}function t(a,e, +g,f){b(f.opacity);c(f.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(z!=a)n.lineWidth=z=a;a=f.linecap;if(w!=a)n.lineCap=w=a;a=f.linejoin;if(I!=a)n.lineJoin=I=a;d(f.color.getContextStyle());n.stroke();J.inflate(f.linewidth*2)}}function u(a,d,e,f,h,l,m,n){g.info.render.vertices+=3;g.info.render.faces++;b(n.opacity);c(n.blending);Q=a.positionScreen.x;U=a.positionScreen.y; +$=d.positionScreen.x;ja=d.positionScreen.y;K=e.positionScreen.x;L=e.positionScreen.y;Ha(Q,U,$,ja,K,L);if(n instanceof THREE.MeshBasicMaterial)if(n.map)n.map.mapping instanceof THREE.UVMapping&&(pa=m.uvs[0],A(Q,U,$,ja,K,L,pa[f].u,pa[f].v,pa[h].u,pa[h].v,pa[l].u,pa[l].v,n.map));else if(n.envMap){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,X.copy(m.vertexNormalsWorld[f]),Ba=(X.x*a.n11+X.y*a.n12+X.z*a.n13)*0.5+0.5,wa=-(X.x*a.n21+X.y*a.n22+X.z*a.n23)*0.5+0.5, +X.copy(m.vertexNormalsWorld[h]),va=(X.x*a.n11+X.y*a.n12+X.z*a.n13)*0.5+0.5,xa=-(X.x*a.n21+X.y*a.n22+X.z*a.n23)*0.5+0.5,X.copy(m.vertexNormalsWorld[l]),M=(X.x*a.n11+X.y*a.n12+X.z*a.n13)*0.5+0.5,ea=-(X.x*a.n21+X.y*a.n22+X.z*a.n23)*0.5+0.5,A(Q,U,$,ja,K,L,Ba,wa,va,xa,M,ea,n.envMap)}else n.wireframe?Ca(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Aa(n.color);else if(n instanceof THREE.MeshLambertMaterial)n.map&&!n.wireframe&&(n.map.mapping instanceof THREE.UVMapping&&(pa=m.uvs[0], +A(Q,U,$,ja,K,L,pa[f].u,pa[f].v,pa[h].u,pa[h].v,pa[l].u,pa[l].v,n.map)),c(THREE.SubtractiveBlending)),P?!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3?(fa.r=W.r=ba.r=aa.r,fa.g=W.g=ba.g=aa.g,fa.b=W.b=ba.b=aa.b,p(i,m.v1.positionWorld,m.vertexNormalsWorld[0],fa),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],W),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ba),fa.r=Math.max(0,Math.min(n.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(n.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(n.color.b* +fa.b,1)),W.r=Math.max(0,Math.min(n.color.r*W.r,1)),W.g=Math.max(0,Math.min(n.color.g*W.g,1)),W.b=Math.max(0,Math.min(n.color.b*W.b,1)),ba.r=Math.max(0,Math.min(n.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(n.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(n.color.b*ba.b,1)),na.r=(W.r+ba.r)*0.5,na.g=(W.g+ba.g)*0.5,na.b=(W.b+ba.b)*0.5,ta=Ja(fa,W,ba,na),Fa(Q,U,$,ja,K,L,0,0,1,0,0,1,ta)):(N.r=aa.r,N.g=aa.g,N.b=aa.b,p(i,m.centroidWorld,m.normalWorld,N),N.r=Math.max(0,Math.min(n.color.r*N.r,1)),N.g=Math.max(0,Math.min(n.color.g* +N.g,1)),N.b=Math.max(0,Math.min(n.color.b*N.b,1)),n.wireframe?Ca(N,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Aa(N)):n.wireframe?Ca(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Aa(n.color);else if(n instanceof THREE.MeshDepthMaterial)ra=k.near,oa=k.far,fa.r=fa.g=fa.b=1-Ea(a.positionScreen.z,ra,oa),W.r=W.g=W.b=1-Ea(d.positionScreen.z,ra,oa),ba.r=ba.g=ba.b=1-Ea(e.positionScreen.z,ra,oa),na.r=(W.r+ba.r)*0.5,na.g=(W.g+ba.g)*0.5,na.b=(W.b+ba.b)*0.5,ta=Ja(fa,W, +ba,na),Fa(Q,U,$,ja,K,L,0,0,1,0,0,1,ta);else if(n instanceof THREE.MeshNormalMaterial)N.r=Ga(m.normalWorld.x),N.g=Ga(m.normalWorld.y),N.b=Ga(m.normalWorld.z),n.wireframe?Ca(N,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Aa(N)}function y(a,d,e,f,h,m,n,j,ga){g.info.render.vertices+=4;g.info.render.faces++;b(j.opacity);c(j.blending);if(j.map||j.envMap)u(a,d,f,0,1,3,n,j,ga),u(h,e,m,1,2,3,n,j,ga);else if(Q=a.positionScreen.x,U=a.positionScreen.y,$=d.positionScreen.x,ja=d.positionScreen.y, +K=e.positionScreen.x,L=e.positionScreen.y,H=f.positionScreen.x,O=f.positionScreen.y,V=h.positionScreen.x,R=h.positionScreen.y,l=m.positionScreen.x,ca=m.positionScreen.y,j instanceof THREE.MeshBasicMaterial)v(Q,U,$,ja,K,L,H,O),j.wireframe?Ca(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Aa(j.color);else if(j instanceof THREE.MeshLambertMaterial)P?!j.wireframe&&j.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==4?(fa.r=W.r=ba.r=na.r=aa.r,fa.g=W.g=ba.g=na.g=aa.g,fa.b= +W.b=ba.b=na.b=aa.b,p(i,n.v1.positionWorld,n.vertexNormalsWorld[0],fa),p(i,n.v2.positionWorld,n.vertexNormalsWorld[1],W),p(i,n.v4.positionWorld,n.vertexNormalsWorld[3],ba),p(i,n.v3.positionWorld,n.vertexNormalsWorld[2],na),fa.r=Math.max(0,Math.min(j.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(j.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(j.color.b*fa.b,1)),W.r=Math.max(0,Math.min(j.color.r*W.r,1)),W.g=Math.max(0,Math.min(j.color.g*W.g,1)),W.b=Math.max(0,Math.min(j.color.b*W.b,1)),ba.r=Math.max(0,Math.min(j.color.r* +ba.r,1)),ba.g=Math.max(0,Math.min(j.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(j.color.b*ba.b,1)),na.r=Math.max(0,Math.min(j.color.r*na.r,1)),na.g=Math.max(0,Math.min(j.color.g*na.g,1)),na.b=Math.max(0,Math.min(j.color.b*na.b,1)),ta=Ja(fa,W,ba,na),Ha(Q,U,$,ja,H,O),Fa(Q,U,$,ja,H,O,0,0,1,0,0,1,ta),Ha(V,R,K,L,l,ca),Fa(V,R,K,L,l,ca,1,0,1,1,0,1,ta)):(N.r=aa.r,N.g=aa.g,N.b=aa.b,p(i,n.centroidWorld,n.normalWorld,N),N.r=Math.max(0,Math.min(j.color.r*N.r,1)),N.g=Math.max(0,Math.min(j.color.g*N.g,1)),N.b=Math.max(0, +Math.min(j.color.b*N.b,1)),v(Q,U,$,ja,K,L,H,O),j.wireframe?Ca(N,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Aa(N)):(v(Q,U,$,ja,K,L,H,O),j.wireframe?Ca(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Aa(j.color));else if(j instanceof THREE.MeshNormalMaterial)N.r=Ga(n.normalWorld.x),N.g=Ga(n.normalWorld.y),N.b=Ga(n.normalWorld.z),v(Q,U,$,ja,K,L,H,O),j.wireframe?Ca(N,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Aa(N);else if(j instanceof THREE.MeshDepthMaterial)ra= +k.near,oa=k.far,fa.r=fa.g=fa.b=1-Ea(a.positionScreen.z,ra,oa),W.r=W.g=W.b=1-Ea(d.positionScreen.z,ra,oa),ba.r=ba.g=ba.b=1-Ea(f.positionScreen.z,ra,oa),na.r=na.g=na.b=1-Ea(e.positionScreen.z,ra,oa),ta=Ja(fa,W,ba,na),Ha(Q,U,$,ja,H,O),Fa(Q,U,$,ja,H,O,0,0,1,0,0,1,ta),Ha(V,R,K,L,l,ca),Fa(V,R,K,L,l,ca,1,0,1,1,0,1,ta)}function Ha(a,b,c,d,e,g){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,g);n.lineTo(a,b);n.closePath()}function v(a,b,c,d,e,g,f,h){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e, +g);n.lineTo(f,h);n.lineTo(a,b);n.closePath()}function Ca(a,b,c,e){if(z!=b)n.lineWidth=z=b;if(w!=c)n.lineCap=w=c;if(I!=e)n.lineJoin=I=e;d(a.getContextStyle());n.stroke();J.inflate(b*2)}function Aa(a){e(a.getContextStyle());n.fill()}function A(a,b,c,d,g,f,h,l,i,k,m,j,ga){if(ga.image.width!=0){if(ga.needsUpdate==!0||ia[ga.id]==void 0){var o=ga.wrapS==THREE.RepeatWrapping,p=ga.wrapT==THREE.RepeatWrapping;ia[ga.id]=n.createPattern(ga.image,o&&p?"repeat":o&&!p?"repeat-x":!o&&p?"repeat-y":"no-repeat");ga.needsUpdate= +!1}e(ia[ga.id]);var o=ga.offset.x/ga.repeat.x,p=ga.offset.y/ga.repeat.y,M=ga.image.width*ga.repeat.x,r=ga.image.height*ga.repeat.y,h=(h+o)*M,l=(l+p)*r,i=(i+o)*M,k=(k+p)*r,m=(m+o)*M,j=(j+p)*r;c-=a;d-=b;g-=a;f-=b;i-=h;k-=l;m-=h;j-=l;o=i*j-m*k;if(o==0){if(qa[ga.id]==void 0)b=document.createElement("canvas"),b.width=ga.image.width,b.height=ga.image.height,a=b.getContext("2d"),a.drawImage(ga.image,0,0),qa[ga.id]=a.getImageData(0,0,ga.image.width,ga.image.height).data,delete b;b=qa[ga.id];h=(Math.floor(h)+ +Math.floor(l)*ga.image.width)*4;N.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);Aa(N)}else o=1/o,ga=(j*c-k*g)*o,k=(j*d-k*f)*o,c=(i*g-m*c)*o,d=(i*f-m*d)*o,a=a-ga*h-c*l,h=b-k*h-d*l,n.save(),n.transform(ga,k,c,d,a,h),n.fill(),n.restore()}}function Fa(a,b,c,d,e,g,f,h,l,i,k,m,j){var ga,o;ga=j.width-1;o=j.height-1;f*=ga;h*=o;l*=ga;i*=o;k*=ga;m*=o;c-=a;d-=b;e-=a;g-=b;l-=f;i-=h;k-=f;m-=h;o=1/(l*m-k*i);ga=(m*c-i*e)*o;i=(m*d-i*g)*o;c=(l*e-k*c)*o;d=(l*g-k*d)*o;a=a-ga*f-c*h;b=b-i*f-d*h;n.save();n.transform(ga,i,c,d, +a,b);n.clip();n.drawImage(j,0,0);n.restore()}function Ja(a,b,c,d){var e=~~(a.r*255),g=~~(a.g*255),a=~~(a.b*255),f=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),l=~~(c.r*255),i=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),m=~~(d.g*255),d=~~(d.b*255);ya[0]=e<0?0:e>255?255:e;ya[1]=g<0?0:g>255?255:g;ya[2]=a<0?0:a>255?255:a;ya[4]=f<0?0:f>255?255:f;ya[5]=h<0?0:h>255?255:h;ya[6]=b<0?0:b>255?255:b;ya[8]=l<0?0:l>255?255:l;ya[9]=i<0?0:i>255?255:i;ya[10]=c<0?0:c>255?255:c;ya[12]=k<0?0:k>255?255:k;ya[13]=m<0?0:m>255?255: +m;ya[14]=d<0?0:d>255?255:d;da.putImageData(za,0,0);Ia.drawImage(ka,0,0);return ga}function Ea(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ga(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Da(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 C,Ka,ua,D;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,q);g.info.render.vertices=0;g.info.render.faces=0;f=j.projectScene(a,k,this.sortElements);h=f.elements;i=f.lights;(P=i.length>0)&&o(i);C= +0;for(Ka=h.length;C1?1:a}var d=this,e,g,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,k,o,p,m,q,n,r,t=new THREE.Rectangle,u=new THREE.Rectangle,y=!1,v=new THREE.Color,A=new THREE.Color,z=new THREE.Color,w=new THREE.Color,I,F=new THREE.Vector3,G=[],s=[],E,T,Z,Q=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":Q=1;break;case "low":Q=0}};this.setSize=function(a,b){j=a;k=b;o=j/2;p=k/2;i.setAttribute("viewBox",-o+" "+-p+" "+j+" "+k);i.setAttribute("width",j);i.setAttribute("height",k);t.set(-o,-p,o,p)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,j){var G,F,L,H;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(k,j,this.sortElements);g=e.elements; +f=e.lights;Z=T=0;if(y=f.length>0){A.setRGB(0,0,0);z.setRGB(0,0,0);w.setRGB(0,0,0);G=0;for(F=f.length;G=0)return a.geometry.materials[b.materialIndex]}function d(a){if(a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial)return!1;return a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){if(a.vertexColors)return a.vertexColors;return!1}function g(a){if(a.map||a.lightMap||a instanceof THREE.ShaderMaterial)return!0; -return!1}function f(a,b,c){var d,e,g,f,h=a.vertices;f=h.length;var i=a.colors,m=i.length,n=a.__vertexArray,k=a.__colorArray,l=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,K=a.__webglCustomAttributesList;if(c.sortParticles){J.multiplySelf(c.matrixWorld);for(d=0;d=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;fm&&(l=n,m=h[l]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[f]=m;i[l]=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)),R.info.render.calls++,R.info.render.vertices+=e.__webglFaceCount,R.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),R.info.render.calls++):g instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),R.info.render.calls++):g instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),R.info.render.calls++)}}function l(a){ca[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);ca[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);ca[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);ca[3].set(a.n41- -a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);ca[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);ca[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=ca[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function k(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),d=0;d<6;d++)if(a=ca[d].x*b.n14+ca[d].y*b.n24+ca[d].z*b.n34+ca[d].w,a<=c)return!1;return!0}function o(a,b){return b.z-a.z}function p(a){var b, -c,d,e,g,f,m,n,o=0,p=a.lights;X||(X=new THREE.PerspectiveCamera(R.shadowCameraFov,R.shadowMapWidth/R.shadowMapHeight,R.shadowCameraNear,R.shadowCameraFar));b=0;for(c=p.length;b=0;c--)a[c].object===b&&a.splice(c,1)}function z(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function u(a,b,c,d,e){d.program||R.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(R.maxMorphTargets); -for(var g=0,f=R.maxMorphTargets;g=0)a&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),l.vertexAttribPointer(b.position,3,l.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;f.morphTargetBase!==-1?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]), +l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0)):c.position>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglVertexBuffer),l.vertexAttribPointer(c.position,3,l.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;gk&&(j=m,k=h[j]);l.bindBuffer(l.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[j]);l.vertexAttribPointer(c["morphTarget"+g],3,l.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[g]=k;i[j]=1;k=-1;g++}}d.program.uniforms.morphTargetInfluences!==null&&l.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g= +0;for(h=e.__webglCustomAttributesList.length;g=0&&(l.bindBuffer(l.ARRAY_BUFFER,c.buffer),l.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,l.FLOAT,!1,0,0))}b.color>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglColorBuffer),l.vertexAttribPointer(b.color,3,l.FLOAT,!1,0,0));b.normal>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglNormalBuffer),l.vertexAttribPointer(b.normal,3,l.FLOAT,!1,0,0));b.tangent>=0&&(l.bindBuffer(l.ARRAY_BUFFER, +e.__webglTangentBuffer),l.vertexAttribPointer(b.tangent,4,l.FLOAT,!1,0,0));b.uv>=0&&(e.__webglUVBuffer?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglUVBuffer),l.vertexAttribPointer(b.uv,2,l.FLOAT,!1,0,0),l.enableVertexAttribArray(b.uv)):l.disableVertexAttribArray(b.uv));b.uv2>=0&&(e.__webglUV2Buffer?(l.bindBuffer(l.ARRAY_BUFFER,e.__webglUV2Buffer),l.vertexAttribPointer(b.uv2,2,l.FLOAT,!1,0,0),l.enableVertexAttribArray(b.uv2)):l.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>= +0&&b.skinIndex>=0&&b.skinWeight>=0&&(l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinVertexABuffer),l.vertexAttribPointer(b.skinVertexA,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),l.vertexAttribPointer(b.skinVertexB,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),l.vertexAttribPointer(b.skinIndex,4,l.FLOAT,!1,0,0),l.bindBuffer(l.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),l.vertexAttribPointer(b.skinWeight,4,l.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe? +(d=d.wireframeLinewidth,d!==va&&(l.lineWidth(d),va=d),a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),l.drawElements(l.LINES,e.__webglLineCount,l.UNSIGNED_SHORT,0)):(a&&l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),l.drawElements(l.TRIANGLES,e.__webglFaceCount,l.UNSIGNED_SHORT,0)),R.info.render.calls++,R.info.render.vertices+=e.__webglFaceCount,R.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?l.LINE_STRIP:l.LINES,d=d.linewidth,d!== +va&&(l.lineWidth(d),va=d),l.drawArrays(f,0,e.__webglLineCount),R.info.render.calls++):f instanceof THREE.ParticleSystem?(l.drawArrays(l.POINTS,0,e.__webglParticleCount),R.info.render.calls++):f instanceof THREE.Ribbon&&(l.drawArrays(l.TRIANGLE_STRIP,0,e.__webglVertexCount),R.info.render.calls++)}}function j(a){ha[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);ha[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);ha[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);ha[3].set(a.n41- +a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);ha[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);ha[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=ha[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function k(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),d=0;d<6;d++)if(a=ha[d].x*b.n14+ha[d].y*b.n24+ha[d].z*b.n34+ha[d].w,a<=c)return!1;return!0}function o(a,b){return b.z-a.z}function p(a){var b, +c,d,e,f,g,m,n,o=0,p=a.lights;X||(X=new THREE.PerspectiveCamera(R.shadowCameraFov,R.shadowMapWidth/R.shadowMapHeight,R.shadowCameraNear,R.shadowCameraFar));b=0;for(c=p.length;b=0;c--)a[c].object===b&&a.splice(c,1)}function y(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function v(a,b,c,d,e){d.program||R.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(R.maxMorphTargets); +for(var f=0,g=R.maxMorphTargets;f0;this.getContext=function(){return j};this.supportsVertexTextures=function(){return za};this.setSize=function(a,b){T.width=a;T.height=b;this.setViewport(0,0,T.width,T.height)};this.setViewport=function(a,b,c,d){Aa=a;K=b;ea=c;S=d;j.viewport(Aa,K,ea,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){I.setHex(a);w=b;j.clearColor(I.r,I.g,I.b,w)};this.setClearColor=function(a,b){I.copy(a);w=b;j.clearColor(I.r,I.g,I.b,w)};this.getClearColor=function(){return I};this.getClearAlpha=function(){return w};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=j.COLOR_BUFFER_BIT;if(b===void 0||b)d|=j.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){U(a);this.clear(b,c,d)};this.addPlugin=function(a){a.init(this); -this.renderPlugins.push(a)};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)v=q.geometry.materials[v],v.transparent?(K.transparent=v,K.opaque=null):(K.opaque=v,K.transparent=null)}else if(v)v.transparent?(K.transparent=v,K.opaque=null):(K.opaque=v,K.transparent=null);g.render=!0;if(this.sortObjects)f.renderDepth?g.z=f.renderDepth:(Y.copy(f.position),J.multiplyVector3(Y),g.z=Y.z)}this.sortObjects&&h.sort(o);h=a.__webglObjectsImmediate;d=0;for(e=h.length;d65535&&(u[ea].counter+=1,s=u[ea].hash+"_"+u[ea].counter,k.geometryGroups[s]===void 0&&(k.geometryGroups[s]={faces3:[],faces4:[],materialIndex:r,vertices:0,numMorphTargets:L})),K instanceof THREE.Face3?k.geometryGroups[s].faces3.push(o):k.geometryGroups[s].faces4.push(o),k.geometryGroups[s].vertices+=S;k.geometryGroupsList=[];o=void 0;for(o in k.geometryGroups)k.geometryGroups[o].id= -na++,k.geometryGroupsList.push(k.geometryGroups[o])}for(m in l.geometryGroups)if(k=l.geometryGroups[m],!k.__webglVertexBuffer){o=k;o.__webglVertexBuffer=j.createBuffer();o.__webglNormalBuffer=j.createBuffer();o.__webglTangentBuffer=j.createBuffer();o.__webglColorBuffer=j.createBuffer();o.__webglUVBuffer=j.createBuffer();o.__webglUV2Buffer=j.createBuffer();o.__webglSkinVertexABuffer=j.createBuffer();o.__webglSkinVertexBBuffer=j.createBuffer();o.__webglSkinIndicesBuffer=j.createBuffer();o.__webglSkinWeightsBuffer= -j.createBuffer();o.__webglFaceBuffer=j.createBuffer();o.__webglLineBuffer=j.createBuffer();if(o.numMorphTargets){K=p=void 0;o.__webglMorphTargetsBuffers=[];p=0;for(K=o.numMorphTargets;p0||S.faceVertexUvs.length>0)k.__uvArray=new Float32Array(o*2);if(S.faceUvs.length>1||S.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(o*2)}if(r.geometry.skinWeights.length&&r.geometry.skinIndices.length)k.__skinVertexAArray=new Float32Array(o*4),k.__skinVertexBArray=new Float32Array(o*4),k.__skinIndexArray=new Float32Array(o*4),k.__skinWeightArray=new Float32Array(o*4);k.__faceArray=new Uint16Array(K*3); -k.__lineArray=new Uint16Array(ea*2);if(k.numMorphTargets){k.__morphTargetsArrays=[];r=0;for(S=k.numMorphTargets;r0&&(j.bindBuffer(j.ARRAY_BUFFER,p.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,Q,K),j.bindBuffer(j.ARRAY_BUFFER,p.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,aa,K),j.bindBuffer(j.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,E,K),j.bindBuffer(j.ARRAY_BUFFER,p.__webglSkinWeightsBuffer), -j.bufferData(j.ARRAY_BUFFER,ha,K))}if(ta&&ea){s=0;for(u=G.length;s0&&(j.bindBuffer(j.ARRAY_BUFFER,p.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,M,K))}if(H&&V.hasTangents){s=0;for(u=G.length;s0&&(j.bindBuffer(j.ARRAY_BUFFER, -p.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,ba,K))}if(oa&&za&&U){s=0;for(u=G.length;s0&&(j.bindBuffer(j.ARRAY_BUFFER,p.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,D,K))}if(ra){s=0;for(u=G.length;s0;this.getContext=function(){return l};this.supportsVertexTextures=function(){return ya};this.setSize=function(a,b){U.width=a;U.height=b;this.setViewport(0,0,U.width,U.height)};this.setViewport=function(a,b,c,d){xa=a;M=b;ea=c;S=d;l.viewport(xa,M,ea,S)};this.setScissor=function(a,b,c,d){l.scissor(a,b,c,d)};this.enableScissorTest=function(a){a? +l.enable(l.SCISSOR_TEST):l.disable(l.SCISSOR_TEST)};this.setClearColorHex=function(a,b){H.setHex(a);O=b;l.clearColor(H.r,H.g,H.b,O)};this.setClearColor=function(a,b){H.copy(a);O=b;l.clearColor(H.r,H.g,H.b,O)};this.getClearColor=function(){return H};this.getClearAlpha=function(){return O};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=l.COLOR_BUFFER_BIT;if(b===void 0||b)d|=l.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=l.STENCIL_BUFFER_BIT;l.clear(d)};this.clearTarget=function(a,b,c,d){T(a);this.clear(b, +c,d)};this.addPlugin=function(a){a.init(this);this.renderPlugins.push(a)};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];l.deleteBuffer(c.__webglVertexBuffer);l.deleteBuffer(c.__webglNormalBuffer);l.deleteBuffer(c.__webglTangentBuffer);l.deleteBuffer(c.__webglColorBuffer); +l.deleteBuffer(c.__webglUVBuffer);l.deleteBuffer(c.__webglUV2Buffer);l.deleteBuffer(c.__webglSkinVertexABuffer);l.deleteBuffer(c.__webglSkinVertexBBuffer);l.deleteBuffer(c.__webglSkinIndicesBuffer);l.deleteBuffer(c.__webglSkinWeightsBuffer);l.deleteBuffer(c.__webglFaceBuffer);l.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d=0)u=r.geometry.materials[u],u.transparent?(M.transparent=u,M.opaque=null):(M.opaque=u,M.transparent=null)}else if(u)u.transparent?(M.transparent=u,M.opaque=null):(M.opaque=u,M.transparent=null);f.render=!0;if(this.sortObjects)g.renderDepth?f.z=g.renderDepth:(Y.copy(g.position),J.multiplyVector3(Y),f.z=Y.z)}this.sortObjects&&h.sort(o);h=a.__webglObjectsImmediate;d=0; +for(e=h.length;d65535&&(v[ea].counter+=1,s=v[ea].hash+"_"+v[ea].counter,j.geometryGroups[s]===void 0&&(j.geometryGroups[s]={faces3:[],faces4:[],materialIndex:q,vertices:0,numMorphTargets:ha})),M instanceof +THREE.Face3?j.geometryGroups[s].faces3.push(o):j.geometryGroups[s].faces4.push(o),j.geometryGroups[s].vertices+=S;j.geometryGroupsList=[];o=void 0;for(o in j.geometryGroups)j.geometryGroups[o].id=na++,j.geometryGroupsList.push(j.geometryGroups[o])}for(k in m.geometryGroups)if(j=m.geometryGroups[k],!j.__webglVertexBuffer){o=j;o.__webglVertexBuffer=l.createBuffer();o.__webglNormalBuffer=l.createBuffer();o.__webglTangentBuffer=l.createBuffer();o.__webglColorBuffer=l.createBuffer();o.__webglUVBuffer= +l.createBuffer();o.__webglUV2Buffer=l.createBuffer();o.__webglSkinVertexABuffer=l.createBuffer();o.__webglSkinVertexBBuffer=l.createBuffer();o.__webglSkinIndicesBuffer=l.createBuffer();o.__webglSkinWeightsBuffer=l.createBuffer();o.__webglFaceBuffer=l.createBuffer();o.__webglLineBuffer=l.createBuffer();if(o.numMorphTargets){M=p=void 0;o.__webglMorphTargetsBuffers=[];p=0;for(M=o.numMorphTargets;p0||S.faceVertexUvs.length>0)j.__uvArray=new Float32Array(o*2);if(S.faceUvs.length>1||S.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(o*2)}if(q.geometry.skinWeights.length&& +q.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(o*4),j.__skinVertexBArray=new Float32Array(o*4),j.__skinIndexArray=new Float32Array(o*4),j.__skinWeightArray=new Float32Array(o*4);j.__faceArray=new Uint16Array(M*3);j.__lineArray=new Uint16Array(ea*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];q=0;for(S=j.numMorphTargets;q0&&(l.bindBuffer(l.ARRAY_BUFFER,p.__webglSkinVertexABuffer),l.bufferData(l.ARRAY_BUFFER, +Q,M),l.bindBuffer(l.ARRAY_BUFFER,p.__webglSkinVertexBBuffer),l.bufferData(l.ARRAY_BUFFER,aa,M),l.bindBuffer(l.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),l.bufferData(l.ARRAY_BUFFER,O,M),l.bindBuffer(l.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),l.bufferData(l.ARRAY_BUFFER,ia,M))}if(ra&&ea){s=0;for(v=E.length;s0&&(l.bindBuffer(l.ARRAY_BUFFER,p.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,U,M))}if(F&&V.hasTangents){s=0;for(v=E.length;s0&&(l.bindBuffer(l.ARRAY_BUFFER,p.__webglUVBuffer),l.bufferData(l.ARRAY_BUFFER,ca,M))}if(qa&&ta&&T){s=0;for(v=E.length;s0&&(l.bindBuffer(l.ARRAY_BUFFER,p.__webglUV2Buffer),l.bufferData(l.ARRAY_BUFFER,B,M))}if(ya){s=0;for(v=E.length;s=0&&j.enableVertexAttribArray(o.position);o.color>=0&&j.enableVertexAttribArray(o.color);o.normal>=0&&j.enableVertexAttribArray(o.normal); -o.tangent>=0&&j.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(j.enableVertexAttribArray(o.skinVertexA),j.enableVertexAttribArray(o.skinVertexB),j.enableVertexAttribArray(o.skinIndex),j.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(f in a.attributes)o[f]!==void 0&&o[f]>=0&&j.enableVertexAttribArray(o[f]);if(a.morphTargets)for(f=a.numSupportedMorphTargets=0;f=0&&(j.enableVertexAttribArray(o[K]), -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)};this.setBlending=function(a){if(a!==oa){switch(a){case THREE.AdditiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE);break;case THREE.SubtractiveBlending:j.blendEquation(j.FUNC_ADD); -j.blendFunc(j.ZERO,j.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.SRC_COLOR);break;default:j.blendEquationSeparate(j.FUNC_ADD,j.FUNC_ADD),j.blendFuncSeparate(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA,j.ONE,j.ONE_MINUS_SRC_ALPHA)}oa=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=j.createTexture(),R.info.memory.textures++;j.activeTexture(j.TEXTURE0+b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture); -var c=s(j.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?j.texImage2D(j.TEXTURE_2D,0,Q(a.format),a.image.width,a.image.height,0,Q(a.format),j.UNSIGNED_BYTE,a.image.data):j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,a.image);c&&j.generateMipmap(j.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else j.activeTexture(j.TEXTURE0+b),j.bindTexture(j.TEXTURE_2D,a.__webglTexture)}}; +"",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");l.attachShader(p,G("fragment",g+j));l.attachShader(p, +G("vertex",d+m));l.linkProgram(p);l.getProgramParameter(p,l.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+l.getProgramParameter(p,l.VALIDATE_STATUS)+", gl error ["+l.getError()+"]");p.uniforms={};p.attributes={};var M,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(M in i)d.push(M);M=d;d=0;for(i=M.length;d=0&&l.enableVertexAttribArray(o.position);o.color>=0&&l.enableVertexAttribArray(o.color);o.normal>=0&&l.enableVertexAttribArray(o.normal); +o.tangent>=0&&l.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(l.enableVertexAttribArray(o.skinVertexA),l.enableVertexAttribArray(o.skinVertexB),l.enableVertexAttribArray(o.skinIndex),l.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(f in a.attributes)o[f]!==void 0&&o[f]>=0&&l.enableVertexAttribArray(o[f]);if(a.morphTargets)for(f=a.numSupportedMorphTargets=0;f=0&&(l.enableVertexAttribArray(o[M]), +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"?l.frontFace(l.CCW):l.frontFace(l.CW),a==="back"?l.cullFace(l.BACK):a==="front"?l.cullFace(l.FRONT):l.cullFace(l.FRONT_AND_BACK),l.enable(l.CULL_FACE)):l.disable(l.CULL_FACE)};this.setBlending=function(a){if(a!==ra){switch(a){case THREE.AdditiveBlending:l.blendEquation(l.FUNC_ADD);l.blendFunc(l.SRC_ALPHA,l.ONE);break;case THREE.SubtractiveBlending:l.blendEquation(l.FUNC_ADD); +l.blendFunc(l.ZERO,l.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:l.blendEquation(l.FUNC_ADD);l.blendFunc(l.ZERO,l.SRC_COLOR);break;default:l.blendEquationSeparate(l.FUNC_ADD,l.FUNC_ADD),l.blendFuncSeparate(l.SRC_ALPHA,l.ONE_MINUS_SRC_ALPHA,l.ONE,l.ONE_MINUS_SRC_ALPHA)}ra=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=l.createTexture(),R.info.memory.textures++;l.activeTexture(l.TEXTURE0+b);l.bindTexture(l.TEXTURE_2D,a.__webglTexture); +var c=s(l.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?l.texImage2D(l.TEXTURE_2D,0,Q(a.format),a.image.width,a.image.height,0,Q(a.format),l.UNSIGNED_BYTE,a.image.data):l.texImage2D(l.TEXTURE_2D,0,l.RGBA,l.RGBA,l.UNSIGNED_BYTE,a.image);c&&l.generateMipmap(l.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else l.activeTexture(l.TEXTURE0+b),l.bindTexture(l.TEXTURE_2D,a.__webglTexture)}}; 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: THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:!0}; THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0}; @@ -352,19 +343,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,b,c,d){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.Math.clamp(e.h+b,0,1);e.s=THREE.Math.clamp(e.s+c,0,1);e.v=THREE.Math.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,e=a.b,g=Math.max(Math.max(c,d),e),f=Math.min(Math.min(c,d),e);if(f===g)f=c=0;else{var h=g-f,f=h/g,c=c===g?(d-e)/h:d===g?2+(e-c)/h:4+(c-d)/h;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=f;b.v=g;return b}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,g=b instanceof THREE.Mesh?b.geometry:b,f=a.vertices,h=g.vertices,i=a.faces,l=g.faces,k=a.faceVertexUvs[0],o=g.faceVertexUvs[0],p={},m=0;m1&&(d=1-d,e=1-e);g=1-d-e;f.copy(a);f.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);f.addSelf(h);h.copy(c);h.multiplyScalar(g);f.addSelf(h);return f},randomPointInFace:function(a,b,c){var d,e,g;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,e=b.vertices[a.b].position, g=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,g);else if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;g=b.vertices[a.c].position;var b=b.vertices[a.d].position,f;c?a._area1&&a._area2?(c=a._area1,f=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),f=THREE.GeometryUtils.triangleArea(e,g,b),a._area1=c,a._area2=f):(c=THREE.GeometryUtils.triangleArea(d,e,b),f=THREE.GeometryUtils.triangleArea(e,g,b));return THREE.GeometryUtils.random()*(c+ -f)a?b(c,e-1):l[e]a?b(c,e-1):j[e]0?(f=c[c.length-1],m=f.x,r=f.y):(f=this.actions[d-1].args,m=f[f.length-2],r=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b2(n,m,o,h),n=THREE.Shape.Utils.b2(n,r,p, -i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];o=g[0];p=g[1];l=g[2];k=g[3];c.length>0?(f=c[c.length-1],m=f.x,r=f.y):(f=this.actions[d-1].args,m=f[f.length-2],r=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b3(n,m,o,l,h),n=THREE.Shape.Utils.b3(n,r,p,k,i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];n=a*g[0].length;f=f.concat(g[0]);g=new THREE.SplineCurve(f); -for(f=1;f<=n;f++)c.push(g.getPointAt(f/n));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=g[0];i=g[1];l=g[2];o=g[3];n=g[4];p=!!g[5];k=f[f.length-2];m=f[f.length-1];f.length==0&&(k=m=0);r=n-o;var q=a*2;for(f=1;f<=q;f++)n=f/q,p||(n=1-n),n=o+n*r,g=k+h+l*Math.cos(n),n=m+i+l*Math.sin(n),c.push(new THREE.Vector2(g,n))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; -THREE.Path.prototype.nltransform=function(a,b,c,d,e,g){var f=this.getPoints(),h,i,l,k,o;h=0;for(i=f.length;h0?(f=c[c.length-1],m=f.x,q=f.y):(f=this.actions[d-1].args,m=f[f.length-2],q=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b2(n,m,o,h),n=THREE.Shape.Utils.b2(n,q,p, +i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];o=g[0];p=g[1];j=g[2];k=g[3];c.length>0?(f=c[c.length-1],m=f.x,q=f.y):(f=this.actions[d-1].args,m=f[f.length-2],q=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b3(n,m,o,j,h),n=THREE.Shape.Utils.b3(n,q,p,k,i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];n=a*g[0].length;f=f.concat(g[0]);g=new THREE.SplineCurve(f); +for(f=1;f<=n;f++)c.push(g.getPointAt(f/n));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=g[0];i=g[1];j=g[2];o=g[3];n=g[4];p=!!g[5];k=f[f.length-2];m=f[f.length-1];f.length==0&&(k=m=0);q=n-o;var r=a*2;for(f=1;f<=r;f++)n=f/r,p||(n=1-n),n=o+n*q,g=k+h+j*Math.cos(n),n=m+i+j*Math.sin(n),c.push(new THREE.Vector2(g,n))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; +THREE.Path.prototype.nltransform=function(a,b,c,d,e,g){var f=this.getPoints(),h,i,j,k,o;h=0;for(i=f.length;h=0?h-1:c.length-1;g=f-1>=0?f-1:l.length-1;var n=[l[f],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(n);var q=[l[f],l[g],c[h]];p=THREE.FontUtils.Triangulate.area(q);m=h;k=f;h+=1;f+=-1;h< -0&&(h+=c.length);h%=c.length;f<0&&(f+=l.length);f%=l.length;e=h-1>=0?h-1:c.length-1;g=f-1>=0?f-1:l.length-1;n=[l[f],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);q=[l[f],l[g],c[h]];q=THREE.FontUtils.Triangulate.area(q);o+p>n+q&&(h=m,f=k,h<0&&(h+=c.length),h%=c.length,f<0&&(f+=l.length),f%=l.length,e=h-1>=0?h-1:c.length-1,g=f-1>=0?f-1:l.length-1);o=c.slice(0,h);p=c.slice(h);m=l.slice(f);k=l.slice(0,f);g=[l[f],l[g],c[h]];r.push([l[f],c[h],c[e]]);r.push(g);c=o.concat(m).concat(k).concat(p)}return{shape:c, -isolatedPts:r,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),g,f,h,i,l={};g=0;for(f=d.length;g=0?h-1:c.length-1;g=f-1>=0?f-1:j.length-1;var n=[j[f],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(n);var r=[j[f],j[g],c[h]];p=THREE.FontUtils.Triangulate.area(r);m=h;k=f;h+=1;f+=-1;h< +0&&(h+=c.length);h%=c.length;f<0&&(f+=j.length);f%=j.length;e=h-1>=0?h-1:c.length-1;g=f-1>=0?f-1:j.length-1;n=[j[f],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);r=[j[f],j[g],c[h]];r=THREE.FontUtils.Triangulate.area(r);o+p>n+r&&(h=m,f=k,h<0&&(h+=c.length),h%=c.length,f<0&&(f+=j.length),f%=j.length,e=h-1>=0?h-1:c.length-1,g=f-1>=0?f-1:j.length-1);o=c.slice(0,h);p=c.slice(h);m=j.slice(f);k=j.slice(0,f);g=[j[f],j[g],c[h]];q.push([j[f],c[h],c[e]]);q.push(g);c=o.concat(m).concat(k).concat(p)}return{shape:c, +isolatedPts:q,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),g,f,h,i,j={};g=0;for(f=d.length;g1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+m),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[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]=e,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",m,h.index+1).pos,d=d*0.33+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[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(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(c=== -"rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d}}if(this.JITCompile&&k[0][l]===void 0){this.hierarchy[0].update(null,!0);for(m=0;ma.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];h=a[c[1]];i=a[c[2]];l=a[c[3]];c=e*e;f=e*c;d[0]=this.interpolate(g[0],h[0],i[0],l[0],e,c,f);d[1]=this.interpolate(g[1],h[1],i[1],l[1],e,c,f);d[2]=this.interpolate(g[2],h[2],i[2],l[2],e,c,f);return d}; +"rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d}}if(this.JITCompile&&k[0][j]===void 0){this.hierarchy[0].update(null,!0);for(m=0;ma.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=e*e;f=e*c;d[0]=this.interpolate(g[0],h[0],i[0],j[0],e,c,f);d[1]=this.interpolate(g[1],h[1],i[1],j[1],e,c,f);d[2]=this.interpolate(g[2],h[2],i[2],j[2],e,c,f);return d}; THREE.Animation.prototype.interpolate=function(a,b,c,d,e,g,f){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*f+(-3*(b-c)-2*a-d)*g+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]}; THREE.CubeCamera=function(a,b,c,d){this.heightOffset=c;this.position=new THREE.Vector3(0,c,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position= @@ -461,7 +452,7 @@ function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37: this.object.translateX(b);this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);c=a*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a= 1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)* Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)}; -THREE.PathControls=function(a,b){function c(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 e(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},g,f=b.getControlPointsArray(),h=b.getLength(),q=f.length,t=0;g=q-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[g]={time:d,pos:f[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;g=0?a:a+f;b=this.verticalAngleMap.srcRange; @@ -479,42 +470,42 @@ THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,argu this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z= -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this, this.mouseup),!1);this.domElement.addEventListener("keydown",c(this,this.keydown),!1);this.domElement.addEventListener("keyup",c(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()}; -THREE.RollControls=function(a,b){this.object=a;this.domElement=b!==void 0?b:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Vector3,g=new THREE.Matrix4,f=!1,h=1,i=0,l=0,k=0,o=0,p=0,m=window.innerWidth/2,r=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var b=a*this.lookSpeed; -this.rotateHorizontally(b*o);this.rotateVertically(b*p)}b=a*this.movementSpeed;this.object.translateZ(-b*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*l);this.object.translateY(b*k);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(b*j);this.object.translateY(b*k);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-g*g);f.copy(c.object.position).subSelf(c.target);g=c.object.up.clone().setLength(d.y);g.addSelf(c.object.up.clone().crossSelf(f).setLength(d.x));g.addSelf(f.setLength(d.z));return g};this.rotateCamera=function(){var a=Math.acos(h.dot(i)/h.length()/i.length());if(a){var b=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion;a*=c.rotateSpeed;d.setFromAxisAngle(b, --a);d.multiplyVector3(f);d.multiplyVector3(c.object.up);d.multiplyVector3(i);c.staticMoving?h=i:(d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-l.y)*c.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),c.staticMoving?l=k:l.y+=(k.y-l.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=p.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(f.length()*c.panSpeed);var b=f.clone().crossSelf(c.object.up).setLength(a.x);b.addSelf(c.object.up.clone().setLength(a.y)); +this.target=new THREE.Vector3(0,0,0);var e=!1,g=d.NONE,f=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector2,k=new THREE.Vector2,o=new THREE.Vector2,p=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,b){return new THREE.Vector2((a-c.screen.offsetLeft)/c.radius*0.5,(b-c.screen.offsetTop)/c.radius*0.5)};this.getMouseProjectionOnBall=function(a,b){var d=new THREE.Vector3((a-c.screen.width*0.5- +c.screen.offsetLeft)/c.radius,(c.screen.height*0.5+c.screen.offsetTop-b)/c.radius,0),e=d.length();e>1?d.normalize():d.z=Math.sqrt(1-e*e);f.copy(c.object.position).subSelf(c.target);e=c.object.up.clone().setLength(d.y);e.addSelf(c.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 b=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion;a*=c.rotateSpeed;d.setFromAxisAngle(b, +-a);d.multiplyVector3(f);d.multiplyVector3(c.object.up);d.multiplyVector3(i);c.staticMoving?h=i:(d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-j.y)*c.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),c.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=p.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(f.length()*c.panSpeed);var b=f.clone().crossSelf(c.object.up).setLength(a.x);b.addSelf(c.object.up.clone().setLength(a.y)); c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?o=p:o.addSelf(a.sub(p,o).multiplyScalar(c.dynamicDampingFactor))}};this.checkDistances=function(){if(!c.noZoom||!c.noPan)c.object.position.lengthSq()>c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),f.lengthSq()0?1:-1;for(h=0;h0?1:-1;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;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(e).addSelf(h).subSelf(a).clone()}function e(a){for(s=a.length;--s>=0;){V=s;R=s-1;R<0&&(R=a.length-1);for(var b= -0,c=m+k*2,b=0;b=0;U--){Z=U/k;Q=i*(1-Z);Z=l*Math.sin(Z*Math.PI/2);s=0;for(G=v.length;sa&&(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 e(a){for(s=a.length;--s>=0;){V=s;R=s-1;R<0&&(R=a.length-1);for(var b= +0,c=m+k*2,b=0;b=0;T--){Z=T/k;Q=i*(1-Z);Z=j*Math.sin(Z*Math.PI/2);s=0;for(E=u.length;s0)for(l=0;l2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return g}i=l;e<=i&&(i=0);l=i+1;e<=l&&(l=0);k=l+1;e<=k&&(k=0);var p;a:{p=a;var m=i,r=l,n=k,q=e,t=f,v=void 0,z=void 0,u=void 0, -B=void 0,A=void 0,F=void 0,H=void 0,E=void 0,L=void 0,z=p[t[m]].x,u=p[t[m]].y,B=p[t[r]].x,A=p[t[r]].y,F=p[t[n]].x,H=p[t[n]].y;if(1.0E-10>(B-z)*(H-u)-(A-u)*(F-z))p=!1;else{for(v=0;v=0&&U>=0&&Q>=0){p=!1;break a}}p= -!0}}if(p){g.push([a[f[i]],a[f[l]],a[f[k]]]);h.push([f[i],f[l],f[k]]);i=l;for(k=l+1;k0)for(j=0;j2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return g}i=j;e<=i&&(i=0);j=i+1;e<=j&&(j=0);k=j+1;e<=k&&(k=0);var p;a:{p=a;var m=i,q=j,n=k,r=e,t=f,u=void 0,y=void 0,v=void 0, +A=void 0,z=void 0,w=void 0,I=void 0,F=void 0,G=void 0,y=p[t[m]].x,v=p[t[m]].y,A=p[t[q]].x,z=p[t[q]].y,w=p[t[n]].x,I=p[t[n]].y;if(1.0E-10>(A-y)*(I-v)-(z-v)*(w-y))p=!1;else{for(u=0;u=0&&T>=0&&Q>=0){p=!1;break a}}p= +!0}}if(p){g.push([a[f[i]],a[f[j]],a[f[k]]]);h.push([f[i],f[j],f[k]]);i=j;for(k=j+1;k0;)this.smooth(a)}; -THREE.SubdivisionModifier.prototype.smooth=function(a){function b(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 l,m,j,n=0;n<4;n++){j=i[n];l=new THREE.Color;l.setRGB(0,0,0);for(var o=0;o=0){p=i.invBindMatrices[m];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p=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].length1){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};o.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};L.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 E)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=na[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(Ba+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=Aa;return this.material=new THREE.MeshLambertMaterial(a)};s.prototype.parse=function(a){for(var b=0;b=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};G.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=na[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(Ba+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=xa;return this.material=new THREE.MeshLambertMaterial(a)};s.prototype.parse=function(a){for(var b=0;b=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b1&&(G=new THREE.MeshFaceMaterial); -a=new THREE.Mesh(E,G);a.name=p;a.position.set(u[0],u[1],u[2]);A?(a.quaternion.set(A[0],A[1],A[2],A[3]),a.useQuaternion=!0):a.rotation.set(B[0],B[1],B[2]);a.scale.set(F[0],F[1],F[2]);a.visible=t.visible;y.scene.add(a);y.objects[p]=a;if(t.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);y.scene.collisions.colliders.push(b)}if(t.castsShadow)b=new THREE.ShadowVolume(E),y.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;t.trigger&&t.trigger.toLowerCase()!="none"&&(b= -{type:t.trigger,object:t},y.triggers[a.name]=b)}}else u=t.position,B=t.rotation,A=t.quaternion,F=t.scale,A=0,a=new THREE.Object3D,a.name=p,a.position.set(u[0],u[1],u[2]),A?(a.quaternion.set(A[0],A[1],A[2],A[3]),a.useQuaternion=!0):a.rotation.set(B[0],B[1],B[2]),a.scale.set(F[0],F[1],F[2]),a.visible=t.visible!==void 0?t.visible:!1,y.scene.add(a),y.objects[p]=a,y.empties[p]=a,t.trigger&&t.trigger.toLowerCase()!="none"&&(b={type:t.trigger,object:t},y.triggers[a.name]=b)}function g(a){return function(b){y.geometries[a]= -b;e();Q-=1;i.onLoadComplete();h()}}function f(a){return function(b){y.geometries[a]=b}}function h(){i.callbackProgress({totalModels:$,totalTextures:ia,loadedModels:$-Q,loadedTextures:ia-T},y);i.onLoadProgress();Q==0&&T==0&&b(y)}var i=this,l=THREE.Loader.prototype.extractUrlbase(c),k,o,p,m,r,n,q,t,v,z,u,B,A,F,H,E,L,s,G,U,Z,Q,T,$,ia,y;U=a;c=new THREE.BinaryLoader;Z=new THREE.JSONLoader;T=Q=0;y={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, -empties:{}};a=!1;for(p in U.objects)if(t=U.objects[p],t.meshCollider){a=!0;break}if(a)y.scene.collisions=new THREE.CollisionSystem;if(U.transform){a=U.transform.position;v=U.transform.rotation;var N=U.transform.scale;a&&y.scene.position.set(a[0],a[1],a[2]);v&&y.scene.rotation.set(v[0],v[1],v[2]);N&&y.scene.scale.set(N[0],N[1],N[2]);(a||v||N)&&y.scene.updateMatrix()}a=function(){T-=1;h();i.onLoadComplete()};for(r in U.cameras)v=U.cameras[r],v.type=="perspective"?L=new THREE.PerspectiveCamera(v.fov, -v.aspect,v.near,v.far):v.type=="ortho"&&(L=new THREE.OrthographicCamera(v.left,v.right,v.top,v.bottom,v.near,v.far)),u=v.position,v=v.target,L.position.set(u[0],u[1],u[2]),L.target=new THREE.Vector3(v[0],v[1],v[2]),y.cameras[r]=L;for(m in U.lights)v=U.lights[m],r=v.color!==void 0?v.color:16777215,L=v.intensity!==void 0?v.intensity:1,v.type=="directional"?(u=v.direction,z=new THREE.DirectionalLight(r,L),z.position.set(u[0],u[1],u[2]),z.position.normalize()):v.type=="point"?(u=v.position,z=v.distance, -z=new THREE.PointLight(r,L,z),z.position.set(u[0],u[1],u[2])):v.type=="ambient"&&(z=new THREE.AmbientLight(r)),y.scene.add(z),y.lights[m]=z;for(n in U.fogs)m=U.fogs[n],m.type=="linear"?s=new THREE.Fog(0,m.near,m.far):m.type=="exp2"&&(s=new THREE.FogExp2(0,m.density)),v=m.color,s.color.setRGB(v[0],v[1],v[2]),y.fogs[n]=s;if(y.cameras&&U.defaults.camera)y.currentCamera=y.cameras[U.defaults.camera];if(y.fogs&&U.defaults.fog)y.scene.fog=y.fogs[U.defaults.fog];v=U.defaults.bgcolor;y.bgColor=new THREE.Color; -y.bgColor.setRGB(v[0],v[1],v[2]);y.bgColorAlpha=U.defaults.bgalpha;for(k in U.geometries)if(n=U.geometries[k],n.type=="bin_mesh"||n.type=="ascii_mesh")Q+=1,i.onLoadStart();$=Q;for(k in U.geometries)n=U.geometries[k],n.type=="cube"?(E=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),y.geometries[k]=E):n.type=="plane"?(E=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),y.geometries[k]=E):n.type=="sphere"? -(E=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),y.geometries[k]=E):n.type=="cylinder"?(E=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),y.geometries[k]=E):n.type=="torus"?(E=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),y.geometries[k]=E):n.type=="icosahedron"?(E=new THREE.IcosahedronGeometry(n.subdivisions),y.geometries[k]=E):n.type=="bin_mesh"?c.load(d(n.url,U.urlBaseType),g(k)):n.type=="ascii_mesh"?Z.load(d(n.url,U.urlBaseType), -g(k)):n.type=="embedded_mesh"&&(n=U.embeds[n.id])&&Z.createModel(n,f(k),"");for(q in U.textures)if(k=U.textures[q],k.url instanceof Array){T+=k.url.length;for(n=0;n1&&(E=new THREE.MeshFaceMaterial); +a=new THREE.Mesh(F,E);a.name=p;a.position.set(v[0],v[1],v[2]);z?(a.quaternion.set(z[0],z[1],z[2],z[3]),a.useQuaternion=!0):a.rotation.set(A[0],A[1],A[2]);a.scale.set(w[0],w[1],w[2]);a.visible=t.visible;K.scene.add(a);K.objects[p]=a;if(t.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);K.scene.collisions.colliders.push(b)}if(t.castsShadow)b=new THREE.ShadowVolume(F),K.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;t.trigger&&t.trigger.toLowerCase()!="none"&&(b= +{type:t.trigger,object:t},K.triggers[a.name]=b)}}else v=t.position,A=t.rotation,z=t.quaternion,w=t.scale,z=0,a=new THREE.Object3D,a.name=p,a.position.set(v[0],v[1],v[2]),z?(a.quaternion.set(z[0],z[1],z[2],z[3]),a.useQuaternion=!0):a.rotation.set(A[0],A[1],A[2]),a.scale.set(w[0],w[1],w[2]),a.visible=t.visible!==void 0?t.visible:!1,K.scene.add(a),K.objects[p]=a,K.empties[p]=a,t.trigger&&t.trigger.toLowerCase()!="none"&&(b={type:t.trigger,object:t},K.triggers[a.name]=b)}function g(a){return function(b){K.geometries[a]= +b;e();Q-=1;i.onLoadComplete();h()}}function f(a){return function(b){K.geometries[a]=b}}function h(){i.callbackProgress({totalModels:$,totalTextures:ja,loadedModels:$-Q,loadedTextures:ja-U},K);i.onLoadProgress();Q==0&&U==0&&b(K)}var i=this,j=THREE.Loader.prototype.extractUrlbase(c),k,o,p,m,q,n,r,t,u,y,v,A,z,w,I,F,G,s,E,T,Z,Q,U,$,ja,K;T=a;c=new THREE.BinaryLoader;Z=new THREE.JSONLoader;U=Q=0;K={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, +empties:{}};a=!1;for(p in T.objects)if(t=T.objects[p],t.meshCollider){a=!0;break}if(a)K.scene.collisions=new THREE.CollisionSystem;if(T.transform){a=T.transform.position;u=T.transform.rotation;var L=T.transform.scale;a&&K.scene.position.set(a[0],a[1],a[2]);u&&K.scene.rotation.set(u[0],u[1],u[2]);L&&K.scene.scale.set(L[0],L[1],L[2]);(a||u||L)&&K.scene.updateMatrix()}a=function(){U-=1;h();i.onLoadComplete()};for(q in T.cameras)u=T.cameras[q],u.type=="perspective"?G=new THREE.PerspectiveCamera(u.fov, +u.aspect,u.near,u.far):u.type=="ortho"&&(G=new THREE.OrthographicCamera(u.left,u.right,u.top,u.bottom,u.near,u.far)),v=u.position,u=u.target,G.position.set(v[0],v[1],v[2]),G.target=new THREE.Vector3(u[0],u[1],u[2]),K.cameras[q]=G;for(m in T.lights)u=T.lights[m],q=u.color!==void 0?u.color:16777215,G=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(v=u.direction,y=new THREE.DirectionalLight(q,G),y.position.set(v[0],v[1],v[2]),y.position.normalize()):u.type=="point"?(v=u.position,y=u.distance, +y=new THREE.PointLight(q,G,y),y.position.set(v[0],v[1],v[2])):u.type=="ambient"&&(y=new THREE.AmbientLight(q)),K.scene.add(y),K.lights[m]=y;for(n in T.fogs)m=T.fogs[n],m.type=="linear"?s=new THREE.Fog(0,m.near,m.far):m.type=="exp2"&&(s=new THREE.FogExp2(0,m.density)),u=m.color,s.color.setRGB(u[0],u[1],u[2]),K.fogs[n]=s;if(K.cameras&&T.defaults.camera)K.currentCamera=K.cameras[T.defaults.camera];if(K.fogs&&T.defaults.fog)K.scene.fog=K.fogs[T.defaults.fog];u=T.defaults.bgcolor;K.bgColor=new THREE.Color; +K.bgColor.setRGB(u[0],u[1],u[2]);K.bgColorAlpha=T.defaults.bgalpha;for(k in T.geometries)if(n=T.geometries[k],n.type=="bin_mesh"||n.type=="ascii_mesh")Q+=1,i.onLoadStart();$=Q;for(k in T.geometries)n=T.geometries[k],n.type=="cube"?(F=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),K.geometries[k]=F):n.type=="plane"?(F=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),K.geometries[k]=F):n.type=="sphere"? +(F=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),K.geometries[k]=F):n.type=="cylinder"?(F=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),K.geometries[k]=F):n.type=="torus"?(F=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),K.geometries[k]=F):n.type=="icosahedron"?(F=new THREE.IcosahedronGeometry(n.subdivisions),K.geometries[k]=F):n.type=="bin_mesh"?c.load(d(n.url,T.urlBaseType),g(k)):n.type=="ascii_mesh"?Z.load(d(n.url,T.urlBaseType), +g(k)):n.type=="embedded_mesh"&&(n=T.embeds[n.id])&&Z.createModel(n,f(k),"");for(r in T.textures)if(k=T.textures[r],k.url instanceof Array){U+=k.url.length;for(n=0;n=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;e<8;e++){for(var g=0,f=0;f>1^-(h&1);c[8*f+e]=g}d+=b}b=a.length-d;g=new Uint16Array(b);for(e=f=0;e=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 b=this.count*3;bthis.size-1&&(i=this.size-1);var p=Math.floor(l-h);p<1&&(p=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var m=Math.floor(k-h);m<1&&(m=1);h=Math.floor(k+h);h>this.size-1&&(h=this.size- -1);for(var r,n,q,t,v,z;o0&&(this.field[q+r]+=t)}}};this.addPlaneX=function(a,b){var e,g,f,h,i,l=this.size,k=this.yd,o=this.zd,p=this.field,m=l*Math.sqrt(a/b);m>l&&(m=l);for(e=0;e0)for(g=0;gk&&(r=k);for(g=0;g0){i=g*o;for(e=0;ek&&(r=k);for(f=0;f0){i=p*f;for(g=0;gthis.size-1&&(i=this.size-1);var p=Math.floor(j-h);p<1&&(p=1);j=Math.floor(j+h);j>this.size-1&&(j=this.size-1);var m=Math.floor(k-h);m<1&&(m=1);h=Math.floor(k+h);h>this.size-1&&(h=this.size- +1);for(var q,n,r,t,u,y;o0&&(this.field[r+q]+=t)}}};this.addPlaneX=function(a,b){var e,g,f,h,i,j=this.size,k=this.yd,o=this.zd,p=this.field,m=j*Math.sqrt(a/b);m>j&&(m=j);for(e=0;e0)for(g=0;gk&&(q=k);for(g=0;g0){i=g*o;for(e=0;ek&&(q=k);for(f=0;f0){i=p*f;for(g=0;g0&&B.x0&&B.y0.0010&&m.scale>0.0010)u.x=m.x,u.y=m.y,u.z=m.z,v=m.size*m.scale/h,z.x=v*n,z.y=v,b.uniform3f(A.screenPosition, -u.x,u.y,u.z),b.uniform2f(A.scale,z.x,z.y),b.uniform1f(A.rotation,m.rotation),b.uniform1f(A.opacity,m.opacity),b.uniform3f(A.color,m.color.r,m.color.g,m.color.b),c.setBlending(m.blending),c.setTexture(m.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var b=this,c=this.setSize,d=this.render,e=new THREE.PerspectiveCamera,g=new THREE.PerspectiveCamera,f=new THREE.Matrix4,h=new THREE.Matrix4,i,l,k,o;e.matrixAutoUpdate=g.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},p=new THREE.WebGLRenderTarget(512,512,a),m=new THREE.WebGLRenderTarget(512,512,a),r=new THREE.PerspectiveCamera(53, -1,1,1E4);r.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:p},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}"}), -n=new THREE.Scene;n.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));n.add(r);this.setSize=function(a,d){c.call(b,a,d);p.width=a;p.height=d;m.width=a;m.height=d};this.render=function(a,c){a.updateMatrixWorld();if(i!==c.aspect||l!==c.near||k!==c.far||o!==c.fov){i=c.aspect;l=c.near;k=c.far;o=c.fov;var v=c.projectionMatrix.clone(),z=125/30*0.5,u=z*l/125,B=l*Math.tan(o*Math.PI/360),A;f.n14=z;h.n14=-z;z=-B*i+u;A=B*i+u;v.n11=2*l/(A-z);v.n13=(A+z)/(A-z);e.projectionMatrix.copy(v);z=-B*i-u;A=B*i-u;v.n11= -2*l/(A-z);v.n13=(A+z)/(A-z);g.projectionMatrix.copy(v)}e.matrixWorld.copy(c.matrixWorld).multiplySelf(h);e.position.copy(c.position);e.near=c.near;e.far=c.far;d.call(b,a,e,p,!0);g.matrixWorld.copy(c.matrixWorld).multiplySelf(f);g.position.copy(c.position);g.near=c.near;g.far=c.far;d.call(b,a,g,m,!0);n.updateMatrixWorld();d.call(b,n,r)}}; +"color");d.uniforms.scale=b.getUniformLocation(d.program,"scale");d.uniforms.rotation=b.getUniformLocation(d.program,"rotation");d.uniforms.screenPosition=b.getUniformLocation(d.program,"screenPosition");d.attributesEnabled=!1};this.render=function(a,g,f,h){var a=a.__webglFlares,i,j,k=a.length,o,p,m,q=new THREE.Vector3,n=h/f,r=f*0.5,t=h*0.5,u=16/h,y=new THREE.Vector2(u*n,u),v=new THREE.Vector3(1,1,0),A=new THREE.Vector2(1,1),z=d.uniforms;i=d.attributes;b.useProgram(d.program);if(!d.attributesEnabled)b.enableVertexAttribArray(d.attributes.vertex), +b.enableVertexAttribArray(d.attributes.uv),d.attributesEnabled=!0;b.uniform1i(z.occlusionMap,0);b.uniform1i(z.map,1);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(i.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(i.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.disable(b.CULL_FACE);b.depthMask(!1);for(j=0;j0&&A.x0&&A.y0.0010&&m.scale>0.0010)v.x=m.x,v.y=m.y,v.z=m.z,u=m.size*m.scale/h,y.x=u*n,y.y=u,b.uniform3f(z.screenPosition, +v.x,v.y,v.z),b.uniform2f(z.scale,y.x,y.y),b.uniform1f(z.rotation,m.rotation),b.uniform1f(z.opacity,m.opacity),b.uniform3f(z.color,m.color.r,m.color.g,m.color.b),c.setBlending(m.blending),c.setTexture(m.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}; +THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d={};this.init=function(a){b=a.context;c=a;d.vertices=new Float32Array(16);d.faces=new Uint16Array(6);a=0;d.vertices[a++]=-1;d.vertices[a++]=-1;d.vertices[a++]=0;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=-1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=0;d.vertices[a++]=-1;d.vertices[a++]=1;d.vertices[a++]=0;a=d.vertices[a++]=0;d.faces[a++]=0;d.faces[a++]=1;d.faces[a++]= +2;d.faces[a++]=0;d.faces[a++]=2;d.faces[a++]=3;d.vertexBuffer=b.createBuffer();d.elementBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.bufferData(b.ARRAY_BUFFER,d.vertices,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,d.faces,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,g=b.createProgram(),f=b.createShader(b.FRAGMENT_SHADER),h=b.createShader(b.VERTEX_SHADER);b.shaderSource(f,a.fragmentShader);b.shaderSource(h,a.vertexShader); +b.compileShader(f);b.compileShader(h);b.attachShader(g,f);b.attachShader(g,h);b.linkProgram(g);d.program=g;d.attributes={};d.uniforms={};d.attributes.position=b.getAttribLocation(d.program,"position");d.attributes.uv=b.getAttribLocation(d.program,"uv");d.uniforms.uvOffset=b.getUniformLocation(d.program,"uvOffset");d.uniforms.uvScale=b.getUniformLocation(d.program,"uvScale");d.uniforms.rotation=b.getUniformLocation(d.program,"rotation");d.uniforms.scale=b.getUniformLocation(d.program,"scale");d.uniforms.alignment= +b.getUniformLocation(d.program,"alignment");d.uniforms.color=b.getUniformLocation(d.program,"color");d.uniforms.map=b.getUniformLocation(d.program,"map");d.uniforms.opacity=b.getUniformLocation(d.program,"opacity");d.uniforms.useScreenCoordinates=b.getUniformLocation(d.program,"useScreenCoordinates");d.uniforms.affectedByDistance=b.getUniformLocation(d.program,"affectedByDistance");d.uniforms.screenPosition=b.getUniformLocation(d.program,"screenPosition");d.uniforms.modelViewMatrix=b.getUniformLocation(d.program, +"modelViewMatrix");d.uniforms.projectionMatrix=b.getUniformLocation(d.program,"projectionMatrix");d.attributesEnabled=!1};this.render=function(e,g,f,h,i){var j,k;j=d.attributes;var o=d.uniforms,p=h/f,m=[];f*=0.5;var q=h*0.5,n=!0;b.useProgram(d.program);_currentProgram=d.program;if(!d.attributesEnabled)b.enableVertexAttribArray(j.position),b.enableVertexAttribArray(j.uv),d.attributesEnabled=!0;b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(j.position, +2,b.FLOAT,!1,16,0);b.vertexAttribPointer(j.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.uniformMatrix4fv(o.projectionMatrix,!1,i);b.activeTexture(b.TEXTURE0);b.uniform1i(o.map,0);i=0;for(j=e.__webglSprites.length;i1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=f;b.v=g;return b}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,g=b instanceof THREE.Mesh?b.geometry:b,f=a.vertices,h=g.vertices,i=a.faces,k=g.faces,j=a.faceVertexUvs[0],q=g.faceVertexUvs[0],o={},l=0;l1&&(d=1-d,e=1-e);g=1-d-e;f.copy(a);f.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);f.addSelf(h);h.copy(c);h.multiplyScalar(g);f.addSelf(h);return f},randomPointInFace:function(a,b,c){var d,e,g;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,e=b.vertices[a.b].position, g=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,g);else if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;g=b.vertices[a.c].position;var b=b.vertices[a.d].position,f;c?a._area1&&a._area2?(c=a._area1,f=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),f=THREE.GeometryUtils.triangleArea(e,g,b),a._area1=c,a._area2=f):(c=THREE.GeometryUtils.triangleArea(d,e,b),f=THREE.GeometryUtils.triangleArea(e,g,b));return THREE.GeometryUtils.random()*(c+ -f)a?b(c,e-1):k[e]a?b(d,e-1):k[e]0?(f=c[c.length-1],l=f.x,s=f.y):(f=this.actions[d-1].args,l=f[f.length-2],s=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b2(n,l,q,h),n=THREE.Shape.Utils.b2(n,s,o, -i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];q=g[0];o=g[1];k=g[2];j=g[3];c.length>0?(f=c[c.length-1],l=f.x,s=f.y):(f=this.actions[d-1].args,l=f[f.length-2],s=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b3(n,l,q,k,h),n=THREE.Shape.Utils.b3(n,s,o,j,i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];n=a*g[0].length;f=f.concat(g[0]);g=new THREE.SplineCurve(f); -for(f=1;f<=n;f++)c.push(g.getPointAt(f/n));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=g[0];i=g[1];k=g[2];q=g[3];n=g[4];o=!!g[5];j=f[f.length-2];l=f[f.length-1];f.length==0&&(j=l=0);s=n-q;var p=a*2;for(f=1;f<=p;f++)n=f/p,o||(n=1-n),n=q+n*s,g=j+h+k*Math.cos(n),n=l+i+k*Math.sin(n),c.push(new THREE.Vector2(g,n))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; -THREE.Path.prototype.nltransform=function(a,b,c,d,e,g){var f=this.getPoints(),h,i,k,j,q;h=0;for(i=f.length;h0?(f=c[c.length-1],l=f.x,s=f.y):(f=this.actions[d-1].args,l=f[f.length-2],s=f[f.length-1]);for(f=1;f<=a;f++)m=f/a,g=THREE.Shape.Utils.b2(m,l,p,h),m=THREE.Shape.Utils.b2(m,s,o, +i),c.push(new THREE.Vector2(g,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];p=g[0];o=g[1];k=g[2];j=g[3];c.length>0?(f=c[c.length-1],l=f.x,s=f.y):(f=this.actions[d-1].args,l=f[f.length-2],s=f[f.length-1]);for(f=1;f<=a;f++)m=f/a,g=THREE.Shape.Utils.b3(m,l,p,k,h),m=THREE.Shape.Utils.b3(m,s,o,j,i),c.push(new THREE.Vector2(g,m));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];m=a*g[0].length;f=f.concat(g[0]);g=new THREE.SplineCurve(f); +for(f=1;f<=m;f++)c.push(g.getPointAt(f/m));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=g[0];i=g[1];k=g[2];p=g[3];m=g[4];o=!!g[5];j=f[f.length-2];l=f[f.length-1];f.length==0&&(j=l=0);s=m-p;var q=a*2;for(f=1;f<=q;f++)m=f/q,o||(m=1-m),m=p+m*s,g=j+h+k*Math.cos(m),m=l+i+k*Math.sin(m),c.push(new THREE.Vector2(g,m))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; +THREE.Path.prototype.nltransform=function(a,b,c,d,e,g){var f=this.getPoints(),h,i,k,j,p;h=0;for(i=f.length;h=0?h-1:c.length-1;g=f-1>=0?f-1:k.length-1;var n=[k[f],c[h],c[e]];q=THREE.FontUtils.Triangulate.area(n);var p=[k[f],k[g],c[h]];o=THREE.FontUtils.Triangulate.area(p);l=h;j=f;h+=1;f+=-1;h< -0&&(h+=c.length);h%=c.length;f<0&&(f+=k.length);f%=k.length;e=h-1>=0?h-1:c.length-1;g=f-1>=0?f-1:k.length-1;n=[k[f],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);p=[k[f],k[g],c[h]];p=THREE.FontUtils.Triangulate.area(p);q+o>n+p&&(h=l,f=j,h<0&&(h+=c.length),h%=c.length,f<0&&(f+=k.length),f%=k.length,e=h-1>=0?h-1:c.length-1,g=f-1>=0?f-1:k.length-1);q=c.slice(0,h);o=c.slice(h);l=k.slice(f);j=k.slice(0,f);g=[k[f],k[g],c[h]];s.push([k[f],c[h],c[e]]);s.push(g);c=q.concat(l).concat(j).concat(o)}return{shape:c, +THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,g,f,h,i,k,j,p,o,l,s=[];for(i=0;i=0?h-1:c.length-1;g=f-1>=0?f-1:k.length-1;var m=[k[f],c[h],c[e]];p=THREE.FontUtils.Triangulate.area(m);var q=[k[f],k[g],c[h]];o=THREE.FontUtils.Triangulate.area(q);l=h;j=f;h+=1;f+=-1;h< +0&&(h+=c.length);h%=c.length;f<0&&(f+=k.length);f%=k.length;e=h-1>=0?h-1:c.length-1;g=f-1>=0?f-1:k.length-1;m=[k[f],c[h],c[e]];m=THREE.FontUtils.Triangulate.area(m);q=[k[f],k[g],c[h]];q=THREE.FontUtils.Triangulate.area(q);p+o>m+q&&(h=l,f=j,h<0&&(h+=c.length),h%=c.length,f<0&&(f+=k.length),f%=k.length,e=h-1>=0?h-1:c.length-1,g=f-1>=0?f-1:k.length-1);p=c.slice(0,h);o=c.slice(h);l=k.slice(f);j=k.slice(0,f);g=[k[f],k[g],c[h]];s.push([k[f],c[h],c[e]]);s.push(g);c=p.concat(l).concat(j).concat(o)}return{shape:c, isolatedPts:s,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),g,f,h,i,k={};g=0;for(f=d.length;g1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+l),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,d,e,g,f,h,i,k,j=this.data.JIT.hierarchy,p,o;this.currentTime+=a*this.timeScale;o=this.currentTime;p=this.currentTime%=this.data.length;k=parseInt(Math.min(p*this.data.fps,this.data.length*this.data.fps),10);for(var l=0,s=this.hierarchy.length;l1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+l),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",l,f.index-1).pos,this.points[1]=e,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",l,h.index+1).pos,d=d*0.33+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[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(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(c=== "rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(g[0]-e[0])*d,c.y=e[1]+(g[1]-e[1])*d,c.z=e[2]+(g[2]-e[2])*d}}if(this.JITCompile&&j[0][k]===void 0){this.hierarchy[0].update(null,!0);for(l=0;la.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];h=a[c[1]];i=a[c[2]];k=a[c[3]];c=e*e;f=e*c;d[0]=this.interpolate(g[0],h[0],i[0],k[0],e,c,f);d[1]=this.interpolate(g[1],h[1],i[1],k[1],e,c,f);d[2]=this.interpolate(g[2],h[2],i[2],k[2],e,c,f);return d}; @@ -94,72 +94,72 @@ THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hie THREE.CubeCamera=function(a,b,c,d){this.heightOffset=c;this.position=new THREE.Vector3(0,c,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position= this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ= new THREE.Vector3(0,0,0);this.renderTarget=new THREE.WebGLRenderTargetCube(d,d,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(a){this.position.copy(a);this.position.y+=this.heightOffset;this.targetPX.copy(this.position);this.targetNX.copy(this.position);this.targetPY.copy(this.position);this.targetNY.copy(this.position);this.targetPZ.copy(this.position);this.targetNZ.copy(this.position);this.targetPX.x+=1;this.targetNX.x-=1;this.targetPY.y+= -1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,c){var b=this.renderTarget;b.activeCubeFace=0;a.render(c,this.cameraPX,b);b.activeCubeFace=1;a.render(c,this.cameraNX,b);b.activeCubeFace=2;a.render(c,this.cameraPY,b);b.activeCubeFace=3;a.render(c, -this.cameraNY,b);b.activeCubeFace=4;a.render(c,this.cameraPZ,b);b.activeCubeFace=5;a.render(c,this.cameraNZ,b)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")}; +1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,b){var d=this.renderTarget;d.activeCubeFace=0;a.render(b,this.cameraPX,d);d.activeCubeFace=1;a.render(b,this.cameraNX,d);d.activeCubeFace=2;a.render(b,this.cameraPY,d);d.activeCubeFace=3;a.render(b, +this.cameraNY,d);d.activeCubeFace=4;a.render(b,this.cameraPZ,d);d.activeCubeFace=5;a.render(b,this.cameraNZ,d)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")}; THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,b,c,d,e,g,f){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,g,f);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,e);this.zoom=1;this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera; THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPersepectiveMode=!0;this.inOrthographicMode=!1}; THREE.CombinedCamera.prototype.toOrthographic=function(){var a=Math.tan(this.fov/2)*((this.cameraP.near+this.cameraP.far)/2),b=2*a*this.cameraP.aspect/2;a/=this.zoom;b/=this.zoom;this.cameraO.left=-b;this.cameraO.right=b;this.cameraO.top=a;this.cameraO.bottom=-a;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPersepectiveMode=!1;this.inOrthographicMode=!0}; THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,b){b||(b=43.25);var c=2*Math.atan(b/(a*2));c*=180/Math.PI;this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()}; THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1}; THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1}; -THREE.FirstPersonControls=function(a,b){function c(a,c){return function(){c.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=b!==void 0?b:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor= +THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=b!==void 0?b:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor= 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward= !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown= function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp= -!1;break;case 70:this.moveDown=!1}};this.update=function(a){var c=0;if(!this.freeze){if(this.heightSpeed){var b=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=a*b*this.heightCoef}else this.autoSpeedFactor=0;c=a*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(c);this.moveLeft&&this.object.translateX(-c);this.moveRight&& -this.object.translateX(c);this.moveUp&&this.object.translateY(c);this.moveDown&&this.object.translateY(-c);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;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)* +!1;break;case 70:this.moveDown=!1}};this.update=function(a){var b=0;if(!this.freeze){if(this.heightSpeed){var c=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=a*c*this.heightCoef}else this.autoSpeedFactor=0;b=a*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(b);this.moveLeft&&this.object.translateX(-b);this.moveRight&& +this.object.translateX(b);this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);c=a*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a= +1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)* Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)}; -THREE.PathControls=function(a,b){function c(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function d(a,c){return function(){c.apply(a,arguments)}}function e(a,c,b,d){var f={name:b,fps:0.6,length:d,hierarchy:[]},e,g=c.getControlPointsArray(),h=c.getLength(),p=g.length,m=0;e=p-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[e]={time:d,pos:g[e],rot:[0,0,0,1],scl:[1,1,1]};for(e=1;e=0?a:a+f;b=this.verticalAngleMap.srcRange; a=this.verticalAngleMap.dstRange;b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove= -function(a){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}),c=new THREE.MeshLambertMaterial({color:65280}), -b=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(b,a);a=new THREE.Mesh(f,c);a.position.set(0,10,0);this.animation=e(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=e(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,c=this.spline,f=g(c,10),b=g(c,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),f=new THREE.Line(f,h),b=new THREE.ParticleSystem(b,new THREE.ParticleBasicMaterial({color:16755200,size:3}));f.scale.set(1,1,1);a.add(f);b.scale.set(1,1,1);a.add(b);for(var f=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),l=0;l0){var c=this.getContainerDimensions(),b=c.size[0]/2,f=c.size[1]/2;this.moveState.yawLeft=-(a.pageX-c.offset[0]-b)/b;this.moveState.pitchDown=(a.pageY-c.offset[1]-f)/f;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward= -!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(a){var c=a*this.movementSpeed;a*=this.rollSpeed;this.object.translateX(this.moveVector.x*c);this.object.translateY(this.moveVector.y*c);this.object.translateZ(this.moveVector.z*c);this.tmpQuaternion.set(this.rotationVector.x*a,this.rotationVector.y*a,this.rotationVector.z*a,1).normalize();this.object.quaternion.multiplySelf(this.tmpQuaternion);this.object.matrix.setPosition(this.object.position);this.object.matrix.setRotationFromQuaternion(this.object.quaternion); +!0;break;case 2:this.object.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),c=b.size[0]/2,f=b.size[1]/2;this.moveState.yawLeft=-(a.pageX-b.offset[0]-c)/c;this.moveState.pitchDown=(a.pageY-b.offset[1]-f)/f;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward= +!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(a){var b=a*this.movementSpeed;a*=this.rollSpeed;this.object.translateX(this.moveVector.x*b);this.object.translateY(this.moveVector.y*b);this.object.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*a,this.rotationVector.y*a,this.rotationVector.z*a,1).normalize();this.object.quaternion.multiplySelf(this.tmpQuaternion);this.object.matrix.setPosition(this.object.position);this.object.matrix.setRotationFromQuaternion(this.object.quaternion); this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z= -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this, this.mouseup),!1);this.domElement.addEventListener("keydown",c(this,this.keydown),!1);this.domElement.addEventListener("keyup",c(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()}; -THREE.RollControls=function(a,b){this.object=a;this.domElement=b!==void 0?b:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Vector3,g=new THREE.Matrix4,f=!1,h=1,i=0,k=0,j=0,q=0,o=0,l=window.innerWidth/2,s=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var b=a*this.lookSpeed; -this.rotateHorizontally(b*q);this.rotateVertically(b*o)}b=a*this.movementSpeed;this.object.translateZ(-b*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*k);this.object.translateY(b*j);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(b*k);this.object.translateY(b*j);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(c.object.position).subSelf(c.target);e=c.object.up.clone().setLength(d.y);e.addSelf(c.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 b=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion;a*=c.rotateSpeed;d.setFromAxisAngle(b, --a);d.multiplyVector3(f);d.multiplyVector3(c.object.up);d.multiplyVector3(i);c.staticMoving?h=i:(d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1)),d.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(j.y-k.y)*c.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),c.staticMoving?k=j:k.y+=(j.y-k.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=o.clone().subSelf(q);if(a.lengthSq()){a.multiplyScalar(f.length()*c.panSpeed);var b=f.clone().crossSelf(c.object.up).setLength(a.x);b.addSelf(c.object.up.clone().setLength(a.y)); -c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?q=o:q.addSelf(a.sub(o,q).multiplyScalar(c.dynamicDampingFactor))}};this.checkDistances=function(){if(!c.noZoom||!c.noPan)c.object.position.lengthSq()>c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),f.lengthSq()0&&(f.multiplyScalar(a),c.staticMoving?k=j:k.y+=(j.y-k.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=o.clone().subSelf(p);if(a.lengthSq()){a.multiplyScalar(f.length()*c.panSpeed);var b=f.clone().crossSelf(c.object.up).setLength(a.x);b.addSelf(c.object.up.clone().setLength(a.y)); +c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?p=o:p.addSelf(a.sub(o,p).multiplyScalar(c.dynamicDampingFactor))}};this.checkDistances=function(){if(!c.noZoom||!c.noPan)c.object.position.lengthSq()>c.maxDistance*c.maxDistance&&c.object.position.setLength(c.maxDistance),f.lengthSq()0?1:-1;for(h=0;h0?1:-1;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;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 e(a){for(w=a.length;--w>=0;){J=w;N=w-1;N<0&&(N=a.length-1);for(var b= -0,c=l+j*2,b=0;b=0;B--){G=B/j;I=i*(1-G);G=k*Math.sin(G*Math.PI/2);w=0;for(D=r.length;w=0;B--){G=B/j;I=i*(1-G);G=k*Math.sin(G*Math.PI/2);w=0;for(D=r.length;w0)for(k=0;k2;){if(q--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return g}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);j=k+1;e<=j&&(j=0);var o;a:{o=a;var l=i,s=k,n=j,p=e,m=f,r=void 0,t=void 0,v=void 0, -y=void 0,u=void 0,x=void 0,z=void 0,A=void 0,F=void 0,t=o[m[l]].x,v=o[m[l]].y,y=o[m[s]].x,u=o[m[s]].y,x=o[m[n]].x,z=o[m[n]].y;if(1.0E-10>(y-t)*(z-v)-(u-v)*(x-t))o=!1;else{for(r=0;r=0&&B>=0&&I>=0){o=!1;break a}}o=!0}}if(o){g.push([a[f[i]], -a[f[k]],a[f[j]]]);h.push([f[i],f[k],f[j]]);i=k;for(j=k+1;j0)for(k=0;k2;){if(p--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return g}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);j=k+1;e<=j&&(j=0);var o;a:{o=a;var l=i,s=k,m=j,q=e,n=f,r=void 0,t=void 0,v=void 0, +y=void 0,u=void 0,x=void 0,z=void 0,A=void 0,F=void 0,t=o[n[l]].x,v=o[n[l]].y,y=o[n[s]].x,u=o[n[s]].y,x=o[n[m]].x,z=o[n[m]].y;if(1.0E-10>(y-t)*(z-v)-(u-v)*(x-t))o=!1;else{for(r=0;r=0&&B>=0&&I>=0){o=!1;break a}}o=!0}}if(o){g.push([a[f[i]], +a[f[k]],a[f[j]]]);h.push([f[i],f[k],f[j]]);i=k;for(j=k+1;j0;)this.smooth(a)}; -THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,b,c,d,h,i){var j=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(f.useOldVertexColors){j.vertexColors=[];for(var k,l,n,m=0;m<4;m++){n=i[m];k=new THREE.Color;k.setRGB(0,0,0);for(var p=0;p=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=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=f.indexOf("(")>=0,h;if(e)d=f.split("."),f=d.shift(),d.shift();else if(g){h=f.split("(");f=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};q.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a=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};p.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};F.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 A)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=Z[this.effect.surface.init_from]))a.map= +null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;d.length>0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};F.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 A)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=Z[this.effect.surface.init_from]))a.map= THREE.ImageUtils.loadTexture(da+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=ea;return this.material=new THREE.MeshLambertMaterial(a)};w.prototype.parse=function(a){for(var b=0;b=0,d=a.indexOf("(")>=0,f,e;if(c)b=a.split("."),a=b.shift(),e=b.shift();else if(d){f=a.split("(");a=f.shift();for(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&&(D=new THREE.MeshFaceMaterial); -a=new THREE.Mesh(A,D);a.name=o;a.position.set(v[0],v[1],v[2]);u?(a.quaternion.set(u[0],u[1],u[2],u[3]),a.useQuaternion=!0):a.rotation.set(y[0],y[1],y[2]);a.scale.set(x[0],x[1],x[2]);a.visible=m.visible;C.scene.add(a);C.objects[o]=a;if(m.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);C.scene.collisions.colliders.push(b)}if(m.castsShadow)b=new THREE.ShadowVolume(A),C.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;m.trigger&&m.trigger.toLowerCase()!="none"&&(b= -{type:m.trigger,object:m},C.triggers[a.name]=b)}}else v=m.position,y=m.rotation,u=m.quaternion,x=m.scale,u=0,a=new THREE.Object3D,a.name=o,a.position.set(v[0],v[1],v[2]),u?(a.quaternion.set(u[0],u[1],u[2],u[3]),a.useQuaternion=!0):a.rotation.set(y[0],y[1],y[2]),a.scale.set(x[0],x[1],x[2]),a.visible=m.visible!==void 0?m.visible:!1,C.scene.add(a),C.objects[o]=a,C.empties[o]=a,m.trigger&&m.trigger.toLowerCase()!="none"&&(b={type:m.trigger,object:m},C.triggers[a.name]=b)}function g(a){return function(b){C.geometries[a]= -b;e();I-=1;i.onLoadComplete();h()}}function f(a){return function(b){C.geometries[a]=b}}function h(){i.callbackProgress({totalModels:K,totalTextures:O,loadedModels:K-I,loadedTextures:O-E},C);i.onLoadProgress();I==0&&E==0&&b(C)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),j,q,o,l,s,n,p,m,r,t,v,y,u,x,z,A,F,w,D,B,G,I,E,K,O,C;B=a;c=new THREE.BinaryLoader;G=new THREE.JSONLoader;E=I=0;C={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, -empties:{}};a=!1;for(o in B.objects)if(m=B.objects[o],m.meshCollider){a=!0;break}if(a)C.scene.collisions=new THREE.CollisionSystem;if(B.transform){a=B.transform.position;r=B.transform.rotation;var L=B.transform.scale;a&&C.scene.position.set(a[0],a[1],a[2]);r&&C.scene.rotation.set(r[0],r[1],r[2]);L&&C.scene.scale.set(L[0],L[1],L[2]);(a||r||L)&&C.scene.updateMatrix()}a=function(){E-=1;h();i.onLoadComplete()};for(s in B.cameras)r=B.cameras[s],r.type=="perspective"?F=new THREE.PerspectiveCamera(r.fov, +THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:k+"/"+a}function e(){var a;for(o in B.objects)if(!C.objects[o])if(n=B.objects[o],n.geometry!==void 0){if(A=C.geometries[n.geometry]){a=!1;for(H=0;H1&&(D=new THREE.MeshFaceMaterial); +a=new THREE.Mesh(A,D);a.name=o;a.position.set(v[0],v[1],v[2]);u?(a.quaternion.set(u[0],u[1],u[2],u[3]),a.useQuaternion=!0):a.rotation.set(y[0],y[1],y[2]);a.scale.set(x[0],x[1],x[2]);a.visible=n.visible;C.scene.add(a);C.objects[o]=a;if(n.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);C.scene.collisions.colliders.push(b)}if(n.castsShadow)b=new THREE.ShadowVolume(A),C.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;n.trigger&&n.trigger.toLowerCase()!="none"&&(b= +{type:n.trigger,object:n},C.triggers[a.name]=b)}}else v=n.position,y=n.rotation,u=n.quaternion,x=n.scale,u=0,a=new THREE.Object3D,a.name=o,a.position.set(v[0],v[1],v[2]),u?(a.quaternion.set(u[0],u[1],u[2],u[3]),a.useQuaternion=!0):a.rotation.set(y[0],y[1],y[2]),a.scale.set(x[0],x[1],x[2]),a.visible=n.visible!==void 0?n.visible:!1,C.scene.add(a),C.objects[o]=a,C.empties[o]=a,n.trigger&&n.trigger.toLowerCase()!="none"&&(b={type:n.trigger,object:n},C.triggers[a.name]=b)}function g(a){return function(b){C.geometries[a]= +b;e();I-=1;i.onLoadComplete();h()}}function f(a){return function(b){C.geometries[a]=b}}function h(){i.callbackProgress({totalModels:K,totalTextures:O,loadedModels:K-I,loadedTextures:O-E},C);i.onLoadProgress();I==0&&E==0&&b(C)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),j,p,o,l,s,m,q,n,r,t,v,y,u,x,z,A,F,w,D,B,G,I,E,K,O,C;B=a;c=new THREE.BinaryLoader;G=new THREE.JSONLoader;E=I=0;C={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, +empties:{}};a=!1;for(o in B.objects)if(n=B.objects[o],n.meshCollider){a=!0;break}if(a)C.scene.collisions=new THREE.CollisionSystem;if(B.transform){a=B.transform.position;r=B.transform.rotation;var L=B.transform.scale;a&&C.scene.position.set(a[0],a[1],a[2]);r&&C.scene.rotation.set(r[0],r[1],r[2]);L&&C.scene.scale.set(L[0],L[1],L[2]);(a||r||L)&&C.scene.updateMatrix()}a=function(){E-=1;h();i.onLoadComplete()};for(s in B.cameras)r=B.cameras[s],r.type=="perspective"?F=new THREE.PerspectiveCamera(r.fov, r.aspect,r.near,r.far):r.type=="ortho"&&(F=new THREE.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)),v=r.position,r=r.target,F.position.set(v[0],v[1],v[2]),F.target=new THREE.Vector3(r[0],r[1],r[2]),C.cameras[s]=F;for(l in B.lights)r=B.lights[l],s=r.color!==void 0?r.color:16777215,F=r.intensity!==void 0?r.intensity:1,r.type=="directional"?(v=r.direction,t=new THREE.DirectionalLight(s,F),t.position.set(v[0],v[1],v[2]),t.position.normalize()):r.type=="point"?(v=r.position,t=r.distance, -t=new THREE.PointLight(s,F,t),t.position.set(v[0],v[1],v[2])):r.type=="ambient"&&(t=new THREE.AmbientLight(s)),C.scene.add(t),C.lights[l]=t;for(n in B.fogs)l=B.fogs[n],l.type=="linear"?w=new THREE.Fog(0,l.near,l.far):l.type=="exp2"&&(w=new THREE.FogExp2(0,l.density)),r=l.color,w.color.setRGB(r[0],r[1],r[2]),C.fogs[n]=w;if(C.cameras&&B.defaults.camera)C.currentCamera=C.cameras[B.defaults.camera];if(C.fogs&&B.defaults.fog)C.scene.fog=C.fogs[B.defaults.fog];r=B.defaults.bgcolor;C.bgColor=new THREE.Color; -C.bgColor.setRGB(r[0],r[1],r[2]);C.bgColorAlpha=B.defaults.bgalpha;for(j in B.geometries)if(n=B.geometries[j],n.type=="bin_mesh"||n.type=="ascii_mesh")I+=1,i.onLoadStart();K=I;for(j in B.geometries)n=B.geometries[j],n.type=="cube"?(A=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),C.geometries[j]=A):n.type=="plane"?(A=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),C.geometries[j]=A):n.type=="sphere"? -(A=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),C.geometries[j]=A):n.type=="cylinder"?(A=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),C.geometries[j]=A):n.type=="torus"?(A=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),C.geometries[j]=A):n.type=="icosahedron"?(A=new THREE.IcosahedronGeometry(n.subdivisions),C.geometries[j]=A):n.type=="bin_mesh"?c.load(d(n.url,B.urlBaseType),g(j)):n.type=="ascii_mesh"?G.load(d(n.url,B.urlBaseType), -g(j)):n.type=="embedded_mesh"&&(n=B.embeds[n.id])&&G.createModel(n,f(j),"");for(p in B.textures)if(j=B.textures[p],j.url instanceof Array){E+=j.url.length;for(n=0;n=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;e<8;e++){for(var g=0,f=0;f>1^-(h&1);c[8*f+e]=g}d+=b}b=a.length-d;g=new Uint16Array(b);for(e=f=0;e=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 b=this.count*3;bthis.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 l=Math.floor(j-h);l<1&&(l=1);h=Math.floor(j+h);h>this.size-1&&(h=this.size- -1);for(var s,n,p,m,r,t;q0&&(this.field[p+s]+=m)}}};this.addPlaneX=function(a,b){var e,g,f,h,i,k=this.size,j=this.yd,q=this.zd,o=this.field,l=k*Math.sqrt(a/b);l>k&&(l=k);for(e=0;e0)for(g=0;gj&&(s=j);for(g=0;g0){i=g*q;for(e=0;ej&&(s=j);for(f=0;f0){i=o*f;for(g=0;gthis.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 l=Math.floor(j-h);l<1&&(l=1);h=Math.floor(j+h);h>this.size-1&&(h=this.size- +1);for(var s,m,q,n,r,t;p0&&(this.field[q+s]+=n)}}};this.addPlaneX=function(a,b){var e,g,f,h,i,k=this.size,j=this.yd,p=this.zd,o=this.field,l=k*Math.sqrt(a/b);l>k&&(l=k);for(e=0;e0)for(g=0;gj&&(s=j);for(g=0;g0){i=g*p;for(e=0;ej&&(s=j);for(f=0;f0){i=o*f;for(g=0;g0&&y.x0&&y.y0.0010&&l.scale>0.0010)v.x=l.x,v.y=l.y,v.z=l.z,r=l.size*l.scale/h,t.x=r*n,t.y=r,b.uniform3f(u.screenPosition, +"color");d.uniforms.scale=b.getUniformLocation(d.program,"scale");d.uniforms.rotation=b.getUniformLocation(d.program,"rotation");d.uniforms.screenPosition=b.getUniformLocation(d.program,"screenPosition");d.attributesEnabled=!1};this.render=function(a,g,f,h){var a=a.__webglFlares,i,k,j=a.length,p,o,l,s=new THREE.Vector3,m=h/f,q=f*0.5,n=h*0.5,r=16/h,t=new THREE.Vector2(r*m,r),v=new THREE.Vector3(1,1,0),y=new THREE.Vector2(1,1),u=d.uniforms;i=d.attributes;b.useProgram(d.program);if(!d.attributesEnabled)b.enableVertexAttribArray(d.attributes.vertex), +b.enableVertexAttribArray(d.attributes.uv),d.attributesEnabled=!0;b.uniform1i(u.occlusionMap,0);b.uniform1i(u.map,1);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(i.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(i.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.disable(b.CULL_FACE);b.depthMask(!1);for(k=0;k0&&y.x0&&y.y0.0010&&l.scale>0.0010)v.x=l.x,v.y=l.y,v.z=l.z,r=l.size*l.scale/h,t.x=r*m,t.y=r,b.uniform3f(u.screenPosition, v.x,v.y,v.z),b.uniform2f(u.scale,t.x,t.y),b.uniform1f(u.rotation,l.rotation),b.uniform1f(u.opacity,l.opacity),b.uniform3f(u.color,l.color.r,l.color.g,l.color.b),c.setBlending(l.blending),c.setTexture(l.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var b=this,c=this.setSize,d=this.render,e=new THREE.PerspectiveCamera,g=new THREE.PerspectiveCamera,f=new THREE.Matrix4,h=new THREE.Matrix4,i,k,j,q;e.matrixAutoUpdate=g.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},o=new THREE.WebGLRenderTarget(512,512,a),l=new THREE.WebGLRenderTarget(512,512,a),s=new THREE.PerspectiveCamera(53, +THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d={};this.init=function(a){b=a.context;c=a;d.vertices=new Float32Array(16);d.faces=new Uint16Array(6);a=0;d.vertices[a++]=-1;d.vertices[a++]=-1;d.vertices[a++]=0;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=-1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=1;d.vertices[a++]=0;d.vertices[a++]=-1;d.vertices[a++]=1;d.vertices[a++]=0;a=d.vertices[a++]=0;d.faces[a++]=0;d.faces[a++]=1;d.faces[a++]= +2;d.faces[a++]=0;d.faces[a++]=2;d.faces[a++]=3;d.vertexBuffer=b.createBuffer();d.elementBuffer=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.bufferData(b.ARRAY_BUFFER,d.vertices,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,d.faces,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,g=b.createProgram(),f=b.createShader(b.FRAGMENT_SHADER),h=b.createShader(b.VERTEX_SHADER);b.shaderSource(f,a.fragmentShader);b.shaderSource(h,a.vertexShader); +b.compileShader(f);b.compileShader(h);b.attachShader(g,f);b.attachShader(g,h);b.linkProgram(g);d.program=g;d.attributes={};d.uniforms={};d.attributes.position=b.getAttribLocation(d.program,"position");d.attributes.uv=b.getAttribLocation(d.program,"uv");d.uniforms.uvOffset=b.getUniformLocation(d.program,"uvOffset");d.uniforms.uvScale=b.getUniformLocation(d.program,"uvScale");d.uniforms.rotation=b.getUniformLocation(d.program,"rotation");d.uniforms.scale=b.getUniformLocation(d.program,"scale");d.uniforms.alignment= +b.getUniformLocation(d.program,"alignment");d.uniforms.color=b.getUniformLocation(d.program,"color");d.uniforms.map=b.getUniformLocation(d.program,"map");d.uniforms.opacity=b.getUniformLocation(d.program,"opacity");d.uniforms.useScreenCoordinates=b.getUniformLocation(d.program,"useScreenCoordinates");d.uniforms.affectedByDistance=b.getUniformLocation(d.program,"affectedByDistance");d.uniforms.screenPosition=b.getUniformLocation(d.program,"screenPosition");d.uniforms.modelViewMatrix=b.getUniformLocation(d.program, +"modelViewMatrix");d.uniforms.projectionMatrix=b.getUniformLocation(d.program,"projectionMatrix");d.attributesEnabled=!1};this.render=function(e,g,f,h,i){var k,j;k=d.attributes;var p=d.uniforms,o=h/f,l=[];f*=0.5;var s=h*0.5,m=!0;b.useProgram(d.program);_currentProgram=d.program;if(!d.attributesEnabled)b.enableVertexAttribArray(k.position),b.enableVertexAttribArray(k.uv),d.attributesEnabled=!0;b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(k.position, +2,b.FLOAT,!1,16,0);b.vertexAttribPointer(k.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.uniformMatrix4fv(p.projectionMatrix,!1,i);b.activeTexture(b.TEXTURE0);b.uniform1i(p.map,0);i=0;for(k=e.__webglSprites.length;i>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+ +THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,f,g;if(c===0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),f=a*6-d,a=c*(1-b),g=c*(1- +b*f),b=c*(1-b*(1-f)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+ Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this}, divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)}, @@ -9,96 +9,96 @@ equals:function(a){return a.x===this.x&&a.y===this.y}};THREE.Vector3=function(a, THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this}, addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this}, divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a):this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)}, -cross:function(a,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-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,e=this.z;this.x=c*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,a).lengthSq()},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){var b=Math.cos(this.y); -this.y=Math.asin(a.n13);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,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- +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-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this,a).lengthSq()},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){var b=Math.cos(this.y); +this.y=Math.asin(a.n13);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){function c(a,b,c){p.sub(c,a);y=p.dot(b);if(y<=0)return null;I=A.add(a,r.copy(b).multiplyScalar(y));return T=c.distanceTo(I)}function e(a,b,c,e){p.sub(e,b);A.sub(c,b);r.sub(a,b);sa=p.dot(p);ha=p.dot(A);la=p.dot(r);ka=A.dot(A);J=A.dot(r);P=1/(sa*ka-ha*ha);G=(ka*la-ha*J)*P;N=(sa*J-ha*la)*P;return G>=0&&N>=0&&G+N<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;br.scale.x)return[];p={distance:A,point:r.position,face:null,object:r};y.push(p)}else if(r instanceof THREE.Mesh){A=c(this.origin,this.direction,r.matrixWorld.getPosition());if(A===null||A>r.geometry.boundingSphere.radius*Math.max(r.scale.x,Math.max(r.scale.y,r.scale.z)))return y;var I,T=r.geometry,oa=T.vertices,J;r.matrixRotationWorld.extractRotation(r.matrixWorld);A=0;for(qa=T.faces.length;A< -qa;A++)if(p=T.faces[A],a.copy(this.origin),b.copy(this.direction),J=r.matrixWorld,o=J.multiplyVector3(o.copy(p.centroid)).subSelf(a),I=o.dot(b),!(I<=0)&&(f=J.multiplyVector3(f.copy(oa[p.a].position)),g=J.multiplyVector3(g.copy(oa[p.b].position)),h=J.multiplyVector3(h.copy(oa[p.c].position)),p instanceof THREE.Face4&&(i=J.multiplyVector3(i.copy(oa[p.d].position))),k=r.matrixRotationWorld.multiplyVector3(k.copy(p.normal)),I=b.dot(k),r.doubleSided||(r.flipSided?I>0:I<0)))if(I=k.dot(o.sub(f,a))/I,l.add(a, -b.multiplyScalar(I)),p instanceof THREE.Face3)e(l,f,g,h)&&(p={distance:a.distanceTo(l),point:l.clone(),face:p,object:r},y.push(p));else if(p instanceof THREE.Face4&&(e(l,f,g,i)||e(l,g,h,i)))p={distance:a.distanceTo(l),point:l.clone(),face:p,object:r},y.push(p)}return y};var p=new THREE.Vector3,A=new THREE.Vector3,r=new THREE.Vector3,y,I,T,sa,ha,la,ka,J,P,G,N}; -THREE.Rectangle=function(){function a(){g=e-b;h=f-c}var b,c,e,f,g,h,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,h,l,p){i=!1;b=g;c=h;e=l;f=p;a()};this.addPoint=function(g,h){i?(i=!1,b=g,c=h,e=g,f=h):(b=bg?e:g,f=f>h?f:h);a()};this.add3Points= -function(g,h,l,p,A,r){i?(i=!1,b=gl?g>A?g:A:l>A?l:A,f=h>p?h>r?h:r:p>r?p:r):(b=gl?g>A?g>e?g:e:A>e?A:e:l>A?l>e?l:e:A>e?A:e,f=h>p?h>r?h>f?h:f:r>f?r:f:p>r?p>f?p:f:r>f?r:f);a()};this.addRectangle=function(g){i?(i=!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(){i=!0;f=e=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&&E>=0&&M+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;bm.scale.x)return[];q={distance:s,point:m.position,face:null,object:m};y.push(q)}else if(m instanceof THREE.Mesh){s=c(this.origin,this.direction,m.matrixWorld.getPosition());if(s===null||s>m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)))return y;var D,L=m.geometry,oa=L.vertices,G;m.matrixRotationWorld.extractRotation(m.matrixWorld);s=0;for(qa=L.faces.length;s< +qa;s++)if(q=L.faces[s],a.copy(this.origin),b.copy(this.direction),G=m.matrixWorld,n=G.multiplyVector3(n.copy(q.centroid)).subSelf(a),D=n.dot(b),!(D<=0)&&(f=G.multiplyVector3(f.copy(oa[q.a].position)),g=G.multiplyVector3(g.copy(oa[q.b].position)),h=G.multiplyVector3(h.copy(oa[q.c].position)),q instanceof THREE.Face4&&(i=G.multiplyVector3(i.copy(oa[q.d].position))),l=m.matrixRotationWorld.multiplyVector3(l.copy(q.normal)),D=b.dot(l),m.doubleSided||(m.flipSided?D>0:D<0)))if(D=l.dot(n.sub(f,a))/D,j.add(a, +b.multiplyScalar(D)),q instanceof THREE.Face3)d(j,f,g,h)&&(q={distance:a.distanceTo(j),point:j.clone(),face:q,object:m},y.push(q));else if(q instanceof THREE.Face4&&(d(j,f,g,i)||d(j,g,h,i)))q={distance:a.distanceTo(j),point:j.clone(),face:q,object:m},y.push(q)}return y};var q=new THREE.Vector3,s=new THREE.Vector3,m=new THREE.Vector3,y,D,L,sa,fa,la,ka,G,N,M,E}; +THREE.Rectangle=function(){function a(){g=d-b;h=f-c}var b,c,d,f,g,h,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(g,h,j,q){i=!1;b=g;c=h;d=j;f=q;a()};this.addPoint=function(g,h){i?(i=!1,b=g,c=h,d=g,f=h):(b=bg?d:g,f=f>h?f:h);a()};this.add3Points= +function(g,h,j,q,s,m){i?(i=!1,b=gj?g>s?g:s:j>s?j:s,f=h>q?h>m?h:m:q>m?q:m):(b=gj?g>s?g>d?g:d:s>d?s:d:j>s?j>d?j:d:s>d?s:d,f=h>q?h>m?h>f?h:f:m>f?m:f:q>m?q>f?q:f:m>f?m:f);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),f=g.getBottom()):(b=bg.getRight()?d:g.getRight(),f=f> +g.getBottom()?f:g.getBottom());a()};this.inflate=function(g){b-=g;c-=g;d+=g;f+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){i=!0;f=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&&h>=0&&i>=0?!0:g<0&&f<0||h<0&&i<0?!1:(g<0?c=Math.max(c,g/(g-f)):f<0&&(e=Math.min(e,g/(g-f))),h<0?c=Math.max(c,h/(h-i)):i<0&&(e=Math.min(e,h/(h-i))),eh&&i.positionScreen.z0&&G.z<1))h=ka[la]=ka[la]||new THREE.RenderableParticle,la++,ha=h,ha.x=G.x/G.w,ha.y=G.y/G.w,ha.z=G.z,ha.rotation=R.rotation.z,ha.scale.x=R.scale.x*Math.abs(ha.x-(G.x+g.projectionMatrix.n11)/(G.w+g.projectionMatrix.n14)),ha.scale.y=R.scale.y*Math.abs(ha.y-(G.y+g.projectionMatrix.n22)/(G.w+g.projectionMatrix.n24)), -ha.material=R.material,J.elements.push(ha);f&&J.elements.sort(c);return J}};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),h=a*b,i=e*f;this.w=h*g-i*c;this.x=h*c+i*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); +THREE.Projector=function(){function a(){var a=h[g]=h[g]||new THREE.RenderableObject;g++;return a}function b(){var a=l[n]=l[n]||new THREE.RenderableVertex;n++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,g=a.z+a.w,f=b.z+b.w,h=-a.z+a.w,i=-b.z+b.w;return g>=0&&f>=0&&h>=0&&i>=0?!0:g<0&&f<0||h<0&&i<0?!1:(g<0?c=Math.max(c,g/(g-f)):f<0&&(d=Math.min(d,g/(g-f))),h<0?c=Math.max(c,h/(h-i)):i<0&&(d=Math.min(d,h/(h-i))),dh&&i.positionScreen.z0&&M.z<1))h=ka[la]=ka[la]||new THREE.RenderableParticle,la++,fa=h,fa.x=M.x/M.w,fa.y=M.y/M.w,fa.z=M.z,fa.rotation=O.rotation.z,fa.scale.x=O.scale.x*Math.abs(fa.x-(M.x+g.projectionMatrix.n11)/(M.w+g.projectionMatrix.n14)),fa.scale.y=O.scale.y*Math.abs(fa.y-(M.y+g.projectionMatrix.n22)/(M.w+g.projectionMatrix.n24)), +fa.material=O.material,G.elements.push(fa);f&&G.elements.sort(c);return G}};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),g=Math.cos(c),c=Math.sin(c),h=a*b,i=d*f;this.w=h*g-i*c;this.x=h*c+i*g;this.y=d*b*g+a*f*c;this.z=a*f*g-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,e=this.z,f=this.w,g=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+f*g+c*i-e*h;this.y=c*a+f*h+e*g-b*i;this.z=e*a+f*i+b*h-c*g;this.w=f*a-b*g-c*h-e*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,e=a.y,f=a.z,g=this.x,h=this.y,i=this.z,o=this.w,k=o*c+h*f-i*e,l=o*e+i*c-g*f,p=o*f+g*e-h*c,c=-g* -c-h*e-i*f;b.x=k*o+c*-g+l*-i-p*-h;b.y=l*o+c*-h+p*-g-k*-i;b.z=p*o+c*-i+k*-h-l*-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.0010)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,h){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=h;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +this.x,c=this.y,d=this.z,f=this.w,g=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+f*g+c*i-d*h;this.y=c*a+f*h+d*g-b*i;this.z=d*a+f*i+b*h-c*g;this.w=f*a-b*g-c*h-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,f=a.z,g=this.x,h=this.y,i=this.z,n=this.w,l=n*c+h*f-i*d,j=n*d+i*c-g*f,q=n*f+g*d-h*c,c=-g* +c-h*d-i*f;b.x=l*n+c*-g+j*-i-q*-h;b.y=j*n+c*-h+q*-g-l*-i;b.z=q*n+c*-i+l*-h-j*-g;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 g=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.0010)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)*g)/f;d=Math.sin(d*g)/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,g){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=g;this.centroid=new THREE.Vector3}; +THREE.Face4=function(a,b,c,d,f,g,h){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=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=h;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;b< +b,c,d,f,g,h=new THREE.Vector3,i=new THREE.Vector3;a=0;for(b=this.faces.length;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;b< c;b++){a=this.vertices[b];if(a.position.xthis.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;k=this.points[c[0]];l=this.points[c[1]]; -p=this.points[c[2]];A=this.points[c[3]];i=h*h;o=h*i;e.x=b(k.x,l.x,p.x,A.x,h,i,o);e.y=b(k.y,l.y,p.y,A.y,h,i,o);e.z=b(k.z,l.z,p.z,A.z,h,i,o);return e};this.getControlPointsArray=function(){var a,b,c=this.points.length,e=[];for(a=0;athis.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;l=this.points[c[0]];j=this.points[c[1]]; +q=this.points[c[2]];s=this.points[c[3]];i=h*h;n=h*i;d.x=b(l.x,j.x,q.x,s.x,h,i,n);d.y=b(l.y,j.y,q.y,s.y,h,i,n);d.z=b(l.z,j.z,q.z,s.z,h,i,n);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a1){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var b=1;b=this.LODs[b].visibleAtDistance)this.LODs[b-1].object3D.visible=!1,this.LODs[b].object3D.visible=!0;else break;for(;b= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness * shadow ) );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec3( shadowDarkness );\n#endif\n}\n}\n#ifdef GAMMA_OUTPUT\nshadowColor *= shadowColor;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif",linear_to_gamma_fragment:"#ifdef GAMMA_OUTPUT\ngl_FragColor.xyz = sqrt( gl_FragColor.xyz );\n#endif"}; -THREE.UniformsUtils={merge:function(a){var b,c,e,f={};for(b=0;b=0)return a.geometry.materials[b.materialIndex]}function e(a){if(a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial)return!1;return a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function f(a){if(a.vertexColors)return a.vertexColors;return!1}function g(a){if(a.map||a.lightMap||a instanceof THREE.ShaderMaterial)return!0; -return!1}function h(a,b,c){var e,g,f,z,m=a.vertices;z=m.length;var h=a.colors,i=h.length,s=a.__vertexArray,w=a.__colorArray,j=a.__sortArray,q=a.__dirtyVertices,l=a.__dirtyColors,p=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){h=0;var u=g.morphTargetForcedOrder;for(m=g.morphTargetInfluences;hi&&(s=w,i=m[s]);d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[s]);d.vertexAttribPointer(c["morphTarget"+h],3,d.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=i;u[s]=1;i=-1;h++}}e.program.uniforms.morphTargetInfluences!==null&&d.uniform1fv(e.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){h= -0;for(m=f.__webglCustomAttributesList.length;h=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)),F.info.render.calls++,F.info.render.vertices+=f.__webglFaceCount,F.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),F.info.render.calls++):g instanceof THREE.ParticleSystem?(d.drawArrays(d.POINTS,0,f.__webglParticleCount),F.info.render.calls++):g instanceof THREE.Ribbon&&(d.drawArrays(d.TRIANGLE_STRIP,0,f.__webglVertexCount),F.info.render.calls++)}}function k(a){pa[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);pa[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);pa[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);pa[3].set(a.n41- -a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);pa[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);pa[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=pa[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function l(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=pa[c].x*b.n14+pa[c].y*b.n24+pa[c].z*b.n34+pa[c].w,a<=d)return!1;return!0}function p(a,b){return b.z-a.z}function A(a){var b, -c,e,f,g,h,m,u,p=0,s=a.lights;ma||(ma=new THREE.PerspectiveCamera(F.shadowCameraFov,F.shadowMapWidth/F.shadowMapHeight,F.shadowCameraNear,F.shadowCameraFar));b=0;for(c=s.length;b=0;d--)a[d].object===b&&a.splice(d,1)}function la(a,b){for(var d=a.length-1;d>=0;d--)a[d]===b&&a.splice(d,1)}function ka(a,b,c,e,f){e.program||F.initMaterial(e,b,c,f);if(e.morphTargets&& -!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(F.maxMorphTargets);for(var g=0,h=F.maxMorphTargets;g0;this.getContext=function(){return d};this.supportsVertexTextures=function(){return Wa};this.setSize=function(a,b){oa.width=a;oa.height=b;this.setViewport(0,0,oa.width,oa.height)};this.setViewport=function(a,b,c,e){Pa=a;Qa=b;Ea=c;Aa=e;d.viewport(Pa,Qa,Ea,Aa)};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){L.setHex(a);O=b;d.clearColor(L.r,L.g,L.b,O)};this.setClearColor=function(a,b){L.copy(a);O=b;d.clearColor(L.r,L.g,L.b,O)};this.getClearColor=function(){return L};this.getClearAlpha=function(){return O};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){qa(a);this.clear(b,c,d)};this.addPlugin=function(a){a.init(this);this.renderPlugins.push(a)};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)q=w.geometry.materials[q],q.transparent?(s.transparent=q,s.opaque=null):(s.opaque=q,s.transparent=null)}else if(q)q.transparent?(s.transparent=q,s.opaque=null):(s.opaque=q,s.transparent=null);g.render=!0;if(this.sortObjects)h.renderDepth?g.z=h.renderDepth:(Da.copy(h.position),za.multiplyVector3(Da),g.z=Da.z)}this.sortObjects&&m.sort(p);m=a.__webglObjectsImmediate; -e=0;for(f=m.length;e65535&&(q[w].counter+=1,j=q[w].hash+"_"+q[w].counter,k.geometryGroups[j]===void 0&&(k.geometryGroups[j]={faces3:[],faces4:[],materialIndex:r,vertices:0,numMorphTargets:A})),u instanceof THREE.Face3?k.geometryGroups[j].faces3.push(z):k.geometryGroups[j].faces4.push(z), -k.geometryGroups[j].vertices+=s;k.geometryGroupsList=[];z=void 0;for(z in k.geometryGroups)k.geometryGroups[z].id=Fa++,k.geometryGroupsList.push(k.geometryGroups[z])}for(l in o.geometryGroups)if(k=o.geometryGroups[l],!k.__webglVertexBuffer){z=k;z.__webglVertexBuffer=d.createBuffer();z.__webglNormalBuffer=d.createBuffer();z.__webglTangentBuffer=d.createBuffer();z.__webglColorBuffer=d.createBuffer();z.__webglUVBuffer=d.createBuffer();z.__webglUV2Buffer=d.createBuffer();z.__webglSkinVertexABuffer=d.createBuffer(); -z.__webglSkinVertexBBuffer=d.createBuffer();z.__webglSkinIndicesBuffer=d.createBuffer();z.__webglSkinWeightsBuffer=d.createBuffer();z.__webglFaceBuffer=d.createBuffer();z.__webglLineBuffer=d.createBuffer();if(z.numMorphTargets){u=m=void 0;z.__webglMorphTargetsBuffers=[];m=0;for(u=z.numMorphTargets;m0||s.faceVertexUvs.length>0)k.__uvArray=new Float32Array(z*2);if(s.faceUvs.length>1||s.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(z*2)}if(r.geometry.skinWeights.length&&r.geometry.skinIndices.length)k.__skinVertexAArray=new Float32Array(z*4),k.__skinVertexBArray= -new Float32Array(z*4),k.__skinIndexArray=new Float32Array(z*4),k.__skinWeightArray=new Float32Array(z*4);k.__faceArray=new Uint16Array(u*3);k.__lineArray=new Uint16Array(w*2);if(k.numMorphTargets){k.__morphTargetsArrays=[];r=0;for(s=k.numMorphTargets;r0&&(d.bindBuffer(d.ARRAY_BUFFER,m.__webglSkinVertexABuffer),d.bufferData(d.ARRAY_BUFFER,U,u),d.bindBuffer(d.ARRAY_BUFFER,m.__webglSkinVertexBBuffer),d.bufferData(d.ARRAY_BUFFER,V,u),d.bindBuffer(d.ARRAY_BUFFER, -m.__webglSkinIndicesBuffer),d.bufferData(d.ARRAY_BUFFER,ca,u),d.bindBuffer(d.ARRAY_BUFFER,m.__webglSkinWeightsBuffer),d.bufferData(d.ARRAY_BUFFER,ja,u))}if(qa&&w){j=0;for(q=y.length;j0&&(d.bindBuffer(d.ARRAY_BUFFER,m.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,ea,u))}if(N&&L.hasTangents){j=0;for(q=y.length;j0&&(d.bindBuffer(d.ARRAY_BUFFER,m.__webglUVBuffer),d.bufferData(d.ARRAY_BUFFER,ba,u))}if(na&&va&&J){j=0;for(q=y.length;j0&&(d.bindBuffer(d.ARRAY_BUFFER,m.__webglUV2Buffer), -d.bufferData(d.ARRAY_BUFFER,t,u))}if(oa){j=0;for(q=y.length;j=0)return a.geometry.materials[b.materialIndex]}function d(a){if(a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial)return!1;return a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function f(a){if(a.vertexColors)return a.vertexColors;return!1}function g(a){if(a.map||a.lightMap||a instanceof THREE.ShaderMaterial)return!0; +return!1}function h(a,b,c){var d,g,f,h,o=a.vertices;h=o.length;var r=a.colors,i=r.length,t=a.__vertexArray,j=a.__colorArray,k=a.__sortArray,w=a.__dirtyVertices,q=a.__dirtyColors,n=a.__webglCustomAttributesList;if(c.sortParticles){za.multiplySelf(c.matrixWorld);for(d=0;d=0)a&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(b.position,3,e.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;g.morphTargetBase!==-1?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[g.morphTargetBase]), +e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0)):c.position>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){h=0;var r=g.morphTargetForcedOrder;for(o=g.morphTargetInfluences;hi&&(t=j,i=o[t]);e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[t]);e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=i;r[t]=1;i=-1;h++}}d.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){h= +0;for(o=f.__webglCustomAttributesList.length;h=0&&(e.bindBuffer(e.ARRAY_BUFFER,c.buffer),e.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,e.FLOAT,!1,0,0))}b.color>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglColorBuffer),e.vertexAttribPointer(b.color,3,e.FLOAT,!1,0,0));b.normal>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglNormalBuffer),e.vertexAttribPointer(b.normal,3,e.FLOAT,!1,0,0));b.tangent>=0&&(e.bindBuffer(e.ARRAY_BUFFER, +f.__webglTangentBuffer),e.vertexAttribPointer(b.tangent,4,e.FLOAT,!1,0,0));b.uv>=0&&(f.__webglUVBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUVBuffer),e.vertexAttribPointer(b.uv,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv)):e.disableVertexAttribArray(b.uv));b.uv2>=0&&(f.__webglUV2Buffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUV2Buffer),e.vertexAttribPointer(b.uv2,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv2)):e.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>= +0&&b.skinIndex>=0&&b.skinWeight>=0&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexABuffer),e.vertexAttribPointer(b.skinVertexA,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),e.vertexAttribPointer(b.skinVertexB,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),e.vertexAttribPointer(b.skinIndex,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),e.vertexAttribPointer(b.skinWeight,4,e.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe? +(d=d.wireframeLinewidth,d!==Fa&&(e.lineWidth(d),Fa=d),a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),e.drawElements(e.LINES,f.__webglLineCount,e.UNSIGNED_SHORT,0)):(a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),e.drawElements(e.TRIANGLES,f.__webglFaceCount,e.UNSIGNED_SHORT,0)),C.info.render.calls++,C.info.render.vertices+=f.__webglFaceCount,C.info.render.faces+=f.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?e.LINE_STRIP:e.LINES,d=d.linewidth,d!== +Fa&&(e.lineWidth(d),Fa=d),e.drawArrays(g,0,f.__webglLineCount),C.info.render.calls++):g instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS,0,f.__webglParticleCount),C.info.render.calls++):g instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,0,f.__webglVertexCount),C.info.render.calls++)}}function l(a){pa[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);pa[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);pa[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);pa[3].set(a.n41- +a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);pa[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);pa[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=pa[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function j(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),e=0;e<6;e++)if(a=pa[e].x*b.n14+pa[e].y*b.n24+pa[e].z*b.n34+pa[e].w,a<=c)return!1;return!0}function q(a,b){return b.z-a.z}function s(a){var b, +c,d,f,g,h,o,r,q=0,t=a.lights;ma||(ma=new THREE.PerspectiveCamera(C.shadowCameraFov,C.shadowMapWidth/C.shadowMapHeight,C.shadowCameraNear,C.shadowCameraFar));b=0;for(c=t.length;b=0;c--)a[c].object===b&&a.splice(c,1)}function la(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function ka(a,b,c,d,f){d.program||C.initMaterial(d,b,c,f);if(d.morphTargets&& +!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(C.maxMorphTargets);for(var g=0,h=C.maxMorphTargets;g0;this.getContext=function(){return e};this.supportsVertexTextures=function(){return Va};this.setSize=function(a,b){oa.width=a;oa.height=b;this.setViewport(0,0,oa.width,oa.height)};this.setViewport=function(a,b,c,d){Oa=a;Pa=b;Ja=c;Ka=d;e.viewport(Oa,Pa,Ja,Ka)};this.setScissor=function(a,b,c,d){e.scissor(a,b,c,d)};this.enableScissorTest= +function(a){a?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(a,b){Q.setHex(a);J=b;e.clearColor(Q.r,Q.g,Q.b,J)};this.setClearColor=function(a,b){Q.copy(a);J=b;e.clearColor(Q.r,Q.g,Q.b,J)};this.getClearColor=function(){return Q};this.getClearAlpha=function(){return J};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=e.COLOR_BUFFER_BIT;if(b===void 0||b)d|=e.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=e.STENCIL_BUFFER_BIT;e.clear(d)};this.clearTarget=function(a,b,c, +d){qa(a);this.clear(b,c,d)};this.addPlugin=function(a){a.init(this);this.renderPlugins.push(a)};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];e.deleteBuffer(c.__webglVertexBuffer);e.deleteBuffer(c.__webglNormalBuffer);e.deleteBuffer(c.__webglTangentBuffer);e.deleteBuffer(c.__webglColorBuffer); +e.deleteBuffer(c.__webglUVBuffer);e.deleteBuffer(c.__webglUV2Buffer);e.deleteBuffer(c.__webglSkinVertexABuffer);e.deleteBuffer(c.__webglSkinVertexBBuffer);e.deleteBuffer(c.__webglSkinIndicesBuffer);e.deleteBuffer(c.__webglSkinWeightsBuffer);e.deleteBuffer(c.__webglFaceBuffer);e.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,f=c.numMorphTargets;d=0)w=D.geometry.materials[w],w.transparent?(t.transparent=w,t.opaque=null):(t.opaque=w,t.transparent=null)}else if(w)w.transparent?(t.transparent=w,t.opaque=null):(t.opaque=w,t.transparent=null);g.render=!0;if(this.sortObjects)h.renderDepth?g.z=h.renderDepth:(Ca.copy(h.position),za.multiplyVector3(Ca),g.z=Ca.z)}this.sortObjects&&o.sort(q);o=a.__webglObjectsImmediate; +d=0;for(f=o.length;d65535&&(w[y].counter+=1,k=w[y].hash+"_"+w[y].counter,l.geometryGroups[k]===void 0&&(l.geometryGroups[k]={faces3:[],faces4:[],materialIndex:s,vertices:0,numMorphTargets:G})),r instanceof THREE.Face3?l.geometryGroups[k].faces3.push(m): +l.geometryGroups[k].faces4.push(m),l.geometryGroups[k].vertices+=t;l.geometryGroupsList=[];m=void 0;for(m in l.geometryGroups)l.geometryGroups[m].id=Da++,l.geometryGroupsList.push(l.geometryGroups[m])}for(q in n.geometryGroups)if(l=n.geometryGroups[q],!l.__webglVertexBuffer){m=l;m.__webglVertexBuffer=e.createBuffer();m.__webglNormalBuffer=e.createBuffer();m.__webglTangentBuffer=e.createBuffer();m.__webglColorBuffer=e.createBuffer();m.__webglUVBuffer=e.createBuffer();m.__webglUV2Buffer=e.createBuffer(); +m.__webglSkinVertexABuffer=e.createBuffer();m.__webglSkinVertexBBuffer=e.createBuffer();m.__webglSkinIndicesBuffer=e.createBuffer();m.__webglSkinWeightsBuffer=e.createBuffer();m.__webglFaceBuffer=e.createBuffer();m.__webglLineBuffer=e.createBuffer();if(m.numMorphTargets){r=o=void 0;m.__webglMorphTargetsBuffers=[];o=0;for(r=m.numMorphTargets;o0||t.faceVertexUvs.length>0)l.__uvArray=new Float32Array(m*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)l.__uv2Array=new Float32Array(m*2)}if(s.geometry.skinWeights.length&&s.geometry.skinIndices.length)l.__skinVertexAArray= +new Float32Array(m*4),l.__skinVertexBArray=new Float32Array(m*4),l.__skinIndexArray=new Float32Array(m*4),l.__skinWeightArray=new Float32Array(m*4);l.__faceArray=new Uint16Array(r*3);l.__lineArray=new Uint16Array(y*2);if(l.numMorphTargets){l.__morphTargetsArrays=[];s=0;for(t=l.numMorphTargets;s0&&(e.bindBuffer(e.ARRAY_BUFFER,o.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,S,r),e.bindBuffer(e.ARRAY_BUFFER,o.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER, +T,r),e.bindBuffer(e.ARRAY_BUFFER,o.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,aa,r),e.bindBuffer(e.ARRAY_BUFFER,o.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,ha,r))}if(qa&&y){k=0;for(w=I.length;k0&&(e.bindBuffer(e.ARRAY_BUFFER,o.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,ca,r))}if(O&&ja.hasTangents){k=0;for(w=I.length;k0&&(e.bindBuffer(e.ARRAY_BUFFER,o.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,$,r))}if(na&&va&&J){k=0;for(w=I.length;k0&&(e.bindBuffer(e.ARRAY_BUFFER,o.__webglUV2Buffer), +e.bufferData(e.ARRAY_BUFFER,u,r))}if(oa){k=0;for(w=I.length;k=0&&d.enableVertexAttribArray(q.position);q.color>=0&&d.enableVertexAttribArray(q.color);q.normal>=0&&d.enableVertexAttribArray(q.normal); -q.tangent>=0&&d.enableVertexAttribArray(q.tangent);a.skinning&&q.skinVertexA>=0&&q.skinVertexB>=0&&q.skinIndex>=0&&q.skinWeight>=0&&(d.enableVertexAttribArray(q.skinVertexA),d.enableVertexAttribArray(q.skinVertexB),d.enableVertexAttribArray(q.skinIndex),d.enableVertexAttribArray(q.skinWeight));if(a.attributes)for(g in a.attributes)q[g]!==void 0&&q[g]>=0&&d.enableVertexAttribArray(q[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g=0&&(d.enableVertexAttribArray(q[y]), -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)};this.setBlending=function(a){if(a!==Na){switch(a){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE);break;case THREE.SubtractiveBlending:d.blendEquation(d.FUNC_ADD); -d.blendFunc(d.ZERO,d.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ZERO,d.SRC_COLOR);break;default:d.blendEquationSeparate(d.FUNC_ADD,d.FUNC_ADD),d.blendFuncSeparate(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA)}Na=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=d.createTexture(),F.info.memory.textures++;d.activeTexture(d.TEXTURE0+b);d.bindTexture(d.TEXTURE_2D,a.__webglTexture); -var c=ba(d.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?d.texImage2D(d.TEXTURE_2D,0,ia(a.format),a.image.width,a.image.height,0,ia(a.format),d.UNSIGNED_BYTE,a.image.data):d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA,d.UNSIGNED_BYTE,a.image);c&&d.generateMipmap(d.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else d.activeTexture(d.TEXTURE0+b),d.bindTexture(d.TEXTURE_2D,a.__webglTexture)}}; +h=["#ifdef GL_ES","precision "+Aa+" 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:"",C.gammaInput?"#define GAMMA_INPUT":"",C.gammaOutput?"#define GAMMA_OUTPUT":"",C.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");e.attachShader(s,K("fragment",h+l));e.attachShader(s, +K("vertex",d+n));e.linkProgram(s);e.getProgramParameter(s,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(s,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");s.uniforms={};s.attributes={};var y,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(y in j)d.push(y);y=d;d=0;for(j=y.length;d=0&&e.enableVertexAttribArray(m.position);m.color>=0&&e.enableVertexAttribArray(m.color);m.normal>=0&&e.enableVertexAttribArray(m.normal); +m.tangent>=0&&e.enableVertexAttribArray(m.tangent);a.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0&&(e.enableVertexAttribArray(m.skinVertexA),e.enableVertexAttribArray(m.skinVertexB),e.enableVertexAttribArray(m.skinIndex),e.enableVertexAttribArray(m.skinWeight));if(a.attributes)for(g in a.attributes)m[g]!==void 0&&m[g]>=0&&e.enableVertexAttribArray(m[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g=0&&(e.enableVertexAttribArray(m[y]), +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"?e.frontFace(e.CCW):e.frontFace(e.CW),a==="back"?e.cullFace(e.BACK):a==="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK),e.enable(e.CULL_FACE)):e.disable(e.CULL_FACE)};this.setBlending=function(a){if(a!==Qa){switch(a){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD); +e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}Qa=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=e.createTexture(),C.info.memory.textures++;e.activeTexture(e.TEXTURE0+b);e.bindTexture(e.TEXTURE_2D,a.__webglTexture); +var c=$(e.TEXTURE_2D,a,a.image);a instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,ga(a.format),a.image.width,a.image.height,0,ga(a.format),e.UNSIGNED_BYTE,a.image.data):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,a.image);c&&e.generateMipmap(e.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else e.activeTexture(e.TEXTURE0+b),e.bindTexture(e.TEXTURE_2D,a.__webglTexture)}}; 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: THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:!0}; THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0}; diff --git a/examples/webgl_sprites.html b/examples/webgl_sprites.html index e8f3df63..f5773a64 100644 --- a/examples/webgl_sprites.html +++ b/examples/webgl_sprites.html @@ -113,6 +113,10 @@ container.appendChild( renderer.domElement ); + renderer.addPlugin( new THREE.SpritePlugin() ); + + // stats + stats = new Stats(); stats.domElement.style.position = 'absolute'; stats.domElement.style.top = '0px'; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 6bea43f5..95593c73 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -162,18 +162,12 @@ THREE.WebGLRenderer = function ( parameters ) { var _cameraLight, _shadowMatrix = []; var _depthMaterial, _depthMaterialMorph; - // sprites - - var _sprite = {}; - var _spriteAttributesEnabled = false; - // initialize _gl = initGL(); setDefaultGLState(); - initSprites(); initShadowmaps(); this.context = _gl; @@ -3202,21 +3196,13 @@ THREE.WebGLRenderer = function ( parameters ) { } - // render 2d - - if ( scene.__webglSprites.length ) { - - renderSprites( scene, camera ); - - } - // custom render plugins if ( this.renderPlugins.length ) { for ( i = 0, il = this.renderPlugins.length; i < il; i ++ ) { - this.renderPlugins[ i ].render( scene, camera, _viewportWidth, _viewportHeight ); + this.renderPlugins[ i ].render( scene, camera, _viewportWidth, _viewportHeight, _projectionMatrixArray ); _currentProgram = null; _oldBlending = -1; @@ -3615,143 +3601,6 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function renderSprites ( scene, camera ) { - - var o, ol, object; - var attributes = _sprite.attributes; - var uniforms = _sprite.uniforms; - var invAspect = _viewportHeight / _viewportWidth; - var size, scale = []; - var screenPosition; - var halfViewportWidth = _viewportWidth * 0.5; - var halfViewportHeight = _viewportHeight * 0.5; - var mergeWith3D = true; - - // setup gl - - _gl.useProgram( _sprite.program ); - _currentProgram = _sprite.program; - _oldBlending = -1; - _oldDepthTest = -1; - _currentGeometryGroupHash = -1; - - if ( !_spriteAttributesEnabled ) { - - _gl.enableVertexAttribArray( _sprite.attributes.position ); - _gl.enableVertexAttribArray( _sprite.attributes.uv ); - - _spriteAttributesEnabled = true; - - } - - _gl.disable( _gl.CULL_FACE ); - _gl.enable( _gl.BLEND ); - _gl.depthMask( true ); - - _gl.bindBuffer( _gl.ARRAY_BUFFER, _sprite.vertexBuffer ); - _gl.vertexAttribPointer( attributes.position, 2, _gl.FLOAT, false, 2 * 8, 0 ); - _gl.vertexAttribPointer( attributes.uv, 2, _gl.FLOAT, false, 2 * 8, 8 ); - - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _sprite.elementBuffer ); - - _gl.uniformMatrix4fv( uniforms.projectionMatrix, false, _projectionMatrixArray ); - - _gl.activeTexture( _gl.TEXTURE0 ); - _gl.uniform1i( uniforms.map, 0 ); - - // update positions and sort - - for( o = 0, ol = scene.__webglSprites.length; o < ol; o ++ ) { - - object = scene.__webglSprites[ o ]; - - if ( !object.visible || object.opacity === 0 ) continue; - - if( !object.useScreenCoordinates ) { - - object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray ); - object.z = -object._modelViewMatrix.n34; - - } else { - - object.z = -object.position.z; - - } - - } - - scene.__webglSprites.sort( painterSort ); - - // render all sprites - - for ( o = 0, ol = scene.__webglSprites.length; o < ol; o ++ ) { - - object = scene.__webglSprites[ o ]; - - if ( !object.visible || object.opacity === 0 ) continue; - - if ( object.map && object.map.image && object.map.image.width ) { - - if ( object.useScreenCoordinates ) { - - _gl.uniform1i( uniforms.useScreenCoordinates, 1 ); - _gl.uniform3f( uniforms.screenPosition, ( object.position.x - halfViewportWidth ) / halfViewportWidth, - ( halfViewportHeight - object.position.y ) / halfViewportHeight, - Math.max( 0, Math.min( 1, object.position.z ))); - - } else { - - _gl.uniform1i( uniforms.useScreenCoordinates, 0 ); - _gl.uniform1i( uniforms.affectedByDistance, object.affectedByDistance ? 1 : 0 ); - _gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, object._modelViewMatrixArray ); - - } - - size = object.map.image.width / ( object.scaleByViewport ? _viewportHeight : 1 ); - - scale[ 0 ] = size * invAspect * object.scale.x; - scale[ 1 ] = size * object.scale.y; - - _gl.uniform2f( uniforms.uvScale, object.uvScale.x, object.uvScale.y ); - _gl.uniform2f( uniforms.uvOffset, object.uvOffset.x, object.uvOffset.y ); - _gl.uniform2f( uniforms.alignment, object.alignment.x, object.alignment.y ); - - _gl.uniform1f( uniforms.opacity, object.opacity ); - _gl.uniform3f( uniforms.color, object.color.r, object.color.g, object.color.b ); - - _gl.uniform1f( uniforms.rotation, object.rotation ); - _gl.uniform2fv( uniforms.scale, scale ); - - if ( object.mergeWith3D && !mergeWith3D ) { - - _gl.enable( _gl.DEPTH_TEST ); - mergeWith3D = true; - - } else if ( !object.mergeWith3D && mergeWith3D ) { - - _gl.disable( _gl.DEPTH_TEST ); - mergeWith3D = false; - - } - - _this.setBlending( object.blending ); - _this.setTexture( object.map, 0 ); - - _gl.drawElements( _gl.TRIANGLES, 6, _gl.UNSIGNED_SHORT, 0 ); - - } - - } - - - // restore gl - - _gl.enable( _gl.CULL_FACE ); - _gl.enable( _gl.DEPTH_TEST ); - _gl.depthMask( _oldDepthWrite ); - - } - // Geometry splitting function sortFacesByMaterial ( geometry ) { @@ -5917,72 +5766,6 @@ THREE.WebGLRenderer = function ( parameters ) { // Initialization - function initSprites () { - - _sprite.vertices = new Float32Array( 8 + 8 ); - _sprite.faces = new Uint16Array( 6 ); - - var i = 0; - - _sprite.vertices[ i++ ] = -1; _sprite.vertices[ i++ ] = -1; // vertex 0 - _sprite.vertices[ i++ ] = 0; _sprite.vertices[ i++ ] = 1; // uv 0 - - _sprite.vertices[ i++ ] = 1; _sprite.vertices[ i++ ] = -1; // vertex 1 - _sprite.vertices[ i++ ] = 1; _sprite.vertices[ i++ ] = 1; // uv 1 - - _sprite.vertices[ i++ ] = 1; _sprite.vertices[ i++ ] = 1; // vertex 2 - _sprite.vertices[ i++ ] = 1; _sprite.vertices[ i++ ] = 0; // uv 2 - - _sprite.vertices[ i++ ] = -1; _sprite.vertices[ i++ ] = 1; // vertex 3 - _sprite.vertices[ i++ ] = 0; _sprite.vertices[ i++ ] = 0; // uv 3 - - i = 0; - - _sprite.faces[ i++ ] = 0; _sprite.faces[ i++ ] = 1; _sprite.faces[ i++ ] = 2; - _sprite.faces[ i++ ] = 0; _sprite.faces[ i++ ] = 2; _sprite.faces[ i++ ] = 3; - - _sprite.vertexBuffer = _gl.createBuffer(); - _sprite.elementBuffer = _gl.createBuffer(); - - _gl.bindBuffer( _gl.ARRAY_BUFFER, _sprite.vertexBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, _sprite.vertices, _gl.STATIC_DRAW ); - - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, _sprite.elementBuffer ); - _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, _sprite.faces, _gl.STATIC_DRAW ); - - _sprite.program = _gl.createProgram(); - _gl.attachShader( _sprite.program, getShader( "fragment", THREE.ShaderLib.sprite.fragmentShader ) ); - _gl.attachShader( _sprite.program, getShader( "vertex", THREE.ShaderLib.sprite.vertexShader ) ); - _gl.linkProgram( _sprite.program ); - - _sprite.attributes = {}; - _sprite.uniforms = {}; - - _sprite.attributes.position = _gl.getAttribLocation ( _sprite.program, "position" ); - _sprite.attributes.uv = _gl.getAttribLocation ( _sprite.program, "uv" ); - - _sprite.uniforms.uvOffset = _gl.getUniformLocation( _sprite.program, "uvOffset" ); - _sprite.uniforms.uvScale = _gl.getUniformLocation( _sprite.program, "uvScale" ); - - _sprite.uniforms.rotation = _gl.getUniformLocation( _sprite.program, "rotation" ); - _sprite.uniforms.scale = _gl.getUniformLocation( _sprite.program, "scale" ); - _sprite.uniforms.alignment = _gl.getUniformLocation( _sprite.program, "alignment" ); - - _sprite.uniforms.color = _gl.getUniformLocation( _sprite.program, "color" ); - _sprite.uniforms.map = _gl.getUniformLocation( _sprite.program, "map" ); - _sprite.uniforms.opacity = _gl.getUniformLocation( _sprite.program, "opacity" ); - - _sprite.uniforms.useScreenCoordinates = _gl.getUniformLocation( _sprite.program, "useScreenCoordinates" ); - _sprite.uniforms.affectedByDistance = _gl.getUniformLocation( _sprite.program, "affectedByDistance" ); - _sprite.uniforms.screenPosition = _gl.getUniformLocation( _sprite.program, "screenPosition" ); - _sprite.uniforms.modelViewMatrix = _gl.getUniformLocation( _sprite.program, "modelViewMatrix" ); - _sprite.uniforms.projectionMatrix = _gl.getUniformLocation( _sprite.program, "projectionMatrix" ); - - //_gl.enableVertexAttribArray( _sprite.attributes.position ); - //_gl.enableVertexAttribArray( _sprite.attributes.uv ); - - }; - function initShadowmaps () { var depthShader = THREE.ShaderLib[ "depthRGBA" ]; diff --git a/src/renderers/WebGLShaders.js b/src/renderers/WebGLShaders.js index ca5c0971..0dd675af 100644 --- a/src/renderers/WebGLShaders.js +++ b/src/renderers/WebGLShaders.js @@ -966,78 +966,6 @@ THREE.UniformsLib = { THREE.ShaderLib = { - 'sprite': { - - vertexShader: [ - - "uniform int useScreenCoordinates;", - "uniform int affectedByDistance;", - "uniform vec3 screenPosition;", - "uniform mat4 modelViewMatrix;", - "uniform mat4 projectionMatrix;", - "uniform float rotation;", - "uniform vec2 scale;", - "uniform vec2 alignment;", - "uniform vec2 uvOffset;", - "uniform vec2 uvScale;", - - "attribute vec2 position;", - "attribute vec2 uv;", - - "varying vec2 vUV;", - - "void main() {", - - "vUV = uvOffset + uv * uvScale;", - - "vec2 alignedPosition = position + alignment;", - - "vec2 rotatedPosition;", - "rotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;", - "rotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;", - - "vec4 finalPosition;", - - "if( useScreenCoordinates != 0 ) {", - - "finalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );", - - "} else {", - - "finalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );", - "finalPosition.xy += rotatedPosition * ( affectedByDistance == 1 ? 1.0 : finalPosition.z );", - - "}", - - "gl_Position = finalPosition;", - - "}" - - ].join( "\n" ), - - fragmentShader: [ - - "#ifdef GL_ES", - "precision highp float;", - "#endif", - - "uniform vec3 color;", - "uniform sampler2D map;", - "uniform float opacity;", - - "varying vec2 vUV;", - - "void main() {", - - "vec4 texture = texture2D( map, vUV );", - "gl_FragColor = vec4( color * texture.xyz, texture.a * opacity );", - - "}" - - ].join( "\n" ) - - }, - 'depth': { uniforms: { diff --git a/utils/build.py b/utils/build.py index 1e581518..0d3bbfdf 100644 --- a/utils/build.py +++ b/utils/build.py @@ -131,9 +131,11 @@ EXTRAS_FILES = [ 'extras/objects/MarchingCubes.js', 'extras/objects/LensFlare.js', 'extras/plugins/LensFlarePlugin.js', +'extras/plugins/SpritePlugin.js', 'extras/renderers/AnaglyphWebGLRenderer.js', 'extras/renderers/CrosseyedWebGLRenderer.js', -'extras/shaders/ShaderFlares.js' +'extras/shaders/ShaderFlares.js', +'extras/shaders/ShaderSprite.js' ] CANVAS_FILES = [