|
@@ -1,13 +1,13 @@
|
|
|
// ThreeExtras.js r41/ROME - http://github.com/mrdoob/three.js
|
|
|
-THREE.ColorUtils={adjustHSV:function(a,c,b,e){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,g);g.h=THREE.ColorUtils.clamp(g.h+c,0,1);g.s=THREE.ColorUtils.clamp(g.s+b,0,1);g.v=THREE.ColorUtils.clamp(g.v+e,0,1);a.setHSV(g.h,g.s,g.v)},rgbToHsv:function(a,c){var b=a.r,e=a.g,g=a.b,f=Math.max(Math.max(b,e),g),h=Math.min(Math.min(b,e),g);if(h==f)h=b=0;else{var j=f-h;h=j/f;b=b==f?(e-g)/j:e==f?2+(g-b)/j:4+(b-e)/j;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===undefined&&(c={h:0,s:0,v:0});c.h=b;c.s=h;c.v=f;return c},
|
|
|
-clamp:function(a,c,b){return a<c?c:a>b?b:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
|
|
|
-var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,e=a.vertices.length,g=b?c.geometry:c,f=a.vertices,h=g.vertices,j=a.faces,k=g.faces,m=a.faceVertexUvs[0];g=g.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var l=0,n=h.length;l<n;l++){var p=new THREE.Vertex(h[l].position.clone());b&&c.matrix.multiplyVector3(p.position);f.push(p)}l=0;for(n=k.length;l<n;l++){h=k[l];var o,w,D=h.vertexNormals;p=h.vertexColors;if(h instanceof THREE.Face3)o=new THREE.Face3(h.a+e,h.b+e,h.c+
|
|
|
-e);else 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);b=0;for(f=D.length;b<f;b++){w=D[b];o.vertexNormals.push(w.clone())}o.color.copy(h.color);b=0;for(f=p.length;b<f;b++){w=p[b];o.vertexColors.push(w.clone())}o.materials=h.materials.slice();o.centroid.copy(h.centroid);j.push(o)}l=0;for(n=g.length;l<n;l++){e=g[l];j=[];b=0;for(f=e.length;b<f;b++)j.push(new THREE.UV(e[b].u,e[b].v));m.push(j)}}};
|
|
|
-THREE.ImageUtils={loadTexture:function(a,c,b){var e=new Image,g=new THREE.Texture(e,c);e.onload=function(){g.needsUpdate=!0;b&&b(this)};e.src=a;return g},loadTextureCube:function(a,c,b){var e,g=[],f=new THREE.Texture(g,c);c=g.loadCount=0;for(e=a.length;c<e;++c){g[c]=new Image;g[c].onload=function(){g.loadCount+=1;if(g.loadCount==6)f.needsUpdate=!0;b&&b(this)};g[c].src=a[c]}return f}};
|
|
|
-THREE.SceneUtils={addMesh:function(a,c,b,e,g,f,h,j,k,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=e;c.position.y=g;c.position.z=f;c.rotation.x=h;c.rotation.y=j;c.rotation.z=k;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,b){var e=THREE.ShaderUtils.lib.cube;e.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:e.uniforms});c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);
|
|
|
-return c},addPanoramaCube:function(a,c,b){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,e,!0),
|
|
|
-new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var e=c/2;c=new THREE.Plane(c,c);var g=Math.PI,f=Math.PI/2;THREE.SceneUtils.addMesh(a,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));THREE.SceneUtils.addMesh(a,c,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));THREE.SceneUtils.addMesh(a,c,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));THREE.SceneUtils.addMesh(a,c,1,0,e,0,f,
|
|
|
-0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));THREE.SceneUtils.addMesh(a,c,1,0,-e,0,-f,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,c){THREE.SceneUtils.traverseHierarchy(a,function(b){b.visible=c})},traverseHierarchy:function(a,c){var b,e,g=a.children.length;for(e=0;e<g;e++){b=a.children[e];c(b);THREE.SceneUtils.traverseHierarchy(b,c)}}};
|
|
|
+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],p,u,v=h.vertexNormals,t=h.vertexColors;h instanceof THREE.Face3?p=new THREE.Face3(h.a+e,h.b+e,h.c+e):
|
|
|
+h instanceof THREE.Face4&&(p=new THREE.Face4(h.a+e,h.b+e,h.c+e,h.d+e));p.normal.copy(h.normal);c=0;for(g=v.length;c<g;c++)u=v[c],p.vertexNormals.push(u.clone());p.color.copy(h.color);c=0;for(g=t.length;c<g;c++)u=t[c],p.vertexColors.push(u.clone());p.materials=h.materials.slice();p.centroid.copy(h.centroid);k.push(p)}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.Cube(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),
|
|
|
+new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var e=b/2,b=new THREE.Plane(b,b),f=Math.PI,g=Math.PI/2;THREE.SceneUtils.addMesh(a,b,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));THREE.SceneUtils.addMesh(a,b,1,-e,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));THREE.SceneUtils.addMesh(a,b,1,e,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));THREE.SceneUtils.addMesh(a,b,1,0,e,0,g,0,f,
|
|
|
+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",
|
|
@@ -17,153 +17,161 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec
|
|
|
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}"},
|
|
|
screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
|
|
|
-fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,e,g,f=2*Math.ceil(a*3)+1;f>25&&(f=25);g=(f-1)*0.5;b=Array(f);for(c=e=0;c<f;++c){b[c]=Math.exp(-((c-g)*(c-g))/(2*a*a));e+=b[c]}for(c=0;c<f;++c)b[c]/=e;return b}};
|
|
|
-THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(g){for(var f=0;f<a.length;f++)a[f].update(g)};b.addToUpdate=function(g){a.indexOf(g)===-1&&a.push(g)};b.removeFromUpdate=function(g){g=a.indexOf(g);g!==-1&&a.splice(g,1)};b.add=function(g){c[g.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+g.name+" already exists in library. Overwriting.");c[g.name]=g;if(g.initialized!==!0){for(var f=0;f<g.hierarchy.length;f++){for(var h=0;h<g.hierarchy[f].keys.length;h++){if(g.hierarchy[f].keys[h].time<
|
|
|
-0)g.hierarchy[f].keys[h].time=0;if(g.hierarchy[f].keys[h].rot!==undefined&&!(g.hierarchy[f].keys[h].rot instanceof THREE.Quaternion)){var j=g.hierarchy[f].keys[h].rot;g.hierarchy[f].keys[h].rot=new THREE.Quaternion(j[0],j[1],j[2],j[3])}}if(g.hierarchy[f].keys[0].morphTargets!==undefined){j={};for(h=0;h<g.hierarchy[f].keys.length;h++)for(var k=0;k<g.hierarchy[f].keys[h].morphTargets.length;k++){var m=g.hierarchy[f].keys[h].morphTargets[k];j[m]=-1}g.hierarchy[f].usedMorphTargets=j;for(h=0;h<g.hierarchy[f].keys.length;h++){var l=
|
|
|
-{};for(m in j){for(k=0;k<g.hierarchy[f].keys[h].morphTargets.length;k++)if(g.hierarchy[f].keys[h].morphTargets[k]===m){l[m]=g.hierarchy[f].keys[h].morphTargetsInfluences[k];break}k===g.hierarchy[f].keys[h].morphTargets.length&&(l[m]=0)}g.hierarchy[f].keys[h].morphTargetsInfluences=l}}for(h=1;h<g.hierarchy[f].keys.length;h++)if(g.hierarchy[f].keys[h].time===g.hierarchy[f].keys[h-1].time){g.hierarchy[f].keys.splice(h,1);h--}for(h=1;h<g.hierarchy[f].keys.length;h++)g.hierarchy[f].keys[h].index=h}h=parseInt(g.length*
|
|
|
-g.fps,10);g.JIT={};g.JIT.hierarchy=[];for(f=0;f<g.hierarchy.length;f++)g.JIT.hierarchy.push(Array(h));g.initialized=!0}};b.get=function(g){if(typeof g==="string")if(c[g])return c[g];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+g);return null}};b.parse=function(g){var f=[];if(g instanceof THREE.SkinnedMesh)for(var h=0;h<g.bones.length;h++)f.push(g.bones[h]);else e(g,f);return f};var e=function(g,f){f.push(g);for(var h=0;h<g.children.length;h++)e(g.children[h],f)};b.LINEAR=
|
|
|
-0;b.CATMULLROM=1;b.CATMULLROM_FORWARD=2;return b}();THREE.Animation=function(a,c,b,e){this.root=a;this.data=THREE.AnimationHandler.get(c);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=b!==undefined?b:THREE.AnimationHandler.LINEAR;this.JITCompile=e!==undefined?e:!0;this.points=[];this.target=new THREE.Vector3};
|
|
|
-THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=c!==undefined?c:0;var b,e=this.hierarchy.length,g;for(b=0;b<e;b++){g=this.hierarchy[b];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)g.useQuaternion=!0;g.matrixAutoUpdate=!0;if(g.animationCache===undefined){g.animationCache={};g.animationCache.prevKey={pos:0,rot:0,scl:0};g.animationCache.nextKey={pos:0,rot:0,scl:0};g.animationCache.originalMatrix=
|
|
|
-g instanceof THREE.Bone?g.skinMatrix:g.matrix}var f=g.animationCache.prevKey;g=g.animationCache.nextKey;f.pos=this.data.hierarchy[b].keys[0];f.rot=this.data.hierarchy[b].keys[0];f.scl=this.data.hierarchy[b].keys[0];g.pos=this.getNextKeyWith("pos",b,1);g.rot=this.getNextKeyWith("rot",b,1);g.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
|
|
|
+fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,e,f,g=2*Math.ceil(a*3)+1;g>25&&(g=25);f=(g-1)*0.5;c=Array(g);for(b=e=0;b<g;++b)c[b]=Math.exp(-((b-f)*(b-f))/(2*a*a)),e+=c[b];for(b=0;b<g;++b)c[b]/=e;return c}};
|
|
|
+THREE.AnimationHandler=function(){var a=[],b={},c={update:function(c){for(var b=0;b<a.length;b++)a[b].update(c)},addToUpdate:function(c){a.indexOf(c)===-1&&a.push(c)},removeFromUpdate:function(c){c=a.indexOf(c);c!==-1&&a.splice(c,1)},add:function(a){b[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");b[a.name]=a;if(a.initialized!==!0){for(var c=0;c<a.hierarchy.length;c++){for(var e=0;e<a.hierarchy[c].keys.length;e++){if(a.hierarchy[c].keys[e].time<
|
|
|
+0)a.hierarchy[c].keys[e].time=0;if(a.hierarchy[c].keys[e].rot!==void 0&&!(a.hierarchy[c].keys[e].rot instanceof THREE.Quaternion)){var k=a.hierarchy[c].keys[e].rot;a.hierarchy[c].keys[e].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(a.hierarchy[c].keys[0].morphTargets!==void 0){k={};for(e=0;e<a.hierarchy[c].keys.length;e++)for(var j=0;j<a.hierarchy[c].keys[e].morphTargets.length;j++){var m=a.hierarchy[c].keys[e].morphTargets[j];k[m]=-1}a.hierarchy[c].usedMorphTargets=k;for(e=0;e<a.hierarchy[c].keys.length;e++){var l=
|
|
|
+{};for(m in k){for(j=0;j<a.hierarchy[c].keys[e].morphTargets.length;j++)if(a.hierarchy[c].keys[e].morphTargets[j]===m){l[m]=a.hierarchy[c].keys[e].morphTargetsInfluences[j];break}j===a.hierarchy[c].keys[e].morphTargets.length&&(l[m]=0)}a.hierarchy[c].keys[e].morphTargetsInfluences=l}}for(e=1;e<a.hierarchy[c].keys.length;e++)a.hierarchy[c].keys[e].time===a.hierarchy[c].keys[e-1].time&&(a.hierarchy[c].keys.splice(e,1),e--);for(e=1;e<a.hierarchy[c].keys.length;e++)a.hierarchy[c].keys[e].index=e}e=parseInt(a.length*
|
|
|
+a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(c=0;c<a.hierarchy.length;c++)a.JIT.hierarchy.push(Array(e));a.initialized=!0}},get:function(a){if(typeof a==="string")return b[a]?b[a]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+a),null)},parse:function(a){var c=[];if(a instanceof THREE.SkinnedMesh)for(var b=0;b<a.bones.length;b++)c.push(a.bones[b]);else e(a,c);return c}},e=function(a,c){c.push(a);for(var b=0;b<a.children.length;b++)e(a.children[b],c)};c.LINEAR=0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=
|
|
|
+2;return c}();THREE.Animation=function(a,b,c,e){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=c!==void 0?c:THREE.AnimationHandler.LINEAR;this.JITCompile=e!==void 0?e:!0;this.points=[];this.target=new THREE.Vector3};
|
|
|
+THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==void 0?a:!0;this.currentTime=b!==void 0?b:0;var c,e=this.hierarchy.length,f;for(c=0;c<e;c++){f=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)f.useQuaternion=!0;f.matrixAutoUpdate=!0;if(f.animationCache===void 0)f.animationCache={},f.animationCache.prevKey={pos:0,rot:0,scl:0},f.animationCache.nextKey={pos:0,rot:0,scl:0},f.animationCache.originalMatrix=f instanceof
|
|
|
+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.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
|
|
|
-THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,e,g,f,h,j,k,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,w=this.hierarchy.length;o<w;o++){a=this.hierarchy[o];k=a.animationCache;if(this.JITCompile&&l[o][m]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=l[o][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
|
|
|
-!1}else{a.matrix=l[o][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var D=0;D<3;D++){b=c[D];h=k.prevKey[b];j=k.nextKey[b];if(j.time<=p){if(n<p)if(this.loop){h=this.data.hierarchy[o].keys[0];for(j=this.getNextKeyWith(b,o,1);j.time<n;){h=j;j=this.getNextKeyWith(b,o,j.index+1)}}else{this.stop();return}else{do{h=j;j=this.getNextKeyWith(b,o,j.index+1)}while(j.time<
|
|
|
-n)}k.prevKey[b]=h;k.nextKey[b]=j}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(n-h.time)/(j.time-h.time);g=h[b];f=j[b];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(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=g[0]+(f[0]-g[0])*e;b.y=g[1]+(f[1]-g[1])*e;b.z=g[2]+(f[2]-g[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
|
|
|
-this.getPrevKeyWith("pos",o,h.index-1).pos;this.points[1]=g;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",o,j.index+1).pos;e=e*0.33+0.33;g=this.interpolateCatmullRom(this.points,e);b.x=g[0];b.y=g[1];b.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(b===
|
|
|
-"rot")THREE.Quaternion.slerp(g,f,a.quaternion,e);else if(b==="scl"){b=a.scale;b.x=g[0]+(f[0]-g[0])*e;b.y=g[1]+(f[1]-g[1])*e;b.z=g[2]+(f[2]-g[2])*e}}}}if(this.JITCompile&&l[0][m]===undefined){this.hierarchy[0].update(undefined,!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()}}};
|
|
|
-THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],e=[],g,f,h,j,k,m;g=(a.length-1)*c;f=Math.floor(g);g-=f;b[0]=f==0?f:f-1;b[1]=f;b[2]=f>a.length-2?f:f+1;b[3]=f>a.length-3?f:f+2;f=a[b[0]];j=a[b[1]];k=a[b[2]];m=a[b[3]];b=g*g;h=g*b;e[0]=this.interpolate(f[0],j[0],k[0],m[0],g,b,h);e[1]=this.interpolate(f[1],j[1],k[1],m[1],g,b,h);e[2]=this.interpolate(f[2],j[2],k[2],m[2],g,b,h);return e};
|
|
|
-THREE.Animation.prototype.interpolate=function(a,c,b,e,g,f,h){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*h+(-3*(c-b)-2*a-e)*f+a*g+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b<e.length-1?b:e.length-1;else b%=e.length;for(;b<e.length;b++)if(e[b][a]!==undefined)return e[b];return this.data.hierarchy[c].keys[0]};
|
|
|
-THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;for(b=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b>0?b:0:b>=0?b:b+e.length;b>=0;b--)if(e[b][a]!==undefined)return e[b];return this.data.hierarchy[c].keys[e.length-1]};
|
|
|
-THREE.QuakeCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=
|
|
|
-a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.activeLook!==undefined)this.activeLook=a.activeLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=
|
|
|
-a.heightMax;if(a.constrainVertical!==undefined)this.constrainVertical=a.constrainVertical;if(a.verticalMin!==undefined)this.verticalMin=a.verticalMin;if(a.verticalMax!==undefined)this.verticalMax=a.verticalMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.freeze=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=
|
|
|
-window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=
|
|
|
-function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/
|
|
|
-1E3;this.lastUpdate=b;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var e=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(e+this.autoSpeedFactor));this.moveBackward&&this.translateZ(e);this.moveLeft&&this.translateX(-e);this.moveRight&&this.translateX(e);e=this.tdiff*this.lookSpeed;
|
|
|
-this.activeLook||(e=0);this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=
|
|
|
-(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,
|
|
|
-this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
|
|
|
-THREE.QuakeCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};
|
|
|
-THREE.PathCamera=function(a){function c(m,l,n,p){var o={name:n,fps:0.6,length:p,hierarchy:[]},w,D=l.getControlPointsArray(),z=l.getLength(),v=D.length,A=0;w=v-1;l={parent:-1,keys:[]};l.keys[0]={time:0,pos:D[0],rot:[0,0,0,1],scl:[1,1,1]};l.keys[w]={time:p,pos:D[w],rot:[0,0,0,1],scl:[1,1,1]};for(w=1;w<v-1;w++){A=p*z.chunks[w]/z.total;l.keys[w]={time:A,pos:D[w]}}o.hierarchy[0]=l;THREE.AnimationHandler.add(o);return new THREE.Animation(m,n,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(m,l){var n,
|
|
|
-p,o=new THREE.Geometry;for(n=0;n<m.points.length*l;n++){p=n/(m.points.length*l);p=m.getPoint(p);o.vertices[n]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return o}function e(m,l){var n=b(l,10),p=b(l,10),o=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(n,o);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);m.addChild(lineObj);particleObj.scale.set(1,1,1);m.addChild(particleObj);p=new THREE.Sphere(1,
|
|
|
-16,8);o=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<l.points.length;i++){n=new THREE.Mesh(p,o);n.position.copy(l.points[i]);n.updateMatrix();m.addChild(n)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
|
|
|
-!0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
|
|
|
-if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
|
|
|
-this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,f=Math.PI/180;this.update=function(m,l,n){var p,o;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*f;this.theta=this.lon*f;p=this.phi%g;this.phi=p>=0?p:p+g;p=this.verticalAngleMap.srcRange;o=this.verticalAngleMap.dstRange;
|
|
|
-var w=o[1]-o[0];this.phi=TWEEN.Easing.Quadratic.EaseInOut(((this.phi-p[0])*(o[1]-o[0])/(p[1]-p[0])+o[0]-o[0])/w)*w+o[0];p=this.horizontalAngleMap.srcRange;o=this.horizontalAngleMap.dstRange;w=o[1]-o[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-p[0])*(o[1]-o[0])/(p[1]-p[0])+o[0]-o[0])/w)*w+o[0];p=this.target.position;p.x=100*Math.sin(this.phi)*Math.cos(this.theta);p.y=100*Math.cos(this.phi);p.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,m,l,n)};this.onMouseMove=
|
|
|
-function(m){this.mouseX=m.clientX-this.windowHalfX;this.mouseY=m.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),j=new THREE.Cube(10,10,20),k=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,h);a.position.set(0,10,
|
|
|
-0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(m,l){return function(){l.apply(m,arguments)}}(this,
|
|
|
-this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
|
|
|
-THREE.FlyCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==undefined)this.autoForward=
|
|
|
-a.autoForward;if(a.domElement!==undefined)this.domElement=a.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier=
|
|
|
+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 p=0,u=this.hierarchy.length;p<u;p++)if(a=this.hierarchy[p],j=a.animationCache,this.JITCompile&&l[p][m]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=l[p][m],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
|
|
|
+!1):(a.matrix=l[p][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[p].keys[0];for(k=this.getNextKeyWith(c,p,1);k.time<n;)h=k,k=this.getNextKeyWith(c,p,k.index+1)}else{this.stop();return}else{do h=k,k=this.getNextKeyWith(c,p,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 "+p),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",p,h.index-1).pos,this.points[1]=f,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",p,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(p=0;p<this.hierarchy.length;p++)l[p][m]=this.hierarchy[p]instanceof THREE.Bone?this.hierarchy[p].skinMatrix.clone():this.hierarchy[p].matrix.clone()}}};
|
|
|
+THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],e=[],f,g,h,k,j,m;f=(a.length-1)*b;g=Math.floor(f);f-=g;c[0]=g==0?g:g-1;c[1]=g;c[2]=g>a.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];k=a[c[1]];j=a[c[2]];m=a[c[3]];c=f*f;h=f*c;e[0]=this.interpolate(g[0],k[0],j[0],m[0],f,c,h);e[1]=this.interpolate(g[1],k[1],j[1],m[1],f,c,h);e[2]=this.interpolate(g[2],k[2],j[2],m[2],f,c,h);return e};
|
|
|
+THREE.Animation.prototype.interpolate=function(a,b,c,e,f,g,h){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*h+(-3*(b-c)-2*a-e)*g+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c<e.length-1?c:e.length-1:c%=e.length;c<e.length;c++)if(e[c][a]!==void 0)return e[c];return this.data.hierarchy[b].keys[0]};
|
|
|
+THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var e=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==void 0)return e[c];return this.data.hierarchy[b].keys[e.length-1]};
|
|
|
+THREE.QuakeCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=
|
|
|
+a.movementSpeed;if(a.lookSpeed!==void 0)this.lookSpeed=a.lookSpeed;if(a.noFly!==void 0)this.noFly=a.noFly;if(a.lookVertical!==void 0)this.lookVertical=a.lookVertical;if(a.autoForward!==void 0)this.autoForward=a.autoForward;if(a.activeLook!==void 0)this.activeLook=a.activeLook;if(a.heightSpeed!==void 0)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==void 0)this.heightCoef=a.heightCoef;if(a.heightMin!==void 0)this.heightMin=a.heightMin;if(a.heightMax!==void 0)this.heightMax=a.heightMax;if(a.constrainVertical!==
|
|
|
+void 0)this.constrainVertical=a.constrainVertical;if(a.verticalMin!==void 0)this.verticalMin=a.verticalMin;if(a.verticalMax!==void 0)this.verticalMax=a.verticalMax;if(a.domElement!==void 0)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(a){a.preventDefault();
|
|
|
+a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.mouseX=a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.onKeyDown=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=
|
|
|
+!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){var a=(new Date).getTime();this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;if(!this.freeze){this.autoSpeedFactor=
|
|
|
+this.heightSpeed?this.tdiff*((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var b=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.translateZ(b);this.moveLeft&&this.translateX(-b);this.moveRight&&this.translateX(b);b=this.tdiff*this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&&
|
|
|
+(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target.position,f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=
|
|
|
+(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;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,z=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++)z=e*k.chunks[f]/k.total,c.keys[f]={time:z,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.Sphere(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!==
|
|
|
+void 0)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==void 0)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==void 0)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==void 0)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==void 0)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==void 0)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==void 0)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=
|
|
|
+window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,g=Math.PI/180;this.update=function(a,c,b){var e,h;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*g;this.theta=this.lon*g;e=this.phi%f;this.phi=e>=0?e:e+f;e=this.verticalAngleMap.srcRange;h=this.verticalAngleMap.dstRange;var k=h[1]-h[0];this.phi=
|
|
|
+TWEEN.Easing.Quadratic.EaseInOut(((this.phi-e[0])*(h[1]-h[0])/(e[1]-e[0])+h[0]-h[0])/k)*k+h[0];e=this.horizontalAngleMap.srcRange;h=this.horizontalAngleMap.dstRange;k=h[1]-h[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-e[0])*(h[1]-h[0])/(e[1]-e[0])+h[0]-h[0])/k)*k+h[0];e=this.target.position;e.x=100*Math.sin(this.phi)*Math.cos(this.theta);e.y=100*Math.cos(this.phi);e.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,a,c,b)};this.onMouseMove=function(a){this.mouseX=
|
|
|
+a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),h=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.Cube(10,10,20),j=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(k,a);a=new THREE.Mesh(j,h);a.position.set(0,10,0);this.animation=b(this.animationParent,
|
|
|
+this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=b(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(a,c){return function(){c.apply(a,arguments)}}(this,this.onMouseMove),!1)};
|
|
|
+THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
|
|
|
+THREE.FlyCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==void 0)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==void 0)this.dragToLook=a.dragToLook;if(a.autoForward!==void 0)this.autoForward=
|
|
|
+a.autoForward;if(a.domElement!==void 0)this.domElement=a.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=
|
|
|
0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};
|
|
|
-this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;
|
|
|
-case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var e=this.getContainerDimensions(),g=e.size[0]/2,f=e.size[1]/2;this.moveState.yawLeft=-(b.clientX-e.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY-
|
|
|
-e.offset[1]-f)/f;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook){this.mouseStatus--;this.moveState.yawLeft=this.moveState.pitchDown=0}else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;b=this.tdiff*this.movementSpeed;var e=this.tdiff*
|
|
|
-this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVector.y*b);this.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*e,this.rotationVector.y*e,this.rotationVector.z*e,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var b=this.moveState.forward||
|
|
|
-this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=
|
|
|
-document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);window.addEventListener("keydown",c(this,this.keydown),!1);window.addEventListener("keyup",c(this,
|
|
|
+this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;
|
|
|
+case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),f=b.size[0]/2,g=b.size[1]/2;this.moveState.yawLeft=-(a.clientX-b.offset[0]-f)/f;this.moveState.pitchDown=(a.clientY-
|
|
|
+b.offset[1]-g)/g;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;var a=this.tdiff*this.movementSpeed,b=this.tdiff*
|
|
|
+this.rollSpeed;this.translateX(this.moveVector.x*a);this.translateY(this.moveVector.y*a);this.translateZ(this.moveVector.z*a);this.tmpQuaternion.set(this.rotationVector.x*b,this.rotationVector.y*b,this.rotationVector.z*b,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var a=this.moveState.forward||
|
|
|
+this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=
|
|
|
+document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",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,c,b,e){THREE.Camera.call(this,a,c,b,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.useTarget=!1;this.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Matrix4,k=!1,m=1,l=0,n=0,p=0,o=0,w=0,D=window.innerWidth/2,z=window.innerHeight/2;this.update=
|
|
|
-function(){var v=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=v;this.delta=(v-this.lastUpdate)/1E3;this.lastUpdate=v;if(this.mouseLook){v=this.delta*this.lookSpeed;this.rotateHorizontally(v*o);this.rotateVertically(v*w)}v=this.delta*this.movementSpeed;this.translateZ(v*(l>0||this.autoForward&&!(l<0)?1:l));this.translateX(v*n);this.translateY(v*p);k&&(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);f.set(0,1,0);g.cross(f,h).normalize();f.cross(h,g).normalize();this.matrix.n11=g.x;this.matrix.n12=f.x;this.matrix.n13=h.x;this.matrix.n21=g.y;this.matrix.n22=f.y;this.matrix.n23=h.y;this.matrix.n31=g.z;this.matrix.n32=f.z;this.matrix.n33=h.z;j.identity();j.n11=Math.cos(this.roll);j.n12=-Math.sin(this.roll);j.n21=Math.sin(this.roll);j.n22=Math.cos(this.roll);this.matrix.multiplySelf(j);
|
|
|
-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(v){this.position.x+=this.matrix.n11*v;this.position.y+=this.matrix.n21*v;this.position.z+=this.matrix.n31*v};this.translateY=function(v){this.position.x+=this.matrix.n12*v;this.position.y+=this.matrix.n22*v;this.position.z+=this.matrix.n32*v};this.translateZ=function(v){this.position.x-=this.matrix.n13*v;this.position.y-=
|
|
|
-this.matrix.n23*v;this.position.z-=this.matrix.n33*v};this.rotateHorizontally=function(v){g.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);g.multiplyScalar(v);this.forward.subSelf(g);this.forward.normalize()};this.rotateVertically=function(v){f.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);f.multiplyScalar(v);this.forward.addSelf(f);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(v){v.preventDefault()},!1);this.domElement.addEventListener("mousemove",
|
|
|
-function(v){o=(v.clientX-D)/window.innerWidth;w=(v.clientY-z)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(v){v.preventDefault();v.stopPropagation();switch(v.button){case 0:l=1;break;case 2:l=-1}},!1);this.domElement.addEventListener("mouseup",function(v){v.preventDefault();v.stopPropagation();switch(v.button){case 0:l=0;break;case 2:l=0}},!1);this.domElement.addEventListener("keydown",function(v){switch(v.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:k=!0;m=1;break;case 69:k=!0;m=-1;break;case 82:p=1;break;case 70:p=-1}},!1);this.domElement.addEventListener("keyup",function(v){switch(v.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:k=!1;break;case 69:k=!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=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,p=0,u=0,v=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*p),this.rotateVertically(a*u));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();
|
|
|
+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){p=(a.clientX-v)/window.innerWidth;u=(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: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;
|
|
|
THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
|
|
|
-THREE.Cube=function(a,c,b,e,g,f,h,j,k){function m(z,v,A,t,C,E,K,N){var L,J,G=e||1,O=g||1,R=C/2,T=E/2,S=l.vertices.length;if(z=="x"&&v=="y"||z=="y"&&v=="x")L="z";else if(z=="x"&&v=="z"||z=="z"&&v=="x"){L="y";O=f||1}else if(z=="z"&&v=="y"||z=="y"&&v=="z"){L="x";G=f||1}var U=G+1,H=O+1;C/=G;var Q=E/O;for(J=0;J<H;J++)for(E=0;E<U;E++){var V=new THREE.Vector3;V[z]=(E*C-R)*A;V[v]=(J*Q-T)*t;V[L]=K;l.vertices.push(new THREE.Vertex(V))}for(J=0;J<O;J++)for(E=0;E<G;E++){l.faces.push(new THREE.Face4(E+U*J+S,E+
|
|
|
-U*(J+1)+S,E+1+U*(J+1)+S,E+1+U*J+S,null,null,N));l.faceVertexUvs[0].push([new THREE.UV(E/G,J/O),new THREE.UV(E/G,(J+1)/O),new THREE.UV((E+1)/G,(J+1)/O),new THREE.UV((E+1)/G,J/O)])}}THREE.Geometry.call(this);var l=this,n=a/2,p=c/2,o=b/2;j=j?-1:1;if(h!==undefined)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(k!=undefined)for(var D in k)this.sides[D]!=undefined&&(this.sides[D]=
|
|
|
-k[D]);this.sides.px&&m("z","y",1*j,-1,b,c,-n,this.materials[0]);this.sides.nx&&m("z","y",-1*j,-1,b,c,n,this.materials[1]);this.sides.py&&m("x","z",1*j,1,a,b,p,this.materials[2]);this.sides.ny&&m("x","z",1*j,-1,a,b,-p,this.materials[3]);this.sides.pz&&m("x","y",1*j,-1,a,c,o,this.materials[4]);this.sides.nz&&m("x","y",-1*j,-1,a,c,-o,this.materials[5]);(function(){for(var z=[],v=[],A=0,t=l.vertices.length;A<t;A++){for(var C=l.vertices[A],E=!1,K=0,N=z.length;K<N;K++){var L=z[K];if(C.position.x==L.position.x&&
|
|
|
-C.position.y==L.position.y&&C.position.z==L.position.z){v[A]=K;E=!0;break}}if(!E){v[A]=z.length;z.push(new THREE.Vertex(C.position.clone()))}}A=0;for(t=l.faces.length;A<t;A++){C=l.faces[A];C.a=v[C.a];C.b=v[C.b];C.c=v[C.c];C.d=v[C.d]}l.vertices=z})();this.computeCentroids();this.computeFaceNormals()};THREE.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
|
|
|
-THREE.Cylinder=function(a,c,b,e,g,f){function h(p,o,w){j.vertices.push(new THREE.Vertex(new THREE.Vector3(p,o,w)))}THREE.Geometry.call(this);var j=this,k,m=Math.PI*2,l=e/2;for(k=0;k<a;k++)h(Math.sin(m*k/a)*c,Math.cos(m*k/a)*c,-l);for(k=0;k<a;k++)h(Math.sin(m*k/a)*b,Math.cos(m*k/a)*b,l);for(k=0;k<a;k++)j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(b>0){h(0,0,-l-(f||0));for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(c>0){h(0,0,l+(g||0));
|
|
|
-for(k=a+a/2;k<2*a;k++)j.faces.push(new THREE.Face4(2*a+1,(2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a))}k=0;for(a=this.faces.length;k<a;k++){c=[];b=this.faces[k];g=this.vertices[b.a];f=this.vertices[b.b];l=this.vertices[b.c];var n=this.vertices[b.d];c.push(new THREE.UV(0.5+Math.atan2(g.position.x,g.position.y)/m,0.5+g.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(f.position.x,f.position.y)/m,0.5+f.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(l.position.x,l.position.y)/m,0.5+l.position.z/
|
|
|
-e));b instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(n.position.x,n.position.y)/m,0.5+n.position.z/e));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.Cylinder.prototype=new THREE.Geometry;THREE.Cylinder.prototype.constructor=THREE.Cylinder;
|
|
|
-THREE.Icosahedron=function(a){function c(n,p,o){var w=Math.sqrt(n*n+p*p+o*o);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(n/w,p/w,o/w)))-1}function b(n,p,o,w){w.faces.push(new THREE.Face3(n,p,o))}function e(n,p){var o=g.vertices[n].position,w=g.vertices[p].position;return c((o.x+w.x)/2,(o.y+w.y)/2,(o.z+w.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
|
|
|
-1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,f);b(0,5,1,f);b(0,1,7,f);b(0,7,10,f);b(0,10,11,f);b(1,5,9,f);b(5,11,4,f);b(11,10,2,f);b(10,7,6,f);b(7,1,8,f);b(3,9,4,f);b(3,4,2,f);b(3,2,6,f);b(3,6,8,f);b(3,8,9,f);b(4,9,5,f);b(2,4,11,f);b(6,2,10,f);b(8,6,7,f);b(9,8,1,f);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var j in f.faces){var k=e(f.faces[j].a,f.faces[j].b),m=e(f.faces[j].b,f.faces[j].c),l=e(f.faces[j].c,f.faces[j].a);b(f.faces[j].a,k,l,h);b(f.faces[j].b,m,k,h);b(f.faces[j].c,
|
|
|
-l,m,h);b(k,m,l,h)}f.faces=h.faces}g.faces=f.faces;delete f;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
|
|
|
-THREE.Lathe=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;b=[];for(var e=[],g=[],f=[],h=(new THREE.Matrix4).setRotationZ(c),j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));b[j]=a[j].clone();e[j]=this.vertices.length-1}for(var k=0;k<=this.angle+0.0010;k+=c){for(j=0;j<b.length;j++)if(k<this.angle){b[j]=h.multiplyVector3(b[j].clone());this.vertices.push(new THREE.Vertex(b[j]));g[j]=this.vertices.length-1}else g=f;k==0&&(f=e);
|
|
|
-for(j=0;j<e.length-1;j++){this.faces.push(new THREE.Face4(g[j],g[j+1],e[j+1],e[j]));this.faceVertexUvs[0].push([new THREE.UV(1-k/this.angle,j/a.length),new THREE.UV(1-k/this.angle,(j+1)/a.length),new THREE.UV(1-(k-c)/this.angle,(j+1)/a.length),new THREE.UV(1-(k-c)/this.angle,j/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Lathe.prototype=new THREE.Geometry;THREE.Lathe.prototype.constructor=THREE.Lathe;
|
|
|
-THREE.Plane=function(a,c,b,e){THREE.Geometry.call(this);var g,f=a/2,h=c/2;b=b||1;e=e||1;var j=b+1,k=e+1;a/=b;var m=c/e;for(g=0;g<k;g++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-f,-(g*m-h),0)));for(g=0;g<e;g++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+j*g,c+j*(g+1),c+1+j*(g+1),c+1+j*g));this.faceVertexUvs[0].push([new THREE.UV(c/b,g/e),new THREE.UV(c/b,(g+1)/e),new THREE.UV((c+1)/b,(g+1)/e),new THREE.UV((c+1)/b,g/e)])}this.computeCentroids();this.computeFaceNormals()};
|
|
|
+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-
|
|
|
+this.screen.offsetLeft)/this.radius*0.5,(c-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(a,c){var b=new THREE.Vector3((a-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-c)/this.radius,0),e=b.length();e>1?b.normalize():b.z=Math.sqrt(1-e*e);f=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(b.y);e.addSelf(this.up.clone().crossSelf(f).setLength(b.x));e.addSelf(f.setLength(b.z));return e};
|
|
|
+this.rotateCamera=function(){var a=Math.acos(g.dot(h)/g.length()/h.length());if(a){var c=(new THREE.Vector3).cross(g,h).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c,-a);b.multiplyVector3(f);b.multiplyVector3(this.up);b.multiplyVector3(h);this.staticMoving?g=h:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(g))}};this.zoomCamera=function(){var a=1+(j.y-k.y)*this.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),this.staticMoving?k=j:k.y+=(j.y-k.y)*this.dynamicDampingFactor)};
|
|
|
+this.panCamera=function(){var a=l.clone().subSelf(m);if(a.lengthSq()){a.multiplyScalar(f.length()*this.panSpeed);var c=f.clone().crossSelf(this.up).setLength(a.x);c.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?m=l:m.addSelf(a.sub(l,m).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance),
|
|
|
+f.lengthSq()<this.minDistance*this.minDistance&&this.position.add(this.target.position,f.setLength(this.minDistance))};this.update=function(a,c,b){f=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,f);this.checkDistances();this.supr.update.call(this,a,c,b)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",
|
|
|
+b(this,function(a){c&&(g=h=this.getMouseProjectionOnBall(a.clientX,a.clientY),k=j=this.getMouseOnScreen(a.clientX,a.clientY),m=l=this.getMouseOnScreen(a.clientX,a.clientY),c=!1);e!==this.STATE.NONE&&(e===this.STATE.ROTATE?h=this.getMouseProjectionOnBall(a.clientX,a.clientY):e===this.STATE.ZOOM&&!this.noZoom?j=this.getMouseOnScreen(a.clientX,a.clientY):e===this.STATE.PAN&&!this.noPan&&(l=this.getMouseOnScreen(a.clientX,a.clientY)))}),!1);this.domElement.addEventListener("mousedown",b(this,function(a){a.preventDefault();
|
|
|
+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.Cube=function(a,b,c,e,f,g,h,k,j){function m(a,c,b,h,k,j,m,n){var p,t,u=e||1,v=f||1,K=k/2,N=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",v=g||1;else if(a=="z"&&c=="y"||a=="y"&&c=="z")p="x",u=g||1;var O=u+1,D=v+1;k/=u;var J=j/v;for(t=0;t<D;t++)for(j=0;j<O;j++){var P=new THREE.Vector3;P[a]=(j*k-K)*b;P[c]=(t*J-N)*h;P[p]=m;l.vertices.push(new THREE.Vertex(P))}for(t=0;t<v;t++)for(j=0;j<u;j++)l.faces.push(new THREE.Face4(j+O*t+L,j+O*(t+
|
|
|
+1)+L,j+1+O*(t+1)+L,j+1+O*t+L,null,null,n)),l.faceVertexUvs[0].push([new THREE.UV(j/u,t/v),new THREE.UV(j/u,(t+1)/v),new THREE.UV((j+1)/u,(t+1)/v),new THREE.UV((j+1)/u,t/v)])}THREE.Geometry.call(this);var l=this,n=a/2,t=b/2,p=c/2,k=k?-1:1;if(h!==void 0)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var u=0;u<6;u++)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,p,this.materials[4]);this.sides.nz&&m("x","y",-1*k,-1,a,b,-p,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.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
|
|
|
+THREE.Cylinder=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/
|
|
|
+e));c instanceof THREE.Face4&&b.push(new THREE.UV(0.5+Math.atan2(n.position.x,n.position.y)/m,0.5+n.position.z/e));this.faceVertexUvs[0].push(b)}this.computeCentroids();this.computeFaceNormals()};THREE.Cylinder.prototype=new THREE.Geometry;THREE.Cylinder.prototype.constructor=THREE.Cylinder;
|
|
|
+THREE.Icosahedron=function(a){function b(a,c,b){var e=Math.sqrt(a*a+c*c+b*b);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(a/e,c/e,b/e)))-1}function c(a,c,b,e){e.faces.push(new THREE.Face3(a,c,b))}function e(a,c){var e=f.vertices[a].position,g=f.vertices[c].position;return b((e.x+g.x)/2,(e.y+g.y)/2,(e.z+g.z)/2)}var f=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
|
|
|
+1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=e(g.faces[k].a,g.faces[k].b),m=e(g.faces[k].b,g.faces[k].c),l=e(g.faces[k].c,g.faces[k].a);c(g.faces[k].a,j,l,h);c(g.faces[k].b,m,j,h);c(g.faces[k].c,
|
|
|
+l,m,h);c(j,m,l,h)}g.faces=h.faces}f.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
|
|
|
+THREE.Lathe=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],e=[],f=[],g=[],h=(new THREE.Matrix4).setRotationZ(b),k=0;k<a.length;k++)this.vertices.push(new THREE.Vertex(a[k])),c[k]=a[k].clone(),e[k]=this.vertices.length-1;for(var j=0;j<=this.angle+0.0010;j+=b){for(k=0;k<c.length;k++)j<this.angle?(c[k]=h.multiplyVector3(c[k].clone()),this.vertices.push(new THREE.Vertex(c[k])),f[k]=this.vertices.length-1):f=g;j==0&&(g=e);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.Lathe.prototype=new THREE.Geometry;THREE.Lathe.prototype.constructor=THREE.Lathe;
|
|
|
+THREE.Plane=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.Plane.prototype=new THREE.Geometry;THREE.Plane.prototype.constructor=THREE.Plane;
|
|
|
-THREE.Sphere=function(a,c,b){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b<h+1;b++){e=b/h;var j=a*Math.cos(e*g),k=a*Math.sin(e*g),m=[],l=0;for(e=0;e<f;e++){var n=2*e/f,p=k*Math.sin(n*g);n=k*Math.cos(n*g);(b==0||b==h)&&e>0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,j,p)))-1);m.push(l)}c.push(m)}var o,w,D;g=c.length;for(b=0;b<g;b++){f=c[b].length;if(b>0)for(e=0;e<f;e++){m=e==f-1;h=c[b][m?0:e+1];j=c[b][m?f-1:e];k=c[b-1][m?f-1:e];m=c[b-
|
|
|
-1][m?0:e+1];p=b/(g-1);o=(b-1)/(g-1);w=(e+1)/f;n=e/f;l=new THREE.UV(1-w,p);p=new THREE.UV(1-n,p);n=new THREE.UV(1-n,o);var z=new THREE.UV(1-w,o);if(b<c.length-1){o=this.vertices[h].position.clone();w=this.vertices[j].position.clone();D=this.vertices[k].position.clone();o.normalize();w.normalize();D.normalize();this.faces.push(new THREE.Face3(h,j,k,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(D.x,D.y,D.z)]));this.faceVertexUvs[0].push([l,p,n])}if(b>1){o=this.vertices[h].position.clone();
|
|
|
-w=this.vertices[k].position.clone();D=this.vertices[m].position.clone();o.normalize();w.normalize();D.normalize();this.faces.push(new THREE.Face3(h,k,m,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(D.x,D.y,D.z)]));this.faceVertexUvs[0].push([l,n,z])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere;
|
|
|
-THREE.Torus=function(a,c,b,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=e||6;a=[];for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){e=b/this.segmentsT*2*Math.PI;var g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b=
|
|
|
-1;b<=this.segmentsT;++b){e=(this.segmentsT+1)*c+b;g=(this.segmentsT+1)*c+b-1;var f=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(e,g,f,h));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus;
|
|
|
-THREE.TorusKnot=function(a,c,b,e,g,f,h){function j(n,p,o,w,D,z){p=o/w*n;o=Math.cos(p);return new THREE.Vector3(D*(2+o)*0.5*Math.cos(n),D*(2+o)*Math.sin(n)*0.5,z*D*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=e||8;this.p=g||2;this.q=f||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;e=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var k=
|
|
|
-a/this.segmentsR*2*this.p*Math.PI;h=c/this.segmentsT*2*Math.PI;g=j(k,h,this.q,this.p,this.radius,this.heightScale);k=j(k+0.01,h,this.q,this.p,this.radius,this.heightScale);b.x=k.x-g.x;b.y=k.y-g.y;b.z=k.z-g.z;e.x=k.x+g.x;e.y=k.y+g.y;e.z=k.z+g.z;f.cross(b,e);e.cross(f,b);f.normalize();e.normalize();k=-this.tube*Math.cos(h);h=this.tube*Math.sin(h);g.x+=k*e.x+h*f.x;g.y+=k*e.y+h*f.y;g.z+=k*e.z+h*f.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,g.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=
|
|
|
-0;c<this.segmentsT;++c){e=(a+1)%this.segmentsR;f=(c+1)%this.segmentsT;g=this.grid[a][c];b=this.grid[e][c];e=this.grid[e][f];f=this.grid[a][f];h=new THREE.UV(a/this.segmentsR,c/this.segmentsT);k=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var m=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT),l=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(g,b,e,f));this.faceVertexUvs[0].push([h,k,m,l])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
|
|
|
+THREE.Sphere=function(a,b,c){THREE.Geometry.call(this);for(var 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 p,u,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);p=(c-1)/(f-1);u=(e+1)/g;var n=e/g,l=new THREE.UV(1-u,t),t=new THREE.UV(1-n,t),n=new THREE.UV(1-n,p),w=new THREE.UV(1-u,p);c<b.length-1&&(p=this.vertices[h].position.clone(),u=this.vertices[k].position.clone(),v=this.vertices[j].position.clone(),p.normalize(),u.normalize(),v.normalize(),this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)])),this.faceVertexUvs[0].push([l,t,n]));c>1&&(p=this.vertices[h].position.clone(),
|
|
|
+u=this.vertices[j].position.clone(),v=this.vertices[m].position.clone(),p.normalize(),u.normalize(),v.normalize(),this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)])),this.faceVertexUvs[0].push([l,n,w]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere;
|
|
|
+THREE.Torus=function(a,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.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus;
|
|
|
+THREE.TorusKnot=function(a,b,c,e,f,g,h){function k(a,c,b,e,g,f){c=b/e*a;b=Math.cos(c);return new THREE.Vector3(g*(2+b)*0.5*Math.cos(a),g*(2+b)*Math.sin(a)*0.5,f*g*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=e||8;this.p=f||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;e=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(b=0;b<this.segmentsT;++b){var j=
|
|
|
+a/this.segmentsR*2*this.p*Math.PI,h=b/this.segmentsT*2*Math.PI,f=k(j,h,this.q,this.p,this.radius,this.heightScale),j=k(j+0.01,h,this.q,this.p,this.radius,this.heightScale);c.x=j.x-f.x;c.y=j.y-f.y;c.z=j.z-f.z;e.x=j.x+f.x;e.y=j.y+f.y;e.z=j.z+f.z;g.cross(c,e);e.cross(g,c);g.normalize();e.normalize();j=-this.tube*Math.cos(h);h=this.tube*Math.sin(h);f.x+=j*e.x+h*g.x;f.y+=j*e.y+h*g.y;f.z+=j*e.z+h*g.z;this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z)))-1}}for(a=0;a<this.segmentsR;++a)for(b=
|
|
|
+0;b<this.segmentsT;++b){var e=(a+1)%this.segmentsR,g=(b+1)%this.segmentsT,f=this.grid[a][b],c=this.grid[e][b],e=this.grid[e][g],g=this.grid[a][g],h=new THREE.UV(a/this.segmentsR,b/this.segmentsT),j=new THREE.UV((a+1)/this.segmentsR,b/this.segmentsT),m=new THREE.UV((a+1)/this.segmentsR,(b+1)/this.segmentsT),l=new THREE.UV(a/this.segmentsR,(b+1)/this.segmentsT);this.faces.push(new THREE.Face4(f,c,e,g));this.faceVertexUvs[0].push([h,j,m,l])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
|
|
|
THREE.TorusKnot.prototype=new THREE.Geometry;THREE.TorusKnot.prototype.constructor=THREE.TorusKnot;
|
|
|
-THREE.Text=function(a,c,b,e){c||(c=100);b||(b=50);e||(e=4);THREE.Geometry.call(this);ThreeFont.size=c;ThreeFont.divisions=e;a=ThreeFont.drawText(a);vertices=a.points;faces=a.faces;contour=a.contour;a=0;for(var g in vertices){c=vertices[g];this.vertices.push(new THREE.Vertex(new THREE.Vector3(c.x,c.y,0)));a++}for(g in vertices){c=vertices[g];this.vertices.push(new THREE.Vertex(new THREE.Vector3(c.x,c.y,b)))}for(g in faces){b=faces[g];this.faces.push(new THREE.Face3(b[2],b[1],b[0]))}for(g in faces){b=
|
|
|
-faces[g];this.faces.push(new THREE.Face3(b[0]+a,b[1]+a,b[2]+a))}g=contour.length;for(var f;--g>0;){if(f){if(f.equals(contour[g])){f=null;continue}}else f=contour[g];for(b=0;b<vertices.length;b++)if(vertices[b].equals(contour[g]))break;for(c=0;c<vertices.length;c++)if(vertices[c].equals(contour[g-1]))break;this.faces.push(new THREE.Face4(b,c,c+a,b+a))}this.computeCentroids();this.computeFaceNormals()};THREE.Text.prototype=new THREE.Geometry;THREE.Text.prototype.constructor=THREE.Text;
|
|
|
-var ThreeFont={};ThreeFont.faces={};ThreeFont.face="helvetiker";ThreeFont.weight="normal";ThreeFont.style="normal";ThreeFont.size=150;ThreeFont.divisions=10;ThreeFont.getFace=function(){return this.faces[this.face][this.weight][this.style]};
|
|
|
-ThreeFont.loadFace=function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};if(a.strokeFont){this.faces[c].normal=this.faces[c].normal||{};this.faces[c].normal.normal=a;this.faces[c].normal.italic=a;this.faces[c].bold=this.faces[c].normal||{};this.faces[c].bold.normal=a;this.faces[c].bold.italic=a}else{this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a}return a};
|
|
|
-ThreeFont.extractPoints=function(a){if(a.length<3)console.log("not valid polygon");else{var c=[],b,e,g=[],f;for(f in a){b=a[f];c.push(b.x+","+b.y)}b=c[0];b=c.slice(1).indexOf(b);if(b<c.length){b++;e=a.slice(0,b)}for(holes=[];b<c.length;){firstIndex=b+1;b=c[firstIndex];b=c.slice(firstIndex+1).indexOf(b)+firstIndex;if(b<=firstIndex)break;var h=a.slice(firstIndex,b+1);if(THREE.Triangulate.area(h)<0){g.push({shape:e,holes:holes});e=h;holes=[]}else holes.push(h);b++}g.push({shape:e,holes:holes});c=[];
|
|
|
-for(var j in g){b=g[j];e=b.shape;holes=b.holes;for(var k in holes){a=holes[k];h=Number.POSITIVE_INFINITY;var m,l,n;for(n in a){var p=a[n];for(f in e){d=p.distanceTo(e[f]);if(d<h){h=d;m=n;l=f}}}prevShapeVert=l-1>=0?l-1:e.length-1;nextShapeVert=l+1<e.length?l+1:0;prevHoleVert=m-1>=0?m-1:a.length-1;nextHoleVert=m+1<a.length?m+1:0;h=e.slice(0,l);p=e.slice(l);var o=a.slice(m),w=a.slice(0,m);c.push(a[m]);c.push(e[l]);c.push(e[prevShapeVert]);c.push(a[m]);c.push(a[prevHoleVert]);c.push(e[l]);b.shape=h.concat(o).concat(w).concat(p)}}a=
|
|
|
-[];f=[];m=0;for(j in g){b=g[j];e=b.shape;a=a.concat(e);l=THREE.Triangulate(e,!0);for(var D in l){k=l[D];k[0]+=m;k[1]+=m;k[2]+=m}f=f.concat(l);m+=e.length}for(D=0;D<c.length/3;D++){k=[];for(g=0;g<3;g++)for(e=0;e<a.length;e++)if(a[e].equals(c[D*3+g])){k.push(e);break}f.push(k)}return{points:a,faces:f}}};
|
|
|
-ThreeFont.drawText=function(a){pts=[];var c=this.getFace(),b=this.size/c.resolution,e=0,g=String(a).split(""),f=g.length;for(a=0;a<f;a++)e+=this.extractGlyphPoints(g[a],c,b,e);width=e/2;for(var h in pts)pts[h].x-=width;c=this.extractPoints(pts);c.contour=pts;return c};function b2p0(a,c){return(1-a)*(1-a)*c}function b2p1(a,c){return 2*(1-a)*a*c}function b2p2(a,c){return a*a*c}function b2(a,c,b,e){return b2p0(a,c)+b2p1(a,b)+b2p2(a,e)}function b3p0(a,c){var b=1-a;return b*b*b*c}
|
|
|
-function b3p1(a,c){var b=1-a;return 3*b*b*a*c}function b3p2(a,c){return 3*(1-a)*a*a*c}function b3p3(a,c){return a*a*a*c}function b3(a,c,b,e,g){return b3p0(a,c)+b3p1(a,b)+b3p2(a,e)+b3p3(a,g)}
|
|
|
-ThreeFont.extractGlyphPoints=function(a,c,b,e){var g,f,h,j=c.glyphs[a]||c.glyphs[ctxt.options.fallbackCharacter];if(j){if(j.o){c=j._cachedOutline||(j._cachedOutline=j.o.split(" "));h=c.length;for(a=0;a<h;){g=c[a++];switch(g){case "m":x=c[a++]*b+e;y=c[a++]*b;pts.push(new THREE.Vector2(x,y));break;case "l":x=c[a++]*b+e;y=c[a++]*b;pts.push(new THREE.Vector2(x,y));break;case "q":g=c[a++]*b+e;f=c[a++]*b;cpx1=c[a++]*b+e;cpy1=c[a++]*b;var k=pts[pts.length-1];if(k){cpx0=k.x;cpy0=k.y;k=1;for(var m=this.divisions;k<=
|
|
|
-m;k++){var l=k/m,n=b2(l,cpx0,cpx1,g);l=b2(l,cpy0,cpy1,f);pts.push(new THREE.Vector2(n,l))}}break;case "b":g=c[a++]*b+e;f=c[a++]*b;cpx1=c[a++]*b+e;cpy1=c[a++]*-b;cpx2=c[a++]*b+e;cpy2=c[a++]*-b;if(k=pts[pts.length-1]){cpx0=k.x;cpy0=k.y;k=1;for(m=this.divisions;k<=m;k++){l=k/m;n=b3(l,cpx0,cpx1,cpx2,g);l=b3(l,cpy0,cpy1,cpy2,f);pts.push(new THREE.Vector2(n,l))}}}}}return j.ha*b}};
|
|
|
-(function(a){var c=function(b){for(var e=b.length,g=0,f=e-1,h=0;h<e;f=h++)g+=b[f].x*b[h].y-b[h].x*b[f].y;return g*0.5};a.Triangulate=function(b,e){var g=[],f=b.length;if(f<3)return null;var h=[],j=[],k;if(0<c(b))for(k=0;k<f;k++)h[k]=k;else for(k=0;k<f;k++)h[k]=f-1-k;var m=2*f,l;l=0;for(k=f-1;f>2;){if(0>=m--){console.log("Warning, unable to triangulate polygon!");return null}var n=k;f<=n&&(n=0);k=n+1;f<=k&&(k=0);var p=k+1;f<=p&&(p=0);var o;a:{o=b;var w=n,D=k,z=p,v=f,A=h,t=void 0,C=void 0,E=void 0,
|
|
|
-K=void 0,N=void 0,L=void 0,J=void 0,G=void 0,O=void 0;C=o[A[w]].x;E=o[A[w]].y;K=o[A[D]].x;N=o[A[D]].y;L=o[A[z]].x;J=o[A[z]].y;if(1.0E-10>(K-C)*(J-E)-(N-E)*(L-C))o=!1;else{for(t=0;t<v;t++)if(!(t==w||t==D||t==z)){G=o[A[t]].x;O=o[A[t]].y;var R=void 0,T=void 0,S=void 0,U=void 0,H=void 0,Q=void 0,V=void 0,W=void 0,P=void 0,Y=void 0,aa=void 0,ba=void 0;H=void 0;S=void 0;R=void 0;R=L-K;T=J-N;S=C-L;U=E-J;H=K-C;Q=N-E;V=G-C;W=O-E;P=G-K;Y=O-N;aa=G-L;ba=O-J;R=R*Y-T*P;H=H*W-Q*V;S=S*ba-U*aa;if(R>=0&&S>=0&&H>=0){o=
|
|
|
-!1;break a}}o=!0}}if(o){m=h[n];o=h[k];w=h[p];g.push(b[m]);g.push(b[o]);g.push(b[w]);j.push([h[n],h[k],h[p]]);l++;n=k;for(p=k+1;p<f;n++,p++)h[n]=h[p];f--;m=2*f}}if(e)return j;return g};a.Triangulate.area=c;return a})(THREE);window._typeface_js={faces:ThreeFont.faces,loadFace:ThreeFont.loadFace};THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
|
|
|
-THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";
|
|
|
-this.statusDomElement.innerHTML=c},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,c,b){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],b)]},createMaterial:function(a,c){function b(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}function e(j,k){var m=new Image;m.onload=function(){if(!b(this.width)||!b(this.height)){var l=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),n=Math.pow(2,Math.round(Math.log(this.height)/
|
|
|
-Math.LN2));j.image.width=l;j.image.height=n;j.image.getContext("2d").drawImage(this,0,0,l,n)}else j.image=this;j.needsUpdate=!0};m.src=k}var g,f,h;g="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,lightMap:null,wireframe:a.wireframe};if(a.shading)if(a.shading=="Phong")g="MeshPhongMaterial";else a.shading=="Basic"&&(g="MeshBasicMaterial");if(a.blending)if(a.blending=="Additive")f.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")f.blending=THREE.SubtractiveBlending;else if(a.blending==
|
|
|
-"Multiply")f.blending=THREE.MultiplyBlending;if(a.transparent!==undefined||a.opacity<1)f.transparent=a.transparent;if(a.depthTest!==undefined)f.depthTest=a.depthTest;if(a.vertexColors!==undefined)if(a.vertexColors=="face")f.vertexColors=THREE.FaceColors;else if(a.vertexColors)f.vertexColors=THREE.VertexColors;if(a.mapDiffuse&&c){h=document.createElement("canvas");f.map=new THREE.Texture(h);f.map.sourceFile=a.mapDiffuse;e(f.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=(a.colorDiffuse[0]*255<<
|
|
|
-16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;f.color=h;f.opacity=a.transparency}else if(a.DbgColor)f.color=a.DbgColor;if(a.mapLightmap&&c){h=document.createElement("canvas");f.lightMap=new THREE.Texture(h);f.lightMap.sourceFile=a.mapLightmap;e(f.lightMap,c+"/"+a.mapLightmap)}return new THREE[g](f)}};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 c=this,b=a.model,e=a.callback,g=a.texture_path?a.texture_path:this.extractUrlbase(b);a=new Worker(b);a.onmessage=function(f){c.createModel(f.data,e,g);c.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
|
|
|
-THREE.JSONLoader.prototype.createModel=function(a,c,b){var e=new THREE.Geometry,g=a.scale!==undefined?1/a.scale:1;this.init_materials(e,a.materials,b);(function(f){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var h,j,k,m,l,n,p,o,w,D,z,v,A,t,C=a.faces;n=a.vertices;var E=a.normals,K=a.colors,N=0;for(h=0;h<a.uvs.length;h++)a.uvs[h].length&&N++;for(h=0;h<N;h++){e.faceUvs[h]=[];e.faceVertexUvs[h]=[]}m=0;for(l=n.length;m<l;){p=new THREE.Vertex;p.position.x=n[m++]*
|
|
|
-f;p.position.y=n[m++]*f;p.position.z=n[m++]*f;e.vertices.push(p)}m=0;for(l=C.length;m<l;){f=C[m++];n=f&1;k=f&2;h=f&4;j=f&8;o=f&16;p=f&32;D=f&64;f&=128;if(n){z=new THREE.Face4;z.a=C[m++];z.b=C[m++];z.c=C[m++];z.d=C[m++];n=4}else{z=new THREE.Face3;z.a=C[m++];z.b=C[m++];z.c=C[m++];n=3}if(k){k=C[m++];z.materials=e.materials[k]}k=e.faces.length;if(h)for(h=0;h<N;h++){v=a.uvs[h];w=C[m++];t=v[w*2];w=v[w*2+1];e.faceUvs[h][k]=new THREE.UV(t,w)}if(j)for(h=0;h<N;h++){v=a.uvs[h];A=[];for(j=0;j<n;j++){w=C[m++];
|
|
|
-t=v[w*2];w=v[w*2+1];A[j]=new THREE.UV(t,w)}e.faceVertexUvs[h][k]=A}if(o){o=C[m++]*3;j=new THREE.Vector3;j.x=E[o++];j.y=E[o++];j.z=E[o];z.normal=j}if(p)for(h=0;h<n;h++){o=C[m++]*3;j=new THREE.Vector3;j.x=E[o++];j.y=E[o++];j.z=E[o];z.vertexNormals.push(j)}if(D){p=C[m++];p=new THREE.Color(K[p]);z.color=p}if(f)for(h=0;h<n;h++){p=C[m++];p=new THREE.Color(K[p]);z.vertexColors.push(p)}e.faces.push(z)}}})(g);(function(){var f,h,j,k;if(a.skinWeights){f=0;for(h=a.skinWeights.length;f<h;f+=2){j=a.skinWeights[f];
|
|
|
-k=a.skinWeights[f+1];e.skinWeights.push(new THREE.Vector4(j,k,0,0))}}if(a.skinIndices){f=0;for(h=a.skinIndices.length;f<h;f+=2){j=a.skinIndices[f];k=a.skinIndices[f+1];e.skinIndices.push(new THREE.Vector4(j,k,0,0))}}e.bones=a.bones;e.animation=a.animation})();(function(f){if(a.morphTargets!==undefined){var h,j,k,m,l,n,p,o,w;h=0;for(j=a.morphTargets.length;h<j;h++){e.morphTargets[h]={};e.morphTargets[h].name=a.morphTargets[h].name;e.morphTargets[h].vertices=[];o=e.morphTargets[h].vertices;w=a.morphTargets[h].vertices;
|
|
|
-k=0;for(m=w.length;k<m;k+=3){l=w[k]*f;n=w[k+1]*f;p=w[k+2]*f;o.push(new THREE.Vertex(new THREE.Vector3(l,n,p)))}}}if(a.morphColors!==undefined){h=0;for(j=a.morphColors.length;h<j;h++){e.morphColors[h]={};e.morphColors[h].name=a.morphColors[h].name;e.morphColors[h].colors=[];m=e.morphColors[h].colors;l=a.morphColors[h].colors;f=0;for(k=l.length;f<k;f+=3){n=new THREE.Color(16755200);n.setRGB(l[f],l[f+1],l[f+2]);m.push(n)}}}})(g);(function(){if(a.edges!==undefined){var f,h,j;for(f=0;f<a.edges.length;f+=
|
|
|
-2){h=a.edges[f];j=a.edges[f+1];e.edges.push(new THREE.Edge(e.vertices[h],e.vertices[j],h,j))}}})();e.computeFaceNormals();c(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 c=a.model,b=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.BinaryLoader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,b,g,e,f)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};
|
|
|
-c.postMessage(a)},loadAjaxBuffers:function(a,c,b,e,g,f){var h=new XMLHttpRequest,j=e+"/"+a,k=0;h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.BinaryLoader.prototype.createBinModel(h.responseText,b,g,c):alert("Couldn't load ["+j+"] ["+h.status+"]");else if(h.readyState==3){if(f){k==0&&(k=h.getResponseHeader("Content-Length"));f({total:k,loaded:h.responseText.length})}}else h.readyState==2&&(k=h.getResponseHeader("Content-Length"))};h.open("GET",j,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
|
|
|
-h.setRequestHeader("Content-Type","text/plain");h.send(null)},createBinModel:function(a,c,b,e){var g=function(f){function h(u,B){var F=l(u,B),I=l(u,B+1),M=l(u,B+2),X=l(u,B+3),Z=(X<<1&255|M>>7)-127;F|=(M&127)<<16|I<<8;if(F==0&&Z==-127)return 0;return(1-2*(X>>7))*(1+F*Math.pow(2,-23))*Math.pow(2,Z)}function j(u,B){var F=l(u,B),I=l(u,B+1),M=l(u,B+2);return(l(u,B+3)<<24)+(M<<16)+(I<<8)+F}function k(u,B){var F=l(u,B);return(l(u,B+1)<<8)+F}function m(u,B){var F=l(u,B);return F>127?F-256:F}function l(u,
|
|
|
-B){return u.charCodeAt(B)&255}function n(u){var B,F,I;B=j(a,u);F=j(a,u+K);I=j(a,u+N);u=k(a,u+L);THREE.BinaryLoader.prototype.f3(v,B,F,I,u)}function p(u){var B,F,I,M,X,Z;B=j(a,u);F=j(a,u+K);I=j(a,u+N);M=k(a,u+L);X=j(a,u+J);Z=j(a,u+G);u=j(a,u+O);THREE.BinaryLoader.prototype.f3n(v,C,B,F,I,M,X,Z,u)}function o(u){var B,F,I,M;B=j(a,u);F=j(a,u+R);I=j(a,u+T);M=j(a,u+S);u=k(a,u+U);THREE.BinaryLoader.prototype.f4(v,B,F,I,M,u)}function w(u){var B,F,I,M,X,Z,ha,ia;B=j(a,u);F=j(a,u+R);I=j(a,u+T);M=j(a,u+S);X=k(a,
|
|
|
-u+U);Z=j(a,u+H);ha=j(a,u+Q);ia=j(a,u+V);u=j(a,u+W);THREE.BinaryLoader.prototype.f4n(v,C,B,F,I,M,X,Z,ha,ia,u)}function D(u){var B,F;B=j(a,u);F=j(a,u+P);u=j(a,u+Y);THREE.BinaryLoader.prototype.uv3(v.faceVertexUvs[0],E[B*2],E[B*2+1],E[F*2],E[F*2+1],E[u*2],E[u*2+1])}function z(u){var B,F,I;B=j(a,u);F=j(a,u+aa);I=j(a,u+ba);u=j(a,u+ja);THREE.BinaryLoader.prototype.uv4(v.faceVertexUvs[0],E[B*2],E[B*2+1],E[F*2],E[F*2+1],E[I*2],E[I*2+1],E[u*2],E[u*2+1])}var v=this,A=0,t,C=[],E=[],K,N,L,J,G,O,R,T,S,U,H,Q,V,
|
|
|
-W,P,Y,aa,ba,ja,ca,da,ea,fa,ga,$;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,f);t={signature:a.substr(A,8),header_bytes:l(a,A+8),vertex_coordinate_bytes:l(a,A+9),normal_coordinate_bytes:l(a,A+10),uv_coordinate_bytes:l(a,A+11),vertex_index_bytes:l(a,A+12),normal_index_bytes:l(a,A+13),uv_index_bytes:l(a,A+14),material_index_bytes:l(a,A+15),nvertices:j(a,A+16),nnormals:j(a,A+16+4),nuvs:j(a,A+16+8),ntri_flat:j(a,A+16+12),ntri_smooth:j(a,A+16+16),ntri_flat_uv:j(a,A+16+20),ntri_smooth_uv:j(a,
|
|
|
-A+16+24),nquad_flat:j(a,A+16+28),nquad_smooth:j(a,A+16+32),nquad_flat_uv:j(a,A+16+36),nquad_smooth_uv:j(a,A+16+40)};A+=t.header_bytes;K=t.vertex_index_bytes;N=t.vertex_index_bytes*2;L=t.vertex_index_bytes*3;J=t.vertex_index_bytes*3+t.material_index_bytes;G=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;O=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;R=t.vertex_index_bytes;T=t.vertex_index_bytes*2;S=t.vertex_index_bytes*3;U=t.vertex_index_bytes*4;H=t.vertex_index_bytes*
|
|
|
-4+t.material_index_bytes;Q=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes;V=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*2;W=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;P=t.uv_index_bytes;Y=t.uv_index_bytes*2;aa=t.uv_index_bytes;ba=t.uv_index_bytes*2;ja=t.uv_index_bytes*3;f=t.vertex_index_bytes*3+t.material_index_bytes;$=t.vertex_index_bytes*4+t.material_index_bytes;ca=t.ntri_flat*f;da=t.ntri_smooth*(f+t.normal_index_bytes*3);ea=t.ntri_flat_uv*
|
|
|
-(f+t.uv_index_bytes*3);fa=t.ntri_smooth_uv*(f+t.normal_index_bytes*3+t.uv_index_bytes*3);ga=t.nquad_flat*$;f=t.nquad_smooth*($+t.normal_index_bytes*4);$=t.nquad_flat_uv*($+t.uv_index_bytes*4);A+=function(u){for(var B,F,I,M=t.vertex_coordinate_bytes*3,X=u+t.nvertices*M;u<X;u+=M){B=h(a,u);F=h(a,u+t.vertex_coordinate_bytes);I=h(a,u+t.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(v,B,F,I)}return t.nvertices*M}(A);A+=function(u){for(var B,F,I,M=t.normal_coordinate_bytes*3,X=u+t.nnormals*M;u<
|
|
|
-X;u+=M){B=m(a,u);F=m(a,u+t.normal_coordinate_bytes);I=m(a,u+t.normal_coordinate_bytes*2);C.push(B/127,F/127,I/127)}return t.nnormals*M}(A);A+=function(u){for(var B,F,I=t.uv_coordinate_bytes*2,M=u+t.nuvs*I;u<M;u+=I){B=h(a,u);F=h(a,u+t.uv_coordinate_bytes);E.push(B,F)}return t.nuvs*I}(A);ca=A+ca;da=ca+da;ea=da+ea;fa=ea+fa;ga=fa+ga;f=ga+f;$=f+$;(function(u){var B,F=t.vertex_index_bytes*3+t.material_index_bytes,I=F+t.uv_index_bytes*3,M=u+t.ntri_flat_uv*I;for(B=u;B<M;B+=I){n(B);D(B+F)}return M-u})(da);
|
|
|
-(function(u){var B,F=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,I=F+t.uv_index_bytes*3,M=u+t.ntri_smooth_uv*I;for(B=u;B<M;B+=I){p(B);D(B+F)}return M-u})(ea);(function(u){var B,F=t.vertex_index_bytes*4+t.material_index_bytes,I=F+t.uv_index_bytes*4,M=u+t.nquad_flat_uv*I;for(B=u;B<M;B+=I){o(B);z(B+F)}return M-u})(f);(function(u){var B,F=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,I=F+t.uv_index_bytes*4,M=u+t.nquad_smooth_uv*I;for(B=u;B<M;B+=I){w(B);
|
|
|
-z(B+F)}return M-u})($);(function(u){var B,F=t.vertex_index_bytes*3+t.material_index_bytes,I=u+t.ntri_flat*F;for(B=u;B<I;B+=F)n(B);return I-u})(A);(function(u){var B,F=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,I=u+t.ntri_smooth*F;for(B=u;B<I;B+=F)p(B);return I-u})(ca);(function(u){var B,F=t.vertex_index_bytes*4+t.material_index_bytes,I=u+t.nquad_flat*F;for(B=u;B<I;B+=F)o(B);return I-u})(fa);(function(u){var B,F=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*
|
|
|
-4,I=u+t.nquad_smooth*F;for(B=u;B<I;B+=F)w(B);return I-u})(ga);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(b))},v:function(a,c,b,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,b,e)))},f3:function(a,c,b,e,g){a.faces.push(new THREE.Face3(c,b,e,null,null,a.materials[g]))},f4:function(a,c,b,e,g,f){a.faces.push(new THREE.Face4(c,b,e,g,null,null,a.materials[f]))},f3n:function(a,c,b,e,g,f,h,j,k){f=a.materials[f];var m=c[j*3],
|
|
|
-l=c[j*3+1];j=c[j*3+2];var n=c[k*3],p=c[k*3+1];k=c[k*3+2];a.faces.push(new THREE.Face3(b,e,g,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,l,j),new THREE.Vector3(n,p,k)],null,f))},f4n:function(a,c,b,e,g,f,h,j,k,m,l){h=a.materials[h];var n=c[k*3],p=c[k*3+1];k=c[k*3+2];var o=c[m*3],w=c[m*3+1];m=c[m*3+2];var D=c[l*3],z=c[l*3+1];l=c[l*3+2];a.faces.push(new THREE.Face4(b,e,g,f,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(n,p,k),new THREE.Vector3(o,w,m),new THREE.Vector3(D,
|
|
|
-z,l)],null,h))},uv3:function(a,c,b,e,g,f,h){var j=[];j.push(new THREE.UV(c,b));j.push(new THREE.UV(e,g));j.push(new THREE.UV(f,h));a.push(j)},uv4:function(a,c,b,e,g,f,h,j,k){var m=[];m.push(new THREE.UV(c,b));m.push(new THREE.UV(e,g));m.push(new THREE.UV(f,h));m.push(new THREE.UV(j,k));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,c){var b=this,e=new Worker(a);e.postMessage(0);var g=THREE.Loader.prototype.extractUrlbase(a);e.onmessage=function(f){function h(P,Y){return Y=="relativeToHTML"?P:g+"/"+P}function j(){for(o in G.objects)if(!H.objects[o]){A=G.objects[o];if(A.geometry!==undefined){if(K=H.geometries[A.geometry]){J=[];for(W=0;W<A.materials.length;W++)J[W]=H.materials[A.materials[W]];t=A.position;r=A.rotation;q=A.quaternion;s=A.scale;q=0;J.length==0&&(J[0]=new THREE.MeshFaceMaterial);
|
|
|
-J.length>1&&(J=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(K,J);object.name=o;object.position.set(t[0],t[1],t[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;H.scene.addObject(object);H.objects[o]=object;if(A.meshCollider){var P=THREE.CollisionUtils.MeshColliderWBox(object);H.scene.collisions.colliders.push(P)}if(A.castsShadow){P=new THREE.ShadowVolume(K);H.scene.addChild(P);
|
|
|
-P.position=object.position;P.rotation=object.rotation;P.scale=object.scale}if(A.trigger&&A.trigger.toLowerCase()!="none"){P={type:A.trigger,object:A};H.triggers[object.name]=P}}}else{t=A.position;r=A.rotation;q=A.quaternion;s=A.scale;q=0;object=new THREE.Object3D;object.name=o;object.position.set(t[0],t[1],t[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible!==undefined?A.visible:
|
|
|
-!1;H.scene.addObject(object);H.objects[o]=object;H.empties[o]=object;if(A.trigger&&A.trigger.toLowerCase()!="none"){P={type:A.trigger,object:A};H.triggers[object.name]=P}}}}function k(P){return function(Y){H.geometries[P]=Y;j();R-=1;b.onLoadComplete();l()}}function m(P){return function(Y){H.geometries[P]=Y}}function l(){b.callbackProgress({totalModels:S,totalTextures:U,loadedModels:S-R,loadedTextures:U-T},H);b.onLoadProgress();R==0&&T==0&&c(H)}var n,p,o,w,D,z,v,A,t,C,E,K,N,L,J,G,O,R,T,S,U,H;G=f.data;
|
|
|
-f=new THREE.BinaryLoader;O=new THREE.JSONLoader;T=R=0;H={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var Q=!1;for(o in G.objects){A=G.objects[o];if(A.meshCollider){Q=!0;break}}if(Q)H.scene.collisions=new THREE.CollisionSystem;if(G.transform){Q=G.transform.position;C=G.transform.rotation;var V=G.transform.scale;Q&&H.scene.position.set(Q[0],Q[1],Q[2]);C&&H.scene.rotation.set(C[0],C[1],C[2]);V&&H.scene.scale.set(V[0],V[1],
|
|
|
-V[2]);(Q||C||V)&&H.scene.updateMatrix()}Q=function(){T-=1;l();b.onLoadComplete()};for(D in G.cameras){C=G.cameras[D];if(C.type=="perspective")N=new THREE.Camera(C.fov,C.aspect,C.near,C.far);else if(C.type=="ortho"){N=new THREE.Camera;N.projectionMatrix=THREE.Matrix4.makeOrtho(C.left,C.right,C.top,C.bottom,C.near,C.far)}t=C.position;C=C.target;N.position.set(t[0],t[1],t[2]);N.target.position.set(C[0],C[1],C[2]);H.cameras[D]=N}for(w in G.lights){D=G.lights[w];N=D.color!==undefined?D.color:16777215;
|
|
|
-C=D.intensity!==undefined?D.intensity:1;if(D.type=="directional"){t=D.direction;light=new THREE.DirectionalLight(N,C);light.position.set(t[0],t[1],t[2]);light.position.normalize()}else if(D.type=="point"){t=D.position;light=new THREE.PointLight(N,C);light.position.set(t[0],t[1],t[2])}H.scene.addLight(light);H.lights[w]=light}for(z in G.fogs){w=G.fogs[z];if(w.type=="linear")L=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(L=new THREE.FogExp2(0,w.density));C=w.color;L.color.setRGB(C[0],C[1],C[2]);
|
|
|
-H.fogs[z]=L}if(H.cameras&&G.defaults.camera)H.currentCamera=H.cameras[G.defaults.camera];if(H.fogs&&G.defaults.fog)H.scene.fog=H.fogs[G.defaults.fog];C=G.defaults.bgcolor;H.bgColor=new THREE.Color;H.bgColor.setRGB(C[0],C[1],C[2]);H.bgColorAlpha=G.defaults.bgalpha;for(n in G.geometries){z=G.geometries[n];if(z.type=="bin_mesh"||z.type=="ascii_mesh"){R+=1;b.onLoadStart()}}S=R;for(n in G.geometries){z=G.geometries[n];if(z.type=="cube"){K=new THREE.Cube(z.width,z.height,z.depth,z.segmentsWidth,z.segmentsHeight,
|
|
|
-z.segmentsDepth,null,z.flipped,z.sides);H.geometries[n]=K}else if(z.type=="plane"){K=new THREE.Plane(z.width,z.height,z.segmentsWidth,z.segmentsHeight);H.geometries[n]=K}else if(z.type=="sphere"){K=new THREE.Sphere(z.radius,z.segmentsWidth,z.segmentsHeight);H.geometries[n]=K}else if(z.type=="cylinder"){K=new THREE.Cylinder(z.numSegs,z.topRad,z.botRad,z.height,z.topOffset,z.botOffset);H.geometries[n]=K}else if(z.type=="torus"){K=new THREE.Torus(z.radius,z.tube,z.segmentsR,z.segmentsT);H.geometries[n]=
|
|
|
-K}else if(z.type=="icosahedron"){K=new THREE.Icosahedron(z.subdivisions);H.geometries[n]=K}else if(z.type=="bin_mesh")f.load({model:h(z.url,G.urlBaseType),callback:k(n)});else if(z.type=="ascii_mesh")O.load({model:h(z.url,G.urlBaseType),callback:k(n)});else if(z.type=="embedded_mesh")(z=G.embeds[z.id])&&O.createModel(z,m(n),"")}for(v in G.textures){n=G.textures[v];if(n.url instanceof Array){T+=n.url.length;for(f=0;f<n.url.length;f++)b.onLoadStart()}else{T+=1;b.onLoadStart()}}U=T;for(v in G.textures){n=
|
|
|
-G.textures[v];if(n.mapping!=undefined&&THREE[n.mapping]!=undefined)n.mapping=new THREE[n.mapping];if(n.url instanceof Array){f=[];for(var W=0;W<n.url.length;W++)f[W]=h(n.url[W],G.urlBaseType);f=THREE.ImageUtils.loadTextureCube(f,n.mapping,Q)}else{f=THREE.ImageUtils.loadTexture(h(n.url,G.urlBaseType),n.mapping,Q);if(THREE[n.minFilter]!=undefined)f.minFilter=THREE[n.minFilter];if(THREE[n.magFilter]!=undefined)f.magFilter=THREE[n.magFilter]}H.textures[v]=f}for(p in G.materials){v=G.materials[p];for(E in v.parameters)if(E==
|
|
|
-"envMap"||E=="map"||E=="lightMap")v.parameters[E]=H.textures[v.parameters[E]];else if(E=="shading")v.parameters[E]=v.parameters[E]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(E=="blending")v.parameters[E]=THREE[v.parameters[E]]?THREE[v.parameters[E]]:THREE.NormalBlending;else if(E=="combine")v.parameters[E]=v.parameters[E]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(E=="vertexColors")if(v.parameters[E]=="face")v.parameters[E]=THREE.FaceColors;else if(v.parameters[E])v.parameters[E]=
|
|
|
-THREE.VertexColors;if(v.parameters.opacity!==undefined&&v.parameters.opacity<1)v.parameters.transparent=!0;v=new THREE[v.type](v.parameters);H.materials[p]=v}j();b.callbackSync(H)}}};
|
|
|
-THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
|
|
|
-0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,e,g){return b+(e-b)*g};this.VIntX=function(b,e,g,f,h,j,k,m,l,n){h=(h-l)/(n-l);l=this.normal_cache;e[f]=j+h*this.delta;e[f+1]=k;e[f+2]=m;g[f]=this.lerp(l[b],l[b+3],h);g[f+1]=this.lerp(l[b+1],l[b+4],h);g[f+2]=this.lerp(l[b+2],l[b+5],h)};this.VIntY=function(b,e,g,f,h,j,k,m,l,n){h=(h-l)/(n-l);l=this.normal_cache;e[f]=j;e[f+1]=k+h*this.delta;e[f+
|
|
|
-2]=m;e=b+this.yd*3;g[f]=this.lerp(l[b],l[e],h);g[f+1]=this.lerp(l[b+1],l[e+1],h);g[f+2]=this.lerp(l[b+2],l[e+2],h)};this.VIntZ=function(b,e,g,f,h,j,k,m,l,n){h=(h-l)/(n-l);l=this.normal_cache;e[f]=j;e[f+1]=k;e[f+2]=m+h*this.delta;e=b+this.zd*3;g[f]=this.lerp(l[b],l[e],h);g[f+1]=this.lerp(l[b+1],l[e+1],h);g[f+2]=this.lerp(l[b+2],l[e+2],h)};this.compNorm=function(b){var e=b*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[b-1]-this.field[b+1];this.normal_cache[e+1]=this.field[b-this.yd]-
|
|
|
-this.field[b+this.yd];this.normal_cache[e+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,e,g,f,h,j){var k=f+1,m=f+this.yd,l=f+this.zd,n=k+this.yd,p=k+this.zd,o=f+this.yd+this.zd,w=k+this.yd+this.zd,D=0,z=this.field[f],v=this.field[k],A=this.field[m],t=this.field[n],C=this.field[l],E=this.field[p],K=this.field[o],N=this.field[w];z<h&&(D|=1);v<h&&(D|=2);A<h&&(D|=8);t<h&&(D|=4);C<h&&(D|=16);E<h&&(D|=32);K<h&&(D|=128);N<h&&(D|=64);var L=THREE.edgeTable[D];if(L==0)return 0;
|
|
|
-var J=this.delta,G=b+J,O=e+J;J=g+J;if(L&1){this.compNorm(f);this.compNorm(k);this.VIntX(f*3,this.vlist,this.nlist,0,h,b,e,g,z,v)}if(L&2){this.compNorm(k);this.compNorm(n);this.VIntY(k*3,this.vlist,this.nlist,3,h,G,e,g,v,t)}if(L&4){this.compNorm(m);this.compNorm(n);this.VIntX(m*3,this.vlist,this.nlist,6,h,b,O,g,A,t)}if(L&8){this.compNorm(f);this.compNorm(m);this.VIntY(f*3,this.vlist,this.nlist,9,h,b,e,g,z,A)}if(L&16){this.compNorm(l);this.compNorm(p);this.VIntX(l*3,this.vlist,this.nlist,12,h,b,e,J,
|
|
|
-C,E)}if(L&32){this.compNorm(p);this.compNorm(w);this.VIntY(p*3,this.vlist,this.nlist,15,h,G,e,J,E,N)}if(L&64){this.compNorm(o);this.compNorm(w);this.VIntX(o*3,this.vlist,this.nlist,18,h,b,O,J,K,N)}if(L&128){this.compNorm(l);this.compNorm(o);this.VIntY(l*3,this.vlist,this.nlist,21,h,b,e,J,C,K)}if(L&256){this.compNorm(f);this.compNorm(l);this.VIntZ(f*3,this.vlist,this.nlist,24,h,b,e,g,z,C)}if(L&512){this.compNorm(k);this.compNorm(p);this.VIntZ(k*3,this.vlist,this.nlist,27,h,G,e,g,v,E)}if(L&1024){this.compNorm(n);
|
|
|
-this.compNorm(w);this.VIntZ(n*3,this.vlist,this.nlist,30,h,G,O,g,t,N)}if(L&2048){this.compNorm(m);this.compNorm(o);this.VIntZ(m*3,this.vlist,this.nlist,33,h,b,O,g,A,K)}D<<=4;for(h=f=0;THREE.triTable[D+h]!=-1;){b=D+h;e=b+1;g=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[e],3*THREE.triTable[g],j);h+=3;f++}return f};this.posnormtriv=function(b,e,g,f,h,j){var k=this.count*3;this.positionArray[k]=b[g];this.positionArray[k+1]=b[g+1];this.positionArray[k+2]=b[g+2];this.positionArray[k+
|
|
|
-3]=b[f];this.positionArray[k+4]=b[f+1];this.positionArray[k+5]=b[f+2];this.positionArray[k+6]=b[h];this.positionArray[k+7]=b[h+1];this.positionArray[k+8]=b[h+2];this.normalArray[k]=e[g];this.normalArray[k+1]=e[g+1];this.normalArray[k+2]=e[g+2];this.normalArray[k+3]=e[f];this.normalArray[k+4]=e[f+1];this.normalArray[k+5]=e[f+2];this.normalArray[k+6]=e[h];this.normalArray[k+7]=e[h+1];this.normalArray[k+8]=e[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=
|
|
|
-function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;b(this)}};this.addBall=function(b,e,g,f,h){var j=this.size*Math.sqrt(f/h),k=g*this.size,m=e*this.size,l=b*this.size,n=Math.floor(k-j);n<1&&(n=1);k=Math.floor(k+j);k>this.size-1&&(k=this.size-1);var p=Math.floor(m-j);p<1&&(p=1);m=Math.floor(m+j);m>this.size-1&&(m=this.size-1);var o=Math.floor(l-j);o<1&&(o=1);j=Math.floor(l+j);
|
|
|
-j>this.size-1&&(j=this.size-1);for(var w,D,z,v,A,t;n<k;n++){l=this.size2*n;D=n/this.size-g;A=D*D;for(D=p;D<m;D++){z=l+this.size*D;w=D/this.size-e;t=w*w;for(w=o;w<j;w++){v=w/this.size-b;v=f/(1.0E-6+v*v+t+A)-h;v>0&&(this.field[z+w]+=v)}}}};this.addPlaneX=function(b,e){var g,f,h,j,k,m=this.size,l=this.yd,n=this.zd,p=this.field,o=m*Math.sqrt(b/e);o>m&&(o=m);for(g=0;g<o;g++){f=g/m;f*=f;j=b/(1.0E-4+f)-e;if(j>0)for(f=0;f<m;f++){k=g+f*l;for(h=0;h<m;h++)p[n*h+k]+=j}}};this.addPlaneY=function(b,e){var g,f,
|
|
|
-h,j,k,m,l=this.size,n=this.yd,p=this.zd,o=this.field,w=l*Math.sqrt(b/e);w>l&&(w=l);for(f=0;f<w;f++){g=f/l;g*=g;j=b/(1.0E-4+g)-e;if(j>0){k=f*n;for(g=0;g<l;g++){m=k+g;for(h=0;h<l;h++)o[p*h+m]+=j}}}};this.addPlaneZ=function(b,e){var g,f,h,j,k,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/e);dist>size&&(dist=size);for(h=0;h<dist;h++){g=h/size;g*=g;j=b/(1.0E-4+g)-e;if(j>0){k=zd*h;for(f=0;f<size;f++){m=k+f*yd;for(g=0;g<size;g++)field[m+g]+=j}}}};this.reset=function(){var b;
|
|
|
-for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var e,g,f,h,j,k,m,l,n,p=this.size-2;for(h=1;h<p;h++){n=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(f=1;f<p;f++){l=n+this.size*f;k=(f-this.halfsize)/this.halfsize;for(g=1;g<p;g++){j=(g-this.halfsize)/this.halfsize;e=l+g;this.polygonize(j,k,m,e,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,e=new THREE.Geometry,g=[];this.render(function(f){var h,j,k,m,l,n,p,o;for(h=
|
|
|
-0;h<f.count;h++){p=h*3;l=p+1;o=p+2;j=f.positionArray[p];k=f.positionArray[l];m=f.positionArray[o];n=new THREE.Vector3(j,k,m);j=f.normalArray[p];k=f.normalArray[l];m=f.normalArray[o];p=new THREE.Vector3(j,k,m);p.normalize();l=new THREE.Vertex(n);e.vertices.push(l);g.push(p)}nfaces=f.count/3;for(h=0;h<nfaces;h++){p=(b+h)*3;l=p+1;o=p+2;n=g[p];j=g[l];k=g[o];p=new THREE.Face3(p,l,o,[n,j,k]);e.faces.push(p)}b+=nfaces;f.count=0});return e};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;
|
|
|
-THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
|
|
|
+THREE.Text=function(a,b){THREE.Geometry.call(this);var b=b||{},c=b.height!==void 0?b.height:50,e=b.curveSegments!==void 0?b.curveSegments:4;THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=e;e=THREE.FontUtils.drawText(a);vertices=e.points;faces=e.faces;contour=e.contour;var e=0,f;for(f in vertices){var g=vertices[f];this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,0)));e++}for(f in vertices)g=vertices[f],this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,
|
|
|
+g.y,c)));for(f in faces)c=faces[f],this.faces.push(new THREE.Face3(c[2],c[1],c[0]));for(f in faces)c=faces[f],this.faces.push(new THREE.Face3(c[0]+e,c[1]+e,c[2]+e));f=contour.length;for(var h;--f>0;){if(h){if(h.equals(contour[f])){h=null;continue}}else h=contour[f];for(c=0;c<vertices.length;c++)if(vertices[c].equals(contour[f]))break;for(g=0;g<vertices.length;g++)if(vertices[g].equals(contour[f-1]))break;this.faces.push(new THREE.Face4(c,g,g+e,c+e))}this.computeCentroids();this.computeFaceNormals()};
|
|
|
+THREE.Text.prototype=new THREE.Geometry;THREE.Text.prototype.constructor=THREE.Text;
|
|
|
+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){if(a.length<3)console.log("not valid polygon");
|
|
|
+else{var b=[],c,e,f=[],g;for(g in a)c=a[g],b.push(c.x+","+c.y);c=b[0];c=b.slice(1).indexOf(c);c<b.length&&(c++,e=a.slice(0,c));for(holes=[];c<b.length;){firstIndex=c+1;c=b[firstIndex];c=b.slice(firstIndex+1).indexOf(c)+firstIndex;if(c<=firstIndex)break;var h=a.slice(firstIndex,c+1);this.Triangulate.area(h)<0?(f.push({shape:e,holes:holes}),e=h,holes=[]):holes.push(h);c++}f.push({shape:e,holes:holes});var b=[],k;for(k in f){c=f[k];e=c.shape;holes=c.holes;for(var j in holes){var a=holes[j],h=Number.POSITIVE_INFINITY,
|
|
|
+m,l,n;for(n in a){var t=a[n];for(g in e)d=t.distanceTo(e[g]),d<h&&(h=d,m=n,l=g)}prevShapeVert=l-1>=0?l-1:e.length-1;nextShapeVert=l+1<e.length?l+1:0;prevHoleVert=m-1>=0?m-1:a.length-1;nextHoleVert=m+1<a.length?m+1:0;var h=e.slice(0,l),t=e.slice(l),p=a.slice(m),u=a.slice(0,m);b.push(a[m]);b.push(e[l]);b.push(e[prevShapeVert]);b.push(a[m]);b.push(a[prevHoleVert]);b.push(e[l]);c.shape=h.concat(p).concat(u).concat(t)}}a=[];g=[];m=0;for(k in f){c=f[k];e=c.shape;a=a.concat(e);l=THREE.FontUtils.Triangulate(e,
|
|
|
+!0);for(var v in l)j=l[v],j[0]+=m,j[1]+=m,j[2]+=m;g=g.concat(l);m+=e.length}for(v=0;v<b.length/3;v++){j=[];for(f=0;f<3;f++)for(e=0;e<a.length;e++)if(a[e].equals(b[v*3+f])){j.push(e);break}g.push(j)}return{points:a,faces:g}}},drawText:function(a){pts=[];for(var b=this.getFace(),c=this.size/b.resolution,e=0,f=String(a).split(""),g=f.length,a=0;a<g;a++)e+=this.extractGlyphPoints(f[a],b,c,e);width=e/2;for(var h in pts)pts[h].x-=width;b=this.extractPoints(pts);b.contour=pts;return b},b2p0:function(a,b){return(1-
|
|
|
+a)*(1-a)*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=b.glyphs[a]||b.glyphs[ctxt.options.fallbackCharacter];
|
|
|
+if(k){if(k.o){b=k._cachedOutline||(k._cachedOutline=k.o.split(" "));h=b.length;for(a=0;a<h;)switch(f=b[a++],f){case "m":x=b[a++]*c+e;y=b[a++]*c;pts.push(new THREE.Vector2(x,y));break;case "l":x=b[a++]*c+e;y=b[a++]*c;pts.push(new THREE.Vector2(x,y));break;case "q":f=b[a++]*c+e;g=b[a++]*c;cpx1=b[a++]*c+e;cpy1=b[a++]*c;var j=pts[pts.length-1];if(j){cpx0=j.x;cpy0=j.y;for(var j=1,m=this.divisions;j<=m;j++){var l=j/m,n=THREE.FontUtils.b2(l,cpx0,cpx1,f),l=THREE.FontUtils.b2(l,cpy0,cpy1,g);pts.push(new THREE.Vector2(n,
|
|
|
+l))}}break;case "b":if(f=b[a++]*c+e,g=b[a++]*c,cpx1=b[a++]*c+e,cpy1=b[a++]*-c,cpx2=b[a++]*c+e,cpy2=b[a++]*-c,j=pts[pts.length-1]){cpx0=j.x;cpy0=j.y;j=1;for(m=this.divisions;j<=m;j++)l=j/m,n=THREE.FontUtils.b3(l,cpx0,cpx1,cpx2,f),l=THREE.FontUtils.b3(l,cpy0,cpy1,cpy2,g),pts.push(new THREE.Vector2(n,l))}}}return k.ha*c}}};
|
|
|
+(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=[],g=a.length;if(g<3)return null;var h=[],k=[],j;if(0<b(a))for(j=0;j<g;j++)h[j]=j;else for(j=0;j<g;j++)h[j]=g-1-j;var m=2*g,l;l=0;for(j=g-1;g>2;){if(0>=m--)return console.log("Warning, unable to triangulate polygon!"),null;var n=j;g<=n&&(n=0);j=n+1;g<=j&&(j=0);var t=j+1;g<=t&&(t=0);var p;a:{p=a;var u=n,v=j,w=t,B=g,z=h,o=void 0,A=void 0,C=void 0,F=
|
|
|
+void 0,G=void 0,H=void 0,I=void 0,E=void 0,M=void 0,A=p[z[u]].x,C=p[z[u]].y,F=p[z[v]].x,G=p[z[v]].y,H=p[z[w]].x,I=p[z[w]].y;if(1.0E-10>(F-A)*(I-C)-(G-C)*(H-A))p=!1;else{for(o=0;o<B;o++)if(!(o==u||o==v||o==w)){var E=p[z[o]].x,M=p[z[o]].y,K=void 0,N=void 0,L=void 0,O=void 0,D=void 0,J=void 0,P=void 0,Q=void 0,S=void 0,T=void 0,U=void 0,V=void 0,K=L=D=void 0,K=H-F,N=I-G,L=A-H,O=C-I,D=F-A,J=G-C,P=E-A,Q=M-C,S=E-F,T=M-G,U=E-H,V=M-I,K=K*T-N*S,D=D*Q-J*P,L=L*V-O*U;if(K>=0&&L>=0&&D>=0){p=!1;break a}}p=!0}}if(p){m=
|
|
|
+h[n];p=h[j];u=h[t];f.push(a[m]);f.push(a[p]);f.push(a[u]);k.push([h[n],h[j],h[t]]);l++;n=j;for(t=j+1;t<g;n++,t++)h[n]=h[t];g--;m=2*g}}if(e)return k;return f};a.Triangulate.area=b;return a})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
|
|
|
+THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";
|
|
|
+this.statusDomElement.innerHTML=b},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,b,c){a.materials=[];for(var e=0;e<b.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(b[e],c)]},createMaterial:function(a,b){function c(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==a}function e(a,b){var e=new Image;e.onload=function(){if(!c(this.width)||!c(this.height)){var b=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),e=Math.pow(2,Math.round(Math.log(this.height)/
|
|
|
+Math.LN2));a.image.width=b;a.image.height=e;a.image.getContext("2d").drawImage(this,0,0,b,e)}else a.image=this;a.needsUpdate=!0};e.src=b}var f,g,h;f="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,wireframe:a.wireframe};a.shading&&(a.shading=="Phong"?f="MeshPhongMaterial":a.shading=="Basic"&&(f="MeshBasicMaterial"));if(a.blending)if(a.blending=="Additive")g.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")g.blending=THREE.SubtractiveBlending;else if(a.blending==
|
|
|
+"Multiply")g.blending=THREE.MultiplyBlending;if(a.transparent!==void 0||a.opacity<1)g.transparent=a.transparent;if(a.depthTest!==void 0)g.depthTest=a.depthTest;if(a.vertexColors!==void 0)if(a.vertexColors=="face")g.vertexColors=THREE.FaceColors;else if(a.vertexColors)g.vertexColors=THREE.VertexColors;if(a.mapDiffuse&&b)h=document.createElement("canvas"),g.map=new THREE.Texture(h),g.map.sourceFile=a.mapDiffuse,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.mapLightmap&&b)h=document.createElement("canvas"),g.lightMap=new THREE.Texture(h),g.lightMap.sourceFile=a.mapLightmap,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,p,u,v,w,B,z,o,A=a.faces;n=a.vertices;var C=a.normals,F=a.colors,G=0;for(b=0;b<a.uvs.length;b++)a.uvs[b].length&&G++;for(b=0;b<G;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=A.length;m<l;){c=A[m++];n=c&1;j=c&2;b=c&4;f=c&8;p=c&16;t=c&32;v=c&64;c&=128;n?(w=new THREE.Face4,w.a=A[m++],w.b=A[m++],w.c=A[m++],w.d=A[m++],n=4):(w=new THREE.Face3,w.a=A[m++],w.b=A[m++],w.c=A[m++],n=3);if(j)j=A[m++],w.materials=e.materials[j];j=e.faces.length;if(b)for(b=0;b<G;b++)B=a.uvs[b],u=A[m++],o=B[u*2],u=B[u*2+1],e.faceUvs[b][j]=new THREE.UV(o,u);if(f)for(b=0;b<G;b++){B=a.uvs[b];z=[];for(f=0;f<n;f++)u=A[m++],o=B[u*2],u=B[u*2+1],z[f]=
|
|
|
+new THREE.UV(o,u);e.faceVertexUvs[b][j]=z}if(p)p=A[m++]*3,f=new THREE.Vector3,f.x=C[p++],f.y=C[p++],f.z=C[p],w.normal=f;if(t)for(b=0;b<n;b++)p=A[m++]*3,f=new THREE.Vector3,f.x=C[p++],f.y=C[p++],f.z=C[p],w.vertexNormals.push(f);if(v)t=A[m++],t=new THREE.Color(F[t]),w.color=t;if(c)for(b=0;b<n;b++)t=A[m++],t=new THREE.Color(F[t]),w.vertexColors.push(t);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,t,p,u;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=[];p=e.morphTargets[b].vertices;u=a.morphTargets[b].vertices;j=0;for(m=u.length;j<m;j+=3)l=u[j]*c,n=u[j+1]*
|
|
|
+c,t=u[j+2]*c,p.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],
|
|
|
+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+F);g=f(a,c+G);c=j(a,c+H);THREE.BinaryLoader.prototype.f3(B,b,e,g,c)}function t(c){var b,e,g,h,l,m;b=f(a,c);e=f(a,c+F);g=f(a,c+G);h=j(a,c+H);l=f(a,c+I);m=f(a,c+E);c=f(a,c+M);THREE.BinaryLoader.prototype.f3n(B,A,b,e,g,h,l,m,c)}function p(c){var b,e,g,h;b=f(a,c);e=f(a,c+K);g=f(a,c+N);h=f(a,c+L);c=j(a,c+O);THREE.BinaryLoader.prototype.f4(B,b,e,g,h,c)}function u(c){var b,e,g,h,l,m,n,o;b=f(a,c);e=f(a,c+K);g=f(a,c+N);h=f(a,c+L);l=j(a,
|
|
|
+c+O);m=f(a,c+D);n=f(a,c+J);o=f(a,c+P);c=f(a,c+Q);THREE.BinaryLoader.prototype.f4n(B,A,b,e,g,h,l,m,n,o,c)}function v(c){var b,e;b=f(a,c);e=f(a,c+S);c=f(a,c+T);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],C[b*2],C[b*2+1],C[e*2],C[e*2+1],C[c*2],C[c*2+1])}function w(c){var b,e,g;b=f(a,c);e=f(a,c+U);g=f(a,c+V);c=f(a,c+aa);THREE.BinaryLoader.prototype.uv4(B.faceVertexUvs[0],C[b*2],C[b*2+1],C[e*2],C[e*2+1],C[g*2],C[g*2+1],C[c*2],C[c*2+1])}var B=this,z=0,o,A=[],C=[],F,G,H,I,E,M,K,N,L,O,D,J,P,Q,S,T,
|
|
|
+U,V,aa,W,X,Y,Z,$,R;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(B,e,c);o={signature:a.substr(z,8),header_bytes:l(a,z+8),vertex_coordinate_bytes:l(a,z+9),normal_coordinate_bytes:l(a,z+10),uv_coordinate_bytes:l(a,z+11),vertex_index_bytes:l(a,z+12),normal_index_bytes:l(a,z+13),uv_index_bytes:l(a,z+14),material_index_bytes:l(a,z+15),nvertices:f(a,z+16),nnormals:f(a,z+16+4),nuvs:f(a,z+16+8),ntri_flat:f(a,z+16+12),ntri_smooth:f(a,z+16+16),ntri_flat_uv:f(a,z+16+20),ntri_smooth_uv:f(a,
|
|
|
+z+16+24),nquad_flat:f(a,z+16+28),nquad_smooth:f(a,z+16+32),nquad_flat_uv:f(a,z+16+36),nquad_smooth_uv:f(a,z+16+40)};z+=o.header_bytes;F=o.vertex_index_bytes;G=o.vertex_index_bytes*2;H=o.vertex_index_bytes*3;I=o.vertex_index_bytes*3+o.material_index_bytes;E=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;M=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;K=o.vertex_index_bytes;N=o.vertex_index_bytes*2;L=o.vertex_index_bytes*3;O=o.vertex_index_bytes*4;D=o.vertex_index_bytes*
|
|
|
+4+o.material_index_bytes;J=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes;P=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;Q=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;S=o.uv_index_bytes;T=o.uv_index_bytes*2;U=o.uv_index_bytes;V=o.uv_index_bytes*2;aa=o.uv_index_bytes*3;c=o.vertex_index_bytes*3+o.material_index_bytes;R=o.vertex_index_bytes*4+o.material_index_bytes;W=o.ntri_flat*c;X=o.ntri_smooth*(c+o.normal_index_bytes*3);Y=o.ntri_flat_uv*
|
|
|
+(c+o.uv_index_bytes*3);Z=o.ntri_smooth_uv*(c+o.normal_index_bytes*3+o.uv_index_bytes*3);$=o.nquad_flat*R;c=o.nquad_smooth*(R+o.normal_index_bytes*4);R=o.nquad_flat_uv*(R+o.uv_index_bytes*4);z+=function(c){for(var e,f,g,j=o.vertex_coordinate_bytes*3,k=c+o.nvertices*j;c<k;c+=j)e=b(a,c),f=b(a,c+o.vertex_coordinate_bytes),g=b(a,c+o.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(B,e,f,g);return o.nvertices*j}(z);z+=function(c){for(var b,e,f,g=o.normal_coordinate_bytes*3,h=c+o.nnormals*g;c<h;c+=
|
|
|
+g)b=m(a,c),e=m(a,c+o.normal_coordinate_bytes),f=m(a,c+o.normal_coordinate_bytes*2),A.push(b/127,e/127,f/127);return o.nnormals*g}(z);z+=function(c){for(var e,f,g=o.uv_coordinate_bytes*2,j=c+o.nuvs*g;c<j;c+=g)e=b(a,c),f=b(a,c+o.uv_coordinate_bytes),C.push(e,f);return o.nuvs*g}(z);W=z+W;X=W+X;Y=X+Y;Z=Y+Z;$=Z+$;c=$+c;R=c+R;(function(a){var c,b=o.vertex_index_bytes*3+o.material_index_bytes,e=b+o.uv_index_bytes*3,f=a+o.ntri_flat_uv*e;for(c=a;c<f;c+=e)n(c),v(c+b);return f-a})(X);(function(a){var c,b=o.vertex_index_bytes*
|
|
|
+3+o.material_index_bytes+o.normal_index_bytes*3,e=b+o.uv_index_bytes*3,f=a+o.ntri_smooth_uv*e;for(c=a;c<f;c+=e)t(c),v(c+b);return f-a})(Y);(function(a){var c,b=o.vertex_index_bytes*4+o.material_index_bytes,e=b+o.uv_index_bytes*4,f=a+o.nquad_flat_uv*e;for(c=a;c<f;c+=e)p(c),w(c+b);return f-a})(c);(function(a){var c,b=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,e=b+o.uv_index_bytes*4,f=a+o.nquad_smooth_uv*e;for(c=a;c<f;c+=e)u(c),w(c+b);return f-a})(R);(function(a){var c,b=o.vertex_index_bytes*
|
|
|
+3+o.material_index_bytes,e=a+o.ntri_flat*b;for(c=a;c<e;c+=b)n(c);return e-a})(z);(function(a){var c,b=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,e=a+o.ntri_smooth*b;for(c=a;c<e;c+=b)t(c);return e-a})(W);(function(a){var c,b=o.vertex_index_bytes*4+o.material_index_bytes,e=a+o.nquad_flat*b;for(c=a;c<e;c+=b)p(c);return e-a})(Z);(function(a){var c,b=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,e=a+o.nquad_smooth*b;for(c=a;c<e;c+=b)u(c);return e-a})($);
|
|
|
+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],p=b[m*3],u=b[m*3+1],m=b[m*3+2],v=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,t,j),new THREE.Vector3(p,u,m),new THREE.Vector3(v,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(p in E.objects)if(!D.objects[p])if(z=E.objects[p],z.geometry!==void 0){if(F=D.geometries[z.geometry]){I=[];for(Q=0;Q<z.materials.length;Q++)I[Q]=D.materials[z.materials[Q]];o=z.position;r=z.rotation;q=z.quaternion;s=z.scale;q=0;I.length==0&&(I[0]=new THREE.MeshFaceMaterial);
|
|
|
+I.length>1&&(I=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(F,I);object.name=p;object.position.set(o[0],o[1],o[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=z.visible;D.scene.addObject(object);D.objects[p]=object;if(z.meshCollider){var a=THREE.CollisionUtils.MeshColliderWBox(object);D.scene.collisions.colliders.push(a)}if(z.castsShadow)a=new THREE.ShadowVolume(F),D.scene.addChild(a),
|
|
|
+a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;z.trigger&&z.trigger.toLowerCase()!="none"&&(a={type:z.trigger,object:z},D.triggers[object.name]=a)}}else o=z.position,r=z.rotation,q=z.quaternion,s=z.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(o[0],o[1],o[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=z.visible!==void 0?z.visible:!1,D.scene.addObject(object),
|
|
|
+D.objects[p]=object,D.empties[p]=object,z.trigger&&z.trigger.toLowerCase()!="none"&&(a={type:z.trigger,object:z},D.triggers[object.name]=a)}function j(a){return function(b){D.geometries[a]=b;k();K-=1;c.onLoadComplete();l()}}function m(a){return function(c){D.geometries[a]=c}}function l(){c.callbackProgress({totalModels:L,totalTextures:O,loadedModels:L-K,loadedTextures:O-N},D);c.onLoadProgress();K==0&&N==0&&b(D)}var n,t,p,u,v,w,B,z,o,A,C,F,G,H,I,E,M,K,N,L,O,D;E=a.data;a=new THREE.BinaryLoader;M=new THREE.JSONLoader;
|
|
|
+N=K=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var J=!1;for(p in E.objects)if(z=E.objects[p],z.meshCollider){J=!0;break}if(J)D.scene.collisions=new THREE.CollisionSystem;if(E.transform){J=E.transform.position;A=E.transform.rotation;var P=E.transform.scale;J&&D.scene.position.set(J[0],J[1],J[2]);A&&D.scene.rotation.set(A[0],A[1],A[2]);P&&D.scene.scale.set(P[0],P[1],P[2]);(J||A||P)&&D.scene.updateMatrix()}J=function(){N-=
|
|
|
+1;l();c.onLoadComplete()};for(v in E.cameras){A=E.cameras[v];if(A.type=="perspective")G=new THREE.Camera(A.fov,A.aspect,A.near,A.far);else if(A.type=="ortho")G=new THREE.Camera,G.projectionMatrix=THREE.Matrix4.makeOrtho(A.left,A.right,A.top,A.bottom,A.near,A.far);o=A.position;A=A.target;G.position.set(o[0],o[1],o[2]);G.target.position.set(A[0],A[1],A[2]);D.cameras[v]=G}for(u in E.lights){v=E.lights[u];G=v.color!==void 0?v.color:16777215;A=v.intensity!==void 0?v.intensity:1;if(v.type=="directional")o=
|
|
|
+v.direction,light=new THREE.DirectionalLight(G,A),light.position.set(o[0],o[1],o[2]),light.position.normalize();else if(v.type=="point")o=v.position,light=new THREE.PointLight(G,A),light.position.set(o[0],o[1],o[2]);D.scene.addLight(light);D.lights[u]=light}for(w in E.fogs)u=E.fogs[w],u.type=="linear"?H=new THREE.Fog(0,u.near,u.far):u.type=="exp2"&&(H=new THREE.FogExp2(0,u.density)),A=u.color,H.color.setRGB(A[0],A[1],A[2]),D.fogs[w]=H;if(D.cameras&&E.defaults.camera)D.currentCamera=D.cameras[E.defaults.camera];
|
|
|
+if(D.fogs&&E.defaults.fog)D.scene.fog=D.fogs[E.defaults.fog];A=E.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(A[0],A[1],A[2]);D.bgColorAlpha=E.defaults.bgalpha;for(n in E.geometries)if(w=E.geometries[n],w.type=="bin_mesh"||w.type=="ascii_mesh")K+=1,c.onLoadStart();L=K;for(n in E.geometries)w=E.geometries[n],w.type=="cube"?(F=new THREE.Cube(w.width,w.height,w.depth,w.segmentsWidth,w.segmentsHeight,w.segmentsDepth,null,w.flipped,w.sides),D.geometries[n]=F):w.type=="plane"?(F=new THREE.Plane(w.width,
|
|
|
+w.height,w.segmentsWidth,w.segmentsHeight),D.geometries[n]=F):w.type=="sphere"?(F=new THREE.Sphere(w.radius,w.segmentsWidth,w.segmentsHeight),D.geometries[n]=F):w.type=="cylinder"?(F=new THREE.Cylinder(w.numSegs,w.topRad,w.botRad,w.height,w.topOffset,w.botOffset),D.geometries[n]=F):w.type=="torus"?(F=new THREE.Torus(w.radius,w.tube,w.segmentsR,w.segmentsT),D.geometries[n]=F):w.type=="icosahedron"?(F=new THREE.Icosahedron(w.subdivisions),D.geometries[n]=F):w.type=="bin_mesh"?a.load({model:e(w.url,
|
|
|
+E.urlBaseType),callback:j(n)}):w.type=="ascii_mesh"?M.load({model:e(w.url,E.urlBaseType),callback:j(n)}):w.type=="embedded_mesh"&&(w=E.embeds[w.id])&&M.createModel(w,m(n),"");for(B in E.textures)if(n=E.textures[B],n.url instanceof Array){N+=n.url.length;for(a=0;a<n.url.length;a++)c.onLoadStart()}else N+=1,c.onLoadStart();O=N;for(B in E.textures){n=E.textures[B];if(n.mapping!=void 0&&THREE[n.mapping]!=void 0)n.mapping=new THREE[n.mapping];if(n.url instanceof Array){for(var a=[],Q=0;Q<n.url.length;Q++)a[Q]=
|
|
|
+e(n.url[Q],E.urlBaseType);a=THREE.ImageUtils.loadTextureCube(a,n.mapping,J)}else{a=THREE.ImageUtils.loadTexture(e(n.url,E.urlBaseType),n.mapping,J);if(THREE[n.minFilter]!=void 0)a.minFilter=THREE[n.minFilter];if(THREE[n.magFilter]!=void 0)a.magFilter=THREE[n.magFilter]}D.textures[B]=a}for(t in E.materials){B=E.materials[t];for(C in B.parameters)if(C=="envMap"||C=="map"||C=="lightMap")B.parameters[C]=D.textures[B.parameters[C]];else if(C=="shading")B.parameters[C]=B.parameters[C]=="flat"?THREE.FlatShading:
|
|
|
+THREE.SmoothShading;else if(C=="blending")B.parameters[C]=THREE[B.parameters[C]]?THREE[B.parameters[C]]:THREE.NormalBlending;else if(C=="combine")B.parameters[C]=B.parameters[C]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(C=="vertexColors")if(B.parameters[C]=="face")B.parameters[C]=THREE.FaceColors;else if(B.parameters[C])B.parameters[C]=THREE.VertexColors;if(B.parameters.opacity!==void 0&&B.parameters.opacity<1)B.parameters.transparent=!0;B=new THREE[B.type](B.parameters);
|
|
|
+D.materials[t]=B}k();c.callbackSync(D)}}};
|
|
|
+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,p=g+this.yd+this.zd,u=j+this.yd+this.zd,v=0,w=this.field[g],B=this.field[j],z=this.field[m],o=this.field[n],A=this.field[l],C=this.field[t],F=this.field[p],G=this.field[u];w<h&&(v|=1);B<h&&(v|=2);z<h&&(v|=8);o<h&&(v|=4);A<h&&(v|=16);C<h&&(v|=32);F<h&&(v|=128);G<h&&(v|=64);var H=THREE.edgeTable[v];if(H==0)return 0;var I=this.delta,
|
|
|
+E=a+I,M=b+I,I=f+I;H&1&&(this.compNorm(g),this.compNorm(j),this.VIntX(g*3,this.vlist,this.nlist,0,h,a,b,f,w,B));H&2&&(this.compNorm(j),this.compNorm(n),this.VIntY(j*3,this.vlist,this.nlist,3,h,E,b,f,B,o));H&4&&(this.compNorm(m),this.compNorm(n),this.VIntX(m*3,this.vlist,this.nlist,6,h,a,M,f,z,o));H&8&&(this.compNorm(g),this.compNorm(m),this.VIntY(g*3,this.vlist,this.nlist,9,h,a,b,f,w,z));H&16&&(this.compNorm(l),this.compNorm(t),this.VIntX(l*3,this.vlist,this.nlist,12,h,a,b,I,A,C));H&32&&(this.compNorm(t),
|
|
|
+this.compNorm(u),this.VIntY(t*3,this.vlist,this.nlist,15,h,E,b,I,C,G));H&64&&(this.compNorm(p),this.compNorm(u),this.VIntX(p*3,this.vlist,this.nlist,18,h,a,M,I,F,G));H&128&&(this.compNorm(l),this.compNorm(p),this.VIntY(l*3,this.vlist,this.nlist,21,h,a,b,I,A,F));H&256&&(this.compNorm(g),this.compNorm(l),this.VIntZ(g*3,this.vlist,this.nlist,24,h,a,b,f,w,A));H&512&&(this.compNorm(j),this.compNorm(t),this.VIntZ(j*3,this.vlist,this.nlist,27,h,E,b,f,B,C));H&1024&&(this.compNorm(n),this.compNorm(u),this.VIntZ(n*
|
|
|
+3,this.vlist,this.nlist,30,h,E,M,f,o,G));H&2048&&(this.compNorm(m),this.compNorm(p),this.VIntZ(m*3,this.vlist,this.nlist,33,h,a,M,f,z,F));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+
|
|
|
+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 p=Math.floor(l-k);p<1&&(p=1);k=Math.floor(l+k);k>this.size-1&&(k=this.size-
|
|
|
+1);for(var u,v,w,B,z,o;n<j;n++){l=this.size2*n;v=n/this.size-f;z=v*v;for(v=t;v<m;v++){w=l+this.size*v;u=v/this.size-b;o=u*u;for(u=p;u<k;u++)B=u/this.size-a,B=g/(1.0E-6+B*B+o+z)-h,B>0&&(this.field[w+u]+=B)}}};this.addPlaneX=function(a,b){var f,g,h,k,j,m=this.size,l=this.yd,n=this.zd,t=this.field,p=m*Math.sqrt(a/b);p>m&&(p=m);for(f=0;f<p;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,p=this.field,u=l*Math.sqrt(a/b);u>l&&(u=l);for(g=0;g<u;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++)p[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,p;for(h=0;h<g.count;h++)t=h*3,l=t+1,p=t+2,k=g.positionArray[t],
|
|
|
+j=g.positionArray[l],m=g.positionArray[p],n=new THREE.Vector3(k,j,m),k=g.normalArray[t],j=g.normalArray[l],m=g.normalArray[p],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,p=t+2,n=f[t],k=f[l],j=f[p],t=new THREE.Face3(t,l,p,[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;
|
|
|
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]);
|
|
@@ -188,21 +196,24 @@ THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0
|
|
|
4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
|
|
|
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
|
|
|
2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);
|
|
|
-THREE.Trident=function(a){function c(f){return new THREE.Mesh(new THREE.Cylinder(30,0.1,a.length/20,a.length/5),new THREE.MeshBasicMaterial({color:f}))}function b(f,h){var j=new THREE.Geometry;j.vertices=[new THREE.Vertex,new THREE.Vertex(f)];return new THREE.Line(j,new THREE.LineBasicMaterial({color:h}))}THREE.Object3D.call(this);var e=Math.PI/2,g;a=a||THREE.Trident.defaultParams;if(a!==THREE.Trident.defaultParams)for(g in THREE.Trident.defaultParams)a.hasOwnProperty(g)||(a[g]=THREE.Trident.defaultParams[g]);
|
|
|
-this.scale=new THREE.Vector3(a.scale,a.scale,a.scale);this.addChild(b(new THREE.Vector3(a.length,0,0),a.xAxisColor));this.addChild(b(new THREE.Vector3(0,a.length,0),a.yAxisColor));this.addChild(b(new THREE.Vector3(0,0,a.length),a.zAxisColor));if(a.showArrows){g=c(a.xAxisColor);g.rotation.y=-e;g.position.x=a.length;this.addChild(g);g=c(a.yAxisColor);g.rotation.x=e;g.position.y=a.length;this.addChild(g);g=c(a.zAxisColor);g.rotation.y=Math.PI;g.position.z=a.length;this.addChild(g)}};
|
|
|
-THREE.Trident.prototype=new THREE.Object3D;THREE.Trident.prototype.constructor=THREE.Trident;THREE.Trident.defaultParams={xAxisColor:16711680,yAxisColor:65280,zAxisColor:255,showArrows:!0,length:100,scale:1};THREE.PlaneCollider=function(a,c){this.point=a;this.normal=c};THREE.SphereCollider=function(a,c){this.center=a;this.radius=c;this.radiusSq=c*c};THREE.BoxCollider=function(a,c){this.min=a;this.max=c;this.dynamic=!0;this.normal=new THREE.Vector3};
|
|
|
-THREE.MeshCollider=function(a,c){this.mesh=a;this.box=c;this.numFaces=this.mesh.geometry.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[]};THREE.Collisions=new THREE.CollisionSystem;THREE.CollisionSystem.prototype.merge=function(a){this.colliders=this.colliders.concat(a.colliders);this.hits=this.hits.concat(a.hits)};
|
|
|
-THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var c,b,e,g,f=0;c=0;for(b=this.colliders.length;c<b;c++){g=this.colliders[c];e=this.rayCast(a,g);if(e<Number.MAX_VALUE){g.distance=e;e>f?this.hits.push(g):this.hits.unshift(g);f=e}}return this.hits};
|
|
|
-THREE.CollisionSystem.prototype.rayCastNearest=function(a){var c=this.rayCastAll(a);if(c.length==0)return null;for(var b=0;c[b]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,c[b]);if(e.dist<Number.MAX_VALUE){c[b].distance=e.dist;c[b].faceIndex=e.faceIndex;break}b++}if(b>c.length)return null;return c[b]};
|
|
|
-THREE.CollisionSystem.prototype.rayCast=function(a,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(a,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(a,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(a,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(a,c.box)};
|
|
|
-THREE.CollisionSystem.prototype.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),e=Number.MAX_VALUE,g,f=0;f<c.numFaces;f++){var h=c.mesh.geometry.faces[f],j=c.mesh.geometry.vertices[h.a].position,k=c.mesh.geometry.vertices[h.b].position,m=c.mesh.geometry.vertices[h.c].position,l=h instanceof THREE.Face4?c.mesh.geometry.vertices[h.d].position:null;if(h instanceof THREE.Face3){h=this.rayTriangle(b,j,k,m,e,this.collisionNormal);if(h<e){e=h;g=f;c.normal.copy(this.collisionNormal);c.normal.normalize()}}else if(h instanceof
|
|
|
-THREE.Face4){h=this.rayTriangle(b,j,k,l,e,this.collisionNormal);if(h<e){e=h;g=f;c.normal.copy(this.collisionNormal);c.normal.normalize()}h=this.rayTriangle(b,k,m,l,e,this.collisionNormal);if(h<e){e=h;g=f;c.normal.copy(this.collisionNormal);c.normal.normalize()}}}return{dist:e,faceIndex:g}};
|
|
|
-THREE.CollisionSystem.prototype.rayTriangle=function(a,c,b,e,g,f){var h=THREE.CollisionSystem.__v1,j=THREE.CollisionSystem.__v2;f.set(0,0,0);h.sub(b,c);j.sub(e,b);f.cross(h,j);j=f.dot(a.direction);if(!(j<0))return Number.MAX_VALUE;h=f.dot(c)-f.dot(a.origin);if(!(h<=0))return Number.MAX_VALUE;if(!(h>=j*g))return Number.MAX_VALUE;h/=j;j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(h);j.addSelf(a.origin);if(Math.abs(f.x)>Math.abs(f.y))if(Math.abs(f.x)>Math.abs(f.z)){a=j.y-c.y;f=b.y-
|
|
|
-c.y;g=e.y-c.y;j=j.z-c.z;b=b.z-c.z;e=e.z-c.z}else{a=j.x-c.x;f=b.x-c.x;g=e.x-c.x;j=j.y-c.y;b=b.y-c.y;e=e.y-c.y}else if(Math.abs(f.y)>Math.abs(f.z)){a=j.x-c.x;f=b.x-c.x;g=e.x-c.x;j=j.z-c.z;b=b.z-c.z;e=e.z-c.z}else{a=j.x-c.x;f=b.x-c.x;g=e.x-c.x;j=j.y-c.y;b=b.y-c.y;e=e.y-c.y}c=f*e-b*g;if(c==0)return Number.MAX_VALUE;c=1/c;e=(a*e-j*g)*c;if(!(e>=0))return Number.MAX_VALUE;c*=f*j-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return h};
|
|
|
-THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,b);var e=THREE.CollisionSystem.__r;e.origin.copy(a.origin);e.direction.copy(a.direction);b.multiplyVector3(e.origin);b.rotateAxis(e.direction);e.direction.normalize();return e};
|
|
|
-THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;if(c.dynamic&&c.mesh&&c.mesh.matrixWorld)b=this.makeRayLocal(a,c.mesh);else{b=THREE.CollisionSystem.__r;b.origin.copy(a.origin);b.direction.copy(a.direction)}var e=0,g=0,f=0,h=0,j=0,k=0,m=!0;if(b.origin.x<c.min.x){e=c.min.x-b.origin.x;e/=b.direction.x;m=!1;h=-1}else if(b.origin.x>c.max.x){e=c.max.x-b.origin.x;e/=b.direction.x;m=!1;h=1}if(b.origin.y<c.min.y){g=c.min.y-b.origin.y;g/=b.direction.y;m=!1;j=-1}else if(b.origin.y>c.max.y){g=c.max.y-
|
|
|
-b.origin.y;g/=b.direction.y;m=!1;j=1}if(b.origin.z<c.min.z){f=c.min.z-b.origin.z;f/=b.direction.z;m=!1;k=-1}else if(b.origin.z>c.max.z){f=c.max.z-b.origin.z;f/=b.direction.z;m=!1;k=1}if(m)return-1;m=0;if(g>e){m=1;e=g}if(f>e){m=2;e=f}switch(m){case 0:j=b.origin.y+b.direction.y*e;if(j<c.min.y||j>c.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(h,0,0);break;case 1:h=b.origin.x+b.direction.x*e;if(h<c.min.x||h>c.max.x)return Number.MAX_VALUE;
|
|
|
-b=b.origin.z+b.direction.z*e;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(0,j,0);break;case 2:h=b.origin.x+b.direction.x*e;if(h<c.min.x||h>c.max.x)return Number.MAX_VALUE;j=b.origin.y+b.direction.y*e;if(j<c.min.y||j>c.max.y)return Number.MAX_VALUE;c.normal.set(0,0,k)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),e=c.point.dot(c.normal);if(b<0)b=(e-a.origin.dot(c.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE};
|
|
|
-THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq<c.radiusSq)return-1;var e=b.dot(a.direction.clone());if(e<=0)return Number.MAX_VALUE;b=c.radiusSq-(b.lengthSq()-e*e);if(b>=0)return Math.abs(e)-Math.sqrt(b);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4;
|
|
|
-THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var c=a.geometry.boundingBox,b=new THREE.Vector3(c.x[0],c.y[0],c.z[0]);c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]);b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c};
|
|
|
+THREE.Trident=function(a){function b(b){return new THREE.Mesh(new THREE.Cylinder(30,0.1,a.length/20,a.length/5),new THREE.MeshBasicMaterial({color:b}))}function c(a,b){var c=new THREE.Geometry;c.vertices=[new THREE.Vertex,new THREE.Vertex(a)];return new THREE.Line(c,new THREE.LineBasicMaterial({color:b}))}THREE.Object3D.call(this);var e=Math.PI/2,f,a=a||THREE.Trident.defaultParams;if(a!==THREE.Trident.defaultParams)for(f in THREE.Trident.defaultParams)a.hasOwnProperty(f)||(a[f]=THREE.Trident.defaultParams[f]);
|
|
|
+this.scale=new THREE.Vector3(a.scale,a.scale,a.scale);this.addChild(c(new THREE.Vector3(a.length,0,0),a.xAxisColor));this.addChild(c(new THREE.Vector3(0,a.length,0),a.yAxisColor));this.addChild(c(new THREE.Vector3(0,0,a.length),a.zAxisColor));if(a.showArrows)f=b(a.xAxisColor),f.rotation.y=-e,f.position.x=a.length,this.addChild(f),f=b(a.yAxisColor),f.rotation.x=e,f.position.y=a.length,this.addChild(f),f=b(a.zAxisColor),f.rotation.y=Math.PI,f.position.z=a.length,this.addChild(f)};
|
|
|
+THREE.Trident.prototype=new THREE.Object3D;THREE.Trident.prototype.constructor=THREE.Trident;THREE.Trident.defaultParams={xAxisColor:16711680,yAxisColor:65280,zAxisColor:255,showArrows:!0,length:100,scale:1};THREE.PlaneCollider=function(a,b){this.point=a;this.normal=b};THREE.SphereCollider=function(a,b){this.center=a;this.radius=b;this.radiusSq=b*b};THREE.BoxCollider=function(a,b){this.min=a;this.max=b;this.dynamic=!0;this.normal=new THREE.Vector3};
|
|
|
+THREE.MeshCollider=function(a,b){this.mesh=a;this.box=b;this.numFaces=this.mesh.geometry.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[]};THREE.Collisions=new THREE.CollisionSystem;THREE.CollisionSystem.prototype.merge=function(a){this.colliders=this.colliders.concat(a.colliders);this.hits=this.hits.concat(a.hits)};
|
|
|
+THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var b,c,e,f,g=0;b=0;for(c=this.colliders.length;b<c;b++)if(f=this.colliders[b],e=this.rayCast(a,f),e<Number.MAX_VALUE)f.distance=e,e>g?this.hits.push(f):this.hits.unshift(f),g=e;return this.hits};
|
|
|
+THREE.CollisionSystem.prototype.rayCastNearest=function(a){var b=this.rayCastAll(a);if(b.length==0)return null;for(var c=0;b[c]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,b[c]);if(e.dist<Number.MAX_VALUE){b[c].distance=e.dist;b[c].faceIndex=e.faceIndex;break}c++}if(c>b.length)return null;return b[c]};
|
|
|
+THREE.CollisionSystem.prototype.rayCast=function(a,b){if(b instanceof THREE.PlaneCollider)return this.rayPlane(a,b);else if(b instanceof THREE.SphereCollider)return this.raySphere(a,b);else if(b instanceof THREE.BoxCollider)return this.rayBox(a,b);else if(b instanceof THREE.MeshCollider&&b.box)return this.rayBox(a,b.box)};
|
|
|
+THREE.CollisionSystem.prototype.rayMesh=function(a,b){for(var c=this.makeRayLocal(a,b.mesh),e=Number.MAX_VALUE,f,g=0;g<b.numFaces;g++){var h=b.mesh.geometry.faces[g],k=b.mesh.geometry.vertices[h.a].position,j=b.mesh.geometry.vertices[h.b].position,m=b.mesh.geometry.vertices[h.c].position,l=h instanceof THREE.Face4?b.mesh.geometry.vertices[h.d].position:null;h instanceof THREE.Face3?(h=this.rayTriangle(c,k,j,m,e,this.collisionNormal),h<e&&(e=h,f=g,b.normal.copy(this.collisionNormal),b.normal.normalize())):
|
|
|
+h instanceof THREE.Face4&&(h=this.rayTriangle(c,k,j,l,e,this.collisionNormal),h<e&&(e=h,f=g,b.normal.copy(this.collisionNormal),b.normal.normalize()),h=this.rayTriangle(c,j,m,l,e,this.collisionNormal),h<e&&(e=h,f=g,b.normal.copy(this.collisionNormal),b.normal.normalize()))}return{dist:e,faceIndex:f}};
|
|
|
+THREE.CollisionSystem.prototype.rayTriangle=function(a,b,c,e,f,g){var h=THREE.CollisionSystem.__v1,k=THREE.CollisionSystem.__v2;g.set(0,0,0);h.sub(c,b);k.sub(e,c);g.cross(h,k);k=g.dot(a.direction);if(!(k<0))return Number.MAX_VALUE;h=g.dot(b)-g.dot(a.origin);if(!(h<=0))return Number.MAX_VALUE;if(!(h>=k*f))return Number.MAX_VALUE;h/=k;k=THREE.CollisionSystem.__v3;k.copy(a.direction);k.multiplyScalar(h);k.addSelf(a.origin);Math.abs(g.x)>Math.abs(g.y)?Math.abs(g.x)>Math.abs(g.z)?(a=k.y-b.y,g=c.y-b.y,
|
|
|
+f=e.y-b.y,k=k.z-b.z,c=c.z-b.z,e=e.z-b.z):(a=k.x-b.x,g=c.x-b.x,f=e.x-b.x,k=k.y-b.y,c=c.y-b.y,e=e.y-b.y):Math.abs(g.y)>Math.abs(g.z)?(a=k.x-b.x,g=c.x-b.x,f=e.x-b.x,k=k.z-b.z,c=c.z-b.z,e=e.z-b.z):(a=k.x-b.x,g=c.x-b.x,f=e.x-b.x,k=k.y-b.y,c=c.y-b.y,e=e.y-b.y);b=g*e-c*f;if(b==0)return Number.MAX_VALUE;b=1/b;e=(a*e-k*f)*b;if(!(e>=0))return Number.MAX_VALUE;b*=g*k-c*a;if(!(b>=0))return Number.MAX_VALUE;if(!(1-e-b>=0))return Number.MAX_VALUE;return h};
|
|
|
+THREE.CollisionSystem.prototype.makeRayLocal=function(a,b){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(b.matrixWorld,c);var e=THREE.CollisionSystem.__r;e.origin.copy(a.origin);e.direction.copy(a.direction);c.multiplyVector3(e.origin);c.rotateAxis(e.direction);e.direction.normalize();return e};
|
|
|
+THREE.CollisionSystem.prototype.rayBox=function(a,b){var c;b.dynamic&&b.mesh&&b.mesh.matrixWorld?c=this.makeRayLocal(a,b.mesh):(c=THREE.CollisionSystem.__r,c.origin.copy(a.origin),c.direction.copy(a.direction));var e=0,f=0,g=0,h=0,k=0,j=0,m=!0;c.origin.x<b.min.x?(e=b.min.x-c.origin.x,e/=c.direction.x,m=!1,h=-1):c.origin.x>b.max.x&&(e=b.max.x-c.origin.x,e/=c.direction.x,m=!1,h=1);c.origin.y<b.min.y?(f=b.min.y-c.origin.y,f/=c.direction.y,m=!1,k=-1):c.origin.y>b.max.y&&(f=b.max.y-c.origin.y,f/=c.direction.y,
|
|
|
+m=!1,k=1);c.origin.z<b.min.z?(g=b.min.z-c.origin.z,g/=c.direction.z,m=!1,j=-1):c.origin.z>b.max.z&&(g=b.max.z-c.origin.z,g/=c.direction.z,m=!1,j=1);if(m)return-1;m=0;f>e&&(m=1,e=f);g>e&&(m=2,e=g);switch(m){case 0:k=c.origin.y+c.direction.y*e;if(k<b.min.y||k>b.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*e;if(c<b.min.z||c>b.max.z)return Number.MAX_VALUE;b.normal.set(h,0,0);break;case 1:h=c.origin.x+c.direction.x*e;if(h<b.min.x||h>b.max.x)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*
|
|
|
+e;if(c<b.min.z||c>b.max.z)return Number.MAX_VALUE;b.normal.set(0,k,0);break;case 2:h=c.origin.x+c.direction.x*e;if(h<b.min.x||h>b.max.x)return Number.MAX_VALUE;k=c.origin.y+c.direction.y*e;if(k<b.min.y||k>b.max.y)return Number.MAX_VALUE;b.normal.set(0,0,j)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,b){var c=a.direction.dot(b.normal),e=b.point.dot(b.normal);if(c<0)c=(e-a.origin.dot(b.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE};
|
|
|
+THREE.CollisionSystem.prototype.raySphere=function(a,b){var c=b.center.clone().subSelf(a.origin);if(c.lengthSq<b.radiusSq)return-1;var e=c.dot(a.direction.clone());if(e<=0)return Number.MAX_VALUE;c=b.radiusSq-(c.lengthSq()-e*e);if(c>=0)return Math.abs(e)-Math.sqrt(c);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4;
|
|
|
+THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var b=a.geometry.boundingBox,c=new THREE.Vector3(b.x[0],b.y[0],b.z[0]),b=new THREE.Vector3(b.x[1],b.y[1],b.z[1]),c=new THREE.BoxCollider(c,b);c.mesh=a;return c};THREE.CollisionUtils.MeshAABB=function(a){var b=THREE.CollisionUtils.MeshOBB(a);b.min.addSelf(a.position);b.max.addSelf(a.position);b.dynamic=!1;return b};
|
|
|
THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))};
|
|
|
+THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var b=this,c=this.setSize,e=this.render,f=new THREE.Camera,g=new THREE.Camera,a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},h=new THREE.WebGLRenderTarget(512,512,a),k=new THREE.WebGLRenderTarget(512,512,a),j=new THREE.Camera(53,1,1,1E4);j.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:h},mapRight:{type:"t",value:1,texture:k}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
|
|
|
+fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});var m=new THREE.Scene;m.addObject(new THREE.Mesh(new THREE.Plane(2,2),_material));this.setSize=function(a,e){c.call(b,a,e);h.width=a;h.height=e;k.width=a;k.height=e};this.render=
|
|
|
+function(a,c){f.projectionMatrix=c.projectionMatrix;f.position.copy(c.position);f.target.position.copy(c.target.position);f.translateX(-10);g.projectionMatrix=c.projectionMatrix;g.position.copy(c.position);g.target.position.copy(c.target.position);g.translateX(10);e.call(b,a,f,h,!0);e.call(b,a,g,k,!0);e.call(b,m,j)}};THREE.AnaglyphWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.AnaglyphWebGLRenderer.prototype.constructor=THREE.AnaglyphWebGLRenderer;
|