@openglobus/og 0.26.3 → 0.26.5

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.
@@ -10,7 +10,9 @@ import type { NumberArray2 } from "../math/Vec2";
10
10
  import { Vec3 } from "../math/Vec3";
11
11
  import { Sphere } from "../bv/Sphere";
12
12
  import { Quat } from "../math/Quat";
13
- export type CameraEvents = ["viewchange", "moveend"];
13
+ import { EasingFunction } from "../utils/easing";
14
+ import { LonLat } from "../LonLat";
15
+ export type CameraEvents = ["viewchange", "moveend", "flystart", "flyend", "flystop"];
14
16
  export interface ICameraParams {
15
17
  eye?: Vec3;
16
18
  viewAngle?: number;
@@ -20,6 +22,30 @@ export interface ICameraParams {
20
22
  width?: number;
21
23
  height?: number;
22
24
  }
25
+ export interface IFlyCartesianParams extends IFlyBaseParams {
26
+ look?: Vec3 | LonLat;
27
+ up?: Vec3;
28
+ }
29
+ export interface IFlyBaseParams {
30
+ duration?: number;
31
+ ease?: EasingFunction;
32
+ completeCallback?: Function;
33
+ startCallback?: Function;
34
+ frameCallback?: Function;
35
+ }
36
+ export declare const DEFAULT_FLIGHT_DURATION = 800;
37
+ export declare const DEFAULT_EASING: EasingFunction;
38
+ type CameraFrame = {
39
+ eye: Vec3;
40
+ n: Vec3;
41
+ u: Vec3;
42
+ v: Vec3;
43
+ };
44
+ type CameraFlight = {
45
+ fly: (progress: number) => CameraFrame;
46
+ duration: number;
47
+ startedAt: number;
48
+ };
23
49
  /**
24
50
  * Camera class.
25
51
  * @class
@@ -123,8 +149,35 @@ declare class Camera {
123
149
  isFirstPass: boolean;
124
150
  _width: number;
125
151
  _height: number;
152
+ protected _flight: CameraFlight | null;
153
+ protected _completeCallback: Function | null;
154
+ protected _frameCallback: Function | null;
155
+ protected _flying: boolean;
126
156
  constructor(options?: ICameraParams);
127
157
  get id(): number;
158
+ /**
159
+ * Flies to the cartesian coordinates.
160
+ * @public
161
+ * @param {Vec3} [cartesian] - Finish cartesian coordinates.
162
+ * @param {IFlyCartesianParams} [params] - Flight parameters
163
+ */
164
+ flyCartesian(cartesian: Vec3, params?: IFlyCartesianParams): void;
165
+ /**
166
+ * Breaks the flight.
167
+ * @public
168
+ */
169
+ stopFlying(): void;
170
+ /**
171
+ * Prepare camera to the frame. Used in render node frame function.
172
+ * @public
173
+ */
174
+ checkFly(): void;
175
+ /**
176
+ * Returns camera is flying.
177
+ * @public
178
+ * @returns {boolean}
179
+ */
180
+ isFlying(): boolean;
128
181
  checkMoveEnd(): void;
129
182
  bindFrustumsPickingColors(renderer: Renderer): void;
130
183
  /**
@@ -1,34 +1,20 @@
1
- import { Camera, CameraEvents, type ICameraParams } from "./Camera";
1
+ import { Camera, type IFlyCartesianParams, type ICameraParams } from "./Camera";
2
2
  import { Key } from "../Lock";
3
3
  import { LonLat } from "../LonLat";
4
4
  import { Planet } from "../scene/Planet";
5
5
  import { Vec3 } from "../math/Vec3";
6
6
  import { Extent } from "../Extent";
7
7
  import { Segment } from "../segment/Segment";
8
- import { EventsHandler } from "../Events";
9
- import { EasingFunction } from "../utils/easing";
10
8
  export interface IPlanetCameraParams extends ICameraParams {
11
9
  minAltitude?: number;
12
10
  maxAltitude?: number;
13
11
  }
14
- export type PlanetCameraEventsList = [
15
- "flystart",
16
- "flyend",
17
- "flystop"
18
- ];
19
- export declare const DEFAULT_FLIGHT_DURATION = 800;
20
- export declare const DEFAULT_EASING: EasingFunction;
21
- type CameraFrame = {
22
- eye: Vec3;
23
- n: Vec3;
24
- u: Vec3;
25
- v: Vec3;
26
- };
27
- type CameraFlight = {
28
- fly: (progress: number) => CameraFrame;
29
- duration: number;
30
- startedAt: number;
31
- };
12
+ export interface IPlanetFlyCartesianParams extends IFlyCartesianParams {
13
+ amplitude?: number;
14
+ }
15
+ export interface IPlanetFlyDistanceParams extends IPlanetFlyCartesianParams {
16
+ distance?: number;
17
+ }
32
18
  /**
33
19
  * Planet camera.
34
20
  * @class
@@ -46,9 +32,9 @@ type CameraFlight = {
46
32
  * @param {Vec3} [options.up] - Camera eye position. Default (0,1,0)
47
33
  * @fires og.Camera#viewchange
48
34
  * @fires og.Camera#moveend
49
- * @fires og.PlanetCamera#flystart
50
- * @fires og.PlanetCamera#flyend
51
- * @fires og.PlanetCamera#flystop
35
+ * @fires og.Camera#flystart
36
+ * @fires og.Camera#flyend
37
+ * @fires og.Camera#flystop
52
38
  */
53
39
  declare class PlanetCamera extends Camera {
54
40
  /**
@@ -57,7 +43,6 @@ declare class PlanetCamera extends Camera {
57
43
  * @type {Planet}
58
44
  */
59
45
  planet: Planet;
60
- events: EventsHandler<PlanetCameraEventsList> & EventsHandler<CameraEvents>;
61
46
  /**
62
47
  * Minimal altitude that camera can reach over the terrain.
63
48
  * @public
@@ -102,10 +87,6 @@ declare class PlanetCamera extends Camera {
102
87
  _insideSegment: Segment | null;
103
88
  slope: number;
104
89
  protected _keyLock: Key;
105
- protected _flight: CameraFlight | null;
106
- protected _completeCallback: Function | null;
107
- protected _frameCallback: Function | null;
108
- protected _flying: boolean;
109
90
  protected _checkTerrainCollision: boolean;
110
91
  eyeNorm: Vec3;
111
92
  constructor(planet: Planet, options?: IPlanetCameraParams);
@@ -168,56 +149,20 @@ declare class PlanetCamera extends Camera {
168
149
  * @public
169
150
  * @param {Extent} extent - Current extent.
170
151
  * @param {number} [height] - Destination height.
171
- * @param {Vec3} [up] - Camera UP in the end of flying. Default - (0,1,0)
172
- * @param {Number} [ampl] - Altitude amplitude factor.
173
- * @param {Number} [duration] - Animation duration
174
- * @param {EasingFunction} [ease] - Animation easing
175
- * @param {Function} [completeCallback] - Callback that calls after flying when flying is finished.
176
- * @param {Function} [startCallback] - Callback that calls before the flying begins.
177
- * @param {Function} [frameCallback] - Each frame callback
152
+ * @param {IPlanetFlyCartesianParams} [params] - Flight parameters
178
153
  */
179
- flyExtent(extent: Extent, height?: number | null, up?: Vec3 | null, ampl?: number | null, duration?: number, ease?: EasingFunction, completeCallback?: Function | null, startCallback?: Function | null, frameCallback?: Function | null): void;
154
+ flyExtent(extent: Extent, height?: number | null, params?: IPlanetFlyCartesianParams): void;
180
155
  viewDistance(cartesian: Vec3, distance?: number): void;
181
- flyDistance(cartesian: Vec3, distance?: number, ampl?: number, duration?: number, ease?: EasingFunction, completeCallback?: Function, startCallback?: Function, frameCallback?: Function): void;
182
- /**
183
- * Flies to the cartesian coordinates.
184
- * @public
185
- * @param {Vec3} cartesian - Finish cartesian coordinates.
186
- * @param {Vec3} [look] - Camera LOOK in the end of flying. Default - (0,0,0)
187
- * @param {Vec3} [up] - Camera UP vector in the end of flying. Default - (0,1,0)
188
- * @param {Number} [ampl=1.0] - Altitude amplitude factor.
189
- * @param {Number} [duration] - Animation duration
190
- * @param {EasingFunction} [ease] - Animation easing
191
- * @param {Function} [completeCallback] - Callback that calls after flying when flying is finished.
192
- * @param {Function} [startCallback] - Callback that calls before the flying begins.
193
- * @param {Function} [frameCallback] - Each frame callback
194
- */
195
- flyCartesian(cartesian: Vec3, look?: Vec3 | LonLat | null, up?: Vec3 | null, ampl?: number, duration?: number, ease?: EasingFunction, completeCallback?: Function | null, startCallback?: Function | null, frameCallback?: Function | null): void;
196
156
  /**
197
157
  * Flies to the geo coordinates.
198
158
  * @public
199
159
  * @param {LonLat} lonlat - Finish coordinates.
200
- * @param {Vec3 | LonLat} [look] - Camera LOOK in the end of flying. Default - (0,0,0)
201
- * @param {Vec3} [up] - Camera UP vector in the end of flying. Default - (0,1,0)
202
- * @param {number} [ampl] - Altitude amplitude factor.
203
- * @param {Number} [duration] - Animation duration
204
- * @param {EasingFunction} [ease] - Animation easing
205
- * @param {Function} [completeCallback] - Callback that calls after flying when flying is finished.
206
- * @param {Function} [startCallback] - Callback that calls befor the flying begins.
207
- * @param {Function} [frameCallback] - each frame callback
208
- */
209
- flyLonLat(lonlat: LonLat, look?: Vec3 | LonLat, up?: Vec3, ampl?: number, duration?: number, ease?: EasingFunction, completeCallback?: Function, startCallback?: Function, frameCallback?: Function): void;
210
- /**
211
- * Breaks the flight.
212
- * @public
160
+ * @param {IPlanetFlyCartesianParams} [params] - Flight parameters
213
161
  */
162
+ flyLonLat(lonlat: LonLat, params?: IPlanetFlyCartesianParams): void;
163
+ flyDistance(cartesian: Vec3, distance?: number, params?: IPlanetFlyCartesianParams): void;
164
+ flyCartesian(cartesian: Vec3, params?: IPlanetFlyCartesianParams): void;
214
165
  stopFlying(): void;
215
- /**
216
- * Returns camera is flying.
217
- * @public
218
- * @returns {boolean}
219
- */
220
- isFlying(): boolean;
221
166
  /**
222
167
  * Rotates around planet to the left.
223
168
  * @public
@@ -245,11 +190,6 @@ declare class PlanetCamera extends Camera {
245
190
  */
246
191
  rotateDown(angle: number): void;
247
192
  rotateVertical(angle: number, center: Vec3, minSlope?: number): void;
248
- /**
249
- * Prepare camera to the frame. Used in render node frame function.
250
- * @public
251
- */
252
- checkFly(): void;
253
193
  checkTerrainCollision(): Vec3 | undefined;
254
194
  getSurfaceVisibleDistance(d: number): number;
255
195
  /**
@@ -5,12 +5,36 @@ import { Quat } from "../math/Quat";
5
5
  import { Sphere } from "../bv/Sphere";
6
6
  import { Vec2 } from "../math/Vec2";
7
7
  import { Vec3 } from "../math/Vec3";
8
- interface IEarthNavigationParams extends IControlParams {
9
- speed?: number;
8
+ import { type EventsHandler } from "../Events";
9
+ interface IMouseNavigationParams extends IControlParams {
10
10
  fixedUp?: boolean;
11
+ inertia?: number;
12
+ dragInertia?: number;
13
+ minSlope?: number;
14
+ mass?: number;
15
+ zoomSpeed?: number;
11
16
  }
17
+ export type MouseNavigationEventsList = [
18
+ "drag",
19
+ "zoom",
20
+ "rotate"
21
+ ];
22
+ /**
23
+ * Mouse navigation.
24
+ * @class
25
+ * @extends {Control}
26
+ * @param {IMouseNavigationParams} [options] - Mouse navigation options:
27
+ * @param {boolean} [options.fixedUp] - fix up at north pole
28
+ * @param {number} [options.inertia] - inertia factor
29
+ * @param {number} [options.dragInertia] - drag inertia
30
+ * @param {number} [options.mass] - camera mass, affects velocity. Default is 1
31
+ * @param {number} [options.minSlope] - minimal slope for vertical camera movement. Default is 0.35
32
+ * @param {number} [options.zoomSpeed] - zoom speed factor. Default is 1
33
+ * @fires og.MouseNavigation#drag
34
+ * @fires og.MouseNavigation#zoom
35
+ * @fires og.MouseNavigation#rotate
36
+ */
12
37
  export declare class MouseNavigation extends Control {
13
- speed: number;
14
38
  force: Vec3;
15
39
  force_h: number;
16
40
  force_v: number;
@@ -18,8 +42,13 @@ export declare class MouseNavigation extends Control {
18
42
  vel_h: number;
19
43
  vel_v: number;
20
44
  mass: number;
45
+ minSlope: number;
46
+ inertia: number;
47
+ dragInertia: number;
48
+ zoomSpeed: number;
21
49
  vel_roll: number;
22
50
  force_roll: number;
51
+ events: EventsHandler<MouseNavigationEventsList>;
23
52
  protected _lookPos: Vec3 | undefined;
24
53
  protected _grabbedPoint: Vec3 | null;
25
54
  protected _targetZoomPoint: Vec3 | null;
@@ -46,8 +75,7 @@ export declare class MouseNavigation extends Control {
46
75
  protected _screenPosIsChanged: boolean;
47
76
  protected _rotHDir: number;
48
77
  protected _rotVDir: number;
49
- protected _dragInertia: number;
50
- constructor(options?: IEarthNavigationParams);
78
+ constructor(options?: IMouseNavigationParams);
51
79
  oninit(): void;
52
80
  onadd(): void;
53
81
  onremove(): void;
@@ -75,6 +103,7 @@ export declare class MouseNavigation extends Control {
75
103
  protected _updateVel_v(): void;
76
104
  protected _updateVel_roll(): void;
77
105
  protected get dt(): number;
106
+ protected get velocityInertia(): number;
78
107
  stop(): void;
79
108
  }
80
109
  export {};
@@ -6,8 +6,15 @@ import { Sphere } from "../bv/Sphere";
6
6
  import { Vec2 } from "../math/Vec2";
7
7
  import { Vec3 } from "../math/Vec3";
8
8
  import type { ITouchState } from "../renderer/RendererEvents";
9
+ import { EventsHandler } from "../Events";
9
10
  interface ITouchNavigationParams extends IControlParams {
11
+ inertia?: number;
10
12
  }
13
+ export type TouchNavigationEventsList = [
14
+ "inertiamove",
15
+ "drag",
16
+ "doubletapzoom"
17
+ ];
11
18
  declare class TouchExt {
12
19
  x: number;
13
20
  y: number;
@@ -25,10 +32,18 @@ declare class TouchExt {
25
32
  }
26
33
  /**
27
34
  * Touch pad planet camera dragging control.
35
+ * @class
36
+ * @extends {Control}
37
+ * @param {ITouchNavigationParams} [options] - Mouse navigation options:
38
+ * @param {number} [options.inertia] - inertia factor. Default is 0.007
39
+ * @fires og.TouchNavigation#inertiamove
40
+ * @fires og.TouchNavigation#drag
41
+ * @fires og.TouchNavigation#doubletapzoom
28
42
  */
29
43
  export declare class TouchNavigation extends Control {
30
44
  grabbedPoint: Vec3;
31
45
  inertia: number;
46
+ events: EventsHandler<TouchNavigationEventsList>;
32
47
  protected grabbedSpheroid: Sphere;
33
48
  protected qRot: Quat;
34
49
  protected scaleRot: number;
@@ -264,6 +264,7 @@ declare class Entity {
264
264
  protected _qFrame: Quat;
265
265
  protected _qRot: Quat;
266
266
  _absoluteQRot: Quat;
267
+ protected _useDirectQuaternion: boolean;
267
268
  constructor(options?: IEntityParams);
268
269
  get isEmpty(): boolean;
269
270
  /**
@@ -401,6 +402,13 @@ declare class Entity {
401
402
  * @param {Quat} rot - The new rotation quaternion.
402
403
  */
403
404
  setRotation(rot: Quat): void;
405
+ /**
406
+ * Sets rotation directly from glTF quaternion with common coordinate system conversion.
407
+ * This method avoids current pitch/yaw/roll airplane like conversion.
408
+ * @public
409
+ * @param {Quat} rot - Quaternion from glTF
410
+ */
411
+ setDirectQuaternionRotation(rot: Quat): void;
404
412
  /**
405
413
  * Sets the pitch rotation of the entity.
406
414
  * @param {number} val - The new pitch angle in radians.