From 1a18e646fe84c30984a5298c284d959e925e6a54 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 20 Dec 2012 01:18:52 -0800 Subject: [PATCH] Cones. (Cones are the first primitive solid because 3-sided cones are basically cheap arrows that can be littered all over the place for debugging.) --- cone_primitive.html | 18 ++++++++++++++++++ nt3d.js | 7 +++++++ 2 files changed, 25 insertions(+) create mode 100644 cone_primitive.html diff --git a/cone_primitive.html b/cone_primitive.html new file mode 100644 index 0000000..19a7686 --- /dev/null +++ b/cone_primitive.html @@ -0,0 +1,18 @@ + + + Cone primitive + + + + +

Cone primitive

+

There's a cone primitive.

+ + diff --git a/nt3d.js b/nt3d.js index 7472548..0443913 100644 --- a/nt3d.js +++ b/nt3d.js @@ -55,6 +55,13 @@ nt3d = { } 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 -- 2.44.1