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.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,30 +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
|
-
|
967
|
+
uv = result.uv;
|
953
968
|
var depth = options.depth;
|
954
969
|
var pIndex = points.length - 1;
|
955
|
-
var iIndex =
|
970
|
+
var iIndex = indices.length - 1;
|
956
971
|
|
957
972
|
for (var i = 0, len = polygon.length; i < len; i++) {
|
958
973
|
var ring = polygon[i];
|
@@ -993,14 +1008,14 @@
|
|
993
1008
|
d = idx + 1; // points.push(p3, p4, p1, p2);
|
994
1009
|
// index.push(a, c, b, c, d, b);
|
995
1010
|
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
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);
|
1002
1017
|
|
1003
|
-
generateSideWallUV(
|
1018
|
+
generateSideWallUV(uv, points, a, b, c, d);
|
1004
1019
|
j++;
|
1005
1020
|
}
|
1006
1021
|
}
|
@@ -1025,7 +1040,7 @@
|
|
1025
1040
|
var holes = [],
|
1026
1041
|
flatVertices = new Float32Array(count * 2),
|
1027
1042
|
points = [],
|
1028
|
-
|
1043
|
+
uv = [];
|
1029
1044
|
var pOffset = count * 3,
|
1030
1045
|
uOffset = count * 2;
|
1031
1046
|
var depth = options.depth;
|
@@ -1058,10 +1073,10 @@
|
|
1058
1073
|
points[pOffset + idx1] = x;
|
1059
1074
|
points[pOffset + idx1 + 1] = y;
|
1060
1075
|
points[pOffset + idx1 + 2] = z;
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1076
|
+
uv[idx2] = x;
|
1077
|
+
uv[idx2 + 1] = y;
|
1078
|
+
uv[uOffset + idx2] = x;
|
1079
|
+
uv[uOffset + idx2 + 1] = y;
|
1065
1080
|
idx1 += 3;
|
1066
1081
|
idx2 += 2;
|
1067
1082
|
j++;
|
@@ -1073,7 +1088,7 @@
|
|
1073
1088
|
holes: holes,
|
1074
1089
|
points: points,
|
1075
1090
|
count: count,
|
1076
|
-
|
1091
|
+
uv: uv
|
1077
1092
|
};
|
1078
1093
|
}
|
1079
1094
|
|
@@ -1113,8 +1128,8 @@
|
|
1113
1128
|
generateTopAndBottom(result, options);
|
1114
1129
|
generateSides(result, options);
|
1115
1130
|
result.position = new Float32Array(result.points);
|
1116
|
-
result.indices = new Uint32Array(result.
|
1117
|
-
result.uv = new Float32Array(result.
|
1131
|
+
result.indices = new Uint32Array(result.indices);
|
1132
|
+
result.uv = new Float32Array(result.uv);
|
1118
1133
|
result.normal = generateNormal(result.indices, result.position);
|
1119
1134
|
return result;
|
1120
1135
|
});
|
@@ -1163,8 +1178,8 @@
|
|
1163
1178
|
generateTopAndBottom(result, options);
|
1164
1179
|
generateSides(result, options);
|
1165
1180
|
result.position = new Float32Array(result.points);
|
1166
|
-
result.indices = new Uint32Array(result.
|
1167
|
-
result.uv = new Float32Array(result.
|
1181
|
+
result.indices = new Uint32Array(result.indices);
|
1182
|
+
result.uv = new Float32Array(result.uv);
|
1168
1183
|
result.normal = generateNormal(result.indices, result.position);
|
1169
1184
|
return result;
|
1170
1185
|
});
|
@@ -1186,8 +1201,8 @@
|
|
1186
1201
|
}
|
1187
1202
|
|
1188
1203
|
var points = [],
|
1189
|
-
|
1190
|
-
|
1204
|
+
indices = [],
|
1205
|
+
uv = [];
|
1191
1206
|
var leftPoints = result.leftPoints,
|
1192
1207
|
rightPoints = result.rightPoints;
|
1193
1208
|
var i = 0,
|
@@ -1237,16 +1252,20 @@
|
|
1237
1252
|
|
1238
1253
|
i = 0;
|
1239
1254
|
len = points.length;
|
1255
|
+
var uIndex = uv.length - 1;
|
1240
1256
|
|
1241
1257
|
while (i < len) {
|
1242
1258
|
var x = points[i],
|
1243
1259
|
y = points[i + 1];
|
1244
|
-
|
1260
|
+
uv[++uIndex] = x;
|
1261
|
+
uv[++uIndex] = y; // uvs.push(x, y);
|
1262
|
+
|
1245
1263
|
i += 3;
|
1246
1264
|
}
|
1247
1265
|
|
1248
1266
|
i = 0;
|
1249
1267
|
len = leftPoints.length;
|
1268
|
+
var iIndex = indices.length - 1;
|
1250
1269
|
|
1251
1270
|
while (i < len - 1) {
|
1252
1271
|
// top
|
@@ -1255,8 +1274,14 @@
|
|
1255
1274
|
b1 = i + 1,
|
1256
1275
|
c1 = a1 + len,
|
1257
1276
|
d1 = b1 + len;
|
1258
|
-
|
1259
|
-
|
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
|
1260
1285
|
// left1 left2 right1,right2
|
1261
1286
|
|
1262
1287
|
var len2 = len * 2;
|
@@ -1264,14 +1289,20 @@
|
|
1264
1289
|
b2 = a2 + 1,
|
1265
1290
|
c2 = a2 + len,
|
1266
1291
|
d2 = b2 + len;
|
1267
|
-
|
1268
|
-
|
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
|
+
|
1269
1300
|
i++;
|
1270
1301
|
}
|
1271
1302
|
|
1272
|
-
result.
|
1303
|
+
result.indices = indices;
|
1273
1304
|
result.points = points;
|
1274
|
-
result.
|
1305
|
+
result.uv = uv;
|
1275
1306
|
|
1276
1307
|
if (depths) {
|
1277
1308
|
len = leftPoints.length;
|
@@ -1287,18 +1318,20 @@
|
|
1287
1318
|
|
1288
1319
|
function generateSides(result, options) {
|
1289
1320
|
var points = result.points,
|
1290
|
-
|
1321
|
+
indices = result.indices,
|
1291
1322
|
leftPoints = result.leftPoints,
|
1292
1323
|
rightPoints = result.rightPoints,
|
1293
|
-
|
1324
|
+
uv = result.uv;
|
1294
1325
|
var z = options.depth;
|
1295
1326
|
var bottomStickGround = options.bottomStickGround;
|
1296
1327
|
var rings = [leftPoints, rightPoints];
|
1297
1328
|
var depthsEnable = result.depths;
|
1329
|
+
var pIndex = points.length - 1;
|
1330
|
+
var iIndex = indices.length - 1;
|
1298
1331
|
|
1299
1332
|
function addOneSideIndex(v1, v2) {
|
1300
|
-
var idx = points.length / 3;
|
1301
|
-
|
1333
|
+
var idx = points.length / 3; // let pIndex = points.length - 1;
|
1334
|
+
// top
|
1302
1335
|
|
1303
1336
|
points[++pIndex] = v1[0];
|
1304
1337
|
points[++pIndex] = v1[1];
|
@@ -1319,8 +1352,14 @@
|
|
1319
1352
|
b = idx + 3,
|
1320
1353
|
c = idx,
|
1321
1354
|
d = idx + 1;
|
1322
|
-
|
1323
|
-
|
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);
|
1324
1363
|
}
|
1325
1364
|
|
1326
1365
|
for (var i = 0, _len = rings.length; i < _len; i++) {
|
@@ -1568,7 +1607,8 @@
|
|
1568
1607
|
var offset = circlePointsLen * 3,
|
1569
1608
|
uOffset = circlePointsLen * 2;
|
1570
1609
|
var indices = [],
|
1571
|
-
|
1610
|
+
uv = [];
|
1611
|
+
var iIndex = indices.length - 1;
|
1572
1612
|
|
1573
1613
|
for (var i = -1; i < radialSegments; i++) {
|
1574
1614
|
var rad = aRad * i;
|
@@ -1586,16 +1626,19 @@
|
|
1586
1626
|
v = 0;
|
1587
1627
|
u = 0.5 + x / radius / 2;
|
1588
1628
|
v = 0.5 + y / radius / 2;
|
1589
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
1629
|
+
uv[uIdx] = u;
|
1630
|
+
uv[uIdx + 1] = v;
|
1631
|
+
uv[uIdx + uOffset] = u;
|
1632
|
+
uv[uIdx + 1 + uOffset] = v;
|
1593
1633
|
idx += 3;
|
1594
1634
|
uIdx += 2;
|
1595
1635
|
|
1596
1636
|
if (i > 1) {
|
1597
1637
|
// bottom indices
|
1598
|
-
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;
|
1599
1642
|
}
|
1600
1643
|
}
|
1601
1644
|
|
@@ -1609,15 +1652,19 @@
|
|
1609
1652
|
points[pointsLen - 1] = height;
|
1610
1653
|
var indicesLen = indices.length; // top indices
|
1611
1654
|
|
1655
|
+
iIndex = indices.length - 1;
|
1656
|
+
|
1612
1657
|
for (var _i = 0; _i < indicesLen; _i++) {
|
1613
1658
|
var index = indices[_i];
|
1614
|
-
indices.push(index + circlePointsLen);
|
1659
|
+
indices[++iIndex] = index + circlePointsLen; // indices.push(index + circlePointsLen);
|
1615
1660
|
}
|
1616
1661
|
|
1617
1662
|
var sidePoints = new Float32Array((circlePointsLen * 3 * 2 - 6) * 2);
|
1618
1663
|
var pIndex = -1;
|
1619
1664
|
idx = circlePointsLen * 2;
|
1620
1665
|
uIdx = 0;
|
1666
|
+
iIndex = indices.length - 1;
|
1667
|
+
var uvIndex = uv.length - 1;
|
1621
1668
|
|
1622
1669
|
for (var _i2 = 0, len = points.length / 2; _i2 < len - 3; _i2 += 3) {
|
1623
1670
|
var x1 = points[_i2],
|
@@ -1641,11 +1688,25 @@
|
|
1641
1688
|
c = idx,
|
1642
1689
|
d = idx + 1; // indices.push(a, c, b, c, d, b);
|
1643
1690
|
|
1644
|
-
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
|
+
|
1645
1698
|
idx += 4;
|
1646
1699
|
var u1 = uIdx / circlePointsLen,
|
1647
1700
|
u2 = (uIdx + 1) / circlePointsLen;
|
1648
|
-
|
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
|
+
|
1649
1710
|
uIdx++;
|
1650
1711
|
}
|
1651
1712
|
|
@@ -1658,7 +1719,7 @@
|
|
1658
1719
|
indices: new Uint32Array(indices),
|
1659
1720
|
position: position,
|
1660
1721
|
normal: normal,
|
1661
|
-
uv: new Float32Array(
|
1722
|
+
uv: new Float32Array(uv)
|
1662
1723
|
};
|
1663
1724
|
}
|
1664
1725
|
|
@@ -4421,9 +4482,9 @@
|
|
4421
4482
|
pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP$1);
|
4422
4483
|
var result = generatePathVertexData(pathPointList, options);
|
4423
4484
|
result.line = line;
|
4424
|
-
result.position = new Float32Array(result.
|
4425
|
-
result.indices = new Uint32Array(result.
|
4426
|
-
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);
|
4427
4488
|
result.normal = new Float32Array(result.normal);
|
4428
4489
|
return result;
|
4429
4490
|
});
|
@@ -4461,6 +4522,10 @@
|
|
4461
4522
|
var rightOffset = new Vector3();
|
4462
4523
|
var tempPoint1 = new Vector3();
|
4463
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;
|
4464
4529
|
|
4465
4530
|
function addVertices(pathPoint) {
|
4466
4531
|
var first = position.length === 0;
|
@@ -4511,31 +4576,135 @@
|
|
4511
4576
|
tempPoint2.copy(dir).setLength(_dist).add(tempPoint1);
|
4512
4577
|
|
4513
4578
|
if (sideOffset > 0) {
|
4514
|
-
position
|
4515
|
-
|
4516
|
-
|
4517
|
-
|
4518
|
-
|
4519
|
-
|
4520
|
-
|
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
|
+
|
4521
4605
|
verticesCount += 6;
|
4522
|
-
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
|
+
|
4523
4624
|
count += 12;
|
4524
4625
|
} else {
|
4525
|
-
position
|
4526
|
-
|
4527
|
-
|
4528
|
-
|
4529
|
-
|
4530
|
-
|
4531
|
-
|
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
|
+
|
4532
4652
|
verticesCount += 6;
|
4533
|
-
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
|
+
|
4534
4671
|
count += 12;
|
4535
4672
|
}
|
4536
4673
|
|
4537
|
-
|
4538
|
-
|
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) {
|
4539
4708
|
// uv2.push(
|
4540
4709
|
// uvDist2 - sharpUvOffset2, 0,
|
4541
4710
|
// uvDist2 - sharpUvOffset2, 1,
|
@@ -4546,9 +4715,34 @@
|
|
4546
4715
|
// );
|
4547
4716
|
// }
|
4548
4717
|
} else {
|
4549
|
-
position
|
4550
|
-
|
4551
|
-
|
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) {
|
4552
4746
|
// uv2.push(
|
4553
4747
|
// uvDist2, 0,
|
4554
4748
|
// uvDist2, 1
|
@@ -4558,7 +4752,16 @@
|
|
4558
4752
|
verticesCount += 2;
|
4559
4753
|
|
4560
4754
|
if (!first) {
|
4561
|
-
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
|
+
|
4562
4765
|
count += 6;
|
4563
4766
|
}
|
4564
4767
|
}
|
@@ -4587,10 +4790,10 @@
|
|
4587
4790
|
}
|
4588
4791
|
|
4589
4792
|
return {
|
4590
|
-
|
4793
|
+
position: position,
|
4591
4794
|
normal: normal,
|
4592
|
-
|
4593
|
-
|
4795
|
+
uv: uv,
|
4796
|
+
indices: indices,
|
4594
4797
|
count: count
|
4595
4798
|
};
|
4596
4799
|
}
|
@@ -4615,8 +4818,8 @@
|
|
4615
4818
|
var result = generateTubeVertexData(pathPointList, options);
|
4616
4819
|
result.line = line;
|
4617
4820
|
result.position = new Float32Array(result.points);
|
4618
|
-
result.indices = new Uint32Array(result.
|
4619
|
-
result.uv = new Float32Array(result.
|
4821
|
+
result.indices = new Uint32Array(result.indices);
|
4822
|
+
result.uv = new Float32Array(result.uv);
|
4620
4823
|
result.normal = new Float32Array(result.normal);
|
4621
4824
|
return result;
|
4622
4825
|
});
|
@@ -4643,9 +4846,9 @@
|
|
4643
4846
|
|
4644
4847
|
var points = [];
|
4645
4848
|
var normal = [];
|
4646
|
-
var
|
4849
|
+
var uv = []; // const uv2 = [];
|
4647
4850
|
|
4648
|
-
var
|
4851
|
+
var indices = [];
|
4649
4852
|
var verticesCount = 0;
|
4650
4853
|
var normalDir = new Vector3();
|
4651
4854
|
var pIndex = -1;
|
@@ -4672,8 +4875,8 @@
|
|
4672
4875
|
normal[++nIndex] = normalDir.x;
|
4673
4876
|
normal[++nIndex] = normalDir.y;
|
4674
4877
|
normal[++nIndex] = normalDir.z;
|
4675
|
-
|
4676
|
-
|
4878
|
+
uv[++uIndex] = uvDist;
|
4879
|
+
uv[++uIndex] = i / radialSegments; // uvs.push(uvDist, r / radialSegments);
|
4677
4880
|
// if (generateUv2) {
|
4678
4881
|
// uv2.push(uvDist2, r / radialSegments);
|
4679
4882
|
// }
|
@@ -4686,12 +4889,12 @@
|
|
4686
4889
|
var begin2 = verticesCount - (radialSegments + 1);
|
4687
4890
|
|
4688
4891
|
for (var _i = 0; _i < radialSegments; _i++) {
|
4689
|
-
|
4690
|
-
|
4691
|
-
|
4692
|
-
|
4693
|
-
|
4694
|
-
|
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(
|
4695
4898
|
// begin2 + i,
|
4696
4899
|
// begin1 + i,
|
4697
4900
|
// begin1 + i + 1,
|
@@ -4726,9 +4929,9 @@
|
|
4726
4929
|
return {
|
4727
4930
|
points: points,
|
4728
4931
|
normal: normal,
|
4729
|
-
|
4932
|
+
uv: uv,
|
4730
4933
|
// uv2,
|
4731
|
-
|
4934
|
+
indices: indices,
|
4732
4935
|
count: count
|
4733
4936
|
};
|
4734
4937
|
}
|