@math.gl/core/types
@math.gl/core provides shared numeric array, bounds, and spheroid types, plus runtime array checks and Float16 support detection.
Usageโ
Use import type for declarations that add no runtime code:
import type {NumericArray, NumberArray3, Bounds3D} from '@math.gl/core/types';
NumberArray covers JavaScript number arrays; NumericArray also includes numeric typed arrays. Sized variants describe fixed component counts. See array types and bounds for the contracts and runtime helpers.
Featuresโ
| Feature | Support | Notes |
|---|---|---|
| Number and typed-array declarations | โ | NumericArray, TypedArray and constructor types, with BigInt typed arrays represented separately. |
| Fixed-component array types | โ | Sized NumberArray/NumericArray variants cover commonly used vector, matrix, and bounds lengths. |
| Runtime representation guards | โ | Array and typed-array guards include intrinsic, cross-realm Uint16 and Float16 checks. |
| Half-float storage capability detection | โ | Native Float16Array detection and constructor selection; the Uint16 fallback stores encoded bits rather than decoded numeric values. |
| Bounds and spheroid contracts | โ | Bounds2D/3D and SpheroidParameters describe geometry independently of renderers and CRS engines. |
| Runtime enforcement of sized declarations | โ | Type declarations do not validate buffer length, coordinate units, or physical meaning at runtime. |
| Bundled Float16 arithmetic polyfill | โ | The helpers select/detect storage. They do not supply numeric half-float array semantics when the runtime lacks them. |
Installationโ
npm install @math.gl/core
SpheroidParametersโ
A type-only geometry contract with semiMajorAxis and semiMinorAxis in metres.
Both axes must be finite and positive, with semiMinorAxis <= semiMajorAxis.
Equal axes describe a sphere. It contains no datum, axis order, coordinate units
or epoch metadata. The type is also exported by core, geospatial and projection.
Use Ellipsoid.fromSpheroid and toSpheroid
to exchange this geometry with the geospatial class. The type adds no runtime code.