isard 2.2.2 → 2.3.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 +17 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/isard_grid_bg.wasm +0 -0
- package/dist/isard_webgl2_bg.wasm +0 -0
- package/dist/isard_webgpu_bg.wasm +0 -0
- package/dist/map/clip-volume.d.ts +60 -0
- package/dist/map/clip-volume.js +352 -0
- package/dist/map/clip-volume.js.map +1 -0
- package/dist/map/events.js +1 -1
- package/dist/map/events.js.map +1 -1
- package/dist/map.d.ts +9 -9
- package/dist/map.js +21 -21
- package/dist/map.js.map +1 -1
- package/dist/react/ClipVolume.d.ts +10 -0
- package/dist/react/ClipVolume.js +22 -0
- package/dist/react/ClipVolume.js.map +1 -0
- package/dist/react/IsardMap.d.ts +1 -1
- package/dist/react/IsardMap.js +1 -1
- package/dist/react/IsardMap.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/dist/types.d.ts +44 -18
- package/dist/types.js.map +1 -1
- package/dist/ui/style.js +6 -6
- package/dist/ui/style.js.map +1 -1
- package/dist/wasm/isard_webgl2.d.ts +11 -9
- package/dist/wasm/isard_webgl2.js +15 -10
- package/dist/wasm/isard_webgpu.d.ts +11 -9
- package/dist/wasm/isard_webgpu.js +15 -10
- package/package.json +1 -1
- package/dist/map/clip-box.d.ts +0 -52
- package/dist/map/clip-box.js +0 -233
- package/dist/map/clip-box.js.map +0 -1
- package/dist/react/ClipBox.d.ts +0 -9
- package/dist/react/ClipBox.js +0 -21
- package/dist/react/ClipBox.js.map +0 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** `<ClipVolume>`: a volume cutting the map's 3D layers (a box, a cylinder, a prism on a polygon), its handles' changes
|
|
2
|
+
* told back */
|
|
3
|
+
import { useEffect } from 'react';
|
|
4
|
+
import { useMap, useMapEvent } from "./context.js";
|
|
5
|
+
/** The map's clipping volume (`GeoMap.setClipVolume`) while mounted */
|
|
6
|
+
export const ClipVolume = ({ onChange, ...volume }) => {
|
|
7
|
+
const map = useMap();
|
|
8
|
+
// Numbers, strings and arrays: compared by value
|
|
9
|
+
const options = JSON.stringify(volume);
|
|
10
|
+
// The layers whole again when unmounted
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!map)
|
|
13
|
+
return;
|
|
14
|
+
return () => map.setClipVolume(undefined);
|
|
15
|
+
}, [map]);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
map?.setClipVolume(JSON.parse(options));
|
|
18
|
+
}, [map, options]);
|
|
19
|
+
useMapEvent('clipvolume', (moved) => onChange?.(moved));
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=ClipVolume.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClipVolume.js","sourceRoot":"","sources":["../../src/react/ClipVolume.tsx"],"names":[],"mappings":"AAAA;eACe;AAEf,OAAO,EAAkB,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAOnD,uEAAuE;AACvE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAmB,EAAa,EAAE;IAChF,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC;IACrB,iDAAiD;IACjD,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEvC,wCAAwC;IACxC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,GAAG;YAAE,OAAO;QAEjB,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACV,SAAS,CAAC,GAAG,EAAE;QACb,GAAG,EAAE,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB,CAAC,CAAC;IAC/D,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IACnB,WAAW,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAExD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["/** `<ClipVolume>`: a volume cutting the map's 3D layers (a box, a cylinder, a prism on a polygon), its handles' changes\n * told back */\n\nimport { type ReactNode, useEffect } from 'react';\nimport type { ClipVolume as ClipVolumeOptions } from '../types.ts';\nimport { useMap, useMapEvent } from './context.ts';\n\nexport type ClipVolumeProps = ClipVolumeOptions & {\n /** The volume moved or sized by its handles (`handles`): keep it in a state to follow them */\n onChange?: (volume: ClipVolumeOptions) => void;\n};\n\n/** The map's clipping volume (`GeoMap.setClipVolume`) while mounted */\nexport const ClipVolume = ({ onChange, ...volume }: ClipVolumeProps): ReactNode => {\n const map = useMap();\n // Numbers, strings and arrays: compared by value\n const options = JSON.stringify(volume);\n\n // The layers whole again when unmounted\n useEffect(() => {\n if (!map) return;\n\n return () => map.setClipVolume(undefined);\n }, [map]);\n useEffect(() => {\n map?.setClipVolume(JSON.parse(options) as ClipVolumeOptions);\n }, [map, options]);\n useMapEvent('clipvolume', (moved) => onChange?.(moved));\n\n return null;\n};\n"]}
|
package/dist/react/IsardMap.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface MapEventProps {
|
|
|
16
16
|
onQuality?: (event: MapEvents['quality']) => void;
|
|
17
17
|
onIdle?: () => void;
|
|
18
18
|
onLeave?: () => void;
|
|
19
|
-
|
|
19
|
+
onClipVolume?: (event: MapEvents['clipvolume']) => void;
|
|
20
20
|
}
|
|
21
21
|
export interface IsardMapProps extends Omit<GeoMapOptions, keyof Camera>, MapEventProps {
|
|
22
22
|
/** The camera at creation, then left to the user's gestures */
|
package/dist/react/IsardMap.js
CHANGED
|
@@ -16,7 +16,7 @@ const EVENT_PROPS = {
|
|
|
16
16
|
onQuality: 'quality',
|
|
17
17
|
onIdle: 'idle',
|
|
18
18
|
onLeave: 'leave',
|
|
19
|
-
|
|
19
|
+
onClipVolume: 'clipvolume',
|
|
20
20
|
};
|
|
21
21
|
/** The props that are not options of the map */
|
|
22
22
|
const NOT_OPTIONS = [...Object.keys(EVENT_PROPS), 'onLoad', 'onError', 'hoverPicking', 'id', 'className', 'style'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IsardMap.js","sourceRoot":"","sources":["../../src/react/IsardMap.tsx"],"names":[],"mappings":";AAAA,iHAAiH;AAEjH,OAAO,EAEL,UAAU,EAEV,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAgB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAkBjE,MAAM,WAAW,GAAG;IAClB,WAAW,EAAE,WAAW;IACxB,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,OAAO;IAChB,cAAc,EAAE,cAAc;IAC9B,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,SAAS;IACpB,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,OAAO;IAChB,SAAS,EAAE,SAAS;CAC2C,CAAC;AAuBlE,gDAAgD;AAChD,MAAM,WAAW,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAEnH,MAAM,WAAW,GAAG,CAAC,G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C,OAAO;gBAAE,OAAO;YAClD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAChB,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,0EAA0E;IAC1E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,GAAG,IAAI,YAAY;YAAE,GAAG,CAAC,YAAY,GAAG,YAAY,CAAC;IAC3D,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;IAExB,mHAAmH;IACnH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,GAAG,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC;YAAE,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACnF,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IAElB,OAAO,CACL,cAAK,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,YAC5E,OAAO,CAAC,CAAC,CAAC,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YAAG,KAAK,CAAC,QAAQ,GAAuB,CAAC,CAAC,CAAC,IAAI,GACzF,CACP,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/** `<IsardMap>`: the map, created when it mounts, destroyed when it unmounts, its options and events as props */\n\nimport {\n type CSSProperties,\n forwardRef,\n type ReactNode,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { LayerOrder } from '../bind/layers.ts';\nimport { GeoMap } from '../map.ts';\nimport type { GeoMapOptions, LonLat, MapEvents, ViewshedOptions } from '../types.ts';\nimport type { Camera } from '../wasm/isard_webgpu.js';\nimport { type Binding, defined, MapContext } from './context.ts';\n\n/** The props of the map's events: `onClick` for 'click', `onMoveEnd` for 'moveend'… */\nexport interface MapEventProps {\n onMoveStart?: (camera: Camera) => void;\n onMove?: (camera: Camera) => void;\n onMoveEnd?: (camera: Camera) => void;\n onResize?: (event: MapEvents['resize']) => void;\n onHover?: (event: MapEvents['hover']) => void;\n onHoverFeature?: (event: MapEvents['hoverfeature']) => void;\n onClick?: (event: MapEvents['click']) => void;\n onRender?: (event: MapEvents['render']) => void;\n onQuality?: (event: MapEvents['quality']) => void;\n onIdle?: () => void;\n onLeave?: () => void;\n onClipBox?: (event: MapEvents['clipbox']) => void;\n}\n\nconst EVENT_PROPS = {\n onMoveStart: 'movestart',\n onMove: 'move',\n onMoveEnd: 'moveend',\n onResize: 'resize',\n onHover: 'hover',\n onHoverFeature: 'hoverfeature',\n onClick: 'click',\n onRender: 'render',\n onQuality: 'quality',\n onIdle: 'idle',\n onLeave: 'leave',\n onClipBox: 'clipbox',\n} as const satisfies Record<keyof MapEventProps, keyof MapEvents>;\n\nexport interface IsardMapProps extends Omit<GeoMapOptions, keyof Camera>, MapEventProps {\n /** The camera at creation, then left to the user's gestures */\n center?: LonLat;\n zoom?: number;\n pitch?: number;\n bearing?: number;\n /** A camera the map follows: set again whenever it changes (with `onMove` to keep it in a state) */\n camera?: Partial<Camera>;\n /** What `onHoverFeature` picks: within `radius` CSS pixels, among `layers` (default every layer) */\n hoverPicking?: GeoMap['hoverPicking'];\n /** The map, once created */\n onLoad?: (map: GeoMap) => void;\n /** The map's creation failed (no WebGL2, the engine not found) */\n onError?: (error: unknown) => void;\n id?: string;\n className?: string;\n style?: CSSProperties;\n /** Layers, markers, popups, panels, effects; drawn once the map is created */\n children?: ReactNode;\n}\n\n/** The props that are not options of the map */\nconst NOT_OPTIONS = [...Object.keys(EVENT_PROPS), 'onLoad', 'onError', 'hoverPicking', 'id', 'className', 'style'];\n\nconst isEventProp = (key: string): key is keyof typeof EVENT_PROPS => key in EVENT_PROPS;\n\n/** Options the map takes again after its creation, and how */\nconst LIVE_OPTIONS: { [K in keyof GeoMapOptions]?: (map: GeoMap, props: IsardMapProps) => void } = {\n quality: (map, p) => map.setQuality(p.quality ?? 'high'),\n basemap: (map, p) => {\n if (p.basemap) map.setBasemap(p.basemap, p.hillshade);\n },\n hillshade: (map, p) => {\n if (p.basemap) map.setBasemap(p.basemap, p.hillshade);\n },\n terrain: (map, p) => map.setTerrain(p.terrain ?? false),\n minZoom: (map, p) => map.setMinZoom(p.minZoom ?? 0),\n maxZoom: (map, p) => map.setMaxZoom(p.maxZoom ?? 22),\n maxPitch: (map, p) => map.setMaxPitch(p.maxPitch ?? 70),\n atmosphere: (map, p) => map.setAtmosphere(p.atmosphere),\n projection: (map, p) => map.setProjection(p.projection ?? 'globe'),\n loading: (map, p) => map.setLoading(p.loading ?? 'immediate'),\n sky: (map, p) => map.setSky(p.sky ?? true),\n sun: (map, p) => map.setSun(p.sun),\n background: (map, p) => {\n if (p.background) map.setBackground(p.background);\n },\n};\n\nconst isLiveOption = (key: string): key is keyof typeof LIVE_OPTIONS => key in LIVE_OPTIONS;\n\nconst optionsOf = (props: Partial<IsardMapProps>): GeoMapOptions =>\n Object.fromEntries(Object.entries(props).filter(([key]) => !NOT_OPTIONS.includes(key))) as GeoMapOptions;\n\nconst sameCamera = (a: Camera, b: Partial<Camera>): boolean =>\n (b.center === undefined || (a.center[0] === b.center[0] && a.center[1] === b.center[1])) &&\n (b.zoom === undefined || a.zoom === b.zoom) &&\n (b.pitch === undefined || a.pitch === b.pitch) &&\n (b.bearing === undefined || a.bearing === b.bearing);\n\n/** What the components of a new map share */\nconst bindingOf = (map: GeoMap): Binding => {\n const viewsheds = new Map<object, ViewshedOptions>();\n\n return {\n map,\n order: new LayerOrder(),\n viewsheds,\n applyViewsheds: () => map.setViewshed(viewsheds.size > 0 ? [...viewsheds.values()] : undefined),\n };\n};\n\n/**\n * A map filling its element (give it a height). Created once mounted, destroyed when unmounted; the options read at\n * creation only (`body`, `preset`, `interactive`, the URLs) need a new `key` to take another value\n */\nexport const IsardMap = forwardRef<GeoMap | undefined, IsardMapProps>(function IsardMap(props, ref) {\n const element = useRef<HTMLDivElement>(null);\n const latest = useRef(props);\n const applied = useRef<IsardMapProps>(props);\n const [binding, setBinding] = useState<Binding>();\n const map = binding?.map;\n const { camera, hoverPicking } = props;\n\n latest.current = props;\n useImperativeHandle(ref, () => map, [map]);\n\n // Created once: StrictMode's second mount and an unmount before the engine is loaded drop the map they started\n useEffect(() => {\n const container = element.current;\n\n if (!container) return;\n\n const created: { map?: GeoMap; cancelled: boolean } = { cancelled: false };\n const { camera, center, zoom, pitch, bearing, children: _, ...options } = latest.current;\n\n GeoMap.create(container, { ...optionsOf(options), ...defined({ center, zoom, pitch, bearing }), ...camera }).then(\n (map) => {\n if (created.cancelled) {\n map.destroy();\n\n return;\n }\n\n created.map = map;\n setBinding(bindingOf(map));\n latest.current.onLoad?.(map);\n },\n (error: unknown) => {\n if (created.cancelled) return;\n if (latest.current.onError) latest.current.onError(error);\n else console.error(error);\n },\n );\n\n return () => {\n created.cancelled = true;\n created.map?.destroy();\n setBinding(undefined);\n };\n }, []);\n\n // The events, each listened to once: the props may give another function at each render\n useEffect(() => {\n if (!map) return;\n\n const offs = Object.keys(EVENT_PROPS)\n .filter(isEventProp)\n .map((prop) =>\n map.on(EVENT_PROPS[prop], (event) => (latest.current[prop] as ((e: unknown) => void) | undefined)?.(event)),\n );\n\n return () => {\n offs.forEach((off) => {\n off();\n });\n };\n }, [map]);\n\n // The options taken again, compared with what the map was given last\n useEffect(() => {\n if (!map) return;\n\n const last = applied.current;\n const done = new Set<(map: GeoMap, props: IsardMapProps) => void>();\n\n applied.current = props;\n Object.keys(LIVE_OPTIONS)\n .filter(isLiveOption)\n .forEach((key) => {\n const apply = LIVE_OPTIONS[key];\n const changed = !Object.is(last[key], props[key]);\n\n if (!apply || done.has(apply) || !changed) return;\n done.add(apply);\n apply(map, props);\n });\n });\n\n // What `onHoverFeature` picks, given to the map whenever the prop changes\n useEffect(() => {\n if (map && hoverPicking) map.hoverPicking = hoverPicking;\n }, [map, hoverPicking]);\n\n // A controlled camera: set when the prop changes, unless the map is already there (a gesture reported by `onMove`)\n useEffect(() => {\n if (map && camera && !sameCamera(map.getCamera(), camera)) map.setCamera(camera);\n }, [map, camera]);\n\n return (\n <div ref={element} id={props.id} className={props.className} style={props.style}>\n {binding ? <MapContext.Provider value={binding}>{props.children}</MapContext.Provider> : null}\n </div>\n );\n});\n"]}
|
|
1
|
+
{"version":3,"file":"IsardMap.js","sourceRoot":"","sources":["../../src/react/IsardMap.tsx"],"names":[],"mappings":";AAAA,iHAAiH;AAEjH,OAAO,EAEL,UAAU,EAEV,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGnC,OAAO,EAAgB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAkBjE,MAAM,WAAW,GAAG;IAClB,WAAW,EAAE,WAAW;IACxB,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,OAAO;IAChB,cAAc,EAAE,cAAc;IAC9B,OAAO,EAAE,OAAO;IAChB,QAAQ,EAAE,QAAQ;IAClB,SAAS,EAAE,SAAS;IACpB,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,OAAO;IAChB,YAAY,EAAE,YAAY;CACqC,CAAC;AAuBlE,gDAAgD;AAChD,MAAM,WAAW,GAAG,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAEnH,MAAM,WAAW,GAAG,CAAC,GAAW,EAAmC,EAAE,CAAC,GAAG,IAAI,WAAW,CAAC;AA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,KAAK,CAAC,CAAC;YAChB,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACpB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,0EAA0E;IAC1E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,GAAG,IAAI,YAAY;YAAE,GAAG,CAAC,YAAY,GAAG,YAAY,CAAC;IAC3D,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC;IAExB,mHAAmH;IACnH,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,GAAG,IAAI,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,MAAM,CAAC;YAAE,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACnF,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC;IAElB,OAAO,CACL,cAAK,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,YAC5E,OAAO,CAAC,CAAC,CAAC,KAAC,UAAU,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YAAG,KAAK,CAAC,QAAQ,GAAuB,CAAC,CAAC,CAAC,IAAI,GACzF,CACP,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/** `<IsardMap>`: the map, created when it mounts, destroyed when it unmounts, its options and events as props */\n\nimport {\n type CSSProperties,\n forwardRef,\n type ReactNode,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { LayerOrder } from '../bind/layers.ts';\nimport { GeoMap } from '../map.ts';\nimport type { GeoMapOptions, LonLat, MapEvents, ViewshedOptions } from '../types.ts';\nimport type { Camera } from '../wasm/isard_webgpu.js';\nimport { type Binding, defined, MapContext } from './context.ts';\n\n/** The props of the map's events: `onClick` for 'click', `onMoveEnd` for 'moveend'… */\nexport interface MapEventProps {\n onMoveStart?: (camera: Camera) => void;\n onMove?: (camera: Camera) => void;\n onMoveEnd?: (camera: Camera) => void;\n onResize?: (event: MapEvents['resize']) => void;\n onHover?: (event: MapEvents['hover']) => void;\n onHoverFeature?: (event: MapEvents['hoverfeature']) => void;\n onClick?: (event: MapEvents['click']) => void;\n onRender?: (event: MapEvents['render']) => void;\n onQuality?: (event: MapEvents['quality']) => void;\n onIdle?: () => void;\n onLeave?: () => void;\n onClipVolume?: (event: MapEvents['clipvolume']) => void;\n}\n\nconst EVENT_PROPS = {\n onMoveStart: 'movestart',\n onMove: 'move',\n onMoveEnd: 'moveend',\n onResize: 'resize',\n onHover: 'hover',\n onHoverFeature: 'hoverfeature',\n onClick: 'click',\n onRender: 'render',\n onQuality: 'quality',\n onIdle: 'idle',\n onLeave: 'leave',\n onClipVolume: 'clipvolume',\n} as const satisfies Record<keyof MapEventProps, keyof MapEvents>;\n\nexport interface IsardMapProps extends Omit<GeoMapOptions, keyof Camera>, MapEventProps {\n /** The camera at creation, then left to the user's gestures */\n center?: LonLat;\n zoom?: number;\n pitch?: number;\n bearing?: number;\n /** A camera the map follows: set again whenever it changes (with `onMove` to keep it in a state) */\n camera?: Partial<Camera>;\n /** What `onHoverFeature` picks: within `radius` CSS pixels, among `layers` (default every layer) */\n hoverPicking?: GeoMap['hoverPicking'];\n /** The map, once created */\n onLoad?: (map: GeoMap) => void;\n /** The map's creation failed (no WebGL2, the engine not found) */\n onError?: (error: unknown) => void;\n id?: string;\n className?: string;\n style?: CSSProperties;\n /** Layers, markers, popups, panels, effects; drawn once the map is created */\n children?: ReactNode;\n}\n\n/** The props that are not options of the map */\nconst NOT_OPTIONS = [...Object.keys(EVENT_PROPS), 'onLoad', 'onError', 'hoverPicking', 'id', 'className', 'style'];\n\nconst isEventProp = (key: string): key is keyof typeof EVENT_PROPS => key in EVENT_PROPS;\n\n/** Options the map takes again after its creation, and how */\nconst LIVE_OPTIONS: { [K in keyof GeoMapOptions]?: (map: GeoMap, props: IsardMapProps) => void } = {\n quality: (map, p) => map.setQuality(p.quality ?? 'high'),\n basemap: (map, p) => {\n if (p.basemap) map.setBasemap(p.basemap, p.hillshade);\n },\n hillshade: (map, p) => {\n if (p.basemap) map.setBasemap(p.basemap, p.hillshade);\n },\n terrain: (map, p) => map.setTerrain(p.terrain ?? false),\n minZoom: (map, p) => map.setMinZoom(p.minZoom ?? 0),\n maxZoom: (map, p) => map.setMaxZoom(p.maxZoom ?? 22),\n maxPitch: (map, p) => map.setMaxPitch(p.maxPitch ?? 70),\n atmosphere: (map, p) => map.setAtmosphere(p.atmosphere),\n projection: (map, p) => map.setProjection(p.projection ?? 'globe'),\n loading: (map, p) => map.setLoading(p.loading ?? 'immediate'),\n sky: (map, p) => map.setSky(p.sky ?? true),\n sun: (map, p) => map.setSun(p.sun),\n background: (map, p) => {\n if (p.background) map.setBackground(p.background);\n },\n};\n\nconst isLiveOption = (key: string): key is keyof typeof LIVE_OPTIONS => key in LIVE_OPTIONS;\n\nconst optionsOf = (props: Partial<IsardMapProps>): GeoMapOptions =>\n Object.fromEntries(Object.entries(props).filter(([key]) => !NOT_OPTIONS.includes(key))) as GeoMapOptions;\n\nconst sameCamera = (a: Camera, b: Partial<Camera>): boolean =>\n (b.center === undefined || (a.center[0] === b.center[0] && a.center[1] === b.center[1])) &&\n (b.zoom === undefined || a.zoom === b.zoom) &&\n (b.pitch === undefined || a.pitch === b.pitch) &&\n (b.bearing === undefined || a.bearing === b.bearing);\n\n/** What the components of a new map share */\nconst bindingOf = (map: GeoMap): Binding => {\n const viewsheds = new Map<object, ViewshedOptions>();\n\n return {\n map,\n order: new LayerOrder(),\n viewsheds,\n applyViewsheds: () => map.setViewshed(viewsheds.size > 0 ? [...viewsheds.values()] : undefined),\n };\n};\n\n/**\n * A map filling its element (give it a height). Created once mounted, destroyed when unmounted; the options read at\n * creation only (`body`, `preset`, `interactive`, the URLs) need a new `key` to take another value\n */\nexport const IsardMap = forwardRef<GeoMap | undefined, IsardMapProps>(function IsardMap(props, ref) {\n const element = useRef<HTMLDivElement>(null);\n const latest = useRef(props);\n const applied = useRef<IsardMapProps>(props);\n const [binding, setBinding] = useState<Binding>();\n const map = binding?.map;\n const { camera, hoverPicking } = props;\n\n latest.current = props;\n useImperativeHandle(ref, () => map, [map]);\n\n // Created once: StrictMode's second mount and an unmount before the engine is loaded drop the map they started\n useEffect(() => {\n const container = element.current;\n\n if (!container) return;\n\n const created: { map?: GeoMap; cancelled: boolean } = { cancelled: false };\n const { camera, center, zoom, pitch, bearing, children: _, ...options } = latest.current;\n\n GeoMap.create(container, { ...optionsOf(options), ...defined({ center, zoom, pitch, bearing }), ...camera }).then(\n (map) => {\n if (created.cancelled) {\n map.destroy();\n\n return;\n }\n\n created.map = map;\n setBinding(bindingOf(map));\n latest.current.onLoad?.(map);\n },\n (error: unknown) => {\n if (created.cancelled) return;\n if (latest.current.onError) latest.current.onError(error);\n else console.error(error);\n },\n );\n\n return () => {\n created.cancelled = true;\n created.map?.destroy();\n setBinding(undefined);\n };\n }, []);\n\n // The events, each listened to once: the props may give another function at each render\n useEffect(() => {\n if (!map) return;\n\n const offs = Object.keys(EVENT_PROPS)\n .filter(isEventProp)\n .map((prop) =>\n map.on(EVENT_PROPS[prop], (event) => (latest.current[prop] as ((e: unknown) => void) | undefined)?.(event)),\n );\n\n return () => {\n offs.forEach((off) => {\n off();\n });\n };\n }, [map]);\n\n // The options taken again, compared with what the map was given last\n useEffect(() => {\n if (!map) return;\n\n const last = applied.current;\n const done = new Set<(map: GeoMap, props: IsardMapProps) => void>();\n\n applied.current = props;\n Object.keys(LIVE_OPTIONS)\n .filter(isLiveOption)\n .forEach((key) => {\n const apply = LIVE_OPTIONS[key];\n const changed = !Object.is(last[key], props[key]);\n\n if (!apply || done.has(apply) || !changed) return;\n done.add(apply);\n apply(map, props);\n });\n });\n\n // What `onHoverFeature` picks, given to the map whenever the prop changes\n useEffect(() => {\n if (map && hoverPicking) map.hoverPicking = hoverPicking;\n }, [map, hoverPicking]);\n\n // A controlled camera: set when the prop changes, unless the map is already there (a gesture reported by `onMove`)\n useEffect(() => {\n if (map && camera && !sameCamera(map.getCamera(), camera)) map.setCamera(camera);\n }, [map, camera]);\n\n return (\n <div ref={element} id={props.id} className={props.className} style={props.style}>\n {binding ? <MapContext.Provider value={binding}>{props.children}</MapContext.Provider> : null}\n </div>\n );\n});\n"]}
|
package/dist/react/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type { GeoMap, LayerSpec } from '../map.ts';
|
|
|
19
19
|
export type { LonLat } from '../types.ts';
|
|
20
20
|
export type { Marker as MarkerHandle, Panel as PanelHandle, Popup as PopupHandle } from '../ui/overlay.ts';
|
|
21
21
|
export type { Camera } from '../wasm/isard_webgpu.js';
|
|
22
|
-
export {
|
|
22
|
+
export { ClipVolume, type ClipVolumeProps } from './ClipVolume.tsx';
|
|
23
23
|
export { Control, type ControlProps } from './Control.tsx';
|
|
24
24
|
export { CustomLayer, type CustomLayerProps } from './CustomLayer.tsx';
|
|
25
25
|
export { useMap, useMapEvent } from './context.ts';
|
package/dist/react/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* </IsardMap>
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
|
-
export {
|
|
17
|
+
export { ClipVolume } from "./ClipVolume.js";
|
|
18
18
|
export { Control } from "./Control.js";
|
|
19
19
|
export { CustomLayer } from "./CustomLayer.js";
|
|
20
20
|
export { useMap, useMapEvent } from "./context.js";
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,EAAE,UAAU,EAAwB,MAAM,iBAAkB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAqB,MAAM,cAAe,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAyB,MAAM,kBAAmB,CAAC;AACvE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,QAAQ,EAA0C,MAAM,eAAgB,CAAC;AAClF,OAAO,EAAE,KAAK,EAAsD,MAAM,YAAa,CAAC;AACxF,OAAO,EAAE,MAAM,EAAoB,MAAM,aAAc,CAAC;AACxD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAa,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAmB,MAAM,YAAa,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAsB,cAAc,EAA4B,MAAM,qBAAsB,CAAC;AAC9G,OAAO,EACL,UAAU,EACV,SAAS,EACT,MAAM,EACN,KAAK,EACL,MAAM,EACN,KAAK,EACL,cAAc,EACd,WAAW,GAEZ,MAAM,kBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAgB,CAAC","sourcesContent":["/**\n * Isard in React: the map, its layers, markers, popups, panels and effects as components, created when they mount,\n * updated by the least their props need and removed when they unmount.\n *\n * ```tsx\n * <IsardMap preset=\"ign-3d\" center={[2.35, 48.85]} zoom={15} style={{ height: 400 }}>\n * <VectorTiles style={OPENFREEMAP_STYLES.liberty}>\n * <Geometry roofs=\"generated\" />\n * <Trees />\n * <Labels />\n * </VectorTiles>\n * <Layer type=\"lines\" data={routes} color=\"#0057b8\" width={3} />\n * <Marker lonLat={[2.35, 48.85]}><Popup>Here</Popup></Marker>\n * </IsardMap>\n * ```\n */\n\nexport type { Layer as LayerHandle } from '../layers/layers.ts';\nexport type { GeoMap, LayerSpec } from '../map.ts';\nexport type { LonLat } from '../types.ts';\nexport type { Marker as MarkerHandle, Panel as PanelHandle, Popup as PopupHandle } from '../ui/overlay.ts';\nexport type { Camera } from '../wasm/isard_webgpu.js';\nexport { ClipVolume, type ClipVolumeProps } from './ClipVolume.tsx';\nexport { Control, type ControlProps } from './Control.tsx';\nexport { CustomLayer, type CustomLayerProps } from './CustomLayer.tsx';\nexport { useMap, useMapEvent } from './context.ts';\nexport { IsardMap, type IsardMapProps, type MapEventProps } from './IsardMap.tsx';\nexport { Layer, type LayerHandles, type LayerProps, type LayerType } from './Layer.tsx';\nexport { Marker, type MarkerProps } from './Marker.tsx';\nexport { Panel, type PanelProps } from './Panel.tsx';\nexport { Popup, type PopupProps } from './Popup.tsx';\nexport { Swipe, SwipeOther, type SwipeProps } from './Swipe.tsx';\nexport { Geometry, type GeometryProps, VectorGeometry, type VectorGeometryProps } from './VectorGeometry.tsx';\nexport {\n Extrusions,\n Furniture,\n Labels,\n Lamps,\n Raster,\n Trees,\n useVectorTiles,\n VectorTiles,\n type VectorTilesProps,\n} from './VectorTiles.tsx';\nexport { Viewshed } from './Viewshed.tsx';\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -244,32 +244,57 @@ export interface ViewshedOptions {
|
|
|
244
244
|
/** Angle of view up and down, degrees (default 40) */
|
|
245
245
|
verticalFov?: number;
|
|
246
246
|
}
|
|
247
|
-
/**
|
|
248
|
-
|
|
249
|
-
* clouds; the ground and the flat layers stay whole. What lies inside it is cut, all around it stays (a cutaway, to
|
|
250
|
-
* look into a building or under the ground), or what lies outside it (a BIM viewer's section box); the faces the cut
|
|
251
|
-
* opens filled, as a section on a plan.
|
|
252
|
-
*/
|
|
253
|
-
export interface ClipBox {
|
|
254
|
-
/** The center of its foot */
|
|
255
|
-
position: LonLat;
|
|
247
|
+
/** What every clipping volume has (`ClipVolume`) */
|
|
248
|
+
interface ClipVolumeBase {
|
|
256
249
|
/** Metres of its foot above the ground (or above the ellipsoid, `altitudeReference: 'sea'`); 0 by default */
|
|
257
250
|
altitude?: number;
|
|
258
251
|
/** What the altitude is above: `'ground'` (the relief, the default) or `'sea'` (the ellipsoid), as the models' */
|
|
259
252
|
altitudeReference?: 'ground' | 'sea';
|
|
260
|
-
/** Metres
|
|
261
|
-
|
|
262
|
-
/**
|
|
263
|
-
heading?: number;
|
|
264
|
-
/** What is cut: `'inside'` (the default) what lies inside the box, `'outside'` what lies outside it */
|
|
253
|
+
/** Metres up from its foot */
|
|
254
|
+
height: number;
|
|
255
|
+
/** What is cut: `'inside'` (the default) what lies inside the volume, `'outside'` what lies outside it */
|
|
265
256
|
cut?: 'inside' | 'outside';
|
|
266
257
|
/** A CSS color for the faces the cut opens, the inside of walls and floors (default `#d9cfc1`); `null` leaves them
|
|
267
258
|
* open */
|
|
268
259
|
sectionColor?: string | null;
|
|
269
|
-
/** Handles on the
|
|
270
|
-
* each
|
|
260
|
+
/** Handles on the volume to size and move it with the pointer: a disc on each of a box's faces, on a cylinder's rim,
|
|
261
|
+
* on each of a polygon's vertices, on the top and the bottom, and one at its middle to move it; the map tells each
|
|
262
|
+
* change by `'clipvolume'`. None by default */
|
|
271
263
|
handles?: boolean;
|
|
272
264
|
}
|
|
265
|
+
/** A box: its foot's center, its size, its heading */
|
|
266
|
+
export interface ClipBox extends ClipVolumeBase {
|
|
267
|
+
shape: 'box';
|
|
268
|
+
/** The center of its foot */
|
|
269
|
+
position: LonLat;
|
|
270
|
+
/** Metres across its heading */
|
|
271
|
+
width: number;
|
|
272
|
+
/** Metres along its heading */
|
|
273
|
+
length: number;
|
|
274
|
+
/** Degrees clockwise from north of its length; 0 by default */
|
|
275
|
+
heading?: number;
|
|
276
|
+
}
|
|
277
|
+
/** A cylinder standing up: its foot's center, its radius */
|
|
278
|
+
export interface ClipCylinder extends ClipVolumeBase {
|
|
279
|
+
shape: 'cylinder';
|
|
280
|
+
/** The center of its foot */
|
|
281
|
+
position: LonLat;
|
|
282
|
+
/** Metres */
|
|
283
|
+
radius: number;
|
|
284
|
+
}
|
|
285
|
+
/** A prism standing on a polygon: a building's outline, a plot */
|
|
286
|
+
export interface ClipPolygon extends ClipVolumeBase {
|
|
287
|
+
shape: 'polygon';
|
|
288
|
+
/** Its vertices, 3 to 16, open (its last not repeating its first) */
|
|
289
|
+
polygon: LonLat[];
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* A volume cutting the map's 3D layers (`GeoMap.setClipVolume`): a box, a cylinder or a prism on a polygon. The models,
|
|
293
|
+
* the 3D Tiles, the extrusions and the point clouds are cut; the ground and the flat layers stay whole. What lies
|
|
294
|
+
* inside it is cut, all around it stays (a cutaway, to look into a building or under the ground), or what lies outside
|
|
295
|
+
* it (a BIM viewer's section box); the faces the cut opens filled, as a section on a plan.
|
|
296
|
+
*/
|
|
297
|
+
export type ClipVolume = ClipBox | ClipCylinder | ClipPolygon;
|
|
273
298
|
/** An eye at street level (`GeoMap.setFirstPerson`) */
|
|
274
299
|
export interface FirstPersonView {
|
|
275
300
|
/** Where it stands */
|
|
@@ -503,8 +528,8 @@ export interface MapEvents {
|
|
|
503
528
|
idle: Record<string, never>;
|
|
504
529
|
/** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */
|
|
505
530
|
leave: Record<string, never>;
|
|
506
|
-
/** The clipping
|
|
507
|
-
|
|
531
|
+
/** The clipping volume moved or was sized by its handles (`ClipVolume.handles`): the volume now set */
|
|
532
|
+
clipvolume: ClipVolume;
|
|
508
533
|
}
|
|
509
534
|
/** What a layer handle needs from its map */
|
|
510
535
|
export interface LayerHost {
|
|
@@ -523,3 +548,4 @@ export interface LayerHost {
|
|
|
523
548
|
/** What its quality draws (`GeoMap.setQuality`) */
|
|
524
549
|
readonly quality: QualitySettings;
|
|
525
550
|
}
|
|
551
|
+
export {};
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,0CAA0C","sourcesContent":["/** Public types of the `isard` package */\n\nimport type { TileGrid } from './basemap/grid.ts';\nimport type { DecoderUrls } from './decoding/decoders.ts';\nimport type { Feature, Ramp, Size } from './layers/features.ts';\nimport type { Layer } from './layers/layers.ts';\nimport type { RasterLayer } from './layers/raster.ts';\nimport type { QualitySettings } from './map/quality.ts';\nimport type { AttributionOptions } from './ui/controls.ts';\nimport type { Camera, Engine } from './wasm/isard_webgpu.js';\n\nexport type LonLat = [lon: number, lat: number];\nexport type Point = [x: number, y: number];\n\n/**\n * The named basemaps. OpenFreeMap's vector styles, OpenStreetMap data worldwide, their labels above the other layers:\n * `osm-positron` (light grey, quiet: data over it reads first), `osm-liberty` and `osm-bright` (in colour), `osm-dark`\n * (near black: bright data over it, a wind's particles, lights). The\n * Géoplateforme's (IGN, France): rasters (`ign-plan`, `ign-plan-grey`, `ign-ortho`, the aerial photographs) or vector\n * tiles with their labels (`ign-plan-vector`, `ign-plan-grey-vector`, the PLAN.IGN styles).\n */\nexport type BasemapName =\n | 'osm-positron'\n | 'osm-liberty'\n | 'osm-bright'\n | 'osm-dark'\n | 'ign-plan'\n | 'ign-plan-grey'\n | 'ign-ortho'\n | 'ign-plan-vector'\n | 'ign-plan-grey-vector'\n | 'none';\n\n/** A basemap by name (see `BasemapName`) */\nexport type Basemap = BasemapName;\n\n/**\n * The Earth's named terrain models. `'terrain-tiles'`: worldwide, the Terrain Tiles of AWS's open data registry\n * (SRTM, EU-DEM, GMTED… merged by Mapzen, 30 m in most places), the sea floor flattened at sea level. `'ign'`: France,\n * the IGN's RGE ALTI from the Géoplateforme (1 to 5 m), raised by the RAF20 geoid to heights above the ellipsoid.\n */\nexport type TerrainModel = 'terrain-tiles' | 'ign';\n\n/** How tiles encode their altitudes: `'float32'`, raw little-endian floats (`image/x-bil;bits=32`, an ArcGIS raw\n * grid); `'terrarium'`, the colors of a PNG, `R × 256 + G + B / 256 - 32768`; `'mapbox'`, those of Terrain-RGB,\n * `(R × 65536 + G × 256 + B) / 10 - 10000` */\nexport type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';\n\n/**\n * How tiles load and show. 'immediate' (default): everything visible loads, tiles show as soon as they arrive.\n * 'smooth': during flights the levels flown through are skipped, off-center tiles wait while the camera moves, tiles\n * fade in; fewer downloads, for slow networks or GPUs.\n */\nexport type LoadingMode = 'immediate' | 'smooth';\n\n/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7, up to three levels later under a\n * tilted camera (it sees much farther than its center: the horizon stays curved) */\nexport type Projection = 'globe' | 'mercator';\n\n/** A body to draw the map on, other than the named ones (`CelestialBody`) */\nexport interface BodyOptions {\n /** Equatorial radius, metres */\n radius: number;\n /** Flattening of its ellipsoid, 0 for a sphere (default 0) */\n flattening?: number;\n /** An atmosphere: its halo around the globe, true for the Earth's light blue, or a CSS color (its alpha the\n * halo's strength) (default false) */\n atmosphere?: boolean | string;\n /** Color of the globe where no tile covers it (past the Web Mercator latitudes, 85°), a CSS color (default\n * `#808080`) */\n color?: string;\n /** Lowest and highest altitudes of its ground, metres around the ellipsoid: what its relief may raise into view\n * (default ±1 % of the radius) */\n relief?: [lowest: number, highest: number];\n}\n\n/**\n * The body the map is drawn on: 'earth' (WGS 84, the default), 'moon' (a sphere of 1 737 400 m, no atmosphere),\n * 'mars' (a sphere of 3 396 190 m, its equatorial radius, a thin dusty halo; planetocentric latitudes) or another\n * one. Zoom levels keep their meaning on screen (the Web Mercator tile pyramid), their metres follow the body:\n * altitudes, relief, buildings, 3D Tiles. Off the Earth, the map has none of the Earth's defaults: no basemap, no\n * credits, and space for its background; the Moon and Mars have NASA's relief for `terrain: true`.\n */\nexport type CelestialBody = 'earth' | 'moon' | 'mars' | BodyOptions;\n\n/** A level of the map's quality (`GeoMapOptions.quality`) */\nexport type Quality = 'high' | 'medium' | 'low';\n\nexport interface GeoMapOptions extends Partial<Camera> {\n /** The body the map is drawn on (default 'earth'); set at creation */\n body?: CelestialBody;\n /** Default 'globe' */\n projection?: Projection;\n /** Default 'immediate' */\n loading?: LoadingMode;\n /** The basemap (default 'osm-positron'; 'none' off the Earth) */\n basemap?: Basemap;\n /** Opacity of the IGN hillshade over the basemap (France, Géoplateforme), 0 for none (default 0) */\n hillshade?: number;\n /** Color behind the map (sky of tilted flat views), a CSS color (default `#f2f2f0`; black off the Earth) */\n background?: string;\n /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */\n sky?: boolean;\n /** The sun casting the shadows of buildings, trees, models and the relief (`setSun`); none by default */\n sun?: SunOptions;\n /** What the map draws less of on a device that cannot keep up (`setQuality`): `'high'` (the default) all of it;\n * `'medium'` at most 1.5 device pixels a CSS pixel, the 3D Tiles coarser far away; `'low'` one device pixel a CSS\n * pixel, no sun's shadows, the 3D Tiles coarser still; `'auto'` high, a level lower each time the frames stay slow\n * while the map moves (`'quality'` event) */\n quality?: Quality | 'auto';\n /** The GPU memory, megabytes, the layers' tiles (3D Tiles, point clouds, vector tiles) and the rasters' tiles may\n * hold all together: past it the tiles drawn least recently are unloaded, whichever their layer, the vector tiles\n * (those of the view) kept (`GeoMap.memory`). `'auto'` (the default): 256 on a touch screen (a phone, a tablet: iOS\n * closes a page past about a gigabyte, the page's workers included), 1024 elsewhere. Set at creation */\n memory?: number | 'auto';\n /** Multisampled antialiasing of the canvas (default true): the edges of the buildings, 3D Tiles and models smooth.\n * False draws each pixel once (lines and halos antialias themselves): wide translucent layers, a network's halo over\n * a region, cost up to four times less on an integrated GPU (MapLibre's default). Set at creation */\n antialias?: boolean;\n /** The engine on wgpu (#146): 'auto' (default) WebGPU where the browser gives an adapter, else wgpu's WebGL2 fallback;\n * 'webgpu' or 'webgl' forces one */\n renderer?: 'auto' | 'webgpu' | 'webgl2';\n /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on\n * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options\n * (default false; on another body, its `url` is required). Network layers are draped on it */\n terrain?: boolean | TerrainModel | TerrainOptions;\n minZoom?: number;\n maxZoom?: number;\n /** Highest pitch, degrees, up to 85 (default 70) */\n maxPitch?: number;\n /** Sky over the plane, seen when the camera is tilted towards the horizon, and the fog the ground fades into\n * (MapLibre's `setSky`); default none: the background color */\n atmosphere?: AtmosphereOptions;\n /** Mouse, touch and keyboard controls (default true) */\n interactive?: boolean;\n /** Keyboard controls once the map has the focus (it is reached with Tab): arrows pan, Shift + arrows rotate and\n * tilt, + and - zoom (Shift: two levels), 0 faces north and levels the view (default true; none when not\n * `interactive`) */\n keyboard?: boolean;\n /** Accessible name of the map, read by screen readers (default 'Map') */\n ariaLabel?: string;\n /** A preset of map options (`IGN_PRESETS`: `'ign'`, `'ign-3d'`, `'ign-ortho-3d'`), the other options over it */\n preset?: 'ign' | 'ign-3d' | 'ign-ortho-3d';\n /** The folder isard's files are served from (its engines, `isard_webgpu_bg.wasm`, `isard_webgl2_bg.wasm`, its\n * modules, `isard_points_bg.wasm`, `isard_tiles3d_bg.wasm`, `isard_tess_bg.wasm`, `isard_grid_bg.wasm`, and its\n * workers, `decoder.worker.js`, `basemap.worker.js`): one option for a bundler that moves them, the `…Url` options\n * below for each one. `isard/vite` sets it for the whole page; default next to the module */\n assetsUrl?: string | URL;\n /** Where to load the engine on WebGPU from (`isard_webgpu_bg.wasm`), when a bundler does not resolve the default URL */\n webgpuWasmUrl?: string | URL;\n /** Where to load the engine's WebGL2 fallback from (`isard_webgl2_bg.wasm`, for a browser without WebGPU), when a\n * bundler does not resolve the default URL */\n webgl2WasmUrl?: string | URL;\n /** Where the decoding workers load the point cloud module from (`isard_points_bg.wasm`, the LAZ decoder of COPC),\n * when a bundler does not resolve the default URL. Loaded with the first point cloud only */\n pointsWasmUrl?: string | URL;\n /** Where the decoding workers load the 3D Tiles module from (`isard_tiles3d_bg.wasm`: a tile's content decoded for\n * the GPU), when a bundler does not resolve the default URL. Loaded with the first tile */\n tiles3dWasmUrl?: string | URL;\n /** Where the basemap workers load the tessellation module from (`isard_tess_bg.wasm`: the vector tiles drawn as\n * geometry, `vectorTiles().vectors()`, made ready for the GPU off the main thread), when a bundler does not resolve\n * the default URL. Loaded with the first tile of geometry; without it, the main thread does that work */\n tessWasmUrl?: string | URL;\n /** Where the workers load the grid module from (`isard_grid_bg.wasm`: GRIB2 and NetCDF files read by\n * `map.readGrids`), when a bundler does not resolve the default URL. Loaded with the first file */\n gridWasmUrl?: string | URL;\n /** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */\n basemapWorkerUrl?: string | URL;\n /** Texture size of the vector basemap's tiles, pixels (default 512: lines and edges sharp at every zoom on a screen\n * of pixel ratio 1). 256: a quarter of the drawing in the workers, of the uploads and of the GPU memory, for lines\n * and edges a little softer between two zoom levels (the tiles are shown 181 to 362 CSS pixels wide) */\n basemapTileSize?: number;\n /** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default\n * OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */\n glyphs?: string;\n /** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,\n * 1 to 4). False (or 0) also decodes the PNG relief and reprojects the equirectangular rasters on the main thread,\n * else done by the vector basemap's workers */\n workers?: number | false;\n /** Where to load the decoding worker from, when a bundler does not resolve the default URL */\n workerUrl?: string | URL;\n /** Folders of the Draco and Basis Universal decoders, loaded by the workers on first use (default: the official\n * builds on gstatic.com and jsDelivr; self-host them for offline or locked-down networks). They run through\n * `new Function`: a Content Security Policy needs `'unsafe-eval'` (see `DecoderUrls`) */\n decoders?: Partial<DecoderUrls>;\n /** Credits at the bottom right: false for none, or its options (default true: the credits of the basemap,\n * hillshade and relief in use, compact on maps narrower than 640 px) */\n attributionControl?: boolean | AttributionOptions;\n}\n\nexport interface TerrainOptions {\n /** One of the Earth's named models (default `'terrain-tiles'` on the Earth); unused with a `url` */\n model?: TerrainModel;\n /** Altitudes of 256 × 256 tiles in `encoding`: a WMS GetMap URL with {bbox} (EPSG:3857 on the Earth, the body's\n * Mercator metres elsewhere: the sphere of its radius), a tile URL with {z}, {x} and {y}, or an ArcGIS image service\n * (a URL ending in `/ImageServer`), asked for raw altitudes in the body's Mercator (default: the `model`'s; on the\n * Moon and Mars, NASA's Trek LOLA and MOLA models) */\n url?: string;\n /** How the tiles of `url` encode their altitudes (default `'float32'`); `'terrarium'` and `'mapbox'` take a URL with\n * {z}, {x} and {y} */\n encoding?: TerrainEncoding;\n /** Vertical exaggeration, 1 for the true relief (default 1) */\n exaggeration?: number;\n /** Finest level of the relief, up to 15 (default 15; 14 for the Terrain Tiles, 8 for the Moon's and Mars's models). It\n * starts at level 6 on the Earth, coarser on bodies of a larger relief for their size (3 on the Moon and Mars) */\n maxZoom?: number;\n /** Altitudes over mainland France raised by the height of the RAF20 geoid (the French one, 0 away from France), to\n * heights above the ellipsoid (those of 3D Tiles); false keeps the altitudes as served (NGF-IGN69 for the IGN's)\n * (default true for the `'ign'` model, false otherwise) */\n geoid?: boolean;\n}\n\n/** Sky, horizon and fog over the plane, with the names and meanings of MapLibre's `setSky` */\nexport interface AtmosphereOptions {\n /** A CSS color (default `#9cc7ec`) */\n skyColor?: string;\n /** (default `#e8f1f8`) */\n horizonColor?: string;\n /** (default `#f2f5f8`) */\n fogColor?: string;\n /** Blend from the horizon to the sky color, share of the field of view above the horizon, 0-1 (default 0.6) */\n skyHorizonBlend?: number;\n /** Blend from the horizon to the fog color below the horizon, 0-1 (default 0.7) */\n horizonFogBlend?: number;\n /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */\n fogGroundBlend?: number;\n}\n\n/** The sun casting shadows (`GeoMap.setSun`): where it stands, by date or by hand, and how dark its shadows are */\nexport interface SunOptions {\n /** The time: the sun where it stands then over the map's center (default now, unless `azimuth` and `altitude`) */\n date?: Date;\n /** Degrees clockwise from north, with `altitude`: the sun placed by hand */\n azimuth?: number;\n /** Degrees above the horizon; at or under it, no shadows */\n altitude?: number;\n /** How dark the shadows are, 0 to 1 (default 0.35) */\n opacity?: number;\n /** How dark the night is, 0 to 1: the scene tinted in its blue, the windows of the buildings and the streets of\n * `vectors()` lit, the labels light on dark. By default from the sun's altitude: falling from 6° above the horizon\n * to 6° under it */\n night?: number;\n}\n\n/** What can be seen from a point (`GeoMap.setViewshed`); with several observers, the colors, the opacity and the\n * cone's color are the first one's */\nexport interface ViewshedOptions {\n /** The observer */\n position: LonLat;\n /** Metres above the ground (default 1.7, eye level) */\n height?: number;\n /** Metres around the observer that are tinted (default 1000) */\n range?: number;\n /** A CSS color for what is seen (default `#2f9e44`) */\n visibleColor?: string;\n /** A CSS color for what is hidden (default `#e03131`) */\n hiddenColor?: string;\n /** How strongly the colors tint the scene, multiplied into it so that its textures and shading stay, 0-1 (default\n * 0.7) */\n opacity?: number;\n /** A CSS color for the cone drawn in 3D (one way only): its fan through the axis, at the eye's height and tilted\n * with it, from the eye to the range; solid where nothing hides it, faint behind the scene; none by default */\n coneColor?: string;\n /** To look one way only (a camera, a lookout), degrees clockwise from north; all around without it */\n direction?: number;\n /** Degrees above the horizon the cone looks, negative below (default 0) */\n tilt?: number;\n /** Angle of view across, degrees (default 60) */\n fov?: number;\n /** Angle of view up and down, degrees (default 40) */\n verticalFov?: number;\n}\n\n/**\n * A box cutting the map's 3D layers (`GeoMap.setClipBox`): the models, the 3D Tiles, the extrusions and the point\n * clouds; the ground and the flat layers stay whole. What lies inside it is cut, all around it stays (a cutaway, to\n * look into a building or under the ground), or what lies outside it (a BIM viewer's section box); the faces the cut\n * opens filled, as a section on a plan.\n */\nexport interface ClipBox {\n /** The center of its foot */\n position: LonLat;\n /** Metres of its foot above the ground (or above the ellipsoid, `altitudeReference: 'sea'`); 0 by default */\n altitude?: number;\n /** What the altitude is above: `'ground'` (the relief, the default) or `'sea'` (the ellipsoid), as the models' */\n altitudeReference?: 'ground' | 'sea';\n /** Metres across its heading, along it, and up */\n size: [width: number, length: number, height: number];\n /** Degrees clockwise from north of its length; 0 by default */\n heading?: number;\n /** What is cut: `'inside'` (the default) what lies inside the box, `'outside'` what lies outside it */\n cut?: 'inside' | 'outside';\n /** A CSS color for the faces the cut opens, the inside of walls and floors (default `#d9cfc1`); `null` leaves them\n * open */\n sectionColor?: string | null;\n /** Handles on the box to size it (one on each face) and move it (one at its middle) with the pointer; the map tells\n * each change by `'clipbox'`. None by default */\n handles?: boolean;\n}\n\n/** An eye at street level (`GeoMap.setFirstPerson`) */\nexport interface FirstPersonView {\n /** Where it stands */\n lonLat: LonLat;\n /** Metres above the ground (default 1.7) */\n height?: number;\n /** Degrees clockwise from north it looks to */\n bearing: number;\n /** Degrees from straight down: 90 level (the default), 180 straight up */\n pitch?: number;\n /** Vertical field of view, degrees (default 75) */\n fov?: number;\n}\n\n/** Layers shown on one side of a vertical line only (`GeoMap.setSwipe`) */\nexport interface SwipeOptions {\n /** CSS pixels from the left of the map */\n position: number;\n layers: readonly Layer[];\n /** The side they show on (default 'left') */\n side?: 'left' | 'right';\n /** Layers shown on the other side only: two meshes of the same place, each on its side, never drawn over each other */\n other?: readonly Layer[];\n}\n\n/** Animation of a camera move */\nexport interface AnimationOptions {\n /** Milliseconds */\n duration?: number;\n /** Progress over time, both 0 to 1 */\n easing?: (t: number) => number;\n}\n\nexport interface FlyToOptions extends AnimationOptions {\n /** How far the flight zooms out on its way, as MapLibre's `curve` (default 1.42) */\n curve?: number;\n /** Average speed in screens per second when `duration` is not given (default 1.2) */\n speed?: number;\n}\n\n/**\n * Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':\n * longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the\n * north (NASA's Trek WMTS, WorldCRS84Quad). A `TileGrid`: the tile matrices of a WMTS in any CRS (Lambert-93…), or a\n * WMS asked for each tile's box in its CRS. The last two are reprojected into Web Mercator tiles by the map's workers\n * (in the page with `workers: false`).\n */\nexport type RasterGrid = 'mercator' | 'equirectangular' | TileGrid;\n\n/** The GPU memory of a map's layers (`GeoMap.memory`), bytes */\nexport interface MapMemory {\n /** What they may hold (`GeoMapOptions.memory`) */\n budget: number;\n /** What they hold: the tiles of the 3D Tiles, point clouds and vector tiles, the pools of the rasters' tiles (the\n * relief's included), each one's full from its creation */\n held: number;\n /** Each layer's, bottom first */\n layers: { layer: Layer; bytes: number }[];\n}\n\n/** What `RasterLayer.setStyle` changes */\nexport interface RasterStyle {\n opacity: number;\n /** 0 = greyscale, 1 = original colors */\n saturation: number;\n}\n\n/** Where a new layer goes: under `before`, or on top of the others (under the labels kept on top) */\nexport interface Placement {\n before?: Layer;\n}\n\nexport interface RasterOptions extends Placement {\n /** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */\n url: string;\n /** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that\n * grid; with a `TileGrid`, they are map zooms, by default those its matrices span */\n grid?: RasterGrid;\n minZoom?: number;\n maxZoom?: number;\n opacity?: number;\n /** 0 = greyscale, 1 = original colors */\n saturation?: number;\n /** Side of the tiles' textures, pixels (default 256): more for sharper tiles drawn by a `loader` */\n size?: number;\n /** Draws each tile instead of fetching `url`: an image of `size` × `size`, null for nothing there; a rejection is\n * retried like a network error */\n loader?: (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n /** Credits of the tiles, HTML: shown by the attribution control while the layer is on the map */\n attribution?: string;\n /** Drawn on the ground (default true); false: only on the 3D layers it is draped on (`Tiles3dOptions.drape`), its\n * tiles still loaded as the ground's would be: a solar potential on the roofs only */\n ground?: boolean;\n}\n\nexport interface NetworkStyle {\n /** Line width, CSS pixels, or zoom stops `[[zoom, width], …]` (default 2) */\n width: Size;\n /** Values above are drawn as unreached (default 1800) */\n max: number;\n /** Darker line every `contour` value units, 0 for none (default 0) */\n contour: number;\n opacity: number;\n /** Width of the halo drawn under the lines, CSS pixels or zoom stops, 0 for none (default 0): wide and faint, the\n * reached streets add up into a heat map that fills the blocks */\n halo: Size;\n /** Opacity of the halo at the middle of a line, fading quadratically to its sides (default 0.11) */\n haloOpacity: number;\n /** Colors from 0 to `max`: `[[fraction of max, color], …]` (default green to red) */\n ramp: Ramp | undefined;\n /** Color of the parts beyond `max` or unreached (default `rgba(140, 140, 140, 0.25)`) */\n unreachedColor: string;\n /** Share of `max` over which the colors fade out before it, 0 to 1 (default 0) */\n fade: number;\n}\n\nexport interface NetworkOptions extends Partial<NetworkStyle>, Placement {\n /** Node coordinates in degrees: lon0, lat0, lon1, lat1… */\n nodes: Float64Array;\n /** Edges as node index pairs: a0, b0, a1, b1… */\n edges: Uint32Array;\n /** Line of each edge, from A to B: the points of edge e are `points[start[e] .. start[e + 1]]` (lon, lat pairs,\n * counted in points); with fewer than two points an edge is straight. Default: all straight. */\n lines?: { start: Uint32Array; points: Float64Array };\n /** Per edge, the cost of travelling it from A to B then from B to A, in value units (Infinity: closed that way;\n * closed both ways: not drawn). A point along an edge then takes the quickest way there, min(value(A) + cost from\n * A, value(B) + cost from B), as a travel time does. Without costs, values are interpolated along the edges. */\n costs?: Float32Array;\n /** Width factor of each edge (default 1): rail lines wider than streets */\n edgeWidths?: Float32Array;\n}\n\nexport interface Tiles3dStyle {\n /** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */\n maxScreenSpaceError: number;\n opacity: number;\n /** Size of the points of point cloud tiles (`.pnts`, glTF points), CSS pixels: 2 by default */\n pointSize?: number;\n /** A CSS color multiplying the textures of the meshes, the color of the untextured ones (buildings without\n * textures are light grey without it); none by default */\n color?: string;\n /** Each feature's color from its properties (a building's height, its use: a thematic map), in place of `color`: a\n * CSS color, or undefined for the layer's. Asked once for each feature of a tile, when the tile is first drawn, and\n * again for every tile when it changes (in React, keep the same function from one render to the next) */\n featureColor?: FeatureColor | undefined;\n}\n\n/** A feature's color from its properties and its index in its tile (`Tiles3dStyle.featureColor`) */\nexport type FeatureColor = (properties: Record<string, unknown>, feature: number) => string | undefined;\n\nexport interface Tiles3dOptions extends Partial<Tiles3dStyle>, Placement {\n /** URL of a `tileset.json` (3D Tiles 1.0 b3dm and pnts, 1.1 glb meshes and points, external tilesets) */\n url: string;\n /** Its heights are altitudes above the geoid (NGF-IGN69), as the IGN's Bâtiments 3D, rather than above the\n * ellipsoid (3D Tiles as specified): each tile raised by the RAF20 geoid, onto the IGN relief (default false) */\n geoid?: boolean;\n /** The walls of its untextured meshes show windows: glass by day, some lit at night (`setFacades`; default false) */\n facades?: boolean;\n /** A raster layer draped on its meshes (`setDrape`): an ortho or a solar potential on the roofs */\n drape?: Drape | undefined;\n}\n\n/** A raster layer draped on a 3D layer's faces (3D Tiles, extrusions, a vector tiles layer's buildings, models), as\n * Cesium's imagery on 3D Tiles: each point of a face takes the raster's color where it stands (its longitude and\n * latitude, whatever its height) */\nexport interface Drape {\n /** The raster layer, on the same map (with `ground: false`, on the 3D layers only) */\n raster: RasterLayer;\n /** 'up': the faces looking up, the roofs (default); 'all': the walls too, the raster stretched down them */\n faces?: 'up' | 'all';\n /** 0 to 1 (default 1), times the raster layer's opacity */\n opacity?: number;\n}\n\nexport interface MapPointerEvent {\n point: Point;\n /** Undefined above the horizon */\n lonLat: LonLat | undefined;\n}\n\n/** What 'hoverfeature' found under the pointer */\nexport interface MapHoverFeatureEvent extends MapPointerEvent {\n /** The feature under the pointer (see `GeoMap.pickFeature`), undefined if none */\n hit: FeatureHit | undefined;\n}\n\n/** The GPU time of a frame (`GeoMap.gpuTimings`), in all and by part (ms) */\nexport interface MapGpuTimings {\n /** The frame's number */\n frame: number;\n ms: number;\n /** The backdrop (sky, globe), the ground (the raster layers over the relief), each layer (with its handle), the\n * shadows, the panorama, the viewshed */\n parts: { part: 'backdrop' | 'ground' | 'layer' | 'shadows' | 'panorama' | 'viewshed'; layer?: Layer; ms: number }[];\n}\n\n/** What a pick looks at: within `radius` CSS pixels of the point (default 0), among `layers` (default every layer;\n * the others hide nothing) */\nexport interface PickOptions {\n radius?: number;\n layers?: readonly Layer[];\n}\n\n/** A picked feature: its layer handle, its index there and, for line, circle, fill, extrusion, point cloud and 3D\n * Tiles layers, the feature itself (a building of 3D Tiles with its properties) */\nexport interface FeatureHit {\n layer: Layer;\n index: number;\n feature: Feature | undefined;\n}\n\nexport interface MapEvents {\n /** The camera started moving (a gesture, an animation or `setCamera`) */\n movestart: Camera;\n /** The camera moved */\n move: Camera;\n /** The camera stopped: no gesture held, no animation running */\n moveend: Camera;\n /** The map changed size (CSS pixels) */\n resize: { width: number; height: number };\n /** The pointer moved over the map (at most once per frame, not while dragging) */\n hover: MapPointerEvent;\n /** What is under the pointer, picked without stalling the GPU: a frame or two after 'hover', only while listened to\n * (radius and layers in `GeoMap.hoverPicking`) */\n hoverfeature: MapHoverFeatureEvent;\n /** Click without drag */\n click: MapPointerEvent;\n /** A frame was drawn; duration of the engine call in milliseconds */\n render: { ms: number };\n /** The map's quality changed, by `setQuality` or stepped down by `'auto'` */\n quality: { quality: Quality };\n /** Everything in view is loaded and drawn, nothing moves: the end of a load, once after each change (as MapLibre's\n * `idle`). Tiles requested by the first frame count, so it never fires before they arrive. */\n idle: Record<string, never>;\n /** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */\n leave: Record<string, never>;\n /** The clipping box moved or was sized by its handles (`ClipBox.handles`): the box now set */\n clipbox: ClipBox;\n}\n\n/** What a layer handle needs from its map */\nexport interface LayerHost {\n readonly engine: Engine;\n requestRender(): void;\n /** Forgets a removed layer */\n detach(layer: Layer): void;\n /** Moves a layer under `before`, or on top */\n moveLayer(layer: Layer, before: Layer | undefined): void;\n /** A layer created again in the engine (new id): put at the place of its old id, which is removed */\n replaceLayer(layer: Layer, old: number): void;\n /** Resolves once the map is idle (everything in view loaded and drawn) */\n whenIdle(): Promise<void>;\n /** Work the map waits on before it is idle (`GeoMap.track`) */\n track<T>(work: Promise<T>): Promise<T>;\n /** What its quality draws (`GeoMap.setQuality`) */\n readonly quality: QualitySettings;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,0CAA0C","sourcesContent":["/** Public types of the `isard` package */\n\nimport type { TileGrid } from './basemap/grid.ts';\nimport type { DecoderUrls } from './decoding/decoders.ts';\nimport type { Feature, Ramp, Size } from './layers/features.ts';\nimport type { Layer } from './layers/layers.ts';\nimport type { RasterLayer } from './layers/raster.ts';\nimport type { QualitySettings } from './map/quality.ts';\nimport type { AttributionOptions } from './ui/controls.ts';\nimport type { Camera, Engine } from './wasm/isard_webgpu.js';\n\nexport type LonLat = [lon: number, lat: number];\nexport type Point = [x: number, y: number];\n\n/**\n * The named basemaps. OpenFreeMap's vector styles, OpenStreetMap data worldwide, their labels above the other layers:\n * `osm-positron` (light grey, quiet: data over it reads first), `osm-liberty` and `osm-bright` (in colour), `osm-dark`\n * (near black: bright data over it, a wind's particles, lights). The\n * Géoplateforme's (IGN, France): rasters (`ign-plan`, `ign-plan-grey`, `ign-ortho`, the aerial photographs) or vector\n * tiles with their labels (`ign-plan-vector`, `ign-plan-grey-vector`, the PLAN.IGN styles).\n */\nexport type BasemapName =\n | 'osm-positron'\n | 'osm-liberty'\n | 'osm-bright'\n | 'osm-dark'\n | 'ign-plan'\n | 'ign-plan-grey'\n | 'ign-ortho'\n | 'ign-plan-vector'\n | 'ign-plan-grey-vector'\n | 'none';\n\n/** A basemap by name (see `BasemapName`) */\nexport type Basemap = BasemapName;\n\n/**\n * The Earth's named terrain models. `'terrain-tiles'`: worldwide, the Terrain Tiles of AWS's open data registry\n * (SRTM, EU-DEM, GMTED… merged by Mapzen, 30 m in most places), the sea floor flattened at sea level. `'ign'`: France,\n * the IGN's RGE ALTI from the Géoplateforme (1 to 5 m), raised by the RAF20 geoid to heights above the ellipsoid.\n */\nexport type TerrainModel = 'terrain-tiles' | 'ign';\n\n/** How tiles encode their altitudes: `'float32'`, raw little-endian floats (`image/x-bil;bits=32`, an ArcGIS raw\n * grid); `'terrarium'`, the colors of a PNG, `R × 256 + G + B / 256 - 32768`; `'mapbox'`, those of Terrain-RGB,\n * `(R × 65536 + G × 256 + B) / 10 - 10000` */\nexport type TerrainEncoding = 'float32' | 'terrarium' | 'mapbox';\n\n/**\n * How tiles load and show. 'immediate' (default): everything visible loads, tiles show as soon as they arrive.\n * 'smooth': during flights the levels flown through are skipped, off-center tiles wait while the camera moves, tiles\n * fade in; fewer downloads, for slow networks or GPUs.\n */\nexport type LoadingMode = 'immediate' | 'smooth';\n\n/** 'globe': a sphere at low zoom, blending into Web Mercator between zooms 5 and 7, up to three levels later under a\n * tilted camera (it sees much farther than its center: the horizon stays curved) */\nexport type Projection = 'globe' | 'mercator';\n\n/** A body to draw the map on, other than the named ones (`CelestialBody`) */\nexport interface BodyOptions {\n /** Equatorial radius, metres */\n radius: number;\n /** Flattening of its ellipsoid, 0 for a sphere (default 0) */\n flattening?: number;\n /** An atmosphere: its halo around the globe, true for the Earth's light blue, or a CSS color (its alpha the\n * halo's strength) (default false) */\n atmosphere?: boolean | string;\n /** Color of the globe where no tile covers it (past the Web Mercator latitudes, 85°), a CSS color (default\n * `#808080`) */\n color?: string;\n /** Lowest and highest altitudes of its ground, metres around the ellipsoid: what its relief may raise into view\n * (default ±1 % of the radius) */\n relief?: [lowest: number, highest: number];\n}\n\n/**\n * The body the map is drawn on: 'earth' (WGS 84, the default), 'moon' (a sphere of 1 737 400 m, no atmosphere),\n * 'mars' (a sphere of 3 396 190 m, its equatorial radius, a thin dusty halo; planetocentric latitudes) or another\n * one. Zoom levels keep their meaning on screen (the Web Mercator tile pyramid), their metres follow the body:\n * altitudes, relief, buildings, 3D Tiles. Off the Earth, the map has none of the Earth's defaults: no basemap, no\n * credits, and space for its background; the Moon and Mars have NASA's relief for `terrain: true`.\n */\nexport type CelestialBody = 'earth' | 'moon' | 'mars' | BodyOptions;\n\n/** A level of the map's quality (`GeoMapOptions.quality`) */\nexport type Quality = 'high' | 'medium' | 'low';\n\nexport interface GeoMapOptions extends Partial<Camera> {\n /** The body the map is drawn on (default 'earth'); set at creation */\n body?: CelestialBody;\n /** Default 'globe' */\n projection?: Projection;\n /** Default 'immediate' */\n loading?: LoadingMode;\n /** The basemap (default 'osm-positron'; 'none' off the Earth) */\n basemap?: Basemap;\n /** Opacity of the IGN hillshade over the basemap (France, Géoplateforme), 0 for none (default 0) */\n hillshade?: number;\n /** Color behind the map (sky of tilted flat views), a CSS color (default `#f2f2f0`; black off the Earth) */\n background?: string;\n /** Space behind the globe: stars and atmosphere halo, fading out as the globe turns flat (default true) */\n sky?: boolean;\n /** The sun casting the shadows of buildings, trees, models and the relief (`setSun`); none by default */\n sun?: SunOptions;\n /** What the map draws less of on a device that cannot keep up (`setQuality`): `'high'` (the default) all of it;\n * `'medium'` at most 1.5 device pixels a CSS pixel, the 3D Tiles coarser far away; `'low'` one device pixel a CSS\n * pixel, no sun's shadows, the 3D Tiles coarser still; `'auto'` high, a level lower each time the frames stay slow\n * while the map moves (`'quality'` event) */\n quality?: Quality | 'auto';\n /** The GPU memory, megabytes, the layers' tiles (3D Tiles, point clouds, vector tiles) and the rasters' tiles may\n * hold all together: past it the tiles drawn least recently are unloaded, whichever their layer, the vector tiles\n * (those of the view) kept (`GeoMap.memory`). `'auto'` (the default): 256 on a touch screen (a phone, a tablet: iOS\n * closes a page past about a gigabyte, the page's workers included), 1024 elsewhere. Set at creation */\n memory?: number | 'auto';\n /** Multisampled antialiasing of the canvas (default true): the edges of the buildings, 3D Tiles and models smooth.\n * False draws each pixel once (lines and halos antialias themselves): wide translucent layers, a network's halo over\n * a region, cost up to four times less on an integrated GPU (MapLibre's default). Set at creation */\n antialias?: boolean;\n /** The engine on wgpu (#146): 'auto' (default) WebGPU where the browser gives an adapter, else wgpu's WebGL2 fallback;\n * 'webgpu' or 'webgl' forces one */\n renderer?: 'auto' | 'webgpu' | 'webgl2';\n /** Relief under the basemap: true for the body's terrain model (on the Earth the worldwide Terrain Tiles; NASA's on\n * the Moon and Mars: LOLA, MOLA), one of the Earth's models by name (`'ign'`: France, RGE ALTI), or its options\n * (default false; on another body, its `url` is required). Network layers are draped on it */\n terrain?: boolean | TerrainModel | TerrainOptions;\n minZoom?: number;\n maxZoom?: number;\n /** Highest pitch, degrees, up to 85 (default 70) */\n maxPitch?: number;\n /** Sky over the plane, seen when the camera is tilted towards the horizon, and the fog the ground fades into\n * (MapLibre's `setSky`); default none: the background color */\n atmosphere?: AtmosphereOptions;\n /** Mouse, touch and keyboard controls (default true) */\n interactive?: boolean;\n /** Keyboard controls once the map has the focus (it is reached with Tab): arrows pan, Shift + arrows rotate and\n * tilt, + and - zoom (Shift: two levels), 0 faces north and levels the view (default true; none when not\n * `interactive`) */\n keyboard?: boolean;\n /** Accessible name of the map, read by screen readers (default 'Map') */\n ariaLabel?: string;\n /** A preset of map options (`IGN_PRESETS`: `'ign'`, `'ign-3d'`, `'ign-ortho-3d'`), the other options over it */\n preset?: 'ign' | 'ign-3d' | 'ign-ortho-3d';\n /** The folder isard's files are served from (its engines, `isard_webgpu_bg.wasm`, `isard_webgl2_bg.wasm`, its\n * modules, `isard_points_bg.wasm`, `isard_tiles3d_bg.wasm`, `isard_tess_bg.wasm`, `isard_grid_bg.wasm`, and its\n * workers, `decoder.worker.js`, `basemap.worker.js`): one option for a bundler that moves them, the `…Url` options\n * below for each one. `isard/vite` sets it for the whole page; default next to the module */\n assetsUrl?: string | URL;\n /** Where to load the engine on WebGPU from (`isard_webgpu_bg.wasm`), when a bundler does not resolve the default URL */\n webgpuWasmUrl?: string | URL;\n /** Where to load the engine's WebGL2 fallback from (`isard_webgl2_bg.wasm`, for a browser without WebGPU), when a\n * bundler does not resolve the default URL */\n webgl2WasmUrl?: string | URL;\n /** Where the decoding workers load the point cloud module from (`isard_points_bg.wasm`, the LAZ decoder of COPC),\n * when a bundler does not resolve the default URL. Loaded with the first point cloud only */\n pointsWasmUrl?: string | URL;\n /** Where the decoding workers load the 3D Tiles module from (`isard_tiles3d_bg.wasm`: a tile's content decoded for\n * the GPU), when a bundler does not resolve the default URL. Loaded with the first tile */\n tiles3dWasmUrl?: string | URL;\n /** Where the basemap workers load the tessellation module from (`isard_tess_bg.wasm`: the vector tiles drawn as\n * geometry, `vectorTiles().vectors()`, made ready for the GPU off the main thread), when a bundler does not resolve\n * the default URL. Loaded with the first tile of geometry; without it, the main thread does that work */\n tessWasmUrl?: string | URL;\n /** Where the workers load the grid module from (`isard_grid_bg.wasm`: GRIB2 and NetCDF files read by\n * `map.readGrids`), when a bundler does not resolve the default URL. Loaded with the first file */\n gridWasmUrl?: string | URL;\n /** Where to load the vector basemap worker from, when a bundler does not resolve the default URL */\n basemapWorkerUrl?: string | URL;\n /** Texture size of the vector basemap's tiles, pixels (default 512: lines and edges sharp at every zoom on a screen\n * of pixel ratio 1). 256: a quarter of the drawing in the workers, of the uploads and of the GPU memory, for lines\n * and edges a little softer between two zoom levels (the tiles are shown 181 to 362 CSS pixels wide) */\n basemapTileSize?: number;\n /** Glyphs of the symbol layers: a URL with `{fontstack}` and `{range}` (MapLibre's glyph format; default\n * OpenFreeMap's fonts, Noto Sans). A vector basemap's labels take the glyphs of its style */\n glyphs?: string;\n /** Workers decoding 3D Tiles off the main thread: a count, or false to decode on the main thread (default: cores - 1,\n * 1 to 4). False (or 0) also decodes the PNG relief and reprojects the equirectangular rasters on the main thread,\n * else done by the vector basemap's workers */\n workers?: number | false;\n /** Where to load the decoding worker from, when a bundler does not resolve the default URL */\n workerUrl?: string | URL;\n /** Folders of the Draco and Basis Universal decoders, loaded by the workers on first use (default: the official\n * builds on gstatic.com and jsDelivr; self-host them for offline or locked-down networks). They run through\n * `new Function`: a Content Security Policy needs `'unsafe-eval'` (see `DecoderUrls`) */\n decoders?: Partial<DecoderUrls>;\n /** Credits at the bottom right: false for none, or its options (default true: the credits of the basemap,\n * hillshade and relief in use, compact on maps narrower than 640 px) */\n attributionControl?: boolean | AttributionOptions;\n}\n\nexport interface TerrainOptions {\n /** One of the Earth's named models (default `'terrain-tiles'` on the Earth); unused with a `url` */\n model?: TerrainModel;\n /** Altitudes of 256 × 256 tiles in `encoding`: a WMS GetMap URL with {bbox} (EPSG:3857 on the Earth, the body's\n * Mercator metres elsewhere: the sphere of its radius), a tile URL with {z}, {x} and {y}, or an ArcGIS image service\n * (a URL ending in `/ImageServer`), asked for raw altitudes in the body's Mercator (default: the `model`'s; on the\n * Moon and Mars, NASA's Trek LOLA and MOLA models) */\n url?: string;\n /** How the tiles of `url` encode their altitudes (default `'float32'`); `'terrarium'` and `'mapbox'` take a URL with\n * {z}, {x} and {y} */\n encoding?: TerrainEncoding;\n /** Vertical exaggeration, 1 for the true relief (default 1) */\n exaggeration?: number;\n /** Finest level of the relief, up to 15 (default 15; 14 for the Terrain Tiles, 8 for the Moon's and Mars's models). It\n * starts at level 6 on the Earth, coarser on bodies of a larger relief for their size (3 on the Moon and Mars) */\n maxZoom?: number;\n /** Altitudes over mainland France raised by the height of the RAF20 geoid (the French one, 0 away from France), to\n * heights above the ellipsoid (those of 3D Tiles); false keeps the altitudes as served (NGF-IGN69 for the IGN's)\n * (default true for the `'ign'` model, false otherwise) */\n geoid?: boolean;\n}\n\n/** Sky, horizon and fog over the plane, with the names and meanings of MapLibre's `setSky` */\nexport interface AtmosphereOptions {\n /** A CSS color (default `#9cc7ec`) */\n skyColor?: string;\n /** (default `#e8f1f8`) */\n horizonColor?: string;\n /** (default `#f2f5f8`) */\n fogColor?: string;\n /** Blend from the horizon to the sky color, share of the field of view above the horizon, 0-1 (default 0.6) */\n skyHorizonBlend?: number;\n /** Blend from the horizon to the fog color below the horizon, 0-1 (default 0.7) */\n horizonFogBlend?: number;\n /** Share of the distance to the far plane over which the ground fades into the fog, 0-1 (default 0.4) */\n fogGroundBlend?: number;\n}\n\n/** The sun casting shadows (`GeoMap.setSun`): where it stands, by date or by hand, and how dark its shadows are */\nexport interface SunOptions {\n /** The time: the sun where it stands then over the map's center (default now, unless `azimuth` and `altitude`) */\n date?: Date;\n /** Degrees clockwise from north, with `altitude`: the sun placed by hand */\n azimuth?: number;\n /** Degrees above the horizon; at or under it, no shadows */\n altitude?: number;\n /** How dark the shadows are, 0 to 1 (default 0.35) */\n opacity?: number;\n /** How dark the night is, 0 to 1: the scene tinted in its blue, the windows of the buildings and the streets of\n * `vectors()` lit, the labels light on dark. By default from the sun's altitude: falling from 6° above the horizon\n * to 6° under it */\n night?: number;\n}\n\n/** What can be seen from a point (`GeoMap.setViewshed`); with several observers, the colors, the opacity and the\n * cone's color are the first one's */\nexport interface ViewshedOptions {\n /** The observer */\n position: LonLat;\n /** Metres above the ground (default 1.7, eye level) */\n height?: number;\n /** Metres around the observer that are tinted (default 1000) */\n range?: number;\n /** A CSS color for what is seen (default `#2f9e44`) */\n visibleColor?: string;\n /** A CSS color for what is hidden (default `#e03131`) */\n hiddenColor?: string;\n /** How strongly the colors tint the scene, multiplied into it so that its textures and shading stay, 0-1 (default\n * 0.7) */\n opacity?: number;\n /** A CSS color for the cone drawn in 3D (one way only): its fan through the axis, at the eye's height and tilted\n * with it, from the eye to the range; solid where nothing hides it, faint behind the scene; none by default */\n coneColor?: string;\n /** To look one way only (a camera, a lookout), degrees clockwise from north; all around without it */\n direction?: number;\n /** Degrees above the horizon the cone looks, negative below (default 0) */\n tilt?: number;\n /** Angle of view across, degrees (default 60) */\n fov?: number;\n /** Angle of view up and down, degrees (default 40) */\n verticalFov?: number;\n}\n\n/** What every clipping volume has (`ClipVolume`) */\ninterface ClipVolumeBase {\n /** Metres of its foot above the ground (or above the ellipsoid, `altitudeReference: 'sea'`); 0 by default */\n altitude?: number;\n /** What the altitude is above: `'ground'` (the relief, the default) or `'sea'` (the ellipsoid), as the models' */\n altitudeReference?: 'ground' | 'sea';\n /** Metres up from its foot */\n height: number;\n /** What is cut: `'inside'` (the default) what lies inside the volume, `'outside'` what lies outside it */\n cut?: 'inside' | 'outside';\n /** A CSS color for the faces the cut opens, the inside of walls and floors (default `#d9cfc1`); `null` leaves them\n * open */\n sectionColor?: string | null;\n /** Handles on the volume to size and move it with the pointer: a disc on each of a box's faces, on a cylinder's rim,\n * on each of a polygon's vertices, on the top and the bottom, and one at its middle to move it; the map tells each\n * change by `'clipvolume'`. None by default */\n handles?: boolean;\n}\n\n/** A box: its foot's center, its size, its heading */\nexport interface ClipBox extends ClipVolumeBase {\n shape: 'box';\n /** The center of its foot */\n position: LonLat;\n /** Metres across its heading */\n width: number;\n /** Metres along its heading */\n length: number;\n /** Degrees clockwise from north of its length; 0 by default */\n heading?: number;\n}\n\n/** A cylinder standing up: its foot's center, its radius */\nexport interface ClipCylinder extends ClipVolumeBase {\n shape: 'cylinder';\n /** The center of its foot */\n position: LonLat;\n /** Metres */\n radius: number;\n}\n\n/** A prism standing on a polygon: a building's outline, a plot */\nexport interface ClipPolygon extends ClipVolumeBase {\n shape: 'polygon';\n /** Its vertices, 3 to 16, open (its last not repeating its first) */\n polygon: LonLat[];\n}\n\n/**\n * A volume cutting the map's 3D layers (`GeoMap.setClipVolume`): a box, a cylinder or a prism on a polygon. The models,\n * the 3D Tiles, the extrusions and the point clouds are cut; the ground and the flat layers stay whole. What lies\n * inside it is cut, all around it stays (a cutaway, to look into a building or under the ground), or what lies outside\n * it (a BIM viewer's section box); the faces the cut opens filled, as a section on a plan.\n */\nexport type ClipVolume = ClipBox | ClipCylinder | ClipPolygon;\n\n/** An eye at street level (`GeoMap.setFirstPerson`) */\nexport interface FirstPersonView {\n /** Where it stands */\n lonLat: LonLat;\n /** Metres above the ground (default 1.7) */\n height?: number;\n /** Degrees clockwise from north it looks to */\n bearing: number;\n /** Degrees from straight down: 90 level (the default), 180 straight up */\n pitch?: number;\n /** Vertical field of view, degrees (default 75) */\n fov?: number;\n}\n\n/** Layers shown on one side of a vertical line only (`GeoMap.setSwipe`) */\nexport interface SwipeOptions {\n /** CSS pixels from the left of the map */\n position: number;\n layers: readonly Layer[];\n /** The side they show on (default 'left') */\n side?: 'left' | 'right';\n /** Layers shown on the other side only: two meshes of the same place, each on its side, never drawn over each other */\n other?: readonly Layer[];\n}\n\n/** Animation of a camera move */\nexport interface AnimationOptions {\n /** Milliseconds */\n duration?: number;\n /** Progress over time, both 0 to 1 */\n easing?: (t: number) => number;\n}\n\nexport interface FlyToOptions extends AnimationOptions {\n /** How far the flight zooms out on its way, as MapLibre's `curve` (default 1.42) */\n curve?: number;\n /** Average speed in screens per second when `duration` is not given (default 1.2) */\n speed?: number;\n}\n\n/**\n * Tile grid of a raster's URL. 'mercator': Web Mercator (XYZ, WMTS PM), the engine's own. 'equirectangular':\n * longitudes and latitudes (Plate Carrée, EPSG:4326-like), two 256 px tiles side by side at level 0, rows from the\n * north (NASA's Trek WMTS, WorldCRS84Quad). A `TileGrid`: the tile matrices of a WMTS in any CRS (Lambert-93…), or a\n * WMS asked for each tile's box in its CRS. The last two are reprojected into Web Mercator tiles by the map's workers\n * (in the page with `workers: false`).\n */\nexport type RasterGrid = 'mercator' | 'equirectangular' | TileGrid;\n\n/** The GPU memory of a map's layers (`GeoMap.memory`), bytes */\nexport interface MapMemory {\n /** What they may hold (`GeoMapOptions.memory`) */\n budget: number;\n /** What they hold: the tiles of the 3D Tiles, point clouds and vector tiles, the pools of the rasters' tiles (the\n * relief's included), each one's full from its creation */\n held: number;\n /** Each layer's, bottom first */\n layers: { layer: Layer; bytes: number }[];\n}\n\n/** What `RasterLayer.setStyle` changes */\nexport interface RasterStyle {\n opacity: number;\n /** 0 = greyscale, 1 = original colors */\n saturation: number;\n}\n\n/** Where a new layer goes: under `before`, or on top of the others (under the labels kept on top) */\nexport interface Placement {\n before?: Layer;\n}\n\nexport interface RasterOptions extends Placement {\n /** Tile URL with {z}, {x} and {y} (256 px tiles); unused with a `loader` */\n url: string;\n /** Tile grid of `url` (default 'mercator'); with 'equirectangular', `minZoom` and `maxZoom` are levels of that\n * grid; with a `TileGrid`, they are map zooms, by default those its matrices span */\n grid?: RasterGrid;\n minZoom?: number;\n maxZoom?: number;\n opacity?: number;\n /** 0 = greyscale, 1 = original colors */\n saturation?: number;\n /** Side of the tiles' textures, pixels (default 256): more for sharper tiles drawn by a `loader` */\n size?: number;\n /** Draws each tile instead of fetching `url`: an image of `size` × `size`, null for nothing there; a rejection is\n * retried like a network error */\n loader?: (z: number, x: number, y: number, signal: AbortSignal) => Promise<ImageBitmap | null>;\n /** Credits of the tiles, HTML: shown by the attribution control while the layer is on the map */\n attribution?: string;\n /** Drawn on the ground (default true); false: only on the 3D layers it is draped on (`Tiles3dOptions.drape`), its\n * tiles still loaded as the ground's would be: a solar potential on the roofs only */\n ground?: boolean;\n}\n\nexport interface NetworkStyle {\n /** Line width, CSS pixels, or zoom stops `[[zoom, width], …]` (default 2) */\n width: Size;\n /** Values above are drawn as unreached (default 1800) */\n max: number;\n /** Darker line every `contour` value units, 0 for none (default 0) */\n contour: number;\n opacity: number;\n /** Width of the halo drawn under the lines, CSS pixels or zoom stops, 0 for none (default 0): wide and faint, the\n * reached streets add up into a heat map that fills the blocks */\n halo: Size;\n /** Opacity of the halo at the middle of a line, fading quadratically to its sides (default 0.11) */\n haloOpacity: number;\n /** Colors from 0 to `max`: `[[fraction of max, color], …]` (default green to red) */\n ramp: Ramp | undefined;\n /** Color of the parts beyond `max` or unreached (default `rgba(140, 140, 140, 0.25)`) */\n unreachedColor: string;\n /** Share of `max` over which the colors fade out before it, 0 to 1 (default 0) */\n fade: number;\n}\n\nexport interface NetworkOptions extends Partial<NetworkStyle>, Placement {\n /** Node coordinates in degrees: lon0, lat0, lon1, lat1… */\n nodes: Float64Array;\n /** Edges as node index pairs: a0, b0, a1, b1… */\n edges: Uint32Array;\n /** Line of each edge, from A to B: the points of edge e are `points[start[e] .. start[e + 1]]` (lon, lat pairs,\n * counted in points); with fewer than two points an edge is straight. Default: all straight. */\n lines?: { start: Uint32Array; points: Float64Array };\n /** Per edge, the cost of travelling it from A to B then from B to A, in value units (Infinity: closed that way;\n * closed both ways: not drawn). A point along an edge then takes the quickest way there, min(value(A) + cost from\n * A, value(B) + cost from B), as a travel time does. Without costs, values are interpolated along the edges. */\n costs?: Float32Array;\n /** Width factor of each edge (default 1): rail lines wider than streets */\n edgeWidths?: Float32Array;\n}\n\nexport interface Tiles3dStyle {\n /** Screen-space error (CSS pixels) above which a tile is refined: 16 by default, lower is finer and heavier */\n maxScreenSpaceError: number;\n opacity: number;\n /** Size of the points of point cloud tiles (`.pnts`, glTF points), CSS pixels: 2 by default */\n pointSize?: number;\n /** A CSS color multiplying the textures of the meshes, the color of the untextured ones (buildings without\n * textures are light grey without it); none by default */\n color?: string;\n /** Each feature's color from its properties (a building's height, its use: a thematic map), in place of `color`: a\n * CSS color, or undefined for the layer's. Asked once for each feature of a tile, when the tile is first drawn, and\n * again for every tile when it changes (in React, keep the same function from one render to the next) */\n featureColor?: FeatureColor | undefined;\n}\n\n/** A feature's color from its properties and its index in its tile (`Tiles3dStyle.featureColor`) */\nexport type FeatureColor = (properties: Record<string, unknown>, feature: number) => string | undefined;\n\nexport interface Tiles3dOptions extends Partial<Tiles3dStyle>, Placement {\n /** URL of a `tileset.json` (3D Tiles 1.0 b3dm and pnts, 1.1 glb meshes and points, external tilesets) */\n url: string;\n /** Its heights are altitudes above the geoid (NGF-IGN69), as the IGN's Bâtiments 3D, rather than above the\n * ellipsoid (3D Tiles as specified): each tile raised by the RAF20 geoid, onto the IGN relief (default false) */\n geoid?: boolean;\n /** The walls of its untextured meshes show windows: glass by day, some lit at night (`setFacades`; default false) */\n facades?: boolean;\n /** A raster layer draped on its meshes (`setDrape`): an ortho or a solar potential on the roofs */\n drape?: Drape | undefined;\n}\n\n/** A raster layer draped on a 3D layer's faces (3D Tiles, extrusions, a vector tiles layer's buildings, models), as\n * Cesium's imagery on 3D Tiles: each point of a face takes the raster's color where it stands (its longitude and\n * latitude, whatever its height) */\nexport interface Drape {\n /** The raster layer, on the same map (with `ground: false`, on the 3D layers only) */\n raster: RasterLayer;\n /** 'up': the faces looking up, the roofs (default); 'all': the walls too, the raster stretched down them */\n faces?: 'up' | 'all';\n /** 0 to 1 (default 1), times the raster layer's opacity */\n opacity?: number;\n}\n\nexport interface MapPointerEvent {\n point: Point;\n /** Undefined above the horizon */\n lonLat: LonLat | undefined;\n}\n\n/** What 'hoverfeature' found under the pointer */\nexport interface MapHoverFeatureEvent extends MapPointerEvent {\n /** The feature under the pointer (see `GeoMap.pickFeature`), undefined if none */\n hit: FeatureHit | undefined;\n}\n\n/** The GPU time of a frame (`GeoMap.gpuTimings`), in all and by part (ms) */\nexport interface MapGpuTimings {\n /** The frame's number */\n frame: number;\n ms: number;\n /** The backdrop (sky, globe), the ground (the raster layers over the relief), each layer (with its handle), the\n * shadows, the panorama, the viewshed */\n parts: { part: 'backdrop' | 'ground' | 'layer' | 'shadows' | 'panorama' | 'viewshed'; layer?: Layer; ms: number }[];\n}\n\n/** What a pick looks at: within `radius` CSS pixels of the point (default 0), among `layers` (default every layer;\n * the others hide nothing) */\nexport interface PickOptions {\n radius?: number;\n layers?: readonly Layer[];\n}\n\n/** A picked feature: its layer handle, its index there and, for line, circle, fill, extrusion, point cloud and 3D\n * Tiles layers, the feature itself (a building of 3D Tiles with its properties) */\nexport interface FeatureHit {\n layer: Layer;\n index: number;\n feature: Feature | undefined;\n}\n\nexport interface MapEvents {\n /** The camera started moving (a gesture, an animation or `setCamera`) */\n movestart: Camera;\n /** The camera moved */\n move: Camera;\n /** The camera stopped: no gesture held, no animation running */\n moveend: Camera;\n /** The map changed size (CSS pixels) */\n resize: { width: number; height: number };\n /** The pointer moved over the map (at most once per frame, not while dragging) */\n hover: MapPointerEvent;\n /** What is under the pointer, picked without stalling the GPU: a frame or two after 'hover', only while listened to\n * (radius and layers in `GeoMap.hoverPicking`) */\n hoverfeature: MapHoverFeatureEvent;\n /** Click without drag */\n click: MapPointerEvent;\n /** A frame was drawn; duration of the engine call in milliseconds */\n render: { ms: number };\n /** The map's quality changed, by `setQuality` or stepped down by `'auto'` */\n quality: { quality: Quality };\n /** Everything in view is loaded and drawn, nothing moves: the end of a load, once after each change (as MapLibre's\n * `idle`). Tiles requested by the first frame count, so it never fires before they arrive. */\n idle: Record<string, never>;\n /** The pointer left the canvas (a mouse going out of the map, or onto a control or marker) */\n leave: Record<string, never>;\n /** The clipping volume moved or was sized by its handles (`ClipVolume.handles`): the volume now set */\n clipvolume: ClipVolume;\n}\n\n/** What a layer handle needs from its map */\nexport interface LayerHost {\n readonly engine: Engine;\n requestRender(): void;\n /** Forgets a removed layer */\n detach(layer: Layer): void;\n /** Moves a layer under `before`, or on top */\n moveLayer(layer: Layer, before: Layer | undefined): void;\n /** A layer created again in the engine (new id): put at the place of its old id, which is removed */\n replaceLayer(layer: Layer, old: number): void;\n /** Resolves once the map is idle (everything in view loaded and drawn) */\n whenIdle(): Promise<void>;\n /** Work the map waits on before it is idle (`GeoMap.track`) */\n track<T>(work: Promise<T>): Promise<T>;\n /** What its quality draws (`GeoMap.setQuality`) */\n readonly quality: QualitySettings;\n}\n"]}
|
package/dist/ui/style.js
CHANGED
|
@@ -15,7 +15,7 @@ const CSS = `
|
|
|
15
15
|
--isard-popup-bg: #fff;
|
|
16
16
|
--isard-popup-fg: #1d2433;
|
|
17
17
|
--isard-marker-color: #3a6fd8;
|
|
18
|
-
--isard-
|
|
18
|
+
--isard-clipvolume-color: #e8590c;
|
|
19
19
|
--isard-attrib-bg: rgb(255 255 255 / 0.5);
|
|
20
20
|
--isard-attrib-fg: rgb(0 0 0 / 0.75);
|
|
21
21
|
--isard-focus: #3a6fd8;
|
|
@@ -66,11 +66,11 @@ const CSS = `
|
|
|
66
66
|
.isard-ctrl-search li { padding: 5px 10px; cursor: pointer; }
|
|
67
67
|
.isard-ctrl-search li:hover, .isard-ctrl-search li[aria-selected="true"] { background: var(--isard-ctrl-hover); }
|
|
68
68
|
.isard-ctrl-minimap { overflow: hidden; cursor: pointer; border-radius: 4px; box-shadow: var(--isard-ctrl-shadow); background: var(--isard-ctrl-bg); }
|
|
69
|
-
.isard-
|
|
70
|
-
.isard-
|
|
71
|
-
.isard-
|
|
72
|
-
.isard-
|
|
73
|
-
.isard-
|
|
69
|
+
.isard-clipvolume { position: absolute; inset: 0; pointer-events: none; }
|
|
70
|
+
.isard-clipvolume svg { display: block; width: 100%; height: 100%; overflow: visible; }
|
|
71
|
+
.isard-clipvolume line { stroke: var(--isard-clipvolume-color); stroke-width: 1.5; stroke-dasharray: 5 3; }
|
|
72
|
+
.isard-clipvolume circle { fill: #fff; stroke: var(--isard-clipvolume-color); stroke-width: 2; pointer-events: auto; cursor: grab; touch-action: none; }
|
|
73
|
+
.isard-clipvolume circle.isard-clipvolume-move { fill: var(--isard-clipvolume-color); stroke: #fff; cursor: move; }
|
|
74
74
|
.isard-marker { position: absolute; top: 0; left: 0; pointer-events: auto; will-change: transform; }
|
|
75
75
|
.isard-marker-draggable { cursor: grab; touch-action: none; }
|
|
76
76
|
.isard-marker-dragging { cursor: grabbing; }
|
package/dist/ui/style.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/ui/style.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0IX,CAAC;AAEF,MAAM,MAAM,GAAG,IAAI,OAAO,EAAY,CAAC;AAEvC,mHAAmH;AACnH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAa,EAAQ,EAAE;IACjD,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO;IAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEhB,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAEzC,KAAK,CAAC,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC;IACzB,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC;IACxB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC,CAAC","sourcesContent":["/**\n * Styles of the DOM overlays (markers, popups, controls), injected once per document so the package needs no CSS\n * file. Colors are custom properties, defaults on the root with no specificity: an application restyles them on any\n * element around the map (its container's class may be replaced by a framework: nothing depends on it).\n */\n\nconst CSS = `\n:where(:root) {\n --isard-ctrl-bg: #fff;\n --isard-ctrl-fg: #333;\n --isard-ctrl-hover: rgb(0 0 0 / 0.05);\n --isard-ctrl-active: #1d2433;\n --isard-ctrl-active-fg: #fff;\n --isard-ctrl-border: #ddd;\n --isard-ctrl-shadow: 0 0 0 2px rgb(0 0 0 / 0.1);\n --isard-popup-bg: #fff;\n --isard-popup-fg: #1d2433;\n --isard-marker-color: #3a6fd8;\n --isard-clipbox-color: #e8590c;\n --isard-attrib-bg: rgb(255 255 255 / 0.5);\n --isard-attrib-fg: rgb(0 0 0 / 0.75);\n --isard-focus: #3a6fd8;\n}\n.isard-canvas:focus { outline: none; }\n.isard-canvas:focus-visible { outline: 2px solid var(--isard-focus); outline-offset: -2px; }\n.isard-overlay { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }\n.isard-ctrl-top-left, .isard-ctrl-top-right, .isard-ctrl-bottom-left, .isard-ctrl-bottom-right {\n position: absolute; pointer-events: none; z-index: 2;\n}\n.isard-ctrl-top-left { top: 0; left: 0; }\n.isard-ctrl-top-right { top: 0; right: 0; }\n.isard-ctrl-bottom-left { bottom: 0; left: 0; }\n.isard-ctrl-bottom-right { bottom: 0; right: 0; }\n.isard-ctrl { clear: both; pointer-events: auto; transform: translate(0, 0); }\n.isard-ctrl-top-left .isard-ctrl { float: left; margin: 10px 0 0 10px; }\n.isard-ctrl-top-right .isard-ctrl { float: right; margin: 10px 10px 0 0; }\n.isard-ctrl-bottom-left .isard-ctrl { float: left; margin: 0 0 10px 10px; }\n.isard-ctrl-bottom-right .isard-ctrl { float: right; margin: 0 10px 10px 0; }\n.isard-ctrl-group { background: var(--isard-ctrl-bg); border-radius: 4px; box-shadow: var(--isard-ctrl-shadow); }\n.isard-ctrl-group button {\n display: block; width: 29px; height: 29px; padding: 0; margin: 0; border: 0; box-sizing: border-box;\n background: transparent; color: var(--isard-ctrl-fg); cursor: pointer; font: inherit;\n}\n.isard-ctrl-group button + button { border-top: 1px solid var(--isard-ctrl-border); }\n.isard-ctrl-group button:first-child { border-radius: 4px 4px 0 0; }\n.isard-ctrl-group button:last-child { border-radius: 0 0 4px 4px; }\n.isard-ctrl-group button:only-child { border-radius: inherit; }\n.isard-ctrl-group button:hover { background-color: var(--isard-ctrl-hover); }\n.isard-ctrl-group button:focus-visible { outline: 2px solid var(--isard-ctrl-active); outline-offset: -2px; }\n.isard-ctrl-group button.active { background: var(--isard-ctrl-active); color: var(--isard-ctrl-active-fg); }\n.isard-ctrl-group button svg { display: block; margin: auto; pointer-events: none; }\n.isard-ctrl-compass svg { transition: transform 0.05s; }\n.isard-ctrl-scale {\n box-sizing: border-box; padding: 0 5px; border: 2px solid var(--isard-ctrl-fg); border-top: 0;\n background: var(--isard-attrib-bg); color: var(--isard-ctrl-fg); font: 11px/1.4 system-ui, sans-serif; white-space: nowrap;\n}\n.isard-ctrl-search { position: relative; width: 260px; }\n.isard-ctrl-search input {\n box-sizing: border-box; width: 100%; padding: 6px 10px; border: 0; border-radius: 4px; outline: none;\n background: var(--isard-ctrl-bg); color: var(--isard-ctrl-fg); box-shadow: var(--isard-ctrl-shadow); font: 13px system-ui, sans-serif;\n}\n.isard-ctrl-search input:focus-visible { box-shadow: 0 0 0 2px var(--isard-focus); }\n.isard-ctrl-search ul {\n position: absolute; left: 0; right: 0; margin: 4px 0 0; padding: 4px 0; list-style: none; border-radius: 4px;\n background: var(--isard-ctrl-bg); color: var(--isard-ctrl-fg); box-shadow: var(--isard-ctrl-shadow); font: 13px system-ui, sans-serif;\n}\n.isard-ctrl-search li { padding: 5px 10px; cursor: pointer; }\n.isard-ctrl-search li:hover, .isard-ctrl-search li[aria-selected=\"true\"] { background: var(--isard-ctrl-hover); }\n.isard-ctrl-minimap { overflow: hidden; cursor: pointer; border-radius: 4px; box-shadow: var(--isard-ctrl-shadow); background: var(--isard-ctrl-bg); }\n.isard-clipbox { position: absolute; inset: 0; pointer-events: none; }\n.isard-clipbox svg { display: block; width: 100%; height: 100%; overflow: visible; }\n.isard-clipbox line { stroke: var(--isard-clipbox-color); stroke-width: 1.5; stroke-dasharray: 5 3; }\n.isard-clipbox circle { fill: #fff; stroke: var(--isard-clipbox-color); stroke-width: 2; pointer-events: auto; cursor: grab; touch-action: none; }\n.isard-clipbox circle.isard-clipbox-move { fill: var(--isard-clipbox-color); stroke: #fff; cursor: move; }\n.isard-marker { position: absolute; top: 0; left: 0; pointer-events: auto; will-change: transform; }\n.isard-marker-draggable { cursor: grab; touch-action: none; }\n.isard-marker-dragging { cursor: grabbing; }\n.isard-marker-stem { position: absolute; z-index: -1; width: 2px; margin-left: -1px; transform-origin: top center; background: var(--isard-marker-color); opacity: 0.8; pointer-events: none; }\n.isard-marker-stem::after { content: \"\"; position: absolute; bottom: -3px; left: -2px; width: 6px; height: 6px; border-radius: 50%; background: inherit; }\n.isard-marker-pin { display: block; color: var(--isard-marker-color); filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.35)); }\n.isard-panel { position: absolute; top: 0; left: 0; transform-origin: 0 0; pointer-events: auto; will-change: transform; }\n.isard-popup {\n position: absolute; top: 0; left: 0; display: flex; pointer-events: none; will-change: transform; z-index: 1;\n color: var(--isard-popup-fg);\n}\n.isard-popup-anchor-top, .isard-popup-anchor-top-left, .isard-popup-anchor-top-right { flex-direction: column; }\n.isard-popup-anchor-bottom, .isard-popup-anchor-bottom-left, .isard-popup-anchor-bottom-right {\n flex-direction: column-reverse;\n}\n.isard-popup-anchor-left { flex-direction: row; }\n.isard-popup-anchor-right { flex-direction: row-reverse; }\n.isard-popup-tip { width: 0; height: 0; border: 10px solid transparent; z-index: 1; }\n.isard-popup-anchor-top .isard-popup-tip { align-self: center; border-top: none; border-bottom-color: var(--isard-popup-bg); }\n.isard-popup-anchor-top-left .isard-popup-tip {\n align-self: flex-start; border-top: none; border-left: none; border-bottom-color: var(--isard-popup-bg);\n}\n.isard-popup-anchor-top-right .isard-popup-tip {\n align-self: flex-end; border-top: none; border-right: none; border-bottom-color: var(--isard-popup-bg);\n}\n.isard-popup-anchor-bottom .isard-popup-tip { align-self: center; border-bottom: none; border-top-color: var(--isard-popup-bg); }\n.isard-popup-anchor-bottom-left .isard-popup-tip {\n align-self: flex-start; border-bottom: none; border-left: none; border-top-color: var(--isard-popup-bg);\n}\n.isard-popup-anchor-bottom-right .isard-popup-tip {\n align-self: flex-end; border-bottom: none; border-right: none; border-top-color: var(--isard-popup-bg);\n}\n.isard-popup-anchor-left .isard-popup-tip { align-self: center; border-left: none; border-right-color: var(--isard-popup-bg); }\n.isard-popup-anchor-right .isard-popup-tip { align-self: center; border-right: none; border-left-color: var(--isard-popup-bg); }\n.isard-popup-content {\n position: relative; padding: 12px 14px; border-radius: 4px; background: var(--isard-popup-bg);\n box-shadow: 0 1px 4px rgb(0 0 0 / 0.2); pointer-events: auto; overflow-wrap: break-word;\n}\n.isard-popup-has-close .isard-popup-content { padding-right: 26px; }\n.isard-popup-anchor-top-left .isard-popup-content { border-top-left-radius: 0; }\n.isard-popup-anchor-top-right .isard-popup-content { border-top-right-radius: 0; }\n.isard-popup-anchor-bottom-left .isard-popup-content { border-bottom-left-radius: 0; }\n.isard-popup-anchor-bottom-right .isard-popup-content { border-bottom-right-radius: 0; }\n.isard-popup-close {\n position: absolute; top: 0; right: 0; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 0 4px 0 4px;\n background: transparent; color: inherit; font: 18px/22px system-ui, sans-serif; cursor: pointer;\n}\n.isard-popup-close:hover { background: rgb(0 0 0 / 0.05); }\n.isard-popup-close:focus-visible, .isard-attrib-button:focus-visible, .isard-attrib a:focus-visible {\n outline: 2px solid var(--isard-focus); outline-offset: -2px;\n}\n.isard-attrib {\n display: flex; align-items: center; gap: 4px; padding: 0 5px; border-radius: 4px; background: var(--isard-attrib-bg);\n color: var(--isard-attrib-fg); font: 12px/20px system-ui, sans-serif;\n}\n.isard-ctrl-bottom-right .isard-ctrl.isard-attrib, .isard-ctrl-bottom-left .isard-ctrl.isard-attrib { margin-bottom: 0; }\n.isard-ctrl-bottom-right .isard-ctrl.isard-attrib { margin-right: 0; border-radius: 4px 0 0 0; }\n.isard-ctrl-bottom-left .isard-ctrl.isard-attrib { margin-left: 0; border-radius: 0 4px 0 0; }\n.isard-attrib a { color: inherit; text-decoration: none; }\n.isard-attrib a:hover { text-decoration: underline; }\n.isard-attrib-button {\n display: none; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 12px; flex: none;\n background: var(--isard-ctrl-bg); color: var(--isard-ctrl-fg); cursor: pointer;\n}\n.isard-attrib-button svg { display: block; margin: auto; }\n.isard-ctrl.isard-attrib.isard-attrib-compact { min-height: 24px; padding: 2px; border-radius: 12px; margin: 0 10px 10px; }\n.isard-attrib-compact .isard-attrib-button { display: block; }\n.isard-attrib-compact .isard-attrib-inner { display: none; padding: 0 6px 0 2px; }\n.isard-attrib-compact.isard-attrib-open { background: var(--isard-ctrl-bg); }\n.isard-attrib-compact.isard-attrib-open .isard-attrib-inner { display: block; }\n`;\n\nconst styled = new WeakSet<Document>();\n\n/** Adds the overlay styles to a document, once; first in the head so application rules win at equal specificity */\nexport const injectStyle = (doc: Document): void => {\n if (styled.has(doc)) return;\n styled.add(doc);\n\n const style = doc.createElement('style');\n\n style.dataset.isard = '';\n style.textContent = CSS;\n doc.head.prepend(style);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/ui/style.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,GAAG,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0IX,CAAC;AAEF,MAAM,MAAM,GAAG,IAAI,OAAO,EAAY,CAAC;AAEvC,mHAAmH;AACnH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAa,EAAQ,EAAE;IACjD,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE,OAAO;IAC5B,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAEhB,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAEzC,KAAK,CAAC,OAAO,CAAC,KAAK,GAAG,EAAE,CAAC;IACzB,KAAK,CAAC,WAAW,GAAG,GAAG,CAAC;IACxB,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC1B,CAAC,CAAC","sourcesContent":["/**\n * Styles of the DOM overlays (markers, popups, controls), injected once per document so the package needs no CSS\n * file. Colors are custom properties, defaults on the root with no specificity: an application restyles them on any\n * element around the map (its container's class may be replaced by a framework: nothing depends on it).\n */\n\nconst CSS = `\n:where(:root) {\n --isard-ctrl-bg: #fff;\n --isard-ctrl-fg: #333;\n --isard-ctrl-hover: rgb(0 0 0 / 0.05);\n --isard-ctrl-active: #1d2433;\n --isard-ctrl-active-fg: #fff;\n --isard-ctrl-border: #ddd;\n --isard-ctrl-shadow: 0 0 0 2px rgb(0 0 0 / 0.1);\n --isard-popup-bg: #fff;\n --isard-popup-fg: #1d2433;\n --isard-marker-color: #3a6fd8;\n --isard-clipvolume-color: #e8590c;\n --isard-attrib-bg: rgb(255 255 255 / 0.5);\n --isard-attrib-fg: rgb(0 0 0 / 0.75);\n --isard-focus: #3a6fd8;\n}\n.isard-canvas:focus { outline: none; }\n.isard-canvas:focus-visible { outline: 2px solid var(--isard-focus); outline-offset: -2px; }\n.isard-overlay { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }\n.isard-ctrl-top-left, .isard-ctrl-top-right, .isard-ctrl-bottom-left, .isard-ctrl-bottom-right {\n position: absolute; pointer-events: none; z-index: 2;\n}\n.isard-ctrl-top-left { top: 0; left: 0; }\n.isard-ctrl-top-right { top: 0; right: 0; }\n.isard-ctrl-bottom-left { bottom: 0; left: 0; }\n.isard-ctrl-bottom-right { bottom: 0; right: 0; }\n.isard-ctrl { clear: both; pointer-events: auto; transform: translate(0, 0); }\n.isard-ctrl-top-left .isard-ctrl { float: left; margin: 10px 0 0 10px; }\n.isard-ctrl-top-right .isard-ctrl { float: right; margin: 10px 10px 0 0; }\n.isard-ctrl-bottom-left .isard-ctrl { float: left; margin: 0 0 10px 10px; }\n.isard-ctrl-bottom-right .isard-ctrl { float: right; margin: 0 10px 10px 0; }\n.isard-ctrl-group { background: var(--isard-ctrl-bg); border-radius: 4px; box-shadow: var(--isard-ctrl-shadow); }\n.isard-ctrl-group button {\n display: block; width: 29px; height: 29px; padding: 0; margin: 0; border: 0; box-sizing: border-box;\n background: transparent; color: var(--isard-ctrl-fg); cursor: pointer; font: inherit;\n}\n.isard-ctrl-group button + button { border-top: 1px solid var(--isard-ctrl-border); }\n.isard-ctrl-group button:first-child { border-radius: 4px 4px 0 0; }\n.isard-ctrl-group button:last-child { border-radius: 0 0 4px 4px; }\n.isard-ctrl-group button:only-child { border-radius: inherit; }\n.isard-ctrl-group button:hover { background-color: var(--isard-ctrl-hover); }\n.isard-ctrl-group button:focus-visible { outline: 2px solid var(--isard-ctrl-active); outline-offset: -2px; }\n.isard-ctrl-group button.active { background: var(--isard-ctrl-active); color: var(--isard-ctrl-active-fg); }\n.isard-ctrl-group button svg { display: block; margin: auto; pointer-events: none; }\n.isard-ctrl-compass svg { transition: transform 0.05s; }\n.isard-ctrl-scale {\n box-sizing: border-box; padding: 0 5px; border: 2px solid var(--isard-ctrl-fg); border-top: 0;\n background: var(--isard-attrib-bg); color: var(--isard-ctrl-fg); font: 11px/1.4 system-ui, sans-serif; white-space: nowrap;\n}\n.isard-ctrl-search { position: relative; width: 260px; }\n.isard-ctrl-search input {\n box-sizing: border-box; width: 100%; padding: 6px 10px; border: 0; border-radius: 4px; outline: none;\n background: var(--isard-ctrl-bg); color: var(--isard-ctrl-fg); box-shadow: var(--isard-ctrl-shadow); font: 13px system-ui, sans-serif;\n}\n.isard-ctrl-search input:focus-visible { box-shadow: 0 0 0 2px var(--isard-focus); }\n.isard-ctrl-search ul {\n position: absolute; left: 0; right: 0; margin: 4px 0 0; padding: 4px 0; list-style: none; border-radius: 4px;\n background: var(--isard-ctrl-bg); color: var(--isard-ctrl-fg); box-shadow: var(--isard-ctrl-shadow); font: 13px system-ui, sans-serif;\n}\n.isard-ctrl-search li { padding: 5px 10px; cursor: pointer; }\n.isard-ctrl-search li:hover, .isard-ctrl-search li[aria-selected=\"true\"] { background: var(--isard-ctrl-hover); }\n.isard-ctrl-minimap { overflow: hidden; cursor: pointer; border-radius: 4px; box-shadow: var(--isard-ctrl-shadow); background: var(--isard-ctrl-bg); }\n.isard-clipvolume { position: absolute; inset: 0; pointer-events: none; }\n.isard-clipvolume svg { display: block; width: 100%; height: 100%; overflow: visible; }\n.isard-clipvolume line { stroke: var(--isard-clipvolume-color); stroke-width: 1.5; stroke-dasharray: 5 3; }\n.isard-clipvolume circle { fill: #fff; stroke: var(--isard-clipvolume-color); stroke-width: 2; pointer-events: auto; cursor: grab; touch-action: none; }\n.isard-clipvolume circle.isard-clipvolume-move { fill: var(--isard-clipvolume-color); stroke: #fff; cursor: move; }\n.isard-marker { position: absolute; top: 0; left: 0; pointer-events: auto; will-change: transform; }\n.isard-marker-draggable { cursor: grab; touch-action: none; }\n.isard-marker-dragging { cursor: grabbing; }\n.isard-marker-stem { position: absolute; z-index: -1; width: 2px; margin-left: -1px; transform-origin: top center; background: var(--isard-marker-color); opacity: 0.8; pointer-events: none; }\n.isard-marker-stem::after { content: \"\"; position: absolute; bottom: -3px; left: -2px; width: 6px; height: 6px; border-radius: 50%; background: inherit; }\n.isard-marker-pin { display: block; color: var(--isard-marker-color); filter: drop-shadow(0 1px 2px rgb(0 0 0 / 0.35)); }\n.isard-panel { position: absolute; top: 0; left: 0; transform-origin: 0 0; pointer-events: auto; will-change: transform; }\n.isard-popup {\n position: absolute; top: 0; left: 0; display: flex; pointer-events: none; will-change: transform; z-index: 1;\n color: var(--isard-popup-fg);\n}\n.isard-popup-anchor-top, .isard-popup-anchor-top-left, .isard-popup-anchor-top-right { flex-direction: column; }\n.isard-popup-anchor-bottom, .isard-popup-anchor-bottom-left, .isard-popup-anchor-bottom-right {\n flex-direction: column-reverse;\n}\n.isard-popup-anchor-left { flex-direction: row; }\n.isard-popup-anchor-right { flex-direction: row-reverse; }\n.isard-popup-tip { width: 0; height: 0; border: 10px solid transparent; z-index: 1; }\n.isard-popup-anchor-top .isard-popup-tip { align-self: center; border-top: none; border-bottom-color: var(--isard-popup-bg); }\n.isard-popup-anchor-top-left .isard-popup-tip {\n align-self: flex-start; border-top: none; border-left: none; border-bottom-color: var(--isard-popup-bg);\n}\n.isard-popup-anchor-top-right .isard-popup-tip {\n align-self: flex-end; border-top: none; border-right: none; border-bottom-color: var(--isard-popup-bg);\n}\n.isard-popup-anchor-bottom .isard-popup-tip { align-self: center; border-bottom: none; border-top-color: var(--isard-popup-bg); }\n.isard-popup-anchor-bottom-left .isard-popup-tip {\n align-self: flex-start; border-bottom: none; border-left: none; border-top-color: var(--isard-popup-bg);\n}\n.isard-popup-anchor-bottom-right .isard-popup-tip {\n align-self: flex-end; border-bottom: none; border-right: none; border-top-color: var(--isard-popup-bg);\n}\n.isard-popup-anchor-left .isard-popup-tip { align-self: center; border-left: none; border-right-color: var(--isard-popup-bg); }\n.isard-popup-anchor-right .isard-popup-tip { align-self: center; border-right: none; border-left-color: var(--isard-popup-bg); }\n.isard-popup-content {\n position: relative; padding: 12px 14px; border-radius: 4px; background: var(--isard-popup-bg);\n box-shadow: 0 1px 4px rgb(0 0 0 / 0.2); pointer-events: auto; overflow-wrap: break-word;\n}\n.isard-popup-has-close .isard-popup-content { padding-right: 26px; }\n.isard-popup-anchor-top-left .isard-popup-content { border-top-left-radius: 0; }\n.isard-popup-anchor-top-right .isard-popup-content { border-top-right-radius: 0; }\n.isard-popup-anchor-bottom-left .isard-popup-content { border-bottom-left-radius: 0; }\n.isard-popup-anchor-bottom-right .isard-popup-content { border-bottom-right-radius: 0; }\n.isard-popup-close {\n position: absolute; top: 0; right: 0; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 0 4px 0 4px;\n background: transparent; color: inherit; font: 18px/22px system-ui, sans-serif; cursor: pointer;\n}\n.isard-popup-close:hover { background: rgb(0 0 0 / 0.05); }\n.isard-popup-close:focus-visible, .isard-attrib-button:focus-visible, .isard-attrib a:focus-visible {\n outline: 2px solid var(--isard-focus); outline-offset: -2px;\n}\n.isard-attrib {\n display: flex; align-items: center; gap: 4px; padding: 0 5px; border-radius: 4px; background: var(--isard-attrib-bg);\n color: var(--isard-attrib-fg); font: 12px/20px system-ui, sans-serif;\n}\n.isard-ctrl-bottom-right .isard-ctrl.isard-attrib, .isard-ctrl-bottom-left .isard-ctrl.isard-attrib { margin-bottom: 0; }\n.isard-ctrl-bottom-right .isard-ctrl.isard-attrib { margin-right: 0; border-radius: 4px 0 0 0; }\n.isard-ctrl-bottom-left .isard-ctrl.isard-attrib { margin-left: 0; border-radius: 0 4px 0 0; }\n.isard-attrib a { color: inherit; text-decoration: none; }\n.isard-attrib a:hover { text-decoration: underline; }\n.isard-attrib-button {\n display: none; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 12px; flex: none;\n background: var(--isard-ctrl-bg); color: var(--isard-ctrl-fg); cursor: pointer;\n}\n.isard-attrib-button svg { display: block; margin: auto; }\n.isard-ctrl.isard-attrib.isard-attrib-compact { min-height: 24px; padding: 2px; border-radius: 12px; margin: 0 10px 10px; }\n.isard-attrib-compact .isard-attrib-button { display: block; }\n.isard-attrib-compact .isard-attrib-inner { display: none; padding: 0 6px 0 2px; }\n.isard-attrib-compact.isard-attrib-open { background: var(--isard-ctrl-bg); }\n.isard-attrib-compact.isard-attrib-open .isard-attrib-inner { display: block; }\n`;\n\nconst styled = new WeakSet<Document>();\n\n/** Adds the overlay styles to a document, once; first in the head so application rules win at equal specificity */\nexport const injectStyle = (doc: Document): void => {\n if (styled.has(doc)) return;\n styled.add(doc);\n\n const style = doc.createElement('style');\n\n style.dataset.isard = '';\n style.textContent = CSS;\n doc.head.prepend(style);\n};\n"]}
|
|
@@ -290,9 +290,9 @@ export class Engine {
|
|
|
290
290
|
*/
|
|
291
291
|
camera(): Camera;
|
|
292
292
|
/**
|
|
293
|
-
* Removes the clipping
|
|
293
|
+
* Removes the clipping volume: the layers whole again
|
|
294
294
|
*/
|
|
295
|
-
|
|
295
|
+
clearClipVolume(): void;
|
|
296
296
|
/**
|
|
297
297
|
* Removes the panorama
|
|
298
298
|
*/
|
|
@@ -469,12 +469,14 @@ export class Engine {
|
|
|
469
469
|
*/
|
|
470
470
|
setCircles(id: number, points: Float64Array, feature: Uint32Array): void;
|
|
471
471
|
/**
|
|
472
|
-
* Cuts the 3D layers by a
|
|
473
|
-
* width, length and height (metres), its heading (degrees clockwise from north of
|
|
474
|
-
* inside it (else what is outside), 1 for an altitude above the relief (else
|
|
475
|
-
*
|
|
472
|
+
* Cuts the 3D layers by a volume: `values` its foot's longitude, latitude (degrees) and altitude (metres), its
|
|
473
|
+
* width, length and height (metres; a cylinder's width its diameter), its heading (degrees clockwise from north of
|
|
474
|
+
* a box's length), 1 to cut what is inside it (else what is outside), 1 for an altitude above the relief (else
|
|
475
|
+
* above the ellipsoid), its shape (0 a box, 1 a cylinder, 2 a prism on a polygon); `polygon` the polygon's
|
|
476
|
+
* vertices east and north of its foot's center (metres, 16 at most); `section` the color of the faces the cut
|
|
477
|
+
* opens (RGB 0-1), empty to leave them open
|
|
476
478
|
*/
|
|
477
|
-
|
|
479
|
+
setClipVolume(values: Float64Array, polygon: Float64Array, section: Float32Array): void;
|
|
478
480
|
/**
|
|
479
481
|
* A raster layer draped on the roofs, or all the faces, of a 3D Tiles layer, an extrusion layer, a vector tiles
|
|
480
482
|
* layer's buildings or a model layer (`raster` undefined: none)
|
|
@@ -945,7 +947,7 @@ export interface InitOutput {
|
|
|
945
947
|
readonly engine_backend: (a: number) => [number, number];
|
|
946
948
|
readonly engine_bounds: (a: number) => [number, number];
|
|
947
949
|
readonly engine_camera: (a: number) => any;
|
|
948
|
-
readonly
|
|
950
|
+
readonly engine_clearClipVolume: (a: number) => void;
|
|
949
951
|
readonly engine_clearPanorama: (a: number) => void;
|
|
950
952
|
readonly engine_clearPivot: (a: number) => void;
|
|
951
953
|
readonly engine_clearPreload: (a: number) => void;
|
|
@@ -983,7 +985,7 @@ export interface InitOutput {
|
|
|
983
985
|
readonly engine_setCamera: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
984
986
|
readonly engine_setCircleAlignment: (a: number, b: number, c: number) => void;
|
|
985
987
|
readonly engine_setCircles: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
986
|
-
readonly
|
|
988
|
+
readonly engine_setClipVolume: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
987
989
|
readonly engine_setDrape: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
988
990
|
readonly engine_setExtrusionAnchors: (a: number, b: number, c: number, d: number, e: number) => [number, number];
|
|
989
991
|
readonly engine_setExtrusionBatch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number, n: number, o: number, p: number, q: number) => [number, number];
|
|
@@ -357,10 +357,10 @@ export class Engine {
|
|
|
357
357
|
return ret;
|
|
358
358
|
}
|
|
359
359
|
/**
|
|
360
|
-
* Removes the clipping
|
|
360
|
+
* Removes the clipping volume: the layers whole again
|
|
361
361
|
*/
|
|
362
|
-
|
|
363
|
-
wasm.
|
|
362
|
+
clearClipVolume() {
|
|
363
|
+
wasm.engine_clearClipVolume(this.__wbg_ptr);
|
|
364
364
|
}
|
|
365
365
|
/**
|
|
366
366
|
* Removes the panorama
|
|
@@ -737,19 +737,24 @@ export class Engine {
|
|
|
737
737
|
wasm.engine_setCircles(this.__wbg_ptr, id, ptr0, len0, ptr1, len1);
|
|
738
738
|
}
|
|
739
739
|
/**
|
|
740
|
-
* Cuts the 3D layers by a
|
|
741
|
-
* width, length and height (metres), its heading (degrees clockwise from north of
|
|
742
|
-
* inside it (else what is outside), 1 for an altitude above the relief (else
|
|
743
|
-
*
|
|
740
|
+
* Cuts the 3D layers by a volume: `values` its foot's longitude, latitude (degrees) and altitude (metres), its
|
|
741
|
+
* width, length and height (metres; a cylinder's width its diameter), its heading (degrees clockwise from north of
|
|
742
|
+
* a box's length), 1 to cut what is inside it (else what is outside), 1 for an altitude above the relief (else
|
|
743
|
+
* above the ellipsoid), its shape (0 a box, 1 a cylinder, 2 a prism on a polygon); `polygon` the polygon's
|
|
744
|
+
* vertices east and north of its foot's center (metres, 16 at most); `section` the color of the faces the cut
|
|
745
|
+
* opens (RGB 0-1), empty to leave them open
|
|
744
746
|
* @param {Float64Array} values
|
|
747
|
+
* @param {Float64Array} polygon
|
|
745
748
|
* @param {Float32Array} section
|
|
746
749
|
*/
|
|
747
|
-
|
|
750
|
+
setClipVolume(values, polygon, section) {
|
|
748
751
|
const ptr0 = passArrayF64ToWasm0(values, wasm.__wbindgen_malloc);
|
|
749
752
|
const len0 = WASM_VECTOR_LEN;
|
|
750
|
-
const ptr1 =
|
|
753
|
+
const ptr1 = passArrayF64ToWasm0(polygon, wasm.__wbindgen_malloc);
|
|
751
754
|
const len1 = WASM_VECTOR_LEN;
|
|
752
|
-
|
|
755
|
+
const ptr2 = passArrayF32ToWasm0(section, wasm.__wbindgen_malloc);
|
|
756
|
+
const len2 = WASM_VECTOR_LEN;
|
|
757
|
+
wasm.engine_setClipVolume(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
|
|
753
758
|
}
|
|
754
759
|
/**
|
|
755
760
|
* A raster layer draped on the roofs, or all the faces, of a 3D Tiles layer, an extrusion layer, a vector tiles
|