// ThreeExtras.js r42 - http://github.com/mrdoob/three.js THREE.ColorUtils={adjustHSV:function(a,c,b,g){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+g,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,c){var b=a.r,g=a.g,f=a.b,h=Math.max(Math.max(b,g),f),e=Math.min(Math.min(b,g),f);if(e==h)e=b=0;else{var j=h-e,e=j/h,b=b==h?(g-f)/j:g==h?2+(f-b)/j:4+(b-g)/j;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=e;c.v=h;return c}, clamp:function(a,c,b){return ab?b:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; THREE.GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,g=a.vertices.length,f=b?c.geometry:c,h=a.vertices,e=f.vertices,j=a.faces,k=f.faces,l=a.faceVertexUvs[0],f=f.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var m=0,n=e.length;m 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);f=(h-1)*0.5;b=Array(h);for(c=g=0;c1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+g+" on bone "+p),g=g<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=f[0]+(h[0]-f[0])*g,b.y=f[1]+(h[1]-f[1])*g,b.z=f[2]+(h[2]-f[2])*g;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",p,e.index-1).pos,this.points[1]=f,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",p,j.index+1).pos,g=g*0.33+0.33,f=this.interpolateCatmullRom(this.points,g),b.x=f[0],b.y=f[1],b.z=f[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(b),this.target.y=0,this.target.normalize(),g=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,g,0)}else if(b=== "rot")THREE.Quaternion.slerp(f,h,a.quaternion,g);else if(b==="scl")b=a.scale,b.x=f[0]+(h[0]-f[0])*g,b.y=f[1]+(h[1]-f[1])*g,b.z=f[2]+(h[2]-f[2])*g}}if(this.JITCompile&&m[0][l]===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]];j=a[b[1]];k=a[b[2]];l=a[b[3]];b=f*f;e=f*b;g[0]=this.interpolate(h[0],j[0],k[0],l[0],f,b,e);g[1]=this.interpolate(h[1],j[1],k[1],l[1],f,b,e);g[2]=this.interpolate(h[2],j[2],k[2],l[2],f,b,e);return g}; THREE.Animation.prototype.interpolate=function(a,c,b,g,f,h,e){a=(b-a)*0.5;g=(g-c)*0.5;return(2*(c-b)+a+g)*e+(-3*(c-b)-2*a-g)*h+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var g=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+g.length;b>=0;b--)if(g[b][a]!==void 0)return g[b];return this.data.hierarchy[c].keys[g.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.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 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,f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.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;f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.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 g={name:c,fps:0.6,length:e,hierarchy:[]},h,f=b.getControlPointsArray(),j=b.getLength(),k=f.length,y=0;h=k-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[h]={time:e,pos:f[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h=0?e:e+f;e=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var j=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])/j)*j+g[0];e=this.horizontalAngleMap.srcRange;g=this.horizontalAngleMap.dstRange;j=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])/j)*j+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= 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}),e=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,e);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&&g(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,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.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 c=this.getContainerDimensions(),f=c.size[0]/2,h=c.size[1]/2;this.moveState.yawLeft=-(a.clientX-c.offset[0]-f)/f;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,g){THREE.Camera.call(this,a,c,b,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 f=new THREE.Vector3,h=new THREE.Vector3,e=new THREE.Vector3,j=new THREE.Matrix4,k=!1,l=1,m=0,n=0,o=0,p=0,w=0,t=window.innerWidth/2,v=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*w));a=this.delta*this.movementSpeed;this.translateZ(a*(m>0||this.autoForward&&!(m<0)?1:m));this.translateX(a*n);this.translateY(a*o);k&&(this.roll+=this.rollSpeed*this.delta*l);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); else if(this.forward.y1?c.normalize():c.z=Math.sqrt(1-e*e);f=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(c.y);e.addSelf(this.up.clone().crossSelf(f).setLength(c.x));e.addSelf(f.setLength(c.z));return e}; this.rotateCamera=function(){var a=Math.acos(h.dot(e)/h.length()/e.length());if(a){var b=(new THREE.Vector3).cross(h,e).normalize(),c=new THREE.Quaternion;a*=this.rotateSpeed;c.setFromAxisAngle(b,-a);c.multiplyVector3(f);c.multiplyVector3(this.up);c.multiplyVector3(e);this.staticMoving?h=e:(c.setFromAxisAngle(b,a*(this.dynamicDampingFactor-1)),c.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-j.y)*this.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),this.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)}; this.panCamera=function(){var a=m.clone().subSelf(l);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?l=m:l.addSelf(a.sub(m,l).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()h)break;g++}return g/f};THREE.LineCurve=function(a,c,b,g){this.x1=a;this.y1=c;this.x2=b;this.y2=g};THREE.LineCurve.prototype=new THREE.Curve;THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){return new THREE.Vector2(this.x1+(this.x2-this.x1)*a,this.y1+(this.y2-this.y1)*a)}; THREE.QuadraticBezierCurve=function(a,c,b,g,f,h){this.x0=a;this.y0=c;this.x1=b;this.y1=g;this.x2=f;this.y2=h};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var c;c=THREE.FontUtils.b2(a,this.x0,this.x1,this.x2);a=THREE.FontUtils.b2(a,this.y0,this.y1,this.y2);return new THREE.Vector2(c,a)}; THREE.QuadraticBezierCurve.prototype.getNormalVector=function(a){var c;c=THREE.Curve.Utils.tangentQuadraticBezier(a,this.x0,this.x1,this.x2);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.y0,this.y1,this.y2);return(new THREE.Vector2(-a,c)).unit()};THREE.CubicBezierCurve=function(a,c,b,g,f,h,e,j){this.x0=a;this.y0=c;this.x1=b;this.y1=g;this.x2=f;this.y2=h;this.x3=e;this.y3=j};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; THREE.CubicBezierCurve.prototype.getPoint=function(a){var c;c=THREE.FontUtils.b3(a,this.x0,this.x1,this.x2,this.x3);a=THREE.FontUtils.b3(a,this.y0,this.y1,this.y2,this.y3);return new THREE.Vector2(c,a)};THREE.SplineCurve=function(a){this.points=a};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve; THREE.SplineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2,b=[],g=this.points,f;f=(g.length-1)*a;a=Math.floor(f);f-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>g.length-2?a:a+1;b[3]=a>g.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(g[b[0]].x,g[b[1]].x,g[b[2]].x,g[b[3]].x,f);c.y=THREE.Curve.Utils.interpolate(g[b[0]].y,g[b[1]].y,g[b[2]].y,g[b[3]].y,f);return c};THREE.ArcCurve=function(a,c,b,g,f,h){this.aX=a;this.aY=c;this.aRadius=b;this.aStartAngle=g;this.aEndAngle=f;this.aClockwise=h}; THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(a){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);a=this.aStartAngle+a*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(a),this.aY+this.aRadius*Math.sin(a))}; THREE.Curve.Utils={tangentQuadraticBezier:function(a,c,b,g){return 2*(1-a)*(b-c)+2*a*(g-b)},tangentSpline:function(){},interpolate:function(a,c,b,g,f){var a=(b-a)*0.5,g=(g-c)*0.5,h=f*f;return(2*c-2*b+a+g)*f*h+(-3*c+3*b-2*a-g)*h+a*f+c}};THREE.Path=function(a){this.actions=[];this.curves=[];a&&this.fromPoints(a)};THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc"}; THREE.Path.prototype.fromPoints=function(a){this.moveTo(a[0].x,a[0].y);var c,b=a.length;for(c=1;c0?(e=b[b.length-1],p=e.x,w=e.y):(e=this.actions[g-1].args,p=e[e.length-2],w=e[e.length-1]);for(e=1;e<=a;e++)t=e/a,h=THREE.FontUtils.b2(t,p,n,j),t=THREE.FontUtils.b2(t,w,o,k), b.push(new THREE.Vector2(h,t));break;case THREE.PathActions.BEZIER_CURVE_TO:j=h[4];k=h[5];n=h[0];o=h[1];l=h[2];m=h[3];b.length>0?(e=b[b.length-1],p=e.x,w=e.y):(e=this.actions[g-1].args,p=e[e.length-2],w=e[e.length-1]);for(e=1;e<=a;e++)t=e/a,h=THREE.FontUtils.b3(t,p,n,l,j),t=THREE.FontUtils.b3(t,w,o,m,k),b.push(new THREE.Vector2(h,t));break;case THREE.PathActions.CSPLINE_THRU:e=this.actions[g-1].args;e=[new THREE.Vector2(e[e.length-2],e[e.length-1])];t=a*h[0].length;e=e.concat(h[0]);h=new THREE.SplineCurve(e); for(e=1;e<=t;e++)b.push(h.getPointAt(e/t));break;case THREE.PathActions.ARC:e=this.actions[g-1].args;j=h[0];k=h[1];l=h[2];n=h[3];t=h[4];o=!!h[5];m=e[e.length-2];p=e[e.length-1];e.length==0&&(m=p=0);w=t-n;var v=a*2;for(e=1;e<=v;e++)t=e/v,o||(t=1-t),t=n+t*w,h=m+j+l*Math.cos(t),t=p+k+l*Math.sin(t),b.push(new THREE.Vector2(h,t))}c&&b.push(b[0]);return b}; THREE.Path.prototype.getMinAndMax=function(){var a=this.getPoints(),c,b,g,f;c=b=Number.NEGATIVE_INFINITY;g=f=Number.POSITIVE_INFINITY;var h,e,j;e=0;for(j=a.length;ec)c=h.x;else if(h.xb)b=h.y;else if(h.y=c)return c=b[a]-c,a=this.curves[a],c=1-c/a.getLength(),a.getPointAt(c);a++}return null}; THREE.Path.prototype.getLength=function(){var a=[],c=0,b,g=this.curves.length;for(b=0;b=0?j-1:b.length-1;h=e-1>=0?e-1:l.length-1;var t=[l[e],b[j],b[f]];n=THREE.FontUtils.Triangulate.area(t);var v=[l[e],l[h],b[j]];o=THREE.FontUtils.Triangulate.area(v);p=j;m=e;j+=1;e+=-1;j<0&&(j+=b.length);j%=b.length; e<0&&(e+=l.length);e%=l.length;f=j-1>=0?j-1:b.length-1;h=e-1>=0?e-1:l.length-1;t=[l[e],b[j],b[f]];t=THREE.FontUtils.Triangulate.area(t);v=[l[e],l[h],b[j]];v=THREE.FontUtils.Triangulate.area(v);n+o>t+v&&(j=p,e=m,j<0&&(j+=b.length),j%=b.length,e<0&&(e+=l.length),e%=l.length,f=j-1>=0?j-1:b.length-1,h=e-1>=0?e-1:l.length-1);n=b.slice(0,j);o=b.slice(j);p=l.slice(e);m=l.slice(0,e);h=[l[e],l[h],b[j]];w.push([l[e],b[j],b[f]]);w.push(h);b=n.concat(p).concat(m).concat(o)}return{shape:b,isolatedPts:w,allpoints:g}}, triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),g=b.allpoints,f=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),h,e,j,k;for(h=0;h0){e(0,0,-m-(h||0));for(k=a;k0){e(0,0,m+ (f||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;k=0;){O=A;M=A-1;M<0&&(M=a.length-1);for(var b=0,b=0;b0;J--){t=J/m;K=j*t;D=k*(1-Math.sin((1-t)*Math.PI/2));A=0;for(E=B.length;A0||(m=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,j,o)))-1);l.push(m)}c.push(l)}for(var p,w,t,f=c.length,b=0;b0)for(g=0;g1&&(p= this.vertices[e].position.clone(),w=this.vertices[k].position.clone(),t=this.vertices[l].position.clone(),p.normalize(),w.normalize(),t.normalize(),this.faces.push(new THREE.Face3(e,k,l,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(t.x,t.y,t.z)])),this.faceVertexUvs[0].push([m,n,v]))}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,c){w.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c,e){w.faces.push(new THREE.Face4(a,b,c,e))}this.text=a;var c=c||this.parameters,f=c.height!==void 0?c.height:50,h=c.curveSegments!==void 0?c.curveSegments:4,e=c.font!==void 0?c.font:"helvetiker",j=c.weight!==void 0?c.weight:"normal",k=c.style!==void 0?c.style:"normal",l=c.bevelThickness!==void 0?c.bevelThickness:10,m=c.bevelSize!==void 0?c.bevelSize:8,n=c.bevelEnabled!== void 0?c.bevelEnabled:!1;THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=h;THREE.FontUtils.face=e;THREE.FontUtils.weight=j;THREE.FontUtils.style=k;THREE.FontUtils.bevelSize=m;var j=THREE.FontUtils.drawText(a),h=j.points,o=j.faces,e=j.contour,p=j.bevel,w=this;w.vertices=[];w.faces=[];for(var t,k=h.length,v=o.length,m=p.length,j=0;j0;){if(x){if(x.equals(e[j])){x=null;continue}}else x=e[j];l=k*2+j;o=l-1;g(l,o,o+m,l+m);for(n=0;n0;){if(x){if(x.equals(e[j])){x=null;continue}}else x=e[j];for(n=0;n0&&j.push({shape:f,holes:g}),f=n,g=[]):g.push(n):this.Triangulate.area(n)<0?(j.push({shape:n,holes:g}),g=[]):g.push(n);b++}m&&j.push({shape:f,holes:g})}var o,p,w, t,v,x;h=[];for(e=0;e=0?p-1:f.length-1;var n=o-1>=0?o-1:m.length-1,y=[];y.push(m[o]);y.push(f[p]);y.push(f[b]);w=this.Triangulate.area(y);var u=[];u.push(m[o]);u.push(m[n]);u.push(f[p]);v=this.Triangulate.area(u);t=p;x=o;p+=1;o+=-1;p<0&&(p+=f.length);p%=f.length;o<0&&(o+=m.length);o%=f.length;b=p- 1>=0?p-1:f.length-1;n=o-1>=0?o-1:m.length-1;y=[];y.push(m[o]);y.push(f[p]);y.push(f[b]);y=this.Triangulate.area(y);u=[];u.push(m[o]);u.push(m[n]);u.push(f[p]);u=this.Triangulate.area(u);w+v>y+u&&(p=t,o=x,p<0&&(p+=f.length),p%=f.length,o<0&&(o+=m.length),o%=f.length,b=p-1>=0?p-1:f.length-1,n=o-1>=0?o-1:m.length-1);w=f.slice(0,p);v=f.slice(p);t=m.slice(o);x=m.slice(0,o);h.push(m[o]);h.push(f[p]);h.push(f[b]);h.push(m[o]);h.push(m[n]);h.push(f[p]);f=w.concat(t).concat(x).concat(v)}k.shape=f}o=[];p=[]; for(e=l=0;e=0;){if(m){if(m.equals(b[a])){m=null;k=this.Triangulate.area(g)>0;e.push(k);h.push(j.divideScalar(g.length));g=[];j=new THREE.Vector2;continue}}else m=b[a];j.addSelf(b[a]);g.push(b[a])}a=b.length;for(g= 0;--a>=0;)k=b[a],j=h[g],k=k.clone().subSelf(j),l=this.bevelSize/k.length(),e[g]?l+=1:l=1-l,l=k.multiplyScalar(l).addSelf(j),f.unshift(l),m?m.equals(b[a])&&(m=null,g++):m=b[a];c.bevel=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,g){return this.b2p0(a,c)+this.b2p1(a,b)+this.b2p2(a,g)},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,g,f){return this.b3p0(a,c)+this.b3p1(a,b)+this.b3p2(a,g)+this.b3p3(a,f)},extractGlyphPoints:function(a,c,b,g,f){var h=[],e,j,k,l,m,n,o,p,w,t,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(l=0;l2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(g)return j;return h}k=l;f<=k&&(k=0);l=k+1;f<=l&&(l=0);m=l+1;f<=m&&(m=0);var o;a:{o=a;var p=k,w=l,t=m,v=f,x=e,y=void 0,u=void 0,z=void 0, B=void 0,A=void 0,E=void 0,G=void 0,H=void 0,L=void 0,u=o[x[p]].x,z=o[x[p]].y,B=o[x[w]].x,A=o[x[w]].y,E=o[x[t]].x,G=o[x[t]].y;if(1.0E-10>(B-u)*(G-z)-(A-z)*(E-u))o=!1;else{for(y=0;y=0&&K>=0&&I>=0){o=!1;break a}}o=!0}}if(o){h.push([a[e[k]], a[e[l]],a[e[m]]]);j.push([e[k],e[l],e[m]]);k=l;for(m=l+1;m>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 f(a,b){var c=m(a,b),e=m(a,b+1),g=m(a,b+2);return(m(a,b+3)<<24)+(g<<16)+(e<<8)+c}function k(a,b){var c=m(a,b);return(m(a,b+1)<<8)+c}function l(a,b){var c=m(a,b);return c>127?c-256:c}function m(a, b){return a.charCodeAt(b)&255}function n(b){var c,e,g;c=f(a,b);e=f(a,b+A);g=f(a,b+E);b=k(a,b+G);THREE.BinaryLoader.prototype.f3(x,c,e,g,b)}function o(b){var c,e,g,h,l,m;c=f(a,b);e=f(a,b+A);g=f(a,b+E);h=k(a,b+G);l=f(a,b+H);m=f(a,b+L);b=f(a,b+J);THREE.BinaryLoader.prototype.f3n(x,z,c,e,g,h,l,m,b)}function p(b){var c,e,g,h;c=f(a,b);e=f(a,b+D);g=f(a,b+K);h=f(a,b+F);b=k(a,b+I);THREE.BinaryLoader.prototype.f4(x,c,e,g,h,b)}function w(b){var c,e,g,h,l,m,n,o;c=f(a,b);e=f(a,b+D);g=f(a,b+K);h=f(a,b+F);l=k(a, b+I);m=f(a,b+O);n=f(a,b+M);o=f(a,b+C);b=f(a,b+P);THREE.BinaryLoader.prototype.f4n(x,z,c,e,g,h,l,m,n,o,b)}function t(b){var c,e;c=f(a,b);e=f(a,b+N);b=f(a,b+R);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],B[c*2],B[c*2+1],B[e*2],B[e*2+1],B[b*2],B[b*2+1])}function v(b){var c,e,g;c=f(a,b);e=f(a,b+S);g=f(a,b+Y);b=f(a,b+Z);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],B[c*2],B[c*2+1],B[e*2],B[e*2+1],B[g*2],B[g*2+1],B[b*2],B[b*2+1])}var x=this,y=0,u,z=[],B=[],A,E,G,H,L,J,D,K,F,I,O,M,C,P,N,R, S,Y,Z,T,U,V,W,X,Q;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,g,b);u={signature:a.substr(y,8),header_bytes:m(a,y+8),vertex_coordinate_bytes:m(a,y+9),normal_coordinate_bytes:m(a,y+10),uv_coordinate_bytes:m(a,y+11),vertex_index_bytes:m(a,y+12),normal_index_bytes:m(a,y+13),uv_index_bytes:m(a,y+14),material_index_bytes:m(a,y+15),nvertices:f(a,y+16),nnormals:f(a,y+16+4),nuvs:f(a,y+16+8),ntri_flat:f(a,y+16+12),ntri_smooth:f(a,y+16+16),ntri_flat_uv:f(a,y+16+20),ntri_smooth_uv:f(a,y+ 16+24),nquad_flat:f(a,y+16+28),nquad_smooth:f(a,y+16+32),nquad_flat_uv:f(a,y+16+36),nquad_smooth_uv:f(a,y+16+40)};y+=u.header_bytes;A=u.vertex_index_bytes;E=u.vertex_index_bytes*2;G=u.vertex_index_bytes*3;H=u.vertex_index_bytes*3+u.material_index_bytes;L=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes;J=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes*2;D=u.vertex_index_bytes;K=u.vertex_index_bytes*2;F=u.vertex_index_bytes*3;I=u.vertex_index_bytes*4;O=u.vertex_index_bytes* 4+u.material_index_bytes;M=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes;C=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*2;P=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*3;N=u.uv_index_bytes;R=u.uv_index_bytes*2;S=u.uv_index_bytes;Y=u.uv_index_bytes*2;Z=u.uv_index_bytes*3;b=u.vertex_index_bytes*3+u.material_index_bytes;Q=u.vertex_index_bytes*4+u.material_index_bytes;T=u.ntri_flat*b;U=u.ntri_smooth*(b+u.normal_index_bytes*3);V=u.ntri_flat_uv* (b+u.uv_index_bytes*3);W=u.ntri_smooth_uv*(b+u.normal_index_bytes*3+u.uv_index_bytes*3);X=u.nquad_flat*Q;b=u.nquad_smooth*(Q+u.normal_index_bytes*4);Q=u.nquad_flat_uv*(Q+u.uv_index_bytes*4);y+=function(b){for(var g,f,h,j=u.vertex_coordinate_bytes*3,k=b+u.nvertices*j;b1&&(L=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(A,L);object.name=p;object.position.set(u[0],u[1],u[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=y.visible;C.scene.addObject(object);C.objects[p]=object;y.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),C.scene.collisions.colliders.push(a)); if(y.castsShadow)a=new THREE.ShadowVolume(A),C.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},C.triggers[object.name]=a)}}else u=y.position,r=y.rotation,q=y.quaternion,s=y.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(u[0],u[1],u[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=y.visible!==void 0?y.visible:!1,C.scene.addObject(object),C.objects[p]=object,C.empties[p]=object,y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},C.triggers[object.name]=a)}function k(a){return function(c){C.geometries[a]=c;g();F-=1;b.onLoadComplete();m()}}function l(a){return function(b){C.geometries[a]=b}}function m(){b.callbackProgress({totalModels:O,totalTextures:M,loadedModels:O-F,loadedTextures:M-I},C);b.onLoadProgress();F==0&&I==0&&c(C)}var n, o,p,w,t,v,x,y,u,z,B,A,E,G,H,L,J,D,K,F,I,O,M,C;D=a.data;H=new THREE.BinaryLoader;K=new THREE.JSONLoader;I=F=0;C={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(p in D.objects)if(y=D.objects[p],y.meshCollider){a=!0;break}if(a)C.scene.collisions=new THREE.CollisionSystem;if(D.transform){a=D.transform.position;z=D.transform.rotation;var P=D.transform.scale;a&&C.scene.position.set(a[0],a[1],a[2]);z&&C.scene.rotation.set(z[0], z[1],z[2]);P&&C.scene.scale.set(P[0],P[1],P[2]);(a||z||P)&&C.scene.updateMatrix()}a=function(){I-=1;m();b.onLoadComplete()};for(t in D.cameras){z=D.cameras[t];if(z.type=="perspective")E=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho")E=new THREE.Camera,E.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far);u=z.position;z=z.target;E.position.set(u[0],u[1],u[2]);E.target.position.set(z[0],z[1],z[2]);C.cameras[t]=E}for(w in D.lights)t=D.lights[w], E=t.color!==void 0?t.color:16777215,z=t.intensity!==void 0?t.intensity:1,t.type=="directional"?(u=t.direction,J=new THREE.DirectionalLight(E,z),J.position.set(u[0],u[1],u[2]),J.position.normalize()):t.type=="point"?(u=t.position,d=t.distance,J=new THREE.PointLight(E,z,d),J.position.set(u[0],u[1],u[2])):t.type=="ambient"&&(J=new THREE.AmbientLight(E)),C.scene.addLight(J),C.lights[w]=J;for(v in D.fogs)w=D.fogs[v],w.type=="linear"?G=new THREE.Fog(0,w.near,w.far):w.type=="exp2"&&(G=new THREE.FogExp2(0, w.density)),z=w.color,G.color.setRGB(z[0],z[1],z[2]),C.fogs[v]=G;if(C.cameras&&D.defaults.camera)C.currentCamera=C.cameras[D.defaults.camera];if(C.fogs&&D.defaults.fog)C.scene.fog=C.fogs[D.defaults.fog];z=D.defaults.bgcolor;C.bgColor=new THREE.Color;C.bgColor.setRGB(z[0],z[1],z[2]);C.bgColorAlpha=D.defaults.bgalpha;for(n in D.geometries)if(v=D.geometries[n],v.type=="bin_mesh"||v.type=="ascii_mesh")F+=1,b.onLoadStart();O=F;for(n in D.geometries)v=D.geometries[n],v.type=="cube"?(A=new THREE.CubeGeometry(v.width, v.height,v.depth,v.segmentsWidth,v.segmentsHeight,v.segmentsDepth,null,v.flipped,v.sides),C.geometries[n]=A):v.type=="plane"?(A=new THREE.PlaneGeometry(v.width,v.height,v.segmentsWidth,v.segmentsHeight),C.geometries[n]=A):v.type=="sphere"?(A=new THREE.SphereGeometry(v.radius,v.segmentsWidth,v.segmentsHeight),C.geometries[n]=A):v.type=="cylinder"?(A=new THREE.CylinderGeometry(v.numSegs,v.topRad,v.botRad,v.height,v.topOffset,v.botOffset),C.geometries[n]=A):v.type=="torus"?(A=new THREE.TorusGeometry(v.radius, v.tube,v.segmentsR,v.segmentsT),C.geometries[n]=A):v.type=="icosahedron"?(A=new THREE.IcosahedronGeometry(v.subdivisions),C.geometries[n]=A):v.type=="bin_mesh"?H.load({model:e(v.url,D.urlBaseType),callback:k(n)}):v.type=="ascii_mesh"?K.load({model:e(v.url,D.urlBaseType),callback:k(n)}):v.type=="embedded_mesh"&&(v=D.embeds[v.id])&&K.createModel(v,l(n),"");for(x in D.textures)if(n=D.textures[x],n.url instanceof Array){I+=n.url.length;for(H=0;H=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 c=this.count*3;cthis.size-1&&(k=this.size-1);var o=Math.floor(l-j);o<1&&(o=1);l=Math.floor(l+j);l>this.size-1&&(l=this.size-1);var p=Math.floor(m-j);p<1&&(p=1);j=Math.floor(m+j);j>this.size-1&&(j=this.size- 1);for(var w,t,v,x,y,u;n0&&(this.field[v+w]+=x)}}};this.addPlaneX=function(a,c){var f,h,e,j,k,l=this.size,m=this.yd,n=this.zd,o=this.field,p=l*Math.sqrt(a/c);p>l&&(p=l);for(f=0;f0)for(h=0;hm&&(w=m);for(h=0;h0){k=h*n;for(f=0;fsize&&(dist=size);for(e=0;e0){k=zd*e;for(h=0;hh?this.hits.push(f):this.hits.unshift(f),h=g;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 g=this.rayMesh(a,c[b]);if(g.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),g=Number.MAX_VALUE,f,h=0;h=j*f))return Number.MAX_VALUE;e/=j;j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(e);j.addSelf(a.origin);Math.abs(h.x)> Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=j.y-c.y,h=b.y-c.y,f=g.y-c.y,j=j.z-c.z,b=b.z-c.z,g=g.z-c.z):(a=j.x-c.x,h=b.x-c.x,f=g.x-c.x,j=j.y-c.y,b=b.y-c.y,g=g.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(a=j.x-c.x,h=b.x-c.x,f=g.x-c.x,j=j.z-c.z,b=b.z-c.z,g=g.z-c.z):(a=j.x-c.x,h=b.x-c.x,f=g.x-c.x,j=j.y-c.y,b=b.y-c.y,g=g.y-c.y);c=h*g-b*f;if(c==0)return Number.MAX_VALUE;c=1/c;g=(a*g-j*f)*c;if(!(g>=0))return Number.MAX_VALUE;c*=h*j-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-g-c>=0))return Number.MAX_VALUE;return e}; THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,b);var g=THREE.CollisionSystem.__r;g.origin.copy(a.origin);g.direction.copy(a.direction);b.multiplyVector3(g.origin);b.rotateAxis(g.direction);g.direction.normalize();return g}; 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 g=0,f=0,h=0,e=0,j=0,k=0,l=!0;b.origin.xc.max.x&&(g=c.max.x-b.origin.x,g/=b.direction.x,l=!1,e=1);b.origin.yc.max.y&&(f=c.max.y-b.origin.y,f/=b.direction.y, l=!1,j=1);b.origin.zc.max.z&&(h=c.max.z-b.origin.z,h/=b.direction.z,l=!1,k=1);if(l)return-1;l=0;f>g&&(l=1,g=f);h>g&&(l=2,g=h);switch(l){case 0:j=b.origin.y+b.direction.y*g;if(jc.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*g;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(e,0,0);break;case 1:e=b.origin.x+b.direction.x*g;if(ec.max.x)return Number.MAX_VALUE;b=b.origin.z+b.direction.z* g;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(0,j,0);break;case 2:e=b.origin.x+b.direction.x*g;if(ec.max.x)return Number.MAX_VALUE;j=b.origin.y+b.direction.y*g;if(jc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,k)}return g};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),g=c.point.dot(c.normal);if(b<0)b=(g-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(g)-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,g=this.render,f=new THREE.Camera,h=new THREE.Camera,e=new THREE.Matrix4,j=new THREE.Matrix4,k,l,m;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= 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 w=new THREE.Scene;w.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(k!==b.aspect||l!==b.near||m!==b.fov){k=b.aspect;l=b.near;m=b.fov;var x=b.projectionMatrix.clone(),y=125/30*0.5,u=y*l/125,z=l*Math.tan(m*Math.PI/360),B;e.n14=y;j.n14=-y;y=-z*k+u;B=z*k+u;x.n11=2*l/(B-y);x.n13=(B+y)/(B-y);f.projectionMatrix=x.clone();y=-z*k-u;B=z*k-u;x.n11=2*l/(B-y); x.n13=(B+y)/(B-y);h.projectionMatrix=x.clone()}f.matrix=b.matrixWorld.clone().multiplySelf(j);f.update(null,!0);f.position.copy(b.position);f.near=l;f.far=b.far;g.call(c,a,f,n,!0);h.matrix=b.matrixWorld.clone().multiplySelf(e);h.update(null,!0);h.position.copy(b.position);h.near=l;h.far=b.far;g.call(c,a,h,o,!0);g.call(c,w,p)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,g=this.render,f,h,e=new THREE.Camera,j=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();e.fov=b.fov;e.aspect=0.5*b.aspect;e.near=b.near;e.far=b.far; e.updateProjectionMatrix();e.position.copy(b.position);e.target.position.copy(b.target.position);e.translateX(c.separation);j.projectionMatrix=e.projectionMatrix;j.position.copy(b.position);j.target.position.copy(b.target.position);j.translateX(-c.separation);this.setViewport(0,0,f,h);g.call(c,a,e);this.setViewport(f,0,f,h);g.call(c,a,j,!1)}};