react-three-map 1.0.0-next.0 → 1.0.0-next.2
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 +12 -0
- package/dist/cjs/main.js +41 -1263
- package/dist/es/main10.mjs +10 -71
- package/dist/es/main10.mjs.map +1 -1
- package/dist/es/main11.mjs +35 -12
- package/dist/es/main11.mjs.map +1 -1
- package/dist/es/main12.mjs +13 -12
- package/dist/es/main12.mjs.map +1 -1
- package/dist/es/main13.mjs +24 -42
- package/dist/es/main13.mjs.map +1 -1
- package/dist/es/main14.mjs +4 -13
- package/dist/es/main14.mjs.map +1 -1
- package/dist/es/main15.mjs +31 -22
- package/dist/es/main15.mjs.map +1 -1
- package/dist/es/main16.mjs +23 -87
- package/dist/es/main16.mjs.map +1 -1
- package/dist/es/main17.mjs +94 -14
- package/dist/es/main17.mjs.map +1 -1
- package/dist/es/main18.mjs +58 -22
- package/dist/es/main18.mjs.map +1 -1
- package/dist/es/main19.mjs +20 -27
- package/dist/es/main19.mjs.map +1 -1
- package/dist/es/main20.mjs +23 -8
- package/dist/es/main20.mjs.map +1 -1
- package/dist/es/main21.mjs +16 -34
- package/dist/es/main21.mjs.map +1 -1
- package/dist/es/main22.mjs +80 -12
- package/dist/es/main22.mjs.map +1 -1
- package/dist/es/main3.mjs +4 -13
- package/dist/es/main3.mjs.map +1 -1
- package/dist/es/main4.mjs +3 -3
- package/dist/es/main5.mjs +1 -1
- package/dist/es/main6.mjs +1 -1
- package/dist/es/main7.mjs +1 -1
- package/dist/es/main8.mjs +20 -87
- package/dist/es/main8.mjs.map +1 -1
- package/dist/es/main9.mjs +24 -80
- package/dist/es/main9.mjs.map +1 -1
- package/dist/maplibre/cjs/main.js +0 -4
- package/dist/maplibre/es/main18.mjs +0 -4
- package/dist/maplibre/es/main18.mjs.map +1 -1
- package/package.json +1 -1
- package/stories/package.json +1 -1
- package/stories/yarn.lock +19 -14
- package/dist/es/main23.mjs +0 -26
- package/dist/es/main23.mjs.map +0 -1
- package/dist/es/main24.mjs +0 -5
- package/dist/es/main24.mjs.map +0 -1
- package/dist/es/main25.mjs +0 -33
- package/dist/es/main25.mjs.map +0 -1
- package/dist/es/main26.mjs +0 -27
- package/dist/es/main26.mjs.map +0 -1
- package/dist/es/main27.mjs +0 -98
- package/dist/es/main27.mjs.map +0 -1
- package/dist/es/main28.mjs +0 -66
- package/dist/es/main28.mjs.map +0 -1
- package/dist/es/main29.mjs +0 -23
- package/dist/es/main29.mjs.map +0 -1
- package/dist/es/main30.mjs +0 -27
- package/dist/es/main30.mjs.map +0 -1
- package/dist/es/main31.mjs +0 -19
- package/dist/es/main31.mjs.map +0 -1
- package/dist/es/main32.mjs +0 -83
- package/dist/es/main32.mjs.map +0 -1
- package/dist/es/main33.mjs +0 -501
- package/dist/es/main33.mjs.map +0 -1
- package/dist/es/main34.mjs +0 -90
- package/dist/es/main34.mjs.map +0 -1
- package/dist/es/main35.mjs +0 -6
- package/dist/es/main35.mjs.map +0 -1
- package/dist/es/main36.mjs +0 -26
- package/dist/es/main36.mjs.map +0 -1
- package/dist/es/main37.mjs +0 -19
- package/dist/es/main37.mjs.map +0 -1
- package/dist/es/main38.mjs +0 -50
- package/dist/es/main38.mjs.map +0 -1
- package/dist/es/main39.mjs +0 -31
- package/dist/es/main39.mjs.map +0 -1
- package/dist/es/main40.mjs +0 -9
- package/dist/es/main40.mjs.map +0 -1
- package/dist/es/main41.mjs +0 -62
- package/dist/es/main41.mjs.map +0 -1
- package/dist/es/main42.mjs +0 -42
- package/dist/es/main42.mjs.map +0 -1
package/dist/es/main7.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MathUtils } from "three";
|
|
2
|
-
import { earthRadius } from "./
|
|
2
|
+
import { earthRadius } from "./main14.mjs";
|
|
3
3
|
function vector3ToCoords(position, origin) {
|
|
4
4
|
const [x, y, z] = position;
|
|
5
5
|
const latitude = origin.latitude + -z / earthRadius * MathUtils.RAD2DEG;
|
package/dist/es/main8.mjs
CHANGED
|
@@ -1,93 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const [mapInstance, setMapInstance] = useState(null);
|
|
12
|
-
const containerRef = useRef();
|
|
13
|
-
const { current: contextValue } = useRef({ mapLib: null, map: null });
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const mapLib = props.mapLib;
|
|
16
|
-
let isMounted = true;
|
|
17
|
-
let mapbox;
|
|
18
|
-
Promise.resolve(mapLib || import("mapbox-gl")).then((module) => {
|
|
19
|
-
if (!isMounted) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (!module) {
|
|
23
|
-
throw new Error("Invalid mapLib");
|
|
24
|
-
}
|
|
25
|
-
const mapboxgl = "Map" in module ? module : module.default;
|
|
26
|
-
if (!mapboxgl.Map) {
|
|
27
|
-
throw new Error("Invalid mapLib");
|
|
28
|
-
}
|
|
29
|
-
setGlobals(mapboxgl, props);
|
|
30
|
-
if (!mapboxgl.supported || mapboxgl.supported(props)) {
|
|
31
|
-
if (props.reuseMaps) {
|
|
32
|
-
mapbox = Mapbox.reuse(props, containerRef.current);
|
|
33
|
-
}
|
|
34
|
-
if (!mapbox) {
|
|
35
|
-
mapbox = new Mapbox(mapboxgl.Map, props, containerRef.current);
|
|
36
|
-
}
|
|
37
|
-
contextValue.map = createRef(mapbox);
|
|
38
|
-
contextValue.mapLib = mapboxgl;
|
|
39
|
-
setMapInstance(mapbox);
|
|
40
|
-
mountedMapsContext == null ? void 0 : mountedMapsContext.onMapMount(contextValue.map, props.id);
|
|
41
|
-
} else {
|
|
42
|
-
throw new Error("Map is not supported by this browser");
|
|
43
|
-
}
|
|
44
|
-
}).catch((error) => {
|
|
45
|
-
const { onError } = props;
|
|
46
|
-
if (onError) {
|
|
47
|
-
onError({
|
|
48
|
-
type: "error",
|
|
49
|
-
target: null,
|
|
50
|
-
error
|
|
51
|
-
});
|
|
52
|
-
} else {
|
|
53
|
-
console.error(error);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return () => {
|
|
57
|
-
isMounted = false;
|
|
58
|
-
if (mapbox) {
|
|
59
|
-
mountedMapsContext == null ? void 0 : mountedMapsContext.onMapUnmount(props.id);
|
|
60
|
-
if (props.reuseMaps) {
|
|
61
|
-
mapbox.recycle();
|
|
62
|
-
} else {
|
|
63
|
-
mapbox.destroy();
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
}, []);
|
|
68
|
-
useIsomorphicLayoutEffect(() => {
|
|
69
|
-
if (mapInstance) {
|
|
70
|
-
mapInstance.setProps(props);
|
|
71
|
-
}
|
|
1
|
+
import { useCoordsToMatrix } from "./main12.mjs";
|
|
2
|
+
import { useRender } from "./main16.mjs";
|
|
3
|
+
import { useRoot } from "./main17.mjs";
|
|
4
|
+
function useCanvasInLayer(props, fromLngLat, map) {
|
|
5
|
+
const { latitude, longitude, altitude, frameloop } = props;
|
|
6
|
+
const origin = useCoordsToMatrix({
|
|
7
|
+
latitude,
|
|
8
|
+
longitude,
|
|
9
|
+
altitude,
|
|
10
|
+
fromLngLat
|
|
72
11
|
});
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
12
|
+
const { onRemove, useThree, r3m } = useRoot(fromLngLat, map, props);
|
|
13
|
+
const render = useRender({ origin, frameloop, useThree, map, r3m });
|
|
14
|
+
return {
|
|
15
|
+
id: props.id,
|
|
16
|
+
beforeId: props.beforeId,
|
|
17
|
+
onRemove,
|
|
18
|
+
render,
|
|
19
|
+
type: "custom",
|
|
20
|
+
renderingMode: "3d"
|
|
82
21
|
};
|
|
83
|
-
return React.createElement("div", { id: props.id, ref: containerRef, style }, mapInstance && React.createElement(
|
|
84
|
-
MapContext.Provider,
|
|
85
|
-
{ value: contextValue },
|
|
86
|
-
React.createElement("div", { "mapboxgl-children": "", style: CHILD_CONTAINER_STYLE }, props.children)
|
|
87
|
-
));
|
|
88
22
|
}
|
|
89
|
-
React.forwardRef(_Map);
|
|
90
23
|
export {
|
|
91
|
-
|
|
24
|
+
useCanvasInLayer
|
|
92
25
|
};
|
|
93
26
|
//# sourceMappingURL=main8.mjs.map
|
package/dist/es/main8.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main8.mjs","sources":["../../
|
|
1
|
+
{"version":3,"file":"main8.mjs","sources":["../../src/core/canvas-in-layer/use-canvas-in-layer.tsx"],"sourcesContent":["import { CanvasProps } from \"../../api/canvas-props\";\nimport { FromLngLat, MapInstance } from \"../generic-map\";\nimport { useCoordsToMatrix } from \"../use-coords-to-matrix\";\nimport { useRender } from \"./use-render\";\nimport { useRoot } from \"./use-root\";\n\n/** get all the properties that you need to render as a map `<Layer>` */\nexport function useCanvasInLayer(props: CanvasProps,fromLngLat: FromLngLat, map: MapInstance) {\n\n const {latitude, longitude, altitude, frameloop } = props;\n\n const origin = useCoordsToMatrix({\n latitude, longitude, altitude, fromLngLat,\n });\n\n const { onRemove, useThree, r3m } = useRoot(fromLngLat, map, props);\n \n const render = useRender({origin, frameloop, useThree, map, r3m});\n \n return {\n id: props.id,\n beforeId: props.beforeId,\n onRemove,\n render,\n type: 'custom',\n renderingMode: '3d'\n } as const\n\n}"],"names":[],"mappings":";;;AAOgB,SAAA,iBAAiB,OAAmB,YAAwB,KAAkB;AAE5F,QAAM,EAAC,UAAU,WAAW,UAAU,cAAc;AAElD,QAAM,SAAS,kBAAkB;AAAA,IAC/B;AAAA,IAAU;AAAA,IAAW;AAAA,IAAU;AAAA,EAAA,CAChC;AAEK,QAAA,EAAE,UAAU,UAAU,IAAA,IAAQ,QAAQ,YAAY,KAAK,KAAK;AAE5D,QAAA,SAAS,UAAU,EAAC,QAAQ,WAAW,UAAU,KAAK,KAAI;AAEzD,SAAA;AAAA,IACL,IAAI,MAAM;AAAA,IACV,UAAU,MAAM;AAAA,IAChB;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,eAAe;AAAA,EAAA;AAGrB;"}
|
package/dist/es/main9.mjs
CHANGED
|
@@ -1,86 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { memo,
|
|
1
|
+
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useState, useEffect } from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
const options = {
|
|
19
|
-
...props,
|
|
20
|
-
element: hasChildren ? document.createElement("div") : null
|
|
21
|
-
};
|
|
22
|
-
const mk = new mapLib.Marker(options);
|
|
23
|
-
mk.setLngLat([props.longitude, props.latitude]);
|
|
24
|
-
mk.getElement().addEventListener("click", (e) => {
|
|
25
|
-
var _a, _b;
|
|
26
|
-
(_b = (_a = thisRef.current.props).onClick) == null ? void 0 : _b.call(_a, {
|
|
27
|
-
type: "click",
|
|
28
|
-
target: mk,
|
|
29
|
-
originalEvent: e
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
mk.on("dragstart", (e) => {
|
|
33
|
-
var _a, _b;
|
|
34
|
-
const evt = e;
|
|
35
|
-
evt.lngLat = marker.getLngLat();
|
|
36
|
-
(_b = (_a = thisRef.current.props).onDragStart) == null ? void 0 : _b.call(_a, evt);
|
|
37
|
-
});
|
|
38
|
-
mk.on("drag", (e) => {
|
|
39
|
-
var _a, _b;
|
|
40
|
-
const evt = e;
|
|
41
|
-
evt.lngLat = marker.getLngLat();
|
|
42
|
-
(_b = (_a = thisRef.current.props).onDrag) == null ? void 0 : _b.call(_a, evt);
|
|
43
|
-
});
|
|
44
|
-
mk.on("dragend", (e) => {
|
|
45
|
-
var _a, _b;
|
|
46
|
-
const evt = e;
|
|
47
|
-
evt.lngLat = marker.getLngLat();
|
|
48
|
-
(_b = (_a = thisRef.current.props).onDragEnd) == null ? void 0 : _b.call(_a, evt);
|
|
49
|
-
});
|
|
50
|
-
return mk;
|
|
51
|
-
}, []);
|
|
4
|
+
import { CanvasPortal } from "./main18.mjs";
|
|
5
|
+
const InitCanvasFC = memo((props) => {
|
|
6
|
+
const canvas = props.map.getCanvas();
|
|
7
|
+
const [el] = useState(() => {
|
|
8
|
+
const el2 = document.createElement("div");
|
|
9
|
+
el2.style.position = "absolute";
|
|
10
|
+
el2.style.top = "0";
|
|
11
|
+
el2.style.bottom = "0";
|
|
12
|
+
el2.style.left = "0";
|
|
13
|
+
el2.style.right = "0";
|
|
14
|
+
el2.style.pointerEvents = "none";
|
|
15
|
+
return el2;
|
|
16
|
+
});
|
|
52
17
|
useEffect(() => {
|
|
53
|
-
|
|
18
|
+
const parent = canvas.parentElement;
|
|
19
|
+
parent.appendChild(el);
|
|
54
20
|
return () => {
|
|
55
|
-
|
|
21
|
+
parent.removeChild(el);
|
|
56
22
|
};
|
|
57
23
|
}, []);
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
marker.setLngLat([longitude, latitude]);
|
|
65
|
-
}
|
|
66
|
-
if (offset && !arePointsEqual(marker.getOffset(), offset)) {
|
|
67
|
-
marker.setOffset(offset);
|
|
68
|
-
}
|
|
69
|
-
if (marker.isDraggable() !== draggable) {
|
|
70
|
-
marker.setDraggable(draggable);
|
|
71
|
-
}
|
|
72
|
-
if (marker.getRotation() !== rotation) {
|
|
73
|
-
marker.setRotation(rotation);
|
|
74
|
-
}
|
|
75
|
-
if (marker.getRotationAlignment() !== rotationAlignment) {
|
|
76
|
-
marker.setRotationAlignment(rotationAlignment);
|
|
77
|
-
}
|
|
78
|
-
if (marker.getPitchAlignment() !== pitchAlignment) {
|
|
79
|
-
marker.setPitchAlignment(pitchAlignment);
|
|
80
|
-
}
|
|
81
|
-
if (marker.getPopup() !== popup) {
|
|
82
|
-
marker.setPopup(popup);
|
|
83
|
-
}
|
|
84
|
-
return createPortal(props.children, marker.getElement());
|
|
85
|
-
}));
|
|
24
|
+
return /* @__PURE__ */ jsx(Fragment, { children: createPortal(/* @__PURE__ */ jsx(CanvasPortal, { ...props }), el) });
|
|
25
|
+
});
|
|
26
|
+
InitCanvasFC.displayName = "InitCanvasFC";
|
|
27
|
+
export {
|
|
28
|
+
InitCanvasFC
|
|
29
|
+
};
|
|
86
30
|
//# sourceMappingURL=main9.mjs.map
|
package/dist/es/main9.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main9.mjs","sources":["../../
|
|
1
|
+
{"version":3,"file":"main9.mjs","sources":["../../src/core/canvas-overlay/init-canvas-fc.tsx"],"sourcesContent":["import { memo, useEffect, useState } from \"react\";\nimport { createPortal } from 'react-dom';\nimport { Matrix4Tuple } from \"three\";\nimport { CanvasProps } from \"../../api/canvas-props\";\nimport { FromLngLat, MapInstance } from \"../generic-map\";\nimport { CanvasPortal } from \"./canvas-portal\";\n\ninterface InitCanvasFCProps extends CanvasProps {\n map: MapInstance,\n setOnRender: (callback: () => (mx: Matrix4Tuple) => void) => void,\n frameloop?: 'always' | 'demand',\n fromLngLat: FromLngLat,\n}\nexport const InitCanvasFC = memo<InitCanvasFCProps>((props) => {\n const canvas = props.map.getCanvas() // eslint-disable-line @typescript-eslint/no-non-null-assertion\n\n const [el] = useState(() => {\n const el = document.createElement('div');\n el.style.position = 'absolute';\n el.style.top = '0';\n el.style.bottom = '0';\n el.style.left = '0';\n el.style.right = '0';\n el.style.pointerEvents = 'none';\n return el\n })\n\n useEffect(() => {\n const parent = canvas.parentElement!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n parent.appendChild(el);\n return () => {\n parent.removeChild(el);\n }\n }, []) // eslint-disable-line react-hooks/exhaustive-deps\n return <>\n {createPortal((\n <CanvasPortal {...props} />\n ), el)}\n </>\n})\nInitCanvasFC.displayName = 'InitCanvasFC';\n"],"names":["el"],"mappings":";;;;AAaa,MAAA,eAAe,KAAwB,CAAC,UAAU;AACvD,QAAA,SAAS,MAAM,IAAI,UAAU;AAEnC,QAAM,CAAC,EAAE,IAAI,SAAS,MAAM;AACpBA,UAAAA,MAAK,SAAS,cAAc,KAAK;AACvCA,QAAG,MAAM,WAAW;AACpBA,QAAG,MAAM,MAAM;AACfA,QAAG,MAAM,SAAS;AAClBA,QAAG,MAAM,OAAO;AAChBA,QAAG,MAAM,QAAQ;AACjBA,QAAG,MAAM,gBAAgB;AAClBA,WAAAA;AAAAA,EAAA,CACR;AAED,YAAU,MAAM;AACd,UAAM,SAAS,OAAO;AACtB,WAAO,YAAY,EAAE;AACrB,WAAO,MAAM;AACX,aAAO,YAAY,EAAE;AAAA,IAAA;AAAA,EAEzB,GAAG,CAAE,CAAA;AACE,SAAA,oBAAA,UAAA,EACJ,uBACE,oBAAA,cAAA,EAAc,GAAG,MAAO,CAAA,GACxB,EAAE,EACP,CAAA;AACF,CAAC;AACD,aAAa,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main18.mjs","sources":["../../../src/core/canvas-overlay/canvas-portal.tsx"],"sourcesContent":["import { Canvas } from \"@react-three/fiber\";\nimport { memo, useState } from \"react\";\nimport { Matrix4Tuple } from \"three\";\nimport { CanvasProps } from \"../../api/canvas-props\";\nimport { events } from \"../events\";\nimport { FromLngLat, MapInstance } from \"../generic-map\";\nimport { useFunction } from \"../use-function\";\nimport { InitR3M } from \"./init-r3m\";\nimport { SyncCameraFC } from \"./sync-camera-fc\";\n\ninterface CanvasPortalProps extends CanvasProps {\n setOnRender: (callback: () => (mx: Matrix4Tuple) => void) => void,\n map: MapInstance,\n fromLngLat: FromLngLat,\n}\n\nexport const CanvasPortal = memo<CanvasPortalProps>(({\n children, latitude, longitude, altitude,\n setOnRender, map, fromLngLat, ...props\n}) => {\n\n const mapCanvas = map.getCanvas();\n const eventSource = mapCanvas.parentElement!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n\n const [ready, setReady] = useState(false);\n\n const onReady = useFunction(() => {\n setReady(true);\n })\n\n return <Canvas\n
|
|
1
|
+
{"version":3,"file":"main18.mjs","sources":["../../../src/core/canvas-overlay/canvas-portal.tsx"],"sourcesContent":["import { Canvas } from \"@react-three/fiber\";\nimport { memo, useState } from \"react\";\nimport { Matrix4Tuple } from \"three\";\nimport { CanvasProps } from \"../../api/canvas-props\";\nimport { events } from \"../events\";\nimport { FromLngLat, MapInstance } from \"../generic-map\";\nimport { useFunction } from \"../use-function\";\nimport { InitR3M } from \"./init-r3m\";\nimport { SyncCameraFC } from \"./sync-camera-fc\";\n\ninterface CanvasPortalProps extends CanvasProps {\n setOnRender: (callback: () => (mx: Matrix4Tuple) => void) => void,\n map: MapInstance,\n fromLngLat: FromLngLat,\n}\n\nexport const CanvasPortal = memo<CanvasPortalProps>(({\n children, latitude, longitude, altitude,\n setOnRender, map, fromLngLat, ...props\n}) => {\n\n const mapCanvas = map.getCanvas();\n const eventSource = mapCanvas.parentElement!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n\n const [ready, setReady] = useState(false);\n\n const onReady = useFunction(() => {\n setReady(true);\n })\n\n return <Canvas\n events={events}\n eventSource={eventSource}\n {...props}\n gl={{ autoClear: false, ...props.gl }}\n >\n <InitR3M\n map={map}\n fromLngLat={fromLngLat}\n latitude={latitude}\n longitude={longitude}\n altitude={altitude}\n />\n <SyncCameraFC\n latitude={latitude}\n longitude={longitude}\n altitude={altitude}\n setOnRender={setOnRender}\n onReady={onReady}\n map={map}\n />\n {ready && children}\n </Canvas>\n})\nCanvasPortal.displayName = 'CanvasPortal';\n"],"names":[],"mappings":";;;;;;;AAgBa,MAAA,eAAe,KAAwB,CAAC;AAAA,EACnD;AAAA,EAAU;AAAA,EAAU;AAAA,EAAW;AAAA,EAC/B;AAAA,EAAa;AAAA,EAAK;AAAA,EAAY,GAAG;AACnC,MAAM;AAEE,QAAA,YAAY,IAAI;AACtB,QAAM,cAAc,UAAU;AAE9B,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,KAAK;AAElC,QAAA,UAAU,YAAY,MAAM;AAChC,aAAS,IAAI;AAAA,EAAA,CACd;AAEM,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACN;AAAA,MACA;AAAA,MACC,GAAG;AAAA,MACJ,IAAI,EAAE,WAAW,OAAO,GAAG,MAAM,GAAG;AAAA,MAEpC,UAAA;AAAA,QAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UAAA;AAAA,QACF;AAAA,QACA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UAAA;AAAA,QACF;AAAA,QACC,SAAS;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAEd,CAAC;AACD,aAAa,cAAc;"}
|
package/package.json
CHANGED
package/stories/package.json
CHANGED
package/stories/yarn.lock
CHANGED
|
@@ -821,16 +821,16 @@
|
|
|
821
821
|
rw "^1.3.3"
|
|
822
822
|
sort-object "^3.0.3"
|
|
823
823
|
|
|
824
|
-
"@maplibre/maplibre-gl-style-spec@^
|
|
825
|
-
version "
|
|
826
|
-
resolved "https://registry.yarnpkg.com/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-
|
|
827
|
-
integrity sha512-
|
|
824
|
+
"@maplibre/maplibre-gl-style-spec@^20.3.1":
|
|
825
|
+
version "20.4.0"
|
|
826
|
+
resolved "https://registry.yarnpkg.com/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-20.4.0.tgz#408339e051fb51e022b40af2235e0beb037937ea"
|
|
827
|
+
integrity sha512-AzBy3095fTFPjDjmWpR2w6HVRAZJ6hQZUCwk5Plz6EyfnfuQW1odeW5i2Ai47Y6TBA2hQnC+azscjBSALpaWgw==
|
|
828
828
|
dependencies:
|
|
829
829
|
"@mapbox/jsonlint-lines-primitives" "~2.0.2"
|
|
830
830
|
"@mapbox/unitbezier" "^0.0.1"
|
|
831
831
|
json-stringify-pretty-compact "^4.0.0"
|
|
832
832
|
minimist "^1.2.8"
|
|
833
|
-
quickselect "^
|
|
833
|
+
quickselect "^2.0.0"
|
|
834
834
|
rw "^1.3.3"
|
|
835
835
|
tinyqueue "^3.0.0"
|
|
836
836
|
|
|
@@ -1452,7 +1452,7 @@
|
|
|
1452
1452
|
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.10.tgz#6dfbf5ea17142f7f9a043809f1cd4c448cb68249"
|
|
1453
1453
|
integrity sha512-Nmh0K3iWQJzniTuPRcJn5hxXkfB1T1pgB89SBig5PlJQU5yocazeu4jATJlaA0GYFKWMqDdvYemoSnF2pXgLVA==
|
|
1454
1454
|
|
|
1455
|
-
"@types/geojson@^7946.0.
|
|
1455
|
+
"@types/geojson@^7946.0.14", "@types/geojson@^7946.0.15":
|
|
1456
1456
|
version "7946.0.16"
|
|
1457
1457
|
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.16.tgz#8ebe53d69efada7044454e3305c19017d97ced2a"
|
|
1458
1458
|
integrity sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==
|
|
@@ -2252,7 +2252,7 @@ draco3d@^1.4.1:
|
|
|
2252
2252
|
resolved "https://registry.yarnpkg.com/draco3d/-/draco3d-1.5.6.tgz#0d570a9792e3a3a9fafbfea065b692940441c626"
|
|
2253
2253
|
integrity sha512-+3NaRjWktb5r61ZFoDejlykPEFKT5N/LkbXsaddlw6xNSXBanUYpFc2AXXpbJDilPHazcSreU/DpQIaxfX0NfQ==
|
|
2254
2254
|
|
|
2255
|
-
earcut@^3.0.0
|
|
2255
|
+
earcut@^3.0.0:
|
|
2256
2256
|
version "3.0.1"
|
|
2257
2257
|
resolved "https://registry.yarnpkg.com/earcut/-/earcut-3.0.1.tgz#f60b3f671c5657cca9d3e131c5527c5dde00ef38"
|
|
2258
2258
|
integrity sha512-0l1/0gOjESMeQyYaK5IDiPNvFeu93Z/cO0TjZh9eZ1vyCtZnA7KMZ8rQggpsJHIbGSdrqYq9OhuveadOVHCshw==
|
|
@@ -3218,10 +3218,10 @@ mapbox-gl@^3.9.4:
|
|
|
3218
3218
|
tinyqueue "^3.0.0"
|
|
3219
3219
|
vt-pbf "^3.1.3"
|
|
3220
3220
|
|
|
3221
|
-
maplibre-gl@^
|
|
3222
|
-
version "
|
|
3223
|
-
resolved "https://registry.yarnpkg.com/maplibre-gl/-/maplibre-gl-
|
|
3224
|
-
integrity sha512-
|
|
3221
|
+
maplibre-gl@^4.7.1:
|
|
3222
|
+
version "4.7.1"
|
|
3223
|
+
resolved "https://registry.yarnpkg.com/maplibre-gl/-/maplibre-gl-4.7.1.tgz#06a524438ee2aafbe8bcd91002a4e01468ea5486"
|
|
3224
|
+
integrity sha512-lgL7XpIwsgICiL82ITplfS7IGwrB1OJIw/pCvprDp2dhmSSEBgmPzYRvwYYYvJGJD7fxUv1Tvpih4nZ6VrLuaA==
|
|
3225
3225
|
dependencies:
|
|
3226
3226
|
"@mapbox/geojson-rewind" "^0.5.2"
|
|
3227
3227
|
"@mapbox/jsonlint-lines-primitives" "^2.0.2"
|
|
@@ -3230,14 +3230,14 @@ maplibre-gl@^5.1.0:
|
|
|
3230
3230
|
"@mapbox/unitbezier" "^0.0.1"
|
|
3231
3231
|
"@mapbox/vector-tile" "^1.3.1"
|
|
3232
3232
|
"@mapbox/whoots-js" "^3.1.0"
|
|
3233
|
-
"@maplibre/maplibre-gl-style-spec" "^
|
|
3234
|
-
"@types/geojson" "^7946.0.
|
|
3233
|
+
"@maplibre/maplibre-gl-style-spec" "^20.3.1"
|
|
3234
|
+
"@types/geojson" "^7946.0.14"
|
|
3235
3235
|
"@types/geojson-vt" "3.2.5"
|
|
3236
3236
|
"@types/mapbox__point-geometry" "^0.1.4"
|
|
3237
3237
|
"@types/mapbox__vector-tile" "^1.3.4"
|
|
3238
3238
|
"@types/pbf" "^3.0.5"
|
|
3239
3239
|
"@types/supercluster" "^7.1.3"
|
|
3240
|
-
earcut "^3.0.
|
|
3240
|
+
earcut "^3.0.0"
|
|
3241
3241
|
geojson-vt "^4.0.2"
|
|
3242
3242
|
gl-matrix "^3.4.3"
|
|
3243
3243
|
global-prefix "^4.0.0"
|
|
@@ -4196,6 +4196,11 @@ queue-microtask@^1.2.2:
|
|
|
4196
4196
|
resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243"
|
|
4197
4197
|
integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==
|
|
4198
4198
|
|
|
4199
|
+
quickselect@^2.0.0:
|
|
4200
|
+
version "2.0.0"
|
|
4201
|
+
resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-2.0.0.tgz#f19680a486a5eefb581303e023e98faaf25dd018"
|
|
4202
|
+
integrity sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==
|
|
4203
|
+
|
|
4199
4204
|
quickselect@^3.0.0:
|
|
4200
4205
|
version "3.0.0"
|
|
4201
4206
|
resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-3.0.0.tgz#a37fc953867d56f095a20ac71c6d27063d2de603"
|
package/dist/es/main23.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { useThree, _roots } from "@react-three/fiber";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { Matrix4 } from "three";
|
|
4
|
-
function useR3M() {
|
|
5
|
-
const r3m = useThree((s) => s.r3m);
|
|
6
|
-
return r3m;
|
|
7
|
-
}
|
|
8
|
-
function useInitR3M(props) {
|
|
9
|
-
const canvas = useThree((s) => s.gl.domElement);
|
|
10
|
-
useState(() => {
|
|
11
|
-
const store = _roots.get(canvas).store;
|
|
12
|
-
initR3M({ ...props, store });
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function initR3M({ store, ...props }) {
|
|
16
|
-
const viewProjMx = new Matrix4().identity().toArray();
|
|
17
|
-
const r3m = { ...props, viewProjMx };
|
|
18
|
-
store.setState({ r3m });
|
|
19
|
-
return r3m;
|
|
20
|
-
}
|
|
21
|
-
export {
|
|
22
|
-
initR3M,
|
|
23
|
-
useInitR3M,
|
|
24
|
-
useR3M
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=main23.mjs.map
|
package/dist/es/main23.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main23.mjs","sources":["../../src/core/use-r3m.ts"],"sourcesContent":["import { RootState, _roots, useThree } from \"@react-three/fiber\";\nimport { useState } from \"react\";\nimport { Matrix4, Matrix4Tuple } from \"three\";\nimport { UseBoundStore } from 'zustand';\nimport { FromLngLat, MapInstance } from \"./generic-map\";\n\nexport interface R3M<T extends MapInstance = MapInstance> {\n /** Map provider */\n map: T,\n /** view projection matrix coming from the map provider */\n viewProjMx: Matrix4Tuple,\n fromLngLat: FromLngLat,\n}\n\nexport function useR3M<T extends MapInstance> () {\n const r3m = useThree(s=>(s as any).r3m) as R3M<T>; // eslint-disable-line @typescript-eslint/no-explicit-any\n return r3m;\n}\n\n/** init `useR3M` hook */\nexport function useInitR3M<T extends MapInstance>(props: {\n map: T; fromLngLat: FromLngLat;\n}) {\n const canvas = useThree(s => s.gl.domElement);\n // to run only once\n useState(()=>{\n const store = _roots.get(canvas)!.store; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n initR3M({...props, store})\n })\n}\n\nexport function initR3M<T extends MapInstance>({store, ...props}: {\n map: T;\n fromLngLat: FromLngLat;\n store: UseBoundStore<RootState>;\n}) {\n const viewProjMx = new Matrix4().identity().toArray();\n const r3m : R3M<T> = { ...props, viewProjMx };\n store.setState({r3m} as any); // eslint-disable-line @typescript-eslint/no-explicit-any\n return r3m;\n}"],"names":[],"mappings":";;;AAcO,SAAS,SAAiC;AAC/C,QAAM,MAAM,SAAS,CAAI,MAAA,EAAU,GAAG;AAC/B,SAAA;AACT;AAGO,SAAS,WAAkC,OAE/C;AACD,QAAM,SAAS,SAAS,CAAK,MAAA,EAAE,GAAG,UAAU;AAE5C,WAAS,MAAI;AACX,UAAM,QAAQ,OAAO,IAAI,MAAM,EAAG;AAClC,YAAQ,EAAC,GAAG,OAAO,MAAM,CAAA;AAAA,EAAA,CAC1B;AACH;AAEO,SAAS,QAA+B,EAAC,OAAO,GAAG,SAIvD;AACD,QAAM,aAAa,IAAI,QAAA,EAAU,WAAW,QAAQ;AACpD,QAAM,MAAe,EAAE,GAAG,OAAO,WAAW;AACtC,QAAA,SAAS,EAAC,IAAA,CAAW;AACpB,SAAA;AACT;"}
|
package/dist/es/main24.mjs
DELETED
package/dist/es/main24.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main24.mjs","sources":["../../src/core/earth-radius.ts"],"sourcesContent":["export const earthRadius = 6371008.8;\n"],"names":[],"mappings":"AAAO,MAAM,cAAc;"}
|
package/dist/es/main25.mjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { useThree, _roots } from "@react-three/fiber";
|
|
2
|
-
import { useMemo } from "react";
|
|
3
|
-
function useCoords() {
|
|
4
|
-
const coords = useThree((s) => s.coords);
|
|
5
|
-
return coords;
|
|
6
|
-
}
|
|
7
|
-
function useSetCoords({ longitude, latitude, altitude }) {
|
|
8
|
-
const canvas = useThree((s) => s.gl.domElement);
|
|
9
|
-
useMemo(() => {
|
|
10
|
-
const store = _roots.get(canvas).store;
|
|
11
|
-
const coords = { longitude, latitude, altitude };
|
|
12
|
-
setCoords(store, coords);
|
|
13
|
-
}, [longitude, latitude, altitude]);
|
|
14
|
-
}
|
|
15
|
-
function useSetRootCoords(store, {
|
|
16
|
-
longitude,
|
|
17
|
-
latitude,
|
|
18
|
-
altitude
|
|
19
|
-
}) {
|
|
20
|
-
useMemo(() => {
|
|
21
|
-
setCoords(store, { longitude, latitude, altitude });
|
|
22
|
-
}, [longitude, latitude, altitude]);
|
|
23
|
-
}
|
|
24
|
-
function setCoords(store, coords) {
|
|
25
|
-
store.setState({ coords });
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
setCoords,
|
|
29
|
-
useCoords,
|
|
30
|
-
useSetCoords,
|
|
31
|
-
useSetRootCoords
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=main25.mjs.map
|
package/dist/es/main25.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main25.mjs","sources":["../../src/core/use-coords.tsx"],"sourcesContent":["import { RootState, _roots, useThree } from \"@react-three/fiber\";\nimport { useMemo } from \"react\";\nimport { UseBoundStore } from 'zustand';\nimport { Coords } from \"../api/coords\";\n\nexport function useCoords() {\n const coords = useThree(s=>(s as any).coords) as Coords; // eslint-disable-line @typescript-eslint/no-explicit-any\n return coords;\n}\n\nexport function useSetCoords({longitude, latitude, altitude}: Coords) {\n \n const canvas = useThree(s => s.gl.domElement);\n useMemo(()=>{\n const store = _roots.get(canvas)!.store; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n const coords : Coords = { longitude, latitude, altitude };\n setCoords(store, coords);\n }, [longitude, latitude, altitude]) // eslint-disable-line react-hooks/exhaustive-deps\n}\n\nexport function useSetRootCoords(store:UseBoundStore<RootState>, {\n longitude, latitude, altitude\n}: Coords) {\n useMemo(()=>{\n setCoords(store, {longitude, latitude, altitude});\n }, [longitude, latitude, altitude]) // eslint-disable-line react-hooks/exhaustive-deps\n}\n\nexport function setCoords(store:UseBoundStore<RootState>, coords: Coords) {\n store.setState({coords} as any) // eslint-disable-line @typescript-eslint/no-explicit-any\n}"],"names":[],"mappings":";;AAKO,SAAS,YAAY;AAC1B,QAAM,SAAS,SAAS,CAAI,MAAA,EAAU,MAAM;AACrC,SAAA;AACT;AAEO,SAAS,aAAa,EAAC,WAAW,UAAU,YAAmB;AAEpE,QAAM,SAAS,SAAS,CAAK,MAAA,EAAE,GAAG,UAAU;AAC5C,UAAQ,MAAI;AACV,UAAM,QAAQ,OAAO,IAAI,MAAM,EAAG;AAClC,UAAM,SAAkB,EAAE,WAAW,UAAU,SAAS;AACxD,cAAU,OAAO,MAAM;AAAA,EACtB,GAAA,CAAC,WAAW,UAAU,QAAQ,CAAC;AACpC;AAEO,SAAS,iBAAiB,OAAgC;AAAA,EAC/D;AAAA,EAAW;AAAA,EAAU;AACvB,GAAW;AACT,UAAQ,MAAI;AACV,cAAU,OAAO,EAAC,WAAW,UAAU,SAAS,CAAA;AAAA,EAC/C,GAAA,CAAC,WAAW,UAAU,QAAQ,CAAC;AACpC;AAEgB,SAAA,UAAU,OAAgC,QAAgB;AAClE,QAAA,SAAS,EAAC,OAAA,CAAc;AAChC;"}
|
package/dist/es/main26.mjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { syncCamera } from "./main21.mjs";
|
|
2
|
-
import { useFunction } from "./main20.mjs";
|
|
3
|
-
function useRender({
|
|
4
|
-
map,
|
|
5
|
-
origin,
|
|
6
|
-
useThree,
|
|
7
|
-
frameloop,
|
|
8
|
-
r3m
|
|
9
|
-
}) {
|
|
10
|
-
const render = useFunction((_gl, projViewMx) => {
|
|
11
|
-
const pVMx = "defaultProjectionData" in projViewMx ? Object.values(projViewMx.defaultProjectionData.mainMatrix) : projViewMx;
|
|
12
|
-
r3m.viewProjMx.splice(0, 16, ...pVMx);
|
|
13
|
-
const state = useThree.getState();
|
|
14
|
-
const camera = state.camera;
|
|
15
|
-
const { gl, advance } = state;
|
|
16
|
-
syncCamera(camera, origin, projViewMx);
|
|
17
|
-
gl.resetState();
|
|
18
|
-
advance(Date.now() * 1e-3, true);
|
|
19
|
-
if (!frameloop || frameloop === "always")
|
|
20
|
-
map.triggerRepaint();
|
|
21
|
-
});
|
|
22
|
-
return render;
|
|
23
|
-
}
|
|
24
|
-
export {
|
|
25
|
-
useRender
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=main26.mjs.map
|
package/dist/es/main26.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"main26.mjs","sources":["../../src/core/canvas-in-layer/use-render.ts"],"sourcesContent":["import { RootState } from \"@react-three/fiber\";\nimport { Matrix4Tuple, PerspectiveCamera } from \"three\";\nimport { UseBoundStore } from \"zustand\";\nimport { MapInstance } from \"../generic-map\";\nimport { syncCamera } from \"../sync-camera\";\nimport { useFunction } from \"../use-function\";\nimport { R3M } from \"../use-r3m\";\n\nexport function useRender({\n map, origin, useThree, frameloop, r3m,\n} :{\n map: MapInstance,\n origin: Matrix4Tuple,\n useThree: UseBoundStore<RootState>,\n frameloop?: 'always' | 'demand',\n r3m: R3M\n}) {\n const render = useFunction((_gl: WebGL2RenderingContext, projViewMx: number[] | {defaultProjectionData: {mainMatrix: Record<string, number>}}) => {\n const pVMx = 'defaultProjectionData' in projViewMx ? Object.values(projViewMx.defaultProjectionData.mainMatrix) : projViewMx;\n r3m.viewProjMx.splice(0, 16, ...pVMx)\n const state = useThree.getState();\n const camera = state.camera as PerspectiveCamera;\n const {gl, advance} = state;\n syncCamera(camera as PerspectiveCamera, origin, projViewMx as Matrix4Tuple);\n gl.resetState();\n advance(Date.now() * 0.001, true);\n if (!frameloop || frameloop === 'always') map.triggerRepaint();\n })\n return render;\n}"],"names":[],"mappings":";;AAQO,SAAS,UAAU;AAAA,EACxB;AAAA,EAAK;AAAA,EAAQ;AAAA,EAAU;AAAA,EAAW;AACpC,GAMG;AACD,QAAM,SAAS,YAAY,CAAC,KAA6B,eAAyF;AAC1I,UAAA,OAAO,2BAA2B,aAAa,OAAO,OAAO,WAAW,sBAAsB,UAAU,IAAI;AAClH,QAAI,WAAW,OAAO,GAAG,IAAI,GAAG,IAAI;AAC9B,UAAA,QAAQ,SAAS;AACvB,UAAM,SAAS,MAAM;AACf,UAAA,EAAC,IAAI,QAAW,IAAA;AACX,eAAA,QAA6B,QAAQ,UAA0B;AAC1E,OAAG,WAAW;AACd,YAAQ,KAAK,IAAQ,IAAA,MAAO,IAAI;AAC5B,QAAA,CAAC,aAAa,cAAc;AAAU,UAAI,eAAe;AAAA,EAAA,CAC9D;AACM,SAAA;AACT;"}
|