@openglobus/og 0.26.2 → 0.26.4

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,7 @@ 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
- type CameraEvents = ["viewchange", "moveend"];
13
+ export type CameraEvents = ["viewchange", "moveend"];
14
14
  export interface ICameraParams {
15
15
  eye?: Vec3;
16
16
  viewAngle?: number;
@@ -1,20 +1,34 @@
1
- import { Camera, type ICameraParams } from "./Camera";
1
+ import { Camera, CameraEvents, 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";
8
10
  export interface IPlanetCameraParams extends ICameraParams {
9
11
  minAltitude?: number;
10
12
  maxAltitude?: number;
11
13
  }
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;
12
21
  type CameraFrame = {
13
22
  eye: Vec3;
14
23
  n: Vec3;
15
24
  u: Vec3;
16
25
  v: Vec3;
17
26
  };
27
+ type CameraFlight = {
28
+ fly: (progress: number) => CameraFrame;
29
+ duration: number;
30
+ startedAt: number;
31
+ };
18
32
  /**
19
33
  * Planet camera.
20
34
  * @class
@@ -30,6 +44,11 @@ type CameraFrame = {
30
44
  * @param {Vec3} [options.eye] - Camera eye position. Default (0,0,0)
31
45
  * @param {Vec3} [options.look] - Camera look position. Default (0,0,0)
32
46
  * @param {Vec3} [options.up] - Camera eye position. Default (0,1,0)
47
+ * @fires og.Camera#viewchange
48
+ * @fires og.Camera#moveend
49
+ * @fires og.PlanetCamera#flystart
50
+ * @fires og.PlanetCamera#flyend
51
+ * @fires og.PlanetCamera#flystop
33
52
  */
34
53
  declare class PlanetCamera extends Camera {
35
54
  /**
@@ -38,6 +57,7 @@ declare class PlanetCamera extends Camera {
38
57
  * @type {Planet}
39
58
  */
40
59
  planet: Planet;
60
+ events: EventsHandler<PlanetCameraEventsList> & EventsHandler<CameraEvents>;
41
61
  /**
42
62
  * Minimal altitude that camera can reach over the terrain.
43
63
  * @public
@@ -82,9 +102,7 @@ declare class PlanetCamera extends Camera {
82
102
  _insideSegment: Segment | null;
83
103
  slope: number;
84
104
  protected _keyLock: Key;
85
- protected _framesArr: CameraFrame[];
86
- protected _framesCounter: number;
87
- protected _numFrames: number;
105
+ protected _flight: CameraFlight | null;
88
106
  protected _completeCallback: Function | null;
89
107
  protected _frameCallback: Function | null;
90
108
  protected _flying: boolean;
@@ -152,13 +170,15 @@ declare class PlanetCamera extends Camera {
152
170
  * @param {number} [height] - Destination height.
153
171
  * @param {Vec3} [up] - Camera UP in the end of flying. Default - (0,1,0)
154
172
  * @param {Number} [ampl] - Altitude amplitude factor.
173
+ * @param {Number} [duration] - Animation duration
174
+ * @param {EasingFunction} [ease] - Animation easing
155
175
  * @param {Function} [completeCallback] - Callback that calls after flying when flying is finished.
156
176
  * @param {Function} [startCallback] - Callback that calls before the flying begins.
157
177
  * @param {Function} [frameCallback] - Each frame callback
158
178
  */
159
- flyExtent(extent: Extent, height?: number | null, up?: Vec3 | null, ampl?: number | null, completeCallback?: Function | null, startCallback?: Function | null, frameCallback?: Function | null): void;
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;
160
180
  viewDistance(cartesian: Vec3, distance?: number): void;
161
- flyDistance(cartesian: Vec3, distance?: number, ampl?: number, completeCallback?: Function, startCallback?: Function, frameCallback?: Function): void;
181
+ flyDistance(cartesian: Vec3, distance?: number, ampl?: number, duration?: number, ease?: EasingFunction, completeCallback?: Function, startCallback?: Function, frameCallback?: Function): void;
162
182
  /**
163
183
  * Flies to the cartesian coordinates.
164
184
  * @public
@@ -166,11 +186,13 @@ declare class PlanetCamera extends Camera {
166
186
  * @param {Vec3} [look] - Camera LOOK in the end of flying. Default - (0,0,0)
167
187
  * @param {Vec3} [up] - Camera UP vector in the end of flying. Default - (0,1,0)
168
188
  * @param {Number} [ampl=1.0] - Altitude amplitude factor.
189
+ * @param {Number} [duration] - Animation duration
190
+ * @param {EasingFunction} [ease] - Animation easing
169
191
  * @param {Function} [completeCallback] - Callback that calls after flying when flying is finished.
170
192
  * @param {Function} [startCallback] - Callback that calls before the flying begins.
171
193
  * @param {Function} [frameCallback] - Each frame callback
172
194
  */
173
- flyCartesian(cartesian: Vec3, look?: Vec3 | LonLat | null, up?: Vec3 | null, ampl?: number, completeCallback?: Function | null, startCallback?: Function | null, frameCallback?: Function | null): void;
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;
174
196
  /**
175
197
  * Flies to the geo coordinates.
176
198
  * @public
@@ -178,11 +200,13 @@ declare class PlanetCamera extends Camera {
178
200
  * @param {Vec3 | LonLat} [look] - Camera LOOK in the end of flying. Default - (0,0,0)
179
201
  * @param {Vec3} [up] - Camera UP vector in the end of flying. Default - (0,1,0)
180
202
  * @param {number} [ampl] - Altitude amplitude factor.
203
+ * @param {Number} [duration] - Animation duration
204
+ * @param {EasingFunction} [ease] - Animation easing
181
205
  * @param {Function} [completeCallback] - Callback that calls after flying when flying is finished.
182
206
  * @param {Function} [startCallback] - Callback that calls befor the flying begins.
183
207
  * @param {Function} [frameCallback] - each frame callback
184
208
  */
185
- flyLonLat(lonlat: LonLat, look?: Vec3 | LonLat, up?: Vec3, ampl?: number, completeCallback?: Function, startCallback?: Function, frameCallbak?: Function): void;
209
+ flyLonLat(lonlat: LonLat, look?: Vec3 | LonLat, up?: Vec3, ampl?: number, duration?: number, ease?: EasingFunction, completeCallback?: Function, startCallback?: Function, frameCallback?: Function): void;
186
210
  /**
187
211
  * Breaks the flight.
188
212
  * @public
@@ -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,13 +75,15 @@ 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;
80
+ onadd(): void;
81
+ onremove(): void;
52
82
  onactivate(): void;
53
83
  ondeactivate(): void;
54
84
  protected onDraw(): void;
55
85
  _onShiftFree: () => void;
86
+ private _onCameraFly;
56
87
  protected _onMouseMove: (e: IMouseState) => void;
57
88
  protected _onMouseEnter: (e: IMouseState) => void;
58
89
  protected _onMouseLeave: () => void;
@@ -72,6 +103,7 @@ export declare class MouseNavigation extends Control {
72
103
  protected _updateVel_v(): void;
73
104
  protected _updateVel_roll(): void;
74
105
  protected get dt(): number;
106
+ protected get velocityInertia(): number;
75
107
  stop(): void;
76
108
  }
77
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;
@@ -41,6 +56,9 @@ export declare class TouchNavigation extends Control {
41
56
  protected _touching: boolean;
42
57
  constructor(options?: ITouchNavigationParams);
43
58
  oninit(): void;
59
+ onadd(): void;
60
+ onremove(): void;
61
+ private _onCameraFly;
44
62
  protected onTouchStart(e: ITouchState): void;
45
63
  protected _startTouchOne(e: ITouchState): void;
46
64
  stopRotation(): void;
@@ -1,8 +1,14 @@
1
1
  import { Control, type IControlParams } from "../Control";
2
2
  import { PolygonDrawingScene } from "./PolygonDrawingScene";
3
+ export interface IDrawingControlParams extends IControlParams {
4
+ cornerStyle?: any;
5
+ centerStyle?: any;
6
+ outlineStyle?: any;
7
+ fillStyle?: any;
8
+ }
3
9
  declare class DrawingControl extends Control {
4
10
  protected _drawingScene: PolygonDrawingScene;
5
- constructor(options?: IControlParams);
11
+ constructor(options?: IDrawingControlParams);
6
12
  activatePolygonDrawing(): void;
7
13
  activateLineStringDrawing(): void;
8
14
  oninit(): void;
@@ -1,8 +1,9 @@
1
1
  import { type EventsHandler } from '../../Events';
2
- import type { CoordinatesType } from "../../entity/Geometry";
2
+ import type { CoordinatesType, IGeometryStyle } from "../../entity/Geometry";
3
+ import type { IGeoObjectParams } from "../../entity/GeoObject";
4
+ import type { IPolylineParams } from "../../entity/Polyline";
3
5
  import { Entity } from '../../entity/Entity';
4
6
  import type { IMouseState } from "../../renderer/RendererEvents";
5
- import { Object3d } from '../../Object3d';
6
7
  import { Planet } from '../../scene/Planet';
7
8
  import { RenderNode } from '../../scene/RenderNode';
8
9
  import { Vec2 } from '../../math/Vec2';
@@ -11,35 +12,21 @@ import { Vector } from '../../layer/Vector';
11
12
  type PolygonDrawingSceneEventsList = ["change", "startpoint"];
12
13
  export interface IPolygonDrawingSceneParams {
13
14
  coordinates?: CoordinatesType[];
15
+ cornerStyle?: IGeoObjectParams;
16
+ centerStyle?: IGeoObjectParams;
17
+ outlineStyle?: IPolylineParams;
18
+ fillStyle?: IGeometryStyle;
14
19
  name: string;
15
20
  }
16
21
  export declare const NUM_SEGMENTS = 200;
17
22
  export declare const OUTLINE_ALT = 0.3;
18
- export declare const COORDINATES_COLOR = "rgb(350, 350, 0)";
19
- export declare const CENTER_COLOR = "rgb(0, 350, 50)";
20
- export declare const OUTLINE_COLOR = "rgb(0, 350, 50)";
21
- export declare const OUTLINE_THICKNESS = 3.5;
22
- export declare const CORNER_OPTIONS: {
23
- scale: number;
24
- instanced: boolean;
25
- tag: string;
26
- color: string;
27
- object3d: Object3d;
28
- };
29
- export declare const CENTER_OPTIONS: {
30
- scale: number;
31
- instanced: boolean;
32
- tag: string;
33
- color: string;
34
- object3d: Object3d;
35
- };
36
- export declare const OUTLINE_OPTIONS: {
37
- thickness: number;
38
- color: string;
39
- };
40
23
  declare class PolygonDrawingScene extends RenderNode {
41
24
  events: EventsHandler<PolygonDrawingSceneEventsList>;
42
25
  _planet: Planet | null;
26
+ _cornerStyle: IGeoObjectParams;
27
+ _centerStyle: IGeoObjectParams;
28
+ _outlineStyle: IPolylineParams;
29
+ _fillStyle: IGeometryStyle;
43
30
  protected _initCoordinates: CoordinatesType[];
44
31
  protected _pickedCorner: Entity | null;
45
32
  protected _pickedCenter: Entity | null;
@@ -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.
package/lib/index.d.ts CHANGED
@@ -33,4 +33,6 @@ export * from './layer/index';
33
33
  import { EmptyTerrain, GlobusTerrain, RgbTerrain, BilTerrain, GlobusRgbTerrain } from './terrain/index';
34
34
  import { MoveAxisEntity } from "./control/geoObjectEditor/MoveAxisEntity";
35
35
  import { Gltf } from './utils/gltf/gltfParser';
36
- export { bv, jd, math, mercator, utils, input, control, scene, quadTreeStrategyType, wgs84, moon, mars, terrain, layer, webgl, Framebuffer, EmptyTerrain, GlobusTerrain, RgbTerrain, GlobusRgbTerrain, BilTerrain, Control, Camera, Ellipsoid, Planet, PlanetCamera, LightSource, Program, Handler, Multisample, Renderer, Clock, Events, Extent, LonLat, RenderNode, Line2, Line3, Mat3, Mat4, Plane, Quat, Ray, Vec2, Vec3, Vec4, Geoid, Popup, QuadTreeStrategy, EquiQuadTreeStrategy, EarthQuadTreeStrategy, Wgs84QuadTreeStrategy, Object3d, Gltf, MoveAxisEntity, };
36
+ import { Easing } from './utils/easing';
37
+ import type { EasingFunction } from './utils/easing';
38
+ export { bv, jd, math, mercator, utils, input, control, scene, quadTreeStrategyType, wgs84, moon, mars, terrain, layer, webgl, Easing, EasingFunction, Framebuffer, EmptyTerrain, GlobusTerrain, RgbTerrain, GlobusRgbTerrain, BilTerrain, Control, Camera, Ellipsoid, Planet, PlanetCamera, LightSource, Program, Handler, Multisample, Renderer, Clock, Events, Extent, LonLat, RenderNode, Line2, Line3, Mat3, Mat4, Plane, Quat, Ray, Vec2, Vec3, Vec4, Geoid, Popup, QuadTreeStrategy, EquiQuadTreeStrategy, EarthQuadTreeStrategy, Wgs84QuadTreeStrategy, Object3d, Gltf, MoveAxisEntity, };