// ThreeExtras.js r42 - http://github.com/mrdoob/three.js THREE.ColorUtils={adjustHSV:function(a,b,c,g){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.ColorUtils.clamp(e.h+b,0,1);e.s=THREE.ColorUtils.clamp(e.s+c,0,1);e.v=THREE.ColorUtils.clamp(e.v+g,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,g=a.g,e=a.b,h=Math.max(Math.max(c,g),e),f=Math.min(Math.min(c,g),e);if(f==h)f=c=0;else{var j=h-f,f=j/h,c=c==h?(g-e)/j:g==h?2+(e-c)/j:4+(c-g)/j;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=f;b.v=h;return b}, clamp:function(a,b,c){return ac?c:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,g=a.vertices.length,e=c?b.geometry:b,h=a.vertices,f=e.vertices,j=a.faces,k=e.faces,m=a.faceVertexUvs[0],e=e.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var l=0,n=f.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;", THREE.ShaderChunk.fog_pars_fragment,"void 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 + viewPosition );\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 + viewPosition );\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;", THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:"attribute vec4 tangent;\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;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\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\n}"}, cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},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;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t", 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);e=(h-1)*0.5;c=Array(h);for(b=g=0;b1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+g+" on bone "+p),g=g<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(h[0]-e[0])*g,c.y=e[1]+(h[1]-e[1])*g,c.z=e[2]+(h[2]-e[2])*g;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",p,f.index-1).pos,this.points[1]=e,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",p,j.index+1).pos,g=g*0.33+0.33,e=this.interpolateCatmullRom(this.points,g),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)g=this.interpolateCatmullRom(this.points,g*1.01),this.target.set(g[0],g[1],g[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),g=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,g,0)}else if(c=== "rot")THREE.Quaternion.slerp(e,h,a.quaternion,g);else if(c==="scl")c=a.scale,c.x=e[0]+(h[0]-e[0])*g,c.y=e[1]+(h[1]-e[1])*g,c.z=e[2]+(h[2]-e[2])*g}}if(this.JITCompile&&l[0][m]===void 0){this.hierarchy[0].update(void 0,!0);for(p=0;pa.length-2?h:h+1;c[3]=h>a.length-3?h:h+2;h=a[c[0]];j=a[c[1]];k=a[c[2]];m=a[c[3]];c=e*e;f=e*c;g[0]=this.interpolate(h[0],j[0],k[0],m[0],e,c,f);g[1]=this.interpolate(h[1],j[1],k[1],m[1],e,c,f);g[2]=this.interpolate(h[2],j[2],k[2],m[2],e,c,f);return g}; THREE.Animation.prototype.interpolate=function(a,b,c,g,e,h,f){a=(c-a)*0.5;g=(g-b)*0.5;return(2*(b-c)+a+g)*f+(-3*(b-c)-2*a-g)*h+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var g=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+g.length;c>=0;c--)if(g[c][a]!==void 0)return g[c];return this.data.hierarchy[b].keys[g.length-1]}; THREE.FirstPersonCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;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 b=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.translateZ(b);this.moveLeft&&this.translateX(-b);this.moveRight&&this.translateX(b);b=this.tdiff*this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&& (this.lat-=this.mouseY*b);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*b;this.lookVertical&&(this.lat-=this.mouseY*b);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",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.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype; THREE.FirstPersonCamera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);if(this.noFly)b.y=0;this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))}; THREE.PathCamera=function(a){function b(a,c,b,f){var g={name:b,fps:0.6,length:f,hierarchy:[]},e,h=c.getControlPointsArray(),j=c.getLength(),k=h.length,w=0;e=k-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:h[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[e]={time:f,pos:h[e],rot:[0,0,0,1],scl:[1,1,1]};for(e=1;e=0?f:f+e;f=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var j=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])/j)*j+g[0];f=this.horizontalAngleMap.srcRange;g=this.horizontalAngleMap.dstRange;j=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])/j)*j+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,c,b)};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}),f=new THREE.MeshLambertMaterial({color:65280}),j=new THREE.CubeGeometry(10,10,20),k=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,f);a.position.set(0,10,0);this.animation= b(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=b(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&g(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(a,c){return function(){c.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 b(a,b){return function(){b.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.0050;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 b=this.getContainerDimensions(),e=b.size[0]/2,h=b.size[1]/2;this.moveState.yawLeft=-(a.clientX-b.offset[0]-e)/e;this.moveState.pitchDown=(a.clientY- b.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,b=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*b,this.rotationVector.y*b,this.rotationVector.z*b,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",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this,this.mouseup),!1);window.addEventListener("keydown",b(this,this.keydown),!1);window.addEventListener("keyup",b(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,b,c,g){THREE.Camera.call(this,a,b,c,g);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,f=new THREE.Vector3,j=new THREE.Matrix4,k=!1,m=1,l=0,n=0,o=0,p=0,u=0,x=window.innerWidth/2,y=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);k&&(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?b.normalize():b.z=Math.sqrt(1-f*f);e=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(b.y);f.addSelf(this.up.clone().crossSelf(e).setLength(b.x));f.addSelf(e.setLength(b.z));return f}; this.rotateCamera=function(){var a=Math.acos(h.dot(f)/h.length()/f.length());if(a){var c=(new THREE.Vector3).cross(h,f).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c,-a);b.multiplyVector3(e);b.multiplyVector3(this.up);b.multiplyVector3(f);this.staticMoving?h=f:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-j.y)*this.zoomSpeed;a!==1&&a>0&&(e.multiplyScalar(a),this.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)}; this.panCamera=function(){var a=l.clone().subSelf(m);if(a.lengthSq()){a.multiplyScalar(e.length()*this.panSpeed);var c=e.clone().crossSelf(this.up).setLength(a.x);c.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(c);this.target.position.addSelf(c);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?(n=b[b.length-1],l=n.x,n=n.y):(n=this.actions[c-1].args,l=n[n.length-2],n=n[n.length-1]);for(o=1;o<=a;o++)p=o/a,u=THREE.FontUtils.b2(p,l,k,h),p=THREE.FontUtils.b2(p,n,m,e),b.push(new THREE.Vector2(u, p));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];e=f[5];k=f[0];m=f[1];j=f[2];f=f[3];b.length>0?(n=b[b.length-1],l=n.x,n=n.y):(n=this.actions[c-1].args,l=n[n.length-2],n=n[n.length-1]);for(o=1;o<=a;o++)p=o/a,u=THREE.FontUtils.b3(p,l,k,j,h),p=THREE.FontUtils.b3(p,n,m,f,e),b.push(new THREE.Vector2(u,p))}return b}; THREE.Path.prototype.getMinAndMax=function(){var a=this.getPoints(),b,c,g,e;b=c=Number.NEGATIVE_INFINITY;g=e=Number.POSITIVE_INFINITY;var h,f,j;f=0;for(j=a.length;fb)b=h.x;else if(h.xc)c=h.y;else if(h.y0){f(0,0,-l-(h||0));for(k=a;k0){f(0,0,l+ (e||0));for(k=a+a/2;k<2*a;k++)j.faces.push(new THREE.Face4(2*a+1,(2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a))}k=0;for(a=this.faces.length;k0;){for(j=0;j0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,j,o)))-1);m.push(l)}b.push(m)}for(var p,u,x,e=b.length,c=0;c0)for(g=0;g1&&(p= this.vertices[f].position.clone(),u=this.vertices[k].position.clone(),x=this.vertices[m].position.clone(),p.normalize(),u.normalize(),x.normalize(),this.faces.push(new THREE.Face3(f,k,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([l,n,y]))}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,b){THREE.Geometry.call(this);this.parameters=b||{};this.set(a)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; THREE.TextGeometry.prototype.set=function(a,b){function c(a,c,b){u.vertices.push(new THREE.Vertex(new THREE.Vector3(a,c,b)))}function g(a,c,b,f){u.faces.push(new THREE.Face4(a,c,b,f))}this.text=a;var b=b||this.parameters,e=b.height!==void 0?b.height:50,h=b.curveSegments!==void 0?b.curveSegments:4,f=b.font!==void 0?b.font:"helvetiker",j=b.weight!==void 0?b.weight:"normal",k=b.style!==void 0?b.style:"normal",m=b.bezelThickness!==void 0?b.bezelThickness:10,l=b.bezelSize!==void 0?b.bezelSize:8,n=b.bezelEnabled!== void 0?b.bezelEnabled:!1;THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=h;THREE.FontUtils.face=f;THREE.FontUtils.weight=j;THREE.FontUtils.style=k;THREE.FontUtils.bezelSize=l;var j=THREE.FontUtils.drawText(a),h=j.points,o=j.faces,f=j.contour,p=j.bezel,u=this;u.vertices=[];u.faces=[];for(var x,k=h.length,y=o.length,l=p.length,j=0;j0;){if(v){if(v.equals(f[j])){v=null;continue}}else v=f[j];m=k*2+j;o=m-1;g(m,o,o+l,m+l);for(n=0;n0;){if(v){if(v.equals(f[j])){v=null;continue}}else v=f[j];for(n=0;n0&&j.push({shape:e,holes:g}),e=n,g=[]):g.push(n):this.Triangulate.area(n)<0?(j.push({shape:n,holes:g}),g=[]):g.push(n);c++}l&&j.push({shape:e,holes:g})}var o,p,u, x,y,v;h=[];for(f=0;f=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[c]);u=this.Triangulate.area(w);var t=[];t.push(l[o]);t.push(l[n]);t.push(e[p]);y=this.Triangulate.area(t);x=p;v=o;p+=1;o+=-1;p<0&&(p+=e.length);p%=e.length;o<0&&(o+=l.length);o%=e.length;c=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[c]);w=this.Triangulate.area(w);t=[];t.push(l[o]);t.push(l[n]);t.push(e[p]);t=this.Triangulate.area(t);u+y>w+t&&(p=x,o=v,p<0&&(p+=e.length),p%=e.length,o<0&&(o+=l.length),o%=e.length,c=p-1>=0?p-1:e.length-1,n=o-1>=0?o-1:l.length-1);u=e.slice(0,p);y=e.slice(p);x=l.slice(o);v=l.slice(0,o);h.push(l[o]);h.push(e[p]);h.push(e[c]);h.push(l[o]);h.push(l[n]);h.push(e[p]);e=u.concat(x).concat(v).concat(y)}k.shape=e}o=[];p=[]; for(f=m=0;f=0;){if(l){if(l.equals(c[a])){l=null;k=this.Triangulate.area(g)>0;f.push(k);h.push(j.divideScalar(g.length));g=[];j=new THREE.Vector2;continue}}else l=c[a];j.addSelf(c[a]);g.push(c[a])}a=c.length;for(g=0;--a>=0;)k=c[a], j=h[g],k=k.clone().subSelf(j),m=this.bezelSize/k.length(),f[g]?m+=1:m=1-m,m=k.multiplyScalar(m).addSelf(j),e.unshift(m),l?l.equals(c[a])&&(l=null,g++):l=c[a];b.bezel=e;return b},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,g){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,g)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a, b){return a*a*a*b},b3:function(a,b,c,g,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,g)+this.b3p3(a,e)},extractGlyphPoints:function(a,b,c,g){var e=[],h=new THREE.Path,f,j,k,m,l,n,o,p,u,x,y=b.glyphs[a]||b.glyphs[ctxt.options.fallbackCharacter];if(y){if(y.o){b=y._cachedOutline||(y._cachedOutline=y.o.split(" "));k=b.length;for(a=0;a0)for(m=0;m2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(g)return j;return h}k=m;e<=k&&(k=0);m=k+1;e<=m&&(m=0);l=m+1;e<=l&&(l=0);var o;a:{o=a;var p=k,u=m,x=l,y=e,v=f,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[v[p]].x,z=o[v[p]].y,A=o[v[u]].x,E=o[v[u]].y,F=o[v[x]].x,G=o[v[x]].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= f[k];o=f[m];p=f[l];h.push(a[n]);h.push(a[o]);h.push(a[p]);j.push([f[k],f[m],f[l]]);k=m;for(l=m+1;l>7)-127;e|=(f&127)<<16|g<<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,c){var b=l(a,c),g=l(a,c+1),f=l(a,c+2);return(l(a,c+3)<<24)+(f<<16)+(g<<8)+b}function k(a,c){var b=l(a,c);return(l(a,c+1)<<8)+b}function m(a,c){var b=l(a,c);return b>127?b-256:b}function l(a, c){return a.charCodeAt(c)&255}function n(c){var b,g,f;b=e(a,c);g=e(a,c+E);f=e(a,c+F);c=k(a,c+G);THREE.BinaryLoader.prototype.f3(v,b,g,f,c)}function o(c){var b,g,f,h,l,m;b=e(a,c);g=e(a,c+E);f=e(a,c+F);h=k(a,c+G);l=e(a,c+D);m=e(a,c+K);c=e(a,c+I);THREE.BinaryLoader.prototype.f3n(v,z,b,g,f,h,l,m,c)}function p(c){var b,g,f,h;b=e(a,c);g=e(a,c+C);f=e(a,c+J);h=e(a,c+L);c=k(a,c+H);THREE.BinaryLoader.prototype.f4(v,b,g,f,h,c)}function u(c){var b,g,f,h,l,m,n,o;b=e(a,c);g=e(a,c+C);f=e(a,c+J);h=e(a,c+L);l=k(a, c+H);m=e(a,c+N);n=e(a,c+O);o=e(a,c+B);c=e(a,c+P);THREE.BinaryLoader.prototype.f4n(v,z,b,g,f,h,l,m,n,o,c)}function x(c){var b,g;b=e(a,c);g=e(a,c+M);c=e(a,c+R);THREE.BinaryLoader.prototype.uv3(v.faceVertexUvs[0],A[b*2],A[b*2+1],A[g*2],A[g*2+1],A[c*2],A[c*2+1])}function y(c){var b,g,f;b=e(a,c);g=e(a,c+S);f=e(a,c+Y);c=e(a,c+Z);THREE.BinaryLoader.prototype.uv4(v.faceVertexUvs[0],A[b*2],A[b*2+1],A[g*2],A[g*2+1],A[f*2],A[f*2+1],A[c*2],A[c*2+1])}var v=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(v,g,c);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;c=t.vertex_index_bytes*3+t.material_index_bytes;Q=t.vertex_index_bytes*4+t.material_index_bytes;T=t.ntri_flat*c;U=t.ntri_smooth*(c+t.normal_index_bytes*3);V=t.ntri_flat_uv* (c+t.uv_index_bytes*3);W=t.ntri_smooth_uv*(c+t.normal_index_bytes*3+t.uv_index_bytes*3);X=t.nquad_flat*Q;c=t.nquad_smooth*(Q+t.normal_index_bytes*4);Q=t.nquad_flat_uv*(Q+t.uv_index_bytes*4);w+=function(c){for(var e,g,h,j=t.vertex_coordinate_bytes*3,k=c+t.nvertices*j;c1&&(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 k(a){return function(b){B.geometries[a]=b;j();L-=1;c.onLoadComplete();l()}}function m(a){return function(c){B.geometries[a]=c}}function l(){c.callbackProgress({totalModels:N,totalTextures:O,loadedModels:N-L,loadedTextures:O-H},B);c.onLoadProgress();L==0&&H==0&&b(B)}var n, o,p,u,x,y,v,w,t,z,A,E,F,G,D,K,I,C,J,L,H,N,O,B;C=a.data;D=new THREE.BinaryLoader;J=new THREE.JSONLoader;H=L=0;B={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(p in C.objects)if(w=C.objects[p],w.meshCollider){a=!0;break}if(a)B.scene.collisions=new THREE.CollisionSystem;if(C.transform){a=C.transform.position;z=C.transform.rotation;var P=C.transform.scale;a&&B.scene.position.set(a[0],a[1],a[2]);z&&B.scene.rotation.set(z[0], z[1],z[2]);P&&B.scene.scale.set(P[0],P[1],P[2]);(a||z||P)&&B.scene.updateMatrix()}a=function(){H-=1;l();c.onLoadComplete()};for(x in C.cameras){z=C.cameras[x];if(z.type=="perspective")F=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho")F=new THREE.Camera,F.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far);t=z.position;z=z.target;F.position.set(t[0],t[1],t[2]);F.target.position.set(z[0],z[1],z[2]);B.cameras[x]=F}for(u in C.lights)x=C.lights[u], F=x.color!==void 0?x.color:16777215,z=x.intensity!==void 0?x.intensity:1,x.type=="directional"?(t=x.direction,I=new THREE.DirectionalLight(F,z),I.position.set(t[0],t[1],t[2]),I.position.normalize()):x.type=="point"?(t=x.position,d=x.distance,I=new THREE.PointLight(F,z,d),I.position.set(t[0],t[1],t[2])):x.type=="ambient"&&(I=new THREE.AmbientLight(F)),B.scene.addLight(I),B.lights[u]=I;for(y in C.fogs)u=C.fogs[y],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[y]=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(y=C.geometries[n],y.type=="bin_mesh"||y.type=="ascii_mesh")L+=1,c.onLoadStart();N=L;for(n in C.geometries)y=C.geometries[n],y.type=="cube"?(E=new THREE.CubeGeometry(y.width, y.height,y.depth,y.segmentsWidth,y.segmentsHeight,y.segmentsDepth,null,y.flipped,y.sides),B.geometries[n]=E):y.type=="plane"?(E=new THREE.PlaneGeometry(y.width,y.height,y.segmentsWidth,y.segmentsHeight),B.geometries[n]=E):y.type=="sphere"?(E=new THREE.SphereGeometry(y.radius,y.segmentsWidth,y.segmentsHeight),B.geometries[n]=E):y.type=="cylinder"?(E=new THREE.CylinderGeometry(y.numSegs,y.topRad,y.botRad,y.height,y.topOffset,y.botOffset),B.geometries[n]=E):y.type=="torus"?(E=new THREE.TorusGeometry(y.radius, y.tube,y.segmentsR,y.segmentsT),B.geometries[n]=E):y.type=="icosahedron"?(E=new THREE.IcosahedronGeometry(y.subdivisions),B.geometries[n]=E):y.type=="bin_mesh"?D.load({model:g(y.url,C.urlBaseType),callback:k(n)}):y.type=="ascii_mesh"?J.load({model:g(y.url,C.urlBaseType),callback:k(n)}):y.type=="embedded_mesh"&&(y=C.embeds[y.id])&&J.createModel(y,m(n),"");for(v in C.textures)if(n=C.textures[v],n.url instanceof Array){H+=n.url.length;for(D=0;D=this.maxCount-3&&j(this)};this.begin=function(){this.count=0; this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;bthis.size-1&&(k=this.size-1);var o=Math.floor(m-j);o<1&&(o=1);m=Math.floor(m+j);m>this.size-1&&(m=this.size-1);var p=Math.floor(l-j);p<1&&(p=1);j=Math.floor(l+j);j>this.size-1&&(j=this.size- 1);for(var u,x,y,v,w,t;n0&&(this.field[y+u]+=v)}}};this.addPlaneX=function(a,b){var e,h,f,j,k,m=this.size,l=this.yd,n=this.zd,o=this.field,p=m*Math.sqrt(a/b);p>m&&(p=m);for(e=0;e0)for(h=0;hl&&(u=l);for(h=0;h0){k=h*n;for(e=0;esize&&(dist=size);for(f=0;f0){k=zd*f;for(h=0;hh?this.hits.push(e):this.hits.unshift(e),h=g;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(a){var b=this.rayCastAll(a);if(b.length==0)return null;for(var c=0;b[c]instanceof THREE.MeshCollider;){var g=this.rayMesh(a,b[c]);if(g.distb.length)return null;return b[c]}; THREE.CollisionSystem.prototype.rayCast=function(a,b){if(b instanceof THREE.PlaneCollider)return this.rayPlane(a,b);else if(b instanceof THREE.SphereCollider)return this.raySphere(a,b);else if(b instanceof THREE.BoxCollider)return this.rayBox(a,b);else if(b instanceof THREE.MeshCollider&&b.box)return this.rayBox(a,b.box)}; THREE.CollisionSystem.prototype.rayMesh=function(a,b){for(var c=this.makeRayLocal(a,b.mesh),g=Number.MAX_VALUE,e,h=0;h=j*e))return Number.MAX_VALUE;f/=j;j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(f);j.addSelf(a.origin);Math.abs(h.x)> Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=j.y-b.y,h=c.y-b.y,e=g.y-b.y,j=j.z-b.z,c=c.z-b.z,g=g.z-b.z):(a=j.x-b.x,h=c.x-b.x,e=g.x-b.x,j=j.y-b.y,c=c.y-b.y,g=g.y-b.y):Math.abs(h.y)>Math.abs(h.z)?(a=j.x-b.x,h=c.x-b.x,e=g.x-b.x,j=j.z-b.z,c=c.z-b.z,g=g.z-b.z):(a=j.x-b.x,h=c.x-b.x,e=g.x-b.x,j=j.y-b.y,c=c.y-b.y,g=g.y-b.y);b=h*g-c*e;if(b==0)return Number.MAX_VALUE;b=1/b;g=(a*g-j*e)*b;if(!(g>=0))return Number.MAX_VALUE;b*=h*j-c*a;if(!(b>=0))return Number.MAX_VALUE;if(!(1-g-b>=0))return Number.MAX_VALUE;return f}; THREE.CollisionSystem.prototype.makeRayLocal=function(a,b){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(b.matrixWorld,c);var g=THREE.CollisionSystem.__r;g.origin.copy(a.origin);g.direction.copy(a.direction);c.multiplyVector3(g.origin);c.rotateAxis(g.direction);g.direction.normalize();return g}; THREE.CollisionSystem.prototype.rayBox=function(a,b){var c;b.dynamic&&b.mesh&&b.mesh.matrixWorld?c=this.makeRayLocal(a,b.mesh):(c=THREE.CollisionSystem.__r,c.origin.copy(a.origin),c.direction.copy(a.direction));var g=0,e=0,h=0,f=0,j=0,k=0,m=!0;c.origin.xb.max.x&&(g=b.max.x-c.origin.x,g/=c.direction.x,m=!1,f=1);c.origin.yb.max.y&&(e=b.max.y-c.origin.y,e/=c.direction.y, m=!1,j=1);c.origin.zb.max.z&&(h=b.max.z-c.origin.z,h/=c.direction.z,m=!1,k=1);if(m)return-1;m=0;e>g&&(m=1,g=e);h>g&&(m=2,g=h);switch(m){case 0:j=c.origin.y+c.direction.y*g;if(jb.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*g;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(f,0,0);break;case 1:f=c.origin.x+c.direction.x*g;if(fb.max.x)return Number.MAX_VALUE;c=c.origin.z+c.direction.z* g;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(0,j,0);break;case 2:f=c.origin.x+c.direction.x*g;if(fb.max.x)return Number.MAX_VALUE;j=c.origin.y+c.direction.y*g;if(jb.max.y)return Number.MAX_VALUE;b.normal.set(0,0,k)}return g};THREE.CollisionSystem.prototype.rayPlane=function(a,b){var c=a.direction.dot(b.normal),g=b.point.dot(b.normal);if(c<0)c=(g-a.origin.dot(b.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(a,b){var c=b.center.clone().subSelf(a.origin);if(c.lengthSq=0)return Math.abs(g)-Math.sqrt(c);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 b=a.geometry.boundingBox,c=new THREE.Vector3(b.x[0],b.y[0],b.z[0]),b=new THREE.Vector3(b.x[1],b.y[1],b.z[1]),c=new THREE.BoxCollider(c,b);c.mesh=a;return c};THREE.CollisionUtils.MeshAABB=function(a){var b=THREE.CollisionUtils.MeshOBB(a);b.min.addSelf(a.position);b.max.addSelf(a.position);b.dynamic=!1;return b}; 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 b=this,c=this.setSize,g=this.render,e=new THREE.Camera,h=new THREE.Camera,f=new THREE.Matrix4,j=new THREE.Matrix4,k,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){c.call(b,a,e);n.width=a;n.height=e;o.width=a;o.height=e};this.render=function(a,c){c.update(null,!0);if(k!==c.aspect||m!==c.near||l!==c.fov){k=c.aspect;m=c.near;l=c.fov;var v=c.projectionMatrix.clone(),w=125/30*0.5,t=w*m/125,z=m*Math.tan(l*Math.PI/360),A;f.n14=w;j.n14=-w;w=-z*k+t;A=z*k+t;v.n11=2*m/(A-w);v.n13=(A+w)/(A-w);e.projectionMatrix=v.clone();w=-z*k-t;A=z*k-t;v.n11=2*m/(A-w); v.n13=(A+w)/(A-w);h.projectionMatrix=v.clone()}e.matrix=c.matrixWorld.clone().multiplySelf(j);e.update(null,!0);e.position.copy(c.position);e.near=m;e.far=c.far;g.call(b,a,e,n,!0);h.matrix=c.matrixWorld.clone().multiplySelf(f);h.update(null,!0);h.position.copy(c.position);h.near=m;h.far=c.far;g.call(b,a,h,o,!0);g.call(b,u,p)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,g=this.render,e,h,f=new THREE.Camera,j=new THREE.Camera;b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(a,f){c.call(b,a,f);e=a/2;h=f};this.render=function(a,c){this.clear();f.fov=c.fov;f.aspect=0.5*c.aspect;f.near=c.near;f.far=c.far; f.updateProjectionMatrix();f.position.copy(c.position);f.target.position.copy(c.target.position);f.translateX(b.separation);j.projectionMatrix=f.projectionMatrix;j.position.copy(c.position);j.target.position.copy(c.target.position);j.translateX(-b.separation);this.setViewport(0,0,e,h);g.call(b,a,f);this.setViewport(e,0,e,h);g.call(b,a,j,!1)}};