@openglobus/og 0.18.3 → 0.18.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.
Files changed (44) hide show
  1. package/README.md +8 -5
  2. package/css/og.css +251 -3
  3. package/lib/@openglobus/og.css +1 -1
  4. package/lib/@openglobus/og.esm.js +1 -1
  5. package/lib/@openglobus/og.esm.js.map +1 -1
  6. package/lib/@openglobus/og.umd.js +1 -1
  7. package/lib/@openglobus/og.umd.js.map +1 -1
  8. package/lib/js/camera/PlanetCamera.d.ts +2 -2
  9. package/lib/js/camera/PlanetCamera.js +3 -2
  10. package/lib/js/control/Atmosphere.js +7 -10
  11. package/lib/js/control/EarthCoordinates.js +2 -2
  12. package/lib/js/control/elevationProfile/ElevationProfile.d.ts +41 -25
  13. package/lib/js/control/elevationProfile/ElevationProfile.js +103 -74
  14. package/lib/js/control/elevationProfile/ElevationProfileButtonsView.d.ts +14 -0
  15. package/lib/js/control/elevationProfile/ElevationProfileButtonsView.js +61 -0
  16. package/lib/js/control/elevationProfile/ElevationProfileControl.d.ts +33 -0
  17. package/lib/js/control/elevationProfile/ElevationProfileControl.js +153 -0
  18. package/lib/js/control/elevationProfile/ElevationProfileLegend.d.ts +20 -0
  19. package/lib/js/control/elevationProfile/ElevationProfileLegend.js +82 -0
  20. package/lib/js/control/elevationProfile/ElevationProfileScene.d.ts +80 -0
  21. package/lib/js/control/elevationProfile/ElevationProfileScene.js +539 -0
  22. package/lib/js/control/elevationProfile/ElevationProfileView.d.ts +63 -0
  23. package/lib/js/control/elevationProfile/ElevationProfileView.js +504 -0
  24. package/lib/js/control/elevationProfile/PointListDialog.d.ts +12 -0
  25. package/lib/js/control/elevationProfile/PointListDialog.js +57 -0
  26. package/lib/js/control/index.d.ts +2 -1
  27. package/lib/js/control/index.js +2 -1
  28. package/lib/js/entity/Polyline.js +1 -1
  29. package/lib/js/layer/GeoImage.js +3 -0
  30. package/lib/js/renderer/Renderer.d.ts +0 -1
  31. package/lib/js/renderer/Renderer.js +3 -28
  32. package/lib/js/renderer/RendererEvents.js +0 -7
  33. package/lib/js/scene/Planet.d.ts +4 -0
  34. package/lib/js/scene/Planet.js +9 -1
  35. package/lib/js/terrain/GlobusTerrain.d.ts +3 -0
  36. package/lib/js/terrain/GlobusTerrain.js +14 -2
  37. package/lib/js/terrain/MapboxTerrain.js +29 -29
  38. package/lib/js/ui/Dialog.js +1 -1
  39. package/lib/js/utils/TerrainWorker.js +1 -1
  40. package/lib/js/utils/shared.d.ts +2 -1
  41. package/lib/js/utils/shared.js +21 -3
  42. package/package.json +1 -1
  43. package/lib/js/shaders/pickingMask.d.ts +0 -2
  44. package/lib/js/shaders/pickingMask.js +0 -22
@@ -7,7 +7,6 @@ import { FontAtlas } from "../utils/FontAtlas";
7
7
  import { input } from "../input/input";
8
8
  import { isEmpty } from "../utils/shared";
9
9
  import { LabelWorker } from "../entity/LabelWorker";
10
- import { pickingMask } from "../shaders/pickingMask";
11
10
  import { randomi } from "../math";
12
11
  import { screenFrame } from "../shaders/screenFrame";
13
12
  import { toneMapping } from "../shaders/toneMapping";
@@ -197,7 +196,6 @@ class Renderer {
197
196
  this.screenFramePositionBuffer = null;
198
197
  this.screenTexture = {};
199
198
  this.outputTexture = null;
200
- this._pickingMaskCoordinatesBuffer = null;
201
199
  this._skipDistanceFrame = false;
202
200
  this._distancePixelBuffer = null;
203
201
  this._skipPickingFrame = false;
@@ -418,7 +416,7 @@ class Renderer {
418
416
  });
419
417
  this.handler.addProgram(screenFrame());
420
418
  this.pickingFramebuffer = new Framebuffer(this.handler, {
421
- width: 640, height: 480, depthComponent: "DEPTH_STENCIL", renderbufferTarget: "DEPTH_STENCIL_ATTACHMENT"
419
+ width: 640, height: 480
422
420
  });
423
421
  this.pickingFramebuffer.init();
424
422
  this._tempPickingPix_ = new Uint8Array(this.pickingFramebuffer.width * this.pickingFramebuffer.height * 4);
@@ -491,7 +489,6 @@ class Renderer {
491
489
  };
492
490
  this._initReadPixelsBuffers();
493
491
  }
494
- this.handler.addProgram(pickingMask());
495
492
  this.handler.ONCANVASRESIZE = () => {
496
493
  this._resizeStart();
497
494
  this.events.dispatch(this.events.resize, this.handler.canvas);
@@ -505,7 +502,6 @@ class Renderer {
505
502
  };
506
503
  this.screenFramePositionBuffer = this.handler.createArrayBuffer(new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]), 2, 4);
507
504
  this.outputTexture = this.screenTexture.screen;
508
- this._pickingMaskCoordinatesBuffer = this.handler.createArrayBuffer(new Float32Array([0, 0]), 2, 1);
509
505
  this._initializeRenderNodes();
510
506
  this._initializeControls();
511
507
  }
@@ -815,34 +811,14 @@ class Renderer {
815
811
  let gl = h.gl;
816
812
  if (this.activeCamera.isFirstPass) {
817
813
  gl.clearColor(0.0, 0.0, 0.0, 1.0);
818
- gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
814
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
819
815
  }
820
816
  else {
821
- gl.clear(gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
817
+ gl.clear(gl.DEPTH_BUFFER_BIT);
822
818
  }
823
819
  //
824
- // draw picking mask
825
- //
826
- h.programs.pickingMask.activate();
827
- let sh = h.programs.pickingMask._program;
828
- let shu = sh.uniforms, sha = sh.attributes;
829
- let /*ts = this.events.touchState,*/ ms = this.events.mouseState;
830
- gl.disable(gl.DEPTH_TEST);
831
- gl.enable(gl.STENCIL_TEST);
832
- gl.colorMask(false, false, false, false);
833
- gl.stencilFunc(gl.ALWAYS, 2, 0xFF);
834
- gl.stencilOp(gl.REPLACE, gl.ZERO, gl.REPLACE);
835
- gl.uniform2f(shu.offset, (ms.nx - 0.5) * 2, (0.5 - ms.ny) * 2);
836
- gl.bindBuffer(gl.ARRAY_BUFFER, this._pickingMaskCoordinatesBuffer);
837
- gl.vertexAttribPointer(sha.coordinates, this._pickingMaskCoordinatesBuffer.itemSize, gl.FLOAT, false, 0, 0);
838
- gl.drawArrays(gl.POINTS, 0, this._pickingMaskCoordinatesBuffer.numItems);
839
- gl.enable(gl.DEPTH_TEST);
840
- //
841
820
  // draw picking scenes
842
821
  //
843
- gl.colorMask(true, true, true, true);
844
- gl.stencilFunc(gl.EQUAL, 2, 0xFF);
845
- gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
846
822
  gl.disable(gl.BLEND);
847
823
  let dp = this._pickingCallbacks;
848
824
  for (let i = 0, len = dp.length; i < len; i++) {
@@ -852,7 +828,6 @@ class Renderer {
852
828
  dp[i].callback.call(dp[i].sender);
853
829
  }
854
830
  gl.enable(gl.BLEND);
855
- gl.disable(gl.STENCIL_TEST);
856
831
  this.pickingFramebuffer.deactivate();
857
832
  }
858
833
  /**
@@ -11,8 +11,6 @@ export function createRendererEvents(renderer) {
11
11
  const LB_M = 0b0001;
12
12
  const RB_M = 0b0010;
13
13
  const MB_M = 0b0100;
14
- let __skipFrames__ = 0;
15
- const MAX_SKIP_FRAMES_ON_BLACK = 15;
16
14
  const ISBLACK = (c) => !(c[0] || c[1] || c[2]);
17
15
  const NOTBLACK = (c) => !!(c[0] || c[1] || c[2]);
18
16
  /**
@@ -454,11 +452,6 @@ class RendererEvents extends Events {
454
452
  else {
455
453
  r.readPickingColor(ms.nx, 1 - ms.ny, t);
456
454
  }
457
- // current is black
458
- if (ISBLACK(t) && __skipFrames__++ < MAX_SKIP_FRAMES_ON_BLACK) {
459
- return;
460
- }
461
- __skipFrames__ = 0;
462
455
  p[0] = c[0];
463
456
  p[1] = c[1];
464
457
  p[2] = c[2];
@@ -315,6 +315,10 @@ export declare class Planet extends RenderNode {
315
315
  protected _nightTextureSrc: string | null;
316
316
  protected _specularTextureSrc: string | null;
317
317
  constructor(options?: IPlanetParams);
318
+ /**
319
+ * Returns true if current terrain data set is loaded
320
+ */
321
+ get terrainReady(): boolean;
318
322
  get maxGridSize(): number;
319
323
  getNorthFrameRotation(cartesian: Vec3): Quat;
320
324
  set atmosphereMaxOpacity(opacity: number);
@@ -112,7 +112,7 @@ export class Planet extends RenderNode {
112
112
  this._ambient = new Float32Array([a.x, a.y, a.z]);
113
113
  this._diffuse = new Float32Array([d.x, d.y, d.z]);
114
114
  this._specular = new Float32Array([s.x, s.y, s.z, shininess]);
115
- this._maxGridSize = Math.log2(options.maxGridSize || 128);
115
+ this._maxGridSize = Math.log2(options.maxGridSize || 256);
116
116
  this.SLICE_SIZE = 4;
117
117
  this.SLICE_SIZE_4 = this.SLICE_SIZE * 4;
118
118
  this.SLICE_SIZE_3 = this.SLICE_SIZE * 3;
@@ -149,6 +149,12 @@ export class Planet extends RenderNode {
149
149
  this._nightTextureSrc = options.nightTextureSrc || null;
150
150
  this._specularTextureSrc = options.specularTextureSrc || null;
151
151
  }
152
+ /**
153
+ * Returns true if current terrain data set is loaded
154
+ */
155
+ get terrainReady() {
156
+ return this._terrainCompleted && this._terrainCompletedActivated;
157
+ }
152
158
  get maxGridSize() {
153
159
  return this._maxGridSize;
154
160
  }
@@ -483,6 +489,7 @@ export class Planet extends RenderNode {
483
489
  // loading Earth night glowing texture
484
490
  if (this._nightTextureSrc) {
485
491
  let img = new Image();
492
+ img.crossOrigin = "Anonymous";
486
493
  img.onload = () => {
487
494
  this._nightTexture = this.renderer.handler.createTextureDefault(img);
488
495
  this._nightTexture.default = true;
@@ -495,6 +502,7 @@ export class Planet extends RenderNode {
495
502
  // load water specular mask
496
503
  if (this._specularTextureSrc) {
497
504
  let img = new Image();
505
+ img.crossOrigin = "Anonymous";
498
506
  img.onload = () => {
499
507
  this._specularTexture = this.renderer.handler.createTextureDefault(img);
500
508
  this._specularTexture.default = true;
@@ -12,6 +12,7 @@ export interface IGlobusTerrainParams extends IEmptyTerrainParams {
12
12
  urlRewrite?: UrlRewriteFunc;
13
13
  noDataValues?: number[];
14
14
  plainGridSize?: number;
15
+ heightFactor?: number;
15
16
  }
16
17
  type TileData = {
17
18
  heights: number[] | TypedArray | null;
@@ -33,6 +34,7 @@ type UrlRewriteFunc = (segment: Segment, url: string) => string;
33
34
  * @param {string} [options.responseType="arraybuffer"] - Response type.
34
35
  * @param {number} [options.MAX_LOADING_TILES] - Maximum at one time loading tiles.
35
36
  * @param {Array.<number>} [gridSizeByZoom] - Array of values, where each value corresponds to the size of a tile(or segment) on the globe. Each value must be power of two.
37
+ * @param {number} [heightFactor=1] - Elevation height multiplier.
36
38
  *
37
39
  * @fires GlobusTerrainEvents#load
38
40
  * @fires GlobusTerrainEvents#loadend
@@ -59,6 +61,7 @@ declare class GlobusTerrain extends EmptyTerrain {
59
61
  * @type {Function} -
60
62
  */
61
63
  protected _urlRewriteCallback: UrlRewriteFunc | null;
64
+ protected _heightFactor: number;
62
65
  constructor(name?: string, options?: IGlobusTerrainParams);
63
66
  get loader(): Loader<GlobusTerrain>;
64
67
  clearCache(): void;
@@ -26,6 +26,7 @@ import { Vec3 } from "../math/Vec3";
26
26
  * @param {string} [options.responseType="arraybuffer"] - Response type.
27
27
  * @param {number} [options.MAX_LOADING_TILES] - Maximum at one time loading tiles.
28
28
  * @param {Array.<number>} [gridSizeByZoom] - Array of values, where each value corresponds to the size of a tile(or segment) on the globe. Each value must be power of two.
29
+ * @param {number} [heightFactor=1] - Elevation height multiplier.
29
30
  *
30
31
  * @fires GlobusTerrainEvents#load
31
32
  * @fires GlobusTerrainEvents#loadend
@@ -33,7 +34,7 @@ import { Vec3 } from "../math/Vec3";
33
34
  class GlobusTerrain extends EmptyTerrain {
34
35
  constructor(name = "", options = {}) {
35
36
  super({
36
- geoidSrc: "//openglobus.org/geoid/egm84-30.pgm",
37
+ geoidSrc: "https://openglobus.org/geoid/egm84-30.pgm",
37
38
  maxNativeZoom: options.maxNativeZoom || 14,
38
39
  ...options
39
40
  });
@@ -44,11 +45,15 @@ class GlobusTerrain extends EmptyTerrain {
44
45
  this.isEmpty = false;
45
46
  this.equalizeNormals = true;
46
47
  this.name = name || "openglobus";
47
- this.url = options.url || "//{s}.srtm3.openglobus.org/{z}/{y}/{x}.ddm";
48
+ this.url = options.url || "https://{s}.srtm3.openglobus.org/{z}/{y}/{x}.ddm";
48
49
  this.gridSizeByZoom = options.gridSizeByZoom || [
49
50
  64, 32, 32, 16, 16, 8, 8, 8, 8, 16, 16, 16, 16, 32, 32, 16, 8, 4, 2, 2, 2, 2, 2, 2
50
51
  ];
52
+ this._heightFactor = options.heightFactor != undefined ? options.heightFactor : 1.0;
51
53
  this.noDataValues = options.noDataValues || [];
54
+ for (let i = 0; i < this.noDataValues.length; i++) {
55
+ this.noDataValues[i] *= this._heightFactor;
56
+ }
52
57
  this.plainGridSize = options.plainGridSize || 32;
53
58
  this._extent = createExtent(options.extent, new Extent(new LonLat(-180.0, -90.0), new LonLat(180.0, 90.0)));
54
59
  this._dataType = "arrayBuffer";
@@ -299,6 +304,13 @@ class GlobusTerrain extends EmptyTerrain {
299
304
  * @returns {Array.<number>} -
300
305
  */
301
306
  _createHeights(data, tileIndex, x, y, z, extent, isMaxZoom) {
307
+ if (this._heightFactor !== 1) {
308
+ let res = new Float32Array(data);
309
+ for (let i = 0, len = res.length; i < len; i++) {
310
+ res[i] = res[i] * this._heightFactor;
311
+ }
312
+ return res;
313
+ }
302
314
  return new Float32Array(data);
303
315
  }
304
316
  /**
@@ -15,17 +15,17 @@ class MapboxTerrain extends GlobusTerrain {
15
15
  super(name || "MapboxTerrain", {
16
16
  equalizeVertices: options.equalizeVertices != undefined ? options.equalizeVertices : true,
17
17
  maxZoom: options.maxZoom || 17,
18
+ noDataValues: options.noDataValues || [-65537, -10000],
19
+ plainGridSize: options.plainGridSize || 128,
20
+ url: options.url != undefined
21
+ ? options.url
22
+ : `//api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=${options.key || KEY}`,
23
+ gridSizeByZoom: options.gridSizeByZoom || [
24
+ 64, 32, 16, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 16, 32, 16, 32, 16, 32, 16, 8, 4
25
+ ],
18
26
  ...options
19
27
  });
20
28
  this.equalizeNormals = options.equalizeNormals || false;
21
- this.gridSizeByZoom = options.gridSizeByZoom || [
22
- 64, 32, 16, 8, 8, 8, 8, 16, 16, 16, 16, 16, 32, 16, 32, 16, 32, 16, 32, 16, 8, 4
23
- ];
24
- this.url = options.url != undefined
25
- ? options.url
26
- : `//api.mapbox.com/v4/mapbox.terrain-rgb/{z}/{x}/{y}.pngraw?access_token=${options.key || KEY}`;
27
- this.noDataValues = options.noDataValues || [-65537, -10000];
28
- this.plainGridSize = options.plainGridSize || 128;
29
29
  this._dataType = "imageBitmap";
30
30
  this._imageSize = options.imageSize || 256;
31
31
  this._ctx = this._createTemporalCanvas(this._imageSize);
@@ -52,7 +52,7 @@ class MapboxTerrain extends GlobusTerrain {
52
52
  //
53
53
  if (!isPowerOfTwo(this._imageSize) && SIZE === this._imageSize) {
54
54
  let outCurrenElevations = new Float32Array(SIZE * SIZE);
55
- extractElevationTilesMapboxNonPowerOfTwo(rgbaData, outCurrenElevations);
55
+ extractElevationTilesMapboxNonPowerOfTwo(rgbaData, outCurrenElevations, this._heightFactor);
56
56
  return outCurrenElevations;
57
57
  }
58
58
  if (this._imageSize === this.plainGridSize) {
@@ -61,22 +61,22 @@ class MapboxTerrain extends GlobusTerrain {
61
61
  for (let k = 0, len = this._imageSize * this._imageSize; k < len; k++) {
62
62
  let j = k % this._imageSize, i = Math.floor(k / this._imageSize);
63
63
  let fromInd4 = k * 4;
64
- let h = rgb2Height(rgbaData[fromInd4], rgbaData[fromInd4 + 1], rgbaData[fromInd4 + 2]);
64
+ let h = this._heightFactor * rgb2Height(rgbaData[fromInd4], rgbaData[fromInd4 + 1], rgbaData[fromInd4 + 2]);
65
65
  outCurrenElevations[i * (this._imageSize + 1) + j] = h;
66
66
  }
67
67
  for (let i = 0, len = this._imageSize; i < len; i++) {
68
68
  let j = this._imageSize - 1;
69
69
  let fromInd4 = (i * this._imageSize + j) * 4;
70
- let h = rgb2Height(rgbaData[fromInd4], rgbaData[fromInd4 + 1], rgbaData[fromInd4 + 2]);
70
+ let h = this._heightFactor * rgb2Height(rgbaData[fromInd4], rgbaData[fromInd4 + 1], rgbaData[fromInd4 + 2]);
71
71
  outCurrenElevations[i * (this._imageSize + 1) + this._imageSize] = h;
72
72
  }
73
73
  for (let j = 0, len = this._imageSize; j < len; j++) {
74
74
  let i = this._imageSize - 1;
75
75
  let fromInd4 = (i * this._imageSize + j) * 4;
76
- let h = rgb2Height(rgbaData[fromInd4], rgbaData[fromInd4 + 1], rgbaData[fromInd4 + 2]);
76
+ let h = this._heightFactor * rgb2Height(rgbaData[fromInd4], rgbaData[fromInd4 + 1], rgbaData[fromInd4 + 2]);
77
77
  outCurrenElevations[this._imageSize * (this._imageSize + 1) + j] = h;
78
78
  }
79
- let h = rgb2Height(rgbaData[rgbaData.length - 4], rgbaData[rgbaData.length - 3], rgbaData[rgbaData.length - 2]);
79
+ let h = this._heightFactor * rgb2Height(rgbaData[rgbaData.length - 4], rgbaData[rgbaData.length - 3], rgbaData[rgbaData.length - 2]);
80
80
  outCurrenElevations[outCurrenElevations.length - 1] = h;
81
81
  return outCurrenElevations;
82
82
  }
@@ -94,10 +94,10 @@ class MapboxTerrain extends GlobusTerrain {
94
94
  }
95
95
  }
96
96
  if (preventChildren) {
97
- extractElevationTilesMapboxNoChildren(rgbaData, this.noDataValues, outCurrenElevations);
97
+ extractElevationTilesMapboxNoChildren(rgbaData, this._heightFactor, this.noDataValues, outCurrenElevations);
98
98
  }
99
99
  else {
100
- extractElevationTilesMapbox(rgbaData, this.noDataValues, outCurrenElevations, outChildrenElevations);
100
+ extractElevationTilesMapbox(rgbaData, this._heightFactor, this.noDataValues, outCurrenElevations, outChildrenElevations);
101
101
  }
102
102
  this._elevationCache[tileIndex] = {
103
103
  heights: outCurrenElevations,
@@ -129,7 +129,7 @@ class MapboxTerrain extends GlobusTerrain {
129
129
  let index = (i * this._imageSize + j) * 4;
130
130
  if (this._imageDataCache[tileIndex]) {
131
131
  let data = this._imageDataCache[tileIndex];
132
- callback(rgb2Height(data[index], data[index + 1], data[index + 2]));
132
+ callback(this._heightFactor * rgb2Height(data[index], data[index + 1], data[index + 2]));
133
133
  return true;
134
134
  }
135
135
  if (!this._fetchCache[tileIndex]) {
@@ -145,7 +145,7 @@ class MapboxTerrain extends GlobusTerrain {
145
145
  this._ctx.drawImage(response.data, 0, 0);
146
146
  let data = this._ctx.getImageData(0, 0, 256, 256).data;
147
147
  this._imageDataCache[tileIndex] = data;
148
- callback(rgb2Height(data[index], data[index + 1], data[index + 2]));
148
+ callback(this._heightFactor * rgb2Height(data[index], data[index + 1], data[index + 2]));
149
149
  }
150
150
  else if (response.status === "error") {
151
151
  callback(0);
@@ -159,13 +159,13 @@ class MapboxTerrain extends GlobusTerrain {
159
159
  return false;
160
160
  }
161
161
  }
162
- function extractElevationTilesMapboxNonPowerOfTwo(rgbaData, outCurrenElevations) {
162
+ function extractElevationTilesMapboxNonPowerOfTwo(rgbaData, outCurrenElevations, heightFactor = 1) {
163
163
  for (let i = 0, len = outCurrenElevations.length; i < len; i++) {
164
164
  let i4 = i * 4;
165
- outCurrenElevations[i] = rgb2Height(rgbaData[i4], rgbaData[i4 + 1], rgbaData[i4 + 2]);
165
+ outCurrenElevations[i] = heightFactor * rgb2Height(rgbaData[i4], rgbaData[i4 + 1], rgbaData[i4 + 2]);
166
166
  }
167
167
  }
168
- function extractElevationTilesMapbox(rgbaData, noDataValues, outCurrenElevations, outChildrenElevations) {
168
+ function extractElevationTilesMapbox(rgbaData, heightFactor, noDataValues, outCurrenElevations, outChildrenElevations) {
169
169
  let destSize = Math.sqrt(outCurrenElevations.length) - 1;
170
170
  let destSizeOne = destSize + 1;
171
171
  let sourceSize = Math.sqrt(rgbaData.length / 4);
@@ -173,7 +173,7 @@ function extractElevationTilesMapbox(rgbaData, noDataValues, outCurrenElevations
173
173
  let rightHeight = 0, bottomHeight = 0, sourceSize4 = 0;
174
174
  for (let k = 0, currIndex = 0, sourceDataLength = rgbaData.length / 4; k < sourceDataLength; k++) {
175
175
  let k4 = k * 4;
176
- let height = rgb2Height(rgbaData[k4], rgbaData[k4 + 1], rgbaData[k4 + 2]);
176
+ let height = heightFactor * rgb2Height(rgbaData[k4], rgbaData[k4 + 1], rgbaData[k4 + 2]);
177
177
  let isNoDataCurrent = MapboxTerrain.checkNoDataValue(noDataValues, height), isNoDataRight = false, isNoDataBottom = false;
178
178
  let i = Math.floor(k / sourceSize), j = k % sourceSize;
179
179
  let tileX = Math.floor(j / destSize), tileY = Math.floor(i / destSize);
@@ -186,7 +186,7 @@ function extractElevationTilesMapbox(rgbaData, noDataValues, outCurrenElevations
186
186
  }
187
187
  if ((j + 1) % destSize === 0 && j !== sourceSize - 1) {
188
188
  //current tile
189
- rightHeight = rgb2Height(rgbaData[k4 + 4], rgbaData[k4 + 5], rgbaData[k4 + 6]);
189
+ rightHeight = heightFactor * rgb2Height(rgbaData[k4 + 4], rgbaData[k4 + 5], rgbaData[k4 + 6]);
190
190
  isNoDataRight = MapboxTerrain.checkNoDataValue(noDataValues, rightHeight);
191
191
  let middleHeight = height;
192
192
  if (!(isNoDataCurrent || isNoDataRight)) {
@@ -204,7 +204,7 @@ function extractElevationTilesMapbox(rgbaData, noDataValues, outCurrenElevations
204
204
  if ((i + 1) % destSize === 0 && i !== sourceSize - 1) {
205
205
  //current tile
206
206
  sourceSize4 = sourceSize * 4;
207
- bottomHeight = rgb2Height(rgbaData[k4 + sourceSize4], rgbaData[k4 + sourceSize4 + 1], rgbaData[k4 + sourceSize4 + 2]);
207
+ bottomHeight = heightFactor * rgb2Height(rgbaData[k4 + sourceSize4], rgbaData[k4 + sourceSize4 + 1], rgbaData[k4 + sourceSize4 + 2]);
208
208
  isNoDataBottom = MapboxTerrain.checkNoDataValue(noDataValues, bottomHeight);
209
209
  let middleHeight = (height + bottomHeight) * 0.5;
210
210
  if (!(isNoDataCurrent || isNoDataBottom)) {
@@ -222,7 +222,7 @@ function extractElevationTilesMapbox(rgbaData, noDataValues, outCurrenElevations
222
222
  if ((j + 1) % destSize === 0 && j !== sourceSize - 1 &&
223
223
  (i + 1) % destSize === 0 && i !== sourceSize - 1) {
224
224
  //current tile
225
- let rightBottomHeight = rgb2Height(rgbaData[k4 + sourceSize4 + 4], rgbaData[k4 + sourceSize4 + 5], rgbaData[k4 + sourceSize4 + 6]);
225
+ let rightBottomHeight = heightFactor * rgb2Height(rgbaData[k4 + sourceSize4 + 4], rgbaData[k4 + sourceSize4 + 5], rgbaData[k4 + sourceSize4 + 6]);
226
226
  let isNoDataRightBottom = MapboxTerrain.checkNoDataValue(noDataValues, rightBottomHeight);
227
227
  let middleHeight = height;
228
228
  if (!(isNoDataCurrent || isNoDataRight || isNoDataBottom || isNoDataRightBottom)) {
@@ -243,14 +243,14 @@ function extractElevationTilesMapbox(rgbaData, noDataValues, outCurrenElevations
243
243
  }
244
244
  }
245
245
  }
246
- function extractElevationTilesMapboxNoChildren(rgbaData, noDataValues, outCurrenElevations) {
246
+ function extractElevationTilesMapboxNoChildren(rgbaData, heightFactor, noDataValues, outCurrenElevations) {
247
247
  let destSize = Math.sqrt(outCurrenElevations.length) - 1;
248
248
  let sourceSize = Math.sqrt(rgbaData.length / 4);
249
249
  let dt = sourceSize / destSize;
250
250
  let rightHeight = 0, bottomHeight = 0, sourceSize4 = 0;
251
251
  for (let k = 0, currIndex = 0, sourceDataLength = rgbaData.length / 4; k < sourceDataLength; k++) {
252
252
  let k4 = k * 4;
253
- let height = rgb2Height(rgbaData[k4], rgbaData[k4 + 1], rgbaData[k4 + 2]);
253
+ let height = heightFactor * rgb2Height(rgbaData[k4], rgbaData[k4 + 1], rgbaData[k4 + 2]);
254
254
  let isNoDataCurrent = MapboxTerrain.checkNoDataValue(noDataValues, height), isNoDataRight = false, isNoDataBottom = false;
255
255
  let i = Math.floor(k / sourceSize), j = k % sourceSize;
256
256
  let tileX = Math.floor(j / destSize), tileY = Math.floor(i / destSize);
@@ -259,7 +259,7 @@ function extractElevationTilesMapboxNoChildren(rgbaData, noDataValues, outCurren
259
259
  }
260
260
  if ((j + 1) % destSize === 0 && j !== sourceSize - 1) {
261
261
  //current tile
262
- rightHeight = rgb2Height(rgbaData[k4 + 4], rgbaData[k4 + 5], rgbaData[k4 + 6]);
262
+ rightHeight = heightFactor * rgb2Height(rgbaData[k4 + 4], rgbaData[k4 + 5], rgbaData[k4 + 6]);
263
263
  isNoDataRight = MapboxTerrain.checkNoDataValue(noDataValues, rightHeight);
264
264
  let middleHeight = height;
265
265
  if (!(isNoDataCurrent || isNoDataRight)) {
@@ -272,7 +272,7 @@ function extractElevationTilesMapboxNoChildren(rgbaData, noDataValues, outCurren
272
272
  if ((i + 1) % destSize === 0 && i !== sourceSize - 1) {
273
273
  //current tile
274
274
  sourceSize4 = sourceSize * 4;
275
- bottomHeight = rgb2Height(rgbaData[k4 + sourceSize4], rgbaData[k4 + sourceSize4 + 1], rgbaData[k4 + sourceSize4 + 2]);
275
+ bottomHeight = heightFactor * rgb2Height(rgbaData[k4 + sourceSize4], rgbaData[k4 + sourceSize4 + 1], rgbaData[k4 + sourceSize4 + 2]);
276
276
  isNoDataBottom = MapboxTerrain.checkNoDataValue(noDataValues, bottomHeight);
277
277
  let middleHeight = (height + bottomHeight) * 0.5;
278
278
  if (!(isNoDataCurrent || isNoDataBottom)) {
@@ -285,7 +285,7 @@ function extractElevationTilesMapboxNoChildren(rgbaData, noDataValues, outCurren
285
285
  if ((j + 1) % destSize === 0 && j !== sourceSize - 1 &&
286
286
  (i + 1) % destSize === 0 && i !== sourceSize - 1) {
287
287
  //current tile
288
- let rightBottomHeight = rgb2Height(rgbaData[k4 + sourceSize4 + 4], rgbaData[k4 + sourceSize4 + 5], rgbaData[k4 + sourceSize4 + 6]);
288
+ let rightBottomHeight = heightFactor * rgb2Height(rgbaData[k4 + sourceSize4 + 4], rgbaData[k4 + sourceSize4 + 5], rgbaData[k4 + sourceSize4 + 6]);
289
289
  let isNoDataRightBottom = MapboxTerrain.checkNoDataValue(noDataValues, rightBottomHeight);
290
290
  let middleHeight = height;
291
291
  if (!(isNoDataCurrent || isNoDataRight || isNoDataBottom || isNoDataRightBottom)) {
@@ -19,7 +19,7 @@ class Dialog extends View {
19
19
  display: getDefault(options.visible, true) ? "flex" : "none",
20
20
  resize: getDefault(options.resizable, true) ? "both" : "none",
21
21
  width: options.width || 300,
22
- height: options.height ? `height:${options.height || 200}` : "",
22
+ height: options.height ? `height: ${options.height || 200}px` : "",
23
23
  left: options.left || 0,
24
24
  top: options.top || 0,
25
25
  minHeight: options.minHeight ? `${options.minHeight}px` : 'unset',
@@ -59,7 +59,7 @@ const TERRAIN_PROGRAM = `'use strict';
59
59
  end = arr.length - 1;
60
60
  while (start <= end) {
61
61
  let k = Math.floor((start + end) * 0.5);
62
- if (arr[k] === x)
62
+ if (Math.abs(arr[k] - x) < 1e-3)
63
63
  return k;
64
64
  else if (arr[k] < x)
65
65
  start = k + 1;
@@ -132,7 +132,7 @@ export declare function base64StringToBlog(string: string): Blob;
132
132
  * @param {Number} limit
133
133
  * @param {boolean} [skip]
134
134
  */
135
- export declare function throttle(func: Function, limit: number, skip: boolean): () => void;
135
+ export declare function throttle(func: Function, limit: number, skip?: boolean): () => void;
136
136
  /**
137
137
  *
138
138
  * y2-----Q12--------------Q22---
@@ -264,4 +264,5 @@ export declare function loadImage(url: string): Promise<HTMLImageElement>;
264
264
  */
265
265
  export declare function isImageLoaded(image: HTMLImageElement): boolean;
266
266
  export declare function distanceFormat(v: number): string;
267
+ export declare function distanceFormatExt(v: number): [string, string];
267
268
  export declare function getUrlParam(paramName: string): number | undefined;
@@ -245,7 +245,7 @@ export function binarySearchFast(arr, x) {
245
245
  let start = 0, end = arr.length - 1;
246
246
  while (start <= end) {
247
247
  let k = Math.floor((start + end) * 0.5);
248
- if (arr[k] === x) {
248
+ if (Math.abs(arr[k] - x) < 1e-3) {
249
249
  return k;
250
250
  }
251
251
  else if (arr[k] < x) {
@@ -510,7 +510,7 @@ export function base64StringToBlog(string) {
510
510
  * @param {Number} limit
511
511
  * @param {boolean} [skip]
512
512
  */
513
- export function throttle(func, limit, skip) {
513
+ export function throttle(func, limit, skip = false) {
514
514
  let lastFunc;
515
515
  let lastRan = 0;
516
516
  return function () {
@@ -875,7 +875,7 @@ export function isImageLoaded(image) {
875
875
  }
876
876
  export function distanceFormat(v) {
877
877
  if (v > 1000) {
878
- return `${(v / 1000).toFixed(1)} km`;
878
+ return `${(v / 1000).toFixed(2)} km`;
879
879
  }
880
880
  else if (v > 9) {
881
881
  return `${Math.round(v)} m`;
@@ -884,6 +884,24 @@ export function distanceFormat(v) {
884
884
  return `${v.toFixed(1)} m`;
885
885
  }
886
886
  }
887
+ export function distanceFormatExt(v) {
888
+ if (v > 1000) {
889
+ let d = v - Math.floor(v);
890
+ if (d !== 0) {
891
+ return [(v / 1000).toFixed(2), "km"];
892
+ }
893
+ return [(v / 1000).toFixed(0), "km"];
894
+ }
895
+ else if (v > 9) {
896
+ return [Math.round(v).toString(), "m"];
897
+ }
898
+ else {
899
+ if (v <= 0.01) {
900
+ return ["0", "m"];
901
+ }
902
+ return [v.toFixed(1), "m"];
903
+ }
904
+ }
887
905
  export function getUrlParam(paramName) {
888
906
  let urlParams = new URLSearchParams(location.search);
889
907
  let param = urlParams.get(paramName);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.18.3",
3
+ "version": "0.18.5",
4
4
  "description": "[openglobus](https://www.openglobus.org/) is a javascript/typescript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers, and 3D objects. It uses the WebGL technology, open source, and completely free.",
5
5
  "directories": {
6
6
  "example": "./sandbox"
@@ -1,2 +0,0 @@
1
- import { Program } from '../webgl/Program';
2
- export declare function pickingMask(): Program;
@@ -1,22 +0,0 @@
1
- import { Program } from '../webgl/Program';
2
- export function pickingMask() {
3
- return new Program("pickingMask", {
4
- uniforms: {
5
- offset: "vec2"
6
- },
7
- attributes: {
8
- coordinates: "vec2"
9
- },
10
- vertexShader: `attribute vec2 coordinates;
11
- uniform vec2 offset;
12
- void main() {
13
-
14
- gl_Position = vec4(coordinates + offset, 0.0, 1.0);
15
- gl_PointSize = 5.0;
16
- }`,
17
- fragmentShader: `precision highp float;
18
- void main(void) {
19
- gl_FragColor = vec4(1.0);
20
- }`
21
- });
22
- }