@openglobus/og 0.12.4 → 0.13.2

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 (93) hide show
  1. package/README.md +0 -2
  2. package/dist/@openglobus/og.esm.js +2 -2
  3. package/dist/@openglobus/og.esm.js.map +1 -1
  4. package/dist/@openglobus/og.umd.js +2 -2
  5. package/dist/@openglobus/og.umd.js.map +1 -1
  6. package/package.json +7 -7
  7. package/src/og/Extent.js +3 -3
  8. package/src/og/Globe.js +277 -275
  9. package/src/og/ImageCanvas.js +3 -3
  10. package/src/og/LonLat.js +9 -9
  11. package/src/og/QueueArray.js +2 -2
  12. package/src/og/Rectangle.js +5 -5
  13. package/src/og/bv/Box.js +1 -1
  14. package/src/og/bv/Sphere.js +2 -2
  15. package/src/og/camera/Camera.js +1 -1
  16. package/src/og/camera/PlanetCamera.js +649 -646
  17. package/src/og/control/LayerSwitcher.js +1 -1
  18. package/src/og/control/MouseNavigation.js +22 -13
  19. package/src/og/control/MouseWheelZoomControl.js +2 -2
  20. package/src/og/control/ScaleControl.js +1 -1
  21. package/src/og/control/TouchNavigation.js +319 -319
  22. package/src/og/control/ZoomControl.js +132 -132
  23. package/src/og/control/visibleExtent/Segment.js +12 -12
  24. package/src/og/ellipsoid/Ellipsoid.js +577 -567
  25. package/src/og/entity/BillboardHandler.js +878 -1051
  26. package/src/og/entity/Entity.js +1 -1
  27. package/src/og/entity/EntityCollection.js +847 -857
  28. package/src/og/entity/GeoObjectHandler.js +2 -2
  29. package/src/og/entity/LabelHandler.js +887 -1040
  30. package/src/og/entity/LabelWorker.js +0 -6
  31. package/src/og/entity/PointCloud.js +495 -495
  32. package/src/og/entity/Polyline.js +2218 -2222
  33. package/src/og/entity/RayHandler.js +1 -1
  34. package/src/og/layer/CanvasTiles.js +6 -3
  35. package/src/og/layer/GeoImage.js +1 -1
  36. package/src/og/layer/KML.js +5 -5
  37. package/src/og/layer/Layer.js +800 -752
  38. package/src/og/layer/Vector.js +997 -1010
  39. package/src/og/layer/XYZ.js +359 -357
  40. package/src/og/math/Line2.js +4 -4
  41. package/src/og/math/Quat.js +2 -2
  42. package/src/og/math/Ray.js +2 -2
  43. package/src/og/math/Vec2.js +524 -524
  44. package/src/og/math/Vec3.js +900 -900
  45. package/src/og/math/Vec4.js +261 -261
  46. package/src/og/math.js +397 -398
  47. package/src/og/quadTree/EntityCollectionNode.js +389 -387
  48. package/src/og/renderer/Renderer.js +14 -20
  49. package/src/og/renderer/RendererEvents.js +1034 -1045
  50. package/src/og/scene/Planet.js +12 -9
  51. package/src/og/scene/RenderNode.js +347 -354
  52. package/src/og/segment/Segment.js +3 -1
  53. package/src/og/segment/SegmentLonLat.js +1 -4
  54. package/src/og/shaders/billboard.js +220 -204
  55. package/src/og/shaders/drawnode.js +607 -603
  56. package/src/og/shaders/label.js +576 -456
  57. package/src/og/shaders/polyline.js +365 -361
  58. package/src/og/terrain/MapboxTerrain.js +1 -1
  59. package/src/og/utils/FontAtlas.js +209 -200
  60. package/src/og/utils/GeoImageCreator.js +4 -5
  61. package/src/og/utils/TextureAtlas.js +4 -4
  62. package/src/og/utils/VectorTileCreator.js +414 -414
  63. package/src/og/utils/shared.js +1 -1
  64. package/src/og/webgl/Handler.js +28 -60
  65. package/src/og/webgl/Multisample.js +260 -260
  66. package/src/og/webgl/Program.js +411 -396
  67. package/types/bv/Box.d.ts +1 -1
  68. package/types/bv/Sphere.d.ts +1 -1
  69. package/types/camera/PlanetCamera.d.ts +3 -3
  70. package/types/control/LayerSwitcher.d.ts +1 -1
  71. package/types/ellipsoid/Ellipsoid.d.ts +9 -2
  72. package/types/entity/BillboardHandler.d.ts +0 -4
  73. package/types/entity/EntityCollection.d.ts +0 -8
  74. package/types/entity/LabelHandler.d.ts +0 -2
  75. package/types/entity/Polyline.d.ts +1 -1
  76. package/types/layer/KML.d.ts +11 -11
  77. package/types/layer/Layer.d.ts +4 -0
  78. package/types/layer/Vector.d.ts +1 -8
  79. package/types/math/Line2.d.ts +4 -4
  80. package/types/math/Ray.d.ts +2 -2
  81. package/types/math/Vec2.d.ts +1 -1
  82. package/types/math/Vec3.d.ts +1 -1
  83. package/types/math/Vec4.d.ts +2 -2
  84. package/types/math.d.ts +1 -1
  85. package/types/renderer/Renderer.d.ts +1 -1
  86. package/types/renderer/RendererEvents.d.ts +1 -1
  87. package/types/shaders/label.d.ts +1 -1
  88. package/types/utils/FontAtlas.d.ts +3 -2
  89. package/types/utils/TextureAtlas.d.ts +3 -3
  90. package/types/utils/VectorTileCreator.d.ts +4 -4
  91. package/types/utils/shared.d.ts +1 -1
  92. package/types/webgl/Handler.d.ts +6 -31
  93. package/types/webgl/Program.d.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openglobus/og",
3
- "version": "0.12.4",
3
+ "version": "0.13.2",
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"
@@ -43,24 +43,24 @@
43
43
  "./css/og.css": "./css/og.css"
44
44
  },
45
45
  "devDependencies": {
46
- "@babel/preset-env": "^7.16.8",
46
+ "@babel/preset-env": "^7.16.11",
47
47
  "@rollup/plugin-json": "^4.1.0",
48
48
  "@types/jest": "^27.4.0",
49
- "eslint": "^8.6.0",
49
+ "eslint": "^8.7.0",
50
50
  "jaguarjs-jsdoc": "^1.1.0",
51
51
  "jest": "^27.4.7",
52
52
  "jest-canvas-mock": "^2.3.1",
53
53
  "jest-webgl-canvas-mock": "^0.2.3",
54
- "jsdoc": "^3.6.7",
55
- "lint-staged": "^12.1.7",
54
+ "jsdoc": "^3.6.10",
55
+ "lint-staged": "^12.3.1",
56
56
  "local-web-server": "^5.1.1",
57
57
  "msdf-bmfont-xml": "^2.5.4",
58
58
  "postcss": "^8.4.5",
59
59
  "prettier": "^2.5.1",
60
- "rollup": "^2.63.0",
60
+ "rollup": "^2.66.1",
61
61
  "rollup-plugin-postcss": "^4.0.2",
62
62
  "rollup-plugin-terser": "^7.0.2",
63
- "typescript": "^4.5.4"
63
+ "typescript": "^4.5.5"
64
64
  },
65
65
  "lint-staged": {
66
66
  "*.{js,ts}": [
package/src/og/Extent.js CHANGED
@@ -19,15 +19,15 @@ export class Extent {
19
19
  * @param {LonLat} [sw] - South West extent corner coordiantes.
20
20
  * @param {LonLat} [ne] - North East extent corner coordiantes.
21
21
  */
22
- constructor(sw, ne) {
22
+ constructor(sw = new LonLat(), ne = new LonLat()) {
23
23
  /**
24
24
  * @public
25
25
  */
26
- this.southWest = sw || new LonLat();
26
+ this.southWest = sw;
27
27
  /**
28
28
  * @public
29
29
  */
30
- this.northEast = ne || new LonLat();
30
+ this.northEast = ne;
31
31
  }
32
32
 
33
33
  /**
package/src/og/Globe.js CHANGED
@@ -1,103 +1,105 @@
1
- /**
2
- * @module og/Globe
3
- */
4
-
5
- "use strict";
6
-
7
- import { CompassButton } from "./control/CompassButton.js";
8
- import { EarthCoordinates } from "./control/EarthCoordinates.js";
9
- import { EarthNavigation } from "./control/EarthNavigation.js";
10
- import { MouseNavigation } from "./control/MouseNavigation.js";
11
- import { ScaleControl } from "./control/ScaleControl.js";
12
- import { Sun } from "./control/Sun.js";
13
- import { TouchNavigation } from "./control/TouchNavigation.js";
14
- import { ZoomControl } from "./control/ZoomControl.js";
15
- import { Renderer } from "./renderer/Renderer.js";
16
- import { Planet } from "./scene/Planet.js";
17
- import { EmptyTerrain } from "./terrain/EmptyTerrain.js";
18
- import { isEmpty } from "./utils/shared.js";
1
+ /**
2
+ * @module og/Globe
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { CompassButton } from "./control/CompassButton.js";
8
+ import { EarthCoordinates } from "./control/EarthCoordinates.js";
9
+ import { EarthNavigation } from "./control/EarthNavigation.js";
10
+ import { MouseNavigation } from "./control/MouseNavigation.js";
11
+ import { ScaleControl } from "./control/ScaleControl.js";
12
+ import { Sun } from "./control/Sun.js";
13
+ import { TouchNavigation } from "./control/TouchNavigation.js";
14
+ import { ZoomControl } from "./control/ZoomControl.js";
15
+ import { Renderer } from "./renderer/Renderer.js";
16
+ import { Planet } from "./scene/Planet.js";
17
+ import { EmptyTerrain } from "./terrain/EmptyTerrain.js";
18
+ import { isEmpty } from "./utils/shared.js";
19
19
  import { Handler } from "./webgl/Handler.js";
20
-
21
- /** @const {string} */
22
- const CANVAS_ID_PREFIX = "globus_viewport_";
23
- /** @const {string} */
24
- const PLANET_NAME_PREFIX = "globus_planet_";
25
-
26
- /**
27
- * Creates a WebGL context with globe.
28
- * @class
29
- *
30
- * @example <caption>Basic initialization</caption>
31
- * globus = new og.Globe({
32
- * 'atmosphere': false,
33
- * 'target': 'globus',
34
- * 'name': 'Earth',
35
- * 'controls': [
36
- * new og.control.MouseNavigation({ autoActivate: true }),
37
- * new og.control.KeyboardNavigation({ autoActivate: true }),
38
- * new og.control.EarthCoordinates({ autoActivate: true, center: false }),
39
- * new og.control.LayerSwitcher({ autoActivate: true }),
40
- * new og.control.ZoomControl({ autoActivate: true }),
41
- * new og.control.TouchNavigation({ autoActivate: true }),
42
- * new og.control.Sun({ autoActivate: true })
43
- * ],
44
- * 'terrain': new og.terrain.GlobusTerrain(),
45
- * 'layers': [
46
- * new og.layer.XYZ("OpenStreetMap", { isBaseLayer: true, url: "http://b.tile.openstreetmap.org/{z}/{x}/{y}.png", visibility: true, attribution: 'Data @ <a href="http://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="http://www.openstreetmap.org/copyright">ODbL</a>' })
47
- * ],
48
- * 'autoActivate': true
49
- * });
50
- *
51
- * @param {object} options - Options:
52
- * @param {string} options.target - HTML element id where planet canvas have to be created.
53
- * @param {RenderNode} [options.skybox] - Render skybox. null - default.
54
- * @param {string} [options.name] - Planet name. Default is unic identifier.
55
- * @param {Terrain} [options.terrain] - Terrain provider. Default no terrain - og.terrain.EmptyTerrain.
56
- * @param {Array.<control.Control>} [options.controls] - Renderer controls array.
57
- * @param {Array.<Layer>} [options.layers] - Planet layers.
58
- * @param {Extent} [options.viewExtent] - Viewable starting extent.
59
- * @param {boolean} [options.autoActivate] - Globe rendering auto activation flag. True is default.
60
- * @param {DOMElement} [options.attributionContainer] - Container for attribution list.
61
- * @param {Number} [options.maxGridSize] = Maximal segment grid size. 128 is default
62
- * @param {boolean} [options.useSpecularTexture] - use specular water mask
20
+ import { createColorRGB } from "./utils/shared.js";
21
+ import { Vec3 } from "./math/Vec3.js";
22
+
23
+ /** @const {string} */
24
+ const CANVAS_ID_PREFIX = "globus_viewport_";
25
+ /** @const {string} */
26
+ const PLANET_NAME_PREFIX = "globus_planet_";
27
+
28
+ /**
29
+ * Creates a WebGL context with globe.
30
+ * @class
31
+ *
32
+ * @example <caption>Basic initialization</caption>
33
+ * globus = new og.Globe({
34
+ * 'atmosphere': false,
35
+ * 'target': 'globus',
36
+ * 'name': 'Earth',
37
+ * 'controls': [
38
+ * new og.control.MouseNavigation({ autoActivate: true }),
39
+ * new og.control.KeyboardNavigation({ autoActivate: true }),
40
+ * new og.control.EarthCoordinates({ autoActivate: true, center: false }),
41
+ * new og.control.LayerSwitcher({ autoActivate: true }),
42
+ * new og.control.ZoomControl({ autoActivate: true }),
43
+ * new og.control.TouchNavigation({ autoActivate: true }),
44
+ * new og.control.Sun({ autoActivate: true })
45
+ * ],
46
+ * 'terrain': new og.terrain.GlobusTerrain(),
47
+ * 'layers': [
48
+ * new og.layer.XYZ("OpenStreetMap", { isBaseLayer: true, url: "http://b.tile.openstreetmap.org/{z}/{x}/{y}.png", visibility: true, attribution: 'Data @ <a href="http://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="http://www.openstreetmap.org/copyright">ODbL</a>' })
49
+ * ],
50
+ * 'autoActivate': true
51
+ * });
52
+ *
53
+ * @param {object} options - Options:
54
+ * @param {string} options.target - HTML element id where planet canvas have to be created.
55
+ * @param {RenderNode} [options.skybox] - Render skybox. null - default.
56
+ * @param {string} [options.name] - Planet name. Default is unic identifier.
57
+ * @param {Terrain} [options.terrain] - Terrain provider. Default no terrain - og.terrain.EmptyTerrain.
58
+ * @param {Array.<control.Control>} [options.controls] - Renderer controls array.
59
+ * @param {Array.<Layer>} [options.layers] - Planet layers.
60
+ * @param {Extent} [options.viewExtent] - Viewable starting extent.
61
+ * @param {boolean} [options.autoActivate] - Globe rendering auto activation flag. True is default.
62
+ * @param {DOMElement} [options.attributionContainer] - Container for attribution list.
63
+ * @param {Number} [options.maxGridSize] = Maximal segment grid size. 128 is default
64
+ * @param {boolean} [options.useSpecularTexture] - use specular water mask
63
65
  * @param {boolean} [options.useNightTexture] - show night cities
64
66
  * @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
67
- * @param {Number} [options.minEqualZoomAltitude=10000.0] - Minimal altitude since segments on the screen bacame the same zoom level
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] -
70
- */
71
-
72
- class Globe {
73
- /**
74
- * @param {*} options
75
- */
76
- constructor(options) {
77
- // Canvas creation
78
- var _canvasId = CANVAS_ID_PREFIX + Globe._staticCounter++;
79
-
80
- this._canvas = document.createElement("canvas");
81
- this._canvas.id = _canvasId;
82
- this._canvas.style.width = "100%";
83
- this._canvas.style.height = "100%";
84
- this._canvas.style.display = "block";
85
- this._canvas.style.opacity = "0.0";
86
- this._canvas.style.transition = "opacity 1.0s";
87
-
88
- /**
89
- * Dom element where WebGL canvas creates
90
- * @public
91
- * @type {Element}
92
- */
93
- if (options.target instanceof HTMLElement) {
94
- this.div = options.target;
95
- } else {
96
- this.div =
97
- document.getElementById(options.target) || document.querySelector(options.target);
98
- }
99
-
100
- this.div.appendChild(this._canvas);
67
+ * @param {Number} [options.minAltitude=1.0] - Minimal camera altitude above terrain
68
+ * @param {Number} [options.maxEqualZoomAltitude=15000000.0] - Maximal altitude since segments on the screen bacame the same zoom level
69
+ * @param {Number} [options.minEqualZoomAltitude=10000.0] - Minimal altitude since segments on the screen bacame the same zoom level
70
+ * @param {Number} [options.minEqualZoomCameraSlope=0.8] - Minimal camera slope above te globe where segments on the screen bacame the same zoom level
71
+ * @param {Number} [options.loadingBatchSize=12] -
72
+ */
73
+
74
+ class Globe {
75
+ /**
76
+ * @param {*} options
77
+ */
78
+ constructor(options) {
79
+ // Canvas creation
80
+ var _canvasId = CANVAS_ID_PREFIX + Globe._staticCounter++;
81
+
82
+ this._canvas = document.createElement("canvas");
83
+ this._canvas.id = _canvasId;
84
+ this._canvas.style.width = "100%";
85
+ this._canvas.style.height = "100%";
86
+ this._canvas.style.display = "block";
87
+ this._canvas.style.opacity = "0.0";
88
+ this._canvas.style.transition = "opacity 1.0s";
89
+
90
+ /**
91
+ * Dom element where WebGL canvas creates
92
+ * @public
93
+ * @type {Element}
94
+ */
95
+ if (options.target instanceof HTMLElement) {
96
+ this.div = options.target;
97
+ } else {
98
+ this.div =
99
+ document.getElementById(options.target) || document.querySelector(options.target);
100
+ }
101
+
102
+ this.div.appendChild(this._canvas);
101
103
  this.div.classList.add("ogViewport");
102
104
 
103
105
  document.addEventListener("visibilitychange", () => {
@@ -107,184 +109,184 @@ class Globe {
107
109
  } else {
108
110
  this.renderer.handler.stop();
109
111
  }
110
- });
111
-
112
- function _disableWheel(e) {
113
- e.preventDefault();
114
- }
115
-
116
- this.div.onmouseenter = function () {
117
- document.addEventListener("mousewheel", _disableWheel, {
118
- capture: false,
119
- passive: false
120
- });
121
- };
122
- this.div.onmouseleave = function () {
123
- document.removeEventListener("mousewheel", _disableWheel);
124
- };
125
-
126
- /**
127
- * Interface for the renderer context(events, input states, renderer nodes etc.)
128
- * @public
129
- * @type {Renderer}
130
- */
131
- this.renderer = new Renderer(
112
+ });
113
+
114
+ function _disableWheel(e) {
115
+ e.preventDefault();
116
+ }
117
+
118
+ this.div.onmouseenter = function () {
119
+ document.addEventListener("mousewheel", _disableWheel, {
120
+ capture: false,
121
+ passive: false
122
+ });
123
+ };
124
+ this.div.onmouseleave = function () {
125
+ document.removeEventListener("mousewheel", _disableWheel);
126
+ };
127
+
128
+ /**
129
+ * Interface for the renderer context(events, input states, renderer nodes etc.)
130
+ * @public
131
+ * @type {Renderer}
132
+ */
133
+ this.renderer = new Renderer(
132
134
  new Handler(_canvasId, {
133
- pixelRatio: window.devicePixelRatio + 0.15,
134
- context: {
135
- alpha: false,
136
- antialias: false,
137
- powerPreference: "high-performance"
138
- }
139
- }),
140
- {
141
- autoActivate: false
142
- }
143
- );
144
- this.renderer.initialize();
145
- this.renderer.div = this.div;
146
- this.renderer.div.attributions = document.createElement("div");
147
- if (options.attributionContainer) {
148
- options.attributionContainer.appendChild(this.renderer.div.attributions);
149
- } else {
150
- this.renderer.div.attributions.classList.add("ogAttribution");
151
- this.div.appendChild(this.renderer.div.attributions);
152
- }
153
-
154
- // Skybox
155
- if (options.skybox) {
156
- this.renderer.addNode(options.skybox);
157
- }
158
-
159
- /**
160
- * Planet node name. Access with this.renderer.<name>
161
- * @private
162
- * @type {String}
163
- */
164
- this._planetName = options.name ? options.name : PLANET_NAME_PREFIX + Globe._staticCounter;
165
-
166
- if (options.atmosphere) {
167
- /**
168
- * Render node renders a planet.
169
- * @public
170
- * @type {Planet|og.scene.PlanetAtmosphere}
171
- */
172
- // TODO:
173
- } else {
174
- this.planet = new Planet({
135
+ pixelRatio: window.devicePixelRatio + 0.15,
136
+ context: {
137
+ alpha: false,
138
+ antialias: false,
139
+ powerPreference: "high-performance"
140
+ }
141
+ }), {
142
+ autoActivate: false,
143
+ backgroundColor: createColorRGB(options.backgroundColor, new Vec3(115 / 255, 203 / 255, 249 / 255))
144
+ }
145
+ );
146
+ this.renderer.initialize();
147
+ this.renderer.div = this.div;
148
+ this.renderer.div.attributions = document.createElement("div");
149
+ if (options.attributionContainer) {
150
+ options.attributionContainer.appendChild(this.div.attributions);
151
+ } else {
152
+ this.div.attributions.classList.add("ogAttribution");
153
+ this.div.appendChild(this.div.attributions);
154
+ }
155
+
156
+ // Skybox
157
+ if (options.skybox) {
158
+ this.renderer.addNode(options.skybox);
159
+ }
160
+
161
+ /**
162
+ * Planet node name. Access with this.renderer.<name>
163
+ * @private
164
+ * @type {String}
165
+ */
166
+ this._planetName = options.name ? options.name : PLANET_NAME_PREFIX + Globe._staticCounter;
167
+
168
+ if (options.atmosphere) {
169
+ /**
170
+ * Render node renders a planet.
171
+ * @public
172
+ * @type {Planet|og.scene.PlanetAtmosphere}
173
+ */
174
+ // TODO:
175
+ } else {
176
+ this.planet = new Planet({
175
177
  name: this._planetName,
176
- frustums: options.frustums,
177
- ellipsoid: options.ellipsoid,
178
- maxGridSize: options.maxGridSize,
179
- useNightTexture: options.useNightTexture,
180
- useSpecularTexture: options.useSpecularTexture,
181
- minAltitude: options.minAltitude,
182
- maxAltitude: options.maxAltitude || 15000000,
183
- maxEqualZoomAltitude: options.maxEqualZoomAltitude,
184
- minEqualZoomAltitude: options.minEqualZoomAltitude,
178
+ frustums: options.frustums,
179
+ ellipsoid: options.ellipsoid,
180
+ maxGridSize: options.maxGridSize,
181
+ useNightTexture: options.useNightTexture,
182
+ useSpecularTexture: options.useSpecularTexture,
183
+ minAltitude: options.minAltitude,
184
+ maxAltitude: options.maxAltitude || 15000000,
185
+ maxEqualZoomAltitude: options.maxEqualZoomAltitude,
186
+ minEqualZoomAltitude: options.minEqualZoomAltitude,
185
187
  minEqualZoomCameraSlope: options.minEqualZoomCameraSlope,
186
- loadingBatchSize: options.loadingBatchSize
187
- });
188
- }
189
-
190
- // Attach terrain provider
191
- if (options.terrain) {
192
- this.planet.setTerrain(options.terrain);
193
- } else {
194
- this.planet.setTerrain(new EmptyTerrain());
195
- }
196
-
197
- this.renderer.addNode(this.planet);
198
-
199
- // Add controls
200
- if (options.controls) {
201
- this.planet.addControls(options.controls);
202
- } else {
203
- this.planet.addControls([
204
- new ZoomControl(),
205
- options.useEarthNavigation
206
- ? new EarthNavigation()
207
- : new MouseNavigation({
208
- minSlope: options.minSlope
209
- }),
210
- new TouchNavigation(),
211
- new EarthCoordinates(),
212
- new ScaleControl(),
213
- new CompassButton(options)
214
- ]);
215
- }
216
-
217
- var _controls = this.renderer.controls;
218
- for (var i in _controls) {
219
- if (_controls[i] instanceof Sun) {
220
- this.sun = _controls[i];
221
- break;
222
- }
223
- }
224
-
225
- if (!this.sun) {
226
- this.sun = new Sun();
227
- this.planet.addControl(this.sun);
228
- }
229
-
230
- if (options.sun) {
231
- if (options.sun.active !== undefined && !options.sun.active) {
232
- this.sun.deactivate();
233
- }
234
- }
235
-
236
- if (options.layers) {
237
- this.planet.addLayers(options.layers);
238
- }
239
-
240
- // TODO: view center, altitude, extent
241
- let ve = options.viewExtent;
242
- if (ve) {
243
- if (ve instanceof Array) {
244
- this.planet.viewExtentArr(ve);
245
- } else {
246
- this.planet.viewExtent(ve);
247
- }
248
- }
249
-
250
- this._opacityCounter = 0;
251
- this._fadeHandler = null;
252
- this._stopHandler = null;
253
-
254
- // Run!
255
- if (options.autoActivate || isEmpty(options.autoActivate)) {
256
- this.renderer.start();
257
- this.fadeIn();
258
- }
259
- }
260
-
261
- /**
262
- * Starts screen brightness fading in effect by the duration time.
263
- * @public
264
- */
265
- fadeIn() {
266
- this._canvas.style.opacity = 1.0;
267
- }
268
-
269
- /**
270
- * Starts screen brightness fading out effect by the duration time.
271
- * @public
272
- * @param {number} duration - Fadeout duration time.
273
- */
274
- fadeOut() {
275
- this._canvas.style.opacity = 0.0;
276
- }
277
-
278
- static get _staticCounter() {
279
- if (!this._counter && this._counter !== 0) {
280
- this._counter = 0;
281
- }
282
- return this._counter;
283
- }
284
-
285
- static set _staticCounter(n) {
286
- this._counter = n;
287
- }
288
- }
289
-
290
- export { Globe };
188
+ loadingBatchSize: options.loadingBatchSize
189
+ });
190
+ }
191
+
192
+ // Attach terrain provider
193
+ if (options.terrain) {
194
+ this.planet.setTerrain(options.terrain);
195
+ } else {
196
+ this.planet.setTerrain(new EmptyTerrain());
197
+ }
198
+
199
+ this.renderer.addNode(this.planet);
200
+
201
+ // Add controls
202
+ if (options.controls) {
203
+ this.planet.addControls(options.controls);
204
+ } else {
205
+ this.planet.addControls([
206
+ new ZoomControl(),
207
+ options.useEarthNavigation
208
+ ? new EarthNavigation()
209
+ : new MouseNavigation({
210
+ minSlope: options.minSlope
211
+ }),
212
+ new TouchNavigation(),
213
+ new EarthCoordinates(),
214
+ new ScaleControl(),
215
+ new CompassButton(options)
216
+ ]);
217
+ }
218
+
219
+ var _controls = this.renderer.controls;
220
+ for (var i in _controls) {
221
+ if (_controls[i] instanceof Sun) {
222
+ this.sun = _controls[i];
223
+ break;
224
+ }
225
+ }
226
+
227
+ if (!this.sun) {
228
+ this.sun = new Sun();
229
+ this.planet.addControl(this.sun);
230
+ }
231
+
232
+ if (options.sun) {
233
+ if (options.sun.active !== undefined && !options.sun.active) {
234
+ this.sun.deactivate();
235
+ }
236
+ }
237
+
238
+ if (options.layers) {
239
+ this.planet.addLayers(options.layers);
240
+ }
241
+
242
+ // TODO: view center, altitude, extent
243
+ let ve = options.viewExtent;
244
+ if (ve) {
245
+ if (ve instanceof Array) {
246
+ this.planet.viewExtentArr(ve);
247
+ } else {
248
+ this.planet.viewExtent(ve);
249
+ }
250
+ }
251
+
252
+ this._opacityCounter = 0;
253
+ this._fadeHandler = null;
254
+ this._stopHandler = null;
255
+
256
+ // Run!
257
+ if (options.autoActivate || isEmpty(options.autoActivate)) {
258
+ this.renderer.start();
259
+ this.fadeIn();
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Starts screen brightness fading in effect by the duration time.
265
+ * @public
266
+ */
267
+ fadeIn() {
268
+ this._canvas.style.opacity = 1.0;
269
+ }
270
+
271
+ /**
272
+ * Starts screen brightness fading out effect by the duration time.
273
+ * @public
274
+ * @param {number} duration - Fadeout duration time.
275
+ */
276
+ fadeOut() {
277
+ this._canvas.style.opacity = 0.0;
278
+ }
279
+
280
+ static get _staticCounter() {
281
+ if (!this._counter && this._counter !== 0) {
282
+ this._counter = 0;
283
+ }
284
+ return this._counter;
285
+ }
286
+
287
+ static set _staticCounter(n) {
288
+ this._counter = n;
289
+ }
290
+ }
291
+
292
+ export { Globe };
@@ -13,15 +13,15 @@ class ImageCanvas {
13
13
  * @param {number} [width] - Canvas width. Default 256.
14
14
  * @param {number} [height] - Canvas height. Default 256.
15
15
  */
16
- constructor(width, height) {
16
+ constructor(width = 256, height = 256) {
17
17
  /**
18
18
  * Canvas object.
19
19
  * @protected
20
20
  * @type {Object}
21
21
  */
22
22
  this._canvas = document.createElement("canvas");
23
- this._canvas.width = width || 256;
24
- this._canvas.height = height || 256;
23
+ this._canvas.width = width;
24
+ this._canvas.height = height;
25
25
 
26
26
  /**
27
27
  * Canvas context.