@openglobus/og 0.13.5 → 0.13.8

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 (78) hide show
  1. package/css/og.css +66 -25
  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 +1 -1
  8. package/src/og/Events.js +188 -188
  9. package/src/og/Extent.js +1 -9
  10. package/src/og/Globe.js +1 -0
  11. package/src/og/Object3d.js +384 -0
  12. package/src/og/arial.js +1705 -1703
  13. package/src/og/camera/Camera.js +640 -640
  14. package/src/og/control/DebugInfo.js +15 -4
  15. package/src/og/control/EarthCoordinates.js +151 -160
  16. package/src/og/control/KeyboardNavigation.js +48 -2
  17. package/src/og/control/LayerAnimation.js +115 -0
  18. package/src/og/control/MouseNavigation.js +460 -460
  19. package/src/og/control/Sun.js +170 -170
  20. package/src/og/control/TouchNavigation.js +13 -13
  21. package/src/og/control/ZoomControl.js +1 -3
  22. package/src/og/control/index.js +3 -1
  23. package/src/og/control/ruler/Ruler.js +43 -0
  24. package/src/og/control/ruler/RulerScene.js +370 -0
  25. package/src/og/control/visibleExtent/Segment.js +1 -4
  26. package/src/og/ellipsoid/Ellipsoid.js +20 -1
  27. package/src/og/entity/Entity.js +1 -1
  28. package/src/og/entity/GeoObject.js +1 -1
  29. package/src/og/entity/LabelHandler.js +3 -2
  30. package/src/og/input/input.js +7 -1
  31. package/src/og/layer/CanvasTiles.js +8 -8
  32. package/src/og/layer/KML.js +181 -12
  33. package/src/og/layer/Layer.js +27 -42
  34. package/src/og/layer/Vector.js +80 -14
  35. package/src/og/layer/XYZ.js +8 -2
  36. package/src/og/math/Vec3.js +1 -1
  37. package/src/og/math.js +4 -4
  38. package/src/og/quadTree/Node.js +2 -1
  39. package/src/og/renderer/Renderer.js +1 -2
  40. package/src/og/renderer/RendererEvents.js +17 -3
  41. package/src/og/res/images.js +0 -2
  42. package/src/og/scene/Planet.js +92 -32
  43. package/src/og/segment/Segment.js +1 -8
  44. package/src/og/shaders/label.js +30 -42
  45. package/src/og/terrain/EmptyTerrain.js +164 -146
  46. package/src/og/terrain/Geoid.js +246 -241
  47. package/src/og/terrain/GlobusTerrain.js +23 -24
  48. package/src/og/terrain/MapboxTerrain.js +292 -294
  49. package/src/og/utils/FontAtlas.js +1 -2
  50. package/src/og/utils/Loader.js +160 -112
  51. package/src/og/utils/PlainSegmentWorker.js +38 -26
  52. package/src/og/utils/VectorTileCreator.js +1 -1
  53. package/src/og/utils/units.js +78 -0
  54. package/src/og/webgl/ProgramController.js +143 -143
  55. package/types/Object3d.d.ts +21 -0
  56. package/types/arial.d.ts +1 -0
  57. package/types/control/EarthCoordinates.d.ts +27 -30
  58. package/types/control/KeyboardNavigation.d.ts +3 -0
  59. package/types/control/Sun.d.ts +1 -1
  60. package/types/control/index.d.ts +2 -1
  61. package/types/control/ruler/Ruler.d.ts +13 -0
  62. package/types/control/ruler/RulerScene.d.ts +48 -0
  63. package/types/ellipsoid/Ellipsoid.d.ts +8 -0
  64. package/types/input/input.d.ts +6 -0
  65. package/types/layer/KML.d.ts +26 -1
  66. package/types/layer/Layer.d.ts +23 -31
  67. package/types/layer/Vector.d.ts +2 -0
  68. package/types/layer/XYZ.d.ts +1 -0
  69. package/types/math.d.ts +1 -1
  70. package/types/renderer/RendererEvents.d.ts +2 -0
  71. package/types/res/images.d.ts +0 -1
  72. package/types/scene/Planet.d.ts +12 -3
  73. package/types/terrain/EmptyTerrain.d.ts +4 -1
  74. package/types/terrain/Geoid.d.ts +1 -10
  75. package/types/terrain/GlobusTerrain.d.ts +0 -2
  76. package/types/terrain/MapboxTerrain.d.ts +1 -1
  77. package/types/utils/Loader.d.ts +4 -0
  78. package/types/utils/units.d.ts +20 -0
@@ -42,17 +42,179 @@ export class KML extends Vector {
42
42
  _extractCoordonatesFromKml(xmlDoc) {
43
43
  const raw = Array.from(xmlDoc.getElementsByTagName("coordinates"));
44
44
  const rawText = raw.map(item => item.textContent.trim());
45
- const coordinates = rawText.map(item =>
45
+ const coordinates = rawText.map(item =>
46
46
  item
47
- .replace(/\n/g, " ")
48
- .replace(/\t/g, " ")
49
- .replace(/ +/g," ")
50
- .split(" ")
51
- .map((co) => co.split(",").map(parseFloat))
47
+ .replace(/\n/g, " ")
48
+ .replace(/\t/g, " ")
49
+ .replace(/ +/g, " ")
50
+ .split(" ")
51
+ .map((co) => co.split(",").map(parseFloat))
52
52
  );
53
53
  return coordinates;
54
54
  }
55
55
 
56
+ /**
57
+ * @private
58
+ */
59
+ _AGBRtoRGBA(agbr) {
60
+ if (!agbr || agbr.length != 8) return
61
+
62
+ const a = parseInt(agbr.slice(0, 2), 16) / 255;
63
+ const b = parseInt(agbr.slice(2, 4), 16);
64
+ const g = parseInt(agbr.slice(4, 6), 16);
65
+ const r = parseInt(agbr.slice(6, 8), 16);
66
+
67
+ return `rgba(${r},${g},${b},${a})`;
68
+ }
69
+
70
+ /**
71
+ * @private
72
+ returns array of longitude, latitude, altitude (altitude optional)
73
+ */
74
+ _parseKMLcoordinates(coords) {
75
+ const coordinates = coords.innerHTML.trim()
76
+ .replace(/\n/g, ' ')
77
+ .replace(/\t/g, ' ')
78
+ .replace(/ +/g, ' ')
79
+ .split(" ")
80
+ .map((co) => co.split(",").map(parseFloat))
81
+
82
+ return coordinates;
83
+ }
84
+
85
+ /**
86
+ * @private
87
+ */
88
+ _kmlPlacemarkToEntity(placemark, extent) {
89
+ if (!placemark) return;
90
+
91
+ const nameTags = Array.from(placemark.getElementsByTagName("name"))
92
+ const name = nameTags && nameTags[0]?.innerHTML?.trim() || '';
93
+
94
+ const { iconHeading, iconURL, iconColor, lineWidth, lineColor } = this._extractStyle(placemark);
95
+
96
+ // TODO handle MultiGeometry
97
+
98
+ const lonLats = [];
99
+ for (const coord of placemark.getElementsByTagName("coordinates")) {
100
+ const coordinates = this._parseKMLcoordinates(coord) || [[0, 0, 0]]
101
+
102
+ for (const lonlatalt of coordinates) {
103
+ const [lon, lat, alt] = lonlatalt
104
+
105
+ lonLats.push(new LonLat(lon, lat, alt));
106
+
107
+ if (lon < extent.southWest.lon) extent.southWest.lon = lon;
108
+ if (lat < extent.southWest.lat) extent.southWest.lat = lat;
109
+ if (lon > extent.northEast.lon) extent.northEast.lon = lon;
110
+ if (lat > extent.northEast.lat) extent.northEast.lat = lat;
111
+ }
112
+ }
113
+
114
+ if (lonLats.length === 1) {
115
+ const hdgrad = iconHeading * 0.01745329; // radians
116
+
117
+ return new Entity({
118
+ name,
119
+ lonlat: lonLats[0],
120
+ billboard: {
121
+ src: iconURL,
122
+ size: [24, 24],
123
+ color: iconColor,
124
+ rotation: hdgrad
125
+ },
126
+ properties: {
127
+ color: iconColor,
128
+ heading: iconHeading
129
+ }
130
+ });
131
+
132
+ } else {
133
+ return new Entity({
134
+ polyline: {
135
+ pathLonLat: [lonLats],
136
+ thickness: lineWidth,
137
+ color: lineColor,
138
+ isClosed: false
139
+ }
140
+ });
141
+ }
142
+ }
143
+
144
+ _extractStyle(placemark) {
145
+ let iconColor;
146
+ let iconHeading;
147
+ let iconURL;
148
+ let lineColor;
149
+ let lineWidth;
150
+
151
+ const style = placemark.getElementsByTagName("Style")[0];
152
+ if (style) {
153
+ let iconstyle = style.getElementsByTagName("IconStyle")[0];
154
+ if (iconstyle) {
155
+ let color = iconstyle.getElementsByTagName("color")[0];
156
+ if (color)
157
+ iconColor = this._AGBRtoRGBA(color.innerHTML.trim());
158
+
159
+ let heading = iconstyle.getElementsByTagName("heading")[0];
160
+ if (heading) {
161
+ const hdg = parseFloat(heading.innerHTML.trim());
162
+ if (hdg >= 0 && hdg <= 360)
163
+ iconHeading = hdg % 360;
164
+ }
165
+
166
+ let icon = iconstyle.getElementsByTagName("Icon")[0];
167
+ if (icon) {
168
+ let href = icon.getElementsByTagName("href")[0];
169
+ if (href) {
170
+ iconURL = href.innerHTML.trim();
171
+ }
172
+ }
173
+ }
174
+
175
+ let linestyle = style.getElementsByTagName("LineStyle")[0];
176
+ if (linestyle) {
177
+ let color = linestyle.getElementsByTagName("color")[0];
178
+ if (color)
179
+ lineColor = this._AGBRtoRGBA(color.innerHTML.trim());
180
+ let width = linestyle.getElementsByTagName("width")[0];
181
+ if (width !== undefined)
182
+ lineWidth = parseFloat(width.innerHTML.trim());
183
+ }
184
+ }
185
+
186
+ if (!iconColor) iconColor = "#FFFFFF"
187
+ if (!iconHeading) iconHeading = 0
188
+ if (!iconURL) iconURL = "https://openglobus.org/examples/billboards/carrot.png"
189
+
190
+ if (!lineColor) lineColor = "#FFFFFF"
191
+ if (!lineWidth) lineWidth = 1
192
+
193
+ return { iconHeading, iconURL, iconColor, lineWidth, lineColor };
194
+ }
195
+
196
+ _parseKML(xml, extent, entities = undefined) {
197
+ if (!entities)
198
+ entities = [];
199
+
200
+ if (xml.documentElement.nodeName !== "kml")
201
+ return entities;
202
+
203
+ for (const placemark of xml.getElementsByTagName("Placemark")) {
204
+ const entity = this._kmlPlacemarkToEntity(placemark, extent);
205
+ if (entity) entities.push(entity);
206
+ }
207
+
208
+ return entities;
209
+ }
210
+
211
+ _convertKMLintoEntities(xml) {
212
+ const extent = new Extent(new LonLat(180.0, 90.0), new LonLat(-180.0, -90.0));
213
+ const entities = this._parseKML(xml, extent);
214
+
215
+ return { entities, extent }
216
+ }
217
+
56
218
  /**
57
219
  * Creates billboards or polylines from array of lonlat.
58
220
  * @public
@@ -129,6 +291,7 @@ export class KML extends Vector {
129
291
  * @returns {Promise<{entities: Entity[], extent: Extent}>}
130
292
  */
131
293
  async addKmlFromFiles(kmls, color = null, billboard = null) {
294
+ if (!Array.isArray(kmls)) return null
132
295
  const kmlObjs = await Promise.all(kmls.map(this._getXmlContent));
133
296
  const coordonates = kmlObjs.map(this._extractCoordonatesFromKml);
134
297
  const { entities, extent } = this._convertCoordonatesIntoEntities(
@@ -179,14 +342,20 @@ export class KML extends Vector {
179
342
  */
180
343
  async addKmlFromUrl(url, color = null, billboard = null) {
181
344
  const kml = await this._getKmlFromUrl(url);
182
- const coordonates = this._extractCoordonatesFromKml(kml);
183
- const { entities, extent } = this._convertCoordonatesIntoEntities(
184
- [coordonates],
185
- color || this._color,
186
- billboard || this._billboard
187
- );
345
+ /*
346
+ const coordonates = this._extractCoordonatesFromKml(kml);
347
+ const { entities, extent } = this._convertCoordonatesIntoEntities(
348
+ [coordonates],
349
+ color || this._color,
350
+ billboard || this._billboard
351
+ );
352
+ */
353
+ const { entities, extent } = this._convertKMLintoEntities(kml);
354
+
188
355
  this._extent = this._expandExtents(this._extent, extent);
356
+
189
357
  entities.forEach(this.add.bind(this));
358
+
190
359
  return { entities, extent };
191
360
  }
192
361
  }
@@ -34,29 +34,29 @@ export const FADING_FACTOR = 0.29;
34
34
  * @fires og.Layer#visibilitychange
35
35
  * @fires og.Layer#add
36
36
  * @fires og.Layer#remove
37
- * @fires og.layer.Vector#mousemove
38
- * @fires og.layer.Vector#mouseenter
39
- * @fires og.layer.Vector#mouseleave
40
- * @fires og.layer.Vector#lclick
41
- * @fires og.layer.Vector#rclick
42
- * @fires og.layer.Vector#mclick
43
- * @fires og.layer.Vector#ldblclick
44
- * @fires og.layer.Vector#rdblclick
45
- * @fires og.layer.Vector#mdblclick
46
- * @fires og.layer.Vector#lup
47
- * @fires og.layer.Vector#rup
48
- * @fires og.layer.Vector#mup
49
- * @fires og.layer.Vector#ldown
50
- * @fires og.layer.Vector#rdown
51
- * @fires og.layer.Vector#mdown
52
- * @fires og.layer.Vector#lhold
53
- * @fires og.layer.Vector#rhold
54
- * @fires og.layer.Vector#mhold
55
- * @fires og.layer.Vector#mousewheel
56
- * @fires og.layer.Vector#touchmove
57
- * @fires og.layer.Vector#touchstart
58
- * @fires og.layer.Vector#touchend
59
- * @fires og.layer.Vector#doubletouch
37
+ * @fires og.layer.Layer#mousemove
38
+ * @fires og.layer.Layer#mouseenter
39
+ * @fires og.layer.Layer#mouseleave
40
+ * @fires og.layer.Layer#lclick
41
+ * @fires og.layer.Layer#rclick
42
+ * @fires og.layer.Layer#mclick
43
+ * @fires og.layer.Layer#ldblclick
44
+ * @fires og.layer.Layer#rdblclick
45
+ * @fires og.layer.Layer#mdblclick
46
+ * @fires og.layer.Layer#lup
47
+ * @fires og.layer.Layer#rup
48
+ * @fires og.layer.Layer#mup
49
+ * @fires og.layer.Layer#ldown
50
+ * @fires og.layer.Layer#rdown
51
+ * @fires og.layer.Layer#mdown
52
+ * @fires og.layer.Layer#lhold
53
+ * @fires og.layer.Layer#rhold
54
+ * @fires og.layer.Layer#mhold
55
+ * @fires og.layer.Layer#mousewheel
56
+ * @fires og.layer.Layer#touchmove
57
+ * @fires og.layer.Layer#touchstart
58
+ * @fires og.layer.Layer#touchend
59
+ * @fires og.layer.Layer#doubletouch
60
60
  */
61
61
  class Layer {
62
62
  constructor(name, options = {}) {
@@ -230,23 +230,6 @@ class Layer {
230
230
  this.__lcounter = n;
231
231
  }
232
232
 
233
- static get __requestsCounter() {
234
- return this.__reqcounter;
235
- }
236
-
237
- static set __requestsCounter(v) {
238
- this.__reqcounter = v;
239
- }
240
-
241
- /**
242
- * Maximum loading queries at one time.
243
- * @const
244
- * @type {number}
245
- */
246
- static get MAX_REQUESTS() {
247
- return 7;
248
- }
249
-
250
233
  get instanceName() {
251
234
  return "Layer";
252
235
  }
@@ -413,8 +396,10 @@ class Layer {
413
396
  * @param {string} html - HTML code that represents layer attribution, it could be just a text.
414
397
  */
415
398
  setAttribution(html) {
416
- this._attribution = html;
417
- this._planet && this._planet.updateAttributionsList();
399
+ if (this._attribution !== html) {
400
+ this._attribution = html;
401
+ this._planet && this._planet.updateAttributionsList();
402
+ }
418
403
  }
419
404
 
420
405
  /**
@@ -137,6 +137,11 @@ class Vector extends Layer {
137
137
  });
138
138
  this._bindEventsDefault(this._polylineEntityCollection);
139
139
 
140
+ this._geoObjectEntityCollection = new EntityCollection({
141
+ pickingEnabled: this.pickingEnabled
142
+ });
143
+ this._bindEventsDefault(this._geoObjectEntityCollection);
144
+
140
145
  this._geometryHandler = new GeometryHandler(this);
141
146
 
142
147
  this._entityCollectionsTree = null;
@@ -186,6 +191,7 @@ class Vector extends Layer {
186
191
  this._geometryHandler.assignHandler(planet.renderer.handler);
187
192
  this._polylineEntityCollection.addTo(planet, true);
188
193
  this._stripEntityCollection.addTo(planet, true);
194
+ this._geoObjectEntityCollection.addTo(planet, true);
189
195
  this.setEntities(this._entities);
190
196
  }
191
197
  return this;
@@ -285,6 +291,10 @@ class Vector extends Layer {
285
291
  this._polylineEntityCollection.add(entity);
286
292
  }
287
293
 
294
+ if (entity.geoObject) {
295
+ this._geoObjectEntityCollection.add(entity);
296
+ }
297
+
288
298
  if (entity.geometry) {
289
299
  this._hasImageryTiles = true;
290
300
  if (this._planet) {
@@ -412,20 +422,22 @@ class Vector extends Layer {
412
422
 
413
423
  this._polylineEntityCollection.setPickingEnabled(picking);
414
424
 
425
+ this._geoObjectEntityCollection.setPickingEnabled(picking);
426
+
415
427
  this._entityCollectionsTree &&
416
- this._entityCollectionsTree.traverseTree(function (node) {
417
- node.entityCollection.setPickingEnabled(picking);
418
- });
428
+ this._entityCollectionsTree.traverseTree(function (node) {
429
+ node.entityCollection.setPickingEnabled(picking);
430
+ });
419
431
 
420
432
  this._entityCollectionsTreeNorth &&
421
- this._entityCollectionsTreeNorth.traverseTree(function (node) {
422
- node.entityCollection.setPickingEnabled(picking);
423
- });
433
+ this._entityCollectionsTreeNorth.traverseTree(function (node) {
434
+ node.entityCollection.setPickingEnabled(picking);
435
+ });
424
436
 
425
437
  this._entityCollectionsTreeSouth &&
426
- this._entityCollectionsTreeSouth.traverseTree(function (node) {
427
- node.entityCollection.setPickingEnabled(picking);
428
- });
438
+ this._entityCollectionsTreeSouth.traverseTree(function (node) {
439
+ node.entityCollection.setPickingEnabled(picking);
440
+ });
429
441
  }
430
442
 
431
443
  /**
@@ -527,10 +539,10 @@ class Vector extends Layer {
527
539
 
528
540
  this._entities = new Array(temp.length);
529
541
 
530
- var entitiesForTree = [];
542
+ let entitiesForTree = [];
531
543
 
532
- for (var i = 0; i < temp.length; i++) {
533
- var ei = temp[i];
544
+ for (let i = 0; i < temp.length; i++) {
545
+ let ei = temp[i];
534
546
 
535
547
  ei._layer = this;
536
548
  ei._layerIndex = i;
@@ -539,6 +551,8 @@ class Vector extends Layer {
539
551
  this._stripEntityCollection.add(ei);
540
552
  } else if (ei.polyline || ei.ray) {
541
553
  this._polylineEntityCollection.add(ei);
554
+ } else if (ei.geoObject) {
555
+ this._geoObjectEntityCollection.add(ei);
542
556
  } else if (ei.billboard || ei.label || ei.shape) {
543
557
  entitiesForTree.push(ei);
544
558
  }
@@ -711,7 +725,7 @@ class Vector extends Layer {
711
725
  }
712
726
 
713
727
  _collectPolylineCollectionPASS(outArr) {
714
- var ec = this._polylineEntityCollection;
728
+ let ec = this._polylineEntityCollection;
715
729
 
716
730
  ec._fadingOpacity = this._fadingOpacity;
717
731
  ec.scaleByDistance = this.scaleByDistance;
@@ -762,6 +776,58 @@ class Vector extends Layer {
762
776
  }
763
777
  }
764
778
 
779
+ _collectGeoObjectCollectionPASS(outArr) {
780
+ let ec = this._geoObjectEntityCollection;
781
+
782
+ ec._fadingOpacity = this._fadingOpacity;
783
+ ec.scaleByDistance = this.scaleByDistance;
784
+ ec.pickingScale = this.pickingScale;
785
+ ec.polygonOffsetUnits = this.polygonOffsetUnits;
786
+
787
+ outArr.push(ec);
788
+
789
+ // if (this.clampToGround || this.relativeToGround) {
790
+ // let rtg = Number(this.relativeToGround);
791
+ //
792
+ // var nodes = this._planet._renderedNodes;
793
+ // var visibleExtent = this._planet.getViewExtent();
794
+ // var e = ec._entities;
795
+ // var e_i = e.length;
796
+ // let res = new Vec3();
797
+ //
798
+ // while (e_i--) {
799
+ // var p = e[e_i].polyline;
800
+ // if (visibleExtent.overlaps(p._extent)) {
801
+ // // TODO:this works only for mercator area.
802
+ // // needs to be working on poles.
803
+ // let coords = p._pathLonLatMerc,
804
+ // c_j = coords.length;
805
+ // while (c_j--) {
806
+ // var c_j_h = coords[c_j].length;
807
+ // while (c_j_h--) {
808
+ // let ll = coords[c_j][c_j_h],
809
+ // n_k = nodes.length;
810
+ // while (n_k--) {
811
+ // var seg = nodes[n_k].segment;
812
+ // if (seg._extent.isInside(ll)) {
813
+ // let cart = p._path3v[c_j][c_j_h];
814
+ // seg.getTerrainPoint(cart, ll, res);
815
+ // p.setPoint3v(
816
+ // res.addA(res.normal().scale((rtg && p.altitude) || 0.0)),
817
+ // c_j_h,
818
+ // c_j,
819
+ // true
820
+ // );
821
+ // break;
822
+ // }
823
+ // }
824
+ // }
825
+ // }
826
+ // }
827
+ // }
828
+ // }
829
+ }
830
+
765
831
  collectVisibleCollections(outArr) {
766
832
  var p = this._planet;
767
833
 
@@ -775,8 +841,8 @@ class Vector extends Layer {
775
841
 
776
842
  // Common collections first
777
843
  this._collectStripCollectionPASS(outArr);
778
-
779
844
  this._collectPolylineCollectionPASS(outArr);
845
+ this._collectGeoObjectCollectionPASS(outArr);
780
846
 
781
847
  // Merc nodes
782
848
  this._secondPASS = [];
@@ -92,6 +92,10 @@ class XYZ extends Layer {
92
92
  this._urlRewriteCallback = options.urlRewrite || null;
93
93
  }
94
94
 
95
+ get isIdle() {
96
+ return !this._planet || this._planet._tileLoader.isIdle(this);
97
+ }
98
+
95
99
  get instanceName() {
96
100
  return "XYZ";
97
101
  }
@@ -162,6 +166,7 @@ class XYZ extends Layer {
162
166
 
163
167
  this._planet._tileLoader.load(
164
168
  {
169
+ sender: this,
165
170
  src: this._getHTTPRequestString(material.segment),
166
171
  type: "imageBitmap",
167
172
  filter: () =>
@@ -185,7 +190,8 @@ class XYZ extends Layer {
185
190
  material.textureNotExists();
186
191
  }
187
192
  }
188
- }
193
+ },
194
+ this._id
189
195
  );
190
196
  } else {
191
197
  material.textureNotExists();
@@ -303,7 +309,7 @@ class XYZ extends Layer {
303
309
  clearMaterial(material) {
304
310
  if (material.isReady && material.textureExists) {
305
311
  !material.texture.default &&
306
- material.segment.handler.gl.deleteTexture(material.texture);
312
+ material.segment.handler.gl.deleteTexture(material.texture);
307
313
  material.texture = null;
308
314
 
309
315
  if (material.image) {
@@ -194,7 +194,7 @@ export class Vec3 {
194
194
  * @returns {Vec3} -
195
195
  */
196
196
  static lerp(v1, v2, l) {
197
- return Vec3(v1.x + (v2.x - v1.x) * l, v1.y + (v2.y - v1.y) * l, v1.z + (v2.z - v1.z) * l);
197
+ return new Vec3(v1.x + (v2.x - v1.x) * l, v1.y + (v2.y - v1.y) * l, v1.z + (v2.z - v1.z) * l);
198
198
  }
199
199
 
200
200
  /**
package/src/og/math.js CHANGED
@@ -200,15 +200,15 @@ export function mod(m, n) {
200
200
  * @returns {number} -
201
201
  */
202
202
  export function zeroTwoPI(a) {
203
- var mod = mod(a, TWO_PI);
204
- if (Math.abs(mod) < EPSILON14 && Math.abs(a) > EPSILON14) {
203
+ const res = mod(a, TWO_PI);
204
+ if (Math.abs(res) < EPSILON14 && Math.abs(a) > EPSILON14) {
205
205
  return TWO_PI;
206
206
  }
207
- return mod;
207
+ return res;
208
208
  }
209
209
 
210
210
  /**
211
- * Returns 0.0 if x is smaller then edge and otherwise 1.0.
211
+ * Returns 0.0 if x is smaller than edge and otherwise 1.0.
212
212
  * @function
213
213
  * @param {number} edge -
214
214
  * @param {number} x - Value to edge.
@@ -284,7 +284,7 @@ class Node {
284
284
  } else if (
285
285
  seg.terrainReady &&
286
286
  seg.tileZoom < planet.terrain._maxNodeZoom &&
287
- (!maxZoom || maxZoom && cam.projectedSize(seg.bsphere.center, seg.bsphere.radius) > this.planet._maxLodSize)) {
287
+ (!maxZoom || cam.projectedSize(seg.bsphere.center, seg.bsphere.radius) > this.planet._maxLodSize)) {
288
288
  this.traverseNodes(cam, maxZoom, seg, stopLoading);
289
289
  } else if (altVis) {
290
290
  seg.passReady = maxZoom ? seg.terrainReady : false;
@@ -404,6 +404,7 @@ class Node {
404
404
 
405
405
  if (!this.segment.terrainReady) {
406
406
  this.planet._renderCompleted = false;
407
+ this.planet._terrainCompleted = false;
407
408
  }
408
409
 
409
410
  let k = 0,
@@ -15,7 +15,6 @@ import { FontAtlas } from "../utils/FontAtlas.js";
15
15
  import { TextureAtlas } from "../utils/TextureAtlas.js";
16
16
  import * as arial from "../arial.js";
17
17
  import { depth } from "../shaders/depth.js";
18
- import { ARIAL_FONT_B64 } from "../res/images.js";
19
18
  import { LabelWorker } from "../entity/LabelWorker.js";
20
19
 
21
20
  let __pickingCallbackCounter__ = 0;
@@ -497,7 +496,7 @@ class Renderer {
497
496
 
498
497
  this.outputTexture = this.screenTexture.screen;
499
498
 
500
- this.fontAtlas.initFont("arial", arial.data, ARIAL_FONT_B64);
499
+ this.fontAtlas.initFont("arial", arial.data, arial.image);
501
500
  }
502
501
 
503
502
  setCurrentScreen(screenName) {
@@ -161,6 +161,8 @@ class RendererEvents extends Events {
161
161
  prev_x: 0,
162
162
  /** Previous touch Y coordinate. */
163
163
  prev_y: 0,
164
+ /** Screen touch position world direction. */
165
+ direction: new Vec3(),
164
166
  /** JavaScript touching system event message. */
165
167
  sys: null,
166
168
  /** Current touched(picking) object. */
@@ -222,6 +224,13 @@ class RendererEvents extends Events {
222
224
  this.mouseState.x,
223
225
  this.mouseState.y
224
226
  );
227
+ //
228
+ // TODO: Replace in some other place with a thought that we do
229
+ // not need to make unproject when we do not make touching
230
+ this.touchState.direction = this.renderer.activeCamera.unproject(
231
+ this.touchState.x,
232
+ this.touchState.y
233
+ );
225
234
  this.entityPickingEvents();
226
235
  this._keyboardHandler.handleEvents();
227
236
  this.handleMouseEvents();
@@ -493,7 +502,7 @@ class RendererEvents extends Events {
493
502
  var ts = this.touchState;
494
503
  ts.sys = event;
495
504
 
496
- ts.clienX = event.touches.item(0).clientX - event.offsetLeft;
505
+ ts.clientX = event.touches.item(0).clientX - event.offsetLeft;
497
506
  ts.clientY = event.touches.item(0).clientY - event.offsetTop;
498
507
 
499
508
  let h = this.renderer.handler;
@@ -569,8 +578,13 @@ class RendererEvents extends Events {
569
578
 
570
579
  ts.sys = event;
571
580
  ts.moving = true;
572
- // this._dblTchBegins = 0;
573
- // this._oneTouchStart = false;
581
+
582
+ var dX = ts.x - ts.prev_x
583
+ var dY = ts.y - ts.prev_y
584
+ if (Math.abs(dX) > 9 || Math.abs(dY) > 9) {
585
+ this._dblTchBegins = 0;
586
+ this._oneTouchStart = false;
587
+ }
574
588
  }
575
589
 
576
590
  /**