@@ -795,15 +795,14 @@ function extrusion(args) {
795
795
var slist = [ ]
796
796
for ( var i = 0 ; i < contour . length ; i ++ ) slist . push ( vec ( contour [ i ] [ 0 ] , contour [ i ] [ 1 ] , 0 ) )
797
797
var shape_closed = slist [ slist . length - 1 ] . equals ( slist [ 0 ] )
798
- if ( ! shape_closed ) new Error ( "An extrusion shape must be a closed curve." )
798
+ if ( ! shape_closed ) throw new Error ( "An extrusion shape must be a closed curve." )
799
799
shapeinfo = [ ]
800
800
var out = vec ( 0 , 0 , 1 )
801
801
var L = slist . length
802
802
var firstsharp = null
803
803
var totallength = 0
804
804
var vs = [ ] , lengths = [ ] , i , v
805
805
806
-
807
806
// Identify that corner of the shape that is the lowest point (minimum y)
808
807
var miny , minyi
809
808
for ( i = 0 ; i < L - 1 ; i ++ ) { // create list of vectors, calculate total length of the shape
@@ -980,10 +979,10 @@ function extrusion(args) {
980
979
function tessellate ( contours ) {
981
980
// Use the poly2tri.js library to divide a 2D shape with possible holes into triangles.
982
981
// Not called if the path is closed (so no end caps need to be displayed).
983
- var i , j
982
+ var i , j , endsave = null
984
983
var c = contours [ 0 ]
985
984
// poly2tri.js does not accept duplicate points:
986
- if ( c [ 0 ] [ 0 ] === c [ c . length - 1 ] [ 0 ] && c [ 0 ] [ 1 ] === c [ c . length - 1 ] [ 1 ] ) c . pop ( )
985
+ if ( c [ 0 ] [ 0 ] === c [ c . length - 1 ] [ 0 ] && c [ 0 ] [ 1 ] === c [ c . length - 1 ] [ 1 ] ) endsave = c . pop ( )
987
986
988
987
// Create poly2tri.js element for outer contour:
989
988
var pts = [ ]
@@ -998,6 +997,7 @@ function extrusion(args) {
998
997
for ( i = 0 ; i < contours [ j ] . length ; i ++ ) pts . push ( new Point ( c [ i ] [ 0 ] , c [ i ] [ 1 ] ) )
999
998
swctx . addHole ( pts )
1000
999
}
1000
+ if ( endsave !== null ) c . push ( endsave ) // restore last contour point
1001
1001
1002
1002
function texpos ( p ) { // evalulate texture coordinates, using bounding box info
1003
1003
var x = p . x , y = p . y
0 commit comments