@openglobus/og 0.16.3 → 0.17.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 (197) hide show
  1. package/README.md +1 -1
  2. package/css/og.css +24 -2
  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/Clock.js +1 -5
  10. package/src/og/Events.js +2 -6
  11. package/src/og/Extent.js +5 -9
  12. package/src/og/Globe.js +93 -56
  13. package/src/og/ImageCanvas.js +13 -6
  14. package/src/og/Lock.js +44 -48
  15. package/src/og/LonLat.js +1 -5
  16. package/src/og/Object3d.js +2 -2
  17. package/src/og/QueueArray.js +1 -1
  18. package/src/og/Stack.js +49 -53
  19. package/src/og/astro/earth.js +112 -116
  20. package/src/og/astro/jd.js +514 -518
  21. package/src/og/astro/orbit.js +119 -123
  22. package/src/og/astro/rotation.js +36 -40
  23. package/src/og/bv/Box.js +77 -81
  24. package/src/og/bv/Sphere.js +57 -61
  25. package/src/og/camera/Camera.js +20 -7
  26. package/src/og/camera/Frustum.js +4 -4
  27. package/src/og/camera/PlanetCamera.js +15 -22
  28. package/src/og/cons.js +1 -1
  29. package/src/og/control/Atmosphere.js +0 -4
  30. package/src/og/control/Control.js +9 -8
  31. package/src/og/control/DebugInfo.js +3 -7
  32. package/src/og/control/DrawingSwitcher.js +117 -0
  33. package/src/og/control/EarthCoordinates.js +214 -214
  34. package/src/og/control/EarthNavigation.js +6 -13
  35. package/src/og/control/GeoImageDragControl.js +0 -4
  36. package/src/og/control/KeyboardNavigation.js +0 -4
  37. package/src/og/control/LayerAnimation.js +0 -4
  38. package/src/og/control/LayerSwitcher.js +2 -4
  39. package/src/og/control/Lighting.js +12 -16
  40. package/src/og/control/MouseNavigation.js +1 -5
  41. package/src/og/control/MouseWheelZoomControl.js +0 -4
  42. package/src/og/control/RulerSwitcher.js +0 -4
  43. package/src/og/control/ScaleControl.js +2 -6
  44. package/src/og/control/ShowFps.js +40 -44
  45. package/src/og/control/SimpleNavigation.js +10 -10
  46. package/src/og/control/SimpleSkyBackground.js +0 -4
  47. package/src/og/control/Sun.js +0 -4
  48. package/src/og/control/ToggleWireframe.js +35 -39
  49. package/src/og/control/ZoomControl.js +0 -4
  50. package/src/og/control/drawing/DrawingControl.js +51 -0
  51. package/src/og/control/drawing/LineStringDrawingScene.js +203 -0
  52. package/src/og/control/drawing/PolygonDrawingScene.js +785 -0
  53. package/src/og/control/elevationProfile/ElevationProfile.js +275 -0
  54. package/src/og/control/index.js +5 -1
  55. package/src/og/control/ruler/Ruler.js +0 -4
  56. package/src/og/control/ruler/RulerScene.js +3 -2
  57. package/src/og/control/selection/Selection.js +0 -4
  58. package/src/og/control/selection/SelectionScene.js +2 -4
  59. package/src/og/control/timeline/TimelineControl.js +4 -4
  60. package/src/og/control/timeline/TimelineModel.js +2 -2
  61. package/src/og/control/timeline/TimelineView.js +1 -0
  62. package/src/og/control/visibleExtent/Segment.js +7 -7
  63. package/src/og/control/visibleExtent/drawnode.js +0 -4
  64. package/src/og/ellipsoid/Ellipsoid.js +236 -325
  65. package/src/og/ellipsoid/wgs84.js +0 -4
  66. package/src/og/entity/BaseBillboard.js +375 -379
  67. package/src/og/entity/Billboard.js +0 -4
  68. package/src/og/entity/BillboardHandler.js +3 -7
  69. package/src/og/entity/Entity.js +22 -22
  70. package/src/og/entity/EntityCollection.js +14 -18
  71. package/src/og/entity/GeoObject.js +6 -8
  72. package/src/og/entity/GeoObjectHandler.js +30 -24
  73. package/src/og/entity/Geometry.js +5 -4
  74. package/src/og/entity/GeometryHandler.js +18 -19
  75. package/src/og/entity/Label.js +0 -4
  76. package/src/og/entity/LabelHandler.js +10 -14
  77. package/src/og/entity/LabelWorker.js +1 -1
  78. package/src/og/entity/PointCloud.js +2 -6
  79. package/src/og/entity/PointCloudHandler.js +122 -126
  80. package/src/og/entity/Polyline.js +15 -17
  81. package/src/og/entity/PolylineHandler.js +104 -108
  82. package/src/og/entity/Ray.js +29 -29
  83. package/src/og/entity/RayHandler.js +2 -2
  84. package/src/og/entity/Strip.js +1 -1
  85. package/src/og/entity/StripHandler.js +2 -2
  86. package/src/og/index.js +3 -1
  87. package/src/og/input/KeyboardHandler.js +128 -132
  88. package/src/og/input/MouseHandler.js +94 -98
  89. package/src/og/input/TouchHandler.js +59 -63
  90. package/src/og/input/input.js +44 -48
  91. package/src/og/layer/BaseGeoImage.js +6 -9
  92. package/src/og/layer/CanvasTiles.js +1 -5
  93. package/src/og/layer/GeoImage.js +0 -4
  94. package/src/og/layer/GeoTexture2d.js +0 -4
  95. package/src/og/layer/GeoVideo.js +0 -4
  96. package/src/og/layer/KML.js +1 -0
  97. package/src/og/layer/Layer.js +22 -26
  98. package/src/og/layer/Material.js +0 -4
  99. package/src/og/layer/Vector.js +25 -22
  100. package/src/og/layer/WMS.js +182 -186
  101. package/src/og/layer/XYZ.js +0 -4
  102. package/src/og/light/LightSource.js +0 -4
  103. package/src/og/math/Line2.js +28 -32
  104. package/src/og/math/Mat3.js +152 -156
  105. package/src/og/math/Ray.js +0 -4
  106. package/src/og/math/Vec2.js +0 -4
  107. package/src/og/math/Vec3.js +5 -4
  108. package/src/og/math/Vec4.js +0 -4
  109. package/src/og/math/coder.js +104 -104
  110. package/src/og/math.js +42 -10
  111. package/src/og/mercator.js +1 -1
  112. package/src/og/proj/EPSG3857.js +13 -13
  113. package/src/og/proj/Proj.js +59 -63
  114. package/src/og/quadTree/EPSG4326QuadTreeStrategy.js +1 -0
  115. package/src/og/quadTree/EarthQuadTreeStrategy.js +1 -0
  116. package/src/og/quadTree/EntityCollectionNode.js +12 -16
  117. package/src/og/quadTree/MarsQuadTreeStrategy.js +1 -0
  118. package/src/og/quadTree/Node.js +15 -14
  119. package/src/og/quadTree/QuadTreeStrategy.js +1 -0
  120. package/src/og/quadTree/Wgs84QuadTreeStrategy.js +1 -0
  121. package/src/og/renderer/Renderer.js +114 -27
  122. package/src/og/renderer/RendererEvents.js +0 -4
  123. package/src/og/scene/Axes.js +74 -78
  124. package/src/og/scene/BaseNode.js +1 -5
  125. package/src/og/scene/Planet.js +127 -130
  126. package/src/og/scene/RenderNode.js +20 -12
  127. package/src/og/scene/SkyBox.js +104 -108
  128. package/src/og/segment/Segment.js +10 -6
  129. package/src/og/segment/SegmentLonLat.js +3 -7
  130. package/src/og/segment/segmentHelper.js +229 -225
  131. package/src/og/shaders/atmos.js +1 -1
  132. package/src/og/shaders/billboard.js +0 -4
  133. package/src/og/shaders/drawnode.js +5 -9
  134. package/src/og/shaders/geoObject.js +0 -4
  135. package/src/og/shaders/label.js +0 -4
  136. package/src/og/shaders/pickingMask.js +0 -4
  137. package/src/og/shaders/pointCloud.js +0 -4
  138. package/src/og/shaders/polyline.js +0 -4
  139. package/src/og/shaders/ray.js +0 -4
  140. package/src/og/shaders/skybox.js +0 -4
  141. package/src/og/terrain/EmptyTerrain.js +0 -4
  142. package/src/og/utils/FontAtlas.js +0 -4
  143. package/src/og/utils/GeoImageCreator.js +2 -3
  144. package/src/og/utils/NormalMapCreator.js +11 -12
  145. package/src/og/utils/PlainSegmentWorker.js +9 -9
  146. package/src/og/utils/TerrainWorker.js +2 -2
  147. package/src/og/utils/TextureAtlas.js +1 -1
  148. package/src/og/utils/VectorTileCreator.js +3 -9
  149. package/src/og/utils/earcut.js +8 -8
  150. package/src/og/utils/shared.js +30 -11
  151. package/src/og/webgl/Framebuffer.js +2 -6
  152. package/src/og/webgl/Handler.js +46 -20
  153. package/src/og/webgl/Multisample.js +2 -6
  154. package/src/og/webgl/Program.js +4 -8
  155. package/src/og/webgl/ProgramController.js +2 -2
  156. package/types/Clock.d.ts +1 -1
  157. package/types/Extent.d.ts +5 -5
  158. package/types/Globe.d.ts +15 -1
  159. package/types/ImageCanvas.d.ts +5 -0
  160. package/types/bv/Box.d.ts +1 -1
  161. package/types/bv/Sphere.d.ts +3 -3
  162. package/types/camera/Camera.d.ts +3 -2
  163. package/types/camera/PlanetCamera.d.ts +4 -4
  164. package/types/control/DrawingSwitcher.d.ts +13 -0
  165. package/types/control/EarthCoordinates.d.ts +1 -1
  166. package/types/control/Lighting.d.ts +8 -8
  167. package/types/control/drawing/DrawingControl.d.ts +14 -0
  168. package/types/control/drawing/LineStringDrawingScene.d.ts +5 -0
  169. package/types/control/drawing/PolygonDrawingScene.d.ts +99 -0
  170. package/types/control/index.d.ts +3 -1
  171. package/types/control/ruler/RulerScene.d.ts +0 -1
  172. package/types/control/selection/SelectionScene.d.ts +0 -1
  173. package/types/ellipsoid/Ellipsoid.d.ts +53 -64
  174. package/types/entity/Entity.d.ts +3 -2
  175. package/types/entity/GeoObject.d.ts +1 -2
  176. package/types/entity/Geometry.d.ts +5 -0
  177. package/types/entity/Polyline.d.ts +1 -1
  178. package/types/entity/Ray.d.ts +1 -0
  179. package/types/index.d.ts +1 -0
  180. package/types/layer/BaseGeoImage.d.ts +1 -1
  181. package/types/layer/CanvasTiles.d.ts +1 -1
  182. package/types/layer/Layer.d.ts +1 -1
  183. package/types/layer/Vector.d.ts +1 -0
  184. package/types/math/Vec3.d.ts +2 -0
  185. package/types/math.d.ts +7 -0
  186. package/types/renderer/Renderer.d.ts +7 -1
  187. package/types/scene/Axes.d.ts +0 -1
  188. package/types/scene/Planet.d.ts +27 -26
  189. package/types/scene/RenderNode.d.ts +2 -0
  190. package/types/scene/SkyBox.d.ts +0 -1
  191. package/types/segment/Segment.d.ts +3 -2
  192. package/types/segment/SegmentLonLat.d.ts +0 -1
  193. package/types/utils/GeoImageCreator.d.ts +1 -1
  194. package/types/utils/NormalMapCreator.d.ts +1 -1
  195. package/types/utils/VectorTileCreator.d.ts +2 -2
  196. package/types/utils/shared.d.ts +2 -0
  197. package/types/webgl/Handler.d.ts +6 -4
@@ -113,7 +113,7 @@ const _programm = `'use strict';
113
113
  _outlineColorArr = new Float32Array(maxLetters * 24),
114
114
  _pickingColorArr = new Float32Array(maxLetters * 18);
115
115
 
116
- for (var i = 0; i < maxLetters; i++) {
116
+ for (let i = 0; i < maxLetters; i++) {
117
117
  if (isVisible !== 0) {
118
118
  concatTypedArrays(_vertexArr, i, [0, 0, 0, -1, 1, -1, 1, -1, 1, 0, 0, 0]);
119
119
  } else {
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/entity/PointCloud
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import { Vec3 } from "../math/Vec3.js";
@@ -212,7 +208,7 @@ class PointCloud {
212
208
  */
213
209
  setPoints(points) {
214
210
  this.clear();
215
- for (var i = 0; i < points.length; i++) {
211
+ for (let i = 0; i < points.length; i++) {
216
212
  var pi = points[i];
217
213
  var pos = new Vec3(pi[0], pi[1], pi[2]),
218
214
  col = new Vec4(pi[3], pi[4], pi[5], pi[6] == undefined ? 255.0 : pi[6]);
@@ -475,7 +471,7 @@ class PointCloud {
475
471
 
476
472
  _setPickingColors() {
477
473
  if (this._renderNode) {
478
- for (var i = 0; i < this._points.length; i++) {
474
+ for (let i = 0; i < this._points.length; i++) {
479
475
  var p = this._points[i];
480
476
  p._entity = this._entity;
481
477
  p._entityCollection = this._entity._entityCollection;
@@ -1,126 +1,122 @@
1
- /**
2
- * @module og/entity/PointCloudHandler
3
- */
4
-
5
- "use strict";
6
-
7
- import * as shaders from "../shaders/pointCloud.js";
8
-
9
- class PointCloudHandler {
10
- constructor(entityCollection) {
11
- /**
12
- * Picking rendering option.
13
- * @public
14
- * @type {boolean}
15
- */
16
- this.pickingEnabled = true;
17
-
18
- /**
19
- * Parent collection
20
- * @private
21
- * @type {EntityCollection}
22
- */
23
- this._entityCollection = entityCollection;
24
-
25
- /**
26
- * Renderer
27
- * @private
28
- * @type {Renderer}
29
- */
30
- this._renderer = null;
31
-
32
- /**
33
- * Point cloud array
34
- * @private
35
- * @type {Array.<PointCloud>}
36
- */
37
- this._pointClouds = [];
38
-
39
- this.__staticId = PointCloudHandler._staticCounter++;
40
- }
41
-
42
- static get _staticCounter() {
43
- if (!this._counter && this._counter !== 0) {
44
- this._counter = 0;
45
- }
46
- return this._counter;
47
- }
48
-
49
- static set _staticCounter(n) {
50
- this._counter = n;
51
- }
52
-
53
- _initProgram() {
54
- if (this._renderer.handler) {
55
- if (!this._renderer.handler.programs.pointCloud) {
56
- this._renderer.handler.addProgram(shaders.pointCloud());
57
- }
58
- }
59
- }
60
-
61
- setRenderNode(renderNode) {
62
- this._renderer = renderNode.renderer;
63
- this._initProgram();
64
- for (var i = 0; i < this._pointClouds.length; i++) {
65
- this._pointClouds[i].setRenderNode(renderNode);
66
- }
67
- }
68
-
69
- add(pointCloud) {
70
- if (pointCloud._handlerIndex === -1) {
71
- pointCloud._handler = this;
72
- pointCloud._handlerIndex = this._pointClouds.length;
73
- this._pointClouds.push(pointCloud);
74
- this._entityCollection &&
75
- this._entityCollection.renderNode &&
76
- pointCloud.setRenderNode(this._entityCollection.renderNode);
77
- }
78
- }
79
-
80
- remove(pointCloud) {
81
- var index = pointCloud._handlerIndex;
82
- if (index !== -1) {
83
- pointCloud._deleteBuffers();
84
- pointCloud._handlerIndex = -1;
85
- pointCloud._handler = null;
86
- this._pointClouds.splice(index, 1);
87
- this.reindexPointCloudArray(index);
88
- }
89
- }
90
-
91
- reindexPointCloudArray(startIndex) {
92
- var pc = this._pointClouds;
93
- for (var i = startIndex; i < pc.length; i++) {
94
- pc[i]._handlerIndex = i;
95
- }
96
- }
97
-
98
- draw() {
99
- var i = this._pointClouds.length;
100
- while (i--) {
101
- this._pointClouds[i].draw();
102
- }
103
- }
104
-
105
- drawPicking() {
106
- if (this.pickingEnabled) {
107
- var i = this._pointClouds.length;
108
- while (i--) {
109
- this._pointClouds[i].drawPicking();
110
- }
111
- }
112
- }
113
-
114
- clear() {
115
- var i = this._pointClouds.length;
116
- while (i--) {
117
- this._pointClouds[i]._deleteBuffers();
118
- this._pointClouds[i]._handler = null;
119
- this._pointClouds[i]._handlerIndex = -1;
120
- }
121
- this._pointClouds.length = 0;
122
- this._pointClouds = [];
123
- }
124
- }
125
-
126
- export { PointCloudHandler };
1
+ "use strict";
2
+
3
+ import * as shaders from "../shaders/pointCloud.js";
4
+
5
+ class PointCloudHandler {
6
+ constructor(entityCollection) {
7
+ /**
8
+ * Picking rendering option.
9
+ * @public
10
+ * @type {boolean}
11
+ */
12
+ this.pickingEnabled = true;
13
+
14
+ /**
15
+ * Parent collection
16
+ * @private
17
+ * @type {EntityCollection}
18
+ */
19
+ this._entityCollection = entityCollection;
20
+
21
+ /**
22
+ * Renderer
23
+ * @private
24
+ * @type {Renderer}
25
+ */
26
+ this._renderer = null;
27
+
28
+ /**
29
+ * Point cloud array
30
+ * @private
31
+ * @type {Array.<PointCloud>}
32
+ */
33
+ this._pointClouds = [];
34
+
35
+ this.__staticId = PointCloudHandler._staticCounter++;
36
+ }
37
+
38
+ static get _staticCounter() {
39
+ if (!this._counter && this._counter !== 0) {
40
+ this._counter = 0;
41
+ }
42
+ return this._counter;
43
+ }
44
+
45
+ static set _staticCounter(n) {
46
+ this._counter = n;
47
+ }
48
+
49
+ _initProgram() {
50
+ if (this._renderer.handler) {
51
+ if (!this._renderer.handler.programs.pointCloud) {
52
+ this._renderer.handler.addProgram(shaders.pointCloud());
53
+ }
54
+ }
55
+ }
56
+
57
+ setRenderNode(renderNode) {
58
+ this._renderer = renderNode.renderer;
59
+ this._initProgram();
60
+ for (let i = 0; i < this._pointClouds.length; i++) {
61
+ this._pointClouds[i].setRenderNode(renderNode);
62
+ }
63
+ }
64
+
65
+ add(pointCloud) {
66
+ if (pointCloud._handlerIndex === -1) {
67
+ pointCloud._handler = this;
68
+ pointCloud._handlerIndex = this._pointClouds.length;
69
+ this._pointClouds.push(pointCloud);
70
+ this._entityCollection &&
71
+ this._entityCollection.renderNode &&
72
+ pointCloud.setRenderNode(this._entityCollection.renderNode);
73
+ }
74
+ }
75
+
76
+ remove(pointCloud) {
77
+ var index = pointCloud._handlerIndex;
78
+ if (index !== -1) {
79
+ pointCloud._deleteBuffers();
80
+ pointCloud._handlerIndex = -1;
81
+ pointCloud._handler = null;
82
+ this._pointClouds.splice(index, 1);
83
+ this.reindexPointCloudArray(index);
84
+ }
85
+ }
86
+
87
+ reindexPointCloudArray(startIndex) {
88
+ var pc = this._pointClouds;
89
+ for (let i = startIndex; i < pc.length; i++) {
90
+ pc[i]._handlerIndex = i;
91
+ }
92
+ }
93
+
94
+ draw() {
95
+ var i = this._pointClouds.length;
96
+ while (i--) {
97
+ this._pointClouds[i].draw();
98
+ }
99
+ }
100
+
101
+ drawPicking() {
102
+ if (this.pickingEnabled) {
103
+ var i = this._pointClouds.length;
104
+ while (i--) {
105
+ this._pointClouds[i].drawPicking();
106
+ }
107
+ }
108
+ }
109
+
110
+ clear() {
111
+ var i = this._pointClouds.length;
112
+ while (i--) {
113
+ this._pointClouds[i]._deleteBuffers();
114
+ this._pointClouds[i]._handler = null;
115
+ this._pointClouds[i]._handlerIndex = -1;
116
+ }
117
+ this._pointClouds.length = 0;
118
+ this._pointClouds = [];
119
+ }
120
+ }
121
+
122
+ export { PointCloudHandler };
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/entity/Polyline
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import { Extent } from "../Extent.js";
@@ -96,7 +92,7 @@ class Polyline {
96
92
  this._pathLengths = [];
97
93
 
98
94
  /**
99
- * Polyline geodetic degrees coordiantes.
95
+ * Polyline geodetic degrees coordinates.
100
96
  * @private
101
97
  * @type {Array.<LonLat>}
102
98
  */
@@ -225,7 +221,7 @@ class Polyline {
225
221
  outIndexes.push(0, 0);
226
222
  }
227
223
 
228
- for (var j = 0, len = path3v.length; j < len; j++) {
224
+ for (let j = 0, len = path3v.length; j < len; j++) {
229
225
  var path = path3v[j],
230
226
  pathColors_j = pathColors[j];
231
227
 
@@ -747,7 +743,7 @@ class Polyline {
747
743
  outIndexes.push(0, 0);
748
744
  }
749
745
 
750
- for (var j = 0, len = pathLonLat.length; j < len; j++) {
746
+ for (let j = 0, len = pathLonLat.length; j < len; j++) {
751
747
  var path = pathLonLat[j],
752
748
  pathColors_j = pathColors[j];
753
749
 
@@ -1015,7 +1011,7 @@ class Polyline {
1015
1011
 
1016
1012
  var ellipsoid = this._renderNode.ellipsoid;
1017
1013
 
1018
- for (var j = 0; j < path3v.length; j++) {
1014
+ for (let j = 0; j < path3v.length; j++) {
1019
1015
  var path = path3v[j];
1020
1016
 
1021
1017
  var last;
@@ -1056,7 +1052,7 @@ class Polyline {
1056
1052
  vh[k] = v_high.z;
1057
1053
  vl[k++] = v_low.z;
1058
1054
 
1059
- for (var i = 0; i < path.length; i++) {
1055
+ for (let i = 0; i < path.length; i++) {
1060
1056
  var cur = path[i],
1061
1057
  pji = this._path3v[j][i];
1062
1058
 
@@ -1177,7 +1173,7 @@ class Polyline {
1177
1173
 
1178
1174
  var ellipsoid = this._renderNode.ellipsoid;
1179
1175
 
1180
- for (var j = 0; j < pathLonLat.length; j++) {
1176
+ for (let j = 0; j < pathLonLat.length; j++) {
1181
1177
  var path = pathLonLat[j];
1182
1178
 
1183
1179
  var last;
@@ -1216,7 +1212,7 @@ class Polyline {
1216
1212
  vh[k] = v_high.z;
1217
1213
  vl[k++] = v_low.z;
1218
1214
 
1219
- for (var i = 0; i < path.length; i++) {
1215
+ for (let i = 0; i < path.length; i++) {
1220
1216
  var cur = path[i];
1221
1217
  var cartesian = ellipsoid.lonLatToCartesian(cur);
1222
1218
  c[j][i] = cartesian;
@@ -1316,9 +1312,9 @@ class Polyline {
1316
1312
  var extent = this._extent;
1317
1313
  extent.southWest.set(180.0, 90.0);
1318
1314
  extent.northEast.set(-180.0, -90.0);
1319
- for (var i = 0; i < l.length; i++) {
1315
+ for (let i = 0; i < l.length; i++) {
1320
1316
  var pi = l[i];
1321
- for (var j = 0; j < pi.length; j++) {
1317
+ for (let j = 0; j < pi.length; j++) {
1322
1318
  var lon = pi[j].lon,
1323
1319
  lat = pi[j].lat;
1324
1320
  if (lon > extent.northEast.lon) {
@@ -1363,7 +1359,7 @@ class Polyline {
1363
1359
  k = 0,
1364
1360
  kk = 0;
1365
1361
 
1366
- //for (var i = 0; i < segmentIndex; i++) {
1362
+ //for (let i = 0; i < segmentIndex; i++) {
1367
1363
  // kk += this._path3v[i].length * 12 + 24;
1368
1364
  //}
1369
1365
  kk = this._pathLengths[segmentIndex] * 12 + 24 * segmentIndex;
@@ -1432,7 +1428,7 @@ class Polyline {
1432
1428
  extent.northEast.set(-180.0, -90.0);
1433
1429
  for (let i = 0; i < l.length; i++) {
1434
1430
  var pi = l[i];
1435
- for (var j = 0; j < pi.length; j++) {
1431
+ for (let j = 0; j < pi.length; j++) {
1436
1432
  var lon = pi[j].lon,
1437
1433
  lat = pi[j].lat;
1438
1434
  if (lon > extent.northEast.lon) {
@@ -1686,7 +1682,7 @@ class Polyline {
1686
1682
  let c = this._colors;
1687
1683
 
1688
1684
  //optimized with this._pathLengths
1689
- //for (var i = 0; i < segmentIndex; i++) {
1685
+ //for (let i = 0; i < segmentIndex; i++) {
1690
1686
  // kk += this._path3v[i].length * 16 + 32;
1691
1687
  //}
1692
1688
 
@@ -1763,7 +1759,9 @@ class Polyline {
1763
1759
  this._createData3v([].concat(this._path3v));
1764
1760
  }
1765
1761
  this._refresh();
1766
- this._update();
1762
+ if (renderNode.renderer.isInitialized()) {
1763
+ this._update();
1764
+ }
1767
1765
  }
1768
1766
  }
1769
1767
 
@@ -1,109 +1,105 @@
1
- /**
2
- * @module og/entity/PolylineHandler
3
- */
4
-
5
- 'use strict';
6
-
7
- import * as shaders from '../shaders/polyline.js';
8
-
9
- class PolylineHandler {
10
- constructor(entityCollection) {
11
-
12
- this._entityCollection = entityCollection;
13
-
14
- this._renderer = null;
15
-
16
- this._polylines = [];
17
-
18
- this.__staticId = PolylineHandler._staticCounter++;
19
-
20
- this.pickingEnabled = true;
21
- }
22
-
23
- static get _staticCounter() {
24
- if (!this._counter && this._counter !== 0) {
25
- this._counter = 0;
26
- }
27
- return this._counter;
28
- }
29
-
30
- static set _staticCounter(n) {
31
- this._counter = n;
32
- }
33
-
34
- _initProgram() {
35
- if (this._renderer.handler) {
36
- if (!this._renderer.handler.programs.polyline_screen) {
37
- this._renderer.handler.addProgram(shaders.polyline_screen());
38
- }
39
- if (!this._renderer.handler.programs.polyline_picking) {
40
- this._renderer.handler.addProgram(shaders.polyline_picking());
41
- }
42
- }
43
- }
44
-
45
- setRenderNode(renderNode) {
46
- this._renderer = renderNode.renderer;
47
- this._initProgram();
48
- for (var i = 0; i < this._polylines.length; i++) {
49
- this._polylines[i].setRenderNode(renderNode);
50
- }
51
- }
52
-
53
- add(polyline) {
54
- if (polyline._handlerIndex === -1) {
55
- polyline._handler = this;
56
- polyline._handlerIndex = this._polylines.length;
57
- this._polylines.push(polyline);
58
- this._entityCollection && this._entityCollection.renderNode &&
59
- polyline.setRenderNode(this._entityCollection.renderNode);
60
- }
61
- }
62
-
63
- remove(polyline) {
64
- var index = polyline._handlerIndex;
65
- if (index !== -1) {
66
- polyline._deleteBuffers();
67
- polyline._handlerIndex = -1;
68
- polyline._handler = null;
69
- this._polylines.splice(index, 1);
70
- this.reindexPolylineArray(index);
71
- }
72
- }
73
-
74
- reindexPolylineArray(startIndex) {
75
- var ls = this._polylines;
76
- for (var i = startIndex; i < ls.length; i++) {
77
- ls[i]._handlerIndex = i;
78
- }
79
- }
80
-
81
- draw() {
82
- let i = this._polylines.length;
83
- while (i--) {
84
- this._polylines[i].draw();
85
- }
86
- }
87
-
88
- drawPicking() {
89
- if (this.pickingEnabled) {
90
- let i = this._polylines.length;
91
- while (i--) {
92
- this._polylines[i].drawPicking();
93
- }
94
- }
95
- }
96
-
97
- clear() {
98
- var i = this._polylines.length;
99
- while (i--) {
100
- this._polylines[i]._deleteBuffers();
101
- this._polylines[i]._handler = null;
102
- this._polylines[i]._handlerIndex = -1;
103
- }
104
- this._polylines.length = 0;
105
- this._polylines = [];
106
- }
107
- }
108
-
1
+ 'use strict';
2
+
3
+ import * as shaders from '../shaders/polyline.js';
4
+
5
+ class PolylineHandler {
6
+ constructor(entityCollection) {
7
+
8
+ this._entityCollection = entityCollection;
9
+
10
+ this._renderer = null;
11
+
12
+ this._polylines = [];
13
+
14
+ this.__staticId = PolylineHandler._staticCounter++;
15
+
16
+ this.pickingEnabled = true;
17
+ }
18
+
19
+ static get _staticCounter() {
20
+ if (!this._counter && this._counter !== 0) {
21
+ this._counter = 0;
22
+ }
23
+ return this._counter;
24
+ }
25
+
26
+ static set _staticCounter(n) {
27
+ this._counter = n;
28
+ }
29
+
30
+ _initProgram() {
31
+ if (this._renderer.handler) {
32
+ if (!this._renderer.handler.programs.polyline_screen) {
33
+ this._renderer.handler.addProgram(shaders.polyline_screen());
34
+ }
35
+ if (!this._renderer.handler.programs.polyline_picking) {
36
+ this._renderer.handler.addProgram(shaders.polyline_picking());
37
+ }
38
+ }
39
+ }
40
+
41
+ setRenderNode(renderNode) {
42
+ this._renderer = renderNode.renderer;
43
+ this._initProgram();
44
+ for (let i = 0; i < this._polylines.length; i++) {
45
+ this._polylines[i].setRenderNode(renderNode);
46
+ }
47
+ }
48
+
49
+ add(polyline) {
50
+ if (polyline._handlerIndex === -1) {
51
+ polyline._handler = this;
52
+ polyline._handlerIndex = this._polylines.length;
53
+ this._polylines.push(polyline);
54
+ this._entityCollection && this._entityCollection.renderNode &&
55
+ polyline.setRenderNode(this._entityCollection.renderNode);
56
+ }
57
+ }
58
+
59
+ remove(polyline) {
60
+ var index = polyline._handlerIndex;
61
+ if (index !== -1) {
62
+ polyline._deleteBuffers();
63
+ polyline._handlerIndex = -1;
64
+ polyline._handler = null;
65
+ this._polylines.splice(index, 1);
66
+ this.reindexPolylineArray(index);
67
+ }
68
+ }
69
+
70
+ reindexPolylineArray(startIndex) {
71
+ var ls = this._polylines;
72
+ for (let i = startIndex; i < ls.length; i++) {
73
+ ls[i]._handlerIndex = i;
74
+ }
75
+ }
76
+
77
+ draw() {
78
+ let i = this._polylines.length;
79
+ while (i--) {
80
+ this._polylines[i].draw();
81
+ }
82
+ }
83
+
84
+ drawPicking() {
85
+ if (this.pickingEnabled) {
86
+ let i = this._polylines.length;
87
+ while (i--) {
88
+ this._polylines[i].drawPicking();
89
+ }
90
+ }
91
+ }
92
+
93
+ clear() {
94
+ var i = this._polylines.length;
95
+ while (i--) {
96
+ this._polylines[i]._deleteBuffers();
97
+ this._polylines[i]._handler = null;
98
+ this._polylines[i]._handlerIndex = -1;
99
+ }
100
+ this._polylines.length = 0;
101
+ this._polylines = [];
102
+ }
103
+ }
104
+
109
105
  export { PolylineHandler };