@openglobus/og 0.11.1 → 0.11.6

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 (255) hide show
  1. package/package.json +18 -20
  2. package/src/og/Clock.js +11 -11
  3. package/src/og/Deferred.js +1 -1
  4. package/src/og/Events.js +9 -7
  5. package/src/og/Extent.js +117 -72
  6. package/src/og/Globe.js +35 -22
  7. package/src/og/ImageCanvas.js +24 -18
  8. package/src/og/Lock.js +2 -2
  9. package/src/og/LonLat.js +40 -37
  10. package/src/og/Popup.js +21 -15
  11. package/src/og/QueueArray.js +7 -3
  12. package/src/og/Rectangle.js +11 -6
  13. package/src/og/Stack.js +8 -5
  14. package/src/og/ajax.js +21 -33
  15. package/src/og/astro/astro.js +5 -5
  16. package/src/og/astro/earth.js +23 -17
  17. package/src/og/astro/jd.js +44 -39
  18. package/src/og/astro/orbit.js +20 -18
  19. package/src/og/astro/rotation.js +17 -8
  20. package/src/og/bv/Box.js +7 -3
  21. package/src/og/bv/Sphere.js +17 -9
  22. package/src/og/camera/Camera.js +137 -86
  23. package/src/og/camera/Frustum.js +30 -19
  24. package/src/og/camera/PlanetCamera.js +30 -26
  25. package/src/og/control/CompassButton.js +8 -2
  26. package/src/og/control/Control.js +13 -11
  27. package/src/og/control/DebugInfo.js +4 -1
  28. package/src/og/control/EarthCoordinates.js +62 -41
  29. package/src/og/control/EarthNavigation.js +20 -22
  30. package/src/og/control/GeoImageDragControl.js +1 -1
  31. package/src/og/control/KeyboardNavigation.js +12 -12
  32. package/src/og/control/LayerSwitcher.js +24 -23
  33. package/src/og/control/Lighting.js +1 -1
  34. package/src/og/control/MouseNavigation.js +1 -1
  35. package/src/og/control/ScaleControl.js +1 -1
  36. package/src/og/control/SegmentBoundVisualization.js +8 -9
  37. package/src/og/control/ShowFps.js +15 -10
  38. package/src/og/control/SimpleNavigation.js +8 -10
  39. package/src/og/control/Sun.js +25 -15
  40. package/src/og/control/ToggleWireframe.js +5 -5
  41. package/src/og/control/TouchNavigation.js +58 -45
  42. package/src/og/control/ZoomControl.js +41 -25
  43. package/src/og/control/index.js +4 -0
  44. package/src/og/ellipsoid/Ellipsoid.js +181 -85
  45. package/src/og/ellipsoid/wgs84.js +4 -4
  46. package/src/og/entity/BaseBillboard.js +97 -44
  47. package/src/og/entity/Billboard.js +15 -11
  48. package/src/og/entity/BillboardHandler.js +314 -64
  49. package/src/og/entity/Entity.js +106 -74
  50. package/src/og/entity/EntityCollection.js +72 -49
  51. package/src/og/entity/GeoObject.js +228 -0
  52. package/src/og/entity/GeoObjectHandler.js +910 -0
  53. package/src/og/entity/Geometry.js +29 -26
  54. package/src/og/entity/GeometryHandler.js +598 -126
  55. package/src/og/entity/Label.js +74 -40
  56. package/src/og/entity/LabelHandler.js +47 -246
  57. package/src/og/entity/LabelWorker.js +213 -0
  58. package/src/og/entity/Object3d.js +504 -0
  59. package/src/og/entity/PointCloud.js +81 -33
  60. package/src/og/entity/PointCloudHandler.js +9 -9
  61. package/src/og/entity/Polyline.js +39 -39
  62. package/src/og/entity/Ray.js +61 -28
  63. package/src/og/entity/ShapeHandler.js +1 -1
  64. package/src/og/entity/Strip.js +77 -48
  65. package/src/og/entity/StripHandler.js +27 -27
  66. package/src/og/entity/index.js +8 -16
  67. package/src/og/input/KeyboardHandler.js +107 -104
  68. package/src/og/input/MouseHandler.js +81 -78
  69. package/src/og/input/TouchHandler.js +55 -51
  70. package/src/og/layer/BaseGeoImage.js +61 -30
  71. package/src/og/layer/CanvasTiles.js +26 -24
  72. package/src/og/layer/GeoImage.js +10 -10
  73. package/src/og/layer/GeoTexture2d.js +1 -1
  74. package/src/og/layer/GeoVideo.js +3 -3
  75. package/src/og/layer/KML.js +66 -40
  76. package/src/og/layer/Layer.js +27 -17
  77. package/src/og/layer/Material.js +93 -61
  78. package/src/og/layer/Vector.js +118 -72
  79. package/src/og/layer/WMS.js +36 -19
  80. package/src/og/layer/XYZ.js +55 -48
  81. package/src/og/light/LightSource.js +47 -40
  82. package/src/og/math/Line2.js +24 -24
  83. package/src/og/math/Line3.js +103 -102
  84. package/src/og/math/Mat3.js +134 -121
  85. package/src/og/math/Mat4.js +603 -459
  86. package/src/og/math/Plane.js +21 -20
  87. package/src/og/math/Quat.js +980 -927
  88. package/src/og/math/Ray.js +195 -187
  89. package/src/og/math/Vec2.js +127 -117
  90. package/src/og/math/Vec3.js +206 -176
  91. package/src/og/math/Vec4.js +49 -53
  92. package/src/og/math/coder.js +18 -18
  93. package/src/og/math.js +12 -12
  94. package/src/og/mercator.js +11 -11
  95. package/src/og/proj/EPSG3857.js +4 -4
  96. package/src/og/proj/EPSG4326.js +4 -4
  97. package/src/og/proj/Proj.js +31 -31
  98. package/src/og/quadTree/EntityCollectionNode.js +310 -300
  99. package/src/og/quadTree/Node.js +1008 -993
  100. package/src/og/renderer/Renderer.js +768 -747
  101. package/src/og/renderer/RendererEvents.js +9 -6
  102. package/src/og/scene/Axes.js +1 -1
  103. package/src/og/scene/BaseNode.js +8 -9
  104. package/src/og/scene/Planet.js +115 -87
  105. package/src/og/scene/RenderNode.js +29 -22
  106. package/src/og/scene/SkyBox.js +1 -1
  107. package/src/og/segment/Segment.js +1886 -1878
  108. package/src/og/segment/SegmentLonLat.js +298 -268
  109. package/src/og/segment/segmentHelper.js +11 -11
  110. package/src/og/shaders/bloom.js +1 -1
  111. package/src/og/shaders/blur.js +2 -2
  112. package/src/og/shaders/depth.js +1 -1
  113. package/src/og/shaders/geoObject.js +211 -0
  114. package/src/og/shaders/label.js +1 -1
  115. package/src/og/shaders/lumFilter.js +1 -1
  116. package/src/og/shaders/pointCloud.js +42 -42
  117. package/src/og/shaders/screenFrame.js +1 -1
  118. package/src/og/shaders/shape.js +15 -21
  119. package/src/og/shaders/skybox.js +37 -37
  120. package/src/og/shaders/toneMapping.js +1 -1
  121. package/src/og/shapes/BaseShape.js +129 -57
  122. package/src/og/shapes/Icosphere.js +30 -15
  123. package/src/og/shapes/Sphere.js +13 -16
  124. package/src/og/terrain/BilTerrain.js +2 -1
  125. package/src/og/terrain/EmptyTerrain.js +2 -2
  126. package/src/og/terrain/Geoid.js +2 -2
  127. package/src/og/terrain/GlobusTerrain.js +10 -10
  128. package/src/og/terrain/MapboxTerrain.js +1 -1
  129. package/src/og/utils/GeoImageCreator.js +9 -9
  130. package/src/og/utils/Loader.js +6 -6
  131. package/src/og/utils/NormalMapCreator.js +13 -13
  132. package/src/og/utils/TerrainWorker.js +1 -1
  133. package/src/og/utils/TextureAtlas.js +20 -22
  134. package/src/og/utils/VectorTileCreator.js +5 -5
  135. package/src/og/utils/earcut.js +1 -1
  136. package/src/og/utils/shared.js +15 -15
  137. package/src/og/webgl/Framebuffer.js +101 -53
  138. package/src/og/webgl/Handler.js +125 -85
  139. package/src/og/webgl/Multisample.js +55 -27
  140. package/src/og/webgl/Program.js +80 -35
  141. package/src/og/webgl/ProgramController.js +27 -23
  142. package/src/og/webgl/callbacks.js +8 -8
  143. package/types/Clock.d.ts +6 -2
  144. package/types/Deferred.d.ts +1 -1
  145. package/types/Events.d.ts +8 -4
  146. package/types/Extent.d.ts +37 -33
  147. package/types/Globe.d.ts +15 -13
  148. package/types/ImageCanvas.d.ts +5 -3
  149. package/types/LonLat.d.ts +24 -24
  150. package/types/Popup.d.ts +4 -0
  151. package/types/QueueArray.d.ts +6 -2
  152. package/types/Rectangle.d.ts +10 -4
  153. package/types/Stack.d.ts +4 -0
  154. package/types/ajax.d.ts +1 -1
  155. package/types/astro/earth.d.ts +3 -2
  156. package/types/bv/Box.d.ts +10 -5
  157. package/types/bv/Sphere.d.ts +13 -7
  158. package/types/camera/Camera.d.ts +90 -81
  159. package/types/camera/Frustum.d.ts +26 -22
  160. package/types/camera/PlanetCamera.d.ts +49 -53
  161. package/types/control/CompassButton.d.ts +4 -4
  162. package/types/control/Control.d.ts +7 -4
  163. package/types/control/DebugInfo.d.ts +3 -4
  164. package/types/control/EarthCoordinates.d.ts +6 -6
  165. package/types/control/EarthNavigation.d.ts +42 -0
  166. package/types/control/KeyboardNavigation.d.ts +3 -4
  167. package/types/control/LayerSwitcher.d.ts +3 -5
  168. package/types/control/Lighting.d.ts +3 -3
  169. package/types/control/MouseNavigation.d.ts +47 -0
  170. package/types/control/ScaleControl.d.ts +3 -3
  171. package/types/control/ShowFps.d.ts +3 -4
  172. package/types/control/SimpleNavigation.d.ts +3 -6
  173. package/types/control/Sun.d.ts +8 -10
  174. package/types/control/ToggleWireframe.d.ts +3 -3
  175. package/types/control/TouchNavigation.d.ts +48 -0
  176. package/types/control/ZoomControl.d.ts +3 -4
  177. package/types/control/index.d.ts +3 -1
  178. package/types/ellipsoid/Ellipsoid.d.ts +47 -43
  179. package/types/ellipsoid/wgs84.d.ts +3 -2
  180. package/types/entity/BaseBillboard.d.ts +41 -34
  181. package/types/entity/Billboard.d.ts +7 -7
  182. package/types/entity/BillboardHandler.d.ts +4 -0
  183. package/types/entity/Entity.d.ts +101 -83
  184. package/types/entity/EntityCollection.d.ts +57 -43
  185. package/types/entity/GeoObject.d.ts +111 -0
  186. package/types/entity/GeoObjectHandler.d.ts +77 -0
  187. package/types/entity/Geometry.d.ts +9 -7
  188. package/types/entity/GeometryHandler.d.ts +2 -2
  189. package/types/entity/Label.d.ts +24 -29
  190. package/types/entity/LabelHandler.d.ts +9 -2
  191. package/types/entity/LabelWorker.d.ts +9 -0
  192. package/types/entity/PointCloud.d.ts +8 -8
  193. package/types/entity/PointCloudHandler.d.ts +3 -3
  194. package/types/entity/Polyline.d.ts +58 -55
  195. package/types/entity/Ray.d.ts +19 -18
  196. package/types/entity/Strip.d.ts +8 -7
  197. package/types/entity/StripHandler.d.ts +3 -3
  198. package/types/entity/index.d.ts +7 -7
  199. package/types/input/KeyboardHandler.d.ts +10 -0
  200. package/types/input/MouseHandler.d.ts +5 -0
  201. package/types/input/TouchHandler.d.ts +5 -0
  202. package/types/layer/BaseGeoImage.d.ts +23 -35
  203. package/types/layer/CanvasTiles.d.ts +15 -22
  204. package/types/layer/GeoImage.d.ts +5 -18
  205. package/types/layer/GeoVideo.d.ts +5 -30
  206. package/types/layer/KML.d.ts +20 -15
  207. package/types/layer/Layer.d.ts +326 -0
  208. package/types/layer/Material.d.ts +45 -0
  209. package/types/layer/Vector.d.ts +208 -0
  210. package/types/layer/WMS.d.ts +4 -7
  211. package/types/layer/XYZ.d.ts +19 -25
  212. package/types/light/LightSource.d.ts +54 -53
  213. package/types/math/Line2.d.ts +11 -0
  214. package/types/math/Line3.d.ts +10 -0
  215. package/types/math/Mat3.d.ts +30 -18
  216. package/types/math/Mat4.d.ts +71 -52
  217. package/types/math/Plane.d.ts +5 -4
  218. package/types/math/Quat.d.ts +379 -0
  219. package/types/math/Ray.d.ts +82 -0
  220. package/types/math/Vec2.d.ts +102 -101
  221. package/types/math/Vec3.d.ts +143 -142
  222. package/types/math/Vec4.d.ts +40 -39
  223. package/types/math/coder.d.ts +12 -11
  224. package/types/math.d.ts +8 -8
  225. package/types/mercator.d.ts +3 -3
  226. package/types/proj/EPSG3857.d.ts +3 -2
  227. package/types/proj/EPSG4326.d.ts +3 -2
  228. package/types/proj/Proj.d.ts +42 -0
  229. package/types/quadTree/EntityCollectionNode.d.ts +34 -0
  230. package/types/quadTree/Node.d.ts +61 -0
  231. package/types/renderer/Renderer.d.ts +300 -0
  232. package/types/renderer/RendererEvents.d.ts +10 -7
  233. package/types/scene/BaseNode.d.ts +9 -9
  234. package/types/scene/Planet.d.ts +131 -126
  235. package/types/scene/RenderNode.d.ts +22 -23
  236. package/types/segment/Segment.d.ts +279 -0
  237. package/types/segment/SegmentLonLat.d.ts +16 -0
  238. package/types/shaders/geoObject.d.ts +3 -0
  239. package/types/shapes/BaseShape.d.ts +43 -40
  240. package/types/shapes/Sphere.d.ts +7 -7
  241. package/types/terrain/BilTerrain.d.ts +0 -1
  242. package/types/terrain/EmptyTerrain.d.ts +4 -4
  243. package/types/terrain/GlobusTerrain.d.ts +17 -54
  244. package/types/terrain/MapboxTerrain.d.ts +0 -1
  245. package/types/utils/GeoImageCreator.d.ts +3 -2
  246. package/types/utils/TextureAtlas.d.ts +8 -8
  247. package/types/utils/shared.d.ts +25 -24
  248. package/types/webgl/Framebuffer.d.ts +5 -5
  249. package/types/webgl/Handler.d.ts +68 -43
  250. package/types/webgl/Multisample.d.ts +5 -5
  251. package/types/webgl/Program.d.ts +8 -2
  252. package/types/webgl/ProgramController.d.ts +18 -13
  253. package/src/og/inherits.js +0 -8
  254. package/src/og/utils/polylabel.js +0 -176
  255. package/types/inherits.d.ts +0 -4
@@ -2,24 +2,25 @@
2
2
  * @module og/entity/EntityCollection
3
3
  */
4
4
 
5
- 'use strict';
6
-
7
- import * as math from '../math.js';
8
- import { BillboardHandler } from './BillboardHandler.js';
9
- import { Events } from '../Events.js';
10
- import { LabelHandler } from './LabelHandler.js';
11
- import { PolylineHandler } from './PolylineHandler.js';
12
- import { RayHandler } from './RayHandler.js';
13
- import { PointCloudHandler } from './PointCloudHandler.js';
14
- import { StripHandler } from './StripHandler.js';
15
- import { ShapeHandler } from './ShapeHandler.js';
5
+ "use strict";
6
+
7
+ import * as math from "../math.js";
8
+ import { BillboardHandler } from "./BillboardHandler.js";
9
+ import { Events } from "../Events.js";
10
+ import { LabelHandler } from "./LabelHandler.js";
11
+ import { PolylineHandler } from "./PolylineHandler.js";
12
+ import { RayHandler } from "./RayHandler.js";
13
+ import { PointCloudHandler } from "./PointCloudHandler.js";
14
+ import { StripHandler } from "./StripHandler.js";
15
+ import { ShapeHandler } from "./ShapeHandler.js";
16
+ import { GeoObjectHandler } from "./GeoObjectHandler.js";
16
17
 
17
18
  /**
18
19
  * An observable collection of og.Entity instances where each entity has a unique id.
19
20
  * Entity collection provide handlers for an each type of entity like billboard, label or 3ds object.
20
21
  * @constructor
21
22
  * @param {Object} [options] - Entity options:
22
- * @param {Array.<og.Entity>} [options.entities] - Entities array.
23
+ * @param {Array.<Entity>} [options.entities] - Entities array.
23
24
  * @param {boolean} [options.visibility=true] - Entity visibility.
24
25
  * @param {Array.<number>} [options.scaleByDistance] - Entity scale by distance parameters. (exactly 3 entries)
25
26
  * First index - near distance to the entity, after entity becomes full scale.
@@ -65,7 +66,6 @@ import { ShapeHandler } from './ShapeHandler.js';
65
66
  */
66
67
  class EntityCollection {
67
68
  constructor(options) {
68
-
69
69
  options = options || {};
70
70
 
71
71
  /**
@@ -85,7 +85,7 @@ class EntityCollection {
85
85
  /**
86
86
  * Render node context.
87
87
  * @public
88
- * @type {og.scene.RenderNode}
88
+ * @type {RenderNode}
89
89
  */
90
90
  this.renderNode = null;
91
91
 
@@ -101,64 +101,73 @@ class EntityCollection {
101
101
  * @public
102
102
  * @type {Number}
103
103
  */
104
- this.polygonOffsetFactor = options.polygonOffsetFactor != undefined ? options.polygonOffsetFactor : 0.0;
104
+ this.polygonOffsetFactor =
105
+ options.polygonOffsetFactor != undefined ? options.polygonOffsetFactor : 0.0;
105
106
 
106
107
  /**
107
108
  * Specifies the scale Units for gl.polygonOffset function to calculate depth values, 0.0 is default.
108
109
  * @public
109
110
  * @type {Number}
110
111
  */
111
- this.polygonOffsetUnits = options.polygonOffsetUnits != undefined ? options.polygonOffsetUnits : 0.0;
112
+ this.polygonOffsetUnits =
113
+ options.polygonOffsetUnits != undefined ? options.polygonOffsetUnits : 0.0;
112
114
 
113
115
  /**
114
116
  * Billboards handler
115
117
  * @public
116
- * @type {og.BillboardHandler}
118
+ * @type {BillboardHandler}
117
119
  */
118
120
  this.billboardHandler = new BillboardHandler(this);
119
121
 
120
122
  /**
121
123
  * Labels handler
122
124
  * @public
123
- * @type {og.LabelHandler}
125
+ * @type {LabelHandler}
124
126
  */
125
127
  this.labelHandler = new LabelHandler(this, options.labelMaxLetters);
126
128
 
127
129
  /**
128
130
  * Shape handler
129
131
  * @public
130
- * @type {og.ShapeHandler}
132
+ * @type {ShapeHandler}
131
133
  */
132
134
  this.shapeHandler = new ShapeHandler(this);
133
135
 
134
136
  /**
135
137
  * Polyline handler
136
138
  * @public
137
- * @type {og.PolylineHandler}
139
+ * @type {PolylineHandler}
138
140
  */
139
141
  this.polylineHandler = new PolylineHandler(this);
140
142
 
141
143
  /**
142
144
  * Ray handler
143
145
  * @public
144
- * @type {og.RayHandler}
146
+ * @type {RayHandler}
145
147
  */
146
148
  this.rayHandler = new RayHandler(this);
147
149
 
148
150
  /**
149
151
  * PointCloud handler
150
152
  * @public
151
- * @type {og.PointCloudHandler}
153
+ * @type {PointCloudHandler}
152
154
  */
153
155
  this.pointCloudHandler = new PointCloudHandler(this);
154
156
 
155
157
  /**
156
158
  * Strip handler
157
159
  * @public
158
- * @type {og.StripHandler}
160
+ * @type {StripHandler}
159
161
  */
160
162
  this.stripHandler = new StripHandler(this);
161
163
 
164
+ /**
165
+ * Geo object handler
166
+ * @public
167
+ * @type {og.GeoObjectHandler}
168
+ */
169
+ this.geoObjectHandler = new GeoObjectHandler(this);
170
+
162
171
  if (options.pickingEnabled != undefined) {
163
172
  this.setPickingEnabled(options.pickingEnabled);
164
173
  }
@@ -166,7 +175,7 @@ class EntityCollection {
166
175
  /**
167
176
  * Entities array.
168
177
  * @protected
169
- * @type {Array.<og.Entity>}
178
+ * @type {Array.<Entity>}
170
179
  */
171
180
  this._entities = [];
172
181
 
@@ -175,7 +184,7 @@ class EntityCollection {
175
184
  * Second index - far distance to the entity, when entity becomes zero scale.
176
185
  * Third index - far distance to the entity, when entity becomes invisible.
177
186
  * @public
178
- * @type {Array.<number,number,number>}
187
+ * @type {Array.<number>} - (exactly 3 entries)
179
188
  */
180
189
  this.scaleByDistance = options.scaleByDistance || [math.MAX32, math.MAX32, math.MAX32];
181
190
 
@@ -198,7 +207,7 @@ class EntityCollection {
198
207
  /**
199
208
  * Entity collection events handler.
200
209
  * @public
201
- * @type {og.Events}
210
+ * @type {Events}
202
211
  */
203
212
  this.events = new Events(EVENT_NAMES, this);
204
213
 
@@ -268,6 +277,7 @@ class EntityCollection {
268
277
  this.shapeHandler.pickingEnabled = enable;
269
278
  this.pointCloudHandler.pickingEnabled = enable;
270
279
  this.stripHandler.pickingEnabled = enable;
280
+ this.geoObjectHandler.pickingEnabled = enable;
271
281
  }
272
282
 
273
283
  /**
@@ -293,7 +303,6 @@ class EntityCollection {
293
303
  }
294
304
 
295
305
  _addRecursively(entity) {
296
-
297
306
  // billboard
298
307
  entity.billboard && this.billboardHandler.add(entity.billboard);
299
308
 
@@ -315,6 +324,9 @@ class EntityCollection {
315
324
  // strip
316
325
  entity.strip && this.stripHandler.add(entity.strip);
317
326
 
327
+ //geoObject
328
+ entity.geoObject && this.geoObjectHandler.add(entity.geoObject);
329
+
318
330
  this.events.dispatch(this.events.entityadd, entity);
319
331
 
320
332
  for (var i = 0; i < entity.childrenNodes.length; i++) {
@@ -328,8 +340,8 @@ class EntityCollection {
328
340
  /**
329
341
  * Adds entity to the collection and returns collection.
330
342
  * @public
331
- * @param {og.Entity} entity - Entity.
332
- * @returns {og.EntityCollection} -
343
+ * @param {Entity} entity - Entity.
344
+ * @returns {EntityCollection} -
333
345
  */
334
346
  add(entity) {
335
347
  if (!entity._entityCollection) {
@@ -352,8 +364,8 @@ class EntityCollection {
352
364
  /**
353
365
  * Adds entities array to the collection and returns collection.
354
366
  * @public
355
- * @param {Array.<og.Entity>} entities - Entities array.
356
- * @returns {og.EntityCollection} -
367
+ * @param {Array.<Entity>} entities - Entities array.
368
+ * @returns {EntityCollection} -
357
369
  */
358
370
  addEntities(entities) {
359
371
  for (let i = 0, len = entities.length; i < len; i++) {
@@ -365,11 +377,14 @@ class EntityCollection {
365
377
  /**
366
378
  * Returns true if the entity belongs this collection, otherwise returns false.
367
379
  * @public
368
- * @param {og.Entity} entity - Entity.
380
+ * @param {Entity} entity - Entity.
369
381
  * @returns {boolean} -
370
382
  */
371
383
  belongs(entity) {
372
- return (entity._entityCollection && this._renderNodeIndex === entity._entityCollection._renderNodeIndex);
384
+ return (
385
+ entity._entityCollection &&
386
+ this._renderNodeIndex === entity._entityCollection._renderNodeIndex
387
+ );
373
388
  }
374
389
 
375
390
  _removeRecursively(entity) {
@@ -397,6 +412,9 @@ class EntityCollection {
397
412
  // strip
398
413
  entity.strip && this.stripHandler.remove(entity.strip);
399
414
 
415
+ // geoObject
416
+ entity.geoObject && this.geoObjectHandler.remove(entity.geoObject);
417
+
400
418
  for (var i = 0; i < entity.childrenNodes.length; i++) {
401
419
  this._removeRecursively(entity.childrenNodes[i]);
402
420
  }
@@ -405,7 +423,7 @@ class EntityCollection {
405
423
  /**
406
424
  * Removes entity from this collection.
407
425
  * @public
408
- * @param {og.Entity} entity - Entity to remove.
426
+ * @param {Entity} entity - Entity to remove.
409
427
  */
410
428
  removeEntity(entity) {
411
429
  this._entities.splice(entity._entityCollectionIndex, 1);
@@ -468,9 +486,9 @@ class EntityCollection {
468
486
  /**
469
487
  * Adds this collection to render node.
470
488
  * @public
471
- * @param {og.scene.RenderNode} renderNode - Render node.
489
+ * @param {RenderNode} renderNode - Render node.
472
490
  * @param {boolean} [isHidden] - Uses in vector layers that render in planet render specific function.
473
- * @returns {og.EntityCollection} -
491
+ * @returns {EntityCollection} -
474
492
  */
475
493
  addTo(renderNode, isHidden) {
476
494
  if (!this.renderNode) {
@@ -490,16 +508,16 @@ class EntityCollection {
490
508
 
491
509
  /**
492
510
  * This function is called in the RenderNode assign function.
493
- * @param {og.RenderNode} renderNode
511
+ * @param {RenderNode} renderNode
494
512
  */
495
513
  bindRenderNode(renderNode) {
496
-
497
514
  if (renderNode.renderer) {
498
-
499
515
  this.billboardHandler.setRenderer(renderNode.renderer);
500
516
  this.labelHandler.setRenderer(renderNode.renderer);
501
517
  this.rayHandler.setRenderer(renderNode.renderer);
502
518
 
519
+ this.geoObjectHandler.setRenderNode(renderNode);
520
+
503
521
  this.shapeHandler.setRenderNode(renderNode);
504
522
  this.polylineHandler.setRenderNode(renderNode);
505
523
  this.pointCloudHandler.setRenderNode(renderNode);
@@ -514,7 +532,7 @@ class EntityCollection {
514
532
  /**
515
533
  * Updates coordiantes all lonLat entities in collection after collecction attached to the planet node.
516
534
  * @private
517
- * @param {og.Ellipsoid} ellipsoid - Globe ellipsoid.
535
+ * @param {Ellipsoid} ellipsoid - Globe ellipsoid.
518
536
  */
519
537
  _updateGeodeticCoordinates(ellipsoid) {
520
538
  var e = this._entities;
@@ -542,9 +560,10 @@ class EntityCollection {
542
560
  */
543
561
  updateLabelsFontAtlas() {
544
562
  if (this.renderNode) {
545
- var l = this.labelHandler._billboards;
546
- for (var i = 0; i < l.length; i++) {
547
- l[i].assignFontAtlas(this.renderNode.renderer.fontAtlas);
563
+ var l = [].concat(this.labelHandler._billboards);
564
+ this.labelHandler._billboards = [];
565
+ for (var i = 0; i < l.length; i++) {
566
+ this.labelHandler.assignFontAtlas(l[i]);
548
567
  }
549
568
  }
550
569
  }
@@ -558,7 +577,11 @@ class EntityCollection {
558
577
  if (this._renderNodeIndex !== -1) {
559
578
  this.renderNode.entityCollections.splice(this._renderNodeIndex, 1);
560
579
  // reindex in the renderNode
561
- for (var i = this._renderNodeIndex; i < this.renderNode.entityCollections.length; i++) {
580
+ for (
581
+ var i = this._renderNodeIndex;
582
+ i < this.renderNode.entityCollections.length;
583
+ i++
584
+ ) {
562
585
  this.renderNode.entityCollections._renderNodeIndex = i;
563
586
  }
564
587
  }
@@ -571,7 +594,7 @@ class EntityCollection {
571
594
  /**
572
595
  * Gets entity array.
573
596
  * @public
574
- * @returns {Array.<og.Entity>} -
597
+ * @returns {Array.<Entity>} -
575
598
  */
576
599
  getEntities() {
577
600
  return [].concat(this._entities);
@@ -595,7 +618,6 @@ class EntityCollection {
595
618
  * @public
596
619
  */
597
620
  clear() {
598
-
599
621
  // TODO: Optimize by replace delete
600
622
  // code to the clearEntity function.
601
623
  this.billboardHandler.clear();
@@ -605,6 +627,7 @@ class EntityCollection {
605
627
  this.rayHandler.clear();
606
628
  this.pointCloudHandler.clear();
607
629
  this.stripHandler.clear();
630
+ this.geoObjectHandler.clear();
608
631
 
609
632
  var i = this._entities.length;
610
633
  while (i--) {
@@ -622,7 +645,7 @@ class EntityCollection {
622
645
  /**
623
646
  * Clears entity recursevely.
624
647
  * @private
625
- * @param {og.Entity} entity - Entity to clear.
648
+ * @param {Entity} entity - Entity to clear.
626
649
  */
627
650
  _clearEntity(entity) {
628
651
  entity._entityCollection = null;
@@ -631,7 +654,7 @@ class EntityCollection {
631
654
  this._clearEntity(entity.childrenNodes[i]);
632
655
  }
633
656
  }
634
- };
657
+ }
635
658
 
636
659
  const EVENT_NAMES = [
637
660
  /**
@@ -833,4 +856,4 @@ const EVENT_NAMES = [
833
856
  "touchenter"
834
857
  ];
835
858
 
836
- export { EntityCollection };
859
+ export { EntityCollection };
@@ -0,0 +1,228 @@
1
+ /**
2
+ * @module og/shape/BaseShape
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { Quat, Vec3 } from "../math/index.js";
8
+ import { MAX32, RADIANS, lerp } from "../math.js";
9
+ import { LonLat } from "../LonLat.js";
10
+ import * as utils from "../utils/shared.js";
11
+ import { Planet } from "../scene/Planet.js";
12
+
13
+ /**
14
+ * @class
15
+ * @param {Object} options - Geo object parameters:
16
+ * @param {og.Vec3} [options.position] - Geo object position.
17
+ */
18
+
19
+ class GeoObject {
20
+ constructor(options) {
21
+ options = options || {};
22
+
23
+ this.scale = options.scale || 0.02;
24
+ this.scaleByDistance = new Float32Array(options.scaleByDistance || [MAX32, MAX32, MAX32]);
25
+
26
+ /**
27
+ * Geo object center cartesian position.
28
+ * @protected
29
+ * @type {og.Vec3}
30
+ */
31
+ this._position = utils.createVector3(options.position);
32
+
33
+ this._positionHigh = new Vec3();
34
+
35
+ this._positionLow = new Vec3();
36
+
37
+ Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
38
+
39
+ this._pitch = options.pitch || 0.0;
40
+ this._yaw = options.yaw || 0.0;
41
+ this._roll = options.roll || 0.0;
42
+
43
+ this._planet = options.planet || null;
44
+ this._lonLatAlt = new LonLat(0, 0, 100000);
45
+
46
+ /**
47
+ * RGBA color.
48
+ * @protected
49
+ * @type {og.Vec4}
50
+ */
51
+ this._color = utils.createColorRGBA(options.color);
52
+
53
+ this._direction = new Vec3(0, 0, 0);
54
+
55
+ this._handler = null;
56
+ this._handlerIndex = -1;
57
+ this._vertices = options.vertices;
58
+ this._normals = options.normals;
59
+ this._indices = options.indices;
60
+ this.instanced = options.instanced;
61
+ this.tag = options.tag || "none";
62
+ if (options.indices) {
63
+ this._indicesCount = options.indices.length;
64
+ }
65
+ if (options.vertices) {
66
+ this._verticesCount = Math.floor(options.vertices.length / 3);
67
+ }
68
+ }
69
+
70
+ get planet() {
71
+ return this._handler && this._handler._planet;
72
+ }
73
+
74
+ get renderer() {
75
+ return this.planet && this.planet.renderer;
76
+ }
77
+
78
+ /**
79
+ * Sets geo object opacity.
80
+ * @public
81
+ * @param {number} a - Billboard opacity.
82
+ */
83
+ setOpacity(a) {
84
+ this._color.w = a;
85
+ this.setColor(this._color.x, this._color.y, this._color.z, a);
86
+ }
87
+
88
+ /**
89
+ * Sets RGBA color. Each channel from 0.0 to 1.0.
90
+ * @public
91
+ * @param {number} r - Red.
92
+ * @param {number} g - Green.
93
+ * @param {number} b - Blue.
94
+ * @param {number} a - Alpha.
95
+ */
96
+ setColor(r, g, b, a) {
97
+ this._color.x = r;
98
+ this._color.y = g;
99
+ this._color.z = b;
100
+ a != undefined && (this._color.w = a);
101
+ this._handler && this._handler.setRgbaArr(this._handlerIndex, this._color);
102
+ }
103
+
104
+ /**
105
+ * Sets RGBA color. Each channel from 0.0 to 1.0.
106
+ * @public
107
+ * @param {og.Vec4} color - RGBA vector.
108
+ */
109
+ setColor4v(color) {
110
+ this._color.x = color.x;
111
+ this._color.y = color.y;
112
+ this._color.z = color.z;
113
+ color.w != undefined && (this._color.w = color.w);
114
+ this._handler && this._handler.setRgbaArr(this._handlerIndex, color);
115
+ }
116
+
117
+ /**
118
+ * Sets geo object visibility.
119
+ * @public
120
+ * @param {boolean} visibility - Visibility flag.
121
+ */
122
+ setVisibility(visibility) {
123
+ this._visibility = visibility;
124
+ this._handler && this._handler.setVisibility(this._handlerIndex, visibility);
125
+ }
126
+
127
+ /**
128
+ * Returns geo object visibility.
129
+ * @public
130
+ * @returns {boolean}
131
+ */
132
+ getVisibility() {
133
+ return this._visibility;
134
+ }
135
+
136
+ setLonLat(lon, lat, alt) {
137
+ this._lonLatAlt.lon = lon;
138
+ this._lonLatAlt.lat = lat;
139
+ this._lonLatAlt.height = alt;
140
+ this._handler._planet.ellipsoid.lonLatToCartesianRes(this._lonLatAlt, this._position);
141
+ this.setPosition3v(this._position);
142
+ }
143
+
144
+ /**
145
+ * Sets geoObject position.
146
+ * @public
147
+ * @param {number} x - X coordinate.
148
+ * @param {number} y - Y coordinate.
149
+ * @param {number} z - Z coordinate.
150
+ */
151
+ setPosition(x, y, z) {
152
+ this._position.x = x;
153
+ this._position.y = y;
154
+ this._position.z = z;
155
+ Vec3.doubleToTwoFloats(this._position, this._positionHigh, this._positionLow);
156
+ this._handler &&
157
+ this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
158
+ this.updateDirection();
159
+ }
160
+
161
+ /**
162
+ * Sets billboard position.
163
+ * @public
164
+ * @param {og.Vec3} position - Cartesian coordinates.
165
+ */
166
+ setPosition3v(position) {
167
+ this._position.x = position.x;
168
+ this._position.y = position.y;
169
+ this._position.z = position.z;
170
+ Vec3.doubleToTwoFloats(position, this._positionHigh, this._positionLow);
171
+ this._handler &&
172
+ this._handler.setPositionArr(this._handlerIndex, this._positionHigh, this._positionLow);
173
+ this.updateDirection();
174
+ }
175
+
176
+ setYaw(yaw) {
177
+ this._yaw = yaw;
178
+ this.updateDirection();
179
+ }
180
+
181
+ setPitch(pitch) {
182
+ this._pitch = pitch;
183
+ this._handler && this._handler.setPitchRollArr(this._handlerIndex, pitch, this._roll);
184
+ }
185
+
186
+ setRoll(roll) {
187
+ this._roll = roll;
188
+ this._handler && this._handler.setPitchRollArr(this._handlerIndex, this._pitch, roll);
189
+ }
190
+
191
+ setScale(scale) {
192
+ this.scale = scale;
193
+ this._handler && this._handler.setScaleArr(this._handlerIndex, scale);
194
+ }
195
+
196
+ /**
197
+ * Removes geo object from handler.
198
+ * @public
199
+ */
200
+ remove() {
201
+ this._entity = null;
202
+ this._handler && this._handler.remove(this);
203
+ }
204
+
205
+ /**
206
+ * Sets billboard picking color.
207
+ * @public
208
+ * @param {og.Vec3} color - Picking color.
209
+ */
210
+ setPickingColor3v(color) {
211
+ this._handler && this._handler.setPickingColorArr(this._handlerIndex, color);
212
+ }
213
+
214
+ updateDirection() {
215
+ if (this._entity && this._entity.renderNode && this._entity.renderNode.ellipsoid) {
216
+ this._entity.renderNode.ellipsoid.lonLatToCartesianRes(this._lonLatAlt, this._position);
217
+ }
218
+ this._qNorthFrame = Planet.getBearingNorthRotationQuat(this._position);
219
+
220
+ let qq = Quat.yRotation(this._yaw * RADIANS)
221
+ .mul(this._qNorthFrame)
222
+ .conjugate();
223
+ this._direction = qq.mulVec3(new Vec3(0.0, 0.0, -1.0)).normalize();
224
+ this._handler && this._handler.setDirectionArr(this._handlerIndex, this._direction);
225
+ }
226
+ }
227
+
228
+ export { GeoObject };