ThreeExtras.js 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // ThreeExtras.js r36 - http://github.com/mrdoob/three.js
  2. var GeometryUtils={merge:function(b,e){var a=e instanceof THREE.Mesh,c=b.vertices.length,f=a?e.geometry:e,d=b.vertices,g=f.vertices,j=b.faces,h=f.faces,l=b.uvs;f=f.uvs;a&&e.matrixAutoUpdate&&e.updateMatrix();for(var m=0,n=g.length;m<n;m++){var o=new THREE.Vertex(g[m].position.clone());a&&e.matrix.multiplyVector3(o.position);d.push(o)}m=0;for(n=h.length;m<n;m++){g=h[m];var k,p=g.vertexNormals;if(g instanceof THREE.Face3)k=new THREE.Face3(g.a+c,g.b+c,g.c+c);else g instanceof THREE.Face4&&(k=new THREE.Face4(g.a+
  3. c,g.b+c,g.c+c,g.d+c));k.centroid.copy(g.centroid);k.normal.copy(g.normal);a=0;for(d=p.length;a<d;a++){o=p[a];k.vertexNormals.push(o.clone())}k.materials=g.materials.slice();j.push(k)}m=0;for(n=f.length;m<n;m++){c=f[m];j=[];a=0;for(d=c.length;a<d;a++)j.push(new THREE.UV(c[a].u,c[a].v));l.push(j)}}},ImageUtils={loadTexture:function(b,e,a){var c=new Image,f=new THREE.Texture(c,e);c.onload=function(){f.needsUpdate=!0;a&&a(this)};c.src=b;return f},loadTextureCube:function(b,e,a){var c,f=[],d=new THREE.Texture(f,
  4. e);e=f.loadCount=0;for(c=b.length;e<c;++e){f[e]=new Image;f[e].onload=function(){f.loadCount+=1;if(f.loadCount==6)d.needsUpdate=!0;a&&a(this)};f[e].src=b[e]}return d}},SceneUtils={loadScene:function(b,e,a,c){b=new Worker(b);b.postMessage(0);b.onmessage=function(f){function d(){for(m in w.objects)if(!x.objects[m]){t=w.objects[m];if(B=x.geometries[t.geometry]){F=[];for(i=0;i<t.materials.length;i++)F[i]=x.materials[t.materials[i]];u=t.position;r=t.rotation;s=t.scale;object=new THREE.Mesh(B,F);object.position.set(u[0],
  5. u[1],u[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=t.visible;x.scene.addObject(object);x.objects[m]=object}}}function g(H){return function(G){x.geometries[H]=G;d();y-=1;j()}}function j(){c({total_models:E,total_textures:I,loaded_models:E-y,loaded_textures:I-D},x);y==0&&D==0&&a(x)}var h,l,m,n,o,k,p,t,u,q,v,B,A,z,F,w,C,y,D,E,I,x;w=f.data;C=new THREE.Loader;D=y=0;x={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},
  6. fogs:{}};f=function(){D-=1;j()};for(o in w.cameras){q=w.cameras[o];if(q.type=="perspective")A=new THREE.Camera(q.fov,q.aspect,q.near,q.far);else if(q.type=="ortho"){A=new THREE.Camera;A.projectionMatrix=THREE.Matrix4.makeOrtho(q.left,q.right,q.top,q.bottom,q.near,q.far)}u=q.position;q=q.target;A.position.set(u[0],u[1],u[2]);A.target.position.set(q[0],q[1],q[2]);x.cameras[o]=A}for(n in w.lights){o=w.lights[n];if(o.type=="directional"){u=o.direction;light=new THREE.DirectionalLight;light.position.set(u[0],
  7. u[1],u[2]);light.position.normalize()}else if(o.type=="point"){u=o.position;light=new THREE.PointLight;light.position.set(u[0],u[1],u[2])}q=o.color;i=o.intensity||1;light.color.setRGB(q[0]*i,q[1]*i,q[2]*i);x.scene.addLight(light);x.lights[n]=light}for(k in w.fogs){n=w.fogs[k];if(n.type=="linear")z=new THREE.Fog(0,n.near,n.far);else n.type=="exp2"&&(z=new THREE.FogExp2(0,n.density));q=n.color;z.color.setRGB(q[0],q[1],q[2]);x.fogs[k]=z}if(x.cameras&&w.defaults.camera)x.currentCamera=x.cameras[w.defaults.camera];
  8. if(x.fogs&&w.defaults.fog)x.scene.fog=x.fogs[w.defaults.fog];q=w.defaults.bgcolor;x.bgColor=new THREE.Color;x.bgColor.setRGB(q[0],q[1],q[2]);x.bgColorAlpha=w.defaults.bgalpha;for(h in w.geometries){k=w.geometries[h];if(k.type=="bin_mesh"||k.type=="ascii_mesh")y+=1}E=y;for(h in w.geometries){k=w.geometries[h];if(k.type=="cube"){B=new Cube(k.width,k.height,k.depth,k.segmentsWidth,k.segmentsHeight,k.segmentsDepth,null,k.flipped,k.sides);x.geometries[h]=B}else if(k.type=="plane"){B=new Plane(k.width,
  9. k.height,k.segmentsWidth,k.segmentsHeight);x.geometries[h]=B}else if(k.type=="sphere"){B=new Sphere(k.radius,k.segmentsWidth,k.segmentsHeight);x.geometries[h]=B}else if(k.type=="cylinder"){B=new Cylinder(k.numSegs,k.topRad,k.botRad,k.height,k.topOffset,k.botOffset);x.geometries[h]=B}else if(k.type=="torus"){B=new Torus(k.radius,k.tube,k.segmentsR,k.segmentsT);x.geometries[h]=B}else if(k.type=="icosahedron"){B=new Icosahedron(k.subdivisions);x.geometries[h]=B}else if(k.type=="bin_mesh")C.loadBinary({model:k.url,
  10. callback:g(h)});else k.type=="ascii_mesh"&&C.loadAscii({model:k.url,callback:g(h)})}for(p in w.textures){h=w.textures[p];D+=h.url instanceof Array?h.url.length:1}I=D;for(p in w.textures){h=w.textures[p];if(h.mapping!=undefined&&THREE[h.mapping]!=undefined)h.mapping=new THREE[h.mapping];if(h.url instanceof Array)k=ImageUtils.loadTextureCube(h.url,h.mapping,f);else{k=ImageUtils.loadTexture(h.url,h.mapping,f);if(THREE[h.minFilter]!=undefined)k.minFilter=THREE[h.minFilter];if(THREE[h.magFilter]!=undefined)k.magFilter=
  11. THREE[h.magFilter]}x.textures[p]=k}for(l in w.materials){p=w.materials[l];for(v in p.parameters)if(v=="envMap"||v=="map"||v=="lightMap")p.parameters[v]=x.textures[p.parameters[v]];else if(v=="shading")p.parameters[v]=p.parameters[v]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(v=="blending")p.parameters[v]=THREE[p.parameters[v]]?THREE[p.parameters[v]]:THREE.NormalBlending;else v=="combine"&&(p.parameters[v]=p.parameters[v]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);p=new THREE[p.type](p.parameters);
  12. x.materials[l]=p}d();e(x)}},addMesh:function(b,e,a,c,f,d,g,j,h,l){e=new THREE.Mesh(e,l);e.scale.x=e.scale.y=e.scale.z=a;e.position.x=c;e.position.y=f;e.position.z=d;e.rotation.x=g;e.rotation.y=j;e.rotation.z=h;b.addObject(e);return e},addPanoramaCubeWebGL:function(b,e,a){var c=ShaderUtils.lib.cube;c.uniforms.tCube.texture=a;a=new THREE.MeshShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,uniforms:c.uniforms});e=new THREE.Mesh(new Cube(e,e,e,1,1,1,null,!0),a);b.addObject(e);
  13. return e},addPanoramaCube:function(b,e,a){var c=[];c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(a[0])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(a[1])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(a[2])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(a[3])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(a[4])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(a[5])}));e=new THREE.Mesh(new Cube(e,e,e,1,1,c,!0),new THREE.MeshFaceMaterial);
  14. b.addObject(e);return e},addPanoramaCubePlanes:function(b,e,a){var c=e/2;e=new Plane(e,e);var f=Math.PI,d=Math.PI/2;SceneUtils.addMesh(b,e,1,0,0,-c,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(a[5])}));SceneUtils.addMesh(b,e,1,-c,0,0,0,d,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(a[0])}));SceneUtils.addMesh(b,e,1,c,0,0,0,-d,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(a[1])}));SceneUtils.addMesh(b,e,1,0,c,0,d,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(a[2])}));
  15. SceneUtils.addMesh(b,e,1,0,-c,0,-d,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(a[3])}))},showHierarchy:function(b,e){SceneUtils.traverseHierarchy(b,function(a){a.visible=e})},traverseHierarchy:function(b,e){var a,c,f=b.children.length;for(c=0;c<f;c++){a=b.children[c];e(a);SceneUtils.traverseHierarchy(a,e)}}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",
  16. value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
  17. vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
  18. normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
  19. uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragmentShader:"uniform vec3 uDirLightPos;\nuniform vec3 uAmbientLightColor;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform bool enableDiffuse;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );\nvec3 aoTex = vec3( 1.0, 1.0, 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ndiffuseTex = texture2D( tDiffuse, vUv ).xyz;\nif( enableAO )\naoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\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 = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\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}",
  20. 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}"},
  21. 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",
  22. 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; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
  23. film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time * 1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor = vec4( cResult, cTextureScreen.a );\n}"},
  24. screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
  25. fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(b){var e,a,c,f,d=2*Math.ceil(b*3)+1;d>25&&(d=25);f=(d-1)*0.5;a=Array(d);for(e=c=0;e<d;++e){a[e]=Math.exp(-((e-f)*(e-f))/(2*b*b));c+=a[e]}for(e=0;e<d;++e)a[e]/=c;return a}};
  26. THREE.QuakeCamera=function(b){function e(a,c){return function(){c.apply(a,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.lookSpeed!==undefined)this.lookSpeed=b.lookSpeed;if(b.noFly!==undefined)this.noFly=
  27. b.noFly;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.autoForward!==undefined)this.autoForward=b.autoForward;if(b.dragToLook!==undefined)this.dragToLook=b.dragToLook;if(b.heightSpeed!==undefined)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==undefined)this.heightCoef=b.heightCoef;if(b.heightMin!==undefined)this.heightMin=b.heightMin;if(b.heightMax!==undefined)this.heightMax=b.heightMax;if(b.domElement!==undefined)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=
  28. this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(a){a.preventDefault();a.stopPropagation();if(!this.dragToLook)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.dragToLook)switch(a.button){case 0:this.moveForward=
  29. !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}};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=
  30. !1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed);
  31. var a=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(a=0);this.lon+=this.mouseX*a;this.lookVertical&&(this.lat-=this.mouseY*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;a=this.target.position;var c=this.position;a.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=c.y+100*Math.cos(this.phi);a.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},
  32. !1);this.domElement.addEventListener("mousemove",e(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",e(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",e(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",e(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",e(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
  33. THREE.QuakeCamera.prototype.translate=function(b,e){this.matrix.rotateAxis(e);if(this.noFly)e.y=0;this.position.addSelf(e.multiplyScalar(b));this.target.position.addSelf(e.multiplyScalar(b))};
  34. THREE.PathCamera=function(b){function e(l,m,n,o){var k={name:n,fps:0.6,length:o,hierarchy:[]},p,t=m.getControlPointsArray(),u=m.getLength(),q=t.length,v=0;p=q-1;m={parent:-1,keys:[]};m.keys[0]={time:0,pos:t[0],rot:[0,0,0,1],scl:[1,1,1]};m.keys[p]={time:o,pos:t[p],rot:[0,0,0,1],scl:[1,1,1]};for(p=1;p<q-1;p++){v=o*u.chunks[p]/u.total;m.keys[p]={time:v,pos:t[p]}}k.hierarchy[0]=m;THREE.AnimationHandler.add(k);return new THREE.Animation(l,n,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function a(l,m){var n,
  35. o,k=new THREE.Geometry;for(n=0;n<l.points.length*m;n++){o=n/(l.points.length*m);o=l.getPoint(o);k.vertices[n]=new THREE.Vertex(new THREE.Vector3(o.x,o.y,o.z))}return k}function c(l,m){var n=a(m,10),o=a(m,10),k=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(n,k);particleObj=new THREE.ParticleSystem(o,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);l.addChild(lineObj);particleObj.scale.set(1,1,1);l.addChild(particleObj);o=new Sphere(1,
  36. 16,8);k=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<m.points.length;i++){n=new THREE.Mesh(o,k);n.position.copy(m.points[i]);n.updateMatrix();l.addChild(n)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
  37. !0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(b){if(b.duration!==undefined)this.duration=b.duration*1E3;if(b.waypoints!==undefined)this.waypoints=b.waypoints;if(b.useConstantSpeed!==undefined)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==undefined)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==undefined)this.createDebugPath=b.createDebugPath;
  38. if(b.createDebugDummy!==undefined)this.createDebugDummy=b.createDebugDummy;if(b.lookSpeed!==undefined)this.lookSpeed=b.lookSpeed;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.lookHorizontal!==undefined)this.lookHorizontal=b.lookHorizontal;if(b.verticalAngleMap!==undefined)this.verticalAngleMap=b.verticalAngleMap;if(b.horizontalAngleMap!==undefined)this.horizontalAngleMap=b.horizontalAngleMap;if(b.domElement!==undefined)this.domElement=b.domElement}this.theta=this.phi=this.lon=
  39. this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,d=Math.PI/180;this.update=function(l,m,n){var o,k;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*d;this.theta=this.lon*d;o=this.phi%f;this.phi=o>=0?o:o+f;o=this.verticalAngleMap.srcRange;k=this.verticalAngleMap.dstRange;
  40. this.phi=(this.phi-o[0])*(k[1]-k[0])/(o[1]-o[0])+k[0];o=this.horizontalAngleMap.srcRange;k=this.horizontalAngleMap.dstRange;this.theta=(this.theta-o[0])*(k[1]-k[0])/(o[1]-o[0])+k[0];o=this.target.position;o.x=100*Math.sin(this.phi)*Math.cos(this.theta);o.y=100*Math.cos(this.phi);o.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,m,n)};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);
  41. this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){b=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),j=new Cube(10,10,20),h=new Cube(2,2,10);this.animationParent=new THREE.Mesh(j,b);b=new THREE.Mesh(h,g);b.position.set(0,10,0);this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else{this.animation=
  42. e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&c(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(l,m){return function(){m.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;
  43. var Cube=function(b,e,a,c,f,d,g,j,h){function l(u,q,v,B,A,z,F,w){var C,y,D=c||1,E=f||1,I=A/2,x=z/2,H=m.vertices.length;if(u=="x"&&q=="y"||u=="y"&&q=="x")C="z";else if(u=="x"&&q=="z"||u=="z"&&q=="x"){C="y";E=d||1}else if(u=="z"&&q=="y"||u=="y"&&q=="z"){C="x";D=d||1}var G=D+1,K=E+1;A/=D;var L=z/E;for(y=0;y<K;y++)for(z=0;z<G;z++){var J=new THREE.Vector3;J[u]=(z*A-I)*v;J[q]=(y*L-x)*B;J[C]=F;m.vertices.push(new THREE.Vertex(J))}for(y=0;y<E;y++)for(z=0;z<D;z++){m.faces.push(new THREE.Face4(z+G*y+H,z+G*
  44. (y+1)+H,z+1+G*(y+1)+H,z+1+G*y+H,null,null,w));m.faceVertexUvs.push([new THREE.UV(z/D,y/E),new THREE.UV(z/D,(y+1)/E),new THREE.UV((z+1)/D,(y+1)/E),new THREE.UV((z+1)/D,y/E)])}}THREE.Geometry.call(this);var m=this,n=b/2,o=e/2,k=a/2;j=j?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var p=0;p<6;p++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(h!=undefined)for(var t in h)this.sides[t]!=undefined&&(this.sides[t]=
  45. h[t]);this.sides.px&&l("z","y",1*j,-1,a,e,-n,this.materials[0]);this.sides.nx&&l("z","y",-1*j,-1,a,e,n,this.materials[1]);this.sides.py&&l("x","z",1*j,1,b,a,o,this.materials[2]);this.sides.ny&&l("x","z",1*j,-1,b,a,-o,this.materials[3]);this.sides.pz&&l("x","y",1*j,-1,b,e,k,this.materials[4]);this.sides.nz&&l("x","y",-1*j,-1,b,e,-k,this.materials[5]);(function(){for(var u=[],q=[],v=0,B=m.vertices.length;v<B;v++){for(var A=m.vertices[v],z=!1,F=0,w=u.length;F<w;F++){var C=u[F];if(A.position.x==C.position.x&&
  46. A.position.y==C.position.y&&A.position.z==C.position.z){q[v]=F;z=!0;break}}if(!z){q[v]=u.length;u.push(new THREE.Vertex(A.position.clone()))}}v=0;for(B=m.faces.length;v<B;v++){A=m.faces[v];A.a=q[A.a];A.b=q[A.b];A.c=q[A.c];A.d=q[A.d]}m.vertices=u})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
  47. var Cylinder=function(b,e,a,c,f,d){function g(m,n,o){j.vertices.push(new THREE.Vertex(new THREE.Vector3(m,n,o)))}THREE.Geometry.call(this);var j=this,h=Math.PI,l=c/2;for(c=0;c<b;c++)g(Math.sin(2*h*c/b)*e,Math.cos(2*h*c/b)*e,-l);for(c=0;c<b;c++)g(Math.sin(2*h*c/b)*a,Math.cos(2*h*c/b)*a,l);for(c=0;c<b;c++)j.faces.push(new THREE.Face4(c,c+b,b+(c+1)%b,(c+1)%b));if(a>0){g(0,0,-l-(d||0));for(c=b;c<b+b/2;c++)j.faces.push(new THREE.Face4(2*b,(2*c-2*b)%b,(2*c-2*b+1)%b,(2*c-2*b+2)%b))}if(e>0){g(0,0,l+(f||0));
  48. for(c=b+b/2;c<2*b;c++)j.faces.push(new THREE.Face4(2*b+1,(2*c-2*b+2)%b+b,(2*c-2*b+1)%b+b,(2*c-2*b)%b+b))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
  49. var Icosahedron=function(b){function e(n,o,k){var p=Math.sqrt(n*n+o*o+k*k);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(n/p,o/p,k/p)))-1}function a(n,o,k,p){p.faces.push(new THREE.Face3(n,o,k))}function c(n,o){var k=f.vertices[n].position,p=f.vertices[o].position;return e((k.x+p.x)/2,(k.y+p.y)/2,(k.z+p.z)/2)}var f=this,d=new THREE.Geometry,g;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;e(-1,b,0);e(1,b,0);e(-1,-b,0);e(1,-b,0);e(0,-1,b);e(0,1,b);e(0,-1,-b);e(0,
  50. 1,-b);e(b,0,-1);e(b,0,1);e(-b,0,-1);e(-b,0,1);a(0,11,5,d);a(0,5,1,d);a(0,1,7,d);a(0,7,10,d);a(0,10,11,d);a(1,5,9,d);a(5,11,4,d);a(11,10,2,d);a(10,7,6,d);a(7,1,8,d);a(3,9,4,d);a(3,4,2,d);a(3,2,6,d);a(3,6,8,d);a(3,8,9,d);a(4,9,5,d);a(2,4,11,d);a(6,2,10,d);a(8,6,7,d);a(9,8,1,d);for(b=0;b<this.subdivisions;b++){g=new THREE.Geometry;for(var j in d.faces){var h=c(d.faces[j].a,d.faces[j].b),l=c(d.faces[j].b,d.faces[j].c),m=c(d.faces[j].c,d.faces[j].a);a(d.faces[j].a,h,m,g);a(d.faces[j].b,l,h,g);a(d.faces[j].c,
  51. m,l,g);a(h,l,m,g)}d.faces=g.faces}f.faces=d.faces;delete d;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
  52. function Lathe(b,e,a){THREE.Geometry.call(this);this.steps=e||12;this.angle=a||2*Math.PI;e=this.angle/this.steps;for(var c=[],f=[],d=[],g=[],j=0;j<b.length;j++){this.vertices.push(new THREE.Vertex(b[j]));c[j]=b[j].clone();f[j]=this.vertices.length-1}for(var h=(new THREE.Matrix4).setRotationZ(e),l=0;l<=this.angle+0.0010;l+=e){for(j=0;j<c.length;j++)if(l<this.angle){c[j]=h.multiplyVector3(c[j].clone());this.vertices.push(new THREE.Vertex(c[j]));d[j]=this.vertices.length-1}else d=g;l==0&&(g=f);for(j=
  53. 0;j<f.length-1;j++){this.faces.push(new THREE.Face4(d[j],d[j+1],f[j+1],f[j]));this.uvs.push([new THREE.UV(l/a,j/b.length),new THREE.UV(l/a,(j+1)/b.length),new THREE.UV((l-e)/a,(j+1)/b.length),new THREE.UV((l-e)/a,j/b.length)])}f=d;d=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
  54. var Plane=function(b,e,a,c){THREE.Geometry.call(this);var f,d=b/2,g=e/2;a=a||1;c=c||1;var j=a+1,h=c+1;b/=a;var l=e/c;for(f=0;f<h;f++)for(e=0;e<j;e++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(e*b-d,-(f*l-g),0)));for(f=0;f<c;f++)for(e=0;e<a;e++){this.faces.push(new THREE.Face4(e+j*f,e+j*(f+1),e+1+j*(f+1),e+1+j*f));this.faceVertexUvs.push([new THREE.UV(e/a,f/c),new THREE.UV(e/a,(f+1)/c),new THREE.UV((e+1)/a,(f+1)/c),new THREE.UV((e+1)/a,f/c)])}this.computeCentroids();this.computeFaceNormals()};
  55. Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
  56. var Sphere=function(b,e,a){THREE.Geometry.call(this);var c,f=Math.PI,d=Math.max(3,e||8),g=Math.max(2,a||6);e=[];for(a=0;a<g+1;a++){c=a/g;var j=b*Math.cos(c*f),h=b*Math.sin(c*f),l=[],m=0;for(c=0;c<d;c++){var n=2*c/d,o=h*Math.sin(n*f);n=h*Math.cos(n*f);(a==0||a==g)&&c>0||(m=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,j,o)))-1);l.push(m)}e.push(l)}var k,p,t;f=e.length;for(a=0;a<f;a++){d=e[a].length;if(a>0)for(c=0;c<d;c++){l=c==d-1;g=e[a][l?0:c+1];j=e[a][l?d-1:c];h=e[a-1][l?d-1:c];l=e[a-1][l?
  57. 0:c+1];o=a/(f-1);k=(a-1)/(f-1);p=(c+1)/d;n=c/d;m=new THREE.UV(1-p,o);o=new THREE.UV(1-n,o);n=new THREE.UV(1-n,k);var u=new THREE.UV(1-p,k);if(a<e.length-1){k=this.vertices[g].position.clone();p=this.vertices[j].position.clone();t=this.vertices[h].position.clone();k.normalize();p.normalize();t.normalize();this.faces.push(new THREE.Face3(g,j,h,[new THREE.Vector3(k.x,k.y,k.z),new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(t.x,t.y,t.z)]));this.uvs.push([m,o,n])}if(a>1){k=this.vertices[g].position.clone();
  58. p=this.vertices[h].position.clone();t=this.vertices[l].position.clone();k.normalize();p.normalize();t.normalize();this.faces.push(new THREE.Face3(g,h,l,[new THREE.Vector3(k.x,k.y,k.z),new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(t.x,t.y,t.z)]));this.uvs.push([m,n,u])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
  59. var Torus=function(b,e,a,c){this.radius=b||100;this.tube=e||40;this.segmentsR=a||8;this.segmentsT=c||6;b=[];THREE.Geometry.call(this);for(e=0;e<=this.segmentsR;++e)for(a=0;a<=this.segmentsT;++a){c=a/this.segmentsT*2*Math.PI;var f=e/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(c),(this.radius+this.tube*Math.cos(f))*Math.sin(c),this.tube*Math.sin(f))));b.push([a/this.segmentsT,1-e/this.segmentsR])}for(e=1;e<=this.segmentsR;++e)for(a=
  60. 1;a<=this.segmentsT;++a){c=(this.segmentsT+1)*e+a;f=(this.segmentsT+1)*e+a-1;var d=(this.segmentsT+1)*(e-1)+a-1,g=(this.segmentsT+1)*(e-1)+a;this.faces.push(new THREE.Face4(c,f,d,g));this.uvs.push([new THREE.UV(b[c][0],b[c][1]),new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[d][0],b[d][1]),new THREE.UV(b[g][0],b[g][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
  61. var TorusKnot=function(b,e,a,c,f,d,g){function j(n,o,k,p,t,u){o=k/p*n;k=Math.cos(o);return new THREE.Vector3(t*(2+k)*0.5*Math.cos(n),t*(2+k)*Math.sin(n)*0.5,u*t*Math.sin(o)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=e||40;this.segmentsR=a||64;this.segmentsT=c||8;this.p=f||2;this.q=d||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);a=new THREE.Vector3;c=new THREE.Vector3;d=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(e=0;e<this.segmentsT;++e){var h=
  62. b/this.segmentsR*2*this.p*Math.PI;g=e/this.segmentsT*2*Math.PI;f=j(h,g,this.q,this.p,this.radius,this.heightScale);h=j(h+0.01,g,this.q,this.p,this.radius,this.heightScale);a.x=h.x-f.x;a.y=h.y-f.y;a.z=h.z-f.z;c.x=h.x+f.x;c.y=h.y+f.y;c.z=h.z+f.z;d.cross(a,c);c.cross(d,a);d.normalize();c.normalize();h=this.tube*Math.cos(g);g=this.tube*Math.sin(g);f.x+=h*c.x+g*d.x;f.y+=h*c.y+g*d.y;f.z+=h*c.z+g*d.z;this.grid[b][e]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z)))-1}}for(b=0;b<this.segmentsR;++b)for(e=
  63. 0;e<this.segmentsT;++e){d=(b+1)%this.segmentsR;g=(e+1)%this.segmentsT;f=this.grid[b][e];a=this.grid[d][e];c=this.grid[b][g];d=this.grid[d][g];g=new THREE.UV(b/this.segmentsR,e/this.segmentsT);h=new THREE.UV((b+1)/this.segmentsR,e/this.segmentsT);var l=new THREE.UV(b/this.segmentsR,(e+1)/this.segmentsT),m=new THREE.UV((b+1)/this.segmentsR,(e+1)/this.segmentsT);this.faces.push(new THREE.Face3(f,a,c));this.uvs.push([g,h,l]);this.faces.push(new THREE.Face3(d,c,a));this.uvs.push([m,l,h])}this.computeCentroids();
  64. this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(){this.statusDomElement=(this.showStatus=showStatus)?this.addStatusElement():null};
  65. THREE.Loader.prototype={addStatusElement:function(){var b=document.createElement("div");b.style.fontSize="0.8em";b.style.textAlign="left";b.style.background="#b00";b.style.color="#fff";b.style.width="140px";b.style.padding="0.25em 0.25em 0.25em 0.5em";b.style.position="absolute";b.style.right="0px";b.style.top="0px";b.style.zIndex=1E3;b.innerHTML="Loading ...";return b},updateProgress:function(b){var e="Loaded ";e+=b.total?(100*b.loaded/b.total).toFixed(0)+"%":(b.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=
  66. e},extractUrlbase:function(b){b=b.split("/");b.pop();return b.join("/")},init_materials:function(b,e,a){b.materials=[];for(var c=0;c<e.length;++c)b.materials[c]=[THREE.Loader.prototype.createMaterial(e[c],a)]},createMaterial:function(b,e){function a(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}function c(j,h){var l=new Image;l.onload=function(){if(!a(this.width)||!a(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),n=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));
  67. j.image.width=m;j.image.height=n;j.image.getContext("2d").drawImage(this,0,0,m,n)}else j.image=this;j.needsUpdate=!0};l.src=h}var f,d,g;f="MeshLambertMaterial";d={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:b.vertexColors};b.shading&&b.shading=="Phong"&&(f="MeshPhongMaterial");if(b.mapDiffuse&&e){g=document.createElement("canvas");d.map=new THREE.Texture(g);d.map.sourceFile=b.mapDiffuse;c(d.map,e+"/"+b.mapDiffuse)}else if(b.colorDiffuse){g=(b.colorDiffuse[0]*255<<16)+(b.colorDiffuse[1]*
  68. 255<<8)+b.colorDiffuse[2]*255;d.color=g;d.opacity=b.transparency}else if(b.DbgColor)d.color=b.DbgColor;if(b.mapLightmap&&e){g=document.createElement("canvas");d.lightMap=new THREE.Texture(g);d.lightMap.sourceFile=b.mapLightmap;c(d.lightMap,e+"/"+b.mapLightmap)}return new THREE[f](d)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
  69. THREE.MarchingCubes=function(b,e){THREE.Object3D.call(this);this.materials=e instanceof Array?e:[e];this.init=function(a){this.isolation=80;this.size=a;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
  70. 0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(a,c,f){return a+(c-a)*f};this.VIntX=function(a,c,f,d,g,j,h,l,m,n){g=(g-m)/(n-m);m=this.normal_cache;c[d]=j+g*this.delta;c[d+1]=h;c[d+2]=l;f[d]=this.lerp(m[a],m[a+3],g);f[d+1]=this.lerp(m[a+1],m[a+4],g);f[d+2]=this.lerp(m[a+2],m[a+5],g)};this.VIntY=function(a,c,f,d,g,j,h,l,m,n){g=(g-m)/(n-m);m=this.normal_cache;c[d]=j;c[d+1]=h+g*this.delta;c[d+
  71. 2]=l;c=a+this.yd*3;f[d]=this.lerp(m[a],m[c],g);f[d+1]=this.lerp(m[a+1],m[c+1],g);f[d+2]=this.lerp(m[a+2],m[c+2],g)};this.VIntZ=function(a,c,f,d,g,j,h,l,m,n){g=(g-m)/(n-m);m=this.normal_cache;c[d]=j;c[d+1]=h;c[d+2]=l+g*this.delta;c=a+this.zd*3;f[d]=this.lerp(m[a],m[c],g);f[d+1]=this.lerp(m[a+1],m[c+1],g);f[d+2]=this.lerp(m[a+2],m[c+2],g)};this.compNorm=function(a){var c=a*3;if(this.normal_cache[c]==0){this.normal_cache[c]=this.field[a-1]-this.field[a+1];this.normal_cache[c+1]=this.field[a-this.yd]-
  72. this.field[a+this.yd];this.normal_cache[c+2]=this.field[a-this.zd]-this.field[a+this.zd]}};this.polygonize=function(a,c,f,d,g,j){var h=d+1,l=d+this.yd,m=d+this.zd,n=h+this.yd,o=h+this.zd,k=d+this.yd+this.zd,p=h+this.yd+this.zd,t=0,u=this.field[d],q=this.field[h],v=this.field[l],B=this.field[n],A=this.field[m],z=this.field[o],F=this.field[k],w=this.field[p];u<g&&(t|=1);q<g&&(t|=2);v<g&&(t|=8);B<g&&(t|=4);A<g&&(t|=16);z<g&&(t|=32);F<g&&(t|=128);w<g&&(t|=64);var C=THREE.edgeTable[t];if(C==0)return 0;
  73. var y=this.delta,D=a+y,E=c+y;y=f+y;if(C&1){this.compNorm(d);this.compNorm(h);this.VIntX(d*3,this.vlist,this.nlist,0,g,a,c,f,u,q)}if(C&2){this.compNorm(h);this.compNorm(n);this.VIntY(h*3,this.vlist,this.nlist,3,g,D,c,f,q,B)}if(C&4){this.compNorm(l);this.compNorm(n);this.VIntX(l*3,this.vlist,this.nlist,6,g,a,E,f,v,B)}if(C&8){this.compNorm(d);this.compNorm(l);this.VIntY(d*3,this.vlist,this.nlist,9,g,a,c,f,u,v)}if(C&16){this.compNorm(m);this.compNorm(o);this.VIntX(m*3,this.vlist,this.nlist,12,g,a,c,y,
  74. A,z)}if(C&32){this.compNorm(o);this.compNorm(p);this.VIntY(o*3,this.vlist,this.nlist,15,g,D,c,y,z,w)}if(C&64){this.compNorm(k);this.compNorm(p);this.VIntX(k*3,this.vlist,this.nlist,18,g,a,E,y,F,w)}if(C&128){this.compNorm(m);this.compNorm(k);this.VIntY(m*3,this.vlist,this.nlist,21,g,a,c,y,A,F)}if(C&256){this.compNorm(d);this.compNorm(m);this.VIntZ(d*3,this.vlist,this.nlist,24,g,a,c,f,u,A)}if(C&512){this.compNorm(h);this.compNorm(o);this.VIntZ(h*3,this.vlist,this.nlist,27,g,D,c,f,q,z)}if(C&1024){this.compNorm(n);
  75. this.compNorm(p);this.VIntZ(n*3,this.vlist,this.nlist,30,g,D,E,f,B,w)}if(C&2048){this.compNorm(l);this.compNorm(k);this.VIntZ(l*3,this.vlist,this.nlist,33,g,a,E,f,v,F)}t<<=4;for(g=d=0;THREE.triTable[t+g]!=-1;){a=t+g;c=a+1;f=a+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[c],3*THREE.triTable[f],j);g+=3;d++}return d};this.posnormtriv=function(a,c,f,d,g,j){var h=this.count*3;this.positionArray[h]=a[f];this.positionArray[h+1]=a[f+1];this.positionArray[h+2]=a[f+2];this.positionArray[h+
  76. 3]=a[d];this.positionArray[h+4]=a[d+1];this.positionArray[h+5]=a[d+2];this.positionArray[h+6]=a[g];this.positionArray[h+7]=a[g+1];this.positionArray[h+8]=a[g+2];this.normalArray[h]=c[f];this.normalArray[h+1]=c[f+1];this.normalArray[h+2]=c[f+2];this.normalArray[h+3]=c[d];this.normalArray[h+4]=c[d+1];this.normalArray[h+5]=c[d+2];this.normalArray[h+6]=c[g];this.normalArray[h+7]=c[g+1];this.normalArray[h+8]=c[g+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=
  77. function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(a){if(this.count!=0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;a(this)}};this.addBall=function(a,c,f,d,g){var j=this.size*Math.sqrt(d/g),h=f*this.size,l=c*this.size,m=a*this.size,n=Math.floor(h-j);n<1&&(n=1);h=Math.floor(h+j);h>this.size-1&&(h=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 k=Math.floor(m-j);k<1&&(k=1);j=Math.floor(m+j);
  78. j>this.size-1&&(j=this.size-1);for(var p,t,u,q,v,B;n<h;n++){m=this.size2*n;t=n/this.size-f;v=t*t;for(t=o;t<l;t++){u=m+this.size*t;p=t/this.size-c;B=p*p;for(p=k;p<j;p++){q=p/this.size-a;q=d/(1.0E-6+q*q+B+v)-g;q>0&&(this.field[u+p]+=q)}}}};this.addPlaneX=function(a,c){var f,d,g,j,h,l=this.size,m=this.yd,n=this.zd,o=this.field,k=l*Math.sqrt(a/c);k>l&&(k=l);for(f=0;f<k;f++){d=f/l;d*=d;j=a/(1.0E-4+d)-c;if(j>0)for(d=0;d<l;d++){h=f+d*m;for(g=0;g<l;g++)o[n*g+h]+=j}}};this.addPlaneY=function(a,c){var f,d,
  79. g,j,h,l,m=this.size,n=this.yd,o=this.zd,k=this.field,p=m*Math.sqrt(a/c);p>m&&(p=m);for(d=0;d<p;d++){f=d/m;f*=f;j=a/(1.0E-4+f)-c;if(j>0){h=d*n;for(f=0;f<m;f++){l=h+f;for(g=0;g<m;g++)k[o*g+l]+=j}}}};this.addPlaneZ=function(a,c){var f,d,g,j,h,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(a/c);dist>size&&(dist=size);for(g=0;g<dist;g++){f=g/size;f*=f;j=a/(1.0E-4+f)-c;if(j>0){h=zd*g;for(d=0;d<size;d++){l=h+d*yd;for(f=0;f<size;f++)field[l+f]+=j}}}};this.reset=function(){var a;
  80. for(a=0;a<this.size3;a++){this.normal_cache[a*3]=0;this.field[a]=0}};this.render=function(a){this.begin();var c,f,d,g,j,h,l,m,n,o=this.size-2;for(g=1;g<o;g++){n=this.size2*g;l=(g-this.halfsize)/this.halfsize;for(d=1;d<o;d++){m=n+this.size*d;h=(d-this.halfsize)/this.halfsize;for(f=1;f<o;f++){j=(f-this.halfsize)/this.halfsize;c=m+f;this.polygonize(j,h,l,c,this.isolation,a)}}}this.end(a)};this.generateGeometry=function(){var a=0,c=new THREE.Geometry;this.render(function(f){var d,g,j,h,l,m,n,o;for(d=
  81. 0;d<f.count;d++){l=d*3;n=l+1;o=l+2;g=f.positionArray[l];j=f.positionArray[n];h=f.positionArray[o];m=new THREE.Vector3(g,j,h);g=f.normalArray[l];j=f.normalArray[n];h=f.normalArray[o];l=new THREE.Vector3(g,j,h);l.normalize();l=new THREE.Vertex(m,l);c.vertices.push(l)}nfaces=f.count/3;for(d=0;d<nfaces;d++){l=(a+d)*3;n=l+1;o=l+2;m=c.vertices[l].normal;g=c.vertices[n].normal;j=c.vertices[o].normal;l=new THREE.Face3(l,n,o,[m,g,j]);c.faces.push(l)}a+=nfaces;f.count=0});return c};this.init(b)};
  82. THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  83. THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
  84. 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
  85. 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
  86. THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,8,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-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