isard 2.0.0 → 2.1.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 (58) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +1 -1
  3. package/dist/basemap/vectortiles/vectors.d.ts +3 -1
  4. package/dist/basemap/vectortiles/vectors.js +2 -0
  5. package/dist/basemap/vectortiles/vectors.js.map +1 -1
  6. package/dist/basemap/vectortiles.d.ts +1 -3
  7. package/dist/basemap/vectortiles.js +1 -3
  8. package/dist/basemap/vectortiles.js.map +1 -1
  9. package/dist/bind/layers.js +2 -2
  10. package/dist/bind/layers.js.map +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/isard_webgl2_bg.wasm +0 -0
  14. package/dist/isard_webgpu_bg.wasm +0 -0
  15. package/dist/layers/extrusions.d.ts +6 -1
  16. package/dist/layers/extrusions.js +15 -4
  17. package/dist/layers/extrusions.js.map +1 -1
  18. package/dist/layers/ground.d.ts +1 -1
  19. package/dist/layers/ground.js +1 -1
  20. package/dist/layers/ground.js.map +1 -1
  21. package/dist/layers/layers.js +1 -1
  22. package/dist/layers/layers.js.map +1 -1
  23. package/dist/layers/models.d.ts +7 -1
  24. package/dist/layers/models.js +19 -1
  25. package/dist/layers/models.js.map +1 -1
  26. package/dist/layers/pointclouds.d.ts +2 -2
  27. package/dist/layers/pointclouds.js +3 -3
  28. package/dist/layers/pointclouds.js.map +1 -1
  29. package/dist/layers/raster.js +5 -0
  30. package/dist/layers/raster.js.map +1 -1
  31. package/dist/layers/tiles3d.d.ts +4 -6
  32. package/dist/layers/tiles3d.js +9 -14
  33. package/dist/layers/tiles3d.js.map +1 -1
  34. package/dist/layers/vectors.d.ts +6 -0
  35. package/dist/layers/vectors.js +18 -1
  36. package/dist/layers/vectors.js.map +1 -1
  37. package/dist/map/engine-settings.d.ts +4 -1
  38. package/dist/map/engine-settings.js +13 -2
  39. package/dist/map/engine-settings.js.map +1 -1
  40. package/dist/map/layer-stack.d.ts +5 -6
  41. package/dist/map/layer-stack.js +5 -6
  42. package/dist/map/layer-stack.js.map +1 -1
  43. package/dist/map.d.ts +22 -9
  44. package/dist/map.js +52 -16
  45. package/dist/map.js.map +1 -1
  46. package/dist/react/VectorGeometry.d.ts +4 -1
  47. package/dist/react/VectorGeometry.js +5 -1
  48. package/dist/react/VectorGeometry.js.map +1 -1
  49. package/dist/settings.d.ts +2 -0
  50. package/dist/settings.js +1 -1
  51. package/dist/settings.js.map +1 -1
  52. package/dist/types.d.ts +23 -4
  53. package/dist/types.js.map +1 -1
  54. package/dist/wasm/isard_webgl2.d.ts +21 -7
  55. package/dist/wasm/isard_webgl2.js +42 -21
  56. package/dist/wasm/isard_webgpu.d.ts +21 -7
  57. package/dist/wasm/isard_webgpu.js +42 -21
  58. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"pointclouds.js","sourceRoot":"","sources":["../../src/layers/pointclouds.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAA0B,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAa,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAUrE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AA6DpC;iCACiC;AACjC,MAAM,CAAC,MAAM,eAAe,GAA6D;IACvF,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,E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MAAc,EAAE,EAAU;QACtC,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;QAErB,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC9B,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,CAAC,CAAC,mBAAmB,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,YAAY,EAAE,CAAC,CAAC;YAEtF,OAAO;QACT,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAExG,MAAM,CAAC,kBAAkB,CACvB,EAAE,EACF,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,EACrB,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,EAC/B,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,IAAI,CACjC,CAAC;IACJ,CAAC;IAED,gBAAgB;IACN,MAAM,CAAC,MAAc;QAC7B,MAAM,EAAE,GACN,IAAI,CAAC,MAAM,KAAK,SAAS;YACvB,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC;YAC7D,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAEhF,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEvB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/**\n * Point clouds: a COPC file (Cloud Optimized Point Cloud: LAZ 1.4 with an octree, read by HTTP range requests, as the\n * IGN distributes LiDAR HD) or a 3D Tiles point cloud (`.pnts`, glTF points), drawn by the engine with 3D Tiles. The\n * COPC file's CRS comes from its WKT (built-in CRSs, or registered ones: `registerCrs`) or the `crs` option; altitudes\n * in NGF-IGN69 (Lambert-93, the CC zones) are raised by the RAF20 geoid height onto the ellipsoid of the relief and\n * the 3D Tiles.\n */\nimport { type Crs, type CrsLike, epsgCode, getCrs } from '../data/crs.ts';\nimport type { LayerHost, Placement } from '../types.ts';\nimport { parseColor, type Ramp, rampTexels } from '../util/color.ts';\nimport type {\n Engine,\n PointCloudCrs,\n PointCloudInfo,\n PointCloudPoint,\n PointCloudStats,\n Tiles3dStats,\n} from '../wasm/isard_webgpu.js';\nimport type { Feature } from './features.ts';\nimport { Layer } from './layers.ts';\n\n/** What the points are colored by */\nexport type PointColor = 'rgb' | 'classification' | 'elevation' | 'intensity';\n\n/** The look of a class of points */\nexport interface ClassStyle {\n /** CSS color */\n color?: string;\n /** false hides the class */\n visible?: boolean;\n}\n\nexport interface PointCloudStyle {\n /** By RGB (files with colors), class (the ASPRS palette, `classifications`), altitude (`elevationRamp` over\n * `elevationRange`) or intensity (grey over `intensityRange`). Default: RGB when the file has colors, else class */\n colorBy?: PointColor;\n /** CSS pixels: the size of the points, or the smallest with `sizeMode: 'adaptive'` (default 2) */\n pointSize: number;\n /** CSS pixels: the largest adaptive size (default 4) */\n maxPointSize: number;\n /** `'adaptive'` (default): the spacing of the points of the finest level drawn there, at their distance (the\n * nearer, the larger, no gap); `'fixed'`: `pointSize` everywhere */\n sizeMode: 'adaptive' | 'fixed';\n /** `'circle'` (default) or `'square'` */\n shape: 'circle' | 'square';\n /** Eye-Dome Lighting: points shaded by the depth of their neighbours on screen, their relief read without normals\n * nor colors (default false; `strength` 1, `radius` 1.4 CSS pixels) */\n edl: boolean | { strength?: number; radius?: number };\n /** Colors and visibility by class code, over the defaults (ASPRS, and IGN's LiDAR HD classes 64 to 67; the noise\n * 7 and 18 and the artefacts 65 hidden): `{ 2: { color: '#a0522d' }, 66: { visible: false } }` */\n classifications: Record<number, ClassStyle>;\n /** Altitudes (metres, the file's vertical datum) mapped onto the ramp; default the file's lowest and highest */\n elevationRange?: [min: number, max: number];\n /** Colors from the lowest altitude (0) to the highest (1) */\n elevationRamp: Ramp;\n /** Intensities mapped from black to white; default the bulk of the first node's (2nd to 98th percentile) */\n intensityRange?: [min: number, max: number];\n /** CSS pixels: a node is refined while the spacing of its points covers more on screen (default 1.5; lower is finer\n * and heavier). For 3D Tiles, their screen-space error (default 16) */\n maxScreenSpaceError: number;\n /** Points drawn at most, the nearest and the coarsest first (default 3 000 000) */\n pointBudget: number;\n}\n\nexport interface PointCloudOptions extends Partial<PointCloudStyle>, Placement {\n /** A COPC file (`.copc.laz`) or a 3D Tiles `tileset.json` of points */\n url: string;\n /** Default: `'3dtiles'` for a `.json` URL, else `'copc'` */\n format?: 'copc' | '3dtiles';\n /** The CRS of a COPC file without a WKT, or whose CRS is not built in (`proj4('EPSG:2992')`) */\n crs?: CrsLike;\n /** Its altitudes are above the geoid (NGF-IGN69), raised by the RAF20 geoid height; default for Lambert-93 and the\n * CC zones */\n geoid?: boolean;\n /** Metres of a unit of z; default the vertical unit of the WKT (a US survey foot…), else that of x and y */\n verticalScale?: number;\n /** Requests a second at most: 8 by default for the Géoplateforme (data.geopf.fr allows 10), no limit elsewhere */\n requestsPerSecond?: number;\n}\n\n/** The default classes: ASPRS LAS 1.4, then IGN's LiDAR HD (64 permanent structures, 65 artefacts, 66 virtual points,\n * 67 miscellaneous buildings) */\nexport const CLASSIFICATIONS: Readonly<Record<number, Readonly<Required<ClassStyle>>>> = {\n 0: { color: '#a6a6a6', visible: true },\n 1: { color: '#c8c8c8', visible: true },\n 2: { color: '#b08458', visible: true },\n 3: { color: '#9ccc65', visible: true },\n 4: { color: '#5aa83f', visible: true },\n 5: { color: '#2e7d32', visible: true },\n 6: { color: '#e57352', visible: true },\n 7: { color: '#ff00ff', visible: false },\n 8: { color: '#ff0000', visible: true },\n 9: { color: '#3d8fd6', visible: true },\n 10: { color: '#8e6bb0', visible: true },\n 11: { color: '#7a7a7a', visible: true },\n 12: { color: '#ffe680', visible: true },\n 13: { color: '#ffff00', visible: true },\n 14: { color: '#ffc800', visible: true },\n 15: { color: '#c89600', visible: true },\n 16: { color: '#ff9632', visible: true },\n 17: { color: '#b48cc8', visible: true },\n 18: { color: '#ff00ff', visible: false },\n 64: { color: '#8c6e5a', visible: true },\n 65: { color: '#ff00ff', visible: false },\n 66: { color: '#5a6ec8', visible: true },\n 67: { color: '#e6966e', visible: true },\n};\n\n/** The default ramp of the altitudes, low to high */\nexport const ELEVATION_RAMP: Ramp = [\n [0, '#2b83ba'],\n [0.25, '#abdda4'],\n [0.5, '#ffffbf'],\n [0.75, '#fdae61'],\n [1, '#d7191c'],\n];\n\n/** The colors of the 256 classes (RGBA, alpha 0 hides one) */\nexport const classPalette = (overrides: Record<number, ClassStyle> = {}): Uint8Array => {\n const out = new Uint8Array(256 * 4);\n\n for (let code = 0; code < 256; code += 1) {\n const base = CLASSIFICATIONS[code] ?? { color: '#c8c8c8', visible: true };\n const own = overrides[code] ?? {};\n const [r = 0, g = 0, b = 0] = parseColor(own.color ?? base.color);\n\n out.set([r * 255, g * 255, b * 255, (own.visible ?? base.visible) ? 255 : 0], code * 4);\n }\n\n return out;\n};\n\n/** The section of a WKT opening with one of `keywords` (`PROJCS[…]`), from its keyword to its closing bracket */\nconst section = (wkt: string, keywords: string[]): string | undefined => {\n for (const keyword of keywords) {\n const start = wkt.indexOf(`${keyword}[`);\n\n if (start < 0) continue;\n\n let depth = 0;\n\n for (let i = start + keyword.length; i < wkt.length; i += 1) {\n if (wkt[i] === '[') depth += 1;\n else if (wkt[i] === ']' && --depth === 0) return wkt.slice(start, i + 1);\n }\n }\n\n return undefined;\n};\n\n/** The EPSG code a WKT section ends with (its own `AUTHORITY`, or `ID` in WKT2), the last of its nested ones */\nconst lastCode = (part: string): number | undefined => {\n const codes = [...part.matchAll(/(?:AUTHORITY|ID)\\[\\s*\"EPSG\"\\s*,\\s*\"?(\\d+)\"?\\s*\\]/g)];\n const last = codes.at(-1)?.[1];\n\n return last === undefined ? undefined : Number(last);\n};\n\n/** The factor of the last `UNIT` (`LENGTHUNIT` in WKT2) of a WKT section */\nconst lastUnit = (part: string | undefined): number | undefined => {\n const units = [...(part ?? '').matchAll(/(?:LENGTH)?UNIT\\[\\s*\"[^\"]*\"\\s*,\\s*([\\d.eE+-]+)/g)];\n const factor = Number(units.at(-1)?.[1]);\n\n return Number.isFinite(factor) && factor > 0 ? factor : undefined;\n};\n\n/** What a WKT says of a CRS: its EPSG code (projected first), the metres of a unit of z */\nexport const wktCrs = (wkt: string): { code: number | undefined; verticalScale: number | undefined } => {\n const projected = section(wkt, ['PROJCS', 'PROJCRS']);\n const geographic = section(wkt, ['GEOGCS', 'GEOGCRS']);\n const code = lastCode(projected ?? geographic ?? '') ?? (/Lambert[- ]93/i.test(wkt) ? 2154 : undefined);\n const vertical = section(wkt, ['VERT_CS', 'VERTCRS']);\n const verticalScale = lastUnit(vertical ?? projected);\n\n return { code, verticalScale };\n};\n\n/** Whether the altitudes of a CRS are NGF-IGN69 by default: Lambert-93 and the CC zones */\nconst FRENCH = (code: number | undefined) => code === 2154 || (code !== undefined && code >= 3942 && code <= 3950);\n\n/** The CRS of a COPC file for the engine, from its WKT and the options */\nexport const pointCloudCrs = (\n wkt: string | undefined,\n options: Pick<PointCloudOptions, 'crs' | 'geoid' | 'verticalScale'>,\n): PointCloudCrs => {\n const parsed = wkt ? wktCrs(wkt) : { code: undefined, verticalScale: undefined };\n const crs = ((): Crs => {\n if (options.crs !== undefined) return getCrs(options.crs);\n\n const code = parsed.code;\n\n if (code === undefined) throw new Error('isard: the file names no CRS: give it as `crs`');\n try {\n return getCrs(`EPSG:${code}`);\n } catch {\n throw new Error(\n `isard: the CRS of the file, EPSG:${code}, is not built in: give it as \\`crs\\` (proj4('EPSG:${code}'))`,\n );\n }\n })();\n const code = typeof options.crs === 'string' ? (epsgCode(options.crs) ?? parsed.code) : parsed.code;\n const inverse = (xy: Float64Array) => {\n const out = new Float64Array(xy.length);\n\n for (let i = 0; i + 1 < xy.length; i += 2) {\n const [lon = Number.NaN, lat = Number.NaN] = crs.inverse([xy[i] as number, xy[i + 1] as number]);\n\n out[i] = lon;\n out[i + 1] = lat;\n }\n\n return out;\n };\n\n return {\n inverse,\n geoid: options.geoid ?? (FRENCH(code) || /IGN69|NGF/.test(wkt ?? '')),\n verticalScale: options.verticalScale ?? parsed.verticalScale ?? 1,\n };\n};\n\n/** The style numbers of the engine (`setPointCloudStyle`) */\nconst styleNumbers = (s: PointCloudStyle, rate: number): Float64Array => {\n const colors: PointColor[] = ['rgb', 'classification', 'elevation', 'intensity'];\n const edl: { strength?: number; radius?: number } | undefined = s.edl === true ? {} : s.edl || undefined;\n const [emin = Number.NaN, emax = Number.NaN] = s.elevationRange ?? [];\n const [imin = Number.NaN, imax = Number.NaN] = s.intensityRange ?? [];\n\n return Float64Array.of(\n s.colorBy ? colors.indexOf(s.colorBy) : -1,\n s.pointSize,\n s.maxPointSize,\n s.sizeMode === 'fixed' ? 0 : 1,\n s.shape === 'square' ? 0 : 1,\n edl ? (edl.strength ?? 1) : 0,\n edl?.radius ?? 1.4,\n emin,\n emax,\n imin,\n imax,\n s.maxScreenSpaceError,\n s.pointBudget,\n rate,\n );\n};\n\n/** A point cloud (`GeoMap.addPointCloud`): COPC or 3D Tiles points; `pickFeature` gives a COPC point's attributes */\nexport class PointCloudLayer extends Layer {\n readonly url: string;\n readonly format: 'copc' | '3dtiles';\n private style: PointCloudStyle;\n private readonly options: PointCloudOptions;\n\n /** @internal */\n constructor(map: LayerHost, options: PointCloudOptions) {\n super(map);\n\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(options.url, base).href : options.url;\n this.format = options.format ?? (/\\.json(?:[?#]|$)/i.test(options.url) ? '3dtiles' : 'copc');\n this.options = options;\n\n const tiles = this.format === '3dtiles';\n\n this.style = {\n ...(options.colorBy ? { colorBy: options.colorBy } : {}),\n pointSize: options.pointSize ?? 2,\n maxPointSize: options.maxPointSize ?? 4,\n sizeMode: options.sizeMode ?? 'adaptive',\n shape: options.shape ?? 'circle',\n edl: options.edl ?? false,\n classifications: options.classifications ?? {},\n ...(options.elevationRange ? { elevationRange: options.elevationRange } : {}),\n elevationRamp: options.elevationRamp ?? ELEVATION_RAMP,\n ...(options.intensityRange ? { intensityRange: options.intensityRange } : {}),\n maxScreenSpaceError: options.maxScreenSpaceError ?? (tiles ? 16 : 1.5),\n pointBudget: options.pointBudget ?? 3_000_000,\n };\n }\n\n /** Changes the style, the rest kept */\n setStyle(style: Partial<PointCloudStyle>): 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.apply(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n getStyle(): Readonly<PointCloudStyle> {\n return this.style;\n }\n\n /** Loading counters; undefined once removed and while the engine with 3D Tiles loads */\n stats(): PointCloudStats | Tiles3dStats | undefined {\n if (this.id < 0) return undefined;\n\n return this.format === '3dtiles' ? this.map.engine.tiles3dStats(this.id) : this.map.engine.pointCloudStats(this.id);\n }\n\n /** What a COPC file says of itself (points, format, CRS, center, altitudes), once its head is read */\n info(): PointCloudInfo | undefined {\n return this.id < 0 || this.format === '3dtiles' ? undefined : this.map.engine.pointCloudInfo(this.id);\n }\n\n /** @internal The point picked (`pickFeature`, 'hoverfeature'): a Point at its longitude, latitude and height, its\n * attributes as properties */\n featureAt(index: number): Feature<PointCloudPoint> | undefined {\n if (this.id < 0 || this.format === '3dtiles') return undefined;\n\n const point = this.map.engine.pointCloudPoint(this.id, index);\n\n if (!point) return undefined;\n\n return {\n type: 'Feature',\n geometry: { type: 'Point', coordinates: [...point.lonLat, point.height] },\n properties: point,\n };\n }\n\n private apply(engine: Engine, id: number): void {\n const s = this.style;\n\n if (this.format === '3dtiles') {\n engine.setTiles3dStyle(id, s.maxScreenSpaceError, 1, s.pointSize, new Float32Array());\n\n return;\n }\n\n const rate = this.options.requestsPerSecond ?? (/^https?:\\/\\/data\\.geopf\\.fr\\//.test(this.url) ? 8 : 0);\n\n engine.setPointCloudStyle(\n id,\n styleNumbers(s, rate),\n classPalette(s.classifications),\n rampTexels(s.elevationRamp).rgba,\n );\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id =\n this.format === '3dtiles'\n ? engine.addTiles3d(this.url, this.style.maxScreenSpaceError)\n : engine.addPointCloud(this.url, (wkt) => pointCloudCrs(wkt, this.options));\n\n this.apply(engine, id);\n\n return id;\n }\n}\n"]}
1
+ {"version":3,"file":"pointclouds.js","sourceRoot":"","sources":["../../src/layers/pointclouds.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAA0B,QAAQ,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAa,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAUrE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AA6DpC;iCACiC;AACjC,MAAM,CAAC,MAAM,eAAe,GAA6D;IACvF,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE;IACtC,CAAC,EA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CAAC,CAAC,mBAAmB,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,EAAE,IAAI,YAAY,EAAE,CAAC,CAAC;YAEtF,OAAO;QACT,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAExG,MAAM,CAAC,kBAAkB,CACvB,EAAE,EACF,YAAY,CAAC,CAAC,EAAE,IAAI,CAAC,EACrB,YAAY,CAAC,CAAC,CAAC,eAAe,CAAC,EAC/B,UAAU,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,IAAI,CACjC,CAAC;IACJ,CAAC;IAED,gBAAgB;IACN,MAAM,CAAC,MAAc;QAC7B,MAAM,EAAE,GACN,IAAI,CAAC,MAAM,KAAK,SAAS;YACvB,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC;YAC7D,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAEhF,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAEvB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/**\n * Point clouds: a COPC file (Cloud Optimized Point Cloud: LAZ 1.4 with an octree, read by HTTP range requests, as the\n * IGN distributes LiDAR HD) or a 3D Tiles point cloud (`.pnts`, glTF points). The\n * COPC file's CRS comes from its WKT (built-in CRSs, or registered ones: `registerCrs`) or the `crs` option; altitudes\n * in NGF-IGN69 (Lambert-93, the CC zones) are raised by the RAF20 geoid height onto the ellipsoid of the relief and\n * the 3D Tiles.\n */\nimport { type Crs, type CrsLike, epsgCode, getCrs } from '../data/crs.ts';\nimport type { LayerHost, Placement } from '../types.ts';\nimport { parseColor, type Ramp, rampTexels } from '../util/color.ts';\nimport type {\n Engine,\n PointCloudCrs,\n PointCloudInfo,\n PointCloudPoint,\n PointCloudStats,\n Tiles3dStats,\n} from '../wasm/isard_webgpu.js';\nimport type { Feature } from './features.ts';\nimport { Layer } from './layers.ts';\n\n/** What the points are colored by */\nexport type PointColor = 'rgb' | 'classification' | 'elevation' | 'intensity';\n\n/** The look of a class of points */\nexport interface ClassStyle {\n /** CSS color */\n color?: string;\n /** false hides the class */\n visible?: boolean;\n}\n\nexport interface PointCloudStyle {\n /** By RGB (files with colors), class (the ASPRS palette, `classifications`), altitude (`elevationRamp` over\n * `elevationRange`) or intensity (grey over `intensityRange`). Default: RGB when the file has colors, else class */\n colorBy?: PointColor;\n /** CSS pixels: the size of the points, or the smallest with `sizeMode: 'adaptive'` (default 2) */\n pointSize: number;\n /** CSS pixels: the largest adaptive size (default 4) */\n maxPointSize: number;\n /** `'adaptive'` (default): the spacing of the points of the finest level drawn there, at their distance (the\n * nearer, the larger, no gap); `'fixed'`: `pointSize` everywhere */\n sizeMode: 'adaptive' | 'fixed';\n /** `'circle'` (default) or `'square'` */\n shape: 'circle' | 'square';\n /** Eye-Dome Lighting: points shaded by the depth of their neighbours on screen, their relief read without normals\n * nor colors (default false; `strength` 1, `radius` 1.4 CSS pixels) */\n edl: boolean | { strength?: number; radius?: number };\n /** Colors and visibility by class code, over the defaults (ASPRS, and IGN's LiDAR HD classes 64 to 67; the noise\n * 7 and 18 and the artefacts 65 hidden): `{ 2: { color: '#a0522d' }, 66: { visible: false } }` */\n classifications: Record<number, ClassStyle>;\n /** Altitudes (metres, the file's vertical datum) mapped onto the ramp; default the file's lowest and highest */\n elevationRange?: [min: number, max: number];\n /** Colors from the lowest altitude (0) to the highest (1) */\n elevationRamp: Ramp;\n /** Intensities mapped from black to white; default the bulk of the first node's (2nd to 98th percentile) */\n intensityRange?: [min: number, max: number];\n /** CSS pixels: a node is refined while the spacing of its points covers more on screen (default 1.5; lower is finer\n * and heavier). For 3D Tiles, their screen-space error (default 16) */\n maxScreenSpaceError: number;\n /** Points drawn at most, the nearest and the coarsest first (default 3 000 000) */\n pointBudget: number;\n}\n\nexport interface PointCloudOptions extends Partial<PointCloudStyle>, Placement {\n /** A COPC file (`.copc.laz`) or a 3D Tiles `tileset.json` of points */\n url: string;\n /** Default: `'3dtiles'` for a `.json` URL, else `'copc'` */\n format?: 'copc' | '3dtiles';\n /** The CRS of a COPC file without a WKT, or whose CRS is not built in (`proj4('EPSG:2992')`) */\n crs?: CrsLike;\n /** Its altitudes are above the geoid (NGF-IGN69), raised by the RAF20 geoid height; default for Lambert-93 and the\n * CC zones */\n geoid?: boolean;\n /** Metres of a unit of z; default the vertical unit of the WKT (a US survey foot…), else that of x and y */\n verticalScale?: number;\n /** Requests a second at most: 8 by default for the Géoplateforme (data.geopf.fr allows 10), no limit elsewhere */\n requestsPerSecond?: number;\n}\n\n/** The default classes: ASPRS LAS 1.4, then IGN's LiDAR HD (64 permanent structures, 65 artefacts, 66 virtual points,\n * 67 miscellaneous buildings) */\nexport const CLASSIFICATIONS: Readonly<Record<number, Readonly<Required<ClassStyle>>>> = {\n 0: { color: '#a6a6a6', visible: true },\n 1: { color: '#c8c8c8', visible: true },\n 2: { color: '#b08458', visible: true },\n 3: { color: '#9ccc65', visible: true },\n 4: { color: '#5aa83f', visible: true },\n 5: { color: '#2e7d32', visible: true },\n 6: { color: '#e57352', visible: true },\n 7: { color: '#ff00ff', visible: false },\n 8: { color: '#ff0000', visible: true },\n 9: { color: '#3d8fd6', visible: true },\n 10: { color: '#8e6bb0', visible: true },\n 11: { color: '#7a7a7a', visible: true },\n 12: { color: '#ffe680', visible: true },\n 13: { color: '#ffff00', visible: true },\n 14: { color: '#ffc800', visible: true },\n 15: { color: '#c89600', visible: true },\n 16: { color: '#ff9632', visible: true },\n 17: { color: '#b48cc8', visible: true },\n 18: { color: '#ff00ff', visible: false },\n 64: { color: '#8c6e5a', visible: true },\n 65: { color: '#ff00ff', visible: false },\n 66: { color: '#5a6ec8', visible: true },\n 67: { color: '#e6966e', visible: true },\n};\n\n/** The default ramp of the altitudes, low to high */\nexport const ELEVATION_RAMP: Ramp = [\n [0, '#2b83ba'],\n [0.25, '#abdda4'],\n [0.5, '#ffffbf'],\n [0.75, '#fdae61'],\n [1, '#d7191c'],\n];\n\n/** The colors of the 256 classes (RGBA, alpha 0 hides one) */\nexport const classPalette = (overrides: Record<number, ClassStyle> = {}): Uint8Array => {\n const out = new Uint8Array(256 * 4);\n\n for (let code = 0; code < 256; code += 1) {\n const base = CLASSIFICATIONS[code] ?? { color: '#c8c8c8', visible: true };\n const own = overrides[code] ?? {};\n const [r = 0, g = 0, b = 0] = parseColor(own.color ?? base.color);\n\n out.set([r * 255, g * 255, b * 255, (own.visible ?? base.visible) ? 255 : 0], code * 4);\n }\n\n return out;\n};\n\n/** The section of a WKT opening with one of `keywords` (`PROJCS[…]`), from its keyword to its closing bracket */\nconst section = (wkt: string, keywords: string[]): string | undefined => {\n for (const keyword of keywords) {\n const start = wkt.indexOf(`${keyword}[`);\n\n if (start < 0) continue;\n\n let depth = 0;\n\n for (let i = start + keyword.length; i < wkt.length; i += 1) {\n if (wkt[i] === '[') depth += 1;\n else if (wkt[i] === ']' && --depth === 0) return wkt.slice(start, i + 1);\n }\n }\n\n return undefined;\n};\n\n/** The EPSG code a WKT section ends with (its own `AUTHORITY`, or `ID` in WKT2), the last of its nested ones */\nconst lastCode = (part: string): number | undefined => {\n const codes = [...part.matchAll(/(?:AUTHORITY|ID)\\[\\s*\"EPSG\"\\s*,\\s*\"?(\\d+)\"?\\s*\\]/g)];\n const last = codes.at(-1)?.[1];\n\n return last === undefined ? undefined : Number(last);\n};\n\n/** The factor of the last `UNIT` (`LENGTHUNIT` in WKT2) of a WKT section */\nconst lastUnit = (part: string | undefined): number | undefined => {\n const units = [...(part ?? '').matchAll(/(?:LENGTH)?UNIT\\[\\s*\"[^\"]*\"\\s*,\\s*([\\d.eE+-]+)/g)];\n const factor = Number(units.at(-1)?.[1]);\n\n return Number.isFinite(factor) && factor > 0 ? factor : undefined;\n};\n\n/** What a WKT says of a CRS: its EPSG code (projected first), the metres of a unit of z */\nexport const wktCrs = (wkt: string): { code: number | undefined; verticalScale: number | undefined } => {\n const projected = section(wkt, ['PROJCS', 'PROJCRS']);\n const geographic = section(wkt, ['GEOGCS', 'GEOGCRS']);\n const code = lastCode(projected ?? geographic ?? '') ?? (/Lambert[- ]93/i.test(wkt) ? 2154 : undefined);\n const vertical = section(wkt, ['VERT_CS', 'VERTCRS']);\n const verticalScale = lastUnit(vertical ?? projected);\n\n return { code, verticalScale };\n};\n\n/** Whether the altitudes of a CRS are NGF-IGN69 by default: Lambert-93 and the CC zones */\nconst FRENCH = (code: number | undefined) => code === 2154 || (code !== undefined && code >= 3942 && code <= 3950);\n\n/** The CRS of a COPC file for the engine, from its WKT and the options */\nexport const pointCloudCrs = (\n wkt: string | undefined,\n options: Pick<PointCloudOptions, 'crs' | 'geoid' | 'verticalScale'>,\n): PointCloudCrs => {\n const parsed = wkt ? wktCrs(wkt) : { code: undefined, verticalScale: undefined };\n const crs = ((): Crs => {\n if (options.crs !== undefined) return getCrs(options.crs);\n\n const code = parsed.code;\n\n if (code === undefined) throw new Error('isard: the file names no CRS: give it as `crs`');\n try {\n return getCrs(`EPSG:${code}`);\n } catch {\n throw new Error(\n `isard: the CRS of the file, EPSG:${code}, is not built in: give it as \\`crs\\` (proj4('EPSG:${code}'))`,\n );\n }\n })();\n const code = typeof options.crs === 'string' ? (epsgCode(options.crs) ?? parsed.code) : parsed.code;\n const inverse = (xy: Float64Array) => {\n const out = new Float64Array(xy.length);\n\n for (let i = 0; i + 1 < xy.length; i += 2) {\n const [lon = Number.NaN, lat = Number.NaN] = crs.inverse([xy[i] as number, xy[i + 1] as number]);\n\n out[i] = lon;\n out[i + 1] = lat;\n }\n\n return out;\n };\n\n return {\n inverse,\n geoid: options.geoid ?? (FRENCH(code) || /IGN69|NGF/.test(wkt ?? '')),\n verticalScale: options.verticalScale ?? parsed.verticalScale ?? 1,\n };\n};\n\n/** The style numbers of the engine (`setPointCloudStyle`) */\nconst styleNumbers = (s: PointCloudStyle, rate: number): Float64Array => {\n const colors: PointColor[] = ['rgb', 'classification', 'elevation', 'intensity'];\n const edl: { strength?: number; radius?: number } | undefined = s.edl === true ? {} : s.edl || undefined;\n const [emin = Number.NaN, emax = Number.NaN] = s.elevationRange ?? [];\n const [imin = Number.NaN, imax = Number.NaN] = s.intensityRange ?? [];\n\n return Float64Array.of(\n s.colorBy ? colors.indexOf(s.colorBy) : -1,\n s.pointSize,\n s.maxPointSize,\n s.sizeMode === 'fixed' ? 0 : 1,\n s.shape === 'square' ? 0 : 1,\n edl ? (edl.strength ?? 1) : 0,\n edl?.radius ?? 1.4,\n emin,\n emax,\n imin,\n imax,\n s.maxScreenSpaceError,\n s.pointBudget,\n rate,\n );\n};\n\n/** A point cloud (`GeoMap.addPointCloud`): COPC or 3D Tiles points; `pickFeature` gives a COPC point's attributes */\nexport class PointCloudLayer extends Layer {\n readonly url: string;\n readonly format: 'copc' | '3dtiles';\n private style: PointCloudStyle;\n private readonly options: PointCloudOptions;\n\n /** @internal */\n constructor(map: LayerHost, options: PointCloudOptions) {\n super(map);\n\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(options.url, base).href : options.url;\n this.format = options.format ?? (/\\.json(?:[?#]|$)/i.test(options.url) ? '3dtiles' : 'copc');\n this.options = options;\n\n const tiles = this.format === '3dtiles';\n\n this.style = {\n ...(options.colorBy ? { colorBy: options.colorBy } : {}),\n pointSize: options.pointSize ?? 2,\n maxPointSize: options.maxPointSize ?? 4,\n sizeMode: options.sizeMode ?? 'adaptive',\n shape: options.shape ?? 'circle',\n edl: options.edl ?? false,\n classifications: options.classifications ?? {},\n ...(options.elevationRange ? { elevationRange: options.elevationRange } : {}),\n elevationRamp: options.elevationRamp ?? ELEVATION_RAMP,\n ...(options.intensityRange ? { intensityRange: options.intensityRange } : {}),\n maxScreenSpaceError: options.maxScreenSpaceError ?? (tiles ? 16 : 1.5),\n pointBudget: options.pointBudget ?? 3_000_000,\n };\n }\n\n /** Changes the style, the rest kept */\n setStyle(style: Partial<PointCloudStyle>): void {\n this.style = { ...this.style, ...style };\n // Kept for its creation in a new engine (the GPU lost and given back), none while it has no id\n if (this.id < 0) return;\n this.apply(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n getStyle(): Readonly<PointCloudStyle> {\n return this.style;\n }\n\n /** Loading counters; undefined once removed, and while the map waits for a new engine (the GPU lost) */\n stats(): PointCloudStats | Tiles3dStats | undefined {\n if (this.id < 0) return undefined;\n\n return this.format === '3dtiles' ? this.map.engine.tiles3dStats(this.id) : this.map.engine.pointCloudStats(this.id);\n }\n\n /** What a COPC file says of itself (points, format, CRS, center, altitudes), once its head is read */\n info(): PointCloudInfo | undefined {\n return this.id < 0 || this.format === '3dtiles' ? undefined : this.map.engine.pointCloudInfo(this.id);\n }\n\n /** @internal The point picked (`pickFeature`, 'hoverfeature'): a Point at its longitude, latitude and height, its\n * attributes as properties */\n featureAt(index: number): Feature<PointCloudPoint> | undefined {\n if (this.id < 0 || this.format === '3dtiles') return undefined;\n\n const point = this.map.engine.pointCloudPoint(this.id, index);\n\n if (!point) return undefined;\n\n return {\n type: 'Feature',\n geometry: { type: 'Point', coordinates: [...point.lonLat, point.height] },\n properties: point,\n };\n }\n\n private apply(engine: Engine, id: number): void {\n const s = this.style;\n\n if (this.format === '3dtiles') {\n engine.setTiles3dStyle(id, s.maxScreenSpaceError, 1, s.pointSize, new Float32Array());\n\n return;\n }\n\n const rate = this.options.requestsPerSecond ?? (/^https?:\\/\\/data\\.geopf\\.fr\\//.test(this.url) ? 8 : 0);\n\n engine.setPointCloudStyle(\n id,\n styleNumbers(s, rate),\n classPalette(s.classifications),\n rampTexels(s.elevationRamp).rgba,\n );\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id =\n this.format === '3dtiles'\n ? engine.addTiles3d(this.url, this.style.maxScreenSpaceError)\n : engine.addPointCloud(this.url, (wkt) => pointCloudCrs(wkt, this.options));\n\n this.apply(engine, id);\n\n return id;\n }\n}\n"]}
@@ -21,4 +21,9 @@ export class RasterLayer extends Layer {
21
21
  return engine.addRaster(url, minZoom, maxZoom, opacity, saturation, size, loader, ground);
22
22
  }
23
23
  }
24
+ /** @internal Sends the raster draped on 3D layer `id` (3D Tiles, extrusions): none until its raster is on the map */
25
+ export const sendDrape = (engine, id, drape) => {
26
+ const { raster, faces = 'up', opacity = 1 } = drape ?? {};
27
+ engine.setDrape(id, raster && raster.id >= 0 ? raster.id : undefined, faces === 'all', opacity);
28
+ };
24
29
  //# sourceMappingURL=raster.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"raster.js","sourceRoot":"","sources":["../../src/layers/raster.ts"],"names":[],"mappings":"AAAA,mDAAmD;AAInD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,wCAAwC;AACxC,MAAM,OAAO,WAAY,SAAQ,KAAK;IAIjB;IAHnB,gBAAgB;IAChB,YACE,GAAc,EACG,OAGhB;QAED,KAAK,CAAC,GAAG,CAAC,CAAC;QALM,YAAO,GAAP,OAAO,CAGvB;IAGH,CAAC;IAED,wDAAwD;IACxD,QAAQ,CAAC,KAA2B;QAClC,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QAC7D,IAAI,CAAC,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,IAAI,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QACtE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;QACvF,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAC3B,CAAC;IAED,gBAAgB;IACN,MAAM,CAAC,MAAc;QAC7B,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;QAE1F,OAAO,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5F,CAAC;CACF","sourcesContent":["/** Raster tiles (basemaps, overlays) as a layer */\n\nimport type { LayerHost, RasterOptions, RasterStyle } from '../types.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport { Layer } from './layers.ts';\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' | 'before'>> & {\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, ground } = this.options;\n\n return engine.addRaster(url, minZoom, maxZoom, opacity, saturation, size, loader, ground);\n }\n}\n"]}
1
+ {"version":3,"file":"raster.js","sourceRoot":"","sources":["../../src/layers/raster.ts"],"names":[],"mappings":"AAAA,mDAAmD;AAInD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;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AAE,MAAM,IAAI,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,KAAK,KAAK,KAAK,EAAE,OAAO,CAAC,CAAC;AAClG,CAAC,CAAC","sourcesContent":["/** Raster tiles (basemaps, overlays) as a layer */\n\nimport type { Drape, LayerHost, RasterOptions, RasterStyle } from '../types.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport { Layer } from './layers.ts';\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' | 'before'>> & {\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, ground } = this.options;\n\n return engine.addRaster(url, minZoom, maxZoom, opacity, saturation, size, loader, ground);\n }\n}\n\n/** @internal Sends the raster draped on 3D layer `id` (3D Tiles, extrusions): none until its raster is on the map */\nexport const sendDrape = (engine: Engine, id: number, drape: Drape | undefined): void => {\n const { raster, faces = 'up', opacity = 1 } = drape ?? {};\n\n engine.setDrape(id, raster && raster.id >= 0 ? raster.id : undefined, faces === 'all', opacity);\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  /** A 3D Tiles tileset as a layer: its style, its features picked */
2
- import type { Tiles3dDrape, Tiles3dStyle } from '../types.ts';
2
+ import type { Drape, Tiles3dStyle } from '../types.ts';
3
3
  import type { Tiles3dStats } from '../wasm/isard_webgpu.js';
4
4
  import { Layer } from './layers.ts';
5
5
  /** Textured meshes in 3D Tiles */
@@ -13,13 +13,11 @@ export declare class Tiles3dLayer extends Layer {
13
13
  * windows, as the vector tiles' buildings do: glass by day, some lit at night. Their faces near vertical are walls,
14
14
  * bays of 3 metres along them and floors of 3.2 metres from the ellipsoid (a mesh tells neither foot nor top) */
15
15
  setFacades(facades: boolean): void;
16
- /** A raster layer draped on its meshes, its roofs by default (see `Tiles3dDrape`); undefined: none */
17
- setDrape(drape: Tiles3dDrape | undefined): void;
16
+ /** A raster layer draped on its meshes, its roofs by default (see `Drape`); undefined: none */
17
+ setDrape(drape: Drape | undefined): void;
18
18
  setStyle(style: Partial<Tiles3dStyle>): void;
19
- /** Loading counters; undefined once the layer is removed, and while the engine with 3D Tiles loads (see
20
- * `GeoMapOptions.tiles3d`) */
19
+ /** Loading counters; undefined once the layer is removed, and while the map waits for a new engine (the GPU lost) */
21
20
  stats(): Tiles3dStats | undefined;
22
- private sendDrape;
23
21
  private applyStyle;
24
22
  private applyFeatureColor;
25
23
  }
@@ -2,6 +2,7 @@
2
2
  import { rgb } from "../settings.js";
3
3
  import { parseColor } from "../util/color.js";
4
4
  import { Layer } from "./layers.js";
5
+ import { sendDrape } from "./raster.js";
5
6
  /**
6
7
  * The engine's colors of a tile's features from a `featureColor`: RGBA bytes for each (alpha 0: the layer's color),
7
8
  * the CSS colors parsed once each
@@ -47,24 +48,24 @@ export class Tiles3dLayer extends Layer {
47
48
  * bays of 3 metres along them and floors of 3.2 metres from the ellipsoid (a mesh tells neither foot nor top) */
48
49
  setFacades(facades) {
49
50
  this.facades = facades;
50
- // Kept for its creation while the engine with 3D Tiles loads
51
+ // Kept for its creation in a new engine (the GPU lost and given back), none while it has no id
51
52
  if (this.id < 0)
52
53
  return;
53
54
  this.map.engine.setTiles3dFacades(this.id, facades);
54
55
  this.map.requestRender();
55
56
  }
56
- /** A raster layer draped on its meshes, its roofs by default (see `Tiles3dDrape`); undefined: none */
57
+ /** A raster layer draped on its meshes, its roofs by default (see `Drape`); undefined: none */
57
58
  setDrape(drape) {
58
59
  this.drape = drape;
59
- // Kept for its creation while the engine with 3D Tiles loads
60
+ // Kept for its creation in a new engine (the GPU lost and given back), none while it has no id
60
61
  if (this.id < 0)
61
62
  return;
62
- this.sendDrape(this.map.engine, this.id);
63
+ sendDrape(this.map.engine, this.id, drape);
63
64
  this.map.requestRender();
64
65
  }
65
66
  setStyle(style) {
66
67
  this.style = { ...this.style, ...style };
67
- // Kept for its creation while the engine with 3D Tiles loads
68
+ // Kept for its creation in a new engine (the GPU lost and given back), none while it has no id
68
69
  if (this.id < 0)
69
70
  return;
70
71
  this.applyStyle(this.map.engine, this.id);
@@ -84,8 +85,7 @@ export class Tiles3dLayer extends Layer {
84
85
  const [properties, feature] = hit;
85
86
  return { type: 'Feature', id: feature, properties: properties ?? {}, geometry: null };
86
87
  }
87
- /** Loading counters; undefined once the layer is removed, and while the engine with 3D Tiles loads (see
88
- * `GeoMapOptions.tiles3d`) */
88
+ /** Loading counters; undefined once the layer is removed, and while the map waits for a new engine (the GPU lost) */
89
89
  stats() {
90
90
  return this.id < 0 ? undefined : this.map.engine.tiles3dStats(this.id);
91
91
  }
@@ -96,17 +96,12 @@ export class Tiles3dLayer extends Layer {
96
96
  this.applyFeatureColor(engine, id);
97
97
  engine.setTiles3dFacades(id, this.facades);
98
98
  // A raster created before (on a new engine, the map relinks once every layer is there)
99
- this.sendDrape(engine, id);
99
+ sendDrape(engine, id, this.drape);
100
100
  return id;
101
101
  }
102
102
  /** @internal On a new engine, the raster may come after the tiles: draped once both are there */
103
103
  relink(engine) {
104
- this.sendDrape(engine, this.id);
105
- }
106
- sendDrape(engine, id) {
107
- const { raster, faces = 'up', opacity = 1 } = this.drape ?? {};
108
- const rasterId = raster && raster.id >= 0 ? raster.id : undefined;
109
- engine.setTiles3dDrape(id, rasterId, faces === 'all', opacity);
104
+ sendDrape(engine, this.id, this.drape);
110
105
  }
111
106
  /** @internal */
112
107
  qualityChanged() {
@@ -1 +1 @@
1
-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AmB,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACtE,sCAAsC;QACtC,MAAM,KAAK,GAAG,mBAAmB,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC;QAEhE,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnG,CAAC;IAEO,iBAAiB,CAAC,MAAc,EAAE,EAAU;QAClD,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAEpC,MAAM,CAAC,uBAAuB,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IACxF,CAAC;CACF","sourcesContent":["/** A 3D Tiles tileset as a layer: its style, its features picked */\n\nimport { rgb } from '../settings.ts';\nimport type { FeatureColor, LayerHost, Tiles3dDrape, Tiles3dStyle } from '../types.ts';\nimport { parseColor } from '../util/color.ts';\nimport type { Engine, Tiles3dStats } from '../wasm/isard_webgpu.js';\nimport type { Feature } from './features.ts';\nimport { Layer } from './layers.ts';\n\n/**\n * The engine's colors of a tile's features from a `featureColor`: RGBA bytes for each (alpha 0: the layer's color),\n * the CSS colors parsed once each\n */\nconst featureColors = (color: FeatureColor) => {\n const parsed = new Map<string, number[]>();\n const bytesOf = (css: string) => {\n const known = parsed.get(css);\n\n if (known) return known;\n\n const [r, g, b] = parseColor(css);\n const made = [r, g, b].map((c) => Math.round(c * 255)).concat(255);\n\n parsed.set(css, made);\n\n return made;\n };\n\n return (properties: Record<string, unknown>[] | undefined, count: number): Uint8Array => {\n const rgba = new Uint8Array(count * 4);\n\n Array.from({ length: count }, (_, i) => color(properties?.[i] ?? {}, i)).forEach((css, i) => {\n if (css) rgba.set(bytesOf(css), i * 4);\n });\n\n return rgba;\n };\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 private facades = false,\n private drape: Tiles3dDrape | undefined = undefined,\n ) {\n super(map);\n }\n\n /** Whether the walls of its untextured meshes (buildings without their photos, as the IGN's Bâtiments 3D) show\n * windows, as the vector tiles' buildings do: glass by day, some lit at night. Their faces near vertical are walls,\n * bays of 3 metres along them and floors of 3.2 metres from the ellipsoid (a mesh tells neither foot nor top) */\n setFacades(facades: boolean): void {\n this.facades = facades;\n // Kept for its creation while the engine with 3D Tiles loads\n if (this.id < 0) return;\n this.map.engine.setTiles3dFacades(this.id, facades);\n this.map.requestRender();\n }\n\n /** A raster layer draped on its meshes, its roofs by default (see `Tiles3dDrape`); undefined: none */\n setDrape(drape: Tiles3dDrape | undefined): void {\n this.drape = drape;\n // Kept for its creation while the engine with 3D Tiles loads\n if (this.id < 0) return;\n this.sendDrape(this.map.engine, this.id);\n this.map.requestRender();\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 // The features colored again only when their function changed: every tile asks for its colors then\n if ('featureColor' in style) this.applyFeatureColor(this.map.engine, this.id);\n this.map.requestRender();\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.map.quality.errorScale, this.geoid);\n\n this.applyStyle(engine, id);\n this.applyFeatureColor(engine, id);\n engine.setTiles3dFacades(id, this.facades);\n // A raster created before (on a new engine, the map relinks once every layer is there)\n this.sendDrape(engine, id);\n\n return id;\n }\n\n /** @internal On a new engine, the raster may come after the tiles: draped once both are there */\n override relink(engine: Engine): void {\n this.sendDrape(engine, this.id);\n }\n\n private sendDrape(engine: Engine, id: number): void {\n const { raster, faces = 'up', opacity = 1 } = this.drape ?? {};\n const rasterId = raster && raster.id >= 0 ? raster.id : undefined;\n\n engine.setTiles3dDrape(id, rasterId, faces === 'all', opacity);\n }\n\n /** @internal */\n override qualityChanged(): void {\n if (this.id >= 0) this.applyStyle(this.map.engine, this.id);\n }\n\n private applyStyle(engine: Engine, id: number): void {\n const { maxScreenSpaceError, opacity, pointSize, color } = this.style;\n // Coarser far away at a lower quality\n const error = maxScreenSpaceError * this.map.quality.errorScale;\n\n engine.setTiles3dStyle(id, error, opacity, pointSize, new Float32Array(color ? rgb(color) : []));\n }\n\n private applyFeatureColor(engine: Engine, id: number): void {\n const { featureColor } = this.style;\n\n engine.setTiles3dFeatureColors(id, featureColor ? featureColors(featureColor) : null);\n }\n}\n"]}
1
+ {"version":3,"file":"tiles3d.js","sourceRoot":"","sources":["../../src/layers/tiles3d.ts"],"names":[],"mappings":"AAAA,oEAAoE;AAEpE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CA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,CAAC;CACF","sourcesContent":["/** A 3D Tiles tileset as a layer: its style, its features picked */\n\nimport { rgb } from '../settings.ts';\nimport type { Drape, FeatureColor, LayerHost, Tiles3dStyle } from '../types.ts';\nimport { parseColor } from '../util/color.ts';\nimport type { Engine, Tiles3dStats } from '../wasm/isard_webgpu.js';\nimport type { Feature } from './features.ts';\nimport { Layer } from './layers.ts';\nimport { sendDrape } from './raster.ts';\n\n/**\n * The engine's colors of a tile's features from a `featureColor`: RGBA bytes for each (alpha 0: the layer's color),\n * the CSS colors parsed once each\n */\nconst featureColors = (color: FeatureColor) => {\n const parsed = new Map<string, number[]>();\n const bytesOf = (css: string) => {\n const known = parsed.get(css);\n\n if (known) return known;\n\n const [r, g, b] = parseColor(css);\n const made = [r, g, b].map((c) => Math.round(c * 255)).concat(255);\n\n parsed.set(css, made);\n\n return made;\n };\n\n return (properties: Record<string, unknown>[] | undefined, count: number): Uint8Array => {\n const rgba = new Uint8Array(count * 4);\n\n Array.from({ length: count }, (_, i) => color(properties?.[i] ?? {}, i)).forEach((css, i) => {\n if (css) rgba.set(bytesOf(css), i * 4);\n });\n\n return rgba;\n };\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 private facades = false,\n private drape: Drape | undefined = undefined,\n ) {\n super(map);\n }\n\n /** Whether the walls of its untextured meshes (buildings without their photos, as the IGN's Bâtiments 3D) show\n * windows, as the vector tiles' buildings do: glass by day, some lit at night. Their faces near vertical are walls,\n * bays of 3 metres along them and floors of 3.2 metres from the ellipsoid (a mesh tells neither foot nor top) */\n setFacades(facades: boolean): void {\n this.facades = facades;\n // Kept for its creation in a new engine (the GPU lost and given back), none while it has no id\n if (this.id < 0) return;\n this.map.engine.setTiles3dFacades(this.id, facades);\n this.map.requestRender();\n }\n\n /** A raster layer draped on its meshes, its roofs by default (see `Drape`); undefined: none */\n setDrape(drape: Drape | undefined): void {\n this.drape = drape;\n // Kept for its creation in a new engine (the GPU lost and given back), none while it has no id\n if (this.id < 0) return;\n sendDrape(this.map.engine, this.id, drape);\n this.map.requestRender();\n }\n\n setStyle(style: Partial<Tiles3dStyle>): void {\n this.style = { ...this.style, ...style };\n // Kept for its creation in a new engine (the GPU lost and given back), none while it has no id\n if (this.id < 0) return;\n this.applyStyle(this.map.engine, this.id);\n // The features colored again only when their function changed: every tile asks for its colors then\n if ('featureColor' in style) this.applyFeatureColor(this.map.engine, this.id);\n this.map.requestRender();\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 map waits for a new engine (the GPU lost) */\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.map.quality.errorScale, this.geoid);\n\n this.applyStyle(engine, id);\n this.applyFeatureColor(engine, id);\n engine.setTiles3dFacades(id, this.facades);\n // A raster created before (on a new engine, the map relinks once every layer is there)\n sendDrape(engine, id, this.drape);\n\n return id;\n }\n\n /** @internal On a new engine, the raster may come after the tiles: draped once both are there */\n override relink(engine: Engine): void {\n sendDrape(engine, this.id, this.drape);\n }\n\n /** @internal */\n override qualityChanged(): void {\n if (this.id >= 0) this.applyStyle(this.map.engine, this.id);\n }\n\n private applyStyle(engine: Engine, id: number): void {\n const { maxScreenSpaceError, opacity, pointSize, color } = this.style;\n // Coarser far away at a lower quality\n const error = maxScreenSpaceError * this.map.quality.errorScale;\n\n engine.setTiles3dStyle(id, error, opacity, pointSize, new Float32Array(color ? rgb(color) : []));\n }\n\n private applyFeatureColor(engine: Engine, id: number): void {\n const { featureColor } = this.style;\n\n engine.setTiles3dFeatureColors(id, featureColor ? featureColors(featureColor) : null);\n }\n}\n"]}
@@ -4,6 +4,7 @@
4
4
  * tiles again. The workers cut each vector tile into polygons and lines and style its features; the engine draws the
5
5
  * style's layers in their order, each over its zoom range.
6
6
  */
7
+ import type { Drape } from '../types.ts';
7
8
  import { type Feature, type Size } from './features.ts';
8
9
  import { Layer } from './layers.ts';
9
10
  import type { Tiles3dLayer } from './tiles3d.ts';
@@ -54,6 +55,8 @@ export declare class VectorLayer extends Layer {
54
55
  private shown;
55
56
  /** Its buildings' walls show their windows (`setFacades`) */
56
57
  private facades;
58
+ /** A raster layer draped on its buildings (`setDrape`) */
59
+ private drape;
57
60
  /** The 3D buildings drawn in place of its raised ones (`vectors({ buildings3d })`), for `map.pickFeature` */
58
61
  buildings3d: Tiles3dLayer | undefined;
59
62
  /** Resolves once the style is loaded, its layers drawn known (`layers`), and the map has drawn the layer; rejected
@@ -82,6 +85,9 @@ export declare class VectorLayer extends Layer {
82
85
  setLayoutProperty(layer: string, name: string, value: unknown): void;
83
86
  /** Whether its buildings' walls show their windows: glass by day, some lit at night (only the lit ones without) */
84
87
  setFacades(facades: boolean): void;
88
+ /** A raster layer draped on its buildings, their roofs by default (see `Drape`); undefined: none. Its 3D buildings'
89
+ * too */
90
+ setDrape(drape: Drape | undefined): void;
85
91
  setVisible(visible: boolean): void;
86
92
  private sendSublayers;
87
93
  /** A tile to the engine: its mesh uploaded as it is, or without one its geometry, which the engine makes ready */
@@ -7,6 +7,7 @@
7
7
  import { FLOATS } from "../util/style-floats.js";
8
8
  import { stops } from "./features.js";
9
9
  import { Layer } from "./layers.js";
10
+ import { sendDrape } from "./raster.js";
10
11
  /** The main thread's time a frame gives to uploading tiles (ms): tiles arriving together are uploaded over several
11
12
  * frames, not all in the one (copying a tile's buffers to the GPU takes milliseconds) */
12
13
  const UPLOAD_MS = 4;
@@ -21,6 +22,8 @@ export class VectorLayer extends Layer {
21
22
  shown = true;
22
23
  /** Its buildings' walls show their windows (`setFacades`) */
23
24
  facades = false;
25
+ /** A raster layer draped on its buildings (`setDrape`) */
26
+ drape = undefined;
24
27
  /** @internal Resolved once the style is loaded and its layers drawn known (set by its `VectorTiles`) */
25
28
  styled = Promise.resolve();
26
29
  /** @internal Changes a property of a style layer drawn (set by its `VectorTiles`) */
@@ -183,6 +186,14 @@ export class VectorLayer extends Layer {
183
186
  this.buildings3d?.setFacades(facades);
184
187
  this.map.requestRender();
185
188
  }
189
+ /** A raster layer draped on its buildings, their roofs by default (see `Drape`); undefined: none. Its 3D buildings'
190
+ * too */
191
+ setDrape(drape) {
192
+ this.drape = drape;
193
+ sendDrape(this.map.engine, this.id, drape);
194
+ this.buildings3d?.setDrape(drape);
195
+ this.map.requestRender();
196
+ }
186
197
  setVisible(visible) {
187
198
  this.shown = visible;
188
199
  this.sendSublayers(this.map.engine, this.id);
@@ -211,11 +222,17 @@ export class VectorLayer extends Layer {
211
222
  const id = engine.addVectorTiles();
212
223
  this.sendSublayers(engine, id);
213
224
  engine.setFacades(id, this.facades);
214
- // An engine made anew (after a context loss, or the one with 3D Tiles): its tiles cut again by the workers, once
225
+ // A raster created before (on a new engine, the map relinks once every layer is there)
226
+ sendDrape(engine, id, this.drape);
227
+ // An engine made anew (after a context loss): its tiles cut again by the workers, once
215
228
  // the layer has its id there. Keeping their geometry here would double the memory they take
216
229
  this.dispose();
217
230
  queueMicrotask(() => this.recut?.());
218
231
  return id;
219
232
  }
233
+ /** @internal On a new engine, the raster may come after the layer: draped once both are there */
234
+ relink(engine) {
235
+ sendDrape(engine, this.id, this.drape);
236
+ }
220
237
  }
221
238
  //# sourceMappingURL=vectors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vectors.js","sourceRoot":"","sources":["../../src/layers/vectors.ts"],"names":[],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drawn as geometry, tile by tile (`VectorTiles.vectors`), instead of into the\n * images of a raster layer: sharp at any zoom and pitch, on the relief, picked by feature, restyled without cutting the\n * tiles again. The workers cut each vector tile into polygons and lines and style its features; the engine draws the\n * style's layers in their order, each over its zoom range.\n */\n\nimport type { LayerHost } from '../types.ts';\nimport { FLOATS } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport type { TileVectors } from '../workers/basemap/protocol.ts';\nimport { type Feature, type Size, stops } from './features.ts';\nimport { Layer } from './layers.ts';\nimport type { Tiles3dLayer } from './tiles3d.ts';\n\n/** A style layer as the engine draws it: its kind, zoom range, visibility and dashes (dash, gap, dash, gap, in line\n * widths; zeros: solid) */\nexport interface VectorSublayer {\n /** The style layer's id */\n id: string;\n /** Its source layer, if any (not for a background) */\n sourceLayer: string | undefined;\n kind: 'fill' | 'line' | 'extrusion' | 'circle';\n minZoom: number;\n maxZoom: number;\n visible: boolean;\n /** Its opacity when it depends on the zoom only, evaluated at the camera's zoom (else 1: the features' colors hold\n * it) */\n opacity: Size;\n dash: [number, number, number, number];\n /** The caps of its lines' ends (`line-cap`) */\n cap: 'butt' | 'round' | 'square';\n /** The joins of its lines' pieces (`line-join`), a miter longer than `miterLimit` line widths bevelled\n * (`line-miter-limit`); round and 2 if left out */\n join?: 'miter' | 'bevel' | 'round';\n miterLimit?: number;\n /** How far its fills or lines move on screen (`fill-translate`, `line-translate`: CSS pixels, x right, y down),\n * turning with the map or staying on the screen (`*-translate-anchor`); none and `map` if left out */\n translate?: [number, number];\n translateAnchor?: 'map' | 'viewport';\n /** Its fills have patterns (`fill-pattern`, `background-pattern`): over the relief, the engine finds the ground under\n * them */\n patterned?: boolean;\n /** Its lines glow at night (the streets: its id names a road, not its casing; `setSun`) */\n lit: boolean;\n}\n\n/** The properties of a picked feature, with the style layer that drew it */\nexport type VectorFeature = Feature<Record<string, unknown>> & { layer: string; sourceLayer: string | undefined };\n\n/** The main thread's time a frame gives to uploading tiles (ms): tiles arriving together are uploaded over several\n * frames, not all in the one (copying a tile's buffers to the GPU takes milliseconds) */\nconst UPLOAD_MS = 4;\n\ninterface Tile {\n /** Its number in the engine: tiles are numbered for picking in this order */\n key: number;\n /** What picking needs (its geometry and styles are the engine's only: an engine made anew asks the tiles again) */\n vectors: Pick<TileVectors, 'properties' | 'sublayer'>;\n}\n\nexport class VectorLayer extends Layer {\n private readonly tiles = new Map<string, Tile>();\n /** The tiles waiting for their upload (`UPLOAD_MS` a frame), each with what resolves its `setTile` */\n private readonly queue = new Map<string, { vectors: TileVectors; uploaded: () => void }>();\n private flushing = false;\n private sublayers: VectorSublayer[] = [];\n private nextKey = 0;\n /** The whole layer shown (`setVisible`), over each style layer's visibility */\n private shown = true;\n /** Its buildings' walls show their windows (`setFacades`) */\n private facades = false;\n /** @internal Resolved once the style is loaded and its layers drawn known (set by its `VectorTiles`) */\n styled: Promise<void> = Promise.resolve();\n /** @internal Changes a property of a style layer drawn (set by its `VectorTiles`) */\n restyle: ((layer: string, group: 'paint' | 'layout', name: string, value: unknown) => void) | undefined;\n /** @internal Asks the workers for the tiles in view again (set by its `VectorTiles`): an engine made anew has none */\n recut: (() => void) | undefined;\n /** @internal Asks for the tiles in view (set by its `VectorTiles`): those of a new quality */\n refresh: (() => void) | undefined;\n /** The 3D buildings drawn in place of its raised ones (`vectors({ buildings3d })`), for `map.pickFeature` */\n buildings3d: Tiles3dLayer | undefined;\n\n /** @internal */\n constructor(map: LayerHost) {\n super(map);\n }\n\n /** @internal Its tiles as far as the map's quality reaches */\n override qualityChanged(): void {\n this.refresh?.();\n }\n\n /** Resolves once the style is loaded, its layers drawn known (`layers`), and the map has drawn the layer; rejected\n * if the style fails */\n override get ready(): Promise<void> {\n return this.styled.then(() => super.ready);\n }\n\n /** The style layers drawn, in order */\n get layers(): readonly VectorSublayer[] {\n return this.sublayers;\n }\n\n /** Keys of the tiles held (`z/x/y`) */\n get tileKeys(): string[] {\n return [...this.tiles.keys()];\n }\n\n /** @internal Sets the style layers drawn, in order (the tiles' sublayers) */\n setSublayers(sublayers: VectorSublayer[]): void {\n this.sublayers = sublayers;\n this.sendSublayers(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** @internal Adds or replaces a tile, cut by the workers (and made ready for the GPU there, with its mesh): uploaded\n * on a coming frame, within its share of the frame (`UPLOAD_MS`); resolves once it is (or once dropped meanwhile) */\n setTile(tile: string, vectors: TileVectors): Promise<void> {\n if (this.removed) return Promise.resolve();\n // The map not idle until it is uploaded\n return this.map.track(\n new Promise((uploaded) => {\n // A newer cut of a tile still waiting takes its place\n this.queue.get(tile)?.uploaded();\n this.queue.set(tile, { vectors, uploaded });\n this.flushSoon();\n }),\n );\n }\n\n /** Uploads the waiting tiles on the next frame */\n private flushSoon(): void {\n if (this.flushing) return;\n this.flushing = true;\n requestAnimationFrame(() => {\n this.flushing = false;\n this.flush();\n });\n }\n\n /** Uploads waiting tiles for `UPLOAD_MS` at most (one at least), the rest on the next frames; a tile's `setTile`\n * resolves once it is there */\n private flush(): void {\n // Removed meanwhile, or between two engines (the new one asks for the tiles again)\n if (this.id < 0) return;\n\n const start = performance.now();\n\n for (const [tile, waiting] of this.queue) {\n this.upload(tile, waiting.vectors);\n this.queue.delete(tile);\n waiting.uploaded();\n if (performance.now() - start > UPLOAD_MS) break;\n }\n if (this.queue.size > 0) this.flushSoon();\n this.map.requestRender();\n }\n\n /** Sends a tile to the engine (its blocks whole, mapped at their buffer's creation); its key */\n private upload(tile: string, vectors: TileVectors): number {\n const key = this.tiles.get(tile)?.key ?? this.nextKey++;\n const { properties, sublayer } = vectors;\n\n this.tiles.set(tile, { key, vectors: { properties, sublayer } });\n this.sendTile(this.map.engine, this.id, key, vectors);\n\n return key;\n }\n\n /** @internal New styles of a tile's features, as the workers evaluated them (the same features) */\n setTileStyles(tile: string, styles: Float32Array): void {\n const waiting = this.queue.get(tile);\n\n // Not uploaded yet: uploaded with them\n if (waiting) {\n if (styles.length === waiting.vectors.properties.length * FLOATS) waiting.vectors.styles = styles;\n\n return;\n }\n\n const t = this.tiles.get(tile);\n\n if (!t || styles.length !== t.vectors.properties.length * FLOATS) return;\n this.map.engine.setFeatureStyle(this.id, styles, t.key);\n this.map.requestRender();\n }\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal The tiles waiting resolved (dropped), none held */\n override dispose(): void {\n this.queue.forEach((waiting) => {\n waiting.uploaded();\n });\n this.queue.clear();\n this.tiles.clear();\n }\n\n /** @internal */\n removeTile(tile: string): void {\n this.queue.get(tile)?.uploaded();\n this.queue.delete(tile);\n\n const t = this.tiles.get(tile);\n\n if (!t) return;\n this.tiles.delete(tile);\n this.map.engine.removeVectorTile(this.id, t.key);\n this.map.requestRender();\n }\n\n /** The feature of a picked index (no geometry: the tiles hold it cut), its properties and style layer. Tiles are\n * numbered one after the other, in the order they were first added */\n featureAt(index: number): VectorFeature | undefined {\n const tiles = [...this.tiles.values()].sort((a, b) => a.key - b.key);\n // The tile holding the index, and the index among its features (one pass, the features of the tiles before\n // taken off)\n const { tile, rest } = tiles.reduce<{ tile?: Tile; rest: number }>(\n (found, t) => {\n if (found.tile) return found;\n\n const count = t.vectors.properties.length;\n\n return found.rest < count ? { tile: t, rest: found.rest } : { rest: found.rest - count };\n },\n { rest: index },\n );\n\n if (!tile) return undefined;\n\n const properties = tile.vectors.properties[rest];\n const sublayer = this.sublayers[tile.vectors.sublayer[rest] ?? -1];\n\n if (properties === undefined || !sublayer) return undefined;\n\n return { type: 'Feature', properties, geometry: null, layer: sublayer.id, sourceLayer: sublayer.sourceLayer };\n }\n\n /** Changes a paint property of a style layer drawn, as MapLibre's `setPaintProperty`: the tiles are restyled, not cut\n * again */\n setPaintProperty(layer: string, name: string, value: unknown): void {\n this.restyle?.(layer, 'paint', name, value);\n }\n\n /** Changes a layout property of a style layer drawn (`visibility`: shown or hidden at once), as MapLibre's\n * `setLayoutProperty` */\n setLayoutProperty(layer: string, name: string, value: unknown): void {\n this.restyle?.(layer, 'layout', name, value);\n }\n\n /** Whether its buildings' walls show their windows: glass by day, some lit at night (only the lit ones without) */\n setFacades(facades: boolean): void {\n this.facades = facades;\n this.map.engine.setFacades(this.id, facades);\n // Its 3D buildings' walls too\n this.buildings3d?.setFacades(facades);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.shown = visible;\n this.sendSublayers(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n private sendSublayers(engine: Engine, id: number): void {\n const s = this.sublayers;\n\n engine.setVectorSublayers(\n id,\n Uint8Array.from(s, (l) => ({ fill: 0, line: 1, extrusion: 2, circle: 3 })[l.kind]),\n Float64Array.from(s.flatMap((l) => [l.minZoom, l.maxZoom])),\n Uint8Array.from(s, (l) => (l.visible && this.shown ? 1 : 0)),\n Float32Array.from(s.flatMap((l) => l.dash)),\n Float32Array.from(s.flatMap((l) => stops(l.opacity))),\n Uint8Array.from(s, (l) => ({ butt: 0, round: 1, square: 2 })[l.cap]),\n Uint8Array.from(s, (l) => (l.lit ? 1 : 0)),\n Float32Array.from(s.flatMap((l) => [{ round: 0, miter: 1, bevel: 2 }[l.join ?? 'round'], l.miterLimit ?? 2])),\n Float32Array.from(s.flatMap((l) => [...(l.translate ?? [0, 0]), l.translateAnchor === 'viewport' ? 1 : 0])),\n Uint8Array.from(s, (l) => (l.patterned ? 1 : 0)),\n );\n }\n\n /** A tile to the engine: its mesh uploaded as it is, or without one its geometry, which the engine makes ready */\n private sendTile(engine: Engine, id: number, key: number, vectors: TileVectors): void {\n const { fills, lines, circles, styles, sublayer, mesh } = vectors;\n\n if (mesh) {\n engine.setVectorTileMesh(\n id,\n key,\n fills.points,\n fills.ringStart,\n fills.polygonStart,\n fills.feature,\n fills.fillStart,\n mesh.vertices,\n mesh.indices,\n mesh.fillRanges,\n mesh.prism,\n mesh.pieces,\n mesh.lineTable,\n mesh.lineRanges,\n mesh.blocks,\n mesh.blockIndices,\n mesh.blockRanges,\n mesh.bounds,\n sublayer,\n );\n } else {\n engine.setVectorTile(\n id,\n key,\n fills.points,\n fills.ringStart,\n fills.polygonStart,\n fills.feature,\n fills.fillStart,\n lines.points,\n lines.start,\n lines.feature,\n lines.lineStart,\n sublayer,\n vectors.tile ?? new Float64Array(),\n fills.roofs ?? new Uint8Array(),\n fills.roofHeights ?? new Float32Array(),\n fills.roofOutlines ?? new Float64Array(),\n fills.roofOutlineStart ?? new Uint32Array(),\n fills.roofMetres ?? 0,\n );\n }\n // The circles' points, once the tile is there\n if (circles) engine.setVectorTilePoints(id, key, circles.points, circles.feature, circles.circleStart);\n engine.setFeatureStyle(id, styles, key);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addVectorTiles();\n\n this.sendSublayers(engine, id);\n engine.setFacades(id, this.facades);\n // An engine made anew (after a context loss, or the one with 3D Tiles): its tiles cut again by the workers, once\n // the layer has its id there. Keeping their geometry here would double the memory they take\n this.dispose();\n queueMicrotask(() => this.recut?.());\n\n return id;\n }\n}\n"]}
1
+ {"version":3,"file":"vectors.js","sourceRoot":"","sources":["../../src/layers/vectors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGjD,OAAO,EAA2B,KAAK,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAsCxC;yFACyF;AACzF,MAAM,SAAS,GAAG,CAAC,CAAC;AASpB,MAAM,OAAO,WAAY,SAAQ,KAAK;IACnB,KAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IACjD,sGAAsG;IACrF,KAAK,GAAG,IAAI,GAAG,EAA0D,CAAC;IACnF,QAAQ,GAAG,KAAK,CAAC;IACjB,SAAS,GAAqB,EAAE,CAAC;IACjC,OAAO,GAAG,CAAC,CAAC;IACpB,+EAA+E;IACvE,KAAK,GAAG,IAAI,CAAC;IACrB,6DAA6D;IACrD,OAAO,GAAG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","sourcesContent":["/**\n * The fills and lines of a MapLibre style drawn as geometry, tile by tile (`VectorTiles.vectors`), instead of into the\n * images of a raster layer: sharp at any zoom and pitch, on the relief, picked by feature, restyled without cutting the\n * tiles again. The workers cut each vector tile into polygons and lines and style its features; the engine draws the\n * style's layers in their order, each over its zoom range.\n */\n\nimport type { Drape, LayerHost } from '../types.ts';\nimport { FLOATS } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport type { TileVectors } from '../workers/basemap/protocol.ts';\nimport { type Feature, type Size, stops } from './features.ts';\nimport { Layer } from './layers.ts';\nimport { sendDrape } from './raster.ts';\nimport type { Tiles3dLayer } from './tiles3d.ts';\n\n/** A style layer as the engine draws it: its kind, zoom range, visibility and dashes (dash, gap, dash, gap, in line\n * widths; zeros: solid) */\nexport interface VectorSublayer {\n /** The style layer's id */\n id: string;\n /** Its source layer, if any (not for a background) */\n sourceLayer: string | undefined;\n kind: 'fill' | 'line' | 'extrusion' | 'circle';\n minZoom: number;\n maxZoom: number;\n visible: boolean;\n /** Its opacity when it depends on the zoom only, evaluated at the camera's zoom (else 1: the features' colors hold\n * it) */\n opacity: Size;\n dash: [number, number, number, number];\n /** The caps of its lines' ends (`line-cap`) */\n cap: 'butt' | 'round' | 'square';\n /** The joins of its lines' pieces (`line-join`), a miter longer than `miterLimit` line widths bevelled\n * (`line-miter-limit`); round and 2 if left out */\n join?: 'miter' | 'bevel' | 'round';\n miterLimit?: number;\n /** How far its fills or lines move on screen (`fill-translate`, `line-translate`: CSS pixels, x right, y down),\n * turning with the map or staying on the screen (`*-translate-anchor`); none and `map` if left out */\n translate?: [number, number];\n translateAnchor?: 'map' | 'viewport';\n /** Its fills have patterns (`fill-pattern`, `background-pattern`): over the relief, the engine finds the ground under\n * them */\n patterned?: boolean;\n /** Its lines glow at night (the streets: its id names a road, not its casing; `setSun`) */\n lit: boolean;\n}\n\n/** The properties of a picked feature, with the style layer that drew it */\nexport type VectorFeature = Feature<Record<string, unknown>> & { layer: string; sourceLayer: string | undefined };\n\n/** The main thread's time a frame gives to uploading tiles (ms): tiles arriving together are uploaded over several\n * frames, not all in the one (copying a tile's buffers to the GPU takes milliseconds) */\nconst UPLOAD_MS = 4;\n\ninterface Tile {\n /** Its number in the engine: tiles are numbered for picking in this order */\n key: number;\n /** What picking needs (its geometry and styles are the engine's only: an engine made anew asks the tiles again) */\n vectors: Pick<TileVectors, 'properties' | 'sublayer'>;\n}\n\nexport class VectorLayer extends Layer {\n private readonly tiles = new Map<string, Tile>();\n /** The tiles waiting for their upload (`UPLOAD_MS` a frame), each with what resolves its `setTile` */\n private readonly queue = new Map<string, { vectors: TileVectors; uploaded: () => void }>();\n private flushing = false;\n private sublayers: VectorSublayer[] = [];\n private nextKey = 0;\n /** The whole layer shown (`setVisible`), over each style layer's visibility */\n private shown = true;\n /** Its buildings' walls show their windows (`setFacades`) */\n private facades = false;\n /** A raster layer draped on its buildings (`setDrape`) */\n private drape: Drape | undefined = undefined;\n /** @internal Resolved once the style is loaded and its layers drawn known (set by its `VectorTiles`) */\n styled: Promise<void> = Promise.resolve();\n /** @internal Changes a property of a style layer drawn (set by its `VectorTiles`) */\n restyle: ((layer: string, group: 'paint' | 'layout', name: string, value: unknown) => void) | undefined;\n /** @internal Asks the workers for the tiles in view again (set by its `VectorTiles`): an engine made anew has none */\n recut: (() => void) | undefined;\n /** @internal Asks for the tiles in view (set by its `VectorTiles`): those of a new quality */\n refresh: (() => void) | undefined;\n /** The 3D buildings drawn in place of its raised ones (`vectors({ buildings3d })`), for `map.pickFeature` */\n buildings3d: Tiles3dLayer | undefined;\n\n /** @internal */\n constructor(map: LayerHost) {\n super(map);\n }\n\n /** @internal Its tiles as far as the map's quality reaches */\n override qualityChanged(): void {\n this.refresh?.();\n }\n\n /** Resolves once the style is loaded, its layers drawn known (`layers`), and the map has drawn the layer; rejected\n * if the style fails */\n override get ready(): Promise<void> {\n return this.styled.then(() => super.ready);\n }\n\n /** The style layers drawn, in order */\n get layers(): readonly VectorSublayer[] {\n return this.sublayers;\n }\n\n /** Keys of the tiles held (`z/x/y`) */\n get tileKeys(): string[] {\n return [...this.tiles.keys()];\n }\n\n /** @internal Sets the style layers drawn, in order (the tiles' sublayers) */\n setSublayers(sublayers: VectorSublayer[]): void {\n this.sublayers = sublayers;\n this.sendSublayers(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** @internal Adds or replaces a tile, cut by the workers (and made ready for the GPU there, with its mesh): uploaded\n * on a coming frame, within its share of the frame (`UPLOAD_MS`); resolves once it is (or once dropped meanwhile) */\n setTile(tile: string, vectors: TileVectors): Promise<void> {\n if (this.removed) return Promise.resolve();\n // The map not idle until it is uploaded\n return this.map.track(\n new Promise((uploaded) => {\n // A newer cut of a tile still waiting takes its place\n this.queue.get(tile)?.uploaded();\n this.queue.set(tile, { vectors, uploaded });\n this.flushSoon();\n }),\n );\n }\n\n /** Uploads the waiting tiles on the next frame */\n private flushSoon(): void {\n if (this.flushing) return;\n this.flushing = true;\n requestAnimationFrame(() => {\n this.flushing = false;\n this.flush();\n });\n }\n\n /** Uploads waiting tiles for `UPLOAD_MS` at most (one at least), the rest on the next frames; a tile's `setTile`\n * resolves once it is there */\n private flush(): void {\n // Removed meanwhile, or between two engines (the new one asks for the tiles again)\n if (this.id < 0) return;\n\n const start = performance.now();\n\n for (const [tile, waiting] of this.queue) {\n this.upload(tile, waiting.vectors);\n this.queue.delete(tile);\n waiting.uploaded();\n if (performance.now() - start > UPLOAD_MS) break;\n }\n if (this.queue.size > 0) this.flushSoon();\n this.map.requestRender();\n }\n\n /** Sends a tile to the engine (its blocks whole, mapped at their buffer's creation); its key */\n private upload(tile: string, vectors: TileVectors): number {\n const key = this.tiles.get(tile)?.key ?? this.nextKey++;\n const { properties, sublayer } = vectors;\n\n this.tiles.set(tile, { key, vectors: { properties, sublayer } });\n this.sendTile(this.map.engine, this.id, key, vectors);\n\n return key;\n }\n\n /** @internal New styles of a tile's features, as the workers evaluated them (the same features) */\n setTileStyles(tile: string, styles: Float32Array): void {\n const waiting = this.queue.get(tile);\n\n // Not uploaded yet: uploaded with them\n if (waiting) {\n if (styles.length === waiting.vectors.properties.length * FLOATS) waiting.vectors.styles = styles;\n\n return;\n }\n\n const t = this.tiles.get(tile);\n\n if (!t || styles.length !== t.vectors.properties.length * FLOATS) return;\n this.map.engine.setFeatureStyle(this.id, styles, t.key);\n this.map.requestRender();\n }\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal The tiles waiting resolved (dropped), none held */\n override dispose(): void {\n this.queue.forEach((waiting) => {\n waiting.uploaded();\n });\n this.queue.clear();\n this.tiles.clear();\n }\n\n /** @internal */\n removeTile(tile: string): void {\n this.queue.get(tile)?.uploaded();\n this.queue.delete(tile);\n\n const t = this.tiles.get(tile);\n\n if (!t) return;\n this.tiles.delete(tile);\n this.map.engine.removeVectorTile(this.id, t.key);\n this.map.requestRender();\n }\n\n /** The feature of a picked index (no geometry: the tiles hold it cut), its properties and style layer. Tiles are\n * numbered one after the other, in the order they were first added */\n featureAt(index: number): VectorFeature | undefined {\n const tiles = [...this.tiles.values()].sort((a, b) => a.key - b.key);\n // The tile holding the index, and the index among its features (one pass, the features of the tiles before\n // taken off)\n const { tile, rest } = tiles.reduce<{ tile?: Tile; rest: number }>(\n (found, t) => {\n if (found.tile) return found;\n\n const count = t.vectors.properties.length;\n\n return found.rest < count ? { tile: t, rest: found.rest } : { rest: found.rest - count };\n },\n { rest: index },\n );\n\n if (!tile) return undefined;\n\n const properties = tile.vectors.properties[rest];\n const sublayer = this.sublayers[tile.vectors.sublayer[rest] ?? -1];\n\n if (properties === undefined || !sublayer) return undefined;\n\n return { type: 'Feature', properties, geometry: null, layer: sublayer.id, sourceLayer: sublayer.sourceLayer };\n }\n\n /** Changes a paint property of a style layer drawn, as MapLibre's `setPaintProperty`: the tiles are restyled, not cut\n * again */\n setPaintProperty(layer: string, name: string, value: unknown): void {\n this.restyle?.(layer, 'paint', name, value);\n }\n\n /** Changes a layout property of a style layer drawn (`visibility`: shown or hidden at once), as MapLibre's\n * `setLayoutProperty` */\n setLayoutProperty(layer: string, name: string, value: unknown): void {\n this.restyle?.(layer, 'layout', name, value);\n }\n\n /** Whether its buildings' walls show their windows: glass by day, some lit at night (only the lit ones without) */\n setFacades(facades: boolean): void {\n this.facades = facades;\n this.map.engine.setFacades(this.id, facades);\n // Its 3D buildings' walls too\n this.buildings3d?.setFacades(facades);\n this.map.requestRender();\n }\n\n /** A raster layer draped on its buildings, their roofs by default (see `Drape`); undefined: none. Its 3D buildings'\n * too */\n setDrape(drape: Drape | undefined): void {\n this.drape = drape;\n sendDrape(this.map.engine, this.id, drape);\n this.buildings3d?.setDrape(drape);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.shown = visible;\n this.sendSublayers(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n private sendSublayers(engine: Engine, id: number): void {\n const s = this.sublayers;\n\n engine.setVectorSublayers(\n id,\n Uint8Array.from(s, (l) => ({ fill: 0, line: 1, extrusion: 2, circle: 3 })[l.kind]),\n Float64Array.from(s.flatMap((l) => [l.minZoom, l.maxZoom])),\n Uint8Array.from(s, (l) => (l.visible && this.shown ? 1 : 0)),\n Float32Array.from(s.flatMap((l) => l.dash)),\n Float32Array.from(s.flatMap((l) => stops(l.opacity))),\n Uint8Array.from(s, (l) => ({ butt: 0, round: 1, square: 2 })[l.cap]),\n Uint8Array.from(s, (l) => (l.lit ? 1 : 0)),\n Float32Array.from(s.flatMap((l) => [{ round: 0, miter: 1, bevel: 2 }[l.join ?? 'round'], l.miterLimit ?? 2])),\n Float32Array.from(s.flatMap((l) => [...(l.translate ?? [0, 0]), l.translateAnchor === 'viewport' ? 1 : 0])),\n Uint8Array.from(s, (l) => (l.patterned ? 1 : 0)),\n );\n }\n\n /** A tile to the engine: its mesh uploaded as it is, or without one its geometry, which the engine makes ready */\n private sendTile(engine: Engine, id: number, key: number, vectors: TileVectors): void {\n const { fills, lines, circles, styles, sublayer, mesh } = vectors;\n\n if (mesh) {\n engine.setVectorTileMesh(\n id,\n key,\n fills.points,\n fills.ringStart,\n fills.polygonStart,\n fills.feature,\n fills.fillStart,\n mesh.vertices,\n mesh.indices,\n mesh.fillRanges,\n mesh.prism,\n mesh.pieces,\n mesh.lineTable,\n mesh.lineRanges,\n mesh.blocks,\n mesh.blockIndices,\n mesh.blockRanges,\n mesh.bounds,\n sublayer,\n );\n } else {\n engine.setVectorTile(\n id,\n key,\n fills.points,\n fills.ringStart,\n fills.polygonStart,\n fills.feature,\n fills.fillStart,\n lines.points,\n lines.start,\n lines.feature,\n lines.lineStart,\n sublayer,\n vectors.tile ?? new Float64Array(),\n fills.roofs ?? new Uint8Array(),\n fills.roofHeights ?? new Float32Array(),\n fills.roofOutlines ?? new Float64Array(),\n fills.roofOutlineStart ?? new Uint32Array(),\n fills.roofMetres ?? 0,\n );\n }\n // The circles' points, once the tile is there\n if (circles) engine.setVectorTilePoints(id, key, circles.points, circles.feature, circles.circleStart);\n engine.setFeatureStyle(id, styles, key);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addVectorTiles();\n\n this.sendSublayers(engine, id);\n engine.setFacades(id, this.facades);\n // A raster created before (on a new engine, the map relinks once every layer is there)\n sendDrape(engine, id, this.drape);\n // An engine made anew (after a context loss): its tiles cut again by the workers, once\n // the layer has its id there. Keeping their geometry here would double the memory they take\n this.dispose();\n queueMicrotask(() => this.recut?.());\n\n return id;\n }\n /** @internal On a new engine, the raster may come after the layer: draped once both are there */\n override relink(engine: Engine): void {\n sendDrape(engine, this.id, this.drape);\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The settings of the map's engine: made from the options, given to each new engine (at creation, and again after a
3
- * context loss or once the engine with 3D Tiles is loaded), with the page's request headers.
3
+ * context loss), with the page's request headers.
4
4
  */
5
5
  import type { PngEncoding } from '../basemap/terrain.ts';
6
6
  import { type Settings, type TerrainLoader } from '../settings.ts';
@@ -9,6 +9,9 @@ import { type HeaderRules } from '../util/requests.ts';
9
9
  import type { Engine } from '../wasm/isard_webgpu.js';
10
10
  /** The settings of a map from its options; `earth`: the map is of the Earth */
11
11
  export declare const mapSettings: (options: GeoMapOptions, earth: boolean, terrainLoader: (url: string, encoding: PngEncoding, floor?: number) => TerrainLoader) => Settings;
12
+ /** A map's GPU memory budget in bytes (`GeoMapOptions.memory`): `'auto'` lower on a touch screen, a phone's or a
13
+ * tablet's */
14
+ export declare const memoryBudget: (memory: number | "auto" | undefined) => number;
12
15
  /** Gives a new engine the settings and the page's request headers */
13
16
  export declare const applySettings: (engine: Engine, settings: Settings) => void;
14
17
  /** The page's request headers to an engine (its own requests: raster tiles, tilesets, point clouds) */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The settings of the map's engine: made from the options, given to each new engine (at creation, and again after a
3
- * context loss or once the engine with 3D Tiles is loaded), with the page's request headers.
3
+ * context loss), with the page's request headers.
4
4
  */
5
5
  import { SEA } from "../basemap/basemaps.js";
6
6
  import { atmosphereSettings, bodySettings, haloSettings, rgb, terrainSettings, } from "../settings.js";
@@ -17,17 +17,28 @@ export const mapSettings = (options, earth, terrainLoader) => {
17
17
  atmosphere: atmosphereSettings(options.atmosphere),
18
18
  terrain: terrainSettings(options.terrain, options.body, body.radius, terrainLoader),
19
19
  loading: options.loading ?? 'immediate',
20
+ memory: memoryBudget(options.memory),
20
21
  background: rgb(options.background ?? (earth ? '#f2f2f0' : '#000000')),
21
22
  globeColor: earth ? SEA['osm-positron'] : rgb(body.color),
22
23
  };
23
24
  };
25
+ /** A map's GPU memory budget in bytes (`GeoMapOptions.memory`): `'auto'` lower on a touch screen, a phone's or a
26
+ * tablet's */
27
+ export const memoryBudget = (memory) => {
28
+ if (typeof memory === 'number' && memory > 0)
29
+ return memory * 2 ** 20;
30
+ const touch = typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;
31
+ return (touch ? 256 : 1024) * 2 ** 20;
32
+ };
24
33
  /** Gives a new engine the settings and the page's request headers */
25
34
  export const applySettings = (engine, settings) => {
26
35
  // The body first: the layers' shaders may take its size
27
36
  const { radius, flattening, atmosphere: air, relief } = settings.body;
28
37
  engine.setBody(radius, flattening, haloSettings(air), ...relief);
29
38
  sendHeaders(engine, headerRules());
30
- const { zoomRange, maxPitch, globe, sky, atmosphere, terrain, loading, background, globeColor } = settings;
39
+ const { zoomRange, maxPitch, globe, sky, atmosphere, terrain, loading, memory, background, globeColor } = settings;
40
+ // Before the layers: a raster's pool takes the budget as it is when the raster is made
41
+ engine.setMemoryBudget(memory);
31
42
  engine.setZoomRange(...zoomRange);
32
43
  engine.setMaxPitch(maxPitch);
33
44
  engine.setGlobe(globe);
@@ -1 +1 @@
1
- {"version":3,"file":"engine-settings.js","sourceRoot":"","sources":["../../src/map/engine-settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,GAAG,EAGH,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAoB,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAGpE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAsB,EACtB,KAAc,EACd,aAAoF,EAC1E,EAAE;IACZ,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,CAAC,OAAO,CAAC,OAAO,IAAI,CAAC,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;QACxD,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE;QAChC,KAAK,EAAE,CAAC,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,KAAK,OAAO;QAClD,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,IAAI;QACxB,UAAU,EAAE,kBAAkB,CAAC,OAAO,CAAC,UAAU,CA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CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/G,MAAM,CAAC,mBAAmB,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC;IACpD,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,CAAC;IACpC,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,uGAAuG;AACvG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,KAAkB,EAAQ,EAAE;IACtE,MAAM,CAAC,iBAAiB,CACtB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,EAC/B,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EACrE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAC/D,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * The settings of the map's engine: made from the options, given to each new engine (at creation, and again after a\n * context loss or once the engine with 3D Tiles is loaded), with the page's request headers.\n */\n\nimport { SEA } from '../basemap/basemaps.ts';\nimport type { PngEncoding } from '../basemap/terrain.ts';\nimport {\n atmosphereSettings,\n bodySettings,\n haloSettings,\n rgb,\n type Settings,\n type TerrainLoader,\n terrainSettings,\n} from '../settings.ts';\nimport type { GeoMapOptions } from '../types.ts';\nimport { type HeaderRules, headerRules } from '../util/requests.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\n\n/** The settings of a map from its options; `earth`: the map is of the Earth */\nexport const mapSettings = (\n options: GeoMapOptions,\n earth: boolean,\n terrainLoader: (url: string, encoding: PngEncoding, floor?: number) => TerrainLoader,\n): Settings => {\n const body = bodySettings(options.body);\n\n return {\n body,\n zoomRange: [options.minZoom ?? 0, options.maxZoom ?? 22],\n maxPitch: options.maxPitch ?? 70,\n globe: (options.projection ?? 'globe') === 'globe',\n sky: options.sky ?? true,\n atmosphere: atmosphereSettings(options.atmosphere),\n terrain: terrainSettings(options.terrain, options.body, body.radius, terrainLoader),\n loading: options.loading ?? 'immediate',\n background: rgb(options.background ?? (earth ? '#f2f2f0' : '#000000')),\n globeColor: earth ? SEA['osm-positron'] : rgb(body.color),\n };\n};\n\n/** Gives a new engine the settings and the page's request headers */\nexport const applySettings = (engine: Engine, settings: Settings): void => {\n // The body first: the layers' shaders may take its size\n const { radius, flattening, atmosphere: air, relief } = settings.body;\n\n engine.setBody(radius, flattening, haloSettings(air), ...relief);\n sendHeaders(engine, headerRules());\n\n const { zoomRange, maxPitch, globe, sky, atmosphere, terrain, loading, background, globeColor } = settings;\n\n engine.setZoomRange(...zoomRange);\n engine.setMaxPitch(maxPitch);\n engine.setGlobe(globe);\n engine.setSky(sky);\n engine.setAtmosphere(atmosphere);\n engine.setTerrain(terrain?.url, terrain?.exaggeration ?? 1, terrain?.maxZoom, terrain?.geoid, terrain?.loader);\n engine.setImmediateLoading(loading === 'immediate');\n engine.setBackground(...background);\n engine.setGlobeColor(...globeColor);\n};\n\n/** The page's request headers to an engine (its own requests: raster tiles, tilesets, point clouds) */\nexport const sendHeaders = (engine: Engine, rules: HeaderRules): void => {\n engine.setRequestHeaders(\n rules.map(([prefix]) => prefix),\n Uint32Array.from(rules, ([, headers]) => Object.keys(headers).length),\n rules.flatMap(([, headers]) => Object.entries(headers).flat()),\n );\n};\n"]}
1
+ {"version":3,"file":"engine-settings.js","sourceRoot":"","sources":["../../src/map/engine-settings.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA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,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,IAAI,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC/G,MAAM,CAAC,mBAAmB,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC;IACpD,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,CAAC;IACpC,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,uGAAuG;AACvG,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,KAAkB,EAAQ,EAAE;IACtE,MAAM,CAAC,iBAAiB,CACtB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,EAC/B,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,EACrE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,CAC/D,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * The settings of the map's engine: made from the options, given to each new engine (at creation, and again after a\n * context loss), with the page's request headers.\n */\n\nimport { SEA } from '../basemap/basemaps.ts';\nimport type { PngEncoding } from '../basemap/terrain.ts';\nimport {\n atmosphereSettings,\n bodySettings,\n haloSettings,\n rgb,\n type Settings,\n type TerrainLoader,\n terrainSettings,\n} from '../settings.ts';\nimport type { GeoMapOptions } from '../types.ts';\nimport { type HeaderRules, headerRules } from '../util/requests.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\n\n/** The settings of a map from its options; `earth`: the map is of the Earth */\nexport const mapSettings = (\n options: GeoMapOptions,\n earth: boolean,\n terrainLoader: (url: string, encoding: PngEncoding, floor?: number) => TerrainLoader,\n): Settings => {\n const body = bodySettings(options.body);\n\n return {\n body,\n zoomRange: [options.minZoom ?? 0, options.maxZoom ?? 22],\n maxPitch: options.maxPitch ?? 70,\n globe: (options.projection ?? 'globe') === 'globe',\n sky: options.sky ?? true,\n atmosphere: atmosphereSettings(options.atmosphere),\n terrain: terrainSettings(options.terrain, options.body, body.radius, terrainLoader),\n loading: options.loading ?? 'immediate',\n memory: memoryBudget(options.memory),\n background: rgb(options.background ?? (earth ? '#f2f2f0' : '#000000')),\n globeColor: earth ? SEA['osm-positron'] : rgb(body.color),\n };\n};\n\n/** A map's GPU memory budget in bytes (`GeoMapOptions.memory`): `'auto'` lower on a touch screen, a phone's or a\n * tablet's */\nexport const memoryBudget = (memory: number | 'auto' | undefined): number => {\n if (typeof memory === 'number' && memory > 0) return memory * 2 ** 20;\n\n const touch = typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches;\n\n return (touch ? 256 : 1024) * 2 ** 20;\n};\n\n/** Gives a new engine the settings and the page's request headers */\nexport const applySettings = (engine: Engine, settings: Settings): void => {\n // The body first: the layers' shaders may take its size\n const { radius, flattening, atmosphere: air, relief } = settings.body;\n\n engine.setBody(radius, flattening, haloSettings(air), ...relief);\n sendHeaders(engine, headerRules());\n\n const { zoomRange, maxPitch, globe, sky, atmosphere, terrain, loading, memory, background, globeColor } = settings;\n\n // Before the layers: a raster's pool takes the budget as it is when the raster is made\n engine.setMemoryBudget(memory);\n engine.setZoomRange(...zoomRange);\n engine.setMaxPitch(maxPitch);\n engine.setGlobe(globe);\n engine.setSky(sky);\n engine.setAtmosphere(atmosphere);\n engine.setTerrain(terrain?.url, terrain?.exaggeration ?? 1, terrain?.maxZoom, terrain?.geoid, terrain?.loader);\n engine.setImmediateLoading(loading === 'immediate');\n engine.setBackground(...background);\n engine.setGlobeColor(...globeColor);\n};\n\n/** The page's request headers to an engine (its own requests: raster tiles, tilesets, point clouds) */\nexport const sendHeaders = (engine: Engine, rules: HeaderRules): void => {\n engine.setRequestHeaders(\n rules.map(([prefix]) => prefix),\n Uint32Array.from(rules, ([, headers]) => Object.keys(headers).length),\n rules.flatMap(([, headers]) => Object.entries(headers).flat()),\n );\n};\n"]}