提交 e604036b 编写于 作者: A alteredq

Changed normal map examples to use new normal map shader with standard lights.

Removed old normal map shader with custom lights.
上级 457b7a60
因为 它太大了无法显示 source diff 。你可以改为 查看blob
// ThreeExtras.js r41/ROME - http://github.com/mrdoob/three.js
THREE.ColorUtils={adjustHSV:function(a,b,c,e){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.ColorUtils.clamp(f.h+b,0,1);f.s=THREE.ColorUtils.clamp(f.s+c,0,1);f.v=THREE.ColorUtils.clamp(f.v+e,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,b){var c=a.r,e=a.g,f=a.b,g=Math.max(Math.max(c,e),f),h=Math.min(Math.min(c,e),f);if(h==g)h=c=0;else{var k=g-h,h=k/g,c=c==g?(e-f)/k:e==g?2+(f-c)/k:4+(c-e)/k;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=h;b.v=g;return b},
clamp:function(a,b,c){return a<b?b:a>c?c:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,m=a.faceVertexUvs[0],f=f.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var l=0,n=h.length;l<n;l++){var t=new THREE.Vertex(h[l].position.clone());c&&b.matrix.multiplyVector3(t.position);g.push(t)}l=0;for(n=j.length;l<n;l++){var h=j[l],o,w,v=h.vertexNormals,t=h.vertexColors;h instanceof THREE.Face3?o=new THREE.Face3(h.a+e,h.b+e,h.c+e):
h instanceof THREE.Face4&&(o=new THREE.Face4(h.a+e,h.b+e,h.c+e,h.d+e));o.normal.copy(h.normal);c=0;for(g=v.length;c<g;c++)w=v[c],o.vertexNormals.push(w.clone());o.color.copy(h.color);c=0;for(g=t.length;c<g;c++)w=t[c],o.vertexColors.push(w.clone());o.materials=h.materials.slice();o.centroid.copy(h.centroid);k.push(o)}l=0;for(n=f.length;l<n;l++){e=f[l];k=[];c=0;for(g=e.length;c<g;c++)k.push(new THREE.UV(e[c].u,e[c].v));m.push(k)}}};
var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,m=a.faceVertexUvs[0],f=f.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var l=0,n=h.length;l<n;l++){var p=new THREE.Vertex(h[l].position.clone());c&&b.matrix.multiplyVector3(p.position);g.push(p)}l=0;for(n=j.length;l<n;l++){var h=j[l],o,v,u=h.vertexNormals,p=h.vertexColors;h instanceof THREE.Face3?o=new THREE.Face3(h.a+e,h.b+e,h.c+e):
h instanceof THREE.Face4&&(o=new THREE.Face4(h.a+e,h.b+e,h.c+e,h.d+e));o.normal.copy(h.normal);c=0;for(g=u.length;c<g;c++)v=u[c],o.vertexNormals.push(v.clone());o.color.copy(h.color);c=0;for(g=p.length;c<g;c++)v=p[c],o.vertexColors.push(v.clone());o.materials=h.materials.slice();o.centroid.copy(h.centroid);k.push(o)}l=0;for(n=f.length;l<n;l++){e=f[l];k=[];c=0;for(g=e.length;c<g;c++)k.push(new THREE.UV(e[c].u,e[c].v));m.push(k)}}};
THREE.ImageUtils={loadTexture:function(a,b,c){var e=new Image,f=new THREE.Texture(e,b);e.onload=function(){f.needsUpdate=!0;c&&c(this)};e.src=a;return f},loadTextureCube:function(a,b,c){var e,f=[],g=new THREE.Texture(f,b),b=f.loadCount=0;for(e=a.length;b<e;++b)f[b]=new Image,f[b].onload=function(){f.loadCount+=1;if(f.loadCount==6)g.needsUpdate=!0;c&&c(this)},f[b].src=a[b];return g}};
THREE.SceneUtils={addMesh:function(a,b,c,e,f,g,h,k,j,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=e;b.position.y=f;b.position.z=g;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var e=THREE.ShaderUtils.lib.cube;e.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:e.uniforms});b=new THREE.Mesh(new THREE.CubeGeometry(b,b,b,1,1,1,null,!0),c);a.addObject(b);
return b},addPanoramaCube:function(a,b,c){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new THREE.Cube(b,b,b,1,1,e,!0),
......@@ -10,9 +10,9 @@ new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:funct
new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));THREE.SceneUtils.addMesh(a,b,1,0,-e,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}))},showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,e,f=a.children.length;for(e=0;e<f;e++)c=a.children[e],b(c),THREE.SceneUtils.traverseHierarchy(c,b)}};
THREE.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",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}",
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}"},
normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:5,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},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 enableSpecular;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\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 specularTex = 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;\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\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 = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight * pointDiffuseWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight * dirDiffuseWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}",
vertexShader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.lights,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:5,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},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},uOpacity:{type:"f",value:1}}]),fragmentShader:"uniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform float uOpacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\ngl_FragColor = vec4( 1.0 );\nvec4 mColor = vec4( uDiffuseColor, uOpacity );\nvec4 mSpecular = vec4( uSpecularColor, uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor = gl_FragColor * texture2D( tAO, vUv );\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointTotal = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ 0 ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ 0 ].xyz + vViewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointTotal += pointDistance * vec4( pointLightColor[ 0 ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ 0 ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirTotal += vec4( directionalLightColor[ 0 ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );\n}\n#endif\nvec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirTotal;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointTotal;\n#endif\ngl_FragColor = gl_FragColor * totalLight;\n}",
vertexShader:"attribute vec4 tangent;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"},
cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"},convolution:{uniforms:{tDiffuse:{type:"t",
value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
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}"},
......@@ -27,8 +27,8 @@ THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=
THREE.Bone?f.skinMatrix:f.matrix;var g=f.animationCache.prevKey;f=f.animationCache.nextKey;g.pos=this.data.hierarchy[c].keys[0];g.rot=this.data.hierarchy[c].keys[0];g.scl=this.data.hierarchy[c].keys[0];f.pos=this.getNextKeyWith("pos",c,1);f.rot=this.getNextKeyWith("rot",c,1);f.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==void 0)this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix:this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix,delete this.hierarchy[a].animationCache};
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,f,g,h,k,j,m,l=this.data.JIT.hierarchy,n,t;this.currentTime+=a*this.timeScale;t=this.currentTime;n=this.currentTime%=this.data.length;m=parseInt(Math.min(n*this.data.fps,this.data.length*this.data.fps),10);for(var o=0,w=this.hierarchy.length;o<w;o++)if(a=this.hierarchy[o],j=a.animationCache,this.JITCompile&&l[o][m]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=l[o][m],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
!1):(a.matrix=l[o][m],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var v=0;v<3;v++){c=b[v];h=j.prevKey[c];k=j.nextKey[c];if(k.time<=t){if(n<t)if(this.loop){h=this.data.hierarchy[o].keys[0];for(k=this.getNextKeyWith(c,o,1);k.time<n;)h=k,k=this.getNextKeyWith(c,o,k.index+1)}else{this.stop();return}else{do h=k,k=this.getNextKeyWith(c,o,k.index+1);while(k.time<
THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,f,g,h,k,j,m,l=this.data.JIT.hierarchy,n,p;this.currentTime+=a*this.timeScale;p=this.currentTime;n=this.currentTime%=this.data.length;m=parseInt(Math.min(n*this.data.fps,this.data.length*this.data.fps),10);for(var o=0,v=this.hierarchy.length;o<v;o++)if(a=this.hierarchy[o],j=a.animationCache,this.JITCompile&&l[o][m]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=l[o][m],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
!1):(a.matrix=l[o][m],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var u=0;u<3;u++){c=b[u];h=j.prevKey[c];k=j.nextKey[c];if(k.time<=p){if(n<p)if(this.loop){h=this.data.hierarchy[o].keys[0];for(k=this.getNextKeyWith(c,o,1);k.time<n;)h=k,k=this.getNextKeyWith(c,o,k.index+1)}else{this.stop();return}else{do h=k,k=this.getNextKeyWith(c,o,k.index+1);while(k.time<
n)}j.prevKey[c]=h;j.nextKey[c]=k}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(n-h.time)/(k.time-h.time);f=h[c];g=k[c];if(e<0||e>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o),e=e<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=f[0]+(g[0]-f[0])*e,c.y=f[1]+(g[1]-f[1])*e,c.z=f[2]+(g[2]-f[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
this.getPrevKeyWith("pos",o,h.index-1).pos,this.points[1]=f,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",o,k.index+1).pos,e=e*0.33+0.33,f=this.interpolateCatmullRom(this.points,e),c.x=f[0],c.y=f[1],c.z=f[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(c===
"rot")THREE.Quaternion.slerp(f,g,a.quaternion,e);else if(c==="scl")c=a.scale,c.x=f[0]+(g[0]-f[0])*e,c.y=f[1]+(g[1]-f[1])*e,c.z=f[2]+(g[2]-f[2])*e}}if(this.JITCompile&&l[0][m]===void 0){this.hierarchy[0].update(void 0,!0);for(o=0;o<this.hierarchy.length;o++)l[o][m]=this.hierarchy[o]instanceof THREE.Bone?this.hierarchy[o].skinMatrix.clone():this.hierarchy[o].matrix.clone()}}};
......@@ -45,7 +45,7 @@ this.heightSpeed?this.tdiff*((this.position.y<this.heightMin?this.heightMin:this
(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;a=this.target.position;f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),
!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
THREE.QuakeCamera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);if(this.noFly)b.y=0;this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};
THREE.PathCamera=function(a){function b(a,c,b,e){var g={name:b,fps:0.6,length:e,hierarchy:[]},f,h=c.getControlPointsArray(),k=c.getLength(),j=h.length,p=0;f=j-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:h[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[f]={time:e,pos:h[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f<j-1;f++)p=e*k.chunks[f]/k.total,c.keys[f]={time:p,pos:h[f]};g.hierarchy[0]=c;THREE.AnimationHandler.add(g);return new THREE.Animation(a,b,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(a,c){var b,
THREE.PathCamera=function(a){function b(a,c,b,e){var g={name:b,fps:0.6,length:e,hierarchy:[]},f,h=c.getControlPointsArray(),k=c.getLength(),j=h.length,y=0;f=j-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:h[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[f]={time:e,pos:h[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f<j-1;f++)y=e*k.chunks[f]/k.total,c.keys[f]={time:y,pos:h[f]};g.hierarchy[0]=c;THREE.AnimationHandler.add(g);return new THREE.Animation(a,b,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(a,c){var b,
e,g=new THREE.Geometry;for(b=0;b<a.points.length*c;b++)e=b/(a.points.length*c),e=a.getPoint(e),g.vertices[b]=new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z));return g}function e(a,b){var e=c(b,10),g=c(b,10),f=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(e,f);particleObj=new THREE.ParticleSystem(g,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.addChild(lineObj);particleObj.scale.set(1,1,1);a.addChild(particleObj);g=new THREE.SphereGeometry(1,
16,8);f=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<b.points.length;i++)e=new THREE.Mesh(g,f),e.position.copy(b.points[i]),e.updateMatrix(),a.addChild(e)}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.lookHorizontal=
this.lookVertical=!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!==void 0)this.duration=a.duration*1E3;if(a.waypoints!==void 0)this.waypoints=a.waypoints;if(a.useConstantSpeed!==void 0)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==void 0)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==void 0)this.createDebugPath=a.createDebugPath;if(a.createDebugDummy!==
......@@ -65,13 +65,13 @@ this.rollSpeed;this.translateX(this.moveVector.x*a);this.translateY(this.moveVec
this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=
document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this,this.mouseup),!1);window.addEventListener("keydown",b(this,this.keydown),!1);window.addEventListener("keyup",b(this,
this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype;
THREE.RollCamera=function(a,b,c,e){THREE.Camera.call(this,a,b,c,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Matrix4,j=!1,m=1,l=0,n=0,t=0,o=0,w=0,v=window.innerWidth/2,z=window.innerHeight/2;this.update=
function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.delta=(a-this.lastUpdate)/1E3;this.lastUpdate=a;this.mouseLook&&(a=this.delta*this.lookSpeed,this.rotateHorizontally(a*o),this.rotateVertically(a*w));a=this.delta*this.movementSpeed;this.translateZ(a*(l>0||this.autoForward&&!(l<0)?1:l));this.translateX(a*n);this.translateY(a*t);j&&(this.roll+=this.rollSpeed*this.delta*m);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();
THREE.RollCamera=function(a,b,c,e){THREE.Camera.call(this,a,b,c,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Matrix4,j=!1,m=1,l=0,n=0,p=0,o=0,v=0,u=window.innerWidth/2,w=window.innerHeight/2;this.update=
function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.delta=(a-this.lastUpdate)/1E3;this.lastUpdate=a;this.mouseLook&&(a=this.delta*this.lookSpeed,this.rotateHorizontally(a*o),this.rotateVertically(a*v));a=this.delta*this.movementSpeed;this.translateZ(a*(l>0||this.autoForward&&!(l<0)?1:l));this.translateX(a*n);this.translateY(a*p);j&&(this.roll+=this.rollSpeed*this.delta*m);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();
else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();h.copy(this.forward);g.set(0,1,0);f.cross(g,h).normalize();g.cross(h,f).normalize();this.matrix.n11=f.x;this.matrix.n12=g.x;this.matrix.n13=h.x;this.matrix.n21=f.y;this.matrix.n22=g.y;this.matrix.n23=h.y;this.matrix.n31=f.z;this.matrix.n32=g.z;this.matrix.n33=h.z;k.identity();k.n11=Math.cos(this.roll);k.n12=-Math.sin(this.roll);k.n21=Math.sin(this.roll);k.n22=Math.cos(this.roll);this.matrix.multiplySelf(k);
this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(a){this.position.x+=this.matrix.n11*a;this.position.y+=this.matrix.n21*a;this.position.z+=this.matrix.n31*a};this.translateY=function(a){this.position.x+=this.matrix.n12*a;this.position.y+=this.matrix.n22*a;this.position.z+=this.matrix.n32*a};this.translateZ=function(a){this.position.x-=this.matrix.n13*a;this.position.y-=
this.matrix.n23*a;this.position.z-=this.matrix.n33*a};this.rotateHorizontally=function(a){f.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);f.multiplyScalar(a);this.forward.subSelf(f);this.forward.normalize()};this.rotateVertically=function(a){g.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);g.multiplyScalar(a);this.forward.addSelf(g);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",
function(a){o=(a.clientX-v)/window.innerWidth;w=(a.clientY-z)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:l=1;break;case 2:l=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:l=0;break;case 2:l=0}},!1);this.domElement.addEventListener("keydown",function(a){switch(a.keyCode){case 38:case 87:l=1;break;case 37:case 65:n=-1;break;
case 40:case 83:l=-1;break;case 39:case 68:n=1;break;case 81:j=!0;m=1;break;case 69:j=!0;m=-1;break;case 82:t=1;break;case 70:t=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:l=0;break;case 37:case 65:n=0;break;case 40:case 83:l=0;break;case 39:case 68:n=0;break;case 81:j=!1;break;case 69:j=!1;break;case 82:t=0;break;case 70:t=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
function(a){o=(a.clientX-u)/window.innerWidth;v=(a.clientY-w)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:l=1;break;case 2:l=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:l=0;break;case 2:l=0}},!1);this.domElement.addEventListener("keydown",function(a){switch(a.keyCode){case 38:case 87:l=1;break;case 37:case 65:n=-1;break;
case 40:case 83:l=-1;break;case 39:case 68:n=1;break;case 81:j=!0;m=1;break;case 69:j=!0;m=-1;break;case 82:p=1;break;case 70:p=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:l=0;break;case 37:case 65:n=0;break;case 40:case 83:l=0;break;case 39:case 68:n=0;break;case 81:j=!1;break;case 69:j=!1;break;case 82:p=0;break;case 70:p=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
THREE.TrackballCamera=function(a){function b(a,c){return function(){c.apply(a,arguments)}}a=a||{};THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.domElement=a.domElement||document;this.screen=a.screen||{width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=a.radius||(this.screen.width+this.screen.height)/4;this.rotateSpeed=a.rotateSpeed||1;this.zoomSpeed=a.zoomSpeed||1.2;this.panSpeed=a.panSpeed||0.3;this.noZoom=a.noZoom||!1;this.noPan=a.noPan||
!1;this.staticMoving=a.staticMoving||!1;this.dynamicDampingFactor=a.dynamicDampingFactor||0.2;this.minDistance=a.minDistance||0;this.maxDistance=a.maxDistance||Infinity;this.keys=a.keys||[65,83,68];this.useTarget=!0;var c=!1,e=this.STATE.NONE,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector2,j=new THREE.Vector2,m=new THREE.Vector2,l=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,c){return new THREE.Vector2((a-
......@@ -83,9 +83,9 @@ b(this,function(a){c&&(g=h=this.getMouseProjectionOnBall(a.clientX,a.clientY),k=
a.stopPropagation();if(e===this.STATE.NONE)e=a.button,e===this.STATE.ROTATE?g=h=this.getMouseProjectionOnBall(a.clientX,a.clientY):e===this.STATE.ZOOM&&!this.noZoom?k=j=this.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(m=l=this.getMouseOnScreen(a.clientX,a.clientY))}),!1);this.domElement.addEventListener("mouseup",b(this,function(a){a.preventDefault();a.stopPropagation();e=this.STATE.NONE}),!1);window.addEventListener("keydown",b(this,function(a){if(e===this.STATE.NONE){if(a.keyCode===this.keys[this.STATE.ROTATE])e=
this.STATE.ROTATE;else if(a.keyCode===this.keys[this.STATE.ZOOM]&&!this.noZoom)e=this.STATE.ZOOM;else if(a.keyCode===this.keys[this.STATE.PAN]&&!this.noPan)e=this.STATE.PAN;e!==this.STATE.NONE&&(c=!0)}}),!1);window.addEventListener("keyup",b(this,function(){if(e!==this.STATE.NONE)e=this.STATE.NONE}),!1)};THREE.TrackballCamera.prototype=new THREE.Camera;THREE.TrackballCamera.prototype.constructor=THREE.TrackballCamera;THREE.TrackballCamera.prototype.supr=THREE.Camera.prototype;
THREE.TrackballCamera.prototype.STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};
THREE.CubeGeometry=function(a,b,c,e,f,g,h,k,j){function m(a,c,b,h,k,j,m,n){var t,o,w=e||1,v=f||1,K=k/2,M=j/2,L=l.vertices.length;if(a=="x"&&c=="y"||a=="y"&&c=="x")t="z";else if(a=="x"&&c=="z"||a=="z"&&c=="x")t="y",v=g||1;else if(a=="z"&&c=="y"||a=="y"&&c=="z")t="x",w=g||1;var H=w+1,N=v+1;k/=w;var O=j/v;for(o=0;o<N;o++)for(j=0;j<H;j++){var A=new THREE.Vector3;A[a]=(j*k-K)*b;A[c]=(o*O-M)*h;A[t]=m;l.vertices.push(new THREE.Vertex(A))}for(o=0;o<v;o++)for(j=0;j<w;j++)l.faces.push(new THREE.Face4(j+H*o+
L,j+H*(o+1)+L,j+1+H*(o+1)+L,j+1+H*o+L,null,null,n)),l.faceVertexUvs[0].push([new THREE.UV(j/w,o/v),new THREE.UV(j/w,(o+1)/v),new THREE.UV((j+1)/w,(o+1)/v),new THREE.UV((j+1)/w,o/v)])}THREE.Geometry.call(this);var l=this,n=a/2,t=b/2,o=c/2,k=k?-1:1;if(h!==void 0)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var w=0;w<6;w++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=void 0)for(var v in j)this.sides[v]!=void 0&&(this.sides[v]=
j[v]);this.sides.px&&m("z","y",1*k,-1,c,b,-n,this.materials[0]);this.sides.nx&&m("z","y",-1*k,-1,c,b,n,this.materials[1]);this.sides.py&&m("x","z",1*k,1,a,c,t,this.materials[2]);this.sides.ny&&m("x","z",1*k,-1,a,c,-t,this.materials[3]);this.sides.pz&&m("x","y",1*k,-1,a,b,o,this.materials[4]);this.sides.nz&&m("x","y",-1*k,-1,a,b,-o,this.materials[5]);(function(){for(var a=[],c=[],b=0,e=l.vertices.length;b<e;b++){for(var g=l.vertices[b],f=!1,h=0,k=a.length;h<k;h++){var j=a[h];if(g.position.x==j.position.x&&
THREE.CubeGeometry=function(a,b,c,e,f,g,h,k,j){function m(a,c,b,h,k,j,m,n){var p,o,v=e||1,u=f||1,C=k/2,J=j/2,L=l.vertices.length;if(a=="x"&&c=="y"||a=="y"&&c=="x")p="z";else if(a=="x"&&c=="z"||a=="z"&&c=="x")p="y",u=g||1;else if(a=="z"&&c=="y"||a=="y"&&c=="z")p="x",v=g||1;var H=v+1,N=u+1;k/=v;var O=j/u;for(o=0;o<N;o++)for(j=0;j<H;j++){var A=new THREE.Vector3;A[a]=(j*k-C)*b;A[c]=(o*O-J)*h;A[p]=m;l.vertices.push(new THREE.Vertex(A))}for(o=0;o<u;o++)for(j=0;j<v;j++)l.faces.push(new THREE.Face4(j+H*o+
L,j+H*(o+1)+L,j+1+H*(o+1)+L,j+1+H*o+L,null,null,n)),l.faceVertexUvs[0].push([new THREE.UV(j/v,o/u),new THREE.UV(j/v,(o+1)/u),new THREE.UV((j+1)/v,(o+1)/u),new THREE.UV((j+1)/v,o/u)])}THREE.Geometry.call(this);var l=this,n=a/2,p=b/2,o=c/2,k=k?-1:1;if(h!==void 0)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var v=0;v<6;v++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=void 0)for(var u in j)this.sides[u]!=void 0&&(this.sides[u]=
j[u]);this.sides.px&&m("z","y",1*k,-1,c,b,-n,this.materials[0]);this.sides.nx&&m("z","y",-1*k,-1,c,b,n,this.materials[1]);this.sides.py&&m("x","z",1*k,1,a,c,p,this.materials[2]);this.sides.ny&&m("x","z",1*k,-1,a,c,-p,this.materials[3]);this.sides.pz&&m("x","y",1*k,-1,a,b,o,this.materials[4]);this.sides.nz&&m("x","y",-1*k,-1,a,b,-o,this.materials[5]);(function(){for(var a=[],c=[],b=0,e=l.vertices.length;b<e;b++){for(var g=l.vertices[b],f=!1,h=0,k=a.length;h<k;h++){var j=a[h];if(g.position.x==j.position.x&&
g.position.y==j.position.y&&g.position.z==j.position.z){c[b]=h;f=!0;break}}if(!f)c[b]=a.length,a.push(new THREE.Vertex(g.position.clone()))}b=0;for(e=l.faces.length;b<e;b++)g=l.faces[b],g.a=c[g.a],g.b=c[g.b],g.c=c[g.c],g.d=c[g.d];l.vertices=a})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
THREE.CylinderGeometry=function(a,b,c,e,f,g){function h(a,c,b){k.vertices.push(new THREE.Vertex(new THREE.Vector3(a,c,b)))}THREE.Geometry.call(this);var k=this,j,m=Math.PI*2,l=e/2;for(j=0;j<a;j++)h(Math.sin(m*j/a)*b,Math.cos(m*j/a)*b,-l);for(j=0;j<a;j++)h(Math.sin(m*j/a)*c,Math.cos(m*j/a)*c,l);for(j=0;j<a;j++)k.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c>0){h(0,0,-l-(g||0));for(j=a;j<a+a/2;j++)k.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b>0){h(0,0,l+
(f||0));for(j=a+a/2;j<2*a;j++)k.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j<a;j++){var b=[],c=this.faces[j],f=this.vertices[c.a],g=this.vertices[c.b],l=this.vertices[c.c],n=this.vertices[c.d];b.push(new THREE.UV(0.5+Math.atan2(f.position.x,f.position.y)/m,0.5+f.position.z/e));b.push(new THREE.UV(0.5+Math.atan2(g.position.x,g.position.y)/m,0.5+g.position.z/e));b.push(new THREE.UV(0.5+Math.atan2(l.position.x,l.position.y)/m,0.5+l.position.z/
......@@ -97,27 +97,27 @@ THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;t
for(k=0;k<e.length-1;k++)this.faces.push(new THREE.Face4(f[k],f[k+1],e[k+1],e[k])),this.faceVertexUvs[0].push([new THREE.UV(1-j/this.angle,k/a.length),new THREE.UV(1-j/this.angle,(k+1)/a.length),new THREE.UV(1-(j-b)/this.angle,(k+1)/a.length),new THREE.UV(1-(j-b)/this.angle,k/a.length)]);e=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
THREE.PlaneGeometry=function(a,b,c,e){THREE.Geometry.call(this);var f,g=a/2,h=b/2,c=c||1,e=e||1,k=c+1,j=e+1;a/=c;var m=b/e;for(f=0;f<j;f++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-g,-(f*m-h),0)));for(f=0;f<e;f++)for(b=0;b<c;b++)this.faces.push(new THREE.Face4(b+k*f,b+k*(f+1),b+1+k*(f+1),b+1+k*f)),this.faceVertexUvs[0].push([new THREE.UV(b/c,f/e),new THREE.UV(b/c,(f+1)/e),new THREE.UV((b+1)/c,(f+1)/e),new THREE.UV((b+1)/c,f/e)]);this.computeCentroids();this.computeFaceNormals()};
THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
THREE.SphereGeometry=function(a,b,c){THREE.Geometry.call(this);for(var a=a||50,e,f=Math.PI,g=Math.max(3,b||8),h=Math.max(2,c||6),b=[],c=0;c<h+1;c++){e=c/h;var k=a*Math.cos(e*f),j=a*Math.sin(e*f),m=[],l=0;for(e=0;e<g;e++){var n=2*e/g,t=j*Math.sin(n*f),n=j*Math.cos(n*f);(c==0||c==h)&&e>0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,k,t)))-1);m.push(l)}b.push(m)}for(var o,w,v,f=b.length,c=0;c<f;c++)if(g=b[c].length,c>0)for(e=0;e<g;e++){m=e==g-1;h=b[c][m?0:e+1];k=b[c][m?g-1:e];j=b[c-1][m?
g-1:e];m=b[c-1][m?0:e+1];t=c/(f-1);o=(c-1)/(f-1);w=(e+1)/g;var n=e/g,l=new THREE.UV(1-w,t),t=new THREE.UV(1-n,t),n=new THREE.UV(1-n,o),z=new THREE.UV(1-w,o);c<b.length-1&&(o=this.vertices[h].position.clone(),w=this.vertices[k].position.clone(),v=this.vertices[j].position.clone(),o.normalize(),w.normalize(),v.normalize(),this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(v.x,v.y,v.z)])),this.faceVertexUvs[0].push([l,t,n]));c>1&&(o=
this.vertices[h].position.clone(),w=this.vertices[j].position.clone(),v=this.vertices[m].position.clone(),o.normalize(),w.normalize(),v.normalize(),this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(v.x,v.y,v.z)])),this.faceVertexUvs[0].push([l,n,z]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
THREE.SphereGeometry=function(a,b,c){THREE.Geometry.call(this);for(var a=a||50,e,f=Math.PI,g=Math.max(3,b||8),h=Math.max(2,c||6),b=[],c=0;c<h+1;c++){e=c/h;var k=a*Math.cos(e*f),j=a*Math.sin(e*f),m=[],l=0;for(e=0;e<g;e++){var n=2*e/g,p=j*Math.sin(n*f),n=j*Math.cos(n*f);(c==0||c==h)&&e>0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,k,p)))-1);m.push(l)}b.push(m)}for(var o,v,u,f=b.length,c=0;c<f;c++)if(g=b[c].length,c>0)for(e=0;e<g;e++){m=e==g-1;h=b[c][m?0:e+1];k=b[c][m?g-1:e];j=b[c-1][m?
g-1:e];m=b[c-1][m?0:e+1];p=c/(f-1);o=(c-1)/(f-1);v=(e+1)/g;var n=e/g,l=new THREE.UV(1-v,p),p=new THREE.UV(1-n,p),n=new THREE.UV(1-n,o),w=new THREE.UV(1-v,o);c<b.length-1&&(o=this.vertices[h].position.clone(),v=this.vertices[k].position.clone(),u=this.vertices[j].position.clone(),o.normalize(),v.normalize(),u.normalize(),this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(u.x,u.y,u.z)])),this.faceVertexUvs[0].push([l,p,n]));c>1&&(o=
this.vertices[h].position.clone(),v=this.vertices[j].position.clone(),u=this.vertices[m].position.clone(),o.normalize(),v.normalize(),u.normalize(),this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(u.x,u.y,u.z)])),this.faceVertexUvs[0].push([l,n,w]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(a,b){THREE.Geometry.call(this);this.parameters=b||{};this.set(a)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
THREE.TextGeometry.prototype.set=function(a,b){function c(a,c,b){w.vertices.push(new THREE.Vertex(new THREE.Vector3(a,c,b)))}function e(a,c,b,e){w.faces.push(new THREE.Face4(a,c,b,e))}this.text=a;var b=b||this.parameters,f=b.height!==void 0?b.height:50,g=b.curveSegments!==void 0?b.curveSegments:4,h=b.font!==void 0?b.font:"helvetiker",k=b.weight!==void 0?b.weight:"normal",j=b.style!==void 0?b.style:"normal",m=b.bezelThickness!==void 0?b.bezelThickness:10,l=b.bezelSize!==void 0?b.bezelSize:8,n=b.bezelEnabled!==
void 0?b.bezelEnabled:!1;THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=g;THREE.FontUtils.face=h;THREE.FontUtils.weight=k;THREE.FontUtils.style=j;THREE.FontUtils.bezelSize=l;var k=THREE.FontUtils.drawText(a),g=k.points,t=k.faces,h=k.contour,o=k.bezel,w=this;w.vertices=[];w.faces=[];for(var v,j=g.length,z=t.length,l=o.length,k=0;k<j;k++)v=g[k],c(v.x,v.y,0);for(k=0;k<j;k++)v=g[k],c(v.x,v.y,f);if(n){for(k=0;k<l;k++)v=o[k],c(v.x,v.y,m);for(k=0;k<l;k++)v=o[k],c(v.x,v.y,f-m)}for(k=
0;k<z;k++)f=t[k],w.faces.push(new THREE.Face3(f[2],f[1],f[0]));for(k=0;k<z;k++)f=t[k],w.faces.push(new THREE.Face3(f[0]+j,f[1]+j,f[2]+j));var x;if(n)for(k=o.length;--k>0;){if(x){if(x.equals(h[k])){x=null;continue}}else x=h[k];m=j*2+k;t=m-1;e(m,t,t+l,m+l);for(n=0;n<j;n++)if(g[n].equals(h[k]))break;for(f=0;f<j;f++)if(g[f].equals(h[k-1]))break;e(n,f,t,m);e(m+l,t+l,f+j,n+j)}else for(k=h.length;--k>0;){if(x){if(x.equals(h[k])){x=null;continue}}else x=h[k];for(n=0;n<j;n++)if(g[n].equals(h[k]))break;for(f=
THREE.TextGeometry.prototype.set=function(a,b){function c(a,c,b){v.vertices.push(new THREE.Vertex(new THREE.Vector3(a,c,b)))}function e(a,c,b,e){v.faces.push(new THREE.Face4(a,c,b,e))}this.text=a;var b=b||this.parameters,f=b.height!==void 0?b.height:50,g=b.curveSegments!==void 0?b.curveSegments:4,h=b.font!==void 0?b.font:"helvetiker",k=b.weight!==void 0?b.weight:"normal",j=b.style!==void 0?b.style:"normal",m=b.bezelThickness!==void 0?b.bezelThickness:10,l=b.bezelSize!==void 0?b.bezelSize:8,n=b.bezelEnabled!==
void 0?b.bezelEnabled:!1;THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=g;THREE.FontUtils.face=h;THREE.FontUtils.weight=k;THREE.FontUtils.style=j;THREE.FontUtils.bezelSize=l;var k=THREE.FontUtils.drawText(a),g=k.points,p=k.faces,h=k.contour,o=k.bezel,v=this;v.vertices=[];v.faces=[];for(var u,j=g.length,w=p.length,l=o.length,k=0;k<j;k++)u=g[k],c(u.x,u.y,0);for(k=0;k<j;k++)u=g[k],c(u.x,u.y,f);if(n){for(k=0;k<l;k++)u=o[k],c(u.x,u.y,m);for(k=0;k<l;k++)u=o[k],c(u.x,u.y,f-m)}for(k=
0;k<w;k++)f=p[k],v.faces.push(new THREE.Face3(f[2],f[1],f[0]));for(k=0;k<w;k++)f=p[k],v.faces.push(new THREE.Face3(f[0]+j,f[1]+j,f[2]+j));var x;if(n)for(k=o.length;--k>0;){if(x){if(x.equals(h[k])){x=null;continue}}else x=h[k];m=j*2+k;p=m-1;e(m,p,p+l,m+l);for(n=0;n<j;n++)if(g[n].equals(h[k]))break;for(f=0;f<j;f++)if(g[f].equals(h[k-1]))break;e(n,f,p,m);e(m+l,p+l,f+j,n+j)}else for(k=h.length;--k>0;){if(x){if(x.equals(h[k])){x=null;continue}}else x=h[k];for(n=0;n<j;n++)if(g[n].equals(h[k]))break;for(f=
0;f<j;f++)if(g[f].equals(h[k-1]))break;e(n,f,f+j,n+j)}this.computeCentroids();this.computeFaceNormals()};
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},extractPoints:function(a,b){if(a.length<3)return console.log("not valid polygon"),
{points:a,faces:[]};for(var c,e,f,g,h,k=[],j=0;j<b.length;j++){h=b[j];g=[];for(c=0;c<h.length;c++)e=h[c],g.push(e.x+","+e.y);var m;c=g.slice(1).indexOf(g[0]);var l=this.Triangulate.area(h.slice(0,c+1))<0;e=[];for(c=-1;c<g.length;){m=c+1;c=g[m];c=g.slice(m+1).indexOf(c)+m;if(c<=m)break;var n=h.slice(m,c+1);l?this.Triangulate.area(n)<0?(m>0&&k.push({shape:f,holes:e}),f=n,e=[]):e.push(n):this.Triangulate.area(n)<0?(k.push({shape:n,holes:e}),e=[]):e.push(n);c++}l&&k.push({shape:f,holes:e})}var t,o,w,
v,z,x;g=[];for(h=0;h<k.length;h++){j=k[h];f=j.shape;e=j.holes;for(m=0;m<e.length;m++){l=e[m];w=Number.POSITIVE_INFINITY;for(n=0;n<l.length;n++){z=l[n];for(c=0;c<f.length;c++)v=f[c],v=z.distanceTo(v),v<w&&(w=v,t=n,o=c)}c=o-1>=0?o-1:f.length-1;var n=t-1>=0?t-1:l.length-1,p=[];p.push(l[t]);p.push(f[o]);p.push(f[c]);w=this.Triangulate.area(p);var u=[];u.push(l[t]);u.push(l[n]);u.push(f[o]);z=this.Triangulate.area(u);v=o;x=t;o+=1;t+=-1;o<0&&(o+=f.length);o%=f.length;t<0&&(t+=l.length);t%=f.length;c=o-
1>=0?o-1:f.length-1;n=t-1>=0?t-1:l.length-1;p=[];p.push(l[t]);p.push(f[o]);p.push(f[c]);p=this.Triangulate.area(p);u=[];u.push(l[t]);u.push(l[n]);u.push(f[o]);u=this.Triangulate.area(u);w+z>p+u&&(o=v,t=x,o<0&&(o+=f.length),o%=f.length,t<0&&(t+=l.length),t%=f.length,c=o-1>=0?o-1:f.length-1,n=t-1>=0?t-1:l.length-1);w=f.slice(0,o);z=f.slice(o);v=l.slice(t);x=l.slice(0,t);g.push(l[t]);g.push(f[o]);g.push(f[c]);g.push(l[t]);g.push(l[n]);g.push(f[o]);f=w.concat(v).concat(x).concat(z)}j.shape=f}t=[];o=[];
for(h=m=0;h<k.length;h++){j=k[h];f=j.shape;t=t.concat(f);l=THREE.FontUtils.Triangulate(f,!0);for(e=0;e<l.length;e++)j=l[e],j[0]+=m,j[1]+=m,j[2]+=m;o=o.concat(l);m+=f.length}var B;for(e=0;e<g.length/3;e++){j=[];for(k=0;k<3;k++){h=!1;for(f=0;f<t.length&&!h;f++)B=e*3+k,t[f].equals(g[B])&&(j.push(f),h=!0);h||(t.push(g[B]),j.push(t.length-1),console.log("not found"))}o.push(j)}return{points:t,faces:o}},drawText:function(a){var b=[],c=[],e,f=this.getFace(),g=this.size/f.resolution,h=0;e=String(a).split("");
{points:a,faces:[]};for(var c,e,f,g,h,k=[],j=0;j<b.length;j++){h=b[j];g=[];for(c=0;c<h.length;c++)e=h[c],g.push(e.x+","+e.y);var m;c=g.slice(1).indexOf(g[0]);var l=this.Triangulate.area(h.slice(0,c+1))<0;e=[];for(c=-1;c<g.length;){m=c+1;c=g[m];c=g.slice(m+1).indexOf(c)+m;if(c<=m)break;var n=h.slice(m,c+1);l?this.Triangulate.area(n)<0?(m>0&&k.push({shape:f,holes:e}),f=n,e=[]):e.push(n):this.Triangulate.area(n)<0?(k.push({shape:n,holes:e}),e=[]):e.push(n);c++}l&&k.push({shape:f,holes:e})}var p,o,v,
u,w,x;g=[];for(h=0;h<k.length;h++){j=k[h];f=j.shape;e=j.holes;for(m=0;m<e.length;m++){l=e[m];v=Number.POSITIVE_INFINITY;for(n=0;n<l.length;n++){w=l[n];for(c=0;c<f.length;c++)u=f[c],u=w.distanceTo(u),u<v&&(v=u,p=n,o=c)}c=o-1>=0?o-1:f.length-1;var n=p-1>=0?p-1:l.length-1,y=[];y.push(l[p]);y.push(f[o]);y.push(f[c]);v=this.Triangulate.area(y);var t=[];t.push(l[p]);t.push(l[n]);t.push(f[o]);w=this.Triangulate.area(t);u=o;x=p;o+=1;p+=-1;o<0&&(o+=f.length);o%=f.length;p<0&&(p+=l.length);p%=f.length;c=o-
1>=0?o-1:f.length-1;n=p-1>=0?p-1:l.length-1;y=[];y.push(l[p]);y.push(f[o]);y.push(f[c]);y=this.Triangulate.area(y);t=[];t.push(l[p]);t.push(l[n]);t.push(f[o]);t=this.Triangulate.area(t);v+w>y+t&&(o=u,p=x,o<0&&(o+=f.length),o%=f.length,p<0&&(p+=l.length),p%=f.length,c=o-1>=0?o-1:f.length-1,n=p-1>=0?p-1:l.length-1);v=f.slice(0,o);w=f.slice(o);u=l.slice(p);x=l.slice(0,p);g.push(l[p]);g.push(f[o]);g.push(f[c]);g.push(l[p]);g.push(l[n]);g.push(f[o]);f=v.concat(u).concat(x).concat(w)}j.shape=f}p=[];o=[];
for(h=m=0;h<k.length;h++){j=k[h];f=j.shape;p=p.concat(f);l=THREE.FontUtils.Triangulate(f,!0);for(e=0;e<l.length;e++)j=l[e],j[0]+=m,j[1]+=m,j[2]+=m;o=o.concat(l);m+=f.length}var z;for(e=0;e<g.length/3;e++){j=[];for(k=0;k<3;k++){h=!1;for(f=0;f<p.length&&!h;f++)z=e*3+k,p[f].equals(g[z])&&(j.push(f),h=!0);h||(p.push(g[z]),j.push(p.length-1),console.log("not found"))}o.push(j)}return{points:p,faces:o}},drawText:function(a){var b=[],c=[],e,f=this.getFace(),g=this.size/f.resolution,h=0;e=String(a).split("");
for(var k=e.length,a=0;a<k;a++){var j=this.extractGlyphPoints(e[a],f,g,h);h+=j.offset;b.push(j.points);c=c.concat(j.points)}a=h/2;for(e=0;e<c.length;e++)c[e].x-=a;b=this.extractPoints(c,b);b.contour=c;f=[];g=[];e=[];for(var h=[],k=new THREE.Vector2,m,a=c.length;--a>=0;){if(m){if(m.equals(c[a])){m=null;j=this.Triangulate.area(e)>0;h.push(j);g.push(k.divideScalar(e.length));e=[];k=new THREE.Vector2;continue}}else m=c[a];k.addSelf(c[a]);e.push(c[a])}a=c.length;e=0;for(var l;--a>=0;)j=c[a],k=g[e],j=j.clone().subSelf(k),
l=this.bezelSize/j.length(),h[e]?l+=1:l=1-l,l=j.multiplyScalar(l).addSelf(k),f.unshift(l),m?m.equals(c[a])&&(m=null,e++):m=c[a];b.bezel=f;return b},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,e){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,e)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*
b},b3:function(a,b,c,e,f){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,e)+this.b3p3(a,f)},extractGlyphPoints:function(a,b,c,e){var f=[],g,h,k,j,m,l,n,t,o,w,v=b.glyphs[a]||b.glyphs[ctxt.options.fallbackCharacter];if(v){if(v.o){b=v._cachedOutline||(v._cachedOutline=v.o.split(" "));k=b.length;for(a=0;a<k;)switch(h=b[a++],h){case "m":h=b[a++]*c+e;j=b[a++]*c;f.push(new THREE.Vector2(h,j));break;case "l":h=b[a++]*c+e;j=b[a++]*c;f.push(new THREE.Vector2(h,j));break;case "q":h=b[a++]*c+e;j=b[a++]*c;n=
b[a++]*c+e;t=b[a++]*c;if(g=f[f.length-1]){m=g.x;l=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++){var z=g/divisions,x=THREE.FontUtils.b2(z,m,n,h),z=THREE.FontUtils.b2(z,l,t,j);f.push(new THREE.Vector2(x,z))}}break;case "b":if(h=b[a++]*c+e,j=b[a++]*c,n=b[a++]*c+e,t=b[a++]*-c,o=b[a++]*c+e,w=b[a++]*-c,g=f[f.length-1]){m=g.x;l=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++)z=g/divisions,x=THREE.FontUtils.b3(z,m,n,o,h),z=THREE.FontUtils.b3(z,l,t,w,j),f.push(new THREE.Vector2(x,z))}}}return{offset:v.ha*
b},b3:function(a,b,c,e,f){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,e)+this.b3p3(a,f)},extractGlyphPoints:function(a,b,c,e){var f=[],g,h,k,j,m,l,n,p,o,v,u=b.glyphs[a]||b.glyphs[ctxt.options.fallbackCharacter];if(u){if(u.o){b=u._cachedOutline||(u._cachedOutline=u.o.split(" "));k=b.length;for(a=0;a<k;)switch(h=b[a++],h){case "m":h=b[a++]*c+e;j=b[a++]*c;f.push(new THREE.Vector2(h,j));break;case "l":h=b[a++]*c+e;j=b[a++]*c;f.push(new THREE.Vector2(h,j));break;case "q":h=b[a++]*c+e;j=b[a++]*c;n=
b[a++]*c+e;p=b[a++]*c;if(g=f[f.length-1]){m=g.x;l=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++){var w=g/divisions,x=THREE.FontUtils.b2(w,m,n,h),w=THREE.FontUtils.b2(w,l,p,j);f.push(new THREE.Vector2(x,w))}}break;case "b":if(h=b[a++]*c+e,j=b[a++]*c,n=b[a++]*c+e,p=b[a++]*-c,o=b[a++]*c+e,v=b[a++]*-c,g=f[f.length-1]){m=g.x;l=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++)w=g/divisions,x=THREE.FontUtils.b3(w,m,n,o,h),w=THREE.FontUtils.b3(w,l,p,v,j),f.push(new THREE.Vector2(x,w))}}}return{offset:u.ha*
c,points:f}}}};
(function(a){var b=function(a){for(var b=a.length,f=0,g=b-1,h=0;h<b;g=h++)f+=a[g].x*a[h].y-a[h].x*a[g].y;return f*0.5};a.Triangulate=function(a,e){var f=a.length;if(f<3)return null;var g=[],h=[],k=[],j,m,l;if(b(a)>0)for(m=0;m<f;m++)h[m]=m;else for(m=0;m<f;m++)h[m]=f-1-m;var n=2*f;for(m=f-1;f>2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return g}j=m;f<=j&&(j=0);m=j+1;f<=m&&(m=0);l=m+1;f<=l&&(l=0);var t;a:{t=a;var o=j,w=m,v=l,z=f,x=h,p=void 0,u=void 0,B=void 0,
y=void 0,D=void 0,E=void 0,F=void 0,G=void 0,I=void 0,u=t[x[o]].x,B=t[x[o]].y,y=t[x[w]].x,D=t[x[w]].y,E=t[x[v]].x,F=t[x[v]].y;if(1.0E-10>(y-u)*(F-B)-(D-B)*(E-u))t=!1;else{for(p=0;p<z;p++)if(!(p==o||p==w||p==v)){var G=t[x[p]].x,I=t[x[p]].y,C=void 0,K=void 0,M=void 0,L=void 0,H=void 0,N=void 0,O=void 0,A=void 0,P=void 0,J=void 0,Q=void 0,R=void 0,C=M=H=void 0,C=E-y,K=F-D,M=u-E,L=B-F,H=y-u,N=D-B,O=G-u,A=I-B,P=G-y,J=I-D,Q=G-E,R=I-F,C=C*J-K*P,H=H*A-N*O,M=M*R-L*Q;if(C>=0&&M>=0&&H>=0){t=!1;break a}}t=!0}}if(t){n=
h[j];t=h[m];o=h[l];g.push(a[n]);g.push(a[t]);g.push(a[o]);k.push([h[j],h[m],h[l]]);j=m;for(l=m+1;l<f;j++,l++)h[j]=h[l];f--;n=2*f}}if(e)return k;return g};a.Triangulate.area=b;return a})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
(function(a){var b=function(a){for(var b=a.length,f=0,g=b-1,h=0;h<b;g=h++)f+=a[g].x*a[h].y-a[h].x*a[g].y;return f*0.5};a.Triangulate=function(a,e){var f=a.length;if(f<3)return null;var g=[],h=[],k=[],j,m,l;if(b(a)>0)for(m=0;m<f;m++)h[m]=m;else for(m=0;m<f;m++)h[m]=f-1-m;var n=2*f;for(m=f-1;f>2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return g}j=m;f<=j&&(j=0);m=j+1;f<=m&&(m=0);l=m+1;f<=l&&(l=0);var p;a:{p=a;var o=j,v=m,u=l,w=f,x=h,y=void 0,t=void 0,z=void 0,
B=void 0,E=void 0,F=void 0,G=void 0,D=void 0,K=void 0,t=p[x[o]].x,z=p[x[o]].y,B=p[x[v]].x,E=p[x[v]].y,F=p[x[u]].x,G=p[x[u]].y;if(1.0E-10>(B-t)*(G-z)-(E-z)*(F-t))p=!1;else{for(y=0;y<w;y++)if(!(y==o||y==v||y==u)){var D=p[x[y]].x,K=p[x[y]].y,I=void 0,C=void 0,J=void 0,L=void 0,H=void 0,N=void 0,O=void 0,A=void 0,P=void 0,M=void 0,R=void 0,S=void 0,I=J=H=void 0,I=F-B,C=G-E,J=t-F,L=z-G,H=B-t,N=E-z,O=D-t,A=K-z,P=D-B,M=K-E,R=D-F,S=K-G,I=I*M-C*P,H=H*A-N*O,J=J*S-L*R;if(I>=0&&J>=0&&H>=0){p=!1;break a}}p=!0}}if(p){n=
h[j];p=h[m];o=h[l];g.push(a[n]);g.push(a[p]);g.push(a[o]);k.push([h[j],h[m],h[l]]);j=m;for(l=m+1;l<f;j++,l++)h[j]=h[l];f--;n=2*f}}if(e)return k;return g};a.Triangulate.area=b;return a})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
THREE.TorusGeometry=function(a,b,c,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){var e=c/this.segmentsT*2*Math.PI,f=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
1;c<=this.segmentsT;++c){var e=(this.segmentsT+1)*b+c,f=(this.segmentsT+1)*b+c-1,g=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,f,g,h));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusGeometry.prototype=new THREE.Geometry;
THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
......@@ -132,56 +132,55 @@ Math.LN2));a.image.width=b;a.image.height=e;a.image.getContext("2d").drawImage(t
1)g.map.wrapS=THREE.RepeatWrapping;if(a.mapDiffuseRepeat[1]!=1)g.map.wrapT=THREE.RepeatWrapping}a.mapDiffuseOffset&&g.map.offset.set(a.mapDiffuseOffset[0],a.mapDiffuseOffset[1]);if(a.mapDiffuseWrap){h={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(h[a.mapDiffuseWrap[0]]!==void 0)g.map.wrapS=h[a.mapDiffuseWrap[0]];if(h[a.mapDiffuseWrap[1]]!==void 0)g.map.wrapT=h[a.mapDiffuseWrap[1]]}e(g.map,b+"/"+a.mapDiffuse)}else if(a.colorDiffuse)h=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*
255<<8)+a.colorDiffuse[2]*255,g.color=h,g.opacity=a.transparency;else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLight&&b){h=document.createElement("canvas");g.lightMap=new THREE.Texture(h);g.lightMap.sourceFile=a.mapLight;if(a.mapLightmapRepeat)g.lightMap.repeat.set(a.mapLightRepeat[0],a.mapLightRepeat[1]),g.lightMap.wrapS=g.lightMap.wrapT=THREE.RepeatWrapping;a.mapLightmapOffset&&g.lightMap.offset.set(a.mapLightmapOffset[0],a.mapLightmapOffset[1]);e(g.lightMap,b+"/"+a.mapLightmap)}return new THREE[f](g)}};
THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;THREE.JSONLoader.prototype.load=function(a){var b=this,c=a.model,e=a.callback,f=a.texture_path?a.texture_path:this.extractUrlbase(c),a=new Worker(c);a.onmessage=function(a){b.createModel(a.data,e,f);b.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
THREE.JSONLoader.prototype.createModel=function(a,b,c){var e=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;this.init_materials(e,a.materials,c);(function(c){if(a.version===void 0||a.version!=2)console.error("Deprecated file format.");else{var b,f,j,m,l,n,t,o,w,v,z,x,p,u,B=a.faces;n=a.vertices;var y=a.normals,D=a.colors,E=0;for(b=0;b<a.uvs.length;b++)a.uvs[b].length&&E++;for(b=0;b<E;b++)e.faceUvs[b]=[],e.faceVertexUvs[b]=[];m=0;for(l=n.length;m<l;)t=new THREE.Vertex,t.position.x=n[m++]*c,t.position.y=
n[m++]*c,t.position.z=n[m++]*c,e.vertices.push(t);m=0;for(l=B.length;m<l;){c=B[m++];n=c&1;j=c&2;b=c&4;f=c&8;o=c&16;t=c&32;v=c&64;c&=128;n?(z=new THREE.Face4,z.a=B[m++],z.b=B[m++],z.c=B[m++],z.d=B[m++],n=4):(z=new THREE.Face3,z.a=B[m++],z.b=B[m++],z.c=B[m++],n=3);if(j)j=B[m++],z.materials=e.materials[j];j=e.faces.length;if(b)for(b=0;b<E;b++)x=a.uvs[b],w=B[m++],u=x[w*2],w=x[w*2+1],e.faceUvs[b][j]=new THREE.UV(u,w);if(f)for(b=0;b<E;b++){x=a.uvs[b];p=[];for(f=0;f<n;f++)w=B[m++],u=x[w*2],w=x[w*2+1],p[f]=
new THREE.UV(u,w);e.faceVertexUvs[b][j]=p}if(o)o=B[m++]*3,f=new THREE.Vector3,f.x=y[o++],f.y=y[o++],f.z=y[o],z.normal=f;if(t)for(b=0;b<n;b++)o=B[m++]*3,f=new THREE.Vector3,f.x=y[o++],f.y=y[o++],f.z=y[o],z.vertexNormals.push(f);if(v)t=B[m++],t=new THREE.Color(D[t]),z.color=t;if(c)for(b=0;b<n;b++)t=B[m++],t=new THREE.Color(D[t]),z.vertexColors.push(t);e.faces.push(z)}}})(f);(function(){var c,b,f,j;if(a.skinWeights){c=0;for(b=a.skinWeights.length;c<b;c+=2)f=a.skinWeights[c],j=a.skinWeights[c+1],e.skinWeights.push(new THREE.Vector4(f,
j,0,0))}if(a.skinIndices){c=0;for(b=a.skinIndices.length;c<b;c+=2)f=a.skinIndices[c],j=a.skinIndices[c+1],e.skinIndices.push(new THREE.Vector4(f,j,0,0))}e.bones=a.bones;e.animation=a.animation})();(function(c){if(a.morphTargets!==void 0){var b,f,j,m,l,n,t,o,w;b=0;for(f=a.morphTargets.length;b<f;b++){e.morphTargets[b]={};e.morphTargets[b].name=a.morphTargets[b].name;e.morphTargets[b].vertices=[];o=e.morphTargets[b].vertices;w=a.morphTargets[b].vertices;j=0;for(m=w.length;j<m;j+=3)l=w[j]*c,n=w[j+1]*
c,t=w[j+2]*c,o.push(new THREE.Vertex(new THREE.Vector3(l,n,t)))}}if(a.morphColors!==void 0){b=0;for(f=a.morphColors.length;b<f;b++){e.morphColors[b]={};e.morphColors[b].name=a.morphColors[b].name;e.morphColors[b].colors=[];m=e.morphColors[b].colors;l=a.morphColors[b].colors;c=0;for(j=l.length;c<j;c+=3)n=new THREE.Color(16755200),n.setRGB(l[c],l[c+1],l[c+2]),m.push(n)}}})(f);(function(){if(a.edges!==void 0){var c,b,f;for(c=0;c<a.edges.length;c+=2)b=a.edges[c],f=a.edges[c+1],e.edges.push(new THREE.Edge(e.vertices[b],
THREE.JSONLoader.prototype.createModel=function(a,b,c){var e=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;this.init_materials(e,a.materials,c);(function(c){if(a.version===void 0||a.version!=2)console.error("Deprecated file format.");else{var b,f,j,m,l,n,p,o,v,u,w,x,y,t,z=a.faces;n=a.vertices;var B=a.normals,E=a.colors,F=0;for(b=0;b<a.uvs.length;b++)a.uvs[b].length&&F++;for(b=0;b<F;b++)e.faceUvs[b]=[],e.faceVertexUvs[b]=[];m=0;for(l=n.length;m<l;)p=new THREE.Vertex,p.position.x=n[m++]*c,p.position.y=
n[m++]*c,p.position.z=n[m++]*c,e.vertices.push(p);m=0;for(l=z.length;m<l;){c=z[m++];n=c&1;j=c&2;b=c&4;f=c&8;o=c&16;p=c&32;u=c&64;c&=128;n?(w=new THREE.Face4,w.a=z[m++],w.b=z[m++],w.c=z[m++],w.d=z[m++],n=4):(w=new THREE.Face3,w.a=z[m++],w.b=z[m++],w.c=z[m++],n=3);if(j)j=z[m++],w.materials=e.materials[j];j=e.faces.length;if(b)for(b=0;b<F;b++)x=a.uvs[b],v=z[m++],t=x[v*2],v=x[v*2+1],e.faceUvs[b][j]=new THREE.UV(t,v);if(f)for(b=0;b<F;b++){x=a.uvs[b];y=[];for(f=0;f<n;f++)v=z[m++],t=x[v*2],v=x[v*2+1],y[f]=
new THREE.UV(t,v);e.faceVertexUvs[b][j]=y}if(o)o=z[m++]*3,f=new THREE.Vector3,f.x=B[o++],f.y=B[o++],f.z=B[o],w.normal=f;if(p)for(b=0;b<n;b++)o=z[m++]*3,f=new THREE.Vector3,f.x=B[o++],f.y=B[o++],f.z=B[o],w.vertexNormals.push(f);if(u)p=z[m++],p=new THREE.Color(E[p]),w.color=p;if(c)for(b=0;b<n;b++)p=z[m++],p=new THREE.Color(E[p]),w.vertexColors.push(p);e.faces.push(w)}}})(f);(function(){var c,b,f,j;if(a.skinWeights){c=0;for(b=a.skinWeights.length;c<b;c+=2)f=a.skinWeights[c],j=a.skinWeights[c+1],e.skinWeights.push(new THREE.Vector4(f,
j,0,0))}if(a.skinIndices){c=0;for(b=a.skinIndices.length;c<b;c+=2)f=a.skinIndices[c],j=a.skinIndices[c+1],e.skinIndices.push(new THREE.Vector4(f,j,0,0))}e.bones=a.bones;e.animation=a.animation})();(function(c){if(a.morphTargets!==void 0){var b,f,j,m,l,n,p,o,v;b=0;for(f=a.morphTargets.length;b<f;b++){e.morphTargets[b]={};e.morphTargets[b].name=a.morphTargets[b].name;e.morphTargets[b].vertices=[];o=e.morphTargets[b].vertices;v=a.morphTargets[b].vertices;j=0;for(m=v.length;j<m;j+=3)l=v[j]*c,n=v[j+1]*
c,p=v[j+2]*c,o.push(new THREE.Vertex(new THREE.Vector3(l,n,p)))}}if(a.morphColors!==void 0){b=0;for(f=a.morphColors.length;b<f;b++){e.morphColors[b]={};e.morphColors[b].name=a.morphColors[b].name;e.morphColors[b].colors=[];m=e.morphColors[b].colors;l=a.morphColors[b].colors;c=0;for(j=l.length;c<j;c+=3)n=new THREE.Color(16755200),n.setRGB(l[c],l[c+1],l[c+2]),m.push(n)}}})(f);(function(){if(a.edges!==void 0){var c,b,f;for(c=0;c<a.edges.length;c+=2)b=a.edges[c],f=a.edges[c+1],e.edges.push(new THREE.Edge(e.vertices[b],
e.vertices[f],b,f))}})();e.computeCentroids();e.computeFaceNormals();b(e)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
THREE.BinaryLoader.prototype={load:function(a){var b=a.model,c=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b),a=(new Date).getTime(),b=new Worker(b),g=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(a){THREE.BinaryLoader.prototype.loadAjaxBuffers(a.data.buffers,a.data.materials,c,f,e,g)};b.onerror=function(a){alert("worker.onerror: "+a.message+"\n"+a.data);a.preventDefault()};
b.postMessage(a)},loadAjaxBuffers:function(a,b,c,e,f,g){var h=new XMLHttpRequest,k=e+"/"+a,j=0;h.onreadystatechange=function(){h.readyState==4?h.status==200||h.status==0?THREE.BinaryLoader.prototype.createBinModel(h.responseText,c,f,b):alert("Couldn't load ["+k+"] ["+h.status+"]"):h.readyState==3?g&&(j==0&&(j=h.getResponseHeader("Content-Length")),g({total:j,loaded:h.responseText.length})):h.readyState==2&&(j=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
h.setRequestHeader("Content-Type","text/plain");h.send(null)},createBinModel:function(a,b,c,e){var f=function(c){function b(a,c){var e=l(a,c),f=l(a,c+1),g=l(a,c+2),h=l(a,c+3),j=(h<<1&255|g>>7)-127;e|=(g&127)<<16|f<<8;if(e==0&&j==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,j)}function f(a,c){var b=l(a,c),e=l(a,c+1),g=l(a,c+2);return(l(a,c+3)<<24)+(g<<16)+(e<<8)+b}function j(a,c){var b=l(a,c);return(l(a,c+1)<<8)+b}function m(a,c){var b=l(a,c);return b>127?b-256:b}function l(a,
c){return a.charCodeAt(c)&255}function n(c){var b,e,g;b=f(a,c);e=f(a,c+D);g=f(a,c+E);c=j(a,c+F);THREE.BinaryLoader.prototype.f3(x,b,e,g,c)}function t(c){var b,e,g,h,m,l;b=f(a,c);e=f(a,c+D);g=f(a,c+E);h=j(a,c+F);m=f(a,c+G);l=f(a,c+I);c=f(a,c+C);THREE.BinaryLoader.prototype.f3n(x,B,b,e,g,h,m,l,c)}function o(c){var b,e,g,h;b=f(a,c);e=f(a,c+K);g=f(a,c+M);h=f(a,c+L);c=j(a,c+H);THREE.BinaryLoader.prototype.f4(x,b,e,g,h,c)}function w(c){var b,e,g,h,m,l,n,o;b=f(a,c);e=f(a,c+K);g=f(a,c+M);h=f(a,c+L);m=j(a,
c+H);l=f(a,c+N);n=f(a,c+O);o=f(a,c+A);c=f(a,c+P);THREE.BinaryLoader.prototype.f4n(x,B,b,e,g,h,m,l,n,o,c)}function v(c){var b,e;b=f(a,c);e=f(a,c+J);c=f(a,c+Q);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],y[b*2],y[b*2+1],y[e*2],y[e*2+1],y[c*2],y[c*2+1])}function z(c){var b,e,g;b=f(a,c);e=f(a,c+R);g=f(a,c+T);c=f(a,c+Z);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],y[b*2],y[b*2+1],y[e*2],y[e*2+1],y[g*2],y[g*2+1],y[c*2],y[c*2+1])}var x=this,p=0,u,B=[],y=[],D,E,F,G,I,C,K,M,L,H,N,O,A,P,J,Q,
R,T,Z,U,V,W,X,Y,S;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,e,c);u={signature:a.substr(p,8),header_bytes:l(a,p+8),vertex_coordinate_bytes:l(a,p+9),normal_coordinate_bytes:l(a,p+10),uv_coordinate_bytes:l(a,p+11),vertex_index_bytes:l(a,p+12),normal_index_bytes:l(a,p+13),uv_index_bytes:l(a,p+14),material_index_bytes:l(a,p+15),nvertices:f(a,p+16),nnormals:f(a,p+16+4),nuvs:f(a,p+16+8),ntri_flat:f(a,p+16+12),ntri_smooth:f(a,p+16+16),ntri_flat_uv:f(a,p+16+20),ntri_smooth_uv:f(a,p+
16+24),nquad_flat:f(a,p+16+28),nquad_smooth:f(a,p+16+32),nquad_flat_uv:f(a,p+16+36),nquad_smooth_uv:f(a,p+16+40)};p+=u.header_bytes;D=u.vertex_index_bytes;E=u.vertex_index_bytes*2;F=u.vertex_index_bytes*3;G=u.vertex_index_bytes*3+u.material_index_bytes;I=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes;C=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes*2;K=u.vertex_index_bytes;M=u.vertex_index_bytes*2;L=u.vertex_index_bytes*3;H=u.vertex_index_bytes*4;N=u.vertex_index_bytes*
4+u.material_index_bytes;O=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes;A=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*2;P=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*3;J=u.uv_index_bytes;Q=u.uv_index_bytes*2;R=u.uv_index_bytes;T=u.uv_index_bytes*2;Z=u.uv_index_bytes*3;c=u.vertex_index_bytes*3+u.material_index_bytes;S=u.vertex_index_bytes*4+u.material_index_bytes;U=u.ntri_flat*c;V=u.ntri_smooth*(c+u.normal_index_bytes*3);W=u.ntri_flat_uv*
(c+u.uv_index_bytes*3);X=u.ntri_smooth_uv*(c+u.normal_index_bytes*3+u.uv_index_bytes*3);Y=u.nquad_flat*S;c=u.nquad_smooth*(S+u.normal_index_bytes*4);S=u.nquad_flat_uv*(S+u.uv_index_bytes*4);p+=function(c){for(var e,f,g,j=u.vertex_coordinate_bytes*3,k=c+u.nvertices*j;c<k;c+=j)e=b(a,c),f=b(a,c+u.vertex_coordinate_bytes),g=b(a,c+u.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(x,e,f,g);return u.nvertices*j}(p);p+=function(c){for(var b,e,f,g=u.normal_coordinate_bytes*3,h=c+u.nnormals*g;c<h;c+=
g)b=m(a,c),e=m(a,c+u.normal_coordinate_bytes),f=m(a,c+u.normal_coordinate_bytes*2),B.push(b/127,e/127,f/127);return u.nnormals*g}(p);p+=function(c){for(var e,f,g=u.uv_coordinate_bytes*2,j=c+u.nuvs*g;c<j;c+=g)e=b(a,c),f=b(a,c+u.uv_coordinate_bytes),y.push(e,f);return u.nuvs*g}(p);U=p+U;V=U+V;W=V+W;X=W+X;Y=X+Y;c=Y+c;S=c+S;(function(a){var c,b=u.vertex_index_bytes*3+u.material_index_bytes,e=b+u.uv_index_bytes*3,f=a+u.ntri_flat_uv*e;for(c=a;c<f;c+=e)n(c),v(c+b);return f-a})(V);(function(a){var c,b=u.vertex_index_bytes*
3+u.material_index_bytes+u.normal_index_bytes*3,e=b+u.uv_index_bytes*3,f=a+u.ntri_smooth_uv*e;for(c=a;c<f;c+=e)t(c),v(c+b);return f-a})(W);(function(a){var c,b=u.vertex_index_bytes*4+u.material_index_bytes,e=b+u.uv_index_bytes*4,f=a+u.nquad_flat_uv*e;for(c=a;c<f;c+=e)o(c),z(c+b);return f-a})(c);(function(a){var c,b=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*4,e=b+u.uv_index_bytes*4,f=a+u.nquad_smooth_uv*e;for(c=a;c<f;c+=e)w(c),z(c+b);return f-a})(S);(function(a){var c,b=u.vertex_index_bytes*
3+u.material_index_bytes,e=a+u.ntri_flat*b;for(c=a;c<e;c+=b)n(c);return e-a})(p);(function(a){var c,b=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes*3,e=a+u.ntri_smooth*b;for(c=a;c<e;c+=b)t(c);return e-a})(U);(function(a){var c,b=u.vertex_index_bytes*4+u.material_index_bytes,e=a+u.nquad_flat*b;for(c=a;c<e;c+=b)o(c);return e-a})(X);(function(a){var c,b=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*4,e=a+u.nquad_smooth*b;for(c=a;c<e;c+=b)w(c);return e-a})(Y);
this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))},f3:function(a,b,c,e,f){a.faces.push(new THREE.Face3(b,c,e,null,null,a.materials[f]))},f4:function(a,b,c,e,f,g){a.faces.push(new THREE.Face4(b,c,e,f,null,null,a.materials[g]))},f3n:function(a,b,c,e,f,g,h,k,j){var g=a.materials[g],m=b[k*3],l=b[k*3+1],k=b[k*3+2],n=b[j*3],t=b[j*3+1],j=b[j*3+2];a.faces.push(new THREE.Face3(c,
e,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,l,k),new THREE.Vector3(n,t,j)],null,g))},f4n:function(a,b,c,e,f,g,h,k,j,m,l){var h=a.materials[h],n=b[j*3],t=b[j*3+1],j=b[j*3+2],o=b[m*3],w=b[m*3+1],m=b[m*3+2],v=b[l*3],z=b[l*3+1],l=b[l*3+2];a.faces.push(new THREE.Face4(c,e,f,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(n,t,j),new THREE.Vector3(o,w,m),new THREE.Vector3(v,z,l)],null,h))},uv3:function(a,b,c,e,f,g,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(e,
c){return a.charCodeAt(c)&255}function n(c){var b,e,g;b=f(a,c);e=f(a,c+E);g=f(a,c+F);c=j(a,c+G);THREE.BinaryLoader.prototype.f3(x,b,e,g,c)}function p(c){var b,e,g,h,m,l;b=f(a,c);e=f(a,c+E);g=f(a,c+F);h=j(a,c+G);m=f(a,c+D);l=f(a,c+K);c=f(a,c+I);THREE.BinaryLoader.prototype.f3n(x,z,b,e,g,h,m,l,c)}function o(c){var b,e,g,h;b=f(a,c);e=f(a,c+C);g=f(a,c+J);h=f(a,c+L);c=j(a,c+H);THREE.BinaryLoader.prototype.f4(x,b,e,g,h,c)}function v(c){var b,e,g,h,m,l,n,o;b=f(a,c);e=f(a,c+C);g=f(a,c+J);h=f(a,c+L);m=j(a,
c+H);l=f(a,c+N);n=f(a,c+O);o=f(a,c+A);c=f(a,c+P);THREE.BinaryLoader.prototype.f4n(x,z,b,e,g,h,m,l,n,o,c)}function u(c){var b,e;b=f(a,c);e=f(a,c+M);c=f(a,c+R);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],B[b*2],B[b*2+1],B[e*2],B[e*2+1],B[c*2],B[c*2+1])}function w(c){var b,e,g;b=f(a,c);e=f(a,c+S);g=f(a,c+Y);c=f(a,c+Z);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],B[b*2],B[b*2+1],B[e*2],B[e*2+1],B[g*2],B[g*2+1],B[c*2],B[c*2+1])}var x=this,y=0,t,z=[],B=[],E,F,G,D,K,I,C,J,L,H,N,O,A,P,M,R,
S,Y,Z,T,U,V,W,X,Q;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,e,c);t={signature:a.substr(y,8),header_bytes:l(a,y+8),vertex_coordinate_bytes:l(a,y+9),normal_coordinate_bytes:l(a,y+10),uv_coordinate_bytes:l(a,y+11),vertex_index_bytes:l(a,y+12),normal_index_bytes:l(a,y+13),uv_index_bytes:l(a,y+14),material_index_bytes:l(a,y+15),nvertices:f(a,y+16),nnormals:f(a,y+16+4),nuvs:f(a,y+16+8),ntri_flat:f(a,y+16+12),ntri_smooth:f(a,y+16+16),ntri_flat_uv:f(a,y+16+20),ntri_smooth_uv:f(a,y+
16+24),nquad_flat:f(a,y+16+28),nquad_smooth:f(a,y+16+32),nquad_flat_uv:f(a,y+16+36),nquad_smooth_uv:f(a,y+16+40)};y+=t.header_bytes;E=t.vertex_index_bytes;F=t.vertex_index_bytes*2;G=t.vertex_index_bytes*3;D=t.vertex_index_bytes*3+t.material_index_bytes;K=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;I=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;C=t.vertex_index_bytes;J=t.vertex_index_bytes*2;L=t.vertex_index_bytes*3;H=t.vertex_index_bytes*4;N=t.vertex_index_bytes*
4+t.material_index_bytes;O=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes;A=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*2;P=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;M=t.uv_index_bytes;R=t.uv_index_bytes*2;S=t.uv_index_bytes;Y=t.uv_index_bytes*2;Z=t.uv_index_bytes*3;c=t.vertex_index_bytes*3+t.material_index_bytes;Q=t.vertex_index_bytes*4+t.material_index_bytes;T=t.ntri_flat*c;U=t.ntri_smooth*(c+t.normal_index_bytes*3);V=t.ntri_flat_uv*
(c+t.uv_index_bytes*3);W=t.ntri_smooth_uv*(c+t.normal_index_bytes*3+t.uv_index_bytes*3);X=t.nquad_flat*Q;c=t.nquad_smooth*(Q+t.normal_index_bytes*4);Q=t.nquad_flat_uv*(Q+t.uv_index_bytes*4);y+=function(c){for(var e,f,g,j=t.vertex_coordinate_bytes*3,k=c+t.nvertices*j;c<k;c+=j)e=b(a,c),f=b(a,c+t.vertex_coordinate_bytes),g=b(a,c+t.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(x,e,f,g);return t.nvertices*j}(y);y+=function(c){for(var b,e,f,g=t.normal_coordinate_bytes*3,h=c+t.nnormals*g;c<h;c+=
g)b=m(a,c),e=m(a,c+t.normal_coordinate_bytes),f=m(a,c+t.normal_coordinate_bytes*2),z.push(b/127,e/127,f/127);return t.nnormals*g}(y);y+=function(c){for(var e,f,g=t.uv_coordinate_bytes*2,j=c+t.nuvs*g;c<j;c+=g)e=b(a,c),f=b(a,c+t.uv_coordinate_bytes),B.push(e,f);return t.nuvs*g}(y);T=y+T;U=T+U;V=U+V;W=V+W;X=W+X;c=X+c;Q=c+Q;(function(a){var c,b=t.vertex_index_bytes*3+t.material_index_bytes,e=b+t.uv_index_bytes*3,f=a+t.ntri_flat_uv*e;for(c=a;c<f;c+=e)n(c),u(c+b);return f-a})(U);(function(a){var c,b=t.vertex_index_bytes*
3+t.material_index_bytes+t.normal_index_bytes*3,e=b+t.uv_index_bytes*3,f=a+t.ntri_smooth_uv*e;for(c=a;c<f;c+=e)p(c),u(c+b);return f-a})(V);(function(a){var c,b=t.vertex_index_bytes*4+t.material_index_bytes,e=b+t.uv_index_bytes*4,f=a+t.nquad_flat_uv*e;for(c=a;c<f;c+=e)o(c),w(c+b);return f-a})(c);(function(a){var c,b=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,e=b+t.uv_index_bytes*4,f=a+t.nquad_smooth_uv*e;for(c=a;c<f;c+=e)v(c),w(c+b);return f-a})(Q);(function(a){var c,b=t.vertex_index_bytes*
3+t.material_index_bytes,e=a+t.ntri_flat*b;for(c=a;c<e;c+=b)n(c);return e-a})(y);(function(a){var c,b=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,e=a+t.ntri_smooth*b;for(c=a;c<e;c+=b)p(c);return e-a})(T);(function(a){var c,b=t.vertex_index_bytes*4+t.material_index_bytes,e=a+t.nquad_flat*b;for(c=a;c<e;c+=b)o(c);return e-a})(W);(function(a){var c,b=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,e=a+t.nquad_smooth*b;for(c=a;c<e;c+=b)v(c);return e-a})(X);
this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))},v:function(a,b,c,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))},f3:function(a,b,c,e,f){a.faces.push(new THREE.Face3(b,c,e,null,null,a.materials[f]))},f4:function(a,b,c,e,f,g){a.faces.push(new THREE.Face4(b,c,e,f,null,null,a.materials[g]))},f3n:function(a,b,c,e,f,g,h,k,j){var g=a.materials[g],m=b[k*3],l=b[k*3+1],k=b[k*3+2],n=b[j*3],p=b[j*3+1],j=b[j*3+2];a.faces.push(new THREE.Face3(c,
e,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,l,k),new THREE.Vector3(n,p,j)],null,g))},f4n:function(a,b,c,e,f,g,h,k,j,m,l){var h=a.materials[h],n=b[j*3],p=b[j*3+1],j=b[j*3+2],o=b[m*3],v=b[m*3+1],m=b[m*3+2],u=b[l*3],w=b[l*3+1],l=b[l*3+2];a.faces.push(new THREE.Face4(c,e,f,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(n,p,j),new THREE.Vector3(o,v,m),new THREE.Vector3(u,w,l)],null,h))},uv3:function(a,b,c,e,f,g,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(e,
f));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,b,c,e,f,g,h,k,j){var m=[];m.push(new THREE.UV(b,c));m.push(new THREE.UV(e,f));m.push(new THREE.UV(g,h));m.push(new THREE.UV(k,j));a.push(m)}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
THREE.SceneLoader.prototype={load:function(a,b){var c=this,e=new Worker(a);e.postMessage(0);var f=THREE.Loader.prototype.extractUrlbase(a);e.onmessage=function(a){function e(a,c){return c=="relativeToHTML"?a:f+"/"+a}function k(){for(o in C.objects)if(!A.objects[o])if(u=C.objects[o],u.geometry!==void 0){if(E=A.geometries[u.geometry]){var a=!1;I=[];for(J=0;J<u.materials.length;J++)I[J]=A.materials[u.materials[J]],a=I[J]instanceof THREE.MeshShaderMaterial;a&&E.computeTangents();B=u.position;r=u.rotation;
q=u.quaternion;s=u.scale;q=0;I.length==0&&(I[0]=new THREE.MeshFaceMaterial);I.length>1&&(I=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(E,I);object.name=o;object.position.set(B[0],B[1],B[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=u.visible;A.scene.addObject(object);A.objects[o]=object;u.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),A.scene.collisions.colliders.push(a));
if(u.castsShadow)a=new THREE.ShadowVolume(E),A.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;u.trigger&&u.trigger.toLowerCase()!="none"&&(a={type:u.trigger,object:u},A.triggers[object.name]=a)}}else B=u.position,r=u.rotation,q=u.quaternion,s=u.scale,q=0,object=new THREE.Object3D,object.name=o,object.position.set(B[0],B[1],B[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],
s[1],s[2]),object.visible=u.visible!==void 0?u.visible:!1,A.scene.addObject(object),A.objects[o]=object,A.empties[o]=object,u.trigger&&u.trigger.toLowerCase()!="none"&&(a={type:u.trigger,object:u},A.triggers[object.name]=a)}function j(a){return function(b){A.geometries[a]=b;k();L-=1;c.onLoadComplete();l()}}function m(a){return function(c){A.geometries[a]=c}}function l(){c.callbackProgress({totalModels:N,totalTextures:O,loadedModels:N-L,loadedTextures:O-H},A);c.onLoadProgress();L==0&&H==0&&b(A)}var n,
t,o,w,v,z,x,p,u,B,y,D,E,F,G,I,C,K,M,L,H,N,O,A;C=a.data;K=new THREE.BinaryLoader;M=new THREE.JSONLoader;H=L=0;A={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(o in C.objects)if(u=C.objects[o],u.meshCollider){a=!0;break}if(a)A.scene.collisions=new THREE.CollisionSystem;if(C.transform){a=C.transform.position;y=C.transform.rotation;var P=C.transform.scale;a&&A.scene.position.set(a[0],a[1],a[2]);y&&A.scene.rotation.set(y[0],
y[1],y[2]);P&&A.scene.scale.set(P[0],P[1],P[2]);(a||y||P)&&A.scene.updateMatrix()}a=function(){H-=1;l();c.onLoadComplete()};for(v in C.cameras){y=C.cameras[v];if(y.type=="perspective")F=new THREE.Camera(y.fov,y.aspect,y.near,y.far);else if(y.type=="ortho")F=new THREE.Camera,F.projectionMatrix=THREE.Matrix4.makeOrtho(y.left,y.right,y.top,y.bottom,y.near,y.far);B=y.position;y=y.target;F.position.set(B[0],B[1],B[2]);F.target.position.set(y[0],y[1],y[2]);A.cameras[v]=F}for(w in C.lights){v=C.lights[w];
F=v.color!==void 0?v.color:16777215;y=v.intensity!==void 0?v.intensity:1;if(v.type=="directional")B=v.direction,p=new THREE.DirectionalLight(F,y),p.position.set(B[0],B[1],B[2]),p.position.normalize();else if(v.type=="point")B=v.position,d=v.distance,p=new THREE.PointLight(F,y,d),p.position.set(B[0],B[1],B[2]);A.scene.addLight(p);A.lights[w]=p}for(z in C.fogs)p=C.fogs[z],p.type=="linear"?G=new THREE.Fog(0,p.near,p.far):p.type=="exp2"&&(G=new THREE.FogExp2(0,p.density)),y=p.color,G.color.setRGB(y[0],
y[1],y[2]),A.fogs[z]=G;if(A.cameras&&C.defaults.camera)A.currentCamera=A.cameras[C.defaults.camera];if(A.fogs&&C.defaults.fog)A.scene.fog=A.fogs[C.defaults.fog];y=C.defaults.bgcolor;A.bgColor=new THREE.Color;A.bgColor.setRGB(y[0],y[1],y[2]);A.bgColorAlpha=C.defaults.bgalpha;for(n in C.geometries)if(p=C.geometries[n],p.type=="bin_mesh"||p.type=="ascii_mesh")L+=1,c.onLoadStart();N=L;for(n in C.geometries)p=C.geometries[n],p.type=="cube"?(E=new THREE.CubeGeometry(p.width,p.height,p.depth,p.segmentsWidth,
p.segmentsHeight,p.segmentsDepth,null,p.flipped,p.sides),A.geometries[n]=E):p.type=="plane"?(E=new THREE.PlaneGeometry(p.width,p.height,p.segmentsWidth,p.segmentsHeight),A.geometries[n]=E):p.type=="sphere"?(E=new THREE.SphereGeometry(p.radius,p.segmentsWidth,p.segmentsHeight),A.geometries[n]=E):p.type=="cylinder"?(E=new THREE.CylinderGeometry(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset),A.geometries[n]=E):p.type=="torus"?(E=new THREE.TorusGeometry(p.radius,p.tube,p.segmentsR,p.segmentsT),
A.geometries[n]=E):p.type=="icosahedron"?(E=new THREE.IcosahedronGeometry(p.subdivisions),A.geometries[n]=E):p.type=="bin_mesh"?K.load({model:e(p.url,C.urlBaseType),callback:j(n)}):p.type=="ascii_mesh"?M.load({model:e(p.url,C.urlBaseType),callback:j(n)}):p.type=="embedded_mesh"&&(p=C.embeds[p.id])&&M.createModel(p,m(n),"");for(x in C.textures)if(p=C.textures[x],p.url instanceof Array){H+=p.url.length;for(n=0;n<p.url.length;n++)c.onLoadStart()}else H+=1,c.onLoadStart();O=H;for(x in C.textures){p=C.textures[x];
if(p.mapping!=void 0&&THREE[p.mapping]!=void 0)p.mapping=new THREE[p.mapping];if(p.url instanceof Array){n=[];for(var J=0;J<p.url.length;J++)n[J]=e(p.url[J],C.urlBaseType);n=THREE.ImageUtils.loadTextureCube(n,p.mapping,a)}else{n=THREE.ImageUtils.loadTexture(e(p.url,C.urlBaseType),p.mapping,a);if(THREE[p.minFilter]!=void 0)n.minFilter=THREE[p.minFilter];if(THREE[p.magFilter]!=void 0)n.magFilter=THREE[p.magFilter];if(p.repeat){n.repeat.set(p.repeat[0],p.repeat[1]);if(p.repeat[0]!=1)n.wrapS=THREE.RepeatWrapping;
if(p.repeat[1]!=1)n.wrapT=THREE.RepeatWrapping}p.offset&&n.offset.set(p.offset[0],p.offset[1]);if(p.wrap){K={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(K[p.wrap[0]]!==void 0)n.wrapS=K[p.wrap[0]];if(K[p.wrap[1]]!==void 0)n.wrapT=K[p.wrap[1]]}}A.textures[x]=n}for(t in C.materials){x=C.materials[t];for(D in x.parameters)if(D=="envMap"||D=="map"||D=="lightMap")x.parameters[D]=A.textures[x.parameters[D]];else if(D=="shading")x.parameters[D]=x.parameters[D]=="flat"?THREE.FlatShading:
THREE.SmoothShading;else if(D=="blending")x.parameters[D]=THREE[x.parameters[D]]?THREE[x.parameters[D]]:THREE.NormalBlending;else if(D=="combine")x.parameters[D]=x.parameters[D]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(D=="vertexColors")if(x.parameters[D]=="face")x.parameters[D]=THREE.FaceColors;else if(x.parameters[D])x.parameters[D]=THREE.VertexColors;if(x.parameters.opacity!==void 0&&x.parameters.opacity<1)x.parameters.transparent=!0;if(x.parameters.normalMap){n=THREE.ShaderUtils.lib.normal;
a=THREE.UniformsUtils.clone(n.uniforms);K=x.parameters.color;M=x.parameters.specular;z=x.parameters.ambient;G=x.parameters.shininess;for(var Q,R,T,J=0;J<A.scene.lights.length;J++)p=A.scene.lights[J],!T&&p instanceof THREE.AmbientLight?T=p:!Q&&p instanceof THREE.PointLight?Q=p:!R&&p instanceof THREE.DirectionalLight&&(R=p);a.tNormal.texture=A.textures[x.parameters.normalMap];if(x.parameters.normalMapFactor)a.uNormalScale.value=x.parameters.normalMapFactor;if(x.parameters.map)a.tDiffuse.texture=x.parameters.map,
a.enableDiffuse.value=!0;a.enableAO.value=!1;a.enableSpecular.value=!1;if(Q)a.uPointLightPos.value=Q.position,a.uPointLightColor.value=Q.color;if(R)a.uDirLightPos.value=R.position,a.uDirLightColor.value=R.color;if(T)a.uAmbientLightColor.value=T.color;a.uDiffuseColor.value.setHex(K);a.uSpecularColor.value.setHex(M);a.uAmbientColor.value.setHex(z);a.uShininess.value=G;x=new THREE.MeshShaderMaterial({fragmentShader:n.fragmentShader,vertexShader:n.vertexShader,uniforms:a})}else x=new THREE[x.type](x.parameters);
A.materials[t]=x}k();c.callbackSync(A)}}};
THREE.SceneLoader.prototype={load:function(a,b){var c=this,e=new Worker(a);e.postMessage(0);var f=THREE.Loader.prototype.extractUrlbase(a);e.onmessage=function(a){function e(a,c){return c=="relativeToHTML"?a:f+"/"+a}function k(){for(o in C.objects)if(!A.objects[o])if(y=C.objects[o],y.geometry!==void 0){if(E=A.geometries[y.geometry]){var a=!1;K=[];for(M=0;M<y.materials.length;M++)K[M]=A.materials[y.materials[M]],a=K[M]instanceof THREE.MeshShaderMaterial;a&&E.computeTangents();t=y.position;r=y.rotation;
q=y.quaternion;s=y.scale;q=0;K.length==0&&(K[0]=new THREE.MeshFaceMaterial);K.length>1&&(K=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(E,K);object.name=o;object.position.set(t[0],t[1],t[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=y.visible;A.scene.addObject(object);A.objects[o]=object;y.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),A.scene.collisions.colliders.push(a));
if(y.castsShadow)a=new THREE.ShadowVolume(E),A.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},A.triggers[object.name]=a)}}else t=y.position,r=y.rotation,q=y.quaternion,s=y.scale,q=0,object=new THREE.Object3D,object.name=o,object.position.set(t[0],t[1],t[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],
s[1],s[2]),object.visible=y.visible!==void 0?y.visible:!1,A.scene.addObject(object),A.objects[o]=object,A.empties[o]=object,y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},A.triggers[object.name]=a)}function j(a){return function(b){A.geometries[a]=b;k();L-=1;c.onLoadComplete();l()}}function m(a){return function(c){A.geometries[a]=c}}function l(){c.callbackProgress({totalModels:N,totalTextures:O,loadedModels:N-L,loadedTextures:O-H},A);c.onLoadProgress();L==0&&H==0&&b(A)}var n,
p,o,v,u,w,x,y,t,z,B,E,F,G,D,K,I,C,J,L,H,N,O,A;C=a.data;D=new THREE.BinaryLoader;J=new THREE.JSONLoader;H=L=0;A={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(o in C.objects)if(y=C.objects[o],y.meshCollider){a=!0;break}if(a)A.scene.collisions=new THREE.CollisionSystem;if(C.transform){a=C.transform.position;z=C.transform.rotation;var P=C.transform.scale;a&&A.scene.position.set(a[0],a[1],a[2]);z&&A.scene.rotation.set(z[0],
z[1],z[2]);P&&A.scene.scale.set(P[0],P[1],P[2]);(a||z||P)&&A.scene.updateMatrix()}a=function(){H-=1;l();c.onLoadComplete()};for(u in C.cameras){z=C.cameras[u];if(z.type=="perspective")F=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho")F=new THREE.Camera,F.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far);t=z.position;z=z.target;F.position.set(t[0],t[1],t[2]);F.target.position.set(z[0],z[1],z[2]);A.cameras[u]=F}for(v in C.lights)u=C.lights[v],
F=u.color!==void 0?u.color:16777215,z=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(t=u.direction,I=new THREE.DirectionalLight(F,z),I.position.set(t[0],t[1],t[2]),I.position.normalize()):u.type=="point"?(t=u.position,d=u.distance,I=new THREE.PointLight(F,z,d),I.position.set(t[0],t[1],t[2])):u.type=="ambient"&&(I=new THREE.AmbientLight(F)),A.scene.addLight(I),A.lights[v]=I;for(w in C.fogs)v=C.fogs[w],v.type=="linear"?G=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(G=new THREE.FogExp2(0,
v.density)),z=v.color,G.color.setRGB(z[0],z[1],z[2]),A.fogs[w]=G;if(A.cameras&&C.defaults.camera)A.currentCamera=A.cameras[C.defaults.camera];if(A.fogs&&C.defaults.fog)A.scene.fog=A.fogs[C.defaults.fog];z=C.defaults.bgcolor;A.bgColor=new THREE.Color;A.bgColor.setRGB(z[0],z[1],z[2]);A.bgColorAlpha=C.defaults.bgalpha;for(n in C.geometries)if(w=C.geometries[n],w.type=="bin_mesh"||w.type=="ascii_mesh")L+=1,c.onLoadStart();N=L;for(n in C.geometries)w=C.geometries[n],w.type=="cube"?(E=new THREE.CubeGeometry(w.width,
w.height,w.depth,w.segmentsWidth,w.segmentsHeight,w.segmentsDepth,null,w.flipped,w.sides),A.geometries[n]=E):w.type=="plane"?(E=new THREE.PlaneGeometry(w.width,w.height,w.segmentsWidth,w.segmentsHeight),A.geometries[n]=E):w.type=="sphere"?(E=new THREE.SphereGeometry(w.radius,w.segmentsWidth,w.segmentsHeight),A.geometries[n]=E):w.type=="cylinder"?(E=new THREE.CylinderGeometry(w.numSegs,w.topRad,w.botRad,w.height,w.topOffset,w.botOffset),A.geometries[n]=E):w.type=="torus"?(E=new THREE.TorusGeometry(w.radius,
w.tube,w.segmentsR,w.segmentsT),A.geometries[n]=E):w.type=="icosahedron"?(E=new THREE.IcosahedronGeometry(w.subdivisions),A.geometries[n]=E):w.type=="bin_mesh"?D.load({model:e(w.url,C.urlBaseType),callback:j(n)}):w.type=="ascii_mesh"?J.load({model:e(w.url,C.urlBaseType),callback:j(n)}):w.type=="embedded_mesh"&&(w=C.embeds[w.id])&&J.createModel(w,m(n),"");for(x in C.textures)if(n=C.textures[x],n.url instanceof Array){H+=n.url.length;for(D=0;D<n.url.length;D++)c.onLoadStart()}else H+=1,c.onLoadStart();
O=H;for(x in C.textures){n=C.textures[x];if(n.mapping!=void 0&&THREE[n.mapping]!=void 0)n.mapping=new THREE[n.mapping];if(n.url instanceof Array){D=[];for(var M=0;M<n.url.length;M++)D[M]=e(n.url[M],C.urlBaseType);D=THREE.ImageUtils.loadTextureCube(D,n.mapping,a)}else{D=THREE.ImageUtils.loadTexture(e(n.url,C.urlBaseType),n.mapping,a);if(THREE[n.minFilter]!=void 0)D.minFilter=THREE[n.minFilter];if(THREE[n.magFilter]!=void 0)D.magFilter=THREE[n.magFilter];if(n.repeat){D.repeat.set(n.repeat[0],n.repeat[1]);
if(n.repeat[0]!=1)D.wrapS=THREE.RepeatWrapping;if(n.repeat[1]!=1)D.wrapT=THREE.RepeatWrapping}n.offset&&D.offset.set(n.offset[0],n.offset[1]);if(n.wrap){J={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(J[n.wrap[0]]!==void 0)D.wrapS=J[n.wrap[0]];if(J[n.wrap[1]]!==void 0)D.wrapT=J[n.wrap[1]]}}A.textures[x]=D}for(p in C.materials){x=C.materials[p];for(B in x.parameters)if(B=="envMap"||B=="map"||B=="lightMap")x.parameters[B]=A.textures[x.parameters[B]];else if(B=="shading")x.parameters[B]=
x.parameters[B]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(B=="blending")x.parameters[B]=THREE[x.parameters[B]]?THREE[x.parameters[B]]:THREE.NormalBlending;else if(B=="combine")x.parameters[B]=x.parameters[B]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(B=="vertexColors")if(x.parameters[B]=="face")x.parameters[B]=THREE.FaceColors;else if(x.parameters[B])x.parameters[B]=THREE.VertexColors;if(x.parameters.opacity!==void 0&&x.parameters.opacity<1)x.parameters.transparent=
!0;if(x.parameters.normalMap){n=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(n.uniforms);D=x.parameters.color;J=x.parameters.specular;w=x.parameters.ambient;G=x.parameters.shininess;a.tNormal.texture=A.textures[x.parameters.normalMap];if(x.parameters.normalMapFactor)a.uNormalScale.value=x.parameters.normalMapFactor;if(x.parameters.map)a.tDiffuse.texture=x.parameters.map,a.enableDiffuse.value=!0;a.enableAO.value=!1;a.enableSpecular.value=!1;a.uDiffuseColor.value.setHex(D);a.uSpecularColor.value.setHex(J);
a.uAmbientColor.value.setHex(w);a.uShininess.value=G;if(x.parameters.opacity)a.uOpacity.value=x.parameters.opacity;x=new THREE.MeshShaderMaterial({fragmentShader:n.fragmentShader,vertexShader:n.vertexShader,uniforms:a,lights:!0})}else x=new THREE[x.type](x.parameters);A.materials[p]=x}k();c.callbackSync(A)}}};
THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];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=
0;this.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(a,b,f){return a+(b-a)*f};this.VIntX=function(a,b,f,g,h,k,j,m,l,n){h=(h-l)/(n-l);l=this.normal_cache;b[g]=k+h*this.delta;b[g+1]=j;b[g+2]=m;f[g]=this.lerp(l[a],l[a+3],h);f[g+1]=this.lerp(l[a+1],l[a+4],h);f[g+2]=this.lerp(l[a+2],l[a+5],h)};this.VIntY=function(a,b,f,g,h,k,j,m,l,n){h=(h-l)/(n-l);l=this.normal_cache;b[g]=k;b[g+1]=j+h*this.delta;b[g+
2]=m;b=a+this.yd*3;f[g]=this.lerp(l[a],l[b],h);f[g+1]=this.lerp(l[a+1],l[b+1],h);f[g+2]=this.lerp(l[a+2],l[b+2],h)};this.VIntZ=function(a,b,f,g,h,k,j,m,l,n){h=(h-l)/(n-l);l=this.normal_cache;b[g]=k;b[g+1]=j;b[g+2]=m+h*this.delta;b=a+this.zd*3;f[g]=this.lerp(l[a],l[b],h);f[g+1]=this.lerp(l[a+1],l[b+1],h);f[g+2]=this.lerp(l[a+2],l[b+2],h)};this.compNorm=function(a){var b=a*3;this.normal_cache[b]==0&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+
this.yd],this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,f,g,h,k){var j=g+1,m=g+this.yd,l=g+this.zd,n=j+this.yd,t=j+this.zd,o=g+this.yd+this.zd,w=j+this.yd+this.zd,v=0,z=this.field[g],x=this.field[j],p=this.field[m],u=this.field[n],B=this.field[l],y=this.field[t],D=this.field[o],E=this.field[w];z<h&&(v|=1);x<h&&(v|=2);p<h&&(v|=8);u<h&&(v|=4);B<h&&(v|=16);y<h&&(v|=32);D<h&&(v|=128);E<h&&(v|=64);var F=THREE.edgeTable[v];if(F==0)return 0;var G=this.delta,
I=a+G,C=b+G,G=f+G;F&1&&(this.compNorm(g),this.compNorm(j),this.VIntX(g*3,this.vlist,this.nlist,0,h,a,b,f,z,x));F&2&&(this.compNorm(j),this.compNorm(n),this.VIntY(j*3,this.vlist,this.nlist,3,h,I,b,f,x,u));F&4&&(this.compNorm(m),this.compNorm(n),this.VIntX(m*3,this.vlist,this.nlist,6,h,a,C,f,p,u));F&8&&(this.compNorm(g),this.compNorm(m),this.VIntY(g*3,this.vlist,this.nlist,9,h,a,b,f,z,p));F&16&&(this.compNorm(l),this.compNorm(t),this.VIntX(l*3,this.vlist,this.nlist,12,h,a,b,G,B,y));F&32&&(this.compNorm(t),
this.compNorm(w),this.VIntY(t*3,this.vlist,this.nlist,15,h,I,b,G,y,E));F&64&&(this.compNorm(o),this.compNorm(w),this.VIntX(o*3,this.vlist,this.nlist,18,h,a,C,G,D,E));F&128&&(this.compNorm(l),this.compNorm(o),this.VIntY(l*3,this.vlist,this.nlist,21,h,a,b,G,B,D));F&256&&(this.compNorm(g),this.compNorm(l),this.VIntZ(g*3,this.vlist,this.nlist,24,h,a,b,f,z,B));F&512&&(this.compNorm(j),this.compNorm(t),this.VIntZ(j*3,this.vlist,this.nlist,27,h,I,b,f,x,y));F&1024&&(this.compNorm(n),this.compNorm(w),this.VIntZ(n*
3,this.vlist,this.nlist,30,h,I,C,f,u,E));F&2048&&(this.compNorm(m),this.compNorm(o),this.VIntZ(m*3,this.vlist,this.nlist,33,h,a,C,f,p,D));v<<=4;for(h=g=0;THREE.triTable[v+h]!=-1;)a=v+h,b=a+1,f=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[f],k),h+=3,g++;return g};this.posnormtriv=function(a,b,f,g,h,k){var j=this.count*3;this.positionArray[j]=a[f];this.positionArray[j+1]=a[f+1];this.positionArray[j+2]=a[f+2];this.positionArray[j+3]=a[g];this.positionArray[j+
this.yd],this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,f,g,h,k){var j=g+1,m=g+this.yd,l=g+this.zd,n=j+this.yd,p=j+this.zd,o=g+this.yd+this.zd,v=j+this.yd+this.zd,u=0,w=this.field[g],x=this.field[j],y=this.field[m],t=this.field[n],z=this.field[l],B=this.field[p],E=this.field[o],F=this.field[v];w<h&&(u|=1);x<h&&(u|=2);y<h&&(u|=8);t<h&&(u|=4);z<h&&(u|=16);B<h&&(u|=32);E<h&&(u|=128);F<h&&(u|=64);var G=THREE.edgeTable[u];if(G==0)return 0;var D=this.delta,
K=a+D,I=b+D,D=f+D;G&1&&(this.compNorm(g),this.compNorm(j),this.VIntX(g*3,this.vlist,this.nlist,0,h,a,b,f,w,x));G&2&&(this.compNorm(j),this.compNorm(n),this.VIntY(j*3,this.vlist,this.nlist,3,h,K,b,f,x,t));G&4&&(this.compNorm(m),this.compNorm(n),this.VIntX(m*3,this.vlist,this.nlist,6,h,a,I,f,y,t));G&8&&(this.compNorm(g),this.compNorm(m),this.VIntY(g*3,this.vlist,this.nlist,9,h,a,b,f,w,y));G&16&&(this.compNorm(l),this.compNorm(p),this.VIntX(l*3,this.vlist,this.nlist,12,h,a,b,D,z,B));G&32&&(this.compNorm(p),
this.compNorm(v),this.VIntY(p*3,this.vlist,this.nlist,15,h,K,b,D,B,F));G&64&&(this.compNorm(o),this.compNorm(v),this.VIntX(o*3,this.vlist,this.nlist,18,h,a,I,D,E,F));G&128&&(this.compNorm(l),this.compNorm(o),this.VIntY(l*3,this.vlist,this.nlist,21,h,a,b,D,z,E));G&256&&(this.compNorm(g),this.compNorm(l),this.VIntZ(g*3,this.vlist,this.nlist,24,h,a,b,f,w,z));G&512&&(this.compNorm(j),this.compNorm(p),this.VIntZ(j*3,this.vlist,this.nlist,27,h,K,b,f,x,B));G&1024&&(this.compNorm(n),this.compNorm(v),this.VIntZ(n*
3,this.vlist,this.nlist,30,h,K,I,f,t,F));G&2048&&(this.compNorm(m),this.compNorm(o),this.VIntZ(m*3,this.vlist,this.nlist,33,h,a,I,f,y,E));u<<=4;for(h=g=0;THREE.triTable[u+h]!=-1;)a=u+h,b=a+1,f=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[f],k),h+=3,g++;return g};this.posnormtriv=function(a,b,f,g,h,k){var j=this.count*3;this.positionArray[j]=a[f];this.positionArray[j+1]=a[f+1];this.positionArray[j+2]=a[f+2];this.positionArray[j+3]=a[g];this.positionArray[j+
4]=a[g+1];this.positionArray[j+5]=a[g+2];this.positionArray[j+6]=a[h];this.positionArray[j+7]=a[h+1];this.positionArray[j+8]=a[h+2];this.normalArray[j]=b[f];this.normalArray[j+1]=b[f+1];this.normalArray[j+2]=b[f+2];this.normalArray[j+3]=b[g];this.normalArray[j+4]=b[g+1];this.normalArray[j+5]=b[g+2];this.normalArray[j+6]=b[h];this.normalArray[j+7]=b[h+1];this.normalArray[j+8]=b[h+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;
this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,f,g,h){var k=this.size*Math.sqrt(g/h),j=f*this.size,m=b*this.size,l=a*this.size,n=Math.floor(j-k);n<1&&(n=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var t=Math.floor(m-k);t<1&&(t=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var o=Math.floor(l-k);o<1&&(o=1);k=Math.floor(l+k);k>this.size-1&&(k=this.size-
1);for(var w,v,z,x,p,u;n<j;n++){l=this.size2*n;v=n/this.size-f;p=v*v;for(v=t;v<m;v++){z=l+this.size*v;w=v/this.size-b;u=w*w;for(w=o;w<k;w++)x=w/this.size-a,x=g/(1.0E-6+x*x+u+p)-h,x>0&&(this.field[z+w]+=x)}}};this.addPlaneX=function(a,b){var f,g,h,k,j,m=this.size,l=this.yd,n=this.zd,t=this.field,o=m*Math.sqrt(a/b);o>m&&(o=m);for(f=0;f<o;f++)if(g=f/m,g*=g,k=a/(1.0E-4+g)-b,k>0)for(g=0;g<m;g++){j=f+g*l;for(h=0;h<m;h++)t[n*h+j]+=k}};this.addPlaneY=function(a,b){var f,g,h,k,j,m,l=this.size,n=this.yd,t=
this.zd,o=this.field,w=l*Math.sqrt(a/b);w>l&&(w=l);for(g=0;g<w;g++)if(f=g/l,f*=f,k=a/(1.0E-4+f)-b,k>0){j=g*n;for(f=0;f<l;f++){m=j+f;for(h=0;h<l;h++)o[t*h+m]+=k}}};this.addPlaneZ=function(a,b){var f,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(a/b);dist>size&&(dist=size);for(h=0;h<dist;h++)if(f=h/size,f*=f,k=a/(1.0E-4+f)-b,k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(f=0;f<size;f++)field[m+f]+=k}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*
3]=0,this.field[a]=0};this.render=function(a){this.begin();var b,f,g,h,k,j,m,l,n,t=this.size-2;for(h=1;h<t;h++){n=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<t;g++){l=n+this.size*g;j=(g-this.halfsize)/this.halfsize;for(f=1;f<t;f++)k=(f-this.halfsize)/this.halfsize,b=l+f,this.polygonize(k,j,m,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,f=[];this.render(function(g){var h,k,j,m,l,n,t,o;for(h=0;h<g.count;h++)t=h*3,l=t+1,o=t+2,k=g.positionArray[t],
j=g.positionArray[l],m=g.positionArray[o],n=new THREE.Vector3(k,j,m),k=g.normalArray[t],j=g.normalArray[l],m=g.normalArray[o],t=new THREE.Vector3(k,j,m),t.normalize(),l=new THREE.Vertex(n),b.vertices.push(l),f.push(t);nfaces=g.count/3;for(h=0;h<nfaces;h++)t=(a+h)*3,l=t+1,o=t+2,n=f[t],k=f[l],j=f[o],t=new THREE.Face3(t,l,o,[n,k,j]),b.faces.push(t);a+=nfaces;g.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,f,g,h){var k=this.size*Math.sqrt(g/h),j=f*this.size,m=b*this.size,l=a*this.size,n=Math.floor(j-k);n<1&&(n=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var p=Math.floor(m-k);p<1&&(p=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var o=Math.floor(l-k);o<1&&(o=1);k=Math.floor(l+k);k>this.size-1&&(k=this.size-
1);for(var v,u,w,x,y,t;n<j;n++){l=this.size2*n;u=n/this.size-f;y=u*u;for(u=p;u<m;u++){w=l+this.size*u;v=u/this.size-b;t=v*v;for(v=o;v<k;v++)x=v/this.size-a,x=g/(1.0E-6+x*x+t+y)-h,x>0&&(this.field[w+v]+=x)}}};this.addPlaneX=function(a,b){var f,g,h,k,j,m=this.size,l=this.yd,n=this.zd,p=this.field,o=m*Math.sqrt(a/b);o>m&&(o=m);for(f=0;f<o;f++)if(g=f/m,g*=g,k=a/(1.0E-4+g)-b,k>0)for(g=0;g<m;g++){j=f+g*l;for(h=0;h<m;h++)p[n*h+j]+=k}};this.addPlaneY=function(a,b){var f,g,h,k,j,m,l=this.size,n=this.yd,p=
this.zd,o=this.field,v=l*Math.sqrt(a/b);v>l&&(v=l);for(g=0;g<v;g++)if(f=g/l,f*=f,k=a/(1.0E-4+f)-b,k>0){j=g*n;for(f=0;f<l;f++){m=j+f;for(h=0;h<l;h++)o[p*h+m]+=k}}};this.addPlaneZ=function(a,b){var f,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(a/b);dist>size&&(dist=size);for(h=0;h<dist;h++)if(f=h/size,f*=f,k=a/(1.0E-4+f)-b,k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(f=0;f<size;f++)field[m+f]+=k}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*
3]=0,this.field[a]=0};this.render=function(a){this.begin();var b,f,g,h,k,j,m,l,n,p=this.size-2;for(h=1;h<p;h++){n=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<p;g++){l=n+this.size*g;j=(g-this.halfsize)/this.halfsize;for(f=1;f<p;f++)k=(f-this.halfsize)/this.halfsize,b=l+f,this.polygonize(k,j,m,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,f=[];this.render(function(g){var h,k,j,m,l,n,p,o;for(h=0;h<g.count;h++)p=h*3,l=p+1,o=p+2,k=g.positionArray[p],
j=g.positionArray[l],m=g.positionArray[o],n=new THREE.Vector3(k,j,m),k=g.normalArray[p],j=g.normalArray[l],m=g.normalArray[o],p=new THREE.Vector3(k,j,m),p.normalize(),l=new THREE.Vertex(n),b.vertices.push(l),f.push(p);nfaces=g.count/3;for(h=0;h<nfaces;h++)p=(a+h)*3,l=p+1,o=p+2,n=f[p],k=f[l],j=f[o],p=new THREE.Face3(p,l,o,[n,k,j]),b.faces.push(p);a+=nfaces;g.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
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,
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,
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]);
......
......@@ -54,7 +54,6 @@
</div>
<script type="text/javascript" src="../build/Three.js"></script>
<script type="text/javascript" src="js/Detector.js"></script>
<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
<script type="text/javascript" src="js/Stats.js"></script>
......@@ -89,8 +88,8 @@
function init() {
container = document.createElement('div');
document.body.appendChild(container);
container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 100000 );
camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, -10000, 10000 );
......@@ -141,22 +140,14 @@
uniforms[ "tDisplacement" ].texture = THREE.ImageUtils.loadTexture( "textures/normal/ninja/displacement.jpg" );
uniforms[ "uDisplacementBias" ].value = - 0.428408 * scale;
uniforms[ "uDisplacementScale" ].value = 2.436143 * scale;
uniforms[ "uPointLightPos" ].value = pointLight.position;
uniforms[ "uPointLightColor" ].value = pointLight.color;
uniforms[ "uDirLightPos" ].value = directionalLight.position;
uniforms[ "uDirLightColor" ].value = directionalLight.color;
uniforms[ "uAmbientLightColor" ].value = ambientLight.color;
uniforms[ "uDiffuseColor" ].value.setHex( diffuse );
uniforms[ "uSpecularColor" ].value.setHex( specular );
uniforms[ "uAmbientColor" ].value.setHex( ambient );
uniforms[ "uShininess" ].value = shininess;
var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms };
var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true };
var material1 = new THREE.MeshShaderMaterial( parameters );
var material2 = new THREE.MeshPhongMaterial( { color: diffuse, specular: specular, ambient: ambient, shininess: shininess } );
......
......@@ -84,8 +84,8 @@
function init() {
container = document.createElement('div');
document.body.appendChild(container);
container = document.createElement( 'div' );
document.body.appendChild( container );
camera = new THREE.Camera( 50, window.innerWidth / window.innerHeight, 1, 10000 );
camera.position.z = 900;
......@@ -125,21 +125,13 @@
uniforms[ "enableDiffuse" ].value = true;
uniforms[ "enableSpecular" ].value = false;
uniforms[ "uPointLightPos" ].value = pointLight.position;
uniforms[ "uPointLightColor" ].value = pointLight.color;
uniforms[ "uDirLightPos" ].value = directionalLight.position;
uniforms[ "uDirLightColor" ].value = directionalLight.color;
uniforms[ "uAmbientLightColor" ].value = ambientLight.color;
uniforms[ "uDiffuseColor" ].value.setHex( diffuse );
uniforms[ "uSpecularColor" ].value.setHex( specular );
uniforms[ "uAmbientColor" ].value.setHex( ambient );
uniforms[ "uShininess" ].value = shininess;
var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms };
var parameters = { fragmentShader: shader.fragmentShader, vertexShader: shader.vertexShader, uniforms: uniforms, lights: true };
var material = new THREE.MeshShaderMaterial( parameters );
loader = new THREE.JSONLoader( true );
......
......@@ -86,217 +86,11 @@ THREE.ShaderUtils = {
// Normal map shader
// - Blinn-Phong
// - normal + diffuse + specular + AO + displacement maps
// - 1 point and 1 directional lights
// - point and directional lights (use with "lights: true" material option)
------------------------------------------------------------------------- */
'normal' : {
uniforms: {
"enableAO" : { type: "i", value: 0 },
"enableDiffuse" : { type: "i", value: 0 },
"enableSpecular": { type: "i", value: 0 },
"tDiffuse" : { type: "t", value: 0, texture: null },
"tNormal" : { type: "t", value: 2, texture: null },
"tSpecular" : { type: "t", value: 3, texture: null },
"tAO" : { type: "t", value: 4, texture: null },
"uNormalScale": { type: "f", value: 1.0 },
"tDisplacement": { type: "t", value: 5, 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( 0xeeeeee ) },
"uDirLightPos": { type: "v3", value: new THREE.Vector3() },
"uDirLightColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
"uAmbientLightColor": { type: "c", value: new THREE.Color( 0x050505 ) },
"uDiffuseColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
"uSpecularColor": { type: "c", value: new THREE.Color( 0x111111 ) },
"uAmbientColor": { type: "c", value: new THREE.Color( 0x050505 ) },
"uShininess": { type: "f", value: 30 }
},
fragmentShader: [
"uniform vec3 uDirLightPos;",
"uniform vec3 uAmbientLightColor;",
"uniform vec3 uDirLightColor;",
"uniform vec3 uPointLightColor;",
"uniform vec3 uAmbientColor;",
"uniform vec3 uDiffuseColor;",
"uniform vec3 uSpecularColor;",
"uniform float uShininess;",
"uniform bool enableDiffuse;",
"uniform bool enableSpecular;",
"uniform bool enableAO;",
"uniform sampler2D tDiffuse;",
"uniform sampler2D tNormal;",
"uniform sampler2D tSpecular;",
"uniform sampler2D tAO;",
"uniform float uNormalScale;",
"varying vec3 vTangent;",
"varying vec3 vBinormal;",
"varying vec3 vNormal;",
"varying vec2 vUv;",
"varying vec3 vPointLightVector;",
"varying vec3 vViewPosition;",
"void main() {",
"vec3 diffuseTex = vec3( 1.0 );",
"vec3 aoTex = vec3( 1.0 );",
"vec3 specularTex = vec3( 1.0, 1.0, 1.0 );",
"vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;",
"normalTex.xy *= uNormalScale;",
"normalTex = normalize( normalTex );",
"if( enableDiffuse )",
"diffuseTex = texture2D( tDiffuse, vUv ).xyz;",
"if( enableAO )",
"aoTex = texture2D( tAO, vUv ).xyz;",
"if( enableSpecular )",
"specularTex = texture2D( tSpecular, vUv ).xyz;",
"mat3 tsb = mat3( vTangent, vBinormal, vNormal );",
"vec3 finalNormal = tsb * normalTex;",
"vec3 normal = normalize( finalNormal );",
"vec3 viewPosition = normalize( vViewPosition );",
// point light
"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );",
"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );",
"vec3 pointVector = normalize( vPointLightVector );",
"vec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );",
"float pointDotNormalHalf = dot( normal, pointHalfVector );",
"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
"float pointSpecularWeight = 0.0;",
"if ( pointDotNormalHalf >= 0.0 )",
"pointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );",
"pointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;",
"pointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight * pointDiffuseWeight;",
// directional light
"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );",
"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );",
"vec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );",
"vec3 dirVector = normalize( lDirection.xyz );",
"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );",
"float dirDotNormalHalf = dot( normal, dirHalfVector );",
"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
"float dirSpecularWeight = 0.0;",
"if ( dirDotNormalHalf >= 0.0 )",
"dirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );",
"dirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;",
"dirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight * dirDiffuseWeight;",
// all lights contribution summation
"vec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );",
"totalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );",
"totalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );",
"gl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );",
"}"
].join("\n"),
vertexShader: [
"attribute vec4 tangent;",
"uniform vec3 uPointLightPos;",
"#ifdef VERTEX_TEXTURES",
"uniform sampler2D tDisplacement;",
"uniform float uDisplacementScale;",
"uniform float uDisplacementBias;",
"#endif",
"varying vec3 vTangent;",
"varying vec3 vBinormal;",
"varying vec3 vNormal;",
"varying vec2 vUv;",
"varying vec3 vPointLightVector;",
"varying vec3 vViewPosition;",
"void main() {",
"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
"vViewPosition = cameraPosition - mPosition.xyz;",
"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
"vNormal = normalize( normalMatrix * normal );",
// tangent and binormal vectors
"vTangent = normalize( normalMatrix * tangent.xyz );",
"vBinormal = cross( vNormal, vTangent ) * tangent.w;",
"vBinormal = normalize( vBinormal );",
"vUv = uv;",
// point light
"vec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );",
"vPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );",
// displacement mapping
"#ifdef VERTEX_TEXTURES",
"vec3 dv = texture2D( tDisplacement, uv ).xyz;",
"float df = uDisplacementScale * dv.x + uDisplacementBias;",
"vec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;",
"gl_Position = projectionMatrix * displacedPosition;",
"#else",
"gl_Position = projectionMatrix * mvPosition;",
"#endif",
"}"
].join("\n")
},
'normal2' : {
uniforms: THREE.UniformsUtils.merge( [
THREE.UniformsLib[ "lights" ],
......@@ -551,7 +345,7 @@ THREE.ShaderUtils = {
].join("\n")
},
/* -------------------------------------------------------------------------
// Cube map shader
------------------------------------------------------------------------- */
......
......@@ -690,7 +690,7 @@ THREE.SceneLoader.prototype = {
if ( m.parameters.normalMap ) {
var shader = THREE.ShaderUtils.lib[ "normal2" ];
var shader = THREE.ShaderUtils.lib[ "normal" ];
var uniforms = THREE.UniformsUtils.clone( shader.uniforms );
var diffuse = m.parameters.color;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册