@jscad/modeling 2.9.0 → 2.9.3
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/CHANGELOG.md +42 -0
- package/README.md +4 -4
- package/dist/jscad-modeling.min.js +437 -428
- package/package.json +3 -2
- package/src/colors/colorize.test.js +1 -1
- package/src/geometries/geom2/index.d.ts +1 -0
- package/src/geometries/geom2/index.js +2 -1
- package/src/geometries/geom2/toOutlines.js +66 -52
- package/src/geometries/geom2/validate.d.ts +3 -0
- package/src/geometries/geom2/validate.js +36 -0
- package/src/geometries/geom3/create.js +1 -1
- package/src/geometries/geom3/create.test.js +1 -1
- package/src/geometries/geom3/fromPoints.js +1 -1
- package/src/geometries/geom3/index.d.ts +1 -0
- package/src/geometries/geom3/index.js +2 -1
- package/src/geometries/geom3/isA.js +1 -1
- package/src/geometries/geom3/validate.d.ts +3 -0
- package/src/geometries/geom3/validate.js +62 -0
- package/src/geometries/path2/index.d.ts +1 -1
- package/src/geometries/path2/index.js +2 -2
- package/src/geometries/path2/validate.d.ts +3 -0
- package/src/geometries/path2/validate.js +41 -0
- package/src/geometries/poly2/arePointsInside.js +0 -35
- package/src/geometries/poly3/create.js +1 -1
- package/src/geometries/poly3/index.d.ts +1 -0
- package/src/geometries/poly3/index.js +2 -1
- package/src/geometries/poly3/measureArea.test.js +16 -16
- package/src/geometries/poly3/measureBoundingSphere.test.js +8 -8
- package/src/geometries/poly3/validate.d.ts +4 -0
- package/src/geometries/poly3/validate.js +64 -0
- package/src/maths/constants.d.ts +1 -0
- package/src/maths/constants.js +11 -0
- package/src/maths/utils/aboutEqualNormals.js +1 -5
- package/src/measurements/measureCenterOfMass.test.js +2 -2
- package/src/operations/booleans/intersect.test.js +8 -0
- package/src/operations/booleans/intersectGeom3.js +2 -1
- package/src/operations/booleans/scission.test.js +4 -4
- package/src/operations/booleans/subtract.test.js +8 -0
- package/src/operations/booleans/subtractGeom3.js +2 -1
- package/src/operations/booleans/to3DWalls.js +1 -1
- package/src/operations/booleans/trees/Node.js +10 -16
- package/src/operations/booleans/trees/PolygonTreeNode.js +13 -14
- package/src/operations/booleans/trees/Tree.js +1 -2
- package/src/operations/booleans/trees/splitPolygonByPlane.js +2 -3
- package/src/operations/booleans/union.test.js +27 -0
- package/src/operations/booleans/unionGeom3.js +2 -1
- package/src/operations/expansions/expand.test.js +30 -21
- package/src/operations/expansions/expandGeom3.test.js +14 -14
- package/src/operations/expansions/expandShell.js +5 -4
- package/src/operations/expansions/extrudePolygon.js +7 -7
- package/src/operations/expansions/offset.test.js +25 -0
- package/src/operations/extrusions/earcut/assignHoles.js +7 -3
- package/src/operations/extrusions/earcut/assignHoles.test.js +50 -4
- package/src/operations/extrusions/earcut/linkedList.js +1 -1
- package/src/operations/extrusions/extrudeFromSlices.test.js +16 -10
- package/src/operations/extrusions/extrudeLinear.test.js +15 -9
- package/src/operations/extrusions/extrudeRectangular.test.js +15 -8
- package/src/operations/extrusions/extrudeRotate.js +5 -1
- package/src/operations/extrusions/extrudeRotate.test.js +12 -0
- package/src/operations/extrusions/extrudeWalls.js +2 -2
- package/src/operations/extrusions/project.js +11 -14
- package/src/operations/extrusions/project.test.js +55 -55
- package/src/operations/hulls/hull.test.js +24 -1
- package/src/operations/hulls/hullChain.test.js +6 -4
- package/src/operations/hulls/hullGeom2.js +6 -18
- package/src/operations/hulls/hullGeom3.js +5 -18
- package/src/operations/hulls/hullPath2.js +4 -14
- package/src/operations/hulls/hullPath2.test.js +1 -1
- package/src/operations/hulls/hullPoints2.js +43 -92
- package/src/operations/hulls/toUniquePoints.js +34 -0
- package/src/operations/modifiers/generalize.js +2 -13
- package/src/operations/modifiers/generalize.test.js +5 -31
- package/src/operations/modifiers/insertTjunctions.js +1 -1
- package/src/operations/modifiers/insertTjunctions.test.js +21 -21
- package/src/operations/modifiers/mergePolygons.js +11 -14
- package/src/operations/{booleans → modifiers}/reTesselateCoplanarPolygons.js +1 -1
- package/src/operations/{booleans → modifiers}/reTesselateCoplanarPolygons.test.js +5 -5
- package/src/operations/{booleans → modifiers}/retessellate.js +2 -9
- package/src/operations/{booleans → modifiers}/retessellate.test.js +0 -0
- package/src/operations/modifiers/snapPolygons.test.js +12 -12
- package/src/operations/modifiers/triangulatePolygons.js +3 -3
- package/src/operations/transforms/align.test.js +12 -0
- package/src/operations/transforms/center.js +1 -1
- package/src/operations/transforms/center.test.js +12 -0
- package/src/operations/transforms/mirror.test.js +16 -0
- package/src/operations/transforms/rotate.test.js +10 -0
- package/src/operations/transforms/scale.test.js +15 -0
- package/src/operations/transforms/transform.test.js +5 -0
- package/src/operations/transforms/translate.test.js +16 -0
- package/src/primitives/arc.test.js +11 -0
- package/src/primitives/circle.test.js +15 -9
- package/src/primitives/cube.test.js +3 -0
- package/src/primitives/cuboid.js +1 -1
- package/src/primitives/cuboid.test.js +9 -24
- package/src/primitives/cylinder.test.js +7 -4
- package/src/primitives/cylinderElliptic.js +14 -7
- package/src/primitives/cylinderElliptic.test.js +72 -50
- package/src/primitives/ellipse.js +3 -1
- package/src/primitives/ellipse.test.js +14 -8
- package/src/primitives/ellipsoid.js +8 -6
- package/src/primitives/ellipsoid.test.js +84 -80
- package/src/primitives/geodesicSphere.test.js +3 -0
- package/src/primitives/line.test.js +1 -0
- package/src/primitives/polygon.test.js +15 -10
- package/src/primitives/polyhedron.js +1 -1
- package/src/primitives/polyhedron.test.js +14 -42
- package/src/primitives/rectangle.test.js +3 -0
- package/src/primitives/roundedCuboid.js +6 -6
- package/src/primitives/roundedCuboid.test.js +5 -0
- package/src/primitives/roundedCylinder.js +7 -5
- package/src/primitives/roundedCylinder.test.js +40 -36
- package/src/primitives/roundedRectangle.test.js +5 -0
- package/src/primitives/sphere.test.js +52 -73
- package/src/primitives/square.test.js +3 -0
- package/src/primitives/star.test.js +6 -0
- package/src/primitives/torus.test.js +8 -1
- package/src/primitives/triangle.js +1 -2
- package/src/primitives/triangle.test.js +7 -0
- package/src/utils/areAllShapesTheSameType.js +2 -2
- package/src/utils/areAllShapesTheSameType.test.js +17 -0
- package/src/utils/index.d.ts +1 -0
- package/src/utils/index.js +3 -1
- package/src/utils/trigonometry.d.ts +2 -0
- package/src/utils/trigonometry.js +34 -0
- package/src/utils/trigonometry.test.js +25 -0
- package/test/helpers/nearlyEqual.js +4 -1
- package/src/geometries/path2/eachPoint.d.ts +0 -9
- package/src/geometries/path2/eachPoint.js +0 -17
- package/src/geometries/path2/eachPoint.test.js +0 -11
- package/src/operations/modifiers/edges.js +0 -195
- package/src/operations/modifiers/repairTjunctions.js +0 -44
|
@@ -10,6 +10,7 @@ test('ellipsoid (defaults)', (t) => {
|
|
|
10
10
|
const obs = ellipsoid()
|
|
11
11
|
const pts = geom3.toPoints(obs)
|
|
12
12
|
|
|
13
|
+
t.notThrows(() => geom3.validate(obs))
|
|
13
14
|
t.is(pts.length, 512)
|
|
14
15
|
})
|
|
15
16
|
|
|
@@ -26,8 +27,8 @@ test('ellipsoid (options)', (t) => {
|
|
|
26
27
|
[1.2990381056766582, -1.25, -6.06217782649107], [1.5000000000000004, 0, -6.06217782649107]],
|
|
27
28
|
[[1.5000000000000004, 0, 6.06217782649107], [1.2990381056766582, -1.25, 6.06217782649107],
|
|
28
29
|
[2.25, -2.1650635094610964, 3.4999999999999996], [2.598076211353316, 0, 3.4999999999999996]],
|
|
29
|
-
[[1.5000000000000004, 0, -6.06217782649107], [1.2990381056766582, -1.25, -6.06217782649107], [
|
|
30
|
-
[[
|
|
30
|
+
[[1.5000000000000004, 0, -6.06217782649107], [1.2990381056766582, -1.25, -6.06217782649107], [0, 0, -7]],
|
|
31
|
+
[[0, 0, 7], [1.2990381056766582, -1.25, 6.06217782649107], [1.5000000000000004, 0, 6.06217782649107]],
|
|
31
32
|
[[2.598076211353316, -2.4999999999999996, 0], [1.5000000000000004, -4.330127018922193, 0],
|
|
32
33
|
[1.2990381056766584, -3.75, -3.4999999999999996], [2.25, -2.1650635094610964, -3.4999999999999996]],
|
|
33
34
|
[[2.25, -2.1650635094610964, 3.4999999999999996], [1.2990381056766584, -3.75, 3.4999999999999996],
|
|
@@ -36,28 +37,28 @@ test('ellipsoid (options)', (t) => {
|
|
|
36
37
|
[0.7500000000000004, -2.165063509461097, -6.06217782649107], [1.2990381056766582, -1.25, -6.06217782649107]],
|
|
37
38
|
[[1.2990381056766582, -1.25, 6.06217782649107], [0.7500000000000004, -2.165063509461097, 6.06217782649107],
|
|
38
39
|
[1.2990381056766584, -3.75, 3.4999999999999996], [2.25, -2.1650635094610964, 3.4999999999999996]],
|
|
39
|
-
[[1.2990381056766582, -1.25, -6.06217782649107], [0.7500000000000004, -2.165063509461097, -6.06217782649107], [
|
|
40
|
-
[[
|
|
41
|
-
[[1.5000000000000004, -4.330127018922193, 0], [
|
|
42
|
-
[
|
|
43
|
-
[[1.2990381056766584, -3.75, 3.4999999999999996], [
|
|
44
|
-
[
|
|
45
|
-
[[1.2990381056766584, -3.75, -3.4999999999999996], [
|
|
46
|
-
[
|
|
47
|
-
[[0.7500000000000004, -2.165063509461097, 6.06217782649107], [
|
|
48
|
-
[
|
|
49
|
-
[[0.7500000000000004, -2.165063509461097, -6.06217782649107], [
|
|
50
|
-
[[
|
|
51
|
-
[[
|
|
52
|
-
[-1.2990381056766576, -3.7500000000000004, -3.4999999999999996], [
|
|
53
|
-
[[
|
|
54
|
-
[-1.4999999999999993, -4.330127018922194, 0], [
|
|
55
|
-
[[
|
|
56
|
-
[-0.7499999999999998, -2.1650635094610973, -6.06217782649107], [
|
|
57
|
-
[[
|
|
58
|
-
[-1.2990381056766576, -3.7500000000000004, 3.4999999999999996], [
|
|
59
|
-
[[
|
|
60
|
-
[[
|
|
40
|
+
[[1.2990381056766582, -1.25, -6.06217782649107], [0.7500000000000004, -2.165063509461097, -6.06217782649107], [0, 0, -7]],
|
|
41
|
+
[[0, 0, 7], [0.7500000000000004, -2.165063509461097, 6.06217782649107], [1.2990381056766582, -1.25, 6.06217782649107]],
|
|
42
|
+
[[1.5000000000000004, -4.330127018922193, 0], [0, -5, 0],
|
|
43
|
+
[0, -4.330127018922194, -3.4999999999999996], [1.2990381056766584, -3.75, -3.4999999999999996]],
|
|
44
|
+
[[1.2990381056766584, -3.75, 3.4999999999999996], [0, -4.330127018922194, 3.4999999999999996],
|
|
45
|
+
[0, -5, 0], [1.5000000000000004, -4.330127018922193, 0]],
|
|
46
|
+
[[1.2990381056766584, -3.75, -3.4999999999999996], [0, -4.330127018922194, -3.4999999999999996],
|
|
47
|
+
[0, -2.5000000000000004, -6.06217782649107], [0.7500000000000004, -2.165063509461097, -6.06217782649107]],
|
|
48
|
+
[[0.7500000000000004, -2.165063509461097, 6.06217782649107], [0, -2.5000000000000004, 6.06217782649107],
|
|
49
|
+
[0, -4.330127018922194, 3.4999999999999996], [1.2990381056766584, -3.75, 3.4999999999999996]],
|
|
50
|
+
[[0.7500000000000004, -2.165063509461097, -6.06217782649107], [0, -2.5000000000000004, -6.06217782649107], [0, 0, -7]],
|
|
51
|
+
[[0, 0, 7], [0, -2.5000000000000004, 6.06217782649107], [0.7500000000000004, -2.165063509461097, 6.06217782649107]],
|
|
52
|
+
[[0, -5, 0], [-1.4999999999999993, -4.330127018922194, 0],
|
|
53
|
+
[-1.2990381056766576, -3.7500000000000004, -3.4999999999999996], [0, -4.330127018922194, -3.4999999999999996]],
|
|
54
|
+
[[0, -4.330127018922194, 3.4999999999999996], [-1.2990381056766576, -3.7500000000000004, 3.4999999999999996],
|
|
55
|
+
[-1.4999999999999993, -4.330127018922194, 0], [0, -5, 0]],
|
|
56
|
+
[[0, -4.330127018922194, -3.4999999999999996], [-1.2990381056766576, -3.7500000000000004, -3.4999999999999996],
|
|
57
|
+
[-0.7499999999999998, -2.1650635094610973, -6.06217782649107], [0, -2.5000000000000004, -6.06217782649107]],
|
|
58
|
+
[[0, -2.5000000000000004, 6.06217782649107], [-0.7499999999999998, -2.1650635094610973, 6.06217782649107],
|
|
59
|
+
[-1.2990381056766576, -3.7500000000000004, 3.4999999999999996], [0, -4.330127018922194, 3.4999999999999996]],
|
|
60
|
+
[[0, -2.5000000000000004, -6.06217782649107], [-0.7499999999999998, -2.1650635094610973, -6.06217782649107], [0, 0, -7]],
|
|
61
|
+
[[0, 0, 7], [-0.7499999999999998, -2.1650635094610973, 6.06217782649107], [0, -2.5000000000000004, 6.06217782649107]],
|
|
61
62
|
[[-1.4999999999999993, -4.330127018922194, 0], [-2.598076211353316, -2.4999999999999996, 0],
|
|
62
63
|
[-2.25, -2.1650635094610964, -3.4999999999999996], [-1.2990381056766576, -3.7500000000000004, -3.4999999999999996]],
|
|
63
64
|
[[-1.2990381056766576, -3.7500000000000004, 3.4999999999999996], [-2.25, -2.1650635094610964, 3.4999999999999996],
|
|
@@ -66,28 +67,28 @@ test('ellipsoid (options)', (t) => {
|
|
|
66
67
|
[-1.2990381056766582, -1.25, -6.06217782649107], [-0.7499999999999998, -2.1650635094610973, -6.06217782649107]],
|
|
67
68
|
[[-0.7499999999999998, -2.1650635094610973, 6.06217782649107], [-1.2990381056766582, -1.25, 6.06217782649107],
|
|
68
69
|
[-2.25, -2.1650635094610964, 3.4999999999999996], [-1.2990381056766576, -3.7500000000000004, 3.4999999999999996]],
|
|
69
|
-
[[-0.7499999999999998, -2.1650635094610973, -6.06217782649107], [-1.2990381056766582, -1.25, -6.06217782649107], [
|
|
70
|
-
[[
|
|
71
|
-
[[-2.598076211353316, -2.4999999999999996, 0], [-3,
|
|
72
|
-
[-2.598076211353316,
|
|
73
|
-
[[-2.25, -2.1650635094610964, 3.4999999999999996], [-2.598076211353316,
|
|
74
|
-
[-3,
|
|
75
|
-
[[-2.25, -2.1650635094610964, -3.4999999999999996], [-2.598076211353316,
|
|
76
|
-
[-1.5000000000000004,
|
|
77
|
-
[[-1.2990381056766582, -1.25, 6.06217782649107], [-1.5000000000000004,
|
|
78
|
-
[-2.598076211353316,
|
|
79
|
-
[[-1.2990381056766582, -1.25, -6.06217782649107], [-1.5000000000000004,
|
|
80
|
-
[[
|
|
81
|
-
[[-3,
|
|
82
|
-
[-2.2500000000000004, 2.1650635094610955, -3.4999999999999996], [-2.598076211353316,
|
|
83
|
-
[[-2.598076211353316,
|
|
84
|
-
[-2.5980762113533165, 2.4999999999999987, 0], [-3,
|
|
85
|
-
[[-2.598076211353316,
|
|
86
|
-
[-1.2990381056766584, 1.2499999999999996, -6.06217782649107], [-1.5000000000000004,
|
|
87
|
-
[[-1.5000000000000004,
|
|
88
|
-
[-2.2500000000000004, 2.1650635094610955, 3.4999999999999996], [-2.598076211353316,
|
|
89
|
-
[[-1.5000000000000004,
|
|
90
|
-
[[
|
|
70
|
+
[[-0.7499999999999998, -2.1650635094610973, -6.06217782649107], [-1.2990381056766582, -1.25, -6.06217782649107], [0, 0, -7]],
|
|
71
|
+
[[0, 0, 7], [-1.2990381056766582, -1.25, 6.06217782649107], [-0.7499999999999998, -2.1650635094610973, 6.06217782649107]],
|
|
72
|
+
[[-2.598076211353316, -2.4999999999999996, 0], [-3, 0, 0],
|
|
73
|
+
[-2.598076211353316, 0, -3.4999999999999996], [-2.25, -2.1650635094610964, -3.4999999999999996]],
|
|
74
|
+
[[-2.25, -2.1650635094610964, 3.4999999999999996], [-2.598076211353316, 0, 3.4999999999999996],
|
|
75
|
+
[-3, 0, 0], [-2.598076211353316, -2.4999999999999996, 0]],
|
|
76
|
+
[[-2.25, -2.1650635094610964, -3.4999999999999996], [-2.598076211353316, 0, -3.4999999999999996],
|
|
77
|
+
[-1.5000000000000004, 0, -6.06217782649107], [-1.2990381056766582, -1.25, -6.06217782649107]],
|
|
78
|
+
[[-1.2990381056766582, -1.25, 6.06217782649107], [-1.5000000000000004, 0, 6.06217782649107],
|
|
79
|
+
[-2.598076211353316, 0, 3.4999999999999996], [-2.25, -2.1650635094610964, 3.4999999999999996]],
|
|
80
|
+
[[-1.2990381056766582, -1.25, -6.06217782649107], [-1.5000000000000004, 0, -6.06217782649107], [0, 0, -7]],
|
|
81
|
+
[[0, 0, 7], [-1.5000000000000004, 0, 6.06217782649107], [-1.2990381056766582, -1.25, 6.06217782649107]],
|
|
82
|
+
[[-3, 0, 0], [-2.5980762113533165, 2.4999999999999987, 0],
|
|
83
|
+
[-2.2500000000000004, 2.1650635094610955, -3.4999999999999996], [-2.598076211353316, 0, -3.4999999999999996]],
|
|
84
|
+
[[-2.598076211353316, 0, 3.4999999999999996], [-2.2500000000000004, 2.1650635094610955, 3.4999999999999996],
|
|
85
|
+
[-2.5980762113533165, 2.4999999999999987, 0], [-3, 0, 0]],
|
|
86
|
+
[[-2.598076211353316, 0, -3.4999999999999996], [-2.2500000000000004, 2.1650635094610955, -3.4999999999999996],
|
|
87
|
+
[-1.2990381056766584, 1.2499999999999996, -6.06217782649107], [-1.5000000000000004, 0, -6.06217782649107]],
|
|
88
|
+
[[-1.5000000000000004, 0, 6.06217782649107], [-1.2990381056766584, 1.2499999999999996, 6.06217782649107],
|
|
89
|
+
[-2.2500000000000004, 2.1650635094610955, 3.4999999999999996], [-2.598076211353316, 0, 3.4999999999999996]],
|
|
90
|
+
[[-1.5000000000000004, 0, -6.06217782649107], [-1.2990381056766584, 1.2499999999999996, -6.06217782649107], [0, 0, -7]],
|
|
91
|
+
[[0, 0, 7], [-1.2990381056766584, 1.2499999999999996, 6.06217782649107], [-1.5000000000000004, 0, 6.06217782649107]],
|
|
91
92
|
[[-2.5980762113533165, 2.4999999999999987, 0], [-1.5000000000000013, 4.330127018922193, 0],
|
|
92
93
|
[-1.2990381056766591, 3.75, -3.4999999999999996], [-2.2500000000000004, 2.1650635094610955, -3.4999999999999996]],
|
|
93
94
|
[[-2.2500000000000004, 2.1650635094610955, 3.4999999999999996], [-1.2990381056766591, 3.75, 3.4999999999999996],
|
|
@@ -96,28 +97,28 @@ test('ellipsoid (options)', (t) => {
|
|
|
96
97
|
[-0.7500000000000009, 2.165063509461097, -6.06217782649107], [-1.2990381056766584, 1.2499999999999996, -6.06217782649107]],
|
|
97
98
|
[[-1.2990381056766584, 1.2499999999999996, 6.06217782649107], [-0.7500000000000009, 2.165063509461097, 6.06217782649107],
|
|
98
99
|
[-1.2990381056766591, 3.75, 3.4999999999999996], [-2.2500000000000004, 2.1650635094610955, 3.4999999999999996]],
|
|
99
|
-
[[-1.2990381056766584, 1.2499999999999996, -6.06217782649107], [-0.7500000000000009, 2.165063509461097, -6.06217782649107], [
|
|
100
|
-
[[
|
|
101
|
-
[[-1.5000000000000013, 4.330127018922193, 0], [
|
|
102
|
-
[
|
|
103
|
-
[[-1.2990381056766591, 3.75, 3.4999999999999996], [
|
|
104
|
-
[
|
|
105
|
-
[[-1.2990381056766591, 3.75, -3.4999999999999996], [
|
|
106
|
-
[
|
|
107
|
-
[[-0.7500000000000009, 2.165063509461097, 6.06217782649107], [
|
|
108
|
-
[
|
|
109
|
-
[[-0.7500000000000009, 2.165063509461097, -6.06217782649107], [
|
|
110
|
-
[[
|
|
111
|
-
[[
|
|
112
|
-
[1.2990381056766584, 3.75, -3.4999999999999996], [
|
|
113
|
-
[[
|
|
114
|
-
[1.5000000000000004, 4.330127018922193, 0], [
|
|
115
|
-
[[
|
|
116
|
-
[0.7500000000000004, 2.165063509461097, -6.06217782649107], [
|
|
117
|
-
[[
|
|
118
|
-
[1.2990381056766584, 3.75, 3.4999999999999996], [
|
|
119
|
-
[[
|
|
120
|
-
[[
|
|
100
|
+
[[-1.2990381056766584, 1.2499999999999996, -6.06217782649107], [-0.7500000000000009, 2.165063509461097, -6.06217782649107], [0, 0, -7]],
|
|
101
|
+
[[0, 0, 7], [-0.7500000000000009, 2.165063509461097, 6.06217782649107], [-1.2990381056766584, 1.2499999999999996, 6.06217782649107]],
|
|
102
|
+
[[-1.5000000000000013, 4.330127018922193, 0], [0, 5, 0],
|
|
103
|
+
[0, 4.330127018922194, -3.4999999999999996], [-1.2990381056766591, 3.75, -3.4999999999999996]],
|
|
104
|
+
[[-1.2990381056766591, 3.75, 3.4999999999999996], [0, 4.330127018922194, 3.4999999999999996],
|
|
105
|
+
[0, 5, 0], [-1.5000000000000013, 4.330127018922193, 0]],
|
|
106
|
+
[[-1.2990381056766591, 3.75, -3.4999999999999996], [0, 4.330127018922194, -3.4999999999999996],
|
|
107
|
+
[0, 2.5000000000000004, -6.06217782649107], [-0.7500000000000009, 2.165063509461097, -6.06217782649107]],
|
|
108
|
+
[[-0.7500000000000009, 2.165063509461097, 6.06217782649107], [0, 2.5000000000000004, 6.06217782649107],
|
|
109
|
+
[0, 4.330127018922194, 3.4999999999999996], [-1.2990381056766591, 3.75, 3.4999999999999996]],
|
|
110
|
+
[[-0.7500000000000009, 2.165063509461097, -6.06217782649107], [0, 2.5000000000000004, -6.06217782649107], [0, 0, -7]],
|
|
111
|
+
[[0, 0, 7], [0, 2.5000000000000004, 6.06217782649107], [-0.7500000000000009, 2.165063509461097, 6.06217782649107]],
|
|
112
|
+
[[0, 5, 0], [1.5000000000000004, 4.330127018922193, 0],
|
|
113
|
+
[1.2990381056766584, 3.75, -3.4999999999999996], [0, 4.330127018922194, -3.4999999999999996]],
|
|
114
|
+
[[0, 4.330127018922194, 3.4999999999999996], [1.2990381056766584, 3.75, 3.4999999999999996],
|
|
115
|
+
[1.5000000000000004, 4.330127018922193, 0], [0, 5, 0]],
|
|
116
|
+
[[0, 4.330127018922194, -3.4999999999999996], [1.2990381056766584, 3.75, -3.4999999999999996],
|
|
117
|
+
[0.7500000000000004, 2.165063509461097, -6.06217782649107], [0, 2.5000000000000004, -6.06217782649107]],
|
|
118
|
+
[[0, 2.5000000000000004, 6.06217782649107], [0.7500000000000004, 2.165063509461097, 6.06217782649107],
|
|
119
|
+
[1.2990381056766584, 3.75, 3.4999999999999996], [0, 4.330127018922194, 3.4999999999999996]],
|
|
120
|
+
[[0, 2.5000000000000004, -6.06217782649107], [0.7500000000000004, 2.165063509461097, -6.06217782649107], [0, 0, -7]],
|
|
121
|
+
[[0, 0, 7], [0.7500000000000004, 2.165063509461097, 6.06217782649107], [0, 2.5000000000000004, 6.06217782649107]],
|
|
121
122
|
[[1.5000000000000004, 4.330127018922193, 0], [2.598076211353315, 2.500000000000002, 0],
|
|
122
123
|
[2.2499999999999996, 2.1650635094610986, -3.4999999999999996], [1.2990381056766584, 3.75, -3.4999999999999996]],
|
|
123
124
|
[[1.2990381056766584, 3.75, 3.4999999999999996], [2.2499999999999996, 2.1650635094610986, 3.4999999999999996],
|
|
@@ -126,25 +127,27 @@ test('ellipsoid (options)', (t) => {
|
|
|
126
127
|
[1.2990381056766578, 1.2500000000000013, -6.06217782649107], [0.7500000000000004, 2.165063509461097, -6.06217782649107]],
|
|
127
128
|
[[0.7500000000000004, 2.165063509461097, 6.06217782649107], [1.2990381056766578, 1.2500000000000013, 6.06217782649107],
|
|
128
129
|
[2.2499999999999996, 2.1650635094610986, 3.4999999999999996], [1.2990381056766584, 3.75, 3.4999999999999996]],
|
|
129
|
-
[[0.7500000000000004, 2.165063509461097, -6.06217782649107], [1.2990381056766578, 1.2500000000000013, -6.06217782649107], [
|
|
130
|
-
[[
|
|
131
|
-
[[2.598076211353315, 2.500000000000002, 0], [3,
|
|
132
|
-
[2.598076211353316,
|
|
133
|
-
[[2.2499999999999996, 2.1650635094610986, 3.4999999999999996], [2.598076211353316,
|
|
134
|
-
[3,
|
|
135
|
-
[[2.2499999999999996, 2.1650635094610986, -3.4999999999999996], [2.598076211353316,
|
|
136
|
-
[1.5000000000000004,
|
|
137
|
-
[[1.2990381056766578, 1.2500000000000013, 6.06217782649107], [1.5000000000000004,
|
|
138
|
-
[2.598076211353316,
|
|
139
|
-
[[1.2990381056766578, 1.2500000000000013, -6.06217782649107], [1.5000000000000004,
|
|
140
|
-
[[
|
|
130
|
+
[[0.7500000000000004, 2.165063509461097, -6.06217782649107], [1.2990381056766578, 1.2500000000000013, -6.06217782649107], [0, 0, -7]],
|
|
131
|
+
[[0, 0, 7], [1.2990381056766578, 1.2500000000000013, 6.06217782649107], [0.7500000000000004, 2.165063509461097, 6.06217782649107]],
|
|
132
|
+
[[2.598076211353315, 2.500000000000002, 0], [3, 0, 0],
|
|
133
|
+
[2.598076211353316, 0, -3.4999999999999996], [2.2499999999999996, 2.1650635094610986, -3.4999999999999996]],
|
|
134
|
+
[[2.2499999999999996, 2.1650635094610986, 3.4999999999999996], [2.598076211353316, 0, 3.4999999999999996],
|
|
135
|
+
[3, 0, 0], [2.598076211353315, 2.500000000000002, 0]],
|
|
136
|
+
[[2.2499999999999996, 2.1650635094610986, -3.4999999999999996], [2.598076211353316, 0, -3.4999999999999996],
|
|
137
|
+
[1.5000000000000004, 0, -6.06217782649107], [1.2990381056766578, 1.2500000000000013, -6.06217782649107]],
|
|
138
|
+
[[1.2990381056766578, 1.2500000000000013, 6.06217782649107], [1.5000000000000004, 0, 6.06217782649107],
|
|
139
|
+
[2.598076211353316, 0, 3.4999999999999996], [2.2499999999999996, 2.1650635094610986, 3.4999999999999996]],
|
|
140
|
+
[[1.2990381056766578, 1.2500000000000013, -6.06217782649107], [1.5000000000000004, 0, -6.06217782649107], [0, 0, -7]],
|
|
141
|
+
[[0, 0, 7], [1.5000000000000004, 0, 6.06217782649107], [1.2990381056766578, 1.2500000000000013, 6.06217782649107]]
|
|
141
142
|
]
|
|
143
|
+
t.notThrows(() => geom3.validate(obs))
|
|
142
144
|
t.is(pts.length, 72)
|
|
143
145
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
144
146
|
|
|
145
147
|
// test segments
|
|
146
148
|
obs = ellipsoid({ segments: 8 })
|
|
147
149
|
pts = geom3.toPoints(obs)
|
|
150
|
+
t.notThrows(() => geom3.validate(obs))
|
|
148
151
|
t.is(pts.length, 32)
|
|
149
152
|
|
|
150
153
|
obs = ellipsoid({ center: [-3, 5, 7], segments: 8 })
|
|
@@ -200,6 +203,7 @@ test('ellipsoid (options)', (t) => {
|
|
|
200
203
|
[[-3, 5, 8], [-2.2928932188134525, 5, 7.707106781186548], [-2.5, 5.5, 7.707106781186548]]
|
|
201
204
|
]
|
|
202
205
|
|
|
206
|
+
t.notThrows(() => geom3.validate(obs))
|
|
203
207
|
t.is(pts.length, 32)
|
|
204
208
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
205
209
|
})
|
|
@@ -9,6 +9,7 @@ const comparePolygonsAsPoints = require('../../test/helpers/comparePolygonsAsPoi
|
|
|
9
9
|
test('geodesicSphere (defaults)', (t) => {
|
|
10
10
|
const obs = geodesicSphere()
|
|
11
11
|
const pts = geom3.toPoints(obs)
|
|
12
|
+
t.notThrows(() => geom3.validate(obs))
|
|
12
13
|
t.is(pts.length, 20)
|
|
13
14
|
})
|
|
14
15
|
|
|
@@ -39,6 +40,7 @@ test('geodesicSphere (options)', (t) => {
|
|
|
39
40
|
[[0, -2.628654726407001, -4.253254557317035], [2.628654726407001, -4.253254557317035, 0], [-2.628654726407001, -4.253254557317035, 0]]
|
|
40
41
|
]
|
|
41
42
|
|
|
43
|
+
t.notThrows(() => geom3.validate(obs))
|
|
42
44
|
t.is(pts.length, 20)
|
|
43
45
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
44
46
|
|
|
@@ -46,5 +48,6 @@ test('geodesicSphere (options)', (t) => {
|
|
|
46
48
|
obs = geodesicSphere({ radius: 5, frequency: 18 })
|
|
47
49
|
pts = geom3.toPoints(obs)
|
|
48
50
|
|
|
51
|
+
t.notThrows.skip(() => geom3.validate(obs))
|
|
49
52
|
t.is(pts.length, 180)
|
|
50
53
|
})
|
|
@@ -7,42 +7,47 @@ const { polygon } = require('./index')
|
|
|
7
7
|
const comparePoints = require('../../test/helpers/comparePoints')
|
|
8
8
|
|
|
9
9
|
test('polygon: providing only object.points creates expected geometry', (t) => {
|
|
10
|
-
let
|
|
10
|
+
let geometry = polygon({ points: [[0, 0], [100, 0], [130, 50], [30, 50]] })
|
|
11
11
|
|
|
12
|
-
let obs = geom2.toPoints(
|
|
12
|
+
let obs = geom2.toPoints(geometry)
|
|
13
13
|
let exp = [[0, 0], [100, 0], [130, 50], [30, 50]]
|
|
14
14
|
|
|
15
|
+
t.notThrows(() => geom2.validate(geometry))
|
|
15
16
|
t.true(comparePoints(obs, exp))
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
geometry = polygon({ points: [[[0, 0], [100, 0], [0, 100]], [[10, 10], [80, 10], [10, 80]]] })
|
|
18
19
|
|
|
19
|
-
obs = geom2.toPoints(
|
|
20
|
+
obs = geom2.toPoints(geometry)
|
|
20
21
|
exp = [[0, 0], [100, 0], [10, 80], [10, 10], [80, 10], [0, 100]]
|
|
21
22
|
|
|
23
|
+
t.notThrows(() => geom2.validate(geometry))
|
|
22
24
|
t.true(comparePoints(obs, exp))
|
|
23
25
|
})
|
|
24
26
|
|
|
25
27
|
test('polygon: providing object.points (array) and object.path (array) creates expected geometry', (t) => {
|
|
26
|
-
let
|
|
28
|
+
let geometry = polygon({ points: [[0, 0], [100, 0], [130, 50], [30, 50]], paths: [[3, 2, 1, 0]] })
|
|
27
29
|
|
|
28
|
-
let obs = geom2.toPoints(
|
|
30
|
+
let obs = geom2.toPoints(geometry)
|
|
29
31
|
let exp = [[30, 50], [130, 50], [100, 0], [0, 0]]
|
|
30
32
|
|
|
33
|
+
t.notThrows(() => geom2.validate(geometry))
|
|
31
34
|
t.true(comparePoints(obs, exp))
|
|
32
35
|
|
|
33
36
|
// multiple paths
|
|
34
|
-
|
|
37
|
+
geometry = polygon({ points: [[0, 0], [100, 0], [0, 100], [10, 10], [80, 10], [10, 80]], paths: [[0, 1, 2], [3, 4, 5]] })
|
|
35
38
|
|
|
36
|
-
obs = geom2.toPoints(
|
|
39
|
+
obs = geom2.toPoints(geometry)
|
|
37
40
|
exp = [[0, 0], [100, 0], [10, 80], [10, 10], [80, 10], [0, 100]]
|
|
38
41
|
|
|
42
|
+
t.notThrows(() => geom2.validate(geometry))
|
|
39
43
|
t.true(comparePoints(obs, exp))
|
|
40
44
|
|
|
41
45
|
// multiple points and paths
|
|
42
|
-
|
|
46
|
+
geometry = polygon({ points: [[[0, 0], [100, 0], [0, 100]], [[10, 10], [80, 10], [10, 80]]], paths: [[0, 1, 2], [3, 4, 5]] })
|
|
43
47
|
|
|
44
|
-
obs = geom2.toPoints(
|
|
48
|
+
obs = geom2.toPoints(geometry)
|
|
45
49
|
exp = [[0, 0], [100, 0], [10, 80], [10, 10], [80, 10], [0, 100]]
|
|
46
50
|
|
|
51
|
+
t.notThrows(() => geom2.validate(geometry))
|
|
47
52
|
t.true(comparePoints(obs, exp))
|
|
48
53
|
})
|
|
@@ -60,7 +60,7 @@ const polyhedron = (options) => {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
const polygons = faces.map((face, findex) => {
|
|
63
|
-
const polygon = poly3.
|
|
63
|
+
const polygon = poly3.create(face.map((pindex) => points[pindex]))
|
|
64
64
|
if (colors && colors[findex]) polygon.color = colors[findex]
|
|
65
65
|
return polygon
|
|
66
66
|
})
|
|
@@ -14,31 +14,14 @@ test('polyhedron (points and faces)', (t) => {
|
|
|
14
14
|
let obs = polyhedron({ points, faces, colors })
|
|
15
15
|
let pts = geom3.toPoints(obs)
|
|
16
16
|
let exp = [
|
|
17
|
-
[[-1
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
[[1
|
|
22
|
-
|
|
23
|
-
[1.0000000, 1.0000000, 1.0000000],
|
|
24
|
-
[1.0000000, -1.0000000, 1.0000000]],
|
|
25
|
-
[[-1.0000000, -1.0000000, -1.0000000],
|
|
26
|
-
[1.0000000, -1.0000000, -1.0000000],
|
|
27
|
-
[1.0000000, -1.0000000, 1.0000000],
|
|
28
|
-
[-1.0000000, -1.0000000, 1.0000000]],
|
|
29
|
-
[[-1.0000000, 1.0000000, -1.0000000],
|
|
30
|
-
[-1.0000000, 1.0000000, 1.0000000],
|
|
31
|
-
[1.0000000, 1.0000000, 1.0000000],
|
|
32
|
-
[1.0000000, 1.0000000, -1.0000000]],
|
|
33
|
-
[[-1.0000000, -1.0000000, -1.0000000],
|
|
34
|
-
[-1.0000000, 1.0000000, -1.0000000],
|
|
35
|
-
[1.0000000, 1.0000000, -1.0000000],
|
|
36
|
-
[1.0000000, -1.0000000, -1.0000000]],
|
|
37
|
-
[[-1.0000000, -1.0000000, 1.0000000],
|
|
38
|
-
[1.0000000, -1.0000000, 1.0000000],
|
|
39
|
-
[1.0000000, 1.0000000, 1.0000000],
|
|
40
|
-
[-1.0000000, 1.0000000, 1.0000000]]
|
|
17
|
+
[[-1, -1, -1], [-1, -1, 1], [-1, 1, 1], [-1, 1, -1]],
|
|
18
|
+
[[1, -1, -1], [1, 1, -1], [1, 1, 1], [1, -1, 1]],
|
|
19
|
+
[[-1, -1, -1], [1, -1, -1], [1, -1, 1], [-1, -1, 1]],
|
|
20
|
+
[[-1, 1, -1], [-1, 1, 1], [1, 1, 1], [1, 1, -1]],
|
|
21
|
+
[[-1, -1, -1], [-1, 1, -1], [1, 1, -1], [1, -1, -1]],
|
|
22
|
+
[[-1, -1, 1], [1, -1, 1], [1, 1, 1], [-1, 1, 1]]
|
|
41
23
|
]
|
|
24
|
+
t.notThrows(() => geom3.validate(obs))
|
|
42
25
|
t.deepEqual(pts.length, 6)
|
|
43
26
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
44
27
|
|
|
@@ -48,25 +31,14 @@ test('polyhedron (points and faces)', (t) => {
|
|
|
48
31
|
obs = polyhedron({ points: points, faces: faces, orientation: 'inward' })
|
|
49
32
|
pts = geom3.toPoints(obs)
|
|
50
33
|
exp = [
|
|
51
|
-
[[0, 0, 10],
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
[[0, 0, 10],
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
[[0, 0, 10],
|
|
58
|
-
[-10, 10, 0],
|
|
59
|
-
[-10, -10, 0]],
|
|
60
|
-
[[0, 0, 10],
|
|
61
|
-
[10, 10, 0],
|
|
62
|
-
[-10, 10, 0]],
|
|
63
|
-
[[-10, 10, 0],
|
|
64
|
-
[10, 10, 0],
|
|
65
|
-
[10, -10, 0]],
|
|
66
|
-
[[-10, 10, 0],
|
|
67
|
-
[10, -10, 0],
|
|
68
|
-
[-10, -10, 0]]
|
|
34
|
+
[[0, 0, 10], [10, -10, 0], [10, 10, 0]],
|
|
35
|
+
[[0, 0, 10], [-10, -10, 0], [10, -10, 0]],
|
|
36
|
+
[[0, 0, 10], [-10, 10, 0], [-10, -10, 0]],
|
|
37
|
+
[[0, 0, 10], [10, 10, 0], [-10, 10, 0]],
|
|
38
|
+
[[-10, 10, 0], [10, 10, 0], [10, -10, 0]],
|
|
39
|
+
[[-10, 10, 0], [10, -10, 0], [-10, -10, 0]]
|
|
69
40
|
]
|
|
41
|
+
t.notThrows(() => geom3.validate(obs))
|
|
70
42
|
t.deepEqual(pts.length, 6)
|
|
71
43
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
72
44
|
})
|
|
@@ -16,6 +16,7 @@ test('rectangle (defaults)', (t) => {
|
|
|
16
16
|
[-1, 1]
|
|
17
17
|
]
|
|
18
18
|
|
|
19
|
+
t.notThrows(() => geom2.validate(geometry))
|
|
19
20
|
t.deepEqual(obs.length, 4)
|
|
20
21
|
t.true(comparePoints(obs, exp))
|
|
21
22
|
})
|
|
@@ -31,6 +32,7 @@ test('rectangle (options)', (t) => {
|
|
|
31
32
|
[-5, -3]
|
|
32
33
|
]
|
|
33
34
|
|
|
35
|
+
t.notThrows(() => geom2.validate(geometry))
|
|
34
36
|
t.deepEqual(obs.length, 4)
|
|
35
37
|
t.true(comparePoints(obs, exp))
|
|
36
38
|
|
|
@@ -44,6 +46,7 @@ test('rectangle (options)', (t) => {
|
|
|
44
46
|
[-3, 5]
|
|
45
47
|
]
|
|
46
48
|
|
|
49
|
+
t.notThrows(() => geom2.validate(geometry))
|
|
47
50
|
t.deepEqual(obs.length, 4)
|
|
48
51
|
t.true(comparePoints(obs, exp))
|
|
49
52
|
})
|
|
@@ -57,10 +57,10 @@ const stitchCorners = (previousCorners, currentCorners) => {
|
|
|
57
57
|
const previous = previousCorners[i]
|
|
58
58
|
const current = currentCorners[i]
|
|
59
59
|
for (let j = 0; j < (previous.length - 1); j++) {
|
|
60
|
-
polygons.push(poly3.
|
|
60
|
+
polygons.push(poly3.create([previous[j], previous[j + 1], current[j]]))
|
|
61
61
|
|
|
62
62
|
if (j < (current.length - 1)) {
|
|
63
|
-
polygons.push(poly3.
|
|
63
|
+
polygons.push(poly3.create([current[j], previous[j + 1], current[j + 1]]))
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -81,7 +81,7 @@ const stitchWalls = (previousCorners, currentCorners) => {
|
|
|
81
81
|
const p1 = previous[0]
|
|
82
82
|
const c1 = current[0]
|
|
83
83
|
|
|
84
|
-
polygons.push(poly3.
|
|
84
|
+
polygons.push(poly3.create([p0, p1, c1, c0]))
|
|
85
85
|
}
|
|
86
86
|
return polygons
|
|
87
87
|
}
|
|
@@ -104,7 +104,7 @@ const stitchSides = (bottomCorners, topCorners) => {
|
|
|
104
104
|
const polygons = []
|
|
105
105
|
for (let i = 0; i < topPoints.length; i++) {
|
|
106
106
|
const j = (i + 1) % topPoints.length
|
|
107
|
-
polygons.push(poly3.
|
|
107
|
+
polygons.push(poly3.create([bottomPoints[i], bottomPoints[j], topPoints[j], topPoints[i]]))
|
|
108
108
|
}
|
|
109
109
|
return polygons
|
|
110
110
|
}
|
|
@@ -168,10 +168,10 @@ const roundedCuboid = (options) => {
|
|
|
168
168
|
if (slice === segments) {
|
|
169
169
|
// add the top
|
|
170
170
|
let points = cornersPos.map((corner) => corner[0])
|
|
171
|
-
polygons.push(poly3.
|
|
171
|
+
polygons.push(poly3.create(points))
|
|
172
172
|
// add the bottom
|
|
173
173
|
points = cornersNeg.map((corner) => corner[0])
|
|
174
|
-
polygons.push(poly3.
|
|
174
|
+
polygons.push(poly3.create(points))
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
prevCornersPos = cornersPos
|
|
@@ -10,6 +10,7 @@ test('roundedCuboid (defaults)', (t) => {
|
|
|
10
10
|
const obs = roundedCuboid()
|
|
11
11
|
const pts = geom3.toPoints(obs)
|
|
12
12
|
|
|
13
|
+
t.notThrows(() => geom3.validate(obs))
|
|
13
14
|
t.deepEqual(pts.length, 614)
|
|
14
15
|
})
|
|
15
16
|
|
|
@@ -19,6 +20,7 @@ test('roundedCuboid (options)', (t) => {
|
|
|
19
20
|
let pts = geom3.toPoints(obs)
|
|
20
21
|
let exp = []
|
|
21
22
|
|
|
23
|
+
t.notThrows(() => geom3.validate(obs))
|
|
22
24
|
t.is(pts.length, 62)
|
|
23
25
|
|
|
24
26
|
// test center
|
|
@@ -27,6 +29,7 @@ test('roundedCuboid (options)', (t) => {
|
|
|
27
29
|
exp = [
|
|
28
30
|
]
|
|
29
31
|
|
|
32
|
+
t.notThrows(() => geom3.validate(obs))
|
|
30
33
|
t.is(pts.length, 62)
|
|
31
34
|
|
|
32
35
|
// test size
|
|
@@ -126,6 +129,7 @@ test('roundedCuboid (options)', (t) => {
|
|
|
126
129
|
[[3.8, -4.8, -6], [-3.8, -4.8, -6],
|
|
127
130
|
[-3.8, 4.8, -6], [3.8, 4.8, -6]]
|
|
128
131
|
]
|
|
132
|
+
t.notThrows(() => geom3.validate(obs))
|
|
129
133
|
t.deepEqual(pts.length, 62)
|
|
130
134
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
131
135
|
|
|
@@ -224,6 +228,7 @@ test('roundedCuboid (options)', (t) => {
|
|
|
224
228
|
[[2, 3, 6], [-2, 3, 6], [-2, -3, 6], [2, -3, 6]],
|
|
225
229
|
[[2, -3, -6], [-2, -3, -6], [-2, 3, -6], [2, 3, -6]]
|
|
226
230
|
]
|
|
231
|
+
t.notThrows(() => geom3.validate(obs))
|
|
227
232
|
t.deepEqual(pts.length, 62)
|
|
228
233
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
229
234
|
})
|
|
@@ -5,6 +5,8 @@ const vec3 = require('../maths/vec3')
|
|
|
5
5
|
const geom3 = require('../geometries/geom3')
|
|
6
6
|
const poly3 = require('../geometries/poly3')
|
|
7
7
|
|
|
8
|
+
const { sin, cos } = require('../utils/trigonometry')
|
|
9
|
+
|
|
8
10
|
const { isGT, isGTE, isNumberArray } = require('./commonChecks')
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -64,7 +66,7 @@ const roundedCylinder = (options) => {
|
|
|
64
66
|
const fromPoints = (points) => {
|
|
65
67
|
// adjust the points to center
|
|
66
68
|
const newpoints = points.map((point) => vec3.add(point, point, center))
|
|
67
|
-
return poly3.
|
|
69
|
+
return poly3.create(newpoints)
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
const polygons = []
|
|
@@ -72,8 +74,8 @@ const roundedCylinder = (options) => {
|
|
|
72
74
|
const v2 = vec3.create()
|
|
73
75
|
let prevcylinderpoint
|
|
74
76
|
for (let slice1 = 0; slice1 <= segments; slice1++) {
|
|
75
|
-
const angle =
|
|
76
|
-
const cylinderpoint = vec3.add(vec3.create(), vec3.scale(v1, xvector,
|
|
77
|
+
const angle = 2 * Math.PI * slice1 / segments
|
|
78
|
+
const cylinderpoint = vec3.add(vec3.create(), vec3.scale(v1, xvector, cos(angle)), vec3.scale(v2, yvector, sin(angle)))
|
|
77
79
|
if (slice1 > 0) {
|
|
78
80
|
// cylinder wall
|
|
79
81
|
let points = []
|
|
@@ -86,8 +88,8 @@ const roundedCylinder = (options) => {
|
|
|
86
88
|
let prevcospitch, prevsinpitch
|
|
87
89
|
for (let slice2 = 0; slice2 <= qsegments; slice2++) {
|
|
88
90
|
const pitch = 0.5 * Math.PI * slice2 / qsegments
|
|
89
|
-
const cospitch =
|
|
90
|
-
const sinpitch =
|
|
91
|
+
const cospitch = cos(pitch)
|
|
92
|
+
const sinpitch = sin(pitch)
|
|
91
93
|
if (slice2 > 0) {
|
|
92
94
|
// cylinder rounding, start
|
|
93
95
|
points = []
|