-
Notifications
You must be signed in to change notification settings - Fork 0
/
properties.ts
390 lines (369 loc) · 8.4 KB
/
properties.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
import {
PerspectiveCameraProps,
Props as CanvasProps,
} from "@react-three/fiber";
import { Color as ThreeColor } from "three";
import { Degree, Radian } from ".";
import { CONSTELLATION_KEY } from "./core/constellations";
import { Star, StarDict } from "./core/stars";
/**
* Color type, same as three.Color.
* @see ThreeColor
*/
export type Color = ThreeColor;
/**
* Root of properties for CelestialEngine.
*/
export type CelestialEngineProps = UniverseProps &
InternationalizationProps &
RepresentationProps &
ObservationProps &
InteractionProps;
/**
* Properties of the universe.
*/
export interface UniverseProps {
/**
* clock of current universe.
*/
universeClock: Date;
/**
* dictionary of the loaded stars.
*/
stars: StarDict;
/**
* upper-bound Vmag for the stars.
*/
vMag: number;
/**
* radius of the celestial sphere.
* @defaultvalue 20.0
*/
sphereRadius?: number;
/**
* ratio for star sizes.
* @defaultvalue 1.0 .
*/
starSizeRatio?: number;
}
export interface InternationalizationProps {
/**
* constellation names.
* @defaultvalue DEFAULT_KNOWN_CONS_NAMES .
*/
constellationNames: { [key in CONSTELLATION_KEY]: string };
/**
* star names.
* @defaultvalue DEFAULT_KNOWN_STAR_NAMES .
*/
starNames: { [key: number]: string };
}
/**
* Properties for representational elements.
*/
export interface RepresentationProps {
/**
* properties for constellation lines.
*/
constellations?: RepresentationItemProps;
/**
* properties for the equatorial grid sphere.
*/
equatorialGrid?: RepresentationItemProps;
/**
* properties for the azimuthal grid sphere.
*/
azimuthalGrid?: RepresentationItemProps;
/**
* properties for the direction label.
*/
directionLabel?: DirectionLabelProps;
/**
* properties for the star marker.
* key: star number (HIP ID), value: props for the star.
*/
starMarkers?: StarMarkerProps[];
/**
* Default font for labels (TTF, OTF, and WOFF formats are supported).
* This value will be applied for labels items except the labels which
* have specified their own font properties.
* @defaultvalue "(The Roboto font from Google Fonts CDN)"
*/
defaultFont?: string;
/**
* Default font size (em-height, in local world unit) for labels.
* @defaultvalue 0.1
*/
defaultFontSize?: number;
}
/**
* Properties shared between the representational items.
*/
export interface RepresentationItemPropsBase {
/**
* show the element.
* @defaultvalue true
*/
show?: boolean;
/**
* line color.
*/
color?: Color;
/**
* opacity of the element.
* @defaultvalue 1.0
*/
opacity?: number;
/**
* radial offset against the sphere radius.
* @defaultvalue 0.0
*/
radialOffset?: number;
}
/**
* Properties for grids and constellation lines.
*/
export interface RepresentationItemProps extends RepresentationItemPropsBase {
/**
* width of the lines.
* @defaultvalue 1.0
*/
lineWidth?: number;
}
export interface RepresentationLabelItemPropsBase
extends RepresentationItemPropsBase {
/**
* The font for the label (TTF, OTF, and WOFF formats are supported).
* @defaultvalue defaultFont
*/
font?: string;
/**
* The font size (em-height, in local world unit) for the label.
* @defaultvalue defaultFontSize
*/
fontSize?: number;
}
/**
* Properties for navigation labels.
*/
export interface DirectionLabelProps extends RepresentationLabelItemPropsBase {
/**
* directional label texts.
*/
texts?: {
north: string;
east: string;
south: string;
west: string;
};
}
/**
* Properties for the star markers.
*/
export interface StarMarkerProps extends RepresentationLabelItemPropsBase {
/**
* star number, aka HIP ID
*/
starNumber: number;
/**
* label text for the star.
* @defaultvalue declared star name correspond to specified star.
*/
text?: string;
/**
* marker size.
*/
markerSize?: number;
/**
* show the target marker.
* @defaultvalue true
*/
showTargetMark?: boolean;
}
/**
* Properties for the observer.
*/
export interface ObservationProps {
/**
* latitude of the observation location, in degree. [-90..+90]
*/
latitude: Degree;
/**
* longitude of the observation location, in degree. [0..360]
*/
longitude: Degree;
/**
* observation target.
*/
target: ObservationTargetProps;
/**
* camera fov, in degree.
*/
fov: Degree;
/**
* zoom factor.
*/
zoom: number;
/**
* animation speed. (0.0..1.0]
* @defaultvalue 1.0
*/
animationSpeed?: number;
/**
* optional camera properties for @see PerspectiveCamera .
*/
cameraProps?: Omit<
PerspectiveCameraProps,
"fov" | "zoom" | "aspect" | "position" | "ref"
>;
}
export type ObservationTargetProps =
| ObservationAzAltTargetProps
| ObservationRaDecTargetProps
| ObservationStarTargetProps;
/**
* Properties of the az/alt for observation target (center).
*/
export interface ObservationAzAltTargetProps {
/**
* azimuth angle, in degree. [0..360]
*/
azimuth: Degree;
/**
* altitude angle, in degree. [-90..+90]
*/
altitude: Degree;
}
/**
* Properties of the ra/dec for the observation target (center).
*/
export interface ObservationRaDecTargetProps {
/**
* right ascension, in radian.
*/
ra: Radian;
/**
* declination, in radian.
*/
dec: Radian;
}
/**
* Properties of the star numbore for observation target (center).
*/
export interface ObservationStarTargetProps {
/**
* targeting star number.
*/
starNumber: number;
}
/**
* Distinguish the observation target is identified by the Az/Alt.
* @param target observation target
*/
export const targetIsAzAlt = (
target: ObservationTargetProps
): target is ObservationAzAltTargetProps => "azimuth" in target;
/**
* Distinguish the observation target is identified by the celestial Ra/Dec.
* @param target observation target
*/
export const targetIsRaDec = (
target: ObservationTargetProps
): target is ObservationRaDecTargetProps => "ra" in target;
/**
* Distinguish the observation target is identified by the star ID.
* @param target observation target
*/
export const targetIsStar = (
target: ObservationTargetProps
): target is ObservationStarTargetProps => "starNumber" in target;
/**
* Describes interactions by the user on the celestial canvas.
*/
export interface InteractionProps
extends Pick<CanvasProps, "onWheel" | "onTouchMove"> {
/**
* handle selection of the celestial entities.
* this event will occur by the clicking or tapping.
*/
onSelect?: (event: CelestialSelectEvent) => any;
/**
* handle move of the sight in the celestial canvas.
* this event will occur by the dragging or swiping.
*/
onMove?: (event: CelestialMoveEvent) => any;
/**
* handle zoom changes on the celestial canvas.
* this event will occur by moving wheels or pinching fingers.
*/
onZoom?: (event: CelestialZoomEvent) => any;
/**
* mouse button ids for handling click.
* @defaultvalue 1
*/
reactiveButtons?: number;
/**
* whether disable user-side pinch zoom on the celestial canvas.
* @defaultvalue true
*/
disableUserScale?: boolean;
}
/**
* Describes the selection of the celestial object.
*/
export interface CelestialSelectEvent {
/**
* right ascension of the selection point, in radian.
*/
ra: Radian;
/**
* declination of the selection point, in radian.
*/
dec: Radian;
/**
* nearest star of the selected position.
*/
star: (Star & { distance: number }) | null;
/**
* nearest named star of the selected position.
*/
namedStar: (Star & { distance: number }) | null;
/**
* nearest constellation of the selected position.
*/
constellation: { consKey: CONSTELLATION_KEY; distance: number } | null;
/**
* original event dispatched by the DOM element.
*/
originalEvent: MouseEvent | TouchEvent;
}
/**
* Describes the movement of the sight.
*/
export interface CelestialMoveEvent {
/**
* azimuthal difference.
*/
azimuth: Degree;
/**
* altitudal difference.
*/
altitude: Degree;
/**
* original event dispatched by the DOM element.
*/
originalEvent: MouseEvent | TouchEvent;
}
/**
* Describes the change of the zoom of the camera.
*/
export interface CelestialZoomEvent {
/**
* delta zoom factor.
*/
zoomDelta: number;
/**
* original event dispatched by the DOM element.
*/
originalEvent: MouseEvent | TouchEvent;
}