@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,27 +2,25 @@
2
2
  * @module og/shape/BaseShape
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { Vec3 } from '../math/Vec3.js';
8
- import { Quat } from '../math/Quat.js';
9
- import { Mat4 } from '../math/Mat4.js';
7
+ import { Vec3 } from "../math/Vec3.js";
8
+ import { Quat } from "../math/Quat.js";
9
+ import { Mat4 } from "../math/Mat4.js";
10
10
 
11
11
  /**
12
12
  * Base geometry shape class.
13
13
  * @class
14
14
  * @param {Object} options - Shape parameters:
15
- * @param {og.Vec3} [options.position] - Shape position.
16
- * @param {og.Quat} [options.orientation] - Shape orientation(rotation).
17
- * @param {og.Vec3} [options.scale] - Scale vector.
15
+ * @param {Vec3} [options.position] - Shape position.
16
+ * @param {Quat} [options.orientation] - Shape orientation(rotation).
17
+ * @param {Vec3} [options.scale] - Scale vector.
18
18
  * @param {Array.<number>} [options.color] - Shape RGBA color. (exactly 4 entries)
19
19
  * @param {string} [options.src] - Texture image url source.
20
20
  * @param {boolean} [options.visibility] - Shape visibility.
21
21
  */
22
22
  class BaseShape {
23
-
24
23
  constructor(options) {
25
-
26
24
  options = options || {};
27
25
 
28
26
  /**
@@ -36,21 +34,21 @@ class BaseShape {
36
34
  /**
37
35
  * Shape position.
38
36
  * @public
39
- * @type {og.Vec3}
37
+ * @type {Vec3}
40
38
  */
41
39
  this.position = options.position || new Vec3();
42
40
 
43
41
  /**
44
42
  * Shape orientation(rotation)
45
43
  * @public
46
- * @type {og.Quat}
44
+ * @type {Quat}
47
45
  */
48
46
  this.orientation = options.orientation || new Quat(0.0, 0.0, 0.0, 1.0);
49
47
 
50
48
  /**
51
49
  * Scale.
52
50
  * @public
53
- * @type {og.Vec3}
51
+ * @type {Vec3}
54
52
  */
55
53
  this.scale = options.scale || new Vec3(1.0, 1.0, 1.0);
56
54
 
@@ -59,14 +57,16 @@ class BaseShape {
59
57
  * @public
60
58
  * @type {Array.<number>} - (exactly 4 entries)
61
59
  */
62
- this.color = options.color ? new Float32Array(options.color) : new Float32Array([1.0, 1.0, 1.0, 1.0]);
60
+ this.color = options.color
61
+ ? new Float32Array(options.color)
62
+ : new Float32Array([1.0, 1.0, 1.0, 1.0]);
63
63
 
64
64
  /**
65
65
  * Shape visibility.
66
66
  * @public
67
67
  * @type {boolean}
68
68
  */
69
- this.visibility = (options.visibility != undefined ? options.visibility : true);
69
+ this.visibility = options.visibility != undefined ? options.visibility : true;
70
70
 
71
71
  /**
72
72
  * Image url source.
@@ -130,21 +130,21 @@ class BaseShape {
130
130
  /**
131
131
  * Scale matrix.
132
132
  * @protected
133
- * @type {og.Mat4}
133
+ * @type {Mat4}
134
134
  */
135
135
  this._mxScale = new Mat4().setIdentity().scale(this.scale);
136
136
 
137
137
  /**
138
138
  * Translation matrix.
139
139
  * @protected
140
- * @type {og.Mat4}
140
+ * @type {Mat4}
141
141
  */
142
142
  this._mxTranslation = new Mat4().setIdentity();
143
143
 
144
144
  /**
145
145
  * Model matrix.
146
146
  * @protected
147
- * @type {og.Mat4}
147
+ * @type {Mat4}
148
148
  */
149
149
  this._mxModel = new Mat4().setIdentity();
150
150
 
@@ -157,7 +157,7 @@ class BaseShape {
157
157
  /**
158
158
  * Assigned render node.
159
159
  * @protected
160
- * @type {og.scene.RenderNode}
160
+ * @type {RenderNode}
161
161
  */
162
162
  this._renderNode = null;
163
163
 
@@ -171,14 +171,14 @@ class BaseShape {
171
171
  /**
172
172
  * Entity instance that holds this shape.
173
173
  * @protected
174
- * @type {og.Entity}
174
+ * @type {Entity}
175
175
  */
176
176
  this._entity = null;
177
177
 
178
178
  /**
179
179
  * Handler that stores and renders this shape object.
180
180
  * @protected
181
- * @type {og.ShapeHandler}
181
+ * @type {ShapeHandler}
182
182
  */
183
183
  this._handler = null;
184
184
 
@@ -206,7 +206,6 @@ class BaseShape {
206
206
  * @public
207
207
  */
208
208
  clear() {
209
-
210
209
  this.position.set(0.0, 0.0, 0.0);
211
210
  this.orientation.set(0.0, 0.0, 0.0, 1.0);
212
211
  this.scale.set(1.0, 1.0, 1.0);
@@ -240,7 +239,7 @@ class BaseShape {
240
239
  /**
241
240
  * Sets shape color.
242
241
  * @public
243
- * @param {og.Vec4} color - RGBA color vector.
242
+ * @param {Vec4} color - RGBA color vector.
244
243
  */
245
244
  setColor4v(color) {
246
245
  this.color[0] = color.x;
@@ -296,7 +295,7 @@ class BaseShape {
296
295
  /**
297
296
  * Assign render node.
298
297
  * @public
299
- * @param {og.scene.RenderNode} renderNode - Render node to assign.
298
+ * @param {RenderNode} renderNode - Render node to assign.
300
299
  */
301
300
  setRenderNode(renderNode) {
302
301
  this._renderNode = renderNode;
@@ -305,7 +304,7 @@ class BaseShape {
305
304
  var img = new Image();
306
305
  var that = this;
307
306
  img.onload = function () {
308
- that.texture = renderNode.renderer.handler.createTexture(this);
307
+ that.texture = renderNode.renderer.handler.createTextureDefault(this);
309
308
  };
310
309
  img.src = this._src;
311
310
  }
@@ -314,7 +313,7 @@ class BaseShape {
314
313
  /**
315
314
  * Sets shape position.
316
315
  * @public
317
- * @param {og.Vec3} position - Shape position.
316
+ * @param {Vec3} position - Shape position.
318
317
  */
319
318
  setPosition3v(position) {
320
319
  this.position.copy(position);
@@ -325,7 +324,7 @@ class BaseShape {
325
324
  /**
326
325
  * Translate shape position to vector.
327
326
  * @public
328
- * @param {og.Vec3} vec - Translation vector.
327
+ * @param {Vec3} vec - Translation vector.
329
328
  */
330
329
  translate3v(vec) {
331
330
  this.position.addA(vec);
@@ -334,7 +333,7 @@ class BaseShape {
334
333
 
335
334
  /**
336
335
  * Sets shape scale.
337
- * @param {og.Vec3} scale - Scale vector.
336
+ * @param {Vec3} scale - Scale vector.
338
337
  */
339
338
  setScale3v(scale) {
340
339
  this.scale.copy(scale);
@@ -358,7 +357,7 @@ class BaseShape {
358
357
  /**
359
358
  * Assign picking color.
360
359
  * @protected
361
- * @param {og.Vec3} color - Picking RGB color.
360
+ * @param {Vec3} color - Picking RGB color.
362
361
  */
363
362
  setPickingColor3v(color) {
364
363
  //...
@@ -377,10 +376,26 @@ class BaseShape {
377
376
  _createBuffers() {
378
377
  this._deleteBuffers();
379
378
  var r = this._renderNode.renderer;
380
- this._positionBuffer = r.handler.createArrayBuffer(new Float32Array(this._positionData), 3, this._positionData.length / 3);
381
- this._normalBuffer = r.handler.createArrayBuffer(new Float32Array(this._normalData), 3, this._normalData.length / 3);
382
- this._indexBuffer = r.handler.createElementArrayBuffer(new Uint16Array(this._indexData), 1, this._indexData.length);
383
- this._textureCoordBuffer = r.handler.createArrayBuffer(new Float32Array(this._textureCoordData), 2, this._textureCoordData.length / 2);
379
+ this._positionBuffer = r.handler.createArrayBuffer(
380
+ new Float32Array(this._positionData),
381
+ 3,
382
+ this._positionData.length / 3
383
+ );
384
+ this._normalBuffer = r.handler.createArrayBuffer(
385
+ new Float32Array(this._normalData),
386
+ 3,
387
+ this._normalData.length / 3
388
+ );
389
+ this._indexBuffer = r.handler.createElementArrayBuffer(
390
+ new Uint16Array(this._indexData),
391
+ 1,
392
+ this._indexData.length
393
+ );
394
+ this._textureCoordBuffer = r.handler.createArrayBuffer(
395
+ new Float32Array(this._textureCoordData),
396
+ 2,
397
+ this._textureCoordData.length / 2
398
+ );
384
399
  }
385
400
 
386
401
  /**
@@ -400,9 +415,11 @@ class BaseShape {
400
415
  let rn = this._renderNode;
401
416
  let r = rn.renderer;
402
417
 
403
- let sh, p,
418
+ let sh,
419
+ p,
404
420
  gl = r.handler.gl,
405
- sha, shu;
421
+ sha,
422
+ shu;
406
423
 
407
424
  if (rn.lightEnabled) {
408
425
  sh = r.handler.programs.shape_wl;
@@ -415,12 +432,23 @@ class BaseShape {
415
432
  gl.uniform4fv(shu.lightsPositions, rn._lightsTransformedPositions);
416
433
  gl.uniform3fv(shu.lightsParamsv, rn._lightsParamsv);
417
434
  gl.uniform1fv(shu.lightsParamsf, rn._lightsParamsf);
418
- gl.uniformMatrix4fv(shu.projectionMatrix, false, r.activeCamera.getProjectionMatrix());
435
+ gl.uniformMatrix4fv(
436
+ shu.projectionMatrix,
437
+ false,
438
+ r.activeCamera.getProjectionMatrix()
439
+ );
419
440
  gl.uniformMatrix4fv(shu.viewMatrix, false, r.activeCamera.getViewMatrix());
420
441
  gl.uniformMatrix3fv(shu.normalMatrix, false, r.activeCamera.getNormalMatrix());
421
442
 
422
443
  gl.bindBuffer(gl.ARRAY_BUFFER, this._normalBuffer);
423
- gl.vertexAttribPointer(sha.aVertexNormal, this._normalBuffer.itemSize, gl.FLOAT, false, 0, 0);
444
+ gl.vertexAttribPointer(
445
+ sha.aVertexNormal,
446
+ this._normalBuffer.itemSize,
447
+ gl.FLOAT,
448
+ false,
449
+ 0,
450
+ 0
451
+ );
424
452
  } else {
425
453
  sh = r.handler.programs.shape_nl;
426
454
  p = sh._program;
@@ -429,13 +457,24 @@ class BaseShape {
429
457
 
430
458
  sh.activate();
431
459
 
432
- gl.uniformMatrix4fv(shu.projectionViewMatrix, false, r.activeCamera.getProjectionViewMatrix());
460
+ gl.uniformMatrix4fv(
461
+ shu.projectionViewMatrix,
462
+ false,
463
+ r.activeCamera.getProjectionViewMatrix()
464
+ );
433
465
  }
434
466
 
435
467
  gl.uniform4fv(shu.uColor, this.color);
436
468
 
437
469
  gl.bindBuffer(gl.ARRAY_BUFFER, this._positionBuffer);
438
- gl.vertexAttribPointer(sha.aVertexPosition, this._positionBuffer.itemSize, gl.FLOAT, false, 0, 0);
470
+ gl.vertexAttribPointer(
471
+ sha.aVertexPosition,
472
+ this._positionBuffer.itemSize,
473
+ gl.FLOAT,
474
+ false,
475
+ 0,
476
+ 0
477
+ );
439
478
  gl.uniformMatrix4fv(shu.modelMatrix, false, this._mxModel._m);
440
479
 
441
480
  gl.activeTexture(gl.TEXTURE0);
@@ -443,41 +482,74 @@ class BaseShape {
443
482
  gl.uniform1i(shu.uSampler, 0);
444
483
 
445
484
  gl.bindBuffer(gl.ARRAY_BUFFER, this._textureCoordBuffer);
446
- gl.vertexAttribPointer(sha.aTextureCoord, this._textureCoordBuffer.itemSize, gl.FLOAT, false, 0, 0);
485
+ gl.vertexAttribPointer(
486
+ sha.aTextureCoord,
487
+ this._textureCoordBuffer.itemSize,
488
+ gl.FLOAT,
489
+ false,
490
+ 0,
491
+ 0
492
+ );
447
493
 
448
494
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
449
- gl.drawElements(r.handler.gl.TRIANGLES, this._indexBuffer.numItems, gl.UNSIGNED_SHORT, 0);
495
+ gl.drawElements(
496
+ r.handler.gl.TRIANGLES,
497
+ this._indexBuffer.numItems,
498
+ gl.UNSIGNED_SHORT,
499
+ 0
500
+ );
450
501
  }
451
502
  }
452
503
 
453
- drawPicking() {
504
+ drawPicking() {
454
505
  if (this.visibility) {
455
506
  let rn = this._renderNode;
456
507
  let r = rn.renderer;
457
508
 
458
- let sh, p,
509
+ let sh,
510
+ p,
459
511
  gl = r.handler.gl,
460
- sha, shu;
512
+ sha,
513
+ shu;
461
514
 
515
+ sh = r.handler.programs.shape_picking;
516
+ p = sh._program;
517
+ shu = p.uniforms;
518
+ sha = p.attributes;
462
519
 
520
+ sh.activate();
463
521
 
464
- sh = r.handler.programs.shape_picking;
465
- p = sh._program;
466
- shu = p.uniforms;
467
- sha = p.attributes;
468
-
469
- sh.activate();
470
-
471
- gl.uniformMatrix4fv(shu.projectionViewMatrix, false, r.activeCamera.getProjectionViewMatrix());
522
+ gl.uniformMatrix4fv(
523
+ shu.projectionViewMatrix,
524
+ false,
525
+ r.activeCamera.getProjectionViewMatrix()
526
+ );
472
527
 
473
- gl.uniform4fv(shu.uColor, [this._pickingColor[0], this._pickingColor[1], this._pickingColor[2], 1.0]);
528
+ gl.uniform4fv(shu.uColor, [
529
+ this._pickingColor[0],
530
+ this._pickingColor[1],
531
+ this._pickingColor[2],
532
+ 1.0
533
+ ]);
474
534
 
475
535
  gl.bindBuffer(gl.ARRAY_BUFFER, this._positionBuffer);
476
- gl.vertexAttribPointer(sha.aVertexPosition, this._positionBuffer.itemSize, gl.FLOAT, false, 0, 0);
536
+ gl.vertexAttribPointer(
537
+ sha.aVertexPosition,
538
+ this._positionBuffer.itemSize,
539
+ gl.FLOAT,
540
+ false,
541
+ 0,
542
+ 0
543
+ );
477
544
  gl.uniformMatrix4fv(shu.modelMatrix, false, this._mxModel._m);
478
545
 
479
546
  gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, this._indexBuffer);
480
- gl.drawElements(r.handler.gl.TRIANGLES, this._indexBuffer.numItems, gl.UNSIGNED_SHORT, 0);
547
+ gl.drawElements(
548
+ r.handler.gl.TRIANGLES,
549
+ this._indexBuffer.numItems,
550
+ gl.UNSIGNED_SHORT,
551
+ 0
552
+ );
481
553
  }
482
554
  }
483
555
  }
@@ -2,17 +2,17 @@
2
2
  * @module og/shape/BaseShape
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { BaseShape } from './BaseShape.js';
7
+ import { BaseShape } from "./BaseShape.js";
8
8
 
9
9
  /**
10
10
  * @class
11
- * @extends {og.shape.BaseShape}
11
+ * @extends {BaseShape}
12
12
  * @param {Object} options - Icosphere parameters:
13
- * @param {og.Vec3} [options.position] - Icosphere position.
14
- * @param {og.Quat} [options.orientation] - Icosphere orientation(rotation).
15
- * @param {og.Vec3} [options.scale] - Scale vector.
13
+ * @param {Vec3} [options.position] - Icosphere position.
14
+ * @param {Quat} [options.orientation] - Icosphere orientation(rotation).
15
+ * @param {Vec3} [options.scale] - Scale vector.
16
16
  * @param {Array.<number>} [options.color] - Icosphere RGBA color. (exactly 4 entries)
17
17
  * @param {string} [options.src] - Texture image url source.
18
18
  * @param {boolean} [options.visibility] - Icosphere visibility.
@@ -45,7 +45,11 @@ class Icosphere extends BaseShape {
45
45
  // add vertex to mesh, fix position to be on unit sphere, return index
46
46
  _addVertex(p) {
47
47
  var length = Math.sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]);
48
- this._positionData.push(this._size * p[0] / length, this._size * p[1] / length, this._size * p[2] / length);
48
+ this._positionData.push(
49
+ (this._size * p[0]) / length,
50
+ (this._size * p[1]) / length,
51
+ (this._size * p[2]) / length
52
+ );
49
53
  return this._index++;
50
54
  }
51
55
 
@@ -63,9 +67,21 @@ class Icosphere extends BaseShape {
63
67
  return ret;
64
68
  }
65
69
 
66
- var point1 = [this._positionData[p1 * 3], this._positionData[p1 * 3 + 1], this._positionData[p1 * 3 + 2]];
67
- var point2 = [this._positionData[p2 * 3], this._positionData[p2 * 3 + 1], this._positionData[p2 * 3 + 2]];
68
- var middle = [(point1[0] + point2[0]) / 2.0, (point1[1] + point2[1]) / 2.0, (point1[2] + point2[2]) / 2.0];
70
+ var point1 = [
71
+ this._positionData[p1 * 3],
72
+ this._positionData[p1 * 3 + 1],
73
+ this._positionData[p1 * 3 + 2]
74
+ ];
75
+ var point2 = [
76
+ this._positionData[p2 * 3],
77
+ this._positionData[p2 * 3 + 1],
78
+ this._positionData[p2 * 3 + 2]
79
+ ];
80
+ var middle = [
81
+ (point1[0] + point2[0]) / 2.0,
82
+ (point1[1] + point2[1]) / 2.0,
83
+ (point1[2] + point2[2]) / 2.0
84
+ ];
69
85
 
70
86
  // add vertex makes sure point is on unit sphere
71
87
  var i = this._addVertex(middle);
@@ -79,7 +95,6 @@ class Icosphere extends BaseShape {
79
95
  * @virtual
80
96
  */
81
97
  _createData() {
82
-
83
98
  this._positionData = [];
84
99
  this._indexData = [];
85
100
  this._index = 0;
@@ -113,7 +128,7 @@ class Icosphere extends BaseShape {
113
128
  faces.push([0, 7, 10]);
114
129
  faces.push([0, 10, 11]);
115
130
 
116
- // 5 adjacent faces
131
+ // 5 adjacent faces
117
132
  faces.push([1, 5, 9]);
118
133
  faces.push([5, 11, 4]);
119
134
  faces.push([11, 10, 2]);
@@ -127,7 +142,7 @@ class Icosphere extends BaseShape {
127
142
  faces.push([3, 6, 8]);
128
143
  faces.push([3, 8, 9]);
129
144
 
130
- // 5 adjacent faces
145
+ // 5 adjacent faces
131
146
  faces.push([4, 9, 5]);
132
147
  faces.push([2, 4, 11]);
133
148
  faces.push([6, 2, 10]);
@@ -161,4 +176,4 @@ class Icosphere extends BaseShape {
161
176
  }
162
177
  }
163
178
 
164
- export { Icosphere };
179
+ export { Icosphere };
@@ -2,17 +2,17 @@
2
2
  * @module og/shape/BaseShape
3
3
  */
4
4
 
5
- 'use strict';
5
+ "use strict";
6
6
 
7
- import { BaseShape } from './BaseShape.js';
7
+ import { BaseShape } from "./BaseShape.js";
8
8
 
9
9
  /**
10
10
  * @class
11
- * @extends {og.shape.BaseShape}
11
+ * @extends {BaseShape}
12
12
  * @param {Object} options - Sphere parameters:
13
- * @param {og.Vec3} [options.position] - Sphere position.
14
- * @param {og.Quat} [options.orientation] - Sphere orientation(rotation).
15
- * @param {og.Vec3} [options.scale] - Scale vector.
13
+ * @param {Vec3} [options.position] - Sphere position.
14
+ * @param {Quat} [options.orientation] - Sphere orientation(rotation).
15
+ * @param {Vec3} [options.scale] - Scale vector.
16
16
  * @param {Array.<number>} [options.color] - Sphere RGBA color. (exactly 4 entries)
17
17
  * @param {string} [options.src] - Texture image url source.
18
18
  * @param {boolean} [options.visibility] - Sphere visibility.
@@ -21,11 +21,9 @@ import { BaseShape } from './BaseShape.js';
21
21
  * @param {number} [options.lonBands=16] - Number of longitude bands.
22
22
  */
23
23
  class Sphere extends BaseShape {
24
-
25
24
  constructor(options) {
26
-
27
25
  super(options);
28
-
26
+
29
27
  /**
30
28
  * Sphere radius.
31
29
  * @protected
@@ -57,20 +55,19 @@ class Sphere extends BaseShape {
57
55
  * @virtual
58
56
  */
59
57
  _createData() {
60
-
61
58
  for (let latNumber = 0; latNumber <= this._latBands; latNumber++) {
62
- var theta = latNumber * Math.PI / this._latBands;
59
+ var theta = (latNumber * Math.PI) / this._latBands;
63
60
  var sinTheta = Math.sin(theta);
64
61
  var cosTheta = Math.cos(theta);
65
62
 
66
63
  for (let longNumber = 0; longNumber <= this._lonBands; longNumber++) {
67
- var phi = longNumber * 2 * Math.PI / this._lonBands;
64
+ var phi = (longNumber * 2 * Math.PI) / this._lonBands;
68
65
  var sinPhi = Math.sin(phi);
69
66
  var cosPhi = Math.cos(phi);
70
67
  var x = cosPhi * sinTheta;
71
68
  var y = cosTheta;
72
69
  var z = sinPhi * sinTheta;
73
- var u = 1 - (longNumber / this._lonBands);
70
+ var u = 1 - longNumber / this._lonBands;
74
71
  var v = latNumber / this._latBands;
75
72
  this._normalData.push(x);
76
73
  this._normalData.push(y);
@@ -85,7 +82,7 @@ class Sphere extends BaseShape {
85
82
 
86
83
  for (let latNumber = 0; latNumber < this._latBands; latNumber++) {
87
84
  for (let longNumber = 0; longNumber < this._lonBands; longNumber++) {
88
- var first = (latNumber * (this._lonBands + 1)) + longNumber;
85
+ var first = latNumber * (this._lonBands + 1) + longNumber;
89
86
  var second = first + this._lonBands + 1;
90
87
 
91
88
  this._indexData.push(first);
@@ -100,4 +97,4 @@ class Sphere extends BaseShape {
100
97
  }
101
98
  }
102
99
 
103
- export { Sphere };
100
+ export { Sphere };
@@ -4,6 +4,7 @@ import { GlobusTerrain } from "./GlobusTerrain.js";
4
4
  import { WMS } from "../layer/WMS.js";
5
5
  import { isPowerOfTwo, nextHighestPowerOfTwo } from "../math.js";
6
6
  import { getTileExtent } from "../mercator.js";
7
+ import { Layer } from "../layer/Layer.js";
7
8
 
8
9
  class BilTerrain extends GlobusTerrain {
9
10
  constructor(options) {
@@ -58,7 +58,7 @@ class EmptyTerrain {
58
58
  /**
59
59
  * Planet node.
60
60
  * @protected
61
- * @type {og.scene.Planet}
61
+ * @type {Planet}
62
62
  */
63
63
  this._planet = null;
64
64
 
@@ -117,7 +117,7 @@ class EmptyTerrain {
117
117
  * Loads or creates segment elevation data.
118
118
  * @public
119
119
  * @virtual
120
- * @param {og.planetSegment.Segment} segment - Segment to create elevation data.
120
+ * @param {Segment} segment - Segment to create elevation data.
121
121
  */
122
122
  handleSegmentTerrain(segment) {
123
123
  segment.terrainIsLoading = false;
@@ -17,7 +17,6 @@ import { Vec3 } from "../math/Vec3.js";
17
17
  import { Ray } from "../math/Ray.js";
18
18
  import { Extent } from "../Extent.js";
19
19
  import { LonLat } from "../LonLat.js";
20
- import { MAX_NORMAL_ZOOM } from "../segment/Segment.js";
21
20
 
22
21
  const EVENT_NAMES = [
23
22
  /**
@@ -36,7 +35,7 @@ const EVENT_NAMES = [
36
35
  /**
37
36
  * Class that loads segment elevation data, converts it to the array and passes it to the planet segment.
38
37
  * @class
39
- * @extends {og.terrain.EmptyTerrain}
38
+ * @extends {EmptyTerrain}
40
39
  * @param {string} [name=""] - Terrain provider name.
41
40
  * @param {Object} [options] - Provider options:
42
41
  * @param {number} [options.minZoom=3] - Minimal visible zoom index when terrain handler works.
@@ -63,7 +62,7 @@ class GlobusTerrain extends EmptyTerrain {
63
62
  /**
64
63
  * Events handler.
65
64
  * @public
66
- * @type {og.Events}
65
+ * @type {Events}
67
66
  */
68
67
  this.events = new Events(EVENT_NAMES, this);
69
68
 
@@ -140,7 +139,7 @@ class GlobusTerrain extends EmptyTerrain {
140
139
  * Rewrites elevation storage url query.
141
140
  * @private
142
141
  * @callback og.terrain.GlobusTerrain~_urlRewriteCallback
143
- * @param {og.planetSegment.Segment} segment - Segment to load.
142
+ * @param {Segment} segment - Segment to load.
144
143
  * @param {string} url - Created url.
145
144
  * @returns {string} - Url query string.
146
145
  */
@@ -350,7 +349,8 @@ class GlobusTerrain extends EmptyTerrain {
350
349
  * Starts to load segment data.
351
350
  * @public
352
351
  * @virtual
353
- * @param {og.planetSegment.Segment} segment - Segment that wants a terrain data.
352
+ * @param {Segment} segment - Segment that wants a terrain data.
353
+ * @param {boolean} forceLoading
354
354
  */
355
355
  loadTerrain(segment, forceLoading) {
356
356
  if (this._planet.terrainLock.isFree()) {
@@ -400,7 +400,7 @@ class GlobusTerrain extends EmptyTerrain {
400
400
  * Creates query url.
401
401
  * @protected
402
402
  * @virtual
403
- * @param {og.planetSegment.Segment} segment -
403
+ * @param {Segment} segment -
404
404
  * @returns {string} -
405
405
  */
406
406
  _createUrl(segment) {
@@ -414,7 +414,7 @@ class GlobusTerrain extends EmptyTerrain {
414
414
  /**
415
415
  * Returns actual url query string.
416
416
  * @protected
417
- * @param {og.planetSegment.Segment} segment - Segment that loads image data.
417
+ * @param {Segment} segment - Segment that loads image data.
418
418
  * @returns {string} - Url string.
419
419
  */
420
420
  _getHTTPRequestString(segment) {
@@ -426,7 +426,7 @@ class GlobusTerrain extends EmptyTerrain {
426
426
  /**
427
427
  * Sets url rewrite callback, used for custom url rewriting for every tile laoding.
428
428
  * @public
429
- * @param {og.terrain.GlobusTerrain~_urlRewriteCallback} ur - The callback that returns tile custom created url.
429
+ * @param {GlobusTerrain~_urlRewriteCallback} ur - The callback that returns tile custom created url.
430
430
  */
431
431
  setUrlRewriteCallback(ur) {
432
432
  this._urlRewriteCallback = ur;
@@ -445,7 +445,7 @@ class GlobusTerrain extends EmptyTerrain {
445
445
 
446
446
  /**
447
447
  * @protected
448
- * @param {og.planetSegment.Segment} segment -
448
+ * @param {Segment} segment -
449
449
  * @param {*} data -
450
450
  */
451
451
  _applyElevationsData(segment, elevations) {
@@ -138,10 +138,14 @@ class FontAtlas {
138
138
 
139
139
  let img = new Image();
140
140
  img.onload = () => {
141
- atlas.createTexture(img);
141
+ this._createTexture(atlas, img);
142
142
  def.resolve(index);
143
143
  };
144
144
  img.src = ARIAL_FONT_B64;
145
+ }
146
+
147
+ _createTexture(atlas, img) {
148
+ atlas.createTexture(img);
145
149
  }
146
150
 
147
151
  loadFont(faceName, srcDir, atlasUrl) {
@@ -183,7 +187,7 @@ class FontAtlas {
183
187
 
184
188
  let img = new Image();
185
189
  img.onload = () => {
186
- atlas.createTexture(img);
190
+ this._createTexture(atlas, img);
187
191
  def.resolve(index);
188
192
  };
189
193