@openglobus/og 0.11.6 → 0.12.1

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 (213) hide show
  1. package/css/og.css +5 -2
  2. package/package.json +12 -12
  3. package/src/og/Globe.js +25 -10
  4. package/src/og/Popup.js +3 -2
  5. package/src/og/camera/Camera.js +70 -79
  6. package/src/og/camera/PlanetCamera.js +33 -33
  7. package/src/og/control/DebugInfo.js +2 -2
  8. package/src/og/control/EarthNavigation.js +26 -17
  9. package/src/og/control/Lighting.js +74 -64
  10. package/src/og/control/MouseNavigation.js +30 -29
  11. package/src/og/control/MouseWheelZoomControl.js +257 -0
  12. package/src/og/control/Sun.js +3 -3
  13. package/src/og/control/index.js +2 -0
  14. package/src/og/control/visibleExtent/Segment.js +1862 -0
  15. package/src/og/control/visibleExtent/VisibleExtent.js +80 -0
  16. package/src/og/control/visibleExtent/drawnode.js +751 -0
  17. package/src/og/ellipsoid/Ellipsoid.js +1 -1
  18. package/src/og/entity/BaseBillboard.js +67 -76
  19. package/src/og/entity/BillboardHandler.js +15 -8
  20. package/src/og/entity/Entity.js +742 -742
  21. package/src/og/entity/GeoObjectHandler.js +102 -117
  22. package/src/og/entity/Label.js +45 -48
  23. package/src/og/entity/LabelHandler.js +24 -23
  24. package/src/og/entity/LabelWorker.js +21 -16
  25. package/src/og/layer/CanvasTiles.js +8 -12
  26. package/src/og/layer/GeoImage.js +2 -10
  27. package/src/og/layer/GeoTexture2d.js +2 -10
  28. package/src/og/layer/GeoVideo.js +2 -10
  29. package/src/og/layer/Layer.js +23 -32
  30. package/src/og/layer/Material.js +1 -1
  31. package/src/og/layer/WMS.js +0 -2
  32. package/src/og/layer/XYZ.js +31 -33
  33. package/src/og/math/Vec3.js +18 -2
  34. package/src/og/quadTree/Node.js +52 -111
  35. package/src/og/quadTree/quadTree.js +1 -1
  36. package/src/og/renderer/Renderer.js +85 -122
  37. package/src/og/renderer/RendererEvents.js +44 -22
  38. package/src/og/scene/Planet.js +179 -198
  39. package/src/og/segment/Segment.js +99 -268
  40. package/src/og/segment/Slice.js +45 -0
  41. package/src/og/shaders/drawnode.js +174 -360
  42. package/src/og/shaders/toneMapping.js +1 -0
  43. package/src/og/shapes/BaseShape.js +1 -1
  44. package/src/og/terrain/EmptyTerrain.js +3 -2
  45. package/src/og/terrain/GlobusTerrain.js +2 -0
  46. package/src/og/utils/FontAtlas.js +6 -2
  47. package/src/og/utils/GeoImageCreator.js +5 -1
  48. package/src/og/utils/Loader.js +1 -1
  49. package/src/og/utils/PlainSegmentWorker.js +0 -13
  50. package/src/og/utils/TextureAtlas.js +2 -2
  51. package/src/og/utils/VectorTileCreator.js +1 -3
  52. package/src/og/utils/shared.js +1 -1
  53. package/src/og/webgl/Handler.js +156 -118
  54. package/types/Clock.d.ts +0 -94
  55. package/types/Deferred.d.ts +0 -6
  56. package/types/Events.d.ts +0 -77
  57. package/types/Extent.d.ts +0 -166
  58. package/types/Globe.d.ts +0 -82
  59. package/types/ImageCanvas.d.ts +0 -123
  60. package/types/Lock.d.ts +0 -12
  61. package/types/LonLat.d.ts +0 -108
  62. package/types/Popup.d.ts +0 -42
  63. package/types/QueueArray.d.ts +0 -19
  64. package/types/Rectangle.d.ts +0 -80
  65. package/types/Stack.d.ts +0 -19
  66. package/types/ajax.d.ts +0 -24
  67. package/types/arial.d.ts +0 -48
  68. package/types/astro/astro.d.ts +0 -38
  69. package/types/astro/earth.d.ts +0 -7
  70. package/types/astro/jd.d.ts +0 -254
  71. package/types/bv/Box.d.ts +0 -30
  72. package/types/bv/Sphere.d.ts +0 -38
  73. package/types/bv/index.d.ts +0 -3
  74. package/types/camera/Camera.d.ts +0 -312
  75. package/types/camera/Frustum.d.ts +0 -133
  76. package/types/camera/PlanetCamera.d.ts +0 -218
  77. package/types/camera/index.d.ts +0 -3
  78. package/types/cons.d.ts +0 -40
  79. package/types/control/CompassButton.d.ts +0 -17
  80. package/types/control/Control.d.ts +0 -104
  81. package/types/control/DebugInfo.d.ts +0 -15
  82. package/types/control/EarthCoordinates.d.ts +0 -47
  83. package/types/control/EarthNavigation.d.ts +0 -42
  84. package/types/control/GeoImageDragControl.d.ts +0 -6
  85. package/types/control/KeyboardNavigation.d.ts +0 -21
  86. package/types/control/LayerSwitcher.d.ts +0 -21
  87. package/types/control/Lighting.d.ts +0 -16
  88. package/types/control/MouseNavigation.d.ts +0 -47
  89. package/types/control/ScaleControl.d.ts +0 -22
  90. package/types/control/ShowFps.d.ts +0 -11
  91. package/types/control/SimpleNavigation.d.ts +0 -25
  92. package/types/control/Sun.d.ts +0 -50
  93. package/types/control/ToggleWireframe.d.ts +0 -12
  94. package/types/control/TouchNavigation.d.ts +0 -48
  95. package/types/control/ZoomControl.d.ts +0 -27
  96. package/types/control/index.d.ts +0 -17
  97. package/types/ellipsoid/Ellipsoid.d.ts +0 -146
  98. package/types/ellipsoid/index.d.ts +0 -3
  99. package/types/ellipsoid/wgs84.d.ts +0 -6
  100. package/types/entity/BaseBillboard.d.ts +0 -215
  101. package/types/entity/Billboard.d.ts +0 -94
  102. package/types/entity/BillboardHandler.d.ts +0 -78
  103. package/types/entity/Entity.d.ts +0 -348
  104. package/types/entity/EntityCollection.d.ts +0 -317
  105. package/types/entity/GeoObject.d.ts +0 -111
  106. package/types/entity/GeoObjectHandler.d.ts +0 -77
  107. package/types/entity/Geometry.d.ts +0 -74
  108. package/types/entity/GeometryHandler.d.ts +0 -76
  109. package/types/entity/Label.d.ts +0 -189
  110. package/types/entity/LabelHandler.d.ts +0 -31
  111. package/types/entity/LabelWorker.d.ts +0 -9
  112. package/types/entity/PointCloud.d.ts +0 -174
  113. package/types/entity/PointCloudHandler.d.ts +0 -38
  114. package/types/entity/Polyline.d.ts +0 -306
  115. package/types/entity/PolylineHandler.d.ts +0 -18
  116. package/types/entity/Ray.d.ts +0 -124
  117. package/types/entity/RayHandler.d.ts +0 -67
  118. package/types/entity/ShapeHandler.d.ts +0 -22
  119. package/types/entity/Strip.d.ts +0 -119
  120. package/types/entity/StripHandler.d.ts +0 -38
  121. package/types/entity/index.d.ts +0 -8
  122. package/types/index.core.d.ts +0 -65
  123. package/types/index.d.ts +0 -45
  124. package/types/index.webgl.d.ts +0 -7
  125. package/types/input/KeyboardHandler.d.ts +0 -10
  126. package/types/input/MouseHandler.d.ts +0 -5
  127. package/types/input/TouchHandler.d.ts +0 -5
  128. package/types/input/input.d.ts +0 -34
  129. package/types/layer/BaseGeoImage.d.ts +0 -94
  130. package/types/layer/CanvasTiles.d.ts +0 -68
  131. package/types/layer/GeoImage.d.ts +0 -52
  132. package/types/layer/GeoTexture2d.d.ts +0 -8
  133. package/types/layer/GeoVideo.d.ts +0 -55
  134. package/types/layer/KML.d.ts +0 -63
  135. package/types/layer/Layer.d.ts +0 -326
  136. package/types/layer/Material.d.ts +0 -45
  137. package/types/layer/Vector.d.ts +0 -208
  138. package/types/layer/WMS.d.ts +0 -63
  139. package/types/layer/XYZ.d.ts +0 -120
  140. package/types/layer/index.d.ts +0 -10
  141. package/types/light/LightSource.d.ts +0 -178
  142. package/types/math/Line2.d.ts +0 -11
  143. package/types/math/Line3.d.ts +0 -10
  144. package/types/math/Mat3.d.ts +0 -65
  145. package/types/math/Mat4.d.ts +0 -176
  146. package/types/math/Plane.d.ts +0 -18
  147. package/types/math/Quat.d.ts +0 -379
  148. package/types/math/Ray.d.ts +0 -82
  149. package/types/math/Vec2.d.ts +0 -309
  150. package/types/math/Vec3.d.ts +0 -460
  151. package/types/math/Vec4.d.ts +0 -162
  152. package/types/math/coder.d.ts +0 -43
  153. package/types/math/index.d.ts +0 -11
  154. package/types/math.d.ts +0 -261
  155. package/types/mercator.d.ts +0 -92
  156. package/types/proj/EPSG3857.d.ts +0 -6
  157. package/types/proj/EPSG4326.d.ts +0 -6
  158. package/types/proj/Proj.d.ts +0 -42
  159. package/types/quadTree/EntityCollectionNode.d.ts +0 -34
  160. package/types/quadTree/Node.d.ts +0 -61
  161. package/types/quadTree/quadTree.d.ts +0 -40
  162. package/types/renderer/Renderer.d.ts +0 -300
  163. package/types/renderer/RendererEvents.d.ts +0 -233
  164. package/types/res/images.d.ts +0 -3
  165. package/types/scene/Axes.d.ts +0 -11
  166. package/types/scene/BaseNode.d.ts +0 -60
  167. package/types/scene/Planet.d.ts +0 -577
  168. package/types/scene/RenderNode.d.ts +0 -142
  169. package/types/scene/SkyBox.d.ts +0 -10
  170. package/types/scene/index.d.ts +0 -4
  171. package/types/segment/Segment.d.ts +0 -279
  172. package/types/segment/SegmentLonLat.d.ts +0 -16
  173. package/types/segment/segmentHelper.d.ts +0 -13
  174. package/types/shaders/billboard.d.ts +0 -3
  175. package/types/shaders/depth.d.ts +0 -2
  176. package/types/shaders/drawnode.d.ts +0 -7
  177. package/types/shaders/geoObject.d.ts +0 -3
  178. package/types/shaders/label.d.ts +0 -4
  179. package/types/shaders/pointCloud.d.ts +0 -2
  180. package/types/shaders/polyline.d.ts +0 -3
  181. package/types/shaders/ray.d.ts +0 -2
  182. package/types/shaders/screenFrame.d.ts +0 -2
  183. package/types/shaders/shape.d.ts +0 -4
  184. package/types/shaders/skybox.d.ts +0 -2
  185. package/types/shaders/toneMapping.d.ts +0 -2
  186. package/types/shapes/BaseShape.d.ts +0 -250
  187. package/types/shapes/Sphere.d.ts +0 -41
  188. package/types/terrain/BilTerrain.d.ts +0 -7
  189. package/types/terrain/EmptyTerrain.d.ts +0 -72
  190. package/types/terrain/Geoid.d.ts +0 -26
  191. package/types/terrain/GlobusTerrain.d.ts +0 -116
  192. package/types/terrain/MapboxTerrain.d.ts +0 -7
  193. package/types/terrain/index.d.ts +0 -5
  194. package/types/utils/FontAtlas.d.ts +0 -14
  195. package/types/utils/GeoImageCreator.d.ts +0 -30
  196. package/types/utils/ImagesCacheManager.d.ts +0 -10
  197. package/types/utils/Loader.d.ts +0 -25
  198. package/types/utils/NormalMapCreator.d.ts +0 -39
  199. package/types/utils/PlainSegmentWorker.d.ts +0 -10
  200. package/types/utils/TerrainWorker.d.ts +0 -9
  201. package/types/utils/TextureAtlas.d.ts +0 -111
  202. package/types/utils/VectorTileCreator.d.ts +0 -16
  203. package/types/utils/colorTable.d.ts +0 -143
  204. package/types/utils/earcut.d.ts +0 -6
  205. package/types/utils/shared.d.ts +0 -231
  206. package/types/webgl/Framebuffer.d.ts +0 -135
  207. package/types/webgl/Handler.d.ts +0 -397
  208. package/types/webgl/Multisample.d.ts +0 -89
  209. package/types/webgl/Program.d.ts +0 -161
  210. package/types/webgl/ProgramController.d.ts +0 -89
  211. package/types/webgl/callbacks.d.ts +0 -1
  212. package/types/webgl/index.d.ts +0 -6
  213. package/types/webgl/types.d.ts +0 -2
package/css/og.css CHANGED
@@ -50,7 +50,7 @@
50
50
  height: 19px;
51
51
  position: absolute;
52
52
  background-color: rgba(22, 76, 155, 1) !important;
53
- z-index: 12000;
53
+ z-index: 35000;
54
54
  }
55
55
 
56
56
  .ogAttribution {
@@ -153,7 +153,7 @@
153
153
  right: 0px;
154
154
  width: 17em;
155
155
  background-color: rgba(22, 76, 155, 0.4);
156
- z-index: 5000;
156
+ z-index: 25000;
157
157
  padding: 0 0 0 10px;
158
158
  font-family: "Segoe UI", Frutiger, "Frutiger Linotype", "Dejavu Sans", "Helvetica Neue", Arial, sans-serif;
159
159
  border-radius: 2px;
@@ -261,6 +261,8 @@
261
261
  text-shadow: 0px 0px 3px #616161;
262
262
  padding: 10px;
263
263
  pointer-events: none;
264
+ transform: scale(1.0);
265
+ transform-origin: top left;
264
266
  }
265
267
 
266
268
  .og-debug-info .og-watch-line {
@@ -448,6 +450,7 @@
448
450
 
449
451
  .og-lighing .og-value {
450
452
  float: left;
453
+ width: 50px;
451
454
  }
452
455
 
453
456
  .og-lighing #layers {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.11.6",
3
+ "version": "0.12.1",
4
4
  "description": "[OpenGlobus](http://www.openglobus.org/) is a javascript library designed to display interactive 3d maps and planets with map tiles, imagery and vector data, markers and 3d objects. It uses the WebGL technology, open source and completely free.",
5
5
  "directories": {
6
6
  "example": "./sandbox"
@@ -17,7 +17,7 @@
17
17
  "test": "jest --env=jsdom",
18
18
  "test_watch": "jest --env=jsdom --watch",
19
19
  "lint": "eslint src/og",
20
- "generate_types": "rm -rf types; tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly --outDir types; exit 0",
20
+ "generate_types": "rm -rf types; tsc src/**/*.js --declaration --allowJs --emitDeclarationOnly --outDir types",
21
21
  "compile_js_as_ts": "tsc src/og/index.js --AllowJs --checkJs --outDir dist/@openglobus/src/"
22
22
  },
23
23
  "repository": {
@@ -43,24 +43,24 @@
43
43
  "./css/og.css": "./css/og.css"
44
44
  },
45
45
  "devDependencies": {
46
- "@babel/preset-env": "^7.16.0",
46
+ "@babel/preset-env": "^7.16.8",
47
47
  "@rollup/plugin-json": "^4.1.0",
48
- "@types/jest": "^27.0.2",
49
- "eslint": "^8.2.0",
48
+ "@types/jest": "^27.4.0",
49
+ "eslint": "^8.6.0",
50
50
  "jaguarjs-jsdoc": "^1.1.0",
51
- "jest": "^27.3.1",
51
+ "jest": "^27.4.7",
52
52
  "jest-canvas-mock": "^2.3.1",
53
53
  "jest-webgl-canvas-mock": "^0.2.3",
54
54
  "jsdoc": "^3.6.7",
55
- "lint-staged": "^11.2.6",
55
+ "lint-staged": "^12.1.7",
56
56
  "local-web-server": "^5.1.1",
57
57
  "msdf-bmfont-xml": "^2.5.4",
58
- "postcss": "^8.3.11",
59
- "prettier": "^2.4.1",
60
- "rollup": "^2.60.0",
61
- "rollup-plugin-postcss": "^4.0.1",
58
+ "postcss": "^8.4.5",
59
+ "prettier": "^2.5.1",
60
+ "rollup": "^2.63.0",
61
+ "rollup-plugin-postcss": "^4.0.2",
62
62
  "rollup-plugin-terser": "^7.0.2",
63
- "typescript": "^4.4.4"
63
+ "typescript": "^4.5.4"
64
64
  },
65
65
  "lint-staged": {
66
66
  "*.{js,ts}": [
package/src/og/Globe.js CHANGED
@@ -16,7 +16,7 @@ import { Renderer } from "./renderer/Renderer.js";
16
16
  import { Planet } from "./scene/Planet.js";
17
17
  import { EmptyTerrain } from "./terrain/EmptyTerrain.js";
18
18
  import { isEmpty } from "./utils/shared.js";
19
- import { Handler } from "./webgl/Handler.js";
19
+ import { Handler } from "./webgl/Handler.js";
20
20
 
21
21
  /** @const {string} */
22
22
  const CANVAS_ID_PREFIX = "globus_viewport_";
@@ -60,10 +60,13 @@ const PLANET_NAME_PREFIX = "globus_planet_";
60
60
  * @param {DOMElement} [options.attributionContainer] - Container for attribution list.
61
61
  * @param {Number} [options.maxGridSize] = Maximal segment grid size. 128 is default
62
62
  * @param {boolean} [options.useSpecularTexture] - use specular water mask
63
- * @param {boolean} [options.useNightTexture] - show night cities
64
- * @param {Number} [options.maxEqualZoomAltitude=850000.0] - Maximal altitude since segments on the screen bacame the same zoom level
63
+ * @param {boolean} [options.useNightTexture] - show night cities
64
+ * @param {Number} [options.maxAltitude=15000000.0] - Maximal camera altitude above terrain
65
+ * @param {Number} [options.minAltitude=1.0] - Minimal camera altitude above terrain
66
+ * @param {Number} [options.maxEqualZoomAltitude=15000000.0] - Maximal altitude since segments on the screen bacame the same zoom level
65
67
  * @param {Number} [options.minEqualZoomAltitude=10000.0] - Minimal altitude since segments on the screen bacame the same zoom level
66
68
  * @param {Number} [options.minEqualZoomCameraSlope=0.8] - Minimal camera slope above te globe where segments on the screen bacame the same zoom level
69
+ * @param {Number} [options.loadingBatchSize=12] -
67
70
  */
68
71
 
69
72
  class Globe {
@@ -95,7 +98,16 @@ class Globe {
95
98
  }
96
99
 
97
100
  this.div.appendChild(this._canvas);
98
- this.div.classList.add("ogViewport");
101
+ this.div.classList.add("ogViewport");
102
+
103
+ document.addEventListener("visibilitychange", () => {
104
+ if (document.visibilityState === 'visible') {
105
+ this.renderer.handler.start();
106
+ this.renderer && this.renderer.resize();
107
+ } else {
108
+ this.renderer.handler.stop();
109
+ }
110
+ });
99
111
 
100
112
  function _disableWheel(e) {
101
113
  e.preventDefault();
@@ -117,7 +129,8 @@ class Globe {
117
129
  * @type {Renderer}
118
130
  */
119
131
  this.renderer = new Renderer(
120
- new Handler(_canvasId, {
132
+ new Handler(_canvasId, {
133
+ pixelRatio: window.devicePixelRatio + 0.15,
121
134
  context: {
122
135
  alpha: false,
123
136
  antialias: false,
@@ -159,16 +172,18 @@ class Globe {
159
172
  // TODO:
160
173
  } else {
161
174
  this.planet = new Planet({
162
- name: this._planetName,
175
+ name: this._planetName,
176
+ frustums: options.frustums,
163
177
  ellipsoid: options.ellipsoid,
164
178
  maxGridSize: options.maxGridSize,
165
179
  useNightTexture: options.useNightTexture,
166
180
  useSpecularTexture: options.useSpecularTexture,
167
181
  minAltitude: options.minAltitude,
168
- maxAltitude: options.maxAltitude,
182
+ maxAltitude: options.maxAltitude || 15000000,
169
183
  maxEqualZoomAltitude: options.maxEqualZoomAltitude,
170
184
  minEqualZoomAltitude: options.minEqualZoomAltitude,
171
- minEqualZoomCameraSlope: options.minEqualZoomCameraSlope
185
+ minEqualZoomCameraSlope: options.minEqualZoomCameraSlope,
186
+ loadingBatchSize: options.loadingBatchSize
172
187
  });
173
188
  }
174
189
 
@@ -190,8 +205,8 @@ class Globe {
190
205
  options.useEarthNavigation
191
206
  ? new EarthNavigation()
192
207
  : new MouseNavigation({
193
- minSlope: options.minSlope
194
- }),
208
+ minSlope: options.minSlope
209
+ }),
195
210
  new TouchNavigation(),
196
211
  new EarthCoordinates(),
197
212
  new ScaleControl(),
package/src/og/Popup.js CHANGED
@@ -74,11 +74,12 @@ class Popup {
74
74
 
75
75
  setScreen(p) {
76
76
  if (this._planet) {
77
+ let r = this._planet.renderer.handler.pixelRatio;
77
78
  this.el.style.transform =
78
79
  "translate(" +
79
- (p.x - this.clientWidth * 0.5) +
80
+ (p.x / r - this.clientWidth * 0.5) +
80
81
  "px, " +
81
- (p.y - this._planet.renderer.handler.canvas.height - this._tipEl.clientHeight) +
82
+ (p.y / r - this._planet.renderer.handler.canvas.clientHeight - this._tipEl.clientHeight) +
82
83
  "px)";
83
84
  }
84
85
  }
@@ -98,26 +98,26 @@ class Camera {
98
98
  * @protected
99
99
  * @type {Vec3}
100
100
  */
101
- this._u = new Vec3(0.0, 1.0, 0.0); // up x n
101
+ this._r = new Vec3(1.0, 0.0, 0.0); // up x n
102
102
 
103
103
  /**
104
104
  * Camera up vector.
105
105
  * @protected
106
106
  * @type {Vec3}
107
107
  */
108
- this._v = new Vec3(1.0, 0.0, 0.0); // n x u - UP
108
+ this._u = new Vec3(0.0, 1.0, 0.0); // n x u - UP
109
109
 
110
110
  /**
111
111
  * Camera forward vector.
112
112
  * @protected
113
113
  * @type {Vec3}
114
114
  */
115
- this._n = new Vec3(0.0, 0.0, 1.0); // eye - look - FORWARD
115
+ this._b = new Vec3(0.0, 0.0, 1.0); // eye - look - FORWARD
116
116
 
117
117
  // Previous frame values
118
- this._pu = this._u.clone();
119
- this._pv = this._v.clone();
120
- this._pn = this._n.clone();
118
+ this._pu = this._r.clone();
119
+ this._pv = this._u.clone();
120
+ this._pn = this._b.clone();
121
121
  this._peye = this.eye.clone();
122
122
  this.isMoved = false;
123
123
 
@@ -173,9 +173,9 @@ class Camera {
173
173
  }
174
174
 
175
175
  checkMoveEnd() {
176
- var u = this._u,
177
- v = this._v,
178
- n = this._n,
176
+ var u = this._r,
177
+ v = this._u,
178
+ n = this._b,
179
179
  eye = this.eye;
180
180
 
181
181
  if (this._peye.equal(eye) && this._pu.equal(u) && this._pv.equal(v) && this._pn.equal(n)) {
@@ -216,27 +216,27 @@ class Camera {
216
216
  }
217
217
 
218
218
  getUp() {
219
- return this._v.clone();
219
+ return this._u.clone();
220
220
  }
221
221
 
222
222
  getDown() {
223
- return this._v.negateTo();
223
+ return this._u.negateTo();
224
224
  }
225
225
 
226
226
  getRight() {
227
- return this._u.clone();
227
+ return this._r.clone();
228
228
  }
229
229
 
230
230
  getLeft() {
231
- return this._u.negateTo();
231
+ return this._r.negateTo();
232
232
  }
233
233
 
234
234
  getForward() {
235
- return this._n.negateTo();
235
+ return this._b.negateTo();
236
236
  }
237
237
 
238
238
  getBackward() {
239
- return this._n.clone();
239
+ return this._b.clone();
240
240
  }
241
241
 
242
242
  /**
@@ -245,9 +245,9 @@ class Camera {
245
245
  * @virtual
246
246
  */
247
247
  update() {
248
- var u = this._u,
249
- v = this._v,
250
- n = this._n,
248
+ var u = this._r,
249
+ v = this._u,
250
+ n = this._b,
251
251
  eye = this.eye;
252
252
 
253
253
  Vec3.doubleToTwoFloat32Array(eye, this.eyeHigh, this.eyeLow);
@@ -321,12 +321,7 @@ class Camera {
321
321
  this._tanViewAngle_hradOneByHeight =
322
322
  this._tanViewAngle_hrad * this.renderer.handler._oneByHeight;
323
323
  var c = this.renderer.handler.canvas;
324
- this._projSizeConst =
325
- Math.min(
326
- c.clientWidth < 256 ? 256 : c.clientWidth,
327
- c.clientHeight < 256 ? 256 : c.clientHeight
328
- ) /
329
- (angle * math.RADIANS);
324
+ this._projSizeConst = Math.min(c.clientWidth < 256 ? 256 : c.clientWidth, c.clientHeight < 256 ? 256 : c.clientHeight) / (angle * math.RADIANS);
330
325
  for (let i = 0, len = this.frustums.length; i < len; i++) {
331
326
  this.frustums[i].setProjectionMatrix(
332
327
  angle,
@@ -368,15 +363,15 @@ class Camera {
368
363
  this.eye.x = eye.x;
369
364
  this.eye.y = eye.y;
370
365
  this.eye.z = eye.z;
371
- look = look || this._n;
372
- up = up || this._v;
373
- this._n.x = eye.x - look.x;
374
- this._n.y = eye.y - look.y;
375
- this._n.z = eye.z - look.z;
376
- this._u.copy(up.cross(this._n));
377
- this._n.normalize();
378
- this._u.normalize();
379
- this._v.copy(this._n.cross(this._u));
366
+ look = look || this._b;
367
+ up = up || this._u;
368
+ this._b.x = eye.x - look.x;
369
+ this._b.y = eye.y - look.y;
370
+ this._b.z = eye.z - look.z;
371
+ this._r.copy(up.cross(this._b));
372
+ this._b.normalize();
373
+ this._r.normalize();
374
+ this._u.copy(this._b.cross(this._r));
380
375
  return this;
381
376
  }
382
377
 
@@ -384,14 +379,14 @@ class Camera {
384
379
  * Sets camera look point
385
380
  * @public
386
381
  * @param {Vec3} look - Look point
387
- * @param {Vec3} [up] - Camera up vector otherwise camera current up vector(this._v)
382
+ * @param {Vec3} [up] - Camera up vector otherwise camera current up vector(this._u)
388
383
  */
389
384
  look(look, up) {
390
- this._n.set(this.eye.x - look.x, this.eye.y - look.y, this.eye.z - look.z);
391
- this._u.copy((up || this._v).cross(this._n));
392
- this._n.normalize();
393
- this._u.normalize();
394
- this._v.copy(this._n.cross(this._u));
385
+ this._b.set(this.eye.x - look.x, this.eye.y - look.y, this.eye.z - look.z);
386
+ this._r.copy((up || this._u).cross(this._b));
387
+ this._b.normalize();
388
+ this._r.normalize();
389
+ this._u.copy(this._b.cross(this._r));
395
390
  }
396
391
 
397
392
  /**
@@ -402,9 +397,9 @@ class Camera {
402
397
  * @param {number} dn - delta Z
403
398
  */
404
399
  slide(du, dv, dn) {
405
- this.eye.x += du * this._u.x + dv * this._v.x + dn * this._n.x;
406
- this.eye.y += du * this._u.y + dv * this._v.y + dn * this._n.y;
407
- this.eye.z += du * this._u.z + dv * this._v.z + dn * this._n.z;
400
+ this.eye.x += du * this._r.x + dv * this._u.x + dn * this._b.x;
401
+ this.eye.y += du * this._r.y + dv * this._u.y + dn * this._b.y;
402
+ this.eye.z += du * this._r.z + dv * this._u.z + dn * this._b.z;
408
403
  }
409
404
 
410
405
  /**
@@ -415,16 +410,16 @@ class Camera {
415
410
  roll(angle) {
416
411
  var cs = Math.cos(math.RADIANS * angle);
417
412
  var sn = Math.sin(math.RADIANS * angle);
418
- var t = this._u.clone();
419
- this._u.set(
420
- cs * t.x - sn * this._v.x,
421
- cs * t.y - sn * this._v.y,
422
- cs * t.z - sn * this._v.z
413
+ var t = this._r.clone();
414
+ this._r.set(
415
+ cs * t.x - sn * this._u.x,
416
+ cs * t.y - sn * this._u.y,
417
+ cs * t.z - sn * this._u.z
423
418
  );
424
- this._v.set(
425
- sn * t.x + cs * this._v.x,
426
- sn * t.y + cs * this._v.y,
427
- sn * t.z + cs * this._v.z
419
+ this._u.set(
420
+ sn * t.x + cs * this._u.x,
421
+ sn * t.y + cs * this._u.y,
422
+ sn * t.z + cs * this._u.z
428
423
  );
429
424
  }
430
425
 
@@ -436,16 +431,16 @@ class Camera {
436
431
  pitch(angle) {
437
432
  var cs = Math.cos(math.RADIANS * angle);
438
433
  var sn = Math.sin(math.RADIANS * angle);
439
- var t = this._n.clone();
440
- this._n.set(
441
- cs * t.x - sn * this._v.x,
442
- cs * t.y - sn * this._v.y,
443
- cs * t.z - sn * this._v.z
434
+ var t = this._b.clone();
435
+ this._b.set(
436
+ cs * t.x - sn * this._u.x,
437
+ cs * t.y - sn * this._u.y,
438
+ cs * t.z - sn * this._u.z
444
439
  );
445
- this._v.set(
446
- sn * t.x + cs * this._v.x,
447
- sn * t.y + cs * this._v.y,
448
- sn * t.z + cs * this._v.z
440
+ this._u.set(
441
+ sn * t.x + cs * this._u.x,
442
+ sn * t.y + cs * this._u.y,
443
+ sn * t.z + cs * this._u.z
449
444
  );
450
445
  }
451
446
 
@@ -457,16 +452,16 @@ class Camera {
457
452
  yaw(angle) {
458
453
  var cs = Math.cos(math.RADIANS * angle);
459
454
  var sn = Math.sin(math.RADIANS * angle);
460
- var t = this._u.clone();
461
- this._u.set(
462
- cs * t.x - sn * this._n.x,
463
- cs * t.y - sn * this._n.y,
464
- cs * t.z - sn * this._n.z
455
+ var t = this._r.clone();
456
+ this._r.set(
457
+ cs * t.x - sn * this._b.x,
458
+ cs * t.y - sn * this._b.y,
459
+ cs * t.z - sn * this._b.z
465
460
  );
466
- this._n.set(
467
- sn * t.x + cs * this._n.x,
468
- sn * t.y + cs * this._n.y,
469
- sn * t.z + cs * this._n.z
461
+ this._b.set(
462
+ sn * t.x + cs * this._b.x,
463
+ sn * t.y + cs * this._b.y,
464
+ sn * t.z + cs * this._b.z
470
465
  );
471
466
  }
472
467
 
@@ -485,12 +480,8 @@ class Camera {
485
480
  var px = (x - w) / w,
486
481
  py = -(y - h) / h;
487
482
 
488
- var world1 = this.frustums[0]._inverseProjectionViewMatrix
489
- .mulVec4(new Vec4(px, py, -1.0, 1.0))
490
- .affinity(),
491
- world2 = this.frustums[0]._inverseProjectionViewMatrix
492
- .mulVec4(new Vec4(px, py, 0.0, 1.0))
493
- .affinity();
483
+ var world1 = this.frustums[0]._inverseProjectionViewMatrix.mulVec4(new Vec4(px, py, -1.0, 1.0)).affinity(),
484
+ world2 = this.frustums[0]._inverseProjectionViewMatrix.mulVec4(new Vec4(px, py, 0.0, 1.0)).affinity();
494
485
 
495
486
  return world2.subA(world1).toVec3().normalize();
496
487
  }
@@ -520,16 +511,16 @@ class Camera {
520
511
  center = center || Vec3.ZERO;
521
512
  up = up || Vec3.UP;
522
513
 
523
- var rot = new Mat4().setRotation(isArc ? this._v : up, angle);
514
+ var rot = new Mat4().setRotation(isArc ? this._u : up, angle);
524
515
  var tr = new Mat4().setIdentity().translate(center);
525
516
  var ntr = new Mat4().setIdentity().translate(center.negateTo());
526
517
 
527
518
  var trm = tr.mul(rot).mul(ntr);
528
519
 
529
520
  this.eye = trm.mulVec3(this.eye);
530
- this._v = rot.mulVec3(this._v).normalize();
531
521
  this._u = rot.mulVec3(this._u).normalize();
532
- this._n = rot.mulVec3(this._n).normalize();
522
+ this._r = rot.mulVec3(this._r).normalize();
523
+ this._b = rot.mulVec3(this._b).normalize();
533
524
  }
534
525
 
535
526
  /**
@@ -551,7 +542,7 @@ class Camera {
551
542
  * @param {Vec3} center - Point that the camera rotates around.
552
543
  */
553
544
  rotateVertical(angle, center) {
554
- this.rotateAround(angle, false, center, this._u);
545
+ this.rotateAround(angle, false, center, this._r);
555
546
  }
556
547
 
557
548
  /**
@@ -36,20 +36,15 @@ class PlanetCamera extends Camera {
36
36
  * @param {Object} [options] - Planet camera options:
37
37
  */
38
38
  constructor(planet, options) {
39
- super(
40
- planet.renderer,
41
- Object.assign(
42
- {},
43
- {
44
- frustums: /*[[100, 10000000]]*/ [
45
- [1, 100 + 0.075],
46
- [100, 1000 + 0.075],
47
- [1000, 1e6 + 10000],
48
- [1e6, 1e9]
49
- ] //[[1, 1e3 + 100], [1e3, 1e6 + 10000], [1e6, 1e9]]*/
50
- },
51
- options
52
- )
39
+ super(planet.renderer, {
40
+ frustums: [
41
+ [1, 100 + 0.075],
42
+ [100, 1000 + 0.075],
43
+ [1000, 1e6 + 10000],
44
+ [1e6, 1e9]
45
+ ], //[[1, 1e3 + 100], [1e3, 1e6 + 10000], [1e6, 1e9]]*/
46
+ ...options
47
+ }
53
48
  );
54
49
  /**
55
50
  * Assigned camera's planet.
@@ -144,7 +139,7 @@ class PlanetCamera extends Camera {
144
139
  super.update();
145
140
  this.updateGeodeticPosition();
146
141
  this.eyeNorm = this.eye.normal();
147
- this.slope = this._n.dot(this.eyeNorm);
142
+ this.slope = this._b.dot(this.eyeNorm);
148
143
  this.events.dispatch(this.events.viewchange, this);
149
144
  }
150
145
 
@@ -387,8 +382,8 @@ class PlanetCamera extends Camera {
387
382
  var ground_a = this.planet.ellipsoid.lonLatToCartesian(
388
383
  new LonLat(this._lonLat.lon, this._lonLat.lat)
389
384
  );
390
- var v_a = this._v,
391
- n_a = this._n;
385
+ var v_a = this._u,
386
+ n_a = this._b;
392
387
 
393
388
  var lonlat_b = this.planet.ellipsoid.cartesianToLonLat(cartesian);
394
389
  var up_b = up || Vec3.UP;
@@ -543,18 +538,18 @@ class PlanetCamera extends Camera {
543
538
  }
544
539
 
545
540
  rotateVertical(angle, center, minSlope = 0) {
546
- var rot = new Mat4().setRotation(this._u, angle);
541
+ var rot = new Mat4().setRotation(this._r, angle);
547
542
  var tr = new Mat4().setIdentity().translate(center);
548
543
  var ntr = new Mat4().setIdentity().translate(center.negateTo());
549
544
  var trm = tr.mul(rot).mul(ntr);
550
545
 
551
546
  let eye = trm.mulVec3(this.eye);
552
- let v = rot.mulVec3(this._v).normalize();
553
547
  let u = rot.mulVec3(this._u).normalize();
554
- let n = rot.mulVec3(this._n).normalize();
548
+ let r = rot.mulVec3(this._r).normalize();
549
+ let b = rot.mulVec3(this._b).normalize();
555
550
 
556
551
  let eyeNorm = eye.normal();
557
- let slope = n.dot(eyeNorm);
552
+ let slope = b.dot(eyeNorm);
558
553
 
559
554
  if (minSlope) {
560
555
  let dSlope = slope - this.slope;
@@ -562,20 +557,20 @@ class PlanetCamera extends Camera {
562
557
  if (slope < minSlope && dSlope < 0) return;
563
558
 
564
559
  if (
565
- (slope > 0.1 && v.dot(eyeNorm) > 0) ||
560
+ (slope > 0.1 && u.dot(eyeNorm) > 0) ||
566
561
  this.slope <= 0.1 ||
567
- this._v.dot(this.eye.normal()) <= 0.0
562
+ this._u.dot(this.eye.normal()) <= 0.0
568
563
  ) {
569
564
  this.eye = eye;
570
- this._v = v;
571
565
  this._u = u;
572
- this._n = n;
566
+ this._r = r;
567
+ this._b = b;
573
568
  }
574
569
  } else {
575
570
  this.eye = eye;
576
- this._v = v;
577
571
  this._u = u;
578
- this._n = n;
572
+ this._r = r;
573
+ this._b = b;
579
574
  }
580
575
  }
581
576
 
@@ -592,9 +587,9 @@ class PlanetCamera extends Camera {
592
587
  this.planet._normalMapCreator.lock(this._keyLock);
593
588
 
594
589
  this.eye = this._framesArr[c].eye;
595
- this._u = this._framesArr[c].u;
596
- this._v = this._framesArr[c].v;
597
- this._n = this._framesArr[c].n;
590
+ this._r = this._framesArr[c].u;
591
+ this._u = this._framesArr[c].v;
592
+ this._b = this._framesArr[c].n;
598
593
 
599
594
  if (this._frameCallback) {
600
595
  this._frameCallback();
@@ -636,15 +631,20 @@ class PlanetCamera extends Camera {
636
631
  getHeading() {
637
632
  let u = this.eye.normal();
638
633
  let f = Vec3.proj_b_to_plane(
639
- this.slope >= 0.97 ? this.getUp() : this.getForward(),
640
- u
641
- ).normalize(),
634
+ this.slope >= 0.97 ? this.getUp() : this.getForward(),
635
+ u
636
+ ).normalize(),
642
637
  n = Vec3.proj_b_to_plane(Vec3.UP, u).normalize();
643
638
  let res = Math.sign(u.dot(f.cross(n))) * Math.acos(f.dot(n)) * math.DEGREES;
644
639
  if (res < 0.0) {
645
640
  return 360.0 + res;
646
641
  }
647
642
  return res;
643
+ }
644
+
645
+ isVisible(poi) {
646
+ let e = this.eye.length();
647
+ return this.eye.distance(poi) < Math.sqrt(e * e - this.planet.ellipsoid._a2);
648
648
  }
649
649
  }
650
650
 
@@ -93,8 +93,8 @@ class DebugInfo extends Control {
93
93
  frame: () => p.camera.slope.toFixed(3)
94
94
  },
95
95
  {
96
- label: "lodRatio",
97
- frame: () => p._lodRatio.toFixed(3)
96
+ label: "lodSize",
97
+ frame: () => Math.round(p.lodSize)
98
98
  },
99
99
  {
100
100
  label: "deltaTime/FPS",