poly-extrude 0.5.0 → 0.6.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 +43 -5
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +2 -2
- package/dist/poly-extrude.mjs +43 -5
- package/package.json +1 -1
- package/readme.md +71 -20
- package/src/polyline.js +43 -3
package/dist/poly-extrude.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* poly-extrude v0.
|
2
|
+
* poly-extrude v0.6.0
|
3
3
|
*/
|
4
4
|
(function (global, factory) {
|
5
5
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
@@ -1071,11 +1071,19 @@
|
|
1071
1071
|
return x1 === x2 && y1 === y2;
|
1072
1072
|
}
|
1073
1073
|
|
1074
|
+
function checkOptions(options) {
|
1075
|
+
options.lineWidth = Math.max(0, options.lineWidth);
|
1076
|
+
options.depth = Math.max(0, options.depth);
|
1077
|
+
options.sideDepth = Math.max(0, options.sideDepth);
|
1078
|
+
}
|
1079
|
+
|
1074
1080
|
function extrudePolylines(lines, options) {
|
1075
1081
|
options = Object.assign({}, {
|
1076
1082
|
depth: 2,
|
1077
|
-
lineWidth: 1
|
1083
|
+
lineWidth: 1,
|
1084
|
+
bottomStickGround: false
|
1078
1085
|
}, options);
|
1086
|
+
checkOptions(options);
|
1079
1087
|
var results = lines.map(function (line) {
|
1080
1088
|
var result = expandLine(line, options);
|
1081
1089
|
result.line = line;
|
@@ -1096,8 +1104,10 @@
|
|
1096
1104
|
depth: 2,
|
1097
1105
|
lineWidth: 1,
|
1098
1106
|
side: 'left',
|
1099
|
-
sideDepth: 0
|
1107
|
+
sideDepth: 0,
|
1108
|
+
bottomStickGround: false
|
1100
1109
|
}, options);
|
1110
|
+
checkOptions(options);
|
1101
1111
|
var _options = options,
|
1102
1112
|
depth = _options.depth,
|
1103
1113
|
side = _options.side,
|
@@ -1141,6 +1151,7 @@
|
|
1141
1151
|
}
|
1142
1152
|
|
1143
1153
|
function generateTopAndBottom(result, options) {
|
1154
|
+
var bottomStickGround = options.bottomStickGround;
|
1144
1155
|
var z = options.depth;
|
1145
1156
|
var depths = result.depths;
|
1146
1157
|
var lz = z,
|
@@ -1182,12 +1193,22 @@
|
|
1182
1193
|
var idx2 = len * 2 * 3 + idx0;
|
1183
1194
|
points[idx2] = x1;
|
1184
1195
|
points[idx2 + 1] = y1;
|
1185
|
-
points[idx2 + 2] = z1;
|
1196
|
+
points[idx2 + 2] = z1;
|
1197
|
+
|
1198
|
+
if (bottomStickGround) {
|
1199
|
+
points[idx2 + 2] = 0;
|
1200
|
+
} // bottom right
|
1201
|
+
|
1186
1202
|
|
1187
1203
|
var idx3 = len * 2 * 3 + len * 3 + idx0;
|
1188
1204
|
points[idx3] = x2;
|
1189
1205
|
points[idx3 + 1] = y2;
|
1190
1206
|
points[idx3 + 2] = z2;
|
1207
|
+
|
1208
|
+
if (bottomStickGround) {
|
1209
|
+
points[idx3 + 2] = 0;
|
1210
|
+
}
|
1211
|
+
|
1191
1212
|
i++;
|
1192
1213
|
}
|
1193
1214
|
|
@@ -1248,12 +1269,29 @@
|
|
1248
1269
|
rightPoints = result.rightPoints,
|
1249
1270
|
uvs = result.uvs;
|
1250
1271
|
var z = options.depth;
|
1272
|
+
var bottomStickGround = options.bottomStickGround;
|
1251
1273
|
var rings = [leftPoints, rightPoints];
|
1252
1274
|
var depthsEnable = result.depths;
|
1253
1275
|
|
1254
1276
|
function addOneSideIndex(v1, v2) {
|
1255
1277
|
var idx = points.length / 3;
|
1256
|
-
|
1278
|
+
var pIndex = points.length - 1; // top
|
1279
|
+
|
1280
|
+
points[++pIndex] = v1[0];
|
1281
|
+
points[++pIndex] = v1[1];
|
1282
|
+
points[++pIndex] = (depthsEnable ? v1.depth : z) + v1[2];
|
1283
|
+
points[++pIndex] = v2[0];
|
1284
|
+
points[++pIndex] = v2[1];
|
1285
|
+
points[++pIndex] = (depthsEnable ? v2.depth : z) + v2[2]; // points.push(v1[0], v1[1], (depthsEnable ? v1.depth : z) + v1[2], v2[0], v2[1], (depthsEnable ? v2.depth : z) + v2[2]);
|
1286
|
+
// bottom
|
1287
|
+
|
1288
|
+
points[++pIndex] = v1[0];
|
1289
|
+
points[++pIndex] = v1[1];
|
1290
|
+
points[++pIndex] = bottomStickGround ? 0 : v1[2];
|
1291
|
+
points[++pIndex] = v2[0];
|
1292
|
+
points[++pIndex] = v2[1];
|
1293
|
+
points[++pIndex] = bottomStickGround ? 0 : v2[2]; // points.push(v1[0], v1[1], v1[2], v2[0], v2[1], v2[2]);
|
1294
|
+
|
1257
1295
|
var a = idx + 2,
|
1258
1296
|
b = idx + 3,
|
1259
1297
|
c = idx,
|