]> git.scottworley.com Git - nt3d/commitdiff
Flip the order of shape,path in extrude args
authorScott Worley <ScottWorley@ScottWorley.com>
Fri, 21 Dec 2012 05:40:57 +0000 (21:40 -0800)
committerScott Worley <ScottWorley@ScottWorley.com>
Fri, 21 Dec 2012 06:11:33 +0000 (22:11 -0800)
box_by_extrude.html
nt3d.js
torus_by_extrude.html

index a95a7d300a7b90243c28954838cafb7a887491ad..be95de64ade3309ee6f56697df71f964afbfb73b 100644 (file)
@@ -8,8 +8,8 @@
         var x      = [size, 0,    0];
         var y      = [0,    size, 0];
         var xy     = [size, size, 0];
         var x      = [size, 0,    0];
         var y      = [0,    size, 0];
         var xy     = [size, size, 0];
-       return nt3d.extrude([origin, x, xy, y],
-                           [[0, 0, 0], [0, 0, 1]],
+       return nt3d.extrude([[0, 0, 0], [0, 0, 1]],
+                           [origin, x, xy, y],
                            [[0, 0, 1], [0, 0, 1]],
                            [[1, 0, 0], [1, 0, 0]]);
       }
                            [[0, 0, 1], [0, 0, 1]],
                            [[1, 0, 0], [1, 0, 0]]);
       }
diff --git a/nt3d.js b/nt3d.js
index 0443913962128ee0a511cb805d9ac404d24a509b..a4d3977f9815714252a98370d441b2ed2b467bcf 100644 (file)
--- a/nt3d.js
+++ b/nt3d.js
@@ -62,8 +62,9 @@ nt3d = {
                return this.closed_trianglefan([apex].concat(base)).concat(
                       this.trianglefan(base.reverse()));
        },
                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);
+       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(
                // Add the end-caps
                // XXX: This doesn't work if shape is not convex
                return guts_result.points.concat(
@@ -71,8 +72,8 @@ nt3d = {
                        nt3d.trianglefan(guts_result.last_loop));
 
        },
                        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)));
                // Stitch the ends together
                return guts_result.points.concat(
                        nt3d.closed_quadstrip(nt3d.zip(guts_result.first_loop, guts_result.last_loop)));
@@ -88,7 +89,7 @@ nt3d = {
                }
                return fixedpathnormals;
        },
                }
                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;
                var fixedpathnormals = this._fix_pathnormals(shapenormals, pathnormals);
                var result = { points: [] };
                var prev_loop;
index 323ad1472d006161824fc71a4949b227e8dccf8f..69bbdabc4a9150970d655cb41448dc1404a5686d 100644 (file)
@@ -4,15 +4,15 @@
     <script type="text/javascript" src="nt3d.js"></script>
     <script type="text/javascript">
       function torus_by_extrude(torus_radius, cross_section_radius, long_steps, short_steps) {
     <script type="text/javascript" src="nt3d.js"></script>
     <script type="text/javascript">
       function torus_by_extrude(torus_radius, cross_section_radius, long_steps, short_steps) {
-       var cross_section = nt3d.circle(cross_section_radius, short_steps);
        var path = nt3d.circle(torus_radius, long_steps);
        var path = nt3d.circle(torus_radius, long_steps);
+       var cross_section = nt3d.circle(cross_section_radius, short_steps);
        var cross_section_normals = nt3d.rotate_about_origin(path, [0,0,1], Math.PI/2);
        var path_normals = [];
        path_normals.length = long_steps;
        for (var i = 0; i < long_steps; i++) {
                path_normals[i] = [0, 0, 1];
        }
        var cross_section_normals = nt3d.rotate_about_origin(path, [0,0,1], Math.PI/2);
        var path_normals = [];
        path_normals.length = long_steps;
        for (var i = 0; i < long_steps; i++) {
                path_normals[i] = [0, 0, 1];
        }
-       return nt3d.closed_extrude(cross_section, path, cross_section_normals, path_normals);
+       return nt3d.closed_extrude(path, cross_section, cross_section_normals, path_normals);
       }
       var params = [["Torus radus", 100],
                     ["Cross section radius", 40],
       }
       var params = [["Torus radus", 100],
                     ["Cross section radius", 40],