isard 1.6.0 → 1.8.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.
Files changed (131) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/dist/basemap/furniture.d.ts +20 -2
  3. package/dist/basemap/furniture.js +72 -3
  4. package/dist/basemap/furniture.js.map +1 -1
  5. package/dist/basemap/meshes.d.ts +21 -0
  6. package/dist/basemap/meshes.js +159 -0
  7. package/dist/basemap/meshes.js.map +1 -0
  8. package/dist/basemap/placed.d.ts +13 -0
  9. package/dist/basemap/placed.js +14 -0
  10. package/dist/basemap/placed.js.map +1 -0
  11. package/dist/basemap/trees.d.ts +4 -14
  12. package/dist/basemap/trees.js +12 -93
  13. package/dist/basemap/trees.js.map +1 -1
  14. package/dist/basemap/vectortiles/context.d.ts +4 -2
  15. package/dist/basemap/vectortiles/context.js.map +1 -1
  16. package/dist/basemap/vectortiles/extrusions.d.ts +1 -1
  17. package/dist/basemap/vectortiles/extrusions.js +7 -16
  18. package/dist/basemap/vectortiles/extrusions.js.map +1 -1
  19. package/dist/basemap/vectortiles/furniture.d.ts +19 -0
  20. package/dist/basemap/vectortiles/furniture.js +29 -0
  21. package/dist/basemap/vectortiles/furniture.js.map +1 -0
  22. package/dist/basemap/vectortiles/labels.js +8 -1
  23. package/dist/basemap/vectortiles/labels.js.map +1 -1
  24. package/dist/basemap/vectortiles/lamps.js +11 -76
  25. package/dist/basemap/vectortiles/lamps.js.map +1 -1
  26. package/dist/basemap/vectortiles/placed.d.ts +38 -0
  27. package/dist/basemap/vectortiles/placed.js +143 -0
  28. package/dist/basemap/vectortiles/placed.js.map +1 -0
  29. package/dist/basemap/vectortiles/street-wind.js +4 -6
  30. package/dist/basemap/vectortiles/street-wind.js.map +1 -1
  31. package/dist/basemap/vectortiles/trees.d.ts +2 -9
  32. package/dist/basemap/vectortiles/trees.js +34 -165
  33. package/dist/basemap/vectortiles/trees.js.map +1 -1
  34. package/dist/basemap/vectortiles/vectors.d.ts +4 -5
  35. package/dist/basemap/vectortiles/vectors.js +17 -16
  36. package/dist/basemap/vectortiles/vectors.js.map +1 -1
  37. package/dist/basemap/vectortiles.d.ts +14 -4
  38. package/dist/basemap/vectortiles.js +40 -12
  39. package/dist/basemap/vectortiles.js.map +1 -1
  40. package/dist/basemap/wmts.js +2 -2
  41. package/dist/basemap/wmts.js.map +1 -1
  42. package/dist/basemap.worker.js +2 -2
  43. package/dist/basemap.worker.js.map +18 -14
  44. package/dist/bind/layers.d.ts +10 -3
  45. package/dist/bind/layers.js +11 -4
  46. package/dist/bind/layers.js.map +1 -1
  47. package/dist/data/collada.js +3 -17
  48. package/dist/data/collada.js.map +1 -1
  49. package/dist/data/crs.js +1 -1
  50. package/dist/data/crs.js.map +1 -1
  51. package/dist/data/ifc.js +21 -22
  52. package/dist/data/ifc.js.map +1 -1
  53. package/dist/geoplateforme.d.ts +16 -4
  54. package/dist/geoplateforme.js +26 -4
  55. package/dist/geoplateforme.js.map +1 -1
  56. package/dist/index.d.ts +5 -4
  57. package/dist/index.js +3 -3
  58. package/dist/index.js.map +1 -1
  59. package/dist/isard_bg.wasm +0 -0
  60. package/dist/isard_core_bg.wasm +0 -0
  61. package/dist/isard_grid_bg.wasm +0 -0
  62. package/dist/isard_tess_bg.wasm +0 -0
  63. package/dist/layers/extrusions.js +5 -4
  64. package/dist/layers/extrusions.js.map +1 -1
  65. package/dist/layers/features.d.ts +0 -2
  66. package/dist/layers/features.js +5 -6
  67. package/dist/layers/features.js.map +1 -1
  68. package/dist/layers/layers.d.ts +2 -0
  69. package/dist/layers/layers.js +11 -0
  70. package/dist/layers/layers.js.map +1 -1
  71. package/dist/layers/panoramas.d.ts +32 -10
  72. package/dist/layers/panoramas.js +55 -28
  73. package/dist/layers/panoramas.js.map +1 -1
  74. package/dist/layers/photos.js +5 -6
  75. package/dist/layers/photos.js.map +1 -1
  76. package/dist/layers/trees.js +7 -7
  77. package/dist/layers/trees.js.map +1 -1
  78. package/dist/layers/vectors.d.ts +1 -0
  79. package/dist/layers/vectors.js +23 -8
  80. package/dist/layers/vectors.js.map +1 -1
  81. package/dist/map/frame-loop.d.ts +2 -0
  82. package/dist/map/frame-loop.js +3 -3
  83. package/dist/map/frame-loop.js.map +1 -1
  84. package/dist/map.js +17 -0
  85. package/dist/map.js.map +1 -1
  86. package/dist/panoramax.d.ts +19 -0
  87. package/dist/panoramax.js +48 -3
  88. package/dist/panoramax.js.map +1 -1
  89. package/dist/react/CustomLayer.js +5 -4
  90. package/dist/react/CustomLayer.js.map +1 -1
  91. package/dist/react/Layer.d.ts +1 -1
  92. package/dist/react/Layer.js +6 -5
  93. package/dist/react/Layer.js.map +1 -1
  94. package/dist/react/VectorGeometry.d.ts +18 -9
  95. package/dist/react/VectorGeometry.js +30 -15
  96. package/dist/react/VectorGeometry.js.map +1 -1
  97. package/dist/react/VectorTiles.d.ts +65 -0
  98. package/dist/react/VectorTiles.js +112 -0
  99. package/dist/react/VectorTiles.js.map +1 -0
  100. package/dist/react/context.d.ts +12 -0
  101. package/dist/react/context.js +40 -1
  102. package/dist/react/context.js.map +1 -1
  103. package/dist/react/index.d.ts +7 -1
  104. package/dist/react/index.js +7 -1
  105. package/dist/react/index.js.map +1 -1
  106. package/dist/types.d.ts +2 -0
  107. package/dist/types.js.map +1 -1
  108. package/dist/util/geo.d.ts +8 -0
  109. package/dist/util/geo.js +8 -0
  110. package/dist/util/geo.js.map +1 -1
  111. package/dist/util/gltf.d.ts +18 -1
  112. package/dist/util/gltf.js +26 -1
  113. package/dist/util/gltf.js.map +1 -1
  114. package/dist/util/roofs.d.ts +8 -0
  115. package/dist/util/roofs.js +16 -2
  116. package/dist/util/roofs.js.map +1 -1
  117. package/dist/util/style-floats.d.ts +33 -0
  118. package/dist/util/style-floats.js +34 -0
  119. package/dist/util/style-floats.js.map +1 -0
  120. package/dist/util/sun.js +1 -1
  121. package/dist/util/sun.js.map +1 -1
  122. package/dist/workers/basemap/furniture.d.ts +13 -0
  123. package/dist/workers/basemap/geometry.d.ts +2 -5
  124. package/dist/workers/basemap/labels.d.ts +5 -2
  125. package/dist/workers/basemap/lamps.d.ts +3 -3
  126. package/dist/workers/basemap/tiles.d.ts +2 -0
  127. package/dist/workers/basemap/trees.d.ts +3 -0
  128. package/dist/workers/basemap.worker.d.ts +17 -1
  129. package/dist/workers/basemap.worker.js +12 -1
  130. package/dist/workers/basemap.worker.js.map +1 -1
  131. package/package.json +1 -1
@@ -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,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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,GAAG,CAAC;YAAE,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,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnE,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEnD,OAAO,EAAE,CAAC;IACZ,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 /** @internal Layers drawn with this one, removed and moved with it (the conifers of a basemap's trees) */\n readonly companions: Layer[] = [];\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.companions.forEach((c) => {\n c.remove();\n });\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 this.companions.forEach((c) => {\n c.moveBefore(other);\n });\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 /** Its glow at night (`setGlow`) */\n private glow: { from: number; color: string } | undefined;\n /** Its feature highlighted (`setHighlight`) */\n private highlight: { feature: number; color: string } | undefined;\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 /** Lights at night the part of the model from `from` metres above its foot (a street lamp's head) in a CSS color;\n * none without a color */\n setGlow(from: number, color?: string): void {\n this.glow = color === undefined ? undefined : { from, color };\n if (this.id < 0) return;\n this.sendGlow(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Highlights a feature of the model (an IFC model's element, `hit.index` of a pick) in a CSS color (amber by\n * default); none without a feature */\n setHighlight(feature?: number, color = '#ffb000'): void {\n this.highlight = feature === undefined ? undefined : { feature, color };\n if (this.id < 0) return;\n this.sendHighlight(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n private sendHighlight(engine: Engine, id: number): void {\n const [r = 0, g = 0, b = 0] = this.highlight ? parseColor(this.highlight.color) : [];\n\n engine.setModelHighlight(id, this.highlight ? this.highlight.feature : Number.NaN, r, g, b);\n }\n\n private sendGlow(engine: Engine, id: number): void {\n const [r = 0, g = 0, b = 0] = this.glow ? parseColor(this.glow.color) : [];\n\n engine.setModelGlow(id, this.glow ? this.glow.from : Number.NaN, r, g, b);\n }\n\n /** @internal The instances as the engine takes them (`instanceNumbers`: seven numbers each), above the ground */\n setInstanceNumbers(numbers: Float64Array): void {\n this.instances = numbers;\n this.ground = true;\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 const id = engine.addModels(this.url, this.instances, this.ground);\n\n if (this.glow) this.sendGlow(engine, id);\n if (this.highlight) this.sendHighlight(engine, id);\n\n return id;\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;IA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IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnE,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEnD,OAAO,EAAE,CAAC;IACZ,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 /** @internal Layers drawn with this one, removed and moved with it (the conifers of a basemap's trees) */\n readonly companions: Layer[] = [];\n\n /** @internal What stops once the layer is removed (a vector tiles' layer following the view) */\n readonly whenRemoved: (() => void)[] = [];\n\n #removed = false;\n\n /** Whether the layer was removed (`remove`) */\n get removed(): boolean {\n return this.#removed;\n }\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.#removed = true;\n this.map.detach(this);\n this.companions.forEach((c) => {\n c.remove();\n });\n this.whenRemoved.splice(0).forEach((stop) => {\n stop();\n });\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 this.companions.forEach((c) => {\n c.moveBefore(other);\n });\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 /** Its glow at night (`setGlow`) */\n private glow: { from: number; color: string } | undefined;\n /** Its feature highlighted (`setHighlight`) */\n private highlight: { feature: number; color: string } | undefined;\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 /** Lights at night the part of the model from `from` metres above its foot (a street lamp's head) in a CSS color;\n * none without a color */\n setGlow(from: number, color?: string): void {\n this.glow = color === undefined ? undefined : { from, color };\n if (this.id < 0) return;\n this.sendGlow(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Highlights a feature of the model (an IFC model's element, `hit.index` of a pick) in a CSS color (amber by\n * default); none without a feature */\n setHighlight(feature?: number, color = '#ffb000'): void {\n this.highlight = feature === undefined ? undefined : { feature, color };\n if (this.id < 0) return;\n this.sendHighlight(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n private sendHighlight(engine: Engine, id: number): void {\n const [r = 0, g = 0, b = 0] = this.highlight ? parseColor(this.highlight.color) : [];\n\n engine.setModelHighlight(id, this.highlight ? this.highlight.feature : Number.NaN, r, g, b);\n }\n\n private sendGlow(engine: Engine, id: number): void {\n const [r = 0, g = 0, b = 0] = this.glow ? parseColor(this.glow.color) : [];\n\n engine.setModelGlow(id, this.glow ? this.glow.from : Number.NaN, r, g, b);\n }\n\n /** @internal The instances as the engine takes them (`instanceNumbers`: seven numbers each), above the ground */\n setInstanceNumbers(numbers: Float64Array): void {\n this.instances = numbers;\n this.ground = true;\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 const id = engine.addModels(this.url, this.instances, this.ground);\n\n if (this.glow) this.sendGlow(engine, id);\n if (this.highlight) this.sendHighlight(engine, id);\n\n return id;\n }\n}\n"]}
@@ -1,5 +1,28 @@
1
1
  import type { FirstPersonView, LonLat } from '../types.ts';
2
- export interface PanoramaOptions {
2
+ /** What the panoramas of either kind take */
3
+ interface PanoramaLook {
4
+ /** Radius of the sphere around the panorama its images are a backdrop on, metres (default 1000) */
5
+ backgroundDistance?: number;
6
+ /** 0-1 (default 1) */
7
+ opacity?: number;
8
+ }
9
+ /** A 360° photo (an equirectangular image): where it was taken and the way its middle faces */
10
+ export interface PanoramaPhoto {
11
+ /** Its image (JPEG, PNG), its middle the photo's `heading`, its top straight up */
12
+ url: string;
13
+ lonLat: LonLat;
14
+ /** Degrees clockwise from north of its middle (0 by default) */
15
+ heading?: number;
16
+ /** Metres of its camera above the ground (2.5 by default) */
17
+ height?: number;
18
+ id?: number | string;
19
+ }
20
+ /** 360° photos as panoramas (`photos`, in the order of their walk) */
21
+ export interface PhotoPanoramaOptions extends PanoramaLook {
22
+ photos: readonly PanoramaPhoto[];
23
+ }
24
+ /** A vehicle's calibrated cameras around each of its positions (Stereopolis) */
25
+ export interface CalibratedPanoramaOptions extends PanoramaLook {
3
26
  /** URL of an image: `{cameraId}` and `{panoId}` replaced by a camera's id and a panorama's */
4
27
  url: string;
5
28
  /** GeoJSON points: each panorama's position, and its `id`, `heading`, `pitch`, `roll` (degrees) in properties */
@@ -11,11 +34,8 @@ export interface PanoramaOptions {
11
34
  /** Altitudes above the geoid (NGF-IGN69), raised by the RAF20 geoid onto the IGN relief (default true in
12
35
  * Lambert-93) */
13
36
  geoid?: boolean;
14
- /** Radius of the sphere around the panorama its images are a backdrop on, metres (default 1000) */
15
- backgroundDistance?: number;
16
- /** 0-1 (default 1) */
17
- opacity?: number;
18
37
  }
38
+ export type PanoramaOptions = CalibratedPanoramaOptions | PhotoPanoramaOptions;
19
39
  /** A panorama: where it is and which way the vehicle faced */
20
40
  export interface Panorama {
21
41
  index: number;
@@ -51,14 +71,15 @@ interface Attitude {
51
71
  * projection (Lambert-93: sin(46.5°) · (3° - longitude))
52
72
  */
53
73
  export declare const panoramaRotation: (attitude: Attitude, lon: number, lambert93: boolean) => number[];
74
+ /** The numbers of a 360° photo's camera facing `heading` (its frame east, north, up): x right, y down, z ahead; no
75
+ * focal (the engine's sign of an equirectangular image) */
76
+ export declare const photoCamera: (heading: number) => number[];
54
77
  /** The panoramas of a set, one shown at a time */
55
78
  export declare class Panoramas {
56
79
  private readonly host;
57
- private readonly options;
80
+ private readonly look;
58
81
  readonly list: readonly Panorama[];
59
- private readonly attitudes;
60
- private readonly cameras;
61
- private readonly lambert93;
82
+ private readonly source;
62
83
  /** The panorama shown, if any */
63
84
  current: Panorama | undefined;
64
85
  private shown;
@@ -91,6 +112,7 @@ export declare class Panoramas {
91
112
  /** Ends the walk: the panorama hidden, the camera turning around a point again, above where the eye stood */
92
113
  exit(): void;
93
114
  }
94
- /** Loads a set of panoramas: their positions and attitudes, the calibration of their cameras */
115
+ /** Loads a set of panoramas: a vehicle's (their positions and attitudes, the calibration of their cameras), or 360°
116
+ * photos */
95
117
  export declare const loadPanoramas: (host: PanoramaHost, options: PanoramaOptions) => Promise<Panoramas>;
96
118
  export {};
@@ -1,9 +1,10 @@
1
1
  /**
2
- * Street-level panoramas: the oriented images of a vehicle's cameras around each of its positions (Stereopolis, the
3
- * iTowns immersive examples), projected onto the scene around the panorama shown. Their positions and attitudes come
4
- * as GeoJSON points (Lambert-93 by default, altitudes NGF-IGN69 raised by the RAF20 geoid onto the IGN relief), the
5
- * calibration of the cameras as JSON (rotation and position in the panorama frame, intrinsics, MicMac's radial
6
- * distortion), the images from a URL template with `{cameraId}` and `{panoId}`.
2
+ * Street-level panoramas projected onto the scene around the panorama shown: the oriented images of a vehicle's
3
+ * cameras around each of its positions (Stereopolis, the iTowns immersive examples: their positions and attitudes as
4
+ * GeoJSON points, Lambert-93 by default, altitudes NGF-IGN69 raised by the RAF20 geoid onto the IGN relief; the
5
+ * calibration of the cameras as JSON, rotation and position in the panorama frame, intrinsics, MicMac's radial
6
+ * distortion; the images from a URL template with `{cameraId}` and `{panoId}`), or 360° photos (`photos`: one
7
+ * equirectangular image each, where it was taken and the way its middle faces: Panoramax's).
7
8
  *
8
9
  * ```ts
9
10
  * const panoramas = await map.addPanoramas({ url, orientationsUrl, calibrationUrl });
@@ -12,6 +13,7 @@
12
13
  */
13
14
  import { getCrs } from "../data/crs.js";
14
15
  import { withHeaders } from "../engine/requests.js";
16
+ import { RAD } from "../util/geo.js";
15
17
  import { isNumbers, isRecord } from "../util/guards.js";
16
18
  const isOrientation = (value) => isRecord(value) && isRecord(value.geometry) && isNumbers(value.geometry.coordinates) && isRecord(value.properties);
17
19
  const isCrs = (value) => isRecord(value) &&
@@ -33,7 +35,6 @@ const isCalibration = (value) => isRecord(value) &&
33
35
  isNumbers(value.distortion.poly357) &&
34
36
  (value.distortion.limit === undefined || typeof value.distortion.limit === 'number')));
35
37
  const isCalibrations = (value) => Array.isArray(value) && value.every(isCalibration);
36
- const RAD = Math.PI / 180;
37
38
  /** 3 × 3 product, row-major */
38
39
  const times = (a, b) => Array.from({ length: 9 }, (_, i) => {
39
40
  const [r, c] = [Math.floor(i / 3), i % 3];
@@ -74,25 +75,33 @@ const cameraNumbers = (c) => {
74
75
  d?.limit ?? 0,
75
76
  ];
76
77
  };
78
+ /** The numbers of a 360° photo's camera facing `heading` (its frame east, north, up): x right, y down, z ahead; no
79
+ * focal (the engine's sign of an equirectangular image) */
80
+ export const photoCamera = (heading) => {
81
+ const h = heading * RAD;
82
+ return [
83
+ ...[Math.cos(h), -Math.sin(h), 0],
84
+ ...[0, 0, -1],
85
+ ...[Math.sin(h), Math.cos(h), 0],
86
+ ...[0, 0, 0],
87
+ ...[0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
88
+ ];
89
+ };
77
90
  /** The panoramas of a set, one shown at a time */
78
91
  export class Panoramas {
79
92
  host;
80
- options;
93
+ look;
81
94
  list;
82
- attitudes;
83
- cameras;
84
- lambert93;
95
+ source;
85
96
  /** The panorama shown, if any */
86
97
  current;
87
98
  shown = 0;
88
99
  /** @internal */
89
- constructor(host, options, list, attitudes, cameras, lambert93) {
100
+ constructor(host, look, list, source) {
90
101
  this.host = host;
91
- this.options = options;
102
+ this.look = look;
92
103
  this.list = list;
93
- this.attitudes = attitudes;
94
- this.cameras = cameras;
95
- this.lambert93 = lambert93;
104
+ this.source = source;
96
105
  }
97
106
  /** The panorama nearest to a position */
98
107
  nearest(lonLat) {
@@ -105,8 +114,7 @@ export class Panoramas {
105
114
  /** Shows a panorama (its index in `list`): projected as soon as its first image arrives, the others after */
106
115
  async show(index) {
107
116
  const pano = this.list[index];
108
- const attitude = this.attitudes[index];
109
- if (!pano || !attitude)
117
+ if (!pano)
110
118
  return;
111
119
  const shown = ++this.shown;
112
120
  // The images of the panorama shown before: no longer downloaded nor decoded
@@ -114,11 +122,9 @@ export class Panoramas {
114
122
  this.loading?.abort();
115
123
  this.loading = controller;
116
124
  this.current = pano;
117
- const rotation = panoramaRotation(attitude, pano.lonLat[0], this.lambert93);
118
- const { url, backgroundDistance, opacity } = this.options;
119
- this.host.setPanorama(pano.lonLat[0], pano.lonLat[1], pano.height, Float64Array.from(rotation), Float64Array.from(this.cameras.flatMap(cameraNumbers)), backgroundDistance, opacity);
120
- const images = Promise.all(this.cameras.map(async (camera, k) => {
121
- const src = url.replaceAll('{cameraId}', String(camera.id)).replaceAll('{panoId}', String(pano.id));
125
+ const { backgroundDistance, opacity } = this.look;
126
+ this.host.setPanorama(pano.lonLat[0], pano.lonLat[1], pano.height, Float64Array.from(this.source.rotation(index)), Float64Array.from(this.source.cameras(index)), backgroundDistance, opacity);
127
+ const images = Promise.all(this.source.images(index).map(async (src, k) => {
122
128
  const response = await fetch(src, withHeaders(src, { signal: controller.signal }));
123
129
  if (!response.ok)
124
130
  throw new Error(`isard: panorama image ${src}: ${response.status}`);
@@ -226,8 +232,28 @@ export class Panoramas {
226
232
  this.host.setFirstPerson(undefined);
227
233
  }
228
234
  }
229
- /** Loads a set of panoramas: their positions and attitudes, the calibration of their cameras */
235
+ /** Loads a set of panoramas: a vehicle's (their positions and attitudes, the calibration of their cameras), or 360°
236
+ * photos */
230
237
  export const loadPanoramas = async (host, options) => {
238
+ const look = { backgroundDistance: options.backgroundDistance ?? 1000, opacity: options.opacity ?? 1 };
239
+ if ('photos' in options) {
240
+ const photos = options.photos;
241
+ const list = photos.map((photo, index) => ({
242
+ index,
243
+ id: photo.id ?? index,
244
+ lonLat: photo.lonLat,
245
+ // Above the ground there as the relief has it (the ellipsoid without one)
246
+ height: (host.elevationAt(photo.lonLat) ?? 0) + (photo.height ?? 2.5),
247
+ heading: photo.heading ?? 0,
248
+ }));
249
+ // Their frame east, north, up: the camera turned to the photo's heading
250
+ const identity = [1, 0, 0, 0, 1, 0, 0, 0, 1];
251
+ return new Panoramas(host, look, list, {
252
+ rotation: () => identity,
253
+ cameras: (i) => photoCamera(photos[i]?.heading ?? 0),
254
+ images: (i) => [photos[i]?.url ?? ''],
255
+ });
256
+ }
231
257
  const json = async (src, is) => {
232
258
  const response = await fetch(src, withHeaders(src));
233
259
  if (!response.ok)
@@ -264,11 +290,12 @@ export const loadPanoramas = async (host, options) => {
264
290
  heading: number('heading'),
265
291
  });
266
292
  });
267
- return new Panoramas(host, {
268
- url: options.url,
269
- backgroundDistance: options.backgroundDistance ?? 1000,
270
- opacity: options.opacity ?? 1,
271
- }, list, attitudes, cameras, lambert93);
293
+ const numbers = cameras.flatMap(cameraNumbers);
294
+ return new Panoramas(host, look, list, {
295
+ rotation: (i) => panoramaRotation(attitudes[i] ?? { heading: 0, pitch: 0, roll: 0 }, list[i]?.lonLat[0] ?? 0, lambert93),
296
+ cameras: () => numbers,
297
+ images: (i) => cameras.map((camera) => options.url.replaceAll('{cameraId}', String(camera.id)).replaceAll('{panoId}', String(list[i]?.id ?? i))),
298
+ });
272
299
  };
273
300
  /** A step of the walk that failed (an image not found): told, the walk going on */
274
301
  const report = (error) => {
@@ -1 +1 @@
1
- {"version":3,"file":"panoramas.js","sourceRoot":"","sources":["../../src/layers/panoramas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAwExD,MAAM,aAAa,GAAG,CAAC,KAAc,EAA6C,EAAE,CAClF,QAAQ,CAAC,KAAK,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;AAErH,MAAM,KAAK,GAAG,CAAC,KAAc,EAAgC,EAAE,CAC7D,QAAQ,CAAC,KAAK,CAAC;IACf,CAAC,KAAK,CAAC,UAAU,KAAK,SAAS;QAC7B,CAAC,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,KAAK,CAAC,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC;AAExH,MAAM,cAAc,GAAG,CAAC,KAAc,EAAyB,EAAE,CAC/D,QAAQ,CAAC,KAAK,CAAC;IACf,CAAC,KAAK,CAAC,GAAG,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,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AE,OAAO,CAAC,kBAAkB,IAAI,IAAI;QACtD,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC;KAC9B,EACD,IAAI,EACJ,SAAS,EACT,OAAO,EACP,SAAS,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,mFAAmF;AACnF,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;IACtC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC,CAAC","sourcesContent":["/**\n * Street-level panoramas: the oriented images of a vehicle's cameras around each of its positions (Stereopolis, the\n * iTowns immersive examples), projected onto the scene around the panorama shown. Their positions and attitudes come\n * as GeoJSON points (Lambert-93 by default, altitudes NGF-IGN69 raised by the RAF20 geoid onto the IGN relief), the\n * calibration of the cameras as JSON (rotation and position in the panorama frame, intrinsics, MicMac's radial\n * distortion), the images from a URL template with `{cameraId}` and `{panoId}`.\n *\n * ```ts\n * const panoramas = await map.addPanoramas({ url, orientationsUrl, calibrationUrl });\n * await panoramas.show(panoramas.nearest([2.3345, 48.8505]).index);\n * ```\n */\nimport { getCrs } from '../data/crs.ts';\nimport { withHeaders } from '../engine/requests.ts';\nimport type { FirstPersonView, LonLat } from '../types.ts';\nimport { isNumbers, isRecord } from '../util/guards.ts';\n\nexport interface PanoramaOptions {\n /** URL of an image: `{cameraId}` and `{panoId}` replaced by a camera's id and a panorama's */\n url: string;\n /** GeoJSON points: each panorama's position, and its `id`, `heading`, `pitch`, `roll` (degrees) in properties */\n orientationsUrl: string;\n /** JSON array of the cameras: `id`, `rotation` (row-major), `position`, `projection`, `size`, `distortion` */\n calibrationUrl: string;\n /** CRS of the positions (default the GeoJSON's `crs` member, else `EPSG:2154`) */\n crs?: string;\n /** Altitudes above the geoid (NGF-IGN69), raised by the RAF20 geoid onto the IGN relief (default true in\n * Lambert-93) */\n geoid?: boolean;\n /** Radius of the sphere around the panorama its images are a backdrop on, metres (default 1000) */\n backgroundDistance?: number;\n /** 0-1 (default 1) */\n opacity?: number;\n}\n\n/** A panorama: where it is and which way the vehicle faced */\nexport interface Panorama {\n index: number;\n id: number | string;\n lonLat: LonLat;\n /** Metres above the ellipsoid */\n height: number;\n /** Degrees clockwise from north */\n heading: number;\n}\n\n/** What the map gives the panoramas */\nexport interface PanoramaHost {\n setPanorama(\n lon: number,\n lat: number,\n height: number,\n rotation: Float64Array,\n cameras: Float64Array,\n radius: number,\n opacity: number,\n ): void;\n setPanoramaImage(index: number, image: ImageBitmap): void;\n clearPanorama(): void;\n geoidHeight(lon: number, lat: number): number;\n /** The street-level eye, and setting it (undefined: back to the camera turning around a point) */\n firstPerson(): Readonly<Required<FirstPersonView>> | undefined;\n setFirstPerson(view: FirstPersonView | undefined): void;\n elevationAt(lonLat: LonLat): number | undefined;\n /** Follows the clicks on the map (with the ground clicked), the keys typed on it and its wheel (taken from the\n * map's own); returns what stops */\n listen(\n click: (lonLat: LonLat | undefined) => void,\n key: (e: KeyboardEvent) => void,\n wheel: (e: WheelEvent) => void,\n ): () => void;\n}\n\ninterface Calibration {\n id: number | string;\n rotation: number[];\n position: number[];\n projection: number[];\n size: number[];\n distortion?: { pps: number[]; poly357: number[]; limit?: number };\n}\n\ninterface Orientations {\n crs?: { properties?: { name?: string } };\n features: { geometry: { coordinates: number[] }; properties: Record<string, unknown> }[];\n}\n\nconst isOrientation = (value: unknown): value is Orientations['features'][number] =>\n isRecord(value) && isRecord(value.geometry) && isNumbers(value.geometry.coordinates) && isRecord(value.properties);\n\nconst isCrs = (value: unknown): value is Orientations['crs'] =>\n isRecord(value) &&\n (value.properties === undefined ||\n (isRecord(value.properties) && (value.properties.name === undefined || typeof value.properties.name === 'string')));\n\nconst isOrientations = (value: unknown): value is Orientations =>\n isRecord(value) &&\n (value.crs === undefined || isCrs(value.crs)) &&\n Array.isArray(value.features) &&\n value.features.every(isOrientation);\n\nconst isCalibration = (value: unknown): value is Calibration =>\n isRecord(value) &&\n (typeof value.id === 'number' || typeof value.id === 'string') &&\n isNumbers(value.rotation) &&\n isNumbers(value.position) &&\n isNumbers(value.projection) &&\n isNumbers(value.size) &&\n (value.distortion === undefined ||\n (isRecord(value.distortion) &&\n isNumbers(value.distortion.pps) &&\n isNumbers(value.distortion.poly357) &&\n (value.distortion.limit === undefined || typeof value.distortion.limit === 'number')));\n\nconst isCalibrations = (value: unknown): value is Calibration[] => Array.isArray(value) && value.every(isCalibration);\n\ninterface Attitude {\n heading: number;\n pitch: number;\n roll: number;\n}\n\nconst RAD = Math.PI / 180;\n\n/** 3 × 3 product, row-major */\nconst times = (a: number[], b: number[]): number[] =>\n Array.from({ length: 9 }, (_, i) => {\n const [r, c] = [Math.floor(i / 3), i % 3];\n\n return [0, 1, 2].reduce((sum, k) => sum + (a[r * 3 + k] ?? 0) * (b[k * 3 + c] ?? 0), 0);\n });\n\nconst rotX = (t: number) => [1, 0, 0, 0, Math.cos(t), -Math.sin(t), 0, Math.sin(t), Math.cos(t)];\nconst rotY = (t: number) => [Math.cos(t), 0, Math.sin(t), 0, 1, 0, -Math.sin(t), 0, Math.cos(t)];\nconst rotZ = (t: number) => [Math.cos(t), -Math.sin(t), 0, Math.sin(t), Math.cos(t), 0, 0, 0, 1];\n\n/**\n * The panorama frame to east, north, up (row-major): the vehicle's attitude in the CRS's grid (iTowns'\n * `quaternionFromRollPitchHeading`: Ry(-roll) · Rx(-pitch) · Rz(-heading)), turned by the meridian convergence of the\n * projection (Lambert-93: sin(46.5°) · (3° - longitude))\n */\nexport const panoramaRotation = (attitude: Attitude, lon: number, lambert93: boolean): number[] => {\n const vehicle = times(times(rotY(-attitude.roll * RAD), rotX(-attitude.pitch * RAD)), rotZ(-attitude.heading * RAD));\n const convergence = lambert93 ? Math.sin(46.5 * RAD) * (3 - lon) * RAD : 0;\n\n return times(rotZ(convergence), vehicle);\n};\n\n/** The 25 numbers of a camera for `setPanorama` */\nconst cameraNumbers = (c: Calibration): number[] => {\n const p = c.projection;\n const d = c.distortion;\n\n return [\n ...c.rotation.slice(0, 9),\n ...c.position.slice(0, 3),\n p[0] ?? 1,\n p[4] ?? 1,\n p[2] ?? 0,\n p[5] ?? 0,\n p[1] ?? 0,\n c.size[0] ?? 1,\n c.size[1] ?? 1,\n d?.pps[0] ?? 0,\n d?.pps[1] ?? 0,\n d?.poly357[0] ?? 0,\n d?.poly357[1] ?? 0,\n d?.poly357[2] ?? 0,\n d?.limit ?? 0,\n ];\n};\n\n/** The panoramas of a set, one shown at a time */\nexport class Panoramas {\n /** The panorama shown, if any */\n current: Panorama | undefined;\n private shown = 0;\n\n /** @internal */\n constructor(\n private readonly host: PanoramaHost,\n private readonly options: Required<Pick<PanoramaOptions, 'url' | 'backgroundDistance' | 'opacity'>>,\n readonly list: readonly Panorama[],\n private readonly attitudes: readonly Attitude[],\n private readonly cameras: readonly Calibration[],\n private readonly lambert93: boolean,\n ) {}\n\n /** The panorama nearest to a position */\n nearest(lonLat: LonLat): Panorama | undefined {\n const cos = Math.cos(lonLat[1] * RAD);\n\n return this.list.reduce<{ best?: Panorama; distance: number }>(\n (nearest, p) => {\n const d = ((p.lonLat[0] - lonLat[0]) * cos) ** 2 + (p.lonLat[1] - lonLat[1]) ** 2;\n\n return d < nearest.distance ? { best: p, distance: d } : nearest;\n },\n { distance: Number.POSITIVE_INFINITY },\n ).best;\n }\n\n /** Shows a panorama (its index in `list`): projected as soon as its first image arrives, the others after */\n async show(index: number): Promise<void> {\n const pano = this.list[index];\n const attitude = this.attitudes[index];\n\n if (!pano || !attitude) return;\n\n const shown = ++this.shown;\n // The images of the panorama shown before: no longer downloaded nor decoded\n const controller = new AbortController();\n\n this.loading?.abort();\n this.loading = controller;\n this.current = pano;\n\n const rotation = panoramaRotation(attitude, pano.lonLat[0], this.lambert93);\n const { url, backgroundDistance, opacity } = this.options;\n\n this.host.setPanorama(\n pano.lonLat[0],\n pano.lonLat[1],\n pano.height,\n Float64Array.from(rotation),\n Float64Array.from(this.cameras.flatMap(cameraNumbers)),\n backgroundDistance,\n opacity,\n );\n const images = Promise.all(\n this.cameras.map(async (camera, k) => {\n const src = url.replaceAll('{cameraId}', String(camera.id)).replaceAll('{panoId}', String(pano.id));\n const response = await fetch(src, withHeaders(src, { signal: controller.signal }));\n\n if (!response.ok) throw new Error(`isard: panorama image ${src}: ${response.status}`);\n\n const blob = await response.blob();\n\n if (controller.signal.aborted) return;\n\n const image = await createImageBitmap(blob, { premultiplyAlpha: 'none' });\n\n // Another panorama shown since: this image is not its\n if (shown === this.shown) this.host.setPanoramaImage(k, image);\n image.close();\n }),\n );\n\n // Another panorama shown, or this one hidden, meanwhile: not a failure\n await images.catch((error: unknown) => {\n if (!controller.signal.aborted) throw error;\n });\n }\n\n /** The downloads of the panorama shown, aborted by the next one shown or by `hide` */\n private loading: AbortController | undefined;\n\n /** Hides the panorama shown */\n hide(): void {\n this.shown++;\n this.loading?.abort();\n this.current = undefined;\n this.host.clearPanorama();\n }\n\n /** Stops the walk (`enter`) */\n private stopWalking: (() => void) | undefined;\n\n /**\n * Street-level walk from panorama to panorama (the iTowns immersive view): the eye on a panorama, the drag\n * turning it; a click goes to the panorama nearest to the clicked point, the wheel to the nearest one ahead (or\n * behind), Z and S (or Page Up and Page Down) to the next and the previous ones. Starts on the panorama `index`,\n * else the one nearest to `near`\n */\n async enter(start: { index?: number; near?: LonLat } = {}): Promise<void> {\n const first = start.index ?? (start.near && this.nearest(start.near)?.index) ?? 0;\n\n this.stopWalking?.();\n this.stopWalking = this.host.listen(\n (lonLat) => {\n const target = lonLat && this.nearest(lonLat);\n\n if (target && target !== this.current) this.go(target.index).catch(report);\n },\n (e) => {\n const step = { z: 1, Z: 1, PageUp: 1, s: -1, S: -1, PageDown: -1 }[e.key];\n\n if (!step || !this.current) return;\n e.preventDefault();\n this.go((this.current.index + step + this.list.length) % this.list.length).catch(report);\n },\n (e) => {\n // One step per notch, the next ones once it is shown\n if (this.moving || e.deltaY === 0) return;\n\n const target = this.ahead(e.deltaY < 0);\n\n if (target) {\n this.moving = true;\n this.go(target.index)\n .catch(report)\n .finally(() => {\n this.moving = false;\n });\n }\n },\n );\n await this.go(first, this.list[first]?.heading);\n }\n\n /** A step of the wheel under way */\n private moving = false;\n\n /** The nearest panorama ahead of the eye (within 60° of where it looks), or behind it */\n ahead(forward = true): Panorama | undefined {\n const eye = this.host.firstPerson();\n const here = this.current;\n\n if (!eye || !here) return undefined;\n\n const cos = Math.cos(here.lonLat[1] * RAD);\n const look = (eye.bearing + (forward ? 0 : 180)) * RAD;\n\n return this.list.reduce<{ best?: Panorama; distance: number }>(\n (nearest, p) => {\n if (p === here) return nearest;\n\n const [east, north] = [(p.lonLat[0] - here.lonLat[0]) * cos, p.lonLat[1] - here.lonLat[1]];\n const d = Math.hypot(east, north);\n const off = Math.acos(Math.max(-1, Math.min(1, (east * Math.sin(look) + north * Math.cos(look)) / (d || 1))));\n\n return off < 60 * RAD && d < nearest.distance ? { best: p, distance: d } : nearest;\n },\n { distance: Number.POSITIVE_INFINITY },\n ).best;\n }\n\n /** Goes to a panorama during the walk, the eye looking the same way (or `bearing`) */\n async go(index: number, bearing?: number): Promise<void> {\n const pano = this.list[index];\n\n if (!pano) return;\n\n const eye = this.host.firstPerson();\n // The eye at the panorama's cameras, above the ground there\n const ground = this.host.elevationAt(pano.lonLat);\n\n this.host.setFirstPerson({\n lonLat: pano.lonLat,\n height: ground === undefined ? 2.5 : Math.max(0.5, pano.height - ground),\n bearing: bearing ?? eye?.bearing ?? pano.heading,\n ...(eye ? { pitch: eye.pitch, fov: eye.fov } : {}),\n });\n await this.show(index);\n }\n\n /** Ends the walk: the panorama hidden, the camera turning around a point again, above where the eye stood */\n exit(): void {\n this.stopWalking?.();\n this.stopWalking = undefined;\n this.hide();\n this.host.setFirstPerson(undefined);\n }\n}\n\n/** Loads a set of panoramas: their positions and attitudes, the calibration of their cameras */\nexport const loadPanoramas = async (host: PanoramaHost, options: PanoramaOptions): Promise<Panoramas> => {\n const json = async <T>(src: string, is: (value: unknown) => value is T): Promise<T> => {\n const response = await fetch(src, withHeaders(src));\n\n if (!response.ok) throw new Error(`isard: ${src}: ${response.status}`);\n\n const value: unknown = await response.json();\n\n if (!is(value)) throw new Error(`isard: ${src}: unexpected content`);\n\n return value;\n };\n const [orientations, cameras] = await Promise.all([\n json(options.orientationsUrl, isOrientations),\n json(options.calibrationUrl, isCalibrations),\n ]);\n const crsName = options.crs ?? orientations.crs?.properties?.name ?? 'EPSG:2154';\n const lambert93 = /2154/.test(crsName);\n const crs = getCrs(crsName);\n const geoid = options.geoid ?? lambert93;\n const list: Panorama[] = [];\n const attitudes: Attitude[] = [];\n\n orientations.features.forEach((feature) => {\n const [x = 0, y = 0, z = 0] = feature.geometry.coordinates;\n const [lon = 0, lat = 0] = crs.inverse([x, y]);\n const p = feature.properties;\n const number = (key: string) => {\n const value = p[key];\n\n return typeof value === 'number' ? value : 0;\n };\n\n attitudes.push({ heading: number('heading'), pitch: number('pitch'), roll: number('roll') });\n list.push({\n index: list.length,\n id: typeof p.id === 'number' || typeof p.id === 'string' ? p.id : list.length,\n lonLat: [lon, lat],\n height: z + (geoid ? host.geoidHeight(lon, lat) : 0),\n heading: number('heading'),\n });\n });\n\n return new Panoramas(\n host,\n {\n url: options.url,\n backgroundDistance: options.backgroundDistance ?? 1000,\n opacity: options.opacity ?? 1,\n },\n list,\n attitudes,\n cameras,\n lambert93,\n );\n};\n\n/** A step of the walk that failed (an image not found): told, the walk going on */\nconst report = (error: unknown): void => {\n console.warn('isard: panorama', error);\n};\n"]}
1
+ {"version":3,"file":"panoramas.js","sourceRoot":"","sources":["../../src/layers/panoramas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAgGxD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AAC,MAAM,EAAE,EAAE,CACrB,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CACzG;KACJ,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,mFAAmF;AACnF,MAAM,MAAM,GAAG,CAAC,KAAc,EAAQ,EAAE;IACtC,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC,CAAC;AACzC,CAAC,CAAC","sourcesContent":["/**\n * Street-level panoramas projected onto the scene around the panorama shown: the oriented images of a vehicle's\n * cameras around each of its positions (Stereopolis, the iTowns immersive examples: their positions and attitudes as\n * GeoJSON points, Lambert-93 by default, altitudes NGF-IGN69 raised by the RAF20 geoid onto the IGN relief; the\n * calibration of the cameras as JSON, rotation and position in the panorama frame, intrinsics, MicMac's radial\n * distortion; the images from a URL template with `{cameraId}` and `{panoId}`), or 360° photos (`photos`: one\n * equirectangular image each, where it was taken and the way its middle faces: Panoramax's).\n *\n * ```ts\n * const panoramas = await map.addPanoramas({ url, orientationsUrl, calibrationUrl });\n * await panoramas.show(panoramas.nearest([2.3345, 48.8505]).index);\n * ```\n */\nimport { getCrs } from '../data/crs.ts';\nimport { withHeaders } from '../engine/requests.ts';\nimport type { FirstPersonView, LonLat } from '../types.ts';\nimport { RAD } from '../util/geo.ts';\nimport { isNumbers, isRecord } from '../util/guards.ts';\n\n/** What the panoramas of either kind take */\ninterface PanoramaLook {\n /** Radius of the sphere around the panorama its images are a backdrop on, metres (default 1000) */\n backgroundDistance?: number;\n /** 0-1 (default 1) */\n opacity?: number;\n}\n\n/** A 360° photo (an equirectangular image): where it was taken and the way its middle faces */\nexport interface PanoramaPhoto {\n /** Its image (JPEG, PNG), its middle the photo's `heading`, its top straight up */\n url: string;\n lonLat: LonLat;\n /** Degrees clockwise from north of its middle (0 by default) */\n heading?: number;\n /** Metres of its camera above the ground (2.5 by default) */\n height?: number;\n id?: number | string;\n}\n\n/** 360° photos as panoramas (`photos`, in the order of their walk) */\nexport interface PhotoPanoramaOptions extends PanoramaLook {\n photos: readonly PanoramaPhoto[];\n}\n\n/** A vehicle's calibrated cameras around each of its positions (Stereopolis) */\nexport interface CalibratedPanoramaOptions extends PanoramaLook {\n /** URL of an image: `{cameraId}` and `{panoId}` replaced by a camera's id and a panorama's */\n url: string;\n /** GeoJSON points: each panorama's position, and its `id`, `heading`, `pitch`, `roll` (degrees) in properties */\n orientationsUrl: string;\n /** JSON array of the cameras: `id`, `rotation` (row-major), `position`, `projection`, `size`, `distortion` */\n calibrationUrl: string;\n /** CRS of the positions (default the GeoJSON's `crs` member, else `EPSG:2154`) */\n crs?: string;\n /** Altitudes above the geoid (NGF-IGN69), raised by the RAF20 geoid onto the IGN relief (default true in\n * Lambert-93) */\n geoid?: boolean;\n}\n\nexport type PanoramaOptions = CalibratedPanoramaOptions | PhotoPanoramaOptions;\n\n/** A panorama: where it is and which way the vehicle faced */\nexport interface Panorama {\n index: number;\n id: number | string;\n lonLat: LonLat;\n /** Metres above the ellipsoid */\n height: number;\n /** Degrees clockwise from north */\n heading: number;\n}\n\n/** What the map gives the panoramas */\nexport interface PanoramaHost {\n setPanorama(\n lon: number,\n lat: number,\n height: number,\n rotation: Float64Array,\n cameras: Float64Array,\n radius: number,\n opacity: number,\n ): void;\n setPanoramaImage(index: number, image: ImageBitmap): void;\n clearPanorama(): void;\n geoidHeight(lon: number, lat: number): number;\n /** The street-level eye, and setting it (undefined: back to the camera turning around a point) */\n firstPerson(): Readonly<Required<FirstPersonView>> | undefined;\n setFirstPerson(view: FirstPersonView | undefined): void;\n elevationAt(lonLat: LonLat): number | undefined;\n /** Follows the clicks on the map (with the ground clicked), the keys typed on it and its wheel (taken from the\n * map's own); returns what stops */\n listen(\n click: (lonLat: LonLat | undefined) => void,\n key: (e: KeyboardEvent) => void,\n wheel: (e: WheelEvent) => void,\n ): () => void;\n}\n\ninterface Calibration {\n id: number | string;\n rotation: number[];\n position: number[];\n projection: number[];\n size: number[];\n distortion?: { pps: number[]; poly357: number[]; limit?: number };\n}\n\ninterface Orientations {\n crs?: { properties?: { name?: string } };\n features: { geometry: { coordinates: number[] }; properties: Record<string, unknown> }[];\n}\n\nconst isOrientation = (value: unknown): value is Orientations['features'][number] =>\n isRecord(value) && isRecord(value.geometry) && isNumbers(value.geometry.coordinates) && isRecord(value.properties);\n\nconst isCrs = (value: unknown): value is Orientations['crs'] =>\n isRecord(value) &&\n (value.properties === undefined ||\n (isRecord(value.properties) && (value.properties.name === undefined || typeof value.properties.name === 'string')));\n\nconst isOrientations = (value: unknown): value is Orientations =>\n isRecord(value) &&\n (value.crs === undefined || isCrs(value.crs)) &&\n Array.isArray(value.features) &&\n value.features.every(isOrientation);\n\nconst isCalibration = (value: unknown): value is Calibration =>\n isRecord(value) &&\n (typeof value.id === 'number' || typeof value.id === 'string') &&\n isNumbers(value.rotation) &&\n isNumbers(value.position) &&\n isNumbers(value.projection) &&\n isNumbers(value.size) &&\n (value.distortion === undefined ||\n (isRecord(value.distortion) &&\n isNumbers(value.distortion.pps) &&\n isNumbers(value.distortion.poly357) &&\n (value.distortion.limit === undefined || typeof value.distortion.limit === 'number')));\n\nconst isCalibrations = (value: unknown): value is Calibration[] => Array.isArray(value) && value.every(isCalibration);\n\ninterface Attitude {\n heading: number;\n pitch: number;\n roll: number;\n}\n\n/** 3 × 3 product, row-major */\nconst times = (a: number[], b: number[]): number[] =>\n Array.from({ length: 9 }, (_, i) => {\n const [r, c] = [Math.floor(i / 3), i % 3];\n\n return [0, 1, 2].reduce((sum, k) => sum + (a[r * 3 + k] ?? 0) * (b[k * 3 + c] ?? 0), 0);\n });\n\nconst rotX = (t: number) => [1, 0, 0, 0, Math.cos(t), -Math.sin(t), 0, Math.sin(t), Math.cos(t)];\nconst rotY = (t: number) => [Math.cos(t), 0, Math.sin(t), 0, 1, 0, -Math.sin(t), 0, Math.cos(t)];\nconst rotZ = (t: number) => [Math.cos(t), -Math.sin(t), 0, Math.sin(t), Math.cos(t), 0, 0, 0, 1];\n\n/**\n * The panorama frame to east, north, up (row-major): the vehicle's attitude in the CRS's grid (iTowns'\n * `quaternionFromRollPitchHeading`: Ry(-roll) · Rx(-pitch) · Rz(-heading)), turned by the meridian convergence of the\n * projection (Lambert-93: sin(46.5°) · (3° - longitude))\n */\nexport const panoramaRotation = (attitude: Attitude, lon: number, lambert93: boolean): number[] => {\n const vehicle = times(times(rotY(-attitude.roll * RAD), rotX(-attitude.pitch * RAD)), rotZ(-attitude.heading * RAD));\n const convergence = lambert93 ? Math.sin(46.5 * RAD) * (3 - lon) * RAD : 0;\n\n return times(rotZ(convergence), vehicle);\n};\n\n/** The 25 numbers of a camera for `setPanorama` */\nconst cameraNumbers = (c: Calibration): number[] => {\n const p = c.projection;\n const d = c.distortion;\n\n return [\n ...c.rotation.slice(0, 9),\n ...c.position.slice(0, 3),\n p[0] ?? 1,\n p[4] ?? 1,\n p[2] ?? 0,\n p[5] ?? 0,\n p[1] ?? 0,\n c.size[0] ?? 1,\n c.size[1] ?? 1,\n d?.pps[0] ?? 0,\n d?.pps[1] ?? 0,\n d?.poly357[0] ?? 0,\n d?.poly357[1] ?? 0,\n d?.poly357[2] ?? 0,\n d?.limit ?? 0,\n ];\n};\n\n/** What shows a panorama of a set (its index): its frame to east, north, up (row-major), its cameras' numbers\n * (`cameraNumbers`, 25 each), their images' URLs */\ninterface PanoramaSource {\n rotation(index: number): number[];\n cameras(index: number): number[];\n images(index: number): string[];\n}\n\n/** The numbers of a 360° photo's camera facing `heading` (its frame east, north, up): x right, y down, z ahead; no\n * focal (the engine's sign of an equirectangular image) */\nexport const photoCamera = (heading: number): number[] => {\n const h = heading * RAD;\n\n return [\n ...[Math.cos(h), -Math.sin(h), 0],\n ...[0, 0, -1],\n ...[Math.sin(h), Math.cos(h), 0],\n ...[0, 0, 0],\n ...[0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],\n ];\n};\n\n/** The panoramas of a set, one shown at a time */\nexport class Panoramas {\n /** The panorama shown, if any */\n current: Panorama | undefined;\n private shown = 0;\n\n /** @internal */\n constructor(\n private readonly host: PanoramaHost,\n private readonly look: Required<PanoramaLook>,\n readonly list: readonly Panorama[],\n private readonly source: PanoramaSource,\n ) {}\n\n /** The panorama nearest to a position */\n nearest(lonLat: LonLat): Panorama | undefined {\n const cos = Math.cos(lonLat[1] * RAD);\n\n return this.list.reduce<{ best?: Panorama; distance: number }>(\n (nearest, p) => {\n const d = ((p.lonLat[0] - lonLat[0]) * cos) ** 2 + (p.lonLat[1] - lonLat[1]) ** 2;\n\n return d < nearest.distance ? { best: p, distance: d } : nearest;\n },\n { distance: Number.POSITIVE_INFINITY },\n ).best;\n }\n\n /** Shows a panorama (its index in `list`): projected as soon as its first image arrives, the others after */\n async show(index: number): Promise<void> {\n const pano = this.list[index];\n\n if (!pano) return;\n\n const shown = ++this.shown;\n // The images of the panorama shown before: no longer downloaded nor decoded\n const controller = new AbortController();\n\n this.loading?.abort();\n this.loading = controller;\n this.current = pano;\n\n const { backgroundDistance, opacity } = this.look;\n\n this.host.setPanorama(\n pano.lonLat[0],\n pano.lonLat[1],\n pano.height,\n Float64Array.from(this.source.rotation(index)),\n Float64Array.from(this.source.cameras(index)),\n backgroundDistance,\n opacity,\n );\n const images = Promise.all(\n this.source.images(index).map(async (src, k) => {\n const response = await fetch(src, withHeaders(src, { signal: controller.signal }));\n\n if (!response.ok) throw new Error(`isard: panorama image ${src}: ${response.status}`);\n\n const blob = await response.blob();\n\n if (controller.signal.aborted) return;\n\n const image = await createImageBitmap(blob, { premultiplyAlpha: 'none' });\n\n // Another panorama shown since: this image is not its\n if (shown === this.shown) this.host.setPanoramaImage(k, image);\n image.close();\n }),\n );\n\n // Another panorama shown, or this one hidden, meanwhile: not a failure\n await images.catch((error: unknown) => {\n if (!controller.signal.aborted) throw error;\n });\n }\n\n /** The downloads of the panorama shown, aborted by the next one shown or by `hide` */\n private loading: AbortController | undefined;\n\n /** Hides the panorama shown */\n hide(): void {\n this.shown++;\n this.loading?.abort();\n this.current = undefined;\n this.host.clearPanorama();\n }\n\n /** Stops the walk (`enter`) */\n private stopWalking: (() => void) | undefined;\n\n /**\n * Street-level walk from panorama to panorama (the iTowns immersive view): the eye on a panorama, the drag\n * turning it; a click goes to the panorama nearest to the clicked point, the wheel to the nearest one ahead (or\n * behind), Z and S (or Page Up and Page Down) to the next and the previous ones. Starts on the panorama `index`,\n * else the one nearest to `near`\n */\n async enter(start: { index?: number; near?: LonLat } = {}): Promise<void> {\n const first = start.index ?? (start.near && this.nearest(start.near)?.index) ?? 0;\n\n this.stopWalking?.();\n this.stopWalking = this.host.listen(\n (lonLat) => {\n const target = lonLat && this.nearest(lonLat);\n\n if (target && target !== this.current) this.go(target.index).catch(report);\n },\n (e) => {\n const step = { z: 1, Z: 1, PageUp: 1, s: -1, S: -1, PageDown: -1 }[e.key];\n\n if (!step || !this.current) return;\n e.preventDefault();\n this.go((this.current.index + step + this.list.length) % this.list.length).catch(report);\n },\n (e) => {\n // One step per notch, the next ones once it is shown\n if (this.moving || e.deltaY === 0) return;\n\n const target = this.ahead(e.deltaY < 0);\n\n if (target) {\n this.moving = true;\n this.go(target.index)\n .catch(report)\n .finally(() => {\n this.moving = false;\n });\n }\n },\n );\n await this.go(first, this.list[first]?.heading);\n }\n\n /** A step of the wheel under way */\n private moving = false;\n\n /** The nearest panorama ahead of the eye (within 60° of where it looks), or behind it */\n ahead(forward = true): Panorama | undefined {\n const eye = this.host.firstPerson();\n const here = this.current;\n\n if (!eye || !here) return undefined;\n\n const cos = Math.cos(here.lonLat[1] * RAD);\n const look = (eye.bearing + (forward ? 0 : 180)) * RAD;\n\n return this.list.reduce<{ best?: Panorama; distance: number }>(\n (nearest, p) => {\n if (p === here) return nearest;\n\n const [east, north] = [(p.lonLat[0] - here.lonLat[0]) * cos, p.lonLat[1] - here.lonLat[1]];\n const d = Math.hypot(east, north);\n const off = Math.acos(Math.max(-1, Math.min(1, (east * Math.sin(look) + north * Math.cos(look)) / (d || 1))));\n\n return off < 60 * RAD && d < nearest.distance ? { best: p, distance: d } : nearest;\n },\n { distance: Number.POSITIVE_INFINITY },\n ).best;\n }\n\n /** Goes to a panorama during the walk, the eye looking the same way (or `bearing`) */\n async go(index: number, bearing?: number): Promise<void> {\n const pano = this.list[index];\n\n if (!pano) return;\n\n const eye = this.host.firstPerson();\n // The eye at the panorama's cameras, above the ground there\n const ground = this.host.elevationAt(pano.lonLat);\n\n this.host.setFirstPerson({\n lonLat: pano.lonLat,\n height: ground === undefined ? 2.5 : Math.max(0.5, pano.height - ground),\n bearing: bearing ?? eye?.bearing ?? pano.heading,\n ...(eye ? { pitch: eye.pitch, fov: eye.fov } : {}),\n });\n await this.show(index);\n }\n\n /** Ends the walk: the panorama hidden, the camera turning around a point again, above where the eye stood */\n exit(): void {\n this.stopWalking?.();\n this.stopWalking = undefined;\n this.hide();\n this.host.setFirstPerson(undefined);\n }\n}\n\n/** Loads a set of panoramas: a vehicle's (their positions and attitudes, the calibration of their cameras), or 360°\n * photos */\nexport const loadPanoramas = async (host: PanoramaHost, options: PanoramaOptions): Promise<Panoramas> => {\n const look = { backgroundDistance: options.backgroundDistance ?? 1000, opacity: options.opacity ?? 1 };\n\n if ('photos' in options) {\n const photos = options.photos;\n const list = photos.map((photo, index) => ({\n index,\n id: photo.id ?? index,\n lonLat: photo.lonLat,\n // Above the ground there as the relief has it (the ellipsoid without one)\n height: (host.elevationAt(photo.lonLat) ?? 0) + (photo.height ?? 2.5),\n heading: photo.heading ?? 0,\n }));\n // Their frame east, north, up: the camera turned to the photo's heading\n const identity = [1, 0, 0, 0, 1, 0, 0, 0, 1];\n\n return new Panoramas(host, look, list, {\n rotation: () => identity,\n cameras: (i) => photoCamera(photos[i]?.heading ?? 0),\n images: (i) => [photos[i]?.url ?? ''],\n });\n }\n\n const json = async <T>(src: string, is: (value: unknown) => value is T): Promise<T> => {\n const response = await fetch(src, withHeaders(src));\n\n if (!response.ok) throw new Error(`isard: ${src}: ${response.status}`);\n\n const value: unknown = await response.json();\n\n if (!is(value)) throw new Error(`isard: ${src}: unexpected content`);\n\n return value;\n };\n const [orientations, cameras] = await Promise.all([\n json(options.orientationsUrl, isOrientations),\n json(options.calibrationUrl, isCalibrations),\n ]);\n const crsName = options.crs ?? orientations.crs?.properties?.name ?? 'EPSG:2154';\n const lambert93 = /2154/.test(crsName);\n const crs = getCrs(crsName);\n const geoid = options.geoid ?? lambert93;\n const list: Panorama[] = [];\n const attitudes: Attitude[] = [];\n\n orientations.features.forEach((feature) => {\n const [x = 0, y = 0, z = 0] = feature.geometry.coordinates;\n const [lon = 0, lat = 0] = crs.inverse([x, y]);\n const p = feature.properties;\n const number = (key: string) => {\n const value = p[key];\n\n return typeof value === 'number' ? value : 0;\n };\n\n attitudes.push({ heading: number('heading'), pitch: number('pitch'), roll: number('roll') });\n list.push({\n index: list.length,\n id: typeof p.id === 'number' || typeof p.id === 'string' ? p.id : list.length,\n lonLat: [lon, lat],\n height: z + (geoid ? host.geoidHeight(lon, lat) : 0),\n heading: number('heading'),\n });\n });\n\n const numbers = cameras.flatMap(cameraNumbers);\n\n return new Panoramas(host, look, list, {\n rotation: (i) =>\n panoramaRotation(attitudes[i] ?? { heading: 0, pitch: 0, roll: 0 }, list[i]?.lonLat[0] ?? 0, lambert93),\n cameras: () => numbers,\n images: (i) =>\n cameras.map((camera) =>\n options.url.replaceAll('{cameraId}', String(camera.id)).replaceAll('{panoId}', String(list[i]?.id ?? i)),\n ),\n });\n};\n\n/** A step of the walk that failed (an image not found): told, the walk going on */\nconst report = (error: unknown): void => {\n console.warn('isard: panorama', error);\n};\n"]}