mapbox-gl-camera

1.0.4 • Public • Published

mapbox-gl-camera

Camera helper for WebGL custom layers on top of mapbox-gl-js.

WIP, check Issues

Installation

npm install mapbox-gl-camera

Usage

import { Camera } from 'mapbox-gl-camera';

const camera = new Camera();

// ...

mapInstance.on('style.load', () => {
  mapInstance.addLayer({
    id: 'custom_layer',
    type: 'custom',
    onAdd: function (map, gl) {
      // ...
    },
    render: function (gl, matrix) {
      camera.update(mapInstance, matrix);

      camera.view;            // <-- view matrix
      camera.projection;      // <-- projection matrix
      camera.viewProjection;  // <-- projection*view matrix
      camera.world;           // <-- world matrix

      camera.positionFromLngLatAlt([13.418314, 52.49871, 10]) // calculates world position from LngLatAlt coordinates

      mapInstance.triggerRepaint();
    }
  });
});

Example

Using regl

examples/example-regl.gif

source: examples/regl.js

Building the example

MAPBOX_TOKEN=your_mapbox_access_token npm run watch

References

MIT License

Readme

Keywords

Package Sidebar

Install

npm i mapbox-gl-camera

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

1.84 MB

Total Files

11

Last publish

Collaborators

  • dawidgorny