isard 2.0.0 → 2.1.1

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 +47 -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
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EACL,OAAO,EAIP,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAuB,MAAM,2BAA2B,CAAC;AAiB5E,OAAO,EAAE,QAAQ,EAAuB,MAAM,kCAAkC,CAAC;AAEjF,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAsB,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAGL,MAAM,EACN,qBAAqB,EACrB,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,yBAAyB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAmC,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAsB,WAAW,EAAuB,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EAAE,MAAM,EAAkB,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,aAAa,EAGb,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,MAAM,gBAAgB,CAAC;AAuCxB,OAAO,EACL,kBAAkB,EAIlB,iBAAiB,GAElB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAEL,MAAM,EAIN,KAAK,EAEL,KAAK,GAGN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAqB,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAsB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/**\n * isard: a WebGL2 map engine for large, interactive data layers, labels and 3D Tiles.\n *\n * ```ts\n * import { GeoMap } from 'isard';\n * const map = await GeoMap.create(container, { center: [2.4246, 48.8457], zoom: 13 });\n * const network = map.addNetwork({ nodes, edges, max: 1800, contour: 300 });\n * map.on('hover', ({ lonLat }) => lonLat && network.setValues(travelTimes(lonLat)));\n * map.addTiles3d({ url: 'https://…/tileset.json' });\n * map.addControl(new NavigationControl());\n * new Marker().setLonLat([2.4246, 48.8457]).setPopup(new Popup({ offset: [0, -34] }).setText('Here')).addTo(map);\n * ```\n */\nexport { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from './basemap/basemaps.ts';\nexport type { TileGrid, TileMatrix } from './basemap/grid.ts';\nexport { coniferModel, type TreeColors, treeModel } from './basemap/models/trees.ts';\nexport {\n PMTiles,\n type PmtilesEntry,\n type PmtilesHeader,\n type PmtilesTileType,\n tileIdToZxy,\n zxyToTileId,\n} from './basemap/pmtiles.ts';\nexport { basicStyle, type PmtilesOptions } from './basemap/pmtileslayer.ts';\nexport type {\n CandidateIcon,\n CandidateOverlap,\n Json,\n LabelCandidate,\n RasterSource,\n Style,\n StyleLayer,\n} from './basemap/vectorstyle.ts';\nexport type { VectorExtrusionOptions } from './basemap/vectortiles/extrusions.ts';\nexport type { FurnitureOptions } from './basemap/vectortiles/furniture.ts';\nexport type { LabelsOptions } from './basemap/vectortiles/labels.ts';\nexport type { LampsOptions } from './basemap/vectortiles/lamps.ts';\nexport type { StreetWindLayer, StreetWindOptions } from './basemap/vectortiles/street-wind.ts';\nexport type { LoadedStyle } from './basemap/vectortiles/style.ts';\nexport type { TreesOptions } from './basemap/vectortiles/trees.ts';\nexport { isStreet, type VectorsOptions } from './basemap/vectortiles/vectors.ts';\nexport type { VectorRasterOptions, VectorTilesOptions } from './basemap/vectortiles.ts';\nexport { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from './basemap/vectortiles.ts';\nexport { parseWmtsGrid, wmtsGrid } from './basemap/wmts.ts';\nexport { type ColladaImages, colladaImages, loadCollada, parseCollada } from './data/collada.ts';\nexport {\n type Crs,\n type CrsLike,\n getCrs,\n lambertConformalConic,\n registerCrs,\n reproject,\n transverseMercator,\n} from './data/crs.ts';\nexport { parseGpx } from './data/gpx.ts';\nexport {\n type IfcElement,\n type IfcModel,\n type IfcOptions,\n type IfcPlace,\n type IfcProperties,\n type IfcStorey,\n loadIfc,\n WEB_IFC,\n} from './data/ifc.ts';\nexport { parseKml } from './data/kml.ts';\nexport { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';\nexport type { DecoderUrls } from './decoding/decoders.ts';\nexport {\n BATIMENTS_3D_URL,\n type BdTopoBuilding,\n batiments3d,\n bdtopoBuildings,\n bdtopoRoofs,\n type GeocodedPlace,\n geoplateformeGeocode,\n geoplateformeWfs,\n geoplateformeWms,\n geoplateformeWmts,\n IGN_ATTRIBUTION,\n IGN_PRESETS,\n type IgnPreset,\n lambert93Grid,\n} from './geoplateforme.ts';\nexport { type Grid, windAt, windFields } from './grids.ts';\nexport type { CustomFrame, CustomLayerInterface } from './layers/custom.ts';\nexport { CustomLayer } from './layers/custom.ts';\nexport type { ExtrusionOptions, ExtrusionStyle, PolygonArrays, TileKey } from './layers/extrusions.ts';\nexport { ExtrusionLayer } from './layers/extrusions.ts';\nexport type {\n CircleOptions,\n CircleStyle,\n Feature,\n FeatureCollection,\n FeatureData,\n FeatureLayerStyle,\n FillOptions,\n FillStyle,\n Geometry,\n LineOptions,\n LineStyle,\n Position,\n Properties,\n Ramp,\n Size,\n Stops,\n Styled,\n} from './layers/features.ts';\nexport { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColor } from './layers/features.ts';\nexport type { FlowField, FlowOptions, FlowStyle, TimedField } from './layers/flow.ts';\nexport { FlowLayer, flowFieldFromImage, flowFieldsFromImage } from './layers/flow.ts';\nexport type { TextPart } from './layers/glyphs.ts';\nexport { DEFAULT_FONT, GLYPHS_URL } from './layers/glyphs.ts';\nexport type { GroundOptions, GroundTexture, GroundUniform } from './layers/ground.ts';\nexport { GroundLayer } from './layers/ground.ts';\nexport type { ImageOptions, Pixels, SpriteIcon } from './layers/icons.ts';\nexport { Layer } from './layers/layers.ts';\nexport type { ModelInstance, ModelOptions } from './layers/models.ts';\nexport { ModelLayer } from './layers/models.ts';\nexport { NetworkLayer } from './layers/network.ts';\nexport {\n type CalibratedPanoramaOptions,\n type Panorama,\n type PanoramaOptions,\n type PanoramaPhoto,\n Panoramas,\n type PhotoPanoramaOptions,\n} from './layers/panoramas.ts';\nexport { type PhotoOptions, photoModel } from './layers/photos.ts';\nexport type { ClassStyle, PointCloudOptions, PointCloudStyle, PointColor } from './layers/pointclouds.ts';\nexport { CLASSIFICATIONS, ELEVATION_RAMP, PointCloudLayer } from './layers/pointclouds.ts';\nexport { RasterLayer } from './layers/raster.ts';\nexport type { Overlap, SymbolOptions, SymbolStyle } from './layers/symbols.ts';\nexport { SymbolLayer } from './layers/symbols.ts';\nexport { Tiles3dLayer } from './layers/tiles3d.ts';\nexport { type TreeKind, type TreeOptions, treeKind } from './layers/trees.ts';\nexport { type VectorFeature, VectorLayer, type VectorSublayer } from './layers/vectors.ts';\nexport type { HoverPicking } from './map/hover-pick.ts';\nexport { GeoMap, type LayerSpec } from './map.ts';\nexport {\n PANORAMAX_API,\n type PanoramaxPicture,\n type PanoramaxSequenceOptions,\n panoramaxPanoramas,\n panoramaxPhoto,\n panoramaxPicture,\n panoramaxSequence,\n panoramaxStyle,\n} from './panoramax.ts';\nexport type {\n AnimationOptions,\n AtmosphereOptions,\n Basemap,\n BasemapName,\n BodyOptions,\n CelestialBody,\n FeatureColor,\n FeatureHit,\n FirstPersonView,\n FlyToOptions,\n GeoMapOptions,\n LoadingMode,\n LonLat,\n MapEvents,\n MapGpuTimings,\n MapHoverFeatureEvent,\n MapPointerEvent,\n NetworkOptions,\n NetworkStyle,\n PickOptions,\n Placement,\n Point,\n Projection,\n Quality,\n RasterGrid,\n RasterOptions,\n RasterStyle,\n SunOptions,\n SwipeOptions,\n TerrainEncoding,\n TerrainModel,\n TerrainOptions,\n Tiles3dDrape,\n Tiles3dOptions,\n Tiles3dStyle,\n ViewshedOptions,\n} from './types.ts';\nexport {\n AttributionControl,\n type AttributionOptions,\n type Control,\n type ControlPosition,\n NavigationControl,\n type NavigationOptions,\n} from './ui/controls.ts';\nexport { MinimapControl, type MinimapOptions } from './ui/minimap.ts';\nexport {\n type Anchor,\n Marker,\n type MarkerEvent,\n type MarkerEvents,\n type MarkerOptions,\n Panel,\n type PanelOptions,\n Popup,\n type PopupEvents,\n type PopupOptions,\n} from './ui/overlay.ts';\nexport { lengthLabel, roundLength, ScaleControl, type ScaleOptions } from './ui/scale.ts';\nexport { SearchControl, type SearchOptions } from './ui/search.ts';\nexport { setRequestHeaders } from './util/requests.ts';\nexport type { RoofMode } from './util/roofs.ts';\nexport { sunPosition } from './util/sun.ts';\nexport type {\n Camera,\n NetworkStats,\n PickHit,\n PickResult,\n PointCloudInfo,\n PointCloudPoint,\n PointCloudStats,\n RasterLayerStats,\n Tiles3dStats,\n} from './wasm/isard_webgpu.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EAAE,YAAY,EAAmB,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACrF,OAAO,EACL,OAAO,EAIP,WAAW,EACX,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAuB,MAAM,2BAA2B,CAAC;AAiB5E,OAAO,EAAE,QAAQ,EAAuB,MAAM,kCAAkC,CAAC;AAEjF,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAsB,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjG,OAAO,EAGL,MAAM,EACN,qBAAqB,EACrB,WAAW,EACX,SAAS,EACT,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAOL,OAAO,EACP,OAAO,GACR,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,C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M,mBAAmB,CAAC;AAC9E,OAAO,EAAsB,WAAW,EAAuB,MAAM,qBAAqB,CAAC;AAE3F,OAAO,EAAE,MAAM,EAAkB,MAAM,UAAU,CAAC;AAClD,OAAO,EACL,aAAa,EAGb,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,GACf,MAAM,gBAAgB,CAAC;AAwCxB,OAAO,EACL,kBAAkB,EAIlB,iBAAiB,GAElB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAEL,MAAM,EAIN,KAAK,EAEL,KAAK,GAGN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAqB,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAsB,MAAM,gBAAgB,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/**\n * isard: a WebGL2 map engine for large, interactive data layers, labels and 3D Tiles.\n *\n * ```ts\n * import { GeoMap } from 'isard';\n * const map = await GeoMap.create(container, { center: [2.4246, 48.8457], zoom: 13 });\n * const network = map.addNetwork({ nodes, edges, max: 1800, contour: 300 });\n * map.on('hover', ({ lonLat }) => lonLat && network.setValues(travelTimes(lonLat)));\n * map.addTiles3d({ url: 'https://…/tileset.json' });\n * map.addControl(new NavigationControl());\n * new Marker().setLonLat([2.4246, 48.8457]).setPopup(new Popup({ offset: [0, -34] }).setText('Here')).addTo(map);\n * ```\n */\nexport { OPENFREEMAP_ATTRIBUTION, TERRAIN_TILES_ATTRIBUTION } from './basemap/basemaps.ts';\nexport type { TileGrid, TileMatrix } from './basemap/grid.ts';\nexport { coniferModel, type TreeColors, treeModel } from './basemap/models/trees.ts';\nexport {\n PMTiles,\n type PmtilesEntry,\n type PmtilesHeader,\n type PmtilesTileType,\n tileIdToZxy,\n zxyToTileId,\n} from './basemap/pmtiles.ts';\nexport { basicStyle, type PmtilesOptions } from './basemap/pmtileslayer.ts';\nexport type {\n CandidateIcon,\n CandidateOverlap,\n Json,\n LabelCandidate,\n RasterSource,\n Style,\n StyleLayer,\n} from './basemap/vectorstyle.ts';\nexport type { VectorExtrusionOptions } from './basemap/vectortiles/extrusions.ts';\nexport type { FurnitureOptions } from './basemap/vectortiles/furniture.ts';\nexport type { LabelsOptions } from './basemap/vectortiles/labels.ts';\nexport type { LampsOptions } from './basemap/vectortiles/lamps.ts';\nexport type { StreetWindLayer, StreetWindOptions } from './basemap/vectortiles/street-wind.ts';\nexport type { LoadedStyle } from './basemap/vectortiles/style.ts';\nexport type { TreesOptions } from './basemap/vectortiles/trees.ts';\nexport { isStreet, type VectorsOptions } from './basemap/vectortiles/vectors.ts';\nexport type { VectorRasterOptions, VectorTilesOptions } from './basemap/vectortiles.ts';\nexport { OPENFREEMAP_STYLES, PLAN_STYLES, VectorTiles } from './basemap/vectortiles.ts';\nexport { parseWmtsGrid, wmtsGrid } from './basemap/wmts.ts';\nexport { type ColladaImages, colladaImages, loadCollada, parseCollada } from './data/collada.ts';\nexport {\n type Crs,\n type CrsLike,\n getCrs,\n lambertConformalConic,\n registerCrs,\n reproject,\n transverseMercator,\n} from './data/crs.ts';\nexport { parseGpx } from './data/gpx.ts';\nexport {\n type IfcElement,\n type IfcModel,\n type IfcOptions,\n type IfcPlace,\n type IfcProperties,\n type IfcStorey,\n loadIfc,\n WEB_IFC,\n} from './data/ifc.ts';\nexport { parseKml } from './data/kml.ts';\nexport { parseTopoJson, type TopoGeometry, type Topology } from './data/topojson.ts';\nexport type { DecoderUrls } from './decoding/decoders.ts';\nexport {\n BATIMENTS_3D_URL,\n type BdTopoBuilding,\n batiments3d,\n bdtopoBuildings,\n bdtopoRoofs,\n type GeocodedPlace,\n geoplateformeGeocode,\n geoplateformeWfs,\n geoplateformeWms,\n geoplateformeWmts,\n IGN_ATTRIBUTION,\n IGN_PRESETS,\n type IgnPreset,\n lambert93Grid,\n} from './geoplateforme.ts';\nexport { type Grid, windAt, windFields } from './grids.ts';\nexport type { CustomFrame, CustomLayerInterface } from './layers/custom.ts';\nexport { CustomLayer } from './layers/custom.ts';\nexport type { ExtrusionOptions, ExtrusionStyle, PolygonArrays, TileKey } from './layers/extrusions.ts';\nexport { ExtrusionLayer } from './layers/extrusions.ts';\nexport type {\n CircleOptions,\n CircleStyle,\n Feature,\n FeatureCollection,\n FeatureData,\n FeatureLayerStyle,\n FillOptions,\n FillStyle,\n Geometry,\n LineOptions,\n LineStyle,\n Position,\n Properties,\n Ramp,\n Size,\n Stops,\n Styled,\n} from './layers/features.ts';\nexport { CircleLayer, FeatureLayer, FillLayer, interpolate, LineLayer, parseColor } from './layers/features.ts';\nexport type { FlowField, FlowOptions, FlowStyle, TimedField } from './layers/flow.ts';\nexport { FlowLayer, flowFieldFromImage, flowFieldsFromImage } from './layers/flow.ts';\nexport type { TextPart } from './layers/glyphs.ts';\nexport { DEFAULT_FONT, GLYPHS_URL } from './layers/glyphs.ts';\nexport type { GroundOptions, GroundTexture, GroundUniform } from './layers/ground.ts';\nexport { GroundLayer } from './layers/ground.ts';\nexport type { ImageOptions, Pixels, SpriteIcon } from './layers/icons.ts';\nexport { Layer } from './layers/layers.ts';\nexport type { ModelInstance, ModelOptions } from './layers/models.ts';\nexport { ModelLayer } from './layers/models.ts';\nexport { NetworkLayer } from './layers/network.ts';\nexport {\n type CalibratedPanoramaOptions,\n type Panorama,\n type PanoramaOptions,\n type PanoramaPhoto,\n Panoramas,\n type PhotoPanoramaOptions,\n} from './layers/panoramas.ts';\nexport { type PhotoOptions, photoModel } from './layers/photos.ts';\nexport type { ClassStyle, PointCloudOptions, PointCloudStyle, PointColor } from './layers/pointclouds.ts';\nexport { CLASSIFICATIONS, ELEVATION_RAMP, PointCloudLayer } from './layers/pointclouds.ts';\nexport { RasterLayer } from './layers/raster.ts';\nexport type { Overlap, SymbolOptions, SymbolStyle } from './layers/symbols.ts';\nexport { SymbolLayer } from './layers/symbols.ts';\nexport { Tiles3dLayer } from './layers/tiles3d.ts';\nexport { type TreeKind, type TreeOptions, treeKind } from './layers/trees.ts';\nexport { type VectorFeature, VectorLayer, type VectorSublayer } from './layers/vectors.ts';\nexport type { HoverPicking } from './map/hover-pick.ts';\nexport { GeoMap, type LayerSpec } from './map.ts';\nexport {\n PANORAMAX_API,\n type PanoramaxPicture,\n type PanoramaxSequenceOptions,\n panoramaxPanoramas,\n panoramaxPhoto,\n panoramaxPicture,\n panoramaxSequence,\n panoramaxStyle,\n} from './panoramax.ts';\nexport type {\n AnimationOptions,\n AtmosphereOptions,\n Basemap,\n BasemapName,\n BodyOptions,\n CelestialBody,\n Drape,\n FeatureColor,\n FeatureHit,\n FirstPersonView,\n FlyToOptions,\n GeoMapOptions,\n LoadingMode,\n LonLat,\n MapEvents,\n MapGpuTimings,\n MapHoverFeatureEvent,\n MapMemory,\n MapPointerEvent,\n NetworkOptions,\n NetworkStyle,\n PickOptions,\n Placement,\n Point,\n Projection,\n Quality,\n RasterGrid,\n RasterOptions,\n RasterStyle,\n SunOptions,\n SwipeOptions,\n TerrainEncoding,\n TerrainModel,\n TerrainOptions,\n Tiles3dOptions,\n Tiles3dStyle,\n ViewshedOptions,\n} from './types.ts';\nexport {\n AttributionControl,\n type AttributionOptions,\n type Control,\n type ControlPosition,\n NavigationControl,\n type NavigationOptions,\n} from './ui/controls.ts';\nexport { MinimapControl, type MinimapOptions } from './ui/minimap.ts';\nexport {\n type Anchor,\n Marker,\n type MarkerEvent,\n type MarkerEvents,\n type MarkerOptions,\n Panel,\n type PanelOptions,\n Popup,\n type PopupEvents,\n type PopupOptions,\n} from './ui/overlay.ts';\nexport { lengthLabel, roundLength, ScaleControl, type ScaleOptions } from './ui/scale.ts';\nexport { SearchControl, type SearchOptions } from './ui/search.ts';\nexport { setRequestHeaders } from './util/requests.ts';\nexport type { RoofMode } from './util/roofs.ts';\nexport { sunPosition } from './util/sun.ts';\nexport type {\n Camera,\n NetworkStats,\n PickHit,\n PickResult,\n PointCloudInfo,\n PointCloudPoint,\n PointCloudStats,\n RasterLayerStats,\n Tiles3dStats,\n} from './wasm/isard_webgpu.js';\n"]}
Binary file
Binary file
@@ -4,7 +4,7 @@
4
4
  * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by
5
5
  * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).
6
6
  */
7
- import type { Placement } from '../types.ts';
7
+ import type { Drape, Placement } from '../types.ts';
8
8
  import { type Feature, type FeatureData, type FeatureLayerStyle, type Properties, type Styled } from './features.ts';
9
9
  import { Layer } from './layers.ts';
10
10
  import type { NetworkLayer } from './network.ts';
@@ -27,6 +27,8 @@ export interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {
27
27
  export interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {
28
28
  /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */
29
29
  data?: FeatureData<P>;
30
+ /** A raster layer draped on the roofs (`setDrape`): an ortho or a solar potential */
31
+ drape?: Drape | undefined;
30
32
  }
31
33
  /** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */
32
34
  export type TileKey = string | number;
@@ -43,9 +45,12 @@ export interface PolygonArrays {
43
45
  }
44
46
  export declare class ExtrusionLayer<P = Properties> extends Layer {
45
47
  private style;
48
+ private drape;
46
49
  private readonly tiles;
47
50
  private nextBatch;
48
51
  private network;
52
+ /** A raster layer draped on its roofs by default (see `Drape`); undefined: none */
53
+ setDrape(drape: Drape | undefined): void;
49
54
  /** Replaces the set given as `data` */
50
55
  setData(data: FeatureData<P>): void;
51
56
  /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */
@@ -9,17 +9,20 @@ import { roofNumber } from "../util/roofs.js";
9
9
  import { FLOATS, STYLE } from "../util/style-floats.js";
10
10
  import { evaluate, featuresOf, parseColor, polygonGeometry, rampTexels, stops, } from "./features.js";
11
11
  import { Layer } from "./layers.js";
12
+ import { sendDrape } from "./raster.js";
12
13
  /** TileKey of the set given as `data` */
13
14
  const DATA = Symbol('data');
14
15
  export class ExtrusionLayer extends Layer {
15
16
  style;
17
+ drape;
16
18
  tiles = new Map();
17
19
  nextBatch = 1;
18
20
  network;
19
21
  /** @internal */
20
- constructor(map, data, style) {
22
+ constructor(map, data, style, drape = undefined) {
21
23
  super(map);
22
24
  this.style = style;
25
+ this.drape = drape;
23
26
  if (data) {
24
27
  const features = featuresOf(data);
25
28
  const properties = features.map((f) => f.properties);
@@ -33,6 +36,12 @@ export class ExtrusionLayer extends Layer {
33
36
  });
34
37
  }
35
38
  }
39
+ /** A raster layer draped on its roofs by default (see `Drape`); undefined: none */
40
+ setDrape(drape) {
41
+ this.drape = drape;
42
+ sendDrape(this.map.engine, this.id, drape);
43
+ this.map.requestRender();
44
+ }
36
45
  /** Replaces the set given as `data` */
37
46
  setData(data) {
38
47
  const features = featuresOf(data);
@@ -225,19 +234,21 @@ export class ExtrusionLayer extends Layer {
225
234
  this.tiles.forEach((tile) => {
226
235
  this.sendTile(engine, id, tile);
227
236
  });
228
- // A network created before (on a new engine, the map relinks once every layer is there)
237
+ // A network or a raster created before (on a new engine, the map relinks once every layer is there)
229
238
  if (!this.network || this.network.layer.id >= 0)
230
239
  this.sendLink(engine, id);
240
+ sendDrape(engine, id, this.drape);
231
241
  return id;
232
242
  }
233
- /** @internal On a new engine, the network may come after the buildings: linked once both are there */
243
+ /** @internal On a new engine, the network and the raster may come after the buildings: linked once all are there */
234
244
  relink(engine) {
235
245
  if (this.network)
236
246
  this.sendLink(engine, this.id);
247
+ sendDrape(engine, this.id, this.drape);
237
248
  }
238
249
  }
239
250
  export const extrusionStyle = (options) => {
240
- const { data: _, before: __, ...rest } = options;
251
+ const { data: _, before: __, drape: ___, ...rest } = options;
241
252
  return {
242
253
  opacity: 1,
243
254
  minZoom: 0,
@@ -1 +1 @@
1
- {"version":3,"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C,MAAM,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;QACH,wFAAwF;QACxF,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAE3E,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,sGAAsG;IAC7F,MAAM,CAAC,MAAc;QAC5B,IAAI,IAAI,CAAC,OAAO;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAI,OAA4B,EAAqB,EAAE;IACnF,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEjD,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,MAAM,CAAC,GAAG;QACtB,OAAO,EAAE,KAAK;QACd,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Extruded polygons (buildings), styled per feature like the other feature layers, coming in tiles (or one set): an\n * application loading a tiled source (BD TOPO vector tiles…) hands each tile's buildings to `setTile` and drops them\n * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by\n * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).\n */\n\nimport type { LayerHost, Placement } from '../types.ts';\nimport { metresAt } from '../util/geo.ts';\nimport { roofNumber } from '../util/roofs.ts';\nimport { FLOATS, STYLE } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport {\n evaluate,\n type Feature,\n type FeatureData,\n type FeatureLayerStyle,\n featuresOf,\n type Properties,\n parseColor,\n polygonGeometry,\n rampTexels,\n type Styled,\n stops,\n} from './features.ts';\nimport { Layer } from './layers.ts';\nimport type { NetworkLayer } from './network.ts';\n\nexport interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color (default `#e4e1dc`) */\n color: Styled<string, P>;\n /** Height of the roof over the ground, metres (default 6) */\n height: Styled<number, P>;\n /** Height of the foot of the walls, metres (default 0) */\n base: Styled<number, P>;\n /** Its roof's shape (default `flat`): one of OpenStreetMap's `roof:shape` (hipped, gabled, pyramidal, mansard; the\n * others drawn as the nearest of them), or `generated` from its outline (hipped or gabled under 450 m², a mansard\n * under 3000 m², flat past that). Fitted into the building's height, at most half of it */\n roof: Styled<string, P>;\n /** Its roof's height over the walls' top, metres (default: as its slopes make it) */\n roofHeight: Styled<number, P>;\n /** The walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades: boolean;\n}\n\nexport interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {\n /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */\n data?: FeatureData<P>;\n}\n\n/** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */\nexport type TileKey = string | number;\n\n/**\n * Polygons as typed arrays, for tiles decoded in a worker (no GeoJSON in between): points in Mercator [0, 1] (x, y\n * interleaved, y towards the south), the first point of each ring and the first ring of each polygon (one more entry\n * than rings and polygons; the first ring of a polygon is its outline), the feature of each polygon\n */\nexport interface PolygonArrays {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n}\n\ninterface Tile<P> {\n /** Batch number in the engine: tiles are drawn, and their features numbered for picking, in this order */\n batch: number;\n /** The properties of the features, which the style reads */\n properties: P[];\n features: Feature<P>[] | undefined;\n arrays: PolygonArrays | undefined;\n values: Float32Array | undefined;\n anchors: Float32Array | undefined;\n}\n\n/** TileKey of the set given as `data` */\nconst DATA = Symbol('data');\n\nexport class ExtrusionLayer<P = Properties> extends Layer {\n private readonly tiles = new Map<TileKey | typeof DATA, Tile<P>>();\n private nextBatch = 1;\n private network: { layer: NetworkLayer; max: number } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P> | undefined,\n private style: ExtrusionStyle<P>,\n ) {\n super(map);\n if (data) {\n const features = featuresOf(data);\n const properties = features.map((f) => f.properties);\n\n this.tiles.set(DATA, {\n batch: 0,\n properties,\n features,\n arrays: undefined,\n values: undefined,\n anchors: undefined,\n });\n }\n }\n\n /** Replaces the set given as `data` */\n setData(data: FeatureData<P>): void {\n const features = featuresOf(data);\n\n this.put(\n DATA,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n\n /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */\n setTile(key: TileKey, data: FeatureData<P> | { arrays: PolygonArrays; properties: P[] }): void {\n if ('arrays' in data) this.put(key, data.properties, undefined, data.arrays);\n else {\n const features = featuresOf(data);\n\n this.put(\n key,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n }\n\n removeTile(key: TileKey): void {\n const tile = this.tiles.get(key);\n\n if (!tile) return;\n this.tiles.delete(key);\n this.map.engine.removeExtrusionBatch(this.id, tile.batch);\n this.map.requestRender();\n }\n\n /** Keys of the tiles held */\n get tileKeys(): TileKey[] {\n return [...this.tiles.keys()].filter((k): k is TileKey => k !== DATA);\n }\n\n /** The properties of the features of a tile (or of the data) */\n properties(key?: TileKey): readonly P[] {\n return this.tiles.get(key ?? DATA)?.properties ?? [];\n }\n\n /** The feature of a picked index (its geometry if given as GeoJSON): tiles are numbered one after the other, in the\n * order they were added */\n featureAt(index: number): Feature<P> | undefined {\n let rest = index;\n\n for (const tile of [...this.tiles.values()].sort((a, b) => a.batch - b.batch)) {\n const n = tile.properties.length;\n\n if (rest < n) {\n const properties = tile.properties[rest];\n\n if (properties === undefined) return undefined;\n\n return tile.features?.[rest] ?? { type: 'Feature', properties, geometry: null };\n }\n rest -= n;\n }\n\n return undefined;\n }\n\n /** The tile and the index in it of a picked index */\n tileAt(index: number): { key: TileKey | undefined; index: number } | undefined {\n let rest = index;\n\n for (const [key, tile] of [...this.tiles].sort((a, b) => a[1].batch - b[1].batch)) {\n if (rest < tile.properties.length) return { key: key === DATA ? undefined : key, index: rest };\n rest -= tile.properties.length;\n }\n\n return undefined;\n }\n\n setStyle(style: Partial<ExtrusionStyle<P>>): void {\n this.style = { ...this.style, ...style };\n\n const engine = this.map.engine;\n // The roofs are geometry: the blocks built again\n const reshaped = style.roof !== undefined || style.roofHeight !== undefined;\n\n this.tiles.forEach((tile) => {\n if (reshaped) this.sendTile(engine, this.id, tile);\n else this.sendStyle(engine, this.id, tile);\n });\n this.sendLayer(engine, this.id);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible });\n }\n\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.tiles.forEach((tile) => {\n this.map.engine.setFeatureMask(this.id, this.mask(tile), tile.batch);\n });\n this.map.requestRender();\n }\n\n /** One value per building of a tile (or of the data), colored through the ramp; NaN keeps a building's color */\n setValues(values: Float32Array | undefined, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.values = values;\n this.map.engine.setFeatureValues(\n this.id,\n values ?? new Float32Array(tile.properties.length).fill(Number.NaN),\n tile.batch,\n );\n this.map.requestRender();\n }\n\n /**\n * Colors the buildings by the node values of a network layer, recolored with it: each building takes min(value(A)\n * + cost from A, value(B) + cost from B) from its anchors (`setAnchors`), through the ramp, up to `max` (above, or\n * unreached: its own color). Undefined: back to the buildings' own values.\n */\n linkNetwork(network: NetworkLayer | undefined, max = Number.POSITIVE_INFINITY): void {\n this.network = network && { layer: network, max };\n this.sendLink(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Per building of a tile (or of the data): node A, node B, cost from A, cost from B (4 floats each) */\n setAnchors(anchors: Float32Array, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.anchors = anchors;\n this.map.engine.setExtrusionAnchors(this.id, tile.batch, anchors);\n this.map.requestRender();\n }\n\n private put(\n key: TileKey | typeof DATA,\n properties: P[],\n features: Feature<P>[] | undefined,\n arrays: PolygonArrays | undefined,\n ): void {\n const old = this.tiles.get(key);\n const tile: Tile<P> = {\n batch: old?.batch ?? (key === DATA ? 0 : this.nextBatch++),\n properties,\n features,\n arrays,\n values: undefined,\n anchors: undefined,\n };\n\n this.tiles.set(key, tile);\n this.sendTile(this.map.engine, this.id, tile);\n this.map.requestRender();\n }\n\n private mask(tile: Tile<P>): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(tile.properties.length).fill(255);\n\n if (filter)\n tile.properties.forEach((p, i) => {\n if (!filter(p, i)) mask[i] = 0;\n });\n\n return mask;\n }\n\n private sendTile(engine: Engine, id: number, tile: Tile<P>): void {\n const g = tile.arrays ?? polygonGeometry(tile.features ?? []);\n const n = tile.properties.length;\n const { roofs, heights } = this.roofs(tile, g.feature);\n // The metres per Mercator unit at the middle of the batch (a batch spanning a country errs by a few hundredths)\n const [north, south] = g.points.reduce(\n ([lo, hi], v, i) => (i % 2 === 1 ? [Math.min(lo, v), Math.max(hi, v)] : [lo, hi]),\n [1, 0],\n );\n const metres = north <= south ? metresAt((north + south) / 2) : 0;\n\n engine.setExtrusionBatch(\n id,\n tile.batch,\n g.points,\n g.ringStart,\n g.polygonStart,\n g.feature,\n n,\n roofs,\n heights,\n metres,\n );\n this.sendStyle(engine, id, tile);\n if (tile.values) engine.setFeatureValues(id, tile.values, tile.batch);\n if (tile.anchors) engine.setExtrusionAnchors(id, tile.batch, tile.anchors);\n }\n\n /** Each polygon's roof (`roofNumber`: none if all flat) and height, from its feature's style */\n private roofs(tile: Tile<P>, feature: Uint32Array): { roofs: Uint8Array; heights: Float32Array } {\n const { roof, roofHeight } = this.style;\n\n if (roof === 'flat') return { roofs: new Uint8Array(), heights: new Float32Array() };\n\n const shapes = tile.properties.map((p, i) => roofNumber(evaluate(roof, p, i)) ?? 0);\n const heights = tile.properties.map((p, i) => evaluate(roofHeight, p, i));\n\n return {\n roofs: Uint8Array.from(feature, (f) => shapes[f] ?? 0),\n heights: Float32Array.from(feature, (f) => heights[f] ?? Number.NaN),\n };\n }\n\n private sendStyle(engine: Engine, id: number, tile: Tile<P>): void {\n const { color, height, base } = this.style;\n const out = new Float32Array(tile.properties.length * FLOATS);\n // Constant colors parsed once: a tile has thousands of buildings\n const fixed = typeof color === 'string' ? parseColor(color) : undefined;\n\n tile.properties.forEach((p, i) => {\n const o = i * FLOATS;\n\n out.set(fixed ?? parseColor(evaluate(color, p, i)), o + STYLE.color);\n out.set(stops(evaluate(height, p, i)), o + STYLE.size);\n out.set(stops(evaluate(base, p, i)), o + STYLE.size2);\n });\n engine.setFeatureStyle(id, out, tile.batch);\n engine.setFeatureMask(id, this.mask(tile), tile.batch);\n }\n\n private sendLayer(engine: Engine, id: number): void {\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n engine.setFacades(id, this.style.facades);\n }\n\n private sendLink(engine: Engine, id: number): void {\n const n = this.network;\n // A network removed (or not created) links to nothing\n const network = n && n.layer.id >= 0 ? n.layer.id : undefined;\n\n engine.linkExtrusionNetwork(id, network, n ? Math.min(n.max, 1e29) : 0);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addExtrusions();\n\n this.sendLayer(engine, id);\n this.tiles.forEach((tile) => {\n this.sendTile(engine, id, tile);\n });\n // A network created before (on a new engine, the map relinks once every layer is there)\n if (!this.network || this.network.layer.id >= 0) this.sendLink(engine, id);\n\n return id;\n }\n\n /** @internal On a new engine, the network may come after the buildings: linked once both are there */\n override relink(engine: Engine): void {\n if (this.network) this.sendLink(engine, this.id);\n }\n}\n\nexport const extrusionStyle = <P>(options: ExtrusionOptions<P>): ExtrusionStyle<P> => {\n const { data: _, before: __, ...rest } = options;\n\n return {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n color: '#e4e1dc',\n height: 6,\n base: 0,\n roof: 'flat',\n roofHeight: Number.NaN,\n facades: false,\n ...rest,\n };\n};\n"]}
1
+ {"version":3,"file":"extrusions.js","sourceRoot":"","sources":["../../src/layers/extrusions.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EACL,QAAQ,EAIR,UAAU,EAEV,UAAU,EACV,eAAe,EACf,UAAU,EAEV,KAAK,GACN,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAoDxC,yCAAyC;AACzC,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAE5B,MAAM,OAAO,cAA+B,SAAQ,KAAK;IAS7C;IACA;IATO,KAAK,GAAG,IAAI,GAAG,EAAkC,CAAC;IAC3D,SAAS,GAAG,CAAC,CAAC;IACd,OAAO,CAAmD;IAElE,gBAAgB;IAChB,YACE,GAAc,EACd,IAAgC,EACxB,KAAwB,EACxB,QAA2B,SAAS;QAE5C,KAAK,CAAC,GAAG,CAAC,CAAC;QAHH,UAAK,GAAL,KAAK,CAAmB;QACxB,UAAK,GAAL,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AE,CAAC,CAAC;QACjD,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,CAAI,OAA4B,EAAqB,EAAE;IACnF,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAE7D,OAAO;QACL,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,SAAS;QACjB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,CAAC;QACT,IAAI,EAAE,CAAC;QACP,IAAI,EAAE,MAAM;QACZ,UAAU,EAAE,MAAM,CAAC,GAAG;QACtB,OAAO,EAAE,KAAK;QACd,GAAG,IAAI;KACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * Extruded polygons (buildings), styled per feature like the other feature layers, coming in tiles (or one set): an\n * application loading a tiled source (BD TOPO vector tiles…) hands each tile's buildings to `setTile` and drops them\n * with `removeTile`. Colored by their color, by a value per building through the ramp (water at a building), or by\n * the node values of a network layer (`linkNetwork`: the travel time to each building, recolored with the network).\n */\n\nimport type { Drape, LayerHost, Placement } from '../types.ts';\nimport { metresAt } from '../util/geo.ts';\nimport { roofNumber } from '../util/roofs.ts';\nimport { FLOATS, STYLE } from '../util/style-floats.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport {\n evaluate,\n type Feature,\n type FeatureData,\n type FeatureLayerStyle,\n featuresOf,\n type Properties,\n parseColor,\n polygonGeometry,\n rampTexels,\n type Styled,\n stops,\n} from './features.ts';\nimport { Layer } from './layers.ts';\nimport type { NetworkLayer } from './network.ts';\nimport { sendDrape } from './raster.ts';\n\nexport interface ExtrusionStyle<P = Properties> extends FeatureLayerStyle<P> {\n /** CSS color (default `#e4e1dc`) */\n color: Styled<string, P>;\n /** Height of the roof over the ground, metres (default 6) */\n height: Styled<number, P>;\n /** Height of the foot of the walls, metres (default 0) */\n base: Styled<number, P>;\n /** Its roof's shape (default `flat`): one of OpenStreetMap's `roof:shape` (hipped, gabled, pyramidal, mansard; the\n * others drawn as the nearest of them), or `generated` from its outline (hipped or gabled under 450 m², a mansard\n * under 3000 m², flat past that). Fitted into the building's height, at most half of it */\n roof: Styled<string, P>;\n /** Its roof's height over the walls' top, metres (default: as its slopes make it) */\n roofHeight: Styled<number, P>;\n /** The walls show their windows: glass by day, some lit at night (default false: only the lit ones) */\n facades: boolean;\n}\n\nexport interface ExtrusionOptions<P = Properties> extends Partial<ExtrusionStyle<P>>, Placement {\n /** Polygon and MultiPolygon features, as one set (tiles come with `setTile`) */\n data?: FeatureData<P>;\n /** A raster layer draped on the roofs (`setDrape`): an ortho or a solar potential */\n drape?: Drape | undefined;\n}\n\n/** Key of a tile of extrusions (see `ExtrusionLayer.setTile`) */\nexport type TileKey = string | number;\n\n/**\n * Polygons as typed arrays, for tiles decoded in a worker (no GeoJSON in between): points in Mercator [0, 1] (x, y\n * interleaved, y towards the south), the first point of each ring and the first ring of each polygon (one more entry\n * than rings and polygons; the first ring of a polygon is its outline), the feature of each polygon\n */\nexport interface PolygonArrays {\n points: Float64Array;\n ringStart: Uint32Array;\n polygonStart: Uint32Array;\n feature: Uint32Array;\n}\n\ninterface Tile<P> {\n /** Batch number in the engine: tiles are drawn, and their features numbered for picking, in this order */\n batch: number;\n /** The properties of the features, which the style reads */\n properties: P[];\n features: Feature<P>[] | undefined;\n arrays: PolygonArrays | undefined;\n values: Float32Array | undefined;\n anchors: Float32Array | undefined;\n}\n\n/** TileKey of the set given as `data` */\nconst DATA = Symbol('data');\n\nexport class ExtrusionLayer<P = Properties> extends Layer {\n private readonly tiles = new Map<TileKey | typeof DATA, Tile<P>>();\n private nextBatch = 1;\n private network: { layer: NetworkLayer; max: number } | undefined;\n\n /** @internal */\n constructor(\n map: LayerHost,\n data: FeatureData<P> | undefined,\n private style: ExtrusionStyle<P>,\n private drape: Drape | undefined = undefined,\n ) {\n super(map);\n if (data) {\n const features = featuresOf(data);\n const properties = features.map((f) => f.properties);\n\n this.tiles.set(DATA, {\n batch: 0,\n properties,\n features,\n arrays: undefined,\n values: undefined,\n anchors: undefined,\n });\n }\n }\n\n /** A raster layer draped on its roofs by default (see `Drape`); undefined: none */\n setDrape(drape: Drape | undefined): void {\n this.drape = drape;\n sendDrape(this.map.engine, this.id, drape);\n this.map.requestRender();\n }\n\n /** Replaces the set given as `data` */\n setData(data: FeatureData<P>): void {\n const features = featuresOf(data);\n\n this.put(\n DATA,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n\n /** Adds or replaces the buildings of a tile: GeoJSON, or typed arrays with the properties of each feature */\n setTile(key: TileKey, data: FeatureData<P> | { arrays: PolygonArrays; properties: P[] }): void {\n if ('arrays' in data) this.put(key, data.properties, undefined, data.arrays);\n else {\n const features = featuresOf(data);\n\n this.put(\n key,\n features.map((f) => f.properties),\n features,\n undefined,\n );\n }\n }\n\n removeTile(key: TileKey): void {\n const tile = this.tiles.get(key);\n\n if (!tile) return;\n this.tiles.delete(key);\n this.map.engine.removeExtrusionBatch(this.id, tile.batch);\n this.map.requestRender();\n }\n\n /** Keys of the tiles held */\n get tileKeys(): TileKey[] {\n return [...this.tiles.keys()].filter((k): k is TileKey => k !== DATA);\n }\n\n /** The properties of the features of a tile (or of the data) */\n properties(key?: TileKey): readonly P[] {\n return this.tiles.get(key ?? DATA)?.properties ?? [];\n }\n\n /** The feature of a picked index (its geometry if given as GeoJSON): tiles are numbered one after the other, in the\n * order they were added */\n featureAt(index: number): Feature<P> | undefined {\n let rest = index;\n\n for (const tile of [...this.tiles.values()].sort((a, b) => a.batch - b.batch)) {\n const n = tile.properties.length;\n\n if (rest < n) {\n const properties = tile.properties[rest];\n\n if (properties === undefined) return undefined;\n\n return tile.features?.[rest] ?? { type: 'Feature', properties, geometry: null };\n }\n rest -= n;\n }\n\n return undefined;\n }\n\n /** The tile and the index in it of a picked index */\n tileAt(index: number): { key: TileKey | undefined; index: number } | undefined {\n let rest = index;\n\n for (const [key, tile] of [...this.tiles].sort((a, b) => a[1].batch - b[1].batch)) {\n if (rest < tile.properties.length) return { key: key === DATA ? undefined : key, index: rest };\n rest -= tile.properties.length;\n }\n\n return undefined;\n }\n\n setStyle(style: Partial<ExtrusionStyle<P>>): void {\n this.style = { ...this.style, ...style };\n\n const engine = this.map.engine;\n // The roofs are geometry: the blocks built again\n const reshaped = style.roof !== undefined || style.roofHeight !== undefined;\n\n this.tiles.forEach((tile) => {\n if (reshaped) this.sendTile(engine, this.id, tile);\n else this.sendStyle(engine, this.id, tile);\n });\n this.sendLayer(engine, this.id);\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.setStyle({ visible });\n }\n\n setFilter(filter: ((properties: P, index: number) => boolean) | undefined): void {\n this.style = { ...this.style, filter };\n this.tiles.forEach((tile) => {\n this.map.engine.setFeatureMask(this.id, this.mask(tile), tile.batch);\n });\n this.map.requestRender();\n }\n\n /** One value per building of a tile (or of the data), colored through the ramp; NaN keeps a building's color */\n setValues(values: Float32Array | undefined, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.values = values;\n this.map.engine.setFeatureValues(\n this.id,\n values ?? new Float32Array(tile.properties.length).fill(Number.NaN),\n tile.batch,\n );\n this.map.requestRender();\n }\n\n /**\n * Colors the buildings by the node values of a network layer, recolored with it: each building takes min(value(A)\n * + cost from A, value(B) + cost from B) from its anchors (`setAnchors`), through the ramp, up to `max` (above, or\n * unreached: its own color). Undefined: back to the buildings' own values.\n */\n linkNetwork(network: NetworkLayer | undefined, max = Number.POSITIVE_INFINITY): void {\n this.network = network && { layer: network, max };\n this.sendLink(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Per building of a tile (or of the data): node A, node B, cost from A, cost from B (4 floats each) */\n setAnchors(anchors: Float32Array, key?: TileKey): void {\n const tile = this.tiles.get(key ?? DATA);\n\n if (!tile) return;\n tile.anchors = anchors;\n this.map.engine.setExtrusionAnchors(this.id, tile.batch, anchors);\n this.map.requestRender();\n }\n\n private put(\n key: TileKey | typeof DATA,\n properties: P[],\n features: Feature<P>[] | undefined,\n arrays: PolygonArrays | undefined,\n ): void {\n const old = this.tiles.get(key);\n const tile: Tile<P> = {\n batch: old?.batch ?? (key === DATA ? 0 : this.nextBatch++),\n properties,\n features,\n arrays,\n values: undefined,\n anchors: undefined,\n };\n\n this.tiles.set(key, tile);\n this.sendTile(this.map.engine, this.id, tile);\n this.map.requestRender();\n }\n\n private mask(tile: Tile<P>): Uint8Array {\n const { filter } = this.style;\n const mask = new Uint8Array(tile.properties.length).fill(255);\n\n if (filter)\n tile.properties.forEach((p, i) => {\n if (!filter(p, i)) mask[i] = 0;\n });\n\n return mask;\n }\n\n private sendTile(engine: Engine, id: number, tile: Tile<P>): void {\n const g = tile.arrays ?? polygonGeometry(tile.features ?? []);\n const n = tile.properties.length;\n const { roofs, heights } = this.roofs(tile, g.feature);\n // The metres per Mercator unit at the middle of the batch (a batch spanning a country errs by a few hundredths)\n const [north, south] = g.points.reduce(\n ([lo, hi], v, i) => (i % 2 === 1 ? [Math.min(lo, v), Math.max(hi, v)] : [lo, hi]),\n [1, 0],\n );\n const metres = north <= south ? metresAt((north + south) / 2) : 0;\n\n engine.setExtrusionBatch(\n id,\n tile.batch,\n g.points,\n g.ringStart,\n g.polygonStart,\n g.feature,\n n,\n roofs,\n heights,\n metres,\n );\n this.sendStyle(engine, id, tile);\n if (tile.values) engine.setFeatureValues(id, tile.values, tile.batch);\n if (tile.anchors) engine.setExtrusionAnchors(id, tile.batch, tile.anchors);\n }\n\n /** Each polygon's roof (`roofNumber`: none if all flat) and height, from its feature's style */\n private roofs(tile: Tile<P>, feature: Uint32Array): { roofs: Uint8Array; heights: Float32Array } {\n const { roof, roofHeight } = this.style;\n\n if (roof === 'flat') return { roofs: new Uint8Array(), heights: new Float32Array() };\n\n const shapes = tile.properties.map((p, i) => roofNumber(evaluate(roof, p, i)) ?? 0);\n const heights = tile.properties.map((p, i) => evaluate(roofHeight, p, i));\n\n return {\n roofs: Uint8Array.from(feature, (f) => shapes[f] ?? 0),\n heights: Float32Array.from(feature, (f) => heights[f] ?? Number.NaN),\n };\n }\n\n private sendStyle(engine: Engine, id: number, tile: Tile<P>): void {\n const { color, height, base } = this.style;\n const out = new Float32Array(tile.properties.length * FLOATS);\n // Constant colors parsed once: a tile has thousands of buildings\n const fixed = typeof color === 'string' ? parseColor(color) : undefined;\n\n tile.properties.forEach((p, i) => {\n const o = i * FLOATS;\n\n out.set(fixed ?? parseColor(evaluate(color, p, i)), o + STYLE.color);\n out.set(stops(evaluate(height, p, i)), o + STYLE.size);\n out.set(stops(evaluate(base, p, i)), o + STYLE.size2);\n });\n engine.setFeatureStyle(id, out, tile.batch);\n engine.setFeatureMask(id, this.mask(tile), tile.batch);\n }\n\n private sendLayer(engine: Engine, id: number): void {\n const { ramp, opacity, minZoom, maxZoom, visible } = this.style;\n const r = ramp && rampTexels(ramp);\n\n engine.setFeatureRamp(id, r?.rgba, r?.min ?? 0, r?.max ?? 1);\n engine.setFeatureLayer(id, Float32Array.from(stops(opacity)), minZoom, maxZoom, visible);\n engine.setFacades(id, this.style.facades);\n }\n\n private sendLink(engine: Engine, id: number): void {\n const n = this.network;\n // A network removed (or not created) links to nothing\n const network = n && n.layer.id >= 0 ? n.layer.id : undefined;\n\n engine.linkExtrusionNetwork(id, network, n ? Math.min(n.max, 1e29) : 0);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addExtrusions();\n\n this.sendLayer(engine, id);\n this.tiles.forEach((tile) => {\n this.sendTile(engine, id, tile);\n });\n // A network or a raster created before (on a new engine, the map relinks once every layer is there)\n if (!this.network || this.network.layer.id >= 0) this.sendLink(engine, id);\n sendDrape(engine, id, this.drape);\n\n return id;\n }\n\n /** @internal On a new engine, the network and the raster may come after the buildings: linked once all are there */\n override relink(engine: Engine): void {\n if (this.network) this.sendLink(engine, this.id);\n sendDrape(engine, this.id, this.drape);\n }\n}\n\nexport const extrusionStyle = <P>(options: ExtrusionOptions<P>): ExtrusionStyle<P> => {\n const { data: _, before: __, drape: ___, ...rest } = options;\n\n return {\n opacity: 1,\n minZoom: 0,\n maxZoom: 24,\n visible: true,\n filter: undefined,\n ramp: undefined,\n color: '#e4e1dc',\n height: 6,\n base: 0,\n roof: 'flat',\n roofHeight: Number.NaN,\n facades: false,\n ...rest,\n };\n};\n"]}
@@ -47,7 +47,7 @@ export declare class GroundLayer extends Layer {
47
47
  setTexture(name: string, texture: GroundTexture): void;
48
48
  /**
49
49
  * Replaces a region of a texture: `data` holds `width` × `height` texels for (`x`, `y`) of `layer` (2D arrays).
50
- * Keep the texture's own `data` up to date too if it must survive a WebGL context loss.
50
+ * Keep the texture's own `data` up to date too if it must survive the GPU lost (`GeoMap`'s engine made again).
51
51
  */
52
52
  updateTexture(name: string, data: ArrayBufferView, region: {
53
53
  x?: number;
@@ -45,7 +45,7 @@ export class GroundLayer extends Layer {
45
45
  }
46
46
  /**
47
47
  * Replaces a region of a texture: `data` holds `width` × `height` texels for (`x`, `y`) of `layer` (2D arrays).
48
- * Keep the texture's own `data` up to date too if it must survive a WebGL context loss.
48
+ * Keep the texture's own `data` up to date too if it must survive the GPU lost (`GeoMap`'s engine made again).
49
49
  */
50
50
  updateTexture(name, data, region) {
51
51
  const { x = 0, y = 0, layer = 0, width, height } = region;
@@ -1 +1 @@
1
- {"version":3,"file":"ground.js","sourceRoot":"","sources":["../../src/layers/ground.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAG7F,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAoBpC,sDAAsD;AACtD,MAAM,MAAM,GAAG,CAAC,MAAyB,E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;YACzC,MAAM,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,EAAE,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAE1C,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,WAAW,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAmC,EAK/E,EAAE;IACF,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAE3C,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,CAAC,CAAC","sourcesContent":["/** A ground shader as a layer: the page's WGSL over the ground, its uniforms and textures */\n\nimport type { LayerHost, LonLat, Placement } from '../types.ts';\nimport { toMercator } from '../util/geo.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport { Layer } from './layers.ts';\n\n/** A texture of a ground layer (see `GroundLayer`): a global of its name in the shader, `texture_2d<f32>` (or\n * `<u32>`, `<i32>` for the integer formats, `texture_2d_array` with `depth`), read with `textureLoad` or sampled with\n * `isard_linear` (`r8`, `rgba8` only) or `isard_nearest` */\nexport interface GroundTexture {\n /** `r8`, `r8ui`, `r16ui`, `r16i`, `r32ui`, `r32f`, `rg16ui`, `rg32f`, `rgba8`, `rgba8ui`, `rgba16ui`, `rgba32f` */\n format: string;\n width: number;\n height: number;\n /** Layers of a 2D array; 0 or undefined: a 2D texture */\n depth?: number;\n /** Texels row after row (layer after layer), any typed array; undefined: left empty */\n data?: ArrayBufferView;\n}\n\n/** A uniform of a ground layer: a number (`f32`), 2 to 4 numbers (`vec2f`…`vec4f`), 9 or 16 (`mat3x3f`,\n * `mat4x4f`, column major), or its WGSL type and value (`{ type: 'u32', value: 3 }`, `vec2i`, `mat2x2f`…) */\nexport type GroundUniform = number | readonly number[] | { type: string; value: number | readonly number[] };\n\n/** The WGSL type of a uniform given by its numbers */\nconst typeOf = (values: readonly number[]): string => {\n const types: Record<number, string> = { 1: 'f32', 2: 'vec2f', 3: 'vec3f', 4: 'vec4f', 9: 'mat3x3f', 16: 'mat4x4f' };\n const type = types[values.length];\n\n if (!type) throw new Error(`isard: a ground uniform of ${values.length} numbers needs its type`);\n\n return type;\n};\n\n/** A uniform's WGSL type and numbers */\nconst uniformOf = (uniform: GroundUniform): { type: string; values: number[] } => {\n if (typeof uniform === 'number' || Array.isArray(uniform)) {\n const values = [uniform].flat();\n\n return { type: typeOf(values), values };\n }\n if ('type' in uniform) return { type: uniform.type, values: [uniform.value].flat() };\n\n throw new Error('isard: a ground uniform is numbers or { type, value }');\n};\n\nexport interface GroundOptions extends Placement {\n /**\n * WGSL defining `fn ground(offset: vec2f) -> vec4f`: the color of the ground (premultiplied alpha, 0 for nothing) at\n * `offset`, the Mercator offset of the pixel from `anchor` (times `ISARD_CIRCUMFERENCE`: metres of EPSG:3857), exact\n * to the millimetre at any zoom. Its uniforms (`uniforms`) are read as `u.<name>`, its textures (`textures`) by their\n * names; also there: `isard.zoom`, `isard.pixel_ratio`. Derivatives (`fwidth`, `textureSample`) before any branch\n * that depends on the pixel (WGSL's uniformity)\n */\n code: string;\n /** Where the offsets are taken from */\n anchor: LonLat;\n /** Box it shows in, `[west, south, east, north]` (default the world): only the ground there is drawn again */\n bounds?: [west: number, south: number, east: number, north: number];\n textures?: Record<string, GroundTexture>;\n /** Declared once, with their types: `setUniform` changes their values */\n uniforms?: Record<string, GroundUniform>;\n}\n\nconst bytesOf = (data: ArrayBufferView) => new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n\n/** The application's fragment shader run over the ground, draped on the relief (water depth, heat maps…) */\nexport class GroundLayer extends Layer {\n private readonly textures = new Map<string, GroundTexture>();\n private readonly uniforms = new Map<string, { type: string; values: number[] }>();\n private visible = true;\n\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly options: GroundOptions,\n ) {\n super(map);\n Object.entries(options.textures ?? {}).forEach(([name, texture]) => {\n this.textures.set(name, texture);\n });\n Object.entries(options.uniforms ?? {}).forEach(([name, uniform]) => {\n this.uniforms.set(name, uniformOf(uniform));\n });\n }\n\n /** Creates or replaces a texture of the code's sampler `name` */\n setTexture(name: string, texture: GroundTexture): void {\n this.textures.set(name, texture);\n this.sendTexture(this.map.engine, this.id, name, texture);\n this.map.requestRender();\n }\n\n /**\n * Replaces a region of a texture: `data` holds `width` × `height` texels for (`x`, `y`) of `layer` (2D arrays).\n * Keep the texture's own `data` up to date too if it must survive a WebGL context loss.\n */\n updateTexture(\n name: string,\n data: ArrayBufferView,\n region: { x?: number; y?: number; layer?: number; width: number; height: number },\n ): void {\n const { x = 0, y = 0, layer = 0, width, height } = region;\n\n this.map.engine.updateGroundTexture(this.id, name, x, y, layer, width, height, bytesOf(data));\n this.map.requestRender();\n }\n\n /** A uniform declared in `uniforms`: a number, or numbers for vectors and matrices (column major) */\n setUniform(name: string, value: number | readonly number[]): void {\n const uniform = this.uniforms.get(name);\n\n if (!uniform) throw new Error(`isard: no uniform ${name} declared for this ground layer`);\n\n const values = [value].flat();\n\n this.uniforms.set(name, { ...uniform, values });\n this.map.engine.setGroundUniform(this.id, name, Float64Array.from(values));\n this.map.requestRender();\n }\n\n setBounds(bounds: [west: number, south: number, east: number, north: number]): void {\n this.options.bounds = bounds;\n this.map.engine.setGroundBounds(this.id, ...mercatorBox(bounds));\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.visible = visible;\n this.map.engine.setGroundVisible(this.id, visible);\n this.map.requestRender();\n }\n\n private sendTexture(engine: Engine, id: number, name: string, t: GroundTexture): void {\n const data = t.data && bytesOf(t.data);\n\n engine.setGroundTexture(id, name, t.format, t.width, t.height, t.depth ?? 0, data);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const [ax, ay] = toMercator(this.options.anchor);\n const id = engine.addGround(\n this.options.code,\n [...this.uniforms.keys()],\n [...this.uniforms.values()].map(({ type }) => type),\n ax,\n ay,\n ...mercatorBox(this.options.bounds ?? [-180, -85.06, 180, 85.06]),\n );\n\n this.textures.forEach((texture, name) => {\n this.sendTexture(engine, id, name, texture);\n });\n this.uniforms.forEach(({ values }, name) => {\n engine.setGroundUniform(id, name, Float64Array.from(values));\n });\n engine.setGroundVisible(id, this.visible);\n\n return id;\n }\n}\n\n/** A lon/lat box to Mercator min x, min y, max x, max y (y towards the south) */\nconst mercatorBox = ([west, south, east, north]: [number, number, number, number]): [\n number,\n number,\n number,\n number,\n] => {\n const [x0, y1] = toMercator([west, south]);\n const [x1, y0] = toMercator([east, north]);\n\n return [x0, y0, x1, y1];\n};\n"]}
1
+ {"version":3,"file":"ground.js","sourceRoot":"","sources":["../../src/layers/ground.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAG7F,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAoBpC,sDAAsD;AACtD,MAAM,MAAM,GAAG,CAAC,MAAyB,EAAU,EAAE;IACnD,MAAM,KAAK,GAA2B,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;IACpH,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAElC,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,MAAM,yBAAyB,CAAC,CAAC;IAEjG,OAAO,IAAI,C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,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;IAE3C,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC1B,CAAC,CAAC","sourcesContent":["/** A ground shader as a layer: the page's WGSL over the ground, its uniforms and textures */\n\nimport type { LayerHost, LonLat, Placement } from '../types.ts';\nimport { toMercator } from '../util/geo.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport { Layer } from './layers.ts';\n\n/** A texture of a ground layer (see `GroundLayer`): a global of its name in the shader, `texture_2d<f32>` (or\n * `<u32>`, `<i32>` for the integer formats, `texture_2d_array` with `depth`), read with `textureLoad` or sampled with\n * `isard_linear` (`r8`, `rgba8` only) or `isard_nearest` */\nexport interface GroundTexture {\n /** `r8`, `r8ui`, `r16ui`, `r16i`, `r32ui`, `r32f`, `rg16ui`, `rg32f`, `rgba8`, `rgba8ui`, `rgba16ui`, `rgba32f` */\n format: string;\n width: number;\n height: number;\n /** Layers of a 2D array; 0 or undefined: a 2D texture */\n depth?: number;\n /** Texels row after row (layer after layer), any typed array; undefined: left empty */\n data?: ArrayBufferView;\n}\n\n/** A uniform of a ground layer: a number (`f32`), 2 to 4 numbers (`vec2f`…`vec4f`), 9 or 16 (`mat3x3f`,\n * `mat4x4f`, column major), or its WGSL type and value (`{ type: 'u32', value: 3 }`, `vec2i`, `mat2x2f`…) */\nexport type GroundUniform = number | readonly number[] | { type: string; value: number | readonly number[] };\n\n/** The WGSL type of a uniform given by its numbers */\nconst typeOf = (values: readonly number[]): string => {\n const types: Record<number, string> = { 1: 'f32', 2: 'vec2f', 3: 'vec3f', 4: 'vec4f', 9: 'mat3x3f', 16: 'mat4x4f' };\n const type = types[values.length];\n\n if (!type) throw new Error(`isard: a ground uniform of ${values.length} numbers needs its type`);\n\n return type;\n};\n\n/** A uniform's WGSL type and numbers */\nconst uniformOf = (uniform: GroundUniform): { type: string; values: number[] } => {\n if (typeof uniform === 'number' || Array.isArray(uniform)) {\n const values = [uniform].flat();\n\n return { type: typeOf(values), values };\n }\n if ('type' in uniform) return { type: uniform.type, values: [uniform.value].flat() };\n\n throw new Error('isard: a ground uniform is numbers or { type, value }');\n};\n\nexport interface GroundOptions extends Placement {\n /**\n * WGSL defining `fn ground(offset: vec2f) -> vec4f`: the color of the ground (premultiplied alpha, 0 for nothing) at\n * `offset`, the Mercator offset of the pixel from `anchor` (times `ISARD_CIRCUMFERENCE`: metres of EPSG:3857), exact\n * to the millimetre at any zoom. Its uniforms (`uniforms`) are read as `u.<name>`, its textures (`textures`) by their\n * names; also there: `isard.zoom`, `isard.pixel_ratio`. Derivatives (`fwidth`, `textureSample`) before any branch\n * that depends on the pixel (WGSL's uniformity)\n */\n code: string;\n /** Where the offsets are taken from */\n anchor: LonLat;\n /** Box it shows in, `[west, south, east, north]` (default the world): only the ground there is drawn again */\n bounds?: [west: number, south: number, east: number, north: number];\n textures?: Record<string, GroundTexture>;\n /** Declared once, with their types: `setUniform` changes their values */\n uniforms?: Record<string, GroundUniform>;\n}\n\nconst bytesOf = (data: ArrayBufferView) => new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n\n/** The application's fragment shader run over the ground, draped on the relief (water depth, heat maps…) */\nexport class GroundLayer extends Layer {\n private readonly textures = new Map<string, GroundTexture>();\n private readonly uniforms = new Map<string, { type: string; values: number[] }>();\n private visible = true;\n\n /** @internal */\n constructor(\n map: LayerHost,\n private readonly options: GroundOptions,\n ) {\n super(map);\n Object.entries(options.textures ?? {}).forEach(([name, texture]) => {\n this.textures.set(name, texture);\n });\n Object.entries(options.uniforms ?? {}).forEach(([name, uniform]) => {\n this.uniforms.set(name, uniformOf(uniform));\n });\n }\n\n /** Creates or replaces a texture of the code's sampler `name` */\n setTexture(name: string, texture: GroundTexture): void {\n this.textures.set(name, texture);\n this.sendTexture(this.map.engine, this.id, name, texture);\n this.map.requestRender();\n }\n\n /**\n * Replaces a region of a texture: `data` holds `width` × `height` texels for (`x`, `y`) of `layer` (2D arrays).\n * Keep the texture's own `data` up to date too if it must survive the GPU lost (`GeoMap`'s engine made again).\n */\n updateTexture(\n name: string,\n data: ArrayBufferView,\n region: { x?: number; y?: number; layer?: number; width: number; height: number },\n ): void {\n const { x = 0, y = 0, layer = 0, width, height } = region;\n\n this.map.engine.updateGroundTexture(this.id, name, x, y, layer, width, height, bytesOf(data));\n this.map.requestRender();\n }\n\n /** A uniform declared in `uniforms`: a number, or numbers for vectors and matrices (column major) */\n setUniform(name: string, value: number | readonly number[]): void {\n const uniform = this.uniforms.get(name);\n\n if (!uniform) throw new Error(`isard: no uniform ${name} declared for this ground layer`);\n\n const values = [value].flat();\n\n this.uniforms.set(name, { ...uniform, values });\n this.map.engine.setGroundUniform(this.id, name, Float64Array.from(values));\n this.map.requestRender();\n }\n\n setBounds(bounds: [west: number, south: number, east: number, north: number]): void {\n this.options.bounds = bounds;\n this.map.engine.setGroundBounds(this.id, ...mercatorBox(bounds));\n this.map.requestRender();\n }\n\n setVisible(visible: boolean): void {\n this.visible = visible;\n this.map.engine.setGroundVisible(this.id, visible);\n this.map.requestRender();\n }\n\n private sendTexture(engine: Engine, id: number, name: string, t: GroundTexture): void {\n const data = t.data && bytesOf(t.data);\n\n engine.setGroundTexture(id, name, t.format, t.width, t.height, t.depth ?? 0, data);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const [ax, ay] = toMercator(this.options.anchor);\n const id = engine.addGround(\n this.options.code,\n [...this.uniforms.keys()],\n [...this.uniforms.values()].map(({ type }) => type),\n ax,\n ay,\n ...mercatorBox(this.options.bounds ?? [-180, -85.06, 180, 85.06]),\n );\n\n this.textures.forEach((texture, name) => {\n this.sendTexture(engine, id, name, texture);\n });\n this.uniforms.forEach(({ values }, name) => {\n engine.setGroundUniform(id, name, Float64Array.from(values));\n });\n engine.setGroundVisible(id, this.visible);\n\n return id;\n }\n}\n\n/** A lon/lat box to Mercator min x, min y, max x, max y (y towards the south) */\nconst mercatorBox = ([west, south, east, north]: [number, number, number, number]): [\n number,\n number,\n number,\n number,\n] => {\n const [x0, y1] = toMercator([west, south]);\n const [x1, y0] = toMercator([east, north]);\n\n return [x0, y0, x1, y1];\n};\n"]}
@@ -43,7 +43,7 @@ export class Layer {
43
43
  return this.#removed;
44
44
  }
45
45
  remove() {
46
- // Not created yet: a 3D Tiles layer or a model waiting for the engine with 3D Tiles
46
+ // No id: its creation failed, or the map waits for a new engine (the GPU lost)
47
47
  if (this.#id >= 0)
48
48
  this.map.engine.removeLayer(this.#id);
49
49
  this.#id = -1;
@@ -1 +1 @@
1
- {"version":3,"file":"layers.js","sourceRoot":"","sources":["../../src/layers/layers.ts"],"names":[],"mappings":"AAAA;uEACuE;AAKvE,MAAM,OAAgB,KAAK;IACzB,GAAG,GAAG,CAAC,CAAC,CAAC;IAET,gBAAgB;IACG,GAAG,CAAY;IAElC,gBAAgB;IAChB,YAAY,GAAc;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,oCAAoC;IACpC,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,MAAM,CAA4B;IAElC,gHAAgH;IAChH,IAAI,KAAK;QACP,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAEpC,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,wGAAwG;IACxG,MAAM,CAAC,MAAc;QACnB,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACd,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,sGAAsG;IACtG,YAAY;QACV,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IA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,CAAC;CACF","sourcesContent":["/** The base of the handles of the layers added to a map: its id in the engine, created again after a context\n * loss with the same handle; its companions, its place, its removal */\n\nimport type { LayerHost } from '../types.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\n\nexport abstract class Layer {\n #id = -1;\n\n /** @internal */\n protected readonly map: LayerHost;\n\n /** @internal */\n constructor(map: LayerHost) {\n this.map = map;\n }\n\n /** Id of the layer in the engine */\n get id(): number {\n return this.#id;\n }\n\n #ready: Promise<void> | undefined;\n\n /** Resolves once the map has drawn the layer, what it shows in view loaded (the map idle after it was added) */\n get ready(): Promise<void> {\n this.#ready ??= this.map.whenIdle();\n\n return this.#ready;\n }\n\n /** @internal Creates the layer in an engine (again after a context loss); its id is -1 if that fails */\n attach(engine: Engine): void {\n this.#id = -1;\n this.#id = this.create(engine);\n }\n\n /** @internal Forgets its id in an engine that is gone (before the layers are created in a new one) */\n forgetEngine(): void {\n this.#id = -1;\n }\n\n /** @internal Sends what refers to other layers, once every layer of a new engine has its id */\n relink(_engine: Engine): void {}\n\n /** @internal The map's quality changed (`GeoMap.setQuality`): what it draws by it sent again */\n qualityChanged(): void {}\n\n /** @internal The layer is removed or its map destroyed: frees what it holds outside the engine */\n dispose(): void {}\n\n /** @internal */\n protected abstract create(engine: Engine): number;\n\n /** @internal Layers drawn with this one, removed and moved with it (the conifers of a basemap's trees) */\n readonly companions: Layer[] = [];\n\n /** @internal What stops once the layer is removed (a vector tiles' layer following the view) */\n readonly whenRemoved: (() => void)[] = [];\n\n #removed = false;\n\n /** Whether the layer was removed (`remove`) */\n get removed(): boolean {\n return this.#removed;\n }\n\n remove(): void {\n // Not created yet: a 3D Tiles layer or a model waiting for the engine with 3D Tiles\n if (this.#id >= 0) this.map.engine.removeLayer(this.#id);\n this.#id = -1;\n this.#removed = true;\n this.map.detach(this);\n this.companions.forEach((c) => {\n c.remove();\n });\n this.whenRemoved.splice(0).forEach((stop) => {\n stop();\n });\n this.map.requestRender();\n }\n\n /** Moves the layer under `other`, or on top of every layer (above the labels of a vector basemap too) */\n moveBefore(other: Layer | undefined): void {\n this.map.moveLayer(this, other);\n this.companions.forEach((c) => {\n c.moveBefore(other);\n });\n }\n}\n"]}
1
+ {"version":3,"file":"layers.js","sourceRoot":"","sources":["../../src/layers/layers.ts"],"names":[],"mappings":"AAAA;uEACuE;AAKvE,MAAM,OAAgB,KAAK;IACzB,GAAG,GAAG,CAAC,CAAC,CAAC;IAET,gBAAgB;IACG,GAAG,CAAY;IAElC,gBAAgB;IAChB,YAAY,GAAc;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,oCAAoC;IACpC,IAAI,EAAE;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,MAAM,CAA4B;IAElC,gHAAgH;IAChH,IAAI,KAAK;QACP,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAEpC,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,wGAAwG;IACxG,MAAM,CAAC,MAAc;QACnB,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACd,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;IAED,sGAAsG;IACtG,YAAY;QACV,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAChB,CAAC;IAED,+FAA+F;IAC/F,MAAM,CAAC,OAAe,IAAS,CAAC;IAEhC,gGAAgG;IAChG,cAAc,KAAU,CAAC;IAEzB,kGAAkG;IAClG,OAAO,KAAU,CAAC;IAKlB,0GAA0G;IACjG,UAAU,GAAY,EAAE,CAAC;IAElC,gGAAgG;IACvF,WAAW,GAAmB,EAAE,CAAC;IAE1C,QAAQ,GAAG,KAAK,CAAC;IAEjB,+CAA+C;IAC/C,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,MAAM;QACJ,+EAA+E;QAC/E,IAAI,IAAI,CAAC,GAAG,IAAI,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzD,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;QACd,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC5B,CAAC,CAAC,MAAM,EAAE,CAAC;QACb,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YAC1C,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAC3B,CAAC;IAED,yGAAyG;IACzG,UAAU,CAAC,KAAwB;QACjC,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC5B,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["/** The base of the handles of the layers added to a map: its id in the engine, created again after a context\n * loss with the same handle; its companions, its place, its removal */\n\nimport type { LayerHost } from '../types.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\n\nexport abstract class Layer {\n #id = -1;\n\n /** @internal */\n protected readonly map: LayerHost;\n\n /** @internal */\n constructor(map: LayerHost) {\n this.map = map;\n }\n\n /** Id of the layer in the engine */\n get id(): number {\n return this.#id;\n }\n\n #ready: Promise<void> | undefined;\n\n /** Resolves once the map has drawn the layer, what it shows in view loaded (the map idle after it was added) */\n get ready(): Promise<void> {\n this.#ready ??= this.map.whenIdle();\n\n return this.#ready;\n }\n\n /** @internal Creates the layer in an engine (again after a context loss); its id is -1 if that fails */\n attach(engine: Engine): void {\n this.#id = -1;\n this.#id = this.create(engine);\n }\n\n /** @internal Forgets its id in an engine that is gone (before the layers are created in a new one) */\n forgetEngine(): void {\n this.#id = -1;\n }\n\n /** @internal Sends what refers to other layers, once every layer of a new engine has its id */\n relink(_engine: Engine): void {}\n\n /** @internal The map's quality changed (`GeoMap.setQuality`): what it draws by it sent again */\n qualityChanged(): void {}\n\n /** @internal The layer is removed or its map destroyed: frees what it holds outside the engine */\n dispose(): void {}\n\n /** @internal */\n protected abstract create(engine: Engine): number;\n\n /** @internal Layers drawn with this one, removed and moved with it (the conifers of a basemap's trees) */\n readonly companions: Layer[] = [];\n\n /** @internal What stops once the layer is removed (a vector tiles' layer following the view) */\n readonly whenRemoved: (() => void)[] = [];\n\n #removed = false;\n\n /** Whether the layer was removed (`remove`) */\n get removed(): boolean {\n return this.#removed;\n }\n\n remove(): void {\n // No id: its creation failed, or the map waits for a new engine (the GPU lost)\n if (this.#id >= 0) this.map.engine.removeLayer(this.#id);\n this.#id = -1;\n this.#removed = true;\n this.map.detach(this);\n this.companions.forEach((c) => {\n c.remove();\n });\n this.whenRemoved.splice(0).forEach((stop) => {\n stop();\n });\n this.map.requestRender();\n }\n\n /** Moves the layer under `other`, or on top of every layer (above the labels of a vector basemap too) */\n moveBefore(other: Layer | undefined): void {\n this.map.moveLayer(this, other);\n this.companions.forEach((c) => {\n c.moveBefore(other);\n });\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /** glTF models drawn at many positions as a layer: their instances, their glow, their highlight */
2
- import type { LonLat, Placement } from '../types.ts';
2
+ import type { Drape, LonLat, Placement } from '../types.ts';
3
3
  import { Layer } from './layers.ts';
4
4
  /** Where and how a model stands */
5
5
  export interface ModelInstance {
@@ -22,6 +22,8 @@ export interface ModelOptions extends Placement {
22
22
  instances: readonly ModelInstance[];
23
23
  /** What the altitudes are above: `'ground'` (the relief, the default) or `'sea'` (the ellipsoid) */
24
24
  altitudeReference?: 'ground' | 'sea';
25
+ /** A raster layer draped on the faces looking up (`setDrape`): an ortho on the roofs of a city's models */
26
+ drape?: Drape | undefined;
25
27
  }
26
28
  /** A glTF model drawn at positions, in one instanced draw; `pickFeature` gives the instance's index */
27
29
  export declare class ModelLayer extends Layer {
@@ -34,6 +36,8 @@ export declare class ModelLayer extends Layer {
34
36
  /** Its feature highlighted (`setHighlight`) */
35
37
  private highlight;
36
38
  private ground;
39
+ /** The raster layer draped on it (`setDrape`) */
40
+ private drape;
37
41
  /** Replaces the instances (and what their altitudes are above, kept if not given) */
38
42
  setInstances(instances: readonly ModelInstance[], altitudeReference?: 'ground' | 'sea'): void;
39
43
  /** Lights at night the part of the model from `from` metres above its foot (a street lamp's head) in a CSS color;
@@ -42,6 +46,8 @@ export declare class ModelLayer extends Layer {
42
46
  /** Highlights a feature of the model (an IFC model's element, `hit.index` of a pick) in a CSS color (amber by
43
47
  * default); none without a feature */
44
48
  setHighlight(feature?: number, color?: string): void;
49
+ /** A raster layer draped on its faces looking up by default (see `Drape`); undefined: none */
50
+ setDrape(drape: Drape | undefined): void;
45
51
  private sendHighlight;
46
52
  private sendGlow;
47
53
  remove(): void;
@@ -1,6 +1,7 @@
1
1
  /** glTF models drawn at many positions as a layer: their instances, their glow, their highlight */
2
2
  import { parseColor } from "../util/color.js";
3
3
  import { Layer } from "./layers.js";
4
+ import { sendDrape } from "./raster.js";
4
5
  /** The numbers of instances for the engine: longitude, latitude, altitude, heading, pitch, roll, scale */
5
6
  const instanceNumbers = (instances) => {
6
7
  const out = new Float64Array(instances.length * 7);
@@ -20,6 +21,8 @@ export class ModelLayer extends Layer {
20
21
  /** Its feature highlighted (`setHighlight`) */
21
22
  highlight;
22
23
  ground;
24
+ /** The raster layer draped on it (`setDrape`) */
25
+ drape;
23
26
  /** @internal */
24
27
  constructor(map, options) {
25
28
  super(map);
@@ -38,13 +41,14 @@ export class ModelLayer extends Layer {
38
41
  }
39
42
  this.instances = instanceNumbers(options.instances);
40
43
  this.ground = options.altitudeReference !== 'sea';
44
+ this.drape = options.drape;
41
45
  }
42
46
  /** Replaces the instances (and what their altitudes are above, kept if not given) */
43
47
  setInstances(instances, altitudeReference) {
44
48
  this.instances = instanceNumbers(instances);
45
49
  if (altitudeReference)
46
50
  this.ground = altitudeReference === 'ground';
47
- // 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
48
52
  if (this.id < 0)
49
53
  return;
50
54
  this.map.engine.setModelInstances(this.id, this.instances, this.ground);
@@ -68,6 +72,14 @@ export class ModelLayer extends Layer {
68
72
  this.sendHighlight(this.map.engine, this.id);
69
73
  this.map.requestRender();
70
74
  }
75
+ /** A raster layer draped on its faces looking up by default (see `Drape`); undefined: none */
76
+ setDrape(drape) {
77
+ this.drape = drape;
78
+ if (this.id < 0)
79
+ return;
80
+ sendDrape(this.map.engine, this.id, drape);
81
+ this.map.requestRender();
82
+ }
71
83
  sendHighlight(engine, id) {
72
84
  const [r = 0, g = 0, b = 0] = this.highlight ? parseColor(this.highlight.color) : [];
73
85
  engine.setModelHighlight(id, this.highlight ? this.highlight.feature : Number.NaN, r, g, b);
@@ -101,7 +113,13 @@ export class ModelLayer extends Layer {
101
113
  this.sendGlow(engine, id);
102
114
  if (this.highlight)
103
115
  this.sendHighlight(engine, id);
116
+ // A raster created before (on a new engine, the map relinks once every layer is there)
117
+ sendDrape(engine, id, this.drape);
104
118
  return id;
105
119
  }
120
+ /** @internal On a new engine, the raster may come after the models: draped once both are there */
121
+ relink(engine) {
122
+ sendDrape(engine, this.id, this.drape);
123
+ }
106
124
  }
107
125
  //# sourceMappingURL=models.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/layers/models.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAGnG,OAAO,EAAE,UAAU,E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QAEnD,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/** glTF models drawn at many positions as a layer: their instances, their glow, their highlight */\n\nimport type { LayerHost, LonLat, Placement } from '../types.ts';\nimport { parseColor } from '../util/color.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport { Layer } from './layers.ts';\n\n/** Where and how a model stands */\nexport interface ModelInstance {\n lonLat: LonLat;\n /** Metres above the ground (or above the ellipsoid, `altitudeReference: 'sea'`); 0 by default */\n altitude?: number;\n /** Degrees clockwise from the north of the model's front (glTF +Z); 0 by default */\n heading?: number;\n /** Degrees, nose up */\n pitch?: number;\n /** Degrees, right side down */\n roll?: number;\n /** 1 by default: the model's metres */\n scale?: number;\n}\n\nexport interface ModelOptions extends Placement {\n /** URL of a glTF binary (`.glb`): meshes, textures, Draco, meshopt, KTX2, as in 3D Tiles; or its bytes (`data`) */\n url?: string;\n data?: ArrayBuffer | ArrayBufferView<ArrayBuffer>;\n instances: readonly ModelInstance[];\n /** What the altitudes are above: `'ground'` (the relief, the default) or `'sea'` (the ellipsoid) */\n altitudeReference?: 'ground' | 'sea';\n}\n\n/** The numbers of instances for the engine: longitude, latitude, altitude, heading, pitch, roll, scale */\nconst instanceNumbers = (instances: readonly ModelInstance[]): Float64Array => {\n const out = new Float64Array(instances.length * 7);\n\n instances.forEach(({ lonLat, altitude = 0, heading = 0, pitch = 0, roll = 0, scale = 1 }, i) => {\n out.set([lonLat[0], lonLat[1], altitude, heading, pitch, roll, scale], i * 7);\n });\n\n return out;\n};\n\n/** A glTF model drawn at positions, in one instanced draw; `pickFeature` gives the instance's index */\nexport class ModelLayer extends Layer {\n private readonly url: string;\n /** The `blob:` URL of the page's bytes, revoked once the layer is gone */\n private readonly blob: string | undefined;\n private instances: Float64Array;\n /** Its glow at night (`setGlow`) */\n private glow: { from: number; color: string } | undefined;\n /** Its feature highlighted (`setHighlight`) */\n private highlight: { feature: number; color: string } | undefined;\n private ground: boolean;\n\n /** @internal */\n constructor(map: LayerHost, options: ModelOptions) {\n super(map);\n\n const { url, data } = options;\n\n if (data) {\n this.blob = URL.createObjectURL(new Blob([data], { type: 'model/gltf-binary' }));\n this.url = this.blob;\n } else if (url) {\n // Against the page: the decoding workers fetch it, and a relative URL would be theirs\n const base = typeof document === 'undefined' ? undefined : document.baseURI;\n\n this.url = base ? new URL(url, base).href : url;\n } else {\n throw new Error('isard: a model needs a url or data');\n }\n this.instances = instanceNumbers(options.instances);\n this.ground = options.altitudeReference !== 'sea';\n }\n\n /** Replaces the instances (and what their altitudes are above, kept if not given) */\n setInstances(instances: readonly ModelInstance[], altitudeReference?: 'ground' | 'sea'): void {\n this.instances = instanceNumbers(instances);\n if (altitudeReference) this.ground = altitudeReference === 'ground';\n // Kept for its creation while the engine with 3D Tiles loads\n if (this.id < 0) return;\n this.map.engine.setModelInstances(this.id, this.instances, this.ground);\n this.map.requestRender();\n }\n\n /** Lights at night the part of the model from `from` metres above its foot (a street lamp's head) in a CSS color;\n * none without a color */\n setGlow(from: number, color?: string): void {\n this.glow = color === undefined ? undefined : { from, color };\n if (this.id < 0) return;\n this.sendGlow(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Highlights a feature of the model (an IFC model's element, `hit.index` of a pick) in a CSS color (amber by\n * default); none without a feature */\n setHighlight(feature?: number, color = '#ffb000'): void {\n this.highlight = feature === undefined ? undefined : { feature, color };\n if (this.id < 0) return;\n this.sendHighlight(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n private sendHighlight(engine: Engine, id: number): void {\n const [r = 0, g = 0, b = 0] = this.highlight ? parseColor(this.highlight.color) : [];\n\n engine.setModelHighlight(id, this.highlight ? this.highlight.feature : Number.NaN, r, g, b);\n }\n\n private sendGlow(engine: Engine, id: number): void {\n const [r = 0, g = 0, b = 0] = this.glow ? parseColor(this.glow.color) : [];\n\n engine.setModelGlow(id, this.glow ? this.glow.from : Number.NaN, r, g, b);\n }\n\n /** @internal The instances as the engine takes them (`instanceNumbers`: seven numbers each), above the ground */\n setInstanceNumbers(numbers: Float64Array): void {\n this.instances = numbers;\n this.ground = true;\n if (this.id < 0) return;\n this.map.engine.setModelInstances(this.id, this.instances, this.ground);\n this.map.requestRender();\n }\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal */\n override dispose(): void {\n if (this.blob) URL.revokeObjectURL(this.blob);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addModels(this.url, this.instances, this.ground);\n\n if (this.glow) this.sendGlow(engine, id);\n if (this.highlight) this.sendHighlight(engine, id);\n\n return id;\n }\n}\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/layers/models.ts"],"names":[],"mappings":"AAAA,mGAAmG;AAGnG,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AA4BxC,0GAA0G;AAC1G,MAAM,eAAe,GAAG,CAAC,SAAmC,EAAgB,EAAE;IAC5E,MAAM,GAAG,GAAG,IAAI,YAAY,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAEnD,SAAS,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAG,CAAC,EAAE,OAAO,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE;QAC7F,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAChF,CAAC,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,uGAAuG;AACvG,MAAM,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B;QACtC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,IAAI,CAAC,EAAE,GAAG,CAAC;YAAE,OAAO;QACxB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACxE,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;IAC3B,CAAC;IAEQ,MAAM;QACb,KAAK,CAAC,MAAM,EAAE,CAAC;QACf,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAED,gBAAgB;IACP,OAAO;QACd,IAAI,IAAI,CAAC,IAAI;YAAE,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,gBAAgB;IACN,MAAM,CAAC,MAAc;QAC7B,MAAM,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QAEnE,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,SAAS;YAAE,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACnD,uFAAuF;QACvF,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAElC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,kGAAkG;IACzF,MAAM,CAAC,MAAc;QAC5B,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF","sourcesContent":["/** glTF models drawn at many positions as a layer: their instances, their glow, their highlight */\n\nimport type { Drape, LayerHost, LonLat, Placement } from '../types.ts';\nimport { parseColor } from '../util/color.ts';\nimport type { Engine } from '../wasm/isard_webgpu.js';\nimport { Layer } from './layers.ts';\nimport { sendDrape } from './raster.ts';\n\n/** Where and how a model stands */\nexport interface ModelInstance {\n lonLat: LonLat;\n /** Metres above the ground (or above the ellipsoid, `altitudeReference: 'sea'`); 0 by default */\n altitude?: number;\n /** Degrees clockwise from the north of the model's front (glTF +Z); 0 by default */\n heading?: number;\n /** Degrees, nose up */\n pitch?: number;\n /** Degrees, right side down */\n roll?: number;\n /** 1 by default: the model's metres */\n scale?: number;\n}\n\nexport interface ModelOptions extends Placement {\n /** URL of a glTF binary (`.glb`): meshes, textures, Draco, meshopt, KTX2, as in 3D Tiles; or its bytes (`data`) */\n url?: string;\n data?: ArrayBuffer | ArrayBufferView<ArrayBuffer>;\n instances: readonly ModelInstance[];\n /** What the altitudes are above: `'ground'` (the relief, the default) or `'sea'` (the ellipsoid) */\n altitudeReference?: 'ground' | 'sea';\n /** A raster layer draped on the faces looking up (`setDrape`): an ortho on the roofs of a city's models */\n drape?: Drape | undefined;\n}\n\n/** The numbers of instances for the engine: longitude, latitude, altitude, heading, pitch, roll, scale */\nconst instanceNumbers = (instances: readonly ModelInstance[]): Float64Array => {\n const out = new Float64Array(instances.length * 7);\n\n instances.forEach(({ lonLat, altitude = 0, heading = 0, pitch = 0, roll = 0, scale = 1 }, i) => {\n out.set([lonLat[0], lonLat[1], altitude, heading, pitch, roll, scale], i * 7);\n });\n\n return out;\n};\n\n/** A glTF model drawn at positions, in one instanced draw; `pickFeature` gives the instance's index */\nexport class ModelLayer extends Layer {\n private readonly url: string;\n /** The `blob:` URL of the page's bytes, revoked once the layer is gone */\n private readonly blob: string | undefined;\n private instances: Float64Array;\n /** Its glow at night (`setGlow`) */\n private glow: { from: number; color: string } | undefined;\n /** Its feature highlighted (`setHighlight`) */\n private highlight: { feature: number; color: string } | undefined;\n private ground: boolean;\n /** The raster layer draped on it (`setDrape`) */\n private drape: Drape | undefined;\n\n /** @internal */\n constructor(map: LayerHost, options: ModelOptions) {\n super(map);\n\n const { url, data } = options;\n\n if (data) {\n this.blob = URL.createObjectURL(new Blob([data], { type: 'model/gltf-binary' }));\n this.url = this.blob;\n } else if (url) {\n // Against the page: the decoding workers fetch it, and a relative URL would be theirs\n const base = typeof document === 'undefined' ? undefined : document.baseURI;\n\n this.url = base ? new URL(url, base).href : url;\n } else {\n throw new Error('isard: a model needs a url or data');\n }\n this.instances = instanceNumbers(options.instances);\n this.ground = options.altitudeReference !== 'sea';\n this.drape = options.drape;\n }\n\n /** Replaces the instances (and what their altitudes are above, kept if not given) */\n setInstances(instances: readonly ModelInstance[], altitudeReference?: 'ground' | 'sea'): void {\n this.instances = instanceNumbers(instances);\n if (altitudeReference) this.ground = altitudeReference === 'ground';\n // Kept for its creation 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.setModelInstances(this.id, this.instances, this.ground);\n this.map.requestRender();\n }\n\n /** Lights at night the part of the model from `from` metres above its foot (a street lamp's head) in a CSS color;\n * none without a color */\n setGlow(from: number, color?: string): void {\n this.glow = color === undefined ? undefined : { from, color };\n if (this.id < 0) return;\n this.sendGlow(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** Highlights a feature of the model (an IFC model's element, `hit.index` of a pick) in a CSS color (amber by\n * default); none without a feature */\n setHighlight(feature?: number, color = '#ffb000'): void {\n this.highlight = feature === undefined ? undefined : { feature, color };\n if (this.id < 0) return;\n this.sendHighlight(this.map.engine, this.id);\n this.map.requestRender();\n }\n\n /** A raster layer draped on its faces looking up by default (see `Drape`); undefined: none */\n setDrape(drape: Drape | undefined): void {\n this.drape = drape;\n if (this.id < 0) return;\n sendDrape(this.map.engine, this.id, drape);\n this.map.requestRender();\n }\n\n private sendHighlight(engine: Engine, id: number): void {\n const [r = 0, g = 0, b = 0] = this.highlight ? parseColor(this.highlight.color) : [];\n\n engine.setModelHighlight(id, this.highlight ? this.highlight.feature : Number.NaN, r, g, b);\n }\n\n private sendGlow(engine: Engine, id: number): void {\n const [r = 0, g = 0, b = 0] = this.glow ? parseColor(this.glow.color) : [];\n\n engine.setModelGlow(id, this.glow ? this.glow.from : Number.NaN, r, g, b);\n }\n\n /** @internal The instances as the engine takes them (`instanceNumbers`: seven numbers each), above the ground */\n setInstanceNumbers(numbers: Float64Array): void {\n this.instances = numbers;\n this.ground = true;\n if (this.id < 0) return;\n this.map.engine.setModelInstances(this.id, this.instances, this.ground);\n this.map.requestRender();\n }\n\n override remove(): void {\n super.remove();\n this.dispose();\n }\n\n /** @internal */\n override dispose(): void {\n if (this.blob) URL.revokeObjectURL(this.blob);\n }\n\n /** @internal */\n protected create(engine: Engine): number {\n const id = engine.addModels(this.url, this.instances, this.ground);\n\n if (this.glow) this.sendGlow(engine, id);\n if (this.highlight) this.sendHighlight(engine, id);\n // 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 models: 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
  * Point clouds: a COPC file (Cloud Optimized Point Cloud: LAZ 1.4 with an octree, read by HTTP range requests, as the
3
- * IGN distributes LiDAR HD) or a 3D Tiles point cloud (`.pnts`, glTF points), drawn by the engine with 3D Tiles. The
3
+ * IGN distributes LiDAR HD) or a 3D Tiles point cloud (`.pnts`, glTF points). The
4
4
  * COPC file's CRS comes from its WKT (built-in CRSs, or registered ones: `registerCrs`) or the `crs` option; altitudes
5
5
  * in NGF-IGN69 (Lambert-93, the CC zones) are raised by the RAF20 geoid height onto the ellipsoid of the relief and
6
6
  * the 3D Tiles.
@@ -91,7 +91,7 @@ export declare class PointCloudLayer extends Layer {
91
91
  /** Changes the style, the rest kept */
92
92
  setStyle(style: Partial<PointCloudStyle>): void;
93
93
  getStyle(): Readonly<PointCloudStyle>;
94
- /** Loading counters; undefined once removed and while the engine with 3D Tiles loads */
94
+ /** Loading counters; undefined once removed, and while the map waits for a new engine (the GPU lost) */
95
95
  stats(): PointCloudStats | Tiles3dStats | undefined;
96
96
  /** What a COPC file says of itself (points, format, CRS, center, altitudes), once its head is read */
97
97
  info(): PointCloudInfo | undefined;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Point clouds: a COPC file (Cloud Optimized Point Cloud: LAZ 1.4 with an octree, read by HTTP range requests, as the
3
- * IGN distributes LiDAR HD) or a 3D Tiles point cloud (`.pnts`, glTF points), drawn by the engine with 3D Tiles. The
3
+ * IGN distributes LiDAR HD) or a 3D Tiles point cloud (`.pnts`, glTF points). The
4
4
  * COPC file's CRS comes from its WKT (built-in CRSs, or registered ones: `registerCrs`) or the `crs` option; altitudes
5
5
  * in NGF-IGN69 (Lambert-93, the CC zones) are raised by the RAF20 geoid height onto the ellipsoid of the relief and
6
6
  * the 3D Tiles.
@@ -166,7 +166,7 @@ export class PointCloudLayer extends Layer {
166
166
  /** Changes the style, the rest kept */
167
167
  setStyle(style) {
168
168
  this.style = { ...this.style, ...style };
169
- // Kept for its creation while the engine with 3D Tiles loads
169
+ // Kept for its creation in a new engine (the GPU lost and given back), none while it has no id
170
170
  if (this.id < 0)
171
171
  return;
172
172
  this.apply(this.map.engine, this.id);
@@ -175,7 +175,7 @@ export class PointCloudLayer extends Layer {
175
175
  getStyle() {
176
176
  return this.style;
177
177
  }
178
- /** Loading counters; undefined once removed and while the engine with 3D Tiles loads */
178
+ /** Loading counters; undefined once removed, and while the map waits for a new engine (the GPU lost) */
179
179
  stats() {
180
180
  if (this.id < 0)
181
181
  return undefined;