ThreeExtras.js 65 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // ThreeExtras.js r37 - http://github.com/mrdoob/three.js
  2. var GeometryUtils={merge:function(a,e){var b=e instanceof THREE.Mesh,c=a.vertices.length,d=b?e.geometry:e,f=a.vertices,g=d.vertices,h=a.faces,l=d.faces,k=a.faceVertexUvs[0];d=d.faceVertexUvs[0];b&&e.matrixAutoUpdate&&e.updateMatrix();for(var j=0,m=g.length;j<m;j++){var p=new THREE.Vertex(g[j].position.clone());b&&e.matrix.multiplyVector3(p.position);f.push(p)}j=0;for(m=l.length;j<m;j++){g=l[j];var w,t,z=g.vertexNormals;p=g.vertexColors;if(g instanceof THREE.Face3)w=new THREE.Face3(g.a+c,g.b+c,g.c+
  3. c);else g instanceof THREE.Face4&&(w=new THREE.Face4(g.a+c,g.b+c,g.c+c,g.d+c));w.normal.copy(g.normal);b=0;for(f=z.length;b<f;b++){t=z[b];w.vertexNormals.push(t.clone())}w.color.copy(g.color);b=0;for(f=p.length;b<f;b++){t=p[b];w.vertexColors.push(t.clone())}w.materials=g.materials.slice();w.centroid.copy(g.centroid);h.push(w)}j=0;for(m=d.length;j<m;j++){c=d[j];h=[];b=0;for(f=c.length;b<f;b++)h.push(new THREE.UV(c[b].u,c[b].v));k.push(h)}}},ImageUtils={loadTexture:function(a,e,b){var c=new Image,d=
  4. new THREE.Texture(c,e);c.onload=function(){d.needsUpdate=!0;b&&b(this)};c.src=a;return d},loadTextureCube:function(a,e,b){var c,d=[],f=new THREE.Texture(d,e);e=d.loadCount=0;for(c=a.length;e<c;++e){d[e]=new Image;d[e].onload=function(){d.loadCount+=1;if(d.loadCount==6)f.needsUpdate=!0;b&&b(this)};d[e].src=a[e]}return f}},SceneUtils={loadScene:function(a,e,b,c){var d=new Worker(a);d.postMessage(0);var f=THREE.Loader.prototype.extractUrlbase(a);d.onmessage=function(g){function h(X,Y){return Y=="relativeToHTML"?
  5. X:f+"/"+X}function l(){for(w in G.objects)if(!H.objects[w]){C=G.objects[w];if(L=H.geometries[C.geometry]){J=[];for(O=0;O<C.materials.length;O++)J[O]=H.materials[C.materials[O]];n=C.position;r=C.rotation;q=C.quaternion;s=C.scale;q=0;J.length==0&&(J[0]=new THREE.MeshFaceMaterial);object=new THREE.Mesh(L,J);object.position.set(n[0],n[1],n[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=
  6. C.visible;H.scene.addObject(object);H.objects[w]=object}}}function k(X){return function(Y){H.geometries[X]=Y;l();R-=1;j()}}function j(){c({total_models:Q,total_textures:T,loaded_models:Q-R,loaded_textures:T-P},H);R==0&&P==0&&b(H)}var m,p,w,t,z,y,A,C,n,E,D,L,M,K,J,G,N,U,R,P,Q,T,H;G=g.data;N=new THREE.BinaryLoader;U=new THREE.JSONLoader;P=R=0;H={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};g=function(){P-=1;j()};for(z in G.cameras){E=G.cameras[z];
  7. if(E.type=="perspective")M=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho"){M=new THREE.Camera;M.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far)}n=E.position;E=E.target;M.position.set(n[0],n[1],n[2]);M.target.position.set(E[0],E[1],E[2]);H.cameras[z]=M}for(t in G.lights){z=G.lights[t];M=z.color!==undefined?z.color:16777215;E=z.intensity!==undefined?z.intensity:1;if(z.type=="directional"){n=z.direction;light=new THREE.DirectionalLight(M,E);
  8. light.position.set(n[0],n[1],n[2]);light.position.normalize()}else if(z.type=="point"){n=z.position;light=new THREE.PointLight(M,E);light.position.set(n[0],n[1],n[2])}H.scene.addLight(light);H.lights[t]=light}for(y in G.fogs){t=G.fogs[y];if(t.type=="linear")K=new THREE.Fog(0,t.near,t.far);else t.type=="exp2"&&(K=new THREE.FogExp2(0,t.density));E=t.color;K.color.setRGB(E[0],E[1],E[2]);H.fogs[y]=K}if(H.cameras&&G.defaults.camera)H.currentCamera=H.cameras[G.defaults.camera];if(H.fogs&&G.defaults.fog)H.scene.fog=
  9. H.fogs[G.defaults.fog];E=G.defaults.bgcolor;H.bgColor=new THREE.Color;H.bgColor.setRGB(E[0],E[1],E[2]);H.bgColorAlpha=G.defaults.bgalpha;for(m in G.geometries){y=G.geometries[m];if(y.type=="bin_mesh"||y.type=="ascii_mesh")R+=1}Q=R;for(m in G.geometries){y=G.geometries[m];if(y.type=="cube"){L=new Cube(y.width,y.height,y.depth,y.segmentsWidth,y.segmentsHeight,y.segmentsDepth,null,y.flipped,y.sides);H.geometries[m]=L}else if(y.type=="plane"){L=new Plane(y.width,y.height,y.segmentsWidth,y.segmentsHeight);
  10. H.geometries[m]=L}else if(y.type=="sphere"){L=new Sphere(y.radius,y.segmentsWidth,y.segmentsHeight);H.geometries[m]=L}else if(y.type=="cylinder"){L=new Cylinder(y.numSegs,y.topRad,y.botRad,y.height,y.topOffset,y.botOffset);H.geometries[m]=L}else if(y.type=="torus"){L=new Torus(y.radius,y.tube,y.segmentsR,y.segmentsT);H.geometries[m]=L}else if(y.type=="icosahedron"){L=new Icosahedron(y.subdivisions);H.geometries[m]=L}else if(y.type=="bin_mesh")N.load({model:h(y.url,G.urlBaseType),callback:k(m)});else y.type==
  11. "ascii_mesh"&&U.load({model:h(y.url,G.urlBaseType),callback:k(m)})}for(A in G.textures){m=G.textures[A];P+=m.url instanceof Array?m.url.length:1}T=P;for(A in G.textures){m=G.textures[A];if(m.mapping!=undefined&&THREE[m.mapping]!=undefined)m.mapping=new THREE[m.mapping];if(m.url instanceof Array){y=[];for(var O=0;O<m.url.length;O++)y[O]=h(m.url[O],G.urlBaseType);y=ImageUtils.loadTextureCube(y,m.mapping,g)}else{y=ImageUtils.loadTexture(h(m.url,G.urlBaseType),m.mapping,g);if(THREE[m.minFilter]!=undefined)y.minFilter=
  12. THREE[m.minFilter];if(THREE[m.magFilter]!=undefined)y.magFilter=THREE[m.magFilter]}H.textures[A]=y}for(p in G.materials){A=G.materials[p];for(D in A.parameters)if(D=="envMap"||D=="map"||D=="lightMap")A.parameters[D]=H.textures[A.parameters[D]];else if(D=="shading")A.parameters[D]=A.parameters[D]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(D=="blending")A.parameters[D]=THREE[A.parameters[D]]?THREE[A.parameters[D]]:THREE.NormalBlending;else D=="combine"&&(A.parameters[D]=A.parameters[D]==
  13. "MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);A=new THREE[A.type](A.parameters);H.materials[p]=A}l();e(H)}},addMesh:function(a,e,b,c,d,f,g,h,l,k){e=new THREE.Mesh(e,k);e.scale.x=e.scale.y=e.scale.z=b;e.position.x=c;e.position.y=d;e.position.z=f;e.rotation.x=g;e.rotation.y=h;e.rotation.z=l;a.addObject(e);return e},addPanoramaCubeWebGL:function(a,e,b){var c=ShaderUtils.lib.cube;c.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,
  14. uniforms:c.uniforms});e=new THREE.Mesh(new Cube(e,e,e,1,1,1,null,!0),b);a.addObject(e);return e},addPanoramaCube:function(a,e,b){var c=[];c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));
  15. e=new THREE.Mesh(new Cube(e,e,e,1,1,c,!0),new THREE.MeshFaceMaterial);a.addObject(e);return e},addPanoramaCubePlanes:function(a,e,b){var c=e/2;e=new Plane(e,e);var d=Math.PI,f=Math.PI/2;SceneUtils.addMesh(a,e,1,0,0,-c,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,e,1,-c,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,e,1,c,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,
  16. e,1,0,c,0,f,0,d,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,e,1,0,-c,0,-f,0,d,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,e){SceneUtils.traverseHierarchy(a,function(b){b.visible=e})},traverseHierarchy:function(a,e){var b,c,d=a.children.length;for(c=0;c<d;c++){b=a.children[c];e(b);SceneUtils.traverseHierarchy(b,e)}}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},
  17. mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",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}",
  18. 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}"},
  19. 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},
  20. 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}",
  21. 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}"},
  22. 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",
  23. 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}"},
  24. 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}"},
  25. 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}",
  26. fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var e,b,c,d,f=2*Math.ceil(a*3)+1;f>25&&(f=25);d=(f-1)*0.5;b=Array(f);for(e=c=0;e<f;++e){b[e]=Math.exp(-((e-d)*(e-d))/(2*a*a));c+=b[e]}for(e=0;e<f;++e)b[e]/=c;return b}};
  27. THREE.QuakeCamera=function(a){function e(b,c){return function(){c.apply(b,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.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
  28. a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.activeLook!==undefined)this.activeLook=a.activeLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=
  29. 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(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=
  30. !1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.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(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
  31. !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);
  32. 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;b=this.target.position;var c=this.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.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()},
  33. !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;
  34. THREE.QuakeCamera.prototype.translate=function(a,e){this.matrix.rotateAxis(e);if(this.noFly)e.y=0;this.position.addSelf(e.multiplyScalar(a));this.target.position.addSelf(e.multiplyScalar(a))};
  35. THREE.PathCamera=function(a){function e(k,j,m,p){var w={name:m,fps:0.6,length:p,hierarchy:[]},t,z=j.getControlPointsArray(),y=j.getLength(),A=z.length,C=0;t=A-1;j={parent:-1,keys:[]};j.keys[0]={time:0,pos:z[0],rot:[0,0,0,1],scl:[1,1,1]};j.keys[t]={time:p,pos:z[t],rot:[0,0,0,1],scl:[1,1,1]};for(t=1;t<A-1;t++){C=p*y.chunks[t]/y.total;j.keys[t]={time:C,pos:z[t]}}w.hierarchy[0]=j;THREE.AnimationHandler.add(w);return new THREE.Animation(k,m,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(k,j){var m,
  36. p,w=new THREE.Geometry;for(m=0;m<k.points.length*j;m++){p=m/(k.points.length*j);p=k.getPoint(p);w.vertices[m]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return w}function c(k,j){var m=b(j,10),p=b(j,10),w=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(m,w);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);k.addChild(lineObj);particleObj.scale.set(1,1,1);k.addChild(particleObj);p=new Sphere(1,
  37. 16,8);w=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<j.points.length;i++){m=new THREE.Mesh(p,w);m.position.copy(j.points[i]);m.updateMatrix();k.addChild(m)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.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=
  38. !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(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
  39. if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
  40. this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var d=Math.PI*2,f=Math.PI/180;this.update=function(k,j,m){var p,w;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)*f;this.theta=this.lon*f;p=this.phi%d;this.phi=p>=0?p:p+d;p=this.verticalAngleMap.srcRange;w=this.verticalAngleMap.dstRange;
  41. this.phi=(this.phi-p[0])*(w[1]-w[0])/(p[1]-p[0])+w[0];p=this.horizontalAngleMap.srcRange;w=this.horizontalAngleMap.dstRange;this.theta=(this.theta-p[0])*(w[1]-w[0])/(p[1]-p[0])+w[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,k,j,m)};this.onMouseMove=function(k){this.mouseX=k.clientX-this.windowHalfX;this.mouseY=k.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
  42. 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 Cube(10,10,20),l=new Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(l,g);a.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(a)}else{this.animation=
  43. 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(k,j){return function(){j.apply(k,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;
  44. var Cube=function(a,e,b,c,d,f,g,h,l){function k(y,A,C,n,E,D,L,M){var K,J,G=c||1,N=d||1,U=E/2,R=D/2,P=j.vertices.length;if(y=="x"&&A=="y"||y=="y"&&A=="x")K="z";else if(y=="x"&&A=="z"||y=="z"&&A=="x"){K="y";N=f||1}else if(y=="z"&&A=="y"||y=="y"&&A=="z"){K="x";G=f||1}var Q=G+1,T=N+1;E/=G;var H=D/N;for(J=0;J<T;J++)for(D=0;D<Q;D++){var O=new THREE.Vector3;O[y]=(D*E-U)*C;O[A]=(J*H-R)*n;O[K]=L;j.vertices.push(new THREE.Vertex(O))}for(J=0;J<N;J++)for(D=0;D<G;D++){j.faces.push(new THREE.Face4(D+Q*J+P,D+Q*
  45. (J+1)+P,D+1+Q*(J+1)+P,D+1+Q*J+P,null,null,M));j.faceVertexUvs[0].push([new THREE.UV(D/G,J/N),new THREE.UV(D/G,(J+1)/N),new THREE.UV((D+1)/G,(J+1)/N),new THREE.UV((D+1)/G,J/N)])}}THREE.Geometry.call(this);var j=this,m=a/2,p=e/2,w=b/2;h=h?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var t=0;t<6;t++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(l!=undefined)for(var z in l)this.sides[z]!=undefined&&(this.sides[z]=
  46. l[z]);this.sides.px&&k("z","y",1*h,-1,b,e,-m,this.materials[0]);this.sides.nx&&k("z","y",-1*h,-1,b,e,m,this.materials[1]);this.sides.py&&k("x","z",1*h,1,a,b,p,this.materials[2]);this.sides.ny&&k("x","z",1*h,-1,a,b,-p,this.materials[3]);this.sides.pz&&k("x","y",1*h,-1,a,e,w,this.materials[4]);this.sides.nz&&k("x","y",-1*h,-1,a,e,-w,this.materials[5]);(function(){for(var y=[],A=[],C=0,n=j.vertices.length;C<n;C++){for(var E=j.vertices[C],D=!1,L=0,M=y.length;L<M;L++){var K=y[L];if(E.position.x==K.position.x&&
  47. E.position.y==K.position.y&&E.position.z==K.position.z){A[C]=L;D=!0;break}}if(!D){A[C]=y.length;y.push(new THREE.Vertex(E.position.clone()))}}C=0;for(n=j.faces.length;C<n;C++){E=j.faces[C];E.a=A[E.a];E.b=A[E.b];E.c=A[E.c];E.d=A[E.d]}j.vertices=y})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
  48. var Cylinder=function(a,e,b,c,d,f){function g(j,m,p){h.vertices.push(new THREE.Vertex(new THREE.Vector3(j,m,p)))}THREE.Geometry.call(this);var h=this,l=Math.PI,k=c/2;for(c=0;c<a;c++)g(Math.sin(2*l*c/a)*e,Math.cos(2*l*c/a)*e,-k);for(c=0;c<a;c++)g(Math.sin(2*l*c/a)*b,Math.cos(2*l*c/a)*b,k);for(c=0;c<a;c++)h.faces.push(new THREE.Face4(c,c+a,a+(c+1)%a,(c+1)%a));if(b>0){g(0,0,-k-(f||0));for(c=a;c<a+a/2;c++)h.faces.push(new THREE.Face4(2*a,(2*c-2*a)%a,(2*c-2*a+1)%a,(2*c-2*a+2)%a))}if(e>0){g(0,0,k+(d||0));
  49. for(c=a+a/2;c<2*a;c++)h.faces.push(new THREE.Face4(2*a+1,(2*c-2*a+2)%a+a,(2*c-2*a+1)%a+a,(2*c-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
  50. var Icosahedron=function(a){function e(m,p,w){var t=Math.sqrt(m*m+p*p+w*w);return d.vertices.push(new THREE.Vertex(new THREE.Vector3(m/t,p/t,w/t)))-1}function b(m,p,w,t){t.faces.push(new THREE.Face3(m,p,w))}function c(m,p){var w=d.vertices[m].position,t=d.vertices[p].position;return e((w.x+t.x)/2,(w.y+t.y)/2,(w.z+t.z)/2)}var d=this,f=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;e(-1,a,0);e(1,a,0);e(-1,-a,0);e(1,-a,0);e(0,-1,a);e(0,1,a);e(0,-1,-a);e(0,
  51. 1,-a);e(a,0,-1);e(a,0,1);e(-a,0,-1);e(-a,0,1);b(0,11,5,f);b(0,5,1,f);b(0,1,7,f);b(0,7,10,f);b(0,10,11,f);b(1,5,9,f);b(5,11,4,f);b(11,10,2,f);b(10,7,6,f);b(7,1,8,f);b(3,9,4,f);b(3,4,2,f);b(3,2,6,f);b(3,6,8,f);b(3,8,9,f);b(4,9,5,f);b(2,4,11,f);b(6,2,10,f);b(8,6,7,f);b(9,8,1,f);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var h in f.faces){var l=c(f.faces[h].a,f.faces[h].b),k=c(f.faces[h].b,f.faces[h].c),j=c(f.faces[h].c,f.faces[h].a);b(f.faces[h].a,l,j,g);b(f.faces[h].b,k,l,g);b(f.faces[h].c,
  52. j,k,g);b(l,k,j,g)}f.faces=g.faces}d.faces=f.faces;delete f;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
  53. function Lathe(a,e,b){THREE.Geometry.call(this);this.steps=e||12;this.angle=b||2*Math.PI;e=this.angle/this.steps;for(var c=[],d=[],f=[],g=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));c[h]=a[h].clone();d[h]=this.vertices.length-1}for(var l=(new THREE.Matrix4).setRotationZ(e),k=0;k<=this.angle+0.0010;k+=e){for(h=0;h<c.length;h++)if(k<this.angle){c[h]=l.multiplyVector3(c[h].clone());this.vertices.push(new THREE.Vertex(c[h]));f[h]=this.vertices.length-1}else f=g;k==0&&(g=d);for(h=
  54. 0;h<d.length-1;h++){this.faces.push(new THREE.Face4(f[h],f[h+1],d[h+1],d[h]));this.faceVertexUvs[0].push([new THREE.UV(k/b,h/a.length),new THREE.UV(k/b,(h+1)/a.length),new THREE.UV((k-e)/b,(h+1)/a.length),new THREE.UV((k-e)/b,h/a.length)])}d=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
  55. var Plane=function(a,e,b,c){THREE.Geometry.call(this);var d,f=a/2,g=e/2;b=b||1;c=c||1;var h=b+1,l=c+1;a/=b;var k=e/c;for(d=0;d<l;d++)for(e=0;e<h;e++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(e*a-f,-(d*k-g),0)));for(d=0;d<c;d++)for(e=0;e<b;e++){this.faces.push(new THREE.Face4(e+h*d,e+h*(d+1),e+1+h*(d+1),e+1+h*d));this.faceVertexUvs[0].push([new THREE.UV(e/b,d/c),new THREE.UV(e/b,(d+1)/c),new THREE.UV((e+1)/b,(d+1)/c),new THREE.UV((e+1)/b,d/c)])}this.computeCentroids();this.computeFaceNormals()};
  56. Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
  57. var Sphere=function(a,e,b){THREE.Geometry.call(this);var c,d=Math.PI,f=Math.max(3,e||8),g=Math.max(2,b||6);e=[];for(b=0;b<g+1;b++){c=b/g;var h=a*Math.cos(c*d),l=a*Math.sin(c*d),k=[],j=0;for(c=0;c<f;c++){var m=2*c/f,p=l*Math.sin(m*d);m=l*Math.cos(m*d);(b==0||b==g)&&c>0||(j=this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,h,p)))-1);k.push(j)}e.push(k)}var w,t,z;d=e.length;for(b=0;b<d;b++){f=e[b].length;if(b>0)for(c=0;c<f;c++){k=c==f-1;g=e[b][k?0:c+1];h=e[b][k?f-1:c];l=e[b-1][k?f-1:c];k=e[b-1][k?
  58. 0:c+1];p=b/(d-1);w=(b-1)/(d-1);t=(c+1)/f;m=c/f;j=new THREE.UV(1-t,p);p=new THREE.UV(1-m,p);m=new THREE.UV(1-m,w);var y=new THREE.UV(1-t,w);if(b<e.length-1){w=this.vertices[g].position.clone();t=this.vertices[h].position.clone();z=this.vertices[l].position.clone();w.normalize();t.normalize();z.normalize();this.faces.push(new THREE.Face3(g,h,l,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(z.x,z.y,z.z)]));this.faceVertexUvs[0].push([j,p,m])}if(b>1){w=this.vertices[g].position.clone();
  59. t=this.vertices[l].position.clone();z=this.vertices[k].position.clone();w.normalize();t.normalize();z.normalize();this.faces.push(new THREE.Face3(g,l,k,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(z.x,z.y,z.z)]));this.faceVertexUvs[0].push([j,m,y])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
  60. var Torus=function(a,e,b,c){this.radius=a||100;this.tube=e||40;this.segmentsR=b||8;this.segmentsT=c||6;a=[];THREE.Geometry.call(this);for(e=0;e<=this.segmentsR;++e)for(b=0;b<=this.segmentsT;++b){c=b/this.segmentsT*2*Math.PI;var d=e/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(d))*Math.cos(c),(this.radius+this.tube*Math.cos(d))*Math.sin(c),this.tube*Math.sin(d))));a.push([b/this.segmentsT,1-e/this.segmentsR])}for(e=1;e<=this.segmentsR;++e)for(b=
  61. 1;b<=this.segmentsT;++b){c=(this.segmentsT+1)*e+b;d=(this.segmentsT+1)*e+b-1;var f=(this.segmentsT+1)*(e-1)+b-1,g=(this.segmentsT+1)*(e-1)+b;this.faces.push(new THREE.Face4(c,d,f,g));this.faceVertexUvs[0].push([new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[d][0],a[d][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()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
  62. var TorusKnot=function(a,e,b,c,d,f,g){function h(m,p,w,t,z,y){p=w/t*m;w=Math.cos(p);return new THREE.Vector3(z*(2+w)*0.5*Math.cos(m),z*(2+w)*Math.sin(m)*0.5,y*z*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=e||40;this.segmentsR=b||64;this.segmentsT=c||8;this.p=d||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;c=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(e=0;e<this.segmentsT;++e){var l=
  63. a/this.segmentsR*2*this.p*Math.PI;g=e/this.segmentsT*2*Math.PI;d=h(l,g,this.q,this.p,this.radius,this.heightScale);l=h(l+0.01,g,this.q,this.p,this.radius,this.heightScale);b.x=l.x-d.x;b.y=l.y-d.y;b.z=l.z-d.z;c.x=l.x+d.x;c.y=l.y+d.y;c.z=l.z+d.z;f.cross(b,c);c.cross(f,b);f.normalize();c.normalize();l=this.tube*Math.cos(g);g=this.tube*Math.sin(g);d.x+=l*c.x+g*f.x;d.y+=l*c.y+g*f.y;d.z+=l*c.z+g*f.z;this.grid[a][e]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z)))-1}}for(a=0;a<this.segmentsR;++a)for(e=
  64. 0;e<this.segmentsT;++e){f=(a+1)%this.segmentsR;g=(e+1)%this.segmentsT;d=this.grid[a][e];b=this.grid[f][e];c=this.grid[a][g];f=this.grid[f][g];g=new THREE.UV(a/this.segmentsR,e/this.segmentsT);l=new THREE.UV((a+1)/this.segmentsR,e/this.segmentsT);var k=new THREE.UV(a/this.segmentsR,(e+1)/this.segmentsT),j=new THREE.UV((a+1)/this.segmentsR,(e+1)/this.segmentsT);this.faces.push(new THREE.Face3(d,b,c));this.faceVertexUvs[0].push([g,l,k]);this.faces.push(new THREE.Face3(f,c,b));this.faceVertexUvs[0].push([j,
  65. k,l])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
  66. THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var e="Loaded ";e+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";
  67. this.statusDomElement.innerHTML=e},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,e,b){a.materials=[];for(var c=0;c<e.length;++c)a.materials[c]=[THREE.Loader.prototype.createMaterial(e[c],b)]},createMaterial:function(a,e){function b(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}function c(h,l){var k=new Image;k.onload=function(){if(!b(this.width)||!b(this.height)){var j=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),m=Math.pow(2,Math.round(Math.log(this.height)/
  68. Math.LN2));h.image.width=j;h.image.height=m;h.image.getContext("2d").drawImage(this,0,0,j,m)}else h.image=this;h.needsUpdate=!0};k.src=l}var d,f,g;d="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors?THREE.VertexColors:!1,wireframe:a.wireframe};if(a.shading)if(a.shading=="Phong")d="MeshPhongMaterial";else a.shading=="Basic"&&(d="MeshBasicMaterial");if(a.mapDiffuse&&e){g=document.createElement("canvas");f.map=new THREE.Texture(g);f.map.sourceFile=a.mapDiffuse;
  69. c(f.map,e+"/"+a.mapDiffuse)}else if(a.colorDiffuse){g=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;f.color=g;f.opacity=a.transparency}else if(a.DbgColor)f.color=a.DbgColor;if(a.mapLightmap&&e){g=document.createElement("canvas");f.lightMap=new THREE.Texture(g);f.lightMap.sourceFile=a.mapLightmap;c(f.lightMap,e+"/"+a.mapLightmap)}return new THREE[d](f)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;
  70. THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;THREE.JSONLoader.prototype.load=function(a){var e=this,b=a.model,c=a.callback,d=a.texture_path?a.texture_path:this.extractUrlbase(b);a=new Worker(b);a.onmessage=function(f){e.createModel(f.data,c,d);e.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
  71. THREE.JSONLoader.prototype.createModel=function(a,e,b){var c=new THREE.Geometry;this.init_materials(c,a.materials,b);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var d,f,g,h,l,k,j,m,p,w,t=a.faces;m=a.vertices;var z=a.normals,y=a.colors,A=0;for(d=0;d<a.uvs.length;d++)a.uvs[d].length&&A++;for(d=0;d<A;d++){c.faceUvs[d]=[];c.faceVertexUvs[d]=[]}h=0;for(l=m.length;h<l;){p=new THREE.Vertex;p.position.x=m[h++];p.position.y=m[h++];p.position.z=m[h++];c.vertices.push(p)}h=
  72. 0;for(l=t.length;h<l;){k=t[h++];j=k&1;g=k&2;d=k&4;f=k&8;m=k&16;p=k&32;w=k&64;k&=128;if(j){j=new THREE.Face4;j.a=t[h++];j.b=t[h++];j.c=t[h++];j.d=t[h++];nVertices=4}else{j=new THREE.Face3;j.a=t[h++];j.b=t[h++];j.c=t[h++];nVertices=3}if(g){materialIndex=t[h++];j.materials=c.materials[materialIndex]}g=c.faces.length;if(d)for(d=0;d<A;d++){uvLayer=a.uvs[d];uvIndex=t[h++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];c.faceUvs[d][g]=new THREE.UV(u,v)}if(f)for(d=0;d<A;d++){uvLayer=a.uvs[d];uvs=[];for(f=0;f<
  73. nVertices;f++){uvIndex=t[h++];u=uvLayer[uvIndex*2];v=uvLayer[uvIndex*2+1];uvs[f]=new THREE.UV(u,v)}c.faceVertexUvs[d][g]=uvs}if(m){normalIndex=t[h++]*3;normal=new THREE.Vector3;normal.x=z[normalIndex++];normal.y=z[normalIndex++];normal.z=z[normalIndex];j.normal=normal}if(p)for(d=0;d<nVertices;d++){normalIndex=t[h++]*3;normal=new THREE.Vector3;normal.x=z[normalIndex++];normal.y=z[normalIndex++];normal.z=z[normalIndex];j.vertexNormals.push(normal)}if(w){color=new THREE.Color(t[h++]);j.color=color}if(k)for(d=
  74. 0;d<nVertices;d++){colorIndex=t[h++];color=new THREE.Color(y[colorIndex]);j.vertexColors.push(color)}c.faces.push(j)}}})();(function(){var d,f,g,h;if(a.skinWeights){d=0;for(f=a.skinWeights.length;d<f;d+=2){g=a.skinWeights[d];h=a.skinWeights[d+1];c.skinWeights.push(new THREE.Vector4(g,h,0,0))}}if(a.skinIndices){d=0;for(f=a.skinIndices.length;d<f;d+=2){g=a.skinIndices[d];h=a.skinIndices[d+1];c.skinIndices.push(new THREE.Vector4(g,h,0,0))}}c.bones=a.bones;c.animation=a.animation})();(function(){if(a.morphTargets!==
  75. undefined){var d,f,g,h;d=0;for(f=a.morphTargets.length;d<f;d++){c.morphTargets[d]={};c.morphTargets[d].name=a.morphTargets[d].name;c.morphTargets[d].vertices=[];dstVertices=c.morphTargets[d].vertices;srcVertices=a.morphTargets[d].vertices;g=0;for(h=srcVertices.length;g<h;g+=3)dstVertices.push(new THREE.Vertex(new THREE.Vector3(srcVertices[g],srcVertices[g+1],srcVertices[g+2])))}}})();c.computeCentroids();c.computeFaceNormals();e(c)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};
  76. THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
  77. THREE.BinaryLoader.prototype={load:function(a){var e=a.model,b=a.callback,c=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(e),d=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(e);a=(new Date).getTime();e=new Worker(e);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;e.onmessage=function(g){THREE.BinaryLoader.prototype.loadAjaxBuffers(g.data.buffers,g.data.materials,b,d,c,f)};e.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};
  78. e.postMessage(a)},loadAjaxBuffers:function(a,e,b,c,d,f){var g=new XMLHttpRequest,h=c+"/"+a,l=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,b,d,e):alert("Couldn't load ["+h+"] ["+g.status+"]");else if(g.readyState==3){if(f){l==0&&(l=g.getResponseHeader("Content-Length"));f({total:l,loaded:g.responseText.length})}}else g.readyState==2&&(l=g.getResponseHeader("Content-Length"))};g.open("GET",h,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
  79. g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,e,b,c){var d=function(f){function g(o,x){var B=j(o,x),F=j(o,x+1),I=j(o,x+2),S=j(o,x+3),V=(S<<1&255|I>>7)-127;B|=(I&127)<<16|F<<8;if(B==0&&V==-127)return 0;return(1-2*(S>>7))*(1+B*Math.pow(2,-23))*Math.pow(2,V)}function h(o,x){var B=j(o,x),F=j(o,x+1),I=j(o,x+2);return(j(o,x+3)<<24)+(I<<16)+(F<<8)+B}function l(o,x){var B=j(o,x);return(j(o,x+1)<<8)+B}function k(o,x){var B=j(o,x);return B>127?B-256:B}function j(o,
  80. x){return o.charCodeAt(x)&255}function m(o){var x,B,F;x=h(a,o);B=h(a,o+L);F=h(a,o+M);o=l(a,o+K);THREE.BinaryLoader.prototype.f3(A,x,B,F,o)}function p(o){var x,B,F,I,S,V;x=h(a,o);B=h(a,o+L);F=h(a,o+M);I=l(a,o+K);S=h(a,o+J);V=h(a,o+G);o=h(a,o+N);THREE.BinaryLoader.prototype.f3n(A,E,x,B,F,I,S,V,o)}function w(o){var x,B,F,I;x=h(a,o);B=h(a,o+U);F=h(a,o+R);I=h(a,o+P);o=l(a,o+Q);THREE.BinaryLoader.prototype.f4(A,x,B,F,I,o)}function t(o){var x,B,F,I,S,V,da,ea;x=h(a,o);B=h(a,o+U);F=h(a,o+R);I=h(a,o+P);S=l(a,
  81. o+Q);V=h(a,o+T);da=h(a,o+H);ea=h(a,o+O);o=h(a,o+X);THREE.BinaryLoader.prototype.f4n(A,E,x,B,F,I,S,V,da,ea,o)}function z(o){var x,B;x=h(a,o);B=h(a,o+Y);o=h(a,o+fa);THREE.BinaryLoader.prototype.uv3(A.faceVertexUvs[0],D[x*2],D[x*2+1],D[B*2],D[B*2+1],D[o*2],D[o*2+1])}function y(o){var x,B,F;x=h(a,o);B=h(a,o+ga);F=h(a,o+ha);o=h(a,o+ia);THREE.BinaryLoader.prototype.uv4(A.faceVertexUvs[0],D[x*2],D[x*2+1],D[B*2],D[B*2+1],D[F*2],D[F*2+1],D[o*2],D[o*2+1])}var A=this,C=0,n,E=[],D=[],L,M,K,J,G,N,U,R,P,Q,T,H,
  82. O,X,Y,fa,ga,ha,ia,Z,$,aa,ba,ca,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(A,c,f);n={signature:a.substr(C,8),header_bytes:j(a,C+8),vertex_coordinate_bytes:j(a,C+9),normal_coordinate_bytes:j(a,C+10),uv_coordinate_bytes:j(a,C+11),vertex_index_bytes:j(a,C+12),normal_index_bytes:j(a,C+13),uv_index_bytes:j(a,C+14),material_index_bytes:j(a,C+15),nvertices:h(a,C+16),nnormals:h(a,C+16+4),nuvs:h(a,C+16+8),ntri_flat:h(a,C+16+12),ntri_smooth:h(a,C+16+16),ntri_flat_uv:h(a,C+16+20),ntri_smooth_uv:h(a,
  83. C+16+24),nquad_flat:h(a,C+16+28),nquad_smooth:h(a,C+16+32),nquad_flat_uv:h(a,C+16+36),nquad_smooth_uv:h(a,C+16+40)};C+=n.header_bytes;L=n.vertex_index_bytes;M=n.vertex_index_bytes*2;K=n.vertex_index_bytes*3;J=n.vertex_index_bytes*3+n.material_index_bytes;G=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;N=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;U=n.vertex_index_bytes;R=n.vertex_index_bytes*2;P=n.vertex_index_bytes*3;Q=n.vertex_index_bytes*4;T=n.vertex_index_bytes*
  84. 4+n.material_index_bytes;H=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;X=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;Y=n.uv_index_bytes;fa=n.uv_index_bytes*2;ga=n.uv_index_bytes;ha=n.uv_index_bytes*2;ia=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;Z=n.ntri_flat*f;$=n.ntri_smooth*(f+n.normal_index_bytes*3);aa=n.ntri_flat_uv*
  85. (f+n.uv_index_bytes*3);ba=n.ntri_smooth_uv*(f+n.normal_index_bytes*3+n.uv_index_bytes*3);ca=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);C+=function(o){for(var x,B,F,I=n.vertex_coordinate_bytes*3,S=o+n.nvertices*I;o<S;o+=I){x=g(a,o);B=g(a,o+n.vertex_coordinate_bytes);F=g(a,o+n.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(A,x,B,F)}return n.nvertices*I}(C);C+=function(o){for(var x,B,F,I=n.normal_coordinate_bytes*3,S=o+n.nnormals*I;o<
  86. S;o+=I){x=k(a,o);B=k(a,o+n.normal_coordinate_bytes);F=k(a,o+n.normal_coordinate_bytes*2);E.push(x/127,B/127,F/127)}return n.nnormals*I}(C);C+=function(o){for(var x,B,F=n.uv_coordinate_bytes*2,I=o+n.nuvs*F;o<I;o+=F){x=g(a,o);B=g(a,o+n.uv_coordinate_bytes);D.push(x,B)}return n.nuvs*F}(C);Z=C+Z;$=Z+$;aa=$+aa;ba=aa+ba;ca=ba+ca;f=ca+f;W=f+W;(function(o){var x,B=n.vertex_index_bytes*3+n.material_index_bytes,F=B+n.uv_index_bytes*3,I=o+n.ntri_flat_uv*F;for(x=o;x<I;x+=F){m(x);z(x+B)}return I-o})($);(function(o){var x,
  87. B=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,F=B+n.uv_index_bytes*3,I=o+n.ntri_smooth_uv*F;for(x=o;x<I;x+=F){p(x);z(x+B)}return I-o})(aa);(function(o){var x,B=n.vertex_index_bytes*4+n.material_index_bytes,F=B+n.uv_index_bytes*4,I=o+n.nquad_flat_uv*F;for(x=o;x<I;x+=F){w(x);y(x+B)}return I-o})(f);(function(o){var x,B=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,F=B+n.uv_index_bytes*4,I=o+n.nquad_smooth_uv*F;for(x=o;x<I;x+=F){t(x);y(x+B)}return I-o})(W);
  88. (function(o){var x,B=n.vertex_index_bytes*3+n.material_index_bytes,F=o+n.ntri_flat*B;for(x=o;x<F;x+=B)m(x);return F-o})(C);(function(o){var x,B=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*3,F=o+n.ntri_smooth*B;for(x=o;x<F;x+=B)p(x);return F-o})(Z);(function(o){var x,B=n.vertex_index_bytes*4+n.material_index_bytes,F=o+n.nquad_flat*B;for(x=o;x<F;x+=B)w(x);return F-o})(ba);(function(o){var x,B=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*4,F=o+n.nquad_smooth*
  89. B;for(x=o;x<F;x+=B)t(x);return F-o})(ca);this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;e(new d(b))},v:function(a,e,b,c){a.vertices.push(new THREE.Vertex(new THREE.Vector3(e,b,c)))},f3:function(a,e,b,c,d){a.faces.push(new THREE.Face3(e,b,c,null,null,a.materials[d]))},f4:function(a,e,b,c,d,f){a.faces.push(new THREE.Face4(e,b,c,d,null,null,a.materials[f]))},f3n:function(a,e,b,c,d,f,g,h,l){f=a.materials[f];var k=e[h*3],j=e[h*3+1];h=e[h*3+2];
  90. var m=e[l*3],p=e[l*3+1];l=e[l*3+2];a.faces.push(new THREE.Face3(b,c,d,[new THREE.Vector3(e[g*3],e[g*3+1],e[g*3+2]),new THREE.Vector3(k,j,h),new THREE.Vector3(m,p,l)],null,f))},f4n:function(a,e,b,c,d,f,g,h,l,k,j){g=a.materials[g];var m=e[l*3],p=e[l*3+1];l=e[l*3+2];var w=e[k*3],t=e[k*3+1];k=e[k*3+2];var z=e[j*3],y=e[j*3+1];j=e[j*3+2];a.faces.push(new THREE.Face4(b,c,d,f,[new THREE.Vector3(e[h*3],e[h*3+1],e[h*3+2]),new THREE.Vector3(m,p,l),new THREE.Vector3(w,t,k),new THREE.Vector3(z,y,j)],null,g))},
  91. uv3:function(a,e,b,c,d,f,g){var h=[];h.push(new THREE.UV(e,b));h.push(new THREE.UV(c,d));h.push(new THREE.UV(f,g));a.push(h)},uv4:function(a,e,b,c,d,f,g,h,l){var k=[];k.push(new THREE.UV(e,b));k.push(new THREE.UV(c,d));k.push(new THREE.UV(f,g));k.push(new THREE.UV(h,l));a.push(k)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
  92. THREE.MarchingCubes=function(a,e){THREE.Object3D.call(this);this.materials=e instanceof Array?e:[e];this.init=function(b){this.isolation=80;this.size=b;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=
  93. 0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,d){return b+(c-b)*d};this.VIntX=function(b,c,d,f,g,h,l,k,j,m){g=(g-j)/(m-j);j=this.normal_cache;c[f]=h+g*this.delta;c[f+1]=l;c[f+2]=k;d[f]=this.lerp(j[b],j[b+3],g);d[f+1]=this.lerp(j[b+1],j[b+4],g);d[f+2]=this.lerp(j[b+2],j[b+5],g)};this.VIntY=function(b,c,d,f,g,h,l,k,j,m){g=(g-j)/(m-j);j=this.normal_cache;c[f]=h;c[f+1]=l+g*this.delta;c[f+
  94. 2]=k;c=b+this.yd*3;d[f]=this.lerp(j[b],j[c],g);d[f+1]=this.lerp(j[b+1],j[c+1],g);d[f+2]=this.lerp(j[b+2],j[c+2],g)};this.VIntZ=function(b,c,d,f,g,h,l,k,j,m){g=(g-j)/(m-j);j=this.normal_cache;c[f]=h;c[f+1]=l;c[f+2]=k+g*this.delta;c=b+this.zd*3;d[f]=this.lerp(j[b],j[c],g);d[f+1]=this.lerp(j[b+1],j[c+1],g);d[f+2]=this.lerp(j[b+2],j[c+2],g)};this.compNorm=function(b){var c=b*3;if(this.normal_cache[c]==0){this.normal_cache[c]=this.field[b-1]-this.field[b+1];this.normal_cache[c+1]=this.field[b-this.yd]-
  95. this.field[b+this.yd];this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,c,d,f,g,h){var l=f+1,k=f+this.yd,j=f+this.zd,m=l+this.yd,p=l+this.zd,w=f+this.yd+this.zd,t=l+this.yd+this.zd,z=0,y=this.field[f],A=this.field[l],C=this.field[k],n=this.field[m],E=this.field[j],D=this.field[p],L=this.field[w],M=this.field[t];y<g&&(z|=1);A<g&&(z|=2);C<g&&(z|=8);n<g&&(z|=4);E<g&&(z|=16);D<g&&(z|=32);L<g&&(z|=128);M<g&&(z|=64);var K=THREE.edgeTable[z];if(K==0)return 0;
  96. var J=this.delta,G=b+J,N=c+J;J=d+J;if(K&1){this.compNorm(f);this.compNorm(l);this.VIntX(f*3,this.vlist,this.nlist,0,g,b,c,d,y,A)}if(K&2){this.compNorm(l);this.compNorm(m);this.VIntY(l*3,this.vlist,this.nlist,3,g,G,c,d,A,n)}if(K&4){this.compNorm(k);this.compNorm(m);this.VIntX(k*3,this.vlist,this.nlist,6,g,b,N,d,C,n)}if(K&8){this.compNorm(f);this.compNorm(k);this.VIntY(f*3,this.vlist,this.nlist,9,g,b,c,d,y,C)}if(K&16){this.compNorm(j);this.compNorm(p);this.VIntX(j*3,this.vlist,this.nlist,12,g,b,c,J,
  97. E,D)}if(K&32){this.compNorm(p);this.compNorm(t);this.VIntY(p*3,this.vlist,this.nlist,15,g,G,c,J,D,M)}if(K&64){this.compNorm(w);this.compNorm(t);this.VIntX(w*3,this.vlist,this.nlist,18,g,b,N,J,L,M)}if(K&128){this.compNorm(j);this.compNorm(w);this.VIntY(j*3,this.vlist,this.nlist,21,g,b,c,J,E,L)}if(K&256){this.compNorm(f);this.compNorm(j);this.VIntZ(f*3,this.vlist,this.nlist,24,g,b,c,d,y,E)}if(K&512){this.compNorm(l);this.compNorm(p);this.VIntZ(l*3,this.vlist,this.nlist,27,g,G,c,d,A,D)}if(K&1024){this.compNorm(m);
  98. this.compNorm(t);this.VIntZ(m*3,this.vlist,this.nlist,30,g,G,N,d,n,M)}if(K&2048){this.compNorm(k);this.compNorm(w);this.VIntZ(k*3,this.vlist,this.nlist,33,g,b,N,d,C,L)}z<<=4;for(g=f=0;THREE.triTable[z+g]!=-1;){b=z+g;c=b+1;d=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[d],h);g+=3;f++}return f};this.posnormtriv=function(b,c,d,f,g,h){var l=this.count*3;this.positionArray[l]=b[d];this.positionArray[l+1]=b[d+1];this.positionArray[l+2]=b[d+2];this.positionArray[l+
  99. 3]=b[f];this.positionArray[l+4]=b[f+1];this.positionArray[l+5]=b[f+2];this.positionArray[l+6]=b[g];this.positionArray[l+7]=b[g+1];this.positionArray[l+8]=b[g+2];this.normalArray[l]=c[d];this.normalArray[l+1]=c[d+1];this.normalArray[l+2]=c[d+2];this.normalArray[l+3]=c[f];this.normalArray[l+4]=c[f+1];this.normalArray[l+5]=c[f+2];this.normalArray[l+6]=c[g];this.normalArray[l+7]=c[g+1];this.normalArray[l+8]=c[g+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=
  100. function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;b(this)}};this.addBall=function(b,c,d,f,g){var h=this.size*Math.sqrt(f/g),l=d*this.size,k=c*this.size,j=b*this.size,m=Math.floor(l-h);m<1&&(m=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var p=Math.floor(k-h);p<1&&(p=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var w=Math.floor(j-h);w<1&&(w=1);h=Math.floor(j+h);
  101. h>this.size-1&&(h=this.size-1);for(var t,z,y,A,C,n;m<l;m++){j=this.size2*m;z=m/this.size-d;C=z*z;for(z=p;z<k;z++){y=j+this.size*z;t=z/this.size-c;n=t*t;for(t=w;t<h;t++){A=t/this.size-b;A=f/(1.0E-6+A*A+n+C)-g;A>0&&(this.field[y+t]+=A)}}}};this.addPlaneX=function(b,c){var d,f,g,h,l,k=this.size,j=this.yd,m=this.zd,p=this.field,w=k*Math.sqrt(b/c);w>k&&(w=k);for(d=0;d<w;d++){f=d/k;f*=f;h=b/(1.0E-4+f)-c;if(h>0)for(f=0;f<k;f++){l=d+f*j;for(g=0;g<k;g++)p[m*g+l]+=h}}};this.addPlaneY=function(b,c){var d,f,
  102. g,h,l,k,j=this.size,m=this.yd,p=this.zd,w=this.field,t=j*Math.sqrt(b/c);t>j&&(t=j);for(f=0;f<t;f++){d=f/j;d*=d;h=b/(1.0E-4+d)-c;if(h>0){l=f*m;for(d=0;d<j;d++){k=l+d;for(g=0;g<j;g++)w[p*g+k]+=h}}}};this.addPlaneZ=function(b,c){var d,f,g,h,l,k;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(g=0;g<dist;g++){d=g/size;d*=d;h=b/(1.0E-4+d)-c;if(h>0){l=zd*g;for(f=0;f<size;f++){k=l+f*yd;for(d=0;d<size;d++)field[k+d]+=h}}}};this.reset=function(){var b;
  103. for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var c,d,f,g,h,l,k,j,m,p=this.size-2;for(g=1;g<p;g++){m=this.size2*g;k=(g-this.halfsize)/this.halfsize;for(f=1;f<p;f++){j=m+this.size*f;l=(f-this.halfsize)/this.halfsize;for(d=1;d<p;d++){h=(d-this.halfsize)/this.halfsize;c=j+d;this.polygonize(h,l,k,c,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry;this.render(function(d){var f,g,h,l,k,j,m,p;for(f=
  104. 0;f<d.count;f++){k=f*3;m=k+1;p=k+2;g=d.positionArray[k];h=d.positionArray[m];l=d.positionArray[p];j=new THREE.Vector3(g,h,l);g=d.normalArray[k];h=d.normalArray[m];l=d.normalArray[p];k=new THREE.Vector3(g,h,l);k.normalize();k=new THREE.Vertex(j,k);c.vertices.push(k)}nfaces=d.count/3;for(f=0;f<nfaces;f++){k=(b+f)*3;m=k+1;p=k+2;j=c.vertices[k].normal;g=c.vertices[m].normal;h=c.vertices[p].normal;k=new THREE.Face3(k,m,p,[j,g,h]);c.faces.push(k)}b+=nfaces;d.count=0});return c};this.init(a)};
  105. THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
  106. 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,
  107. 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,
  108. 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]);
  109. THREE.triTable=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