react-three-map 0.4.3 → 0.5.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.
- package/CHANGELOG.md +6 -0
- package/README.md +14 -0
- package/dist/cjs/main.js +7 -1
- package/dist/es/main.mjs +6 -3
- package/dist/es/main.mjs.map +1 -1
- package/dist/es/main10.mjs +2 -2
- package/dist/es/main11.mjs +14 -74
- package/dist/es/main11.mjs.map +1 -1
- package/dist/es/main12.mjs +75 -9
- package/dist/es/main12.mjs.map +1 -1
- package/dist/es/main13.mjs +8 -67
- package/dist/es/main13.mjs.map +1 -1
- package/dist/es/main14.mjs +71 -0
- package/dist/es/main14.mjs.map +1 -0
- package/dist/es/main2.mjs +5 -23
- package/dist/es/main2.mjs.map +1 -1
- package/dist/es/main3.mjs +23 -52
- package/dist/es/main3.mjs.map +1 -1
- package/dist/es/main4.mjs +46 -15
- package/dist/es/main4.mjs.map +1 -1
- package/dist/es/main5.mjs +22 -3
- package/dist/es/main5.mjs.map +1 -1
- package/dist/es/main6.mjs +3 -34
- package/dist/es/main6.mjs.map +1 -1
- package/dist/es/main7.mjs +33 -11
- package/dist/es/main7.mjs.map +1 -1
- package/dist/es/main8.mjs +11 -14
- package/dist/es/main8.mjs.map +1 -1
- package/dist/es/main9.mjs +1 -1
- package/dist/maplibre/cjs/main.js +7 -1
- package/dist/maplibre/es/main.mjs +6 -3
- package/dist/maplibre/es/main.mjs.map +1 -1
- package/dist/maplibre/es/main10.mjs +21 -15
- package/dist/maplibre/es/main10.mjs.map +1 -1
- package/dist/maplibre/es/main11.mjs +17 -72
- package/dist/maplibre/es/main11.mjs.map +1 -1
- package/dist/maplibre/es/main12.mjs +75 -9
- package/dist/maplibre/es/main12.mjs.map +1 -1
- package/dist/maplibre/es/main13.mjs +8 -67
- package/dist/maplibre/es/main13.mjs.map +1 -1
- package/dist/maplibre/es/main14.mjs +71 -0
- package/dist/maplibre/es/main14.mjs.map +1 -0
- package/dist/maplibre/es/main2.mjs +5 -23
- package/dist/maplibre/es/main2.mjs.map +1 -1
- package/dist/maplibre/es/main3.mjs +23 -52
- package/dist/maplibre/es/main3.mjs.map +1 -1
- package/dist/maplibre/es/main4.mjs +46 -15
- package/dist/maplibre/es/main4.mjs.map +1 -1
- package/dist/maplibre/es/main5.mjs +22 -3
- package/dist/maplibre/es/main5.mjs.map +1 -1
- package/dist/maplibre/es/main6.mjs +3 -34
- package/dist/maplibre/es/main6.mjs.map +1 -1
- package/dist/maplibre/es/main7.mjs +33 -11
- package/dist/maplibre/es/main7.mjs.map +1 -1
- package/dist/maplibre/es/main8.mjs +12 -21
- package/dist/maplibre/es/main8.mjs.map +1 -1
- package/dist/maplibre/es/main9.mjs +14 -19
- package/dist/maplibre/es/main9.mjs.map +1 -1
- package/dist/maplibre/types/api/use-map.d.ts +2 -0
- package/dist/maplibre/types/maplibre.index.d.ts +2 -0
- package/dist/types/api/use-map.d.ts +2 -0
- package/dist/types/mapbox.index.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -163,3 +163,17 @@ import { Canvas, Coordinates } from 'react-three-map'
|
|
|
163
163
|
| latitude | The latitude coordinate where to add the scene. | |
|
|
164
164
|
| longitude | The longitude coordinate where to add the scene. | |
|
|
165
165
|
| altitude | The altitude coordinate where to add the scene. | `0` |
|
|
166
|
+
|
|
167
|
+
### useMap
|
|
168
|
+
|
|
169
|
+
Access the map from inside `react-three-map`.
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
import { useMap } from "react-three-map";
|
|
173
|
+
// import { useMap } from "react-three-map/maplibre"; if you use maplibre
|
|
174
|
+
const Component = () => {
|
|
175
|
+
const map = useMap();
|
|
176
|
+
return <>...</>
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
```
|
package/dist/cjs/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
3
|
const fiber = require("@react-three/fiber");
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
5
|
const mapboxGl = require("mapbox-gl");
|
|
6
6
|
const react = require("react");
|
|
7
7
|
const reactMapGl = require("react-map-gl");
|
|
@@ -23,6 +23,10 @@ function _interopNamespaceDefault(e) {
|
|
|
23
23
|
return Object.freeze(n);
|
|
24
24
|
}
|
|
25
25
|
const THREE__namespace = /* @__PURE__ */ _interopNamespaceDefault(THREE);
|
|
26
|
+
const useMap$1 = () => fiber.useThree((s) => {
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = s.r3m) == null ? void 0 : _a.map;
|
|
29
|
+
});
|
|
26
30
|
const quat = new THREE.Quaternion();
|
|
27
31
|
const euler = new THREE.Euler();
|
|
28
32
|
const pos = new THREE.Vector3();
|
|
@@ -333,5 +337,7 @@ function RenderAtCoords({ r3m, origin }) {
|
|
|
333
337
|
}, [set, r3m]);
|
|
334
338
|
return /* @__PURE__ */ jsxRuntime.jsx("perspectiveCamera", { ref: cameraRef });
|
|
335
339
|
}
|
|
340
|
+
const useMap = useMap$1;
|
|
336
341
|
exports.Canvas = Canvas;
|
|
337
342
|
exports.Coordinates = Coordinates;
|
|
343
|
+
exports.useMap = useMap;
|
package/dist/es/main.mjs
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useMap as useMap$1 } from "./main2.mjs";
|
|
2
|
+
import { Canvas } from "./main3.mjs";
|
|
3
|
+
import { Coordinates } from "./main4.mjs";
|
|
4
|
+
const useMap = useMap$1;
|
|
3
5
|
export {
|
|
4
6
|
Canvas,
|
|
5
|
-
Coordinates
|
|
7
|
+
Coordinates,
|
|
8
|
+
useMap
|
|
6
9
|
};
|
|
7
10
|
//# sourceMappingURL=main.mjs.map
|
package/dist/es/main.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.mjs","sources":["../../src/mapbox.index.ts"],"sourcesContent":["import { MapInstance } from 'react-map-gl';\nimport { useMap as useMapGeneric } from './api/use-map';\n\nexport * from './mapbox/canvas';\nexport * from './api/canvas-props';\nexport * from './api/coordinates';\n\nexport const useMap = useMapGeneric<MapInstance>;\n"],"names":["useMapGeneric"],"mappings":";;;AAOO,MAAM,SAASA;"}
|
package/dist/es/main10.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { syncCamera } from "./
|
|
2
|
-
import { useFunction } from "./
|
|
1
|
+
import { syncCamera } from "./main7.mjs";
|
|
2
|
+
import { useFunction } from "./main13.mjs";
|
|
3
3
|
function useRender(origin, r3mRef, frameloop) {
|
|
4
4
|
const render = useFunction((_gl, mapCamMx) => {
|
|
5
5
|
const r3m = r3mRef.current;
|
package/dist/es/main11.mjs
CHANGED
|
@@ -1,78 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
...renderProps,
|
|
15
|
-
frameloop: "never",
|
|
16
|
-
gl: {
|
|
17
|
-
context: gl,
|
|
18
|
-
depth: true,
|
|
19
|
-
autoClear: false,
|
|
20
|
-
antialias: true,
|
|
21
|
-
...renderProps == null ? void 0 : renderProps.gl
|
|
22
|
-
},
|
|
23
|
-
onCreated: (state) => {
|
|
24
|
-
state.gl.forceContextLoss = () => {
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
camera: {
|
|
28
|
-
matrixAutoUpdate: false,
|
|
29
|
-
near: 0
|
|
30
|
-
},
|
|
31
|
-
size: {
|
|
32
|
-
width: canvas.clientWidth,
|
|
33
|
-
height: canvas.clientHeight,
|
|
34
|
-
top: 0,
|
|
35
|
-
left: 0,
|
|
36
|
-
...renderProps == null ? void 0 : renderProps.size
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
const store = _roots.get(canvas).store;
|
|
40
|
-
r3mRef.current.map = map;
|
|
41
|
-
r3mRef.current.root = root;
|
|
42
|
-
r3mRef.current.state = store.getState();
|
|
43
|
-
store.setState({ r3m: r3mRef.current });
|
|
44
|
-
if (frameloop === "demand") {
|
|
45
|
-
store.setState({
|
|
46
|
-
frameloop,
|
|
47
|
-
invalidate: () => {
|
|
48
|
-
map.triggerRepaint();
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
map.on("resize", onResize);
|
|
53
|
-
setTimeout(() => setMounted(true));
|
|
54
|
-
});
|
|
55
|
-
const onResize = useFunction(() => {
|
|
56
|
-
if (!r3mRef.current.map)
|
|
57
|
-
return;
|
|
58
|
-
if (!r3mRef.current.state)
|
|
59
|
-
return;
|
|
60
|
-
const canvas = r3mRef.current.map.getCanvas();
|
|
61
|
-
r3mRef.current.state.setSize(canvas.width, canvas.height);
|
|
62
|
-
});
|
|
63
|
-
const onRemove = useFunction(() => {
|
|
64
|
-
if (!r3mRef.current.root)
|
|
65
|
-
return;
|
|
66
|
-
r3mRef.current.root.unmount();
|
|
67
|
-
r3mRef.current.root = void 0;
|
|
68
|
-
if (!r3mRef.current.map)
|
|
69
|
-
return;
|
|
70
|
-
r3mRef.current.map.off("resize", onResize);
|
|
71
|
-
});
|
|
72
|
-
useEffect(() => () => onRemove(), [onRemove]);
|
|
73
|
-
return { onAdd, onRemove, mounted, r3mRef };
|
|
1
|
+
import { Quaternion, Euler, Vector3, Matrix4 } from "three";
|
|
2
|
+
const quat = new Quaternion();
|
|
3
|
+
const euler = new Euler();
|
|
4
|
+
const pos = new Vector3();
|
|
5
|
+
const scale = new Vector3();
|
|
6
|
+
const m4 = new Matrix4();
|
|
7
|
+
function coordsToMatrix({ longitude, latitude, altitude, fromLngLat }) {
|
|
8
|
+
const center = fromLngLat([longitude, latitude], altitude);
|
|
9
|
+
const scaleUnit = center.meterInMercatorCoordinateUnits();
|
|
10
|
+
pos.set(center.x, center.y, center.z || 0);
|
|
11
|
+
scale.set(scaleUnit, -scaleUnit, scaleUnit);
|
|
12
|
+
quat.setFromEuler(euler.set(-Math.PI * 0.5, 0, 0));
|
|
13
|
+
return m4.compose(pos, quat, scale).toArray();
|
|
74
14
|
}
|
|
75
15
|
export {
|
|
76
|
-
|
|
16
|
+
coordsToMatrix
|
|
77
17
|
};
|
|
78
18
|
//# sourceMappingURL=main11.mjs.map
|
package/dist/es/main11.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main11.mjs","sources":["../../src/core/
|
|
1
|
+
{"version":3,"file":"main11.mjs","sources":["../../src/core/coords-to-matrix.ts"],"sourcesContent":["import { Euler, Matrix4, Quaternion, Vector3 } from \"three\";\nimport { FromLngLat } from \"./generic-map\";\n\nconst quat = new Quaternion();\nconst euler = new Euler();\nconst pos = new Vector3();\nconst scale = new Vector3();\nconst m4 = new Matrix4();\n\n/** calculate Matrix4 from coordinates */\nexport function coordsToMatrix({ longitude, latitude, altitude, fromLngLat }: {\n longitude: number, latitude: number, altitude: number, fromLngLat: FromLngLat\n}) {\n const center = fromLngLat([longitude, latitude], altitude);\n const scaleUnit = center.meterInMercatorCoordinateUnits();\n pos.set(center.x, center.y, center.z || 0);\n scale.set(scaleUnit, -scaleUnit, scaleUnit);\n quat.setFromEuler(euler.set(-Math.PI * .5, 0, 0));\n return m4.compose(pos, quat, scale).toArray();\n}\n"],"names":[],"mappings":";AAGA,MAAM,OAAO,IAAI;AACjB,MAAM,QAAQ,IAAI;AAClB,MAAM,MAAM,IAAI;AAChB,MAAM,QAAQ,IAAI;AAClB,MAAM,KAAK,IAAI;AAGR,SAAS,eAAe,EAAE,WAAW,UAAU,UAAU,cAE7D;AACD,QAAM,SAAS,WAAW,CAAC,WAAW,QAAQ,GAAG,QAAQ;AACnD,QAAA,YAAY,OAAO;AACzB,MAAI,IAAI,OAAO,GAAG,OAAO,GAAG,OAAO,KAAK,CAAC;AACzC,QAAM,IAAI,WAAW,CAAC,WAAW,SAAS;AACrC,OAAA,aAAa,MAAM,IAAI,CAAC,KAAK,KAAK,KAAI,GAAG,CAAC,CAAC;AAChD,SAAO,GAAG,QAAQ,KAAK,MAAM,KAAK,EAAE;AACtC;"}
|
package/dist/es/main12.mjs
CHANGED
|
@@ -1,12 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
1
|
+
import { createRoot, _roots } from "@react-three/fiber";
|
|
2
|
+
import { useState, useRef, useEffect } from "react";
|
|
3
|
+
import { createEvents } from "./main14.mjs";
|
|
4
|
+
import { useFunction } from "./main13.mjs";
|
|
5
|
+
function useOnAdd(fromLngLat, { frameloop, ...renderProps }) {
|
|
6
|
+
const [mounted, setMounted] = useState(false);
|
|
7
|
+
const r3mRef = useRef({ fromLngLat });
|
|
8
|
+
const onAdd = useFunction((map, gl) => {
|
|
9
|
+
const canvas = map.getCanvas();
|
|
10
|
+
const root = createRoot(canvas);
|
|
11
|
+
root.configure({
|
|
12
|
+
dpr: window.devicePixelRatio,
|
|
13
|
+
events: createEvents(),
|
|
14
|
+
...renderProps,
|
|
15
|
+
frameloop: "never",
|
|
16
|
+
gl: {
|
|
17
|
+
context: gl,
|
|
18
|
+
depth: true,
|
|
19
|
+
autoClear: false,
|
|
20
|
+
antialias: true,
|
|
21
|
+
...renderProps == null ? void 0 : renderProps.gl
|
|
22
|
+
},
|
|
23
|
+
onCreated: (state) => {
|
|
24
|
+
state.gl.forceContextLoss = () => {
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
camera: {
|
|
28
|
+
matrixAutoUpdate: false,
|
|
29
|
+
near: 0
|
|
30
|
+
},
|
|
31
|
+
size: {
|
|
32
|
+
width: canvas.clientWidth,
|
|
33
|
+
height: canvas.clientHeight,
|
|
34
|
+
top: 0,
|
|
35
|
+
left: 0,
|
|
36
|
+
...renderProps == null ? void 0 : renderProps.size
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const store = _roots.get(canvas).store;
|
|
40
|
+
r3mRef.current.map = map;
|
|
41
|
+
r3mRef.current.root = root;
|
|
42
|
+
r3mRef.current.state = store.getState();
|
|
43
|
+
store.setState({ r3m: r3mRef.current });
|
|
44
|
+
if (frameloop === "demand") {
|
|
45
|
+
store.setState({
|
|
46
|
+
frameloop,
|
|
47
|
+
invalidate: () => {
|
|
48
|
+
map.triggerRepaint();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
map.on("resize", onResize);
|
|
53
|
+
setTimeout(() => setMounted(true));
|
|
54
|
+
});
|
|
55
|
+
const onResize = useFunction(() => {
|
|
56
|
+
if (!r3mRef.current.map)
|
|
57
|
+
return;
|
|
58
|
+
if (!r3mRef.current.state)
|
|
59
|
+
return;
|
|
60
|
+
const canvas = r3mRef.current.map.getCanvas();
|
|
61
|
+
r3mRef.current.state.setSize(canvas.width, canvas.height);
|
|
62
|
+
});
|
|
63
|
+
const onRemove = useFunction(() => {
|
|
64
|
+
if (!r3mRef.current.root)
|
|
65
|
+
return;
|
|
66
|
+
r3mRef.current.root.unmount();
|
|
67
|
+
r3mRef.current.root = void 0;
|
|
68
|
+
if (!r3mRef.current.map)
|
|
69
|
+
return;
|
|
70
|
+
r3mRef.current.map.off("resize", onResize);
|
|
71
|
+
});
|
|
72
|
+
useEffect(() => () => onRemove(), [onRemove]);
|
|
73
|
+
return { onAdd, onRemove, mounted, r3mRef };
|
|
74
|
+
}
|
|
9
75
|
export {
|
|
10
|
-
|
|
76
|
+
useOnAdd
|
|
11
77
|
};
|
|
12
78
|
//# sourceMappingURL=main12.mjs.map
|
package/dist/es/main12.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main12.mjs","sources":["../../src/core/use-
|
|
1
|
+
{"version":3,"file":"main12.mjs","sources":["../../src/core/use-on-add.ts"],"sourcesContent":["import { RenderProps, _roots, createRoot } from \"@react-three/fiber\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { createEvents } from \"./create-events\";\nimport { FromLngLat, MapInstance } from \"./generic-map\";\nimport { R3mStore } from \"./store\";\nimport { useFunction } from \"./use-function\";\n\nexport function useOnAdd(\n fromLngLat: FromLngLat,\n { frameloop, ...renderProps }: RenderProps<HTMLCanvasElement>\n) {\n\n const [mounted, setMounted] = useState(false);\n\n const r3mRef = useRef<R3mStore>({ fromLngLat });\n\n const onAdd = useFunction((map: MapInstance, gl: WebGLRenderingContext) => {\n\n const canvas = map.getCanvas();\n const root = createRoot(canvas);\n root.configure({\n dpr: window.devicePixelRatio,\n events: createEvents(),\n ...renderProps,\n frameloop: 'never',\n gl: {\n context: gl,\n depth: true,\n autoClear: false,\n antialias: true,\n ...renderProps?.gl,\n },\n onCreated: (state) => {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n state.gl.forceContextLoss = () => { };\n },\n camera: {\n matrixAutoUpdate: false,\n near: 0,\n },\n size: {\n width: canvas.clientWidth,\n height: canvas.clientHeight,\n top: 0,\n left: 0,\n ...renderProps?.size,\n },\n });\n\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const store = _roots.get(canvas)!.store;\n\n r3mRef.current.map = map;\n r3mRef.current.root = root;\n r3mRef.current.state = store.getState();\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n store.setState({ r3m: r3mRef.current } as any);\n\n if (frameloop === 'demand') {\n store.setState({\n frameloop,\n invalidate: () => {\n map.triggerRepaint();\n },\n })\n }\n\n map.on('resize', onResize)\n\n setTimeout(() => setMounted(true));\n\n })\n\n const onResize = useFunction(() => {\n if (!r3mRef.current.map) return;\n if (!r3mRef.current.state) return;\n const canvas = r3mRef.current.map.getCanvas();\n r3mRef.current.state.setSize(canvas.width, canvas.height);\n })\n\n const onRemove = useFunction(() => {\n if (!r3mRef.current.root) return;\n r3mRef.current.root.unmount();\n r3mRef.current.root = undefined;\n if (!r3mRef.current.map) return;\n r3mRef.current.map.off('resize', onResize)\n })\n\n // on unmount\n useEffect(() => () => onRemove(), [onRemove])\n\n return { onAdd, onRemove, mounted, r3mRef };\n}"],"names":[],"mappings":";;;;AAOO,SAAS,SACd,YACA,EAAE,WAAW,GAAG,eAChB;AAEA,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAE5C,QAAM,SAAS,OAAiB,EAAE,WAAY,CAAA;AAE9C,QAAM,QAAQ,YAAY,CAAC,KAAkB,OAA8B;AAEnE,UAAA,SAAS,IAAI;AACb,UAAA,OAAO,WAAW,MAAM;AAC9B,SAAK,UAAU;AAAA,MACb,KAAK,OAAO;AAAA,MACZ,QAAQ,aAAa;AAAA,MACrB,GAAG;AAAA,MACH,WAAW;AAAA,MACX,IAAI;AAAA,QACF,SAAS;AAAA,QACT,OAAO;AAAA,QACP,WAAW;AAAA,QACX,WAAW;AAAA,QACX,GAAG,2CAAa;AAAA,MAClB;AAAA,MACA,WAAW,CAAC,UAAU;AAEd,cAAA,GAAG,mBAAmB,MAAM;AAAA,QAAA;AAAA,MACpC;AAAA,MACA,QAAQ;AAAA,QACN,kBAAkB;AAAA,QAClB,MAAM;AAAA,MACR;AAAA,MACA,MAAM;AAAA,QACJ,OAAO,OAAO;AAAA,QACd,QAAQ,OAAO;AAAA,QACf,KAAK;AAAA,QACL,MAAM;AAAA,QACN,GAAG,2CAAa;AAAA,MAClB;AAAA,IAAA,CACD;AAGD,UAAM,QAAQ,OAAO,IAAI,MAAM,EAAG;AAElC,WAAO,QAAQ,MAAM;AACrB,WAAO,QAAQ,OAAO;AACf,WAAA,QAAQ,QAAQ,MAAM,SAAS;AAGtC,UAAM,SAAS,EAAE,KAAK,OAAO,QAAgB,CAAA;AAE7C,QAAI,cAAc,UAAU;AAC1B,YAAM,SAAS;AAAA,QACb;AAAA,QACA,YAAY,MAAM;AAChB,cAAI,eAAe;AAAA,QACrB;AAAA,MAAA,CACD;AAAA,IACH;AAEI,QAAA,GAAG,UAAU,QAAQ;AAEd,eAAA,MAAM,WAAW,IAAI,CAAC;AAAA,EAAA,CAElC;AAEK,QAAA,WAAW,YAAY,MAAM;AAC7B,QAAA,CAAC,OAAO,QAAQ;AAAK;AACrB,QAAA,CAAC,OAAO,QAAQ;AAAO;AAC3B,UAAM,SAAS,OAAO,QAAQ,IAAI,UAAU;AAC5C,WAAO,QAAQ,MAAM,QAAQ,OAAO,OAAO,OAAO,MAAM;AAAA,EAAA,CACzD;AAEK,QAAA,WAAW,YAAY,MAAM;AAC7B,QAAA,CAAC,OAAO,QAAQ;AAAM;AACnB,WAAA,QAAQ,KAAK;AACpB,WAAO,QAAQ,OAAO;AAClB,QAAA,CAAC,OAAO,QAAQ;AAAK;AACzB,WAAO,QAAQ,IAAI,IAAI,UAAU,QAAQ;AAAA,EAAA,CAC1C;AAGD,YAAU,MAAM,MAAM,SAAY,GAAA,CAAC,QAAQ,CAAC;AAE5C,SAAO,EAAE,OAAO,UAAU,SAAS,OAAO;AAC5C;"}
|
package/dist/es/main13.mjs
CHANGED
|
@@ -1,71 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
onPointerDown: ["pointerdown", true],
|
|
9
|
-
onPointerUp: ["pointerup", true],
|
|
10
|
-
onPointerLeave: ["pointerleave", true],
|
|
11
|
-
onPointerMove: ["pointermove", true],
|
|
12
|
-
onPointerCancel: ["pointercancel", true],
|
|
13
|
-
onLostPointerCapture: ["lostpointercapture", true]
|
|
1
|
+
import { useRef, useCallback } from "react";
|
|
2
|
+
const useFunction = (callback) => {
|
|
3
|
+
const callbackRef = useRef(callback);
|
|
4
|
+
callbackRef.current = callback;
|
|
5
|
+
return useCallback((...args) => {
|
|
6
|
+
return callbackRef.current(...args);
|
|
7
|
+
}, []);
|
|
14
8
|
};
|
|
15
|
-
const projByViewInv = new Matrix4();
|
|
16
|
-
function createEvents() {
|
|
17
|
-
return (store) => {
|
|
18
|
-
const { handlePointer } = createEvents$1(store);
|
|
19
|
-
return {
|
|
20
|
-
priority: 1,
|
|
21
|
-
enabled: true,
|
|
22
|
-
compute(event, state) {
|
|
23
|
-
state.pointer.x = event.offsetX / state.size.width * 2 - 1;
|
|
24
|
-
state.pointer.y = 1 - event.offsetY / state.size.height * 2;
|
|
25
|
-
if (state.camera.userData.projByViewInv)
|
|
26
|
-
projByViewInv.fromArray(state.camera.userData.projByViewInv);
|
|
27
|
-
state.raycaster.camera = state.camera;
|
|
28
|
-
state.raycaster.ray.origin.setScalar(0).applyMatrix4(projByViewInv);
|
|
29
|
-
state.raycaster.ray.direction.set(state.pointer.x, state.pointer.y, 1).applyMatrix4(projByViewInv).sub(state.raycaster.ray.origin).normalize();
|
|
30
|
-
},
|
|
31
|
-
connected: void 0,
|
|
32
|
-
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
33
|
-
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
34
|
-
{}
|
|
35
|
-
),
|
|
36
|
-
update: () => {
|
|
37
|
-
var _a;
|
|
38
|
-
const { events, internal } = store.getState();
|
|
39
|
-
if (((_a = internal.lastEvent) == null ? void 0 : _a.current) && events.handlers) {
|
|
40
|
-
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
connect: (target) => {
|
|
44
|
-
var _a;
|
|
45
|
-
const { set, events } = store.getState();
|
|
46
|
-
(_a = events.disconnect) == null ? void 0 : _a.call(events);
|
|
47
|
-
set((state) => ({ events: { ...state.events, connected: target.parentNode } }));
|
|
48
|
-
Object.entries(events.handlers ?? []).forEach(([name, event]) => {
|
|
49
|
-
const [eventName, passive] = DOM_EVENTS[name];
|
|
50
|
-
target.addEventListener(eventName, event, { passive });
|
|
51
|
-
});
|
|
52
|
-
},
|
|
53
|
-
disconnect: () => {
|
|
54
|
-
const { set, events } = store.getState();
|
|
55
|
-
if (events.connected) {
|
|
56
|
-
Object.entries(events.handlers ?? []).forEach(([name, event]) => {
|
|
57
|
-
if (events && events.connected instanceof HTMLElement) {
|
|
58
|
-
const [eventName] = DOM_EVENTS[name];
|
|
59
|
-
events.connected.removeEventListener(eventName, event);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
9
|
export {
|
|
69
|
-
|
|
10
|
+
useFunction
|
|
70
11
|
};
|
|
71
12
|
//# sourceMappingURL=main13.mjs.map
|
package/dist/es/main13.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main13.mjs","sources":["../../src/core/
|
|
1
|
+
{"version":3,"file":"main13.mjs","sources":["../../src/core/use-function.ts"],"sourcesContent":["import { useCallback, useRef } from 'react';\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport const useFunction = <T extends (...args: any[]) => any>(callback: T): T => {\n const callbackRef = useRef(callback);\n callbackRef.current = callback;\n return useCallback((...args: any[]) => {\n return callbackRef.current(...args);\n }, []) as T;\n};\n"],"names":[],"mappings":";AAGa,MAAA,cAAc,CAAoC,aAAmB;AAC1E,QAAA,cAAc,OAAO,QAAQ;AACnC,cAAY,UAAU;AACf,SAAA,YAAY,IAAI,SAAgB;AAC9B,WAAA,YAAY,QAAQ,GAAG,IAAI;AAAA,EACpC,GAAG,CAAE,CAAA;AACP;"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { createEvents as createEvents$1 } from "@react-three/fiber";
|
|
2
|
+
import { Matrix4 } from "three";
|
|
3
|
+
const DOM_EVENTS = {
|
|
4
|
+
onClick: ["click", false],
|
|
5
|
+
onContextMenu: ["contextmenu", false],
|
|
6
|
+
onDoubleClick: ["dblclick", false],
|
|
7
|
+
onWheel: ["wheel", true],
|
|
8
|
+
onPointerDown: ["pointerdown", true],
|
|
9
|
+
onPointerUp: ["pointerup", true],
|
|
10
|
+
onPointerLeave: ["pointerleave", true],
|
|
11
|
+
onPointerMove: ["pointermove", true],
|
|
12
|
+
onPointerCancel: ["pointercancel", true],
|
|
13
|
+
onLostPointerCapture: ["lostpointercapture", true]
|
|
14
|
+
};
|
|
15
|
+
const projByViewInv = new Matrix4();
|
|
16
|
+
function createEvents() {
|
|
17
|
+
return (store) => {
|
|
18
|
+
const { handlePointer } = createEvents$1(store);
|
|
19
|
+
return {
|
|
20
|
+
priority: 1,
|
|
21
|
+
enabled: true,
|
|
22
|
+
compute(event, state) {
|
|
23
|
+
state.pointer.x = event.offsetX / state.size.width * 2 - 1;
|
|
24
|
+
state.pointer.y = 1 - event.offsetY / state.size.height * 2;
|
|
25
|
+
if (state.camera.userData.projByViewInv)
|
|
26
|
+
projByViewInv.fromArray(state.camera.userData.projByViewInv);
|
|
27
|
+
state.raycaster.camera = state.camera;
|
|
28
|
+
state.raycaster.ray.origin.setScalar(0).applyMatrix4(projByViewInv);
|
|
29
|
+
state.raycaster.ray.direction.set(state.pointer.x, state.pointer.y, 1).applyMatrix4(projByViewInv).sub(state.raycaster.ray.origin).normalize();
|
|
30
|
+
},
|
|
31
|
+
connected: void 0,
|
|
32
|
+
handlers: Object.keys(DOM_EVENTS).reduce(
|
|
33
|
+
(acc, key) => ({ ...acc, [key]: handlePointer(key) }),
|
|
34
|
+
{}
|
|
35
|
+
),
|
|
36
|
+
update: () => {
|
|
37
|
+
var _a;
|
|
38
|
+
const { events, internal } = store.getState();
|
|
39
|
+
if (((_a = internal.lastEvent) == null ? void 0 : _a.current) && events.handlers) {
|
|
40
|
+
events.handlers.onPointerMove(internal.lastEvent.current);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
connect: (target) => {
|
|
44
|
+
var _a;
|
|
45
|
+
const { set, events } = store.getState();
|
|
46
|
+
(_a = events.disconnect) == null ? void 0 : _a.call(events);
|
|
47
|
+
set((state) => ({ events: { ...state.events, connected: target.parentNode } }));
|
|
48
|
+
Object.entries(events.handlers ?? []).forEach(([name, event]) => {
|
|
49
|
+
const [eventName, passive] = DOM_EVENTS[name];
|
|
50
|
+
target.addEventListener(eventName, event, { passive });
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
disconnect: () => {
|
|
54
|
+
const { set, events } = store.getState();
|
|
55
|
+
if (events.connected) {
|
|
56
|
+
Object.entries(events.handlers ?? []).forEach(([name, event]) => {
|
|
57
|
+
if (events && events.connected instanceof HTMLElement) {
|
|
58
|
+
const [eventName] = DOM_EVENTS[name];
|
|
59
|
+
events.connected.removeEventListener(eventName, event);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
set((state) => ({ events: { ...state.events, connected: void 0 } }));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
createEvents
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=main14.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main14.mjs","sources":["../../src/core/create-events.ts"],"sourcesContent":["import { Events, RenderProps, RootState, createEvents as createFiberEvents } from \"@react-three/fiber\";\nimport { Matrix4 } from \"three\";\nimport { UseBoundStore } from \"zustand\";\n\ntype DomEvent = PointerEvent | MouseEvent | WheelEvent;\n\nconst DOM_EVENTS = {\n onClick: [\"click\", false],\n onContextMenu: [\"contextmenu\", false],\n onDoubleClick: [\"dblclick\", false],\n onWheel: [\"wheel\", true],\n onPointerDown: [\"pointerdown\", true],\n onPointerUp: [\"pointerup\", true],\n onPointerLeave: [\"pointerleave\", true],\n onPointerMove: [\"pointermove\", true],\n onPointerCancel: [\"pointercancel\", true],\n onLostPointerCapture: [\"lostpointercapture\", true],\n} as const;\n\nconst projByViewInv = new Matrix4()\n\n/** ThreeLayer event manager for MapLibre and Mapbox */\nexport function createEvents(): RenderProps<HTMLCanvasElement>[\"events\"] {\n return (store: UseBoundStore<RootState>) => {\n const { handlePointer } = createFiberEvents(store);\n\n return {\n priority: 1,\n enabled: true,\n compute(event: DomEvent, state: RootState) {\n\n state.pointer.x = (event.offsetX / state.size.width) * 2 - 1;\n state.pointer.y = 1 - (event.offsetY / state.size.height) * 2;\n\n if (state.camera.userData.projByViewInv) projByViewInv.fromArray(state.camera.userData.projByViewInv);\n\n state.raycaster.camera = state.camera;\n state.raycaster.ray.origin.setScalar(0).applyMatrix4(projByViewInv);\n state.raycaster.ray.direction\n .set(state.pointer.x, state.pointer.y, 1)\n .applyMatrix4(projByViewInv)\n .sub(state.raycaster.ray.origin)\n .normalize();\n },\n connected: undefined,\n handlers: Object.keys(DOM_EVENTS).reduce(\n (acc, key) => ({ ...acc, [key]: handlePointer(key) }),\n {}\n ) as unknown as Events,\n update: () => {\n const { events, internal } = store.getState();\n if (internal.lastEvent?.current && events.handlers) {\n events.handlers.onPointerMove(internal.lastEvent.current);\n }\n },\n connect: (target: HTMLElement) => {\n const { set, events } = store.getState();\n events.disconnect?.();\n set((state) => ({ events: { ...state.events, connected: target.parentNode } }));\n Object.entries(events.handlers ?? []).forEach(([name, event]) => {\n const [eventName, passive] = DOM_EVENTS[name as keyof typeof DOM_EVENTS];\n target.addEventListener(eventName, event, { passive });\n });\n },\n disconnect: () => {\n const { set, events } = store.getState();\n if (events.connected) {\n Object.entries(events.handlers ?? []).forEach(([name, event]) => {\n if (events && events.connected instanceof HTMLElement) {\n const [eventName] = DOM_EVENTS[name as keyof typeof DOM_EVENTS];\n events.connected.removeEventListener(eventName, event);\n }\n });\n set((state) => ({ events: { ...state.events, connected: undefined } }));\n }\n },\n };\n };\n}\n"],"names":["createFiberEvents"],"mappings":";;AAMA,MAAM,aAAa;AAAA,EACjB,SAAS,CAAC,SAAS,KAAK;AAAA,EACxB,eAAe,CAAC,eAAe,KAAK;AAAA,EACpC,eAAe,CAAC,YAAY,KAAK;AAAA,EACjC,SAAS,CAAC,SAAS,IAAI;AAAA,EACvB,eAAe,CAAC,eAAe,IAAI;AAAA,EACnC,aAAa,CAAC,aAAa,IAAI;AAAA,EAC/B,gBAAgB,CAAC,gBAAgB,IAAI;AAAA,EACrC,eAAe,CAAC,eAAe,IAAI;AAAA,EACnC,iBAAiB,CAAC,iBAAiB,IAAI;AAAA,EACvC,sBAAsB,CAAC,sBAAsB,IAAI;AACnD;AAEA,MAAM,gBAAgB,IAAI;AAGnB,SAAS,eAAyD;AACvE,SAAO,CAAC,UAAoC;AAC1C,UAAM,EAAE,cAAA,IAAkBA,eAAkB,KAAK;AAE1C,WAAA;AAAA,MACL,UAAU;AAAA,MACV,SAAS;AAAA,MACT,QAAQ,OAAiB,OAAkB;AAEzC,cAAM,QAAQ,IAAK,MAAM,UAAU,MAAM,KAAK,QAAS,IAAI;AAC3D,cAAM,QAAQ,IAAI,IAAK,MAAM,UAAU,MAAM,KAAK,SAAU;AAExD,YAAA,MAAM,OAAO,SAAS;AAAe,wBAAc,UAAU,MAAM,OAAO,SAAS,aAAa;AAE9F,cAAA,UAAU,SAAS,MAAM;AAC/B,cAAM,UAAU,IAAI,OAAO,UAAU,CAAC,EAAE,aAAa,aAAa;AAC5D,cAAA,UAAU,IAAI,UACjB,IAAI,MAAM,QAAQ,GAAG,MAAM,QAAQ,GAAG,CAAC,EACvC,aAAa,aAAa,EAC1B,IAAI,MAAM,UAAU,IAAI,MAAM,EAC9B;MACL;AAAA,MACA,WAAW;AAAA,MACX,UAAU,OAAO,KAAK,UAAU,EAAE;AAAA,QAChC,CAAC,KAAK,SAAS,EAAE,GAAG,KAAK,CAAC,GAAG,GAAG,cAAc,GAAG;QACjD,CAAC;AAAA,MACH;AAAA,MACA,QAAQ,MAAM;;AACZ,cAAM,EAAE,QAAQ,SAAS,IAAI,MAAM,SAAS;AAC5C,cAAI,cAAS,cAAT,mBAAoB,YAAW,OAAO,UAAU;AAClD,iBAAO,SAAS,cAAc,SAAS,UAAU,OAAO;AAAA,QAC1D;AAAA,MACF;AAAA,MACA,SAAS,CAAC,WAAwB;;AAChC,cAAM,EAAE,KAAK,OAAO,IAAI,MAAM,SAAS;AACvC,qBAAO,eAAP;AACA,YAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,GAAG,MAAM,QAAQ,WAAW,OAAO,WAAW,EAAA,EAAI;AACvE,eAAA,QAAQ,OAAO,YAAY,CAAA,CAAE,EAAE,QAAQ,CAAC,CAAC,MAAM,KAAK,MAAM;AAC/D,gBAAM,CAAC,WAAW,OAAO,IAAI,WAAW,IAA+B;AACvE,iBAAO,iBAAiB,WAAW,OAAO,EAAE,QAAS,CAAA;AAAA,QAAA,CACtD;AAAA,MACH;AAAA,MACA,YAAY,MAAM;AAChB,cAAM,EAAE,KAAK,OAAO,IAAI,MAAM,SAAS;AACvC,YAAI,OAAO,WAAW;AACb,iBAAA,QAAQ,OAAO,YAAY,CAAA,CAAE,EAAE,QAAQ,CAAC,CAAC,MAAM,KAAK,MAAM;AAC3D,gBAAA,UAAU,OAAO,qBAAqB,aAAa;AACrD,oBAAM,CAAC,SAAS,IAAI,WAAW,IAA+B;AACvD,qBAAA,UAAU,oBAAoB,WAAW,KAAK;AAAA,YACvD;AAAA,UAAA,CACD;AACG,cAAA,CAAC,WAAW,EAAE,QAAQ,EAAE,GAAG,MAAM,QAAQ,WAAW,OAAU,EAAA,EAAI;AAAA,QACxE;AAAA,MACF;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
package/dist/es/main2.mjs
CHANGED
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { Layer } from "react-map-gl";
|
|
6
|
-
import * as THREE from "three";
|
|
7
|
-
import { useCanvas } from "./main4.mjs";
|
|
8
|
-
extend(THREE);
|
|
9
|
-
const fromLngLat = MercatorCoordinate.fromLngLat;
|
|
10
|
-
const Canvas = memo((props) => {
|
|
11
|
-
const { id, onAdd, onRemove, render } = useCanvas({ ...props, fromLngLat });
|
|
12
|
-
return /* @__PURE__ */ jsx(
|
|
13
|
-
Layer,
|
|
14
|
-
{
|
|
15
|
-
id,
|
|
16
|
-
type: "custom",
|
|
17
|
-
renderingMode: "3d",
|
|
18
|
-
onAdd,
|
|
19
|
-
onRemove,
|
|
20
|
-
render
|
|
21
|
-
}
|
|
22
|
-
);
|
|
1
|
+
import { useThree } from "@react-three/fiber";
|
|
2
|
+
const useMap = () => useThree((s) => {
|
|
3
|
+
var _a;
|
|
4
|
+
return (_a = s.r3m) == null ? void 0 : _a.map;
|
|
23
5
|
});
|
|
24
6
|
export {
|
|
25
|
-
|
|
7
|
+
useMap
|
|
26
8
|
};
|
|
27
9
|
//# sourceMappingURL=main2.mjs.map
|
package/dist/es/main2.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main2.mjs","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"main2.mjs","sources":["../../src/api/use-map.ts"],"sourcesContent":["import { useThree } from \"@react-three/fiber\";\nimport { MapInstance } from \"../core/generic-map\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useMap = <T extends MapInstance = MapInstance>(): T | undefined => useThree((s) => (s as any as { r3m?: {map: T}}).r3m?.map);"],"names":[],"mappings":";AAIO,MAAM,SAAS,MAA0D,SAAS,CAAC,MAAO;;AAAA,iBAA+B,QAA/B,mBAAoC;AAAA,CAAG;"}
|
package/dist/es/main3.mjs
CHANGED
|
@@ -1,56 +1,27 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/* @__PURE__ */ jsx(RenderAtCoords, { r3m, origin }),
|
|
24
|
-
children
|
|
25
|
-
] }), scene, { events: { priority: 2 } }) });
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { extend } from "@react-three/fiber";
|
|
3
|
+
import { MercatorCoordinate } from "mapbox-gl";
|
|
4
|
+
import { memo } from "react";
|
|
5
|
+
import { Layer } from "react-map-gl";
|
|
6
|
+
import * as THREE from "three";
|
|
7
|
+
import { useCanvas } from "./main5.mjs";
|
|
8
|
+
extend(THREE);
|
|
9
|
+
const fromLngLat = MercatorCoordinate.fromLngLat;
|
|
10
|
+
const Canvas = memo((props) => {
|
|
11
|
+
const { id, onAdd, onRemove, render } = useCanvas({ ...props, fromLngLat });
|
|
12
|
+
return /* @__PURE__ */ jsx(
|
|
13
|
+
Layer,
|
|
14
|
+
{
|
|
15
|
+
id,
|
|
16
|
+
type: "custom",
|
|
17
|
+
renderingMode: "3d",
|
|
18
|
+
onAdd,
|
|
19
|
+
onRemove,
|
|
20
|
+
render
|
|
21
|
+
}
|
|
22
|
+
);
|
|
26
23
|
});
|
|
27
|
-
Coordinates.displayName = "Coordinates";
|
|
28
|
-
function RenderAtCoords({ r3m, origin }) {
|
|
29
|
-
const { gl, scene, set } = useThree();
|
|
30
|
-
const cameraRef = useRef(null);
|
|
31
|
-
useFrame(() => {
|
|
32
|
-
if (!r3m.mapCamMx)
|
|
33
|
-
return;
|
|
34
|
-
if (!cameraRef.current)
|
|
35
|
-
return;
|
|
36
|
-
syncCamera(cameraRef.current, origin, r3m.mapCamMx);
|
|
37
|
-
gl.render(scene, cameraRef.current);
|
|
38
|
-
});
|
|
39
|
-
useLayoutEffect(() => {
|
|
40
|
-
if (!cameraRef.current)
|
|
41
|
-
return;
|
|
42
|
-
set({
|
|
43
|
-
invalidate: () => {
|
|
44
|
-
if (!r3m.map)
|
|
45
|
-
return;
|
|
46
|
-
r3m.map.triggerRepaint();
|
|
47
|
-
},
|
|
48
|
-
camera: cameraRef.current
|
|
49
|
-
});
|
|
50
|
-
}, [set, r3m]);
|
|
51
|
-
return /* @__PURE__ */ jsx("perspectiveCamera", { ref: cameraRef });
|
|
52
|
-
}
|
|
53
24
|
export {
|
|
54
|
-
|
|
25
|
+
Canvas
|
|
55
26
|
};
|
|
56
27
|
//# sourceMappingURL=main3.mjs.map
|
package/dist/es/main3.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main3.mjs","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"main3.mjs","sources":["../../src/mapbox/canvas.tsx"],"sourcesContent":["import { extend } from \"@react-three/fiber\";\nimport { MercatorCoordinate } from \"mapbox-gl\";\nimport { memo } from \"react\";\nimport { Layer } from \"react-map-gl\";\nimport * as THREE from \"three\";\nimport { CanvasProps } from \"../api/canvas-props\";\nimport { useCanvas } from \"../core/use-canvas\";\n\nextend(THREE);\n\nconst fromLngLat = MercatorCoordinate.fromLngLat\n\n/** react`-three-fiber` canvas inside `Mapbox` */\nexport const Canvas = memo<CanvasProps>((props) => {\n\n const { id, onAdd, onRemove, render } = useCanvas({ ...props, fromLngLat });\n\n return <Layer\n id={id}\n type=\"custom\"\n renderingMode=\"3d\"\n onAdd={onAdd}\n onRemove={onRemove}\n render={render}\n />\n})"],"names":[],"mappings":";;;;;;;AAQA,OAAO,KAAK;AAEZ,MAAM,aAAa,mBAAmB;AAGzB,MAAA,SAAS,KAAkB,CAAC,UAAU;AAE3C,QAAA,EAAE,IAAI,OAAO,UAAU,OAAA,IAAW,UAAU,EAAE,GAAG,OAAO,WAAA,CAAY;AAEnE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACN;AAAA,MACA,MAAK;AAAA,MACL,eAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EAAA;AAEJ,CAAC;"}
|