@openglobus/og 0.11.5 → 0.12.0

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 (267) hide show
  1. package/css/og.css +5 -2
  2. package/package.json +12 -14
  3. package/src/og/Clock.js +6 -10
  4. package/src/og/Events.js +5 -7
  5. package/src/og/Extent.js +73 -32
  6. package/src/og/Globe.js +25 -10
  7. package/src/og/ImageCanvas.js +18 -15
  8. package/src/og/LonLat.js +13 -10
  9. package/src/og/Popup.js +19 -17
  10. package/src/og/QueueArray.js +3 -4
  11. package/src/og/Rectangle.js +4 -6
  12. package/src/og/Stack.js +2 -4
  13. package/src/og/ajax.js +20 -14
  14. package/src/og/astro/earth.js +21 -15
  15. package/src/og/bv/Box.js +2 -3
  16. package/src/og/bv/Sphere.js +10 -7
  17. package/src/og/camera/Camera.js +70 -79
  18. package/src/og/camera/Frustum.js +19 -12
  19. package/src/og/camera/PlanetCamera.js +33 -34
  20. package/src/og/control/CompassButton.js +1 -2
  21. package/src/og/control/Control.js +7 -9
  22. package/src/og/control/DebugInfo.js +2 -3
  23. package/src/og/control/EarthNavigation.js +26 -17
  24. package/src/og/control/KeyboardNavigation.js +9 -9
  25. package/src/og/control/LayerSwitcher.js +21 -20
  26. package/src/og/control/Lighting.js +74 -64
  27. package/src/og/control/MouseNavigation.js +30 -29
  28. package/src/og/control/MouseWheelZoomControl.js +257 -0
  29. package/src/og/control/SegmentBoundVisualization.js +5 -6
  30. package/src/og/control/ShowFps.js +12 -7
  31. package/src/og/control/SimpleNavigation.js +5 -7
  32. package/src/og/control/Sun.js +24 -14
  33. package/src/og/control/ToggleWireframe.js +3 -3
  34. package/src/og/control/TouchNavigation.js +43 -32
  35. package/src/og/control/ZoomControl.js +40 -24
  36. package/src/og/control/index.js +2 -0
  37. package/src/og/control/visibleExtent/Segment.js +1862 -0
  38. package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
  39. package/src/og/control/visibleExtent/drawnode.js +751 -0
  40. package/src/og/ellipsoid/Ellipsoid.js +149 -57
  41. package/src/og/ellipsoid/wgs84.js +3 -3
  42. package/src/og/entity/BaseBillboard.js +72 -30
  43. package/src/og/entity/Billboard.js +9 -5
  44. package/src/og/entity/BillboardHandler.js +315 -62
  45. package/src/og/entity/Entity.js +742 -704
  46. package/src/og/entity/EntityCollection.js +47 -24
  47. package/src/og/entity/GeoObject.js +228 -0
  48. package/src/og/entity/GeoObjectHandler.js +895 -0
  49. package/src/og/entity/GeometryHandler.js +595 -123
  50. package/src/og/entity/Label.js +62 -30
  51. package/src/og/entity/LabelHandler.js +42 -243
  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 +76 -28
  55. package/src/og/entity/PointCloudHandler.js +5 -5
  56. package/src/og/entity/Ray.js +49 -16
  57. package/src/og/entity/Strip.js +72 -43
  58. package/src/og/entity/StripHandler.js +23 -23
  59. package/src/og/layer/BaseGeoImage.js +50 -19
  60. package/src/og/layer/CanvasTiles.js +16 -17
  61. package/src/og/layer/GeoImage.js +8 -16
  62. package/src/og/layer/GeoTexture2d.js +2 -10
  63. package/src/og/layer/GeoVideo.js +2 -10
  64. package/src/og/layer/KML.js +55 -33
  65. package/src/og/layer/Layer.js +24 -33
  66. package/src/og/layer/Material.js +1 -1
  67. package/src/og/layer/Vector.js +94 -48
  68. package/src/og/layer/WMS.js +33 -18
  69. package/src/og/layer/XYZ.js +24 -26
  70. package/src/og/light/LightSource.js +19 -12
  71. package/src/og/math/Mat3.js +24 -12
  72. package/src/og/math/Mat4.js +603 -603
  73. package/src/og/math/Plane.js +19 -18
  74. package/src/og/math/Ray.js +17 -12
  75. package/src/og/math/Vec2.js +24 -14
  76. package/src/og/math/Vec3.js +78 -32
  77. package/src/og/math/coder.js +7 -7
  78. package/src/og/proj/EPSG3857.js +3 -3
  79. package/src/og/proj/EPSG4326.js +3 -3
  80. package/src/og/proj/Proj.js +2 -4
  81. package/src/og/quadTree/Node.js +50 -95
  82. package/src/og/quadTree/quadTree.js +1 -1
  83. package/src/og/renderer/Renderer.js +106 -126
  84. package/src/og/renderer/RendererEvents.js +45 -23
  85. package/src/og/scene/BaseNode.js +2 -3
  86. package/src/og/scene/Planet.js +139 -191
  87. package/src/og/scene/RenderNode.js +15 -8
  88. package/src/og/segment/Segment.js +93 -268
  89. package/src/og/segment/Slice.js +45 -0
  90. package/src/og/shaders/drawnode.js +174 -360
  91. package/src/og/shaders/geoObject.js +211 -0
  92. package/src/og/shaders/pointCloud.js +41 -41
  93. package/src/og/shaders/shape.js +12 -18
  94. package/src/og/shaders/skybox.js +36 -36
  95. package/src/og/shaders/toneMapping.js +1 -0
  96. package/src/og/shapes/BaseShape.js +108 -36
  97. package/src/og/shapes/Icosphere.js +25 -10
  98. package/src/og/shapes/Sphere.js +8 -11
  99. package/src/og/terrain/EmptyTerrain.js +3 -2
  100. package/src/og/terrain/GlobusTerrain.js +2 -0
  101. package/src/og/utils/FontAtlas.js +6 -2
  102. package/src/og/utils/GeoImageCreator.js +5 -1
  103. package/src/og/utils/Loader.js +1 -1
  104. package/src/og/utils/PlainSegmentWorker.js +0 -13
  105. package/src/og/utils/TextureAtlas.js +18 -20
  106. package/src/og/utils/VectorTileCreator.js +1 -3
  107. package/src/og/utils/shared.js +2 -2
  108. package/src/og/webgl/Handler.js +219 -162
  109. package/src/og/webgl/Multisample.js +44 -16
  110. package/src/og/webgl/Program.js +78 -33
  111. package/src/og/webgl/callbacks.js +3 -3
  112. package/types/Clock.d.ts +0 -94
  113. package/types/Deferred.d.ts +0 -6
  114. package/types/Events.d.ts +0 -77
  115. package/types/Extent.d.ts +0 -166
  116. package/types/Globe.d.ts +0 -82
  117. package/types/ImageCanvas.d.ts +0 -123
  118. package/types/Lock.d.ts +0 -12
  119. package/types/LonLat.d.ts +0 -108
  120. package/types/Popup.d.ts +0 -42
  121. package/types/QueueArray.d.ts +0 -19
  122. package/types/Rectangle.d.ts +0 -80
  123. package/types/Stack.d.ts +0 -19
  124. package/types/ajax.d.ts +0 -24
  125. package/types/arial.d.ts +0 -48
  126. package/types/astro/astro.d.ts +0 -38
  127. package/types/astro/earth.d.ts +0 -7
  128. package/types/astro/jd.d.ts +0 -254
  129. package/types/bv/Box.d.ts +0 -30
  130. package/types/bv/Sphere.d.ts +0 -38
  131. package/types/bv/index.d.ts +0 -3
  132. package/types/camera/Camera.d.ts +0 -312
  133. package/types/camera/Frustum.d.ts +0 -133
  134. package/types/camera/PlanetCamera.d.ts +0 -218
  135. package/types/camera/index.d.ts +0 -3
  136. package/types/cons.d.ts +0 -40
  137. package/types/control/CompassButton.d.ts +0 -17
  138. package/types/control/Control.d.ts +0 -104
  139. package/types/control/DebugInfo.d.ts +0 -15
  140. package/types/control/EarthCoordinates.d.ts +0 -47
  141. package/types/control/EarthNavigation.d.ts +0 -42
  142. package/types/control/GeoImageDragControl.d.ts +0 -6
  143. package/types/control/KeyboardNavigation.d.ts +0 -21
  144. package/types/control/LayerSwitcher.d.ts +0 -21
  145. package/types/control/Lighting.d.ts +0 -16
  146. package/types/control/MouseNavigation.d.ts +0 -47
  147. package/types/control/ScaleControl.d.ts +0 -22
  148. package/types/control/ShowFps.d.ts +0 -11
  149. package/types/control/SimpleNavigation.d.ts +0 -25
  150. package/types/control/Sun.d.ts +0 -50
  151. package/types/control/ToggleWireframe.d.ts +0 -12
  152. package/types/control/TouchNavigation.d.ts +0 -48
  153. package/types/control/ZoomControl.d.ts +0 -27
  154. package/types/control/index.d.ts +0 -17
  155. package/types/ellipsoid/Ellipsoid.d.ts +0 -146
  156. package/types/ellipsoid/index.d.ts +0 -3
  157. package/types/ellipsoid/wgs84.d.ts +0 -6
  158. package/types/entity/BaseBillboard.d.ts +0 -208
  159. package/types/entity/Billboard.d.ts +0 -94
  160. package/types/entity/BillboardHandler.d.ts +0 -78
  161. package/types/entity/Entity.d.ts +0 -333
  162. package/types/entity/EntityCollection.d.ts +0 -311
  163. package/types/entity/Geometry.d.ts +0 -74
  164. package/types/entity/GeometryHandler.d.ts +0 -76
  165. package/types/entity/Label.d.ts +0 -189
  166. package/types/entity/LabelHandler.d.ts +0 -29
  167. package/types/entity/PointCloud.d.ts +0 -174
  168. package/types/entity/PointCloudHandler.d.ts +0 -38
  169. package/types/entity/Polyline.d.ts +0 -306
  170. package/types/entity/PolylineHandler.d.ts +0 -18
  171. package/types/entity/Ray.d.ts +0 -124
  172. package/types/entity/RayHandler.d.ts +0 -67
  173. package/types/entity/ShapeHandler.d.ts +0 -22
  174. package/types/entity/Strip.d.ts +0 -119
  175. package/types/entity/StripHandler.d.ts +0 -38
  176. package/types/entity/index.d.ts +0 -8
  177. package/types/index.core.d.ts +0 -65
  178. package/types/index.d.ts +0 -45
  179. package/types/index.webgl.d.ts +0 -7
  180. package/types/input/KeyboardHandler.d.ts +0 -10
  181. package/types/input/MouseHandler.d.ts +0 -5
  182. package/types/input/TouchHandler.d.ts +0 -5
  183. package/types/input/input.d.ts +0 -34
  184. package/types/layer/BaseGeoImage.d.ts +0 -94
  185. package/types/layer/CanvasTiles.d.ts +0 -68
  186. package/types/layer/GeoImage.d.ts +0 -52
  187. package/types/layer/GeoTexture2d.d.ts +0 -8
  188. package/types/layer/GeoVideo.d.ts +0 -55
  189. package/types/layer/KML.d.ts +0 -63
  190. package/types/layer/Layer.d.ts +0 -326
  191. package/types/layer/Material.d.ts +0 -45
  192. package/types/layer/Vector.d.ts +0 -208
  193. package/types/layer/WMS.d.ts +0 -63
  194. package/types/layer/XYZ.d.ts +0 -120
  195. package/types/layer/index.d.ts +0 -10
  196. package/types/light/LightSource.d.ts +0 -178
  197. package/types/math/Line2.d.ts +0 -11
  198. package/types/math/Line3.d.ts +0 -10
  199. package/types/math/Mat3.d.ts +0 -65
  200. package/types/math/Mat4.d.ts +0 -176
  201. package/types/math/Plane.d.ts +0 -18
  202. package/types/math/Quat.d.ts +0 -379
  203. package/types/math/Ray.d.ts +0 -82
  204. package/types/math/Vec2.d.ts +0 -309
  205. package/types/math/Vec3.d.ts +0 -460
  206. package/types/math/Vec4.d.ts +0 -162
  207. package/types/math/coder.d.ts +0 -43
  208. package/types/math/index.d.ts +0 -11
  209. package/types/math.d.ts +0 -261
  210. package/types/mercator.d.ts +0 -92
  211. package/types/proj/EPSG3857.d.ts +0 -6
  212. package/types/proj/EPSG4326.d.ts +0 -6
  213. package/types/proj/Proj.d.ts +0 -42
  214. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  215. package/types/quadTree/Node.d.ts +0 -61
  216. package/types/quadTree/quadTree.d.ts +0 -40
  217. package/types/renderer/Renderer.d.ts +0 -298
  218. package/types/renderer/RendererEvents.d.ts +0 -233
  219. package/types/res/images.d.ts +0 -3
  220. package/types/scene/Axes.d.ts +0 -11
  221. package/types/scene/BaseNode.d.ts +0 -60
  222. package/types/scene/Planet.d.ts +0 -577
  223. package/types/scene/RenderNode.d.ts +0 -142
  224. package/types/scene/SkyBox.d.ts +0 -10
  225. package/types/scene/index.d.ts +0 -4
  226. package/types/segment/Segment.d.ts +0 -279
  227. package/types/segment/SegmentLonLat.d.ts +0 -16
  228. package/types/segment/segmentHelper.d.ts +0 -13
  229. package/types/shaders/billboard.d.ts +0 -3
  230. package/types/shaders/depth.d.ts +0 -2
  231. package/types/shaders/drawnode.d.ts +0 -7
  232. package/types/shaders/label.d.ts +0 -4
  233. package/types/shaders/pointCloud.d.ts +0 -2
  234. package/types/shaders/polyline.d.ts +0 -3
  235. package/types/shaders/ray.d.ts +0 -2
  236. package/types/shaders/screenFrame.d.ts +0 -2
  237. package/types/shaders/shape.d.ts +0 -4
  238. package/types/shaders/skybox.d.ts +0 -2
  239. package/types/shaders/toneMapping.d.ts +0 -2
  240. package/types/shapes/BaseShape.d.ts +0 -250
  241. package/types/shapes/Sphere.d.ts +0 -41
  242. package/types/terrain/BilTerrain.d.ts +0 -7
  243. package/types/terrain/EmptyTerrain.d.ts +0 -72
  244. package/types/terrain/Geoid.d.ts +0 -26
  245. package/types/terrain/GlobusTerrain.d.ts +0 -116
  246. package/types/terrain/MapboxTerrain.d.ts +0 -7
  247. package/types/terrain/index.d.ts +0 -5
  248. package/types/utils/FontAtlas.d.ts +0 -14
  249. package/types/utils/GeoImageCreator.d.ts +0 -30
  250. package/types/utils/ImagesCacheManager.d.ts +0 -10
  251. package/types/utils/Loader.d.ts +0 -25
  252. package/types/utils/NormalMapCreator.d.ts +0 -39
  253. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  254. package/types/utils/TerrainWorker.d.ts +0 -9
  255. package/types/utils/TextureAtlas.d.ts +0 -111
  256. package/types/utils/VectorTileCreator.d.ts +0 -16
  257. package/types/utils/colorTable.d.ts +0 -143
  258. package/types/utils/earcut.d.ts +0 -6
  259. package/types/utils/shared.d.ts +0 -231
  260. package/types/webgl/Framebuffer.d.ts +0 -135
  261. package/types/webgl/Handler.d.ts +0 -388
  262. package/types/webgl/Multisample.d.ts +0 -89
  263. package/types/webgl/Program.d.ts +0 -155
  264. package/types/webgl/ProgramController.d.ts +0 -89
  265. package/types/webgl/callbacks.d.ts +0 -1
  266. package/types/webgl/index.d.ts +0 -6
  267. package/types/webgl/types.d.ts +0 -2
@@ -1,704 +1,742 @@
1
- /**
2
- * @module og/entity/Entity
3
- */
4
-
5
- "use strict";
6
-
7
- import * as mercator from "../mercator.js";
8
- import * as utils from "../utils/shared.js";
9
- import { Billboard } from "./Billboard.js";
10
- import { Strip } from "./Strip.js";
11
- import { Extent } from "../Extent.js";
12
- import { Geometry } from "./Geometry.js";
13
- import { Label } from "./Label.js";
14
- import { LonLat } from "../LonLat.js";
15
- import { Polyline } from "./Polyline.js";
16
- import { Ray } from "./Ray.js";
17
- import { PointCloud } from "./PointCloud.js";
18
- import { Sphere } from "../shapes/Sphere.js";
19
- import { Vec3 } from "../math/Vec3.js";
20
-
21
- /**
22
- * Entity instances aggregate multiple forms of visualization into a single high-level object.
23
- * They can be created manually and added to entity collection.
24
- *
25
- * @class
26
- * @param {Object} [options] - Entity options:
27
- * @param {string} [options.name] - A human readable name to display to users. It does not have to be unique.
28
- * @param {Vec3|Array.<number>} [options.cartesian] - Spatial entities like billboard, label, sphere etc. cartesian position.
29
- * @param {LonLat} [options.lonlat] - Geodetic coordiantes for an entities like billboard, label, sphere etc.
30
- * @param {boolean} [options.aground] - True for entities that have to be placed on the relief.
31
- * @param {boolean} [options.visibility] - Entity visibility.
32
- * @param {*} [options.billboard] - Billboard options(see {@link og.Billboard}).
33
- * @param {*} [options.label] - Label options(see {@link og.Label}).
34
- * @param {*} [options.sphere] - Sphere options(see {@link og.shape.Sphere}).
35
- * @param {*} [options.box] - Sphere options(see {@link og.shape.Box}).
36
- * @param {*} [options.polyline] - Polyline options(see {@link og.Polyline}).
37
- * @param {*} [options.ray] - Ray options(see {@link og.Ray}).
38
- * @param {*} [options.pointCloud] - Point cloud options(see {@link og.PointCloud}).
39
- * @param {*} [options.geometry] - Geometry options (see {@link og.Geometry}), available for vector layer only.
40
- * @param {*} [options.properties] - Entity custom properties.
41
- */
42
- class Entity {
43
- constructor(options) {
44
- options = options || {};
45
-
46
- options.properties = options.properties || {};
47
-
48
- /**
49
- * Unic identifier.
50
- * @public
51
- * @readonly
52
- */
53
- this.id = Entity._staticCounter++;
54
-
55
- /**
56
- * Entity user defined properties.
57
- * @public
58
- * @type {Object}
59
- */
60
- this.properties = options.properties || {};
61
-
62
- /**
63
- * Entity name.
64
- * @public
65
- * @type {string}
66
- */
67
- this.properties.name = this.properties.name || options.name || "";
68
-
69
- /**
70
- * Children entities.
71
- * @public
72
- * @type {Array.<Entity>}
73
- */
74
- this.childrenNodes = [];
75
-
76
- /**
77
- * Parent entity.
78
- * @public
79
- * @type {Entity}
80
- */
81
- this.parent = null;
82
-
83
- /**
84
- * Entity cartesian position.
85
- * @protected
86
- * @type {Vec3}
87
- */
88
- this._cartesian = utils.createVector3(options.cartesian);
89
-
90
- /**
91
- * Geodetic entity coordiantes.
92
- * @protected
93
- * @type {LonLat}
94
- */
95
- this._lonlat = utils.createLonLat(options.lonlat);
96
-
97
- /**
98
- * World Mercator entity coordinates.
99
- * @protected
100
- * @type {LonLat}
101
- */
102
- this._lonlatMerc = null;
103
-
104
- /**
105
- * Entity visible terrain altitude.
106
- * @protected
107
- * @type {number}
108
- */
109
- this._altitude = options.altitude || 0.0;
110
-
111
- /**
112
- * Visibility flag.
113
- * @protected
114
- * @type {boolean}
115
- */
116
- this._visibility = options.visibility != undefined ? options.visibility : true;
117
-
118
- /**
119
- * Entity collection that this entity belongs to.
120
- * @protected
121
- * @type {EntityCollection}
122
- */
123
- this._entityCollection = null;
124
-
125
- /**
126
- * Entity collection array store index.
127
- * @protected
128
- * @type {number}
129
- */
130
- this._entityCollectionIndex = -1;
131
-
132
- /**
133
- * Assigned vector layer pointer.
134
- * @protected
135
- * @type {layer.Vector}
136
- */
137
- this._layer = null;
138
-
139
- /**
140
- * Assigned vector layer entity array index.
141
- * @protected
142
- * @type {number}
143
- */
144
- this._layerIndex = -1;
145
-
146
- /**
147
- * Picking color.
148
- * @protected
149
- * @type {Vec3}
150
- */
151
- this._pickingColor = new Vec3(0, 0, 0);
152
-
153
- this._featureConstructorArray = {
154
- billboard: [Billboard, this.setBillboard],
155
- label: [Label, this.setLabel],
156
- sphere: [Sphere, this.setShape],
157
- // box: [Box, this.setShape],
158
- polyline: [Polyline, this.setPolyline],
159
- pointCloud: [PointCloud, this.setPointCloud],
160
- geometry: [Geometry, this.setGeometry],
161
- strip: [Strip, this.setStrip],
162
- ray: [Ray, this.setRay]
163
- };
164
-
165
- /**
166
- * Billboard entity.
167
- * @public
168
- * @type {Billboard}
169
- */
170
- this.billboard = this._createOptionFeature("billboard", options.billboard);
171
-
172
- /**
173
- * Text label entity.
174
- * @public
175
- * @type {Label}
176
- */
177
- this.label = this._createOptionFeature("label", options.label);
178
-
179
- /**
180
- * Shape entity.
181
- * @public
182
- * @type {shape.BaseShape}
183
- */
184
- this.shape = this._createOptionFeature("sphere", options.sphere || options.box);
185
-
186
- /**
187
- * Polyline entity.
188
- * @public
189
- * @type {Polyline}
190
- */
191
- this.polyline = this._createOptionFeature("polyline", options.polyline);
192
-
193
- /**
194
- * Ray entity.
195
- * @public
196
- * @type {ray}
197
- */
198
- this.ray = this._createOptionFeature("ray", options.ray);
199
-
200
- /**
201
- * PointCloud entity.
202
- * @public
203
- * @type {PointCloud}
204
- */
205
- this.pointCloud = this._createOptionFeature("pointCloud", options.pointCloud);
206
-
207
- /**
208
- * Geometry entity(available for vector layer only).
209
- * @public
210
- * @type {Geometry}
211
- */
212
- this.geometry = this._createOptionFeature("geometry", options.geometry);
213
-
214
- /**
215
- * Strip entity.
216
- * @public
217
- * @type {Strip}
218
- */
219
- this.strip = this._createOptionFeature("strip", options.strip);
220
- }
221
-
222
- static get _staticCounter() {
223
- if (!this._counter && this._counter !== 0) {
224
- this._counter = 0;
225
- }
226
- return this._counter;
227
- }
228
-
229
- static set _staticCounter(n) {
230
- this._counter = n;
231
- }
232
-
233
- get instanceName() {
234
- return "Entity";
235
- }
236
-
237
- _createOptionFeature(featureName, options) {
238
- if (options) {
239
- var c = this._featureConstructorArray[featureName];
240
- return c[1].call(this, new c[0](options));
241
- }
242
- return null;
243
- }
244
-
245
- getCollectionIndex() {
246
- return this._entityCollectionIndex;
247
- }
248
-
249
- /**
250
- * Adds current entity into the specified entity collection.
251
- * @public
252
- * @param {EntityCollection|og.layer.Vector} collection - Specified entity collection or vector layer.
253
- * @param {Boolean} [rightNow=false] - Entity insertion option for vector layer.
254
- * @returns {Entity} - This object.
255
- */
256
- addTo(collection, rightNow) {
257
- collection.add(this, rightNow);
258
- return this;
259
- }
260
-
261
- /**
262
- * Removes current entity from collection and layer.
263
- * @public
264
- */
265
- remove() {
266
- this._layer && this._layer.removeEntity(this);
267
- this._entityCollection && this._entityCollection.removeEntity(this);
268
- }
269
-
270
- /**
271
- * Sets the entity visibility.
272
- * @public
273
- * @param {boolean} visibility - Entity visibility.
274
- */
275
- setVisibility(visibility) {
276
- this._visibility = visibility;
277
-
278
- // billboards
279
- this.billboard && this.billboard.setVisibility(visibility);
280
-
281
- // labels
282
- this.label && this.label.setVisibility(visibility);
283
-
284
- // shape
285
- this.shape && this.shape.setVisibility(visibility);
286
-
287
- // polyline
288
- this.polyline && this.polyline.setVisibility(visibility);
289
-
290
- // ray
291
- this.ray && this.ray.setVisibility(visibility);
292
-
293
- // geometry
294
- this.geometry && this.geometry.setVisibility(visibility);
295
-
296
- for (var i = 0; i < this.childrenNodes.length; i++) {
297
- this.childrenNodes[i].setVisibility(visibility);
298
- }
299
- }
300
-
301
- /**
302
- * Returns entity visibility.
303
- * @public
304
- * @returns {boolean} -
305
- */
306
- getVisibility() {
307
- return this._visibility;
308
- }
309
-
310
- /**
311
- * Sets entity cartesian position.
312
- * @public
313
- * @param {Vec3} cartesian - Cartesian position in 3d space.
314
- */
315
- setCartesian3v(cartesian) {
316
- this.setCartesian(cartesian.x, cartesian.y, cartesian.z);
317
- }
318
-
319
- /**
320
- * Sets entity cartesian position.
321
- * @public
322
- * @param {number} x - 3d space X - position.
323
- * @param {number} y - 3d space Y - position.
324
- * @param {number} z - 3d space Z - position.
325
- */
326
- setCartesian(x, y, z) {
327
- var p = this._cartesian;
328
-
329
- p.x = x;
330
- p.y = y;
331
- p.z = z;
332
-
333
- // billboards
334
- this.billboard && this.billboard.setPosition3v(p);
335
-
336
- // labels
337
- this.label && this.label.setPosition3v(p);
338
-
339
- // shape
340
- this.shape && this.shape.setPosition3v(p);
341
-
342
- for (var i = 0; i < this.childrenNodes.length; i++) {
343
- this.childrenNodes[i].setCartesian(x, y, z);
344
- }
345
-
346
- var ec = this._entityCollection;
347
-
348
- if (ec && ec.renderNode && ec.renderNode.ellipsoid) {
349
- this._lonlat = ec.renderNode.ellipsoid.cartesianToLonLat(p);
350
-
351
- if (Math.abs(this._lonlat.lat) < mercator.MAX_LAT) {
352
- this._lonlatMerc = this._lonlat.forwardMercator();
353
- } else {
354
- this._lonlatMerc = null;
355
- }
356
- }
357
-
358
- ec && ec.events.dispatch(ec.events.entitymove, this);
359
- }
360
-
361
- /**
362
- * Sets entity cartesian position without event dispatching.
363
- * @protected
364
- * @param {Vec3} cartesian - Cartesian position in 3d space.
365
- * @param {boolean} skipLonLat - skip geodetic calculation.
366
- */
367
- _setCartesian3vSilent(cartesian, skipLonLat) {
368
- var p = this._cartesian;
369
-
370
- p.x = cartesian.x;
371
- p.y = cartesian.y;
372
- p.z = cartesian.z;
373
-
374
- // billboards
375
- this.billboard && this.billboard.setPosition3v(p);
376
-
377
- // labels
378
- this.label && this.label.setPosition3v(p);
379
-
380
- // shape
381
- this.shape && this.shape.setPosition3v(p);
382
-
383
- for (var i = 0; i < this.childrenNodes.length; i++) {
384
- this.childrenNodes[i].setCartesian(p.x, p.y, p.z);
385
- }
386
-
387
- var ec = this._entityCollection;
388
-
389
- if (!skipLonLat && ec && ec.renderNode && ec.renderNode.ellipsoid) {
390
- this._lonlat = ec.renderNode.ellipsoid.cartesianToLonLat(p);
391
-
392
- if (Math.abs(this._lonlat.lat) < mercator.MAX_LAT) {
393
- this._lonlatMerc = this._lonlat.forwardMercator();
394
- } else {
395
- this._lonlatMerc = null;
396
- }
397
- }
398
- }
399
-
400
- /**
401
- * Gets entity geodetic coordinates.
402
- * @public
403
- * @returns {LonLat} -
404
- */
405
- getLonLat() {
406
- return this._lonlat.clone();
407
- }
408
-
409
- /**
410
- * Sets geodetic coordinates of the entity point object.
411
- * @public
412
- * @param {LonLat} lonlat - WGS84 coordinates.
413
- */
414
- setLonLat(lonlat) {
415
- var l = this._lonlat;
416
-
417
- l.lon = lonlat.lon;
418
- l.lat = lonlat.lat;
419
- l.height = lonlat.height;
420
-
421
- var ec = this._entityCollection;
422
- if (ec && ec.renderNode && ec.renderNode.ellipsoid) {
423
- if (Math.abs(lonlat.lat) < mercator.MAX_LAT) {
424
- this._lonlatMerc = lonlat.forwardMercator();
425
- } else {
426
- this._lonlatMerc = null;
427
- }
428
-
429
- ec.renderNode.ellipsoid.lonLatToCartesianRes(lonlat, this._cartesian);
430
- this.setCartesian3v(this._cartesian);
431
- }
432
- }
433
-
434
- /**
435
- * Sets entity altitude over the planet.
436
- * @public
437
- * @param {number} altitude - Altitude.
438
- */
439
- setAltitude(altitude) {
440
- this._altitude = altitude;
441
- }
442
-
443
- /**
444
- * Sets entity altitude over the planet.
445
- * @public
446
- * @return {number} Altitude.
447
- */
448
- getAltitude() {
449
- return this._altitude;
450
- }
451
-
452
- /**
453
- * Returns carteain position.
454
- * @public
455
- * @returns {Vec3} -
456
- */
457
- getCartesian() {
458
- return this._cartesian.clone();
459
- }
460
-
461
- /**
462
- * Sets entity billboard.
463
- * @public
464
- * @param {Billboard} billboard - Billboard object.
465
- * @returns {Billboard} -
466
- */
467
- setBillboard(billboard) {
468
- if (this.billboard) {
469
- this.billboard.remove();
470
- }
471
- this.billboard = billboard;
472
- this.billboard._entity = this;
473
- this.billboard.setPosition3v(this._cartesian);
474
- this.billboard.setVisibility(this._visibility);
475
- this._entityCollection && this._entityCollection._billboardHandler.add(billboard);
476
- return billboard;
477
- }
478
-
479
- /**
480
- * Sets entity label.
481
- * @public
482
- * @param {Label} label - Text label.
483
- * @returns {Label} -
484
- */
485
- setLabel(label) {
486
- if (this.label) {
487
- this.label.remove();
488
- }
489
- this.label = label;
490
- this.label._entity = this;
491
- this.label.setPosition3v(this._cartesian);
492
- this.label.setVisibility(this._visibility);
493
- this._entityCollection && this._entityCollection._labelHandler.add(label);
494
- return label;
495
- }
496
-
497
- /**
498
- * Sets entity ray.
499
- * @public
500
- * @param {Ray} ray - Ray object.
501
- * @returns {Ray} -
502
- */
503
- setRay(ray) {
504
- if (this.ray) {
505
- this.ray.remove();
506
- }
507
- this.ray = ray;
508
- this.ray._entity = this;
509
- this.ray.setVisibility(this._visibility);
510
- this._entityCollection && this._entityCollection._rayHandler.add(ray);
511
- return ray;
512
- }
513
-
514
- /**
515
- * Sets entity shape.
516
- * @public
517
- * @param {BaseShape} shape - Shape object.
518
- * @returns {Polyline} -
519
- */
520
- setShape(shape) {
521
- if (this.shape) {
522
- this.shape.remove();
523
- }
524
- this.shape = shape;
525
- this.shape._entity = this;
526
- this.shape.setPosition3v(this._cartesian);
527
- this.shape.setVisibility(this._visibility);
528
- this._entityCollection && this._entityCollection._shapeHandler.add(shape);
529
- return shape;
530
- }
531
-
532
- /**
533
- * Sets entity polyline.
534
- * @public
535
- * @param {Polyline} polyline - Polyline object.
536
- * @returns {Polyline} -
537
- */
538
- setPolyline(polyline) {
539
- if (this.polyline) {
540
- this.polyline.remove();
541
- }
542
- this.polyline = polyline;
543
- this.polyline._entity = this;
544
- this.polyline.setVisibility(this._visibility);
545
- this._entityCollection && this._entityCollection._polylineHandler.add(polyline);
546
- return polyline;
547
- }
548
-
549
- /**
550
- * Sets entity pointCloud.
551
- * @public
552
- * @param {PointCloud} pointCloud - PointCloud object.
553
- * @returns {PointCloud} -
554
- */
555
- setPointCloud(pointCloud) {
556
- if (this.pointCloud) {
557
- this.pointCloud.remove();
558
- }
559
- this.pointCloud = pointCloud;
560
- this.pointCloud._entity = this;
561
- this.pointCloud.setVisibility(this._visibility);
562
- this._entityCollection && this._entityCollection._pointCloudHandler.add(pointCloud);
563
- return pointCloud;
564
- }
565
-
566
- /**
567
- * Sets entity geometry.
568
- * @public
569
- * @param {Geometry} geometry - Geometry object.
570
- * @returns {Geometry} -
571
- */
572
- setGeometry(geometry) {
573
- if (this.geometry) {
574
- this.geometry.remove();
575
- }
576
- this.geometry = geometry;
577
- this.geometry._entity = this;
578
- this.geometry.setVisibility(this._visibility);
579
- this._layer && this._layer.add(this);
580
- return geometry;
581
- }
582
-
583
- /**
584
- * Sets entity strip.
585
- * @public
586
- * @param {Strip} strip - Strip object.
587
- * @returns {Strip} -
588
- */
589
- setStrip(strip) {
590
- if (this.strip) {
591
- this.strip.remove();
592
- }
593
- this.strip = strip;
594
- this.strip._entity = this;
595
- this.strip.setVisibility(this._visibility);
596
- this._entityCollection && this._entityCollection._stripHandler.add(strip);
597
- return strip;
598
- }
599
-
600
- get layer() {
601
- return this._layer;
602
- }
603
-
604
- get rendererEvents() {
605
- if (this._layer) {
606
- return this._layer.events;
607
- } else if (this._entityCollection) {
608
- return this._entityCollection.events;
609
- }
610
- return null;
611
- }
612
-
613
- /**
614
- * Append child entity.
615
- * @public
616
- * @param {Entity} entity - Child entity.
617
- */
618
- appendChild(entity) {
619
- entity._entityCollection = this._entityCollection;
620
- entity._pickingColor = this._pickingColor;
621
- entity.parent = this;
622
- this.childrenNodes.push(entity);
623
- this._entityCollection && this._entityCollection._addRecursively(entity);
624
- }
625
-
626
- /**
627
- * Appends entity items(billboard, label etc.) picking color.
628
- * @public
629
- */
630
- setPickingColor() {
631
- var c = this._pickingColor;
632
-
633
- // billboard
634
- this.billboard && this.billboard.setPickingColor3v(c);
635
-
636
- // label
637
- this.label && this.label.setPickingColor3v(c);
638
-
639
- // shape
640
- this.shape && this.shape.setPickingColor3v(c);
641
-
642
- // polyline
643
- this.polyline && this.polyline.setPickingColor3v(c);
644
-
645
- // ray
646
- this.ray && this.ray.setPickingColor3v(c);
647
-
648
- // strip
649
- this.strip && this.strip.setPickingColor3v(c);
650
-
651
- for (var i = 0; i < this.childrenNodes.length; i++) {
652
- this.childrenNodes[i].setPickingColor();
653
- }
654
- }
655
-
656
- /**
657
- * Return geodethic extent.
658
- * @returns {Extent} -
659
- */
660
- getExtent() {
661
- var res;
662
- var c = this._lonlat;
663
- if (this.billboard || this.label) {
664
- res = new Extent(new LonLat(c.lon, c.lat), new LonLat(c.lon, c.lat));
665
- } else {
666
- res = new Extent(new LonLat(180.0, 90.0), new LonLat(-180.0, -90.0));
667
- }
668
-
669
- var sw = res.southWest,
670
- ne = res.northEast;
671
-
672
- if (this.polyline) {
673
- let e = this.polyline.getExtent();
674
- if (e.southWest.lon < sw.lon) sw.lon = e.southWest.lon;
675
- if (e.southWest.lat < sw.lat) sw.lat = e.southWest.lat;
676
- if (e.northEast.lon > ne.lon) ne.lon = e.northEast.lon;
677
- if (e.northEast.lat > ne.lat) ne.lat = e.northEast.lat;
678
- }
679
-
680
- if (this.geometry) {
681
- let e = this.geometry.getExtent();
682
- if (e.southWest.lon < sw.lon) sw.lon = e.southWest.lon;
683
- if (e.southWest.lat < sw.lat) sw.lat = e.southWest.lat;
684
- if (e.northEast.lon > ne.lon) ne.lon = e.northEast.lon;
685
- if (e.northEast.lat > ne.lat) ne.lat = e.northEast.lat;
686
- }
687
-
688
- for (var i = 0; i < this.childrenNodes.length; i++) {
689
- let e = this.childrenNodes[i].getExtent();
690
- if (e.southWest.lon < sw.lon) sw.lon = e.southWest.lon;
691
- if (e.southWest.lat < sw.lat) sw.lat = e.southWest.lat;
692
- if (e.northEast.lon > ne.lon) ne.lon = e.northEast.lon;
693
- if (e.northEast.lat > ne.lat) ne.lat = e.northEast.lat;
694
- }
695
-
696
- return res;
697
- }
698
-
699
- isEqual(entity) {
700
- return this.id === entity.id;
701
- }
702
- }
703
-
704
- export { Entity };
1
+ /**
2
+ * @module og/entity/Entity
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import * as mercator from "../mercator.js";
8
+ import * as utils from "../utils/shared.js";
9
+ import { Billboard } from "./Billboard.js";
10
+ import { Strip } from "./Strip.js";
11
+ import { Extent } from "../Extent.js";
12
+ import { Geometry } from "./Geometry.js";
13
+ import { Label } from "./Label.js";
14
+ import { LonLat } from "../LonLat.js";
15
+ import { Polyline } from "./Polyline.js";
16
+ import { Ray } from "./Ray.js";
17
+ import { PointCloud } from "./PointCloud.js";
18
+ import { Sphere } from "../shapes/Sphere.js";
19
+ import { Vec3 } from "../math/Vec3.js";
20
+ import { GeoObject } from "./GeoObject.js";
21
+
22
+ /**
23
+ * Entity instances aggregate multiple forms of visualization into a single high-level object.
24
+ * They can be created manually and added to entity collection.
25
+ *
26
+ * @class
27
+ * @param {Object} [options] - Entity options:
28
+ * @param {string} [options.name] - A human readable name to display to users. It does not have to be unique.
29
+ * @param {Vec3|Array.<number>} [options.cartesian] - Spatial entities like billboard, label, sphere etc. cartesian position.
30
+ * @param {LonLat} [options.lonlat] - Geodetic coordiantes for an entities like billboard, label, sphere etc.
31
+ * @param {boolean} [options.aground] - True for entities that have to be placed on the relief.
32
+ * @param {boolean} [options.visibility] - Entity visibility.
33
+ * @param {*} [options.billboard] - Billboard options(see {@link og.Billboard}).
34
+ * @param {*} [options.label] - Label options(see {@link og.Label}).
35
+ * @param {*} [options.sphere] - Sphere options(see {@link og.shape.Sphere}).
36
+ * @param {*} [options.box] - Sphere options(see {@link og.shape.Box}).
37
+ * @param {*} [options.polyline] - Polyline options(see {@link og.Polyline}).
38
+ * @param {*} [options.ray] - Ray options(see {@link og.Ray}).
39
+ * @param {*} [options.pointCloud] - Point cloud options(see {@link og.PointCloud}).
40
+ * @param {*} [options.geometry] - Geometry options (see {@link og.Geometry}), available for vector layer only.
41
+ * @param {*} [options.properties] - Entity custom properties.
42
+ */
43
+ class Entity {
44
+ constructor(options) {
45
+ options = options || {};
46
+
47
+ options.properties = options.properties || {};
48
+
49
+ /**
50
+ * Unic identifier.
51
+ * @public
52
+ * @readonly
53
+ */
54
+ this.id = Entity._staticCounter++;
55
+
56
+ /**
57
+ * Entity user defined properties.
58
+ * @public
59
+ * @type {Object}
60
+ */
61
+ this.properties = options.properties || {};
62
+
63
+ /**
64
+ * Entity name.
65
+ * @public
66
+ * @type {string}
67
+ */
68
+ this.properties.name = this.properties.name || options.name || "";
69
+
70
+ /**
71
+ * Children entities.
72
+ * @public
73
+ * @type {Array.<Entity>}
74
+ */
75
+ this.childrenNodes = [];
76
+
77
+ /**
78
+ * Parent entity.
79
+ * @public
80
+ * @type {Entity}
81
+ */
82
+ this.parent = null;
83
+
84
+ /**
85
+ * Entity cartesian position.
86
+ * @protected
87
+ * @type {Vec3}
88
+ */
89
+ this._cartesian = utils.createVector3(options.cartesian);
90
+
91
+ /**
92
+ * Geodetic entity coordiantes.
93
+ * @protected
94
+ * @type {LonLat}
95
+ */
96
+ this._lonlat = utils.createLonLat(options.lonlat);
97
+
98
+ /**
99
+ * World Mercator entity coordinates.
100
+ * @protected
101
+ * @type {LonLat}
102
+ */
103
+ this._lonlatMerc = null;
104
+
105
+ /**
106
+ * Entity visible terrain altitude.
107
+ * @protected
108
+ * @type {number}
109
+ */
110
+ this._altitude = options.altitude || 0.0;
111
+
112
+ /**
113
+ * Visibility flag.
114
+ * @protected
115
+ * @type {boolean}
116
+ */
117
+ this._visibility = options.visibility != undefined ? options.visibility : true;
118
+
119
+ /**
120
+ * Entity collection that this entity belongs to.
121
+ * @protected
122
+ * @type {EntityCollection}
123
+ */
124
+ this._entityCollection = null;
125
+
126
+ /**
127
+ * Entity collection array store index.
128
+ * @protected
129
+ * @type {number}
130
+ */
131
+ this._entityCollectionIndex = -1;
132
+
133
+ /**
134
+ * Assigned vector layer pointer.
135
+ * @protected
136
+ * @type {layer.Vector}
137
+ */
138
+ this._layer = null;
139
+
140
+ /**
141
+ * Assigned vector layer entity array index.
142
+ * @protected
143
+ * @type {number}
144
+ */
145
+ this._layerIndex = -1;
146
+
147
+ /**
148
+ * Picking color.
149
+ * @protected
150
+ * @type {Vec3}
151
+ */
152
+ this._pickingColor = new Vec3(0, 0, 0);
153
+
154
+ this._featureConstructorArray = {
155
+ billboard: [Billboard, this.setBillboard],
156
+ label: [Label, this.setLabel],
157
+ sphere: [Sphere, this.setShape],
158
+ // box: [Box, this.setShape],
159
+ polyline: [Polyline, this.setPolyline],
160
+ pointCloud: [PointCloud, this.setPointCloud],
161
+ geometry: [Geometry, this.setGeometry],
162
+ geoObject: [GeoObject, this.setGeoObject],
163
+ strip: [Strip, this.setStrip],
164
+ ray: [Ray, this.setRay]
165
+ };
166
+
167
+ /**
168
+ * Billboard entity.
169
+ * @public
170
+ * @type {Billboard}
171
+ */
172
+ this.billboard = this._createOptionFeature("billboard", options.billboard);
173
+
174
+ /**
175
+ * Text label entity.
176
+ * @public
177
+ * @type {Label}
178
+ */
179
+ this.label = this._createOptionFeature("label", options.label);
180
+
181
+ /**
182
+ * Shape entity.
183
+ * @public
184
+ * @type {shape.BaseShape}
185
+ */
186
+ this.shape = this._createOptionFeature("sphere", options.sphere || options.box);
187
+
188
+ /**
189
+ * Polyline entity.
190
+ * @public
191
+ * @type {Polyline}
192
+ */
193
+ this.polyline = this._createOptionFeature("polyline", options.polyline);
194
+
195
+ /**
196
+ * Ray entity.
197
+ * @public
198
+ * @type {ray}
199
+ */
200
+ this.ray = this._createOptionFeature("ray", options.ray);
201
+
202
+ /**
203
+ * PointCloud entity.
204
+ * @public
205
+ * @type {PointCloud}
206
+ */
207
+ this.pointCloud = this._createOptionFeature("pointCloud", options.pointCloud);
208
+
209
+ /**
210
+ * Geometry entity(available for vector layer only).
211
+ * @public
212
+ * @type {Geometry}
213
+ */
214
+ this.geometry = this._createOptionFeature("geometry", options.geometry);
215
+
216
+ /**
217
+ * Geo object entity
218
+ * @public
219
+ * @type {og.Geometry}
220
+ */
221
+ this.geoObject = this._createOptionFeature("geoObject", options.geoObject);
222
+
223
+ /**
224
+ * Strip entity.
225
+ * @public
226
+ * @type {Strip}
227
+ */
228
+ this.strip = this._createOptionFeature("strip", options.strip);
229
+ }
230
+
231
+ static get _staticCounter() {
232
+ if (!this._counter && this._counter !== 0) {
233
+ this._counter = 0;
234
+ }
235
+ return this._counter;
236
+ }
237
+
238
+ static set _staticCounter(n) {
239
+ this._counter = n;
240
+ }
241
+
242
+ get instanceName() {
243
+ return "Entity";
244
+ }
245
+
246
+ _createOptionFeature(featureName, options) {
247
+ if (options) {
248
+ let c = this._featureConstructorArray[featureName];
249
+ return c[1].call(this, new c[0](options));
250
+ }
251
+ return null;
252
+ }
253
+
254
+ getCollectionIndex() {
255
+ return this._entityCollectionIndex;
256
+ }
257
+
258
+ /**
259
+ * Adds current entity into the specified entity collection.
260
+ * @public
261
+ * @param {EntityCollection|Vector} collection - Specified entity collection or vector layer.
262
+ * @param {Boolean} [rightNow=false] - Entity insertion option for vector layer.
263
+ * @returns {Entity} - This object.
264
+ */
265
+ addTo(collection, rightNow) {
266
+ collection.add(this, rightNow);
267
+ return this;
268
+ }
269
+
270
+ /**
271
+ * Removes current entity from collection and layer.
272
+ * @public
273
+ */
274
+ remove() {
275
+ this._layer && this._layer.removeEntity(this);
276
+ this._entityCollection && this._entityCollection.removeEntity(this);
277
+ }
278
+
279
+ /**
280
+ * Sets the entity visibility.
281
+ * @public
282
+ * @param {boolean} visibility - Entity visibility.
283
+ */
284
+ setVisibility(visibility) {
285
+ this._visibility = visibility;
286
+
287
+ // billboards
288
+ this.billboard && this.billboard.setVisibility(visibility);
289
+
290
+ // geoObject
291
+ this.geoObject && this.geoObject.setVisibility(visibility);
292
+
293
+ // labels
294
+ this.label && this.label.setVisibility(visibility);
295
+
296
+ // shape
297
+ this.shape && this.shape.setVisibility(visibility);
298
+
299
+ // polyline
300
+ this.polyline && this.polyline.setVisibility(visibility);
301
+
302
+ // ray
303
+ this.ray && this.ray.setVisibility(visibility);
304
+
305
+ // geometry
306
+ this.geometry && this.geometry.setVisibility(visibility);
307
+
308
+ for (let i = 0; i < this.childrenNodes.length; i++) {
309
+ this.childrenNodes[i].setVisibility(visibility);
310
+ }
311
+ }
312
+
313
+ /**
314
+ * Returns entity visibility.
315
+ * @public
316
+ * @returns {boolean} -
317
+ */
318
+ getVisibility() {
319
+ return this._visibility;
320
+ }
321
+
322
+ /**
323
+ * Sets entity cartesian position.
324
+ * @public
325
+ * @param {Vec3} cartesian - Cartesian position in 3d space.
326
+ */
327
+ setCartesian3v(cartesian) {
328
+ this.setCartesian(cartesian.x, cartesian.y, cartesian.z);
329
+ }
330
+
331
+ /**
332
+ * Sets entity cartesian position.
333
+ * @public
334
+ * @param {number} x - 3d space X - position.
335
+ * @param {number} y - 3d space Y - position.
336
+ * @param {number} z - 3d space Z - position.
337
+ */
338
+ setCartesian(x, y, z) {
339
+ let p = this._cartesian;
340
+
341
+ p.x = x;
342
+ p.y = y;
343
+ p.z = z;
344
+
345
+ // billboards
346
+ this.billboard && this.billboard.setPosition3v(p);
347
+
348
+ // geoObject
349
+ this.geoObject && this.geoObject.setPosition3v(p);
350
+
351
+ // labels
352
+ this.label && this.label.setPosition3v(p);
353
+
354
+ // shape
355
+ this.shape && this.shape.setPosition3v(p);
356
+
357
+ for (let i = 0; i < this.childrenNodes.length; i++) {
358
+ this.childrenNodes[i].setCartesian(x, y, z);
359
+ }
360
+
361
+ let ec = this._entityCollection;
362
+
363
+ if (ec && ec.renderNode && ec.renderNode.ellipsoid) {
364
+ this._lonlat = ec.renderNode.ellipsoid.cartesianToLonLat(p);
365
+
366
+ if (Math.abs(this._lonlat.lat) < mercator.MAX_LAT) {
367
+ this._lonlatMerc = this._lonlat.forwardMercator();
368
+ } else {
369
+ this._lonlatMerc = null;
370
+ }
371
+ }
372
+
373
+ ec && ec.events.dispatch(ec.events.entitymove, this);
374
+ }
375
+
376
+ /**
377
+ * Sets entity cartesian position without event dispatching.
378
+ * @protected
379
+ * @param {Vec3} cartesian - Cartesian position in 3d space.
380
+ * @param {boolean} skipLonLat - skip geodetic calculation.
381
+ */
382
+ _setCartesian3vSilent(cartesian, skipLonLat) {
383
+ let p = this._cartesian;
384
+
385
+ p.x = cartesian.x;
386
+ p.y = cartesian.y;
387
+ p.z = cartesian.z;
388
+
389
+ // billboards
390
+ this.billboard && this.billboard.setPosition3v(p);
391
+
392
+ // geoObject
393
+ this.geoObject && this.geoObject.setPosition3v(p);
394
+
395
+ // labels
396
+ this.label && this.label.setPosition3v(p);
397
+
398
+ // shape
399
+ this.shape && this.shape.setPosition3v(p);
400
+
401
+ for (let i = 0; i < this.childrenNodes.length; i++) {
402
+ this.childrenNodes[i].setCartesian(p.x, p.y, p.z);
403
+ }
404
+
405
+ let ec = this._entityCollection;
406
+
407
+ if (!skipLonLat && ec && ec.renderNode && ec.renderNode.ellipsoid) {
408
+ this._lonlat = ec.renderNode.ellipsoid.cartesianToLonLat(p);
409
+
410
+ if (Math.abs(this._lonlat.lat) < mercator.MAX_LAT) {
411
+ this._lonlatMerc = this._lonlat.forwardMercator();
412
+ } else {
413
+ this._lonlatMerc = null;
414
+ }
415
+ }
416
+ }
417
+
418
+ /**
419
+ * Gets entity geodetic coordinates.
420
+ * @public
421
+ * @returns {LonLat} -
422
+ */
423
+ getLonLat() {
424
+ return this._lonlat.clone();
425
+ }
426
+
427
+ /**
428
+ * Sets geodetic coordinates of the entity point object.
429
+ * @public
430
+ * @param {LonLat} lonlat - WGS84 coordinates.
431
+ */
432
+ setLonLat(lonlat) {
433
+ let l = this._lonlat;
434
+
435
+ l.lon = lonlat.lon;
436
+ l.lat = lonlat.lat;
437
+ l.height = lonlat.height;
438
+
439
+ let ec = this._entityCollection;
440
+ if (ec && ec.renderNode && ec.renderNode.ellipsoid) {
441
+ if (Math.abs(lonlat.lat) < mercator.MAX_LAT) {
442
+ this._lonlatMerc = lonlat.forwardMercator();
443
+ } else {
444
+ this._lonlatMerc = null;
445
+ }
446
+
447
+ ec.renderNode.ellipsoid.lonLatToCartesianRes(lonlat, this._cartesian);
448
+ this.setCartesian3v(this._cartesian);
449
+ }
450
+ }
451
+
452
+ /**
453
+ * Sets entity altitude over the planet.
454
+ * @public
455
+ * @param {number} altitude - Altitude.
456
+ */
457
+ setAltitude(altitude) {
458
+ this._altitude = altitude;
459
+ }
460
+
461
+ /**
462
+ * Sets entity altitude over the planet.
463
+ * @public
464
+ * @return {number} Altitude.
465
+ */
466
+ getAltitude() {
467
+ return this._altitude;
468
+ }
469
+
470
+ /**
471
+ * Returns carteain position.
472
+ * @public
473
+ * @returns {Vec3} -
474
+ */
475
+ getCartesian() {
476
+ return this._cartesian.clone();
477
+ }
478
+
479
+ /**
480
+ * Sets entity billboard.
481
+ * @public
482
+ * @param {Billboard} billboard - Billboard object.
483
+ * @returns {Billboard} -
484
+ */
485
+ setBillboard(billboard) {
486
+ if (this.billboard) {
487
+ this.billboard.remove();
488
+ }
489
+ this.billboard = billboard;
490
+ this.billboard._entity = this;
491
+ this.billboard.setPosition3v(this._cartesian);
492
+ this.billboard.setVisibility(this._visibility);
493
+ this._entityCollection && this._entityCollection._billboardHandler.add(billboard);
494
+ return billboard;
495
+ }
496
+
497
+ /**
498
+ * Sets entity label.
499
+ * @public
500
+ * @param {Label} label - Text label.
501
+ * @returns {Label} -
502
+ */
503
+ setLabel(label) {
504
+ if (this.label) {
505
+ this.label.remove();
506
+ }
507
+ this.label = label;
508
+ this.label._entity = this;
509
+ this.label.setPosition3v(this._cartesian);
510
+ this.label.setVisibility(this._visibility);
511
+ this._entityCollection && this._entityCollection._labelHandler.add(label);
512
+ return label;
513
+ }
514
+
515
+ /**
516
+ * Sets entity ray.
517
+ * @public
518
+ * @param {Ray} ray - Ray object.
519
+ * @returns {Ray} -
520
+ */
521
+ setRay(ray) {
522
+ if (this.ray) {
523
+ this.ray.remove();
524
+ }
525
+ this.ray = ray;
526
+ this.ray._entity = this;
527
+ this.ray.setVisibility(this._visibility);
528
+ this._entityCollection && this._entityCollection._rayHandler.add(ray);
529
+ return ray;
530
+ }
531
+
532
+ /**
533
+ * Sets entity shape.
534
+ * @public
535
+ * @param {BaseShape} shape - Shape object.
536
+ * @returns {Polyline} -
537
+ */
538
+ setShape(shape) {
539
+ if (this.shape) {
540
+ this.shape.remove();
541
+ }
542
+ this.shape = shape;
543
+ this.shape._entity = this;
544
+ this.shape.setPosition3v(this._cartesian);
545
+ this.shape.setVisibility(this._visibility);
546
+ this._entityCollection && this._entityCollection._shapeHandler.add(shape);
547
+ return shape;
548
+ }
549
+
550
+ /**
551
+ * Sets entity polyline.
552
+ * @public
553
+ * @param {Polyline} polyline - Polyline object.
554
+ * @returns {Polyline} -
555
+ */
556
+ setPolyline(polyline) {
557
+ if (this.polyline) {
558
+ this.polyline.remove();
559
+ }
560
+ this.polyline = polyline;
561
+ this.polyline._entity = this;
562
+ this.polyline.setVisibility(this._visibility);
563
+ this._entityCollection && this._entityCollection._polylineHandler.add(polyline);
564
+ return polyline;
565
+ }
566
+
567
+ /**
568
+ * Sets entity pointCloud.
569
+ * @public
570
+ * @param {PointCloud} pointCloud - PointCloud object.
571
+ * @returns {PointCloud} -
572
+ */
573
+ setPointCloud(pointCloud) {
574
+ if (this.pointCloud) {
575
+ this.pointCloud.remove();
576
+ }
577
+ this.pointCloud = pointCloud;
578
+ this.pointCloud._entity = this;
579
+ this.pointCloud.setVisibility(this._visibility);
580
+ this._entityCollection && this._entityCollection._pointCloudHandler.add(pointCloud);
581
+ return pointCloud;
582
+ }
583
+
584
+ /**
585
+ * Sets entity geometry.
586
+ * @public
587
+ * @param {Geometry} geometry - Geometry object.
588
+ * @returns {Geometry} -
589
+ */
590
+ setGeometry(geometry) {
591
+ if (this.geometry) {
592
+ this.geometry.remove();
593
+ }
594
+ this.geometry = geometry;
595
+ this.geometry._entity = this;
596
+ this.geometry.setVisibility(this._visibility);
597
+ this._layer && this._layer.add(this);
598
+ return geometry;
599
+ }
600
+
601
+ /**
602
+ * Sets entity geoObject.
603
+ * @public
604
+ * @param {GeoObject} geoObject - GeoObject.
605
+ * @returns {GeoObject} -
606
+ */
607
+ setGeoObject(geoObject) {
608
+ if (this.geoObject) {
609
+ this.geoObject.remove();
610
+ }
611
+ this.geoObject = geoObject;
612
+ this.geoObject._entity = this;
613
+ this.geoObject.setPosition3v(this._cartesian);
614
+ this.geoObject.setVisibility(this._visibility);
615
+ this._entityCollection && this._entityCollection._geoObjectHandler.add(geoObject);
616
+ return geoObject;
617
+ }
618
+
619
+ /**
620
+ * Sets entity strip.
621
+ * @public
622
+ * @param {Strip} strip - Strip object.
623
+ * @returns {Strip} -
624
+ */
625
+ setStrip(strip) {
626
+ if (this.strip) {
627
+ this.strip.remove();
628
+ }
629
+ this.strip = strip;
630
+ this.strip._entity = this;
631
+ this.strip.setVisibility(this._visibility);
632
+ this._entityCollection && this._entityCollection._stripHandler.add(strip);
633
+ return strip;
634
+ }
635
+
636
+ get layer() {
637
+ return this._layer;
638
+ }
639
+
640
+ get rendererEvents() {
641
+ if (this._layer) {
642
+ return this._layer.events;
643
+ } else if (this._entityCollection) {
644
+ return this._entityCollection.events;
645
+ }
646
+ return null;
647
+ }
648
+
649
+ /**
650
+ * Append child entity.
651
+ * @public
652
+ * @param {Entity} entity - Child entity.
653
+ */
654
+ appendChild(entity) {
655
+ entity._entityCollection = this._entityCollection;
656
+ entity._pickingColor = this._pickingColor;
657
+ entity.parent = this;
658
+ this.childrenNodes.push(entity);
659
+ this._entityCollection && this._entityCollection._addRecursively(entity);
660
+ }
661
+
662
+ /**
663
+ * Appends entity items(billboard, label etc.) picking color.
664
+ * @public
665
+ */
666
+ setPickingColor() {
667
+ let c = this._pickingColor;
668
+
669
+ // billboard
670
+ this.billboard && this.billboard.setPickingColor3v(c);
671
+
672
+ // label
673
+ this.label && this.label.setPickingColor3v(c);
674
+
675
+ // shape
676
+ this.shape && this.shape.setPickingColor3v(c);
677
+
678
+ // polyline
679
+ this.polyline && this.polyline.setPickingColor3v(c);
680
+
681
+ // ray
682
+ this.ray && this.ray.setPickingColor3v(c);
683
+
684
+ // strip
685
+ this.strip && this.strip.setPickingColor3v(c);
686
+
687
+ // billboard
688
+ this.geoObject && this.geoObject.setPickingColor3v(c);
689
+ for (let i = 0; i < this.childrenNodes.length; i++) {
690
+ this.childrenNodes[i].setPickingColor();
691
+ }
692
+ }
693
+
694
+ /**
695
+ * Return geodethic extent.
696
+ * @returns {Extent} -
697
+ */
698
+ getExtent() {
699
+ let res;
700
+ let c = this._lonlat;
701
+ if (this.billboard || this.label) {
702
+ res = new Extent(new LonLat(c.lon, c.lat), new LonLat(c.lon, c.lat));
703
+ } else {
704
+ res = new Extent(new LonLat(180.0, 90.0), new LonLat(-180.0, -90.0));
705
+ }
706
+
707
+ let sw = res.southWest,
708
+ ne = res.northEast;
709
+
710
+ if (this.polyline) {
711
+ let e = this.polyline.getExtent();
712
+ if (e.southWest.lon < sw.lon) sw.lon = e.southWest.lon;
713
+ if (e.southWest.lat < sw.lat) sw.lat = e.southWest.lat;
714
+ if (e.northEast.lon > ne.lon) ne.lon = e.northEast.lon;
715
+ if (e.northEast.lat > ne.lat) ne.lat = e.northEast.lat;
716
+ }
717
+
718
+ if (this.geometry) {
719
+ let e = this.geometry.getExtent();
720
+ if (e.southWest.lon < sw.lon) sw.lon = e.southWest.lon;
721
+ if (e.southWest.lat < sw.lat) sw.lat = e.southWest.lat;
722
+ if (e.northEast.lon > ne.lon) ne.lon = e.northEast.lon;
723
+ if (e.northEast.lat > ne.lat) ne.lat = e.northEast.lat;
724
+ }
725
+
726
+ for (let i = 0; i < this.childrenNodes.length; i++) {
727
+ let e = this.childrenNodes[i].getExtent();
728
+ if (e.southWest.lon < sw.lon) sw.lon = e.southWest.lon;
729
+ if (e.southWest.lat < sw.lat) sw.lat = e.southWest.lat;
730
+ if (e.northEast.lon > ne.lon) ne.lon = e.northEast.lon;
731
+ if (e.northEast.lat > ne.lat) ne.lat = e.northEast.lat;
732
+ }
733
+
734
+ return res;
735
+ }
736
+
737
+ isEqual(entity) {
738
+ return this.id === entity.id;
739
+ }
740
+ }
741
+
742
+ export { Entity };