react-three-map 0.7.2 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +57 -4
- package/dist/cjs/main.js +386 -181
- package/dist/es/main.mjs +9 -3
- package/dist/es/main.mjs.map +1 -1
- package/dist/es/main10.mjs +8 -20
- package/dist/es/main10.mjs.map +1 -1
- package/dist/es/main11.mjs +33 -19
- package/dist/es/main11.mjs.map +1 -1
- package/dist/es/main12.mjs +11 -87
- package/dist/es/main12.mjs.map +1 -1
- package/dist/es/main13.mjs +23 -9
- package/dist/es/main13.mjs.map +1 -1
- package/dist/es/main14.mjs +2 -68
- package/dist/es/main14.mjs.map +1 -1
- package/dist/es/main15.mjs +33 -0
- package/dist/es/main15.mjs.map +1 -0
- package/dist/es/main16.mjs +26 -0
- package/dist/es/main16.mjs.map +1 -0
- package/dist/es/main17.mjs +98 -0
- package/dist/es/main17.mjs.map +1 -0
- package/dist/es/main18.mjs +66 -0
- package/dist/es/main18.mjs.map +1 -0
- package/dist/es/main19.mjs +23 -0
- package/dist/es/main19.mjs.map +1 -0
- package/dist/es/main2.mjs.map +1 -1
- package/dist/es/main20.mjs +27 -0
- package/dist/es/main20.mjs.map +1 -0
- package/dist/es/main21.mjs +19 -0
- package/dist/es/main21.mjs.map +1 -0
- package/dist/es/main22.mjs +83 -0
- package/dist/es/main22.mjs.map +1 -0
- package/dist/es/main3.mjs +43 -50
- package/dist/es/main3.mjs.map +1 -1
- package/dist/es/main4.mjs +50 -24
- package/dist/es/main4.mjs.map +1 -1
- package/dist/es/main5.mjs +12 -3
- package/dist/es/main5.mjs.map +1 -1
- package/dist/es/main6.mjs +19 -34
- package/dist/es/main6.mjs.map +1 -1
- package/dist/es/main7.mjs +10 -11
- package/dist/es/main7.mjs.map +1 -1
- package/dist/es/main8.mjs +17 -16
- package/dist/es/main8.mjs.map +1 -1
- package/dist/es/main9.mjs +27 -15
- package/dist/es/main9.mjs.map +1 -1
- package/dist/maplibre/cjs/main.js +386 -181
- package/dist/maplibre/es/main.mjs +9 -3
- package/dist/maplibre/es/main.mjs.map +1 -1
- package/dist/maplibre/es/main10.mjs +9 -20
- package/dist/maplibre/es/main10.mjs.map +1 -1
- package/dist/maplibre/es/main11.mjs +33 -14
- package/dist/maplibre/es/main11.mjs.map +1 -1
- package/dist/maplibre/es/main12.mjs +11 -87
- package/dist/maplibre/es/main12.mjs.map +1 -1
- package/dist/maplibre/es/main13.mjs +23 -9
- package/dist/maplibre/es/main13.mjs.map +1 -1
- package/dist/maplibre/es/main14.mjs +2 -68
- package/dist/maplibre/es/main14.mjs.map +1 -1
- package/dist/maplibre/es/main15.mjs +33 -0
- package/dist/maplibre/es/main15.mjs.map +1 -0
- package/dist/maplibre/es/main16.mjs +26 -0
- package/dist/maplibre/es/main16.mjs.map +1 -0
- package/dist/maplibre/es/main17.mjs +98 -0
- package/dist/maplibre/es/main17.mjs.map +1 -0
- package/dist/maplibre/es/main18.mjs +66 -0
- package/dist/maplibre/es/main18.mjs.map +1 -0
- package/dist/maplibre/es/main19.mjs +23 -0
- package/dist/maplibre/es/main19.mjs.map +1 -0
- package/dist/maplibre/es/main2.mjs.map +1 -1
- package/dist/maplibre/es/main20.mjs +27 -0
- package/dist/maplibre/es/main20.mjs.map +1 -0
- package/dist/maplibre/es/main21.mjs +19 -0
- package/dist/maplibre/es/main21.mjs.map +1 -0
- package/dist/maplibre/es/main22.mjs +83 -0
- package/dist/maplibre/es/main22.mjs.map +1 -0
- package/dist/maplibre/es/main3.mjs +43 -50
- package/dist/maplibre/es/main3.mjs.map +1 -1
- package/dist/maplibre/es/main4.mjs +50 -24
- package/dist/maplibre/es/main4.mjs.map +1 -1
- package/dist/maplibre/es/main5.mjs +12 -3
- package/dist/maplibre/es/main5.mjs.map +1 -1
- package/dist/maplibre/es/main6.mjs +19 -34
- package/dist/maplibre/es/main6.mjs.map +1 -1
- package/dist/maplibre/es/main7.mjs +10 -11
- package/dist/maplibre/es/main7.mjs.map +1 -1
- package/dist/maplibre/es/main8.mjs +17 -16
- package/dist/maplibre/es/main8.mjs.map +1 -1
- package/dist/maplibre/es/main9.mjs +25 -19
- package/dist/maplibre/es/main9.mjs.map +1 -1
- package/dist/maplibre/types/api/canvas-props.d.ts +4 -4
- package/dist/maplibre/types/api/coords-to-vector-3.d.ts +3 -0
- package/dist/maplibre/types/api/coords.d.ts +5 -0
- package/dist/maplibre/types/api/index.d.ts +6 -0
- package/dist/maplibre/types/api/near-coordinates.d.ts +3 -0
- package/dist/maplibre/types/api/use-map.d.ts +1 -1
- package/dist/maplibre/types/api/vector-3-to-coords.d.ts +3 -0
- package/dist/maplibre/types/core/canvas-in-layer/use-canvas-in-layer.d.ts +11 -0
- package/dist/maplibre/types/core/canvas-in-layer/use-render.d.ts +12 -0
- package/dist/maplibre/types/core/canvas-in-layer/use-root.d.ts +7 -0
- package/dist/maplibre/types/core/canvas-overlay/canvas-portal.d.ts +11 -0
- package/dist/maplibre/types/core/canvas-overlay/init-canvas-fc.d.ts +12 -0
- package/dist/maplibre/types/core/canvas-overlay/init-r3m.d.ts +10 -0
- package/dist/maplibre/types/core/canvas-overlay/render.d.ts +1 -0
- package/dist/maplibre/types/core/canvas-overlay/sync-camera-fc.d.ts +14 -0
- package/dist/maplibre/types/core/coords-to-matrix.d.ts +2 -4
- package/dist/maplibre/types/core/earth-radius.d.ts +1 -0
- package/dist/maplibre/types/core/events.d.ts +4 -0
- package/dist/maplibre/types/core/use-coords-to-matrix.d.ts +5 -0
- package/dist/maplibre/types/core/use-coords.d.ts +7 -5
- package/dist/maplibre/types/core/use-r3m.d.ts +22 -0
- package/dist/maplibre/types/{maplibre → mapbox}/canvas.d.ts +1 -1
- package/dist/maplibre/types/maplibre.index.d.ts +3 -4
- package/dist/types/api/canvas-props.d.ts +4 -4
- package/dist/types/api/coords-to-vector-3.d.ts +3 -0
- package/dist/types/api/coords.d.ts +5 -0
- package/dist/types/api/index.d.ts +6 -0
- package/dist/types/api/near-coordinates.d.ts +3 -0
- package/dist/types/api/use-map.d.ts +1 -1
- package/dist/types/api/vector-3-to-coords.d.ts +3 -0
- package/dist/types/core/canvas-in-layer/use-canvas-in-layer.d.ts +11 -0
- package/dist/types/core/canvas-in-layer/use-render.d.ts +12 -0
- package/dist/types/core/canvas-in-layer/use-root.d.ts +7 -0
- package/dist/types/core/canvas-overlay/canvas-portal.d.ts +11 -0
- package/dist/types/core/canvas-overlay/init-canvas-fc.d.ts +12 -0
- package/dist/types/core/canvas-overlay/init-r3m.d.ts +10 -0
- package/dist/types/core/canvas-overlay/render.d.ts +1 -0
- package/dist/types/core/canvas-overlay/sync-camera-fc.d.ts +14 -0
- package/dist/types/core/coords-to-matrix.d.ts +2 -4
- package/dist/types/core/earth-radius.d.ts +1 -0
- package/dist/types/core/events.d.ts +4 -0
- package/dist/types/core/use-coords-to-matrix.d.ts +5 -0
- package/dist/types/core/use-coords.d.ts +7 -5
- package/dist/types/core/use-r3m.d.ts +22 -0
- package/dist/types/mapbox.index.d.ts +2 -3
- package/package.json +12 -12
- package/stories/package.json +15 -8
- package/stories/yarn.lock +2033 -1194
- package/vitest.config.ts +1 -5
- package/dist/maplibre/types/core/create-events.d.ts +0 -3
- package/dist/maplibre/types/core/store.d.ts +0 -12
- package/dist/maplibre/types/core/use-canvas.d.ts +0 -11
- package/dist/maplibre/types/core/use-create-root.d.ts +0 -13
- package/dist/maplibre/types/core/use-on-add.d.ts +0 -10
- package/dist/maplibre/types/core/use-render.d.ts +0 -4
- package/dist/types/core/create-events.d.ts +0 -3
- package/dist/types/core/store.d.ts +0 -12
- package/dist/types/core/use-canvas.d.ts +0 -11
- package/dist/types/core/use-create-root.d.ts +0 -13
- package/dist/types/core/use-on-add.d.ts +0 -10
- package/dist/types/core/use-render.d.ts +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# react-three-map
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9dfe4f6: Remove `turf` dependency.
|
|
8
|
+
- 9dfe4f6: Map to wait for r3f to finish rendering before the next render in overlay mode.
|
|
9
|
+
|
|
10
|
+
## 0.8.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 7e1743d: - Peer dependency upgrade: `maplibre-gl`: `>=3.2`, so we don't need to sort `maplibre` old DPR bug anymore.
|
|
15
|
+
- Add `overlay?: boolean` to `<Canvas>`, so you can render on a separated canvas if preferred.
|
|
16
|
+
- Add `NearCoordinates` component.
|
|
17
|
+
- Add `coordsToVector3` function.
|
|
18
|
+
|
|
3
19
|
## 0.7.2
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
[](https://github.com/RodrigoHamuy/react-three-map)
|
|
4
4
|
[](https://npmjs.com/package/react-three-map)
|
|
5
5
|
[](https://bundlephobia.com/result?p=react-three-map)
|
|
6
|
-
[](https://rodrigohamuy.github.io/react-three-map/?story=canvas--a-maplibre-example)
|
|
7
|
-
[](https://codecov.io/gh/RodrigoHamuy/react-three-map)
|
|
8
6
|
[](https://github.com/RodrigoHamuy/react-three-map/actions?query=workflow%3Arelease)
|
|
9
|
-
|
|
7
|
+
[](https://rodrigohamuy.github.io/react-three-map/?story=canvas--a-maplibre-example)
|
|
8
|
+
[](https://github.com/sponsors/RodrigoHamuy?frequency=one-time&sponsor=RodrigoHamuy)
|
|
10
9
|
|
|
11
10
|
`react-three-map` is a bridge to use [`react-three-fiber`](https://github.com/pmndrs/react-three-fiber) inside [`react-map-gl`](https://github.com/visgl/react-map-gl).
|
|
12
11
|
|
|
@@ -127,6 +126,19 @@ It shares most of the props from R3F `<Canvas>`, so you can check them directly
|
|
|
127
126
|
| longitude | The longitude coordinate where to add the scene. | |
|
|
128
127
|
| altitude | The altitude coordinate where to add the scene. | `0` |
|
|
129
128
|
| frameloop | Render mode: `"always"`, `"demand"`. | `"always"` |
|
|
129
|
+
| overlay | Render on a separated canvas. | `false` |
|
|
130
|
+
|
|
131
|
+
**About `overlay`**
|
|
132
|
+
|
|
133
|
+
You may want to use `overlay` if:
|
|
134
|
+
|
|
135
|
+
- You use `react-postprocessing` and have issues clearing the screen.
|
|
136
|
+
- Want to avoid unnecesary map renders when only the Three scene changed.
|
|
137
|
+
|
|
138
|
+
But it comes with some caveats:
|
|
139
|
+
|
|
140
|
+
- ThreeJS will always render on top, as this is now a separated canvas and doesn't have access to the map depth buffer.
|
|
141
|
+
- `react-postprocessing` will also not work if you also use `<Coordinates>` components.
|
|
130
142
|
|
|
131
143
|
#### Render Props removed from `@react-three/fiber`
|
|
132
144
|
|
|
@@ -166,6 +178,16 @@ import { Canvas, Coordinates } from 'react-three-map'
|
|
|
166
178
|
| longitude | The longitude coordinate where to add the scene. | |
|
|
167
179
|
| altitude | The altitude coordinate where to add the scene. | `0` |
|
|
168
180
|
|
|
181
|
+
### NearCoordinates
|
|
182
|
+
|
|
183
|
+
[](https://rodrigohamuy.github.io/react-three-map/?story=multi-coordinates--default)
|
|
184
|
+
|
|
185
|
+
Same as `Coordinates`, but with an error margin that increases the further you are from the origin.
|
|
186
|
+
|
|
187
|
+
Recommended to use at city level distances, but margin errors will be noticeable at country level distances.
|
|
188
|
+
|
|
189
|
+
Check the story to see the difference between the two.
|
|
190
|
+
|
|
169
191
|
### useMap
|
|
170
192
|
|
|
171
193
|
Access the map from inside `react-three-map`.
|
|
@@ -178,4 +200,35 @@ const Component = () => {
|
|
|
178
200
|
return <>...</>
|
|
179
201
|
}
|
|
180
202
|
|
|
181
|
-
```
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### coordsToVector3
|
|
206
|
+
|
|
207
|
+
[](https://rodrigohamuy.github.io/react-three-map/?story=extrude-coordinates--extrude-coordinates)
|
|
208
|
+
|
|
209
|
+
This utility function converts geographic coordinates into a `Vector3Tuple`, which represents a 3D vector in meters.
|
|
210
|
+
|
|
211
|
+
Similar to `NearCoordinates` it has a relatively good precision at city distances, but is not recommended if your distances are too big.
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
| Parameter | Description |
|
|
215
|
+
| ---------------- | --------------------------------------------------------------- |
|
|
216
|
+
| `point: Coords` | The geographic coordinates of the point to convert. |
|
|
217
|
+
| `origin: Coords` | The geographic coordinates used as the origin for calculations. |
|
|
218
|
+
|
|
219
|
+
Returns a `Vector3Tuple` representing the 3D position of the point relative to the origin.
|
|
220
|
+
|
|
221
|
+
### vector3ToCoords
|
|
222
|
+
|
|
223
|
+
[](https://rodrigohamuy.github.io/react-three-map/?story=pivot-controls--default)
|
|
224
|
+
|
|
225
|
+
This utility function converts a `Vector3Tuple`, which represents a 3D vector in meters, back into geographic coordinates.
|
|
226
|
+
|
|
227
|
+
It is the inverse of `coordsToVector3` and maintains the same level of precision. It is not recommended for use with very large distances.
|
|
228
|
+
|
|
229
|
+
| Parameter | Description |
|
|
230
|
+
| ------------------------ | --------------------------------------------------------------- |
|
|
231
|
+
| `position: Vector3Tuple` | The 3D vector to convert back into geographic coordinates. |
|
|
232
|
+
| `origin: Coords` | The geographic coordinates used as the origin for calculations. |
|
|
233
|
+
|
|
234
|
+
Returns a `Coords` object representing the geographic coordinates of the point relative to the origin.
|