poly-extrude 0.9.0 → 0.10.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 +1856 -2219
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +2 -4
- package/dist/poly-extrude.mjs +1856 -2219
- package/package.json +1 -1
- package/src/math/Quaternion.js +7 -7
- package/src/path.js +11 -14
- package/src/tube.js +3 -7
- package/src/util.js +13 -0
package/package.json
CHANGED
package/src/math/Quaternion.js
CHANGED
@@ -672,16 +672,16 @@ class Quaternion {
|
|
672
672
|
|
673
673
|
}
|
674
674
|
|
675
|
-
_onChangeCallback() { }
|
675
|
+
// _onChangeCallback() { }
|
676
676
|
|
677
|
-
* [Symbol.iterator]() {
|
677
|
+
// * [Symbol.iterator]() {
|
678
678
|
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
679
|
+
// yield this._x;
|
680
|
+
// yield this._y;
|
681
|
+
// yield this._z;
|
682
|
+
// yield this._w;
|
683
683
|
|
684
|
-
}
|
684
|
+
// }
|
685
685
|
|
686
686
|
}
|
687
687
|
|
package/src/path.js
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
import { Vector3 } from './math/Vector3';
|
2
2
|
import { PathPoint } from './path/PathPoint';
|
3
3
|
import { PathPointList } from './path/PathPointList';
|
4
|
-
import { merge } from './util';
|
4
|
+
import { line2Vectors, merge } from './util';
|
5
5
|
const UP = new Vector3(0, 0, 1);
|
6
6
|
|
7
|
+
const right = new Vector3();
|
8
|
+
const left = new Vector3();
|
9
|
+
|
10
|
+
// for sharp corners
|
11
|
+
const leftOffset = new Vector3();
|
12
|
+
const rightOffset = new Vector3();
|
13
|
+
const tempPoint1 = new Vector3();
|
14
|
+
const tempPoint2 = new Vector3();
|
15
|
+
|
7
16
|
export function expandPaths(lines, options) {
|
8
17
|
options = Object.assign({}, { lineWidth: 1, cornerRadius: 0, cornerSplit: 10 }, options);
|
9
18
|
const results = lines.map(line => {
|
10
|
-
const points = line
|
11
|
-
const [x, y, z] = p;
|
12
|
-
return new Vector3(x, y, z || 0);
|
13
|
-
});
|
19
|
+
const points = line2Vectors(line);
|
14
20
|
const pathPointList = new PathPointList();
|
15
21
|
pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP);
|
16
22
|
const result = generatePathVertexData(pathPointList, options);
|
@@ -53,15 +59,6 @@ function generatePathVertexData(pathPointList, options) {
|
|
53
59
|
const indices = [];
|
54
60
|
let verticesCount = 0;
|
55
61
|
|
56
|
-
const right = new Vector3();
|
57
|
-
const left = new Vector3();
|
58
|
-
|
59
|
-
// for sharp corners
|
60
|
-
const leftOffset = new Vector3();
|
61
|
-
const rightOffset = new Vector3();
|
62
|
-
const tempPoint1 = new Vector3();
|
63
|
-
const tempPoint2 = new Vector3();
|
64
|
-
|
65
62
|
let pIndex = position.length - 1;
|
66
63
|
let nIndex = normal.length - 1;
|
67
64
|
let uIndex = uv.length - 1;
|
package/src/tube.js
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
import { Vector3 } from './math/Vector3';
|
2
2
|
import { PathPoint } from './path/PathPoint';
|
3
3
|
import { PathPointList } from './path/PathPointList';
|
4
|
-
import { merge } from './util';
|
4
|
+
import { line2Vectors, merge } from './util';
|
5
5
|
const UP = new Vector3(0, 0, 1);
|
6
|
+
const normalDir = new Vector3();
|
6
7
|
|
7
8
|
export function expandTubes(lines, options) {
|
8
9
|
options = Object.assign({}, { radius: 1, cornerSplit: 0, radialSegments: 8, startRad: -Math.PI / 4 }, options);
|
9
10
|
const results = lines.map(line => {
|
10
|
-
const points = line
|
11
|
-
const [x, y, z] = p;
|
12
|
-
return new Vector3(x, y, z || 0);
|
13
|
-
});
|
11
|
+
const points = line2Vectors(line);
|
14
12
|
const pathPointList = new PathPointList();
|
15
13
|
pathPointList.set(points, options.cornerRadius, options.cornerSplit, UP);
|
16
14
|
const result = generateTubeVertexData(pathPointList, options);
|
@@ -51,8 +49,6 @@ function generateTubeVertexData(pathPointList, options) {
|
|
51
49
|
const indices = [];
|
52
50
|
let verticesCount = 0;
|
53
51
|
|
54
|
-
const normalDir = new Vector3();
|
55
|
-
|
56
52
|
let pIndex = -1;
|
57
53
|
let nIndex = -1;
|
58
54
|
let uIndex = -1;
|
package/src/util.js
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
import { Vector3 } from './math/Vector3';
|
2
|
+
|
1
3
|
/**
|
2
4
|
* https://github.com/Turfjs/turf/blob/master/packages/turf-boolean-clockwise/index.ts
|
3
5
|
* @param {*} ring
|
@@ -208,3 +210,14 @@ export function generateSideWallUV(uvs, vertices, indexA, indexB, indexC, indexD
|
|
208
210
|
}
|
209
211
|
|
210
212
|
}
|
213
|
+
|
214
|
+
export function line2Vectors(line) {
|
215
|
+
const points = [];
|
216
|
+
for (let i = 0, len = line.length; i < len; i++) {
|
217
|
+
const p = line[i];
|
218
|
+
const [x, y, z] = p;
|
219
|
+
const v = new Vector3(x, y, z || 0);
|
220
|
+
points[i] = v;
|
221
|
+
}
|
222
|
+
return points;
|
223
|
+
}
|