@openglobus/og 0.15.5 → 0.16.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 (126) hide show
  1. package/README.md +1 -1
  2. package/css/og.css +1 -1
  3. package/dist/@openglobus/og.css +1 -1
  4. package/dist/@openglobus/og.esm.js +2 -2
  5. package/dist/@openglobus/og.esm.js.map +1 -1
  6. package/dist/@openglobus/og.umd.js +2 -2
  7. package/dist/@openglobus/og.umd.js.map +1 -1
  8. package/package.json +13 -15
  9. package/src/og/Globe.js +5 -2
  10. package/src/og/LonLat.js +18 -1
  11. package/src/og/Object3d.js +21 -2
  12. package/src/og/bv/index.js +2 -2
  13. package/src/og/camera/PlanetCamera.js +4 -10
  14. package/src/og/control/LayerSwitcher.js +4 -3
  15. package/src/og/control/RulerSwitcher.js +2 -2
  16. package/src/og/control/ZoomControl.js +2 -2
  17. package/src/og/control/heightRuler/HeightRulerScene.js +6 -2
  18. package/src/og/control/index.js +5 -2
  19. package/src/og/control/ruler/RulerScene.js +11 -8
  20. package/src/og/control/timeline/TimelineControl.js +5 -3
  21. package/src/og/control/timeline/TimelineModel.js +4 -0
  22. package/src/og/control/timeline/TimelineView.js +10 -3
  23. package/src/og/control/visibleExtent/Segment.js +36 -42
  24. package/src/og/ellipsoid/Ellipsoid.js +23 -10
  25. package/src/og/entity/Entity.js +3 -3
  26. package/src/og/entity/EntityCollection.js +2 -2
  27. package/src/og/entity/Label.js +1 -1
  28. package/src/og/entity/Polyline.js +4 -2
  29. package/src/og/index.js +4 -7
  30. package/src/og/layer/CanvasTiles.js +70 -23
  31. package/src/og/layer/GeoImage.js +40 -18
  32. package/src/og/layer/Vector.js +14 -11
  33. package/src/og/layer/WMS.js +2 -2
  34. package/src/og/math.js +2 -1
  35. package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +26 -0
  36. package/src/og/quadTree/Node.js +44 -50
  37. package/src/og/quadTree/index.js +2 -0
  38. package/src/og/renderer/Renderer.js +13 -1
  39. package/src/og/scene/Planet.js +4 -4
  40. package/src/og/scene/index.js +3 -3
  41. package/src/og/segment/Segment.js +88 -76
  42. package/src/og/shaders/drawnode.js +138 -89
  43. package/src/og/shaders/geoObject.js +57 -46
  44. package/src/og/shaders/ray.js +15 -21
  45. package/src/og/terrain/EmptyTerrain.js +19 -7
  46. package/src/og/terrain/GlobusTerrain.js +23 -18
  47. package/src/og/terrain/MapboxTerrain.js +7 -8
  48. package/src/og/terrain/index.js +4 -4
  49. package/src/og/utils/objParser.js +227 -0
  50. package/src/og/utils/shared.js +9 -0
  51. package/src/og/webgl/Handler.js +1 -3
  52. package/types/Globe.d.ts +2 -0
  53. package/types/LonLat.d.ts +12 -1
  54. package/types/Object3d.d.ts +2 -0
  55. package/types/Popup.d.ts +1 -1
  56. package/types/bv/index.d.ts +2 -2
  57. package/types/camera/PlanetCamera.d.ts +0 -7
  58. package/types/camera/index.d.ts +2 -2
  59. package/types/control/GeoImageDragControl.d.ts +1 -1
  60. package/types/control/LayerAnimation.d.ts +1 -1
  61. package/types/control/Lighting.d.ts +2 -2
  62. package/types/control/heightRuler/HeightRulerScene.d.ts +1 -1
  63. package/types/control/index.d.ts +3 -2
  64. package/types/control/ruler/RulerScene.d.ts +5 -4
  65. package/types/control/selection/SelectionScene.d.ts +3 -3
  66. package/types/control/timeline/TimelineControl.d.ts +10 -0
  67. package/types/control/timeline/TimelineModel.d.ts +33 -0
  68. package/types/control/timeline/TimelineView.d.ts +57 -0
  69. package/types/control/timeline/timelineUtils.d.ts +9 -0
  70. package/types/ellipsoid/Ellipsoid.d.ts +16 -9
  71. package/types/ellipsoid/index.d.ts +2 -2
  72. package/types/entity/Entity.d.ts +3 -3
  73. package/types/entity/EntityCollection.d.ts +2 -2
  74. package/types/entity/Label.d.ts +1 -1
  75. package/types/entity/Polyline.d.ts +1 -0
  76. package/types/index.d.ts +45 -46
  77. package/types/layer/CanvasTiles.d.ts +2 -1
  78. package/types/layer/GeoImage.d.ts +7 -1
  79. package/types/layer/GeoTexture2d.d.ts +1 -1
  80. package/types/layer/Vector.d.ts +3 -3
  81. package/types/layer/index.d.ts +9 -9
  82. package/types/math/Line2.d.ts +1 -1
  83. package/types/math/Line3.d.ts +1 -1
  84. package/types/math/index.d.ts +10 -10
  85. package/types/mercator.d.ts +1 -1
  86. package/types/quadTree/EPSG4326QuadTreeStrategy.d.ts +3 -0
  87. package/types/quadTree/EntityCollectionNode.d.ts +1 -1
  88. package/types/quadTree/index.d.ts +2 -0
  89. package/types/renderer/Renderer.d.ts +2 -2
  90. package/types/scene/Axes.d.ts +1 -1
  91. package/types/scene/SkyBox.d.ts +1 -1
  92. package/types/scene/index.d.ts +3 -3
  93. package/types/segment/Segment.d.ts +9 -11
  94. package/types/shaders/atmos.d.ts +1 -1
  95. package/types/shaders/billboard.d.ts +1 -1
  96. package/types/shaders/depth.d.ts +1 -1
  97. package/types/shaders/label.d.ts +1 -1
  98. package/types/shaders/pickingMask.d.ts +1 -1
  99. package/types/shaders/pointCloud.d.ts +1 -1
  100. package/types/shaders/polyline.d.ts +1 -1
  101. package/types/shaders/ray.d.ts +1 -1
  102. package/types/shaders/screenFrame.d.ts +1 -1
  103. package/types/shaders/skybox.d.ts +1 -1
  104. package/types/shaders/toneMapping.d.ts +1 -1
  105. package/types/terrain/BilTerrain.d.ts +1 -0
  106. package/types/terrain/EmptyTerrain.d.ts +13 -2
  107. package/types/terrain/GlobusTerrain.d.ts +2 -1
  108. package/types/terrain/MapboxTerrain.d.ts +1 -3
  109. package/types/terrain/index.d.ts +4 -4
  110. package/types/ui/Button.d.ts +1 -1
  111. package/types/ui/ButtonGroup.d.ts +12 -0
  112. package/types/ui/Dialog.d.ts +2 -2
  113. package/types/ui/Slider.d.ts +1 -1
  114. package/types/ui/ToggleButton.d.ts +1 -1
  115. package/types/ui/View.d.ts +1 -1
  116. package/types/utils/GeoImageCreator.d.ts +2 -2
  117. package/types/utils/ImagesCacheManager.d.ts +1 -1
  118. package/types/utils/Loader.d.ts +1 -1
  119. package/types/utils/VectorTileCreator.d.ts +1 -1
  120. package/types/utils/objParser.d.ts +8 -0
  121. package/types/utils/shared.d.ts +6 -0
  122. package/types/webgl/Handler.d.ts +2 -2
  123. package/src/og/index.core.js +0 -116
  124. package/src/og/index.webgl.js +0 -17
  125. package/types/index.core.d.ts +0 -65
  126. package/types/index.webgl.d.ts +0 -7
@@ -48,10 +48,15 @@ export function drawnode_screen_nl() {
48
48
  defaultTexture: "sampler2d",
49
49
  height: "float"
50
50
  }, attributes: {
51
- aVertexPositionHigh: "vec3", aVertexPositionLow: "vec3", aTextureCoord: "vec2"
51
+ aVertexPositionHigh: "vec3",
52
+ aVertexPositionLow: "vec3",
53
+ aTextureCoord: "vec2"
52
54
  },
53
55
 
54
- vertexShader: `attribute vec3 aVertexPositionHigh;
56
+ vertexShader:
57
+ `precision highp float;
58
+
59
+ attribute vec3 aVertexPositionHigh;
55
60
  attribute vec3 aVertexPositionLow;
56
61
  attribute vec2 aTextureCoord;
57
62
 
@@ -64,16 +69,19 @@ export function drawnode_screen_nl() {
64
69
  varying vec2 vTextureCoord;
65
70
 
66
71
  void main(void) {
67
- vTextureCoord = aTextureCoord;
68
72
 
69
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
70
- vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
71
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
73
+ vTextureCoord = aTextureCoord;
74
+ vec3 nh = height * normalize(aVertexPositionHigh + aVertexPositionLow);
72
75
 
73
76
  mat4 viewMatrixRTE = viewMatrix;
74
77
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
75
-
76
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
78
+ mat4 m = projectionMatrix * viewMatrixRTE;
79
+
80
+ vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
81
+ vec3 lowDiff = aVertexPositionLow - eyePositionLow + nh;
82
+
83
+ // This is works for Mac Chrome, prevent some weird optimization I suppose
84
+ gl_Position = m * vec4(highDiff + lowDiff, 1.0);
77
85
  }`,
78
86
 
79
87
  fragmentShader: `precision highp float;
@@ -151,37 +159,39 @@ export function drawnode_screen_wl_webgl1NoAtmos() {
151
159
 
152
160
  uniform mat4 projectionMatrix;
153
161
  uniform mat4 viewMatrix;
154
- uniform float height;
155
162
  uniform vec4 uGlobalTextureCoord;
156
163
  uniform vec3 uNormalMapBias;
157
164
  uniform vec3 eyePositionHigh;
158
165
  uniform vec3 eyePositionLow;
166
+ uniform float height;
159
167
 
160
168
  varying vec4 vTextureCoord;
161
- varying vec2 vGlobalTextureCoord;
162
169
  varying vec3 v_vertex;
163
- varying float v_height;
164
170
  varying vec3 cameraPosition;
171
+ varying vec2 vGlobalTextureCoord;
172
+ varying float v_height;
165
173
 
166
174
  void main(void) {
167
175
 
168
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
169
-
176
+ // I replace it here (from the bottom) because it
177
+ // somehow affects on float precision on MacPC Chrome
178
+ vTextureCoord.xy = aTextureCoord;
179
+ vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
180
+ vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
181
+
182
+ vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
183
+ vec3 nh = height * normalize(aVertexPosition);
170
184
  cameraPosition = eyePositionHigh + eyePositionLow;
171
185
 
172
186
  vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
173
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
187
+ vec3 lowDiff = aVertexPositionLow - eyePositionLow + nh;
174
188
 
175
189
  mat4 viewMatrixRTE = viewMatrix;
176
190
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
177
191
 
178
192
  v_height = height;
179
- v_vertex = aVertexPosition + normalize(aVertexPosition) * height;
180
-
181
- vTextureCoord.xy = aTextureCoord;
182
- vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
183
- vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
184
-
193
+ v_vertex = aVertexPosition + nh;
194
+
185
195
  gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
186
196
  }`,
187
197
 
@@ -192,23 +202,22 @@ export function drawnode_screen_wl_webgl1NoAtmos() {
192
202
  #define MAX_POINT_LIGHTS 1
193
203
  #define SLICE_SIZE ${SLICE_SIZE + 1}
194
204
 
205
+ uniform vec4 specular;
195
206
  uniform vec3 diffuse;
196
207
  uniform vec3 ambient;
197
- uniform vec4 specular;
198
208
 
199
209
  uniform sampler2D uNormalMap;
200
- uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
201
210
  uniform sampler2D nightTexture;
202
211
  uniform sampler2D specularTexture;
212
+ uniform sampler2D defaultTexture;
213
+ uniform sampler2D samplerArr[SLICE_SIZE];
203
214
 
204
215
  uniform vec4 tileOffsetArr[SLICE_SIZE];
216
+ uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
205
217
  uniform float layerOpacityArr[SLICE_SIZE];
206
218
 
207
- uniform sampler2D defaultTexture;
208
- uniform sampler2D samplerArr[SLICE_SIZE];
209
219
  uniform int samplerCount;
210
- uniform float nightTextureCoefficient;
211
-
220
+ uniform float nightTextureCoefficient;
212
221
  uniform float camHeight;
213
222
 
214
223
  varying vec4 vTextureCoord;
@@ -330,43 +339,47 @@ export function drawnode_screen_wl_webgl2NoAtmos() {
330
339
  vertexShader:
331
340
  `#version 300 es
332
341
 
342
+ precision highp float;
343
+
333
344
  in vec3 aVertexPositionHigh;
334
345
  in vec3 aVertexPositionLow;
335
346
  in vec2 aTextureCoord;
336
347
 
337
348
  uniform mat4 projectionMatrix;
338
349
  uniform mat4 viewMatrix;
339
- uniform float height;
340
350
  uniform vec4 uGlobalTextureCoord;
341
351
  uniform vec3 uNormalMapBias;
342
352
  uniform vec3 eyePositionHigh;
343
353
  uniform vec3 eyePositionLow;
354
+ uniform float height;
344
355
 
345
356
  out vec4 vTextureCoord;
346
- out vec2 vGlobalTextureCoord;
347
357
  out vec3 v_vertex;
348
- out float v_height;
349
358
  out vec3 cameraPosition;
359
+ out vec2 vGlobalTextureCoord;
360
+ out float v_height;
350
361
 
351
362
  void main(void) {
352
363
 
353
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
354
-
364
+ // I replace it here (from the bottom) because it
365
+ // somehow affects on float precision on MacPC Chrome
366
+ vTextureCoord.xy = aTextureCoord;
367
+ vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
368
+ vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
369
+
370
+ vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
371
+ vec3 nh = height * normalize(aVertexPosition);
355
372
  cameraPosition = eyePositionHigh + eyePositionLow;
356
373
 
357
374
  vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
358
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
375
+ vec3 lowDiff = aVertexPositionLow - eyePositionLow + nh;
359
376
 
360
377
  mat4 viewMatrixRTE = viewMatrix;
361
378
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
362
379
 
363
380
  v_height = height;
364
- v_vertex = aVertexPosition + normalize(aVertexPosition) * height;
365
-
366
- vTextureCoord.xy = aTextureCoord;
367
- vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
368
- vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
369
-
381
+ v_vertex = aVertexPosition + nh;
382
+
370
383
  gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
371
384
  }`,
372
385
 
@@ -378,20 +391,20 @@ export function drawnode_screen_wl_webgl2NoAtmos() {
378
391
  #define MAX_POINT_LIGHTS 1
379
392
  #define SLICE_SIZE ${SLICE_SIZE + 1}
380
393
 
394
+ uniform vec4 specular;
381
395
  uniform vec3 diffuse;
382
- uniform vec3 ambient;
383
- uniform vec4 specular;
396
+ uniform vec3 ambient;
384
397
 
385
398
  uniform sampler2D uNormalMap;
386
- uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
387
399
  uniform sampler2D nightTexture;
388
400
  uniform sampler2D specularTexture;
401
+ uniform sampler2D defaultTexture;
402
+ uniform sampler2D samplerArr[SLICE_SIZE];
389
403
 
390
404
  uniform vec4 tileOffsetArr[SLICE_SIZE];
405
+ uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
391
406
  uniform float layerOpacityArr[SLICE_SIZE];
392
407
 
393
- uniform sampler2D defaultTexture;
394
- uniform sampler2D samplerArr[SLICE_SIZE];
395
408
  uniform int samplerCount;
396
409
  uniform float nightTextureCoefficient;
397
410
 
@@ -522,6 +535,8 @@ export function drawnode_screen_wl_webgl2Atmos() {
522
535
  vertexShader:
523
536
  `#version 300 es
524
537
 
538
+ precision highp float;
539
+
525
540
  in vec3 aVertexPositionHigh;
526
541
  in vec3 aVertexPositionLow;
527
542
  in vec2 aTextureCoord;
@@ -535,30 +550,32 @@ export function drawnode_screen_wl_webgl2Atmos() {
535
550
  uniform float height;
536
551
 
537
552
  out vec4 vTextureCoord;
538
- out vec2 vGlobalTextureCoord;
539
553
  out vec3 v_vertex;
540
- out float v_height;
541
554
  out vec3 cameraPosition;
555
+ out vec2 vGlobalTextureCoord;
556
+ out float v_height;
542
557
 
543
558
  void main(void) {
544
559
 
545
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
546
-
560
+ // I replace it here (from the bottom) because it
561
+ // somehow affects on float precision on MacPC Chrome
562
+ vTextureCoord.xy = aTextureCoord;
563
+ vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
564
+ vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
565
+
566
+ vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
567
+ vec3 nh = height * normalize(aVertexPosition);
547
568
  cameraPosition = eyePositionHigh + eyePositionLow;
548
569
 
549
570
  vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
550
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
571
+ vec3 lowDiff = aVertexPositionLow - eyePositionLow + nh;
551
572
 
552
573
  mat4 viewMatrixRTE = viewMatrix;
553
574
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
554
575
 
555
576
  v_height = height;
556
- v_vertex = aVertexPosition + normalize(aVertexPosition) * height;
557
-
558
- vTextureCoord.xy = aTextureCoord;
559
- vGlobalTextureCoord = uGlobalTextureCoord.xy + (uGlobalTextureCoord.zw - uGlobalTextureCoord.xy) * aTextureCoord;
560
- vTextureCoord.zw = uNormalMapBias.z * ( aTextureCoord + uNormalMapBias.xy );
561
-
577
+ v_vertex = aVertexPosition + nh;
578
+
562
579
  gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
563
580
  }`,
564
581
 
@@ -570,28 +587,27 @@ export function drawnode_screen_wl_webgl2Atmos() {
570
587
  #define MAX_POINT_LIGHTS 1
571
588
  #define SLICE_SIZE ${SLICE_SIZE + 1}
572
589
 
590
+ uniform vec4 specular;
573
591
  uniform vec3 diffuse;
574
592
  uniform vec3 ambient;
575
- uniform vec4 specular;
576
593
 
577
- uniform sampler2D uNormalMap;
578
594
  uniform vec3 lightsPositions[MAX_POINT_LIGHTS];
595
+
596
+ uniform sampler2D uNormalMap;
579
597
  uniform sampler2D nightTexture;
580
598
  uniform sampler2D specularTexture;
581
-
582
599
  uniform sampler2D transmittanceTexture;
583
600
  uniform sampler2D scatteringTexture;
601
+ uniform sampler2D defaultTexture;
602
+ uniform sampler2D samplerArr[SLICE_SIZE];
584
603
 
585
604
  uniform vec4 tileOffsetArr[SLICE_SIZE];
586
605
  uniform float layerOpacityArr[SLICE_SIZE];
587
606
 
588
- uniform sampler2D defaultTexture;
589
- uniform sampler2D samplerArr[SLICE_SIZE];
590
607
  uniform int samplerCount;
591
608
  uniform float nightTextureCoefficient;
592
609
 
593
- uniform vec2 maxMinOpacity;
594
-
610
+ uniform vec2 maxMinOpacity;
595
611
  uniform float camHeight;
596
612
 
597
613
  in vec4 vTextureCoord;
@@ -828,7 +844,10 @@ export function drawnode_colorPicking() {
828
844
  aVertexPositionHigh: "vec3", aVertexPositionLow: "vec3", aTextureCoord: "vec2"
829
845
  },
830
846
 
831
- vertexShader: `attribute vec3 aVertexPositionHigh;
847
+ vertexShader:
848
+ `precision highp float;
849
+
850
+ attribute vec3 aVertexPositionHigh;
832
851
  attribute vec3 aVertexPositionLow;
833
852
  attribute vec2 aTextureCoord;
834
853
 
@@ -842,18 +861,23 @@ export function drawnode_colorPicking() {
842
861
 
843
862
  void main(void) {
844
863
 
845
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
846
- vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
847
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
864
+ vTextureCoord = aTextureCoord;
848
865
 
849
866
  mat4 viewMatrixRTE = viewMatrix;
850
867
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
851
868
 
852
- vTextureCoord = aTextureCoord;
853
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
869
+ mat4 m = projectionMatrix * viewMatrixRTE;
870
+
871
+ vec3 nh = height * normalize(aVertexPositionHigh + aVertexPositionLow);
872
+
873
+ vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
874
+ vec3 lowDiff = aVertexPositionLow - eyePositionLow + nh;
875
+
876
+ gl_Position = m * vec4(highDiff + lowDiff, 1.0);
854
877
  }`,
855
878
 
856
- fragmentShader: `precision highp float;
879
+ fragmentShader:
880
+ `precision highp float;
857
881
  #define SLICE_SIZE ${SLICE_SIZE + 1}
858
882
  uniform vec4 tileOffsetArr[SLICE_SIZE];
859
883
  uniform vec4 pickingColorArr[SLICE_SIZE];
@@ -901,35 +925,47 @@ export function drawnode_heightPicking() {
901
925
  aVertexPositionHigh: "vec3", aVertexPositionLow: "vec3"
902
926
  },
903
927
 
904
- vertexShader: `attribute vec3 aVertexPositionHigh;
928
+ vertexShader:
929
+ `precision highp float;
930
+
931
+ attribute vec3 aVertexPositionHigh;
905
932
  attribute vec3 aVertexPositionLow;
906
933
 
907
934
  uniform mat4 projectionMatrix;
908
935
  uniform mat4 viewMatrix;
909
- uniform float height;
910
936
  uniform vec3 eyePositionHigh;
911
937
  uniform vec3 eyePositionLow;
938
+ uniform float height;
912
939
 
913
- varying float range;
940
+ varying vec3 eyePosition;
941
+ varying vec3 vertexPosition;
914
942
 
915
943
  void main(void) {
916
944
 
917
- vec3 cameraPosition = eyePositionHigh + eyePositionLow;
918
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
919
-
920
- vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
921
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
945
+ // This code is works for Mac Chrome and Safari
946
+ // any other code probably will produce jittering
922
947
 
923
948
  mat4 viewMatrixRTE = viewMatrix;
924
949
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
925
950
 
926
- range = distance(cameraPosition, aVertexPosition + normalize(aVertexPosition) * height);
927
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
951
+ mat4 m = projectionMatrix * viewMatrixRTE;
952
+
953
+ vec3 nh = height * normalize(aVertexPositionHigh + aVertexPositionLow);
954
+
955
+ eyePosition = eyePositionHigh + eyePositionLow;
956
+ vertexPosition = aVertexPositionHigh + aVertexPositionLow;
957
+
958
+ vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
959
+ vec3 lowDiff = aVertexPositionLow - eyePositionLow + nh;
960
+
961
+ gl_Position = m * vec4(highDiff + lowDiff, 1.0);
928
962
  }`,
929
963
 
930
- fragmentShader: `precision highp float;
964
+ fragmentShader:
965
+ `precision highp float;
931
966
 
932
- varying float range;
967
+ varying vec3 eyePosition;
968
+ varying vec3 vertexPosition;
933
969
 
934
970
  vec3 encode24(highp float f) {
935
971
  float F = abs(f);
@@ -944,6 +980,7 @@ export function drawnode_heightPicking() {
944
980
  }
945
981
 
946
982
  void main(void) {
983
+ float range = distance(eyePosition, vertexPosition);
947
984
  gl_FragColor = vec4(encode24(range), 1.0);
948
985
  }`
949
986
  });
@@ -962,30 +999,42 @@ export function drawnode_depth() {
962
999
  aVertexPositionHigh: "vec3", aVertexPositionLow: "vec3"
963
1000
  },
964
1001
 
965
- vertexShader: `attribute vec3 aVertexPositionHigh;
1002
+ vertexShader:
1003
+ `precision highp float;
1004
+
1005
+ attribute vec3 aVertexPositionHigh;
966
1006
  attribute vec3 aVertexPositionLow;
967
1007
 
968
1008
  uniform mat4 projectionMatrix;
969
1009
  uniform mat4 viewMatrix;
970
- uniform float height;
971
1010
  uniform vec3 eyePositionHigh;
972
1011
  uniform vec3 eyePositionLow;
1012
+ uniform float height;
973
1013
 
974
1014
  void main(void) {
975
1015
 
976
- vec3 cameraPosition = eyePositionHigh + eyePositionLow;
977
- vec3 aVertexPosition = aVertexPositionHigh + aVertexPositionLow;
978
-
979
- vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
980
- vec3 lowDiff = aVertexPositionLow + normalize(aVertexPosition) * height - eyePositionLow;
1016
+ // @hack
1017
+ // This code is works for Mac Chrome and Safari
1018
+ // any other code probably will produce jittering
981
1019
 
982
1020
  mat4 viewMatrixRTE = viewMatrix;
983
1021
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
984
1022
 
985
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
1023
+ mat4 m = projectionMatrix * viewMatrixRTE;
1024
+
1025
+ vec3 nh = height * normalize(aVertexPositionHigh + aVertexPositionLow);
1026
+
1027
+ vec3 eyePosition = eyePositionHigh + eyePositionLow;
1028
+ vec3 vertexPosition = aVertexPositionHigh + aVertexPositionLow;
1029
+
1030
+ vec3 highDiff = aVertexPositionHigh - eyePositionHigh;
1031
+ vec3 lowDiff = aVertexPositionLow - eyePositionLow + nh;
1032
+
1033
+ gl_Position = m * vec4(highDiff + lowDiff, 1.0);
986
1034
  }`,
987
1035
 
988
- fragmentShader: `precision highp float;
1036
+ fragmentShader:
1037
+ `precision highp float;
989
1038
  uniform vec3 frustumPickingColor;
990
1039
 
991
1040
  void main(void) {
@@ -101,8 +101,6 @@ export const geo_object = () =>
101
101
  vec3 r = cross(normalize(-position), aDirection);
102
102
  mat3 modelMatrix = mat3(r, normalize(position), -aDirection) * rotX * rotZ;
103
103
 
104
- float dist = length(cameraPosition);
105
-
106
104
  mat4 viewMatrixRTE = viewMatrix;
107
105
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
108
106
 
@@ -126,8 +124,12 @@ export const geo_object = () =>
126
124
 
127
125
  vec3 vert = modelMatrix * aVertexPosition * aScale * scd;
128
126
  v_vertex = position + vert;
127
+
128
+ // @hack
129
+ // Mac/Safari affects on lowDiff somehow.
130
+ vert += lowDiff;
129
131
 
130
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff + vert, 1.0);
132
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + vert, 1.0);
131
133
  }`,
132
134
 
133
135
  fragmentShader: `precision highp float;
@@ -170,9 +172,7 @@ export const geo_object_picking = () =>
170
172
  uniforms: {
171
173
  viewMatrix: "mat4",
172
174
  projectionMatrix: "mat4",
173
-
174
175
  uScaleByDistance: "vec3",
175
-
176
176
  eyePositionHigh: "vec3",
177
177
  eyePositionLow: "vec3",
178
178
  pickingScale: "float"
@@ -193,18 +193,17 @@ export const geo_object_picking = () =>
193
193
  attribute vec3 aPositionHigh;
194
194
  attribute vec3 aPositionLow;
195
195
  attribute vec3 aDirection;
196
- attribute vec2 aPitchRoll;
197
196
  attribute vec3 aPickingColor;
197
+ attribute vec2 aPitchRoll;
198
198
  attribute float aScale;
199
199
  attribute float aDispose;
200
200
 
201
+ uniform vec3 eyePositionHigh;
202
+ uniform vec3 eyePositionLow;
201
203
  uniform vec3 uScaleByDistance;
202
204
  uniform mat4 projectionMatrix;
203
205
  uniform mat4 viewMatrix;
204
206
  uniform float pickingScale;
205
-
206
- uniform vec3 eyePositionHigh;
207
- uniform vec3 eyePositionLow;
208
207
 
209
208
  varying vec3 vColor;
210
209
 
@@ -213,46 +212,58 @@ export const geo_object_picking = () =>
213
212
  void main(void) {
214
213
 
215
214
  if (aDispose == 0.0) {
216
- return;
217
- }
215
+ return;
216
+ }
218
217
 
219
- vColor = aPickingColor;
220
-
221
- float roll = aPitchRoll.y;
222
- mat3 rotZ = mat3(
223
- vec3(cos(roll), sin(roll), 0.0),
224
- vec3(-sin(roll), cos(roll), 0.0),
225
- vec3(0.0, 0.0, 1.0)
218
+ vColor = aPickingColor;
219
+
220
+ float roll = aPitchRoll.y;
221
+ mat3 rotZ = mat3(
222
+ vec3(cos(roll), sin(roll), 0.0),
223
+ vec3(-sin(roll), cos(roll), 0.0),
224
+ vec3(0.0, 0.0, 1.0)
225
+ );
226
+
227
+ float pitch = aPitchRoll.x;
228
+ mat3 rotX = mat3(
229
+ vec3(1.0, 0.0, 0.0),
230
+ vec3(0.0, cos(pitch), sin(pitch)),
231
+ vec3(0.0, -sin(pitch), cos(pitch))
226
232
  );
233
+
234
+ vec3 position = aPositionHigh + aPositionLow;
235
+ vec3 cameraPosition = eyePositionHigh + eyePositionLow;
236
+ vec3 r = cross(normalize(-position), aDirection);
237
+ mat3 modelMatrix = mat3(r, normalize(position), -aDirection) * rotX * rotZ;
238
+
239
+ mat4 viewMatrixRTE = viewMatrix;
240
+ viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
241
+
242
+ vec3 highDiff = aPositionHigh - eyePositionHigh;
243
+ vec3 lowDiff = aPositionLow - eyePositionLow;
244
+
245
+ vec3 look = cameraPosition - position;
246
+ float lookLength = length(look);
247
+
248
+ // if(lookLength > uScaleByDistance[1])
249
+ // {
250
+ // scd = uScaleByDistance[1] / uScaleByDistance[0];
251
+ // }
252
+ // else if(lookLength > uScaleByDistance[0])
253
+ // {
254
+ // scd = lookLength / uScaleByDistance[0];
255
+ // }
256
+ // ... is the same math above
257
+ // @hack
258
+ // pickingScale replace to this line, because when it s
259
+ // tays in the vert above it affects on Mac Safari jitter
260
+ float scd = pickingScale * uScaleByDistance[2] * clamp(lookLength, uScaleByDistance[0], uScaleByDistance[1]) / uScaleByDistance[0];
227
261
 
228
- float pitch = aPitchRoll.x;
229
- mat3 rotX = mat3(
230
- vec3(1.0, 0.0, 0.0),
231
- vec3(0.0, cos(pitch), sin(pitch)),
232
- vec3(0.0, -sin(pitch), cos(pitch))
233
- );
234
-
235
- vec3 position = aPositionHigh + aPositionLow;
236
- vec3 cameraPosition = eyePositionHigh + eyePositionLow;
237
- vec3 r = cross(normalize(-position), aDirection);
238
- mat3 modelMatrix = mat3(r, normalize(position), -aDirection) * rotX * rotZ;
239
-
240
- float dist = length(cameraPosition);
241
-
242
- mat4 viewMatrixRTE = viewMatrix;
243
- viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
244
-
245
- vec3 highDiff = aPositionHigh - eyePositionHigh;
246
- vec3 lowDiff = aPositionLow - eyePositionLow;
247
-
248
- vec3 look = cameraPosition - position;
249
- float lookLength = length(look);
250
-
251
- float scd = uScaleByDistance[2] * clamp(lookLength, uScaleByDistance[0], uScaleByDistance[1]) / uScaleByDistance[0];
252
-
253
- vec3 vert = modelMatrix * aVertexPosition * aScale * pickingScale * scd;
254
-
255
- gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff + vert, 1.0);
262
+ vec3 vert = modelMatrix * aVertexPosition * aScale * scd;
263
+
264
+ vert += lowDiff;
265
+
266
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + vert, 1.0);
256
267
  }`,
257
268
  fragmentShader:
258
269
  `precision highp float;
@@ -27,13 +27,14 @@ export function rayScreen() {
27
27
  },
28
28
  vertexShader:
29
29
  `precision highp float;
30
- attribute vec2 a_vertices;
30
+
31
+ attribute vec4 a_rgba;
31
32
  attribute vec3 a_startPosHigh;
32
33
  attribute vec3 a_startPosLow;
33
34
  attribute vec3 a_endPosHigh;
34
35
  attribute vec3 a_endPosLow;
36
+ attribute vec2 a_vertices;
35
37
  attribute float a_thickness;
36
- attribute vec4 a_rgba;
37
38
 
38
39
  varying vec4 v_rgba;
39
40
 
@@ -48,38 +49,31 @@ export function rayScreen() {
48
49
 
49
50
  v_rgba = vec4(a_rgba.rgb, a_rgba.a * uOpacity);
50
51
 
51
- vec3 camPos = eyePositionHigh + eyePositionLow;
52
-
53
- vec3 startPos = a_startPosHigh + a_startPosLow;
54
- float length = length((a_endPosHigh + a_endPosLow) - startPos);
55
- vec3 direction = normalize((a_endPosHigh + a_endPosLow) - startPos);
56
- vec3 vertPos = startPos + a_vertices.y * direction * length;
52
+ vec3 v = (a_endPosHigh - a_startPosHigh) + (a_endPosLow - a_startPosLow);
57
53
 
58
- vec3 look = vertPos - camPos;
59
- vec3 up = normalize(direction);
54
+ vec3 look = (a_startPosHigh - eyePositionHigh) + (a_startPosLow - eyePositionLow) + v * a_vertices.y;
55
+ vec3 up = normalize(normalize(v));
60
56
  vec3 right = normalize(cross(look,up));
61
57
 
62
- float dist = dot(camPos - vertPos, vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]));
58
+ float dist = dot(look, vec3(viewMatrix[0][2], viewMatrix[1][2], viewMatrix[2][2]));
63
59
  float focalSize = 2.0 * dist * resolution;
64
- vec3 rr = right * a_thickness * focalSize * a_vertices.x;
60
+ vec3 vert = right * a_thickness * focalSize * a_vertices.x;
65
61
 
66
- vec3 highDiff = -eyePositionHigh;
67
- vec3 lowDiff = rr - eyePositionLow;
62
+ vec3 highDiff;
63
+ vec3 lowDiff;
68
64
 
69
65
  if(a_vertices.y == 0.0){
70
- highDiff += a_startPosHigh;
71
- lowDiff += a_startPosLow;
66
+ highDiff = a_startPosHigh - eyePositionHigh;
67
+ vert += a_startPosLow - eyePositionLow;
72
68
  }else{
73
- highDiff += a_endPosHigh;
74
- lowDiff += a_endPosLow;
69
+ highDiff = a_endPosHigh - eyePositionHigh;
70
+ vert += a_endPosLow - eyePositionLow;
75
71
  }
76
72
 
77
73
  mat4 viewMatrixRTE = viewMatrix;
78
74
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
79
-
80
- vec4 pos = viewMatrixRTE * vec4(highDiff + lowDiff, 1.0);
81
75
 
82
- gl_Position = projectionMatrix * pos;
76
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + vert, 1.0);
83
77
  }`,
84
78
  fragmentShader:
85
79
  `precision highp float;