@jscad/modeling 2.12.5 → 3.0.1-alpha.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/CHANGELOG.md +49 -321
- package/LICENSE +1 -1
- package/README.md +5 -3
- package/dist/jscad-modeling.es.js +7 -0
- package/dist/jscad-modeling.min.js +7 -1214
- package/global.d.ts +15 -0
- package/package.json +22 -19
- package/rollup.config.js +21 -0
- package/src/colors/colorNameToRgb.d.ts +2 -4
- package/src/colors/colorNameToRgb.js +4 -6
- package/src/colors/colorNameToRgb.test.js +2 -2
- package/src/colors/colorize.d.ts +6 -8
- package/src/colors/colorize.js +20 -26
- package/src/colors/colorize.test.js +14 -16
- package/src/colors/cssColors.d.ts +1 -1
- package/src/colors/cssColors.js +2 -4
- package/src/colors/hexToRgb.d.ts +2 -4
- package/src/colors/hexToRgb.js +3 -5
- package/src/colors/hexToRgb.test.js +2 -2
- package/src/colors/hslToRgb.d.ts +5 -7
- package/src/colors/hslToRgb.js +4 -6
- package/src/colors/hslToRgb.test.js +2 -2
- package/src/colors/hsvToRgb.d.ts +5 -7
- package/src/colors/hsvToRgb.js +3 -5
- package/src/colors/hsvToRgb.test.js +2 -2
- package/src/colors/hueToColorComponent.d.ts +1 -3
- package/src/colors/hueToColorComponent.js +2 -4
- package/src/colors/index.d.ts +11 -12
- package/src/colors/index.js +12 -13
- package/src/colors/rgbToHex.d.ts +3 -5
- package/src/colors/rgbToHex.js +2 -4
- package/src/colors/rgbToHex.test.js +2 -2
- package/src/colors/rgbToHsl.d.ts +5 -7
- package/src/colors/rgbToHsl.js +2 -4
- package/src/colors/rgbToHsl.test.js +2 -2
- package/src/colors/rgbToHsv.d.ts +5 -7
- package/src/colors/rgbToHsv.js +2 -4
- package/src/colors/rgbToHsv.test.js +2 -2
- package/src/connectors/create.js +3 -5
- package/src/connectors/create.test.js +3 -3
- package/src/connectors/extends.js +7 -8
- package/src/connectors/fromPointAxisNormal.js +6 -8
- package/src/connectors/fromPointAxisNormal.test.js +3 -3
- package/src/connectors/index.js +7 -9
- package/src/connectors/normalize.js +7 -9
- package/src/connectors/toString.js +1 -3
- package/src/connectors/transform.js +10 -12
- package/src/connectors/transform.test.js +3 -3
- package/src/connectors/transformationBetween.js +25 -27
- package/src/connectors/transformationBetween.test.js +13 -13
- package/src/curves/bezier/arcLengthToT.d.ts +2 -4
- package/src/curves/bezier/arcLengthToT.js +6 -8
- package/src/curves/bezier/arcLengthToT.test.js +13 -13
- package/src/curves/bezier/create.d.ts +2 -4
- package/src/curves/bezier/create.js +3 -5
- package/src/curves/bezier/create.test.js +2 -2
- package/src/curves/bezier/index.d.ts +7 -8
- package/src/curves/bezier/index.js +9 -8
- package/src/curves/bezier/length.d.ts +2 -4
- package/src/curves/bezier/length.js +4 -6
- package/src/curves/bezier/length.test.js +12 -12
- package/src/curves/bezier/lengths.d.ts +2 -4
- package/src/curves/bezier/lengths.js +5 -7
- package/src/curves/bezier/lengths.test.js +12 -12
- package/src/curves/bezier/tangentAt.d.ts +2 -4
- package/src/curves/bezier/tangentAt.js +2 -4
- package/src/curves/bezier/tangentAt.test.js +2 -2
- package/src/curves/bezier/type.d.ts +1 -3
- package/src/curves/bezier/valueAt.d.ts +2 -4
- package/src/curves/bezier/valueAt.js +2 -4
- package/src/curves/bezier/valueAt.test.js +2 -2
- package/src/curves/index.d.ts +1 -3
- package/src/curves/index.js +4 -5
- package/src/geometries/geom2/applyTransforms.js +7 -13
- package/src/geometries/geom2/applyTransforms.test.js +6 -6
- package/src/geometries/geom2/clone.d.ts +2 -4
- package/src/geometries/geom2/clone.js +3 -5
- package/src/geometries/geom2/clone.test.js +5 -5
- package/src/geometries/geom2/create.d.ts +3 -5
- package/src/geometries/geom2/create.js +19 -19
- package/src/geometries/geom2/create.test.js +6 -6
- package/src/geometries/geom2/fromCompactBinary.d.ts +2 -4
- package/src/geometries/geom2/fromCompactBinary.js +19 -11
- package/src/geometries/geom2/fromSides.d.ts +4 -0
- package/src/geometries/geom2/fromSides.js +115 -0
- package/src/geometries/geom2/fromToCompactBinary.test.js +16 -38
- package/src/geometries/geom2/index.d.ts +14 -15
- package/src/geometries/geom2/index.js +17 -24
- package/src/geometries/geom2/isA.d.ts +2 -4
- package/src/geometries/geom2/isA.js +4 -6
- package/src/geometries/geom2/isA.test.js +5 -3
- package/src/geometries/geom2/reverse.d.ts +2 -4
- package/src/geometries/geom2/reverse.js +12 -14
- package/src/geometries/geom2/reverse.test.js +29 -9
- package/src/geometries/geom2/toCompactBinary.d.ts +2 -4
- package/src/geometries/geom2/toCompactBinary.js +18 -15
- package/src/geometries/geom2/toOutlines.d.ts +3 -5
- package/src/geometries/geom2/toOutlines.js +3 -109
- package/src/geometries/geom2/toOutlines.test.js +34 -61
- package/src/geometries/geom2/toPoints.d.ts +3 -5
- package/src/geometries/geom2/toPoints.js +10 -13
- package/src/geometries/geom2/toPoints.test.js +8 -8
- package/src/geometries/geom2/toSides.d.ts +3 -5
- package/src/geometries/geom2/toSides.js +13 -6
- package/src/geometries/geom2/toString.d.ts +2 -4
- package/src/geometries/geom2/toString.js +9 -11
- package/src/geometries/geom2/toString.test.js +17 -0
- package/src/geometries/geom2/transform.d.ts +3 -5
- package/src/geometries/geom2/transform.js +9 -11
- package/src/geometries/geom2/transform.test.js +28 -29
- package/src/geometries/geom2/type.d.ts +5 -7
- package/src/geometries/geom2/validate.d.ts +1 -3
- package/src/geometries/geom2/validate.js +34 -13
- package/src/geometries/geom2/validate.test.js +39 -0
- package/src/geometries/geom3/applyTransforms.js +5 -7
- package/src/geometries/geom3/applyTransforms.test.js +6 -6
- package/src/geometries/geom3/clone.d.ts +2 -4
- package/src/geometries/geom3/clone.js +3 -5
- package/src/geometries/geom3/clone.test.js +5 -5
- package/src/geometries/geom3/create.d.ts +3 -5
- package/src/geometries/geom3/create.js +17 -8
- package/src/geometries/geom3/create.test.js +5 -5
- package/src/geometries/geom3/fromCompactBinary.d.ts +2 -4
- package/src/geometries/geom3/fromCompactBinary.js +6 -8
- package/src/geometries/geom3/fromPoints.d.ts +3 -5
- package/src/geometries/geom3/fromPoints.js +11 -19
- package/src/geometries/geom3/fromPoints.test.js +6 -6
- package/src/geometries/geom3/fromPointsConvex.d.ts +3 -5
- package/src/geometries/geom3/fromPointsConvex.js +6 -7
- package/src/geometries/geom3/fromPointsConvex.test.js +6 -5
- package/src/geometries/geom3/fromToCompactBinary.test.js +7 -7
- package/src/geometries/geom3/index.d.ts +14 -15
- package/src/geometries/geom3/index.js +22 -30
- package/src/geometries/geom3/invert.d.ts +2 -4
- package/src/geometries/geom3/invert.js +8 -10
- package/src/geometries/geom3/invert.test.js +5 -5
- package/src/geometries/geom3/isA.d.ts +2 -4
- package/src/geometries/geom3/isA.js +2 -4
- package/src/geometries/geom3/isA.test.js +2 -2
- package/src/geometries/geom3/toCompactBinary.d.ts +2 -4
- package/src/geometries/geom3/toCompactBinary.js +10 -12
- package/src/geometries/geom3/toPoints.d.ts +3 -5
- package/src/geometries/geom3/toPoints.js +5 -8
- package/src/geometries/geom3/toPoints.test.js +9 -9
- package/src/geometries/geom3/toPolygons.d.ts +3 -5
- package/src/geometries/geom3/toPolygons.js +4 -6
- package/src/geometries/geom3/toString.d.ts +2 -4
- package/src/geometries/geom3/toString.js +5 -7
- package/src/geometries/geom3/toString.test.js +17 -0
- package/src/geometries/geom3/transform.d.ts +3 -5
- package/src/geometries/geom3/transform.js +6 -8
- package/src/geometries/geom3/transform.test.js +6 -6
- package/src/geometries/geom3/type.d.ts +4 -6
- package/src/geometries/geom3/validate.d.ts +1 -3
- package/src/geometries/geom3/validate.js +5 -6
- package/src/geometries/geom3/validate.test.js +26 -0
- package/src/geometries/index.d.ts +6 -7
- package/src/geometries/index.js +10 -10
- package/src/geometries/path2/appendArc.d.ts +4 -6
- package/src/geometries/path2/appendArc.js +58 -60
- package/src/geometries/path2/appendArc.test.js +8 -7
- package/src/geometries/path2/appendBezier.d.ts +3 -5
- package/src/geometries/path2/appendBezier.js +41 -43
- package/src/geometries/path2/appendBezier.test.js +3 -3
- package/src/geometries/path2/appendPoints.d.ts +3 -5
- package/src/geometries/path2/appendPoints.js +6 -8
- package/src/geometries/path2/appendPoints.test.js +2 -2
- package/src/geometries/path2/applyTransforms.js +3 -5
- package/src/geometries/path2/applyTransforms.test.js +4 -4
- package/src/geometries/path2/clone.d.ts +2 -4
- package/src/geometries/path2/clone.js +3 -5
- package/src/geometries/path2/close.d.ts +2 -4
- package/src/geometries/path2/close.js +6 -8
- package/src/geometries/path2/close.test.js +2 -2
- package/src/geometries/path2/concat.d.ts +2 -4
- package/src/geometries/path2/concat.js +11 -13
- package/src/geometries/path2/concat.test.js +2 -2
- package/src/geometries/path2/create.d.ts +3 -5
- package/src/geometries/path2/create.js +12 -9
- package/src/geometries/path2/create.test.js +2 -2
- package/src/geometries/path2/equals.d.ts +2 -4
- package/src/geometries/path2/equals.js +9 -11
- package/src/geometries/path2/equals.test.js +2 -2
- package/src/geometries/path2/fromCompactBinary.d.ts +2 -4
- package/src/geometries/path2/fromCompactBinary.js +5 -7
- package/src/geometries/path2/fromPoints.d.ts +3 -5
- package/src/geometries/path2/fromPoints.js +9 -11
- package/src/geometries/path2/fromPoints.test.js +3 -3
- package/src/geometries/path2/fromToCompactBinary.test.js +2 -2
- package/src/geometries/path2/index.d.ts +18 -19
- package/src/geometries/path2/index.js +19 -28
- package/src/geometries/path2/isA.d.ts +2 -4
- package/src/geometries/path2/isA.js +2 -4
- package/src/geometries/path2/isA.test.js +2 -2
- package/src/geometries/path2/reverse.d.ts +2 -4
- package/src/geometries/path2/reverse.js +5 -7
- package/src/geometries/path2/reverse.test.js +2 -2
- package/src/geometries/path2/toCompactBinary.d.ts +2 -4
- package/src/geometries/path2/toCompactBinary.js +2 -4
- package/src/geometries/path2/toPoints.d.ts +3 -5
- package/src/geometries/path2/toPoints.js +4 -6
- package/src/geometries/path2/toPoints.test.js +3 -3
- package/src/geometries/path2/toString.d.ts +2 -4
- package/src/geometries/path2/toString.js +5 -7
- package/src/geometries/path2/transform.d.ts +3 -5
- package/src/geometries/path2/transform.js +6 -8
- package/src/geometries/path2/transform.test.js +5 -5
- package/src/geometries/path2/type.d.ts +4 -6
- package/src/geometries/path2/validate.d.ts +1 -3
- package/src/geometries/path2/validate.js +6 -7
- package/src/geometries/poly2/arePointsInside.d.ts +3 -5
- package/src/geometries/poly2/arePointsInside.js +21 -24
- package/src/geometries/poly2/arePointsInside.test.js +2 -2
- package/src/geometries/poly2/clone.d.ts +3 -0
- package/src/geometries/poly2/clone.js +8 -0
- package/src/geometries/poly2/clone.test.js +17 -0
- package/src/geometries/poly2/create.d.ts +3 -5
- package/src/geometries/poly2/create.js +11 -12
- package/src/geometries/poly2/create.test.js +4 -4
- package/src/geometries/poly2/index.d.ts +14 -6
- package/src/geometries/poly2/index.js +16 -11
- package/src/geometries/poly2/isA.d.ts +3 -0
- package/src/geometries/poly2/isA.js +16 -0
- package/src/geometries/poly2/isA.test.js +30 -0
- package/src/geometries/poly2/isConvex.d.ts +3 -0
- package/src/geometries/poly2/isConvex.js +37 -0
- package/src/geometries/poly2/isConvex.test.js +27 -0
- package/src/geometries/poly2/isSimple.d.ts +3 -0
- package/src/geometries/poly2/isSimple.js +38 -0
- package/src/geometries/poly2/isSimple.test.js +31 -0
- package/src/geometries/poly2/measureArea.d.ts +2 -4
- package/src/geometries/poly2/measureArea.js +5 -7
- package/src/geometries/poly2/measureArea.test.js +2 -2
- package/src/geometries/poly2/measureBoundingBox.d.ts +4 -0
- package/src/geometries/poly2/measureBoundingBox.js +18 -0
- package/src/geometries/poly2/measureBoundingBox.test.js +71 -0
- package/src/geometries/poly2/reverse.d.ts +3 -0
- package/src/geometries/poly2/reverse.js +13 -0
- package/src/geometries/poly2/reverse.test.js +27 -0
- package/src/geometries/poly2/toPoints.d.ts +4 -0
- package/src/geometries/poly2/toPoints.js +8 -0
- package/src/geometries/poly2/toPoints.test.js +18 -0
- package/src/geometries/poly2/toString.d.ts +3 -0
- package/src/geometries/poly2/toString.js +9 -0
- package/src/geometries/poly2/toString.test.js +10 -0
- package/src/geometries/poly2/transform.d.ts +4 -0
- package/src/geometries/poly2/transform.js +20 -0
- package/src/geometries/poly2/transform.test.js +62 -0
- package/src/geometries/poly2/type.d.ts +5 -5
- package/src/geometries/poly2/validate.d.ts +2 -0
- package/src/geometries/poly2/validate.js +46 -0
- package/src/geometries/poly2/validate.test.js +31 -0
- package/src/geometries/poly3/clone.d.ts +3 -5
- package/src/geometries/poly3/clone.js +6 -8
- package/src/geometries/poly3/clone.test.js +6 -5
- package/src/geometries/poly3/create.d.ts +3 -5
- package/src/geometries/poly3/create.js +6 -6
- package/src/geometries/poly3/create.test.js +15 -3
- package/src/geometries/poly3/fromVerticesAndPlane.d.ts +5 -0
- package/src/geometries/poly3/{fromPointsAndPlane.js → fromVerticesAndPlane.js} +5 -7
- package/src/geometries/poly3/index.d.ts +16 -18
- package/src/geometries/poly3/index.js +17 -22
- package/src/geometries/poly3/invert.d.ts +2 -4
- package/src/geometries/poly3/invert.js +6 -7
- package/src/geometries/poly3/invert.test.js +5 -5
- package/src/geometries/poly3/isA.d.ts +2 -4
- package/src/geometries/poly3/isA.js +2 -4
- package/src/geometries/poly3/isA.test.js +3 -3
- package/src/geometries/poly3/isConvex.d.ts +2 -4
- package/src/geometries/poly3/isConvex.js +21 -23
- package/src/geometries/poly3/isConvex.test.js +9 -9
- package/src/geometries/poly3/measureArea.d.ts +2 -4
- package/src/geometries/poly3/measureArea.js +4 -6
- package/src/geometries/poly3/measureArea.test.js +12 -11
- package/src/geometries/poly3/measureBoundingBox.d.ts +3 -5
- package/src/geometries/poly3/measureBoundingBox.js +6 -8
- package/src/geometries/poly3/measureBoundingBox.test.js +9 -8
- package/src/geometries/poly3/measureBoundingSphere.d.ts +3 -5
- package/src/geometries/poly3/measureBoundingSphere.js +4 -6
- package/src/geometries/poly3/measureBoundingSphere.test.js +8 -7
- package/src/geometries/poly3/measureSignedVolume.d.ts +2 -4
- package/src/geometries/poly3/measureSignedVolume.js +4 -6
- package/src/geometries/poly3/measureSignedVolume.test.js +8 -8
- package/src/geometries/poly3/plane.d.ts +3 -5
- package/src/geometries/poly3/plane.js +2 -4
- package/src/geometries/poly3/toString.d.ts +2 -4
- package/src/geometries/poly3/toString.js +4 -12
- package/src/geometries/poly3/toString.test.js +10 -0
- package/src/geometries/poly3/toVertices.d.ts +4 -0
- package/src/geometries/poly3/toVertices.js +8 -0
- package/src/geometries/poly3/transform.d.ts +3 -5
- package/src/geometries/poly3/transform.js +7 -9
- package/src/geometries/poly3/transform.test.js +7 -7
- package/src/geometries/poly3/type.d.ts +6 -6
- package/src/geometries/poly3/validate.d.ts +1 -3
- package/src/geometries/poly3/validate.js +14 -15
- package/src/geometries/slice/calculatePlane.d.ts +5 -0
- package/src/geometries/slice/calculatePlane.js +65 -0
- package/src/geometries/slice/calculatePlane.test.js +43 -0
- package/src/geometries/slice/clone.d.ts +3 -0
- package/src/geometries/slice/clone.js +9 -0
- package/src/geometries/slice/clone.test.js +14 -0
- package/src/geometries/slice/create.d.ts +4 -0
- package/src/geometries/slice/create.js +18 -0
- package/src/{operations/extrusions → geometries}/slice/create.test.js +3 -3
- package/src/{operations/extrusions → geometries/slice}/earcut/assignHoles.js +6 -8
- package/src/geometries/slice/earcut/assignHoles.test.js +75 -0
- package/src/{operations/extrusions → geometries/slice}/earcut/eliminateHoles.js +3 -5
- package/src/{operations/extrusions → geometries/slice}/earcut/index.js +7 -8
- package/src/{operations/extrusions → geometries/slice}/earcut/linkedList.js +3 -6
- package/src/{operations/extrusions → geometries/slice}/earcut/linkedListSort.js +1 -4
- package/src/{operations/extrusions → geometries/slice}/earcut/linkedPolygon.js +8 -10
- package/src/{operations/extrusions → geometries/slice}/earcut/polygonHierarchy.js +13 -13
- package/src/{operations/extrusions → geometries/slice}/earcut/triangle.js +2 -5
- package/src/geometries/slice/equals.d.ts +3 -0
- package/src/geometries/slice/equals.js +27 -0
- package/src/geometries/slice/equals.test.js +17 -0
- package/src/geometries/slice/fromGeom2.d.ts +5 -0
- package/src/geometries/slice/fromGeom2.js +17 -0
- package/src/geometries/slice/fromVertices.d.ts +7 -0
- package/src/geometries/slice/fromVertices.js +34 -0
- package/src/geometries/slice/fromVertices.test.js +11 -0
- package/src/geometries/slice/index.d.ts +16 -0
- package/src/geometries/slice/index.js +23 -0
- package/src/geometries/slice/isA.d.ts +3 -0
- package/src/geometries/slice/isA.js +16 -0
- package/src/{operations/extrusions → geometries}/slice/isA.test.js +3 -3
- package/src/geometries/slice/reverse.d.ts +3 -0
- package/src/geometries/slice/reverse.js +14 -0
- package/src/geometries/slice/toEdges.d.ts +3 -0
- package/src/geometries/slice/toEdges.js +20 -0
- package/src/geometries/slice/toPolygons.d.ts +5 -0
- package/src/{operations/extrusions → geometries}/slice/toPolygons.js +9 -10
- package/src/geometries/slice/toString.d.ts +3 -0
- package/src/geometries/slice/toString.js +16 -0
- package/src/geometries/slice/toString.test.js +17 -0
- package/src/geometries/slice/toVertices.d.ts +4 -0
- package/src/geometries/slice/toVertices.js +19 -0
- package/src/geometries/slice/transform.d.ts +5 -0
- package/src/geometries/slice/transform.js +19 -0
- package/src/{operations/extrusions → geometries}/slice/transform.test.js +11 -21
- package/src/geometries/slice/type.d.ts +7 -0
- package/src/geometries/slice/validate.d.ts +1 -0
- package/src/geometries/slice/validate.js +48 -0
- package/src/geometries/slice/validate.test.js +36 -0
- package/src/geometries/types.d.ts +12 -10
- package/src/index.d.ts +2 -4
- package/src/index.js +14 -16
- package/src/index.test-d.ts +3 -3
- package/src/maths/constants.d.ts +1 -1
- package/src/maths/constants.js +10 -20
- package/src/maths/index.d.ts +9 -11
- package/src/maths/index.js +11 -12
- package/src/maths/line2/clone.d.ts +2 -4
- package/src/maths/line2/clone.js +4 -6
- package/src/maths/line2/clone.test.js +4 -3
- package/src/maths/line2/closestPoint.d.ts +3 -5
- package/src/maths/line2/closestPoint.js +7 -9
- package/src/maths/line2/closestPoint.test.js +4 -3
- package/src/maths/line2/copy.d.ts +2 -4
- package/src/maths/line2/copy.js +4 -6
- package/src/maths/line2/copy.test.js +4 -3
- package/src/maths/line2/create.d.ts +2 -4
- package/src/maths/line2/create.js +5 -8
- package/src/maths/line2/create.test.js +3 -3
- package/src/maths/line2/direction.d.ts +3 -5
- package/src/maths/line2/direction.js +4 -6
- package/src/maths/line2/direction.test.js +3 -3
- package/src/maths/line2/distanceToPoint.d.ts +3 -5
- package/src/maths/line2/distanceToPoint.js +5 -7
- package/src/maths/line2/distanceToPoint.test.js +6 -4
- package/src/maths/line2/equals.d.ts +2 -4
- package/src/maths/line2/equals.js +4 -6
- package/src/maths/line2/equals.test.js +3 -2
- package/src/maths/line2/fromPoints.d.ts +3 -5
- package/src/maths/line2/fromPoints.js +6 -8
- package/src/maths/line2/fromPoints.test.js +4 -3
- package/src/maths/line2/fromValues.d.ts +2 -4
- package/src/maths/line2/fromValues.js +6 -8
- package/src/maths/line2/fromValues.test.js +4 -3
- package/src/maths/line2/index.d.ts +16 -17
- package/src/maths/line2/index.js +16 -18
- package/src/maths/line2/intersectPointOfLines.d.ts +3 -5
- package/src/maths/line2/intersectPointOfLines.js +7 -8
- package/src/maths/line2/intersectPointOfLines.test.js +4 -3
- package/src/maths/line2/origin.d.ts +3 -5
- package/src/maths/line2/origin.js +4 -6
- package/src/maths/line2/origin.test.js +4 -3
- package/src/maths/line2/reverse.d.ts +2 -4
- package/src/maths/line2/reverse.js +7 -9
- package/src/maths/line2/reverse.test.js +4 -3
- package/src/maths/line2/toString.d.ts +2 -4
- package/src/maths/line2/toString.js +3 -5
- package/src/maths/line2/transform.d.ts +3 -5
- package/src/maths/line2/transform.js +9 -11
- package/src/maths/line2/transform.test.js +4 -3
- package/src/maths/line2/type.d.ts +1 -3
- package/src/maths/line2/xAtY.d.ts +2 -4
- package/src/maths/line2/xAtY.js +5 -7
- package/src/maths/line2/xAtY.test.js +6 -4
- package/src/maths/line3/clone.d.ts +2 -4
- package/src/maths/line3/clone.js +5 -7
- package/src/maths/line3/clone.test.js +4 -3
- package/src/maths/line3/closestPoint.d.ts +3 -5
- package/src/maths/line3/closestPoint.js +12 -14
- package/src/maths/line3/closestPoint.test.js +4 -3
- package/src/maths/line3/copy.d.ts +2 -4
- package/src/maths/line3/copy.js +5 -7
- package/src/maths/line3/copy.test.js +4 -3
- package/src/maths/line3/create.d.ts +2 -4
- package/src/maths/line3/create.js +4 -7
- package/src/maths/line3/create.test.js +3 -3
- package/src/maths/line3/direction.d.ts +3 -5
- package/src/maths/line3/direction.js +3 -5
- package/src/maths/line3/direction.test.js +4 -3
- package/src/maths/line3/distanceToPoint.d.ts +3 -5
- package/src/maths/line3/distanceToPoint.js +8 -10
- package/src/maths/line3/distanceToPoint.test.js +6 -4
- package/src/maths/line3/equals.d.ts +2 -4
- package/src/maths/line3/equals.js +4 -6
- package/src/maths/line3/equals.test.js +3 -2
- package/src/maths/line3/fromPlanes.d.ts +3 -5
- package/src/maths/line3/fromPlanes.js +14 -17
- package/src/maths/line3/fromPlanes.test.js +4 -4
- package/src/maths/line3/fromPointAndDirection.d.ts +3 -5
- package/src/maths/line3/fromPointAndDirection.js +6 -8
- package/src/maths/line3/fromPointAndDirection.test.js +4 -3
- package/src/maths/line3/fromPoints.d.ts +3 -5
- package/src/maths/line3/fromPoints.js +7 -9
- package/src/maths/line3/fromPoints.test.js +4 -3
- package/src/maths/line3/index.d.ts +16 -17
- package/src/maths/line3/index.js +16 -18
- package/src/maths/line3/intersectPointOfLineAndPlane.d.ts +4 -6
- package/src/maths/line3/intersectPointOfLineAndPlane.js +10 -13
- package/src/maths/line3/intersectPointOfLineAndPlane.test.js +4 -4
- package/src/maths/line3/origin.d.ts +3 -5
- package/src/maths/line3/origin.js +3 -5
- package/src/maths/line3/origin.test.js +4 -3
- package/src/maths/line3/reverse.d.ts +2 -4
- package/src/maths/line3/reverse.js +6 -8
- package/src/maths/line3/reverse.test.js +4 -3
- package/src/maths/line3/toString.d.ts +2 -4
- package/src/maths/line3/toString.js +3 -5
- package/src/maths/line3/transform.d.ts +3 -5
- package/src/maths/line3/transform.js +10 -12
- package/src/maths/line3/transform.test.js +4 -3
- package/src/maths/line3/type.d.ts +2 -4
- package/src/maths/mat4/add.d.ts +2 -4
- package/src/maths/mat4/add.js +5 -7
- package/src/maths/mat4/add.test.js +4 -3
- package/src/maths/mat4/clone.d.ts +2 -4
- package/src/maths/mat4/clone.js +4 -6
- package/src/maths/mat4/clone.test.js +4 -3
- package/src/maths/mat4/copy.d.ts +2 -4
- package/src/maths/mat4/copy.js +4 -6
- package/src/maths/mat4/copy.test.js +4 -3
- package/src/maths/mat4/create.d.ts +2 -4
- package/src/maths/mat4/create.js +2 -5
- package/src/maths/mat4/create.test.js +3 -3
- package/src/maths/mat4/equals.d.ts +2 -4
- package/src/maths/mat4/equals.js +4 -6
- package/src/maths/mat4/equals.test.js +3 -2
- package/src/maths/mat4/fromRotation.d.ts +3 -5
- package/src/maths/mat4/fromRotation.js +8 -10
- package/src/maths/mat4/fromRotation.test.js +4 -3
- package/src/maths/mat4/fromScaling.d.ts +3 -5
- package/src/maths/mat4/fromScaling.js +4 -6
- package/src/maths/mat4/fromScaling.test.js +4 -3
- package/src/maths/mat4/fromTaitBryanRotation.d.ts +2 -4
- package/src/maths/mat4/fromTaitBryanRotation.js +7 -9
- package/src/maths/mat4/fromTaitBryanRotation.test.js +3 -3
- package/src/maths/mat4/fromTranslation.d.ts +3 -5
- package/src/maths/mat4/fromTranslation.js +4 -6
- package/src/maths/mat4/fromTranslation.test.js +4 -3
- package/src/maths/mat4/fromValues.d.ts +2 -4
- package/src/maths/mat4/fromValues.js +19 -21
- package/src/maths/mat4/fromValues.test.js +4 -3
- package/src/maths/mat4/fromVectorRotation.d.ts +3 -5
- package/src/maths/mat4/fromVectorRotation.js +8 -10
- package/src/maths/mat4/fromVectorRotation.test.js +4 -5
- package/src/maths/mat4/fromXRotation.d.ts +2 -4
- package/src/maths/mat4/fromXRotation.js +5 -7
- package/src/maths/mat4/fromXRotation.test.js +4 -3
- package/src/maths/mat4/fromYRotation.d.ts +2 -4
- package/src/maths/mat4/fromYRotation.js +5 -7
- package/src/maths/mat4/fromYRotation.test.js +4 -3
- package/src/maths/mat4/fromZRotation.d.ts +2 -4
- package/src/maths/mat4/fromZRotation.js +5 -7
- package/src/maths/mat4/fromZRotation.test.js +4 -3
- package/src/maths/mat4/identity.d.ts +2 -4
- package/src/maths/mat4/identity.js +3 -5
- package/src/maths/mat4/identity.test.js +4 -3
- package/src/maths/mat4/index.d.ts +30 -28
- package/src/maths/mat4/index.js +29 -31
- package/src/maths/mat4/invert.d.ts +3 -0
- package/src/maths/mat4/invert.js +7 -7
- package/src/maths/mat4/invert.test.js +6 -5
- package/src/maths/mat4/isIdentity.d.ts +2 -4
- package/src/maths/mat4/isIdentity.js +4 -6
- package/src/maths/mat4/isIdentity.test.js +2 -2
- package/src/maths/mat4/isMirroring.d.ts +2 -4
- package/src/maths/mat4/isMirroring.js +4 -6
- package/src/maths/mat4/isMirroring.test.js +3 -3
- package/src/maths/mat4/isOnlyTransformScale.d.ts +3 -0
- package/src/maths/mat4/isOnlyTransformScale.js +7 -5
- package/src/maths/mat4/isOnlyTransformScale.test.js +3 -3
- package/src/maths/mat4/mirrorByPlane.d.ts +3 -5
- package/src/maths/mat4/mirrorByPlane.js +4 -6
- package/src/maths/mat4/mirrorByPlane.test.js +4 -4
- package/src/maths/mat4/multiply.d.ts +2 -4
- package/src/maths/mat4/multiply.js +5 -7
- package/src/maths/mat4/multiply.test.js +4 -3
- package/src/maths/mat4/rotate.d.ts +3 -5
- package/src/maths/mat4/rotate.js +9 -11
- package/src/maths/mat4/rotate.test.js +6 -5
- package/src/maths/mat4/rotateX.d.ts +2 -4
- package/src/maths/mat4/rotateX.js +6 -8
- package/src/maths/mat4/rotateX.test.js +4 -3
- package/src/maths/mat4/rotateY.d.ts +2 -4
- package/src/maths/mat4/rotateY.js +6 -8
- package/src/maths/mat4/rotateY.test.js +4 -3
- package/src/maths/mat4/rotateZ.d.ts +2 -4
- package/src/maths/mat4/rotateZ.js +6 -8
- package/src/maths/mat4/rotateZ.test.js +4 -3
- package/src/maths/mat4/scale.d.ts +3 -5
- package/src/maths/mat4/scale.js +5 -7
- package/src/maths/mat4/scale.test.js +4 -3
- package/src/maths/mat4/subtract.d.ts +2 -4
- package/src/maths/mat4/subtract.js +5 -7
- package/src/maths/mat4/subtract.test.js +4 -3
- package/src/maths/mat4/toString.d.ts +2 -4
- package/src/maths/mat4/toString.js +3 -5
- package/src/maths/mat4/translate.d.ts +3 -5
- package/src/maths/mat4/translate.js +5 -7
- package/src/maths/mat4/translate.test.js +11 -15
- package/src/maths/mat4/type.d.ts +1 -3
- package/src/maths/plane/clone.d.ts +2 -4
- package/src/maths/plane/clone.test.js +4 -3
- package/src/maths/plane/copy.d.ts +2 -4
- package/src/maths/plane/copy.test.js +4 -3
- package/src/maths/plane/create.d.ts +2 -4
- package/src/maths/plane/create.test.js +3 -3
- package/src/maths/plane/equals.d.ts +2 -4
- package/src/maths/plane/equals.test.js +3 -2
- package/src/maths/plane/flip.d.ts +2 -4
- package/src/maths/plane/flip.js +4 -6
- package/src/maths/plane/flip.test.js +4 -3
- package/src/maths/plane/fromNormalAndPoint.d.ts +3 -5
- package/src/maths/plane/fromNormalAndPoint.js +6 -9
- package/src/maths/plane/fromNormalAndPoint.test.js +4 -3
- package/src/maths/plane/fromPoints.d.ts +3 -5
- package/src/maths/plane/fromPoints.js +4 -6
- package/src/maths/plane/fromPoints.test.js +4 -3
- package/src/maths/plane/fromPointsRandom.d.ts +3 -5
- package/src/maths/plane/fromPointsRandom.js +8 -10
- package/src/maths/plane/fromValues.d.ts +2 -4
- package/src/maths/plane/index.d.ts +14 -16
- package/src/maths/plane/index.js +38 -40
- package/src/maths/plane/projectionOfPoint.d.ts +3 -5
- package/src/maths/plane/projectionOfPoint.js +5 -7
- package/src/maths/plane/projectionOfPoint.test.js +3 -3
- package/src/maths/plane/signedDistanceToPoint.d.ts +3 -5
- package/src/maths/plane/signedDistanceToPoint.js +5 -7
- package/src/maths/plane/signedDistanceToPoint.test.js +3 -2
- package/src/maths/plane/toString.d.ts +2 -4
- package/src/maths/plane/transform.d.ts +3 -5
- package/src/maths/plane/transform.js +11 -13
- package/src/maths/plane/transform.test.js +4 -3
- package/src/maths/plane/type.d.ts +1 -3
- package/src/maths/rotation.test.js +4 -4
- package/src/maths/types.d.ts +15 -8
- package/src/maths/utils/OrthonormalFormula.d.ts +9 -0
- package/src/maths/utils/OrthonormalFormula.js +82 -0
- package/src/maths/utils/OrthonormalFormula.test.js +72 -0
- package/src/maths/utils/aboutEqualNormals.d.ts +2 -4
- package/src/maths/utils/aboutEqualNormals.js +4 -6
- package/src/maths/utils/area.d.ts +2 -4
- package/src/maths/utils/area.js +2 -4
- package/src/maths/utils/interpolateBetween2DPointsForY.d.ts +2 -4
- package/src/maths/utils/interpolateBetween2DPointsForY.js +4 -6
- package/src/maths/utils/intersect.d.ts +2 -4
- package/src/maths/utils/intersect.js +14 -9
- package/src/maths/utils/intersect.test.js +40 -0
- package/src/maths/utils/solve2Linear.d.ts +2 -4
- package/src/maths/utils/solve2Linear.js +1 -3
- package/src/maths/utils/trigonometry.js +7 -9
- package/src/maths/utils/trigonometry.test.js +3 -3
- package/src/maths/vec1/type.d.ts +1 -3
- package/src/maths/vec2/abs.d.ts +2 -4
- package/src/maths/vec2/abs.js +4 -6
- package/src/maths/vec2/abs.test.js +4 -3
- package/src/maths/vec2/add.d.ts +2 -4
- package/src/maths/vec2/add.js +5 -7
- package/src/maths/vec2/add.test.js +4 -3
- package/src/maths/vec2/angle.d.ts +1 -3
- package/src/maths/vec2/angle.js +1 -1
- package/src/maths/vec2/angleDegrees.d.ts +2 -4
- package/src/maths/vec2/angleDegrees.js +4 -6
- package/src/maths/vec2/angleDegrees.test.js +6 -4
- package/src/maths/vec2/angleRadians.d.ts +2 -4
- package/src/maths/vec2/angleRadians.js +3 -5
- package/src/maths/vec2/angleRadians.test.js +6 -4
- package/src/maths/vec2/clone.d.ts +2 -4
- package/src/maths/vec2/clone.js +4 -6
- package/src/maths/vec2/clone.test.js +4 -3
- package/src/maths/vec2/copy.d.ts +2 -4
- package/src/maths/vec2/copy.js +4 -6
- package/src/maths/vec2/copy.test.js +4 -3
- package/src/maths/vec2/create.d.ts +2 -4
- package/src/maths/vec2/create.js +2 -5
- package/src/maths/vec2/create.test.js +3 -3
- package/src/maths/vec2/cross.d.ts +3 -5
- package/src/maths/vec2/cross.js +5 -7
- package/src/maths/vec2/cross.test.js +14 -12
- package/src/maths/vec2/distance.d.ts +2 -4
- package/src/maths/vec2/distance.js +4 -6
- package/src/maths/vec2/distance.test.js +6 -4
- package/src/maths/vec2/divide.d.ts +2 -4
- package/src/maths/vec2/divide.js +5 -7
- package/src/maths/vec2/divide.test.js +4 -3
- package/src/maths/vec2/dot.d.ts +2 -4
- package/src/maths/vec2/dot.js +4 -6
- package/src/maths/vec2/dot.test.js +3 -2
- package/src/maths/vec2/equals.d.ts +2 -4
- package/src/maths/vec2/equals.js +3 -5
- package/src/maths/vec2/equals.test.js +3 -2
- package/src/maths/vec2/fromAngleDegrees.d.ts +2 -4
- package/src/maths/vec2/fromAngleDegrees.js +5 -7
- package/src/maths/vec2/fromAngleDegrees.test.js +4 -3
- package/src/maths/vec2/fromAngleRadians.d.ts +2 -4
- package/src/maths/vec2/fromAngleRadians.js +5 -7
- package/src/maths/vec2/fromAngleRadians.test.js +4 -4
- package/src/maths/vec2/fromScalar.d.ts +2 -4
- package/src/maths/vec2/fromScalar.js +4 -6
- package/src/maths/vec2/fromScalar.test.js +4 -3
- package/src/maths/vec2/fromValues.d.ts +2 -4
- package/src/maths/vec2/fromValues.js +5 -7
- package/src/maths/vec2/index.d.ts +34 -35
- package/src/maths/vec2/index.js +33 -35
- package/src/maths/vec2/length.d.ts +2 -4
- package/src/maths/vec2/length.js +3 -5
- package/src/maths/vec2/length.test.js +6 -4
- package/src/maths/vec2/lerp.d.ts +2 -4
- package/src/maths/vec2/lerp.js +6 -8
- package/src/maths/vec2/lerp.test.js +4 -3
- package/src/maths/vec2/max.d.ts +2 -4
- package/src/maths/vec2/max.js +5 -7
- package/src/maths/vec2/max.test.js +4 -3
- package/src/maths/vec2/min.d.ts +2 -4
- package/src/maths/vec2/min.js +5 -7
- package/src/maths/vec2/min.test.js +4 -3
- package/src/maths/vec2/multiply.d.ts +2 -4
- package/src/maths/vec2/multiply.js +5 -7
- package/src/maths/vec2/multiply.test.js +4 -3
- package/src/maths/vec2/negate.d.ts +2 -4
- package/src/maths/vec2/negate.js +4 -6
- package/src/maths/vec2/negate.test.js +4 -3
- package/src/maths/vec2/normal.d.ts +2 -4
- package/src/maths/vec2/normal.js +7 -9
- package/src/maths/vec2/normal.test.js +4 -3
- package/src/maths/vec2/normalize.d.ts +2 -4
- package/src/maths/vec2/normalize.js +4 -8
- package/src/maths/vec2/normalize.test.js +4 -3
- package/src/maths/vec2/rotate.d.ts +2 -4
- package/src/maths/vec2/rotate.js +6 -8
- package/src/maths/vec2/rotate.test.js +4 -4
- package/src/maths/vec2/scale.d.ts +2 -4
- package/src/maths/vec2/scale.js +5 -7
- package/src/maths/vec2/scale.test.js +4 -3
- package/src/maths/vec2/snap.d.ts +2 -4
- package/src/maths/vec2/snap.js +5 -7
- package/src/maths/vec2/snap.test.js +4 -3
- package/src/maths/vec2/squaredDistance.d.ts +2 -4
- package/src/maths/vec2/squaredDistance.js +4 -6
- package/src/maths/vec2/squaredDistance.test.js +6 -4
- package/src/maths/vec2/squaredLength.d.ts +2 -4
- package/src/maths/vec2/squaredLength.js +3 -5
- package/src/maths/vec2/squaredLength.test.js +6 -4
- package/src/maths/vec2/subtract.d.ts +2 -4
- package/src/maths/vec2/subtract.js +5 -7
- package/src/maths/vec2/subtract.test.js +4 -3
- package/src/maths/vec2/toString.d.ts +2 -4
- package/src/maths/vec2/toString.js +3 -5
- package/src/maths/vec2/transform.d.ts +3 -5
- package/src/maths/vec2/transform.js +5 -7
- package/src/maths/vec2/transform.test.js +4 -3
- package/src/maths/vec2/type.d.ts +1 -3
- package/src/maths/vec3/abs.d.ts +2 -4
- package/src/maths/vec3/abs.js +4 -6
- package/src/maths/vec3/abs.test.js +4 -3
- package/src/maths/vec3/add.d.ts +2 -4
- package/src/maths/vec3/add.js +5 -7
- package/src/maths/vec3/add.test.js +4 -3
- package/src/maths/vec3/angle.d.ts +2 -4
- package/src/maths/vec3/angle.js +5 -7
- package/src/maths/vec3/angle.test.js +6 -4
- package/src/maths/vec3/clone.d.ts +2 -4
- package/src/maths/vec3/clone.js +4 -6
- package/src/maths/vec3/clone.test.js +4 -3
- package/src/maths/vec3/copy.d.ts +2 -4
- package/src/maths/vec3/copy.js +4 -6
- package/src/maths/vec3/copy.test.js +4 -3
- package/src/maths/vec3/create.d.ts +2 -4
- package/src/maths/vec3/create.js +2 -5
- package/src/maths/vec3/create.test.js +3 -3
- package/src/maths/vec3/cross.d.ts +2 -4
- package/src/maths/vec3/cross.js +5 -7
- package/src/maths/vec3/cross.test.js +4 -3
- package/src/maths/vec3/distance.d.ts +2 -4
- package/src/maths/vec3/distance.js +4 -6
- package/src/maths/vec3/distance.test.js +6 -4
- package/src/maths/vec3/divide.d.ts +2 -4
- package/src/maths/vec3/divide.js +5 -7
- package/src/maths/vec3/divide.test.js +4 -3
- package/src/maths/vec3/dot.d.ts +2 -4
- package/src/maths/vec3/dot.js +4 -6
- package/src/maths/vec3/dot.test.js +3 -2
- package/src/maths/vec3/equals.d.ts +2 -4
- package/src/maths/vec3/equals.js +3 -5
- package/src/maths/vec3/equals.test.js +3 -2
- package/src/maths/vec3/fromScalar.d.ts +2 -4
- package/src/maths/vec3/fromScalar.js +4 -6
- package/src/maths/vec3/fromScalar.test.js +4 -3
- package/src/maths/vec3/fromValues.d.ts +2 -4
- package/src/maths/vec3/fromValues.js +6 -8
- package/src/maths/vec3/fromValues.test.js +4 -3
- package/src/maths/vec3/fromVec2.d.ts +3 -5
- package/src/maths/vec3/fromVec2.js +4 -6
- package/src/maths/vec3/fromVec2.test.js +3 -3
- package/src/maths/vec3/index.d.ts +33 -34
- package/src/maths/vec3/index.js +32 -34
- package/src/maths/vec3/length.d.ts +2 -4
- package/src/maths/vec3/length.js +3 -5
- package/src/maths/vec3/length.test.js +6 -4
- package/src/maths/vec3/lerp.d.ts +2 -4
- package/src/maths/vec3/lerp.js +6 -8
- package/src/maths/vec3/lerp.test.js +4 -3
- package/src/maths/vec3/max.d.ts +2 -4
- package/src/maths/vec3/max.js +5 -7
- package/src/maths/vec3/max.test.js +4 -3
- package/src/maths/vec3/min.d.ts +2 -4
- package/src/maths/vec3/min.js +5 -7
- package/src/maths/vec3/min.test.js +4 -3
- package/src/maths/vec3/multiply.d.ts +2 -4
- package/src/maths/vec3/multiply.js +5 -7
- package/src/maths/vec3/multiply.test.js +4 -3
- package/src/maths/vec3/negate.d.ts +2 -4
- package/src/maths/vec3/negate.js +4 -6
- package/src/maths/vec3/negate.test.js +4 -3
- package/src/maths/vec3/normalize.d.ts +2 -4
- package/src/maths/vec3/normalize.js +4 -6
- package/src/maths/vec3/normalize.test.js +4 -3
- package/src/maths/vec3/orthogonal.d.ts +2 -4
- package/src/maths/vec3/orthogonal.js +7 -9
- package/src/maths/vec3/orthogonal.test.js +4 -3
- package/src/maths/vec3/rotateX.d.ts +2 -4
- package/src/maths/vec3/rotateX.js +6 -8
- package/src/maths/vec3/rotateX.test.js +4 -4
- package/src/maths/vec3/rotateY.d.ts +2 -4
- package/src/maths/vec3/rotateY.js +6 -8
- package/src/maths/vec3/rotateY.test.js +4 -4
- package/src/maths/vec3/rotateZ.d.ts +2 -4
- package/src/maths/vec3/rotateZ.js +6 -8
- package/src/maths/vec3/rotateZ.test.js +4 -4
- package/src/maths/vec3/scale.d.ts +2 -4
- package/src/maths/vec3/scale.js +5 -7
- package/src/maths/vec3/scale.test.js +4 -3
- package/src/maths/vec3/snap.d.ts +2 -4
- package/src/maths/vec3/snap.js +5 -7
- package/src/maths/vec3/snap.test.js +4 -3
- package/src/maths/vec3/squaredDistance.d.ts +2 -4
- package/src/maths/vec3/squaredDistance.js +4 -6
- package/src/maths/vec3/squaredDistance.test.js +6 -4
- package/src/maths/vec3/squaredLength.d.ts +2 -4
- package/src/maths/vec3/squaredLength.js +3 -5
- package/src/maths/vec3/squaredLength.test.js +6 -4
- package/src/maths/vec3/subtract.d.ts +2 -4
- package/src/maths/vec3/subtract.js +5 -7
- package/src/maths/vec3/subtract.test.js +4 -3
- package/src/maths/vec3/toString.d.ts +2 -4
- package/src/maths/vec3/toString.js +3 -5
- package/src/maths/vec3/transform.d.ts +3 -5
- package/src/maths/vec3/transform.js +5 -7
- package/src/maths/vec3/transform.test.js +12 -15
- package/src/maths/vec3/type.d.ts +1 -3
- package/src/maths/vec4/clone.d.ts +2 -4
- package/src/maths/vec4/clone.js +4 -6
- package/src/maths/vec4/clone.test.js +4 -3
- package/src/maths/vec4/copy.d.ts +2 -4
- package/src/maths/vec4/copy.js +4 -6
- package/src/maths/vec4/copy.test.js +4 -3
- package/src/maths/vec4/create.d.ts +2 -4
- package/src/maths/vec4/create.js +2 -5
- package/src/maths/vec4/create.test.js +3 -3
- package/src/maths/vec4/dot.d.ts +2 -4
- package/src/maths/vec4/dot.js +4 -6
- package/src/maths/vec4/dot.test.js +2 -2
- package/src/maths/vec4/equals.d.ts +2 -4
- package/src/maths/vec4/equals.js +3 -5
- package/src/maths/vec4/equals.test.js +3 -2
- package/src/maths/vec4/fromScalar.d.ts +2 -4
- package/src/maths/vec4/fromScalar.js +3 -5
- package/src/maths/vec4/fromScalar.test.js +4 -3
- package/src/maths/vec4/fromValues.d.ts +2 -4
- package/src/maths/vec4/fromValues.js +7 -9
- package/src/maths/vec4/fromValues.test.js +4 -3
- package/src/maths/vec4/index.d.ts +10 -11
- package/src/maths/vec4/index.js +9 -11
- package/src/maths/vec4/toString.d.ts +2 -4
- package/src/maths/vec4/toString.js +3 -5
- package/src/maths/vec4/transform.d.ts +3 -5
- package/src/maths/vec4/transform.js +6 -7
- package/src/maths/vec4/transform.test.js +4 -3
- package/src/maths/vec4/type.d.ts +1 -3
- package/src/measurements/calculateEpsilonFromBounds.js +2 -4
- package/src/measurements/calculateEpsilonFromBounds.test.js +4 -3
- package/src/measurements/index.d.ts +13 -14
- package/src/measurements/index.js +13 -15
- package/src/measurements/measureAggregateArea.d.ts +3 -5
- package/src/measurements/measureAggregateArea.js +4 -7
- package/src/measurements/measureAggregateArea.test.js +4 -3
- package/src/measurements/measureAggregateBoundingBox.d.ts +4 -6
- package/src/measurements/measureAggregateBoundingBox.js +6 -9
- package/src/measurements/measureAggregateBoundingBox.test.js +4 -4
- package/src/measurements/measureAggregateEpsilon.d.ts +3 -5
- package/src/measurements/measureAggregateEpsilon.js +10 -9
- package/src/measurements/measureAggregateEpsilon.test.js +6 -4
- package/src/measurements/measureAggregateVolume.d.ts +3 -5
- package/src/measurements/measureAggregateVolume.js +4 -7
- package/src/measurements/measureAggregateVolume.test.js +4 -3
- package/src/measurements/measureArea.d.ts +5 -7
- package/src/measurements/measureArea.js +37 -20
- package/src/measurements/measureArea.test.js +14 -4
- package/src/measurements/measureBoundingBox.d.ts +6 -8
- package/src/measurements/measureBoundingBox.js +81 -82
- package/src/measurements/measureBoundingBox.test.js +26 -5
- package/src/measurements/measureBoundingSphere.d.ts +4 -7
- package/src/measurements/measureBoundingSphere.js +83 -64
- package/src/measurements/measureBoundingSphere.test.js +7 -4
- package/src/measurements/measureCenter.d.ts +4 -6
- package/src/measurements/measureCenter.js +4 -6
- package/src/measurements/measureCenter.test.js +7 -4
- package/src/measurements/measureCenterOfMass.d.ts +4 -6
- package/src/measurements/measureCenterOfMass.js +6 -8
- package/src/measurements/measureCenterOfMass.test.js +7 -4
- package/src/measurements/measureDimensions.d.ts +4 -6
- package/src/measurements/measureDimensions.js +3 -5
- package/src/measurements/measureDimensions.test.js +7 -4
- package/src/measurements/measureEpsilon.d.ts +5 -7
- package/src/measurements/measureEpsilon.js +14 -30
- package/src/measurements/measureEpsilon.test.js +7 -4
- package/src/measurements/measureVolume.d.ts +5 -7
- package/src/measurements/measureVolume.js +7 -31
- package/src/measurements/measureVolume.test.js +7 -4
- package/src/measurements/types.d.ts +2 -1
- package/src/operations/booleans/index.d.ts +4 -6
- package/src/operations/booleans/index.js +5 -7
- package/src/operations/booleans/intersect.d.ts +5 -6
- package/src/operations/booleans/intersect.js +13 -15
- package/src/operations/booleans/intersect.test.js +24 -0
- package/src/operations/booleans/intersectGeom2.js +10 -20
- package/src/operations/booleans/intersectGeom2.test.js +47 -17
- package/src/operations/booleans/intersectGeom3.js +9 -15
- package/src/operations/booleans/intersectGeom3.test.js +17 -17
- package/src/operations/booleans/intersectGeom3Sub.js +10 -11
- package/src/operations/booleans/martinez/compareEvents.js +45 -0
- package/src/operations/booleans/martinez/compareSegments.js +51 -0
- package/src/operations/booleans/martinez/computeFields.js +109 -0
- package/src/operations/booleans/martinez/connectEdges.js +189 -0
- package/src/operations/booleans/martinez/contour.js +12 -0
- package/src/operations/booleans/martinez/divideSegment.js +32 -0
- package/src/operations/booleans/martinez/edgeType.js +4 -0
- package/src/operations/booleans/martinez/fillQueue.js +80 -0
- package/src/operations/booleans/martinez/index.js +154 -0
- package/src/operations/booleans/martinez/operation.js +4 -0
- package/src/operations/booleans/martinez/possibleIntersection.js +113 -0
- package/src/operations/booleans/martinez/segmentIntersection.js +132 -0
- package/src/operations/booleans/martinez/signedArea.js +16 -0
- package/src/operations/booleans/martinez/splaytree.js +599 -0
- package/src/operations/booleans/martinez/subdivideSegments.js +82 -0
- package/src/operations/booleans/martinez/sweepEvent.js +132 -0
- package/src/operations/booleans/martinez/tinyqueue.js +76 -0
- package/src/operations/booleans/mayOverlap.js +5 -7
- package/src/operations/booleans/mayOverlap.test.js +6 -6
- package/src/operations/booleans/scission.d.ts +4 -5
- package/src/operations/booleans/scission.js +5 -13
- package/src/operations/booleans/scission.test.js +10 -4
- package/src/operations/booleans/scissionGeom3.js +15 -16
- package/src/operations/booleans/subtract.d.ts +5 -6
- package/src/operations/booleans/subtract.js +13 -15
- package/src/operations/booleans/subtract.test.js +24 -0
- package/src/operations/booleans/subtractGeom2.js +10 -20
- package/src/operations/booleans/subtractGeom2.test.js +46 -17
- package/src/operations/booleans/subtractGeom3.js +9 -15
- package/src/operations/booleans/subtractGeom3.test.js +16 -6
- package/src/operations/booleans/subtractGeom3Sub.js +10 -11
- package/src/operations/booleans/trees/Node.js +45 -48
- package/src/operations/booleans/trees/PolygonTreeNode.js +35 -37
- package/src/operations/booleans/trees/Tree.js +9 -12
- package/src/operations/booleans/trees/index.js +1 -3
- package/src/operations/booleans/trees/splitLineSegmentByPlane.js +2 -4
- package/src/operations/booleans/trees/splitPolygonByPlane.js +55 -57
- package/src/operations/booleans/union.d.ts +5 -6
- package/src/operations/booleans/union.js +13 -15
- package/src/operations/booleans/union.test.js +24 -0
- package/src/operations/booleans/unionGeom2.js +10 -20
- package/src/operations/booleans/unionGeom2.test.js +153 -84
- package/src/operations/booleans/unionGeom3.js +9 -15
- package/src/operations/booleans/unionGeom3.test.js +22 -9
- package/src/operations/booleans/unionGeom3Sub.js +10 -12
- package/src/operations/extrusions/extrudeFromSlices.d.ts +3 -6
- package/src/operations/extrusions/extrudeFromSlices.js +19 -31
- package/src/operations/extrusions/extrudeFromSlices.test.js +54 -48
- package/src/operations/extrusions/extrudeHelical.d.ts +2 -4
- package/src/operations/extrusions/extrudeHelical.js +19 -26
- package/src/operations/extrusions/extrudeHelical.test.js +6 -6
- package/src/operations/extrusions/extrudeLinear.d.ts +4 -6
- package/src/operations/extrusions/extrudeLinear.js +10 -16
- package/src/operations/extrusions/extrudeLinear.test.js +90 -67
- package/src/operations/extrusions/extrudeLinearGeom2.js +18 -23
- package/src/operations/extrusions/extrudeLinearPath2.js +11 -12
- package/src/operations/extrusions/extrudeRotate.d.ts +2 -4
- package/src/operations/extrusions/extrudeRotate.js +28 -32
- package/src/operations/extrusions/extrudeRotate.test.js +70 -34
- package/src/operations/extrusions/extrudeWalls.js +11 -14
- package/src/operations/extrusions/extrudeWalls.test.js +24 -48
- package/src/operations/extrusions/index.d.ts +5 -9
- package/src/operations/extrusions/index.js +6 -10
- package/src/operations/extrusions/project.d.ts +6 -8
- package/src/operations/extrusions/project.js +35 -32
- package/src/operations/extrusions/project.test.js +116 -83
- package/src/operations/hulls/hull.d.ts +5 -7
- package/src/operations/hulls/hull.js +14 -15
- package/src/operations/hulls/hull.test.js +101 -58
- package/src/operations/hulls/hullChain.d.ts +5 -7
- package/src/operations/hulls/hullChain.js +15 -10
- package/src/operations/hulls/hullChain.test.js +27 -8
- package/src/operations/hulls/hullGeom2.js +7 -13
- package/src/operations/hulls/hullGeom3.js +6 -12
- package/src/operations/hulls/hullPath2.js +6 -12
- package/src/operations/hulls/hullPath2.test.js +4 -4
- package/src/operations/hulls/hullPoints2.d.ts +2 -4
- package/src/operations/hulls/hullPoints2.js +3 -5
- package/src/operations/hulls/hullPoints2.test.js +2 -2
- package/src/operations/hulls/hullPoints3.d.ts +3 -5
- package/src/operations/hulls/hullPoints3.js +4 -6
- package/src/operations/hulls/index.d.ts +4 -6
- package/src/operations/hulls/index.js +5 -7
- package/src/operations/hulls/quickhull/Face.js +7 -21
- package/src/operations/hulls/quickhull/HalfEdge.js +2 -5
- package/src/operations/hulls/quickhull/QuickHull.js +14 -16
- package/src/operations/hulls/quickhull/Vertex.js +1 -3
- package/src/operations/hulls/quickhull/VertexList.js +1 -4
- package/src/operations/hulls/quickhull/index.js +2 -4
- package/src/operations/hulls/quickhull/point-line-distance.js +2 -6
- package/src/operations/hulls/toUniquePoints.js +4 -6
- package/src/operations/modifiers/generalize.d.ts +2 -2
- package/src/operations/modifiers/generalize.js +15 -21
- package/src/operations/modifiers/generalize.test.js +6 -6
- package/src/operations/modifiers/index.d.ts +3 -3
- package/src/operations/modifiers/index.js +4 -6
- package/src/operations/modifiers/insertTjunctions.js +164 -165
- package/src/operations/modifiers/insertTjunctions.test.js +5 -5
- package/src/operations/modifiers/mergePolygons.js +35 -36
- package/src/operations/modifiers/reTesselateCoplanarPolygons.js +235 -236
- package/src/operations/modifiers/reTesselateCoplanarPolygons.test.js +4 -4
- package/src/operations/modifiers/retessellate.d.ts +2 -2
- package/src/operations/modifiers/retessellate.js +7 -7
- package/src/operations/modifiers/retessellate.test.js +4 -4
- package/src/operations/modifiers/snap.d.ts +2 -2
- package/src/operations/modifiers/snap.js +30 -23
- package/src/operations/modifiers/snap.test.js +32 -10
- package/src/operations/modifiers/snapPolygons.js +14 -16
- package/src/operations/modifiers/snapPolygons.test.js +3 -3
- package/src/operations/modifiers/triangulatePolygons.js +5 -6
- package/src/operations/offsets/extrudePolygon.js +32 -0
- package/src/operations/offsets/index.d.ts +2 -0
- package/src/operations/offsets/index.js +9 -0
- package/src/operations/offsets/offset.d.ts +12 -0
- package/src/operations/offsets/offset.js +32 -0
- package/src/operations/offsets/offsetFromPoints.d.ts +10 -0
- package/src/operations/{expansions → offsets}/offsetFromPoints.js +29 -28
- package/src/operations/offsets/offsetFromPoints.test.js +316 -0
- package/src/operations/offsets/offsetGeom2.js +55 -0
- package/src/operations/offsets/offsetGeom2.test.js +269 -0
- package/src/operations/offsets/offsetGeom3.js +31 -0
- package/src/operations/{expansions/expandGeom3.test.js → offsets/offsetGeom3.test.js} +71 -5
- package/src/operations/{expansions/expandPath2.js → offsets/offsetPath2.js} +27 -33
- package/src/operations/offsets/offsetPath2.test.js +103 -0
- package/src/operations/{expansions/expandShell.js → offsets/offsetShell.js} +54 -56
- package/src/operations/transforms/align.d.ts +5 -7
- package/src/operations/transforms/align.js +16 -15
- package/src/operations/transforms/align.test.js +9 -8
- package/src/operations/transforms/center.d.ts +3 -3
- package/src/operations/transforms/center.js +12 -22
- package/src/operations/transforms/center.test.js +34 -6
- package/src/operations/transforms/index.d.ts +7 -9
- package/src/operations/transforms/index.js +8 -29
- package/src/operations/transforms/mirror.d.ts +3 -3
- package/src/operations/transforms/mirror.js +12 -22
- package/src/operations/transforms/mirror.test.js +16 -10
- package/src/operations/transforms/rotate.d.ts +6 -6
- package/src/operations/transforms/rotate.js +14 -24
- package/src/operations/transforms/rotate.test.js +18 -7
- package/src/operations/transforms/scale.d.ts +6 -6
- package/src/operations/transforms/scale.js +13 -23
- package/src/operations/transforms/scale.test.js +21 -6
- package/src/operations/transforms/transform.d.ts +3 -3
- package/src/operations/transforms/transform.js +8 -13
- package/src/operations/transforms/transform.test.js +7 -7
- package/src/operations/transforms/translate.d.ts +3 -5
- package/src/operations/transforms/translate.js +14 -24
- package/src/operations/transforms/translate.test.js +18 -6
- package/src/primitives/arc.d.ts +3 -5
- package/src/primitives/arc.js +26 -28
- package/src/primitives/arc.test.js +17 -16
- package/src/primitives/circle.d.ts +3 -5
- package/src/primitives/circle.js +10 -12
- package/src/primitives/circle.test.js +23 -12
- package/src/primitives/commonChecks.js +3 -9
- package/src/primitives/cube.d.ts +3 -5
- package/src/primitives/cube.js +6 -9
- package/src/primitives/cube.test.js +14 -4
- package/src/primitives/cuboid.d.ts +3 -5
- package/src/primitives/cuboid.js +8 -10
- package/src/primitives/cuboid.test.js +14 -4
- package/src/primitives/cylinder.d.ts +3 -5
- package/src/primitives/cylinder.js +11 -15
- package/src/primitives/cylinder.test.js +16 -4
- package/src/primitives/cylinderElliptic.d.ts +3 -5
- package/src/primitives/cylinderElliptic.js +33 -35
- package/src/primitives/cylinderElliptic.test.js +26 -5
- package/src/primitives/ellipse.d.ts +3 -5
- package/src/primitives/ellipse.js +19 -21
- package/src/primitives/ellipse.test.js +23 -12
- package/src/primitives/ellipsoid.d.ts +3 -5
- package/src/primitives/ellipsoid.js +48 -51
- package/src/primitives/ellipsoid.test.js +16 -4
- package/src/primitives/geodesicSphere.d.ts +2 -4
- package/src/primitives/geodesicSphere.js +14 -17
- package/src/primitives/geodesicSphere.test.js +12 -4
- package/src/primitives/index.d.ts +21 -23
- package/src/primitives/index.js +22 -24
- package/src/primitives/line.d.ts +3 -5
- package/src/primitives/line.js +3 -5
- package/src/primitives/line.test.js +5 -5
- package/src/primitives/polygon.d.ts +3 -5
- package/src/primitives/polygon.js +17 -22
- package/src/primitives/polygon.test.js +14 -9
- package/src/primitives/polyhedron.d.ts +4 -6
- package/src/primitives/polyhedron.js +15 -17
- package/src/primitives/polyhedron.test.js +12 -6
- package/src/primitives/rectangle.d.ts +3 -5
- package/src/primitives/rectangle.js +10 -12
- package/src/primitives/rectangle.test.js +13 -7
- package/src/primitives/roundedCuboid.d.ts +3 -5
- package/src/primitives/roundedCuboid.js +57 -58
- package/src/primitives/roundedCuboid.test.js +24 -8
- package/src/primitives/roundedCylinder.d.ts +3 -5
- package/src/primitives/roundedCylinder.js +73 -76
- package/src/primitives/roundedCylinder.test.js +24 -4
- package/src/primitives/roundedRectangle.d.ts +3 -5
- package/src/primitives/roundedRectangle.js +16 -16
- package/src/primitives/roundedRectangle.test.js +19 -10
- package/src/primitives/sphere.d.ts +3 -5
- package/src/primitives/sphere.js +8 -11
- package/src/primitives/sphere.test.js +16 -4
- package/src/primitives/square.d.ts +3 -5
- package/src/primitives/square.js +6 -9
- package/src/primitives/square.test.js +14 -8
- package/src/primitives/star.d.ts +3 -5
- package/src/primitives/star.js +16 -18
- package/src/primitives/star.test.js +18 -10
- package/src/primitives/torus.d.ts +2 -4
- package/src/primitives/torus.js +16 -18
- package/src/primitives/torus.test.js +18 -6
- package/src/primitives/triangle.d.ts +2 -4
- package/src/primitives/triangle.js +9 -11
- package/src/primitives/triangle.test.js +23 -13
- package/src/text/fonts/single-line/hershey/simplex.js +1 -1
- package/src/text/index.d.ts +2 -4
- package/src/text/index.js +3 -5
- package/src/text/vectorChar.d.ts +2 -8
- package/src/text/vectorChar.js +51 -36
- package/src/text/vectorChar.test.js +63 -0
- package/src/text/vectorText.d.ts +2 -8
- package/src/text/vectorText.js +100 -69
- package/src/text/vectorText.test.js +267 -0
- package/src/utils/areAllShapesTheSameType.d.ts +2 -4
- package/src/utils/areAllShapesTheSameType.js +4 -6
- package/src/utils/areAllShapesTheSameType.test.js +3 -3
- package/src/utils/coalesce.d.ts +3 -0
- package/src/utils/coalesce.js +20 -0
- package/src/utils/degToRad.d.ts +1 -3
- package/src/utils/degToRad.js +3 -5
- package/src/utils/degToRad.test.js +3 -3
- package/src/utils/flatten.d.ts +2 -4
- package/src/utils/flatten.js +1 -3
- package/src/utils/fnNumberSort.d.ts +1 -3
- package/src/utils/fnNumberSort.js +1 -3
- package/src/utils/index.d.ts +4 -9
- package/src/utils/index.js +5 -10
- package/src/utils/insertSorted.d.ts +1 -3
- package/src/utils/insertSorted.js +11 -13
- package/src/utils/padArrayToLength.d.ts +1 -3
- package/src/utils/padArrayToLength.js +2 -4
- package/src/utils/padArrayToLength.test.js +2 -2
- package/src/utils/radToDeg.d.ts +1 -3
- package/src/utils/radToDeg.js +3 -5
- package/src/utils/radToDeg.test.js +3 -3
- package/src/utils/radiusToSegments.d.ts +1 -3
- package/src/utils/radiusToSegments.js +6 -8
- package/src/utils/radiusToSegments.test.js +3 -3
- package/src/utils/recursiveArray.d.ts +1 -3
- package/test/helpers/asserts.js +9 -16
- package/test/helpers/comparePoints.js +2 -4
- package/test/helpers/comparePolygonLists.js +2 -4
- package/test/helpers/comparePolygons.js +4 -6
- package/test/helpers/comparePolygonsAsPoints.js +4 -6
- package/test/helpers/compareVectors.js +5 -6
- package/test/helpers/index.js +6 -8
- package/test/helpers/nearlyEqual.js +1 -3
- package/tsconfig.json +17 -0
- package/src/geometries/geom2/fromPoints.d.ts +0 -6
- package/src/geometries/geom2/fromPoints.js +0 -35
- package/src/geometries/geom2/fromPoints.test.js +0 -22
- package/src/geometries/poly2/flip.d.ts +0 -5
- package/src/geometries/poly2/flip.js +0 -15
- package/src/geometries/poly3/fromPoints.d.ts +0 -6
- package/src/geometries/poly3/fromPoints.js +0 -25
- package/src/geometries/poly3/fromPoints.test.js +0 -15
- package/src/geometries/poly3/fromPointsAndPlane.d.ts +0 -7
- package/src/geometries/poly3/toPoints.d.ts +0 -6
- package/src/geometries/poly3/toPoints.js +0 -10
- package/src/maths/OrthoNormalBasis.js +0 -59
- package/src/maths/mat4/leftMultiplyVec2.d.ts +0 -6
- package/src/maths/mat4/leftMultiplyVec2.js +0 -28
- package/src/maths/mat4/leftMultiplyVec3.d.ts +0 -6
- package/src/maths/mat4/leftMultiplyVec3.js +0 -29
- package/src/maths/mat4/mirror.d.ts +0 -6
- package/src/maths/mat4/mirror.js +0 -34
- package/src/maths/mat4/rightMultiplyVec2.d.ts +0 -6
- package/src/maths/mat4/rightMultiplyVec2.js +0 -29
- package/src/maths/mat4/rightMultiplyVec3.d.ts +0 -6
- package/src/maths/mat4/rightMultiplyVec3.js +0 -30
- package/src/maths/plane/fromNoisyPoints.d.ts +0 -6
- package/src/maths/plane/fromNoisyPoints.js +0 -106
- package/src/maths/plane/fromNoisyPoints.test.js +0 -24
- package/src/maths/utils/index.d.ts +0 -8
- package/src/maths/utils/index.js +0 -15
- package/src/operations/booleans/fromFakePolygons.js +0 -52
- package/src/operations/booleans/to3DWalls.js +0 -36
- package/src/operations/expansions/expand.d.ts +0 -18
- package/src/operations/expansions/expand.js +0 -42
- package/src/operations/expansions/expand.test.js +0 -188
- package/src/operations/expansions/expandGeom2.js +0 -43
- package/src/operations/expansions/expandGeom3.js +0 -36
- package/src/operations/expansions/extrudePolygon.js +0 -34
- package/src/operations/expansions/index.d.ts +0 -4
- package/src/operations/expansions/index.js +0 -11
- package/src/operations/expansions/offset.d.ts +0 -15
- package/src/operations/expansions/offset.js +0 -36
- package/src/operations/expansions/offset.test.js +0 -503
- package/src/operations/expansions/offsetGeom2.js +0 -47
- package/src/operations/expansions/offsetPath2.js +0 -32
- package/src/operations/extrusions/earcut/assignHoles.test.js +0 -74
- package/src/operations/extrusions/extrudeRectangular.d.ts +0 -17
- package/src/operations/extrusions/extrudeRectangular.js +0 -45
- package/src/operations/extrusions/extrudeRectangular.test.js +0 -72
- package/src/operations/extrusions/extrudeRectangularGeom2.js +0 -46
- package/src/operations/extrusions/extrudeRectangularPath2.js +0 -33
- package/src/operations/extrusions/slice/calculatePlane.d.ts +0 -7
- package/src/operations/extrusions/slice/calculatePlane.js +0 -41
- package/src/operations/extrusions/slice/calculatePlane.test.js +0 -35
- package/src/operations/extrusions/slice/clone.d.ts +0 -6
- package/src/operations/extrusions/slice/clone.js +0 -28
- package/src/operations/extrusions/slice/clone.test.js +0 -34
- package/src/operations/extrusions/slice/create.d.ts +0 -5
- package/src/operations/extrusions/slice/create.js +0 -20
- package/src/operations/extrusions/slice/equals.d.ts +0 -5
- package/src/operations/extrusions/slice/equals.js +0 -27
- package/src/operations/extrusions/slice/equals.test.js +0 -17
- package/src/operations/extrusions/slice/fromPoints.d.ts +0 -9
- package/src/operations/extrusions/slice/fromPoints.js +0 -35
- package/src/operations/extrusions/slice/fromPoints.test.js +0 -15
- package/src/operations/extrusions/slice/fromSides.d.ts +0 -7
- package/src/operations/extrusions/slice/fromSides.js +0 -27
- package/src/operations/extrusions/slice/fromSides.test.js +0 -15
- package/src/operations/extrusions/slice/index.d.ts +0 -16
- package/src/operations/extrusions/slice/index.js +0 -19
- package/src/operations/extrusions/slice/isA.d.ts +0 -5
- package/src/operations/extrusions/slice/isA.js +0 -18
- package/src/operations/extrusions/slice/repair.js +0 -62
- package/src/operations/extrusions/slice/reverse.d.ts +0 -6
- package/src/operations/extrusions/slice/reverse.js +0 -26
- package/src/operations/extrusions/slice/toEdges.d.ts +0 -5
- package/src/operations/extrusions/slice/toEdges.js +0 -13
- package/src/operations/extrusions/slice/toPolygons.d.ts +0 -7
- package/src/operations/extrusions/slice/toString.d.ts +0 -5
- package/src/operations/extrusions/slice/toString.js +0 -15
- package/src/operations/extrusions/slice/transform.d.ts +0 -7
- package/src/operations/extrusions/slice/transform.js +0 -21
- package/src/operations/extrusions/slice/type.d.ts +0 -7
- package/src/operations/hulls/quickhull/get-plane-normal.js +0 -20
- package/src/text/text.test.js +0 -187
- package/src/text/vectorParams.js +0 -26
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import * as geom2 from '../../geometries/geom2/index.js'
|
|
2
|
+
import * as geom3 from '../../geometries/geom3/index.js'
|
|
3
|
+
import * as path2 from '../../geometries/path2/index.js'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
const geom3 = require('../../geometries/geom3')
|
|
5
|
-
const path2 = require('../../geometries/path2')
|
|
5
|
+
import { measureAggregateBoundingBox } from '../../measurements/measureAggregateBoundingBox.js'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { translate } = require('./translate')
|
|
7
|
+
import { translate } from './translate.js'
|
|
10
8
|
|
|
11
9
|
const centerGeometry = (options, object) => {
|
|
12
10
|
const defaults = {
|
|
@@ -15,7 +13,7 @@ const centerGeometry = (options, object) => {
|
|
|
15
13
|
}
|
|
16
14
|
const { axes, relativeTo } = Object.assign({}, defaults, options)
|
|
17
15
|
|
|
18
|
-
const bounds =
|
|
16
|
+
const bounds = measureAggregateBoundingBox(object)
|
|
19
17
|
const offset = [0, 0, 0]
|
|
20
18
|
if (axes[0]) offset[0] = relativeTo[0] - (bounds[0][0] + ((bounds[1][0] - bounds[0][0]) / 2))
|
|
21
19
|
if (axes[1]) offset[1] = relativeTo[1] - (bounds[0][1] + ((bounds[1][1] - bounds[0][1]) / 2))
|
|
@@ -25,7 +23,7 @@ const centerGeometry = (options, object) => {
|
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
25
|
* Center the given objects using the given options.
|
|
28
|
-
* @param {
|
|
26
|
+
* @param {object} options - options for centering
|
|
29
27
|
* @param {Array} [options.axes=[true,true,true]] - axis of which to center, true or false
|
|
30
28
|
* @param {Array} [options.relativeTo=[0,0,0]] - relative point of which to center the objects
|
|
31
29
|
* @param {...Object} objects - the objects to center
|
|
@@ -35,7 +33,7 @@ const centerGeometry = (options, object) => {
|
|
|
35
33
|
* @example
|
|
36
34
|
* let myshape = center({axes: [true,false,false]}, sphere()) // center about the X axis
|
|
37
35
|
*/
|
|
38
|
-
const center = (options, ...objects) => {
|
|
36
|
+
export const center = (options, ...objects) => {
|
|
39
37
|
const defaults = {
|
|
40
38
|
axes: [true, true, true],
|
|
41
39
|
relativeTo: [0, 0, 0]
|
|
@@ -43,8 +41,6 @@ const center = (options, ...objects) => {
|
|
|
43
41
|
}
|
|
44
42
|
const { axes, relativeTo } = Object.assign({}, defaults, options)
|
|
45
43
|
|
|
46
|
-
objects = flatten(objects)
|
|
47
|
-
if (objects.length === 0) throw new Error('wrong number of arguments')
|
|
48
44
|
if (relativeTo.length !== 3) throw new Error('relativeTo must be an array of length 3')
|
|
49
45
|
|
|
50
46
|
options = { axes, relativeTo }
|
|
@@ -53,6 +49,7 @@ const center = (options, ...objects) => {
|
|
|
53
49
|
if (path2.isA(object)) return centerGeometry(options, object)
|
|
54
50
|
if (geom2.isA(object)) return centerGeometry(options, object)
|
|
55
51
|
if (geom3.isA(object)) return centerGeometry(options, object)
|
|
52
|
+
if (Array.isArray(object)) return centerGeometry(options, object)
|
|
56
53
|
return object
|
|
57
54
|
})
|
|
58
55
|
return results.length === 1 ? results[0] : results
|
|
@@ -64,7 +61,7 @@ const center = (options, ...objects) => {
|
|
|
64
61
|
* @return {Object|Array} the centered object, or a list of centered objects
|
|
65
62
|
* @alias module:modeling/transforms.centerX
|
|
66
63
|
*/
|
|
67
|
-
const centerX = (...objects) => center({ axes: [true, false, false] }, objects)
|
|
64
|
+
export const centerX = (...objects) => center({ axes: [true, false, false] }, ...objects)
|
|
68
65
|
|
|
69
66
|
/**
|
|
70
67
|
* Center the given objects about the Y axis.
|
|
@@ -72,7 +69,7 @@ const centerX = (...objects) => center({ axes: [true, false, false] }, objects)
|
|
|
72
69
|
* @return {Object|Array} the centered object, or a list of centered objects
|
|
73
70
|
* @alias module:modeling/transforms.centerY
|
|
74
71
|
*/
|
|
75
|
-
const centerY = (...objects) => center({ axes: [false, true, false] }, objects)
|
|
72
|
+
export const centerY = (...objects) => center({ axes: [false, true, false] }, ...objects)
|
|
76
73
|
|
|
77
74
|
/**
|
|
78
75
|
* Center the given objects about the Z axis.
|
|
@@ -80,11 +77,4 @@ const centerY = (...objects) => center({ axes: [false, true, false] }, objects)
|
|
|
80
77
|
* @return {Object|Array} the centered object, or a list of centered objects
|
|
81
78
|
* @alias module:modeling/transforms.centerZ
|
|
82
79
|
*/
|
|
83
|
-
const centerZ = (...objects) => center({ axes: [false, false, true] }, objects)
|
|
84
|
-
|
|
85
|
-
module.exports = {
|
|
86
|
-
center,
|
|
87
|
-
centerX,
|
|
88
|
-
centerY,
|
|
89
|
-
centerZ
|
|
90
|
-
}
|
|
80
|
+
export const centerZ = (...objects) => center({ axes: [false, false, true] }, ...objects)
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import test from 'ava'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { comparePoints, comparePolygonsAsPoints } from '../../../test/helpers/index.js'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { geom2, geom3, path2 } from '../../geometries/index.js'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { measureArea, measureAggregateBoundingBox, measureVolume } from '../../measurements/index.js'
|
|
8
|
+
|
|
9
|
+
import { square } from '../../primitives/index.js'
|
|
10
|
+
|
|
11
|
+
import { center, centerX, centerY, centerZ } from './index.js'
|
|
8
12
|
|
|
9
13
|
test('center: centering of a path2 produces expected changes to points', (t) => {
|
|
10
14
|
const geometry = path2.fromPoints({}, [[5, 0], [0, 3], [-1, 0]])
|
|
@@ -23,18 +27,20 @@ test('center: centering of a path2 produces expected changes to points', (t) =>
|
|
|
23
27
|
})
|
|
24
28
|
|
|
25
29
|
test('center: centering of a geom2 produces expected changes to points', (t) => {
|
|
26
|
-
const geometry = geom2.
|
|
30
|
+
const geometry = geom2.create([[[0, 0], [10, 0], [0, 10]]])
|
|
27
31
|
|
|
28
32
|
// center about Y
|
|
29
33
|
let centered = center({ axes: [false, true, false] }, geometry)
|
|
30
34
|
let pts = geom2.toPoints(centered)
|
|
31
35
|
const exp = [[0, -5], [10, -5], [0, 5]]
|
|
32
36
|
t.notThrows(() => geom2.validate(centered))
|
|
37
|
+
t.is(measureArea(centered), measureArea(geometry))
|
|
33
38
|
t.true(comparePoints(pts, exp))
|
|
34
39
|
|
|
35
40
|
centered = centerY(geometry)
|
|
36
41
|
pts = geom2.toPoints(centered)
|
|
37
42
|
t.notThrows(() => geom2.validate(centered))
|
|
43
|
+
t.is(measureArea(centered), measureArea(geometry))
|
|
38
44
|
t.true(comparePoints(pts, exp))
|
|
39
45
|
})
|
|
40
46
|
|
|
@@ -61,11 +67,13 @@ test('center: centering of a geom3 produces expected changes to polygons', (t) =
|
|
|
61
67
|
[[-5, -7, 18], [5, -7, 18], [5, 13, 18], [-5, 13, 18]]
|
|
62
68
|
]
|
|
63
69
|
t.notThrows(() => geom3.validate(centered))
|
|
70
|
+
t.is(measureVolume(centered), measureVolume(geometry))
|
|
64
71
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
65
72
|
|
|
66
73
|
centered = centerX(geometry)
|
|
67
74
|
pts = geom3.toPoints(centered)
|
|
68
75
|
t.notThrows(() => geom3.validate(centered))
|
|
76
|
+
t.is(measureVolume(centered), measureVolume(geometry))
|
|
69
77
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
70
78
|
|
|
71
79
|
// center about Y
|
|
@@ -80,11 +88,13 @@ test('center: centering of a geom3 produces expected changes to polygons', (t) =
|
|
|
80
88
|
[[-2, -10, 18], [8, -10, 18], [8, 10, 18], [-2, 10, 18]]
|
|
81
89
|
]
|
|
82
90
|
t.notThrows(() => geom3.validate(centered))
|
|
91
|
+
t.is(measureVolume(centered), measureVolume(geometry))
|
|
83
92
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
84
93
|
|
|
85
94
|
centered = centerY(geometry)
|
|
86
95
|
pts = geom3.toPoints(centered)
|
|
87
96
|
t.notThrows(() => geom3.validate(centered))
|
|
97
|
+
t.is(measureVolume(centered), measureVolume(geometry))
|
|
88
98
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
89
99
|
|
|
90
100
|
// center about Z
|
|
@@ -99,18 +109,20 @@ test('center: centering of a geom3 produces expected changes to polygons', (t) =
|
|
|
99
109
|
[[-2, -7, 15], [8, -7, 15], [8, 13, 15], [-2, 13, 15]]
|
|
100
110
|
]
|
|
101
111
|
t.notThrows(() => geom3.validate(centered))
|
|
112
|
+
t.is(measureVolume(centered), measureVolume(geometry))
|
|
102
113
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
103
114
|
|
|
104
115
|
centered = centerZ(geometry)
|
|
105
116
|
pts = geom3.toPoints(centered)
|
|
106
117
|
t.notThrows(() => geom3.validate(centered))
|
|
118
|
+
t.is(measureVolume(centered), measureVolume(geometry))
|
|
107
119
|
t.true(comparePolygonsAsPoints(pts, exp))
|
|
108
120
|
})
|
|
109
121
|
|
|
110
122
|
test('center: centering of multiple objects produces expected changes', (t) => {
|
|
111
123
|
const junk = 'hello'
|
|
112
124
|
const geometry1 = path2.fromPoints({}, [[-5, 5], [5, 5], [-5, -5], [10, -5]])
|
|
113
|
-
const geometry2 = geom2.
|
|
125
|
+
const geometry2 = geom2.create([[[-5, -5], [0, 5], [10, -5]]])
|
|
114
126
|
|
|
115
127
|
const centered = center({ axes: [true, true, false], relativeTo: [10, 15, 0] }, junk, geometry1, geometry2)
|
|
116
128
|
|
|
@@ -126,3 +138,19 @@ test('center: centering of multiple objects produces expected changes', (t) => {
|
|
|
126
138
|
t.notThrows(() => geom2.validate(centered[2]))
|
|
127
139
|
t.true(comparePoints(pts2, exp2))
|
|
128
140
|
})
|
|
141
|
+
|
|
142
|
+
test('center multiple separate', (t) => {
|
|
143
|
+
const square1 = square({ size: 4, center: [10, 10] })
|
|
144
|
+
const square2 = square({ size: 6, center: [-10, -10] })
|
|
145
|
+
const obs = center({}, square1, square2)
|
|
146
|
+
t.notThrows(() => obs.map(geom2.validate))
|
|
147
|
+
t.deepEqual([[-3, -3, 0], [3, 3, 0]], measureAggregateBoundingBox(obs))
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
test('center multiple grouped', (t) => {
|
|
151
|
+
const square1 = square({ size: 4, center: [10, 10] })
|
|
152
|
+
const square2 = square({ size: 6, center: [-10, -10] })
|
|
153
|
+
const obs = center({}, [square1, square2])
|
|
154
|
+
t.notThrows(() => obs.map(geom2.validate))
|
|
155
|
+
t.deepEqual([[-12.5, -12.5, 0], [12.5, 12.5, 0]], measureAggregateBoundingBox(obs))
|
|
156
|
+
})
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export * from './center'
|
|
3
|
-
export * from './mirror'
|
|
4
|
-
export * from './rotate'
|
|
5
|
-
export * from './scale'
|
|
6
|
-
export * from './transform'
|
|
7
|
-
export * from './translate'
|
|
8
|
-
|
|
9
|
-
export as namespace transforms
|
|
1
|
+
export { align, AlignOptions } from './align.js'
|
|
2
|
+
export * from './center.js'
|
|
3
|
+
export * from './mirror.js'
|
|
4
|
+
export * from './rotate.js'
|
|
5
|
+
export * from './scale.js'
|
|
6
|
+
export * from './transform.js'
|
|
7
|
+
export * from './translate.js'
|
|
@@ -3,35 +3,14 @@
|
|
|
3
3
|
* In all cases, the function returns the results, and never changes the original shapes.
|
|
4
4
|
* @module modeling/transforms
|
|
5
5
|
* @example
|
|
6
|
-
*
|
|
6
|
+
* import { center, rotateX, translate } from '@jscad/modeling'
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
align: require('./align'),
|
|
8
|
+
export { align } from './align.js'
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export { center, centerX, centerY, centerZ } from './center.js'
|
|
11
|
+
export { mirror, mirrorX, mirrorY, mirrorZ } from './mirror.js'
|
|
12
|
+
export { rotate, rotateX, rotateY, rotateZ } from './rotate.js'
|
|
13
|
+
export { scale, scaleX, scaleY, scaleZ } from './scale.js'
|
|
14
|
+
export { translate, translateX, translateY, translateZ } from './translate.js'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
mirrorX: require('./mirror').mirrorX,
|
|
18
|
-
mirrorY: require('./mirror').mirrorY,
|
|
19
|
-
mirrorZ: require('./mirror').mirrorZ,
|
|
20
|
-
|
|
21
|
-
rotate: require('./rotate').rotate,
|
|
22
|
-
rotateX: require('./rotate').rotateX,
|
|
23
|
-
rotateY: require('./rotate').rotateY,
|
|
24
|
-
rotateZ: require('./rotate').rotateZ,
|
|
25
|
-
|
|
26
|
-
scale: require('./scale').scale,
|
|
27
|
-
scaleX: require('./scale').scaleX,
|
|
28
|
-
scaleY: require('./scale').scaleY,
|
|
29
|
-
scaleZ: require('./scale').scaleZ,
|
|
30
|
-
|
|
31
|
-
transform: require('./transform'),
|
|
32
|
-
|
|
33
|
-
translate: require('./translate').translate,
|
|
34
|
-
translateX: require('./translate').translateX,
|
|
35
|
-
translateY: require('./translate').translateY,
|
|
36
|
-
translateZ: require('./translate').translateZ
|
|
37
|
-
}
|
|
16
|
+
export { transform } from './transform.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Geometry } from '../../geometries/types'
|
|
2
|
-
import { Vec3 } from '../../maths/types'
|
|
3
|
-
import RecursiveArray from '../../utils/recursiveArray'
|
|
1
|
+
import type { Geometry } from '../../geometries/types.d.ts'
|
|
2
|
+
import type { Vec3 } from '../../maths/types.d.ts'
|
|
3
|
+
import type { RecursiveArray } from '../../utils/recursiveArray.d.ts'
|
|
4
4
|
|
|
5
5
|
export interface MirrorOptions {
|
|
6
6
|
origin?: Vec3
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import * as mat4 from '../../maths/mat4/index.js'
|
|
2
|
+
import * as plane from '../../maths/plane/index.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const geom2 = require('../../geometries/geom2')
|
|
7
|
-
const geom3 = require('../../geometries/geom3')
|
|
8
|
-
const path2 = require('../../geometries/path2')
|
|
4
|
+
import * as geom2 from '../../geometries/geom2/index.js'
|
|
5
|
+
import * as geom3 from '../../geometries/geom3/index.js'
|
|
6
|
+
import * as path2 from '../../geometries/path2/index.js'
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* Mirror the given objects using the given options.
|
|
12
|
-
* @param {
|
|
10
|
+
* @param {object} options - options for mirror
|
|
13
11
|
* @param {Array} [options.origin=[0,0,0]] - the origin of the plane
|
|
14
12
|
* @param {Array} [options.normal=[0,0,1]] - the normal vector of the plane
|
|
15
13
|
* @param {...Object} objects - the objects to mirror
|
|
@@ -19,16 +17,13 @@ const path2 = require('../../geometries/path2')
|
|
|
19
17
|
* @example
|
|
20
18
|
* let myshape = mirror({normal: [0,0,10]}, cube({center: [0,0,15], radius: [20, 25, 5]}))
|
|
21
19
|
*/
|
|
22
|
-
const mirror = (options, ...objects) => {
|
|
20
|
+
export const mirror = (options, ...objects) => {
|
|
23
21
|
const defaults = {
|
|
24
22
|
origin: [0, 0, 0],
|
|
25
23
|
normal: [0, 0, 1] // Z axis
|
|
26
24
|
}
|
|
27
25
|
const { origin, normal } = Object.assign({}, defaults, options)
|
|
28
26
|
|
|
29
|
-
objects = flatten(objects)
|
|
30
|
-
if (objects.length === 0) throw new Error('wrong number of arguments')
|
|
31
|
-
|
|
32
27
|
const planeOfMirror = plane.fromNormalAndPoint(plane.create(), normal, origin)
|
|
33
28
|
// verify the plane, i.e. check that the given normal was valid
|
|
34
29
|
if (Number.isNaN(planeOfMirror[0])) {
|
|
@@ -41,6 +36,8 @@ const mirror = (options, ...objects) => {
|
|
|
41
36
|
if (path2.isA(object)) return path2.transform(matrix, object)
|
|
42
37
|
if (geom2.isA(object)) return geom2.transform(matrix, object)
|
|
43
38
|
if (geom3.isA(object)) return geom3.transform(matrix, object)
|
|
39
|
+
// handle recursive arrays
|
|
40
|
+
if (Array.isArray(object)) return mirror(options, ...object)
|
|
44
41
|
return object
|
|
45
42
|
})
|
|
46
43
|
return results.length === 1 ? results[0] : results
|
|
@@ -52,7 +49,7 @@ const mirror = (options, ...objects) => {
|
|
|
52
49
|
* @return {Object|Array} the mirrored object, or a list of mirrored objects
|
|
53
50
|
* @alias module:modeling/transforms.mirrorX
|
|
54
51
|
*/
|
|
55
|
-
const mirrorX = (...objects) => mirror({ normal: [1, 0, 0] }, objects)
|
|
52
|
+
export const mirrorX = (...objects) => mirror({ normal: [1, 0, 0] }, ...objects)
|
|
56
53
|
|
|
57
54
|
/**
|
|
58
55
|
* Mirror the given objects about the Y axis.
|
|
@@ -60,7 +57,7 @@ const mirrorX = (...objects) => mirror({ normal: [1, 0, 0] }, objects)
|
|
|
60
57
|
* @return {Object|Array} the mirrored object, or a list of mirrored objects
|
|
61
58
|
* @alias module:modeling/transforms.mirrorY
|
|
62
59
|
*/
|
|
63
|
-
const mirrorY = (...objects) => mirror({ normal: [0, 1, 0] }, objects)
|
|
60
|
+
export const mirrorY = (...objects) => mirror({ normal: [0, 1, 0] }, ...objects)
|
|
64
61
|
|
|
65
62
|
/**
|
|
66
63
|
* Mirror the given objects about the Z axis.
|
|
@@ -68,11 +65,4 @@ const mirrorY = (...objects) => mirror({ normal: [0, 1, 0] }, objects)
|
|
|
68
65
|
* @return {Object|Array} the mirrored object, or a list of mirrored objects
|
|
69
66
|
* @alias module:modeling/transforms.mirrorZ
|
|
70
67
|
*/
|
|
71
|
-
const mirrorZ = (...objects) => mirror({ normal: [0, 0, 1] }, objects)
|
|
72
|
-
|
|
73
|
-
module.exports = {
|
|
74
|
-
mirror,
|
|
75
|
-
mirrorX,
|
|
76
|
-
mirrorY,
|
|
77
|
-
mirrorZ
|
|
78
|
-
}
|
|
68
|
+
export const mirrorZ = (...objects) => mirror({ normal: [0, 0, 1] }, ...objects)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import test from 'ava'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { comparePoints, comparePolygonsAsPoints } from '../../../test/helpers/index.js'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { geom2, geom3, path2 } from '../../geometries/index.js'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { measureArea, measureVolume } from '../../measurements/index.js'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
import { mirror, mirrorX, mirrorY, mirrorZ } from './index.js'
|
|
10
10
|
|
|
11
11
|
test('mirror: mirroring of path2 about X/Y produces expected changes to points', (t) => {
|
|
12
12
|
const geometry = path2.fromPoints({}, [[-5, 5], [5, 5], [-5, -5], [10, -5]])
|
|
@@ -37,12 +37,12 @@ test('mirror: mirroring of path2 about X/Y produces expected changes to points',
|
|
|
37
37
|
})
|
|
38
38
|
|
|
39
39
|
test('mirror: mirroring of geom2 about X/Y produces expected changes to points', (t) => {
|
|
40
|
-
const geometry = geom2.
|
|
40
|
+
const geometry = geom2.create([[[-5, -5], [0, 5], [10, -5]]])
|
|
41
41
|
|
|
42
42
|
// mirror about X
|
|
43
43
|
let mirrored = mirror({ normal: [1, 0, 0] }, geometry)
|
|
44
44
|
let obs = geom2.toPoints(mirrored)
|
|
45
|
-
let exp = [[
|
|
45
|
+
let exp = [[-10, -5], [0, 5], [5, -5]]
|
|
46
46
|
t.notThrows(() => geom2.validate(mirrored))
|
|
47
47
|
t.is(measureArea(mirrored), measureArea(geometry))
|
|
48
48
|
t.true(comparePoints(obs, exp))
|
|
@@ -56,7 +56,7 @@ test('mirror: mirroring of geom2 about X/Y produces expected changes to points',
|
|
|
56
56
|
// mirror about Y
|
|
57
57
|
mirrored = mirror({ normal: [0, 1, 0] }, geometry)
|
|
58
58
|
obs = geom2.toPoints(mirrored)
|
|
59
|
-
exp = [[
|
|
59
|
+
exp = [[10, 5], [0, -5], [-5, 5]]
|
|
60
60
|
t.notThrows(() => geom2.validate(mirrored))
|
|
61
61
|
t.is(measureArea(mirrored), measureArea(geometry))
|
|
62
62
|
t.true(comparePoints(obs, exp))
|
|
@@ -91,12 +91,14 @@ test('mirror: mirroring of geom3 about X/Y/Z produces expected changes to polygo
|
|
|
91
91
|
[[2, 13, 18], [-8, 13, 18], [-8, -7, 18], [2, -7, 18]]
|
|
92
92
|
]
|
|
93
93
|
t.notThrows(() => geom3.validate(mirrored))
|
|
94
|
+
t.is(measureVolume(mirrored), measureVolume(geometry))
|
|
94
95
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
95
96
|
t.deepEqual(obs, exp)
|
|
96
97
|
|
|
97
98
|
mirrored = mirrorX(geometry)
|
|
98
99
|
obs = geom3.toPoints(mirrored)
|
|
99
100
|
t.notThrows(() => geom3.validate(mirrored))
|
|
101
|
+
t.is(measureVolume(mirrored), measureVolume(geometry))
|
|
100
102
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
101
103
|
|
|
102
104
|
// mirror about Y
|
|
@@ -111,11 +113,13 @@ test('mirror: mirroring of geom3 about X/Y/Z produces expected changes to polygo
|
|
|
111
113
|
[[-2, -13, 18], [8, -13, 18], [8, 7, 18], [-2, 7, 18]]
|
|
112
114
|
]
|
|
113
115
|
t.notThrows(() => geom3.validate(mirrored))
|
|
116
|
+
t.is(measureVolume(mirrored), measureVolume(geometry))
|
|
114
117
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
115
118
|
|
|
116
119
|
mirrored = mirrorY(geometry)
|
|
117
120
|
obs = geom3.toPoints(mirrored)
|
|
118
121
|
t.notThrows(() => geom3.validate(mirrored))
|
|
122
|
+
t.is(measureVolume(mirrored), measureVolume(geometry))
|
|
119
123
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
120
124
|
|
|
121
125
|
// mirror about Z
|
|
@@ -130,18 +134,20 @@ test('mirror: mirroring of geom3 about X/Y/Z produces expected changes to polygo
|
|
|
130
134
|
[[-2, 13, -18], [8, 13, -18], [8, -7, -18], [-2, -7, -18]]
|
|
131
135
|
]
|
|
132
136
|
t.notThrows(() => geom3.validate(mirrored))
|
|
137
|
+
t.is(measureVolume(mirrored), measureVolume(geometry))
|
|
133
138
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
134
139
|
|
|
135
140
|
mirrored = mirrorZ(geometry)
|
|
136
141
|
obs = geom3.toPoints(mirrored)
|
|
137
142
|
t.notThrows(() => geom3.validate(mirrored))
|
|
143
|
+
t.is(measureVolume(mirrored), measureVolume(geometry))
|
|
138
144
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
139
145
|
})
|
|
140
146
|
|
|
141
147
|
test('mirror: mirroring of multiple objects produces an array of mirrored objects', (t) => {
|
|
142
148
|
const junk = 'hello'
|
|
143
149
|
const geometry1 = path2.fromPoints({}, [[-5, 5], [5, 5], [-5, -5], [10, -5]])
|
|
144
|
-
const geometry2 = geom2.
|
|
150
|
+
const geometry2 = geom2.create([[[-5, -5], [0, 5], [10, -5]]])
|
|
145
151
|
|
|
146
152
|
const mirrored = mirror({ normal: [0, 1, 0] }, junk, geometry1, geometry2)
|
|
147
153
|
t.is(mirrored[0], junk)
|
|
@@ -152,7 +158,7 @@ test('mirror: mirroring of multiple objects produces an array of mirrored object
|
|
|
152
158
|
t.true(comparePoints(obs, exp))
|
|
153
159
|
|
|
154
160
|
obs = geom2.toPoints(mirrored[2])
|
|
155
|
-
exp = [[
|
|
161
|
+
exp = [[10, 5], [0, -5], [-5, 5]]
|
|
156
162
|
t.notThrows(() => geom2.validate(mirrored[2]))
|
|
157
163
|
t.true(comparePoints(obs, exp))
|
|
158
164
|
})
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Geometry } from '../../geometries/types'
|
|
2
|
-
import {
|
|
3
|
-
import RecursiveArray from '../../utils/recursiveArray'
|
|
1
|
+
import type { Geometry } from '../../geometries/types.d.ts'
|
|
2
|
+
import type { Vec } from '../../maths/types.d.ts'
|
|
3
|
+
import type { RecursiveArray } from '../../utils/recursiveArray.d.ts'
|
|
4
4
|
|
|
5
|
-
export function rotate<T extends Geometry>(angles:
|
|
6
|
-
export function rotate<T extends Geometry>(angles:
|
|
7
|
-
export function rotate(angles:
|
|
5
|
+
export function rotate<T extends Geometry>(angles: Vec, geometry: T): T
|
|
6
|
+
export function rotate<T extends Geometry>(angles: Vec, ...geometries: RecursiveArray<T>): Array<T>
|
|
7
|
+
export function rotate(angles: Vec, ...geometries: RecursiveArray<Geometry>): Array<Geometry>
|
|
8
8
|
|
|
9
9
|
export function rotateX<T extends Geometry>(angle: number, geometry: T): T
|
|
10
10
|
export function rotateX<T extends Geometry>(angle: number, ...geometries: RecursiveArray<T>): Array<T>
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import * as mat4 from '../../maths/mat4/index.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const geom3 = require('../../geometries/geom3')
|
|
7
|
-
const path2 = require('../../geometries/path2')
|
|
3
|
+
import * as geom2 from '../../geometries/geom2/index.js'
|
|
4
|
+
import * as geom3 from '../../geometries/geom3/index.js'
|
|
5
|
+
import * as path2 from '../../geometries/path2/index.js'
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
* Rotate the given objects using the given options.
|
|
@@ -14,14 +12,11 @@ const path2 = require('../../geometries/path2')
|
|
|
14
12
|
* @alias module:modeling/transforms.rotate
|
|
15
13
|
*
|
|
16
14
|
* @example
|
|
17
|
-
* const
|
|
15
|
+
* const newSphere = rotate([TAU / 8, 0, 0], sphere())
|
|
18
16
|
*/
|
|
19
|
-
const rotate = (angles, ...objects) => {
|
|
17
|
+
export const rotate = (angles, ...objects) => {
|
|
20
18
|
if (!Array.isArray(angles)) throw new Error('angles must be an array')
|
|
21
19
|
|
|
22
|
-
objects = flatten(objects)
|
|
23
|
-
if (objects.length === 0) throw new Error('wrong number of arguments')
|
|
24
|
-
|
|
25
20
|
// adjust the angles if necessary
|
|
26
21
|
angles = angles.slice() // don't modify the original
|
|
27
22
|
while (angles.length < 3) angles.push(0)
|
|
@@ -36,6 +31,8 @@ const rotate = (angles, ...objects) => {
|
|
|
36
31
|
if (path2.isA(object)) return path2.transform(matrix, object)
|
|
37
32
|
if (geom2.isA(object)) return geom2.transform(matrix, object)
|
|
38
33
|
if (geom3.isA(object)) return geom3.transform(matrix, object)
|
|
34
|
+
// handle recursive arrays
|
|
35
|
+
if (Array.isArray(object)) return rotate(angles, ...object)
|
|
39
36
|
return object
|
|
40
37
|
})
|
|
41
38
|
return results.length === 1 ? results[0] : results
|
|
@@ -43,34 +40,27 @@ const rotate = (angles, ...objects) => {
|
|
|
43
40
|
|
|
44
41
|
/**
|
|
45
42
|
* Rotate the given objects about the X axis, using the given options.
|
|
46
|
-
* @param {
|
|
43
|
+
* @param {number} angle - angle (RADIANS) of rotations about X
|
|
47
44
|
* @param {...Object} objects - the objects to rotate
|
|
48
45
|
* @return {Object|Array} the rotated object, or a list of rotated objects
|
|
49
46
|
* @alias module:modeling/transforms.rotateX
|
|
50
47
|
*/
|
|
51
|
-
const rotateX = (angle, ...objects) => rotate([angle, 0, 0], objects)
|
|
48
|
+
export const rotateX = (angle, ...objects) => rotate([angle, 0, 0], ...objects)
|
|
52
49
|
|
|
53
50
|
/**
|
|
54
51
|
* Rotate the given objects about the Y axis, using the given options.
|
|
55
|
-
* @param {
|
|
52
|
+
* @param {number} angle - angle (RADIANS) of rotations about Y
|
|
56
53
|
* @param {...Object} objects - the objects to rotate
|
|
57
54
|
* @return {Object|Array} the rotated object, or a list of rotated objects
|
|
58
55
|
* @alias module:modeling/transforms.rotateY
|
|
59
56
|
*/
|
|
60
|
-
const rotateY = (angle, ...objects) => rotate([0, angle, 0], objects)
|
|
57
|
+
export const rotateY = (angle, ...objects) => rotate([0, angle, 0], ...objects)
|
|
61
58
|
|
|
62
59
|
/**
|
|
63
60
|
* Rotate the given objects about the Z axis, using the given options.
|
|
64
|
-
* @param {
|
|
61
|
+
* @param {number} angle - angle (RADIANS) of rotations about Z
|
|
65
62
|
* @param {...Object} objects - the objects to rotate
|
|
66
63
|
* @return {Object|Array} the rotated object, or a list of rotated objects
|
|
67
64
|
* @alias module:modeling/transforms.rotateZ
|
|
68
65
|
*/
|
|
69
|
-
const rotateZ = (angle, ...objects) => rotate([0, 0, angle], objects)
|
|
70
|
-
|
|
71
|
-
module.exports = {
|
|
72
|
-
rotate,
|
|
73
|
-
rotateX,
|
|
74
|
-
rotateY,
|
|
75
|
-
rotateZ
|
|
76
|
-
}
|
|
66
|
+
export const rotateZ = (angle, ...objects) => rotate([0, 0, angle], ...objects)
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import test from 'ava'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { TAU } from '../../maths/constants.js'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
import { geom2, geom3, path2 } from '../../geometries/index.js'
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
import { measureArea, measureVolume } from '../../measurements/index.js'
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
import { rotate, rotateX, rotateY, rotateZ } from './index.js'
|
|
10
|
+
|
|
11
|
+
import { comparePoints, comparePolygonsAsPoints } from '../../../test/helpers/index.js'
|
|
10
12
|
|
|
11
13
|
test('rotate: rotating of a path2 produces expected changes to points', (t) => {
|
|
12
14
|
const geometry = path2.fromPoints({}, [[1, 0], [0, 1], [-1, 0]])
|
|
@@ -28,7 +30,7 @@ test('rotate: rotating of a path2 produces expected changes to points', (t) => {
|
|
|
28
30
|
})
|
|
29
31
|
|
|
30
32
|
test('rotate: rotating of a geom2 produces expected changes to points', (t) => {
|
|
31
|
-
const geometry = geom2.
|
|
33
|
+
const geometry = geom2.create([[[0, 0], [1, 0], [0, 1]]])
|
|
32
34
|
|
|
33
35
|
// rotate about Z
|
|
34
36
|
let rotated = rotate([0, 0, -TAU / 4], geometry)
|
|
@@ -39,11 +41,13 @@ test('rotate: rotating of a geom2 produces expected changes to points', (t) => {
|
|
|
39
41
|
new Float32Array([1, 0])
|
|
40
42
|
]
|
|
41
43
|
t.notThrows(() => geom2.validate(rotated))
|
|
44
|
+
t.is(measureArea(rotated), measureArea(geometry))
|
|
42
45
|
t.true(comparePoints(obs, exp))
|
|
43
46
|
|
|
44
47
|
rotated = rotateZ(-TAU / 4, geometry)
|
|
45
48
|
obs = geom2.toPoints(rotated)
|
|
46
49
|
t.notThrows(() => geom2.validate(rotated))
|
|
50
|
+
t.is(measureArea(rotated), measureArea(geometry))
|
|
47
51
|
t.true(comparePoints(obs, exp))
|
|
48
52
|
})
|
|
49
53
|
|
|
@@ -76,11 +80,13 @@ test('rotate: rotating of a geom3 produces expected changes to polygons', (t) =>
|
|
|
76
80
|
[8, -18, 13.000000000000002], [-2, -18, 13.000000000000002]]
|
|
77
81
|
]
|
|
78
82
|
t.notThrows(() => geom3.validate(rotated))
|
|
83
|
+
t.is(measureVolume(rotated), measureVolume(geometry))
|
|
79
84
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
80
85
|
|
|
81
86
|
rotated = rotateX(TAU / 4, geometry)
|
|
82
87
|
obs = geom3.toPoints(rotated)
|
|
83
88
|
t.notThrows(() => geom3.validate(rotated))
|
|
89
|
+
t.is(measureVolume(rotated), measureVolume(geometry))
|
|
84
90
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
85
91
|
|
|
86
92
|
// rotate about Y
|
|
@@ -101,10 +107,13 @@ test('rotate: rotating of a geom3 produces expected changes to polygons', (t) =>
|
|
|
101
107
|
[-18, 13, 8.000000000000002], [-18, 13, -1.999999999999999]]
|
|
102
108
|
]
|
|
103
109
|
t.notThrows(() => geom3.validate(rotated))
|
|
110
|
+
t.is(measureVolume(rotated), measureVolume(geometry))
|
|
104
111
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
105
112
|
|
|
106
113
|
rotated = rotateY(-TAU / 4, geometry)
|
|
107
114
|
obs = geom3.toPoints(rotated)
|
|
115
|
+
t.notThrows(() => geom3.validate(rotated))
|
|
116
|
+
t.is(measureVolume(rotated), measureVolume(geometry))
|
|
108
117
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
109
118
|
|
|
110
119
|
// rotate about Z
|
|
@@ -125,18 +134,20 @@ test('rotate: rotating of a geom3 produces expected changes to polygons', (t) =>
|
|
|
125
134
|
[-8.000000000000002, -12.999999999999998, 18], [1.9999999999999984, -13, 18]]
|
|
126
135
|
]
|
|
127
136
|
t.notThrows(() => geom3.validate(rotated))
|
|
137
|
+
t.is(measureVolume(rotated), measureVolume(geometry))
|
|
128
138
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
129
139
|
|
|
130
140
|
rotated = rotateZ(TAU / 2, geometry)
|
|
131
141
|
obs = geom3.toPoints(rotated)
|
|
132
142
|
t.notThrows(() => geom3.validate(rotated))
|
|
143
|
+
t.is(measureVolume(rotated), measureVolume(geometry))
|
|
133
144
|
t.true(comparePolygonsAsPoints(obs, exp))
|
|
134
145
|
})
|
|
135
146
|
|
|
136
147
|
test('rotate: rotating of multiple objects produces expected changes', (t) => {
|
|
137
148
|
const junk = 'hello'
|
|
138
149
|
const geometry1 = path2.fromPoints({}, [[-5, 5], [5, 5], [-5, -5], [10, -5]])
|
|
139
|
-
const geometry2 = geom2.
|
|
150
|
+
const geometry2 = geom2.create([[[-5, -5], [0, 5], [10, -5]]])
|
|
140
151
|
|
|
141
152
|
const rotated = rotate([0, 0, TAU / 4], junk, geometry1, geometry2)
|
|
142
153
|
|