|
@@ -1,25 +1,25 @@
|
|
|
// ThreeExtras.js r39 - http://github.com/mrdoob/three.js
|
|
|
THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(d){for(var f=0;f<a.length;f++)a[f].update(d)};b.addToUpdate=function(d){a.indexOf(d)===-1&&a.push(d)};b.removeFromUpdate=function(d){d=a.indexOf(d);d!==-1&&a.splice(d,1)};b.add=function(d){c[d.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+d.name+" already exists in library. Overwriting.");c[d.name]=d;if(d.initialized!==!0){for(var f=0;f<d.hierarchy.length;f++){for(var g=0;g<d.hierarchy[f].keys.length;g++){if(d.hierarchy[f].keys[g].time<
|
|
|
-0)d.hierarchy[f].keys[g].time=0;if(d.hierarchy[f].keys[g].rot!==undefined&&!(d.hierarchy[f].keys[g].rot instanceof THREE.Quaternion)){var h=d.hierarchy[f].keys[g].rot;d.hierarchy[f].keys[g].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(d.hierarchy[f].keys[0].morphTargets!==undefined){h={};for(g=0;g<d.hierarchy[f].keys.length;g++)for(var j=0;j<d.hierarchy[f].keys[g].morphTargets.length;j++){var l=d.hierarchy[f].keys[g].morphTargets[j];h[l]=-1}d.hierarchy[f].usedMorphTargets=h;for(g=0;g<d.hierarchy[f].keys.length;g++){var k=
|
|
|
-{};for(l in h){for(j=0;j<d.hierarchy[f].keys[g].morphTargets.length;j++)if(d.hierarchy[f].keys[g].morphTargets[j]===l){k[l]=d.hierarchy[f].keys[g].morphTargetsInfluences[j];break}j===d.hierarchy[f].keys[g].morphTargets.length&&(k[l]=0)}d.hierarchy[f].keys[g].morphTargetsInfluences=k}}for(g=1;g<d.hierarchy[f].keys.length;g++)if(d.hierarchy[f].keys[g].time===d.hierarchy[f].keys[g-1].time){d.hierarchy[f].keys.splice(g,1);g--}for(g=1;g<d.hierarchy[f].keys.length;g++)d.hierarchy[f].keys[g].index=g}g=parseInt(d.length*
|
|
|
+0)d.hierarchy[f].keys[g].time=0;if(d.hierarchy[f].keys[g].rot!==undefined&&!(d.hierarchy[f].keys[g].rot instanceof THREE.Quaternion)){var h=d.hierarchy[f].keys[g].rot;d.hierarchy[f].keys[g].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(d.hierarchy[f].keys[0].morphTargets!==undefined){h={};for(g=0;g<d.hierarchy[f].keys.length;g++)for(var k=0;k<d.hierarchy[f].keys[g].morphTargets.length;k++){var l=d.hierarchy[f].keys[g].morphTargets[k];h[l]=-1}d.hierarchy[f].usedMorphTargets=h;for(g=0;g<d.hierarchy[f].keys.length;g++){var j=
|
|
|
+{};for(l in h){for(k=0;k<d.hierarchy[f].keys[g].morphTargets.length;k++)if(d.hierarchy[f].keys[g].morphTargets[k]===l){j[l]=d.hierarchy[f].keys[g].morphTargetsInfluences[k];break}k===d.hierarchy[f].keys[g].morphTargets.length&&(j[l]=0)}d.hierarchy[f].keys[g].morphTargetsInfluences=j}}for(g=1;g<d.hierarchy[f].keys.length;g++)if(d.hierarchy[f].keys[g].time===d.hierarchy[f].keys[g-1].time){d.hierarchy[f].keys.splice(g,1);g--}for(g=1;g<d.hierarchy[f].keys.length;g++)d.hierarchy[f].keys[g].index=g}g=parseInt(d.length*
|
|
|
d.fps,10);d.JIT={};d.JIT.hierarchy=[];for(f=0;f<d.hierarchy.length;f++)d.JIT.hierarchy.push(Array(g));d.initialized=!0}};b.get=function(d){if(typeof d==="string")if(c[d])return c[d];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+d);return null}};b.parse=function(d){var f=[];if(d instanceof THREE.SkinnedMesh)for(var g=0;g<d.bones.length;g++)f.push(d.bones[g]);else e(d,f);return f};var e=function(d,f){f.push(d);for(var g=0;g<d.children.length;g++)e(d.children[g],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,d;for(b=0;b<e;b++){d=this.hierarchy[b];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)d.useQuaternion=!0;d.matrixAutoUpdate=!0;if(d.animationCache===undefined){d.animationCache={};d.animationCache.prevKey={pos:0,rot:0,scl:0};d.animationCache.nextKey={pos:0,rot:0,scl:0};d.animationCache.originalMatrix=
|
|
|
d instanceof THREE.Bone?d.skinMatrix:d.matrix}var f=d.animationCache.prevKey;d=d.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];d.pos=this.getNextKeyWith("pos",b,1);d.rot=this.getNextKeyWith("rot",b,1);d.scl=this.getNextKeyWith("scl",b,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,d,f,g,h,j,l,k=this.data.JIT.hierarchy,t,o;this.currentTime+=a*this.timeScale;o=this.currentTime;t=this.currentTime%=this.data.length;l=parseInt(Math.min(t*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,w=this.hierarchy.length;n<w;n++){a=this.hierarchy[n];j=a.animationCache;if(this.JITCompile&&k[n][l]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=k[n][l];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
|
|
|
-!1}else{a.matrix=k[n][l];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 p=0;p<3;p++){b=c[p];g=j.prevKey[b];h=j.nextKey[b];if(h.time<=o){if(t<o)if(this.loop){g=this.data.hierarchy[n].keys[0];for(h=this.getNextKeyWith(b,n,1);h.time<t;){g=h;h=this.getNextKeyWith(b,n,h.index+1)}}else{this.stop();return}else{do{g=h;h=this.getNextKeyWith(b,n,h.index+1)}while(h.time<
|
|
|
-t)}j.prevKey[b]=g;j.nextKey[b]=h}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(t-g.time)/(h.time-g.time);d=g[b];f=h[b];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+n);e=e<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=d[0]+(f[0]-d[0])*e;b.y=d[1]+(f[1]-d[1])*e;b.z=d[2]+(f[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
|
|
|
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,e,d,f,g,h,k,l,j=this.data.JIT.hierarchy,t,o;this.currentTime+=a*this.timeScale;o=this.currentTime;t=this.currentTime%=this.data.length;l=parseInt(Math.min(t*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,w=this.hierarchy.length;n<w;n++){a=this.hierarchy[n];k=a.animationCache;if(this.JITCompile&&j[n][l]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=j[n][l];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
|
|
|
+!1}else{a.matrix=j[n][l];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 p=0;p<3;p++){b=c[p];g=k.prevKey[b];h=k.nextKey[b];if(h.time<=o){if(t<o)if(this.loop){g=this.data.hierarchy[n].keys[0];for(h=this.getNextKeyWith(b,n,1);h.time<t;){g=h;h=this.getNextKeyWith(b,n,h.index+1)}}else{this.stop();return}else{do{g=h;h=this.getNextKeyWith(b,n,h.index+1)}while(h.time<
|
|
|
+t)}k.prevKey[b]=g;k.nextKey[b]=h}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(t-g.time)/(h.time-g.time);d=g[b];f=h[b];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+n);e=e<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=d[0]+(f[0]-d[0])*e;b.y=d[1]+(f[1]-d[1])*e;b.z=d[2]+(f[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
|
|
|
this.getPrevKeyWith("pos",n,g.index-1).pos;this.points[1]=d;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos;e=e*0.33+0.33;d=this.interpolateCatmullRom(this.points,e);b.x=d[0];b.y=d[1];b.z=d[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(d,f,a.quaternion,e);else if(b==="scl"){b=a.scale;b.x=d[0]+(f[0]-d[0])*e;b.y=d[1]+(f[1]-d[1])*e;b.z=d[2]+(f[2]-d[2])*e}}}}if(this.JITCompile&&k[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(n=0;n<this.hierarchy.length;n++)k[n][l]=this.hierarchy[n]instanceof THREE.Bone?this.hierarchy[n].skinMatrix.clone():this.hierarchy[n].matrix.clone()}}};
|
|
|
-THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],e=[],d,f,g,h,j,l;d=(a.length-1)*c;f=Math.floor(d);d-=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]];h=a[b[1]];j=a[b[2]];l=a[b[3]];b=d*d;g=d*b;e[0]=this.interpolate(f[0],h[0],j[0],l[0],d,b,g);e[1]=this.interpolate(f[1],h[1],j[1],l[1],d,b,g);e[2]=this.interpolate(f[2],h[2],j[2],l[2],d,b,g);return e};
|
|
|
+"rot")THREE.Quaternion.slerp(d,f,a.quaternion,e);else if(b==="scl"){b=a.scale;b.x=d[0]+(f[0]-d[0])*e;b.y=d[1]+(f[1]-d[1])*e;b.z=d[2]+(f[2]-d[2])*e}}}}if(this.JITCompile&&j[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(n=0;n<this.hierarchy.length;n++)j[n][l]=this.hierarchy[n]instanceof THREE.Bone?this.hierarchy[n].skinMatrix.clone():this.hierarchy[n].matrix.clone()}}};
|
|
|
+THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],e=[],d,f,g,h,k,l;d=(a.length-1)*c;f=Math.floor(d);d-=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]];h=a[b[1]];k=a[b[2]];l=a[b[3]];b=d*d;g=d*b;e[0]=this.interpolate(f[0],h[0],k[0],l[0],d,b,g);e[1]=this.interpolate(f[1],h[1],k[1],l[1],d,b,g);e[2]=this.interpolate(f[2],h[2],k[2],l[2],d,b,g);return e};
|
|
|
THREE.Animation.prototype.interpolate=function(a,c,b,e,d,f,g){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*g+(-3*(c-b)-2*a-e)*f+a*d+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]};
|
|
|
-var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,e=a.vertices.length,d=b?c.geometry:c,f=a.vertices,g=d.vertices,h=a.faces,j=d.faces,l=a.faceVertexUvs[0];d=d.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var k=0,t=g.length;k<t;k++){var o=new THREE.Vertex(g[k].position.clone());b&&c.matrix.multiplyVector3(o.position);f.push(o)}k=0;for(t=j.length;k<t;k++){g=j[k];var n,w,p=g.vertexNormals;o=g.vertexColors;if(g instanceof THREE.Face3)n=new THREE.Face3(g.a+e,g.b+e,g.c+
|
|
|
-e);else g instanceof THREE.Face4&&(n=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));n.normal.copy(g.normal);b=0;for(f=p.length;b<f;b++){w=p[b];n.vertexNormals.push(w.clone())}n.color.copy(g.color);b=0;for(f=o.length;b<f;b++){w=o[b];n.vertexColors.push(w.clone())}n.materials=g.materials.slice();n.centroid.copy(g.centroid);h.push(n)}k=0;for(t=d.length;k<t;k++){e=d[k];h=[];b=0;for(f=e.length;b<f;b++)h.push(new THREE.UV(e[b].u,e[b].v));l.push(h)}}};
|
|
|
+var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,e=a.vertices.length,d=b?c.geometry:c,f=a.vertices,g=d.vertices,h=a.faces,k=d.faces,l=a.faceVertexUvs[0];d=d.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var j=0,t=g.length;j<t;j++){var o=new THREE.Vertex(g[j].position.clone());b&&c.matrix.multiplyVector3(o.position);f.push(o)}j=0;for(t=k.length;j<t;j++){g=k[j];var n,w,p=g.vertexNormals;o=g.vertexColors;if(g instanceof THREE.Face3)n=new THREE.Face3(g.a+e,g.b+e,g.c+
|
|
|
+e);else g instanceof THREE.Face4&&(n=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));n.normal.copy(g.normal);b=0;for(f=p.length;b<f;b++){w=p[b];n.vertexNormals.push(w.clone())}n.color.copy(g.color);b=0;for(f=o.length;b<f;b++){w=o[b];n.vertexColors.push(w.clone())}n.materials=g.materials.slice();n.centroid.copy(g.centroid);h.push(n)}j=0;for(t=d.length;j<t;j++){e=d[j];h=[];b=0;for(f=e.length;b<f;b++)h.push(new THREE.UV(e[b].u,e[b].v));l.push(h)}}};
|
|
|
THREE.ImageUtils={loadTexture:function(a,c,b){var e=new Image,d=new THREE.Texture(e,c);e.onload=function(){d.needsUpdate=!0;b&&b(this)};e.src=a;return d},loadTextureCube:function(a,c,b){var e,d=[],f=new THREE.Texture(d,c);c=d.loadCount=0;for(e=a.length;c<e;++c){d[c]=new Image;d[c].onload=function(){d.loadCount+=1;if(d.loadCount==6)f.needsUpdate=!0;b&&b(this)};d[c].src=a[c]}return f}};
|
|
|
-THREE.SceneUtils={addMesh:function(a,c,b,e,d,f,g,h,j,l){c=new THREE.Mesh(c,l);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=e;c.position.y=d;c.position.z=f;c.rotation.x=g;c.rotation.y=h;c.rotation.z=j;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);
|
|
|
+THREE.SceneUtils={addMesh:function(a,c,b,e,d,f,g,h,k,l){c=new THREE.Mesh(c,l);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=e;c.position.y=d;c.position.z=f;c.rotation.x=g;c.rotation.y=h;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 d=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,d,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));THREE.SceneUtils.addMesh(a,c,1,0,-e,0,-f,0,d,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,d=a.children.length;for(e=0;e<d;e++){b=a.children[e];c(b);THREE.SceneUtils.traverseHierarchy(b,c)}}};
|
|
@@ -43,15 +43,15 @@ this.activeLook||(e=0);this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=thi
|
|
|
(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;d=this.position;b.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=d.y+100*Math.cos(this.phi);b.z=d.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(l,k,t,o){var n={name:t,fps:0.6,length:o,hierarchy:[]},w,p=k.getControlPointsArray(),z=k.getLength(),v=p.length,y=0;w=v-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:p[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[w]={time:o,pos:p[w],rot:[0,0,0,1],scl:[1,1,1]};for(w=1;w<v-1;w++){y=o*z.chunks[w]/z.total;k.keys[w]={time:y,pos:p[w]}}n.hierarchy[0]=k;THREE.AnimationHandler.add(n);return new THREE.Animation(l,t,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(l,k){var t,
|
|
|
-o,n=new THREE.Geometry;for(t=0;t<l.points.length*k;t++){o=t/(l.points.length*k);o=l.getPoint(o);n.vertices[t]=new THREE.Vertex(new THREE.Vector3(o.x,o.y,o.z))}return n}function e(l,k){var t=b(k,10),o=b(k,10),n=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(t,n);particleObj=new THREE.ParticleSystem(o,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);l.addChild(lineObj);particleObj.scale.set(1,1,1);l.addChild(particleObj);o=new THREE.Sphere(1,
|
|
|
-16,8);n=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<k.points.length;i++){t=new THREE.Mesh(o,n);t.position.copy(k.points[i]);t.updateMatrix();l.addChild(t)}}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=
|
|
|
+THREE.PathCamera=function(a){function c(l,j,t,o){var n={name:t,fps:0.6,length:o,hierarchy:[]},w,p=j.getControlPointsArray(),z=j.getLength(),v=p.length,y=0;w=v-1;j={parent:-1,keys:[]};j.keys[0]={time:0,pos:p[0],rot:[0,0,0,1],scl:[1,1,1]};j.keys[w]={time:o,pos:p[w],rot:[0,0,0,1],scl:[1,1,1]};for(w=1;w<v-1;w++){y=o*z.chunks[w]/z.total;j.keys[w]={time:y,pos:p[w]}}n.hierarchy[0]=j;THREE.AnimationHandler.add(n);return new THREE.Animation(l,t,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(l,j){var t,
|
|
|
+o,n=new THREE.Geometry;for(t=0;t<l.points.length*j;t++){o=t/(l.points.length*j);o=l.getPoint(o);n.vertices[t]=new THREE.Vertex(new THREE.Vector3(o.x,o.y,o.z))}return n}function e(l,j){var t=b(j,10),o=b(j,10),n=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(t,n);particleObj=new THREE.ParticleSystem(o,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);l.addChild(lineObj);particleObj.scale.set(1,1,1);l.addChild(particleObj);o=new THREE.Sphere(1,
|
|
|
+16,8);n=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<j.points.length;i++){t=new THREE.Mesh(o,n);t.position.copy(j.points[i]);t.updateMatrix();l.addChild(t)}}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 d=Math.PI*2,f=Math.PI/180;this.update=function(l,k,t){var o,n;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;o=this.phi%d;this.phi=o>=0?o:o+d;o=this.verticalAngleMap.srcRange;n=this.verticalAngleMap.dstRange;
|
|
|
-this.phi=(this.phi-o[0])*(n[1]-n[0])/(o[1]-o[0])+n[0];o=this.horizontalAngleMap.srcRange;n=this.horizontalAngleMap.dstRange;this.theta=(this.theta-o[0])*(n[1]-n[0])/(o[1]-o[0])+n[0];o=this.target.position;o.x=100*Math.sin(this.phi)*Math.cos(this.theta);o.y=100*Math.cos(this.phi);o.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,k,t)};this.onMouseMove=function(l){this.mouseX=l.clientX-this.windowHalfX;this.mouseY=l.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
|
|
|
-this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new THREE.Cube(10,10,20),j=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(j,g);a.position.set(0,10,0);this.animation=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(l,k){return function(){k.apply(l,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
|
|
|
+this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var d=Math.PI*2,f=Math.PI/180;this.update=function(l,j,t){var o,n;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;o=this.phi%d;this.phi=o>=0?o:o+d;o=this.verticalAngleMap.srcRange;n=this.verticalAngleMap.dstRange;
|
|
|
+this.phi=(this.phi-o[0])*(n[1]-n[0])/(o[1]-o[0])+n[0];o=this.horizontalAngleMap.srcRange;n=this.horizontalAngleMap.dstRange;this.theta=(this.theta-o[0])*(n[1]-n[0])/(o[1]-o[0])+n[0];o=this.target.position;o.x=100*Math.sin(this.phi)*Math.cos(this.theta);o.y=100*Math.cos(this.phi);o.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,j,t)};this.onMouseMove=function(l){this.mouseX=l.clientX-this.windowHalfX;this.mouseY=l.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
|
|
|
+this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new THREE.Cube(10,10,20),k=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(k,g);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(l,j){return function(){j.apply(l,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
|
|
|
THREE.FlyCamera=function(a){function 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=
|
|
|
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()}};
|
|
@@ -62,88 +62,88 @@ this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVec
|
|
|
this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-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),!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 d=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Matrix4,j=!1,l=1,k=0,t=0,o=0,n=0,w=0,p=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*n);this.rotateVertically(v*w)}v=this.delta*this.movementSpeed;this.translateZ(v*(k>0||this.autoForward&&!(k<0)?1:k));this.translateX(v*t);this.translateY(v*o);j&&(this.roll+=this.rollSpeed*this.delta*l);if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y<
|
|
|
+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 d=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Matrix4,k=!1,l=1,j=0,t=0,o=0,n=0,w=0,p=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*n);this.rotateVertically(v*w)}v=this.delta*this.movementSpeed;this.translateZ(v*(j>0||this.autoForward&&!(j<0)?1:j));this.translateX(v*t);this.translateY(v*o);k&&(this.roll+=this.rollSpeed*this.delta*l);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()}g.copy(this.forward);f.set(0,1,0);d.cross(f,g).normalize();f.cross(g,d).normalize();this.matrix.n11=d.x;this.matrix.n12=f.x;this.matrix.n13=g.x;this.matrix.n21=d.y;this.matrix.n22=f.y;this.matrix.n23=g.y;this.matrix.n31=d.z;this.matrix.n32=f.z;this.matrix.n33=g.z;h.identity();h.n11=Math.cos(this.roll);h.n12=-Math.sin(this.roll);h.n21=Math.sin(this.roll);h.n22=Math.cos(this.roll);this.matrix.multiplySelf(h);
|
|
|
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){d.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);d.multiplyScalar(v);this.forward.subSelf(d);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){n=(v.clientX-p)/window.innerWidth;w=(v.clientY-z)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(v){v.preventDefault();v.stopPropagation();switch(v.button){case 0:k=1;break;case 2:k=-1}},!1);this.domElement.addEventListener("mouseup",function(v){v.preventDefault();v.stopPropagation();switch(v.button){case 0:k=0;break;case 2:k=0}},!1);this.domElement.addEventListener("keydown",function(v){switch(v.keyCode){case 38:case 87:k=1;break;case 37:case 65:t=-1;break;
|
|
|
-case 40:case 83:k=-1;break;case 39:case 68:t=1;break;case 81:j=!0;l=1;break;case 69:j=!0;l=-1;break;case 82:o=1;break;case 70:o=-1}},!1);this.domElement.addEventListener("keyup",function(v){switch(v.keyCode){case 38:case 87:k=0;break;case 37:case 65:t=0;break;case 40:case 83:k=0;break;case 39:case 68:t=0;break;case 81:j=!1;break;case 69:j=!1;break;case 82:o=0;break;case 70:o=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
|
|
|
+function(v){n=(v.clientX-p)/window.innerWidth;w=(v.clientY-z)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(v){v.preventDefault();v.stopPropagation();switch(v.button){case 0:j=1;break;case 2:j=-1}},!1);this.domElement.addEventListener("mouseup",function(v){v.preventDefault();v.stopPropagation();switch(v.button){case 0:j=0;break;case 2:j=0}},!1);this.domElement.addEventListener("keydown",function(v){switch(v.keyCode){case 38:case 87:j=1;break;case 37:case 65:t=-1;break;
|
|
|
+case 40:case 83:j=-1;break;case 39:case 68:t=1;break;case 81:k=!0;l=1;break;case 69:k=!0;l=-1;break;case 82:o=1;break;case 70:o=-1}},!1);this.domElement.addEventListener("keyup",function(v){switch(v.keyCode){case 38:case 87:j=0;break;case 37:case 65:t=0;break;case 40:case 83:j=0;break;case 39:case 68:t=0;break;case 81:k=!1;break;case 69:k=!1;break;case 82:o=0;break;case 70:o=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,d,f,g,h,j){function l(z,v,y,m,D,C,I,L){var H,B,K=e||1,J=d||1,P=D/2,T=C/2,Q=k.vertices.length;if(z=="x"&&v=="y"||z=="y"&&v=="x")H="z";else if(z=="x"&&v=="z"||z=="z"&&v=="x"){H="y";J=f||1}else if(z=="z"&&v=="y"||z=="y"&&v=="z"){H="x";K=f||1}var F=K+1,N=J+1;D/=K;var S=C/J;for(B=0;B<N;B++)for(C=0;C<F;C++){var M=new THREE.Vector3;M[z]=(C*D-P)*y;M[v]=(B*S-T)*m;M[H]=I;k.vertices.push(new THREE.Vertex(M))}for(B=0;B<J;B++)for(C=0;C<K;C++){k.faces.push(new THREE.Face4(C+F*B+Q,C+
|
|
|
-F*(B+1)+Q,C+1+F*(B+1)+Q,C+1+F*B+Q,null,null,L));k.faceVertexUvs[0].push([new THREE.UV(C/K,B/J),new THREE.UV(C/K,(B+1)/J),new THREE.UV((C+1)/K,(B+1)/J),new THREE.UV((C+1)/K,B/J)])}}THREE.Geometry.call(this);var k=this,t=a/2,o=c/2,n=b/2;h=h?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var w=0;w<6;w++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=undefined)for(var p in j)this.sides[p]!=undefined&&(this.sides[p]=
|
|
|
-j[p]);this.sides.px&&l("z","y",1*h,-1,b,c,-t,this.materials[0]);this.sides.nx&&l("z","y",-1*h,-1,b,c,t,this.materials[1]);this.sides.py&&l("x","z",1*h,1,a,b,o,this.materials[2]);this.sides.ny&&l("x","z",1*h,-1,a,b,-o,this.materials[3]);this.sides.pz&&l("x","y",1*h,-1,a,c,n,this.materials[4]);this.sides.nz&&l("x","y",-1*h,-1,a,c,-n,this.materials[5]);(function(){for(var z=[],v=[],y=0,m=k.vertices.length;y<m;y++){for(var D=k.vertices[y],C=!1,I=0,L=z.length;I<L;I++){var H=z[I];if(D.position.x==H.position.x&&
|
|
|
-D.position.y==H.position.y&&D.position.z==H.position.z){v[y]=I;C=!0;break}}if(!C){v[y]=z.length;z.push(new THREE.Vertex(D.position.clone()))}}y=0;for(m=k.faces.length;y<m;y++){D=k.faces[y];D.a=v[D.a];D.b=v[D.b];D.c=v[D.c];D.d=v[D.d]}k.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,d,f){function g(o,n,w){h.vertices.push(new THREE.Vertex(new THREE.Vector3(o,n,w)))}THREE.Geometry.call(this);var h=this,j,l=Math.PI*2,k=e/2;for(j=0;j<a;j++)g(Math.sin(l*j/a)*c,Math.cos(l*j/a)*c,-k);for(j=0;j<a;j++)g(Math.sin(l*j/a)*b,Math.cos(l*j/a)*b,k);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(b>0){g(0,0,-k-(f||0));for(j=a;j<a+a/2;j++)h.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(c>0){g(0,0,k+(d||0));
|
|
|
-for(j=a+a/2;j<2*a;j++)h.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j<a;j++){c=[];b=this.faces[j];d=this.vertices[b.a];f=this.vertices[b.b];k=this.vertices[b.c];var t=this.vertices[b.d];c.push(new THREE.UV(0.5+Math.atan2(d.position.x,d.position.y)/l,0.5+d.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(f.position.x,f.position.y)/l,0.5+f.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(k.position.x,k.position.y)/l,0.5+k.position.z/
|
|
|
+THREE.Cube=function(a,c,b,e,d,f,g,h,k){function l(z,v,y,m,D,C,I,L){var H,B,K=e||1,J=d||1,P=D/2,T=C/2,Q=j.vertices.length;if(z=="x"&&v=="y"||z=="y"&&v=="x")H="z";else if(z=="x"&&v=="z"||z=="z"&&v=="x"){H="y";J=f||1}else if(z=="z"&&v=="y"||z=="y"&&v=="z"){H="x";K=f||1}var F=K+1,N=J+1;D/=K;var S=C/J;for(B=0;B<N;B++)for(C=0;C<F;C++){var M=new THREE.Vector3;M[z]=(C*D-P)*y;M[v]=(B*S-T)*m;M[H]=I;j.vertices.push(new THREE.Vertex(M))}for(B=0;B<J;B++)for(C=0;C<K;C++){j.faces.push(new THREE.Face4(C+F*B+Q,C+
|
|
|
+F*(B+1)+Q,C+1+F*(B+1)+Q,C+1+F*B+Q,null,null,L));j.faceVertexUvs[0].push([new THREE.UV(C/K,B/J),new THREE.UV(C/K,(B+1)/J),new THREE.UV((C+1)/K,(B+1)/J),new THREE.UV((C+1)/K,B/J)])}}THREE.Geometry.call(this);var j=this,t=a/2,o=c/2,n=b/2;h=h?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var w=0;w<6;w++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var p in k)this.sides[p]!=undefined&&(this.sides[p]=
|
|
|
+k[p]);this.sides.px&&l("z","y",1*h,-1,b,c,-t,this.materials[0]);this.sides.nx&&l("z","y",-1*h,-1,b,c,t,this.materials[1]);this.sides.py&&l("x","z",1*h,1,a,b,o,this.materials[2]);this.sides.ny&&l("x","z",1*h,-1,a,b,-o,this.materials[3]);this.sides.pz&&l("x","y",1*h,-1,a,c,n,this.materials[4]);this.sides.nz&&l("x","y",-1*h,-1,a,c,-n,this.materials[5]);(function(){for(var z=[],v=[],y=0,m=j.vertices.length;y<m;y++){for(var D=j.vertices[y],C=!1,I=0,L=z.length;I<L;I++){var H=z[I];if(D.position.x==H.position.x&&
|
|
|
+D.position.y==H.position.y&&D.position.z==H.position.z){v[y]=I;C=!0;break}}if(!C){v[y]=z.length;z.push(new THREE.Vertex(D.position.clone()))}}y=0;for(m=j.faces.length;y<m;y++){D=j.faces[y];D.a=v[D.a];D.b=v[D.b];D.c=v[D.c];D.d=v[D.d]}j.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,d,f){function g(o,n,w){h.vertices.push(new THREE.Vertex(new THREE.Vector3(o,n,w)))}THREE.Geometry.call(this);var h=this,k,l=Math.PI*2,j=e/2;for(k=0;k<a;k++)g(Math.sin(l*k/a)*c,Math.cos(l*k/a)*c,-j);for(k=0;k<a;k++)g(Math.sin(l*k/a)*b,Math.cos(l*k/a)*b,j);for(k=0;k<a;k++)h.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(b>0){g(0,0,-j-(f||0));for(k=a;k<a+a/2;k++)h.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){g(0,0,j+(d||0));
|
|
|
+for(k=a+a/2;k<2*a;k++)h.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];d=this.vertices[b.a];f=this.vertices[b.b];j=this.vertices[b.c];var t=this.vertices[b.d];c.push(new THREE.UV(0.5+Math.atan2(d.position.x,d.position.y)/l,0.5+d.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(f.position.x,f.position.y)/l,0.5+f.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(j.position.x,j.position.y)/l,0.5+j.position.z/
|
|
|
e));b instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(t.position.x,t.position.y)/l,0.5+t.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(t,o,n){var w=Math.sqrt(t*t+o*o+n*n);return d.vertices.push(new THREE.Vertex(new THREE.Vector3(t/w,o/w,n/w)))-1}function b(t,o,n,w){w.faces.push(new THREE.Face3(t,o,n))}function e(t,o){var n=d.vertices[t].position,w=d.vertices[o].position;return c((n.x+w.x)/2,(n.y+w.y)/2,(n.z+w.z)/2)}var d=this,f=new THREE.Geometry,g;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++){g=new THREE.Geometry;for(var h in f.faces){var j=e(f.faces[h].a,f.faces[h].b),l=e(f.faces[h].b,f.faces[h].c),k=e(f.faces[h].c,f.faces[h].a);b(f.faces[h].a,j,k,g);b(f.faces[h].b,l,j,g);b(f.faces[h].c,
|
|
|
-k,l,g);b(j,l,k,g)}f.faces=g.faces}d.faces=f.faces;delete f;delete g;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=[],d=[],f=[],g=(new THREE.Matrix4).setRotationZ(c),h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));b[h]=a[h].clone();e[h]=this.vertices.length-1}for(var j=0;j<=this.angle+0.0010;j+=c){for(h=0;h<b.length;h++)if(j<this.angle){b[h]=g.multiplyVector3(b[h].clone());this.vertices.push(new THREE.Vertex(b[h]));d[h]=this.vertices.length-1}else d=f;j==0&&(f=e);
|
|
|
-for(h=0;h<e.length-1;h++){this.faces.push(new THREE.Face4(d[h],d[h+1],e[h+1],e[h]));this.faceVertexUvs[0].push([new THREE.UV(1-j/this.angle,h/a.length),new THREE.UV(1-j/this.angle,(h+1)/a.length),new THREE.UV(1-(j-c)/this.angle,(h+1)/a.length),new THREE.UV(1-(j-c)/this.angle,h/a.length)])}e=d;d=[]}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 d,f=a/2,g=c/2;b=b||1;e=e||1;var h=b+1,j=e+1;a/=b;var l=c/e;for(d=0;d<j;d++)for(c=0;c<h;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-f,-(d*l-g),0)));for(d=0;d<e;d++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+h*d,c+h*(d+1),c+1+h*(d+1),c+1+h*d));this.faceVertexUvs[0].push([new THREE.UV(c/b,d/e),new THREE.UV(c/b,(d+1)/e),new THREE.UV((c+1)/b,(d+1)/e),new THREE.UV((c+1)/b,d/e)])}this.computeCentroids();this.computeFaceNormals()};
|
|
|
+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++){g=new THREE.Geometry;for(var h in f.faces){var k=e(f.faces[h].a,f.faces[h].b),l=e(f.faces[h].b,f.faces[h].c),j=e(f.faces[h].c,f.faces[h].a);b(f.faces[h].a,k,j,g);b(f.faces[h].b,l,k,g);b(f.faces[h].c,
|
|
|
+j,l,g);b(k,l,j,g)}f.faces=g.faces}d.faces=f.faces;delete f;delete g;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=[],d=[],f=[],g=(new THREE.Matrix4).setRotationZ(c),h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));b[h]=a[h].clone();e[h]=this.vertices.length-1}for(var k=0;k<=this.angle+0.0010;k+=c){for(h=0;h<b.length;h++)if(k<this.angle){b[h]=g.multiplyVector3(b[h].clone());this.vertices.push(new THREE.Vertex(b[h]));d[h]=this.vertices.length-1}else d=f;k==0&&(f=e);
|
|
|
+for(h=0;h<e.length-1;h++){this.faces.push(new THREE.Face4(d[h],d[h+1],e[h+1],e[h]));this.faceVertexUvs[0].push([new THREE.UV(1-k/this.angle,h/a.length),new THREE.UV(1-k/this.angle,(h+1)/a.length),new THREE.UV(1-(k-c)/this.angle,(h+1)/a.length),new THREE.UV(1-(k-c)/this.angle,h/a.length)])}e=d;d=[]}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 d,f=a/2,g=c/2;b=b||1;e=e||1;var h=b+1,k=e+1;a/=b;var l=c/e;for(d=0;d<k;d++)for(c=0;c<h;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-f,-(d*l-g),0)));for(d=0;d<e;d++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+h*d,c+h*(d+1),c+1+h*(d+1),c+1+h*d));this.faceVertexUvs[0].push([new THREE.UV(c/b,d/e),new THREE.UV(c/b,(d+1)/e),new THREE.UV((c+1)/b,(d+1)/e),new THREE.UV((c+1)/b,d/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,d=Math.PI,f=Math.max(3,c||8),g=Math.max(2,b||6);c=[];for(b=0;b<g+1;b++){e=b/g;var h=a*Math.cos(e*d),j=a*Math.sin(e*d),l=[],k=0;for(e=0;e<f;e++){var t=2*e/f,o=j*Math.sin(t*d);t=j*Math.cos(t*d);(b==0||b==g)&&e>0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,h,o)))-1);l.push(k)}c.push(l)}var n,w,p;d=c.length;for(b=0;b<d;b++){f=c[b].length;if(b>0)for(e=0;e<f;e++){l=e==f-1;g=c[b][l?0:e+1];h=c[b][l?f-1:e];j=c[b-1][l?f-1:e];l=c[b-
|
|
|
-1][l?0:e+1];o=b/(d-1);n=(b-1)/(d-1);w=(e+1)/f;t=e/f;k=new THREE.UV(1-w,o);o=new THREE.UV(1-t,o);t=new THREE.UV(1-t,n);var z=new THREE.UV(1-w,n);if(b<c.length-1){n=this.vertices[g].position.clone();w=this.vertices[h].position.clone();p=this.vertices[j].position.clone();n.normalize();w.normalize();p.normalize();this.faces.push(new THREE.Face3(g,h,j,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(p.x,p.y,p.z)]));this.faceVertexUvs[0].push([k,o,t])}if(b>1){n=this.vertices[g].position.clone();
|
|
|
-w=this.vertices[j].position.clone();p=this.vertices[l].position.clone();n.normalize();w.normalize();p.normalize();this.faces.push(new THREE.Face3(g,j,l,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(p.x,p.y,p.z)]));this.faceVertexUvs[0].push([k,t,z])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere;
|
|
|
+THREE.Sphere=function(a,c,b){THREE.Geometry.call(this);var e,d=Math.PI,f=Math.max(3,c||8),g=Math.max(2,b||6);c=[];for(b=0;b<g+1;b++){e=b/g;var h=a*Math.cos(e*d),k=a*Math.sin(e*d),l=[],j=0;for(e=0;e<f;e++){var t=2*e/f,o=k*Math.sin(t*d);t=k*Math.cos(t*d);(b==0||b==g)&&e>0||(j=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,h,o)))-1);l.push(j)}c.push(l)}var n,w,p;d=c.length;for(b=0;b<d;b++){f=c[b].length;if(b>0)for(e=0;e<f;e++){l=e==f-1;g=c[b][l?0:e+1];h=c[b][l?f-1:e];k=c[b-1][l?f-1:e];l=c[b-
|
|
|
+1][l?0:e+1];o=b/(d-1);n=(b-1)/(d-1);w=(e+1)/f;t=e/f;j=new THREE.UV(1-w,o);o=new THREE.UV(1-t,o);t=new THREE.UV(1-t,n);var z=new THREE.UV(1-w,n);if(b<c.length-1){n=this.vertices[g].position.clone();w=this.vertices[h].position.clone();p=this.vertices[k].position.clone();n.normalize();w.normalize();p.normalize();this.faces.push(new THREE.Face3(g,h,k,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(p.x,p.y,p.z)]));this.faceVertexUvs[0].push([j,o,t])}if(b>1){n=this.vertices[g].position.clone();
|
|
|
+w=this.vertices[k].position.clone();p=this.vertices[l].position.clone();n.normalize();w.normalize();p.normalize();this.faces.push(new THREE.Face3(g,k,l,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(p.x,p.y,p.z)]));this.faceVertexUvs[0].push([j,t,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 d=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(d))*Math.cos(e),(this.radius+this.tube*Math.cos(d))*Math.sin(e),this.tube*Math.sin(d))));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;d=(this.segmentsT+1)*c+b-1;var f=(this.segmentsT+1)*(c-1)+b-1,g=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(e,d,f,g));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus;
|
|
|
-THREE.TorusKnot=function(a,c,b,e,d,f,g){function h(t,o,n,w,p,z){o=n/w*t;n=Math.cos(o);return new THREE.Vector3(p*(2+n)*0.5*Math.cos(t),p*(2+n)*Math.sin(t)*0.5,z*p*Math.sin(o)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=e||8;this.p=d||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;e=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var j=
|
|
|
-a/this.segmentsR*2*this.p*Math.PI;g=c/this.segmentsT*2*Math.PI;d=h(j,g,this.q,this.p,this.radius,this.heightScale);j=h(j+0.01,g,this.q,this.p,this.radius,this.heightScale);b.x=j.x-d.x;b.y=j.y-d.y;b.z=j.z-d.z;e.x=j.x+d.x;e.y=j.y+d.y;e.z=j.z+d.z;f.cross(b,e);e.cross(f,b);f.normalize();e.normalize();j=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);d.x+=j*e.x+g*f.x;d.y+=j*e.y+g*f.y;d.z+=j*e.z+g*f.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.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;d=this.grid[a][c];b=this.grid[e][c];e=this.grid[e][f];f=this.grid[a][f];g=new THREE.UV(a/this.segmentsR,c/this.segmentsT);j=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var l=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT),k=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(d,b,e,f));this.faceVertexUvs[0].push([g,j,l,k])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
|
|
|
+THREE.TorusKnot=function(a,c,b,e,d,f,g){function h(t,o,n,w,p,z){o=n/w*t;n=Math.cos(o);return new THREE.Vector3(p*(2+n)*0.5*Math.cos(t),p*(2+n)*Math.sin(t)*0.5,z*p*Math.sin(o)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=e||8;this.p=d||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;e=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a<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;g=c/this.segmentsT*2*Math.PI;d=h(k,g,this.q,this.p,this.radius,this.heightScale);k=h(k+0.01,g,this.q,this.p,this.radius,this.heightScale);b.x=k.x-d.x;b.y=k.y-d.y;b.z=k.z-d.z;e.x=k.x+d.x;e.y=k.y+d.y;e.z=k.z+d.z;f.cross(b,e);e.cross(f,b);f.normalize();e.normalize();k=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);d.x+=k*e.x+g*f.x;d.y+=k*e.y+g*f.y;d.z+=k*e.z+g*f.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.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;d=this.grid[a][c];b=this.grid[e][c];e=this.grid[e][f];f=this.grid[a][f];g=new THREE.UV(a/this.segmentsR,c/this.segmentsT);k=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var l=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT),j=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(d,b,e,f));this.faceVertexUvs[0].push([g,k,l,j])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
|
|
|
THREE.TorusKnot.prototype=new THREE.Geometry;THREE.TorusKnot.prototype.constructor=THREE.TorusKnot;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(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}function e(h,j){var l=new Image;l.onload=function(){if(!b(this.width)||!b(this.height)){var k=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),t=Math.pow(2,Math.round(Math.log(this.height)/
|
|
|
-Math.LN2));h.image.width=k;h.image.height=t;h.image.getContext("2d").drawImage(this,0,0,k,t)}else h.image=this;h.needsUpdate=!0};l.src=j}var d,f,g;d="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,lightMap:null,wireframe:a.wireframe};if(a.shading)if(a.shading=="Phong")d="MeshPhongMaterial";else a.shading=="Basic"&&(d="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==
|
|
|
+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(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}function e(h,k){var l=new Image;l.onload=function(){if(!b(this.width)||!b(this.height)){var j=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),t=Math.pow(2,Math.round(Math.log(this.height)/
|
|
|
+Math.LN2));h.image.width=j;h.image.height=t;h.image.getContext("2d").drawImage(this,0,0,j,t)}else h.image=this;h.needsUpdate=!0};l.src=k}var d,f,g;d="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,lightMap:null,wireframe:a.wireframe};if(a.shading)if(a.shading=="Phong")d="MeshPhongMaterial";else a.shading=="Basic"&&(d="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){g=document.createElement("canvas");f.map=new THREE.Texture(g);f.map.sourceFile=a.mapDiffuse;e(f.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){g=(a.colorDiffuse[0]*255<<
|
|
|
16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;f.color=g;f.opacity=a.transparency}else if(a.DbgColor)f.color=a.DbgColor;if(a.mapLightmap&&c){g=document.createElement("canvas");f.lightMap=new THREE.Texture(g);f.lightMap.sourceFile=a.mapLightmap;e(f.lightMap,c+"/"+a.mapLightmap)}return new THREE[d](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,d=a.texture_path?a.texture_path:this.extractUrlbase(b);a=new Worker(b);a.onmessage=function(f){c.createModel(f.data,e,d);c.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
|
|
|
-THREE.JSONLoader.prototype.createModel=function(a,c,b){var e=new THREE.Geometry;this.init_materials(e,a.materials,b);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var d,f,g,h,j,l,k,t,o,n,w,p,z,v,y,m=a.faces;n=a.vertices;var D=a.normals,C=a.colors;l=a.scale!==undefined?a.scale:1;var I=0;for(d=0;d<a.uvs.length;d++)a.uvs[d].length&&I++;for(d=0;d<I;d++){e.faceUvs[d]=[];e.faceVertexUvs[d]=[]}h=0;for(j=n.length;h<j;){k=new THREE.Vertex;k.position.x=n[h++]/
|
|
|
-l;k.position.y=n[h++]/l;k.position.z=n[h++]/l;e.vertices.push(k)}h=0;for(j=m.length;h<j;){n=m[h++];l=n&1;g=n&2;d=n&4;f=n&8;t=n&16;k=n&32;w=n&64;n&=128;if(l){p=new THREE.Face4;p.a=m[h++];p.b=m[h++];p.c=m[h++];p.d=m[h++];l=4}else{p=new THREE.Face3;p.a=m[h++];p.b=m[h++];p.c=m[h++];l=3}if(g){g=m[h++];p.materials=e.materials[g]}g=e.faces.length;if(d)for(d=0;d<I;d++){z=a.uvs[d];o=m[h++];y=z[o*2];o=z[o*2+1];e.faceUvs[d][g]=new THREE.UV(y,o)}if(f)for(d=0;d<I;d++){z=a.uvs[d];v=[];for(f=0;f<l;f++){o=m[h++];
|
|
|
-y=z[o*2];o=z[o*2+1];v[f]=new THREE.UV(y,o)}e.faceVertexUvs[d][g]=v}if(t){t=m[h++]*3;f=new THREE.Vector3;f.x=D[t++];f.y=D[t++];f.z=D[t];p.normal=f}if(k)for(d=0;d<l;d++){t=m[h++]*3;f=new THREE.Vector3;f.x=D[t++];f.y=D[t++];f.z=D[t];p.vertexNormals.push(f)}if(w){k=m[h++];k=new THREE.Color(C[k]);p.color=k}if(n)for(d=0;d<l;d++){k=m[h++];k=new THREE.Color(C[k]);p.vertexColors.push(k)}e.faces.push(p)}}})();(function(){var d,f,g,h;if(a.skinWeights){d=0;for(f=a.skinWeights.length;d<f;d+=2){g=a.skinWeights[d];
|
|
|
-h=a.skinWeights[d+1];e.skinWeights.push(new THREE.Vector4(g,h,0,0))}}if(a.skinIndices){d=0;for(f=a.skinIndices.length;d<f;d+=2){g=a.skinIndices[d];h=a.skinIndices[d+1];e.skinIndices.push(new THREE.Vector4(g,h,0,0))}}e.bones=a.bones;e.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var d,f,g,h,j,l;d=0;for(f=a.morphTargets.length;d<f;d++){e.morphTargets[d]={};e.morphTargets[d].name=a.morphTargets[d].name;e.morphTargets[d].vertices=[];j=e.morphTargets[d].vertices;l=a.morphTargets[d].vertices;
|
|
|
-g=0;for(h=l.length;g<h;g+=3)j.push(new THREE.Vertex(new THREE.Vector3(l[g],l[g+1],l[g+2])))}}if(a.morphColors!==undefined){var k,t;d=0;for(f=a.morphColors.length;d<f;d++){e.morphColors[d]={};e.morphColors[d].name=a.morphColors[d].name;e.morphColors[d].colors=[];l=e.morphColors[d].colors;k=a.morphColors[d].colors;h=0;for(j=k.length;h<j;h+=3){t=new THREE.Color(16755200);t.setRGB(k[g],k[g+1],k[g+2]);l.push(t)}}}})();(function(){if(a.edges!==undefined){var d,f,g;for(d=0;d<a.edges.length;d+=2){f=a.edges[d];
|
|
|
+THREE.JSONLoader.prototype.createModel=function(a,c,b){var e=new THREE.Geometry;this.init_materials(e,a.materials,b);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var d,f,g,h,k,l,j,t,o,n,w,p,z,v,y,m=a.faces;n=a.vertices;var D=a.normals,C=a.colors;l=a.scale!==undefined?a.scale:1;var I=0;for(d=0;d<a.uvs.length;d++)a.uvs[d].length&&I++;for(d=0;d<I;d++){e.faceUvs[d]=[];e.faceVertexUvs[d]=[]}h=0;for(k=n.length;h<k;){j=new THREE.Vertex;j.position.x=n[h++]/
|
|
|
+l;j.position.y=n[h++]/l;j.position.z=n[h++]/l;e.vertices.push(j)}h=0;for(k=m.length;h<k;){n=m[h++];l=n&1;g=n&2;d=n&4;f=n&8;t=n&16;j=n&32;w=n&64;n&=128;if(l){p=new THREE.Face4;p.a=m[h++];p.b=m[h++];p.c=m[h++];p.d=m[h++];l=4}else{p=new THREE.Face3;p.a=m[h++];p.b=m[h++];p.c=m[h++];l=3}if(g){g=m[h++];p.materials=e.materials[g]}g=e.faces.length;if(d)for(d=0;d<I;d++){z=a.uvs[d];o=m[h++];y=z[o*2];o=z[o*2+1];e.faceUvs[d][g]=new THREE.UV(y,o)}if(f)for(d=0;d<I;d++){z=a.uvs[d];v=[];for(f=0;f<l;f++){o=m[h++];
|
|
|
+y=z[o*2];o=z[o*2+1];v[f]=new THREE.UV(y,o)}e.faceVertexUvs[d][g]=v}if(t){t=m[h++]*3;f=new THREE.Vector3;f.x=D[t++];f.y=D[t++];f.z=D[t];p.normal=f}if(j)for(d=0;d<l;d++){t=m[h++]*3;f=new THREE.Vector3;f.x=D[t++];f.y=D[t++];f.z=D[t];p.vertexNormals.push(f)}if(w){j=m[h++];j=new THREE.Color(C[j]);p.color=j}if(n)for(d=0;d<l;d++){j=m[h++];j=new THREE.Color(C[j]);p.vertexColors.push(j)}e.faces.push(p)}}})();(function(){var d,f,g,h;if(a.skinWeights){d=0;for(f=a.skinWeights.length;d<f;d+=2){g=a.skinWeights[d];
|
|
|
+h=a.skinWeights[d+1];e.skinWeights.push(new THREE.Vector4(g,h,0,0))}}if(a.skinIndices){d=0;for(f=a.skinIndices.length;d<f;d+=2){g=a.skinIndices[d];h=a.skinIndices[d+1];e.skinIndices.push(new THREE.Vector4(g,h,0,0))}}e.bones=a.bones;e.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var d,f,g,h,k,l;d=0;for(f=a.morphTargets.length;d<f;d++){e.morphTargets[d]={};e.morphTargets[d].name=a.morphTargets[d].name;e.morphTargets[d].vertices=[];k=e.morphTargets[d].vertices;l=a.morphTargets[d].vertices;
|
|
|
+g=0;for(h=l.length;g<h;g+=3)k.push(new THREE.Vertex(new THREE.Vector3(l[g],l[g+1],l[g+2])))}}if(a.morphColors!==undefined){var j,t;d=0;for(f=a.morphColors.length;d<f;d++){e.morphColors[d]={};e.morphColors[d].name=a.morphColors[d].name;e.morphColors[d].colors=[];l=e.morphColors[d].colors;j=a.morphColors[d].colors;h=0;for(k=j.length;h<k;h+=3){t=new THREE.Color(16755200);t.setRGB(j[g],j[g+1],j[g+2]);l.push(t)}}}})();(function(){if(a.edges!==undefined){var d,f,g;for(d=0;d<a.edges.length;d+=2){f=a.edges[d];
|
|
|
g=a.edges[d+1];e.edges.push(new THREE.Edge(e.vertices[f],e.vertices[g],f,g))}}})();e.computeCentroids();e.computeFaceNormals();e.computeEdgeFaces();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),d=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(g){THREE.BinaryLoader.prototype.loadAjaxBuffers(g.data.buffers,g.data.materials,b,d,e,f)};c.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};
|
|
|
-c.postMessage(a)},loadAjaxBuffers:function(a,c,b,e,d,f){var g=new XMLHttpRequest,h=e+"/"+a,j=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,b,d,c):alert("Couldn't load ["+h+"] ["+g.status+"]");else if(g.readyState==3){if(f){j==0&&(j=g.getResponseHeader("Content-Length"));f({total:j,loaded:g.responseText.length})}}else g.readyState==2&&(j=g.getResponseHeader("Content-Length"))};g.open("GET",h,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
|
|
|
-g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,c,b,e){var d=function(f){function g(u,x){var A=k(u,x),E=k(u,x+1),G=k(u,x+2),R=k(u,x+3),U=(R<<1&255|G>>7)-127;A|=(G&127)<<16|E<<8;if(A==0&&U==-127)return 0;return(1-2*(R>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,U)}function h(u,x){var A=k(u,x),E=k(u,x+1),G=k(u,x+2);return(k(u,x+3)<<24)+(G<<16)+(E<<8)+A}function j(u,x){var A=k(u,x);return(k(u,x+1)<<8)+A}function l(u,x){var A=k(u,x);return A>127?A-256:A}function k(u,
|
|
|
-x){return u.charCodeAt(x)&255}function t(u){var x,A,E;x=h(a,u);A=h(a,u+I);E=h(a,u+L);u=j(a,u+H);THREE.BinaryLoader.prototype.f3(v,x,A,E,u)}function o(u){var x,A,E,G,R,U;x=h(a,u);A=h(a,u+I);E=h(a,u+L);G=j(a,u+H);R=h(a,u+B);U=h(a,u+K);u=h(a,u+J);THREE.BinaryLoader.prototype.f3n(v,D,x,A,E,G,R,U,u)}function n(u){var x,A,E,G;x=h(a,u);A=h(a,u+P);E=h(a,u+T);G=h(a,u+Q);u=j(a,u+F);THREE.BinaryLoader.prototype.f4(v,x,A,E,G,u)}function w(u){var x,A,E,G,R,U,ba,ca;x=h(a,u);A=h(a,u+P);E=h(a,u+T);G=h(a,u+Q);R=j(a,
|
|
|
+c.postMessage(a)},loadAjaxBuffers:function(a,c,b,e,d,f){var g=new XMLHttpRequest,h=e+"/"+a,k=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,b,d,c):alert("Couldn't load ["+h+"] ["+g.status+"]");else if(g.readyState==3){if(f){k==0&&(k=g.getResponseHeader("Content-Length"));f({total:k,loaded:g.responseText.length})}}else g.readyState==2&&(k=g.getResponseHeader("Content-Length"))};g.open("GET",h,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
|
|
|
+g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,c,b,e){var d=function(f){function g(u,x){var A=j(u,x),E=j(u,x+1),G=j(u,x+2),R=j(u,x+3),U=(R<<1&255|G>>7)-127;A|=(G&127)<<16|E<<8;if(A==0&&U==-127)return 0;return(1-2*(R>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,U)}function h(u,x){var A=j(u,x),E=j(u,x+1),G=j(u,x+2);return(j(u,x+3)<<24)+(G<<16)+(E<<8)+A}function k(u,x){var A=j(u,x);return(j(u,x+1)<<8)+A}function l(u,x){var A=j(u,x);return A>127?A-256:A}function j(u,
|
|
|
+x){return u.charCodeAt(x)&255}function t(u){var x,A,E;x=h(a,u);A=h(a,u+I);E=h(a,u+L);u=k(a,u+H);THREE.BinaryLoader.prototype.f3(v,x,A,E,u)}function o(u){var x,A,E,G,R,U;x=h(a,u);A=h(a,u+I);E=h(a,u+L);G=k(a,u+H);R=h(a,u+B);U=h(a,u+K);u=h(a,u+J);THREE.BinaryLoader.prototype.f3n(v,D,x,A,E,G,R,U,u)}function n(u){var x,A,E,G;x=h(a,u);A=h(a,u+P);E=h(a,u+T);G=h(a,u+Q);u=k(a,u+F);THREE.BinaryLoader.prototype.f4(v,x,A,E,G,u)}function w(u){var x,A,E,G,R,U,ba,ca;x=h(a,u);A=h(a,u+P);E=h(a,u+T);G=h(a,u+Q);R=k(a,
|
|
|
u+F);U=h(a,u+N);ba=h(a,u+S);ca=h(a,u+M);u=h(a,u+O);THREE.BinaryLoader.prototype.f4n(v,D,x,A,E,G,R,U,ba,ca,u)}function p(u){var x,A;x=h(a,u);A=h(a,u+W);u=h(a,u+da);THREE.BinaryLoader.prototype.uv3(v.faceVertexUvs[0],C[x*2],C[x*2+1],C[A*2],C[A*2+1],C[u*2],C[u*2+1])}function z(u){var x,A,E;x=h(a,u);A=h(a,u+ea);E=h(a,u+fa);u=h(a,u+ga);THREE.BinaryLoader.prototype.uv4(v.faceVertexUvs[0],C[x*2],C[x*2+1],C[A*2],C[A*2+1],C[E*2],C[E*2+1],C[u*2],C[u*2+1])}var v=this,y=0,m,D=[],C=[],I,L,H,B,K,J,P,T,Q,F,N,S,
|
|
|
-M,O,W,da,ea,fa,ga,X,Y,Z,$,aa,V;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,f);m={signature:a.substr(y,8),header_bytes:k(a,y+8),vertex_coordinate_bytes:k(a,y+9),normal_coordinate_bytes:k(a,y+10),uv_coordinate_bytes:k(a,y+11),vertex_index_bytes:k(a,y+12),normal_index_bytes:k(a,y+13),uv_index_bytes:k(a,y+14),material_index_bytes:k(a,y+15),nvertices:h(a,y+16),nnormals:h(a,y+16+4),nuvs:h(a,y+16+8),ntri_flat:h(a,y+16+12),ntri_smooth:h(a,y+16+16),ntri_flat_uv:h(a,y+16+20),ntri_smooth_uv:h(a,
|
|
|
+M,O,W,da,ea,fa,ga,X,Y,Z,$,aa,V;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,f);m={signature:a.substr(y,8),header_bytes:j(a,y+8),vertex_coordinate_bytes:j(a,y+9),normal_coordinate_bytes:j(a,y+10),uv_coordinate_bytes:j(a,y+11),vertex_index_bytes:j(a,y+12),normal_index_bytes:j(a,y+13),uv_index_bytes:j(a,y+14),material_index_bytes:j(a,y+15),nvertices:h(a,y+16),nnormals:h(a,y+16+4),nuvs:h(a,y+16+8),ntri_flat:h(a,y+16+12),ntri_smooth:h(a,y+16+16),ntri_flat_uv:h(a,y+16+20),ntri_smooth_uv:h(a,
|
|
|
y+16+24),nquad_flat:h(a,y+16+28),nquad_smooth:h(a,y+16+32),nquad_flat_uv:h(a,y+16+36),nquad_smooth_uv:h(a,y+16+40)};y+=m.header_bytes;I=m.vertex_index_bytes;L=m.vertex_index_bytes*2;H=m.vertex_index_bytes*3;B=m.vertex_index_bytes*3+m.material_index_bytes;K=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;J=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;P=m.vertex_index_bytes;T=m.vertex_index_bytes*2;Q=m.vertex_index_bytes*3;F=m.vertex_index_bytes*4;N=m.vertex_index_bytes*
|
|
|
4+m.material_index_bytes;S=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;M=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;O=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;W=m.uv_index_bytes;da=m.uv_index_bytes*2;ea=m.uv_index_bytes;fa=m.uv_index_bytes*2;ga=m.uv_index_bytes*3;f=m.vertex_index_bytes*3+m.material_index_bytes;V=m.vertex_index_bytes*4+m.material_index_bytes;X=m.ntri_flat*f;Y=m.ntri_smooth*(f+m.normal_index_bytes*3);Z=m.ntri_flat_uv*
|
|
|
(f+m.uv_index_bytes*3);$=m.ntri_smooth_uv*(f+m.normal_index_bytes*3+m.uv_index_bytes*3);aa=m.nquad_flat*V;f=m.nquad_smooth*(V+m.normal_index_bytes*4);V=m.nquad_flat_uv*(V+m.uv_index_bytes*4);y+=function(u){for(var x,A,E,G=m.vertex_coordinate_bytes*3,R=u+m.nvertices*G;u<R;u+=G){x=g(a,u);A=g(a,u+m.vertex_coordinate_bytes);E=g(a,u+m.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(v,x,A,E)}return m.nvertices*G}(y);y+=function(u){for(var x,A,E,G=m.normal_coordinate_bytes*3,R=u+m.nnormals*G;u<
|
|
|
R;u+=G){x=l(a,u);A=l(a,u+m.normal_coordinate_bytes);E=l(a,u+m.normal_coordinate_bytes*2);D.push(x/127,A/127,E/127)}return m.nnormals*G}(y);y+=function(u){for(var x,A,E=m.uv_coordinate_bytes*2,G=u+m.nuvs*E;u<G;u+=E){x=g(a,u);A=g(a,u+m.uv_coordinate_bytes);C.push(x,A)}return m.nuvs*E}(y);X=y+X;Y=X+Y;Z=Y+Z;$=Z+$;aa=$+aa;f=aa+f;V=f+V;(function(u){var x,A=m.vertex_index_bytes*3+m.material_index_bytes,E=A+m.uv_index_bytes*3,G=u+m.ntri_flat_uv*E;for(x=u;x<G;x+=E){t(x);p(x+A)}return G-u})(Y);(function(u){var x,
|
|
|
A=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,E=A+m.uv_index_bytes*3,G=u+m.ntri_smooth_uv*E;for(x=u;x<G;x+=E){o(x);p(x+A)}return G-u})(Z);(function(u){var x,A=m.vertex_index_bytes*4+m.material_index_bytes,E=A+m.uv_index_bytes*4,G=u+m.nquad_flat_uv*E;for(x=u;x<G;x+=E){n(x);z(x+A)}return G-u})(f);(function(u){var x,A=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,E=A+m.uv_index_bytes*4,G=u+m.nquad_smooth_uv*E;for(x=u;x<G;x+=E){w(x);z(x+A)}return G-u})(V);
|
|
|
(function(u){var x,A=m.vertex_index_bytes*3+m.material_index_bytes,E=u+m.ntri_flat*A;for(x=u;x<E;x+=A)t(x);return E-u})(y);(function(u){var x,A=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,E=u+m.ntri_smooth*A;for(x=u;x<E;x+=A)o(x);return E-u})(X);(function(u){var x,A=m.vertex_index_bytes*4+m.material_index_bytes,E=u+m.nquad_flat*A;for(x=u;x<E;x+=A)n(x);return E-u})($);(function(u){var x,A=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,E=u+m.nquad_smooth*
|
|
|
-A;for(x=u;x<E;x+=A)w(x);return E-u})(aa);this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;c(new d(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,d){a.faces.push(new THREE.Face3(c,b,e,null,null,a.materials[d]))},f4:function(a,c,b,e,d,f){a.faces.push(new THREE.Face4(c,b,e,d,null,null,a.materials[f]))},f3n:function(a,c,b,e,d,f,g,h,j){f=a.materials[f];var l=c[h*3],k=c[h*3+1];h=c[h*3+2];
|
|
|
-var t=c[j*3],o=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face3(b,e,d,[new THREE.Vector3(c[g*3],c[g*3+1],c[g*3+2]),new THREE.Vector3(l,k,h),new THREE.Vector3(t,o,j)],null,f))},f4n:function(a,c,b,e,d,f,g,h,j,l,k){g=a.materials[g];var t=c[j*3],o=c[j*3+1];j=c[j*3+2];var n=c[l*3],w=c[l*3+1];l=c[l*3+2];var p=c[k*3],z=c[k*3+1];k=c[k*3+2];a.faces.push(new THREE.Face4(b,e,d,f,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(t,o,j),new THREE.Vector3(n,w,l),new THREE.Vector3(p,z,k)],null,g))},
|
|
|
-uv3:function(a,c,b,e,d,f,g){var h=[];h.push(new THREE.UV(c,b));h.push(new THREE.UV(e,d));h.push(new THREE.UV(f,g));a.push(h)},uv4:function(a,c,b,e,d,f,g,h,j){var l=[];l.push(new THREE.UV(c,b));l.push(new THREE.UV(e,d));l.push(new THREE.UV(f,g));l.push(new THREE.UV(h,j));a.push(l)}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
|
|
|
+A;for(x=u;x<E;x+=A)w(x);return E-u})(aa);this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;c(new d(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,d){a.faces.push(new THREE.Face3(c,b,e,null,null,a.materials[d]))},f4:function(a,c,b,e,d,f){a.faces.push(new THREE.Face4(c,b,e,d,null,null,a.materials[f]))},f3n:function(a,c,b,e,d,f,g,h,k){f=a.materials[f];var l=c[h*3],j=c[h*3+1];h=c[h*3+2];
|
|
|
+var t=c[k*3],o=c[k*3+1];k=c[k*3+2];a.faces.push(new THREE.Face3(b,e,d,[new THREE.Vector3(c[g*3],c[g*3+1],c[g*3+2]),new THREE.Vector3(l,j,h),new THREE.Vector3(t,o,k)],null,f))},f4n:function(a,c,b,e,d,f,g,h,k,l,j){g=a.materials[g];var t=c[k*3],o=c[k*3+1];k=c[k*3+2];var n=c[l*3],w=c[l*3+1];l=c[l*3+2];var p=c[j*3],z=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face4(b,e,d,f,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(t,o,k),new THREE.Vector3(n,w,l),new THREE.Vector3(p,z,j)],null,g))},
|
|
|
+uv3:function(a,c,b,e,d,f,g){var h=[];h.push(new THREE.UV(c,b));h.push(new THREE.UV(e,d));h.push(new THREE.UV(f,g));a.push(h)},uv4:function(a,c,b,e,d,f,g,h,k){var l=[];l.push(new THREE.UV(c,b));l.push(new THREE.UV(e,d));l.push(new THREE.UV(f,g));l.push(new THREE.UV(h,k));a.push(l)}};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 d=THREE.Loader.prototype.extractUrlbase(a);e.onmessage=function(f){function g(O,W){return W=="relativeToHTML"?O:d+"/"+O}function h(){for(o in B.objects)if(!F.objects[o]){v=B.objects[o];if(C=F.geometries[v.geometry]){H=[];for(M=0;M<v.materials.length;M++)H[M]=F.materials[v.materials[M]];y=v.position;r=v.rotation;q=v.quaternion;s=v.scale;q=0;H.length==0&&(H[0]=new THREE.MeshFaceMaterial);H.length>1&&(H=[new THREE.MeshFaceMaterial]);
|
|
|
object=new THREE.Mesh(C,H);object.name=o;object.position.set(y[0],y[1],y[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=v.visible;F.scene.addObject(object);F.objects[o]=object;if(v.meshCollider){var O=THREE.CollisionUtils.MeshColliderWBox(object);F.scene.collisions.colliders.push(O)}if(v.castsShadow){O=new THREE.ShadowVolume(C);F.scene.addChild(O);O.position=object.position;O.rotation=
|
|
|
-object.rotation;O.scale=object.scale}}}}function j(O){return function(W){F.geometries[O]=W;h();J-=1;b.onLoadComplete();l()}}function l(){b.callbackProgress({totalModels:T,totalTextures:Q,loadedModels:T-J,loadedTextures:Q-P},F);b.onLoadProgress();J==0&&P==0&&c(F)}var k,t,o,n,w,p,z,v,y,m,D,C,I,L,H,B,K,J,P,T,Q,F;B=f.data;f=new THREE.BinaryLoader;K=new THREE.JSONLoader;P=J=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};var N=!1;for(o in B.objects){v=
|
|
|
+object.rotation;O.scale=object.scale}}}}function k(O){return function(W){F.geometries[O]=W;h();J-=1;b.onLoadComplete();l()}}function l(){b.callbackProgress({totalModels:T,totalTextures:Q,loadedModels:T-J,loadedTextures:Q-P},F);b.onLoadProgress();J==0&&P==0&&c(F)}var j,t,o,n,w,p,z,v,y,m,D,C,I,L,H,B,K,J,P,T,Q,F;B=f.data;f=new THREE.BinaryLoader;K=new THREE.JSONLoader;P=J=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};var N=!1;for(o in B.objects){v=
|
|
|
B.objects[o];if(v.meshCollider){N=!0;break}}if(N)F.scene.collisions=new THREE.CollisionSystem;if(B.transform){N=B.transform.position;m=B.transform.rotation;var S=B.transform.scale;N&&F.scene.position.set(N[0],N[1],N[2]);m&&F.scene.rotation.set(m[0],m[1],m[2]);S&&F.scene.scale.set(S[0],S[1],S[2]);(N||m||S)&&F.scene.updateMatrix()}N=function(){P-=1;l();b.onLoadComplete()};for(w in B.cameras){m=B.cameras[w];if(m.type=="perspective")I=new THREE.Camera(m.fov,m.aspect,m.near,m.far);else if(m.type=="ortho"){I=
|
|
|
new THREE.Camera;I.projectionMatrix=THREE.Matrix4.makeOrtho(m.left,m.right,m.top,m.bottom,m.near,m.far)}y=m.position;m=m.target;I.position.set(y[0],y[1],y[2]);I.target.position.set(m[0],m[1],m[2]);F.cameras[w]=I}for(n in B.lights){w=B.lights[n];I=w.color!==undefined?w.color:16777215;m=w.intensity!==undefined?w.intensity:1;if(w.type=="directional"){y=w.direction;light=new THREE.DirectionalLight(I,m);light.position.set(y[0],y[1],y[2]);light.position.normalize()}else if(w.type=="point"){y=w.position;
|
|
|
light=new THREE.PointLight(I,m);light.position.set(y[0],y[1],y[2])}F.scene.addLight(light);F.lights[n]=light}for(p in B.fogs){n=B.fogs[p];if(n.type=="linear")L=new THREE.Fog(0,n.near,n.far);else n.type=="exp2"&&(L=new THREE.FogExp2(0,n.density));m=n.color;L.color.setRGB(m[0],m[1],m[2]);F.fogs[p]=L}if(F.cameras&&B.defaults.camera)F.currentCamera=F.cameras[B.defaults.camera];if(F.fogs&&B.defaults.fog)F.scene.fog=F.fogs[B.defaults.fog];m=B.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(m[0],
|
|
|
-m[1],m[2]);F.bgColorAlpha=B.defaults.bgalpha;for(k in B.geometries){p=B.geometries[k];if(p.type=="bin_mesh"||p.type=="ascii_mesh"){J+=1;b.onLoadStart()}}T=J;for(k in B.geometries){p=B.geometries[k];if(p.type=="cube"){C=new THREE.Cube(p.width,p.height,p.depth,p.segmentsWidth,p.segmentsHeight,p.segmentsDepth,null,p.flipped,p.sides);F.geometries[k]=C}else if(p.type=="plane"){C=new THREE.Plane(p.width,p.height,p.segmentsWidth,p.segmentsHeight);F.geometries[k]=C}else if(p.type=="sphere"){C=new THREE.Sphere(p.radius,
|
|
|
-p.segmentsWidth,p.segmentsHeight);F.geometries[k]=C}else if(p.type=="cylinder"){C=new THREE.Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);F.geometries[k]=C}else if(p.type=="torus"){C=new THREE.Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);F.geometries[k]=C}else if(p.type=="icosahedron"){C=new THREE.Icosahedron(p.subdivisions);F.geometries[k]=C}else if(p.type=="bin_mesh")f.load({model:g(p.url,B.urlBaseType),callback:j(k)});else p.type=="ascii_mesh"&&K.load({model:g(p.url,
|
|
|
-B.urlBaseType),callback:j(k)})}for(z in B.textures){k=B.textures[z];if(k.url instanceof Array){P+=k.url.length;for(p=0;p<k.url.length;p++)b.onLoadStart()}else{P+=1;b.onLoadStart()}}Q=P;for(z in B.textures){k=B.textures[z];if(k.mapping!=undefined&&THREE[k.mapping]!=undefined)k.mapping=new THREE[k.mapping];if(k.url instanceof Array){p=[];for(var M=0;M<k.url.length;M++)p[M]=g(k.url[M],B.urlBaseType);p=THREE.ImageUtils.loadTextureCube(p,k.mapping,N)}else{p=THREE.ImageUtils.loadTexture(g(k.url,B.urlBaseType),
|
|
|
-k.mapping,N);if(THREE[k.minFilter]!=undefined)p.minFilter=THREE[k.minFilter];if(THREE[k.magFilter]!=undefined)p.magFilter=THREE[k.magFilter]}F.textures[z]=p}for(t in B.materials){z=B.materials[t];for(D in z.parameters)if(D=="envMap"||D=="map"||D=="lightMap")z.parameters[D]=F.textures[z.parameters[D]];else if(D=="shading")z.parameters[D]=z.parameters[D]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(D=="blending")z.parameters[D]=THREE[z.parameters[D]]?THREE[z.parameters[D]]:THREE.NormalBlending;
|
|
|
+m[1],m[2]);F.bgColorAlpha=B.defaults.bgalpha;for(j in B.geometries){p=B.geometries[j];if(p.type=="bin_mesh"||p.type=="ascii_mesh"){J+=1;b.onLoadStart()}}T=J;for(j in B.geometries){p=B.geometries[j];if(p.type=="cube"){C=new THREE.Cube(p.width,p.height,p.depth,p.segmentsWidth,p.segmentsHeight,p.segmentsDepth,null,p.flipped,p.sides);F.geometries[j]=C}else if(p.type=="plane"){C=new THREE.Plane(p.width,p.height,p.segmentsWidth,p.segmentsHeight);F.geometries[j]=C}else if(p.type=="sphere"){C=new THREE.Sphere(p.radius,
|
|
|
+p.segmentsWidth,p.segmentsHeight);F.geometries[j]=C}else if(p.type=="cylinder"){C=new THREE.Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);F.geometries[j]=C}else if(p.type=="torus"){C=new THREE.Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);F.geometries[j]=C}else if(p.type=="icosahedron"){C=new THREE.Icosahedron(p.subdivisions);F.geometries[j]=C}else if(p.type=="bin_mesh")f.load({model:g(p.url,B.urlBaseType),callback:k(j)});else p.type=="ascii_mesh"&&K.load({model:g(p.url,
|
|
|
+B.urlBaseType),callback:k(j)})}for(z in B.textures){j=B.textures[z];if(j.url instanceof Array){P+=j.url.length;for(p=0;p<j.url.length;p++)b.onLoadStart()}else{P+=1;b.onLoadStart()}}Q=P;for(z in B.textures){j=B.textures[z];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){p=[];for(var M=0;M<j.url.length;M++)p[M]=g(j.url[M],B.urlBaseType);p=THREE.ImageUtils.loadTextureCube(p,j.mapping,N)}else{p=THREE.ImageUtils.loadTexture(g(j.url,B.urlBaseType),
|
|
|
+j.mapping,N);if(THREE[j.minFilter]!=undefined)p.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)p.magFilter=THREE[j.magFilter]}F.textures[z]=p}for(t in B.materials){z=B.materials[t];for(D in z.parameters)if(D=="envMap"||D=="map"||D=="lightMap")z.parameters[D]=F.textures[z.parameters[D]];else if(D=="shading")z.parameters[D]=z.parameters[D]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(D=="blending")z.parameters[D]=THREE[z.parameters[D]]?THREE[z.parameters[D]]:THREE.NormalBlending;
|
|
|
else if(D=="combine")z.parameters[D]=z.parameters[D]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(D=="vertexColors")if(z.parameters[D]=="face")z.parameters[D]=THREE.FaceColors;else if(z.parameters[D])z.parameters[D]=THREE.VertexColors;if(z.parameters.opacity!==undefined&&z.parameters.opacity<1)z.parameters.transparent=!0;z=new THREE[z.type](z.parameters);F.materials[t]=z}h();b.callbackSync(F)}}};
|
|
|
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,d){return b+(e-b)*d};this.VIntX=function(b,e,d,f,g,h,j,l,k,t){g=(g-k)/(t-k);k=this.normal_cache;e[f]=h+g*this.delta;e[f+1]=j;e[f+2]=l;d[f]=this.lerp(k[b],k[b+3],g);d[f+1]=this.lerp(k[b+1],k[b+4],g);d[f+2]=this.lerp(k[b+2],k[b+5],g)};this.VIntY=function(b,e,d,f,g,h,j,l,k,t){g=(g-k)/(t-k);k=this.normal_cache;e[f]=h;e[f+1]=j+g*this.delta;e[f+
|
|
|
-2]=l;e=b+this.yd*3;d[f]=this.lerp(k[b],k[e],g);d[f+1]=this.lerp(k[b+1],k[e+1],g);d[f+2]=this.lerp(k[b+2],k[e+2],g)};this.VIntZ=function(b,e,d,f,g,h,j,l,k,t){g=(g-k)/(t-k);k=this.normal_cache;e[f]=h;e[f+1]=j;e[f+2]=l+g*this.delta;e=b+this.zd*3;d[f]=this.lerp(k[b],k[e],g);d[f+1]=this.lerp(k[b+1],k[e+1],g);d[f+2]=this.lerp(k[b+2],k[e+2],g)};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,d,f,g,h){var j=f+1,l=f+this.yd,k=f+this.zd,t=j+this.yd,o=j+this.zd,n=f+this.yd+this.zd,w=j+this.yd+this.zd,p=0,z=this.field[f],v=this.field[j],y=this.field[l],m=this.field[t],D=this.field[k],C=this.field[o],I=this.field[n],L=this.field[w];z<g&&(p|=1);v<g&&(p|=2);y<g&&(p|=8);m<g&&(p|=4);D<g&&(p|=16);C<g&&(p|=32);I<g&&(p|=128);L<g&&(p|=64);var H=THREE.edgeTable[p];if(H==0)return 0;
|
|
|
-var B=this.delta,K=b+B,J=e+B;B=d+B;if(H&1){this.compNorm(f);this.compNorm(j);this.VIntX(f*3,this.vlist,this.nlist,0,g,b,e,d,z,v)}if(H&2){this.compNorm(j);this.compNorm(t);this.VIntY(j*3,this.vlist,this.nlist,3,g,K,e,d,v,m)}if(H&4){this.compNorm(l);this.compNorm(t);this.VIntX(l*3,this.vlist,this.nlist,6,g,b,J,d,y,m)}if(H&8){this.compNorm(f);this.compNorm(l);this.VIntY(f*3,this.vlist,this.nlist,9,g,b,e,d,z,y)}if(H&16){this.compNorm(k);this.compNorm(o);this.VIntX(k*3,this.vlist,this.nlist,12,g,b,e,B,
|
|
|
-D,C)}if(H&32){this.compNorm(o);this.compNorm(w);this.VIntY(o*3,this.vlist,this.nlist,15,g,K,e,B,C,L)}if(H&64){this.compNorm(n);this.compNorm(w);this.VIntX(n*3,this.vlist,this.nlist,18,g,b,J,B,I,L)}if(H&128){this.compNorm(k);this.compNorm(n);this.VIntY(k*3,this.vlist,this.nlist,21,g,b,e,B,D,I)}if(H&256){this.compNorm(f);this.compNorm(k);this.VIntZ(f*3,this.vlist,this.nlist,24,g,b,e,d,z,D)}if(H&512){this.compNorm(j);this.compNorm(o);this.VIntZ(j*3,this.vlist,this.nlist,27,g,K,e,d,v,C)}if(H&1024){this.compNorm(t);
|
|
|
-this.compNorm(w);this.VIntZ(t*3,this.vlist,this.nlist,30,g,K,J,d,m,L)}if(H&2048){this.compNorm(l);this.compNorm(n);this.VIntZ(l*3,this.vlist,this.nlist,33,g,b,J,d,y,I)}p<<=4;for(g=f=0;THREE.triTable[p+g]!=-1;){b=p+g;e=b+1;d=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[e],3*THREE.triTable[d],h);g+=3;f++}return f};this.posnormtriv=function(b,e,d,f,g,h){var j=this.count*3;this.positionArray[j]=b[d];this.positionArray[j+1]=b[d+1];this.positionArray[j+2]=b[d+2];this.positionArray[j+
|
|
|
-3]=b[f];this.positionArray[j+4]=b[f+1];this.positionArray[j+5]=b[f+2];this.positionArray[j+6]=b[g];this.positionArray[j+7]=b[g+1];this.positionArray[j+8]=b[g+2];this.normalArray[j]=e[d];this.normalArray[j+1]=e[d+1];this.normalArray[j+2]=e[d+2];this.normalArray[j+3]=e[f];this.normalArray[j+4]=e[f+1];this.normalArray[j+5]=e[f+2];this.normalArray[j+6]=e[g];this.normalArray[j+7]=e[g+1];this.normalArray[j+8]=e[g+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=
|
|
|
-function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;b(this)}};this.addBall=function(b,e,d,f,g){var h=this.size*Math.sqrt(f/g),j=d*this.size,l=e*this.size,k=b*this.size,t=Math.floor(j-h);t<1&&(t=1);j=Math.floor(j+h);j>this.size-1&&(j=this.size-1);var o=Math.floor(l-h);o<1&&(o=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var n=Math.floor(k-h);n<1&&(n=1);h=Math.floor(k+h);
|
|
|
-h>this.size-1&&(h=this.size-1);for(var w,p,z,v,y,m;t<j;t++){k=this.size2*t;p=t/this.size-d;y=p*p;for(p=o;p<l;p++){z=k+this.size*p;w=p/this.size-e;m=w*w;for(w=n;w<h;w++){v=w/this.size-b;v=f/(1.0E-6+v*v+m+y)-g;v>0&&(this.field[z+w]+=v)}}}};this.addPlaneX=function(b,e){var d,f,g,h,j,l=this.size,k=this.yd,t=this.zd,o=this.field,n=l*Math.sqrt(b/e);n>l&&(n=l);for(d=0;d<n;d++){f=d/l;f*=f;h=b/(1.0E-4+f)-e;if(h>0)for(f=0;f<l;f++){j=d+f*k;for(g=0;g<l;g++)o[t*g+j]+=h}}};this.addPlaneY=function(b,e){var d,f,
|
|
|
-g,h,j,l,k=this.size,t=this.yd,o=this.zd,n=this.field,w=k*Math.sqrt(b/e);w>k&&(w=k);for(f=0;f<w;f++){d=f/k;d*=d;h=b/(1.0E-4+d)-e;if(h>0){j=f*t;for(d=0;d<k;d++){l=j+d;for(g=0;g<k;g++)n[o*g+l]+=h}}}};this.addPlaneZ=function(b,e){var d,f,g,h,j,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/e);dist>size&&(dist=size);for(g=0;g<dist;g++){d=g/size;d*=d;h=b/(1.0E-4+d)-e;if(h>0){j=zd*g;for(f=0;f<size;f++){l=j+f*yd;for(d=0;d<size;d++)field[l+d]+=h}}}};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,d,f,g,h,j,l,k,t,o=this.size-2;for(g=1;g<o;g++){t=this.size2*g;l=(g-this.halfsize)/this.halfsize;for(f=1;f<o;f++){k=t+this.size*f;j=(f-this.halfsize)/this.halfsize;for(d=1;d<o;d++){h=(d-this.halfsize)/this.halfsize;e=k+d;this.polygonize(h,j,l,e,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,e=new THREE.Geometry,d=[];this.render(function(f){var g,h,j,l,k,t,o,n;for(g=
|
|
|
-0;g<f.count;g++){o=g*3;k=o+1;n=o+2;h=f.positionArray[o];j=f.positionArray[k];l=f.positionArray[n];t=new THREE.Vector3(h,j,l);h=f.normalArray[o];j=f.normalArray[k];l=f.normalArray[n];o=new THREE.Vector3(h,j,l);o.normalize();k=new THREE.Vertex(t);e.vertices.push(k);d.push(o)}nfaces=f.count/3;for(g=0;g<nfaces;g++){o=(b+g)*3;k=o+1;n=o+2;t=d[o];h=d[k];j=d[n];o=new THREE.Face3(o,k,n,[t,h,j]);e.faces.push(o)}b+=nfaces;f.count=0});return e};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;
|
|
|
+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,d){return b+(e-b)*d};this.VIntX=function(b,e,d,f,g,h,k,l,j,t){g=(g-j)/(t-j);j=this.normal_cache;e[f]=h+g*this.delta;e[f+1]=k;e[f+2]=l;d[f]=this.lerp(j[b],j[b+3],g);d[f+1]=this.lerp(j[b+1],j[b+4],g);d[f+2]=this.lerp(j[b+2],j[b+5],g)};this.VIntY=function(b,e,d,f,g,h,k,l,j,t){g=(g-j)/(t-j);j=this.normal_cache;e[f]=h;e[f+1]=k+g*this.delta;e[f+
|
|
|
+2]=l;e=b+this.yd*3;d[f]=this.lerp(j[b],j[e],g);d[f+1]=this.lerp(j[b+1],j[e+1],g);d[f+2]=this.lerp(j[b+2],j[e+2],g)};this.VIntZ=function(b,e,d,f,g,h,k,l,j,t){g=(g-j)/(t-j);j=this.normal_cache;e[f]=h;e[f+1]=k;e[f+2]=l+g*this.delta;e=b+this.zd*3;d[f]=this.lerp(j[b],j[e],g);d[f+1]=this.lerp(j[b+1],j[e+1],g);d[f+2]=this.lerp(j[b+2],j[e+2],g)};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,d,f,g,h){var k=f+1,l=f+this.yd,j=f+this.zd,t=k+this.yd,o=k+this.zd,n=f+this.yd+this.zd,w=k+this.yd+this.zd,p=0,z=this.field[f],v=this.field[k],y=this.field[l],m=this.field[t],D=this.field[j],C=this.field[o],I=this.field[n],L=this.field[w];z<g&&(p|=1);v<g&&(p|=2);y<g&&(p|=8);m<g&&(p|=4);D<g&&(p|=16);C<g&&(p|=32);I<g&&(p|=128);L<g&&(p|=64);var H=THREE.edgeTable[p];if(H==0)return 0;
|
|
|
+var B=this.delta,K=b+B,J=e+B;B=d+B;if(H&1){this.compNorm(f);this.compNorm(k);this.VIntX(f*3,this.vlist,this.nlist,0,g,b,e,d,z,v)}if(H&2){this.compNorm(k);this.compNorm(t);this.VIntY(k*3,this.vlist,this.nlist,3,g,K,e,d,v,m)}if(H&4){this.compNorm(l);this.compNorm(t);this.VIntX(l*3,this.vlist,this.nlist,6,g,b,J,d,y,m)}if(H&8){this.compNorm(f);this.compNorm(l);this.VIntY(f*3,this.vlist,this.nlist,9,g,b,e,d,z,y)}if(H&16){this.compNorm(j);this.compNorm(o);this.VIntX(j*3,this.vlist,this.nlist,12,g,b,e,B,
|
|
|
+D,C)}if(H&32){this.compNorm(o);this.compNorm(w);this.VIntY(o*3,this.vlist,this.nlist,15,g,K,e,B,C,L)}if(H&64){this.compNorm(n);this.compNorm(w);this.VIntX(n*3,this.vlist,this.nlist,18,g,b,J,B,I,L)}if(H&128){this.compNorm(j);this.compNorm(n);this.VIntY(j*3,this.vlist,this.nlist,21,g,b,e,B,D,I)}if(H&256){this.compNorm(f);this.compNorm(j);this.VIntZ(f*3,this.vlist,this.nlist,24,g,b,e,d,z,D)}if(H&512){this.compNorm(k);this.compNorm(o);this.VIntZ(k*3,this.vlist,this.nlist,27,g,K,e,d,v,C)}if(H&1024){this.compNorm(t);
|
|
|
+this.compNorm(w);this.VIntZ(t*3,this.vlist,this.nlist,30,g,K,J,d,m,L)}if(H&2048){this.compNorm(l);this.compNorm(n);this.VIntZ(l*3,this.vlist,this.nlist,33,g,b,J,d,y,I)}p<<=4;for(g=f=0;THREE.triTable[p+g]!=-1;){b=p+g;e=b+1;d=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[e],3*THREE.triTable[d],h);g+=3;f++}return f};this.posnormtriv=function(b,e,d,f,g,h){var k=this.count*3;this.positionArray[k]=b[d];this.positionArray[k+1]=b[d+1];this.positionArray[k+2]=b[d+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[g];this.positionArray[k+7]=b[g+1];this.positionArray[k+8]=b[g+2];this.normalArray[k]=e[d];this.normalArray[k+1]=e[d+1];this.normalArray[k+2]=e[d+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[g];this.normalArray[k+7]=e[g+1];this.normalArray[k+8]=e[g+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=
|
|
|
+function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;b(this)}};this.addBall=function(b,e,d,f,g){var h=this.size*Math.sqrt(f/g),k=d*this.size,l=e*this.size,j=b*this.size,t=Math.floor(k-h);t<1&&(t=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var o=Math.floor(l-h);o<1&&(o=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var n=Math.floor(j-h);n<1&&(n=1);h=Math.floor(j+h);
|
|
|
+h>this.size-1&&(h=this.size-1);for(var w,p,z,v,y,m;t<k;t++){j=this.size2*t;p=t/this.size-d;y=p*p;for(p=o;p<l;p++){z=j+this.size*p;w=p/this.size-e;m=w*w;for(w=n;w<h;w++){v=w/this.size-b;v=f/(1.0E-6+v*v+m+y)-g;v>0&&(this.field[z+w]+=v)}}}};this.addPlaneX=function(b,e){var d,f,g,h,k,l=this.size,j=this.yd,t=this.zd,o=this.field,n=l*Math.sqrt(b/e);n>l&&(n=l);for(d=0;d<n;d++){f=d/l;f*=f;h=b/(1.0E-4+f)-e;if(h>0)for(f=0;f<l;f++){k=d+f*j;for(g=0;g<l;g++)o[t*g+k]+=h}}};this.addPlaneY=function(b,e){var d,f,
|
|
|
+g,h,k,l,j=this.size,t=this.yd,o=this.zd,n=this.field,w=j*Math.sqrt(b/e);w>j&&(w=j);for(f=0;f<w;f++){d=f/j;d*=d;h=b/(1.0E-4+d)-e;if(h>0){k=f*t;for(d=0;d<j;d++){l=k+d;for(g=0;g<j;g++)n[o*g+l]+=h}}}};this.addPlaneZ=function(b,e){var d,f,g,h,k,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/e);dist>size&&(dist=size);for(g=0;g<dist;g++){d=g/size;d*=d;h=b/(1.0E-4+d)-e;if(h>0){k=zd*g;for(f=0;f<size;f++){l=k+f*yd;for(d=0;d<size;d++)field[l+d]+=h}}}};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,d,f,g,h,k,l,j,t,o=this.size-2;for(g=1;g<o;g++){t=this.size2*g;l=(g-this.halfsize)/this.halfsize;for(f=1;f<o;f++){j=t+this.size*f;k=(f-this.halfsize)/this.halfsize;for(d=1;d<o;d++){h=(d-this.halfsize)/this.halfsize;e=j+d;this.polygonize(h,k,l,e,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,e=new THREE.Geometry,d=[];this.render(function(f){var g,h,k,l,j,t,o,n;for(g=
|
|
|
+0;g<f.count;g++){o=g*3;j=o+1;n=o+2;h=f.positionArray[o];k=f.positionArray[j];l=f.positionArray[n];t=new THREE.Vector3(h,k,l);h=f.normalArray[o];k=f.normalArray[j];l=f.normalArray[n];o=new THREE.Vector3(h,k,l);o.normalize();j=new THREE.Vertex(t);e.vertices.push(j);d.push(o)}nfaces=f.count/3;for(g=0;g<nfaces;g++){o=(b+g)*3;j=o+1;n=o+2;t=d[o];h=d[j];k=d[n];o=new THREE.Face3(o,j,n,[t,h,k]);e.faces.push(o)}b+=nfaces;f.count=0});return e};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,
|
|
@@ -169,17 +169,17 @@ 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.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};
|
|
|
-THREE.MeshCollider=function(a,c,b,e){this.vertices=a;this.faces=c;this.normals=b;this.box=e;this.numFaces=this.faces.length};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[];console.log("Collision system init / 004")};THREE.Collisions=new THREE.CollisionSystem;
|
|
|
+THREE.MeshCollider=function(a,c,b,e){this.vertices=a;this.faces=c;this.normals=b;this.box=e;this.numFaces=this.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[];console.log("Collision system init / 004")};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,d,f=0;c=0;for(b=this.colliders.length;c<b;c++){d=this.colliders[c];e=this.rayCast(a,d);if(e<Number.MAX_VALUE){d.distance=e;e>f?this.hits.push(d):this.hits.unshift(d);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<Number.MAX_VALUE){c[b].distance=e;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,d=0;d<c.numFaces/3;d++){var f=d*3;f=this.rayTriangle(b,c.vertices[c.faces[f+0]],c.vertices[c.faces[f+1]],c.vertices[c.faces[f+2]],e);if(f<e){e=f;c.normal=this.collisionNormal.clone().normalize()}}return e};
|
|
|
-THREE.CollisionSystem.prototype.rayTriangle=function(a,c,b,e,d){var f=THREE.CollisionSystem.__v1,g=THREE.CollisionSystem.__v2,h=new THREE.Vector3;this.collisionNormal.set(0,0,0);f.sub(b,c);g.sub(e,b);h.cross(f,g);g=h.dot(a.direction);if(!(g<0))return Number.MAX_VALUE;f=h.dot(c)-h.dot(a.origin);if(!(f<=0))return Number.MAX_VALUE;if(!(f>=g*d))return Number.MAX_VALUE;f/=g;var j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(f);j.addSelf(a.origin);if(Math.abs(h.x)>Math.abs(h.y))if(Math.abs(h.x)>
|
|
|
-Math.abs(h.z)){a=j.y-c.y;d=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;d=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(h.y)>Math.abs(h.z)){a=j.x-c.x;d=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;d=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=d*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*=d*j-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;this.collisionNormal=
|
|
|
-h;return f};THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=new THREE.Ray(a.origin.clone(),a.direction.clone()),e=THREE.Matrix4.makeInvert(c.matrixWorld);e.multiplyVector3(b.origin);e.rotateAxis(b.direction);b.direction.normalize();return b};
|
|
|
-THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;b=c.dynamic&&c.mesh&&c.mesh.matrixWorld?this.makeRayLocal(a,c.mesh):new THREE.Ray(a.origin.clone(),a.direction.clone());var e=0,d=0,f=0,g=0,h=0,j=0,l=!0;if(b.origin.x<c.min.x){e=c.min.x-b.origin.x;e/=b.direction.x;l=!1;g=-1}else if(b.origin.x>c.max.x){e=c.max.x-b.origin.x;e/=b.direction.x;l=!1;g=1}if(b.origin.y<c.min.y){d=c.min.y-b.origin.y;d/=b.direction.y;l=!1;h=-1}else if(b.origin.y>c.max.y){d=c.max.y-b.origin.y;d/=b.direction.y;l=!1;h=
|
|
|
-1}if(b.origin.z<c.min.z){f=c.min.z-b.origin.z;f/=b.direction.z;l=!1;j=-1}else if(b.origin.z>c.max.z){f=c.max.z-b.origin.z;f/=b.direction.z;l=!1;j=1}if(l)return-1;l=0;if(d>e){l=1;e=d}if(f>e){l=2;e=f}switch(l){case 0:h=b.origin.y+b.direction.y*e;if(h<c.min.y||h>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=new THREE.Vector3(g,0,0);break;case 1:g=b.origin.x+b.direction.x*e;if(g<c.min.x||g>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=new THREE.Vector3(0,h,0);break;case 2:g=b.origin.x+b.direction.x*e;if(g<c.min.x||g>c.max.x)return Number.MAX_VALUE;h=b.origin.y+b.direction.y*e;if(h<c.min.y||h>c.max.y)return Number.MAX_VALUE;c.normal=new THREE.Vector3(0,0,j)}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.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),e=Number.MAX_VALUE,d=0;d<c.numFaces/3;d++){var f=d*3;f=this.rayTriangle(b,c.vertices[c.faces[f+0]],c.vertices[c.faces[f+1]],c.vertices[c.faces[f+2]],e,this.collisionNormal);if(f<e){e=f;c.normal.copy(this.collisionNormal);c.normal.normalize()}}return e};
|
|
|
+THREE.CollisionSystem.prototype.rayTriangle=function(a,c,b,e,d,f){var g=THREE.CollisionSystem.__v1,h=THREE.CollisionSystem.__v2;f.set(0,0,0);g.sub(b,c);h.sub(e,b);f.cross(g,h);h=f.dot(a.direction);if(!(h<0))return Number.MAX_VALUE;g=f.dot(c)-f.dot(a.origin);if(!(g<=0))return Number.MAX_VALUE;if(!(g>=h*d))return Number.MAX_VALUE;g/=h;h=THREE.CollisionSystem.__v3;h.copy(a.direction);h.multiplyScalar(g);h.addSelf(a.origin);if(Math.abs(f.x)>Math.abs(f.y))if(Math.abs(f.x)>Math.abs(f.z)){a=h.y-c.y;f=b.y-
|
|
|
+c.y;d=e.y-c.y;h=h.z-c.z;b=b.z-c.z;e=e.z-c.z}else{a=h.x-c.x;f=b.x-c.x;d=e.x-c.x;h=h.y-c.y;b=b.y-c.y;e=e.y-c.y}else if(Math.abs(f.y)>Math.abs(f.z)){a=h.x-c.x;f=b.x-c.x;d=e.x-c.x;h=h.z-c.z;b=b.z-c.z;e=e.z-c.z}else{a=h.x-c.x;f=b.x-c.x;d=e.x-c.x;h=h.y-c.y;b=b.y-c.y;e=e.y-c.y}c=f*e-b*d;if(c==0)return Number.MAX_VALUE;c=1/c;e=(a*e-h*d)*c;if(!(e>=0))return Number.MAX_VALUE;c*=f*h-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return g};
|
|
|
+THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=new THREE.Ray(a.origin.clone(),a.direction.clone()),e=THREE.Matrix4.makeInvert(c.matrixWorld);e.multiplyVector3(b.origin);e.rotateAxis(b.direction);b.direction.normalize();return b};
|
|
|
+THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;b=c.dynamic&&c.mesh&&c.mesh.matrixWorld?this.makeRayLocal(a,c.mesh):new THREE.Ray(a.origin.clone(),a.direction.clone());var e=0,d=0,f=0,g=0,h=0,k=0,l=!0;if(b.origin.x<c.min.x){e=c.min.x-b.origin.x;e/=b.direction.x;l=!1;g=-1}else if(b.origin.x>c.max.x){e=c.max.x-b.origin.x;e/=b.direction.x;l=!1;g=1}if(b.origin.y<c.min.y){d=c.min.y-b.origin.y;d/=b.direction.y;l=!1;h=-1}else if(b.origin.y>c.max.y){d=c.max.y-b.origin.y;d/=b.direction.y;l=!1;h=
|
|
|
+1}if(b.origin.z<c.min.z){f=c.min.z-b.origin.z;f/=b.direction.z;l=!1;k=-1}else if(b.origin.z>c.max.z){f=c.max.z-b.origin.z;f/=b.direction.z;l=!1;k=1}if(l)return-1;l=0;if(d>e){l=1;e=d}if(f>e){l=2;e=f}switch(l){case 0:h=b.origin.y+b.direction.y*e;if(h<c.min.y||h>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=new THREE.Vector3(g,0,0);break;case 1:g=b.origin.x+b.direction.x*e;if(g<c.min.x||g>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=new THREE.Vector3(0,h,0);break;case 2:g=b.origin.x+b.direction.x*e;if(g<c.min.x||g>c.max.x)return Number.MAX_VALUE;h=b.origin.y+b.direction.y*e;if(h<c.min.y||h>c.max.y)return Number.MAX_VALUE;c.normal=new THREE.Vector3(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.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.CollisionUtils.MeshColliderWBox=function(a){for(var c=a.geometry.vertices,b=c.length,e=a.geometry.faces,d=e.length,f=[],g=[],h=[],j=0;j<b;j++)f.push(new THREE.Vector3(c[j].position.x,c[j].position.y,c[j].position.z));for(j=0;j<d;j++){g.push(e[j].a,e[j].b,e[j].c);h.push(new THREE.Vector3(e[j].normal.x,e[j].normal.y,e[j].normal.z))}c=new THREE.MeshCollider(f,g,h,THREE.CollisionUtils.MeshOBB(a));c.mesh=a;return c};
|
|
|
+THREE.CollisionUtils.MeshColliderWBox=function(a){for(var c=a.geometry.vertices,b=c.length,e=a.geometry.faces,d=e.length,f=[],g=[],h=[],k=0;k<b;k++)f.push(new THREE.Vector3(c[k].position.x,c[k].position.y,c[k].position.z));for(k=0;k<d;k++){g.push(e[k].a,e[k].b,e[k].c);h.push(new THREE.Vector3(e[k].normal.x,e[k].normal.y,e[k].normal.z))}c=new THREE.MeshCollider(f,g,h,THREE.CollisionUtils.MeshOBB(a));c.mesh=a;return c};
|