docs/csg.js
function(offsetvector) {
            var newpolygons = [];

            var polygon1 = this;
            var direction = polygon1.plane.normal.dot(offsetvector);
            if (direction > 0) {
                polygon1 = polygon1.flipped();
            }
            newpolygons.push(polygon1);
            var polygon2 = polygon1.translate(offsetvector);
            var numvertices = this.vertices.length;
            for (var i = 0; i < numvertices; i++) {
                var sidefacepoints = [];
                var nexti = (i < (numvertices - 1)) ? i + 1 : 0;
                sidefacepoints.push(polygon1.vertices[i].pos);
                sidefacepoints.push(polygon2.vertices[i].pos);
                sidefacepoints.push(polygon2.vertices[nexti].pos);
                sidefacepoints.push(polygon1.vertices[nexti].pos);
                var sidefacepolygon = CSG.Polygon.createFromPoints(sidefacepoints, this.shared);
                newpolygons.push(sidefacepolygon);
            }
            polygon2 = polygon2.flipped();
            newpolygons.push(polygon2);
            return CSG.fromPolygons(newpolygons);
        }
function(offsetvector) {
            var newpolygons = [];

            var polygon1 = this;
            var direction = polygon1.plane.normal.dot(offsetvector);
            if (direction > 0) {
                polygon1 = polygon1.flipped();
            }
            newpolygons.push(polygon1);
            var polygon2 = polygon1.translate(offsetvector);
            var numvertices = this.vertices.length;
            for (var i = 0; i < numvertices; i++) {
                var sidefacepoints = [];
                var nexti = (i < (numvertices - 1)) ? i + 1 : 0;
                sidefacepoints.push(polygon1.vertices[i].pos);
                sidefacepoints.push(polygon2.vertices[i].pos);
                sidefacepoints.push(polygon2.vertices[nexti].pos);
                sidefacepoints.push(polygon1.vertices[nexti].pos);
                var sidefacepolygon = CSG.Polygon.createFromPoints(sidefacepoints, this.shared);
                newpolygons.push(sidefacepolygon);
            }
            polygon2 = polygon2.flipped();
            newpolygons.push(polygon2);
            return CSG.fromPolygons(newpolygons);
        }
function ( offsetvector ) { var newpolygons = [ ] ; var polygon1 = this ; var direction = polygon1 . plane . normal . dot ( offsetvector ) ; if ( direction > 0 ) { polygon1 = polygon1 . flipped ( ) ; } newpolygons . push ( polygon1 ) ; var polygon2 = polygon1 . translate ( offsetvector ) ; var numvertices = this . vertices . length ; for ( var i = 0 ; i < numvertices ; i ++ ) { var sidefacepoints = [ ] ; var nexti = ( i < ( numvertices - 1 ) ) ? i + 1 : 0 ; sidefacepoints . push ( polygon1 . vertices [ i ] . pos ) ; sidefacepoints . push ( polygon2 . vertices [ i ] . pos ) ; sidefacepoints . push ( polygon2 . vertices [ nexti ] . pos ) ; sidefacepoints . push ( polygon1 . vertices [ nexti ] . pos ) ; var sidefacepolygon = CSG . Polygon . createFromPoints ( sidefacepoints , this . shared ) ; newpolygons . push ( sidefacepolygon ) ; } polygon2 = polygon2 . flipped ( ) ; newpolygons . push ( polygon2 ) ; return CSG . fromPolygons ( newpolygons ) ; }
Extrude a polygon into the direction offsetvector Returns a CSG object
Extrude a polygon into the direction offsetvector Returns a CSG object