@openglobus/og 0.14.10 → 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 (140) hide show
  1. package/css/og.css +378 -275
  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 +5 -5
  10. package/src/og/Object3d.js +104 -145
  11. package/src/og/camera/Camera.js +31 -27
  12. package/src/og/camera/PlanetCamera.js +22 -14
  13. package/src/og/cons.js +107 -107
  14. package/src/og/control/Atmosphere.js +396 -0
  15. package/src/og/control/CompassButton.js +11 -18
  16. package/src/og/control/Control.js +187 -188
  17. package/src/og/control/GeoImageDragControl.js +84 -66
  18. package/src/og/control/LayerSwitcher.js +56 -138
  19. package/src/og/control/Lighting.js +314 -186
  20. package/src/og/control/MouseNavigation.js +2 -2
  21. package/src/og/control/RulerSwitcher.js +24 -19
  22. package/src/og/control/ScaleControl.js +30 -10
  23. package/src/og/control/SimpleSkyBackground.js +210 -0
  24. package/src/og/control/Sun.js +2 -0
  25. package/src/og/control/ZoomControl.js +30 -42
  26. package/src/og/control/index.js +6 -0
  27. package/src/og/control/ruler/RulerScene.js +5 -23
  28. package/src/og/control/selection/Selection.js +99 -0
  29. package/src/og/control/selection/SelectionScene.js +350 -0
  30. package/src/og/control/timeline/TimelineControl.js +99 -0
  31. package/src/og/control/timeline/TimelineModel.js +133 -0
  32. package/src/og/control/timeline/TimelineView.js +449 -0
  33. package/src/og/control/timeline/timelineUtils.js +132 -0
  34. package/src/og/ellipsoid/Ellipsoid.js +120 -93
  35. package/src/og/ellipsoid/wgs84.js +13 -13
  36. package/src/og/entity/Entity.js +36 -9
  37. package/src/og/entity/EntityCollection.js +0 -2
  38. package/src/og/entity/GeoObject.js +72 -56
  39. package/src/og/entity/GeoObjectHandler.js +487 -656
  40. package/src/og/entity/GeometryHandler.js +1341 -1337
  41. package/src/og/entity/Polyline.js +0 -16
  42. package/src/og/entity/Ray.js +0 -10
  43. package/src/og/entity/RayHandler.js +3 -44
  44. package/src/og/entity/Strip.js +1 -6
  45. package/src/og/index.js +10 -6
  46. package/src/og/input/input.js +3 -1
  47. package/src/og/layer/CanvasTiles.js +39 -34
  48. package/src/og/layer/Layer.js +69 -9
  49. package/src/og/layer/Material.js +1 -8
  50. package/src/og/layer/WMS.js +16 -5
  51. package/src/og/light/LightSource.js +2 -0
  52. package/src/og/math/Line3.js +140 -139
  53. package/src/og/math/Plane.js +118 -117
  54. package/src/og/math/Ray.js +242 -239
  55. package/src/og/math/Vec3.js +56 -37
  56. package/src/og/math/Vec4.js +3 -4
  57. package/src/og/math.js +21 -21
  58. package/src/og/quadTree/Node.js +5 -4
  59. package/src/og/quadTree/index.js +12 -0
  60. package/src/og/renderer/Renderer.js +64 -37
  61. package/src/og/renderer/RendererEvents.js +1071 -1065
  62. package/src/og/scene/Planet.js +352 -172
  63. package/src/og/scene/RenderNode.js +27 -12
  64. package/src/og/segment/Segment.js +0 -5
  65. package/src/og/shaders/atmos.js +332 -0
  66. package/src/og/shaders/drawnode.js +475 -109
  67. package/src/og/shaders/geoObject.js +96 -51
  68. package/src/og/shaders/polyline.js +212 -17
  69. package/src/og/shaders/ray.js +13 -6
  70. package/src/og/shaders/toneMapping.js +5 -5
  71. package/src/og/shaders/utils.js +88 -0
  72. package/src/og/terrain/GlobusTerrain.js +5 -4
  73. package/src/og/terrain/MapboxTerrain.js +231 -52
  74. package/src/og/ui/Button.js +106 -0
  75. package/src/og/ui/ButtonGroup.js +57 -0
  76. package/src/og/ui/Dialog.js +242 -0
  77. package/src/og/ui/Slider.js +144 -0
  78. package/src/og/ui/ToggleButton.js +51 -0
  79. package/src/og/{control → ui}/UIhelpers.js +11 -2
  80. package/src/og/ui/View.js +190 -0
  81. package/src/og/utils/shared.js +960 -942
  82. package/src/og/webgl/Framebuffer.js +308 -387
  83. package/src/og/webgl/Handler.js +90 -30
  84. package/src/og/webgl/Multisample.js +8 -0
  85. package/types/Clock.d.ts +7 -2
  86. package/types/Object3d.d.ts +14 -3
  87. package/types/camera/Camera.d.ts +18 -17
  88. package/types/camera/PlanetCamera.d.ts +3 -1
  89. package/types/control/Atmosphere.d.ts +15 -0
  90. package/types/control/CompassButton.d.ts +1 -2
  91. package/types/control/GeoImageDragControl.d.ts +7 -1
  92. package/types/control/LayerSwitcher.d.ts +5 -6
  93. package/types/control/Lighting.d.ts +32 -7
  94. package/types/control/ScaleControl.d.ts +2 -1
  95. package/types/control/SimpleSkyBackground.d.ts +15 -0
  96. package/types/control/ZoomControl.d.ts +0 -1
  97. package/types/control/index.d.ts +4 -1
  98. package/types/control/ruler/RulerScene.d.ts +0 -1
  99. package/types/control/selection/Selection.d.ts +49 -0
  100. package/types/control/selection/SelectionScene.d.ts +34 -0
  101. package/types/ellipsoid/Ellipsoid.d.ts +3 -2
  102. package/types/entity/Entity.d.ts +8 -0
  103. package/types/entity/GeoObject.d.ts +28 -22
  104. package/types/entity/GeoObjectHandler.d.ts +16 -56
  105. package/types/entity/Ray.d.ts +0 -3
  106. package/types/entity/RayHandler.d.ts +0 -4
  107. package/types/index.d.ts +7 -5
  108. package/types/input/input.d.ts +2 -0
  109. package/types/layer/CanvasTiles.d.ts +1 -0
  110. package/types/layer/Layer.d.ts +9 -0
  111. package/types/layer/WMS.d.ts +7 -3
  112. package/types/math/Plane.d.ts +1 -1
  113. package/types/math/Vec3.d.ts +19 -16
  114. package/types/math/Vec4.d.ts +2 -3
  115. package/types/math.d.ts +20 -20
  116. package/types/quadTree/index.d.ts +10 -0
  117. package/types/renderer/Renderer.d.ts +11 -37
  118. package/types/scene/Planet.d.ts +27 -1
  119. package/types/scene/RenderNode.d.ts +2 -1
  120. package/types/segment/Segment.d.ts +1 -1
  121. package/types/shaders/atmos.d.ts +4 -0
  122. package/types/shaders/drawnode.d.ts +3 -2
  123. package/types/shaders/utils.d.ts +1 -0
  124. package/types/terrain/GlobusTerrain.d.ts +1 -1
  125. package/types/terrain/MapboxTerrain.d.ts +2 -1
  126. package/types/ui/Button.d.ts +21 -0
  127. package/types/ui/Dialog.d.ts +41 -0
  128. package/types/ui/Slider.d.ts +30 -0
  129. package/types/ui/ToggleButton.d.ts +10 -0
  130. package/types/{control → ui}/UIhelpers.d.ts +1 -1
  131. package/types/ui/View.d.ts +32 -0
  132. package/types/utils/shared.d.ts +16 -14
  133. package/types/webgl/Framebuffer.d.ts +2 -5
  134. package/types/webgl/Handler.d.ts +15 -10
  135. package/types/webgl/Multisample.d.ts +2 -0
  136. package/src/og/ajax.js +0 -204
  137. package/src/og/entity/Object3d.js +0 -504
  138. package/src/og/utils/quadTreeType.js +0 -11
  139. package/types/ajax.d.ts +0 -24
  140. package/types/utils/quadTreeType.d.ts +0 -8
@@ -39,38 +39,47 @@ export class Vec3 {
39
39
  static get UP() {
40
40
  return new Vec3(0, 1, 0);
41
41
  }
42
+
42
43
  /** @const */
43
44
  static get DOWN() {
44
45
  return new Vec3(0, -1, 0);
45
46
  }
47
+
46
48
  /** @const */
47
49
  static get RIGHT() {
48
50
  return new Vec3(1, 0, 0);
49
51
  }
52
+
50
53
  /** @const */
51
54
  static get LEFT() {
52
55
  return new Vec3(-1, 0, 0);
53
56
  }
57
+
54
58
  /** @const */
55
59
  static get FORWARD() {
56
60
  return new Vec3(0, 0, -1);
57
61
  }
62
+
58
63
  /** @const */
59
64
  static get BACKWARD() {
60
65
  return new Vec3(0, 0, 1);
61
66
  }
67
+
62
68
  /** @const */
63
69
  static get ZERO() {
64
70
  return new Vec3();
65
71
  }
72
+
66
73
  /** @const */
67
74
  static get UNIT_X() {
68
75
  return new Vec3(1, 0, 0);
69
76
  }
77
+
70
78
  /** @const */
71
79
  static get UNIT_Y() {
72
80
  return new Vec3(0, 1, 0);
73
81
  }
82
+
74
83
  /** @const */
75
84
  static get UNIT_Z() {
76
85
  return new Vec3(0, 0, 1);
@@ -231,9 +240,7 @@ export class Vec3 {
231
240
  * @returns {Vec3} -
232
241
  */
233
242
  static scale(a, scale) {
234
- var res = new Vec3(a.x, a.y, a.z);
235
- res.scale(scale);
236
- return res;
243
+ return a.scaleTo(scale);
237
244
  }
238
245
 
239
246
  /**
@@ -314,6 +321,18 @@ export class Vec3 {
314
321
  return res;
315
322
  }
316
323
 
324
+ static length2(a) {
325
+ return a.length2();
326
+ }
327
+
328
+ static length(a) {
329
+ return a.length();
330
+ }
331
+
332
+ static dot(a, b) {
333
+ return a.dot(b);
334
+ }
335
+
317
336
  /**
318
337
  * Converts to 4d vector, Fourth value is 1.0.
319
338
  * @public
@@ -372,13 +391,13 @@ export class Vec3 {
372
391
 
373
392
  /**
374
393
  * Copy input vector's values.
375
- * @param {Vec3} point3 - Vector to copy.
394
+ * @param {Vec3} p - Vector to copy.
376
395
  * @returns {Vec3} -
377
396
  */
378
- copy(point3) {
379
- this.x = point3.x;
380
- this.y = point3.y;
381
- this.z = point3.z;
397
+ copy(p) {
398
+ this.x = p.x;
399
+ this.y = p.y;
400
+ this.z = p.z;
382
401
  return this;
383
402
  }
384
403
 
@@ -412,47 +431,47 @@ export class Vec3 {
412
431
  /**
413
432
  * Adds vector to the current.
414
433
  * @public
415
- * @param {Vec3} point3 - Point to add.
434
+ * @param {Vec3} p - Point to add.
416
435
  * @returns {Vec3} -
417
436
  */
418
- addA(point3) {
419
- this.x += point3.x;
420
- this.y += point3.y;
421
- this.z += point3.z;
437
+ addA(p) {
438
+ this.x += p.x;
439
+ this.y += p.y;
440
+ this.z += p.z;
422
441
  return this;
423
442
  }
424
443
 
425
444
  /**
426
445
  * Gets two vectors summarization.
427
446
  * @public
428
- * @param {Vec3} point3 - Vector to add.
447
+ * @param {Vec3} p - Vector to add.
429
448
  * @returns {Vec3} Returns a sum vector.
430
449
  */
431
- add(point3) {
432
- return new Vec3(this.x + point3.x, this.y + point3.y, this.z + point3.z);
450
+ add(p) {
451
+ return new Vec3(this.x + p.x, this.y + p.y, this.z + p.z);
433
452
  }
434
453
 
435
454
  /**
436
455
  * Subtract vector from the current.
437
456
  * @public
438
- * @param {Vec3} point3 - Subtract vector.
457
+ * @param {Vec3} p - Subtract vector.
439
458
  * @returns {Vec3} -
440
459
  */
441
- subA(point3) {
442
- this.x -= point3.x;
443
- this.y -= point3.y;
444
- this.z -= point3.z;
460
+ subA(p) {
461
+ this.x -= p.x;
462
+ this.y -= p.y;
463
+ this.z -= p.z;
445
464
  return this;
446
465
  }
447
466
 
448
467
  /**
449
468
  * Gets vector subtraction.
450
469
  * @public
451
- * @param {Vec3} point3 - Subtract vector.
470
+ * @param {Vec3} p - Subtract vector.
452
471
  * @return {Vec3} Returns new instance of a subtraction
453
472
  */
454
- sub(point3) {
455
- return new Vec3(this.x - point3.x, this.y - point3.y, this.z - point3.z);
473
+ sub(p) {
474
+ return new Vec3(this.x - p.x, this.y - p.y, this.z - p.z);
456
475
  }
457
476
 
458
477
  /**
@@ -527,11 +546,11 @@ export class Vec3 {
527
546
  /**
528
547
  * Gets vectors dot production.
529
548
  * @public
530
- * @param {Vec3} point3 - Another vector.
549
+ * @param {Vec3} a - Another vector.
531
550
  * @returns {number} -
532
551
  */
533
- dot(point3) {
534
- return point3.x * this.x + point3.y * this.y + point3.z * this.z;
552
+ dot(a) {
553
+ return a.x * this.x + a.y * this.y + a.z * this.z;
535
554
  }
536
555
 
537
556
  /**
@@ -696,26 +715,26 @@ export class Vec3 {
696
715
  /**
697
716
  * Gets distance to point.
698
717
  * @public
699
- * @param {Vec3} point3 - Distant point.
718
+ * @param {Vec3} p - Distant point.
700
719
  * @returns {number} -
701
720
  */
702
- distance(point3) {
703
- let dx = this.x - point3.x,
704
- dy = this.y - point3.y,
705
- dz = this.z - point3.z;
721
+ distance(p) {
722
+ let dx = this.x - p.x,
723
+ dy = this.y - p.y,
724
+ dz = this.z - p.z;
706
725
  return Math.sqrt(dx * dx + dy * dy + dz * dz);
707
726
  }
708
727
 
709
728
  /**
710
729
  * Gets square distance to point.
711
730
  * @public
712
- * @param {Vec3} point3 - Distant point.
731
+ * @param {Vec3} p - Distant point.
713
732
  * @returns {number} -
714
733
  */
715
- distance2(point3) {
716
- let dx = this.x - point3.x,
717
- dy = this.y - point3.y,
718
- dz = this.z - point3.z;
734
+ distance2(p) {
735
+ let dx = this.x - p.x,
736
+ dy = this.y - p.y,
737
+ dz = this.z - p.z;
719
738
  return dx * dx + dy * dy + dz * dz;
720
739
  }
721
740
 
@@ -106,9 +106,8 @@ export class Vec4 {
106
106
  * Converts vector to a number array.
107
107
  * @public
108
108
  * @returns {Array.<number>} - (exactly 4 entries)
109
- * @deprecated
110
109
  */
111
- toVec() {
110
+ toArray() {
112
111
  return [this.x, this.y, this.z, this.w];
113
112
  }
114
113
 
@@ -117,8 +116,8 @@ export class Vec4 {
117
116
  * @public
118
117
  * @returns {Array.<number>} - (exactly 4 entries)
119
118
  */
120
- toArray() {
121
- return [this.x, this.y, this.z, this.w];
119
+ toArray3() {
120
+ return [this.x, this.y, this.z];
122
121
  }
123
122
 
124
123
  /**
package/src/og/math.js CHANGED
@@ -49,26 +49,26 @@ export const DEGREES_TO_HOURS = 1.0 / 15.0;
49
49
  /** @const */
50
50
  export const SQRT_HALF = Math.sqrt(0.5);
51
51
 
52
- export const EPSILON1 = 0.1;
53
- export const EPSILON2 = 0.01;
54
- export const EPSILON3 = 0.001;
55
- export const EPSILON4 = 0.0001;
56
- export const EPSILON5 = 0.00001;
57
- export const EPSILON6 = 0.000001;
58
- export const EPSILON7 = 1e-7;
59
- export const EPSILON8 = 1e-8;
60
- export const EPSILON9 = 1e-9;
61
- export const EPSILON10 = 1e-10;
62
- export const EPSILON11 = 1e-11;
63
- export const EPSILON12 = 1e-12;
64
- export const EPSILON13 = 1e-13;
65
- export const EPSILON14 = 1e-14;
66
- export const EPSILON15 = 1e-15;
67
- export const EPSILON16 = 1e-16;
68
- export const EPSILON17 = 1e-17;
69
- export const EPSILON18 = 1e-18;
70
- export const EPSILON19 = 1e-19;
71
- export const EPSILON20 = 1e-20;
52
+ export const EPS1 = 0.1;
53
+ export const EPS2 = 0.01;
54
+ export const EPS3 = 0.001;
55
+ export const EPS4 = 0.0001;
56
+ export const EPS5 = 0.00001;
57
+ export const EPS6 = 0.000001;
58
+ export const EPS7 = 1e-7;
59
+ export const EPS8 = 1e-8;
60
+ export const EPS9 = 1e-9;
61
+ export const EPS10 = 1e-10;
62
+ export const EPS11 = 1e-11;
63
+ export const EPS12 = 1e-12;
64
+ export const EPS13 = 1e-13;
65
+ export const EPS14 = 1e-14;
66
+ export const EPS15 = 1e-15;
67
+ export const EPS16 = 1e-16;
68
+ export const EPS17 = 1e-17;
69
+ export const EPS18 = 1e-18;
70
+ export const EPS19 = 1e-19;
71
+ export const EPS20 = 1e-20;
72
72
 
73
73
  /**
74
74
  * The log function returns the power to which the base value has to be raised to produce n.
@@ -201,7 +201,7 @@ export function mod(m, n) {
201
201
  */
202
202
  export function zeroTwoPI(a) {
203
203
  const res = mod(a, TWO_PI);
204
- if (Math.abs(res) < EPSILON14 && Math.abs(a) > EPSILON14) {
204
+ if (Math.abs(res) < EPS14 && Math.abs(a) > EPS14) {
205
205
  return TWO_PI;
206
206
  }
207
207
  return res;
@@ -230,12 +230,12 @@ class Node {
230
230
  }
231
231
 
232
232
  if (this.inFrustum || this._cameraInside || seg.tileZoom < 3) {
233
- let h = cam._lonLat.height;
233
+ let h = Math.abs(cam._lonLat.height);
234
234
 
235
235
  let eye = cam.eye;
236
236
  let horizonDist = eye.length2() - this.planet.ellipsoid._b2;
237
237
 
238
- let altVis = seg.tileZoom > 19 || (seg.tileZoom < 4 && !seg.terrainReady) || seg.tileZoom < 2;
238
+ let altVis = seg.tileZoom > 19 || (seg.tileZoom < 5 && !seg.terrainReady) || seg.tileZoom < 2;
239
239
 
240
240
  if (h > 21000) {
241
241
  altVis = altVis || eye.distance2(seg._sw) < horizonDist || eye.distance2(seg._nw) < horizonDist || eye.distance2(seg._ne) < horizonDist || eye.distance2(seg._se) < horizonDist;
@@ -351,7 +351,8 @@ class Node {
351
351
  var bp = ni.segment;
352
352
  var ld = ap.gridSize / (bp.gridSize * Math.pow(2, bp.tileZoom - ap.tileZoom));
353
353
 
354
- let cs_size = ap.gridSize, opcs_size = bp.gridSize;
354
+ let cs_size = ap.gridSize,
355
+ opcs_size = bp.gridSize;
355
356
 
356
357
  if (ld > 1) {
357
358
  cs_size = Math.ceil(ap.gridSize / ld);
@@ -786,4 +787,4 @@ class Node {
786
787
  }
787
788
  }
788
789
 
789
- export { Node };
790
+ export { Node };
@@ -0,0 +1,12 @@
1
+ import { EarthQuadTreeStrategy } from "./EarthQuadTreeStrategy.js";
2
+ import { MarsQuadTreeStrategy } from "./MarsQuadTreeStrategy.js";
3
+ import { Wgs84QuadTreeStrategy } from "./Wgs84QuadTreeStrategy.js";
4
+ import { QuadTreeStrategy } from "./QuadTreeStrategy.js";
5
+
6
+ const quadTreeStrategyType = {
7
+ earth: EarthQuadTreeStrategy,
8
+ mars: MarsQuadTreeStrategy,
9
+ wgs84: Wgs84QuadTreeStrategy
10
+ }
11
+
12
+ export { quadTreeStrategyType, QuadTreeStrategy, Wgs84QuadTreeStrategy, MarsQuadTreeStrategy, EarthQuadTreeStrategy };
@@ -21,6 +21,10 @@ let __pickingCallbackCounter__ = 0;
21
21
 
22
22
  let __depthCallbackCounter__ = 0;
23
23
 
24
+ const DIFFUSE = 0;
25
+ const NORMAL = 1;
26
+ const POSITION = 2;
27
+
24
28
  /**
25
29
  * Represents high level WebGL context interface that starts WebGL handler working in real time.
26
30
  * @class
@@ -54,6 +58,9 @@ let __depthCallbackCounter__ = 0;
54
58
  * @fires og.RendererEvents#touchleave
55
59
  * @fires og.RendererEvents#touchenter
56
60
  */
61
+
62
+ let __resizeTimeout;
63
+
57
64
  class Renderer {
58
65
  constructor(handler, params) {
59
66
  params = params || {};
@@ -80,8 +87,6 @@ class Renderer {
80
87
 
81
88
  this.brightThreshold = 0.9;
82
89
 
83
- this.backgroundColor = params.backgroundColor || new Vec3(115 / 255, 203 / 255, 249 / 255);
84
-
85
90
  /**
86
91
  * Render nodes drawing queue.
87
92
  * @private
@@ -192,6 +197,13 @@ class Renderer {
192
197
  * @type {utils.TextureAtlas}
193
198
  */
194
199
  this.billboardsTextureAtlas = new TextureAtlas();
200
+ //TODO global texture atlas
201
+ /**
202
+ * Texture atlas for the billboards images. One atlas per node.
203
+ * @protected
204
+ * @type {utils.TextureAtlas}
205
+ */
206
+ this.geoObjectsTextureAtlas = new TextureAtlas();
195
207
 
196
208
  /**
197
209
  * Texture font atlas for the font families and styles. One atlas per node.
@@ -209,6 +221,8 @@ class Renderer {
209
221
 
210
222
  this._currentOutput = "screen";
211
223
 
224
+ this._fnScreenFrame = null;
225
+
212
226
  this.labelWorker = new LabelWorker(4);
213
227
  }
214
228
 
@@ -386,6 +400,7 @@ class Renderer {
386
400
  var that = this;
387
401
 
388
402
  this.billboardsTextureAtlas.assignHandler(this.handler);
403
+ this.geoObjectsTextureAtlas.assignHandler(this.handler);
389
404
 
390
405
  this.fontAtlas.assignHandler(this.handler);
391
406
 
@@ -456,6 +471,7 @@ class Renderer {
456
471
  }).init();
457
472
 
458
473
  this.blitFramebuffer = new Framebuffer(this.handler, {
474
+ size: 1,
459
475
  useDepth: false,
460
476
  internalFormat: this._internalFormat,
461
477
  format: this._format,
@@ -478,11 +494,16 @@ class Renderer {
478
494
  }
479
495
 
480
496
  this.handler.ONCANVASRESIZE = () => {
481
- this.resize();
497
+ this._resizeStart();
482
498
  this.events.dispatch(this.events.resize, this.handler.canvas);
499
+ clearTimeout(__resizeTimeout);
500
+ __resizeTimeout = setTimeout(() => {
501
+ this._resizeEnd();
502
+ this.events.dispatch(this.events.resizeend, this.handler.canvas);
503
+ }, 320);
483
504
  };
484
505
 
485
- this._screenFrameCornersBuffer = this.handler.createArrayBuffer(
506
+ this.screenFramePositionBuffer = this.handler.createArrayBuffer(
486
507
  new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]),
487
508
  2,
488
509
  4
@@ -499,6 +520,10 @@ class Renderer {
499
520
  this.fontAtlas.initFont("arial", arial.data, arial.image);
500
521
  }
501
522
 
523
+ resize() {
524
+ this._resizeEnd();
525
+ }
526
+
502
527
  setCurrentScreen(screenName) {
503
528
  this._currentOutput = screenName;
504
529
  if (this.screenTexture[screenName]) {
@@ -506,22 +531,24 @@ class Renderer {
506
531
  }
507
532
  }
508
533
 
509
- resize() {
534
+ _resizeStart() {
510
535
  let c = this.handler.canvas;
511
- this.activeCamera.setAspectRatio(c.width / c.height);
512
- this.sceneFramebuffer.setSize(c.width, c.height);
513
536
 
514
- this.blitFramebuffer &&
515
- this.blitFramebuffer.setSize(c.width, c.height, true);
537
+ this.activeCamera.setAspectRatio(c.width / c.height);
538
+ this.sceneFramebuffer.setSize(c.width * 0.5, c.height * 0.5);
539
+ this.blitFramebuffer && this.blitFramebuffer.setSize(c.width * 0.5, c.height * 0.5, true);
540
+ }
516
541
 
517
- this.toneMappingFramebuffer &&
518
- this.toneMappingFramebuffer.setSize(c.width, c.height, true);
542
+ _resizeEnd() {
543
+ let c = this.handler.canvas;
519
544
 
520
- this.depthFramebuffer &&
521
- this.depthFramebuffer.setSize(c.clientWidth, c.clientHeight, true);
545
+ this.activeCamera.setAspectRatio(c.width / c.height);
546
+ this.sceneFramebuffer.setSize(c.width, c.height);
547
+ this.blitFramebuffer && this.blitFramebuffer.setSize(c.width, c.height, true);
522
548
 
523
- this.screenDepthFramebuffer &&
524
- this.screenDepthFramebuffer.setSize(c.clientWidth, c.clientHeight, true);
549
+ this.toneMappingFramebuffer && this.toneMappingFramebuffer.setSize(c.width, c.height, true);
550
+ this.depthFramebuffer && this.depthFramebuffer.setSize(c.clientWidth, c.clientHeight, true);
551
+ this.screenDepthFramebuffer && this.screenDepthFramebuffer.setSize(c.clientWidth, c.clientHeight, true);
525
552
 
526
553
  if (this.handler.gl.type === "webgl") {
527
554
  this.screenTexture.screen = this.sceneFramebuffer.textures[0];
@@ -714,35 +741,35 @@ class Renderer {
714
741
  let e = this.events;
715
742
  e.handleEvents();
716
743
 
717
- let sfb = this.sceneFramebuffer;
718
- sfb.activate();
744
+ let sceneFramebuffer = this.sceneFramebuffer;
745
+ sceneFramebuffer.activate();
719
746
 
720
- let h = this.handler;
747
+ let h = this.handler,
748
+ gl = h.gl;
721
749
 
722
- h.gl.clearColor(
723
- this.backgroundColor.x,
724
- this.backgroundColor.y,
725
- this.backgroundColor.z,
726
- 1.0
727
- );
728
- h.gl.clear(h.gl.COLOR_BUFFER_BIT | h.gl.DEPTH_BUFFER_BIT);
750
+ gl.blendEquation(gl.FUNC_ADD);
751
+ gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
752
+ gl.enable(gl.BLEND);
753
+ gl.clearColor(0.0, 0.0, 0.0, 0.0);
754
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
729
755
 
730
756
  e.dispatch(e.draw, this);
731
757
 
732
758
  let frustums = this.activeCamera.frustums;
733
759
 
734
- let pointerEvent = e.pointerEvent() || this.activeCamera.isMoved;
760
+ let pointerEvent = e.pointerEvent() || this.activeCamera.isMoving;
735
761
 
736
762
  // Rendering scene nodes and entityCollections
737
763
  let rn = this._renderNodesArr;
738
764
  let k = frustums.length;
739
765
  while (k--) {
740
766
  this.activeCamera.setCurrentFrustum(k);
741
- h.gl.clear(h.gl.DEPTH_BUFFER_BIT);
767
+ gl.clear(gl.DEPTH_BUFFER_BIT);
742
768
  let i = rn.length;
743
769
  while (i--) {
744
770
  rn[i].drawNode();
745
771
  }
772
+
746
773
  this._drawEntityCollections();
747
774
 
748
775
  if (pointerEvent) {
@@ -750,16 +777,15 @@ class Renderer {
750
777
  }
751
778
  }
752
779
 
753
- sfb.deactivate();
780
+ sceneFramebuffer.deactivate();
754
781
 
755
- this.blitFramebuffer && sfb.blitTo(this.blitFramebuffer);
782
+ this.blitFramebuffer && sceneFramebuffer.blitTo(this.blitFramebuffer, 0);
756
783
 
757
784
  if (pointerEvent) {
758
785
  // It works ONLY for 0 (closest) frustum
759
786
  if (h.isWebGl2()) {
760
787
  this._drawDepthBuffer();
761
788
  }
762
-
763
789
  this._readPickingColor();
764
790
  }
765
791
 
@@ -783,7 +809,7 @@ class Renderer {
783
809
 
784
810
  gl.disable(gl.DEPTH_TEST);
785
811
 
786
- gl.bindBuffer(gl.ARRAY_BUFFER, this._screenFrameCornersBuffer);
812
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.screenFramePositionBuffer);
787
813
  gl.vertexAttribPointer(p.attributes.corners, 2, gl.FLOAT, false, 0, 0);
788
814
 
789
815
  this.toneMappingFramebuffer.activate();
@@ -802,10 +828,10 @@ class Renderer {
802
828
 
803
829
  this.toneMappingFramebuffer.deactivate();
804
830
 
831
+ // SCREEN PASS
805
832
  sh = h.programs.screenFrame;
806
833
  p = sh._program;
807
834
  gl = h.gl;
808
-
809
835
  sh.activate();
810
836
  gl.activeTexture(gl.TEXTURE0);
811
837
  gl.bindTexture(gl.TEXTURE_2D, this.outputTexture);
@@ -816,6 +842,7 @@ class Renderer {
816
842
  }
817
843
 
818
844
  _screenFrameNoMSAA() {
845
+
819
846
  var h = this.handler;
820
847
  var sh = h.programs.screenFrame,
821
848
  p = sh._program,
@@ -826,7 +853,7 @@ class Renderer {
826
853
  gl.activeTexture(gl.TEXTURE0);
827
854
  gl.bindTexture(gl.TEXTURE_2D, this.outputTexture);
828
855
  gl.uniform1i(p.uniforms.texture, 0);
829
- gl.bindBuffer(gl.ARRAY_BUFFER, this._screenFrameCornersBuffer);
856
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.screenFramePositionBuffer);
830
857
  gl.vertexAttribPointer(p.attributes.corners, 2, gl.FLOAT, false, 0, 0);
831
858
  gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
832
859
  gl.enable(gl.DEPTH_TEST);
@@ -842,7 +869,7 @@ class Renderer {
842
869
  var h = this.handler;
843
870
  var gl = h.gl;
844
871
 
845
- if (frustumIndex === this.activeCamera.FARTHEST_FRUSTUM_INDEX) {
872
+ if (this.activeCamera.isFirstPass) {
846
873
  gl.clearColor(0.0, 0.0, 0.0, 1.0);
847
874
  gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
848
875
  } else {
@@ -851,8 +878,8 @@ class Renderer {
851
878
 
852
879
  gl.disable(h.gl.BLEND);
853
880
 
854
- var dp = this._pickingCallbacks;
855
- var i = dp.length;
881
+ let dp = this._pickingCallbacks;
882
+ let i = dp.length;
856
883
  while (i--) {
857
884
  /**
858
885
  * This callback renders picking frame.
@@ -895,7 +922,7 @@ class Renderer {
895
922
 
896
923
  gl = h.gl;
897
924
 
898
- gl.bindBuffer(gl.ARRAY_BUFFER, this._screenFrameCornersBuffer);
925
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.screenFramePositionBuffer);
899
926
  gl.vertexAttribPointer(p.attributes.corners, 2, gl.FLOAT, false, 0, 0);
900
927
 
901
928
  sh.activate();