// ThreeExtras.js r46dev - http://github.com/mrdoob/three.js THREE.ColorUtils={adjustHSV:function(a,c,b,d){var h=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,h);h.h=THREE.Math.clamp(h.h+c,0,1);h.s=THREE.Math.clamp(h.s+b,0,1);h.v=THREE.Math.clamp(h.v+d,0,1);a.setHSV(h.h,h.s,h.v)},rgbToHsv:function(a,c){var b=a.r,d=a.g,h=a.b,f=Math.max(Math.max(b,d),h),e=Math.min(Math.min(b,d),h);if(e===f)e=b=0;else{var g=f-e,e=g/f,b=b===f?(d-h)/g:d===f?2+(h-b)/g:4+(b-d)/g;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=e;c.v=f;return c}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; THREE.GeometryUtils={merge:function(a,c){for(var b,d,h=a.vertices.length,f=c instanceof THREE.Mesh?c.geometry:c,e=a.vertices,g=f.vertices,i=a.faces,k=f.faces,j=a.faceVertexUvs[0],p=f.faceVertexUvs[0],m={},n=0;n1&&(d=1-d,h=1-h);f=1-d-h;e.copy(a);e.multiplyScalar(d);g.copy(c);g.multiplyScalar(h);e.addSelf(g);g.copy(b);g.multiplyScalar(f);e.addSelf(g);return e},randomPointInFace:function(a,c,b){var d,h,f;if(a instanceof THREE.Face3)return d=c.vertices[a.a].position,h=c.vertices[a.b].position, f=c.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,h,f);else if(a instanceof THREE.Face4){d=c.vertices[a.a].position;h=c.vertices[a.b].position;f=c.vertices[a.c].position;var c=c.vertices[a.d].position,e;b?a._area1&&a._area2?(b=a._area1,e=a._area2):(b=THREE.GeometryUtils.triangleArea(d,h,c),e=THREE.GeometryUtils.triangleArea(h,f,c),a._area1=b,a._area2=e):(b=THREE.GeometryUtils.triangleArea(d,h,c),e=THREE.GeometryUtils.triangleArea(h,f,c));return THREE.GeometryUtils.random()*(b+ e)a?b(d,e-1):k[e] 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;", THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3( 1.0 ), uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = max( dot( normal, pointHalfVector ), 0.0 );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;\npointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight * pointDiffuseWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = max( dot( normal, dirHalfVector ), 0.0 );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;\ndirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight * dirDiffuseWeight;\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * ( totalDiffuse + ambientLightColor * uAmbientColor) + totalSpecular;\nif ( enableReflection ) {\nvec3 wPos = cameraPosition - vViewPosition;\nvec3 vReflect = reflect( normalize( wPos ), normal );\nvec4 cubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, uReflectivity );\n}", THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["attribute vec4 tangent;\nuniform vec2 uOffset;\nuniform vec2 uRepeat;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;", THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv * uRepeat + uOffset;\n#if MAX_POINT_LIGHTS > 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( 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.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPoint(c/a));return b};THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPointAt(c/a));return b}; THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==a+1)return this.cacheArcLengths;var c=[],b,d=this.getPoint(0),h,f=0;c.push(0);for(h=1;h<=a;h++)b=this.getPoint(h/a),f+=b.distanceTo(d),c.push(f),d=b;return this.cacheArcLengths=c}; THREE.Curve.prototype.getUtoTmapping=function(a,c){var b=this.getLengths(),d=0,h=b.length,f;f=c?c:a*b[h-1];Date.now();for(var e=0,g=h-1,i;e<=g;)if(d=Math.floor(e+(g-e)/2),i=b[d]-f,i<0)e=d+1;else if(i>0)g=d-1;else{g=d;break}d=g;if(b[d]==f)return d/(h-1);e=b[d];return b=(d+(f-e)/(b[d+1]-e))/(h-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 c=a-1.0E-4;a+=1.0E-4;c<0&&(c=0);a>1&&(a=1);var c=this.getPoint(c),a=this.getPoint(a),b=new THREE.Vector2;b.sub(a,c);return b.unit()};THREE.LineCurve=function(a,c){a instanceof THREE.Vector2?(this.v1=a,this.v2=c):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(a,c,b,d){this.constructor(new THREE.Vector2(a,c),new THREE.Vector2(b,d))};THREE.LineCurve.prototype=new THREE.Curve; THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2;c.sub(this.v2,this.v1);c.multiplyScalar(a).addSelf(this.v1);return c};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(){var a=new THREE.Vector2;a.sub(this.v2,this.v1);a.normalize();return a}; THREE.QuadraticBezierCurve=function(a,c,b){if(!(c instanceof THREE.Vector2))var d=Array.prototype.slice.call(arguments),a=new THREE.Vector2(d[0],d[1]),c=new THREE.Vector2(d[2],d[3]),b=new THREE.Vector2(d[4],d[5]);this.v0=a;this.v1=c;this.v2=b};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var c;c=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(c,a)};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var c;c=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.x,this.v1.x,this.v2.x);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.v0.y,this.v1.y,this.v2.y);c=new THREE.Vector2(c,a);c.normalize();return c}; THREE.CubicBezierCurve=function(a,c,b,d){if(!(c instanceof THREE.Vector2))var h=Array.prototype.slice.call(arguments),a=new THREE.Vector2(h[0],h[1]),c=new THREE.Vector2(h[2],h[3]),b=new THREE.Vector2(h[4],h[5]),d=new THREE.Vector2(h[6],h[7]);this.v0=a;this.v1=c;this.v2=b;this.v3=d};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; THREE.CubicBezierCurve.prototype.getPoint=function(a){var c;c=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(c,a)};THREE.CubicBezierCurve.prototype.getTangent=function(a){var c;c=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);a=THREE.Curve.Utils.tangentCubicBezier(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);c=new THREE.Vector2(c,a);c.normalize();return c}; THREE.SplineCurve=function(a){this.points=a};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve; THREE.SplineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2,b=[],d=this.points,h;h=(d.length-1)*a;a=Math.floor(h);h-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>d.length-2?a:a+1;b[3]=a>d.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(d[b[0]].x,d[b[1]].x,d[b[2]].x,d[b[3]].x,h);c.y=THREE.Curve.Utils.interpolate(d[b[0]].y,d[b[1]].y,d[b[2]].y,d[b[3]].y,h);return c};THREE.ArcCurve=function(a,c,b,d,h,f){this.aX=a;this.aY=c;this.aRadius=b;this.aStartAngle=d;this.aEndAngle=h;this.aClockwise=f}; THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(a){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);a=this.aStartAngle+a*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(a),this.aY+this.aRadius*Math.sin(a))}; THREE.Curve.Utils={tangentQuadraticBezier:function(a,c,b,d){return 2*(1-a)*(b-c)+2*a*(d-b)},tangentCubicBezier:function(a,c,b,d,h){return-3*c*(1-a)*(1-a)+3*b*(1-a)*(1-a)-6*a*b*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*h},tangentSpline:function(a){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,c,b,d,h){var a=(b-a)*0.5,d=(d-c)*0.5,f=h*h;return(2*c-2*b+a+d)*h*f+(-3*c+3*b-2*a-d)*f+a*h+c}}; THREE.Curve.create=function(a,c){a.prototype=new THREE.Curve;a.prototype.constructor=a;a.prototype.getPoint=c;return a};THREE.LineCurve3=THREE.Curve.create(function(a,c){this.v1=a;this.v2=c},function(a){var c=new THREE.Vector3;c.sub(this.v2,this.v1);c.multiplyScalar(a);c.addSelf(this.v1);return c}); THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,c,b){this.v0=a;this.v1=c;this.v2=b},function(a){var c,b;c=THREE.Shape.Utils.b2(a,this.v0.x,this.v1.x,this.v2.x);b=THREE.Shape.Utils.b2(a,this.v0.y,this.v1.y,this.v2.y);a=THREE.Shape.Utils.b2(a,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(c,b,a)}); THREE.CubicBezierCurve3=THREE.Curve.create(function(a,c,b,d){this.v0=a;this.v1=c;this.v2=b;this.v3=d},function(a){var c,b;c=THREE.Shape.Utils.b3(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=THREE.Shape.Utils.b3(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y);a=THREE.Shape.Utils.b3(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(c,b,a)}); THREE.SplineCurve3=THREE.Curve.create(function(a){this.points=a},function(a){var c=new THREE.Vector3,b=[],d=this.points,h;h=(d.length-1)*a;a=Math.floor(h);h-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>d.length-2?a:a+1;b[3]=a>d.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(d[b[0]].x,d[b[1]].x,d[b[2]].x,d[b[3]].x,h);c.y=THREE.Curve.Utils.interpolate(d[b[0]].y,d[b[1]].y,d[b[2]].y,d[b[3]].y,h);c.z=THREE.Curve.Utils.interpolate(d[b[0]].z,d[b[1]].z,d[b[2]].z,d[b[3]].z,h);return c}); THREE.CurvePath=function(){this.curves=[];this.bends=[]};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){}; THREE.CurvePath.prototype.getPoint=function(a){for(var c=a*this.getLength(),b=this.getCurveLengths(),a=0;a=c)return c=b[a]-c,a=this.curves[a],c=1-c/a.getLength(),a.getPointAt(c);a++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]}; THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var a=[],c=0,b,d=this.curves.length;for(b=0;bc)c=f.x;else if(f.xb)b=f.y;else if(f.y0?(e=b[b.length-1],n=e.x,t=e.y):(e=this.actions[d-1].args,n=e[e.length-2],t=e[e.length-1]);for(e=1;e<=a;e++)l=e/a,f=THREE.Shape.Utils.b2(l,n,p,g),l=THREE.Shape.Utils.b2(l,t,m, i),b.push(new THREE.Vector2(f,l));break;case THREE.PathActions.BEZIER_CURVE_TO:g=f[4];i=f[5];p=f[0];m=f[1];k=f[2];j=f[3];b.length>0?(e=b[b.length-1],n=e.x,t=e.y):(e=this.actions[d-1].args,n=e[e.length-2],t=e[e.length-1]);for(e=1;e<=a;e++)l=e/a,f=THREE.Shape.Utils.b3(l,n,p,k,g),l=THREE.Shape.Utils.b3(l,t,m,j,i),b.push(new THREE.Vector2(f,l));break;case THREE.PathActions.CSPLINE_THRU:e=this.actions[d-1].args;e=[new THREE.Vector2(e[e.length-2],e[e.length-1])];l=a*f[0].length;e=e.concat(f[0]);f=new THREE.SplineCurve(e); for(e=1;e<=l;e++)b.push(f.getPointAt(e/l));break;case THREE.PathActions.ARC:e=this.actions[d-1].args;g=f[0];i=f[1];k=f[2];p=f[3];l=f[4];m=!!f[5];j=e[e.length-2];n=e[e.length-1];e.length==0&&(j=n=0);t=l-p;var s=a*2;for(e=1;e<=s;e++)l=e/s,m||(l=1-l),l=p+l*t,f=j+g+k*Math.cos(l),l=n+i+k*Math.sin(l),b.push(new THREE.Vector2(f,l))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)}; THREE.Path.prototype.nltransform=function(a,c,b,d,h,f){var e=this.getPoints(),g,i,k,j,p;g=0;for(i=e.length;g=0?g-1:b.length-1;f=e-1>=0?e-1:k.length-1;var l=[k[e],b[g],b[h]];p=THREE.FontUtils.Triangulate.area(l);var s=[k[e],k[f],b[g]];m=THREE.FontUtils.Triangulate.area(s);n=g;j=e;g+=1;e+=-1;g< 0&&(g+=b.length);g%=b.length;e<0&&(e+=k.length);e%=k.length;h=g-1>=0?g-1:b.length-1;f=e-1>=0?e-1:k.length-1;l=[k[e],b[g],b[h]];l=THREE.FontUtils.Triangulate.area(l);s=[k[e],k[f],b[g]];s=THREE.FontUtils.Triangulate.area(s);p+m>l+s&&(g=n,e=j,g<0&&(g+=b.length),g%=b.length,e<0&&(e+=k.length),e%=k.length,h=g-1>=0?g-1:b.length-1,f=e-1>=0?e-1:k.length-1);p=b.slice(0,g);m=b.slice(g);n=k.slice(e);j=k.slice(0,e);f=[k[e],k[f],b[g]];t.push([k[e],b[g],b[h]]);t.push(f);b=p.concat(n).concat(j).concat(m)}return{shape:b, isolatedPts:t,allpoints:d}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),d=b.allpoints,h=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),f,e,g,i,k={};f=0;for(e=d.length;f1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n),d=d<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=h[0]+(f[0]-h[0])*d,b.y=h[1]+(f[1]-h[1])*d,b.z=h[2]+(f[2]-h[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",n,e.index-1).pos,this.points[1]=h,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",n,g.index+1).pos,d=d*0.33+0.33,h=this.interpolateCatmullRom(this.points,d),b.x=h[0],b.y=h[1],b.z=h[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(b=== "rot")THREE.Quaternion.slerp(h,f,a.quaternion,d);else if(b==="scl")b=a.scale,b.x=h[0]+(f[0]-h[0])*d,b.y=h[1]+(f[1]-h[1])*d,b.z=h[2]+(f[2]-h[2])*d}}if(this.JITCompile&&j[0][k]===void 0){this.hierarchy[0].update(null,!0);for(n=0;na.length-2?f:f+1;b[3]=f>a.length-3?f:f+2;f=a[b[0]];g=a[b[1]];i=a[b[2]];k=a[b[3]];b=h*h;e=h*b;d[0]=this.interpolate(f[0],g[0],i[0],k[0],h,b,e);d[1]=this.interpolate(f[1],g[1],i[1],k[1],h,b,e);d[2]=this.interpolate(f[2],g[2],i[2],k[2],h,b,e);return d}; THREE.Animation.prototype.interpolate=function(a,c,b,d,h,f,e){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*e+(-3*(c-b)-2*a-d)*f+a*h+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b0?b:0:b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==void 0)return d[b];return this.data.hierarchy[c].keys[d.length-1]}; THREE.CubeCamera=function(a,c,b,d){this.heightOffset=b;this.position=new THREE.Vector3(0,b,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,c);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,c);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position= this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ= new THREE.Vector3(0,0,0);this.renderTarget=new THREE.WebGLRenderTargetCube(d,d,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(a){this.position.copy(a);this.position.y+=this.heightOffset;this.targetPX.copy(this.position);this.targetNX.copy(this.position);this.targetPY.copy(this.position);this.targetNY.copy(this.position);this.targetPZ.copy(this.position);this.targetNZ.copy(this.position);this.targetPX.x+=1;this.targetNX.x-=1;this.targetPY.y+= 1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,b){var d=this.renderTarget;d.activeCubeFace=0;a.render(b,this.cameraPX,d);d.activeCubeFace=1;a.render(b,this.cameraNX,d);d.activeCubeFace=2;a.render(b,this.cameraPY,d);d.activeCubeFace=3;a.render(b, this.cameraNY,d);d.activeCubeFace=4;a.render(b,this.cameraPZ,d);d.activeCubeFace=5;a.render(b,this.cameraNZ,d)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")}; THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,c,b,d,h,f,e){THREE.Camera.call(this);this.fov=b;this.left=-a/2;this.right=a/2;this.top=c/2;this.bottom=-c/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,c/2,c/-2,f,e);this.cameraP=new THREE.PerspectiveCamera(b,a/c,d,h);this.zoom=1;this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera; THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPersepectiveMode=!0;this.inOrthographicMode=!1}; THREE.CombinedCamera.prototype.toOrthographic=function(){var a=Math.tan(this.fov/2)*((this.cameraP.near+this.cameraP.far)/2),c=2*a*this.cameraP.aspect/2;a/=this.zoom;c/=this.zoom;this.cameraO.left=-c;this.cameraO.right=c;this.cameraO.top=a;this.cameraO.bottom=-a;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPersepectiveMode=!1;this.inOrthographicMode=!0}; THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,c){c||(c=43.25);var b=2*Math.atan(c/(a*2));b*=180/Math.PI;this.setFov(b);return b};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()}; THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1}; THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1}; THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor= 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward= !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown= function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp= !1;break;case 70:this.moveDown=!1}};this.update=function(a){var b=0;if(!this.freeze){if(this.heightSpeed){var c=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=a*c*this.heightCoef}else this.autoSpeedFactor=0;b=a*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(b);this.moveLeft&&this.object.translateX(-b);this.moveRight&& this.object.translateX(b);this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);c=a*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a= 1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)* Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)}; THREE.PathControls=function(a,c){function b(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function h(a,b,d,c){var e={name:d,fps:0.6,length:c,hierarchy:[]},f,h=b.getControlPointsArray(),g=b.getLength(),s=h.length,q=0;f=s-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:h[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:c,pos:h[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f=0?a:a+e;d=this.verticalAngleMap.srcRange; a=this.verticalAngleMap.dstRange;d=THREE.Math.mapLinear(this.phi,d[0],d[1],a[0],a[1]);var c=a[1]-a[0];this.phi=b((d-a[0])/c)*c+a[0];d=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;d=THREE.Math.mapLinear(this.theta,d[0],d[1],a[0],a[1]);c=a[1]-a[0];this.theta=b((d-a[0])/c)*c+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove= function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}), c=new THREE.CubeGeometry(10,10,20),e=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(e,b);a.position.set(0,10,0);this.animation=h(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=h(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a= this.debugPath,b=this.spline,e=f(b,10),c=f(b,10),g=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),e=new THREE.Line(e,g),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));e.scale.set(1,1,1);a.add(e);c.scale.set(1,1,1);a.add(c);for(var e=new THREE.SphereGeometry(1,16,8),g=new THREE.MeshBasicMaterial({color:65280}),n=0;n0){var b=this.getContainerDimensions(),c=b.size[0]/2,e=b.size[1]/2;this.moveState.yawLeft=-(a.pageX-b.offset[0]-c)/c;this.moveState.pitchDown=(a.pageY-b.offset[1]-e)/e;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward= !1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(a){var b=a*this.movementSpeed;a*=this.rollSpeed;this.object.translateX(this.moveVector.x*b);this.object.translateY(this.moveVector.y*b);this.object.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*a,this.rotationVector.y*a,this.rotationVector.z*a,1).normalize();this.object.quaternion.multiplySelf(this.tmpQuaternion);this.object.matrix.setPosition(this.object.position);this.object.matrix.setRotationFromQuaternion(this.object.quaternion); this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z= -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this, this.mouseup),!1);this.domElement.addEventListener("keydown",b(this,this.keydown),!1);this.domElement.addEventListener("keyup",b(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()}; THREE.RollControls=function(a,c){this.object=a;this.domElement=c!==void 0?c:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var b=new THREE.Vector3,d=new THREE.Vector3,h=new THREE.Vector3,f=new THREE.Matrix4,e=!1,g=1,i=0,k=0,j=0,p=0,m=0,n=window.innerWidth/2,t=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var c=a*this.lookSpeed; this.rotateHorizontally(c*p);this.rotateVertically(c*m)}c=a*this.movementSpeed;this.object.translateZ(-c*(i>0||this.autoForward&&!(i<0)?1:i));this.object.translateX(c*k);this.object.translateY(c*j);e&&(this.roll+=this.rollSpeed*a*g);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-f*f);e.copy(b.object.position).subSelf(b.target);f=b.object.up.clone().setLength(d.y);f.addSelf(b.object.up.clone().crossSelf(e).setLength(d.x));f.addSelf(e.setLength(d.z));return f};this.rotateCamera=function(){var a=Math.acos(g.dot(i)/g.length()/i.length());if(a){var c=(new THREE.Vector3).cross(g,i).normalize(),d=new THREE.Quaternion;a*=b.rotateSpeed;d.setFromAxisAngle(c,-a);d.multiplyVector3(e); d.multiplyVector3(b.object.up);d.multiplyVector3(i);b.staticMoving?g=i:(d.setFromAxisAngle(c,a*(b.dynamicDampingFactor-1)),d.multiplyVector3(g))}};this.zoomCamera=function(){var a=1+(j.y-k.y)*b.zoomSpeed;a!==1&&a>0&&(e.multiplyScalar(a),b.staticMoving?k=j:k.y+=(j.y-k.y)*this.dynamicDampingFactor)};this.panCamera=function(){var a=m.clone().subSelf(p);if(a.lengthSq()){a.multiplyScalar(e.length()*b.panSpeed);var c=e.clone().crossSelf(b.object.up).setLength(a.x);c.addSelf(b.object.up.clone().setLength(a.y)); b.object.position.addSelf(c);b.target.addSelf(c);b.staticMoving?p=m:p.addSelf(a.sub(m,p).multiplyScalar(b.dynamicDampingFactor))}};this.checkDistances=function(){if(!b.noZoom||!b.noPan)b.object.position.lengthSq()>b.maxDistance*b.maxDistance&&b.object.position.setLength(b.maxDistance),e.lengthSq()0?1:-1;for(g=0;g0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,e,0)));for(g=0;g0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-e,0)));for(g=0;ga&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function h(a){for(v=a.length;--v>=0;){J=v;N=v-1;N<0&&(N=a.length-1);for(var b= 0,c=n+j*2,b=0;b=0;z--){G=z/j;I=i*(1-G);G=k*Math.sin(G*Math.PI/2);v=0;for(D=r.length;v0||(j=this.vertices.push(new THREE.Vertex(new THREE.Vector3(p,g,m)))-1);k.push(j)}c.push(k)}for(var n,t,l,h=c.length,b=0;b0)for(d=0;d1&&(n= this.vertices[e].position.clone(),t=this.vertices[i].position.clone(),l=this.vertices[k].position.clone(),n.normalize(),t.normalize(),l.normalize(),this.faces.push(new THREE.Face3(e,i,k,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(l.x,l.y,l.z)])),this.faceVertexUvs[0].push([j,p,s]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry; THREE.TextGeometry=function(a,c){var b=(new THREE.TextPath(a,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var d=b[b.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(d/2,120),new THREE.Vector2(d,0))}THREE.ExtrudeGeometry.call(this,b,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[c][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var c=this.getFace(),b=this.size/c.resolution,d= 0,h=String(a).split(""),f=h.length,e=[],a=0;a0)for(k=0;k2;){if(p--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return g;return f}i=k;h<=i&&(i=0);k=i+1;h<=k&&(k=0);j=k+1;h<=j&&(j=0);var m;a:{m=a;var n=i,t=k,l=j,s=h,q=e,r=void 0,o=void 0,u=void 0, y=void 0,w=void 0,x=void 0,A=void 0,C=void 0,F=void 0,o=m[q[n]].x,u=m[q[n]].y,y=m[q[t]].x,w=m[q[t]].y,x=m[q[l]].x,A=m[q[l]].y;if(1.0E-10>(y-o)*(A-u)-(w-u)*(x-o))m=!1;else{for(r=0;r=0&&z>=0&&I>=0){m=!1;break a}}m=!0}}if(m){f.push([a[e[i]], a[e[k]],a[e[j]]]);g.push([e[i],e[k],e[j]]);i=k;for(j=k+1;j0;)this.smooth(a)}; THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,d,g,i){var j=new THREE.Face4(a,b,c,d,null,g.color,g.material);if(e.useOldVertexColors){j.vertexColors=[];for(var k,n,l,o=0;o<4;o++){l=i[o];k=new THREE.Color;k.setRGB(0,0,0);for(var q=0;q>7)-127;d|=(f&127)<<16|e<<8;if(d==0&&h==-127)return 0;return(1-2*(g>>7))*(1+d*Math.pow(2,-23))*Math.pow(2,h)}function g(a,b){var c=j(a,b),d=j(a,b+1),e=j(a,b+2);return(j(a,b+3)<<24)+(e<<16)+(d<<8)+c}function h(a,b){var c=j(a,b);return(j(a,b+1)<<8)+c}function k(a,b){var c=j(a,b);return c>127?c-256:c}function j(a,b){return a.charCodeAt(b)&255}function p(b){var c, d,e;c=g(a,b);d=g(a,b+w);e=g(a,b+x);b=h(a,b+A);q.faces.push(new THREE.Face3(c,d,e,null,null,b))}function m(b){var c,d,e,f,j,k,l;c=g(a,b);d=g(a,b+w);e=g(a,b+x);f=h(a,b+A);j=g(a,b+C);k=g(a,b+F);l=g(a,b+v);var b=u[k*3],n=u[k*3+1];k=u[k*3+2];var m=u[l*3],o=u[l*3+1];l=u[l*3+2];q.faces.push(new THREE.Face3(c,d,e,[new THREE.Vector3(u[j*3],u[j*3+1],u[j*3+2]),new THREE.Vector3(b,n,k),new THREE.Vector3(m,o,l)],null,f))}function n(b){var c,d,e,f;c=g(a,b);d=g(a,b+D);e=g(a,b+z);f=g(a,b+G);b=h(a,b+I);q.faces.push(new THREE.Face4(c, d,e,f,null,null,b))}function t(b){var c,d,e,f,j,k,l,n,m;c=g(a,b);d=g(a,b+D);e=g(a,b+z);f=g(a,b+G);j=h(a,b+I);k=g(a,b+E);l=g(a,b+K);n=g(a,b+O);m=g(a,b+B);var b=u[l*3],o=u[l*3+1];l=u[l*3+2];var fa=u[n*3],ga=u[n*3+1];n=u[n*3+2];var ha=u[m*3],p=u[m*3+1];m=u[m*3+2];q.faces.push(new THREE.Face4(c,d,e,f,[new THREE.Vector3(u[k*3],u[k*3+1],u[k*3+2]),new THREE.Vector3(b,o,l),new THREE.Vector3(fa,ga,n),new THREE.Vector3(ha,p,m)],null,j))}function l(b){var c,d,e,f;c=g(a,b);d=g(a,b+L);e=g(a,b+H);b=y[c*2];f=y[c* 2+1];c=y[d*2];var h=q.faceVertexUvs[0];d=y[d*2+1];var i=y[e*2];e=y[e*2+1];var j=[];j.push(new THREE.UV(b,f));j.push(new THREE.UV(c,d));j.push(new THREE.UV(i,e));h.push(j)}function s(b){var c,d,e,f,h,i;c=g(a,b);d=g(a,b+M);e=g(a,b+J);f=g(a,b+N);b=y[c*2];h=y[c*2+1];c=y[d*2];i=y[d*2+1];d=y[e*2];var j=q.faceVertexUvs[0];e=y[e*2+1];var k=y[f*2];f=y[f*2+1];var l=[];l.push(new THREE.UV(b,h));l.push(new THREE.UV(c,i));l.push(new THREE.UV(d,e));l.push(new THREE.UV(k,f));j.push(l)}var q=this,r=0,o,u=[],y=[], w,x,A,C,F,v,D,z,G,I,E,K,O,B,L,H,M,J,N,R,P,T,S,U,Q;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(q,d,b);o={signature:a.substr(r,8),header_bytes:j(a,r+8),vertex_coordinate_bytes:j(a,r+9),normal_coordinate_bytes:j(a,r+10),uv_coordinate_bytes:j(a,r+11),vertex_index_bytes:j(a,r+12),normal_index_bytes:j(a,r+13),uv_index_bytes:j(a,r+14),material_index_bytes:j(a,r+15),nvertices:g(a,r+16),nnormals:g(a,r+16+4),nuvs:g(a,r+16+8),ntri_flat:g(a,r+16+12),ntri_smooth:g(a,r+16+16),ntri_flat_uv:g(a, r+16+20),ntri_smooth_uv:g(a,r+16+24),nquad_flat:g(a,r+16+28),nquad_smooth:g(a,r+16+32),nquad_flat_uv:g(a,r+16+36),nquad_smooth_uv:g(a,r+16+40)};r+=o.header_bytes;w=o.vertex_index_bytes;x=o.vertex_index_bytes*2;A=o.vertex_index_bytes*3;C=o.vertex_index_bytes*3+o.material_index_bytes;F=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;v=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;D=o.vertex_index_bytes;z=o.vertex_index_bytes*2;G=o.vertex_index_bytes*3;I=o.vertex_index_bytes* 4;E=o.vertex_index_bytes*4+o.material_index_bytes;K=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes;O=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;B=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;L=o.uv_index_bytes;H=o.uv_index_bytes*2;M=o.uv_index_bytes;J=o.uv_index_bytes*2;N=o.uv_index_bytes*3;b=o.vertex_index_bytes*3+o.material_index_bytes;Q=o.vertex_index_bytes*4+o.material_index_bytes;R=o.ntri_flat*b;P=o.ntri_smooth*(b+o.normal_index_bytes* 3);T=o.ntri_flat_uv*(b+o.uv_index_bytes*3);S=o.ntri_smooth_uv*(b+o.normal_index_bytes*3+o.uv_index_bytes*3);U=o.nquad_flat*Q;b=o.nquad_smooth*(Q+o.normal_index_bytes*4);Q=o.nquad_flat_uv*(Q+o.uv_index_bytes*4);r+=function(b){for(var d,f,g,h=o.vertex_coordinate_bytes*3,i=b+o.nvertices*h;b=0){p=i.invBindMatrices[n];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p1){j=new THREE.MeshFaceMaterial;for(g=0;g1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(e=0;e1?c[1].substr(0,b):"0";c[1].length=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;db){k=j.output[i];break}g=k!==void 0?k instanceof THREE.Matrix4?g.multiply(g,k):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};p.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};F.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof C)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=$[this.effect.surface.init_from]))a.map= THREE.ImageUtils.loadTexture(da+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=ea;return this.material=new THREE.MeshLambertMaterial(a)};v.prototype.parse=function(a){for(var b=0;b=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b1&&(D=new THREE.MeshFaceMaterial); a=new THREE.Mesh(C,D);a.name=m;a.position.set(u[0],u[1],u[2]);w?(a.quaternion.set(w[0],w[1],w[2],w[3]),a.useQuaternion=!0):a.rotation.set(y[0],y[1],y[2]);a.scale.set(x[0],x[1],x[2]);a.visible=q.visible;B.scene.add(a);B.objects[m]=a;if(q.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);B.scene.collisions.colliders.push(b)}if(q.castsShadow)b=new THREE.ShadowVolume(C),B.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;q.trigger&&q.trigger.toLowerCase()!="none"&&(b= {type:q.trigger,object:q},B.triggers[a.name]=b)}}else u=q.position,y=q.rotation,w=q.quaternion,x=q.scale,w=0,a=new THREE.Object3D,a.name=m,a.position.set(u[0],u[1],u[2]),w?(a.quaternion.set(w[0],w[1],w[2],w[3]),a.useQuaternion=!0):a.rotation.set(y[0],y[1],y[2]),a.scale.set(x[0],x[1],x[2]),a.visible=q.visible!==void 0?q.visible:!1,B.scene.add(a),B.objects[m]=a,B.empties[m]=a,q.trigger&&q.trigger.toLowerCase()!="none"&&(b={type:q.trigger,object:q},B.triggers[a.name]=b)}function f(a){return function(b){B.geometries[a]= b;h();I-=1;i.onLoadComplete();g()}}function e(a){return function(b){B.geometries[a]=b}}function g(){i.callbackProgress({totalModels:K,totalTextures:O,loadedModels:K-I,loadedTextures:O-E},B);i.onLoadProgress();I==0&&E==0&&c(B)}var i=this,k=THREE.Loader.prototype.extractUrlbase(b),j,p,m,n,t,l,s,q,r,o,u,y,w,x,A,C,F,v,D,z,G,I,E,K,O,B;z=a;b=new THREE.BinaryLoader;G=new THREE.JSONLoader;E=I=0;B={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, empties:{}};a=!1;for(m in z.objects)if(q=z.objects[m],q.meshCollider){a=!0;break}if(a)B.scene.collisions=new THREE.CollisionSystem;if(z.transform){a=z.transform.position;r=z.transform.rotation;var L=z.transform.scale;a&&B.scene.position.set(a[0],a[1],a[2]);r&&B.scene.rotation.set(r[0],r[1],r[2]);L&&B.scene.scale.set(L[0],L[1],L[2]);(a||r||L)&&B.scene.updateMatrix()}a=function(){E-=1;g();i.onLoadComplete()};for(t in z.cameras)r=z.cameras[t],r.type=="perspective"?F=new THREE.PerspectiveCamera(r.fov, r.aspect,r.near,r.far):r.type=="ortho"&&(F=new THREE.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)),u=r.position,r=r.target,F.position.set(u[0],u[1],u[2]),F.target=new THREE.Vector3(r[0],r[1],r[2]),B.cameras[t]=F;for(n in z.lights)r=z.lights[n],t=r.color!==void 0?r.color:16777215,F=r.intensity!==void 0?r.intensity:1,r.type=="directional"?(u=r.direction,o=new THREE.DirectionalLight(t,F),o.position.set(u[0],u[1],u[2]),o.position.normalize()):r.type=="point"?(u=r.position,o=r.distance, o=new THREE.PointLight(t,F,o),o.position.set(u[0],u[1],u[2])):r.type=="ambient"&&(o=new THREE.AmbientLight(t)),B.scene.add(o),B.lights[n]=o;for(l in z.fogs)n=z.fogs[l],n.type=="linear"?v=new THREE.Fog(0,n.near,n.far):n.type=="exp2"&&(v=new THREE.FogExp2(0,n.density)),r=n.color,v.color.setRGB(r[0],r[1],r[2]),B.fogs[l]=v;if(B.cameras&&z.defaults.camera)B.currentCamera=B.cameras[z.defaults.camera];if(B.fogs&&z.defaults.fog)B.scene.fog=B.fogs[z.defaults.fog];r=z.defaults.bgcolor;B.bgColor=new THREE.Color; B.bgColor.setRGB(r[0],r[1],r[2]);B.bgColorAlpha=z.defaults.bgalpha;for(j in z.geometries)if(l=z.geometries[j],l.type=="bin_mesh"||l.type=="ascii_mesh")I+=1,i.onLoadStart();K=I;for(j in z.geometries)l=z.geometries[j],l.type=="cube"?(C=new THREE.CubeGeometry(l.width,l.height,l.depth,l.segmentsWidth,l.segmentsHeight,l.segmentsDepth,null,l.flipped,l.sides),B.geometries[j]=C):l.type=="plane"?(C=new THREE.PlaneGeometry(l.width,l.height,l.segmentsWidth,l.segmentsHeight),B.geometries[j]=C):l.type=="sphere"? (C=new THREE.SphereGeometry(l.radius,l.segmentsWidth,l.segmentsHeight),B.geometries[j]=C):l.type=="cylinder"?(C=new THREE.CylinderGeometry(l.topRad,l.botRad,l.height,l.radSegs,l.heightSegs),B.geometries[j]=C):l.type=="torus"?(C=new THREE.TorusGeometry(l.radius,l.tube,l.segmentsR,l.segmentsT),B.geometries[j]=C):l.type=="icosahedron"?(C=new THREE.IcosahedronGeometry(l.subdivisions),B.geometries[j]=C):l.type=="bin_mesh"?b.load(d(l.url,z.urlBaseType),f(j)):l.type=="ascii_mesh"?G.load(d(l.url,z.urlBaseType), f(j)):l.type=="embedded_mesh"&&(l=z.embeds[l.id])&&G.createModel(l,e(j),"");for(s in z.textures)if(j=z.textures[s],j.url instanceof Array){E+=j.url.length;for(l=0;l=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),d=1,h=0;h<8;h++){for(var f=0,e=0;e>1^-(g&1);b[8*e+h]=f}d+=c}c=a.length-d;f=new Uint16Array(c);for(h=e=0;h=this.maxCount-3&&g(this)};this.begin= function(){this.count=0;this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!==0){for(var c=this.count*3;cthis.size-1&&(i=this.size-1);var m=Math.floor(k-g);m<1&&(m=1);k=Math.floor(k+g);k>this.size-1&&(k=this.size-1);var n=Math.floor(j-g);n<1&&(n=1);g=Math.floor(j+g); g>this.size-1&&(g=this.size-1);for(var t,l,s,q,r,o;p0&&(this.field[s+t]+=q)}}};this.addPlaneX=function(a,c){var h,f,e,g,i,k=this.size,j=this.yd,p=this.zd,m=this.field,n=k*Math.sqrt(a/c);n>k&&(n=k);for(h=0;h0)for(f=0;fj&&(t=j);for(f=0;f0){i=f*p;for(h=0;hj&&(t=j);for(e=0;e0){i=m*e;for(f=0;ff?this.hits.push(h):this.hits.unshift(h),f=d;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(a){var c=this.rayCastAll(a);if(c.length==0)return null;for(var b=0;c[b]instanceof THREE.MeshCollider;){var d=this.rayMesh(a,c[b]);if(d.distc.length)return null;return c[b]}; THREE.CollisionSystem.prototype.rayCast=function(a,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(a,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(a,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(a,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(a,c.box)}; THREE.CollisionSystem.prototype.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),d=Number.MAX_VALUE,h,f=0;f=g*h))return Number.MAX_VALUE;e/=g;g=THREE.CollisionSystem.__v3;g.copy(a.direction);g.multiplyScalar(e);g.addSelf(a.origin);Math.abs(f.x)> Math.abs(f.y)?Math.abs(f.x)>Math.abs(f.z)?(a=g.y-c.y,f=b.y-c.y,h=d.y-c.y,g=g.z-c.z,b=b.z-c.z,d=d.z-c.z):(a=g.x-c.x,f=b.x-c.x,h=d.x-c.x,g=g.y-c.y,b=b.y-c.y,d=d.y-c.y):Math.abs(f.y)>Math.abs(f.z)?(a=g.x-c.x,f=b.x-c.x,h=d.x-c.x,g=g.z-c.z,b=b.z-c.z,d=d.z-c.z):(a=g.x-c.x,f=b.x-c.x,h=d.x-c.x,g=g.y-c.y,b=b.y-c.y,d=d.y-c.y);c=f*d-b*h;if(c==0)return Number.MAX_VALUE;c=1/c;d=(a*d-g*h)*c;if(!(d>=0))return Number.MAX_VALUE;c*=f*g-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-d-c>=0))return Number.MAX_VALUE;return e}; THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;b.getInverse(c.matrixWorld);var d=THREE.CollisionSystem.__r;d.origin.copy(a.origin);d.direction.copy(a.direction);b.multiplyVector3(d.origin);b.rotateAxis(d.direction);d.direction.normalize();return d}; THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;c.dynamic&&c.mesh&&c.mesh.matrixWorld?b=this.makeRayLocal(a,c.mesh):(b=THREE.CollisionSystem.__r,b.origin.copy(a.origin),b.direction.copy(a.direction));var d=0,h=0,f=0,e=0,g=0,i=0,k=!0;b.origin.xc.max.x&&(d=c.max.x-b.origin.x,d/=b.direction.x,k=!1,e=1);b.origin.yc.max.y&&(h=c.max.y-b.origin.y,h/=b.direction.y, k=!1,g=1);b.origin.zc.max.z&&(f=c.max.z-b.origin.z,f/=b.direction.z,k=!1,i=1);if(k)return-1;k=0;h>d&&(k=1,d=h);f>d&&(k=2,d=f);switch(k){case 0:g=b.origin.y+b.direction.y*d;if(gc.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*d;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(e,0,0);break;case 1:e=b.origin.x+b.direction.x*d;if(ec.max.x)return Number.MAX_VALUE;b=b.origin.z+b.direction.z* d;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(0,g,0);break;case 2:e=b.origin.x+b.direction.x*d;if(ec.max.x)return Number.MAX_VALUE;g=b.origin.y+b.direction.y*d;if(gc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,i)}return d};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),d=c.point.dot(c.normal);if(b<0)b=(d-a.origin.dot(c.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq=0)return Math.abs(d)-Math.sqrt(b);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var c=a.geometry.boundingBox,b=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c}; THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))}; if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var c=this,b=this.setSize,d=this.render,h=new THREE.PerspectiveCamera,f=new THREE.PerspectiveCamera,e=new THREE.Matrix4,g=new THREE.Matrix4,i,k,j,p;h.matrixAutoUpdate=f.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},m=new THREE.WebGLRenderTarget(512,512,a),n=new THREE.WebGLRenderTarget(512,512,a),t=new THREE.PerspectiveCamera(53, 1,1,1E4);t.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:m},mapRight:{type:"t",value:1,texture:n}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}), l=new THREE.Scene;l.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));l.add(t);this.setSize=function(a,d){b.call(c,a,d);m.width=a;m.height=d;n.width=a;n.height=d};this.render=function(a,b){a.updateMatrixWorld();if(i!==b.aspect||k!==b.near||j!==b.far||p!==b.fov){i=b.aspect;k=b.near;j=b.far;p=b.fov;var r=b.projectionMatrix.clone(),o=125/30*0.5,u=o*k/125,y=k*Math.tan(p*Math.PI/360),w;e.n14=o;g.n14=-o;o=-y*i+u;w=y*i+u;r.n11=2*k/(w-o);r.n13=(w+o)/(w-o);h.projectionMatrix.copy(r);o=-y*i-u;w=y*i-u;r.n11= 2*k/(w-o);r.n13=(w+o)/(w-o);f.projectionMatrix.copy(r)}h.matrixWorld.copy(b.matrixWorld).multiplySelf(g);h.position.copy(b.position);h.near=b.near;h.far=b.far;d.call(c,a,h,m,!0);f.matrixWorld.copy(b.matrixWorld).multiplySelf(e);f.position.copy(b.position);f.near=b.near;f.far=b.far;d.call(c,a,f,n,!0);l.updateMatrixWorld();d.call(c,l,t)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,d=this.render,h,f,e=new THREE.PerspectiveCamera;e.target=new THREE.Vector3(0,0,0);var g=new THREE.PerspectiveCamera;g.target=new THREE.Vector3(0,0,0);c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;this.setSize=function(a,d){b.call(c,a,d);h=a/2;f=d};this.render=function(a,b){this.clear();e.fov=b.fov;e.aspect=0.5*b.aspect;e.near=b.near;e.far= b.far;e.updateProjectionMatrix();e.position.copy(b.position);e.target.copy(b.target);e.translateX(c.separation);e.lookAt(e.target);g.projectionMatrix=e.projectionMatrix;g.position.copy(b.position);g.target.copy(b.target);g.translateX(-c.separation);g.lookAt(g.target);this.setViewport(0,0,h,f);d.call(c,a,e);this.setViewport(h,0,h,f);d.call(c,a,g,!1)}};