astro-viewer 2.0.0 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/astroviewer.cjs +19832 -16986
  2. package/dist/astroviewer.js +1 -1
  3. package/dist/astroviewer.min.js +1 -1
  4. package/lib-esm/AstroSphere.d.ts +31 -2
  5. package/lib-esm/AstroSphere.js +267 -16
  6. package/lib-esm/AstroViewer.d.ts +33 -2
  7. package/lib-esm/AstroViewer.js +93 -0
  8. package/lib-esm/Camera.js +24 -8
  9. package/lib-esm/Config.js +12 -0
  10. package/lib-esm/Global.js +12 -0
  11. package/lib-esm/index.d.ts +8 -1
  12. package/lib-esm/index.js +18 -1
  13. package/lib-esm/model/AbstractSkyEntity.d.ts +10 -0
  14. package/lib-esm/model/AbstractSkyEntity.js +12 -0
  15. package/lib-esm/model/AstroGL.js +12 -0
  16. package/lib-esm/model/ColorMaps.js +12 -0
  17. package/lib-esm/model/MetadataColumn.js +12 -0
  18. package/lib-esm/model/MetadataManager.js +12 -0
  19. package/lib-esm/model/Point.js +12 -0
  20. package/lib-esm/model/Point2D.js +12 -0
  21. package/lib-esm/model/Source.js +12 -0
  22. package/lib-esm/model/SphereFoV.d.ts +30 -0
  23. package/lib-esm/model/SphereFoV.js +195 -0
  24. package/lib-esm/model/catalogues/CatalogueGL.js +12 -0
  25. package/lib-esm/model/catalogues/CatalogueProps.js +13 -1
  26. package/lib-esm/model/earth/WMTSAdapter.d.ts +12 -0
  27. package/lib-esm/model/earth/WMTSAdapter.js +97 -0
  28. package/lib-esm/model/earth/XYZAnchestorTile.d.ts +17 -0
  29. package/lib-esm/model/earth/XYZAnchestorTile.js +87 -0
  30. package/lib-esm/model/earth/XYZConfig.d.ts +72 -0
  31. package/lib-esm/model/earth/XYZConfig.js +13 -0
  32. package/lib-esm/model/earth/XYZFoVHelper.d.ts +9 -0
  33. package/lib-esm/model/earth/XYZFoVHelper.js +101 -0
  34. package/lib-esm/model/earth/XYZMap.d.ts +31 -0
  35. package/lib-esm/model/earth/XYZMap.js +208 -0
  36. package/lib-esm/model/earth/XYZMapDescriptor.d.ts +29 -0
  37. package/lib-esm/model/earth/XYZMapDescriptor.js +77 -0
  38. package/lib-esm/model/earth/XYZMeshBuilder.d.ts +6 -0
  39. package/lib-esm/model/earth/XYZMeshBuilder.js +108 -0
  40. package/lib-esm/model/earth/XYZTile.d.ts +38 -0
  41. package/lib-esm/model/earth/XYZTile.js +167 -0
  42. package/lib-esm/model/earth/XYZTileBuffer.d.ts +37 -0
  43. package/lib-esm/model/earth/XYZTileBuffer.js +139 -0
  44. package/lib-esm/model/earth/XYZTileRequestScheduler.d.ts +25 -0
  45. package/lib-esm/model/earth/XYZTileRequestScheduler.js +172 -0
  46. package/lib-esm/model/earth/XYZTypes.d.ts +24 -0
  47. package/lib-esm/model/earth/XYZTypes.js +13 -0
  48. package/lib-esm/model/earth/XYZVisibleTilesManager.d.ts +19 -0
  49. package/lib-esm/model/earth/XYZVisibleTilesManager.js +77 -0
  50. package/lib-esm/model/footprints/Footprint.js +12 -0
  51. package/lib-esm/model/footprints/FootprintProps.js +13 -1
  52. package/lib-esm/model/footprints/FootprintSetGL.js +13 -1
  53. package/lib-esm/model/grid/EquatorialGrid.js +20 -6
  54. package/lib-esm/model/grid/GridTextHelper.d.ts +10 -19
  55. package/lib-esm/model/grid/GridTextHelper.js +70 -67
  56. package/lib-esm/model/grid/HealpixGrid.d.ts +4 -4
  57. package/lib-esm/model/grid/HealpixGrid.js +19 -6
  58. package/lib-esm/model/grid/LonLatGrid.d.ts +40 -0
  59. package/lib-esm/model/grid/LonLatGrid.js +258 -0
  60. package/lib-esm/model/hips/AllSky.js +12 -0
  61. package/lib-esm/model/hips/AncestorTile.js +12 -0
  62. package/lib-esm/model/hips/FoVHelper.js +12 -0
  63. package/lib-esm/model/hips/HiPS.js +12 -9
  64. package/lib-esm/model/hips/HiPSDescriptor.js +12 -0
  65. package/lib-esm/model/hips/Tile.js +12 -0
  66. package/lib-esm/model/hips/TileBuffer.js +12 -0
  67. package/lib-esm/model/hips/VisibleTilesManager.js +12 -0
  68. package/lib-esm/model/tap/TapMetadata.js +12 -0
  69. package/lib-esm/model/tap/TapMetadataList.js +12 -0
  70. package/lib-esm/model/tap/TapRepo.js +12 -0
  71. package/lib-esm/model/terra/TerraFootprintSetGL.d.ts +4 -0
  72. package/lib-esm/model/terra/TerraFootprintSetGL.js +16 -0
  73. package/lib-esm/model/terra/TerraPointSetGL.d.ts +4 -0
  74. package/lib-esm/model/terra/TerraPointSetGL.js +16 -0
  75. package/lib-esm/services/SesameService.js +11 -3
  76. package/lib-esm/services/helpers.js +12 -0
  77. package/lib-esm/services/hipsNodeService.js +12 -0
  78. package/lib-esm/services/parse-hipslist.js +12 -0
  79. package/lib-esm/services/queryCatalogueByFoV.js +13 -1
  80. package/lib-esm/services/queryFootprintSetByFov.js +13 -1
  81. package/lib-esm/services/tapRepoService.js +13 -1
  82. package/lib-esm/services/types.js +12 -0
  83. package/lib-esm/shader/CatalogueShaderProgram.js +12 -0
  84. package/lib-esm/shader/FootprintShaderProgram.js +12 -0
  85. package/lib-esm/shader/GridShaderManager.js +12 -0
  86. package/lib-esm/shader/HiPSShaderProgram.js +12 -0
  87. package/lib-esm/shader/ShaderManager.js +12 -1
  88. package/lib-esm/shader/ShaderManagerMutliHiPS.js +12 -1
  89. package/lib-esm/shader/XYZShaderProgram.d.ts +33 -0
  90. package/lib-esm/shader/XYZShaderProgram.js +213 -0
  91. package/lib-esm/utils/CoordsType.js +12 -0
  92. package/lib-esm/utils/FoVUtils.js +12 -0
  93. package/lib-esm/utils/GeomUtils.js +12 -0
  94. package/lib-esm/utils/MouseHelper.js +12 -0
  95. package/lib-esm/utils/PerspectiveMatrixManager.js +12 -0
  96. package/lib-esm/utils/RayPickingUtils.js +12 -0
  97. package/lib-esm/utils/STCSParser.js +12 -0
  98. package/lib-esm/utils/ShaderUtility.js +13 -1
  99. package/lib-esm/utils/Utils.js +12 -0
  100. package/lib-esm/utils/XYZRayPickingUtils.d.ts +27 -0
  101. package/lib-esm/utils/XYZRayPickingUtils.js +226 -0
  102. package/package.json +1 -2
  103. package/lib-esm/model/FoV.d.ts +0 -62
  104. package/lib-esm/model/FoV.js +0 -274
@@ -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
@@ -0,0 +1,33 @@
1
+ type XYZLocations = {
2
+ pMatrix: WebGLUniformLocation | null;
3
+ mMatrix: WebGLUniformLocation | null;
4
+ vMatrix: WebGLUniformLocation | null;
5
+ sampler: WebGLUniformLocation | null;
6
+ colorMapIdx: WebGLUniformLocation | null;
7
+ vertexPositionAttribute: number;
8
+ textureCoordAttribute: number;
9
+ };
10
+ export declare class XYZShaderProgram {
11
+ readonly locations: XYZLocations;
12
+ private _webgl;
13
+ private _shaderProgram?;
14
+ private _colorMapBlockIndex;
15
+ private _colorMapBuffer;
16
+ private _runtimeColorMap;
17
+ private _colorMapVariableInfo;
18
+ constructor(webgl: WebGL2RenderingContext);
19
+ get shaderProgram(): WebGLProgram;
20
+ enableProgram(): 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;
27
+ private initShaders;
28
+ private compileShader;
29
+ private initColorMapBuffer;
30
+ private uploadColorMap;
31
+ private getColorMap;
32
+ }
33
+ export {};
@@ -0,0 +1,213 @@
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';
14
+ export class XYZShaderProgram {
15
+ locations;
16
+ _webgl;
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
+ };
26
+ constructor(webgl) {
27
+ this._webgl = webgl;
28
+ this.locations = {
29
+ pMatrix: null,
30
+ mMatrix: null,
31
+ vMatrix: null,
32
+ sampler: null,
33
+ colorMapIdx: null,
34
+ vertexPositionAttribute: -1,
35
+ textureCoordAttribute: -1,
36
+ };
37
+ }
38
+ get shaderProgram() {
39
+ const gl = this._webgl;
40
+ if (!this._shaderProgram) {
41
+ const program = gl.createProgram();
42
+ if (!program) {
43
+ throw new Error('Could not create XYZ shader program');
44
+ }
45
+ this._shaderProgram = program;
46
+ this.initShaders();
47
+ }
48
+ gl.useProgram(this._shaderProgram);
49
+ return this._shaderProgram;
50
+ }
51
+ enableProgram() {
52
+ this._webgl.useProgram(this.shaderProgram);
53
+ }
54
+ setRuntimeColorMap(colorMap) {
55
+ this._runtimeColorMap = colorMap;
56
+ }
57
+ enableShaders(pMatrix, vMatrix, mMatrix, colorMapIdx = 0) {
58
+ const gl = this._webgl;
59
+ const program = this.shaderProgram;
60
+ gl.useProgram(program);
61
+ this.locations.pMatrix = gl.getUniformLocation(program, 'uPMatrix');
62
+ this.locations.mMatrix = gl.getUniformLocation(program, 'uMMatrix');
63
+ this.locations.vMatrix = gl.getUniformLocation(program, 'uVMatrix');
64
+ this.locations.sampler = gl.getUniformLocation(program, 'uSampler');
65
+ this.locations.colorMapIdx = gl.getUniformLocation(program, 'cmapIdx');
66
+ this.locations.vertexPositionAttribute = gl.getAttribLocation(program, 'aVertexPosition');
67
+ this.locations.textureCoordAttribute = gl.getAttribLocation(program, 'aTextureCoord');
68
+ gl.uniformMatrix4fv(this.locations.pMatrix, false, pMatrix);
69
+ gl.uniformMatrix4fv(this.locations.vMatrix, false, vMatrix);
70
+ gl.uniformMatrix4fv(this.locations.mMatrix, false, mMatrix);
71
+ gl.uniform1i(this.locations.sampler, 0);
72
+ gl.uniform1i(this.locations.colorMapIdx, colorMapIdx);
73
+ if (colorMapIdx >= 2) {
74
+ this.uploadColorMap(colorMapIdx);
75
+ }
76
+ }
77
+ initShaders() {
78
+ const gl = this._webgl;
79
+ const vertexShader = this.compileShader(gl.VERTEX_SHADER, `#version 300 es
80
+ in vec3 aVertexPosition;
81
+ in vec2 aTextureCoord;
82
+ uniform mat4 uPMatrix;
83
+ uniform mat4 uVMatrix;
84
+ uniform mat4 uMMatrix;
85
+ out vec2 vTextureCoord;
86
+ void main(void) {
87
+ vTextureCoord = aTextureCoord;
88
+ gl_Position = uPMatrix * uVMatrix * uMMatrix * vec4(aVertexPosition, 1.0);
89
+ }`);
90
+ const fragmentShader = this.compileShader(gl.FRAGMENT_SHADER, `#version 300 es
91
+ precision mediump float;
92
+ in vec2 vTextureCoord;
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
+
102
+ out vec4 outColor;
103
+
104
+ void main(void) {
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;
128
+ }`);
129
+ gl.attachShader(this._shaderProgram, vertexShader);
130
+ gl.attachShader(this._shaderProgram, fragmentShader);
131
+ gl.linkProgram(this._shaderProgram);
132
+ if (!gl.getProgramParameter(this._shaderProgram, gl.LINK_STATUS)) {
133
+ throw new Error(gl.getProgramInfoLog(this._shaderProgram) || 'Could not initialise XYZ shaders');
134
+ }
135
+ this.initColorMapBuffer();
136
+ }
137
+ compileShader(type, source) {
138
+ const gl = this._webgl;
139
+ const shader = gl.createShader(type);
140
+ if (!shader) {
141
+ throw new Error('Could not create XYZ shader');
142
+ }
143
+ gl.shaderSource(shader, source);
144
+ gl.compileShader(shader);
145
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
146
+ throw new Error(gl.getShaderInfoLog(shader) || 'XYZ shader compile error');
147
+ }
148
+ return shader;
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
+ }
213
+ }
@@ -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)
@@ -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 (Fab)
@@ -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 { Point } from "../model/Point.js";
2
14
  import Point2D from "../model/Point2D.js";
3
15
  import { CoordsType } from "./CoordsType.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
  /**
2
14
  * @author Fabrizio Giordano (Fab)
3
15
  */
@@ -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 { mat4 } from "gl-matrix";
2
14
  export class PerspectiveMatrixManager {
3
15
  _pMatrix;
@@ -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
  * @author Fabrizio Giordano (Fab)
3
15
  */
@@ -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
  * @author Fabrizio Giordano (Fab77)
3
15
  */
@@ -1,6 +1,18 @@
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 global from "../Global.js";
2
15
  // // import ShaderManager from "../shader/ShaderManager.js";
3
- export {};
4
16
  // // type GL = WebGLRenderingContext | WebGL2RenderingContext;
5
17
  // class ShaderUtility {
6
18
  // private lastUsedProgram: WebGLProgram | null = null;
@@ -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
  * @author Fabrizio Giordano (Fab)
3
15
  */
@@ -0,0 +1,27 @@
1
+ import { ReadonlyMat4, ReadonlyVec3, vec3 } from 'gl-matrix';
2
+ import Camera from '../Camera.js';
3
+ import { AbstractSkyEntity } from '../model/AbstractSkyEntity.js';
4
+ import type { XYZTileCoord } from '../model/earth/XYZTypes.js';
5
+ export type XYZLonLat = {
6
+ lonDeg: number;
7
+ latDeg: number;
8
+ };
9
+ declare class XYZRayPickingUtils {
10
+ static getRayFromMouse(mouseX: number, mouseY: number, pMatrix: ReadonlyMat4, webgl: WebGL2RenderingContext, vMatrix: ReadonlyMat4): vec3;
11
+ static raySphere(rayOrigWorld: ReadonlyVec3, rayDirectionWorld: ReadonlyVec3, sphere: Pick<AbstractSkyEntity, 'center' | 'radius'>): number;
12
+ static getIntersectionPointWithModel(mouseX: number, mouseY: number, xyzModel: AbstractSkyEntity, webgl: WebGL2RenderingContext, camera: Camera, pMatrix: ReadonlyMat4): [number, number, number] | null;
13
+ static getLonLatFromMouse(mouseX: number, mouseY: number, xyzModel: AbstractSkyEntity, webgl: WebGL2RenderingContext, camera: Camera, pMatrix: ReadonlyMat4): XYZLonLat | null;
14
+ static getTileFromMouse(mouseX: number, mouseY: number, z: number, xyzModel: AbstractSkyEntity, webgl: WebGL2RenderingContext, camera: Camera, pMatrix: ReadonlyMat4): XYZTileCoord | null;
15
+ static getVisibleTilesFromViewport(z: number, xyzModel: AbstractSkyEntity, webgl: WebGL2RenderingContext, camera: Camera, pMatrix: ReadonlyMat4, sampleCount?: number, padding?: number): XYZTileCoord[];
16
+ static modelPointToLonLat(point: Readonly<[number, number, number]>): XYZLonLat;
17
+ static lonLatToTile(lonDeg: number, latDeg: number, z: number): XYZTileCoord;
18
+ static getNeighborTiles(tile: XYZTileCoord, ring?: number): XYZTileCoord[];
19
+ static deduplicateTiles(tiles: XYZTileCoord[]): XYZTileCoord[];
20
+ private static fillSmallTileGaps;
21
+ private static latToTileY;
22
+ private static isMercatorLatitude;
23
+ private static wrapTileX;
24
+ private static clampTileY;
25
+ private static mat4MultiplyVec4;
26
+ }
27
+ export default XYZRayPickingUtils;