react-three-map 0.7.2 → 0.8.0

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.
Files changed (138) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +42 -4
  3. package/dist/cjs/main.js +369 -181
  4. package/dist/es/main.mjs +6 -2
  5. package/dist/es/main.mjs.map +1 -1
  6. package/dist/es/main10.mjs +33 -20
  7. package/dist/es/main10.mjs.map +1 -1
  8. package/dist/es/main11.mjs +11 -19
  9. package/dist/es/main11.mjs.map +1 -1
  10. package/dist/es/main12.mjs +20 -85
  11. package/dist/es/main12.mjs.map +1 -1
  12. package/dist/es/main13.mjs +30 -9
  13. package/dist/es/main13.mjs.map +1 -1
  14. package/dist/es/main14.mjs +22 -67
  15. package/dist/es/main14.mjs.map +1 -1
  16. package/dist/es/main15.mjs +98 -0
  17. package/dist/es/main15.mjs.map +1 -0
  18. package/dist/es/main16.mjs +66 -0
  19. package/dist/es/main16.mjs.map +1 -0
  20. package/dist/es/main17.mjs +23 -0
  21. package/dist/es/main17.mjs.map +1 -0
  22. package/dist/es/main18.mjs +27 -0
  23. package/dist/es/main18.mjs.map +1 -0
  24. package/dist/es/main19.mjs +19 -0
  25. package/dist/es/main19.mjs.map +1 -0
  26. package/dist/es/main2.mjs.map +1 -1
  27. package/dist/es/main20.mjs +72 -0
  28. package/dist/es/main20.mjs.map +1 -0
  29. package/dist/es/main3.mjs +43 -50
  30. package/dist/es/main3.mjs.map +1 -1
  31. package/dist/es/main4.mjs +50 -24
  32. package/dist/es/main4.mjs.map +1 -1
  33. package/dist/es/main5.mjs +19 -3
  34. package/dist/es/main5.mjs.map +1 -1
  35. package/dist/es/main6.mjs +14 -33
  36. package/dist/es/main6.mjs.map +1 -1
  37. package/dist/es/main7.mjs +18 -7
  38. package/dist/es/main7.mjs.map +1 -1
  39. package/dist/es/main8.mjs +26 -21
  40. package/dist/es/main8.mjs.map +1 -1
  41. package/dist/es/main9.mjs +9 -15
  42. package/dist/es/main9.mjs.map +1 -1
  43. package/dist/maplibre/cjs/main.js +369 -181
  44. package/dist/maplibre/es/main.mjs +6 -2
  45. package/dist/maplibre/es/main.mjs.map +1 -1
  46. package/dist/maplibre/es/main10.mjs +33 -19
  47. package/dist/maplibre/es/main10.mjs.map +1 -1
  48. package/dist/maplibre/es/main11.mjs +11 -14
  49. package/dist/maplibre/es/main11.mjs.map +1 -1
  50. package/dist/maplibre/es/main12.mjs +20 -85
  51. package/dist/maplibre/es/main12.mjs.map +1 -1
  52. package/dist/maplibre/es/main13.mjs +30 -9
  53. package/dist/maplibre/es/main13.mjs.map +1 -1
  54. package/dist/maplibre/es/main14.mjs +22 -67
  55. package/dist/maplibre/es/main14.mjs.map +1 -1
  56. package/dist/maplibre/es/main15.mjs +98 -0
  57. package/dist/maplibre/es/main15.mjs.map +1 -0
  58. package/dist/maplibre/es/main16.mjs +66 -0
  59. package/dist/maplibre/es/main16.mjs.map +1 -0
  60. package/dist/maplibre/es/main17.mjs +23 -0
  61. package/dist/maplibre/es/main17.mjs.map +1 -0
  62. package/dist/maplibre/es/main18.mjs +27 -0
  63. package/dist/maplibre/es/main18.mjs.map +1 -0
  64. package/dist/maplibre/es/main19.mjs +19 -0
  65. package/dist/maplibre/es/main19.mjs.map +1 -0
  66. package/dist/maplibre/es/main2.mjs.map +1 -1
  67. package/dist/maplibre/es/main20.mjs +72 -0
  68. package/dist/maplibre/es/main20.mjs.map +1 -0
  69. package/dist/maplibre/es/main3.mjs +43 -50
  70. package/dist/maplibre/es/main3.mjs.map +1 -1
  71. package/dist/maplibre/es/main4.mjs +50 -24
  72. package/dist/maplibre/es/main4.mjs.map +1 -1
  73. package/dist/maplibre/es/main5.mjs +19 -3
  74. package/dist/maplibre/es/main5.mjs.map +1 -1
  75. package/dist/maplibre/es/main6.mjs +14 -33
  76. package/dist/maplibre/es/main6.mjs.map +1 -1
  77. package/dist/maplibre/es/main7.mjs +18 -7
  78. package/dist/maplibre/es/main7.mjs.map +1 -1
  79. package/dist/maplibre/es/main8.mjs +26 -21
  80. package/dist/maplibre/es/main8.mjs.map +1 -1
  81. package/dist/maplibre/es/main9.mjs +8 -20
  82. package/dist/maplibre/es/main9.mjs.map +1 -1
  83. package/dist/maplibre/types/api/canvas-props.d.ts +4 -4
  84. package/dist/maplibre/types/api/coords-to-vector-3.d.ts +4 -0
  85. package/dist/maplibre/types/api/coords.d.ts +5 -0
  86. package/dist/maplibre/types/api/index.d.ts +5 -0
  87. package/dist/maplibre/types/api/near-coordinates.d.ts +3 -0
  88. package/dist/maplibre/types/api/use-map.d.ts +1 -1
  89. package/dist/maplibre/types/core/canvas-in-layer/use-canvas-in-layer.d.ts +11 -0
  90. package/dist/maplibre/types/core/canvas-in-layer/use-render.d.ts +12 -0
  91. package/dist/maplibre/types/core/canvas-in-layer/use-root.d.ts +7 -0
  92. package/dist/maplibre/types/core/canvas-overlay/canvas-portal.d.ts +11 -0
  93. package/dist/maplibre/types/core/canvas-overlay/init-canvas-fc.d.ts +12 -0
  94. package/dist/maplibre/types/core/canvas-overlay/init-r3m.d.ts +10 -0
  95. package/dist/maplibre/types/core/canvas-overlay/render.d.ts +1 -0
  96. package/dist/maplibre/types/core/canvas-overlay/sync-camera-fc.d.ts +13 -0
  97. package/dist/maplibre/types/core/coords-to-matrix.d.ts +2 -4
  98. package/dist/maplibre/types/core/events.d.ts +4 -0
  99. package/dist/maplibre/types/core/use-coords-to-matrix.d.ts +5 -0
  100. package/dist/maplibre/types/core/use-coords.d.ts +7 -5
  101. package/dist/maplibre/types/core/use-r3m.d.ts +22 -0
  102. package/dist/maplibre/types/{maplibre → mapbox}/canvas.d.ts +1 -1
  103. package/dist/maplibre/types/maplibre.index.d.ts +3 -4
  104. package/dist/types/api/canvas-props.d.ts +4 -4
  105. package/dist/types/api/coords-to-vector-3.d.ts +4 -0
  106. package/dist/types/api/coords.d.ts +5 -0
  107. package/dist/types/api/index.d.ts +5 -0
  108. package/dist/types/api/near-coordinates.d.ts +3 -0
  109. package/dist/types/api/use-map.d.ts +1 -1
  110. package/dist/types/core/canvas-in-layer/use-canvas-in-layer.d.ts +11 -0
  111. package/dist/types/core/canvas-in-layer/use-render.d.ts +12 -0
  112. package/dist/types/core/canvas-in-layer/use-root.d.ts +7 -0
  113. package/dist/types/core/canvas-overlay/canvas-portal.d.ts +11 -0
  114. package/dist/types/core/canvas-overlay/init-canvas-fc.d.ts +12 -0
  115. package/dist/types/core/canvas-overlay/init-r3m.d.ts +10 -0
  116. package/dist/types/core/canvas-overlay/render.d.ts +1 -0
  117. package/dist/types/core/canvas-overlay/sync-camera-fc.d.ts +13 -0
  118. package/dist/types/core/coords-to-matrix.d.ts +2 -4
  119. package/dist/types/core/events.d.ts +4 -0
  120. package/dist/types/core/use-coords-to-matrix.d.ts +5 -0
  121. package/dist/types/core/use-coords.d.ts +7 -5
  122. package/dist/types/core/use-r3m.d.ts +22 -0
  123. package/dist/types/mapbox.index.d.ts +2 -3
  124. package/package.json +12 -9
  125. package/stories/package.json +12 -5
  126. package/stories/yarn.lock +128 -135
  127. package/dist/maplibre/types/core/create-events.d.ts +0 -3
  128. package/dist/maplibre/types/core/store.d.ts +0 -12
  129. package/dist/maplibre/types/core/use-canvas.d.ts +0 -11
  130. package/dist/maplibre/types/core/use-create-root.d.ts +0 -13
  131. package/dist/maplibre/types/core/use-on-add.d.ts +0 -10
  132. package/dist/maplibre/types/core/use-render.d.ts +0 -4
  133. package/dist/types/core/create-events.d.ts +0 -3
  134. package/dist/types/core/store.d.ts +0 -12
  135. package/dist/types/core/use-canvas.d.ts +0 -11
  136. package/dist/types/core/use-create-root.d.ts +0 -13
  137. package/dist/types/core/use-on-add.d.ts +0 -10
  138. package/dist/types/core/use-render.d.ts +0 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # react-three-map
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7e1743d: - Peer dependency upgrade: `maplibre-gl`: `>=3.2`, so we don't need to sort `maplibre` old DPR bug anymore.
8
+ - Add `overlay?: boolean` to `<Canvas>`, so you can render on a separated canvas if preferred.
9
+ - Add `NearCoordinates` component.
10
+ - Add `coordsToVector3` function.
11
+
3
12
  ## 0.7.2
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -3,10 +3,9 @@
3
3
  [![Repository](https://img.shields.io/static/v1?&message=github&style=flat&colorA=000000&colorB=000000&label=&logo=github&logoColor=ffffff)](https://github.com/RodrigoHamuy/react-three-map)
4
4
  [![Version](https://img.shields.io/npm/v/react-three-map?style=flat&colorA=000000&colorB=000000)](https://npmjs.com/package/react-three-map)
5
5
  [![Build Size](https://img.shields.io/bundlephobia/minzip/react-three-map?label=size&?style=flat&colorA=000000&colorB=000000)](https://bundlephobia.com/result?p=react-three-map)
6
- [![Stories](https://img.shields.io/badge/stories-stories?colorA=000&colorB=000000&logo=maplibre)](https://rodrigohamuy.github.io/react-three-map/?story=canvas--a-maplibre-example)
7
- [![codecov](https://img.shields.io/codecov/c/github/RodrigoHamuy/react-three-map?style=flat&colorA=000000&colorB=000000&logo=github&label=codecov&logo=codecov)](https://codecov.io/gh/RodrigoHamuy/react-three-map)
8
6
  [![Build Status](https://img.shields.io/github/actions/workflow/status/RodrigoHamuy/react-three-map/release.yml?branch=main&style=flat&colorA=000000)](https://github.com/RodrigoHamuy/react-three-map/actions?query=workflow%3Arelease)
9
-
7
+ [![Examples](https://img.shields.io/badge/stories-stories?colorA=000&colorB=000000&label=📍)](https://rodrigohamuy.github.io/react-three-map/?story=canvas--a-maplibre-example)
8
+ [![Sponsor me](https://img.shields.io/github/sponsors/RodrigoHamuy?style=flat&colorA=000000&colorB=000000&label=💛%20sponsor)](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://img.shields.io/badge/-demo-%23ff69b4)](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,20 @@ const Component = () => {
178
200
  return <>...</>
179
201
  }
180
202
 
181
- ```
203
+ ```
204
+
205
+ ### coordsToVector3
206
+
207
+ [![](https://img.shields.io/badge/-demo-%23ff69b4)](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.