react-three-map 0.3.5 → 0.4.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 +25 -0
- package/dist/cjs/main.js +1 -1
- package/dist/es/main.mjs +4 -2
- package/dist/es/main.mjs.map +1 -1
- package/dist/es/main10.mjs +10 -0
- package/dist/es/main10.mjs.map +1 -0
- package/dist/es/main11.mjs +52 -0
- package/dist/es/main11.mjs.map +1 -0
- package/dist/es/main12.mjs +9 -0
- package/dist/es/main12.mjs.map +1 -0
- package/dist/es/main13.mjs +56 -0
- package/dist/es/main13.mjs.map +1 -0
- package/dist/es/main2.mjs +17 -29
- package/dist/es/main2.mjs.map +1 -1
- package/dist/es/main3.mjs +38 -6
- package/dist/es/main3.mjs.map +1 -1
- package/dist/es/main4.mjs +20 -16
- package/dist/es/main4.mjs.map +1 -1
- package/dist/es/main5.mjs +3 -60
- package/dist/es/main5.mjs.map +1 -1
- package/dist/es/main6.mjs +5 -12
- package/dist/es/main6.mjs.map +1 -1
- package/dist/es/main7.mjs +10 -52
- package/dist/es/main7.mjs.map +1 -1
- package/dist/es/main8.mjs +14 -5
- package/dist/es/main8.mjs.map +1 -1
- package/dist/es/main9.mjs +15 -0
- package/dist/es/main9.mjs.map +1 -0
- package/dist/maplibre/cjs/main.js +1 -1
- package/dist/maplibre/es/main.mjs +4 -2
- package/dist/maplibre/es/main.mjs.map +1 -1
- package/dist/maplibre/es/main10.mjs +10 -0
- package/dist/maplibre/es/main10.mjs.map +1 -0
- package/dist/maplibre/es/main11.mjs +52 -0
- package/dist/maplibre/es/main11.mjs.map +1 -0
- package/dist/maplibre/es/main12.mjs +9 -0
- package/dist/maplibre/es/main12.mjs.map +1 -0
- package/dist/maplibre/es/main13.mjs +56 -0
- package/dist/maplibre/es/main13.mjs.map +1 -0
- package/dist/maplibre/es/main2.mjs +17 -29
- package/dist/maplibre/es/main2.mjs.map +1 -1
- package/dist/maplibre/es/main3.mjs +38 -6
- package/dist/maplibre/es/main3.mjs.map +1 -1
- package/dist/maplibre/es/main4.mjs +20 -16
- package/dist/maplibre/es/main4.mjs.map +1 -1
- package/dist/maplibre/es/main5.mjs +3 -60
- package/dist/maplibre/es/main5.mjs.map +1 -1
- package/dist/maplibre/es/main6.mjs +5 -12
- package/dist/maplibre/es/main6.mjs.map +1 -1
- package/dist/maplibre/es/main7.mjs +10 -52
- package/dist/maplibre/es/main7.mjs.map +1 -1
- package/dist/maplibre/es/main8.mjs +14 -5
- package/dist/maplibre/es/main8.mjs.map +1 -1
- package/dist/maplibre/es/main9.mjs +15 -0
- package/dist/maplibre/es/main9.mjs.map +1 -0
- package/dist/maplibre/types/api/canvas-props.d.ts +8 -0
- package/dist/maplibre/types/api/coordinates.d.ts +7 -0
- package/dist/maplibre/types/core/store.d.ts +12 -0
- package/dist/maplibre/types/core/sync-camera.d.ts +2 -0
- package/dist/maplibre/types/core/use-canvas.d.ts +7 -9
- package/dist/maplibre/types/core/use-coords.d.ts +5 -0
- package/dist/maplibre/types/core/use-create-root.d.ts +13 -0
- package/dist/maplibre/types/core/use-on-add.d.ts +6 -4
- package/dist/maplibre/types/core/use-render.d.ts +3 -2
- package/dist/maplibre/types/maplibre/canvas.d.ts +2 -8
- package/dist/maplibre/types/maplibre.index.d.ts +2 -0
- package/dist/types/api/canvas-props.d.ts +8 -0
- package/dist/types/api/coordinates.d.ts +7 -0
- package/dist/types/core/store.d.ts +12 -0
- package/dist/types/core/sync-camera.d.ts +2 -0
- package/dist/types/core/use-canvas.d.ts +7 -9
- package/dist/types/core/use-coords.d.ts +5 -0
- package/dist/types/core/use-create-root.d.ts +13 -0
- package/dist/types/core/use-on-add.d.ts +6 -4
- package/dist/types/core/use-render.d.ts +3 -2
- package/dist/types/mapbox/canvas.d.ts +3 -9
- package/dist/types/mapbox.index.d.ts +2 -0
- package/package.json +5 -5
- package/stories/README.md +1 -0
- package/stories/package.json +31 -0
- package/stories/sandbox.config.json +3 -0
- package/stories/yarn.lock +4295 -0
- package/dist/maplibre/types/core/state-ref.d.ts +0 -8
- package/dist/types/core/state-ref.d.ts +0 -8
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -138,3 +138,28 @@ Therefore, the following `<Canvas>` props are ignored:
|
|
|
138
138
|
- orthographic
|
|
139
139
|
- dpr
|
|
140
140
|
|
|
141
|
+
### Coordinates
|
|
142
|
+
|
|
143
|
+
[](https://rodrigohamuy.github.io/react-three-map/?story=multi-coordinates--default--default)
|
|
144
|
+
|
|
145
|
+
This component allows you to have 3D objects at different coordinates.
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
import { Canvas, Coordinates } from 'react-three-map'
|
|
150
|
+
|
|
151
|
+
<Canvas latitude={51} longitude={0}>
|
|
152
|
+
<Coordinates latitude={50} longitude={0}>
|
|
153
|
+
<mesh><sphereGeometry /></mesh>
|
|
154
|
+
</Coordinates>
|
|
155
|
+
<Coordinates latitude={52} longitude={0}>
|
|
156
|
+
<mesh><sphereGeometry /></mesh>
|
|
157
|
+
</Coordinates>
|
|
158
|
+
</Canvas>
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
| Props | Description | Default |
|
|
162
|
+
| --------- | ------------------------------------------------ | ---------- |
|
|
163
|
+
| latitude | The latitude coordinate where to add the scene. | |
|
|
164
|
+
| longitude | The longitude coordinate where to add the scene. | |
|
|
165
|
+
| altitude | The altitude coordinate where to add the scene. | `0` |
|
package/dist/cjs/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),l=require("@react-three/fiber"),b=require("mapbox-gl"),s=require("react"),S=require("react-map-gl"),m=require("three");function L(n){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const e=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(c,t,e.get?e:{enumerable:!0,get:()=>n[t]})}}return c.default=n,Object.freeze(c)}const O=L(m),h=new m.Quaternion,T=new m.Euler,M=new m.Vector3,R=new m.Vector3,A=new m.Matrix4;function z({longitude:n,latitude:c,altitude:t,fromLngLat:e}){const o=e([n,c],t),r=o.meterInMercatorCoordinateUnits();return M.set(o.x,o.y,o.z||0),R.set(r,-r,r),h.setFromEuler(T.set(-Math.PI*.5,0,0)),A.compose(M,h,R).toArray()}function C({latitude:n,longitude:c,altitude:t,fromLngLat:e}){return s.useMemo(()=>z({latitude:n,longitude:c,altitude:t,fromLngLat:e}),[n,c,t,e])}const x={onClick:["click",!1],onContextMenu:["contextmenu",!1],onDoubleClick:["dblclick",!1],onWheel:["wheel",!0],onPointerDown:["pointerdown",!0],onPointerUp:["pointerup",!0],onPointerLeave:["pointerleave",!0],onPointerMove:["pointermove",!0],onPointerCancel:["pointercancel",!0],onLostPointerCapture:["lostpointercapture",!0]};function q(){return n=>{const{handlePointer:c}=l.createEvents(n);return{priority:1,enabled:!0,compute(t,e){e.size.width=e.gl.domElement.width/window.devicePixelRatio,e.size.height=e.gl.domElement.height/window.devicePixelRatio,e.pointer.x=t.offsetX/e.size.width*2-1,e.pointer.y=1-t.offsetY/e.size.height*2,e.raycaster.camera=e.camera,e.raycaster.ray.origin.setScalar(0).applyMatrix4(e.camera.projectionMatrixInverse),e.raycaster.ray.direction.set(e.pointer.x,e.pointer.y,1).applyMatrix4(e.camera.projectionMatrixInverse).sub(e.raycaster.ray.origin).normalize()},connected:void 0,handlers:Object.keys(x).reduce((t,e)=>({...t,[e]:c(e)}),{}),update:()=>{var o;const{events:t,internal:e}=n.getState();(o=e.lastEvent)!=null&&o.current&&t.handlers&&t.handlers.onPointerMove(e.lastEvent.current)},connect:t=>{var r;const{set:e,events:o}=n.getState();(r=o.disconnect)==null||r.call(o),e(a=>({events:{...a.events,connected:t.parentNode}})),Object.entries(o.handlers??[]).forEach(([a,u])=>{const[i,f]=x[a];t.addEventListener(i,u,{passive:f})})},disconnect:()=>{const{set:t,events:e}=n.getState();e.connected&&(Object.entries(e.handlers??[]).forEach(([o,r])=>{if(e&&e.connected instanceof HTMLElement){const[a]=x[o];e.connected.removeEventListener(a,r)}}),t(o=>({events:{...o.events,connected:void 0}})))}}}}const y=n=>{const c=s.useRef(n);return c.current=n,s.useCallback((...t)=>c.current(...t),[])};function k(n,{frameloop:c,...t}){const[e,o]=s.useState(!1),r=s.useRef({fromLngLat:n}),a=y((i,f)=>{const p=i.getCanvas(),v=l.createRoot(p);v.configure({dpr:window.devicePixelRatio,events:q(),...t,frameloop:"never",gl:{context:f,depth:!0,autoClear:!1,antialias:!0,...t==null?void 0:t.gl},onCreated:j=>{j.gl.forceContextLoss=()=>{}},camera:{matrixAutoUpdate:!1},size:{width:p.clientWidth,height:p.clientHeight,top:0,left:0,...t==null?void 0:t.size}});const g=l._roots.get(p).store;r.current.map=i,r.current.root=v,r.current.state=g.getState(),g.setState({r3m:r.current}),c==="demand"&&g.setState({frameloop:c,invalidate:()=>{i.triggerRepaint()}}),setTimeout(()=>o(!0))}),u=y(()=>{setTimeout(()=>{r.current.root&&r.current.root.unmount()})});return{onAdd:a,onRemove:u,mounted:e,r3mRef:r}}const D=({children:n,frameloop:c,fromLngLat:t,...e})=>{const o=s.useId(),{onAdd:r,onRemove:a,mounted:u,r3mRef:i}=k(t,{frameloop:c,...e});return s.useEffect(()=>{u&&i.current.root&&i.current.root.render(d.jsx(d.Fragment,{children:n}))},[i,u,n]),{id:o,onAdd:r,onRemove:a,r3mRef:i}},F=new m.Matrix4;function w(n,c,t){n.projectionMatrix.fromArray(t).multiply(F.fromArray(c)),n.projectionMatrixInverse.copy(n.projectionMatrix).invert()}function I(n,c,t){return y((o,r)=>{const a=c.current;if(!a.state||!a.map)return;const u=a.state.camera,i=a.state.gl,f=a.state.advance;a.mapCamMx=r,w(u,n,r),i.resetState(),f(Date.now()*.001,!0),t==="always"&&a.map.triggerRepaint()})}function N({longitude:n,latitude:c,altitude:t=0,frameloop:e="always",fromLngLat:o,...r}){const a=C({latitude:c,longitude:n,altitude:t,fromLngLat:o}),{id:u,onAdd:i,onRemove:f,r3mRef:p}=D({frameloop:e,fromLngLat:o,...r}),v=I(a,p,e);return{id:u,onAdd:i,onRemove:f,render:v}}l.extend(O);const P=b.MercatorCoordinate.fromLngLat,_=s.memo(n=>{const{id:c,onAdd:t,onRemove:e,render:o}=N({...n,fromLngLat:P});return d.jsx(S.Layer,{id:c,type:"custom",renderingMode:"3d",onAdd:t,onRemove:e,render:o})}),H=()=>l.useThree(n=>n.r3m),E=s.memo(({latitude:n,longitude:c,altitude:t=0,children:e})=>{const[o]=s.useState(()=>new m.Scene),r=H(),a=C({latitude:n,longitude:c,altitude:t,fromLngLat:r.fromLngLat});return d.jsx(d.Fragment,{children:l.createPortal(d.jsxs(d.Fragment,{children:[d.jsx(U,{r3m:r,origin:a}),e]}),o,{events:{priority:2}})})});E.displayName="Coordinates";function U({r3m:n,origin:c}){const{gl:t,scene:e,set:o}=l.useThree(),r=s.useRef(null);return l.useFrame(()=>{n.mapCamMx&&r.current&&(w(r.current,c,n.mapCamMx),t.render(e,r.current))}),s.useLayoutEffect(()=>{r.current&&o({invalidate:()=>{n.map&&n.map.triggerRepaint()},camera:r.current})},[o,n]),d.jsx("perspectiveCamera",{ref:r})}exports.Canvas=_;exports.Coordinates=E;
|
package/dist/es/main.mjs
CHANGED
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":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Quaternion as m, Euler as l, Vector3 as s, Matrix4 as w } from "three";
|
|
2
|
+
const o = new m(), p = new l(), n = new s(), r = new s(), x = new w();
|
|
3
|
+
function d({ longitude: c, latitude: a, altitude: i, fromLngLat: u }) {
|
|
4
|
+
const t = u([c, a], i), e = t.meterInMercatorCoordinateUnits();
|
|
5
|
+
return n.set(t.x, t.y, t.z || 0), r.set(e, -e, e), o.setFromEuler(p.set(-Math.PI * 0.5, 0, 0)), x.compose(n, o, r).toArray();
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
d as coordsToMatrix
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=main10.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main10.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":["quat","Quaternion","euler","Euler","pos","Vector3","scale","m4","Matrix4","coordsToMatrix","longitude","latitude","altitude","fromLngLat","center","scaleUnit"],"mappings":";AAGA,MAAMA,IAAO,IAAIC,KACXC,IAAQ,IAAIC,KACZC,IAAM,IAAIC,KACVC,IAAQ,IAAID,KACZE,IAAK,IAAIC;AAGR,SAASC,EAAe,EAAE,WAAAC,GAAW,UAAAC,GAAU,UAAAC,GAAU,YAAAC,KAE7D;AACD,QAAMC,IAASD,EAAW,CAACH,GAAWC,CAAQ,GAAGC,CAAQ,GACnDG,IAAYD,EAAO;AACzB,SAAAV,EAAI,IAAIU,EAAO,GAAGA,EAAO,GAAGA,EAAO,KAAK,CAAC,GACzCR,EAAM,IAAIS,GAAW,CAACA,GAAWA,CAAS,GACrCf,EAAA,aAAaE,EAAM,IAAI,CAAC,KAAK,KAAK,KAAI,GAAG,CAAC,CAAC,GACzCK,EAAG,QAAQH,GAAKJ,GAAMM,CAAK,EAAE;AACtC;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createRoot as d, _roots as h } from "@react-three/fiber";
|
|
2
|
+
import { useState as R, useRef as x } from "react";
|
|
3
|
+
import { createEvents as C } from "./main13.mjs";
|
|
4
|
+
import { useFunction as c } from "./main12.mjs";
|
|
5
|
+
function T(s, { frameloop: a, ...t }) {
|
|
6
|
+
const [r, m] = R(!1), e = x({ fromLngLat: s }), f = c((n, g) => {
|
|
7
|
+
const o = n.getCanvas(), u = d(o);
|
|
8
|
+
u.configure({
|
|
9
|
+
dpr: window.devicePixelRatio,
|
|
10
|
+
events: C(),
|
|
11
|
+
...t,
|
|
12
|
+
frameloop: "never",
|
|
13
|
+
gl: {
|
|
14
|
+
context: g,
|
|
15
|
+
depth: !0,
|
|
16
|
+
autoClear: !1,
|
|
17
|
+
antialias: !0,
|
|
18
|
+
...t == null ? void 0 : t.gl
|
|
19
|
+
},
|
|
20
|
+
onCreated: (v) => {
|
|
21
|
+
v.gl.forceContextLoss = () => {
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
camera: {
|
|
25
|
+
matrixAutoUpdate: !1
|
|
26
|
+
},
|
|
27
|
+
size: {
|
|
28
|
+
width: o.clientWidth,
|
|
29
|
+
height: o.clientHeight,
|
|
30
|
+
top: 0,
|
|
31
|
+
left: 0,
|
|
32
|
+
...t == null ? void 0 : t.size
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const i = h.get(o).store;
|
|
36
|
+
e.current.map = n, e.current.root = u, e.current.state = i.getState(), i.setState({ r3m: e.current }), a === "demand" && i.setState({
|
|
37
|
+
frameloop: a,
|
|
38
|
+
invalidate: () => {
|
|
39
|
+
n.triggerRepaint();
|
|
40
|
+
}
|
|
41
|
+
}), setTimeout(() => m(!0));
|
|
42
|
+
}), l = c(() => {
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
e.current.root && e.current.root.unmount();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
return { onAdd: f, onRemove: l, mounted: r, r3mRef: e };
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
T as useOnAdd
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=main11.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main11.mjs","sources":["../../src/core/use-on-add.ts"],"sourcesContent":["import { RenderProps, _roots, createRoot } from \"@react-three/fiber\";\nimport { 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 },\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 setTimeout(() => setMounted(true));\n\n })\n\n const onRemove = useFunction(() => {\n setTimeout(() => {\n if (!r3mRef.current.root) return;\n r3mRef.current.root.unmount();\n })\n })\n\n return { onAdd, onRemove, mounted, r3mRef };\n}"],"names":["useOnAdd","fromLngLat","frameloop","renderProps","mounted","setMounted","useState","r3mRef","useRef","onAdd","useFunction","map","gl","canvas","root","createRoot","createEvents","state","store","_roots","onRemove"],"mappings":";;;;AAOO,SAASA,EACdC,GACA,EAAE,WAAAC,GAAW,GAAGC,KAChB;AAEA,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAS,EAAK,GAEtCC,IAASC,EAAiB,EAAE,YAAAP,EAAY,CAAA,GAExCQ,IAAQC,EAAY,CAACC,GAAkBC,MAA8B;AAEnE,UAAAC,IAASF,EAAI,aACbG,IAAOC,EAAWF,CAAM;AAC9B,IAAAC,EAAK,UAAU;AAAA,MACb,KAAK,OAAO;AAAA,MACZ,QAAQE,EAAa;AAAA,MACrB,GAAGb;AAAA,MACH,WAAW;AAAA,MACX,IAAI;AAAA,QACF,SAASS;AAAA,QACT,OAAO;AAAA,QACP,WAAW;AAAA,QACX,WAAW;AAAA,QACX,GAAGT,KAAA,gBAAAA,EAAa;AAAA,MAClB;AAAA,MACA,WAAW,CAACc,MAAU;AAEd,QAAAA,EAAA,GAAG,mBAAmB,MAAM;AAAA,QAAA;AAAA,MACpC;AAAA,MACA,QAAQ;AAAA,QACN,kBAAkB;AAAA,MACpB;AAAA,MACA,MAAM;AAAA,QACJ,OAAOJ,EAAO;AAAA,QACd,QAAQA,EAAO;AAAA,QACf,KAAK;AAAA,QACL,MAAM;AAAA,QACN,GAAGV,KAAA,gBAAAA,EAAa;AAAA,MAClB;AAAA,IAAA,CACD;AAGD,UAAMe,IAAQC,EAAO,IAAIN,CAAM,EAAG;AAElC,IAAAN,EAAO,QAAQ,MAAMI,GACrBJ,EAAO,QAAQ,OAAOO,GACfP,EAAA,QAAQ,QAAQW,EAAM,SAAS,GAGtCA,EAAM,SAAS,EAAE,KAAKX,EAAO,QAAgB,CAAA,GAEzCL,MAAc,YAChBgB,EAAM,SAAS;AAAA,MACb,WAAAhB;AAAA,MACA,YAAY,MAAM;AAChB,QAAAS,EAAI,eAAe;AAAA,MACrB;AAAA,IAAA,CACD,GAGQ,WAAA,MAAMN,EAAW,EAAI,CAAC;AAAA,EAAA,CAElC,GAEKe,IAAWV,EAAY,MAAM;AACjC,eAAW,MAAM;AACX,MAACH,EAAO,QAAQ,QACbA,EAAA,QAAQ,KAAK;IAAQ,CAC7B;AAAA,EAAA,CACF;AAED,SAAO,EAAE,OAAAE,GAAO,UAAAW,GAAU,SAAAhB,GAAS,QAAAG,EAAO;AAC5C;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main12.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":["useFunction","callback","callbackRef","useRef","useCallback","args"],"mappings":";AAGa,MAAAA,IAAc,CAAoCC,MAAmB;AAC1E,QAAAC,IAAcC,EAAOF,CAAQ;AACnC,SAAAC,EAAY,UAAUD,GACfG,EAAY,IAAIC,MACdH,EAAY,QAAQ,GAAGG,CAAI,GACjC,CAAE,CAAA;AACP;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createEvents as p } from "@react-three/fiber";
|
|
2
|
+
const c = {
|
|
3
|
+
onClick: ["click", !1],
|
|
4
|
+
onContextMenu: ["contextmenu", !1],
|
|
5
|
+
onDoubleClick: ["dblclick", !1],
|
|
6
|
+
onWheel: ["wheel", !0],
|
|
7
|
+
onPointerDown: ["pointerdown", !0],
|
|
8
|
+
onPointerUp: ["pointerup", !0],
|
|
9
|
+
onPointerLeave: ["pointerleave", !0],
|
|
10
|
+
onPointerMove: ["pointermove", !0],
|
|
11
|
+
onPointerCancel: ["pointercancel", !0],
|
|
12
|
+
onLostPointerCapture: ["lostpointercapture", !0]
|
|
13
|
+
};
|
|
14
|
+
function u() {
|
|
15
|
+
return (o) => {
|
|
16
|
+
const { handlePointer: a } = p(o);
|
|
17
|
+
return {
|
|
18
|
+
priority: 1,
|
|
19
|
+
enabled: !0,
|
|
20
|
+
compute(n, e) {
|
|
21
|
+
e.size.width = e.gl.domElement.width / window.devicePixelRatio, e.size.height = e.gl.domElement.height / window.devicePixelRatio, e.pointer.x = n.offsetX / e.size.width * 2 - 1, e.pointer.y = 1 - n.offsetY / e.size.height * 2, e.raycaster.camera = e.camera, e.raycaster.ray.origin.setScalar(0).applyMatrix4(e.camera.projectionMatrixInverse), e.raycaster.ray.direction.set(e.pointer.x, e.pointer.y, 1).applyMatrix4(e.camera.projectionMatrixInverse).sub(e.raycaster.ray.origin).normalize();
|
|
22
|
+
},
|
|
23
|
+
connected: void 0,
|
|
24
|
+
handlers: Object.keys(c).reduce(
|
|
25
|
+
(n, e) => ({ ...n, [e]: a(e) }),
|
|
26
|
+
{}
|
|
27
|
+
),
|
|
28
|
+
update: () => {
|
|
29
|
+
var t;
|
|
30
|
+
const { events: n, internal: e } = o.getState();
|
|
31
|
+
(t = e.lastEvent) != null && t.current && n.handlers && n.handlers.onPointerMove(e.lastEvent.current);
|
|
32
|
+
},
|
|
33
|
+
connect: (n) => {
|
|
34
|
+
var i;
|
|
35
|
+
const { set: e, events: t } = o.getState();
|
|
36
|
+
(i = t.disconnect) == null || i.call(t), e((r) => ({ events: { ...r.events, connected: n.parentNode } })), Object.entries(t.handlers ?? []).forEach(([r, l]) => {
|
|
37
|
+
const [s, d] = c[r];
|
|
38
|
+
n.addEventListener(s, l, { passive: d });
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
disconnect: () => {
|
|
42
|
+
const { set: n, events: e } = o.getState();
|
|
43
|
+
e.connected && (Object.entries(e.handlers ?? []).forEach(([t, i]) => {
|
|
44
|
+
if (e && e.connected instanceof HTMLElement) {
|
|
45
|
+
const [r] = c[t];
|
|
46
|
+
e.connected.removeEventListener(r, i);
|
|
47
|
+
}
|
|
48
|
+
}), n((t) => ({ events: { ...t.events, connected: void 0 } })));
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
u as createEvents
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=main13.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main13.mjs","sources":["../../src/core/create-events.ts"],"sourcesContent":["import { Events, RenderProps, RootState, createEvents as createFiberEvents } from \"@react-three/fiber\";\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\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 return {\n priority: 1,\n enabled: true,\n compute(event: DomEvent, state: RootState) {\n state.size.width = state.gl.domElement.width / window.devicePixelRatio;\n state.size.height = state.gl.domElement.height / window.devicePixelRatio;\n state.pointer.x = (event.offsetX / state.size.width) * 2 - 1;\n state.pointer.y = 1 - (event.offsetY / state.size.height) * 2;\n state.raycaster.camera = state.camera;\n state.raycaster.ray.origin.setScalar(0).applyMatrix4(state.camera.projectionMatrixInverse);\n state.raycaster.ray.direction\n .set(state.pointer.x, state.pointer.y, 1)\n .applyMatrix4(state.camera.projectionMatrixInverse)\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":["DOM_EVENTS","createEvents","store","handlePointer","createFiberEvents","event","state","acc","key","events","internal","_a","target","set","name","eventName","passive"],"mappings":"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"}
|
package/dist/es/main2.mjs
CHANGED
|
@@ -1,38 +1,26 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { extend as
|
|
3
|
-
import { MercatorCoordinate as
|
|
4
|
-
import { memo as
|
|
5
|
-
import { Layer as
|
|
6
|
-
import * as
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
d(
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
altitude: m = 0,
|
|
14
|
-
frameloop: e = "always",
|
|
15
|
-
...t
|
|
16
|
-
}) => {
|
|
17
|
-
const n = x(() => y({
|
|
18
|
-
latitude: r,
|
|
19
|
-
longitude: o,
|
|
20
|
-
altitude: m,
|
|
21
|
-
fromLngLat: c.fromLngLat
|
|
22
|
-
}), [r, o, m]), { id: s, onAdd: a, onRemove: f, render: p } = C({ m4: n, frameloop: e, ...t });
|
|
23
|
-
return /* @__PURE__ */ i(
|
|
24
|
-
M,
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { extend as a } from "@react-three/fiber";
|
|
3
|
+
import { MercatorCoordinate as i } from "mapbox-gl";
|
|
4
|
+
import { memo as d } from "react";
|
|
5
|
+
import { Layer as f } from "react-map-gl";
|
|
6
|
+
import * as p from "three";
|
|
7
|
+
import { useCanvas as s } from "./main4.mjs";
|
|
8
|
+
a(p);
|
|
9
|
+
const c = i.fromLngLat, y = d((o) => {
|
|
10
|
+
const { id: r, onAdd: m, onRemove: t, render: e } = s({ ...o, fromLngLat: c });
|
|
11
|
+
return /* @__PURE__ */ n(
|
|
12
|
+
f,
|
|
25
13
|
{
|
|
26
|
-
id:
|
|
14
|
+
id: r,
|
|
27
15
|
type: "custom",
|
|
28
16
|
renderingMode: "3d",
|
|
29
|
-
onAdd:
|
|
30
|
-
onRemove:
|
|
31
|
-
render:
|
|
17
|
+
onAdd: m,
|
|
18
|
+
onRemove: t,
|
|
19
|
+
render: e
|
|
32
20
|
}
|
|
33
21
|
);
|
|
34
22
|
});
|
|
35
23
|
export {
|
|
36
|
-
|
|
24
|
+
y as Canvas
|
|
37
25
|
};
|
|
38
26
|
//# sourceMappingURL=main2.mjs.map
|
package/dist/es/main2.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main2.mjs","sources":["../../src/mapbox/canvas.tsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"main2.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":["extend","THREE","fromLngLat","MercatorCoordinate","Canvas","memo","props","id","onAdd","onRemove","render","useCanvas","jsx","Layer"],"mappings":";;;;;;;AAQAA,EAAOC,CAAK;AAEZ,MAAMC,IAAaC,EAAmB,YAGzBC,IAASC,EAAkB,CAACC,MAAU;AAE3C,QAAA,EAAE,IAAAC,GAAI,OAAAC,GAAO,UAAAC,GAAU,QAAAC,EAAA,IAAWC,EAAU,EAAE,GAAGL,GAAO,YAAAJ,EAAA,CAAY;AAEnE,SAAA,gBAAAU;AAAA,IAACC;AAAA,IAAA;AAAA,MACN,IAAAN;AAAA,MACA,MAAK;AAAA,MACL,eAAc;AAAA,MACd,OAAAC;AAAA,MACA,UAAAC;AAAA,MACA,QAAAC;AAAA,IAAA;AAAA,EAAA;AAEJ,CAAC;"}
|
package/dist/es/main3.mjs
CHANGED
|
@@ -1,10 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsx as m, Fragment as s, jsxs as c } from "react/jsx-runtime";
|
|
2
|
+
import { createPortal as u, useThree as f, useFrame as p } from "@react-three/fiber";
|
|
3
|
+
import { memo as d, useState as l, useRef as C, useLayoutEffect as g } from "react";
|
|
4
|
+
import { Scene as x } from "three";
|
|
5
|
+
import { useR3M as L } from "./main5.mjs";
|
|
6
|
+
import { syncCamera as R } from "./main6.mjs";
|
|
7
|
+
import { useCoords as y } from "./main7.mjs";
|
|
8
|
+
const h = d(({
|
|
9
|
+
latitude: e,
|
|
10
|
+
longitude: n,
|
|
11
|
+
altitude: o = 0,
|
|
12
|
+
children: a
|
|
13
|
+
}) => {
|
|
14
|
+
const [t] = l(() => new x()), r = L(), i = y({
|
|
15
|
+
latitude: e,
|
|
16
|
+
longitude: n,
|
|
17
|
+
altitude: o,
|
|
18
|
+
fromLngLat: r.fromLngLat
|
|
19
|
+
});
|
|
20
|
+
return /* @__PURE__ */ m(s, { children: u(/* @__PURE__ */ c(s, { children: [
|
|
21
|
+
/* @__PURE__ */ m(v, { r3m: r, origin: i }),
|
|
22
|
+
a
|
|
23
|
+
] }), t, { events: { priority: 2 } }) });
|
|
24
|
+
});
|
|
25
|
+
h.displayName = "Coordinates";
|
|
26
|
+
function v({ r3m: e, origin: n }) {
|
|
27
|
+
const { gl: o, scene: a, set: t } = f(), r = C(null);
|
|
28
|
+
return p(() => {
|
|
29
|
+
e.mapCamMx && r.current && (R(r.current, n, e.mapCamMx), o.render(a, r.current));
|
|
30
|
+
}), g(() => {
|
|
31
|
+
r.current && t({
|
|
32
|
+
invalidate: () => {
|
|
33
|
+
e.map && e.map.triggerRepaint();
|
|
34
|
+
},
|
|
35
|
+
camera: r.current
|
|
36
|
+
});
|
|
37
|
+
}, [t, e]), /* @__PURE__ */ m("perspectiveCamera", { ref: r });
|
|
6
38
|
}
|
|
7
39
|
export {
|
|
8
|
-
|
|
40
|
+
h as Coordinates
|
|
9
41
|
};
|
|
10
42
|
//# 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/api/coordinates.tsx"],"sourcesContent":["import { createPortal, useFrame, useThree } from \"@react-three/fiber\";\nimport { PropsWithChildren, memo, useLayoutEffect, useRef, useState } from \"react\";\nimport { Matrix4Tuple, PerspectiveCamera, Scene } from \"three\";\nimport { R3mStore, useR3M } from \"../core/store\";\nimport { syncCamera } from \"../core/sync-camera\";\nimport { useCoords } from \"../core/use-coords\";\n\nexport interface CoordinatesProps extends PropsWithChildren {\n longitude: number,\n latitude: number,\n altitude?: number,\n}\n\nexport const Coordinates = memo<CoordinatesProps>(({\n latitude, longitude, altitude = 0, children\n}) => {\n\n const [scene] = useState(() => new Scene())\n\n const r3m = useR3M();\n\n const origin = useCoords({\n latitude, longitude, altitude, fromLngLat: r3m.fromLngLat,\n });\n\n\n return <>{createPortal(<>\n <RenderAtCoords r3m={r3m} origin={origin} />\n {children}\n </>, scene, { events: { priority: 2 } })}</>\n})\n\nCoordinates.displayName = 'Coordinates';\n\ninterface RenderAtCoordsProps {\n r3m: R3mStore,\n origin: Matrix4Tuple\n}\n\nfunction RenderAtCoords({ r3m, origin }: RenderAtCoordsProps) {\n\n const { gl, scene, set } = useThree()\n\n const cameraRef = useRef<PerspectiveCamera>(null)\n\n useFrame(() => {\n if (!r3m.mapCamMx) return;\n if (!cameraRef.current) return;\n syncCamera(cameraRef.current, origin, r3m.mapCamMx);\n gl.render(scene, cameraRef.current);\n })\n\n useLayoutEffect(() => {\n if (!cameraRef.current) return;\n set({\n invalidate: () => {\n if (!r3m.map) return;\n r3m.map.triggerRepaint();\n },\n camera: cameraRef.current,\n });\n }, [set, r3m])\n\n return <perspectiveCamera ref={cameraRef} />\n}"],"names":["Coordinates","memo","latitude","longitude","altitude","children","scene","useState","Scene","r3m","useR3M","origin","useCoords","jsx","Fragment","jsxs","RenderAtCoords","gl","set","useThree","cameraRef","useRef","useFrame","syncCamera","useLayoutEffect"],"mappings":";;;;;;;AAaa,MAAAA,IAAcC,EAAuB,CAAC;AAAA,EACjD,UAAAC;AAAA,EAAU,WAAAC;AAAA,EAAW,UAAAC,IAAW;AAAA,EAAG,UAAAC;AACrC,MAAM;AAEJ,QAAM,CAACC,CAAK,IAAIC,EAAS,MAAM,IAAIC,EAAO,CAAA,GAEpCC,IAAMC,KAENC,IAASC,EAAU;AAAA,IACvB,UAAAV;AAAA,IAAU,WAAAC;AAAA,IAAW,UAAAC;AAAA,IAAU,YAAYK,EAAI;AAAA,EAAA,CAChD;AAGM,SAAA,gBAAAI,EAAAC,GAAA,EAAG,YACR,gBAAAC,EAAAD,GAAA,EAAA,UAAA;AAAA,IAAC,gBAAAD,EAAAG,GAAA,EAAe,KAAAP,GAAU,QAAAE,EAAgB,CAAA;AAAA,IACzCN;AAAA,EAAA,GACH,GAAKC,GAAO,EAAE,QAAQ,EAAE,UAAU,EAAA,GAAK,EAAE,CAAA;AAC3C,CAAC;AAEDN,EAAY,cAAc;AAO1B,SAASgB,EAAe,EAAE,KAAAP,GAAK,QAAAE,KAA+B;AAE5D,QAAM,EAAE,IAAAM,GAAI,OAAAX,GAAO,KAAAY,MAAQC,EAAS,GAE9BC,IAAYC,EAA0B,IAAI;AAEhD,SAAAC,EAAS,MAAM;AACb,IAAKb,EAAI,YACJW,EAAU,YACfG,EAAWH,EAAU,SAAST,GAAQF,EAAI,QAAQ,GAC/CQ,EAAA,OAAOX,GAAOc,EAAU,OAAO;AAAA,EAAA,CACnC,GAEDI,EAAgB,MAAM;AACpB,IAAKJ,EAAU,WACXF,EAAA;AAAA,MACF,YAAY,MAAM;AAChB,QAAKT,EAAI,OACTA,EAAI,IAAI;MACV;AAAA,MACA,QAAQW,EAAU;AAAA,IAAA,CACnB;AAAA,EAAA,GACA,CAACF,GAAKT,CAAG,CAAC,GAEN,gBAAAI,EAAC,qBAAkB,EAAA,KAAKO,EAAW,CAAA;AAC5C;"}
|
package/dist/es/main4.mjs
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
frameloop:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
n
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { useCoords as a } from "./main7.mjs";
|
|
2
|
+
import { useCreateRoot as f } from "./main8.mjs";
|
|
3
|
+
import { useRender as p } from "./main9.mjs";
|
|
4
|
+
function x({
|
|
5
|
+
longitude: r,
|
|
6
|
+
latitude: n,
|
|
7
|
+
altitude: s = 0,
|
|
8
|
+
frameloop: o = "always",
|
|
9
|
+
fromLngLat: e,
|
|
10
|
+
...t
|
|
11
|
+
}) {
|
|
12
|
+
const m = a({
|
|
13
|
+
latitude: n,
|
|
14
|
+
longitude: r,
|
|
15
|
+
altitude: s,
|
|
16
|
+
fromLngLat: e
|
|
17
|
+
}), { id: d, onAdd: u, onRemove: i, r3mRef: c } = f({ frameloop: o, fromLngLat: e, ...t }), R = p(m, c, o);
|
|
18
|
+
return { id: d, onAdd: u, onRemove: i, render: R };
|
|
19
|
+
}
|
|
16
20
|
export {
|
|
17
|
-
|
|
21
|
+
x as useCanvas
|
|
18
22
|
};
|
|
19
23
|
//# sourceMappingURL=main4.mjs.map
|
package/dist/es/main4.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main4.mjs","sources":["../../src/core/use-canvas.
|
|
1
|
+
{"version":3,"file":"main4.mjs","sources":["../../src/core/use-canvas.ts"],"sourcesContent":["import { CanvasProps } from \"../api/canvas-props\";\nimport { FromLngLat } from \"./generic-map\";\nimport { useCoords } from \"./use-coords\";\nimport { useCreateRoot } from \"./use-create-root\";\nimport { useRender } from \"./use-render\";\n\nexport interface useCanvasProps extends CanvasProps {\n fromLngLat: FromLngLat,\n}\n\nexport function useCanvas({\n longitude, latitude, altitude = 0,\n frameloop = 'always',\n fromLngLat,\n ...renderProps\n}: useCanvasProps) {\n\n const m4 = useCoords({\n latitude, longitude, altitude, fromLngLat,\n });\n\n const { id, onAdd, onRemove, r3mRef } = useCreateRoot({ frameloop, fromLngLat, ...renderProps });\n\n const render = useRender(m4, r3mRef, frameloop);\n\n return { id, onAdd, onRemove, render }\n}"],"names":["useCanvas","longitude","latitude","altitude","frameloop","fromLngLat","renderProps","m4","useCoords","id","onAdd","onRemove","r3mRef","useCreateRoot","render","useRender"],"mappings":";;;AAUO,SAASA,EAAU;AAAA,EACxB,WAAAC;AAAA,EAAW,UAAAC;AAAA,EAAU,UAAAC,IAAW;AAAA,EAChC,WAAAC,IAAY;AAAA,EACZ,YAAAC;AAAA,EACA,GAAGC;AACL,GAAmB;AAEjB,QAAMC,IAAKC,EAAU;AAAA,IACnB,UAAAN;AAAA,IAAU,WAAAD;AAAA,IAAW,UAAAE;AAAA,IAAU,YAAAE;AAAA,EAAA,CAChC,GAEK,EAAE,IAAAI,GAAI,OAAAC,GAAO,UAAAC,GAAU,QAAAC,EAAO,IAAIC,EAAc,EAAE,WAAAT,GAAW,YAAAC,GAAY,GAAGC,EAAa,CAAA,GAEzFQ,IAASC,EAAUR,GAAIK,GAAQR,CAAS;AAE9C,SAAO,EAAE,IAAAK,GAAI,OAAAC,GAAO,UAAAC,GAAU,QAAAG,EAAO;AACvC;"}
|
package/dist/es/main5.mjs
CHANGED
|
@@ -1,63 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { createEvents as d } from "./main7.mjs";
|
|
4
|
-
import { useFunction as c } from "./main8.mjs";
|
|
5
|
-
function w(e, { frameloop: u, ...n }) {
|
|
6
|
-
const [l, r] = h(!1), g = c((t, m) => {
|
|
7
|
-
const o = t.getCanvas(), i = v(o);
|
|
8
|
-
i.configure({
|
|
9
|
-
dpr: window.devicePixelRatio,
|
|
10
|
-
events: d(),
|
|
11
|
-
...n,
|
|
12
|
-
frameloop: "never",
|
|
13
|
-
gl: {
|
|
14
|
-
context: m,
|
|
15
|
-
depth: !0,
|
|
16
|
-
autoClear: !1,
|
|
17
|
-
antialias: !0,
|
|
18
|
-
...n == null ? void 0 : n.gl
|
|
19
|
-
},
|
|
20
|
-
onCreated: (a) => {
|
|
21
|
-
u === "demand" && a.set({
|
|
22
|
-
frameloop: u,
|
|
23
|
-
invalidate: () => {
|
|
24
|
-
t.triggerRepaint();
|
|
25
|
-
}
|
|
26
|
-
}), e.current = {
|
|
27
|
-
state: a,
|
|
28
|
-
map: t,
|
|
29
|
-
root: i
|
|
30
|
-
}, a.gl.forceContextLoss = () => {
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
camera: {
|
|
34
|
-
matrixAutoUpdate: !1
|
|
35
|
-
},
|
|
36
|
-
size: {
|
|
37
|
-
width: o.clientWidth,
|
|
38
|
-
height: o.clientHeight,
|
|
39
|
-
top: 0,
|
|
40
|
-
left: 0,
|
|
41
|
-
...n == null ? void 0 : n.size
|
|
42
|
-
}
|
|
43
|
-
}), e.current = {
|
|
44
|
-
map: t,
|
|
45
|
-
root: i
|
|
46
|
-
}, t.on("resize", s), setTimeout(() => r(!0));
|
|
47
|
-
}), s = c(() => {
|
|
48
|
-
var i;
|
|
49
|
-
if (!((i = e.current) != null && i.state))
|
|
50
|
-
return;
|
|
51
|
-
const t = e.current.state, o = e.current.map.getCanvas();
|
|
52
|
-
t.setSize(o.width, o.height);
|
|
53
|
-
}), f = c((t) => {
|
|
54
|
-
setTimeout(() => {
|
|
55
|
-
e.current && (e.current.root.unmount(), t.off("resize", s));
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
return { onAdd: g, onRemove: f, mounted: l };
|
|
59
|
-
}
|
|
1
|
+
import { useThree as r } from "@react-three/fiber";
|
|
2
|
+
const m = () => r((e) => e.r3m);
|
|
60
3
|
export {
|
|
61
|
-
|
|
4
|
+
m as useR3M
|
|
62
5
|
};
|
|
63
6
|
//# sourceMappingURL=main5.mjs.map
|
package/dist/es/main5.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main5.mjs","sources":["../../src/core/
|
|
1
|
+
{"version":3,"file":"main5.mjs","sources":["../../src/core/store.ts"],"sourcesContent":["import { ReconcilerRoot, RootState, useThree } from \"@react-three/fiber\";\nimport { Matrix4Tuple } from \"three\";\nimport { FromLngLat, MapInstance } from \"./generic-map\";\n\n/** react-three-map store */\nexport interface R3mStore {\n fromLngLat: FromLngLat,\n map?: MapInstance;\n mapCamMx?: Matrix4Tuple;\n state?: RootState\n root?: ReconcilerRoot<HTMLCanvasElement>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useR3M = (): R3mStore => useThree((s: any) => s.r3m);"],"names":["useR3M","useThree","s"],"mappings":";AAcO,MAAMA,IAAS,MAAgBC,EAAS,CAACC,MAAWA,EAAE,GAAG;"}
|
package/dist/es/main6.mjs
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { Matrix4 as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return m((l, a) => {
|
|
6
|
-
var e;
|
|
7
|
-
if (!((e = r.current) != null && e.state))
|
|
8
|
-
return;
|
|
9
|
-
const t = r.current.state.camera, c = r.current.state.gl, i = r.current.state.advance;
|
|
10
|
-
t.projectionMatrix.fromArray(a).multiply(p.fromArray(n)), t.projectionMatrixInverse.copy(t.projectionMatrix).invert(), c.resetState(), i(Date.now() * 1e-3, !0), o === "always" && r.current.map.triggerRepaint();
|
|
11
|
-
});
|
|
1
|
+
import { Matrix4 as i } from "three";
|
|
2
|
+
const n = new i();
|
|
3
|
+
function p(r, o, t) {
|
|
4
|
+
r.projectionMatrix.fromArray(t).multiply(n.fromArray(o)), r.projectionMatrixInverse.copy(r.projectionMatrix).invert();
|
|
12
5
|
}
|
|
13
6
|
export {
|
|
14
|
-
|
|
7
|
+
p as syncCamera
|
|
15
8
|
};
|
|
16
9
|
//# sourceMappingURL=main6.mjs.map
|
package/dist/es/main6.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main6.mjs","sources":["../../src/core/
|
|
1
|
+
{"version":3,"file":"main6.mjs","sources":["../../src/core/sync-camera.ts"],"sourcesContent":["import { Matrix4, Matrix4Tuple, PerspectiveCamera } from \"three\";\n\nconst mx = new Matrix4();\n\nexport function syncCamera(camera: PerspectiveCamera, origin: Matrix4Tuple, mapCamMx: Matrix4Tuple) {\n camera.projectionMatrix.fromArray(mapCamMx).multiply(mx.fromArray(origin));\n camera.projectionMatrixInverse.copy(camera.projectionMatrix).invert();\n}"],"names":["mx","Matrix4","syncCamera","camera","origin","mapCamMx"],"mappings":";AAEA,MAAMA,IAAK,IAAIC;AAEC,SAAAC,EAAWC,GAA2BC,GAAsBC,GAAwB;AAC3F,EAAAF,EAAA,iBAAiB,UAAUE,CAAQ,EAAE,SAASL,EAAG,UAAUI,CAAM,CAAC,GACzED,EAAO,wBAAwB,KAAKA,EAAO,gBAAgB,EAAE;AAC/D;"}
|