@openglobus/og 0.11.1 → 0.11.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (255) hide show
  1. package/package.json +18 -20
  2. package/src/og/Clock.js +11 -11
  3. package/src/og/Deferred.js +1 -1
  4. package/src/og/Events.js +9 -7
  5. package/src/og/Extent.js +117 -72
  6. package/src/og/Globe.js +35 -22
  7. package/src/og/ImageCanvas.js +24 -18
  8. package/src/og/Lock.js +2 -2
  9. package/src/og/LonLat.js +40 -37
  10. package/src/og/Popup.js +21 -15
  11. package/src/og/QueueArray.js +7 -3
  12. package/src/og/Rectangle.js +11 -6
  13. package/src/og/Stack.js +8 -5
  14. package/src/og/ajax.js +21 -33
  15. package/src/og/astro/astro.js +5 -5
  16. package/src/og/astro/earth.js +23 -17
  17. package/src/og/astro/jd.js +44 -39
  18. package/src/og/astro/orbit.js +20 -18
  19. package/src/og/astro/rotation.js +17 -8
  20. package/src/og/bv/Box.js +7 -3
  21. package/src/og/bv/Sphere.js +17 -9
  22. package/src/og/camera/Camera.js +137 -86
  23. package/src/og/camera/Frustum.js +30 -19
  24. package/src/og/camera/PlanetCamera.js +30 -26
  25. package/src/og/control/CompassButton.js +8 -2
  26. package/src/og/control/Control.js +13 -11
  27. package/src/og/control/DebugInfo.js +4 -1
  28. package/src/og/control/EarthCoordinates.js +62 -41
  29. package/src/og/control/EarthNavigation.js +20 -22
  30. package/src/og/control/GeoImageDragControl.js +1 -1
  31. package/src/og/control/KeyboardNavigation.js +12 -12
  32. package/src/og/control/LayerSwitcher.js +24 -23
  33. package/src/og/control/Lighting.js +1 -1
  34. package/src/og/control/MouseNavigation.js +1 -1
  35. package/src/og/control/ScaleControl.js +1 -1
  36. package/src/og/control/SegmentBoundVisualization.js +8 -9
  37. package/src/og/control/ShowFps.js +15 -10
  38. package/src/og/control/SimpleNavigation.js +8 -10
  39. package/src/og/control/Sun.js +25 -15
  40. package/src/og/control/ToggleWireframe.js +5 -5
  41. package/src/og/control/TouchNavigation.js +58 -45
  42. package/src/og/control/ZoomControl.js +41 -25
  43. package/src/og/control/index.js +4 -0
  44. package/src/og/ellipsoid/Ellipsoid.js +181 -85
  45. package/src/og/ellipsoid/wgs84.js +4 -4
  46. package/src/og/entity/BaseBillboard.js +97 -44
  47. package/src/og/entity/Billboard.js +15 -11
  48. package/src/og/entity/BillboardHandler.js +314 -64
  49. package/src/og/entity/Entity.js +106 -74
  50. package/src/og/entity/EntityCollection.js +72 -49
  51. package/src/og/entity/GeoObject.js +228 -0
  52. package/src/og/entity/GeoObjectHandler.js +910 -0
  53. package/src/og/entity/Geometry.js +29 -26
  54. package/src/og/entity/GeometryHandler.js +598 -126
  55. package/src/og/entity/Label.js +74 -40
  56. package/src/og/entity/LabelHandler.js +47 -246
  57. package/src/og/entity/LabelWorker.js +213 -0
  58. package/src/og/entity/Object3d.js +504 -0
  59. package/src/og/entity/PointCloud.js +81 -33
  60. package/src/og/entity/PointCloudHandler.js +9 -9
  61. package/src/og/entity/Polyline.js +39 -39
  62. package/src/og/entity/Ray.js +61 -28
  63. package/src/og/entity/ShapeHandler.js +1 -1
  64. package/src/og/entity/Strip.js +77 -48
  65. package/src/og/entity/StripHandler.js +27 -27
  66. package/src/og/entity/index.js +8 -16
  67. package/src/og/input/KeyboardHandler.js +107 -104
  68. package/src/og/input/MouseHandler.js +81 -78
  69. package/src/og/input/TouchHandler.js +55 -51
  70. package/src/og/layer/BaseGeoImage.js +61 -30
  71. package/src/og/layer/CanvasTiles.js +26 -24
  72. package/src/og/layer/GeoImage.js +10 -10
  73. package/src/og/layer/GeoTexture2d.js +1 -1
  74. package/src/og/layer/GeoVideo.js +3 -3
  75. package/src/og/layer/KML.js +66 -40
  76. package/src/og/layer/Layer.js +27 -17
  77. package/src/og/layer/Material.js +93 -61
  78. package/src/og/layer/Vector.js +118 -72
  79. package/src/og/layer/WMS.js +36 -19
  80. package/src/og/layer/XYZ.js +55 -48
  81. package/src/og/light/LightSource.js +47 -40
  82. package/src/og/math/Line2.js +24 -24
  83. package/src/og/math/Line3.js +103 -102
  84. package/src/og/math/Mat3.js +134 -121
  85. package/src/og/math/Mat4.js +603 -459
  86. package/src/og/math/Plane.js +21 -20
  87. package/src/og/math/Quat.js +980 -927
  88. package/src/og/math/Ray.js +195 -187
  89. package/src/og/math/Vec2.js +127 -117
  90. package/src/og/math/Vec3.js +206 -176
  91. package/src/og/math/Vec4.js +49 -53
  92. package/src/og/math/coder.js +18 -18
  93. package/src/og/math.js +12 -12
  94. package/src/og/mercator.js +11 -11
  95. package/src/og/proj/EPSG3857.js +4 -4
  96. package/src/og/proj/EPSG4326.js +4 -4
  97. package/src/og/proj/Proj.js +31 -31
  98. package/src/og/quadTree/EntityCollectionNode.js +310 -300
  99. package/src/og/quadTree/Node.js +1008 -993
  100. package/src/og/renderer/Renderer.js +768 -747
  101. package/src/og/renderer/RendererEvents.js +9 -6
  102. package/src/og/scene/Axes.js +1 -1
  103. package/src/og/scene/BaseNode.js +8 -9
  104. package/src/og/scene/Planet.js +115 -87
  105. package/src/og/scene/RenderNode.js +29 -22
  106. package/src/og/scene/SkyBox.js +1 -1
  107. package/src/og/segment/Segment.js +1886 -1878
  108. package/src/og/segment/SegmentLonLat.js +298 -268
  109. package/src/og/segment/segmentHelper.js +11 -11
  110. package/src/og/shaders/bloom.js +1 -1
  111. package/src/og/shaders/blur.js +2 -2
  112. package/src/og/shaders/depth.js +1 -1
  113. package/src/og/shaders/geoObject.js +211 -0
  114. package/src/og/shaders/label.js +1 -1
  115. package/src/og/shaders/lumFilter.js +1 -1
  116. package/src/og/shaders/pointCloud.js +42 -42
  117. package/src/og/shaders/screenFrame.js +1 -1
  118. package/src/og/shaders/shape.js +15 -21
  119. package/src/og/shaders/skybox.js +37 -37
  120. package/src/og/shaders/toneMapping.js +1 -1
  121. package/src/og/shapes/BaseShape.js +129 -57
  122. package/src/og/shapes/Icosphere.js +30 -15
  123. package/src/og/shapes/Sphere.js +13 -16
  124. package/src/og/terrain/BilTerrain.js +2 -1
  125. package/src/og/terrain/EmptyTerrain.js +2 -2
  126. package/src/og/terrain/Geoid.js +2 -2
  127. package/src/og/terrain/GlobusTerrain.js +10 -10
  128. package/src/og/terrain/MapboxTerrain.js +1 -1
  129. package/src/og/utils/GeoImageCreator.js +9 -9
  130. package/src/og/utils/Loader.js +6 -6
  131. package/src/og/utils/NormalMapCreator.js +13 -13
  132. package/src/og/utils/TerrainWorker.js +1 -1
  133. package/src/og/utils/TextureAtlas.js +20 -22
  134. package/src/og/utils/VectorTileCreator.js +5 -5
  135. package/src/og/utils/earcut.js +1 -1
  136. package/src/og/utils/shared.js +15 -15
  137. package/src/og/webgl/Framebuffer.js +101 -53
  138. package/src/og/webgl/Handler.js +125 -85
  139. package/src/og/webgl/Multisample.js +55 -27
  140. package/src/og/webgl/Program.js +80 -35
  141. package/src/og/webgl/ProgramController.js +27 -23
  142. package/src/og/webgl/callbacks.js +8 -8
  143. package/types/Clock.d.ts +6 -2
  144. package/types/Deferred.d.ts +1 -1
  145. package/types/Events.d.ts +8 -4
  146. package/types/Extent.d.ts +37 -33
  147. package/types/Globe.d.ts +15 -13
  148. package/types/ImageCanvas.d.ts +5 -3
  149. package/types/LonLat.d.ts +24 -24
  150. package/types/Popup.d.ts +4 -0
  151. package/types/QueueArray.d.ts +6 -2
  152. package/types/Rectangle.d.ts +10 -4
  153. package/types/Stack.d.ts +4 -0
  154. package/types/ajax.d.ts +1 -1
  155. package/types/astro/earth.d.ts +3 -2
  156. package/types/bv/Box.d.ts +10 -5
  157. package/types/bv/Sphere.d.ts +13 -7
  158. package/types/camera/Camera.d.ts +90 -81
  159. package/types/camera/Frustum.d.ts +26 -22
  160. package/types/camera/PlanetCamera.d.ts +49 -53
  161. package/types/control/CompassButton.d.ts +4 -4
  162. package/types/control/Control.d.ts +7 -4
  163. package/types/control/DebugInfo.d.ts +3 -4
  164. package/types/control/EarthCoordinates.d.ts +6 -6
  165. package/types/control/EarthNavigation.d.ts +42 -0
  166. package/types/control/KeyboardNavigation.d.ts +3 -4
  167. package/types/control/LayerSwitcher.d.ts +3 -5
  168. package/types/control/Lighting.d.ts +3 -3
  169. package/types/control/MouseNavigation.d.ts +47 -0
  170. package/types/control/ScaleControl.d.ts +3 -3
  171. package/types/control/ShowFps.d.ts +3 -4
  172. package/types/control/SimpleNavigation.d.ts +3 -6
  173. package/types/control/Sun.d.ts +8 -10
  174. package/types/control/ToggleWireframe.d.ts +3 -3
  175. package/types/control/TouchNavigation.d.ts +48 -0
  176. package/types/control/ZoomControl.d.ts +3 -4
  177. package/types/control/index.d.ts +3 -1
  178. package/types/ellipsoid/Ellipsoid.d.ts +47 -43
  179. package/types/ellipsoid/wgs84.d.ts +3 -2
  180. package/types/entity/BaseBillboard.d.ts +41 -34
  181. package/types/entity/Billboard.d.ts +7 -7
  182. package/types/entity/BillboardHandler.d.ts +4 -0
  183. package/types/entity/Entity.d.ts +101 -83
  184. package/types/entity/EntityCollection.d.ts +57 -43
  185. package/types/entity/GeoObject.d.ts +111 -0
  186. package/types/entity/GeoObjectHandler.d.ts +77 -0
  187. package/types/entity/Geometry.d.ts +9 -7
  188. package/types/entity/GeometryHandler.d.ts +2 -2
  189. package/types/entity/Label.d.ts +24 -29
  190. package/types/entity/LabelHandler.d.ts +9 -2
  191. package/types/entity/LabelWorker.d.ts +9 -0
  192. package/types/entity/PointCloud.d.ts +8 -8
  193. package/types/entity/PointCloudHandler.d.ts +3 -3
  194. package/types/entity/Polyline.d.ts +58 -55
  195. package/types/entity/Ray.d.ts +19 -18
  196. package/types/entity/Strip.d.ts +8 -7
  197. package/types/entity/StripHandler.d.ts +3 -3
  198. package/types/entity/index.d.ts +7 -7
  199. package/types/input/KeyboardHandler.d.ts +10 -0
  200. package/types/input/MouseHandler.d.ts +5 -0
  201. package/types/input/TouchHandler.d.ts +5 -0
  202. package/types/layer/BaseGeoImage.d.ts +23 -35
  203. package/types/layer/CanvasTiles.d.ts +15 -22
  204. package/types/layer/GeoImage.d.ts +5 -18
  205. package/types/layer/GeoVideo.d.ts +5 -30
  206. package/types/layer/KML.d.ts +20 -15
  207. package/types/layer/Layer.d.ts +326 -0
  208. package/types/layer/Material.d.ts +45 -0
  209. package/types/layer/Vector.d.ts +208 -0
  210. package/types/layer/WMS.d.ts +4 -7
  211. package/types/layer/XYZ.d.ts +19 -25
  212. package/types/light/LightSource.d.ts +54 -53
  213. package/types/math/Line2.d.ts +11 -0
  214. package/types/math/Line3.d.ts +10 -0
  215. package/types/math/Mat3.d.ts +30 -18
  216. package/types/math/Mat4.d.ts +71 -52
  217. package/types/math/Plane.d.ts +5 -4
  218. package/types/math/Quat.d.ts +379 -0
  219. package/types/math/Ray.d.ts +82 -0
  220. package/types/math/Vec2.d.ts +102 -101
  221. package/types/math/Vec3.d.ts +143 -142
  222. package/types/math/Vec4.d.ts +40 -39
  223. package/types/math/coder.d.ts +12 -11
  224. package/types/math.d.ts +8 -8
  225. package/types/mercator.d.ts +3 -3
  226. package/types/proj/EPSG3857.d.ts +3 -2
  227. package/types/proj/EPSG4326.d.ts +3 -2
  228. package/types/proj/Proj.d.ts +42 -0
  229. package/types/quadTree/EntityCollectionNode.d.ts +34 -0
  230. package/types/quadTree/Node.d.ts +61 -0
  231. package/types/renderer/Renderer.d.ts +300 -0
  232. package/types/renderer/RendererEvents.d.ts +10 -7
  233. package/types/scene/BaseNode.d.ts +9 -9
  234. package/types/scene/Planet.d.ts +131 -126
  235. package/types/scene/RenderNode.d.ts +22 -23
  236. package/types/segment/Segment.d.ts +279 -0
  237. package/types/segment/SegmentLonLat.d.ts +16 -0
  238. package/types/shaders/geoObject.d.ts +3 -0
  239. package/types/shapes/BaseShape.d.ts +43 -40
  240. package/types/shapes/Sphere.d.ts +7 -7
  241. package/types/terrain/BilTerrain.d.ts +0 -1
  242. package/types/terrain/EmptyTerrain.d.ts +4 -4
  243. package/types/terrain/GlobusTerrain.d.ts +17 -54
  244. package/types/terrain/MapboxTerrain.d.ts +0 -1
  245. package/types/utils/GeoImageCreator.d.ts +3 -2
  246. package/types/utils/TextureAtlas.d.ts +8 -8
  247. package/types/utils/shared.d.ts +25 -24
  248. package/types/webgl/Framebuffer.d.ts +5 -5
  249. package/types/webgl/Handler.d.ts +68 -43
  250. package/types/webgl/Multisample.d.ts +5 -5
  251. package/types/webgl/Program.d.ts +8 -2
  252. package/types/webgl/ProgramController.d.ts +18 -13
  253. package/src/og/inherits.js +0 -8
  254. package/src/og/utils/polylabel.js +0 -176
  255. package/types/inherits.d.ts +0 -4
@@ -2,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.
18
- * @param {Array.<number,number,number,number>} [options.color] - Shape RGBA color.
15
+ * @param {Vec3} [options.position] - Shape position.
16
+ * @param {Quat} [options.orientation] - Shape orientation(rotation).
17
+ * @param {Vec3} [options.scale] - Scale vector.
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,37 +34,39 @@ 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
 
57
55
  /**
58
56
  * Shape RGBA color.
59
57
  * @public
60
- * @type {Array.<number,number,number,number>}
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,28 +157,28 @@ 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
 
164
164
  /**
165
165
  * Assigned picking color.
166
166
  * @protected
167
- * @type {Array.<number,number,number>}
167
+ * @type {Array.<number>} - (exactly 3 entries)
168
168
  */
169
169
  this._pickingColor = [0.0, 0.0, 0.0, 0.0];
170
170
 
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);
@@ -228,7 +227,7 @@ class BaseShape {
228
227
  /**
229
228
  * Sets shape color.
230
229
  * @public
231
- * @param {Array.<number,number,number,number>} color - RGBA color values array.
230
+ * @param {Array.<number>} color - RGBA color values array. (exactly 4 entries)
232
231
  */
233
232
  setColor(color) {
234
233
  this.color[0] = color[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;
@@ -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,18 +2,18 @@
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.
16
- * @param {Array.<number,number,number,number>} [options.color] - Icosphere RGBA color.
13
+ * @param {Vec3} [options.position] - Icosphere position.
14
+ * @param {Quat} [options.orientation] - Icosphere orientation(rotation).
15
+ * @param {Vec3} [options.scale] - Scale vector.
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.
19
19
  * @param {number} [options.size] - Icosphere radius.
@@ -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,18 +2,18 @@
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.
16
- * @param {Array.<number,number,number,number>} [options.color] - Sphere RGBA color.
13
+ * @param {Vec3} [options.position] - Sphere position.
14
+ * @param {Quat} [options.orientation] - Sphere orientation(rotation).
15
+ * @param {Vec3} [options.scale] - Scale vector.
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.
19
19
  * @param {number} [options.radius=100] - Sphere radius.
@@ -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) {
@@ -15,7 +16,7 @@ class BilTerrain extends GlobusTerrain {
15
16
 
16
17
  this.equalizeNormals = true;
17
18
 
18
- this.minZoom = options.minZoom || 3;
19
+ this.minZoom = options.minZoom || 2;
19
20
 
20
21
  this.maxZoom = options.maxZoom || 14;
21
22
 
@@ -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;
@@ -96,7 +96,7 @@ class Geoid {
96
96
  }
97
97
  if ((j > start) && (rawfile[j - 1] === 13)) j--;
98
98
  return String.fromCharCode.apply(null, rawfile.slice(start, j));
99
- };
99
+ }
100
100
 
101
101
  var m, s;
102
102
  for (; ;) {
@@ -237,6 +237,6 @@ class Geoid {
237
237
 
238
238
  return model.offset + model.scale * h;
239
239
  }
240
- };
240
+ }
241
241
 
242
242
  export { Geoid };