isard 1.1.0 → 1.2.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 +33 -0
- package/dist/basemap/basemaps.d.ts +1 -1
- package/dist/basemap/basemaps.js +2 -2
- package/dist/basemap/basemaps.js.map +1 -1
- package/dist/basemap/grid.d.ts +5 -5
- package/dist/basemap/grid.js +59 -65
- package/dist/basemap/grid.js.map +1 -1
- package/dist/basemap/mvt.d.ts +1 -1
- package/dist/basemap/mvt.js +6 -6
- package/dist/basemap/mvt.js.map +1 -1
- package/dist/basemap/pmtiles.d.ts +10 -10
- package/dist/basemap/pmtiles.js +39 -31
- package/dist/basemap/pmtiles.js.map +1 -1
- package/dist/basemap/resample.d.ts +2 -2
- package/dist/basemap/resample.js +16 -14
- package/dist/basemap/resample.js.map +1 -1
- package/dist/basemap/terrain.d.ts +3 -3
- package/dist/basemap/terrain.js +6 -6
- package/dist/basemap/terrain.js.map +1 -1
- package/dist/basemap/vectorstyle.d.ts +12 -10
- package/dist/basemap/vectorstyle.js +128 -110
- package/dist/basemap/vectorstyle.js.map +1 -1
- package/dist/basemap/vectortiles.d.ts +11 -11
- package/dist/basemap/vectortiles.js +141 -103
- package/dist/basemap/vectortiles.js.map +1 -1
- package/dist/basemap/wmts.d.ts +3 -3
- package/dist/basemap/wmts.js +16 -11
- package/dist/basemap/wmts.js.map +1 -1
- package/dist/basemap.worker.js +2 -2
- package/dist/basemap.worker.js.map +14 -13
- package/dist/bind/layers.d.ts +13 -4
- package/dist/bind/layers.js +64 -40
- package/dist/bind/layers.js.map +1 -1
- package/dist/data/crs.d.ts +10 -10
- package/dist/data/crs.js +38 -34
- package/dist/data/crs.js.map +1 -1
- package/dist/data/gpx.d.ts +1 -1
- package/dist/data/gpx.js +20 -20
- package/dist/data/gpx.js.map +1 -1
- package/dist/data/kml.d.ts +1 -1
- package/dist/data/kml.js +42 -39
- package/dist/data/kml.js.map +1 -1
- package/dist/data/topojson.d.ts +1 -1
- package/dist/data/topojson.js +15 -10
- package/dist/data/topojson.js.map +1 -1
- package/dist/data/xml.d.ts +5 -5
- package/dist/data/xml.js +19 -18
- package/dist/data/xml.js.map +1 -1
- package/dist/decoder.worker.js +4 -4
- package/dist/decoder.worker.js.map +6 -6
- package/dist/engine/decoders.d.ts +2 -2
- package/dist/engine/decoders.js +28 -25
- package/dist/engine/decoders.js.map +1 -1
- package/dist/engine/loader.js +13 -14
- package/dist/engine/loader.js.map +1 -1
- package/dist/engine/requests.d.ts +1 -1
- package/dist/engine/requests.js +19 -16
- package/dist/engine/requests.js.map +1 -1
- package/dist/engine-loader.d.ts +8 -8
- package/dist/engine-loader.js +27 -27
- package/dist/engine-loader.js.map +1 -1
- package/dist/geoplateforme.d.ts +10 -10
- package/dist/geoplateforme.js +22 -20
- package/dist/geoplateforme.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/isard_bg.wasm +0 -0
- package/dist/isard_core_bg.wasm +0 -0
- package/dist/isard_points_bg.wasm +0 -0
- package/dist/layers/extrusions.d.ts +1 -1
- package/dist/layers/extrusions.js +10 -5
- package/dist/layers/extrusions.js.map +1 -1
- package/dist/layers/features.d.ts +10 -10
- package/dist/layers/features.js +41 -42
- package/dist/layers/features.js.map +1 -1
- package/dist/layers/glyphs.d.ts +3 -3
- package/dist/layers/glyphs.js +34 -40
- package/dist/layers/glyphs.js.map +1 -1
- package/dist/layers/icons.d.ts +8 -8
- package/dist/layers/icons.js +76 -68
- package/dist/layers/icons.js.map +1 -1
- package/dist/layers/layers.d.ts +1 -1
- package/dist/layers/layers.js +33 -29
- package/dist/layers/layers.js.map +1 -1
- package/dist/layers/panoramas.d.ts +2 -2
- package/dist/layers/panoramas.js +52 -41
- package/dist/layers/panoramas.js.map +1 -1
- package/dist/layers/pointclouds.d.ts +3 -3
- package/dist/layers/pointclouds.js +25 -33
- package/dist/layers/pointclouds.js.map +1 -1
- package/dist/layers/symbols.d.ts +1 -1
- package/dist/layers/symbols.js +68 -71
- package/dist/layers/symbols.js.map +1 -1
- package/dist/map/basemap-layers.d.ts +26 -0
- package/dist/map/basemap-layers.js +61 -0
- package/dist/map/basemap-layers.js.map +1 -0
- package/dist/map/canvas.d.ts +17 -0
- package/dist/map/canvas.js +56 -0
- package/dist/map/canvas.js.map +1 -0
- package/dist/map/checks.d.ts +11 -0
- package/dist/map/checks.js +39 -0
- package/dist/map/checks.js.map +1 -0
- package/dist/map/credits.d.ts +17 -0
- package/dist/map/credits.js +34 -0
- package/dist/map/credits.js.map +1 -0
- package/dist/map/engine-settings.d.ts +15 -0
- package/dist/map/engine-settings.js +45 -0
- package/dist/map/engine-settings.js.map +1 -0
- package/dist/map/engines.d.ts +41 -0
- package/dist/map/engines.js +77 -0
- package/dist/map/engines.js.map +1 -0
- package/dist/map/events.d.ts +14 -0
- package/dist/map/events.js +46 -0
- package/dist/map/events.js.map +1 -0
- package/dist/map/frame-loop.d.ts +61 -0
- package/dist/map/frame-loop.js +139 -0
- package/dist/map/frame-loop.js.map +1 -0
- package/dist/map/hover-pick.d.ts +30 -0
- package/dist/map/hover-pick.js +56 -0
- package/dist/map/hover-pick.js.map +1 -0
- package/dist/map/layer-spec.d.ts +42 -0
- package/dist/map/layer-spec.js +34 -0
- package/dist/map/layer-spec.js.map +1 -0
- package/dist/map/layer-stack.d.ts +36 -0
- package/dist/map/layer-stack.js +101 -0
- package/dist/map/layer-stack.js.map +1 -0
- package/dist/map/overlay-host.d.ts +36 -0
- package/dist/map/overlay-host.js +101 -0
- package/dist/map/overlay-host.js.map +1 -0
- package/dist/map/panorama-host.d.ts +5 -0
- package/dist/map/panorama-host.js +32 -0
- package/dist/map/panorama-host.js.map +1 -0
- package/dist/map/raster-source.d.ts +11 -0
- package/dist/map/raster-source.js +26 -0
- package/dist/map/raster-source.js.map +1 -0
- package/dist/map/symbol-atlases.d.ts +26 -0
- package/dist/map/symbol-atlases.js +59 -0
- package/dist/map/symbol-atlases.js.map +1 -0
- package/dist/map/viewshed.d.ts +5 -0
- package/dist/map/viewshed.js +28 -0
- package/dist/map/viewshed.js.map +1 -0
- package/dist/map/workers.d.ts +46 -0
- package/dist/map/workers.js +73 -0
- package/dist/map/workers.js.map +1 -0
- package/dist/map.d.ts +33 -120
- package/dist/map.js +164 -689
- package/dist/map.js.map +1 -1
- package/dist/react/Control.d.ts +11 -0
- package/dist/react/Control.js +18 -0
- package/dist/react/Control.js.map +1 -0
- package/dist/react/CustomLayer.d.ts +11 -0
- package/dist/react/CustomLayer.js +30 -0
- package/dist/react/CustomLayer.js.map +1 -0
- package/dist/react/IsardMap.d.ts +43 -0
- package/dist/react/IsardMap.js +146 -0
- package/dist/react/IsardMap.js.map +1 -0
- package/dist/react/Layer.d.ts +42 -0
- package/dist/react/Layer.js +74 -0
- package/dist/react/Layer.js.map +1 -0
- package/dist/react/Marker.d.ts +24 -0
- package/dist/react/Marker.js +53 -0
- package/dist/react/Marker.js.map +1 -0
- package/dist/react/Panel.d.ts +11 -0
- package/dist/react/Panel.js +37 -0
- package/dist/react/Panel.js.map +1 -0
- package/dist/react/Popup.d.ts +18 -0
- package/dist/react/Popup.js +60 -0
- package/dist/react/Popup.js.map +1 -0
- package/dist/react/Swipe.d.ts +9 -0
- package/dist/react/Swipe.js +41 -0
- package/dist/react/Swipe.js.map +1 -0
- package/dist/react/Viewshed.d.ts +5 -0
- package/dist/react/Viewshed.js +28 -0
- package/dist/react/Viewshed.js.map +1 -0
- package/dist/react/context.d.ts +32 -0
- package/dist/react/context.js +20 -0
- package/dist/react/context.js.map +1 -0
- package/dist/react/index.d.ts +15 -108
- package/dist/react/index.js +10 -397
- package/dist/react/index.js.map +1 -1
- package/dist/settings.d.ts +5 -9
- package/dist/settings.js +17 -15
- package/dist/settings.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/dist/types.js.map +1 -1
- package/dist/ui/controls.js +6 -4
- package/dist/ui/controls.js.map +1 -1
- package/dist/ui/interaction.d.ts +2 -2
- package/dist/ui/interaction.js +8 -7
- package/dist/ui/interaction.js.map +1 -1
- package/dist/ui/overlay.js +18 -20
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/style.d.ts +1 -1
- package/dist/ui/style.js +2 -2
- package/dist/ui/style.js.map +1 -1
- package/dist/util/animation.d.ts +3 -3
- package/dist/util/animation.js +6 -6
- package/dist/util/animation.js.map +1 -1
- package/dist/util/color.d.ts +1 -1
- package/dist/util/color.js +14 -16
- package/dist/util/color.js.map +1 -1
- package/dist/util/geo.d.ts +6 -6
- package/dist/util/geo.js +12 -12
- package/dist/util/geo.js.map +1 -1
- package/dist/util/guards.d.ts +7 -0
- package/dist/util/guards.js +8 -0
- package/dist/util/guards.js.map +1 -0
- package/dist/util/lru.js.map +1 -1
- package/dist/wasm/isard.d.ts +168 -0
- package/dist/wasm/isard.js +146 -0
- package/dist/wasm/isard_core.d.ts +144 -0
- package/dist/wasm/isard_core.js +122 -0
- package/dist/workers/basemap.worker.d.ts +3 -3
- package/dist/workers/basemap.worker.js +94 -83
- package/dist/workers/basemap.worker.js.map +1 -1
- package/package.json +1 -1
package/dist/layers/icons.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../src/layers/icons.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAqDpD,6GAA6G;AAC7G,MAAM,UAAU,aAAa,CAAC,MAAoD;IAChF,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACtF,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CA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ACN,CAAC,CAAC;YACH,gCAAgC;YAChC,KAAK,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI;gBACrB,CAAC,IAAI,EAAE,GAAG,CAAC;gBACX,CAAC,KAAK,EAAE,GAAG,CAAC;gBACZ,CAAC,IAAI,EAAE,MAAM,CAAC;gBACd,CAAC,KAAK,EAAE,MAAM,CAAC;aACP,EAAE,CAAC;gBACX,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;gBACxD,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC9B,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC9B,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC9B,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC","sourcesContent":["/**\n * Icons for the symbol layers: the images of a style's sprite (MapLibre's sprite format: a JSON index and a PNG sheet,\n * `@2x` on high-density screens, one sprite or several with their ids) and the application's own (`map.addImage`),\n * packed on first use into an RGBA atlas the engine samples (premultiplied: no dark fringe where it is scaled); and the\n * layout of an icon around its anchor: by its anchor and offset, or stretched around its text (`icon-text-fit`), by\n * the stretchable zones and the content box of its image when it has them (`stretchX`, `stretchY`, `content`).\n */\n\nimport { withHeaders } from '../engine/requests.ts';\nimport type { Anchor } from '../ui/overlay.ts';\nimport type { Engine } from '../wasm/isard.js';\n\n/** An image of a sprite's index: its place in the sheet (pixels) and how it is drawn */\nexport interface SpriteIcon {\n x: number;\n y: number;\n width: number;\n height: number;\n /** Image pixels per CSS pixel (default 1; 2 in an `@2x` sheet) */\n pixelRatio?: number;\n /** A signed distance field in alpha, drawn in the icon color */\n sdf?: boolean;\n /** Columns and rows that stretch when the icon is fitted to its text (image pixels): the others keep their size */\n stretchX?: [number, number][];\n stretchY?: [number, number][];\n /** Where the text goes when the icon is fitted to it: left, top, right, bottom (image pixels) */\n content?: [number, number, number, number];\n}\n\nexport type SpriteIndex = Record<string, SpriteIcon>;\n\n/** RGBA pixels, straight alpha, row after row */\nexport interface Pixels {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n}\n\n/** How an image of the application is drawn (`map.addImage`): `SpriteIcon` without its place */\nexport type ImageOptions = Omit<SpriteIcon, 'x' | 'y' | 'width' | 'height'>;\n\n/** An icon in the atlas: its place (texels) and how it is drawn */\nexport interface Icon {\n x: number;\n y: number;\n width: number;\n height: number;\n pixelRatio: number;\n sdf: boolean;\n stretchX: [number, number][] | undefined;\n stretchY: [number, number][] | undefined;\n content: [number, number, number, number] | undefined;\n}\n\n/** A sprite of a style: its id (`default`: its images keep their names, else `id:name`) and its URL without\n * extension */\nexport interface SpriteSource {\n id: string;\n url: string;\n}\n\n/** The sprites of a style's `sprite`: one URL, or several with their ids (MapLibre's style specification) */\nexport function spriteSources(sprite: string | readonly SpriteSource[] | undefined): SpriteSource[] {\n if (typeof sprite === 'string') return sprite ? [{ id: 'default', url: sprite }] : [];\n return Array.isArray(sprite) ? sprite.filter((s) => typeof s?.url === 'string' && typeof s.id === 'string') : [];\n}\n\n/** The name of an image of a sprite in the style: its own in the `default` sprite, `id:name` in another */\nexport function spriteName(id: string, name: string): string {\n return id === 'default' ? name : `${id}:${name}`;\n}\n\n/** The URL of a sprite's index or sheet: `.json` or `.png`, `@2x` before it for high-density screens, before the\n * query of the URL if it has one */\nexport function spriteFile(url: string, extension: 'json' | 'png', ratio: number): string {\n const suffix = `${ratio > 1 ? '@2x' : ''}.${extension}`;\n const query = url.search(/[?#]/);\n return query < 0 ? `${url}${suffix}` : `${url.slice(0, query)}${suffix}${url.slice(query)}`;\n}\n\n/** A sprite loaded: its images by name (with the sprite's prefix) and its sheet */\nexport interface LoadedSprite {\n icons: SpriteIndex;\n image: ImageBitmap;\n}\n\n/** Loads a style's sprites (`@2x` above a device pixel ratio of 1, the 1x ones if a server has none); the sprites\n * that fail are left out */\nexport async function loadSprites(\n sprite: string | readonly SpriteSource[] | undefined,\n ratio = typeof devicePixelRatio === 'number' ? devicePixelRatio : 1,\n): Promise<LoadedSprite[]> {\n const one = async ({ id, url }: SpriteSource, r: number): Promise<LoadedSprite | undefined> => {\n const [json, png] = await Promise.all([\n fetch(spriteFile(url, 'json', r), withHeaders(spriteFile(url, 'json', r))),\n fetch(spriteFile(url, 'png', r), withHeaders(spriteFile(url, 'png', r))),\n ]);\n if (!json.ok || !png.ok) return r > 1 ? one({ id, url }, 1) : undefined;\n const index = (await json.json()) as SpriteIndex;\n const icons: SpriteIndex = {};\n for (const [name, icon] of Object.entries(index)) icons[spriteName(id, name)] = icon;\n return { icons, image: await createImageBitmap(await png.blob()) };\n };\n const loaded = await Promise.all(spriteSources(sprite).map((s) => one(s, ratio).catch(() => undefined)));\n return loaded.filter((s): s is LoadedSprite => s !== undefined);\n}\n\n/** The pixels of an image (read back through a canvas) */\nexport function readPixels(image: CanvasImageSource & { width: number; height: number }): Pixels | undefined {\n const { width, height } = image;\n if (!(width > 0 && height > 0)) return undefined;\n const canvas =\n typeof OffscreenCanvas === 'function'\n ? new OffscreenCanvas(width, height)\n : Object.assign(document.createElement('canvas'), { width, height });\n const g = canvas.getContext('2d') as CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D | null;\n if (!g) return undefined;\n g.drawImage(image, 0, 0);\n return g.getImageData(0, 0, width, height);\n}\n\n/** Where an icon's pixels are: a region of an image, read when first packed */\ninterface IconSource {\n pixels: () => Pixels | undefined;\n x: number;\n y: number;\n width: number;\n height: number;\n options: ImageOptions;\n}\n\n/** A shelf of the packer: its y, height, and the x of the next free place */\ninterface Shelf {\n y: number;\n height: number;\n x: number;\n}\n\n/** The icons of a map and their atlas: a square that doubles as it fills, up to the texture size limit */\nexport class Icons {\n private size = 256;\n private data = new Uint8Array(256 * 256 * 4);\n private shelves: Shelf[] = [];\n private readonly sources = new Map<string, IconSource>();\n /** Icons packed, null for those that cannot be (no pixels, the atlas full) */\n private readonly packed = new Map<string, Icon | null>();\n private engine: Engine | undefined;\n /** Rows changed since the last upload: first, end */\n private dirty: [number, number] | undefined;\n private full = false;\n private readonly maxSize: number;\n /** Bumped each time icons are added or removed: labels laid out without some of theirs are laid out again */\n version = 0;\n\n /** `maxSize`: the GPU's texture size limit if known (the atlas is at most 4096 × 4096) */\n constructor(maxSize = 4096) {\n this.maxSize = Math.max(256, Math.min(4096, maxSize));\n }\n\n /** Sends the whole atlas to an engine (a new one after a context loss) */\n attach(engine: Engine): void {\n this.engine = engine;\n this.dirty = undefined;\n this.upload();\n }\n\n /** Side of the atlas */\n get atlasSize(): number {\n return this.size;\n }\n\n /** An image of the application under `name` (another image of that name is replaced) */\n add(name: string, pixels: Pixels, options: ImageOptions = {}): void {\n this.define(name, { pixels: () => pixels, x: 0, y: 0, width: pixels.width, height: pixels.height, options });\n }\n\n /** The images of a sprite's index, `prefix` before their names, their pixels read from the sheet on first use */\n addSprite(prefix: string, index: SpriteIndex, sheet: () => Pixels | undefined): void {\n let pixels: Pixels | undefined;\n let read = false;\n const once = () => {\n if (!read) {\n read = true;\n pixels = sheet();\n }\n return pixels;\n };\n for (const [name, icon] of Object.entries(index)) {\n if (!icon || typeof icon !== 'object') continue;\n const { x, y, width, height, ...options } = icon;\n this.define(`${prefix}${name}`, { pixels: once, x, y, width, height, options }, false);\n }\n this.version += 1;\n }\n\n private define(name: string, source: IconSource, bump = true): void {\n this.sources.set(name, source);\n // Packed again on its next use (its old place stays taken)\n this.packed.delete(name);\n if (bump) this.version += 1;\n }\n\n has(name: string): boolean {\n return this.sources.has(name);\n }\n\n /** Forgets an image, or every image whose name starts with `prefix` (a sprite's) */\n remove(name: string, prefix = false): void {\n for (const key of [...this.sources.keys()]) {\n if (prefix ? key.startsWith(name) : key === name) {\n this.sources.delete(key);\n this.packed.delete(key);\n }\n }\n this.version += 1;\n }\n\n /** The icon of this name, packed into the atlas on first use; undefined if there is none (`flush` uploads it) */\n get(name: string): Icon | undefined {\n const hit = this.packed.get(name);\n if (hit !== undefined) return hit ?? undefined;\n const source = this.sources.get(name);\n if (!source) return undefined;\n const icon = this.pack(source);\n this.packed.set(name, icon ?? null);\n return icon;\n }\n\n /** Sends the rows changed since the last upload to the engine */\n flush(): void {\n const dirty = this.dirty;\n this.dirty = undefined;\n if (!dirty || !this.engine) return;\n const [y0, y1] = dirty;\n const row = this.size * 4;\n this.engine.updateIconAtlas(0, y0, this.size, y1 - y0, this.data.subarray(y0 * row, y1 * row));\n }\n\n private upload(): void {\n const engine = this.engine;\n if (!engine) return;\n engine.setIconAtlas(this.size, this.size);\n const used = this.shelves.reduce((m, s) => Math.max(m, s.y + s.height), 0);\n if (used > 0) engine.updateIconAtlas(0, 0, this.size, used, this.data.subarray(0, used * this.size * 4));\n }\n\n /** Copies an icon's pixels into the atlas, premultiplied, with a texel of room around it */\n private pack(source: IconSource): Icon | undefined {\n const pixels = source.pixels();\n const { x, y, width: w, height: h } = source;\n if (!pixels || !(w > 0 && h > 0) || x < 0 || y < 0 || x + w > pixels.width || y + h > pixels.height) {\n return undefined;\n }\n const place = this.place(w + 2, h + 2);\n if (!place) return undefined;\n const [px, py] = [place[0] + 1, place[1] + 1];\n for (let row = 0; row < h; row += 1) {\n for (let col = 0; col < w; col += 1) {\n const from = ((y + row) * pixels.width + x + col) * 4;\n const to = ((py + row) * this.size + px + col) * 4;\n const a = pixels.data[from + 3] ?? 0;\n this.data[to] = ((pixels.data[from] ?? 0) * a + 127) / 255;\n this.data[to + 1] = ((pixels.data[from + 1] ?? 0) * a + 127) / 255;\n this.data[to + 2] = ((pixels.data[from + 2] ?? 0) * a + 127) / 255;\n this.data[to + 3] = a;\n }\n }\n const [d0, d1] = this.dirty ?? [place[1], place[1]];\n this.dirty = [Math.min(d0, place[1]), Math.max(d1, place[1] + h + 2)];\n const { pixelRatio, sdf, stretchX, stretchY, content } = source.options;\n return {\n x: px,\n y: py,\n width: w,\n height: h,\n pixelRatio: pixelRatio && pixelRatio > 0 ? pixelRatio : 1,\n sdf: sdf === true,\n stretchX: Array.isArray(stretchX) ? stretchX : undefined,\n stretchY: Array.isArray(stretchY) ? stretchY : undefined,\n content: Array.isArray(content) && content.length === 4 ? content : undefined,\n };\n }\n\n /** A free place of `w` × `h` texels (shelves, the atlas doubled when full); undefined once it cannot grow */\n private place(w: number, h: number): [number, number] | undefined {\n for (;;) {\n const shelf = this.shelves.find((s) => s.height >= h && s.height <= h + 8 && s.x + w <= this.size);\n if (shelf) {\n shelf.x += w;\n return [shelf.x - w, shelf.y];\n }\n const last = this.shelves.at(-1);\n const y = last ? last.y + last.height : 0;\n if (y + h <= this.size && w <= this.size) {\n this.shelves.push({ y, height: h, x: w });\n return [0, y];\n }\n if (this.size * 2 > this.maxSize) {\n if (!this.full) console.warn(`isard: the icon atlas is full (${this.size} × ${this.size})`);\n this.full = true;\n return undefined;\n }\n this.grow();\n }\n }\n\n /** Doubles the atlas; the icons keep their places (texels) */\n private grow(): void {\n const size = this.size * 2;\n const data = new Uint8Array(size * size * 4);\n for (let row = 0; row < this.size; row += 1) {\n data.set(this.data.subarray(row * this.size * 4, (row + 1) * this.size * 4), row * size * 4);\n }\n this.size = size;\n this.data = data;\n this.dirty = undefined;\n this.upload();\n }\n}\n\n/** How an icon is laid out around its anchor */\nexport interface IconLayoutOptions {\n /** Scale of the image (`icon-size`) */\n size: number;\n anchor: Anchor;\n /** CSS pixels at size 1 */\n offset: [number, number];\n /** Degrees, clockwise */\n rotate: number;\n /** Stretched around the text: its width, its height, both (`icon-text-fit`) */\n fit: 'none' | 'width' | 'height' | 'both';\n /** Room around the text when fitted: top, right, bottom, left (CSS pixels) */\n padding: [number, number, number, number];\n /** The text's box around the anchor (CSS pixels), if it has one */\n text?: [number, number, number, number] | undefined;\n}\n\n/** An icon laid out: its quads (x, y, width, height in CSS pixels from the anchor, atlas u0, v0, u1, v1 in texels, -1\n * or -2 for a distance field, turn in radians) and its box from the anchor */\nexport interface IconLayout {\n quads: number[][];\n box: [number, number, number, number];\n}\n\n/** Pieces of an image along one axis: image start, end, laid out start, end */\ntype Pieces = [number, number, number, number][];\n\n/**\n * An axis of an icon fitted to `lo`…`hi` (CSS pixels): its content (the whole image by default) spans them, its\n * stretchable zones (the whole image by default) taking the room the fixed parts (at `scale` CSS pixels per image\n * pixel) leave\n */\nexport function stretch(\n length: number,\n zones: readonly [number, number][] | undefined,\n content: [number, number] | undefined,\n lo: number,\n hi: number,\n scale: number,\n): Pieces {\n const clamp = (v: number) => Math.max(0, Math.min(length, Number(v) || 0));\n const spans = (zones?.length ? zones : [[0, length] as [number, number]])\n .map(([a, b]): [number, number] => [clamp(Math.min(a, b)), clamp(Math.max(a, b))])\n .filter(([a, b]) => b > a);\n const cuts = [...new Set([0, length, ...spans.flat()])].sort((a, b) => a - b);\n const pieces = cuts.slice(1).map((b, i): [number, number, boolean] => {\n const a = cuts[i] ?? 0;\n return [a, b, spans.some(([s, e]) => s <= a && b <= e)];\n });\n const [c0, c1] = content ? [clamp(content[0]), clamp(content[1])] : [0, length];\n const overlap = (a: number, b: number) => Math.max(0, Math.min(b, c1) - Math.max(a, c0));\n const stretchable = pieces.reduce((n, [a, b, s]) => n + (s ? overlap(a, b) : 0), 0);\n const fixed = c1 - c0 - stretchable;\n // CSS pixels per stretchable image pixel: what the fixed parts of the content leave of the room\n const k = stretchable > 0 ? Math.max(0, (hi - lo - fixed * scale) / stretchable) : scale;\n // Laid out position of an image coordinate\n const at = (x: number) => pieces.reduce((n, [a, b, s]) => n + Math.max(0, Math.min(x, b) - a) * (s ? k : scale), 0);\n const origin = lo - at(c0);\n return pieces.map(([a, b]) => [a, b, origin + at(a), origin + at(b)]);\n}\n\n/** Where an anchor's side lies along an axis of the icon: at its start 0, at its end 1, else the middle */\nfunction align(start: boolean, end: boolean): number {\n if (start) return 0;\n return end ? 1 : 0.5;\n}\n\n/** Lays an icon out around its anchor: placed by its anchor and offset, or fitted to its text */\nexport function layoutIcon(icon: Icon, options: IconLayoutOptions): IconLayout {\n const { size, anchor, offset, rotate, fit, padding, text } = options;\n const { width: w, height: h, pixelRatio } = icon;\n let xs: Pieces;\n let ys: Pieces;\n if (fit !== 'none' && text) {\n const [top, right, bottom, left] = padding;\n const [x0, y0, x1, y1] = [text[0] - left, text[1] - top, text[2] + right, text[3] + bottom];\n // The fixed parts at the image's own size; an axis not fitted at the icon's size, centered on the text\n const own = 1 / pixelRatio;\n const scaled = size / pixelRatio;\n const centered = (length: number, lo: number, hi: number): Pieces => {\n const c = (lo + hi) / 2;\n return [[0, length, c - (length * scaled) / 2, c + (length * scaled) / 2]];\n };\n const content = icon.content;\n xs =\n fit === 'height'\n ? centered(w, x0, x1)\n : stretch(w, icon.stretchX, content && [content[0], content[2]], x0, x1, own);\n ys =\n fit === 'width'\n ? centered(h, y0, y1)\n : stretch(h, icon.stretchY, content && [content[1], content[3]], y0, y1, own);\n } else {\n const [dw, dh] = [(w / pixelRatio) * size, (h / pixelRatio) * size];\n const ax = align(anchor.includes('left'), anchor.includes('right'));\n const ay = align(anchor.startsWith('top'), anchor.startsWith('bottom'));\n const [left, top] = [offset[0] * size - dw * ax, offset[1] * size - dh * ay];\n xs = [[0, w, left, left + dw]];\n ys = [[0, h, top, top + dh]];\n }\n const angle = ((Number(rotate) || 0) * Math.PI) / 180;\n const kind = icon.sdf ? -2 : -1;\n const quads: number[][] = [];\n const [cs, sn] = [Math.cos(angle), Math.sin(angle)];\n const box: [number, number, number, number] = [\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ];\n for (const [v0, v1, top, bottom] of ys) {\n for (const [u0, u1, left, right] of xs) {\n if (right <= left || bottom <= top) continue;\n quads.push([\n left,\n top,\n right - left,\n bottom - top,\n icon.x + u0,\n icon.y + v0,\n icon.x + u1,\n icon.y + v1,\n kind,\n angle,\n ]);\n // The box of the turned corners\n for (const [px, py] of [\n [left, top],\n [right, top],\n [left, bottom],\n [right, bottom],\n ] as const) {\n const [rx, ry] = [px * cs - py * sn, px * sn + py * cs];\n box[0] = Math.min(box[0], rx);\n box[1] = Math.min(box[1], ry);\n box[2] = Math.max(box[2], rx);\n box[3] = Math.max(box[3], ry);\n }\n }\n }\n return { quads, box: quads.length ? box : [0, 0, 0, 0] };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../src/layers/icons.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAsBxD,MAAM,OAAO,GAAG,CAAC,KAAc,EAA+B,EAAE,CAC9D,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;AAEtF,4EAA4E;AAC5E,MAAM,YAAY,GAAG,CAAC,KAAc,EAAuB,EAAE,CAC3D,QAAQ,CAAC,KAAK,CAAC;IACf,CAAC,KAAK,CA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C,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC9B,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC,CAAC","sourcesContent":["/**\n * Icons for the symbol layers: the images of a style's sprite (MapLibre's sprite format: a JSON index and a PNG sheet,\n * `@2x` on high-density screens, one sprite or several with their ids) and the application's own (`map.addImage`),\n * packed on first use into an RGBA atlas the engine samples (premultiplied: no dark fringe where it is scaled); and the\n * layout of an icon around its anchor: by its anchor and offset, or stretched around its text (`icon-text-fit`), by\n * the stretchable zones and the content box of its image when it has them (`stretchX`, `stretchY`, `content`).\n */\n\nimport { withHeaders } from '../engine/requests.ts';\nimport type { Anchor } from '../ui/overlay.ts';\nimport { isNumbers, isRecord } from '../util/guards.ts';\nimport type { Engine } from '../wasm/isard.js';\n\n/** An image of a sprite's index: its place in the sheet (pixels) and how it is drawn */\nexport interface SpriteIcon {\n x: number;\n y: number;\n width: number;\n height: number;\n /** Image pixels per CSS pixel (default 1; 2 in an `@2x` sheet) */\n pixelRatio?: number;\n /** A signed distance field in alpha, drawn in the icon color */\n sdf?: boolean;\n /** Columns and rows that stretch when the icon is fitted to its text (image pixels): the others keep their size */\n stretchX?: [number, number][];\n stretchY?: [number, number][];\n /** Where the text goes when the icon is fitted to it: left, top, right, bottom (image pixels) */\n content?: [number, number, number, number];\n}\n\nexport type SpriteIndex = Record<string, SpriteIcon>;\n\nconst isPairs = (value: unknown): value is [number, number][] =>\n Array.isArray(value) && value.every((pair) => isNumbers(pair) && pair.length === 2);\n\n/** An icon of a sprite index: its place, and what is drawn from the rest */\nconst isSpriteIcon = (value: unknown): value is SpriteIcon =>\n isRecord(value) &&\n [value.x, value.y, value.width, value.height].every((v) => typeof v === 'number') &&\n (value.pixelRatio === undefined || typeof value.pixelRatio === 'number') &&\n (value.sdf === undefined || typeof value.sdf === 'boolean') &&\n (value.stretchX === undefined || isPairs(value.stretchX)) &&\n (value.stretchY === undefined || isPairs(value.stretchY)) &&\n (value.content === undefined || (isNumbers(value.content) && value.content.length === 4));\n\n/** RGBA pixels, straight alpha, row after row */\nexport interface Pixels {\n width: number;\n height: number;\n data: Uint8Array | Uint8ClampedArray;\n}\n\n/** How an image of the application is drawn (`map.addImage`): `SpriteIcon` without its place */\nexport type ImageOptions = Omit<SpriteIcon, 'x' | 'y' | 'width' | 'height'>;\n\n/** An icon in the atlas: its place (texels) and how it is drawn */\nexport interface Icon {\n x: number;\n y: number;\n width: number;\n height: number;\n pixelRatio: number;\n sdf: boolean;\n stretchX: [number, number][] | undefined;\n stretchY: [number, number][] | undefined;\n content: [number, number, number, number] | undefined;\n}\n\n/** A sprite of a style: its id (`default`: its images keep their names, else `id:name`) and its URL without\n * extension */\nexport interface SpriteSource {\n id: string;\n url: string;\n}\n\n/** The sprites of a style's `sprite`: one URL, or several with their ids (MapLibre's style specification) */\nexport const spriteSources = (sprite: string | readonly SpriteSource[] | undefined): SpriteSource[] => {\n if (typeof sprite === 'string') return sprite ? [{ id: 'default', url: sprite }] : [];\n\n return Array.isArray(sprite) ? sprite.filter((s) => typeof s?.url === 'string' && typeof s.id === 'string') : [];\n};\n\n/** The name of an image of a sprite in the style: its own in the `default` sprite, `id:name` in another */\nexport const spriteName = (id: string, name: string): string => {\n return id === 'default' ? name : `${id}:${name}`;\n};\n\n/** The URL of a sprite's index or sheet: `.json` or `.png`, `@2x` before it for high-density screens, before the\n * query of the URL if it has one */\nexport const spriteFile = (url: string, extension: 'json' | 'png', ratio: number): string => {\n const suffix = `${ratio > 1 ? '@2x' : ''}.${extension}`;\n const query = url.search(/[?#]/);\n\n return query < 0 ? `${url}${suffix}` : `${url.slice(0, query)}${suffix}${url.slice(query)}`;\n};\n\n/** A sprite loaded: its images by name (with the sprite's prefix) and its sheet */\nexport interface LoadedSprite {\n icons: SpriteIndex;\n image: ImageBitmap;\n}\n\n/** Loads a style's sprites (`@2x` above a device pixel ratio of 1, the 1x ones if a server has none); the sprites\n * that fail are left out */\nexport const loadSprites = async (\n sprite: string | readonly SpriteSource[] | undefined,\n ratio = typeof devicePixelRatio === 'number' ? devicePixelRatio : 1,\n): Promise<LoadedSprite[]> => {\n const one = async ({ id, url }: SpriteSource, r: number): Promise<LoadedSprite | undefined> => {\n const [json, png] = await Promise.all([\n fetch(spriteFile(url, 'json', r), withHeaders(spriteFile(url, 'json', r))),\n fetch(spriteFile(url, 'png', r), withHeaders(spriteFile(url, 'png', r))),\n ]);\n\n if (!json.ok || !png.ok) return r > 1 ? one({ id, url }, 1) : undefined;\n\n const index: unknown = await json.json();\n\n if (!isRecord(index)) return r > 1 ? one({ id, url }, 1) : undefined;\n\n const icons: SpriteIndex = Object.fromEntries(\n Object.entries(index).flatMap(([name, icon]) => (isSpriteIcon(icon) ? [[spriteName(id, name), icon]] : [])),\n );\n\n return { icons, image: await createImageBitmap(await png.blob()) };\n };\n const loaded = await Promise.all(spriteSources(sprite).map((s) => one(s, ratio).catch(() => undefined)));\n\n return loaded.filter((s): s is LoadedSprite => s !== undefined);\n};\n\n/** The pixels of an image (read back through a canvas) */\nexport const readPixels = (image: CanvasImageSource & { width: number; height: number }): Pixels | undefined => {\n const { width, height } = image;\n\n if (!(width > 0 && height > 0)) return undefined;\n\n const g =\n typeof OffscreenCanvas === 'function'\n ? new OffscreenCanvas(width, height).getContext('2d')\n : Object.assign(document.createElement('canvas'), { width, height }).getContext('2d');\n\n if (!g) return undefined;\n g.drawImage(image, 0, 0);\n\n return g.getImageData(0, 0, width, height);\n};\n\n/** Where an icon's pixels are: a region of an image, read when first packed */\ninterface IconSource {\n pixels: () => Pixels | undefined;\n x: number;\n y: number;\n width: number;\n height: number;\n options: ImageOptions;\n}\n\n/** A shelf of the packer: its y, height, and the x of the next free place */\ninterface Shelf {\n y: number;\n height: number;\n x: number;\n}\n\n/** The icons of a map and their atlas: a square that doubles as it fills, up to the texture size limit */\nexport class Icons {\n private size = 256;\n private data = new Uint8Array(256 * 256 * 4);\n private shelves: Shelf[] = [];\n private readonly sources = new Map<string, IconSource>();\n /** Icons packed, null for those that cannot be (no pixels, the atlas full) */\n private readonly packed = new Map<string, Icon | null>();\n private engine: Engine | undefined;\n /** Rows changed since the last upload: first, end */\n private dirty: [number, number] | undefined;\n private full = false;\n private readonly maxSize: number;\n /** Bumped each time icons are added or removed: labels laid out without some of theirs are laid out again */\n version = 0;\n\n /** `maxSize`: the GPU's texture size limit if known (the atlas is at most 4096 × 4096) */\n constructor(maxSize = 4096) {\n this.maxSize = Math.max(256, Math.min(4096, maxSize));\n }\n\n /** Sends the whole atlas to an engine (a new one after a context loss) */\n attach(engine: Engine): void {\n this.engine = engine;\n this.dirty = undefined;\n this.upload();\n }\n\n /** Side of the atlas */\n get atlasSize(): number {\n return this.size;\n }\n\n /** An image of the application under `name` (another image of that name is replaced) */\n add(name: string, pixels: Pixels, options: ImageOptions = {}): void {\n this.define(name, { pixels: () => pixels, x: 0, y: 0, width: pixels.width, height: pixels.height, options });\n }\n\n /** The images of a sprite's index, `prefix` before their names, their pixels read from the sheet on first use */\n addSprite(prefix: string, index: SpriteIndex, sheet: () => Pixels | undefined): void {\n let pixels: Pixels | undefined;\n let read = false;\n const once = () => {\n if (!read) {\n read = true;\n pixels = sheet();\n }\n\n return pixels;\n };\n\n Object.entries(index).forEach(([name, icon]) => {\n if (!icon || typeof icon !== 'object') return;\n\n const { x, y, width, height, ...options } = icon;\n\n this.define(`${prefix}${name}`, { pixels: once, x, y, width, height, options }, false);\n });\n this.version += 1;\n }\n\n private define(name: string, source: IconSource, bump = true): void {\n this.sources.set(name, source);\n // Packed again on its next use (its old place stays taken)\n this.packed.delete(name);\n if (bump) this.version += 1;\n }\n\n has(name: string): boolean {\n return this.sources.has(name);\n }\n\n /** Forgets an image, or every image whose name starts with `prefix` (a sprite's) */\n remove(name: string, prefix = false): void {\n [...this.sources.keys()]\n .filter((key) => (prefix ? key.startsWith(name) : key === name))\n .forEach((key) => {\n this.sources.delete(key);\n this.packed.delete(key);\n });\n this.version += 1;\n }\n\n /** The icon of this name, packed into the atlas on first use; undefined if there is none (`flush` uploads it) */\n get(name: string): Icon | undefined {\n const hit = this.packed.get(name);\n\n if (hit !== undefined) return hit ?? undefined;\n\n const source = this.sources.get(name);\n\n if (!source) return undefined;\n\n const icon = this.pack(source);\n\n this.packed.set(name, icon ?? null);\n\n return icon;\n }\n\n /** Sends the rows changed since the last upload to the engine */\n flush(): void {\n const dirty = this.dirty;\n\n this.dirty = undefined;\n if (!dirty || !this.engine) return;\n\n const [y0, y1] = dirty;\n const row = this.size * 4;\n\n this.engine.updateIconAtlas(0, y0, this.size, y1 - y0, this.data.subarray(y0 * row, y1 * row));\n }\n\n private upload(): void {\n const engine = this.engine;\n\n if (!engine) return;\n engine.setIconAtlas(this.size, this.size);\n\n const used = this.shelves.reduce((m, s) => Math.max(m, s.y + s.height), 0);\n\n if (used > 0) engine.updateIconAtlas(0, 0, this.size, used, this.data.subarray(0, used * this.size * 4));\n }\n\n /** Copies an icon's pixels into the atlas, premultiplied, with a texel of room around it */\n private pack(source: IconSource): Icon | undefined {\n const pixels = source.pixels();\n const { x, y, width: w, height: h } = source;\n\n if (!pixels || !(w > 0 && h > 0) || x < 0 || y < 0 || x + w > pixels.width || y + h > pixels.height) {\n return undefined;\n }\n\n const place = this.place(w + 2, h + 2);\n\n if (!place) return undefined;\n\n const [px, py] = [place[0] + 1, place[1] + 1];\n\n for (let row = 0; row < h; row += 1) {\n for (let col = 0; col < w; col += 1) {\n const from = ((y + row) * pixels.width + x + col) * 4;\n const to = ((py + row) * this.size + px + col) * 4;\n const a = pixels.data[from + 3] ?? 0;\n\n this.data[to] = ((pixels.data[from] ?? 0) * a + 127) / 255;\n this.data[to + 1] = ((pixels.data[from + 1] ?? 0) * a + 127) / 255;\n this.data[to + 2] = ((pixels.data[from + 2] ?? 0) * a + 127) / 255;\n this.data[to + 3] = a;\n }\n }\n\n const [d0, d1] = this.dirty ?? [place[1], place[1]];\n\n this.dirty = [Math.min(d0, place[1]), Math.max(d1, place[1] + h + 2)];\n\n const { pixelRatio, sdf, stretchX, stretchY, content } = source.options;\n\n return {\n x: px,\n y: py,\n width: w,\n height: h,\n pixelRatio: pixelRatio && pixelRatio > 0 ? pixelRatio : 1,\n sdf: sdf === true,\n stretchX: Array.isArray(stretchX) ? stretchX : undefined,\n stretchY: Array.isArray(stretchY) ? stretchY : undefined,\n content: Array.isArray(content) && content.length === 4 ? content : undefined,\n };\n }\n\n /** A free place of `w` × `h` texels (shelves, the atlas doubled when full); undefined once it cannot grow */\n private place(w: number, h: number): [number, number] | undefined {\n for (;;) {\n const shelf = this.shelves.find((s) => s.height >= h && s.height <= h + 8 && s.x + w <= this.size);\n\n if (shelf) {\n shelf.x += w;\n\n return [shelf.x - w, shelf.y];\n }\n\n const last = this.shelves.at(-1);\n const y = last ? last.y + last.height : 0;\n\n if (y + h <= this.size && w <= this.size) {\n this.shelves.push({ y, height: h, x: w });\n\n return [0, y];\n }\n if (this.size * 2 > this.maxSize) {\n if (!this.full) console.warn(`isard: the icon atlas is full (${this.size} × ${this.size})`);\n this.full = true;\n\n return undefined;\n }\n this.grow();\n }\n }\n\n /** Doubles the atlas; the icons keep their places (texels) */\n private grow(): void {\n const size = this.size * 2;\n const data = new Uint8Array(size * size * 4);\n\n for (let row = 0; row < this.size; row += 1) {\n data.set(this.data.subarray(row * this.size * 4, (row + 1) * this.size * 4), row * size * 4);\n }\n this.size = size;\n this.data = data;\n this.dirty = undefined;\n this.upload();\n }\n}\n\n/** How an icon is laid out around its anchor */\nexport interface IconLayoutOptions {\n /** Scale of the image (`icon-size`) */\n size: number;\n anchor: Anchor;\n /** CSS pixels at size 1 */\n offset: [number, number];\n /** Degrees, clockwise */\n rotate: number;\n /** Stretched around the text: its width, its height, both (`icon-text-fit`) */\n fit: 'none' | 'width' | 'height' | 'both';\n /** Room around the text when fitted: top, right, bottom, left (CSS pixels) */\n padding: [number, number, number, number];\n /** The text's box around the anchor (CSS pixels), if it has one */\n text?: [number, number, number, number] | undefined;\n}\n\n/** An icon laid out: its quads (x, y, width, height in CSS pixels from the anchor, atlas u0, v0, u1, v1 in texels, -1\n * or -2 for a distance field, turn in radians) and its box from the anchor */\nexport interface IconLayout {\n quads: number[][];\n box: [number, number, number, number];\n}\n\n/** Pieces of an image along one axis: image start, end, laid out start, end */\ntype Pieces = [number, number, number, number][];\n\n/**\n * An axis of an icon fitted to `lo`…`hi` (CSS pixels): its content (the whole image by default) spans them, its\n * stretchable zones (the whole image by default) taking the room the fixed parts (at `scale` CSS pixels per image\n * pixel) leave\n */\nexport const stretch = (\n length: number,\n zones: readonly [number, number][] | undefined,\n content: [number, number] | undefined,\n lo: number,\n hi: number,\n scale: number,\n): Pieces => {\n const clamp = (v: number) => Math.max(0, Math.min(length, Number(v) || 0));\n const whole: [number, number][] = [[0, length]];\n const spans = (zones?.length ? zones : whole)\n .map(([a, b]): [number, number] => [clamp(Math.min(a, b)), clamp(Math.max(a, b))])\n .filter(([a, b]) => b > a);\n const cuts = [...new Set([0, length, ...spans.flat()])].sort((a, b) => a - b);\n const pieces = cuts.slice(1).map((b, i): [number, number, boolean] => {\n const a = cuts[i] ?? 0;\n\n return [a, b, spans.some(([s, e]) => s <= a && b <= e)];\n });\n const [c0, c1] = content ? [clamp(content[0]), clamp(content[1])] : [0, length];\n const overlap = (a: number, b: number) => Math.max(0, Math.min(b, c1) - Math.max(a, c0));\n const stretchable = pieces.reduce((n, [a, b, s]) => n + (s ? overlap(a, b) : 0), 0);\n const fixed = c1 - c0 - stretchable;\n // CSS pixels per stretchable image pixel: what the fixed parts of the content leave of the room\n const k = stretchable > 0 ? Math.max(0, (hi - lo - fixed * scale) / stretchable) : scale;\n // Laid out position of an image coordinate\n const at = (x: number) => pieces.reduce((n, [a, b, s]) => n + Math.max(0, Math.min(x, b) - a) * (s ? k : scale), 0);\n const origin = lo - at(c0);\n\n return pieces.map(([a, b]) => [a, b, origin + at(a), origin + at(b)]);\n};\n\n/** Where an anchor's side lies along an axis of the icon: at its start 0, at its end 1, else the middle */\nconst align = (start: boolean, end: boolean): number => {\n if (start) return 0;\n\n return end ? 1 : 0.5;\n};\n\n/** Lays an icon out around its anchor: placed by its anchor and offset, or fitted to its text */\nexport const layoutIcon = (icon: Icon, options: IconLayoutOptions): IconLayout => {\n const { size, anchor, offset, rotate, fit, padding, text } = options;\n const { width: w, height: h, pixelRatio } = icon;\n const [xs, ys] = ((): [Pieces, Pieces] => {\n if (fit !== 'none' && text) {\n const [top, right, bottom, left] = padding;\n const [x0, y0, x1, y1] = [text[0] - left, text[1] - top, text[2] + right, text[3] + bottom];\n // The fixed parts at the image's own size; an axis not fitted at the icon's size, centered on the text\n const own = 1 / pixelRatio;\n const scaled = size / pixelRatio;\n const centered = (length: number, lo: number, hi: number): Pieces => {\n const c = (lo + hi) / 2;\n\n return [[0, length, c - (length * scaled) / 2, c + (length * scaled) / 2]];\n };\n const content = icon.content;\n\n return [\n fit === 'height'\n ? centered(w, x0, x1)\n : stretch(w, icon.stretchX, content && [content[0], content[2]], x0, x1, own),\n fit === 'width'\n ? centered(h, y0, y1)\n : stretch(h, icon.stretchY, content && [content[1], content[3]], y0, y1, own),\n ];\n }\n\n const [dw, dh] = [(w / pixelRatio) * size, (h / pixelRatio) * size];\n const ax = align(anchor.includes('left'), anchor.includes('right'));\n const ay = align(anchor.startsWith('top'), anchor.startsWith('bottom'));\n const [left, top] = [offset[0] * size - dw * ax, offset[1] * size - dh * ay];\n\n return [[[0, w, left, left + dw]], [[0, h, top, top + dh]]];\n })();\n const angle = ((Number(rotate) || 0) * Math.PI) / 180;\n const kind = icon.sdf ? -2 : -1;\n const quads: number[][] = [];\n const [cs, sn] = [Math.cos(angle), Math.sin(angle)];\n const box: [number, number, number, number] = [\n Number.POSITIVE_INFINITY,\n Number.POSITIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n Number.NEGATIVE_INFINITY,\n ];\n\n ys.forEach(([v0, v1, top, bottom]) => {\n xs.forEach(([u0, u1, left, right]) => {\n if (right <= left || bottom <= top) return;\n quads.push([\n left,\n top,\n right - left,\n bottom - top,\n icon.x + u0,\n icon.y + v0,\n icon.x + u1,\n icon.y + v1,\n kind,\n angle,\n ]);\n\n // The box of the turned corners\n const corners: [number, number][] = [\n [left, top],\n [right, top],\n [left, bottom],\n [right, bottom],\n ];\n\n corners.forEach(([px, py]) => {\n const [rx, ry] = [px * cs - py * sn, px * sn + py * cs];\n\n box[0] = Math.min(box[0], rx);\n box[1] = Math.min(box[1], ry);\n box[2] = Math.max(box[2], rx);\n box[3] = Math.max(box[3], ry);\n });\n });\n });\n\n return { quads, box: quads.length ? box : [0, 0, 0, 0] };\n};\n"]}
|
package/dist/layers/layers.d.ts
CHANGED
|
@@ -184,7 +184,7 @@ export interface ModelOptions {
|
|
|
184
184
|
altitudeReference?: 'ground' | 'sea';
|
|
185
185
|
}
|
|
186
186
|
/** The numbers of instances for the engine: longitude, latitude, altitude, heading, pitch, roll, scale */
|
|
187
|
-
export declare
|
|
187
|
+
export declare const instanceNumbers: (instances: readonly ModelInstance[]) => Float64Array;
|
|
188
188
|
/** A glTF model drawn at positions, in one instanced draw; `pickFeature` gives the instance's index */
|
|
189
189
|
export declare class ModelLayer extends Layer {
|
|
190
190
|
private readonly url;
|
package/dist/layers/layers.js
CHANGED
|
@@ -133,23 +133,23 @@ export class NetworkLayer extends Layer {
|
|
|
133
133
|
/** @internal */
|
|
134
134
|
create(engine) {
|
|
135
135
|
const { nodes, edges, lines } = this.geometry;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
else {
|
|
136
|
+
const mercator = (() => {
|
|
137
|
+
if (this.kept) {
|
|
138
|
+
const { origin, nodes: n, lines: l } = this.kept;
|
|
139
|
+
return { nodes: unpack(n, origin), lines: l && unpack(l, origin) };
|
|
140
|
+
}
|
|
142
141
|
// Mercator here: Math.tan and Math.log run natively, several times faster than in WebAssembly
|
|
143
|
-
|
|
144
|
-
const origin = [
|
|
142
|
+
const projected = { nodes: mercatorPoints(nodes), lines: lines && mercatorPoints(lines.points) };
|
|
143
|
+
const origin = [projected.nodes[0] ?? 0, projected.nodes[1] ?? 0];
|
|
145
144
|
this.kept = {
|
|
146
145
|
origin,
|
|
147
|
-
nodes: pack(
|
|
148
|
-
lines:
|
|
146
|
+
nodes: pack(projected.nodes, origin),
|
|
147
|
+
lines: projected.lines && pack(projected.lines, origin),
|
|
149
148
|
};
|
|
150
149
|
// The degrees are not needed again: millions of points for a region
|
|
151
150
|
this.geometry = { nodes: EMPTY, edges, lines: lines && { start: lines.start, points: EMPTY } };
|
|
152
|
-
|
|
151
|
+
return projected;
|
|
152
|
+
})();
|
|
153
153
|
const id = engine.addNetwork(mercator.nodes, edges, lines?.start, mercator.lines, this.costs, networkStyle(this.style));
|
|
154
154
|
if (this.style.ramp)
|
|
155
155
|
engine.setNetworkRamp(id, rampTexels(this.style.ramp).rgba);
|
|
@@ -161,7 +161,7 @@ export class NetworkLayer extends Layer {
|
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
/** The 25 numbers of a network style for the engine */
|
|
164
|
-
|
|
164
|
+
const networkStyle = (style) => {
|
|
165
165
|
const { width, halo, max, contour, opacity, haloOpacity, unreachedColor, fade } = style;
|
|
166
166
|
return Float32Array.from([
|
|
167
167
|
...stops(width),
|
|
@@ -173,34 +173,34 @@ function networkStyle(style) {
|
|
|
173
173
|
...parseColor(unreachedColor),
|
|
174
174
|
fade,
|
|
175
175
|
]);
|
|
176
|
-
}
|
|
176
|
+
};
|
|
177
177
|
const EMPTY = new Float64Array(0);
|
|
178
178
|
/** Interleaved points as f32 offsets from an origin, and back */
|
|
179
|
-
|
|
179
|
+
const pack = (points, [ox, oy]) => {
|
|
180
180
|
const out = new Float32Array(points.length);
|
|
181
181
|
for (let i = 0; i < points.length; i += 2) {
|
|
182
182
|
out[i] = (points[i] ?? 0) - ox;
|
|
183
183
|
out[i + 1] = (points[i + 1] ?? 0) - oy;
|
|
184
184
|
}
|
|
185
185
|
return out;
|
|
186
|
-
}
|
|
187
|
-
|
|
186
|
+
};
|
|
187
|
+
const unpack = (points, [ox, oy]) => {
|
|
188
188
|
const out = new Float64Array(points.length);
|
|
189
189
|
for (let i = 0; i < points.length; i += 2) {
|
|
190
190
|
out[i] = (points[i] ?? 0) + ox;
|
|
191
191
|
out[i + 1] = (points[i + 1] ?? 0) + oy;
|
|
192
192
|
}
|
|
193
193
|
return out;
|
|
194
|
-
}
|
|
194
|
+
};
|
|
195
195
|
/** Longitudes and latitudes (degrees, interleaved) to Mercator [0, 1], y towards the south */
|
|
196
|
-
|
|
196
|
+
const mercatorPoints = (lonLat) => {
|
|
197
197
|
const out = new Float64Array(lonLat.length);
|
|
198
198
|
for (let i = 0; i < lonLat.length; i += 2) {
|
|
199
199
|
out[i] = mercatorX(lonLat[i] ?? 0);
|
|
200
200
|
out[i + 1] = mercatorY(lonLat[i + 1] ?? 0);
|
|
201
201
|
}
|
|
202
202
|
return out;
|
|
203
|
-
}
|
|
203
|
+
};
|
|
204
204
|
/** Textured meshes in 3D Tiles */
|
|
205
205
|
export class Tiles3dLayer extends Layer {
|
|
206
206
|
url;
|
|
@@ -263,10 +263,12 @@ export class GroundLayer extends Layer {
|
|
|
263
263
|
constructor(map, options) {
|
|
264
264
|
super(map);
|
|
265
265
|
this.options = options;
|
|
266
|
-
|
|
266
|
+
Object.entries(options.textures ?? {}).forEach(([name, texture]) => {
|
|
267
267
|
this.textures.set(name, texture);
|
|
268
|
-
|
|
268
|
+
});
|
|
269
|
+
Object.entries(options.uniforms ?? {}).forEach(([name, value]) => {
|
|
269
270
|
this.uniforms.set(name, [value].flat());
|
|
271
|
+
});
|
|
270
272
|
}
|
|
271
273
|
/** Creates or replaces a texture of the code's sampler `name` */
|
|
272
274
|
setTexture(name, texture) {
|
|
@@ -308,30 +310,32 @@ export class GroundLayer extends Layer {
|
|
|
308
310
|
create(engine) {
|
|
309
311
|
const [ax, ay] = toMercator(this.options.anchor);
|
|
310
312
|
const id = engine.addGround(this.options.code, ax, ay, ...mercatorBox(this.options.bounds ?? [-180, -85.06, 180, 85.06]));
|
|
311
|
-
|
|
313
|
+
this.textures.forEach((texture, name) => {
|
|
312
314
|
this.sendTexture(engine, id, name, texture);
|
|
313
|
-
|
|
315
|
+
});
|
|
316
|
+
this.uniforms.forEach((values, name) => {
|
|
314
317
|
engine.setGroundUniform(id, name, Float64Array.from(values));
|
|
318
|
+
});
|
|
315
319
|
engine.setGroundVisible(id, this.visible);
|
|
316
320
|
return id;
|
|
317
321
|
}
|
|
318
322
|
}
|
|
319
323
|
/** A lon/lat box to Mercator min x, min y, max x, max y (y towards the south) */
|
|
320
|
-
|
|
324
|
+
const mercatorBox = ([west, south, east, north]) => {
|
|
321
325
|
const [x0, y1] = toMercator([west, south]);
|
|
322
326
|
const [x1, y0] = toMercator([east, north]);
|
|
323
327
|
return [x0, y0, x1, y1];
|
|
324
|
-
}
|
|
328
|
+
};
|
|
325
329
|
// ── The page's own 3D content: custom layers, glTF models ──
|
|
326
330
|
/** Reports an error of the page without throwing it here: the console shows it, as an uncaught one */
|
|
327
|
-
|
|
331
|
+
const report = (error) => {
|
|
328
332
|
if (typeof reportError === 'function')
|
|
329
333
|
reportError(error);
|
|
330
334
|
else
|
|
331
335
|
queueMicrotask(() => {
|
|
332
336
|
throw error;
|
|
333
337
|
});
|
|
334
|
-
}
|
|
338
|
+
};
|
|
335
339
|
/** A layer drawn by the page's WebGL code (see `CustomLayerInterface`) */
|
|
336
340
|
export class CustomLayer extends Layer {
|
|
337
341
|
implementation;
|
|
@@ -410,13 +414,13 @@ export class CustomLayer extends Layer {
|
|
|
410
414
|
}
|
|
411
415
|
}
|
|
412
416
|
/** The numbers of instances for the engine: longitude, latitude, altitude, heading, pitch, roll, scale */
|
|
413
|
-
export
|
|
417
|
+
export const instanceNumbers = (instances) => {
|
|
414
418
|
const out = new Float64Array(instances.length * 7);
|
|
415
419
|
instances.forEach(({ lonLat, altitude = 0, heading = 0, pitch = 0, roll = 0, scale = 1 }, i) => {
|
|
416
420
|
out.set([lonLat[0], lonLat[1], altitude, heading, pitch, roll, scale], i * 7);
|
|
417
421
|
});
|
|
418
422
|
return out;
|
|
419
|
-
}
|
|
423
|
+
};
|
|
420
424
|
/** A glTF model drawn at positions, in one instanced draw; `pickFeature` gives the instance's index */
|
|
421
425
|
export class ModelLayer extends Layer {
|
|
422
426
|
url;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layers.js","sourceRoot":"","sources":["../../src/layers/layers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAUrC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAgB,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,OAAgB,KAAK;IACzB,GAAG,GAAG,CAAC,CAAC,CAAC;IAET,gBAAgB;IACG,GAAG,CAAY;IAElC,gBAAgB;IAChB,YAAY,GAAc;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,oCAAoC;IACpC,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,MAAM,CAA4B;IAElC;iFAC6E;IAC7E,IAAI,KAAK;QACP,IAAI,CAAC,MAAM,KAAK,CAAC,KAAK,IAAI,EAAE;YAC1B;gBAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ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AAM,CAAC,CAAC;QACxE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAC3B,CAAC;IAEQ,MAAM;QACb,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,gBAAgB;IACP,OAAO;QACd,IAAI,IAAI,CAAC,IAAI;YAAE,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,gBAAgB;IACN,MAAM,CAAC,MAAc;QAC7B,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;CACF","sourcesContent":["/**\n * Handles of the layers added to a map. Each one keeps what it needs to be created again: after a WebGL context loss,\n * the map recreates its engine and every layer in order, with the same handle (its id is updated). Also the page's\n * own 3D content: custom layers (its WebGL code called in every frame) and glTF models drawn at positions.\n */\n\nimport type { GeoMap } from '../map.ts';\nimport { rgb } from '../settings.ts';\nimport type {\n LayerHost,\n LonLat,\n NetworkOptions,\n NetworkStyle,\n RasterOptions,\n RasterStyle,\n Tiles3dStyle,\n} from '../types.ts';\nimport { mercatorX, mercatorY, toMercator } from '../util/geo.ts';\nimport type { Camera, Engine, NetworkStats, Tiles3dStats } from '../wasm/isard.js';\nimport { type Feature, parseColor, rampTexels, stops } from './features.ts';\n\nexport abstract class Layer {\n #id = -1;\n\n /** @internal */\n protected readonly map: LayerHost;\n\n /** @internal */\n constructor(map: LayerHost) {\n this.map = map;\n }\n\n /** Id of the layer in the engine */\n get id(): number {\n return this.#id;\n }\n\n #ready: Promise<void> | undefined;\n\n /** Resolves once the map has drawn the layer, what it shows in view loaded (the map idle after it was added; a\n * layer waiting for the engine with 3D Tiles, once that one has drawn it) */\n get ready(): Promise<void> {\n this.#ready ??= (async () => {\n do await this.map.whenIdle();\n while (this.#id < 0 && this.needsFullEngine);\n })();\n return this.#ready;\n }\n\n /** @internal Creates the layer in an engine (again after a context loss); its id is -1 if that fails */\n attach(engine: Engine): void {\n this.#id = -1;\n this.#id = this.create(engine);\n }\n\n /** @internal Forgets its id in an engine that is gone (before the layers are created in a new one) */\n forgetEngine(): void {\n this.#id = -1;\n }\n\n /** @internal Sends what refers to other layers, once every layer of a new engine has its id */\n relink(_engine: Engine): void {}\n\n /** @internal Drawn by the engine with 3D Tiles only (3D Tiles, models): on the core engine, it waits for that one */\n get needsFullEngine(): boolean {\n return false;\n }\n\n /** @internal The layer is removed or its map destroyed: frees what it holds outside the engine */\n dispose(): void {}\n\n /** @internal */\n protected abstract create(engine: Engine): number;\n\n remove(): void {\n // Not created yet: a 3D Tiles layer or a model waiting for the engine with 3D Tiles\n if (this.#id >= 0) this.map.engine.removeLayer(this.#id);\n this.#id = -1;\n this.map.detach(this);\n this.map.requestRender();\n }\n\n /** Moves the layer under `other`, or on top of every layer (above the labels of a vector basemap too) */\n moveBefore(other: Layer | undefined): void {\n this.map.moveLayer(this, other);\n }\n}\n\n/** Raster tiles (basemaps, overlays) */\nexport class RasterLayer extends Layer {\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly options: Required<Omit<RasterOptions, 'size' | 'loader' | 'grid' | 'attribution'>> & {\n size: number | undefined;\n loader: RasterOptions['loader'] | undefined;\n },\n ) {\n super(map);\n }\n\n /** Changes the opacity or saturation, the other kept */\n setStyle(style: Partial<RasterStyle>): void {\n this.options.opacity = style.opacity ?? this.options.opacity;\n this.options.saturation = style.saturation ?? this.options.saturation;\n this.map.engine.setRasterStyle(this.id, this.options.opacity, this.options.saturation);\n this.map.requestRender();\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const { url, minZoom, maxZoom, opacity, saturation, size, loader } = this.options;\n return engine.addRaster(url, minZoom, maxZoom, opacity, saturation, size, loader);\n }\n}\n\n/** Line network colored by a value per node (travel time, water depth…) */\nexport class NetworkLayer extends Layer {\n private values: Float32Array | undefined;\n /** Node and line positions in Mercator, kept for a context loss: f32 offsets from an origin (exact to the centimetre\n * across a region, half the memory of f64) */\n private kept: { origin: [number, number]; nodes: Float32Array; lines: Float32Array | undefined } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n private geometry: { nodes: Float64Array; edges: Uint32Array; lines: NetworkOptions['lines'] | undefined },\n private costs: Float32Array | undefined,\n private style: NetworkStyle,\n private edgeWidths: Float32Array | undefined,\n ) {\n super(map);\n }\n\n /** One value per node, in node order; negative (or 1e30 and above) = unreached. Costs one texture upload, drawn\n * next frame. */\n setValues(values: Float32Array): void {\n this.values = values;\n this.map.engine.setNetworkValues(this.id, values);\n this.map.requestRender();\n }\n\n /** Costs of the edges, A → B then B → A (see `NetworkOptions.costs`), when the way the network is travelled\n * changes; undefined: values interpolated along the edges. The geometry stays on the graphics card. */\n setCosts(costs: Float32Array | undefined): void {\n this.costs = costs;\n this.map.engine.setNetworkCosts(this.id, costs);\n this.map.requestRender();\n }\n\n setStyle(style: Partial<NetworkStyle>): void {\n const ramp = this.style.ramp;\n this.style = { ...this.style, ...style };\n this.map.engine.setNetworkStyle(this.id, networkStyle(this.style));\n if (this.style.ramp !== ramp)\n this.map.engine.setNetworkRamp(this.id, this.style.ramp && rampTexels(this.style.ramp).rgba);\n this.map.requestRender();\n }\n\n /** Width factor of each edge (undefined: 1 for all) */\n setEdgeWidths(widths: Float32Array | undefined): void {\n this.edgeWidths = widths;\n this.map.engine.setNetworkScales(this.id, widths);\n this.map.requestRender();\n }\n\n /** Pieces in all and drawn in the last frame */\n stats(): NetworkStats | undefined {\n return this.map.engine.networkStats(this.id);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const { nodes, edges, lines } = this.geometry;\n let mercator: { nodes: Float64Array; lines: Float64Array | undefined };\n if (this.kept) {\n const { origin, nodes: n, lines: l } = this.kept;\n mercator = { nodes: unpack(n, origin), lines: l && unpack(l, origin) };\n } else {\n // Mercator here: Math.tan and Math.log run natively, several times faster than in WebAssembly\n mercator = { nodes: mercatorPoints(nodes), lines: lines && mercatorPoints(lines.points) };\n const origin: [number, number] = [mercator.nodes[0] ?? 0, mercator.nodes[1] ?? 0];\n this.kept = {\n origin,\n nodes: pack(mercator.nodes, origin),\n lines: mercator.lines && pack(mercator.lines, origin),\n };\n // The degrees are not needed again: millions of points for a region\n this.geometry = { nodes: EMPTY, edges, lines: lines && { start: lines.start, points: EMPTY } };\n }\n const id = engine.addNetwork(\n mercator.nodes,\n edges,\n lines?.start,\n mercator.lines,\n this.costs,\n networkStyle(this.style),\n );\n if (this.style.ramp) engine.setNetworkRamp(id, rampTexels(this.style.ramp).rgba);\n if (this.edgeWidths) engine.setNetworkScales(id, this.edgeWidths);\n if (this.values) engine.setNetworkValues(id, this.values);\n return id;\n }\n}\n\n/** The 25 numbers of a network style for the engine */\nfunction networkStyle(style: NetworkStyle): Float32Array {\n const { width, halo, max, contour, opacity, haloOpacity, unreachedColor, fade } = style;\n return Float32Array.from([\n ...stops(width),\n ...stops(halo),\n max,\n contour,\n opacity,\n haloOpacity,\n ...parseColor(unreachedColor),\n fade,\n ]);\n}\n\nconst EMPTY = new Float64Array(0);\n\n/** Interleaved points as f32 offsets from an origin, and back */\nfunction pack(points: Float64Array, [ox, oy]: [number, number]): Float32Array {\n const out = new Float32Array(points.length);\n for (let i = 0; i < points.length; i += 2) {\n out[i] = (points[i] ?? 0) - ox;\n out[i + 1] = (points[i + 1] ?? 0) - oy;\n }\n return out;\n}\n\nfunction unpack(points: Float32Array, [ox, oy]: [number, number]): Float64Array {\n const out = new Float64Array(points.length);\n for (let i = 0; i < points.length; i += 2) {\n out[i] = (points[i] ?? 0) + ox;\n out[i + 1] = (points[i + 1] ?? 0) + oy;\n }\n return out;\n}\n\n/** Longitudes and latitudes (degrees, interleaved) to Mercator [0, 1], y towards the south */\nfunction mercatorPoints(lonLat: Float64Array): Float64Array {\n const out = new Float64Array(lonLat.length);\n for (let i = 0; i < lonLat.length; i += 2) {\n out[i] = mercatorX(lonLat[i] ?? 0);\n out[i + 1] = mercatorY(lonLat[i + 1] ?? 0);\n }\n return out;\n}\n\n/** Textured meshes in 3D Tiles */\nexport class Tiles3dLayer extends Layer {\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly url: string,\n private readonly geoid: boolean,\n private style: Tiles3dStyle,\n ) {\n super(map);\n }\n\n setStyle(style: Partial<Tiles3dStyle>): void {\n this.style = { ...this.style, ...style };\n // Kept for its creation while the engine with 3D Tiles loads\n if (this.id < 0) return;\n this.applyStyle(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** @internal */\n override get needsFullEngine(): boolean {\n return true;\n }\n\n /** @internal The feature picked (`pickFeature`, 'hoverfeature'): the properties of its feature in the tile\n * (`EXT_structural_metadata`, a b3dm batch table), none for a mesh without features; its index in the tile as id */\n featureAt(index: number): Feature<Record<string, unknown>> | undefined {\n if (this.id < 0) return undefined;\n const hit = this.map.engine.tiles3dFeature(this.id, index);\n if (!hit) return undefined;\n const [properties, feature] = hit;\n return { type: 'Feature', id: feature, properties: properties ?? {}, geometry: null };\n }\n\n /** Loading counters; undefined once the layer is removed, and while the engine with 3D Tiles loads (see\n * `GeoMapOptions.tiles3d`) */\n stats(): Tiles3dStats | undefined {\n return this.id < 0 ? undefined : this.map.engine.tiles3dStats(this.id);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addTiles3d(this.url, this.style.maxScreenSpaceError, this.geoid);\n this.applyStyle(engine, id);\n return id;\n }\n\n private applyStyle(engine: Engine, id: number): void {\n const { maxScreenSpaceError, opacity, pointSize, color } = this.style;\n engine.setTiles3dStyle(id, maxScreenSpaceError, opacity, pointSize, new Float32Array(color ? rgb(color) : []));\n }\n}\n\n/** A texture of a ground layer (see `GroundLayer`) */\nexport interface GroundTexture {\n /** `r8`, `r8ui`, `r16ui`, `r16i`, `r32ui`, `r32f`, `rg16ui`, `rg32f`, `rgba8`, `rgba8ui`, `rgba16ui`, `rgba32f`:\n * integer formats are read with `usampler2D` / `isampler2D` and `texelFetch` */\n format: string;\n width: number;\n height: number;\n /** Layers of a 2D array (`sampler2DArray`, `usampler2DArray`…); 0 or undefined: a 2D texture */\n depth?: number;\n /** Linear filtering (non-integer formats); default nearest */\n linear?: boolean;\n /** Texels row after row (layer after layer), any typed array; undefined: left empty */\n data?: ArrayBufferView;\n}\n\nexport interface GroundOptions {\n /**\n * GLSL ES 3.0 defining `vec4 ground(vec2 offset)`: the color of the ground (premultiplied alpha, 0 for nothing) at\n * `offset`, the Mercator offset of the pixel from `anchor` (times `ISARD_CIRCUMFERENCE`: metres of EPSG:3857), exact to\n * the millimetre at any zoom. The code declares its own uniforms and samplers; also there: `u_zoom`,\n * `u_pixel_ratio`\n */\n code: string;\n /** Where the offsets are taken from */\n anchor: LonLat;\n /** Box it shows in, `[west, south, east, north]` (default the world): only the ground there is drawn again */\n bounds?: [west: number, south: number, east: number, north: number];\n textures?: Record<string, GroundTexture>;\n uniforms?: Record<string, number | readonly number[]>;\n}\n\nconst bytesOf = (data: ArrayBufferView) => new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n\n/** The application's fragment shader run over the ground, draped on the relief (water depth, heat maps…) */\nexport class GroundLayer extends Layer {\n private readonly textures = new Map<string, GroundTexture>();\n private readonly uniforms = new Map<string, number[]>();\n private visible = true;\n\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly options: GroundOptions,\n ) {\n super(map);\n for (const [name, texture] of Object.entries(options.textures ?? {})) this.textures.set(name, texture);\n for (const [name, value] of Object.entries(options.uniforms ?? {})) this.uniforms.set(name, [value].flat());\n }\n\n /** Creates or replaces a texture of the code's sampler `name` */\n setTexture(name: string, texture: GroundTexture): void {\n this.textures.set(name, texture);\n this.sendTexture(this.map.engine, this.id, name, texture);\n this.map.requestRender();\n }\n\n /**\n * Replaces a region of a texture: `data` holds `width` × `height` texels for (`x`, `y`) of `layer` (2D arrays).\n * Keep the texture's own `data` up to date too if it must survive a WebGL context loss.\n */\n updateTexture(\n name: string,\n data: ArrayBufferView,\n region: { x?: number; y?: number; layer?: number; width: number; height: number },\n ): void {\n const { x = 0, y = 0, layer = 0, width, height } = region;\n this.map.engine.updateGroundTexture(this.id, name, x, y, layer, width, height, bytesOf(data));\n this.map.requestRender();\n }\n\n /** A uniform of the code: a number, or numbers for vectors, arrays and matrices (column major) */\n setUniform(name: string, value: number | readonly number[]): void {\n const values = [value].flat();\n this.uniforms.set(name, values);\n this.map.engine.setGroundUniform(this.id, name, Float64Array.from(values));\n this.map.requestRender();\n }\n\n setBounds(bounds: [west: number, south: number, east: number, north: number]): void {\n this.options.bounds = bounds;\n this.map.engine.setGroundBounds(this.id, ...mercatorBox(bounds));\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.visible = visible;\n this.map.engine.setGroundVisible(this.id, visible);\n this.map.requestRender();\n }\n\n private sendTexture(engine: Engine, id: number, name: string, t: GroundTexture): void {\n const data = t.data && bytesOf(t.data);\n engine.setGroundTexture(id, name, t.format, t.width, t.height, t.depth ?? 0, t.linear ?? false, data);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const [ax, ay] = toMercator(this.options.anchor);\n const id = engine.addGround(\n this.options.code,\n ax,\n ay,\n ...mercatorBox(this.options.bounds ?? [-180, -85.06, 180, 85.06]),\n );\n for (const [name, texture] of this.textures) this.sendTexture(engine, id, name, texture);\n for (const [name, values] of this.uniforms) engine.setGroundUniform(id, name, Float64Array.from(values));\n engine.setGroundVisible(id, this.visible);\n return id;\n }\n}\n\n/** A lon/lat box to Mercator min x, min y, max x, max y (y towards the south) */\nfunction mercatorBox([west, south, east, north]: [number, number, number, number]): [number, number, number, number] {\n const [x0, y1] = toMercator([west, south]);\n const [x1, y0] = toMercator([east, north]);\n return [x0, y0, x1, y1];\n}\n\n// ── The page's own 3D content: custom layers, glTF models ──\n\n/** Reports an error of the page without throwing it here: the console shows it, as an uncaught one */\nfunction report(error: unknown): void {\n if (typeof reportError === 'function') reportError(error);\n else\n queueMicrotask(() => {\n throw error;\n });\n}\n\n/** What a custom layer gets to draw a frame (`CustomLayerInterface.render`) */\nexport interface CustomFrame {\n /**\n * The model-view-projection matrix of a local frame at a position and altitude (metres above the ellipsoid, as the\n * relief is drawn: times its exaggeration), column-major for `uniformMatrix4fv` or a three.js camera: x east, y\n * north, z up, in metres. Made in double precision relative to the camera, so that what is drawn stays exact at\n * any zoom; draw within a few kilometres of the position (or take one matrix per object far apart). Only during\n * `render`.\n */\n matrixAt(lonLat: LonLat, altitude?: number): Float32Array;\n /** The camera of the frame */\n readonly camera: Camera;\n}\n\n/**\n * A layer drawn by the page with its own WebGL code, as MapLibre's `CustomLayerInterface`: `render` is called at the\n * layer's place in every frame drawn. It starts with the canvas bound, its viewport set, blending on (`SRC_ALPHA`,\n * `ONE_MINUS_SRC_ALPHA`), no culling, and in `'3d'` mode the depth test on (`LEQUAL`, depth written): the relief, the\n * buildings and the 3D Tiles hide what it draws and what it draws hides them. Whatever WebGL state it changes is set\n * back afterwards; a library that caches the WebGL state (three.js) must forget it first (`renderer.resetState()`).\n *\n * The map is busy drawing meanwhile: `render` reads the frame, not the map (`getCamera` excepted); it may call\n * `requestRender` for an animation.\n */\nexport interface CustomLayerInterface {\n /** A name for the application (the map numbers its layers) */\n id?: string;\n /** `'2d'` (the default): drawn over what is under it; `'3d'`: with the depth buffer of the 3D layers */\n renderingMode?: '2d' | '3d';\n /** Creates the WebGL objects: once added, and again after the WebGL context was lost and restored */\n onAdd?(gl: WebGL2RenderingContext, map: GeoMap): void;\n render(gl: WebGL2RenderingContext, frame: CustomFrame): void;\n /** Frees the WebGL objects: the layer is removed, or the map destroyed */\n onRemove?(gl: WebGL2RenderingContext, map: GeoMap): void;\n}\n\n/** The model-view-projection of a local frame in the engine running the map (`Engine.customMatrix`) */\n/** @internal */\nexport type CustomMatrix = (lon: number, lat: number, altitude: number) => Float32Array | undefined;\n\n/** A layer drawn by the page's WebGL code (see `CustomLayerInterface`) */\nexport class CustomLayer extends Layer {\n /** The map's WebGL context, and whether `onAdd` made the layer's objects there (until `onRemove`) */\n private readonly gl: WebGL2RenderingContext;\n private added = false;\n /** The context was lost since `onAdd`: its objects are gone */\n private stale = false;\n private readonly lost = () => {\n this.stale = true;\n };\n private readonly frame: CustomFrame;\n\n /** @internal */\n constructor(\n map: LayerHost,\n /** The application's object */\n readonly implementation: CustomLayerInterface,\n private readonly canvas: HTMLCanvasElement,\n private readonly owner: GeoMap,\n matrix: CustomMatrix,\n camera: () => Camera,\n ) {\n super(map);\n // The context the engine made on the canvas\n this.gl = canvas.getContext('webgl2') as WebGL2RenderingContext;\n this.frame = {\n matrixAt: ([lon, lat], altitude = 0) => {\n const m = matrix(lon, lat, altitude);\n if (!m) throw new Error('isard: frame.matrixAt is only available during render');\n return m;\n },\n get camera() {\n return camera();\n },\n };\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n // Once, and again on a context restored (not when the map moves onto another engine: the same context)\n if (!this.added || this.stale) {\n if (!this.added) this.canvas.addEventListener('webglcontextlost', this.lost);\n this.added = true;\n this.stale = false;\n this.implementation.onAdd?.(this.gl, this.owner);\n }\n return engine.addCustomLayer(this.draw, this.implementation.renderingMode === '3d');\n }\n\n /** Called by the engine at the layer's place in the frame; the page's errors are reported, the frame goes on */\n private readonly draw = (): void => {\n try {\n this.implementation.render(this.gl, this.frame);\n } catch (error) {\n report(error);\n }\n };\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal The layer is removed or the map destroyed: `onRemove`, unless the context is lost */\n override dispose(): void {\n if (!this.added) return;\n this.added = false;\n this.canvas.removeEventListener('webglcontextlost', this.lost);\n if (this.stale) return;\n try {\n this.implementation.onRemove?.(this.gl, this.owner);\n } catch (error) {\n report(error);\n }\n }\n}\n\n/** Where and how a model stands */\nexport interface ModelInstance {\n lonLat: LonLat;\n /** Metres above the ground (or above the ellipsoid, `altitudeReference: 'sea'`); 0 by default */\n altitude?: number;\n /** Degrees clockwise from the north of the model's front (glTF +Z); 0 by default */\n heading?: number;\n /** Degrees, nose up */\n pitch?: number;\n /** Degrees, right side down */\n roll?: number;\n /** 1 by default: the model's metres */\n scale?: number;\n}\n\nexport interface ModelOptions {\n /** URL of a glTF binary (`.glb`): meshes, textures, Draco, meshopt, KTX2, as in 3D Tiles; or its bytes (`data`) */\n url?: string;\n data?: ArrayBuffer | ArrayBufferView<ArrayBuffer>;\n instances: readonly ModelInstance[];\n /** What the altitudes are above: `'ground'` (the relief, the default) or `'sea'` (the ellipsoid) */\n altitudeReference?: 'ground' | 'sea';\n}\n\n/** The numbers of instances for the engine: longitude, latitude, altitude, heading, pitch, roll, scale */\nexport function instanceNumbers(instances: readonly ModelInstance[]): Float64Array {\n const out = new Float64Array(instances.length * 7);\n instances.forEach(({ lonLat, altitude = 0, heading = 0, pitch = 0, roll = 0, scale = 1 }, i) => {\n out.set([lonLat[0], lonLat[1], altitude, heading, pitch, roll, scale], i * 7);\n });\n return out;\n}\n\n/** A glTF model drawn at positions, in one instanced draw; `pickFeature` gives the instance's index */\nexport class ModelLayer extends Layer {\n private readonly url: string;\n /** The `blob:` URL of the page's bytes, revoked once the layer is gone */\n private readonly blob: string | undefined;\n private instances: Float64Array;\n private ground: boolean;\n\n /** @internal */\n constructor(map: LayerHost, options: ModelOptions) {\n super(map);\n const { url, data } = options;\n if (data) {\n this.blob = URL.createObjectURL(new Blob([data], { type: 'model/gltf-binary' }));\n this.url = this.blob;\n } else if (url) {\n // Against the page: the decoding workers fetch it, and a relative URL would be theirs\n const base = typeof document === 'undefined' ? undefined : document.baseURI;\n this.url = base ? new URL(url, base).href : url;\n } else {\n throw new Error('isard: a model needs a url or data');\n }\n this.instances = instanceNumbers(options.instances);\n this.ground = options.altitudeReference !== 'sea';\n }\n\n /** @internal The engine with 3D Tiles decodes and draws the models */\n override get needsFullEngine(): boolean {\n return true;\n }\n\n /** Replaces the instances (and what their altitudes are above, kept if not given) */\n setInstances(instances: readonly ModelInstance[], altitudeReference?: 'ground' | 'sea'): void {\n this.instances = instanceNumbers(instances);\n if (altitudeReference) this.ground = altitudeReference === 'ground';\n // Kept for its creation while the engine with 3D Tiles loads\n if (this.id < 0) return;\n this.map.engine.setModelInstances(this.id, this.instances, this.ground);\n this.map.requestRender();\n }\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal */\n override dispose(): void {\n if (this.blob) URL.revokeObjectURL(this.blob);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n return engine.addModels(this.url, this.instances, this.ground);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"layers.js","sourceRoot":"","sources":["../../src/layers/layers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAUrC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAElE,OAAO,EAAgB,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,OAAgB,KAAK;IACzB,GAAG,GAAG,CAAC,CAAC,CAAC;IAET,gBAAgB;IACG,GAAG,CAAY;IAElC,gBAAgB;IAChB,YAAY,GAAc;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,oCAAoC;IACpC,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,MAAM,CAA4B;IAElC;iFAC6E;IAC7E,IAAI,KAAK;QACP,IAAI,CAAC,MAAM,KAAK,CAAC,KAAK,IAAI,EAAE;YAC1B;gBAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;mBACtB,IAAI,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,eAAe,EAAE;QAC/C,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,wGAAwG;IACxG,MAAM,CAAC,MAAc;QACnB,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACd,IAAI,CA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AAE,OAAO;QACxB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACxE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAC3B,CAAC;IAEQ,MAAM;QACb,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,gBAAgB;IACP,OAAO;QACd,IAAI,IAAI,CAAC,IAAI;YAAE,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,gBAAgB;IACN,MAAM,CAAC,MAAc;QAC7B,OAAO,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACjE,CAAC;CACF","sourcesContent":["/**\n * Handles of the layers added to a map. Each one keeps what it needs to be created again: after a WebGL context loss,\n * the map recreates its engine and every layer in order, with the same handle (its id is updated). Also the page's\n * own 3D content: custom layers (its WebGL code called in every frame) and glTF models drawn at positions.\n */\n\nimport type { GeoMap } from '../map.ts';\nimport { rgb } from '../settings.ts';\nimport type {\n LayerHost,\n LonLat,\n NetworkOptions,\n NetworkStyle,\n RasterOptions,\n RasterStyle,\n Tiles3dStyle,\n} from '../types.ts';\nimport { mercatorX, mercatorY, toMercator } from '../util/geo.ts';\nimport type { Camera, Engine, NetworkStats, Tiles3dStats } from '../wasm/isard.js';\nimport { type Feature, parseColor, rampTexels, stops } from './features.ts';\n\nexport abstract class Layer {\n #id = -1;\n\n /** @internal */\n protected readonly map: LayerHost;\n\n /** @internal */\n constructor(map: LayerHost) {\n this.map = map;\n }\n\n /** Id of the layer in the engine */\n get id(): number {\n return this.#id;\n }\n\n #ready: Promise<void> | undefined;\n\n /** Resolves once the map has drawn the layer, what it shows in view loaded (the map idle after it was added; a\n * layer waiting for the engine with 3D Tiles, once that one has drawn it) */\n get ready(): Promise<void> {\n this.#ready ??= (async () => {\n do await this.map.whenIdle();\n while (this.#id < 0 && this.needsFullEngine);\n })();\n\n return this.#ready;\n }\n\n /** @internal Creates the layer in an engine (again after a context loss); its id is -1 if that fails */\n attach(engine: Engine): void {\n this.#id = -1;\n this.#id = this.create(engine);\n }\n\n /** @internal Forgets its id in an engine that is gone (before the layers are created in a new one) */\n forgetEngine(): void {\n this.#id = -1;\n }\n\n /** @internal Sends what refers to other layers, once every layer of a new engine has its id */\n relink(_engine: Engine): void {}\n\n /** @internal Drawn by the engine with 3D Tiles only (3D Tiles, models): on the core engine, it waits for that one */\n get needsFullEngine(): boolean {\n return false;\n }\n\n /** @internal The layer is removed or its map destroyed: frees what it holds outside the engine */\n dispose(): void {}\n\n /** @internal */\n protected abstract create(engine: Engine): number;\n\n remove(): void {\n // Not created yet: a 3D Tiles layer or a model waiting for the engine with 3D Tiles\n if (this.#id >= 0) this.map.engine.removeLayer(this.#id);\n this.#id = -1;\n this.map.detach(this);\n this.map.requestRender();\n }\n\n /** Moves the layer under `other`, or on top of every layer (above the labels of a vector basemap too) */\n moveBefore(other: Layer | undefined): void {\n this.map.moveLayer(this, other);\n }\n}\n\n/** Raster tiles (basemaps, overlays) */\nexport class RasterLayer extends Layer {\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly options: Required<Omit<RasterOptions, 'size' | 'loader' | 'grid' | 'attribution'>> & {\n size: number | undefined;\n loader: RasterOptions['loader'] | undefined;\n },\n ) {\n super(map);\n }\n\n /** Changes the opacity or saturation, the other kept */\n setStyle(style: Partial<RasterStyle>): void {\n this.options.opacity = style.opacity ?? this.options.opacity;\n this.options.saturation = style.saturation ?? this.options.saturation;\n this.map.engine.setRasterStyle(this.id, this.options.opacity, this.options.saturation);\n this.map.requestRender();\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const { url, minZoom, maxZoom, opacity, saturation, size, loader } = this.options;\n\n return engine.addRaster(url, minZoom, maxZoom, opacity, saturation, size, loader);\n }\n}\n\n/** Line network colored by a value per node (travel time, water depth…) */\nexport class NetworkLayer extends Layer {\n private values: Float32Array | undefined;\n /** Node and line positions in Mercator, kept for a context loss: f32 offsets from an origin (exact to the centimetre\n * across a region, half the memory of f64) */\n private kept: { origin: [number, number]; nodes: Float32Array; lines: Float32Array | undefined } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n private geometry: { nodes: Float64Array; edges: Uint32Array; lines: NetworkOptions['lines'] | undefined },\n private costs: Float32Array | undefined,\n private style: NetworkStyle,\n private edgeWidths: Float32Array | undefined,\n ) {\n super(map);\n }\n\n /** One value per node, in node order; negative (or 1e30 and above) = unreached. Costs one texture upload, drawn\n * next frame. */\n setValues(values: Float32Array): void {\n this.values = values;\n this.map.engine.setNetworkValues(this.id, values);\n this.map.requestRender();\n }\n\n /** Costs of the edges, A → B then B → A (see `NetworkOptions.costs`), when the way the network is travelled\n * changes; undefined: values interpolated along the edges. The geometry stays on the graphics card. */\n setCosts(costs: Float32Array | undefined): void {\n this.costs = costs;\n this.map.engine.setNetworkCosts(this.id, costs);\n this.map.requestRender();\n }\n\n setStyle(style: Partial<NetworkStyle>): void {\n const ramp = this.style.ramp;\n\n this.style = { ...this.style, ...style };\n this.map.engine.setNetworkStyle(this.id, networkStyle(this.style));\n if (this.style.ramp !== ramp)\n this.map.engine.setNetworkRamp(this.id, this.style.ramp && rampTexels(this.style.ramp).rgba);\n this.map.requestRender();\n }\n\n /** Width factor of each edge (undefined: 1 for all) */\n setEdgeWidths(widths: Float32Array | undefined): void {\n this.edgeWidths = widths;\n this.map.engine.setNetworkScales(this.id, widths);\n this.map.requestRender();\n }\n\n /** Pieces in all and drawn in the last frame */\n stats(): NetworkStats | undefined {\n return this.map.engine.networkStats(this.id);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const { nodes, edges, lines } = this.geometry;\n const mercator = ((): { nodes: Float64Array; lines: Float64Array | undefined } => {\n if (this.kept) {\n const { origin, nodes: n, lines: l } = this.kept;\n\n return { nodes: unpack(n, origin), lines: l && unpack(l, origin) };\n }\n\n // Mercator here: Math.tan and Math.log run natively, several times faster than in WebAssembly\n const projected = { nodes: mercatorPoints(nodes), lines: lines && mercatorPoints(lines.points) };\n const origin: [number, number] = [projected.nodes[0] ?? 0, projected.nodes[1] ?? 0];\n\n this.kept = {\n origin,\n nodes: pack(projected.nodes, origin),\n lines: projected.lines && pack(projected.lines, origin),\n };\n // The degrees are not needed again: millions of points for a region\n this.geometry = { nodes: EMPTY, edges, lines: lines && { start: lines.start, points: EMPTY } };\n\n return projected;\n })();\n const id = engine.addNetwork(\n mercator.nodes,\n edges,\n lines?.start,\n mercator.lines,\n this.costs,\n networkStyle(this.style),\n );\n\n if (this.style.ramp) engine.setNetworkRamp(id, rampTexels(this.style.ramp).rgba);\n if (this.edgeWidths) engine.setNetworkScales(id, this.edgeWidths);\n if (this.values) engine.setNetworkValues(id, this.values);\n\n return id;\n }\n}\n\n/** The 25 numbers of a network style for the engine */\nconst networkStyle = (style: NetworkStyle): Float32Array => {\n const { width, halo, max, contour, opacity, haloOpacity, unreachedColor, fade } = style;\n\n return Float32Array.from([\n ...stops(width),\n ...stops(halo),\n max,\n contour,\n opacity,\n haloOpacity,\n ...parseColor(unreachedColor),\n fade,\n ]);\n};\n\nconst EMPTY = new Float64Array(0);\n\n/** Interleaved points as f32 offsets from an origin, and back */\nconst pack = (points: Float64Array, [ox, oy]: [number, number]): Float32Array => {\n const out = new Float32Array(points.length);\n\n for (let i = 0; i < points.length; i += 2) {\n out[i] = (points[i] ?? 0) - ox;\n out[i + 1] = (points[i + 1] ?? 0) - oy;\n }\n\n return out;\n};\n\nconst unpack = (points: Float32Array, [ox, oy]: [number, number]): Float64Array => {\n const out = new Float64Array(points.length);\n\n for (let i = 0; i < points.length; i += 2) {\n out[i] = (points[i] ?? 0) + ox;\n out[i + 1] = (points[i + 1] ?? 0) + oy;\n }\n\n return out;\n};\n\n/** Longitudes and latitudes (degrees, interleaved) to Mercator [0, 1], y towards the south */\nconst mercatorPoints = (lonLat: Float64Array): Float64Array => {\n const out = new Float64Array(lonLat.length);\n\n for (let i = 0; i < lonLat.length; i += 2) {\n out[i] = mercatorX(lonLat[i] ?? 0);\n out[i + 1] = mercatorY(lonLat[i + 1] ?? 0);\n }\n\n return out;\n};\n\n/** Textured meshes in 3D Tiles */\nexport class Tiles3dLayer extends Layer {\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly url: string,\n private readonly geoid: boolean,\n private style: Tiles3dStyle,\n ) {\n super(map);\n }\n\n setStyle(style: Partial<Tiles3dStyle>): void {\n this.style = { ...this.style, ...style };\n // Kept for its creation while the engine with 3D Tiles loads\n if (this.id < 0) return;\n this.applyStyle(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** @internal */\n override get needsFullEngine(): boolean {\n return true;\n }\n\n /** @internal The feature picked (`pickFeature`, 'hoverfeature'): the properties of its feature in the tile\n * (`EXT_structural_metadata`, a b3dm batch table), none for a mesh without features; its index in the tile as id */\n featureAt(index: number): Feature<Record<string, unknown>> | undefined {\n if (this.id < 0) return undefined;\n\n const hit = this.map.engine.tiles3dFeature(this.id, index);\n\n if (!hit) return undefined;\n\n const [properties, feature] = hit;\n\n return { type: 'Feature', id: feature, properties: properties ?? {}, geometry: null };\n }\n\n /** Loading counters; undefined once the layer is removed, and while the engine with 3D Tiles loads (see\n * `GeoMapOptions.tiles3d`) */\n stats(): Tiles3dStats | undefined {\n return this.id < 0 ? undefined : this.map.engine.tiles3dStats(this.id);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addTiles3d(this.url, this.style.maxScreenSpaceError, this.geoid);\n\n this.applyStyle(engine, id);\n\n return id;\n }\n\n private applyStyle(engine: Engine, id: number): void {\n const { maxScreenSpaceError, opacity, pointSize, color } = this.style;\n\n engine.setTiles3dStyle(id, maxScreenSpaceError, opacity, pointSize, new Float32Array(color ? rgb(color) : []));\n }\n}\n\n/** A texture of a ground layer (see `GroundLayer`) */\nexport interface GroundTexture {\n /** `r8`, `r8ui`, `r16ui`, `r16i`, `r32ui`, `r32f`, `rg16ui`, `rg32f`, `rgba8`, `rgba8ui`, `rgba16ui`, `rgba32f`:\n * integer formats are read with `usampler2D` / `isampler2D` and `texelFetch` */\n format: string;\n width: number;\n height: number;\n /** Layers of a 2D array (`sampler2DArray`, `usampler2DArray`…); 0 or undefined: a 2D texture */\n depth?: number;\n /** Linear filtering (non-integer formats); default nearest */\n linear?: boolean;\n /** Texels row after row (layer after layer), any typed array; undefined: left empty */\n data?: ArrayBufferView;\n}\n\nexport interface GroundOptions {\n /**\n * GLSL ES 3.0 defining `vec4 ground(vec2 offset)`: the color of the ground (premultiplied alpha, 0 for nothing) at\n * `offset`, the Mercator offset of the pixel from `anchor` (times `ISARD_CIRCUMFERENCE`: metres of EPSG:3857), exact to\n * the millimetre at any zoom. The code declares its own uniforms and samplers; also there: `u_zoom`,\n * `u_pixel_ratio`\n */\n code: string;\n /** Where the offsets are taken from */\n anchor: LonLat;\n /** Box it shows in, `[west, south, east, north]` (default the world): only the ground there is drawn again */\n bounds?: [west: number, south: number, east: number, north: number];\n textures?: Record<string, GroundTexture>;\n uniforms?: Record<string, number | readonly number[]>;\n}\n\nconst bytesOf = (data: ArrayBufferView) => new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n\n/** The application's fragment shader run over the ground, draped on the relief (water depth, heat maps…) */\nexport class GroundLayer extends Layer {\n private readonly textures = new Map<string, GroundTexture>();\n private readonly uniforms = new Map<string, number[]>();\n private visible = true;\n\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly options: GroundOptions,\n ) {\n super(map);\n Object.entries(options.textures ?? {}).forEach(([name, texture]) => {\n this.textures.set(name, texture);\n });\n Object.entries(options.uniforms ?? {}).forEach(([name, value]) => {\n this.uniforms.set(name, [value].flat());\n });\n }\n\n /** Creates or replaces a texture of the code's sampler `name` */\n setTexture(name: string, texture: GroundTexture): void {\n this.textures.set(name, texture);\n this.sendTexture(this.map.engine, this.id, name, texture);\n this.map.requestRender();\n }\n\n /**\n * Replaces a region of a texture: `data` holds `width` × `height` texels for (`x`, `y`) of `layer` (2D arrays).\n * Keep the texture's own `data` up to date too if it must survive a WebGL context loss.\n */\n updateTexture(\n name: string,\n data: ArrayBufferView,\n region: { x?: number; y?: number; layer?: number; width: number; height: number },\n ): void {\n const { x = 0, y = 0, layer = 0, width, height } = region;\n\n this.map.engine.updateGroundTexture(this.id, name, x, y, layer, width, height, bytesOf(data));\n this.map.requestRender();\n }\n\n /** A uniform of the code: a number, or numbers for vectors, arrays and matrices (column major) */\n setUniform(name: string, value: number | readonly number[]): void {\n const values = [value].flat();\n\n this.uniforms.set(name, values);\n this.map.engine.setGroundUniform(this.id, name, Float64Array.from(values));\n this.map.requestRender();\n }\n\n setBounds(bounds: [west: number, south: number, east: number, north: number]): void {\n this.options.bounds = bounds;\n this.map.engine.setGroundBounds(this.id, ...mercatorBox(bounds));\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.visible = visible;\n this.map.engine.setGroundVisible(this.id, visible);\n this.map.requestRender();\n }\n\n private sendTexture(engine: Engine, id: number, name: string, t: GroundTexture): void {\n const data = t.data && bytesOf(t.data);\n\n engine.setGroundTexture(id, name, t.format, t.width, t.height, t.depth ?? 0, t.linear ?? false, data);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const [ax, ay] = toMercator(this.options.anchor);\n const id = engine.addGround(\n this.options.code,\n ax,\n ay,\n ...mercatorBox(this.options.bounds ?? [-180, -85.06, 180, 85.06]),\n );\n\n this.textures.forEach((texture, name) => {\n this.sendTexture(engine, id, name, texture);\n });\n this.uniforms.forEach((values, name) => {\n engine.setGroundUniform(id, name, Float64Array.from(values));\n });\n engine.setGroundVisible(id, this.visible);\n\n return id;\n }\n}\n\n/** A lon/lat box to Mercator min x, min y, max x, max y (y towards the south) */\nconst mercatorBox = ([west, south, east, north]: [number, number, number, number]): [\n number,\n number,\n number,\n number,\n] => {\n const [x0, y1] = toMercator([west, south]);\n const [x1, y0] = toMercator([east, north]);\n\n return [x0, y0, x1, y1];\n};\n\n// ── The page's own 3D content: custom layers, glTF models ──\n\n/** Reports an error of the page without throwing it here: the console shows it, as an uncaught one */\nconst report = (error: unknown): void => {\n if (typeof reportError === 'function') reportError(error);\n else\n queueMicrotask(() => {\n throw error;\n });\n};\n\n/** What a custom layer gets to draw a frame (`CustomLayerInterface.render`) */\nexport interface CustomFrame {\n /**\n * The model-view-projection matrix of a local frame at a position and altitude (metres above the ellipsoid, as the\n * relief is drawn: times its exaggeration), column-major for `uniformMatrix4fv` or a three.js camera: x east, y\n * north, z up, in metres. Made in double precision relative to the camera, so that what is drawn stays exact at\n * any zoom; draw within a few kilometres of the position (or take one matrix per object far apart). Only during\n * `render`.\n */\n matrixAt(lonLat: LonLat, altitude?: number): Float32Array;\n /** The camera of the frame */\n readonly camera: Camera;\n}\n\n/**\n * A layer drawn by the page with its own WebGL code, as MapLibre's `CustomLayerInterface`: `render` is called at the\n * layer's place in every frame drawn. It starts with the canvas bound, its viewport set, blending on (`SRC_ALPHA`,\n * `ONE_MINUS_SRC_ALPHA`), no culling, and in `'3d'` mode the depth test on (`LEQUAL`, depth written): the relief, the\n * buildings and the 3D Tiles hide what it draws and what it draws hides them. Whatever WebGL state it changes is set\n * back afterwards; a library that caches the WebGL state (three.js) must forget it first (`renderer.resetState()`).\n *\n * The map is busy drawing meanwhile: `render` reads the frame, not the map (`getCamera` excepted); it may call\n * `requestRender` for an animation.\n */\nexport interface CustomLayerInterface {\n /** A name for the application (the map numbers its layers) */\n id?: string;\n /** `'2d'` (the default): drawn over what is under it; `'3d'`: with the depth buffer of the 3D layers */\n renderingMode?: '2d' | '3d';\n /** Creates the WebGL objects: once added, and again after the WebGL context was lost and restored */\n onAdd?(gl: WebGL2RenderingContext, map: GeoMap): void;\n render(gl: WebGL2RenderingContext, frame: CustomFrame): void;\n /** Frees the WebGL objects: the layer is removed, or the map destroyed */\n onRemove?(gl: WebGL2RenderingContext, map: GeoMap): void;\n}\n\n/** The model-view-projection of a local frame in the engine running the map (`Engine.customMatrix`) */\n/** @internal */\nexport type CustomMatrix = (lon: number, lat: number, altitude: number) => Float32Array | undefined;\n\n/** A layer drawn by the page's WebGL code (see `CustomLayerInterface`) */\nexport class CustomLayer extends Layer {\n /** The map's WebGL context, and whether `onAdd` made the layer's objects there (until `onRemove`) */\n private readonly gl: WebGL2RenderingContext;\n private added = false;\n /** The context was lost since `onAdd`: its objects are gone */\n private stale = false;\n private readonly lost = () => {\n this.stale = true;\n };\n private readonly frame: CustomFrame;\n\n /** @internal */\n constructor(\n map: LayerHost,\n /** The application's object */\n readonly implementation: CustomLayerInterface,\n private readonly canvas: HTMLCanvasElement,\n private readonly owner: GeoMap,\n matrix: CustomMatrix,\n camera: () => Camera,\n ) {\n super(map);\n // The context the engine made on the canvas\n this.gl = canvas.getContext('webgl2') as WebGL2RenderingContext;\n this.frame = {\n matrixAt: ([lon, lat], altitude = 0) => {\n const m = matrix(lon, lat, altitude);\n\n if (!m) throw new Error('isard: frame.matrixAt is only available during render');\n\n return m;\n },\n get camera() {\n return camera();\n },\n };\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n // Once, and again on a context restored (not when the map moves onto another engine: the same context)\n if (!this.added || this.stale) {\n if (!this.added) this.canvas.addEventListener('webglcontextlost', this.lost);\n this.added = true;\n this.stale = false;\n this.implementation.onAdd?.(this.gl, this.owner);\n }\n\n return engine.addCustomLayer(this.draw, this.implementation.renderingMode === '3d');\n }\n\n /** Called by the engine at the layer's place in the frame; the page's errors are reported, the frame goes on */\n private readonly draw = (): void => {\n try {\n this.implementation.render(this.gl, this.frame);\n } catch (error) {\n report(error);\n }\n };\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal The layer is removed or the map destroyed: `onRemove`, unless the context is lost */\n override dispose(): void {\n if (!this.added) return;\n this.added = false;\n this.canvas.removeEventListener('webglcontextlost', this.lost);\n if (this.stale) return;\n try {\n this.implementation.onRemove?.(this.gl, this.owner);\n } catch (error) {\n report(error);\n }\n }\n}\n\n/** Where and how a model stands */\nexport interface ModelInstance {\n lonLat: LonLat;\n /** Metres above the ground (or above the ellipsoid, `altitudeReference: 'sea'`); 0 by default */\n altitude?: number;\n /** Degrees clockwise from the north of the model's front (glTF +Z); 0 by default */\n heading?: number;\n /** Degrees, nose up */\n pitch?: number;\n /** Degrees, right side down */\n roll?: number;\n /** 1 by default: the model's metres */\n scale?: number;\n}\n\nexport interface ModelOptions {\n /** URL of a glTF binary (`.glb`): meshes, textures, Draco, meshopt, KTX2, as in 3D Tiles; or its bytes (`data`) */\n url?: string;\n data?: ArrayBuffer | ArrayBufferView<ArrayBuffer>;\n instances: readonly ModelInstance[];\n /** What the altitudes are above: `'ground'` (the relief, the default) or `'sea'` (the ellipsoid) */\n altitudeReference?: 'ground' | 'sea';\n}\n\n/** The numbers of instances for the engine: longitude, latitude, altitude, heading, pitch, roll, scale */\nexport const instanceNumbers = (instances: readonly ModelInstance[]): Float64Array => {\n const out = new Float64Array(instances.length * 7);\n\n instances.forEach(({ lonLat, altitude = 0, heading = 0, pitch = 0, roll = 0, scale = 1 }, i) => {\n out.set([lonLat[0], lonLat[1], altitude, heading, pitch, roll, scale], i * 7);\n });\n\n return out;\n};\n\n/** A glTF model drawn at positions, in one instanced draw; `pickFeature` gives the instance's index */\nexport class ModelLayer extends Layer {\n private readonly url: string;\n /** The `blob:` URL of the page's bytes, revoked once the layer is gone */\n private readonly blob: string | undefined;\n private instances: Float64Array;\n private ground: boolean;\n\n /** @internal */\n constructor(map: LayerHost, options: ModelOptions) {\n super(map);\n\n const { url, data } = options;\n\n if (data) {\n this.blob = URL.createObjectURL(new Blob([data], { type: 'model/gltf-binary' }));\n this.url = this.blob;\n } else if (url) {\n // Against the page: the decoding workers fetch it, and a relative URL would be theirs\n const base = typeof document === 'undefined' ? undefined : document.baseURI;\n\n this.url = base ? new URL(url, base).href : url;\n } else {\n throw new Error('isard: a model needs a url or data');\n }\n this.instances = instanceNumbers(options.instances);\n this.ground = options.altitudeReference !== 'sea';\n }\n\n /** @internal The engine with 3D Tiles decodes and draws the models */\n override get needsFullEngine(): boolean {\n return true;\n }\n\n /** Replaces the instances (and what their altitudes are above, kept if not given) */\n setInstances(instances: readonly ModelInstance[], altitudeReference?: 'ground' | 'sea'): void {\n this.instances = instanceNumbers(instances);\n if (altitudeReference) this.ground = altitudeReference === 'ground';\n // Kept for its creation while the engine with 3D Tiles loads\n if (this.id < 0) return;\n this.map.engine.setModelInstances(this.id, this.instances, this.ground);\n this.map.requestRender();\n }\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal */\n override dispose(): void {\n if (this.blob) URL.revokeObjectURL(this.blob);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n return engine.addModels(this.url, this.instances, this.ground);\n }\n}\n"]}
|
|
@@ -50,7 +50,7 @@ interface Attitude {
|
|
|
50
50
|
* `quaternionFromRollPitchHeading`: Ry(-roll) · Rx(-pitch) · Rz(-heading)), turned by the meridian convergence of the
|
|
51
51
|
* projection (Lambert-93: sin(46.5°) · (3° - longitude))
|
|
52
52
|
*/
|
|
53
|
-
export declare
|
|
53
|
+
export declare const panoramaRotation: (attitude: Attitude, lon: number, lambert93: boolean) => number[];
|
|
54
54
|
/** The panoramas of a set, one shown at a time */
|
|
55
55
|
export declare class Panoramas {
|
|
56
56
|
private readonly host;
|
|
@@ -90,5 +90,5 @@ export declare class Panoramas {
|
|
|
90
90
|
exit(): void;
|
|
91
91
|
}
|
|
92
92
|
/** Loads a set of panoramas: their positions and attitudes, the calibration of their cameras */
|
|
93
|
-
export declare
|
|
93
|
+
export declare const loadPanoramas: (host: PanoramaHost, options: PanoramaOptions) => Promise<Panoramas>;
|
|
94
94
|
export {};
|