@math.gl/geometry 5.0.0-beta.4 → 5.0.0-beta.6
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/README.md +61 -0
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/color/color-lut-types.d.ts +16 -0
- package/dist/color/color-lut-types.d.ts.map +1 -0
- package/dist/color/color-lut-types.js +5 -0
- package/dist/color/color-lut-types.js.map +1 -0
- package/dist/color/index.cjs +132 -0
- package/dist/color/index.cjs.map +6 -0
- package/dist/color/index.d.ts +4 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +5 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/sample-lut.d.ts +13 -0
- package/dist/color/sample-lut.d.ts.map +1 -0
- package/dist/color/sample-lut.js +132 -0
- package/dist/color/sample-lut.js.map +1 -0
- package/dist/culling/bounds.d.ts +20 -0
- package/dist/culling/bounds.d.ts.map +1 -0
- package/dist/culling/bounds.js +121 -0
- package/dist/culling/bounds.js.map +1 -0
- package/dist/culling/frustum-planes.d.ts +5 -0
- package/dist/culling/frustum-planes.d.ts.map +1 -0
- package/dist/culling/frustum-planes.js +37 -0
- package/dist/culling/frustum-planes.js.map +1 -0
- package/dist/culling/geometric-queries.d.ts +34 -0
- package/dist/culling/geometric-queries.d.ts.map +1 -0
- package/dist/culling/geometric-queries.js +208 -0
- package/dist/culling/geometric-queries.js.map +1 -0
- package/dist/culling/index.cjs +917 -514
- package/dist/culling/index.cjs.map +3 -3
- package/dist/culling/index.d.ts +5 -1
- package/dist/culling/index.d.ts.map +1 -1
- package/dist/culling/index.js +3 -0
- package/dist/culling/index.js.map +1 -1
- package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.d.ts +3 -3
- package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.d.ts.map +1 -1
- package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.js +25 -8
- package/dist/culling/lib/bounding-volumes/axis-aligned-bounding-box.js.map +1 -1
- package/dist/culling/lib/culling-volume.d.ts +3 -0
- package/dist/culling/lib/culling-volume.d.ts.map +1 -1
- package/dist/culling/lib/culling-volume.js +7 -0
- package/dist/culling/lib/culling-volume.js.map +1 -1
- package/dist/culling/lib/ray.d.ts +5 -0
- package/dist/culling/lib/ray.d.ts.map +1 -1
- package/dist/culling/lib/ray.js +21 -0
- package/dist/culling/lib/ray.js.map +1 -1
- package/dist/curves/adaptive-sampling.d.ts +16 -0
- package/dist/curves/adaptive-sampling.d.ts.map +1 -0
- package/dist/curves/adaptive-sampling.js +59 -0
- package/dist/curves/adaptive-sampling.js.map +1 -0
- package/dist/curves/index.d.ts +4 -0
- package/dist/curves/index.d.ts.map +1 -1
- package/dist/curves/index.js +2 -0
- package/dist/curves/index.js.map +1 -1
- package/dist/curves/parallel-transport.d.ts +12 -0
- package/dist/curves/parallel-transport.d.ts.map +1 -0
- package/dist/curves/parallel-transport.js +83 -0
- package/dist/curves/parallel-transport.js.map +1 -0
- package/dist/index.cjs +1336 -699
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/lighting/index.cjs +175 -0
- package/dist/lighting/index.cjs.map +6 -0
- package/dist/lighting/index.d.ts +4 -0
- package/dist/lighting/index.d.ts.map +1 -0
- package/dist/lighting/index.js +5 -0
- package/dist/lighting/index.js.map +1 -0
- package/dist/lighting/lighting-types.d.ts +16 -0
- package/dist/lighting/lighting-types.d.ts.map +1 -0
- package/dist/lighting/lighting-types.js +5 -0
- package/dist/lighting/lighting-types.js.map +1 -0
- package/dist/lighting/photometry.d.ts +36 -0
- package/dist/lighting/photometry.d.ts.map +1 -0
- package/dist/lighting/photometry.js +181 -0
- package/dist/lighting/photometry.js.map +1 -0
- package/dist/utils/project-bounds.d.ts +44 -0
- package/dist/utils/project-bounds.d.ts.map +1 -0
- package/dist/utils/project-bounds.js +93 -0
- package/dist/utils/project-bounds.js.map +1 -0
- package/dist/utils/project-texture-coordinates.d.ts +19 -0
- package/dist/utils/project-texture-coordinates.d.ts.map +1 -0
- package/dist/utils/project-texture-coordinates.js +49 -0
- package/dist/utils/project-texture-coordinates.js.map +1 -0
- package/package.json +15 -3
- package/src/color/color-lut-types.ts +19 -0
- package/src/color/index.ts +6 -0
- package/src/color/sample-lut.ts +175 -0
- package/src/culling/bounds.ts +152 -0
- package/src/culling/frustum-planes.ts +41 -0
- package/src/culling/geometric-queries.ts +299 -0
- package/src/culling/index.ts +37 -1
- package/src/culling/lib/bounding-volumes/axis-aligned-bounding-box.ts +26 -8
- package/src/culling/lib/culling-volume.ts +9 -1
- package/src/culling/lib/ray.ts +21 -0
- package/src/curves/adaptive-sampling.ts +85 -0
- package/src/curves/index.ts +4 -0
- package/src/curves/parallel-transport.ts +104 -0
- package/src/index.ts +44 -0
- package/src/lighting/index.ts +10 -0
- package/src/lighting/lighting-types.ts +20 -0
- package/src/lighting/photometry.ts +264 -0
- package/src/utils/project-bounds.ts +154 -0
- package/src/utils/project-texture-coordinates.ts +67 -0
package/README.md
CHANGED
|
@@ -24,7 +24,68 @@ The experimental `HingeTree` evaluates rigid panels connected by hinges. See the
|
|
|
24
24
|
[HingeTree API](https://math.gl/docs/modules/geometry/api-reference/hinge-tree) and
|
|
25
25
|
[unfolding polyhedra example](https://github.com/visgl/math.gl/tree/master/examples/geometry/unfolding-polyhedron).
|
|
26
26
|
|
|
27
|
+
Optional `@math.gl/geometry/lighting` and `@math.gl/geometry/color` subpaths provide renderer-independent photometric and color LUT calculations. See the [lighting and color guide](https://math.gl/docs/modules/geometry/lighting). These CPU graphics utilities return numbers and typed arrays; file parsing remains in loaders.gl.
|
|
28
|
+
|
|
29
|
+
`projectBounds` samples a prepared nonlinear transform over a finite box. Its result distinguishes approximate fitting from an enclosure conditional on caller-qualified Lipschitz bounds. See the [API reference](https://math.gl/docs/modules/geometry/utils/api-reference/project-bounds).
|
|
30
|
+
Generate detached float64 UVs for CPU positions with `projectTextureCoordinates`, an explicit image rectangle and a prepared synchronous transform. It does not infer projection seams, clip domains or allocate GPU resources. See the [API reference](https://math.gl/docs/modules/geometry/utils/api-reference/project-texture-coordinates).
|
|
31
|
+
|
|
27
32
|
## Sources and credits
|
|
28
33
|
|
|
29
34
|
See [the packaged source and license index](./THIRD-PARTY-NOTICES.md) and
|
|
30
35
|
[math.gl references and credits](https://math.gl/docs/references-and-credits).
|
|
36
|
+
|
|
37
|
+
## Culling
|
|
38
|
+
|
|
39
|
+
This module contains classes for bounding boxes, view frustum intersections and analytic shapes.
|
|
40
|
+
|
|
41
|
+
The `BoxShape`, `CapsuleShape`, `CylinderShape`, `PlaneShape` and `SphereShape` classes follow the
|
|
42
|
+
glTF 2.1 draft shape conventions. They support point containment and distance, plane/frustum
|
|
43
|
+
classification, ray intersections, affine transforms and conservative enclosing bounds. Shape
|
|
44
|
+
distance is exact under rigid or uniform-scale transforms and estimated under non-uniform scale or
|
|
45
|
+
shear. `PlaneShape` represents an unbounded half-space and therefore has no finite bounding box or
|
|
46
|
+
bounding sphere.
|
|
47
|
+
|
|
48
|
+
## Curves
|
|
49
|
+
|
|
50
|
+
Renderer-independent 2D and 3D Euclidean curves: lines, quadratic and cubic Bézier curves,
|
|
51
|
+
cubic Hermite curves, and open or closed Catmull–Rom splines. Includes analytic derivatives,
|
|
52
|
+
unit tangents, flat Float64 sampling, and reusable approximate arc-length tables.
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
import {CubicBezierCurve, CurveArcLength} from '@math.gl/geometry';
|
|
56
|
+
|
|
57
|
+
const curve = new CubicBezierCurve([0, 0, 0], [1, 2, 0], [3, 2, 1], [4, 0, 1]);
|
|
58
|
+
const point = curve.getPoint(0.5);
|
|
59
|
+
const tangent = curve.getTangent(0.5);
|
|
60
|
+
const traversal = new CurveArcLength(curve);
|
|
61
|
+
const positions = traversal.getSpacedPoints(100); // 101 xyz vertices
|
|
62
|
+
const output = new Float64Array(3);
|
|
63
|
+
traversal.getPointAt(0.25, output); // reuse a buffer during animation
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Control points are copied at construction. Parameters are in [0, 1]; coordinates use the
|
|
67
|
+
caller's Cartesian units. Longitude/latitude inputs are treated as a plane, not geodesics.
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
See the [module documentation](https://math.gl/docs/modules/curves) for the API and numerical limits.
|
|
71
|
+
|
|
72
|
+
## Polygon
|
|
73
|
+
|
|
74
|
+
This module contains utilities that work with polylines and polygons.
|
|
75
|
+
|
|
76
|
+
### Projection-aware subdivision
|
|
77
|
+
|
|
78
|
+
`subdividePolyline` subdivides source edges through a supplied coordinate transform using a tolerance in target units. It returns source and target coordinates plus edge attribution for interpolating other data. See the [API reference](https://math.gl/docs/modules/geometry/polygon/api-reference/subdivide-polyline) for domains, limits, accuracy, and polygon-ring usage.
|
|
79
|
+
|
|
80
|
+
`subdivideTriangleMesh` refines indexed triangle meshes with shared-edge conformity and interpolation weights for UVs and other vertex attributes. It supports filled polygons after triangulation and textured bitmap meshes. See the [mesh API reference](https://math.gl/docs/modules/geometry/polygon/api-reference/subdivide-triangle-mesh).
|
|
81
|
+
|
|
82
|
+
## Spatial index
|
|
83
|
+
|
|
84
|
+
Experimental static 2D/3D box and point indexes and a triangle BVH. Queries return original
|
|
85
|
+
input row or triangle indices. Intended as a reusable mathematical foundation for loaders and
|
|
86
|
+
applications, with geometry refinement left to adapters. See the module docs for limits.
|
|
87
|
+
|
|
88
|
+
## Utils
|
|
89
|
+
|
|
90
|
+
This module contains dependency-light utilities for typed-array geometry, primitive iteration,
|
|
91
|
+
vertex normals, packed colors, and compressed attributes.
|
package/THIRD-PARTY-NOTICES.md
CHANGED
|
@@ -13,6 +13,6 @@ latest available upstream releases.
|
|
|
13
13
|
| Mapbox / lineclip | Adapted flat-array clipping; ISC notice retained in `src/polygon/lineclip.ts` and [LICENSE](./LICENSE). |
|
|
14
14
|
| luma.gl / vis.gl contributors | CPU geometry tessellation lineage, including truncated cones; MIT, [LICENSE](./LICENSE). |
|
|
15
15
|
|
|
16
|
-
Hinge evaluation and
|
|
16
|
+
Hinge evaluation and myriahedral geometry were developed independently of
|
|
17
17
|
Nico Belmonte's application source. His work is credited as inspiration, not as
|
|
18
18
|
licensed source incorporated into this package.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Numerical RGB lookup table, independent of its file encoding or renderer. */
|
|
2
|
+
export type ColorLUT = {
|
|
3
|
+
/** Independent 1D curves or one 3D RGB mapping. */
|
|
4
|
+
dimension: 1 | 3;
|
|
5
|
+
/** Number of samples along each axis. */
|
|
6
|
+
size: number;
|
|
7
|
+
/** Interleaved RGB values, red coordinate varying fastest for 3D tables. */
|
|
8
|
+
data: Float32Array;
|
|
9
|
+
/** Minimum input coordinate for each channel. */
|
|
10
|
+
domainMinimum: number[];
|
|
11
|
+
/** Maximum input coordinate for each channel. */
|
|
12
|
+
domainMaximum: number[];
|
|
13
|
+
/** Optional strictly increasing normalized knots from 0 through 1. */
|
|
14
|
+
inputGrid?: Float64Array;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=color-lut-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-lut-types.d.ts","sourceRoot":"","sources":["../../src/color/color-lut-types.ts"],"names":[],"mappings":"AAIA,gFAAgF;AAChF,MAAM,MAAM,QAAQ,GAAG;IACrB,mDAAmD;IACnD,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC;IACjB,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,4EAA4E;IAC5E,IAAI,EAAE,YAAY,CAAC;IACnB,iDAAiD;IACjD,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,iDAAiD;IACjD,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,sEAAsE;IACtE,SAAS,CAAC,EAAE,YAAY,CAAC;CAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-lut-types.js","sourceRoot":"","sources":["../../src/color/color-lut-types.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// dist/color/index.js
|
|
20
|
+
var index_exports = {};
|
|
21
|
+
__export(index_exports, {
|
|
22
|
+
applyColorLUT: () => applyColorLUT,
|
|
23
|
+
createColorLUTSampler: () => createColorLUTSampler
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// dist/color/sample-lut.js
|
|
28
|
+
function createColorLUTSampler(lut) {
|
|
29
|
+
const writeSample = createColorLUTWriter(lut);
|
|
30
|
+
return (red, green, blue) => {
|
|
31
|
+
const result = [0, 0, 0];
|
|
32
|
+
writeSample(red, green, blue, result, 0);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function createColorLUTWriter(lut) {
|
|
37
|
+
var _a;
|
|
38
|
+
const { dimension, size } = lut;
|
|
39
|
+
if (![1, 3].includes(dimension) || !Number.isSafeInteger(size) || size < 2 || !Number.isSafeInteger(size ** dimension * 3) || lut.data.length !== size ** dimension * 3 || lut.domainMinimum.length !== 3 || lut.domainMaximum.length !== 3) {
|
|
40
|
+
throw new Error("LUT: invalid calculation table");
|
|
41
|
+
}
|
|
42
|
+
const minimum = Array.from(lut.domainMinimum);
|
|
43
|
+
const maximum = Array.from(lut.domainMaximum);
|
|
44
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
45
|
+
if (!Number.isFinite(minimum[channel]) || !Number.isFinite(maximum[channel]) || !Number.isFinite(maximum[channel] - minimum[channel]) || maximum[channel] <= minimum[channel])
|
|
46
|
+
throw new Error("LUT: invalid calculation domain");
|
|
47
|
+
}
|
|
48
|
+
if (!lut.data.every(Number.isFinite))
|
|
49
|
+
throw new Error("LUT: invalid calculation samples");
|
|
50
|
+
const data = lut.data.slice();
|
|
51
|
+
const grid = (_a = lut.inputGrid) == null ? void 0 : _a.slice();
|
|
52
|
+
if (grid && (grid.length !== size || grid[0] !== 0 || grid[size - 1] !== 1 || grid.some((value, index) => !Number.isFinite(value) || index > 0 && value <= grid[index - 1]))) {
|
|
53
|
+
throw new Error("LUT: invalid nonuniform input grid");
|
|
54
|
+
}
|
|
55
|
+
const coordinates = [0, 0, 0];
|
|
56
|
+
const indices = [0, 0, 0];
|
|
57
|
+
const weights = [0, 0, 0];
|
|
58
|
+
const accumulated = [0, 0, 0];
|
|
59
|
+
return (red, green, blue, result, resultOffset) => {
|
|
60
|
+
coordinates[0] = red;
|
|
61
|
+
coordinates[1] = green;
|
|
62
|
+
coordinates[2] = blue;
|
|
63
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
64
|
+
const value = coordinates[channel];
|
|
65
|
+
if (!Number.isFinite(value))
|
|
66
|
+
throw new Error("LUT: input colors must be finite");
|
|
67
|
+
const normalized = value <= minimum[channel] ? 0 : value >= maximum[channel] ? 1 : (value - minimum[channel]) / (maximum[channel] - minimum[channel]);
|
|
68
|
+
writeLUTInterval(normalized, size, grid, indices, weights, channel);
|
|
69
|
+
}
|
|
70
|
+
accumulated[0] = 0;
|
|
71
|
+
accumulated[1] = 0;
|
|
72
|
+
accumulated[2] = 0;
|
|
73
|
+
if (dimension === 1) {
|
|
74
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
75
|
+
const offset = indices[channel] * 3 + channel;
|
|
76
|
+
accumulated[channel] = data[offset] * (1 - weights[channel]) + data[offset + 3] * weights[channel];
|
|
77
|
+
}
|
|
78
|
+
} else {
|
|
79
|
+
for (let blueCorner = 0; blueCorner < 2; blueCorner++) {
|
|
80
|
+
for (let greenCorner = 0; greenCorner < 2; greenCorner++) {
|
|
81
|
+
for (let redCorner = 0; redCorner < 2; redCorner++) {
|
|
82
|
+
const weight = (redCorner ? weights[0] : 1 - weights[0]) * (greenCorner ? weights[1] : 1 - weights[1]) * (blueCorner ? weights[2] : 1 - weights[2]);
|
|
83
|
+
const offset = (((indices[2] + blueCorner) * size + indices[1] + greenCorner) * size + indices[0] + redCorner) * 3;
|
|
84
|
+
for (let channel = 0; channel < 3; channel++)
|
|
85
|
+
accumulated[channel] += data[offset + channel] * weight;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (let channel = 0; channel < 3; channel++)
|
|
91
|
+
result[resultOffset + channel] = accumulated[channel];
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function applyColorLUT(lut, colors, options = {}) {
|
|
95
|
+
const { components = 3 } = options;
|
|
96
|
+
if (![3, 4].includes(components) || colors.length % components !== 0)
|
|
97
|
+
throw new Error("LUT: invalid pixel component count");
|
|
98
|
+
const writeSample = createColorLUTWriter(lut);
|
|
99
|
+
const result = new Float32Array(colors.length);
|
|
100
|
+
for (let offset = 0; offset < colors.length; offset += components) {
|
|
101
|
+
writeSample(colors[offset], colors[offset + 1], colors[offset + 2], result, offset);
|
|
102
|
+
if (components === 4) {
|
|
103
|
+
const alpha = colors[offset + 3];
|
|
104
|
+
result[offset + 3] = alpha;
|
|
105
|
+
if (!Number.isFinite(alpha) || !Number.isFinite(result[offset + 3]))
|
|
106
|
+
throw new Error("LUT: alpha cannot be represented as float32");
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return result;
|
|
110
|
+
}
|
|
111
|
+
function writeLUTInterval(value, size, grid, indices, weights, channel) {
|
|
112
|
+
if (!grid) {
|
|
113
|
+
const coordinate = value * (size - 1);
|
|
114
|
+
const lower2 = Math.min(Math.floor(coordinate), size - 2);
|
|
115
|
+
indices[channel] = lower2;
|
|
116
|
+
weights[channel] = coordinate - lower2;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
let lower = 0;
|
|
120
|
+
let upper = size - 1;
|
|
121
|
+
while (upper - lower > 1) {
|
|
122
|
+
const midpoint = Math.floor((lower + upper) / 2);
|
|
123
|
+
if (value < grid[midpoint])
|
|
124
|
+
upper = midpoint;
|
|
125
|
+
else
|
|
126
|
+
lower = midpoint;
|
|
127
|
+
}
|
|
128
|
+
lower = Math.min(lower, size - 2);
|
|
129
|
+
indices[channel] = lower;
|
|
130
|
+
weights[channel] = (value - grid[lower]) / (grid[lower + 1] - grid[lower]);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/color/index.ts", "../../src/color/sample-lut.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;ACmBM,SAAU,sBAAsB,KAAa;AACjD,QAAM,cAAc,qBAAqB,GAAG;AAC5C,SAAO,CAAC,KAAK,OAAO,SAAQ;AAC1B,UAAM,SAAmC,CAAC,GAAG,GAAG,CAAC;AACjD,gBAAY,KAAK,OAAO,MAAM,QAAQ,CAAC;AACvC,WA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;;AAC/B,cAAQ;EACf;AACA,UAAQ,KAAK,IAAI,OAAO,OAAO,CAAC;AAChC,UAAQ,OAAO,IAAI;AACnB,UAAQ,OAAO,KAAK,QAAQ,KAAK,KAAK,MAAM,KAAK,QAAQ,CAAC,IAAI,KAAK,KAAK;AAC1E;",
|
|
5
|
+
"names": ["lower"]
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/color/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,qBAAqB,EAAE,aAAa,EAAC,wBAAqB;AAClE,YAAY,EAAC,eAAe,EAAE,oBAAoB,EAAC,wBAAqB;AACxE,YAAY,EAAC,QAAQ,EAAC,6BAA0B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/color/index.ts"],"names":[],"mappings":"AAAA,UAAU;AACV,+BAA+B;AAC/B,4DAA4D;AAC5D,OAAO,EAAC,qBAAqB,EAAE,aAAa,EAAC,wBAAqB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ColorLUT } from "./color-lut-types.js";
|
|
2
|
+
/** Reusable RGB sampler; inputs use the authored domain and outputs retain signed/HDR values. */
|
|
3
|
+
export type ColorLUTSampler = (red: number, green: number, blue: number) => [number, number, number];
|
|
4
|
+
/** Options for interleaved floating-point RGB or RGBA buffers. */
|
|
5
|
+
export type ApplyColorLUTOptions = {
|
|
6
|
+
/** Number of interleaved components; default 3. Alpha is copied at float32 precision. */
|
|
7
|
+
components?: 3 | 4;
|
|
8
|
+
};
|
|
9
|
+
/** Creates a snapshot sampler with per-channel 1D linear or red-fastest 3D trilinear interpolation. */
|
|
10
|
+
export declare function createColorLUTSampler(lut: ColorLUT): ColorLUTSampler;
|
|
11
|
+
/** Applies a LUT to floating-point pixels without changing the source or applying transfer functions. */
|
|
12
|
+
export declare function applyColorLUT(lut: ColorLUT, colors: Float32Array | Float64Array, options?: ApplyColorLUTOptions): Float32Array;
|
|
13
|
+
//# sourceMappingURL=sample-lut.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample-lut.d.ts","sourceRoot":"","sources":["../../src/color/sample-lut.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,QAAQ,EAAC,6BAA0B;AAEhD,iGAAiG;AACjG,MAAM,MAAM,eAAe,GAAG,CAC5B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,KACT,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE9B,kEAAkE;AAClE,MAAM,MAAM,oBAAoB,GAAG;IACjC,yFAAyF;IACzF,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;CACpB,CAAC;AAEF,uGAAuG;AACvG,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,QAAQ,GAAG,eAAe,CAOpE;AAmGD,yGAAyG;AACzG,wBAAgB,aAAa,CAC3B,GAAG,EAAE,QAAQ,EACb,MAAM,EAAE,YAAY,GAAG,YAAY,EACnC,OAAO,GAAE,oBAAyB,GACjC,YAAY,CAgBd"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** Creates a snapshot sampler with per-channel 1D linear or red-fastest 3D trilinear interpolation. */
|
|
2
|
+
export function createColorLUTSampler(lut) {
|
|
3
|
+
const writeSample = createColorLUTWriter(lut);
|
|
4
|
+
return (red, green, blue) => {
|
|
5
|
+
const result = [0, 0, 0];
|
|
6
|
+
writeSample(red, green, blue, result, 0);
|
|
7
|
+
return result;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
/** Creates a validated snapshot writer with reusable per-sampler scratch storage. */
|
|
11
|
+
function createColorLUTWriter(lut) {
|
|
12
|
+
const { dimension, size } = lut;
|
|
13
|
+
if (![1, 3].includes(dimension) ||
|
|
14
|
+
!Number.isSafeInteger(size) ||
|
|
15
|
+
size < 2 ||
|
|
16
|
+
!Number.isSafeInteger(size ** dimension * 3) ||
|
|
17
|
+
lut.data.length !== size ** dimension * 3 ||
|
|
18
|
+
lut.domainMinimum.length !== 3 ||
|
|
19
|
+
lut.domainMaximum.length !== 3) {
|
|
20
|
+
throw new Error('LUT: invalid calculation table');
|
|
21
|
+
}
|
|
22
|
+
const minimum = Array.from(lut.domainMinimum);
|
|
23
|
+
const maximum = Array.from(lut.domainMaximum);
|
|
24
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
25
|
+
if (!Number.isFinite(minimum[channel]) ||
|
|
26
|
+
!Number.isFinite(maximum[channel]) ||
|
|
27
|
+
!Number.isFinite(maximum[channel] - minimum[channel]) ||
|
|
28
|
+
maximum[channel] <= minimum[channel])
|
|
29
|
+
throw new Error('LUT: invalid calculation domain');
|
|
30
|
+
}
|
|
31
|
+
if (!lut.data.every(Number.isFinite))
|
|
32
|
+
throw new Error('LUT: invalid calculation samples');
|
|
33
|
+
const data = lut.data.slice();
|
|
34
|
+
const grid = lut.inputGrid?.slice();
|
|
35
|
+
if (grid &&
|
|
36
|
+
(grid.length !== size ||
|
|
37
|
+
grid[0] !== 0 ||
|
|
38
|
+
grid[size - 1] !== 1 ||
|
|
39
|
+
grid.some((value, index) => !Number.isFinite(value) || (index > 0 && value <= grid[index - 1])))) {
|
|
40
|
+
throw new Error('LUT: invalid nonuniform input grid');
|
|
41
|
+
}
|
|
42
|
+
const coordinates = [0, 0, 0];
|
|
43
|
+
const indices = [0, 0, 0];
|
|
44
|
+
const weights = [0, 0, 0];
|
|
45
|
+
const accumulated = [0, 0, 0];
|
|
46
|
+
return (red, green, blue, result, resultOffset) => {
|
|
47
|
+
coordinates[0] = red;
|
|
48
|
+
coordinates[1] = green;
|
|
49
|
+
coordinates[2] = blue;
|
|
50
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
51
|
+
const value = coordinates[channel];
|
|
52
|
+
if (!Number.isFinite(value))
|
|
53
|
+
throw new Error('LUT: input colors must be finite');
|
|
54
|
+
const normalized = value <= minimum[channel]
|
|
55
|
+
? 0
|
|
56
|
+
: value >= maximum[channel]
|
|
57
|
+
? 1
|
|
58
|
+
: (value - minimum[channel]) / (maximum[channel] - minimum[channel]);
|
|
59
|
+
writeLUTInterval(normalized, size, grid, indices, weights, channel);
|
|
60
|
+
}
|
|
61
|
+
accumulated[0] = 0;
|
|
62
|
+
accumulated[1] = 0;
|
|
63
|
+
accumulated[2] = 0;
|
|
64
|
+
if (dimension === 1) {
|
|
65
|
+
for (let channel = 0; channel < 3; channel++) {
|
|
66
|
+
const offset = indices[channel] * 3 + channel;
|
|
67
|
+
accumulated[channel] =
|
|
68
|
+
data[offset] * (1 - weights[channel]) + data[offset + 3] * weights[channel];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
for (let blueCorner = 0; blueCorner < 2; blueCorner++) {
|
|
73
|
+
for (let greenCorner = 0; greenCorner < 2; greenCorner++) {
|
|
74
|
+
for (let redCorner = 0; redCorner < 2; redCorner++) {
|
|
75
|
+
const weight = (redCorner ? weights[0] : 1 - weights[0]) *
|
|
76
|
+
(greenCorner ? weights[1] : 1 - weights[1]) *
|
|
77
|
+
(blueCorner ? weights[2] : 1 - weights[2]);
|
|
78
|
+
const offset = (((indices[2] + blueCorner) * size + indices[1] + greenCorner) * size +
|
|
79
|
+
indices[0] +
|
|
80
|
+
redCorner) *
|
|
81
|
+
3;
|
|
82
|
+
for (let channel = 0; channel < 3; channel++)
|
|
83
|
+
accumulated[channel] += data[offset + channel] * weight;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (let channel = 0; channel < 3; channel++)
|
|
89
|
+
result[resultOffset + channel] = accumulated[channel];
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Applies a LUT to floating-point pixels without changing the source or applying transfer functions. */
|
|
93
|
+
export function applyColorLUT(lut, colors, options = {}) {
|
|
94
|
+
const { components = 3 } = options;
|
|
95
|
+
if (![3, 4].includes(components) || colors.length % components !== 0)
|
|
96
|
+
throw new Error('LUT: invalid pixel component count');
|
|
97
|
+
const writeSample = createColorLUTWriter(lut);
|
|
98
|
+
const result = new Float32Array(colors.length);
|
|
99
|
+
for (let offset = 0; offset < colors.length; offset += components) {
|
|
100
|
+
writeSample(colors[offset], colors[offset + 1], colors[offset + 2], result, offset);
|
|
101
|
+
if (components === 4) {
|
|
102
|
+
const alpha = colors[offset + 3];
|
|
103
|
+
result[offset + 3] = alpha;
|
|
104
|
+
if (!Number.isFinite(alpha) || !Number.isFinite(result[offset + 3]))
|
|
105
|
+
throw new Error('LUT: alpha cannot be represented as float32');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
/** Finds normalized uniform/nonuniform knots, retaining the final endpoint in the last interval. */
|
|
111
|
+
function writeLUTInterval(value, size, grid, indices, weights, channel) {
|
|
112
|
+
if (!grid) {
|
|
113
|
+
const coordinate = value * (size - 1);
|
|
114
|
+
const lower = Math.min(Math.floor(coordinate), size - 2);
|
|
115
|
+
indices[channel] = lower;
|
|
116
|
+
weights[channel] = coordinate - lower;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
let lower = 0;
|
|
120
|
+
let upper = size - 1;
|
|
121
|
+
while (upper - lower > 1) {
|
|
122
|
+
const midpoint = Math.floor((lower + upper) / 2);
|
|
123
|
+
if (value < grid[midpoint])
|
|
124
|
+
upper = midpoint;
|
|
125
|
+
else
|
|
126
|
+
lower = midpoint;
|
|
127
|
+
}
|
|
128
|
+
lower = Math.min(lower, size - 2);
|
|
129
|
+
indices[channel] = lower;
|
|
130
|
+
weights[channel] = (value - grid[lower]) / (grid[lower + 1] - grid[lower]);
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=sample-lut.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sample-lut.js","sourceRoot":"","sources":["../../src/color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,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC;IAClC,OAAO,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC;IACzB,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Bounds, Bounds2D, Bounds3D, NumericArray } from '@math.gl/core';
|
|
2
|
+
type ReadonlyBounds = readonly [ArrayLike<number>, ArrayLike<number>];
|
|
3
|
+
export declare function createEmptyBounds(dimension: 2): Bounds2D;
|
|
4
|
+
export declare function createEmptyBounds(dimension: 3): Bounds3D;
|
|
5
|
+
export declare function createEmptyBounds(dimension: 2 | 3): Bounds;
|
|
6
|
+
/** Any inverted axis denotes empty bounds. Equal endpoints describe a nonempty point. */
|
|
7
|
+
export declare function isEmptyBounds(bounds: ReadonlyBounds): boolean;
|
|
8
|
+
export declare function boundsContainsPoint(bounds: ReadonlyBounds, p: ArrayLike<number>): boolean;
|
|
9
|
+
export declare function boundsContainsBounds(a: ReadonlyBounds, b: ReadonlyBounds): boolean;
|
|
10
|
+
export declare function boundsIntersect(a: ReadonlyBounds, b: ReadonlyBounds): boolean;
|
|
11
|
+
export declare function unionBounds(a: ReadonlyBounds, b: ReadonlyBounds, out?: Bounds): Bounds;
|
|
12
|
+
export declare function intersectBounds(a: ReadonlyBounds, b: ReadonlyBounds, out?: Bounds): Bounds;
|
|
13
|
+
export declare function expandBoundsByPoint(bounds: ReadonlyBounds, p: ArrayLike<number>, out?: Bounds): Bounds;
|
|
14
|
+
/** Negative padding shrinks bounds; an inverted result becomes canonical empty bounds. */
|
|
15
|
+
export declare function expandBounds(bounds: ReadonlyBounds, padding: number, out?: Bounds): Bounds;
|
|
16
|
+
export declare function clampPointToBounds(bounds: ReadonlyBounds, p: ArrayLike<number>, out?: NumericArray): NumericArray | null;
|
|
17
|
+
export declare function spheresIntersect(a: ArrayLike<number>, ar: number, b: ArrayLike<number>, br: number): boolean;
|
|
18
|
+
export declare function boundsIntersectSphere(bounds: ReadonlyBounds, center: ArrayLike<number>, r: number): boolean;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=bounds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounds.d.ts","sourceRoot":"","sources":["../../src/culling/bounds.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAC,MAAM,eAAe,CAAC;AAE5E,KAAK,cAAc,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;AA4BtE,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,CAAC,GAAG,QAAQ,CAAC;AAC1D,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,CAAC,GAAG,QAAQ,CAAC;AAC1D,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;AAK5D,yFAAyF;AACzF,wBAAgB,aAAa,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAI7D;AACD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,CAKzF;AACD,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,GAAG,OAAO,CAOlF;AACD,wBAAgB,eAAe,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,GAAG,OAAO,CAO7E;AAQD,wBAAgB,WAAW,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAUtF;AACD,wBAAgB,eAAe,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,EAAE,cAAc,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAS1F;AACD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,cAAc,EACtB,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,EACpB,GAAG,CAAC,EAAE,MAAM,GACX,MAAM,CAGR;AACD,0FAA0F;AAC1F,wBAAgB,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAU1F;AACD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,cAAc,EACtB,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,EACpB,GAAG,GAAE,YAAkC,GACtC,YAAY,GAAG,IAAI,CAOrB;AAID,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,EACpB,EAAE,EAAE,MAAM,EACV,CAAC,EAAE,SAAS,CAAC,MAAM,CAAC,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAMT;AACD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,cAAc,EACtB,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,CAAC,EAAE,MAAM,GACR,OAAO,CAIT"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
function dimension(bounds) {
|
|
2
|
+
const n = bounds[0].length;
|
|
3
|
+
if ((n !== 2 && n !== 3) ||
|
|
4
|
+
bounds[1].length !== n ||
|
|
5
|
+
[...Array.from(bounds[0]), ...Array.from(bounds[1])].some(Number.isNaN)) {
|
|
6
|
+
throw new RangeError('Expected 2D or 3D bounds without NaN');
|
|
7
|
+
}
|
|
8
|
+
const empty = Array.from({ length: n }, (_, i) => bounds[0][i] > bounds[1][i]).some(Boolean);
|
|
9
|
+
if (!empty &&
|
|
10
|
+
[...Array.from(bounds[0]), ...Array.from(bounds[1])].some(x => !Number.isFinite(x))) {
|
|
11
|
+
throw new RangeError('Nonempty bounds must be finite');
|
|
12
|
+
}
|
|
13
|
+
return n;
|
|
14
|
+
}
|
|
15
|
+
function pair(a, b) {
|
|
16
|
+
const n = dimension(a);
|
|
17
|
+
if (dimension(b) !== n)
|
|
18
|
+
throw new RangeError('Bounds dimensions must match');
|
|
19
|
+
return n;
|
|
20
|
+
}
|
|
21
|
+
function point(p, n) {
|
|
22
|
+
if (p.length !== n || Array.from(p).some(x => !Number.isFinite(x)))
|
|
23
|
+
throw new RangeError('Expected a finite point of matching dimension');
|
|
24
|
+
}
|
|
25
|
+
export function createEmptyBounds(dimension) {
|
|
26
|
+
if (dimension !== 2 && dimension !== 3)
|
|
27
|
+
throw new RangeError('Expected dimension 2 or 3');
|
|
28
|
+
return [new Array(dimension).fill(Infinity), new Array(dimension).fill(-Infinity)];
|
|
29
|
+
}
|
|
30
|
+
/** Any inverted axis denotes empty bounds. Equal endpoints describe a nonempty point. */
|
|
31
|
+
export function isEmptyBounds(bounds) {
|
|
32
|
+
return Array.from({ length: dimension(bounds) }, (_, i) => bounds[0][i] > bounds[1][i]).some(Boolean);
|
|
33
|
+
}
|
|
34
|
+
export function boundsContainsPoint(bounds, p) {
|
|
35
|
+
point(p, dimension(bounds));
|
|
36
|
+
return (!isEmptyBounds(bounds) && Array.from(p).every((x, i) => x >= bounds[0][i] && x <= bounds[1][i]));
|
|
37
|
+
}
|
|
38
|
+
export function boundsContainsBounds(a, b) {
|
|
39
|
+
const n = pair(a, b);
|
|
40
|
+
return (isEmptyBounds(b) ||
|
|
41
|
+
(!isEmptyBounds(a) &&
|
|
42
|
+
Array.from({ length: n }, (_, i) => a[0][i] <= b[0][i] && a[1][i] >= b[1][i]).every(Boolean)));
|
|
43
|
+
}
|
|
44
|
+
export function boundsIntersect(a, b) {
|
|
45
|
+
const n = pair(a, b);
|
|
46
|
+
return (!isEmptyBounds(a) &&
|
|
47
|
+
!isEmptyBounds(b) &&
|
|
48
|
+
Array.from({ length: n }, (_, i) => a[0][i] <= b[1][i] && b[0][i] <= a[1][i]).every(Boolean));
|
|
49
|
+
}
|
|
50
|
+
function store(values, out = createEmptyBounds(values[0].length)) {
|
|
51
|
+
if (out[0].length !== values[0].length || out[1].length !== values[0].length) {
|
|
52
|
+
throw new RangeError('Output bounds dimensions must match');
|
|
53
|
+
}
|
|
54
|
+
for (let j = 0; j < 2; j++)
|
|
55
|
+
for (let i = 0; i < values[j].length; i++)
|
|
56
|
+
out[j][i] = values[j][i];
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
export function unionBounds(a, b, out) {
|
|
60
|
+
const n = pair(a, b);
|
|
61
|
+
const values = createEmptyBounds(n);
|
|
62
|
+
const ea = isEmptyBounds(a), eb = isEmptyBounds(b);
|
|
63
|
+
for (let i = 0; i < n; i++) {
|
|
64
|
+
values[0][i] = Math.min(ea ? Infinity : a[0][i], eb ? Infinity : b[0][i]);
|
|
65
|
+
values[1][i] = Math.max(ea ? -Infinity : a[1][i], eb ? -Infinity : b[1][i]);
|
|
66
|
+
}
|
|
67
|
+
return store(values, out);
|
|
68
|
+
}
|
|
69
|
+
export function intersectBounds(a, b, out) {
|
|
70
|
+
const n = pair(a, b), values = createEmptyBounds(n);
|
|
71
|
+
if (boundsIntersect(a, b))
|
|
72
|
+
for (let i = 0; i < n; i++) {
|
|
73
|
+
values[0][i] = Math.max(a[0][i], b[0][i]);
|
|
74
|
+
values[1][i] = Math.min(a[1][i], b[1][i]);
|
|
75
|
+
}
|
|
76
|
+
return store(values, out);
|
|
77
|
+
}
|
|
78
|
+
export function expandBoundsByPoint(bounds, p, out) {
|
|
79
|
+
point(p, dimension(bounds));
|
|
80
|
+
return unionBounds(bounds, [p, p], out);
|
|
81
|
+
}
|
|
82
|
+
/** Negative padding shrinks bounds; an inverted result becomes canonical empty bounds. */
|
|
83
|
+
export function expandBounds(bounds, padding, out) {
|
|
84
|
+
if (!Number.isFinite(padding))
|
|
85
|
+
throw new RangeError('Padding must be finite');
|
|
86
|
+
const n = dimension(bounds), values = createEmptyBounds(n);
|
|
87
|
+
if (!isEmptyBounds(bounds))
|
|
88
|
+
for (let i = 0; i < n; i++) {
|
|
89
|
+
values[0][i] = bounds[0][i] - padding;
|
|
90
|
+
values[1][i] = bounds[1][i] + padding;
|
|
91
|
+
}
|
|
92
|
+
return store(isEmptyBounds(values) ? createEmptyBounds(n) : values, out);
|
|
93
|
+
}
|
|
94
|
+
export function clampPointToBounds(bounds, p, out = new Array(p.length)) {
|
|
95
|
+
point(p, dimension(bounds));
|
|
96
|
+
if (out.length < p.length)
|
|
97
|
+
throw new RangeError('Result buffer is too short');
|
|
98
|
+
if (isEmptyBounds(bounds))
|
|
99
|
+
return null;
|
|
100
|
+
const result = Array.from(p, (x, i) => Math.max(bounds[0][i], Math.min(bounds[1][i], x)));
|
|
101
|
+
for (let i = 0; i < result.length; i++)
|
|
102
|
+
out[i] = result[i];
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
function radius(r) {
|
|
106
|
+
if (!Number.isFinite(r) || r < 0)
|
|
107
|
+
throw new RangeError('Radius must be finite and nonnegative');
|
|
108
|
+
}
|
|
109
|
+
export function spheresIntersect(a, ar, b, br) {
|
|
110
|
+
point(a, 3);
|
|
111
|
+
point(b, 3);
|
|
112
|
+
radius(ar);
|
|
113
|
+
radius(br);
|
|
114
|
+
return Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]) <= ar + br;
|
|
115
|
+
}
|
|
116
|
+
export function boundsIntersectSphere(bounds, center, r) {
|
|
117
|
+
radius(r);
|
|
118
|
+
const closest = clampPointToBounds(bounds, center);
|
|
119
|
+
return closest !== null && Math.hypot(...Array.from(center, (x, i) => x - closest[i])) <= r;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=bounds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bounds.js","sourceRoot":"","sources":["../../src/culling/bounds.ts"],"names":[],"mappings":"AAM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,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC;AACtE,CAAC;AACD,MAAM,UAAU,qBAAqB,CACnC,MAAsB,EACtB,MAAyB,EACzB,CAAS;IAET,MAAM,CAAC,CAAC,CAAC,CAAC;IACV,MAAM,OAAO,GAAG,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnD,OAAO,OAAO,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ProjectionDepthOptions } from '@math.gl/core';
|
|
2
|
+
import { Plane } from "./lib/plane.js";
|
|
3
|
+
/** Inward planes: left, right, bottom, top, near, far. An infinite far plane is omitted. */
|
|
4
|
+
export declare function extractFrustumPlanes(matrix: ArrayLike<number>, options?: ProjectionDepthOptions): Plane[];
|
|
5
|
+
//# sourceMappingURL=frustum-planes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frustum-planes.d.ts","sourceRoot":"","sources":["../../src/culling/frustum-planes.ts"],"names":[],"mappings":"AAGA,OAAO,EAA0B,KAAK,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACnF,OAAO,EAAC,KAAK,EAAC,uBAAoB;AAElC,4FAA4F;AAC5F,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,EACzB,OAAO,GAAE,sBAA2B,GACnC,KAAK,EAAE,CA8BT"}
|