From 53842b875fd12d6c1a2f64f01be96c553122944a Mon Sep 17 00:00:00 2001 From: Wliu Date: Sat, 10 Jan 2015 18:25:25 -0500 Subject: [PATCH 1/7] Make the cylinders open-capped -Re-enabled transparency (since this was the only thing blocking it from being enabled) -Currently bugged since ALL faces are removed --- index.html | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 693fa77..022f29c 100644 --- a/index.html +++ b/index.html @@ -236,14 +236,14 @@ smallGeoR2=smallGeoR2 + "+0.01"; } - var smallCylinderGeom=new THREE.CylinderGeometry(eval(smallGeoR1), eval(smallGeoR2), 0.5, 50); + var smallCylinderGeom=new THREE.CylinderGeometry(eval(smallGeoR1), eval(smallGeoR2), 0.5, 50, 1, true); smallCylinderGeom.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); - var largeCylinderGeom=new THREE.CylinderGeometry(eval(bigGeoR1), eval(bigGeoR2), 0.5, 360); + var largeCylinderGeom=new THREE.CylinderGeometry(eval(bigGeoR1), eval(bigGeoR2), 0.5, 360, 1, true); largeCylinderGeom.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); var smallCylinderBSP=new ThreeBSP(smallCylinderGeom); var largeCylinderBSP=new ThreeBSP(largeCylinderGeom); var intersectionBSP=largeCylinderBSP.subtract(smallCylinderBSP); - var material=new THREE.MeshPhongMaterial({color: 0xffff00/*, transparent: true, opacity: 0.5*/}); + var material=new THREE.MeshPhongMaterial({color: 0xffff00, transparent: true, opacity: 0.5}); var hollowCylinder=intersectionBSP.toMesh(material); hollowCylinder.rotation.set(0, 0, Math.PI/2); this.group.add(hollowCylinder); @@ -254,11 +254,11 @@ Graph.prototype.addSolidWithoutHoles=function(leftRadius, rightRadius){ for(var i=this.bound1; i Date: Sun, 11 Jan 2015 12:16:39 -0500 Subject: [PATCH 2/7] Remove only the inside faces and not the outside ones This requires a modified version of three.js which I will create a PR for soon on the three.js repo --- index.html | 14 +++++++++++++- js/three.min.js | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 022f29c..d133e41 100644 --- a/index.html +++ b/index.html @@ -254,7 +254,19 @@ Graph.prototype.addSolidWithoutHoles=function(leftRadius, rightRadius){ for(var i=this.bound1; i=this.bound2) + { + geometry=new THREE.CylinderGeometry(eval(leftRadius), eval(rightRadius), this.quality, 100, 1, true, false); + } + else + { + geometry=new THREE.CylinderGeometry(eval(leftRadius), eval(rightRadius), this.quality, 100, 1, true, true); + } geometry.verticesNeedUpdate=true; geometry.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+this.quality/2), -this.axisOfRotation)); diff --git a/js/three.min.js b/js/three.min.js index a88b4af..90e5421 100644 --- a/js/three.min.js +++ b/js/three.min.js @@ -709,10 +709,10 @@ THREE.BoxGeometry=function(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,s){var u,v=h.wi h.faceVertexUvs[0].push([g.clone(),u,G.clone()])}THREE.Geometry.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.widthSegments=d||1;this.heightSegments=e||1;this.depthSegments=f||1;var h=this;d=a/2;e=b/2;f=c/2;g("z","y",-1,-1,c,b,d,0);g("z","y",1,-1,c,b,-d,1);g("x","z",1,1,a,c,e,2);g("x","z",1,-1,a,c,-e,3);g("x","y",1,-1,a,b,f,4);g("x","y",-1,-1,a,b,-f,5);this.mergeVertices()};THREE.BoxGeometry.prototype=Object.create(THREE.Geometry.prototype); THREE.CircleGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="CircleGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};a=a||50;b=void 0!==b?Math.max(3,b):8;c=void 0!==c?c:0;d=void 0!==d?d:2*Math.PI;var e,f=[];e=new THREE.Vector3;var g=new THREE.Vector2(.5,.5);this.vertices.push(e);f.push(g);for(e=0;e<=b;e++){var h=new THREE.Vector3,k=c+e/b*d;h.x=a*Math.cos(k);h.y=a*Math.sin(k);this.vertices.push(h);f.push(new THREE.Vector2((h.x/a+1)/2,(h.y/a+1)/2))}c=new THREE.Vector3(0, 0,1);for(e=1;e<=b;e++)this.faces.push(new THREE.Face3(e,e+1,0,[c.clone(),c.clone(),c.clone()])),this.faceVertexUvs[0].push([f[e].clone(),f[e+1].clone(),g.clone()]);this.computeFaceNormals();this.boundingSphere=new THREE.Sphere(new THREE.Vector3,a)};THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.CubeGeometry=function(a,b,c,d,e,f){console.warn("THREE.CubeGeometry has been renamed to THREE.BoxGeometry.");return new THREE.BoxGeometry(a,b,c,d,e,f)}; -THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f};a=void 0!==a?a:20;b=void 0!==b?b:20;c=void 0!==c?c:100;d=d||8;e=e||1;f=void 0!==f?f:!1;var g=c/2,h,k,n=[],p=[];for(k=0;k<=e;k++){var q=[],m=[],r=k/e,t=r*(b-a)+a;for(h=0;h<=d;h++){var s=h/d,u=new THREE.Vector3;u.x=t*Math.sin(s*Math.PI*2);u.y=-r*c+g;u.z=t*Math.cos(s*Math.PI*2);this.vertices.push(u);q.push(this.vertices.length- +THREE.CylinderGeometry=function(a,b,c,d,e,f,ggggg){THREE.Geometry.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,openEnded2:ggggg};a=void 0!==a?a:20;b=void 0!==b?b:20;c=void 0!==c?c:100;d=d||8;e=e||1;f=void 0!==f?f:!1;ggggg=void 0!==ggggg?ggggg:!1;var g=c/2,h,k,n=[],p=[];for(k=0;k<=e;k++){var q=[],m=[],r=k/e,t=r*(b-a)+a;for(h=0;h<=d;h++){var s=h/d,u=new THREE.Vector3;u.x=t*Math.sin(s*Math.PI*2);u.y=-r*c+g;u.z=t*Math.cos(s*Math.PI*2);this.vertices.push(u);q.push(this.vertices.length- 1);m.push(new THREE.Vector2(s,1-r))}n.push(q);p.push(m)}c=(b-a)/c;for(h=0;h=d)return new THREE.Vector2(c,a);d=Math.sqrt(d/2)}else a=!1,1E-10d?-1E-10>f&&(a=!0):Math.sign(e)== Math.sign(g)&&(a=!0),a?(c=-e,a=d,d=Math.sqrt(h)):(c=d,a=e,d=Math.sqrt(h/2));return new THREE.Vector2(c/d,a/d)}function e(a,b){var c,d;for(P=a.length;0<=--P;){c=P;d=P-1;0>d&&(d=a.length-1);for(var e=0,f=r+2*p,e=0;e Date: Sun, 11 Jan 2015 16:01:29 -0500 Subject: [PATCH 3/7] Do the same thing for addBSP -This doesn't work yet, most likely due to ThreeCSG interfering with something --- index.html | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index d133e41..154a05c 100644 --- a/index.html +++ b/index.html @@ -236,10 +236,27 @@ smallGeoR2=smallGeoR2 + "+0.01"; } - var smallCylinderGeom=new THREE.CylinderGeometry(eval(smallGeoR1), eval(smallGeoR2), 0.5, 50, 1, true); + var smallCylinderGeom, largeCylinderGeom; + if(i===this.bound1) + { + smallCylinderGeom=new THREE.CylinderGeometry(eval(smallGeoR1), eval(smallGeoR2), 0.5, 50, 1, false, true); + } + else + { + smallCylinderGeom=new THREE.CylinderGeometry(eval(smallGeoR1), eval(smallGeoR2), 0.5, 50, 1, true, true); + } smallCylinderGeom.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); - var largeCylinderGeom=new THREE.CylinderGeometry(eval(bigGeoR1), eval(bigGeoR2), 0.5, 360, 1, true); + + if(i+0.5>=this.bound2) + { + largeCylinderGeom=new THREE.CylinderGeometry(eval(bigGeoR1), eval(bigGeoR2), 0.5, 360, 1, true, false); + } + else + { + largeCylinderGeom=new THREE.CylinderGeometry(eval(bigGeoR1), eval(bigGeoR2), 0.5, 360, 1, true, true); + } largeCylinderGeom.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); + var smallCylinderBSP=new ThreeBSP(smallCylinderGeom); var largeCylinderBSP=new ThreeBSP(largeCylinderGeom); var intersectionBSP=largeCylinderBSP.subtract(smallCylinderBSP); From 6ce7922aa76c736b525b93b62368c10a134ef669 Mon Sep 17 00:00:00 2001 From: Wliu Date: Sun, 11 Jan 2015 16:36:12 -0500 Subject: [PATCH 4/7] Clean up addBSP --- index.html | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index 154a05c..1e1af80 100644 --- a/index.html +++ b/index.html @@ -228,40 +228,36 @@ render(); }; - Graph.prototype.addBSP=function(smallGeoR1, smallGeoR2, bigGeoR1, bigGeoR2){ + Graph.prototype.addBSP=function(innerCylinderSmallRadius, innerCylinderLargeRadius, outerCylinderSmallRadius, outerCylinderLargeRadius){ for(var i=this.bound1; i=this.bound2) { - largeCylinderGeom=new THREE.CylinderGeometry(eval(bigGeoR1), eval(bigGeoR2), 0.5, 360, 1, true, false); + largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), 0.5, 360, 1, true, false); } else { - largeCylinderGeom=new THREE.CylinderGeometry(eval(bigGeoR1), eval(bigGeoR2), 0.5, 360, 1, true, true); + largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), 0.5, 360, 1, true, true); } - largeCylinderGeom.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); + largeCylinder.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); - var smallCylinderBSP=new ThreeBSP(smallCylinderGeom); - var largeCylinderBSP=new ThreeBSP(largeCylinderGeom); - var intersectionBSP=largeCylinderBSP.subtract(smallCylinderBSP); - var material=new THREE.MeshPhongMaterial({color: 0xffff00, transparent: true, opacity: 0.5}); - var hollowCylinder=intersectionBSP.toMesh(material); + var hollowCylinder=new ThreeBSP(largeCylinder).subtract(new ThreeBSP(smallCylinder)).toMesh(new THREE.MeshPhongMaterial({color: 0xffff00, transparent: true, opacity: 0.5})); hollowCylinder.rotation.set(0, 0, Math.PI/2); this.group.add(hollowCylinder); } From 227b4bc396e2e316d644ea0b2d41e15d3ef2778b Mon Sep 17 00:00:00 2001 From: Wliu Date: Sun, 11 Jan 2015 16:43:04 -0500 Subject: [PATCH 5/7] It might actually be like this --- index.html | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 1e1af80..08ca3e0 100644 --- a/index.html +++ b/index.html @@ -240,21 +240,19 @@ if(i===this.bound1) { smallCylinder=new THREE.CylinderGeometry(eval(innerCylinderSmallRadius), eval(innerCylinderLargeRadius), 0.5, 50, 1, false, true); + largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), 0.5, 360, 1, false, true); } - else - { - smallCylinder=new THREE.CylinderGeometry(eval(innerCylinderSmallRadius), eval(innerCylinderLargeRadius), 0.5, 50, 1, true, true); - } - smallCylinder.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); - - if(i+0.5>=this.bound2) + else if(i+0.5>=this.bound2) { + smallCylinder=new THREE.CylinderGeometry(eval(innerCylinderSmallRadius), eval(innerCylinderLargeRadius), 0.5, 50, 1, true, false); largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), 0.5, 360, 1, true, false); } else { + smallCylinder=new THREE.CylinderGeometry(eval(innerCylinderSmallRadius), eval(innerCylinderLargeRadius), 0.5, 50, 1, true, true); largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), 0.5, 360, 1, true, true); } + smallCylinder.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); largeCylinder.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); var hollowCylinder=new ThreeBSP(largeCylinder).subtract(new ThreeBSP(smallCylinder)).toMesh(new THREE.MeshPhongMaterial({color: 0xffff00, transparent: true, opacity: 0.5})); From 79fab56fadf8db3b451e1f4d4896868ea88102c0 Mon Sep 17 00:00:00 2001 From: Wliu Date: Mon, 12 Jan 2015 20:15:30 -0500 Subject: [PATCH 6/7] Merge branch 'gh-pages' into remove-inside-faces Conflicts: index.html --- index.html | 68 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/index.html b/index.html index 08ca3e0..b5443e3 100644 --- a/index.html +++ b/index.html @@ -165,19 +165,19 @@ console.log(" Both boundY1 and boundY2 are greater than or equal to 0"); if(graph2ComparingPoint1>graph1ComparingPoint1 && graph2ComparingPoint2>graph1ComparingPoint2){ console.log(" Graph2 is higher than graph1"); - this.addBSP("this.axisOfRotation-graphArray[1].getY(i)", "this.axisOfRotation-graphArray[1].getY(i+0.5)", "this.axisOfRotation-this.getY(i)", "this.axisOfRotation-this.getY(i+0.5)"); + this.addBSP("this.axisOfRotation-graphArray[1].getY(i)", "this.axisOfRotation-graphArray[1].getY(i+step)", "this.axisOfRotation-this.getY(i)", "this.axisOfRotation-this.getY(i+step)"); } else { console.log(" Graph2 is lower than or equal to graph1"); - this.addBSP("this.axisOfRotation-this.getY(i)", "this.axisOfRotation-this.getY(i+0.5)", "this.axisOfRotation-graphArray[1].getY(i)", "this.axisOfRotation-graphArray[1].getY(i+0.5)"); + this.addBSP("this.axisOfRotation-this.getY(i)", "this.axisOfRotation-this.getY(i+step)", "this.axisOfRotation-graphArray[1].getY(i)", "this.axisOfRotation-graphArray[1].getY(i+step)"); } } else { console.log(" One of the bounds is less than 0"); if(graph2ComparingPoint1>graph1ComparingPoint1 && graph2ComparingPoint2>graph1ComparingPoint2){ console.log(" Graph2 is higher than graph1"); - this.addBSP("this.axisOfRotation+Math.abs(graphArray[1].getY(i))", "this.axisOfRotation+Math.abs(graphArray[1].getY(i+0.5))", "this.axisOfRotation-this.getY(i)", "this.axisOfRotation-this.getY(i+0.5)"); + this.addBSP("this.axisOfRotation+Math.abs(graphArray[1].getY(i))", "this.axisOfRotation+Math.abs(graphArray[1].getY(i+step))", "this.axisOfRotation-this.getY(i)", "this.axisOfRotation-this.getY(i+step)"); } else { console.log(" Graph2 is lower than or equal to graph1"); - this.addBSP("this.axisOfRotation-this.getY(i)", "this.axisOfRotation-this.getY(i+0.5)", "this.axisOfRotation-graphArray[1].getY(i)", "this.axisOfRotation-graphArray[1].getY(i+0.5)"); + this.addBSP("this.axisOfRotation-this.getY(i)", "this.axisOfRotation-this.getY(i+step)", "this.axisOfRotation-graphArray[1].getY(i)", "this.axisOfRotation-graphArray[1].getY(i+step)"); } } } else if(this.axisOfRotation<=boundY1 && this.axisOfRotation<=graphArray[1].getY(this.bound1)){ @@ -186,19 +186,19 @@ console.log(" Both boundY1 and boundY2 are greater than or equal to 0"); if(graph2ComparingPoint1>graph1ComparingPoint1 && graph2ComparingPoint2>graph1ComparingPoint2){ console.log(" Graph2 is higher than graph1"); - this.addBSP("Math.abs(this.axisOfRotation)+this.getY(i)", "Math.abs(this.axisOfRotation)+this.getY(i+0.5)", "Math.abs(this.axisOfRotation)+graphArray[1].getY(i)", "Math.abs(this.axisOfRotation)+graphArray[1].getY(i+0.5)"); + this.addBSP("Math.abs(this.axisOfRotation)+this.getY(i)", "Math.abs(this.axisOfRotation)+this.getY(i+step)", "Math.abs(this.axisOfRotation)+graphArray[1].getY(i)", "Math.abs(this.axisOfRotation)+graphArray[1].getY(i+step)"); } else { console.log(" Graph2 is lower than or equal to graph1"); - this.addBSP("Math.abs(this.axisOfRotation)+graphArray[1].getY(i)", "Math.abs(this.axisOfRotation)+graphArray[1].getY(i+0.5)", "Math.abs(this.axisOfRotation)+this.getY(i)", "Math.abs(this.axisOfRotation)+this.getY(i+0.5)"); + this.addBSP("Math.abs(this.axisOfRotation)+graphArray[1].getY(i)", "Math.abs(this.axisOfRotation)+graphArray[1].getY(i+step)", "Math.abs(this.axisOfRotation)+this.getY(i)", "Math.abs(this.axisOfRotation)+this.getY(i+step)"); } } else { console.log(" One of the bounds is less than 0"); if(graph2ComparingPoint1>graph1ComparingPoint1 && graph2ComparingPoint2>graph1ComparingPoint2){ console.log(" Graph2 is higher than graph1"); - this.addBSP("Math.abs(this.axisOfRotation-this.getY(i))", "Math.abs(this.axisOfRotation-this.getY(i+0.5))", "Math.abs(this.axisOfRotation-graphArray[1].getY(i))", "Math.abs(this.axisOfRotation-graphArray[1].getY(i+0.5))"); + this.addBSP("Math.abs(this.axisOfRotation-this.getY(i))", "Math.abs(this.axisOfRotation-this.getY(i+step))", "Math.abs(this.axisOfRotation-graphArray[1].getY(i))", "Math.abs(this.axisOfRotation-graphArray[1].getY(i+step))"); } else { console.log(" Graph2 is lower than or equal to graph1"); - this.addBSP("Math.abs(this.axisOfRotation-graphArray[1].getY(i))", "Math.abs(this.axisOfRotation-graphArray[1].getY(i+0.5))", "Math.abs(this.axisOfRotation-this.getY(i))", "Math.abs(this.axisOfRotation-this.getY(i+0.5))"); + this.addBSP("Math.abs(this.axisOfRotation-graphArray[1].getY(i))", "Math.abs(this.axisOfRotation-graphArray[1].getY(i+step))", "Math.abs(this.axisOfRotation-this.getY(i))", "Math.abs(this.axisOfRotation-this.getY(i+step))"); } } } else { @@ -211,49 +211,55 @@ console.log(" BoundY1 is equal to boundY2 and bound1 does not equal bound2"); if(this.axisOfRotation>boundY1){ console.log(" Axis of rotation is greater than boundY1"); - this.addBSP("Math.abs(this.axisOfRotation-this.getY(i))", "Math.abs(this.axisOfRotation-this.getY(i+0.5))", "Math.abs(this.axisOfRotation)", "Math.abs(this.axisOfRotation)"); + this.addBSP("Math.abs(this.axisOfRotation-this.getY(i))", "Math.abs(this.axisOfRotation-this.getY(i+step))", "Math.abs(this.axisOfRotation)", "Math.abs(this.axisOfRotation)"); } else if(this.axisOfRotationthis.bound2) //Prevent the solid from extending beyond the second bound if it can't be divided by the quality + { + step=this.bound2-i; + } + var smallCylinder, largeCylinder; if(i===this.bound1) { - smallCylinder=new THREE.CylinderGeometry(eval(innerCylinderSmallRadius), eval(innerCylinderLargeRadius), 0.5, 50, 1, false, true); - largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), 0.5, 360, 1, false, true); + smallCylinder=new THREE.CylinderGeometry(eval(innerCylinderSmallRadius), eval(innerCylinderLargeRadius), step, 50, 1, false, true); + largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), step, 360, 1, false, true); } - else if(i+0.5>=this.bound2) + else if(i+step>=this.bound2) { - smallCylinder=new THREE.CylinderGeometry(eval(innerCylinderSmallRadius), eval(innerCylinderLargeRadius), 0.5, 50, 1, true, false); - largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), 0.5, 360, 1, true, false); + smallCylinder=new THREE.CylinderGeometry(eval(innerCylinderSmallRadius), eval(innerCylinderLargeRadius), step, 50, 1, true, false); + largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), step, 360, 1, true, false); } else { - smallCylinder=new THREE.CylinderGeometry(eval(innerCylinderSmallRadius), eval(innerCylinderLargeRadius), 0.5, 50, 1, true, true); - largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), 0.5, 360, 1, true, true); + smallCylinder=new THREE.CylinderGeometry(eval(innerCylinderSmallRadius), eval(innerCylinderLargeRadius), step, 50, 1, true, true); + largeCylinder=new THREE.CylinderGeometry(eval(outerCylinderSmallRadius), eval(outerCylinderLargeRadius), step, 360, 1, true, true); } - smallCylinder.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); - largeCylinder.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+0.5/2), -this.axisOfRotation)); + smallCylinder.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+step/2), -this.axisOfRotation)); + largeCylinder.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+step/2), -this.axisOfRotation)); var hollowCylinder=new ThreeBSP(largeCylinder).subtract(new ThreeBSP(smallCylinder)).toMesh(new THREE.MeshPhongMaterial({color: 0xffff00, transparent: true, opacity: 0.5})); hollowCylinder.rotation.set(0, 0, Math.PI/2); @@ -263,23 +269,29 @@ }; Graph.prototype.addSolidWithoutHoles=function(leftRadius, rightRadius){ - for(var i=this.bound1; ithis.bound2) //Prevent the solid from extending beyond the second bound if it can't be divided by the quality + { + step=this.bound2-i; + } + var geometry; if(i===this.bound1) { - geometry=new THREE.CylinderGeometry(eval(leftRadius), eval(rightRadius), this.quality, 100, 1, false, true); + geometry=new THREE.CylinderGeometry(eval(leftRadius), eval(rightRadius), step, 100, 1, false, true); } - else if(i+this.quality>=this.bound2) + else if(i+step>=this.bound2) { - geometry=new THREE.CylinderGeometry(eval(leftRadius), eval(rightRadius), this.quality, 100, 1, true, false); + geometry=new THREE.CylinderGeometry(eval(leftRadius), eval(rightRadius), step, 100, 1, true, false); } else { - geometry=new THREE.CylinderGeometry(eval(leftRadius), eval(rightRadius), this.quality, 100, 1, true, true); + geometry=new THREE.CylinderGeometry(eval(leftRadius), eval(rightRadius), step, 100, 1, true, true); } geometry.verticesNeedUpdate=true; - geometry.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+this.quality/2), -this.axisOfRotation)); + geometry.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+step/2), -this.axisOfRotation)); var material=new THREE.MeshPhongMaterial({color: 0xffff00, transparent: true, opacity: 0.5}); var plane=new THREE.Mesh(geometry, material); From 645dcca478f29cfffbf9c88ab9110deab22fac9c Mon Sep 17 00:00:00 2001 From: Wliu Date: Wed, 14 Jan 2015 19:34:29 -0500 Subject: [PATCH 7/7] Merge branch 'gh-pages' into remove-inside-faces Conflicts: index.html --- index.html | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/index.html b/index.html index b5443e3..239fbca 100644 --- a/index.html +++ b/index.html @@ -108,11 +108,8 @@ } var geometry=new THREE.Geometry(); - geometry.verticesNeedUpdate=true; - var spline=new THREE.SplineCurve3(points); var splinePoints=spline.getPoints(points.length-1); - for(i=0; iboundY2){ //Switch the bounds around so that the for loop works + if(this.bound1>this.bound2){ //Switch the bounds around so that the for loop works var temp=this.bound2; this.bound2=this.bound1; this.bound1=temp; @@ -290,7 +287,6 @@ { geometry=new THREE.CylinderGeometry(eval(leftRadius), eval(rightRadius), step, 100, 1, true, true); } - geometry.verticesNeedUpdate=true; geometry.applyMatrix(new THREE.Matrix4().makeTranslation(0, -(i+step/2), -this.axisOfRotation)); var material=new THREE.MeshPhongMaterial({color: 0xffff00, transparent: true, opacity: 0.5}); @@ -388,10 +384,7 @@ function addAxis(){ var geometry=new THREE.Geometry(); - geometry.verticesNeedUpdate=true; - var axes=new THREE.Geometry(); - axes.verticesNeedUpdate=true; for(var i=-size; i<=size; i+=1){ if(i){