Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thin-bears-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-three-map": patch
---

Support maplibre@v5
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ import { Canvas } from "react-three-map/maplibre"

function BasicExample() {
return <Map
antialias
canvasContextAttributes={{
antialias: true,
}}
initialViewState={{
latitude: 51,
longitude: 0,
Expand Down
2 changes: 1 addition & 1 deletion example-mapbox/src/canvas.basic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useControls } from "leva";
import Mapbox from "mapbox-gl";
import 'mapbox-gl/dist/mapbox-gl.css';
import { FC, PropsWithChildren, useRef, useState } from "react";
import Map from 'react-map-gl';
import Map from 'react-map-gl/mapbox';
import { Canvas } from "react-three-map";
import { Mesh } from "three";

Expand Down
2 changes: 1 addition & 1 deletion example-mapbox/src/story-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useControls } from 'leva';
import Mapbox from "mapbox-gl";
import 'mapbox-gl/dist/mapbox-gl.css';
import { FC, PropsWithChildren } from "react";
import Map from 'react-map-gl';
import Map from 'react-map-gl/mapbox';

export interface StoryMapProps extends PropsWithChildren {
latitude: number,
Expand Down
2 changes: 1 addition & 1 deletion example-maplibre/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@react-three/drei": "^9.77.10",
"@react-three/fiber": "^8.13.4",
"leva": "^0.9.35",
"maplibre-gl": "^4.7.1",
"maplibre-gl": "^5.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-map-gl": "8.0.1",
Expand Down
4 changes: 3 additions & 1 deletion example-maplibre/src/canvas.basic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ export default { title: 'Canvas' }
export function BasicExample() {
return <div style={{ height: '100vh' }}>
<Map
antialias
canvasContextAttributes={{
antialias: true,
}}
initialViewState={{
latitude: 51,
longitude: 0,
Expand Down
4 changes: 3 additions & 1 deletion example-maplibre/src/story-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export const StoryMap: FC<StoryMapProps> = ({

return <div style={{ height: '100vh', position: 'relative' }}>
<Map
antialias
canvasContextAttributes={{
antialias: true,
}}
initialViewState={{
latitude,
longitude,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"leva": "^0.9.35",
"luxon": "^3.3.0",
"mapbox-gl": "^3.9.4",
"maplibre-gl": "4.7.1",
"maplibre-gl": "^5.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-map-gl": "^8.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/core/canvas-in-layer/use-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function useRender({
const state = useThree.getState();
const camera = state.camera as PerspectiveCamera;
const {gl, advance} = state;
syncCamera(camera as PerspectiveCamera, origin, projViewMx as Matrix4Tuple);
syncCamera(camera as PerspectiveCamera, origin, pVMx as Matrix4Tuple);
gl.resetState();
advance(Date.now() * 0.001, true);
if (!frameloop || frameloop === 'always') map.triggerRepaint();
Expand Down
5 changes: 3 additions & 2 deletions src/core/canvas-overlay/sync-camera-fc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const SyncCameraFC = memo<SyncCameraFCProps>(({
}
}, -Infinity)

const onRender = useFunction((viewProjMx: Matrix4Tuple) => {
const onRender = useFunction((viewProjMx: Matrix4Tuple | {defaultProjectionData: {mainMatrix: Record<string, number>}}) => {
map.triggerRepaint = triggerRepaintOff;

if (threeCanvas.width !== mapCanvas.width || threeCanvas.height !== mapCanvas.height) {
Expand All @@ -70,7 +70,8 @@ export const SyncCameraFC = memo<SyncCameraFCProps>(({
);
}

r3m.viewProjMx = viewProjMx;
const pVMx = 'defaultProjectionData' in viewProjMx ? Object.values(viewProjMx.defaultProjectionData.mainMatrix) : viewProjMx;
r3m.viewProjMx = pVMx as Matrix4Tuple;
if (!ready.current && onReady) {
ready.current = true;
onReady();
Expand Down
2 changes: 1 addition & 1 deletion stories/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"leva": "^0.9.35",
"luxon": "^3.4.4",
"mapbox-gl": "^3.9.4",
"maplibre-gl": "^4.7.1",
"maplibre-gl": "^5.4.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-map-gl": "^8.0.1",
Expand Down
4 changes: 3 additions & 1 deletion stories/src/canvas/maplibre.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export function Maplibre() {
<Leva theme={{ sizes: { rootWidth: '340px', controlWidth: '150px' } }} />
<div style={{ height: '100vh' }}>
<Map
antialias
canvasContextAttributes={{
antialias: true,
}}
initialViewState={{
latitude: 51,
longitude: 0,
Expand Down
4 changes: 3 additions & 1 deletion stories/src/maplibre/story-maplibre.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export const StoryMaplibre: FC<Omit<StoryMapProps, 'mapboxChildren'>> = ({

return <div style={{ height: '100vh', position: 'relative' }}>
<Map
antialias
canvasContextAttributes={{
antialias: true,
}}
mapLib={MapLibre}
initialViewState={{ latitude, longitude, ...rest }}
maxPitch={rest.pitch ? Math.min(rest.pitch, 85) : undefined}
Expand Down
33 changes: 14 additions & 19 deletions stories/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -821,16 +821,16 @@
rw "^1.3.3"
sort-object "^3.0.3"

"@maplibre/maplibre-gl-style-spec@^20.3.1":
version "20.4.0"
resolved "https://registry.yarnpkg.com/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-20.4.0.tgz#408339e051fb51e022b40af2235e0beb037937ea"
integrity sha512-AzBy3095fTFPjDjmWpR2w6HVRAZJ6hQZUCwk5Plz6EyfnfuQW1odeW5i2Ai47Y6TBA2hQnC+azscjBSALpaWgw==
"@maplibre/maplibre-gl-style-spec@^23.1.0":
version "23.2.0"
resolved "https://registry.yarnpkg.com/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-23.2.0.tgz#f746e0bf4292664b0bc1e1af672700511e3bb634"
integrity sha512-o53j6v4Zhezk9GhA1h+iBVCRaE3aij4GBxZY2OoWZuaicxWuXS4i80qYKXggpIDkzGsiiMZHg6Wp4gz+CcD4Yw==
dependencies:
"@mapbox/jsonlint-lines-primitives" "~2.0.2"
"@mapbox/unitbezier" "^0.0.1"
json-stringify-pretty-compact "^4.0.0"
minimist "^1.2.8"
quickselect "^2.0.0"
quickselect "^3.0.0"
rw "^1.3.3"
tinyqueue "^3.0.0"

Expand Down Expand Up @@ -1452,7 +1452,7 @@
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.10.tgz#6dfbf5ea17142f7f9a043809f1cd4c448cb68249"
integrity sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==

"@types/geojson@^7946.0.14", "@types/geojson@^7946.0.15":
"@types/geojson@^7946.0.15", "@types/geojson@^7946.0.16":
version "7946.0.16"
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.16.tgz#8ebe53d69efada7044454e3305c19017d97ced2a"
integrity sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==
Expand Down Expand Up @@ -2252,7 +2252,7 @@ draco3d@^1.4.1:
resolved "https://registry.yarnpkg.com/draco3d/-/draco3d-1.5.6.tgz#0d570a9792e3a3a9fafbfea065b692940441c626"
integrity sha512-+3NaRjWktb5r61ZFoDejlykPEFKT5N/LkbXsaddlw6xNSXBanUYpFc2AXXpbJDilPHazcSreU/DpQIaxfX0NfQ==

earcut@^3.0.0:
earcut@^3.0.0, earcut@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/earcut/-/earcut-3.0.1.tgz#f60b3f671c5657cca9d3e131c5527c5dde00ef38"
integrity sha512-0l1/0gOjESMeQyYaK5IDiPNvFeu93Z/cO0TjZh9eZ1vyCtZnA7KMZ8rQggpsJHIbGSdrqYq9OhuveadOVHCshw==
Expand Down Expand Up @@ -3218,10 +3218,10 @@ mapbox-gl@^3.9.4:
tinyqueue "^3.0.0"
vt-pbf "^3.1.3"

maplibre-gl@^4.7.1:
version "4.7.1"
resolved "https://registry.yarnpkg.com/maplibre-gl/-/maplibre-gl-4.7.1.tgz#06a524438ee2aafbe8bcd91002a4e01468ea5486"
integrity sha512-lgL7XpIwsgICiL82ITplfS7IGwrB1OJIw/pCvprDp2dhmSSEBgmPzYRvwYYYvJGJD7fxUv1Tvpih4nZ6VrLuaA==
maplibre-gl@^5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/maplibre-gl/-/maplibre-gl-5.4.0.tgz#1cff5776838b981636d8c1a182034e76e98707ff"
integrity sha512-ZVrtdFIhFAqt53H2k5Ssqn7QIKNI19fW+He5tr4loxZxWZffp1aZYY9ImNncAJaALU/NYlV6Eul7UVB56/N7WQ==
dependencies:
"@mapbox/geojson-rewind" "^0.5.2"
"@mapbox/jsonlint-lines-primitives" "^2.0.2"
Expand All @@ -3230,14 +3230,14 @@ maplibre-gl@^4.7.1:
"@mapbox/unitbezier" "^0.0.1"
"@mapbox/vector-tile" "^1.3.1"
"@mapbox/whoots-js" "^3.1.0"
"@maplibre/maplibre-gl-style-spec" "^20.3.1"
"@types/geojson" "^7946.0.14"
"@maplibre/maplibre-gl-style-spec" "^23.1.0"
"@types/geojson" "^7946.0.16"
"@types/geojson-vt" "3.2.5"
"@types/mapbox__point-geometry" "^0.1.4"
"@types/mapbox__vector-tile" "^1.3.4"
"@types/pbf" "^3.0.5"
"@types/supercluster" "^7.1.3"
earcut "^3.0.0"
earcut "^3.0.1"
geojson-vt "^4.0.2"
gl-matrix "^3.4.3"
global-prefix "^4.0.0"
Expand Down Expand Up @@ -4196,11 +4196,6 @@ queue-microtask@^1.2.2:
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==

quickselect@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-2.0.0.tgz#f19680a486a5eefb581303e023e98faaf25dd018"
integrity sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==

quickselect@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-3.0.0.tgz#a37fc953867d56f095a20ac71c6d27063d2de603"
Expand Down
33 changes: 14 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1160,16 +1160,16 @@
rw "^1.3.3"
sort-object "^3.0.3"

"@maplibre/maplibre-gl-style-spec@^20.3.1":
version "20.4.0"
resolved "https://registry.yarnpkg.com/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-20.4.0.tgz#408339e051fb51e022b40af2235e0beb037937ea"
integrity sha512-AzBy3095fTFPjDjmWpR2w6HVRAZJ6hQZUCwk5Plz6EyfnfuQW1odeW5i2Ai47Y6TBA2hQnC+azscjBSALpaWgw==
"@maplibre/maplibre-gl-style-spec@^23.1.0":
version "23.2.0"
resolved "https://registry.yarnpkg.com/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-23.2.0.tgz#f746e0bf4292664b0bc1e1af672700511e3bb634"
integrity sha512-o53j6v4Zhezk9GhA1h+iBVCRaE3aij4GBxZY2OoWZuaicxWuXS4i80qYKXggpIDkzGsiiMZHg6Wp4gz+CcD4Yw==
dependencies:
"@mapbox/jsonlint-lines-primitives" "~2.0.2"
"@mapbox/unitbezier" "^0.0.1"
json-stringify-pretty-compact "^4.0.0"
minimist "^1.2.8"
quickselect "^2.0.0"
quickselect "^3.0.0"
rw "^1.3.3"
tinyqueue "^3.0.0"

Expand Down Expand Up @@ -1808,7 +1808,7 @@
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.10.tgz#6dfbf5ea17142f7f9a043809f1cd4c448cb68249"
integrity sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==

"@types/geojson@^7946.0.14", "@types/geojson@^7946.0.15":
"@types/geojson@^7946.0.15", "@types/geojson@^7946.0.16":
version "7946.0.16"
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.16.tgz#8ebe53d69efada7044454e3305c19017d97ced2a"
integrity sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==
Expand Down Expand Up @@ -3066,7 +3066,7 @@ draco3d@^1.4.1:
resolved "https://registry.yarnpkg.com/draco3d/-/draco3d-1.5.6.tgz#0d570a9792e3a3a9fafbfea065b692940441c626"
integrity sha512-+3NaRjWktb5r61ZFoDejlykPEFKT5N/LkbXsaddlw6xNSXBanUYpFc2AXXpbJDilPHazcSreU/DpQIaxfX0NfQ==

earcut@^3.0.0:
earcut@^3.0.0, earcut@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/earcut/-/earcut-3.0.1.tgz#f60b3f671c5657cca9d3e131c5527c5dde00ef38"
integrity sha512-0l1/0gOjESMeQyYaK5IDiPNvFeu93Z/cO0TjZh9eZ1vyCtZnA7KMZ8rQggpsJHIbGSdrqYq9OhuveadOVHCshw==
Expand Down Expand Up @@ -4833,10 +4833,10 @@ mapbox-gl@^3.9.4:
tinyqueue "^3.0.0"
vt-pbf "^3.1.3"

maplibre-gl@4.7.1:
version "4.7.1"
resolved "https://registry.yarnpkg.com/maplibre-gl/-/maplibre-gl-4.7.1.tgz#06a524438ee2aafbe8bcd91002a4e01468ea5486"
integrity sha512-lgL7XpIwsgICiL82ITplfS7IGwrB1OJIw/pCvprDp2dhmSSEBgmPzYRvwYYYvJGJD7fxUv1Tvpih4nZ6VrLuaA==
maplibre-gl@^5.4.0:
version "5.4.0"
resolved "https://registry.yarnpkg.com/maplibre-gl/-/maplibre-gl-5.4.0.tgz#1cff5776838b981636d8c1a182034e76e98707ff"
integrity sha512-ZVrtdFIhFAqt53H2k5Ssqn7QIKNI19fW+He5tr4loxZxWZffp1aZYY9ImNncAJaALU/NYlV6Eul7UVB56/N7WQ==
dependencies:
"@mapbox/geojson-rewind" "^0.5.2"
"@mapbox/jsonlint-lines-primitives" "^2.0.2"
Expand All @@ -4845,14 +4845,14 @@ maplibre-gl@4.7.1:
"@mapbox/unitbezier" "^0.0.1"
"@mapbox/vector-tile" "^1.3.1"
"@mapbox/whoots-js" "^3.1.0"
"@maplibre/maplibre-gl-style-spec" "^20.3.1"
"@types/geojson" "^7946.0.14"
"@maplibre/maplibre-gl-style-spec" "^23.1.0"
"@types/geojson" "^7946.0.16"
"@types/geojson-vt" "3.2.5"
"@types/mapbox__point-geometry" "^0.1.4"
"@types/mapbox__vector-tile" "^1.3.4"
"@types/pbf" "^3.0.5"
"@types/supercluster" "^7.1.3"
earcut "^3.0.0"
earcut "^3.0.1"
geojson-vt "^4.0.2"
gl-matrix "^3.4.3"
global-prefix "^4.0.0"
Expand Down Expand Up @@ -6106,11 +6106,6 @@ quick-lru@^4.0.1:
resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f"
integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==

quickselect@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-2.0.0.tgz#f19680a486a5eefb581303e023e98faaf25dd018"
integrity sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==

quickselect@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-3.0.0.tgz#a37fc953867d56f095a20ac71c6d27063d2de603"
Expand Down