@openglobus/og 0.18.5 → 0.19.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.
Files changed (38) hide show
  1. package/README.md +17 -69
  2. package/css/og.css +59 -44
  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/Globe.d.ts +2 -0
  9. package/lib/js/Globe.js +3 -1
  10. package/lib/js/control/DebugInfo.js +5 -0
  11. package/lib/js/control/LayerSwitcher.d.ts +18 -3
  12. package/lib/js/control/LayerSwitcher.js +111 -11
  13. package/lib/js/control/MouseNavigation.d.ts +2 -0
  14. package/lib/js/control/MouseNavigation.js +15 -15
  15. package/lib/js/control/elevationProfile/ElevationProfile.js +3 -1
  16. package/lib/js/control/elevationProfile/ElevationProfileScene.js +7 -7
  17. package/lib/js/control/heightRuler/HeightRulerScene.js +1 -1
  18. package/lib/js/control/ruler/RulerScene.js +3 -3
  19. package/lib/js/control/selection/SelectionScene.js +2 -2
  20. package/lib/js/entity/Entity.js +5 -1
  21. package/lib/js/layer/Layer.d.ts +18 -4
  22. package/lib/js/layer/Layer.js +25 -4
  23. package/lib/js/layer/XYZ.d.ts +0 -1
  24. package/lib/js/quadTree/Node.d.ts +21 -3
  25. package/lib/js/quadTree/Node.js +161 -62
  26. package/lib/js/renderer/Renderer.js +19 -16
  27. package/lib/js/renderer/RendererEvents.d.ts +1 -0
  28. package/lib/js/renderer/RendererEvents.js +5 -0
  29. package/lib/js/scene/Planet.d.ts +29 -4
  30. package/lib/js/scene/Planet.js +207 -85
  31. package/lib/js/segment/Segment.d.ts +7 -1
  32. package/lib/js/segment/Segment.js +57 -12
  33. package/lib/js/shaders/drawnode.js +21 -2
  34. package/lib/js/shaders/geoObject.js +30 -24
  35. package/lib/js/terrain/GlobusTerrain.js +1 -1
  36. package/lib/js/utils/shared.d.ts +1 -0
  37. package/lib/js/utils/shared.js +1 -0
  38. package/package.json +2 -2
@@ -299,7 +299,8 @@ export function drawnode_screen_wl_webgl2NoAtmos() {
299
299
  ambient: "vec3",
300
300
  specular: "vec4",
301
301
  camHeight: "float",
302
- nightTextureCoefficient: "float"
302
+ nightTextureCoefficient: "float",
303
+ transitionOpacity: "float"
303
304
  }, attributes: {
304
305
  aVertexPositionHigh: "vec3",
305
306
  aVertexPositionLow: "vec3",
@@ -373,6 +374,8 @@ export function drawnode_screen_wl_webgl2NoAtmos() {
373
374
 
374
375
  uniform int samplerCount;
375
376
  uniform float nightTextureCoefficient;
377
+
378
+ uniform float transitionOpacity;
376
379
 
377
380
  uniform float camHeight;
378
381
 
@@ -424,8 +427,10 @@ export function drawnode_screen_wl_webgl2NoAtmos() {
424
427
  vec4 lightWeighting = vec4(ambient + diffuse * diffuseLightWeighting + night, 1.0);
425
428
 
426
429
  diffuseColor = texture( defaultTexture, vTextureCoord.xy );
430
+
427
431
  if( samplerCount == 0 ) {
428
432
  diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
433
+ diffuseColor *= transitionOpacity;
429
434
  return;
430
435
  }
431
436
 
@@ -434,29 +439,34 @@ export function drawnode_screen_wl_webgl2NoAtmos() {
434
439
  blend(diffuseColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
435
440
  if( samplerCount == 1 ) {
436
441
  diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
442
+ diffuseColor *= transitionOpacity;
437
443
  return;
438
444
  }
439
445
 
440
446
  blend(diffuseColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
441
447
  if( samplerCount == 2 ) {
442
448
  diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
449
+ diffuseColor *= transitionOpacity;
443
450
  return;
444
451
  }
445
452
 
446
453
  blend(diffuseColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
447
454
  if( samplerCount == 3 ) {
448
455
  diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
456
+ diffuseColor *= transitionOpacity;
449
457
  return;
450
458
  }
451
459
 
452
460
  blend(diffuseColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
453
461
  if( samplerCount == 4 ) {
454
462
  diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
463
+ diffuseColor *= transitionOpacity;
455
464
  return;
456
465
  }
457
466
 
458
467
  blend(diffuseColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
459
468
  diffuseColor = diffuseColor * lightWeighting + vec4(spec, 0.0);
469
+ diffuseColor *= transitionOpacity;
460
470
  }`
461
471
  });
462
472
  }
@@ -486,7 +496,8 @@ export function drawnode_screen_wl_webgl2Atmos() {
486
496
  scatteringTexture: "sampler2D",
487
497
  camHeight: "float",
488
498
  nightTextureCoefficient: "float",
489
- maxMinOpacity: "vec2"
499
+ maxMinOpacity: "vec2",
500
+ transitionOpacity: "float"
490
501
  }, attributes: {
491
502
  aVertexPositionHigh: "vec3",
492
503
  aVertexPositionLow: "vec3",
@@ -566,6 +577,8 @@ export function drawnode_screen_wl_webgl2Atmos() {
566
577
 
567
578
  uniform vec2 maxMinOpacity;
568
579
  uniform float camHeight;
580
+
581
+ uniform float transitionOpacity;
569
582
 
570
583
  in vec4 vTextureCoord;
571
584
  in vec3 v_vertex;
@@ -749,6 +762,7 @@ export function drawnode_screen_wl_webgl2Atmos() {
749
762
  diffuseColor = texture( defaultTexture, vTextureCoord.xy );
750
763
  if( samplerCount == 0 ) {
751
764
  diffuseColor = mix(diffuseColor * lightWeighting, atmosColor, fadingOpacity) + vec4(spec, 0.0);
765
+ diffuseColor *= transitionOpacity;
752
766
  return;
753
767
  }
754
768
 
@@ -757,29 +771,34 @@ export function drawnode_screen_wl_webgl2Atmos() {
757
771
  blend(diffuseColor, samplerArr[0], tileOffsetArr[0], layerOpacityArr[0]);
758
772
  if( samplerCount == 1 ) {
759
773
  diffuseColor = mix(diffuseColor * lightWeighting, atmosColor * diffuseColor.a, fadingOpacity) + vec4(spec, 0.0);
774
+ diffuseColor *= transitionOpacity;
760
775
  return;
761
776
  }
762
777
 
763
778
  blend(diffuseColor, samplerArr[1], tileOffsetArr[1], layerOpacityArr[1]);
764
779
  if( samplerCount == 2 ) {
765
780
  diffuseColor = mix(diffuseColor * lightWeighting, atmosColor * diffuseColor.a, fadingOpacity) + vec4(spec, 0.0);
781
+ diffuseColor *= transitionOpacity;
766
782
  return;
767
783
  }
768
784
 
769
785
  blend(diffuseColor, samplerArr[2], tileOffsetArr[2], layerOpacityArr[2]);
770
786
  if( samplerCount == 3 ) {
771
787
  diffuseColor = mix(diffuseColor * lightWeighting, atmosColor * diffuseColor.a, fadingOpacity) + vec4(spec, 0.0);
788
+ diffuseColor *= transitionOpacity;
772
789
  return;
773
790
  }
774
791
 
775
792
  blend(diffuseColor, samplerArr[3], tileOffsetArr[3], layerOpacityArr[3]);
776
793
  if( samplerCount == 4 ) {
777
794
  diffuseColor = mix(diffuseColor * lightWeighting, atmosColor * diffuseColor.a, fadingOpacity) + vec4(spec, 0.0);
795
+ diffuseColor *= transitionOpacity;
778
796
  return;
779
797
  }
780
798
 
781
799
  blend(diffuseColor, samplerArr[4], tileOffsetArr[4], layerOpacityArr[4]);
782
800
  diffuseColor = mix(diffuseColor * lightWeighting, atmosColor * diffuseColor.a, fadingOpacity) + vec4(spec, 0.0);
801
+ diffuseColor *= transitionOpacity;
783
802
  }`
784
803
  });
785
804
  }
@@ -38,7 +38,6 @@ export const geo_object = () => new Program("geo_object", {
38
38
  attribute float aUseTexture;
39
39
  attribute vec2 aTexCoord;
40
40
 
41
- uniform float uUseTexture;
42
41
  uniform vec3 uScaleByDistance;
43
42
  uniform mat4 projectionMatrix;
44
43
  uniform mat4 viewMatrix;
@@ -51,7 +50,6 @@ export const geo_object = () => new Program("geo_object", {
51
50
  varying vec3 v_vertex;
52
51
  varying vec4 vColor;
53
52
  varying float vDispose;
54
- varying float vUseTexture;
55
53
  varying vec2 vTexCoords;
56
54
 
57
55
  const float PI = 3.141592653589793;
@@ -64,22 +62,25 @@ export const geo_object = () => new Program("geo_object", {
64
62
  return;
65
63
  }
66
64
 
67
- vUseTexture = uUseTexture;
68
65
  vColor = aColor;
69
66
  vTexCoords = aTexCoord;
70
67
 
71
- float roll = aPitchRoll.y;
68
+ float cos_roll = cos(aPitchRoll.y);
69
+ float sin_roll = sin(aPitchRoll.y);
70
+
72
71
  mat3 rotZ = mat3(
73
- vec3(cos(roll), sin(roll), 0.0),
74
- vec3(-sin(roll), cos(roll), 0.0),
72
+ vec3(cos_roll, sin_roll, 0.0),
73
+ vec3(-sin_roll, cos_roll, 0.0),
75
74
  vec3(0.0, 0.0, 1.0)
76
75
  );
77
76
 
78
- float pitch = aPitchRoll.x;
77
+ float cos_pitch = cos(aPitchRoll.x);
78
+ float sin_pitch = sin(aPitchRoll.x);
79
+
79
80
  mat3 rotX = mat3(
80
81
  vec3(1.0, 0.0, 0.0),
81
- vec3(0.0, cos(pitch), sin(pitch)),
82
- vec3(0.0, -sin(pitch), cos(pitch))
82
+ vec3(0.0, cos_pitch, sin_pitch),
83
+ vec3(0.0, -sin_pitch, cos_pitch)
83
84
  );
84
85
 
85
86
  vec3 position = aPositionHigh + aPositionLow;
@@ -125,13 +126,13 @@ export const geo_object = () => new Program("geo_object", {
125
126
  uniform vec3 lightsParamsv[MAX_POINT_LIGHTS * 3];
126
127
  uniform float lightsParamsf[MAX_POINT_LIGHTS];
127
128
  uniform sampler2D uTexture;
128
-
129
+ uniform float uUseTexture;
130
+
129
131
  varying vec3 cameraPosition;
130
132
  varying vec3 v_vertex;
131
133
  varying vec4 vColor;
132
134
  varying vec3 vNormal;
133
135
  varying vec2 vTexCoords;
134
- varying float vUseTexture;
135
136
 
136
137
  void main(void) {
137
138
  vec3 normal = normalize(vNormal);
@@ -144,7 +145,8 @@ export const geo_object = () => new Program("geo_object", {
144
145
  float diffuseLightWeighting = max(dot(normal, lightDir), 0.0);
145
146
  vec3 lightWeighting = lightsParamsv[0] + lightsParamsv[1] * diffuseLightWeighting + lightsParamsv[2] * specularLightWeighting;
146
147
  vec4 tColor = texture2D(uTexture, vTexCoords);
147
- if(vUseTexture > 0.0){
148
+
149
+ if(uUseTexture > 0.0) {
148
150
  gl_FragColor = vec4(tColor.rgb * lightWeighting, tColor.a);
149
151
  } else {
150
152
  gl_FragColor = vec4(vColor.rgb * lightWeighting, vColor.a);
@@ -200,19 +202,23 @@ export const geo_object_picking = () => new Program("geo_object_picking", {
200
202
 
201
203
  vColor = aPickingColor;
202
204
 
203
- float roll = aPitchRoll.y;
204
- mat3 rotZ = mat3(
205
- vec3(cos(roll), sin(roll), 0.0),
206
- vec3(-sin(roll), cos(roll), 0.0),
207
- vec3(0.0, 0.0, 1.0)
208
- );
209
-
210
- float pitch = aPitchRoll.x;
211
- mat3 rotX = mat3(
212
- vec3(1.0, 0.0, 0.0),
213
- vec3(0.0, cos(pitch), sin(pitch)),
214
- vec3(0.0, -sin(pitch), cos(pitch))
205
+ float cos_roll = cos(aPitchRoll.y);
206
+ float sin_roll = sin(aPitchRoll.y);
207
+
208
+ mat3 rotZ = mat3(
209
+ vec3(cos_roll, sin_roll, 0.0),
210
+ vec3(-sin_roll, cos_roll, 0.0),
211
+ vec3(0.0, 0.0, 1.0)
215
212
  );
213
+
214
+ float cos_pitch = cos(aPitchRoll.x);
215
+ float sin_pitch = sin(aPitchRoll.x);
216
+
217
+ mat3 rotX = mat3(
218
+ vec3(1.0, 0.0, 0.0),
219
+ vec3(0.0, cos_pitch, sin_pitch),
220
+ vec3(0.0, -sin_pitch, cos_pitch)
221
+ );
216
222
 
217
223
  vec3 position = aPositionHigh + aPositionLow;
218
224
  vec3 cameraPosition = eyePositionHigh + eyePositionLow;
@@ -47,7 +47,7 @@ class GlobusTerrain extends EmptyTerrain {
47
47
  this.name = name || "openglobus";
48
48
  this.url = options.url || "https://{s}.srtm3.openglobus.org/{z}/{y}/{x}.ddm";
49
49
  this.gridSizeByZoom = options.gridSizeByZoom || [
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
+ 64, 32, 32, 16, 16, 8, 8, 8, 16, 16, 16, 32, 32, 32, 32, 16, 8, 4, 2, 2, 2, 2, 2, 2
51
51
  ];
52
52
  this._heightFactor = options.heightFactor != undefined ? options.heightFactor : 1.0;
53
53
  this.noDataValues = options.noDataValues || [];
@@ -78,6 +78,7 @@ export declare function binarySearchFast(arr: number[] | TypedArray, x: number):
78
78
  */
79
79
  export declare function binarySearch(ar: any[], el: any, compare_fn: Function): number;
80
80
  /**
81
+ * @todo: replace any with generic
81
82
  * Binary insertion that uses binarySearch algorithm.
82
83
  * @param {any[]} ar - The sorted array to insert.
83
84
  * @param {any} el - The item to insert.
@@ -292,6 +292,7 @@ export function binarySearch(ar, el, compare_fn) {
292
292
  return -m - 1;
293
293
  }
294
294
  /**
295
+ * @todo: replace any with generic
295
296
  * Binary insertion that uses binarySearch algorithm.
296
297
  * @param {any[]} ar - The sorted array to insert.
297
298
  * @param {any} el - The item to insert.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.18.5",
3
+ "version": "0.19.1",
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"
@@ -47,7 +47,7 @@
47
47
  "jsdoc": "^4.0.2",
48
48
  "lint-staged": "^14.0.1",
49
49
  "local-web-server": "^5.3.0",
50
- "postcss": "^8.4.29",
50
+ "postcss": "^8.4.31",
51
51
  "prettier": "^3.0.3",
52
52
  "rollup": "^3.29.2",
53
53
  "rollup-plugin-copy": "^3.5.0",