@jbroll/jscad-modeling 2.12.7
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/.claude/settings.local.json +30 -0
- package/CHANGELOG.md +888 -0
- package/CLAUDE.md +135 -0
- package/README.md +99 -0
- package/benchmarks/booleans.bench.js +100 -0
- package/benchmarks/extrusions.bench.js +124 -0
- package/benchmarks/measurements.bench.js +123 -0
- package/benchmarks/run.js +145 -0
- package/benchmarks/transforms.bench.js +106 -0
- package/benchmarks/utils.bench.js +89 -0
- package/dist/jscad-modeling.min.js +1214 -0
- package/package.json +66 -0
- package/src/colors/colorNameToRgb.d.ts +5 -0
- package/src/colors/colorNameToRgb.js +14 -0
- package/src/colors/colorNameToRgb.test.js +14 -0
- package/src/colors/colorize.d.ts +14 -0
- package/src/colors/colorize.js +65 -0
- package/src/colors/colorize.test.js +72 -0
- package/src/colors/cssColors.d.ts +149 -0
- package/src/colors/cssColors.js +176 -0
- package/src/colors/hexToRgb.d.ts +5 -0
- package/src/colors/hexToRgb.js +26 -0
- package/src/colors/hexToRgb.test.js +37 -0
- package/src/colors/hslToRgb.d.ts +8 -0
- package/src/colors/hslToRgb.js +44 -0
- package/src/colors/hslToRgb.test.js +37 -0
- package/src/colors/hsvToRgb.d.ts +8 -0
- package/src/colors/hsvToRgb.js +73 -0
- package/src/colors/hsvToRgb.test.js +27 -0
- package/src/colors/hueToColorComponent.d.ts +3 -0
- package/src/colors/hueToColorComponent.js +18 -0
- package/src/colors/index.d.ts +13 -0
- package/src/colors/index.js +19 -0
- package/src/colors/rgbToHex.d.ts +6 -0
- package/src/colors/rgbToHex.js +27 -0
- package/src/colors/rgbToHex.test.js +15 -0
- package/src/colors/rgbToHsl.d.ts +8 -0
- package/src/colors/rgbToHsl.js +53 -0
- package/src/colors/rgbToHsl.test.js +35 -0
- package/src/colors/rgbToHsv.d.ts +8 -0
- package/src/colors/rgbToHsv.js +52 -0
- package/src/colors/rgbToHsv.test.js +40 -0
- package/src/colors/types.d.ts +6 -0
- package/src/connectors/create.js +23 -0
- package/src/connectors/create.test.js +17 -0
- package/src/connectors/extends.js +15 -0
- package/src/connectors/fromPointAxisNormal.js +21 -0
- package/src/connectors/fromPointAxisNormal.test.js +22 -0
- package/src/connectors/index.js +12 -0
- package/src/connectors/normalize.js +20 -0
- package/src/connectors/toString.js +15 -0
- package/src/connectors/transform.js +28 -0
- package/src/connectors/transform.test.js +106 -0
- package/src/connectors/transformationBetween.js +68 -0
- package/src/connectors/transformationBetween.test.js +40 -0
- package/src/curves/bezier/arcLengthToT.d.ts +10 -0
- package/src/curves/bezier/arcLengthToT.js +63 -0
- package/src/curves/bezier/arcLengthToT.test.js +79 -0
- package/src/curves/bezier/create.d.ts +5 -0
- package/src/curves/bezier/create.js +81 -0
- package/src/curves/bezier/create.test.js +60 -0
- package/src/curves/bezier/index.d.ts +9 -0
- package/src/curves/bezier/index.js +13 -0
- package/src/curves/bezier/length.d.ts +5 -0
- package/src/curves/bezier/length.js +18 -0
- package/src/curves/bezier/length.test.js +54 -0
- package/src/curves/bezier/lengths.d.ts +5 -0
- package/src/curves/bezier/lengths.js +56 -0
- package/src/curves/bezier/lengths.test.js +78 -0
- package/src/curves/bezier/tangentAt.d.ts +5 -0
- package/src/curves/bezier/tangentAt.js +45 -0
- package/src/curves/bezier/tangentAt.test.js +63 -0
- package/src/curves/bezier/type.d.ts +9 -0
- package/src/curves/bezier/valueAt.d.ts +5 -0
- package/src/curves/bezier/valueAt.js +44 -0
- package/src/curves/bezier/valueAt.test.js +63 -0
- package/src/curves/index.d.ts +3 -0
- package/src/curves/index.js +9 -0
- package/src/geometries/geom2/applyTransforms.js +26 -0
- package/src/geometries/geom2/applyTransforms.test.js +21 -0
- package/src/geometries/geom2/clone.d.ts +5 -0
- package/src/geometries/geom2/clone.js +9 -0
- package/src/geometries/geom2/clone.test.js +26 -0
- package/src/geometries/geom2/create.d.ts +6 -0
- package/src/geometries/geom2/create.js +26 -0
- package/src/geometries/geom2/create.test.js +20 -0
- package/src/geometries/geom2/fromCompactBinary.d.ts +5 -0
- package/src/geometries/geom2/fromCompactBinary.js +32 -0
- package/src/geometries/geom2/fromPoints.d.ts +6 -0
- package/src/geometries/geom2/fromPoints.js +35 -0
- package/src/geometries/geom2/fromPoints.test.js +22 -0
- package/src/geometries/geom2/fromToCompactBinary.test.js +122 -0
- package/src/geometries/geom2/index.d.ts +16 -0
- package/src/geometries/geom2/index.js +30 -0
- package/src/geometries/geom2/isA.d.ts +5 -0
- package/src/geometries/geom2/isA.js +18 -0
- package/src/geometries/geom2/isA.test.js +19 -0
- package/src/geometries/geom2/reverse.d.ts +5 -0
- package/src/geometries/geom2/reverse.js +22 -0
- package/src/geometries/geom2/reverse.test.js +20 -0
- package/src/geometries/geom2/toCompactBinary.d.ts +5 -0
- package/src/geometries/geom2/toCompactBinary.js +53 -0
- package/src/geometries/geom2/toOutlines.d.ts +6 -0
- package/src/geometries/geom2/toOutlines.js +119 -0
- package/src/geometries/geom2/toOutlines.test.js +122 -0
- package/src/geometries/geom2/toPoints.d.ts +6 -0
- package/src/geometries/geom2/toPoints.js +25 -0
- package/src/geometries/geom2/toPoints.test.js +24 -0
- package/src/geometries/geom2/toSides.d.ts +6 -0
- package/src/geometries/geom2/toSides.js +16 -0
- package/src/geometries/geom2/toString.d.ts +5 -0
- package/src/geometries/geom2/toString.js +24 -0
- package/src/geometries/geom2/transform.d.ts +6 -0
- package/src/geometries/geom2/transform.js +28 -0
- package/src/geometries/geom2/transform.test.js +110 -0
- package/src/geometries/geom2/type.d.ts +11 -0
- package/src/geometries/geom2/validate.d.ts +3 -0
- package/src/geometries/geom2/validate.js +36 -0
- package/src/geometries/geom3/applyTransforms.js +23 -0
- package/src/geometries/geom3/applyTransforms.test.js +28 -0
- package/src/geometries/geom3/clone.d.ts +5 -0
- package/src/geometries/geom3/clone.js +9 -0
- package/src/geometries/geom3/clone.test.js +31 -0
- package/src/geometries/geom3/create.d.ts +6 -0
- package/src/geometries/geom3/create.js +26 -0
- package/src/geometries/geom3/create.test.js +25 -0
- package/src/geometries/geom3/fromCompactBinary.d.ts +5 -0
- package/src/geometries/geom3/fromCompactBinary.js +44 -0
- package/src/geometries/geom3/fromPoints.d.ts +6 -0
- package/src/geometries/geom3/fromPoints.js +28 -0
- package/src/geometries/geom3/fromPoints.test.js +24 -0
- package/src/geometries/geom3/fromPointsConvex.d.ts +6 -0
- package/src/geometries/geom3/fromPointsConvex.js +26 -0
- package/src/geometries/geom3/fromPointsConvex.test.js +31 -0
- package/src/geometries/geom3/fromToCompactBinary.test.js +139 -0
- package/src/geometries/geom3/index.d.ts +16 -0
- package/src/geometries/geom3/index.js +37 -0
- package/src/geometries/geom3/invert.d.ts +5 -0
- package/src/geometries/geom3/invert.js +18 -0
- package/src/geometries/geom3/invert.test.js +31 -0
- package/src/geometries/geom3/isA.d.ts +5 -0
- package/src/geometries/geom3/isA.js +18 -0
- package/src/geometries/geom3/isA.test.js +19 -0
- package/src/geometries/geom3/toCompactBinary.d.ts +5 -0
- package/src/geometries/geom3/toCompactBinary.js +68 -0
- package/src/geometries/geom3/toPoints.d.ts +6 -0
- package/src/geometries/geom3/toPoints.js +18 -0
- package/src/geometries/geom3/toPoints.test.js +19 -0
- package/src/geometries/geom3/toPolygons.d.ts +6 -0
- package/src/geometries/geom3/toPolygons.js +15 -0
- package/src/geometries/geom3/toString.d.ts +5 -0
- package/src/geometries/geom3/toString.js +23 -0
- package/src/geometries/geom3/transform.d.ts +6 -0
- package/src/geometries/geom3/transform.js +20 -0
- package/src/geometries/geom3/transform.test.js +49 -0
- package/src/geometries/geom3/type.d.ts +11 -0
- package/src/geometries/geom3/validate.d.ts +3 -0
- package/src/geometries/geom3/validate.js +62 -0
- package/src/geometries/index.d.ts +7 -0
- package/src/geometries/index.js +21 -0
- package/src/geometries/path2/appendArc.d.ts +15 -0
- package/src/geometries/path2/appendArc.js +142 -0
- package/src/geometries/path2/appendArc.test.js +88 -0
- package/src/geometries/path2/appendBezier.d.ts +11 -0
- package/src/geometries/path2/appendBezier.js +156 -0
- package/src/geometries/path2/appendBezier.test.js +36 -0
- package/src/geometries/path2/appendPoints.d.ts +6 -0
- package/src/geometries/path2/appendPoints.js +15 -0
- package/src/geometries/path2/appendPoints.test.js +35 -0
- package/src/geometries/path2/applyTransforms.js +20 -0
- package/src/geometries/path2/applyTransforms.test.js +28 -0
- package/src/geometries/path2/clone.d.ts +5 -0
- package/src/geometries/path2/clone.js +9 -0
- package/src/geometries/path2/close.d.ts +5 -0
- package/src/geometries/path2/close.js +33 -0
- package/src/geometries/path2/close.test.js +43 -0
- package/src/geometries/path2/concat.d.ts +5 -0
- package/src/geometries/path2/concat.js +36 -0
- package/src/geometries/path2/concat.test.js +35 -0
- package/src/geometries/path2/create.d.ts +6 -0
- package/src/geometries/path2/create.js +30 -0
- package/src/geometries/path2/create.test.js +7 -0
- package/src/geometries/path2/equals.d.ts +5 -0
- package/src/geometries/path2/equals.js +47 -0
- package/src/geometries/path2/equals.test.js +38 -0
- package/src/geometries/path2/fromCompactBinary.d.ts +5 -0
- package/src/geometries/path2/fromCompactBinary.js +33 -0
- package/src/geometries/path2/fromPoints.d.ts +10 -0
- package/src/geometries/path2/fromPoints.js +42 -0
- package/src/geometries/path2/fromPoints.test.js +33 -0
- package/src/geometries/path2/fromToCompactBinary.test.js +114 -0
- package/src/geometries/path2/index.d.ts +20 -0
- package/src/geometries/path2/index.js +35 -0
- package/src/geometries/path2/isA.d.ts +5 -0
- package/src/geometries/path2/isA.js +20 -0
- package/src/geometries/path2/isA.test.js +19 -0
- package/src/geometries/path2/reverse.d.ts +5 -0
- package/src/geometries/path2/reverse.js +20 -0
- package/src/geometries/path2/reverse.test.js +9 -0
- package/src/geometries/path2/toCompactBinary.d.ts +5 -0
- package/src/geometries/path2/toCompactBinary.js +52 -0
- package/src/geometries/path2/toPoints.d.ts +6 -0
- package/src/geometries/path2/toPoints.js +15 -0
- package/src/geometries/path2/toPoints.test.js +13 -0
- package/src/geometries/path2/toString.d.ts +5 -0
- package/src/geometries/path2/toString.js +24 -0
- package/src/geometries/path2/transform.d.ts +6 -0
- package/src/geometries/path2/transform.js +20 -0
- package/src/geometries/path2/transform.test.js +50 -0
- package/src/geometries/path2/type.d.ts +12 -0
- package/src/geometries/path2/validate.d.ts +3 -0
- package/src/geometries/path2/validate.js +41 -0
- package/src/geometries/poly2/arePointsInside.d.ts +6 -0
- package/src/geometries/poly2/arePointsInside.js +83 -0
- package/src/geometries/poly2/arePointsInside.test.js +77 -0
- package/src/geometries/poly2/create.d.ts +6 -0
- package/src/geometries/poly2/create.js +24 -0
- package/src/geometries/poly2/create.test.js +13 -0
- package/src/geometries/poly2/flip.d.ts +5 -0
- package/src/geometries/poly2/flip.js +15 -0
- package/src/geometries/poly2/index.d.ts +7 -0
- package/src/geometries/poly2/index.js +17 -0
- package/src/geometries/poly2/measureArea.d.ts +5 -0
- package/src/geometries/poly2/measureArea.js +12 -0
- package/src/geometries/poly2/measureArea.test.js +44 -0
- package/src/geometries/poly2/type.d.ts +7 -0
- package/src/geometries/poly3/clone.d.ts +6 -0
- package/src/geometries/poly3/clone.js +28 -0
- package/src/geometries/poly3/clone.test.js +35 -0
- package/src/geometries/poly3/create.d.ts +6 -0
- package/src/geometries/poly3/create.js +24 -0
- package/src/geometries/poly3/create.test.js +9 -0
- package/src/geometries/poly3/fromPoints.d.ts +6 -0
- package/src/geometries/poly3/fromPoints.js +25 -0
- package/src/geometries/poly3/fromPoints.test.js +15 -0
- package/src/geometries/poly3/fromPointsAndPlane.d.ts +7 -0
- package/src/geometries/poly3/fromPointsAndPlane.js +17 -0
- package/src/geometries/poly3/index.d.ts +19 -0
- package/src/geometries/poly3/index.js +29 -0
- package/src/geometries/poly3/invert.d.ts +5 -0
- package/src/geometries/poly3/invert.js +21 -0
- package/src/geometries/poly3/invert.test.js +18 -0
- package/src/geometries/poly3/isA.d.ts +5 -0
- package/src/geometries/poly3/isA.js +18 -0
- package/src/geometries/poly3/isA.test.js +19 -0
- package/src/geometries/poly3/isConvex.d.ts +5 -0
- package/src/geometries/poly3/isConvex.js +44 -0
- package/src/geometries/poly3/isConvex.test.js +24 -0
- package/src/geometries/poly3/measureArea.d.ts +5 -0
- package/src/geometries/poly3/measureArea.js +83 -0
- package/src/geometries/poly3/measureArea.test.js +111 -0
- package/src/geometries/poly3/measureBoundingBox.d.ts +6 -0
- package/src/geometries/poly3/measureBoundingBox.js +20 -0
- package/src/geometries/poly3/measureBoundingBox.test.js +70 -0
- package/src/geometries/poly3/measureBoundingSphere.d.ts +6 -0
- package/src/geometries/poly3/measureBoundingSphere.js +56 -0
- package/src/geometries/poly3/measureBoundingSphere.test.js +60 -0
- package/src/geometries/poly3/measureSignedVolume.d.ts +5 -0
- package/src/geometries/poly3/measureSignedVolume.js +25 -0
- package/src/geometries/poly3/measureSignedVolume.test.js +68 -0
- package/src/geometries/poly3/plane.d.ts +6 -0
- package/src/geometries/poly3/plane.js +10 -0
- package/src/geometries/poly3/toPoints.d.ts +6 -0
- package/src/geometries/poly3/toPoints.js +10 -0
- package/src/geometries/poly3/toString.d.ts +5 -0
- package/src/geometries/poly3/toString.js +17 -0
- package/src/geometries/poly3/transform.d.ts +6 -0
- package/src/geometries/poly3/transform.js +22 -0
- package/src/geometries/poly3/transform.test.js +62 -0
- package/src/geometries/poly3/type.d.ts +11 -0
- package/src/geometries/poly3/validate.d.ts +4 -0
- package/src/geometries/poly3/validate.js +64 -0
- package/src/geometries/types.d.ts +21 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +17 -0
- package/src/index.test-d.ts +26 -0
- package/src/maths/OrthoNormalBasis.js +59 -0
- package/src/maths/constants.d.ts +3 -0
- package/src/maths/constants.js +41 -0
- package/src/maths/index.d.ts +11 -0
- package/src/maths/index.js +19 -0
- package/src/maths/line2/clone.d.ts +5 -0
- package/src/maths/line2/clone.js +18 -0
- package/src/maths/line2/clone.test.js +21 -0
- package/src/maths/line2/closestPoint.d.ts +6 -0
- package/src/maths/line2/closestPoint.js +25 -0
- package/src/maths/line2/closestPoint.test.js +48 -0
- package/src/maths/line2/copy.d.ts +5 -0
- package/src/maths/line2/copy.js +16 -0
- package/src/maths/line2/copy.test.js +27 -0
- package/src/maths/line2/create.d.ts +5 -0
- package/src/maths/line2/create.js +20 -0
- package/src/maths/line2/create.test.js +10 -0
- package/src/maths/line2/direction.d.ts +6 -0
- package/src/maths/line2/direction.js +16 -0
- package/src/maths/line2/direction.test.js +31 -0
- package/src/maths/line2/distanceToPoint.d.ts +6 -0
- package/src/maths/line2/distanceToPoint.js +17 -0
- package/src/maths/line2/distanceToPoint.test.js +31 -0
- package/src/maths/line2/equals.d.ts +5 -0
- package/src/maths/line2/equals.js +11 -0
- package/src/maths/line2/equals.test.js +26 -0
- package/src/maths/line2/fromPoints.d.ts +6 -0
- package/src/maths/line2/fromPoints.js +26 -0
- package/src/maths/line2/fromPoints.test.js +24 -0
- package/src/maths/line2/fromValues.d.ts +5 -0
- package/src/maths/line2/fromValues.js +20 -0
- package/src/maths/line2/fromValues.test.js +12 -0
- package/src/maths/line2/index.d.ts +18 -0
- package/src/maths/line2/index.js +22 -0
- package/src/maths/line2/intersectPointOfLines.d.ts +6 -0
- package/src/maths/line2/intersectPointOfLines.js +21 -0
- package/src/maths/line2/intersectPointOfLines.test.js +31 -0
- package/src/maths/line2/origin.d.ts +6 -0
- package/src/maths/line2/origin.js +13 -0
- package/src/maths/line2/origin.test.js +30 -0
- package/src/maths/line2/reverse.d.ts +5 -0
- package/src/maths/line2/reverse.js +20 -0
- package/src/maths/line2/reverse.test.js +36 -0
- package/src/maths/line2/toString.d.ts +5 -0
- package/src/maths/line2/toString.js +10 -0
- package/src/maths/line2/transform.d.ts +6 -0
- package/src/maths/line2/transform.js +26 -0
- package/src/maths/line2/transform.test.js +89 -0
- package/src/maths/line2/type.d.ts +3 -0
- package/src/maths/line2/xAtY.d.ts +5 -0
- package/src/maths/line2/xAtY.js +22 -0
- package/src/maths/line2/xAtY.test.js +39 -0
- package/src/maths/line3/clone.d.ts +5 -0
- package/src/maths/line3/clone.js +19 -0
- package/src/maths/line3/clone.test.js +24 -0
- package/src/maths/line3/closestPoint.d.ts +6 -0
- package/src/maths/line3/closestPoint.js +24 -0
- package/src/maths/line3/closestPoint.test.js +37 -0
- package/src/maths/line3/copy.d.ts +5 -0
- package/src/maths/line3/copy.js +17 -0
- package/src/maths/line3/copy.test.js +33 -0
- package/src/maths/line3/create.d.ts +5 -0
- package/src/maths/line3/create.js +23 -0
- package/src/maths/line3/create.test.js +11 -0
- package/src/maths/line3/direction.d.ts +6 -0
- package/src/maths/line3/direction.js +10 -0
- package/src/maths/line3/direction.test.js +26 -0
- package/src/maths/line3/distanceToPoint.d.ts +6 -0
- package/src/maths/line3/distanceToPoint.js +19 -0
- package/src/maths/line3/distanceToPoint.test.js +31 -0
- package/src/maths/line3/equals.d.ts +5 -0
- package/src/maths/line3/equals.js +25 -0
- package/src/maths/line3/equals.test.js +17 -0
- package/src/maths/line3/fromPlanes.d.ts +6 -0
- package/src/maths/line3/fromPlanes.js +47 -0
- package/src/maths/line3/fromPlanes.test.js +38 -0
- package/src/maths/line3/fromPointAndDirection.d.ts +6 -0
- package/src/maths/line3/fromPointAndDirection.js +25 -0
- package/src/maths/line3/fromPointAndDirection.test.js +37 -0
- package/src/maths/line3/fromPoints.d.ts +6 -0
- package/src/maths/line3/fromPoints.js +19 -0
- package/src/maths/line3/fromPoints.test.js +37 -0
- package/src/maths/line3/index.d.ts +18 -0
- package/src/maths/line3/index.js +22 -0
- package/src/maths/line3/intersectPointOfLineAndPlane.d.ts +7 -0
- package/src/maths/line3/intersectPointOfLineAndPlane.js +29 -0
- package/src/maths/line3/intersectPointOfLineAndPlane.test.js +29 -0
- package/src/maths/line3/origin.d.ts +6 -0
- package/src/maths/line3/origin.js +10 -0
- package/src/maths/line3/origin.test.js +26 -0
- package/src/maths/line3/reverse.d.ts +5 -0
- package/src/maths/line3/reverse.js +19 -0
- package/src/maths/line3/reverse.test.js +33 -0
- package/src/maths/line3/toString.d.ts +5 -0
- package/src/maths/line3/toString.js +14 -0
- package/src/maths/line3/transform.d.ts +6 -0
- package/src/maths/line3/transform.js +26 -0
- package/src/maths/line3/transform.test.js +66 -0
- package/src/maths/line3/type.d.ts +5 -0
- package/src/maths/mat4/add.d.ts +5 -0
- package/src/maths/mat4/add.js +30 -0
- package/src/maths/mat4/add.test.js +27 -0
- package/src/maths/mat4/clone.d.ts +5 -0
- package/src/maths/mat4/clone.js +31 -0
- package/src/maths/mat4/clone.test.js +21 -0
- package/src/maths/mat4/copy.d.ts +5 -0
- package/src/maths/mat4/copy.js +29 -0
- package/src/maths/mat4/copy.test.js +30 -0
- package/src/maths/mat4/create.d.ts +5 -0
- package/src/maths/mat4/create.js +20 -0
- package/src/maths/mat4/create.test.js +10 -0
- package/src/maths/mat4/equals.d.ts +5 -0
- package/src/maths/mat4/equals.js +16 -0
- package/src/maths/mat4/equals.test.js +56 -0
- package/src/maths/mat4/fromRotation.d.ts +6 -0
- package/src/maths/mat4/fromRotation.js +60 -0
- package/src/maths/mat4/fromRotation.test.js +18 -0
- package/src/maths/mat4/fromScaling.d.ts +6 -0
- package/src/maths/mat4/fromScaling.js +35 -0
- package/src/maths/mat4/fromScaling.test.js +12 -0
- package/src/maths/mat4/fromTaitBryanRotation.d.ts +5 -0
- package/src/maths/mat4/fromTaitBryanRotation.js +55 -0
- package/src/maths/mat4/fromTaitBryanRotation.test.js +24 -0
- package/src/maths/mat4/fromTranslation.d.ts +6 -0
- package/src/maths/mat4/fromTranslation.js +35 -0
- package/src/maths/mat4/fromTranslation.test.js +12 -0
- package/src/maths/mat4/fromValues.d.ts +5 -0
- package/src/maths/mat4/fromValues.js +53 -0
- package/src/maths/mat4/fromValues.test.js +12 -0
- package/src/maths/mat4/fromVectorRotation.d.ts +6 -0
- package/src/maths/mat4/fromVectorRotation.js +49 -0
- package/src/maths/mat4/fromVectorRotation.test.js +127 -0
- package/src/maths/mat4/fromXRotation.d.ts +5 -0
- package/src/maths/mat4/fromXRotation.js +41 -0
- package/src/maths/mat4/fromXRotation.test.js +14 -0
- package/src/maths/mat4/fromYRotation.d.ts +5 -0
- package/src/maths/mat4/fromYRotation.js +41 -0
- package/src/maths/mat4/fromYRotation.test.js +14 -0
- package/src/maths/mat4/fromZRotation.d.ts +5 -0
- package/src/maths/mat4/fromZRotation.js +41 -0
- package/src/maths/mat4/fromZRotation.test.js +14 -0
- package/src/maths/mat4/identity.d.ts +5 -0
- package/src/maths/mat4/identity.js +28 -0
- package/src/maths/mat4/identity.test.js +12 -0
- package/src/maths/mat4/index.d.ts +29 -0
- package/src/maths/mat4/index.js +36 -0
- package/src/maths/mat4/invert.js +71 -0
- package/src/maths/mat4/invert.test.js +32 -0
- package/src/maths/mat4/isIdentity.d.ts +5 -0
- package/src/maths/mat4/isIdentity.js +20 -0
- package/src/maths/mat4/isIdentity.test.js +11 -0
- package/src/maths/mat4/isMirroring.d.ts +5 -0
- package/src/maths/mat4/isMirroring.js +24 -0
- package/src/maths/mat4/isMirroring.test.js +37 -0
- package/src/maths/mat4/isOnlyTransformScale.js +22 -0
- package/src/maths/mat4/isOnlyTransformScale.test.js +29 -0
- package/src/maths/mat4/leftMultiplyVec2.d.ts +6 -0
- package/src/maths/mat4/leftMultiplyVec2.js +28 -0
- package/src/maths/mat4/leftMultiplyVec3.d.ts +6 -0
- package/src/maths/mat4/leftMultiplyVec3.js +29 -0
- package/src/maths/mat4/mirror.d.ts +6 -0
- package/src/maths/mat4/mirror.js +34 -0
- package/src/maths/mat4/mirrorByPlane.d.ts +6 -0
- package/src/maths/mat4/mirrorByPlane.js +32 -0
- package/src/maths/mat4/mirrorByPlane.test.js +28 -0
- package/src/maths/mat4/multiply.d.ts +5 -0
- package/src/maths/mat4/multiply.js +67 -0
- package/src/maths/mat4/multiply.test.js +28 -0
- package/src/maths/mat4/rightMultiplyVec2.d.ts +6 -0
- package/src/maths/mat4/rightMultiplyVec2.js +29 -0
- package/src/maths/mat4/rightMultiplyVec3.d.ts +6 -0
- package/src/maths/mat4/rightMultiplyVec3.js +30 -0
- package/src/maths/mat4/rotate.d.ts +6 -0
- package/src/maths/mat4/rotate.js +82 -0
- package/src/maths/mat4/rotate.test.js +27 -0
- package/src/maths/mat4/rotateX.d.ts +5 -0
- package/src/maths/mat4/rotateX.js +47 -0
- package/src/maths/mat4/rotateX.test.js +21 -0
- package/src/maths/mat4/rotateY.d.ts +5 -0
- package/src/maths/mat4/rotateY.js +47 -0
- package/src/maths/mat4/rotateY.test.js +21 -0
- package/src/maths/mat4/rotateZ.d.ts +5 -0
- package/src/maths/mat4/rotateZ.js +47 -0
- package/src/maths/mat4/rotateZ.test.js +21 -0
- package/src/maths/mat4/scale.d.ts +6 -0
- package/src/maths/mat4/scale.js +34 -0
- package/src/maths/mat4/scale.test.js +21 -0
- package/src/maths/mat4/subtract.d.ts +5 -0
- package/src/maths/mat4/subtract.js +30 -0
- package/src/maths/mat4/subtract.test.js +27 -0
- package/src/maths/mat4/toString.d.ts +5 -0
- package/src/maths/mat4/toString.js +10 -0
- package/src/maths/mat4/translate.d.ts +6 -0
- package/src/maths/mat4/translate.js +51 -0
- package/src/maths/mat4/translate.test.js +72 -0
- package/src/maths/mat4/type.d.ts +8 -0
- package/src/maths/plane/clone.d.ts +5 -0
- package/src/maths/plane/clone.test.js +24 -0
- package/src/maths/plane/copy.d.ts +5 -0
- package/src/maths/plane/copy.test.js +30 -0
- package/src/maths/plane/create.d.ts +5 -0
- package/src/maths/plane/create.test.js +10 -0
- package/src/maths/plane/equals.d.ts +5 -0
- package/src/maths/plane/equals.test.js +17 -0
- package/src/maths/plane/flip.d.ts +5 -0
- package/src/maths/plane/flip.js +17 -0
- package/src/maths/plane/flip.test.js +26 -0
- package/src/maths/plane/fromNoisyPoints.d.ts +6 -0
- package/src/maths/plane/fromNoisyPoints.js +106 -0
- package/src/maths/plane/fromNoisyPoints.test.js +24 -0
- package/src/maths/plane/fromNormalAndPoint.d.ts +6 -0
- package/src/maths/plane/fromNormalAndPoint.js +32 -0
- package/src/maths/plane/fromNormalAndPoint.test.js +12 -0
- package/src/maths/plane/fromPoints.d.ts +6 -0
- package/src/maths/plane/fromPoints.js +47 -0
- package/src/maths/plane/fromPoints.test.js +20 -0
- package/src/maths/plane/fromPointsRandom.d.ts +6 -0
- package/src/maths/plane/fromPointsRandom.js +42 -0
- package/src/maths/plane/fromValues.d.ts +5 -0
- package/src/maths/plane/index.d.ts +17 -0
- package/src/maths/plane/index.js +46 -0
- package/src/maths/plane/projectionOfPoint.d.ts +6 -0
- package/src/maths/plane/projectionOfPoint.js +19 -0
- package/src/maths/plane/projectionOfPoint.test.js +43 -0
- package/src/maths/plane/signedDistanceToPoint.d.ts +6 -0
- package/src/maths/plane/signedDistanceToPoint.js +13 -0
- package/src/maths/plane/signedDistanceToPoint.test.js +20 -0
- package/src/maths/plane/toString.d.ts +5 -0
- package/src/maths/plane/transform.d.ts +6 -0
- package/src/maths/plane/transform.js +40 -0
- package/src/maths/plane/transform.test.js +72 -0
- package/src/maths/plane/type.d.ts +3 -0
- package/src/maths/rotation.test.js +131 -0
- package/src/maths/types.d.ts +8 -0
- package/src/maths/utils/aboutEqualNormals.d.ts +5 -0
- package/src/maths/utils/aboutEqualNormals.js +12 -0
- package/src/maths/utils/area.d.ts +5 -0
- package/src/maths/utils/area.js +17 -0
- package/src/maths/utils/index.d.ts +8 -0
- package/src/maths/utils/index.js +15 -0
- package/src/maths/utils/interpolateBetween2DPointsForY.d.ts +5 -0
- package/src/maths/utils/interpolateBetween2DPointsForY.js +31 -0
- package/src/maths/utils/intersect.d.ts +5 -0
- package/src/maths/utils/intersect.js +40 -0
- package/src/maths/utils/solve2Linear.d.ts +5 -0
- package/src/maths/utils/solve2Linear.js +11 -0
- package/src/maths/utils/trigonometry.d.ts +2 -0
- package/src/maths/utils/trigonometry.js +34 -0
- package/src/maths/utils/trigonometry.test.js +27 -0
- package/src/maths/vec1/type.d.ts +3 -0
- package/src/maths/vec2/abs.d.ts +5 -0
- package/src/maths/vec2/abs.js +15 -0
- package/src/maths/vec2/abs.test.js +24 -0
- package/src/maths/vec2/add.d.ts +5 -0
- package/src/maths/vec2/add.js +16 -0
- package/src/maths/vec2/add.test.js +26 -0
- package/src/maths/vec2/angle.d.ts +3 -0
- package/src/maths/vec2/angle.js +1 -0
- package/src/maths/vec2/angleDegrees.d.ts +5 -0
- package/src/maths/vec2/angleDegrees.js +12 -0
- package/src/maths/vec2/angleDegrees.test.js +24 -0
- package/src/maths/vec2/angleRadians.d.ts +5 -0
- package/src/maths/vec2/angleRadians.js +10 -0
- package/src/maths/vec2/angleRadians.test.js +24 -0
- package/src/maths/vec2/clone.d.ts +5 -0
- package/src/maths/vec2/clone.js +17 -0
- package/src/maths/vec2/clone.test.js +21 -0
- package/src/maths/vec2/copy.d.ts +5 -0
- package/src/maths/vec2/copy.js +15 -0
- package/src/maths/vec2/copy.test.js +30 -0
- package/src/maths/vec2/create.d.ts +5 -0
- package/src/maths/vec2/create.js +15 -0
- package/src/maths/vec2/create.test.js +10 -0
- package/src/maths/vec2/cross.d.ts +6 -0
- package/src/maths/vec2/cross.js +17 -0
- package/src/maths/vec2/cross.test.js +51 -0
- package/src/maths/vec2/distance.d.ts +5 -0
- package/src/maths/vec2/distance.js +15 -0
- package/src/maths/vec2/distance.test.js +30 -0
- package/src/maths/vec2/divide.d.ts +5 -0
- package/src/maths/vec2/divide.js +16 -0
- package/src/maths/vec2/divide.test.js +36 -0
- package/src/maths/vec2/dot.d.ts +5 -0
- package/src/maths/vec2/dot.js +11 -0
- package/src/maths/vec2/dot.test.js +24 -0
- package/src/maths/vec2/equals.d.ts +5 -0
- package/src/maths/vec2/equals.js +11 -0
- package/src/maths/vec2/equals.test.js +17 -0
- package/src/maths/vec2/fromAngleDegrees.d.ts +5 -0
- package/src/maths/vec2/fromAngleDegrees.js +13 -0
- package/src/maths/vec2/fromAngleDegrees.test.js +12 -0
- package/src/maths/vec2/fromAngleRadians.d.ts +5 -0
- package/src/maths/vec2/fromAngleRadians.js +17 -0
- package/src/maths/vec2/fromAngleRadians.test.js +15 -0
- package/src/maths/vec2/fromScalar.d.ts +5 -0
- package/src/maths/vec2/fromScalar.js +15 -0
- package/src/maths/vec2/fromScalar.test.js +12 -0
- package/src/maths/vec2/fromValues.d.ts +5 -0
- package/src/maths/vec2/fromValues.js +18 -0
- package/src/maths/vec2/index.d.ts +36 -0
- package/src/maths/vec2/index.js +39 -0
- package/src/maths/vec2/length.d.ts +5 -0
- package/src/maths/vec2/length.js +10 -0
- package/src/maths/vec2/length.test.js +29 -0
- package/src/maths/vec2/lerp.d.ts +5 -0
- package/src/maths/vec2/lerp.js +19 -0
- package/src/maths/vec2/lerp.test.js +26 -0
- package/src/maths/vec2/max.d.ts +5 -0
- package/src/maths/vec2/max.js +16 -0
- package/src/maths/vec2/max.test.js +31 -0
- package/src/maths/vec2/min.d.ts +5 -0
- package/src/maths/vec2/min.js +16 -0
- package/src/maths/vec2/min.test.js +31 -0
- package/src/maths/vec2/multiply.d.ts +5 -0
- package/src/maths/vec2/multiply.js +16 -0
- package/src/maths/vec2/multiply.test.js +36 -0
- package/src/maths/vec2/negate.d.ts +5 -0
- package/src/maths/vec2/negate.js +15 -0
- package/src/maths/vec2/negate.test.js +26 -0
- package/src/maths/vec2/normal.d.ts +5 -0
- package/src/maths/vec2/normal.js +17 -0
- package/src/maths/vec2/normal.test.js +30 -0
- package/src/maths/vec2/normalize.d.ts +5 -0
- package/src/maths/vec2/normalize.js +23 -0
- package/src/maths/vec2/normalize.test.js +36 -0
- package/src/maths/vec2/rotate.d.ts +5 -0
- package/src/maths/vec2/rotate.js +23 -0
- package/src/maths/vec2/rotate.test.js +31 -0
- package/src/maths/vec2/scale.d.ts +5 -0
- package/src/maths/vec2/scale.js +16 -0
- package/src/maths/vec2/scale.test.js +24 -0
- package/src/maths/vec2/snap.d.ts +5 -0
- package/src/maths/vec2/snap.js +16 -0
- package/src/maths/vec2/snap.test.js +32 -0
- package/src/maths/vec2/squaredDistance.d.ts +5 -0
- package/src/maths/vec2/squaredDistance.js +15 -0
- package/src/maths/vec2/squaredDistance.test.js +30 -0
- package/src/maths/vec2/squaredLength.d.ts +5 -0
- package/src/maths/vec2/squaredLength.js +14 -0
- package/src/maths/vec2/squaredLength.test.js +29 -0
- package/src/maths/vec2/subtract.d.ts +5 -0
- package/src/maths/vec2/subtract.js +16 -0
- package/src/maths/vec2/subtract.test.js +26 -0
- package/src/maths/vec2/toString.d.ts +5 -0
- package/src/maths/vec2/toString.js +10 -0
- package/src/maths/vec2/transform.d.ts +6 -0
- package/src/maths/vec2/transform.js +18 -0
- package/src/maths/vec2/transform.test.js +66 -0
- package/src/maths/vec2/type.d.ts +3 -0
- package/src/maths/vec3/abs.d.ts +5 -0
- package/src/maths/vec3/abs.js +16 -0
- package/src/maths/vec3/abs.test.js +24 -0
- package/src/maths/vec3/add.d.ts +5 -0
- package/src/maths/vec3/add.js +17 -0
- package/src/maths/vec3/add.test.js +26 -0
- package/src/maths/vec3/angle.d.ts +5 -0
- package/src/maths/vec3/angle.js +25 -0
- package/src/maths/vec3/angle.test.js +34 -0
- package/src/maths/vec3/clone.d.ts +5 -0
- package/src/maths/vec3/clone.js +18 -0
- package/src/maths/vec3/clone.test.js +21 -0
- package/src/maths/vec3/copy.d.ts +5 -0
- package/src/maths/vec3/copy.js +16 -0
- package/src/maths/vec3/copy.test.js +27 -0
- package/src/maths/vec3/create.d.ts +5 -0
- package/src/maths/vec3/create.js +15 -0
- package/src/maths/vec3/create.test.js +10 -0
- package/src/maths/vec3/cross.d.ts +5 -0
- package/src/maths/vec3/cross.js +24 -0
- package/src/maths/vec3/cross.test.js +51 -0
- package/src/maths/vec3/distance.d.ts +5 -0
- package/src/maths/vec3/distance.js +16 -0
- package/src/maths/vec3/distance.test.js +46 -0
- package/src/maths/vec3/divide.d.ts +5 -0
- package/src/maths/vec3/divide.js +17 -0
- package/src/maths/vec3/divide.test.js +36 -0
- package/src/maths/vec3/dot.d.ts +5 -0
- package/src/maths/vec3/dot.js +11 -0
- package/src/maths/vec3/dot.test.js +24 -0
- package/src/maths/vec3/equals.d.ts +5 -0
- package/src/maths/vec3/equals.js +11 -0
- package/src/maths/vec3/equals.test.js +17 -0
- package/src/maths/vec3/fromScalar.d.ts +5 -0
- package/src/maths/vec3/fromScalar.js +17 -0
- package/src/maths/vec3/fromScalar.test.js +12 -0
- package/src/maths/vec3/fromValues.d.ts +5 -0
- package/src/maths/vec3/fromValues.js +20 -0
- package/src/maths/vec3/fromValues.test.js +12 -0
- package/src/maths/vec3/fromVec2.d.ts +6 -0
- package/src/maths/vec3/fromVec2.js +17 -0
- package/src/maths/vec3/fromVec2.test.js +13 -0
- package/src/maths/vec3/index.d.ts +35 -0
- package/src/maths/vec3/index.js +39 -0
- package/src/maths/vec3/length.d.ts +5 -0
- package/src/maths/vec3/length.js +15 -0
- package/src/maths/vec3/length.test.js +45 -0
- package/src/maths/vec3/lerp.d.ts +5 -0
- package/src/maths/vec3/lerp.js +18 -0
- package/src/maths/vec3/lerp.test.js +26 -0
- package/src/maths/vec3/max.d.ts +5 -0
- package/src/maths/vec3/max.js +17 -0
- package/src/maths/vec3/max.test.js +31 -0
- package/src/maths/vec3/min.d.ts +5 -0
- package/src/maths/vec3/min.js +17 -0
- package/src/maths/vec3/min.test.js +31 -0
- package/src/maths/vec3/multiply.d.ts +5 -0
- package/src/maths/vec3/multiply.js +17 -0
- package/src/maths/vec3/multiply.test.js +36 -0
- package/src/maths/vec3/negate.d.ts +5 -0
- package/src/maths/vec3/negate.js +16 -0
- package/src/maths/vec3/negate.test.js +26 -0
- package/src/maths/vec3/normalize.d.ts +5 -0
- package/src/maths/vec3/normalize.js +23 -0
- package/src/maths/vec3/normalize.test.js +36 -0
- package/src/maths/vec3/orthogonal.d.ts +5 -0
- package/src/maths/vec3/orthogonal.js +22 -0
- package/src/maths/vec3/orthogonal.test.js +24 -0
- package/src/maths/vec3/rotateX.d.ts +5 -0
- package/src/maths/vec3/rotateX.js +33 -0
- package/src/maths/vec3/rotateX.test.js +31 -0
- package/src/maths/vec3/rotateY.d.ts +5 -0
- package/src/maths/vec3/rotateY.js +33 -0
- package/src/maths/vec3/rotateY.test.js +31 -0
- package/src/maths/vec3/rotateZ.d.ts +5 -0
- package/src/maths/vec3/rotateZ.js +30 -0
- package/src/maths/vec3/rotateZ.test.js +31 -0
- package/src/maths/vec3/scale.d.ts +5 -0
- package/src/maths/vec3/scale.js +17 -0
- package/src/maths/vec3/scale.test.js +36 -0
- package/src/maths/vec3/snap.d.ts +5 -0
- package/src/maths/vec3/snap.js +17 -0
- package/src/maths/vec3/snap.test.js +32 -0
- package/src/maths/vec3/squaredDistance.d.ts +5 -0
- package/src/maths/vec3/squaredDistance.js +16 -0
- package/src/maths/vec3/squaredDistance.test.js +46 -0
- package/src/maths/vec3/squaredLength.d.ts +5 -0
- package/src/maths/vec3/squaredLength.js +15 -0
- package/src/maths/vec3/squaredLength.test.js +45 -0
- package/src/maths/vec3/subtract.d.ts +5 -0
- package/src/maths/vec3/subtract.js +17 -0
- package/src/maths/vec3/subtract.test.js +26 -0
- package/src/maths/vec3/toString.d.ts +5 -0
- package/src/maths/vec3/toString.js +9 -0
- package/src/maths/vec3/transform.d.ts +6 -0
- package/src/maths/vec3/transform.js +22 -0
- package/src/maths/vec3/transform.test.js +66 -0
- package/src/maths/vec3/type.d.ts +3 -0
- package/src/maths/vec4/clone.d.ts +5 -0
- package/src/maths/vec4/clone.js +19 -0
- package/src/maths/vec4/clone.test.js +24 -0
- package/src/maths/vec4/copy.d.ts +5 -0
- package/src/maths/vec4/copy.js +17 -0
- package/src/maths/vec4/copy.test.js +30 -0
- package/src/maths/vec4/create.d.ts +5 -0
- package/src/maths/vec4/create.js +15 -0
- package/src/maths/vec4/create.test.js +10 -0
- package/src/maths/vec4/dot.d.ts +5 -0
- package/src/maths/vec4/dot.js +11 -0
- package/src/maths/vec4/dot.test.js +11 -0
- package/src/maths/vec4/equals.d.ts +5 -0
- package/src/maths/vec4/equals.js +11 -0
- package/src/maths/vec4/equals.test.js +17 -0
- package/src/maths/vec4/fromScalar.d.ts +5 -0
- package/src/maths/vec4/fromScalar.js +17 -0
- package/src/maths/vec4/fromScalar.test.js +12 -0
- package/src/maths/vec4/fromValues.d.ts +5 -0
- package/src/maths/vec4/fromValues.js +22 -0
- package/src/maths/vec4/fromValues.test.js +15 -0
- package/src/maths/vec4/index.d.ts +12 -0
- package/src/maths/vec4/index.js +16 -0
- package/src/maths/vec4/toString.d.ts +5 -0
- package/src/maths/vec4/toString.js +10 -0
- package/src/maths/vec4/transform.d.ts +6 -0
- package/src/maths/vec4/transform.js +20 -0
- package/src/maths/vec4/transform.test.js +66 -0
- package/src/maths/vec4/type.d.ts +3 -0
- package/src/measurements/calculateEpsilonFromBounds.js +11 -0
- package/src/measurements/calculateEpsilonFromBounds.test.js +18 -0
- package/src/measurements/index.d.ts +15 -0
- package/src/measurements/index.js +20 -0
- package/src/measurements/measureAggregateArea.d.ts +6 -0
- package/src/measurements/measureAggregateArea.js +26 -0
- package/src/measurements/measureAggregateArea.test.js +22 -0
- package/src/measurements/measureAggregateBoundingBox.d.ts +8 -0
- package/src/measurements/measureAggregateBoundingBox.js +30 -0
- package/src/measurements/measureAggregateBoundingBox.test.js +35 -0
- package/src/measurements/measureAggregateEpsilon.d.ts +6 -0
- package/src/measurements/measureAggregateEpsilon.js +29 -0
- package/src/measurements/measureAggregateEpsilon.test.js +28 -0
- package/src/measurements/measureAggregateVolume.d.ts +6 -0
- package/src/measurements/measureAggregateVolume.js +26 -0
- package/src/measurements/measureAggregateVolume.test.js +21 -0
- package/src/measurements/measureArea.d.ts +8 -0
- package/src/measurements/measureArea.js +80 -0
- package/src/measurements/measureArea.test.js +58 -0
- package/src/measurements/measureBoundingBox.d.ts +10 -0
- package/src/measurements/measureBoundingBox.js +134 -0
- package/src/measurements/measureBoundingBox.test.js +66 -0
- package/src/measurements/measureBoundingSphere.d.ts +9 -0
- package/src/measurements/measureBoundingSphere.js +146 -0
- package/src/measurements/measureBoundingSphere.test.js +59 -0
- package/src/measurements/measureCenter.d.ts +7 -0
- package/src/measurements/measureCenter.js +28 -0
- package/src/measurements/measureCenter.test.js +58 -0
- package/src/measurements/measureCenterOfMass.d.ts +7 -0
- package/src/measurements/measureCenterOfMass.js +106 -0
- package/src/measurements/measureCenterOfMass.test.js +58 -0
- package/src/measurements/measureDimensions.d.ts +7 -0
- package/src/measurements/measureDimensions.js +28 -0
- package/src/measurements/measureDimensions.test.js +58 -0
- package/src/measurements/measureEpsilon.d.ts +8 -0
- package/src/measurements/measureEpsilon.js +48 -0
- package/src/measurements/measureEpsilon.test.js +58 -0
- package/src/measurements/measureVolume.d.ts +8 -0
- package/src/measurements/measureVolume.js +68 -0
- package/src/measurements/measureVolume.test.js +58 -0
- package/src/measurements/types.d.ts +3 -0
- package/src/operations/booleans/fromFakePolygons.js +52 -0
- package/src/operations/booleans/index.d.ts +6 -0
- package/src/operations/booleans/index.js +14 -0
- package/src/operations/booleans/intersect.d.ts +7 -0
- package/src/operations/booleans/intersect.js +47 -0
- package/src/operations/booleans/intersectGeom2.js +27 -0
- package/src/operations/booleans/intersectGeom2.test.js +69 -0
- package/src/operations/booleans/intersectGeom3.js +25 -0
- package/src/operations/booleans/intersectGeom3.test.js +116 -0
- package/src/operations/booleans/intersectGeom3Sub.js +33 -0
- package/src/operations/booleans/mayOverlap.js +35 -0
- package/src/operations/booleans/mayOverlap.test.js +73 -0
- package/src/operations/booleans/scission.d.ts +6 -0
- package/src/operations/booleans/scission.js +45 -0
- package/src/operations/booleans/scission.test.js +51 -0
- package/src/operations/booleans/scissionGeom3.js +93 -0
- package/src/operations/booleans/subtract.d.ts +7 -0
- package/src/operations/booleans/subtract.js +47 -0
- package/src/operations/booleans/subtractGeom2.js +27 -0
- package/src/operations/booleans/subtractGeom2.test.js +72 -0
- package/src/operations/booleans/subtractGeom3.js +25 -0
- package/src/operations/booleans/subtractGeom3.test.js +109 -0
- package/src/operations/booleans/subtractGeom3Sub.js +31 -0
- package/src/operations/booleans/to3DWalls.js +36 -0
- package/src/operations/booleans/trees/Node.js +144 -0
- package/src/operations/booleans/trees/PolygonTreeNode.js +261 -0
- package/src/operations/booleans/trees/Tree.js +50 -0
- package/src/operations/booleans/trees/index.js +3 -0
- package/src/operations/booleans/trees/splitLineSegmentByPlane.js +15 -0
- package/src/operations/booleans/trees/splitPolygonByPlane.d.ts +33 -0
- package/src/operations/booleans/trees/splitPolygonByPlane.js +119 -0
- package/src/operations/booleans/trees/splitPolygonByPlane.test.js +132 -0
- package/src/operations/booleans/union.d.ts +7 -0
- package/src/operations/booleans/union.js +46 -0
- package/src/operations/booleans/unionGeom2.js +26 -0
- package/src/operations/booleans/unionGeom2.test.js +166 -0
- package/src/operations/booleans/unionGeom3.js +25 -0
- package/src/operations/booleans/unionGeom3.test.js +133 -0
- package/src/operations/booleans/unionGeom3Sub.js +40 -0
- package/src/operations/expansions/expand.d.ts +18 -0
- package/src/operations/expansions/expand.js +42 -0
- package/src/operations/expansions/expand.test.js +188 -0
- package/src/operations/expansions/expandGeom2.js +43 -0
- package/src/operations/expansions/expandGeom3.js +36 -0
- package/src/operations/expansions/expandGeom3.test.js +32 -0
- package/src/operations/expansions/expandPath2.js +99 -0
- package/src/operations/expansions/expandShell.js +224 -0
- package/src/operations/expansions/extrudePolygon.js +34 -0
- package/src/operations/expansions/index.d.ts +4 -0
- package/src/operations/expansions/index.js +11 -0
- package/src/operations/expansions/offset.d.ts +15 -0
- package/src/operations/expansions/offset.js +36 -0
- package/src/operations/expansions/offset.test.js +503 -0
- package/src/operations/expansions/offsetFromPoints.js +170 -0
- package/src/operations/expansions/offsetGeom2.js +47 -0
- package/src/operations/expansions/offsetPath2.js +32 -0
- package/src/operations/extrusions/earcut/assignHoles.js +91 -0
- package/src/operations/extrusions/earcut/assignHoles.test.js +74 -0
- package/src/operations/extrusions/earcut/eliminateHoles.js +131 -0
- package/src/operations/extrusions/earcut/index.js +252 -0
- package/src/operations/extrusions/earcut/linkedList.js +58 -0
- package/src/operations/extrusions/earcut/linkedListSort.js +54 -0
- package/src/operations/extrusions/earcut/linkedPolygon.js +197 -0
- package/src/operations/extrusions/earcut/polygonHierarchy.js +64 -0
- package/src/operations/extrusions/earcut/triangle.js +16 -0
- package/src/operations/extrusions/extrudeFromSlices.d.ts +15 -0
- package/src/operations/extrusions/extrudeFromSlices.js +124 -0
- package/src/operations/extrusions/extrudeFromSlices.test.js +167 -0
- package/src/operations/extrusions/extrudeHelical.d.ts +14 -0
- package/src/operations/extrusions/extrudeHelical.js +109 -0
- package/src/operations/extrusions/extrudeHelical.test.js +70 -0
- package/src/operations/extrusions/extrudeLinear.d.ts +15 -0
- package/src/operations/extrusions/extrudeLinear.js +47 -0
- package/src/operations/extrusions/extrudeLinear.test.js +226 -0
- package/src/operations/extrusions/extrudeLinearGeom2.js +64 -0
- package/src/operations/extrusions/extrudeLinearPath2.js +24 -0
- package/src/operations/extrusions/extrudeRectangular.d.ts +17 -0
- package/src/operations/extrusions/extrudeRectangular.js +45 -0
- package/src/operations/extrusions/extrudeRectangular.test.js +72 -0
- package/src/operations/extrusions/extrudeRectangularGeom2.js +46 -0
- package/src/operations/extrusions/extrudeRectangularPath2.js +33 -0
- package/src/operations/extrusions/extrudeRotate.d.ts +12 -0
- package/src/operations/extrusions/extrudeRotate.js +138 -0
- package/src/operations/extrusions/extrudeRotate.test.js +161 -0
- package/src/operations/extrusions/extrudeWalls.js +78 -0
- package/src/operations/extrusions/extrudeWalls.test.js +82 -0
- package/src/operations/extrusions/index.d.ts +9 -0
- package/src/operations/extrusions/index.js +16 -0
- package/src/operations/extrusions/project.d.ts +14 -0
- package/src/operations/extrusions/project.js +88 -0
- package/src/operations/extrusions/project.test.js +123 -0
- package/src/operations/extrusions/slice/calculatePlane.d.ts +7 -0
- package/src/operations/extrusions/slice/calculatePlane.js +41 -0
- package/src/operations/extrusions/slice/calculatePlane.test.js +35 -0
- package/src/operations/extrusions/slice/clone.d.ts +6 -0
- package/src/operations/extrusions/slice/clone.js +28 -0
- package/src/operations/extrusions/slice/clone.test.js +34 -0
- package/src/operations/extrusions/slice/create.d.ts +5 -0
- package/src/operations/extrusions/slice/create.js +20 -0
- package/src/operations/extrusions/slice/create.test.js +9 -0
- package/src/operations/extrusions/slice/equals.d.ts +5 -0
- package/src/operations/extrusions/slice/equals.js +27 -0
- package/src/operations/extrusions/slice/equals.test.js +17 -0
- package/src/operations/extrusions/slice/fromPoints.d.ts +9 -0
- package/src/operations/extrusions/slice/fromPoints.js +35 -0
- package/src/operations/extrusions/slice/fromPoints.test.js +15 -0
- package/src/operations/extrusions/slice/fromSides.d.ts +7 -0
- package/src/operations/extrusions/slice/fromSides.js +27 -0
- package/src/operations/extrusions/slice/fromSides.test.js +15 -0
- package/src/operations/extrusions/slice/index.d.ts +16 -0
- package/src/operations/extrusions/slice/index.js +19 -0
- package/src/operations/extrusions/slice/isA.d.ts +5 -0
- package/src/operations/extrusions/slice/isA.js +18 -0
- package/src/operations/extrusions/slice/isA.test.js +19 -0
- package/src/operations/extrusions/slice/repair.js +62 -0
- package/src/operations/extrusions/slice/reverse.d.ts +6 -0
- package/src/operations/extrusions/slice/reverse.js +26 -0
- package/src/operations/extrusions/slice/toEdges.d.ts +5 -0
- package/src/operations/extrusions/slice/toEdges.js +13 -0
- package/src/operations/extrusions/slice/toPolygons.d.ts +7 -0
- package/src/operations/extrusions/slice/toPolygons.js +40 -0
- package/src/operations/extrusions/slice/toString.d.ts +5 -0
- package/src/operations/extrusions/slice/toString.js +15 -0
- package/src/operations/extrusions/slice/transform.d.ts +7 -0
- package/src/operations/extrusions/slice/transform.js +21 -0
- package/src/operations/extrusions/slice/transform.test.js +66 -0
- package/src/operations/extrusions/slice/type.d.ts +7 -0
- package/src/operations/hulls/hull.d.ts +8 -0
- package/src/operations/hulls/hull.js +52 -0
- package/src/operations/hulls/hull.test.js +284 -0
- package/src/operations/hulls/hullChain.d.ts +8 -0
- package/src/operations/hulls/hullChain.js +43 -0
- package/src/operations/hulls/hullChain.test.js +87 -0
- package/src/operations/hulls/hullGeom2.js +31 -0
- package/src/operations/hulls/hullGeom3.js +27 -0
- package/src/operations/hulls/hullPath2.js +28 -0
- package/src/operations/hulls/hullPath2.test.js +16 -0
- package/src/operations/hulls/hullPoints2.d.ts +5 -0
- package/src/operations/hulls/hullPoints2.js +62 -0
- package/src/operations/hulls/hullPoints2.test.js +48 -0
- package/src/operations/hulls/hullPoints3.d.ts +6 -0
- package/src/operations/hulls/hullPoints3.js +23 -0
- package/src/operations/hulls/index.d.ts +6 -0
- package/src/operations/hulls/index.js +14 -0
- package/src/operations/hulls/quickhull/Face.js +334 -0
- package/src/operations/hulls/quickhull/HalfEdge.js +56 -0
- package/src/operations/hulls/quickhull/QuickHull.js +754 -0
- package/src/operations/hulls/quickhull/Vertex.js +21 -0
- package/src/operations/hulls/quickhull/VertexList.js +146 -0
- package/src/operations/hulls/quickhull/get-plane-normal.js +20 -0
- package/src/operations/hulls/quickhull/index.js +16 -0
- package/src/operations/hulls/quickhull/point-line-distance.js +42 -0
- package/src/operations/hulls/toUniquePoints.js +34 -0
- package/src/operations/modifiers/generalize.d.ts +12 -0
- package/src/operations/modifiers/generalize.js +82 -0
- package/src/operations/modifiers/generalize.test.js +170 -0
- package/src/operations/modifiers/index.d.ts +3 -0
- package/src/operations/modifiers/index.js +12 -0
- package/src/operations/modifiers/insertTjunctions.js +294 -0
- package/src/operations/modifiers/insertTjunctions.test.js +89 -0
- package/src/operations/modifiers/mergePolygons.js +208 -0
- package/src/operations/modifiers/reTesselateCoplanarPolygons.js +345 -0
- package/src/operations/modifiers/reTesselateCoplanarPolygons.test.js +70 -0
- package/src/operations/modifiers/retessellate.d.ts +3 -0
- package/src/operations/modifiers/retessellate.js +93 -0
- package/src/operations/modifiers/retessellate.test.js +173 -0
- package/src/operations/modifiers/snap.d.ts +6 -0
- package/src/operations/modifiers/snap.js +57 -0
- package/src/operations/modifiers/snap.test.js +146 -0
- package/src/operations/modifiers/snapPolygons.js +32 -0
- package/src/operations/modifiers/snapPolygons.test.js +70 -0
- package/src/operations/modifiers/triangulatePolygons.js +45 -0
- package/src/operations/transforms/align.d.ts +16 -0
- package/src/operations/transforms/align.js +89 -0
- package/src/operations/transforms/align.test.js +96 -0
- package/src/operations/transforms/center.d.ts +24 -0
- package/src/operations/transforms/center.js +90 -0
- package/src/operations/transforms/center.test.js +128 -0
- package/src/operations/transforms/index.d.ts +9 -0
- package/src/operations/transforms/index.js +37 -0
- package/src/operations/transforms/mirror.d.ts +24 -0
- package/src/operations/transforms/mirror.js +78 -0
- package/src/operations/transforms/mirror.test.js +158 -0
- package/src/operations/transforms/rotate.d.ts +19 -0
- package/src/operations/transforms/rotate.js +76 -0
- package/src/operations/transforms/rotate.test.js +154 -0
- package/src/operations/transforms/scale.d.ts +19 -0
- package/src/operations/transforms/scale.js +74 -0
- package/src/operations/transforms/scale.test.js +151 -0
- package/src/operations/transforms/transform.d.ts +7 -0
- package/src/operations/transforms/transform.js +32 -0
- package/src/operations/transforms/transform.test.js +76 -0
- package/src/operations/transforms/translate.d.ts +21 -0
- package/src/operations/transforms/translate.js +72 -0
- package/src/operations/transforms/translate.test.js +151 -0
- package/src/primitives/arc.d.ts +15 -0
- package/src/primitives/arc.js +86 -0
- package/src/primitives/arc.test.js +223 -0
- package/src/primitives/circle.d.ts +14 -0
- package/src/primitives/circle.js +38 -0
- package/src/primitives/circle.test.js +155 -0
- package/src/primitives/commonChecks.js +19 -0
- package/src/primitives/cube.d.ts +11 -0
- package/src/primitives/cube.js +30 -0
- package/src/primitives/cube.test.js +55 -0
- package/src/primitives/cuboid.d.ts +11 -0
- package/src/primitives/cuboid.js +55 -0
- package/src/primitives/cuboid.test.js +64 -0
- package/src/primitives/cylinder.d.ts +13 -0
- package/src/primitives/cylinder.js +46 -0
- package/src/primitives/cylinder.test.js +90 -0
- package/src/primitives/cylinderElliptic.d.ts +16 -0
- package/src/primitives/cylinderElliptic.js +132 -0
- package/src/primitives/cylinderElliptic.test.js +213 -0
- package/src/primitives/ellipse.d.ts +14 -0
- package/src/primitives/ellipse.js +78 -0
- package/src/primitives/ellipse.test.js +146 -0
- package/src/primitives/ellipsoid.d.ts +13 -0
- package/src/primitives/ellipsoid.js +99 -0
- package/src/primitives/ellipsoid.test.js +216 -0
- package/src/primitives/geodesicSphere.d.ts +10 -0
- package/src/primitives/geodesicSphere.js +140 -0
- package/src/primitives/geodesicSphere.test.js +60 -0
- package/src/primitives/index.d.ts +23 -0
- package/src/primitives/index.js +31 -0
- package/src/primitives/line.d.ts +6 -0
- package/src/primitives/line.js +19 -0
- package/src/primitives/line.test.js +17 -0
- package/src/primitives/polygon.d.ts +12 -0
- package/src/primitives/polygon.js +81 -0
- package/src/primitives/polygon.test.js +63 -0
- package/src/primitives/polyhedron.d.ts +14 -0
- package/src/primitives/polyhedron.js +72 -0
- package/src/primitives/polyhedron.test.js +44 -0
- package/src/primitives/rectangle.d.ts +11 -0
- package/src/primitives/rectangle.js +44 -0
- package/src/primitives/rectangle.test.js +59 -0
- package/src/primitives/roundedCuboid.d.ts +13 -0
- package/src/primitives/roundedCuboid.js +193 -0
- package/src/primitives/roundedCuboid.test.js +248 -0
- package/src/primitives/roundedCylinder.d.ts +14 -0
- package/src/primitives/roundedCylinder.js +147 -0
- package/src/primitives/roundedCylinder.test.js +165 -0
- package/src/primitives/roundedRectangle.d.ts +13 -0
- package/src/primitives/roundedRectangle.js +76 -0
- package/src/primitives/roundedRectangle.test.js +124 -0
- package/src/primitives/sphere.d.ts +13 -0
- package/src/primitives/sphere.js +35 -0
- package/src/primitives/sphere.test.js +172 -0
- package/src/primitives/square.d.ts +11 -0
- package/src/primitives/square.js +31 -0
- package/src/primitives/square.test.js +51 -0
- package/src/primitives/star.d.ts +15 -0
- package/src/primitives/star.js +88 -0
- package/src/primitives/star.test.js +148 -0
- package/src/primitives/torus.d.ts +15 -0
- package/src/primitives/torus.js +64 -0
- package/src/primitives/torus.test.js +59 -0
- package/src/primitives/triangle.d.ts +10 -0
- package/src/primitives/triangle.js +163 -0
- package/src/primitives/triangle.test.js +103 -0
- package/src/text/fonts/single-line/hershey/simplex.js +101 -0
- package/src/text/index.d.ts +4 -0
- package/src/text/index.js +12 -0
- package/src/text/text.test.js +187 -0
- package/src/text/vectorChar.d.ts +22 -0
- package/src/text/vectorChar.js +60 -0
- package/src/text/vectorParams.js +26 -0
- package/src/text/vectorText.d.ts +21 -0
- package/src/text/vectorText.js +92 -0
- package/src/utils/areAllShapesTheSameType.d.ts +5 -0
- package/src/utils/areAllShapesTheSameType.js +25 -0
- package/src/utils/areAllShapesTheSameType.test.js +17 -0
- package/src/utils/corners.d.ts +1 -0
- package/src/utils/degToRad.d.ts +3 -0
- package/src/utils/degToRad.js +9 -0
- package/src/utils/degToRad.test.js +19 -0
- package/src/utils/flatten.d.ts +5 -0
- package/src/utils/flatten.js +25 -0
- package/src/utils/flatten.test.js +94 -0
- package/src/utils/fnNumberSort.d.ts +3 -0
- package/src/utils/fnNumberSort.js +6 -0
- package/src/utils/index.d.ts +9 -0
- package/src/utils/index.js +15 -0
- package/src/utils/insertSorted.d.ts +3 -0
- package/src/utils/insertSorted.js +21 -0
- package/src/utils/padArrayToLength.d.ts +3 -0
- package/src/utils/padArrayToLength.js +17 -0
- package/src/utils/padArrayToLength.test.js +27 -0
- package/src/utils/radToDeg.d.ts +3 -0
- package/src/utils/radToDeg.js +9 -0
- package/src/utils/radToDeg.test.js +19 -0
- package/src/utils/radiusToSegments.d.ts +3 -0
- package/src/utils/radiusToSegments.js +18 -0
- package/src/utils/radiusToSegments.test.js +28 -0
- package/src/utils/recursiveArray.d.ts +3 -0
- package/test/helpers/asserts.js +126 -0
- package/test/helpers/comparePoints.js +16 -0
- package/test/helpers/comparePolygonLists.js +10 -0
- package/test/helpers/comparePolygons.js +16 -0
- package/test/helpers/comparePolygonsAsPoints.js +23 -0
- package/test/helpers/compareVectors.js +36 -0
- package/test/helpers/index.js +8 -0
- package/test/helpers/nearlyEqual.js +34 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
|
|
3
|
+
const { TAU } = require('../../maths/constants')
|
|
4
|
+
|
|
5
|
+
const { geom2, geom3 } = require('../../geometries')
|
|
6
|
+
|
|
7
|
+
const { arc, rectangle } = require('../../primitives')
|
|
8
|
+
|
|
9
|
+
const { extrudeRectangular } = require('./index')
|
|
10
|
+
|
|
11
|
+
test('extrudeRectangular (defaults)', (t) => {
|
|
12
|
+
const geometry1 = arc({ radius: 5, endAngle: TAU / 4, segments: 16 })
|
|
13
|
+
const geometry2 = rectangle({ size: [5, 5] })
|
|
14
|
+
|
|
15
|
+
let obs = extrudeRectangular({ }, geometry1)
|
|
16
|
+
let pts = geom3.toPoints(obs)
|
|
17
|
+
t.notThrows(() => geom3.validate(obs))
|
|
18
|
+
t.is(pts.length, 44)
|
|
19
|
+
|
|
20
|
+
obs = extrudeRectangular({ }, geometry2)
|
|
21
|
+
pts = geom3.toPoints(obs)
|
|
22
|
+
t.notThrows(() => geom3.validate(obs))
|
|
23
|
+
t.is(pts.length, 32)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
test('extrudeRectangular (chamfer)', (t) => {
|
|
27
|
+
const geometry1 = arc({ radius: 5, endAngle: TAU / 4, segments: 16 })
|
|
28
|
+
const geometry2 = rectangle({ size: [5, 5] })
|
|
29
|
+
|
|
30
|
+
let obs = extrudeRectangular({ corners: 'chamfer' }, geometry1)
|
|
31
|
+
let pts = geom3.toPoints(obs)
|
|
32
|
+
t.notThrows(() => geom3.validate(obs))
|
|
33
|
+
t.is(pts.length, 60)
|
|
34
|
+
|
|
35
|
+
obs = extrudeRectangular({ corners: 'chamfer' }, geometry2)
|
|
36
|
+
pts = geom3.toPoints(obs)
|
|
37
|
+
t.notThrows(() => geom3.validate(obs))
|
|
38
|
+
t.is(pts.length, 48)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
test('extrudeRectangular (segments = 8, round)', (t) => {
|
|
42
|
+
const geometry1 = arc({ radius: 5, endAngle: TAU / 4, segments: 16 })
|
|
43
|
+
const geometry2 = rectangle({ size: [5, 5] })
|
|
44
|
+
|
|
45
|
+
let obs = extrudeRectangular({ segments: 8, corners: 'round' }, geometry1)
|
|
46
|
+
let pts = geom3.toPoints(obs)
|
|
47
|
+
t.notThrows(() => geom3.validate(obs))
|
|
48
|
+
t.is(pts.length, 84)
|
|
49
|
+
|
|
50
|
+
obs = extrudeRectangular({ segments: 8, corners: 'round' }, geometry2)
|
|
51
|
+
pts = geom3.toPoints(obs)
|
|
52
|
+
t.notThrows(() => geom3.validate(obs))
|
|
53
|
+
t.is(pts.length, 64)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('extrudeRectangular (holes)', (t) => {
|
|
57
|
+
const geometry2 = geom2.create([
|
|
58
|
+
[[15, 15], [-15, 15]],
|
|
59
|
+
[[-15, 15], [-15, -15]],
|
|
60
|
+
[[-15, -15], [15, -15]],
|
|
61
|
+
[[15, -15], [15, 15]],
|
|
62
|
+
[[-5, 5], [5, 5]],
|
|
63
|
+
[[5, 5], [5, -5]],
|
|
64
|
+
[[5, -5], [-5, -5]],
|
|
65
|
+
[[-5, -5], [-5, 5]]
|
|
66
|
+
])
|
|
67
|
+
|
|
68
|
+
const obs = extrudeRectangular({ size: 2, height: 15, segments: 16, corners: 'round' }, geometry2)
|
|
69
|
+
const pts = geom3.toPoints(obs)
|
|
70
|
+
t.notThrows(() => geom3.validate(obs))
|
|
71
|
+
t.is(pts.length, 192)
|
|
72
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const { area } = require('../../maths/utils')
|
|
2
|
+
|
|
3
|
+
const geom2 = require('../../geometries/geom2')
|
|
4
|
+
const path2 = require('../../geometries/path2')
|
|
5
|
+
|
|
6
|
+
const expand = require('../expansions/expand')
|
|
7
|
+
|
|
8
|
+
const extrudeLinearGeom2 = require('./extrudeLinearGeom2')
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* Expand and extrude the given geometry (geom2).
|
|
12
|
+
* @see expand for additional options
|
|
13
|
+
* @param {Object} options - options for extrusion, if any
|
|
14
|
+
* @param {Number} [options.size=1] - size of the rectangle
|
|
15
|
+
* @param {Number} [options.height=1] - height of the extrusion
|
|
16
|
+
* @param {geom2} geometry - the geometry to extrude
|
|
17
|
+
* @return {geom3} the extruded geometry
|
|
18
|
+
*/
|
|
19
|
+
const extrudeRectangularGeom2 = (options, geometry) => {
|
|
20
|
+
const defaults = {
|
|
21
|
+
size: 1,
|
|
22
|
+
height: 1
|
|
23
|
+
}
|
|
24
|
+
const { size, height } = Object.assign({ }, defaults, options)
|
|
25
|
+
|
|
26
|
+
options.delta = size
|
|
27
|
+
options.offset = [0, 0, height]
|
|
28
|
+
|
|
29
|
+
// convert the geometry to outlines
|
|
30
|
+
const outlines = geom2.toOutlines(geometry)
|
|
31
|
+
if (outlines.length === 0) throw new Error('the given geometry cannot be empty')
|
|
32
|
+
|
|
33
|
+
// expand the outlines
|
|
34
|
+
const newparts = outlines.map((outline) => {
|
|
35
|
+
if (area(outline) < 0) outline.reverse() // all outlines must wind counter clockwise
|
|
36
|
+
return expand(options, path2.fromPoints({ closed: true }, outline))
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// create a composite geometry
|
|
40
|
+
const allsides = newparts.reduce((sides, part) => sides.concat(geom2.toSides(part)), [])
|
|
41
|
+
const newgeometry = geom2.create(allsides)
|
|
42
|
+
|
|
43
|
+
return extrudeLinearGeom2(options, newgeometry)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = extrudeRectangularGeom2
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const path2 = require('../../geometries/path2')
|
|
2
|
+
|
|
3
|
+
const expand = require('../expansions/expand')
|
|
4
|
+
|
|
5
|
+
const extrudeLinearGeom2 = require('./extrudeLinearGeom2')
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* Expand and extrude the given geometry (path2).
|
|
9
|
+
* @See expand for addition options
|
|
10
|
+
* @param {Object} options - options for extrusion, if any
|
|
11
|
+
* @param {Number} [options.size=1] - size of the rectangle
|
|
12
|
+
* @param {Number} [options.height=1] - height of the extrusion
|
|
13
|
+
* @param {path2} geometry - the geometry to extrude
|
|
14
|
+
* @return {geom3} the extruded geometry
|
|
15
|
+
*/
|
|
16
|
+
const extrudeRectangularPath2 = (options, geometry) => {
|
|
17
|
+
const defaults = {
|
|
18
|
+
size: 1,
|
|
19
|
+
height: 1
|
|
20
|
+
}
|
|
21
|
+
const { size, height } = Object.assign({ }, defaults, options)
|
|
22
|
+
|
|
23
|
+
options.delta = size
|
|
24
|
+
options.offset = [0, 0, height]
|
|
25
|
+
|
|
26
|
+
const points = path2.toPoints(geometry)
|
|
27
|
+
if (points.length === 0) throw new Error('the given geometry cannot be empty')
|
|
28
|
+
|
|
29
|
+
const newgeometry = expand(options, geometry)
|
|
30
|
+
return extrudeLinearGeom2(options, newgeometry)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = extrudeRectangularPath2
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Geom2, Geom3 } from '../../geometries/types'
|
|
2
|
+
|
|
3
|
+
export default extrudeRotate
|
|
4
|
+
|
|
5
|
+
export interface ExtrudeRotateOptions {
|
|
6
|
+
angle?: number
|
|
7
|
+
startAngle?: number
|
|
8
|
+
overflow?: 'cap'
|
|
9
|
+
segments?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare function extrudeRotate(options: ExtrudeRotateOptions, geometry: Geom2): Geom3
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const { TAU } = require('../../maths/constants')
|
|
2
|
+
const mat4 = require('../../maths/mat4')
|
|
3
|
+
|
|
4
|
+
const { mirrorX } = require('../transforms/mirror')
|
|
5
|
+
|
|
6
|
+
const geom2 = require('../../geometries/geom2')
|
|
7
|
+
|
|
8
|
+
const slice = require('./slice')
|
|
9
|
+
|
|
10
|
+
const extrudeFromSlices = require('./extrudeFromSlices')
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Rotate extrude the given geometry using the given options.
|
|
14
|
+
*
|
|
15
|
+
* @param {Object} options - options for extrusion
|
|
16
|
+
* @param {Number} [options.angle=TAU] - angle of the extrusion (RADIANS)
|
|
17
|
+
* @param {Number} [options.startAngle=0] - start angle of the extrusion (RADIANS)
|
|
18
|
+
* @param {String} [options.overflow='cap'] - what to do with points outside of bounds (+ / - x) :
|
|
19
|
+
* defaults to capping those points to 0 (only supported behaviour for now)
|
|
20
|
+
* @param {Number} [options.segments=12] - number of segments of the extrusion
|
|
21
|
+
* @param {geom2} geometry - the geometry to extrude
|
|
22
|
+
* @returns {geom3} the extruded geometry
|
|
23
|
+
* @alias module:modeling/extrusions.extrudeRotate
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* const myshape = extrudeRotate({segments: 8, angle: TAU / 2}, circle({size: 3, center: [4, 0]}))
|
|
27
|
+
*/
|
|
28
|
+
const extrudeRotate = (options, geometry) => {
|
|
29
|
+
const defaults = {
|
|
30
|
+
segments: 12,
|
|
31
|
+
startAngle: 0,
|
|
32
|
+
angle: TAU,
|
|
33
|
+
overflow: 'cap'
|
|
34
|
+
}
|
|
35
|
+
let { segments, startAngle, angle, overflow } = Object.assign({}, defaults, options)
|
|
36
|
+
|
|
37
|
+
if (segments < 3) throw new Error('segments must be greater then 3')
|
|
38
|
+
|
|
39
|
+
startAngle = Math.abs(startAngle) > TAU ? startAngle % TAU : startAngle
|
|
40
|
+
angle = Math.abs(angle) > TAU ? angle % TAU : angle
|
|
41
|
+
|
|
42
|
+
let endAngle = startAngle + angle
|
|
43
|
+
endAngle = Math.abs(endAngle) > TAU ? endAngle % TAU : endAngle
|
|
44
|
+
|
|
45
|
+
if (endAngle < startAngle) {
|
|
46
|
+
const x = startAngle
|
|
47
|
+
startAngle = endAngle
|
|
48
|
+
endAngle = x
|
|
49
|
+
}
|
|
50
|
+
let totalRotation = endAngle - startAngle
|
|
51
|
+
if (totalRotation <= 0.0) totalRotation = TAU
|
|
52
|
+
|
|
53
|
+
if (Math.abs(totalRotation) < TAU) {
|
|
54
|
+
// adjust the segments to achieve the total rotation requested
|
|
55
|
+
const anglePerSegment = TAU / segments
|
|
56
|
+
segments = Math.floor(Math.abs(totalRotation) / anglePerSegment)
|
|
57
|
+
if (Math.abs(totalRotation) > (segments * anglePerSegment)) segments++
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// console.log('startAngle: '+startAngle)
|
|
61
|
+
// console.log('endAngle: '+endAngle)
|
|
62
|
+
// console.log(totalRotation)
|
|
63
|
+
// console.log(segments)
|
|
64
|
+
|
|
65
|
+
// convert geometry to an array of sides, easier to deal with
|
|
66
|
+
let shapeSides = geom2.toSides(geometry)
|
|
67
|
+
if (shapeSides.length === 0) throw new Error('the given geometry cannot be empty')
|
|
68
|
+
|
|
69
|
+
// determine if the rotate extrude can be computed in the first place
|
|
70
|
+
// ie all the points have to be either x > 0 or x < 0
|
|
71
|
+
|
|
72
|
+
// generic solution to always have a valid solid, even if points go beyond x/ -x
|
|
73
|
+
// 1. split points up between all those on the 'left' side of the axis (x<0) & those on the 'righ' (x>0)
|
|
74
|
+
// 2. for each set of points do the extrusion operation IN OPOSITE DIRECTIONS
|
|
75
|
+
// 3. union the two resulting solids
|
|
76
|
+
|
|
77
|
+
// 1. alt : OR : just cap of points at the axis ?
|
|
78
|
+
|
|
79
|
+
const pointsWithNegativeX = shapeSides.filter((s) => (s[0][0] < 0))
|
|
80
|
+
const pointsWithPositiveX = shapeSides.filter((s) => (s[0][0] >= 0))
|
|
81
|
+
const arePointsWithNegAndPosX = pointsWithNegativeX.length > 0 && pointsWithPositiveX.length > 0
|
|
82
|
+
|
|
83
|
+
// FIXME actually there are cases where setting X=0 will change the basic shape
|
|
84
|
+
// - Alternative #1 : don't allow shapes with both negative and positive X values
|
|
85
|
+
// - Alternative #2 : remove one half of the shape (costly)
|
|
86
|
+
if (arePointsWithNegAndPosX && overflow === 'cap') {
|
|
87
|
+
if (pointsWithNegativeX.length > pointsWithPositiveX.length) {
|
|
88
|
+
shapeSides = shapeSides.map((side) => {
|
|
89
|
+
let point0 = side[0]
|
|
90
|
+
let point1 = side[1]
|
|
91
|
+
point0 = [Math.min(point0[0], 0), point0[1]]
|
|
92
|
+
point1 = [Math.min(point1[0], 0), point1[1]]
|
|
93
|
+
return [point0, point1]
|
|
94
|
+
})
|
|
95
|
+
// recreate the geometry from the (-) capped points
|
|
96
|
+
geometry = geom2.create(shapeSides)
|
|
97
|
+
geometry = mirrorX(geometry)
|
|
98
|
+
} else if (pointsWithPositiveX.length >= pointsWithNegativeX.length) {
|
|
99
|
+
shapeSides = shapeSides.map((side) => {
|
|
100
|
+
let point0 = side[0]
|
|
101
|
+
let point1 = side[1]
|
|
102
|
+
point0 = [Math.max(point0[0], 0), point0[1]]
|
|
103
|
+
point1 = [Math.max(point1[0], 0), point1[1]]
|
|
104
|
+
return [point0, point1]
|
|
105
|
+
})
|
|
106
|
+
// recreate the geometry from the (+) capped points
|
|
107
|
+
geometry = geom2.create(shapeSides)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const rotationPerSlice = totalRotation / segments
|
|
112
|
+
const isCapped = Math.abs(totalRotation) < TAU
|
|
113
|
+
const baseSlice = slice.fromSides(geom2.toSides(geometry))
|
|
114
|
+
slice.reverse(baseSlice, baseSlice)
|
|
115
|
+
|
|
116
|
+
const matrix = mat4.create()
|
|
117
|
+
const createSlice = (progress, index, base) => {
|
|
118
|
+
let Zrotation = rotationPerSlice * index + startAngle
|
|
119
|
+
// fix rounding error when rotating TAU radians
|
|
120
|
+
if (totalRotation === TAU && index === segments) {
|
|
121
|
+
Zrotation = startAngle
|
|
122
|
+
}
|
|
123
|
+
mat4.multiply(matrix, mat4.fromZRotation(matrix, Zrotation), mat4.fromXRotation(mat4.create(), TAU / 4))
|
|
124
|
+
|
|
125
|
+
return slice.transform(matrix, base)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
options = {
|
|
129
|
+
numberOfSlices: segments + 1,
|
|
130
|
+
capStart: isCapped,
|
|
131
|
+
capEnd: isCapped,
|
|
132
|
+
close: !isCapped,
|
|
133
|
+
callback: createSlice
|
|
134
|
+
}
|
|
135
|
+
return extrudeFromSlices(options, baseSlice)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
module.exports = extrudeRotate
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
|
|
3
|
+
const { comparePoints, comparePolygonsAsPoints } = require('../../../test/helpers')
|
|
4
|
+
|
|
5
|
+
const { TAU } = require('../../maths/constants')
|
|
6
|
+
|
|
7
|
+
const { geom2, geom3 } = require('../../geometries')
|
|
8
|
+
|
|
9
|
+
const { extrudeRotate } = require('./index')
|
|
10
|
+
|
|
11
|
+
test('extrudeRotate: (defaults) extruding of a geom2 produces an expected geom3', (t) => {
|
|
12
|
+
const geometry2 = geom2.fromPoints([[10, 8], [10, -8], [26, -8], [26, 8]])
|
|
13
|
+
|
|
14
|
+
const geometry3 = extrudeRotate({ }, geometry2)
|
|
15
|
+
const pts = geom3.toPoints(geometry3)
|
|
16
|
+
t.notThrows(() => geom3.validate(geometry3))
|
|
17
|
+
t.is(pts.length, 96)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('extrudeRotate: (angle) extruding of a geom2 produces an expected geom3', (t) => {
|
|
21
|
+
const geometry2 = geom2.fromPoints([[10, 8], [10, -8], [26, -8], [26, 8]])
|
|
22
|
+
|
|
23
|
+
// test angle
|
|
24
|
+
let geometry3 = extrudeRotate({ segments: 4, angle: TAU / 8 }, geometry2)
|
|
25
|
+
let pts = geom3.toPoints(geometry3)
|
|
26
|
+
const exp = [
|
|
27
|
+
[[10, 0, 8], [26, 0, 8], [18.38477631085024, 18.384776310850235, 8]],
|
|
28
|
+
[[10, 0, 8], [18.38477631085024, 18.384776310850235, 8], [7.0710678118654755, 7.071067811865475, 8]],
|
|
29
|
+
[[10, 0, -8], [10, 0, 8], [7.0710678118654755, 7.071067811865475, 8]],
|
|
30
|
+
[[10, 0, -8], [7.0710678118654755, 7.071067811865475, 8], [7.0710678118654755, 7.071067811865475, -8]],
|
|
31
|
+
[[26, 0, -8], [10, 0, -8], [7.0710678118654755, 7.071067811865475, -8]],
|
|
32
|
+
[[26, 0, -8], [7.0710678118654755, 7.071067811865475, -8], [18.38477631085024, 18.384776310850235, -8]],
|
|
33
|
+
[[26, 0, 8], [26, 0, -8], [18.38477631085024, 18.384776310850235, -8]],
|
|
34
|
+
[[26, 0, 8], [18.38477631085024, 18.384776310850235, -8], [18.38477631085024, 18.384776310850235, 8]],
|
|
35
|
+
[[7.0710678118654755, 7.071067811865475, -8], [7.0710678118654755, 7.071067811865475, 8], [18.38477631085024, 18.384776310850235, 8]],
|
|
36
|
+
[[18.38477631085024, 18.384776310850235, 8], [18.38477631085024, 18.384776310850235, -8], [7.0710678118654755, 7.071067811865475, -8]],
|
|
37
|
+
[[26, 0, 8], [10, 0, 8], [10, 0, -8]],
|
|
38
|
+
[[10, 0, -8], [26, 0, -8], [26, 0, 8]]
|
|
39
|
+
]
|
|
40
|
+
t.notThrows(() => geom3.validate(geometry3))
|
|
41
|
+
t.is(pts.length, 12)
|
|
42
|
+
t.true(comparePolygonsAsPoints(pts, exp))
|
|
43
|
+
|
|
44
|
+
geometry3 = extrudeRotate({ segments: 4, angle: -250 * 0.017453292519943295 }, geometry2)
|
|
45
|
+
pts = geom3.toPoints(geometry3)
|
|
46
|
+
t.notThrows(() => geom3.validate(geometry3))
|
|
47
|
+
t.is(pts.length, 28)
|
|
48
|
+
|
|
49
|
+
geometry3 = extrudeRotate({ segments: 4, angle: 250 * 0.017453292519943295 }, geometry2)
|
|
50
|
+
pts = geom3.toPoints(geometry3)
|
|
51
|
+
t.notThrows(() => geom3.validate(geometry3))
|
|
52
|
+
t.is(pts.length, 28)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('extrudeRotate: (startAngle) extruding of a geom2 produces an expected geom3', (t) => {
|
|
56
|
+
const geometry2 = geom2.fromPoints([[10, 8], [10, -8], [26, -8], [26, 8]])
|
|
57
|
+
|
|
58
|
+
// test startAngle
|
|
59
|
+
let geometry3 = extrudeRotate({ segments: 5, startAngle: TAU / 8 }, geometry2)
|
|
60
|
+
let pts = geom3.toPoints(geometry3)
|
|
61
|
+
let exp = [
|
|
62
|
+
[7.0710678118654755, 7.071067811865475, 8],
|
|
63
|
+
[18.38477631085024, 18.384776310850235, 8],
|
|
64
|
+
[-11.803752993228215, 23.166169628897567, 8]
|
|
65
|
+
]
|
|
66
|
+
t.notThrows(() => geom3.validate(geometry3))
|
|
67
|
+
t.is(pts.length, 40)
|
|
68
|
+
t.true(comparePoints(pts[0], exp))
|
|
69
|
+
|
|
70
|
+
geometry3 = extrudeRotate({ segments: 5, startAngle: -TAU / 8 }, geometry2)
|
|
71
|
+
pts = geom3.toPoints(geometry3)
|
|
72
|
+
exp = [
|
|
73
|
+
[7.0710678118654755, -7.071067811865475, 8],
|
|
74
|
+
[18.38477631085024, -18.384776310850235, 8],
|
|
75
|
+
[23.166169628897567, 11.803752993228215, 8]
|
|
76
|
+
]
|
|
77
|
+
t.notThrows(() => geom3.validate(geometry3))
|
|
78
|
+
t.is(pts.length, 40)
|
|
79
|
+
t.true(comparePoints(pts[0], exp))
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
test('extrudeRotate: (segments) extruding of a geom2 produces an expected geom3', (t) => {
|
|
83
|
+
let geometry2 = geom2.fromPoints([[10, 8], [10, -8], [26, -8], [26, 8]])
|
|
84
|
+
|
|
85
|
+
// test segments
|
|
86
|
+
let geometry3 = extrudeRotate({ segments: 4 }, geometry2)
|
|
87
|
+
let pts = geom3.toPoints(geometry3)
|
|
88
|
+
t.notThrows(() => geom3.validate(geometry3))
|
|
89
|
+
t.is(pts.length, 32)
|
|
90
|
+
|
|
91
|
+
geometry3 = extrudeRotate({ segments: 64 }, geometry2)
|
|
92
|
+
pts = geom3.toPoints(geometry3)
|
|
93
|
+
t.notThrows(() => geom3.validate(geometry3))
|
|
94
|
+
t.is(pts.length, 512)
|
|
95
|
+
|
|
96
|
+
// test overlapping edges
|
|
97
|
+
geometry2 = geom2.fromPoints([[0, 0], [2, 1], [1, 2], [1, 3], [3, 4], [0, 5]])
|
|
98
|
+
geometry3 = extrudeRotate({ segments: 8 }, geometry2)
|
|
99
|
+
pts = geom3.toPoints(geometry3)
|
|
100
|
+
t.notThrows(() => geom3.validate(geometry3))
|
|
101
|
+
t.is(pts.length, 64)
|
|
102
|
+
|
|
103
|
+
// test overlapping edges that produce hollow shape
|
|
104
|
+
geometry2 = geom2.fromPoints([[30, 0], [30, 60], [0, 60], [0, 50], [10, 40], [10, 30], [0, 20], [0, 10], [10, 0]])
|
|
105
|
+
geometry3 = extrudeRotate({ segments: 8 }, geometry2)
|
|
106
|
+
pts = geom3.toPoints(geometry3)
|
|
107
|
+
t.notThrows(() => geom3.validate(geometry3))
|
|
108
|
+
t.is(pts.length, 80)
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
test('extrudeRotate: (overlap +/-) extruding of a geom2 produces an expected geom3', (t) => {
|
|
112
|
+
// overlap of Y axis; even number of + and - points
|
|
113
|
+
let geometry = geom2.fromPoints([[-1, 8], [-1, -8], [7, -8], [7, 8]])
|
|
114
|
+
|
|
115
|
+
let obs = extrudeRotate({ segments: 4, angle: TAU / 4 }, geometry)
|
|
116
|
+
let pts = geom3.toPoints(obs)
|
|
117
|
+
let exp = [
|
|
118
|
+
[[0, 0, 8], [7, 0, 8], [0, 7, 8]],
|
|
119
|
+
[[7, 0, -8], [0, 0, -8], [0, 7, -8]],
|
|
120
|
+
[[7, 0, 8], [7, 0, -8], [0, 7, -8]],
|
|
121
|
+
[[7, 0, 8], [0, 7, -8], [0, 7, 8]],
|
|
122
|
+
[[0, 0, -8], [0, 0, 8], [0, 7, 8]],
|
|
123
|
+
[[0, 7, 8], [0, 7, -8], [0, 0, -8]],
|
|
124
|
+
[[7, 0, 8], [0, 0, 8], [0, 0, -8]],
|
|
125
|
+
[[0, 0, -8], [7, 0, -8], [7, 0, 8]]
|
|
126
|
+
]
|
|
127
|
+
t.notThrows(() => geom3.validate(obs))
|
|
128
|
+
t.is(pts.length, 8)
|
|
129
|
+
t.true(comparePolygonsAsPoints(pts, exp))
|
|
130
|
+
|
|
131
|
+
// overlap of Y axis; larger number of - points
|
|
132
|
+
geometry = geom2.fromPoints([[-1, 8], [-2, 4], [-1, -8], [7, -8], [7, 8]])
|
|
133
|
+
|
|
134
|
+
obs = extrudeRotate({ segments: 8, angle: TAU / 4 }, geometry)
|
|
135
|
+
pts = geom3.toPoints(obs)
|
|
136
|
+
exp = [
|
|
137
|
+
[[1, 0, -8], [0, 0, -8], [0.7071067811865476, 0.7071067811865475, -8]],
|
|
138
|
+
[[2, 0, 4], [1, 0, -8], [0.7071067811865476, 0.7071067811865475, -8]],
|
|
139
|
+
[[2, 0, 4], [0.7071067811865476, 0.7071067811865475, -8], [1.4142135623730951, 1.414213562373095, 4]],
|
|
140
|
+
[[1, 0, 8], [2, 0, 4], [1.4142135623730951, 1.414213562373095, 4]],
|
|
141
|
+
[[1, 0, 8], [1.4142135623730951, 1.414213562373095, 4], [0.7071067811865476, 0.7071067811865475, 8]],
|
|
142
|
+
[[0, 0, 8], [1, 0, 8], [0.7071067811865476, 0.7071067811865475, 8]],
|
|
143
|
+
[[0.7071067811865476, 0.7071067811865475, -8], [0, 0, -8], [0, 1, -8]],
|
|
144
|
+
[[1.4142135623730951, 1.414213562373095, 4], [0.7071067811865476, 0.7071067811865475, -8], [0, 1, -8]],
|
|
145
|
+
[[1.4142135623730951, 1.414213562373095, 4], [0, 1, -8], [0, 2, 4]],
|
|
146
|
+
[[0.7071067811865476, 0.7071067811865475, 8], [1.4142135623730951, 1.414213562373095, 4], [0, 2, 4]],
|
|
147
|
+
[[0.7071067811865476, 0.7071067811865475, 8], [0, 2, 4], [0, 1, 8]],
|
|
148
|
+
[[0, 0, 8], [0.7071067811865476, 0.7071067811865475, 8], [0, 1, 8]],
|
|
149
|
+
[[0, 1, -8], [0, 0, -8], [0, 0, 8]],
|
|
150
|
+
[[0, 0, 8], [0, 1, 8], [0, 2, 4]],
|
|
151
|
+
[[0, 2, 4], [0, 1, -8], [0, 0, 8]],
|
|
152
|
+
[[0, 0, 8], [0, 0, -8], [1, 0, -8]],
|
|
153
|
+
[[2, 0, 4], [1, 0, 8], [0, 0, 8]],
|
|
154
|
+
[[0, 0, 8], [1, 0, -8], [2, 0, 4]]
|
|
155
|
+
]
|
|
156
|
+
t.notThrows(() => geom3.validate(obs))
|
|
157
|
+
t.is(pts.length, 18)
|
|
158
|
+
t.true(comparePolygonsAsPoints(pts, exp))
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
// TEST HOLES
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
const { EPS } = require('../../maths/constants')
|
|
2
|
+
const vec3 = require('../../maths/vec3')
|
|
3
|
+
|
|
4
|
+
const poly3 = require('../../geometries/poly3')
|
|
5
|
+
|
|
6
|
+
const slice = require('./slice')
|
|
7
|
+
|
|
8
|
+
// https://en.wikipedia.org/wiki/Greatest_common_divisor#Using_Euclid's_algorithm
|
|
9
|
+
const gcd = (a, b) => {
|
|
10
|
+
if (a === b) { return a }
|
|
11
|
+
if (a < b) { return gcd(b, a) }
|
|
12
|
+
if (b === 1) { return 1 }
|
|
13
|
+
if (b === 0) { return a }
|
|
14
|
+
return gcd(b, a % b)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const lcm = (a, b) => (a * b) / gcd(a, b)
|
|
18
|
+
|
|
19
|
+
// Return a set of edges that encloses the same area by splitting
|
|
20
|
+
// the given edges to have newlength total edges.
|
|
21
|
+
const repartitionEdges = (newlength, edges) => {
|
|
22
|
+
// NOTE: This implementation splits each edge evenly.
|
|
23
|
+
const multiple = newlength / edges.length
|
|
24
|
+
if (multiple === 1) {
|
|
25
|
+
return edges
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const divisor = vec3.fromValues(multiple, multiple, multiple)
|
|
29
|
+
|
|
30
|
+
const newEdges = []
|
|
31
|
+
edges.forEach((edge) => {
|
|
32
|
+
const increment = vec3.subtract(vec3.create(), edge[1], edge[0])
|
|
33
|
+
vec3.divide(increment, increment, divisor)
|
|
34
|
+
|
|
35
|
+
// repartition the edge
|
|
36
|
+
let prev = edge[0]
|
|
37
|
+
for (let i = 1; i <= multiple; ++i) {
|
|
38
|
+
const next = vec3.add(vec3.create(), prev, increment)
|
|
39
|
+
newEdges.push([prev, next])
|
|
40
|
+
prev = next
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
return newEdges
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const EPSAREA = (EPS * EPS / 2) * Math.sin(Math.PI / 3)
|
|
47
|
+
|
|
48
|
+
/*
|
|
49
|
+
* Extrude (build) walls between the given slices.
|
|
50
|
+
* Each wall consists of two triangles, which may be invalid if slices are overlapping.
|
|
51
|
+
*/
|
|
52
|
+
const extrudeWalls = (slice0, slice1) => {
|
|
53
|
+
let edges0 = slice.toEdges(slice0)
|
|
54
|
+
let edges1 = slice.toEdges(slice1)
|
|
55
|
+
|
|
56
|
+
if (edges0.length !== edges1.length) {
|
|
57
|
+
// different shapes, so adjust one or both to the same number of edges
|
|
58
|
+
const newlength = lcm(edges0.length, edges1.length)
|
|
59
|
+
if (newlength !== edges0.length) edges0 = repartitionEdges(newlength, edges0)
|
|
60
|
+
if (newlength !== edges1.length) edges1 = repartitionEdges(newlength, edges1)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const walls = []
|
|
64
|
+
edges0.forEach((edge0, i) => {
|
|
65
|
+
const edge1 = edges1[i]
|
|
66
|
+
|
|
67
|
+
const poly0 = poly3.create([edge0[0], edge0[1], edge1[1]])
|
|
68
|
+
const poly0area = poly3.measureArea(poly0)
|
|
69
|
+
if (Number.isFinite(poly0area) && poly0area > EPSAREA) walls.push(poly0)
|
|
70
|
+
|
|
71
|
+
const poly1 = poly3.create([edge0[0], edge1[1], edge1[0]])
|
|
72
|
+
const poly1area = poly3.measureArea(poly1)
|
|
73
|
+
if (Number.isFinite(poly1area) && poly1area > EPSAREA) walls.push(poly1)
|
|
74
|
+
})
|
|
75
|
+
return walls
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
module.exports = extrudeWalls
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
const test = require('ava')
|
|
2
|
+
|
|
3
|
+
const { mat4 } = require('../../maths')
|
|
4
|
+
|
|
5
|
+
const slice = require('./slice')
|
|
6
|
+
|
|
7
|
+
const extrudeWalls = require('./extrudeWalls')
|
|
8
|
+
|
|
9
|
+
test('extrudeWalls (same shapes)', (t) => {
|
|
10
|
+
const matrix = mat4.fromTranslation(mat4.create(), [0, 0, 10])
|
|
11
|
+
|
|
12
|
+
const shape0 = []
|
|
13
|
+
const shape1 = [
|
|
14
|
+
[[-10.0, 10.0], [-10.0, -10.0]],
|
|
15
|
+
[[-10.0, -10.0], [10.0, -10.0]],
|
|
16
|
+
[[10.0, -10.0], [10.0, 10.0]],
|
|
17
|
+
[[10.0, 10.0], [-10.0, 10.0]]
|
|
18
|
+
]
|
|
19
|
+
const shape2 = [ // hole
|
|
20
|
+
[[-10.0, 10.0], [-10.0, -10.0]],
|
|
21
|
+
[[-10.0, -10.0], [10.0, -10.0]],
|
|
22
|
+
[[10.0, -10.0], [10.0, 10.0]],
|
|
23
|
+
[[10.0, 10.0], [-10.0, 10.0]],
|
|
24
|
+
[[-5.0, -5.0], [-5.0, 5.0]],
|
|
25
|
+
[[5.0, -5.0], [-5.0, -5.0]],
|
|
26
|
+
[[5.0, 5.0], [5.0, -5.0]],
|
|
27
|
+
[[-5.0, 5.0], [5.0, 5.0]]
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
const slice0 = slice.fromSides(shape0)
|
|
31
|
+
const slice1 = slice.fromSides(shape1)
|
|
32
|
+
const slice2 = slice.fromSides(shape2)
|
|
33
|
+
|
|
34
|
+
// empty slices
|
|
35
|
+
let walls = extrudeWalls(slice0, slice0)
|
|
36
|
+
t.is(walls.length, 0)
|
|
37
|
+
|
|
38
|
+
// outline slices
|
|
39
|
+
walls = extrudeWalls(slice1, slice.transform(matrix, slice1))
|
|
40
|
+
t.is(walls.length, 8)
|
|
41
|
+
|
|
42
|
+
// slices with holes
|
|
43
|
+
walls = extrudeWalls(slice2, slice.transform(matrix, slice2))
|
|
44
|
+
t.is(walls.length, 16)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
test('extrudeWalls (different shapes)', (t) => {
|
|
48
|
+
const matrix = mat4.fromTranslation(mat4.create(), [0, 0, 10])
|
|
49
|
+
|
|
50
|
+
const shape1 = [
|
|
51
|
+
[[-10.0, 10.0], [-10.0, -10.0]],
|
|
52
|
+
[[-10.0, -10.0], [10.0, -10.0]],
|
|
53
|
+
[[10.0, -10.0], [10.0, 10.0]]
|
|
54
|
+
]
|
|
55
|
+
const shape2 = [
|
|
56
|
+
[[-10.0, 10.0], [-10.0, -10.0]],
|
|
57
|
+
[[-10.0, -10.0], [10.0, -10.0]],
|
|
58
|
+
[[10.0, -10.0], [10.0, 10.0]],
|
|
59
|
+
[[10.0, 10.0], [-10.0, 10.0]]
|
|
60
|
+
]
|
|
61
|
+
const shape3 = [
|
|
62
|
+
[[2.50000, -4.33013], [5.00000, 0.00000]],
|
|
63
|
+
[[5.00000, 0.00000], [2.50000, 4.33013]],
|
|
64
|
+
[[2.50000, 4.33013], [-2.50000, 4.33013]],
|
|
65
|
+
[[-2.50000, 4.33013], [-5.00000, 0.00000]],
|
|
66
|
+
[[-5.00000, 0.00000], [-2.50000, -4.33013]],
|
|
67
|
+
[[-2.50000, -4.33013], [2.50000, -4.33013]]
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
const slice1 = slice.fromSides(shape1)
|
|
71
|
+
const slice2 = slice.fromSides(shape2)
|
|
72
|
+
const slice3 = slice.fromSides(shape3)
|
|
73
|
+
|
|
74
|
+
let walls = extrudeWalls(slice1, slice.transform(matrix, slice2))
|
|
75
|
+
t.is(walls.length, 24)
|
|
76
|
+
|
|
77
|
+
walls = extrudeWalls(slice1, slice.transform(matrix, slice3))
|
|
78
|
+
t.is(walls.length, 12)
|
|
79
|
+
|
|
80
|
+
walls = extrudeWalls(slice3, slice.transform(matrix, slice2))
|
|
81
|
+
t.is(walls.length, 24)
|
|
82
|
+
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { default as extrudeFromSlices, ExtrudeFromSlicesOptions } from './extrudeFromSlices'
|
|
2
|
+
export { default as extrudeLinear, ExtrudeLinearOptions } from './extrudeLinear'
|
|
3
|
+
export { default as extrudeRectangular, ExtrudeRectangularOptions } from './extrudeRectangular'
|
|
4
|
+
export { default as extrudeRotate, ExtrudeRotateOptions } from './extrudeRotate'
|
|
5
|
+
export { default as extrudeHelical, ExtrudeHelicalOptions } from './extrudeHelical'
|
|
6
|
+
export { default as project, ProjectOptions } from './project'
|
|
7
|
+
export * as slice from './slice'
|
|
8
|
+
|
|
9
|
+
export as namespace extrusions
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* All 2D shapes (primitives or the results of operations) can be extruded in various ways.
|
|
3
|
+
* In all cases, the function returns the results, and never changes the original shapes.
|
|
4
|
+
* @module modeling/extrusions
|
|
5
|
+
* @example
|
|
6
|
+
* const { extrudeHelical, extrudeLinear, extrudeRectangular, extrudeRotate, project, slice } = require('@jscad/modeling').extrusions
|
|
7
|
+
*/
|
|
8
|
+
module.exports = {
|
|
9
|
+
extrudeFromSlices: require('./extrudeFromSlices'),
|
|
10
|
+
extrudeLinear: require('./extrudeLinear'),
|
|
11
|
+
extrudeRectangular: require('./extrudeRectangular'),
|
|
12
|
+
extrudeRotate: require('./extrudeRotate'),
|
|
13
|
+
extrudeHelical: require('./extrudeHelical'),
|
|
14
|
+
project: require('./project'),
|
|
15
|
+
slice: require('./slice')
|
|
16
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Geom2, Geom3 } from '../../geometries/types'
|
|
2
|
+
import { Vec3 } from '../../maths/vec3'
|
|
3
|
+
import RecursiveArray from '../../utils/recursiveArray'
|
|
4
|
+
|
|
5
|
+
export default project
|
|
6
|
+
|
|
7
|
+
export interface ProjectOptions {
|
|
8
|
+
axis?: Vec3
|
|
9
|
+
origin?: Vec3
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare function project(options: ProjectOptions, geometry: Geom3): Geom2
|
|
13
|
+
declare function project(options: ProjectOptions, ...geometries: RecursiveArray<Geom3>): Array<Geom2>
|
|
14
|
+
declare function project(options: ProjectOptions, ...geometries: RecursiveArray<any>): Array<any>
|