@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
@@ -49,7 +49,7 @@ class Camera {
49
49
  * @public
50
50
  * @type {Vec3}
51
51
  */
52
- this.eye = new Vec3();
52
+ this.eye = options.eye || new Vec3();
53
53
 
54
54
  /**
55
55
  * Camera RTE high position
@@ -70,7 +70,7 @@ class Camera {
70
70
  * @protected
71
71
  * @type {Number}
72
72
  */
73
- this._aspect = options.aspect || this.renderer.handler.getClientAspect();
73
+ this._aspect = options.aspect || 1.0;
74
74
 
75
75
  /**
76
76
  * Camera view angle in degrees
@@ -143,7 +143,6 @@ class Camera {
143
143
 
144
144
  fr._cameraFrustumIndex = this.frustums.length;
145
145
  this.frustums.push(fr);
146
- this.renderer.assignPickingColor(fr);
147
146
  this.nearFarArr.push.apply(this.nearFarArr, [fi[0], fi[1]]);
148
147
  this.frustumColors.push.apply(this.frustumColors, fr._pickingColorU);
149
148
  }
@@ -160,7 +159,6 @@ class Camera {
160
159
 
161
160
  fr._cameraFrustumIndex = this.frustums.length;
162
161
  this.frustums.push(fr);
163
- this.renderer.assignPickingColor(fr);
164
162
  this.nearFarArr = new Array([near, far]);
165
163
  this.frustumColors.push.apply(this.frustumColors, fr._pickingColorU);
166
164
  }
@@ -171,7 +169,11 @@ class Camera {
171
169
 
172
170
  this.isFirstPass = false;
173
171
 
174
- renderer && this._init(options);
172
+ this.set(
173
+ options.eye || new Vec3(0.0, 0.0, 1.0),
174
+ options.look || new Vec3(),
175
+ options.up || new Vec3(0.0, 1.0, 0.0)
176
+ );
175
177
  }
176
178
 
177
179
  checkMoveEnd() {
@@ -195,6 +197,16 @@ class Camera {
195
197
  this._peye.copy(eye);
196
198
  }
197
199
 
200
+ bindRenderer(renderer) {
201
+ this.renderer = renderer;
202
+ for (let i = 0; i < this.frustums.length; i++) {
203
+ this.renderer.assignPickingColor(this.frustums[i]);
204
+ }
205
+ this._aspect = this.renderer.handler.getClientAspect();
206
+
207
+ this._setProj(this._viewAngle, this._aspect);
208
+ }
209
+
198
210
  /**
199
211
  * Camera initialization.
200
212
  * @public
@@ -208,6 +220,7 @@ class Camera {
208
220
  * @param {Vec3} [options.up] - Camera eye position. Default (0,1,0)
209
221
  */
210
222
  _init(options) {
223
+
211
224
  this._setProj(this._viewAngle, this._aspect);
212
225
 
213
226
  this.set(
@@ -478,9 +491,9 @@ class Camera {
478
491
  }
479
492
 
480
493
  /**
481
- * Gets projected 3d point to the 2d screen coordiantes
494
+ * Gets projected 3d point to the 2d screen coordinates
482
495
  * @public
483
- * @param {Vec3} v - Cartesian 3d coordiantes
496
+ * @param {Vec3} v - Cartesian 3d coordinates
484
497
  * @returns {Vec2} - Screen point coordinates
485
498
  */
486
499
  project(v) {
@@ -25,7 +25,7 @@ class Frustum {
25
25
  * @type {Array.<Array.<number>>}
26
26
  */
27
27
  this._f = new Array(6);
28
- for (var i = 0; i < 6; i++) {
28
+ for (let i = 0; i < 6; i++) {
29
29
  this._f[i] = new Array(4);
30
30
  }
31
31
 
@@ -224,7 +224,7 @@ class Frustum {
224
224
  */
225
225
  containsPoint(point) {
226
226
  var d;
227
- for (var p = 0; p < 6; p++) {
227
+ for (let p = 0; p < 6; p++) {
228
228
  d = point.dotArr(this._f[p]) + this._f[p][3];
229
229
  if (d <= 0) {
230
230
  return false;
@@ -304,11 +304,11 @@ class Frustum {
304
304
  cout,
305
305
  cin;
306
306
 
307
- for (var i = 0; i < 6; i++) {
307
+ for (let i = 0; i < 6; i++) {
308
308
  cout = 0;
309
309
  cin = 0;
310
310
 
311
- for (var k = 0; k < 8 && (cin === 0 || cout === 0); k++) {
311
+ for (let k = 0; k < 8 && (cin === 0 || cout === 0); k++) {
312
312
  var d = box.vertices[k].dotArr(this._f[i]) + this._f[i][3];
313
313
  if (d < 0) {
314
314
  cout++;
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/camera/PlanetCamera
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import { Key } from "../Lock.js";
@@ -24,9 +20,9 @@ import { Ellipsoid } from "../ellipsoid/index.js";
24
20
  * @param {Object} [options.name] - Camera name.
25
21
  * @param {number} [options.viewAngle] - Camera angle of view.
26
22
  * @param {number} [options.near] - Camera near plane distance. Default is 1.0
27
- * @param {number} [options.far] - Camera far plane distance. Deafult is og.math.MAX
28
- * @param {number} [options.minAltitude] - Minimal altitude for the camera. Deafult is 5
29
- * @param {number} [options.maxAltitude] - Maximal altitude for the camera. Deafult is 20000000
23
+ * @param {number} [options.far] - Camera far plane distance. Default is og.math.MAX
24
+ * @param {number} [options.minAltitude] - Minimal altitude for the camera. Default is 5
25
+ * @param {number} [options.maxAltitude] - Maximal altitude for the camera. Default is 20000000
30
26
  * @param {Vec3} [options.eye] - Camera eye position. Default (0,0,0)
31
27
  * @param {Vec3} [options.look] - Camera look position. Default (0,0,0)
32
28
  * @param {Vec3} [options.up] - Camera eye position. Default (0,1,0)
@@ -39,10 +35,7 @@ class PlanetCamera extends Camera {
39
35
  constructor(planet, options) {
40
36
  super(planet.renderer, {
41
37
  frustums: [
42
- [1, 100 + 0.075],
43
- [100, 1000 + 0.075],
44
- [1000, 1e6 + 10000],
45
- [1e6, 1e9]
38
+ [[1, 100], [100, 1000 + 7.0], [1000 - 7.0, 1e6 + 17], [1e6 - 17, 1e9]]
46
39
  ], //[[1, 1e3 + 100], [1e3, 1e6 + 10000], [1e6, 1e9]]*/
47
40
  ...options
48
41
  }
@@ -191,7 +184,7 @@ class PlanetCamera extends Camera {
191
184
  var el = this.planet.ellipsoid;
192
185
  var newEye = el.lonLatToCartesian(this._lonLat);
193
186
  var newLook = lookLonLat ? el.lonLatToCartesian(lookLonLat) : Vec3.ZERO;
194
- this.set(newEye, newLook, up || Vec3.UP);
187
+ this.set(newEye, newLook, up || Vec3.NORTH);
195
188
  this.update();
196
189
  }
197
190
 
@@ -256,7 +249,7 @@ class PlanetCamera extends Camera {
256
249
  southWest.subA(center);
257
250
 
258
251
  var direction = center.normal(); // ellipsoid.getSurfaceNormal(center).negate().normalize();
259
- var right = direction.cross(Vec3.UP).normalize();
252
+ var right = direction.cross(Vec3.NORTH).normalize();
260
253
  var up = right.cross(direction).normalize();
261
254
 
262
255
  var _h = Math.max(
@@ -290,7 +283,7 @@ class PlanetCamera extends Camera {
290
283
  */
291
284
  viewExtent(extent, height) {
292
285
  this.stopFlying();
293
- this.set(this.getExtentPosition(extent, height), Vec3.ZERO, Vec3.UP);
286
+ this.set(this.getExtentPosition(extent, height), Vec3.ZERO, Vec3.NORTH);
294
287
  this.update();
295
288
  }
296
289
 
@@ -369,7 +362,7 @@ class PlanetCamera extends Camera {
369
362
  * @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
370
363
  * @param [frameCallback]
371
364
  */
372
- flyCartesian(cartesian, look = Vec3.ZERO, up = Vec3.UP, ampl = 1.0, completeCallback = () => {
365
+ flyCartesian(cartesian, look = Vec3.ZERO, up = Vec3.NORTH, ampl = 1.0, completeCallback = () => {
373
366
  }, startCallback = () => {
374
367
  }, frameCallback = () => {
375
368
  }) {
@@ -377,7 +370,7 @@ class PlanetCamera extends Camera {
377
370
  this.stopFlying();
378
371
 
379
372
  look = look || Vec3.ZERO;
380
- up = up || Vec3.UP;
373
+ up = up || Vec3.NORTH;
381
374
 
382
375
  this._completeCallback = completeCallback;
383
376
 
@@ -423,7 +416,7 @@ class PlanetCamera extends Camera {
423
416
  var zero = Vec3.ZERO;
424
417
 
425
418
  // camera path and orientations calculation
426
- for (var i = 0; i <= this._numFrames; i++) {
419
+ for (let i = 0; i <= this._numFrames; i++) {
427
420
  var d = 1 - i / this._numFrames;
428
421
  d = d * d * (3 - 2 * d);
429
422
  d *= d;
@@ -461,7 +454,7 @@ class PlanetCamera extends Camera {
461
454
  }
462
455
 
463
456
  /**
464
- * Flies to the geo coordiantes.
457
+ * Flies to the geo coordinates.
465
458
  * @public
466
459
  * @param {LonLat} lonlat - Finish coordinates.
467
460
  * @param {Vec3} [look] - Camera LOOK in the end of flying. Default - (0,0,0)
@@ -471,9 +464,9 @@ class PlanetCamera extends Camera {
471
464
  * @param {cameraCallback} [startCallback] - Callback that calls befor the flying begins.
472
465
  */
473
466
  flyLonLat(lonlat, look, up, ampl, completeCallback, startCallback) {
474
- var _lonlat = new LonLat(lonlat.lon, lonlat.lat, lonlat.height || this._lonLat.height);
467
+ var _lonLat = new LonLat(lonlat.lon, lonlat.lat, lonlat.height || this._lonLat.height);
475
468
  this.flyCartesian(
476
- this.planet.ellipsoid.lonLatToCartesian(_lonlat),
469
+ this.planet.ellipsoid.lonLatToCartesian(_lonLat),
477
470
  look,
478
471
  up,
479
472
  ampl,
@@ -626,7 +619,7 @@ class PlanetCamera extends Camera {
626
619
  if (this._insideSegment && this._insideSegment.planet) {
627
620
  this._terrainAltitude = this._insideSegment.getTerrainPoint(
628
621
  this.eye,
629
- this._lonLatMerc,
622
+ this._insideSegment.getInsideLonLat(this),
630
623
  this._terrainPoint
631
624
  );
632
625
  if (this._terrainAltitude < this.minAltitude && this._checkTerrainCollision) {
@@ -647,7 +640,7 @@ class PlanetCamera extends Camera {
647
640
  this.slope >= 0.97 ? this.getUp() : this.getForward(),
648
641
  u
649
642
  ).normalize(),
650
- n = Vec3.proj_b_to_plane(Vec3.UP, u).normalize();
643
+ n = Vec3.proj_b_to_plane(Vec3.NORTH, u).normalize();
651
644
  let res = Math.sign(u.dot(f.cross(n))) * Math.acos(f.dot(n)) * math.DEGREES;
652
645
  if (res < 0.0) {
653
646
  return 360.0 + res;
package/src/og/cons.js CHANGED
@@ -94,7 +94,7 @@ export class Cons {
94
94
  var d = document.createElement("div");
95
95
  d.classList.add("ogConsole-text");
96
96
  if (style) {
97
- for (var s in style) {
97
+ for (let s in style) {
98
98
  d.style[s] = style[s];
99
99
  }
100
100
  }
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/control/Atmosphere
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import * as atmos from "../shaders/atmos.js";
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/control/Control
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  /**
@@ -121,10 +117,12 @@ class Control {
121
117
  this.renderer = renderer;
122
118
  renderer.controls[this.name] = this;
123
119
  this.onadd && this.onadd();
124
- this._initialized = true;
125
- this.oninit && this.oninit();
126
- if (this.autoActivate) {
127
- this.activate();
120
+ if (renderer.isInitialized()) {
121
+ this._initialized = true;
122
+ this.oninit && this.oninit();
123
+ if (this.autoActivate) {
124
+ this.activate();
125
+ }
128
126
  }
129
127
  }
130
128
  }
@@ -134,6 +132,9 @@ class Control {
134
132
  * @public
135
133
  */
136
134
  remove() {
135
+
136
+ this.deactivate();
137
+
137
138
  this.onremove && this.onremove();
138
139
 
139
140
  let r = this.renderer,
@@ -1,7 +1,3 @@
1
- /**
2
- * @module og/control/DebugInfo
3
- */
4
-
5
1
  "use strict";
6
2
 
7
3
  import { Control } from "./Control.js";
@@ -94,7 +90,7 @@ class DebugInfo extends Control {
94
90
  }
95
91
 
96
92
  addWatches(watches) {
97
- for (var i = 0; i < watches.length; i++) {
93
+ for (let i = 0; i < watches.length; i++) {
98
94
  this.addWatch(watches[i]);
99
95
  }
100
96
  }
@@ -128,7 +124,7 @@ class DebugInfo extends Control {
128
124
 
129
125
  var temp = this._watch;
130
126
  this._watch = [];
131
- for (var i = 0; i < temp.length; i++) {
127
+ for (let i = 0; i < temp.length; i++) {
132
128
  this.addWatch(temp[i]);
133
129
  }
134
130
  this._dialog.container.appendChild(this.el);
@@ -249,7 +245,7 @@ class DebugInfo extends Control {
249
245
  }
250
246
 
251
247
  _frame() {
252
- for (var i = 0; i < this._watch.length; i++) {
248
+ for (let i = 0; i < this._watch.length; i++) {
253
249
  var w = this._watch[i];
254
250
  w.valEl.innerHTML = w.frame ? w.frame() : "";
255
251
  }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ import { ToggleButton } from "../ui/ToggleButton.js";
4
+ import { Control } from "./Control.js";
5
+ import { DrawingControl } from "./drawing/DrawingControl.js";
6
+ import { ButtonGroup } from "../ui/ButtonGroup.js";
7
+
8
+ const ICON_POLYGON_SVG = `<?xml version="1.0" encoding="utf-8"?>
9
+ <!-- Generator: Adobe Illustrator 24.1.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
10
+ <svg version="1.1" id="Layer_2" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
11
+ \t viewBox="0 0 1024 1024" style="enable-background:new 0 0 1024 1024;" xml:space="preserve">
12
+ <g>
13
+ \t<path d="M926.03,321.16c-16.02,0-31.11,3.94-44.48,10.79l-263.43-191.4c2.69-8.94,4.18-18.4,4.18-28.2
14
+ \t\tc0-54.02-43.95-97.97-97.97-97.97c-54.03,0-97.98,43.95-97.98,97.97c0,9.81,1.49,19.27,4.18,28.21L155.75,340.18
15
+ \t\tc-16.22-11.91-36.16-19.03-57.78-19.03C43.95,321.16,0,365.11,0,419.13c0,52.58,41.67,95.5,93.71,97.75l102.63,315.86
16
+ \t\tc-24.28,17.85-40.13,46.52-40.13,78.9c0,54.02,43.95,97.98,97.98,97.98c37.54,0,70.18-21.25,86.62-52.34h367.26
17
+ \t\tc16.44,31.08,49.08,52.34,86.63,52.34c54.03,0,97.98-43.95,97.98-97.98c0-32.46-15.94-61.21-40.33-79.05l104.11-320.4
18
+ \t\tc39.15-12.84,67.54-49.68,67.54-93.07C1024,365.11,980.05,321.16,926.03,321.16z M828.05,911.65c0,8.5-3.3,16.19-8.55,22.09
19
+ \t\tc-6.11,6.85-14.9,11.26-24.79,11.26c-13.65,0-25.37-8.26-30.52-20.02c-1.79-4.09-2.82-8.58-2.82-13.33
20
+ \t\tc0-18.39,14.95-33.35,33.34-33.35c2.93,0,5.72,0.5,8.43,1.21c13.27,3.49,23.21,14.91,24.59,28.9
21
+ \t\tC827.83,909.5,828.05,910.54,828.05,911.65z M790.48,813.89c-45.63,1.96-83.27,35.16-91.87,78.77H350.28
22
+ \t\tc-8.62-43.69-46.38-76.93-92.11-78.79L155.59,498.19c24.41-17.84,40.36-46.59,40.36-79.06c0-8.9-1.3-17.49-3.53-25.7L468.57,192.8
23
+ \t\tc15.84,11.01,35.05,17.52,55.76,17.52c20.71,0,39.92-6.5,55.76-17.52l256.56,186.4c-5.48,12.21-8.59,25.7-8.59,39.93
24
+ \t\tc0,41.02,25.36,76.17,61.21,90.75L790.48,813.89z M254.19,945c-10.11,0-19.07-4.62-25.19-11.75c-5.01-5.84-8.15-13.32-8.15-21.6
25
+ \t\tc0-0.91,0.2-1.76,0.27-2.66c1.14-14.18,11.08-25.8,24.43-29.41c2.78-0.75,5.64-1.28,8.65-1.28c18.38,0,33.33,14.96,33.33,33.35
26
+ \t\tc0,4.74-1.03,9.24-2.82,13.33C279.55,936.74,267.83,945,254.19,945z M64.88,421.49c-0.06-0.79-0.24-1.55-0.24-2.35
27
+ \t\tc0-16.41,11.93-30.01,27.55-32.76c1.89-0.33,3.8-0.58,5.78-0.58c11.94,0,22.35,6.36,28.24,15.81c3.18,5.11,5.11,11.09,5.11,17.53
28
+ \t\tc0,15.47-10.63,28.39-24.94,32.14c-2.7,0.71-5.48,1.2-8.4,1.2C80.4,452.47,66.11,438.76,64.88,421.49z M549.41,90.62
29
+ \t\tc5.07,5.85,8.25,13.39,8.25,21.72c0,7.32-2.44,14.03-6.45,19.54c-6.07,8.33-15.82,13.81-26.88,13.81
30
+ \t\tc-11.07,0-20.83-5.48-26.89-13.81c-4.01-5.51-6.45-12.22-6.45-19.54c0-8.33,3.17-15.86,8.24-21.71
31
+ \t\tc6.12-7.07,15.04-11.64,25.1-11.64C534.38,79,543.29,83.57,549.41,90.62z M959.36,419.13c0,11.94-6.36,22.35-15.82,28.24
32
+ \t\tc-5.1,3.18-11.07,5.1-17.52,5.1c-6.08,0-11.71-1.76-16.62-4.61c-9.71-5.64-16.33-15.94-16.64-27.89c-0.01-0.29-0.09-0.56-0.09-0.85
33
+ \t\tc0-11.75,6.14-22.05,15.36-28c5.2-3.35,11.35-5.35,17.99-5.35C944.41,385.78,959.36,400.75,959.36,419.13z"/>
34
+ </g>
35
+ </svg>`;
36
+
37
+ const ICON_LINESTRING_SVG = `<?xml version="1.0" encoding="utf-8"?><!-- License: MIT. Made by Esri: https://github.com/Esri/calcite-ui-icons -->
38
+ <svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M21 6h.046l-5.25 9h-.944L10 9.455V7H7v2.926L1.862 18H0v3h3v-2.926L8.138 10h1.01L14 15.545V18h3v-3h-.046l5.25-9H24V3h-3zM8 8h1v1H8zM2 20H1v-1h1zm14-3h-1v-1h1zm7-13v1h-1V4z"/></svg>`;
39
+
40
+ const ICON_DEFAULT_SVG = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M4 0l16 12.279-6.951 1.17 4.325 8.817-3.596 1.734-4.35-8.879-5.428 4.702z"/></svg>`;
41
+
42
+ /**
43
+ * Activate drawing control
44
+ * @class
45
+ * @extends {Control}
46
+ * @param {Object} [options] - Control options.
47
+ */
48
+ class DrawingSwitcher extends Control {
49
+ constructor(options = {}) {
50
+ super({
51
+ name: "DrawingSwitcher",
52
+ ...options
53
+ });
54
+
55
+ this.drawingControl = new DrawingControl();
56
+ }
57
+
58
+ oninit() {
59
+ this.planet.addControl(this.drawingControl);
60
+ this._createMenu();
61
+ }
62
+
63
+ onactivate() {
64
+ this.drawingControl.activate();
65
+ }
66
+
67
+ ondeactivate() {
68
+ this.drawingControl.deactivate();
69
+ }
70
+
71
+ _createMenu() {
72
+
73
+ let defaultBtn = new ToggleButton({
74
+ classList: ["og-map-button", "og-drawing-default_button"],
75
+ icon: ICON_DEFAULT_SVG,
76
+ name: "default",
77
+ isActive: true
78
+ });
79
+
80
+ let polyBtn = new ToggleButton({
81
+ classList: ["og-map-button", "og-drawing-polygon_button"],
82
+ icon: ICON_POLYGON_SVG,
83
+ name: "polygon"
84
+ });
85
+
86
+ let lineBtn = new ToggleButton({
87
+ classList: ["og-map-button", "og-drawing-linestring_button"],
88
+ icon: ICON_LINESTRING_SVG,
89
+ name: "linestring"
90
+ });
91
+
92
+ let buttons = new ButtonGroup({
93
+ buttons: [
94
+ defaultBtn, polyBtn, lineBtn
95
+ ]
96
+ });
97
+
98
+ buttons.on("change", (btn) => {
99
+ this.drawingControl.deactivate();
100
+ switch (btn.name) {
101
+ case "polygon":
102
+ this.drawingControl.activatePolygonDrawing();
103
+ break;
104
+ case "linestring":
105
+ this.drawingControl.activateLineStringDrawing();
106
+ break;
107
+ }
108
+ });
109
+
110
+ defaultBtn.appendTo(this.renderer.div)
111
+ polyBtn.appendTo(this.renderer.div);
112
+ lineBtn.appendTo(this.renderer.div);
113
+ }
114
+ }
115
+
116
+ export { DrawingSwitcher };
117
+