@openglobus/og 0.15.3 → 0.15.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +3 -7
  2. package/css/og.css +24 -15
  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 +1 -1
  9. package/src/og/Globe.js +4 -0
  10. package/src/og/LonLat.js +207 -193
  11. package/src/og/Object3d.js +1 -1
  12. package/src/og/camera/Camera.js +4 -16
  13. package/src/og/camera/PlanetCamera.js +12 -6
  14. package/src/og/control/DebugInfo.js +263 -165
  15. package/src/og/control/KeyboardNavigation.js +153 -169
  16. package/src/og/control/MouseNavigation.js +0 -20
  17. package/src/og/control/RulerSwitcher.js +4 -1
  18. package/src/og/control/SimpleNavigation.js +123 -128
  19. package/src/og/control/heightRuler/HeightRuler.js +12 -0
  20. package/src/og/control/heightRuler/HeightRulerScene.js +224 -0
  21. package/src/og/control/heightRuler/HeightRulerSwitcher.js +15 -0
  22. package/src/og/control/index.js +2 -0
  23. package/src/og/control/ruler/RulerScene.js +106 -79
  24. package/src/og/ellipsoid/Ellipsoid.js +20 -3
  25. package/src/og/entity/Entity.js +6 -6
  26. package/src/og/entity/EntityCollection.js +4 -0
  27. package/src/og/entity/GeoObjectHandler.js +3 -0
  28. package/src/og/layer/BaseGeoImage.js +152 -16
  29. package/src/og/layer/GeoImage.js +0 -91
  30. package/src/og/layer/GeoTexture2d.js +54 -143
  31. package/src/og/layer/GeoVideo.js +6 -107
  32. package/src/og/layer/Material.js +1 -1
  33. package/src/og/layer/Vector.js +8 -6
  34. package/src/og/layer/XYZ.js +2 -2
  35. package/src/og/quadTree/EntityCollectionNode.js +8 -2
  36. package/src/og/renderer/Renderer.js +91 -94
  37. package/src/og/renderer/RendererEvents.js +39 -23
  38. package/src/og/scene/BaseNode.js +113 -113
  39. package/src/og/scene/Planet.js +20 -13
  40. package/src/og/scene/RenderNode.js +42 -9
  41. package/src/og/segment/Segment.js +38 -45
  42. package/src/og/shaders/geoObject.js +12 -10
  43. package/src/og/shaders/pickingMask.js +1 -1
  44. package/src/og/utils/GeoImageCreator.js +61 -21
  45. package/src/og/utils/VectorTileCreator.js +32 -49
  46. package/src/og/webgl/Framebuffer.js +5 -0
  47. package/types/LonLat.d.ts +8 -0
  48. package/types/camera/PlanetCamera.d.ts +1 -1
  49. package/types/control/DebugInfo.d.ts +4 -0
  50. package/types/control/SimpleNavigation.d.ts +1 -0
  51. package/types/control/heightRuler/HeightRuler.d.ts +6 -0
  52. package/types/control/heightRuler/HeightRulerScene.d.ts +23 -0
  53. package/types/control/index.d.ts +2 -1
  54. package/types/control/ruler/RulerScene.d.ts +8 -5
  55. package/types/control/selection/SelectionScene.d.ts +0 -1
  56. package/types/ellipsoid/Ellipsoid.d.ts +13 -1
  57. package/types/entity/EntityCollection.d.ts +1 -0
  58. package/types/layer/BaseGeoImage.d.ts +17 -3
  59. package/types/layer/GeoImage.d.ts +0 -8
  60. package/types/layer/GeoTexture2d.d.ts +0 -2
  61. package/types/layer/GeoVideo.d.ts +0 -8
  62. package/types/layer/XYZ.d.ts +1 -1
  63. package/types/renderer/Renderer.d.ts +12 -3
  64. package/types/scene/Axes.d.ts +1 -1
  65. package/types/scene/BaseNode.d.ts +2 -2
  66. package/types/scene/Planet.d.ts +0 -5
  67. package/types/scene/RenderNode.d.ts +16 -9
  68. package/types/scene/SkyBox.d.ts +1 -1
  69. package/types/segment/Segment.d.ts +2 -3
  70. package/types/utils/VectorTileCreator.d.ts +1 -3
  71. package/types/webgl/Framebuffer.d.ts +1 -0
@@ -1,113 +1,113 @@
1
- /**
2
- * @module og/scene/BaseNode
3
- */
4
-
5
- "use strict";
6
-
7
- /**
8
- * Scene node base class.
9
- * @class
10
- * @param {string} name - Node name.
11
- */
12
- class BaseNode {
13
- constructor(name) {
14
- /**
15
- * Node name.
16
- * @public
17
- * @type {string}
18
- */
19
- this.name = name;
20
-
21
- /**
22
- * Top scene tree node pointer.
23
- * @public
24
- * @type {RenderNode}
25
- */
26
- this.topNode = this;
27
-
28
- this._dictionary = [];
29
- this._dictionary[name] = this;
30
-
31
- /**
32
- * Children nodes.
33
- * @public
34
- * @type {Array.<RenderNode>}
35
- */
36
- this.childNodes = [];
37
-
38
- /**
39
- * Parent node pointer.
40
- * @public
41
- * @type {RenderNode}
42
- */
43
- this.parentNode = null;
44
-
45
- this.__staticId = BaseNode._staticCounter++;
46
- }
47
-
48
- static get _staticCounter() {
49
- if (!this.__counter__ && this.__counter__ !== 0) {
50
- this.__counter__ = 0;
51
- }
52
- return this.__counter__;
53
- }
54
-
55
- static set _staticCounter(n) {
56
- this.__counter__ = n;
57
- }
58
-
59
- /**
60
- * Adds node to the current hierarchy.
61
- * @public
62
- * @type {BaseNode}
63
- */
64
- addNode(node) {
65
- if (this.parentNode == null) {
66
- node.topNode = this;
67
- } else {
68
- node.topNode = this.topNode;
69
- }
70
- node.parentNode = this;
71
- node._dictionary = this.topNode._dictionary;
72
- this.childNodes.push(node);
73
- this.topNode._dictionary[node.name] = node;
74
- }
75
-
76
- /**
77
- * Destroy node.
78
- * @public
79
- */
80
- destroy() {
81
- for (var i = 0; i < this.childNodes.length; i++) {
82
- this.childNodes[i].destroy();
83
- }
84
- this._clear();
85
- }
86
-
87
- /**
88
- * Gets node by name in the current.
89
- * @public
90
- * @param {string} name - Node name.
91
- * @return {RenderNode} Node object in the current node.
92
- */
93
- getNodeByName(name) {
94
- return this._dictionary[name];
95
- }
96
-
97
- /**
98
- * Clear current node.
99
- * @protected
100
- */
101
- _clear() {
102
- this.name = "";
103
- this.parentNode = null;
104
- this.topNode = null;
105
- this.childNodes.length = 0;
106
- }
107
-
108
- isEqual(node) {
109
- return node.__staticId === this.__staticId;
110
- }
111
- }
112
-
113
- export { BaseNode };
1
+ /**
2
+ * @module og/scene/BaseNode
3
+ */
4
+
5
+ "use strict";
6
+
7
+ /**
8
+ * Scene node base class.
9
+ * @class
10
+ * @param {string} name - Node name.
11
+ */
12
+ class BaseNode {
13
+ constructor(name) {
14
+ /**
15
+ * Node name.
16
+ * @public
17
+ * @type {string}
18
+ */
19
+ this.name = name;
20
+
21
+ /**
22
+ * Top scene tree node pointer.
23
+ * @public
24
+ * @type {BaseNode}
25
+ */
26
+ this.topNode = this;
27
+
28
+ this._dictionary = [];
29
+ this._dictionary[name] = this;
30
+
31
+ /**
32
+ * Children nodes.
33
+ * @public
34
+ * @type {Array.<RenderNode>}
35
+ */
36
+ this.childNodes = [];
37
+
38
+ /**
39
+ * Parent node pointer.
40
+ * @public
41
+ * @type {RenderNode}
42
+ */
43
+ this.parentNode = null;
44
+
45
+ this.__staticId = BaseNode._staticCounter++;
46
+ }
47
+
48
+ static get _staticCounter() {
49
+ if (!this.__counter__ && this.__counter__ !== 0) {
50
+ this.__counter__ = 0;
51
+ }
52
+ return this.__counter__;
53
+ }
54
+
55
+ static set _staticCounter(n) {
56
+ this.__counter__ = n;
57
+ }
58
+
59
+ /**
60
+ * Adds node to the current hierarchy.
61
+ * @public
62
+ * @type {BaseNode}
63
+ */
64
+ addNode(node) {
65
+ if (this.parentNode == null) {
66
+ node.topNode = this;
67
+ } else {
68
+ node.topNode = this.topNode;
69
+ }
70
+ node.parentNode = this;
71
+ node._dictionary = this.topNode._dictionary;
72
+ this.childNodes.push(node);
73
+ this.topNode._dictionary[node.name] = node;
74
+ }
75
+
76
+ /**
77
+ * Destroy node.
78
+ * @public
79
+ */
80
+ destroy() {
81
+ for (var i = 0; i < this.childNodes.length; i++) {
82
+ this.childNodes[i].destroy();
83
+ }
84
+ this._clear();
85
+ }
86
+
87
+ /**
88
+ * Gets node by name in the current.
89
+ * @public
90
+ * @param {string} name - Node name.
91
+ * @return {RenderNode} Node object in the current node.
92
+ */
93
+ getNodeByName(name) {
94
+ return this._dictionary[name];
95
+ }
96
+
97
+ /**
98
+ * Clear current node.
99
+ * @protected
100
+ */
101
+ _clear() {
102
+ this.name = "";
103
+ this.parentNode = null;
104
+ this.topNode = null;
105
+ this.childNodes.length = 0;
106
+ }
107
+
108
+ isEqual(node) {
109
+ return node.__staticId === this.__staticId;
110
+ }
111
+ }
112
+
113
+ export { BaseNode };
@@ -740,9 +740,7 @@ export class Planet extends RenderNode {
740
740
  h.addProgram(shaders.drawnode_heightPicking(), true);
741
741
 
742
742
  this.renderer.addPickingCallback(this, this._renderColorPickingFramebufferPASS);
743
-
744
743
  this.renderer.addDepthCallback(this, this._renderDepthFramebufferPASS);
745
-
746
744
  this.renderer.addDistanceCallback(this, this._renderDistanceFramebufferPASS);
747
745
  }
748
746
 
@@ -1136,7 +1134,7 @@ export class Planet extends RenderNode {
1136
1134
  * Render node callback.
1137
1135
  * @public
1138
1136
  */
1139
- frame() {
1137
+ preFrame() {
1140
1138
 
1141
1139
  if (this._updateLayer) {
1142
1140
  this._updateLayer = false;
@@ -1144,16 +1142,27 @@ export class Planet extends RenderNode {
1144
1142
  }
1145
1143
 
1146
1144
  if (this.camera.isFirstPass) {
1145
+ this.camera.updateGeodeticPosition();
1147
1146
  this._firstPASS();
1148
- }
1147
+ this.camera.checkTerrainCollision();
1148
+ this.camera.update();
1149
1149
 
1150
- this._renderScreenNodesPASS();
1151
-
1152
- //this._renderHeightPickingFramebufferPASS();
1150
+ // Here is the planet node dispatches a draw event before
1151
+ // rendering begins and we have got render nodes.
1152
+ this.events.dispatch(this.events.draw, this);
1153
+ }
1153
1154
 
1154
1155
  this.drawEntityCollections(this._frustumEntityCollections);
1155
1156
  }
1156
1157
 
1158
+ /**
1159
+ * Render node callback.
1160
+ * @public
1161
+ */
1162
+ frame() {
1163
+ this._renderScreenNodesPASS();
1164
+ }
1165
+
1157
1166
  _checkRendercompleted() {
1158
1167
  if (this._renderCompleted) {
1159
1168
  if (!this._renderCompletedActivated) {
@@ -1194,10 +1203,6 @@ export class Planet extends RenderNode {
1194
1203
  }
1195
1204
  this._skipPreRender = true;
1196
1205
 
1197
- // Here is the planet node dispatches a draw event before
1198
- // rendering begins and we have got render nodes.
1199
- this.events.dispatch(this.events.draw, this);
1200
-
1201
1206
  this.transformLights();
1202
1207
 
1203
1208
  this._normalMapCreator.frame();
@@ -1299,6 +1304,7 @@ export class Planet extends RenderNode {
1299
1304
  }
1300
1305
 
1301
1306
  gl.enable(gl.POLYGON_OFFSET_FILL);
1307
+ //gl.disable(gl.CULL_FACE);
1302
1308
  for (let j = 1, len = sl.length; j < len; j++) {
1303
1309
  let slj = sl[j];
1304
1310
  for (i = slj.length - 1; i >= 0; --i) {
@@ -1314,6 +1320,7 @@ export class Planet extends RenderNode {
1314
1320
  rn[i].segment.screenRendering(sh, sl[j], j, this.transparentTexture, true);
1315
1321
  }
1316
1322
  }
1323
+ //gl.enable(gl.CULL_FACE);
1317
1324
  gl.disable(gl.POLYGON_OFFSET_FILL);
1318
1325
  }
1319
1326
 
@@ -1542,7 +1549,8 @@ export class Planet extends RenderNode {
1542
1549
  gl.uniform3fv(shu.frustumPickingColor, cam.frustum._pickingColorU);
1543
1550
 
1544
1551
  // drawing planet nodes
1545
- var rn = this._renderedNodesInFrustum[cam.getCurrentFrustum()], sl = this._visibleTileLayerSlices;
1552
+ let rn = this._renderedNodesInFrustum[cam.getCurrentFrustum()],
1553
+ sl = this._visibleTileLayerSlices;
1546
1554
 
1547
1555
  let i = rn.length;
1548
1556
  while (i--) {
@@ -1594,7 +1602,6 @@ export class Planet extends RenderNode {
1594
1602
  this.terrain.abortLoading();
1595
1603
  this._tileLoader.abortAll();
1596
1604
 
1597
-
1598
1605
  this.quadTreeStrategy.clear();
1599
1606
  this.layerLock.free(this._memKey);
1600
1607
  this.terrainLock.free(this._memKey);
@@ -5,16 +5,17 @@ import { BaseNode } from "./BaseNode.js";
5
5
 
6
6
  /**
7
7
  * Render node is a logical part of a render mechanism. Represents scene rendering.
8
- * Forexample one scene node for rendering the Earth, another one for rendering the Moon, another node for rendering stars etc.
8
+ * For example one scene node for rendering the Earth, another one for rendering the Moon, another node for rendering stars etc.
9
9
  * Each render node has own model view space defined with matrices(scale, rotation, translation, transformation).
10
10
  * There are collections of ligh sources, entities and so on in the node.
11
11
  * Access to the node is renderer.renderNodes["Earth"]
12
12
  * @class
13
- * @extends {RenderNode}
13
+ * @extends {BaseNode}
14
14
  * @param {string} name - Node name.
15
15
  */
16
+
16
17
  class RenderNode extends BaseNode {
17
- constructor(name) {
18
+ constructor(name = "") {
18
19
  super(name);
19
20
 
20
21
  /**
@@ -167,6 +168,15 @@ class RenderNode extends BaseNode {
167
168
  light.remove();
168
169
  }
169
170
 
171
+ /**
172
+ * Calls render frame node's callback. Used in renderer.
173
+ * @public
174
+ */
175
+ preDrawNode(frustum, frustumIndex) {
176
+ this._isActive && this._preDrawNodes(frustum, frustumIndex);
177
+ }
178
+
179
+
170
180
  /**
171
181
  * Calls render frame node's callback. Used in renderer.
172
182
  * @public
@@ -194,6 +204,8 @@ class RenderNode extends BaseNode {
194
204
 
195
205
  if (this.renderer) {
196
206
  if (this._isActive && this._pickingId === -1) {
207
+ // This picking callback MUST be the first picking callback
208
+ // in the rendering queue in the renderer. It affects on blending.
197
209
  this._pickingId = this.renderer.addPickingCallback(
198
210
  this,
199
211
  this._entityCollectionPickingCallback
@@ -264,6 +276,31 @@ class RenderNode extends BaseNode {
264
276
  }
265
277
  }
266
278
 
279
+ frame() {
280
+
281
+ }
282
+
283
+ preFrame() {
284
+
285
+ }
286
+
287
+ /**
288
+ * @private
289
+ */
290
+ _preDrawNodes() {
291
+ for (var i = 0; i < this.childNodes.length; i++) {
292
+ if (this.childNodes[i]._isActive) {
293
+ this.childNodes[i]._preDrawNodes();
294
+ }
295
+ }
296
+
297
+ if (this.show) {
298
+ //this.lightEnabled && this.transformLights();
299
+ this.preFrame();
300
+ this.drawEntityCollections(this.entityCollections);
301
+ }
302
+ }
303
+
267
304
  /**
268
305
  * @private
269
306
  */
@@ -275,11 +312,7 @@ class RenderNode extends BaseNode {
275
312
  }
276
313
 
277
314
  if (this.show) {
278
- if (this.frame) {
279
- //this.lightEnabled && this.transformLights();
280
- this.frame();
281
- }
282
- this.drawEntityCollections(this.entityCollections);
315
+ this.frame();
283
316
  }
284
317
  }
285
318
 
@@ -296,7 +329,7 @@ class RenderNode extends BaseNode {
296
329
  if (ec.length) {
297
330
 
298
331
  // billoard pass
299
- let i = ec.length;
332
+ let i = ec.length;
300
333
  while (i--) {
301
334
  ec[i]._fadingOpacity && ec[i].billboardHandler.drawPicking();
302
335
  }
@@ -254,11 +254,10 @@ class Segment {
254
254
  * @public
255
255
  * @param {Entity} entity - Entity.
256
256
  * @param {Vec3} res - Point coordinates.
257
- * @param {Vec3} [normal] - Terrain point normal.
258
257
  * @returns {Vec3} -
259
258
  */
260
- getEntityTerrainPoint(entity, res, normal) {
261
- return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res, normal);
259
+ getEntityTerrainPoint(entity, res) {
260
+ return this.getTerrainPoint(entity._cartesian, entity._lonlatMerc, res);
262
261
  }
263
262
 
264
263
  isEntityInside(e) {
@@ -274,80 +273,74 @@ class Segment {
274
273
  * @param {Vec3} [normal] - Terrain point normal.
275
274
  * @returns {number} -
276
275
  */
277
- getTerrainPoint(xyz, insideSegmentPosition, res, normal) {
278
- var verts = this.tempVertices;
276
+ getTerrainPoint(xyz, insideSegmentPosition, res) {
277
+ let verts = this.tempVertices;
279
278
 
280
- _ray.set(xyz, xyz.negateTo());
279
+ if (verts && verts.length) {
280
+ let norm = this.planet.ellipsoid.getSurfaceNormal3v(xyz);
281
+ _ray.set(xyz, norm.negateTo());
281
282
 
282
- if (verts) {
283
- var ne = this._extent.northEast,
283
+ let ne = this._extent.northEast,
284
284
  sw = this._extent.southWest,
285
285
  size = Math.sqrt(verts.length / 3) - 1;
286
286
 
287
- var xmax = ne.lon,
287
+ let xmax = ne.lon,
288
288
  ymax = ne.lat,
289
289
  xmin = sw.lon,
290
290
  ymin = sw.lat,
291
291
  x = insideSegmentPosition.lon,
292
292
  y = insideSegmentPosition.lat;
293
293
 
294
- var sxn = xmax - xmin,
294
+ let sxn = xmax - xmin,
295
295
  syn = ymax - ymin;
296
296
 
297
- var qx = sxn / size,
297
+ let qx = sxn / size,
298
298
  qy = syn / size;
299
299
 
300
- var xn = x - xmin,
300
+ let xn = x - xmin,
301
301
  yn = y - ymin;
302
302
 
303
- var indX = Math.floor(xn / qx),
303
+ let indX = Math.floor(xn / qx),
304
304
  indY = Math.floor(size - yn / qy);
305
305
 
306
- if (verts && verts.length) {
307
- var ind_v0 = ((size + 1) * indY + indX) * 3;
308
- var ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
306
+ let ind_v0 = ((size + 1) * indY + indX) * 3;
307
+ let ind_v2 = ((size + 1) * (indY + 1) + indX) * 3;
309
308
 
310
- _v0.set(verts[ind_v0], verts[ind_v0 + 1], verts[ind_v0 + 2]);
311
- _v1.set(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]);
312
- _v2.set(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]);
309
+ _v0.set(verts[ind_v0], verts[ind_v0 + 1], verts[ind_v0 + 2]);
310
+ _v1.set(verts[ind_v0 + 3], verts[ind_v0 + 4], verts[ind_v0 + 5]);
311
+ _v2.set(verts[ind_v2], verts[ind_v2 + 1], verts[ind_v2 + 2]);
313
312
 
314
- let d = _ray.hitTriangle(_v0, _v1, _v2, res, normal);
313
+ let d = _ray.hitTriangle(_v0, _v1, _v2, res);
315
314
 
315
+ if (d === Ray.INSIDE) {
316
+ return xyz.distance(res);
317
+ } else if (d === Ray.AWAY) {
318
+ _rayEx.set(xyz, norm);
319
+ let d = _rayEx.hitTriangle(_v0, _v1, _v2, res);
316
320
  if (d === Ray.INSIDE) {
317
- return xyz.distance(res);
318
- } else if (d === Ray.AWAY) {
319
- _rayEx.set(xyz, xyz);
320
- let d = _rayEx.hitTriangle(_v0, _v1, _v2, res, normal);
321
- if (d === Ray.INSIDE) {
322
- return -xyz.distance(res);
323
- }
321
+ return -xyz.distance(res);
324
322
  }
323
+ }
325
324
 
326
- _v3.set(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]);
325
+ _v3.set(verts[ind_v2 + 3], verts[ind_v2 + 4], verts[ind_v2 + 5]);
327
326
 
328
- d = _ray.hitTriangle(_v1, _v3, _v2, res, normal);
327
+ d = _ray.hitTriangle(_v1, _v3, _v2, res);
328
+ if (d === Ray.INSIDE) {
329
+ return xyz.distance(res);
330
+ } else if (d === Ray.AWAY) {
331
+ _rayEx.set(xyz, norm);
332
+ let d = _rayEx.hitTriangle(_v1, _v3, _v2, res);
329
333
  if (d === Ray.INSIDE) {
330
- return xyz.distance(res);
331
- } else if (d === Ray.AWAY) {
332
- _rayEx.set(xyz, xyz);
333
- let d = _rayEx.hitTriangle(_v1, _v3, _v2, res, normal);
334
- if (d === Ray.INSIDE) {
335
- return -xyz.distance(res);
336
- }
337
- }
338
-
339
- if (d === Ray.AWAY) {
340
334
  return -xyz.distance(res);
341
335
  }
336
+ }
342
337
 
343
- return xyz.distance(res);
338
+ if (d === Ray.AWAY) {
339
+ return -xyz.distance(res);
344
340
  }
345
341
 
346
- res.copy(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
347
- normal && normal.copy(xyz.normal());
348
342
  return xyz.distance(res);
349
343
  } else {
350
- normal && normal.copy(xyz.normal());
351
344
  return xyz.distance(this.planet.ellipsoid.hitRay(_ray.origin, _ray.direction));
352
345
  }
353
346
  }
@@ -1597,7 +1590,7 @@ class Segment {
1597
1590
  shu = sh.uniforms;
1598
1591
 
1599
1592
  var currHeight;
1600
- if (layerSlice.length) {
1593
+ if (layerSlice && layerSlice.length) {
1601
1594
  currHeight = layerSlice[0]._height;
1602
1595
  } else {
1603
1596
  currHeight = 0;
@@ -1675,4 +1668,4 @@ class Segment {
1675
1668
  }
1676
1669
  }
1677
1670
 
1678
- export { Segment };
1671
+ export { Segment };
@@ -211,20 +211,21 @@ export const geo_object_picking = () =>
211
211
  const float RADIANS = 3.141592653589793 / 180.0;
212
212
 
213
213
  void main(void) {
214
-
214
+
215
215
  if (aDispose == 0.0) {
216
216
  return;
217
217
  }
218
218
 
219
219
  vColor = aPickingColor;
220
- float roll = aPitchRoll.y * RADIANS;
220
+
221
+ float roll = aPitchRoll.y;
221
222
  mat3 rotZ = mat3(
222
223
  vec3(cos(roll), sin(roll), 0.0),
223
224
  vec3(-sin(roll), cos(roll), 0.0),
224
225
  vec3(0.0, 0.0, 1.0)
225
226
  );
226
227
 
227
- float pitch = aPitchRoll.x * RADIANS;
228
+ float pitch = aPitchRoll.x;
228
229
  mat3 rotX = mat3(
229
230
  vec3(1.0, 0.0, 0.0),
230
231
  vec3(0.0, cos(pitch), sin(pitch)),
@@ -232,10 +233,11 @@ export const geo_object_picking = () =>
232
233
  );
233
234
 
234
235
  vec3 position = aPositionHigh + aPositionLow;
236
+ vec3 cameraPosition = eyePositionHigh + eyePositionLow;
235
237
  vec3 r = cross(normalize(-position), aDirection);
236
- mat3 modelMatrix = mat3(r, normalize(position), -aDirection) * rotX * rotZ; /*up=-cross(aDirection, r)*/
238
+ mat3 modelMatrix = mat3(r, normalize(position), -aDirection) * rotX * rotZ;
237
239
 
238
- float dist = length(eyePositionHigh + eyePositionLow);
240
+ float dist = length(cameraPosition);
239
241
 
240
242
  mat4 viewMatrixRTE = viewMatrix;
241
243
  viewMatrixRTE[3] = vec4(0.0, 0.0, 0.0, 1.0);
@@ -243,14 +245,14 @@ export const geo_object_picking = () =>
243
245
  vec3 highDiff = aPositionHigh - eyePositionHigh;
244
246
  vec3 lowDiff = aPositionLow - eyePositionLow;
245
247
 
246
- vec3 look = position - (eyePositionHigh + eyePositionLow);
248
+ vec3 look = cameraPosition - position;
247
249
  float lookLength = length(look);
248
-
250
+
249
251
  float scd = uScaleByDistance[2] * clamp(lookLength, uScaleByDistance[0], uScaleByDistance[1]) / uScaleByDistance[0];
250
252
 
251
- vec4 pos = vec4((highDiff + lowDiff) + modelMatrix * aVertexPosition * aScale * pickingScale * scd, 1.0);
252
-
253
- gl_Position = projectionMatrix * viewMatrixRTE * pos;
253
+ vec3 vert = modelMatrix * aVertexPosition * aScale * pickingScale * scd;
254
+
255
+ gl_Position = projectionMatrix * viewMatrixRTE * vec4(highDiff + lowDiff + vert, 1.0);
254
256
  }`,
255
257
  fragmentShader:
256
258
  `precision highp float;
@@ -20,7 +20,7 @@ export function pickingMask() {
20
20
  void main() {
21
21
 
22
22
  gl_Position = vec4(coordinates + offset, 0.0, 1.0);
23
- gl_PointSize = 20.0;
23
+ gl_PointSize = 5.0;
24
24
  }`,
25
25
  fragmentShader:
26
26
  `precision highp float;