diff --git a/build/Three.js b/build/Three.js index 664189dfbb83e..1e7bc33c21667 100755 --- a/build/Three.js +++ b/build/Three.js @@ -549,10 +549,10 @@ THREE.MeshCollider=function(b,c){this.mesh=b;this.box=c;this.numFaces=this.mesh. THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,e,f,g,k=0;c=0;for(e=this.colliders.length;ck?this.hits.push(g):this.hits.unshift(g),k=f;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.distc.length)return null;return c[e]}; THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,k=0;k=m*g))return Number.MAX_VALUE;h/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(h);m.addSelf(b.origin);Math.abs(k.x)>Math.abs(k.y)?Math.abs(k.x)> -Math.abs(k.z)?(b=m.y-c.y,k=e.y-c.y,g=f.y-c.y,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,k=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(k.y)>Math.abs(k.z)?(b=m.x-c.x,k=e.x-c.x,g=f.x-c.x,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,k=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y);c=k*f-e*g;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-m*g)*c;if(!(f>=0))return Number.MAX_VALUE;c*=k*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return h}; +THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,k=0;k=m*g))return Number.MAX_VALUE;h/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(h);m.addSelf(b.origin);Math.abs(k.x)> +Math.abs(k.y)?Math.abs(k.x)>Math.abs(k.z)?(b=m.y-c.y,k=e.y-c.y,g=f.y-c.y,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,k=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(k.y)>Math.abs(k.z)?(b=m.x-c.x,k=e.x-c.x,g=f.x-c.x,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,k=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y);c=k*f-e*g;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-m*g)*c;if(!(f>=0))return Number.MAX_VALUE;c*=k*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return h}; THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var e=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,e);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);e.multiplyVector3(f.origin);e.rotateAxis(f.direction);f.direction.normalize();return f}; THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,g=0,k=0,h=0,m=0,n=0,o=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,o=!1,h=1);e.origin.yc.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y, o=!1,m=1);e.origin.zc.max.z&&(k=c.max.z-e.origin.z,k/=e.direction.z,o=!1,n=1);if(o)return-1;o=0;g>f&&(o=1,f=g);k>f&&(o=2,f=k);switch(o){case 0:m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(h,0,0);break;case 1:h=e.origin.x+e.direction.x*f;if(hc.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z* diff --git a/build/custom/ThreeExtras.js b/build/custom/ThreeExtras.js index fcd7b71440459..b89a735dcae23 100644 --- a/build/custom/ThreeExtras.js +++ b/build/custom/ThreeExtras.js @@ -1,10 +1,10 @@ // ThreeExtras.js r41/ROME - http://github.com/mrdoob/three.js -THREE.ColorUtils={adjustHSV:function(a,c,b,e){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.ColorUtils.clamp(f.h+c,0,1);f.s=THREE.ColorUtils.clamp(f.s+b,0,1);f.v=THREE.ColorUtils.clamp(f.v+e,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,c){var b=a.r,e=a.g,f=a.b,h=Math.max(Math.max(b,e),f),g=Math.min(Math.min(b,e),f);if(g==h)g=b=0;else{var k=h-g,g=k/h,b=b==h?(e-f)/k:e==h?2+(f-b)/k:4+(b-e)/k;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=g;c.v=h;return c}, +THREE.ColorUtils={adjustHSV:function(a,c,b,f){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.ColorUtils.clamp(e.h+c,0,1);e.s=THREE.ColorUtils.clamp(e.s+b,0,1);e.v=THREE.ColorUtils.clamp(e.v+f,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,c){var b=a.r,f=a.g,e=a.b,h=Math.max(Math.max(b,f),e),g=Math.min(Math.min(b,f),e);if(g==h)g=b=0;else{var k=h-g,g=k/h,b=b==h?(f-e)/k:f==h?2+(e-b)/k:4+(b-f)/k;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=g;c.v=h;return c}, clamp:function(a,c,b){return ab?b:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,e=a.vertices.length,f=b?c.geometry:c,h=a.vertices,g=f.vertices,k=a.faces,j=f.faces,m=a.faceVertexUvs[0],f=f.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var l=0,n=g.length;l 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;\nvoid main() {\ngl_FragColor = vec4( 1.0 );\nvec4 mColor = vec4( uDiffuseColor, uOpacity );\nvec4 mSpecular = vec4( uSpecularColor, 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 = gl_FragColor * texture2D( tAO, vUv );\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\nvec4 pointTotal = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = vec4( 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 + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );\n}\n#endif\nvec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirTotal;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointTotal;\n#endif\ngl_FragColor = gl_FragColor * totalLight;\n}", @@ -13,145 +13,145 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(h=25);f=(h-1)*0.5;b=Array(h);for(c=e=0;c25&&(h=25);e=(h-1)*0.5;b=Array(h);for(c=f=0;c1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+p),e=e<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=f[0]+(h[0]-f[0])*e,b.y=f[1]+(h[1]-f[1])*e,b.z=f[2]+(h[2]-f[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",p,g.index-1).pos,this.points[1]=f,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",p,k.index+1).pos,e=e*0.33+0.33,f=this.interpolateCatmullRom(this.points,e),b.x=f[0],b.y=f[1],b.z=f[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(b=== -"rot")THREE.Quaternion.slerp(f,h,a.quaternion,e);else if(b==="scl")b=a.scale,b.x=f[0]+(h[0]-f[0])*e,b.y=f[1]+(h[1]-f[1])*e,b.z=f[2]+(h[2]-f[2])*e}}if(this.JITCompile&&l[0][m]===void 0){this.hierarchy[0].update(void 0,!0);for(p=0;pa.length-2?h:h+1;b[3]=h>a.length-3?h:h+2;h=a[b[0]];k=a[b[1]];j=a[b[2]];m=a[b[3]];b=f*f;g=f*b;e[0]=this.interpolate(h[0],k[0],j[0],m[0],f,b,g);e[1]=this.interpolate(h[1],k[1],j[1],m[1],f,b,g);e[2]=this.interpolate(h[2],k[2],j[2],m[2],f,b,g);return e}; -THREE.Animation.prototype.interpolate=function(a,c,b,e,f,h,g){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*g+(-3*(c-b)-2*a-e)*h+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=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+e.length;b>=0;b--)if(e[b][a]!==void 0)return e[b];return this.data.hierarchy[c].keys[e.length-1]}; -THREE.FirstPersonCamera=function(a){function c(a,e){return function(){e.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);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=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==void 0)this.movementSpeed= +n)}j.prevKey[b]=g;j.nextKey[b]=k}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;f=(n-g.time)/(k.time-g.time);e=g[b];h=k[b];if(f<0||f>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+p),f=f<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=e[0]+(h[0]-e[0])*f,b.y=e[1]+(h[1]-e[1])*f,b.z=e[2]+(h[2]-e[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",p,g.index-1).pos,this.points[1]=e,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",p,k.index+1).pos,f=f*0.33+0.33,e=this.interpolateCatmullRom(this.points,f),b.x=e[0],b.y=e[1],b.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,f,0)}else if(b=== +"rot")THREE.Quaternion.slerp(e,h,a.quaternion,f);else if(b==="scl")b=a.scale,b.x=e[0]+(h[0]-e[0])*f,b.y=e[1]+(h[1]-e[1])*f,b.z=e[2]+(h[2]-e[2])*f}}if(this.JITCompile&&l[0][m]===void 0){this.hierarchy[0].update(void 0,!0);for(p=0;pa.length-2?h:h+1;b[3]=h>a.length-3?h:h+2;h=a[b[0]];k=a[b[1]];j=a[b[2]];m=a[b[3]];b=e*e;g=e*b;f[0]=this.interpolate(h[0],k[0],j[0],m[0],e,b,g);f[1]=this.interpolate(h[1],k[1],j[1],m[1],e,b,g);f[2]=this.interpolate(h[2],k[2],j[2],m[2],e,b,g);return f}; +THREE.Animation.prototype.interpolate=function(a,c,b,f,e,h,g){a=(b-a)*0.5;f=(f-c)*0.5;return(2*(c-b)+a+f)*g+(-3*(c-b)-2*a-f)*h+a*e+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var f=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+f.length;b>=0;b--)if(f[b][a]!==void 0)return f[b];return this.data.hierarchy[c].keys[f.length-1]}; +THREE.FirstPersonCamera=function(a){function c(a,c){return function(){c.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);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=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==void 0)this.movementSpeed= a.movementSpeed;if(a.lookSpeed!==void 0)this.lookSpeed=a.lookSpeed;if(a.noFly!==void 0)this.noFly=a.noFly;if(a.lookVertical!==void 0)this.lookVertical=a.lookVertical;if(a.autoForward!==void 0)this.autoForward=a.autoForward;if(a.activeLook!==void 0)this.activeLook=a.activeLook;if(a.heightSpeed!==void 0)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==void 0)this.heightCoef=a.heightCoef;if(a.heightMin!==void 0)this.heightMin=a.heightMin;if(a.heightMax!==void 0)this.heightMax=a.heightMax;if(a.constrainVertical!== void 0)this.constrainVertical=a.constrainVertical;if(a.verticalMin!==void 0)this.verticalMin=a.verticalMin;if(a.verticalMax!==void 0)this.verticalMax=a.verticalMax;if(a.domElement!==void 0)this.domElement=a.domElement}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.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(a){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.mouseX=a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};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 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}};this.update=function(){var a=(new Date).getTime();this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;if(!this.freeze){this.autoSpeedFactor= -this.heightSpeed?this.tdiff*((this.position.ythis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var e=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(e+this.autoSpeedFactor));this.moveBackward&&this.translateZ(e);this.moveLeft&&this.translateX(-e);this.moveRight&&this.translateX(e);e=this.tdiff*this.lookSpeed;this.activeLook||(e=0);this.lon+=this.mouseX*e;this.lookVertical&& -(this.lat-=this.mouseY*e);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;var a=this.target.position,c=this.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);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= -(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;a=this.target.position;c=this.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown), +this.heightSpeed?this.tdiff*((this.position.ythis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.translateZ(c);this.moveLeft&&this.translateX(-c);this.moveRight&&this.translateX(c);c=this.tdiff*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;var a=this.target.position,e=this.position;a.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=e.y+100*Math.cos(this.phi);a.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta)}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;if(this.constrainVertical)this.phi= +(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;a=this.target.position;e=this.position;a.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=e.y+100*Math.cos(this.phi);a.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown), !1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype; THREE.FirstPersonCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))}; -THREE.PathCamera=function(a){function c(a,b,c,e){var h={name:c,fps:0.6,length:e,hierarchy:[]},f,g=b.getControlPointsArray(),k=b.getLength(),j=g.length,w=0;f=j-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:e,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f=0?e:e+f;e=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var k=g[1]-g[0];this.phi= -TWEEN.Easing.Quadratic.EaseInOut(((this.phi-e[0])*(g[1]-g[0])/(e[1]-e[0])+g[0]-g[0])/k)*k+g[0];e=this.horizontalAngleMap.srcRange;g=this.horizontalAngleMap.dstRange;k=g[1]-g[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-e[0])*(g[1]-g[0])/(e[1]-e[0])+g[0]-g[0])/k)*k+g[0];e=this.target.position;e.x=100*Math.sin(this.phi)*Math.cos(this.theta);e.y=100*Math.cos(this.phi);e.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,a,b,c)};this.onMouseMove=function(a){this.mouseX= +window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var e=Math.PI*2,h=Math.PI/180;this.update=function(a,b,c){var f,g;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;f=this.phi%e;this.phi=f>=0?f:f+e;f=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var k=g[1]-g[0];this.phi= +TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(g[1]-g[0])/(f[1]-f[0])+g[0]-g[0])/k)*k+g[0];f=this.horizontalAngleMap.srcRange;g=this.horizontalAngleMap.dstRange;k=g[1]-g[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(g[1]-g[0])/(f[1]-f[0])+g[0]-g[0])/k)*k+g[0];f=this.target.position;f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,a,b,c)};this.onMouseMove=function(a){this.mouseX= a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};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}),g=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.CubeGeometry(10,10,20),j=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(j,g);a.position.set(0,10,0);this.animation= -c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(a,b){return function(){b.apply(a,arguments)}}(this,this.onMouseMove), +c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(a,b){return function(){b.apply(a,arguments)}}(this,this.onMouseMove), !1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; -THREE.FlyCamera=function(a){function c(a,e){return function(){e.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.domElement=document;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==void 0)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==void 0)this.dragToLook=a.dragToLook;if(a.autoForward!==void 0)this.autoForward= +THREE.FlyCamera=function(a){function c(a,c){return function(){c.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.domElement=document;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==void 0)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==void 0)this.dragToLook=a.dragToLook;if(a.autoForward!==void 0)this.autoForward= a.autoForward;if(a.domElement!==void 0)this.domElement=a.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier= 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}}; this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break; -case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var e=this.getContainerDimensions(),c=e.size[0]/2,h=e.size[1]/2;this.moveState.yawLeft=-(a.clientX-e.offset[0]-c)/c;this.moveState.pitchDown=(a.clientY- -e.offset[1]-h)/h;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(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;var a=this.tdiff*this.movementSpeed,e=this.tdiff* -this.rollSpeed;this.translateX(this.moveVector.x*a);this.translateY(this.moveVector.y*a);this.translateZ(this.moveVector.z*a);this.tmpQuaternion.set(this.rotationVector.x*e,this.rotationVector.y*e,this.rotationVector.z*e,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var a=this.moveState.forward|| +case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var c=this.getContainerDimensions(),e=c.size[0]/2,h=c.size[1]/2;this.moveState.yawLeft=-(a.clientX-c.offset[0]-e)/e;this.moveState.pitchDown=(a.clientY- +c.offset[1]-h)/h;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(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;var a=this.tdiff*this.movementSpeed,c=this.tdiff* +this.rollSpeed;this.translateX(this.moveVector.x*a);this.translateY(this.moveVector.y*a);this.translateZ(this.moveVector.z*a);this.tmpQuaternion.set(this.rotationVector.x*c,this.rotationVector.y*c,this.rotationVector.z*c,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var a=this.moveState.forward|| this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!= document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);window.addEventListener("keydown",c(this,this.keydown),!1);window.addEventListener("keyup",c(this, this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype; -THREE.RollCamera=function(a,c,b,e){THREE.Camera.call(this,a,c,b,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var f=new THREE.Vector3,h=new THREE.Vector3,g=new THREE.Vector3,k=new THREE.Matrix4,j=!1,m=1,l=0,n=0,o=0,p=0,u=0,v=window.innerWidth/2,x=window.innerHeight/2;this.update= +THREE.RollCamera=function(a,c,b,f){THREE.Camera.call(this,a,c,b,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var e=new THREE.Vector3,h=new THREE.Vector3,g=new THREE.Vector3,k=new THREE.Matrix4,j=!1,m=1,l=0,n=0,o=0,p=0,u=0,v=window.innerWidth/2,x=window.innerHeight/2;this.update= function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.delta=(a-this.lastUpdate)/1E3;this.lastUpdate=a;this.mouseLook&&(a=this.delta*this.lookSpeed,this.rotateHorizontally(a*p),this.rotateVertically(a*u));a=this.delta*this.movementSpeed;this.translateZ(a*(l>0||this.autoForward&&!(l<0)?1:l));this.translateX(a*n);this.translateY(a*o);j&&(this.roll+=this.rollSpeed*this.delta*m);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); -else if(this.forward.y1?e.normalize():e.z=Math.sqrt(1-c*c);f=this.position.clone().subSelf(this.target.position);c=this.up.clone().setLength(e.y);c.addSelf(this.up.clone().crossSelf(f).setLength(e.x));c.addSelf(f.setLength(e.z));return c}; -this.rotateCamera=function(){var a=Math.acos(h.dot(g)/h.length()/g.length());if(a){var b=(new THREE.Vector3).cross(h,g).normalize(),e=new THREE.Quaternion;a*=this.rotateSpeed;e.setFromAxisAngle(b,-a);e.multiplyVector3(f);e.multiplyVector3(this.up);e.multiplyVector3(g);this.staticMoving?h=g:(e.setFromAxisAngle(b,a*(this.dynamicDampingFactor-1)),e.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(j.y-k.y)*this.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),this.staticMoving?k=j:k.y+=(j.y-k.y)*this.dynamicDampingFactor)}; -this.panCamera=function(){var a=l.clone().subSelf(m);if(a.lengthSq()){a.multiplyScalar(f.length()*this.panSpeed);var b=f.clone().crossSelf(this.up).setLength(a.x);b.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(b);this.target.position.addSelf(b);this.staticMoving?m=l:m.addSelf(a.sub(l,m).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), -f.lengthSq()1?c.normalize():c.z=Math.sqrt(1-g*g);e=this.position.clone().subSelf(this.target.position);g=this.up.clone().setLength(c.y);g.addSelf(this.up.clone().crossSelf(e).setLength(c.x));g.addSelf(e.setLength(c.z));return g}; +this.rotateCamera=function(){var a=Math.acos(h.dot(g)/h.length()/g.length());if(a){var b=(new THREE.Vector3).cross(h,g).normalize(),c=new THREE.Quaternion;a*=this.rotateSpeed;c.setFromAxisAngle(b,-a);c.multiplyVector3(e);c.multiplyVector3(this.up);c.multiplyVector3(g);this.staticMoving?h=g:(c.setFromAxisAngle(b,a*(this.dynamicDampingFactor-1)),c.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(j.y-k.y)*this.zoomSpeed;a!==1&&a>0&&(e.multiplyScalar(a),this.staticMoving?k=j:k.y+=(j.y-k.y)*this.dynamicDampingFactor)}; +this.panCamera=function(){var a=l.clone().subSelf(m);if(a.lengthSq()){a.multiplyScalar(e.length()*this.panSpeed);var b=e.clone().crossSelf(this.up).setLength(a.x);b.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(b);this.target.position.addSelf(b);this.staticMoving?m=l:m.addSelf(a.sub(l,m).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), +e.lengthSq()0){g(0,0,-l-(h||0));for(j=a;j0){g(0,0,l+ -(f||0));for(j=a+a/2;j<2*a;j++)k.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j0){g(0,0,-l-(h||0));for(j=a;j0){g(0,0,l+ +(e||0));for(j=a+a/2;j<2*a;j++)k.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,k,o)))-1);m.push(l)}c.push(m)}for(var p,u,v,f=c.length,b=0;b0)for(e=0;e1&&(p= +THREE.SphereGeometry=function(a,c,b){THREE.Geometry.call(this);for(var a=a||50,f,e=Math.PI,h=Math.max(3,c||8),g=Math.max(2,b||6),c=[],b=0;b0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,k,o)))-1);m.push(l)}c.push(m)}for(var p,u,v,e=c.length,b=0;b0)for(f=0;f1&&(p= this.vertices[g].position.clone(),u=this.vertices[j].position.clone(),v=this.vertices[m].position.clone(),p.normalize(),u.normalize(),v.normalize(),this.faces.push(new THREE.Face3(g,j,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)])),this.faceVertexUvs[0].push([l,n,x]))}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){THREE.Geometry.call(this);this.parameters=c||{};this.set(a)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; -THREE.TextGeometry.prototype.set=function(a,c){function b(a,b,e){u.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,e)))}function e(a,b,e,c){u.faces.push(new THREE.Face4(a,b,e,c))}this.text=a;var c=c||this.parameters,f=c.height!==void 0?c.height:50,h=c.curveSegments!==void 0?c.curveSegments:4,g=c.font!==void 0?c.font:"helvetiker",k=c.weight!==void 0?c.weight:"normal",j=c.style!==void 0?c.style:"normal",m=c.bezelThickness!==void 0?c.bezelThickness:10,l=c.bezelSize!==void 0?c.bezelSize:8,n=c.bezelEnabled!== -void 0?c.bezelEnabled:!1;THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=h;THREE.FontUtils.face=g;THREE.FontUtils.weight=k;THREE.FontUtils.style=j;THREE.FontUtils.bezelSize=l;var k=THREE.FontUtils.drawText(a),h=k.points,o=k.faces,g=k.contour,p=k.bezel,u=this;u.vertices=[];u.faces=[];for(var v,j=h.length,x=o.length,l=p.length,k=0;k0;){if(y){if(y.equals(g[k])){y=null;continue}}else y=g[k];m=j*2+k;o=m-1;e(m,o,o+l,m+l);for(n=0;n0;){if(y){if(y.equals(g[k])){y=null;continue}}else y=g[k];for(n=0;n0;){if(y){if(y.equals(g[k])){y=null;continue}}else y=g[k];m=j*2+k;o=m-1;f(m,o,o+l,m+l);for(n=0;n0;){if(y){if(y.equals(g[k])){y=null;continue}}else y=g[k];for(n=0;n0&&k.push({shape:f,holes:e}),f=n,e=[]):e.push(n):this.Triangulate.area(n)<0?(k.push({shape:n,holes:e}),e=[]):e.push(n);b++}l&&k.push({shape:f,holes:e})}var o,p,u, -v,x,y;h=[];for(g=0;g=0?p-1:f.length-1;var n=o-1>=0?o-1:l.length-1,w=[];w.push(l[o]);w.push(f[p]);w.push(f[b]);u=this.Triangulate.area(w);var t=[];t.push(l[o]);t.push(l[n]);t.push(f[p]);x=this.Triangulate.area(t);v=p;y=o;p+=1;o+=-1;p<0&&(p+=f.length);p%=f.length;o<0&&(o+=l.length);o%=f.length;b=p- -1>=0?p-1:f.length-1;n=o-1>=0?o-1:l.length-1;w=[];w.push(l[o]);w.push(f[p]);w.push(f[b]);w=this.Triangulate.area(w);t=[];t.push(l[o]);t.push(l[n]);t.push(f[p]);t=this.Triangulate.area(t);u+x>w+t&&(p=v,o=y,p<0&&(p+=f.length),p%=f.length,o<0&&(o+=l.length),o%=f.length,b=p-1>=0?p-1:f.length-1,n=o-1>=0?o-1:l.length-1);u=f.slice(0,p);x=f.slice(p);v=l.slice(o);y=l.slice(0,o);h.push(l[o]);h.push(f[p]);h.push(f[b]);h.push(l[o]);h.push(l[n]);h.push(f[p]);f=u.concat(v).concat(y).concat(x)}j.shape=f}o=[];p=[]; -for(g=m=0;g=0;){if(m){if(m.equals(b[a])){m=null;j=this.Triangulate.area(e)>0;g.push(j);h.push(k.divideScalar(e.length));e=[];k=new THREE.Vector2;continue}}else m=b[a];k.addSelf(b[a]);e.push(b[a])}a=b.length;e=0;for(var l;--a>=0;)j=b[a],k=h[e],j=j.clone().subSelf(k), -l=this.bezelSize/j.length(),g[e]?l+=1:l=1-l,l=j.multiplyScalar(l).addSelf(k),f.unshift(l),m?m.equals(b[a])&&(m=null,e++):m=b[a];c.bezel=f;return c},b2p0:function(a,c){var b=1-a;return b*b*c},b2p1:function(a,c){return 2*(1-a)*a*c},b2p2:function(a,c){return a*a*c},b2:function(a,c,b,e){return this.b2p0(a,c)+this.b2p1(a,b)+this.b2p2(a,e)},b3p0:function(a,c){var b=1-a;return b*b*b*c},b3p1:function(a,c){var b=1-a;return 3*b*b*a*c},b3p2:function(a,c){return 3*(1-a)*a*a*c},b3p3:function(a,c){return a*a*a* -c},b3:function(a,c,b,e,f){return this.b3p0(a,c)+this.b3p1(a,b)+this.b3p2(a,e)+this.b3p3(a,f)},extractGlyphPoints:function(a,c,b,e){var f=[],h,g,k,j,m,l,n,o,p,u,v=c.glyphs[a]||c.glyphs[ctxt.options.fallbackCharacter];if(v){if(v.o){c=v._cachedOutline||(v._cachedOutline=v.o.split(" "));k=c.length;for(a=0;a0)for(m=0;m2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return h}j=m;f<=j&&(j=0);m=j+1;f<=m&&(m=0);l=m+1;f<=l&&(l=0);var o;a:{o=a;var p=j,u=m,v=l,x=f,y=g,w=void 0,t=void 0,z=void 0, +{points:a,faces:[]};for(var b,f,e,h,g,k=[],j=0;j0&&k.push({shape:e,holes:f}),e=n,f=[]):f.push(n):this.Triangulate.area(n)<0?(k.push({shape:n,holes:f}),f=[]):f.push(n);b++}l&&k.push({shape:e,holes:f})}var o,p,u, +v,x,y;h=[];for(g=0;g=0?p-1:e.length-1;var n=o-1>=0?o-1:l.length-1,w=[];w.push(l[o]);w.push(e[p]);w.push(e[b]);u=this.Triangulate.area(w);var t=[];t.push(l[o]);t.push(l[n]);t.push(e[p]);x=this.Triangulate.area(t);v=p;y=o;p+=1;o+=-1;p<0&&(p+=e.length);p%=e.length;o<0&&(o+=l.length);o%=e.length;b=p- +1>=0?p-1:e.length-1;n=o-1>=0?o-1:l.length-1;w=[];w.push(l[o]);w.push(e[p]);w.push(e[b]);w=this.Triangulate.area(w);t=[];t.push(l[o]);t.push(l[n]);t.push(e[p]);t=this.Triangulate.area(t);u+x>w+t&&(p=v,o=y,p<0&&(p+=e.length),p%=e.length,o<0&&(o+=l.length),o%=e.length,b=p-1>=0?p-1:e.length-1,n=o-1>=0?o-1:l.length-1);u=e.slice(0,p);x=e.slice(p);v=l.slice(o);y=l.slice(0,o);h.push(l[o]);h.push(e[p]);h.push(e[b]);h.push(l[o]);h.push(l[n]);h.push(e[p]);e=u.concat(v).concat(y).concat(x)}j.shape=e}o=[];p=[]; +for(g=m=0;g=0;){if(m){if(m.equals(b[a])){m=null;j=this.Triangulate.area(f)>0;g.push(j);h.push(k.divideScalar(f.length));f=[];k=new THREE.Vector2;continue}}else m=b[a];k.addSelf(b[a]);f.push(b[a])}a=b.length;f=0;for(var l;--a>=0;)j=b[a],k=h[f],j=j.clone().subSelf(k), +l=this.bezelSize/j.length(),g[f]?l+=1:l=1-l,l=j.multiplyScalar(l).addSelf(k),e.unshift(l),m?m.equals(b[a])&&(m=null,f++):m=b[a];c.bezel=e;return c},b2p0:function(a,c){var b=1-a;return b*b*c},b2p1:function(a,c){return 2*(1-a)*a*c},b2p2:function(a,c){return a*a*c},b2:function(a,c,b,f){return this.b2p0(a,c)+this.b2p1(a,b)+this.b2p2(a,f)},b3p0:function(a,c){var b=1-a;return b*b*b*c},b3p1:function(a,c){var b=1-a;return 3*b*b*a*c},b3p2:function(a,c){return 3*(1-a)*a*a*c},b3p3:function(a,c){return a*a*a* +c},b3:function(a,c,b,f,e){return this.b3p0(a,c)+this.b3p1(a,b)+this.b3p2(a,f)+this.b3p3(a,e)},extractGlyphPoints:function(a,c,b,f){var e=[],h,g,k,j,m,l,n,o,p,u,v=c.glyphs[a]||c.glyphs[ctxt.options.fallbackCharacter];if(v){if(v.o){c=v._cachedOutline||(v._cachedOutline=v.o.split(" "));k=c.length;for(a=0;a0)for(m=0;m2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return k;return h}j=m;e<=j&&(j=0);m=j+1;e<=m&&(m=0);l=m+1;e<=l&&(l=0);var o;a:{o=a;var p=j,u=m,v=l,x=e,y=g,w=void 0,t=void 0,z=void 0, A=void 0,E=void 0,F=void 0,G=void 0,D=void 0,K=void 0,t=o[y[p]].x,z=o[y[p]].y,A=o[y[u]].x,E=o[y[u]].y,F=o[y[v]].x,G=o[y[v]].y;if(1.0E-10>(A-t)*(G-z)-(E-z)*(F-t))o=!1;else{for(w=0;w=0&&J>=0&&H>=0){o=!1;break a}}o=!0}}if(o){n= -g[j];o=g[m];p=g[l];h.push(a[n]);h.push(a[o]);h.push(a[p]);k.push([g[j],g[m],g[l]]);j=m;for(l=m+1;l>7)-127;e|=(h&127)<<16|f<<8;if(e==0&&j==-127)return 0;return(1-2*(g>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,j)}function f(a,b){var c=l(a,b),e=l(a,b+1),h=l(a,b+2);return(l(a,b+3)<<24)+(h<<16)+(e<<8)+c}function j(a,b){var c=l(a,b);return(l(a,b+1)<<8)+c}function m(a,b){var c=l(a,b);return c>127?c-256:c}function l(a, -b){return a.charCodeAt(b)&255}function n(b){var c,e,h;c=f(a,b);e=f(a,b+E);h=f(a,b+F);b=j(a,b+G);THREE.BinaryLoader.prototype.f3(y,c,e,h,b)}function o(b){var c,e,h,g,m,l;c=f(a,b);e=f(a,b+E);h=f(a,b+F);g=j(a,b+G);m=f(a,b+D);l=f(a,b+K);b=f(a,b+I);THREE.BinaryLoader.prototype.f3n(y,z,c,e,h,g,m,l,b)}function p(b){var c,e,h,g;c=f(a,b);e=f(a,b+C);h=f(a,b+J);g=f(a,b+L);b=j(a,b+H);THREE.BinaryLoader.prototype.f4(y,c,e,h,g,b)}function u(b){var c,e,h,g,m,l,n,o;c=f(a,b);e=f(a,b+C);h=f(a,b+J);g=f(a,b+L);m=j(a, -b+H);l=f(a,b+N);n=f(a,b+O);o=f(a,b+B);b=f(a,b+P);THREE.BinaryLoader.prototype.f4n(y,z,c,e,h,g,m,l,n,o,b)}function v(b){var c,e;c=f(a,b);e=f(a,b+M);b=f(a,b+R);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],A[c*2],A[c*2+1],A[e*2],A[e*2+1],A[b*2],A[b*2+1])}function x(b){var c,e,h;c=f(a,b);e=f(a,b+S);h=f(a,b+Y);b=f(a,b+Z);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],A[c*2],A[c*2+1],A[e*2],A[e*2+1],A[h*2],A[h*2+1],A[b*2],A[b*2+1])}var y=this,w=0,t,z=[],A=[],E,F,G,D,K,I,C,J,L,H,N,O,B,P,M,R, -S,Y,Z,T,U,V,W,X,Q;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,e,b);t={signature:a.substr(w,8),header_bytes:l(a,w+8),vertex_coordinate_bytes:l(a,w+9),normal_coordinate_bytes:l(a,w+10),uv_coordinate_bytes:l(a,w+11),vertex_index_bytes:l(a,w+12),normal_index_bytes:l(a,w+13),uv_index_bytes:l(a,w+14),material_index_bytes:l(a,w+15),nvertices:f(a,w+16),nnormals:f(a,w+16+4),nuvs:f(a,w+16+8),ntri_flat:f(a,w+16+12),ntri_smooth:f(a,w+16+16),ntri_flat_uv:f(a,w+16+20),ntri_smooth_uv:f(a,w+ -16+24),nquad_flat:f(a,w+16+28),nquad_smooth:f(a,w+16+32),nquad_flat_uv:f(a,w+16+36),nquad_smooth_uv:f(a,w+16+40)};w+=t.header_bytes;E=t.vertex_index_bytes;F=t.vertex_index_bytes*2;G=t.vertex_index_bytes*3;D=t.vertex_index_bytes*3+t.material_index_bytes;K=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;I=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;C=t.vertex_index_bytes;J=t.vertex_index_bytes*2;L=t.vertex_index_bytes*3;H=t.vertex_index_bytes*4;N=t.vertex_index_bytes* +THREE.JSONLoader.prototype.load=function(a){var c=this,b=a.model,f=a.callback,e=a.texture_path?a.texture_path:this.extractUrlbase(b),a=new Worker(b);a.onmessage=function(a){c.createModel(a.data,f,e);c.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())}; +THREE.JSONLoader.prototype.createModel=function(a,c,b){var f=new THREE.Geometry,e=a.scale!==void 0?1/a.scale:1;this.init_materials(f,a.materials,b);(function(b){if(a.version===void 0||a.version!=2)console.error("Deprecated file format.");else{var c,e,j,m,l,n,o,p,u,v,x,y,w,t,z=a.faces;n=a.vertices;var A=a.normals,E=a.colors,F=0;for(c=0;c>7)-127;e|=(g&127)<<16|f<<8;if(e==0&&j==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,j)}function e(a,b){var c=l(a,b),f=l(a,b+1),g=l(a,b+2);return(l(a,b+3)<<24)+(g<<16)+(f<<8)+c}function j(a,b){var c=l(a,b);return(l(a,b+1)<<8)+c}function m(a,b){var c=l(a,b);return c>127?c-256:c}function l(a, +b){return a.charCodeAt(b)&255}function n(b){var c,f,g;c=e(a,b);f=e(a,b+E);g=e(a,b+F);b=j(a,b+G);THREE.BinaryLoader.prototype.f3(y,c,f,g,b)}function o(b){var c,f,g,h,m,l;c=e(a,b);f=e(a,b+E);g=e(a,b+F);h=j(a,b+G);m=e(a,b+D);l=e(a,b+K);b=e(a,b+I);THREE.BinaryLoader.prototype.f3n(y,z,c,f,g,h,m,l,b)}function p(b){var c,f,g,h;c=e(a,b);f=e(a,b+C);g=e(a,b+J);h=e(a,b+L);b=j(a,b+H);THREE.BinaryLoader.prototype.f4(y,c,f,g,h,b)}function u(b){var c,f,g,h,m,l,n,o;c=e(a,b);f=e(a,b+C);g=e(a,b+J);h=e(a,b+L);m=j(a, +b+H);l=e(a,b+N);n=e(a,b+O);o=e(a,b+B);b=e(a,b+P);THREE.BinaryLoader.prototype.f4n(y,z,c,f,g,h,m,l,n,o,b)}function v(b){var c,f;c=e(a,b);f=e(a,b+M);b=e(a,b+R);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],A[c*2],A[c*2+1],A[f*2],A[f*2+1],A[b*2],A[b*2+1])}function x(b){var c,f,g;c=e(a,b);f=e(a,b+S);g=e(a,b+Y);b=e(a,b+Z);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],A[c*2],A[c*2+1],A[f*2],A[f*2+1],A[g*2],A[g*2+1],A[b*2],A[b*2+1])}var y=this,w=0,t,z=[],A=[],E,F,G,D,K,I,C,J,L,H,N,O,B,P,M,R, +S,Y,Z,T,U,V,W,X,Q;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,f,b);t={signature:a.substr(w,8),header_bytes:l(a,w+8),vertex_coordinate_bytes:l(a,w+9),normal_coordinate_bytes:l(a,w+10),uv_coordinate_bytes:l(a,w+11),vertex_index_bytes:l(a,w+12),normal_index_bytes:l(a,w+13),uv_index_bytes:l(a,w+14),material_index_bytes:l(a,w+15),nvertices:e(a,w+16),nnormals:e(a,w+16+4),nuvs:e(a,w+16+8),ntri_flat:e(a,w+16+12),ntri_smooth:e(a,w+16+16),ntri_flat_uv:e(a,w+16+20),ntri_smooth_uv:e(a,w+ +16+24),nquad_flat:e(a,w+16+28),nquad_smooth:e(a,w+16+32),nquad_flat_uv:e(a,w+16+36),nquad_smooth_uv:e(a,w+16+40)};w+=t.header_bytes;E=t.vertex_index_bytes;F=t.vertex_index_bytes*2;G=t.vertex_index_bytes*3;D=t.vertex_index_bytes*3+t.material_index_bytes;K=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;I=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;C=t.vertex_index_bytes;J=t.vertex_index_bytes*2;L=t.vertex_index_bytes*3;H=t.vertex_index_bytes*4;N=t.vertex_index_bytes* 4+t.material_index_bytes;O=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes;B=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*2;P=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;M=t.uv_index_bytes;R=t.uv_index_bytes*2;S=t.uv_index_bytes;Y=t.uv_index_bytes*2;Z=t.uv_index_bytes*3;b=t.vertex_index_bytes*3+t.material_index_bytes;Q=t.vertex_index_bytes*4+t.material_index_bytes;T=t.ntri_flat*b;U=t.ntri_smooth*(b+t.normal_index_bytes*3);V=t.ntri_flat_uv* -(b+t.uv_index_bytes*3);W=t.ntri_smooth_uv*(b+t.normal_index_bytes*3+t.uv_index_bytes*3);X=t.nquad_flat*Q;b=t.nquad_smooth*(Q+t.normal_index_bytes*4);Q=t.nquad_flat_uv*(Q+t.uv_index_bytes*4);w+=function(b){for(var e,f,h,j=t.vertex_coordinate_bytes*3,k=b+t.nvertices*j;b1&&(K=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(E,K);object.name=p;object.position.set(t[0],t[1],t[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=w.visible;B.scene.addObject(object);B.objects[p]=object;w.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),B.scene.collisions.colliders.push(a)); if(w.castsShadow)a=new THREE.ShadowVolume(E),B.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;w.trigger&&w.trigger.toLowerCase()!="none"&&(a={type:w.trigger,object:w},B.triggers[object.name]=a)}}else t=w.position,r=w.rotation,q=w.quaternion,s=w.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(t[0],t[1],t[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], s[1],s[2]),object.visible=w.visible!==void 0?w.visible:!1,B.scene.addObject(object),B.objects[p]=object,B.empties[p]=object,w.trigger&&w.trigger.toLowerCase()!="none"&&(a={type:w.trigger,object:w},B.triggers[object.name]=a)}function j(a){return function(c){B.geometries[a]=c;k();L-=1;b.onLoadComplete();l()}}function m(a){return function(b){B.geometries[a]=b}}function l(){b.callbackProgress({totalModels:N,totalTextures:O,loadedModels:N-L,loadedTextures:O-H},B);b.onLoadProgress();L==0&&H==0&&c(B)}var n, @@ -160,25 +160,25 @@ z[1],z[2]);P&&B.scene.scale.set(P[0],P[1],P[2]);(a||z||P)&&B.scene.updateMatrix( F=v.color!==void 0?v.color:16777215,z=v.intensity!==void 0?v.intensity:1,v.type=="directional"?(t=v.direction,I=new THREE.DirectionalLight(F,z),I.position.set(t[0],t[1],t[2]),I.position.normalize()):v.type=="point"?(t=v.position,d=v.distance,I=new THREE.PointLight(F,z,d),I.position.set(t[0],t[1],t[2])):v.type=="ambient"&&(I=new THREE.AmbientLight(F)),B.scene.addLight(I),B.lights[u]=I;for(x in C.fogs)u=C.fogs[x],u.type=="linear"?G=new THREE.Fog(0,u.near,u.far):u.type=="exp2"&&(G=new THREE.FogExp2(0, u.density)),z=u.color,G.color.setRGB(z[0],z[1],z[2]),B.fogs[x]=G;if(B.cameras&&C.defaults.camera)B.currentCamera=B.cameras[C.defaults.camera];if(B.fogs&&C.defaults.fog)B.scene.fog=B.fogs[C.defaults.fog];z=C.defaults.bgcolor;B.bgColor=new THREE.Color;B.bgColor.setRGB(z[0],z[1],z[2]);B.bgColorAlpha=C.defaults.bgalpha;for(n in C.geometries)if(x=C.geometries[n],x.type=="bin_mesh"||x.type=="ascii_mesh")L+=1,b.onLoadStart();N=L;for(n in C.geometries)x=C.geometries[n],x.type=="cube"?(E=new THREE.CubeGeometry(x.width, x.height,x.depth,x.segmentsWidth,x.segmentsHeight,x.segmentsDepth,null,x.flipped,x.sides),B.geometries[n]=E):x.type=="plane"?(E=new THREE.PlaneGeometry(x.width,x.height,x.segmentsWidth,x.segmentsHeight),B.geometries[n]=E):x.type=="sphere"?(E=new THREE.SphereGeometry(x.radius,x.segmentsWidth,x.segmentsHeight),B.geometries[n]=E):x.type=="cylinder"?(E=new THREE.CylinderGeometry(x.numSegs,x.topRad,x.botRad,x.height,x.topOffset,x.botOffset),B.geometries[n]=E):x.type=="torus"?(E=new THREE.TorusGeometry(x.radius, -x.tube,x.segmentsR,x.segmentsT),B.geometries[n]=E):x.type=="icosahedron"?(E=new THREE.IcosahedronGeometry(x.subdivisions),B.geometries[n]=E):x.type=="bin_mesh"?D.load({model:e(x.url,C.urlBaseType),callback:j(n)}):x.type=="ascii_mesh"?J.load({model:e(x.url,C.urlBaseType),callback:j(n)}):x.type=="embedded_mesh"&&(x=C.embeds[x.id])&&J.createModel(x,m(n),"");for(y in C.textures)if(n=C.textures[y],n.url instanceof Array){H+=n.url.length;for(D=0;D=this.maxCount-3&&k(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&&(j=this.size-1);var o=Math.floor(m-k);o<1&&(o=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var p=Math.floor(l-k);p<1&&(p=1);k=Math.floor(l+k);k>this.size-1&&(k=this.size- -1);for(var u,v,x,y,w,t;n0&&(this.field[x+u]+=y)}}};this.addPlaneX=function(a,c){var f,h,g,k,j,m=this.size,l=this.yd,n=this.zd,o=this.field,p=m*Math.sqrt(a/c);p>m&&(p=m);for(f=0;f0)for(h=0;hl&&(u=l);for(h=0;h0){j=h*n;for(f=0;fsize&&(dist=size);for(g=0;g0){j=zd*g;for(h=0;h=this.maxCount-3&&k(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&&(j=this.size-1);var o=Math.floor(m-k);o<1&&(o=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var p=Math.floor(l-k);p<1&&(p=1);k=Math.floor(l+k);k>this.size-1&&(k=this.size- +1);for(var u,v,x,y,w,t;n0&&(this.field[x+u]+=y)}}};this.addPlaneX=function(a,c){var e,h,g,k,j,m=this.size,l=this.yd,n=this.zd,o=this.field,p=m*Math.sqrt(a/c);p>m&&(p=m);for(e=0;e0)for(h=0;hl&&(u=l);for(h=0;h0){j=h*n;for(e=0;esize&&(dist=size);for(g=0;g0){j=zd*g;for(h=0;hh?this.hits.push(f):this.hits.unshift(f),h=e;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 e=this.rayMesh(a,c[b]);if(e.distc.length)return null;return c[b]}; +THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var c,b,f,e,h=0;c=0;for(b=this.colliders.length;ch?this.hits.push(e):this.hits.unshift(e),h=f;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 f=this.rayMesh(a,c[b]);if(f.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),e=Number.MAX_VALUE,f,h=0;h=k*f))return Number.MAX_VALUE;g/=k;k=THREE.CollisionSystem.__v3;k.copy(a.direction);k.multiplyScalar(g);k.addSelf(a.origin);Math.abs(h.x)>Math.abs(h.y)?Math.abs(h.x)> -Math.abs(h.z)?(a=k.y-c.y,h=b.y-c.y,f=e.y-c.y,k=k.z-c.z,b=b.z-c.z,e=e.z-c.z):(a=k.x-c.x,h=b.x-c.x,f=e.x-c.x,k=k.y-c.y,b=b.y-c.y,e=e.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(a=k.x-c.x,h=b.x-c.x,f=e.x-c.x,k=k.z-c.z,b=b.z-c.z,e=e.z-c.z):(a=k.x-c.x,h=b.x-c.x,f=e.x-c.x,k=k.y-c.y,b=b.y-c.y,e=e.y-c.y);c=h*e-b*f;if(c==0)return Number.MAX_VALUE;c=1/c;e=(a*e-k*f)*c;if(!(e>=0))return Number.MAX_VALUE;c*=h*k-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return g}; -THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,b);var e=THREE.CollisionSystem.__r;e.origin.copy(a.origin);e.direction.copy(a.direction);b.multiplyVector3(e.origin);b.rotateAxis(e.direction);e.direction.normalize();return e}; -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 e=0,f=0,h=0,g=0,k=0,j=0,m=!0;b.origin.xc.max.x&&(e=c.max.x-b.origin.x,e/=b.direction.x,m=!1,g=1);b.origin.yc.max.y&&(f=c.max.y-b.origin.y,f/=b.direction.y, -m=!1,k=1);b.origin.zc.max.z&&(h=c.max.z-b.origin.z,h/=b.direction.z,m=!1,j=1);if(m)return-1;m=0;f>e&&(m=1,e=f);h>e&&(m=2,e=h);switch(m){case 0:k=b.origin.y+b.direction.y*e;if(kc.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(g,0,0);break;case 1:g=b.origin.x+b.direction.x*e;if(gc.max.x)return Number.MAX_VALUE;b=b.origin.z+b.direction.z* -e;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(0,k,0);break;case 2:g=b.origin.x+b.direction.x*e;if(gc.max.x)return Number.MAX_VALUE;k=b.origin.y+b.direction.y*e;if(kc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,j)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),e=c.point.dot(c.normal);if(b<0)b=(e-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(e)-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.prototype.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),f=Number.MAX_VALUE,e,h=0;h=k*e))return Number.MAX_VALUE;g/=k;k=THREE.CollisionSystem.__v3;k.copy(a.direction);k.multiplyScalar(g);k.addSelf(a.origin);Math.abs(h.x)> +Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=k.y-c.y,h=b.y-c.y,e=f.y-c.y,k=k.z-c.z,b=b.z-c.z,f=f.z-c.z):(a=k.x-c.x,h=b.x-c.x,e=f.x-c.x,k=k.y-c.y,b=b.y-c.y,f=f.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(a=k.x-c.x,h=b.x-c.x,e=f.x-c.x,k=k.z-c.z,b=b.z-c.z,f=f.z-c.z):(a=k.x-c.x,h=b.x-c.x,e=f.x-c.x,k=k.y-c.y,b=b.y-c.y,f=f.y-c.y);c=h*f-b*e;if(c==0)return Number.MAX_VALUE;c=1/c;f=(a*f-k*e)*c;if(!(f>=0))return Number.MAX_VALUE;c*=h*k-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return g}; +THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,b);var f=THREE.CollisionSystem.__r;f.origin.copy(a.origin);f.direction.copy(a.direction);b.multiplyVector3(f.origin);b.rotateAxis(f.direction);f.direction.normalize();return f}; +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 f=0,e=0,h=0,g=0,k=0,j=0,m=!0;b.origin.xc.max.x&&(f=c.max.x-b.origin.x,f/=b.direction.x,m=!1,g=1);b.origin.yc.max.y&&(e=c.max.y-b.origin.y,e/=b.direction.y, +m=!1,k=1);b.origin.zc.max.z&&(h=c.max.z-b.origin.z,h/=b.direction.z,m=!1,j=1);if(m)return-1;m=0;e>f&&(m=1,f=e);h>f&&(m=2,f=h);switch(m){case 0:k=b.origin.y+b.direction.y*f;if(kc.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*f;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(g,0,0);break;case 1:g=b.origin.x+b.direction.x*f;if(gc.max.x)return Number.MAX_VALUE;b=b.origin.z+b.direction.z* +f;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(0,k,0);break;case 2:g=b.origin.x+b.direction.x*f;if(gc.max.x)return Number.MAX_VALUE;k=b.origin.y+b.direction.y*f;if(kc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,j)}return f};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),f=c.point.dot(c.normal);if(b<0)b=(f-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(f)-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);var c=this,b=this.setSize,e=this.render,f=new THREE.Camera,h=new THREE.Camera,g=new THREE.Matrix4,k=new THREE.Matrix4,j,m,l;f.useTarget=h.useTarget=!1;f.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},n=new THREE.WebGLRenderTarget(512,512,a),o=new THREE.WebGLRenderTarget(512,512,a),p=new THREE.Camera(53,1,1,1E4);p.position.z= +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var c=this,b=this.setSize,f=this.render,e=new THREE.Camera,h=new THREE.Camera,g=new THREE.Matrix4,k=new THREE.Matrix4,j,m,l;e.useTarget=h.useTarget=!1;e.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},n=new THREE.WebGLRenderTarget(512,512,a),o=new THREE.WebGLRenderTarget(512,512,a),p=new THREE.Camera(53,1,1,1E4);p.position.z= 2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:n},mapRight:{type:"t",value:1,texture:o}},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}"}); -var u=new THREE.Scene;u.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){b.call(c,a,e);n.width=a;n.height=e;o.width=a;o.height=e};this.render=function(a,b){b.update(null,!0);if(j!==b.aspect||m!==b.near||l!==b.fov){j=b.aspect;m=b.near;l=b.fov;var y=b.projectionMatrix.clone(),w=125/30*0.5,t=w*m/125,z=m*Math.tan(l*Math.PI/360),A;g.n14=w;k.n14=-w;w=-z*j+t;A=z*j+t;y.n11=2*m/(A-w);y.n13=(A+w)/(A-w);f.projectionMatrix=y.clone();w=-z*j-t;A=z*j-t;y.n11=2*m/(A-w); -y.n13=(A+w)/(A-w);h.projectionMatrix=y.clone()}f.matrix=b.matrixWorld.clone().multiplySelf(k);f.update(null,!0);f.position.copy(b.position);f.near=m;f.far=b.far;e.call(c,a,f,n,!0);h.matrix=b.matrixWorld.clone().multiplySelf(g);h.update(null,!0);h.position.copy(b.position);h.near=m;h.far=b.far;e.call(c,a,h,o,!0);e.call(c,u,p)}}; -if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,e=this.render,f,h,g=new THREE.Camera,k=new THREE.Camera;c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(a,e){b.call(c,a,e);f=a/2;h=e};this.render=function(a,b){this.clear();g.fov=b.fov;g.aspect=0.5*b.aspect;g.near=b.near;g.far=b.far; -g.updateProjectionMatrix();g.position.copy(b.position);g.target.position.copy(b.target.position);g.translateX(c.separation);k.projectionMatrix=g.projectionMatrix;k.position.copy(b.position);k.target.position.copy(b.target.position);k.translateX(-c.separation);this.setViewport(0,0,f,h);e.call(c,a,g);this.setViewport(f,0,f,h);e.call(c,a,k,!1)}}; +var u=new THREE.Scene;u.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){b.call(c,a,e);n.width=a;n.height=e;o.width=a;o.height=e};this.render=function(a,b){b.update(null,!0);if(j!==b.aspect||m!==b.near||l!==b.fov){j=b.aspect;m=b.near;l=b.fov;var y=b.projectionMatrix.clone(),w=125/30*0.5,t=w*m/125,z=m*Math.tan(l*Math.PI/360),A;g.n14=w;k.n14=-w;w=-z*j+t;A=z*j+t;y.n11=2*m/(A-w);y.n13=(A+w)/(A-w);e.projectionMatrix=y.clone();w=-z*j-t;A=z*j-t;y.n11=2*m/(A-w); +y.n13=(A+w)/(A-w);h.projectionMatrix=y.clone()}e.matrix=b.matrixWorld.clone().multiplySelf(k);e.update(null,!0);e.position.copy(b.position);e.near=m;e.far=b.far;f.call(c,a,e,n,!0);h.matrix=b.matrixWorld.clone().multiplySelf(g);h.update(null,!0);h.position.copy(b.position);h.near=m;h.far=b.far;f.call(c,a,h,o,!0);f.call(c,u,p)}}; +if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,f=this.render,e,h,g=new THREE.Camera,k=new THREE.Camera;c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(a,f){b.call(c,a,f);e=a/2;h=f};this.render=function(a,b){this.clear();g.fov=b.fov;g.aspect=0.5*b.aspect;g.near=b.near;g.far=b.far; +g.updateProjectionMatrix();g.position.copy(b.position);g.target.position.copy(b.target.position);g.translateX(c.separation);k.projectionMatrix=g.projectionMatrix;k.position.copy(b.position);k.target.position.copy(b.target.position);k.translateX(-c.separation);this.setViewport(0,0,e,h);f.call(c,a,g);this.setViewport(e,0,e,h);f.call(c,a,k,!1)}};