astro-viewer 3.1.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 (50) hide show
  1. package/dist/astroviewer.cjs +706 -204
  2. package/dist/astroviewer.js +1 -1
  3. package/dist/astroviewer.min.js +1 -1
  4. package/lib-esm/AstroSphere.d.ts +19 -15
  5. package/lib-esm/AstroSphere.js +163 -94
  6. package/lib-esm/AstroViewer.d.ts +2 -0
  7. package/lib-esm/AstroViewer.js +3 -0
  8. package/lib-esm/Camera.js +4 -6
  9. package/lib-esm/Config.d.ts +2 -0
  10. package/lib-esm/Config.js +3 -1
  11. package/lib-esm/index.d.ts +2 -0
  12. package/lib-esm/index.js +1 -0
  13. package/lib-esm/model/AbstractSkyEntity.d.ts +1 -0
  14. package/lib-esm/model/MetadataManager.d.ts +1 -0
  15. package/lib-esm/model/MetadataManager.js +4 -1
  16. package/lib-esm/model/Point.d.ts +9 -1
  17. package/lib-esm/model/Point.js +18 -0
  18. package/lib-esm/model/SphereFoV.js +4 -3
  19. package/lib-esm/model/earth/XYZConfig.d.ts +4 -0
  20. package/lib-esm/model/earth/XYZFoVHelper.d.ts +5 -2
  21. package/lib-esm/model/earth/XYZFoVHelper.js +40 -3
  22. package/lib-esm/model/footprints/Footprint.d.ts +4 -1
  23. package/lib-esm/model/footprints/Footprint.js +18 -2
  24. package/lib-esm/model/footprints/FootprintSetGL.d.ts +4 -2
  25. package/lib-esm/model/footprints/FootprintSetGL.js +9 -6
  26. package/lib-esm/model/grid/EquatorialGrid.d.ts +2 -1
  27. package/lib-esm/model/grid/EquatorialGrid.js +10 -6
  28. package/lib-esm/model/grid/HealpixGrid.js +5 -2
  29. package/lib-esm/model/grid/LonLatGrid.d.ts +3 -0
  30. package/lib-esm/model/grid/LonLatGrid.js +61 -10
  31. package/lib-esm/model/hips/FoVHelper.d.ts +5 -2
  32. package/lib-esm/model/hips/FoVHelper.js +40 -3
  33. package/lib-esm/model/hips/HiPS.d.ts +2 -0
  34. package/lib-esm/model/hips/HiPS.js +26 -5
  35. package/lib-esm/model/hips/HiPSConfig.d.ts +13 -0
  36. package/lib-esm/model/hips/HiPSConfig.js +1 -0
  37. package/lib-esm/model/hips/Tile.d.ts +1 -0
  38. package/lib-esm/model/hips/Tile.js +3 -0
  39. package/lib-esm/model/hips/TileBuffer.d.ts +5 -0
  40. package/lib-esm/model/hips/TileBuffer.js +49 -0
  41. package/lib-esm/model/terra/TerraFootprintSetGL.d.ts +6 -0
  42. package/lib-esm/model/terra/TerraFootprintSetGL.js +42 -0
  43. package/lib-esm/utils/CoordsType.d.ts +2 -1
  44. package/lib-esm/utils/CoordsType.js +1 -0
  45. package/lib-esm/utils/GeoJSONParser.d.ts +19 -0
  46. package/lib-esm/utils/GeoJSONParser.js +112 -0
  47. package/lib-esm/utils/PerspectiveMatrixManager.js +4 -1
  48. package/lib-esm/utils/STCSParser.d.ts +7 -3
  49. package/lib-esm/utils/STCSParser.js +15 -9
  50. package/package.json +2 -2
@@ -10,6 +10,7 @@ import { ReadonlyMat4 } from 'gl-matrix';
10
10
  import { ColorMap, ColorMapName } from './model/ColorMaps.js';
11
11
  import { HiPS } from './model/hips/HiPS.js';
12
12
  import type { WMTSLayerConfig, XYZDebugStats, XYZLayerConfig } from './model/earth/XYZConfig.js';
13
+ import type { HiPSDebugStats } from './model/hips/HiPSConfig.js';
13
14
  import { XYZMap } from './model/earth/XYZMap.js';
14
15
  import { TerraPointSetGL } from './model/terra/TerraPointSetGL.js';
15
16
  import { TerraFootprintSetGL } from './model/terra/TerraFootprintSetGL.js';
@@ -56,6 +57,7 @@ export declare class AstroViewer {
56
57
  setXYZMaxConcurrentRequests(value: number): void;
57
58
  getXYZMaxConcurrentRequests(): number;
58
59
  getXYZDebugStats(): XYZDebugStats;
60
+ getHiPSDebugStats(): HiPSDebugStats | null;
59
61
  loadHiPS(baseUrl: string): Promise<string>;
60
62
  changeColorMap(colorMapName: ColorMapName): void;
61
63
  changeCustomColorMap(colorMap: ColorMap): void;
@@ -145,6 +145,9 @@ export class AstroViewer {
145
145
  getXYZDebugStats() {
146
146
  return this.astroSphere.getXYZDebugStats();
147
147
  }
148
+ getHiPSDebugStats() {
149
+ return this.astroSphere.getHiPSDebugStats();
150
+ }
148
151
  async loadHiPS(baseUrl) {
149
152
  const hipsUrl = baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
150
153
  const resp = await fetch(hipsUrl + 'properties');
package/lib-esm/Camera.js CHANGED
@@ -84,13 +84,11 @@ class Camera {
84
84
  toggleInsideSphere() {
85
85
  // if (inside !== global.insideSphere) {
86
86
  // global.insideSphere = inside;
87
+ this.insideSphere = global.insideSphere;
87
88
  if (global.insideSphere) {
88
- if (this.cam_pos[2] <= 2) {
89
- this.cam_pos[2] = -2 + this.cam_pos[2];
90
- }
91
- else {
92
- this.cam_pos[2] = -0.005;
93
- }
89
+ this.cam_pos[0] = 0;
90
+ this.cam_pos[1] = 0;
91
+ this.cam_pos[2] = -0.005;
94
92
  }
95
93
  else {
96
94
  this.cam_pos[2] = 2.0 + this.cam_pos[2];
@@ -5,6 +5,8 @@ export interface BootSetup {
5
5
  defaultHips: string;
6
6
  camera_fov_deg: number;
7
7
  camera_fov_rad: number;
8
+ inside_camera_fov_deg: number;
9
+ inside_camera_fov_rad: number;
8
10
  camera_near_plane: number;
9
11
  camera_far_plane: number;
10
12
  corsProxyUrl: string;
package/lib-esm/Config.js CHANGED
@@ -29,6 +29,8 @@ export const bootSetup = {
29
29
  defaultHips: "",
30
30
  camera_fov_deg: 34,
31
31
  camera_fov_rad: 34 * Math.PI / 180.0,
32
+ inside_camera_fov_deg: 60,
33
+ inside_camera_fov_rad: 60 * Math.PI / 180.0,
32
34
  camera_near_plane: 0.00001,
33
35
  camera_far_plane: 2.5,
34
36
  corsProxyUrl: "http://localhost:4000/",
@@ -39,5 +41,5 @@ export const bootSetup = {
39
41
  version: "Astrobrowser v1.0.0",
40
42
  debug: false,
41
43
  insideView: false,
42
- showViewfinder: false,
44
+ showViewfinder: true,
43
45
  };
@@ -12,6 +12,8 @@ export { MetadataColumn, MetadataInit, ColumnType } from './model/MetadataColumn
12
12
  export { Point, SphericalOpts, AstroOpts, PointInitOpts, CartesianOpts } from './model/Point.js';
13
13
  export { FoVUtils } from './utils/FoVUtils.js';
14
14
  export { CoordsType } from './utils/CoordsType.js';
15
+ export { default as GeoJSONParser } from './utils/GeoJSONParser.js';
16
+ export type { ParsedGeoJSONFeature, GeoJSONProperties } from './utils/GeoJSONParser.js';
15
17
  export { ColorMaps, COLOR_MAP_SAMPLE_COUNT, createColorMapFromSamples } from './model/ColorMaps.js';
16
18
  export type { ColorMap, ColorMapName } from './model/ColorMaps.js';
17
19
  export { HiPS } from './model/hips/HiPS.js';
package/lib-esm/index.js CHANGED
@@ -23,6 +23,7 @@ export { MetadataColumn, ColumnType } from './model/MetadataColumn.js';
23
23
  export { Point } from './model/Point.js';
24
24
  export { FoVUtils } from './utils/FoVUtils.js';
25
25
  export { CoordsType } from './utils/CoordsType.js';
26
+ export { default as GeoJSONParser } from './utils/GeoJSONParser.js';
26
27
  export { ColorMaps, COLOR_MAP_SAMPLE_COUNT, createColorMapFromSamples } from './model/ColorMaps.js';
27
28
  export { HiPS } from './model/hips/HiPS.js';
28
29
  export { XYZMap } from './model/earth/XYZMap.js';
@@ -19,6 +19,7 @@ export interface SkyEntityDrawInput {
19
19
  phi: number;
20
20
  theta: number;
21
21
  }>;
22
+ cameraMoving?: boolean;
22
23
  }
23
24
  export declare abstract class AbstractSkyEntity {
24
25
  refreshMe: boolean;
@@ -34,6 +34,7 @@ export declare class MetadataManager {
34
34
  get shapeColumnList(): MetadataColumn[];
35
35
  set selectedRaColumn(columnName: string);
36
36
  set selectedDecColumn(columnName: string);
37
+ set selectedOutlineColumn(columnName: string);
37
38
  set selectedHueColumn(columnName: string);
38
39
  set selectedShapeColumn(columnName: string);
39
40
  set selectedNameColumn(columnName: string);
@@ -110,6 +110,9 @@ export class MetadataManager {
110
110
  set selectedDecColumn(columnName) {
111
111
  this._selectedDecColumn = this._decColumnList.find(c => c.name === columnName) || this._selectedDecColumn;
112
112
  }
113
+ set selectedOutlineColumn(columnName) {
114
+ this._selectedOutlineColumn = this._outlineColumnList.find(c => c.name === columnName) || this._selectedOutlineColumn;
115
+ }
113
116
  set selectedHueColumn(columnName) {
114
117
  this._selectedHueColumn = this._hueColumnList.find(c => c.name === columnName);
115
118
  }
@@ -117,7 +120,7 @@ export class MetadataManager {
117
120
  this._selectedShapeColumn = this._shapeColumnList.find(c => c.name === columnName);
118
121
  }
119
122
  set selectedNameColumn(columnName) {
120
- this._selectedNameColumn = this._shapeColumnList.find(c => c.name === columnName);
123
+ this._selectedNameColumn = this._columns.find(c => c.name === columnName);
121
124
  }
122
125
  resetShapeColumn() {
123
126
  this._selectedShapeColumn = undefined;
@@ -9,11 +9,15 @@ export type AstroOpts = {
9
9
  raDeg: number;
10
10
  decDeg: number;
11
11
  };
12
+ export type GeographicOpts = {
13
+ lonDeg: number;
14
+ latDeg: number;
15
+ };
12
16
  export type SphericalOpts = {
13
17
  phiDeg: number;
14
18
  thetaDeg: number;
15
19
  };
16
- export type PointInitOpts = CartesianOpts | AstroOpts | SphericalOpts;
20
+ export type PointInitOpts = CartesianOpts | AstroOpts | GeographicOpts | SphericalOpts;
17
21
  export declare class Point {
18
22
  private _x;
19
23
  private _y;
@@ -24,6 +28,7 @@ export declare class Point {
24
28
  private _raRad;
25
29
  private _decRad;
26
30
  private _raDecDeg;
31
+ private _lonLatDeg?;
27
32
  constructor(in_options: PointInitOpts, in_type: CoordsType);
28
33
  private computeAstroCoords;
29
34
  private computeCartesianCoords;
@@ -47,6 +52,9 @@ export declare class Point {
47
52
  get raDeg(): number;
48
53
  get decDeg(): number;
49
54
  get raDecDeg(): [number, number];
55
+ get lonDeg(): number;
56
+ get latDeg(): number;
57
+ get lonLatDeg(): [number, number];
50
58
  toADQL(): string;
51
59
  toString(): string;
52
60
  }
@@ -28,6 +28,7 @@ export class Point {
28
28
  _raRad;
29
29
  _decRad;
30
30
  _raDecDeg;
31
+ _lonLatDeg;
31
32
  constructor(in_options, in_type) {
32
33
  this._xyz = [0, 0, 0];
33
34
  this._raDecDeg = [0, 0];
@@ -59,6 +60,20 @@ export class Point {
59
60
  this._z = Number(z.toFixed(MAX_DECIMALS));
60
61
  this._xyz = [this._x, this._y, this._z];
61
62
  }
63
+ else if (in_type === CoordsType.GEOGRAPHIC) {
64
+ const { lonDeg, latDeg } = in_options;
65
+ this._lonLatDeg = [Number(lonDeg), Number(latDeg)];
66
+ this._raDeg = this._lonLatDeg[0];
67
+ this._decDeg = this._lonLatDeg[1];
68
+ this._raDecDeg = [this._raDeg, this._decDeg];
69
+ this._raRad = (this._raDeg * Math.PI) / 180;
70
+ this._decRad = (this._decDeg * Math.PI) / 180;
71
+ const [x, y, z] = this.computeCartesianCoords();
72
+ this._x = Number(x.toFixed(MAX_DECIMALS));
73
+ this._y = Number(y.toFixed(MAX_DECIMALS));
74
+ this._z = Number(z.toFixed(MAX_DECIMALS));
75
+ this._xyz = [this._x, this._y, this._z];
76
+ }
62
77
  else if (in_type === CoordsType.SPHERICAL) {
63
78
  // Not implemented in original; keep behavior
64
79
  console.log(`${CoordsType.SPHERICAL} not implemented yet`);
@@ -135,6 +150,9 @@ export class Point {
135
150
  get raDeg() { return this._raDeg; }
136
151
  get decDeg() { return this._decDeg; }
137
152
  get raDecDeg() { return this._raDecDeg; }
153
+ get lonDeg() { return this._lonLatDeg?.[0] ?? this._raDeg; }
154
+ get latDeg() { return this._lonLatDeg?.[1] ?? this._decDeg; }
155
+ get lonLatDeg() { return this._lonLatDeg ?? [this._raDeg, this._decDeg]; }
138
156
  toADQL() {
139
157
  return `${this._raDecDeg[0]},${this._raDecDeg[1]}`;
140
158
  }
@@ -115,7 +115,7 @@ export class SphereFoV {
115
115
  }
116
116
  const angleDeg = 2 * this.computeAngularDistanceDeg(centerHit.point, edgeHit.point);
117
117
  return {
118
- angleDeg: insideSphere ? 360 - angleDeg : angleDeg,
118
+ angleDeg,
119
119
  distance: edgeHit.distance,
120
120
  };
121
121
  }
@@ -123,8 +123,9 @@ export class SphereFoV {
123
123
  const aNorm = vec3.normalize(vec3.create(), a);
124
124
  const bNorm = vec3.normalize(vec3.create(), b);
125
125
  const dot = vec3.dot(aNorm, bNorm);
126
- const clamped = Math.min(1, Math.max(-1, dot));
127
- return radToDeg(Math.acos(clamped));
126
+ const cross = vec3.cross(vec3.create(), aNorm, bNorm);
127
+ const angleRad = Math.atan2(vec3.length(cross), Math.min(1, Math.max(-1, dot)));
128
+ return radToDeg(angleRad);
128
129
  }
129
130
  getIntersectionPointWithModel(mouseX, mouseY, model, camera, pMatrix) {
130
131
  const rayWorld = this.getRayFromMouse(mouseX, mouseY, pMatrix, camera.getCameraMatrix());
@@ -29,6 +29,10 @@ export type XYZLayerDebugStats = {
29
29
  coarseTileCount: number;
30
30
  hasPendingSelection: boolean;
31
31
  pendingSelectionKey: string | null;
32
+ hipsName?: string;
33
+ hipsUrl?: string;
34
+ isGalactic?: boolean;
35
+ currentOrder?: number | null;
32
36
  };
33
37
  export type XYZRequestBackoffDebugEntry = {
34
38
  host: string;
@@ -1,6 +1,9 @@
1
1
  declare class XYZFoVHelper {
2
- getZoom(fov: number): number;
3
- getLonLatSteps(fov: number): {
2
+ private static readonly LEVEL_HYSTERESIS;
3
+ private static readonly ZOOM_MIN_FOV;
4
+ getZoom(fov: number, currentZoom?: number): number;
5
+ private getRawZoom;
6
+ getLonLatSteps(fov: number, coarse?: boolean): {
4
7
  lonStep: number;
5
8
  latStep: number;
6
9
  };
@@ -13,7 +13,40 @@
13
13
  // FoVHelper.ts
14
14
  'use strict';
15
15
  class XYZFoVHelper {
16
- getZoom(fov) {
16
+ static LEVEL_HYSTERESIS = 0.12;
17
+ static ZOOM_MIN_FOV = {
18
+ 2: 179,
19
+ 3: 90,
20
+ 4: 30,
21
+ 5: 20,
22
+ 6: 6,
23
+ 7: 3.2,
24
+ 8: 1.6,
25
+ 9: 0.85,
26
+ 10: 0.42,
27
+ 11: 0.21,
28
+ 12: 0.12,
29
+ 13: 0.06,
30
+ 14: 0.015,
31
+ 15: 0,
32
+ };
33
+ getZoom(fov, currentZoom) {
34
+ const rawZoom = this.getRawZoom(fov);
35
+ if (currentZoom === undefined || currentZoom === rawZoom)
36
+ return rawZoom;
37
+ if (rawZoom > currentZoom) {
38
+ const boundary = XYZFoVHelper.ZOOM_MIN_FOV[currentZoom];
39
+ if (boundary > 0 && fov > boundary * (1 - XYZFoVHelper.LEVEL_HYSTERESIS))
40
+ return currentZoom;
41
+ }
42
+ else {
43
+ const boundary = XYZFoVHelper.ZOOM_MIN_FOV[rawZoom];
44
+ if (boundary > 0 && fov < boundary * (1 + XYZFoVHelper.LEVEL_HYSTERESIS))
45
+ return currentZoom;
46
+ }
47
+ return rawZoom;
48
+ }
49
+ getRawZoom(fov) {
17
50
  if (fov >= 179)
18
51
  return 2;
19
52
  if (fov >= 90)
@@ -43,10 +76,14 @@ class XYZFoVHelper {
43
76
  return 15;
44
77
  }
45
78
  // used in grid drawing
46
- getLonLatSteps(fov) {
79
+ getLonLatSteps(fov, coarse = false) {
47
80
  let lonStep;
48
81
  let latStep;
49
- if (fov >= 179) {
82
+ if (coarse && fov < 0.21) {
83
+ lonStep = 10;
84
+ latStep = 10;
85
+ }
86
+ else if (fov >= 179) {
50
87
  lonStep = 10;
51
88
  latStep = 10;
52
89
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { SelectionObj } from '../../utils/GeomUtils.js';
5
5
  import { Point } from '../Point.js';
6
+ import { CoordsType } from '../../utils/CoordsType.js';
6
7
  export interface FootprintDetail {
7
8
  key: string;
8
9
  value: string | number;
@@ -19,6 +20,7 @@ export declare class Footprint {
19
20
  private _totConvexPoints;
20
21
  private _npix256?;
21
22
  private _footprintsPointsOrder?;
23
+ private _coordsType;
22
24
  private _selectionObj;
23
25
  private _identifier?;
24
26
  private _center?;
@@ -27,7 +29,8 @@ export declare class Footprint {
27
29
  * @param in_details optional metadata
28
30
  * @param footprintsPointsOrder 1-> clockwise, -1 counter clockwise
29
31
  */
30
- constructor(in_stcs?: string, in_details?: FootprintDetail[], footprintsPointsOrder?: 1 | -1);
32
+ constructor(in_stcs?: string, in_details?: FootprintDetail[], footprintsPointsOrder?: 1 | -1, coordsType?: CoordsType.ASTRO | CoordsType.GEOGRAPHIC);
33
+ static fromPolygons(polygons: Point[][], details?: FootprintDetail[], coordsType?: CoordsType.ASTRO | CoordsType.GEOGRAPHIC): Footprint;
31
34
  private computeSelectionObject;
32
35
  private computePoints;
33
36
  get valid(): boolean;
@@ -19,6 +19,7 @@
19
19
  import GeomUtils from '../../utils/GeomUtils.js';
20
20
  // import global from '../../Global.js';
21
21
  import STCSParser from '../../utils/STCSParser.js';
22
+ import { CoordsType } from '../../utils/CoordsType.js';
22
23
  // export interface ParsedSTCS {
23
24
  // polygons: Point[][]; // array of polygons (each polygon is array of Point objects)
24
25
  // totpoints: number;
@@ -33,6 +34,7 @@ export class Footprint {
33
34
  _totConvexPoints = 0;
34
35
  _npix256;
35
36
  _footprintsPointsOrder;
37
+ _coordsType;
36
38
  _selectionObj;
37
39
  _identifier;
38
40
  _center; // could be typed if you have a Point type
@@ -41,7 +43,8 @@ export class Footprint {
41
43
  * @param in_details optional metadata
42
44
  * @param footprintsPointsOrder 1-> clockwise, -1 counter clockwise
43
45
  */
44
- constructor(in_stcs, in_details = [], footprintsPointsOrder) {
46
+ constructor(in_stcs, in_details = [], footprintsPointsOrder, coordsType = CoordsType.ASTRO) {
47
+ this._coordsType = coordsType;
45
48
  if (in_stcs) {
46
49
  this._stcs = in_stcs.toUpperCase();
47
50
  this._details = in_details;
@@ -56,6 +59,17 @@ export class Footprint {
56
59
  this._details = [];
57
60
  }
58
61
  }
62
+ static fromPolygons(polygons, details = [], coordsType = CoordsType.ASTRO) {
63
+ const footprint = new Footprint(undefined, [], undefined, coordsType);
64
+ footprint._polygons = polygons;
65
+ footprint._details = details;
66
+ footprint._totPoints = polygons.reduce((total, polygon) => total + polygon.length, 0);
67
+ footprint._totConvexPoints = 0;
68
+ footprint._coordsType = coordsType;
69
+ footprint._selectionObj = footprint.computeSelectionObject();
70
+ footprint._valid = footprint._totPoints > 0;
71
+ return footprint;
72
+ }
59
73
  computeSelectionObject() {
60
74
  return GeomUtils.computeSelectionObject(this._polygons);
61
75
  }
@@ -78,7 +92,9 @@ export class Footprint {
78
92
  // return Array.from(rangeSet.r);
79
93
  // }
80
94
  computePoints() {
81
- const res = STCSParser.parseSTCS(this._stcs);
95
+ const res = STCSParser.parseSTCS(this._stcs, {
96
+ coordsType: this._coordsType,
97
+ });
82
98
  this._polygons = res.polygons;
83
99
  this._totPoints = res.totpoints;
84
100
  }
@@ -1,5 +1,6 @@
1
1
  import { Footprint } from "./Footprint.js";
2
2
  import MouseHelper from "../../utils/MouseHelper.js";
3
+ import { CoordsType } from "../../utils/CoordsType.js";
3
4
  import { MetadataManager } from "../MetadataManager.js";
4
5
  import { MetadataColumn } from "../MetadataColumn.js";
5
6
  import { VisibleTilesManager } from "../hips/VisibleTilesManager.js";
@@ -58,10 +59,11 @@ export declare class FootprintSetGL {
58
59
  totSelectedPoints: number;
59
60
  nSlectedPrimitiveFlags: number;
60
61
  _shapeColor: string;
61
- private _bufferInitialised;
62
+ protected _coordsType: CoordsType.ASTRO | CoordsType.GEOGRAPHIC;
63
+ protected _bufferInitialised: boolean;
62
64
  private _webgl;
63
65
  _isVisible: boolean;
64
- private _metadataManager;
66
+ protected _metadataManager: MetadataManager;
65
67
  _providerUrl: string;
66
68
  private _footprintShaderProgram;
67
69
  private _visibleTilesManager;
@@ -58,6 +58,7 @@ export class FootprintSetGL {
58
58
  totSelectedPoints;
59
59
  nSlectedPrimitiveFlags = 0;
60
60
  _shapeColor = "#00fff2ff";
61
+ _coordsType = CoordsType.ASTRO;
61
62
  _bufferInitialised = false;
62
63
  _webgl;
63
64
  _isVisible = true;
@@ -139,7 +140,7 @@ export class FootprintSetGL {
139
140
  }
140
141
  for (let j = 0; j < in_data.length; j++) {
141
142
  if (in_data[j][geomDataIndex] !== null) {
142
- const footprint = new Footprint(in_data[j][geomDataIndex], in_data[j]);
143
+ const footprint = new Footprint(in_data[j][geomDataIndex], in_data[j], undefined, this._coordsType);
143
144
  if (footprint._valid) {
144
145
  this.addFootprint(footprint);
145
146
  this.totPoints += footprint.totPoints;
@@ -193,6 +194,11 @@ export class FootprintSetGL {
193
194
  }
194
195
  }
195
196
  this.indexes[this.indexes.length - 1] = MAX_UNSIGNED_INT;
197
+ this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER, this.vertexCataloguePositionBuffer);
198
+ this._webgl.bufferData(this._webgl.ARRAY_BUFFER, this.vertexCataloguePosition, this._webgl.STATIC_DRAW);
199
+ this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
200
+ this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER, this.indexes, this._webgl.STATIC_DRAW);
201
+ this._bufferInitialised = true;
196
202
  console.log("Buffer initialized");
197
203
  }
198
204
  checkSelection(mouseHelper) {
@@ -212,9 +218,8 @@ export class FootprintSetGL {
212
218
  const details = [...footprint.details];
213
219
  // const geomDataIndex = this.footprintsetProps.geomColumn?.index
214
220
  const geomDataIndex = this._metadataManager.selectedOutlineColumn?.index ?? -1;
215
- if (geomDataIndex < 0)
216
- continue;
217
- details.splice(geomDataIndex, 1);
221
+ if (geomDataIndex >= 0)
222
+ details.splice(geomDataIndex, 1);
218
223
  this._hoveredFootprints.push(footprint);
219
224
  this.totHoveredPoints += footprint.totPoints;
220
225
  }
@@ -586,11 +591,9 @@ export class FootprintSetGL {
586
591
  this._webgl.drawElements(this._webgl.LINE_LOOP, this.selectedVertexPosition.length / 3 + this.nSlectedPrimitiveFlags, this._webgl.UNSIGNED_INT, 0);
587
592
  }
588
593
  this._webgl.bindBuffer(this._webgl.ARRAY_BUFFER, this.vertexCataloguePositionBuffer);
589
- this._webgl.bufferData(this._webgl.ARRAY_BUFFER, this.vertexCataloguePosition, this._webgl.STATIC_DRAW);
590
594
  this._webgl.vertexAttribPointer(this._footprintShaderProgram.locations.position, FootprintSetGL.ELEM_SIZE, this._webgl.FLOAT, false, FootprintSetGL.BYTES_X_ELEM * FootprintSetGL.ELEM_SIZE, 0);
591
595
  this._webgl.enableVertexAttribArray(this._footprintShaderProgram.locations.position);
592
596
  this._webgl.bindBuffer(this._webgl.ELEMENT_ARRAY_BUFFER, this.indexBuffer);
593
- this._webgl.bufferData(this._webgl.ELEMENT_ARRAY_BUFFER, this.indexes, this._webgl.STATIC_DRAW);
594
597
  // const shapeColor = [...colorHex2RGB(this.footprintsetProps.shapeColor), 1.0] as [number, number, number, number]
595
598
  const shapeColor = [...colorHex2RGB(this._shapeColor), 1.0];
596
599
  this._webgl.uniform4f(this._footprintShaderProgram.locations.color, ...shapeColor);
@@ -20,6 +20,7 @@ export declare class EquatorialGrid extends AbstractSkyEntity {
20
20
  private _thetaStepRad;
21
21
  private _phiArray;
22
22
  private _thetaArray;
23
+ private _bufferKey;
23
24
  private _dec4Labels;
24
25
  private _ra4Labels;
25
26
  private _healpixGrid;
@@ -34,7 +35,7 @@ export declare class EquatorialGrid extends AbstractSkyEntity {
34
35
  /** Build RA/Dec line vertex arrays based on FoV step helper */
35
36
  private initBuffers;
36
37
  /** Update buffers when FoV (in degrees) changes */
37
- refresh(fovDeg: number): void;
38
+ refresh(fovDeg: number, coarse?: boolean): void;
38
39
  private vectorDistance;
39
40
  private enableShader;
40
41
  isVisible(): boolean;
@@ -48,6 +48,7 @@ export class EquatorialGrid extends AbstractSkyEntity {
48
48
  _thetaStepRad = 0;
49
49
  _phiArray = [];
50
50
  _thetaArray = [];
51
+ _bufferKey = '';
51
52
  // For placing text labels near current view center:
52
53
  // - _dec4Labels: key = RA(deg), value = points along that RA ring (for Dec labels)
53
54
  // - _ra4Labels : key = Dec(deg), value = points along that Dec ring (for RA labels)
@@ -108,9 +109,9 @@ export class EquatorialGrid extends AbstractSkyEntity {
108
109
  super.webgl.useProgram(this._shaderProgram);
109
110
  }
110
111
  /** Build RA/Dec line vertex arrays based on FoV step helper */
111
- initBuffers(fovDeg) {
112
+ initBuffers(fovDeg, coarse = false) {
112
113
  const R = 1.0;
113
- const steps = fovHelper.getRADegSteps(fovDeg);
114
+ const steps = fovHelper.getRADegSteps(fovDeg, coarse);
114
115
  const phiStep = steps.raStep; // RA step (deg)
115
116
  const thetaStep = steps.decStep; // Dec step (deg)
116
117
  this._phiStep = phiStep;
@@ -162,11 +163,14 @@ export class EquatorialGrid extends AbstractSkyEntity {
162
163
  }
163
164
  }
164
165
  /** Update buffers when FoV (in degrees) changes */
165
- refresh(fovDeg) {
166
+ refresh(fovDeg, coarse = false) {
166
167
  // const fovDeg = healpixGridSingleton.getMinFoV()
167
- if (this._fov !== fovDeg) {
168
+ const steps = fovHelper.getRADegSteps(fovDeg, coarse);
169
+ const bufferKey = `${coarse ? 'coarse' : 'settled'}:${steps.raStep}:${steps.decStep}`;
170
+ if (this._bufferKey !== bufferKey) {
168
171
  this._fov = fovDeg;
169
- this.initBuffers(this._fov);
172
+ this._bufferKey = bufferKey;
173
+ this.initBuffers(this._fov, coarse);
170
174
  }
171
175
  }
172
176
  vectorDistance(p1, p2) {
@@ -226,7 +230,7 @@ export class EquatorialGrid extends AbstractSkyEntity {
226
230
  return;
227
231
  if (this._thetaArray.length === 0)
228
232
  return;
229
- this.refresh(fovDeg);
233
+ this.refresh(fovDeg, !!input.cameraMoving);
230
234
  if (!this.showGrid) {
231
235
  // gridTextHelper.resetDivSets();
232
236
  this.gridText.resetDivSets();
@@ -211,7 +211,7 @@ export class HealpixGrid extends AbstractSkyEntity {
211
211
  // (global as any).hipsFoV = fov;
212
212
  // global.order = fovHelper.getHiPSNorder(fov);
213
213
  // this._visibleorder = global.order;
214
- this._visibleorder = fovHelper.getHiPSNorder(fov);
214
+ this._visibleorder = fovHelper.getHiPSNorder(fov, this._visibleorder);
215
215
  }
216
216
  enableShader(in_mMatrix, pMatrix, vMatrix) {
217
217
  const gl = super.webgl;
@@ -255,7 +255,10 @@ export class HealpixGrid extends AbstractSkyEntity {
255
255
  const pMatrix = input.pMatrix;
256
256
  if (!pMatrix)
257
257
  return;
258
- this.refresh(camera, pMatrix);
258
+ // this.refresh(camera, pMatrix);
259
+ const rawFov = input.fovDeg ?? this.getMinFoV();
260
+ const fov = Number.isFinite(rawFov) && rawFov > 0 ? rawFov : 1e-6;
261
+ this._visibleorder = fovHelper.getHiPSNorder(fov, this._visibleorder);
259
262
  if (!this.showGrid) {
260
263
  // gridTextHelper.resetDivSets();
261
264
  this.gridText.resetDivSets();
@@ -17,12 +17,15 @@ export declare class LatLonGrid extends AbstractSkyEntity {
17
17
  private _showGrid;
18
18
  private _lonArray;
19
19
  private _latArray;
20
+ private _bufferKey;
20
21
  private defaultColor;
21
22
  private gridText;
22
23
  constructor(radius: number, position: [number, number, number], xrad: number, yrad: number, name: string, webgl: WebGL2RenderingContext);
23
24
  init(): void;
24
25
  private initShaders;
25
26
  private initBuffers;
27
+ private buildLonRange;
28
+ private buildLatRange;
26
29
  private lonLatToCartesian;
27
30
  private refresh;
28
31
  refreshFoV(input: SkyEntityDrawInput): number;