X-Git-Url: http://git.scottworley.com/nt3d/blobdiff_plain/aceb2da8b7e5ac5a9e5e1a994680bfff8f726209..1a18e646fe84c30984a5298c284d959e925e6a54:/nt3d.js?ds=inline diff --git a/nt3d.js b/nt3d.js index bae29f2..0443913 100644 --- a/nt3d.js +++ b/nt3d.js @@ -46,6 +46,22 @@ nt3d = { closed_quadstrip: function(strip) { return this.quadstrip(strip.concat([strip[0], strip[1]])); }, + circle: function(r, n) { + var points = []; + for (var i = 0; i < n; i++) { + points.push([r*Math.cos(2*Math.PI*i/n), + r*Math.sin(2*Math.PI*i/n), + 0]); + } + return points; + }, + cone: function(base_center, apex, radius, steps) { + var base = this.circle(radius, steps); + base = this.rotate_onto(base, [0,0,1], this.sub(apex, base_center)); + base = this.translate(base, base_center); + return this.closed_trianglefan([apex].concat(base)).concat( + this.trianglefan(base.reverse())); + }, extrude: function(shape, path, shapenormals, pathnormals) { var guts_result = nt3d._extrude_guts(shape, path, shapenormals, pathnormals); // Add the end-caps