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,187 +0,0 @@
1
- import global from '../../Global.js';
2
- const MAX_MERCATOR_LAT = 85.0511287798066;
3
- export class XYZTileProvider {
4
- _config;
5
- constructor(config) {
6
- this._config = config;
7
- }
8
- get config() {
9
- return this._config;
10
- }
11
- get minZoom() {
12
- return Math.max(0, Math.floor(this._config.minZoom ?? 0));
13
- }
14
- get maxZoom() {
15
- return Math.max(this.minZoom, Math.floor(this._config.maxZoom ?? 6));
16
- }
17
- getInitialTiles() {
18
- return this.getVisibleTilesAtZoom(1, null, [], [], 1);
19
- }
20
- getTileUrl(tile) {
21
- if (this._config.urlResolver) {
22
- return this._config.urlResolver(tile);
23
- }
24
- const effectiveY = this.getEffectiveTileY(tile);
25
- const subdomain = this.getSubdomain(tile);
26
- return this._config.urlTemplate
27
- .replace(/\{z\}/g, String(tile.z))
28
- .replace(/\{x\}/g, String(tile.x))
29
- .replace(/\{y\}/g, String(effectiveY))
30
- .replace(/\{s\}/g, subdomain);
31
- }
32
- resolveZoom(fovDeg) {
33
- const safeFov = Math.max(0.01, Math.min(180, fovDeg));
34
- const targetTileWidthDeg = Math.max(0.01, safeFov / 2);
35
- const rawZoom = Math.ceil(Math.log2(360 / targetTileWidthDeg));
36
- return this.clampZoom(rawZoom);
37
- }
38
- clampZoom(zoom) {
39
- return Math.max(this.minZoom, Math.min(this.maxZoom, zoom));
40
- }
41
- getEffectiveTileY(tile) {
42
- if (!this._config.flipY) {
43
- return tile.y;
44
- }
45
- const dim = 2 ** tile.z;
46
- return dim - 1 - tile.y;
47
- }
48
- getSubdomain(tile) {
49
- const subdomains = this._config.subdomains ?? [];
50
- if (subdomains.length === 0) {
51
- return '';
52
- }
53
- const index = Math.abs(tile.x + tile.y + tile.z) % subdomains.length;
54
- return subdomains[index] ?? '';
55
- }
56
- getVisibleTilesAtZoom(z, centerSphericalDeg, fovPolygon, viewportSphericalSamples, padding = 1) {
57
- const dim = 2 ** z;
58
- const center = this.resolveViewCenter(null, centerSphericalDeg);
59
- const normalizedCenterLon = this.normalizeLonAround(center.lonDeg, center.lonDeg);
60
- const polygonPoints = fovPolygon.length > 0
61
- ? fovPolygon.map((point) => ({
62
- lonDeg: this.normalizeLonAround(point.raDeg > 180 ? point.raDeg - 360 : point.raDeg, normalizedCenterLon),
63
- latDeg: point.decDeg,
64
- }))
65
- : [center];
66
- const samplePoints = viewportSphericalSamples.map((sample) => ({
67
- lonDeg: this.normalizeLonAround(sample.phi > 180 ? sample.phi - 360 : sample.phi, normalizedCenterLon),
68
- latDeg: 90 - sample.theta,
69
- }));
70
- const coveragePoints = [center, ...polygonPoints, ...samplePoints];
71
- let minLon = normalizedCenterLon;
72
- let maxLon = normalizedCenterLon;
73
- let minLat = center.latDeg;
74
- let maxLat = center.latDeg;
75
- for (const point of coveragePoints) {
76
- minLon = Math.min(minLon, point.lonDeg);
77
- maxLon = Math.max(maxLon, point.lonDeg);
78
- minLat = Math.min(minLat, point.latDeg);
79
- maxLat = Math.max(maxLat, point.latDeg);
80
- }
81
- const adaptivePadding = Math.max(padding, Math.min(3, Math.max(1, Math.ceil(z / 3))));
82
- const minX = Math.floor(((minLon + 180) / 360) * dim) - adaptivePadding;
83
- const maxX = Math.floor(((maxLon + 180) / 360) * dim) + adaptivePadding;
84
- const minY = Math.floor(this.latToTileY(maxLat, z)) - adaptivePadding;
85
- const maxY = Math.floor(this.latToTileY(minLat, z)) + adaptivePadding;
86
- const tiles = [];
87
- for (let x = minX; x <= maxX; x++) {
88
- for (let y = minY; y <= maxY; y++) {
89
- tiles.push({
90
- z,
91
- x: this.wrapTileX(x, dim),
92
- y: this.clampTileY(y, dim),
93
- });
94
- }
95
- }
96
- for (const point of coveragePoints) {
97
- const centerTileX = Math.floor(((point.lonDeg + 180) / 360) * dim);
98
- const centerTileY = Math.floor(this.latToTileY(point.latDeg, z));
99
- for (let dx = -adaptivePadding; dx <= adaptivePadding; dx++) {
100
- for (let dy = -adaptivePadding; dy <= adaptivePadding; dy++) {
101
- tiles.push({
102
- z,
103
- x: this.wrapTileX(centerTileX + dx, dim),
104
- y: this.clampTileY(centerTileY + dy, dim),
105
- });
106
- }
107
- }
108
- }
109
- return this.deduplicateTiles(tiles);
110
- }
111
- tileFromSpherical(zoom, sphericalDeg) {
112
- const lonDeg = sphericalDeg.phi > 180 ? sphericalDeg.phi - 360 : sphericalDeg.phi;
113
- const latDeg = 90 - sphericalDeg.theta;
114
- const dim = 2 ** zoom;
115
- const x = Math.floor(((lonDeg + 180) / 360) * dim);
116
- const y = Math.floor(this.latToTileY(latDeg, zoom));
117
- return {
118
- z: zoom,
119
- x: this.wrapTileX(x, dim),
120
- y: this.clampTileY(y, dim),
121
- };
122
- }
123
- getNeighborTiles(tile, ring = 1) {
124
- const dim = 2 ** tile.z;
125
- const neighbors = [];
126
- for (let dx = -ring; dx <= ring; dx++) {
127
- for (let dy = -ring; dy <= ring; dy++) {
128
- neighbors.push({
129
- z: tile.z,
130
- x: this.wrapTileX(tile.x + dx, dim),
131
- y: this.clampTileY(tile.y + dy, dim),
132
- });
133
- }
134
- }
135
- return this.deduplicateTiles(neighbors);
136
- }
137
- deduplicateTiles(tiles) {
138
- const unique = new Map();
139
- for (const tile of tiles) {
140
- unique.set(`${tile.z}/${tile.x}/${tile.y}`, tile);
141
- }
142
- return Array.from(unique.values());
143
- }
144
- resolveViewCenter(camera, centerSphericalDeg) {
145
- if (centerSphericalDeg) {
146
- return {
147
- lonDeg: centerSphericalDeg.phi > 180 ? centerSphericalDeg.phi - 360 : centerSphericalDeg.phi,
148
- latDeg: 90 - centerSphericalDeg.theta,
149
- };
150
- }
151
- if (!camera) {
152
- return { lonDeg: 0, latDeg: 0 };
153
- }
154
- const [x, y, z] = camera.getCameraPosition();
155
- const len = Math.hypot(x, y, z);
156
- if (!Number.isFinite(len) || len === 0) {
157
- return { lonDeg: 0, latDeg: 0 };
158
- }
159
- const scale = global.insideSphere ? 1 / len : -1 / len;
160
- const vx = x * scale;
161
- const vy = y * scale;
162
- const vz = z * scale;
163
- const lonDeg = (Math.atan2(vy, vx) * 180) / Math.PI;
164
- const latDeg = (Math.asin(Math.max(-1, Math.min(1, vz))) * 180) / Math.PI;
165
- return { lonDeg, latDeg };
166
- }
167
- latToTileY(latDeg, z) {
168
- const lat = Math.max(-MAX_MERCATOR_LAT, Math.min(MAX_MERCATOR_LAT, latDeg));
169
- const latRad = (lat * Math.PI) / 180;
170
- const n = 2 ** z;
171
- return ((1 - Math.asinh(Math.tan(latRad)) / Math.PI) / 2) * n;
172
- }
173
- wrapTileX(x, dim) {
174
- return ((x % dim) + dim) % dim;
175
- }
176
- normalizeLonAround(lonDeg, referenceLonDeg) {
177
- let lon = lonDeg;
178
- while (lon - referenceLonDeg > 180)
179
- lon -= 360;
180
- while (lon - referenceLonDeg < -180)
181
- lon += 360;
182
- return lon;
183
- }
184
- clampTileY(y, dim) {
185
- return Math.max(0, Math.min(dim - 1, y));
186
- }
187
- }
@@ -1 +0,0 @@
1
- export type {};
@@ -1 +0,0 @@
1
- export {};