A three.js plugin for Mapbox GL JS, with support for basic animation and advanced 3D rendering.
Add it to your project via npm
:
npm install threebox
Set up and handle the core translations between a Three.js scene graph and the Mapbox GL JS map.
Instantiates a threebox canvas atop the Mapbox GL JS canvas object in map
. Automatically sets up a new canvas DOM element for Three.js and synchronizes the camera movement and events between Three.js and Mapbox GL JS.
Set up some default lights. If you don't call this and don't set up your own lights, all objects added to the scene will appear black.
Manually add a Three.js Object3D
to your map.
object
- any Three.jsObject3D
to add to the mapposition
- Anarray
containing [longitude
,latitude
,altitude
] specifying where the object will be added. Thealtitude
is in meters.
Remove an object from the map.
Given an input of lnglatalt
as an array
of geographic [longitude
, latitude
, altitude
], return a Three.js Vector3
representing the corresponding point in the scenegraph coordinate system.
Given an input of point
as a Three.js Vector3
representing a point in the scenegraph coordinate system, return an array
of the corresponding [longitude
, latitude
, altitude
] in geographic space.
npm run build