@bitbybit-dev/base 1.5.0 → 1.6.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api/GlobalCDNProvider.js +1 -1
- package/lib/api/bearings/ansi-bearings.constants.d.ts +2 -0
- package/lib/api/bearings/ansi-bearings.constants.js +26 -0
- package/lib/api/bearings/ansi-bearings.d.ts +4 -0
- package/lib/api/bearings/ansi-bearings.js +14 -0
- package/lib/api/bearings/bearing-types.d.ts +25 -0
- package/lib/api/bearings/bearing-types.js +1 -0
- package/lib/api/bearings/bearings.constants.d.ts +1 -0
- package/lib/api/bearings/bearings.constants.js +1 -0
- package/lib/api/bearings/iso-bearings.constants.d.ts +2 -0
- package/lib/api/bearings/iso-bearings.constants.js +30 -0
- package/lib/api/bearings/iso-bearings.d.ts +4 -0
- package/lib/api/bearings/iso-bearings.js +14 -0
- package/lib/api/color-space.d.ts +2 -0
- package/lib/api/color-space.js +5 -8
- package/lib/api/fasteners/ansi-fasteners.constants.d.ts +16 -0
- package/lib/api/fasteners/ansi-fasteners.constants.js +118 -0
- package/lib/api/fasteners/ansi-fasteners.d.ts +8 -0
- package/lib/api/fasteners/ansi-fasteners.js +64 -0
- package/lib/api/fasteners/fastener-types.d.ts +161 -0
- package/lib/api/fasteners/fastener-types.js +1 -0
- package/lib/api/fasteners/fasteners.constants.d.ts +5 -0
- package/lib/api/fasteners/fasteners.constants.js +5 -0
- package/lib/api/fasteners/fasteners.d.ts +2 -0
- package/lib/api/fasteners/fasteners.js +9 -0
- package/lib/api/fasteners/iso-fasteners.constants.d.ts +23 -0
- package/lib/api/fasteners/iso-fasteners.constants.js +110 -0
- package/lib/api/fasteners/iso-fasteners.d.ts +9 -0
- package/lib/api/fasteners/iso-fasteners.js +61 -0
- package/lib/api/gears/bevel-gears.d.ts +6 -0
- package/lib/api/gears/bevel-gears.js +69 -0
- package/lib/api/gears/gear-checks.d.ts +8 -0
- package/lib/api/gears/gear-checks.js +69 -0
- package/lib/api/gears/gear-pairs.d.ts +4 -0
- package/lib/api/gears/gear-pairs.js +140 -0
- package/lib/api/gears/gear-types.d.ts +425 -0
- package/lib/api/gears/gear-types.js +1 -0
- package/lib/api/gears/gears.constants.d.ts +19 -0
- package/lib/api/gears/gears.constants.js +19 -0
- package/lib/api/gears/gears.d.ts +10 -0
- package/lib/api/gears/gears.js +156 -0
- package/lib/api/gears/helical-gears.d.ts +5 -0
- package/lib/api/gears/helical-gears.js +33 -0
- package/lib/api/gears/involute-flank.d.ts +26 -0
- package/lib/api/gears/involute-flank.js +158 -0
- package/lib/api/gears/racks.d.ts +3 -0
- package/lib/api/gears/racks.js +64 -0
- package/lib/api/index.d.ts +10 -1
- package/lib/api/index.js +0 -1
- package/lib/api/inputs/base-inputs.d.ts +450 -3
- package/lib/api/inputs/base-inputs.js +12 -0
- package/lib/api/inputs/color-inputs.d.ts +14 -0
- package/lib/api/inputs/color-inputs.js +19 -0
- package/lib/api/inputs/engineering-inputs.d.ts +1539 -0
- package/lib/api/inputs/engineering-inputs.js +2181 -0
- package/lib/api/inputs/index.d.ts +2 -0
- package/lib/api/inputs/index.js +2 -0
- package/lib/api/inputs/io-inputs.d.ts +8 -1
- package/lib/api/inputs/io-inputs.js +4 -1
- package/lib/api/inputs/math-inputs.d.ts +61 -0
- package/lib/api/inputs/math-inputs.js +85 -0
- package/lib/api/inputs/mesh-inputs.d.ts +170 -0
- package/lib/api/inputs/mesh-inputs.js +206 -0
- package/lib/api/inputs/point-inputs.d.ts +4 -4
- package/lib/api/inputs/polyline-inputs.d.ts +144 -0
- package/lib/api/inputs/polyline-inputs.js +151 -0
- package/lib/api/inputs/recipes-inputs.d.ts +76 -0
- package/lib/api/inputs/recipes-inputs.js +74 -0
- package/lib/api/inputs/transforms-inputs.d.ts +34 -0
- package/lib/api/inputs/transforms-inputs.js +35 -0
- package/lib/api/keys/ansi-keys.constants.d.ts +3 -0
- package/lib/api/keys/ansi-keys.constants.js +16 -0
- package/lib/api/keys/ansi-keys.d.ts +3 -0
- package/lib/api/keys/ansi-keys.js +14 -0
- package/lib/api/keys/din-keys.constants.d.ts +3 -0
- package/lib/api/keys/din-keys.constants.js +14 -0
- package/lib/api/keys/din-keys.d.ts +3 -0
- package/lib/api/keys/din-keys.js +13 -0
- package/lib/api/keys/key-types.d.ts +17 -0
- package/lib/api/keys/key-types.js +1 -0
- package/lib/api/keys/keys.constants.d.ts +1 -0
- package/lib/api/keys/keys.constants.js +1 -0
- package/lib/api/knurls/ansi-knurls.constants.d.ts +4 -0
- package/lib/api/knurls/ansi-knurls.constants.js +8 -0
- package/lib/api/knurls/ansi-knurls.d.ts +3 -0
- package/lib/api/knurls/ansi-knurls.js +20 -0
- package/lib/api/knurls/din-knurls.constants.d.ts +2 -0
- package/lib/api/knurls/din-knurls.constants.js +2 -0
- package/lib/api/knurls/din-knurls.d.ts +3 -0
- package/lib/api/knurls/din-knurls.js +19 -0
- package/lib/api/knurls/knurl-types.d.ts +24 -0
- package/lib/api/knurls/knurl-types.js +1 -0
- package/lib/api/knurls/knurls.constants.d.ts +1 -0
- package/lib/api/knurls/knurls.constants.js +1 -0
- package/lib/api/knurls/knurls.d.ts +2 -0
- package/lib/api/knurls/knurls.js +9 -0
- package/lib/api/recipes/checks.d.ts +15 -0
- package/lib/api/recipes/checks.js +85 -0
- package/lib/api/recipes/limits.constants.d.ts +4 -0
- package/lib/api/recipes/limits.constants.js +4 -0
- package/lib/api/recipes/sources.d.ts +0 -13
- package/lib/api/recipes/sources.js +3 -15
- package/lib/api/recipes/surface-mesh.d.ts +0 -14
- package/lib/api/recipes/surface-mesh.js +8 -21
- package/lib/api/recipes/validate-brep.d.ts +2 -0
- package/lib/api/recipes/validate-brep.js +330 -0
- package/lib/api/recipes/validate.d.ts +0 -31
- package/lib/api/recipes/validate.js +7 -115
- package/lib/api/resolved-inputs/index.d.ts +80 -0
- package/lib/api/retaining-rings/ansi-retaining-rings.constants.d.ts +4 -0
- package/lib/api/retaining-rings/ansi-retaining-rings.constants.js +93 -0
- package/lib/api/retaining-rings/ansi-retaining-rings.d.ts +4 -0
- package/lib/api/retaining-rings/ansi-retaining-rings.js +20 -0
- package/lib/api/retaining-rings/din-retaining-rings.constants.d.ts +3 -0
- package/lib/api/retaining-rings/din-retaining-rings.constants.js +115 -0
- package/lib/api/retaining-rings/din-retaining-rings.d.ts +4 -0
- package/lib/api/retaining-rings/din-retaining-rings.js +20 -0
- package/lib/api/retaining-rings/retaining-ring-types.d.ts +30 -0
- package/lib/api/retaining-rings/retaining-ring-types.js +1 -0
- package/lib/api/retaining-rings/retaining-rings.constants.d.ts +1 -0
- package/lib/api/retaining-rings/retaining-rings.constants.js +1 -0
- package/lib/api/retaining-rings/retaining-rings.d.ts +2 -0
- package/lib/api/retaining-rings/retaining-rings.js +9 -0
- package/lib/api/services/base-bitbybit.d.ts +42 -0
- package/lib/api/services/base-bitbybit.js +43 -0
- package/lib/api/services/color.d.ts +35 -2
- package/lib/api/services/color.js +48 -12
- package/lib/api/services/engineering/engineering.d.ts +12 -0
- package/lib/api/services/engineering/engineering.js +13 -0
- package/lib/api/services/engineering/index.d.ts +2 -0
- package/lib/api/services/engineering/index.js +2 -0
- package/lib/api/services/engineering/mechanical/bearings-ansi.d.ts +40 -0
- package/lib/api/services/engineering/mechanical/bearings-ansi.js +47 -0
- package/lib/api/services/engineering/mechanical/bearings-iso.d.ts +39 -0
- package/lib/api/services/engineering/mechanical/bearings-iso.js +46 -0
- package/lib/api/services/engineering/mechanical/bearings.d.ts +14 -0
- package/lib/api/services/engineering/mechanical/bearings.js +15 -0
- package/lib/api/services/engineering/mechanical/fasteners-ansi.d.ts +109 -0
- package/lib/api/services/engineering/mechanical/fasteners-ansi.js +133 -0
- package/lib/api/services/engineering/mechanical/fasteners-iso.d.ts +123 -0
- package/lib/api/services/engineering/mechanical/fasteners-iso.js +151 -0
- package/lib/api/services/engineering/mechanical/fasteners.d.ts +13 -0
- package/lib/api/services/engineering/mechanical/fasteners.js +14 -0
- package/lib/api/services/engineering/mechanical/gears.d.ts +267 -0
- package/lib/api/services/engineering/mechanical/gears.js +318 -0
- package/lib/api/services/engineering/mechanical/index.d.ts +24 -0
- package/lib/api/services/engineering/mechanical/index.js +24 -0
- package/lib/api/services/engineering/mechanical/keys-ansi.d.ts +27 -0
- package/lib/api/services/engineering/mechanical/keys-ansi.js +32 -0
- package/lib/api/services/engineering/mechanical/keys-din.d.ts +26 -0
- package/lib/api/services/engineering/mechanical/keys-din.js +31 -0
- package/lib/api/services/engineering/mechanical/keys.d.ts +14 -0
- package/lib/api/services/engineering/mechanical/keys.js +15 -0
- package/lib/api/services/engineering/mechanical/knurls-ansi.d.ts +26 -0
- package/lib/api/services/engineering/mechanical/knurls-ansi.js +31 -0
- package/lib/api/services/engineering/mechanical/knurls-din.d.ts +26 -0
- package/lib/api/services/engineering/mechanical/knurls-din.js +31 -0
- package/lib/api/services/engineering/mechanical/knurls.d.ts +14 -0
- package/lib/api/services/engineering/mechanical/knurls.js +15 -0
- package/lib/api/services/engineering/mechanical/mechanical.d.ts +29 -0
- package/lib/api/services/engineering/mechanical/mechanical.js +30 -0
- package/lib/api/services/engineering/mechanical/retaining-rings-ansi.d.ts +43 -0
- package/lib/api/services/engineering/mechanical/retaining-rings-ansi.js +51 -0
- package/lib/api/services/engineering/mechanical/retaining-rings-din.d.ts +43 -0
- package/lib/api/services/engineering/mechanical/retaining-rings-din.js +51 -0
- package/lib/api/services/engineering/mechanical/retaining-rings.d.ts +13 -0
- package/lib/api/services/engineering/mechanical/retaining-rings.js +14 -0
- package/lib/api/services/engineering/mechanical/splines-ansi.d.ts +27 -0
- package/lib/api/services/engineering/mechanical/splines-ansi.js +32 -0
- package/lib/api/services/engineering/mechanical/splines-din.d.ts +26 -0
- package/lib/api/services/engineering/mechanical/splines-din.js +31 -0
- package/lib/api/services/engineering/mechanical/splines.d.ts +13 -0
- package/lib/api/services/engineering/mechanical/splines.js +14 -0
- package/lib/api/services/engineering/mechanical/springs.d.ts +27 -0
- package/lib/api/services/engineering/mechanical/springs.js +31 -0
- package/lib/api/services/engineering/mechanical/threads-ansi.d.ts +40 -0
- package/lib/api/services/engineering/mechanical/threads-ansi.js +48 -0
- package/lib/api/services/engineering/mechanical/threads-iso.d.ts +40 -0
- package/lib/api/services/engineering/mechanical/threads-iso.js +48 -0
- package/lib/api/services/engineering/mechanical/threads.d.ts +13 -0
- package/lib/api/services/engineering/mechanical/threads.js +14 -0
- package/lib/api/services/frame.js +3 -3
- package/lib/api/services/geometry-helper.js +8 -111
- package/lib/api/services/helpers/color/color-space.d.ts +2 -0
- package/lib/api/services/helpers/color/color-space.js +12 -0
- package/lib/api/services/helpers/{nurbs.d.ts → curves/nurbs.d.ts} +1 -1
- package/lib/api/services/helpers/{surface-triangulation.d.ts → curves/surface-triangulation.d.ts} +2 -2
- package/lib/api/services/helpers/{surface-triangulation.js → curves/surface-triangulation.js} +14 -8
- package/lib/api/services/helpers/{dxf → files/dxf}/dxf-generator.d.ts +2 -1
- package/lib/api/services/helpers/{dxf → files/dxf}/dxf-generator.js +19 -5
- package/lib/api/services/helpers/files/dxf/dxf.constants.d.ts +4 -0
- package/lib/api/services/helpers/files/dxf/dxf.constants.js +4 -0
- package/lib/api/services/helpers/{dxf → files/dxf}/dxf.d.ts +1 -1
- package/lib/api/services/helpers/{dxf → files/dxf}/dxf.js +2 -2
- package/lib/api/services/helpers/files/glb.constants.d.ts +11 -0
- package/lib/api/services/helpers/files/glb.constants.js +11 -0
- package/lib/api/services/helpers/files/glb.d.ts +1 -0
- package/lib/api/services/helpers/files/glb.js +69 -0
- package/lib/api/services/helpers/files/gzip.constants.d.ts +11 -0
- package/lib/api/services/helpers/files/gzip.constants.js +11 -0
- package/lib/api/services/helpers/files/gzip.d.ts +2 -0
- package/lib/api/services/helpers/files/gzip.js +52 -0
- package/lib/api/services/helpers/{inflate.constants.d.ts → files/inflate.constants.d.ts} +1 -0
- package/lib/api/services/helpers/{inflate.constants.js → files/inflate.constants.js} +1 -0
- package/lib/api/services/helpers/{inflate.d.ts → files/inflate.d.ts} +1 -1
- package/lib/api/services/helpers/{inflate.js → files/inflate.js} +5 -4
- package/lib/api/services/helpers/{zip.d.ts → files/zip.d.ts} +1 -1
- package/lib/api/services/helpers/geometry/arcs.d.ts +9 -0
- package/lib/api/services/helpers/{arcs.js → geometry/arcs.js} +7 -0
- package/lib/api/services/helpers/{frame-axes.d.ts → geometry/frame-axes.d.ts} +8 -5
- package/lib/api/services/helpers/{frame-axes.js → geometry/frame-axes.js} +21 -9
- package/lib/api/services/helpers/geometry/lengths.constants.d.ts +4 -0
- package/lib/api/services/helpers/geometry/lengths.constants.js +3 -0
- package/lib/api/services/helpers/geometry/lengths.d.ts +7 -0
- package/lib/api/services/helpers/geometry/lengths.js +20 -0
- package/lib/api/services/helpers/geometry/matrices.constants.d.ts +8 -0
- package/lib/api/services/helpers/geometry/matrices.constants.js +7 -0
- package/lib/api/services/helpers/geometry/matrices.d.ts +17 -0
- package/lib/api/services/helpers/{matrices.js → geometry/matrices.js} +28 -17
- package/lib/api/services/helpers/{paths.d.ts → geometry/paths.d.ts} +2 -1
- package/lib/api/services/helpers/{paths.js → geometry/paths.js} +36 -30
- package/lib/api/services/helpers/{polygons.d.ts → geometry/polygons.d.ts} +1 -1
- package/lib/api/services/helpers/geometry/polygons.js +111 -0
- package/lib/api/services/helpers/geometry/scalars.d.ts +9 -0
- package/lib/api/services/helpers/geometry/scalars.js +34 -0
- package/lib/api/services/helpers/{triangulation.js → geometry/triangulation.js} +11 -6
- package/lib/api/services/helpers/geometry/vector-grid.d.ts +12 -0
- package/lib/api/services/helpers/geometry/vector-grid.js +149 -0
- package/lib/api/services/helpers/{vectors.d.ts → geometry/vectors.d.ts} +8 -1
- package/lib/api/services/helpers/geometry/vectors.js +43 -0
- package/lib/api/services/helpers/helper-types.d.ts +57 -0
- package/lib/api/services/helpers/mesh/mesh-normals.d.ts +21 -0
- package/lib/api/services/helpers/{mesh-normals.js → mesh/mesh-normals.js} +54 -65
- package/lib/api/services/helpers/mesh/mesh-orientation.d.ts +24 -0
- package/lib/api/services/helpers/mesh/mesh-orientation.js +104 -0
- package/lib/api/services/helpers/{mesh-primitives.d.ts → mesh/mesh-primitives.d.ts} +1 -1
- package/lib/api/services/helpers/{mesh-primitives.js → mesh/mesh-primitives.js} +6 -5
- package/lib/api/services/helpers/mesh/mesh-proximity.constants.d.ts +7 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.constants.js +11 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.d.ts +11 -0
- package/lib/api/services/helpers/mesh/mesh-proximity.js +382 -0
- package/lib/api/services/index.d.ts +3 -0
- package/lib/api/services/index.js +3 -0
- package/lib/api/services/io.d.ts +1 -1
- package/lib/api/services/io.js +1 -1
- package/lib/api/services/line.js +2 -3
- package/lib/api/services/math.d.ts +47 -0
- package/lib/api/services/math.js +77 -10
- package/lib/api/services/mesh.d.ts +174 -2
- package/lib/api/services/mesh.js +305 -7
- package/lib/api/services/point.js +4 -10
- package/lib/api/services/polyline-types.d.ts +6 -0
- package/lib/api/services/polyline-types.js +1 -0
- package/lib/api/services/polyline.d.ts +163 -1
- package/lib/api/services/polyline.js +270 -13
- package/lib/api/services/recipes.d.ts +80 -0
- package/lib/api/services/recipes.js +107 -0
- package/lib/api/services/transforms.d.ts +74 -2
- package/lib/api/services/transforms.js +100 -3
- package/lib/api/services/vector.d.ts +4 -3
- package/lib/api/services/vector.js +14 -14
- package/lib/api/splines/ansi-splines.constants.d.ts +9 -0
- package/lib/api/splines/ansi-splines.constants.js +9 -0
- package/lib/api/splines/ansi-splines.d.ts +3 -0
- package/lib/api/splines/ansi-splines.js +28 -0
- package/lib/api/splines/din-splines.constants.d.ts +12 -0
- package/lib/api/splines/din-splines.constants.js +12 -0
- package/lib/api/splines/din-splines.d.ts +3 -0
- package/lib/api/splines/din-splines.js +38 -0
- package/lib/api/splines/spline-types.d.ts +32 -0
- package/lib/api/splines/spline-types.js +1 -0
- package/lib/api/splines/splines.constants.d.ts +1 -0
- package/lib/api/splines/splines.constants.js +1 -0
- package/lib/api/springs/spring-types.d.ts +26 -0
- package/lib/api/springs/spring-types.js +1 -0
- package/lib/api/springs/springs.constants.d.ts +9 -0
- package/lib/api/springs/springs.constants.js +9 -0
- package/lib/api/springs/springs.d.ts +2 -0
- package/lib/api/springs/springs.js +50 -0
- package/lib/api/threads/ansi-threads.constants.d.ts +6 -0
- package/lib/api/threads/ansi-threads.constants.js +27 -0
- package/lib/api/threads/ansi-threads.d.ts +4 -0
- package/lib/api/threads/ansi-threads.js +50 -0
- package/lib/api/threads/iso-threads.constants.d.ts +5 -0
- package/lib/api/threads/iso-threads.constants.js +20 -0
- package/lib/api/threads/iso-threads.d.ts +4 -0
- package/lib/api/threads/iso-threads.js +32 -0
- package/lib/api/threads/thread-profile.constants.d.ts +3 -0
- package/lib/api/threads/thread-profile.constants.js +3 -0
- package/lib/api/threads/thread-types.d.ts +66 -0
- package/lib/api/threads/thread-types.js +1 -0
- package/package.json +1 -1
- package/lib/api/recipes/index.d.ts +0 -4
- package/lib/api/recipes/index.js +0 -3
- package/lib/api/services/helpers/arcs.d.ts +0 -6
- package/lib/api/services/helpers/matrices.constants.d.ts +0 -2
- package/lib/api/services/helpers/matrices.constants.js +0 -2
- package/lib/api/services/helpers/matrices.d.ts +0 -25
- package/lib/api/services/helpers/mesh-normals.d.ts +0 -11
- package/lib/api/services/helpers/polygons.js +0 -59
- package/lib/api/services/helpers/vectors.js +0 -17
- /package/lib/api/services/helpers/{nurbs.js → curves/nurbs.js} +0 -0
- /package/lib/api/services/helpers/{crc32.d.ts → files/crc32.d.ts} +0 -0
- /package/lib/api/services/helpers/{crc32.js → files/crc32.js} +0 -0
- /package/lib/api/services/helpers/{zip.constants.d.ts → files/zip.constants.d.ts} +0 -0
- /package/lib/api/services/helpers/{zip.constants.js → files/zip.constants.js} +0 -0
- /package/lib/api/services/helpers/{zip.js → files/zip.js} +0 -0
- /package/lib/api/services/helpers/{triangulation.d.ts → geometry/triangulation.d.ts} +0 -0
- /package/lib/api/services/helpers/{mesh-measures.d.ts → mesh/mesh-measures.d.ts} +0 -0
- /package/lib/api/services/helpers/{mesh-measures.js → mesh/mesh-measures.js} +0 -0
- /package/lib/api/services/helpers/{mesh-primitives.constants.d.ts → mesh/mesh-primitives.constants.d.ts} +0 -0
- /package/lib/api/services/helpers/{mesh-primitives.constants.js → mesh/mesh-primitives.constants.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BLOCK_TYPE_BITS, BYTE_BITS, CODE_LENGTH_BITS, CODE_LENGTH_ORDER, CODE_LENGTH_SYMBOLS, DISTANCE_BASE, DISTANCE_EXTRA, DISTANCE_SYMBOLS, DYNAMIC_BLOCK, END_OF_BLOCK, FIRST_LENGTH_SYMBOL, FIXED_BLOCK, FIXED_DISTANCE_BITS, FIXED_LITERAL_BITS, FIXED_LITERAL_ENDS, HCLEN_BASE, HCLEN_BITS, HDIST_BASE, HDIST_BITS, HLIT_BASE, HLIT_BITS, INITIAL_OUTPUT, LENGTH_BASE, LENGTH_EXTRA, LENGTH_MASK, LITERAL_LENGTH_SYMBOLS, MAX_CODE_BITS, REFILL_BELOW, REPEAT_PREVIOUS, REPEAT_PREVIOUS_BASE, REPEAT_PREVIOUS_BITS, REPEAT_ZERO_LONG_BASE, REPEAT_ZERO_LONG_BITS, REPEAT_ZERO_SHORT, REPEAT_ZERO_SHORT_BASE, REPEAT_ZERO_SHORT_BITS, STORED_BLOCK, STORED_HEADER_BYTES, STORED_LENGTH_BYTES, SYMBOL_SHIFT, UINT16_MASK, } from "./inflate.constants";
|
|
1
|
+
import { BLOCK_TYPE_BITS, BYTE_BITS, CODE_LENGTH_BITS, CODE_LENGTH_ORDER, CODE_LENGTH_SYMBOLS, DISTANCE_BASE, DISTANCE_EXTRA, DISTANCE_SYMBOLS, DYNAMIC_BLOCK, END_OF_BLOCK, FIRST_LENGTH_SYMBOL, FIXED_BLOCK, FIXED_DISTANCE_BITS, FIXED_LITERAL_BITS, FIXED_LITERAL_ENDS, HCLEN_BASE, HCLEN_BITS, HDIST_BASE, HDIST_BITS, HLIT_BASE, HLIT_BITS, INITIAL_OUTPUT, MOST_DEFLATE_RATIO, LENGTH_BASE, LENGTH_EXTRA, LENGTH_MASK, LITERAL_LENGTH_SYMBOLS, MAX_CODE_BITS, REFILL_BELOW, REPEAT_PREVIOUS, REPEAT_PREVIOUS_BASE, REPEAT_PREVIOUS_BITS, REPEAT_ZERO_LONG_BASE, REPEAT_ZERO_LONG_BITS, REPEAT_ZERO_SHORT, REPEAT_ZERO_SHORT_BASE, REPEAT_ZERO_SHORT_BITS, STORED_BLOCK, STORED_HEADER_BYTES, STORED_LENGTH_BYTES, SYMBOL_SHIFT, UINT16_MASK, } from "./inflate.constants";
|
|
2
2
|
function reversed(code, bits) {
|
|
3
3
|
let result = 0;
|
|
4
4
|
for (let bit = 0; bit < bits; bit++) {
|
|
@@ -57,7 +57,7 @@ class Inflater {
|
|
|
57
57
|
this.bitBuffer = 0;
|
|
58
58
|
this.bitCount = 0;
|
|
59
59
|
this.size = 0;
|
|
60
|
-
this.output = new Uint8Array(expected !== null && expected !== void 0 ? expected : Math.max(INITIAL_OUTPUT, data.length * 2));
|
|
60
|
+
this.output = new Uint8Array(Math.min(expected !== null && expected !== void 0 ? expected : Math.max(INITIAL_OUTPUT, data.length * 2), data.length * MOST_DEFLATE_RATIO + INITIAL_OUTPUT));
|
|
61
61
|
}
|
|
62
62
|
run() {
|
|
63
63
|
let last = 0;
|
|
@@ -121,10 +121,11 @@ class Inflater {
|
|
|
121
121
|
if (this.size + count <= this.output.length) {
|
|
122
122
|
return;
|
|
123
123
|
}
|
|
124
|
-
if (this.expected !== undefined) {
|
|
124
|
+
if (this.expected !== undefined && this.size + count > this.expected) {
|
|
125
125
|
throw new Error(`The deflate stream holds more than the ${this.expected} bytes expected`);
|
|
126
126
|
}
|
|
127
|
-
const
|
|
127
|
+
const wanted = Math.max(this.output.length * 2, this.size + count);
|
|
128
|
+
const grown = new Uint8Array(this.expected === undefined ? wanted : Math.min(wanted, this.expected));
|
|
128
129
|
grown.set(this.output.subarray(0, this.size));
|
|
129
130
|
this.output = grown;
|
|
130
131
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ZipEntry } from "
|
|
1
|
+
import type { ZipEntry } from "../helper-types";
|
|
2
2
|
export declare function isZip(bytes: Uint8Array): boolean;
|
|
3
3
|
export declare function zipEntries(bytes: Uint8Array): ZipEntry[];
|
|
4
4
|
export declare function zipEntryData(bytes: Uint8Array, entry: ZipEntry): Uint8Array;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type * as Inputs from "../../../inputs";
|
|
2
|
+
import type { ThreePointArc } from "../helper-types";
|
|
3
|
+
type Point2 = Inputs.Base.Point2;
|
|
4
|
+
type Point3 = Inputs.Base.Point3;
|
|
5
|
+
export declare const arcThroughThreePoints: (start: Point3, middle: Point3, end: Point3) => ThreePointArc | undefined;
|
|
6
|
+
export declare const pointsOnArc: (arc: ThreePointArc, start: Point3, end: Point3, segments: number) => Point3[];
|
|
7
|
+
export declare const pointOnCubic2: (from: Point2, control1: Point2, control2: Point2, to: Point2, t: number) => Point2;
|
|
8
|
+
export declare const pointOnCubic3: (from: Point3, control1: Point3, control2: Point3, to: Point3, t: number) => Point3;
|
|
9
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { add3, cross3, dot3, length3, scale3, subtract3 } from "./vectors";
|
|
2
2
|
const FULL_TURN = 2 * Math.PI;
|
|
3
3
|
const COLLINEAR_RATIO = 1e-12;
|
|
4
|
+
const CUBIC_MIDDLE_WEIGHT = 3;
|
|
4
5
|
export const arcThroughThreePoints = (start, middle, end) => {
|
|
5
6
|
const toMiddle = subtract3(middle, start);
|
|
6
7
|
const toEnd = subtract3(end, start);
|
|
@@ -28,3 +29,9 @@ export const pointsOnArc = (arc, start, end, segments) => {
|
|
|
28
29
|
points.push(end);
|
|
29
30
|
return points;
|
|
30
31
|
};
|
|
32
|
+
const cubicBlend = (from, control1, control2, to, t) => {
|
|
33
|
+
const u = 1 - t;
|
|
34
|
+
return u * u * u * from + CUBIC_MIDDLE_WEIGHT * u * t * (u * control1 + t * control2) + t * t * t * to;
|
|
35
|
+
};
|
|
36
|
+
export const pointOnCubic2 = (from, control1, control2, to, t) => [cubicBlend(from[0], control1[0], control2[0], to[0], t), cubicBlend(from[1], control1[1], control2[1], to[1], t)];
|
|
37
|
+
export const pointOnCubic3 = (from, control1, control2, to, t) => [cubicBlend(from[0], control1[0], control2[0], to[0], t), cubicBlend(from[1], control1[1], control2[1], to[1], t), cubicBlend(from[2], control1[2], control2[2], to[2], t)];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as Inputs from "
|
|
1
|
+
import type * as Inputs from "../../../inputs";
|
|
2
2
|
type Vec3 = Inputs.Base.Vector3;
|
|
3
3
|
/**
|
|
4
4
|
* The sine below which two directions count as parallel wherever a frame is squared: a direction
|
|
@@ -19,10 +19,6 @@ export interface FrameAxes {
|
|
|
19
19
|
export declare const isTriple: (value: unknown) => value is Vec3;
|
|
20
20
|
/** Whether a value has the shape of a frame: an `origin`, a `normal` and a `direction`, three finite numbers each. */
|
|
21
21
|
export declare const isFrameShaped: (value: unknown) => value is Inputs.Base.Frame;
|
|
22
|
-
/**
|
|
23
|
-
* A vector scaled to length 1, or undefined for one of no length. It is divided by its largest
|
|
24
|
-
* component before it is measured, so no square overflows or underflows at any finite size.
|
|
25
|
-
*/
|
|
26
22
|
export declare const unitOf: (vector: Vec3) => Vec3 | undefined;
|
|
27
23
|
/**
|
|
28
24
|
* The axes of an origin, a normal and a rough X direction: the normal scaled to length 1 and the
|
|
@@ -33,6 +29,13 @@ export declare const unitOf: (vector: Vec3) => Vec3 | undefined;
|
|
|
33
29
|
* the first subtraction, and the second takes out what rounding left along the normal.
|
|
34
30
|
*/
|
|
35
31
|
export declare const squareFrame: (origin: Vec3, normal: Vec3, direction: Vec3) => FrameAxes | "normal" | "direction";
|
|
32
|
+
/**
|
|
33
|
+
* The axes of an origin and a normal alone: X is the world axis least aligned with the normal,
|
|
34
|
+
* squared to it, so the choice never comes close to parallel. Axes within a billionth of the least
|
|
35
|
+
* aligned count as tied and the first of them, in X, Y, Z order, is taken, so rounding noise in the
|
|
36
|
+
* normal cannot turn the frame. Gives undefined for a normal of no length.
|
|
37
|
+
*/
|
|
38
|
+
export declare const axesAlong: (origin: Vec3, normal: Vec3) => FrameAxes | undefined;
|
|
36
39
|
export declare const WORLD_AXES: FrameAxes;
|
|
37
40
|
export declare const vectorToWorld: (axes: FrameAxes, vector: Vec3) => Vec3;
|
|
38
41
|
export declare const pointToWorld: (axes: FrameAxes, point: Vec3) => Vec3;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { cross3, dot3, scale3, subtract3 } from "./vectors";
|
|
1
2
|
/**
|
|
2
3
|
* The sine below which two directions count as parallel wherever a frame is squared: a direction
|
|
3
4
|
* closer than this to its normal leaves the X axis to rounding.
|
|
4
5
|
*/
|
|
5
6
|
export const PARALLEL_SINE = 1e-9;
|
|
7
|
+
const LEAST_ALIGNED_SLACK = 1e-9;
|
|
6
8
|
/** Whether a value is three finite numbers. */
|
|
7
9
|
export const isTriple = (value) => Array.isArray(value) && value.length === 3 && value.every(n => typeof n === "number" && Number.isFinite(n));
|
|
8
10
|
/** Whether a value has the shape of a frame: an `origin`, a `normal` and a `direction`, three finite numbers each. */
|
|
@@ -13,10 +15,6 @@ export const isFrameShaped = (value) => {
|
|
|
13
15
|
const fields = value;
|
|
14
16
|
return isTriple(fields["origin"]) && isTriple(fields["normal"]) && isTriple(fields["direction"]);
|
|
15
17
|
};
|
|
16
|
-
/**
|
|
17
|
-
* A vector scaled to length 1, or undefined for one of no length. It is divided by its largest
|
|
18
|
-
* component before it is measured, so no square overflows or underflows at any finite size.
|
|
19
|
-
*/
|
|
20
18
|
export const unitOf = (vector) => {
|
|
21
19
|
const largest = Math.max(Math.abs(vector[0]), Math.abs(vector[1]), Math.abs(vector[2]));
|
|
22
20
|
if (!(largest > 0 && largest < Infinity)) {
|
|
@@ -26,10 +24,7 @@ export const unitOf = (vector) => {
|
|
|
26
24
|
const length = Math.hypot(scaled[0], scaled[1], scaled[2]);
|
|
27
25
|
return [scaled[0] / length, scaled[1] / length, scaled[2] / length];
|
|
28
26
|
};
|
|
29
|
-
const withoutPartAlong = (vector, unit) =>
|
|
30
|
-
const along = vector[0] * unit[0] + vector[1] * unit[1] + vector[2] * unit[2];
|
|
31
|
-
return [vector[0] - along * unit[0], vector[1] - along * unit[1], vector[2] - along * unit[2]];
|
|
32
|
-
};
|
|
27
|
+
const withoutPartAlong = (vector, unit) => subtract3(vector, scale3(unit, dot3(vector, unit)));
|
|
33
28
|
/**
|
|
34
29
|
* The axes of an origin, a normal and a rough X direction: the normal scaled to length 1 and the
|
|
35
30
|
* direction turned square to it. Gives the name of the part that cannot be squared instead: a
|
|
@@ -52,9 +47,26 @@ export const squareFrame = (origin, normal, direction) => {
|
|
|
52
47
|
return "direction";
|
|
53
48
|
}
|
|
54
49
|
const x = unitOf(withoutPartAlong(square, z));
|
|
55
|
-
const y =
|
|
50
|
+
const y = cross3(z, x);
|
|
56
51
|
return { origin: [origin[0], origin[1], origin[2]], x, y, z };
|
|
57
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* The axes of an origin and a normal alone: X is the world axis least aligned with the normal,
|
|
55
|
+
* squared to it, so the choice never comes close to parallel. Axes within a billionth of the least
|
|
56
|
+
* aligned count as tied and the first of them, in X, Y, Z order, is taken, so rounding noise in the
|
|
57
|
+
* normal cannot turn the frame. Gives undefined for a normal of no length.
|
|
58
|
+
*/
|
|
59
|
+
export const axesAlong = (origin, normal) => {
|
|
60
|
+
const z = unitOf(normal);
|
|
61
|
+
if (z === undefined) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
const magnitudes = z.map(Math.abs);
|
|
65
|
+
const least = Math.min(...magnitudes);
|
|
66
|
+
const pick = magnitudes.findIndex(magnitude => magnitude <= least + LEAST_ALIGNED_SLACK);
|
|
67
|
+
const across = pick === 0 ? [1, 0, 0] : pick === 1 ? [0, 1, 0] : [0, 0, 1];
|
|
68
|
+
return squareFrame(origin, z, across);
|
|
69
|
+
};
|
|
58
70
|
export const WORLD_AXES = { origin: [0, 0, 0], x: [1, 0, 0], y: [0, 1, 0], z: [0, 0, 1] };
|
|
59
71
|
export const vectorToWorld = (axes, vector) => [
|
|
60
72
|
(axes.x[0] * vector[0] + axes.y[0] * vector[1]) + axes.z[0] * vector[2],
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UnitOfLength } from "../helper-types";
|
|
2
|
+
export declare const checkedUnitOfLength: (unit: unknown, property: string) => UnitOfLength;
|
|
3
|
+
export declare const millimetresPerUnitOf: (unit: UnitOfLength) => number;
|
|
4
|
+
export declare const lengthConverted: (value: number, from: UnitOfLength, to: UnitOfLength) => number;
|
|
5
|
+
export declare const snappedLength: (value: number, from: UnitOfLength, to: UnitOfLength) => number;
|
|
6
|
+
export declare const tableLength: (value: number, from: UnitOfLength, table: UnitOfLength) => number;
|
|
7
|
+
export declare function lengthsConverted<T extends Readonly<Record<K, number>>, K extends keyof T>(record: T, fields: readonly K[], from: UnitOfLength, to: UnitOfLength): T;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InputError } from "../../../kernel-calls/errors";
|
|
2
|
+
import { roundedTo } from "./scalars";
|
|
3
|
+
import { CONVERTED_PLACES, MILLIMETRES_PER_UNIT, TABLE_PLACES } from "./lengths.constants";
|
|
4
|
+
const UNITS = Object.keys(MILLIMETRES_PER_UNIT);
|
|
5
|
+
const isUnitOfLength = (unit) => typeof unit === "string" && UNITS.includes(unit);
|
|
6
|
+
export const checkedUnitOfLength = (unit, property) => {
|
|
7
|
+
if (!isUnitOfLength(unit)) {
|
|
8
|
+
throw new InputError(`\`${property}\` is ${String(unit)}, which is none of ${UNITS.join(", ")}.`, property);
|
|
9
|
+
}
|
|
10
|
+
return unit;
|
|
11
|
+
};
|
|
12
|
+
export const millimetresPerUnitOf = (unit) => MILLIMETRES_PER_UNIT[unit];
|
|
13
|
+
export const lengthConverted = (value, from, to) => from === to ? value : value * MILLIMETRES_PER_UNIT[from] / MILLIMETRES_PER_UNIT[to];
|
|
14
|
+
export const snappedLength = (value, from, to) => from === to ? value : roundedTo(lengthConverted(value, from, to), CONVERTED_PLACES);
|
|
15
|
+
export const tableLength = (value, from, table) => from === table ? value : roundedTo(lengthConverted(value, from, table), TABLE_PLACES[table]);
|
|
16
|
+
export function lengthsConverted(record, fields, from, to) {
|
|
17
|
+
const converted = {};
|
|
18
|
+
fields.forEach(field => { converted[field] = snappedLength(record[field], from, to); });
|
|
19
|
+
return Object.assign(Object.assign({}, record), converted);
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type * as Inputs from "../../../inputs";
|
|
2
|
+
export declare const RIGID_TOLERANCE = 1e-7;
|
|
3
|
+
export declare const LINEAR_COLUMN_STARTS: readonly [0, 4, 8];
|
|
4
|
+
export declare const MATRIX_COLUMN = 4;
|
|
5
|
+
export declare const TRANSLATION_START = 12;
|
|
6
|
+
export declare const W_AXIS = 3;
|
|
7
|
+
export declare const POSITION_SIZE = 3;
|
|
8
|
+
export declare const IDENTITY_MATRIX: Inputs.Base.TransformMatrix;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const RIGID_TOLERANCE = 1e-7;
|
|
2
|
+
export const LINEAR_COLUMN_STARTS = [0, 4, 8];
|
|
3
|
+
export const MATRIX_COLUMN = 4;
|
|
4
|
+
export const TRANSLATION_START = 12;
|
|
5
|
+
export const W_AXIS = 3;
|
|
6
|
+
export const POSITION_SIZE = 3;
|
|
7
|
+
export const IDENTITY_MATRIX = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as Inputs from "../../../inputs";
|
|
2
|
+
type Vec3 = Inputs.Base.Vector3;
|
|
3
|
+
export declare const isTransformMatrix: (value: unknown) => value is Inputs.Base.TransformMatrix;
|
|
4
|
+
export declare const movedCoordinate: (matrix: readonly number[], x: number, y: number, z: number, axis: number) => number;
|
|
5
|
+
export declare const movedPoint: (matrix: readonly number[], point: readonly number[]) => Inputs.Base.Point3;
|
|
6
|
+
export declare const turnedVector: (matrix: readonly number[], vector: readonly number[]) => Inputs.Base.Vector3;
|
|
7
|
+
export declare const movedPositions: (matrix: readonly number[], positions: ArrayLike<number>) => Float64Array;
|
|
8
|
+
export declare const followedBy: (first: readonly number[], second: readonly number[]) => Inputs.Base.TransformMatrix;
|
|
9
|
+
export declare const rigidInverse: (matrix: readonly number[]) => Inputs.Base.TransformMatrix;
|
|
10
|
+
export declare const linearDeterminant: (matrix: readonly number[]) => number;
|
|
11
|
+
export declare const isRigidMatrix: (matrix: readonly number[], tolerance?: number) => boolean;
|
|
12
|
+
export declare const composed: (matrices: readonly (readonly number[])[]) => Inputs.Base.TransformMatrix;
|
|
13
|
+
export declare const symmetricEigen: (matrix: readonly (readonly number[])[]) => {
|
|
14
|
+
value: number;
|
|
15
|
+
vector: Vec3;
|
|
16
|
+
}[];
|
|
17
|
+
export {};
|
|
@@ -1,8 +1,26 @@
|
|
|
1
|
-
import { LINEAR_COLUMN_STARTS, RIGID_TOLERANCE } from "./matrices.constants";
|
|
2
|
-
import { dot3 } from "./vectors";
|
|
3
|
-
/** Whether a value is one column-major 4 x 4 matrix: sixteen finite numbers. */
|
|
1
|
+
import { IDENTITY_MATRIX, LINEAR_COLUMN_STARTS, MATRIX_COLUMN, POSITION_SIZE, RIGID_TOLERANCE, TRANSLATION_START } from "./matrices.constants";
|
|
2
|
+
import { dot3, length3 } from "./vectors";
|
|
4
3
|
export const isTransformMatrix = (value) => Array.isArray(value) && value.length === 16 && value.every(n => typeof n === "number" && Number.isFinite(n));
|
|
5
|
-
|
|
4
|
+
export const movedCoordinate = (matrix, x, y, z, axis) => matrix[axis] * x + matrix[MATRIX_COLUMN + axis] * y + matrix[2 * MATRIX_COLUMN + axis] * z + matrix[TRANSLATION_START + axis];
|
|
5
|
+
export const movedPoint = (matrix, point) => {
|
|
6
|
+
const [x, y, z] = [point[0], point[1], point[2]];
|
|
7
|
+
return [movedCoordinate(matrix, x, y, z, 0), movedCoordinate(matrix, x, y, z, 1), movedCoordinate(matrix, x, y, z, 2)];
|
|
8
|
+
};
|
|
9
|
+
export const turnedVector = (matrix, vector) => {
|
|
10
|
+
const [x, y, z] = [vector[0], vector[1], vector[2]];
|
|
11
|
+
const turned = (axis) => matrix[axis] * x + matrix[MATRIX_COLUMN + axis] * y + matrix[2 * MATRIX_COLUMN + axis] * z;
|
|
12
|
+
return [turned(0), turned(1), turned(2)];
|
|
13
|
+
};
|
|
14
|
+
export const movedPositions = (matrix, positions) => {
|
|
15
|
+
const moved = new Float64Array(positions.length);
|
|
16
|
+
for (let at = 0; at + POSITION_SIZE <= positions.length; at += POSITION_SIZE) {
|
|
17
|
+
const [x, y, z] = [positions[at], positions[at + 1], positions[at + 2]];
|
|
18
|
+
moved[at] = movedCoordinate(matrix, x, y, z, 0);
|
|
19
|
+
moved[at + 1] = movedCoordinate(matrix, x, y, z, 1);
|
|
20
|
+
moved[at + 2] = movedCoordinate(matrix, x, y, z, 2);
|
|
21
|
+
}
|
|
22
|
+
return moved;
|
|
23
|
+
};
|
|
6
24
|
export const followedBy = (first, second) => {
|
|
7
25
|
const product = Array.from({ length: 16 }, (_, index) => {
|
|
8
26
|
const column = Math.floor(index / 4);
|
|
@@ -12,28 +30,21 @@ export const followedBy = (first, second) => {
|
|
|
12
30
|
});
|
|
13
31
|
return product;
|
|
14
32
|
};
|
|
15
|
-
|
|
33
|
+
export const rigidInverse = (matrix) => {
|
|
34
|
+
const [a, b, c, , d, e, f, , g, h, i, , x, y, z] = matrix;
|
|
35
|
+
return [a, d, g, 0, b, e, h, 0, c, f, i, 0, -(a * x + b * y + c * z), -(d * x + e * y + f * z), -(g * x + h * y + i * z), 1];
|
|
36
|
+
};
|
|
16
37
|
export const linearDeterminant = (matrix) => {
|
|
17
38
|
const [a, b, c, , d, e, f, , g, h, i] = matrix;
|
|
18
39
|
return a * (e * i - f * h) - d * (b * i - c * h) + g * (b * f - c * e);
|
|
19
40
|
};
|
|
20
|
-
/**
|
|
21
|
-
* Whether a column-major 4 x 4 matrix only turns and moves: its rotation and scale part has columns
|
|
22
|
-
* of length 1 and at right angles, within `tolerance` on their squared lengths and dot products, and
|
|
23
|
-
* keeps its handedness.
|
|
24
|
-
*/
|
|
25
41
|
export const isRigidMatrix = (matrix, tolerance = RIGID_TOLERANCE) => {
|
|
26
42
|
const [x, y, z] = LINEAR_COLUMN_STARTS.map((start) => [matrix[start], matrix[start + 1], matrix[start + 2]]);
|
|
27
|
-
return [x, y, z].every((column) => Math.abs(
|
|
43
|
+
return [x, y, z].every((column) => Math.abs(length3(column) - 1) <= tolerance)
|
|
28
44
|
&& Math.abs(dot3(x, y)) <= tolerance && Math.abs(dot3(x, z)) <= tolerance && Math.abs(dot3(y, z)) <= tolerance
|
|
29
45
|
&& linearDeterminant(matrix) > 0;
|
|
30
46
|
};
|
|
31
|
-
|
|
32
|
-
export const composed = (matrices) => matrices.reduce((total, matrix) => followedBy(total, matrix), [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]);
|
|
33
|
-
/**
|
|
34
|
-
* The eigenvalues of a symmetric 3 x 3 matrix, largest first, each with its unit eigenvector, by
|
|
35
|
-
* cyclic Jacobi rotations; the vectors come out at right angles to each other.
|
|
36
|
-
*/
|
|
47
|
+
export const composed = (matrices) => matrices.reduce((total, matrix) => followedBy(total, matrix), [...IDENTITY_MATRIX]);
|
|
37
48
|
export const symmetricEigen = (matrix) => {
|
|
38
49
|
let a = matrix.map(row => [...row]);
|
|
39
50
|
let v = [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type * as Inputs from "
|
|
1
|
+
import type * as Inputs from "../../../inputs";
|
|
2
2
|
type Vec3 = Inputs.Base.Vector3;
|
|
3
3
|
type Point3 = Inputs.Base.Point3;
|
|
4
|
+
export declare const pathLength3: (points: readonly Point3[]) => number;
|
|
4
5
|
export declare const pathTangents: (points: readonly Point3[], start?: Vec3, end?: Vec3) => Vec3[];
|
|
5
6
|
export declare const transportedAxes: (points: readonly Point3[], tangents: readonly Vec3[], first: Vec3) => Vec3[];
|
|
6
7
|
export declare const sweepMatrices: (points: readonly Point3[], tangents: readonly Vec3[], xAxes: readonly Vec3[]) => Inputs.Base.TransformMatrix[];
|
|
@@ -1,34 +1,36 @@
|
|
|
1
1
|
import { arcThroughThreePoints, pointsOnArc } from "./arcs";
|
|
2
|
-
import { add3, cross3, dot3, length3, scale3, subtract3 } from "./vectors";
|
|
2
|
+
import { add3, cross3, distance3, dot3, length3, scale3, subtract3 } from "./vectors";
|
|
3
|
+
import { axesAlong, unitOf } from "./frame-axes";
|
|
3
4
|
const STRAIGHT_SLACK = 1e-12;
|
|
4
5
|
const STRAIGHT_COSINE = 1 - STRAIGHT_SLACK;
|
|
5
6
|
const CORNERED_POINTS = 3;
|
|
6
7
|
const MAX_MITRE = 8;
|
|
7
8
|
const TINY_LENGTH = 1e-9;
|
|
8
9
|
const TINY_SQUARED = 1e-18;
|
|
9
|
-
const
|
|
10
|
-
const
|
|
10
|
+
const MEETING_SLACK = 1e-9;
|
|
11
|
+
const ARC_ULPS = 16;
|
|
11
12
|
const reflected = (vector, across, squared) => subtract3(vector, scale3(across, (2 / squared) * dot3(across, vector)));
|
|
12
13
|
const square = (vector, to) => {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
return square(least, tangent);
|
|
14
|
+
const once = subtract3(vector, scale3(to, dot3(vector, to)));
|
|
15
|
+
if (!(length3(once) > TINY_LENGTH)) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const twice = subtract3(once, scale3(to, dot3(once, to)));
|
|
19
|
+
return scale3(twice, 1 / length3(twice));
|
|
20
20
|
};
|
|
21
|
+
const anyAcross = (tangent) => axesAlong([0, 0, 0], tangent).x;
|
|
22
|
+
export const pathLength3 = (points) => points.reduce((length, point, at) => (at === 0 ? length : length + length3(subtract3(point, points[at - 1]))), 0);
|
|
21
23
|
export const pathTangents = (points, start, end) => {
|
|
22
|
-
const directions = points.slice(1).map((point, at) =>
|
|
24
|
+
const directions = points.slice(1).map((point, at) => unitOf(subtract3(point, points[at])));
|
|
23
25
|
return points.map((_, at) => {
|
|
24
26
|
if (at === 0) {
|
|
25
|
-
return start === undefined ? directions[0] :
|
|
27
|
+
return start === undefined ? directions[0] : unitOf(start);
|
|
26
28
|
}
|
|
27
29
|
if (at === points.length - 1) {
|
|
28
|
-
return end === undefined ? directions[at - 1] :
|
|
30
|
+
return end === undefined ? directions[at - 1] : unitOf(end);
|
|
29
31
|
}
|
|
30
32
|
const sum = add3(directions[at - 1], directions[at]);
|
|
31
|
-
return length3(sum) > TINY_LENGTH ?
|
|
33
|
+
return length3(sum) > TINY_LENGTH ? unitOf(sum) : directions[at];
|
|
32
34
|
});
|
|
33
35
|
};
|
|
34
36
|
export const transportedAxes = (points, tangents, first) => {
|
|
@@ -53,8 +55,8 @@ export const sweepMatrices = (points, tangents, xAxes) => points.map((origin, at
|
|
|
53
55
|
let x = xAxes[at];
|
|
54
56
|
let y = cross3(z, x);
|
|
55
57
|
if (at > 0 && at < points.length - 1) {
|
|
56
|
-
const incoming =
|
|
57
|
-
const outgoing =
|
|
58
|
+
const incoming = unitOf(subtract3(origin, points[at - 1]));
|
|
59
|
+
const outgoing = unitOf(subtract3(points[at + 1], origin));
|
|
58
60
|
const cosine = dot3(incoming, outgoing);
|
|
59
61
|
const bend = square(subtract3(outgoing, incoming), z);
|
|
60
62
|
if (cosine < STRAIGHT_COSINE && bend !== undefined) {
|
|
@@ -70,27 +72,31 @@ export const roundedPath3 = (points, radius, segmentsFor) => {
|
|
|
70
72
|
return [...points];
|
|
71
73
|
}
|
|
72
74
|
const rounded = [points[0]];
|
|
75
|
+
const append = (point) => {
|
|
76
|
+
if (distance3(point, rounded[rounded.length - 1]) > 0) {
|
|
77
|
+
rounded.push(point);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
let previousReach = 0;
|
|
73
81
|
for (let at = 1; at < points.length - 1; at++) {
|
|
74
82
|
const corner = points[at];
|
|
75
83
|
const toPrevious = subtract3(points[at - 1], corner);
|
|
76
84
|
const toNext = subtract3(points[at + 1], corner);
|
|
77
|
-
const
|
|
78
|
-
const
|
|
85
|
+
const previousLength = length3(toPrevious);
|
|
86
|
+
const incoming = scale3(toPrevious, -1 / previousLength);
|
|
87
|
+
const outgoing = unitOf(toNext);
|
|
79
88
|
const cosine = dot3(incoming, outgoing);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
const turn = Math.acos(Math.max(-1, Math.min(1, cosine)));
|
|
85
|
-
const reach = Math.min(radius * Math.tan(turn / 2), length3(toPrevious) / 2, length3(toNext) / 2);
|
|
86
|
-
const start = add3(corner, scale3(incoming, -reach));
|
|
89
|
+
const turn = Math.atan2(length3(cross3(incoming, outgoing)), cosine);
|
|
90
|
+
const reach = Math.min(radius * Math.tan(turn / 2), previousLength / 2, length3(toNext) / 2);
|
|
91
|
+
const start = previousReach + reach >= previousLength * (1 - MEETING_SLACK) ? rounded[rounded.length - 1] : add3(corner, scale3(incoming, -reach));
|
|
87
92
|
const end = add3(corner, scale3(outgoing, reach));
|
|
88
|
-
const inward =
|
|
93
|
+
const inward = unitOf(subtract3(outgoing, incoming));
|
|
89
94
|
const fitted = reach / Math.tan(turn / 2);
|
|
90
|
-
const
|
|
91
|
-
const arc = arcThroughThreePoints(start,
|
|
92
|
-
|
|
95
|
+
const precision = ARC_ULPS * Number.EPSILON * Math.max(Math.abs(corner[0]), Math.abs(corner[1]), Math.abs(corner[2]), reach);
|
|
96
|
+
const arc = cosine < STRAIGHT_COSINE && inward !== undefined && fitted > precision ? arcThroughThreePoints(start, add3(corner, scale3(inward, fitted / Math.cos(turn / 2) - fitted)), end) : undefined;
|
|
97
|
+
(arc ? pointsOnArc(arc, start, end, segmentsFor(turn)) : [corner]).forEach(append);
|
|
98
|
+
previousReach = arc ? reach : 0;
|
|
93
99
|
}
|
|
94
|
-
|
|
100
|
+
append(points[points.length - 1]);
|
|
95
101
|
return rounded;
|
|
96
102
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type * as Inputs from "
|
|
1
|
+
import type * as Inputs from "../../../inputs";
|
|
2
2
|
type Point2 = Inputs.Base.Point2;
|
|
3
3
|
export declare const signedArea2: (points: readonly Point2[]) => number;
|
|
4
4
|
export declare const wound2: (points: readonly Point2[], counterClockwise: boolean) => Point2[];
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { InputError } from "../../../kernel-calls/errors";
|
|
2
|
+
import { add2, between2, cross2, distance2, dot2, leftOf2, length2, polar2, scale2, subtract2, unit2Of } from "./vectors";
|
|
3
|
+
const STRAIGHT_TOLERANCE = 1e-9;
|
|
4
|
+
const FIT_TOLERANCE = 1e-9;
|
|
5
|
+
const MESSAGE_DIGITS = 12;
|
|
6
|
+
const shown = (value) => Number(value.toPrecision(MESSAGE_DIGITS));
|
|
7
|
+
export const signedArea2 = (points) => {
|
|
8
|
+
const origin = points[0];
|
|
9
|
+
let twice = 0;
|
|
10
|
+
for (let at = 1; at + 1 < points.length; at++) {
|
|
11
|
+
twice += cross2(subtract2(points[at], origin), subtract2(points[at + 1], origin));
|
|
12
|
+
}
|
|
13
|
+
return twice / 2;
|
|
14
|
+
};
|
|
15
|
+
export const wound2 = (points, counterClockwise) => (signedArea2(points) > 0) === counterClockwise ? [...points] : [...points].reverse();
|
|
16
|
+
export const isInsidePolygon2 = (point, outline) => {
|
|
17
|
+
let inside = false;
|
|
18
|
+
for (let at = 0, previous = outline.length - 1; at < outline.length; previous = at++) {
|
|
19
|
+
const [x1, y1] = outline[at];
|
|
20
|
+
const [x2, y2] = outline[previous];
|
|
21
|
+
if ((y1 > point[1]) !== (y2 > point[1]) && point[0] < ((x2 - x1) * (point[1] - y1)) / (y2 - y1) + x1) {
|
|
22
|
+
inside = !inside;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return inside;
|
|
26
|
+
};
|
|
27
|
+
export const perimeter2 = (points) => points.reduce((sum, point, at) => sum + length2(subtract2(points[(at + 1) % points.length], point)), 0);
|
|
28
|
+
const cornerOf = (points, radii, at) => {
|
|
29
|
+
var _a;
|
|
30
|
+
const corner = points[at];
|
|
31
|
+
const radius = (_a = radii[at]) !== null && _a !== void 0 ? _a : 0;
|
|
32
|
+
const toPrevious = unit2Of(subtract2(points[(at + points.length - 1) % points.length], corner));
|
|
33
|
+
const toNext = unit2Of(subtract2(points[(at + 1) % points.length], corner));
|
|
34
|
+
if (toPrevious === undefined || toNext === undefined) {
|
|
35
|
+
throw new Error(`The point at position ${at} lies on a point beside it, so the corner there has no sides`);
|
|
36
|
+
}
|
|
37
|
+
const half = Math.atan2(Math.abs(cross2(toPrevious, toNext)), dot2(toPrevious, toNext)) / 2;
|
|
38
|
+
if (!(radius > 0) || half < STRAIGHT_TOLERANCE || half > Math.PI / 2 - STRAIGHT_TOLERANCE || unit2Of(add2(toPrevious, toNext)) === undefined) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return { corner, radius, toPrevious, toNext, half, reach: radius / Math.tan(half) };
|
|
42
|
+
};
|
|
43
|
+
const requireFit = (points, corners) => {
|
|
44
|
+
corners.forEach((first, at) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const next = (at + 1) % points.length;
|
|
47
|
+
const second = corners[next];
|
|
48
|
+
const side = length2(subtract2(points[next], points[at]));
|
|
49
|
+
const need = ((_a = first === null || first === void 0 ? void 0 : first.reach) !== null && _a !== void 0 ? _a : 0) + ((_b = second === null || second === void 0 ? void 0 : second.reach) !== null && _b !== void 0 ? _b : 0);
|
|
50
|
+
if (need <= side * (1 + FIT_TOLERANCE)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const single = first === undefined || second === undefined;
|
|
54
|
+
throw new InputError(single
|
|
55
|
+
? `A corner radius of ${(first !== null && first !== void 0 ? first : second).radius} does not fit the edges beside its corner`
|
|
56
|
+
: `the arcs at the points at positions ${at} and ${next} need ${shown(need)} of the side between them, which is ${shown(side)} long`);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
const meetingOf = (points, corners, at) => {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const next = (at + 1) % points.length;
|
|
62
|
+
const first = corners[at];
|
|
63
|
+
const second = corners[next];
|
|
64
|
+
const need = ((_a = first === null || first === void 0 ? void 0 : first.reach) !== null && _a !== void 0 ? _a : 0) + ((_b = second === null || second === void 0 ? void 0 : second.reach) !== null && _b !== void 0 ? _b : 0);
|
|
65
|
+
if (need < distance2(points[next], points[at]) * (1 - FIT_TOLERANCE)) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
if (first === undefined) {
|
|
69
|
+
return points[at];
|
|
70
|
+
}
|
|
71
|
+
return second === undefined ? points[next] : between2(points[at], points[next], first.reach / need);
|
|
72
|
+
};
|
|
73
|
+
export const roundedCorners2 = (points, radii, segmentsFor) => {
|
|
74
|
+
const corners = points.map((_, at) => cornerOf(points, radii, at));
|
|
75
|
+
requireFit(points, corners);
|
|
76
|
+
const meetings = points.map((_, at) => meetingOf(points, corners, at));
|
|
77
|
+
const rounded = [];
|
|
78
|
+
const append = (point) => {
|
|
79
|
+
if (rounded.length === 0 || distance2(point, rounded[rounded.length - 1]) > 0) {
|
|
80
|
+
rounded.push(point);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
points.forEach((point, at) => {
|
|
84
|
+
var _a, _b;
|
|
85
|
+
const rounding = corners[at];
|
|
86
|
+
if (rounding === undefined) {
|
|
87
|
+
append(point);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const { corner, radius, toPrevious, toNext, reach } = rounding;
|
|
91
|
+
const start = (_a = meetings[(at + points.length - 1) % points.length]) !== null && _a !== void 0 ? _a : add2(corner, scale2(toPrevious, reach));
|
|
92
|
+
const end = (_b = meetings[at]) !== null && _b !== void 0 ? _b : add2(corner, scale2(toNext, reach));
|
|
93
|
+
const inward = scale2(leftOf2(toPrevious), cross2(toPrevious, toNext) < 0 ? -radius : radius);
|
|
94
|
+
const center = add2(add2(corner, scale2(toPrevious, reach)), inward);
|
|
95
|
+
const fromStart = subtract2(start, center);
|
|
96
|
+
const toEnd = subtract2(end, center);
|
|
97
|
+
const from = Math.atan2(fromStart[1], fromStart[0]);
|
|
98
|
+
let sweep = Math.atan2(toEnd[1], toEnd[0]) - from;
|
|
99
|
+
sweep -= Math.round(sweep / (2 * Math.PI)) * 2 * Math.PI;
|
|
100
|
+
const segments = segmentsFor(Math.abs(sweep));
|
|
101
|
+
append(start);
|
|
102
|
+
for (let step = 1; step < segments; step++) {
|
|
103
|
+
append(add2(center, polar2(radius, from + (sweep * step) / segments)));
|
|
104
|
+
}
|
|
105
|
+
append(end);
|
|
106
|
+
});
|
|
107
|
+
if (rounded.length > 1 && distance2(rounded[0], rounded[rounded.length - 1]) === 0) {
|
|
108
|
+
rounded.pop();
|
|
109
|
+
}
|
|
110
|
+
return rounded;
|
|
111
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const smoothstep: (value: number) => number;
|
|
2
|
+
export declare const roundedTo: (value: number, places: number) => number;
|
|
3
|
+
export declare const roundedToMillionths: (value: number) => number;
|
|
4
|
+
export declare const fractionOf: (value: number) => number;
|
|
5
|
+
export declare const radiansOf: (degrees: number) => number;
|
|
6
|
+
export declare const degreesOf: (radians: number) => number;
|
|
7
|
+
export declare const angleOfCosine: (cosine: number) => number;
|
|
8
|
+
export declare const interpolated: (start: number, end: number, share: number) => number;
|
|
9
|
+
export declare function fractionText(value: number, denominator: number): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const MILLIONTH_PLACES = 6;
|
|
2
|
+
const DECIMAL_BASE = 10;
|
|
3
|
+
const SMOOTHSTEP_RISE = 3;
|
|
4
|
+
const HALF_TURN_DEGREES = 180;
|
|
5
|
+
export const smoothstep = (value) => {
|
|
6
|
+
const t = Math.min(1, Math.max(0, value));
|
|
7
|
+
return t * t * (SMOOTHSTEP_RISE - 2 * t);
|
|
8
|
+
};
|
|
9
|
+
export const roundedTo = (value, places) => Math.round(value * Math.pow(DECIMAL_BASE, places)) / Math.pow(DECIMAL_BASE, places);
|
|
10
|
+
export const roundedToMillionths = (value) => roundedTo(value, MILLIONTH_PLACES);
|
|
11
|
+
export const fractionOf = (value) => value - Math.floor(value);
|
|
12
|
+
export const radiansOf = (degrees) => degrees * Math.PI / HALF_TURN_DEGREES;
|
|
13
|
+
export const degreesOf = (radians) => radians * HALF_TURN_DEGREES / Math.PI;
|
|
14
|
+
export const angleOfCosine = (cosine) => Math.acos(Math.min(1, Math.max(-1, cosine)));
|
|
15
|
+
export const interpolated = (start, end, share) => start + (end - start) * share;
|
|
16
|
+
function greatestCommonDivisor(first, second) {
|
|
17
|
+
let [a, b] = [first, second];
|
|
18
|
+
while (b !== 0) {
|
|
19
|
+
[a, b] = [b, a % b];
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
}
|
|
23
|
+
export function fractionText(value, denominator) {
|
|
24
|
+
const units = Math.round(Math.abs(value) * denominator);
|
|
25
|
+
const whole = Math.floor(units / denominator);
|
|
26
|
+
const rest = units - whole * denominator;
|
|
27
|
+
const common = greatestCommonDivisor(rest, denominator);
|
|
28
|
+
const sign = value < 0 && units > 0 ? "-" : "";
|
|
29
|
+
if (rest === 0) {
|
|
30
|
+
return `${sign}${String(whole)}`;
|
|
31
|
+
}
|
|
32
|
+
const part = `${String(rest / common)}/${String(denominator / common)}`;
|
|
33
|
+
return whole === 0 ? `${sign}${part}` : `${sign}${String(whole)}-${part}`;
|
|
34
|
+
}
|
|
@@ -36,9 +36,11 @@ function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
|
|
|
36
36
|
&& (bx - px) * (cy - py) >= (cx - px) * (by - py);
|
|
37
37
|
}
|
|
38
38
|
function signedArea(xs, ys) {
|
|
39
|
+
const x0 = xs[0];
|
|
40
|
+
const y0 = ys[0];
|
|
39
41
|
let twice = 0;
|
|
40
|
-
for (let at =
|
|
41
|
-
twice += xs[
|
|
42
|
+
for (let at = 1; at + 1 < xs.length; at++) {
|
|
43
|
+
twice += (xs[at] - x0) * (ys[at + 1] - y0) - (xs[at + 1] - x0) * (ys[at] - y0);
|
|
42
44
|
}
|
|
43
45
|
return twice / 2;
|
|
44
46
|
}
|
|
@@ -51,8 +53,7 @@ class Ring {
|
|
|
51
53
|
this.next = [];
|
|
52
54
|
this.triangles = [];
|
|
53
55
|
}
|
|
54
|
-
loop(vertices, xs, ys,
|
|
55
|
-
const reversed = (signedArea(xs, ys) > 0) !== counterClockwise;
|
|
56
|
+
loop(vertices, xs, ys, reversed) {
|
|
56
57
|
let last = NO_NODE;
|
|
57
58
|
for (let step = 0; step < vertices.length; step++) {
|
|
58
59
|
const at = reversed ? vertices.length - 1 - step : step;
|
|
@@ -289,7 +290,11 @@ export function triangulateFace(positions, loops) {
|
|
|
289
290
|
return fan(outer);
|
|
290
291
|
}
|
|
291
292
|
const ring = new Ring();
|
|
292
|
-
const start = ring.loop(outer, xs, ys,
|
|
293
|
-
const holeStarts = holes.map((hole) =>
|
|
293
|
+
const start = ring.loop(outer, xs, ys, false);
|
|
294
|
+
const holeStarts = holes.map((hole) => {
|
|
295
|
+
const holeXs = xsOf(hole);
|
|
296
|
+
const holeYs = ysOf(hole);
|
|
297
|
+
return ring.loop(hole, holeXs, holeYs, signedArea(holeXs, holeYs) > 0);
|
|
298
|
+
});
|
|
294
299
|
return ring.clip(ring.withHoles(start, holeStarts));
|
|
295
300
|
}
|