@openglobus/og 0.27.24 → 0.28.1

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
@@ -2,6 +2,7 @@ import { Control } from "./control/Control";
2
2
  import { Ellipsoid } from "./ellipsoid/Ellipsoid";
3
3
  import { EmptyTerrain } from "./terrain/EmptyTerrain";
4
4
  import { Layer } from "./layer/Layer";
5
+ import { Navigation } from "./control/Navigation";
5
6
  import type { NumberArray2 } from "./math/Vec2";
6
7
  import type { NumberArray4 } from "./math/Vec4";
7
8
  import { Planet } from "./scene/Planet";
@@ -40,6 +41,18 @@ export interface IGlobeParams {
40
41
  active?: boolean;
41
42
  stopped?: boolean;
42
43
  };
44
+ navigation?: {
45
+ active?: boolean;
46
+ inertia?: number;
47
+ dragInertia?: number;
48
+ minSlope?: number;
49
+ mass?: number;
50
+ zoomSpeed?: number;
51
+ mode?: "lockNorth" | "adaptive" | "free";
52
+ poleThreshold?: number;
53
+ disableRotation?: boolean;
54
+ disableTilt?: boolean;
55
+ };
43
56
  layers?: Layer[];
44
57
  viewExtent?: Extent | NumberArray4;
45
58
  autoActivate?: boolean;
@@ -67,7 +80,7 @@ export interface IGlobeParams {
67
80
  * target: 'globus',
68
81
  * name: 'Earth',
69
82
  * controls: [
70
- * new control.MouseNavigation(),
83
+ * new control.Navigation(),
71
84
  * new control.KeyboardNavigation(),
72
85
  * new control.EarthCoordinates(),
73
86
  * new control.LayerSwitcher({),
@@ -129,6 +142,7 @@ declare class Globe {
129
142
  protected _planetName: string;
130
143
  planet: Planet;
131
144
  sun: Sun;
145
+ navigation: Navigation;
132
146
  constructor(options: IGlobeParams);
133
147
  start(): void;
134
148
  /**
@@ -6,35 +6,41 @@ import { Sphere } from "../bv/Sphere";
6
6
  import { Vec2 } from "../math/Vec2";
7
7
  import { Vec3 } from "../math/Vec3";
8
8
  import { type EventsHandler } from "../Events";
9
- interface IMouseNavigationParams extends IControlParams {
10
- fixedUp?: boolean;
9
+ export type NavigationMode = "lockNorth" | "adaptive" | "free";
10
+ export interface INavigationParams extends IControlParams {
11
11
  inertia?: number;
12
12
  dragInertia?: number;
13
13
  minSlope?: number;
14
14
  mass?: number;
15
15
  zoomSpeed?: number;
16
+ mode?: NavigationMode;
17
+ poleThreshold?: number;
18
+ disableRotation?: boolean;
19
+ disableTilt?: boolean;
16
20
  }
17
- export type MouseNavigationEventsList = [
21
+ export type NavigationEventsList = [
18
22
  "drag",
19
23
  "zoom",
20
24
  "rotate"
21
25
  ];
22
26
  /**
23
- * Mouse navigation.
27
+ * Navigation.
24
28
  * @class
25
29
  * @extends {Control}
26
- * @param {IMouseNavigationParams} [options] - Mouse navigation options:
27
- * @param {boolean} [options.fixedUp] - fix up at north pole
30
+ * @param {INavigationParams} [options] - Navigation options:
31
+ * @param {NavigationMode} [options.mode] - Navigation mode: "lockNorth" (keeps north fixed), "adaptive" (default, auto-detects arc mode), "free" (arc rotation mode)
28
32
  * @param {number} [options.inertia] - inertia factor
29
33
  * @param {number} [options.dragInertia] - drag inertia
30
34
  * @param {number} [options.mass] - camera mass, affects velocity. Default is 1
31
35
  * @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
+ * @param {number} [options.poleThreshold] - Vertical rotation is reduced when camera is close to poles
37
+ * @param {boolean} [options.disableRotation] - Disables horizontal rotation controls (right mouse button and touchpad). Default is false
38
+ * @param {boolean} [options.disableTilt] - Disables vertical tilt controls (right mouse button and touchpad). Default is false
39
+ * @fires og.Navigation#drag
40
+ * @fires og.Navigation#zoom
41
+ * @fires og.Navigation#rotate
36
42
  */
37
- export declare class MouseNavigation extends Control {
43
+ export declare class Navigation extends Control {
38
44
  force: Vec3;
39
45
  force_h: number;
40
46
  force_v: number;
@@ -46,9 +52,14 @@ export declare class MouseNavigation extends Control {
46
52
  inertia: number;
47
53
  dragInertia: number;
48
54
  zoomSpeed: number;
55
+ poleThreshold: number;
56
+ mode: number;
57
+ disableRotation: boolean;
58
+ disableTilt: boolean;
49
59
  vel_roll: number;
50
60
  force_roll: number;
51
- events: EventsHandler<MouseNavigationEventsList>;
61
+ protected _freeMode: boolean;
62
+ events: EventsHandler<NavigationEventsList>;
52
63
  protected _lookPos: Vec3 | undefined;
53
64
  protected _grabbedPoint: Vec3 | null;
54
65
  protected _grabbedDist: number;
@@ -61,7 +72,6 @@ export declare class MouseNavigation extends Control {
61
72
  protected _tUp: Vec3;
62
73
  protected _tRad: number;
63
74
  protected _shiftBusy: boolean;
64
- protected fixedUp: boolean;
65
75
  protected _curPitch: number;
66
76
  protected _curYaw: number;
67
77
  protected _curRoll: number;
@@ -72,11 +82,9 @@ export declare class MouseNavigation extends Control {
72
82
  protected _isTouchPad: boolean;
73
83
  protected _velInertia: number;
74
84
  protected _hold: boolean;
75
- protected _prevVel: Vec3;
76
- protected _screenPosIsChanged: boolean;
77
85
  protected _rotHDir: number;
78
86
  protected _rotVDir: number;
79
- constructor(options?: IMouseNavigationParams);
87
+ constructor(options?: INavigationParams);
80
88
  oninit(): void;
81
89
  onadd(): void;
82
90
  onremove(): void;
@@ -96,6 +104,9 @@ export declare class MouseNavigation extends Control {
96
104
  protected _onLDown: (e: IMouseState) => void;
97
105
  protected _onLHold: (e: IMouseState) => void;
98
106
  protected _onLUp: (e: IMouseState) => void;
107
+ get freeMode(): boolean;
108
+ setMode(mode: NavigationMode): void;
109
+ protected _modeToNumber(mode: NavigationMode): number;
99
110
  protected _handleDrag(): void;
100
111
  protected _corrRoll(): void;
101
112
  protected _handleZoom(): void;
@@ -107,4 +118,3 @@ export declare class MouseNavigation extends Control {
107
118
  protected get velocityInertia(): number;
108
119
  stop(): void;
109
120
  }
110
- export {};
@@ -9,7 +9,7 @@ export * from "./LayerAnimation";
9
9
  export * from "./LayerSwitcher";
10
10
  export * from "./Lighting";
11
11
  export * from "./OldMouseNavigation";
12
- export * from "./MouseNavigation";
12
+ export * from "./Navigation";
13
13
  export * from "./RulerSwitcher";
14
14
  export * from "./ScaleControl";
15
15
  export * from "./ShowFps";
@@ -304,6 +304,11 @@ declare class EntityCollection {
304
304
  * @public
305
305
  */
306
306
  updateLabelsFontAtlas(): void;
307
+ /**
308
+ * Updates stroke texture atlas.
309
+ * @public
310
+ */
311
+ updateStrokeTextureAtlas(): void;
307
312
  /**
308
313
  * Removes collection from render node.
309
314
  * @public
@@ -10,6 +10,7 @@ import { RenderNode } from "../scene/RenderNode";
10
10
  import type { WebGLBufferExt } from "../webgl/Handler";
11
11
  import type { TypedArray } from "../utils/shared";
12
12
  import { Ellipsoid } from "../ellipsoid/Ellipsoid";
13
+ import type { HTMLImageElementExt } from "../utils/ImagesCacheManager";
13
14
  export type Geodetic = LonLat | NumberArray2 | NumberArray3;
14
15
  export type Cartesian = Vec3 | NumberArray3;
15
16
  export type SegmentPath3vExt = Cartesian[];
@@ -29,6 +30,10 @@ export interface IPolylineParams {
29
30
  pathLonLat?: SegmentPathLonLatExt[];
30
31
  visibleSpherePosition?: Cartesian;
31
32
  visibleSphereRadius?: number;
33
+ src?: string;
34
+ image?: HTMLImageElement;
35
+ texOffset?: number;
36
+ strokeSize?: number;
32
37
  }
33
38
  /**
34
39
  * Polyline object.
@@ -109,11 +114,14 @@ declare class Polyline {
109
114
  protected _orders: TypedArray | number[];
110
115
  protected _indexes: TypedArray | number[];
111
116
  protected _colors: TypedArray | number[];
117
+ protected _texCoordArr: TypedArray | number[];
118
+ protected _atlasTexCoords: number[];
112
119
  protected _verticesHighBuffer: WebGLBufferExt | null;
113
120
  protected _verticesLowBuffer: WebGLBufferExt | null;
114
121
  protected _ordersBuffer: WebGLBufferExt | null;
115
122
  protected _indexesBuffer: WebGLBufferExt | null;
116
123
  protected _colorsBuffer: WebGLBufferExt | null;
124
+ protected _texCoordBuffer: WebGLBufferExt | null;
117
125
  protected _pickingColor: NumberArray3;
118
126
  protected _renderNode: RenderNode | null;
119
127
  /**
@@ -133,7 +141,43 @@ declare class Polyline {
133
141
  protected _changedBuffers: boolean[];
134
142
  protected _visibleSphere: Float32Array;
135
143
  __doubleToTwoFloats: (pos: Vec3, highPos: Vec3, lowPos: Vec3) => void;
144
+ /**
145
+ * Stroke image src.
146
+ * @protected
147
+ * @type {string}
148
+ */
149
+ protected _src: string | null;
150
+ /**
151
+ * Stroke image object.
152
+ * @protected
153
+ * @type {Object}
154
+ */
155
+ protected _image: HTMLImageElement & {
156
+ __nodeIndex?: number;
157
+ } | null;
158
+ protected _texOffset: number;
159
+ protected _strokeSize: number;
136
160
  constructor(options?: IPolylineParams);
161
+ get texOffset(): number;
162
+ set texOffset(value: number);
163
+ get strokeSize(): number;
164
+ set strokeSize(value: number);
165
+ /**
166
+ * Sets image template url source.
167
+ * @public
168
+ * @param {string} src - Image url.
169
+ */
170
+ setSrc(src: string | null): void;
171
+ getSrc(): string | null;
172
+ /**
173
+ * Sets image template object.
174
+ * @public
175
+ * @param {Object} image - JavaScript image object.
176
+ */
177
+ setImage(image: HTMLImageElement): void;
178
+ getImage(): HTMLImageElementExt | null;
179
+ _setTexCoordArr(tcoordArr: number[]): void;
180
+ setTextureDisabled(): void;
137
181
  /**
138
182
  * Appends to the line array new cartesian coordinates line data.
139
183
  */
@@ -142,12 +186,25 @@ declare class Polyline {
142
186
  * Appends to the line new cartesian coordinates point data.
143
187
  */
144
188
  protected __appendPoint3v(path3v: SegmentPath3vExt[], point3v: Vec3, pathColors: SegmentPathColor[], color: NumberArray4, isClosed: boolean, outVerticesHigh: number[], outVerticesLow: number[], outColors: number[], outOrders: number[], outIndexes: number[], ellipsoid: Ellipsoid | null, outTransformedPathLonLat: SegmentPathLonLatExt[], outTransformedPathMerc: LonLat[][], outExtent: Extent): void;
189
+ /**
190
+
191
+ [1, -1, 2, -2] - orders for triangle strip line segment
192
+ t2 t3
193
+ (2)-------(-2)
194
+ | |
195
+ | |
196
+ | |
197
+ | |
198
+ (1)-------(-1)
199
+ t0 t1
200
+ */
201
+ static setPathTexCoords(path3v: SegmentPath3vExt[], tCoordArr: number[], outTexCoords: number[]): void;
145
202
  static setPathColors(pathLonLat: SegmentPathLonLatExt[], pathColors: SegmentPathColor[], defaultColor: NumberArray4, outColors: number[]): void;
146
203
  /**
147
204
  * Appends to the line array new geodetic coordinates line data.
148
205
  * @static
149
206
  */
150
- protected __appendLineDataLonLat(pathLonLat: SegmentPathLonLatExt[], pathColors: SegmentPathColor[], defaultColor: NumberArray4, isClosed: boolean, outVerticesHigh: number[], outVerticesLow: number[], outOrders: number[], outIndexes: number[], ellipsoid: Ellipsoid, outTransformedPathCartesian: SegmentPath3vExt[], outPathLonLat: SegmentPathLonLatExt[], outTransformedPathMerc: LonLat[][], outExtent: Extent, outColors: number[]): void;
207
+ protected __appendLineDataLonLat(pathLonLat: SegmentPathLonLatExt[], pathColors: SegmentPathColor[], defaultColor: NumberArray4, isClosed: boolean, outVerticesHigh: number[], outVerticesLow: number[], outOrders: number[], outIndexes: number[], outTexCoords: number[], ellipsoid: Ellipsoid, outTransformedPathCartesian: SegmentPath3vExt[], outPathLonLat: SegmentPathLonLatExt[], outTransformedPathMerc: LonLat[][], outExtent: Extent, outColors: number[]): void;
151
208
  /**
152
209
  * Sets polyline path with cartesian coordinates.
153
210
  * @protected
@@ -232,13 +289,12 @@ declare class Polyline {
232
289
  /**
233
290
  * Gets polyline opacity.
234
291
  * @public
235
- * @param {number} opacity - Opacity.
236
292
  */
237
293
  getOpacity(): number;
238
294
  /**
239
295
  * Sets Polyline thickness in screen pixels.
240
296
  * @public
241
- * @param {number} thickness - Thickness.
297
+ * @param {number} altitude - ALtitude value.
242
298
  */
243
299
  setAltitude(altitude: number): void;
244
300
  /**
@@ -305,7 +361,7 @@ declare class Polyline {
305
361
  setPathColors(pathColors: SegmentPathColor[]): void;
306
362
  /**
307
363
  * Sets polyline color
308
- * @param {string} htmlColor- HTML color
364
+ * @param {string} htmlColor - HTML color.
309
365
  */
310
366
  setColorHTML(htmlColor: string): void;
311
367
  setPathLonLatFast(pathLonLat: SegmentPathLonLatExt[], pathColors?: SegmentPathColor[]): void;
@@ -354,6 +410,7 @@ declare class Polyline {
354
410
  */
355
411
  protected _createIndexBuffer(): void;
356
412
  protected _createColorsBuffer(): void;
413
+ _createTexCoordBuffer(): void;
357
414
  setVisibleSphere(p: Vec3, r: number): void;
358
415
  updateRTCPosition(): void;
359
416
  }
@@ -25,5 +25,8 @@ declare class PolylineHandler {
25
25
  getRTCPosition(pos: Vec3, rtcPositionHigh: Vec3, rtcPositionLow: Vec3): void;
26
26
  setRelativeCenter(c: Vec3): void;
27
27
  protected _updateRTCEyePosition(): void;
28
+ reloadTextures(): void;
29
+ get polylines(): Polyline[];
30
+ refreshTexCoordsArr(): void;
28
31
  }
29
32
  export { PolylineHandler };
@@ -4,6 +4,7 @@ import type { NumberArray3 } from "../math/Vec3";
4
4
  import type { NumberArray4 } from "../math/Vec4";
5
5
  import { Entity } from "./Entity";
6
6
  import { RayHandler } from "./RayHandler";
7
+ import type { HTMLImageElementExt } from "../utils/ImagesCacheManager";
7
8
  export interface IRayParams {
8
9
  thickness?: number;
9
10
  startPosition?: Vec3 | NumberArray3;
@@ -11,6 +12,10 @@ export interface IRayParams {
11
12
  startColor?: string | NumberArray4;
12
13
  endColor?: string | NumberArray4;
13
14
  visibility?: boolean;
15
+ src?: string;
16
+ image?: HTMLImageElement;
17
+ texOffset?: number;
18
+ strokeSize?: number;
14
19
  }
15
20
  /**
16
21
  * Ray class.
@@ -63,6 +68,22 @@ declare class Ray {
63
68
  * @type {number}
64
69
  */
65
70
  _handlerIndex: number;
71
+ /**
72
+ * Stroke image src.
73
+ * @protected
74
+ * @type {string}
75
+ */
76
+ protected _src: string | null;
77
+ /**
78
+ * Stroke image object.
79
+ * @protected
80
+ * @type {Object}
81
+ */
82
+ protected _image: HTMLImageElement & {
83
+ __nodeIndex?: number;
84
+ } | null;
85
+ protected _texOffset: number;
86
+ protected _strokeSize: number;
66
87
  constructor(options?: IRayParams);
67
88
  /**
68
89
  * Sets ray start position.
@@ -73,6 +94,20 @@ declare class Ray {
73
94
  */
74
95
  setStartPosition(x: number, y: number, z: number): void;
75
96
  getLength(): number;
97
+ /**
98
+ * Sets image template url source.
99
+ * @public
100
+ * @param {string} src - Image url.
101
+ */
102
+ setSrc(src: string | null): void;
103
+ getSrc(): string | null;
104
+ /**
105
+ * Sets image template object.
106
+ * @public
107
+ * @param {Object} image - JavaScript image object.
108
+ */
109
+ setImage(image: HTMLImageElement): void;
110
+ getImage(): HTMLImageElementExt | null;
76
111
  /**
77
112
  * Sets ray start position.
78
113
  * @public
@@ -96,6 +131,10 @@ declare class Ray {
96
131
  setThickness(thickness: number): void;
97
132
  setColors4v(startColor?: Vec4, endColor?: Vec4): void;
98
133
  setColorsHTML(startColor?: string, endColor?: string): void;
134
+ get texOffset(): number;
135
+ set texOffset(value: number);
136
+ get strokeSize(): number;
137
+ set strokeSize(value: number);
99
138
  /**
100
139
  * Returns ray start position.
101
140
  * @public
@@ -14,7 +14,7 @@ declare class RayHandler {
14
14
  * @type {boolean}
15
15
  */
16
16
  pickingEnabled: boolean;
17
- protected _entityCollection: EntityCollection;
17
+ _entityCollection: EntityCollection;
18
18
  protected _renderer: Renderer | null;
19
19
  protected _rays: Ray[];
20
20
  protected _vertexBuffer: WebGLBufferExt | null;
@@ -25,6 +25,9 @@ declare class RayHandler {
25
25
  protected _thicknessBuffer: WebGLBufferExt | null;
26
26
  protected _rgbaBuffer: WebGLBufferExt | null;
27
27
  protected _pickingColorBuffer: WebGLBufferExt | null;
28
+ protected _texCoordBuffer: WebGLBufferExt | null;
29
+ protected _texOffsetBuffer: WebGLBufferExt | null;
30
+ protected _strokeSizeBuffer: WebGLBufferExt | null;
28
31
  protected _vertexArr: TypedArray | number[];
29
32
  protected _startPositionHighArr: TypedArray | number[];
30
33
  protected _startPositionLowArr: TypedArray | number[];
@@ -33,10 +36,15 @@ declare class RayHandler {
33
36
  protected _thicknessArr: TypedArray | number[];
34
37
  protected _rgbaArr: TypedArray | number[];
35
38
  protected _pickingColorArr: TypedArray | number[];
39
+ protected _texCoordArr: TypedArray;
40
+ protected _texOffsetArr: TypedArray;
41
+ protected _strokeSizeArr: TypedArray;
36
42
  protected _buffersUpdateCallbacks: Function[];
37
43
  protected _changedBuffers: boolean[];
38
44
  constructor(entityCollection: EntityCollection);
39
45
  static concArr(dest: number[], curr: number[]): void;
46
+ reloadTextures(): void;
47
+ get rays(): Ray[];
40
48
  initProgram(): void;
41
49
  setRenderer(renderer: Renderer): void;
42
50
  refresh(): void;
@@ -65,6 +73,14 @@ declare class RayHandler {
65
73
  createRgbaBuffer(): void;
66
74
  createThicknessBuffer(): void;
67
75
  createVertexBuffer(): void;
76
+ createTexCoordBuffer(): void;
77
+ createTexOffsetBuffer(): void;
78
+ createStrokeSizeBuffer(): void;
68
79
  createPickingColorBuffer(): void;
80
+ setTexCoordArr(index: number, tcoordArr: number[] | TypedArray): void;
81
+ setTextureDisabled(index: number): void;
82
+ setTexOffsetArr(index: number, value: number): void;
83
+ setStrokeSizeArr(index: number, value: number): void;
84
+ refreshTexCoordsArr(): void;
69
85
  }
70
86
  export { RayHandler };