@openglobus/og 1.0.0-rc22 → 1.0.0-rc23

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/lib/Globe.d.ts CHANGED
@@ -44,6 +44,7 @@ export interface IGlobeParams {
44
44
  active?: boolean;
45
45
  stopped?: boolean;
46
46
  localDateTime?: Date | null;
47
+ useTimeZones?: boolean;
47
48
  };
48
49
  navigation?: {
49
50
  active?: boolean;
@@ -4,42 +4,53 @@ import { Clock } from "../Clock";
4
4
  import type { JulianDate } from "../astro/jd";
5
5
  import { Vec3 } from "../math/Vec3";
6
6
  import type { PlanetCamera } from "../camera/PlanetCamera";
7
+ import type { LonLat } from "../LonLat";
7
8
  interface ISunParams extends IControlParams {
8
9
  activationHeight?: number;
9
10
  offsetVertical?: number;
10
11
  offsetHorizontal?: number;
11
12
  stopped?: boolean;
12
13
  localDateTime?: Date | null;
14
+ dateTime?: Date | null;
15
+ useTimeZones?: boolean;
13
16
  }
14
17
  /**
15
18
  * Real Sun geocentric position control that place the Sun on the right place by the Earth.
16
19
  * @class
17
20
  *
18
- * @example <caption>Lighting frozen at 21:30 local solar time under the camera</caption>
19
- * new Sun({ localDateTime: new Date(2026, 7, 3, 21, 30) })
21
+ * @example <caption>Lighting frozen at 21:30 on the local clock under the camera</caption>
22
+ * new Sun({ localDateTime: new Date(Date.UTC(2026, 7, 3, 21, 30)) })
20
23
  *
21
24
  * @param {ISunParams} [options] - Options:
22
25
  * @param {number} [options.activationHeight=12079000.0] - Camera height above which the Sun takes its real position by the clock.
23
26
  * @param {number} [options.offsetVertical=-5000000] - Vertical offset of the camera following light.
24
27
  * @param {number} [options.offsetHorizontal=5000000] - Horizontal offset of the camera following light.
25
28
  * @param {boolean} [options.stopped=false] - Stops the control, leaving the Sun on its real position by the clock.
26
- * @param {Date} [options.localDateTime] - Lights the scene by the local apparent solar time under the camera
27
- * instead of the camera following light. At 12:00 the Sun stands on the meridian there, while the date sets the
28
- * season. Read by its UTC clock, so it is not an instant in time but the numbers a wall clock shows: build it
29
- * with Date.UTC. While it is set it drives the light at any height, whether the control is stopped or not, and
30
- * the Clock is left untouched.
29
+ * @param {Date} [options.localDateTime] - Local clock time under the camera wall-clock numbers,
30
+ * not an instant: build it with Date.UTC. Civil time with useTimeZones, solar time otherwise.
31
+ * @param {Date} [options.dateTime] - Instant in time the Sun takes its real position at.
32
+ * @param {boolean} [options.useTimeZones=false] - Reads localDateTime by the time zone of the point.
33
+ * Leave off on bodies without civil time.
31
34
  */
32
35
  export declare class Sun extends Control {
33
36
  activationHeight: number;
34
37
  offsetVertical: number;
35
38
  offsetHorizontal: number;
36
39
  /**
37
- * Local apparent solar time under the camera, read by its UTC clock,
40
+ * Local clock time under the camera, read by its UTC clock,
38
41
  * or null for the camera following light.
39
42
  * @public
40
43
  * @type {Date | null}
41
44
  */
42
45
  localDateTime: Date | null;
46
+ /**
47
+ * Instant in time the Sun takes its real position at,
48
+ * or null for the camera following light.
49
+ * @public
50
+ * @type {Date | null}
51
+ */
52
+ dateTime: Date | null;
53
+ protected _useTimeZones: boolean;
43
54
  protected _currDate: number;
44
55
  protected _prevDate: number;
45
56
  protected _redrawDate: number;
@@ -49,6 +60,9 @@ export declare class Sun extends Control {
49
60
  protected _f: number;
50
61
  protected _k: number;
51
62
  protected _sunlightPosition: Vec3;
63
+ protected _localLon: number;
64
+ protected _localLat: number;
65
+ protected _localJd: number;
52
66
  constructor(options?: ISunParams);
53
67
  oninit(): void;
54
68
  protected _onClockTick: () => void;
@@ -58,11 +72,24 @@ export declare class Sun extends Control {
58
72
  bindClock(clock: Clock): void;
59
73
  getPosition(): Vec3;
60
74
  /**
61
- * Sets the local apparent solar time under the camera, read by its UTC clock.
75
+ * Reads localDateTime by the time zone of the point instead of the solar clock.
76
+ * @public
77
+ * @type {boolean}
78
+ */
79
+ get useTimeZones(): boolean;
80
+ set useTimeZones(useTimeZones: boolean);
81
+ /**
82
+ * Sets the local clock time under the camera, read by its UTC clock.
62
83
  * @public
63
84
  * @param {Date | null} localDateTime - Local date and time, or null to restore the camera following light.
64
85
  */
65
86
  setLocalDateTime(localDateTime: Date | null): void;
87
+ /**
88
+ * Sets the instant in time the Sun takes its real position at.
89
+ * @public
90
+ * @param {Date | null} dateTime - Instant in time, or null to restore the camera following light.
91
+ */
92
+ setDateTime(dateTime: Date | null): void;
66
93
  protected _setSunPosition3v(position: Vec3): void;
67
94
  /**
68
95
  * Returns a light position offset from the camera along its own up and right axes,
@@ -82,9 +109,11 @@ export declare class Sun extends Control {
82
109
  * @param {number} lon - Longitude under the camera, degrees.
83
110
  * @returns {JulianDate} -
84
111
  */
85
- protected _getLocalJulian(utc: JulianDate, lon: number): JulianDate;
112
+ protected _getSolarJulian(utc: JulianDate, lon: number): JulianDate;
113
+ protected _localDateTimeToUtc(lonLat: LonLat): Date | null;
86
114
  /**
87
- * Returns the Sun position for localDateTime at the location under the camera.
115
+ * Returns the Sun position for localDateTime at the location under the camera:
116
+ * the real position at the civil instant with useTimeZones, the solar reading otherwise.
88
117
  * @protected
89
118
  * @param {PlanetCamera} cam - Planet camera.
90
119
  * @returns {Vec3} -
@@ -17,15 +17,16 @@ type TimelineControlEventsList = [
17
17
  "stopdrag",
18
18
  "startdragcurrent",
19
19
  "stopdragcurrent",
20
- "localtime",
21
- "suntime",
22
- "sundate"
20
+ "changetimelinetime",
21
+ "changelocaltime",
22
+ "changelocaldatetime"
23
23
  ];
24
24
  interface ITimelineControlParams extends IControlParams {
25
25
  name?: string;
26
26
  current?: Date;
27
27
  rangeStart?: Date;
28
28
  rangeEnd?: Date;
29
+ use24HourClock?: boolean;
29
30
  }
30
31
  declare class TimelineControl extends Control {
31
32
  protected _timelineView: TimelineView;
@@ -40,8 +41,17 @@ declare class TimelineControl extends Control {
40
41
  */
41
42
  get model(): TimelineModel;
42
43
  /** Date the Sun marker stands on. Setting it moves the marker without dispatching. */
43
- get sunDate(): Date;
44
- set sunDate(date: Date);
44
+ get localDateTime(): Date;
45
+ set localDateTime(date: Date);
46
+ /** Scale time notation: 24-hour, or 12-hour with am/pm. */
47
+ get use24HourClock(): boolean;
48
+ set use24HourClock(use24HourClock: boolean);
49
+ /** True while the timeline current lights the scene. Setting it also moves the toggle. */
50
+ get timelineTime(): boolean;
51
+ set timelineTime(isActive: boolean);
52
+ protected _applyTimelineTime(isActive: boolean): void;
53
+ /** Lights the scene by the Sun marker, the civil clock time under the camera. */
54
+ applyLocalDateTime(): void;
45
55
  /**
46
56
  * Adds a colored time interval drawn on the scale, e.g. one per telemetry track.
47
57
  * Spans that overlap in time are placed on separate rows automatically, and the
@@ -12,6 +12,7 @@ interface ITimelineViewParams extends IViewParams {
12
12
  minDate?: Date;
13
13
  maxDate?: Date;
14
14
  fillStyle?: string;
15
+ use24HourClock?: boolean;
15
16
  }
16
17
  declare const TOUCH_MODE_NONE = 0;
17
18
  declare const TOUCH_MODE_CURRENT = 1;
@@ -29,9 +30,9 @@ type TimelineViewEventsList = [
29
30
  "playback",
30
31
  "pause",
31
32
  "visibility",
32
- "localtime",
33
- "suntime",
34
- "sundate"
33
+ "changetimelinetime",
34
+ "changelocaltime",
35
+ "changelocaldatetime"
35
36
  ];
36
37
  type TimelineTouchMode = typeof TOUCH_MODE_NONE | typeof TOUCH_MODE_CURRENT | typeof TOUCH_MODE_PINCH | typeof TOUCH_MODE_SCALE | typeof TOUCH_MODE_SUN;
37
38
  interface ITimelineTouchPointer {
@@ -57,8 +58,9 @@ declare class TimelineView extends View<TimelineModel> {
57
58
  protected _isCurrentMouseOver: boolean;
58
59
  protected _isSunDragging: boolean;
59
60
  protected _isSunMouseOver: boolean;
60
- protected _sunDate: Date;
61
- protected _sunTime: boolean;
61
+ protected _localDateTime: Date;
62
+ protected _useLocalDateTime: boolean;
63
+ protected _use24HourClock: boolean;
62
64
  protected _minWidth: number;
63
65
  protected _canvasScale: number;
64
66
  protected _millisecondsInPixel: number;
@@ -66,7 +68,7 @@ declare class TimelineView extends View<TimelineModel> {
66
68
  protected _clickRangeStart: Date;
67
69
  protected _clickRangeEnd: Date;
68
70
  protected _clickCurrentDate: Date;
69
- protected _clickSunDate: Date;
71
+ protected _clickLocalDateTime: Date;
70
72
  protected _clickTime: number;
71
73
  protected _clickDelay: number;
72
74
  protected _clickMoveTolerance: number;
@@ -83,8 +85,8 @@ declare class TimelineView extends View<TimelineModel> {
83
85
  protected _playBackBtn: ToggleButton;
84
86
  protected _multiplierEl: HTMLSelectElement | null;
85
87
  protected _buttons: ButtonGroup;
88
+ protected _timelineTimeBtn: ToggleButton;
86
89
  protected _localTimeBtn: ToggleButton;
87
- protected _sunTimeBtn: ToggleButton;
88
90
  protected _visibility: boolean;
89
91
  constructor(options?: ITimelineViewParams);
90
92
  protected _onResizeObserver(): void;
@@ -98,22 +100,25 @@ declare class TimelineView extends View<TimelineModel> {
98
100
  * @public
99
101
  * @type {boolean}
100
102
  */
101
- get localTime(): boolean;
102
- set localTime(localTime: boolean);
103
+ get timelineTime(): boolean;
104
+ set timelineTime(timelineTime: boolean);
103
105
  /**
104
106
  * True while the Sun is set from its own marker instead of the timeline.
105
107
  * @public
106
108
  * @type {boolean}
107
109
  */
108
- get sunTime(): boolean;
109
- set sunTime(sunTime: boolean);
110
+ get use24HourClock(): boolean;
111
+ set use24HourClock(use24HourClock: boolean);
112
+ protected _notchColor(time: number): string;
113
+ get localTime(): boolean;
114
+ set localTime(localTime: boolean);
110
115
  /**
111
116
  * Date the Sun marker stands on.
112
117
  * @public
113
118
  * @type {Date}
114
119
  */
115
- get sunDate(): Date;
116
- set sunDate(date: Date);
120
+ get localDateTime(): Date;
121
+ set localDateTime(date: Date);
117
122
  setVisibility(visibility: boolean): void;
118
123
  protected _createMultiplier(): HTMLSelectElement;
119
124
  protected _syncMultiplier(): void;
@@ -1,7 +1,7 @@
1
1
  type BaselineType = "alphabetic" | "bottom" | "hanging" | "ideographic" | "middle" | "top";
2
2
  type AlignType = "center" | "end" | "left" | "right" | "start";
3
3
  export declare function addSeconds(date: Date, seconds: number): Date;
4
- export declare function dateToStr(date: Date, showTime?: boolean, showMilliseconds?: boolean): string;
4
+ export declare function dateToStr(date: Date, showTime?: boolean, showMilliseconds?: boolean, use24HourClock?: boolean): string;
5
5
  export declare function createCanvasHTML(): HTMLCanvasElement;
6
6
  export declare function getNearestTimeLeft(t: number, div: number): number;
7
7
  export declare function drawNotch(ctx: CanvasRenderingContext2D, xOffset?: number, size?: number, thickness?: number, color?: string): void;