poly-extrude 0.8.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 +309 -106
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +3 -3
- package/dist/poly-extrude.mjs +309 -106
- package/package.json +1 -1
- package/src/cylinder.js +32 -10
- package/src/path.js +176 -72
- package/src/polygon.js +25 -25
- package/src/polyline.js +40 -16
- package/src/tube.js +14 -14
- package/src/util.js +27 -9
package/dist/poly-extrude.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* poly-extrude v0.
|
2
|
+
* poly-extrude v0.9.0
|
3
3
|
*/
|
4
4
|
var earcut$2 = {exports: {}};
|
5
5
|
|
@@ -862,17 +862,32 @@ function generateSideWallUV(uvs, vertices, indexA, indexB, indexC, indexD) {
|
|
862
862
|
var d_x = vertices[idx4];
|
863
863
|
var d_y = vertices[idx4 + 1];
|
864
864
|
var d_z = vertices[idx4 + 2];
|
865
|
+
var uIndex = uvs.length - 1;
|
865
866
|
|
866
867
|
if (Math.abs(a_y - b_y) < Math.abs(a_x - b_x)) {
|
867
|
-
uvs
|
868
|
-
uvs
|
869
|
-
uvs
|
870
|
-
uvs
|
868
|
+
uvs[++uIndex] = a_x;
|
869
|
+
uvs[++uIndex] = 1 - a_z;
|
870
|
+
uvs[++uIndex] = b_x;
|
871
|
+
uvs[++uIndex] = 1 - b_z;
|
872
|
+
uvs[++uIndex] = c_x;
|
873
|
+
uvs[++uIndex] = 1 - c_z;
|
874
|
+
uvs[++uIndex] = d_x;
|
875
|
+
uvs[++uIndex] = 1 - d_z; // uvs.push(a_x, 1 - a_z);
|
876
|
+
// uvs.push(b_x, 1 - b_z);
|
877
|
+
// uvs.push(c_x, 1 - c_z);
|
878
|
+
// uvs.push(d_x, 1 - d_z);
|
871
879
|
} else {
|
872
|
-
uvs
|
873
|
-
uvs
|
874
|
-
uvs
|
875
|
-
uvs
|
880
|
+
uvs[++uIndex] = a_y;
|
881
|
+
uvs[++uIndex] = 1 - a_z;
|
882
|
+
uvs[++uIndex] = b_y;
|
883
|
+
uvs[++uIndex] = 1 - b_z;
|
884
|
+
uvs[++uIndex] = c_y;
|
885
|
+
uvs[++uIndex] = 1 - c_z;
|
886
|
+
uvs[++uIndex] = d_y;
|
887
|
+
uvs[++uIndex] = 1 - d_z; // uvs.push(a_y, 1 - a_z);
|
888
|
+
// uvs.push(b_y, 1 - b_z);
|
889
|
+
// uvs.push(c_y, 1 - c_z);
|
890
|
+
// uvs.push(d_y, 1 - d_z);
|
876
891
|
}
|
877
892
|
}
|
878
893
|
|
@@ -904,8 +919,8 @@ function extrudePolygons(polygons, options) {
|
|
904
919
|
generateTopAndBottom$1(result, triangles);
|
905
920
|
generateSides$1(result, options);
|
906
921
|
result.position = new Float32Array(result.points);
|
907
|
-
result.indices = new Uint32Array(result.
|
908
|
-
result.uv = new Float32Array(result.
|
922
|
+
result.indices = new Uint32Array(result.indices);
|
923
|
+
result.uv = new Float32Array(result.uv);
|
909
924
|
result.normal = generateNormal(result.indices, result.position);
|
910
925
|
return result;
|
911
926
|
});
|
@@ -915,7 +930,7 @@ function extrudePolygons(polygons, options) {
|
|
915
930
|
}
|
916
931
|
|
917
932
|
function generateTopAndBottom$1(result, triangles) {
|
918
|
-
var
|
933
|
+
var indices = [];
|
919
934
|
var count = result.count;
|
920
935
|
|
921
936
|
for (var i = 0, len = triangles.length; i < len; i += 3) {
|
@@ -923,30 +938,30 @@ function generateTopAndBottom$1(result, triangles) {
|
|
923
938
|
var a = triangles[i],
|
924
939
|
b = triangles[i + 1],
|
925
940
|
c = triangles[i + 2];
|
926
|
-
|
927
|
-
|
928
|
-
|
941
|
+
indices[i] = a;
|
942
|
+
indices[i + 1] = b;
|
943
|
+
indices[i + 2] = c; // bottom
|
929
944
|
|
930
945
|
var idx = len + i;
|
931
946
|
var a1 = count + a,
|
932
947
|
b1 = count + b,
|
933
948
|
c1 = count + c;
|
934
|
-
|
935
|
-
|
936
|
-
|
949
|
+
indices[idx] = a1;
|
950
|
+
indices[idx + 1] = b1;
|
951
|
+
indices[idx + 2] = c1;
|
937
952
|
}
|
938
953
|
|
939
|
-
result.
|
954
|
+
result.indices = indices;
|
940
955
|
}
|
941
956
|
|
942
957
|
function generateSides$1(result, options) {
|
943
958
|
var points = result.points,
|
944
|
-
|
959
|
+
indices = result.indices,
|
945
960
|
polygon = result.polygon,
|
946
|
-
|
961
|
+
uv = result.uv;
|
947
962
|
var depth = options.depth;
|
948
963
|
var pIndex = points.length - 1;
|
949
|
-
var iIndex =
|
964
|
+
var iIndex = indices.length - 1;
|
950
965
|
|
951
966
|
for (var i = 0, len = polygon.length; i < len; i++) {
|
952
967
|
var ring = polygon[i];
|
@@ -987,14 +1002,14 @@ function generateSides$1(result, options) {
|
|
987
1002
|
d = idx + 1; // points.push(p3, p4, p1, p2);
|
988
1003
|
// index.push(a, c, b, c, d, b);
|
989
1004
|
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
1005
|
+
indices[++iIndex] = a;
|
1006
|
+
indices[++iIndex] = c;
|
1007
|
+
indices[++iIndex] = b;
|
1008
|
+
indices[++iIndex] = c;
|
1009
|
+
indices[++iIndex] = d;
|
1010
|
+
indices[++iIndex] = b; // index.push(c, d, b);
|
996
1011
|
|
997
|
-
generateSideWallUV(
|
1012
|
+
generateSideWallUV(uv, points, a, b, c, d);
|
998
1013
|
j++;
|
999
1014
|
}
|
1000
1015
|
}
|
@@ -1019,7 +1034,7 @@ function flatVertices(polygon, options) {
|
|
1019
1034
|
var holes = [],
|
1020
1035
|
flatVertices = new Float32Array(count * 2),
|
1021
1036
|
points = [],
|
1022
|
-
|
1037
|
+
uv = [];
|
1023
1038
|
var pOffset = count * 3,
|
1024
1039
|
uOffset = count * 2;
|
1025
1040
|
var depth = options.depth;
|
@@ -1052,10 +1067,10 @@ function flatVertices(polygon, options) {
|
|
1052
1067
|
points[pOffset + idx1] = x;
|
1053
1068
|
points[pOffset + idx1 + 1] = y;
|
1054
1069
|
points[pOffset + idx1 + 2] = z;
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1070
|
+
uv[idx2] = x;
|
1071
|
+
uv[idx2 + 1] = y;
|
1072
|
+
uv[uOffset + idx2] = x;
|
1073
|
+
uv[uOffset + idx2 + 1] = y;
|
1059
1074
|
idx1 += 3;
|
1060
1075
|
idx2 += 2;
|
1061
1076
|
j++;
|
@@ -1067,7 +1082,7 @@ function flatVertices(polygon, options) {
|
|
1067
1082
|
holes: holes,
|
1068
1083
|
points: points,
|
1069
1084
|
count: count,
|
1070
|
-
|
1085
|
+
uv: uv
|
1071
1086
|
};
|
1072
1087
|
}
|
1073
1088
|
|
@@ -1107,8 +1122,8 @@ function extrudePolylines(lines, options) {
|
|
1107
1122
|
generateTopAndBottom(result, options);
|
1108
1123
|
generateSides(result, options);
|
1109
1124
|
result.position = new Float32Array(result.points);
|
1110
|
-
result.indices = new Uint32Array(result.
|
1111
|
-
result.uv = new Float32Array(result.
|
1125
|
+
result.indices = new Uint32Array(result.indices);
|
1126
|
+
result.uv = new Float32Array(result.uv);
|
1112
1127
|
result.normal = generateNormal(result.indices, result.position);
|
1113
1128
|
return result;
|
1114
1129
|
});
|
@@ -1157,8 +1172,8 @@ function extrudeSlopes(lines, options) {
|
|
1157
1172
|
generateTopAndBottom(result, options);
|
1158
1173
|
generateSides(result, options);
|
1159
1174
|
result.position = new Float32Array(result.points);
|
1160
|
-
result.indices = new Uint32Array(result.
|
1161
|
-
result.uv = new Float32Array(result.
|
1175
|
+
result.indices = new Uint32Array(result.indices);
|
1176
|
+
result.uv = new Float32Array(result.uv);
|
1162
1177
|
result.normal = generateNormal(result.indices, result.position);
|
1163
1178
|
return result;
|
1164
1179
|
});
|
@@ -1180,8 +1195,8 @@ function generateTopAndBottom(result, options) {
|
|
1180
1195
|
}
|
1181
1196
|
|
1182
1197
|
var points = [],
|
1183
|
-
|
1184
|
-
|
1198
|
+
indices = [],
|
1199
|
+
uv = [];
|
1185
1200
|
var leftPoints = result.leftPoints,
|
1186
1201
|
rightPoints = result.rightPoints;
|
1187
1202
|
var i = 0,
|
@@ -1231,16 +1246,20 @@ function generateTopAndBottom(result, options) {
|
|
1231
1246
|
|
1232
1247
|
i = 0;
|
1233
1248
|
len = points.length;
|
1249
|
+
var uIndex = uv.length - 1;
|
1234
1250
|
|
1235
1251
|
while (i < len) {
|
1236
1252
|
var x = points[i],
|
1237
1253
|
y = points[i + 1];
|
1238
|
-
|
1254
|
+
uv[++uIndex] = x;
|
1255
|
+
uv[++uIndex] = y; // uvs.push(x, y);
|
1256
|
+
|
1239
1257
|
i += 3;
|
1240
1258
|
}
|
1241
1259
|
|
1242
1260
|
i = 0;
|
1243
1261
|
len = leftPoints.length;
|
1262
|
+
var iIndex = indices.length - 1;
|
1244
1263
|
|
1245
1264
|
while (i < len - 1) {
|
1246
1265
|
// top
|
@@ -1249,8 +1268,14 @@ function generateTopAndBottom(result, options) {
|
|
1249
1268
|
b1 = i + 1,
|
1250
1269
|
c1 = a1 + len,
|
1251
1270
|
d1 = b1 + len;
|
1252
|
-
|
1253
|
-
|
1271
|
+
indices[++iIndex] = a1;
|
1272
|
+
indices[++iIndex] = c1;
|
1273
|
+
indices[++iIndex] = b1;
|
1274
|
+
indices[++iIndex] = c1;
|
1275
|
+
indices[++iIndex] = d1;
|
1276
|
+
indices[++iIndex] = b1; // index.push(a1, c1, b1);
|
1277
|
+
// index.push(c1, d1, b1);
|
1278
|
+
// bottom
|
1254
1279
|
// left1 left2 right1,right2
|
1255
1280
|
|
1256
1281
|
var len2 = len * 2;
|
@@ -1258,14 +1283,20 @@ function generateTopAndBottom(result, options) {
|
|
1258
1283
|
b2 = a2 + 1,
|
1259
1284
|
c2 = a2 + len,
|
1260
1285
|
d2 = b2 + len;
|
1261
|
-
|
1262
|
-
|
1286
|
+
indices[++iIndex] = a2;
|
1287
|
+
indices[++iIndex] = c2;
|
1288
|
+
indices[++iIndex] = b2;
|
1289
|
+
indices[++iIndex] = c2;
|
1290
|
+
indices[++iIndex] = d2;
|
1291
|
+
indices[++iIndex] = b2; // index.push(a2, c2, b2);
|
1292
|
+
// index.push(c2, d2, b2);
|
1293
|
+
|
1263
1294
|
i++;
|
1264
1295
|
}
|
1265
1296
|
|
1266
|
-
result.
|
1297
|
+
result.indices = indices;
|
1267
1298
|
result.points = points;
|
1268
|
-
result.
|
1299
|
+
result.uv = uv;
|
1269
1300
|
|
1270
1301
|
if (depths) {
|
1271
1302
|
len = leftPoints.length;
|
@@ -1281,18 +1312,20 @@ function generateTopAndBottom(result, options) {
|
|
1281
1312
|
|
1282
1313
|
function generateSides(result, options) {
|
1283
1314
|
var points = result.points,
|
1284
|
-
|
1315
|
+
indices = result.indices,
|
1285
1316
|
leftPoints = result.leftPoints,
|
1286
1317
|
rightPoints = result.rightPoints,
|
1287
|
-
|
1318
|
+
uv = result.uv;
|
1288
1319
|
var z = options.depth;
|
1289
1320
|
var bottomStickGround = options.bottomStickGround;
|
1290
1321
|
var rings = [leftPoints, rightPoints];
|
1291
1322
|
var depthsEnable = result.depths;
|
1323
|
+
var pIndex = points.length - 1;
|
1324
|
+
var iIndex = indices.length - 1;
|
1292
1325
|
|
1293
1326
|
function addOneSideIndex(v1, v2) {
|
1294
|
-
var idx = points.length / 3;
|
1295
|
-
|
1327
|
+
var idx = points.length / 3; // let pIndex = points.length - 1;
|
1328
|
+
// top
|
1296
1329
|
|
1297
1330
|
points[++pIndex] = v1[0];
|
1298
1331
|
points[++pIndex] = v1[1];
|
@@ -1313,8 +1346,14 @@ function generateSides(result, options) {
|
|
1313
1346
|
b = idx + 3,
|
1314
1347
|
c = idx,
|
1315
1348
|
d = idx + 1;
|
1316
|
-
|
1317
|
-
|
1349
|
+
indices[++iIndex] = a;
|
1350
|
+
indices[++iIndex] = c;
|
1351
|
+
indices[++iIndex] = b;
|
1352
|
+
indices[++iIndex] = c;
|
1353
|
+
indices[++iIndex] = d;
|
1354
|
+
indices[++iIndex] = b; // index.push(a, c, b, c, d, b);
|
1355
|
+
|
1356
|
+
generateSideWallUV(uv, points, a, b, c, d);
|
1318
1357
|
}
|
1319
1358
|
|
1320
1359
|
for (var i = 0, _len = rings.length; i < _len; i++) {
|
@@ -1562,7 +1601,8 @@ function cylinder(point, options) {
|
|
1562
1601
|
var offset = circlePointsLen * 3,
|
1563
1602
|
uOffset = circlePointsLen * 2;
|
1564
1603
|
var indices = [],
|
1565
|
-
|
1604
|
+
uv = [];
|
1605
|
+
var iIndex = indices.length - 1;
|
1566
1606
|
|
1567
1607
|
for (var i = -1; i < radialSegments; i++) {
|
1568
1608
|
var rad = aRad * i;
|
@@ -1580,16 +1620,19 @@ function cylinder(point, options) {
|
|
1580
1620
|
v = 0;
|
1581
1621
|
u = 0.5 + x / radius / 2;
|
1582
1622
|
v = 0.5 + y / radius / 2;
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
1623
|
+
uv[uIdx] = u;
|
1624
|
+
uv[uIdx + 1] = v;
|
1625
|
+
uv[uIdx + uOffset] = u;
|
1626
|
+
uv[uIdx + 1 + uOffset] = v;
|
1587
1627
|
idx += 3;
|
1588
1628
|
uIdx += 2;
|
1589
1629
|
|
1590
1630
|
if (i > 1) {
|
1591
1631
|
// bottom indices
|
1592
|
-
indices.push(0, i - 1, i);
|
1632
|
+
// indices.push(0, i - 1, i);
|
1633
|
+
indices[++iIndex] = 0;
|
1634
|
+
indices[++iIndex] = i - 1;
|
1635
|
+
indices[++iIndex] = i;
|
1593
1636
|
}
|
1594
1637
|
}
|
1595
1638
|
|
@@ -1603,15 +1646,19 @@ function cylinder(point, options) {
|
|
1603
1646
|
points[pointsLen - 1] = height;
|
1604
1647
|
var indicesLen = indices.length; // top indices
|
1605
1648
|
|
1649
|
+
iIndex = indices.length - 1;
|
1650
|
+
|
1606
1651
|
for (var _i = 0; _i < indicesLen; _i++) {
|
1607
1652
|
var index = indices[_i];
|
1608
|
-
indices.push(index + circlePointsLen);
|
1653
|
+
indices[++iIndex] = index + circlePointsLen; // indices.push(index + circlePointsLen);
|
1609
1654
|
}
|
1610
1655
|
|
1611
1656
|
var sidePoints = new Float32Array((circlePointsLen * 3 * 2 - 6) * 2);
|
1612
1657
|
var pIndex = -1;
|
1613
1658
|
idx = circlePointsLen * 2;
|
1614
1659
|
uIdx = 0;
|
1660
|
+
iIndex = indices.length - 1;
|
1661
|
+
var uvIndex = uv.length - 1;
|
1615
1662
|
|
1616
1663
|
for (var _i2 = 0, len = points.length / 2; _i2 < len - 3; _i2 += 3) {
|
1617
1664
|
var x1 = points[_i2],
|
@@ -1635,11 +1682,25 @@ function cylinder(point, options) {
|
|
1635
1682
|
c = idx,
|
1636
1683
|
d = idx + 1; // indices.push(a, c, b, c, d, b);
|
1637
1684
|
|
1638
|
-
indices
|
1685
|
+
indices[++iIndex] = c;
|
1686
|
+
indices[++iIndex] = a;
|
1687
|
+
indices[++iIndex] = d;
|
1688
|
+
indices[++iIndex] = a;
|
1689
|
+
indices[++iIndex] = b;
|
1690
|
+
indices[++iIndex] = d; // indices.push(c, a, d, a, b, d);
|
1691
|
+
|
1639
1692
|
idx += 4;
|
1640
1693
|
var u1 = uIdx / circlePointsLen,
|
1641
1694
|
u2 = (uIdx + 1) / circlePointsLen;
|
1642
|
-
|
1695
|
+
uv[++uvIndex] = u1;
|
1696
|
+
uv[++uvIndex] = height / radius / 2;
|
1697
|
+
uv[++uvIndex] = u2;
|
1698
|
+
uv[++uvIndex] = height / radius / 2;
|
1699
|
+
uv[++uvIndex] = u1;
|
1700
|
+
uv[++uvIndex] = 0;
|
1701
|
+
uv[++uvIndex] = u2;
|
1702
|
+
uv[++uvIndex] = 0; // uvs.push(u1, height / radius / 2, u2, height / radius / 2, u1, 0, u2, 0);
|
1703
|
+
|
1643
1704
|
uIdx++;
|
1644
1705
|
}
|
1645
1706
|
|
@@ -1652,7 +1713,7 @@ function cylinder(point, options) {
|
|
1652
1713
|
indices: new Uint32Array(indices),
|
1653
1714
|
position: position,
|
1654
1715
|
normal: normal,
|
1655
|
-
uv: new Float32Array(
|
1716
|
+
uv: new Float32Array(uv)
|
1656
1717
|
};
|
1657
1718
|
}
|
1658
1719
|
|
@@ -4415,9 +4476,9 @@ function expandPaths(lines, options) {
|
|
4415
4476
|
pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP$1);
|
4416
4477
|
var result = generatePathVertexData(pathPointList, options);
|
4417
4478
|
result.line = line;
|
4418
|
-
result.position = new Float32Array(result.
|
4419
|
-
result.indices = new Uint32Array(result.
|
4420
|
-
result.uv = new Float32Array(result.
|
4479
|
+
result.position = new Float32Array(result.position);
|
4480
|
+
result.indices = new Uint32Array(result.indices);
|
4481
|
+
result.uv = new Float32Array(result.uv);
|
4421
4482
|
result.normal = new Float32Array(result.normal);
|
4422
4483
|
return result;
|
4423
4484
|
});
|
@@ -4455,6 +4516,10 @@ function generatePathVertexData(pathPointList, options) {
|
|
4455
4516
|
var rightOffset = new Vector3();
|
4456
4517
|
var tempPoint1 = new Vector3();
|
4457
4518
|
var tempPoint2 = new Vector3();
|
4519
|
+
var pIndex = position.length - 1;
|
4520
|
+
var nIndex = normal.length - 1;
|
4521
|
+
var uIndex = uv.length - 1;
|
4522
|
+
var iIndex = indices.length - 1;
|
4458
4523
|
|
4459
4524
|
function addVertices(pathPoint) {
|
4460
4525
|
var first = position.length === 0;
|
@@ -4505,31 +4570,135 @@ function generatePathVertexData(pathPointList, options) {
|
|
4505
4570
|
tempPoint2.copy(dir).setLength(_dist).add(tempPoint1);
|
4506
4571
|
|
4507
4572
|
if (sideOffset > 0) {
|
4508
|
-
position
|
4509
|
-
|
4510
|
-
|
4511
|
-
|
4512
|
-
|
4513
|
-
|
4514
|
-
|
4573
|
+
position[++pIndex] = tempPoint1.x;
|
4574
|
+
position[++pIndex] = tempPoint1.y;
|
4575
|
+
position[++pIndex] = tempPoint1.z;
|
4576
|
+
position[++pIndex] = right.x;
|
4577
|
+
position[++pIndex] = right.y;
|
4578
|
+
position[++pIndex] = right.z;
|
4579
|
+
position[++pIndex] = left.x;
|
4580
|
+
position[++pIndex] = left.y;
|
4581
|
+
position[++pIndex] = left.z;
|
4582
|
+
position[++pIndex] = right.x;
|
4583
|
+
position[++pIndex] = right.y;
|
4584
|
+
position[++pIndex] = right.z;
|
4585
|
+
position[++pIndex] = tempPoint2.x;
|
4586
|
+
position[++pIndex] = tempPoint2.y;
|
4587
|
+
position[++pIndex] = tempPoint2.z;
|
4588
|
+
position[++pIndex] = right.x;
|
4589
|
+
position[++pIndex] = right.y;
|
4590
|
+
position[++pIndex] = right.z; // position.push(
|
4591
|
+
// tempPoint1.x, tempPoint1.y, tempPoint1.z, // 6
|
4592
|
+
// right.x, right.y, right.z, // 5
|
4593
|
+
// left.x, left.y, left.z, // 4
|
4594
|
+
// right.x, right.y, right.z, // 3
|
4595
|
+
// tempPoint2.x, tempPoint2.y, tempPoint2.z, // 2
|
4596
|
+
// right.x, right.y, right.z // 1
|
4597
|
+
// );
|
4598
|
+
|
4515
4599
|
verticesCount += 6;
|
4516
|
-
indices
|
4600
|
+
indices[++iIndex] = verticesCount - 6;
|
4601
|
+
indices[++iIndex] = verticesCount - 8;
|
4602
|
+
indices[++iIndex] = verticesCount - 7;
|
4603
|
+
indices[++iIndex] = verticesCount - 6;
|
4604
|
+
indices[++iIndex] = verticesCount - 7;
|
4605
|
+
indices[++iIndex] = verticesCount - 5;
|
4606
|
+
indices[++iIndex] = verticesCount - 4;
|
4607
|
+
indices[++iIndex] = verticesCount - 6;
|
4608
|
+
indices[++iIndex] = verticesCount - 5;
|
4609
|
+
indices[++iIndex] = verticesCount - 2;
|
4610
|
+
indices[++iIndex] = verticesCount - 4;
|
4611
|
+
indices[++iIndex] = verticesCount - 1; // indices.push(
|
4612
|
+
// verticesCount - 6, verticesCount - 8, verticesCount - 7,
|
4613
|
+
// verticesCount - 6, verticesCount - 7, verticesCount - 5,
|
4614
|
+
// verticesCount - 4, verticesCount - 6, verticesCount - 5,
|
4615
|
+
// verticesCount - 2, verticesCount - 4, verticesCount - 1
|
4616
|
+
// );
|
4617
|
+
|
4517
4618
|
count += 12;
|
4518
4619
|
} else {
|
4519
|
-
position
|
4520
|
-
|
4521
|
-
|
4522
|
-
|
4523
|
-
|
4524
|
-
|
4525
|
-
|
4620
|
+
position[++pIndex] = left.x;
|
4621
|
+
position[++pIndex] = left.y;
|
4622
|
+
position[++pIndex] = left.z;
|
4623
|
+
position[++pIndex] = tempPoint1.x;
|
4624
|
+
position[++pIndex] = tempPoint1.y;
|
4625
|
+
position[++pIndex] = tempPoint1.z;
|
4626
|
+
position[++pIndex] = left.x;
|
4627
|
+
position[++pIndex] = left.y;
|
4628
|
+
position[++pIndex] = left.z;
|
4629
|
+
position[++pIndex] = right.x;
|
4630
|
+
position[++pIndex] = right.y;
|
4631
|
+
position[++pIndex] = right.z;
|
4632
|
+
position[++pIndex] = left.x;
|
4633
|
+
position[++pIndex] = left.y;
|
4634
|
+
position[++pIndex] = left.z;
|
4635
|
+
position[++pIndex] = tempPoint2.x;
|
4636
|
+
position[++pIndex] = tempPoint2.y;
|
4637
|
+
position[++pIndex] = tempPoint2.z; // position.push(
|
4638
|
+
// left.x, left.y, left.z, // 6
|
4639
|
+
// tempPoint1.x, tempPoint1.y, tempPoint1.z, // 5
|
4640
|
+
// left.x, left.y, left.z, // 4
|
4641
|
+
// right.x, right.y, right.z, // 3
|
4642
|
+
// left.x, left.y, left.z, // 2
|
4643
|
+
// tempPoint2.x, tempPoint2.y, tempPoint2.z // 1
|
4644
|
+
// );
|
4645
|
+
|
4526
4646
|
verticesCount += 6;
|
4527
|
-
indices
|
4647
|
+
indices[++iIndex] = verticesCount - 6;
|
4648
|
+
indices[++iIndex] = verticesCount - 8;
|
4649
|
+
indices[++iIndex] = verticesCount - 7;
|
4650
|
+
indices[++iIndex] = verticesCount - 6;
|
4651
|
+
indices[++iIndex] = verticesCount - 7;
|
4652
|
+
indices[++iIndex] = verticesCount - 5;
|
4653
|
+
indices[++iIndex] = verticesCount - 6;
|
4654
|
+
indices[++iIndex] = verticesCount - 5;
|
4655
|
+
indices[++iIndex] = verticesCount - 3;
|
4656
|
+
indices[++iIndex] = verticesCount - 2;
|
4657
|
+
indices[++iIndex] = verticesCount - 3;
|
4658
|
+
indices[++iIndex] = verticesCount - 1; // indices.push(
|
4659
|
+
// verticesCount - 6, verticesCount - 8, verticesCount - 7,
|
4660
|
+
// verticesCount - 6, verticesCount - 7, verticesCount - 5,
|
4661
|
+
// verticesCount - 6, verticesCount - 5, verticesCount - 3,
|
4662
|
+
// verticesCount - 2, verticesCount - 3, verticesCount - 1
|
4663
|
+
// );
|
4664
|
+
|
4528
4665
|
count += 12;
|
4529
4666
|
}
|
4530
4667
|
|
4531
|
-
|
4532
|
-
|
4668
|
+
for (var i = 0; i < 6; i++) {
|
4669
|
+
normal[++nIndex] = up.x;
|
4670
|
+
normal[++nIndex] = up.y;
|
4671
|
+
normal[++nIndex] = up.z;
|
4672
|
+
} // normal.push(
|
4673
|
+
// up.x, up.y, up.z,
|
4674
|
+
// up.x, up.y, up.z,
|
4675
|
+
// up.x, up.y, up.z,
|
4676
|
+
// up.x, up.y, up.z,
|
4677
|
+
// up.x, up.y, up.z,
|
4678
|
+
// up.x, up.y, up.z
|
4679
|
+
// );
|
4680
|
+
|
4681
|
+
|
4682
|
+
uv[++uIndex] = uvDist - sharpUvOffset;
|
4683
|
+
uv[++uIndex] = 0;
|
4684
|
+
uv[++uIndex] = uvDist - sharpUvOffset;
|
4685
|
+
uv[++uIndex] = 1;
|
4686
|
+
uv[++uIndex] = uvDist;
|
4687
|
+
uv[++uIndex] = 0;
|
4688
|
+
uv[++uIndex] = uvDist;
|
4689
|
+
uv[++uIndex] = 1;
|
4690
|
+
uv[++uIndex] = uvDist + sharpUvOffset;
|
4691
|
+
uv[++uIndex] = 0;
|
4692
|
+
uv[++uIndex] = uvDist + sharpUvOffset;
|
4693
|
+
uv[++uIndex] = 1; // uv.push(
|
4694
|
+
// uvDist - sharpUvOffset, 0,
|
4695
|
+
// uvDist - sharpUvOffset, 1,
|
4696
|
+
// uvDist, 0,
|
4697
|
+
// uvDist, 1,
|
4698
|
+
// uvDist + sharpUvOffset, 0,
|
4699
|
+
// uvDist + sharpUvOffset, 1
|
4700
|
+
// );
|
4701
|
+
// if (generateUv2) {
|
4533
4702
|
// uv2.push(
|
4534
4703
|
// uvDist2 - sharpUvOffset2, 0,
|
4535
4704
|
// uvDist2 - sharpUvOffset2, 1,
|
@@ -4540,9 +4709,34 @@ function generatePathVertexData(pathPointList, options) {
|
|
4540
4709
|
// );
|
4541
4710
|
// }
|
4542
4711
|
} else {
|
4543
|
-
position
|
4544
|
-
|
4545
|
-
|
4712
|
+
position[++pIndex] = left.x;
|
4713
|
+
position[++pIndex] = left.y;
|
4714
|
+
position[++pIndex] = left.z;
|
4715
|
+
position[++pIndex] = right.x;
|
4716
|
+
position[++pIndex] = right.y;
|
4717
|
+
position[++pIndex] = right.z; // position.push(
|
4718
|
+
// left.x, left.y, left.z,
|
4719
|
+
// right.x, right.y, right.z
|
4720
|
+
// );
|
4721
|
+
|
4722
|
+
normal[++nIndex] = up.x;
|
4723
|
+
normal[++nIndex] = up.y;
|
4724
|
+
normal[++nIndex] = up.z;
|
4725
|
+
normal[++nIndex] = up.x;
|
4726
|
+
normal[++nIndex] = up.y;
|
4727
|
+
normal[++nIndex] = up.z; // normal.push(
|
4728
|
+
// up.x, up.y, up.z,
|
4729
|
+
// up.x, up.y, up.z
|
4730
|
+
// );
|
4731
|
+
|
4732
|
+
uv[++uIndex] = uvDist;
|
4733
|
+
uv[++uIndex] = 0;
|
4734
|
+
uv[++uIndex] = uvDist;
|
4735
|
+
uv[++uIndex] = 1; // uv.push(
|
4736
|
+
// uvDist, 0,
|
4737
|
+
// uvDist, 1
|
4738
|
+
// );
|
4739
|
+
// if (generateUv2) {
|
4546
4740
|
// uv2.push(
|
4547
4741
|
// uvDist2, 0,
|
4548
4742
|
// uvDist2, 1
|
@@ -4552,7 +4746,16 @@ function generatePathVertexData(pathPointList, options) {
|
|
4552
4746
|
verticesCount += 2;
|
4553
4747
|
|
4554
4748
|
if (!first) {
|
4555
|
-
indices
|
4749
|
+
indices[++iIndex] = verticesCount - 2;
|
4750
|
+
indices[++iIndex] = verticesCount - 4;
|
4751
|
+
indices[++iIndex] = verticesCount - 3;
|
4752
|
+
indices[++iIndex] = verticesCount - 2;
|
4753
|
+
indices[++iIndex] = verticesCount - 3;
|
4754
|
+
indices[++iIndex] = verticesCount - 1; // indices.push(
|
4755
|
+
// verticesCount - 2, verticesCount - 4, verticesCount - 3,
|
4756
|
+
// verticesCount - 2, verticesCount - 3, verticesCount - 1
|
4757
|
+
// );
|
4758
|
+
|
4556
4759
|
count += 6;
|
4557
4760
|
}
|
4558
4761
|
}
|
@@ -4581,10 +4784,10 @@ function generatePathVertexData(pathPointList, options) {
|
|
4581
4784
|
}
|
4582
4785
|
|
4583
4786
|
return {
|
4584
|
-
|
4787
|
+
position: position,
|
4585
4788
|
normal: normal,
|
4586
|
-
|
4587
|
-
|
4789
|
+
uv: uv,
|
4790
|
+
indices: indices,
|
4588
4791
|
count: count
|
4589
4792
|
};
|
4590
4793
|
}
|
@@ -4609,8 +4812,8 @@ function expandTubes(lines, options) {
|
|
4609
4812
|
var result = generateTubeVertexData(pathPointList, options);
|
4610
4813
|
result.line = line;
|
4611
4814
|
result.position = new Float32Array(result.points);
|
4612
|
-
result.indices = new Uint32Array(result.
|
4613
|
-
result.uv = new Float32Array(result.
|
4815
|
+
result.indices = new Uint32Array(result.indices);
|
4816
|
+
result.uv = new Float32Array(result.uv);
|
4614
4817
|
result.normal = new Float32Array(result.normal);
|
4615
4818
|
return result;
|
4616
4819
|
});
|
@@ -4637,9 +4840,9 @@ function generateTubeVertexData(pathPointList, options) {
|
|
4637
4840
|
|
4638
4841
|
var points = [];
|
4639
4842
|
var normal = [];
|
4640
|
-
var
|
4843
|
+
var uv = []; // const uv2 = [];
|
4641
4844
|
|
4642
|
-
var
|
4845
|
+
var indices = [];
|
4643
4846
|
var verticesCount = 0;
|
4644
4847
|
var normalDir = new Vector3();
|
4645
4848
|
var pIndex = -1;
|
@@ -4666,8 +4869,8 @@ function generateTubeVertexData(pathPointList, options) {
|
|
4666
4869
|
normal[++nIndex] = normalDir.x;
|
4667
4870
|
normal[++nIndex] = normalDir.y;
|
4668
4871
|
normal[++nIndex] = normalDir.z;
|
4669
|
-
|
4670
|
-
|
4872
|
+
uv[++uIndex] = uvDist;
|
4873
|
+
uv[++uIndex] = i / radialSegments; // uvs.push(uvDist, r / radialSegments);
|
4671
4874
|
// if (generateUv2) {
|
4672
4875
|
// uv2.push(uvDist2, r / radialSegments);
|
4673
4876
|
// }
|
@@ -4680,12 +4883,12 @@ function generateTubeVertexData(pathPointList, options) {
|
|
4680
4883
|
var begin2 = verticesCount - (radialSegments + 1);
|
4681
4884
|
|
4682
4885
|
for (var _i = 0; _i < radialSegments; _i++) {
|
4683
|
-
|
4684
|
-
|
4685
|
-
|
4686
|
-
|
4687
|
-
|
4688
|
-
|
4886
|
+
indices[++iIndex] = begin2 + _i;
|
4887
|
+
indices[++iIndex] = begin1 + _i;
|
4888
|
+
indices[++iIndex] = begin1 + _i + 1;
|
4889
|
+
indices[++iIndex] = begin2 + _i;
|
4890
|
+
indices[++iIndex] = begin1 + _i + 1;
|
4891
|
+
indices[++iIndex] = begin2 + _i + 1; // index.push(
|
4689
4892
|
// begin2 + i,
|
4690
4893
|
// begin1 + i,
|
4691
4894
|
// begin1 + i + 1,
|
@@ -4720,9 +4923,9 @@ function generateTubeVertexData(pathPointList, options) {
|
|
4720
4923
|
return {
|
4721
4924
|
points: points,
|
4722
4925
|
normal: normal,
|
4723
|
-
|
4926
|
+
uv: uv,
|
4724
4927
|
// uv2,
|
4725
|
-
|
4928
|
+
indices: indices,
|
4726
4929
|
count: count
|
4727
4930
|
};
|
4728
4931
|
}
|