|
@@ -38,7 +38,7 @@ var Torus=function(a,d,b,f){this.radius=a||100;this.tube=d||40;this.segmentsR=b|
|
|
|
var Icosahedron=function(a){function d(v,q,n){var p=Math.sqrt(v*v+q*q+n*n);return h.vertices.push(new THREE.Vertex(new THREE.Vector3(v/p,q/p,n/p)))-1}function b(v,q,n,p){p.faces.push(new THREE.Face3(v,q,n))}function f(v,q){var n=h.vertices[v].position,p=h.vertices[q].position;return d((n.x+p.x)/2,(n.y+p.y)/2,(n.z+p.z)/2)}var h=this,c=new THREE.Geometry,e;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;d(-1,a,0);d(1,a,0);d(-1,-a,0);d(1,-a,0);d(0,-1,a);d(0,1,a);d(0,-1,-a);d(0,
|
|
|
1,-a);d(a,0,-1);d(a,0,1);d(-a,0,-1);d(-a,0,1);b(0,11,5,c);b(0,5,1,c);b(0,1,7,c);b(0,7,10,c);b(0,10,11,c);b(1,5,9,c);b(5,11,4,c);b(11,10,2,c);b(10,7,6,c);b(7,1,8,c);b(3,9,4,c);b(3,4,2,c);b(3,2,6,c);b(3,6,8,c);b(3,8,9,c);b(4,9,5,c);b(2,4,11,c);b(6,2,10,c);b(8,6,7,c);b(9,8,1,c);for(a=0;a<this.subdivisions;a++){e=new THREE.Geometry;for(var g in c.faces){var j=f(c.faces[g].a,c.faces[g].b),m=f(c.faces[g].b,c.faces[g].c),k=f(c.faces[g].c,c.faces[g].a);b(c.faces[g].a,j,k,e);b(c.faces[g].b,m,j,e);b(c.faces[g].c,
|
|
|
k,m,e);b(j,m,k,e)}c.faces=e.faces}h.faces=c.faces;delete c;delete e;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
|
|
|
-function LathedObject(a,d,b){THREE.Geometry.call(this);this.nsteps=d||12;this.latheAngle=b||2*Math.PI;d=this.latheAngle/this.nsteps;for(var f=[],h=[],c=[],e=[],g=0;g<a.length;g++){this.vertices.push(new THREE.Vertex(a[g]));h[g]=this.vertices.length-1;f[g]=new THREE.Vector3(a[g].x,a[g].y,a[g].z)}for(var j=THREE.Matrix4.rotationZMatrix(this.stepSize),m=0;m<=this.latheAngle+0.001;m+=this.stepSize){for(g=0;g<f.length;g++)if(m<b){f[g]=j.multiplyVector3(f[g].clone());this.vertices.push(new THREE.Vertex(f[g]));
|
|
|
+function LathedObject(a,d,b){THREE.Geometry.call(this);this.nsteps=d||12;this.latheAngle=b||2*Math.PI;d=this.latheAngle/this.nsteps;for(var f=[],h=[],c=[],e=[],g=0;g<a.length;g++){this.vertices.push(new THREE.Vertex(a[g]));h[g]=this.vertices.length-1;f[g]=new THREE.Vector3(a[g].x,a[g].y,a[g].z)}for(var j=THREE.Matrix4.rotationZMatrix(this.stepSize),m=0;m<=this.latheAngle+0.0010;m+=this.stepSize){for(g=0;g<f.length;g++)if(m<b){f[g]=j.multiplyVector3(f[g].clone());this.vertices.push(new THREE.Vertex(f[g]));
|
|
|
c[g]=this.vertices.length-1}else c=e;m==0&&(e=h);for(g=0;g<h.length-1;g++){this.faces.push(new THREE.Face4(c[g],c[g+1],h[g+1],h[g]));this.uvs.push([new THREE.UV(m/b,g/a.length),new THREE.UV(m/b,(g+1)/a.length),new THREE.UV((m-d)/b,(g+1)/a.length),new THREE.UV((m-d)/b,g/a.length)])}h=c;c=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;
|
|
|
if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
|
|
|
THREE.MarchingCubes=function(a,d){THREE.Object3D.call(this);this.materials=d instanceof Array?d:[d];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=
|
|
@@ -102,5 +102,5 @@ a.bones);THREE.Loader.prototype.animation(c,a.animation)})();this.computeCentroi
|
|
|
new THREE.Color(16777215);h.setRGB(d,b,f);a.colors.push(h)},f3:function(a,d,b,f,h){a.faces.push(new THREE.Face3(d,b,f,null,a.materials[h]))},f4:function(a,d,b,f,h,c){a.faces.push(new THREE.Face4(d,b,f,h,null,a.materials[c]))},f3n:function(a,d,b,f,h,c,e,g,j){c=a.materials[c];var m=d[g*3],k=d[g*3+1];g=d[g*3+2];var v=d[j*3],q=d[j*3+1];j=d[j*3+2];a.faces.push(new THREE.Face3(b,f,h,[new THREE.Vector3(d[e*3],d[e*3+1],d[e*3+2]),new THREE.Vector3(m,k,g),new THREE.Vector3(v,q,j)],c))},f4n:function(a,d,b,f,
|
|
|
h,c,e,g,j,m,k){e=a.materials[e];var v=d[j*3],q=d[j*3+1];j=d[j*3+2];var n=d[m*3],p=d[m*3+1];m=d[m*3+2];var u=d[k*3],z=d[k*3+1];k=d[k*3+2];a.faces.push(new THREE.Face4(b,f,h,c,[new THREE.Vector3(d[g*3],d[g*3+1],d[g*3+2]),new THREE.Vector3(v,q,j),new THREE.Vector3(n,p,m),new THREE.Vector3(u,z,k)],e))},uv3:function(a,d,b,f,h,c,e){var g=[];g.push(new THREE.UV(d,b));g.push(new THREE.UV(f,h));g.push(new THREE.UV(c,e));a.push(g)},uv4:function(a,d,b,f,h,c,e,g,j){var m=[];m.push(new THREE.UV(d,b));m.push(new THREE.UV(f,
|
|
|
h));m.push(new THREE.UV(c,e));m.push(new THREE.UV(g,j));a.push(m)},init_materials:function(a,d,b){a.materials=[];for(var f=0;f<d.length;++f)a.materials[f]=[THREE.Loader.prototype.createMaterial(d[f],b)]},createMaterial:function(a,d){function b(g){g=Math.log(g)/Math.LN2;return Math.floor(g)==g}function f(g,j){var m=new Image;m.onload=function(){if(!b(this.width)||!b(this.height)){var k=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),v=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));g.image.width=
|
|
|
-k;g.image.height=v;g.image.getContext("2d").drawImage(this,0,0,k,v)}else g.image=this;g.needsUpdate=!0};m.src=j}var h,c,e;h="MeshLambertMaterial";c={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(h="MeshPhongMaterial");if(a.mapDiffuse&&d){e=document.createElement("canvas");c.map=new THREE.Texture(e);f(c.map,d+"/"+a.mapDiffuse)}else if(a.colorDiffuse){e=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;c.color=
|
|
|
-e;c.opacity=a.transparency}else if(a.DbgColor)c.color=a.DbgColor;if(a.mapLightmap&&d){e=document.createElement("canvas");c.lightMap=new THREE.Texture(e);f(c.lightMap,d+"/"+a.mapLightmap)}return new THREE[h](c)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
|
|
|
+k;g.image.height=v;g.image.getContext("2d").drawImage(this,0,0,k,v)}else g.image=this;g.needsUpdate=!0};m.src=j}var h,c,e;h="MeshLambertMaterial";c={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(h="MeshPhongMaterial");if(a.mapDiffuse&&d){e=document.createElement("canvas");c.map=new THREE.Texture(e);c.map.sourceFile=a.mapDiffuse;f(c.map,d+"/"+a.mapDiffuse)}else if(a.colorDiffuse){e=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+
|
|
|
+a.colorDiffuse[2]*255;c.color=e;c.opacity=a.transparency}else if(a.DbgColor)c.color=a.DbgColor;if(a.mapLightmap&&d){e=document.createElement("canvas");c.lightMap=new THREE.Texture(e);c.lightMap.sourceFile=a.mapLightmap;f(c.lightMap,d+"/"+a.mapLightmap)}return new THREE[h](c)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
|