poly-extrude 0.7.0 → 0.9.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.
- package/dist/poly-extrude.js +333 -107
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +3 -3
- package/dist/poly-extrude.mjs +333 -107
- package/package.json +1 -1
- package/readme.md +22 -26
- package/src/cylinder.js +32 -10
- package/src/path.js +176 -72
- package/src/polygon.js +46 -26
- package/src/polyline.js +40 -16
- package/src/tube.js +14 -14
- package/src/util.js +27 -9
package/dist/poly-extrude.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* poly-extrude v0.
|
2
|
+
* poly-extrude v0.9.0
|
3
3
|
*/
|
4
4
|
(function (global, factory) {
|
5
5
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
@@ -868,17 +868,32 @@
|
|
868
868
|
var d_x = vertices[idx4];
|
869
869
|
var d_y = vertices[idx4 + 1];
|
870
870
|
var d_z = vertices[idx4 + 2];
|
871
|
+
var uIndex = uvs.length - 1;
|
871
872
|
|
872
873
|
if (Math.abs(a_y - b_y) < Math.abs(a_x - b_x)) {
|
873
|
-
uvs
|
874
|
-
uvs
|
875
|
-
uvs
|
876
|
-
uvs
|
874
|
+
uvs[++uIndex] = a_x;
|
875
|
+
uvs[++uIndex] = 1 - a_z;
|
876
|
+
uvs[++uIndex] = b_x;
|
877
|
+
uvs[++uIndex] = 1 - b_z;
|
878
|
+
uvs[++uIndex] = c_x;
|
879
|
+
uvs[++uIndex] = 1 - c_z;
|
880
|
+
uvs[++uIndex] = d_x;
|
881
|
+
uvs[++uIndex] = 1 - d_z; // uvs.push(a_x, 1 - a_z);
|
882
|
+
// uvs.push(b_x, 1 - b_z);
|
883
|
+
// uvs.push(c_x, 1 - c_z);
|
884
|
+
// uvs.push(d_x, 1 - d_z);
|
877
885
|
} else {
|
878
|
-
uvs
|
879
|
-
uvs
|
880
|
-
uvs
|
881
|
-
uvs
|
886
|
+
uvs[++uIndex] = a_y;
|
887
|
+
uvs[++uIndex] = 1 - a_z;
|
888
|
+
uvs[++uIndex] = b_y;
|
889
|
+
uvs[++uIndex] = 1 - b_z;
|
890
|
+
uvs[++uIndex] = c_y;
|
891
|
+
uvs[++uIndex] = 1 - c_z;
|
892
|
+
uvs[++uIndex] = d_y;
|
893
|
+
uvs[++uIndex] = 1 - d_z; // uvs.push(a_y, 1 - a_z);
|
894
|
+
// uvs.push(b_y, 1 - b_z);
|
895
|
+
// uvs.push(c_y, 1 - c_z);
|
896
|
+
// uvs.push(d_y, 1 - d_z);
|
882
897
|
}
|
883
898
|
}
|
884
899
|
|
@@ -910,8 +925,8 @@
|
|
910
925
|
generateTopAndBottom$1(result, triangles);
|
911
926
|
generateSides$1(result, options);
|
912
927
|
result.position = new Float32Array(result.points);
|
913
|
-
result.indices = new Uint32Array(result.
|
914
|
-
result.uv = new Float32Array(result.
|
928
|
+
result.indices = new Uint32Array(result.indices);
|
929
|
+
result.uv = new Float32Array(result.uv);
|
915
930
|
result.normal = generateNormal(result.indices, result.position);
|
916
931
|
return result;
|
917
932
|
});
|
@@ -921,7 +936,7 @@
|
|
921
936
|
}
|
922
937
|
|
923
938
|
function generateTopAndBottom$1(result, triangles) {
|
924
|
-
var
|
939
|
+
var indices = [];
|
925
940
|
var count = result.count;
|
926
941
|
|
927
942
|
for (var i = 0, len = triangles.length; i < len; i += 3) {
|
@@ -929,28 +944,30 @@
|
|
929
944
|
var a = triangles[i],
|
930
945
|
b = triangles[i + 1],
|
931
946
|
c = triangles[i + 2];
|
932
|
-
|
933
|
-
|
934
|
-
|
947
|
+
indices[i] = a;
|
948
|
+
indices[i + 1] = b;
|
949
|
+
indices[i + 2] = c; // bottom
|
935
950
|
|
936
951
|
var idx = len + i;
|
937
952
|
var a1 = count + a,
|
938
953
|
b1 = count + b,
|
939
954
|
c1 = count + c;
|
940
|
-
|
941
|
-
|
942
|
-
|
955
|
+
indices[idx] = a1;
|
956
|
+
indices[idx + 1] = b1;
|
957
|
+
indices[idx + 2] = c1;
|
943
958
|
}
|
944
959
|
|
945
|
-
result.
|
960
|
+
result.indices = indices;
|
946
961
|
}
|
947
962
|
|
948
963
|
function generateSides$1(result, options) {
|
949
964
|
var points = result.points,
|
950
|
-
|
965
|
+
indices = result.indices,
|
951
966
|
polygon = result.polygon,
|
952
|
-
|
953
|
-
var
|
967
|
+
uv = result.uv;
|
968
|
+
var depth = options.depth;
|
969
|
+
var pIndex = points.length - 1;
|
970
|
+
var iIndex = indices.length - 1;
|
954
971
|
|
955
972
|
for (var i = 0, len = polygon.length; i < len; i++) {
|
956
973
|
var ring = polygon[i];
|
@@ -968,17 +985,37 @@
|
|
968
985
|
var idx = points.length / 3;
|
969
986
|
var x1 = v1[0],
|
970
987
|
y1 = v1[1],
|
988
|
+
z1 = v1[2] || 0,
|
971
989
|
x2 = v2[0],
|
972
|
-
y2 = v2[1]
|
973
|
-
|
990
|
+
y2 = v2[1],
|
991
|
+
z2 = v2[2] || 0;
|
992
|
+
points[++pIndex] = x1;
|
993
|
+
points[++pIndex] = y1;
|
994
|
+
points[++pIndex] = z1 + depth;
|
995
|
+
points[++pIndex] = x2;
|
996
|
+
points[++pIndex] = y2;
|
997
|
+
points[++pIndex] = z2 + depth;
|
998
|
+
points[++pIndex] = x1;
|
999
|
+
points[++pIndex] = y1;
|
1000
|
+
points[++pIndex] = z1;
|
1001
|
+
points[++pIndex] = x2;
|
1002
|
+
points[++pIndex] = y2;
|
1003
|
+
points[++pIndex] = z2; // points.push(x1, y1, z, x2, y2, z, x1, y1, 0, x2, y2, 0);
|
1004
|
+
|
974
1005
|
var a = idx + 2,
|
975
1006
|
b = idx + 3,
|
976
1007
|
c = idx,
|
977
1008
|
d = idx + 1; // points.push(p3, p4, p1, p2);
|
1009
|
+
// index.push(a, c, b, c, d, b);
|
978
1010
|
|
979
|
-
|
1011
|
+
indices[++iIndex] = a;
|
1012
|
+
indices[++iIndex] = c;
|
1013
|
+
indices[++iIndex] = b;
|
1014
|
+
indices[++iIndex] = c;
|
1015
|
+
indices[++iIndex] = d;
|
1016
|
+
indices[++iIndex] = b; // index.push(c, d, b);
|
980
1017
|
|
981
|
-
generateSideWallUV(
|
1018
|
+
generateSideWallUV(uv, points, a, b, c, d);
|
982
1019
|
j++;
|
983
1020
|
}
|
984
1021
|
}
|
@@ -1003,10 +1040,10 @@
|
|
1003
1040
|
var holes = [],
|
1004
1041
|
flatVertices = new Float32Array(count * 2),
|
1005
1042
|
points = [],
|
1006
|
-
|
1043
|
+
uv = [];
|
1007
1044
|
var pOffset = count * 3,
|
1008
1045
|
uOffset = count * 2;
|
1009
|
-
var
|
1046
|
+
var depth = options.depth;
|
1010
1047
|
var idx0 = 0,
|
1011
1048
|
idx1 = 0,
|
1012
1049
|
idx2 = 0;
|
@@ -1024,21 +1061,22 @@
|
|
1024
1061
|
while (j < len1) {
|
1025
1062
|
var c = ring[j];
|
1026
1063
|
var x = c[0],
|
1027
|
-
y = c[1]
|
1064
|
+
y = c[1],
|
1065
|
+
z = c[2] || 0;
|
1028
1066
|
flatVertices[idx0++] = x;
|
1029
1067
|
flatVertices[idx0++] = y; // top vertices
|
1030
1068
|
|
1031
1069
|
points[idx1] = x;
|
1032
1070
|
points[idx1 + 1] = y;
|
1033
|
-
points[idx1 + 2] = z; // bottom vertices
|
1071
|
+
points[idx1 + 2] = depth + z; // bottom vertices
|
1034
1072
|
|
1035
1073
|
points[pOffset + idx1] = x;
|
1036
1074
|
points[pOffset + idx1 + 1] = y;
|
1037
|
-
points[pOffset + idx1 + 2] =
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1075
|
+
points[pOffset + idx1 + 2] = z;
|
1076
|
+
uv[idx2] = x;
|
1077
|
+
uv[idx2 + 1] = y;
|
1078
|
+
uv[uOffset + idx2] = x;
|
1079
|
+
uv[uOffset + idx2 + 1] = y;
|
1042
1080
|
idx1 += 3;
|
1043
1081
|
idx2 += 2;
|
1044
1082
|
j++;
|
@@ -1050,7 +1088,7 @@
|
|
1050
1088
|
holes: holes,
|
1051
1089
|
points: points,
|
1052
1090
|
count: count,
|
1053
|
-
|
1091
|
+
uv: uv
|
1054
1092
|
};
|
1055
1093
|
}
|
1056
1094
|
|
@@ -1090,8 +1128,8 @@
|
|
1090
1128
|
generateTopAndBottom(result, options);
|
1091
1129
|
generateSides(result, options);
|
1092
1130
|
result.position = new Float32Array(result.points);
|
1093
|
-
result.indices = new Uint32Array(result.
|
1094
|
-
result.uv = new Float32Array(result.
|
1131
|
+
result.indices = new Uint32Array(result.indices);
|
1132
|
+
result.uv = new Float32Array(result.uv);
|
1095
1133
|
result.normal = generateNormal(result.indices, result.position);
|
1096
1134
|
return result;
|
1097
1135
|
});
|
@@ -1140,8 +1178,8 @@
|
|
1140
1178
|
generateTopAndBottom(result, options);
|
1141
1179
|
generateSides(result, options);
|
1142
1180
|
result.position = new Float32Array(result.points);
|
1143
|
-
result.indices = new Uint32Array(result.
|
1144
|
-
result.uv = new Float32Array(result.
|
1181
|
+
result.indices = new Uint32Array(result.indices);
|
1182
|
+
result.uv = new Float32Array(result.uv);
|
1145
1183
|
result.normal = generateNormal(result.indices, result.position);
|
1146
1184
|
return result;
|
1147
1185
|
});
|
@@ -1163,8 +1201,8 @@
|
|
1163
1201
|
}
|
1164
1202
|
|
1165
1203
|
var points = [],
|
1166
|
-
|
1167
|
-
|
1204
|
+
indices = [],
|
1205
|
+
uv = [];
|
1168
1206
|
var leftPoints = result.leftPoints,
|
1169
1207
|
rightPoints = result.rightPoints;
|
1170
1208
|
var i = 0,
|
@@ -1214,16 +1252,20 @@
|
|
1214
1252
|
|
1215
1253
|
i = 0;
|
1216
1254
|
len = points.length;
|
1255
|
+
var uIndex = uv.length - 1;
|
1217
1256
|
|
1218
1257
|
while (i < len) {
|
1219
1258
|
var x = points[i],
|
1220
1259
|
y = points[i + 1];
|
1221
|
-
|
1260
|
+
uv[++uIndex] = x;
|
1261
|
+
uv[++uIndex] = y; // uvs.push(x, y);
|
1262
|
+
|
1222
1263
|
i += 3;
|
1223
1264
|
}
|
1224
1265
|
|
1225
1266
|
i = 0;
|
1226
1267
|
len = leftPoints.length;
|
1268
|
+
var iIndex = indices.length - 1;
|
1227
1269
|
|
1228
1270
|
while (i < len - 1) {
|
1229
1271
|
// top
|
@@ -1232,8 +1274,14 @@
|
|
1232
1274
|
b1 = i + 1,
|
1233
1275
|
c1 = a1 + len,
|
1234
1276
|
d1 = b1 + len;
|
1235
|
-
|
1236
|
-
|
1277
|
+
indices[++iIndex] = a1;
|
1278
|
+
indices[++iIndex] = c1;
|
1279
|
+
indices[++iIndex] = b1;
|
1280
|
+
indices[++iIndex] = c1;
|
1281
|
+
indices[++iIndex] = d1;
|
1282
|
+
indices[++iIndex] = b1; // index.push(a1, c1, b1);
|
1283
|
+
// index.push(c1, d1, b1);
|
1284
|
+
// bottom
|
1237
1285
|
// left1 left2 right1,right2
|
1238
1286
|
|
1239
1287
|
var len2 = len * 2;
|
@@ -1241,14 +1289,20 @@
|
|
1241
1289
|
b2 = a2 + 1,
|
1242
1290
|
c2 = a2 + len,
|
1243
1291
|
d2 = b2 + len;
|
1244
|
-
|
1245
|
-
|
1292
|
+
indices[++iIndex] = a2;
|
1293
|
+
indices[++iIndex] = c2;
|
1294
|
+
indices[++iIndex] = b2;
|
1295
|
+
indices[++iIndex] = c2;
|
1296
|
+
indices[++iIndex] = d2;
|
1297
|
+
indices[++iIndex] = b2; // index.push(a2, c2, b2);
|
1298
|
+
// index.push(c2, d2, b2);
|
1299
|
+
|
1246
1300
|
i++;
|
1247
1301
|
}
|
1248
1302
|
|
1249
|
-
result.
|
1303
|
+
result.indices = indices;
|
1250
1304
|
result.points = points;
|
1251
|
-
result.
|
1305
|
+
result.uv = uv;
|
1252
1306
|
|
1253
1307
|
if (depths) {
|
1254
1308
|
len = leftPoints.length;
|
@@ -1264,18 +1318,20 @@
|
|
1264
1318
|
|
1265
1319
|
function generateSides(result, options) {
|
1266
1320
|
var points = result.points,
|
1267
|
-
|
1321
|
+
indices = result.indices,
|
1268
1322
|
leftPoints = result.leftPoints,
|
1269
1323
|
rightPoints = result.rightPoints,
|
1270
|
-
|
1324
|
+
uv = result.uv;
|
1271
1325
|
var z = options.depth;
|
1272
1326
|
var bottomStickGround = options.bottomStickGround;
|
1273
1327
|
var rings = [leftPoints, rightPoints];
|
1274
1328
|
var depthsEnable = result.depths;
|
1329
|
+
var pIndex = points.length - 1;
|
1330
|
+
var iIndex = indices.length - 1;
|
1275
1331
|
|
1276
1332
|
function addOneSideIndex(v1, v2) {
|
1277
|
-
var idx = points.length / 3;
|
1278
|
-
|
1333
|
+
var idx = points.length / 3; // let pIndex = points.length - 1;
|
1334
|
+
// top
|
1279
1335
|
|
1280
1336
|
points[++pIndex] = v1[0];
|
1281
1337
|
points[++pIndex] = v1[1];
|
@@ -1296,8 +1352,14 @@
|
|
1296
1352
|
b = idx + 3,
|
1297
1353
|
c = idx,
|
1298
1354
|
d = idx + 1;
|
1299
|
-
|
1300
|
-
|
1355
|
+
indices[++iIndex] = a;
|
1356
|
+
indices[++iIndex] = c;
|
1357
|
+
indices[++iIndex] = b;
|
1358
|
+
indices[++iIndex] = c;
|
1359
|
+
indices[++iIndex] = d;
|
1360
|
+
indices[++iIndex] = b; // index.push(a, c, b, c, d, b);
|
1361
|
+
|
1362
|
+
generateSideWallUV(uv, points, a, b, c, d);
|
1301
1363
|
}
|
1302
1364
|
|
1303
1365
|
for (var i = 0, _len = rings.length; i < _len; i++) {
|
@@ -1545,7 +1607,8 @@
|
|
1545
1607
|
var offset = circlePointsLen * 3,
|
1546
1608
|
uOffset = circlePointsLen * 2;
|
1547
1609
|
var indices = [],
|
1548
|
-
|
1610
|
+
uv = [];
|
1611
|
+
var iIndex = indices.length - 1;
|
1549
1612
|
|
1550
1613
|
for (var i = -1; i < radialSegments; i++) {
|
1551
1614
|
var rad = aRad * i;
|
@@ -1563,16 +1626,19 @@
|
|
1563
1626
|
v = 0;
|
1564
1627
|
u = 0.5 + x / radius / 2;
|
1565
1628
|
v = 0.5 + y / radius / 2;
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1629
|
+
uv[uIdx] = u;
|
1630
|
+
uv[uIdx + 1] = v;
|
1631
|
+
uv[uIdx + uOffset] = u;
|
1632
|
+
uv[uIdx + 1 + uOffset] = v;
|
1570
1633
|
idx += 3;
|
1571
1634
|
uIdx += 2;
|
1572
1635
|
|
1573
1636
|
if (i > 1) {
|
1574
1637
|
// bottom indices
|
1575
|
-
indices.push(0, i - 1, i);
|
1638
|
+
// indices.push(0, i - 1, i);
|
1639
|
+
indices[++iIndex] = 0;
|
1640
|
+
indices[++iIndex] = i - 1;
|
1641
|
+
indices[++iIndex] = i;
|
1576
1642
|
}
|
1577
1643
|
}
|
1578
1644
|
|
@@ -1586,15 +1652,19 @@
|
|
1586
1652
|
points[pointsLen - 1] = height;
|
1587
1653
|
var indicesLen = indices.length; // top indices
|
1588
1654
|
|
1655
|
+
iIndex = indices.length - 1;
|
1656
|
+
|
1589
1657
|
for (var _i = 0; _i < indicesLen; _i++) {
|
1590
1658
|
var index = indices[_i];
|
1591
|
-
indices.push(index + circlePointsLen);
|
1659
|
+
indices[++iIndex] = index + circlePointsLen; // indices.push(index + circlePointsLen);
|
1592
1660
|
}
|
1593
1661
|
|
1594
1662
|
var sidePoints = new Float32Array((circlePointsLen * 3 * 2 - 6) * 2);
|
1595
1663
|
var pIndex = -1;
|
1596
1664
|
idx = circlePointsLen * 2;
|
1597
1665
|
uIdx = 0;
|
1666
|
+
iIndex = indices.length - 1;
|
1667
|
+
var uvIndex = uv.length - 1;
|
1598
1668
|
|
1599
1669
|
for (var _i2 = 0, len = points.length / 2; _i2 < len - 3; _i2 += 3) {
|
1600
1670
|
var x1 = points[_i2],
|
@@ -1618,11 +1688,25 @@
|
|
1618
1688
|
c = idx,
|
1619
1689
|
d = idx + 1; // indices.push(a, c, b, c, d, b);
|
1620
1690
|
|
1621
|
-
indices
|
1691
|
+
indices[++iIndex] = c;
|
1692
|
+
indices[++iIndex] = a;
|
1693
|
+
indices[++iIndex] = d;
|
1694
|
+
indices[++iIndex] = a;
|
1695
|
+
indices[++iIndex] = b;
|
1696
|
+
indices[++iIndex] = d; // indices.push(c, a, d, a, b, d);
|
1697
|
+
|
1622
1698
|
idx += 4;
|
1623
1699
|
var u1 = uIdx / circlePointsLen,
|
1624
1700
|
u2 = (uIdx + 1) / circlePointsLen;
|
1625
|
-
|
1701
|
+
uv[++uvIndex] = u1;
|
1702
|
+
uv[++uvIndex] = height / radius / 2;
|
1703
|
+
uv[++uvIndex] = u2;
|
1704
|
+
uv[++uvIndex] = height / radius / 2;
|
1705
|
+
uv[++uvIndex] = u1;
|
1706
|
+
uv[++uvIndex] = 0;
|
1707
|
+
uv[++uvIndex] = u2;
|
1708
|
+
uv[++uvIndex] = 0; // uvs.push(u1, height / radius / 2, u2, height / radius / 2, u1, 0, u2, 0);
|
1709
|
+
|
1626
1710
|
uIdx++;
|
1627
1711
|
}
|
1628
1712
|
|
@@ -1635,7 +1719,7 @@
|
|
1635
1719
|
indices: new Uint32Array(indices),
|
1636
1720
|
position: position,
|
1637
1721
|
normal: normal,
|
1638
|
-
uv: new Float32Array(
|
1722
|
+
uv: new Float32Array(uv)
|
1639
1723
|
};
|
1640
1724
|
}
|
1641
1725
|
|
@@ -4398,9 +4482,9 @@
|
|
4398
4482
|
pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP$1);
|
4399
4483
|
var result = generatePathVertexData(pathPointList, options);
|
4400
4484
|
result.line = line;
|
4401
|
-
result.position = new Float32Array(result.
|
4402
|
-
result.indices = new Uint32Array(result.
|
4403
|
-
result.uv = new Float32Array(result.
|
4485
|
+
result.position = new Float32Array(result.position);
|
4486
|
+
result.indices = new Uint32Array(result.indices);
|
4487
|
+
result.uv = new Float32Array(result.uv);
|
4404
4488
|
result.normal = new Float32Array(result.normal);
|
4405
4489
|
return result;
|
4406
4490
|
});
|
@@ -4438,6 +4522,10 @@
|
|
4438
4522
|
var rightOffset = new Vector3();
|
4439
4523
|
var tempPoint1 = new Vector3();
|
4440
4524
|
var tempPoint2 = new Vector3();
|
4525
|
+
var pIndex = position.length - 1;
|
4526
|
+
var nIndex = normal.length - 1;
|
4527
|
+
var uIndex = uv.length - 1;
|
4528
|
+
var iIndex = indices.length - 1;
|
4441
4529
|
|
4442
4530
|
function addVertices(pathPoint) {
|
4443
4531
|
var first = position.length === 0;
|
@@ -4488,31 +4576,135 @@
|
|
4488
4576
|
tempPoint2.copy(dir).setLength(_dist).add(tempPoint1);
|
4489
4577
|
|
4490
4578
|
if (sideOffset > 0) {
|
4491
|
-
position
|
4492
|
-
|
4493
|
-
|
4494
|
-
|
4495
|
-
|
4496
|
-
|
4497
|
-
|
4579
|
+
position[++pIndex] = tempPoint1.x;
|
4580
|
+
position[++pIndex] = tempPoint1.y;
|
4581
|
+
position[++pIndex] = tempPoint1.z;
|
4582
|
+
position[++pIndex] = right.x;
|
4583
|
+
position[++pIndex] = right.y;
|
4584
|
+
position[++pIndex] = right.z;
|
4585
|
+
position[++pIndex] = left.x;
|
4586
|
+
position[++pIndex] = left.y;
|
4587
|
+
position[++pIndex] = left.z;
|
4588
|
+
position[++pIndex] = right.x;
|
4589
|
+
position[++pIndex] = right.y;
|
4590
|
+
position[++pIndex] = right.z;
|
4591
|
+
position[++pIndex] = tempPoint2.x;
|
4592
|
+
position[++pIndex] = tempPoint2.y;
|
4593
|
+
position[++pIndex] = tempPoint2.z;
|
4594
|
+
position[++pIndex] = right.x;
|
4595
|
+
position[++pIndex] = right.y;
|
4596
|
+
position[++pIndex] = right.z; // position.push(
|
4597
|
+
// tempPoint1.x, tempPoint1.y, tempPoint1.z, // 6
|
4598
|
+
// right.x, right.y, right.z, // 5
|
4599
|
+
// left.x, left.y, left.z, // 4
|
4600
|
+
// right.x, right.y, right.z, // 3
|
4601
|
+
// tempPoint2.x, tempPoint2.y, tempPoint2.z, // 2
|
4602
|
+
// right.x, right.y, right.z // 1
|
4603
|
+
// );
|
4604
|
+
|
4498
4605
|
verticesCount += 6;
|
4499
|
-
indices
|
4606
|
+
indices[++iIndex] = verticesCount - 6;
|
4607
|
+
indices[++iIndex] = verticesCount - 8;
|
4608
|
+
indices[++iIndex] = verticesCount - 7;
|
4609
|
+
indices[++iIndex] = verticesCount - 6;
|
4610
|
+
indices[++iIndex] = verticesCount - 7;
|
4611
|
+
indices[++iIndex] = verticesCount - 5;
|
4612
|
+
indices[++iIndex] = verticesCount - 4;
|
4613
|
+
indices[++iIndex] = verticesCount - 6;
|
4614
|
+
indices[++iIndex] = verticesCount - 5;
|
4615
|
+
indices[++iIndex] = verticesCount - 2;
|
4616
|
+
indices[++iIndex] = verticesCount - 4;
|
4617
|
+
indices[++iIndex] = verticesCount - 1; // indices.push(
|
4618
|
+
// verticesCount - 6, verticesCount - 8, verticesCount - 7,
|
4619
|
+
// verticesCount - 6, verticesCount - 7, verticesCount - 5,
|
4620
|
+
// verticesCount - 4, verticesCount - 6, verticesCount - 5,
|
4621
|
+
// verticesCount - 2, verticesCount - 4, verticesCount - 1
|
4622
|
+
// );
|
4623
|
+
|
4500
4624
|
count += 12;
|
4501
4625
|
} else {
|
4502
|
-
position
|
4503
|
-
|
4504
|
-
|
4505
|
-
|
4506
|
-
|
4507
|
-
|
4508
|
-
|
4626
|
+
position[++pIndex] = left.x;
|
4627
|
+
position[++pIndex] = left.y;
|
4628
|
+
position[++pIndex] = left.z;
|
4629
|
+
position[++pIndex] = tempPoint1.x;
|
4630
|
+
position[++pIndex] = tempPoint1.y;
|
4631
|
+
position[++pIndex] = tempPoint1.z;
|
4632
|
+
position[++pIndex] = left.x;
|
4633
|
+
position[++pIndex] = left.y;
|
4634
|
+
position[++pIndex] = left.z;
|
4635
|
+
position[++pIndex] = right.x;
|
4636
|
+
position[++pIndex] = right.y;
|
4637
|
+
position[++pIndex] = right.z;
|
4638
|
+
position[++pIndex] = left.x;
|
4639
|
+
position[++pIndex] = left.y;
|
4640
|
+
position[++pIndex] = left.z;
|
4641
|
+
position[++pIndex] = tempPoint2.x;
|
4642
|
+
position[++pIndex] = tempPoint2.y;
|
4643
|
+
position[++pIndex] = tempPoint2.z; // position.push(
|
4644
|
+
// left.x, left.y, left.z, // 6
|
4645
|
+
// tempPoint1.x, tempPoint1.y, tempPoint1.z, // 5
|
4646
|
+
// left.x, left.y, left.z, // 4
|
4647
|
+
// right.x, right.y, right.z, // 3
|
4648
|
+
// left.x, left.y, left.z, // 2
|
4649
|
+
// tempPoint2.x, tempPoint2.y, tempPoint2.z // 1
|
4650
|
+
// );
|
4651
|
+
|
4509
4652
|
verticesCount += 6;
|
4510
|
-
indices
|
4653
|
+
indices[++iIndex] = verticesCount - 6;
|
4654
|
+
indices[++iIndex] = verticesCount - 8;
|
4655
|
+
indices[++iIndex] = verticesCount - 7;
|
4656
|
+
indices[++iIndex] = verticesCount - 6;
|
4657
|
+
indices[++iIndex] = verticesCount - 7;
|
4658
|
+
indices[++iIndex] = verticesCount - 5;
|
4659
|
+
indices[++iIndex] = verticesCount - 6;
|
4660
|
+
indices[++iIndex] = verticesCount - 5;
|
4661
|
+
indices[++iIndex] = verticesCount - 3;
|
4662
|
+
indices[++iIndex] = verticesCount - 2;
|
4663
|
+
indices[++iIndex] = verticesCount - 3;
|
4664
|
+
indices[++iIndex] = verticesCount - 1; // indices.push(
|
4665
|
+
// verticesCount - 6, verticesCount - 8, verticesCount - 7,
|
4666
|
+
// verticesCount - 6, verticesCount - 7, verticesCount - 5,
|
4667
|
+
// verticesCount - 6, verticesCount - 5, verticesCount - 3,
|
4668
|
+
// verticesCount - 2, verticesCount - 3, verticesCount - 1
|
4669
|
+
// );
|
4670
|
+
|
4511
4671
|
count += 12;
|
4512
4672
|
}
|
4513
4673
|
|
4514
|
-
|
4515
|
-
|
4674
|
+
for (var i = 0; i < 6; i++) {
|
4675
|
+
normal[++nIndex] = up.x;
|
4676
|
+
normal[++nIndex] = up.y;
|
4677
|
+
normal[++nIndex] = up.z;
|
4678
|
+
} // normal.push(
|
4679
|
+
// up.x, up.y, up.z,
|
4680
|
+
// up.x, up.y, up.z,
|
4681
|
+
// up.x, up.y, up.z,
|
4682
|
+
// up.x, up.y, up.z,
|
4683
|
+
// up.x, up.y, up.z,
|
4684
|
+
// up.x, up.y, up.z
|
4685
|
+
// );
|
4686
|
+
|
4687
|
+
|
4688
|
+
uv[++uIndex] = uvDist - sharpUvOffset;
|
4689
|
+
uv[++uIndex] = 0;
|
4690
|
+
uv[++uIndex] = uvDist - sharpUvOffset;
|
4691
|
+
uv[++uIndex] = 1;
|
4692
|
+
uv[++uIndex] = uvDist;
|
4693
|
+
uv[++uIndex] = 0;
|
4694
|
+
uv[++uIndex] = uvDist;
|
4695
|
+
uv[++uIndex] = 1;
|
4696
|
+
uv[++uIndex] = uvDist + sharpUvOffset;
|
4697
|
+
uv[++uIndex] = 0;
|
4698
|
+
uv[++uIndex] = uvDist + sharpUvOffset;
|
4699
|
+
uv[++uIndex] = 1; // uv.push(
|
4700
|
+
// uvDist - sharpUvOffset, 0,
|
4701
|
+
// uvDist - sharpUvOffset, 1,
|
4702
|
+
// uvDist, 0,
|
4703
|
+
// uvDist, 1,
|
4704
|
+
// uvDist + sharpUvOffset, 0,
|
4705
|
+
// uvDist + sharpUvOffset, 1
|
4706
|
+
// );
|
4707
|
+
// if (generateUv2) {
|
4516
4708
|
// uv2.push(
|
4517
4709
|
// uvDist2 - sharpUvOffset2, 0,
|
4518
4710
|
// uvDist2 - sharpUvOffset2, 1,
|
@@ -4523,9 +4715,34 @@
|
|
4523
4715
|
// );
|
4524
4716
|
// }
|
4525
4717
|
} else {
|
4526
|
-
position
|
4527
|
-
|
4528
|
-
|
4718
|
+
position[++pIndex] = left.x;
|
4719
|
+
position[++pIndex] = left.y;
|
4720
|
+
position[++pIndex] = left.z;
|
4721
|
+
position[++pIndex] = right.x;
|
4722
|
+
position[++pIndex] = right.y;
|
4723
|
+
position[++pIndex] = right.z; // position.push(
|
4724
|
+
// left.x, left.y, left.z,
|
4725
|
+
// right.x, right.y, right.z
|
4726
|
+
// );
|
4727
|
+
|
4728
|
+
normal[++nIndex] = up.x;
|
4729
|
+
normal[++nIndex] = up.y;
|
4730
|
+
normal[++nIndex] = up.z;
|
4731
|
+
normal[++nIndex] = up.x;
|
4732
|
+
normal[++nIndex] = up.y;
|
4733
|
+
normal[++nIndex] = up.z; // normal.push(
|
4734
|
+
// up.x, up.y, up.z,
|
4735
|
+
// up.x, up.y, up.z
|
4736
|
+
// );
|
4737
|
+
|
4738
|
+
uv[++uIndex] = uvDist;
|
4739
|
+
uv[++uIndex] = 0;
|
4740
|
+
uv[++uIndex] = uvDist;
|
4741
|
+
uv[++uIndex] = 1; // uv.push(
|
4742
|
+
// uvDist, 0,
|
4743
|
+
// uvDist, 1
|
4744
|
+
// );
|
4745
|
+
// if (generateUv2) {
|
4529
4746
|
// uv2.push(
|
4530
4747
|
// uvDist2, 0,
|
4531
4748
|
// uvDist2, 1
|
@@ -4535,7 +4752,16 @@
|
|
4535
4752
|
verticesCount += 2;
|
4536
4753
|
|
4537
4754
|
if (!first) {
|
4538
|
-
indices
|
4755
|
+
indices[++iIndex] = verticesCount - 2;
|
4756
|
+
indices[++iIndex] = verticesCount - 4;
|
4757
|
+
indices[++iIndex] = verticesCount - 3;
|
4758
|
+
indices[++iIndex] = verticesCount - 2;
|
4759
|
+
indices[++iIndex] = verticesCount - 3;
|
4760
|
+
indices[++iIndex] = verticesCount - 1; // indices.push(
|
4761
|
+
// verticesCount - 2, verticesCount - 4, verticesCount - 3,
|
4762
|
+
// verticesCount - 2, verticesCount - 3, verticesCount - 1
|
4763
|
+
// );
|
4764
|
+
|
4539
4765
|
count += 6;
|
4540
4766
|
}
|
4541
4767
|
}
|
@@ -4564,10 +4790,10 @@
|
|
4564
4790
|
}
|
4565
4791
|
|
4566
4792
|
return {
|
4567
|
-
|
4793
|
+
position: position,
|
4568
4794
|
normal: normal,
|
4569
|
-
|
4570
|
-
|
4795
|
+
uv: uv,
|
4796
|
+
indices: indices,
|
4571
4797
|
count: count
|
4572
4798
|
};
|
4573
4799
|
}
|
@@ -4592,8 +4818,8 @@
|
|
4592
4818
|
var result = generateTubeVertexData(pathPointList, options);
|
4593
4819
|
result.line = line;
|
4594
4820
|
result.position = new Float32Array(result.points);
|
4595
|
-
result.indices = new Uint32Array(result.
|
4596
|
-
result.uv = new Float32Array(result.
|
4821
|
+
result.indices = new Uint32Array(result.indices);
|
4822
|
+
result.uv = new Float32Array(result.uv);
|
4597
4823
|
result.normal = new Float32Array(result.normal);
|
4598
4824
|
return result;
|
4599
4825
|
});
|
@@ -4620,9 +4846,9 @@
|
|
4620
4846
|
|
4621
4847
|
var points = [];
|
4622
4848
|
var normal = [];
|
4623
|
-
var
|
4849
|
+
var uv = []; // const uv2 = [];
|
4624
4850
|
|
4625
|
-
var
|
4851
|
+
var indices = [];
|
4626
4852
|
var verticesCount = 0;
|
4627
4853
|
var normalDir = new Vector3();
|
4628
4854
|
var pIndex = -1;
|
@@ -4649,8 +4875,8 @@
|
|
4649
4875
|
normal[++nIndex] = normalDir.x;
|
4650
4876
|
normal[++nIndex] = normalDir.y;
|
4651
4877
|
normal[++nIndex] = normalDir.z;
|
4652
|
-
|
4653
|
-
|
4878
|
+
uv[++uIndex] = uvDist;
|
4879
|
+
uv[++uIndex] = i / radialSegments; // uvs.push(uvDist, r / radialSegments);
|
4654
4880
|
// if (generateUv2) {
|
4655
4881
|
// uv2.push(uvDist2, r / radialSegments);
|
4656
4882
|
// }
|
@@ -4663,12 +4889,12 @@
|
|
4663
4889
|
var begin2 = verticesCount - (radialSegments + 1);
|
4664
4890
|
|
4665
4891
|
for (var _i = 0; _i < radialSegments; _i++) {
|
4666
|
-
|
4667
|
-
|
4668
|
-
|
4669
|
-
|
4670
|
-
|
4671
|
-
|
4892
|
+
indices[++iIndex] = begin2 + _i;
|
4893
|
+
indices[++iIndex] = begin1 + _i;
|
4894
|
+
indices[++iIndex] = begin1 + _i + 1;
|
4895
|
+
indices[++iIndex] = begin2 + _i;
|
4896
|
+
indices[++iIndex] = begin1 + _i + 1;
|
4897
|
+
indices[++iIndex] = begin2 + _i + 1; // index.push(
|
4672
4898
|
// begin2 + i,
|
4673
4899
|
// begin1 + i,
|
4674
4900
|
// begin1 + i + 1,
|
@@ -4703,9 +4929,9 @@
|
|
4703
4929
|
return {
|
4704
4930
|
points: points,
|
4705
4931
|
normal: normal,
|
4706
|
-
|
4932
|
+
uv: uv,
|
4707
4933
|
// uv2,
|
4708
|
-
|
4934
|
+
indices: indices,
|
4709
4935
|
count: count
|
4710
4936
|
};
|
4711
4937
|
}
|