diff --git a/build/Three.js b/build/Three.js index 3f027f5d3d29fca289fc98070a1736b49cb39388..832a6aaff0848b9b1b5597691d5ef8efb93ccf89 100644 --- a/build/Three.js +++ b/build/Three.js @@ -2,7 +2,7 @@ 'use strict';var THREE=THREE||{REVISION:"50dev"};self.console||(self.console={info:function(){},log:function(){},debug:function(){},warn:function(){},error:function(){}});self.Int32Array||(self.Int32Array=Array,self.Float32Array=Array); (function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},lerpSelf:function(a,b){this.r=this.r+(a.r-this.r)*b;this.g=this.g+(a.g-this.g)*b;this.b=this.b+(a.b-this.b)*b;return this},getHex:function(){return Math.floor(this.r*255)<<16^Math.floor(this.g*255)<<8^Math.floor(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; @@ -24,14 +24,14 @@ THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x= this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;this.w=this.w-a.w;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;this.w=this.w*a;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a;this.w=this.w/a}else{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=this.x+(a.x-this.x)*b;this.y=this.y+(a.y-this.y)*b;this.z=this.z+(a.z-this.z)*b;this.w=this.w+(a.w-this.w)*b;return this},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);if(b<1.0E-4){this.x=1;this.z=this.y=0}else{this.x=a.x/b;this.y= a.y/b;this.z=a.z/b}return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],i=a[9];c=a[2];b=a[6];var j=a[10];if(Math.abs(d-g)<0.01&&Math.abs(f-c)<0.01&&Math.abs(i-b)<0.01){if(Math.abs(d+g)<0.1&&Math.abs(f+c)<0.1&&Math.abs(i+b)<0.1&&Math.abs(e+h+j-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;e=(e+1)/2;h=(h+1)/2;j=(j+1)/2;d=(d+g)/4;f=(f+c)/4;i=(i+b)/4;if(e>h&&e>j)if(e<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(e);c=d/b;d=f/b}else if(h> -j)if(h<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(h);b=d/c;d=i/c}else if(j<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(j);b=f/d;c=i/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(f-c)*(f-c)+(g-d)*(g-d));Math.abs(a)<0.001&&(a=1);this.x=(b-i)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+j-1)/2);return this}}; +j)if(h<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(h);b=d/c;d=i/c}else if(j<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(j);b=f/d;c=i/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-i)*(b-i)+(f-c)*(f-c)+(g-d)*(g-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-i)/a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+j-1)/2);return this}}; THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){a[b]===void 0&&(a[b]=[]);a[b].indexOf(c)===-1&&a[b].push(c)};this.dispatchEvent=function(b){for(var c in a[b.type])a[b.type][c](b)};this.removeEventListener=function(b,c){var d=a[b].indexOf(c);d!==-1&&a[b].splice(d,1)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]}; THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes,d=a.elements,a=d[0];b=d[1];var e=d[2],f=d[3],g=d[4],h=d[5],i=d[6],j=d[7],l=d[8],o=d[9],m=d[10],p=d[11],r=d[12],n=d[13],q=d[14],d=d[15];c[0].set(f-a,j-g,p-l,d-r);c[1].set(f+a,j+g,p+l,d+r);c[2].set(f+b,j+h,p+o,d+n);c[3].set(f-b,j-h,p-o,d-n);c[4].set(f-e,j-i,p-m,d-q);c[5].set(f+e,j+i,p+m,d+q);for(a=0;a<6;a++){b=c[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}}; THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=c.elements,c=-a.geometry.boundingSphere.radius*c.getMaxScaleOnAxis(),e=0;e<6;e++){a=b[e].x*d[12]+b[e].y*d[13]+b[e].z*d[14]+b[e].w;if(a<=c)return false}return true};THREE.Frustum.__v1=new THREE.Vector3; THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,l=new THREE.Vector3,o=new THREE.Vector3,m=new THREE.Vector3,p=function(a,b){return a.distance-b.distance},r=new THREE.Vector3,n=new THREE.Vector3,q=new THREE.Vector3,t,u,w,s=function(a,b,c){r.sub(c,a);t=r.dot(b);u=n.add(a,q.copy(b).multiplyScalar(t)); -return w=c.distanceTo(u)},x,F,C,z,v,H,I,N,R=function(a,b,c,d){r.sub(d,b);n.sub(c,b);q.sub(a,b);x=r.dot(r);F=r.dot(n);C=r.dot(q);z=n.dot(n);v=n.dot(q);H=1/(x*z-F*F);I=(z*C-F*v)*H;N=(x*v-F*C)*H;return I>=0&&N>=0&&I+N<1},X=1.0E-4;this.setPrecision=function(a){X=a};this.intersectObject=function(a){var b,c=[];if(a instanceof THREE.Particle){w=s(this.origin,this.direction,a.matrixWorld.getPosition());if(w>a.scale.x)return[];b={distance:w,point:a.position,face:null,object:a};c.push(b)}else if(a instanceof +return w=c.distanceTo(u)},x,F,C,z,v,H,I,N,R=function(a,b,c,d){r.sub(d,b);n.sub(c,b);q.sub(a,b);x=r.dot(r);F=r.dot(n);C=r.dot(q);z=n.dot(n);v=n.dot(q);H=1/(x*z-F*F);I=(z*C-F*v)*H;N=(x*v-F*C)*H;return I>=0&&N>=0&&I+N<1},Y=1.0E-4;this.setPrecision=function(a){Y=a};this.intersectObject=function(a){var b,c=[];if(a instanceof THREE.Particle){w=s(this.origin,this.direction,a.matrixWorld.getPosition());if(w>a.scale.x)return[];b={distance:w,point:a.position,face:null,object:a};c.push(b)}else if(a instanceof THREE.Mesh){var d=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length()),d=a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z));w=s(this.origin,this.direction,a.matrixWorld.getPosition());if(w>d)return c;var k,n,r,q=a.geometry,t=q.vertices,u;a.matrixRotationWorld.extractRotation(a.matrixWorld);d=0;for(k=q.faces.length;d0:n<0))){m.add(i,j.multiplyScalar(r));w=i.distanceTo(m);if(!(wthis.far))if(b instanceof THREE.Face3){e=u.multiplyVector3(e.copy(t[b.a]));f=u.multiplyVector3(f.copy(t[b.b]));g=u.multiplyVector3(g.copy(t[b.c]));if(R(m,e,f,g)){b={distance:w,point:m.clone(),face:b,object:a};c.push(b)}}else if(b instanceof THREE.Face4){e=u.multiplyVector3(e.copy(t[b.a])); +o=a.matrixRotationWorld.multiplyVector3(o.copy(b.normal));n=j.dot(o);if(!(Math.abs(n)0:n<0))){m.add(i,j.multiplyScalar(r));w=i.distanceTo(m);if(!(wthis.far))if(b instanceof THREE.Face3){e=u.multiplyVector3(e.copy(t[b.a]));f=u.multiplyVector3(f.copy(t[b.b]));g=u.multiplyVector3(g.copy(t[b.c]));if(R(m,e,f,g)){b={distance:w,point:m.clone(),face:b,object:a};c.push(b)}}else if(b instanceof THREE.Face4){e=u.multiplyVector3(e.copy(t[b.a])); f=u.multiplyVector3(f.copy(t[b.b]));g=u.multiplyVector3(g.copy(t[b.c]));h=u.multiplyVector3(h.copy(t[b.d]));if(R(m,e,f,h)||R(m,f,g,h)){b={distance:w,point:m.clone(),face:b,object:a};c.push(b)}}}}}}c.sort(p);return c};this.intersectObjects=function(a){for(var b=[],c=0,d=a.length;cf?d:f;e=e>g? e:g}a()};this.add3Points=function(f,g,l,o,m,p){if(h){h=false;b=fl?f>m?f:m:l>m?l:m;e=g>o?g>p?g:p:o>p?o:p}else{b=fl?f>m?f>d?f:d:m>d?m:d:l>m?l>d?l:d:m>d?m:d;e=g>o?g>p?g>e?g:e:p>e?p:e:o>p?o>e?o:e:p>e?p:e}a()};this.addRectangle=function(f){if(h){h=false;b=f.getLeft();c=f.getTop();d=f.getRight();e=f.getBottom()}else{b=b=0&&f>=0&&g>=0&&h>=0)return true;if(e<0&&f<0||g<0&&h<0)return false;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)));if(dg&&h.positionScreen.z0)){K=j[i-2];I.copy(aa.positionScreen);N.copy(K.positionScreen);if(d(I,N)){I.multiplyScalar(1/I.w);N.multiplyScalar(1/N.w);Y=t[q]=t[q]||new THREE.RenderableLine;q++;n=Y;n.v1.positionScreen.copy(I); +l.centroidWorld.copy(M.centroid);Z.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);z.multiplyVector3(l.centroidScreen);ca=M.vertexNormals;aa=0;for(K=ca.length;aa0)){K=j[i-2];I.copy(aa.positionScreen);N.copy(K.positionScreen);if(d(I,N)){I.multiplyScalar(1/I.w);N.multiplyScalar(1/N.w);X=t[q]=t[q]||new THREE.RenderableLine;q++;n=X;n.v1.positionScreen.copy(I); n.v2.positionScreen.copy(N);n.z=Math.max(I.z,N.z);n.material=O.material;x.elements.push(n)}}}}}a=0;for(k=x.sprites.length;a0&&C.z<1){g=s[w]=s[w]||new THREE.RenderableParticle;w++;u=g;u.x=C.x/C.w;u.y=C.y/C.w;u.z=C.z;u.rotation=O.rotation.z;u.scale.x=O.scale.x*Math.abs(u.x-(C.x+e.projectionMatrix.elements[0])/(C.w+e.projectionMatrix.elements[12])); u.scale.y=O.scale.y*Math.abs(u.y-(C.y+e.projectionMatrix.elements[5])/(C.w+e.projectionMatrix.elements[13]));u.material=O.material;x.elements.push(u)}}}f&&x.elements.sort(c);return x}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1}; THREE.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,b){var c=b||"XYZ",d=Math.cos(a.x/2),e=Math.cos(a.y/2),f=Math.cos(a.z/2),g=Math.sin(a.x/2),h=Math.sin(a.y/2),i=Math.sin(a.z/2);switch(c){case "YXZ":this.x=g*e*f+d*h*i;this.y=d*h*f-g*e*i;this.z=d*e*i-g*h*f;this.w=d*e*f+g*h*i;break;case "ZXY":this.x=g*e*f-d*h*i;this.y=d*h*f+g*e* @@ -87,9 +87,9 @@ i;this.z=d*e*i+g*h*f;this.w=d*e*f-g*h*i;break;case "ZYX":this.x=g*e*f-d*h*i;this d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],i=b[6],b=b[10],j=c+f+b;if(j>0){c=0.5/Math.sqrt(j+1);this.w=0.25/c;this.x=(i-g)*c;this.y=(d-h)*c;this.z=(e-a)*c}else if(c>f&&c>b){c=2*Math.sqrt(1+c-f-b);this.w=(i-g)/c;this.x=0.25*c;this.y=(a+e)/c;this.z=(d+h)/c}else if(f>b){c=2*Math.sqrt(1+f-c-b);this.w=(d-h)/c;this.x=(a+e)/c;this.y=0.25*c;this.z=(g+i)/c}else{c=2*Math.sqrt(1+b-c-f);this.w=(e-a)/c;this.x= (d+h)/c;this.y=(g+i)/c;this.z=0.25*c}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=this.x*-1;this.y=this.y*-1;this.z=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);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y= this.y*a;this.z=this.z*a;this.w=this.w*a}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},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},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,l=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+l*-h-o*-g;b.y=l*i+c*-g+o*-f-j*-h;b.z=o*i+c*-h+j*-g-l*-f;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,e=this.z,f=this.w,g=f*a.w+c*a.x+d*a.y+e*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=f;this.x=c;this.y=d;this.z=e;return this}var h=Math.acos(g),i=Math.sqrt(1-g*g);if(Math.abs(i)<0.001){this.w=0.5*(f+this.w);this.x=0.5*(c+this.x); +f=this.x,g=this.y,h=this.z,i=this.w,j=i*c+g*e-h*d,l=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+l*-h-o*-g;b.y=l*i+c*-g+o*-f-j*-h;b.z=o*i+c*-h+j*-g-l*-f;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,e=this.z,f=this.w,g=f*a.w+c*a.x+d*a.y+e*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=f;this.x=c;this.y=d;this.z=e;return this}var h=Math.acos(g),i=Math.sqrt(1-g*g);if(Math.abs(i)<0.0010){this.w=0.5*(f+this.w);this.x=0.5*(c+this.x); this.y=0.5*(d+this.y);this.z=0.5*(e+this.z);return this}g=Math.sin((1-b)*h)/i;h=Math.sin(b*h)/i;this.w=f*g+this.w*h;this.x=c*g+this.x*h;this.y=d*g+this.y*h;this.z=e*g+this.z*h;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}}; -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;if(e<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;e=-e}else c.copy(b);if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}e=Math.sin((1-d)*b)/f;d=Math.sin(d*b)/f;c.w=a.w*e+c.w*d;c.x=a.x*e+c.x*d;c.y=a.y*e+c.y*d;c.z=a.z*e+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")}; +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;if(e<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;e=-e}else c.copy(b);if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}e=Math.sin((1-d)*b)/f;d=Math.sin(d*b)/f;c.w=a.w*e+c.w*d;c.x=a.x*e+c.x*d;c.y=a.y*e+c.y*d;c.z=a.z*e+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")}; 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.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;dc.x)c.x= +Y.cross(f.vertexNormals[d],z);e=Y.dot(H[e]);e=e<0?-1:1;f.vertexTangents[d]=new THREE.Vector4(R.x,R.y,R.z,e)}}this.hasTangents=true},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(this.vertices.length>0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);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}}else{this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};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,h;f=0;for(g=this.vertices.length;f0;a--)if(d.indexOf(e["abcd"[a]])!=a){d.splice(a,1);this.faces[f]=new THREE.Face3(d[0],d[1],d[2]);e=0;for(d=this.faceVertexUvs.length;e1&&(N=new THREE.MeshFaceMaterial); a=new THREE.Mesh(I,N);a.name=m;if(u){a.matrixAutoUpdate=false;a.matrix.set(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],u[9],u[10],u[11],u[12],u[13],u[14],u[15])}else{a.position.set(x[0],x[1],x[2]);if(C){a.quaternion.set(C[0],C[1],C[2],C[3]);a.useQuaternion=true}else a.rotation.set(F[0],F[1],F[2]);a.scale.set(z[0],z[1],z[2])}a.visible=t.visible;a.doubleSided=t.doubleSided;a.castShadow=t.castShadow;a.receiveShadow=t.receiveShadow;M.scene.add(a);M.objects[m]=a}}else{x=t.position;F=t.rotation;C=t.quaternion; z=t.scale;C=0;a=new THREE.Object3D;a.name=m;a.position.set(x[0],x[1],x[2]);if(C){a.quaternion.set(C[0],C[1],C[2],C[3]);a.useQuaternion=true}else a.rotation.set(F[0],F[1],F[2]);a.scale.set(z[0],z[1],z[2]);a.visible=t.visible!==void 0?t.visible:false;M.scene.add(a);M.objects[m]=a;M.empties[m]=a}}}function f(a){return function(b){M.geometries[a]=b;e();Q=Q-1;i.onLoadComplete();h()}}function g(a){return function(b){M.geometries[a]=b}}function h(){i.callbackProgress({totalModels:k,totalTextures:P,loadedModels:k- -Q,loadedTextures:P-D},M);i.onLoadProgress();Q==0&&D==0&&b(M)}var i=this,j=THREE.Loader.prototype.extractUrlBase(c),l,o,m,p,r,n,q,t,u,w,s,x,F,C,z,v,H,I,N,R,X,B,G,Q,D,k,P,M;B=a;c=new THREE.BinaryLoader;G=new THREE.JSONLoader;D=Q=0;M={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(B.transform){a=B.transform.position;w=B.transform.rotation;v=B.transform.scale;a&&M.scene.position.set(a[0],a[1],a[2]);w&&M.scene.rotation.set(w[0],w[1], -w[2]);v&&M.scene.scale.set(v[0],v[1],v[2]);if(a||w||v){M.scene.updateMatrix();M.scene.updateMatrixWorld()}}a=function(){D=D-1;h();i.onLoadComplete()};for(r in B.cameras){v=B.cameras[r];v.type=="perspective"?R=new THREE.PerspectiveCamera(v.fov,v.aspect,v.near,v.far):v.type=="ortho"&&(R=new THREE.OrthographicCamera(v.left,v.right,v.top,v.bottom,v.near,v.far));x=v.position;w=v.target;v=v.up;R.position.set(x[0],x[1],x[2]);R.target=new THREE.Vector3(w[0],w[1],w[2]);v&&R.up.set(v[0],v[1],v[2]);M.cameras[r]= -R}for(p in B.lights){w=B.lights[p];r=w.color!==void 0?w.color:16777215;R=w.intensity!==void 0?w.intensity:1;if(w.type=="directional"){x=w.direction;s=new THREE.DirectionalLight(r,R);s.position.set(x[0],x[1],x[2]);s.position.normalize()}else if(w.type=="point"){x=w.position;s=w.distance;s=new THREE.PointLight(r,R,s);s.position.set(x[0],x[1],x[2])}else w.type=="ambient"&&(s=new THREE.AmbientLight(r));M.scene.add(s);M.lights[p]=s}for(n in B.fogs){p=B.fogs[n];p.type=="linear"?X=new THREE.Fog(0,p.near, -p.far):p.type=="exp2"&&(X=new THREE.FogExp2(0,p.density));v=p.color;X.color.setRGB(v[0],v[1],v[2]);M.fogs[n]=X}if(M.cameras&&B.defaults.camera)M.currentCamera=M.cameras[B.defaults.camera];if(M.fogs&&B.defaults.fog)M.scene.fog=M.fogs[B.defaults.fog];v=B.defaults.bgcolor;M.bgColor=new THREE.Color;M.bgColor.setRGB(v[0],v[1],v[2]);M.bgColorAlpha=B.defaults.bgalpha;for(l in B.geometries){n=B.geometries[l];if(n.type=="bin_mesh"||n.type=="ascii_mesh"){Q=Q+1;i.onLoadStart()}}k=Q;for(l in B.geometries){n= -B.geometries[l];if(n.type=="cube"){I=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides);M.geometries[l]=I}else if(n.type=="plane"){I=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight);M.geometries[l]=I}else if(n.type=="sphere"){I=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight);M.geometries[l]=I}else if(n.type=="cylinder"){I=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs, -n.heightSegs);M.geometries[l]=I}else if(n.type=="torus"){I=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT);M.geometries[l]=I}else if(n.type=="icosahedron"){I=new THREE.IcosahedronGeometry(n.radius,n.subdivisions);M.geometries[l]=I}else if(n.type=="bin_mesh")c.load(d(n.url,B.urlBaseType),f(l));else if(n.type=="ascii_mesh")G.load(d(n.url,B.urlBaseType),f(l));else if(n.type=="embedded_mesh"){n=B.embeds[n.id];n.metadata=B.metadata;n&&G.createModel(n,g(l),"")}}for(q in B.textures){l=B.textures[q]; -if(l.url instanceof Array){D=D+l.url.length;for(n=0;n0){c(THREE.NormalBlending); b(1);e("rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+t+")");n.fillRect(Math.floor(Ba.getX()),Math.floor(Ba.getY()),Math.floor(Ba.getWidth()),Math.floor(Ba.getHeight()))}Ba.empty()}};this.render=function(a,l){function m(a){var b,c,d,e;wa.setRGB(0,0,0);Oa.setRGB(0,0,0);Da.setRGB(0,0,0);b=0;for(c=a.length;b255?255:e;Ra[1]=f<0?0:f>255?255:f;Ra[2]=a<0?0:a>255?255:a;Ra[4]=g< 0){e=1/Math.sqrt(e);c=c*e;d=d*e;b.x=b.x+c;b.y=b.y+d;a.x=a.x-c;a.y=a.y-d}}var Dc,ad,Ja,hb;this.autoClear?this.clear():n.setTransform(1,0,0,-1,p,r);f.info.render.vertices=0;f.info.render.faces=0;g=j.projectScene(a,l,this.sortElements);h=g.elements;i=g.lights;(gb=i.length>0)&&m(i);Dc=0;for(ad=h.length;Dc=0;c--)a[c].object===b&&a.splice(c,1)}function n(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){if(d.needsUpdate){d.program&&D.deallocateMaterial(d);D.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences)e.__webglMorphTargetInfluences=new Float32Array(D.maxMorphTargets);var f=false,g=d.program,h=g.uniforms,i=d.uniforms;if(g!==S){k.useProgram(g);S=g;f=true}if(d.id!==K){K=d.id;f=true}if(f||a!==fa){k.uniformMatrix4fv(h.projectionMatrix, false,a._projectionMatrixArray);a!==fa&&(fa=a)}if(f){if(c&&d.fog){i.fogColor.value=c.color;if(c instanceof THREE.Fog){i.fogNear.value=c.near;i.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)i.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(la){for(var j,l=0,m=0,n=0,o,p,r,q=ob,t=q.directional.colors,u=q.directional.positions,v=q.point.colors,w=q.point.positions,x=q.point.distances,F=q.spot.colors,B=q.spot.positions,H=q.spot.distances, -Z=q.spot.directions,I=q.spot.angles,G=q.spot.exponents,N=0,M=0,Y=0,O=r=0,c=O=0,f=b.length;c0};this.setSize=function(a,b){z.width=a;z.height=b;this.setViewport(0,0,z.width,z.height)};this.setViewport=function(a,b,c,d){Lb=a;mb=b;jb=c;nb=d;k.viewport(Lb,mb,jb,nb)};this.setScissor=function(a,b,c,d){k.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?k.enable(k.SCISSOR_TEST):k.disable(k.SCISSOR_TEST)};this.setClearColorHex=function(a,b){B.setHex(a);G=b;k.clearColor(B.r,B.g,B.b,G)};this.setClearColor=function(a, b){B.copy(a);G=b;k.clearColor(B.r,B.g,B.b,G)};this.getClearColor=function(){return B};this.getClearAlpha=function(){return G};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d=d|k.COLOR_BUFFER_BIT;if(b===void 0||b)d=d|k.DEPTH_BUFFER_BIT;if(c===void 0||c)d=d|k.STENCIL_BUFFER_BIT;k.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)}; @@ -345,7 +346,7 @@ this.deallocateObject=function(a){if(a.__webglInit){a.__webglInit=false;delete a k.deleteBuffer(c.__webglSkinVertexABuffer);k.deleteBuffer(c.__webglSkinVertexBBuffer);k.deleteBuffer(c.__webglSkinIndicesBuffer);k.deleteBuffer(c.__webglSkinWeightsBuffer);k.deleteBuffer(c.__webglFaceBuffer);k.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets){d=0;for(e=c.numMorphTargets;d65535){F[x].counter=F[x].counter+1;z=F[x].hash+"_"+F[x].counter;q.geometryGroups[z]===void 0&&(q.geometryGroups[z]={faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:C,numMorphNormals:B})}u instanceof THREE.Face3?q.geometryGroups[z].faces3.push(s):q.geometryGroups[z].faces4.push(s);q.geometryGroups[z].vertices=q.geometryGroups[z].vertices+w}q.geometryGroupsList= [];var H=void 0;for(H in q.geometryGroups){q.geometryGroups[H].id=O++;q.geometryGroupsList.push(q.geometryGroups[H])}}for(i in j.geometryGroups){l=j.geometryGroups[i];if(!l.__webglVertexBuffer){var K=l;K.__webglVertexBuffer=k.createBuffer();K.__webglNormalBuffer=k.createBuffer();K.__webglTangentBuffer=k.createBuffer();K.__webglColorBuffer=k.createBuffer();K.__webglUVBuffer=k.createBuffer();K.__webglUV2Buffer=k.createBuffer();K.__webglSkinVertexABuffer=k.createBuffer();K.__webglSkinVertexBBuffer=k.createBuffer(); K.__webglSkinIndicesBuffer=k.createBuffer();K.__webglSkinWeightsBuffer=k.createBuffer();K.__webglFaceBuffer=k.createBuffer();K.__webglLineBuffer=k.createBuffer();var Z=void 0,I=void 0;if(K.numMorphTargets){K.__webglMorphTargetsBuffers=[];Z=0;for(I=K.numMorphTargets;Z0||Y.faceVertexUvs.length>0)G.__uvArray=new Float32Array(S*2);if(Y.faceUvs.length>1||Y.faceVertexUvs.length>1)G.__uv2Array= +l,N=g,X=N.geometry,M=G.faces3,$=G.faces4,S=M.length*3+$.length*4,Q=M.length*1+$.length*2,R=M.length*3+$.length*4,P=c(N,G),aa=e(P),Y=d(P),fa=P.vertexColors?P.vertexColors:false;G.__vertexArray=new Float32Array(S*3);if(Y)G.__normalArray=new Float32Array(S*3);if(X.hasTangents)G.__tangentArray=new Float32Array(S*4);if(fa)G.__colorArray=new Float32Array(S*3);if(aa){if(X.faceUvs.length>0||X.faceVertexUvs.length>0)G.__uvArray=new Float32Array(S*2);if(X.faceUvs.length>1||X.faceVertexUvs.length>1)G.__uv2Array= new Float32Array(S*2)}if(N.geometry.skinWeights.length&&N.geometry.skinIndices.length){G.__skinVertexAArray=new Float32Array(S*4);G.__skinVertexBArray=new Float32Array(S*4);G.__skinIndexArray=new Float32Array(S*4);G.__skinWeightArray=new Float32Array(S*4)}G.__faceArray=new Uint16Array(Q*3);G.__lineArray=new Uint16Array(R*2);var ca=void 0,ha=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=[];ca=0;for(ha=G.numMorphTargets;ca=0&&k.enableVertexAttribArray(r.position);r.color>=0&&k.enableVertexAttribArray(r.color);r.normal>=0&&k.enableVertexAttribArray(r.normal);r.tangent>=0&&k.enableVertexAttribArray(r.tangent);if(a.skinning&&r.skinVertexA>=0&&r.skinVertexB>=0&&r.skinIndex>=0&&r.skinWeight>=0){k.enableVertexAttribArray(r.skinVertexA);k.enableVertexAttribArray(r.skinVertexB);k.enableVertexAttribArray(r.skinIndex);k.enableVertexAttribArray(r.skinWeight)}if(a.attributes)for(f in a.attributes)r[f]!==void 0&&r[f]>= 0&&k.enableVertexAttribArray(r[f]);if(a.morphTargets){a.numSupportedMorphTargets=0;b="morphTarget";for(f=0;f=0){k.enableVertexAttribArray(r[s]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;b="morphNormal";for(f=0;f=0){k.enableVertexAttribArray(r[s]);a.numSupportedMorphNormals++}}}a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a, b){if(a){!b||b==="ccw"?k.frontFace(k.CCW):k.frontFace(k.CW);a==="back"?k.cullFace(k.BACK):a==="front"?k.cullFace(k.FRONT):k.cullFace(k.FRONT_AND_BACK);k.enable(k.CULL_FACE)}else k.disable(k.CULL_FACE)};this.setObjectFaces=function(a){if(Z!==a.doubleSided){a.doubleSided?k.disable(k.CULL_FACE):k.enable(k.CULL_FACE);Z=a.doubleSided}if($!==a.flipSided){a.flipSided?k.frontFace(k.CW):k.frontFace(k.CCW);$=a.flipSided}};this.setDepthTest=function(a){if(Na!==a){a?k.enable(k.DEPTH_TEST):k.disable(k.DEPTH_TEST); -Na=a}};this.setDepthWrite=function(a){if(oa!==a){k.depthMask(a);oa=a}};this.setBlending=function(a,b,c,d){if(a!==Y){switch(a){case THREE.NoBlending:k.disable(k.BLEND);break;case THREE.AdditiveBlending:k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE);break;case THREE.SubtractiveBlending:k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO, -k.SRC_COLOR);break;case THREE.CustomBlending:k.enable(k.BLEND);break;default:k.enable(k.BLEND);k.blendEquationSeparate(k.FUNC_ADD,k.FUNC_ADD);k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)}Y=a}if(a===THREE.CustomBlending){if(b!==ha){k.blendEquation(C(b));ha=b}if(c!==Sa||d!==La){k.blendFunc(C(c),C(d));Sa=c;La=d}}else La=Sa=ha=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=k.createTexture();D.info.memory.textures++}k.activeTexture(k.TEXTURE0+ +Na=a}};this.setDepthWrite=function(a){if(oa!==a){k.depthMask(a);oa=a}};this.setBlending=function(a,b,c,d){if(a!==X){switch(a){case THREE.NoBlending:k.disable(k.BLEND);break;case THREE.AdditiveBlending:k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE);break;case THREE.SubtractiveBlending:k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO, +k.SRC_COLOR);break;case THREE.CustomBlending:k.enable(k.BLEND);break;default:k.enable(k.BLEND);k.blendEquationSeparate(k.FUNC_ADD,k.FUNC_ADD);k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)}X=a}if(a===THREE.CustomBlending){if(b!==ha){k.blendEquation(C(b));ha=b}if(c!==Sa||d!==La){k.blendFunc(C(c),C(d));Sa=c;La=d}}else La=Sa=ha=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=k.createTexture();D.info.memory.textures++}k.activeTexture(k.TEXTURE0+ b);k.bindTexture(k.TEXTURE_2D,a.__webglTexture);k.pixelStorei(k.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=(c.width&c.width-1)===0&&(c.height&c.height-1)===0,e=C(a.format),f=C(a.type);s(k.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?k.texImage2D(k.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):k.texImage2D(k.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&k.generateMipmap(k.TEXTURE_2D);a.needsUpdate=false;if(a.onUpdate)a.onUpdate()}else{k.activeTexture(k.TEXTURE0+b);k.bindTexture(k.TEXTURE_2D, a.__webglTexture)}};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=true;if(a.stencilBuffer===void 0)a.stencilBuffer=true;a.__webglTexture=k.createTexture();var c=(a.width&a.width-1)===0&&(a.height&a.height-1)===0,d=C(a.format),e=C(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];k.bindTexture(k.TEXTURE_CUBE_MAP,a.__webglTexture);s(k.TEXTURE_CUBE_MAP,a,c);for(var f=0;f<6;f++){a.__webglFramebuffer[f]= k.createFramebuffer();a.__webglRenderbuffer[f]=k.createRenderbuffer();k.texImage2D(k.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=k.TEXTURE_CUBE_MAP_POSITIVE_X+f;k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer[f]);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,h,g.__webglTexture,0);x(a.__webglRenderbuffer[f],a)}c&&k.generateMipmap(k.TEXTURE_CUBE_MAP)}else{a.__webglFramebuffer=k.createFramebuffer();a.__webglRenderbuffer=k.createRenderbuffer();k.bindTexture(k.TEXTURE_2D, @@ -488,7 +489,7 @@ THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size: c+d;l=b[a++]*c;p=b[a++]*c+d;r=b[a++]*c;e.quadraticCurveTo(p,r,i,l);if(g=f[f.length-1]){o=g.x;m=g.y;g=1;for(h=this.divisions;g<=h;g++){var u=g/h;THREE.Shape.Utils.b2(u,o,p,i);THREE.Shape.Utils.b2(u,m,r,l)}}break;case "b":i=b[a++]*c+d;l=b[a++]*c;p=b[a++]*c+d;r=b[a++]*-c;n=b[a++]*c+d;q=b[a++]*-c;e.bezierCurveTo(i,l,p,r,n,q);if(g=f[f.length-1]){o=g.x;m=g.y;g=1;for(h=this.divisions;g<=h;g++){u=g/h;THREE.Shape.Utils.b3(u,o,p,n,i);THREE.Shape.Utils.b3(u,m,r,q,l)}}}}}return{offset:t.ha*c,path:e}}}}; THREE.FontUtils.generateShapes=function(a,b){var b=b||{},c=b.curveSegments!==void 0?b.curveSegments:4,d=b.font!==void 0?b.font:"helvetiker",e=b.weight!==void 0?b.weight:"normal",f=b.style!==void 0?b.style:"normal";THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=e;THREE.FontUtils.style=f;c=THREE.FontUtils.drawText(a).paths;d=[];e=0;for(f=c.length;e0)for(j=0;j2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");break}i=j;e<=i&&(i=0);j=i+1;e<=j&&(j=0);l=j+1;e<=l&&(l=0);var m;a:{m=a;var p=i,r=j,n=l,q=e,t=g,u=void 0,w=void 0,s=void 0,x=void 0,F=void 0, -C=void 0,z=void 0,v=void 0,H=void 0,w=m[t[p]].x,s=m[t[p]].y,x=m[t[r]].x,F=m[t[r]].y,C=m[t[n]].x,z=m[t[n]].y;if(1.0E-10>(x-w)*(z-s)-(F-s)*(C-w))m=false;else{for(u=0;u=0&&R>=0&&B>=0){m=false;break a}}m=true}}if(m){f.push([a[g[i]], +C=void 0,z=void 0,v=void 0,H=void 0,w=m[t[p]].x,s=m[t[p]].y,x=m[t[r]].x,F=m[t[r]].y,C=m[t[n]].x,z=m[t[n]].y;if(1.0E-10>(x-w)*(z-s)-(F-s)*(C-w))m=false;else{for(u=0;u=0&&R>=0&&B>=0){m=false;break a}}m=true}}if(m){f.push([a[g[i]], a[g[j]],a[g[l]]]);h.push([g[i],g[j],g[l]]);i=j;for(l=j+1;la.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){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]}; -THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.001;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;a=0;for(b=this.hierarchy.length;a=0?a:a+g;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange; b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(a){if(this.domElement=== document){this.mouseX=a.pageX-this.viewHalfX;this.mouseY=a.pageY-this.viewHalfY}else{this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX;this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY}};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}), c=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(g,b);a.position.set(0,10,0);this.animation=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}),p=0;p1?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=a*c.rotateSpeed; @@ -616,8 +617,7 @@ d.setFromAxisAngle(b,-a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.m b.addSelf(c.object.up.clone().setLength(a.y));c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?o=m:o.addSelf(a.sub(m,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){c.dispatchEvent(p);d.copy(c.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousemove",function(a){if(c.enabled){if(e){h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY);j=l=c.getMouseOnScreen(a.clientX,a.clientY);o= m=c.getMouseOnScreen(a.clientX,a.clientY);e=false}f!==-1&&(f===0&&!c.noRotate?i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===1&&!c.noZoom?l=c.getMouseOnScreen(a.clientX,a.clientY):f===2&&!c.noPan&&(m=c.getMouseOnScreen(a.clientX,a.clientY)))}},false);this.domElement.addEventListener("mousedown",function(a){if(c.enabled){a.preventDefault();a.stopPropagation();if(f===-1){f=a.button;f===0&&!c.noRotate?h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===1&&!c.noZoom?j=l=c.getMouseOnScreen(a.clientX, -a.clientY):this.noPan||(o=m=c.getMouseOnScreen(a.clientX,a.clientY))}}},false);this.domElement.addEventListener("mouseup",function(a){if(c.enabled){a.preventDefault();a.stopPropagation();f=-1}},false);window.addEventListener("keydown",function(a){if(c.enabled){a.preventDefault();if(f===-1){a.keyCode===c.keys[0]&&!c.noRotate?f=0:a.keyCode===c.keys[1]&&!c.noZoom?f=1:a.keyCode===c.keys[2]&&!c.noPan&&(f=2);f!==-1&&(e=true)}}},false);window.addEventListener("keyup",function(){c.enabled&&f!==-1&&(f=-1)}, -false)}; +a.clientY):this.noPan||(o=m=c.getMouseOnScreen(a.clientX,a.clientY))}}},false);this.domElement.addEventListener("mouseup",function(a){if(c.enabled){a.preventDefault();a.stopPropagation();f=-1}},false);window.addEventListener("keydown",function(a){if(c.enabled&&f===-1){a.keyCode===c.keys[0]&&!c.noRotate?f=0:a.keyCode===c.keys[1]&&!c.noZoom?f=1:a.keyCode===c.keys[2]&&!c.noPan&&(f=2);f!==-1&&(e=true)}},false);window.addEventListener("keyup",function(){c.enabled&&f!==-1&&(f=-1)},false)}; THREE.OrbitControls=function(a,b){var c,d,e;function f(){return 2*Math.PI/60/60*i.autoRotateSpeed}function g(a){a.preventDefault();if(s===c){o.set(a.clientX,a.clientY);m.sub(o,l);i.rotateLeft(2*Math.PI*m.x/j*i.userRotateSpeed);i.rotateUp(2*Math.PI*m.y/j*i.userRotateSpeed);l.copy(o)}else if(s===d){r.set(a.clientX,a.clientY);n.sub(r,p);n.y>0?i.zoomIn():i.zoomOut();p.copy(r)}}function h(){if(i.userRotate){document.removeEventListener("mousemove",g,false);document.removeEventListener("mouseup",h,false); s=e}}THREE.EventTarget.call(this);this.object=a;this.domElement=b!==void 0?b:document;this.center=new THREE.Vector3;this.userZoom=true;this.userZoomSpeed=1;this.userRotate=true;this.userRotateSpeed=1;this.autoRotate=false;this.autoRotateSpeed=2;var i=this,j=1800,l=new THREE.Vector2,o=new THREE.Vector2,m=new THREE.Vector2,p=new THREE.Vector2,r=new THREE.Vector2,n=new THREE.Vector2,q=0,t=0,u=1,w=new THREE.Vector3;e=-1;c=0;d=1;var s=e,x={type:"change"};this.rotateLeft=function(a){a===void 0&&(a=f()); t=t-a};this.rotateRight=function(a){a===void 0&&(a=f());t=t+a};this.rotateUp=function(a){a===void 0&&(a=f());q=q-a};this.rotateDown=function(a){a===void 0&&(a=f());q=q+a};this.zoomIn=function(a){a===void 0&&(a=Math.pow(0.95,i.userZoomSpeed));u=u/a};this.zoomOut=function(a){a===void 0&&(a=Math.pow(0.95,i.userZoomSpeed));u=u*a};this.update=function(){var a=this.object.position,b=a.clone().subSelf(this.center),c=Math.atan2(b.x,b.z),d=Math.atan2(Math.sqrt(b.x*b.x+b.z*b.z),b.y);this.autoRotate&&this.rotateLeft(f()); @@ -636,10 +636,10 @@ THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||cons h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);if(f===0){console.log("Either infinite or no solutions!");g===0?console.log("Its finite solutions."):console.log("Too bad, no solutions.")}g=g/f;if(g<0){b=Math.atan2(b.y-a.y,b.x-a.x);a=Math.atan2(c.y-a.y,c.x-a.x);b>a&&(a=a+Math.PI*2);c=(b+a)/2;a=-Math.cos(c);c=-Math.sin(c);return new THREE.Vector2(a,c)}return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(c,d){var e,f;for(K=c.length;--K>=0;){e=K;f=K-1;f<0&&(f= c.length-1);for(var g=0,h=m+l*2,g=0;g=0;G--){D=G/l;k=i*(1-D);Q=j*Math.sin(D*Math.PI/2);K=0;for(D=B.length;K0;)this.smooth(a)}; THREE.SubdivisionModifier.prototype.smooth=function(a){function b(){m.debug&&console.log.apply(console,arguments)}function c(){console&&console.log.apply(console,arguments)}function d(a,c,d,e,g,h,i){var j=new THREE.Face4(a,c,d,e,null,g.color,g.materialIndex);if(m.useOldVertexColors){j.vertexColors=[];for(var k,n,p,q=0;q<4;q++){p=h[q];k=new THREE.Color;k.setRGB(0,0,0);for(var r=0;r=w&&a0&&H.x0&& +1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(C.vertex,2,b.FLOAT,false,16,0);b.vertexAttribPointer(C.uv,2,b.FLOAT,false,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(false);var N,R,Y,B,G;for(N=0;N0&&H.x0&& H.y0.001&&G.scale>0.001){v.x=G.x;v.y=G.y;v.z=G.z;C=G.size*G.scale/t;z.x=C*s;z.y=C;b.uniform3f(I.screenPosition,v.x,v.y,v.z);b.uniform2f(I.scale,z.x,z.y);b.uniform1f(I.rotation,G.rotation);b.uniform1f(I.opacity,G.opacity); +b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);B.positionScreen.copy(v);B.customUpdateCallback?B.customUpdateCallback(B):B.updateLensFlares();b.uniform1i(I.renderType,2);b.enable(b.BLEND);R=0;for(Y=B.lensFlares.length;R0.0010&&G.scale>0.0010){v.x=G.x;v.y=G.y;v.z=G.z;C=G.size*G.scale/t;z.x=C*s;z.y=C;b.uniform3f(I.screenPosition,v.x,v.y,v.z);b.uniform2f(I.scale,z.x,z.y);b.uniform1f(I.rotation,G.rotation);b.uniform1f(I.opacity,G.opacity); b.uniform3f(I.color,G.color.r,G.color.g,G.color.b);c.setBlending(G.blending,G.blendEquation,G.blendSrc,G.blendDst);c.setTexture(G.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}}; THREE.ShadowMapPlugin=function(){var a,b,c,d,e=new THREE.Frustum,f=new THREE.Matrix4,g=new THREE.Vector3,h=new THREE.Vector3;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:true});c._shadowPass=true;d._shadowPass=true};this.render= function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(i,j){var l,o,m,p,r,n,q,t,u,w=[];p=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);b.shadowMapCullFrontFaces?a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);l=0;for(o=i.__lights.length;lm&&f>l)if(f<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(f);c=d/b;d=e/b}else if(m> -l)if(m<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(m);b=d/c;d=k/c}else if(l<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(l);b=e/d;c=k/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(e-c)*(e-c)+(g-d)*(g-d));Math.abs(a)<0.001&&(a=1);this.x=(b-k)/a;this.y=(e-c)/a;this.z=(g-d)/a;this.w=Math.acos((f+m+l-1)/2);return this}}; +l)if(m<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(m);b=d/c;d=k/c}else if(l<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(l);b=e/d;c=k/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(e-c)*(e-c)+(g-d)*(g-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-k)/a;this.y=(e-c)/a;this.z=(g-d)/a;this.w=Math.acos((f+m+l-1)/2);return this}}; THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){a[b]===void 0&&(a[b]=[]);a[b].indexOf(c)===-1&&a[b].push(c)};this.dispatchEvent=function(b){for(var c in a[b.type])a[b.type][c](b)};this.removeEventListener=function(b,c){var d=a[b].indexOf(c);d!==-1&&a[b].splice(d,1)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]}; THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes,d=a.elements,a=d[0];b=d[1];var f=d[2],e=d[3],g=d[4],m=d[5],k=d[6],l=d[7],h=d[8],n=d[9],j=d[10],o=d[11],q=d[12],i=d[13],p=d[14],d=d[15];c[0].set(e-a,l-g,o-h,d-q);c[1].set(e+a,l+g,o+h,d+q);c[2].set(e+b,l+m,o+n,d+i);c[3].set(e-b,l-m,o-n,d-i);c[4].set(e-f,l-k,o-j,d-p);c[5].set(e+f,l+k,o+j,d+p);for(a=0;a<6;a++){b=c[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}}; THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=c.elements,c=-a.geometry.boundingSphere.radius*c.getMaxScaleOnAxis(),f=0;f<6;f++){a=b[f].x*d[12]+b[f].y*d[13]+b[f].z*d[14]+b[f].w;if(a<=c)return false}return true};THREE.Frustum.__v1=new THREE.Vector3; THREE.Ray=function(a,b,c,d){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.near=c||0;this.far=d||Infinity;var f=new THREE.Vector3,e=new THREE.Vector3,g=new THREE.Vector3,m=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3,j=new THREE.Vector3,o=function(a,b){return a.distance-b.distance},q=new THREE.Vector3,i=new THREE.Vector3,p=new THREE.Vector3,r,s,v,A=function(a,b,c){q.sub(c,a);r=q.dot(b);s=i.add(a,p.copy(b).multiplyScalar(r)); -return v=c.distanceTo(s)},w,B,x,F,u,z,D,H,P=function(a,b,c,d){q.sub(d,b);i.sub(c,b);p.sub(a,b);w=q.dot(q);B=q.dot(i);x=q.dot(p);F=i.dot(i);u=i.dot(p);z=1/(w*F-B*B);D=(F*x-B*u)*z;H=(w*u-B*x)*z;return D>=0&&H>=0&&D+H<1},L=1.0E-4;this.setPrecision=function(a){L=a};this.intersectObject=function(a){var b,c=[];if(a instanceof THREE.Particle){v=A(this.origin,this.direction,a.matrixWorld.getPosition());if(v>a.scale.x)return[];b={distance:v,point:a.position,face:null,object:a};c.push(b)}else if(a instanceof +return v=c.distanceTo(s)},w,B,x,F,u,z,D,H,P=function(a,b,c,d){q.sub(d,b);i.sub(c,b);p.sub(a,b);w=q.dot(q);B=q.dot(i);x=q.dot(p);F=i.dot(i);u=i.dot(p);z=1/(w*F-B*B);D=(F*x-B*u)*z;H=(w*u-B*x)*z;return D>=0&&H>=0&&D+H<1},M=1.0E-4;this.setPrecision=function(a){M=a};this.intersectObject=function(a){var b,c=[];if(a instanceof THREE.Particle){v=A(this.origin,this.direction,a.matrixWorld.getPosition());if(v>a.scale.x)return[];b={distance:v,point:a.position,face:null,object:a};c.push(b)}else if(a instanceof THREE.Mesh){var d=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length()),d=a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z));v=A(this.origin,this.direction,a.matrixWorld.getPosition());if(v>d)return c;var i,q,y,S=a.geometry,p=S.vertices,r;a.matrixRotationWorld.extractRotation(a.matrixWorld);d=0;for(i=S.faces.length;d0:q<0))){j.add(k,l.multiplyScalar(y));v=k.distanceTo(j);if(!(vthis.far))if(b instanceof THREE.Face3){f=r.multiplyVector3(f.copy(p[b.a]));e=r.multiplyVector3(e.copy(p[b.b]));g=r.multiplyVector3(g.copy(p[b.c]));if(P(j,f,e,g)){b={distance:v,point:j.clone(),face:b,object:a};c.push(b)}}else if(b instanceof THREE.Face4){f=r.multiplyVector3(f.copy(p[b.a])); +n=a.matrixRotationWorld.multiplyVector3(n.copy(b.normal));q=l.dot(n);if(!(Math.abs(q)0:q<0))){j.add(k,l.multiplyScalar(y));v=k.distanceTo(j);if(!(vthis.far))if(b instanceof THREE.Face3){f=r.multiplyVector3(f.copy(p[b.a]));e=r.multiplyVector3(e.copy(p[b.b]));g=r.multiplyVector3(g.copy(p[b.c]));if(P(j,f,e,g)){b={distance:v,point:j.clone(),face:b,object:a};c.push(b)}}else if(b instanceof THREE.Face4){f=r.multiplyVector3(f.copy(p[b.a])); e=r.multiplyVector3(e.copy(p[b.b]));g=r.multiplyVector3(g.copy(p[b.c]));m=r.multiplyVector3(m.copy(p[b.d]));if(P(j,f,e,m)||P(j,e,g,m)){b={distance:v,point:j.clone(),face:b,object:a};c.push(b)}}}}}}c.sort(o);return c};this.intersectObjects=function(a){for(var b=[],c=0,d=a.length;ce?d:e;f=f>g? f:g}a()};this.add3Points=function(e,g,h,n,j,o){if(m){m=false;b=eh?e>j?e:j:h>j?h:j;f=g>n?g>o?g:o:n>o?n:o}else{b=eh?e>j?e>d?e:d:j>d?j:d:h>j?h>d?h:d:j>d?j:d;f=g>n?g>o?g>f?g:f:o>f?o:f:n>o?n>f?n:f:o>f?o:f}a()};this.addRectangle=function(e){if(m){m=false;b=e.getLeft();c=e.getTop();d=e.getRight();f=e.getBottom()}else{b=b=0&&g>=0&&f>=0&&h>=0)return true;if(e<0&&g<0||f<0&&h<0)return false;e<0?c=Math.max(c,e/(e-g)):g<0&&(d=Math.min(d,e/(e-g)));f<0?c=Math.max(c,f/(f-h)):h<0&&(d=Math.min(d,f/(f-h)));if(df&&m.positionScreen.z0)){U=l[k-2];D.copy(M.positionScreen);H.copy(U.positionScreen);if(d(D,H)){D.multiplyScalar(1/D.w);H.multiplyScalar(1/H.w);K=r[p]=r[p]||new THREE.RenderableLine;p++;i=K;i.v1.positionScreen.copy(D);i.v2.positionScreen.copy(H);i.z=Math.max(D.z,H.z);i.material=C.material;w.elements.push(i)}}}}}a= +S.length;Of&&m.positionScreen.z0)){U=l[k-2];D.copy(L.positionScreen);H.copy(U.positionScreen);if(d(D,H)){D.multiplyScalar(1/D.w);H.multiplyScalar(1/H.w);K=r[p]=r[p]||new THREE.RenderableLine;p++;i=K;i.v1.positionScreen.copy(D);i.v2.positionScreen.copy(H);i.z=Math.max(D.z,H.z);i.material=C.material;w.elements.push(i)}}}}}a= 0;for(Q=w.sprites.length;a0&&x.z<1){f=A[v]=A[v]||new THREE.RenderableParticle;v++;s=f;s.x=x.x/x.w;s.y=x.y/x.w;s.z=x.z;s.rotation=C.rotation.z;s.scale.x=C.scale.x*Math.abs(s.x-(x.x+e.projectionMatrix.elements[0])/(x.w+e.projectionMatrix.elements[12]));s.scale.y=C.scale.y*Math.abs(s.y-(x.y+e.projectionMatrix.elements[5])/(x.w+e.projectionMatrix.elements[13])); s.material=C.material;w.elements.push(s)}}}g&&w.elements.sort(c);return w}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d!==void 0?d:1}; THREE.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,b){var c=b||"XYZ",d=Math.cos(a.x/2),f=Math.cos(a.y/2),e=Math.cos(a.z/2),g=Math.sin(a.x/2),m=Math.sin(a.y/2),k=Math.sin(a.z/2);switch(c){case "YXZ":this.x=g*f*e+d*m*k;this.y=d*m*e-g*f*k;this.z=d*f*k-g*m*e;this.w=d*f*e+g*m*k;break;case "ZXY":this.x=g*f*e-d*m*k;this.y=d*m*e+g*f* @@ -86,9 +86,9 @@ k;this.z=d*f*k+g*m*e;this.w=d*f*e-g*m*k;break;case "ZYX":this.x=g*f*e-d*m*k;this d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],g=b[9],m=b[2],k=b[6],b=b[10],l=c+e+b;if(l>0){c=0.5/Math.sqrt(l+1);this.w=0.25/c;this.x=(k-g)*c;this.y=(d-m)*c;this.z=(f-a)*c}else if(c>e&&c>b){c=2*Math.sqrt(1+c-e-b);this.w=(k-g)/c;this.x=0.25*c;this.y=(a+f)/c;this.z=(d+m)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-m)/c;this.x=(a+f)/c;this.y=0.25*c;this.z=(g+k)/c}else{c=2*Math.sqrt(1+b-c-e);this.w=(f-a)/c;this.x= (d+m)/c;this.y=(g+k)/c;this.z=0.25*c}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=this.x*-1;this.y=this.y*-1;this.z=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);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y= this.y*a;this.z=this.z*a;this.w=this.w*a}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},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,m=a.z,a=a.w;this.x=b*a+f*e+c*m-d*g;this.y=c*a+f*g+d*e-b*m;this.z=d*a+f*m+b*g-c*e;this.w=f*a-b*e-c*g-d*m;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z, -e=this.x,g=this.y,m=this.z,k=this.w,l=k*c+g*f-m*d,h=k*d+m*c-e*f,n=k*f+e*d-g*c,c=-e*c-g*d-m*f;b.x=l*k+c*-e+h*-m-n*-g;b.y=h*k+c*-g+n*-e-l*-m;b.z=n*k+c*-m+l*-g-h*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,g=e*a.w+c*a.x+d*a.y+f*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var m=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.001){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x); +e=this.x,g=this.y,m=this.z,k=this.w,l=k*c+g*f-m*d,h=k*d+m*c-e*f,n=k*f+e*d-g*c,c=-e*c-g*d-m*f;b.x=l*k+c*-e+h*-m-n*-g;b.y=h*k+c*-g+n*-e-l*-m;b.z=n*k+c*-m+l*-g-h*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,g=e*a.w+c*a.x+d*a.y+f*a.z;if(g<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;g=-g}else this.copy(a);if(g>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var m=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.0010){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x); this.y=0.5*(d+this.y);this.z=0.5*(f+this.z);return this}g=Math.sin((1-b)*m)/k;m=Math.sin(b*m)/k;this.w=e*g+this.w*m;this.x=c*g+this.x*m;this.y=d*g+this.y*m;this.z=f*g+this.z*m;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}}; -THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.001){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}f=Math.sin((1-d)*b)/e;d=Math.sin(d*b)/e;c.w=a.w*f+c.w*d;c.x=a.x*f+c.x*d;c.y=a.y*f+c.y*d;c.z=a.z*f+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")}; +THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.0010){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}f=Math.sin((1-d)*b)/e;d=Math.sin(d*b)/e;c.w=a.w*f+c.w*d;c.x=a.x*f+c.x*d;c.y=a.y*f+c.y*d;c.z=a.z*f+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")}; THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3}; THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,f=this.vertices.length;dc.x)c.x= +M.cross(e.vertexNormals[d],F);f=M.dot(z[f]);f=f<0?-1:1;e.vertexTangents[d]=new THREE.Vector4(P.x,P.y,P.z,f)}}this.hasTangents=true},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(this.vertices.length>0){var a;a=this.vertices[0];this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,f=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}}else{this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};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,f=Math.pow(10,4),e,g,m;e=0;for(g=this.vertices.length;e0;a--)if(d.indexOf(f["abcd"[a]])!=a){d.splice(a,1);this.faces[e]=new THREE.Face3(d[0],d[1],d[2]);f=0;for(d=this.faceVertexUvs.length;f1&&(H=new THREE.MeshFaceMaterial); a=new THREE.Mesh(D,H);a.name=j;if(s){a.matrixAutoUpdate=false;a.matrix.set(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11],s[12],s[13],s[14],s[15])}else{a.position.set(w[0],w[1],w[2]);if(x){a.quaternion.set(x[0],x[1],x[2],x[3]);a.useQuaternion=true}else a.rotation.set(B[0],B[1],B[2]);a.scale.set(F[0],F[1],F[2])}a.visible=r.visible;a.doubleSided=r.doubleSided;a.castShadow=r.castShadow;a.receiveShadow=r.receiveShadow;y.scene.add(a);y.objects[j]=a}}else{w=r.position;B=r.rotation;x=r.quaternion; F=r.scale;x=0;a=new THREE.Object3D;a.name=j;a.position.set(w[0],w[1],w[2]);if(x){a.quaternion.set(x[0],x[1],x[2],x[3]);a.useQuaternion=true}else a.rotation.set(B[0],B[1],B[2]);a.scale.set(F[0],F[1],F[2]);a.visible=r.visible!==void 0?r.visible:false;y.scene.add(a);y.objects[j]=a;y.empties[j]=a}}}function e(a){return function(b){y.geometries[a]=b;f();G=G-1;k.onLoadComplete();m()}}function g(a){return function(b){y.geometries[a]=b}}function m(){k.callbackProgress({totalModels:Q,totalTextures:O,loadedModels:Q- -G,loadedTextures:O-N},y);k.onLoadProgress();G==0&&N==0&&b(y)}var k=this,l=THREE.Loader.prototype.extractUrlBase(c),h,n,j,o,q,i,p,r,s,v,A,w,B,x,F,u,z,D,H,P,L,t,E,G,N,Q,O,y;t=a;c=new THREE.BinaryLoader;E=new THREE.JSONLoader;N=G=0;y={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(t.transform){a=t.transform.position;v=t.transform.rotation;u=t.transform.scale;a&&y.scene.position.set(a[0],a[1],a[2]);v&&y.scene.rotation.set(v[0],v[1], -v[2]);u&&y.scene.scale.set(u[0],u[1],u[2]);if(a||v||u){y.scene.updateMatrix();y.scene.updateMatrixWorld()}}a=function(){N=N-1;m();k.onLoadComplete()};for(q in t.cameras){u=t.cameras[q];u.type=="perspective"?P=new THREE.PerspectiveCamera(u.fov,u.aspect,u.near,u.far):u.type=="ortho"&&(P=new THREE.OrthographicCamera(u.left,u.right,u.top,u.bottom,u.near,u.far));w=u.position;v=u.target;u=u.up;P.position.set(w[0],w[1],w[2]);P.target=new THREE.Vector3(v[0],v[1],v[2]);u&&P.up.set(u[0],u[1],u[2]);y.cameras[q]= -P}for(o in t.lights){v=t.lights[o];q=v.color!==void 0?v.color:16777215;P=v.intensity!==void 0?v.intensity:1;if(v.type=="directional"){w=v.direction;A=new THREE.DirectionalLight(q,P);A.position.set(w[0],w[1],w[2]);A.position.normalize()}else if(v.type=="point"){w=v.position;A=v.distance;A=new THREE.PointLight(q,P,A);A.position.set(w[0],w[1],w[2])}else v.type=="ambient"&&(A=new THREE.AmbientLight(q));y.scene.add(A);y.lights[o]=A}for(i in t.fogs){o=t.fogs[i];o.type=="linear"?L=new THREE.Fog(0,o.near, -o.far):o.type=="exp2"&&(L=new THREE.FogExp2(0,o.density));u=o.color;L.color.setRGB(u[0],u[1],u[2]);y.fogs[i]=L}if(y.cameras&&t.defaults.camera)y.currentCamera=y.cameras[t.defaults.camera];if(y.fogs&&t.defaults.fog)y.scene.fog=y.fogs[t.defaults.fog];u=t.defaults.bgcolor;y.bgColor=new THREE.Color;y.bgColor.setRGB(u[0],u[1],u[2]);y.bgColorAlpha=t.defaults.bgalpha;for(h in t.geometries){i=t.geometries[h];if(i.type=="bin_mesh"||i.type=="ascii_mesh"){G=G+1;k.onLoadStart()}}Q=G;for(h in t.geometries){i= -t.geometries[h];if(i.type=="cube"){D=new THREE.CubeGeometry(i.width,i.height,i.depth,i.segmentsWidth,i.segmentsHeight,i.segmentsDepth,null,i.flipped,i.sides);y.geometries[h]=D}else if(i.type=="plane"){D=new THREE.PlaneGeometry(i.width,i.height,i.segmentsWidth,i.segmentsHeight);y.geometries[h]=D}else if(i.type=="sphere"){D=new THREE.SphereGeometry(i.radius,i.segmentsWidth,i.segmentsHeight);y.geometries[h]=D}else if(i.type=="cylinder"){D=new THREE.CylinderGeometry(i.topRad,i.botRad,i.height,i.radSegs, -i.heightSegs);y.geometries[h]=D}else if(i.type=="torus"){D=new THREE.TorusGeometry(i.radius,i.tube,i.segmentsR,i.segmentsT);y.geometries[h]=D}else if(i.type=="icosahedron"){D=new THREE.IcosahedronGeometry(i.radius,i.subdivisions);y.geometries[h]=D}else if(i.type=="bin_mesh")c.load(d(i.url,t.urlBaseType),e(h));else if(i.type=="ascii_mesh")E.load(d(i.url,t.urlBaseType),e(h));else if(i.type=="embedded_mesh"){i=t.embeds[i.id];i.metadata=t.metadata;i&&E.createModel(i,g(h),"")}}for(p in t.textures){h=t.textures[p]; -if(h.url instanceof Array){N=N+h.url.length;for(i=0;i0){c(THREE.NormalBlending);b(1);f("rgba("+Math.floor(p.r* 255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+r+")");i.fillRect(Math.floor($.getX()),Math.floor($.getY()),Math.floor($.getWidth()),Math.floor($.getHeight()))}$.empty()}};this.render=function(a,h){function j(a){var b,c,d,e;Y.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);b=0;for(c=a.length;b255?255:j;aa[10]=c<0?0:c>255?255:c;aa[12]=k<0?0:k>255?255:k;aa[13]=l<0?0:l>255 0;g=l.projectScene(a,h,this.sortElements);m=g.elements;k=g.lights;(xa=k.length>0)&&j(k);wa=0;for(Ga=m.length;wab.length-2?f:f+1;c[3]=f>b.length-3?f:f+2;f=b[c[0]];h=b[c[1]];i=b[c[2]];j=b[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(b,a,c,d,e,f,g){b=(c-b)*0.5;d=(d-a)*0.5;return(2*(a-c)+b+d)*g+(-3*(a-c)-2*b-d)*f+b*e+a};THREE.Animation.prototype.getNextKeyWith=function(b,a,c){for(var d=this.data.hierarchy[a].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][b]!==void 0)return d[c];return this.data.hierarchy[a].keys[d.length-1]}; -THREE.KeyFrameAnimation=function(b,a,c){this.root=b;this.data=THREE.AnimationHandler.get(a);this.hierarchy=THREE.AnimationHandler.parse(b);this.currentTime=0;this.timeScale=0.001;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;b=0;for(a=this.hierarchy.length;b=0?a:a+g;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange; b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(a){if(this.domElement=== document){this.mouseX=a.pageX-this.viewHalfX;this.mouseY=a.pageY-this.viewHalfY}else{this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX;this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY}};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}), c=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(g,b);a.position.set(0,10,0);this.animation=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;m1?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=a*c.rotateSpeed; @@ -173,8 +173,7 @@ d.setFromAxisAngle(b,-a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.m b.addSelf(c.object.up.clone().setLength(a.y));c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?n=k:n.addSelf(a.sub(k,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){c.dispatchEvent(m);d.copy(c.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousemove",function(a){if(c.enabled){if(e){h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY);j=l=c.getMouseOnScreen(a.clientX,a.clientY);n= k=c.getMouseOnScreen(a.clientX,a.clientY);e=false}f!==-1&&(f===0&&!c.noRotate?i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===1&&!c.noZoom?l=c.getMouseOnScreen(a.clientX,a.clientY):f===2&&!c.noPan&&(k=c.getMouseOnScreen(a.clientX,a.clientY)))}},false);this.domElement.addEventListener("mousedown",function(a){if(c.enabled){a.preventDefault();a.stopPropagation();if(f===-1){f=a.button;f===0&&!c.noRotate?h=i=c.getMouseProjectionOnBall(a.clientX,a.clientY):f===1&&!c.noZoom?j=l=c.getMouseOnScreen(a.clientX, -a.clientY):this.noPan||(n=k=c.getMouseOnScreen(a.clientX,a.clientY))}}},false);this.domElement.addEventListener("mouseup",function(a){if(c.enabled){a.preventDefault();a.stopPropagation();f=-1}},false);window.addEventListener("keydown",function(a){if(c.enabled){a.preventDefault();if(f===-1){a.keyCode===c.keys[0]&&!c.noRotate?f=0:a.keyCode===c.keys[1]&&!c.noZoom?f=1:a.keyCode===c.keys[2]&&!c.noPan&&(f=2);f!==-1&&(e=true)}}},false);window.addEventListener("keyup",function(){c.enabled&&f!==-1&&(f=-1)}, -false)}; +a.clientY):this.noPan||(n=k=c.getMouseOnScreen(a.clientX,a.clientY))}}},false);this.domElement.addEventListener("mouseup",function(a){if(c.enabled){a.preventDefault();a.stopPropagation();f=-1}},false);window.addEventListener("keydown",function(a){if(c.enabled&&f===-1){a.keyCode===c.keys[0]&&!c.noRotate?f=0:a.keyCode===c.keys[1]&&!c.noZoom?f=1:a.keyCode===c.keys[2]&&!c.noPan&&(f=2);f!==-1&&(e=true)}},false);window.addEventListener("keyup",function(){c.enabled&&f!==-1&&(f=-1)},false)}; THREE.OrbitControls=function(b,a){var c,d,e;function f(){return 2*Math.PI/60/60*i.autoRotateSpeed}function g(a){a.preventDefault();if(p===c){n.set(a.clientX,a.clientY);k.sub(n,l);i.rotateLeft(2*Math.PI*k.x/j*i.userRotateSpeed);i.rotateUp(2*Math.PI*k.y/j*i.userRotateSpeed);l.copy(n)}else if(p===d){o.set(a.clientX,a.clientY);q.sub(o,m);q.y>0?i.zoomIn():i.zoomOut();m.copy(o)}}function h(){if(i.userRotate){document.removeEventListener("mousemove",g,false);document.removeEventListener("mouseup",h,false); p=e}}THREE.EventTarget.call(this);this.object=b;this.domElement=a!==void 0?a:document;this.center=new THREE.Vector3;this.userZoom=true;this.userZoomSpeed=1;this.userRotate=true;this.userRotateSpeed=1;this.autoRotate=false;this.autoRotateSpeed=2;var i=this,j=1800,l=new THREE.Vector2,n=new THREE.Vector2,k=new THREE.Vector2,m=new THREE.Vector2,o=new THREE.Vector2,q=new THREE.Vector2,r=0,s=0,t=1,v=new THREE.Vector3;e=-1;c=0;d=1;var p=e,x={type:"change"};this.rotateLeft=function(a){a===void 0&&(a=f()); s=s-a};this.rotateRight=function(a){a===void 0&&(a=f());s=s+a};this.rotateUp=function(a){a===void 0&&(a=f());r=r-a};this.rotateDown=function(a){a===void 0&&(a=f());r=r+a};this.zoomIn=function(a){a===void 0&&(a=Math.pow(0.95,i.userZoomSpeed));t=t/a};this.zoomOut=function(a){a===void 0&&(a=Math.pow(0.95,i.userZoomSpeed));t=t*a};this.update=function(){var a=this.object.position,b=a.clone().subSelf(this.center),c=Math.atan2(b.x,b.z),d=Math.atan2(Math.sqrt(b.x*b.x+b.z*b.z),b.y);this.autoRotate&&this.rotateLeft(f()); @@ -272,7 +271,7 @@ a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.NEAREST);if(a.getParameter(a "color");k.scale=a.getUniformLocation(l,"scale");k.rotation=a.getUniformLocation(l,"rotation");k.screenPosition=a.getUniformLocation(l,"screenPosition");m=false};this.render=function(b,d,e,s){var b=b.__webglFlares,t=b.length;if(t){var v=new THREE.Vector3,p=s/e,x=e*0.5,z=s*0.5,A=16/s,w=new THREE.Vector2(A*p,A),u=new THREE.Vector3(1,1,0),C=new THREE.Vector2(1,1),B=k,A=n;a.useProgram(l);if(!m){a.enableVertexAttribArray(n.vertex);a.enableVertexAttribArray(n.uv);m=true}a.uniform1i(B.occlusionMap,0);a.uniform1i(B.map, 1);a.bindBuffer(a.ARRAY_BUFFER,f);a.vertexAttribPointer(A.vertex,2,a.FLOAT,false,16,0);a.vertexAttribPointer(A.uv,2,a.FLOAT,false,16,8);a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,g);a.disable(a.CULL_FACE);a.depthMask(false);var E,G,L,H,D;for(E=0;E0&&C.x0&& C.y0.001&&D.scale>0.001){u.x=D.x;u.y=D.y;u.z=D.z;A=D.size*D.scale/s;w.x=A*p;w.y=A;a.uniform3f(B.screenPosition,u.x,u.y,u.z);a.uniform2f(B.scale,w.x,w.y);a.uniform1f(B.rotation,D.rotation);a.uniform1f(B.opacity,D.opacity); +a.bindTexture(a.TEXTURE_2D,h);a.drawElements(a.TRIANGLES,6,a.UNSIGNED_SHORT,0);H.positionScreen.copy(u);H.customUpdateCallback?H.customUpdateCallback(H):H.updateLensFlares();a.uniform1i(B.renderType,2);a.enable(a.BLEND);G=0;for(L=H.lensFlares.length;G0.0010&&D.scale>0.0010){u.x=D.x;u.y=D.y;u.z=D.z;A=D.size*D.scale/s;w.x=A*p;w.y=A;a.uniform3f(B.screenPosition,u.x,u.y,u.z);a.uniform2f(B.scale,w.x,w.y);a.uniform1f(B.rotation,D.rotation);a.uniform1f(B.opacity,D.opacity); a.uniform3f(B.color,D.color.r,D.color.g,D.color.b);c.setBlending(D.blending,D.blendEquation,D.blendSrc,D.blendDst);c.setTexture(D.texture,1);a.drawElements(a.TRIANGLES,6,a.UNSIGNED_SHORT,0)}}}}a.enable(a.CULL_FACE);a.enable(a.DEPTH_TEST);a.depthMask(true)}}}; THREE.ShadowMapPlugin=function(){var b,a,c,d,e=new THREE.Frustum,f=new THREE.Matrix4,g=new THREE.Vector3,h=new THREE.Vector3;this.init=function(e){b=e.context;a=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:true});c._shadowPass=true;d._shadowPass=true};this.render= function(b,c){a.shadowMapEnabled&&a.shadowMapAutoUpdate&&this.update(b,c)};this.update=function(i,j){var l,n,k,m,o,q,r,s,t,v=[];m=0;b.clearColor(1,1,1,1);b.disable(b.BLEND);b.enable(b.CULL_FACE);a.shadowMapCullFrontFaces?b.cullFace(b.FRONT):b.cullFace(b.BACK);a.setDepthTest(true);l=0;for(n=i.__lights.length;ll&&f>k)if(f<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(f);c=d/b;d=e/b}else if(l> -k)if(l<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(l);b=d/c;d=m/c}else if(k<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(k);b=e/d;c=m/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-m)*(b-m)+(e-c)*(e-c)+(h-d)*(h-d));Math.abs(a)<0.001&&(a=1);this.x=(b-m)/a;this.y=(e-c)/a;this.z=(h-d)/a;this.w=Math.acos((f+l+k-1)/2);return this}}; +k)if(l<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(l);b=d/c;d=m/c}else if(k<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(k);b=e/d;c=m/d}this.set(b,c,d,a);return this}a=Math.sqrt((b-m)*(b-m)+(e-c)*(e-c)+(h-d)*(h-d));Math.abs(a)<0.0010&&(a=1);this.x=(b-m)/a;this.y=(e-c)/a;this.z=(h-d)/a;this.w=Math.acos((f+l+k-1)/2);return this}}; THREE.EventTarget=function(){var a={};this.addEventListener=function(b,c){a[b]===void 0&&(a[b]=[]);a[b].indexOf(c)===-1&&a[b].push(c)};this.dispatchEvent=function(b){for(var c in a[b.type])a[b.type][c](b)};this.removeEventListener=function(b,c){var d=a[b].indexOf(c);d!==-1&&a[b].splice(d,1)}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]}; THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes,d=a.elements,a=d[0];b=d[1];var f=d[2],e=d[3],h=d[4],l=d[5],m=d[6],k=d[7],i=d[8],o=d[9],j=d[10],w=d[11],r=d[12],n=d[13],q=d[14],d=d[15];c[0].set(e-a,k-h,w-i,d-r);c[1].set(e+a,k+h,w+i,d+r);c[2].set(e+b,k+l,w+o,d+n);c[3].set(e-b,k-l,w-o,d-n);c[4].set(e-f,k-m,w-j,d-q);c[5].set(e+f,k+m,w+j,d+q);for(a=0;a<6;a++){b=c[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}}; THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=c.elements,c=-a.geometry.boundingSphere.radius*c.getMaxScaleOnAxis(),f=0;f<6;f++){a=b[f].x*d[12]+b[f].y*d[13]+b[f].z*d[14]+b[f].w;if(a<=c)return false}return true};THREE.Frustum.__v1=new THREE.Vector3; @@ -86,9 +86,9 @@ m;this.z=d*f*m+h*l*e;this.w=d*f*e-h*l*m;break;case "ZYX":this.x=h*f*e-d*l*m;this d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],h=b[9],l=b[2],m=b[6],b=b[10],k=c+e+b;if(k>0){c=0.5/Math.sqrt(k+1);this.w=0.25/c;this.x=(m-h)*c;this.y=(d-l)*c;this.z=(f-a)*c}else if(c>e&&c>b){c=2*Math.sqrt(1+c-e-b);this.w=(m-h)/c;this.x=0.25*c;this.y=(a+f)/c;this.z=(d+l)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-l)/c;this.x=(a+f)/c;this.y=0.25*c;this.z=(h+m)/c}else{c=2*Math.sqrt(1+b-c-e);this.w=(f-a)/c;this.x= (d+l)/c;this.y=(h+m)/c;this.z=0.25*c}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=this.x*-1;this.y=this.y*-1;this.z=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);if(a===0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x=this.x*a;this.y= this.y*a;this.z=this.z*a;this.w=this.w*a}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},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,e=a.x,h=a.y,l=a.z,a=a.w;this.x=b*a+f*e+c*l-d*h;this.y=c*a+f*h+d*e-b*l;this.z=d*a+f*l+b*h-c*e;this.w=f*a-b*e-c*h-d*l;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z, -e=this.x,h=this.y,l=this.z,m=this.w,k=m*c+h*f-l*d,i=m*d+l*c-e*f,o=m*f+e*d-h*c,c=-e*c-h*d-l*f;b.x=k*m+c*-e+i*-l-o*-h;b.y=i*m+c*-h+o*-e-k*-l;b.z=o*m+c*-l+k*-h-i*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,h=e*a.w+c*a.x+d*a.y+f*a.z;if(h<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;h=-h}else this.copy(a);if(h>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var l=Math.acos(h),m=Math.sqrt(1-h*h);if(Math.abs(m)<0.001){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x); +e=this.x,h=this.y,l=this.z,m=this.w,k=m*c+h*f-l*d,i=m*d+l*c-e*f,o=m*f+e*d-h*c,c=-e*c-h*d-l*f;b.x=k*m+c*-e+i*-l-o*-h;b.y=i*m+c*-h+o*-e-k*-l;b.z=o*m+c*-l+k*-h-i*-e;return b},slerpSelf:function(a,b){var c=this.x,d=this.y,f=this.z,e=this.w,h=e*a.w+c*a.x+d*a.y+f*a.z;if(h<0){this.w=-a.w;this.x=-a.x;this.y=-a.y;this.z=-a.z;h=-h}else this.copy(a);if(h>=1){this.w=e;this.x=c;this.y=d;this.z=f;return this}var l=Math.acos(h),m=Math.sqrt(1-h*h);if(Math.abs(m)<0.0010){this.w=0.5*(e+this.w);this.x=0.5*(c+this.x); this.y=0.5*(d+this.y);this.z=0.5*(f+this.z);return this}h=Math.sin((1-b)*l)/m;l=Math.sin(b*l)/m;this.w=e*h+this.w*l;this.x=c*h+this.x*l;this.y=d*h+this.y*l;this.z=f*h+this.z*l;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}}; -THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.001){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}f=Math.sin((1-d)*b)/e;d=Math.sin(d*b)/e;c.w=a.w*f+c.w*d;c.x=a.x*f+c.x*d;c.y=a.y*f+c.y*d;c.z=a.z*f+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")}; +THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(f<0){c.w=-b.w;c.x=-b.x;c.y=-b.y;c.z=-b.z;f=-f}else c.copy(b);if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var b=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.0010){c.w=0.5*(a.w+c.w);c.x=0.5*(a.x+c.x);c.y=0.5*(a.y+c.y);c.z=0.5*(a.z+c.z);return c}f=Math.sin((1-d)*b)/e;d=Math.sin(d*b)/e;c.w=a.w*f+c.w*d;c.x=a.x*f+c.x*d;c.y=a.y*f+c.y*d;c.z=a.z*f+c.z*d;return c};THREE.Vertex=function(){console.warn("THREE.Vertex has been DEPRECATED. Use THREE.Vector3 instead.")}; THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3}; THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){var a=new THREE.Face3(this.a,this.b,this.c);a.normal.copy(this.normal);a.color.copy(this.color);a.centroid.copy(this.centroid);a.materialIndex=this.materialIndex;var b,c;b=0;for(c=this.vertexNormals.length;b1&&(R=new THREE.MeshFaceMaterial); a=new THREE.Mesh(G,R);a.name=j;if(s){a.matrixAutoUpdate=false;a.matrix.set(s[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11],s[12],s[13],s[14],s[15])}else{a.position.set(u[0],u[1],u[2]);if(D){a.quaternion.set(D[0],D[1],D[2],D[3]);a.useQuaternion=true}else a.rotation.set(J[0],J[1],J[2]);a.scale.set(M[0],M[1],M[2])}a.visible=p.visible;a.doubleSided=p.doubleSided;a.castShadow=p.castShadow;a.receiveShadow=p.receiveShadow;I.scene.add(a);I.objects[j]=a}}else{u=p.position;J=p.rotation;D=p.quaternion; M=p.scale;D=0;a=new THREE.Object3D;a.name=j;a.position.set(u[0],u[1],u[2]);if(D){a.quaternion.set(D[0],D[1],D[2],D[3]);a.useQuaternion=true}else a.rotation.set(J[0],J[1],J[2]);a.scale.set(M[0],M[1],M[2]);a.visible=p.visible!==void 0?p.visible:false;I.scene.add(a);I.objects[j]=a;I.empties[j]=a}}}function e(a){return function(b){I.geometries[a]=b;f();Z=Z-1;m.onLoadComplete();l()}}function h(a){return function(b){I.geometries[a]=b}}function l(){m.callbackProgress({totalModels:g,totalTextures:W,loadedModels:g- -Z,loadedTextures:W-F},I);m.onLoadProgress();Z==0&&F==0&&b(I)}var m=this,k=THREE.Loader.prototype.extractUrlBase(c),i,o,j,w,r,n,q,p,s,B,A,u,J,D,M,E,Q,G,R,T,S,y,L,Z,F,g,W,I;y=a;c=new THREE.BinaryLoader;L=new THREE.JSONLoader;F=Z=0;I={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},empties:{}};if(y.transform){a=y.transform.position;B=y.transform.rotation;E=y.transform.scale;a&&I.scene.position.set(a[0],a[1],a[2]);B&&I.scene.rotation.set(B[0],B[1], -B[2]);E&&I.scene.scale.set(E[0],E[1],E[2]);if(a||B||E){I.scene.updateMatrix();I.scene.updateMatrixWorld()}}a=function(){F=F-1;l();m.onLoadComplete()};for(r in y.cameras){E=y.cameras[r];E.type=="perspective"?T=new THREE.PerspectiveCamera(E.fov,E.aspect,E.near,E.far):E.type=="ortho"&&(T=new THREE.OrthographicCamera(E.left,E.right,E.top,E.bottom,E.near,E.far));u=E.position;B=E.target;E=E.up;T.position.set(u[0],u[1],u[2]);T.target=new THREE.Vector3(B[0],B[1],B[2]);E&&T.up.set(E[0],E[1],E[2]);I.cameras[r]= -T}for(w in y.lights){B=y.lights[w];r=B.color!==void 0?B.color:16777215;T=B.intensity!==void 0?B.intensity:1;if(B.type=="directional"){u=B.direction;A=new THREE.DirectionalLight(r,T);A.position.set(u[0],u[1],u[2]);A.position.normalize()}else if(B.type=="point"){u=B.position;A=B.distance;A=new THREE.PointLight(r,T,A);A.position.set(u[0],u[1],u[2])}else B.type=="ambient"&&(A=new THREE.AmbientLight(r));I.scene.add(A);I.lights[w]=A}for(n in y.fogs){w=y.fogs[n];w.type=="linear"?S=new THREE.Fog(0,w.near, -w.far):w.type=="exp2"&&(S=new THREE.FogExp2(0,w.density));E=w.color;S.color.setRGB(E[0],E[1],E[2]);I.fogs[n]=S}if(I.cameras&&y.defaults.camera)I.currentCamera=I.cameras[y.defaults.camera];if(I.fogs&&y.defaults.fog)I.scene.fog=I.fogs[y.defaults.fog];E=y.defaults.bgcolor;I.bgColor=new THREE.Color;I.bgColor.setRGB(E[0],E[1],E[2]);I.bgColorAlpha=y.defaults.bgalpha;for(i in y.geometries){n=y.geometries[i];if(n.type=="bin_mesh"||n.type=="ascii_mesh"){Z=Z+1;m.onLoadStart()}}g=Z;for(i in y.geometries){n= -y.geometries[i];if(n.type=="cube"){G=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides);I.geometries[i]=G}else if(n.type=="plane"){G=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight);I.geometries[i]=G}else if(n.type=="sphere"){G=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight);I.geometries[i]=G}else if(n.type=="cylinder"){G=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs, -n.heightSegs);I.geometries[i]=G}else if(n.type=="torus"){G=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT);I.geometries[i]=G}else if(n.type=="icosahedron"){G=new THREE.IcosahedronGeometry(n.radius,n.subdivisions);I.geometries[i]=G}else if(n.type=="bin_mesh")c.load(d(n.url,y.urlBaseType),e(i));else if(n.type=="ascii_mesh")L.load(d(n.url,y.urlBaseType),e(i));else if(n.type=="embedded_mesh"){n=y.embeds[n.id];n.metadata=y.metadata;n&&L.createModel(n,h(i),"")}}for(q in y.textures){i=y.textures[q]; -if(i.url instanceof Array){F=F+i.url.length;for(n=0;n=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function q(a,b,c,d,f){if(d.needsUpdate){d.program&&F.deallocateMaterial(d);F.initMaterial(d,b,c,f);d.needsUpdate=false}if(d.morphTargets&&!f.__webglMorphTargetInfluences)f.__webglMorphTargetInfluences=new Float32Array(F.maxMorphTargets);var e=false,h=d.program,i=h.uniforms,j=d.uniforms;if(h!==za){g.useProgram(h);za=h;e=true}if(d.id!==na){na=d.id;e=true}if(e||a!==ga){g.uniformMatrix4fv(i.projectionMatrix, false,a._projectionMatrixArray);a!==ga&&(ga=a)}if(e){if(c&&d.fog){j.fogColor.value=c.color;if(c instanceof THREE.Fog){j.fogNear.value=c.near;j.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(ob){for(var l,k=0,m=0,o=0,n,q,r,p=bc,s=p.directional.colors,w=p.directional.positions,u=p.point.colors,y=p.point.positions,B=p.point.distances,E=p.spot.colors,I=p.spot.positions,J=p.spot.distances, -L=p.spot.directions,Q=p.spot.angles,G=p.spot.exponents,S=0,R=0,T=0,H=r=0,c=H=0,e=b.length;c0&&Q.x0&& Q.y0.001&&L.scale>0.001){E.x=L.x;E.y=L.y;E.z=L.z;D=L.size*L.scale/p;M.x=D*A;M.y=D;b.uniform3f(G.screenPosition,E.x,E.y,E.z);b.uniform2f(G.scale,M.x,M.y);b.uniform1f(G.rotation,L.rotation);b.uniform1f(G.opacity,L.opacity); +b.bindTexture(b.TEXTURE_2D,l);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);y.positionScreen.copy(E);y.customUpdateCallback?y.customUpdateCallback(y):y.updateLensFlares();b.uniform1i(G.renderType,2);b.enable(b.BLEND);T=0;for(S=y.lensFlares.length;T0.0010&&L.scale>0.0010){E.x=L.x;E.y=L.y;E.z=L.z;D=L.size*L.scale/p;M.x=D*A;M.y=D;b.uniform3f(G.screenPosition,E.x,E.y,E.z);b.uniform2f(G.scale,M.x,M.y);b.uniform1f(G.rotation,L.rotation);b.uniform1f(G.opacity,L.opacity); b.uniform3f(G.color,L.color.r,L.color.g,L.color.b);c.setBlending(L.blending,L.blendEquation,L.blendSrc,L.blendDst);c.setTexture(L.texture,1);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}}}}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(true)}}}; THREE.ShadowMapPlugin=function(){var a,b,c,d,f=new THREE.Frustum,e=new THREE.Matrix4,h=new THREE.Vector3,l=new THREE.Vector3;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:true});c._shadowPass=true;d._shadowPass=true};this.render= function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(m,k){var i,o,j,w,r,n,q,p,s,B=[];w=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);a.enable(a.CULL_FACE);b.shadowMapCullFrontFaces?a.cullFace(a.FRONT):a.cullFace(a.BACK);b.setDepthTest(true);i=0;for(o=m.__lights.length;i 0 ) { - + _this.dispatchEvent( changeEvent ); lastPosition.copy( _this.object.position ); @@ -258,7 +258,7 @@ THREE.TrackballControls = function ( object, domElement ) { if ( ! _this.enabled ) return; - event.preventDefault(); + //event.preventDefault(); if ( _state !== STATE.NONE ) { diff --git a/src/loaders/SceneLoader.js b/src/loaders/SceneLoader.js index 52a2f640f310bb4fcc3de73848a08db523662efa..2be595b468f8d129478425d093f3dc1bfc9c9746 100644 --- a/src/loaders/SceneLoader.js +++ b/src/loaders/SceneLoader.js @@ -23,9 +23,9 @@ THREE.SceneLoader.prototype.load = function( url, callbackFinished ) { xhr.onreadystatechange = function () { - if ( xhr.readyState == 4 ) { + if ( xhr.readyState === 4 ) { - if ( xhr.status == 200 || xhr.status == 0 ) { + if ( xhr.status === 200 || xhr.status === 0 ) { var json = JSON.parse( xhr.responseText ); context.createScene( json, callbackFinished, url ); @@ -182,32 +182,32 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url object = new THREE.Mesh( geometry, material ); object.name = dd; - + if ( m ) { - + object.matrixAutoUpdate = false; object.matrix.set( m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9], m[10], m[11], m[12], m[13], m[14], m[15]); - + } else { - + object.position.set( p[0], p[1], p[2] ); - + if ( q ) { - + object.quaternion.set( q[0], q[1], q[2], q[3] ); object.useQuaternion = true; - + } else { - + object.rotation.set( r[0], r[1], r[2] ); - + } - + object.scale.set( s[0], s[1], s[2] ); - + } object.visible = o.visible; @@ -313,7 +313,7 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url scope.onLoadProgress(); - if( counter_models == 0 && counter_textures == 0 ) { + if( counter_models === 0 && counter_textures === 0 ) { callbackFinished( result ); @@ -321,15 +321,28 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url }; - var callbackTexture = function( images ) { + var callbackTexture = function ( count ) { - counter_textures -= 1; + counter_textures -= count; async_callback_gate(); scope.onLoadComplete(); }; + // must use this instead of just directly calling callbackTexture + // because of closure in the calling context loop + + var generateTextureCallback = function ( count ) { + + return function() { + + callbackTexture( count ); + + }; + + }; + // first go synchronous elements // cameras @@ -338,11 +351,11 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url c = data.cameras[ dc ]; - if ( c.type == "perspective" ) { + if ( c.type === "perspective" ) { camera = new THREE.PerspectiveCamera( c.fov, c.aspect, c.near, c.far ); - } else if ( c.type == "ortho" ) { + } else if ( c.type === "ortho" ) { camera = new THREE.OrthographicCamera( c.left, c.right, c.top, c.bottom, c.near, c.far ); @@ -371,7 +384,7 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url hex = ( l.color !== undefined ) ? l.color : 0xffffff; intensity = ( l.intensity !== undefined ) ? l.intensity : 1; - if ( l.type == "directional" ) { + if ( l.type === "directional" ) { p = l.direction; @@ -379,7 +392,7 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url light.position.set( p[0], p[1], p[2] ); light.position.normalize(); - } else if ( l.type == "point" ) { + } else if ( l.type === "point" ) { p = l.position; d = l.distance; @@ -387,7 +400,7 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url light = new THREE.PointLight( hex, intensity, d ); light.position.set( p[0], p[1], p[2] ); - } else if ( l.type == "ambient" ) { + } else if ( l.type === "ambient" ) { light = new THREE.AmbientLight( hex ); @@ -405,11 +418,11 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url f = data.fogs[ df ]; - if ( f.type == "linear" ) { + if ( f.type === "linear" ) { fog = new THREE.Fog( 0x000000, f.near, f.far ); - } else if ( f.type == "exp2" ) { + } else if ( f.type === "exp2" ) { fog = new THREE.FogExp2( 0x000000, f.density ); @@ -468,50 +481,51 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url g = data.geometries[ dg ]; - if ( g.type == "cube" ) { + if ( g.type === "cube" ) { geometry = new THREE.CubeGeometry( g.width, g.height, g.depth, g.segmentsWidth, g.segmentsHeight, g.segmentsDepth, null, g.flipped, g.sides ); result.geometries[ dg ] = geometry; - } else if ( g.type == "plane" ) { + } else if ( g.type === "plane" ) { geometry = new THREE.PlaneGeometry( g.width, g.height, g.segmentsWidth, g.segmentsHeight ); result.geometries[ dg ] = geometry; - } else if ( g.type == "sphere" ) { + } else if ( g.type === "sphere" ) { geometry = new THREE.SphereGeometry( g.radius, g.segmentsWidth, g.segmentsHeight ); result.geometries[ dg ] = geometry; - } else if ( g.type == "cylinder" ) { + } else if ( g.type === "cylinder" ) { geometry = new THREE.CylinderGeometry( g.topRad, g.botRad, g.height, g.radSegs, g.heightSegs ); result.geometries[ dg ] = geometry; - } else if ( g.type == "torus" ) { + } else if ( g.type === "torus" ) { geometry = new THREE.TorusGeometry( g.radius, g.tube, g.segmentsR, g.segmentsT ); result.geometries[ dg ] = geometry; - } else if ( g.type == "icosahedron" ) { + } else if ( g.type === "icosahedron" ) { geometry = new THREE.IcosahedronGeometry( g.radius, g.subdivisions ); result.geometries[ dg ] = geometry; - } else if ( g.type == "bin_mesh" ) { + } else if ( g.type === "bin_mesh" ) { binLoader.load( get_url( g.url, data.urlBaseType ), create_callback( dg ) ); - } else if ( g.type == "ascii_mesh" ) { + } else if ( g.type === "ascii_mesh" ) { jsonLoader.load( get_url( g.url, data.urlBaseType ), create_callback( dg ) ); - } else if ( g.type == "embedded_mesh" ) { + } else if ( g.type === "embedded_mesh" ) { var modelJson = data.embeds[ g.id ], texture_path = ""; - // Pass metadata along to jsonLoader so it knows the format version. + // pass metadata along to jsonLoader so it knows the format version + modelJson.metadata = data.metadata; if ( modelJson ) { @@ -558,7 +572,7 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url tt = data.textures[ dt ]; - if ( tt.mapping != undefined && THREE[ tt.mapping ] != undefined ) { + if ( tt.mapping !== undefined && THREE[ tt.mapping ] !== undefined ) { tt.mapping = new THREE[ tt.mapping ](); @@ -566,24 +580,25 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url if( tt.url instanceof Array ) { + var count = tt.url.length; var url_array = []; - for( var i = 0; i < tt.url.length; i ++ ) { + for( var i = 0; i < count; i ++ ) { url_array[ i ] = get_url( tt.url[ i ], data.urlBaseType ); } - texture = THREE.ImageUtils.loadTextureCube( url_array, tt.mapping, callbackTexture ); + texture = THREE.ImageUtils.loadTextureCube( url_array, tt.mapping, generateTextureCallback( count ) ); } else { - texture = THREE.ImageUtils.loadTexture( get_url( tt.url, data.urlBaseType ), tt.mapping, callbackTexture ); + texture = THREE.ImageUtils.loadTexture( get_url( tt.url, data.urlBaseType ), tt.mapping, generateTextureCallback( 1 ) ); - if ( THREE[ tt.minFilter ] != undefined ) + if ( THREE[ tt.minFilter ] !== undefined ) texture.minFilter = THREE[ tt.minFilter ]; - if ( THREE[ tt.magFilter ] != undefined ) + if ( THREE[ tt.magFilter ] !== undefined ) texture.magFilter = THREE[ tt.magFilter ]; @@ -591,8 +606,8 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url texture.repeat.set( tt.repeat[ 0 ], tt.repeat[ 1 ] ); - if ( tt.repeat[ 0 ] != 1 ) texture.wrapS = THREE.RepeatWrapping; - if ( tt.repeat[ 1 ] != 1 ) texture.wrapT = THREE.RepeatWrapping; + if ( tt.repeat[ 0 ] !== 1 ) texture.wrapS = THREE.RepeatWrapping; + if ( tt.repeat[ 1 ] !== 1 ) texture.wrapT = THREE.RepeatWrapping; } @@ -630,23 +645,23 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url for ( pp in m.parameters ) { - if ( pp == "envMap" || pp == "map" || pp == "lightMap" ) { + if ( pp === "envMap" || pp === "map" || pp === "lightMap" ) { m.parameters[ pp ] = result.textures[ m.parameters[ pp ] ]; - } else if ( pp == "shading" ) { + } else if ( pp === "shading" ) { m.parameters[ pp ] = ( m.parameters[ pp ] == "flat" ) ? THREE.FlatShading : THREE.SmoothShading; - } else if ( pp == "blending" ) { + } else if ( pp === "blending" ) { - m.parameters[ pp ] = THREE[ m.parameters[ pp ] ] ? THREE[ m.parameters[ pp ] ] : THREE.NormalBlending; + m.parameters[ pp ] = m.parameters[ pp ] in THREE ? THREE[ m.parameters[ pp ] ] : THREE.NormalBlending; - } else if ( pp == "combine" ) { + } else if ( pp === "combine" ) { m.parameters[ pp ] = ( m.parameters[ pp ] == "MixOperation" ) ? THREE.MixOperation : THREE.MultiplyOperation; - } else if ( pp == "vertexColors" ) { + } else if ( pp === "vertexColors" ) { if ( m.parameters[ pp ] == "face" ) { @@ -743,8 +758,8 @@ THREE.SceneLoader.prototype.createScene = function ( json, callbackFinished, url scope.callbackSync( result ); - // just in case there are no async elements: - async_callback_gate(); + // just in case there are no async elements + async_callback_gate(); };