Camera helper for WebGL custom layers on top of mapbox-gl-js.
WIP, check Issues
npm install mapbox-gl-camera
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();
}
});
});
Using regl
source: examples/regl.js
MAPBOX_TOKEN=your_mapbox_access_token npm run watch
- mapbox/mapbox-gl-js#7395
- mapbox/mapbox-gl-js#7268
- https://github.com/peterqliu/threebox
MIT License