Skip to main content

Introduction

Welcome to math.gl! math.gl is JavaScript (TypeScript) math library focused on geospatial and 3D use cases. Designed as a composable, modular toolbox. math.gl provides a core module with classic vector and matrix classes, and a suite of optional modules implementing various aspects of geospatial and 3D math.

While math.gl is highly optimized for use with the WebGL and WebGPU APIs, it has no WebGL dependencies and is designed to be usable in any application.

Features

  • 3D math - Basic vectors and matrices, as well as 3D primitives and culling: @math.gl/types, @math.gl/core, @math.gl/culling
  • Geospatial projections - Support for a variety of geospatial projections @math.gl/geospatial, @math.gl/geoid, @math.gl/proj4, @math.gl/web-mercator
  • Geospatial utilities - Cutting polygons and calculating sun position and direction @math.gl/polygon, @math.gl/sun
  • Discrete Global Grids - Standardized interfaces to a number of the major discrete global grids. @math.gl/dggs-geohash, @math.gl/dggs-quadkey, @math.gl/dggs-s2

Modules

math.gl is a toolbox that offers a suite of composable modules.

Core math librariesModule Description
@math.gl/typesBasic math type helpers (NumericArray etc)
core@math.gl/core3D math classes (vectors, matrices, etc)
culling@math.gl/cullingBounding volumes and intersection testing.
Geospatial math librariesModule Description
geospatial@math.gl/geospatialEllipsoidal math for WGS84 coordinates.
geoid@math.gl/geoidEarth Gravity Model support .
@math.gl/polygonPolygon math, including geospatial cutting etc.
@math.gl/proj4Conversion between coordinate reference systems.
@math.gl/sunSolar position / direction from position and time.
@math.gl/web-mercatorSupports 3D Web Mercator (spherical) projections.
DGGS (Discrete global grid support) librariesModule Description
geohash@math.gl/dggs-geohashGet geometry of GeoHash tokens.
quadkey@math.gl/dggs-quadkeyGet geometry of QuadKey tokens
s2@math.gl/dggs-s2Get geometry of S2 tokens.

In addition, math.gl provides a few deprecated legacy modules, to avoid breaking older applications.

Legacy ModuleDescription
math.glRe-exports the API from @math.gl/core. An "alias" for @math.gl/core to avoid breaking old applications.
viewport-mercator-projectRe-exports the Web Mercator projection utilities in @math.gl/web-mercator. The viewport-mercator-project repository was moved to math.gl in Oct 2019.

Supported Browsers and Node Versions

math.gl is fully supported on:

  • Evergreen browsers: Recent versions of Chrome, Safari, Firefox, Edge etc.
  • Node.js: Active and Maintenance LTS releases

History

YearVersionDescription
2015N/A@math.gl/core classes were created as part of luma.gl v4, as a set of class wrappers for gl-matrix for luma.gl and deck.gl frameworks.
2017v1.0math.gl was broken out into its own repository to manage luma.gl growth. The goal was to independently usable set of 3D and Geospatial math modules.
2018v2.0The math.gl API started to mature.
2019v3.0A collaboration with the Cesium team around 3D Tiles led to parts of the Cesium math library were ported into the math.gl/geospatial and @math.gl/culling modules.
2020+v3.xAdditional geospatial modules have gradually been added to support more advanced use cases for deck.gl.
2022v3.6Code base fully rewritten in TypeScript.
2023v4.0ES module support. gl-matrix was removed as a dependency and math.gl became fully stand-alone.

Attributions

math.gl was inspired by and built upon some of the most proven open source JavaScript math libraries:

  • gl-matrix - math.gl classes use gl-matrix under the hood
  • THREE.js math library - math.gl classes are API-compatible with a subset of the THREE.js classes and pass THREE.js test suites.
  • The CesiumJS math library (Apache2) - The geospatial and culling modules were ported from Cesium code base.

License

MIT license. The libraries that the core @math.gl/core module are built on (e.g. gl-matrix) are also all open source and MIT licensed.

The @math.gl/geospatial and @math.gl/culling modules include Cesium-derived code which is Apache2 licensed.

math.gl will never include any code that is not under permissive license.