fluidcad 0.0.2
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/LICENSE.txt +504 -0
- package/README.md +175 -0
- package/bin/fluidcad.js +94 -0
- package/bin/watcher.js +55 -0
- package/lib/dist/common/edge.d.ts +14 -0
- package/lib/dist/common/edge.js +32 -0
- package/lib/dist/common/face.d.ts +31 -0
- package/lib/dist/common/face.js +83 -0
- package/lib/dist/common/materials.d.ts +7 -0
- package/lib/dist/common/materials.js +22 -0
- package/lib/dist/common/scene-object.d.ts +111 -0
- package/lib/dist/common/scene-object.js +380 -0
- package/lib/dist/common/shape-factory.d.ts +8 -0
- package/lib/dist/common/shape-factory.js +31 -0
- package/lib/dist/common/shape-type.d.ts +1 -0
- package/lib/dist/common/shape-type.js +1 -0
- package/lib/dist/common/shape.d.ts +43 -0
- package/lib/dist/common/shape.js +95 -0
- package/lib/dist/common/shapes.d.ts +6 -0
- package/lib/dist/common/shapes.js +6 -0
- package/lib/dist/common/solid-face.d.ts +9 -0
- package/lib/dist/common/solid-face.js +22 -0
- package/lib/dist/common/solid.d.ts +20 -0
- package/lib/dist/common/solid.js +68 -0
- package/lib/dist/common/vertex.d.ts +17 -0
- package/lib/dist/common/vertex.js +44 -0
- package/lib/dist/common/wire.d.ts +22 -0
- package/lib/dist/common/wire.js +97 -0
- package/lib/dist/constraints/constraint.d.ts +11 -0
- package/lib/dist/constraints/constraint.js +51 -0
- package/lib/dist/constraints/outside.d.ts +3 -0
- package/lib/dist/constraints/outside.js +4 -0
- package/lib/dist/core/2d/aline.d.ts +28 -0
- package/lib/dist/core/2d/aline.js +26 -0
- package/lib/dist/core/2d/arc.d.ts +77 -0
- package/lib/dist/core/2d/arc.js +49 -0
- package/lib/dist/core/2d/aslot.d.ts +12 -0
- package/lib/dist/core/2d/aslot.js +40 -0
- package/lib/dist/core/2d/bezier.d.ts +16 -0
- package/lib/dist/core/2d/bezier.js +15 -0
- package/lib/dist/core/2d/circle.d.ts +24 -0
- package/lib/dist/core/2d/circle.js +44 -0
- package/lib/dist/core/2d/connect.d.ts +11 -0
- package/lib/dist/core/2d/connect.js +10 -0
- package/lib/dist/core/2d/crect.d.ts +12 -0
- package/lib/dist/core/2d/crect.js +74 -0
- package/lib/dist/core/2d/face-driller.d.ts +8 -0
- package/lib/dist/core/2d/face-driller.js +70 -0
- package/lib/dist/core/2d/face-maker.d.ts +13 -0
- package/lib/dist/core/2d/face-maker.js +119 -0
- package/lib/dist/core/2d/face-maker2.d.ts +6 -0
- package/lib/dist/core/2d/face-maker2.js +54 -0
- package/lib/dist/core/2d/hline.d.ts +33 -0
- package/lib/dist/core/2d/hline.js +37 -0
- package/lib/dist/core/2d/hmove.d.ts +9 -0
- package/lib/dist/core/2d/hmove.js +11 -0
- package/lib/dist/core/2d/index.d.ts +22 -0
- package/lib/dist/core/2d/index.js +22 -0
- package/lib/dist/core/2d/line.d.ts +24 -0
- package/lib/dist/core/2d/line.js +40 -0
- package/lib/dist/core/2d/move.d.ts +13 -0
- package/lib/dist/core/2d/move.js +13 -0
- package/lib/dist/core/2d/offset.d.ts +21 -0
- package/lib/dist/core/2d/offset.js +24 -0
- package/lib/dist/core/2d/pmove.d.ts +11 -0
- package/lib/dist/core/2d/pmove.js +12 -0
- package/lib/dist/core/2d/polygon.d.ts +38 -0
- package/lib/dist/core/2d/polygon.js +63 -0
- package/lib/dist/core/2d/project.d.ts +17 -0
- package/lib/dist/core/2d/project.js +20 -0
- package/lib/dist/core/2d/rect.d.ts +27 -0
- package/lib/dist/core/2d/rect.js +58 -0
- package/lib/dist/core/2d/rmove.d.ts +17 -0
- package/lib/dist/core/2d/rmove.js +14 -0
- package/lib/dist/core/2d/slot.d.ts +49 -0
- package/lib/dist/core/2d/slot.js +65 -0
- package/lib/dist/core/2d/tarc.d.ts +46 -0
- package/lib/dist/core/2d/tarc.js +61 -0
- package/lib/dist/core/2d/tcircle.d.ts +15 -0
- package/lib/dist/core/2d/tcircle.js +24 -0
- package/lib/dist/core/2d/tline.d.ts +24 -0
- package/lib/dist/core/2d/tline.js +30 -0
- package/lib/dist/core/2d/vline.d.ts +33 -0
- package/lib/dist/core/2d/vline.js +37 -0
- package/lib/dist/core/2d/vmove.d.ts +9 -0
- package/lib/dist/core/2d/vmove.js +11 -0
- package/lib/dist/core/2d/wire.d.ts +11 -0
- package/lib/dist/core/2d/wire.js +29 -0
- package/lib/dist/core/axis.d.ts +41 -0
- package/lib/dist/core/axis.js +104 -0
- package/lib/dist/core/chamfer.d.ts +31 -0
- package/lib/dist/core/chamfer.js +32 -0
- package/lib/dist/core/color.d.ts +16 -0
- package/lib/dist/core/color.js +19 -0
- package/lib/dist/core/common.d.ts +12 -0
- package/lib/dist/core/common.js +36 -0
- package/lib/dist/core/copy.d.ts +58 -0
- package/lib/dist/core/copy.js +49 -0
- package/lib/dist/core/cut.d.ts +46 -0
- package/lib/dist/core/cut.js +53 -0
- package/lib/dist/core/cylinder.d.ts +11 -0
- package/lib/dist/core/cylinder.js +10 -0
- package/lib/dist/core/extrude.d.ts +36 -0
- package/lib/dist/core/extrude.js +55 -0
- package/lib/dist/core/fillet.d.ts +33 -0
- package/lib/dist/core/fillet.js +58 -0
- package/lib/dist/core/fuse.d.ts +14 -0
- package/lib/dist/core/fuse.js +36 -0
- package/lib/dist/core/index.d.ts +32 -0
- package/lib/dist/core/index.js +30 -0
- package/lib/dist/core/interfaces.d.ts +411 -0
- package/lib/dist/core/interfaces.js +1 -0
- package/lib/dist/core/load.d.ts +10 -0
- package/lib/dist/core/load.js +10 -0
- package/lib/dist/core/loft.d.ts +10 -0
- package/lib/dist/core/loft.js +21 -0
- package/lib/dist/core/mirror.d.ts +40 -0
- package/lib/dist/core/mirror.js +95 -0
- package/lib/dist/core/part.d.ts +7 -0
- package/lib/dist/core/part.js +29 -0
- package/lib/dist/core/plane.d.ts +56 -0
- package/lib/dist/core/plane.js +111 -0
- package/lib/dist/core/region.d.ts +13 -0
- package/lib/dist/core/region.js +18 -0
- package/lib/dist/core/remove.d.ts +10 -0
- package/lib/dist/core/remove.js +10 -0
- package/lib/dist/core/repeat.d.ts +41 -0
- package/lib/dist/core/repeat.js +146 -0
- package/lib/dist/core/revolve.d.ts +19 -0
- package/lib/dist/core/revolve.js +39 -0
- package/lib/dist/core/rotate.d.ts +34 -0
- package/lib/dist/core/rotate.js +48 -0
- package/lib/dist/core/select.d.ts +12 -0
- package/lib/dist/core/select.js +21 -0
- package/lib/dist/core/shell.d.ts +16 -0
- package/lib/dist/core/shell.js +28 -0
- package/lib/dist/core/sketch.d.ts +18 -0
- package/lib/dist/core/sketch.js +34 -0
- package/lib/dist/core/sphere.d.ts +16 -0
- package/lib/dist/core/sphere.js +11 -0
- package/lib/dist/core/split.d.ts +12 -0
- package/lib/dist/core/split.js +26 -0
- package/lib/dist/core/subtract.d.ts +11 -0
- package/lib/dist/core/subtract.js +10 -0
- package/lib/dist/core/sweep.d.ts +16 -0
- package/lib/dist/core/sweep.js +29 -0
- package/lib/dist/core/translate.d.ts +64 -0
- package/lib/dist/core/translate.js +39 -0
- package/lib/dist/core/trim.d.ts +13 -0
- package/lib/dist/core/trim.js +18 -0
- package/lib/dist/core/use.d.ts +5 -0
- package/lib/dist/core/use.js +22 -0
- package/lib/dist/features/2d/aline.d.ts +18 -0
- package/lib/dist/features/2d/aline.js +78 -0
- package/lib/dist/features/2d/amove.d.ts +14 -0
- package/lib/dist/features/2d/amove.js +33 -0
- package/lib/dist/features/2d/arc-from-center.d.ts +16 -0
- package/lib/dist/features/2d/arc-from-center.js +69 -0
- package/lib/dist/features/2d/arc-to-point.d.ts +17 -0
- package/lib/dist/features/2d/arc-to-point.js +95 -0
- package/lib/dist/features/2d/arc.d.ts +19 -0
- package/lib/dist/features/2d/arc.js +94 -0
- package/lib/dist/features/2d/bezier.d.ts +15 -0
- package/lib/dist/features/2d/bezier.js +77 -0
- package/lib/dist/features/2d/circle.d.ts +17 -0
- package/lib/dist/features/2d/circle.js +58 -0
- package/lib/dist/features/2d/connect.d.ts +12 -0
- package/lib/dist/features/2d/connect.js +105 -0
- package/lib/dist/features/2d/constraints/constraint.d.ts +11 -0
- package/lib/dist/features/2d/constraints/constraint.js +49 -0
- package/lib/dist/features/2d/constraints/geometry-qualifier.d.ts +6 -0
- package/lib/dist/features/2d/constraints/geometry-qualifier.js +13 -0
- package/lib/dist/features/2d/constraints/outside.d.ts +3 -0
- package/lib/dist/features/2d/constraints/outside.js +4 -0
- package/lib/dist/features/2d/constraints/qualified-geometry.d.ts +16 -0
- package/lib/dist/features/2d/constraints/qualified-geometry.js +36 -0
- package/lib/dist/features/2d/extrudable-base.d.ts +15 -0
- package/lib/dist/features/2d/extrudable-base.js +27 -0
- package/lib/dist/features/2d/geometry.d.ts +20 -0
- package/lib/dist/features/2d/geometry.js +77 -0
- package/lib/dist/features/2d/hline.d.ts +16 -0
- package/lib/dist/features/2d/hline.js +66 -0
- package/lib/dist/features/2d/hmove.d.ts +14 -0
- package/lib/dist/features/2d/hmove.js +37 -0
- package/lib/dist/features/2d/line.d.ts +15 -0
- package/lib/dist/features/2d/line.js +59 -0
- package/lib/dist/features/2d/move.d.ts +15 -0
- package/lib/dist/features/2d/move.js +36 -0
- package/lib/dist/features/2d/offset.d.ts +18 -0
- package/lib/dist/features/2d/offset.js +117 -0
- package/lib/dist/features/2d/pmove.d.ts +16 -0
- package/lib/dist/features/2d/pmove.js +40 -0
- package/lib/dist/features/2d/polygon.d.ts +25 -0
- package/lib/dist/features/2d/polygon.js +107 -0
- package/lib/dist/features/2d/projection.d.ts +15 -0
- package/lib/dist/features/2d/projection.js +94 -0
- package/lib/dist/features/2d/rect.d.ts +45 -0
- package/lib/dist/features/2d/rect.js +262 -0
- package/lib/dist/features/2d/rmove.d.ts +17 -0
- package/lib/dist/features/2d/rmove.js +39 -0
- package/lib/dist/features/2d/sketch.d.ts +34 -0
- package/lib/dist/features/2d/sketch.js +171 -0
- package/lib/dist/features/2d/slot-from-edge.d.ts +19 -0
- package/lib/dist/features/2d/slot-from-edge.js +66 -0
- package/lib/dist/features/2d/slot.d.ts +24 -0
- package/lib/dist/features/2d/slot.js +119 -0
- package/lib/dist/features/2d/tarc-constrained.d.ts +20 -0
- package/lib/dist/features/2d/tarc-constrained.js +64 -0
- package/lib/dist/features/2d/tarc-to-point-tangent.d.ts +15 -0
- package/lib/dist/features/2d/tarc-to-point-tangent.js +86 -0
- package/lib/dist/features/2d/tarc-to-point.d.ts +13 -0
- package/lib/dist/features/2d/tarc-to-point.js +86 -0
- package/lib/dist/features/2d/tarc-two-circles.d.ts +18 -0
- package/lib/dist/features/2d/tarc-two-circles.js +61 -0
- package/lib/dist/features/2d/tarc-with-tangent.d.ts +17 -0
- package/lib/dist/features/2d/tarc-with-tangent.js +71 -0
- package/lib/dist/features/2d/tarc.d.ts +13 -0
- package/lib/dist/features/2d/tarc.js +71 -0
- package/lib/dist/features/2d/tcircle-constrained.d.ts +14 -0
- package/lib/dist/features/2d/tcircle-constrained.js +37 -0
- package/lib/dist/features/2d/tcircle-three-tan.d.ts +13 -0
- package/lib/dist/features/2d/tcircle-three-tan.js +33 -0
- package/lib/dist/features/2d/tcircle-two-tan.d.ts +13 -0
- package/lib/dist/features/2d/tcircle-two-tan.js +33 -0
- package/lib/dist/features/2d/tline-constrained.d.ts +27 -0
- package/lib/dist/features/2d/tline-constrained.js +82 -0
- package/lib/dist/features/2d/tline.d.ts +12 -0
- package/lib/dist/features/2d/tline.js +49 -0
- package/lib/dist/features/2d/vline.d.ts +16 -0
- package/lib/dist/features/2d/vline.js +65 -0
- package/lib/dist/features/2d/vmove.d.ts +14 -0
- package/lib/dist/features/2d/vmove.js +37 -0
- package/lib/dist/features/2d/wire.d.ts +12 -0
- package/lib/dist/features/2d/wire.js +76 -0
- package/lib/dist/features/Extrude.d.ts +1 -0
- package/lib/dist/features/Extrude.js +1 -0
- package/lib/dist/features/axis-from-edge.d.ts +15 -0
- package/lib/dist/features/axis-from-edge.js +82 -0
- package/lib/dist/features/axis-mid.d.ts +16 -0
- package/lib/dist/features/axis-mid.js +59 -0
- package/lib/dist/features/axis-renderable-base.d.ts +8 -0
- package/lib/dist/features/axis-renderable-base.js +12 -0
- package/lib/dist/features/axis.d.ts +14 -0
- package/lib/dist/features/axis.js +43 -0
- package/lib/dist/features/chamfer.d.ts +20 -0
- package/lib/dist/features/chamfer.js +129 -0
- package/lib/dist/features/color.d.ts +11 -0
- package/lib/dist/features/color.js +93 -0
- package/lib/dist/features/common.d.ts +12 -0
- package/lib/dist/features/common.js +70 -0
- package/lib/dist/features/common2d.d.ts +15 -0
- package/lib/dist/features/common2d.js +96 -0
- package/lib/dist/features/copy-circular.d.ts +23 -0
- package/lib/dist/features/copy-circular.js +73 -0
- package/lib/dist/features/copy-circular2d.d.ts +15 -0
- package/lib/dist/features/copy-circular2d.js +84 -0
- package/lib/dist/features/copy-linear.d.ts +23 -0
- package/lib/dist/features/copy-linear.js +101 -0
- package/lib/dist/features/copy-linear2d.d.ts +15 -0
- package/lib/dist/features/copy-linear2d.js +108 -0
- package/lib/dist/features/cut-base.d.ts +49 -0
- package/lib/dist/features/cut-base.js +312 -0
- package/lib/dist/features/cut-symmetric.d.ts +23 -0
- package/lib/dist/features/cut-symmetric.js +119 -0
- package/lib/dist/features/cut-two-distances.d.ts +24 -0
- package/lib/dist/features/cut-two-distances.js +110 -0
- package/lib/dist/features/cut.d.ts +27 -0
- package/lib/dist/features/cut.js +101 -0
- package/lib/dist/features/cylinder.d.ts +13 -0
- package/lib/dist/features/cylinder.js +33 -0
- package/lib/dist/features/extrude-base.d.ts +56 -0
- package/lib/dist/features/extrude-base.js +331 -0
- package/lib/dist/features/extrude-options.d.ts +8 -0
- package/lib/dist/features/extrude-options.js +1 -0
- package/lib/dist/features/extrude-symmetric.d.ts +28 -0
- package/lib/dist/features/extrude-symmetric.js +177 -0
- package/lib/dist/features/extrude-to-face.d.ts +35 -0
- package/lib/dist/features/extrude-to-face.js +275 -0
- package/lib/dist/features/extrude-two-distances.d.ts +21 -0
- package/lib/dist/features/extrude-two-distances.js +116 -0
- package/lib/dist/features/extrude.d.ts +25 -0
- package/lib/dist/features/extrude.js +182 -0
- package/lib/dist/features/fillet.d.ts +24 -0
- package/lib/dist/features/fillet.js +125 -0
- package/lib/dist/features/fillet2d.d.ts +16 -0
- package/lib/dist/features/fillet2d.js +98 -0
- package/lib/dist/features/fuse.d.ts +10 -0
- package/lib/dist/features/fuse.js +63 -0
- package/lib/dist/features/fuse2d.d.ts +13 -0
- package/lib/dist/features/fuse2d.js +86 -0
- package/lib/dist/features/infinite-extrude.d.ts +10 -0
- package/lib/dist/features/infinite-extrude.js +44 -0
- package/lib/dist/features/lazy-scene-object.d.ts +16 -0
- package/lib/dist/features/lazy-scene-object.js +52 -0
- package/lib/dist/features/lazy-vertex.d.ts +19 -0
- package/lib/dist/features/lazy-vertex.js +62 -0
- package/lib/dist/features/load.d.ts +9 -0
- package/lib/dist/features/load.js +31 -0
- package/lib/dist/features/loft.d.ts +27 -0
- package/lib/dist/features/loft.js +273 -0
- package/lib/dist/features/mirror-feature.d.ts +15 -0
- package/lib/dist/features/mirror-feature.js +39 -0
- package/lib/dist/features/mirror-shape.d.ts +14 -0
- package/lib/dist/features/mirror-shape.js +86 -0
- package/lib/dist/features/mirror-shape2d.d.ts +18 -0
- package/lib/dist/features/mirror-shape2d.js +110 -0
- package/lib/dist/features/part.d.ts +12 -0
- package/lib/dist/features/part.js +36 -0
- package/lib/dist/features/plane-from-object.d.ts +29 -0
- package/lib/dist/features/plane-from-object.js +103 -0
- package/lib/dist/features/plane-mid.d.ts +18 -0
- package/lib/dist/features/plane-mid.js +54 -0
- package/lib/dist/features/plane-renderable-base.d.ts +9 -0
- package/lib/dist/features/plane-renderable-base.js +15 -0
- package/lib/dist/features/plane.d.ts +21 -0
- package/lib/dist/features/plane.js +64 -0
- package/lib/dist/features/region2d.d.ts +25 -0
- package/lib/dist/features/region2d.js +185 -0
- package/lib/dist/features/remove.d.ts +9 -0
- package/lib/dist/features/remove.js +33 -0
- package/lib/dist/features/repeat-circular.d.ts +23 -0
- package/lib/dist/features/repeat-circular.js +47 -0
- package/lib/dist/features/repeat-circular2d.d.ts +17 -0
- package/lib/dist/features/repeat-circular2d.js +90 -0
- package/lib/dist/features/repeat-linear.d.ts +23 -0
- package/lib/dist/features/repeat-linear.js +52 -0
- package/lib/dist/features/repeat-linear2d.d.ts +17 -0
- package/lib/dist/features/repeat-linear2d.js +114 -0
- package/lib/dist/features/revolve-options.d.ts +6 -0
- package/lib/dist/features/revolve-options.js +1 -0
- package/lib/dist/features/revolve.d.ts +23 -0
- package/lib/dist/features/revolve.js +150 -0
- package/lib/dist/features/rotate.d.ts +16 -0
- package/lib/dist/features/rotate.js +89 -0
- package/lib/dist/features/rotate2d.d.ts +15 -0
- package/lib/dist/features/rotate2d.js +83 -0
- package/lib/dist/features/select.d.ts +26 -0
- package/lib/dist/features/select.js +113 -0
- package/lib/dist/features/shell.d.ts +24 -0
- package/lib/dist/features/shell.js +214 -0
- package/lib/dist/features/simple-extruder.d.ts +22 -0
- package/lib/dist/features/simple-extruder.js +108 -0
- package/lib/dist/features/sphere.d.ts +13 -0
- package/lib/dist/features/sphere.js +33 -0
- package/lib/dist/features/split.d.ts +14 -0
- package/lib/dist/features/split.js +74 -0
- package/lib/dist/features/split2d.d.ts +13 -0
- package/lib/dist/features/split2d.js +69 -0
- package/lib/dist/features/state-scene-object.d.ts +15 -0
- package/lib/dist/features/state-scene-object.js +44 -0
- package/lib/dist/features/state-select.d.ts +21 -0
- package/lib/dist/features/state-select.js +73 -0
- package/lib/dist/features/static-scene-object.d.ts +10 -0
- package/lib/dist/features/static-scene-object.js +21 -0
- package/lib/dist/features/subtract.d.ts +13 -0
- package/lib/dist/features/subtract.js +56 -0
- package/lib/dist/features/sweep.d.ts +22 -0
- package/lib/dist/features/sweep.js +129 -0
- package/lib/dist/features/translate.d.ts +17 -0
- package/lib/dist/features/translate.js +76 -0
- package/lib/dist/features/translate2d.d.ts +16 -0
- package/lib/dist/features/translate2d.js +61 -0
- package/lib/dist/features/trim2d.d.ts +15 -0
- package/lib/dist/features/trim2d.js +154 -0
- package/lib/dist/filters/all-filter.d.ts +8 -0
- package/lib/dist/filters/all-filter.js +12 -0
- package/lib/dist/filters/edge/at-index.d.ts +21 -0
- package/lib/dist/filters/edge/at-index.js +82 -0
- package/lib/dist/filters/edge/circle-filter.d.ts +17 -0
- package/lib/dist/filters/edge/circle-filter.js +34 -0
- package/lib/dist/filters/edge/curve-filter.d.ts +17 -0
- package/lib/dist/filters/edge/curve-filter.js +34 -0
- package/lib/dist/filters/edge/edge-filter.d.ts +22 -0
- package/lib/dist/filters/edge/edge-filter.js +169 -0
- package/lib/dist/filters/edge/line-filter.d.ts +14 -0
- package/lib/dist/filters/edge/line-filter.js +27 -0
- package/lib/dist/filters/edge/on-plane.d.ts +20 -0
- package/lib/dist/filters/edge/on-plane.js +70 -0
- package/lib/dist/filters/edge/parallel.d.ts +18 -0
- package/lib/dist/filters/edge/parallel.js +41 -0
- package/lib/dist/filters/edge/vertical-plane.d.ts +18 -0
- package/lib/dist/filters/edge/vertical-plane.js +41 -0
- package/lib/dist/filters/face/at-index.d.ts +21 -0
- package/lib/dist/filters/face/at-index.js +89 -0
- package/lib/dist/filters/face/circle-filter.d.ts +17 -0
- package/lib/dist/filters/face/circle-filter.js +34 -0
- package/lib/dist/filters/face/cone-filter.d.ts +15 -0
- package/lib/dist/filters/face/cone-filter.js +30 -0
- package/lib/dist/filters/face/cylinder-curve.d.ts +17 -0
- package/lib/dist/filters/face/cylinder-curve.js +34 -0
- package/lib/dist/filters/face/cylinder.d.ts +17 -0
- package/lib/dist/filters/face/cylinder.js +34 -0
- package/lib/dist/filters/face/face-filter.d.ts +21 -0
- package/lib/dist/filters/face/face-filter.js +134 -0
- package/lib/dist/filters/face/on-plane.d.ts +18 -0
- package/lib/dist/filters/face/on-plane.js +41 -0
- package/lib/dist/filters/face/parallel.d.ts +18 -0
- package/lib/dist/filters/face/parallel.js +41 -0
- package/lib/dist/filters/filter-base.d.ts +8 -0
- package/lib/dist/filters/filter-base.js +2 -0
- package/lib/dist/filters/filter-builder-base.d.ts +10 -0
- package/lib/dist/filters/filter-builder-base.js +31 -0
- package/lib/dist/filters/filter.d.ts +8 -0
- package/lib/dist/filters/filter.js +33 -0
- package/lib/dist/filters/index.d.ts +4 -0
- package/lib/dist/filters/index.js +8 -0
- package/lib/dist/filters/near-point-filter.d.ts +11 -0
- package/lib/dist/filters/near-point-filter.js +33 -0
- package/lib/dist/helpers/clone-transform.d.ts +3 -0
- package/lib/dist/helpers/clone-transform.js +46 -0
- package/lib/dist/helpers/cut-helpers.d.ts +13 -0
- package/lib/dist/helpers/cut-helpers.js +79 -0
- package/lib/dist/helpers/math-helpers.d.ts +2 -0
- package/lib/dist/helpers/math-helpers.js +6 -0
- package/lib/dist/helpers/normalize.d.ts +12 -0
- package/lib/dist/helpers/normalize.js +118 -0
- package/lib/dist/helpers/resolve-filters.d.ts +6 -0
- package/lib/dist/helpers/resolve-filters.js +25 -0
- package/lib/dist/helpers/resolve.d.ts +8 -0
- package/lib/dist/helpers/resolve.js +45 -0
- package/lib/dist/helpers/scene-helpers.d.ts +17 -0
- package/lib/dist/helpers/scene-helpers.js +67 -0
- package/lib/dist/helpers/types.d.ts +27 -0
- package/lib/dist/helpers/types.js +1 -0
- package/lib/dist/index.d.ts +37 -0
- package/lib/dist/index.js +75 -0
- package/lib/dist/io/file-export.d.ts +30 -0
- package/lib/dist/io/file-export.js +45 -0
- package/lib/dist/io/file-import.d.ts +8 -0
- package/lib/dist/io/file-import.js +81 -0
- package/lib/dist/load.d.ts +1 -0
- package/lib/dist/load.js +1 -0
- package/lib/dist/math/axis.d.ts +72 -0
- package/lib/dist/math/axis.js +157 -0
- package/lib/dist/math/axis.test.d.ts +1 -0
- package/lib/dist/math/axis.test.js +287 -0
- package/lib/dist/math/convert.d.ts +2 -0
- package/lib/dist/math/convert.js +1 -0
- package/lib/dist/math/coordinate-system.d.ts +43 -0
- package/lib/dist/math/coordinate-system.js +140 -0
- package/lib/dist/math/coordinate-system.test.d.ts +1 -0
- package/lib/dist/math/coordinate-system.test.js +308 -0
- package/lib/dist/math/index.d.ts +8 -0
- package/lib/dist/math/index.js +8 -0
- package/lib/dist/math/matrix4.d.ts +53 -0
- package/lib/dist/math/matrix4.js +336 -0
- package/lib/dist/math/matrix4.test.d.ts +1 -0
- package/lib/dist/math/matrix4.test.js +357 -0
- package/lib/dist/math/plane.d.ts +60 -0
- package/lib/dist/math/plane.js +243 -0
- package/lib/dist/math/plane.test.d.ts +1 -0
- package/lib/dist/math/plane.test.js +398 -0
- package/lib/dist/math/point.d.ts +73 -0
- package/lib/dist/math/point.js +227 -0
- package/lib/dist/math/point.test.d.ts +1 -0
- package/lib/dist/math/point.test.js +385 -0
- package/lib/dist/math/quaternion.d.ts +37 -0
- package/lib/dist/math/quaternion.js +234 -0
- package/lib/dist/math/quaternion.test.d.ts +1 -0
- package/lib/dist/math/quaternion.test.js +278 -0
- package/lib/dist/math/vector3d.d.ts +43 -0
- package/lib/dist/math/vector3d.js +143 -0
- package/lib/dist/math/vector3d.test.d.ts +1 -0
- package/lib/dist/math/vector3d.test.js +276 -0
- package/lib/dist/oc/boolean-ops.d.ts +36 -0
- package/lib/dist/oc/boolean-ops.js +337 -0
- package/lib/dist/oc/constraint-resolver.d.ts +7 -0
- package/lib/dist/oc/constraint-resolver.js +31 -0
- package/lib/dist/oc/constraints/constraint-helpers.d.ts +33 -0
- package/lib/dist/oc/constraints/constraint-helpers.js +252 -0
- package/lib/dist/oc/constraints/constraint-solver-adaptor.d.ts +22 -0
- package/lib/dist/oc/constraints/constraint-solver-adaptor.js +62 -0
- package/lib/dist/oc/constraints/constraint-solver.d.ts +18 -0
- package/lib/dist/oc/constraints/constraint-solver.js +2 -0
- package/lib/dist/oc/constraints/create-solver.d.ts +2 -0
- package/lib/dist/oc/constraints/create-solver.js +6 -0
- package/lib/dist/oc/constraints/curve/curve-constraint-solver.d.ts +13 -0
- package/lib/dist/oc/constraints/curve/curve-constraint-solver.js +18 -0
- package/lib/dist/oc/constraints/curve/tangent-circle-solver.d.ts +16 -0
- package/lib/dist/oc/constraints/curve/tangent-circle-solver.js +112 -0
- package/lib/dist/oc/constraints/curve/tangent-line-solver.d.ts +19 -0
- package/lib/dist/oc/constraints/curve/tangent-line-solver.js +83 -0
- package/lib/dist/oc/constraints/curve-constraint-solver.d.ts +1 -0
- package/lib/dist/oc/constraints/curve-constraint-solver.js +2 -0
- package/lib/dist/oc/constraints/geometric/geometric-constraint-solver.d.ts +12 -0
- package/lib/dist/oc/constraints/geometric/geometric-constraint-solver.js +17 -0
- package/lib/dist/oc/constraints/geometric/tangent-circle-solver.d.ts +21 -0
- package/lib/dist/oc/constraints/geometric/tangent-circle-solver.js +220 -0
- package/lib/dist/oc/constraints/geometric/tangent-line-solver.d.ts +19 -0
- package/lib/dist/oc/constraints/geometric/tangent-line-solver.js +92 -0
- package/lib/dist/oc/constraints/geometric-constraint-solver.d.ts +1 -0
- package/lib/dist/oc/constraints/geometric-constraint-solver.js +5 -0
- package/lib/dist/oc/convert.d.ts +42 -0
- package/lib/dist/oc/convert.js +231 -0
- package/lib/dist/oc/edge-ops.d.ts +37 -0
- package/lib/dist/oc/edge-ops.js +306 -0
- package/lib/dist/oc/edge-props.d.ts +11 -0
- package/lib/dist/oc/edge-props.js +45 -0
- package/lib/dist/oc/edge-query.d.ts +44 -0
- package/lib/dist/oc/edge-query.js +235 -0
- package/lib/dist/oc/explorer.d.ts +34 -0
- package/lib/dist/oc/explorer.js +179 -0
- package/lib/dist/oc/extrude-ops.d.ts +22 -0
- package/lib/dist/oc/extrude-ops.js +149 -0
- package/lib/dist/oc/face-maker.d.ts +14 -0
- package/lib/dist/oc/face-maker.js +191 -0
- package/lib/dist/oc/face-maker2.d.ts +10 -0
- package/lib/dist/oc/face-maker2.js +139 -0
- package/lib/dist/oc/face-ops.d.ts +28 -0
- package/lib/dist/oc/face-ops.js +252 -0
- package/lib/dist/oc/face-props.d.ts +12 -0
- package/lib/dist/oc/face-props.js +81 -0
- package/lib/dist/oc/face-query.d.ts +35 -0
- package/lib/dist/oc/face-query.js +341 -0
- package/lib/dist/oc/fillet-ops.d.ts +13 -0
- package/lib/dist/oc/fillet-ops.js +153 -0
- package/lib/dist/oc/geometry.d.ts +22 -0
- package/lib/dist/oc/geometry.js +231 -0
- package/lib/dist/oc/hit-test.d.ts +11 -0
- package/lib/dist/oc/hit-test.js +85 -0
- package/lib/dist/oc/index.d.ts +24 -0
- package/lib/dist/oc/index.js +21 -0
- package/lib/dist/oc/init.d.ts +3 -0
- package/lib/dist/oc/init.js +17 -0
- package/lib/dist/oc/intersection.d.ts +10 -0
- package/lib/dist/oc/intersection.js +107 -0
- package/lib/dist/oc/io.d.ts +49 -0
- package/lib/dist/oc/io.js +417 -0
- package/lib/dist/oc/loft-ops.d.ts +5 -0
- package/lib/dist/oc/loft-ops.js +26 -0
- package/lib/dist/oc/measure.d.ts +21 -0
- package/lib/dist/oc/measure.js +256 -0
- package/lib/dist/oc/mesh.d.ts +15 -0
- package/lib/dist/oc/mesh.js +110 -0
- package/lib/dist/oc/primitives.d.ts +5 -0
- package/lib/dist/oc/primitives.js +19 -0
- package/lib/dist/oc/props.d.ts +13 -0
- package/lib/dist/oc/props.js +18 -0
- package/lib/dist/oc/shape-ops.d.ts +34 -0
- package/lib/dist/oc/shape-ops.js +208 -0
- package/lib/dist/oc/shell-ops.d.ts +5 -0
- package/lib/dist/oc/shell-ops.js +25 -0
- package/lib/dist/oc/sweep-ops.d.ts +12 -0
- package/lib/dist/oc/sweep-ops.js +39 -0
- package/lib/dist/oc/tangent-circle-solver.d.ts +17 -0
- package/lib/dist/oc/tangent-circle-solver.js +72 -0
- package/lib/dist/oc/tangent-line-solver.d.ts +17 -0
- package/lib/dist/oc/tangent-line-solver.js +83 -0
- package/lib/dist/oc/tangent-solver.d.ts +14 -0
- package/lib/dist/oc/tangent-solver.js +199 -0
- package/lib/dist/oc/vertex-ops.d.ts +11 -0
- package/lib/dist/oc/vertex-ops.js +39 -0
- package/lib/dist/oc/wire-ops.d.ts +21 -0
- package/lib/dist/oc/wire-ops.js +176 -0
- package/lib/dist/rendering/builder-context.d.ts +16 -0
- package/lib/dist/rendering/builder-context.js +63 -0
- package/lib/dist/rendering/mesh-builder.d.ts +5 -0
- package/lib/dist/rendering/mesh-builder.js +43 -0
- package/lib/dist/rendering/render-edge.d.ts +3 -0
- package/lib/dist/rendering/render-edge.js +4 -0
- package/lib/dist/rendering/render-face.d.ts +2 -0
- package/lib/dist/rendering/render-face.js +5 -0
- package/lib/dist/rendering/render-solid.d.ts +3 -0
- package/lib/dist/rendering/render-solid.js +61 -0
- package/lib/dist/rendering/render-wire.d.ts +6 -0
- package/lib/dist/rendering/render-wire.js +27 -0
- package/lib/dist/rendering/render.d.ts +3 -0
- package/lib/dist/rendering/render.js +183 -0
- package/lib/dist/rendering/scene-compare.d.ts +4 -0
- package/lib/dist/rendering/scene-compare.js +41 -0
- package/lib/dist/rendering/scene.d.ts +81 -0
- package/lib/dist/rendering/scene.js +206 -0
- package/lib/dist/scene-manager.d.ts +32 -0
- package/lib/dist/scene-manager.js +120 -0
- package/lib/dist/tests/extrude.test.d.ts +1 -0
- package/lib/dist/tests/extrude.test.js +48 -0
- package/lib/dist/tests/features/2d/arc.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/arc.test.js +40 -0
- package/lib/dist/tests/features/2d/circle.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/circle.test.js +64 -0
- package/lib/dist/tests/features/2d/constrained.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/constrained.test.js +202 -0
- package/lib/dist/tests/features/2d/line.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/line.test.js +86 -0
- package/lib/dist/tests/features/2d/move.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/move.test.js +74 -0
- package/lib/dist/tests/features/2d/offset.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/offset.test.js +111 -0
- package/lib/dist/tests/features/2d/pmove.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/pmove.test.js +43 -0
- package/lib/dist/tests/features/2d/polygon.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/polygon.test.js +150 -0
- package/lib/dist/tests/features/2d/project.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/project.test.js +22 -0
- package/lib/dist/tests/features/2d/rect.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/rect.test.js +66 -0
- package/lib/dist/tests/features/2d/rmove.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/rmove.test.js +29 -0
- package/lib/dist/tests/features/2d/slot-from-edge.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/slot-from-edge.test.js +35 -0
- package/lib/dist/tests/features/2d/slot.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/slot.test.js +44 -0
- package/lib/dist/tests/features/2d/tarc.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/tarc.test.js +237 -0
- package/lib/dist/tests/features/2d/tcircle.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/tcircle.test.js +28 -0
- package/lib/dist/tests/features/2d/tline.test.d.ts +1 -0
- package/lib/dist/tests/features/2d/tline.test.js +34 -0
- package/lib/dist/tests/features/axis.test.d.ts +1 -0
- package/lib/dist/tests/features/axis.test.js +143 -0
- package/lib/dist/tests/features/chamfer.test.d.ts +1 -0
- package/lib/dist/tests/features/chamfer.test.js +159 -0
- package/lib/dist/tests/features/color.test.d.ts +1 -0
- package/lib/dist/tests/features/color.test.js +96 -0
- package/lib/dist/tests/features/common2d.test.d.ts +1 -0
- package/lib/dist/tests/features/common2d.test.js +113 -0
- package/lib/dist/tests/features/copy-circular-2d.test.d.ts +1 -0
- package/lib/dist/tests/features/copy-circular-2d.test.js +40 -0
- package/lib/dist/tests/features/copy-circular.test.d.ts +1 -0
- package/lib/dist/tests/features/copy-circular.test.js +44 -0
- package/lib/dist/tests/features/copy-linear-2d.test.d.ts +1 -0
- package/lib/dist/tests/features/copy-linear-2d.test.js +35 -0
- package/lib/dist/tests/features/copy-linear.test.d.ts +1 -0
- package/lib/dist/tests/features/copy-linear.test.js +95 -0
- package/lib/dist/tests/features/copy.test.d.ts +1 -0
- package/lib/dist/tests/features/copy.test.js +158 -0
- package/lib/dist/tests/features/cut-symmetric.test.d.ts +1 -0
- package/lib/dist/tests/features/cut-symmetric.test.js +120 -0
- package/lib/dist/tests/features/cut-two-distances.test.d.ts +1 -0
- package/lib/dist/tests/features/cut-two-distances.test.js +125 -0
- package/lib/dist/tests/features/cut.test.d.ts +1 -0
- package/lib/dist/tests/features/cut.test.js +311 -0
- package/lib/dist/tests/features/dispose.test.d.ts +1 -0
- package/lib/dist/tests/features/dispose.test.js +189 -0
- package/lib/dist/tests/features/extrude-symmetric.test.d.ts +1 -0
- package/lib/dist/tests/features/extrude-symmetric.test.js +240 -0
- package/lib/dist/tests/features/extrude-to-face.test.d.ts +1 -0
- package/lib/dist/tests/features/extrude-to-face.test.js +256 -0
- package/lib/dist/tests/features/extrude-two-distances.test.d.ts +1 -0
- package/lib/dist/tests/features/extrude-two-distances.test.js +264 -0
- package/lib/dist/tests/features/extrude.test.d.ts +1 -0
- package/lib/dist/tests/features/extrude.test.js +640 -0
- package/lib/dist/tests/features/fillet.test.d.ts +1 -0
- package/lib/dist/tests/features/fillet.test.js +163 -0
- package/lib/dist/tests/features/fillet2d.test.d.ts +1 -0
- package/lib/dist/tests/features/fillet2d.test.js +69 -0
- package/lib/dist/tests/features/fuse.test.d.ts +1 -0
- package/lib/dist/tests/features/fuse.test.js +122 -0
- package/lib/dist/tests/features/fuse2d.test.d.ts +1 -0
- package/lib/dist/tests/features/fuse2d.test.js +80 -0
- package/lib/dist/tests/features/loft.test.d.ts +1 -0
- package/lib/dist/tests/features/loft.test.js +283 -0
- package/lib/dist/tests/features/mirror.test.d.ts +1 -0
- package/lib/dist/tests/features/mirror.test.js +112 -0
- package/lib/dist/tests/features/mirror2d.test.d.ts +1 -0
- package/lib/dist/tests/features/mirror2d.test.js +75 -0
- package/lib/dist/tests/features/part-pick.test.d.ts +1 -0
- package/lib/dist/tests/features/part-pick.test.js +73 -0
- package/lib/dist/tests/features/part-repeat.test.d.ts +1 -0
- package/lib/dist/tests/features/part-repeat.test.js +109 -0
- package/lib/dist/tests/features/part.test.d.ts +1 -0
- package/lib/dist/tests/features/part.test.js +356 -0
- package/lib/dist/tests/features/plane.test.d.ts +1 -0
- package/lib/dist/tests/features/plane.test.js +154 -0
- package/lib/dist/tests/features/repeat-circular.test.d.ts +1 -0
- package/lib/dist/tests/features/repeat-circular.test.js +114 -0
- package/lib/dist/tests/features/repeat-linear.test.d.ts +1 -0
- package/lib/dist/tests/features/repeat-linear.test.js +138 -0
- package/lib/dist/tests/features/revolve.test.d.ts +1 -0
- package/lib/dist/tests/features/revolve.test.js +205 -0
- package/lib/dist/tests/features/rotate.test.d.ts +1 -0
- package/lib/dist/tests/features/rotate.test.js +133 -0
- package/lib/dist/tests/features/rotate2d.test.d.ts +1 -0
- package/lib/dist/tests/features/rotate2d.test.js +74 -0
- package/lib/dist/tests/features/select.test.d.ts +1 -0
- package/lib/dist/tests/features/select.test.js +337 -0
- package/lib/dist/tests/features/shell.test.d.ts +1 -0
- package/lib/dist/tests/features/shell.test.js +230 -0
- package/lib/dist/tests/features/subtract.test.d.ts +1 -0
- package/lib/dist/tests/features/subtract.test.js +103 -0
- package/lib/dist/tests/features/sweep.test.d.ts +1 -0
- package/lib/dist/tests/features/sweep.test.js +312 -0
- package/lib/dist/tests/features/translate.test.d.ts +1 -0
- package/lib/dist/tests/features/translate.test.js +117 -0
- package/lib/dist/tests/global-setup.d.ts +1 -0
- package/lib/dist/tests/global-setup.js +5 -0
- package/lib/dist/tests/math/axis.test.d.ts +1 -0
- package/lib/dist/tests/math/axis.test.js +287 -0
- package/lib/dist/tests/math/coordinate-system.test.d.ts +1 -0
- package/lib/dist/tests/math/coordinate-system.test.js +308 -0
- package/lib/dist/tests/math/matrix4.test.d.ts +1 -0
- package/lib/dist/tests/math/matrix4.test.js +357 -0
- package/lib/dist/tests/math/plane.test.d.ts +1 -0
- package/lib/dist/tests/math/plane.test.js +398 -0
- package/lib/dist/tests/math/point.test.d.ts +1 -0
- package/lib/dist/tests/math/point.test.js +385 -0
- package/lib/dist/tests/math/quaternion.test.d.ts +1 -0
- package/lib/dist/tests/math/quaternion.test.js +278 -0
- package/lib/dist/tests/math/vector3d.test.d.ts +1 -0
- package/lib/dist/tests/math/vector3d.test.js +276 -0
- package/lib/dist/tests/setup.d.ts +5 -0
- package/lib/dist/tests/setup.js +14 -0
- package/lib/dist/tests/utils.d.ts +12 -0
- package/lib/dist/tests/utils.js +36 -0
- package/lib/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +83 -0
- package/server/dist/fluidcad-server.d.ts +32 -0
- package/server/dist/fluidcad-server.js +150 -0
- package/server/dist/index.d.ts +1 -0
- package/server/dist/index.js +290 -0
- package/server/dist/routes/actions.d.ts +3 -0
- package/server/dist/routes/actions.js +100 -0
- package/server/dist/routes/export.d.ts +3 -0
- package/server/dist/routes/export.js +55 -0
- package/server/dist/routes/properties.d.ts +3 -0
- package/server/dist/routes/properties.js +46 -0
- package/server/dist/routes/screenshot.d.ts +2 -0
- package/server/dist/routes/screenshot.js +76 -0
- package/server/dist/vite-manager.d.ts +10 -0
- package/server/dist/vite-manager.js +64 -0
- package/server/dist/ws-protocol.d.ts +138 -0
- package/server/dist/ws-protocol.js +4 -0
- package/ui/dist/assets/index-DXW2yo2v.css +2 -0
- package/ui/dist/assets/index-qqJ_mWi7.js +4732 -0
- package/ui/dist/icons/aline.png +0 -0
- package/ui/dist/icons/arc.png +0 -0
- package/ui/dist/icons/aslot.png +0 -0
- package/ui/dist/icons/axis.png +0 -0
- package/ui/dist/icons/box.png +0 -0
- package/ui/dist/icons/chamfer.png +0 -0
- package/ui/dist/icons/circle.png +0 -0
- package/ui/dist/icons/color.png +0 -0
- package/ui/dist/icons/common.png +0 -0
- package/ui/dist/icons/cone.png +0 -0
- package/ui/dist/icons/connect.png +0 -0
- package/ui/dist/icons/copy-circular.png +0 -0
- package/ui/dist/icons/copy-circular2d.png +0 -0
- package/ui/dist/icons/copy-linear.png +0 -0
- package/ui/dist/icons/copy-linear2d.png +0 -0
- package/ui/dist/icons/cut.png +0 -0
- package/ui/dist/icons/cylinder.png +0 -0
- package/ui/dist/icons/edge.png +0 -0
- package/ui/dist/icons/extrude.png +0 -0
- package/ui/dist/icons/fillet.png +0 -0
- package/ui/dist/icons/fillet2d.png +0 -0
- package/ui/dist/icons/fuse.png +0 -0
- package/ui/dist/icons/hline.png +0 -0
- package/ui/dist/icons/hole.png +0 -0
- package/ui/dist/icons/line.png +0 -0
- package/ui/dist/icons/load.png +0 -0
- package/ui/dist/icons/mirror.png +0 -0
- package/ui/dist/icons/mirror2d.png +0 -0
- package/ui/dist/icons/move.png +0 -0
- package/ui/dist/icons/plane.png +0 -0
- package/ui/dist/icons/polygon.png +0 -0
- package/ui/dist/icons/rect.png +0 -0
- package/ui/dist/icons/revolve.png +0 -0
- package/ui/dist/icons/rotate.png +0 -0
- package/ui/dist/icons/rotate2d.png +0 -0
- package/ui/dist/icons/select.png +0 -0
- package/ui/dist/icons/shell.png +0 -0
- package/ui/dist/icons/sketch.png +0 -0
- package/ui/dist/icons/slot.png +0 -0
- package/ui/dist/icons/solid.png +0 -0
- package/ui/dist/icons/sphere.png +0 -0
- package/ui/dist/icons/subtract.png +0 -0
- package/ui/dist/icons/tarc.png +0 -0
- package/ui/dist/icons/tline.png +0 -0
- package/ui/dist/icons/translate.png +0 -0
- package/ui/dist/icons/vline.png +0 -0
- package/ui/dist/icons/wire.png +0 -0
- package/ui/dist/index.html +13 -0
- package/ui/dist/logo.png +0 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
import { Vector3d } from "./vector3d.js";
|
|
2
|
+
import { Point } from "./point.js";
|
|
3
|
+
import { Quaternion } from "./quaternion.js";
|
|
4
|
+
/**
|
|
5
|
+
* 4x4 transformation matrix stored in column-major order.
|
|
6
|
+
* Layout:
|
|
7
|
+
* [0] [4] [8] [12] m00 m01 m02 m03
|
|
8
|
+
* [1] [5] [9] [13] = m10 m11 m12 m13
|
|
9
|
+
* [2] [6] [10] [14] m20 m21 m22 m23
|
|
10
|
+
* [3] [7] [11] [15] m30 m31 m32 m33
|
|
11
|
+
*/
|
|
12
|
+
export class Matrix4 {
|
|
13
|
+
elements;
|
|
14
|
+
constructor(elements) {
|
|
15
|
+
if (elements) {
|
|
16
|
+
if (elements.length !== 16) {
|
|
17
|
+
throw new Error("Matrix4 requires exactly 16 elements");
|
|
18
|
+
}
|
|
19
|
+
this.elements = Object.freeze([...elements]);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
this.elements = Object.freeze([
|
|
23
|
+
1, 0, 0, 0,
|
|
24
|
+
0, 1, 0, 0,
|
|
25
|
+
0, 0, 1, 0,
|
|
26
|
+
0, 0, 0, 1,
|
|
27
|
+
]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
get(row, col) {
|
|
31
|
+
return this.elements[col * 4 + row];
|
|
32
|
+
}
|
|
33
|
+
multiply(other) {
|
|
34
|
+
const a = this.elements;
|
|
35
|
+
const b = other.elements;
|
|
36
|
+
const result = new Array(16);
|
|
37
|
+
for (let col = 0; col < 4; col++) {
|
|
38
|
+
for (let row = 0; row < 4; row++) {
|
|
39
|
+
result[col * 4 + row] =
|
|
40
|
+
a[row] * b[col * 4] +
|
|
41
|
+
a[4 + row] * b[col * 4 + 1] +
|
|
42
|
+
a[8 + row] * b[col * 4 + 2] +
|
|
43
|
+
a[12 + row] * b[col * 4 + 3];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return new Matrix4(result);
|
|
47
|
+
}
|
|
48
|
+
premultiply(other) {
|
|
49
|
+
return other.multiply(this);
|
|
50
|
+
}
|
|
51
|
+
determinant() {
|
|
52
|
+
const m = this.elements;
|
|
53
|
+
const n11 = m[0], n12 = m[4], n13 = m[8], n14 = m[12];
|
|
54
|
+
const n21 = m[1], n22 = m[5], n23 = m[9], n24 = m[13];
|
|
55
|
+
const n31 = m[2], n32 = m[6], n33 = m[10], n34 = m[14];
|
|
56
|
+
const n41 = m[3], n42 = m[7], n43 = m[11], n44 = m[15];
|
|
57
|
+
return (n41 * (n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 +
|
|
58
|
+
n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34) +
|
|
59
|
+
n42 * (n11 * n23 * n34 - n11 * n24 * n33 + n14 * n21 * n33 -
|
|
60
|
+
n13 * n21 * n34 + n13 * n24 * n31 - n14 * n23 * n31) +
|
|
61
|
+
n43 * (n11 * n24 * n32 - n11 * n22 * n34 - n14 * n21 * n32 +
|
|
62
|
+
n12 * n21 * n34 + n14 * n22 * n31 - n12 * n24 * n31) +
|
|
63
|
+
n44 * (-n13 * n22 * n31 - n11 * n23 * n32 + n11 * n22 * n33 +
|
|
64
|
+
n13 * n21 * n32 - n12 * n21 * n33 + n12 * n23 * n31));
|
|
65
|
+
}
|
|
66
|
+
inverse() {
|
|
67
|
+
const m = this.elements;
|
|
68
|
+
const result = new Array(16);
|
|
69
|
+
const n11 = m[0], n12 = m[4], n13 = m[8], n14 = m[12];
|
|
70
|
+
const n21 = m[1], n22 = m[5], n23 = m[9], n24 = m[13];
|
|
71
|
+
const n31 = m[2], n32 = m[6], n33 = m[10], n34 = m[14];
|
|
72
|
+
const n41 = m[3], n42 = m[7], n43 = m[11], n44 = m[15];
|
|
73
|
+
const t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44;
|
|
74
|
+
const t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44;
|
|
75
|
+
const t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44;
|
|
76
|
+
const t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
|
|
77
|
+
const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
|
|
78
|
+
if (det === 0) {
|
|
79
|
+
throw new Error("Matrix is not invertible (determinant is zero)");
|
|
80
|
+
}
|
|
81
|
+
const detInv = 1 / det;
|
|
82
|
+
result[0] = t11 * detInv;
|
|
83
|
+
result[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;
|
|
84
|
+
result[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;
|
|
85
|
+
result[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;
|
|
86
|
+
result[4] = t12 * detInv;
|
|
87
|
+
result[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;
|
|
88
|
+
result[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;
|
|
89
|
+
result[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;
|
|
90
|
+
result[8] = t13 * detInv;
|
|
91
|
+
result[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;
|
|
92
|
+
result[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;
|
|
93
|
+
result[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;
|
|
94
|
+
result[12] = t14 * detInv;
|
|
95
|
+
result[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;
|
|
96
|
+
result[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;
|
|
97
|
+
result[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;
|
|
98
|
+
return new Matrix4(result);
|
|
99
|
+
}
|
|
100
|
+
transpose() {
|
|
101
|
+
const m = this.elements;
|
|
102
|
+
return new Matrix4([
|
|
103
|
+
m[0], m[4], m[8], m[12],
|
|
104
|
+
m[1], m[5], m[9], m[13],
|
|
105
|
+
m[2], m[6], m[10], m[14],
|
|
106
|
+
m[3], m[7], m[11], m[15],
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
transformPoint(p) {
|
|
110
|
+
const m = this.elements;
|
|
111
|
+
const x = p.x, y = p.y, z = p.z;
|
|
112
|
+
const w = 1 / (m[3] * x + m[7] * y + m[11] * z + m[15]);
|
|
113
|
+
return new Point((m[0] * x + m[4] * y + m[8] * z + m[12]) * w, (m[1] * x + m[5] * y + m[9] * z + m[13]) * w, (m[2] * x + m[6] * y + m[10] * z + m[14]) * w);
|
|
114
|
+
}
|
|
115
|
+
transformVector(v) {
|
|
116
|
+
const m = this.elements;
|
|
117
|
+
const x = v.x, y = v.y, z = v.z;
|
|
118
|
+
return new Vector3d(m[0] * x + m[4] * y + m[8] * z, m[1] * x + m[5] * y + m[9] * z, m[2] * x + m[6] * y + m[10] * z);
|
|
119
|
+
}
|
|
120
|
+
transformDirection(v) {
|
|
121
|
+
return this.transformVector(v).normalize();
|
|
122
|
+
}
|
|
123
|
+
decompose() {
|
|
124
|
+
const m = this.elements;
|
|
125
|
+
const sx = new Vector3d(m[0], m[1], m[2]).length();
|
|
126
|
+
const sy = new Vector3d(m[4], m[5], m[6]).length();
|
|
127
|
+
const sz = new Vector3d(m[8], m[9], m[10]).length();
|
|
128
|
+
const det = this.determinant();
|
|
129
|
+
const signX = det < 0 ? -1 : 1;
|
|
130
|
+
const translation = new Vector3d(m[12], m[13], m[14]);
|
|
131
|
+
const scale = new Vector3d(sx * signX, sy, sz);
|
|
132
|
+
const invSX = 1 / sx;
|
|
133
|
+
const invSY = 1 / sy;
|
|
134
|
+
const invSZ = 1 / sz;
|
|
135
|
+
const rotationMatrix = [
|
|
136
|
+
m[0] * invSX, m[1] * invSX, m[2] * invSX, 0,
|
|
137
|
+
m[4] * invSY, m[5] * invSY, m[6] * invSY, 0,
|
|
138
|
+
m[8] * invSZ, m[9] * invSZ, m[10] * invSZ, 0,
|
|
139
|
+
0, 0, 0, 1,
|
|
140
|
+
];
|
|
141
|
+
const rotation = Quaternion.fromRotationMatrix(rotationMatrix);
|
|
142
|
+
return { translation, rotation, scale };
|
|
143
|
+
}
|
|
144
|
+
isMirroring() {
|
|
145
|
+
return this.determinant() < 0;
|
|
146
|
+
}
|
|
147
|
+
equals(other, tolerance = 0) {
|
|
148
|
+
for (let i = 0; i < 16; i++) {
|
|
149
|
+
if (tolerance === 0) {
|
|
150
|
+
if (this.elements[i] !== other.elements[i])
|
|
151
|
+
return false;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
if (Math.abs(this.elements[i] - other.elements[i]) > tolerance)
|
|
155
|
+
return false;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
clone() {
|
|
161
|
+
return new Matrix4([...this.elements]);
|
|
162
|
+
}
|
|
163
|
+
toArray() {
|
|
164
|
+
return [...this.elements];
|
|
165
|
+
}
|
|
166
|
+
toString() {
|
|
167
|
+
const m = this.elements;
|
|
168
|
+
return `Matrix4(\n ${m[0]}, ${m[4]}, ${m[8]}, ${m[12]}\n ${m[1]}, ${m[5]}, ${m[9]}, ${m[13]}\n ${m[2]}, ${m[6]}, ${m[10]}, ${m[14]}\n ${m[3]}, ${m[7]}, ${m[11]}, ${m[15]}\n)`;
|
|
169
|
+
}
|
|
170
|
+
static identity() {
|
|
171
|
+
return new Matrix4();
|
|
172
|
+
}
|
|
173
|
+
static fromTranslation(x, y, z) {
|
|
174
|
+
return new Matrix4([
|
|
175
|
+
1, 0, 0, 0,
|
|
176
|
+
0, 1, 0, 0,
|
|
177
|
+
0, 0, 1, 0,
|
|
178
|
+
x, y, z, 1,
|
|
179
|
+
]);
|
|
180
|
+
}
|
|
181
|
+
static fromTranslationVector(v) {
|
|
182
|
+
return Matrix4.fromTranslation(v.x, v.y, v.z);
|
|
183
|
+
}
|
|
184
|
+
static fromScale(x, y, z) {
|
|
185
|
+
return new Matrix4([
|
|
186
|
+
x, 0, 0, 0,
|
|
187
|
+
0, y, 0, 0,
|
|
188
|
+
0, 0, z, 0,
|
|
189
|
+
0, 0, 0, 1,
|
|
190
|
+
]);
|
|
191
|
+
}
|
|
192
|
+
static fromUniformScale(s) {
|
|
193
|
+
return Matrix4.fromScale(s, s, s);
|
|
194
|
+
}
|
|
195
|
+
static fromRotationX(angle) {
|
|
196
|
+
const c = Math.cos(angle);
|
|
197
|
+
const s = Math.sin(angle);
|
|
198
|
+
return new Matrix4([
|
|
199
|
+
1, 0, 0, 0,
|
|
200
|
+
0, c, s, 0,
|
|
201
|
+
0, -s, c, 0,
|
|
202
|
+
0, 0, 0, 1,
|
|
203
|
+
]);
|
|
204
|
+
}
|
|
205
|
+
static fromRotationY(angle) {
|
|
206
|
+
const c = Math.cos(angle);
|
|
207
|
+
const s = Math.sin(angle);
|
|
208
|
+
return new Matrix4([
|
|
209
|
+
c, 0, -s, 0,
|
|
210
|
+
0, 1, 0, 0,
|
|
211
|
+
s, 0, c, 0,
|
|
212
|
+
0, 0, 0, 1,
|
|
213
|
+
]);
|
|
214
|
+
}
|
|
215
|
+
static fromRotationZ(angle) {
|
|
216
|
+
const c = Math.cos(angle);
|
|
217
|
+
const s = Math.sin(angle);
|
|
218
|
+
return new Matrix4([
|
|
219
|
+
c, s, 0, 0,
|
|
220
|
+
-s, c, 0, 0,
|
|
221
|
+
0, 0, 1, 0,
|
|
222
|
+
0, 0, 0, 1,
|
|
223
|
+
]);
|
|
224
|
+
}
|
|
225
|
+
static fromAxisAngle(axis, angle) {
|
|
226
|
+
const c = Math.cos(angle);
|
|
227
|
+
const s = Math.sin(angle);
|
|
228
|
+
const t = 1 - c;
|
|
229
|
+
const n = axis.normalize();
|
|
230
|
+
const x = n.x, y = n.y, z = n.z;
|
|
231
|
+
return new Matrix4([
|
|
232
|
+
t * x * x + c, t * x * y + s * z, t * x * z - s * y, 0,
|
|
233
|
+
t * x * y - s * z, t * y * y + c, t * y * z + s * x, 0,
|
|
234
|
+
t * x * z + s * y, t * y * z - s * x, t * z * z + c, 0,
|
|
235
|
+
0, 0, 0, 1,
|
|
236
|
+
]);
|
|
237
|
+
}
|
|
238
|
+
static fromRotationAroundAxis(origin, direction, angle) {
|
|
239
|
+
const c = Math.cos(angle);
|
|
240
|
+
const s = Math.sin(angle);
|
|
241
|
+
const t = 1 - c;
|
|
242
|
+
const n = direction.normalize();
|
|
243
|
+
const x = n.x, y = n.y, z = n.z;
|
|
244
|
+
const px = origin.x, py = origin.y, pz = origin.z;
|
|
245
|
+
const r00 = t * x * x + c;
|
|
246
|
+
const r10 = t * x * y + s * z;
|
|
247
|
+
const r20 = t * x * z - s * y;
|
|
248
|
+
const r01 = t * x * y - s * z;
|
|
249
|
+
const r11 = t * y * y + c;
|
|
250
|
+
const r21 = t * y * z + s * x;
|
|
251
|
+
const r02 = t * x * z + s * y;
|
|
252
|
+
const r12 = t * y * z - s * x;
|
|
253
|
+
const r22 = t * z * z + c;
|
|
254
|
+
const tx = px - (r00 * px + r01 * py + r02 * pz);
|
|
255
|
+
const ty = py - (r10 * px + r11 * py + r12 * pz);
|
|
256
|
+
const tz = pz - (r20 * px + r21 * py + r22 * pz);
|
|
257
|
+
return new Matrix4([
|
|
258
|
+
r00, r10, r20, 0,
|
|
259
|
+
r01, r11, r21, 0,
|
|
260
|
+
r02, r12, r22, 0,
|
|
261
|
+
tx, ty, tz, 1,
|
|
262
|
+
]);
|
|
263
|
+
}
|
|
264
|
+
static fromQuaternion(q) {
|
|
265
|
+
return new Matrix4(q.toMatrix());
|
|
266
|
+
}
|
|
267
|
+
static fromEulerAngles(x, y, z) {
|
|
268
|
+
const q = Quaternion.fromEulerAngles(x, y, z);
|
|
269
|
+
return Matrix4.fromQuaternion(q);
|
|
270
|
+
}
|
|
271
|
+
static fromBasis(xAxis, yAxis, zAxis, origin = Point.origin()) {
|
|
272
|
+
return new Matrix4([
|
|
273
|
+
xAxis.x, xAxis.y, xAxis.z, 0,
|
|
274
|
+
yAxis.x, yAxis.y, yAxis.z, 0,
|
|
275
|
+
zAxis.x, zAxis.y, zAxis.z, 0,
|
|
276
|
+
origin.x, origin.y, origin.z, 1,
|
|
277
|
+
]);
|
|
278
|
+
}
|
|
279
|
+
static compose(translation, rotation, scale) {
|
|
280
|
+
const rotMatrix = Matrix4.fromQuaternion(rotation);
|
|
281
|
+
const scaleMatrix = Matrix4.fromScale(scale.x, scale.y, scale.z);
|
|
282
|
+
const translationMatrix = Matrix4.fromTranslationVector(translation);
|
|
283
|
+
return translationMatrix.multiply(rotMatrix).multiply(scaleMatrix);
|
|
284
|
+
}
|
|
285
|
+
static lookAt(eye, target, up = Vector3d.unitY()) {
|
|
286
|
+
const zAxis = eye.vectorTo(target).normalize().negate();
|
|
287
|
+
const xAxis = up.cross(zAxis).normalize();
|
|
288
|
+
const yAxis = zAxis.cross(xAxis);
|
|
289
|
+
return new Matrix4([
|
|
290
|
+
xAxis.x, yAxis.x, zAxis.x, 0,
|
|
291
|
+
xAxis.y, yAxis.y, zAxis.y, 0,
|
|
292
|
+
xAxis.z, yAxis.z, zAxis.z, 0,
|
|
293
|
+
-xAxis.dot(eye.toVector3d()), -yAxis.dot(eye.toVector3d()), -zAxis.dot(eye.toVector3d()), 1,
|
|
294
|
+
]);
|
|
295
|
+
}
|
|
296
|
+
static mirrorPoint(point) {
|
|
297
|
+
const px = point.x, py = point.y, pz = point.z;
|
|
298
|
+
return new Matrix4([
|
|
299
|
+
-1, 0, 0, 0,
|
|
300
|
+
0, -1, 0, 0,
|
|
301
|
+
0, 0, -1, 0,
|
|
302
|
+
2 * px, 2 * py, 2 * pz, 1,
|
|
303
|
+
]);
|
|
304
|
+
}
|
|
305
|
+
static mirrorPlane(normal, pointOnPlane) {
|
|
306
|
+
const n = normal.normalize();
|
|
307
|
+
const d = -n.dot(pointOnPlane.toVector3d());
|
|
308
|
+
const a = n.x, b = n.y, c = n.z;
|
|
309
|
+
return new Matrix4([
|
|
310
|
+
1 - 2 * a * a, -2 * a * b, -2 * a * c, 0,
|
|
311
|
+
-2 * a * b, 1 - 2 * b * b, -2 * b * c, 0,
|
|
312
|
+
-2 * a * c, -2 * b * c, 1 - 2 * c * c, 0,
|
|
313
|
+
-2 * a * d, -2 * b * d, -2 * c * d, 1,
|
|
314
|
+
]);
|
|
315
|
+
}
|
|
316
|
+
static mirrorAxis(axisOrigin, axisDirection) {
|
|
317
|
+
const d = axisDirection.normalize();
|
|
318
|
+
const p = axisOrigin;
|
|
319
|
+
const dx = d.x, dy = d.y, dz = d.z;
|
|
320
|
+
const px = p.x, py = p.y, pz = p.z;
|
|
321
|
+
const xx = dx * dx, yy = dy * dy, zz = dz * dz;
|
|
322
|
+
const xy = dx * dy, xz = dx * dz, yz = dy * dz;
|
|
323
|
+
return new Matrix4([
|
|
324
|
+
2 * xx - 1, 2 * xy, 2 * xz, 0,
|
|
325
|
+
2 * xy, 2 * yy - 1, 2 * yz, 0,
|
|
326
|
+
2 * xz, 2 * yz, 2 * zz - 1, 0,
|
|
327
|
+
2 * (px - xx * px - xy * py - xz * pz),
|
|
328
|
+
2 * (py - xy * px - yy * py - yz * pz),
|
|
329
|
+
2 * (pz - xz * px - yz * py - zz * pz),
|
|
330
|
+
1,
|
|
331
|
+
]);
|
|
332
|
+
}
|
|
333
|
+
static fromArray(arr) {
|
|
334
|
+
return new Matrix4(arr);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { Matrix4 } from "./matrix4.js";
|
|
3
|
+
import { Vector3d } from "./vector3d.js";
|
|
4
|
+
import { Point } from "./point.js";
|
|
5
|
+
import { Quaternion } from "./quaternion.js";
|
|
6
|
+
describe("Matrix4", () => {
|
|
7
|
+
describe("constructor", () => {
|
|
8
|
+
it("creates identity matrix by default", () => {
|
|
9
|
+
const m = new Matrix4();
|
|
10
|
+
expect(m.get(0, 0)).toBe(1);
|
|
11
|
+
expect(m.get(1, 1)).toBe(1);
|
|
12
|
+
expect(m.get(2, 2)).toBe(1);
|
|
13
|
+
expect(m.get(3, 3)).toBe(1);
|
|
14
|
+
expect(m.get(0, 1)).toBe(0);
|
|
15
|
+
});
|
|
16
|
+
it("creates matrix from array", () => {
|
|
17
|
+
const elements = [
|
|
18
|
+
1, 2, 3, 4,
|
|
19
|
+
5, 6, 7, 8,
|
|
20
|
+
9, 10, 11, 12,
|
|
21
|
+
13, 14, 15, 16,
|
|
22
|
+
];
|
|
23
|
+
const m = new Matrix4(elements);
|
|
24
|
+
expect(m.get(0, 0)).toBe(1);
|
|
25
|
+
expect(m.get(1, 0)).toBe(2);
|
|
26
|
+
expect(m.get(0, 1)).toBe(5);
|
|
27
|
+
});
|
|
28
|
+
it("throws for wrong array length", () => {
|
|
29
|
+
expect(() => new Matrix4([1, 2, 3])).toThrow();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
describe("identity", () => {
|
|
33
|
+
it("returns identity matrix", () => {
|
|
34
|
+
const m = Matrix4.identity();
|
|
35
|
+
expect(m.get(0, 0)).toBe(1);
|
|
36
|
+
expect(m.get(1, 1)).toBe(1);
|
|
37
|
+
expect(m.get(2, 2)).toBe(1);
|
|
38
|
+
expect(m.get(3, 3)).toBe(1);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe("multiply", () => {
|
|
42
|
+
it("identity * M = M", () => {
|
|
43
|
+
const m = Matrix4.fromTranslation(1, 2, 3);
|
|
44
|
+
const result = Matrix4.identity().multiply(m);
|
|
45
|
+
expect(result.equals(m)).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
it("M * identity = M", () => {
|
|
48
|
+
const m = Matrix4.fromTranslation(1, 2, 3);
|
|
49
|
+
const result = m.multiply(Matrix4.identity());
|
|
50
|
+
expect(result.equals(m)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
it("combines translations correctly", () => {
|
|
53
|
+
const t1 = Matrix4.fromTranslation(1, 0, 0);
|
|
54
|
+
const t2 = Matrix4.fromTranslation(0, 2, 0);
|
|
55
|
+
const combined = t1.multiply(t2);
|
|
56
|
+
const p = combined.transformPoint(Point.origin());
|
|
57
|
+
expect(p.x).toBeCloseTo(1);
|
|
58
|
+
expect(p.y).toBeCloseTo(2);
|
|
59
|
+
expect(p.z).toBeCloseTo(0);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe("determinant", () => {
|
|
63
|
+
it("identity has determinant 1", () => {
|
|
64
|
+
const m = Matrix4.identity();
|
|
65
|
+
expect(m.determinant()).toBe(1);
|
|
66
|
+
});
|
|
67
|
+
it("scale matrix has determinant = product of scales", () => {
|
|
68
|
+
const m = Matrix4.fromScale(2, 3, 4);
|
|
69
|
+
expect(m.determinant()).toBeCloseTo(24);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
describe("inverse", () => {
|
|
73
|
+
it("M * M^-1 = identity", () => {
|
|
74
|
+
const m = Matrix4.fromTranslation(1, 2, 3);
|
|
75
|
+
const inv = m.inverse();
|
|
76
|
+
const result = m.multiply(inv);
|
|
77
|
+
expect(result.equals(Matrix4.identity(), 1e-10)).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
it("inverts rotation matrix", () => {
|
|
80
|
+
const m = Matrix4.fromRotationZ(Math.PI / 4);
|
|
81
|
+
const inv = m.inverse();
|
|
82
|
+
const result = m.multiply(inv);
|
|
83
|
+
expect(result.equals(Matrix4.identity(), 1e-10)).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
it("inverts complex transformation", () => {
|
|
86
|
+
const m = Matrix4.fromTranslation(1, 2, 3)
|
|
87
|
+
.multiply(Matrix4.fromRotationY(Math.PI / 6))
|
|
88
|
+
.multiply(Matrix4.fromScale(2, 2, 2));
|
|
89
|
+
const inv = m.inverse();
|
|
90
|
+
const result = m.multiply(inv);
|
|
91
|
+
expect(result.equals(Matrix4.identity(), 1e-10)).toBe(true);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
describe("transpose", () => {
|
|
95
|
+
it("swaps rows and columns", () => {
|
|
96
|
+
const m = new Matrix4([
|
|
97
|
+
1, 2, 3, 4,
|
|
98
|
+
5, 6, 7, 8,
|
|
99
|
+
9, 10, 11, 12,
|
|
100
|
+
13, 14, 15, 16,
|
|
101
|
+
]);
|
|
102
|
+
const t = m.transpose();
|
|
103
|
+
expect(t.get(0, 1)).toBe(m.get(1, 0));
|
|
104
|
+
expect(t.get(1, 0)).toBe(m.get(0, 1));
|
|
105
|
+
});
|
|
106
|
+
it("double transpose returns original", () => {
|
|
107
|
+
const m = Matrix4.fromRotationZ(Math.PI / 4);
|
|
108
|
+
const result = m.transpose().transpose();
|
|
109
|
+
expect(result.equals(m, 1e-10)).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
describe("fromTranslation", () => {
|
|
113
|
+
it("creates translation matrix", () => {
|
|
114
|
+
const m = Matrix4.fromTranslation(10, 20, 30);
|
|
115
|
+
const p = m.transformPoint(Point.origin());
|
|
116
|
+
expect(p.x).toBe(10);
|
|
117
|
+
expect(p.y).toBe(20);
|
|
118
|
+
expect(p.z).toBe(30);
|
|
119
|
+
});
|
|
120
|
+
it("does not affect vectors", () => {
|
|
121
|
+
const m = Matrix4.fromTranslation(10, 20, 30);
|
|
122
|
+
const v = m.transformVector(new Vector3d(1, 0, 0));
|
|
123
|
+
expect(v.x).toBe(1);
|
|
124
|
+
expect(v.y).toBe(0);
|
|
125
|
+
expect(v.z).toBe(0);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
describe("fromScale", () => {
|
|
129
|
+
it("creates scale matrix", () => {
|
|
130
|
+
const m = Matrix4.fromScale(2, 3, 4);
|
|
131
|
+
const p = m.transformPoint(new Point(1, 1, 1));
|
|
132
|
+
expect(p.x).toBe(2);
|
|
133
|
+
expect(p.y).toBe(3);
|
|
134
|
+
expect(p.z).toBe(4);
|
|
135
|
+
});
|
|
136
|
+
it("scales vectors", () => {
|
|
137
|
+
const m = Matrix4.fromScale(2, 3, 4);
|
|
138
|
+
const v = m.transformVector(new Vector3d(1, 1, 1));
|
|
139
|
+
expect(v.x).toBe(2);
|
|
140
|
+
expect(v.y).toBe(3);
|
|
141
|
+
expect(v.z).toBe(4);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
describe("fromUniformScale", () => {
|
|
145
|
+
it("scales uniformly", () => {
|
|
146
|
+
const m = Matrix4.fromUniformScale(3);
|
|
147
|
+
const p = m.transformPoint(new Point(1, 2, 3));
|
|
148
|
+
expect(p.x).toBe(3);
|
|
149
|
+
expect(p.y).toBe(6);
|
|
150
|
+
expect(p.z).toBe(9);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
describe("fromRotationX", () => {
|
|
154
|
+
it("rotates around X axis", () => {
|
|
155
|
+
const m = Matrix4.fromRotationX(Math.PI / 2);
|
|
156
|
+
const p = m.transformPoint(new Point(0, 1, 0));
|
|
157
|
+
expect(p.x).toBeCloseTo(0);
|
|
158
|
+
expect(p.y).toBeCloseTo(0);
|
|
159
|
+
expect(p.z).toBeCloseTo(1);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
describe("fromRotationY", () => {
|
|
163
|
+
it("rotates around Y axis", () => {
|
|
164
|
+
const m = Matrix4.fromRotationY(Math.PI / 2);
|
|
165
|
+
const p = m.transformPoint(new Point(1, 0, 0));
|
|
166
|
+
expect(p.x).toBeCloseTo(0);
|
|
167
|
+
expect(p.y).toBeCloseTo(0);
|
|
168
|
+
expect(p.z).toBeCloseTo(-1);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
describe("fromRotationZ", () => {
|
|
172
|
+
it("rotates around Z axis", () => {
|
|
173
|
+
const m = Matrix4.fromRotationZ(Math.PI / 2);
|
|
174
|
+
const p = m.transformPoint(new Point(1, 0, 0));
|
|
175
|
+
expect(p.x).toBeCloseTo(0);
|
|
176
|
+
expect(p.y).toBeCloseTo(1);
|
|
177
|
+
expect(p.z).toBeCloseTo(0);
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
describe("fromAxisAngle", () => {
|
|
181
|
+
it("rotates around arbitrary axis", () => {
|
|
182
|
+
const m = Matrix4.fromAxisAngle(Vector3d.unitZ(), Math.PI / 2);
|
|
183
|
+
const p = m.transformPoint(new Point(1, 0, 0));
|
|
184
|
+
expect(p.x).toBeCloseTo(0);
|
|
185
|
+
expect(p.y).toBeCloseTo(1);
|
|
186
|
+
expect(p.z).toBeCloseTo(0);
|
|
187
|
+
});
|
|
188
|
+
it("rotates around diagonal axis", () => {
|
|
189
|
+
const axis = new Vector3d(1, 1, 0).normalize();
|
|
190
|
+
const m = Matrix4.fromAxisAngle(axis, Math.PI);
|
|
191
|
+
const p = m.transformPoint(new Point(1, 0, 0));
|
|
192
|
+
expect(p.x).toBeCloseTo(0);
|
|
193
|
+
expect(p.y).toBeCloseTo(1);
|
|
194
|
+
expect(p.z).toBeCloseTo(0);
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
describe("fromQuaternion", () => {
|
|
198
|
+
it("creates rotation matrix from quaternion", () => {
|
|
199
|
+
const q = Quaternion.fromAxisAngle(Vector3d.unitZ(), Math.PI / 2);
|
|
200
|
+
const m = Matrix4.fromQuaternion(q);
|
|
201
|
+
const p = m.transformPoint(new Point(1, 0, 0));
|
|
202
|
+
expect(p.x).toBeCloseTo(0);
|
|
203
|
+
expect(p.y).toBeCloseTo(1);
|
|
204
|
+
expect(p.z).toBeCloseTo(0);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
describe("fromEulerAngles", () => {
|
|
208
|
+
it("creates rotation from euler angles", () => {
|
|
209
|
+
const m = Matrix4.fromEulerAngles(0, 0, Math.PI / 2);
|
|
210
|
+
const p = m.transformPoint(new Point(1, 0, 0));
|
|
211
|
+
expect(p.x).toBeCloseTo(0);
|
|
212
|
+
expect(p.y).toBeCloseTo(1);
|
|
213
|
+
expect(p.z).toBeCloseTo(0);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
describe("mirrorPoint", () => {
|
|
217
|
+
it("mirrors through a point", () => {
|
|
218
|
+
const m = Matrix4.mirrorPoint(new Point(5, 0, 0));
|
|
219
|
+
const p = m.transformPoint(new Point(3, 0, 0));
|
|
220
|
+
expect(p.x).toBeCloseTo(7);
|
|
221
|
+
expect(p.y).toBeCloseTo(0);
|
|
222
|
+
expect(p.z).toBeCloseTo(0);
|
|
223
|
+
});
|
|
224
|
+
it("mirrors through origin", () => {
|
|
225
|
+
const m = Matrix4.mirrorPoint(Point.origin());
|
|
226
|
+
const p = m.transformPoint(new Point(1, 2, 3));
|
|
227
|
+
expect(p.x).toBeCloseTo(-1);
|
|
228
|
+
expect(p.y).toBeCloseTo(-2);
|
|
229
|
+
expect(p.z).toBeCloseTo(-3);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
describe("mirrorPlane", () => {
|
|
233
|
+
it("mirrors through XY plane", () => {
|
|
234
|
+
const m = Matrix4.mirrorPlane(Vector3d.unitZ(), Point.origin());
|
|
235
|
+
const p = m.transformPoint(new Point(1, 2, 3));
|
|
236
|
+
expect(p.x).toBeCloseTo(1);
|
|
237
|
+
expect(p.y).toBeCloseTo(2);
|
|
238
|
+
expect(p.z).toBeCloseTo(-3);
|
|
239
|
+
});
|
|
240
|
+
it("mirrors through YZ plane", () => {
|
|
241
|
+
const m = Matrix4.mirrorPlane(Vector3d.unitX(), Point.origin());
|
|
242
|
+
const p = m.transformPoint(new Point(1, 2, 3));
|
|
243
|
+
expect(p.x).toBeCloseTo(-1);
|
|
244
|
+
expect(p.y).toBeCloseTo(2);
|
|
245
|
+
expect(p.z).toBeCloseTo(3);
|
|
246
|
+
});
|
|
247
|
+
it("mirrors through offset plane", () => {
|
|
248
|
+
const m = Matrix4.mirrorPlane(Vector3d.unitX(), new Point(5, 0, 0));
|
|
249
|
+
const p = m.transformPoint(new Point(3, 0, 0));
|
|
250
|
+
expect(p.x).toBeCloseTo(7);
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
describe("mirrorAxis", () => {
|
|
254
|
+
it("mirrors through Z axis", () => {
|
|
255
|
+
const m = Matrix4.mirrorAxis(Point.origin(), Vector3d.unitZ());
|
|
256
|
+
const p = m.transformPoint(new Point(1, 0, 0));
|
|
257
|
+
expect(p.x).toBeCloseTo(-1);
|
|
258
|
+
expect(p.y).toBeCloseTo(0);
|
|
259
|
+
expect(p.z).toBeCloseTo(0);
|
|
260
|
+
});
|
|
261
|
+
it("mirrors through offset axis", () => {
|
|
262
|
+
const m = Matrix4.mirrorAxis(new Point(5, 0, 0), Vector3d.unitZ());
|
|
263
|
+
const p = m.transformPoint(new Point(3, 0, 0));
|
|
264
|
+
expect(p.x).toBeCloseTo(7);
|
|
265
|
+
expect(p.y).toBeCloseTo(0);
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
describe("transformPoint", () => {
|
|
269
|
+
it("applies translation", () => {
|
|
270
|
+
const m = Matrix4.fromTranslation(10, 20, 30);
|
|
271
|
+
const p = m.transformPoint(new Point(1, 2, 3));
|
|
272
|
+
expect(p.x).toBe(11);
|
|
273
|
+
expect(p.y).toBe(22);
|
|
274
|
+
expect(p.z).toBe(33);
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
describe("transformVector", () => {
|
|
278
|
+
it("applies rotation but not translation", () => {
|
|
279
|
+
const m = Matrix4.fromTranslation(10, 20, 30)
|
|
280
|
+
.multiply(Matrix4.fromRotationZ(Math.PI / 2));
|
|
281
|
+
const v = m.transformVector(new Vector3d(1, 0, 0));
|
|
282
|
+
expect(v.x).toBeCloseTo(0);
|
|
283
|
+
expect(v.y).toBeCloseTo(1);
|
|
284
|
+
expect(v.z).toBeCloseTo(0);
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
describe("transformDirection", () => {
|
|
288
|
+
it("returns normalized result", () => {
|
|
289
|
+
const m = Matrix4.fromScale(2, 2, 2);
|
|
290
|
+
const d = m.transformDirection(new Vector3d(1, 0, 0));
|
|
291
|
+
expect(d.length()).toBeCloseTo(1);
|
|
292
|
+
});
|
|
293
|
+
});
|
|
294
|
+
describe("decompose", () => {
|
|
295
|
+
it("extracts translation", () => {
|
|
296
|
+
const m = Matrix4.fromTranslation(1, 2, 3);
|
|
297
|
+
const { translation } = m.decompose();
|
|
298
|
+
expect(translation.x).toBeCloseTo(1);
|
|
299
|
+
expect(translation.y).toBeCloseTo(2);
|
|
300
|
+
expect(translation.z).toBeCloseTo(3);
|
|
301
|
+
});
|
|
302
|
+
it("extracts scale", () => {
|
|
303
|
+
const m = Matrix4.fromScale(2, 3, 4);
|
|
304
|
+
const { scale } = m.decompose();
|
|
305
|
+
expect(scale.x).toBeCloseTo(2);
|
|
306
|
+
expect(scale.y).toBeCloseTo(3);
|
|
307
|
+
expect(scale.z).toBeCloseTo(4);
|
|
308
|
+
});
|
|
309
|
+
it("extracts rotation", () => {
|
|
310
|
+
const m = Matrix4.fromRotationZ(Math.PI / 4);
|
|
311
|
+
const { rotation } = m.decompose();
|
|
312
|
+
const v = rotation.rotateVector(new Vector3d(1, 0, 0));
|
|
313
|
+
expect(v.x).toBeCloseTo(Math.cos(Math.PI / 4));
|
|
314
|
+
expect(v.y).toBeCloseTo(Math.sin(Math.PI / 4));
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
describe("compose", () => {
|
|
318
|
+
it("creates matrix from translation, rotation, scale", () => {
|
|
319
|
+
const translation = new Vector3d(10, 20, 30);
|
|
320
|
+
const rotation = Quaternion.fromAxisAngle(Vector3d.unitZ(), Math.PI / 2);
|
|
321
|
+
const scale = new Vector3d(2, 2, 2);
|
|
322
|
+
const m = Matrix4.compose(translation, rotation, scale);
|
|
323
|
+
const p = m.transformPoint(new Point(1, 0, 0));
|
|
324
|
+
// First scale (1,0,0) -> (2,0,0)
|
|
325
|
+
// Then rotate 90° around Z -> (0,2,0)
|
|
326
|
+
// Then translate -> (10,22,30)
|
|
327
|
+
expect(p.x).toBeCloseTo(10);
|
|
328
|
+
expect(p.y).toBeCloseTo(22);
|
|
329
|
+
expect(p.z).toBeCloseTo(30);
|
|
330
|
+
});
|
|
331
|
+
});
|
|
332
|
+
describe("equals", () => {
|
|
333
|
+
it("returns true for identical matrices", () => {
|
|
334
|
+
const m1 = Matrix4.fromTranslation(1, 2, 3);
|
|
335
|
+
const m2 = Matrix4.fromTranslation(1, 2, 3);
|
|
336
|
+
expect(m1.equals(m2)).toBe(true);
|
|
337
|
+
});
|
|
338
|
+
it("returns false for different matrices", () => {
|
|
339
|
+
const m1 = Matrix4.fromTranslation(1, 2, 3);
|
|
340
|
+
const m2 = Matrix4.fromTranslation(1, 2, 4);
|
|
341
|
+
expect(m1.equals(m2)).toBe(false);
|
|
342
|
+
});
|
|
343
|
+
it("supports tolerance", () => {
|
|
344
|
+
const m1 = Matrix4.fromTranslation(1, 2, 3);
|
|
345
|
+
const m2 = Matrix4.fromTranslation(1.001, 2.001, 3.001);
|
|
346
|
+
expect(m1.equals(m2, 0.01)).toBe(true);
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
describe("clone", () => {
|
|
350
|
+
it("creates independent copy", () => {
|
|
351
|
+
const m = Matrix4.fromTranslation(1, 2, 3);
|
|
352
|
+
const clone = m.clone();
|
|
353
|
+
expect(clone.equals(m)).toBe(true);
|
|
354
|
+
expect(clone).not.toBe(m);
|
|
355
|
+
});
|
|
356
|
+
});
|
|
357
|
+
});
|