astro-viewer 3.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/astroviewer.cjs +3082 -1410
  2. package/dist/astroviewer.js +1 -1
  3. package/dist/astroviewer.min.js +1 -1
  4. package/lib-esm/AstroSphere.d.ts +40 -16
  5. package/lib-esm/AstroSphere.js +359 -93
  6. package/lib-esm/AstroViewer.d.ts +20 -5
  7. package/lib-esm/AstroViewer.js +50 -0
  8. package/lib-esm/Camera.js +28 -14
  9. package/lib-esm/Config.d.ts +2 -0
  10. package/lib-esm/Config.js +15 -1
  11. package/lib-esm/Global.js +12 -0
  12. package/lib-esm/index.d.ts +8 -4
  13. package/lib-esm/index.js +17 -3
  14. package/lib-esm/model/AbstractSkyEntity.d.ts +1 -0
  15. package/lib-esm/model/AbstractSkyEntity.js +12 -0
  16. package/lib-esm/model/AstroGL.js +12 -0
  17. package/lib-esm/model/ColorMaps.js +12 -0
  18. package/lib-esm/model/MetadataColumn.js +12 -0
  19. package/lib-esm/model/MetadataManager.d.ts +1 -0
  20. package/lib-esm/model/MetadataManager.js +16 -1
  21. package/lib-esm/model/Point.d.ts +9 -1
  22. package/lib-esm/model/Point.js +30 -0
  23. package/lib-esm/model/Point2D.js +12 -0
  24. package/lib-esm/model/Source.js +12 -0
  25. package/lib-esm/model/SphereFoV.d.ts +30 -0
  26. package/lib-esm/model/SphereFoV.js +196 -0
  27. package/lib-esm/model/catalogues/CatalogueGL.js +12 -0
  28. package/lib-esm/model/catalogues/CatalogueProps.js +13 -1
  29. package/lib-esm/model/earth/{wmts/WMTSAdapter.d.ts → WMTSAdapter.d.ts} +2 -1
  30. package/lib-esm/model/earth/{wmts/WMTSAdapter.js → WMTSAdapter.js} +12 -0
  31. package/lib-esm/model/earth/XYZAnchestorTile.d.ts +17 -0
  32. package/lib-esm/model/earth/XYZAnchestorTile.js +87 -0
  33. package/lib-esm/model/earth/{types.d.ts → XYZConfig.d.ts} +6 -17
  34. package/lib-esm/model/earth/XYZConfig.js +13 -0
  35. package/lib-esm/model/earth/XYZFoVHelper.d.ts +12 -0
  36. package/lib-esm/model/earth/XYZFoVHelper.js +138 -0
  37. package/lib-esm/model/earth/XYZMap.d.ts +31 -0
  38. package/lib-esm/model/earth/XYZMap.js +208 -0
  39. package/lib-esm/model/earth/XYZMapDescriptor.d.ts +29 -0
  40. package/lib-esm/model/earth/XYZMapDescriptor.js +77 -0
  41. package/lib-esm/model/earth/XYZMeshBuilder.d.ts +1 -1
  42. package/lib-esm/model/earth/XYZMeshBuilder.js +13 -2
  43. package/lib-esm/model/earth/XYZTile.d.ts +20 -21
  44. package/lib-esm/model/earth/XYZTile.js +82 -102
  45. package/lib-esm/model/earth/XYZTileBuffer.d.ts +24 -26
  46. package/lib-esm/model/earth/XYZTileBuffer.js +60 -70
  47. package/lib-esm/model/earth/XYZTileRequestScheduler.d.ts +1 -1
  48. package/lib-esm/model/earth/XYZTileRequestScheduler.js +13 -2
  49. package/lib-esm/model/earth/XYZTypes.d.ts +24 -0
  50. package/lib-esm/model/earth/XYZTypes.js +13 -0
  51. package/lib-esm/model/earth/XYZVisibleTilesManager.d.ts +16 -27
  52. package/lib-esm/model/earth/XYZVisibleTilesManager.js +61 -192
  53. package/lib-esm/model/footprints/Footprint.d.ts +4 -1
  54. package/lib-esm/model/footprints/Footprint.js +30 -2
  55. package/lib-esm/model/footprints/FootprintProps.js +13 -1
  56. package/lib-esm/model/footprints/FootprintSetGL.d.ts +4 -2
  57. package/lib-esm/model/footprints/FootprintSetGL.js +21 -6
  58. package/lib-esm/model/grid/EquatorialGrid.d.ts +2 -1
  59. package/lib-esm/model/grid/EquatorialGrid.js +30 -12
  60. package/lib-esm/model/grid/GridTextHelper.d.ts +10 -19
  61. package/lib-esm/model/grid/GridTextHelper.js +70 -67
  62. package/lib-esm/model/grid/HealpixGrid.d.ts +4 -4
  63. package/lib-esm/model/grid/HealpixGrid.js +24 -8
  64. package/lib-esm/model/grid/LonLatGrid.d.ts +43 -0
  65. package/lib-esm/model/grid/LonLatGrid.js +309 -0
  66. package/lib-esm/model/hips/AllSky.js +12 -0
  67. package/lib-esm/model/hips/AncestorTile.js +12 -0
  68. package/lib-esm/model/hips/FoVHelper.d.ts +5 -2
  69. package/lib-esm/model/hips/FoVHelper.js +52 -3
  70. package/lib-esm/model/hips/HiPS.d.ts +2 -0
  71. package/lib-esm/model/hips/HiPS.js +38 -14
  72. package/lib-esm/model/hips/HiPSConfig.d.ts +13 -0
  73. package/lib-esm/model/hips/HiPSDescriptor.js +12 -0
  74. package/lib-esm/model/hips/Tile.d.ts +1 -0
  75. package/lib-esm/model/hips/Tile.js +15 -0
  76. package/lib-esm/model/hips/TileBuffer.d.ts +5 -0
  77. package/lib-esm/model/hips/TileBuffer.js +61 -0
  78. package/lib-esm/model/hips/VisibleTilesManager.js +12 -0
  79. package/lib-esm/model/tap/TapMetadata.js +12 -0
  80. package/lib-esm/model/tap/TapMetadataList.js +12 -0
  81. package/lib-esm/model/tap/TapRepo.js +12 -0
  82. package/lib-esm/model/terra/TerraFootprintSetGL.d.ts +6 -0
  83. package/lib-esm/model/terra/TerraFootprintSetGL.js +54 -0
  84. package/lib-esm/model/terra/TerraPointSetGL.js +12 -0
  85. package/lib-esm/services/SesameService.js +11 -3
  86. package/lib-esm/services/helpers.js +12 -0
  87. package/lib-esm/services/hipsNodeService.js +12 -0
  88. package/lib-esm/services/parse-hipslist.js +12 -0
  89. package/lib-esm/services/queryCatalogueByFoV.js +13 -1
  90. package/lib-esm/services/queryFootprintSetByFov.js +13 -1
  91. package/lib-esm/services/tapRepoService.js +13 -1
  92. package/lib-esm/services/types.js +12 -0
  93. package/lib-esm/shader/CatalogueShaderProgram.js +12 -0
  94. package/lib-esm/shader/FootprintShaderProgram.js +12 -0
  95. package/lib-esm/shader/GridShaderManager.js +12 -0
  96. package/lib-esm/shader/HiPSShaderProgram.js +12 -0
  97. package/lib-esm/shader/ShaderManager.js +12 -1
  98. package/lib-esm/shader/ShaderManagerMutliHiPS.js +12 -1
  99. package/lib-esm/shader/XYZShaderProgram.d.ts +14 -1
  100. package/lib-esm/shader/XYZShaderProgram.js +127 -2
  101. package/lib-esm/utils/CoordsType.d.ts +2 -1
  102. package/lib-esm/utils/CoordsType.js +13 -0
  103. package/lib-esm/utils/FoVUtils.js +12 -0
  104. package/lib-esm/utils/GeoJSONParser.d.ts +19 -0
  105. package/lib-esm/utils/GeoJSONParser.js +112 -0
  106. package/lib-esm/utils/GeomUtils.js +12 -0
  107. package/lib-esm/utils/MouseHelper.js +12 -0
  108. package/lib-esm/utils/PerspectiveMatrixManager.js +16 -1
  109. package/lib-esm/utils/RayPickingUtils.js +12 -0
  110. package/lib-esm/utils/STCSParser.d.ts +7 -3
  111. package/lib-esm/utils/STCSParser.js +27 -9
  112. package/lib-esm/utils/ShaderUtility.js +13 -1
  113. package/lib-esm/utils/Utils.js +12 -0
  114. package/lib-esm/utils/XYZRayPickingUtils.d.ts +27 -0
  115. package/lib-esm/utils/XYZRayPickingUtils.js +226 -0
  116. package/package.json +2 -2
  117. package/lib-esm/model/FoV.d.ts +0 -62
  118. package/lib-esm/model/FoV.js +0 -274
  119. package/lib-esm/model/earth/XYZAncestorMeshCache.d.ts +0 -10
  120. package/lib-esm/model/earth/XYZAncestorMeshCache.js +0 -31
  121. package/lib-esm/model/earth/XYZLayer.d.ts +0 -31
  122. package/lib-esm/model/earth/XYZLayer.js +0 -231
  123. package/lib-esm/model/earth/XYZTileProvider.d.ts +0 -29
  124. package/lib-esm/model/earth/XYZTileProvider.js +0 -187
  125. package/lib-esm/model/earth/wmts/types.d.ts +0 -1
  126. package/lib-esm/model/earth/wmts/types.js +0 -1
  127. /package/lib-esm/model/{earth/types.js → hips/HiPSConfig.js} +0 -0
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  import global from '../../Global.js';
2
14
  import { Pointing, Vec3 } from 'healpixjs';
3
15
  import RayPickingUtils from '../../utils/RayPickingUtils.js';
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  'use strict';
2
14
  /**
3
15
  * @author Fabrizio Giordano (Fab77)
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  'use strict';
2
14
  export class TapMetadataList {
3
15
  _posEqRAMetaColumns; // ucd.includes('pos.eq.ra')
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  export class TapRepo {
2
14
  _adqlFunctionList;
3
15
  _cataloguesList;
@@ -1,4 +1,10 @@
1
1
  import { FootprintSetGL } from '../footprints/FootprintSetGL.js';
2
+ import { CoordsType } from '../../utils/CoordsType.js';
3
+ import { ParsedGeoJSONFeature } from '../../utils/GeoJSONParser.js';
2
4
  export declare class TerraFootprintSetGL extends FootprintSetGL {
3
5
  _kind: string;
6
+ protected _coordsType: CoordsType.GEOGRAPHIC;
7
+ addGeoJSONFeatures(features: ParsedGeoJSONFeature[]): void;
8
+ private createGeoJSONMetadataColumns;
9
+ private createGeoJSONDetails;
4
10
  }
@@ -1,4 +1,58 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  import { FootprintSetGL } from '../footprints/FootprintSetGL.js';
14
+ import { CoordsType } from '../../utils/CoordsType.js';
15
+ import { Footprint } from '../footprints/Footprint.js';
16
+ import { MetadataColumn } from '../MetadataColumn.js';
17
+ import { MetadataManager } from '../MetadataManager.js';
18
+ import { ColumnType } from '../MetadataColumn.js';
2
19
  export class TerraFootprintSetGL extends FootprintSetGL {
3
20
  _kind = 'TerraFootprintSetGL';
21
+ _coordsType = CoordsType.GEOGRAPHIC;
22
+ addGeoJSONFeatures(features) {
23
+ this._ready = false;
24
+ this.clearFootprints();
25
+ this._metadataManager = new MetadataManager(this.createGeoJSONMetadataColumns(features));
26
+ for (const feature of features) {
27
+ const footprint = Footprint.fromPolygons(feature.polygons, this.createGeoJSONDetails(feature), CoordsType.GEOGRAPHIC);
28
+ if (footprint.valid) {
29
+ this.addFootprint(footprint);
30
+ this.totPoints += footprint.totPoints;
31
+ this.totConvexPoints += footprint.totConvexPoints;
32
+ }
33
+ }
34
+ this._ready = true;
35
+ this._bufferInitialised = false;
36
+ }
37
+ createGeoJSONMetadataColumns(features) {
38
+ const names = new Set();
39
+ features.forEach(feature => Object.keys(feature.properties).forEach(name => names.add(name)));
40
+ return Array.from(names).map((name, index) => {
41
+ const values = features.map(feature => feature.properties[name]).filter(value => value !== null && value !== undefined && value !== '');
42
+ const isNumber = values.length > 0 && values.every(value => typeof value === 'number' || !Number.isNaN(Number(value)));
43
+ const isName = /^name$|nome|denominazione|label|title/i.test(name);
44
+ return new MetadataColumn({
45
+ index,
46
+ name,
47
+ columnType: isName ? ColumnType.MAIN_NAME : (isNumber ? ColumnType.NUMBER : ColumnType.STRING),
48
+ unit: '',
49
+ });
50
+ });
51
+ }
52
+ createGeoJSONDetails(feature) {
53
+ return Object.entries(feature.properties).map(([key, value]) => ({
54
+ key,
55
+ value: typeof value === 'number' ? value : String(value ?? ''),
56
+ }));
57
+ }
4
58
  }
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  import { CatalogueGL } from '../catalogues/CatalogueGL.js';
2
14
  export class TerraPointSetGL extends CatalogueGL {
3
15
  _kind = 'TerraPointSetGL';
@@ -1,6 +1,14 @@
1
- // SesameService.ts
2
- /**
3
- * @author Fabrizio Giordano (Fab)
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
4
12
  */
5
13
  class SesameService {
6
14
  baseURL = 'https://cdsweb.u-strasbg.fr/cgi-bin/nph-sesame/-ox?';
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  // helpers.ts
2
14
  export const toHttps = (url) => url.startsWith('http:') ? url.replace('http:', 'https:') : url;
3
15
  export const urlJoin = (base, path) => new URL(path.replace(/^\/+/, ''), base).toString();
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  // hips-node-repo.ts
2
14
  import { HiPSDescriptor } from '../model/hips/HiPSDescriptor.js';
3
15
  import { toHttps, urlJoin, fetchText, fetchJson } from './helpers.js';
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  export function parseHipsList(text) {
2
14
  const out = [];
3
15
  let current = null;
@@ -1,8 +1,20 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
13
+ export {};
1
14
  // import {CatalogueGL} from '../model/catalogues/CatalogueGL.js'
2
15
  // import {TapMetadata} from '../model/tap/TapMetadata.js'
3
16
  // import {TapMetadataList} from '../model/tap/TapMetadataList.js'
4
17
  // import { queryAsync } from './tapRepoService.js'
5
- export {};
6
18
  // // Optional timeout; adjust or remove if you don’t use timeouts.
7
19
  // const TAP_QUERY_TIMEOUT_MS = 60_000
8
20
  // // Small helpers to be robust with slightly different metadata shapes
@@ -1,3 +1,16 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
13
+ export {};
1
14
  // import {FootprintSetGL} from '../model/footprints/FootprintSetGL.js'
2
15
  // import healpixGridSingleton from '../model/grid/HealpixGridSingleton.js';
3
16
  // import Point from '../model/Point.js';
@@ -5,7 +18,6 @@
5
18
  // import {TapMetadataList} from '../model/tap/TapMetadataList.js'
6
19
  // import { TapRepo } from '../model/tap/TapRepo.js';
7
20
  // import { queryAsync } from './tapRepoService.js'
8
- export {};
9
21
  // interface ColumnLike {
10
22
  // _name: string;
11
23
  // }
@@ -1,9 +1,21 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
13
+ export {};
1
14
  // // addTAPRepo.ts
2
15
  // import { TapRepo } from '../model/tap/TapRepo.js'
3
16
  // import {TapMetadata} from '../model/tap/TapMetadata.js'
4
17
  // import {TapMetadataList} from '../model/tap/TapMetadataList.js'
5
18
  // import global from '../Global.js'
6
- export {};
7
19
  // import {CatalogueGL} from '../model/catalogues/CatalogueGL.js'
8
20
  // import {FootprintSetGL} from '../model/footprints/FootprintSetGL.js'
9
21
  // let catId = 1
@@ -1 +1,13 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  export {};
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  // HiPSShaderProgram.ts
2
14
  import { mat4 } from 'gl-matrix';
3
15
  import ShaderManager from './ShaderManager.js';
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  // HiPSShaderProgram.ts
2
14
  import { mat4 } from 'gl-matrix';
3
15
  import ShaderManager from './ShaderManager.js';
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  // GridShaderManager.ts
2
14
  'use strict';
3
15
  class GridShaderManager {
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  // HiPSShaderProgram.ts
2
14
  import ShaderManager from './ShaderManager.js';
3
15
  import { ColorMaps } from '../model/ColorMaps.js';
@@ -1,4 +1,15 @@
1
- // ShaderManager.ts
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
2
13
  export default class ShaderManager {
3
14
  static catalogueVS() {
4
15
  return `#version 300 es
@@ -1,4 +1,15 @@
1
- // ShaderManagerMultiHiPS.ts
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
2
13
  export default class ShaderManagerMultiHiPS {
3
14
  static hipsVS() {
4
15
  return `#version 300 es
@@ -3,6 +3,7 @@ type XYZLocations = {
3
3
  mMatrix: WebGLUniformLocation | null;
4
4
  vMatrix: WebGLUniformLocation | null;
5
5
  sampler: WebGLUniformLocation | null;
6
+ colorMapIdx: WebGLUniformLocation | null;
6
7
  vertexPositionAttribute: number;
7
8
  textureCoordAttribute: number;
8
9
  };
@@ -10,11 +11,23 @@ export declare class XYZShaderProgram {
10
11
  readonly locations: XYZLocations;
11
12
  private _webgl;
12
13
  private _shaderProgram?;
14
+ private _colorMapBlockIndex;
15
+ private _colorMapBuffer;
16
+ private _runtimeColorMap;
17
+ private _colorMapVariableInfo;
13
18
  constructor(webgl: WebGL2RenderingContext);
14
19
  get shaderProgram(): WebGLProgram;
15
20
  enableProgram(): void;
16
- enableShaders(pMatrix: Float32Array, vMatrix: Float32Array, mMatrix: Float32Array): void;
21
+ setRuntimeColorMap(colorMap: {
22
+ r: Float32Array;
23
+ g: Float32Array;
24
+ b: Float32Array;
25
+ } | undefined): void;
26
+ enableShaders(pMatrix: Float32Array, vMatrix: Float32Array, mMatrix: Float32Array, colorMapIdx?: number): void;
17
27
  private initShaders;
18
28
  private compileShader;
29
+ private initColorMapBuffer;
30
+ private uploadColorMap;
31
+ private getColorMap;
19
32
  }
20
33
  export {};
@@ -1,7 +1,28 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
13
+ import { ColorMaps } from '../model/ColorMaps.js';
1
14
  export class XYZShaderProgram {
2
15
  locations;
3
16
  _webgl;
4
17
  _shaderProgram;
18
+ _colorMapBlockIndex = null;
19
+ _colorMapBuffer = null;
20
+ _runtimeColorMap;
21
+ _colorMapVariableInfo = {
22
+ r_palette: { index: 0, offset: 0 },
23
+ g_palette: { index: 0, offset: 0 },
24
+ b_palette: { index: 0, offset: 0 },
25
+ };
5
26
  constructor(webgl) {
6
27
  this._webgl = webgl;
7
28
  this.locations = {
@@ -9,6 +30,7 @@ export class XYZShaderProgram {
9
30
  mMatrix: null,
10
31
  vMatrix: null,
11
32
  sampler: null,
33
+ colorMapIdx: null,
12
34
  vertexPositionAttribute: -1,
13
35
  textureCoordAttribute: -1,
14
36
  };
@@ -29,7 +51,10 @@ export class XYZShaderProgram {
29
51
  enableProgram() {
30
52
  this._webgl.useProgram(this.shaderProgram);
31
53
  }
32
- enableShaders(pMatrix, vMatrix, mMatrix) {
54
+ setRuntimeColorMap(colorMap) {
55
+ this._runtimeColorMap = colorMap;
56
+ }
57
+ enableShaders(pMatrix, vMatrix, mMatrix, colorMapIdx = 0) {
33
58
  const gl = this._webgl;
34
59
  const program = this.shaderProgram;
35
60
  gl.useProgram(program);
@@ -37,12 +62,17 @@ export class XYZShaderProgram {
37
62
  this.locations.mMatrix = gl.getUniformLocation(program, 'uMMatrix');
38
63
  this.locations.vMatrix = gl.getUniformLocation(program, 'uVMatrix');
39
64
  this.locations.sampler = gl.getUniformLocation(program, 'uSampler');
65
+ this.locations.colorMapIdx = gl.getUniformLocation(program, 'cmapIdx');
40
66
  this.locations.vertexPositionAttribute = gl.getAttribLocation(program, 'aVertexPosition');
41
67
  this.locations.textureCoordAttribute = gl.getAttribLocation(program, 'aTextureCoord');
42
68
  gl.uniformMatrix4fv(this.locations.pMatrix, false, pMatrix);
43
69
  gl.uniformMatrix4fv(this.locations.vMatrix, false, vMatrix);
44
70
  gl.uniformMatrix4fv(this.locations.mMatrix, false, mMatrix);
45
71
  gl.uniform1i(this.locations.sampler, 0);
72
+ gl.uniform1i(this.locations.colorMapIdx, colorMapIdx);
73
+ if (colorMapIdx >= 2) {
74
+ this.uploadColorMap(colorMapIdx);
75
+ }
46
76
  }
47
77
  initShaders() {
48
78
  const gl = this._webgl;
@@ -61,9 +91,40 @@ export class XYZShaderProgram {
61
91
  precision mediump float;
62
92
  in vec2 vTextureCoord;
63
93
  uniform sampler2D uSampler;
94
+ uniform int cmapIdx;
95
+
96
+ layout (std140) uniform colormap {
97
+ float r_palette[256];
98
+ float g_palette[256];
99
+ float b_palette[256];
100
+ };
101
+
64
102
  out vec4 outColor;
103
+
65
104
  void main(void) {
66
- outColor = texture(uSampler, vTextureCoord);
105
+ vec4 color = texture(uSampler, vTextureCoord);
106
+
107
+ if (cmapIdx == 1) {
108
+ float gray = 0.21 * color.r + 0.71 * color.g + 0.07 * color.b;
109
+ outColor = vec4(vec3(gray), color.a);
110
+ return;
111
+ }
112
+
113
+ if (cmapIdx >= 2) {
114
+ int rIndex = int(clamp(color.r * 255.0, 0.0, 255.0));
115
+ int gIndex = int(clamp(color.g * 255.0, 0.0, 255.0));
116
+ int bIndex = int(clamp(color.b * 255.0, 0.0, 255.0));
117
+
118
+ outColor = vec4(
119
+ r_palette[rIndex] / 256.0,
120
+ g_palette[gIndex] / 256.0,
121
+ b_palette[bIndex] / 256.0,
122
+ color.a
123
+ );
124
+ return;
125
+ }
126
+
127
+ outColor = color;
67
128
  }`);
68
129
  gl.attachShader(this._shaderProgram, vertexShader);
69
130
  gl.attachShader(this._shaderProgram, fragmentShader);
@@ -71,6 +132,7 @@ export class XYZShaderProgram {
71
132
  if (!gl.getProgramParameter(this._shaderProgram, gl.LINK_STATUS)) {
72
133
  throw new Error(gl.getProgramInfoLog(this._shaderProgram) || 'Could not initialise XYZ shaders');
73
134
  }
135
+ this.initColorMapBuffer();
74
136
  }
75
137
  compileShader(type, source) {
76
138
  const gl = this._webgl;
@@ -85,4 +147,67 @@ export class XYZShaderProgram {
85
147
  }
86
148
  return shader;
87
149
  }
150
+ initColorMapBuffer() {
151
+ const gl = this._webgl;
152
+ const program = this._shaderProgram;
153
+ const blockIndex = gl.getUniformBlockIndex(program, 'colormap');
154
+ if (blockIndex === gl.INVALID_INDEX) {
155
+ this._colorMapBlockIndex = null;
156
+ return;
157
+ }
158
+ this._colorMapBlockIndex = blockIndex;
159
+ const variableNames = ['r_palette', 'g_palette', 'b_palette'];
160
+ const variableIndices = gl.getUniformIndices(program, variableNames);
161
+ const variableOffsets = gl.getActiveUniforms(program, variableIndices, gl.UNIFORM_OFFSET);
162
+ variableNames.forEach((name, index) => {
163
+ this._colorMapVariableInfo[name] = {
164
+ index: variableIndices[index],
165
+ offset: variableOffsets[index],
166
+ };
167
+ });
168
+ this._colorMapBuffer = gl.createBuffer();
169
+ gl.bindBuffer(gl.UNIFORM_BUFFER, this._colorMapBuffer);
170
+ gl.bufferData(gl.UNIFORM_BUFFER, 3 * 4096, gl.STATIC_DRAW);
171
+ gl.bindBuffer(gl.UNIFORM_BUFFER, null);
172
+ gl.bindBufferBase(gl.UNIFORM_BUFFER, 0, this._colorMapBuffer);
173
+ gl.uniformBlockBinding(program, blockIndex, 0);
174
+ }
175
+ uploadColorMap(colorMapIdx) {
176
+ if (!this._colorMapBuffer || this._colorMapBlockIndex === null) {
177
+ return;
178
+ }
179
+ const colorMap = this.getColorMap(colorMapIdx);
180
+ if (!colorMap) {
181
+ return;
182
+ }
183
+ const gl = this._webgl;
184
+ const program = this.shaderProgram;
185
+ gl.uniformBlockBinding(program, this._colorMapBlockIndex, 0);
186
+ gl.bindBuffer(gl.UNIFORM_BUFFER, this._colorMapBuffer);
187
+ const info = this._colorMapVariableInfo;
188
+ gl.bufferSubData(gl.UNIFORM_BUFFER, info.r_palette.offset, colorMap.r, 0);
189
+ gl.bufferSubData(gl.UNIFORM_BUFFER, info.g_palette.offset, colorMap.g, 0);
190
+ gl.bufferSubData(gl.UNIFORM_BUFFER, info.b_palette.offset, colorMap.b, 0);
191
+ gl.bindBuffer(gl.UNIFORM_BUFFER, null);
192
+ }
193
+ getColorMap(colorMapIdx) {
194
+ switch (colorMapIdx) {
195
+ case 2:
196
+ return ColorMaps.planck;
197
+ case 3:
198
+ return ColorMaps.cmb;
199
+ case 4:
200
+ return ColorMaps.rainbow;
201
+ case 5:
202
+ return ColorMaps.eosb;
203
+ case 6:
204
+ return ColorMaps.cubehelix;
205
+ case 7:
206
+ return ColorMaps.hot;
207
+ case 8:
208
+ return ColorMaps.gray;
209
+ default:
210
+ return this._runtimeColorMap;
211
+ }
212
+ }
88
213
  }
@@ -5,5 +5,6 @@
5
5
  export declare enum CoordsType {
6
6
  CARTESIAN = "cartesian",
7
7
  SPHERICAL = "spherical",
8
- ASTRO = "astro"
8
+ ASTRO = "astro",
9
+ GEOGRAPHIC = "geographic"
9
10
  }
@@ -1,3 +1,15 @@
1
+ /*
2
+ * AstroViewer
3
+ * Copyright (C) Fabrizio Giordano
4
+ * SPDX-License-Identifier: LicenseRef-AstroViewer-Dual-License
5
+ *
6
+ * This file is part of AstroViewer.
7
+ * AstroViewer is distributed under a dual-license model.
8
+ * Commercial use requires a separate commercial license.
9
+ * Non-commercial use is governed by LICENSE-NONCOMMERCIAL.md.
10
+ *
11
+ * See LICENSE.md, LICENSE-COMMERCIAL.md, and LICENSE-NONCOMMERCIAL.md for details.
12
+ */
1
13
  /**
2
14
  * Enum for coordinate types.
3
15
  * @author Fabrizio Giordano (Fab77)
@@ -7,5 +19,6 @@ export var CoordsType;
7
19
  CoordsType["CARTESIAN"] = "cartesian";
8
20
  CoordsType["SPHERICAL"] = "spherical";
9
21
  CoordsType["ASTRO"] = "astro";
22
+ CoordsType["GEOGRAPHIC"] = "geographic";
10
23
  })(CoordsType || (CoordsType = {}));
11
24
  // export default CoordsType;