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.
- package/dist/astroviewer.cjs +3082 -1410
- package/dist/astroviewer.js +1 -1
- package/dist/astroviewer.min.js +1 -1
- package/lib-esm/AstroSphere.d.ts +40 -16
- package/lib-esm/AstroSphere.js +359 -93
- package/lib-esm/AstroViewer.d.ts +20 -5
- package/lib-esm/AstroViewer.js +50 -0
- package/lib-esm/Camera.js +28 -14
- package/lib-esm/Config.d.ts +2 -0
- package/lib-esm/Config.js +15 -1
- package/lib-esm/Global.js +12 -0
- package/lib-esm/index.d.ts +8 -4
- package/lib-esm/index.js +17 -3
- package/lib-esm/model/AbstractSkyEntity.d.ts +1 -0
- package/lib-esm/model/AbstractSkyEntity.js +12 -0
- package/lib-esm/model/AstroGL.js +12 -0
- package/lib-esm/model/ColorMaps.js +12 -0
- package/lib-esm/model/MetadataColumn.js +12 -0
- package/lib-esm/model/MetadataManager.d.ts +1 -0
- package/lib-esm/model/MetadataManager.js +16 -1
- package/lib-esm/model/Point.d.ts +9 -1
- package/lib-esm/model/Point.js +30 -0
- package/lib-esm/model/Point2D.js +12 -0
- package/lib-esm/model/Source.js +12 -0
- package/lib-esm/model/SphereFoV.d.ts +30 -0
- package/lib-esm/model/SphereFoV.js +196 -0
- package/lib-esm/model/catalogues/CatalogueGL.js +12 -0
- package/lib-esm/model/catalogues/CatalogueProps.js +13 -1
- package/lib-esm/model/earth/{wmts/WMTSAdapter.d.ts → WMTSAdapter.d.ts} +2 -1
- package/lib-esm/model/earth/{wmts/WMTSAdapter.js → WMTSAdapter.js} +12 -0
- package/lib-esm/model/earth/XYZAnchestorTile.d.ts +17 -0
- package/lib-esm/model/earth/XYZAnchestorTile.js +87 -0
- package/lib-esm/model/earth/{types.d.ts → XYZConfig.d.ts} +6 -17
- package/lib-esm/model/earth/XYZConfig.js +13 -0
- package/lib-esm/model/earth/XYZFoVHelper.d.ts +12 -0
- package/lib-esm/model/earth/XYZFoVHelper.js +138 -0
- package/lib-esm/model/earth/XYZMap.d.ts +31 -0
- package/lib-esm/model/earth/XYZMap.js +208 -0
- package/lib-esm/model/earth/XYZMapDescriptor.d.ts +29 -0
- package/lib-esm/model/earth/XYZMapDescriptor.js +77 -0
- package/lib-esm/model/earth/XYZMeshBuilder.d.ts +1 -1
- package/lib-esm/model/earth/XYZMeshBuilder.js +13 -2
- package/lib-esm/model/earth/XYZTile.d.ts +20 -21
- package/lib-esm/model/earth/XYZTile.js +82 -102
- package/lib-esm/model/earth/XYZTileBuffer.d.ts +24 -26
- package/lib-esm/model/earth/XYZTileBuffer.js +60 -70
- package/lib-esm/model/earth/XYZTileRequestScheduler.d.ts +1 -1
- package/lib-esm/model/earth/XYZTileRequestScheduler.js +13 -2
- package/lib-esm/model/earth/XYZTypes.d.ts +24 -0
- package/lib-esm/model/earth/XYZTypes.js +13 -0
- package/lib-esm/model/earth/XYZVisibleTilesManager.d.ts +16 -27
- package/lib-esm/model/earth/XYZVisibleTilesManager.js +61 -192
- package/lib-esm/model/footprints/Footprint.d.ts +4 -1
- package/lib-esm/model/footprints/Footprint.js +30 -2
- package/lib-esm/model/footprints/FootprintProps.js +13 -1
- package/lib-esm/model/footprints/FootprintSetGL.d.ts +4 -2
- package/lib-esm/model/footprints/FootprintSetGL.js +21 -6
- package/lib-esm/model/grid/EquatorialGrid.d.ts +2 -1
- package/lib-esm/model/grid/EquatorialGrid.js +30 -12
- package/lib-esm/model/grid/GridTextHelper.d.ts +10 -19
- package/lib-esm/model/grid/GridTextHelper.js +70 -67
- package/lib-esm/model/grid/HealpixGrid.d.ts +4 -4
- package/lib-esm/model/grid/HealpixGrid.js +24 -8
- package/lib-esm/model/grid/LonLatGrid.d.ts +43 -0
- package/lib-esm/model/grid/LonLatGrid.js +309 -0
- package/lib-esm/model/hips/AllSky.js +12 -0
- package/lib-esm/model/hips/AncestorTile.js +12 -0
- package/lib-esm/model/hips/FoVHelper.d.ts +5 -2
- package/lib-esm/model/hips/FoVHelper.js +52 -3
- package/lib-esm/model/hips/HiPS.d.ts +2 -0
- package/lib-esm/model/hips/HiPS.js +38 -14
- package/lib-esm/model/hips/HiPSConfig.d.ts +13 -0
- package/lib-esm/model/hips/HiPSDescriptor.js +12 -0
- package/lib-esm/model/hips/Tile.d.ts +1 -0
- package/lib-esm/model/hips/Tile.js +15 -0
- package/lib-esm/model/hips/TileBuffer.d.ts +5 -0
- package/lib-esm/model/hips/TileBuffer.js +61 -0
- package/lib-esm/model/hips/VisibleTilesManager.js +12 -0
- package/lib-esm/model/tap/TapMetadata.js +12 -0
- package/lib-esm/model/tap/TapMetadataList.js +12 -0
- package/lib-esm/model/tap/TapRepo.js +12 -0
- package/lib-esm/model/terra/TerraFootprintSetGL.d.ts +6 -0
- package/lib-esm/model/terra/TerraFootprintSetGL.js +54 -0
- package/lib-esm/model/terra/TerraPointSetGL.js +12 -0
- package/lib-esm/services/SesameService.js +11 -3
- package/lib-esm/services/helpers.js +12 -0
- package/lib-esm/services/hipsNodeService.js +12 -0
- package/lib-esm/services/parse-hipslist.js +12 -0
- package/lib-esm/services/queryCatalogueByFoV.js +13 -1
- package/lib-esm/services/queryFootprintSetByFov.js +13 -1
- package/lib-esm/services/tapRepoService.js +13 -1
- package/lib-esm/services/types.js +12 -0
- package/lib-esm/shader/CatalogueShaderProgram.js +12 -0
- package/lib-esm/shader/FootprintShaderProgram.js +12 -0
- package/lib-esm/shader/GridShaderManager.js +12 -0
- package/lib-esm/shader/HiPSShaderProgram.js +12 -0
- package/lib-esm/shader/ShaderManager.js +12 -1
- package/lib-esm/shader/ShaderManagerMutliHiPS.js +12 -1
- package/lib-esm/shader/XYZShaderProgram.d.ts +14 -1
- package/lib-esm/shader/XYZShaderProgram.js +127 -2
- package/lib-esm/utils/CoordsType.d.ts +2 -1
- package/lib-esm/utils/CoordsType.js +13 -0
- package/lib-esm/utils/FoVUtils.js +12 -0
- package/lib-esm/utils/GeoJSONParser.d.ts +19 -0
- package/lib-esm/utils/GeoJSONParser.js +112 -0
- package/lib-esm/utils/GeomUtils.js +12 -0
- package/lib-esm/utils/MouseHelper.js +12 -0
- package/lib-esm/utils/PerspectiveMatrixManager.js +16 -1
- package/lib-esm/utils/RayPickingUtils.js +12 -0
- package/lib-esm/utils/STCSParser.d.ts +7 -3
- package/lib-esm/utils/STCSParser.js +27 -9
- package/lib-esm/utils/ShaderUtility.js +13 -1
- package/lib-esm/utils/Utils.js +12 -0
- package/lib-esm/utils/XYZRayPickingUtils.d.ts +27 -0
- package/lib-esm/utils/XYZRayPickingUtils.js +226 -0
- package/package.json +2 -2
- package/lib-esm/model/FoV.d.ts +0 -62
- package/lib-esm/model/FoV.js +0 -274
- package/lib-esm/model/earth/XYZAncestorMeshCache.d.ts +0 -10
- package/lib-esm/model/earth/XYZAncestorMeshCache.js +0 -31
- package/lib-esm/model/earth/XYZLayer.d.ts +0 -31
- package/lib-esm/model/earth/XYZLayer.js +0 -231
- package/lib-esm/model/earth/XYZTileProvider.d.ts +0 -29
- package/lib-esm/model/earth/XYZTileProvider.js +0 -187
- package/lib-esm/model/earth/wmts/types.d.ts +0 -1
- package/lib-esm/model/earth/wmts/types.js +0 -1
- /package/lib-esm/model/{earth/types.js → hips/HiPSConfig.js} +0 -0
|
@@ -0,0 +1,309 @@
|
|
|
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
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
14
|
+
import { mat4, vec4 } from 'gl-matrix';
|
|
15
|
+
import { AbstractSkyEntity } from '../AbstractSkyEntity.js';
|
|
16
|
+
import { xyzFovHelper } from '../earth/XYZFoVHelper.js';
|
|
17
|
+
import GridShaderManager from '../../shader/GridShaderManager.js';
|
|
18
|
+
import { colorHex2RGB, degToRad } from '../../utils/Utils.js';
|
|
19
|
+
import { SphereFoV } from '../SphereFoV.js';
|
|
20
|
+
import global from '../../Global.js';
|
|
21
|
+
import GridTextHelper from './GridTextHelper.js';
|
|
22
|
+
export class LatLonGrid extends AbstractSkyEntity {
|
|
23
|
+
static ELEM_SIZE = 3;
|
|
24
|
+
static BYTES_X_ELEM = new Float32Array().BYTES_PER_ELEMENT;
|
|
25
|
+
_shaderProgram;
|
|
26
|
+
_vertexShader;
|
|
27
|
+
_fragmentShader;
|
|
28
|
+
_attribLocations = {
|
|
29
|
+
position: 0,
|
|
30
|
+
};
|
|
31
|
+
_lonVertexPositionBuffer;
|
|
32
|
+
_latVertexPositionBuffer;
|
|
33
|
+
_lonStep = 10;
|
|
34
|
+
_latStep = 10;
|
|
35
|
+
_segmentStep = 1;
|
|
36
|
+
_fovObj;
|
|
37
|
+
_fovDeg = 180;
|
|
38
|
+
_showGrid = true;
|
|
39
|
+
_lonArray = [];
|
|
40
|
+
_latArray = [];
|
|
41
|
+
_bufferKey = '';
|
|
42
|
+
defaultColor = '#41d4d4';
|
|
43
|
+
gridText = new GridTextHelper('lonlat');
|
|
44
|
+
constructor(radius, position, xrad, yrad, name, webgl) {
|
|
45
|
+
super(radius, position, xrad, yrad, name, webgl);
|
|
46
|
+
this._fovObj = new SphereFoV(webgl);
|
|
47
|
+
this.init();
|
|
48
|
+
}
|
|
49
|
+
init() {
|
|
50
|
+
this.initGL(super.webgl);
|
|
51
|
+
const gl = super.webgl;
|
|
52
|
+
this._shaderProgram = gl.createProgram();
|
|
53
|
+
this.initShaders();
|
|
54
|
+
this._lonVertexPositionBuffer = gl.createBuffer();
|
|
55
|
+
this._latVertexPositionBuffer = gl.createBuffer();
|
|
56
|
+
this.initBuffers(this._fovDeg);
|
|
57
|
+
}
|
|
58
|
+
initShaders() {
|
|
59
|
+
const gl = super.webgl;
|
|
60
|
+
const fsSource = GridShaderManager.healpixGridFS();
|
|
61
|
+
this._fragmentShader = gl.createShader(gl.FRAGMENT_SHADER);
|
|
62
|
+
gl.shaderSource(this._fragmentShader, fsSource);
|
|
63
|
+
gl.compileShader(this._fragmentShader);
|
|
64
|
+
if (!gl.getShaderParameter(this._fragmentShader, gl.COMPILE_STATUS)) {
|
|
65
|
+
const log = gl.getShaderInfoLog(this._fragmentShader) || 'Unknown fragment shader error';
|
|
66
|
+
console.error(log);
|
|
67
|
+
alert(log);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const vsSource = GridShaderManager.healpixGridVS();
|
|
71
|
+
this._vertexShader = gl.createShader(gl.VERTEX_SHADER);
|
|
72
|
+
gl.shaderSource(this._vertexShader, vsSource);
|
|
73
|
+
gl.compileShader(this._vertexShader);
|
|
74
|
+
if (!gl.getShaderParameter(this._vertexShader, gl.COMPILE_STATUS)) {
|
|
75
|
+
const log = gl.getShaderInfoLog(this._vertexShader) || 'Unknown vertex shader error';
|
|
76
|
+
console.error(log);
|
|
77
|
+
alert(log);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
gl.attachShader(this._shaderProgram, this._vertexShader);
|
|
81
|
+
gl.attachShader(this._shaderProgram, this._fragmentShader);
|
|
82
|
+
gl.linkProgram(this._shaderProgram);
|
|
83
|
+
if (!gl.getProgramParameter(this._shaderProgram, gl.LINK_STATUS)) {
|
|
84
|
+
alert('Could not initialise shaders');
|
|
85
|
+
}
|
|
86
|
+
gl.useProgram(this._shaderProgram);
|
|
87
|
+
}
|
|
88
|
+
initBuffers(fovDeg, centerSphericalDeg, coarse = false) {
|
|
89
|
+
const steps = xyzFovHelper.getLonLatSteps(fovDeg, coarse);
|
|
90
|
+
this._lonStep = steps.lonStep;
|
|
91
|
+
this._latStep = steps.latStep;
|
|
92
|
+
this._segmentStep = Math.max(Math.min(this._lonStep, this._latStep), 0.25);
|
|
93
|
+
this._lonArray = [];
|
|
94
|
+
this._latArray = [];
|
|
95
|
+
const center = centerSphericalDeg
|
|
96
|
+
? {
|
|
97
|
+
lon: this.normalizeLon(centerSphericalDeg.phi > 180 ? centerSphericalDeg.phi - 360 : centerSphericalDeg.phi),
|
|
98
|
+
lat: 90 - centerSphericalDeg.theta,
|
|
99
|
+
}
|
|
100
|
+
: null;
|
|
101
|
+
const localGrid = !!center && !coarse && fovDeg < 2;
|
|
102
|
+
const lonValues = localGrid
|
|
103
|
+
? this.buildLonRange(center.lon, Math.max(fovDeg * 4, this._lonStep * 3), this._lonStep)
|
|
104
|
+
: this.buildLonRange(0, 180, this._lonStep);
|
|
105
|
+
const latValues = localGrid
|
|
106
|
+
? this.buildLatRange(center.lat, Math.max(fovDeg * 4, this._latStep * 3), this._latStep)
|
|
107
|
+
: this.buildLatRange(0, 90, this._latStep);
|
|
108
|
+
const latSegmentRange = localGrid && center
|
|
109
|
+
? this.buildLatRange(center.lat, Math.max(fovDeg * 4, this._latStep * 3), this._segmentStep)
|
|
110
|
+
: this.buildLatRange(0, 90, this._segmentStep);
|
|
111
|
+
const lonSegmentRange = localGrid && center
|
|
112
|
+
? this.buildLonRange(center.lon, Math.max(fovDeg * 4, this._lonStep * 3), this._segmentStep)
|
|
113
|
+
: this.buildLonRange(0, 180, this._segmentStep);
|
|
114
|
+
for (const lon of lonValues) {
|
|
115
|
+
const vertices = [];
|
|
116
|
+
for (const lat of latSegmentRange) {
|
|
117
|
+
vertices.push(...this.lonLatToCartesian(lon, Math.min(lat, 90)));
|
|
118
|
+
}
|
|
119
|
+
this._lonArray.push(new Float32Array(vertices));
|
|
120
|
+
}
|
|
121
|
+
for (const lat of latValues) {
|
|
122
|
+
const vertices = [];
|
|
123
|
+
if (lat <= -90 || lat >= 90)
|
|
124
|
+
continue;
|
|
125
|
+
for (const lon of lonSegmentRange) {
|
|
126
|
+
vertices.push(...this.lonLatToCartesian(Math.min(lon, 180), lat));
|
|
127
|
+
}
|
|
128
|
+
this._latArray.push(new Float32Array(vertices));
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
buildLonRange(centerLon, halfSpan, step) {
|
|
132
|
+
const values = [];
|
|
133
|
+
const start = Math.floor((centerLon - halfSpan) / step) * step;
|
|
134
|
+
const end = Math.ceil((centerLon + halfSpan) / step) * step;
|
|
135
|
+
for (let lon = start; lon <= end; lon += step) {
|
|
136
|
+
values.push(this.normalizeLon(lon));
|
|
137
|
+
}
|
|
138
|
+
return values;
|
|
139
|
+
}
|
|
140
|
+
buildLatRange(centerLat, halfSpan, step) {
|
|
141
|
+
const values = [];
|
|
142
|
+
const start = Math.max(-90, Math.floor((centerLat - halfSpan) / step) * step);
|
|
143
|
+
const end = Math.min(90, Math.ceil((centerLat + halfSpan) / step) * step);
|
|
144
|
+
for (let lat = start; lat <= end; lat += step) {
|
|
145
|
+
values.push(lat);
|
|
146
|
+
}
|
|
147
|
+
return values;
|
|
148
|
+
}
|
|
149
|
+
lonLatToCartesian(lonDeg, latDeg) {
|
|
150
|
+
const lonRad = degToRad(lonDeg);
|
|
151
|
+
const latRad = degToRad(latDeg);
|
|
152
|
+
const cosLat = Math.cos(latRad);
|
|
153
|
+
return [
|
|
154
|
+
cosLat * Math.cos(lonRad),
|
|
155
|
+
cosLat * Math.sin(lonRad),
|
|
156
|
+
Math.sin(latRad),
|
|
157
|
+
];
|
|
158
|
+
}
|
|
159
|
+
refresh(fovDeg, input) {
|
|
160
|
+
const coarse = !!input.cameraMoving;
|
|
161
|
+
const steps = xyzFovHelper.getLonLatSteps(fovDeg, coarse);
|
|
162
|
+
const center = input.centerSphericalDeg;
|
|
163
|
+
const localGrid = !!center && !coarse && fovDeg < 2;
|
|
164
|
+
const centerLon = center ? this.normalizeLon(center.phi > 180 ? center.phi - 360 : center.phi) : 0;
|
|
165
|
+
const centerLat = center ? 90 - center.theta : 0;
|
|
166
|
+
const centerKey = localGrid
|
|
167
|
+
? `${this.roundToStep(centerLon, Math.max(steps.lonStep, fovDeg))}:${this.roundToStep(centerLat, Math.max(steps.latStep, fovDeg))}`
|
|
168
|
+
: 'global';
|
|
169
|
+
const bufferKey = `${coarse ? 'coarse' : 'settled'}:${steps.lonStep}:${steps.latStep}:${centerKey}`;
|
|
170
|
+
if (this._bufferKey !== bufferKey) {
|
|
171
|
+
this._fovDeg = fovDeg;
|
|
172
|
+
this._bufferKey = bufferKey;
|
|
173
|
+
this.initBuffers(this._fovDeg, input.centerSphericalDeg, coarse);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
refreshFoV(input) {
|
|
177
|
+
if (!input.camera || !input.pMatrix)
|
|
178
|
+
return this._fovDeg;
|
|
179
|
+
this._fovObj.getFoV(global.insideSphere, this, input.camera, input.pMatrix);
|
|
180
|
+
this.refresh(this._fovObj.minFoV, input);
|
|
181
|
+
return this._fovObj.minFoV;
|
|
182
|
+
}
|
|
183
|
+
getMinFoVDeg() {
|
|
184
|
+
return this._fovObj.minFoV;
|
|
185
|
+
}
|
|
186
|
+
getFoV() {
|
|
187
|
+
return this._fovObj;
|
|
188
|
+
}
|
|
189
|
+
isVisible() {
|
|
190
|
+
return this._showGrid;
|
|
191
|
+
}
|
|
192
|
+
toggleShowGrid() {
|
|
193
|
+
this._showGrid = !this._showGrid;
|
|
194
|
+
return this._showGrid;
|
|
195
|
+
}
|
|
196
|
+
setShowGrid(showGrid) {
|
|
197
|
+
this._showGrid = showGrid;
|
|
198
|
+
}
|
|
199
|
+
enableShader(mMatrix, pMatrix, vMatrix) {
|
|
200
|
+
const gl = super.webgl;
|
|
201
|
+
gl.useProgram(this._shaderProgram);
|
|
202
|
+
const mvMatrix = mat4.create();
|
|
203
|
+
mat4.multiply(mvMatrix, vMatrix, mMatrix);
|
|
204
|
+
const uMVMatrixLoc = gl.getUniformLocation(this._shaderProgram, 'uMVMatrix');
|
|
205
|
+
const uPMatrixLoc = gl.getUniformLocation(this._shaderProgram, 'uPMatrix');
|
|
206
|
+
const uColor = gl.getUniformLocation(this._shaderProgram, 'u_fragcolor');
|
|
207
|
+
this._attribLocations.position = gl.getAttribLocation(this._shaderProgram, 'aCatPosition');
|
|
208
|
+
if (uMVMatrixLoc)
|
|
209
|
+
gl.uniformMatrix4fv(uMVMatrixLoc, false, mvMatrix);
|
|
210
|
+
if (uPMatrixLoc)
|
|
211
|
+
gl.uniformMatrix4fv(uPMatrixLoc, false, pMatrix);
|
|
212
|
+
if (uColor) {
|
|
213
|
+
const rgb = colorHex2RGB(this.defaultColor);
|
|
214
|
+
gl.uniform4f(uColor, rgb[0], rgb[1], rgb[2], 1.0);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
draw(input) {
|
|
218
|
+
if (!this._showGrid) {
|
|
219
|
+
this.gridText.resetDivSets();
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
const gl = super.webgl;
|
|
223
|
+
const camera = input.camera;
|
|
224
|
+
if (!camera)
|
|
225
|
+
return;
|
|
226
|
+
const pMatrix = input.pMatrix;
|
|
227
|
+
if (!pMatrix)
|
|
228
|
+
return;
|
|
229
|
+
this.refreshFoV(input);
|
|
230
|
+
const vMatrix = camera.getCameraMatrix();
|
|
231
|
+
if (!vMatrix)
|
|
232
|
+
return;
|
|
233
|
+
const mMatrix = this.getModelMatrix();
|
|
234
|
+
this.enableShader(mMatrix, pMatrix, vMatrix);
|
|
235
|
+
for (const lonLine of this._lonArray) {
|
|
236
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._lonVertexPositionBuffer);
|
|
237
|
+
gl.bufferData(gl.ARRAY_BUFFER, lonLine, gl.STATIC_DRAW);
|
|
238
|
+
gl.vertexAttribPointer(this._attribLocations.position, LatLonGrid.ELEM_SIZE, gl.FLOAT, false, 0, 0);
|
|
239
|
+
gl.enableVertexAttribArray(this._attribLocations.position);
|
|
240
|
+
gl.drawArrays(gl.LINE_STRIP, 0, lonLine.length / LatLonGrid.ELEM_SIZE);
|
|
241
|
+
}
|
|
242
|
+
for (const latLine of this._latArray) {
|
|
243
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, this._latVertexPositionBuffer);
|
|
244
|
+
gl.bufferData(gl.ARRAY_BUFFER, latLine, gl.STATIC_DRAW);
|
|
245
|
+
gl.vertexAttribPointer(this._attribLocations.position, LatLonGrid.ELEM_SIZE, gl.FLOAT, false, 0, 0);
|
|
246
|
+
gl.enableVertexAttribArray(this._attribLocations.position);
|
|
247
|
+
gl.drawArrays(gl.LINE_LOOP, 0, latLine.length / LatLonGrid.ELEM_SIZE);
|
|
248
|
+
}
|
|
249
|
+
this.drawLabels(input, mMatrix, pMatrix, vMatrix);
|
|
250
|
+
gl.bindBuffer(gl.ARRAY_BUFFER, null);
|
|
251
|
+
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, null);
|
|
252
|
+
}
|
|
253
|
+
drawLabels(input, mMatrix, pMatrix, vMatrix) {
|
|
254
|
+
const center = input.centerSphericalDeg;
|
|
255
|
+
if (!center) {
|
|
256
|
+
this.gridText.resetDivSets();
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
const centerLon = this.normalizeLon(center.phi > 180 ? center.phi - 360 : center.phi);
|
|
260
|
+
const centerLat = 90 - center.theta;
|
|
261
|
+
const lonLine = this.normalizeLon(this.roundToStep(centerLon, this._lonStep));
|
|
262
|
+
const latLine = Math.max(-90 + this._latStep, Math.min(90 - this._latStep, this.roundToStep(centerLat, this._latStep)));
|
|
263
|
+
const lonLabelPoint = this.lonLatToCartesian(lonLine, Math.max(-80, Math.min(80, centerLat)));
|
|
264
|
+
const latLabelPoint = this.lonLatToCartesian(centerLon, latLine);
|
|
265
|
+
const lonScreen = this.projectPointToScreen(lonLabelPoint, mMatrix, pMatrix, vMatrix);
|
|
266
|
+
if (lonScreen) {
|
|
267
|
+
this.gridText.addLonLatDivSet(`${lonLine.toFixed(0)}° lon`, lonScreen.x, lonScreen.y, 'lon');
|
|
268
|
+
}
|
|
269
|
+
const latScreen = this.projectPointToScreen(latLabelPoint, mMatrix, pMatrix, vMatrix);
|
|
270
|
+
if (latScreen) {
|
|
271
|
+
this.gridText.addLonLatDivSet(`${latLine.toFixed(0)}° lat`, latScreen.x, latScreen.y, 'lat');
|
|
272
|
+
}
|
|
273
|
+
this.gridText.resetDivSets();
|
|
274
|
+
}
|
|
275
|
+
projectPointToScreen(point, mMatrix, pMatrix, vMatrix) {
|
|
276
|
+
const mvMatrix = mat4.create();
|
|
277
|
+
const mvpMatrix = mat4.create();
|
|
278
|
+
mat4.multiply(mvMatrix, vMatrix, mMatrix);
|
|
279
|
+
mat4.multiply(mvpMatrix, pMatrix, mvMatrix);
|
|
280
|
+
const clipspace = vec4.fromValues(point[0], point[1], point[2], 1);
|
|
281
|
+
vec4.transformMat4(clipspace, clipspace, mvpMatrix);
|
|
282
|
+
if (Math.abs(clipspace[3]) < 1e-6) {
|
|
283
|
+
return null;
|
|
284
|
+
}
|
|
285
|
+
clipspace[0] /= clipspace[3];
|
|
286
|
+
clipspace[1] /= clipspace[3];
|
|
287
|
+
if (clipspace[0] < -1 || clipspace[0] > 1 || clipspace[1] < -1 || clipspace[1] > 1) {
|
|
288
|
+
return null;
|
|
289
|
+
}
|
|
290
|
+
const canvasRect = super.webgl.canvas.getBoundingClientRect();
|
|
291
|
+
return {
|
|
292
|
+
x: canvasRect.left + (clipspace[0] * 0.5 + 0.5) * canvasRect.width,
|
|
293
|
+
y: canvasRect.top + (clipspace[1] * -0.5 + 0.5) * canvasRect.height,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
roundToStep(value, step) {
|
|
297
|
+
if (step <= 0)
|
|
298
|
+
return value;
|
|
299
|
+
return Math.round(value / step) * step;
|
|
300
|
+
}
|
|
301
|
+
normalizeLon(lonDeg) {
|
|
302
|
+
let lon = lonDeg;
|
|
303
|
+
while (lon < -180)
|
|
304
|
+
lon += 360;
|
|
305
|
+
while (lon > 180)
|
|
306
|
+
lon -= 360;
|
|
307
|
+
return lon;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
@@ -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
|
import global from '../../Global.js';
|
|
3
15
|
export default class AllSky {
|
|
@@ -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
|
import global from '../../Global.js';
|
|
3
15
|
import { fovHelper } from './FoVHelper.js';
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
declare class FoVHelper {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
private static readonly LEVEL_HYSTERESIS;
|
|
3
|
+
private static readonly HIPS_ORDER_MIN_FOV;
|
|
4
|
+
getHiPSNorder(fov: number, currentOrder?: number): number;
|
|
5
|
+
private getRawHiPSNorder;
|
|
6
|
+
getRADegSteps(fov: number, coarse?: boolean): {
|
|
4
7
|
raStep: number;
|
|
5
8
|
decStep: number;
|
|
6
9
|
};
|
|
@@ -1,7 +1,52 @@
|
|
|
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
|
// FoVHelper.ts
|
|
2
14
|
'use strict';
|
|
3
15
|
class FoVHelper {
|
|
4
|
-
|
|
16
|
+
static LEVEL_HYSTERESIS = 0.12;
|
|
17
|
+
static HIPS_ORDER_MIN_FOV = {
|
|
18
|
+
0: 179,
|
|
19
|
+
1: 90,
|
|
20
|
+
2: 30,
|
|
21
|
+
3: 20,
|
|
22
|
+
4: 6,
|
|
23
|
+
5: 3.2,
|
|
24
|
+
6: 1.6,
|
|
25
|
+
7: 0.85,
|
|
26
|
+
8: 0.42,
|
|
27
|
+
9: 0.21,
|
|
28
|
+
10: 0.12,
|
|
29
|
+
11: 0.06,
|
|
30
|
+
12: 0.015,
|
|
31
|
+
13: 0,
|
|
32
|
+
};
|
|
33
|
+
getHiPSNorder(fov, currentOrder) {
|
|
34
|
+
const rawOrder = this.getRawHiPSNorder(fov);
|
|
35
|
+
if (currentOrder === undefined || currentOrder === rawOrder)
|
|
36
|
+
return rawOrder;
|
|
37
|
+
if (rawOrder > currentOrder) {
|
|
38
|
+
const boundary = FoVHelper.HIPS_ORDER_MIN_FOV[currentOrder];
|
|
39
|
+
if (boundary > 0 && fov > boundary * (1 - FoVHelper.LEVEL_HYSTERESIS))
|
|
40
|
+
return currentOrder;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
const boundary = FoVHelper.HIPS_ORDER_MIN_FOV[rawOrder];
|
|
44
|
+
if (boundary > 0 && fov < boundary * (1 + FoVHelper.LEVEL_HYSTERESIS))
|
|
45
|
+
return currentOrder;
|
|
46
|
+
}
|
|
47
|
+
return rawOrder;
|
|
48
|
+
}
|
|
49
|
+
getRawHiPSNorder(fov) {
|
|
5
50
|
if (fov >= 179)
|
|
6
51
|
return 0;
|
|
7
52
|
if (fov >= 90)
|
|
@@ -30,10 +75,14 @@ class FoVHelper {
|
|
|
30
75
|
return 12;
|
|
31
76
|
return 13;
|
|
32
77
|
}
|
|
33
|
-
getRADegSteps(fov) {
|
|
78
|
+
getRADegSteps(fov, coarse = false) {
|
|
34
79
|
let raStep;
|
|
35
80
|
let decStep;
|
|
36
|
-
if (fov
|
|
81
|
+
if (coarse && fov < 0.21) {
|
|
82
|
+
raStep = 10;
|
|
83
|
+
decStep = 10;
|
|
84
|
+
}
|
|
85
|
+
else if (fov >= 179) {
|
|
37
86
|
raStep = 10;
|
|
38
87
|
decStep = 10;
|
|
39
88
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { AbstractSkyEntity, SkyEntityDrawInput } from '../AbstractSkyEntity.js';
|
|
5
5
|
import { ColorMap } from '../ColorMaps.js';
|
|
6
6
|
import { HiPSDescriptor } from './HiPSDescriptor.js';
|
|
7
|
+
import type { HiPSDebugStats } from './HiPSConfig.js';
|
|
7
8
|
import { HealpixGrid } from '../grid/HealpixGrid.js';
|
|
8
9
|
export declare class HiPS extends AbstractSkyEntity {
|
|
9
10
|
private _ancestorTiles;
|
|
@@ -41,6 +42,7 @@ export declare class HiPS extends AbstractSkyEntity {
|
|
|
41
42
|
changeColorMap(colorMap: ColorMap): void;
|
|
42
43
|
private initShaders;
|
|
43
44
|
getCurrentHealpixOrder(): number;
|
|
45
|
+
getDebugStats(): HiPSDebugStats;
|
|
44
46
|
private refresh;
|
|
45
47
|
draw(input: SkyEntityDrawInput): void;
|
|
46
48
|
}
|
|
@@ -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)
|
|
@@ -5,8 +17,6 @@
|
|
|
5
17
|
import { AbstractSkyEntity } from '../AbstractSkyEntity.js';
|
|
6
18
|
import { fovHelper } from './FoVHelper.js';
|
|
7
19
|
import ColorMaps from '../ColorMaps.js';
|
|
8
|
-
// import { hipsShaderProgram } from '../../shader/HiPSShaderProgram.js'
|
|
9
|
-
// import { HiPSShaderProgram } from '../../shader/HiPSShaderProgram.js'
|
|
10
20
|
import AncestorTile from './AncestorTile.js';
|
|
11
21
|
import AllSky from './AllSky.js';
|
|
12
22
|
export class HiPS extends AbstractSkyEntity {
|
|
@@ -33,10 +43,8 @@ export class HiPS extends AbstractSkyEntity {
|
|
|
33
43
|
constructor(radius, position, xrad, yrad, descriptor, webgl, healpixGrid) {
|
|
34
44
|
super(radius, position, xrad, yrad, descriptor.surveyName, webgl, descriptor.isGalactic);
|
|
35
45
|
this._descriptor = descriptor;
|
|
36
|
-
// this.initGL((global as any).gl as WebGL2RenderingContext)
|
|
37
46
|
this.initGL(webgl);
|
|
38
47
|
this._healpixGrid = healpixGrid;
|
|
39
|
-
// newTileBuffer.addHiPS(this)
|
|
40
48
|
this._healpixGrid.visibleTilesManager.tileBuffer.addHiPS(this);
|
|
41
49
|
// DEBUG logs kept from JS (optional)
|
|
42
50
|
// eslint-disable-next-line no-console
|
|
@@ -172,10 +180,31 @@ export class HiPS extends AbstractSkyEntity {
|
|
|
172
180
|
getCurrentHealpixOrder() {
|
|
173
181
|
return this._visibleorder;
|
|
174
182
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
const
|
|
178
|
-
|
|
183
|
+
getDebugStats() {
|
|
184
|
+
const tileBuffer = this._healpixGrid.visibleTilesManager.tileBuffer;
|
|
185
|
+
const visibleTiles = this.isGalacticHips
|
|
186
|
+
? this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder
|
|
187
|
+
: this._healpixGrid.visibleTilesManager.visibleTilesByOrder;
|
|
188
|
+
return {
|
|
189
|
+
activeBaseLayer: 'hips',
|
|
190
|
+
hipsName: this._descriptor.surveyName,
|
|
191
|
+
hipsUrl: this._baseurl,
|
|
192
|
+
isGalactic: this.isGalacticHips,
|
|
193
|
+
currentOrder: visibleTiles.order,
|
|
194
|
+
visibleTileCount: visibleTiles.pixels.length,
|
|
195
|
+
activeTileCount: tileBuffer.activeTileCount,
|
|
196
|
+
cachedTileCount: tileBuffer.cachedTileCount,
|
|
197
|
+
cacheSize: tileBuffer.size,
|
|
198
|
+
readyTileCount: tileBuffer.readyTileCount,
|
|
199
|
+
loadingTileCount: tileBuffer.loadingTileCount,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
refresh(input) {
|
|
203
|
+
// const fov = this._healpixGrid.getMinFoV()
|
|
204
|
+
// this._visibleorder = Math.min(fovHelper.getHiPSNorder(fov), this._maxorder)
|
|
205
|
+
const rawFov = input.fovDeg ?? this._healpixGrid.getMinFoV();
|
|
206
|
+
const fov = Number.isFinite(rawFov) && rawFov > 0 ? rawFov : 1e-6;
|
|
207
|
+
this._visibleorder = Math.min(fovHelper.getHiPSNorder(fov, this._visibleorder), this._maxorder);
|
|
179
208
|
}
|
|
180
209
|
draw(input) {
|
|
181
210
|
const vMatrix = input.camera.getCameraMatrix();
|
|
@@ -184,8 +213,7 @@ export class HiPS extends AbstractSkyEntity {
|
|
|
184
213
|
const pMatrix = input.pMatrix;
|
|
185
214
|
if (!pMatrix)
|
|
186
215
|
return;
|
|
187
|
-
this.refresh();
|
|
188
|
-
// const pMatrix = computePerspectiveMatrixSingleton.pMatrix as Float32Array
|
|
216
|
+
this.refresh(input);
|
|
189
217
|
const mMatrix = this.getModelMatrix();
|
|
190
218
|
super.hipsShaderProgram.setRuntimeColorMap(this.colorMap);
|
|
191
219
|
if (this._allSky && this._allSkyTile) {
|
|
@@ -207,13 +235,9 @@ export class HiPS extends AbstractSkyEntity {
|
|
|
207
235
|
const order = this.isGalacticHips
|
|
208
236
|
? this._healpixGrid.visibleTilesManager.galVisibleTilesByOrder.order
|
|
209
237
|
: this._healpixGrid.visibleTilesManager.visibleTilesByOrder.order;
|
|
210
|
-
// ? visibleTilesManager.galVisibleTilesByOrder.order
|
|
211
|
-
// : visibleTilesManager.visibleTilesByOrder.order
|
|
212
238
|
const map = this.isGalacticHips
|
|
213
239
|
? this._healpixGrid.visibleTilesManager.galAncestorsMap
|
|
214
240
|
: this._healpixGrid.visibleTilesManager.ancestorsMap;
|
|
215
|
-
// ? visibleTilesManager.galAncestorsMap
|
|
216
|
-
// : visibleTilesManager.ancestorsMap
|
|
217
241
|
this._ancestorTiles.forEach((ancestor) => {
|
|
218
242
|
ancestor.draw(order, map, pMatrix, vMatrix, mMatrix, this.colorMapIdx);
|
|
219
243
|
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type HiPSDebugStats = {
|
|
2
|
+
activeBaseLayer: 'hips' | 'xyz' | null;
|
|
3
|
+
hipsName: string | null;
|
|
4
|
+
hipsUrl: string | null;
|
|
5
|
+
isGalactic: boolean | null;
|
|
6
|
+
currentOrder: number | null;
|
|
7
|
+
visibleTileCount: number;
|
|
8
|
+
activeTileCount: number;
|
|
9
|
+
cachedTileCount: number;
|
|
10
|
+
cacheSize: number;
|
|
11
|
+
readyTileCount: number;
|
|
12
|
+
loadingTileCount: number;
|
|
13
|
+
};
|
|
@@ -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
|
// HiPSDescriptor.ts
|
|
2
14
|
'use strict';
|
|
3
15
|
export class HiPSDescriptor {
|
|
@@ -32,6 +32,7 @@ export default class Tile {
|
|
|
32
32
|
constructor(tileno: number, order: number, hips: HiPS, tileBuffer: TileBuffer, webgl: WebGL2RenderingContext, visibleTileManager: VisibleTilesManager);
|
|
33
33
|
destroyIntervals(): void;
|
|
34
34
|
getReadyState(): boolean;
|
|
35
|
+
isLoading(): boolean;
|
|
35
36
|
get cacheTime0(): number | undefined;
|
|
36
37
|
resetCacheTime0(): void;
|
|
37
38
|
setCacheTime0(): void;
|
|
@@ -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
|
// Tile.ts
|
|
2
14
|
import global from '../../Global.js';
|
|
3
15
|
import { fovHelper } from './FoVHelper.js';
|
|
@@ -53,6 +65,9 @@ export default class Tile {
|
|
|
53
65
|
getReadyState() {
|
|
54
66
|
return this._ready;
|
|
55
67
|
}
|
|
68
|
+
isLoading() {
|
|
69
|
+
return !this._ready && !this._abort;
|
|
70
|
+
}
|
|
56
71
|
get cacheTime0() {
|
|
57
72
|
return this._cacheTime0;
|
|
58
73
|
}
|
|
@@ -35,4 +35,9 @@ export declare class TileBuffer {
|
|
|
35
35
|
private key;
|
|
36
36
|
/** Optional: call to stop internal timers if you dispose this buffer. */
|
|
37
37
|
dispose(): void;
|
|
38
|
+
get size(): number;
|
|
39
|
+
get activeTileCount(): number;
|
|
40
|
+
get cachedTileCount(): number;
|
|
41
|
+
get readyTileCount(): number;
|
|
42
|
+
get loadingTileCount(): number;
|
|
38
43
|
}
|
|
@@ -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
|
// TileBuffer.ts
|
|
2
14
|
import Tile from './Tile.js'; // adjust if your file is named differently
|
|
3
15
|
// export default class TileBuffer {
|
|
@@ -142,6 +154,55 @@ export class TileBuffer {
|
|
|
142
154
|
dispose() {
|
|
143
155
|
window.clearInterval(this._cleanerId);
|
|
144
156
|
}
|
|
157
|
+
get size() {
|
|
158
|
+
return this._tiles.size + this._cachedTiles.size + this._galTiles.size + this._galCachedTiles.size;
|
|
159
|
+
}
|
|
160
|
+
get activeTileCount() {
|
|
161
|
+
return this._tiles.size + this._galTiles.size;
|
|
162
|
+
}
|
|
163
|
+
get cachedTileCount() {
|
|
164
|
+
return this._cachedTiles.size + this._galCachedTiles.size;
|
|
165
|
+
}
|
|
166
|
+
get readyTileCount() {
|
|
167
|
+
let count = 0;
|
|
168
|
+
for (const tile of this._tiles.values()) {
|
|
169
|
+
if (tile.getReadyState())
|
|
170
|
+
count++;
|
|
171
|
+
}
|
|
172
|
+
for (const tile of this._galTiles.values()) {
|
|
173
|
+
if (tile.getReadyState())
|
|
174
|
+
count++;
|
|
175
|
+
}
|
|
176
|
+
for (const tile of this._cachedTiles.values()) {
|
|
177
|
+
if (tile.getReadyState())
|
|
178
|
+
count++;
|
|
179
|
+
}
|
|
180
|
+
for (const tile of this._galCachedTiles.values()) {
|
|
181
|
+
if (tile.getReadyState())
|
|
182
|
+
count++;
|
|
183
|
+
}
|
|
184
|
+
return count;
|
|
185
|
+
}
|
|
186
|
+
get loadingTileCount() {
|
|
187
|
+
let count = 0;
|
|
188
|
+
for (const tile of this._tiles.values()) {
|
|
189
|
+
if (tile.isLoading())
|
|
190
|
+
count++;
|
|
191
|
+
}
|
|
192
|
+
for (const tile of this._galTiles.values()) {
|
|
193
|
+
if (tile.isLoading())
|
|
194
|
+
count++;
|
|
195
|
+
}
|
|
196
|
+
for (const tile of this._cachedTiles.values()) {
|
|
197
|
+
if (tile.isLoading())
|
|
198
|
+
count++;
|
|
199
|
+
}
|
|
200
|
+
for (const tile of this._galCachedTiles.values()) {
|
|
201
|
+
if (tile.isLoading())
|
|
202
|
+
count++;
|
|
203
|
+
}
|
|
204
|
+
return count;
|
|
205
|
+
}
|
|
145
206
|
}
|
|
146
207
|
// Singleton (kept for compatibility with your original export)
|
|
147
208
|
// export const newTileBuffer = new TileBuffer()
|