@openglobus/og 0.14.4 → 0.15.0

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 (102) hide show
  1. package/css/og.css +377 -274
  2. package/dist/@openglobus/og.css +1 -1
  3. package/dist/@openglobus/og.esm.js +2 -2
  4. package/dist/@openglobus/og.esm.js.map +1 -1
  5. package/dist/@openglobus/og.umd.js +2 -2
  6. package/dist/@openglobus/og.umd.js.map +1 -1
  7. package/package.json +18 -17
  8. package/src/og/Clock.js +218 -194
  9. package/src/og/Globe.js +1 -3
  10. package/src/og/Object3d.js +104 -145
  11. package/src/og/camera/Camera.js +23 -19
  12. package/src/og/cons.js +107 -107
  13. package/src/og/control/Atmosphere.js +396 -0
  14. package/src/og/control/CompassButton.js +11 -18
  15. package/src/og/control/Control.js +187 -188
  16. package/src/og/control/GeoImageDragControl.js +84 -66
  17. package/src/og/control/LayerSwitcher.js +46 -145
  18. package/src/og/control/Lighting.js +314 -186
  19. package/src/og/control/RulerSwitcher.js +24 -19
  20. package/src/og/control/SimpleSkyBackground.js +38 -12
  21. package/src/og/control/Sun.js +2 -0
  22. package/src/og/control/ZoomControl.js +30 -42
  23. package/src/og/control/ruler/RulerScene.js +5 -23
  24. package/src/og/control/selection/Selection.js +21 -50
  25. package/src/og/control/selection/SelectionScene.js +15 -29
  26. package/src/og/control/timeline/TimelineControl.js +99 -0
  27. package/src/og/control/timeline/TimelineModel.js +133 -0
  28. package/src/og/control/timeline/TimelineView.js +449 -0
  29. package/src/og/control/timeline/timelineUtils.js +132 -0
  30. package/src/og/entity/Entity.js +30 -3
  31. package/src/og/entity/EntityCollection.js +0 -2
  32. package/src/og/entity/GeoObject.js +72 -56
  33. package/src/og/entity/GeoObjectHandler.js +487 -656
  34. package/src/og/input/input.js +3 -1
  35. package/src/og/layer/CanvasTiles.js +39 -34
  36. package/src/og/layer/Layer.js +2 -0
  37. package/src/og/layer/Material.js +1 -8
  38. package/src/og/light/LightSource.js +2 -0
  39. package/src/og/quadTree/Node.js +2 -1
  40. package/src/og/renderer/Renderer.js +26 -42
  41. package/src/og/renderer/RendererEvents.js +4 -4
  42. package/src/og/scene/Planet.js +276 -59
  43. package/src/og/scene/RenderNode.js +27 -12
  44. package/src/og/segment/Segment.js +0 -5
  45. package/src/og/shaders/atmos.js +332 -0
  46. package/src/og/shaders/drawnode.js +475 -109
  47. package/src/og/shaders/geoObject.js +96 -51
  48. package/src/og/shaders/polyline.js +212 -17
  49. package/src/og/shaders/utils.js +88 -0
  50. package/src/og/terrain/GlobusTerrain.js +2 -2
  51. package/src/og/ui/Button.js +106 -0
  52. package/src/og/ui/ButtonGroup.js +57 -0
  53. package/src/og/ui/Dialog.js +242 -0
  54. package/src/og/ui/Slider.js +144 -0
  55. package/src/og/ui/ToggleButton.js +51 -0
  56. package/src/og/ui/View.js +190 -0
  57. package/src/og/utils/shared.js +51 -33
  58. package/src/og/webgl/Framebuffer.js +308 -387
  59. package/src/og/webgl/Handler.js +68 -21
  60. package/src/og/webgl/Multisample.js +8 -0
  61. package/types/Clock.d.ts +7 -2
  62. package/types/Object3d.d.ts +14 -3
  63. package/types/camera/Camera.d.ts +15 -14
  64. package/types/control/Atmosphere.d.ts +15 -0
  65. package/types/control/CompassButton.d.ts +1 -2
  66. package/types/control/GeoImageDragControl.d.ts +7 -1
  67. package/types/control/LayerSwitcher.d.ts +4 -5
  68. package/types/control/Lighting.d.ts +32 -7
  69. package/types/control/SimpleSkyBackground.d.ts +4 -0
  70. package/types/control/ZoomControl.d.ts +0 -1
  71. package/types/control/ruler/RulerScene.d.ts +0 -1
  72. package/types/control/selection/Selection.d.ts +2 -4
  73. package/types/control/selection/SelectionScene.d.ts +0 -1
  74. package/types/entity/Entity.d.ts +8 -0
  75. package/types/entity/GeoObject.d.ts +28 -22
  76. package/types/entity/GeoObjectHandler.d.ts +16 -56
  77. package/types/input/input.d.ts +2 -0
  78. package/types/layer/CanvasTiles.d.ts +1 -0
  79. package/types/layer/Layer.d.ts +1 -0
  80. package/types/math/Plane.d.ts +1 -1
  81. package/types/renderer/Renderer.d.ts +7 -1
  82. package/types/scene/Planet.d.ts +20 -2
  83. package/types/scene/RenderNode.d.ts +2 -1
  84. package/types/segment/Segment.d.ts +1 -1
  85. package/types/shaders/atmos.d.ts +4 -0
  86. package/types/shaders/drawnode.d.ts +3 -2
  87. package/types/shaders/utils.d.ts +1 -0
  88. package/types/terrain/GlobusTerrain.d.ts +1 -1
  89. package/types/ui/Button.d.ts +21 -0
  90. package/types/ui/Dialog.d.ts +41 -0
  91. package/types/ui/Slider.d.ts +30 -0
  92. package/types/ui/ToggleButton.d.ts +10 -0
  93. package/types/ui/View.d.ts +32 -0
  94. package/types/utils/shared.d.ts +16 -14
  95. package/types/webgl/Framebuffer.d.ts +2 -5
  96. package/types/webgl/Handler.d.ts +11 -9
  97. package/types/webgl/Multisample.d.ts +2 -0
  98. package/src/og/ajax.js +0 -204
  99. package/src/og/entity/Object3d.js +0 -504
  100. package/types/ajax.d.ts +0 -24
  101. /package/src/og/{control → ui}/UIhelpers.js +0 -0
  102. /package/types/{control → ui}/UIhelpers.d.ts +0 -0
@@ -33,6 +33,8 @@ import { Geoid } from "../terrain/Geoid.js";
33
33
  import { createColorRGB, isUndef } from "../utils/shared.js";
34
34
  import { MAX_RENDERED_NODES } from "../quadTree/quadTree.js";
35
35
  import { EarthQuadTreeStrategy } from "../quadTree/EarthQuadTreeStrategy.js";
36
+ import { SimpleSkyBackground } from "../control/SimpleSkyBackground.js";
37
+ import { Atmosphere } from "../control/Atmosphere.js";
36
38
 
37
39
  const CUR_LOD_SIZE = 250; //px
38
40
  const MIN_LOD_SIZE = 312; //px
@@ -342,8 +344,8 @@ export class Planet extends RenderNode {
342
344
  //TODO: replace to a function
343
345
  let a = utils.createColorRGB(options.ambient, new Vec3(0.2, 0.2, 0.2));
344
346
  let d = utils.createColorRGB(options.diffuse, new Vec3(0.8, 0.8, 0.8));
345
- let s = utils.createColorRGB(options.specular, new Vec3(0.0003, 0.0003, 0.0003));
346
- let shininess = options.shininess || 20.0;
347
+ let s = utils.createColorRGB(options.specular, new Vec3(0.013, 0.005, 0.0));
348
+ let shininess = options.shininess || 27.0;
347
349
 
348
350
  this._ambient = new Float32Array([a.x, a.y, a.z]);
349
351
  this._diffuse = new Float32Array([d.x, d.y, d.z]);
@@ -422,18 +424,57 @@ export class Planet extends RenderNode {
422
424
 
423
425
  this._terrainCompleted = false;
424
426
  this._terrainCompletedActivated = false;
425
-
426
427
  this._collectRenderNodesIsActive = true;
427
428
 
428
- this._skipPreRender = false;
429
+ /**
430
+ * Night texture brightness coefficient
431
+ * @type {number}
432
+ */
433
+ this.nightTextureCoefficient = 1.5;
434
+
435
+ this._renderScreenNodesPASS = this._renderScreenNodesPASSNoAtmos;
436
+
437
+ this._atmosphereEnabled = options.atmosphereEnabled || false;
438
+ this._atmosphereMaxMinOpacity = new Float32Array([1.0, 0.41]);
429
439
  }
430
440
 
431
441
  static getBearingNorthRotationQuat(cartesian) {
442
+ //
443
+ // TODO: fix normal for ellipsoid
444
+ //
432
445
  let n = cartesian.normal();
433
446
  let t = Vec3.proj_b_to_plane(Vec3.UNIT_Y, n);
434
447
  return Quat.getLookRotation(t, n);
435
448
  }
436
449
 
450
+ set atmosphereMaxOpacity(opacity) {
451
+ this._atmosphereMaxMinOpacity[0] = opacity;
452
+ }
453
+
454
+ get atmosphereMaxOpacity() {
455
+ return this._atmosphereMaxMinOpacity[0];
456
+ }
457
+
458
+ set atmosphereMinOpacity(opacity) {
459
+ this._atmosphereMaxMinOpacity[1] = opacity;
460
+ }
461
+
462
+ get atmosphereMinOpacity() {
463
+ return this._atmosphereMaxMinOpacity[1];
464
+ }
465
+
466
+
467
+ set atmosphereEnabled(enabled) {
468
+ if (enabled != this._atmosphereEnabled) {
469
+ this._atmosphereEnabled = enabled;
470
+ this._initializeAtmosphere();
471
+ }
472
+ }
473
+
474
+ get atmosphereEnabled() {
475
+ return this._atmosphereEnabled;
476
+ }
477
+
437
478
  set diffuse(rgb) {
438
479
  let vec = createColorRGB(rgb);
439
480
  this._diffuse = new Float32Array(vec.toArray());
@@ -461,6 +502,10 @@ export class Planet extends RenderNode {
461
502
  return [...this._layers];
462
503
  }
463
504
 
505
+ get sunPos() {
506
+ return this.renderer.controls.sun.sunlight.getPosition();
507
+ }
508
+
464
509
  /**
465
510
  * Add the given control to the renderer of the planet scene.
466
511
  * @param {control.Control} control - Control.
@@ -641,24 +686,66 @@ export class Planet extends RenderNode {
641
686
  terrain._isReady = true;
642
687
  })
643
688
  .catch((err) => {
644
- console.log(err);
689
+ console.warn(err);
645
690
  });
646
691
  }
647
692
  }
648
693
 
694
+ _initializeAtmosphere() {
695
+ let h = this.renderer.handler;
696
+ h.removeProgram("drawnode_screen_wl");
697
+
698
+ if (this._atmosphereEnabled) {
699
+
700
+ this._renderScreenNodesPASS = this._renderScreenNodesPASSAtmos;
701
+
702
+ if (h.isWebGl2()) {
703
+ h.addProgram(shaders.drawnode_screen_wl_webgl2Atmos(), true);
704
+ } else {
705
+ h.addProgram(shaders.drawnode_screen_wl_webgl1NoAtmos(), true);
706
+ }
707
+
708
+ if (!this.renderer.controls.Atmosphere) {
709
+ this.addControl(new Atmosphere());
710
+ } else {
711
+ this.renderer.controls.Atmosphere.activate();
712
+ }
713
+
714
+ if (this.renderer.controls.SimpleSkyBackground) {
715
+ this.renderer.controls.SimpleSkyBackground.deactivate();
716
+ }
717
+
718
+ } else {
719
+
720
+ this._renderScreenNodesPASS = this._renderScreenNodesPASSNoAtmos;
721
+
722
+
723
+ if (this.renderer.controls.Atmosphere) {
724
+ this.renderer.controls.Atmosphere.deactivate();
725
+ }
726
+
727
+ if (!this.renderer.controls.SimpleSkyBackground) {
728
+ this.addControl(new SimpleSkyBackground());
729
+ } else {
730
+ this.renderer.controls.SimpleSkyBackground.activate();
731
+ }
732
+
733
+ if (h.isWebGl2()) {
734
+ h.addProgram(shaders.drawnode_screen_wl_webgl2NoAtmos(), true);
735
+ } else {
736
+ h.addProgram(shaders.drawnode_screen_wl_webgl1NoAtmos(), true);
737
+ }
738
+ }
739
+ }
740
+
649
741
  /**
650
742
  * @virtual
651
743
  * @protected
652
744
  */
653
745
  _initializeShaders() {
654
- var h = this.renderer.handler;
746
+ let h = this.renderer.handler;
655
747
 
656
748
  h.addProgram(shaders.drawnode_screen_nl(), true);
657
- if (h.isWebGl2()) {
658
- h.addProgram(shaders.drawnode_screen_wl_webgl2(), true);
659
- } else {
660
- h.addProgram(shaders.drawnode_screen_wl(), true);
661
- }
662
749
  h.addProgram(shaders.drawnode_colorPicking(), true);
663
750
  h.addProgram(shaders.drawnode_depth(), true);
664
751
  h.addProgram(shaders.drawnode_heightPicking(), true);
@@ -728,11 +815,6 @@ export class Planet extends RenderNode {
728
815
  this._terrainCompletedActivated = false;
729
816
  });
730
817
 
731
- this.renderer.events.on("resizeend", () => {
732
- this._renderCompletedActivated = false;
733
- this._terrainCompletedActivated = false;
734
- });
735
-
736
818
  // Initialize texture coordinates buffer pool
737
819
  this._textureCoordsBufferCache = [];
738
820
 
@@ -769,7 +851,6 @@ export class Planet extends RenderNode {
769
851
  this._renderedNodesInFrustum[i] = [];
770
852
  }
771
853
 
772
-
773
854
  // Creating quad trees nodes
774
855
  this.quadTreeStrategy.init();
775
856
 
@@ -778,6 +859,8 @@ export class Planet extends RenderNode {
778
859
  // Applying shaders
779
860
  this._initializeShaders();
780
861
 
862
+ this._initializeAtmosphere();
863
+
781
864
  this._updateVisibleLayers();
782
865
 
783
866
  this.renderer.addPickingCallback(this, this._frustumEntityCollectionPickingCallback);
@@ -1013,9 +1096,7 @@ export class Planet extends RenderNode {
1013
1096
 
1014
1097
  this.minCurrZoom = this.maxCurrZoom;
1015
1098
 
1016
- let temp = this._renderedNodes,
1017
- rf = this._renderedNodesInFrustum,
1018
- temp2 = [];
1099
+ let temp = this._renderedNodes, rf = this._renderedNodesInFrustum, temp2 = [];
1019
1100
 
1020
1101
  this._clearRenderNodesInFrustum();
1021
1102
  this._renderedNodes = [];
@@ -1073,6 +1154,10 @@ export class Planet extends RenderNode {
1073
1154
  this._updateVisibleLayers();
1074
1155
  }
1075
1156
 
1157
+ if (this.camera.isFirstPass) {
1158
+ this._firstPASS();
1159
+ }
1160
+
1076
1161
  this._renderScreenNodesPASS();
1077
1162
 
1078
1163
  this._renderHeightPickingFramebufferPASS();
@@ -1113,42 +1198,150 @@ export class Planet extends RenderNode {
1113
1198
  this.camera.setTerrainCollisionActivity(true);
1114
1199
  }
1115
1200
 
1116
- /**
1117
- * @protected
1118
- */
1119
- _renderScreenNodesPASS() {
1201
+ _firstPASS() {
1202
+
1203
+ if (this._skipPreRender && this._collectRenderNodesIsActive) {
1204
+ this._collectRenderNodes();
1205
+ }
1206
+ this._skipPreRender = true;
1207
+
1208
+ // Here is the planet node dispatches a draw event before
1209
+ // rendering begins and we have got render nodes.
1210
+ this.events.dispatch(this.events.draw, this);
1211
+
1212
+ this.transformLights();
1213
+
1214
+ this._normalMapCreator.frame();
1215
+
1216
+ // Creating geoImages textures.
1217
+ this._geoImageCreator.frame();
1218
+
1219
+ // Collect entity collections from vector layers
1220
+ this._collectVectorLayerCollections();
1221
+
1222
+ // Vector tiles rasteriazation
1223
+ this._vectorTileCreator.frame();
1224
+ }
1225
+
1226
+ _renderScreenNodesPASSNoAtmos() {
1120
1227
 
1121
1228
  let sh, shu;
1122
1229
  let renderer = this.renderer;
1123
1230
  let h = renderer.handler;
1124
1231
  let gl = h.gl;
1125
1232
  let cam = renderer.activeCamera;
1126
- let frustumIndex = cam.getCurrentFrustum(), firstPass = frustumIndex === cam.FARTHEST_FRUSTUM_INDEX;
1233
+ let firstPass = cam.isFirstPass;
1234
+ let frustumIndex = cam.currentFrustumIndex;
1235
+
1236
+ gl.enable(gl.CULL_FACE);
1237
+
1238
+ gl.enable(gl.BLEND);
1239
+ gl.blendEquation(gl.FUNC_ADD);
1240
+ gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
1241
+
1242
+ if (this.lightEnabled) {
1243
+ h.programs.drawnode_screen_wl.activate();
1244
+ sh = h.programs.drawnode_screen_wl._program;
1245
+ shu = sh.uniforms;
1246
+
1247
+ gl.uniform3fv(shu.lightsPositions, this._lightsPositions);
1248
+ gl.uniformMatrix4fv(shu.viewMatrix, false, cam.getViewMatrix());
1249
+ gl.uniformMatrix4fv(shu.projectionMatrix, false, cam.getProjectionMatrix());
1127
1250
 
1128
- if (firstPass) {
1129
- if (this._skipPreRender && this._collectRenderNodesIsActive) {
1130
- this._collectRenderNodes();
1251
+ if (this.baseLayer) {
1252
+ gl.uniform3fv(shu.diffuse, this.baseLayer._diffuse || this._diffuse);
1253
+ gl.uniform3fv(shu.ambient, this.baseLayer._ambient || this._ambient);
1254
+ gl.uniform4fv(shu.specular, this.baseLayer._specular || this._specular);
1255
+ gl.uniform1f(shu.nightTextureCoefficient, this.baseLayer.nightTextureCoefficient || this.nightTextureCoefficient);
1256
+ } else {
1257
+ gl.uniform3fv(shu.diffuse, this._diffuse);
1258
+ gl.uniform3fv(shu.ambient, this._ambient);
1259
+ gl.uniform4fv(shu.specular, this._specular);
1260
+ gl.uniform1f(shu.nightTextureCoefficient, this.nightTextureCoefficient);
1131
1261
  }
1132
- this._skipPreRender = true;
1133
1262
 
1134
- // Here is the planet node dispatches a draw event before
1135
- // rendering begins and we have got render nodes.
1136
- this.events.dispatch(this.events.draw, this);
1263
+ //
1264
+ // Night and specular
1265
+ //
1266
+ gl.activeTexture(gl.TEXTURE0 + this.SLICE_SIZE);
1267
+ gl.bindTexture(gl.TEXTURE_2D, this._nightTexture || this.transparentTexture);
1268
+ gl.uniform1i(shu.nightTexture, this.SLICE_SIZE);
1269
+
1270
+ gl.activeTexture(gl.TEXTURE0 + this.SLICE_SIZE + 1);
1271
+ gl.bindTexture(gl.TEXTURE_2D, this._specularTexture || this.transparentTexture);
1272
+ gl.uniform1i(shu.specularTexture, this.SLICE_SIZE + 1);
1273
+
1274
+ gl.uniform1f(shu.camHeight, cam.getHeight());
1275
+
1276
+ } else {
1277
+ h.programs.drawnode_screen_nl.activate();
1278
+ sh = h.programs.drawnode_screen_nl._program;
1279
+ shu = sh.uniforms;
1280
+ gl.uniformMatrix4fv(shu.viewMatrix, false, cam.getViewMatrix());
1281
+ gl.uniformMatrix4fv(shu.projectionMatrix, false, cam.getProjectionMatrix());
1282
+ }
1283
+
1284
+ gl.uniform3fv(shu.eyePositionHigh, cam.eyeHigh);
1285
+ gl.uniform3fv(shu.eyePositionLow, cam.eyeLow);
1137
1286
 
1138
- this.transformLights();
1287
+ //
1288
+ // drawing planet nodes
1289
+ //
1290
+ let rn = this._renderedNodesInFrustum[frustumIndex],
1291
+ sl = this._visibleTileLayerSlices;
1139
1292
 
1140
- this._normalMapCreator.frame();
1293
+ if (sl.length) {
1294
+ let sli = sl[0];
1295
+ for (var i = sli.length - 1; i >= 0; --i) {
1296
+ let li = sli[i];
1297
+ if (li._fading && firstPass && li._refreshFadingOpacity()) {
1298
+ sli.splice(i, 1);
1299
+ }
1300
+ }
1301
+ }
1141
1302
 
1142
- // Creating geoImages textures.
1143
- this._geoImageCreator.frame();
1303
+ let isEq = this.terrain.equalizeVertices;
1304
+ i = rn.length;
1305
+ while (i--) {
1306
+ let s = rn[i].segment;
1307
+ isEq && s.equalize();
1308
+ s.readyToEngage && s.engage();
1309
+ s.screenRendering(sh, sl[0], 0);
1310
+ }
1144
1311
 
1145
- // Collect entity collections from vector layers
1146
- this._collectVectorLayerCollections();
1312
+ gl.enable(gl.POLYGON_OFFSET_FILL);
1313
+ for (let j = 1, len = sl.length; j < len; j++) {
1314
+ let slj = sl[j];
1315
+ for (i = slj.length - 1; i >= 0; --i) {
1316
+ let li = slj[i];
1317
+ if (li._fading && firstPass && li._refreshFadingOpacity()) {
1318
+ slj.splice(i, 1);
1319
+ }
1320
+ }
1147
1321
 
1148
- // Vector tiles rasteriazation
1149
- this._vectorTileCreator.frame();
1322
+ gl.polygonOffset(0, -j);
1323
+ i = rn.length;
1324
+ while (i--) {
1325
+ rn[i].segment.screenRendering(sh, sl[j], j, this.transparentTexture, true);
1326
+ }
1150
1327
  }
1328
+ gl.disable(gl.POLYGON_OFFSET_FILL);
1329
+
1330
+ gl.disable(gl.BLEND);
1331
+ }
1151
1332
 
1333
+ /**
1334
+ * @protected
1335
+ */
1336
+ _renderScreenNodesPASSAtmos() {
1337
+
1338
+ let sh, shu;
1339
+ let renderer = this.renderer;
1340
+ let h = renderer.handler;
1341
+ let gl = h.gl;
1342
+ let cam = renderer.activeCamera;
1343
+ let firstPass = cam.isFirstPass;
1344
+ let frustumIndex = cam.currentFrustumIndex;
1152
1345
 
1153
1346
  gl.enable(gl.CULL_FACE);
1154
1347
 
@@ -1161,9 +1354,7 @@ export class Planet extends RenderNode {
1161
1354
  sh = h.programs.drawnode_screen_wl._program;
1162
1355
  shu = sh.uniforms;
1163
1356
 
1164
- gl.uniform4fv(shu.lightsPositions, this._lightsTransformedPositions);
1165
-
1166
- gl.uniformMatrix3fv(shu.normalMatrix, false, cam.getNormalMatrix());
1357
+ gl.uniform3fv(shu.lightsPositions, this._lightsPositions);
1167
1358
  gl.uniformMatrix4fv(shu.viewMatrix, false, cam.getViewMatrix());
1168
1359
  gl.uniformMatrix4fv(shu.projectionMatrix, false, cam.getProjectionMatrix());
1169
1360
 
@@ -1171,22 +1362,41 @@ export class Planet extends RenderNode {
1171
1362
  gl.uniform3fv(shu.diffuse, this.baseLayer._diffuse || this._diffuse);
1172
1363
  gl.uniform3fv(shu.ambient, this.baseLayer._ambient || this._ambient);
1173
1364
  gl.uniform4fv(shu.specular, this.baseLayer._specular || this._specular);
1365
+ gl.uniform1f(shu.nightTextureCoefficient, this.baseLayer.nightTextureCoefficient || this.nightTextureCoefficient);
1174
1366
  } else {
1175
1367
  gl.uniform3fv(shu.diffuse, this._diffuse);
1176
1368
  gl.uniform3fv(shu.ambient, this._ambient);
1177
1369
  gl.uniform4fv(shu.specular, this._specular);
1370
+ gl.uniform1f(shu.nightTextureCoefficient, this.nightTextureCoefficient);
1178
1371
  }
1179
1372
 
1180
- // bind night glowing material
1373
+ gl.uniform2fv(shu.maxMinOpacity, this._atmosphereMaxMinOpacity);
1374
+
1375
+ //
1376
+ // Night and specular
1377
+ //
1181
1378
  gl.activeTexture(gl.TEXTURE0 + this.SLICE_SIZE);
1182
- gl.bindTexture(gl.TEXTURE_2D, (this.camera._lonLat.height > 329958.0 && (this._nightTexture || this.transparentTexture)) || this.transparentTexture);
1379
+ gl.bindTexture(gl.TEXTURE_2D, this._nightTexture || this.transparentTexture);
1183
1380
  gl.uniform1i(shu.nightTexture, this.SLICE_SIZE);
1184
1381
 
1185
- // bind specular material
1186
1382
  gl.activeTexture(gl.TEXTURE0 + this.SLICE_SIZE + 1);
1187
1383
  gl.bindTexture(gl.TEXTURE_2D, this._specularTexture || this.transparentTexture);
1188
1384
  gl.uniform1i(shu.specularTexture, this.SLICE_SIZE + 1);
1189
1385
 
1386
+
1387
+ //
1388
+ // atmos precomputed textures
1389
+ //
1390
+ gl.activeTexture(gl.TEXTURE0 + this.SLICE_SIZE + 4);
1391
+ gl.bindTexture(gl.TEXTURE_2D, this.renderer.controls.Atmosphere._transmittanceBuffer.textures[0]);
1392
+ gl.uniform1i(shu.transmittanceTexture, this.SLICE_SIZE + 4);
1393
+
1394
+ gl.activeTexture(gl.TEXTURE0 + this.SLICE_SIZE + 5);
1395
+ gl.bindTexture(gl.TEXTURE_2D, this.renderer.controls.Atmosphere._scatteringBuffer.textures[0]);
1396
+ gl.uniform1i(shu.scatteringTexture, this.SLICE_SIZE + 5);
1397
+
1398
+ gl.uniform1f(shu.camHeight, cam.getHeight());
1399
+
1190
1400
  } else {
1191
1401
  h.programs.drawnode_screen_nl.activate();
1192
1402
  sh = h.programs.drawnode_screen_nl._program;
@@ -1198,8 +1408,11 @@ export class Planet extends RenderNode {
1198
1408
  gl.uniform3fv(shu.eyePositionHigh, cam.eyeHigh);
1199
1409
  gl.uniform3fv(shu.eyePositionLow, cam.eyeLow);
1200
1410
 
1411
+ //
1201
1412
  // drawing planet nodes
1202
- var rn = this._renderedNodesInFrustum[frustumIndex], sl = this._visibleTileLayerSlices;
1413
+ //
1414
+ let rn = this._renderedNodesInFrustum[frustumIndex],
1415
+ sl = this._visibleTileLayerSlices;
1203
1416
 
1204
1417
  if (sl.length) {
1205
1418
  let sli = sl[0];
@@ -1254,7 +1467,7 @@ export class Planet extends RenderNode {
1254
1467
  let h = renderer.handler;
1255
1468
  let gl = h.gl;
1256
1469
  let cam = renderer.activeCamera;
1257
- let frustumIndex = cam.getCurrentFrustum();
1470
+ let frustumIndex = cam.currentFrustumIndex;
1258
1471
 
1259
1472
  if (frustumIndex === cam.FARTHEST_FRUSTUM_INDEX) {
1260
1473
  gl.clearColor(0.0, 0.0, 0.0, 1.0);
@@ -1559,23 +1772,27 @@ export class Planet extends RenderNode {
1559
1772
 
1560
1773
  // HEIGHT
1561
1774
  this._heightPickingFramebuffer.activate();
1562
- if (this._heightPickingFramebuffer.isComplete()) {
1563
- this._heightPickingFramebuffer.readPixels(_tempPickingPix_, spx, spy);
1564
- dist = decodeFloatFromRGBAArr(_tempPickingPix_);
1565
- }
1775
+
1776
+ //if (this._heightPickingFramebuffer.isComplete()) {
1777
+ this._heightPickingFramebuffer.readPixels(_tempPickingPix_, spx, spy);
1778
+ dist = decodeFloatFromRGBAArr(_tempPickingPix_);
1779
+ //}
1780
+
1566
1781
  this._heightPickingFramebuffer.deactivate();
1567
1782
 
1568
1783
  if (!(_tempPickingPix_[0] || _tempPickingPix_[1] || _tempPickingPix_[2])) {
1569
1784
  dist = this.getDistanceFromPixelEllipsoid(px) || 0;
1570
1785
  } else if (dist < DEPTH_DISTANCE) {
1571
1786
  r.screenDepthFramebuffer.activate();
1572
- if (r.screenDepthFramebuffer.isComplete()) {
1573
- r.screenDepthFramebuffer.readPixels(_tempDepthColor_, spx, spy);
1574
- let screenPos = new Vec4(spx * 2.0 - 1.0, spy * 2.0 - 1.0, (_tempDepthColor_[0] / 255.0) * 2.0 - 1.0, 1.0 * 2.0 - 1.0);
1575
- let viewPosition = this.camera.frustums[0]._inverseProjectionMatrix.mulVec4(screenPos);
1576
- let dir = px.direction || this.renderer.activeCamera.unproject(px.x, px.y);
1577
- dist = -(viewPosition.z / viewPosition.w) / dir.dot(this.renderer.activeCamera.getForward());
1578
- }
1787
+
1788
+ //if (r.screenDepthFramebuffer.isComplete()) {
1789
+ r.screenDepthFramebuffer.readPixels(_tempDepthColor_, spx, spy);
1790
+ let screenPos = new Vec4(spx * 2.0 - 1.0, spy * 2.0 - 1.0, (_tempDepthColor_[0] / 255.0) * 2.0 - 1.0, 1.0 * 2.0 - 1.0);
1791
+ let viewPosition = this.camera.frustums[0]._inverseProjectionMatrix.mulVec4(screenPos);
1792
+ let dir = px.direction || this.renderer.activeCamera.unproject(px.x, px.y);
1793
+ dist = -(viewPosition.z / viewPosition.w) / dir.dot(this.renderer.activeCamera.getForward());
1794
+ //}
1795
+
1579
1796
  r.screenDepthFramebuffer.deactivate();
1580
1797
  }
1581
1798
  return dist;
@@ -46,7 +46,7 @@ class RenderNode extends BaseNode {
46
46
  * @type {Array.<LightSource>}
47
47
  */
48
48
  this._lights = [];
49
- this._lightsTransformedPositions = [];
49
+ this._lightsPositions = [];
50
50
  this._lightsParamsv = [];
51
51
  this._lightsParamsf = [];
52
52
  this._lightsNames = [];
@@ -228,19 +228,28 @@ class RenderNode extends BaseNode {
228
228
  transformLights() {
229
229
  var r = this.renderer;
230
230
  for (var i = 0; i < this._lights.length; i++) {
231
- var ii = i * 4;
231
+ var ii = i * 3;
232
232
  var tp;
233
- if (this._lights[i].directional) {
234
- tp = r.activeCamera._normalMatrix.mulVec(this._lights[i]._position);
235
- this._lightsTransformedPositions[ii + 3] = 0;
236
- } else {
237
- tp = r.activeCamera._viewMatrix.mulVec3(this._lights[i]._position);
238
- this._lightsTransformedPositions[ii + 3] = 1;
239
- }
240
- this._lightsTransformedPositions[ii] = tp.x;
241
- this._lightsTransformedPositions[ii + 1] = tp.y;
242
- this._lightsTransformedPositions[ii + 2] = tp.z;
233
+ tp = this._lights[i]._position;
234
+ this._lightsPositions[ii] = tp.x;
235
+ this._lightsPositions[ii + 1] = tp.y;
236
+ this._lightsPositions[ii + 2] = tp.z;
243
237
  }
238
+
239
+ // for (var i = 0; i < this._lights.length; i++) {
240
+ // var ii = i * 4;
241
+ // var tp;
242
+ // if (this._lights[i].directional) {
243
+ // tp = r.activeCamera._normalMatrix.mulVec(this._lights[i]._position);
244
+ // this._lightsTransformedPositions[ii + 3] = 0;
245
+ // } else {
246
+ // tp = r.activeCamera._viewMatrix.mulVec3(this._lights[i]._position);
247
+ // this._lightsTransformedPositions[ii + 3] = 1;
248
+ // }
249
+ // this._lightsTransformedPositions[ii] = tp.x;
250
+ // this._lightsTransformedPositions[ii + 1] = tp.y;
251
+ // this._lightsTransformedPositions[ii + 2] = tp.z;
252
+ // }
244
253
  }
245
254
 
246
255
  updateBillboardsTexCoords() {
@@ -249,6 +258,12 @@ class RenderNode extends BaseNode {
249
258
  }
250
259
  }
251
260
 
261
+ updateGeoObjectsTexCoords() {
262
+ for (var i = 0; i < this.entityCollections.length; i++) {
263
+ this.entityCollections[i].geoObjectHandler.refreshTexCoordsArr();
264
+ }
265
+ }
266
+
252
267
  /**
253
268
  * @private
254
269
  */
@@ -97,11 +97,6 @@ class Segment {
97
97
  */
98
98
  this.bbox = new Box();
99
99
 
100
- //this._swNorm = null;
101
- //this._nwNorm = null;
102
- //this._seNorm = null;
103
- //this._neNorm = null;
104
-
105
100
  this._sw = new Vec3();
106
101
  this._nw = new Vec3();
107
102
  this._se = new Vec3();