Constimport "mapbox-gl/dist/mapbox-gl.css";
import Map from "react-map-gl/mapbox";
import { Canvas } from "@wendylabsinc/react-three-map";
function App() {
return (
<Map
mapboxAccessToken="YOUR_TOKEN"
initialViewState={{
latitude: 40.7128,
longitude: -74.006,
zoom: 15,
pitch: 60
}}
mapStyle="mapbox://styles/mapbox/dark-v11"
>
<Canvas latitude={40.7128} longitude={-74.006}>
<ambientLight intensity={0.5} />
<mesh>
<boxGeometry args={[100, 100, 100]} />
<meshStandardMaterial color="hotpink" />
</mesh>
</Canvas>
</Map>
);
}
A React Three Fiber canvas that renders inside a Mapbox map.
This component bridges
@react-three/fiberwithreact-map-gl(Mapbox variant), allowing you to render Three.js scenes at geographic coordinates on the map.Must be used as a child of a
Mapcomponent fromreact-map-gl/mapbox.