closed_quadstrip: function(strip) {
return this.quadstrip(strip.concat([strip[0], strip[1]]));
},
- extrude: function(shape, path, shapenormals, pathnormals) {
- var guts_result = nt3d._extrude_guts(shape, path, shapenormals, pathnormals);
+ 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(path, shape, shapenormals, pathnormals) {
+
+ var guts_result = nt3d._extrude_guts(path, shape, shapenormals, pathnormals);
// Add the end-caps
// XXX: This doesn't work if shape is not convex
return guts_result.points.concat(
nt3d.trianglefan(guts_result.last_loop));
},
- closed_extrude: function(shape, path, shapenormals, pathnormals) {
- var guts_result = nt3d._extrude_guts(shape, path, shapenormals, pathnormals);
+ closed_extrude: function(path, shape, shapenormals, pathnormals) {
+ var guts_result = nt3d._extrude_guts(path, shape, shapenormals, pathnormals);
// Stitch the ends together
return guts_result.points.concat(
nt3d.closed_quadstrip(nt3d.zip(guts_result.first_loop, guts_result.last_loop)));
}
return fixedpathnormals;
},
- _extrude_guts: function(shape, path, shapenormals, pathnormals) {
+ _extrude_guts: function(path, shape, shapenormals, pathnormals) {
var fixedpathnormals = this._fix_pathnormals(shapenormals, pathnormals);
var result = { points: [] };
var prev_loop;