@ac-kit/math-geometry 0.2.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +217 -0
- package/README.md +323 -52
- package/dist/_brand.d.ts +14 -0
- package/dist/_brand.d.ts.map +1 -0
- package/dist/_brand.js +2 -0
- package/dist/_brand.js.map +1 -0
- package/dist/_ear-clipping.d.ts +20 -0
- package/dist/_ear-clipping.d.ts.map +1 -0
- package/dist/_ear-clipping.js +360 -0
- package/dist/_ear-clipping.js.map +1 -0
- package/dist/_ray3-intersect.d.ts +19 -0
- package/dist/_ray3-intersect.d.ts.map +1 -0
- package/dist/_ray3-intersect.js +122 -0
- package/dist/_ray3-intersect.js.map +1 -0
- package/dist/box2-array-boundary.d.ts +50 -0
- package/dist/box2-array-boundary.d.ts.map +1 -0
- package/dist/box2-array-boundary.js +97 -0
- package/dist/box2-array-boundary.js.map +1 -0
- package/dist/box2-array.d.ts +42 -0
- package/dist/box2-array.d.ts.map +1 -0
- package/dist/box2-array.js +134 -0
- package/dist/box2-array.js.map +1 -0
- package/dist/box2-componentwise.d.ts +110 -0
- package/dist/box2-componentwise.d.ts.map +1 -0
- package/dist/box2-componentwise.js +325 -0
- package/dist/box2-componentwise.js.map +1 -0
- package/dist/box2-grid-index.d.ts +67 -0
- package/dist/box2-grid-index.d.ts.map +1 -0
- package/dist/box2-grid-index.js +198 -0
- package/dist/box2-grid-index.js.map +1 -0
- package/dist/box2-record.d.ts +83 -0
- package/dist/box2-record.d.ts.map +1 -0
- package/dist/box2-record.js +124 -0
- package/dist/box2-record.js.map +1 -0
- package/dist/box2.d.ts +38 -0
- package/dist/box2.d.ts.map +1 -0
- package/dist/box2.js +97 -0
- package/dist/box2.js.map +1 -0
- package/dist/box3-array-boundary.d.ts +50 -0
- package/dist/box3-array-boundary.d.ts.map +1 -0
- package/dist/box3-array-boundary.js +107 -0
- package/dist/box3-array-boundary.js.map +1 -0
- package/dist/box3-componentwise.d.ts +110 -0
- package/dist/box3-componentwise.d.ts.map +1 -0
- package/dist/box3-componentwise.js +392 -0
- package/dist/box3-componentwise.js.map +1 -0
- package/dist/box3-record.d.ts +92 -0
- package/dist/box3-record.d.ts.map +1 -0
- package/dist/box3-record.js +147 -0
- package/dist/box3-record.js.map +1 -0
- package/dist/box3.d.ts +19 -16
- package/dist/box3.d.ts.map +1 -1
- package/dist/box3.js +73 -76
- package/dist/box3.js.map +1 -1
- package/dist/box4-array-boundary.d.ts +50 -0
- package/dist/box4-array-boundary.d.ts.map +1 -0
- package/dist/box4-array-boundary.js +117 -0
- package/dist/box4-array-boundary.js.map +1 -0
- package/dist/box4-componentwise.d.ts +110 -0
- package/dist/box4-componentwise.d.ts.map +1 -0
- package/dist/box4-componentwise.js +459 -0
- package/dist/box4-componentwise.js.map +1 -0
- package/dist/box4-record.d.ts +96 -0
- package/dist/box4-record.d.ts.map +1 -0
- package/dist/box4-record.js +167 -0
- package/dist/box4-record.js.map +1 -0
- package/dist/box4.d.ts +13 -8
- package/dist/box4.d.ts.map +1 -1
- package/dist/box4.js +27 -5
- package/dist/box4.js.map +1 -1
- package/dist/circle2-array-boundary.d.ts +51 -0
- package/dist/circle2-array-boundary.d.ts.map +1 -0
- package/dist/circle2-array-boundary.js +93 -0
- package/dist/circle2-array-boundary.js.map +1 -0
- package/dist/circle2-array.d.ts +17 -0
- package/dist/circle2-array.d.ts.map +1 -0
- package/dist/circle2-array.js +44 -0
- package/dist/circle2-array.js.map +1 -0
- package/dist/circle2-record.d.ts +81 -0
- package/dist/circle2-record.d.ts.map +1 -0
- package/dist/circle2-record.js +114 -0
- package/dist/circle2-record.js.map +1 -0
- package/dist/circle2.d.ts +27 -82
- package/dist/circle2.d.ts.map +1 -1
- package/dist/circle2.js +59 -104
- package/dist/circle2.js.map +1 -1
- package/dist/coordinates/cylindrical-record.d.ts +86 -0
- package/dist/coordinates/cylindrical-record.d.ts.map +1 -0
- package/dist/coordinates/cylindrical-record.js +114 -0
- package/dist/coordinates/cylindrical-record.js.map +1 -0
- package/dist/coordinates/horizontal-record.d.ts +86 -0
- package/dist/coordinates/horizontal-record.d.ts.map +1 -0
- package/dist/coordinates/horizontal-record.js +114 -0
- package/dist/coordinates/horizontal-record.js.map +1 -0
- package/dist/coordinates/horizontal.d.ts +48 -0
- package/dist/coordinates/horizontal.d.ts.map +1 -0
- package/dist/coordinates/horizontal.js +100 -0
- package/dist/coordinates/horizontal.js.map +1 -0
- package/dist/coordinates/index.d.ts +10 -0
- package/dist/coordinates/index.d.ts.map +1 -0
- package/dist/coordinates/index.js +10 -0
- package/dist/coordinates/index.js.map +1 -0
- package/dist/coordinates/longitude-latitude-record.d.ts +81 -0
- package/dist/coordinates/longitude-latitude-record.d.ts.map +1 -0
- package/dist/coordinates/longitude-latitude-record.js +104 -0
- package/dist/coordinates/longitude-latitude-record.js.map +1 -0
- package/dist/coordinates/longitude-latitude.d.ts +33 -0
- package/dist/coordinates/longitude-latitude.d.ts.map +1 -0
- package/dist/coordinates/longitude-latitude.js +78 -0
- package/dist/coordinates/longitude-latitude.js.map +1 -0
- package/dist/coordinates/polar-record.d.ts +77 -0
- package/dist/coordinates/polar-record.d.ts.map +1 -0
- package/dist/coordinates/polar-record.js +104 -0
- package/dist/coordinates/polar-record.js.map +1 -0
- package/dist/coordinates/polar.d.ts +28 -0
- package/dist/coordinates/polar.d.ts.map +1 -0
- package/dist/coordinates/polar.js +68 -0
- package/dist/coordinates/polar.js.map +1 -0
- package/dist/coordinates/spherical-cylindrical.d.ts +49 -0
- package/dist/coordinates/spherical-cylindrical.d.ts.map +1 -0
- package/dist/coordinates/spherical-cylindrical.js +110 -0
- package/dist/coordinates/spherical-cylindrical.js.map +1 -0
- package/dist/coordinates/spherical-record.d.ts +86 -0
- package/dist/coordinates/spherical-record.d.ts.map +1 -0
- package/dist/coordinates/spherical-record.js +114 -0
- package/dist/coordinates/spherical-record.js.map +1 -0
- package/dist/frustum3-record.d.ts +132 -0
- package/dist/frustum3-record.d.ts.map +1 -0
- package/dist/frustum3-record.js +333 -0
- package/dist/frustum3-record.js.map +1 -0
- package/dist/frustum3.d.ts +60 -0
- package/dist/frustum3.d.ts.map +1 -0
- package/dist/frustum3.js +186 -0
- package/dist/frustum3.js.map +1 -0
- package/dist/index.d.ts +36 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -16
- package/dist/index.js.map +1 -1
- package/dist/line2-record.d.ts +87 -0
- package/dist/line2-record.d.ts.map +1 -0
- package/dist/line2-record.js +123 -0
- package/dist/line2-record.js.map +1 -0
- package/dist/line2.d.ts +20 -33
- package/dist/line2.d.ts.map +1 -1
- package/dist/line2.js +56 -51
- package/dist/line2.js.map +1 -1
- package/dist/line3-record.d.ts +91 -0
- package/dist/line3-record.d.ts.map +1 -0
- package/dist/line3-record.js +146 -0
- package/dist/line3-record.js.map +1 -0
- package/dist/line3.d.ts +11 -24
- package/dist/line3.d.ts.map +1 -1
- package/dist/line3.js +32 -36
- package/dist/line3.js.map +1 -1
- package/dist/mesh/_generator-kit.d.ts +14 -0
- package/dist/mesh/_generator-kit.d.ts.map +1 -0
- package/dist/mesh/_generator-kit.js +39 -0
- package/dist/mesh/_generator-kit.js.map +1 -0
- package/dist/mesh/_index-kernels-u16.d.ts +43 -0
- package/dist/mesh/_index-kernels-u16.d.ts.map +1 -0
- package/dist/mesh/_index-kernels-u16.js +264 -0
- package/dist/mesh/_index-kernels-u16.js.map +1 -0
- package/dist/mesh/_index-kernels-u32.d.ts +43 -0
- package/dist/mesh/_index-kernels-u32.d.ts.map +1 -0
- package/dist/mesh/_index-kernels-u32.js +264 -0
- package/dist/mesh/_index-kernels-u32.js.map +1 -0
- package/dist/mesh/generate-box.d.ts +16 -0
- package/dist/mesh/generate-box.d.ts.map +1 -0
- package/dist/mesh/generate-box.js +79 -0
- package/dist/mesh/generate-box.js.map +1 -0
- package/dist/mesh/generate-cylinder.d.ts +25 -0
- package/dist/mesh/generate-cylinder.d.ts.map +1 -0
- package/dist/mesh/generate-cylinder.js +117 -0
- package/dist/mesh/generate-cylinder.js.map +1 -0
- package/dist/mesh/generate-heightfield.d.ts +24 -0
- package/dist/mesh/generate-heightfield.d.ts.map +1 -0
- package/dist/mesh/generate-heightfield.js +48 -0
- package/dist/mesh/generate-heightfield.js.map +1 -0
- package/dist/mesh/generate-plane.d.ts +18 -0
- package/dist/mesh/generate-plane.d.ts.map +1 -0
- package/dist/mesh/generate-plane.js +39 -0
- package/dist/mesh/generate-plane.js.map +1 -0
- package/dist/mesh/generate-sphere.d.ts +50 -0
- package/dist/mesh/generate-sphere.d.ts.map +1 -0
- package/dist/mesh/generate-sphere.js +244 -0
- package/dist/mesh/generate-sphere.js.map +1 -0
- package/dist/mesh/index.d.ts +8 -0
- package/dist/mesh/index.d.ts.map +1 -0
- package/dist/mesh/index.js +8 -0
- package/dist/mesh/index.js.map +1 -0
- package/dist/mesh/mesh3-kernels.d.ts +82 -0
- package/dist/mesh/mesh3-kernels.d.ts.map +1 -0
- package/dist/mesh/mesh3-kernels.js +180 -0
- package/dist/mesh/mesh3-kernels.js.map +1 -0
- package/dist/mesh/mesh3.d.ts +66 -0
- package/dist/mesh/mesh3.d.ts.map +1 -0
- package/dist/mesh/mesh3.js +128 -0
- package/dist/mesh/mesh3.js.map +1 -0
- package/dist/plane3-record.d.ts +88 -0
- package/dist/plane3-record.d.ts.map +1 -0
- package/dist/plane3-record.js +123 -0
- package/dist/plane3-record.js.map +1 -0
- package/dist/plane3.d.ts +42 -28
- package/dist/plane3.d.ts.map +1 -1
- package/dist/plane3.js +166 -48
- package/dist/plane3.js.map +1 -1
- package/dist/polygon2.d.ts +82 -29
- package/dist/polygon2.d.ts.map +1 -1
- package/dist/polygon2.js +236 -93
- package/dist/polygon2.js.map +1 -1
- package/dist/polygon3.d.ts +40 -21
- package/dist/polygon3.d.ts.map +1 -1
- package/dist/polygon3.js +215 -91
- package/dist/polygon3.js.map +1 -1
- package/dist/polyline2.d.ts +37 -0
- package/dist/polyline2.d.ts.map +1 -0
- package/dist/polyline2.js +146 -0
- package/dist/polyline2.js.map +1 -0
- package/dist/polyline3.d.ts +35 -0
- package/dist/polyline3.d.ts.map +1 -0
- package/dist/polyline3.js +159 -0
- package/dist/polyline3.js.map +1 -0
- package/dist/quadtree.d.ts +238 -0
- package/dist/quadtree.d.ts.map +1 -0
- package/dist/quadtree.js +1019 -0
- package/dist/quadtree.js.map +1 -0
- package/dist/ray2-record.d.ts +86 -0
- package/dist/ray2-record.d.ts.map +1 -0
- package/dist/ray2-record.js +123 -0
- package/dist/ray2-record.js.map +1 -0
- package/dist/ray2.d.ts +38 -13
- package/dist/ray2.d.ts.map +1 -1
- package/dist/ray2.js +85 -22
- package/dist/ray2.js.map +1 -1
- package/dist/ray3-array.d.ts +27 -0
- package/dist/ray3-array.d.ts.map +1 -0
- package/dist/ray3-array.js +89 -0
- package/dist/ray3-array.js.map +1 -0
- package/dist/ray3-record.d.ts +90 -0
- package/dist/ray3-record.d.ts.map +1 -0
- package/dist/ray3-record.js +146 -0
- package/dist/ray3-record.js.map +1 -0
- package/dist/ray3.d.ts +72 -25
- package/dist/ray3.d.ts.map +1 -1
- package/dist/ray3.js +233 -64
- package/dist/ray3.js.map +1 -1
- package/dist/segment2-record.d.ts +80 -0
- package/dist/segment2-record.d.ts.map +1 -0
- package/dist/segment2-record.js +122 -0
- package/dist/segment2-record.js.map +1 -0
- package/dist/segment2.d.ts +34 -19
- package/dist/segment2.d.ts.map +1 -1
- package/dist/segment2.js +88 -42
- package/dist/segment2.js.map +1 -1
- package/dist/segment3-record.d.ts +90 -0
- package/dist/segment3-record.d.ts.map +1 -0
- package/dist/segment3-record.js +146 -0
- package/dist/segment3-record.js.map +1 -0
- package/dist/segment3.d.ts +24 -12
- package/dist/segment3.d.ts.map +1 -1
- package/dist/segment3.js +67 -30
- package/dist/segment3.js.map +1 -1
- package/dist/size.d.ts +40 -0
- package/dist/size.d.ts.map +1 -0
- package/dist/size.js +72 -0
- package/dist/size.js.map +1 -0
- package/dist/sphere3-array-boundary.d.ts +51 -0
- package/dist/sphere3-array-boundary.d.ts.map +1 -0
- package/dist/sphere3-array-boundary.js +98 -0
- package/dist/sphere3-array-boundary.js.map +1 -0
- package/dist/sphere3-record.d.ts +88 -0
- package/dist/sphere3-record.d.ts.map +1 -0
- package/dist/sphere3-record.js +123 -0
- package/dist/sphere3-record.js.map +1 -0
- package/dist/sphere3.d.ts +55 -12
- package/dist/sphere3.d.ts.map +1 -1
- package/dist/sphere3.js +233 -24
- package/dist/sphere3.js.map +1 -1
- package/dist/spherical/cap.d.ts +56 -0
- package/dist/spherical/cap.d.ts.map +1 -0
- package/dist/spherical/cap.js +363 -0
- package/dist/spherical/cap.js.map +1 -0
- package/dist/spherical/great-circle.d.ts +39 -0
- package/dist/spherical/great-circle.d.ts.map +1 -0
- package/dist/spherical/great-circle.js +158 -0
- package/dist/spherical/great-circle.js.map +1 -0
- package/dist/spherical/index.d.ts +3 -0
- package/dist/spherical/index.d.ts.map +1 -0
- package/dist/spherical/index.js +3 -0
- package/dist/spherical/index.js.map +1 -0
- package/dist/triangle2-record.d.ts +91 -0
- package/dist/triangle2-record.d.ts.map +1 -0
- package/dist/triangle2-record.js +146 -0
- package/dist/triangle2-record.js.map +1 -0
- package/dist/triangle2.d.ts +29 -14
- package/dist/triangle2.d.ts.map +1 -1
- package/dist/triangle2.js +86 -22
- package/dist/triangle2.js.map +1 -1
- package/dist/triangle3-record.d.ts +97 -0
- package/dist/triangle3-record.d.ts.map +1 -0
- package/dist/triangle3-record.js +178 -0
- package/dist/triangle3-record.js.map +1 -0
- package/dist/triangle3.d.ts +41 -17
- package/dist/triangle3.d.ts.map +1 -1
- package/dist/triangle3.js +267 -38
- package/dist/triangle3.js.map +1 -1
- package/package.json +15 -8
- package/dist/angles.d.ts +0 -31
- package/dist/angles.d.ts.map +0 -1
- package/dist/angles.js +0 -53
- package/dist/angles.js.map +0 -1
- package/dist/coordinate-spaces.d.ts +0 -39
- package/dist/coordinate-spaces.d.ts.map +0 -1
- package/dist/coordinate-spaces.js +0 -52
- package/dist/coordinate-spaces.js.map +0 -1
- package/dist/coordinates-vec2.d.ts +0 -7
- package/dist/coordinates-vec2.d.ts.map +0 -1
- package/dist/coordinates-vec2.js +0 -35
- package/dist/coordinates-vec2.js.map +0 -1
- package/dist/coordinates-vec3.d.ts +0 -11
- package/dist/coordinates-vec3.d.ts.map +0 -1
- package/dist/coordinates-vec3.js +0 -61
- package/dist/coordinates-vec3.js.map +0 -1
- package/dist/coordinates.d.ts +0 -54
- package/dist/coordinates.d.ts.map +0 -1
- package/dist/coordinates.js +0 -2
- package/dist/coordinates.js.map +0 -1
- package/dist/euler-angles-quaternion.d.ts +0 -7
- package/dist/euler-angles-quaternion.d.ts.map +0 -1
- package/dist/euler-angles-quaternion.js +0 -100
- package/dist/euler-angles-quaternion.js.map +0 -1
- package/dist/euler-angles.d.ts +0 -33
- package/dist/euler-angles.d.ts.map +0 -1
- package/dist/euler-angles.js +0 -35
- package/dist/euler-angles.js.map +0 -1
- package/dist/geometry-vectors.d.ts +0 -11
- package/dist/geometry-vectors.d.ts.map +0 -1
- package/dist/geometry-vectors.js +0 -19
- package/dist/geometry-vectors.js.map +0 -1
- package/dist/mesh3.d.ts +0 -32
- package/dist/mesh3.d.ts.map +0 -1
- package/dist/mesh3.js +0 -142
- package/dist/mesh3.js.map +0 -1
- package/dist/point2.d.ts +0 -41
- package/dist/point2.d.ts.map +0 -1
- package/dist/point2.js +0 -92
- package/dist/point2.js.map +0 -1
- package/dist/point3.d.ts +0 -43
- package/dist/point3.d.ts.map +0 -1
- package/dist/point3.js +0 -103
- package/dist/point3.js.map +0 -1
- package/dist/point4.d.ts +0 -12
- package/dist/point4.d.ts.map +0 -1
- package/dist/point4.js +0 -28
- package/dist/point4.js.map +0 -1
- package/dist/rect2.d.ts +0 -54
- package/dist/rect2.d.ts.map +0 -1
- package/dist/rect2.js +0 -149
- package/dist/rect2.js.map +0 -1
- package/dist/size2.d.ts +0 -33
- package/dist/size2.d.ts.map +0 -1
- package/dist/size2.js +0 -81
- package/dist/size2.js.map +0 -1
- package/dist/size3.d.ts +0 -21
- package/dist/size3.d.ts.map +0 -1
- package/dist/size3.js +0 -59
- package/dist/size3.js.map +0 -1
- package/dist/size4.d.ts +0 -10
- package/dist/size4.d.ts.map +0 -1
- package/dist/size4.js +0 -16
- package/dist/size4.js.map +0 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Generated from scripts/templates/array-boundary.liquid by scripts/generate-records.ts. Do not edit.
|
|
2
|
+
import { assertInteger } from "@ac-kit/core";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a buffer for `count` boxes: a zero-filled `Float64Array` of `count ×
|
|
5
|
+
* 4` numbers, element `i` at `[i·4, i·4 + 4)`. Allocates.
|
|
6
|
+
*
|
|
7
|
+
* @throws {RangeError} When `count` is not a non-negative safe integer or
|
|
8
|
+
* `count × 4` is not a valid typed array length.
|
|
9
|
+
*/
|
|
10
|
+
export function box2ArrayCreate(count) {
|
|
11
|
+
assertInteger(count, "box2ArrayCreate: count", 0);
|
|
12
|
+
return new Float64Array(count * 4);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Writes element `index` of `array`, the numbers at `[index·4, index·4 + 4)`,
|
|
16
|
+
* into `out`. Each component is written as `+array[i]`, so an index past the
|
|
17
|
+
* end of `array` gives `NaN`, never `undefined`: the box stays clean whatever
|
|
18
|
+
* the caller does. Checking the index is the job of the checked layer.
|
|
19
|
+
*
|
|
20
|
+
* The box is copied: it is never a view of `array`. O(1).
|
|
21
|
+
*/
|
|
22
|
+
export function box2Load(out, array, index) {
|
|
23
|
+
const base = index * 4;
|
|
24
|
+
// The `!` is for the compiler: past the end `+undefined` is `NaN`.
|
|
25
|
+
out[0] = +array[base];
|
|
26
|
+
out[1] = +array[base + 1];
|
|
27
|
+
out[2] = +array[base + 2];
|
|
28
|
+
out[3] = +array[base + 3];
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Writes `value` into `array` as element `index`, at `[index·4, index·4 + 4)`.
|
|
33
|
+
* An element past the end of `array` writes nothing, as a typed array drops an
|
|
34
|
+
* out-of-range write. O(1).
|
|
35
|
+
*/
|
|
36
|
+
export function box2Store(array, index, value) {
|
|
37
|
+
const base = index * 4;
|
|
38
|
+
array[base] = value[0];
|
|
39
|
+
array[base + 1] = value[1];
|
|
40
|
+
array[base + 2] = value[2];
|
|
41
|
+
array[base + 3] = value[3];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Like {@link box2Load} for interleaved data: element `index` starts at `offset +
|
|
45
|
+
* index·stride`, both counted in numbers, and its 4 components follow one
|
|
46
|
+
* another. An index past the end gives `NaN` components. O(1).
|
|
47
|
+
*/
|
|
48
|
+
export function box2LoadStrided(out, array, offset, stride, index) {
|
|
49
|
+
const base = offset + index * stride;
|
|
50
|
+
// The `!` is for the compiler: past the end `+undefined` is `NaN`.
|
|
51
|
+
out[0] = +array[base];
|
|
52
|
+
out[1] = +array[base + 1];
|
|
53
|
+
out[2] = +array[base + 2];
|
|
54
|
+
out[3] = +array[base + 3];
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Like {@link box2Store} for interleaved data: element `index` starts at `offset +
|
|
59
|
+
* index·stride`, both counted in numbers. A component past the end of `array`
|
|
60
|
+
* writes nothing. O(1).
|
|
61
|
+
*/
|
|
62
|
+
export function box2StoreStrided(array, offset, stride, index, value) {
|
|
63
|
+
const base = offset + index * stride;
|
|
64
|
+
array[base] = value[0];
|
|
65
|
+
array[base + 1] = value[1];
|
|
66
|
+
array[base + 2] = value[2];
|
|
67
|
+
array[base + 3] = value[3];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Narrows `value` to binary32 and writes its 4 components into `array` from
|
|
71
|
+
* element `offset` on, unrolled: the way to stage a bounds or instance value
|
|
72
|
+
* for the GPU, where `array.set` costs several times as much for one value. A
|
|
73
|
+
* component past the end of `array` writes nothing. O(1).
|
|
74
|
+
*/
|
|
75
|
+
export function box2StoreFloat32(array, offset, value) {
|
|
76
|
+
array[offset] = value[0];
|
|
77
|
+
array[offset + 1] = value[1];
|
|
78
|
+
array[offset + 2] = value[2];
|
|
79
|
+
array[offset + 3] = value[3];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Whether every number of `array` is finite: the check for a buffer of box2
|
|
83
|
+
* elements read from untrusted data or about to be uploaded. The length is not
|
|
84
|
+
* required to be a multiple of 4. O(n).
|
|
85
|
+
*/
|
|
86
|
+
export function box2ArrayIsFinite(array) {
|
|
87
|
+
// A loop, not `array.every(Number.isFinite)`: measured at 0.5–0.7 ms against
|
|
88
|
+
// 4.1 ms per million numbers on Node (the callback is not inlined), and the
|
|
89
|
+
// check runs on every upload of an untrusted buffer.
|
|
90
|
+
for (let index = 0; index < array.length; index++) {
|
|
91
|
+
if (!Number.isFinite(array[index])) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=box2-array-boundary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box2-array-boundary.js","sourceRoot":"","sources":["../src/box2-array-boundary.ts"],"names":[],"mappings":"AAAA,sGAAsG;AAEtG,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;IAC5C,aAAa,CAAC,KAAK,EAAE,wBAAwB,EAAE,CAAC,CAAC,CAAC;IAClD,OAAO,IAAI,YAAY,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAS,EAAE,KAAmB,EAAE,KAAa;IACrE,MAAM,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC;IACvB,mEAAmE;IACnE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C,KAAK,CAAC,CAAC,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC;QACd,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ReadonlyBox2 } from "./box2-record.js";
|
|
2
|
+
/**
|
|
3
|
+
* The index of the first box that contains the point `(x, y)`, boundary
|
|
4
|
+
* included, or `−1`. O(n).
|
|
5
|
+
*
|
|
6
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4.
|
|
7
|
+
*/
|
|
8
|
+
export declare function box2ArrayFindIndexContainingXy(boxes: Float64Array, x: number, y: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* The index of the last box that contains the point `(x, y)`, boundary
|
|
11
|
+
* included, or `−1`: the topmost one when later boxes are drawn over earlier
|
|
12
|
+
* ones. O(n).
|
|
13
|
+
*
|
|
14
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4.
|
|
15
|
+
*/
|
|
16
|
+
export declare function box2ArrayFindLastIndexContainingXy(boxes: Float64Array, x: number, y: number): number;
|
|
17
|
+
/**
|
|
18
|
+
* Writes the index of every box that contains the point `(x, y)` into `out`, in
|
|
19
|
+
* increasing order, and returns how many. O(n).
|
|
20
|
+
*
|
|
21
|
+
* @param out At least as long as the number of boxes.
|
|
22
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4 or `out` is
|
|
23
|
+
* shorter than the number of boxes.
|
|
24
|
+
*/
|
|
25
|
+
export declare function box2ArrayContainingXy(out: Uint32Array, boxes: Float64Array, x: number, y: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* The index of the first box that shares a point with `box`, boundaries
|
|
28
|
+
* included, or `−1`. An empty `box` intersects nothing. O(n).
|
|
29
|
+
*
|
|
30
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4.
|
|
31
|
+
*/
|
|
32
|
+
export declare function box2ArrayFindIndexIntersecting(boxes: Float64Array, box: ReadonlyBox2): number;
|
|
33
|
+
/**
|
|
34
|
+
* Writes the index of every box that shares a point with `box` into `out`, in
|
|
35
|
+
* increasing order, and returns how many. O(n).
|
|
36
|
+
*
|
|
37
|
+
* @param out At least as long as the number of boxes.
|
|
38
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4 or `out` is
|
|
39
|
+
* shorter than the number of boxes.
|
|
40
|
+
*/
|
|
41
|
+
export declare function box2ArrayIntersecting(out: Uint32Array, boxes: Float64Array, box: ReadonlyBox2): number;
|
|
42
|
+
//# sourceMappingURL=box2-array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box2-array.d.ts","sourceRoot":"","sources":["../src/box2-array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkBrD;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC7C,KAAK,EAAE,YAAY,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACP,MAAM,CAaR;AAED;;;;;;GAMG;AACH,wBAAgB,kCAAkC,CACjD,KAAK,EAAE,YAAY,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACP,MAAM,CAaR;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,YAAY,EACnB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,GACP,MAAM,CAmBR;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC7C,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,YAAY,GACf,MAAM,CAsBR;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,YAAY,GACf,MAAM,CA4BR"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hit-tests over packed boxes (`[minX, minY, maxX, maxY]` per box in a
|
|
3
|
+
* `Float64Array`), for UI picking: one pass, no allocation, each index counted
|
|
4
|
+
* in boxes. Every function throws a `RangeError` once, up front, when the
|
|
5
|
+
* buffer is not a whole number of boxes. A box with a `NaN` bound contains and
|
|
6
|
+
* intersects nothing.
|
|
7
|
+
*/
|
|
8
|
+
function assertWholeBoxes_(name, boxes) {
|
|
9
|
+
if (boxes.length % 4 !== 0) {
|
|
10
|
+
throw new RangeError(`${name}: boxes has ${boxes.length} numbers, not a multiple of 4.`);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The index of the first box that contains the point `(x, y)`, boundary
|
|
15
|
+
* included, or `−1`. O(n).
|
|
16
|
+
*
|
|
17
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4.
|
|
18
|
+
*/
|
|
19
|
+
export function box2ArrayFindIndexContainingXy(boxes, x, y) {
|
|
20
|
+
assertWholeBoxes_("box2ArrayFindIndexContainingXy", boxes);
|
|
21
|
+
for (let offset = 0; offset < boxes.length; offset += 4) {
|
|
22
|
+
if (x >= boxes[offset] &&
|
|
23
|
+
x <= boxes[offset + 2] &&
|
|
24
|
+
y >= boxes[offset + 1] &&
|
|
25
|
+
y <= boxes[offset + 3]) {
|
|
26
|
+
return offset / 4;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return -1;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The index of the last box that contains the point `(x, y)`, boundary
|
|
33
|
+
* included, or `−1`: the topmost one when later boxes are drawn over earlier
|
|
34
|
+
* ones. O(n).
|
|
35
|
+
*
|
|
36
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4.
|
|
37
|
+
*/
|
|
38
|
+
export function box2ArrayFindLastIndexContainingXy(boxes, x, y) {
|
|
39
|
+
assertWholeBoxes_("box2ArrayFindLastIndexContainingXy", boxes);
|
|
40
|
+
for (let offset = boxes.length - 4; offset >= 0; offset -= 4) {
|
|
41
|
+
if (x >= boxes[offset] &&
|
|
42
|
+
x <= boxes[offset + 2] &&
|
|
43
|
+
y >= boxes[offset + 1] &&
|
|
44
|
+
y <= boxes[offset + 3]) {
|
|
45
|
+
return offset / 4;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return -1;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Writes the index of every box that contains the point `(x, y)` into `out`, in
|
|
52
|
+
* increasing order, and returns how many. O(n).
|
|
53
|
+
*
|
|
54
|
+
* @param out At least as long as the number of boxes.
|
|
55
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4 or `out` is
|
|
56
|
+
* shorter than the number of boxes.
|
|
57
|
+
*/
|
|
58
|
+
export function box2ArrayContainingXy(out, boxes, x, y) {
|
|
59
|
+
assertWholeBoxes_("box2ArrayContainingXy", boxes);
|
|
60
|
+
if (out.length < boxes.length / 4) {
|
|
61
|
+
throw new RangeError(`box2ArrayContainingXy: out holds ${out.length} indices for ${boxes.length / 4} boxes.`);
|
|
62
|
+
}
|
|
63
|
+
let count = 0;
|
|
64
|
+
for (let offset = 0; offset < boxes.length; offset += 4) {
|
|
65
|
+
if (x >= boxes[offset] &&
|
|
66
|
+
x <= boxes[offset + 2] &&
|
|
67
|
+
y >= boxes[offset + 1] &&
|
|
68
|
+
y <= boxes[offset + 3]) {
|
|
69
|
+
out[count++] = offset / 4;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return count;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The index of the first box that shares a point with `box`, boundaries
|
|
76
|
+
* included, or `−1`. An empty `box` intersects nothing. O(n).
|
|
77
|
+
*
|
|
78
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4.
|
|
79
|
+
*/
|
|
80
|
+
export function box2ArrayFindIndexIntersecting(boxes, box) {
|
|
81
|
+
assertWholeBoxes_("box2ArrayFindIndexIntersecting", boxes);
|
|
82
|
+
const minX = box[0];
|
|
83
|
+
const minY = box[1];
|
|
84
|
+
const maxX = box[2];
|
|
85
|
+
const maxY = box[3];
|
|
86
|
+
if (!(minX <= maxX && minY <= maxY)) {
|
|
87
|
+
return -1;
|
|
88
|
+
}
|
|
89
|
+
for (let offset = 0; offset < boxes.length; offset += 4) {
|
|
90
|
+
if (boxes[offset] <= maxX &&
|
|
91
|
+
minX <= boxes[offset + 2] &&
|
|
92
|
+
boxes[offset + 1] <= maxY &&
|
|
93
|
+
minY <= boxes[offset + 3] &&
|
|
94
|
+
boxes[offset] <= boxes[offset + 2] &&
|
|
95
|
+
boxes[offset + 1] <= boxes[offset + 3]) {
|
|
96
|
+
return offset / 4;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return -1;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Writes the index of every box that shares a point with `box` into `out`, in
|
|
103
|
+
* increasing order, and returns how many. O(n).
|
|
104
|
+
*
|
|
105
|
+
* @param out At least as long as the number of boxes.
|
|
106
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4 or `out` is
|
|
107
|
+
* shorter than the number of boxes.
|
|
108
|
+
*/
|
|
109
|
+
export function box2ArrayIntersecting(out, boxes, box) {
|
|
110
|
+
assertWholeBoxes_("box2ArrayIntersecting", boxes);
|
|
111
|
+
if (out.length < boxes.length / 4) {
|
|
112
|
+
throw new RangeError(`box2ArrayIntersecting: out holds ${out.length} indices for ${boxes.length / 4} boxes.`);
|
|
113
|
+
}
|
|
114
|
+
const minX = box[0];
|
|
115
|
+
const minY = box[1];
|
|
116
|
+
const maxX = box[2];
|
|
117
|
+
const maxY = box[3];
|
|
118
|
+
let count = 0;
|
|
119
|
+
if (!(minX <= maxX && minY <= maxY)) {
|
|
120
|
+
return count;
|
|
121
|
+
}
|
|
122
|
+
for (let offset = 0; offset < boxes.length; offset += 4) {
|
|
123
|
+
if (boxes[offset] <= maxX &&
|
|
124
|
+
minX <= boxes[offset + 2] &&
|
|
125
|
+
boxes[offset + 1] <= maxY &&
|
|
126
|
+
minY <= boxes[offset + 3] &&
|
|
127
|
+
boxes[offset] <= boxes[offset + 2] &&
|
|
128
|
+
boxes[offset + 1] <= boxes[offset + 3]) {
|
|
129
|
+
out[count++] = offset / 4;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return count;
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=box2-array.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box2-array.js","sourceRoot":"","sources":["../src/box2-array.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,SAAS,iBAAiB,CAAC,IAAY,EAAE,KAAmB;IAC3D,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,UAAU,CACnB,GAAG,IAAI,eAAe,KAAK,CAAC,MAAM,gCAAgC,CAClE,CAAC;IACH,CAAC;AACF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAC7C,KAAmB,EACnB,CAAS,EACT,CAAS;IAET,iBAAiB,CAAC,gCAAgC,EAAE,KAAK,CAAC,CAAC;IAC3D,KAAK,IAAI,MAAM,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,CAAC;QACzD,IACC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAE;YACnB,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE;YACvB,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE;YACvB,CAAC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,EACtB,CAAC;YACF,OAAO,MAAM,GAAG,CAAC,CAAC;QACnB,CAAC;IACF,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACX,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kCAAkC,CACjD,KAAmB,EACnB,CAAS,EACT,CAAS;IAET,iBAAiB,CAAC,oCAAoC,EAA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
|
1
|
+
import type { ReadonlyVec2, Vec2 } from "@ac-kit/math-linear";
|
|
2
|
+
import type { ReadonlyBox2, Box2 } from "./box2-record.js";
|
|
3
|
+
/**
|
|
4
|
+
* Writes the empty box into `out`: `+∞` minima and `−∞` maxima, so that the
|
|
5
|
+
* union with any box is that box and nothing intersects it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function box2Empty(out: Box2): Box2;
|
|
8
|
+
/**
|
|
9
|
+
* Writes the box of the given `center` and `size` (the full extent on each
|
|
10
|
+
* axis) into `out`. A negative size gives an empty box.
|
|
11
|
+
*/
|
|
12
|
+
export declare function box2FromCenterSize(out: Box2, center: ReadonlyVec2, size: ReadonlyVec2): Box2;
|
|
13
|
+
/** Writes the box spanned by any two opposite corners into `out`. */
|
|
14
|
+
export declare function box2FromCorners(out: Box2, a: ReadonlyVec2, b: ReadonlyVec2): Box2;
|
|
15
|
+
/**
|
|
16
|
+
* Writes the bounds of the 2-number points of `points` into `out`; an empty
|
|
17
|
+
* buffer gives the empty box. A point with a `NaN` component leaves that axis
|
|
18
|
+
* to the other points. O(n).
|
|
19
|
+
*
|
|
20
|
+
* @throws {RangeError} When `points.length` is not a multiple of 2.
|
|
21
|
+
*/
|
|
22
|
+
export declare function box2FromPoints(out: Box2, points: Float64Array): Box2;
|
|
23
|
+
/**
|
|
24
|
+
* Like {@link box2FromPoints} for interleaved data: point `i` starts at `offset +
|
|
25
|
+
* i·stride`, both counted in numbers, for `count` points. O(count).
|
|
26
|
+
*
|
|
27
|
+
* @throws {RangeError} When `count` is not a non-negative integer or the last
|
|
28
|
+
* point does not fit in `points`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function box2FromPointsStrided(out: Box2, points: Float64Array, offset: number, stride: number, count: number): Box2;
|
|
31
|
+
/**
|
|
32
|
+
* Whether the box has a minimum above its maximum on some axis. `NaN` is not
|
|
33
|
+
* above anything.
|
|
34
|
+
*/
|
|
35
|
+
export declare function box2IsEmpty(box: ReadonlyBox2): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Writes the extent of the box on each axis, `max − min`, into `out`. An empty
|
|
38
|
+
* box gives negative extents.
|
|
39
|
+
*/
|
|
40
|
+
export declare function box2Size(out: Vec2, box: ReadonlyBox2): Vec2;
|
|
41
|
+
/**
|
|
42
|
+
* Writes the centre of the box into `out`. An empty box gives `NaN` where a
|
|
43
|
+
* bound is infinite.
|
|
44
|
+
*/
|
|
45
|
+
export declare function box2Center(out: Vec2, box: ReadonlyBox2): Vec2;
|
|
46
|
+
/** Whether `point` lies in the box, boundary included. */
|
|
47
|
+
export declare function box2ContainsPoint(box: ReadonlyBox2, point: ReadonlyVec2): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Whether `inner` lies in the box, boundary included. An empty `inner` is
|
|
50
|
+
* contained in any box.
|
|
51
|
+
*/
|
|
52
|
+
export declare function box2ContainsBox2(box: ReadonlyBox2, inner: ReadonlyBox2): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the two boxes share a point, boundaries included. An empty box (an
|
|
55
|
+
* inverted axis) intersects nothing.
|
|
56
|
+
*/
|
|
57
|
+
export declare function box2IntersectsBox2(a: ReadonlyBox2, b: ReadonlyBox2): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Writes the common part of two boxes into `out`; disjoint boxes give an empty
|
|
60
|
+
* box ({@link box2IsEmpty}).
|
|
61
|
+
*/
|
|
62
|
+
export declare function box2Intersection(out: Box2, a: ReadonlyBox2, b: ReadonlyBox2): Box2;
|
|
63
|
+
/**
|
|
64
|
+
* Writes the smallest box holding both boxes into `out`; an empty box (an
|
|
65
|
+
* inverted axis) adds nothing, and two empty boxes give {@link box2Empty}. `out`
|
|
66
|
+
* may be `a` or `b`.
|
|
67
|
+
*/
|
|
68
|
+
export declare function box2Union(out: Box2, a: ReadonlyBox2, b: ReadonlyBox2): Box2;
|
|
69
|
+
/** Writes the smallest box holding `box` and `point` into `out`. */
|
|
70
|
+
export declare function box2ExpandByPoint(out: Box2, box: ReadonlyBox2, point: ReadonlyVec2): Box2;
|
|
71
|
+
/**
|
|
72
|
+
* Writes `box` grown by `margin` on every side into `out`; a negative margin
|
|
73
|
+
* insets and may empty the box.
|
|
74
|
+
*/
|
|
75
|
+
export declare function box2ExpandByScalar(out: Box2, box: ReadonlyBox2, margin: number): Box2;
|
|
76
|
+
/** Writes `box` moved by `offset` into `out`. */
|
|
77
|
+
export declare function box2Translate(out: Box2, box: ReadonlyBox2, offset: ReadonlyVec2): Box2;
|
|
78
|
+
/**
|
|
79
|
+
* Writes the point of the box nearest to `point` into `out`; `out` may be
|
|
80
|
+
* `point`. An empty box gives an unspecified point.
|
|
81
|
+
*/
|
|
82
|
+
export declare function box2ClampPoint(out: Vec2, box: ReadonlyBox2, point: ReadonlyVec2): Vec2;
|
|
83
|
+
/** The distance from `point` to the box: `0` inside or on it. */
|
|
84
|
+
export declare function box2DistanceToPoint(box: ReadonlyBox2, point: ReadonlyVec2): number;
|
|
85
|
+
/**
|
|
86
|
+
* Writes the bounds interpolated from `a` (`t = 0`) to `b` (`t = 1`, exact)
|
|
87
|
+
* into `out`. Not math-scalar's `lerp`, which is `a + (b − a)·t` and misses `b`
|
|
88
|
+
* by rounding at `t = 1`.
|
|
89
|
+
*/
|
|
90
|
+
export declare function box2Lerp(out: Box2, a: ReadonlyBox2, b: ReadonlyBox2, t: number): Box2;
|
|
91
|
+
/**
|
|
92
|
+
* Writes the coordinates of `point` inside the box, `0` at the minimum corner
|
|
93
|
+
* and `1` at the maximum, into `out`: the inverse of {@link box2PointAt}. A flat
|
|
94
|
+
* axis gives non-finite coordinates.
|
|
95
|
+
*/
|
|
96
|
+
export declare function box2Parameter(out: Vec2, box: ReadonlyBox2, point: ReadonlyVec2): Vec2;
|
|
97
|
+
/**
|
|
98
|
+
* Writes the point of the box at `parameter` (`0` at the minimum corner, `1` at
|
|
99
|
+
* the maximum) into `out`.
|
|
100
|
+
*/
|
|
101
|
+
export declare function box2PointAt(out: Vec2, box: ReadonlyBox2, parameter: ReadonlyVec2): Vec2;
|
|
102
|
+
/**
|
|
103
|
+
* Writes the union of every box of `boxes` (4 numbers each) into `out`; an
|
|
104
|
+
* empty buffer, or one of empty (inverted) boxes only, gives the empty box.
|
|
105
|
+
* O(n).
|
|
106
|
+
*
|
|
107
|
+
* @throws {RangeError} When `boxes.length` is not a multiple of 4.
|
|
108
|
+
*/
|
|
109
|
+
export declare function box2ArrayUnion(out: Box2, boxes: Float64Array): Box2;
|
|
110
|
+
//# sourceMappingURL=box2-componentwise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"box2-componentwise.d.ts","sourceRoot":"","sources":["../src/box2-componentwise.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAG9D,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE3D;;;GAGG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,IAAI,GAAG,IAAI,CAMzC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CACjC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,YAAY,GAChB,IAAI,CAMN;AAED,qEAAqE;AACrE,wBAAgB,eAAe,CAC9B,GAAG,EAAE,IAAI,EACT,CAAC,EAAE,YAAY,EACf,CAAC,EAAE,YAAY,GACb,IAAI,CAMN;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAgCpE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,GAAG,EAAE,IAAI,EACT,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,IAAI,CAwCN;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,GA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