diff --git a/build/Three.js b/build/Three.js index 24b14a47..503fcf4d 100644 --- a/build/Three.js +++ b/build/Three.js @@ -18,42 +18,42 @@ 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){n.sub(c,a);p=n.dot(b);if(p<=0)return null;o=q.add(a,m.copy(b).multiplyScalar(p));return r=c.distanceTo(o)}function d(a,b,c,d){n.sub(d,b);q.sub(c,b);m.sub(a,b);s=n.dot(n);u=n.dot(q);t=n.dot(m);A=q.dot(q);B=q.dot(m);z=1/(s*A-u*u);E=(A*t-u*B)*z;H=(s*B-u*t)*z;return E>=0&&H>=0&&E+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[];o={distance:n,point:m.position,face:null,object:m};p.push(o)}else if(m instanceof THREE.Mesh){n=c(this.origin,this.direction,m.matrixWorld.getPosition());if(n===null||n>m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)))return p;var r,s=m.geometry,u=s.vertices,t;m.matrixRotationWorld.extractRotation(m.matrixWorld);n=0;for(q=s.faces.length;n0:r<0)))if(r=j.dot(i.sub(e,a))/r,k.add(a,b.multiplyScalar(r)),o instanceof THREE.Face3)d(k, -e,f,g)&&(o={distance:a.distanceTo(k),point:k.clone(),face:o,object:m},p.push(o));else if(o instanceof THREE.Face4&&(d(k,e,f,h)||d(k,f,g,h)))o={distance:a.distanceTo(k),point:k.clone(),face:o,object:m},p.push(o)}return p};var n=new THREE.Vector3,q=new THREE.Vector3,m=new THREE.Vector3,p,o,r,s,u,t,A,B,z,E,H}; -THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,k,n){h=!1;b=f;c=g;d=k;e=n;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= -function(f,g,k,n,q,m){h?(h=!1,b=fk?f>q?f:q:k>q?k:q,e=g>n?g>m?g:m:n>m?n:m):(b=fk?f>q?f>d?f:d:q>d?q:d:k>q?k>d?k:d:q>d?q:d,e=g>n?g>m?g>e?g:e:m>e?m:e:n>m?n>e?n:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> +THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);p=o.dot(b);if(p<=0)return null;m=s.add(a,n.copy(b).multiplyScalar(p));return q=c.distanceTo(m)}function d(a,b,c,d){o.sub(d,b);s.sub(c,b);n.sub(a,b);r=o.dot(o);t=o.dot(s);x=o.dot(n);v=s.dot(s);D=s.dot(n);y=1/(r*v-t*t);F=(v*x-t*D)*y;E=(r*D-t*x)*y;return F>=0&&E>=0&&F+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;bn.scale.x)return[];m={distance:o,point:n.position,face:null,object:n};p.push(m)}else if(n instanceof THREE.Mesh){o=c(this.origin,this.direction,n.matrixWorld.getPosition());if(o===null||o>n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)))return p;var q,r=n.geometry,t=r.vertices,x;n.matrixRotationWorld.extractRotation(n.matrixWorld);o=0;for(s=r.faces.length;o0:q<0)))if(q=j.dot(i.sub(e,a))/q,k.add(a,b.multiplyScalar(q)),m instanceof THREE.Face3)d(k, +e,f,g)&&(m={distance:a.distanceTo(k),point:k.clone(),face:m,object:n},p.push(m));else if(m instanceof THREE.Face4&&(d(k,e,f,h)||d(k,f,g,h)))m={distance:a.distanceTo(k),point:k.clone(),face:m,object:n},p.push(m)}return p};var o=new THREE.Vector3,s=new THREE.Vector3,n=new THREE.Vector3,p,m,q,r,t,x,v,D,y,F,E}; +THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,k,o){h=!1;b=f;c=g;d=k;e=o;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= +function(f,g,k,o,s,n){h?(h=!1,b=fk?f>s?f:s:k>s?k:s,e=g>o?g>n?g:n:o>n?o:n):(b=fk?f>s?f>d?f:d:s>d?s:d:k>s?k>d?k:d:s>d?s:d,e=g>o?g>n?g>e?g:e:n>e?n:e:o>n?o>e?o:e:n>e?n:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=da.getRight())return!1;if(ea.getBottom())return!1;return!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&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dg&&h.positionScreen.z0&&E.z<1))g=A[t]=A[t]||new THREE.RenderableParticle,t++,u=g,u.x=E.x/E.w,u.y=E.y/E.w,u.z=E.z,u.rotation= -ea.rotation.z,u.scale.x=ea.scale.x*Math.abs(u.x-(E.x+e.projectionMatrix.n11)/(E.w+e.projectionMatrix.n14)),u.scale.y=ea.scale.y*Math.abs(u.y-(E.y+e.projectionMatrix.n22)/(E.w+e.projectionMatrix.n24)),u.material=ea.material,B.elements.push(u);f&&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)}; +k,o,s=[],n,p=[],m,q,r=[],t,x,v=[],D={objects:[],sprites:[],lights:[],elements:[]},y=new THREE.Vector3,F=new THREE.Vector4,E=new THREE.Matrix4,u=new THREE.Matrix4,I=new THREE.Frustum,w=new THREE.Vector4,R=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);E.multiply(b.projectionMatrix,b.matrixWorldInverse);E.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);E.multiply(b.matrixWorld, +b.projectionMatrixInverse);E.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;D.objects.length=0;D.sprites.length=0;D.lights.length=0;var g=function(b){if(b.visible!==!1){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(b.frustumCulled===!1||I.contains(b))?(E.multiplyVector3(y.copy(b.position)),e=a(),e.object= +b,e.z=y.z,D.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(E.multiplyVector3(y.copy(b.position)),e=a(),e.object=b,e.z=y.z,D.sprites.push(e)):b instanceof THREE.Light&&D.lights.push(b);for(var c=0,d=b.children.length;cg&&h.positionScreen.z0&&F.z<1))g=v[x]=v[x]||new THREE.RenderableParticle,x++,t=g,t.x= +F.x/F.w,t.y=F.y/F.w,t.z=F.z,t.rotation=Z.rotation.z,t.scale.x=Z.scale.x*Math.abs(t.x-(F.x+e.projectionMatrix.n11)/(F.w+e.projectionMatrix.n14)),t.scale.y=Z.scale.y*Math.abs(t.y-(F.y+e.projectionMatrix.n22)/(F.w+e.projectionMatrix.n24)),t.material=Z.material,D.elements.push(t);f&&D.elements.sort(c);return D}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= -this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,i=this.w,j=i*c+g*e-h*d,k=i*d+h*c-f*e,n=i*e+f*d-g*c,c=-f* -c-g*d-h*e;b.x=j*i+c*-f+k*-h-n*-g;b.y=k*i+c*-g+n*-f-j*-h;b.z=n*i+c*-h+j*-g-k*-f;return b}}; +this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,i=this.w,j=i*c+g*e-h*d,k=i*d+h*c-f*e,o=i*e+f*d-g*c,c=-f* +c-g*d-h*e;b.x=j*i+c*-f+k*-h-o*-g;b.y=k*i+c*-g+o*-f-j*-h;b.z=o*i+c*-h+j*-g-k*-f;return b}}; THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;e<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.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)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; @@ -88,13 +88,13 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid b,c,d,e,f,g=new THREE.Vector3,h=new THREE.Vector3;a=0;for(b=this.faces.length;a0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;dc.x)c.x=a.x;if(a.yc.y)c.y=a.y;if(a.zc.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,c=0,d=this.vertices.length;cb&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;fthis.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;j=this.points[c[0]];k=this.points[c[1]]; -n=this.points[c[2]];q=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,k.x,n.x,q.x,g,h,i);d.y=b(j.y,k.y,n.y,q.y,g,h,i);d.z=b(j.z,k.z,n.z,q.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;j=this.points[c[0]];k=this.points[c[1]]; +o=this.points[c[2]];s=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,k.x,o.x,s.x,g,h,i);d.y=b(j.y,k.y,o.y,s.y,g,h,i);d.z=b(j.z,k.z,o.z,s.z,g,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(r.r*255)+","+Math.floor(r.g*255)+","+Math.floor(r.b*255)+","+s+")"),o.fillRect(Math.floor(ta.getX()), -Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight()))),ta.empty())};this.render=function(a,k){function n(a){var b,c,d,e;da.setRGB(0,0,0);aa.setRGB(0,0,0);C.setRGB(0,0,0);b=0;for(c=a.length;b>1,C=i.height>>1,g=f.scale.x*m,l=f.scale.y*p,da=g*k,h=l*C,pa.set(a.x-da,a.y-h,a.x+da,a.y+h),la.intersects(pa)&&(o.save(),o.translate(a.x,a.y),o.rotate(-f.rotation),o.scale(g,-l),o.translate(-k,-C),o.drawImage(i,0,0),o.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(da=f.scale.x*m,h=f.scale.y*p,pa.set(a.x-da,a.y-h,a.x+da,a.y+h),la.intersects(pa)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),o.save(),o.translate(a.x,a.y),o.rotate(-f.rotation),o.scale(da,h),g.program(o), -o.restore()))}function s(a,e,f,g){b(g.opacity);c(g.blending);o.beginPath();o.moveTo(a.positionScreen.x,a.positionScreen.y);o.lineTo(e.positionScreen.x,e.positionScreen.y);o.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(z!=a)o.lineWidth=z=a;a=g.linecap;if(E!=a)o.lineCap=E=a;a=g.linejoin;if(H!=a)o.lineJoin=H=a;d(g.color.getContextStyle());o.stroke();pa.inflate(g.linewidth*2)}}function u(a,d,e,g,h,C,aa,j){f.info.render.vertices+=3;f.info.render.faces++;b(j.opacity);c(j.blending); -X=a.positionScreen.x;T=a.positionScreen.y;R=d.positionScreen.x;l=d.positionScreen.y;S=e.positionScreen.x;v=e.positionScreen.y;A(X,T,R,l,S,v);if(j instanceof THREE.MeshBasicMaterial)if(j.map)j.map.mapping instanceof THREE.UVMapping&&(ra=aa.uvs[0],Pa(X,T,R,l,S,v,ra[g].u,ra[g].v,ra[h].u,ra[h].v,ra[C].u,ra[C].v,j.map));else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,qa.copy(aa.vertexNormalsWorld[g]),Ba=(qa.x*a.n11+qa.y*a.n12+qa.z*a.n13)*0.5+0.5, -wa=-(qa.x*a.n21+qa.y*a.n22+qa.z*a.n23)*0.5+0.5,qa.copy(aa.vertexNormalsWorld[h]),xa=(qa.x*a.n11+qa.y*a.n12+qa.z*a.n13)*0.5+0.5,ya=-(qa.x*a.n21+qa.y*a.n22+qa.z*a.n23)*0.5+0.5,qa.copy(aa.vertexNormalsWorld[C]),za=(qa.x*a.n11+qa.y*a.n12+qa.z*a.n13)*0.5+0.5,Aa=-(qa.x*a.n21+qa.y*a.n22+qa.z*a.n23)*0.5+0.5,Pa(X,T,R,l,S,v,Ba,wa,xa,ya,za,Aa,j.envMap)}else j.wireframe?J(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Ea(j.color);else if(j instanceof THREE.MeshLambertMaterial)j.map&&!j.wireframe&& -(j.map.mapping instanceof THREE.UVMapping&&(ra=aa.uvs[0],Pa(X,T,R,l,S,v,ra[g].u,ra[g].v,ra[h].u,ra[h].v,ra[C].u,ra[C].v,j.map)),c(THREE.SubtractiveBlending)),Ia?!j.wireframe&&j.shading==THREE.SmoothShading&&aa.vertexNormalsWorld.length==3?(L.r=V.r=ba.r=da.r,L.g=V.g=ba.g=da.g,L.b=V.b=ba.b=da.b,q(i,aa.v1.positionWorld,aa.vertexNormalsWorld[0],L),q(i,aa.v2.positionWorld,aa.vertexNormalsWorld[1],V),q(i,aa.v3.positionWorld,aa.vertexNormalsWorld[2],ba),L.r=Math.max(0,Math.min(j.color.r*L.r,1)),L.g=Math.max(0, -Math.min(j.color.g*L.g,1)),L.b=Math.max(0,Math.min(j.color.b*L.b,1)),V.r=Math.max(0,Math.min(j.color.r*V.r,1)),V.g=Math.max(0,Math.min(j.color.g*V.g,1)),V.b=Math.max(0,Math.min(j.color.b*V.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)),ga.r=(V.r+ba.r)*0.5,ga.g=(V.g+ba.g)*0.5,ga.b=(V.b+ba.b)*0.5,sa=P(L,V,ba,ga),Ja(X,T,R,l,S,v,0,0,1,0,0,1,sa)):(U.r=da.r,U.g=da.g,U.b=da.b,q(i,aa.centroidWorld,aa.normalWorld,U), -U.r=Math.max(0,Math.min(j.color.r*U.r,1)),U.g=Math.max(0,Math.min(j.color.g*U.g,1)),U.b=Math.max(0,Math.min(j.color.b*U.b,1)),j.wireframe?J(U,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Ea(U)):j.wireframe?J(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Ea(j.color);else if(j instanceof THREE.MeshDepthMaterial)na=k.near,ja=k.far,L.r=L.g=L.b=1-N(a.positionScreen.z,na,ja),V.r=V.g=V.b=1-N(d.positionScreen.z,na,ja),ba.r=ba.g=ba.b=1-N(e.positionScreen.z,na,ja),ga.r= -(V.r+ba.r)*0.5,ga.g=(V.g+ba.g)*0.5,ga.b=(V.b+ba.b)*0.5,sa=P(L,V,ba,ga),Ja(X,T,R,l,S,v,0,0,1,0,0,1,sa);else if(j instanceof THREE.MeshNormalMaterial)U.r=O(aa.normalWorld.x),U.g=O(aa.normalWorld.y),U.b=O(aa.normalWorld.z),j.wireframe?J(U,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):Ea(U)}function t(a,d,e,g,h,j,aa,C,o){f.info.render.vertices+=4;f.info.render.faces++;b(C.opacity);c(C.blending);if(C.map||C.envMap)u(a,d,g,0,1,3,aa,C,o),u(h,e,j,1,2,3,aa,C,o);else if(X=a.positionScreen.x, -T=a.positionScreen.y,R=d.positionScreen.x,l=d.positionScreen.y,S=e.positionScreen.x,v=e.positionScreen.y,W=g.positionScreen.x,M=g.positionScreen.y,Y=h.positionScreen.x,ca=h.positionScreen.y,$=j.positionScreen.x,ea=j.positionScreen.y,C instanceof THREE.MeshBasicMaterial)B(X,T,R,l,S,v,W,M),C.wireframe?J(C.color,C.wireframeLinewidth,C.wireframeLinecap,C.wireframeLinejoin):Ea(C.color);else if(C instanceof THREE.MeshLambertMaterial)Ia?!C.wireframe&&C.shading==THREE.SmoothShading&&aa.vertexNormalsWorld.length== -4?(L.r=V.r=ba.r=ga.r=da.r,L.g=V.g=ba.g=ga.g=da.g,L.b=V.b=ba.b=ga.b=da.b,q(i,aa.v1.positionWorld,aa.vertexNormalsWorld[0],L),q(i,aa.v2.positionWorld,aa.vertexNormalsWorld[1],V),q(i,aa.v4.positionWorld,aa.vertexNormalsWorld[3],ba),q(i,aa.v3.positionWorld,aa.vertexNormalsWorld[2],ga),L.r=Math.max(0,Math.min(C.color.r*L.r,1)),L.g=Math.max(0,Math.min(C.color.g*L.g,1)),L.b=Math.max(0,Math.min(C.color.b*L.b,1)),V.r=Math.max(0,Math.min(C.color.r*V.r,1)),V.g=Math.max(0,Math.min(C.color.g*V.g,1)),V.b=Math.max(0, -Math.min(C.color.b*V.b,1)),ba.r=Math.max(0,Math.min(C.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(C.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(C.color.b*ba.b,1)),ga.r=Math.max(0,Math.min(C.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(C.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(C.color.b*ga.b,1)),sa=P(L,V,ba,ga),A(X,T,R,l,W,M),Ja(X,T,R,l,W,M,0,0,1,0,0,1,sa),A(Y,ca,S,v,$,ea),Ja(Y,ca,S,v,$,ea,1,0,1,1,0,1,sa)):(U.r=da.r,U.g=da.g,U.b=da.b,q(i,aa.centroidWorld,aa.normalWorld,U),U.r=Math.max(0,Math.min(C.color.r* -U.r,1)),U.g=Math.max(0,Math.min(C.color.g*U.g,1)),U.b=Math.max(0,Math.min(C.color.b*U.b,1)),B(X,T,R,l,S,v,W,M),C.wireframe?J(U,C.wireframeLinewidth,C.wireframeLinecap,C.wireframeLinejoin):Ea(U)):(B(X,T,R,l,S,v,W,M),C.wireframe?J(C.color,C.wireframeLinewidth,C.wireframeLinecap,C.wireframeLinejoin):Ea(C.color));else if(C instanceof THREE.MeshNormalMaterial)U.r=O(aa.normalWorld.x),U.g=O(aa.normalWorld.y),U.b=O(aa.normalWorld.z),B(X,T,R,l,S,v,W,M),C.wireframe?J(U,C.wireframeLinewidth,C.wireframeLinecap, -C.wireframeLinejoin):Ea(U);else if(C instanceof THREE.MeshDepthMaterial)na=k.near,ja=k.far,L.r=L.g=L.b=1-N(a.positionScreen.z,na,ja),V.r=V.g=V.b=1-N(d.positionScreen.z,na,ja),ba.r=ba.g=ba.b=1-N(g.positionScreen.z,na,ja),ga.r=ga.g=ga.b=1-N(e.positionScreen.z,na,ja),sa=P(L,V,ba,ga),A(X,T,R,l,W,M),Ja(X,T,R,l,W,M,0,0,1,0,0,1,sa),A(Y,ca,S,v,$,ea),Ja(Y,ca,S,v,$,ea,1,0,1,1,0,1,sa)}function A(a,b,c,d,e,f){o.beginPath();o.moveTo(a,b);o.lineTo(c,d);o.lineTo(e,f);o.lineTo(a,b);o.closePath()}function B(a,b,c, -d,e,f,g,da){o.beginPath();o.moveTo(a,b);o.lineTo(c,d);o.lineTo(e,f);o.lineTo(g,da);o.lineTo(a,b);o.closePath()}function J(a,b,c,e){if(z!=b)o.lineWidth=z=b;if(E!=c)o.lineCap=E=c;if(H!=e)o.lineJoin=H=e;d(a.getContextStyle());o.stroke();pa.inflate(b*2)}function Ea(a){e(a.getContextStyle());o.fill()}function Pa(a,b,c,d,f,g,da,h,l,i,C,j,aa){if(aa.image.width!=0){if(aa.needsUpdate==!0||va[aa.id]==void 0){var k=aa.wrapS==THREE.RepeatWrapping,m=aa.wrapT==THREE.RepeatWrapping;va[aa.id]=o.createPattern(aa.image, -k&&m?"repeat":k&&!m?"repeat-x":!k&&m?"repeat-y":"no-repeat");aa.needsUpdate=!1}e(va[aa.id]);var k=aa.offset.x/aa.repeat.x,m=aa.offset.y/aa.repeat.y,n=aa.image.width*aa.repeat.x,qa=aa.image.height*aa.repeat.y,da=(da+k)*n,h=(h+m)*qa,l=(l+k)*n,i=(i+m)*qa,C=(C+k)*n,j=(j+m)*qa;c-=a;d-=b;f-=a;g-=b;l-=da;i-=h;C-=da;j-=h;k=l*j-C*i;if(k==0){if(fa[aa.id]==void 0)b=document.createElement("canvas"),b.width=aa.image.width,b.height=aa.image.height,a=b.getContext("2d"),a.drawImage(aa.image,0,0),fa[aa.id]=a.getImageData(0, -0,aa.image.width,aa.image.height).data,delete b;b=fa[aa.id];da=(Math.floor(da)+Math.floor(h)*aa.image.width)*4;U.setRGB(b[da]/255,b[da+1]/255,b[da+2]/255);Ea(U)}else k=1/k,aa=(j*c-i*f)*k,i=(j*d-i*g)*k,c=(l*f-C*c)*k,d=(l*g-C*d)*k,a=a-aa*da-c*h,da=b-i*da-d*h,o.save(),o.transform(aa,i,c,d,a,da),o.fill(),o.restore()}}function Ja(a,b,c,d,e,f,g,da,h,l,i,C,aa){var k,j;k=aa.width-1;j=aa.height-1;g*=k;da*=j;h*=k;l*=j;i*=k;C*=j;c-=a;d-=b;e-=a;f-=b;h-=g;l-=da;i-=g;C-=da;j=1/(h*C-i*l);k=(C*c-l*e)*j;l=(C*d-l* -f)*j;c=(h*e-i*c)*j;d=(h*f-i*d)*j;a=a-k*g-c*da;b=b-l*g-d*da;o.save();o.transform(k,l,c,d,a,b);o.clip();o.drawImage(aa,0,0);o.restore()}function P(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),da=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),l=~~(c.g*255),c=~~(c.b*255),i=~~(d.r*255),C=~~(d.g*255),d=~~(d.b*255);Ca[0]=e<0?0:e>255?255:e;Ca[1]=f<0?0:f>255?255:f;Ca[2]=a<0?0:a>255?255:a;Ca[4]=g<0?0:g>255?255:g;Ca[5]=da<0?0:da>255?255:da;Ca[6]=b<0?0:b>255?255:b;Ca[8]=h<0?0:h>255?255:h;Ca[9]= -l<0?0:l>255?255:l;Ca[10]=c<0?0:c>255?255:c;Ca[12]=i<0?0:i>255?255:i;Ca[13]=C<0?0:C>255?255:C;Ca[14]=d<0?0:d>255?255:d;La.putImageData(Oa,0,0);D.drawImage(Ka,0,0);return Ma}function N(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function O(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Fa(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 Na,Qa,ua,Da;this.autoClear?this.clear():o.setTransform(1,0,0,-1,m,p);f.info.render.vertices=0;f.info.render.faces= -0;g=j.projectScene(a,k,this.sortElements);h=g.elements;i=g.lights;(Ia=i.length>0)&&n(i);Na=0;for(Qa=h.length;Na1?1:a}var d=this,e,f,g,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,k,n,q,m,p,o,r,s=new THREE.Rectangle,u=new THREE.Rectangle,t=!1,A=new THREE.Color,B=new THREE.Color,z=new THREE.Color,E=new THREE.Color,H,w=new THREE.Vector3,G=[],y=[],K,Z,Q,X=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":X=1;break;case "low":X=0}};this.setSize=function(a,b){j=a;k=b;n=j/2;q=k/2;i.setAttribute("viewBox",-n+" "+-q+" "+j+" "+k);i.setAttribute("width",j);i.setAttribute("height",k);s.set(-n,-q,n,q)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(j,k){var l,G,v,w;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(j,k,this.sortElements);f=e.elements; -g=e.lights;Q=Z=0;if(t=g.length>0){B.setRGB(0,0,0);z.setRGB(0,0,0);E.setRGB(0,0,0);l=0;for(G=g.length;l0&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b* +255)+","+r+")"),m.fillRect(Math.floor(ja.getX()),Math.floor(ja.getY()),Math.floor(ja.getWidth()),Math.floor(ja.getHeight()))),ja.empty())};this.render=function(a,k){function o(a){var b,c,d,e;fa.setRGB(0,0,0);da.setRGB(0,0,0);ma.setRGB(0,0,0);b=0;for(c=a.length;b>1,k=l.height>>1,g=f.scale.x*n,da=f.scale.y*p,h=g*i,fa=da*k,qa.set(a.x-h,a.y-fa,a.x+h,a.y+fa),ha.intersects(qa)&&(m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(g,-da),m.translate(-i,-k),m.drawImage(l,0,0),m.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*n,fa=f.scale.y*p,qa.set(a.x-h,a.y-fa,a.x+h,a.y+fa),ha.intersects(qa)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),m.save(),m.translate(a.x, +a.y),m.rotate(-f.rotation),m.scale(h,fa),g.program(m),m.restore()))}function r(a,e,f,g){b(g.opacity);c(g.blending);m.beginPath();m.moveTo(a.positionScreen.x,a.positionScreen.y);m.lineTo(e.positionScreen.x,e.positionScreen.y);m.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)m.lineWidth=y=a;a=g.linecap;if(F!=a)m.lineCap=F=a;a=g.linejoin;if(E!=a)m.lineJoin=E=a;d(g.color.getContextStyle());m.stroke();qa.inflate(g.linewidth*2)}}function t(a,d,e,g,h,da,j,m){f.info.render.vertices+= +3;f.info.render.faces++;b(m.opacity);c(m.blending);T=a.positionScreen.x;Y=a.positionScreen.y;O=d.positionScreen.x;l=d.positionScreen.y;P=e.positionScreen.x;A=e.positionScreen.y;v(T,Y,O,l,P,A);if(m instanceof THREE.MeshBasicMaterial)if(m.map)m.map.mapping instanceof THREE.UVMapping&&(sa=j.uvs[0],Qa(T,Y,O,l,P,A,sa[g].u,sa[g].v,sa[h].u,sa[h].v,sa[da].u,sa[da].v,m.map));else if(m.envMap){if(m.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,ra.copy(j.vertexNormalsWorld[g]), +ya=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,za=-(ra.x*a.n21+ra.y*a.n22+ra.z*a.n23)*0.5+0.5,ra.copy(j.vertexNormalsWorld[h]),Aa=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,Ba=-(ra.x*a.n21+ra.y*a.n22+ra.z*a.n23)*0.5+0.5,ra.copy(j.vertexNormalsWorld[da]),xa=(ra.x*a.n11+ra.y*a.n12+ra.z*a.n13)*0.5+0.5,Ca=-(ra.x*a.n21+ra.y*a.n22+ra.z*a.n23)*0.5+0.5,Qa(T,Y,O,l,P,A,ya,za,Aa,Ba,xa,Ca,m.envMap)}else m.wireframe?Fa(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):H(m.color);else if(m instanceof +THREE.MeshLambertMaterial)m.map&&!m.wireframe&&(m.map.mapping instanceof THREE.UVMapping&&(sa=j.uvs[0],Qa(T,Y,O,l,P,A,sa[g].u,sa[g].v,sa[h].u,sa[h].v,sa[da].u,sa[da].v,m.map)),c(THREE.SubtractiveBlending)),Ha?!m.wireframe&&m.shading==THREE.SmoothShading&&j.vertexNormalsWorld.length==3?($.r=U.r=Q.r=fa.r,$.g=U.g=Q.g=fa.g,$.b=U.b=Q.b=fa.b,s(i,j.v1.positionWorld,j.vertexNormalsWorld[0],$),s(i,j.v2.positionWorld,j.vertexNormalsWorld[1],U),s(i,j.v3.positionWorld,j.vertexNormalsWorld[2],Q),$.r=Math.max(0, +Math.min(m.color.r*$.r,1)),$.g=Math.max(0,Math.min(m.color.g*$.g,1)),$.b=Math.max(0,Math.min(m.color.b*$.b,1)),U.r=Math.max(0,Math.min(m.color.r*U.r,1)),U.g=Math.max(0,Math.min(m.color.g*U.g,1)),U.b=Math.max(0,Math.min(m.color.b*U.b,1)),Q.r=Math.max(0,Math.min(m.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(m.color.g*Q.g,1)),Q.b=Math.max(0,Math.min(m.color.b*Q.b,1)),ba.r=(U.r+Q.r)*0.5,ba.g=(U.g+Q.g)*0.5,ba.b=(U.b+Q.b)*0.5,va=Na($,U,Q,ba),Ia(T,Y,O,l,P,A,0,0,1,0,0,1,va)):(S.r=fa.r,S.g=fa.g,S.b=fa.b,s(i,j.centroidWorld, +j.normalWorld,S),S.r=Math.max(0,Math.min(m.color.r*S.r,1)),S.g=Math.max(0,Math.min(m.color.g*S.g,1)),S.b=Math.max(0,Math.min(m.color.b*S.b,1)),m.wireframe?Fa(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):H(S)):m.wireframe?Fa(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):H(m.color);else if(m instanceof THREE.MeshDepthMaterial)oa=k.near,ta=k.far,$.r=$.g=$.b=1-L(a.positionScreen.z,oa,ta),U.r=U.g=U.b=1-L(d.positionScreen.z,oa,ta),Q.r=Q.g=Q.b=1-L(e.positionScreen.z, +oa,ta),ba.r=(U.r+Q.r)*0.5,ba.g=(U.g+Q.g)*0.5,ba.b=(U.b+Q.b)*0.5,va=Na($,U,Q,ba),Ia(T,Y,O,l,P,A,0,0,1,0,0,1,va);else if(m instanceof THREE.MeshNormalMaterial)S.r=M(j.normalWorld.x),S.g=M(j.normalWorld.y),S.b=M(j.normalWorld.z),m.wireframe?Fa(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):H(S)}function x(a,d,e,g,h,da,m,j,ma){f.info.render.vertices+=4;f.info.render.faces++;b(j.opacity);c(j.blending);if(j.map||j.envMap)t(a,d,g,0,1,3,m,j,ma),t(h,e,da,1,2,3,m,j,ma);else if(T=a.positionScreen.x, +Y=a.positionScreen.y,O=d.positionScreen.x,l=d.positionScreen.y,P=e.positionScreen.x,A=e.positionScreen.y,X=g.positionScreen.x,N=g.positionScreen.y,W=h.positionScreen.x,aa=h.positionScreen.y,ea=da.positionScreen.x,Z=da.positionScreen.y,j instanceof THREE.MeshBasicMaterial)D(T,Y,O,l,P,A,X,N),j.wireframe?Fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):H(j.color);else if(j instanceof THREE.MeshLambertMaterial)Ha?!j.wireframe&&j.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length== +4?($.r=U.r=Q.r=ba.r=fa.r,$.g=U.g=Q.g=ba.g=fa.g,$.b=U.b=Q.b=ba.b=fa.b,s(i,m.v1.positionWorld,m.vertexNormalsWorld[0],$),s(i,m.v2.positionWorld,m.vertexNormalsWorld[1],U),s(i,m.v4.positionWorld,m.vertexNormalsWorld[3],Q),s(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ba),$.r=Math.max(0,Math.min(j.color.r*$.r,1)),$.g=Math.max(0,Math.min(j.color.g*$.g,1)),$.b=Math.max(0,Math.min(j.color.b*$.b,1)),U.r=Math.max(0,Math.min(j.color.r*U.r,1)),U.g=Math.max(0,Math.min(j.color.g*U.g,1)),U.b=Math.max(0,Math.min(j.color.b* +U.b,1)),Q.r=Math.max(0,Math.min(j.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(j.color.g*Q.g,1)),Q.b=Math.max(0,Math.min(j.color.b*Q.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)),va=Na($,U,Q,ba),v(T,Y,O,l,X,N),Ia(T,Y,O,l,X,N,0,0,1,0,0,1,va),v(W,aa,P,A,ea,Z),Ia(W,aa,P,A,ea,Z,1,0,1,1,0,1,va)):(S.r=fa.r,S.g=fa.g,S.b=fa.b,s(i,m.centroidWorld,m.normalWorld,S),S.r=Math.max(0,Math.min(j.color.r*S.r,1)),S.g=Math.max(0, +Math.min(j.color.g*S.g,1)),S.b=Math.max(0,Math.min(j.color.b*S.b,1)),D(T,Y,O,l,P,A,X,N),j.wireframe?Fa(S,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):H(S)):(D(T,Y,O,l,P,A,X,N),j.wireframe?Fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):H(j.color));else if(j instanceof THREE.MeshNormalMaterial)S.r=M(m.normalWorld.x),S.g=M(m.normalWorld.y),S.b=M(m.normalWorld.z),D(T,Y,O,l,P,A,X,N),j.wireframe?Fa(S,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):H(S); +else if(j instanceof THREE.MeshDepthMaterial)oa=k.near,ta=k.far,$.r=$.g=$.b=1-L(a.positionScreen.z,oa,ta),U.r=U.g=U.b=1-L(d.positionScreen.z,oa,ta),Q.r=Q.g=Q.b=1-L(g.positionScreen.z,oa,ta),ba.r=ba.g=ba.b=1-L(e.positionScreen.z,oa,ta),va=Na($,U,Q,ba),v(T,Y,O,l,X,N),Ia(T,Y,O,l,X,N,0,0,1,0,0,1,va),v(W,aa,P,A,ea,Z),Ia(W,aa,P,A,ea,Z,1,0,1,1,0,1,va)}function v(a,b,c,d,e,f){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(a,b);m.closePath()}function D(a,b,c,d,e,f,g,h){m.beginPath();m.moveTo(a, +b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(g,h);m.lineTo(a,b);m.closePath()}function Fa(a,b,c,e){if(y!=b)m.lineWidth=y=b;if(F!=c)m.lineCap=F=c;if(E!=e)m.lineJoin=E=e;d(a.getContextStyle());m.stroke();qa.inflate(b*2)}function H(a){e(a.getContextStyle());m.fill()}function Qa(a,b,c,d,f,g,h,fa,da,l,i,j,k){if(k.image.width!=0){if(k.needsUpdate==!0||wa[k.id]==void 0){var ma=k.wrapS==THREE.RepeatWrapping,n=k.wrapT==THREE.RepeatWrapping;wa[k.id]=m.createPattern(k.image,ma&&n?"repeat":ma&&!n?"repeat-x":!ma&& +n?"repeat-y":"no-repeat");k.needsUpdate=!1}e(wa[k.id]);var ma=k.offset.x/k.repeat.x,n=k.offset.y/k.repeat.y,ra=k.image.width*k.repeat.x,o=k.image.height*k.repeat.y,h=(h+ma)*ra,fa=(fa+n)*o,da=(da+ma)*ra,l=(l+n)*o,i=(i+ma)*ra,j=(j+n)*o;c-=a;d-=b;f-=a;g-=b;da-=h;l-=fa;i-=h;j-=fa;ma=da*j-i*l;if(ma==0){if(ca[k.id]==void 0)b=document.createElement("canvas"),b.width=k.image.width,b.height=k.image.height,a=b.getContext("2d"),a.drawImage(k.image,0,0),ca[k.id]=a.getImageData(0,0,k.image.width,k.image.height).data, +delete b;b=ca[k.id];h=(Math.floor(h)+Math.floor(fa)*k.image.width)*4;S.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);H(S)}else ma=1/ma,k=(j*c-l*f)*ma,l=(j*d-l*g)*ma,c=(da*f-i*c)*ma,d=(da*g-i*d)*ma,a=a-k*h-c*fa,h=b-l*h-d*fa,m.save(),m.transform(k,l,c,d,a,h),m.fill(),m.restore()}}function Ia(a,b,c,d,e,f,g,h,fa,da,l,i,k){var j,ma;j=k.width-1;ma=k.height-1;g*=j;h*=ma;fa*=j;da*=ma;l*=j;i*=ma;c-=a;d-=b;e-=a;f-=b;fa-=g;da-=h;l-=g;i-=h;ma=1/(fa*i-l*da);j=(i*c-da*e)*ma;da=(i*d-da*f)*ma;c=(fa*e-l*c)*ma;d=(fa*f-l* +d)*ma;a=a-j*g-c*h;b=b-da*g-d*h;m.save();m.transform(j,da,c,d,a,b);m.clip();m.drawImage(k,0,0);m.restore()}function Na(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),fa=~~(c.r*255),da=~~(c.g*255),c=~~(c.b*255),l=~~(d.r*255),i=~~(d.g*255),d=~~(d.b*255);Da[0]=e<0?0:e>255?255:e;Da[1]=f<0?0:f>255?255:f;Da[2]=a<0?0:a>255?255:a;Da[4]=g<0?0:g>255?255:g;Da[5]=h<0?0:h>255?255:h;Da[6]=b<0?0:b>255?255:b;Da[8]=fa<0?0:fa>255?255:fa;Da[9]=da<0?0:da>255?255:da;Da[10]= +c<0?0:c>255?255:c;Da[12]=l<0?0:l>255?255:l;Da[13]=i<0?0:i>255?255:i;Da[14]=d<0?0:d>255?255:d;Ka.putImageData(Pa,0,0);Ma.drawImage(Ja,0,0);return La}function L(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function M(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function K(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 Oa,Ra,ua,Ea;this.autoClear?this.clear():m.setTransform(1,0,0,-1,n,p);f.info.render.vertices=0;f.info.render.faces=0;g=j.projectScene(a,k,this.sortElements); +h=g.elements;i=g.lights;(Ha=i.length>0)&&o(i);Oa=0;for(Ra=h.length;Oa1?1:a}var d=this,e,f,g,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,k,o,s,n,p,m,q,r=new THREE.Rectangle,t=new THREE.Rectangle,x=!1,v=new THREE.Color,D=new THREE.Color,y=new THREE.Color,F=new THREE.Color,E,u=new THREE.Vector3,I=[],w=[],R,V,J,T=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":T=1;break;case "low":T=0}};this.setSize=function(a,b){j=a;k=b;o=j/2;s=k/2;i.setAttribute("viewBox",-o+" "+-s+" "+j+" "+k);i.setAttribute("width",j);i.setAttribute("height",k);r.set(-o,-s,o,s)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(k,j){var l,I,A,u;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(k,j,this.sortElements);f=e.elements; +g=e.lights;J=V=0;if(x=g.length>0){D.setRGB(0,0,0);y.setRGB(0,0,0);F.setRGB(0,0,0);l=0;for(I=g.length;l= 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_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec3 shadowColor = vec3( 1.0 );\nfloat fDepth;\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nshadowCoord.z += shadowBias;\nbvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nif ( all( shadowTest ) ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nconst float shadowDelta = 1.0 / 9.0;\nconst float dx0 = -1.25 * xPixelOffset;\nconst float dy0 = -1.25 * yPixelOffset;\nconst float dx1 = 1.25 * xPixelOffset;\nconst float dy1 = 1.25 * yPixelOffset;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\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( 1.0 - 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,d,e={};for(b=0;b=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 f(a){if(a.map||a.lightMap||a instanceof THREE.ShaderMaterial)return!0; -return!1}function g(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;var i=a.colors,j=i.length,k=a.__vertexArray,m=a.__colorArray,o=a.__sortArray,n=a.__dirtyVertices,q=a.__dirtyColors,p=a.__webglCustomAttributesList;if(c.sortParticles){ya.multiplySelf(c.matrixWorld);for(d=0;d=0;c--)a[c].object===b&&a.splice(c,1)}function o(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function r(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 l};this.supportsVertexTextures=function(){return la};this.setSize=function(a,b){w.width=a;w.height=b;this.setViewport(0, -0,w.width,w.height)};this.setViewport=function(a,b,c,d){na=a;ja=b;sa=c;ra=d;l.viewport(na,ja,sa,ra)};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){Q.setHex(a);X=b;l.clearColor(Q.r,Q.g,Q.b,X)};this.setClearColor=function(a,b){Q.copy(a);X=b;l.clearColor(Q.r,Q.g,Q.b,X)};this.getClearColor=function(){return Q};this.getClearAlpha=function(){return X};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){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)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&&e.vertexNormalBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexNormalBuffer),l.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,l.FLOAT,!1,0,d[f].index* -12)),a.uv>=0&&e.vertexUvBuffer&&(e.vertexUvBuffer?(l.bindBuffer(l.ARRAY_BUFFER,e.vertexUvBuffer),l.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,l.FLOAT,!1,0,d[f].index*8),l.enableVertexAttribArray(a.uv)):l.disableVertexAttribArray(a.uv)),a.color>=0&&e.vertexColorBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexColorBuffer),l.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,l.FLOAT,!1,0,d[f].index*16)),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)),l.drawElements(l.TRIANGLES,d[f].count, -l.UNSIGNED_SHORT,d[f].start*2),R.info.render.calls++,R.info.render.vertices+=d[f].count,R.info.render.faces+=d[f].count/3}};this.renderBuffer=function(a,b,c,d,e,f){if(d.opacity!==0){var g,h,c=r(a,b,c,d,f),b=c.attributes,a=!1,c=e.id*16777215+c.id*2+(d.wireframe?1:0);c!==Y&&(Y=c,a=!0);if(!d.morphTargets&&b.position>=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=o,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!==fa&&(l.lineWidth(d),fa=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!== -fa&&(l.lineWidth(d),fa=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++,R.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(l.drawArrays(l.TRIANGLE_STRIP,0,e.__webglVertexCount),R.info.render.calls++)}};this.render=function(a,b,c,d){var e,f,g,o,m=a.lights,n=a.fog;M=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."), -a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();i(this.renderPluginsPre,a,b);R.info.render.calls=0;R.info.render.vertices=0;R.info.render.faces=0;R.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);ya.multiply(b.projectionMatrix, -b.matrixWorldInverse);xa.setFromMatrix(ya);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);o=a.__webglObjects;d=0;for(e=o.length;d=0)y=q.geometry.materials[y],y.transparent?(p.transparent=y,p.opaque=null):(p.opaque=y,p.transparent=null)}else if(y)y.transparent?(p.transparent=y,p.opaque=null):(p.opaque=y,p.transparent=null);f.render=!0;if(this.sortObjects)g.renderDepth?f.z=g.renderDepth:(za.copy(g.position),ya.multiplyVector3(za),f.z=za.z)}this.sortObjects&&o.sort(h);o=a.__webglObjectsImmediate;d=0;for(e=o.length;d65535&&(v[w].counter+=1,D=v[w].hash+"_"+v[w].counter,C.geometryGroups[D]===void 0&&(C.geometryGroups[D]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:A})),y instanceof THREE.Face3? -C.geometryGroups[D].faces3.push(r):C.geometryGroups[D].faces4.push(r),C.geometryGroups[D].vertices+=t;C.geometryGroupsList=[];r=void 0;for(r in C.geometryGroups)C.geometryGroups[r].id=ca++,C.geometryGroupsList.push(C.geometryGroups[r])}for(k in j.geometryGroups)if(C=j.geometryGroups[k],!C.__webglVertexBuffer){r=C;r.__webglVertexBuffer=l.createBuffer();r.__webglNormalBuffer=l.createBuffer();r.__webglTangentBuffer=l.createBuffer();r.__webglColorBuffer=l.createBuffer();r.__webglUVBuffer=l.createBuffer(); -r.__webglUV2Buffer=l.createBuffer();r.__webglSkinVertexABuffer=l.createBuffer();r.__webglSkinVertexBBuffer=l.createBuffer();r.__webglSkinIndicesBuffer=l.createBuffer();r.__webglSkinWeightsBuffer=l.createBuffer();r.__webglFaceBuffer=l.createBuffer();r.__webglLineBuffer=l.createBuffer();if(r.numMorphTargets){y=s=void 0;r.__webglMorphTargetsBuffers=[];s=0;for(y=r.numMorphTargets;s0||t.faceVertexUvs.length>0)C.__uvArray=new Float32Array(r*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)C.__uv2Array=new Float32Array(r*2)}if(u.geometry.skinWeights.length&&u.geometry.skinIndices.length)C.__skinVertexAArray= -new Float32Array(r*4),C.__skinVertexBArray=new Float32Array(r*4),C.__skinIndexArray=new Float32Array(r*4),C.__skinWeightArray=new Float32Array(r*4);C.__faceArray=new Uint16Array(y*3);C.__lineArray=new Uint16Array(w*2);if(C.numMorphTargets){C.__morphTargetsArrays=[];u=0;for(t=C.numMorphTargets;u0&&(l.bindBuffer(l.ARRAY_BUFFER,s.__webglSkinVertexABuffer),l.bufferData(l.ARRAY_BUFFER,W,y),l.bindBuffer(l.ARRAY_BUFFER,s.__webglSkinVertexBBuffer),l.bufferData(l.ARRAY_BUFFER,V,y),l.bindBuffer(l.ARRAY_BUFFER,s.__webglSkinIndicesBuffer),l.bufferData(l.ARRAY_BUFFER,E,y),l.bindBuffer(l.ARRAY_BUFFER,s.__webglSkinWeightsBuffer),l.bufferData(l.ARRAY_BUFFER,oa,y))}if(za&&w){D=0;for(v=G.length;D0&&(l.bindBuffer(l.ARRAY_BUFFER,s.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER, -U,y))}if(Z&&X.hasTangents){D=0;for(v=G.length;D0&&(l.bindBuffer(l.ARRAY_BUFFER,s.__webglUVBuffer),l.bufferData(l.ARRAY_BUFFER,ga,y))}if(sa&&Ba&&z){D=0;for(v=G.length;D0&&(l.bindBuffer(l.ARRAY_BUFFER,s.__webglUV2Buffer),l.bufferData(l.ARRAY_BUFFER,F,y))}if(ra){D=0;for(v=G.length;D=0&&l.enableVertexAttribArray(n.position);n.color>=0&&l.enableVertexAttribArray(n.color);n.normal>= -0&&l.enableVertexAttribArray(n.normal);n.tangent>=0&&l.enableVertexAttribArray(n.tangent);a.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0&&(l.enableVertexAttribArray(n.skinVertexA),l.enableVertexAttribArray(n.skinVertexB),l.enableVertexAttribArray(n.skinIndex),l.enableVertexAttribArray(n.skinWeight));if(a.attributes)for(f in a.attributes)n[f]!==void 0&&n[f]>=0&&l.enableVertexAttribArray(n[f]);if(a.morphTargets)for(f=a.numSupportedMorphTargets=0;f=0&&(l.enableVertexAttribArray(n[q]),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.setObjectFaces=function(a){if($!==a.doubleSided)a.doubleSided?l.disable(l.CULL_FACE):l.enable(l.CULL_FACE), -$=a.doubleSided;if(ea!==a.flipSided)a.flipSided?l.frontFace(l.CW):l.frontFace(l.CCW),ea=a.flipSided};this.setDepthTest=function(a){L!==a&&(a?l.enable(l.DEPTH_TEST):l.disable(l.DEPTH_TEST),L=a)};this.setBlending=function(a){if(a!==U){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)}U=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=B(l.TEXTURE_2D,a,a.image),d=H(a.format),e=H(a.type);a instanceof THREE.DataTexture?l.texImage2D(l.TEXTURE_2D,0,d,a.image.width, -a.image.height,0,d,e,a.image.data):l.texImage2D(l.TEXTURE_2D,0,d,d,e,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)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=l.createTexture();var c=H(a.format),d=H(a.type); -if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];l.bindTexture(l.TEXTURE_CUBE_MAP,a.__webglTexture);B(l.TEXTURE_CUBE_MAP,a,a);for(var e=0;e<6;e++){a.__webglFramebuffer[e]=l.createFramebuffer();a.__webglRenderbuffer[e]=l.createRenderbuffer();l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,c,a.width,a.height,0,c,d,null);var f=a,g=l.TEXTURE_CUBE_MAP_POSITIVE_X+e;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[e]);l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,g,f.__webglTexture,0); -z(a.__webglRenderbuffer[e],a)}}else a.__webglFramebuffer=l.createFramebuffer(),a.__webglRenderbuffer=l.createRenderbuffer(),l.bindTexture(l.TEXTURE_2D,a.__webglTexture),B(l.TEXTURE_2D,a,a),l.texImage2D(l.TEXTURE_2D,0,c,a.width,a.height,0,c,d,null),c=l.TEXTURE_2D,l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,c,a.__webglTexture,0),z(a.__webglRenderbuffer,a);b?l.bindTexture(l.TEXTURE_CUBE_MAP,null):l.bindTexture(l.TEXTURE_2D,null);l.bindRenderbuffer(l.RENDERBUFFER, -null);l.bindFramebuffer(l.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=sa,a=ra,d=na,e=ja);b!==W&&(l.bindFramebuffer(l.FRAMEBUFFER,b),l.viewport(d,e,c,a),W=b);Ba=c;wa=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; +return!1}function g(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;var i=a.colors,k=i.length,j=a.__vertexArray,m=a.__colorArray,n=a.__sortArray,o=a.__dirtyVertices,s=a.__dirtyColors,p=a.__webglCustomAttributesList;if(c.sortParticles){Ba.multiplySelf(c.matrixWorld);for(d=0;d=0;c--)a[c].object===b&&a.splice(c,1)}function m(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,e){d.program|| +O.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(O.maxMorphTargets);for(var f=0,g=O.maxMorphTargets;f0};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){oa=a;ta=b;va=c;sa=d;l.viewport(oa,ta,va,sa)};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){J.setHex(a);T=b;l.clearColor(J.r,J.g,J.b,T)};this.setClearColor=function(a,b){J.copy(a);T=b;l.clearColor(J.r,J.g,J.b,T)};this.getClearColor=function(){return J};this.getClearAlpha=function(){return T};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){this.setRenderTarget(a);this.clear(b, +c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)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&&e.vertexNormalBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexNormalBuffer),l.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,l.FLOAT,!1,0,d[f].index*12)),a.uv>=0&&e.vertexUvBuffer&&(e.vertexUvBuffer?(l.bindBuffer(l.ARRAY_BUFFER,e.vertexUvBuffer),l.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,l.FLOAT,!1,0,d[f].index*8),l.enableVertexAttribArray(a.uv)):l.disableVertexAttribArray(a.uv)), +a.color>=0&&e.vertexColorBuffer&&(l.bindBuffer(l.ARRAY_BUFFER,e.vertexColorBuffer),l.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,l.FLOAT,!1,0,d[f].index*16)),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)),l.drawElements(l.TRIANGLES,d[f].count,l.UNSIGNED_SHORT,d[f].start*2),O.info.render.calls++,O.info.render.vertices+=d[f].count,O.info.render.faces+=d[f].count/3}};this.renderBuffer=function(a,b,c,d,e,f){if(d.opacity!==0){var g,h,c=q(a,b,c,d,f),b=c.attributes,a=!1,c=e.id*16777215+ +c.id*2+(d.wireframe?1:0);c!==W&&(W=c,a=!0);if(!d.morphTargets&&b.position>=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!==ca&&(l.lineWidth(d),ca=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)),O.info.render.calls++,O.info.render.vertices+=e.__webglFaceCount,O.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?l.LINE_STRIP:l.LINES,d=d.linewidth,d!==ca&&(l.lineWidth(d),ca=d),l.drawArrays(f,0,e.__webglLineCount),O.info.render.calls++):f instanceof THREE.ParticleSystem?(l.drawArrays(l.POINTS,0,e.__webglParticleCount),O.info.render.calls++, +O.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(l.drawArrays(l.TRIANGLE_STRIP,0,e.__webglVertexCount),O.info.render.calls++)}};this.render=function(a,b,c,d){var e,f,g,m,n=a.lights,o=a.fog;N=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();i(this.renderPluginsPre,a,b);O.info.render.calls=0;O.info.render.vertices=0;O.info.render.faces= +0;O.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Ba.multiply(b.projectionMatrix,b.matrixWorldInverse);Aa.setFromMatrix(Ba);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil); +m=a.__webglObjects;d=0;for(e=m.length;d=0)w=s.geometry.materials[w],w.transparent?(p.transparent=w,p.opaque=null):(p.opaque=w,p.transparent=null)}else if(w)w.transparent? +(p.transparent=w,p.opaque=null):(p.opaque=w,p.transparent=null);f.render=!0;if(this.sortObjects)g.renderDepth?f.z=g.renderDepth:(xa.copy(g.position),Ba.multiplyVector3(xa),f.z=xa.z)}this.sortObjects&&m.sort(h);m=a.__webglObjectsImmediate;d=0;for(e=m.length;d65535&&(v[A].counter+=1,C=v[A].hash+"_"+v[A].counter,q.geometryGroups[C]===void 0&&(q.geometryGroups[C]={faces3:[],faces4:[],materialIndex:x,vertices:0,numMorphTargets:R})),t instanceof THREE.Face3?q.geometryGroups[C].faces3.push(r):q.geometryGroups[C].faces4.push(r),q.geometryGroups[C].vertices+=u;q.geometryGroupsList=[];r=void 0;for(r in q.geometryGroups)q.geometryGroups[r].id= +aa++,q.geometryGroupsList.push(q.geometryGroups[r])}for(k in j.geometryGroups)if(q=j.geometryGroups[k],!q.__webglVertexBuffer){r=q;r.__webglVertexBuffer=l.createBuffer();r.__webglNormalBuffer=l.createBuffer();r.__webglTangentBuffer=l.createBuffer();r.__webglColorBuffer=l.createBuffer();r.__webglUVBuffer=l.createBuffer();r.__webglUV2Buffer=l.createBuffer();r.__webglSkinVertexABuffer=l.createBuffer();r.__webglSkinVertexBBuffer=l.createBuffer();r.__webglSkinIndicesBuffer=l.createBuffer();r.__webglSkinWeightsBuffer= +l.createBuffer();r.__webglFaceBuffer=l.createBuffer();r.__webglLineBuffer=l.createBuffer();if(r.numMorphTargets){t=w=void 0;r.__webglMorphTargetsBuffers=[];w=0;for(t=r.numMorphTargets;w0||u.faceVertexUvs.length>0)q.__uvArray=new Float32Array(r*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)q.__uv2Array=new Float32Array(r*2)}if(x.geometry.skinWeights.length&&x.geometry.skinIndices.length)q.__skinVertexAArray=new Float32Array(r*4),q.__skinVertexBArray=new Float32Array(r*4),q.__skinIndexArray=new Float32Array(r*4),q.__skinWeightArray=new Float32Array(r*4);q.__faceArray=new Uint16Array(t*3); +q.__lineArray=new Uint16Array(A*2);if(q.numMorphTargets){q.__morphTargetsArrays=[];x=0;for(u=q.numMorphTargets;x0&&(l.bindBuffer(l.ARRAY_BUFFER,w.__webglSkinVertexABuffer),l.bufferData(l.ARRAY_BUFFER, +U,t),l.bindBuffer(l.ARRAY_BUFFER,w.__webglSkinVertexBBuffer),l.bufferData(l.ARRAY_BUFFER,Z,t),l.bindBuffer(l.ARRAY_BUFFER,w.__webglSkinIndicesBuffer),l.bufferData(l.ARRAY_BUFFER,V,t),l.bindBuffer(l.ARRAY_BUFFER,w.__webglSkinWeightsBuffer),l.bufferData(l.ARRAY_BUFFER,pa,t))}if(va&&A){C=0;for(v=y.length;C0&&(l.bindBuffer(l.ARRAY_BUFFER,w.__webglColorBuffer),l.bufferData(l.ARRAY_BUFFER,T,t))}if(W&&X.hasTangents){C=0;for(v=y.length;C0&&(l.bindBuffer(l.ARRAY_BUFFER,w.__webglUVBuffer),l.bufferData(l.ARRAY_BUFFER,ea,t))}if(sa&&Ba&&E){C=0;for(v=y.length;C0&&(l.bindBuffer(l.ARRAY_BUFFER,w.__webglUV2Buffer),l.bufferData(l.ARRAY_BUFFER,B,t))}if(ta){C=0;for(v=y.length;C0?"#define VERTEX_TEXTURES":"",O.gammaInput?"#define GAMMA_INPUT":"",O.gammaOutput?"#define GAMMA_OUTPUT":"",O.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+ +c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); +g=["precision "+I+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",O.gammaInput?"#define GAMMA_INPUT":"",O.gammaOutput?"#define GAMMA_OUTPUT":"",O.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.wrapAround?"#define WRAP_AROUND":"",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,v("fragment", +g+j));l.attachShader(p,v("vertex",d+k));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 q,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(q in i)d.push(q);q=d;d=0;for(i=q.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[q]),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.setObjectFaces=function(a){if(ea!==a.doubleSided)a.doubleSided?l.disable(l.CULL_FACE):l.enable(l.CULL_FACE), +ea=a.doubleSided;if(Z!==a.flipSided)a.flipSided?l.frontFace(l.CW):l.frontFace(l.CCW),Z=a.flipSided};this.setDepthTest=function(a){$!==a&&(a?l.enable(l.DEPTH_TEST):l.disable(l.DEPTH_TEST),$=a)};this.setBlending=function(a){if(a!==S){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)}S=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=l.createTexture(),O.info.memory.textures++;l.activeTexture(l.TEXTURE0+b);l.bindTexture(l.TEXTURE_2D,a.__webglTexture);var c=D(l.TEXTURE_2D,a,a.image),d=E(a.format),e=E(a.type);a instanceof THREE.DataTexture?l.texImage2D(l.TEXTURE_2D,0,d,a.image.width, +a.image.height,0,d,e,a.image.data):l.texImage2D(l.TEXTURE_2D,0,d,d,e,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)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=l.createTexture();var c=E(a.format),d=E(a.type); +if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];l.bindTexture(l.TEXTURE_CUBE_MAP,a.__webglTexture);D(l.TEXTURE_CUBE_MAP,a,a);for(var e=0;e<6;e++){a.__webglFramebuffer[e]=l.createFramebuffer();a.__webglRenderbuffer[e]=l.createRenderbuffer();l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,c,a.width,a.height,0,c,d,null);var f=a,g=l.TEXTURE_CUBE_MAP_POSITIVE_X+e;l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer[e]);l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,g,f.__webglTexture,0); +y(a.__webglRenderbuffer[e],a)}}else a.__webglFramebuffer=l.createFramebuffer(),a.__webglRenderbuffer=l.createRenderbuffer(),l.bindTexture(l.TEXTURE_2D,a.__webglTexture),D(l.TEXTURE_2D,a,a),l.texImage2D(l.TEXTURE_2D,0,c,a.width,a.height,0,c,d,null),c=l.TEXTURE_2D,l.bindFramebuffer(l.FRAMEBUFFER,a.__webglFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,c,a.__webglTexture,0),y(a.__webglRenderbuffer,a);b?l.bindTexture(l.TEXTURE_CUBE_MAP,null):l.bindTexture(l.TEXTURE_2D,null);l.bindRenderbuffer(l.RENDERBUFFER, +null);l.bindFramebuffer(l.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,e=d=0):(b=null,c=va,a=sa,d=oa,e=ta);b!==X&&(l.bindFramebuffer(l.FRAMEBUFFER,b),l.viewport(d,e,c,a),X=b);ya=c;za=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; 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}; @@ -348,20 +348,20 @@ 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,f=Math.max(Math.max(c,d),e),g=Math.min(Math.min(c,d),e);if(g===f)g=c=0;else{var h=f-g,g=h/f,c=c===f?(d-e)/h:d===f?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=g;b.v=f;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,f=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,h=f.vertices,i=a.faces,j=f.faces,k=a.faceVertexUvs[0],n=f.faceVertexUvs[0],q={},m=0;m1&&(d=1-d,e=1-e);f=1-d-e;g.copy(a);g.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);g.addSelf(h);h.copy(c);h.multiplyScalar(f);g.addSelf(h);return g},randomPointInFace:function(a,b,c){var d,e,f;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,e=b.vertices[a.b].position, f=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,f);else if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;f=b.vertices[a.c].position;var b=b.vertices[a.d].position,g;c?a._area1&&a._area2?(c=a._area1,g=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b),a._area1=c,a._area2=g):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b));return THREE.GeometryUtils.random()*(c+ -g)a?b(c,e-1):j[e]a?b(c,e-1):j[e]0?(g=c[c.length-1],m=g.x,p=g.y):(g=this.actions[d-1].args,m=g[g.length-2],p=g[g.length-1]);for(g=1;g<=a;g++)o=g/a,f=THREE.Shape.Utils.b2(o,m,n,h),o=THREE.Shape.Utils.b2(o,p,q, -i),c.push(new THREE.Vector2(f,o));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];n=f[0];q=f[1];j=f[2];k=f[3];c.length>0?(g=c[c.length-1],m=g.x,p=g.y):(g=this.actions[d-1].args,m=g[g.length-2],p=g[g.length-1]);for(g=1;g<=a;g++)o=g/a,f=THREE.Shape.Utils.b3(o,m,n,j,h),o=THREE.Shape.Utils.b3(o,p,q,k,i),c.push(new THREE.Vector2(f,o));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];o=a*f[0].length;g=g.concat(f[0]);f=new THREE.SplineCurve(g); -for(g=1;g<=o;g++)c.push(f.getPointAt(g/o));break;case THREE.PathActions.ARC:g=this.actions[d-1].args;h=f[0];i=f[1];j=f[2];n=f[3];o=f[4];q=!!f[5];k=g[g.length-2];m=g[g.length-1];g.length==0&&(k=m=0);p=o-n;var r=a*2;for(g=1;g<=r;g++)o=g/r,q||(o=1-o),o=n+o*p,f=k+h+j*Math.cos(o),o=m+i+j*Math.sin(o),c.push(new THREE.Vector2(f,o))}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,f){var g=this.getPoints(),h,i,j,k,n;h=0;for(i=g.length;h0?(g=c[c.length-1],n=g.x,p=g.y):(g=this.actions[d-1].args,n=g[g.length-2],p=g[g.length-1]);for(g=1;g<=a;g++)m=g/a,f=THREE.Shape.Utils.b2(m,n,o,h),m=THREE.Shape.Utils.b2(m,p,s, +i),c.push(new THREE.Vector2(f,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];o=f[0];s=f[1];j=f[2];k=f[3];c.length>0?(g=c[c.length-1],n=g.x,p=g.y):(g=this.actions[d-1].args,n=g[g.length-2],p=g[g.length-1]);for(g=1;g<=a;g++)m=g/a,f=THREE.Shape.Utils.b3(m,n,o,j,h),m=THREE.Shape.Utils.b3(m,p,s,k,i),c.push(new THREE.Vector2(f,m));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];m=a*f[0].length;g=g.concat(f[0]);f=new THREE.SplineCurve(g); +for(g=1;g<=m;g++)c.push(f.getPointAt(g/m));break;case THREE.PathActions.ARC:g=this.actions[d-1].args;h=f[0];i=f[1];j=f[2];o=f[3];m=f[4];s=!!f[5];k=g[g.length-2];n=g[g.length-1];g.length==0&&(k=n=0);p=m-o;var q=a*2;for(g=1;g<=q;g++)m=g/q,s||(m=1-m),m=o+m*p,f=k+h+j*Math.cos(m),m=n+i+j*Math.sin(m),c.push(new THREE.Vector2(f,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,f){var g=this.getPoints(),h,i,j,k,o;h=0;for(i=g.length;h=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;var o=[j[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(o);var r=[j[g],j[f],c[h]];q=THREE.FontUtils.Triangulate.area(r);m=h;k=g;h+=1;g+=-1;h< -0&&(h+=c.length);h%=c.length;g<0&&(g+=j.length);g%=j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;o=[j[g],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(o);r=[j[g],j[f],c[h]];r=THREE.FontUtils.Triangulate.area(r);n+q>o+r&&(h=m,g=k,h<0&&(h+=c.length),h%=c.length,g<0&&(g+=j.length),g%=j.length,e=h-1>=0?h-1:c.length-1,f=g-1>=0?g-1:j.length-1);n=c.slice(0,h);q=c.slice(h);m=j.slice(g);k=j.slice(0,g);f=[j[g],j[f],c[h]];p.push([j[g],c[h],c[e]]);p.push(f);c=n.concat(m).concat(k).concat(q)}return{shape:c, +THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,f,g,h,i,j,k,o,s,n,p=[];for(i=0;i=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;var m=[j[g],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(m);var q=[j[g],j[f],c[h]];s=THREE.FontUtils.Triangulate.area(q);n=h;k=g;h+=1;g+=-1;h< +0&&(h+=c.length);h%=c.length;g<0&&(g+=j.length);g%=j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;m=[j[g],c[h],c[e]];m=THREE.FontUtils.Triangulate.area(m);q=[j[g],j[f],c[h]];q=THREE.FontUtils.Triangulate.area(q);o+s>m+q&&(h=n,g=k,h<0&&(h+=c.length),h%=c.length,g<0&&(g+=j.length),g%=j.length,e=h-1>=0?h-1:c.length-1,f=g-1>=0?g-1:j.length-1);o=c.slice(0,h);s=c.slice(h);n=j.slice(g);k=j.slice(0,g);f=[j[g],j[f],c[h]];p.push([j[g],c[h],c[e]]);p.push(f);c=o.concat(n).concat(k).concat(s)}return{shape:c, isolatedPts:p,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),f,g,h,i,j={};f=0;for(g=d.length;f1)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]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[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,g.index-1).pos,this.points[1]=e,this.points[2]=f,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,f,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d}}if(this.JITCompile&&k[0][j]===void 0){this.hierarchy[0].updateMatrixWorld(!0);for(m=0;m1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",n,g.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",n,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,f,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d}}if(this.JITCompile&&k[0][j]===void 0){this.hierarchy[0].updateMatrixWorld(!0);for(n=0;na.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];j=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],j[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],j[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],j[2],e,c,g);return d}; THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+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]}; @@ -446,8 +446,8 @@ THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.is e.matrix;e=this.data.hierarchy[c].keys;if(e.length)f.animationCache.prevKey=e[0],f.animationCache.nextKey=e[1],this.startTime=Math.min(e[0].time,this.startTime),this.endTime=Math.max(e[e.length-1].time,this.endTime)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused}; THREE.KeyFrameAnimation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a=0?c:c+b.length;c>=0;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]}; THREE.CubeCamera=function(a,b,c,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= @@ -468,14 +468,14 @@ 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:[]},f,g=b.getControlPointsArray(),h=b.getLength(),r=g.length,s=0;f=r-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f=0?a:a+g;b=this.verticalAngleMap.srcRange; a=this.verticalAngleMap.dstRange;b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove= function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}), c=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(g,b);a.position.set(0,10,0);this.animation=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,b=this.spline,g=f(b,10),c=f(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),g=new THREE.Line(g,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));g.scale.set(1,1,1);a.add(g);c.scale.set(1,1,1);a.add(c);for(var g=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),m=0;m0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*j);this.object.translateY(b*k);g&&(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);g&&(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);g.copy(c.object.position).subSelf(c.target);e=c.object.up.clone().setLength(d.y);e.addSelf(c.object.up.clone().crossSelf(g).setLength(d.x));e.addSelf(g.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(g);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&&(g.multiplyScalar(a),c.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=q.clone().subSelf(n);if(a.lengthSq()){a.multiplyScalar(g.length()*c.panSpeed);var b=g.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?n=q:n.addSelf(a.sub(q,n).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),g.lengthSq()0&&(g.multiplyScalar(a),c.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=s.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(g.length()*c.panSpeed);var b=g.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=s:o.addSelf(a.sub(s,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),g.lengthSq()0?1:-1;for(h=0;h0?1:-1;for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,g,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-g,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,g,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-g,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(y=a.length;--y>=0;){Y=y;ca=y-1;ca<0&&(ca=a.length-1);for(var b= -0,c=m+k*2,b=0;b=0;Z--){Q=Z/k;X=i*(1-Q);Q=j*Math.sin(Q*Math.PI/2);y=0;for(K=u.length;y< -K;y++)T=c(u[y],S[y],Q),f(T.x,T.y,h+X);E=0;for(H=q.length;Ea&&(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;){W=w;aa=w-1;aa<0&&(aa=a.length-1);for(var b= +0,c=n+k*2,b=0;b=0;V--){J=V/k;T=i*(1-J);J=j*Math.sin(J*Math.PI/2);w=0;for(R=t.length;w< +R;w++)Y=c(t[w],P[w],J),f(Y.x,Y.y,h+T);F=0;for(E=s.length;F0)for(j=0;j2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return f}i=j;e<=i&&(i=0);j=i+1;e<=j&&(j=0);k=j+1;e<=k&&(k=0);var q;a:{q=a;var m=i,p=j,o=k,r=e,s=g,u=void 0,t=void 0,A=void 0, -B=void 0,z=void 0,E=void 0,H=void 0,w=void 0,G=void 0,t=q[s[m]].x,A=q[s[m]].y,B=q[s[p]].x,z=q[s[p]].y,E=q[s[o]].x,H=q[s[o]].y;if(1.0E-10>(B-t)*(H-A)-(z-A)*(E-t))q=!1;else{for(u=0;u=0&&Z>=0&&X>=0){q=!1;break a}}q=!0}}if(q){f.push([a[g[i]], -a[g[j]],a[g[k]]]);h.push([g[i],g[j],g[k]]);i=j;for(k=j+1;k0)for(j=0;j2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return f}i=j;e<=i&&(i=0);j=i+1;e<=j&&(j=0);k=j+1;e<=k&&(k=0);var s;a:{s=a;var n=i,p=j,m=k,q=e,r=g,t=void 0,x=void 0,v=void 0, +D=void 0,y=void 0,F=void 0,E=void 0,u=void 0,I=void 0,x=s[r[n]].x,v=s[r[n]].y,D=s[r[p]].x,y=s[r[p]].y,F=s[r[m]].x,E=s[r[m]].y;if(1.0E-10>(D-x)*(E-v)-(y-v)*(F-x))s=!1;else{for(t=0;t=0&&V>=0&&T>=0){s=!1;break a}}s=!0}}if(s){f.push([a[g[i]], +a[g[j]],a[g[k]]]);h.push([g[i],g[j],g[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 j=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(g.useOldVertexColors){j.vertexColors=[];for(var k,o,m,n=0;n<4;n++){m=i[n];k=new THREE.Color;k.setRGB(0,0,0);for(var p=0;p=0){n=k.invBindMatrices[o];l.invBindMatrix=n;l.skinningMatrix=new THREE.Matrix4;l.skinningMatrix.multiply(l.world,n);l.weights=[];for(n=0;n1){j=new THREE.MeshFaceMaterial;i.materials= -l;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";b.matrix=a.matrix;c=a.matrix.decompose();b.position=c[0];b.quaternion=c[1];b.useQuaternion=!0;b.scale=c[2];la.centerGeometry&&b.geometry&&(c=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(c.multiplySelf(b.scale)), -b.position.subSelf(c));for(g=0;g=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;dp)break}if(!s){s=new l(p);t=-1;u=0;for(v=d.length;u=p&&(t=u);p=t;d.splice(p==-1?d.length:p,0,s)}s.addTarget(f,j,g,r)}}else console.log('Could not find transform "'+ -b.sid+'" in node '+this.id)}for(c=0;c=0?i:i+h.length;i>=0;i--)if(k=h[i],k.hasTarget(g)){i=k;break a}i=null}k=void 0;a:{for(j+=1;j4&&la.subdivideFaces){r=r.length?r:new THREE.Color; -for(e=1;e4?[r[0],r[n+1],r[n+2]]:m===4?[r[0],r[1],r[2],r[3]]:[r[0],r[1],r[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(r)}}else console.log("dropped face with vcount "+m+" for geometry with id: "+b.id);c+=g.length*m}};u.prototype=new t;u.prototype.constructor=u;t.prototype.setVertices= -function(a){for(var 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 w)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=va[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(xa+ -e.init_from),e.wrapS=d.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.wrapT=d.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.offset.x=d.texOpts.offsetU,e.offset.y=d.texOpts.offsetV,e.repeat.x=d.texOpts.repeatU,e.repeat.y=d.texOpts.repeatV,a.map=e}}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)};y.prototype.parse=function(a){for(var b=0;b=0,d=a.indexOf("(")>=0;if(c)b=a.split("."),this.sid=b.shift(),this.member=b.shift();else if(d){b=a.split("(");this.sid=b.shift();for(var e=0;e1){c=[];b*=this.strideOut;for(var d=0;d1)console.log("Key.interpolate: Warning! Scale out of bounds:"+f),f=f<0?0:1;if(h.length)for(var e=[],i=0;i=0){o=k.invBindMatrices[n];l.invBindMatrix=o;l.skinningMatrix=new THREE.Matrix4;l.skinningMatrix.multiply(l.world,o);l.weights=[];for(o=0;o1){j=new THREE.MeshFaceMaterial;i.materials= +l;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";b.matrix=a.matrix;c=a.matrix.decompose();b.position=c[0];b.quaternion=c[1];b.useQuaternion=!0;b.scale=c[2];ha.centerGeometry&&b.geometry&&(c=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(c.multiplySelf(b.scale)), +b.position.subSelf(c));for(g=0;g=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;dp)break}if(!r){r=new l(p);t=-1;u=0;for(v=d.length;u=p&&(t=u);p=t;d.splice(p==-1?d.length:p,0,r)}r.addTarget(f,j,g,q)}}else console.log('Could not find transform "'+b.sid+'" in node '+ +this.id)}for(c=0;c=0?i:i+h.length;i>=0;i--)if(k=h[i],k.hasTarget(g)){i=k;break a}i=null}k=void 0;a:{for(j+=1;j4&&ha.subdivideFaces){r=r.length?r:new THREE.Color;for(e=1;e4?[r[0],r[o+1],r[o+2]]:m===4?[r[0],r[1],r[2],r[3]]:[r[0],r[1],r[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(r)}}else console.log("dropped face with vcount "+m+" for geometry with id: "+b.id);c+=g.length*m}};t.prototype=new x;t.prototype.constructor=t;x.prototype.setVertices=function(a){for(var b=0;b0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create(); +return this};I.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 u)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=wa[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(Aa+e.init_from),e.wrapS=d.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping, +e.wrapT=d.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.offset.x=d.texOpts.offsetU,e.offset.y=d.texOpts.offsetV,e.repeat.x=d.texOpts.repeatU,e.repeat.y=d.texOpts.repeatV,a.map=e}}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=Ca;return this.material=new THREE.MeshLambertMaterial(a)};w.prototype.parse=function(a){for(var b= +0;b=0,d=a.indexOf("(")>=0;if(c)b=a.split("."),this.sid=b.shift(),this.member=b.shift();else if(d){b=a.split("(");this.sid=b.shift();for(var e=0;e1){c=[];b*=this.strideOut;for(var d=0;d1)console.log("Key.interpolate: Warning! Scale out of bounds:"+f),f=f<0?0:1;if(h.length)for(var e=[],i=0;i1&&(Z=new THREE.MeshFaceMaterial); -a=new THREE.Mesh(G,Z);a.name=q;a.position.set(A[0],A[1],A[2]);z?(a.quaternion.set(z[0],z[1],z[2],z[3]),a.useQuaternion=!0):a.rotation.set(B[0],B[1],B[2]);a.scale.set(E[0],E[1],E[2]);a.visible=s.visible;v.scene.add(a);v.objects[q]=a;if(s.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);v.scene.collisions.colliders.push(b)}if(s.castsShadow)b=new THREE.ShadowVolume(G),v.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;s.trigger&&s.trigger.toLowerCase()!="none"&&(b= -{type:s.trigger,object:s},v.triggers[a.name]=b)}}else A=s.position,B=s.rotation,z=s.quaternion,E=s.scale,z=0,a=new THREE.Object3D,a.name=q,a.position.set(A[0],A[1],A[2]),z?(a.quaternion.set(z[0],z[1],z[2],z[3]),a.useQuaternion=!0):a.rotation.set(B[0],B[1],B[2]),a.scale.set(E[0],E[1],E[2]),a.visible=s.visible!==void 0?s.visible:!1,v.scene.add(a),v.objects[q]=a,v.empties[q]=a,s.trigger&&s.trigger.toLowerCase()!="none"&&(b={type:s.trigger,object:s},v.triggers[a.name]=b)}function f(a){return function(b){v.geometries[a]= -b;e();T-=1;i.onLoadComplete();h()}}function g(a){return function(b){v.geometries[a]=b}}function h(){i.callbackProgress({totalModels:l,totalTextures:S,loadedModels:l-T,loadedTextures:S-R},v);i.onLoadProgress();T==0&&R==0&&b(v)}var i=this,j=THREE.Loader.prototype.extractUrlbase(c),k,n,q,m,p,o,r,s,u,t,A,B,z,E,H,w,G,y,K,Z,Q,X,T,R,l,S,v;Q=a;c=new THREE.BinaryLoader;X=new THREE.JSONLoader;R=T=0;v={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, -empties:{}};a=!1;for(q in Q.objects)if(s=Q.objects[q],s.meshCollider){a=!0;break}if(a)v.scene.collisions=new THREE.CollisionSystem;if(Q.transform)a=Q.transform.position,u=Q.transform.rotation,H=Q.transform.scale,a&&v.scene.position.set(a[0],a[1],a[2]),u&&v.scene.rotation.set(u[0],u[1],u[2]),H&&v.scene.scale.set(H[0],H[1],H[2]),(a||u||H)&&v.scene.updateMatrix();a=function(){R-=1;h();i.onLoadComplete()};for(p in Q.cameras)H=Q.cameras[p],H.type=="perspective"?y=new THREE.PerspectiveCamera(H.fov,H.aspect, -H.near,H.far):H.type=="ortho"&&(y=new THREE.OrthographicCamera(H.left,H.right,H.top,H.bottom,H.near,H.far)),A=H.position,u=H.target,H=H.up,y.position.set(A[0],A[1],A[2]),y.target=new THREE.Vector3(u[0],u[1],u[2]),H&&y.up.set(H[0],H[1],H[2]),v.cameras[p]=y;for(m in Q.lights)u=Q.lights[m],p=u.color!==void 0?u.color:16777215,y=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(A=u.direction,t=new THREE.DirectionalLight(p,y),t.position.set(A[0],A[1],A[2]),t.position.normalize()):u.type=="point"? -(A=u.position,t=u.distance,t=new THREE.PointLight(p,y,t),t.position.set(A[0],A[1],A[2])):u.type=="ambient"&&(t=new THREE.AmbientLight(p)),v.scene.add(t),v.lights[m]=t;for(o in Q.fogs)m=Q.fogs[o],m.type=="linear"?K=new THREE.Fog(0,m.near,m.far):m.type=="exp2"&&(K=new THREE.FogExp2(0,m.density)),H=m.color,K.color.setRGB(H[0],H[1],H[2]),v.fogs[o]=K;if(v.cameras&&Q.defaults.camera)v.currentCamera=v.cameras[Q.defaults.camera];if(v.fogs&&Q.defaults.fog)v.scene.fog=v.fogs[Q.defaults.fog];H=Q.defaults.bgcolor; -v.bgColor=new THREE.Color;v.bgColor.setRGB(H[0],H[1],H[2]);v.bgColorAlpha=Q.defaults.bgalpha;for(k in Q.geometries)if(o=Q.geometries[k],o.type=="bin_mesh"||o.type=="ascii_mesh")T+=1,i.onLoadStart();l=T;for(k in Q.geometries)o=Q.geometries[k],o.type=="cube"?(G=new THREE.CubeGeometry(o.width,o.height,o.depth,o.segmentsWidth,o.segmentsHeight,o.segmentsDepth,null,o.flipped,o.sides),v.geometries[k]=G):o.type=="plane"?(G=new THREE.PlaneGeometry(o.width,o.height,o.segmentsWidth,o.segmentsHeight),v.geometries[k]= -G):o.type=="sphere"?(G=new THREE.SphereGeometry(o.radius,o.segmentsWidth,o.segmentsHeight),v.geometries[k]=G):o.type=="cylinder"?(G=new THREE.CylinderGeometry(o.topRad,o.botRad,o.height,o.radSegs,o.heightSegs),v.geometries[k]=G):o.type=="torus"?(G=new THREE.TorusGeometry(o.radius,o.tube,o.segmentsR,o.segmentsT),v.geometries[k]=G):o.type=="icosahedron"?(G=new THREE.IcosahedronGeometry(o.subdivisions),v.geometries[k]=G):o.type=="bin_mesh"?c.load(d(o.url,Q.urlBaseType),f(k)):o.type=="ascii_mesh"?X.load(d(o.url, -Q.urlBaseType),f(k)):o.type=="embedded_mesh"&&(o=Q.embeds[o.id])&&X.createModel(o,g(k),"");for(r in Q.textures)if(k=Q.textures[r],k.url instanceof Array){R+=k.url.length;for(o=0;o1&&(V=new THREE.MeshFaceMaterial); +a=new THREE.Mesh(I,V);a.name=s;a.position.set(v[0],v[1],v[2]);y?(a.quaternion.set(y[0],y[1],y[2],y[3]),a.useQuaternion=!0):a.rotation.set(D[0],D[1],D[2]);a.scale.set(F[0],F[1],F[2]);a.visible=r.visible;A.scene.add(a);A.objects[s]=a;if(r.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);A.scene.collisions.colliders.push(b)}if(r.castsShadow)b=new THREE.ShadowVolume(I),A.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;r.trigger&&r.trigger.toLowerCase()!="none"&&(b= +{type:r.trigger,object:r},A.triggers[a.name]=b)}}else v=r.position,D=r.rotation,y=r.quaternion,F=r.scale,y=0,a=new THREE.Object3D,a.name=s,a.position.set(v[0],v[1],v[2]),y?(a.quaternion.set(y[0],y[1],y[2],y[3]),a.useQuaternion=!0):a.rotation.set(D[0],D[1],D[2]),a.scale.set(F[0],F[1],F[2]),a.visible=r.visible!==void 0?r.visible:!1,A.scene.add(a),A.objects[s]=a,A.empties[s]=a,r.trigger&&r.trigger.toLowerCase()!="none"&&(b={type:r.trigger,object:r},A.triggers[a.name]=b)}function f(a){return function(b){A.geometries[a]= +b;e();Y-=1;i.onLoadComplete();h()}}function g(a){return function(b){A.geometries[a]=b}}function h(){i.callbackProgress({totalModels:l,totalTextures:P,loadedModels:l-Y,loadedTextures:P-O},A);i.onLoadProgress();Y==0&&O==0&&b(A)}var i=this,j=THREE.Loader.prototype.extractUrlbase(c),k,o,s,n,p,m,q,r,t,x,v,D,y,F,E,u,I,w,R,V,J,T,Y,O,l,P,A;J=a;c=new THREE.BinaryLoader;T=new THREE.JSONLoader;O=Y=0;A={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, +empties:{}};a=!1;for(s in J.objects)if(r=J.objects[s],r.meshCollider){a=!0;break}if(a)A.scene.collisions=new THREE.CollisionSystem;if(J.transform)a=J.transform.position,t=J.transform.rotation,E=J.transform.scale,a&&A.scene.position.set(a[0],a[1],a[2]),t&&A.scene.rotation.set(t[0],t[1],t[2]),E&&A.scene.scale.set(E[0],E[1],E[2]),(a||t||E)&&A.scene.updateMatrix();a=function(){O-=1;h();i.onLoadComplete()};for(p in J.cameras)E=J.cameras[p],E.type=="perspective"?w=new THREE.PerspectiveCamera(E.fov,E.aspect, +E.near,E.far):E.type=="ortho"&&(w=new THREE.OrthographicCamera(E.left,E.right,E.top,E.bottom,E.near,E.far)),v=E.position,t=E.target,E=E.up,w.position.set(v[0],v[1],v[2]),w.target=new THREE.Vector3(t[0],t[1],t[2]),E&&w.up.set(E[0],E[1],E[2]),A.cameras[p]=w;for(n in J.lights)t=J.lights[n],p=t.color!==void 0?t.color:16777215,w=t.intensity!==void 0?t.intensity:1,t.type=="directional"?(v=t.direction,x=new THREE.DirectionalLight(p,w),x.position.set(v[0],v[1],v[2]),x.position.normalize()):t.type=="point"? +(v=t.position,x=t.distance,x=new THREE.PointLight(p,w,x),x.position.set(v[0],v[1],v[2])):t.type=="ambient"&&(x=new THREE.AmbientLight(p)),A.scene.add(x),A.lights[n]=x;for(m in J.fogs)n=J.fogs[m],n.type=="linear"?R=new THREE.Fog(0,n.near,n.far):n.type=="exp2"&&(R=new THREE.FogExp2(0,n.density)),E=n.color,R.color.setRGB(E[0],E[1],E[2]),A.fogs[m]=R;if(A.cameras&&J.defaults.camera)A.currentCamera=A.cameras[J.defaults.camera];if(A.fogs&&J.defaults.fog)A.scene.fog=A.fogs[J.defaults.fog];E=J.defaults.bgcolor; +A.bgColor=new THREE.Color;A.bgColor.setRGB(E[0],E[1],E[2]);A.bgColorAlpha=J.defaults.bgalpha;for(k in J.geometries)if(m=J.geometries[k],m.type=="bin_mesh"||m.type=="ascii_mesh")Y+=1,i.onLoadStart();l=Y;for(k in J.geometries)m=J.geometries[k],m.type=="cube"?(I=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),A.geometries[k]=I):m.type=="plane"?(I=new THREE.PlaneGeometry(m.width,m.height,m.segmentsWidth,m.segmentsHeight),A.geometries[k]= +I):m.type=="sphere"?(I=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),A.geometries[k]=I):m.type=="cylinder"?(I=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),A.geometries[k]=I):m.type=="torus"?(I=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),A.geometries[k]=I):m.type=="icosahedron"?(I=new THREE.IcosahedronGeometry(m.subdivisions),A.geometries[k]=I):m.type=="bin_mesh"?c.load(d(m.url,J.urlBaseType),f(k)):m.type=="ascii_mesh"?T.load(d(m.url, +J.urlBaseType),f(k)):m.type=="embedded_mesh"&&(m=J.embeds[m.id])&&T.createModel(m,g(k),"");for(q in J.textures)if(k=J.textures[q],k.url instanceof Array){O+=k.url.length;for(m=0;m=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;e<8;e++){for(var f=0,g=0;g>1^-(h&1);c[8*g+e]=f}d+=b}b=a.length-d;f=new Uint16Array(b);for(e=g=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 q=Math.floor(j-h);q<1&&(q=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 p,o,r,s,u,t;n0&&(this.field[r+p]+=s)}}};this.addPlaneX=function(a,b){var e,f,g,h,i,j=this.size,k=this.yd,n=this.zd,q=this.field,m=j*Math.sqrt(a/b);m>j&&(m=j);for(e=0;e0)for(f=0;fk&&(p=k);for(f=0;f0){i=f*n;for(e=0;ek&&(p=k);for(g=0;g0){i=q*g;for(f=0;fthis.size-1&&(i=this.size-1);var s=Math.floor(j-h);s<1&&(s=1);j=Math.floor(j+h);j>this.size-1&&(j=this.size-1);var n=Math.floor(k-h);n<1&&(n=1);h=Math.floor(k+h);h>this.size-1&&(h=this.size- +1);for(var p,m,q,r,t,x;o0&&(this.field[q+p]+=r)}}};this.addPlaneX=function(a,b){var e,f,g,h,i,j=this.size,k=this.yd,o=this.zd,s=this.field,n=j*Math.sqrt(a/b);n>j&&(n=j);for(e=0;e0)for(f=0;fk&&(p=k);for(f=0;f0){i=f*o;for(e=0;ek&&(p=k);for(g=0;g0){i=s*g;for(f=0;f0&&r.x0&&r.y0.0010&&z.scale>0.0010)o.x=z.x,o.y=z.y,o.z=z.z,m=z.size*z.scale/ -h,p.x=m*k,p.y=m,b.uniform3f(s.screenPosition,o.x,o.y,o.z),b.uniform2f(s.scale,p.x,p.y),b.uniform1f(s.rotation,z.rotation),b.uniform1f(s.opacity,z.opacity),b.uniform3f(s.color,z.color.r,z.color.g,z.color.b),c.setBlending(z.blending),c.setTexture(z.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}}; +"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,f,g,h){var a=a.__webglFlares,i=a.length;if(i){var j=new THREE.Vector3,k=h/g,o=g*0.5,s=h*0.5,n=16/h,p=new THREE.Vector2(n*k,n),m=new THREE.Vector3(1,1,0),q=new THREE.Vector2(1,1),r=d.uniforms,n=d.attributes;b.useProgram(d.program);if(!d.attributesEnabled)b.enableVertexAttribArray(d.attributes.vertex), +b.enableVertexAttribArray(d.attributes.uv),d.attributesEnabled=!0;b.uniform1i(r.occlusionMap,0);b.uniform1i(r.map,1);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(n.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(n.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.disable(b.CULL_FACE);b.depthMask(!1);var t,x,v,D,y;for(t=0;t0&&q.x0&&q.y0.0010&&y.scale>0.0010)m.x=y.x,m.y=y.y,m.z=y.z,n=y.size*y.scale/ +h,p.x=n*k,p.y=n,b.uniform3f(r.screenPosition,m.x,m.y,m.z),b.uniform2f(r.scale,p.x,p.y),b.uniform1f(r.rotation,y.rotation),b.uniform1f(r.opacity,y.opacity),b.uniform3f(r.color,y.color.r,y.color.g,y.color.b),c.setBlending(y.blending),c.setTexture(y.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.ShadowMapPlugin=function(){var a,b,c,d,e,f=new THREE.Frustum,g=new THREE.Matrix4;this.shadowMatrix=[];this.shadowMap=[];this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render= -function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(h){var i,j,k,n,q,m,p,o,r=0,s=h.lights;e||(e=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));i=0;for(j=s.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],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):k[e]a?b(c,e-1):k[e]0?(f=c[c.length-1],m=f.x,l=f.y):(f=this.actions[d-1].args,m=f[f.length-2],l=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b2(n,m,q,h),n=THREE.Shape.Utils.b2(n,l,p, -i),c.push(new THREE.Vector2(g,n));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];q=g[0];p=g[1];k=g[2];j=g[3];c.length>0?(f=c[c.length-1],m=f.x,l=f.y):(f=this.actions[d-1].args,m=f[f.length-2],l=f[f.length-1]);for(f=1;f<=a;f++)n=f/a,g=THREE.Shape.Utils.b3(n,m,q,k,h),n=THREE.Shape.Utils.b3(n,l,p,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];p=!!g[5];j=f[f.length-2];m=f[f.length-1];f.length==0&&(j=m=0);l=n-q;var r=a*2;for(f=1;f<=r;f++)n=f/r,p||(n=1-n),n=q+n*l,g=j+h+k*Math.cos(n),n=m+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.getPoints=function(a,b){var a=a||12,c=[],d,e,g,f,h,i,k,j,q,n,m,l,o;d=0;for(e=this.actions.length;d0?(f=c[c.length-1],m=f.x,l=f.y):(f=this.actions[d-1].args,m=f[f.length-2],l=f[f.length-1]);for(f=1;f<=a;f++)o=f/a,g=THREE.Shape.Utils.b2(o,m,q,h),o=THREE.Shape.Utils.b2(o,l,n, +i),c.push(new THREE.Vector2(g,o));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];q=g[0];n=g[1];k=g[2];j=g[3];c.length>0?(f=c[c.length-1],m=f.x,l=f.y):(f=this.actions[d-1].args,m=f[f.length-2],l=f[f.length-1]);for(f=1;f<=a;f++)o=f/a,g=THREE.Shape.Utils.b3(o,m,q,k,h),o=THREE.Shape.Utils.b3(o,l,n,j,i),c.push(new THREE.Vector2(g,o));break;case THREE.PathActions.CSPLINE_THRU:f=this.actions[d-1].args;f=[new THREE.Vector2(f[f.length-2],f[f.length-1])];o=a*g[0].length;f=f.concat(g[0]);g=new THREE.SplineCurve(f); +for(f=1;f<=o;f++)c.push(g.getPointAt(f/o));break;case THREE.PathActions.ARC:f=this.actions[d-1].args;h=g[0];i=g[1];k=g[2];q=g[3];o=g[4];n=!!g[5];j=f[f.length-2];m=f[f.length-1];f.length==0&&(j=m=0);l=o-q;var r=a*2;for(f=1;f<=r;f++)o=f/r,n||(o=1-o),o=q+o*l,g=j+h+k*Math.cos(o),o=m+i+k*Math.sin(o),c.push(new THREE.Vector2(g,o))}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;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 r=[k[f],k[g],c[h]];p=THREE.FontUtils.Triangulate.area(r);m=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);r=[k[f],k[g],c[h]];r=THREE.FontUtils.Triangulate.area(r);q+p>n+r&&(h=m,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);p=c.slice(h);m=k.slice(f);j=k.slice(0,f);g=[k[f],k[g],c[h]];l.push([k[f],c[h],c[e]]);l.push(g);c=q.concat(m).concat(j).concat(p)}return{shape:c, +THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,g,f,h,i,k,j,q,n,m,l=[];for(i=0;i=0?h-1:c.length-1;g=f-1>=0?f-1:k.length-1;var o=[k[f],c[h],c[e]];q=THREE.FontUtils.Triangulate.area(o);var r=[k[f],k[g],c[h]];n=THREE.FontUtils.Triangulate.area(r);m=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;o=[k[f],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(o);r=[k[f],k[g],c[h]];r=THREE.FontUtils.Triangulate.area(r);q+n>o+r&&(h=m,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);n=c.slice(h);m=k.slice(f);j=k.slice(0,f);g=[k[f],k[g],c[h]];l.push([k[f],c[h],c[e]]);l.push(g);c=q.concat(m).concat(j).concat(n)}return{shape:c, isolatedPts:l,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 "+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&&j[0][k]===void 0){this.hierarchy[0].updateMatrixWorld(!0);for(m=0;m=0?c:c+b.length;c>=0;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]}; THREE.CubeCamera=function(a,b,c,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= @@ -121,7 +121,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(),r=f.length,o=0;g=r-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; @@ -139,38 +139,38 @@ 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,k=0,j=0,q=0,p=0,m=window.innerWidth/2,l=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var b=a*this.lookSpeed; -this.rotateHorizontally(b*q);this.rotateVertically(b*p)}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=p.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=p:q.addSelf(a.sub(p,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=n.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=n:q.addSelf(a.sub(n,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?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(f).addSelf(h).subSelf(a).clone()}function e(a){for(v=a.length;--v>=0;){L=v;I=v-1;I<0&&(I=a.length-1);for(var b= -0,c=m+j*2,b=0;b=0;F--){C=F/j;K=i*(1-C);C=k*Math.sin(C*Math.PI/2);v=0;for(E=s.length;v=0;F--){C=F/j;K=i*(1-C);C=k*Math.sin(C*Math.PI/2);v=0;for(E=s.length;v0)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 p;a:{p=a;var m=i,l=k,n=j,r=e,o=f,s=void 0,t=void 0,w=void 0, -z=void 0,u=void 0,y=void 0,x=void 0,A=void 0,D=void 0,t=p[o[m]].x,w=p[o[m]].y,z=p[o[l]].x,u=p[o[l]].y,y=p[o[n]].x,x=p[o[n]].y;if(1.0E-10>(z-t)*(x-w)-(u-w)*(y-t))p=!1;else{for(s=0;s=0&&F>=0&&K>=0){p=!1;break a}}p=!0}}if(p){g.push([a[f[i]], +0,e=String(a).split(""),g=e.length,f=[],a=0;a0)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 n;a:{n=a;var m=i,l=k,o=j,r=e,p=f,s=void 0,t=void 0,w=void 0, +z=void 0,u=void 0,y=void 0,x=void 0,A=void 0,D=void 0,t=n[p[m]].x,w=n[p[m]].y,z=n[p[l]].x,u=n[p[l]].y,y=n[p[o]].x,x=n[p[o]].y;if(1.0E-10>(z-t)*(x-w)-(u-w)*(y-t))n=!1;else{for(s=0;s=0&&F>=0&&K>=0){n=!1;break a}}n=!0}}if(n){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,n,l,m=0;m<4;m++){l=i[m];k=new THREE.Color;k.setRGB(0,0,0);for(var o=0;o=0){o=k.invBindMatrices[l];m.invBindMatrix=o;m.skinningMatrix=new THREE.Matrix4;m.skinningMatrix.multiply(m.world,o);m.weights=[];for(o=0;o1){j=new THREE.MeshFaceMaterial;i.materials=l;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";b.matrix=a.matrix;c=a.matrix.decompose();b.position=c[0];b.quaternion=c[1];b.useQuaternion=!0;b.scale=c[2];Q.centerGeometry&&b.geometry&&(c=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(c.multiplySelf(b.scale)), +else{var g,c=1E6,f=-c,h=0;for(g in W)for(var i=W[g],j=0;j=0){n=k.invBindMatrices[l];m.invBindMatrix=n;m.skinningMatrix=new THREE.Matrix4;m.skinningMatrix.multiply(m.world,n);m.weights=[];for(n=0;n1){j=new THREE.MeshFaceMaterial;i.materials=l;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";b.matrix=a.matrix;c=a.matrix.decompose();b.position=c[0];b.quaternion=c[1];b.useQuaternion=!0;b.scale=c[2];Q.centerGeometry&&b.geometry&&(c=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(c.multiplySelf(b.scale)), b.position.subSelf(c));for(f=0;f=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;dl)break}if(!r){r=new O(l);s=-1;t=0;for(u=d.length;t=l&&(s=t);l=s;d.splice(l==-1?d.length:l,0,r)}r.addTarget(f,j,g,o)}}else console.log('Could not find transform "'+ -b.sid+'" in node '+this.id)}for(c=0;c=0?i:i+h.length;i>=0;i--)if(k=h[i],k.hasTarget(g)){i=k;break a}i=null}k=void 0;a:{for(j+=1;jl)break}if(!r){r=new O(l);s=-1;t=0;for(u=d.length;t=l&&(s=t);l=s;d.splice(l==-1?d.length:l,0,r)}r.addTarget(f,j,g,p)}}else console.log('Could not find transform "'+ +b.sid+'" in node '+this.id)}for(c=0;c=0?i:i+h.length;i>=0;i--)if(k=h[i],k.hasTarget(g)){i=k;break a}i=null}k=void 0;a:{for(j+=1;j4&&Q.subdivideFaces){q=q.length?q:new THREE.Color; -for(e=1;e4?[q[0],q[n+1],q[n+2]]:l===4?[q[0],q[1],q[2],q[3]]:[q[0],q[1],q[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(q)}}else console.log("dropped face with vcount "+l+" for geometry with id: "+b.id);c+=g.length*l}};s.prototype=new t;s.prototype.constructor=s;t.prototype.setVertices= +this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();return this};p.prototype.handlePrimitive=function(a,b){var c=0,d,e,f=a.p,g=a.inputs,h,i,j,k,m=0,l=3,n=[];for(d=0;d4&&Q.subdivideFaces){q=q.length?q:new THREE.Color; +for(e=1;e4?[q[0],q[o+1],q[o+2]]:l===4?[q[0],q[1],q[2],q[3]]:[q[0],q[1],q[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(q)}}else console.log("dropped face with vcount "+l+" for geometry with id: "+b.id);c+=g.length*l}};s.prototype=new t;s.prototype.constructor=s;t.prototype.setVertices= function(a){for(var b=0;b1&&(F=new THREE.MeshFaceMaterial); -a=new THREE.Mesh(D,F);a.name=p;a.position.set(w[0],w[1],w[2]);u?(a.quaternion.set(u[0],u[1],u[2],u[3]),a.useQuaternion=!0):a.rotation.set(z[0],z[1],z[2]);a.scale.set(y[0],y[1],y[2]);a.visible=o.visible;B.scene.add(a);B.objects[p]=a;if(o.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);B.scene.collisions.colliders.push(b)}if(o.castsShadow)b=new THREE.ShadowVolume(D),B.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;o.trigger&&o.trigger.toLowerCase()!="none"&&(b= -{type:o.trigger,object:o},B.triggers[a.name]=b)}}else w=o.position,z=o.rotation,u=o.quaternion,y=o.scale,u=0,a=new THREE.Object3D,a.name=p,a.position.set(w[0],w[1],w[2]),u?(a.quaternion.set(u[0],u[1],u[2],u[3]),a.useQuaternion=!0):a.rotation.set(z[0],z[1],z[2]),a.scale.set(y[0],y[1],y[2]),a.visible=o.visible!==void 0?o.visible:!1,B.scene.add(a),B.objects[p]=a,B.empties[p]=a,o.trigger&&o.trigger.toLowerCase()!="none"&&(b={type:o.trigger,object:o},B.triggers[a.name]=b)}function g(a){return function(b){B.geometries[a]= -b;e();G-=1;i.onLoadComplete();h()}}function f(a){return function(b){B.geometries[a]=b}}function h(){i.callbackProgress({totalModels:O,totalTextures:M,loadedModels:O-G,loadedTextures:M-J},B);i.onLoadProgress();G==0&&J==0&&b(B)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),j,q,p,m,l,n,r,o,s,t,w,z,u,y,x,A,D,v,E,F,C,K,G,J,O,M,B;C=a;c=new THREE.BinaryLoader;K=new THREE.JSONLoader;J=G=0;B={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, -empties:{}};a=!1;for(p in C.objects)if(o=C.objects[p],o.meshCollider){a=!0;break}if(a)B.scene.collisions=new THREE.CollisionSystem;if(C.transform)a=C.transform.position,s=C.transform.rotation,x=C.transform.scale,a&&B.scene.position.set(a[0],a[1],a[2]),s&&B.scene.rotation.set(s[0],s[1],s[2]),x&&B.scene.scale.set(x[0],x[1],x[2]),(a||s||x)&&B.scene.updateMatrix();a=function(){J-=1;h();i.onLoadComplete()};for(l in C.cameras)x=C.cameras[l],x.type=="perspective"?v=new THREE.PerspectiveCamera(x.fov,x.aspect, +THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:k+"/"+a}function e(){var a;for(n in C.objects)if(!B.objects[n])if(p=C.objects[n],p.geometry!==void 0){if(D=B.geometries[p.geometry]){a=!1;for(H=0;H1&&(F=new THREE.MeshFaceMaterial); +a=new THREE.Mesh(D,F);a.name=n;a.position.set(w[0],w[1],w[2]);u?(a.quaternion.set(u[0],u[1],u[2],u[3]),a.useQuaternion=!0):a.rotation.set(z[0],z[1],z[2]);a.scale.set(y[0],y[1],y[2]);a.visible=p.visible;B.scene.add(a);B.objects[n]=a;if(p.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);B.scene.collisions.colliders.push(b)}if(p.castsShadow)b=new THREE.ShadowVolume(D),B.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;p.trigger&&p.trigger.toLowerCase()!="none"&&(b= +{type:p.trigger,object:p},B.triggers[a.name]=b)}}else w=p.position,z=p.rotation,u=p.quaternion,y=p.scale,u=0,a=new THREE.Object3D,a.name=n,a.position.set(w[0],w[1],w[2]),u?(a.quaternion.set(u[0],u[1],u[2],u[3]),a.useQuaternion=!0):a.rotation.set(z[0],z[1],z[2]),a.scale.set(y[0],y[1],y[2]),a.visible=p.visible!==void 0?p.visible:!1,B.scene.add(a),B.objects[n]=a,B.empties[n]=a,p.trigger&&p.trigger.toLowerCase()!="none"&&(b={type:p.trigger,object:p},B.triggers[a.name]=b)}function g(a){return function(b){B.geometries[a]= +b;e();G-=1;i.onLoadComplete();h()}}function f(a){return function(b){B.geometries[a]=b}}function h(){i.callbackProgress({totalModels:O,totalTextures:M,loadedModels:O-G,loadedTextures:M-J},B);i.onLoadProgress();G==0&&J==0&&b(B)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),j,q,n,m,l,o,r,p,s,t,w,z,u,y,x,A,D,v,E,F,C,K,G,J,O,M,B;C=a;c=new THREE.BinaryLoader;K=new THREE.JSONLoader;J=G=0;B={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, +empties:{}};a=!1;for(n in C.objects)if(p=C.objects[n],p.meshCollider){a=!0;break}if(a)B.scene.collisions=new THREE.CollisionSystem;if(C.transform)a=C.transform.position,s=C.transform.rotation,x=C.transform.scale,a&&B.scene.position.set(a[0],a[1],a[2]),s&&B.scene.rotation.set(s[0],s[1],s[2]),x&&B.scene.scale.set(x[0],x[1],x[2]),(a||s||x)&&B.scene.updateMatrix();a=function(){J-=1;h();i.onLoadComplete()};for(l in C.cameras)x=C.cameras[l],x.type=="perspective"?v=new THREE.PerspectiveCamera(x.fov,x.aspect, x.near,x.far):x.type=="ortho"&&(v=new THREE.OrthographicCamera(x.left,x.right,x.top,x.bottom,x.near,x.far)),w=x.position,s=x.target,x=x.up,v.position.set(w[0],w[1],w[2]),v.target=new THREE.Vector3(s[0],s[1],s[2]),x&&v.up.set(x[0],x[1],x[2]),B.cameras[l]=v;for(m in C.lights)s=C.lights[m],l=s.color!==void 0?s.color:16777215,v=s.intensity!==void 0?s.intensity:1,s.type=="directional"?(w=s.direction,t=new THREE.DirectionalLight(l,v),t.position.set(w[0],w[1],w[2]),t.position.normalize()):s.type=="point"? -(w=s.position,t=s.distance,t=new THREE.PointLight(l,v,t),t.position.set(w[0],w[1],w[2])):s.type=="ambient"&&(t=new THREE.AmbientLight(l)),B.scene.add(t),B.lights[m]=t;for(n in C.fogs)m=C.fogs[n],m.type=="linear"?E=new THREE.Fog(0,m.near,m.far):m.type=="exp2"&&(E=new THREE.FogExp2(0,m.density)),x=m.color,E.color.setRGB(x[0],x[1],x[2]),B.fogs[n]=E;if(B.cameras&&C.defaults.camera)B.currentCamera=B.cameras[C.defaults.camera];if(B.fogs&&C.defaults.fog)B.scene.fog=B.fogs[C.defaults.fog];x=C.defaults.bgcolor; -B.bgColor=new THREE.Color;B.bgColor.setRGB(x[0],x[1],x[2]);B.bgColorAlpha=C.defaults.bgalpha;for(j in C.geometries)if(n=C.geometries[j],n.type=="bin_mesh"||n.type=="ascii_mesh")G+=1,i.onLoadStart();O=G;for(j in C.geometries)n=C.geometries[j],n.type=="cube"?(D=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),B.geometries[j]=D):n.type=="plane"?(D=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),B.geometries[j]= -D):n.type=="sphere"?(D=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),B.geometries[j]=D):n.type=="cylinder"?(D=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),B.geometries[j]=D):n.type=="torus"?(D=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),B.geometries[j]=D):n.type=="icosahedron"?(D=new THREE.IcosahedronGeometry(n.subdivisions),B.geometries[j]=D):n.type=="bin_mesh"?c.load(d(n.url,C.urlBaseType),g(j)):n.type=="ascii_mesh"?K.load(d(n.url, -C.urlBaseType),g(j)):n.type=="embedded_mesh"&&(n=C.embeds[n.id])&&K.createModel(n,f(j),"");for(r in C.textures)if(j=C.textures[r],j.url instanceof Array){J+=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 p=Math.floor(k-h);p<1&&(p=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var m=Math.floor(j-h);m<1&&(m=1);h=Math.floor(j+h);h>this.size-1&&(h=this.size- -1);for(var l,n,r,o,s,t;q0&&(this.field[r+l]+=o)}}};this.addPlaneX=function(a,b){var e,g,f,h,i,k=this.size,j=this.yd,q=this.zd,p=this.field,m=k*Math.sqrt(a/b);m>k&&(m=k);for(e=0;e0)for(g=0;gj&&(l=j);for(g=0;g0){i=g*q;for(e=0;ej&&(l=j);for(f=0;f0){i=p*f;for(g=0;gthis.size-1&&(i=this.size-1);var n=Math.floor(k-h);n<1&&(n=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var m=Math.floor(j-h);m<1&&(m=1);h=Math.floor(j+h);h>this.size-1&&(h=this.size- +1);for(var l,o,r,p,s,t;q0&&(this.field[r+l]+=p)}}};this.addPlaneX=function(a,b){var e,g,f,h,i,k=this.size,j=this.yd,q=this.zd,n=this.field,m=k*Math.sqrt(a/b);m>k&&(m=k);for(e=0;e0)for(g=0;gj&&(l=j);for(g=0;g0){i=g*q;for(e=0;ej&&(l=j);for(f=0;f0){i=n*f;for(g=0;g0&&r.x0&&r.y0.0010&&u.scale>0.0010)n.x=u.x,n.y=u.y,n.z=u.z,m=u.size*u.scale/ -h,l.x=m*j,l.y=m,b.uniform3f(o.screenPosition,n.x,n.y,n.z),b.uniform2f(o.scale,l.x,l.y),b.uniform1f(o.rotation,u.rotation),b.uniform1f(o.opacity,u.opacity),b.uniform3f(o.color,u.color.r,u.color.g,u.color.b),c.setBlending(u.blending),c.setTexture(u.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}}; +"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=a.length;if(i){var k=new THREE.Vector3,j=h/f,q=f*0.5,n=h*0.5,m=16/h,l=new THREE.Vector2(m*j,m),o=new THREE.Vector3(1,1,0),r=new THREE.Vector2(1,1),p=d.uniforms,m=d.attributes;b.useProgram(d.program);if(!d.attributesEnabled)b.enableVertexAttribArray(d.attributes.vertex), +b.enableVertexAttribArray(d.attributes.uv),d.attributesEnabled=!0;b.uniform1i(p.occlusionMap,0);b.uniform1i(p.map,1);b.bindBuffer(b.ARRAY_BUFFER,d.vertexBuffer);b.vertexAttribPointer(m.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(m.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,d.elementBuffer);b.disable(b.CULL_FACE);b.depthMask(!1);var s,t,w,z,u;for(s=0;s0&&r.x0&&r.y0.0010&&u.scale>0.0010)o.x=u.x,o.y=u.y,o.z=u.z,m=u.size*u.scale/ +h,l.x=m*j,l.y=m,b.uniform3f(p.screenPosition,o.x,o.y,o.z),b.uniform2f(p.scale,l.x,l.y),b.uniform1f(p.rotation,u.rotation),b.uniform1f(p.opacity,u.opacity),b.uniform3f(p.color,u.color.r,u.color.g,u.color.b),c.setBlending(u.blending),c.setTexture(u.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.ShadowMapPlugin=function(){var a,b,c,d,e,g=new THREE.Frustum,f=new THREE.Matrix4;this.shadowMatrix=[];this.shadowMap=[];this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render= -function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(h){var i,k,j,q,p,m,l,n,r=0,o=h.lights;e||(e=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));i=0;for(k=o.length;i1.0E-5?(this.x=Math.atan2(-a.n23/b,a.n33/b), THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,d,c){this.x=a;this.y=b;this.z=d;this.w=c;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 d(a,b,d){p.sub(d,a);m=p.dot(b);if(m<=0)return null;E=r.add(a,w.copy(b).multiplyScalar(m));return y=d.distanceTo(E)}function c(a,b,d,c){p.sub(c,b);r.sub(d,b);w.sub(a,b);J=p.dot(p);O=p.dot(r);P=p.dot(w);V=r.dot(r);C=r.dot(w);D=1/(J*V-O*O);N=(V*P-O*C)*D;Q=(J*C-O*P)*D;return N>=0&&Q>=0&&N+Q<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, -d,c=[];b=0;for(d=a.length;bm.scale.x)return[];w={distance:r,point:m.position,face:null,object:m};p.push(w)}else if(m instanceof THREE.Mesh){r=d(this.origin,this.direction,m.matrixWorld.getPosition());if(r===null||r>m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)))return p;var y,C=m.geometry,J=C.vertices,H;m.matrixRotationWorld.extractRotation(m.matrixWorld);r=0;for(E=C.faces.length;r0:y<0)))if(y=k.dot(l.sub(f,a))/y,j.add(a,b.multiplyScalar(y)),w instanceof THREE.Face3)c(j, -f,g,h)&&(w={distance:a.distanceTo(j),point:j.clone(),face:w,object:m},p.push(w));else if(w instanceof THREE.Face4&&(c(j,f,g,i)||c(j,g,h,i)))w={distance:a.distanceTo(j),point:j.clone(),face:w,object:m},p.push(w)}return p};var p=new THREE.Vector3,r=new THREE.Vector3,w=new THREE.Vector3,m,E,y,J,O,P,V,C,D,N,Q}; +THREE.Ray=function(a,b){function d(a,b,d){p.sub(d,a);n=p.dot(b);if(n<=0)return null;C=v.add(a,r.copy(b).multiplyScalar(n));return y=d.distanceTo(C)}function c(a,b,d,c){p.sub(c,b);v.sub(d,b);r.sub(a,b);J=p.dot(p);O=p.dot(v);P=p.dot(r);V=v.dot(v);D=v.dot(r);E=1/(J*V-O*O);N=(V*P-O*D)*E;Q=(J*D-O*P)*E;return N>=0&&Q>=0&&N+Q<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, +d,c=[];b=0;for(d=a.length;bn.scale.x)return[];r={distance:v,point:n.position,face:null,object:n};p.push(r)}else if(n instanceof THREE.Mesh){v=d(this.origin,this.direction,n.matrixWorld.getPosition());if(v===null||v>n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)))return p;var y,D=n.geometry,J=D.vertices,H;n.matrixRotationWorld.extractRotation(n.matrixWorld);v=0;for(C=D.faces.length;v0:y<0)))if(y=k.dot(l.sub(f,a))/y,j.add(a,b.multiplyScalar(y)),r instanceof THREE.Face3)c(j, +f,g,h)&&(r={distance:a.distanceTo(j),point:j.clone(),face:r,object:n},p.push(r));else if(r instanceof THREE.Face4&&(c(j,f,g,i)||c(j,g,h,i)))r={distance:a.distanceTo(j),point:j.clone(),face:r,object:n},p.push(r)}return p};var p=new THREE.Vector3,v=new THREE.Vector3,r=new THREE.Vector3,n,C,y,J,O,P,V,D,E,N,Q}; THREE.Rectangle=function(){function a(){g=c-b;h=f-d}var b,d,c,f,g,h,i=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return c};this.getBottom=function(){return f};this.set=function(g,h,j,p){i=!1;b=g;d=h;c=j;f=p;a()};this.addPoint=function(g,h){i?(i=!1,b=g,d=h,c=g,f=h):(b=bg?c:g,f=f>h?f:h);a()};this.add3Points= -function(g,h,j,p,r,w){i?(i=!1,b=gj?g>r?g:r:j>r?j:r,f=h>p?h>w?h:w:p>w?p:w):(b=gj?g>r?g>c?g:c:r>c?r:c:j>r?j>c?j:c:r>c?r:c,f=h>p?h>w?h>f?h:f:w>f?w:f:p>w?p>f?p:f:w>f?w:f);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),d=g.getTop(),c=g.getRight(),f=g.getBottom()):(b=bg.getRight()?c:g.getRight(),f=f> +function(g,h,j,p,v,r){i?(i=!1,b=gj?g>v?g:v:j>v?j:v,f=h>p?h>r?h:r:p>r?p:r):(b=gj?g>v?g>c?g:c:v>c?v:c:j>v?j>c?j:c:v>c?v:c,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(),d=g.getTop(),c=g.getRight(),f=g.getBottom()):(b=bg.getRight()?c:g.getRight(),f=f> g.getBottom()?f:g.getBottom());a()};this.inflate=function(g){b-=g;d-=g;c+=g;f+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();d=d>g.getTop()?d:g.getTop();c=ca.getRight())return!1;if(fa.getBottom())return!1;return!0};this.empty=function(){i=!0;f=c=d=b=0;a()};this.isEmpty=function(){return i}}; THREE.Math={clamp:function(a,b,d){return ad?d:a},clampBottom:function(a,b){return a=0&&e>=0&&g>=0&&h>=0?!0:f<0&&e<0||g<0&&h<0?!1:(f<0?d=Math.max(d,f/(f-e)):e<0&&(c=Math.min(c,f/(f-e))),g<0?d=Math.max(d,g/(g-h)):h<0&&(c=Math.min(c,g/(g-h))),ch&&i.positionScreen.z0&&N.z<1))h=V[P]=V[P]||new THREE.RenderableParticle, -P++,O=h,O.x=N.x/N.w,O.y=N.y/N.w,O.z=N.z,O.rotation=Z.rotation.z,O.scale.x=Z.scale.x*Math.abs(O.x-(N.x+f.projectionMatrix.n11)/(N.w+f.projectionMatrix.n14)),O.scale.y=Z.scale.y*Math.abs(O.y-(N.y+f.projectionMatrix.n22)/(N.w+f.projectionMatrix.n24)),O.material=Z.material,C.elements.push(O);g&&C.elements.sort(d);return C}};THREE.Quaternion=function(a,b,d,c){this.set(a||0,b||0,d||0,c!==void 0?c:1)}; +j,p,v=[],r,n=[],C,y,J=[],O,P,V=[],D={objects:[],sprites:[],lights:[],elements:[]},E=new THREE.Vector3,N=new THREE.Vector4,Q=new THREE.Matrix4,ma=new THREE.Matrix4,ua=new THREE.Frustum,ha=new THREE.Vector4,ca=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);Q.multiply(b.projectionMatrix,b.matrixWorldInverse);Q.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);Q.multiply(b.matrixWorld, +b.projectionMatrixInverse);Q.multiplyVector3(a);return a};this.pickingRay=function(a,b){var d;a.z=-1;d=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(d,b);d.subSelf(a).normalize();return new THREE.Ray(a,d)};this.projectGraph=function(b,c){g=0;D.objects.length=0;D.sprites.length=0;D.lights.length=0;var h=function(b){if(b.visible!==!1){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(b.frustumCulled===!1||ua.contains(b))?(Q.multiplyVector3(E.copy(b.position)),f=a(), +f.object=b,f.z=E.z,D.objects.push(f)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(Q.multiplyVector3(E.copy(b.position)),f=a(),f.object=b,f.z=E.z,D.sprites.push(f)):b instanceof THREE.Light&&D.lights.push(b);for(var d=0,e=b.children.length;dh&&i.positionScreen.z0&&N.z<1))h=V[P]=V[P]||new THREE.RenderableParticle, +P++,O=h,O.x=N.x/N.w,O.y=N.y/N.w,O.z=N.z,O.rotation=Z.rotation.z,O.scale.x=Z.scale.x*Math.abs(O.x-(N.x+f.projectionMatrix.n11)/(N.w+f.projectionMatrix.n14)),O.scale.y=Z.scale.y*Math.abs(O.y-(N.y+f.projectionMatrix.n22)/(N.w+f.projectionMatrix.n24)),O.material=Z.material,D.elements.push(O);g&&D.elements.sort(d);return D}};THREE.Quaternion=function(a,b,d,c){this.set(a||0,b||0,d||0,c!==void 0?c:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,d,c){this.x=a;this.y=b;this.z=d;this.w=c;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,d=a.x*b,c=a.y*b,f=a.z*b,a=Math.cos(c),c=Math.sin(c),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(d),d=Math.sin(d),h=a*b,i=c*f;this.w=h*g-i*d;this.x=h*d+i*g;this.y=c*b*g+a*f*d;this.z=a*f*g-c*b*d;return this},setFromAxisAngle:function(a,b){var d=b/2,c=Math.sin(d); this.x=a.x*c;this.y=a.y*c;this.z=a.z*c;this.w=Math.cos(d);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= @@ -86,13 +86,13 @@ b;a++)d=this.faces[a],d.centroid.set(0,0,0),d instanceof THREE.Face3?(d.centroid b,d,c,f,g,h=new THREE.Vector3,i=new THREE.Vector3;a=0;for(b=this.faces.length;a0){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,d=this.boundingBox.max,c=1,f=this.vertices.length;c< f;c++){a=this.vertices[c].position;if(a.xd.x)d.x=a.x;if(a.yd.y)d.y=a.y;if(a.zd.z)d.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,d=0,c=this.vertices.length;db&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],d=[],c,f=Math.pow(10,4),g,h;g=0;for(h=this.vertices.length;gthis.points.length-2?g:g+1;d[3]=g>this.points.length-3?g:g+2;k=this.points[d[0]];j=this.points[d[1]]; -p=this.points[d[2]];r=this.points[d[3]];i=h*h;l=h*i;c.x=b(k.x,j.x,p.x,r.x,h,i,l);c.y=b(k.y,j.y,p.y,r.y,h,i,l);c.z=b(k.z,j.z,p.z,r.z,h,i,l);return c};this.getControlPointsArray=function(){var a,b,d=this.points.length,c=[];for(a=0;athis.points.length-2?g:g+1;d[3]=g>this.points.length-3?g:g+2;k=this.points[d[0]];j=this.points[d[1]]; +p=this.points[d[2]];v=this.points[d[3]];i=h*h;l=h*i;c.x=b(k.x,j.x,p.x,v.x,h,i,l);c.y=b(k.y,j.y,p.y,v.y,h,i,l);c.z=b(k.z,j.z,p.z,v.z,h,i,l);return c};this.getControlPointsArray=function(){var a,b,d=this.points.length,c=[];for(a=0;a= 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_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec3 shadowColor = vec3( 1.0 );\nfloat fDepth;\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nshadowCoord.z += shadowBias;\nbvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\nif ( all( shadowTest ) ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nconst float shadowDelta = 1.0 / 9.0;\nconst float dx0 = -1.25 * xPixelOffset;\nconst float dy0 = -1.25 * yPixelOffset;\nconst float dx1 = 1.25 * xPixelOffset;\nconst float dy1 = 1.25 * yPixelOffset;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\nfDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );\nif ( fDepth < shadowCoord.z ) shadow += shadowDelta;\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( 1.0 - 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,d,c,f={};for(b=0;b=0)return a.geometry.materials[b.materialIndex]}function c(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,d){var c,f,g,h,v=a.vertices;h=v.length;var i=a.colors,j=i.length,t=a.__vertexArray,k=a.__colorArray,n=a.__sortArray,q=a.__dirtyVertices,m=a.__dirtyColors,l=a.__webglCustomAttributesList;if(d.sortParticles){Da.multiplySelf(d.matrixWorld);for(c=0;c=0;d--)a[d].object===b&&a.splice(d,1)}function E(a,b){for(var d=a.length-1;d>=0;d--)a[d]===b&&a.splice(d,1)}function y(a,b,d,c,f){c.program|| +return!1}function h(a,b,d){var c,f,g,h,w=a.vertices;h=w.length;var i=a.colors,j=i.length,u=a.__vertexArray,k=a.__colorArray,m=a.__sortArray,q=a.__dirtyVertices,n=a.__dirtyColors,l=a.__webglCustomAttributesList;if(d.sortParticles){Da.multiplySelf(d.matrixWorld);for(c=0;c=0;d--)a[d].object===b&&a.splice(d,1)}function C(a,b){for(var d=a.length-1;d>=0;d--)a[d]===b&&a.splice(d,1)}function y(a,b,d,c,f){c.program|| H.initMaterial(c,b,d,f);if(c.morphTargets&&!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(H.maxMorphTargets);for(var g=0,h=H.maxMorphTargets;g0;this.getContext=function(){return e};this.supportsVertexTextures= -function(){return Ma};this.setSize=function(a,b){ma.width=a;ma.height=b;this.setViewport(0,0,ma.width,ma.height)};this.setViewport=function(a,b,c,d){Ea=a;Fa=b;Ga=c;Ha=d;e.viewport(Ea,Fa,Ga,Ha)};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){ja.setHex(a);xa=b;e.clearColor(ja.r,ja.g,ja.b,xa)};this.setClearColor=function(a,b){ja.copy(a);xa=b;e.clearColor(ja.r,ja.g,ja.b, -xa)};this.getClearColor=function(){return ja};this.getClearAlpha=function(){return xa};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){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject= -function(a){if(a.__webglInit)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&&f.vertexNormalBuffer&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexNormalBuffer), -e.vertexAttribPointer(a.normal,f.vertexNormalBuffer.itemSize,e.FLOAT,!1,0,d[g].index*12)),a.uv>=0&&f.vertexUvBuffer&&(f.vertexUvBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.vertexUvBuffer),e.vertexAttribPointer(a.uv,f.vertexUvBuffer.itemSize,e.FLOAT,!1,0,d[g].index*8),e.enableVertexAttribArray(a.uv)):e.disableVertexAttribArray(a.uv)),a.color>=0&&f.vertexColorBuffer&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexColorBuffer),e.vertexAttribPointer(a.color,f.vertexColorBuffer.itemSize,e.FLOAT,!1,0,d[g].index*16)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, -f.vertexIndexBuffer)),e.drawElements(e.TRIANGLES,d[g].count,e.UNSIGNED_SHORT,d[g].start*2),H.info.render.calls++,H.info.render.vertices+=d[g].count,H.info.render.faces+=d[g].count/3}};this.renderBuffer=function(a,b,c,d,f,g){if(d.opacity!==0){var h,i,c=y(a,b,c,d,g),b=c.attributes,a=!1,c=f.id*16777215+c.id*2+(d.wireframe?1:0);c!==R&&(R=c,a=!0);if(!d.morphTargets&&b.position>=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 j=g.morphTargetForcedOrder;for(i=g.morphTargetInfluences;hm&&(k=l,m=i[k]);e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[k]);e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=m;j[k]=1;m=-1;h++}}d.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(d.program.uniforms.morphTargetInfluences, -g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){h=0;for(i=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!==ta&&(e.lineWidth(d),ta=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)),H.info.render.calls++,H.info.render.vertices+=f.__webglFaceCount,H.info.render.faces+=f.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type=== -THREE.LineStrip?e.LINE_STRIP:e.LINES,d=d.linewidth,d!==ta&&(e.lineWidth(d),ta=d),e.drawArrays(g,0,f.__webglLineCount),H.info.render.calls++):g instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS,0,f.__webglParticleCount),H.info.render.calls++,H.info.render.points+=f.__webglParticleCount):g instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,0,f.__webglVertexCount),H.info.render.calls++)}};this.render=function(a,b,c,d){var f,g,h,m,p=a.lights,r=a.fog;I=-1;this.autoUpdateObjects&&this.initWebGLObjects(a); -b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();l(this.renderPluginsPre,a,b);H.info.render.calls=0;H.info.render.vertices=0;H.info.render.faces=0;H.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16); -b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Da.multiply(b.projectionMatrix,b.matrixWorldInverse);Ia.setFromMatrix(Da);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0;for(f=m.length;d=0)q=w.geometry.materials[q],q.transparent?(t.transparent=q,t.opaque=null):(t.opaque=q,t.transparent=null)}else if(q)q.transparent?(t.transparent=q,t.opaque=null):(t.opaque=q,t.transparent=null);g.render=!0;if(this.sortObjects)h.renderDepth?g.z=h.renderDepth:(Ba.copy(h.position),Da.multiplyVector3(Ba),g.z=Ba.z)}this.sortObjects&&m.sort(i);m=a.__webglObjectsImmediate;d=0;for(f=m.length;d< -f;d++)if(g=m[d],h=g.object,h.visible)h.matrixAutoUpdate&&h.matrixWorld.flattenToArray(h._objectMatrixArray),J(h,b),h=g.object.material,h.transparent?(g.transparent=h,g.opaque=null):(g.opaque=h,g.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),O(a.overrideMaterial.depthWrite),P(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),k(a.__webglObjects,!1,"",b,p, -r,!0,a.overrideMaterial),j(a.__webglObjectsImmediate,"",b,p,r,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),k(a.__webglObjects,!0,"opaque",b,p,r,!1),j(a.__webglObjectsImmediate,"opaque",b,p,r,!1),k(a.__webglObjects,!1,"transparent",b,p,r,!0),j(a.__webglObjectsImmediate,"transparent",b,p,r,!0));l(this.renderPluginsPost,a,b);c&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(e.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture), -e.generateMipmap(e.TEXTURE_CUBE_MAP),e.bindTexture(e.TEXTURE_CUBE_MAP,null)):(e.bindTexture(e.TEXTURE_2D,c.__webglTexture),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)))};this.renderImmediateObject=function(a,b,c,d,f){var g=y(a,b,c,d,f);R=-1;H.setObjectFaces(f);f.immediateRenderCallback?f.immediateRenderCallback(g,e,Ia):f.render(function(a){H.renderBufferImmediate(a,g,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate= -[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var i=a.__objectsAdded[0],j=a,k=void 0,l=void 0,F=void 0;if(!i.__webglInit)if(i.__webglInit=!0,i._modelViewMatrix=new THREE.Matrix4,i._normalMatrixArray=new Float32Array(9),i._modelViewMatrixArray=new Float32Array(16),i._objectMatrixArray=new Float32Array(16),i.matrixWorld.flattenToArray(i._objectMatrixArray),i instanceof THREE.Mesh){if(l=i.geometry,l instanceof THREE.Geometry){if(l.geometryGroups===void 0){var F=l,G=void 0, -v=void 0,y=void 0,C=void 0,t=void 0,D=void 0,n=void 0,q={},J=F.morphTargets.length;F.geometryGroups={};G=0;for(v=F.faces.length;G65535&&(q[D].counter+=1,n=q[D].hash+"_"+q[D].counter,F.geometryGroups[n]=== -void 0&&(F.geometryGroups[n]={faces3:[],faces4:[],materialIndex:C,vertices:0,numMorphTargets:J})),y instanceof THREE.Face3?F.geometryGroups[n].faces3.push(G):F.geometryGroups[n].faces4.push(G),F.geometryGroups[n].vertices+=t;F.geometryGroupsList=[];G=void 0;for(G in F.geometryGroups)F.geometryGroups[G].id=na++,F.geometryGroupsList.push(F.geometryGroups[G])}for(k in l.geometryGroups)if(F=l.geometryGroups[k],!F.__webglVertexBuffer){G=F;G.__webglVertexBuffer=e.createBuffer();G.__webglNormalBuffer=e.createBuffer(); -G.__webglTangentBuffer=e.createBuffer();G.__webglColorBuffer=e.createBuffer();G.__webglUVBuffer=e.createBuffer();G.__webglUV2Buffer=e.createBuffer();G.__webglSkinVertexABuffer=e.createBuffer();G.__webglSkinVertexBBuffer=e.createBuffer();G.__webglSkinIndicesBuffer=e.createBuffer();G.__webglSkinWeightsBuffer=e.createBuffer();G.__webglFaceBuffer=e.createBuffer();G.__webglLineBuffer=e.createBuffer();if(G.numMorphTargets){y=v=void 0;G.__webglMorphTargetsBuffers=[];v=0;for(y=G.numMorphTargets;v0||t.faceVertexUvs.length>0)F.__uvArray=new Float32Array(G*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)F.__uv2Array=new Float32Array(G*2)}if(C.geometry.skinWeights.length&& -C.geometry.skinIndices.length)F.__skinVertexAArray=new Float32Array(G*4),F.__skinVertexBArray=new Float32Array(G*4),F.__skinIndexArray=new Float32Array(G*4),F.__skinWeightArray=new Float32Array(G*4);F.__faceArray=new Uint16Array(y*3);F.__lineArray=new Uint16Array(D*2);if(F.numMorphTargets){F.__morphTargetsArrays=[];C=0;for(t=F.numMorphTargets;C0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,W,y),e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,X,y),e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,U,y),e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,ia,y))}if(xa&&D){n=0;for(q=M.length;n0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,ea,y))}if(P&&la.hasTangents){n=0;for(q=M.length;n0&&(e.bindBuffer(e.ARRAY_BUFFER, -v.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,Z,y))}if(ua&&sa&&O){n=0;for(q=M.length;n0&&(e.bindBuffer(e.ARRAY_BUFFER,v.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,s,y))}if(ra){n=0;for(q=M.length;n0};this.setSize=function(a,b){ma.width=a;ma.height=b;this.setViewport(0,0,ma.width,ma.height)};this.setViewport=function(a,b,c,d){Fa=a;Ga=b;Ha=c;Ia=d;e.viewport(Fa,Ga,Ha,Ia)};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){ja.setHex(a);xa=b;e.clearColor(ja.r,ja.g,ja.b,xa)};this.setClearColor=function(a,b){ja.copy(a);xa=b;e.clearColor(ja.r,ja.g,ja.b,xa)};this.getClearColor=function(){return ja};this.getClearAlpha=function(){return xa};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){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)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&&f.vertexNormalBuffer&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexNormalBuffer),e.vertexAttribPointer(a.normal,f.vertexNormalBuffer.itemSize,e.FLOAT,!1,0,d[g].index*12)),a.uv>=0&&f.vertexUvBuffer&&(f.vertexUvBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.vertexUvBuffer),e.vertexAttribPointer(a.uv,f.vertexUvBuffer.itemSize,e.FLOAT,!1,0,d[g].index* +8),e.enableVertexAttribArray(a.uv)):e.disableVertexAttribArray(a.uv)),a.color>=0&&f.vertexColorBuffer&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexColorBuffer),e.vertexAttribPointer(a.color,f.vertexColorBuffer.itemSize,e.FLOAT,!1,0,d[g].index*16)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.vertexIndexBuffer)),e.drawElements(e.TRIANGLES,d[g].count,e.UNSIGNED_SHORT,d[g].start*2),H.info.render.calls++,H.info.render.vertices+=d[g].count,H.info.render.faces+=d[g].count/3}};this.renderBuffer=function(a,b,c,d,f,g){if(d.opacity!== +0){var h,i,c=y(a,b,c,d,g),b=c.attributes,a=!1,c=f.id*16777215+c.id*2+(d.wireframe?1:0);c!==R&&(R=c,a=!0);if(!d.morphTargets&&b.position>=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 j=g.morphTargetForcedOrder;for(i=g.morphTargetInfluences;hk&&(n=l,k=i[n]);e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[n]);e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=k;j[n]=1;k=-1;h++}}d.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList){h=0;for(i=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!==ta&&(e.lineWidth(d),ta=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)),H.info.render.calls++,H.info.render.vertices+=f.__webglFaceCount,H.info.render.faces+=f.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?e.LINE_STRIP:e.LINES,d=d.linewidth,d!==ta&&(e.lineWidth(d),ta=d),e.drawArrays(g,0,f.__webglLineCount),H.info.render.calls++):g instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS, +0,f.__webglParticleCount),H.info.render.calls++,H.info.render.points+=f.__webglParticleCount):g instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,0,f.__webglVertexCount),H.info.render.calls++)}};this.render=function(a,b,c,d){var f,g,h,n,p=a.lights,r=a.fog;I=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();l(this.renderPluginsPre,a,b);H.info.render.calls= +0;H.info.render.vertices=0;H.info.render.faces=0;H.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Da.multiply(b.projectionMatrix,b.matrixWorldInverse);Ja.setFromMatrix(Da);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor, +this.autoClearDepth,this.autoClearStencil);n=a.__webglObjects;d=0;for(f=n.length;d=0)q=v.geometry.materials[q],q.transparent?(u.transparent=q,u.opaque=null):(u.opaque= +q,u.transparent=null)}else if(q)q.transparent?(u.transparent=q,u.opaque=null):(u.opaque=q,u.transparent=null);g.render=!0;if(this.sortObjects)h.renderDepth?g.z=h.renderDepth:(Ba.copy(h.position),Da.multiplyVector3(Ba),g.z=Ba.z)}this.sortObjects&&n.sort(i);n=a.__webglObjectsImmediate;d=0;for(f=n.length;d65535&&(q[E].counter+=1,m=q[E].hash+"_"+q[E].counter,F.geometryGroups[m]===void 0&&(F.geometryGroups[m]={faces3:[],faces4:[],materialIndex:D,vertices:0,numMorphTargets:J})),y instanceof THREE.Face3?F.geometryGroups[m].faces3.push(G):F.geometryGroups[m].faces4.push(G),F.geometryGroups[m].vertices+= +u;F.geometryGroupsList=[];G=void 0;for(G in F.geometryGroups)F.geometryGroups[G].id=na++,F.geometryGroupsList.push(F.geometryGroups[G])}for(k in l.geometryGroups)if(F=l.geometryGroups[k],!F.__webglVertexBuffer){G=F;G.__webglVertexBuffer=e.createBuffer();G.__webglNormalBuffer=e.createBuffer();G.__webglTangentBuffer=e.createBuffer();G.__webglColorBuffer=e.createBuffer();G.__webglUVBuffer=e.createBuffer();G.__webglUV2Buffer=e.createBuffer();G.__webglSkinVertexABuffer=e.createBuffer();G.__webglSkinVertexBBuffer= +e.createBuffer();G.__webglSkinIndicesBuffer=e.createBuffer();G.__webglSkinWeightsBuffer=e.createBuffer();G.__webglFaceBuffer=e.createBuffer();G.__webglLineBuffer=e.createBuffer();if(G.numMorphTargets){y=w=void 0;G.__webglMorphTargetsBuffers=[];w=0;for(y=G.numMorphTargets;w0||u.faceVertexUvs.length>0)F.__uvArray=new Float32Array(G*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)F.__uv2Array=new Float32Array(G*2)}if(D.geometry.skinWeights.length&&D.geometry.skinIndices.length)F.__skinVertexAArray=new Float32Array(G*4),F.__skinVertexBArray=new Float32Array(G*4),F.__skinIndexArray= +new Float32Array(G*4),F.__skinWeightArray=new Float32Array(G*4);F.__faceArray=new Uint16Array(y*3);F.__lineArray=new Uint16Array(E*2);if(F.numMorphTargets){F.__morphTargetsArrays=[];D=0;for(u=F.numMorphTargets;D0&&(e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinVertexABuffer), +e.bufferData(e.ARRAY_BUFFER,W,y),e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,X,y),e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,U,y),e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,ia,y))}if(xa&&E){m=0;for(q=M.length;m0&&(e.bindBuffer(e.ARRAY_BUFFER,w.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,ea,y))}if(P&&la.hasTangents){m=0;for(q=M.length;m< +q;m++)t=aa[M[m]],P=t.vertexTangents,da=P[0],ea=P[1],la=P[2],ba[K]=da.x,ba[K+1]=da.y,ba[K+2]=da.z,ba[K+3]=da.w,ba[K+4]=ea.x,ba[K+5]=ea.y,ba[K+6]=ea.z,ba[K+7]=ea.w,ba[K+8]=la.x,ba[K+9]=la.y,ba[K+10]=la.z,ba[K+11]=la.w,K+=12;m=0;for(q=Y.length;m0&&(e.bindBuffer(e.ARRAY_BUFFER,w.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,Z,y))}if(ua&&sa&&O){m=0;for(q=M.length;m0&&(e.bindBuffer(e.ARRAY_BUFFER,w.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,s,y))}if(ra){m=0;for(q=M.length;m0?"#define VERTEX_TEXTURES":"",H.gammaInput?"#define GAMMA_INPUT":"",H.gammaOutput?"#define GAMMA_OUTPUT":"",H.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+ +c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION": +"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); h=["precision "+ua+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",H.gammaInput?"#define GAMMA_INPUT":"",H.gammaOutput?"#define GAMMA_OUTPUT":"",H.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.wrapAround?"#define WRAP_AROUND":"",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(p,V("fragment", h+k));e.attachShader(p,V("vertex",d+l));e.linkProgram(p);e.getProgramParameter(p,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(p,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");p.uniforms={};p.attributes={};var r,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(r in j)d.push(r);r=d;d=0;for(j=r.length;d=0&&e.enableVertexAttribArray(q.normal);q.tangent>=0&&e.enableVertexAttribArray(q.tangent);a.skinning&&q.skinVertexA>=0&&q.skinVertexB>=0&&q.skinIndex>=0&&q.skinWeight>=0&&(e.enableVertexAttribArray(q.skinVertexA),e.enableVertexAttribArray(q.skinVertexB),e.enableVertexAttribArray(q.skinIndex),e.enableVertexAttribArray(q.skinWeight));if(a.attributes)for(g in a.attributes)q[g]!==void 0&&q[g]>=0&&e.enableVertexAttribArray(q[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g=0&&(e.enableVertexAttribArray(q[r]),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.setObjectFaces=function(a){if(ra!==a.doubleSided)a.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE), ra=a.doubleSided;if(Z!==a.flipSided)a.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW),Z=a.flipSided};this.setDepthTest=function(a){oa!==a&&(a?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),oa=a)};this.setBlending=function(a){if(a!==sa){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)}sa=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=e.createTexture(),H.info.memory.textures++;e.activeTexture(e.TEXTURE0+b);e.bindTexture(e.TEXTURE_2D,a.__webglTexture);var c=C(e.TEXTURE_2D,a,a.image),d=Q(a.format),f=Q(a.type);a instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D, +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)}sa=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=e.createTexture(),H.info.memory.textures++;e.activeTexture(e.TEXTURE0+b);e.bindTexture(e.TEXTURE_2D,a.__webglTexture);var c=D(e.TEXTURE_2D,a,a.image),d=Q(a.format),f=Q(a.type);a instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D, 0,d,a.image.width,a.image.height,0,d,f,a.image.data):e.texImage2D(e.TEXTURE_2D,0,d,d,f,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)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=e.createTexture();var c=Q(a.format), -d=Q(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];e.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture);C(e.TEXTURE_CUBE_MAP,a,a);for(var f=0;f<6;f++){a.__webglFramebuffer[f]=e.createFramebuffer();a.__webglRenderbuffer[f]=e.createRenderbuffer();e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c,a.width,a.height,0,c,d,null);var g=a,h=e.TEXTURE_CUBE_MAP_POSITIVE_X+f;e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[f]);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,h,g.__webglTexture, -0);D(a.__webglRenderbuffer[f],a)}}else a.__webglFramebuffer=e.createFramebuffer(),a.__webglRenderbuffer=e.createRenderbuffer(),e.bindTexture(e.TEXTURE_2D,a.__webglTexture),C(e.TEXTURE_2D,a,a),e.texImage2D(e.TEXTURE_2D,0,c,a.width,a.height,0,c,d,null),c=e.TEXTURE_2D,e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,c,a.__webglTexture,0),D(a.__webglRenderbuffer,a);b?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER, -null);e.bindFramebuffer(e.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=d=0):(b=null,c=Ga,a=Ha,d=Ea,f=Fa);b!==qa&&(e.bindFramebuffer(e.FRAMEBUFFER,b),e.viewport(d,f,c,a),qa=b);Ja=c;Ka=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; +d=Q(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];e.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture);D(e.TEXTURE_CUBE_MAP,a,a);for(var f=0;f<6;f++){a.__webglFramebuffer[f]=e.createFramebuffer();a.__webglRenderbuffer[f]=e.createRenderbuffer();e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,c,a.width,a.height,0,c,d,null);var g=a,h=e.TEXTURE_CUBE_MAP_POSITIVE_X+f;e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[f]);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,h,g.__webglTexture, +0);E(a.__webglRenderbuffer[f],a)}}else a.__webglFramebuffer=e.createFramebuffer(),a.__webglRenderbuffer=e.createRenderbuffer(),e.bindTexture(e.TEXTURE_2D,a.__webglTexture),D(e.TEXTURE_2D,a,a),e.texImage2D(e.TEXTURE_2D,0,c,a.width,a.height,0,c,d,null),c=e.TEXTURE_2D,e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,c,a.__webglTexture,0),E(a.__webglRenderbuffer,a);b?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER, +null);e.bindFramebuffer(e.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=d=0):(b=null,c=Ha,a=Ia,d=Fa,f=Ga);b!==qa&&(e.bindFramebuffer(e.FRAMEBUFFER,b),e.viewport(d,f,c,a),qa=b);Ka=c;La=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; THREE.WebGLRenderTarget=function(a,b,d){this.width=a;this.height=b;d=d||{};this.wrapS=d.wrapS!==void 0?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==void 0?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==void 0?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==void 0?d.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=d.format!==void 0?d.format:THREE.RGBAFormat;this.type=d.type!==void 0?d.type: THREE.UnsignedByteType;this.depthBuffer=d.depthBuffer!==void 0?d.depthBuffer:!0;this.stencilBuffer=d.stencilBuffer!==void 0?d.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,d){THREE.WebGLRenderTarget.call(this,a,b,d);this.activeCubeFace=0}; @@ -305,25 +306,25 @@ c.vertices[f++]=1;c.vertices[f++]=-1;c.vertices[f++]=1;c.vertices[f++]=0;c.verti c.elementBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,c.faces,b.STATIC_DRAW);c.tempTexture=b.createTexture();c.occlusionTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,c.tempTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST); b.bindTexture(b.TEXTURE_2D,c.occlusionTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(c.hasVertexTexture=!1,c.program=a(THREE.ShaderFlares.lensFlare)):(c.hasVertexTexture= !0,c.program=a(THREE.ShaderFlares.lensFlareVertexTexture));c.attributes={};c.uniforms={};c.attributes.vertex=b.getAttribLocation(c.program,"position");c.attributes.uv=b.getAttribLocation(c.program,"uv");c.uniforms.renderType=b.getUniformLocation(c.program,"renderType");c.uniforms.map=b.getUniformLocation(c.program,"map");c.uniforms.occlusionMap=b.getUniformLocation(c.program,"occlusionMap");c.uniforms.opacity=b.getUniformLocation(c.program,"opacity");c.uniforms.color=b.getUniformLocation(c.program, -"color");c.uniforms.scale=b.getUniformLocation(c.program,"scale");c.uniforms.rotation=b.getUniformLocation(c.program,"rotation");c.uniforms.screenPosition=b.getUniformLocation(c.program,"screenPosition");c.attributesEnabled=!1};this.render=function(a,g,h,i){var a=a.__webglFlares,l=a.length;if(l){var k=new THREE.Vector3,j=i/h,p=h*0.5,r=i*0.5,w=16/i,m=new THREE.Vector2(w*j,w),E=new THREE.Vector3(1,1,0),y=new THREE.Vector2(1,1),J=c.uniforms,w=c.attributes;b.useProgram(c.program);if(!c.attributesEnabled)b.enableVertexAttribArray(c.attributes.vertex), -b.enableVertexAttribArray(c.attributes.uv),c.attributesEnabled=!0;b.uniform1i(J.occlusionMap,0);b.uniform1i(J.map,1);b.bindBuffer(b.ARRAY_BUFFER,c.vertexBuffer);b.vertexAttribPointer(w.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(w.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,c.elementBuffer);b.disable(b.CULL_FACE);b.depthMask(!1);var O,P,V,C,D;for(O=0;O0&&y.x0&&y.y0.0010&&D.scale>0.0010)E.x=D.x,E.y=D.y,E.z=D.z,w=D.size*D.scale/ -i,m.x=w*j,m.y=w,b.uniform3f(J.screenPosition,E.x,E.y,E.z),b.uniform2f(J.scale,m.x,m.y),b.uniform1f(J.rotation,D.rotation),b.uniform1f(J.opacity,D.opacity),b.uniform3f(J.color,D.color.r,D.color.g,D.color.b),d.setBlending(D.blending),d.setTexture(D.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}}; +"color");c.uniforms.scale=b.getUniformLocation(c.program,"scale");c.uniforms.rotation=b.getUniformLocation(c.program,"rotation");c.uniforms.screenPosition=b.getUniformLocation(c.program,"screenPosition");c.attributesEnabled=!1};this.render=function(a,g,h,i){var a=a.__webglFlares,l=a.length;if(l){var k=new THREE.Vector3,j=i/h,p=h*0.5,v=i*0.5,r=16/i,n=new THREE.Vector2(r*j,r),C=new THREE.Vector3(1,1,0),y=new THREE.Vector2(1,1),J=c.uniforms,r=c.attributes;b.useProgram(c.program);if(!c.attributesEnabled)b.enableVertexAttribArray(c.attributes.vertex), +b.enableVertexAttribArray(c.attributes.uv),c.attributesEnabled=!0;b.uniform1i(J.occlusionMap,0);b.uniform1i(J.map,1);b.bindBuffer(b.ARRAY_BUFFER,c.vertexBuffer);b.vertexAttribPointer(r.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(r.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,c.elementBuffer);b.disable(b.CULL_FACE);b.depthMask(!1);var O,P,V,D,E;for(O=0;O0&&y.x0&&y.y0.0010&&E.scale>0.0010)C.x=E.x,C.y=E.y,C.z=E.z,r=E.size*E.scale/ +i,n.x=r*j,n.y=r,b.uniform3f(J.screenPosition,C.x,C.y,C.z),b.uniform2f(J.scale,n.x,n.y),b.uniform1f(J.rotation,E.rotation),b.uniform1f(J.opacity,E.opacity),b.uniform3f(J.color,E.color.r,E.color.g,E.color.b),d.setBlending(E.blending),d.setTexture(E.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.ShadowMapPlugin=function(){var a,b,d,c,f,g=new THREE.Frustum,h=new THREE.Matrix4;this.shadowMatrix=[];this.shadowMap=[];this.init=function(f){a=f.context;b=f;var f=THREE.ShaderLib.depthRGBA,g=THREE.UniformsUtils.clone(f.uniforms);d=new THREE.ShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:g});c=new THREE.ShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:g,morphTargets:!0});d._shadowPass=!0;c._shadowPass=!0};this.render= -function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(i){var l,k,j,p,r,w,m,E,y=0,J=i.lights;f||(f=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));l=0;for(k=J.length;l 0", + + "uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];", + "uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];", + + "#endif", + + "#if MAX_POINT_LIGHTS > 0", + + "uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];", + "uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];", + "uniform float pointLightDistance[ MAX_POINT_LIGHTS ];", + + "#endif", + + "varying vec3 vViewPosition;", + + THREE.ShaderChunk[ "shadowmap_pars_fragment" ], + THREE.ShaderChunk[ "fog_pars_fragment" ], + + // Fresnel term + + "float fresnelReflectance( vec3 H, vec3 V, float F0 ) {", + + "float base = 1.0 - dot( V, H );", + "float exponential = pow( base, 5.0 );", + + "return exponential + F0 * ( 1.0 - exponential );", + + "}", + + // Kelemen/Szirmay-Kalos specular BRDF + + "float KS_Skin_Specular( vec3 N,", // Bumped surface normal + "vec3 L,", // Points to light + "vec3 V,", // Points to eye + "float m,", // Roughness + "float rho_s", // Specular brightness + ") {", + + "float result = 0.0;", + "float ndotl = dot( N, L );", + + "if( ndotl > 0.0 ) {", + + "vec3 h = L + V;", // Unnormalized half-way vector + "vec3 H = normalize( h );", + + "float ndoth = dot( N, H );", + + "float PH = pow( 2.0 * texture2D( tBeckmann, vec2( ndoth, m ) ).x, 10.0 );", + + "float F = fresnelReflectance( H, V, 0.028 );", + "float frSpec = max( PH * F / dot( h, h ), 0.0 );", + + "result = ndotl * rho_s * frSpec;", // BRDF * dot(N,L) * rho_s + + "}", + + "return result;", + + "}", + + "void main() {", + + "gl_FragColor = vec4( vec3( 1.0 ), uOpacity );", + + "vec4 colDiffuse = texture2D( tDiffuse, vUv );", + "colDiffuse.rgb *= colDiffuse.rgb;", + + "gl_FragColor = gl_FragColor * colDiffuse;", + + "vec3 normal = normalize( vNormal );", + "vec3 viewPosition = normalize( vViewPosition );", + + // point lights + + "vec3 specularTotal = vec3( 0.0 );", + + "#if MAX_POINT_LIGHTS > 0", + + "vec3 pointTotal = vec3( 0.0 );", + + "for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {", + + "vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );", + + "vec3 lVector = lPosition.xyz + vViewPosition.xyz;", + + "float lDistance = 1.0;", + + "if ( pointLightDistance[ i ] > 0.0 )", + "lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );", + + "lVector = normalize( lVector );", + + "float pointDiffuseWeightFull = max( dot( normal, lVector ), 0.0 );", + "float pointDiffuseWeightHalf = max( 0.5 * dot( normal, lVector ) + 0.5, 0.0 );", + "vec3 pointDiffuseWeight = mix( vec3 ( pointDiffuseWeightFull ), vec3( pointDiffuseWeightHalf ), uWrapRGB );", + + "float pointSpecularWeight = KS_Skin_Specular( normal, lVector, viewPosition, uRoughness, uSpecularBrightness );", + + "pointTotal += lDistance * uDiffuseColor * pointLightColor[ i ] * pointDiffuseWeight;", + "specularTotal += lDistance * uSpecularColor * pointLightColor[ i ] * pointSpecularWeight;", + + "}", + + "#endif", + + // directional lights + + "#if MAX_DIR_LIGHTS > 0", + + "vec3 dirTotal = vec3( 0.0 );", + + "for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {", + + "vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );", + + "vec3 dirVector = normalize( lDirection.xyz );", + + "float dirDiffuseWeightFull = max( dot( normal, dirVector ), 0.0 );", + "float dirDiffuseWeightHalf = max( 0.5 * dot( normal, dirVector ) + 0.5, 0.0 );", + "vec3 dirDiffuseWeight = mix( vec3 ( dirDiffuseWeightFull ), vec3( dirDiffuseWeightHalf ), uWrapRGB );", + + "float dirSpecularWeight = KS_Skin_Specular( normal, dirVector, viewPosition, uRoughness, uSpecularBrightness );", + + "dirTotal += uDiffuseColor * directionalLightColor[ i ] * dirDiffuseWeight;", + "specularTotal += uSpecularColor * directionalLightColor[ i ] * dirSpecularWeight;", + + "}", + + "#endif", + + // all lights contribution summation + + "vec3 totalLight = vec3( 0.0 );", + + "#if MAX_DIR_LIGHTS > 0", + "totalLight += dirTotal;", + "#endif", + + "#if MAX_POINT_LIGHTS > 0", + "totalLight += pointTotal;", + "#endif", + + "gl_FragColor.xyz = gl_FragColor.xyz * ( totalLight + ambientLightColor * uAmbientColor ) + specularTotal;", + + THREE.ShaderChunk[ "shadowmap_fragment" ], + THREE.ShaderChunk[ "linear_to_gamma_fragment" ], + THREE.ShaderChunk[ "fog_fragment" ], + + "}" + + ].join("\n"), + + vertexShader: [ + + "varying vec3 vNormal;", + "varying vec2 vUv;", + + "varying vec3 vViewPosition;", + + THREE.ShaderChunk[ "shadowmap_pars_vertex" ], + + "void main() {", + + "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", + "vViewPosition = -mvPosition.xyz;", + + "vNormal = normalMatrix * normal;", + + "vUv = uv;", + + "gl_Position = projectionMatrix * mvPosition;", + + THREE.ShaderChunk[ "shadowmap_vertex" ], + + "}" + + ].join( "\n" ) + + }, + /* ------------------------------------------------------------------------------------------ // Skin shader // - Blinn-Phong diffuse term (using normal + diffuse maps) @@ -155,7 +398,7 @@ THREE.ShaderSkin = { "vec4 colDiffuse = texture2D( tDiffuse, vUv );", "colDiffuse *= colDiffuse;", - "gl_FragColor = gl_FragColor * pow( colDiffuse, vec4( 0.5 ) );", + "gl_FragColor = gl_FragColor * colDiffuse;", "mat3 tsb = mat3( vTangent, vBinormal, vNormal );", "vec3 finalNormal = tsb * normalTex;", diff --git a/src/extras/plugins/ShadowMapPlugin.js b/src/extras/plugins/ShadowMapPlugin.js index a98ca1e8..b0d0dd06 100644 --- a/src/extras/plugins/ShadowMapPlugin.js +++ b/src/extras/plugins/ShadowMapPlugin.js @@ -187,7 +187,15 @@ THREE.ShadowMapPlugin = function ( ) { } - _renderer.renderBuffer( _cameraLight, lights, fog, material, buffer, object ); + if ( buffer instanceof THREE.BufferGeometry ) { + + _renderer.renderBufferDirect( _cameraLight, lights, fog, material, buffer, object ); + + } else { + + _renderer.renderBuffer( _cameraLight, lights, fog, material, buffer, object ); + + } } diff --git a/src/lights/SpotLight.js b/src/lights/SpotLight.js index cac9cc27..d1e138ed 100644 --- a/src/lights/SpotLight.js +++ b/src/lights/SpotLight.js @@ -13,6 +13,7 @@ THREE.SpotLight = function ( hex, intensity, distance, castShadow ) { this.distance = ( distance !== undefined ) ? distance : 0; this.castShadow = ( castShadow !== undefined ) ? castShadow : false; + this.onlyShadow = false; }; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 59c3fc13..ef80b135 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -67,6 +67,10 @@ THREE.WebGLRenderer = function ( parameters ) { this.maxMorphTargets = 8; + // flags + + this.autoScaleCubemaps = true; + // custom render plugins this.renderPluginsPre = []; @@ -158,7 +162,11 @@ THREE.WebGLRenderer = function ( parameters ) { this.context = _gl; - var _supportsVertexTextures = ( maxVertexTextures() > 0 ); + // GPU capabilities + + var _maxVertexTextures = _gl.getParameter( _gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS ), + _maxTextureSize = _gl.getParameter( _gl.TEXTURE_SIZE ), + _maxCubemapSize = _gl.getParameter( _gl.MAX_CUBE_MAP_TEXTURE_SIZE ); // API @@ -170,7 +178,7 @@ THREE.WebGLRenderer = function ( parameters ) { this.supportsVertexTextures = function () { - return _supportsVertexTextures; + return _maxVertexTextures > 0; }; @@ -4723,7 +4731,7 @@ THREE.WebGLRenderer = function ( parameters ) { dlength += 1; - } else if ( light instanceof THREE.SpotLight ) { // hack, not a proper spotlight + } else if ( light instanceof THREE.SpotLight && ! light.onlyShadow ) { // hack, not a proper spotlight doffset = dlength * 3; @@ -5043,7 +5051,7 @@ THREE.WebGLRenderer = function ( parameters ) { var prefix_vertex = [ - _supportsVertexTextures ? "#define VERTEX_TEXTURES" : "", + ( _maxVertexTextures > 0 ) ? "#define VERTEX_TEXTURES" : "", _this.gammaInput ? "#define GAMMA_INPUT" : "", _this.gammaOutput ? "#define GAMMA_OUTPUT" : "", @@ -5364,6 +5372,32 @@ THREE.WebGLRenderer = function ( parameters ) { }; + function clampToMaxSize ( image, maxSize ) { + + if ( image.width <= maxSize && image.height <= maxSize ) { + + return image; + + } + + // Warning: Scaling through the canvas will only work with images that use + // premultiplied alpha. + + var maxDimension = Math.max( image.width, image.height ); + var newWidth = Math.floor( image.width * maxSize / maxDimension ); + var newHeight = Math.floor( image.height * maxSize / maxDimension ); + + var canvas = document.createElement( 'canvas' ); + canvas.width = newWidth; + canvas.height = newHeight; + + var ctx = canvas.getContext( "2d" ); + ctx.drawImage( image, 0, 0, image.width, image.height, 0, 0, newWidth, newHeight ); + + return canvas; + + } + function setCubeTexture ( texture, slot ) { if ( texture.image.length === 6 ) { @@ -5379,13 +5413,29 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.activeTexture( _gl.TEXTURE0 + slot ); _gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webglTextureCube ); - var needsMipMaps = setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, texture.image[ 0 ] ), + var cubeImage = []; + + for ( var i = 0; i < 6; i ++ ) { + + if ( _this.autoScaleCubemaps ) { + + cubeImage[ i ] = clampToMaxSize( texture.image[ i ], _maxCubemapSize ); + + } else { + + cubeImage[ i ] = texture.image[ i ]; + + } + + } + + var needsMipMaps = setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, cubeImage[ 0 ] ), glFormat = paramThreeToGL( texture.format ), glType = paramThreeToGL( texture.type ); for ( var i = 0; i < 6; i ++ ) { - _gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glFormat, glFormat, glType, texture.image[ i ] ); + _gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glFormat, glFormat, glType, cubeImage[ i ] ); } @@ -5676,7 +5726,7 @@ THREE.WebGLRenderer = function ( parameters ) { light = lights[ l ]; - if ( light instanceof THREE.SpotLight ) dirLights ++; // hack, not a proper spotlight + if ( light instanceof THREE.SpotLight && ! light.onlyShadow ) dirLights ++; // hack, not a proper spotlight if ( light instanceof THREE.DirectionalLight ) dirLights ++; if ( light instanceof THREE.PointLight ) pointLights ++; @@ -5714,12 +5764,6 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function maxVertexTextures () { - - return _gl.getParameter( _gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS ); - - }; - // Initialization function initGL () { diff --git a/src/renderers/WebGLShaders.js b/src/renderers/WebGLShaders.js index ccc4cc3c..f1ca14ac 100644 --- a/src/renderers/WebGLShaders.js +++ b/src/renderers/WebGLShaders.js @@ -769,13 +769,19 @@ THREE.ShaderChunk = { "#endif", "vec3 shadowColor = vec3( 1.0 );", + "float fDepth;", "for( int i = 0; i < MAX_SHADOWS; i ++ ) {", "vec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;", "shadowCoord.z += shadowBias;", - "if ( shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {", + // using "if ( all )" for ATI OpenGL shader compiler + // "if ( something && something )" breaks it + + "bvec4 shadowTest = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );", + + "if ( all( shadowTest ) ) {", "#ifdef SHADOWMAP_SOFT", @@ -785,6 +791,10 @@ THREE.ShaderChunk = { "float shadow = 0.0;", + /* + // this breaks shader compiler / validator on some ATI cards when using OpenGL + // must enroll loop manually + "for ( float y = -1.25; y <= 1.25; y += 1.25 )", "for ( float x = -1.25; x <= 1.25; x += 1.25 ) {", @@ -801,6 +811,42 @@ THREE.ShaderChunk = { "}", "shadow /= 9.0;", + + */ + + "const float shadowDelta = 1.0 / 9.0;", + "const float dx0 = -1.25 * xPixelOffset;", + "const float dy0 = -1.25 * yPixelOffset;", + "const float dx1 = 1.25 * xPixelOffset;", + "const float dy1 = 1.25 * yPixelOffset;", + + "fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy0 ) ) );", + "if ( fDepth < shadowCoord.z ) shadow += shadowDelta;", + + "fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy0 ) ) );", + "if ( fDepth < shadowCoord.z ) shadow += shadowDelta;", + + "fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy0 ) ) );", + "if ( fDepth < shadowCoord.z ) shadow += shadowDelta;", + + "fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, 0.0 ) ) );", + "if ( fDepth < shadowCoord.z ) shadow += shadowDelta;", + + "fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy ) );", + "if ( fDepth < shadowCoord.z ) shadow += shadowDelta;", + + "fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, 0.0 ) ) );", + "if ( fDepth < shadowCoord.z ) shadow += shadowDelta;", + + "fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx0, dy1 ) ) );", + "if ( fDepth < shadowCoord.z ) shadow += shadowDelta;", + + "fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( 0.0, dy1 ) ) );", + "if ( fDepth < shadowCoord.z ) shadow += shadowDelta;", + + "fDepth = unpackDepth( texture2D( shadowMap[ i ], shadowCoord.xy + vec2( dx1, dy1 ) ) );", + "if ( fDepth < shadowCoord.z ) shadow += shadowDelta;", + "shadowColor = shadowColor * vec3( ( 1.0 - shadowDarkness * shadow ) );", "#else", @@ -812,7 +858,7 @@ THREE.ShaderChunk = { // spot with multiple shadows is darker - "shadowColor = shadowColor * vec3( shadowDarkness );", + "shadowColor = shadowColor * vec3( 1.0 - shadowDarkness );", // spot with multiple shadows has the same color as single shadow spot