From 01c31ae9726d3b429154fc4aea5bcb922e692d14 Mon Sep 17 00:00:00 2001 From: alteredq Date: Thu, 12 Jul 2012 01:52:50 +0200 Subject: [PATCH] Big refactoring of BufferGeometry and CTMLoader: moved GL buffers initialization from loader into renderer, no more GL context dependency in loader. BufferGeometry lifecycle now starts to resemble more regular Geometry one. Also this new architecture should make it easier to add more attributes. --- build/Three.js | 648 +++++++++++------------ build/custom/ThreeExtras.js | 15 +- build/custom/ThreeWebGL.js | 441 ++++++++------- examples/js/loaders/ctm/CTMLoader.js | 76 +-- examples/webgl_loader_ctm.html | 2 +- examples/webgl_loader_ctm_materials.html | 2 +- src/extras/core/BufferGeometry.js | 107 ++-- src/renderers/WebGLRenderer.js | 146 +++-- 8 files changed, 718 insertions(+), 719 deletions(-) diff --git a/build/Three.js b/build/Three.js index 64ca9f9448..0adcca6942 100644 --- a/build/Three.js +++ b/build/Three.js @@ -17,8 +17,8 @@ THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a; a;this.z=this.z+a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x=this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x=this.x*a.x;this.y=this.y*a.y;this.z=this.z*a.z;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;return this},divideSelf:function(a){this.x=this.x/a.x;this.y= this.y/a.y;this.z=this.z/a.z;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a}else this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},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;return this},cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this, -a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],i=d[5],k=d[9],l=d[2],o=d[6],d=d[10];if(b===void 0||b==="XYZ"){this.y=Math.asin(c(g));if(Math.abs(g)<0.99999){this.x=Math.atan2(-k,d);this.z=Math.atan2(-f,e)}else{this.x=Math.atan2(h,i);this.z=0}}else if(b==="YXZ"){this.x=Math.asin(-c(k));if(Math.abs(k)< -0.99999){this.y=Math.atan2(g,d);this.z=Math.atan2(h,i)}else{this.y=Math.atan2(-l,e);this.z=0}}else if(b==="ZXY"){this.x=Math.asin(c(o));if(Math.abs(o)<0.99999){this.y=Math.atan2(-l,d);this.z=Math.atan2(-f,i)}else{this.y=0;this.z=Math.atan2(g,e)}}else if(b==="ZYX"){this.y=Math.asin(-c(l));if(Math.abs(l)<0.99999){this.x=Math.atan2(o,d);this.z=Math.atan2(h,e)}else{this.x=0;this.z=Math.atan2(-f,i)}}else if(b==="YZX"){this.z=Math.asin(c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(-k,i);this.y=Math.atan2(-l, +a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,e=d[0],f=d[4],g=d[8],h=d[1],i=d[5],j=d[9],l=d[2],o=d[6],d=d[10];if(b===void 0||b==="XYZ"){this.y=Math.asin(c(g));if(Math.abs(g)<0.99999){this.x=Math.atan2(-j,d);this.z=Math.atan2(-f,e)}else{this.x=Math.atan2(h,i);this.z=0}}else if(b==="YXZ"){this.x=Math.asin(-c(j));if(Math.abs(j)< +0.99999){this.y=Math.atan2(g,d);this.z=Math.atan2(h,i)}else{this.y=Math.atan2(-l,e);this.z=0}}else if(b==="ZXY"){this.x=Math.asin(c(o));if(Math.abs(o)<0.99999){this.y=Math.atan2(-l,d);this.z=Math.atan2(-f,i)}else{this.y=0;this.z=Math.atan2(g,e)}}else if(b==="ZYX"){this.y=Math.asin(-c(l));if(Math.abs(l)<0.99999){this.x=Math.atan2(o,d);this.z=Math.atan2(h,e)}else{this.x=0;this.z=Math.atan2(-f,i)}}else if(b==="YZX"){this.z=Math.asin(c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(-j,i);this.y=Math.atan2(-l, e)}else{this.x=0;this.y=Math.atan2(l,d)}}else if(b==="XZY"){this.z=Math.asin(-c(f));if(Math.abs(f)<0.99999){this.x=Math.atan2(o,i);this.y=Math.atan2(g,e)}else{this.x=Math.atan2(-g,d);this.y=0}}return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,e=a.y*a.y,f=a.z*a.z,g=a.w*a.w;if(b===void 0||b==="XYZ"){this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),g-d-e+f);this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w)));this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g+d-e-f)}else if(b=== "YXZ"){this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z)));this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g-d-e+f);this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g-d+e-f)}else if(b==="ZXY"){this.x=Math.asin(c(2*(a.x*a.w+a.y*a.z)));this.y=Math.atan2(2*(a.y*a.w-a.z*a.x),g-d-e+f);this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),g-d+e-f)}else if(b==="ZYX"){this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),g-d-e+f);this.y=Math.asin(c(2*(a.y*a.w-a.x*a.z)));this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),g+d-e-f)}else if(b==="YZX"){this.x=Math.atan2(2*(a.x*a.w-a.z* a.y),g-d+e-f);this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),g+d-e-f);this.z=Math.asin(c(2*(a.x*a.y+a.z*a.w)))}else if(b==="XZY"){this.x=Math.atan2(2*(a.x*a.w+a.y*a.z),g-d+e-f);this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),g+d-e-f);this.z=Math.asin(c(2*(a.z*a.w-a.x*a.y)))}return this},getScaleFromMatrix:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(),a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x= @@ -26,46 +26,46 @@ b;this.y=c;this.z=a;return this},equals:function(a){return a.x===this.x&&a.y===t THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x=this.x+a.x;this.y=this.y+a.y;this.z=this.z+a.z;this.w=this.w+a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x= 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 k=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+k-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;e=(e+1)/2;h=(h+1)/2;k=(k+1)/2;d=(d+g)/4;f=(f+c)/4;i=(i+b)/4;if(e>h&&e>k)if(e<0.01){b=0;d=c=0.707106781}else{b=Math.sqrt(e);c=d/b;d=f/b}else if(h> -k)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(k<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(k);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+k-1)/2);return this}}; +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.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=this.planes,c=a.elements,a=c[0],d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],i=c[6],k=c[7],l=c[8],o=c[9],m=c[10],p=c[11],r=c[12],n=c[13],q=c[14],c=c[15];b[0].set(f-a,k-g,p-l,c-r);b[1].set(f+a,k+g,p+l,c+r);b[2].set(f+d,k+h,p+o,c+n);b[3].set(f-d,k-h,p-o,c-n);b[4].set(f-e,k-i,p-m,c-q);b[5].set(f+e,k+i,p+m,c+q);for(d=0;d<6;d++){a=b[d];a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))}}; +THREE.Frustum.prototype.setFromMatrix=function(a){var b=this.planes,c=a.elements,a=c[0],d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],i=c[6],j=c[7],l=c[8],o=c[9],m=c[10],p=c[11],r=c[12],n=c[13],q=c[14],c=c[15];b[0].set(f-a,j-g,p-l,c-r);b[1].set(f+a,j+g,p+l,c+r);b[2].set(f+d,j+h,p+o,c+n);b[3].set(f-d,j-h,p-o,c-n);b[4].set(f-e,j-i,p-m,c-q);b[5].set(f+e,j+i,p+m,c+q);for(d=0;d<6;d++){a=b[d];a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))}}; THREE.Frustum.prototype.contains=function(a){for(var b=0,c=this.planes,b=a.matrixWorld,d=b.elements,a=-a.geometry.boundingSphere.radius*b.getMaxScaleOnAxis(),e=0;e<6;e++){b=c[e].x*d[12]+c[e].y*d[13]+c[e].z*d[14]+c[e].w;if(b<=a)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,k=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,s,u,w,t=function(a,b,c){r.sub(c,a);s=r.dot(b);u=n.add(a,q.copy(b).multiplyScalar(s)); -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,b){var c,d=[];if(b===true)for(var j=0,n=a.children.length;ja.scale.x)return[];c={distance:w,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){j=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());j=a.geometry.boundingSphere.radius*Math.max(j.x,Math.max(j.y,j.z));w=t(this.origin,this.direction,a.matrixWorld.getPosition());if(w>j)return d;var r,q,s=a.geometry,u=s.vertices,v;a.matrixRotationWorld.extractRotation(a.matrixWorld);j=0;for(n=s.faces.length;j< -n;j++){c=s.faces[j];i.copy(this.origin);k.copy(this.direction);v=a.matrixWorld;l=v.multiplyVector3(l.copy(c.centroid)).subSelf(i);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));r=k.dot(o);if(!(Math.abs(r)0:r<0))){m.add(i,k.multiplyScalar(q));w=i.distanceTo(m);if(!(wthis.far))if(c instanceof THREE.Face3){e=v.multiplyVector3(e.copy(u[c.a]));f=v.multiplyVector3(f.copy(u[c.b]));g=v.multiplyVector3(g.copy(u[c.c])); +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,s,u,w,t=function(a,b,c){r.sub(c,a);s=r.dot(b);u=n.add(a,q.copy(b).multiplyScalar(s)); +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,b){var c,d=[];if(b===true)for(var k=0,n=a.children.length;ka.scale.x)return[];c={distance:w,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){k=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());k=a.geometry.boundingSphere.radius*Math.max(k.x,Math.max(k.y,k.z));w=t(this.origin,this.direction,a.matrixWorld.getPosition());if(w>k)return d;var r,q,s=a.geometry,u=s.vertices,v;a.matrixRotationWorld.extractRotation(a.matrixWorld);k=0;for(n=s.faces.length;k< +n;k++){c=s.faces[k];i.copy(this.origin);j.copy(this.direction);v=a.matrixWorld;l=v.multiplyVector3(l.copy(c.centroid)).subSelf(i);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));r=j.dot(o);if(!(Math.abs(r)0:r<0))){m.add(i,j.multiplyScalar(q));w=i.distanceTo(m);if(!(wthis.far))if(c instanceof THREE.Face3){e=v.multiplyVector3(e.copy(u[c.a]));f=v.multiplyVector3(f.copy(u[c.b]));g=v.multiplyVector3(g.copy(u[c.c])); if(R(m,e,f,g)){c={distance:w,point:m.clone(),face:c,object:a};d.push(c)}}else if(c instanceof THREE.Face4){e=v.multiplyVector3(e.copy(u[c.a]));f=v.multiplyVector3(f.copy(u[c.b]));g=v.multiplyVector3(g.copy(u[c.c]));h=v.multiplyVector3(h.copy(u[c.d]));if(R(m,e,f,h)||R(m,f,g,h)){c={distance:w,point:m.clone(),face:c,object:a};d.push(c)}}}}}}d.sort(p);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,e=a.length;df?d:f;e=e>g?e:g}a()};this.add3Points=function(f,g,l,o,m,p){if(h===true){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===true){h=false;b=f.getLeft();c=f.getTop();d=f.getRight();e=f.getBottom()}else{b=bf.getRight()?d:f.getRight();e=e>f.getBottom()?e:f.getBottom()}a()};this.inflate=function(f){b=b-f;c=c-f;d=d+f;e=e+f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=da.getRight()||ea.getBottom()?false:true};this.empty=function(){h=true;e=d=c=b=0;a()};this.isEmpty=function(){return h}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a0?1:0}};THREE.Matrix3=function(){this.elements=new Float32Array(9)}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],e=-b[10]*b[4]+b[6]*b[8],f=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],h=b[9]*b[4]-b[5]*b[8],i=-b[9]*b[0]+b[1]*b[8],k=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*e+b[2]*h;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,l=this.elements;l[0]=b*a;l[1]=b*c;l[2]=b*d;l[3]=b*e;l[4]=b*f;l[5]=b*g;l[6]=b*h;l[7]=b*i;l[8]=b*k;return this}, -transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,f,g,h,i,k,l,o,m,p,r,n){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,f!==void 0?f:1,g||0,h||0,i||0,k||0,l!==void 0?l:1,o||0,m||0,p||0,r||0,n!==void 0?n:1)}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,i,k,l,o,m,p,r,n){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=g;q[13]=h;q[2]=i;q[6]=k;q[10]=l;q[14]=o;q[3]=m;q[7]=p;q[11]=r;q[15]=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements, -e=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;e.cross(c,g).normalize();if(e.length()===0){g.x=g.x+1.0E-4;e.cross(c,g).normalize()}f.cross(g,e);d[0]=e.x;d[4]=f.x;d[8]=g.x;d[1]=e.y;d[5]=f.y;d[9]=g.y;d[2]=e.z;d[6]=f.z;d[10]=g.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],i=c[12],k=c[1],l=c[5],o=c[9],m=c[13],p=c[2],r=c[6],n=c[10],q=c[14],s=c[3],u=c[7],w=c[11],c=c[15],t=d[0],x=d[4], -F=d[8],C=d[12],z=d[1],v=d[5],H=d[9],I=d[13],N=d[2],R=d[6],Y=d[10],B=d[14],G=d[3],Q=d[7],D=d[11],d=d[15];e[0]=f*t+g*z+h*N+i*G;e[4]=f*x+g*v+h*R+i*Q;e[8]=f*F+g*H+h*Y+i*D;e[12]=f*C+g*I+h*B+i*d;e[1]=k*t+l*z+o*N+m*G;e[5]=k*x+l*v+o*R+m*Q;e[9]=k*F+l*H+o*Y+m*D;e[13]=k*C+l*I+o*B+m*d;e[2]=p*t+r*z+n*N+q*G;e[6]=p*x+r*v+n*R+q*Q;e[10]=p*F+r*H+n*Y+q*D;e[14]=p*C+r*I+n*B+q*d;e[3]=s*t+u*z+w*N+c*G;e[7]=s*x+u*v+w*R+c*Q;e[11]=s*F+u*H+w*Y+c*D;e[15]=s*C+u*I+w*B+c*d;return this},multiplySelf:function(a){return this.multiply(this, +THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],e=-b[10]*b[4]+b[6]*b[8],f=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],h=b[9]*b[4]-b[5]*b[8],i=-b[9]*b[0]+b[1]*b[8],j=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*e+b[2]*h;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,l=this.elements;l[0]=b*a;l[1]=b*c;l[2]=b*d;l[3]=b*e;l[4]=b*f;l[5]=b*g;l[6]=b*h;l[7]=b*i;l[8]=b*j;return this}, +transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,f,g,h,i,j,l,o,m,p,r,n){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,f!==void 0?f:1,g||0,h||0,i||0,j||0,l!==void 0?l:1,o||0,m||0,p||0,r||0,n!==void 0?n:1)}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,i,j,l,o,m,p,r,n){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=g;q[13]=h;q[2]=i;q[6]=j;q[10]=l;q[14]=o;q[3]=m;q[7]=p;q[11]=r;q[15]=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements, +e=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;e.cross(c,g).normalize();if(e.length()===0){g.x=g.x+1.0E-4;e.cross(c,g).normalize()}f.cross(g,e);d[0]=e.x;d[4]=f.x;d[8]=g.x;d[1]=e.y;d[5]=f.y;d[9]=g.y;d[2]=e.z;d[6]=f.z;d[10]=g.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],i=c[12],j=c[1],l=c[5],o=c[9],m=c[13],p=c[2],r=c[6],n=c[10],q=c[14],s=c[3],u=c[7],w=c[11],c=c[15],t=d[0],x=d[4], +F=d[8],C=d[12],z=d[1],v=d[5],H=d[9],I=d[13],N=d[2],R=d[6],Y=d[10],B=d[14],G=d[3],Q=d[7],D=d[11],d=d[15];e[0]=f*t+g*z+h*N+i*G;e[4]=f*x+g*v+h*R+i*Q;e[8]=f*F+g*H+h*Y+i*D;e[12]=f*C+g*I+h*B+i*d;e[1]=j*t+l*z+o*N+m*G;e[5]=j*x+l*v+o*R+m*Q;e[9]=j*F+l*H+o*Y+m*D;e[13]=j*C+l*I+o*B+m*d;e[2]=p*t+r*z+n*N+q*G;e[6]=p*x+r*v+n*R+q*Q;e[10]=p*F+r*H+n*Y+q*D;e[14]=p*C+r*I+n*B+q*d;e[3]=s*t+u*z+w*N+c*G;e[7]=s*x+u*v+w*R+c*Q;e[11]=s*F+u*H+w*Y+c*D;e[15]=s*C+u*I+w*B+c*d;return this},multiplySelf:function(a){return this.multiply(this, a)},multiplyToArray:function(a,b,c){var d=this.elements;this.multiply(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]=b[0]*a;b[4]=b[4]*a;b[8]=b[8]*a;b[12]=b[12]*a;b[1]=b[1]*a;b[5]=b[5]*a;b[9]=b[9]*a;b[13]=b[13]*a;b[2]=b[2]*a;b[6]=b[6]*a;b[10]=b[10]*a;b[14]=b[14]*a;b[3]=b[3]*a;b[7]=b[7]*a;b[11]=b[11]*a;b[15]= b[15]*a;return this},multiplyVector3:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=1/(b[3]*c+b[7]*d+b[11]*e+b[15]);a.x=(b[0]*c+b[4]*d+b[8]*e+b[12])*f;a.y=(b[1]*c+b[5]*d+b[9]*e+b[13])*f;a.z=(b[2]*c+b[6]*d+b[10]*e+b[14])*f;return a},multiplyVector4:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w;a.x=b[0]*c+b[4]*d+b[8]*e+b[12]*f;a.y=b[1]*c+b[5]*d+b[9]*e+b[13]*f;a.z=b[2]*c+b[6]*d+b[10]*e+b[14]*f;a.w=b[3]*c+b[7]*d+b[11]*e+b[15]*f;return a},multiplyVector3Array:function(a){for(var b=THREE.Matrix4.__v1, c=0,d=a.length;c=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(d=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=k[i-2];I.copy(aa.positionScreen);N.copy(K.positionScreen);if(d(I,N)===true){I.multiplyScalar(1/I.w);N.multiplyScalar(1/N.w);X=void 0;if(q===s.length){X=new THREE.RenderableLine;s.push(X)}else X=s[q];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(j=x.sprites.length;ag&&h.positionScreen.z0)){K=j[i-2];I.copy(aa.positionScreen);N.copy(K.positionScreen);if(d(I,N)===true){I.multiplyScalar(1/I.w);N.multiplyScalar(1/N.w);X=void 0;if(q===s.length){X=new THREE.RenderableLine;s.push(X)}else X=s[q];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=void 0;if(w===t.length){g=new THREE.RenderableParticle;t.push(g)}else g=t[w];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=Math.cos(a.x/2),d=Math.cos(a.y/2),e=Math.cos(a.z/2),f=Math.sin(a.x/2),g=Math.sin(a.y/2),h=Math.sin(a.z/2);if(b===void 0||b==="XYZ"){this.x=f*d*e+c*g*h;this.y=c*g*e-f*d*h;this.z=c*d*h+f*g*e;this.w=c*d*e-f*g*h}else if(b==="YXZ"){this.x=f*d*e+c*g*h;this.y=c*g*e-f*d*h;this.z= c*d*h-f*g*e;this.w=c*d*e+f*g*h}else if(b==="ZXY"){this.x=f*d*e-c*g*h;this.y=c*g*e+f*d*h;this.z=c*d*h+f*g*e;this.w=c*d*e-f*g*h}else if(b==="ZYX"){this.x=f*d*e-c*g*h;this.y=c*g*e+f*d*h;this.z=c*d*h-f*g*e;this.w=c*d*e+f*g*h}else if(b==="YZX"){this.x=f*d*e+c*g*h;this.y=c*g*e+f*d*h;this.z=c*d*h-f*g*e;this.w=c*d*e-f*g*h}else if(b==="XZY"){this.x=f*d*e-c*g*h;this.y=c*g*e-f*d*h;this.z=c*d*h+f*g*e;this.w=c*d*e+f*g*h}return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y* -d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=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],k=c+f+b;if(k>0){c=0.5/Math.sqrt(k+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;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,k=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=k*i+c*-f+l*-h-o*-g;b.y=l*i+c*-g+o*-f-k*-h;b.z=o*i+c*-h+k*-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); +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.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}; @@ -107,17 +107,17 @@ b;a++){c=this.faces[a];d=this.vertices[c.a];e=this.vertices[c.b];f=this.vertices else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a0){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;ethis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1: -f+2;k=this.points[c[0]];l=this.points[c[1]];o=this.points[c[2]];m=this.points[c[3]];h=g*g;i=g*h;d.x=b(k.x,l.x,o.x,m.x,g,h,i);d.y=b(k.y,l.y,o.y,m.y,g,h,i);d.z=b(k.z,l.z,o.z,m.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;athis.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1: +f+2;j=this.points[c[0]];l=this.points[c[1]];o=this.points[c[2]];m=this.points[c[3]];h=g*g;i=g*h;d.x=b(j.x,l.x,o.x,m.x,g,h,i);d.y=b(j.y,l.y,o.y,m.y,g,h,i);d.z=b(j.z,l.z,o.z,m.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a1&&(N=new THREE.MeshFaceMaterial); +THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:j+"/"+a}function e(){var a;for(m in B.objects)if(!L.objects[m]){s=B.objects[m];if(s.geometry!==void 0){if(I=L.geometries[s.geometry]){a=false;N=L.materials[s.materials[0]];(a=N instanceof THREE.ShaderMaterial)&&I.computeTangents();x=s.position;F=s.rotation;C=s.quaternion;z=s.scale;u=s.matrix;C=0;s.materials.length==0&&(N=new THREE.MeshFaceMaterial);s.materials.length>1&&(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=s.visible;a.doubleSided=s.doubleSided;a.castShadow=s.castShadow;a.receiveShadow=s.receiveShadow;L.scene.add(a);L.objects[m]=a}}else{x=s.position;F=s.rotation;C=s.quaternion; -z=s.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=s.visible!==void 0?s.visible:false;L.scene.add(a);L.objects[m]=a;L.empties[m]=a}}}function f(a){return function(b){L.geometries[a]=b;e();Q=Q-1;i.onLoadComplete();h()}}function g(a){return function(b){L.geometries[a]=b}}function h(){i.callbackProgress({totalModels:j,totalTextures:P,loadedModels:j- -Q,loadedTextures:P-D},L);i.onLoadProgress();Q===0&&D===0&&b(L)}var i=this,k=THREE.Loader.prototype.extractUrlBase(c),l,o,m,p,r,n,q,s,u,w,t,x,F,C,z,v,H,I,N,R,Y,B,G,Q,D,j,P,L;B=a;c=new THREE.BinaryLoader;G=new THREE.JSONLoader;D=Q=0;L={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&&L.scene.position.set(a[0],a[1],a[2]);w&&L.scene.rotation.set(w[0],w[1], +z=s.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=s.visible!==void 0?s.visible:false;L.scene.add(a);L.objects[m]=a;L.empties[m]=a}}}function f(a){return function(b){L.geometries[a]=b;e();Q=Q-1;i.onLoadComplete();h()}}function g(a){return function(b){L.geometries[a]=b}}function h(){i.callbackProgress({totalModels:k,totalTextures:P,loadedModels:k- +Q,loadedTextures:P-D},L);i.onLoadProgress();Q===0&&D===0&&b(L)}var i=this,j=THREE.Loader.prototype.extractUrlBase(c),l,o,m,p,r,n,q,s,u,w,t,x,F,C,z,v,H,I,N,R,Y,B,G,Q,D,k,P,L;B=a;c=new THREE.BinaryLoader;G=new THREE.JSONLoader;D=Q=0;L={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&&L.scene.position.set(a[0],a[1],a[2]);w&&L.scene.rotation.set(w[0],w[1], w[2]);v&&L.scene.scale.set(v[0],v[1],v[2]);if(a||w||v){L.scene.updateMatrix();L.scene.updateMatrixWorld()}}a=function(a){return function(){D=D-a;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]);L.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;t=new THREE.DirectionalLight(r,R);t.position.set(x[0],x[1],x[2]);t.position.normalize()}else if(w.type==="point"){x=w.position;t=w.distance;t=new THREE.PointLight(r,R,t);t.position.set(x[0],x[1],x[2])}else w.type==="ambient"&&(t=new THREE.AmbientLight(r));L.scene.add(t);L.lights[p]=t}for(n in B.fogs){p=B.fogs[n];p.type==="linear"? -Y=new THREE.Fog(0,p.near,p.far):p.type==="exp2"&&(Y=new THREE.FogExp2(0,p.density));v=p.color;Y.color.setRGB(v[0],v[1],v[2]);L.fogs[n]=Y}if(L.cameras&&B.defaults.camera)L.currentCamera=L.cameras[B.defaults.camera];if(L.fogs&&B.defaults.fog)L.scene.fog=L.fogs[B.defaults.fog];v=B.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(v[0],v[1],v[2]);L.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()}}j=Q; +Y=new THREE.Fog(0,p.near,p.far):p.type==="exp2"&&(Y=new THREE.FogExp2(0,p.density));v=p.color;Y.color.setRGB(v[0],v[1],v[2]);L.fogs[n]=Y}if(L.cameras&&B.defaults.camera)L.currentCamera=L.cameras[B.defaults.camera];if(L.fogs&&B.defaults.fog)L.scene.fog=L.fogs[B.defaults.fog];v=B.defaults.bgcolor;L.bgColor=new THREE.Color;L.bgColor.setRGB(v[0],v[1],v[2]);L.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);L.geometries[l]=I}else if(n.type==="plane"){I=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight);L.geometries[l]=I}else if(n.type==="sphere"){I=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight);L.geometries[l]=I}else if(n.type==="cylinder"){I=new THREE.CylinderGeometry(n.topRad, n.botRad,n.height,n.radSegs,n.heightSegs);L.geometries[l]=I}else if(n.type==="torus"){I=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT);L.geometries[l]=I}else if(n.type==="icosahedron"){I=new THREE.IcosahedronGeometry(n.radius,n.subdivisions);L.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)+","+s+")");n.fillRect(Math.floor(Ca.getX()),Math.floor(Ca.getY()),Math.floor(Ca.getWidth()),Math.floor(Ca.getHeight()))}Ca.empty()}};this.render=function(a,l){function m(a){var b,c,d,e;wa.setRGB(0,0,0);Ra.setRGB(0,0,0);Fa.setRGB(0,0,0);b=0;for(c=a.length;b>1;m=l.height>>1;g=f.scale.x*p;i=f.scale.y*r;h=g*k;j=i*m;za.set(a.x-h,a.y-j,a.x+h,a.y+j);if(bb.intersects(za)!==false){n.save();n.translate(a.x,a.y);n.rotate(-f.rotation);n.scale(g,-i);n.translate(-k,-m);n.drawImage(l,0,0);n.restore()}}}else if(g instanceof THREE.ParticleCanvasMaterial){h= -f.scale.x*p;j=f.scale.y*r;za.set(a.x-h,a.y-j,a.x+h,a.y+j);if(bb.intersects(za)!==false){d(g.color.getContextStyle());e(g.color.getContextStyle());n.save();n.translate(a.x,a.y);n.rotate(-f.rotation);n.scale(h,j);g.program(n);n.restore()}}}function s(a,e,f,g){b(g.opacity);c(g.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(F!==a)F=n.lineWidth=a;a=g.linecap; -if(C!==a)C=n.lineCap=a;a=g.linejoin;if(z!==a)z=n.lineJoin=a;d(g.color.getContextStyle());n.stroke();za.inflate(g.linewidth*2)}}function t(a,d,e,g,h,k,m,n){f.info.render.vertices=f.info.render.vertices+3;f.info.render.faces++;b(n.opacity);c(n.blending);B=a.positionScreen.x;G=a.positionScreen.y;Q=d.positionScreen.x;D=d.positionScreen.y;j=e.positionScreen.x;P=e.positionScreen.y;w(B,G,Q,D,j,P);if(n instanceof THREE.MeshBasicMaterial)if(n.map!==null){if(n.map.mapping instanceof THREE.UVMapping){fb=m.uvs[0]; -bd(B,G,Q,D,j,P,fb[g].u,fb[g].v,fb[h].u,fb[h].v,fb[k].u,fb[k].v,n.map)}}else if(n.envMap!==null){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping){a=l.matrixWorldInverse;ja.copy(m.vertexNormalsWorld[g]);gb=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;$a=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ja.z*a.elements[9])*0.5+0.5;ja.copy(m.vertexNormalsWorld[h]);ob=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;kb=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ -ja.z*a.elements[9])*0.5+0.5;ja.copy(m.vertexNormalsWorld[k]);pb=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;hb=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ja.z*a.elements[9])*0.5+0.5;bd(B,G,Q,D,j,P,gb,$a,ob,kb,pb,hb,n.envMap)}}else n.wireframe===true?Nb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color);else if(n instanceof THREE.MeshLambertMaterial)if(lb===true)if(n.wireframe===false&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3){Z.r= -$.r=X.r=wa.r;Z.g=$.g=X.g=wa.g;Z.b=$.b=X.b=wa.b;o(i,m.v1.positionWorld,m.vertexNormalsWorld[0],Z);o(i,m.v2.positionWorld,m.vertexNormalsWorld[1],$);o(i,m.v3.positionWorld,m.vertexNormalsWorld[2],X);Z.r=Math.max(0,Math.min(n.color.r*Z.r,1));Z.g=Math.max(0,Math.min(n.color.g*Z.g,1));Z.b=Math.max(0,Math.min(n.color.b*Z.b,1));$.r=Math.max(0,Math.min(n.color.r*$.r,1));$.g=Math.max(0,Math.min(n.color.g*$.g,1));$.b=Math.max(0,Math.min(n.color.b*$.b,1));X.r=Math.max(0,Math.min(n.color.r*X.r,1));X.g=Math.max(0, -Math.min(n.color.g*X.g,1));X.b=Math.max(0,Math.min(n.color.b*X.b,1));ia.r=($.r+X.r)*0.5;ia.g=($.g+X.g)*0.5;ia.b=($.b+X.b)*0.5;Ua=Dc(Z,$,X,ia);ic(B,G,Q,D,j,P,0,0,1,0,0,1,Ua)}else{O.r=wa.r;O.g=wa.g;O.b=wa.b;o(i,m.centroidWorld,m.normalWorld,O);O.r=Math.max(0,Math.min(n.color.r*O.r,1));O.g=Math.max(0,Math.min(n.color.g*O.g,1));O.b=Math.max(0,Math.min(n.color.b*O.b,1));n.wireframe===true?Nb(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}else n.wireframe===true?Nb(n.color,n.wireframeLinewidth, -n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color);else if(n instanceof THREE.MeshDepthMaterial){Pa=l.near;Qa=l.far;Z.r=Z.g=Z.b=1-cc(a.positionScreen.z,Pa,Qa);$.r=$.g=$.b=1-cc(d.positionScreen.z,Pa,Qa);X.r=X.g=X.b=1-cc(e.positionScreen.z,Pa,Qa);ia.r=($.r+X.r)*0.5;ia.g=($.g+X.g)*0.5;ia.b=($.b+X.b)*0.5;Ua=Dc(Z,$,X,ia);ic(B,G,Q,D,j,P,0,0,1,0,0,1,Ua)}else if(n instanceof THREE.MeshNormalMaterial){O.r=jc(m.normalWorld.x);O.g=jc(m.normalWorld.y);O.b=jc(m.normalWorld.z);n.wireframe===true?Nb(O,n.wireframeLinewidth, -n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}}function u(a,d,e,g,h,k,m,n,ga){f.info.render.vertices=f.info.render.vertices+4;f.info.render.faces++;b(n.opacity);c(n.blending);if(n.map!==null||n.envMap!==null){t(a,d,g,0,1,3,m,n,ga);t(h,e,k,1,2,3,m,n,ga)}else{B=a.positionScreen.x;G=a.positionScreen.y;Q=d.positionScreen.x;D=d.positionScreen.y;j=e.positionScreen.x;P=e.positionScreen.y;L=g.positionScreen.x;S=g.positionScreen.y;aa=h.positionScreen.x;K=h.positionScreen.y;ca=k.positionScreen.x;ha=k.positionScreen.y; -if(n instanceof THREE.MeshBasicMaterial){x(B,G,Q,D,j,P,L,S);n.wireframe===true?Nb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color)}else if(n instanceof THREE.MeshLambertMaterial)if(lb===true)if(!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==4){Z.r=$.r=X.r=ia.r=wa.r;Z.g=$.g=X.g=ia.g=wa.g;Z.b=$.b=X.b=ia.b=wa.b;o(i,m.v1.positionWorld,m.vertexNormalsWorld[0],Z);o(i,m.v2.positionWorld,m.vertexNormalsWorld[1],$);o(i,m.v4.positionWorld,m.vertexNormalsWorld[3], +THREE.CanvasRenderer=function(a){function b(a){if(u!==a)u=n.globalAlpha=a}function c(a){if(w!==a){if(a===THREE.NormalBlending)n.globalCompositeOperation="source-over";else if(a===THREE.AdditiveBlending)n.globalCompositeOperation="lighter";else if(a===THREE.SubtractiveBlending)n.globalCompositeOperation="darker";w=a}}function d(a){if(t!==a)t=n.strokeStyle=a}function e(a){if(x!==a)x=n.fillStyle=a}console.log("THREE.CanvasRenderer",THREE.REVISION);var a=a||{},f=this,g,h,i,j=new THREE.Projector,l=a.canvas!== +void 0?a.canvas:document.createElement("canvas"),o,m,p,r,n=l.getContext("2d"),q=new THREE.Color(0),s=0,u=1,w=0,t=null,x=null,F=null,C=null,z=null,v,H,I,N,R=new THREE.RenderableVertex,Y=new THREE.RenderableVertex,B,G,Q,D,k,P,L,S,aa,K,ca,ha,O=new THREE.Color,Z=new THREE.Color,$=new THREE.Color,X=new THREE.Color,ia=new THREE.Color,za=[],Ga=[],Oa,Pa,Ta,Wa,lb,$a,mb,Fb,ab,nb,bb=new THREE.Rectangle,Ha=new THREE.Rectangle,wa=new THREE.Rectangle,ib=false,xa=new THREE.Color,Qa=new THREE.Color,Da=new THREE.Color, +ja=new THREE.Vector3,ob,fb,bc,ga,rc,Gc,a=16;ob=document.createElement("canvas");ob.width=ob.height=2;fb=ob.getContext("2d");fb.fillStyle="rgba(0,0,0,1)";fb.fillRect(0,0,2,2);bc=fb.getImageData(0,0,2,2);ga=bc.data;rc=document.createElement("canvas");rc.width=rc.height=a;Gc=rc.getContext("2d");Gc.translate(-a/2,-a/2);Gc.scale(a,a);a--;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=true;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){o=a;m=b;p=Math.floor(o/2); +r=Math.floor(m/2);l.width=o;l.height=m;bb.set(-p,-r,p,r);Ha.set(-p,-r,p,r);u=1;w=0;z=C=F=x=t=null};this.setClearColor=function(a,b){q.copy(a);s=b!==void 0?b:1;Ha.set(-p,-r,p,r)};this.setClearColorHex=function(a,b){q.setHex(a);s=b!==void 0?b:1;Ha.set(-p,-r,p,r)};this.clear=function(){n.setTransform(1,0,0,-1,p,r);if(Ha.isEmpty()===false){Ha.minSelf(bb);Ha.inflate(2);s<1&&n.clearRect(Math.floor(Ha.getX()),Math.floor(Ha.getY()),Math.floor(Ha.getWidth()),Math.floor(Ha.getHeight()));if(s>0){c(THREE.NormalBlending); +b(1);e("rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+s+")");n.fillRect(Math.floor(Ha.getX()),Math.floor(Ha.getY()),Math.floor(Ha.getWidth()),Math.floor(Ha.getHeight()))}Ha.empty()}};this.render=function(a,l){function m(a){var b,c,d,e;xa.setRGB(0,0,0);Qa.setRGB(0,0,0);Da.setRGB(0,0,0);b=0;for(c=a.length;b>1;m=l.height>>1;g=f.scale.x*p;i=f.scale.y*r;h=g*j;k=i*m;wa.set(a.x-h,a.y-k,a.x+h,a.y+k);if(bb.intersects(wa)!==false){n.save();n.translate(a.x,a.y);n.rotate(-f.rotation);n.scale(g,-i);n.translate(-j,-m);n.drawImage(l,0,0);n.restore()}}}else if(g instanceof THREE.ParticleCanvasMaterial){h= +f.scale.x*p;k=f.scale.y*r;wa.set(a.x-h,a.y-k,a.x+h,a.y+k);if(bb.intersects(wa)!==false){d(g.color.getContextStyle());e(g.color.getContextStyle());n.save();n.translate(a.x,a.y);n.rotate(-f.rotation);n.scale(h,k);g.program(n);n.restore()}}}function s(a,e,f,g){b(g.opacity);c(g.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(F!==a)F=n.lineWidth=a;a=g.linecap; +if(C!==a)C=n.lineCap=a;a=g.linejoin;if(z!==a)z=n.lineJoin=a;d(g.color.getContextStyle());n.stroke();wa.inflate(g.linewidth*2)}}function t(a,d,e,g,h,j,m,n){f.info.render.vertices=f.info.render.vertices+3;f.info.render.faces++;b(n.opacity);c(n.blending);B=a.positionScreen.x;G=a.positionScreen.y;Q=d.positionScreen.x;D=d.positionScreen.y;k=e.positionScreen.x;P=e.positionScreen.y;w(B,G,Q,D,k,P);if(n instanceof THREE.MeshBasicMaterial)if(n.map!==null){if(n.map.mapping instanceof THREE.UVMapping){Wa=m.uvs[0]; +kd(B,G,Q,D,k,P,Wa[g].u,Wa[g].v,Wa[h].u,Wa[h].v,Wa[j].u,Wa[j].v,n.map)}}else if(n.envMap!==null){if(n.envMap.mapping instanceof THREE.SphericalReflectionMapping){a=l.matrixWorldInverse;ja.copy(m.vertexNormalsWorld[g]);lb=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;$a=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ja.z*a.elements[9])*0.5+0.5;ja.copy(m.vertexNormalsWorld[h]);mb=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;Fb=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ +ja.z*a.elements[9])*0.5+0.5;ja.copy(m.vertexNormalsWorld[j]);ab=(ja.x*a.elements[0]+ja.y*a.elements[4]+ja.z*a.elements[8])*0.5+0.5;nb=-(ja.x*a.elements[1]+ja.y*a.elements[5]+ja.z*a.elements[9])*0.5+0.5;kd(B,G,Q,D,k,P,lb,$a,mb,Fb,ab,nb,n.envMap)}}else n.wireframe===true?Mb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Gb(n.color);else if(n instanceof THREE.MeshLambertMaterial)if(ib===true)if(n.wireframe===false&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3){Z.r= +$.r=X.r=xa.r;Z.g=$.g=X.g=xa.g;Z.b=$.b=X.b=xa.b;o(i,m.v1.positionWorld,m.vertexNormalsWorld[0],Z);o(i,m.v2.positionWorld,m.vertexNormalsWorld[1],$);o(i,m.v3.positionWorld,m.vertexNormalsWorld[2],X);Z.r=Math.max(0,Math.min(n.color.r*Z.r,1));Z.g=Math.max(0,Math.min(n.color.g*Z.g,1));Z.b=Math.max(0,Math.min(n.color.b*Z.b,1));$.r=Math.max(0,Math.min(n.color.r*$.r,1));$.g=Math.max(0,Math.min(n.color.g*$.g,1));$.b=Math.max(0,Math.min(n.color.b*$.b,1));X.r=Math.max(0,Math.min(n.color.r*X.r,1));X.g=Math.max(0, +Math.min(n.color.g*X.g,1));X.b=Math.max(0,Math.min(n.color.b*X.b,1));ia.r=($.r+X.r)*0.5;ia.g=($.g+X.g)*0.5;ia.b=($.b+X.b)*0.5;Ta=Hc(Z,$,X,ia);ic(B,G,Q,D,k,P,0,0,1,0,0,1,Ta)}else{O.r=xa.r;O.g=xa.g;O.b=xa.b;o(i,m.centroidWorld,m.normalWorld,O);O.r=Math.max(0,Math.min(n.color.r*O.r,1));O.g=Math.max(0,Math.min(n.color.g*O.g,1));O.b=Math.max(0,Math.min(n.color.b*O.b,1));n.wireframe===true?Mb(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Gb(O)}else n.wireframe===true?Mb(n.color,n.wireframeLinewidth, +n.wireframeLinecap,n.wireframeLinejoin):Gb(n.color);else if(n instanceof THREE.MeshDepthMaterial){Oa=l.near;Pa=l.far;Z.r=Z.g=Z.b=1-cc(a.positionScreen.z,Oa,Pa);$.r=$.g=$.b=1-cc(d.positionScreen.z,Oa,Pa);X.r=X.g=X.b=1-cc(e.positionScreen.z,Oa,Pa);ia.r=($.r+X.r)*0.5;ia.g=($.g+X.g)*0.5;ia.b=($.b+X.b)*0.5;Ta=Hc(Z,$,X,ia);ic(B,G,Q,D,k,P,0,0,1,0,0,1,Ta)}else if(n instanceof THREE.MeshNormalMaterial){O.r=jc(m.normalWorld.x);O.g=jc(m.normalWorld.y);O.b=jc(m.normalWorld.z);n.wireframe===true?Mb(O,n.wireframeLinewidth, +n.wireframeLinecap,n.wireframeLinejoin):Gb(O)}}function u(a,d,e,g,h,j,m,n,ga){f.info.render.vertices=f.info.render.vertices+4;f.info.render.faces++;b(n.opacity);c(n.blending);if(n.map!==null||n.envMap!==null){t(a,d,g,0,1,3,m,n,ga);t(h,e,j,1,2,3,m,n,ga)}else{B=a.positionScreen.x;G=a.positionScreen.y;Q=d.positionScreen.x;D=d.positionScreen.y;k=e.positionScreen.x;P=e.positionScreen.y;L=g.positionScreen.x;S=g.positionScreen.y;aa=h.positionScreen.x;K=h.positionScreen.y;ca=j.positionScreen.x;ha=j.positionScreen.y; +if(n instanceof THREE.MeshBasicMaterial){x(B,G,Q,D,k,P,L,S);n.wireframe===true?Mb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Gb(n.color)}else if(n instanceof THREE.MeshLambertMaterial)if(ib===true)if(!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==4){Z.r=$.r=X.r=ia.r=xa.r;Z.g=$.g=X.g=ia.g=xa.g;Z.b=$.b=X.b=ia.b=xa.b;o(i,m.v1.positionWorld,m.vertexNormalsWorld[0],Z);o(i,m.v2.positionWorld,m.vertexNormalsWorld[1],$);o(i,m.v4.positionWorld,m.vertexNormalsWorld[3], X);o(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ia);Z.r=Math.max(0,Math.min(n.color.r*Z.r,1));Z.g=Math.max(0,Math.min(n.color.g*Z.g,1));Z.b=Math.max(0,Math.min(n.color.b*Z.b,1));$.r=Math.max(0,Math.min(n.color.r*$.r,1));$.g=Math.max(0,Math.min(n.color.g*$.g,1));$.b=Math.max(0,Math.min(n.color.b*$.b,1));X.r=Math.max(0,Math.min(n.color.r*X.r,1));X.g=Math.max(0,Math.min(n.color.g*X.g,1));X.b=Math.max(0,Math.min(n.color.b*X.b,1));ia.r=Math.max(0,Math.min(n.color.r*ia.r,1));ia.g=Math.max(0,Math.min(n.color.g* -ia.g,1));ia.b=Math.max(0,Math.min(n.color.b*ia.b,1));Ua=Dc(Z,$,X,ia);w(B,G,Q,D,L,S);ic(B,G,Q,D,L,S,0,0,1,0,0,1,Ua);w(aa,K,j,P,ca,ha);ic(aa,K,j,P,ca,ha,1,0,1,1,0,1,Ua)}else{O.r=wa.r;O.g=wa.g;O.b=wa.b;o(i,m.centroidWorld,m.normalWorld,O);O.r=Math.max(0,Math.min(n.color.r*O.r,1));O.g=Math.max(0,Math.min(n.color.g*O.g,1));O.b=Math.max(0,Math.min(n.color.b*O.b,1));x(B,G,Q,D,j,P,L,S);n.wireframe===true?Nb(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}else{x(B,G,Q,D,j,P,L,S);n.wireframe=== -true?Nb(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(n.color)}else if(n instanceof THREE.MeshNormalMaterial){O.r=jc(m.normalWorld.x);O.g=jc(m.normalWorld.y);O.b=jc(m.normalWorld.z);x(B,G,Q,D,j,P,L,S);n.wireframe===true?Nb(O,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):Hb(O)}else if(n instanceof THREE.MeshDepthMaterial){Pa=l.near;Qa=l.far;Z.r=Z.g=Z.b=1-cc(a.positionScreen.z,Pa,Qa);$.r=$.g=$.b=1-cc(d.positionScreen.z,Pa,Qa);X.r=X.g=X.b=1-cc(g.positionScreen.z, -Pa,Qa);ia.r=ia.g=ia.b=1-cc(e.positionScreen.z,Pa,Qa);Ua=Dc(Z,$,X,ia);w(B,G,Q,D,L,S);ic(B,G,Q,D,L,S,0,0,1,0,0,1,Ua);w(aa,K,j,P,ca,ha);ic(aa,K,j,P,ca,ha,1,0,1,1,0,1,Ua)}}}function w(a,b,c,d,e,f){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(a,b)}function x(a,b,c,d,e,f,g,h){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(g,h);n.lineTo(a,b)}function Nb(a,b,c,e){if(F!==b)F=n.lineWidth=b;if(C!==c)C=n.lineCap=c;if(z!==e)z=n.lineJoin=e;d(a.getContextStyle());n.stroke(); -za.inflate(b*2)}function Hb(a){e(a.getContextStyle());n.fill()}function bd(a,b,c,d,f,g,h,j,i,k,l,m,o){if(!(o.image===void 0||o.image.width===0)){if(o.needsUpdate===true||ya[o.id]===void 0){var ga=o.wrapS==THREE.RepeatWrapping,p=o.wrapT==THREE.RepeatWrapping;ya[o.id]=n.createPattern(o.image,ga===true&&p===true?"repeat":ga===true&&p===false?"repeat-x":ga===false&&p===true?"repeat-y":"no-repeat");o.needsUpdate=false}e(ya[o.id]);var ga=o.offset.x/o.repeat.x,p=o.offset.y/o.repeat.y,r=o.image.width*o.repeat.x, -q=o.image.height*o.repeat.y,h=(h+ga)*r,j=(j+p)*q,c=c-a,d=d-b,f=f-a,g=g-b,i=(i+ga)*r-h,k=(k+p)*q-j,l=(l+ga)*r-h,m=(m+p)*q-j,ga=i*m-l*k;if(ga===0){if(Ia[o.id]===void 0){b=document.createElement("canvas");b.width=o.image.width;b.height=o.image.height;b=b.getContext("2d");b.drawImage(o.image,0,0);Ia[o.id]=b.getImageData(0,0,o.image.width,o.image.height).data}b=Ia[o.id];h=(Math.floor(h)+Math.floor(j)*o.image.width)*4;O.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);Hb(O)}else{ga=1/ga;o=(m*c-k*f)*ga;k=(m*d-k*g)* -ga;c=(i*f-l*c)*ga;d=(i*g-l*d)*ga;a=a-o*h-c*j;h=b-k*h-d*j;n.save();n.transform(o,k,c,d,a,h);n.fill();n.restore()}}}function ic(a,b,c,d,e,f,g,h,j,i,k,l,m){var o,ga;o=m.width-1;ga=m.height-1;g=g*o;h=h*ga;c=c-a;d=d-b;e=e-a;f=f-b;j=j*o-g;i=i*ga-h;k=k*o-g;l=l*ga-h;ga=1/(j*l-k*i);o=(l*c-i*e)*ga;i=(l*d-i*f)*ga;c=(j*e-k*c)*ga;d=(j*f-k*d)*ga;a=a-o*g-c*h;b=b-i*g-d*h;n.save();n.transform(o,i,c,d,a,b);n.clip();n.drawImage(m,0,0);n.restore()}function Dc(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g= -~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),j=~~(c.r*255),i=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);ga[0]=e<0?0:e>255?255:e;ga[1]=f<0?0:f>255?255:f;ga[2]=a<0?0:a>255?255:a;ga[4]=g<0?0:g>255?255:g;ga[5]=h<0?0:h>255?255:h;ga[6]=b<0?0:b>255?255:b;ga[8]=j<0?0:j>255?255:j;ga[9]=i<0?0:i>255?255:i;ga[10]=c<0?0:c>255?255:c;ga[12]=k<0?0:k>255?255:k;ga[13]=l<0?0:l>255?255:l;ga[14]=d<0?0:d>255?255:d;ab.putImageData(bc,0,0);Cc.drawImage(qb,0,0);return qc}function cc(a,b,c){a=(a-b)/(c- -b);return a*a*(3-2*a)}function jc(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Ob(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;if(e!==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 Ec,cd,Ma,ib;this.autoClear===true?this.clear():n.setTransform(1,0,0,-1,p,r);f.info.render.vertices=0;f.info.render.faces=0;g=k.projectScene(a,l,this.sortElements);h=g.elements;i=g.lights;lb=i.length>0;lb===true&&m(i);Ec=0;for(cd=h.length;Ec255?255:e;ga[1]=f<0?0:f>255?255:f;ga[2]=a<0?0:a>255?255:a;ga[4]=g<0?0:g>255?255:g;ga[5]=h<0?0:h>255?255:h;ga[6]=b<0?0:b>255?255:b;ga[8]=k<0?0:k>255?255:k;ga[9]=i<0?0:i>255?255:i;ga[10]=c<0?0:c>255?255:c;ga[12]=j<0?0:j>255?255:j;ga[13]=l<0?0:l>255?255:l;ga[14]=d<0?0:d>255?255:d;fb.putImageData(bc,0,0);Gc.drawImage(ob,0,0);return rc}function cc(a,b,c){a=(a-b)/(c- +b);return a*a*(3-2*a)}function jc(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Nb(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;if(e!==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 Ic,ld,La,gb;this.autoClear===true?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;ib=i.length>0;ib===true&&m(i);Ic=0;for(ld=h.length;Ic=0)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?false:a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?true:false}function f(a,b,c){var d,e,f,g,h=a.vertices;g=h.length; -var i=a.colors,k=i.length,l=a.__vertexArray,m=a.__colorArray,n=a.__sortArray,o=a.verticesNeedUpdate,p=a.colorsNeedUpdate,r=a.__webglCustomAttributesList;if(c.sortParticles){wa.copy(lb);wa.multiplySelf(c.matrixWorld);for(d=0;d=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){j.useProgram(g);S=g;f=true}if(d.id!==K){K=d.id;f=true}if(f||a!==ha){j.uniformMatrix4fv(h.projectionMatrix, -false,a._projectionMatrixArray);a!==ha&&(ha=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(ja){for(var k,l=0,m=0,n=0,o,p,r,q=qb,s=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,X=0,L=0,O=r=0,c=O=0,f=b.length;c=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!==ha){k.uniformMatrix4fv(h.projectionMatrix, +false,a._projectionMatrixArray);a!==ha&&(ha=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(ja){for(var j,l=0,m=0,n=0,o,p,r,q=ob,s=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,X=0,L=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){ob=a;kb=b;pb=c;hb=d;j.viewport(ob,kb,pb,hb)};this.setScissor=function(a,b,c,d){j.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)};this.setClearColorHex=function(a,b){B.setHex(a);G=b;j.clearColor(B.r,B.g,B.b,G)};this.setClearColor=function(a,b){B.copy(a);G=b;j.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|j.COLOR_BUFFER_BIT;if(b===void 0||b)d=d|j.DEPTH_BUFFER_BIT;if(c===void 0||c)d=d|j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit){a.__webglInit=false;delete a._modelViewMatrix; -delete a._normalMatrix;delete a._normalMatrixArray;delete a._modelViewMatrixArray;delete a._objectMatrixArray;if(a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];j.deleteBuffer(c.__webglVertexBuffer);j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer); -j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets){d=0;for(e=c.numMorphTargets;d1&&(b=true);d=0;for(c=f.length;d=0&&e.vertexNormalBuffer){g=e.vertexNormalBuffer.itemSize;j.bindBuffer(j.ARRAY_BUFFER,e.vertexNormalBuffer);j.vertexAttribPointer(a.normal, -g,j.FLOAT,false,0,f[d].index*g*4)}if(a.uv>=0&&e.vertexUvBuffer)if(e.vertexUvBuffer){g=e.vertexUvBuffer.itemSize;j.bindBuffer(j.ARRAY_BUFFER,e.vertexUvBuffer);j.vertexAttribPointer(a.uv,g,j.FLOAT,false,0,f[d].index*g*4);j.enableVertexAttribArray(a.uv)}else j.disableVertexAttribArray(a.uv);if(a.color>=0&&e.vertexColorBuffer){g=e.vertexColorBuffer.itemSize;j.bindBuffer(j.ARRAY_BUFFER,e.vertexColorBuffer);j.vertexAttribPointer(a.color,g,j.FLOAT,false,0,f[d].index*g*4)}j.bindBuffer(j.ELEMENT_ARRAY_BUFFER, -e.vertexIndexBuffer)}j.drawElements(j.TRIANGLES,f[d].count,j.UNSIGNED_SHORT,f[d].start*2);D.info.render.calls++;D.info.render.vertices=D.info.render.vertices+f[d].count;D.info.render.faces=D.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var g,i,c=q(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ca){ca=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer);j.vertexAttribPointer(b.position, -3,j.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]);j.vertexAttribPointer(c.position,3,j.FLOAT,false,0,0)}else if(c.position>=0){j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer);j.vertexAttribPointer(c.position,3,j.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var k=0;i=f.morphTargetForcedOrder;for(g=f.morphTargetInfluences;k0&&i.push([l,k])}if(i.length>d.numSupportedMorphTargets){i.sort(h);i.length=d.numSupportedMorphTargets}else i.length>d.numSupportedMorphNormals? -i.sort(h):i.length===0&&i.push([0,0]);for(k=0;k=0){j.bindBuffer(j.ARRAY_BUFFER,c.buffer);j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,false,0,0)}}}if(b.color>=0){j.bindBuffer(j.ARRAY_BUFFER, -e.__webglColorBuffer);j.vertexAttribPointer(b.color,3,j.FLOAT,false,0,0)}if(b.normal>=0){j.bindBuffer(j.ARRAY_BUFFER,e.__webglNormalBuffer);j.vertexAttribPointer(b.normal,3,j.FLOAT,false,0,0)}if(b.tangent>=0){j.bindBuffer(j.ARRAY_BUFFER,e.__webglTangentBuffer);j.vertexAttribPointer(b.tangent,4,j.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){j.bindBuffer(j.ARRAY_BUFFER,e.__webglUVBuffer);j.vertexAttribPointer(b.uv,2,j.FLOAT,false,0,0);j.enableVertexAttribArray(b.uv)}else j.disableVertexAttribArray(b.uv); -if(b.uv2>=0)if(e.__webglUV2Buffer){j.bindBuffer(j.ARRAY_BUFFER,e.__webglUV2Buffer);j.vertexAttribPointer(b.uv2,2,j.FLOAT,false,0,0);j.enableVertexAttribArray(b.uv2)}else j.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexABuffer);j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,false,0,0);j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT, -false,0,0);j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);j.vertexAttribPointer(b.skinIndex,4,j.FLOAT,false,0,0);j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==$a){j.lineWidth(d);$a=d}a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,0)}else{a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer); -j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)}D.info.render.calls++;D.info.render.vertices=D.info.render.vertices+e.__webglFaceCount;D.info.render.faces=D.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES;d=d.linewidth;if(d!==$a){j.lineWidth(d);$a=d}j.drawArrays(f,0,e.__webglLineCount);D.info.render.calls++}else if(f instanceof THREE.ParticleSystem){j.drawArrays(j.POINTS,0,e.__webglParticleCount);D.info.render.calls++; -D.info.render.points=D.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount);D.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,h,m,n=a.__lights,o=a.fog;K=-1;ja=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray= -new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);lb.multiply(b.projectionMatrix,b.matrixWorldInverse);za.setFromMatrix(lb);this.autoUpdateObjects&&this.initWebGLObjects(a);i(this.renderPluginsPre,a,b);D.info.render.calls=0;D.info.render.vertices=0;D.info.render.faces=0;D.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor, -this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0;for(e=m.length;d=0){t=r.geometry.materials[t];if(t.transparent){p.transparent=t;p.opaque=null}else{p.opaque=t;p.transparent=null}}}else if(t)if(t.transparent){p.transparent= -t;p.opaque=null}else{p.opaque=t;p.transparent=null}f.render=true;if(this.sortObjects)if(h.renderDepth)f.z=h.renderDepth;else{Ra.copy(h.matrixWorld.getPosition());lb.multiplyVector3(Ra);f.z=Ra.z}}}this.sortObjects&&m.sort(g);m=a.__webglObjectsImmediate;d=0;for(e=m.length;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 k.geometryGroups){l=k.geometryGroups[i];if(!l.__webglVertexBuffer){var K=l;K.__webglVertexBuffer=j.createBuffer();K.__webglNormalBuffer=j.createBuffer();K.__webglTangentBuffer=j.createBuffer();K.__webglColorBuffer=j.createBuffer();K.__webglUVBuffer=j.createBuffer();K.__webglUV2Buffer=j.createBuffer();K.__webglSkinVertexABuffer=j.createBuffer();K.__webglSkinVertexBBuffer=j.createBuffer();K.__webglSkinIndicesBuffer=j.createBuffer();K.__webglSkinWeightsBuffer= -j.createBuffer();K.__webglFaceBuffer=j.createBuffer();K.__webglLineBuffer=j.createBuffer();var Z=void 0,I=void 0;if(K.numMorphTargets){K.__webglMorphTargetsBuffers=[];Z=0;for(I=K.numMorphTargets;Z0||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(L.geometry.skinWeights.length&&L.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,ia=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=[];ca=0;for(ia=G.numMorphTargets;ca0){j.bindBuffer(j.ARRAY_BUFFER,ea.__webglSkinVertexABuffer);j.bufferData(j.ARRAY_BUFFER, -ra,Xa);j.bindBuffer(j.ARRAY_BUFFER,ea.__webglSkinVertexBBuffer);j.bufferData(j.ARRAY_BUFFER,sa,Xa);j.bindBuffer(j.ARRAY_BUFFER,ea.__webglSkinIndicesBuffer);j.bufferData(j.ARRAY_BUFFER,ta,Xa);j.bindBuffer(j.ARRAY_BUFFER,ea.__webglSkinWeightsBuffer);j.bufferData(j.ARRAY_BUFFER,ua,Xa)}}if(ud&&Uc){E=0;for(T=la.length;E0){j.bindBuffer(j.ARRAY_BUFFER,ea.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER, -La,Xa)}}if(td&&Ta.hasTangents){E=0;for(T=la.length;E0){j.bindBuffer(j.ARRAY_BUFFER,ea.__webglUVBuffer);j.bufferData(j.ARRAY_BUFFER,wc,Xa)}}if(hd&&Zc&&ed){E=0;for(T=la.length;E0){j.bindBuffer(j.ARRAY_BUFFER, -ea.__webglUV2Buffer);j.bufferData(j.ARRAY_BUFFER,xc,Xa)}}if(rd){E=0;for(T=la.length;E -0?"#define VERTEX_TEXTURES":"",D.gammaInput?"#define GAMMA_INPUT":"",D.gammaOutput?"#define GAMMA_OUTPUT":"",D.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR": -"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); -k=["precision "+v+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",D.gammaInput?"#define GAMMA_INPUT":"",D.gammaOutput?"#define GAMMA_OUTPUT":"",D.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP": +true;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var D=this,k,P=[],L=0,S=null,aa=null,K=-1,ca=null,ha=null,O=0,Z=-1,$=-1,X=-1,ia=-1,za=-1,Ga=-1,Oa=-1,Pa=-1,Ta=null,Wa=null,lb=null,$a=null,mb=0,Fb=0,ab=0,nb=0,bb=0,Ha=0,wa=new THREE.Frustum,ib=new THREE.Matrix4,xa=new THREE.Matrix4,Qa=new THREE.Vector4,Da=new THREE.Vector3,ja=true,ob={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]}, +point:{length:0,colors:[],positions:[],distances:[]},spot:{length:0,colors:[],positions:[],distances:[],directions:[],angles:[],exponents:[]}};k=function(){var a;try{if(!(a=z.getContext("experimental-webgl",{alpha:H,premultipliedAlpha:I,antialias:N,stencil:R,preserveDrawingBuffer:Y})))throw"Error creating WebGL context.";}catch(b){console.error(b)}a.getExtension("OES_texture_float")||console.log("THREE.WebGLRenderer: Float textures not supported.");return a}();k.clearColor(0,0,0,1);k.clearDepth(1); +k.clearStencil(0);k.enable(k.DEPTH_TEST);k.depthFunc(k.LEQUAL);k.frontFace(k.CCW);k.cullFace(k.BACK);k.enable(k.CULL_FACE);k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA);k.clearColor(B.r,B.g,B.b,G);this.context=k;var fb=k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS);k.getParameter(k.MAX_TEXTURE_SIZE);var bc=k.getParameter(k.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return k};this.supportsVertexTextures=function(){return fb>0};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){mb=a;Fb=b;ab=c;nb=d;k.viewport(mb,Fb,ab,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)};this.deallocateObject=function(a){if(a.__webglInit){a.__webglInit=false;delete a._modelViewMatrix; +delete a._normalMatrix;delete a._normalMatrixArray;delete a._modelViewMatrixArray;delete a._objectMatrixArray;if(a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];k.deleteBuffer(c.__webglVertexBuffer);k.deleteBuffer(c.__webglNormalBuffer);k.deleteBuffer(c.__webglTangentBuffer);k.deleteBuffer(c.__webglColorBuffer);k.deleteBuffer(c.__webglUVBuffer);k.deleteBuffer(c.__webglUV2Buffer);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;d1&&(b=true);d=0;for(c=f.length;d=0&&h){i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.normal,i,k.FLOAT,false,0,g*i*4)}h=e.attributes.uv; +if(a.uv>=0&&h)if(h.buffer){i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.uv,i,k.FLOAT,false,0,g*i*4);k.enableVertexAttribArray(a.uv)}else k.disableVertexAttribArray(a.uv);h=e.attributes.color;if(a.color>=0&&h){i=h.itemSize;k.bindBuffer(k.ARRAY_BUFFER,h.buffer);k.vertexAttribPointer(a.color,i,k.FLOAT,false,0,g*i*4)}k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.attributes.index.buffer)}k.drawElements(k.TRIANGLES,f[d].count,k.UNSIGNED_SHORT,f[d].start*2);D.info.render.calls++;D.info.render.vertices= +D.info.render.vertices+f[d].count;D.info.render.faces=D.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var g,i,c=q(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ca){ca=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){k.bindBuffer(k.ARRAY_BUFFER,e.__webglVertexBuffer);k.vertexAttribPointer(b.position,3,k.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){k.bindBuffer(k.ARRAY_BUFFER, +e.__webglMorphTargetsBuffers[f.morphTargetBase]);k.vertexAttribPointer(c.position,3,k.FLOAT,false,0,0)}else if(c.position>=0){k.bindBuffer(k.ARRAY_BUFFER,e.__webglVertexBuffer);k.vertexAttribPointer(c.position,3,k.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var j=0;i=f.morphTargetForcedOrder;for(g=f.morphTargetInfluences;j0&&i.push([l,j])}if(i.length>d.numSupportedMorphTargets){i.sort(h);i.length=d.numSupportedMorphTargets}else i.length>d.numSupportedMorphNormals?i.sort(h):i.length===0&&i.push([0,0]);for(j=0;j=0){k.bindBuffer(k.ARRAY_BUFFER,c.buffer);k.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,k.FLOAT,false,0,0)}}}if(b.color>=0){k.bindBuffer(k.ARRAY_BUFFER,e.__webglColorBuffer);k.vertexAttribPointer(b.color,3,k.FLOAT,false,0,0)}if(b.normal>= +0){k.bindBuffer(k.ARRAY_BUFFER,e.__webglNormalBuffer);k.vertexAttribPointer(b.normal,3,k.FLOAT,false,0,0)}if(b.tangent>=0){k.bindBuffer(k.ARRAY_BUFFER,e.__webglTangentBuffer);k.vertexAttribPointer(b.tangent,4,k.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){k.bindBuffer(k.ARRAY_BUFFER,e.__webglUVBuffer);k.vertexAttribPointer(b.uv,2,k.FLOAT,false,0,0);k.enableVertexAttribArray(b.uv)}else k.disableVertexAttribArray(b.uv);if(b.uv2>=0)if(e.__webglUV2Buffer){k.bindBuffer(k.ARRAY_BUFFER,e.__webglUV2Buffer); +k.vertexAttribPointer(b.uv2,2,k.FLOAT,false,0,0);k.enableVertexAttribArray(b.uv2)}else k.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinVertexABuffer);k.vertexAttribPointer(b.skinVertexA,4,k.FLOAT,false,0,0);k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);k.vertexAttribPointer(b.skinVertexB,4,k.FLOAT,false,0,0);k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);k.vertexAttribPointer(b.skinIndex, +4,k.FLOAT,false,0,0);k.bindBuffer(k.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==$a){k.lineWidth(d);$a=d}a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);k.drawElements(k.LINES,e.__webglLineCount,k.UNSIGNED_SHORT,0)}else{a&&k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer);k.drawElements(k.TRIANGLES,e.__webglFaceCount,k.UNSIGNED_SHORT,0)}D.info.render.calls++; +D.info.render.vertices=D.info.render.vertices+e.__webglFaceCount;D.info.render.faces=D.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?k.LINE_STRIP:k.LINES;d=d.linewidth;if(d!==$a){k.lineWidth(d);$a=d}k.drawArrays(f,0,e.__webglLineCount);D.info.render.calls++}else if(f instanceof THREE.ParticleSystem){k.drawArrays(k.POINTS,0,e.__webglParticleCount);D.info.render.calls++;D.info.render.points=D.info.render.points+e.__webglParticleCount}else if(f instanceof +THREE.Ribbon){k.drawArrays(k.TRIANGLE_STRIP,0,e.__webglVertexCount);D.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,h,m,n=a.__lights,o=a.fog;K=-1;ja=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld); +b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);ib.multiply(b.projectionMatrix,b.matrixWorldInverse);wa.setFromMatrix(ib);this.autoUpdateObjects&&this.initWebGLObjects(a);i(this.renderPluginsPre,a,b);D.info.render.calls=0;D.info.render.vertices=0;D.info.render.faces=0;D.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;d=0; +for(e=m.length;d=0){t=r.geometry.materials[t];if(t.transparent){p.transparent=t;p.opaque=null}else{p.opaque=t;p.transparent=null}}}else if(t)if(t.transparent){p.transparent=t;p.opaque=null}else{p.opaque=t;p.transparent= +null}f.render=true;if(this.sortObjects)if(h.renderDepth)f.z=h.renderDepth;else{Qa.copy(h.matrixWorld.getPosition());ib.multiplyVector3(Qa);f.z=Qa.z}}}this.sortObjects&&m.sort(g);m=a.__webglObjectsImmediate;d=0;for(e=m.length;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||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(L.geometry.skinWeights.length&&L.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,ia=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=[];ca=0;for(ia=G.numMorphTargets;ca0){k.bindBuffer(k.ARRAY_BUFFER,ea.__webglSkinVertexABuffer);k.bufferData(k.ARRAY_BUFFER,ra,Xa);k.bindBuffer(k.ARRAY_BUFFER,ea.__webglSkinVertexBBuffer);k.bufferData(k.ARRAY_BUFFER,sa,Xa);k.bindBuffer(k.ARRAY_BUFFER,ea.__webglSkinIndicesBuffer);k.bufferData(k.ARRAY_BUFFER,ta,Xa);k.bindBuffer(k.ARRAY_BUFFER,ea.__webglSkinWeightsBuffer);k.bufferData(k.ARRAY_BUFFER,ua,Xa)}}if(Fd&&cd){E=0;for(T=la.length;E0){k.bindBuffer(k.ARRAY_BUFFER,ea.__webglColorBuffer);k.bufferData(k.ARRAY_BUFFER,Ka,Xa)}}if(Ed&&Sa.hasTangents){E=0;for(T=la.length;E0){k.bindBuffer(k.ARRAY_BUFFER,ea.__webglUVBuffer);k.bufferData(k.ARRAY_BUFFER,Ac,Xa)}}if(rd&&hd&&od){E=0;for(T=la.length;E0){k.bindBuffer(k.ARRAY_BUFFER,ea.__webglUV2Buffer);k.bufferData(k.ARRAY_BUFFER,Bc,Xa)}}if(Cd){E=0;for(T=la.length;E0?"#define VERTEX_TEXTURES":"",D.gammaInput?"#define GAMMA_INPUT":"",D.gammaOutput?"#define GAMMA_OUTPUT":"",D.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+ +c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG": +"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); +j=["precision "+v+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",D.gammaInput?"#define GAMMA_INPUT":"",D.gammaOutput?"#define GAMMA_OUTPUT":"",D.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP": "",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n"); -i=w("fragment",k+i);d=w("vertex",d+n);j.attachShader(q,d);j.attachShader(q,i);j.linkProgram(q);j.getProgramParameter(q,j.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+j.getProgramParameter(q,j.VALIDATE_STATUS)+", gl error ["+j.getError()+"]");j.deleteShader(i);j.deleteShader(d);q.uniforms={};q.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(s in h)d.push(s); -s=d;d=0;for(h=s.length;d=0&&j.enableVertexAttribArray(r.position);r.color>=0&&j.enableVertexAttribArray(r.color);r.normal>=0&&j.enableVertexAttribArray(r.normal);r.tangent>=0&&j.enableVertexAttribArray(r.tangent);if(a.skinning&&r.skinVertexA>=0&&r.skinVertexB>=0&&r.skinIndex>=0&&r.skinWeight>=0){j.enableVertexAttribArray(r.skinVertexA);j.enableVertexAttribArray(r.skinVertexB);j.enableVertexAttribArray(r.skinIndex);j.enableVertexAttribArray(r.skinWeight)}if(a.attributes)for(f in a.attributes)r[f]!==void 0&&r[f]>= -0&&j.enableVertexAttribArray(r[f]);if(a.morphTargets){a.numSupportedMorphTargets=0;b="morphTarget";for(f=0;f=0){j.enableVertexAttribArray(r[s]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;b="morphNormal";for(f=0;f=0){j.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"?j.frontFace(j.CCW):j.frontFace(j.CW);a==="back"?j.cullFace(j.BACK):a==="front"?j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK);j.enable(j.CULL_FACE)}else j.disable(j.CULL_FACE)};this.setObjectFaces=function(a){if(Z!==a.doubleSided){a.doubleSided?j.disable(j.CULL_FACE):j.enable(j.CULL_FACE);Z=a.doubleSided}if($!==a.flipSided){a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW);$=a.flipSided}};this.setDepthTest=function(a){if(Pa!==a){a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST); -Pa=a}};this.setDepthWrite=function(a){if(Qa!==a){j.depthMask(a);Qa=a}};this.setBlending=function(a,b,c,d){if(a!==X){if(a===THREE.NoBlending)j.disable(j.BLEND);else if(a===THREE.AdditiveBlending){j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE)}else if(a===THREE.SubtractiveBlending){j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.ONE_MINUS_SRC_COLOR)}else if(a===THREE.MultiplyBlending){j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.SRC_COLOR)}else if(a=== -THREE.CustomBlending)j.enable(j.BLEND);else{j.enable(j.BLEND);j.blendEquationSeparate(j.FUNC_ADD,j.FUNC_ADD);j.blendFuncSeparate(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA,j.ONE,j.ONE_MINUS_SRC_ALPHA)}X=a}if(a===THREE.CustomBlending){if(b!==ia){j.blendEquation(C(b));ia=b}if(c!==ya||d!==Ia){j.blendFunc(C(c),C(d));ya=c;Ia=d}}else Ia=ya=ia=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=j.createTexture();D.info.memory.textures++}j.activeTexture(j.TEXTURE0+ -b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture);j.pixelStorei(j.UNPACK_FLIP_Y_WEBGL,a.flipY);j.pixelStorei(j.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);t(j.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?j.texImage2D(j.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):j.texImage2D(j.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&j.generateMipmap(j.TEXTURE_2D);a.needsUpdate=false;if(a.onUpdate)a.onUpdate()}else{j.activeTexture(j.TEXTURE0+ -b);j.bindTexture(j.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=j.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=[];j.bindTexture(j.TEXTURE_CUBE_MAP,a.__webglTexture);t(j.TEXTURE_CUBE_MAP,a,c); -for(var f=0;f<6;f++){a.__webglFramebuffer[f]=j.createFramebuffer();a.__webglRenderbuffer[f]=j.createRenderbuffer();j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var g=a,h=j.TEXTURE_CUBE_MAP_POSITIVE_X+f;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[f]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,h,g.__webglTexture,0);x(a.__webglRenderbuffer[f],a)}c&&j.generateMipmap(j.TEXTURE_CUBE_MAP)}else{a.__webglFramebuffer=j.createFramebuffer();a.__webglRenderbuffer= -j.createRenderbuffer();j.bindTexture(j.TEXTURE_2D,a.__webglTexture);t(j.TEXTURE_2D,a,c);j.texImage2D(j.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null);d=j.TEXTURE_2D;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,d,a.__webglTexture,0);x(a.__webglRenderbuffer,a);c&&j.generateMipmap(j.TEXTURE_2D)}b?j.bindTexture(j.TEXTURE_CUBE_MAP,null):j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER, -null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer;c=a.width;a=a.height;e=d=0}else{b=null;c=pb;a=hb;d=ob;e=kb}if(b!==aa){j.bindFramebuffer(j.FRAMEBUFFER,b);j.viewport(d,e,c,a);aa=b}bb=c;Ca=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; +i=w("fragment",j+i);d=w("vertex",d+n);k.attachShader(q,d);k.attachShader(q,i);k.linkProgram(q);k.getProgramParameter(q,k.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+k.getProgramParameter(q,k.VALIDATE_STATUS)+", gl error ["+k.getError()+"]");k.deleteShader(i);k.deleteShader(d);q.uniforms={};q.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(s in h)d.push(s); +s=d;d=0;for(h=s.length;d=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(Oa!==a){a?k.enable(k.DEPTH_TEST):k.disable(k.DEPTH_TEST); +Oa=a}};this.setDepthWrite=function(a){if(Pa!==a){k.depthMask(a);Pa=a}};this.setBlending=function(a,b,c,d){if(a!==X){if(a===THREE.NoBlending)k.disable(k.BLEND);else if(a===THREE.AdditiveBlending){k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE)}else if(a===THREE.SubtractiveBlending){k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR)}else if(a===THREE.MultiplyBlending){k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.SRC_COLOR)}else if(a=== +THREE.CustomBlending)k.enable(k.BLEND);else{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!==ia){k.blendEquation(C(b));ia=b}if(c!==za||d!==Ga){k.blendFunc(C(c),C(d));za=c;Ga=d}}else Ga=za=ia=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_FLIP_Y_WEBGL,a.flipY);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);t(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);t(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,a.__webglTexture);t(k.TEXTURE_2D,a,c);k.texImage2D(k.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null);d=k.TEXTURE_2D;k.bindFramebuffer(k.FRAMEBUFFER,a.__webglFramebuffer);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,d,a.__webglTexture,0);x(a.__webglRenderbuffer,a);c&&k.generateMipmap(k.TEXTURE_2D)}b?k.bindTexture(k.TEXTURE_CUBE_MAP,null):k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER, +null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer;c=a.width;a=a.height;e=d=0}else{b=null;c=ab;a=nb;d=mb;e=Fb}if(b!==aa){k.bindFramebuffer(k.FRAMEBUFFER,b);k.viewport(d,e,c,a);aa=b}bb=c;Ha=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==void 0?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==void 0?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==void 0?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==void 0?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:THREE.RGBAFormat;this.type=c.type!==void 0?c.type: THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:true;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:true;this.generateMipmaps=true}; THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0}; @@ -446,31 +447,31 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null}; THREE.ColorUtils={adjustHSV:function(a,b,c,d){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.Math.clamp(e.h+b,0,1);e.s=THREE.Math.clamp(e.s+c,0,1);e.v=THREE.Math.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,e=a.b,f=Math.max(Math.max(c,d),e),g=Math.min(Math.min(c,d),e);if(g===f)g=c=0;else{var h=f-g,g=h/f,c=(c===f?(d-e)/h:d===f?2+(e-c)/h:4+(c-d)/h)/6;c<0&&(c=c+1);c>1&&(c=c-1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=f;return b}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,f=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,h=f.vertices,i=a.faces,k=f.faces,l=a.faceVertexUvs[0],o=f.faceVertexUvs[0],m={},p=0;p1){d=1-d;e=1-e}f=1-d-e;g.copy(a);g.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);g.addSelf(h);h.copy(c);h.multiplyScalar(f);g.addSelf(h);return g},randomPointInFace:function(a,b,c){var d,e,f;if(a instanceof THREE.Face3){d=b.vertices[a.a];e=b.vertices[a.b];f=b.vertices[a.c];return THREE.GeometryUtils.randomPointInTriangle(d,e,f)}if(a instanceof THREE.Face4){d=b.vertices[a.a];e=b.vertices[a.b];f=b.vertices[a.c];var b=b.vertices[a.d],g;if(c)if(a._area1&&a._area2){c=a._area1;g=a._area2}else{c=THREE.GeometryUtils.triangleArea(d,e,b);g=THREE.GeometryUtils.triangleArea(e,f,b);a._area1=c;a._area2=g}else{c=THREE.GeometryUtils.triangleArea(d,e,b);g=THREE.GeometryUtils.triangleArea(e,f,b)}return THREE.GeometryUtils.random()* -(c+g)a?b(c,e-1):k[e]a?b(c,e-1):j[e] -b||r>b||m>b){i=a.vertices.length;w=e.clone();t=e.clone();if(p>=r&&p>=m){k=k.clone();k.lerpSelf(l,0.5);w.a=f;w.b=i;w.c=h;t.a=i;t.b=g;t.c=h;if(e.vertexNormals.length===3){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[1],0.5);w.vertexNormals[1].copy(f);t.vertexNormals[0].copy(f)}if(e.vertexColors.length===3){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[1],0.5);w.vertexColors[1].copy(f);t.vertexColors[0].copy(f)}e=0}else if(r>=p&&r>=m){k=l.clone();k.lerpSelf(o,0.5);w.a=f;w.b=g;w.c= -i;t.a=i;t.b=h;t.c=f;if(e.vertexNormals.length===3){f=e.vertexNormals[1].clone();f.lerpSelf(e.vertexNormals[2],0.5);w.vertexNormals[2].copy(f);t.vertexNormals[0].copy(f);t.vertexNormals[1].copy(e.vertexNormals[2]);t.vertexNormals[2].copy(e.vertexNormals[0])}if(e.vertexColors.length===3){f=e.vertexColors[1].clone();f.lerpSelf(e.vertexColors[2],0.5);w.vertexColors[2].copy(f);t.vertexColors[0].copy(f);t.vertexColors[1].copy(e.vertexColors[2]);t.vertexColors[2].copy(e.vertexColors[0])}e=1}else{k=k.clone(); -k.lerpSelf(o,0.5);w.a=f;w.b=g;w.c=i;t.a=i;t.b=g;t.c=h;if(e.vertexNormals.length===3){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[2],0.5);w.vertexNormals[2].copy(f);t.vertexNormals[0].copy(f)}if(e.vertexColors.length===3){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[2],0.5);w.vertexColors[2].copy(f);t.vertexColors[0].copy(f)}e=2}x.push(w,t);a.vertices.push(k);f=0;for(g=a.faceVertexUvs.length;fb||r>b||n>b||q>b){s=a.vertices.length;u=a.vertices.length+1;w=e.clone();t=e.clone();if(p>=r&&p>=n&&p>=q||n>=r&&n>=p&&n>=q){p=k.clone();p.lerpSelf(l,0.5);l=o.clone();l.lerpSelf(m,0.5);w.a=f;w.b=s;w.c=u;w.d=i;t.a=s;t.b=g;t.c=h;t.d=u;if(e.vertexNormals.length===4){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[1],0.5);g=e.vertexNormals[2].clone();g.lerpSelf(e.vertexNormals[3],0.5);w.vertexNormals[1].copy(f); -w.vertexNormals[2].copy(g);t.vertexNormals[0].copy(f);t.vertexNormals[3].copy(g)}if(e.vertexColors.length===4){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[1],0.5);g=e.vertexColors[2].clone();g.lerpSelf(e.vertexColors[3],0.5);w.vertexColors[1].copy(f);w.vertexColors[2].copy(g);t.vertexColors[0].copy(f);t.vertexColors[3].copy(g)}e=0}else{p=l.clone();p.lerpSelf(o,0.5);l=m.clone();l.lerpSelf(k,0.5);w.a=f;w.b=g;w.c=s;w.d=u;t.a=u;t.b=s;t.c=h;t.d=i;if(e.vertexNormals.length===4){f=e.vertexNormals[1].clone(); +c;b++)h[b]=[];b=0;for(c=a.faces.length;b +b||r>b||m>b){i=a.vertices.length;w=e.clone();t=e.clone();if(p>=r&&p>=m){j=j.clone();j.lerpSelf(l,0.5);w.a=f;w.b=i;w.c=h;t.a=i;t.b=g;t.c=h;if(e.vertexNormals.length===3){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[1],0.5);w.vertexNormals[1].copy(f);t.vertexNormals[0].copy(f)}if(e.vertexColors.length===3){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[1],0.5);w.vertexColors[1].copy(f);t.vertexColors[0].copy(f)}e=0}else if(r>=p&&r>=m){j=l.clone();j.lerpSelf(o,0.5);w.a=f;w.b=g;w.c= +i;t.a=i;t.b=h;t.c=f;if(e.vertexNormals.length===3){f=e.vertexNormals[1].clone();f.lerpSelf(e.vertexNormals[2],0.5);w.vertexNormals[2].copy(f);t.vertexNormals[0].copy(f);t.vertexNormals[1].copy(e.vertexNormals[2]);t.vertexNormals[2].copy(e.vertexNormals[0])}if(e.vertexColors.length===3){f=e.vertexColors[1].clone();f.lerpSelf(e.vertexColors[2],0.5);w.vertexColors[2].copy(f);t.vertexColors[0].copy(f);t.vertexColors[1].copy(e.vertexColors[2]);t.vertexColors[2].copy(e.vertexColors[0])}e=1}else{j=j.clone(); +j.lerpSelf(o,0.5);w.a=f;w.b=g;w.c=i;t.a=i;t.b=g;t.c=h;if(e.vertexNormals.length===3){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[2],0.5);w.vertexNormals[2].copy(f);t.vertexNormals[0].copy(f)}if(e.vertexColors.length===3){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[2],0.5);w.vertexColors[2].copy(f);t.vertexColors[0].copy(f)}e=2}x.push(w,t);a.vertices.push(j);f=0;for(g=a.faceVertexUvs.length;fb||r>b||n>b||q>b){s=a.vertices.length;u=a.vertices.length+1;w=e.clone();t=e.clone();if(p>=r&&p>=n&&p>=q||n>=r&&n>=p&&n>=q){p=j.clone();p.lerpSelf(l,0.5);l=o.clone();l.lerpSelf(m,0.5);w.a=f;w.b=s;w.c=u;w.d=i;t.a=s;t.b=g;t.c=h;t.d=u;if(e.vertexNormals.length===4){f=e.vertexNormals[0].clone();f.lerpSelf(e.vertexNormals[1],0.5);g=e.vertexNormals[2].clone();g.lerpSelf(e.vertexNormals[3],0.5);w.vertexNormals[1].copy(f); +w.vertexNormals[2].copy(g);t.vertexNormals[0].copy(f);t.vertexNormals[3].copy(g)}if(e.vertexColors.length===4){f=e.vertexColors[0].clone();f.lerpSelf(e.vertexColors[1],0.5);g=e.vertexColors[2].clone();g.lerpSelf(e.vertexColors[3],0.5);w.vertexColors[1].copy(f);w.vertexColors[2].copy(g);t.vertexColors[0].copy(f);t.vertexColors[3].copy(g)}e=0}else{p=l.clone();p.lerpSelf(o,0.5);l=m.clone();l.lerpSelf(j,0.5);w.a=f;w.b=g;w.c=s;w.d=u;t.a=u;t.b=s;t.c=h;t.d=i;if(e.vertexNormals.length===4){f=e.vertexNormals[1].clone(); f.lerpSelf(e.vertexNormals[2],0.5);g=e.vertexNormals[3].clone();g.lerpSelf(e.vertexNormals[0],0.5);w.vertexNormals[2].copy(f);w.vertexNormals[3].copy(g);t.vertexNormals[0].copy(g);t.vertexNormals[1].copy(f)}if(e.vertexColors.length===4){f=e.vertexColors[1].clone();f.lerpSelf(e.vertexColors[2],0.5);g=e.vertexColors[3].clone();g.lerpSelf(e.vertexColors[0],0.5);w.vertexColors[2].copy(f);w.vertexColors[3].copy(g);t.vertexColors[0].copy(g);t.vertexColors[1].copy(f)}e=1}x.push(w,t);a.vertices.push(p,l); -f=0;for(g=a.faceVertexUvs.length;fe-1?e-1:o+1,r= +1;if(e.loadCount===6){f.needsUpdate=true;c&&c()}};e[b].crossOrigin=this.crossOrigin;e[b].src=a[b]}return f},getNormalMap:function(a,b){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),j=i.data,l=0;le-1?e-1:o+1,r= l-1<0?0:l-1,n=l+1>d-1?d-1:l+1,q=[],s=[0,0,h[(o*d+l)*4]/255*b];q.push([-1,0,h[(o*d+r)*4]/255*b]);q.push([-1,-1,h[(m*d+r)*4]/255*b]);q.push([0,-1,h[(m*d+l)*4]/255*b]);q.push([1,-1,h[(m*d+n)*4]/255*b]);q.push([1,0,h[(o*d+n)*4]/255*b]);q.push([1,1,h[(p*d+n)*4]/255*b]);q.push([0,1,h[(p*d+l)*4]/255*b]);q.push([-1,1,h[(p*d+r)*4]/255*b]);m=[];r=q.length;for(p=0;p 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( normalize( vNormal.xyz ) * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif", THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:1,texture:null},tFlip:{type:"f",value:-1}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( tFlip * wPos.x, wPos.yz ) );\n}"}}}); THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b=this.getFace(),c=this.size/b.resolution,d= -0,e=(""+a).split(""),f=e.length,g=[],a=0;a0)for(k=0;k2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");break}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);l=k+1;e<=l&&(l=0);var m;a:{m=a;var p=i,r=k,n=l,q=e,s=g,u=void 0,w=void 0,t=void 0,x=void 0,F=void 0, -C=void 0,z=void 0,v=void 0,H=void 0,w=m[s[p]].x,t=m[s[p]].y,x=m[s[r]].x,F=m[s[r]].y,C=m[s[n]].x,z=m[s[n]].y;if(1.0E-10>(x-w)*(z-t)-(F-t)*(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[k]],a[g[l]]]);h.push([g[i],g[k],g[l]]);i=k;for(l=k+1;lb.max.x)b.max.x=c;if(db.max.y)b.max.y=d;if(eb.max.z)b.max.z=e}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};var a=this.vertexPositionArray; -if(a){for(var b,c=0,d,e,f=0,g=a.length;fc&&(c=b)}this.boundingSphere.radius=c}},computeVertexNormals:function(){var a=this.vertexIndexArray,b=this.vertexPositionArray;if(b&&a){var c,d,e,f;c=b.length;if(this.vertexNormalArray===void 0)this.vertexNormalArray=new Float32Array(c);else{c=0;for(d=this.vertexNormalArray.length;c0)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,s=g,u=void 0,w=void 0,t=void 0,x=void 0,F=void 0, +C=void 0,z=void 0,v=void 0,H=void 0,w=m[s[p]].x,t=m[s[p]].y,x=m[s[r]].x,F=m[s[r]].y,C=m[s[n]].x,z=m[s[n]].y;if(1.0E-10>(x-w)*(z-t)-(F-t)*(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;lb.max.x)b.max.x=c;if(db.max.y)b.max.y=d;if(eb.max.z)b.max.z=e}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere= +{radius:0};var a=this.attributes.position.array;if(a){for(var b,c=0,d,e,f=0,g=a.length;fc&&(c=b)}this.boundingSphere.radius=c}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var a,b,c,d;a=this.attributes.position.array.length;if(this.attributes.normal===void 0)this.attributes.normal={itemSize:3,array:new Float32Array(a),numItems:a*3};else{a=0;for(b=this.attributes.normal.array.length;a0)h=d-1;else{h=d;break}}d=h;if(c[d]==f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)};THREE.Curve.prototype.getNormalVector=function(a){a=this.getTangent(a);return new THREE.Vector2(-a.y,a.x)}; THREE.Curve.prototype.getTangent=function(a){var b=a-1.0E-4,a=a+1.0E-4;b<0&&(b=0);a>1&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().subSelf(b).normalize()};THREE.Curve.prototype.getTangentAt=function(a){return this.getTangent(this.getUtoTmapping(a))};THREE.LineCurve=function(a,b){this.v1=a;this.v2=b};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().subSelf(this.v1);b.multiplyScalar(a).addSelf(this.v1);return b}; @@ -533,34 +533,34 @@ THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,e,f){var g=Array.prototype.s THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a);this.curves.push(new THREE.SplineCurve(c));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:b})};THREE.Path.prototype.ellipse=function(a,b,c,d,e,f,g){var h=this.actions[this.actions.length-1];this.absellipse(h.x+a,h.y+b,c,d,e,f,g)}; THREE.Path.prototype.arc=function(a,b,c,d,e,f){var g=this.actions[this.actions.length-1];this.absarc(g.x+a,g.y+b,c,d,e,f)};THREE.Path.prototype.absellipse=function(a,b,c,d,e,f,g){var h=Array.prototype.slice.call(arguments),i=new THREE.EllipseCurve(a,b,c,d,e,f,g);this.curves.push(i);i=i.getPoint(g?1:0);h.push(i.x);h.push(i.y);this.actions.push({action:THREE.PathActions.ELLIPSE,args:h})};THREE.Path.prototype.absarc=function(a,b,c,d,e,f){this.absellipse(a,b,c,c,d,e,f)}; THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c0){g=c[c.length-1]; -p=g.x;r=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];r=g[g.length-1]}for(f=1;f<=a;f++){n=f/a;g=THREE.Shape.Utils.b2(n,p,o,h);n=THREE.Shape.Utils.b2(n,r,m,i);c.push(new THREE.Vector2(g,n))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];o=f[0];m=f[1];k=f[2];l=f[3];if(c.length>0){g=c[c.length-1];p=g.x;r=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];r=g[g.length-1]}for(f=1;f<=a;f++){n=f/a;g=THREE.Shape.Utils.b3(n,p,o,k,h);n=THREE.Shape.Utils.b3(n,r,m,l,i);c.push(new THREE.Vector2(g, -n))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;n=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=a*f[0].length;n=n.concat(f[0]);n=new THREE.SplineCurve(n);for(f=1;f<=g;f++)c.push(n.getPointAt(f/g));break;case THREE.PathActions.ARC:h=f[0];i=f[1];m=f[2];k=f[3];g=f[4];o=!!f[5];p=g-k;r=a*2;for(f=1;f<=r;f++){n=f/r;o||(n=1-n);n=k+n*p;g=h+m*Math.cos(n);n=i+m*Math.sin(n);c.push(new THREE.Vector2(g,n))}break;case THREE.PathActions.ELLIPSE:h=f[0];i=f[1];m=f[2];l=f[3];k=f[4];g=f[5]; -o=!!f[6];p=g-k;r=a*2;for(f=1;f<=r;f++){n=f/r;o||(n=1-n);n=k+n*p;g=h+m*Math.cos(n);n=i+l*Math.sin(n);c.push(new THREE.Vector2(g,n))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1.0E-10&&Math.abs(d.y-c[0].y)<1.0E-10&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; +THREE.Path.prototype.getPoints=function(a,b){if(this.useSpacedPoints){console.log("tata");return this.getSpacedPoints(a,b)}var a=a||12,c=[],d,e,f,g,h,i,j,l,o,m,p,r,n;d=0;for(e=this.actions.length;d0){g=c[c.length-1]; +p=g.x;r=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];r=g[g.length-1]}for(f=1;f<=a;f++){n=f/a;g=THREE.Shape.Utils.b2(n,p,o,h);n=THREE.Shape.Utils.b2(n,r,m,i);c.push(new THREE.Vector2(g,n))}break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];o=f[0];m=f[1];j=f[2];l=f[3];if(c.length>0){g=c[c.length-1];p=g.x;r=g.y}else{g=this.actions[d-1].args;p=g[g.length-2];r=g[g.length-1]}for(f=1;f<=a;f++){n=f/a;g=THREE.Shape.Utils.b3(n,p,o,j,h);n=THREE.Shape.Utils.b3(n,r,m,l,i);c.push(new THREE.Vector2(g, +n))}break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;n=[new THREE.Vector2(g[g.length-2],g[g.length-1])];g=a*f[0].length;n=n.concat(f[0]);n=new THREE.SplineCurve(n);for(f=1;f<=g;f++)c.push(n.getPointAt(f/g));break;case THREE.PathActions.ARC:h=f[0];i=f[1];m=f[2];j=f[3];g=f[4];o=!!f[5];p=g-j;r=a*2;for(f=1;f<=r;f++){n=f/r;o||(n=1-n);n=j+n*p;g=h+m*Math.cos(n);n=i+m*Math.sin(n);c.push(new THREE.Vector2(g,n))}break;case THREE.PathActions.ELLIPSE:h=f[0];i=f[1];m=f[2];l=f[3];j=f[4];g=f[5]; +o=!!f[6];p=g-j;r=a*2;for(f=1;f<=r;f++){n=f/r;o||(n=1-n);n=j+n*p;g=h+m*Math.cos(n);n=i+l*Math.sin(n);c.push(new THREE.Vector2(g,n))}}}d=c[c.length-1];Math.abs(d.x-c[0].x)<1.0E-10&&Math.abs(d.y-c[0].y)<1.0E-10&&c.splice(c.length-1,1);b&&c.push(c[0]);return c}; THREE.Path.prototype.toShapes=function(){var a,b,c,d,e=[],f=new THREE.Path;a=0;for(b=this.actions.length;a=0?h-1:c.length-1;f=g-1>=0?g-1:k.length-1;var n=[k[g],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(n);var q=[k[g],k[f],c[h]];m=THREE.FontUtils.Triangulate.area(q);p=h;l=g;h=h+1;g=g+ --1;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+k.length);g=g%k.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:k.length-1;n=[k[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);q=[k[g],k[f],c[h]];q=THREE.FontUtils.Triangulate.area(q);if(o+m>n+q){h=p;g=l;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+k.length);g=g%k.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:k.length-1}o=c.slice(0,h);m=c.slice(h);p=k.slice(g);l=k.slice(0,g);f=[k[g],k[f],c[h]];r.push([k[g],c[h],c[e]]);r.push(f);c=o.concat(p).concat(l).concat(m)}return{shape:c, -isolatedPts:r,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,false),f,g,h,i,k={};f=0;for(g=d.length;f=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;var n=[j[g],c[h],c[e]];o=THREE.FontUtils.Triangulate.area(n);var q=[j[g],j[f],c[h]];m=THREE.FontUtils.Triangulate.area(q);p=h;l=g;h=h+1;g=g+ +-1;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1;n=[j[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);q=[j[g],j[f],c[h]];q=THREE.FontUtils.Triangulate.area(q);if(o+m>n+q){h=p;g=l;h<0&&(h=h+c.length);h=h%c.length;g<0&&(g=g+j.length);g=g%j.length;e=h-1>=0?h-1:c.length-1;f=g-1>=0?g-1:j.length-1}o=c.slice(0,h);m=c.slice(h);p=j.slice(g);l=j.slice(0,g);f=[j[g],j[f],c[h]];r.push([j[g],c[h],c[e]]);r.push(f);c=o.concat(p).concat(l).concat(m)}return{shape:c, +isolatedPts:r,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,false),f,g,h,i,j={};f=0;for(g=d.length;f1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+p);d=d<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=e[0]+(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType=== THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=this.getPrevKeyWith("pos",p,g.index-1).pos;this.points[1]=e;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",p,h.index+1).pos;d=d*0.33+0.33;e=this.interpolateCatmullRom(this.points,d);c.x=e[0];c.y=e[1];c.z=e[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x, -this.target.z);a.rotation.set(0,d,0)}}}else if(c==="rot")THREE.Quaternion.slerp(e,f,a.quaternion,d);else if(c==="scl"){c=a.scale;c.x=e[0]+(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}}}}if(this.JITCompile&&l[0][k]===void 0){this.hierarchy[0].updateMatrixWorld(true);for(p=0;pa.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]];k=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],k[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],k[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],k[2],e,c,g);return d}; +this.target.z);a.rotation.set(0,d,0)}}}else if(c==="rot")THREE.Quaternion.slerp(e,f,a.quaternion,d);else if(c==="scl"){c=a.scale;c.x=e[0]+(f[0]-e[0])*d;c.y=e[1]+(f[1]-e[1])*d;c.z=e[2]+(f[2]-e[2])*d}}}}if(this.JITCompile&&l[0][j]===void 0){this.hierarchy[0].updateMatrixWorld(true);for(p=0;pa.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.0010;this.isPlaying=false;this.loop=this.isPaused=true;this.JITCompile=c!==void 0?c:true;a=0;for(b=this.hierarchy.length;a=g?b.interpolate(c,g):b.interpolate(c,c.time)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=true}}if(this.JITCompile&&f[0][e]===void 0){this.hierarchy[0].updateMatrixWorld(true); for(a=0;a=0?c:c+b.length;c>=0;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]}; @@ -609,54 +609,54 @@ false;break;case 2:this.moveBackward=false}this.updateRotationVector()};this.upd this.object.matrixWorldNeedsUpdate=true};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z= -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),false);this.domElement.addEventListener("mousedown",c(this,this.mousedown),false);this.domElement.addEventListener("mouseup", c(this,this.mouseup),false);this.domElement.addEventListener("keydown",c(this,this.keydown),false);this.domElement.addEventListener("keyup",c(this,this.keyup),false);this.updateMovementVector();this.updateRotationVector()}; -THREE.RollControls=function(a,b){this.object=a;this.domElement=b!==void 0?b:document;this.mouseLook=true;this.autoForward=false;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=false;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Matrix4,g=false,h=1,i=0,k=0,l=0,o=0,m=0,p=0,r=0;this.handleResize=function(){p=window.innerWidth/2;r=window.innerHeight/2};this.update= -function(a){if(this.mouseLook){var b=a*this.lookSpeed;this.rotateHorizontally(b*o);this.rotateVertically(b*m)}b=a*this.movementSpeed;this.object.translateZ(-b*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*k);this.object.translateY(b*l);if(g)this.roll=this.roll+this.rollSpeed*a*h;if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y0||this.autoForward&&!(i<0)?1:i));this.object.translateX(b*j);this.object.translateY(b*l);if(g)this.roll=this.roll+this.rollSpeed*a*h;if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y1?d.normalize():d.z=Math.sqrt(1-e*e);g.copy(c.object.position).subSelf(c.target);e=c.object.up.clone().setLength(d.y);e.addSelf(c.object.up.clone().crossSelf(g).setLength(d.x));e.addSelf(g.setLength(d.z));return e}; -this.rotateCamera=function(){var a=Math.acos(h.dot(i)/h.length()/i.length());if(a){var b=(new THREE.Vector3).cross(h,i).normalize(),d=new THREE.Quaternion,a=a*c.rotateSpeed;d.setFromAxisAngle(b,-a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.multiplyVector3(i);if(c.staticMoving)h=i;else{d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1));d.multiplyVector3(h)}}};this.zoomCamera=function(){var a=1+(l.y-k.y)*c.zoomSpeed;if(a!==1&&a>0){g.multiplyScalar(a);c.staticMoving?k=l:k.y=k.y+(l.y-k.y)* +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;d.setFromAxisAngle(b,-a);d.multiplyVector3(g);d.multiplyVector3(c.object.up);d.multiplyVector3(i);if(c.staticMoving)h=i;else{d.setFromAxisAngle(b,a*(c.dynamicDampingFactor-1));d.multiplyVector3(h)}}};this.zoomCamera=function(){var a=1+(l.y-j.y)*c.zoomSpeed;if(a!==1&&a>0){g.multiplyScalar(a);c.staticMoving?j=l:j.y=j.y+(l.y-j.y)* this.dynamicDampingFactor}};this.panCamera=function(){var a=m.clone().subSelf(o);if(a.lengthSq()){a.multiplyScalar(g.length()*c.panSpeed);var b=g.clone().crossSelf(c.object.up).setLength(a.x);b.addSelf(c.object.up.clone().setLength(a.y));c.object.position.addSelf(b);c.target.addSelf(b);c.staticMoving?o=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);k=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?k=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&&f===-1){a.keyCode===c.keys[0]&&!c.noRotate?f=0:a.keyCode===c.keys[1]&&!c.noZoom? +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&&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);this.handleResize()}; -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(t===c){o.set(a.clientX,a.clientY);m.sub(o,l);i.rotateLeft(2*Math.PI*m.x/k*i.userRotateSpeed);i.rotateUp(2*Math.PI*m.y/k*i.userRotateSpeed);l.copy(o)}else if(t===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); -t=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,k=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,s=0,u=1,w=new THREE.Vector3;e=-1;c=0;d=1;var t=e,x={type:"change"};this.rotateLeft=function(a){a===void 0&&(a=f()); +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(t===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(t===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); +t=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,s=0,u=1,w=new THREE.Vector3;e=-1;c=0;d=1;var t=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());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()); var c=c+s,d=d+q,d=Math.max(1.0E-6,Math.min(Math.PI-1.0E-6,d)),e=b.length();b.x=e*Math.sin(d)*Math.sin(c);b.y=e*Math.cos(d);b.z=e*Math.sin(d)*Math.cos(c);b.multiplyScalar(u);a.copy(this.center).addSelf(b);this.object.lookAt(this.center);q=s=0;u=1;if(w.distanceTo(this.object.position)>0){this.dispatchEvent(x);w.copy(this.object.position)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},false);this.domElement.addEventListener("mousedown",function(a){if(i.userRotate){a.preventDefault(); if(a.button===0||a.button===2){t=c;l.set(a.clientX,a.clientY)}else if(a.button===1){t=d;p.set(a.clientX,a.clientY)}document.addEventListener("mousemove",g,false);document.addEventListener("mouseup",h,false)}},false);this.domElement.addEventListener("mousewheel",function(a){i.userZoom&&(a.wheelDelta>0?i.zoomOut():i.zoomIn())},false)}; -THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function i(a,b,c,g,h,i,l,m){var n,o=d||1,p=e||1,r=h/2,q=i/2,s=k.vertices.length;if(a==="x"&&b==="y"||a==="y"&&b==="x")n="z";else if(a==="x"&&b==="z"||a==="z"&&b==="x"){n="y";p=f||1}else if(a==="z"&&b==="y"||a==="y"&&b==="z"){n="x";o=f||1}var u=o+1,j=p+1,w=h/o,L=i/p,S=new THREE.Vector3;S[n]=l>0?1:-1;for(h=0;h0?1:-1;for(h=0;h0){this.vertices.push(new THREE.Vector3(0, -g,0));for(h=0;h0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;h0){this.vertices.push(new THREE.Vector3(0, +g,0));for(h=0;h0){this.vertices.push(new THREE.Vector3(0,-g,0));for(h=0;ha&&(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;j=i*(1-D);Q=k*Math.sin(D*Math.PI/2);K=0;for(D=B.length;K=0;G--){D=G/l;k=i*(1-D);Q=j*Math.sin(D*Math.PI/2);K=0;for(D=B.length;K1.0E-4){h.normalize();d=Math.acos(e[k-1].dot(e[k]));i.makeRotationAxis(h,d).multiplyVector3(f[k])}g[k].cross(e[k],f[k])}if(c){d=Math.acos(f[0].dot(f[b-1]));d=d/(b-1);e[0].dot(h.cross(f[0],f[b-1]))>0&&(d=-d);for(k=1;k1.0E-4){h.normalize();d=Math.acos(e[j-1].dot(e[j]));i.makeRotationAxis(h,d).multiplyVector3(f[j])}g[j].cross(e[j],f[j])}if(c){d=Math.acos(f[0].dot(f[b-1]));d=d/(b-1);e[0].dot(h.cross(f[0],f[b-1]))>0&&(d=-d);for(j=1;j=k){for(i=0;i<3;i++){k=[h[i],h[(i+1)%3]];s=true;for(u=0;u=j){for(i=0;i<3;i++){j=[h[i],h[(i+1)%3]];s=true;for(u=0;u0;)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 k=new THREE.Face4(a,c,d,e,null,g.color,g.materialIndex);if(m.useOldVertexColors){k.vertexColors=[];for(var j,n,p,q=0;q<4;q++){p=h[q];j=new THREE.Color;j.setRGB(0,0,0);for(var r=0;r=w&&ad.duration||d.time<0){d.direction=d.direction*-1;if(d.time>d.duration){d.time=d.duration;d.directionBackwards=true}if(d.time<0){d.time=0;d.directionBackwards=false}}}else{d.time=d.time%d.duration;if(d.time<0)d.time=d.time+d.duration}var f=d.startFrame+THREE.Math.clamp(Math.floor(d.time/ e),0,d.length-1),g=d.weight;if(f!==d.currentFrame){this.morphTargetInfluences[d.lastFrame]=0;this.morphTargetInfluences[d.currentFrame]=1*g;this.morphTargetInfluences[f]=0;d.lastFrame=d.currentFrame;d.currentFrame=f}e=d.time%e/e;d.directionBackwards&&(e=1-e);this.morphTargetInfluences[d.currentFrame]=e*g;this.morphTargetInfluences[d.lastFrame]=(1-e)*g}}}; -THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,e,f,g,h,i,k,l,o,m,p;this.init=function(r){b=r.context;c=r;d=new Float32Array(16);e=new Uint16Array(6);r=0;d[r++]=-1;d[r++]=-1;d[r++]=0;d[r++]=0;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]= +THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,e,f,g,h,i,j,l,o,m,p;this.init=function(r){b=r.context;c=r;d=new Float32Array(16);e=new Uint16Array(6);r=0;d[r++]=-1;d[r++]=-1;d[r++]=0;d[r++]=0;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]= 0;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]=0;d[r++]=1;r=0;e[r++]=0;e[r++]=1;e[r++]=2;e[r++]=0;e[r++]=2;e[r++]=3;f=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);h=b.createTexture();i=b.createTexture();b.bindTexture(b.TEXTURE_2D,h);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D, b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,i);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST); -b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);if(b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){k=false;l=a(THREE.ShaderFlares.lensFlare)}else{k=true;l=a(THREE.ShaderFlares.lensFlareVertexTexture)}o={};m={};o.vertex=b.getAttribLocation(l,"position");o.uv=b.getAttribLocation(l,"uv");m.renderType=b.getUniformLocation(l,"renderType");m.map=b.getUniformLocation(l,"map");m.occlusionMap=b.getUniformLocation(l,"occlusionMap");m.opacity=b.getUniformLocation(l,"opacity");m.color=b.getUniformLocation(l, +b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);if(b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){j=false;l=a(THREE.ShaderFlares.lensFlare)}else{j=true;l=a(THREE.ShaderFlares.lensFlareVertexTexture)}o={};m={};o.vertex=b.getAttribLocation(l,"position");o.uv=b.getAttribLocation(l,"uv");m.renderType=b.getUniformLocation(l,"renderType");m.map=b.getUniformLocation(l,"map");m.occlusionMap=b.getUniformLocation(l,"occlusionMap");m.opacity=b.getUniformLocation(l,"opacity");m.color=b.getUniformLocation(l, "color");m.scale=b.getUniformLocation(l,"scale");m.rotation=b.getUniformLocation(l,"rotation");m.screenPosition=b.getUniformLocation(l,"screenPosition");p=false};this.render=function(a,d,e,s){var a=a.__webglFlares,u=a.length;if(u){var w=new THREE.Vector3,t=s/e,x=e*0.5,F=s*0.5,C=16/s,z=new THREE.Vector2(C*t,C),v=new THREE.Vector3(1,1,0),H=new THREE.Vector2(1,1),I=m,C=o;b.useProgram(l);if(!p){b.enableVertexAttribArray(o.vertex);b.enableVertexAttribArray(o.uv);p=true}b.uniform1i(I.occlusionMap,0);b.uniform1i(I.map, -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&& +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.0010&&G.scale>0.0010){v.x=G.x;v.y=G.y;v.z=G.z;C=G.size*G.scale/s;z.x=C*t;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,k){var l,o,m,p,r,n,q,s,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;lh.x)h.x=s.x;if(s.yh.y)h.y=s.y;if(s.zh.z)h.z=s.z}p.left=g.x;p.right=h.x;p.top=h.y;p.bottom=g.y;p.updateProjectionMatrix()}p=m.shadowMap;n=m.shadowMatrix;r=m.shadowCamera;r.position.copy(m.matrixWorld.getPosition());r.lookAt(m.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld); if(m.cameraHelper)m.cameraHelper.lines.visible=m.shadowCameraVisible;m.shadowCameraVisible&&m.cameraHelper.update();n.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);n.multiplySelf(r.projectionMatrix);n.multiplySelf(r.matrixWorldInverse);if(!r._viewMatrixArray)r._viewMatrixArray=new Float32Array(16);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);f.multiply(r.projectionMatrix, r.matrixWorldInverse);e.setFromMatrix(f);b.setRenderTarget(p);b.clear();u=i.__webglObjects;m=0;for(p=u.length;m0)for(j=0;j2;){if(n--<=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 k;a:{k=b;var m=i,o=j,p=l,r=e,s=g,t=void 0,v=void 0,q=void 0,x=void 0,z=void 0, A=void 0,w=void 0,u=void 0,C=void 0,v=k[s[m]].x,q=k[s[m]].y,x=k[s[o]].x,z=k[s[o]].y,A=k[s[p]].x,w=k[s[p]].y;if(1.0E-10>(x-v)*(w-q)-(z-q)*(A-v))k=false;else{for(t=0;t=0&&G>=0&&H>=0){k=false;break a}}k=true}}if(k){f.push([b[g[i]], -b[g[j]],b[g[l]]]);h.push([g[i],g[j],g[l]]);i=j;for(l=j+1;la.max.x)a.max.x=c;if(da.max.y)a.max.y=d;if(ea.max.z)a.max.z=e}if(b===void 0||b.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};var b=this.vertexPositionArray; -if(b){for(var a,c=0,d,e,f=0,g=b.length;fc&&(c=a)}this.boundingSphere.radius=c}},computeVertexNormals:function(){var b=this.vertexIndexArray,a=this.vertexPositionArray;if(a&&b){var c,d,e,f;c=a.length;if(this.vertexNormalArray===void 0)this.vertexNormalArray=new Float32Array(c);else{c=0;for(d=this.vertexNormalArray.length;ca.max.x)a.max.x=c;if(da.max.y)a.max.y=d;if(ea.max.z)a.max.z=e}if(b===void 0||b.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere= +{radius:0};var b=this.attributes.position.array;if(b){for(var a,c=0,d,e,f=0,g=b.length;fc&&(c=a)}this.boundingSphere.radius=c}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var b,a,c,d;b=this.attributes.position.array.length;if(this.attributes.normal===void 0)this.attributes.normal={itemSize:3,array:new Float32Array(b),numItems:b*3};else{b=0;for(a=this.attributes.normal.array.length;b0)h=d-1;else{h=d;break}}d=h;if(c[d]==f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)}; THREE.Curve.prototype.getTangent=function(b){var a=b-1.0E-4,b=b+1.0E-4;a<0&&(a=0);b>1&&(b=1);a=this.getPoint(a);return this.getPoint(b).clone().subSelf(a).normalize()};THREE.Curve.prototype.getTangentAt=function(b){return this.getTangent(this.getUtoTmapping(b))};THREE.LineCurve=function(b,a){this.v1=b;this.v2=a};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.getPoint=function(b){var a=this.v2.clone().subSelf(this.v1);a.multiplyScalar(b).addSelf(this.v1);return a}; diff --git a/build/custom/ThreeWebGL.js b/build/custom/ThreeWebGL.js index 37cef6aa60..fff9d275e8 100644 --- a/build/custom/ThreeWebGL.js +++ b/build/custom/ThreeWebGL.js @@ -16,8 +16,8 @@ THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a; a;this.z=this.z+a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x=this.x-a.x;this.y=this.y-a.y;this.z=this.z-a.z;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x=this.x*a.x;this.y=this.y*a.y;this.z=this.z*a.z;return this},multiplyScalar:function(a){this.x=this.x*a;this.y=this.y*a;this.z=this.z*a;return this},divideSelf:function(a){this.x=this.x/a.x;this.y= this.y/a.y;this.z=this.z/a.z;return this},divideScalar:function(a){if(a){this.x=this.x/a;this.y=this.y/a;this.z=this.z/a}else this.z=this.y=this.x=0;return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},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;return this},cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){return(new THREE.Vector3).sub(this, -a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,f=d[0],e=d[4],h=d[8],k=d[1],m=d[5],l=d[9],i=d[2],o=d[6],d=d[10];if(b===void 0||b==="XYZ"){this.y=Math.asin(c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(-l,d);this.z=Math.atan2(-e,f)}else{this.x=Math.atan2(k,m);this.z=0}}else if(b==="YXZ"){this.x=Math.asin(-c(l));if(Math.abs(l)< -0.99999){this.y=Math.atan2(h,d);this.z=Math.atan2(k,m)}else{this.y=Math.atan2(-i,f);this.z=0}}else if(b==="ZXY"){this.x=Math.asin(c(o));if(Math.abs(o)<0.99999){this.y=Math.atan2(-i,d);this.z=Math.atan2(-e,m)}else{this.y=0;this.z=Math.atan2(h,f)}}else if(b==="ZYX"){this.y=Math.asin(-c(i));if(Math.abs(i)<0.99999){this.x=Math.atan2(o,d);this.z=Math.atan2(k,f)}else{this.x=0;this.z=Math.atan2(-e,m)}}else if(b==="YZX"){this.z=Math.asin(c(k));if(Math.abs(k)<0.99999){this.x=Math.atan2(-l,m);this.y=Math.atan2(-i, +a).lengthSq()},getPositionFromMatrix:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setEulerFromRotationMatrix:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.elements,f=d[0],e=d[4],h=d[8],j=d[1],m=d[5],l=d[9],i=d[2],o=d[6],d=d[10];if(b===void 0||b==="XYZ"){this.y=Math.asin(c(h));if(Math.abs(h)<0.99999){this.x=Math.atan2(-l,d);this.z=Math.atan2(-e,f)}else{this.x=Math.atan2(j,m);this.z=0}}else if(b==="YXZ"){this.x=Math.asin(-c(l));if(Math.abs(l)< +0.99999){this.y=Math.atan2(h,d);this.z=Math.atan2(j,m)}else{this.y=Math.atan2(-i,f);this.z=0}}else if(b==="ZXY"){this.x=Math.asin(c(o));if(Math.abs(o)<0.99999){this.y=Math.atan2(-i,d);this.z=Math.atan2(-e,m)}else{this.y=0;this.z=Math.atan2(h,f)}}else if(b==="ZYX"){this.y=Math.asin(-c(i));if(Math.abs(i)<0.99999){this.x=Math.atan2(o,d);this.z=Math.atan2(j,f)}else{this.x=0;this.z=Math.atan2(-e,m)}}else if(b==="YZX"){this.z=Math.asin(c(j));if(Math.abs(j)<0.99999){this.x=Math.atan2(-l,m);this.y=Math.atan2(-i, f)}else{this.x=0;this.y=Math.atan2(i,d)}}else if(b==="XZY"){this.z=Math.asin(-c(e));if(Math.abs(e)<0.99999){this.x=Math.atan2(o,m);this.y=Math.atan2(h,f)}else{this.x=Math.atan2(-h,d);this.y=0}}return this},setEulerFromQuaternion:function(a,b){function c(a){return Math.min(Math.max(a,-1),1)}var d=a.x*a.x,f=a.y*a.y,e=a.z*a.z,h=a.w*a.w;if(b===void 0||b==="XYZ"){this.x=Math.atan2(2*(a.x*a.w-a.y*a.z),h-d-f+e);this.y=Math.asin(c(2*(a.x*a.z+a.y*a.w)));this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),h+d-f-e)}else if(b=== "YXZ"){this.x=Math.asin(c(2*(a.x*a.w-a.y*a.z)));this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),h-d-f+e);this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),h-d+f-e)}else if(b==="ZXY"){this.x=Math.asin(c(2*(a.x*a.w+a.y*a.z)));this.y=Math.atan2(2*(a.y*a.w-a.z*a.x),h-d-f+e);this.z=Math.atan2(2*(a.z*a.w-a.x*a.y),h-d+f-e)}else if(b==="ZYX"){this.x=Math.atan2(2*(a.x*a.w+a.z*a.y),h-d-f+e);this.y=Math.asin(c(2*(a.y*a.w-a.x*a.z)));this.z=Math.atan2(2*(a.x*a.y+a.z*a.w),h+d-f-e)}else if(b==="YZX"){this.x=Math.atan2(2*(a.x*a.w-a.z* a.y),h-d+f-e);this.y=Math.atan2(2*(a.y*a.w-a.x*a.z),h+d-f-e);this.z=Math.asin(c(2*(a.x*a.y+a.z*a.w)))}else if(b==="XZY"){this.x=Math.atan2(2*(a.x*a.w+a.y*a.z),h-d+f-e);this.y=Math.atan2(2*(a.x*a.z+a.y*a.w),h+d-f-e);this.z=Math.asin(c(2*(a.z*a.w-a.x*a.y)))}return this},getScaleFromMatrix:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],a.elements[6]).length(),a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x= @@ -25,46 +25,46 @@ b;this.y=c;this.z=a;return this},equals:function(a){return a.x===this.x&&a.y===t THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w!==void 0?a.w:1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x=this.x+a.x;this.y=this.y+a.y;this.z=this.z+a.z;this.w=this.w+a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x= 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,f=a[0];d=a[4];var e=a[8],h=a[1],k=a[5],m=a[9];c=a[2];b=a[6];var l=a[10];if(Math.abs(d-h)<0.01&&Math.abs(e-c)<0.01&&Math.abs(m-b)<0.01){if(Math.abs(d+h)<0.1&&Math.abs(e+c)<0.1&&Math.abs(m+b)<0.1&&Math.abs(f+k+l-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;f=(f+1)/2;k=(k+1)/2;l=(l+1)/2;d=(d+h)/4;e=(e+c)/4;m=(m+b)/4;if(f>k&&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(k> -l)if(k<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(k);b=d/c;d=m/c}else if(l<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(l);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+k+l-1)/2);return this}}; +a.y/b;this.z=a.z/b}return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d,a=a.elements,f=a[0];d=a[4];var e=a[8],h=a[1],j=a[5],m=a[9];c=a[2];b=a[6];var l=a[10];if(Math.abs(d-h)<0.01&&Math.abs(e-c)<0.01&&Math.abs(m-b)<0.01){if(Math.abs(d+h)<0.1&&Math.abs(e+c)<0.1&&Math.abs(m+b)<0.1&&Math.abs(f+j+l-3)<0.1){this.set(1,0,0,0);return this}a=Math.PI;f=(f+1)/2;j=(j+1)/2;l=(l+1)/2;d=(d+h)/4;e=(e+c)/4;m=(m+b)/4;if(f>j&&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(j> +l)if(j<0.01){b=0.707106781;c=0;d=0.707106781}else{c=Math.sqrt(j);b=d/c;d=m/c}else if(l<0.01){c=b=0.707106781;d=0}else{d=Math.sqrt(l);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+j+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=this.planes,c=a.elements,a=c[0],d=c[1],f=c[2],e=c[3],h=c[4],k=c[5],m=c[6],l=c[7],i=c[8],o=c[9],j=c[10],v=c[11],p=c[12],n=c[13],r=c[14],c=c[15];b[0].set(e-a,l-h,v-i,c-p);b[1].set(e+a,l+h,v+i,c+p);b[2].set(e+d,l+k,v+o,c+n);b[3].set(e-d,l-k,v-o,c-n);b[4].set(e-f,l-m,v-j,c-r);b[5].set(e+f,l+m,v+j,c+r);for(d=0;d<6;d++){a=b[d];a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))}}; +THREE.Frustum.prototype.setFromMatrix=function(a){var b=this.planes,c=a.elements,a=c[0],d=c[1],f=c[2],e=c[3],h=c[4],j=c[5],m=c[6],l=c[7],i=c[8],o=c[9],k=c[10],v=c[11],p=c[12],n=c[13],r=c[14],c=c[15];b[0].set(e-a,l-h,v-i,c-p);b[1].set(e+a,l+h,v+i,c+p);b[2].set(e+d,l+j,v+o,c+n);b[3].set(e-d,l-j,v-o,c-n);b[4].set(e-f,l-m,v-k,c-r);b[5].set(e+f,l+m,v+k,c+r);for(d=0;d<6;d++){a=b[d];a.divideScalar(Math.sqrt(a.x*a.x+a.y*a.y+a.z*a.z))}}; THREE.Frustum.prototype.contains=function(a){for(var b=0,c=this.planes,b=a.matrixWorld,d=b.elements,a=-a.geometry.boundingSphere.radius*b.getMaxScaleOnAxis(),f=0;f<6;f++){b=c[f].x*d[12]+c[f].y*d[13]+c[f].z*d[14]+c[f].w;if(b<=a)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,h=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Vector3,l=new THREE.Vector3,i=new THREE.Vector3,o=new THREE.Vector3,j=new THREE.Vector3,v=function(a,b){return a.distance-b.distance},p=new THREE.Vector3,n=new THREE.Vector3,r=new THREE.Vector3,q,u,B,D=function(a,b,c){p.sub(c,a);q=p.dot(b);u=n.add(a,r.copy(b).multiplyScalar(q)); +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,h=new THREE.Vector3,j=new THREE.Vector3,m=new THREE.Vector3,l=new THREE.Vector3,i=new THREE.Vector3,o=new THREE.Vector3,k=new THREE.Vector3,v=function(a,b){return a.distance-b.distance},p=new THREE.Vector3,n=new THREE.Vector3,r=new THREE.Vector3,q,u,B,D=function(a,b,c){p.sub(c,a);q=p.dot(b);u=n.add(a,r.copy(b).multiplyScalar(q)); return B=c.distanceTo(u)},s,J,A,M,E,Q,G,R,T=function(a,b,c,d){p.sub(d,b);n.sub(c,b);r.sub(a,b);s=p.dot(p);J=p.dot(n);A=p.dot(r);M=n.dot(n);E=n.dot(r);Q=1/(s*M-J*J);G=(M*A-J*E)*Q;R=(s*E-J*A)*Q;return G>=0&&R>=0&&G+R<1},S=1.0E-4;this.setPrecision=function(a){S=a};this.intersectObject=function(a,b){var c,d=[];if(b===true)for(var g=0,n=a.children.length;ga.scale.x)return[];c={distance:B,point:a.position,face:null,object:a};d.push(c)}else if(a instanceof THREE.Mesh){g=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());g=a.geometry.boundingSphere.radius*Math.max(g.x,Math.max(g.y,g.z));B=D(this.origin,this.direction,a.matrixWorld.getPosition());if(B>g)return d;var p,r,q=a.geometry,u=q.vertices,s;a.matrixRotationWorld.extractRotation(a.matrixWorld);g=0;for(n=q.faces.length;g< -n;g++){c=q.faces[g];m.copy(this.origin);l.copy(this.direction);s=a.matrixWorld;i=s.multiplyVector3(i.copy(c.centroid)).subSelf(m);o=a.matrixRotationWorld.multiplyVector3(o.copy(c.normal));p=l.dot(o);if(!(Math.abs(p)0:p<0))){j.add(m,l.multiplyScalar(r));B=m.distanceTo(j);if(!(Bthis.far))if(c instanceof THREE.Face3){f=s.multiplyVector3(f.copy(u[c.a]));e=s.multiplyVector3(e.copy(u[c.b]));h=s.multiplyVector3(h.copy(u[c.c])); -if(T(j,f,e,h)){c={distance:B,point:j.clone(),face:c,object:a};d.push(c)}}else if(c instanceof THREE.Face4){f=s.multiplyVector3(f.copy(u[c.a]));e=s.multiplyVector3(e.copy(u[c.b]));h=s.multiplyVector3(h.copy(u[c.c]));k=s.multiplyVector3(k.copy(u[c.d]));if(T(j,f,e,k)||T(j,e,h,k)){c={distance:B,point:j.clone(),face:c,object:a};d.push(c)}}}}}}d.sort(v);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,g=a.length;d0:p<0))){k.add(m,l.multiplyScalar(r));B=m.distanceTo(k);if(!(Bthis.far))if(c instanceof THREE.Face3){f=s.multiplyVector3(f.copy(u[c.a]));e=s.multiplyVector3(e.copy(u[c.b]));h=s.multiplyVector3(h.copy(u[c.c])); +if(T(k,f,e,h)){c={distance:B,point:k.clone(),face:c,object:a};d.push(c)}}else if(c instanceof THREE.Face4){f=s.multiplyVector3(f.copy(u[c.a]));e=s.multiplyVector3(e.copy(u[c.b]));h=s.multiplyVector3(h.copy(u[c.c]));j=s.multiplyVector3(j.copy(u[c.d]));if(T(k,f,e,j)||T(k,e,h,j)){c={distance:B,point:k.clone(),face:c,object:a};d.push(c)}}}}}}d.sort(v);return d};this.intersectObjects=function(a,b){for(var c=[],d=0,g=a.length;de?d:e;f=f>h?f:h}a()};this.add3Points=function(e,h,i,o,j,v){if(k===true){k=false;b=ei?e>j?e:j:i>j?i:j;f=h>o?h>v?h:v:o>v?o:v}else{b=ei?e>j?e>d?e:d:j>d?j:d:i>j?i>d?i:d:j>d?j:d;f=h>o?h>v?h>f?h:f:v>f?v:f:o>v?o>f?o:f:v>f?v:f}a()};this.addRectangle=function(e){if(k===true){k=false;b=e.getLeft();c=e.getTop();d=e.getRight();f=e.getBottom()}else{b=be.getRight()?d:e.getRight();f=f>e.getBottom()?f:e.getBottom()}a()};this.inflate=function(e){b=b-e;c=c-e;d=d+e;f=f+e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=da.getRight()||fa.getBottom()?false:true};this.empty=function(){k=true;f=d=c=b=0;a()};this.isEmpty=function(){return k}}; +THREE.Rectangle=function(){function a(){e=d-b;h=f-c}var b=0,c=0,d=0,f=0,e=0,h=0,j=true;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,h,i,o){j=false;b=e;c=h;d=i;f=o;a()};this.addPoint=function(e,h){if(j===true){j=false;b=e;c=h;d=e;f=h}else{b=be?d:e;f=f>h?f:h}a()};this.add3Points=function(e,h,i,o,k,v){if(j===true){j=false;b=ei?e>k?e:k:i>k?i:k;f=h>o?h>v?h:v:o>v?o:v}else{b=ei?e>k?e>d?e:d:k>d?k:d:i>k?i>d?i:d:k>d?k:d;f=h>o?h>v?h>f?h:f:v>f?v:f:o>v?o>f?o:f:v>f?v:f}a()};this.addRectangle=function(e){if(j===true){j=false;b=e.getLeft();c=e.getTop();d=e.getRight();f=e.getBottom()}else{b=be.getRight()?d:e.getRight();f=f>e.getBottom()?f:e.getBottom()}a()};this.inflate=function(e){b=b-e;c=c-e;d=d+e;f=f+e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=da.getRight()||fa.getBottom()?false:true};this.empty=function(){j=true;f=d=c=b=0;a()};this.isEmpty=function(){return j}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a0?1:0}};THREE.Matrix3=function(){this.elements=new Float32Array(9)}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],f=-b[10]*b[4]+b[6]*b[8],e=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],l=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*f+b[2]*k;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,i=this.elements;i[0]=b*a;i[1]=b*c;i[2]=b*d;i[3]=b*f;i[4]=b*e;i[5]=b*h;i[6]=b*k;i[7]=b*m;i[8]=b*l;return this}, -transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,e,h,k,m,l,i,o,j,v,p,n){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,h||0,k||0,m||0,l||0,i!==void 0?i:1,o||0,j||0,v||0,p||0,n!==void 0?n:1)}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,h,k,m,l,i,o,j,v,p,n){var r=this.elements;r[0]=a;r[4]=b;r[8]=c;r[12]=d;r[1]=f;r[5]=e;r[9]=h;r[13]=k;r[2]=m;r[6]=l;r[10]=i;r[14]=o;r[3]=j;r[7]=v;r[11]=p;r[15]=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements, -f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x=h.x+1.0E-4;f.cross(c,h).normalize()}e.cross(h,f);d[0]=f.x;d[4]=e.x;d[8]=h.x;d[1]=f.y;d[5]=e.y;d[9]=h.y;d[2]=f.z;d[6]=e.z;d[10]=h.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,f=this.elements,e=c[0],h=c[4],k=c[8],m=c[12],l=c[1],i=c[5],o=c[9],j=c[13],v=c[2],p=c[6],n=c[10],r=c[14],q=c[3],u=c[7],B=c[11],c=c[15],D=d[0],s=d[4], -J=d[8],A=d[12],M=d[1],E=d[5],Q=d[9],G=d[13],R=d[2],T=d[6],S=d[10],y=d[14],L=d[3],Z=d[7],F=d[11],d=d[15];f[0]=e*D+h*M+k*R+m*L;f[4]=e*s+h*E+k*T+m*Z;f[8]=e*J+h*Q+k*S+m*F;f[12]=e*A+h*G+k*y+m*d;f[1]=l*D+i*M+o*R+j*L;f[5]=l*s+i*E+o*T+j*Z;f[9]=l*J+i*Q+o*S+j*F;f[13]=l*A+i*G+o*y+j*d;f[2]=v*D+p*M+n*R+r*L;f[6]=v*s+p*E+n*T+r*Z;f[10]=v*J+p*Q+n*S+r*F;f[14]=v*A+p*G+n*y+r*d;f[3]=q*D+u*M+B*R+c*L;f[7]=q*s+u*E+B*T+c*Z;f[11]=q*J+u*Q+B*S+c*F;f[15]=q*A+u*G+B*y+c*d;return this},multiplySelf:function(a){return this.multiply(this, +THREE.Matrix3.prototype={constructor:THREE.Matrix3,getInverse:function(a){var b=a.elements,a=b[10]*b[5]-b[6]*b[9],c=-b[10]*b[1]+b[2]*b[9],d=b[6]*b[1]-b[2]*b[5],f=-b[10]*b[4]+b[6]*b[8],e=b[10]*b[0]-b[2]*b[8],h=-b[6]*b[0]+b[2]*b[4],j=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],l=b[5]*b[0]-b[1]*b[4],b=b[0]*a+b[1]*f+b[2]*j;b===0&&console.warn("Matrix3.getInverse(): determinant == 0");var b=1/b,i=this.elements;i[0]=b*a;i[1]=b*c;i[2]=b*d;i[3]=b*f;i[4]=b*e;i[5]=b*h;i[6]=b*j;i[7]=b*m;i[8]=b*l;return this}, +transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,e,h,j,m,l,i,o,k,v,p,n){this.elements=new Float32Array(16);this.set(a!==void 0?a:1,b||0,c||0,d||0,f||0,e!==void 0?e:1,h||0,j||0,m||0,l||0,i!==void 0?i:1,o||0,k||0,v||0,p||0,n!==void 0?n:1)}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,e,h,j,m,l,i,o,k,v,p,n){var r=this.elements;r[0]=a;r[4]=b;r[8]=c;r[12]=d;r[1]=f;r[5]=e;r[9]=h;r[13]=j;r[2]=m;r[6]=l;r[10]=i;r[14]=o;r[3]=k;r[7]=v;r[11]=p;r[15]=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]);return this},lookAt:function(a,b,c){var d=this.elements, +f=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,b).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x=h.x+1.0E-4;f.cross(c,h).normalize()}e.cross(h,f);d[0]=f.x;d[4]=e.x;d[8]=h.x;d[1]=f.y;d[5]=e.y;d[9]=h.y;d[2]=f.z;d[6]=e.z;d[10]=h.z;return this},multiply:function(a,b){var c=a.elements,d=b.elements,f=this.elements,e=c[0],h=c[4],j=c[8],m=c[12],l=c[1],i=c[5],o=c[9],k=c[13],v=c[2],p=c[6],n=c[10],r=c[14],q=c[3],u=c[7],B=c[11],c=c[15],D=d[0],s=d[4], +J=d[8],A=d[12],M=d[1],E=d[5],Q=d[9],G=d[13],R=d[2],T=d[6],S=d[10],y=d[14],L=d[3],Z=d[7],F=d[11],d=d[15];f[0]=e*D+h*M+j*R+m*L;f[4]=e*s+h*E+j*T+m*Z;f[8]=e*J+h*Q+j*S+m*F;f[12]=e*A+h*G+j*y+m*d;f[1]=l*D+i*M+o*R+k*L;f[5]=l*s+i*E+o*T+k*Z;f[9]=l*J+i*Q+o*S+k*F;f[13]=l*A+i*G+o*y+k*d;f[2]=v*D+p*M+n*R+r*L;f[6]=v*s+p*E+n*T+r*Z;f[10]=v*J+p*Q+n*S+r*F;f[14]=v*A+p*G+n*y+r*d;f[3]=q*D+u*M+B*R+c*L;f[7]=q*s+u*E+B*T+c*Z;f[11]=q*J+u*Q+B*S+c*F;f[15]=q*A+u*G+B*y+c*d;return this},multiplySelf:function(a){return this.multiply(this, a)},multiplyToArray:function(a,b,c){var d=this.elements;this.multiply(a,b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]=b[0]*a;b[4]=b[4]*a;b[8]=b[8]*a;b[12]=b[12]*a;b[1]=b[1]*a;b[5]=b[5]*a;b[9]=b[9]*a;b[13]=b[13]*a;b[2]=b[2]*a;b[6]=b[6]*a;b[10]=b[10]*a;b[14]=b[14]*a;b[3]=b[3]*a;b[7]=b[7]*a;b[11]=b[11]*a;b[15]= b[15]*a;return this},multiplyVector3:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=1/(b[3]*c+b[7]*d+b[11]*f+b[15]);a.x=(b[0]*c+b[4]*d+b[8]*f+b[12])*e;a.y=(b[1]*c+b[5]*d+b[9]*f+b[13])*e;a.z=(b[2]*c+b[6]*d+b[10]*f+b[14])*e;return a},multiplyVector4:function(a){var b=this.elements,c=a.x,d=a.y,f=a.z,e=a.w;a.x=b[0]*c+b[4]*d+b[8]*f+b[12]*e;a.y=b[1]*c+b[5]*d+b[9]*f+b[13]*e;a.z=b[2]*c+b[6]*d+b[10]*f+b[14]*e;a.w=b[3]*c+b[7]*d+b[11]*f+b[15]*e;return a},multiplyVector3Array:function(a){for(var b=THREE.Matrix4.__v1, c=0,d=a.length;c=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(dh&&k.positionScreen.z0)){na=l[m-2];G.copy(H.positionScreen);R.copy(na.positionScreen);if(d(G,R)===true){G.multiplyScalar(1/G.w);R.multiplyScalar(1/R.w);Ba=void 0;if(r===q.length){Ba=new THREE.RenderableLine;q.push(Ba)}else Ba=q[r];r++;n=Ba;n.v1.positionScreen.copy(G);n.v2.positionScreen.copy(R);n.z=Math.max(G.z,R.z);n.material=oa.material;s.elements.push(n)}}}}}a=0;for(g= -s.sprites.length;a0&&A.z<1){h=void 0;if(B===D.length){h=new THREE.RenderableParticle;D.push(h)}else h=D[B];B++;u=h;u.x=A.x/A.w;u.y=A.y/A.w;u.z=A.z;u.rotation=oa.rotation.z;u.scale.x=oa.scale.x*Math.abs(u.x-(A.x+e.projectionMatrix.elements[0])/(A.w+e.projectionMatrix.elements[12]));u.scale.y=oa.scale.y*Math.abs(u.y-(A.y+e.projectionMatrix.elements[5])/ +e,f){var h=e.near,J=e.far,F=false,g,X,I,za,H,na,ca,da,oa,Ca,Ja,Aa,Sa,Ua,Da;B=r=v=o=0;s.elements.length=0;if(e.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(e)}a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);M.multiply(e.projectionMatrix,e.matrixWorldInverse);Q.setFromMatrix(M);s=this.projectGraph(a,false);a=0;for(g=s.objects.length;ah&&j.positionScreen.z0)){na=l[m-2];G.copy(H.positionScreen);R.copy(na.positionScreen);if(d(G,R)===true){G.multiplyScalar(1/G.w);R.multiplyScalar(1/R.w);Aa=void 0;if(r===q.length){Aa=new THREE.RenderableLine;q.push(Aa)}else Aa=q[r];r++;n=Aa;n.v1.positionScreen.copy(G);n.v2.positionScreen.copy(R);n.z=Math.max(G.z,R.z);n.material=oa.material;s.elements.push(n)}}}}}a=0;for(g= +s.sprites.length;a0&&A.z<1){h=void 0;if(B===D.length){h=new THREE.RenderableParticle;D.push(h)}else h=D[B];B++;u=h;u.x=A.x/A.w;u.y=A.y/A.w;u.z=A.z;u.rotation=oa.rotation.z;u.scale.x=oa.scale.x*Math.abs(u.x-(A.x+e.projectionMatrix.elements[0])/(A.w+e.projectionMatrix.elements[12]));u.scale.y=oa.scale.y*Math.abs(u.y-(A.y+e.projectionMatrix.elements[5])/ (A.w+e.projectionMatrix.elements[13]));u.material=oa.material;s.elements.push(u)}}}f&&s.elements.sort(c);return s}};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=Math.cos(a.x/2),d=Math.cos(a.y/2),f=Math.cos(a.z/2),e=Math.sin(a.x/2),h=Math.sin(a.y/2),k=Math.sin(a.z/2);if(b===void 0||b==="XYZ"){this.x=e*d*f+c*h*k;this.y=c*h*f-e*d*k;this.z=c*d*k+e*h*f;this.w=c*d*f-e*h*k}else if(b==="YXZ"){this.x=e*d*f+c*h*k;this.y=c*h*f-e*d*k;this.z= -c*d*k-e*h*f;this.w=c*d*f+e*h*k}else if(b==="ZXY"){this.x=e*d*f-c*h*k;this.y=c*h*f+e*d*k;this.z=c*d*k+e*h*f;this.w=c*d*f-e*h*k}else if(b==="ZYX"){this.x=e*d*f-c*h*k;this.y=c*h*f+e*d*k;this.z=c*d*k-e*h*f;this.w=c*d*f+e*h*k}else if(b==="YZX"){this.x=e*d*f+c*h*k;this.y=c*h*f+e*d*k;this.z=c*d*k-e*h*f;this.w=c*d*f-e*h*k}else if(b==="XZY"){this.x=e*d*f-c*h*k;this.y=c*h*f-e*d*k;this.z=c*d*k+e*h*f;this.w=c*d*f+e*h*k}return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y* -d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],h=b[9],k=b[2],m=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=(m-h)*c;this.y=(d-k)*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+k)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-k)/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+k)/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,k=a.z,a=a.w;this.x=b*a+f*e+c*k-d*h;this.y=c*a+f*h+d*e-b*k;this.z=d*a+f*k+b*h-c*e;this.w=f*a-b*e-c*h-d*k;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,k=this.z,m=this.w,l=m*c+h*f-k*d,i=m*d+k*c-e*f,o=m*f+e*d-h*c,c=-e*c-h*d-k*f;b.x=l*m+c*-e+i*-k-o*-h;b.y=i*m+c*-h+o*-e-l*-k;b.z=o*m+c*-k+l*-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 k=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)*k)/m;k=Math.sin(b*k)/m;this.w=e*h+this.w*k;this.x=c*h+this.x*k;this.y=d*h+this.y*k;this.z=f*h+this.z*k;return this},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)}}; +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=Math.cos(a.x/2),d=Math.cos(a.y/2),f=Math.cos(a.z/2),e=Math.sin(a.x/2),h=Math.sin(a.y/2),j=Math.sin(a.z/2);if(b===void 0||b==="XYZ"){this.x=e*d*f+c*h*j;this.y=c*h*f-e*d*j;this.z=c*d*j+e*h*f;this.w=c*d*f-e*h*j}else if(b==="YXZ"){this.x=e*d*f+c*h*j;this.y=c*h*f-e*d*j;this.z= +c*d*j-e*h*f;this.w=c*d*f+e*h*j}else if(b==="ZXY"){this.x=e*d*f-c*h*j;this.y=c*h*f+e*d*j;this.z=c*d*j+e*h*f;this.w=c*d*f-e*h*j}else if(b==="ZYX"){this.x=e*d*f-c*h*j;this.y=c*h*f+e*d*j;this.z=c*d*j-e*h*f;this.w=c*d*f+e*h*j}else if(b==="YZX"){this.x=e*d*f+c*h*j;this.y=c*h*f+e*d*j;this.z=c*d*j-e*h*f;this.w=c*d*f-e*h*j}else if(b==="XZY"){this.x=e*d*f-c*h*j;this.y=c*h*f-e*d*j;this.z=c*d*j+e*h*f;this.w=c*d*f+e*h*j}return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);this.x=a.x*d;this.y=a.y* +d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0],a=b[4],d=b[8],f=b[1],e=b[5],h=b[9],j=b[2],m=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=(m-h)*c;this.y=(d-j)*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+j)/c}else if(e>b){c=2*Math.sqrt(1+e-c-b);this.w=(d-j)/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+j)/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,j=a.z,a=a.w;this.x=b*a+f*e+c*j-d*h;this.y=c*a+f*h+d*e-b*j;this.z=d*a+f*j+b*h-c*e;this.w=f*a-b*e-c*h-d*j;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,j=this.z,m=this.w,l=m*c+h*f-j*d,i=m*d+j*c-e*f,o=m*f+e*d-h*c,c=-e*c-h*d-j*f;b.x=l*m+c*-e+i*-j-o*-h;b.y=i*m+c*-h+o*-e-l*-j;b.z=o*m+c*-j+l*-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 j=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)*j)/m;j=Math.sin(b*j)/m;this.w=e*h+this.w*j;this.x=c*h+this.x*j;this.y=d*h+this.y*j;this.z=f*h+this.z*j;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.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= -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,h,k;e=0;for(h=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;fthis.points.length-2?this.points.length-1:e+1;c[3]=e>this.points.length-3?this.points.length-1: -e+2;l=this.points[c[0]];i=this.points[c[1]];o=this.points[c[2]];j=this.points[c[3]];k=h*h;m=h*k;d.x=b(l.x,i.x,o.x,j.x,h,k,m);d.y=b(l.y,i.y,o.y,j.y,h,k,m);d.z=b(l.z,i.z,o.z,j.z,h,k,m);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;ac.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,h,j;e=0;for(h=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;fthis.points.length-2?this.points.length-1:e+1;c[3]=e>this.points.length-3?this.points.length-1: +e+2;l=this.points[c[0]];i=this.points[c[1]];o=this.points[c[2]];k=this.points[c[3]];j=h*h;m=h*j;d.x=b(l.x,i.x,o.x,k.x,h,j,m);d.y=b(l.y,i.y,o.y,k.y,h,j,m);d.z=b(l.z,i.z,o.z,k.z,h,j,m);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a1&&(R=new THREE.MeshFaceMaterial); -a=new THREE.Mesh(G,R);a.name=j;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(s[0],s[1],s[2]);if(A){a.quaternion.set(A[0],A[1],A[2],A[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=q.visible;a.doubleSided=q.doubleSided;a.castShadow=q.castShadow;a.receiveShadow=q.receiveShadow;I.scene.add(a);I.objects[j]=a}}else{s=q.position;J=q.rotation;A=q.quaternion; -M=q.scale;A=0;a=new THREE.Object3D;a.name=j;a.position.set(s[0],s[1],s[2]);if(A){a.quaternion.set(A[0],A[1],A[2],A[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=q.visible!==void 0?q.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();k()}}function h(a){return function(b){I.geometries[a]=b}}function k(){m.callbackProgress({totalModels:g,totalTextures:X,loadedModels:g- -Z,loadedTextures:X-F},I);m.onLoadProgress();Z===0&&F===0&&b(I)}var m=this,l=THREE.Loader.prototype.extractUrlBase(c),i,o,j,v,p,n,r,q,u,B,D,s,J,A,M,E,Q,G,R,T,S,y,L,Z,F,g,X,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(a){return function(){F=F-a;k();m.onLoadComplete()}};for(p in y.cameras){E=y.cameras[p];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));s=E.position;B=E.target;E=E.up;T.position.set(s[0],s[1],s[2]);T.target=new THREE.Vector3(B[0],B[1],B[2]);E&&T.up.set(E[0], +THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return b=="relativeToHTML"?a:l+"/"+a}function f(){var a;for(k in y.objects)if(!I.objects[k]){q=y.objects[k];if(q.geometry!==void 0){if(G=I.geometries[q.geometry]){a=false;R=I.materials[q.materials[0]];(a=R instanceof THREE.ShaderMaterial)&&G.computeTangents();s=q.position;J=q.rotation;A=q.quaternion;M=q.scale;u=q.matrix;A=0;q.materials.length==0&&(R=new THREE.MeshFaceMaterial);q.materials.length>1&&(R=new THREE.MeshFaceMaterial); +a=new THREE.Mesh(G,R);a.name=k;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(s[0],s[1],s[2]);if(A){a.quaternion.set(A[0],A[1],A[2],A[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=q.visible;a.doubleSided=q.doubleSided;a.castShadow=q.castShadow;a.receiveShadow=q.receiveShadow;I.scene.add(a);I.objects[k]=a}}else{s=q.position;J=q.rotation;A=q.quaternion; +M=q.scale;A=0;a=new THREE.Object3D;a.name=k;a.position.set(s[0],s[1],s[2]);if(A){a.quaternion.set(A[0],A[1],A[2],A[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=q.visible!==void 0?q.visible:false;I.scene.add(a);I.objects[k]=a;I.empties[k]=a}}}function e(a){return function(b){I.geometries[a]=b;f();Z=Z-1;m.onLoadComplete();j()}}function h(a){return function(b){I.geometries[a]=b}}function j(){m.callbackProgress({totalModels:g,totalTextures:X,loadedModels:g- +Z,loadedTextures:X-F},I);m.onLoadProgress();Z===0&&F===0&&b(I)}var m=this,l=THREE.Loader.prototype.extractUrlBase(c),i,o,k,v,p,n,r,q,u,B,D,s,J,A,M,E,Q,G,R,T,S,y,L,Z,F,g,X,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(a){return function(){F=F-a;j();m.onLoadComplete()}};for(p in y.cameras){E=y.cameras[p];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));s=E.position;B=E.target;E=E.up;T.position.set(s[0],s[1],s[2]);T.target=new THREE.Vector3(B[0],B[1],B[2]);E&&T.up.set(E[0], E[1],E[2]);I.cameras[p]=T}for(v in y.lights){B=y.lights[v];p=B.color!==void 0?B.color:16777215;T=B.intensity!==void 0?B.intensity:1;if(B.type==="directional"){s=B.direction;D=new THREE.DirectionalLight(p,T);D.position.set(s[0],s[1],s[2]);D.position.normalize()}else if(B.type==="point"){s=B.position;D=B.distance;D=new THREE.PointLight(p,T,D);D.position.set(s[0],s[1],s[2])}else B.type==="ambient"&&(D=new THREE.AmbientLight(p));I.scene.add(D);I.lights[v]=D}for(n in y.fogs){v=y.fogs[n];v.type==="linear"? S=new THREE.Fog(0,v.near,v.far):v.type==="exp2"&&(S=new THREE.FogExp2(0,v.density));E=v.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, @@ -186,7 +186,7 @@ void 0)n.minFilter=THREE[i.minFilter];if(THREE[i.magFilter]!==void 0)n.magFilter y.materials[o];for(Q in u.parameters)if(Q==="envMap"||Q==="map"||Q==="lightMap")u.parameters[Q]=I.textures[u.parameters[Q]];else if(Q==="shading")u.parameters[Q]=u.parameters[Q]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(Q==="blending")u.parameters[Q]=u.parameters[Q]in THREE?THREE[u.parameters[Q]]:THREE.NormalBlending;else if(Q==="combine")u.parameters[Q]=u.parameters[Q]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(Q==="vertexColors")if(u.parameters[Q]=="face")u.parameters[Q]= THREE.FaceColors;else if(u.parameters[Q])u.parameters[Q]=THREE.VertexColors;if(u.parameters.opacity!==void 0&&u.parameters.opacity<1)u.parameters.transparent=true;if(u.parameters.normalMap){r=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(r.uniforms);i=u.parameters.color;n=u.parameters.specular;S=u.parameters.ambient;c=u.parameters.shininess;a.tNormal.texture=I.textures[u.parameters.normalMap];if(u.parameters.normalMapFactor)a.uNormalScale.value=u.parameters.normalMapFactor;if(u.parameters.map){a.tDiffuse.texture= u.parameters.map;a.enableDiffuse.value=true}if(u.parameters.lightMap){a.tAO.texture=u.parameters.lightMap;a.enableAO.value=true}if(u.parameters.specularMap){a.tSpecular.texture=I.textures[u.parameters.specularMap];a.enableSpecular.value=true}a.uDiffuseColor.value.setHex(i);a.uSpecularColor.value.setHex(n);a.uAmbientColor.value.setHex(S);a.uShininess.value=c;if(u.parameters.opacity)a.uOpacity.value=u.parameters.opacity;R=new THREE.ShaderMaterial({fragmentShader:r.fragmentShader,vertexShader:r.vertexShader, -uniforms:a,lights:true,fog:true})}else R=new THREE[u.type](u.parameters);I.materials[o]=R}f();m.callbackSync(I);k()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null}; +uniforms:a,lights:true,fog:true})}else R=new THREE[u.type](u.parameters);I.materials[o]=R}f();m.callbackSync(I);j()};THREE.TextureLoader=function(){THREE.EventTarget.call(this);this.crossOrigin=null}; THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a){var b=this,c=new Image;c.addEventListener("load",function(){var a=new THREE.Texture(c);a.needsUpdate=true;b.dispatchEvent({type:"load",content:a})},false);c.addEventListener("error",function(){b.dispatchEvent({type:"error",message:"Couldn't load URL ["+a+"]"})},false);if(b.crossOrigin)c.crossOrigin=b.crossOrigin;c.src=a}}; THREE.Material=function(a){a=a||{};this.id=THREE.MaterialCount++;this.name="";this.opacity=a.opacity!==void 0?a.opacity:1;this.transparent=a.transparent!==void 0?a.transparent:false;this.blending=a.blending!==void 0?a.blending:THREE.NormalBlending;this.blendSrc=a.blendSrc!==void 0?a.blendSrc:THREE.SrcAlphaFactor;this.blendDst=a.blendDst!==void 0?a.blendDst:THREE.OneMinusSrcAlphaFactor;this.blendEquation=a.blendEquation!==void 0?a.blendEquation:THREE.AddEquation;this.depthTest=a.depthTest!==void 0? a.depthTest:true;this.depthWrite=a.depthWrite!==void 0?a.depthWrite:true;this.polygonOffset=a.polygonOffset!==void 0?a.polygonOffset:false;this.polygonOffsetFactor=a.polygonOffsetFactor!==void 0?a.polygonOffsetFactor:0;this.polygonOffsetUnits=a.polygonOffsetUnits!==void 0?a.polygonOffsetUnits:0;this.alphaTest=a.alphaTest!==void 0?a.alphaTest:0;this.overdraw=a.overdraw!==void 0?a.overdraw:false;this.needsUpdate=this.visible=true};THREE.MaterialCount=0; @@ -205,15 +205,15 @@ THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.sh THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:true;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:false;this.fog=a.fog!==void 0?a.fog:true};THREE.ParticleBasicMaterial.prototype=Object.create(THREE.Material.prototype); THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=a.fragmentShader!==void 0?a.fragmentShader:"void main() {}";this.vertexShader=a.vertexShader!==void 0?a.vertexShader:"void main() {}";this.uniforms=a.uniforms!==void 0?a.uniforms:{};this.attributes=a.attributes;this.shading=a.shading!==void 0?a.shading:THREE.SmoothShading;this.wireframe=a.wireframe!==void 0?a.wireframe:false;this.wireframeLinewidth=a.wireframeLinewidth!==void 0?a.wireframeLinewidth:1;this.fog= a.fog!==void 0?a.fog:false;this.lights=a.lights!==void 0?a.lights:false;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:THREE.NoColors;this.skinning=a.skinning!==void 0?a.skinning:false;this.morphTargets=a.morphTargets!==void 0?a.morphTargets:false;this.morphNormals=a.morphNormals!==void 0?a.morphNormals:false};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype); -THREE.Texture=function(a,b,c,d,f,e,h,k){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=f!==void 0?f:THREE.LinearFilter;this.minFilter=e!==void 0?e:THREE.LinearMipMapLinearFilter;this.format=h!==void 0?h:THREE.RGBAFormat;this.type=k!==void 0?k:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps= -true;this.premultiplyAlpha=false;this.flipY=true;this.needsUpdate=false;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.DataTexture=function(a,b,c,d,f,e,h,k,m,l){THREE.Texture.call(this,null,e,h,k,m,l,d,f);this.image={data:a,width:b,height:c}}; +THREE.Texture=function(a,b,c,d,f,e,h,j){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=f!==void 0?f:THREE.LinearFilter;this.minFilter=e!==void 0?e:THREE.LinearMipMapLinearFilter;this.format=h!==void 0?h:THREE.RGBAFormat;this.type=j!==void 0?j:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps= +true;this.premultiplyAlpha=false;this.flipY=true;this.needsUpdate=false;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.DataTexture=function(a,b,c,d,f,e,h,j,m,l){THREE.Texture.call(this,null,e,h,j,m,l,d,f);this.image={data:a,width:b,height:c}}; THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=Object.create(THREE.Object3D.prototype); THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b!==void 0?b:new THREE.ParticleBasicMaterial({color:Math.random()*16777215});this.sortParticles=false;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}this.frustumCulled=false};THREE.ParticleSystem.prototype=Object.create(THREE.Object3D.prototype); THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=b!==void 0?b:new THREE.LineBasicMaterial({color:Math.random()*16777215});this.type=c!==void 0?c:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=Object.create(THREE.Object3D.prototype); THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b!==void 0?b:new THREE.MeshBasicMaterial({color:Math.random()*16777215,wireframe:true});if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius;if(this.geometry.morphTargets.length){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c=0)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?false:a&&a.shading!==void 0&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function f(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?true:false}function e(a,b,c){var d,e,f,h,i=a.vertices;h=i.length; -var k=a.colors,j=k.length,l=a.__vertexArray,m=a.__colorArray,o=a.__sortArray,n=a.verticesNeedUpdate,r=a.colorsNeedUpdate,p=a.__webglCustomAttributesList;if(c.sortParticles){Rb.copy(Sb);Rb.multiplySelf(c.matrixWorld);for(d=0;d=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 r(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,k=d.uniforms;if(h!==Aa){g.useProgram(h);Aa=h;e=true}if(d.id!==na){na=d.id;e=true}if(e||a!==da){g.uniformMatrix4fv(i.projectionMatrix, -false,a._projectionMatrixArray);a!==da&&(da=a)}if(e){if(c&&d.fog){k.fogColor.value=c.color;if(c instanceof THREE.Fog){k.fogNear.value=c.near;k.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)k.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(pb){for(var j,l=0,m=0,o=0,n,p,r,q=bc,u=q.directional.colors,v=q.directional.positions,s=q.point.colors,y=q.point.positions,B=q.point.distances,E=q.spot.colors,I=q.spot.positions,J=q.spot.distances, -L=q.spot.directions,Q=q.spot.angles,G=q.spot.exponents,R=0,S=0,T=0,H=r=0,c=H=0,e=b.length;c=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 r(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!==da){g.uniformMatrix4fv(i.projectionMatrix, +false,a._projectionMatrixArray);a!==da&&(da=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 k,l=0,m=0,o=0,n,p,r,q=xc,u=q.directional.colors,v=q.directional.positions,s=q.point.colors,y=q.point.positions,B=q.point.distances,E=q.spot.colors,I=q.spot.positions,J=q.spot.distances, +L=q.spot.directions,Q=q.spot.angles,G=q.spot.exponents,R=0,S=0,T=0,H=r=0,c=H=0,e=b.length;c0};this.setSize= -function(a,b){M.width=a;M.height=b;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(a,b,c,d){Jb=a;cc=b;Kb=c;Lb=d;g.viewport(Jb,cc,Kb,Lb)};this.setScissor=function(a,b,c,d){g.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?g.enable(g.SCISSOR_TEST):g.disable(g.SCISSOR_TEST)};this.setClearColorHex=function(a,b){y.setHex(a);L=b;g.clearColor(y.r,y.g,y.b,L)};this.setClearColor=function(a,b){y.copy(a);L=b;g.clearColor(y.r,y.g,y.b,L)};this.getClearColor=function(){return y};this.getClearAlpha= +g.clearStencil(0);g.enable(g.DEPTH_TEST);g.depthFunc(g.LEQUAL);g.frontFace(g.CCW);g.cullFace(g.BACK);g.enable(g.CULL_FACE);g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.SRC_ALPHA,g.ONE_MINUS_SRC_ALPHA);g.clearColor(y.r,y.g,y.b,L);this.context=g;var dc=g.getParameter(g.MAX_VERTEX_TEXTURE_IMAGE_UNITS);g.getParameter(g.MAX_TEXTURE_SIZE);var Oc=g.getParameter(g.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return g};this.supportsVertexTextures=function(){return dc>0};this.setSize= +function(a,b){M.width=a;M.height=b;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(a,b,c,d){Jb=a;bc=b;Lb=c;Sb=d;g.viewport(Jb,bc,Lb,Sb)};this.setScissor=function(a,b,c,d){g.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?g.enable(g.SCISSOR_TEST):g.disable(g.SCISSOR_TEST)};this.setClearColorHex=function(a,b){y.setHex(a);L=b;g.clearColor(y.r,y.g,y.b,L)};this.setClearColor=function(a,b){y.copy(a);L=b;g.clearColor(y.r,y.g,y.b,L)};this.getClearColor=function(){return y};this.getClearAlpha= function(){return L};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d=d|g.COLOR_BUFFER_BIT;if(b===void 0||b)d=d|g.DEPTH_BUFFER_BIT;if(c===void 0||c)d=d|g.STENCIL_BUFFER_BIT;g.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit){a.__webglInit=false;delete a._modelViewMatrix; delete a._normalMatrix;delete a._normalMatrixArray;delete a._modelViewMatrixArray;delete a._objectMatrixArray;if(a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];g.deleteBuffer(c.__webglVertexBuffer);g.deleteBuffer(c.__webglNormalBuffer);g.deleteBuffer(c.__webglTangentBuffer);g.deleteBuffer(c.__webglColorBuffer);g.deleteBuffer(c.__webglUVBuffer);g.deleteBuffer(c.__webglUV2Buffer);g.deleteBuffer(c.__webglSkinVertexABuffer);g.deleteBuffer(c.__webglSkinVertexBBuffer); g.deleteBuffer(c.__webglSkinIndicesBuffer);g.deleteBuffer(c.__webglSkinWeightsBuffer);g.deleteBuffer(c.__webglFaceBuffer);g.deleteBuffer(c.__webglLineBuffer);var d=void 0,e=void 0;if(c.numMorphTargets){d=0;for(e=c.numMorphTargets;d1&&(b=true);d=0;for(c=f.length;d=0&&e.vertexNormalBuffer){h=e.vertexNormalBuffer.itemSize;g.bindBuffer(g.ARRAY_BUFFER,e.vertexNormalBuffer);g.vertexAttribPointer(a.normal, -h,g.FLOAT,false,0,f[d].index*h*4)}if(a.uv>=0&&e.vertexUvBuffer)if(e.vertexUvBuffer){h=e.vertexUvBuffer.itemSize;g.bindBuffer(g.ARRAY_BUFFER,e.vertexUvBuffer);g.vertexAttribPointer(a.uv,h,g.FLOAT,false,0,f[d].index*h*4);g.enableVertexAttribArray(a.uv)}else g.disableVertexAttribArray(a.uv);if(a.color>=0&&e.vertexColorBuffer){h=e.vertexColorBuffer.itemSize;g.bindBuffer(g.ARRAY_BUFFER,e.vertexColorBuffer);g.vertexAttribPointer(a.color,h,g.FLOAT,false,0,f[d].index*h*4)}g.bindBuffer(g.ELEMENT_ARRAY_BUFFER, -e.vertexIndexBuffer)}g.drawElements(g.TRIANGLES,f[d].count,g.UNSIGNED_SHORT,f[d].start*2);F.info.render.calls++;F.info.render.vertices=F.info.render.vertices+f[d].count;F.info.render.faces=F.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var h,i,c=r(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ca){ca=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){g.bindBuffer(g.ARRAY_BUFFER,e.__webglVertexBuffer);g.vertexAttribPointer(b.position, -3,g.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){g.bindBuffer(g.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]);g.vertexAttribPointer(c.position,3,g.FLOAT,false,0,0)}else if(c.position>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglVertexBuffer);g.vertexAttribPointer(c.position,3,g.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var j=0;i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;j0&&i.push([l,j])}if(i.length>d.numSupportedMorphTargets){i.sort(k);i.length=d.numSupportedMorphTargets}else i.length>d.numSupportedMorphNormals? -i.sort(k):i.length===0&&i.push([0,0]);for(j=0;j=0){g.bindBuffer(g.ARRAY_BUFFER,c.buffer);g.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,g.FLOAT,false,0,0)}}}if(b.color>=0){g.bindBuffer(g.ARRAY_BUFFER, -e.__webglColorBuffer);g.vertexAttribPointer(b.color,3,g.FLOAT,false,0,0)}if(b.normal>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglNormalBuffer);g.vertexAttribPointer(b.normal,3,g.FLOAT,false,0,0)}if(b.tangent>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglTangentBuffer);g.vertexAttribPointer(b.tangent,4,g.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){g.bindBuffer(g.ARRAY_BUFFER,e.__webglUVBuffer);g.vertexAttribPointer(b.uv,2,g.FLOAT,false,0,0);g.enableVertexAttribArray(b.uv)}else g.disableVertexAttribArray(b.uv); -if(b.uv2>=0)if(e.__webglUV2Buffer){g.bindBuffer(g.ARRAY_BUFFER,e.__webglUV2Buffer);g.vertexAttribPointer(b.uv2,2,g.FLOAT,false,0,0);g.enableVertexAttribArray(b.uv2)}else g.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinVertexABuffer);g.vertexAttribPointer(b.skinVertexA,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);g.vertexAttribPointer(b.skinVertexB,4,g.FLOAT, -false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);g.vertexAttribPointer(b.skinIndex,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);g.vertexAttribPointer(b.skinWeight,4,g.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==Ib){g.lineWidth(d);Ib=d}a&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);g.drawElements(g.LINES,e.__webglLineCount,g.UNSIGNED_SHORT,0)}else{a&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer); -g.drawElements(g.TRIANGLES,e.__webglFaceCount,g.UNSIGNED_SHORT,0)}F.info.render.calls++;F.info.render.vertices=F.info.render.vertices+e.__webglFaceCount;F.info.render.faces=F.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?g.LINE_STRIP:g.LINES;d=d.linewidth;if(d!==Ib){g.lineWidth(d);Ib=d}g.drawArrays(f,0,e.__webglLineCount);F.info.render.calls++}else if(f instanceof THREE.ParticleSystem){g.drawArrays(g.POINTS,0,e.__webglParticleCount);F.info.render.calls++; -F.info.render.points=F.info.render.points+e.__webglParticleCount}else if(f instanceof THREE.Ribbon){g.drawArrays(g.TRIANGLE_STRIP,0,e.__webglVertexCount);F.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,j,k,o=a.__lights,n=a.fog;na=-1;pb=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray= -new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Sb.multiply(b.projectionMatrix,b.matrixWorldInverse);dc.setFromMatrix(Sb);this.autoUpdateObjects&&this.initWebGLObjects(a);m(this.renderPluginsPre,a,b);F.info.render.calls=0;F.info.render.vertices=0;F.info.render.faces=0;F.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor, -this.autoClearDepth,this.autoClearStencil);k=a.__webglObjects;d=0;for(e=k.length;d=0){s=r.geometry.materials[s];if(s.transparent){p.transparent=s;p.opaque=null}else{p.opaque=s;p.transparent=null}}}else if(s)if(s.transparent){p.transparent= -s;p.opaque=null}else{p.opaque=s;p.transparent=null}f.render=true;if(this.sortObjects)if(j.renderDepth)f.z=j.renderDepth;else{Pa.copy(j.matrixWorld.getPosition());Sb.multiplyVector3(Pa);f.z=Pa.z}}}this.sortObjects&&k.sort(h);k=a.__webglObjectsImmediate;d=0;for(e=k.length;d65535){E[A].counter=E[A].counter+1;B=E[A].hash+"_"+E[A].counter;q.geometryGroups[B]===void 0&&(q.geometryGroups[B]={faces3:[],faces4:[],materialIndex:y,vertices:0,numMorphTargets:I,numMorphNormals:J})}s instanceof THREE.Face3?q.geometryGroups[B].faces3.push(r):q.geometryGroups[B].faces4.push(r);q.geometryGroups[B].vertices=q.geometryGroups[B].vertices+D}q.geometryGroupsList=[];var L=void 0;for(L in q.geometryGroups){q.geometryGroups[L].id= -oa++;q.geometryGroupsList.push(q.geometryGroups[L])}}for(k in l.geometryGroups){m=l.geometryGroups[k];if(!m.__webglVertexBuffer){var H=m;H.__webglVertexBuffer=g.createBuffer();H.__webglNormalBuffer=g.createBuffer();H.__webglTangentBuffer=g.createBuffer();H.__webglColorBuffer=g.createBuffer();H.__webglUVBuffer=g.createBuffer();H.__webglUV2Buffer=g.createBuffer();H.__webglSkinVertexABuffer=g.createBuffer();H.__webglSkinVertexBBuffer=g.createBuffer();H.__webglSkinIndicesBuffer=g.createBuffer();H.__webglSkinWeightsBuffer= -g.createBuffer();H.__webglFaceBuffer=g.createBuffer();H.__webglLineBuffer=g.createBuffer();var M=void 0,Q=void 0;if(H.numMorphTargets){H.__webglMorphTargetsBuffers=[];M=0;for(Q=H.numMorphTargets;M0||R.faceVertexUvs.length>0)G.__uvArray=new Float32Array(X*2);if(R.faceUvs.length>1||R.faceVertexUvs.length>1)G.__uv2Array=new Float32Array(X*2)}if(S.geometry.skinWeights.length&&S.geometry.skinIndices.length){G.__skinVertexAArray= -new Float32Array(X*4);G.__skinVertexBArray=new Float32Array(X*4);G.__skinIndexArray=new Float32Array(X*4);G.__skinWeightArray=new Float32Array(X*4)}G.__faceArray=new Uint16Array(ca*3);G.__lineArray=new Uint16Array(na*2);var Ba=void 0,Ea=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=[];Ba=0;for(Ea=G.numMorphTargets;Ba0){g.bindBuffer(g.ARRAY_BUFFER,W.__webglSkinVertexABuffer);g.bufferData(g.ARRAY_BUFFER,ia,La);g.bindBuffer(g.ARRAY_BUFFER,W.__webglSkinVertexBBuffer);g.bufferData(g.ARRAY_BUFFER,ja,La);g.bindBuffer(g.ARRAY_BUFFER, -W.__webglSkinIndicesBuffer);g.bufferData(g.ARRAY_BUFFER,ka,La);g.bindBuffer(g.ARRAY_BUFFER,W.__webglSkinWeightsBuffer);g.bufferData(g.ARRAY_BUFFER,la,La)}}if(fd&&Oc){x=0;for(K=aa.length;x0){g.bindBuffer(g.ARRAY_BUFFER,W.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,ya,La)}}if(ed&&Ga.hasTangents){x=0;for(K=aa.length;x0){g.bindBuffer(g.ARRAY_BUFFER,W.__webglUVBuffer);g.bufferData(g.ARRAY_BUFFER,nc,La)}}if(Xc&& -Tc&&bc){x=0;for(K=aa.length;x0){g.bindBuffer(g.ARRAY_BUFFER,W.__webglUV2Buffer);g.bufferData(g.ARRAY_BUFFER,oc,La)}}if(Mc){x=0;for(K=aa.length;x0?"#define VERTEX_TEXTURES":"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights, -"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled? -"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); +r(a,b,c,d,f);a=c.attributes;b=false;d=e.id*16777215+c.id*2+(d.wireframe?1:0);if(d!==ca){ca=d;b=true}if(f instanceof THREE.Mesh){f=e.offsets;f.length>1&&(b=true);d=0;for(c=f.length;d=0&&i){j=i.itemSize;g.bindBuffer(g.ARRAY_BUFFER,i.buffer);g.vertexAttribPointer(a.normal,j,g.FLOAT,false,0,h*j*4)}i=e.attributes.uv; +if(a.uv>=0&&i)if(i.buffer){j=i.itemSize;g.bindBuffer(g.ARRAY_BUFFER,i.buffer);g.vertexAttribPointer(a.uv,j,g.FLOAT,false,0,h*j*4);g.enableVertexAttribArray(a.uv)}else g.disableVertexAttribArray(a.uv);i=e.attributes.color;if(a.color>=0&&i){j=i.itemSize;g.bindBuffer(g.ARRAY_BUFFER,i.buffer);g.vertexAttribPointer(a.color,j,g.FLOAT,false,0,h*j*4)}g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.attributes.index.buffer)}g.drawElements(g.TRIANGLES,f[d].count,g.UNSIGNED_SHORT,f[d].start*2);F.info.render.calls++;F.info.render.vertices= +F.info.render.vertices+f[d].count;F.info.render.faces=F.info.render.faces+f[d].count/3}}}};this.renderBuffer=function(a,b,c,d,e,f){if(d.visible!==false){var h,i,c=r(a,b,c,d,f),b=c.attributes,a=false,c=e.id*16777215+c.id*2+(d.wireframe?1:0);if(c!==ca){ca=c;a=true}if(!d.morphTargets&&b.position>=0){if(a){g.bindBuffer(g.ARRAY_BUFFER,e.__webglVertexBuffer);g.vertexAttribPointer(b.position,3,g.FLOAT,false,0,0)}}else if(f.morphTargetBase){c=d.program.attributes;if(f.morphTargetBase!==-1){g.bindBuffer(g.ARRAY_BUFFER, +e.__webglMorphTargetsBuffers[f.morphTargetBase]);g.vertexAttribPointer(c.position,3,g.FLOAT,false,0,0)}else if(c.position>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglVertexBuffer);g.vertexAttribPointer(c.position,3,g.FLOAT,false,0,0)}if(f.morphTargetForcedOrder.length){var k=0;i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;k0&&i.push([l,k])}if(i.length>d.numSupportedMorphTargets){i.sort(j);i.length=d.numSupportedMorphTargets}else i.length>d.numSupportedMorphNormals?i.sort(j):i.length===0&&i.push([0,0]);for(k=0;k=0){g.bindBuffer(g.ARRAY_BUFFER,c.buffer);g.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,g.FLOAT,false,0,0)}}}if(b.color>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglColorBuffer);g.vertexAttribPointer(b.color,3,g.FLOAT,false,0,0)}if(b.normal>= +0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglNormalBuffer);g.vertexAttribPointer(b.normal,3,g.FLOAT,false,0,0)}if(b.tangent>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglTangentBuffer);g.vertexAttribPointer(b.tangent,4,g.FLOAT,false,0,0)}if(b.uv>=0)if(e.__webglUVBuffer){g.bindBuffer(g.ARRAY_BUFFER,e.__webglUVBuffer);g.vertexAttribPointer(b.uv,2,g.FLOAT,false,0,0);g.enableVertexAttribArray(b.uv)}else g.disableVertexAttribArray(b.uv);if(b.uv2>=0)if(e.__webglUV2Buffer){g.bindBuffer(g.ARRAY_BUFFER,e.__webglUV2Buffer); +g.vertexAttribPointer(b.uv2,2,g.FLOAT,false,0,0);g.enableVertexAttribArray(b.uv2)}else g.disableVertexAttribArray(b.uv2);if(d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0){g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinVertexABuffer);g.vertexAttribPointer(b.skinVertexA,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinVertexBBuffer);g.vertexAttribPointer(b.skinVertexB,4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinIndicesBuffer);g.vertexAttribPointer(b.skinIndex, +4,g.FLOAT,false,0,0);g.bindBuffer(g.ARRAY_BUFFER,e.__webglSkinWeightsBuffer);g.vertexAttribPointer(b.skinWeight,4,g.FLOAT,false,0,0)}}if(f instanceof THREE.Mesh){if(d.wireframe){d=d.wireframeLinewidth;if(d!==ub){g.lineWidth(d);ub=d}a&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer);g.drawElements(g.LINES,e.__webglLineCount,g.UNSIGNED_SHORT,0)}else{a&&g.bindBuffer(g.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer);g.drawElements(g.TRIANGLES,e.__webglFaceCount,g.UNSIGNED_SHORT,0)}F.info.render.calls++; +F.info.render.vertices=F.info.render.vertices+e.__webglFaceCount;F.info.render.faces=F.info.render.faces+e.__webglFaceCount/3}else if(f instanceof THREE.Line){f=f.type===THREE.LineStrip?g.LINE_STRIP:g.LINES;d=d.linewidth;if(d!==ub){g.lineWidth(d);ub=d}g.drawArrays(f,0,e.__webglLineCount);F.info.render.calls++}else if(f instanceof THREE.ParticleSystem){g.drawArrays(g.POINTS,0,e.__webglParticleCount);F.info.render.calls++;F.info.render.points=F.info.render.points+e.__webglParticleCount}else if(f instanceof +THREE.Ribbon){g.drawArrays(g.TRIANGLE_STRIP,0,e.__webglVertexCount);F.info.render.calls++}}};this.render=function(a,b,c,d){var e,f,j,k,o=a.__lights,n=a.fog;na=-1;ob=true;if(b.parent===void 0){console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it...");a.add(b)}this.autoUpdateScene&&a.updateMatrixWorld();if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.matrixWorldInverse.getInverse(b.matrixWorld); +b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Kb.multiply(b.projectionMatrix,b.matrixWorldInverse);cc.setFromMatrix(Kb);this.autoUpdateObjects&&this.initWebGLObjects(a);m(this.renderPluginsPre,a,b);F.info.render.calls=0;F.info.render.vertices=0;F.info.render.faces=0;F.info.render.points=0;this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);k=a.__webglObjects;d=0; +for(e=k.length;d=0){s=r.geometry.materials[s];if(s.transparent){p.transparent=s;p.opaque=null}else{p.opaque=s;p.transparent=null}}}else if(s)if(s.transparent){p.transparent=s;p.opaque=null}else{p.opaque=s;p.transparent= +null}f.render=true;if(this.sortObjects)if(j.renderDepth)f.z=j.renderDepth;else{Oa.copy(j.matrixWorld.getPosition());Kb.multiplyVector3(Oa);f.z=Oa.z}}}this.sortObjects&&k.sort(h);k=a.__webglObjectsImmediate;d=0;for(e=k.length;d65535){E[A].counter= +E[A].counter+1;B=E[A].hash+"_"+E[A].counter;q.geometryGroups[B]===void 0&&(q.geometryGroups[B]={faces3:[],faces4:[],materialIndex:y,vertices:0,numMorphTargets:I,numMorphNormals:J})}s instanceof THREE.Face3?q.geometryGroups[B].faces3.push(r):q.geometryGroups[B].faces4.push(r);q.geometryGroups[B].vertices=q.geometryGroups[B].vertices+D}q.geometryGroupsList=[];var L=void 0;for(L in q.geometryGroups){q.geometryGroups[L].id=oa++;q.geometryGroupsList.push(q.geometryGroups[L])}}for(j in l.geometryGroups){m= +l.geometryGroups[j];if(!m.__webglVertexBuffer){var H=m;H.__webglVertexBuffer=g.createBuffer();H.__webglNormalBuffer=g.createBuffer();H.__webglTangentBuffer=g.createBuffer();H.__webglColorBuffer=g.createBuffer();H.__webglUVBuffer=g.createBuffer();H.__webglUV2Buffer=g.createBuffer();H.__webglSkinVertexABuffer=g.createBuffer();H.__webglSkinVertexBBuffer=g.createBuffer();H.__webglSkinIndicesBuffer=g.createBuffer();H.__webglSkinWeightsBuffer=g.createBuffer();H.__webglFaceBuffer=g.createBuffer();H.__webglLineBuffer= +g.createBuffer();var M=void 0,Q=void 0;if(H.numMorphTargets){H.__webglMorphTargetsBuffers=[];M=0;for(Q=H.numMorphTargets;M0||R.faceVertexUvs.length>0)G.__uvArray=new Float32Array(X*2);if(R.faceUvs.length>1||R.faceVertexUvs.length>1)G.__uv2Array=new Float32Array(X*2)}if(S.geometry.skinWeights.length&&S.geometry.skinIndices.length){G.__skinVertexAArray=new Float32Array(X*4);G.__skinVertexBArray= +new Float32Array(X*4);G.__skinIndexArray=new Float32Array(X*4);G.__skinWeightArray=new Float32Array(X*4)}G.__faceArray=new Uint16Array(ca*3);G.__lineArray=new Uint16Array(na*2);var Aa=void 0,Da=void 0;if(G.numMorphTargets){G.__morphTargetsArrays=[];Aa=0;for(Da=G.numMorphTargets;Aa0){g.bindBuffer(g.ARRAY_BUFFER,W.__webglSkinVertexABuffer);g.bufferData(g.ARRAY_BUFFER,ia,Ka);g.bindBuffer(g.ARRAY_BUFFER,W.__webglSkinVertexBBuffer); +g.bufferData(g.ARRAY_BUFFER,ja,Ka);g.bindBuffer(g.ARRAY_BUFFER,W.__webglSkinIndicesBuffer);g.bufferData(g.ARRAY_BUFFER,ka,Ka);g.bindBuffer(g.ARRAY_BUFFER,W.__webglSkinWeightsBuffer);g.bufferData(g.ARRAY_BUFFER,la,Ka)}}if(qd&&Xc){x=0;for(K=aa.length;x0){g.bindBuffer(g.ARRAY_BUFFER,W.__webglColorBuffer);g.bufferData(g.ARRAY_BUFFER,xa,Ka)}}if(pd&&Fa.hasTangents){x=0;for(K=aa.length;x< +K;x++){C=ra[aa[x]];pb=C.vertexTangents;Ya=pb[0];Za=pb[1];$a=pb[2];ha[fa]=Ya.x;ha[fa+1]=Ya.y;ha[fa+2]=Ya.z;ha[fa+3]=Ya.w;ha[fa+4]=Za.x;ha[fa+5]=Za.y;ha[fa+6]=Za.z;ha[fa+7]=Za.w;ha[fa+8]=$a.x;ha[fa+9]=$a.y;ha[fa+10]=$a.z;ha[fa+11]=$a.w;fa=fa+12}x=0;for(K=ba.length;x0){g.bindBuffer(g.ARRAY_BUFFER,W.__webglUVBuffer);g.bufferData(g.ARRAY_BUFFER,nc,Ka)}}if(hd&&bd&&ed){x=0;for(K=aa.length;x0){g.bindBuffer(g.ARRAY_BUFFER,W.__webglUV2Buffer);g.bufferData(g.ARRAY_BUFFER,oc,Ka)}}if(Oc){x=0;for(K=aa.length;x0?"#define VERTEX_TEXTURES":"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading? +"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel? +"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); k=["precision "+E+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SPOT_LIGHTS "+c.maxSpotLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",F.gammaInput?"#define GAMMA_INPUT":"",F.gammaOutput?"#define GAMMA_OUTPUT":"",F.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP": "",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.doubleSided?"#define DOUBLE_SIDED":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n"); j=B("fragment",k+j);d=B("vertex",d+o);g.attachShader(r,d);g.attachShader(r,j);g.linkProgram(r);g.getProgramParameter(r,g.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+g.getProgramParameter(r,g.VALIDATE_STATUS)+", gl error ["+g.getError()+"]");g.deleteShader(j);g.deleteShader(d);r.uniforms={};r.attributes={};var s,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","boneGlobalMatrices","morphTargetInfluences"];for(s in i)d.push(s); s=d;d=0;for(i=s.length;d=0&&g.enableVertexAttribArray(p.position);p.color>=0&&g.enableVertexAttribArray(p.color);p.normal>=0&&g.enableVertexAttribArray(p.normal);p.tangent>=0&&g.enableVertexAttribArray(p.tangent);if(a.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0){g.enableVertexAttribArray(p.skinVertexA);g.enableVertexAttribArray(p.skinVertexB);g.enableVertexAttribArray(p.skinIndex);g.enableVertexAttribArray(p.skinWeight)}if(a.attributes)for(f in a.attributes)p[f]!==void 0&&p[f]>= 0&&g.enableVertexAttribArray(p[f]);if(a.morphTargets){a.numSupportedMorphTargets=0;b="morphTarget";for(f=0;f=0){g.enableVertexAttribArray(p[s]);a.numSupportedMorphTargets++}}}if(a.morphNormals){a.numSupportedMorphNormals=0;b="morphNormal";for(f=0;f=0){g.enableVertexAttribArray(p[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"?g.frontFace(g.CCW):g.frontFace(g.CW);a==="back"?g.cullFace(g.BACK):a==="front"?g.cullFace(g.FRONT):g.cullFace(g.FRONT_AND_BACK);g.enable(g.CULL_FACE)}else g.disable(g.CULL_FACE)};this.setObjectFaces=function(a){if(Da!==a.doubleSided){a.doubleSided?g.disable(g.CULL_FACE):g.enable(g.CULL_FACE);Da=a.doubleSided}if(Ka!==a.flipSided){a.flipSided?g.frontFace(g.CW):g.frontFace(g.CCW);Ka=a.flipSided}};this.setDepthTest=function(a){if(Ya!==a){a?g.enable(g.DEPTH_TEST):g.disable(g.DEPTH_TEST); -Ya=a}};this.setDepthWrite=function(a){if(ob!==a){g.depthMask(a);ob=a}};this.setBlending=function(a,b,c,d){if(a!==Ba){if(a===THREE.NoBlending)g.disable(g.BLEND);else if(a===THREE.AdditiveBlending){g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.SRC_ALPHA,g.ONE)}else if(a===THREE.SubtractiveBlending){g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.ZERO,g.ONE_MINUS_SRC_COLOR)}else if(a===THREE.MultiplyBlending){g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.ZERO, -g.SRC_COLOR)}else if(a===THREE.CustomBlending)g.enable(g.BLEND);else{g.enable(g.BLEND);g.blendEquationSeparate(g.FUNC_ADD,g.FUNC_ADD);g.blendFuncSeparate(g.SRC_ALPHA,g.ONE_MINUS_SRC_ALPHA,g.ONE,g.ONE_MINUS_SRC_ALPHA)}Ba=a}if(a===THREE.CustomBlending){if(b!==Ta){g.blendEquation(A(b));Ta=b}if(c!==Va||d!==Ea){g.blendFunc(A(c),A(d));Va=c;Ea=d}}else Ea=Va=Ta=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=g.createTexture();F.info.memory.textures++}g.activeTexture(g.TEXTURE0+ +b){if(a){!b||b==="ccw"?g.frontFace(g.CCW):g.frontFace(g.CW);a==="back"?g.cullFace(g.BACK):a==="front"?g.cullFace(g.FRONT):g.cullFace(g.FRONT_AND_BACK);g.enable(g.CULL_FACE)}else g.disable(g.CULL_FACE)};this.setObjectFaces=function(a){if(Ca!==a.doubleSided){a.doubleSided?g.disable(g.CULL_FACE):g.enable(g.CULL_FACE);Ca=a.doubleSided}if(Ja!==a.flipSided){a.flipSided?g.frontFace(g.CW):g.frontFace(g.CCW);Ja=a.flipSided}};this.setDepthTest=function(a){if(nb!==a){a?g.enable(g.DEPTH_TEST):g.disable(g.DEPTH_TEST); +nb=a}};this.setDepthWrite=function(a){if(Xa!==a){g.depthMask(a);Xa=a}};this.setBlending=function(a,b,c,d){if(a!==Aa){if(a===THREE.NoBlending)g.disable(g.BLEND);else if(a===THREE.AdditiveBlending){g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.SRC_ALPHA,g.ONE)}else if(a===THREE.SubtractiveBlending){g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.ZERO,g.ONE_MINUS_SRC_COLOR)}else if(a===THREE.MultiplyBlending){g.enable(g.BLEND);g.blendEquation(g.FUNC_ADD);g.blendFunc(g.ZERO, +g.SRC_COLOR)}else if(a===THREE.CustomBlending)g.enable(g.BLEND);else{g.enable(g.BLEND);g.blendEquationSeparate(g.FUNC_ADD,g.FUNC_ADD);g.blendFuncSeparate(g.SRC_ALPHA,g.ONE_MINUS_SRC_ALPHA,g.ONE,g.ONE_MINUS_SRC_ALPHA)}Aa=a}if(a===THREE.CustomBlending){if(b!==Sa){g.blendEquation(A(b));Sa=b}if(c!==Ua||d!==Da){g.blendFunc(A(c),A(d));Ua=c;Da=d}}else Da=Ua=Sa=null};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit){a.__webglInit=true;a.__webglTexture=g.createTexture();F.info.memory.textures++}g.activeTexture(g.TEXTURE0+ b);g.bindTexture(g.TEXTURE_2D,a.__webglTexture);g.pixelStorei(g.UNPACK_FLIP_Y_WEBGL,a.flipY);g.pixelStorei(g.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);var c=a.image,d=(c.width&c.width-1)===0&&(c.height&c.height-1)===0,e=A(a.format),f=A(a.type);D(g.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?g.texImage2D(g.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):g.texImage2D(g.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&g.generateMipmap(g.TEXTURE_2D);a.needsUpdate=false;if(a.onUpdate)a.onUpdate()}else{g.activeTexture(g.TEXTURE0+ b);g.bindTexture(g.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=g.createTexture();var c=(a.width&a.width-1)===0&&(a.height&a.height-1)===0,d=A(a.format),e=A(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];g.bindTexture(g.TEXTURE_CUBE_MAP,a.__webglTexture);D(g.TEXTURE_CUBE_MAP,a,c); for(var f=0;f<6;f++){a.__webglFramebuffer[f]=g.createFramebuffer();a.__webglRenderbuffer[f]=g.createRenderbuffer();g.texImage2D(g.TEXTURE_CUBE_MAP_POSITIVE_X+f,0,d,a.width,a.height,0,d,e,null);var h=a,i=g.TEXTURE_CUBE_MAP_POSITIVE_X+f;g.bindFramebuffer(g.FRAMEBUFFER,a.__webglFramebuffer[f]);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,i,h.__webglTexture,0);s(a.__webglRenderbuffer[f],a)}c&&g.generateMipmap(g.TEXTURE_CUBE_MAP)}else{a.__webglFramebuffer=g.createFramebuffer();a.__webglRenderbuffer= g.createRenderbuffer();g.bindTexture(g.TEXTURE_2D,a.__webglTexture);D(g.TEXTURE_2D,a,c);g.texImage2D(g.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null);d=g.TEXTURE_2D;g.bindFramebuffer(g.FRAMEBUFFER,a.__webglFramebuffer);g.framebufferTexture2D(g.FRAMEBUFFER,g.COLOR_ATTACHMENT0,d,a.__webglTexture,0);s(a.__webglRenderbuffer,a);c&&g.generateMipmap(g.TEXTURE_2D)}b?g.bindTexture(g.TEXTURE_CUBE_MAP,null):g.bindTexture(g.TEXTURE_2D,null);g.bindRenderbuffer(g.RENDERBUFFER,null);g.bindFramebuffer(g.FRAMEBUFFER, -null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer;c=a.width;a=a.height;e=d=0}else{b=null;c=Kb;a=Lb;d=Jb;e=cc}if(b!==H){g.bindFramebuffer(g.FRAMEBUFFER,b);g.viewport(d,e,c,a);H=b}wc=c;ac=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; +null)}if(a){b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer;c=a.width;a=a.height;e=d=0}else{b=null;c=Lb;a=Sb;d=Jb;e=bc}if(b!==H){g.bindFramebuffer(g.FRAMEBUFFER,b);g.viewport(d,e,c,a);H=b}vc=c;wc=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)}; THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==void 0?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==void 0?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==void 0?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==void 0?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=c.format!==void 0?c.format:THREE.RGBAFormat;this.type=c.type!==void 0?c.type: THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==void 0?c.depthBuffer:true;this.stencilBuffer=c.stencilBuffer!==void 0?c.stencilBuffer:true;this.generateMipmaps=true}; THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0}; THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype);THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=true};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)}; THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null}; THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null}; -THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null}; -THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.vertexColorArray=this.vertexUvArray=this.vertexNormalArray=this.vertexPositionArray=this.vertexIndexArray=this.vertexColorBuffer=this.vertexUvBuffer=this.vertexNormalBuffer=this.vertexPositionBuffer=this.vertexIndexBuffer=null;this.dynamic=false;this.boundingSphere=this.boundingBox=null;this.morphTargets=[]}; -THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,applyMatrix:function(a){if(this.vertexPositionArray!==void 0){a.multiplyVector3Array(this.vertexPositionArray);this.verticesNeedUpdate=true}if(this.vertexNormalArray!==void 0){var b=new THREE.Matrix4;b.extractRotation(a);b.multiplyVector3Array(this.vertexNormalArray);this.normalsNeedUpdate=true}},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3(Infinity,Infinity,Infinity),max:new THREE.Vector3(-Infinity, --Infinity,-Infinity)};var a=this.vertexPositionArray;if(a)for(var b=this.boundingBox,c,d,f,e=0,h=a.length;eb.max.x)b.max.x=c;if(db.max.y)b.max.y=d;if(fb.max.z)b.max.z=f}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};var a=this.vertexPositionArray; -if(a){for(var b,c=0,d,f,e=0,h=a.length;ec&&(c=b)}this.boundingSphere.radius=c}},computeVertexNormals:function(){var a=this.vertexIndexArray,b=this.vertexPositionArray;if(b&&a){var c,d,f,e;c=b.length;if(this.vertexNormalArray===void 0)this.vertexNormalArray=new Float32Array(c);else{c=0;for(d=this.vertexNormalArray.length;cb.max.x)b.max.x=c;if(db.max.y)b.max.y=d;if(fb.max.z)b.max.z=f}if(a===void 0||a.length===0){this.boundingBox.min.set(0,0,0);this.boundingBox.max.set(0,0,0)}},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere= +{radius:0};var a=this.attributes.position.array;if(a){for(var b,c=0,d,f,e=0,h=a.length;ec&&(c=b)}this.boundingSphere.radius=c}},computeVertexNormals:function(){if(this.attributes.position&&this.attributes.index){var a,b,c,d;a=this.attributes.position.array.length;if(this.attributes.normal===void 0)this.attributes.normal={itemSize:3,array:new Float32Array(a),numItems:a*3};else{a=0;for(b=this.attributes.normal.array.length;a0&&Q.x0&& -Q.y0.0010&&L.scale>0.0010){E.x=L.x;E.y=L.y;E.z=L.z;A=L.size*L.scale/q;M.x=A*D;M.y=A;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); +Q.y0.0010&&L.scale>0.0010){E.x=L.x;E.y=L.y;E.z=L.z;A=L.size*L.scale/q;M.x=A*D;M.y=A;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,k=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,l){var i,o,j,v,p,n,r,q,u,B=[];v=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;ik.x)k.x=q.x;if(q.yk.y)k.y=q.y;if(q.zk.z)k.z=q.z}v.left=h.x;v.right=k.x;v.top=k.y;v.bottom=h.y;v.updateProjectionMatrix()}v=j.shadowMap;n=j.shadowMatrix;p=j.shadowCamera;p.position.copy(j.matrixWorld.getPosition());p.lookAt(j.target.matrixWorld.getPosition());p.updateMatrixWorld();p.matrixWorldInverse.getInverse(p.matrixWorld); -if(j.cameraHelper)j.cameraHelper.lines.visible=j.shadowCameraVisible;j.shadowCameraVisible&&j.cameraHelper.update();n.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);n.multiplySelf(p.projectionMatrix);n.multiplySelf(p.matrixWorldInverse);if(!p._viewMatrixArray)p._viewMatrixArray=new Float32Array(16);if(!p._projectionMatrixArray)p._projectionMatrixArray=new Float32Array(16);p.matrixWorldInverse.flattenToArray(p._viewMatrixArray);p.projectionMatrix.flattenToArray(p._projectionMatrixArray);e.multiply(p.projectionMatrix, -p.matrixWorldInverse);f.setFromMatrix(e);b.setRenderTarget(v);b.clear();u=m.__webglObjects;j=0;for(v=u.length;jj.x)j.x=q.x;if(q.yj.y)j.y=q.y;if(q.zj.z)j.z=q.z}v.left=h.x;v.right=j.x;v.top=j.y;v.bottom=h.y;v.updateProjectionMatrix()}v=k.shadowMap;n=k.shadowMatrix;p=k.shadowCamera;p.position.copy(k.matrixWorld.getPosition());p.lookAt(k.target.matrixWorld.getPosition());p.updateMatrixWorld();p.matrixWorldInverse.getInverse(p.matrixWorld); +if(k.cameraHelper)k.cameraHelper.lines.visible=k.shadowCameraVisible;k.shadowCameraVisible&&k.cameraHelper.update();n.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);n.multiplySelf(p.projectionMatrix);n.multiplySelf(p.matrixWorldInverse);if(!p._viewMatrixArray)p._viewMatrixArray=new Float32Array(16);if(!p._projectionMatrixArray)p._projectionMatrixArray=new Float32Array(16);p.matrixWorldInverse.flattenToArray(p._viewMatrixArray);p.projectionMatrix.flattenToArray(p._projectionMatrixArray);e.multiply(p.projectionMatrix, +p.matrixWorldInverse);f.setFromMatrix(e);b.setRenderTarget(v);b.clear();u=m.__webglObjects;k=0;for(v=u.length;k maxRadius ) maxRadius = radius; @@ -156,34 +157,40 @@ THREE.BufferGeometry.prototype = { computeVertexNormals: function () { - var indices = this.vertexIndexArray; - var vertices = this.vertexPositionArray; - - if ( vertices && indices ) { + if ( this.attributes[ "position" ] && this.attributes[ "index" ] ) { var i, il; var j, jl; - var nElements = vertices.length; + var nVertices = this.attributes[ "position" ].array.length; + + if ( this.attributes[ "normal" ] === undefined ) { - if ( this.vertexNormalArray === undefined ) { + this.attributes[ "normal" ] = { - this.vertexNormalArray = new Float32Array( nElements ); + itemSize: 3, + array: new Float32Array( nVertices ), + numItems: nVertices * 3 + + }; } else { // reset existing normals to zero - for ( i = 0, il = this.vertexNormalArray.length; i < il; i ++ ) { + for ( i = 0, il = this.attributes[ "normal" ].array.length; i < il; i ++ ) { - this.vertexNormalArray[ i ] = 0; + this.attributes[ "normal" ].array[ i ] = 0; } } var offsets = this.offsets; - var normals = this.vertexNormalArray; + + var indices = this.attributes[ "index" ].array; + var positions = this.attributes[ "position" ].array; + var normals = this.attributes[ "normal" ].array; var vA, vB, vC, x, y, z, @@ -206,19 +213,19 @@ THREE.BufferGeometry.prototype = { vB = index + indices[ i + 1 ]; vC = index + indices[ i + 2 ]; - x = vertices[ vA * 3 ]; - y = vertices[ vA * 3 + 1 ]; - z = vertices[ vA * 3 + 2 ]; + x = positions[ vA * 3 ]; + y = positions[ vA * 3 + 1 ]; + z = positions[ vA * 3 + 2 ]; pA.set( x, y, z ); - x = vertices[ vB * 3 ]; - y = vertices[ vB * 3 + 1 ]; - z = vertices[ vB * 3 + 2 ]; + x = positions[ vB * 3 ]; + y = positions[ vB * 3 + 1 ]; + z = positions[ vB * 3 + 2 ]; pB.set( x, y, z ); - x = vertices[ vC * 3 ]; - y = vertices[ vC * 3 + 1 ]; - z = vertices[ vC * 3 + 2 ]; + x = positions[ vC * 3 ]; + y = positions[ vC * 3 + 1 ]; + z = positions[ vC * 3 + 2 ]; pC.set( x, y, z ); cb.sub( pC, pB ); diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 070dcba570..63b4ca6329 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -923,6 +923,35 @@ THREE.WebGLRenderer = function ( parameters ) { }; + // + + function initDirectBuffers( geometry ) { + + var a, attribute, type; + + for ( a in geometry.attributes ) { + + if ( a === "index" ) { + + type = _gl.ELEMENT_ARRAY_BUFFER; + + } else { + + type = _gl.ARRAY_BUFFER; + + } + + attribute = geometry.attributes[ a ]; + + attribute.buffer = _gl.createBuffer(); + + _gl.bindBuffer( type, attribute.buffer ); + _gl.bufferData( type, attribute.array, _gl.STATIC_DRAW ); + + } + + }; + // Buffer setting function setParticleBuffers ( geometry, hint, object ) { @@ -2880,49 +2909,57 @@ THREE.WebGLRenderer = function ( parameters ) { function setDirectBuffers ( geometry, hint, dispose ) { - if ( geometry.elementsNeedUpdate && geometry.vertexIndexArray !== undefined ) { + var attributes = geometry.attributes; - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometry.vertexIndexBuffer ); - _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, geometry.vertexIndexArray, hint ); + var index = attributes[ "index" ]; + var position = attributes[ "position" ]; + var normal = attributes[ "normal" ]; + var uv = attributes[ "uv" ]; + var color = attributes[ "color" ]; + + if ( geometry.elementsNeedUpdate && index !== undefined ) { + + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, index.buffer ); + _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, index.array, hint ); } - if ( geometry.verticesNeedUpdate && geometry.vertexPositionArray !== undefined ) { + if ( geometry.verticesNeedUpdate && position !== undefined ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.vertexPositionBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, geometry.vertexPositionArray, hint ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, position.buffer ); + _gl.bufferData( _gl.ARRAY_BUFFER, position.array, hint ); } - if ( geometry.normalsNeedUpdate && geometry.vertexNormalArray !== undefined ) { + if ( geometry.normalsNeedUpdate && normal !== undefined ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.vertexNormalBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, geometry.vertexNormalArray, hint ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, normal.buffer ); + _gl.bufferData( _gl.ARRAY_BUFFER, normal.array, hint ); } - if ( geometry.uvsNeedUpdate && geometry.vertexUvArray !== undefined ) { + if ( geometry.uvsNeedUpdate && uv !== undefined ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.vertexUvBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, geometry.vertexUvArray, hint ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, uv.buffer ); + _gl.bufferData( _gl.ARRAY_BUFFER, uv.array, hint ); } - if ( geometry.colorsNeedUpdate && geometry.vertexColorArray !== undefined ) { + if ( geometry.colorsNeedUpdate && color !== undefined ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometry.vertexColorBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, geometry.vertexColorArray, hint ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, color.buffer ); + _gl.bufferData( _gl.ARRAY_BUFFER, color.array, hint ); } if ( dispose ) { - delete geometry.vertexIndexArray; - delete geometry.vertexPositionArray; - delete geometry.vertexNormalArray; - delete geometry.vertexUvArray; - delete geometry.vertexColorArray; + for ( var i in geometry.attributes ) { + + delete geometry.attributes[ i ].array; + + } } @@ -3023,7 +3060,7 @@ THREE.WebGLRenderer = function ( parameters ) { }; - this.renderBufferDirect = function ( camera, lights, fog, material, geometryGroup, object ) { + this.renderBufferDirect = function ( camera, lights, fog, material, geometry, object ) { if ( material.visible === false ) return; @@ -3035,11 +3072,11 @@ THREE.WebGLRenderer = function ( parameters ) { var updateBuffers = false, wireframeBit = material.wireframe ? 1 : 0, - geometryGroupHash = ( geometryGroup.id * 0xffffff ) + ( program.id * 2 ) + wireframeBit; + geometryHash = ( geometry.id * 0xffffff ) + ( program.id * 2 ) + wireframeBit; - if ( geometryGroupHash !== _currentGeometryGroupHash ) { + if ( geometryHash !== _currentGeometryGroupHash ) { - _currentGeometryGroupHash = geometryGroupHash; + _currentGeometryGroupHash = geometryHash; updateBuffers = true; } @@ -3048,46 +3085,53 @@ THREE.WebGLRenderer = function ( parameters ) { if ( object instanceof THREE.Mesh ) { - var offsets = geometryGroup.offsets; + var offsets = geometry.offsets; // if there is more than 1 chunk - // must set vertexAttribPointer to use new offsets for each chunk + // must set attribute pointers to use new offsets for each chunk // even if geometry and materials didn't change if ( offsets.length > 1 ) updateBuffers = true; for ( var i = 0, il = offsets.length; i < il; ++ i ) { + var startIndex = offsets[ i ].index; + if ( updateBuffers ) { // vertices - var positionSize = geometryGroup.vertexPositionBuffer.itemSize; + var position = geometry.attributes[ "position" ]; + var positionSize = position.itemSize; - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.vertexPositionBuffer ); - _gl.vertexAttribPointer( attributes.position, positionSize, _gl.FLOAT, false, 0, offsets[ i ].index * positionSize * 4 ); // 4 bytes per Float32 + _gl.bindBuffer( _gl.ARRAY_BUFFER, position.buffer ); + _gl.vertexAttribPointer( attributes.position, positionSize, _gl.FLOAT, false, 0, startIndex * positionSize * 4 ); // 4 bytes per Float32 // normals - if ( attributes.normal >= 0 && geometryGroup.vertexNormalBuffer ) { + var normal = geometry.attributes[ "normal" ]; - var normalSize = geometryGroup.vertexNormalBuffer.itemSize; + if ( attributes.normal >= 0 && normal ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.vertexNormalBuffer ); - _gl.vertexAttribPointer( attributes.normal, normalSize, _gl.FLOAT, false, 0, offsets[ i ].index * normalSize * 4 ); + var normalSize = normal.itemSize; + + _gl.bindBuffer( _gl.ARRAY_BUFFER, normal.buffer ); + _gl.vertexAttribPointer( attributes.normal, normalSize, _gl.FLOAT, false, 0, startIndex * normalSize * 4 ); } // uvs - if ( attributes.uv >= 0 && geometryGroup.vertexUvBuffer ) { + var uv = geometry.attributes[ "uv" ]; + + if ( attributes.uv >= 0 && uv ) { - if ( geometryGroup.vertexUvBuffer ) { + if ( uv.buffer ) { - var uvSize = geometryGroup.vertexUvBuffer.itemSize; + var uvSize = uv.itemSize; - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.vertexUvBuffer ); - _gl.vertexAttribPointer( attributes.uv, uvSize, _gl.FLOAT, false, 0, offsets[ i ].index * uvSize * 4 ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, uv.buffer ); + _gl.vertexAttribPointer( attributes.uv, uvSize, _gl.FLOAT, false, 0, startIndex * uvSize * 4 ); _gl.enableVertexAttribArray( attributes.uv ); @@ -3101,17 +3145,23 @@ THREE.WebGLRenderer = function ( parameters ) { // colors - if ( attributes.color >= 0 && geometryGroup.vertexColorBuffer ) { + var color = geometry.attributes[ "color" ]; + + if ( attributes.color >= 0 && color ) { - var colorSize = geometryGroup.vertexColorBuffer.itemSize; + var colorSize = color.itemSize; - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.vertexColorBuffer ); - _gl.vertexAttribPointer( attributes.color, colorSize, _gl.FLOAT, false, 0, offsets[ i ].index * colorSize * 4 ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, color.buffer ); + _gl.vertexAttribPointer( attributes.color, colorSize, _gl.FLOAT, false, 0, startIndex * colorSize * 4 ); } - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.vertexIndexBuffer ); + // indices + + var index = geometry.attributes[ "index" ]; + + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, index.buffer ); } @@ -4034,12 +4084,6 @@ THREE.WebGLRenderer = function ( parameters ) { object._modelViewMatrix = new THREE.Matrix4(); object._normalMatrix = new THREE.Matrix3(); - //object._normalMatrixArray = new Float32Array( 9 ); - //object._modelViewMatrixArray = new Float32Array( 16 ); - //object._objectMatrixArray = new Float32Array( 16 ); - - //object.matrixWorld.flattenToArray( object._objectMatrixArray ); - if ( object instanceof THREE.Mesh ) { geometry = object.geometry; @@ -4077,6 +4121,10 @@ THREE.WebGLRenderer = function ( parameters ) { } + } else if ( geometry instanceof THREE.BufferGeometry ) { + + initDirectBuffers( geometry ); + } } else if ( object instanceof THREE.Ribbon ) { -- GitLab