// ThreeExtras.js r39 - /github.com/mrdoob/three.js THREE.AnimationHandler=function(){var a=[],d={},b={};b.update=function(c){for(var f=0;f1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o);e=e<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=c[0]+(f[0]-c[0])*e;b.y=c[1]+(f[1]-c[1])*e;b.z=c[2]+(f[2]-c[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= this.getPrevKeyWith("pos",o,g.index-1).pos;this.points[1]=c;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",o,h.index+1).pos;e=e*0.33+0.33;c=this.interpolateCatmullRom(this.points,e);b.x=c[0];b.y=c[1];b.z=c[2];if(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(c,f,a.quaternion,e);else if(b==="scl"){b=a.scale;b.x=c[0]+(f[0]-c[0])*e;b.y=c[1]+(f[1]-c[1])*e;b.z=c[2]+(f[2]-c[2])*e}}}}if(this.JITCompile&&k[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(o=0;oa.length-2?f:f+1;b[3]=f>a.length-3?f:f+2;f=a[b[0]];h=a[b[1]];j=a[b[2]];l=a[b[3]];b=c*c;g=c*b;e[0]=this.interpolate(f[0],h[0],j[0],l[0],c,b,g);e[1]=this.interpolate(f[1],h[1],j[1],l[1],c,b,g);e[2]=this.interpolate(f[2],h[2],j[2],l[2],c,b,g);return e}; THREE.Animation.prototype.interpolate=function(a,d,b,e,c,f,g){a=(b-a)*0.5;e=(e-d)*0.5;return(2*(d-b)+a+e)*g+(-3*(d-b)-2*a-e)*f+a*c+d};THREE.Animation.prototype.getNextKeyWith=function(a,d,b){var e=this.data.hierarchy[d].keys;if(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]!==undefined)return e[b];return this.data.hierarchy[d].keys[e.length-1]}; var GeometryUtils={merge:function(a,d){var b=d instanceof THREE.Mesh,e=a.vertices.length,c=b?d.geometry:d,f=a.vertices,g=c.vertices,h=a.faces,j=c.faces,l=a.faceVertexUvs[0];c=c.faceVertexUvs[0];b&&d.matrixAutoUpdate&&d.updateMatrix();for(var k=0,m=g.length;k= 0.0 )\npointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight * pointDiffuseWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 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 );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight * dirDiffuseWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", vertexShader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\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;\nvarying vec3 vPointLightVector;\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;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\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&&(f=25);c=(f-1)*0.5;b=Array(f);for(d=e=0;d this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed);var b=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 e=this.target.position,c=this.position;e.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);e.y=c.y+100*Math.cos(this.phi);e.z=c.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;e=this.target.position;c=this.position;e.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);e.y=c.y+100*Math.cos(this.phi);e.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",d(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup", d(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",d(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",d(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.QuakeCamera.prototype.translate=function(a,d){this.matrix.rotateAxis(d);if(this.noFly)d.y=0;this.position.addSelf(d.multiplyScalar(a));this.target.position.addSelf(d.multiplyScalar(a))}; THREE.PathCamera=function(a){function d(l,k,m,p){var o={name:m,fps:0.6,length:p,hierarchy:[]},x,w=k.getControlPointsArray(),u=k.getLength(),B=w.length,z=0;x=B-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:w[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[x]={time:p,pos:w[x],rot:[0,0,0,1],scl:[1,1,1]};for(x=1;x=0?p:p+c;p=this.verticalAngleMap.srcRange;o=this.verticalAngleMap.dstRange; this.phi=(this.phi-p[0])*(o[1]-o[0])/(p[1]-p[0])+o[0];p=this.horizontalAngleMap.srcRange;o=this.horizontalAngleMap.dstRange;this.theta=(this.theta-p[0])*(o[1]-o[0])/(p[1]-p[0])+o[0];p=this.target.position;p.x=100*Math.sin(this.phi)*Math.cos(this.theta);p.y=100*Math.cos(this.phi);p.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,k,m)};this.onMouseMove=function(l){this.mouseX=l.clientX-this.windowHalfX;this.mouseY=l.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new THREE.Cube(10,10,20),j=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(j,g);a.position.set(0,10,0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= d(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(l,k){return function(){k.apply(l,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 d(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.tdiff=0;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!== undefined)this.autoForward=a.autoForward;if(a.domElement!==undefined)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=(new Date).getTime();this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown= function(b){if(!b.altKey){switch(b.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(b){switch(b.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(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var e=this.getContainerDimensions(),c=e.size[0]/2,f=e.size[1]/2; this.moveState.yawLeft=-(b.clientX-e.offset[0]-c)/c;this.moveState.pitchDown=(b.clientY-e.offset[1]-f)/f;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook){this.mouseStatus--;this.moveState.yawLeft=this.moveState.pitchDown=0}else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate= b;b=this.tdiff*this.movementSpeed;var e=this.tdiff*this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVector.y*b);this.translateZ(this.moveVector.z*b);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 b=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=-b+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",d(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",d(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",d(this,this.mouseup),!1);window.addEventListener("keydown",d(this,this.keydown),!1); window.addEventListener("keyup",d(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.Cube=function(a,d,b,e,c,f,g,h,j){function l(u,B,z,n,y,C,G,K){var J,I,E=e||1,L=c||1,P=y/2,Q=C/2,R=k.vertices.length;if(u=="x"&&B=="y"||u=="y"&&B=="x")J="z";else if(u=="x"&&B=="z"||u=="z"&&B=="x"){J="y";L=f||1}else if(u=="z"&&B=="y"||u=="y"&&B=="z"){J="x";E=f||1}var M=E+1,F=L+1;y/=E;var N=C/L;for(I=0;I0){g(0,0,-k-(f||0));for(j=a;j0){g(0,0,k+(c||0)); for(j=a+a/2;j<2*a;j++)h.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||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,h,p)))-1);l.push(k)}d.push(l)}var o,x,w;c=d.length;for(b=0;b0)for(e=0;e1){o=this.vertices[g].position.clone(); x=this.vertices[j].position.clone();w=this.vertices[l].position.clone();o.normalize();x.normalize();w.normalize();this.faces.push(new THREE.Face3(g,j,l,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(w.x,w.y,w.z)]));this.faceVertexUvs[0].push([k,m,u])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; THREE.Torus=function(a,d,b,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=d||40;this.segmentsR=b||8;this.segmentsT=e||6;a=[];for(d=0;d<=this.segmentsR;++d)for(b=0;b<=this.segmentsT;++b){e=b/this.segmentsT*2*Math.PI;var c=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(c))*Math.cos(e),(this.radius+this.tube*Math.cos(c))*Math.sin(e),this.tube*Math.sin(c))));a.push([b/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(b= 1;b<=this.segmentsT;++b){e=(this.segmentsT+1)*d+b;c=(this.segmentsT+1)*d+b-1;var f=(this.segmentsT+1)*(d-1)+b-1,g=(this.segmentsT+1)*(d-1)+b;this.faces.push(new THREE.Face4(e,c,f,g));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus; THREE.TorusKnot=function(a,d,b,e,c,f,g){function h(m,p,o,x,w,u){p=o/x*m;o=Math.cos(p);return new THREE.Vector3(w*(2+o)*0.5*Math.cos(m),w*(2+o)*Math.sin(m)*0.5,u*w*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=d||40;this.segmentsR=b||64;this.segmentsT=e||8;this.p=c||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;e=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a>7)-127;A|=(H&127)<<16|D<<8;if(A==0&&V==-127)return 0;return(1-2*(S>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,V)}function h(t,v){var A=k(t,v),D=k(t,v+1),H=k(t,v+2);return(k(t,v+3)<<24)+(H<<16)+(D<<8)+A}function j(t,v){var A=k(t,v);return(k(t,v+1)<<8)+A}function l(t,v){var A=k(t,v);return A>127?A-256:A}function k(t, v){return t.charCodeAt(v)&255}function m(t){var v,A,D;v=h(a,t);A=h(a,t+G);D=h(a,t+K);t=j(a,t+J);THREE.BinaryLoader.prototype.f3(B,v,A,D,t)}function p(t){var v,A,D,H,S,V;v=h(a,t);A=h(a,t+G);D=h(a,t+K);H=j(a,t+J);S=h(a,t+I);V=h(a,t+E);t=h(a,t+L);THREE.BinaryLoader.prototype.f3n(B,y,v,A,D,H,S,V,t)}function o(t){var v,A,D,H;v=h(a,t);A=h(a,t+P);D=h(a,t+Q);H=h(a,t+R);t=j(a,t+M);THREE.BinaryLoader.prototype.f4(B,v,A,D,H,t)}function x(t){var v,A,D,H,S,V,ca,da;v=h(a,t);A=h(a,t+P);D=h(a,t+Q);H=h(a,t+R);S=j(a, t+M);V=h(a,t+F);ca=h(a,t+N);da=h(a,t+O);t=h(a,t+T);THREE.BinaryLoader.prototype.f4n(B,y,v,A,D,H,S,V,ca,da,t)}function w(t){var v,A;v=h(a,t);A=h(a,t+U);t=h(a,t+X);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[t*2],C[t*2+1])}function u(t){var v,A,D;v=h(a,t);A=h(a,t+ea);D=h(a,t+fa);t=h(a,t+ga);THREE.BinaryLoader.prototype.uv4(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[D*2],C[D*2+1],C[t*2],C[t*2+1])}var B=this,z=0,n,y=[],C=[],G,K,J,I,E,L,P,Q,R,M,F,N,O, T,U,X,ea,fa,ga,Y,Z,$,aa,ba,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(B,e,f);n={signature:a.substr(z,8),header_bytes:k(a,z+8),vertex_coordinate_bytes:k(a,z+9),normal_coordinate_bytes:k(a,z+10),uv_coordinate_bytes:k(a,z+11),vertex_index_bytes:k(a,z+12),normal_index_bytes:k(a,z+13),uv_index_bytes:k(a,z+14),material_index_bytes:k(a,z+15),nvertices:h(a,z+16),nnormals:h(a,z+16+4),nuvs:h(a,z+16+8),ntri_flat:h(a,z+16+12),ntri_smooth:h(a,z+16+16),ntri_flat_uv:h(a,z+16+20),ntri_smooth_uv:h(a, z+16+24),nquad_flat:h(a,z+16+28),nquad_smooth:h(a,z+16+32),nquad_flat_uv:h(a,z+16+36),nquad_smooth_uv:h(a,z+16+40)};z+=n.header_bytes;G=n.vertex_index_bytes;K=n.vertex_index_bytes*2;J=n.vertex_index_bytes*3;I=n.vertex_index_bytes*3+n.material_index_bytes;E=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;L=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;P=n.vertex_index_bytes;Q=n.vertex_index_bytes*2;R=n.vertex_index_bytes*3;M=n.vertex_index_bytes*4;F=n.vertex_index_bytes* 4+n.material_index_bytes;N=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;O=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;T=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;U=n.uv_index_bytes;X=n.uv_index_bytes*2;ea=n.uv_index_bytes;fa=n.uv_index_bytes*2;ga=n.uv_index_bytes*3;f=n.vertex_index_bytes*3+n.material_index_bytes;W=n.vertex_index_bytes*4+n.material_index_bytes;Y=n.ntri_flat*f;Z=n.ntri_smooth*(f+n.normal_index_bytes*3);$=n.ntri_flat_uv* (f+n.uv_index_bytes*3);aa=n.ntri_smooth_uv*(f+n.normal_index_bytes*3+n.uv_index_bytes*3);ba=n.nquad_flat*W;f=n.nquad_smooth*(W+n.normal_index_bytes*4);W=n.nquad_flat_uv*(W+n.uv_index_bytes*4);z+=function(t){for(var v,A,D,H=n.vertex_coordinate_bytes*3,S=t+n.nvertices*H;t=this.maxCount-3&&h(this)};this.begin= function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;ethis.size-1&&(j=this.size-1);var p=Math.floor(l-h);p<1&&(p=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var o=Math.floor(k-h);o<1&&(o=1);h=Math.floor(k+h); h>this.size-1&&(h=this.size-1);for(var x,w,u,B,z,n;m0&&(this.field[u+x]+=B)}}}};this.addPlaneX=function(b,e){var c,f,g,h,j,l=this.size,k=this.yd,m=this.zd,p=this.field,o=l*Math.sqrt(b/e);o>l&&(o=l);for(c=0;c0)for(f=0;fk&&(x=k);for(f=0;f0){j=f*m;for(c=0;csize&&(dist=size);for(g=0;g0){j=zd*g;for(f=0;ff?this.hits.push(c):this.hits.unshift(c);f=e}}return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(a){var d=this.rayCastAll(a);if(d.length==0)return null;for(var b=0;d[b]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,d[b]);if(ed.length)return null;return d[b]}; THREE.CollisionSystem.prototype.rayCast=function(a,d){if(d instanceof THREE.PlaneCollider)return this.rayPlane(a,d);else if(d instanceof THREE.SphereCollider)return this.raySphere(a,d);else if(d instanceof THREE.BoxCollider)return this.rayBox(a,d);else if(d instanceof THREE.MeshCollider&&d.box)return this.rayBox(a,d.box)}; THREE.CollisionSystem.prototype.rayMesh=function(a,d){for(var b=this.makeRayLocal(a,d.mesh),e=Number.MAX_VALUE,c=0;c=h*f))return Number.MAX_VALUE;g/=h;h=THREE.CollisionSystem.__v3;h.copy(a.direction);h.multiplyScalar(g);h.addSelf(a.origin);if(Math.abs(c.x)>Math.abs(c.y))if(Math.abs(c.x)>Math.abs(c.z)){a=h.y-d.y;c=b.y-d.y;f=e.y-d.y; h=h.z-d.z;b=b.z-d.z;e=e.z-d.z}else{a=h.x-d.x;c=b.x-d.x;f=e.x-d.x;h=h.y-d.y;b=b.y-d.y;e=e.y-d.y}else if(Math.abs(c.y)>Math.abs(c.z)){a=h.x-d.x;c=b.x-d.x;f=e.x-d.x;h=h.z-d.z;b=b.z-d.z;e=e.z-d.z}else{a=h.x-d.x;c=b.x-d.x;f=e.x-d.x;h=h.y-d.y;b=b.y-d.y;e=e.y-d.y}d=c*e-b*f;if(d==0)return Number.MAX_VALUE;d=1/d;e=(a*e-h*f)*d;if(!(e>=0))return Number.MAX_VALUE;d*=c*h-b*a;if(!(d>=0))return Number.MAX_VALUE;if(!(1-e-d>=0))return Number.MAX_VALUE;return g}; THREE.CollisionSystem.prototype.makeRayLocal=function(a,d){var b=new THREE.Ray(a.origin.clone(),a.direction.clone()),e=THREE.Matrix4.makeInvert(d.matrixWorld);e.multiplyVector3(b.origin);e.rotateAxis(b.direction);b.direction.normalize();return b}; THREE.CollisionSystem.prototype.rayBox=function(a,d){var b;b=d.dynamic&&d.mesh&&d.mesh.matrixWorld?this.makeRayLocal(a,d.mesh):new THREE.Ray(a.origin.clone(),a.direction.clone());var e=0,c=0,f=0,g=0,h=0,j=0,l=!0;if(b.origin.xd.max.x){e=d.max.x-b.origin.x;e/=b.direction.x;l=!1;g=1}if(b.origin.yd.max.y){c=d.max.y-b.origin.y;c/=b.direction.y;l=!1;h= 1}if(b.origin.zd.max.z){f=d.max.z-b.origin.z;f/=b.direction.z;l=!1;j=1}if(l)return-1;l=0;if(c>e){l=1;e=c}if(f>e){l=2;e=f}switch(l){case 0:h=b.origin.y+b.direction.y*e;if(hd.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(bd.max.z)return Number.MAX_VALUE;d.normal=new THREE.Vector3(g,0,0);break;case 1:g=b.origin.x+b.direction.x*e;if(gd.max.x)return Number.MAX_VALUE;b=b.origin.z+ b.direction.z*e;if(bd.max.z)return Number.MAX_VALUE;d.normal=new THREE.Vector3(0,h,0);break;case 2:g=b.origin.x+b.direction.x*e;if(gd.max.x)return Number.MAX_VALUE;h=b.origin.y+b.direction.y*e;if(hd.max.y)return Number.MAX_VALUE;d.normal=new THREE.Vector3(0,0,j)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,d){var b=a.direction.dot(d.normal),e=d.point.dot(d.normal);if(b<0)b=(e-a.origin.dot(d.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(a,d){var b=d.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.CollisionUtils={}; THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var d=a.geometry.boundingBox,b=new THREE.Vector3(d.x[0],d.y[0],d.z[0]);d=new THREE.Vector3(d.x[1],d.y[1],d.z[1]);b=new THREE.BoxCollider(b,d);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var d=THREE.CollisionUtils.MeshOBB(a);d.min.addSelf(a.position);d.max.addSelf(a.position);d.dynamic=!1;return d}; THREE.CollisionUtils.MeshColliderWBox=function(a){for(var d=a.geometry.vertices,b=d.length,e=a.geometry.faces,c=e.length,f=[],g=[],h=[],j=0;j