@openglobus/og 0.11.2 → 0.11.7

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 (273) hide show
  1. package/package.json +13 -13
  2. package/src/og/Clock.js +10 -10
  3. package/src/og/Events.js +8 -6
  4. package/src/og/Extent.js +82 -41
  5. package/src/og/Globe.js +25 -13
  6. package/src/og/ImageCanvas.js +22 -16
  7. package/src/og/LonLat.js +16 -13
  8. package/src/og/Popup.js +21 -14
  9. package/src/og/QueueArray.js +6 -2
  10. package/src/og/Rectangle.js +11 -6
  11. package/src/og/Stack.js +5 -2
  12. package/src/og/ajax.js +21 -33
  13. package/src/og/astro/astro.js +5 -5
  14. package/src/og/astro/earth.js +22 -16
  15. package/src/og/astro/jd.js +23 -18
  16. package/src/og/astro/orbit.js +13 -11
  17. package/src/og/astro/rotation.js +17 -8
  18. package/src/og/bv/Box.js +7 -3
  19. package/src/og/bv/Sphere.js +14 -11
  20. package/src/og/camera/Camera.js +51 -54
  21. package/src/og/camera/Frustum.js +29 -18
  22. package/src/og/camera/PlanetCamera.js +32 -23
  23. package/src/og/control/CompassButton.js +5 -1
  24. package/src/og/control/Control.js +12 -10
  25. package/src/og/control/DebugInfo.js +4 -1
  26. package/src/og/control/EarthCoordinates.js +54 -33
  27. package/src/og/control/KeyboardNavigation.js +10 -10
  28. package/src/og/control/LayerSwitcher.js +22 -21
  29. package/src/og/control/Lighting.js +34 -3
  30. package/src/og/control/MouseNavigation.js +1 -1
  31. package/src/og/control/ScaleControl.js +1 -1
  32. package/src/og/control/SegmentBoundVisualization.js +6 -7
  33. package/src/og/control/ShowFps.js +13 -8
  34. package/src/og/control/SimpleNavigation.js +6 -8
  35. package/src/og/control/Sun.js +25 -15
  36. package/src/og/control/ToggleWireframe.js +4 -4
  37. package/src/og/control/TouchNavigation.js +44 -33
  38. package/src/og/control/ZoomControl.js +41 -25
  39. package/src/og/ellipsoid/Ellipsoid.js +162 -66
  40. package/src/og/ellipsoid/wgs84.js +4 -4
  41. package/src/og/entity/BaseBillboard.js +100 -56
  42. package/src/og/entity/Billboard.js +14 -10
  43. package/src/og/entity/BillboardHandler.js +317 -60
  44. package/src/og/entity/Entity.js +100 -68
  45. package/src/og/entity/EntityCollection.js +70 -47
  46. package/src/og/entity/GeoObject.js +228 -0
  47. package/src/og/entity/GeoObjectHandler.js +910 -0
  48. package/src/og/entity/Geometry.js +27 -24
  49. package/src/og/entity/GeometryHandler.js +596 -124
  50. package/src/og/entity/Label.js +80 -49
  51. package/src/og/entity/LabelHandler.js +45 -244
  52. package/src/og/entity/LabelWorker.js +218 -0
  53. package/src/og/entity/Object3d.js +504 -0
  54. package/src/og/entity/PointCloud.js +80 -32
  55. package/src/og/entity/PointCloudHandler.js +8 -8
  56. package/src/og/entity/Polyline.js +16 -16
  57. package/src/og/entity/Ray.js +60 -27
  58. package/src/og/entity/Strip.js +77 -48
  59. package/src/og/entity/StripHandler.js +26 -26
  60. package/src/og/entity/index.js +8 -16
  61. package/src/og/layer/BaseGeoImage.js +54 -23
  62. package/src/og/layer/CanvasTiles.js +24 -24
  63. package/src/og/layer/GeoImage.js +9 -9
  64. package/src/og/layer/GeoVideo.js +3 -3
  65. package/src/og/layer/KML.js +63 -37
  66. package/src/og/layer/Layer.js +44 -21
  67. package/src/og/layer/Material.js +23 -20
  68. package/src/og/layer/Vector.js +114 -68
  69. package/src/og/layer/WMS.js +34 -17
  70. package/src/og/layer/XYZ.js +48 -46
  71. package/src/og/light/LightSource.js +46 -39
  72. package/src/og/math/Mat3.js +34 -22
  73. package/src/og/math/Mat4.js +603 -459
  74. package/src/og/math/Plane.js +21 -20
  75. package/src/og/math/Quat.js +182 -139
  76. package/src/og/math/Ray.js +38 -33
  77. package/src/og/math/Vec2.js +85 -75
  78. package/src/og/math/Vec3.js +142 -112
  79. package/src/og/math/Vec4.js +27 -31
  80. package/src/og/math/coder.js +10 -10
  81. package/src/og/math.js +12 -12
  82. package/src/og/proj/EPSG3857.js +4 -4
  83. package/src/og/proj/EPSG4326.js +4 -4
  84. package/src/og/proj/Proj.js +4 -6
  85. package/src/og/quadTree/Node.js +8 -8
  86. package/src/og/renderer/Renderer.js +59 -52
  87. package/src/og/renderer/RendererEvents.js +50 -27
  88. package/src/og/scene/BaseNode.js +7 -8
  89. package/src/og/scene/Planet.js +102 -103
  90. package/src/og/scene/RenderNode.js +28 -21
  91. package/src/og/segment/Segment.js +26 -21
  92. package/src/og/segment/SegmentLonLat.js +5 -5
  93. package/src/og/shaders/drawnode.js +135 -142
  94. package/src/og/shaders/geoObject.js +211 -0
  95. package/src/og/shaders/pointCloud.js +41 -41
  96. package/src/og/shaders/shape.js +12 -18
  97. package/src/og/shaders/skybox.js +36 -36
  98. package/src/og/shaders/toneMapping.js +1 -0
  99. package/src/og/shapes/BaseShape.js +126 -54
  100. package/src/og/shapes/Icosphere.js +29 -14
  101. package/src/og/shapes/Sphere.js +12 -15
  102. package/src/og/terrain/BilTerrain.js +1 -0
  103. package/src/og/terrain/EmptyTerrain.js +2 -2
  104. package/src/og/terrain/GlobusTerrain.js +9 -9
  105. package/src/og/utils/FontAtlas.js +6 -2
  106. package/src/og/utils/TextureAtlas.js +22 -24
  107. package/src/og/utils/VectorTileCreator.js +1 -3
  108. package/src/og/utils/shared.js +16 -16
  109. package/src/og/webgl/Framebuffer.js +88 -40
  110. package/src/og/webgl/Handler.js +243 -169
  111. package/src/og/webgl/Multisample.js +47 -19
  112. package/src/og/webgl/Program.js +79 -34
  113. package/src/og/webgl/ProgramController.js +17 -13
  114. package/src/og/webgl/callbacks.js +8 -8
  115. package/src/og/inherits.js +0 -8
  116. package/src/og/utils/polylabel.js +0 -176
  117. package/types/Clock.d.ts +0 -90
  118. package/types/Deferred.d.ts +0 -6
  119. package/types/Events.d.ts +0 -73
  120. package/types/Extent.d.ts +0 -166
  121. package/types/Globe.d.ts +0 -75
  122. package/types/ImageCanvas.d.ts +0 -121
  123. package/types/Lock.d.ts +0 -12
  124. package/types/LonLat.d.ts +0 -108
  125. package/types/Popup.d.ts +0 -38
  126. package/types/QueueArray.d.ts +0 -15
  127. package/types/Rectangle.d.ts +0 -74
  128. package/types/Stack.d.ts +0 -15
  129. package/types/ajax.d.ts +0 -24
  130. package/types/arial.d.ts +0 -48
  131. package/types/astro/astro.d.ts +0 -38
  132. package/types/astro/earth.d.ts +0 -6
  133. package/types/astro/jd.d.ts +0 -254
  134. package/types/bv/Box.d.ts +0 -25
  135. package/types/bv/Sphere.d.ts +0 -38
  136. package/types/bv/index.d.ts +0 -3
  137. package/types/camera/Camera.d.ts +0 -303
  138. package/types/camera/Frustum.d.ts +0 -129
  139. package/types/camera/PlanetCamera.d.ts +0 -223
  140. package/types/camera/index.d.ts +0 -3
  141. package/types/cons.d.ts +0 -40
  142. package/types/control/CompassButton.d.ts +0 -18
  143. package/types/control/Control.d.ts +0 -101
  144. package/types/control/DebugInfo.d.ts +0 -16
  145. package/types/control/EarthCoordinates.d.ts +0 -47
  146. package/types/control/EarthNavigation.d.ts +0 -42
  147. package/types/control/GeoImageDragControl.d.ts +0 -6
  148. package/types/control/KeyboardNavigation.d.ts +0 -22
  149. package/types/control/LayerSwitcher.d.ts +0 -23
  150. package/types/control/Lighting.d.ts +0 -16
  151. package/types/control/MouseNavigation.d.ts +0 -51
  152. package/types/control/ScaleControl.d.ts +0 -22
  153. package/types/control/ShowFps.d.ts +0 -12
  154. package/types/control/SimpleNavigation.d.ts +0 -28
  155. package/types/control/Sun.d.ts +0 -52
  156. package/types/control/ToggleWireframe.d.ts +0 -12
  157. package/types/control/TouchNavigation.d.ts +0 -50
  158. package/types/control/ZoomControl.d.ts +0 -28
  159. package/types/control/index.d.ts +0 -17
  160. package/types/ellipsoid/Ellipsoid.d.ts +0 -142
  161. package/types/ellipsoid/index.d.ts +0 -3
  162. package/types/ellipsoid/wgs84.d.ts +0 -5
  163. package/types/entity/BaseBillboard.d.ts +0 -208
  164. package/types/entity/Billboard.d.ts +0 -94
  165. package/types/entity/BillboardHandler.d.ts +0 -74
  166. package/types/entity/Entity.d.ts +0 -331
  167. package/types/entity/EntityCollection.d.ts +0 -303
  168. package/types/entity/Geometry.d.ts +0 -73
  169. package/types/entity/GeometryHandler.d.ts +0 -76
  170. package/types/entity/Label.d.ts +0 -194
  171. package/types/entity/LabelHandler.d.ts +0 -24
  172. package/types/entity/PointCloud.d.ts +0 -174
  173. package/types/entity/PointCloudHandler.d.ts +0 -38
  174. package/types/entity/Polyline.d.ts +0 -304
  175. package/types/entity/PolylineHandler.d.ts +0 -18
  176. package/types/entity/Ray.d.ts +0 -123
  177. package/types/entity/RayHandler.d.ts +0 -67
  178. package/types/entity/ShapeHandler.d.ts +0 -22
  179. package/types/entity/Strip.d.ts +0 -118
  180. package/types/entity/StripHandler.d.ts +0 -38
  181. package/types/entity/index.d.ts +0 -8
  182. package/types/index.core.d.ts +0 -65
  183. package/types/index.d.ts +0 -45
  184. package/types/index.webgl.d.ts +0 -7
  185. package/types/inherits.d.ts +0 -4
  186. package/types/input/KeyboardHandler.d.ts +0 -10
  187. package/types/input/MouseHandler.d.ts +0 -5
  188. package/types/input/TouchHandler.d.ts +0 -5
  189. package/types/input/input.d.ts +0 -34
  190. package/types/layer/BaseGeoImage.d.ts +0 -107
  191. package/types/layer/CanvasTiles.d.ts +0 -75
  192. package/types/layer/GeoImage.d.ts +0 -65
  193. package/types/layer/GeoTexture2d.d.ts +0 -8
  194. package/types/layer/GeoVideo.d.ts +0 -80
  195. package/types/layer/KML.d.ts +0 -58
  196. package/types/layer/Layer.d.ts +0 -321
  197. package/types/layer/Material.d.ts +0 -48
  198. package/types/layer/Vector.d.ts +0 -228
  199. package/types/layer/WMS.d.ts +0 -66
  200. package/types/layer/XYZ.d.ts +0 -130
  201. package/types/layer/index.d.ts +0 -10
  202. package/types/light/LightSource.d.ts +0 -177
  203. package/types/math/Line2.d.ts +0 -11
  204. package/types/math/Line3.d.ts +0 -10
  205. package/types/math/Mat3.d.ts +0 -63
  206. package/types/math/Mat4.d.ts +0 -173
  207. package/types/math/Plane.d.ts +0 -17
  208. package/types/math/Quat.d.ts +0 -376
  209. package/types/math/Ray.d.ts +0 -81
  210. package/types/math/Vec2.d.ts +0 -308
  211. package/types/math/Vec3.d.ts +0 -459
  212. package/types/math/Vec4.d.ts +0 -161
  213. package/types/math/coder.d.ts +0 -42
  214. package/types/math/index.d.ts +0 -11
  215. package/types/math.d.ts +0 -261
  216. package/types/mercator.d.ts +0 -92
  217. package/types/proj/EPSG3857.d.ts +0 -5
  218. package/types/proj/EPSG4326.d.ts +0 -5
  219. package/types/proj/Proj.d.ts +0 -42
  220. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  221. package/types/quadTree/Node.d.ts +0 -61
  222. package/types/quadTree/quadTree.d.ts +0 -40
  223. package/types/renderer/Renderer.d.ts +0 -296
  224. package/types/renderer/RendererEvents.d.ts +0 -230
  225. package/types/res/images.d.ts +0 -3
  226. package/types/scene/Axes.d.ts +0 -11
  227. package/types/scene/BaseNode.d.ts +0 -60
  228. package/types/scene/Planet.d.ts +0 -574
  229. package/types/scene/RenderNode.d.ts +0 -143
  230. package/types/scene/SkyBox.d.ts +0 -10
  231. package/types/scene/index.d.ts +0 -4
  232. package/types/segment/Segment.d.ts +0 -271
  233. package/types/segment/SegmentLonLat.d.ts +0 -62
  234. package/types/segment/segmentHelper.d.ts +0 -13
  235. package/types/shaders/billboard.d.ts +0 -3
  236. package/types/shaders/depth.d.ts +0 -2
  237. package/types/shaders/drawnode.d.ts +0 -7
  238. package/types/shaders/label.d.ts +0 -4
  239. package/types/shaders/pointCloud.d.ts +0 -2
  240. package/types/shaders/polyline.d.ts +0 -3
  241. package/types/shaders/ray.d.ts +0 -2
  242. package/types/shaders/screenFrame.d.ts +0 -2
  243. package/types/shaders/shape.d.ts +0 -4
  244. package/types/shaders/skybox.d.ts +0 -2
  245. package/types/shaders/toneMapping.d.ts +0 -2
  246. package/types/shapes/BaseShape.d.ts +0 -247
  247. package/types/shapes/Sphere.d.ts +0 -41
  248. package/types/terrain/BilTerrain.d.ts +0 -8
  249. package/types/terrain/EmptyTerrain.d.ts +0 -72
  250. package/types/terrain/Geoid.d.ts +0 -26
  251. package/types/terrain/GlobusTerrain.d.ts +0 -153
  252. package/types/terrain/MapboxTerrain.d.ts +0 -8
  253. package/types/terrain/index.d.ts +0 -5
  254. package/types/utils/FontAtlas.d.ts +0 -14
  255. package/types/utils/GeoImageCreator.d.ts +0 -30
  256. package/types/utils/ImagesCacheManager.d.ts +0 -10
  257. package/types/utils/Loader.d.ts +0 -25
  258. package/types/utils/NormalMapCreator.d.ts +0 -39
  259. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  260. package/types/utils/TerrainWorker.d.ts +0 -9
  261. package/types/utils/TextureAtlas.d.ts +0 -111
  262. package/types/utils/VectorTileCreator.d.ts +0 -16
  263. package/types/utils/colorTable.d.ts +0 -143
  264. package/types/utils/earcut.d.ts +0 -6
  265. package/types/utils/shared.d.ts +0 -230
  266. package/types/webgl/Framebuffer.d.ts +0 -135
  267. package/types/webgl/Handler.d.ts +0 -372
  268. package/types/webgl/Multisample.d.ts +0 -89
  269. package/types/webgl/Program.d.ts +0 -155
  270. package/types/webgl/ProgramController.d.ts +0 -84
  271. package/types/webgl/callbacks.d.ts +0 -1
  272. package/types/webgl/index.d.ts +0 -6
  273. package/types/webgl/types.d.ts +0 -2
@@ -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
 
@@ -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;
@@ -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 };