poly-extrude 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * poly-extrude v0.7.0
2
+ * poly-extrude v0.8.0
3
3
  */
4
4
  (function (global, factory) {
5
5
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -950,7 +950,9 @@
950
950
  index = result.index,
951
951
  polygon = result.polygon,
952
952
  uvs = result.uvs;
953
- var z = options.depth;
953
+ var depth = options.depth;
954
+ var pIndex = points.length - 1;
955
+ var iIndex = index.length - 1;
954
956
 
955
957
  for (var i = 0, len = polygon.length; i < len; i++) {
956
958
  var ring = polygon[i];
@@ -968,15 +970,35 @@
968
970
  var idx = points.length / 3;
969
971
  var x1 = v1[0],
970
972
  y1 = v1[1],
973
+ z1 = v1[2] || 0,
971
974
  x2 = v2[0],
972
- y2 = v2[1];
973
- points.push(x1, y1, z, x2, y2, z, x1, y1, 0, x2, y2, 0);
975
+ y2 = v2[1],
976
+ z2 = v2[2] || 0;
977
+ points[++pIndex] = x1;
978
+ points[++pIndex] = y1;
979
+ points[++pIndex] = z1 + depth;
980
+ points[++pIndex] = x2;
981
+ points[++pIndex] = y2;
982
+ points[++pIndex] = z2 + depth;
983
+ points[++pIndex] = x1;
984
+ points[++pIndex] = y1;
985
+ points[++pIndex] = z1;
986
+ points[++pIndex] = x2;
987
+ points[++pIndex] = y2;
988
+ points[++pIndex] = z2; // points.push(x1, y1, z, x2, y2, z, x1, y1, 0, x2, y2, 0);
989
+
974
990
  var a = idx + 2,
975
991
  b = idx + 3,
976
992
  c = idx,
977
993
  d = idx + 1; // points.push(p3, p4, p1, p2);
994
+ // index.push(a, c, b, c, d, b);
978
995
 
979
- index.push(a, c, b, c, d, b); // index.push(c, d, b);
996
+ index[++iIndex] = a;
997
+ index[++iIndex] = c;
998
+ index[++iIndex] = b;
999
+ index[++iIndex] = c;
1000
+ index[++iIndex] = d;
1001
+ index[++iIndex] = b; // index.push(c, d, b);
980
1002
 
981
1003
  generateSideWallUV(uvs, points, a, b, c, d);
982
1004
  j++;
@@ -1006,7 +1028,7 @@
1006
1028
  uvs = [];
1007
1029
  var pOffset = count * 3,
1008
1030
  uOffset = count * 2;
1009
- var z = options.depth;
1031
+ var depth = options.depth;
1010
1032
  var idx0 = 0,
1011
1033
  idx1 = 0,
1012
1034
  idx2 = 0;
@@ -1024,17 +1046,18 @@
1024
1046
  while (j < len1) {
1025
1047
  var c = ring[j];
1026
1048
  var x = c[0],
1027
- y = c[1];
1049
+ y = c[1],
1050
+ z = c[2] || 0;
1028
1051
  flatVertices[idx0++] = x;
1029
1052
  flatVertices[idx0++] = y; // top vertices
1030
1053
 
1031
1054
  points[idx1] = x;
1032
1055
  points[idx1 + 1] = y;
1033
- points[idx1 + 2] = z; // bottom vertices
1056
+ points[idx1 + 2] = depth + z; // bottom vertices
1034
1057
 
1035
1058
  points[pOffset + idx1] = x;
1036
1059
  points[pOffset + idx1 + 1] = y;
1037
- points[pOffset + idx1 + 2] = 0;
1060
+ points[pOffset + idx1 + 2] = z;
1038
1061
  uvs[idx2] = x;
1039
1062
  uvs[idx2 + 1] = y;
1040
1063
  uvs[uOffset + idx2] = x;